Merge git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6
[wrt350n-kernel.git] / sound / pci / hda / patch_realtek.c
blob4b64f8f112ca6343fa7531dad48e4c7bd8af67be
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"
34 #define ALC880_FRONT_EVENT 0x01
35 #define ALC880_DCVOL_EVENT 0x02
36 #define ALC880_HP_EVENT 0x04
37 #define ALC880_MIC_EVENT 0x08
39 /* ALC880 board config type */
40 enum {
41 ALC880_3ST,
42 ALC880_3ST_DIG,
43 ALC880_5ST,
44 ALC880_5ST_DIG,
45 ALC880_W810,
46 ALC880_Z71V,
47 ALC880_6ST,
48 ALC880_6ST_DIG,
49 ALC880_F1734,
50 ALC880_ASUS,
51 ALC880_ASUS_DIG,
52 ALC880_ASUS_W1V,
53 ALC880_ASUS_DIG2,
54 ALC880_FUJITSU,
55 ALC880_UNIWILL_DIG,
56 ALC880_UNIWILL,
57 ALC880_UNIWILL_P53,
58 ALC880_CLEVO,
59 ALC880_TCL_S700,
60 ALC880_LG,
61 ALC880_LG_LW,
62 #ifdef CONFIG_SND_DEBUG
63 ALC880_TEST,
64 #endif
65 ALC880_AUTO,
66 ALC880_MODEL_LAST /* last tag */
69 /* ALC260 models */
70 enum {
71 ALC260_BASIC,
72 ALC260_HP,
73 ALC260_HP_3013,
74 ALC260_FUJITSU_S702X,
75 ALC260_ACER,
76 ALC260_WILL,
77 ALC260_REPLACER_672V,
78 #ifdef CONFIG_SND_DEBUG
79 ALC260_TEST,
80 #endif
81 ALC260_AUTO,
82 ALC260_MODEL_LAST /* last tag */
85 /* ALC262 models */
86 enum {
87 ALC262_BASIC,
88 ALC262_HIPPO,
89 ALC262_HIPPO_1,
90 ALC262_FUJITSU,
91 ALC262_HP_BPC,
92 ALC262_HP_BPC_D7000_WL,
93 ALC262_HP_BPC_D7000_WF,
94 ALC262_HP_TC_T5735,
95 ALC262_HP_RP5700,
96 ALC262_BENQ_ED8,
97 ALC262_SONY_ASSAMD,
98 ALC262_BENQ_T31,
99 ALC262_ULTRA,
100 ALC262_AUTO,
101 ALC262_MODEL_LAST /* last tag */
104 /* ALC268 models */
105 enum {
106 ALC268_3ST,
107 ALC268_TOSHIBA,
108 ALC268_ACER,
109 ALC268_DELL,
110 #ifdef CONFIG_SND_DEBUG
111 ALC268_TEST,
112 #endif
113 ALC268_AUTO,
114 ALC268_MODEL_LAST /* last tag */
117 /* ALC269 models */
118 enum {
119 ALC269_BASIC,
120 ALC269_AUTO,
121 ALC269_MODEL_LAST /* last tag */
124 /* ALC861 models */
125 enum {
126 ALC861_3ST,
127 ALC660_3ST,
128 ALC861_3ST_DIG,
129 ALC861_6ST_DIG,
130 ALC861_UNIWILL_M31,
131 ALC861_TOSHIBA,
132 ALC861_ASUS,
133 ALC861_ASUS_LAPTOP,
134 ALC861_AUTO,
135 ALC861_MODEL_LAST,
138 /* ALC861-VD models */
139 enum {
140 ALC660VD_3ST,
141 ALC660VD_3ST_DIG,
142 ALC861VD_3ST,
143 ALC861VD_3ST_DIG,
144 ALC861VD_6ST_DIG,
145 ALC861VD_LENOVO,
146 ALC861VD_DALLAS,
147 ALC861VD_HP,
148 ALC861VD_AUTO,
149 ALC861VD_MODEL_LAST,
152 /* ALC662 models */
153 enum {
154 ALC662_3ST_2ch_DIG,
155 ALC662_3ST_6ch_DIG,
156 ALC662_3ST_6ch,
157 ALC662_5ST_DIG,
158 ALC662_LENOVO_101E,
159 ALC662_ASUS_EEEPC_P701,
160 ALC662_ASUS_EEEPC_EP20,
161 ALC662_AUTO,
162 ALC662_MODEL_LAST,
165 /* ALC882 models */
166 enum {
167 ALC882_3ST_DIG,
168 ALC882_6ST_DIG,
169 ALC882_ARIMA,
170 ALC882_W2JC,
171 ALC882_TARGA,
172 ALC882_ASUS_A7J,
173 ALC882_ASUS_A7M,
174 ALC885_MACPRO,
175 ALC885_MBP3,
176 ALC885_IMAC24,
177 ALC882_AUTO,
178 ALC882_MODEL_LAST,
181 /* ALC883 models */
182 enum {
183 ALC883_3ST_2ch_DIG,
184 ALC883_3ST_6ch_DIG,
185 ALC883_3ST_6ch,
186 ALC883_6ST_DIG,
187 ALC883_TARGA_DIG,
188 ALC883_TARGA_2ch_DIG,
189 ALC883_ACER,
190 ALC883_ACER_ASPIRE,
191 ALC883_MEDION,
192 ALC883_MEDION_MD2,
193 ALC883_LAPTOP_EAPD,
194 ALC883_LENOVO_101E_2ch,
195 ALC883_LENOVO_NB0763,
196 ALC888_LENOVO_MS7195_DIG,
197 ALC883_HAIER_W66,
198 ALC888_6ST_HP,
199 ALC888_3ST_HP,
200 ALC888_6ST_DELL,
201 ALC883_MITAC,
202 ALC883_AUTO,
203 ALC883_MODEL_LAST,
206 /* for GPIO Poll */
207 #define GPIO_MASK 0x03
209 struct alc_spec {
210 /* codec parameterization */
211 struct snd_kcontrol_new *mixers[5]; /* mixer arrays */
212 unsigned int num_mixers;
214 const struct hda_verb *init_verbs[5]; /* initialization verbs
215 * don't forget NULL
216 * termination!
218 unsigned int num_init_verbs;
220 char *stream_name_analog; /* analog PCM stream */
221 struct hda_pcm_stream *stream_analog_playback;
222 struct hda_pcm_stream *stream_analog_capture;
223 struct hda_pcm_stream *stream_analog_alt_playback;
224 struct hda_pcm_stream *stream_analog_alt_capture;
226 char *stream_name_digital; /* digital PCM stream */
227 struct hda_pcm_stream *stream_digital_playback;
228 struct hda_pcm_stream *stream_digital_capture;
230 /* playback */
231 struct hda_multi_out multiout; /* playback set-up
232 * max_channels, dacs must be set
233 * dig_out_nid and hp_nid are optional
235 hda_nid_t alt_dac_nid;
237 /* capture */
238 unsigned int num_adc_nids;
239 hda_nid_t *adc_nids;
240 hda_nid_t dig_in_nid; /* digital-in NID; optional */
242 /* capture source */
243 unsigned int num_mux_defs;
244 const struct hda_input_mux *input_mux;
245 unsigned int cur_mux[3];
247 /* channel model */
248 const struct hda_channel_mode *channel_mode;
249 int num_channel_mode;
250 int need_dac_fix;
252 /* PCM information */
253 struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */
255 /* dynamic controls, init_verbs and input_mux */
256 struct auto_pin_cfg autocfg;
257 unsigned int num_kctl_alloc, num_kctl_used;
258 struct snd_kcontrol_new *kctl_alloc;
259 struct hda_input_mux private_imux;
260 hda_nid_t private_dac_nids[AUTO_CFG_MAX_OUTS];
262 /* hooks */
263 void (*init_hook)(struct hda_codec *codec);
264 void (*unsol_event)(struct hda_codec *codec, unsigned int res);
266 /* for pin sensing */
267 unsigned int sense_updated: 1;
268 unsigned int jack_present: 1;
269 unsigned int master_sw: 1;
271 /* for virtual master */
272 hda_nid_t vmaster_nid;
273 u32 vmaster_tlv[4];
274 #ifdef CONFIG_SND_HDA_POWER_SAVE
275 struct hda_loopback_check loopback;
276 #endif
280 * configuration template - to be copied to the spec instance
282 struct alc_config_preset {
283 struct snd_kcontrol_new *mixers[5]; /* should be identical size
284 * with spec
286 const struct hda_verb *init_verbs[5];
287 unsigned int num_dacs;
288 hda_nid_t *dac_nids;
289 hda_nid_t dig_out_nid; /* optional */
290 hda_nid_t hp_nid; /* optional */
291 unsigned int num_adc_nids;
292 hda_nid_t *adc_nids;
293 hda_nid_t dig_in_nid;
294 unsigned int num_channel_mode;
295 const struct hda_channel_mode *channel_mode;
296 int need_dac_fix;
297 unsigned int num_mux_defs;
298 const struct hda_input_mux *input_mux;
299 void (*unsol_event)(struct hda_codec *, unsigned int);
300 void (*init_hook)(struct hda_codec *);
301 #ifdef CONFIG_SND_HDA_POWER_SAVE
302 struct hda_amp_list *loopbacks;
303 #endif
308 * input MUX handling
310 static int alc_mux_enum_info(struct snd_kcontrol *kcontrol,
311 struct snd_ctl_elem_info *uinfo)
313 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
314 struct alc_spec *spec = codec->spec;
315 unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id);
316 if (mux_idx >= spec->num_mux_defs)
317 mux_idx = 0;
318 return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo);
321 static int alc_mux_enum_get(struct snd_kcontrol *kcontrol,
322 struct snd_ctl_elem_value *ucontrol)
324 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
325 struct alc_spec *spec = codec->spec;
326 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
328 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
329 return 0;
332 static int alc_mux_enum_put(struct snd_kcontrol *kcontrol,
333 struct snd_ctl_elem_value *ucontrol)
335 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
336 struct alc_spec *spec = codec->spec;
337 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
338 unsigned int mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx;
339 return snd_hda_input_mux_put(codec, &spec->input_mux[mux_idx], ucontrol,
340 spec->adc_nids[adc_idx],
341 &spec->cur_mux[adc_idx]);
346 * channel mode setting
348 static int alc_ch_mode_info(struct snd_kcontrol *kcontrol,
349 struct snd_ctl_elem_info *uinfo)
351 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
352 struct alc_spec *spec = codec->spec;
353 return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
354 spec->num_channel_mode);
357 static int alc_ch_mode_get(struct snd_kcontrol *kcontrol,
358 struct snd_ctl_elem_value *ucontrol)
360 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
361 struct alc_spec *spec = codec->spec;
362 return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
363 spec->num_channel_mode,
364 spec->multiout.max_channels);
367 static int alc_ch_mode_put(struct snd_kcontrol *kcontrol,
368 struct snd_ctl_elem_value *ucontrol)
370 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
371 struct alc_spec *spec = codec->spec;
372 int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
373 spec->num_channel_mode,
374 &spec->multiout.max_channels);
375 if (err >= 0 && spec->need_dac_fix)
376 spec->multiout.num_dacs = spec->multiout.max_channels / 2;
377 return err;
381 * Control the mode of pin widget settings via the mixer. "pc" is used
382 * instead of "%" to avoid consequences of accidently treating the % as
383 * being part of a format specifier. Maximum allowed length of a value is
384 * 63 characters plus NULL terminator.
386 * Note: some retasking pin complexes seem to ignore requests for input
387 * states other than HiZ (eg: PIN_VREFxx) and revert to HiZ if any of these
388 * are requested. Therefore order this list so that this behaviour will not
389 * cause problems when mixer clients move through the enum sequentially.
390 * NIDs 0x0f and 0x10 have been observed to have this behaviour as of
391 * March 2006.
393 static char *alc_pin_mode_names[] = {
394 "Mic 50pc bias", "Mic 80pc bias",
395 "Line in", "Line out", "Headphone out",
397 static unsigned char alc_pin_mode_values[] = {
398 PIN_VREF50, PIN_VREF80, PIN_IN, PIN_OUT, PIN_HP,
400 /* The control can present all 5 options, or it can limit the options based
401 * in the pin being assumed to be exclusively an input or an output pin. In
402 * addition, "input" pins may or may not process the mic bias option
403 * depending on actual widget capability (NIDs 0x0f and 0x10 don't seem to
404 * accept requests for bias as of chip versions up to March 2006) and/or
405 * wiring in the computer.
407 #define ALC_PIN_DIR_IN 0x00
408 #define ALC_PIN_DIR_OUT 0x01
409 #define ALC_PIN_DIR_INOUT 0x02
410 #define ALC_PIN_DIR_IN_NOMICBIAS 0x03
411 #define ALC_PIN_DIR_INOUT_NOMICBIAS 0x04
413 /* Info about the pin modes supported by the different pin direction modes.
414 * For each direction the minimum and maximum values are given.
416 static signed char alc_pin_mode_dir_info[5][2] = {
417 { 0, 2 }, /* ALC_PIN_DIR_IN */
418 { 3, 4 }, /* ALC_PIN_DIR_OUT */
419 { 0, 4 }, /* ALC_PIN_DIR_INOUT */
420 { 2, 2 }, /* ALC_PIN_DIR_IN_NOMICBIAS */
421 { 2, 4 }, /* ALC_PIN_DIR_INOUT_NOMICBIAS */
423 #define alc_pin_mode_min(_dir) (alc_pin_mode_dir_info[_dir][0])
424 #define alc_pin_mode_max(_dir) (alc_pin_mode_dir_info[_dir][1])
425 #define alc_pin_mode_n_items(_dir) \
426 (alc_pin_mode_max(_dir)-alc_pin_mode_min(_dir)+1)
428 static int alc_pin_mode_info(struct snd_kcontrol *kcontrol,
429 struct snd_ctl_elem_info *uinfo)
431 unsigned int item_num = uinfo->value.enumerated.item;
432 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
434 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
435 uinfo->count = 1;
436 uinfo->value.enumerated.items = alc_pin_mode_n_items(dir);
438 if (item_num<alc_pin_mode_min(dir) || item_num>alc_pin_mode_max(dir))
439 item_num = alc_pin_mode_min(dir);
440 strcpy(uinfo->value.enumerated.name, alc_pin_mode_names[item_num]);
441 return 0;
444 static int alc_pin_mode_get(struct snd_kcontrol *kcontrol,
445 struct snd_ctl_elem_value *ucontrol)
447 unsigned int i;
448 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
449 hda_nid_t nid = kcontrol->private_value & 0xffff;
450 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
451 long *valp = ucontrol->value.integer.value;
452 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
453 AC_VERB_GET_PIN_WIDGET_CONTROL,
454 0x00);
456 /* Find enumerated value for current pinctl setting */
457 i = alc_pin_mode_min(dir);
458 while (alc_pin_mode_values[i] != pinctl && i <= alc_pin_mode_max(dir))
459 i++;
460 *valp = i <= alc_pin_mode_max(dir) ? i: alc_pin_mode_min(dir);
461 return 0;
464 static int alc_pin_mode_put(struct snd_kcontrol *kcontrol,
465 struct snd_ctl_elem_value *ucontrol)
467 signed int change;
468 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
469 hda_nid_t nid = kcontrol->private_value & 0xffff;
470 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
471 long val = *ucontrol->value.integer.value;
472 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
473 AC_VERB_GET_PIN_WIDGET_CONTROL,
474 0x00);
476 if (val < alc_pin_mode_min(dir) || val > alc_pin_mode_max(dir))
477 val = alc_pin_mode_min(dir);
479 change = pinctl != alc_pin_mode_values[val];
480 if (change) {
481 /* Set pin mode to that requested */
482 snd_hda_codec_write_cache(codec, nid, 0,
483 AC_VERB_SET_PIN_WIDGET_CONTROL,
484 alc_pin_mode_values[val]);
486 /* Also enable the retasking pin's input/output as required
487 * for the requested pin mode. Enum values of 2 or less are
488 * input modes.
490 * Dynamically switching the input/output buffers probably
491 * reduces noise slightly (particularly on input) so we'll
492 * do it. However, having both input and output buffers
493 * enabled simultaneously doesn't seem to be problematic if
494 * this turns out to be necessary in the future.
496 if (val <= 2) {
497 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
498 HDA_AMP_MUTE, HDA_AMP_MUTE);
499 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
500 HDA_AMP_MUTE, 0);
501 } else {
502 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
503 HDA_AMP_MUTE, HDA_AMP_MUTE);
504 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
505 HDA_AMP_MUTE, 0);
508 return change;
511 #define ALC_PIN_MODE(xname, nid, dir) \
512 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
513 .info = alc_pin_mode_info, \
514 .get = alc_pin_mode_get, \
515 .put = alc_pin_mode_put, \
516 .private_value = nid | (dir<<16) }
518 /* A switch control for ALC260 GPIO pins. Multiple GPIOs can be ganged
519 * together using a mask with more than one bit set. This control is
520 * currently used only by the ALC260 test model. At this stage they are not
521 * needed for any "production" models.
523 #ifdef CONFIG_SND_DEBUG
524 #define alc_gpio_data_info snd_ctl_boolean_mono_info
526 static int alc_gpio_data_get(struct snd_kcontrol *kcontrol,
527 struct snd_ctl_elem_value *ucontrol)
529 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
530 hda_nid_t nid = kcontrol->private_value & 0xffff;
531 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
532 long *valp = ucontrol->value.integer.value;
533 unsigned int val = snd_hda_codec_read(codec, nid, 0,
534 AC_VERB_GET_GPIO_DATA, 0x00);
536 *valp = (val & mask) != 0;
537 return 0;
539 static int alc_gpio_data_put(struct snd_kcontrol *kcontrol,
540 struct snd_ctl_elem_value *ucontrol)
542 signed int change;
543 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
544 hda_nid_t nid = kcontrol->private_value & 0xffff;
545 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
546 long val = *ucontrol->value.integer.value;
547 unsigned int gpio_data = snd_hda_codec_read(codec, nid, 0,
548 AC_VERB_GET_GPIO_DATA,
549 0x00);
551 /* Set/unset the masked GPIO bit(s) as needed */
552 change = (val == 0 ? 0 : mask) != (gpio_data & mask);
553 if (val == 0)
554 gpio_data &= ~mask;
555 else
556 gpio_data |= mask;
557 snd_hda_codec_write_cache(codec, nid, 0,
558 AC_VERB_SET_GPIO_DATA, gpio_data);
560 return change;
562 #define ALC_GPIO_DATA_SWITCH(xname, nid, mask) \
563 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
564 .info = alc_gpio_data_info, \
565 .get = alc_gpio_data_get, \
566 .put = alc_gpio_data_put, \
567 .private_value = nid | (mask<<16) }
568 #endif /* CONFIG_SND_DEBUG */
570 /* A switch control to allow the enabling of the digital IO pins on the
571 * ALC260. This is incredibly simplistic; the intention of this control is
572 * to provide something in the test model allowing digital outputs to be
573 * identified if present. If models are found which can utilise these
574 * outputs a more complete mixer control can be devised for those models if
575 * necessary.
577 #ifdef CONFIG_SND_DEBUG
578 #define alc_spdif_ctrl_info snd_ctl_boolean_mono_info
580 static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol,
581 struct snd_ctl_elem_value *ucontrol)
583 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
584 hda_nid_t nid = kcontrol->private_value & 0xffff;
585 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
586 long *valp = ucontrol->value.integer.value;
587 unsigned int val = snd_hda_codec_read(codec, nid, 0,
588 AC_VERB_GET_DIGI_CONVERT_1, 0x00);
590 *valp = (val & mask) != 0;
591 return 0;
593 static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol,
594 struct snd_ctl_elem_value *ucontrol)
596 signed int change;
597 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
598 hda_nid_t nid = kcontrol->private_value & 0xffff;
599 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
600 long val = *ucontrol->value.integer.value;
601 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
602 AC_VERB_GET_DIGI_CONVERT_1,
603 0x00);
605 /* Set/unset the masked control bit(s) as needed */
606 change = (val == 0 ? 0 : mask) != (ctrl_data & mask);
607 if (val==0)
608 ctrl_data &= ~mask;
609 else
610 ctrl_data |= mask;
611 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1,
612 ctrl_data);
614 return change;
616 #define ALC_SPDIF_CTRL_SWITCH(xname, nid, mask) \
617 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
618 .info = alc_spdif_ctrl_info, \
619 .get = alc_spdif_ctrl_get, \
620 .put = alc_spdif_ctrl_put, \
621 .private_value = nid | (mask<<16) }
622 #endif /* CONFIG_SND_DEBUG */
624 /* A switch control to allow the enabling EAPD digital outputs on the ALC26x.
625 * Again, this is only used in the ALC26x test models to help identify when
626 * the EAPD line must be asserted for features to work.
628 #ifdef CONFIG_SND_DEBUG
629 #define alc_eapd_ctrl_info snd_ctl_boolean_mono_info
631 static int alc_eapd_ctrl_get(struct snd_kcontrol *kcontrol,
632 struct snd_ctl_elem_value *ucontrol)
634 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
635 hda_nid_t nid = kcontrol->private_value & 0xffff;
636 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
637 long *valp = ucontrol->value.integer.value;
638 unsigned int val = snd_hda_codec_read(codec, nid, 0,
639 AC_VERB_GET_EAPD_BTLENABLE, 0x00);
641 *valp = (val & mask) != 0;
642 return 0;
645 static int alc_eapd_ctrl_put(struct snd_kcontrol *kcontrol,
646 struct snd_ctl_elem_value *ucontrol)
648 int change;
649 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
650 hda_nid_t nid = kcontrol->private_value & 0xffff;
651 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
652 long val = *ucontrol->value.integer.value;
653 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
654 AC_VERB_GET_EAPD_BTLENABLE,
655 0x00);
657 /* Set/unset the masked control bit(s) as needed */
658 change = (!val ? 0 : mask) != (ctrl_data & mask);
659 if (!val)
660 ctrl_data &= ~mask;
661 else
662 ctrl_data |= mask;
663 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
664 ctrl_data);
666 return change;
669 #define ALC_EAPD_CTRL_SWITCH(xname, nid, mask) \
670 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
671 .info = alc_eapd_ctrl_info, \
672 .get = alc_eapd_ctrl_get, \
673 .put = alc_eapd_ctrl_put, \
674 .private_value = nid | (mask<<16) }
675 #endif /* CONFIG_SND_DEBUG */
678 * set up from the preset table
680 static void setup_preset(struct alc_spec *spec,
681 const struct alc_config_preset *preset)
683 int i;
685 for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++)
686 spec->mixers[spec->num_mixers++] = preset->mixers[i];
687 for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i];
688 i++)
689 spec->init_verbs[spec->num_init_verbs++] =
690 preset->init_verbs[i];
692 spec->channel_mode = preset->channel_mode;
693 spec->num_channel_mode = preset->num_channel_mode;
694 spec->need_dac_fix = preset->need_dac_fix;
696 spec->multiout.max_channels = spec->channel_mode[0].channels;
698 spec->multiout.num_dacs = preset->num_dacs;
699 spec->multiout.dac_nids = preset->dac_nids;
700 spec->multiout.dig_out_nid = preset->dig_out_nid;
701 spec->multiout.hp_nid = preset->hp_nid;
703 spec->num_mux_defs = preset->num_mux_defs;
704 if (!spec->num_mux_defs)
705 spec->num_mux_defs = 1;
706 spec->input_mux = preset->input_mux;
708 spec->num_adc_nids = preset->num_adc_nids;
709 spec->adc_nids = preset->adc_nids;
710 spec->dig_in_nid = preset->dig_in_nid;
712 spec->unsol_event = preset->unsol_event;
713 spec->init_hook = preset->init_hook;
714 #ifdef CONFIG_SND_HDA_POWER_SAVE
715 spec->loopback.amplist = preset->loopbacks;
716 #endif
719 /* Enable GPIO mask and set output */
720 static struct hda_verb alc_gpio1_init_verbs[] = {
721 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
722 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
723 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
727 static struct hda_verb alc_gpio2_init_verbs[] = {
728 {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
729 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
730 {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
734 static struct hda_verb alc_gpio3_init_verbs[] = {
735 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
736 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
737 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
741 static void alc_sku_automute(struct hda_codec *codec)
743 struct alc_spec *spec = codec->spec;
744 unsigned int mute;
745 unsigned int present;
746 unsigned int hp_nid = spec->autocfg.hp_pins[0];
747 unsigned int sp_nid = spec->autocfg.speaker_pins[0];
749 /* need to execute and sync at first */
750 snd_hda_codec_read(codec, hp_nid, 0, AC_VERB_SET_PIN_SENSE, 0);
751 present = snd_hda_codec_read(codec, hp_nid, 0,
752 AC_VERB_GET_PIN_SENSE, 0);
753 spec->jack_present = (present & 0x80000000) != 0;
754 if (spec->jack_present) {
755 /* mute internal speaker */
756 snd_hda_codec_amp_stereo(codec, sp_nid, HDA_OUTPUT, 0,
757 HDA_AMP_MUTE, HDA_AMP_MUTE);
758 } else {
759 /* unmute internal speaker if necessary */
760 mute = snd_hda_codec_amp_read(codec, hp_nid, 0, HDA_OUTPUT, 0);
761 snd_hda_codec_amp_stereo(codec, sp_nid, HDA_OUTPUT, 0,
762 HDA_AMP_MUTE, mute);
766 /* unsolicited event for HP jack sensing */
767 static void alc_sku_unsol_event(struct hda_codec *codec, unsigned int res)
769 if (codec->vendor_id == 0x10ec0880)
770 res >>= 28;
771 else
772 res >>= 26;
773 if (res != ALC880_HP_EVENT)
774 return;
776 alc_sku_automute(codec);
779 /* 32-bit subsystem ID for BIOS loading in HD Audio codec.
780 * 31 ~ 16 : Manufacture ID
781 * 15 ~ 8 : SKU ID
782 * 7 ~ 0 : Assembly ID
783 * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36
785 static void alc_subsystem_id(struct hda_codec *codec,
786 unsigned int porta, unsigned int porte,
787 unsigned int portd)
789 unsigned int ass, tmp, i;
790 unsigned nid;
791 struct alc_spec *spec = codec->spec;
793 ass = codec->subsystem_id & 0xffff;
794 if ((ass != codec->bus->pci->subsystem_device) && (ass & 1))
795 goto do_sku;
798 * 31~30 : port conetcivity
799 * 29~21 : reserve
800 * 20 : PCBEEP input
801 * 19~16 : Check sum (15:1)
802 * 15~1 : Custom
803 * 0 : override
805 nid = 0x1d;
806 if (codec->vendor_id == 0x10ec0260)
807 nid = 0x17;
808 ass = snd_hda_codec_read(codec, nid, 0,
809 AC_VERB_GET_CONFIG_DEFAULT, 0);
810 if (!(ass & 1) && !(ass & 0x100000))
811 return;
812 if ((ass >> 30) != 1) /* no physical connection */
813 return;
815 /* check sum */
816 tmp = 0;
817 for (i = 1; i < 16; i++) {
818 if ((ass >> i) & 1)
819 tmp++;
821 if (((ass >> 16) & 0xf) != tmp)
822 return;
823 do_sku:
825 * 0 : override
826 * 1 : Swap Jack
827 * 2 : 0 --> Desktop, 1 --> Laptop
828 * 3~5 : External Amplifier control
829 * 7~6 : Reserved
831 tmp = (ass & 0x38) >> 3; /* external Amp control */
832 switch (tmp) {
833 case 1:
834 snd_hda_sequence_write(codec, alc_gpio1_init_verbs);
835 break;
836 case 3:
837 snd_hda_sequence_write(codec, alc_gpio2_init_verbs);
838 break;
839 case 7:
840 snd_hda_sequence_write(codec, alc_gpio3_init_verbs);
841 break;
842 case 5: /* set EAPD output high */
843 switch (codec->vendor_id) {
844 case 0x10ec0260:
845 snd_hda_codec_write(codec, 0x0f, 0,
846 AC_VERB_SET_EAPD_BTLENABLE, 2);
847 snd_hda_codec_write(codec, 0x10, 0,
848 AC_VERB_SET_EAPD_BTLENABLE, 2);
849 break;
850 case 0x10ec0262:
851 case 0x10ec0267:
852 case 0x10ec0268:
853 case 0x10ec0269:
854 case 0x10ec0862:
855 case 0x10ec0662:
856 snd_hda_codec_write(codec, 0x14, 0,
857 AC_VERB_SET_EAPD_BTLENABLE, 2);
858 snd_hda_codec_write(codec, 0x15, 0,
859 AC_VERB_SET_EAPD_BTLENABLE, 2);
860 break;
862 switch (codec->vendor_id) {
863 case 0x10ec0260:
864 snd_hda_codec_write(codec, 0x1a, 0,
865 AC_VERB_SET_COEF_INDEX, 7);
866 tmp = snd_hda_codec_read(codec, 0x1a, 0,
867 AC_VERB_GET_PROC_COEF, 0);
868 snd_hda_codec_write(codec, 0x1a, 0,
869 AC_VERB_SET_COEF_INDEX, 7);
870 snd_hda_codec_write(codec, 0x1a, 0,
871 AC_VERB_SET_PROC_COEF,
872 tmp | 0x2010);
873 break;
874 case 0x10ec0262:
875 case 0x10ec0880:
876 case 0x10ec0882:
877 case 0x10ec0883:
878 case 0x10ec0885:
879 case 0x10ec0888:
880 snd_hda_codec_write(codec, 0x20, 0,
881 AC_VERB_SET_COEF_INDEX, 7);
882 tmp = snd_hda_codec_read(codec, 0x20, 0,
883 AC_VERB_GET_PROC_COEF, 0);
884 snd_hda_codec_write(codec, 0x20, 0,
885 AC_VERB_SET_COEF_INDEX, 7);
886 snd_hda_codec_write(codec, 0x20, 0,
887 AC_VERB_SET_PROC_COEF,
888 tmp | 0x2010);
889 break;
890 case 0x10ec0267:
891 case 0x10ec0268:
892 snd_hda_codec_write(codec, 0x20, 0,
893 AC_VERB_SET_COEF_INDEX, 7);
894 tmp = snd_hda_codec_read(codec, 0x20, 0,
895 AC_VERB_GET_PROC_COEF, 0);
896 snd_hda_codec_write(codec, 0x20, 0,
897 AC_VERB_SET_COEF_INDEX, 7);
898 snd_hda_codec_write(codec, 0x20, 0,
899 AC_VERB_SET_PROC_COEF,
900 tmp | 0x3000);
901 break;
903 default:
904 break;
907 /* is laptop or Desktop and enable the function "Mute internal speaker
908 * when the external headphone out jack is plugged"
910 if (!(ass & 0x8000))
911 return;
913 * 10~8 : Jack location
914 * 12~11: Headphone out -> 00: PortA, 01: PortE, 02: PortD, 03: Resvered
915 * 14~13: Resvered
916 * 15 : 1 --> enable the function "Mute internal speaker
917 * when the external headphone out jack is plugged"
919 if (!spec->autocfg.speaker_pins[0]) {
920 if (spec->autocfg.line_out_pins[0])
921 spec->autocfg.speaker_pins[0] =
922 spec->autocfg.line_out_pins[0];
923 else
924 return;
927 if (!spec->autocfg.hp_pins[0]) {
928 tmp = (ass >> 11) & 0x3; /* HP to chassis */
929 if (tmp == 0)
930 spec->autocfg.hp_pins[0] = porta;
931 else if (tmp == 1)
932 spec->autocfg.hp_pins[0] = porte;
933 else if (tmp == 2)
934 spec->autocfg.hp_pins[0] = portd;
935 else
936 return;
939 snd_hda_codec_write(codec, spec->autocfg.hp_pins[0], 0,
940 AC_VERB_SET_UNSOLICITED_ENABLE,
941 AC_USRSP_EN | ALC880_HP_EVENT);
942 spec->unsol_event = alc_sku_unsol_event;
943 spec->init_hook = alc_sku_automute;
947 * Fix-up pin default configurations
950 struct alc_pincfg {
951 hda_nid_t nid;
952 u32 val;
955 static void alc_fix_pincfg(struct hda_codec *codec,
956 const struct snd_pci_quirk *quirk,
957 const struct alc_pincfg **pinfix)
959 const struct alc_pincfg *cfg;
961 quirk = snd_pci_quirk_lookup(codec->bus->pci, quirk);
962 if (!quirk)
963 return;
965 cfg = pinfix[quirk->value];
966 for (; cfg->nid; cfg++) {
967 int i;
968 u32 val = cfg->val;
969 for (i = 0; i < 4; i++) {
970 snd_hda_codec_write(codec, cfg->nid, 0,
971 AC_VERB_SET_CONFIG_DEFAULT_BYTES_0 + i,
972 val & 0xff);
973 val >>= 8;
979 * ALC880 3-stack model
981 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
982 * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18,
983 * F-Mic = 0x1b, HP = 0x19
986 static hda_nid_t alc880_dac_nids[4] = {
987 /* front, rear, clfe, rear_surr */
988 0x02, 0x05, 0x04, 0x03
991 static hda_nid_t alc880_adc_nids[3] = {
992 /* ADC0-2 */
993 0x07, 0x08, 0x09,
996 /* The datasheet says the node 0x07 is connected from inputs,
997 * but it shows zero connection in the real implementation on some devices.
998 * Note: this is a 915GAV bug, fixed on 915GLV
1000 static hda_nid_t alc880_adc_nids_alt[2] = {
1001 /* ADC1-2 */
1002 0x08, 0x09,
1005 #define ALC880_DIGOUT_NID 0x06
1006 #define ALC880_DIGIN_NID 0x0a
1008 static struct hda_input_mux alc880_capture_source = {
1009 .num_items = 4,
1010 .items = {
1011 { "Mic", 0x0 },
1012 { "Front Mic", 0x3 },
1013 { "Line", 0x2 },
1014 { "CD", 0x4 },
1018 /* channel source setting (2/6 channel selection for 3-stack) */
1019 /* 2ch mode */
1020 static struct hda_verb alc880_threestack_ch2_init[] = {
1021 /* set line-in to input, mute it */
1022 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1023 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1024 /* set mic-in to input vref 80%, mute it */
1025 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1026 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1027 { } /* end */
1030 /* 6ch mode */
1031 static struct hda_verb alc880_threestack_ch6_init[] = {
1032 /* set line-in to output, unmute it */
1033 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1034 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1035 /* set mic-in to output, unmute it */
1036 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1037 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1038 { } /* end */
1041 static struct hda_channel_mode alc880_threestack_modes[2] = {
1042 { 2, alc880_threestack_ch2_init },
1043 { 6, alc880_threestack_ch6_init },
1046 static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
1047 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1048 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1049 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
1050 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
1051 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1052 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1053 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1054 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1055 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1056 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1057 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1058 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1059 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1060 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1061 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
1062 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
1063 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1064 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
1065 HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
1067 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1068 .name = "Channel Mode",
1069 .info = alc_ch_mode_info,
1070 .get = alc_ch_mode_get,
1071 .put = alc_ch_mode_put,
1073 { } /* end */
1076 /* capture mixer elements */
1077 static struct snd_kcontrol_new alc880_capture_mixer[] = {
1078 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
1079 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
1080 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
1081 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
1082 HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
1083 HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
1085 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1086 /* The multiple "Capture Source" controls confuse alsamixer
1087 * So call somewhat different..
1089 /* .name = "Capture Source", */
1090 .name = "Input Source",
1091 .count = 3,
1092 .info = alc_mux_enum_info,
1093 .get = alc_mux_enum_get,
1094 .put = alc_mux_enum_put,
1096 { } /* end */
1099 /* capture mixer elements (in case NID 0x07 not available) */
1100 static struct snd_kcontrol_new alc880_capture_alt_mixer[] = {
1101 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
1102 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
1103 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
1104 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
1106 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1107 /* The multiple "Capture Source" controls confuse alsamixer
1108 * So call somewhat different..
1110 /* .name = "Capture Source", */
1111 .name = "Input Source",
1112 .count = 2,
1113 .info = alc_mux_enum_info,
1114 .get = alc_mux_enum_get,
1115 .put = alc_mux_enum_put,
1117 { } /* end */
1123 * ALC880 5-stack model
1125 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d),
1126 * Side = 0x02 (0xd)
1127 * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
1128 * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
1131 /* additional mixers to alc880_three_stack_mixer */
1132 static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
1133 HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1134 HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
1135 { } /* end */
1138 /* channel source setting (6/8 channel selection for 5-stack) */
1139 /* 6ch mode */
1140 static struct hda_verb alc880_fivestack_ch6_init[] = {
1141 /* set line-in to input, mute it */
1142 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1143 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1144 { } /* end */
1147 /* 8ch mode */
1148 static struct hda_verb alc880_fivestack_ch8_init[] = {
1149 /* set line-in to output, unmute it */
1150 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1151 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1152 { } /* end */
1155 static struct hda_channel_mode alc880_fivestack_modes[2] = {
1156 { 6, alc880_fivestack_ch6_init },
1157 { 8, alc880_fivestack_ch8_init },
1162 * ALC880 6-stack model
1164 * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e),
1165 * Side = 0x05 (0x0f)
1166 * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
1167 * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
1170 static hda_nid_t alc880_6st_dac_nids[4] = {
1171 /* front, rear, clfe, rear_surr */
1172 0x02, 0x03, 0x04, 0x05
1175 static struct hda_input_mux alc880_6stack_capture_source = {
1176 .num_items = 4,
1177 .items = {
1178 { "Mic", 0x0 },
1179 { "Front Mic", 0x1 },
1180 { "Line", 0x2 },
1181 { "CD", 0x4 },
1185 /* fixed 8-channels */
1186 static struct hda_channel_mode alc880_sixstack_modes[1] = {
1187 { 8, NULL },
1190 static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
1191 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1192 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1193 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1194 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
1195 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1196 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1197 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1198 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1199 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
1200 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
1201 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1202 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1203 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1204 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1205 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1206 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1207 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1208 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1209 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1210 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
1212 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1213 .name = "Channel Mode",
1214 .info = alc_ch_mode_info,
1215 .get = alc_ch_mode_get,
1216 .put = alc_ch_mode_put,
1218 { } /* end */
1223 * ALC880 W810 model
1225 * W810 has rear IO for:
1226 * Front (DAC 02)
1227 * Surround (DAC 03)
1228 * Center/LFE (DAC 04)
1229 * Digital out (06)
1231 * The system also has a pair of internal speakers, and a headphone jack.
1232 * These are both connected to Line2 on the codec, hence to DAC 02.
1234 * There is a variable resistor to control the speaker or headphone
1235 * volume. This is a hardware-only device without a software API.
1237 * Plugging headphones in will disable the internal speakers. This is
1238 * implemented in hardware, not via the driver using jack sense. In
1239 * a similar fashion, plugging into the rear socket marked "front" will
1240 * disable both the speakers and headphones.
1242 * For input, there's a microphone jack, and an "audio in" jack.
1243 * These may not do anything useful with this driver yet, because I
1244 * haven't setup any initialization verbs for these yet...
1247 static hda_nid_t alc880_w810_dac_nids[3] = {
1248 /* front, rear/surround, clfe */
1249 0x02, 0x03, 0x04
1252 /* fixed 6 channels */
1253 static struct hda_channel_mode alc880_w810_modes[1] = {
1254 { 6, NULL }
1257 /* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
1258 static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
1259 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1260 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1261 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1262 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
1263 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1264 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1265 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1266 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1267 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
1268 { } /* end */
1273 * Z710V model
1275 * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
1276 * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?),
1277 * Line = 0x1a
1280 static hda_nid_t alc880_z71v_dac_nids[1] = {
1281 0x02
1283 #define ALC880_Z71V_HP_DAC 0x03
1285 /* fixed 2 channels */
1286 static struct hda_channel_mode alc880_2_jack_modes[1] = {
1287 { 2, NULL }
1290 static struct snd_kcontrol_new alc880_z71v_mixer[] = {
1291 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1292 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1293 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1294 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
1295 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1296 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1297 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1298 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1299 { } /* end */
1304 * ALC880 F1734 model
1306 * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
1307 * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
1310 static hda_nid_t alc880_f1734_dac_nids[1] = {
1311 0x03
1313 #define ALC880_F1734_HP_DAC 0x02
1315 static struct snd_kcontrol_new alc880_f1734_mixer[] = {
1316 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1317 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
1318 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1319 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
1320 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1321 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1322 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1323 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1324 { } /* end */
1329 * ALC880 ASUS model
1331 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
1332 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
1333 * Mic = 0x18, Line = 0x1a
1336 #define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
1337 #define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
1339 static struct snd_kcontrol_new alc880_asus_mixer[] = {
1340 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1341 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1342 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1343 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
1344 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1345 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1346 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1347 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1348 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1349 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1350 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1351 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1352 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1353 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1355 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1356 .name = "Channel Mode",
1357 .info = alc_ch_mode_info,
1358 .get = alc_ch_mode_get,
1359 .put = alc_ch_mode_put,
1361 { } /* end */
1365 * ALC880 ASUS W1V model
1367 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
1368 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
1369 * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
1372 /* additional mixers to alc880_asus_mixer */
1373 static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
1374 HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
1375 HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
1376 { } /* end */
1379 /* additional mixers to alc880_asus_mixer */
1380 static struct snd_kcontrol_new alc880_pcbeep_mixer[] = {
1381 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1382 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
1383 { } /* end */
1386 /* TCL S700 */
1387 static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
1388 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1389 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
1390 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
1391 HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
1392 HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
1393 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
1394 HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
1395 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
1396 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
1398 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1399 /* The multiple "Capture Source" controls confuse alsamixer
1400 * So call somewhat different..
1402 /* .name = "Capture Source", */
1403 .name = "Input Source",
1404 .count = 1,
1405 .info = alc_mux_enum_info,
1406 .get = alc_mux_enum_get,
1407 .put = alc_mux_enum_put,
1409 { } /* end */
1412 /* Uniwill */
1413 static struct snd_kcontrol_new alc880_uniwill_mixer[] = {
1414 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1415 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
1416 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1417 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
1418 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1419 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1420 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1421 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1422 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1423 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1424 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1425 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1426 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1427 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1428 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1429 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1430 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1431 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
1433 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1434 .name = "Channel Mode",
1435 .info = alc_ch_mode_info,
1436 .get = alc_ch_mode_get,
1437 .put = alc_ch_mode_put,
1439 { } /* end */
1442 static struct snd_kcontrol_new alc880_fujitsu_mixer[] = {
1443 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1444 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
1445 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1446 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
1447 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1448 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1449 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1450 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1451 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1452 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1453 { } /* end */
1456 static struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = {
1457 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1458 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
1459 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1460 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
1461 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1462 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1463 { } /* end */
1467 * virtual master controls
1471 * slave controls for virtual master
1473 static const char *alc_slave_vols[] = {
1474 "Front Playback Volume",
1475 "Surround Playback Volume",
1476 "Center Playback Volume",
1477 "LFE Playback Volume",
1478 "Side Playback Volume",
1479 "Headphone Playback Volume",
1480 "Speaker Playback Volume",
1481 "Mono Playback Volume",
1482 "Line-Out Playback Volume",
1483 NULL,
1486 static const char *alc_slave_sws[] = {
1487 "Front Playback Switch",
1488 "Surround Playback Switch",
1489 "Center Playback Switch",
1490 "LFE Playback Switch",
1491 "Side Playback Switch",
1492 "Headphone Playback Switch",
1493 "Speaker Playback Switch",
1494 "Mono Playback Switch",
1495 "IEC958 Playback Switch",
1496 NULL,
1500 * build control elements
1502 static int alc_build_controls(struct hda_codec *codec)
1504 struct alc_spec *spec = codec->spec;
1505 int err;
1506 int i;
1508 for (i = 0; i < spec->num_mixers; i++) {
1509 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
1510 if (err < 0)
1511 return err;
1514 if (spec->multiout.dig_out_nid) {
1515 err = snd_hda_create_spdif_out_ctls(codec,
1516 spec->multiout.dig_out_nid);
1517 if (err < 0)
1518 return err;
1520 if (spec->dig_in_nid) {
1521 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
1522 if (err < 0)
1523 return err;
1526 /* if we have no master control, let's create it */
1527 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
1528 snd_hda_set_vmaster_tlv(codec, spec->vmaster_nid,
1529 HDA_OUTPUT, spec->vmaster_tlv);
1530 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
1531 spec->vmaster_tlv, alc_slave_vols);
1532 if (err < 0)
1533 return err;
1535 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
1536 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
1537 NULL, alc_slave_sws);
1538 if (err < 0)
1539 return err;
1542 return 0;
1547 * initialize the codec volumes, etc
1551 * generic initialization of ADC, input mixers and output mixers
1553 static struct hda_verb alc880_volume_init_verbs[] = {
1555 * Unmute ADC0-2 and set the default input to mic-in
1557 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
1558 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1559 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
1560 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1561 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
1562 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1564 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
1565 * mixer widget
1566 * Note: PASD motherboards uses the Line In 2 as the input for front
1567 * panel mic (mic 2)
1569 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
1570 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1571 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1572 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
1573 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
1574 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
1575 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
1576 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
1579 * Set up output mixers (0x0c - 0x0f)
1581 /* set vol=0 to output mixers */
1582 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1583 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1584 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1585 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1586 /* set up input amps for analog loopback */
1587 /* Amp Indices: DAC = 0, mixer = 1 */
1588 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1589 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1590 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1591 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1592 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1593 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1594 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1595 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1601 * 3-stack pin configuration:
1602 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
1604 static struct hda_verb alc880_pin_3stack_init_verbs[] = {
1606 * preset connection lists of input pins
1607 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
1609 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
1610 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1611 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
1614 * Set pin mode and muting
1616 /* set front pin widgets 0x14 for output */
1617 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1618 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1619 /* Mic1 (rear panel) pin widget for input and vref at 80% */
1620 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1621 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1622 /* Mic2 (as headphone out) for HP output */
1623 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1624 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1625 /* Line In pin widget for input */
1626 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1627 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1628 /* Line2 (as front mic) pin widget for input and vref at 80% */
1629 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1630 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1631 /* CD pin widget for input */
1632 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1638 * 5-stack pin configuration:
1639 * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
1640 * line-in/side = 0x1a, f-mic = 0x1b
1642 static struct hda_verb alc880_pin_5stack_init_verbs[] = {
1644 * preset connection lists of input pins
1645 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
1647 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1648 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
1651 * Set pin mode and muting
1653 /* set pin widgets 0x14-0x17 for output */
1654 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1655 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1656 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1657 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1658 /* unmute pins for output (no gain on this amp) */
1659 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1660 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1661 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1662 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1664 /* Mic1 (rear panel) pin widget for input and vref at 80% */
1665 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1666 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1667 /* Mic2 (as headphone out) for HP output */
1668 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1669 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1670 /* Line In pin widget for input */
1671 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1672 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1673 /* Line2 (as front mic) pin widget for input and vref at 80% */
1674 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1675 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1676 /* CD pin widget for input */
1677 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1683 * W810 pin configuration:
1684 * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
1686 static struct hda_verb alc880_pin_w810_init_verbs[] = {
1687 /* hphone/speaker input selector: front DAC */
1688 {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
1690 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1691 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1692 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1693 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1694 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1695 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1697 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1698 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1704 * Z71V pin configuration:
1705 * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
1707 static struct hda_verb alc880_pin_z71v_init_verbs[] = {
1708 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1709 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1710 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1711 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1713 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1714 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1715 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1716 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1722 * 6-stack pin configuration:
1723 * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18,
1724 * f-mic = 0x19, line = 0x1a, HP = 0x1b
1726 static struct hda_verb alc880_pin_6stack_init_verbs[] = {
1727 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1729 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1730 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1731 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1732 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1733 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1734 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1735 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1736 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1738 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1739 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1740 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1741 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1742 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1743 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1744 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1745 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1746 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1752 * Uniwill pin configuration:
1753 * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19,
1754 * line = 0x1a
1756 static struct hda_verb alc880_uniwill_init_verbs[] = {
1757 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1759 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1760 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1761 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1762 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1763 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1764 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1765 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1766 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1767 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1768 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1769 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1770 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1771 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1772 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1774 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1775 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1776 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1777 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1778 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1779 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1780 /* {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, */
1781 /* {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
1782 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1784 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
1785 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
1791 * Uniwill P53
1792 * HP = 0x14, InternalSpeaker = 0x15, mic = 0x19,
1794 static struct hda_verb alc880_uniwill_p53_init_verbs[] = {
1795 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1797 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1798 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1799 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1800 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1801 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1802 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1803 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1804 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1805 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1806 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1807 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1808 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1810 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1811 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1812 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1813 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1814 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1815 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1817 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
1818 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_DCVOL_EVENT},
1823 static struct hda_verb alc880_beep_init_verbs[] = {
1824 { 0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5) },
1828 /* toggle speaker-output according to the hp-jack state */
1829 static void alc880_uniwill_hp_automute(struct hda_codec *codec)
1831 unsigned int present;
1832 unsigned char bits;
1834 present = snd_hda_codec_read(codec, 0x14, 0,
1835 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1836 bits = present ? HDA_AMP_MUTE : 0;
1837 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
1838 HDA_AMP_MUTE, bits);
1839 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
1840 HDA_AMP_MUTE, bits);
1843 /* auto-toggle front mic */
1844 static void alc880_uniwill_mic_automute(struct hda_codec *codec)
1846 unsigned int present;
1847 unsigned char bits;
1849 present = snd_hda_codec_read(codec, 0x18, 0,
1850 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1851 bits = present ? HDA_AMP_MUTE : 0;
1852 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
1855 static void alc880_uniwill_automute(struct hda_codec *codec)
1857 alc880_uniwill_hp_automute(codec);
1858 alc880_uniwill_mic_automute(codec);
1861 static void alc880_uniwill_unsol_event(struct hda_codec *codec,
1862 unsigned int res)
1864 /* Looks like the unsol event is incompatible with the standard
1865 * definition. 4bit tag is placed at 28 bit!
1867 switch (res >> 28) {
1868 case ALC880_HP_EVENT:
1869 alc880_uniwill_hp_automute(codec);
1870 break;
1871 case ALC880_MIC_EVENT:
1872 alc880_uniwill_mic_automute(codec);
1873 break;
1877 static void alc880_uniwill_p53_hp_automute(struct hda_codec *codec)
1879 unsigned int present;
1880 unsigned char bits;
1882 present = snd_hda_codec_read(codec, 0x14, 0,
1883 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1884 bits = present ? HDA_AMP_MUTE : 0;
1885 snd_hda_codec_amp_stereo(codec, 0x15, HDA_INPUT, 0, HDA_AMP_MUTE, bits);
1888 static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec)
1890 unsigned int present;
1892 present = snd_hda_codec_read(codec, 0x21, 0,
1893 AC_VERB_GET_VOLUME_KNOB_CONTROL, 0);
1894 present &= HDA_AMP_VOLMASK;
1895 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0,
1896 HDA_AMP_VOLMASK, present);
1897 snd_hda_codec_amp_stereo(codec, 0x0d, HDA_OUTPUT, 0,
1898 HDA_AMP_VOLMASK, present);
1901 static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec,
1902 unsigned int res)
1904 /* Looks like the unsol event is incompatible with the standard
1905 * definition. 4bit tag is placed at 28 bit!
1907 if ((res >> 28) == ALC880_HP_EVENT)
1908 alc880_uniwill_p53_hp_automute(codec);
1909 if ((res >> 28) == ALC880_DCVOL_EVENT)
1910 alc880_uniwill_p53_dcvol_automute(codec);
1914 * F1734 pin configuration:
1915 * HP = 0x14, speaker-out = 0x15, mic = 0x18
1917 static struct hda_verb alc880_pin_f1734_init_verbs[] = {
1918 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
1919 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
1920 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
1921 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
1923 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1924 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1925 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1926 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1928 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1929 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1930 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1931 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1932 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1933 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1934 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1935 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1936 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1942 * ASUS pin configuration:
1943 * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
1945 static struct hda_verb alc880_pin_asus_init_verbs[] = {
1946 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
1947 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
1948 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
1949 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
1951 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1952 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1953 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1954 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1955 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1956 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1957 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1958 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1960 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1961 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1962 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1963 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1964 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1965 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1966 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1967 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1968 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1973 /* Enable GPIO mask and set output */
1974 #define alc880_gpio1_init_verbs alc_gpio1_init_verbs
1975 #define alc880_gpio2_init_verbs alc_gpio2_init_verbs
1977 /* Clevo m520g init */
1978 static struct hda_verb alc880_pin_clevo_init_verbs[] = {
1979 /* headphone output */
1980 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
1981 /* line-out */
1982 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1983 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1984 /* Line-in */
1985 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1986 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1987 /* CD */
1988 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1989 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1990 /* Mic1 (rear panel) */
1991 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1992 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1993 /* Mic2 (front panel) */
1994 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1995 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1996 /* headphone */
1997 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1998 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1999 /* change to EAPD mode */
2000 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2001 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
2006 static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
2007 /* change to EAPD mode */
2008 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2009 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
2011 /* Headphone output */
2012 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2013 /* Front output*/
2014 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2015 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
2017 /* Line In pin widget for input */
2018 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2019 /* CD pin widget for input */
2020 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2021 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2022 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2024 /* change to EAPD mode */
2025 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2026 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
2032 * LG m1 express dual
2034 * Pin assignment:
2035 * Rear Line-In/Out (blue): 0x14
2036 * Build-in Mic-In: 0x15
2037 * Speaker-out: 0x17
2038 * HP-Out (green): 0x1b
2039 * Mic-In/Out (red): 0x19
2040 * SPDIF-Out: 0x1e
2043 /* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
2044 static hda_nid_t alc880_lg_dac_nids[3] = {
2045 0x05, 0x02, 0x03
2048 /* seems analog CD is not working */
2049 static struct hda_input_mux alc880_lg_capture_source = {
2050 .num_items = 3,
2051 .items = {
2052 { "Mic", 0x1 },
2053 { "Line", 0x5 },
2054 { "Internal Mic", 0x6 },
2058 /* 2,4,6 channel modes */
2059 static struct hda_verb alc880_lg_ch2_init[] = {
2060 /* set line-in and mic-in to input */
2061 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
2062 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
2066 static struct hda_verb alc880_lg_ch4_init[] = {
2067 /* set line-in to out and mic-in to input */
2068 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
2069 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
2073 static struct hda_verb alc880_lg_ch6_init[] = {
2074 /* set line-in and mic-in to output */
2075 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
2076 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
2080 static struct hda_channel_mode alc880_lg_ch_modes[3] = {
2081 { 2, alc880_lg_ch2_init },
2082 { 4, alc880_lg_ch4_init },
2083 { 6, alc880_lg_ch6_init },
2086 static struct snd_kcontrol_new alc880_lg_mixer[] = {
2087 HDA_CODEC_VOLUME("Front Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
2088 HDA_BIND_MUTE("Front Playback Switch", 0x0f, 2, HDA_INPUT),
2089 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2090 HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
2091 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
2092 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
2093 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
2094 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
2095 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2096 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
2097 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
2098 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
2099 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
2100 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
2102 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2103 .name = "Channel Mode",
2104 .info = alc_ch_mode_info,
2105 .get = alc_ch_mode_get,
2106 .put = alc_ch_mode_put,
2108 { } /* end */
2111 static struct hda_verb alc880_lg_init_verbs[] = {
2112 /* set capture source to mic-in */
2113 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2114 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2115 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2116 /* mute all amp mixer inputs */
2117 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
2118 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
2119 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
2120 /* line-in to input */
2121 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2122 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2123 /* built-in mic */
2124 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2125 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2126 /* speaker-out */
2127 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2128 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2129 /* mic-in to input */
2130 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
2131 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2132 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2133 /* HP-out */
2134 {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
2135 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2136 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2137 /* jack sense */
2138 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
2142 /* toggle speaker-output according to the hp-jack state */
2143 static void alc880_lg_automute(struct hda_codec *codec)
2145 unsigned int present;
2146 unsigned char bits;
2148 present = snd_hda_codec_read(codec, 0x1b, 0,
2149 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
2150 bits = present ? HDA_AMP_MUTE : 0;
2151 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
2152 HDA_AMP_MUTE, bits);
2155 static void alc880_lg_unsol_event(struct hda_codec *codec, unsigned int res)
2157 /* Looks like the unsol event is incompatible with the standard
2158 * definition. 4bit tag is placed at 28 bit!
2160 if ((res >> 28) == 0x01)
2161 alc880_lg_automute(codec);
2165 * LG LW20
2167 * Pin assignment:
2168 * Speaker-out: 0x14
2169 * Mic-In: 0x18
2170 * Built-in Mic-In: 0x19
2171 * Line-In: 0x1b
2172 * HP-Out: 0x1a
2173 * SPDIF-Out: 0x1e
2176 static struct hda_input_mux alc880_lg_lw_capture_source = {
2177 .num_items = 3,
2178 .items = {
2179 { "Mic", 0x0 },
2180 { "Internal Mic", 0x1 },
2181 { "Line In", 0x2 },
2185 #define alc880_lg_lw_modes alc880_threestack_modes
2187 static struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
2188 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2189 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2190 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
2191 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
2192 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2193 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2194 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2195 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2196 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2197 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2198 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2199 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2200 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
2201 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
2203 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2204 .name = "Channel Mode",
2205 .info = alc_ch_mode_info,
2206 .get = alc_ch_mode_get,
2207 .put = alc_ch_mode_put,
2209 { } /* end */
2212 static struct hda_verb alc880_lg_lw_init_verbs[] = {
2213 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2214 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
2215 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
2217 /* set capture source to mic-in */
2218 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2219 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2220 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2221 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
2222 /* speaker-out */
2223 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2224 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2225 /* HP-out */
2226 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2227 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2228 /* mic-in to input */
2229 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2230 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2231 /* built-in mic */
2232 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2233 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2234 /* jack sense */
2235 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
2239 /* toggle speaker-output according to the hp-jack state */
2240 static void alc880_lg_lw_automute(struct hda_codec *codec)
2242 unsigned int present;
2243 unsigned char bits;
2245 present = snd_hda_codec_read(codec, 0x1b, 0,
2246 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
2247 bits = present ? HDA_AMP_MUTE : 0;
2248 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
2249 HDA_AMP_MUTE, bits);
2252 static void alc880_lg_lw_unsol_event(struct hda_codec *codec, unsigned int res)
2254 /* Looks like the unsol event is incompatible with the standard
2255 * definition. 4bit tag is placed at 28 bit!
2257 if ((res >> 28) == 0x01)
2258 alc880_lg_lw_automute(codec);
2261 #ifdef CONFIG_SND_HDA_POWER_SAVE
2262 static struct hda_amp_list alc880_loopbacks[] = {
2263 { 0x0b, HDA_INPUT, 0 },
2264 { 0x0b, HDA_INPUT, 1 },
2265 { 0x0b, HDA_INPUT, 2 },
2266 { 0x0b, HDA_INPUT, 3 },
2267 { 0x0b, HDA_INPUT, 4 },
2268 { } /* end */
2271 static struct hda_amp_list alc880_lg_loopbacks[] = {
2272 { 0x0b, HDA_INPUT, 1 },
2273 { 0x0b, HDA_INPUT, 6 },
2274 { 0x0b, HDA_INPUT, 7 },
2275 { } /* end */
2277 #endif
2280 * Common callbacks
2283 static int alc_init(struct hda_codec *codec)
2285 struct alc_spec *spec = codec->spec;
2286 unsigned int i;
2288 for (i = 0; i < spec->num_init_verbs; i++)
2289 snd_hda_sequence_write(codec, spec->init_verbs[i]);
2291 if (spec->init_hook)
2292 spec->init_hook(codec);
2294 return 0;
2297 static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
2299 struct alc_spec *spec = codec->spec;
2301 if (spec->unsol_event)
2302 spec->unsol_event(codec, res);
2305 #ifdef CONFIG_SND_HDA_POWER_SAVE
2306 static int alc_check_power_status(struct hda_codec *codec, hda_nid_t nid)
2308 struct alc_spec *spec = codec->spec;
2309 return snd_hda_check_amp_list_power(codec, &spec->loopback, nid);
2311 #endif
2314 * Analog playback callbacks
2316 static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
2317 struct hda_codec *codec,
2318 struct snd_pcm_substream *substream)
2320 struct alc_spec *spec = codec->spec;
2321 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream);
2324 static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2325 struct hda_codec *codec,
2326 unsigned int stream_tag,
2327 unsigned int format,
2328 struct snd_pcm_substream *substream)
2330 struct alc_spec *spec = codec->spec;
2331 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
2332 stream_tag, format, substream);
2335 static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
2336 struct hda_codec *codec,
2337 struct snd_pcm_substream *substream)
2339 struct alc_spec *spec = codec->spec;
2340 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
2344 * Digital out
2346 static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
2347 struct hda_codec *codec,
2348 struct snd_pcm_substream *substream)
2350 struct alc_spec *spec = codec->spec;
2351 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
2354 static int alc880_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2355 struct hda_codec *codec,
2356 unsigned int stream_tag,
2357 unsigned int format,
2358 struct snd_pcm_substream *substream)
2360 struct alc_spec *spec = codec->spec;
2361 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
2362 stream_tag, format, substream);
2365 static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
2366 struct hda_codec *codec,
2367 struct snd_pcm_substream *substream)
2369 struct alc_spec *spec = codec->spec;
2370 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
2374 * Analog capture
2376 static int alc880_alt_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
2377 struct hda_codec *codec,
2378 unsigned int stream_tag,
2379 unsigned int format,
2380 struct snd_pcm_substream *substream)
2382 struct alc_spec *spec = codec->spec;
2384 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number + 1],
2385 stream_tag, 0, format);
2386 return 0;
2389 static int alc880_alt_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
2390 struct hda_codec *codec,
2391 struct snd_pcm_substream *substream)
2393 struct alc_spec *spec = codec->spec;
2395 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number + 1],
2396 0, 0, 0);
2397 return 0;
2403 static struct hda_pcm_stream alc880_pcm_analog_playback = {
2404 .substreams = 1,
2405 .channels_min = 2,
2406 .channels_max = 8,
2407 /* NID is set in alc_build_pcms */
2408 .ops = {
2409 .open = alc880_playback_pcm_open,
2410 .prepare = alc880_playback_pcm_prepare,
2411 .cleanup = alc880_playback_pcm_cleanup
2415 static struct hda_pcm_stream alc880_pcm_analog_capture = {
2416 .substreams = 1,
2417 .channels_min = 2,
2418 .channels_max = 2,
2419 /* NID is set in alc_build_pcms */
2422 static struct hda_pcm_stream alc880_pcm_analog_alt_playback = {
2423 .substreams = 1,
2424 .channels_min = 2,
2425 .channels_max = 2,
2426 /* NID is set in alc_build_pcms */
2429 static struct hda_pcm_stream alc880_pcm_analog_alt_capture = {
2430 .substreams = 2, /* can be overridden */
2431 .channels_min = 2,
2432 .channels_max = 2,
2433 /* NID is set in alc_build_pcms */
2434 .ops = {
2435 .prepare = alc880_alt_capture_pcm_prepare,
2436 .cleanup = alc880_alt_capture_pcm_cleanup
2440 static struct hda_pcm_stream alc880_pcm_digital_playback = {
2441 .substreams = 1,
2442 .channels_min = 2,
2443 .channels_max = 2,
2444 /* NID is set in alc_build_pcms */
2445 .ops = {
2446 .open = alc880_dig_playback_pcm_open,
2447 .close = alc880_dig_playback_pcm_close,
2448 .prepare = alc880_dig_playback_pcm_prepare
2452 static struct hda_pcm_stream alc880_pcm_digital_capture = {
2453 .substreams = 1,
2454 .channels_min = 2,
2455 .channels_max = 2,
2456 /* NID is set in alc_build_pcms */
2459 /* Used by alc_build_pcms to flag that a PCM has no playback stream */
2460 static struct hda_pcm_stream alc_pcm_null_stream = {
2461 .substreams = 0,
2462 .channels_min = 0,
2463 .channels_max = 0,
2466 static int alc_build_pcms(struct hda_codec *codec)
2468 struct alc_spec *spec = codec->spec;
2469 struct hda_pcm *info = spec->pcm_rec;
2470 int i;
2472 codec->num_pcms = 1;
2473 codec->pcm_info = info;
2475 info->name = spec->stream_name_analog;
2476 if (spec->stream_analog_playback) {
2477 snd_assert(spec->multiout.dac_nids, return -EINVAL);
2478 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
2479 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
2481 if (spec->stream_analog_capture) {
2482 snd_assert(spec->adc_nids, return -EINVAL);
2483 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
2484 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
2487 if (spec->channel_mode) {
2488 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
2489 for (i = 0; i < spec->num_channel_mode; i++) {
2490 if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
2491 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
2496 /* SPDIF for stream index #1 */
2497 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
2498 codec->num_pcms = 2;
2499 info = spec->pcm_rec + 1;
2500 info->name = spec->stream_name_digital;
2501 if (spec->multiout.dig_out_nid &&
2502 spec->stream_digital_playback) {
2503 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
2504 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
2506 if (spec->dig_in_nid &&
2507 spec->stream_digital_capture) {
2508 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
2509 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
2513 /* If the use of more than one ADC is requested for the current
2514 * model, configure a second analog capture-only PCM.
2516 /* Additional Analaog capture for index #2 */
2517 if ((spec->alt_dac_nid && spec->stream_analog_alt_playback) ||
2518 (spec->num_adc_nids > 1 && spec->stream_analog_alt_capture)) {
2519 codec->num_pcms = 3;
2520 info = spec->pcm_rec + 2;
2521 info->name = spec->stream_name_analog;
2522 if (spec->alt_dac_nid) {
2523 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
2524 *spec->stream_analog_alt_playback;
2525 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
2526 spec->alt_dac_nid;
2527 } else {
2528 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
2529 alc_pcm_null_stream;
2530 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
2532 if (spec->num_adc_nids > 1) {
2533 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
2534 *spec->stream_analog_alt_capture;
2535 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid =
2536 spec->adc_nids[1];
2537 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams =
2538 spec->num_adc_nids - 1;
2539 } else {
2540 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
2541 alc_pcm_null_stream;
2542 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = 0;
2546 return 0;
2549 static void alc_free(struct hda_codec *codec)
2551 struct alc_spec *spec = codec->spec;
2552 unsigned int i;
2554 if (!spec)
2555 return;
2557 if (spec->kctl_alloc) {
2558 for (i = 0; i < spec->num_kctl_used; i++)
2559 kfree(spec->kctl_alloc[i].name);
2560 kfree(spec->kctl_alloc);
2562 kfree(spec);
2567 static struct hda_codec_ops alc_patch_ops = {
2568 .build_controls = alc_build_controls,
2569 .build_pcms = alc_build_pcms,
2570 .init = alc_init,
2571 .free = alc_free,
2572 .unsol_event = alc_unsol_event,
2573 #ifdef CONFIG_SND_HDA_POWER_SAVE
2574 .check_power_status = alc_check_power_status,
2575 #endif
2580 * Test configuration for debugging
2582 * Almost all inputs/outputs are enabled. I/O pins can be configured via
2583 * enum controls.
2585 #ifdef CONFIG_SND_DEBUG
2586 static hda_nid_t alc880_test_dac_nids[4] = {
2587 0x02, 0x03, 0x04, 0x05
2590 static struct hda_input_mux alc880_test_capture_source = {
2591 .num_items = 7,
2592 .items = {
2593 { "In-1", 0x0 },
2594 { "In-2", 0x1 },
2595 { "In-3", 0x2 },
2596 { "In-4", 0x3 },
2597 { "CD", 0x4 },
2598 { "Front", 0x5 },
2599 { "Surround", 0x6 },
2603 static struct hda_channel_mode alc880_test_modes[4] = {
2604 { 2, NULL },
2605 { 4, NULL },
2606 { 6, NULL },
2607 { 8, NULL },
2610 static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol,
2611 struct snd_ctl_elem_info *uinfo)
2613 static char *texts[] = {
2614 "N/A", "Line Out", "HP Out",
2615 "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
2617 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
2618 uinfo->count = 1;
2619 uinfo->value.enumerated.items = 8;
2620 if (uinfo->value.enumerated.item >= 8)
2621 uinfo->value.enumerated.item = 7;
2622 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
2623 return 0;
2626 static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol,
2627 struct snd_ctl_elem_value *ucontrol)
2629 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2630 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2631 unsigned int pin_ctl, item = 0;
2633 pin_ctl = snd_hda_codec_read(codec, nid, 0,
2634 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
2635 if (pin_ctl & AC_PINCTL_OUT_EN) {
2636 if (pin_ctl & AC_PINCTL_HP_EN)
2637 item = 2;
2638 else
2639 item = 1;
2640 } else if (pin_ctl & AC_PINCTL_IN_EN) {
2641 switch (pin_ctl & AC_PINCTL_VREFEN) {
2642 case AC_PINCTL_VREF_HIZ: item = 3; break;
2643 case AC_PINCTL_VREF_50: item = 4; break;
2644 case AC_PINCTL_VREF_GRD: item = 5; break;
2645 case AC_PINCTL_VREF_80: item = 6; break;
2646 case AC_PINCTL_VREF_100: item = 7; break;
2649 ucontrol->value.enumerated.item[0] = item;
2650 return 0;
2653 static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol,
2654 struct snd_ctl_elem_value *ucontrol)
2656 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2657 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2658 static unsigned int ctls[] = {
2659 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
2660 AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
2661 AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
2662 AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
2663 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
2664 AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
2666 unsigned int old_ctl, new_ctl;
2668 old_ctl = snd_hda_codec_read(codec, nid, 0,
2669 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
2670 new_ctl = ctls[ucontrol->value.enumerated.item[0]];
2671 if (old_ctl != new_ctl) {
2672 int val;
2673 snd_hda_codec_write_cache(codec, nid, 0,
2674 AC_VERB_SET_PIN_WIDGET_CONTROL,
2675 new_ctl);
2676 val = ucontrol->value.enumerated.item[0] >= 3 ?
2677 HDA_AMP_MUTE : 0;
2678 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
2679 HDA_AMP_MUTE, val);
2680 return 1;
2682 return 0;
2685 static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol,
2686 struct snd_ctl_elem_info *uinfo)
2688 static char *texts[] = {
2689 "Front", "Surround", "CLFE", "Side"
2691 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
2692 uinfo->count = 1;
2693 uinfo->value.enumerated.items = 4;
2694 if (uinfo->value.enumerated.item >= 4)
2695 uinfo->value.enumerated.item = 3;
2696 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
2697 return 0;
2700 static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol,
2701 struct snd_ctl_elem_value *ucontrol)
2703 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2704 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2705 unsigned int sel;
2707 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
2708 ucontrol->value.enumerated.item[0] = sel & 3;
2709 return 0;
2712 static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol,
2713 struct snd_ctl_elem_value *ucontrol)
2715 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2716 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2717 unsigned int sel;
2719 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
2720 if (ucontrol->value.enumerated.item[0] != sel) {
2721 sel = ucontrol->value.enumerated.item[0] & 3;
2722 snd_hda_codec_write_cache(codec, nid, 0,
2723 AC_VERB_SET_CONNECT_SEL, sel);
2724 return 1;
2726 return 0;
2729 #define PIN_CTL_TEST(xname,nid) { \
2730 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2731 .name = xname, \
2732 .info = alc_test_pin_ctl_info, \
2733 .get = alc_test_pin_ctl_get, \
2734 .put = alc_test_pin_ctl_put, \
2735 .private_value = nid \
2738 #define PIN_SRC_TEST(xname,nid) { \
2739 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2740 .name = xname, \
2741 .info = alc_test_pin_src_info, \
2742 .get = alc_test_pin_src_get, \
2743 .put = alc_test_pin_src_put, \
2744 .private_value = nid \
2747 static struct snd_kcontrol_new alc880_test_mixer[] = {
2748 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2749 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2750 HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
2751 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
2752 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2753 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
2754 HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
2755 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
2756 PIN_CTL_TEST("Front Pin Mode", 0x14),
2757 PIN_CTL_TEST("Surround Pin Mode", 0x15),
2758 PIN_CTL_TEST("CLFE Pin Mode", 0x16),
2759 PIN_CTL_TEST("Side Pin Mode", 0x17),
2760 PIN_CTL_TEST("In-1 Pin Mode", 0x18),
2761 PIN_CTL_TEST("In-2 Pin Mode", 0x19),
2762 PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
2763 PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
2764 PIN_SRC_TEST("In-1 Pin Source", 0x18),
2765 PIN_SRC_TEST("In-2 Pin Source", 0x19),
2766 PIN_SRC_TEST("In-3 Pin Source", 0x1a),
2767 PIN_SRC_TEST("In-4 Pin Source", 0x1b),
2768 HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
2769 HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
2770 HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
2771 HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
2772 HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
2773 HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
2774 HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
2775 HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
2776 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
2777 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
2779 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2780 .name = "Channel Mode",
2781 .info = alc_ch_mode_info,
2782 .get = alc_ch_mode_get,
2783 .put = alc_ch_mode_put,
2785 { } /* end */
2788 static struct hda_verb alc880_test_init_verbs[] = {
2789 /* Unmute inputs of 0x0c - 0x0f */
2790 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2791 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2792 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2793 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2794 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2795 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2796 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2797 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2798 /* Vol output for 0x0c-0x0f */
2799 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2800 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2801 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2802 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2803 /* Set output pins 0x14-0x17 */
2804 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2805 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2806 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2807 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2808 /* Unmute output pins 0x14-0x17 */
2809 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2810 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2811 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2812 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2813 /* Set input pins 0x18-0x1c */
2814 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2815 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2816 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2817 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2818 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2819 /* Mute input pins 0x18-0x1b */
2820 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2821 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2822 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2823 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2824 /* ADC set up */
2825 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2826 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
2827 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2828 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
2829 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2830 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
2831 /* Analog input/passthru */
2832 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2833 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2834 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
2835 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
2836 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
2839 #endif
2844 static const char *alc880_models[ALC880_MODEL_LAST] = {
2845 [ALC880_3ST] = "3stack",
2846 [ALC880_TCL_S700] = "tcl",
2847 [ALC880_3ST_DIG] = "3stack-digout",
2848 [ALC880_CLEVO] = "clevo",
2849 [ALC880_5ST] = "5stack",
2850 [ALC880_5ST_DIG] = "5stack-digout",
2851 [ALC880_W810] = "w810",
2852 [ALC880_Z71V] = "z71v",
2853 [ALC880_6ST] = "6stack",
2854 [ALC880_6ST_DIG] = "6stack-digout",
2855 [ALC880_ASUS] = "asus",
2856 [ALC880_ASUS_W1V] = "asus-w1v",
2857 [ALC880_ASUS_DIG] = "asus-dig",
2858 [ALC880_ASUS_DIG2] = "asus-dig2",
2859 [ALC880_UNIWILL_DIG] = "uniwill",
2860 [ALC880_UNIWILL_P53] = "uniwill-p53",
2861 [ALC880_FUJITSU] = "fujitsu",
2862 [ALC880_F1734] = "F1734",
2863 [ALC880_LG] = "lg",
2864 [ALC880_LG_LW] = "lg-lw",
2865 #ifdef CONFIG_SND_DEBUG
2866 [ALC880_TEST] = "test",
2867 #endif
2868 [ALC880_AUTO] = "auto",
2871 static struct snd_pci_quirk alc880_cfg_tbl[] = {
2872 SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_W810),
2873 SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_5ST_DIG),
2874 SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_6ST),
2875 SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_3ST_DIG),
2876 SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_6ST_DIG),
2877 SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_6ST_DIG),
2878 SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_6ST_DIG),
2879 SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_3ST_DIG),
2880 SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_3ST),
2881 SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_6ST_DIG),
2882 SND_PCI_QUIRK(0x103c, 0x2a09, "HP", ALC880_5ST),
2883 SND_PCI_QUIRK(0x1043, 0x10b3, "ASUS W1V", ALC880_ASUS_W1V),
2884 SND_PCI_QUIRK(0x1043, 0x10c2, "ASUS W6A", ALC880_ASUS_DIG),
2885 SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS Wxx", ALC880_ASUS_DIG),
2886 SND_PCI_QUIRK(0x1043, 0x1113, "ASUS", ALC880_ASUS_DIG),
2887 SND_PCI_QUIRK(0x1043, 0x1123, "ASUS", ALC880_ASUS_DIG),
2888 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS", ALC880_ASUS_DIG),
2889 SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_Z71V),
2890 /* SND_PCI_QUIRK(0x1043, 0x1964, "ASUS", ALC880_ASUS_DIG), */
2891 SND_PCI_QUIRK(0x1043, 0x1973, "ASUS", ALC880_ASUS_DIG),
2892 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS", ALC880_ASUS_DIG),
2893 SND_PCI_QUIRK(0x1043, 0x814e, "ASUS", ALC880_ASUS),
2894 SND_PCI_QUIRK(0x1043, 0x8181, "ASUS P4GPL", ALC880_ASUS_DIG),
2895 SND_PCI_QUIRK(0x1043, 0x8196, "ASUS P5GD1", ALC880_6ST),
2896 SND_PCI_QUIRK(0x1043, 0x81b4, "ASUS", ALC880_6ST),
2897 SND_PCI_QUIRK(0x1043, 0, "ASUS", ALC880_ASUS), /* default ASUS */
2898 SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_3ST),
2899 SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_3ST),
2900 SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_5ST),
2901 SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_5ST),
2902 SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_5ST),
2903 SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_6ST_DIG),
2904 SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_6ST_DIG),
2905 SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_6ST_DIG),
2906 SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_6ST_DIG),
2907 SND_PCI_QUIRK(0x1558, 0x0520, "Clevo m520G", ALC880_CLEVO),
2908 SND_PCI_QUIRK(0x1558, 0x0660, "Clevo m655n", ALC880_CLEVO),
2909 SND_PCI_QUIRK(0x1558, 0x5401, "ASUS", ALC880_ASUS_DIG2),
2910 SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_5ST_DIG),
2911 SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_UNIWILL_DIG),
2912 SND_PCI_QUIRK(0x1584, 0x9054, "Uniwlll", ALC880_F1734),
2913 SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_UNIWILL),
2914 SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_UNIWILL_P53),
2915 SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_W810),
2916 SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_5ST_DIG),
2917 SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_5ST_DIG),
2918 SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_F1734),
2919 SND_PCI_QUIRK(0x1734, 0x10ac, "FSC", ALC880_UNIWILL),
2920 SND_PCI_QUIRK(0x1734, 0x10b0, "Fujitsu", ALC880_FUJITSU),
2921 SND_PCI_QUIRK(0x1854, 0x0018, "LG LW20", ALC880_LG_LW),
2922 SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_LG),
2923 SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_LG),
2924 SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_LG_LW),
2925 SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_TCL_S700),
2926 SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_6ST_DIG), /* broken BIOS */
2927 SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_6ST_DIG),
2928 SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_5ST_DIG),
2929 SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_5ST_DIG),
2930 SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_5ST_DIG),
2931 SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_3ST_DIG),
2932 SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_5ST_DIG),
2933 SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_3ST_DIG),
2934 SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_3ST_DIG),
2935 SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_5ST_DIG),
2936 SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_5ST_DIG),
2937 SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_5ST_DIG),
2938 SND_PCI_QUIRK(0x8086, 0, "Intel mobo", ALC880_3ST), /* default Intel */
2939 SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_5ST_DIG),
2940 SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_6ST_DIG),
2945 * ALC880 codec presets
2947 static struct alc_config_preset alc880_presets[] = {
2948 [ALC880_3ST] = {
2949 .mixers = { alc880_three_stack_mixer },
2950 .init_verbs = { alc880_volume_init_verbs,
2951 alc880_pin_3stack_init_verbs },
2952 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2953 .dac_nids = alc880_dac_nids,
2954 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
2955 .channel_mode = alc880_threestack_modes,
2956 .need_dac_fix = 1,
2957 .input_mux = &alc880_capture_source,
2959 [ALC880_3ST_DIG] = {
2960 .mixers = { alc880_three_stack_mixer },
2961 .init_verbs = { alc880_volume_init_verbs,
2962 alc880_pin_3stack_init_verbs },
2963 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2964 .dac_nids = alc880_dac_nids,
2965 .dig_out_nid = ALC880_DIGOUT_NID,
2966 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
2967 .channel_mode = alc880_threestack_modes,
2968 .need_dac_fix = 1,
2969 .input_mux = &alc880_capture_source,
2971 [ALC880_TCL_S700] = {
2972 .mixers = { alc880_tcl_s700_mixer },
2973 .init_verbs = { alc880_volume_init_verbs,
2974 alc880_pin_tcl_S700_init_verbs,
2975 alc880_gpio2_init_verbs },
2976 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2977 .dac_nids = alc880_dac_nids,
2978 .hp_nid = 0x03,
2979 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
2980 .channel_mode = alc880_2_jack_modes,
2981 .input_mux = &alc880_capture_source,
2983 [ALC880_5ST] = {
2984 .mixers = { alc880_three_stack_mixer,
2985 alc880_five_stack_mixer},
2986 .init_verbs = { alc880_volume_init_verbs,
2987 alc880_pin_5stack_init_verbs },
2988 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2989 .dac_nids = alc880_dac_nids,
2990 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
2991 .channel_mode = alc880_fivestack_modes,
2992 .input_mux = &alc880_capture_source,
2994 [ALC880_5ST_DIG] = {
2995 .mixers = { alc880_three_stack_mixer,
2996 alc880_five_stack_mixer },
2997 .init_verbs = { alc880_volume_init_verbs,
2998 alc880_pin_5stack_init_verbs },
2999 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3000 .dac_nids = alc880_dac_nids,
3001 .dig_out_nid = ALC880_DIGOUT_NID,
3002 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
3003 .channel_mode = alc880_fivestack_modes,
3004 .input_mux = &alc880_capture_source,
3006 [ALC880_6ST] = {
3007 .mixers = { alc880_six_stack_mixer },
3008 .init_verbs = { alc880_volume_init_verbs,
3009 alc880_pin_6stack_init_verbs },
3010 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
3011 .dac_nids = alc880_6st_dac_nids,
3012 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
3013 .channel_mode = alc880_sixstack_modes,
3014 .input_mux = &alc880_6stack_capture_source,
3016 [ALC880_6ST_DIG] = {
3017 .mixers = { alc880_six_stack_mixer },
3018 .init_verbs = { alc880_volume_init_verbs,
3019 alc880_pin_6stack_init_verbs },
3020 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
3021 .dac_nids = alc880_6st_dac_nids,
3022 .dig_out_nid = ALC880_DIGOUT_NID,
3023 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
3024 .channel_mode = alc880_sixstack_modes,
3025 .input_mux = &alc880_6stack_capture_source,
3027 [ALC880_W810] = {
3028 .mixers = { alc880_w810_base_mixer },
3029 .init_verbs = { alc880_volume_init_verbs,
3030 alc880_pin_w810_init_verbs,
3031 alc880_gpio2_init_verbs },
3032 .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
3033 .dac_nids = alc880_w810_dac_nids,
3034 .dig_out_nid = ALC880_DIGOUT_NID,
3035 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
3036 .channel_mode = alc880_w810_modes,
3037 .input_mux = &alc880_capture_source,
3039 [ALC880_Z71V] = {
3040 .mixers = { alc880_z71v_mixer },
3041 .init_verbs = { alc880_volume_init_verbs,
3042 alc880_pin_z71v_init_verbs },
3043 .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
3044 .dac_nids = alc880_z71v_dac_nids,
3045 .dig_out_nid = ALC880_DIGOUT_NID,
3046 .hp_nid = 0x03,
3047 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3048 .channel_mode = alc880_2_jack_modes,
3049 .input_mux = &alc880_capture_source,
3051 [ALC880_F1734] = {
3052 .mixers = { alc880_f1734_mixer },
3053 .init_verbs = { alc880_volume_init_verbs,
3054 alc880_pin_f1734_init_verbs },
3055 .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
3056 .dac_nids = alc880_f1734_dac_nids,
3057 .hp_nid = 0x02,
3058 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3059 .channel_mode = alc880_2_jack_modes,
3060 .input_mux = &alc880_capture_source,
3062 [ALC880_ASUS] = {
3063 .mixers = { alc880_asus_mixer },
3064 .init_verbs = { alc880_volume_init_verbs,
3065 alc880_pin_asus_init_verbs,
3066 alc880_gpio1_init_verbs },
3067 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3068 .dac_nids = alc880_asus_dac_nids,
3069 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3070 .channel_mode = alc880_asus_modes,
3071 .need_dac_fix = 1,
3072 .input_mux = &alc880_capture_source,
3074 [ALC880_ASUS_DIG] = {
3075 .mixers = { alc880_asus_mixer },
3076 .init_verbs = { alc880_volume_init_verbs,
3077 alc880_pin_asus_init_verbs,
3078 alc880_gpio1_init_verbs },
3079 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3080 .dac_nids = alc880_asus_dac_nids,
3081 .dig_out_nid = ALC880_DIGOUT_NID,
3082 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3083 .channel_mode = alc880_asus_modes,
3084 .need_dac_fix = 1,
3085 .input_mux = &alc880_capture_source,
3087 [ALC880_ASUS_DIG2] = {
3088 .mixers = { alc880_asus_mixer },
3089 .init_verbs = { alc880_volume_init_verbs,
3090 alc880_pin_asus_init_verbs,
3091 alc880_gpio2_init_verbs }, /* use GPIO2 */
3092 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3093 .dac_nids = alc880_asus_dac_nids,
3094 .dig_out_nid = ALC880_DIGOUT_NID,
3095 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3096 .channel_mode = alc880_asus_modes,
3097 .need_dac_fix = 1,
3098 .input_mux = &alc880_capture_source,
3100 [ALC880_ASUS_W1V] = {
3101 .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
3102 .init_verbs = { alc880_volume_init_verbs,
3103 alc880_pin_asus_init_verbs,
3104 alc880_gpio1_init_verbs },
3105 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3106 .dac_nids = alc880_asus_dac_nids,
3107 .dig_out_nid = ALC880_DIGOUT_NID,
3108 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3109 .channel_mode = alc880_asus_modes,
3110 .need_dac_fix = 1,
3111 .input_mux = &alc880_capture_source,
3113 [ALC880_UNIWILL_DIG] = {
3114 .mixers = { alc880_asus_mixer, alc880_pcbeep_mixer },
3115 .init_verbs = { alc880_volume_init_verbs,
3116 alc880_pin_asus_init_verbs },
3117 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3118 .dac_nids = alc880_asus_dac_nids,
3119 .dig_out_nid = ALC880_DIGOUT_NID,
3120 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3121 .channel_mode = alc880_asus_modes,
3122 .need_dac_fix = 1,
3123 .input_mux = &alc880_capture_source,
3125 [ALC880_UNIWILL] = {
3126 .mixers = { alc880_uniwill_mixer },
3127 .init_verbs = { alc880_volume_init_verbs,
3128 alc880_uniwill_init_verbs },
3129 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3130 .dac_nids = alc880_asus_dac_nids,
3131 .dig_out_nid = ALC880_DIGOUT_NID,
3132 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3133 .channel_mode = alc880_threestack_modes,
3134 .need_dac_fix = 1,
3135 .input_mux = &alc880_capture_source,
3136 .unsol_event = alc880_uniwill_unsol_event,
3137 .init_hook = alc880_uniwill_automute,
3139 [ALC880_UNIWILL_P53] = {
3140 .mixers = { alc880_uniwill_p53_mixer },
3141 .init_verbs = { alc880_volume_init_verbs,
3142 alc880_uniwill_p53_init_verbs },
3143 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3144 .dac_nids = alc880_asus_dac_nids,
3145 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
3146 .channel_mode = alc880_threestack_modes,
3147 .input_mux = &alc880_capture_source,
3148 .unsol_event = alc880_uniwill_p53_unsol_event,
3149 .init_hook = alc880_uniwill_p53_hp_automute,
3151 [ALC880_FUJITSU] = {
3152 .mixers = { alc880_fujitsu_mixer,
3153 alc880_pcbeep_mixer, },
3154 .init_verbs = { alc880_volume_init_verbs,
3155 alc880_uniwill_p53_init_verbs,
3156 alc880_beep_init_verbs },
3157 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3158 .dac_nids = alc880_dac_nids,
3159 .dig_out_nid = ALC880_DIGOUT_NID,
3160 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3161 .channel_mode = alc880_2_jack_modes,
3162 .input_mux = &alc880_capture_source,
3163 .unsol_event = alc880_uniwill_p53_unsol_event,
3164 .init_hook = alc880_uniwill_p53_hp_automute,
3166 [ALC880_CLEVO] = {
3167 .mixers = { alc880_three_stack_mixer },
3168 .init_verbs = { alc880_volume_init_verbs,
3169 alc880_pin_clevo_init_verbs },
3170 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3171 .dac_nids = alc880_dac_nids,
3172 .hp_nid = 0x03,
3173 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3174 .channel_mode = alc880_threestack_modes,
3175 .need_dac_fix = 1,
3176 .input_mux = &alc880_capture_source,
3178 [ALC880_LG] = {
3179 .mixers = { alc880_lg_mixer },
3180 .init_verbs = { alc880_volume_init_verbs,
3181 alc880_lg_init_verbs },
3182 .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids),
3183 .dac_nids = alc880_lg_dac_nids,
3184 .dig_out_nid = ALC880_DIGOUT_NID,
3185 .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes),
3186 .channel_mode = alc880_lg_ch_modes,
3187 .need_dac_fix = 1,
3188 .input_mux = &alc880_lg_capture_source,
3189 .unsol_event = alc880_lg_unsol_event,
3190 .init_hook = alc880_lg_automute,
3191 #ifdef CONFIG_SND_HDA_POWER_SAVE
3192 .loopbacks = alc880_lg_loopbacks,
3193 #endif
3195 [ALC880_LG_LW] = {
3196 .mixers = { alc880_lg_lw_mixer },
3197 .init_verbs = { alc880_volume_init_verbs,
3198 alc880_lg_lw_init_verbs },
3199 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3200 .dac_nids = alc880_dac_nids,
3201 .dig_out_nid = ALC880_DIGOUT_NID,
3202 .num_channel_mode = ARRAY_SIZE(alc880_lg_lw_modes),
3203 .channel_mode = alc880_lg_lw_modes,
3204 .input_mux = &alc880_lg_lw_capture_source,
3205 .unsol_event = alc880_lg_lw_unsol_event,
3206 .init_hook = alc880_lg_lw_automute,
3208 #ifdef CONFIG_SND_DEBUG
3209 [ALC880_TEST] = {
3210 .mixers = { alc880_test_mixer },
3211 .init_verbs = { alc880_test_init_verbs },
3212 .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
3213 .dac_nids = alc880_test_dac_nids,
3214 .dig_out_nid = ALC880_DIGOUT_NID,
3215 .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
3216 .channel_mode = alc880_test_modes,
3217 .input_mux = &alc880_test_capture_source,
3219 #endif
3223 * Automatic parse of I/O pins from the BIOS configuration
3226 #define NUM_CONTROL_ALLOC 32
3227 #define NUM_VERB_ALLOC 32
3229 enum {
3230 ALC_CTL_WIDGET_VOL,
3231 ALC_CTL_WIDGET_MUTE,
3232 ALC_CTL_BIND_MUTE,
3234 static struct snd_kcontrol_new alc880_control_templates[] = {
3235 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
3236 HDA_CODEC_MUTE(NULL, 0, 0, 0),
3237 HDA_BIND_MUTE(NULL, 0, 0, 0),
3240 /* add dynamic controls */
3241 static int add_control(struct alc_spec *spec, int type, const char *name,
3242 unsigned long val)
3244 struct snd_kcontrol_new *knew;
3246 if (spec->num_kctl_used >= spec->num_kctl_alloc) {
3247 int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC;
3249 /* array + terminator */
3250 knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL);
3251 if (!knew)
3252 return -ENOMEM;
3253 if (spec->kctl_alloc) {
3254 memcpy(knew, spec->kctl_alloc,
3255 sizeof(*knew) * spec->num_kctl_alloc);
3256 kfree(spec->kctl_alloc);
3258 spec->kctl_alloc = knew;
3259 spec->num_kctl_alloc = num;
3262 knew = &spec->kctl_alloc[spec->num_kctl_used];
3263 *knew = alc880_control_templates[type];
3264 knew->name = kstrdup(name, GFP_KERNEL);
3265 if (!knew->name)
3266 return -ENOMEM;
3267 knew->private_value = val;
3268 spec->num_kctl_used++;
3269 return 0;
3272 #define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
3273 #define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
3274 #define alc880_is_multi_pin(nid) ((nid) >= 0x18)
3275 #define alc880_multi_pin_idx(nid) ((nid) - 0x18)
3276 #define alc880_is_input_pin(nid) ((nid) >= 0x18)
3277 #define alc880_input_pin_idx(nid) ((nid) - 0x18)
3278 #define alc880_idx_to_dac(nid) ((nid) + 0x02)
3279 #define alc880_dac_to_idx(nid) ((nid) - 0x02)
3280 #define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
3281 #define alc880_idx_to_selector(nid) ((nid) + 0x10)
3282 #define ALC880_PIN_CD_NID 0x1c
3284 /* fill in the dac_nids table from the parsed pin configuration */
3285 static int alc880_auto_fill_dac_nids(struct alc_spec *spec,
3286 const struct auto_pin_cfg *cfg)
3288 hda_nid_t nid;
3289 int assigned[4];
3290 int i, j;
3292 memset(assigned, 0, sizeof(assigned));
3293 spec->multiout.dac_nids = spec->private_dac_nids;
3295 /* check the pins hardwired to audio widget */
3296 for (i = 0; i < cfg->line_outs; i++) {
3297 nid = cfg->line_out_pins[i];
3298 if (alc880_is_fixed_pin(nid)) {
3299 int idx = alc880_fixed_pin_idx(nid);
3300 spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
3301 assigned[idx] = 1;
3304 /* left pins can be connect to any audio widget */
3305 for (i = 0; i < cfg->line_outs; i++) {
3306 nid = cfg->line_out_pins[i];
3307 if (alc880_is_fixed_pin(nid))
3308 continue;
3309 /* search for an empty channel */
3310 for (j = 0; j < cfg->line_outs; j++) {
3311 if (!assigned[j]) {
3312 spec->multiout.dac_nids[i] =
3313 alc880_idx_to_dac(j);
3314 assigned[j] = 1;
3315 break;
3319 spec->multiout.num_dacs = cfg->line_outs;
3320 return 0;
3323 /* add playback controls from the parsed DAC table */
3324 static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
3325 const struct auto_pin_cfg *cfg)
3327 char name[32];
3328 static const char *chname[4] = {
3329 "Front", "Surround", NULL /*CLFE*/, "Side"
3331 hda_nid_t nid;
3332 int i, err;
3334 for (i = 0; i < cfg->line_outs; i++) {
3335 if (!spec->multiout.dac_nids[i])
3336 continue;
3337 nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
3338 if (i == 2) {
3339 /* Center/LFE */
3340 err = add_control(spec, ALC_CTL_WIDGET_VOL,
3341 "Center Playback Volume",
3342 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
3343 HDA_OUTPUT));
3344 if (err < 0)
3345 return err;
3346 err = add_control(spec, ALC_CTL_WIDGET_VOL,
3347 "LFE Playback Volume",
3348 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
3349 HDA_OUTPUT));
3350 if (err < 0)
3351 return err;
3352 err = add_control(spec, ALC_CTL_BIND_MUTE,
3353 "Center Playback Switch",
3354 HDA_COMPOSE_AMP_VAL(nid, 1, 2,
3355 HDA_INPUT));
3356 if (err < 0)
3357 return err;
3358 err = add_control(spec, ALC_CTL_BIND_MUTE,
3359 "LFE Playback Switch",
3360 HDA_COMPOSE_AMP_VAL(nid, 2, 2,
3361 HDA_INPUT));
3362 if (err < 0)
3363 return err;
3364 } else {
3365 sprintf(name, "%s Playback Volume", chname[i]);
3366 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
3367 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
3368 HDA_OUTPUT));
3369 if (err < 0)
3370 return err;
3371 sprintf(name, "%s Playback Switch", chname[i]);
3372 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
3373 HDA_COMPOSE_AMP_VAL(nid, 3, 2,
3374 HDA_INPUT));
3375 if (err < 0)
3376 return err;
3379 return 0;
3382 /* add playback controls for speaker and HP outputs */
3383 static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
3384 const char *pfx)
3386 hda_nid_t nid;
3387 int err;
3388 char name[32];
3390 if (!pin)
3391 return 0;
3393 if (alc880_is_fixed_pin(pin)) {
3394 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
3395 /* specify the DAC as the extra output */
3396 if (!spec->multiout.hp_nid)
3397 spec->multiout.hp_nid = nid;
3398 else
3399 spec->multiout.extra_out_nid[0] = nid;
3400 /* control HP volume/switch on the output mixer amp */
3401 nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
3402 sprintf(name, "%s Playback Volume", pfx);
3403 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
3404 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
3405 if (err < 0)
3406 return err;
3407 sprintf(name, "%s Playback Switch", pfx);
3408 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
3409 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
3410 if (err < 0)
3411 return err;
3412 } else if (alc880_is_multi_pin(pin)) {
3413 /* set manual connection */
3414 /* we have only a switch on HP-out PIN */
3415 sprintf(name, "%s Playback Switch", pfx);
3416 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
3417 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
3418 if (err < 0)
3419 return err;
3421 return 0;
3424 /* create input playback/capture controls for the given pin */
3425 static int new_analog_input(struct alc_spec *spec, hda_nid_t pin,
3426 const char *ctlname,
3427 int idx, hda_nid_t mix_nid)
3429 char name[32];
3430 int err;
3432 sprintf(name, "%s Playback Volume", ctlname);
3433 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
3434 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
3435 if (err < 0)
3436 return err;
3437 sprintf(name, "%s Playback Switch", ctlname);
3438 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
3439 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
3440 if (err < 0)
3441 return err;
3442 return 0;
3445 /* create playback/capture controls for input pins */
3446 static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec,
3447 const struct auto_pin_cfg *cfg)
3449 struct hda_input_mux *imux = &spec->private_imux;
3450 int i, err, idx;
3452 for (i = 0; i < AUTO_PIN_LAST; i++) {
3453 if (alc880_is_input_pin(cfg->input_pins[i])) {
3454 idx = alc880_input_pin_idx(cfg->input_pins[i]);
3455 err = new_analog_input(spec, cfg->input_pins[i],
3456 auto_pin_cfg_labels[i],
3457 idx, 0x0b);
3458 if (err < 0)
3459 return err;
3460 imux->items[imux->num_items].label =
3461 auto_pin_cfg_labels[i];
3462 imux->items[imux->num_items].index =
3463 alc880_input_pin_idx(cfg->input_pins[i]);
3464 imux->num_items++;
3467 return 0;
3470 static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
3471 hda_nid_t nid, int pin_type,
3472 int dac_idx)
3474 /* set as output */
3475 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
3476 pin_type);
3477 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
3478 AMP_OUT_UNMUTE);
3479 /* need the manual connection? */
3480 if (alc880_is_multi_pin(nid)) {
3481 struct alc_spec *spec = codec->spec;
3482 int idx = alc880_multi_pin_idx(nid);
3483 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
3484 AC_VERB_SET_CONNECT_SEL,
3485 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
3489 static int get_pin_type(int line_out_type)
3491 if (line_out_type == AUTO_PIN_HP_OUT)
3492 return PIN_HP;
3493 else
3494 return PIN_OUT;
3497 static void alc880_auto_init_multi_out(struct hda_codec *codec)
3499 struct alc_spec *spec = codec->spec;
3500 int i;
3502 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
3503 for (i = 0; i < spec->autocfg.line_outs; i++) {
3504 hda_nid_t nid = spec->autocfg.line_out_pins[i];
3505 int pin_type = get_pin_type(spec->autocfg.line_out_type);
3506 alc880_auto_set_output_and_unmute(codec, nid, pin_type, i);
3510 static void alc880_auto_init_extra_out(struct hda_codec *codec)
3512 struct alc_spec *spec = codec->spec;
3513 hda_nid_t pin;
3515 pin = spec->autocfg.speaker_pins[0];
3516 if (pin) /* connect to front */
3517 alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
3518 pin = spec->autocfg.hp_pins[0];
3519 if (pin) /* connect to front */
3520 alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
3523 static void alc880_auto_init_analog_input(struct hda_codec *codec)
3525 struct alc_spec *spec = codec->spec;
3526 int i;
3528 for (i = 0; i < AUTO_PIN_LAST; i++) {
3529 hda_nid_t nid = spec->autocfg.input_pins[i];
3530 if (alc880_is_input_pin(nid)) {
3531 snd_hda_codec_write(codec, nid, 0,
3532 AC_VERB_SET_PIN_WIDGET_CONTROL,
3533 i <= AUTO_PIN_FRONT_MIC ?
3534 PIN_VREF80 : PIN_IN);
3535 if (nid != ALC880_PIN_CD_NID)
3536 snd_hda_codec_write(codec, nid, 0,
3537 AC_VERB_SET_AMP_GAIN_MUTE,
3538 AMP_OUT_MUTE);
3543 /* parse the BIOS configuration and set up the alc_spec */
3544 /* return 1 if successful, 0 if the proper config is not found,
3545 * or a negative error code
3547 static int alc880_parse_auto_config(struct hda_codec *codec)
3549 struct alc_spec *spec = codec->spec;
3550 int err;
3551 static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
3553 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
3554 alc880_ignore);
3555 if (err < 0)
3556 return err;
3557 if (!spec->autocfg.line_outs)
3558 return 0; /* can't find valid BIOS pin config */
3560 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
3561 if (err < 0)
3562 return err;
3563 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
3564 if (err < 0)
3565 return err;
3566 err = alc880_auto_create_extra_out(spec,
3567 spec->autocfg.speaker_pins[0],
3568 "Speaker");
3569 if (err < 0)
3570 return err;
3571 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
3572 "Headphone");
3573 if (err < 0)
3574 return err;
3575 err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
3576 if (err < 0)
3577 return err;
3579 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
3581 if (spec->autocfg.dig_out_pin)
3582 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
3583 if (spec->autocfg.dig_in_pin)
3584 spec->dig_in_nid = ALC880_DIGIN_NID;
3586 if (spec->kctl_alloc)
3587 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
3589 spec->init_verbs[spec->num_init_verbs++] = alc880_volume_init_verbs;
3591 spec->num_mux_defs = 1;
3592 spec->input_mux = &spec->private_imux;
3594 return 1;
3597 /* additional initialization for auto-configuration model */
3598 static void alc880_auto_init(struct hda_codec *codec)
3600 alc880_auto_init_multi_out(codec);
3601 alc880_auto_init_extra_out(codec);
3602 alc880_auto_init_analog_input(codec);
3606 * OK, here we have finally the patch for ALC880
3609 static int patch_alc880(struct hda_codec *codec)
3611 struct alc_spec *spec;
3612 int board_config;
3613 int err;
3615 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
3616 if (spec == NULL)
3617 return -ENOMEM;
3619 codec->spec = spec;
3621 board_config = snd_hda_check_board_config(codec, ALC880_MODEL_LAST,
3622 alc880_models,
3623 alc880_cfg_tbl);
3624 if (board_config < 0) {
3625 printk(KERN_INFO "hda_codec: Unknown model for ALC880, "
3626 "trying auto-probe from BIOS...\n");
3627 board_config = ALC880_AUTO;
3630 if (board_config == ALC880_AUTO) {
3631 /* automatic parse from the BIOS config */
3632 err = alc880_parse_auto_config(codec);
3633 if (err < 0) {
3634 alc_free(codec);
3635 return err;
3636 } else if (!err) {
3637 printk(KERN_INFO
3638 "hda_codec: Cannot set up configuration "
3639 "from BIOS. Using 3-stack mode...\n");
3640 board_config = ALC880_3ST;
3644 if (board_config != ALC880_AUTO)
3645 setup_preset(spec, &alc880_presets[board_config]);
3647 spec->stream_name_analog = "ALC880 Analog";
3648 spec->stream_analog_playback = &alc880_pcm_analog_playback;
3649 spec->stream_analog_capture = &alc880_pcm_analog_capture;
3650 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
3652 spec->stream_name_digital = "ALC880 Digital";
3653 spec->stream_digital_playback = &alc880_pcm_digital_playback;
3654 spec->stream_digital_capture = &alc880_pcm_digital_capture;
3656 if (!spec->adc_nids && spec->input_mux) {
3657 /* check whether NID 0x07 is valid */
3658 unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
3659 /* get type */
3660 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
3661 if (wcap != AC_WID_AUD_IN) {
3662 spec->adc_nids = alc880_adc_nids_alt;
3663 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
3664 spec->mixers[spec->num_mixers] =
3665 alc880_capture_alt_mixer;
3666 spec->num_mixers++;
3667 } else {
3668 spec->adc_nids = alc880_adc_nids;
3669 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
3670 spec->mixers[spec->num_mixers] = alc880_capture_mixer;
3671 spec->num_mixers++;
3675 spec->vmaster_nid = 0x0c;
3677 codec->patch_ops = alc_patch_ops;
3678 if (board_config == ALC880_AUTO)
3679 spec->init_hook = alc880_auto_init;
3680 #ifdef CONFIG_SND_HDA_POWER_SAVE
3681 if (!spec->loopback.amplist)
3682 spec->loopback.amplist = alc880_loopbacks;
3683 #endif
3685 return 0;
3690 * ALC260 support
3693 static hda_nid_t alc260_dac_nids[1] = {
3694 /* front */
3695 0x02,
3698 static hda_nid_t alc260_adc_nids[1] = {
3699 /* ADC0 */
3700 0x04,
3703 static hda_nid_t alc260_adc_nids_alt[1] = {
3704 /* ADC1 */
3705 0x05,
3708 static hda_nid_t alc260_hp_adc_nids[2] = {
3709 /* ADC1, 0 */
3710 0x05, 0x04
3713 /* NIDs used when simultaneous access to both ADCs makes sense. Note that
3714 * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
3716 static hda_nid_t alc260_dual_adc_nids[2] = {
3717 /* ADC0, ADC1 */
3718 0x04, 0x05
3721 #define ALC260_DIGOUT_NID 0x03
3722 #define ALC260_DIGIN_NID 0x06
3724 static struct hda_input_mux alc260_capture_source = {
3725 .num_items = 4,
3726 .items = {
3727 { "Mic", 0x0 },
3728 { "Front Mic", 0x1 },
3729 { "Line", 0x2 },
3730 { "CD", 0x4 },
3734 /* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
3735 * headphone jack and the internal CD lines since these are the only pins at
3736 * which audio can appear. For flexibility, also allow the option of
3737 * recording the mixer output on the second ADC (ADC0 doesn't have a
3738 * connection to the mixer output).
3740 static struct hda_input_mux alc260_fujitsu_capture_sources[2] = {
3742 .num_items = 3,
3743 .items = {
3744 { "Mic/Line", 0x0 },
3745 { "CD", 0x4 },
3746 { "Headphone", 0x2 },
3750 .num_items = 4,
3751 .items = {
3752 { "Mic/Line", 0x0 },
3753 { "CD", 0x4 },
3754 { "Headphone", 0x2 },
3755 { "Mixer", 0x5 },
3761 /* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to
3762 * the Fujitsu S702x, but jacks are marked differently.
3764 static struct hda_input_mux alc260_acer_capture_sources[2] = {
3766 .num_items = 4,
3767 .items = {
3768 { "Mic", 0x0 },
3769 { "Line", 0x2 },
3770 { "CD", 0x4 },
3771 { "Headphone", 0x5 },
3775 .num_items = 5,
3776 .items = {
3777 { "Mic", 0x0 },
3778 { "Line", 0x2 },
3779 { "CD", 0x4 },
3780 { "Headphone", 0x6 },
3781 { "Mixer", 0x5 },
3786 * This is just place-holder, so there's something for alc_build_pcms to look
3787 * at when it calculates the maximum number of channels. ALC260 has no mixer
3788 * element which allows changing the channel mode, so the verb list is
3789 * never used.
3791 static struct hda_channel_mode alc260_modes[1] = {
3792 { 2, NULL },
3796 /* Mixer combinations
3798 * basic: base_output + input + pc_beep + capture
3799 * HP: base_output + input + capture_alt
3800 * HP_3013: hp_3013 + input + capture
3801 * fujitsu: fujitsu + capture
3802 * acer: acer + capture
3805 static struct snd_kcontrol_new alc260_base_output_mixer[] = {
3806 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3807 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
3808 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
3809 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
3810 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
3811 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
3812 { } /* end */
3815 static struct snd_kcontrol_new alc260_input_mixer[] = {
3816 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3817 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
3818 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
3819 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
3820 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
3821 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
3822 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
3823 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
3824 { } /* end */
3827 static struct snd_kcontrol_new alc260_pc_beep_mixer[] = {
3828 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x07, 0x05, HDA_INPUT),
3829 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x07, 0x05, HDA_INPUT),
3830 { } /* end */
3833 /* update HP, line and mono out pins according to the master switch */
3834 static void alc260_hp_master_update(struct hda_codec *codec,
3835 hda_nid_t hp, hda_nid_t line,
3836 hda_nid_t mono)
3838 struct alc_spec *spec = codec->spec;
3839 unsigned int val = spec->master_sw ? PIN_HP : 0;
3840 /* change HP and line-out pins */
3841 snd_hda_codec_write(codec, 0x0f, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
3842 val);
3843 snd_hda_codec_write(codec, 0x10, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
3844 val);
3845 /* mono (speaker) depending on the HP jack sense */
3846 val = (val && !spec->jack_present) ? PIN_OUT : 0;
3847 snd_hda_codec_write(codec, 0x11, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
3848 val);
3851 static int alc260_hp_master_sw_get(struct snd_kcontrol *kcontrol,
3852 struct snd_ctl_elem_value *ucontrol)
3854 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3855 struct alc_spec *spec = codec->spec;
3856 *ucontrol->value.integer.value = spec->master_sw;
3857 return 0;
3860 static int alc260_hp_master_sw_put(struct snd_kcontrol *kcontrol,
3861 struct snd_ctl_elem_value *ucontrol)
3863 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3864 struct alc_spec *spec = codec->spec;
3865 int val = !!*ucontrol->value.integer.value;
3866 hda_nid_t hp, line, mono;
3868 if (val == spec->master_sw)
3869 return 0;
3870 spec->master_sw = val;
3871 hp = (kcontrol->private_value >> 16) & 0xff;
3872 line = (kcontrol->private_value >> 8) & 0xff;
3873 mono = kcontrol->private_value & 0xff;
3874 alc260_hp_master_update(codec, hp, line, mono);
3875 return 1;
3878 static struct snd_kcontrol_new alc260_hp_output_mixer[] = {
3880 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3881 .name = "Master Playback Switch",
3882 .info = snd_ctl_boolean_mono_info,
3883 .get = alc260_hp_master_sw_get,
3884 .put = alc260_hp_master_sw_put,
3885 .private_value = (0x0f << 16) | (0x10 << 8) | 0x11
3887 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3888 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
3889 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
3890 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
3891 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
3892 HDA_OUTPUT),
3893 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2, HDA_INPUT),
3894 { } /* end */
3897 static struct hda_verb alc260_hp_unsol_verbs[] = {
3898 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
3902 static void alc260_hp_automute(struct hda_codec *codec)
3904 struct alc_spec *spec = codec->spec;
3905 unsigned int present;
3907 present = snd_hda_codec_read(codec, 0x10, 0,
3908 AC_VERB_GET_PIN_SENSE, 0);
3909 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
3910 alc260_hp_master_update(codec, 0x0f, 0x10, 0x11);
3913 static void alc260_hp_unsol_event(struct hda_codec *codec, unsigned int res)
3915 if ((res >> 26) == ALC880_HP_EVENT)
3916 alc260_hp_automute(codec);
3919 static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
3921 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3922 .name = "Master Playback Switch",
3923 .info = snd_ctl_boolean_mono_info,
3924 .get = alc260_hp_master_sw_get,
3925 .put = alc260_hp_master_sw_put,
3926 .private_value = (0x10 << 16) | (0x15 << 8) | 0x11
3928 HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
3929 HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
3930 HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
3931 HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
3932 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3933 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
3934 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
3935 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
3936 { } /* end */
3939 static struct hda_verb alc260_hp_3013_unsol_verbs[] = {
3940 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
3944 static void alc260_hp_3013_automute(struct hda_codec *codec)
3946 struct alc_spec *spec = codec->spec;
3947 unsigned int present;
3949 present = snd_hda_codec_read(codec, 0x15, 0,
3950 AC_VERB_GET_PIN_SENSE, 0);
3951 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
3952 alc260_hp_master_update(codec, 0x10, 0x15, 0x11);
3955 static void alc260_hp_3013_unsol_event(struct hda_codec *codec,
3956 unsigned int res)
3958 if ((res >> 26) == ALC880_HP_EVENT)
3959 alc260_hp_3013_automute(codec);
3962 /* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12,
3963 * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10.
3965 static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
3966 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3967 HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
3968 ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
3969 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3970 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
3971 HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
3972 HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
3973 ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
3974 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
3975 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
3976 <<<<<<< HEAD:sound/pci/hda/patch_realtek.c
3977 HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
3978 HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x09, 2, HDA_INPUT),
3979 =======
3980 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
3981 HDA_BIND_MUTE("Speaker Playback Switch", 0x09, 2, HDA_INPUT),
3982 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a:sound/pci/hda/patch_realtek.c
3983 { } /* end */
3986 /* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current
3987 * versions of the ALC260 don't act on requests to enable mic bias from NID
3988 * 0x0f (used to drive the headphone jack in these laptops). The ALC260
3989 * datasheet doesn't mention this restriction. At this stage it's not clear
3990 * whether this behaviour is intentional or is a hardware bug in chip
3991 * revisions available in early 2006. Therefore for now allow the
3992 * "Headphone Jack Mode" control to span all choices, but if it turns out
3993 * that the lack of mic bias for this NID is intentional we could change the
3994 * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
3996 * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006
3997 * don't appear to make the mic bias available from the "line" jack, even
3998 * though the NID used for this jack (0x14) can supply it. The theory is
3999 * that perhaps Acer have included blocking capacitors between the ALC260
4000 * and the output jack. If this turns out to be the case for all such
4001 * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
4002 * to ALC_PIN_DIR_INOUT_NOMICBIAS.
4004 * The C20x Tablet series have a mono internal speaker which is controlled
4005 * via the chip's Mono sum widget and pin complex, so include the necessary
4006 * controls for such models. On models without a "mono speaker" the control
4007 * won't do anything.
4009 static struct snd_kcontrol_new alc260_acer_mixer[] = {
4010 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4011 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
4012 ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
4013 <<<<<<< HEAD:sound/pci/hda/patch_realtek.c
4014 HDA_CODEC_VOLUME_MONO("Mono Speaker Playback Volume", 0x0a, 1, 0x0,
4015 =======
4016 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
4017 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a:sound/pci/hda/patch_realtek.c
4018 HDA_OUTPUT),
4019 <<<<<<< HEAD:sound/pci/hda/patch_realtek.c
4020 HDA_BIND_MUTE_MONO("Mono Speaker Playback Switch", 0x0a, 1, 2,
4021 =======
4022 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2,
4023 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a:sound/pci/hda/patch_realtek.c
4024 HDA_INPUT),
4025 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4026 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4027 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4028 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4029 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
4030 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
4031 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
4032 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
4033 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
4034 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
4035 { } /* end */
4038 /* Packard bell V7900 ALC260 pin usage: HP = 0x0f, Mic jack = 0x12,
4039 * Line In jack = 0x14, CD audio = 0x16, pc beep = 0x17.
4041 static struct snd_kcontrol_new alc260_will_mixer[] = {
4042 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4043 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
4044 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4045 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4046 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
4047 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
4048 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
4049 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
4050 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4051 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4052 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
4053 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
4054 { } /* end */
4057 /* Replacer 672V ALC260 pin usage: Mic jack = 0x12,
4058 * Line In jack = 0x14, ATAPI Mic = 0x13, speaker = 0x0f.
4060 static struct snd_kcontrol_new alc260_replacer_672v_mixer[] = {
4061 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4062 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
4063 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4064 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4065 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
4066 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x07, 0x1, HDA_INPUT),
4067 HDA_CODEC_MUTE("ATATI Mic Playback Switch", 0x07, 0x1, HDA_INPUT),
4068 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
4069 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
4070 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
4071 { } /* end */
4074 /* capture mixer elements */
4075 static struct snd_kcontrol_new alc260_capture_mixer[] = {
4076 HDA_CODEC_VOLUME("Capture Volume", 0x04, 0x0, HDA_INPUT),
4077 HDA_CODEC_MUTE("Capture Switch", 0x04, 0x0, HDA_INPUT),
4078 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x05, 0x0, HDA_INPUT),
4079 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x05, 0x0, HDA_INPUT),
4081 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4082 /* The multiple "Capture Source" controls confuse alsamixer
4083 * So call somewhat different..
4085 /* .name = "Capture Source", */
4086 .name = "Input Source",
4087 .count = 2,
4088 .info = alc_mux_enum_info,
4089 .get = alc_mux_enum_get,
4090 .put = alc_mux_enum_put,
4092 { } /* end */
4095 static struct snd_kcontrol_new alc260_capture_alt_mixer[] = {
4096 HDA_CODEC_VOLUME("Capture Volume", 0x05, 0x0, HDA_INPUT),
4097 HDA_CODEC_MUTE("Capture Switch", 0x05, 0x0, HDA_INPUT),
4099 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4100 /* The multiple "Capture Source" controls confuse alsamixer
4101 * So call somewhat different..
4103 /* .name = "Capture Source", */
4104 .name = "Input Source",
4105 .count = 1,
4106 .info = alc_mux_enum_info,
4107 .get = alc_mux_enum_get,
4108 .put = alc_mux_enum_put,
4110 { } /* end */
4114 * initialization verbs
4116 static struct hda_verb alc260_init_verbs[] = {
4117 /* Line In pin widget for input */
4118 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
4119 /* CD pin widget for input */
4120 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
4121 /* Mic1 (rear panel) pin widget for input and vref at 80% */
4122 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
4123 /* Mic2 (front panel) pin widget for input and vref at 80% */
4124 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
4125 /* LINE-2 is used for line-out in rear */
4126 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4127 /* select line-out */
4128 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
4129 /* LINE-OUT pin */
4130 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4131 /* enable HP */
4132 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4133 /* enable Mono */
4134 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4135 /* mute capture amp left and right */
4136 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4137 /* set connection select to line in (default select for this ADC) */
4138 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
4139 /* mute capture amp left and right */
4140 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4141 /* set connection select to line in (default select for this ADC) */
4142 {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
4143 /* set vol=0 Line-Out mixer amp left and right */
4144 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4145 /* unmute pin widget amp left and right (no gain on this amp) */
4146 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4147 /* set vol=0 HP mixer amp left and right */
4148 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4149 /* unmute pin widget amp left and right (no gain on this amp) */
4150 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4151 /* set vol=0 Mono mixer amp left and right */
4152 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4153 /* unmute pin widget amp left and right (no gain on this amp) */
4154 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4155 /* unmute LINE-2 out pin */
4156 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4157 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
4158 * Line In 2 = 0x03
4160 /* mute analog inputs */
4161 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4162 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4163 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4164 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4165 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
4166 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
4167 /* mute Front out path */
4168 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4169 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4170 /* mute Headphone out path */
4171 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4172 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4173 /* mute Mono out path */
4174 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4175 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4179 #if 0 /* should be identical with alc260_init_verbs? */
4180 static struct hda_verb alc260_hp_init_verbs[] = {
4181 /* Headphone and output */
4182 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
4183 /* mono output */
4184 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
4185 /* Mic1 (rear panel) pin widget for input and vref at 80% */
4186 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
4187 /* Mic2 (front panel) pin widget for input and vref at 80% */
4188 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
4189 /* Line In pin widget for input */
4190 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
4191 /* Line-2 pin widget for output */
4192 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
4193 /* CD pin widget for input */
4194 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
4195 /* unmute amp left and right */
4196 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
4197 /* set connection select to line in (default select for this ADC) */
4198 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
4199 /* unmute Line-Out mixer amp left and right (volume = 0) */
4200 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
4201 /* mute pin widget amp left and right (no gain on this amp) */
4202 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
4203 /* unmute HP mixer amp left and right (volume = 0) */
4204 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
4205 /* mute pin widget amp left and right (no gain on this amp) */
4206 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
4207 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
4208 * Line In 2 = 0x03
4210 /* mute analog inputs */
4211 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4212 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4213 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4214 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4215 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
4216 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
4217 /* Unmute Front out path */
4218 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4219 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4220 /* Unmute Headphone out path */
4221 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4222 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4223 /* Unmute Mono out path */
4224 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4225 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4228 #endif
4230 static struct hda_verb alc260_hp_3013_init_verbs[] = {
4231 /* Line out and output */
4232 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
4233 /* mono output */
4234 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
4235 /* Mic1 (rear panel) pin widget for input and vref at 80% */
4236 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
4237 /* Mic2 (front panel) pin widget for input and vref at 80% */
4238 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
4239 /* Line In pin widget for input */
4240 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
4241 /* Headphone pin widget for output */
4242 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
4243 /* CD pin widget for input */
4244 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
4245 /* unmute amp left and right */
4246 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
4247 /* set connection select to line in (default select for this ADC) */
4248 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
4249 /* unmute Line-Out mixer amp left and right (volume = 0) */
4250 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
4251 /* mute pin widget amp left and right (no gain on this amp) */
4252 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
4253 /* unmute HP mixer amp left and right (volume = 0) */
4254 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
4255 /* mute pin widget amp left and right (no gain on this amp) */
4256 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
4257 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
4258 * Line In 2 = 0x03
4260 /* mute analog inputs */
4261 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4262 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4263 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4264 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4265 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
4266 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
4267 /* Unmute Front out path */
4268 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4269 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4270 /* Unmute Headphone out path */
4271 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4272 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4273 /* Unmute Mono out path */
4274 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4275 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4279 /* Initialisation sequence for ALC260 as configured in Fujitsu S702x
4280 * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD
4281 * audio = 0x16, internal speaker = 0x10.
4283 static struct hda_verb alc260_fujitsu_init_verbs[] = {
4284 /* Disable all GPIOs */
4285 {0x01, AC_VERB_SET_GPIO_MASK, 0},
4286 /* Internal speaker is connected to headphone pin */
4287 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4288 /* Headphone/Line-out jack connects to Line1 pin; make it an output */
4289 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4290 /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
4291 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
4292 /* Ensure all other unused pins are disabled and muted. */
4293 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
4294 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4295 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
4296 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4297 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
4298 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4299 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
4300 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4302 /* Disable digital (SPDIF) pins */
4303 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
4304 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
4306 /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
4307 * when acting as an output.
4309 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
4311 /* Start with output sum widgets muted and their output gains at min */
4312 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4313 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4314 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4315 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4316 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4317 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4318 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4319 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4320 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4322 /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
4323 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4324 /* Unmute Line1 pin widget output buffer since it starts as an output.
4325 * If the pin mode is changed by the user the pin mode control will
4326 * take care of enabling the pin's input/output buffers as needed.
4327 * Therefore there's no need to enable the input buffer at this
4328 * stage.
4330 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4331 /* Unmute input buffer of pin widget used for Line-in (no equiv
4332 * mixer ctrl)
4334 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4336 /* Mute capture amp left and right */
4337 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4338 /* Set ADC connection select to match default mixer setting - line
4339 * in (on mic1 pin)
4341 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
4343 /* Do the same for the second ADC: mute capture input amp and
4344 * set ADC connection to line in (on mic1 pin)
4346 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4347 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
4349 /* Mute all inputs to mixer widget (even unconnected ones) */
4350 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
4351 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
4352 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
4353 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
4354 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
4355 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
4356 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
4357 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
4362 /* Initialisation sequence for ALC260 as configured in Acer TravelMate and
4363 * similar laptops (adapted from Fujitsu init verbs).
4365 static struct hda_verb alc260_acer_init_verbs[] = {
4366 /* On TravelMate laptops, GPIO 0 enables the internal speaker and
4367 * the headphone jack. Turn this on and rely on the standard mute
4368 * methods whenever the user wants to turn these outputs off.
4370 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
4371 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
4372 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
4373 /* Internal speaker/Headphone jack is connected to Line-out pin */
4374 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4375 /* Internal microphone/Mic jack is connected to Mic1 pin */
4376 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
4377 /* Line In jack is connected to Line1 pin */
4378 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
4379 /* Some Acers (eg: C20x Tablets) use Mono pin for internal speaker */
4380 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4381 /* Ensure all other unused pins are disabled and muted. */
4382 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
4383 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4384 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
4385 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4386 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
4387 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4388 /* Disable digital (SPDIF) pins */
4389 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
4390 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
4392 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
4393 * bus when acting as outputs.
4395 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
4396 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
4398 /* Start with output sum widgets muted and their output gains at min */
4399 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4400 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4401 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4402 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4403 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4404 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4405 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4406 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4407 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4409 /* Unmute Line-out pin widget amp left and right
4410 * (no equiv mixer ctrl)
4412 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4413 /* Unmute mono pin widget amp output (no equiv mixer ctrl) */
4414 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4415 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
4416 * inputs. If the pin mode is changed by the user the pin mode control
4417 * will take care of enabling the pin's input/output buffers as needed.
4418 * Therefore there's no need to enable the input buffer at this
4419 * stage.
4421 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4422 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4424 /* Mute capture amp left and right */
4425 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4426 /* Set ADC connection select to match default mixer setting - mic
4427 * (on mic1 pin)
4429 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
4431 /* Do similar with the second ADC: mute capture input amp and
4432 * set ADC connection to mic to match ALSA's default state.
4434 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4435 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
4437 /* Mute all inputs to mixer widget (even unconnected ones) */
4438 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
4439 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
4440 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
4441 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
4442 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
4443 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
4444 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
4445 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
4450 static struct hda_verb alc260_will_verbs[] = {
4451 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4452 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x00},
4453 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
4454 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
4455 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
4456 {0x1a, AC_VERB_SET_PROC_COEF, 0x3040},
4460 static struct hda_verb alc260_replacer_672v_verbs[] = {
4461 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
4462 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
4463 {0x1a, AC_VERB_SET_PROC_COEF, 0x3050},
4465 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
4466 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
4467 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
4469 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
4473 /* toggle speaker-output according to the hp-jack state */
4474 static void alc260_replacer_672v_automute(struct hda_codec *codec)
4476 unsigned int present;
4478 /* speaker --> GPIO Data 0, hp or spdif --> GPIO data 1 */
4479 present = snd_hda_codec_read(codec, 0x0f, 0,
4480 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
4481 if (present) {
4482 snd_hda_codec_write_cache(codec, 0x01, 0,
4483 AC_VERB_SET_GPIO_DATA, 1);
4484 snd_hda_codec_write_cache(codec, 0x0f, 0,
4485 AC_VERB_SET_PIN_WIDGET_CONTROL,
4486 PIN_HP);
4487 } else {
4488 snd_hda_codec_write_cache(codec, 0x01, 0,
4489 AC_VERB_SET_GPIO_DATA, 0);
4490 snd_hda_codec_write_cache(codec, 0x0f, 0,
4491 AC_VERB_SET_PIN_WIDGET_CONTROL,
4492 PIN_OUT);
4496 static void alc260_replacer_672v_unsol_event(struct hda_codec *codec,
4497 unsigned int res)
4499 if ((res >> 26) == ALC880_HP_EVENT)
4500 alc260_replacer_672v_automute(codec);
4503 /* Test configuration for debugging, modelled after the ALC880 test
4504 * configuration.
4506 #ifdef CONFIG_SND_DEBUG
4507 static hda_nid_t alc260_test_dac_nids[1] = {
4508 0x02,
4510 static hda_nid_t alc260_test_adc_nids[2] = {
4511 0x04, 0x05,
4513 /* For testing the ALC260, each input MUX needs its own definition since
4514 * the signal assignments are different. This assumes that the first ADC
4515 * is NID 0x04.
4517 static struct hda_input_mux alc260_test_capture_sources[2] = {
4519 .num_items = 7,
4520 .items = {
4521 { "MIC1 pin", 0x0 },
4522 { "MIC2 pin", 0x1 },
4523 { "LINE1 pin", 0x2 },
4524 { "LINE2 pin", 0x3 },
4525 { "CD pin", 0x4 },
4526 { "LINE-OUT pin", 0x5 },
4527 { "HP-OUT pin", 0x6 },
4531 .num_items = 8,
4532 .items = {
4533 { "MIC1 pin", 0x0 },
4534 { "MIC2 pin", 0x1 },
4535 { "LINE1 pin", 0x2 },
4536 { "LINE2 pin", 0x3 },
4537 { "CD pin", 0x4 },
4538 { "Mixer", 0x5 },
4539 { "LINE-OUT pin", 0x6 },
4540 { "HP-OUT pin", 0x7 },
4544 static struct snd_kcontrol_new alc260_test_mixer[] = {
4545 /* Output driver widgets */
4546 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
4547 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
4548 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4549 HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
4550 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4551 HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
4553 /* Modes for retasking pin widgets
4554 * Note: the ALC260 doesn't seem to act on requests to enable mic
4555 * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't
4556 * mention this restriction. At this stage it's not clear whether
4557 * this behaviour is intentional or is a hardware bug in chip
4558 * revisions available at least up until early 2006. Therefore for
4559 * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all
4560 * choices, but if it turns out that the lack of mic bias for these
4561 * NIDs is intentional we could change their modes from
4562 * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
4564 ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
4565 ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
4566 ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
4567 ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
4568 ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
4569 ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
4571 /* Loopback mixer controls */
4572 HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
4573 HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
4574 HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
4575 HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
4576 HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
4577 HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
4578 HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
4579 HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
4580 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4581 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4582 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
4583 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
4584 HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
4585 HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
4586 HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
4587 HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
4589 /* Controls for GPIO pins, assuming they are configured as outputs */
4590 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
4591 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
4592 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
4593 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
4595 /* Switches to allow the digital IO pins to be enabled. The datasheet
4596 * is ambigious as to which NID is which; testing on laptops which
4597 * make this output available should provide clarification.
4599 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
4600 ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
4602 /* A switch allowing EAPD to be enabled. Some laptops seem to use
4603 * this output to turn on an external amplifier.
4605 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
4606 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
4608 { } /* end */
4610 static struct hda_verb alc260_test_init_verbs[] = {
4611 /* Enable all GPIOs as outputs with an initial value of 0 */
4612 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
4613 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
4614 {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
4616 /* Enable retasking pins as output, initially without power amp */
4617 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4618 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4619 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4620 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4621 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4622 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4624 /* Disable digital (SPDIF) pins initially, but users can enable
4625 * them via a mixer switch. In the case of SPDIF-out, this initverb
4626 * payload also sets the generation to 0, output to be in "consumer"
4627 * PCM format, copyright asserted, no pre-emphasis and no validity
4628 * control.
4630 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
4631 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
4633 /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
4634 * OUT1 sum bus when acting as an output.
4636 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
4637 {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
4638 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
4639 {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
4641 /* Start with output sum widgets muted and their output gains at min */
4642 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4643 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4644 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4645 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4646 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4647 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4648 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4649 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4650 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4652 /* Unmute retasking pin widget output buffers since the default
4653 * state appears to be output. As the pin mode is changed by the
4654 * user the pin mode control will take care of enabling the pin's
4655 * input/output buffers as needed.
4657 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4658 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4659 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4660 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4661 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4662 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4663 /* Also unmute the mono-out pin widget */
4664 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4666 /* Mute capture amp left and right */
4667 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4668 /* Set ADC connection select to match default mixer setting (mic1
4669 * pin)
4671 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
4673 /* Do the same for the second ADC: mute capture input amp and
4674 * set ADC connection to mic1 pin
4676 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4677 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
4679 /* Mute all inputs to mixer widget (even unconnected ones) */
4680 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
4681 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
4682 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
4683 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
4684 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
4685 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
4686 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
4687 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
4691 #endif
4693 #define alc260_pcm_analog_playback alc880_pcm_analog_alt_playback
4694 #define alc260_pcm_analog_capture alc880_pcm_analog_capture
4696 #define alc260_pcm_digital_playback alc880_pcm_digital_playback
4697 #define alc260_pcm_digital_capture alc880_pcm_digital_capture
4700 * for BIOS auto-configuration
4703 static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
4704 const char *pfx)
4706 hda_nid_t nid_vol;
4707 unsigned long vol_val, sw_val;
4708 char name[32];
4709 int err;
4711 if (nid >= 0x0f && nid < 0x11) {
4712 nid_vol = nid - 0x7;
4713 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
4714 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
4715 } else if (nid == 0x11) {
4716 nid_vol = nid - 0x7;
4717 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
4718 sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
4719 } else if (nid >= 0x12 && nid <= 0x15) {
4720 nid_vol = 0x08;
4721 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
4722 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
4723 } else
4724 return 0; /* N/A */
4726 snprintf(name, sizeof(name), "%s Playback Volume", pfx);
4727 err = add_control(spec, ALC_CTL_WIDGET_VOL, name, vol_val);
4728 if (err < 0)
4729 return err;
4730 snprintf(name, sizeof(name), "%s Playback Switch", pfx);
4731 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, sw_val);
4732 if (err < 0)
4733 return err;
4734 return 1;
4737 /* add playback controls from the parsed DAC table */
4738 static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
4739 const struct auto_pin_cfg *cfg)
4741 hda_nid_t nid;
4742 int err;
4744 spec->multiout.num_dacs = 1;
4745 spec->multiout.dac_nids = spec->private_dac_nids;
4746 spec->multiout.dac_nids[0] = 0x02;
4748 nid = cfg->line_out_pins[0];
4749 if (nid) {
4750 err = alc260_add_playback_controls(spec, nid, "Front");
4751 if (err < 0)
4752 return err;
4755 nid = cfg->speaker_pins[0];
4756 if (nid) {
4757 err = alc260_add_playback_controls(spec, nid, "Speaker");
4758 if (err < 0)
4759 return err;
4762 nid = cfg->hp_pins[0];
4763 if (nid) {
4764 err = alc260_add_playback_controls(spec, nid, "Headphone");
4765 if (err < 0)
4766 return err;
4768 return 0;
4771 /* create playback/capture controls for input pins */
4772 static int alc260_auto_create_analog_input_ctls(struct alc_spec *spec,
4773 const struct auto_pin_cfg *cfg)
4775 struct hda_input_mux *imux = &spec->private_imux;
4776 int i, err, idx;
4778 for (i = 0; i < AUTO_PIN_LAST; i++) {
4779 if (cfg->input_pins[i] >= 0x12) {
4780 idx = cfg->input_pins[i] - 0x12;
4781 err = new_analog_input(spec, cfg->input_pins[i],
4782 auto_pin_cfg_labels[i], idx,
4783 0x07);
4784 if (err < 0)
4785 return err;
4786 imux->items[imux->num_items].label =
4787 auto_pin_cfg_labels[i];
4788 imux->items[imux->num_items].index = idx;
4789 imux->num_items++;
4791 if (cfg->input_pins[i] >= 0x0f && cfg->input_pins[i] <= 0x10){
4792 idx = cfg->input_pins[i] - 0x09;
4793 err = new_analog_input(spec, cfg->input_pins[i],
4794 auto_pin_cfg_labels[i], idx,
4795 0x07);
4796 if (err < 0)
4797 return err;
4798 imux->items[imux->num_items].label =
4799 auto_pin_cfg_labels[i];
4800 imux->items[imux->num_items].index = idx;
4801 imux->num_items++;
4804 return 0;
4807 static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
4808 hda_nid_t nid, int pin_type,
4809 int sel_idx)
4811 /* set as output */
4812 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4813 pin_type);
4814 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
4815 AMP_OUT_UNMUTE);
4816 /* need the manual connection? */
4817 if (nid >= 0x12) {
4818 int idx = nid - 0x12;
4819 snd_hda_codec_write(codec, idx + 0x0b, 0,
4820 AC_VERB_SET_CONNECT_SEL, sel_idx);
4824 static void alc260_auto_init_multi_out(struct hda_codec *codec)
4826 struct alc_spec *spec = codec->spec;
4827 hda_nid_t nid;
4829 alc_subsystem_id(codec, 0x10, 0x15, 0x0f);
4830 nid = spec->autocfg.line_out_pins[0];
4831 if (nid) {
4832 int pin_type = get_pin_type(spec->autocfg.line_out_type);
4833 alc260_auto_set_output_and_unmute(codec, nid, pin_type, 0);
4836 nid = spec->autocfg.speaker_pins[0];
4837 if (nid)
4838 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
4840 nid = spec->autocfg.hp_pins[0];
4841 if (nid)
4842 alc260_auto_set_output_and_unmute(codec, nid, PIN_HP, 0);
4845 #define ALC260_PIN_CD_NID 0x16
4846 static void alc260_auto_init_analog_input(struct hda_codec *codec)
4848 struct alc_spec *spec = codec->spec;
4849 int i;
4851 for (i = 0; i < AUTO_PIN_LAST; i++) {
4852 hda_nid_t nid = spec->autocfg.input_pins[i];
4853 if (nid >= 0x12) {
4854 snd_hda_codec_write(codec, nid, 0,
4855 AC_VERB_SET_PIN_WIDGET_CONTROL,
4856 i <= AUTO_PIN_FRONT_MIC ?
4857 PIN_VREF80 : PIN_IN);
4858 if (nid != ALC260_PIN_CD_NID)
4859 snd_hda_codec_write(codec, nid, 0,
4860 AC_VERB_SET_AMP_GAIN_MUTE,
4861 AMP_OUT_MUTE);
4867 * generic initialization of ADC, input mixers and output mixers
4869 static struct hda_verb alc260_volume_init_verbs[] = {
4871 * Unmute ADC0-1 and set the default input to mic-in
4873 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
4874 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4875 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
4876 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4878 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
4879 * mixer widget
4880 * Note: PASD motherboards uses the Line In 2 as the input for
4881 * front panel mic (mic 2)
4883 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
4884 /* mute analog inputs */
4885 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4886 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4887 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4888 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4889 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
4892 * Set up output mixers (0x08 - 0x0a)
4894 /* set vol=0 to output mixers */
4895 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4896 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4897 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4898 /* set up input amps for analog loopback */
4899 /* Amp Indices: DAC = 0, mixer = 1 */
4900 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4901 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4902 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4903 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4904 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4905 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4910 static int alc260_parse_auto_config(struct hda_codec *codec)
4912 struct alc_spec *spec = codec->spec;
4913 unsigned int wcap;
4914 int err;
4915 static hda_nid_t alc260_ignore[] = { 0x17, 0 };
4917 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
4918 alc260_ignore);
4919 if (err < 0)
4920 return err;
4921 err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg);
4922 if (err < 0)
4923 return err;
4924 if (!spec->kctl_alloc)
4925 return 0; /* can't find valid BIOS pin config */
4926 err = alc260_auto_create_analog_input_ctls(spec, &spec->autocfg);
4927 if (err < 0)
4928 return err;
4930 spec->multiout.max_channels = 2;
4932 if (spec->autocfg.dig_out_pin)
4933 spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
4934 if (spec->kctl_alloc)
4935 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
4937 spec->init_verbs[spec->num_init_verbs++] = alc260_volume_init_verbs;
4939 spec->num_mux_defs = 1;
4940 spec->input_mux = &spec->private_imux;
4942 /* check whether NID 0x04 is valid */
4943 wcap = get_wcaps(codec, 0x04);
4944 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
4945 if (wcap != AC_WID_AUD_IN) {
4946 spec->adc_nids = alc260_adc_nids_alt;
4947 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
4948 spec->mixers[spec->num_mixers] = alc260_capture_alt_mixer;
4949 } else {
4950 spec->adc_nids = alc260_adc_nids;
4951 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
4952 spec->mixers[spec->num_mixers] = alc260_capture_mixer;
4954 spec->num_mixers++;
4956 return 1;
4959 /* additional initialization for auto-configuration model */
4960 static void alc260_auto_init(struct hda_codec *codec)
4962 alc260_auto_init_multi_out(codec);
4963 alc260_auto_init_analog_input(codec);
4966 #ifdef CONFIG_SND_HDA_POWER_SAVE
4967 static struct hda_amp_list alc260_loopbacks[] = {
4968 { 0x07, HDA_INPUT, 0 },
4969 { 0x07, HDA_INPUT, 1 },
4970 { 0x07, HDA_INPUT, 2 },
4971 { 0x07, HDA_INPUT, 3 },
4972 { 0x07, HDA_INPUT, 4 },
4973 { } /* end */
4975 #endif
4978 * ALC260 configurations
4980 static const char *alc260_models[ALC260_MODEL_LAST] = {
4981 [ALC260_BASIC] = "basic",
4982 [ALC260_HP] = "hp",
4983 [ALC260_HP_3013] = "hp-3013",
4984 [ALC260_FUJITSU_S702X] = "fujitsu",
4985 [ALC260_ACER] = "acer",
4986 [ALC260_WILL] = "will",
4987 [ALC260_REPLACER_672V] = "replacer",
4988 #ifdef CONFIG_SND_DEBUG
4989 [ALC260_TEST] = "test",
4990 #endif
4991 [ALC260_AUTO] = "auto",
4994 static struct snd_pci_quirk alc260_cfg_tbl[] = {
4995 SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER),
4996 SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER),
4997 SND_PCI_QUIRK(0x103c, 0x2808, "HP d5700", ALC260_HP_3013),
4998 SND_PCI_QUIRK(0x103c, 0x280a, "HP d5750", ALC260_HP_3013),
4999 SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013),
5000 SND_PCI_QUIRK(0x103c, 0x3011, "HP", ALC260_HP),
5001 SND_PCI_QUIRK(0x103c, 0x3012, "HP", ALC260_HP_3013),
5002 SND_PCI_QUIRK(0x103c, 0x3013, "HP", ALC260_HP_3013),
5003 SND_PCI_QUIRK(0x103c, 0x3014, "HP", ALC260_HP),
5004 SND_PCI_QUIRK(0x103c, 0x3015, "HP", ALC260_HP),
5005 SND_PCI_QUIRK(0x103c, 0x3016, "HP", ALC260_HP),
5006 SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_BASIC),
5007 SND_PCI_QUIRK(0x104d, 0x81cc, "Sony VAIO", ALC260_BASIC),
5008 SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC),
5009 SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X),
5010 SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC),
5011 SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_REPLACER_672V),
5012 SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_WILL),
5016 static struct alc_config_preset alc260_presets[] = {
5017 [ALC260_BASIC] = {
5018 .mixers = { alc260_base_output_mixer,
5019 alc260_input_mixer,
5020 alc260_pc_beep_mixer,
5021 alc260_capture_mixer },
5022 .init_verbs = { alc260_init_verbs },
5023 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5024 .dac_nids = alc260_dac_nids,
5025 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
5026 .adc_nids = alc260_adc_nids,
5027 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5028 .channel_mode = alc260_modes,
5029 .input_mux = &alc260_capture_source,
5031 [ALC260_HP] = {
5032 .mixers = { alc260_hp_output_mixer,
5033 alc260_input_mixer,
5034 alc260_capture_alt_mixer },
5035 .init_verbs = { alc260_init_verbs,
5036 alc260_hp_unsol_verbs },
5037 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5038 .dac_nids = alc260_dac_nids,
5039 .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
5040 .adc_nids = alc260_hp_adc_nids,
5041 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5042 .channel_mode = alc260_modes,
5043 .input_mux = &alc260_capture_source,
5044 .unsol_event = alc260_hp_unsol_event,
5045 .init_hook = alc260_hp_automute,
5047 [ALC260_HP_3013] = {
5048 .mixers = { alc260_hp_3013_mixer,
5049 alc260_input_mixer,
5050 alc260_capture_alt_mixer },
5051 .init_verbs = { alc260_hp_3013_init_verbs,
5052 alc260_hp_3013_unsol_verbs },
5053 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5054 .dac_nids = alc260_dac_nids,
5055 .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
5056 .adc_nids = alc260_hp_adc_nids,
5057 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5058 .channel_mode = alc260_modes,
5059 .input_mux = &alc260_capture_source,
5060 .unsol_event = alc260_hp_3013_unsol_event,
5061 .init_hook = alc260_hp_3013_automute,
5063 [ALC260_FUJITSU_S702X] = {
5064 .mixers = { alc260_fujitsu_mixer,
5065 alc260_capture_mixer },
5066 .init_verbs = { alc260_fujitsu_init_verbs },
5067 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5068 .dac_nids = alc260_dac_nids,
5069 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
5070 .adc_nids = alc260_dual_adc_nids,
5071 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5072 .channel_mode = alc260_modes,
5073 .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources),
5074 .input_mux = alc260_fujitsu_capture_sources,
5076 [ALC260_ACER] = {
5077 .mixers = { alc260_acer_mixer,
5078 alc260_capture_mixer },
5079 .init_verbs = { alc260_acer_init_verbs },
5080 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5081 .dac_nids = alc260_dac_nids,
5082 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
5083 .adc_nids = alc260_dual_adc_nids,
5084 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5085 .channel_mode = alc260_modes,
5086 .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
5087 .input_mux = alc260_acer_capture_sources,
5089 [ALC260_WILL] = {
5090 .mixers = { alc260_will_mixer,
5091 alc260_capture_mixer },
5092 .init_verbs = { alc260_init_verbs, alc260_will_verbs },
5093 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5094 .dac_nids = alc260_dac_nids,
5095 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
5096 .adc_nids = alc260_adc_nids,
5097 .dig_out_nid = ALC260_DIGOUT_NID,
5098 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5099 .channel_mode = alc260_modes,
5100 .input_mux = &alc260_capture_source,
5102 [ALC260_REPLACER_672V] = {
5103 .mixers = { alc260_replacer_672v_mixer,
5104 alc260_capture_mixer },
5105 .init_verbs = { alc260_init_verbs, alc260_replacer_672v_verbs },
5106 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5107 .dac_nids = alc260_dac_nids,
5108 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
5109 .adc_nids = alc260_adc_nids,
5110 .dig_out_nid = ALC260_DIGOUT_NID,
5111 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5112 .channel_mode = alc260_modes,
5113 .input_mux = &alc260_capture_source,
5114 .unsol_event = alc260_replacer_672v_unsol_event,
5115 .init_hook = alc260_replacer_672v_automute,
5117 #ifdef CONFIG_SND_DEBUG
5118 [ALC260_TEST] = {
5119 .mixers = { alc260_test_mixer,
5120 alc260_capture_mixer },
5121 .init_verbs = { alc260_test_init_verbs },
5122 .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
5123 .dac_nids = alc260_test_dac_nids,
5124 .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
5125 .adc_nids = alc260_test_adc_nids,
5126 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5127 .channel_mode = alc260_modes,
5128 .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources),
5129 .input_mux = alc260_test_capture_sources,
5131 #endif
5134 static int patch_alc260(struct hda_codec *codec)
5136 struct alc_spec *spec;
5137 int err, board_config;
5139 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5140 if (spec == NULL)
5141 return -ENOMEM;
5143 codec->spec = spec;
5145 board_config = snd_hda_check_board_config(codec, ALC260_MODEL_LAST,
5146 alc260_models,
5147 alc260_cfg_tbl);
5148 if (board_config < 0) {
5149 snd_printd(KERN_INFO "hda_codec: Unknown model for ALC260, "
5150 "trying auto-probe from BIOS...\n");
5151 board_config = ALC260_AUTO;
5154 if (board_config == ALC260_AUTO) {
5155 /* automatic parse from the BIOS config */
5156 err = alc260_parse_auto_config(codec);
5157 if (err < 0) {
5158 alc_free(codec);
5159 return err;
5160 } else if (!err) {
5161 printk(KERN_INFO
5162 "hda_codec: Cannot set up configuration "
5163 "from BIOS. Using base mode...\n");
5164 board_config = ALC260_BASIC;
5168 if (board_config != ALC260_AUTO)
5169 setup_preset(spec, &alc260_presets[board_config]);
5171 spec->stream_name_analog = "ALC260 Analog";
5172 spec->stream_analog_playback = &alc260_pcm_analog_playback;
5173 spec->stream_analog_capture = &alc260_pcm_analog_capture;
5175 spec->stream_name_digital = "ALC260 Digital";
5176 spec->stream_digital_playback = &alc260_pcm_digital_playback;
5177 spec->stream_digital_capture = &alc260_pcm_digital_capture;
5179 spec->vmaster_nid = 0x08;
5181 codec->patch_ops = alc_patch_ops;
5182 if (board_config == ALC260_AUTO)
5183 spec->init_hook = alc260_auto_init;
5184 #ifdef CONFIG_SND_HDA_POWER_SAVE
5185 if (!spec->loopback.amplist)
5186 spec->loopback.amplist = alc260_loopbacks;
5187 #endif
5189 return 0;
5194 * ALC882 support
5196 * ALC882 is almost identical with ALC880 but has cleaner and more flexible
5197 * configuration. Each pin widget can choose any input DACs and a mixer.
5198 * Each ADC is connected from a mixer of all inputs. This makes possible
5199 * 6-channel independent captures.
5201 * In addition, an independent DAC for the multi-playback (not used in this
5202 * driver yet).
5204 #define ALC882_DIGOUT_NID 0x06
5205 #define ALC882_DIGIN_NID 0x0a
5207 static struct hda_channel_mode alc882_ch_modes[1] = {
5208 { 8, NULL }
5211 static hda_nid_t alc882_dac_nids[4] = {
5212 /* front, rear, clfe, rear_surr */
5213 0x02, 0x03, 0x04, 0x05
5216 /* identical with ALC880 */
5217 #define alc882_adc_nids alc880_adc_nids
5218 #define alc882_adc_nids_alt alc880_adc_nids_alt
5220 /* input MUX */
5221 /* FIXME: should be a matrix-type input source selection */
5223 static struct hda_input_mux alc882_capture_source = {
5224 .num_items = 4,
5225 .items = {
5226 { "Mic", 0x0 },
5227 { "Front Mic", 0x1 },
5228 { "Line", 0x2 },
5229 { "CD", 0x4 },
5232 #define alc882_mux_enum_info alc_mux_enum_info
5233 #define alc882_mux_enum_get alc_mux_enum_get
5235 static int alc882_mux_enum_put(struct snd_kcontrol *kcontrol,
5236 struct snd_ctl_elem_value *ucontrol)
5238 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
5239 struct alc_spec *spec = codec->spec;
5240 const struct hda_input_mux *imux = spec->input_mux;
5241 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
5242 static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
5243 <<<<<<< HEAD:sound/pci/hda/patch_realtek.c
5244 hda_nid_t nid = capture_mixers[adc_idx];
5245 =======
5246 hda_nid_t nid;
5247 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a:sound/pci/hda/patch_realtek.c
5248 unsigned int *cur_val = &spec->cur_mux[adc_idx];
5249 unsigned int i, idx;
5251 <<<<<<< HEAD:sound/pci/hda/patch_realtek.c
5252 =======
5253 if (spec->num_adc_nids < 3)
5254 nid = capture_mixers[adc_idx + 1];
5255 else
5256 nid = capture_mixers[adc_idx];
5257 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a:sound/pci/hda/patch_realtek.c
5258 idx = ucontrol->value.enumerated.item[0];
5259 if (idx >= imux->num_items)
5260 idx = imux->num_items - 1;
5261 if (*cur_val == idx)
5262 return 0;
5263 for (i = 0; i < imux->num_items; i++) {
5264 unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
5265 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
5266 imux->items[i].index,
5267 HDA_AMP_MUTE, v);
5269 *cur_val = idx;
5270 return 1;
5274 * 2ch mode
5276 static struct hda_verb alc882_3ST_ch2_init[] = {
5277 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
5278 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
5279 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
5280 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
5281 { } /* end */
5285 * 6ch mode
5287 static struct hda_verb alc882_3ST_ch6_init[] = {
5288 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5289 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
5290 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
5291 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5292 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
5293 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
5294 { } /* end */
5297 static struct hda_channel_mode alc882_3ST_6ch_modes[2] = {
5298 { 2, alc882_3ST_ch2_init },
5299 { 6, alc882_3ST_ch6_init },
5303 * 6ch mode
5305 static struct hda_verb alc882_sixstack_ch6_init[] = {
5306 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
5307 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5308 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5309 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5310 { } /* end */
5314 * 8ch mode
5316 static struct hda_verb alc882_sixstack_ch8_init[] = {
5317 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5318 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5319 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5320 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5321 { } /* end */
5324 static struct hda_channel_mode alc882_sixstack_modes[2] = {
5325 { 6, alc882_sixstack_ch6_init },
5326 { 8, alc882_sixstack_ch8_init },
5330 * macbook pro ALC885 can switch LineIn to LineOut without loosing Mic
5334 * 2ch mode
5336 static struct hda_verb alc885_mbp_ch2_init[] = {
5337 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
5338 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5339 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5340 { } /* end */
5344 * 6ch mode
5346 static struct hda_verb alc885_mbp_ch6_init[] = {
5347 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5348 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5349 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
5350 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5351 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5352 { } /* end */
5355 static struct hda_channel_mode alc885_mbp_6ch_modes[2] = {
5356 { 2, alc885_mbp_ch2_init },
5357 { 6, alc885_mbp_ch6_init },
5361 /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
5362 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
5364 static struct snd_kcontrol_new alc882_base_mixer[] = {
5365 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5366 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5367 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
5368 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
5369 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
5370 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
5371 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
5372 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
5373 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
5374 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
5375 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5376 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5377 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5378 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5379 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5380 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5381 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
5382 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5383 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
5384 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
5385 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
5386 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
5387 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
5388 { } /* end */
5391 static struct snd_kcontrol_new alc885_mbp3_mixer[] = {
5392 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
5393 HDA_BIND_MUTE ("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
5394 HDA_CODEC_MUTE ("Speaker Playback Switch", 0x14, 0x00, HDA_OUTPUT),
5395 HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
5396 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5397 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5398 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
5399 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
5400 HDA_CODEC_VOLUME("Line Boost", 0x1a, 0x00, HDA_INPUT),
5401 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
5402 { } /* end */
5404 static struct snd_kcontrol_new alc882_w2jc_mixer[] = {
5405 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5406 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5407 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5408 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5409 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5410 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5411 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5412 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
5413 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5414 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
5415 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
5416 { } /* end */
5419 static struct snd_kcontrol_new alc882_targa_mixer[] = {
5420 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5421 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5422 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5423 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5424 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5425 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5426 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5427 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5428 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5429 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
5430 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
5431 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
5432 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
5433 { } /* end */
5436 /* Pin assignment: Front=0x14, HP = 0x15, Front = 0x16, ???
5437 * Front Mic=0x18, Line In = 0x1a, Line In = 0x1b, CD = 0x1c
5439 static struct snd_kcontrol_new alc882_asus_a7j_mixer[] = {
5440 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5441 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
5442 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
5443 HDA_CODEC_MUTE("Mobile Front Playback Switch", 0x16, 0x0, HDA_OUTPUT),
5444 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5445 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5446 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5447 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5448 HDA_CODEC_VOLUME("Mobile Line Playback Volume", 0x0b, 0x03, HDA_INPUT),
5449 HDA_CODEC_MUTE("Mobile Line Playback Switch", 0x0b, 0x03, HDA_INPUT),
5450 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5451 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5452 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
5453 { } /* end */
5456 static struct snd_kcontrol_new alc882_asus_a7m_mixer[] = {
5457 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5458 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5459 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
5460 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5461 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5462 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5463 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5464 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5465 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
5466 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5467 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
5468 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
5469 { } /* end */
5472 static struct snd_kcontrol_new alc882_chmode_mixer[] = {
5474 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5475 .name = "Channel Mode",
5476 .info = alc_ch_mode_info,
5477 .get = alc_ch_mode_get,
5478 .put = alc_ch_mode_put,
5480 { } /* end */
5483 static struct hda_verb alc882_init_verbs[] = {
5484 /* Front mixer: unmute input/output amp left and right (volume = 0) */
5485 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5486 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5487 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5488 /* Rear mixer */
5489 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5490 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5491 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5492 /* CLFE mixer */
5493 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5494 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5495 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5496 /* Side mixer */
5497 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5498 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5499 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5501 /* Front Pin: output 0 (0x0c) */
5502 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5503 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5504 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
5505 /* Rear Pin: output 1 (0x0d) */
5506 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5507 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5508 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
5509 /* CLFE Pin: output 2 (0x0e) */
5510 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5511 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5512 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
5513 /* Side Pin: output 3 (0x0f) */
5514 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5515 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5516 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
5517 /* Mic (rear) pin: input vref at 80% */
5518 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5519 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5520 /* Front Mic pin: input vref at 80% */
5521 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5522 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5523 /* Line In pin: input */
5524 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
5525 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5526 /* Line-2 In: Headphone output (output 0 - 0x0c) */
5527 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5528 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5529 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
5530 /* CD pin widget for input */
5531 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
5533 /* FIXME: use matrix-type input source selection */
5534 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5535 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
5536 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5537 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5538 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5539 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5540 /* Input mixer2 */
5541 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5542 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5543 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5544 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5545 /* Input mixer3 */
5546 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5547 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5548 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5549 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5550 /* ADC1: mute amp left and right */
5551 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5552 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
5553 /* ADC2: mute amp left and right */
5554 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5555 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
5556 /* ADC3: mute amp left and right */
5557 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5558 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
5563 static struct hda_verb alc882_eapd_verbs[] = {
5564 /* change to EAPD mode */
5565 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
5566 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
5570 /* Mac Pro test */
5571 static struct snd_kcontrol_new alc882_macpro_mixer[] = {
5572 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5573 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5574 HDA_CODEC_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT),
5575 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
5576 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
5577 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x02, HDA_INPUT),
5578 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x02, HDA_INPUT),
5579 { } /* end */
5582 static struct hda_verb alc882_macpro_init_verbs[] = {
5583 /* Front mixer: unmute input/output amp left and right (volume = 0) */
5584 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5585 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5586 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5587 /* Front Pin: output 0 (0x0c) */
5588 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5589 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5590 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
5591 /* Front Mic pin: input vref at 80% */
5592 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5593 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5594 /* Speaker: output */
5595 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5596 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5597 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x04},
5598 /* Headphone output (output 0 - 0x0c) */
5599 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5600 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5601 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
5603 /* FIXME: use matrix-type input source selection */
5604 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5605 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
5606 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5607 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5608 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5609 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5610 /* Input mixer2 */
5611 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5612 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5613 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5614 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5615 /* Input mixer3 */
5616 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5617 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5618 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5619 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5620 /* ADC1: mute amp left and right */
5621 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5622 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
5623 /* ADC2: mute amp left and right */
5624 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5625 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
5626 /* ADC3: mute amp left and right */
5627 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5628 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
5633 /* Macbook Pro rev3 */
5634 static struct hda_verb alc885_mbp3_init_verbs[] = {
5635 /* Front mixer: unmute input/output amp left and right (volume = 0) */
5636 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5637 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5638 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5639 /* Rear mixer */
5640 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5641 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5642 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5643 /* Front Pin: output 0 (0x0c) */
5644 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5645 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5646 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
5647 /* HP Pin: output 0 (0x0d) */
5648 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4},
5649 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5650 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
5651 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
5652 /* Mic (rear) pin: input vref at 80% */
5653 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5654 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5655 /* Front Mic pin: input vref at 80% */
5656 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5657 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5658 /* Line In pin: use output 1 when in LineOut mode */
5659 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
5660 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5661 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
5663 /* FIXME: use matrix-type input source selection */
5664 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5665 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
5666 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5667 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5668 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5669 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5670 /* Input mixer2 */
5671 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5672 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5673 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5674 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5675 /* Input mixer3 */
5676 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5677 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5678 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5679 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5680 /* ADC1: mute amp left and right */
5681 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5682 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
5683 /* ADC2: mute amp left and right */
5684 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5685 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
5686 /* ADC3: mute amp left and right */
5687 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5688 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
5693 /* iMac 24 mixer. */
5694 static struct snd_kcontrol_new alc885_imac24_mixer[] = {
5695 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
5696 HDA_CODEC_MUTE("Master Playback Switch", 0x0c, 0x00, HDA_INPUT),
5697 { } /* end */
5700 /* iMac 24 init verbs. */
5701 static struct hda_verb alc885_imac24_init_verbs[] = {
5702 /* Internal speakers: output 0 (0x0c) */
5703 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5704 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5705 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
5706 /* Internal speakers: output 0 (0x0c) */
5707 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5708 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5709 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
5710 /* Headphone: output 0 (0x0c) */
5711 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5712 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5713 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
5714 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
5715 /* Front Mic: input vref at 80% */
5716 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5717 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5721 /* Toggle speaker-output according to the hp-jack state */
5722 static void alc885_imac24_automute(struct hda_codec *codec)
5724 unsigned int present;
5726 present = snd_hda_codec_read(codec, 0x14, 0,
5727 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
5728 snd_hda_codec_amp_stereo(codec, 0x18, HDA_OUTPUT, 0,
5729 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
5730 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_OUTPUT, 0,
5731 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
5734 /* Processes unsolicited events. */
5735 static void alc885_imac24_unsol_event(struct hda_codec *codec,
5736 unsigned int res)
5738 /* Headphone insertion or removal. */
5739 if ((res >> 26) == ALC880_HP_EVENT)
5740 alc885_imac24_automute(codec);
5743 static void alc885_mbp3_automute(struct hda_codec *codec)
5745 unsigned int present;
5747 present = snd_hda_codec_read(codec, 0x15, 0,
5748 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
5749 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
5750 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
5751 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
5752 HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
5755 static void alc885_mbp3_unsol_event(struct hda_codec *codec,
5756 unsigned int res)
5758 /* Headphone insertion or removal. */
5759 if ((res >> 26) == ALC880_HP_EVENT)
5760 alc885_mbp3_automute(codec);
5764 static struct hda_verb alc882_targa_verbs[] = {
5765 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5766 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5768 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5769 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5771 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
5772 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
5773 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
5775 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
5776 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
5777 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
5778 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
5779 { } /* end */
5782 /* toggle speaker-output according to the hp-jack state */
5783 static void alc882_targa_automute(struct hda_codec *codec)
5785 unsigned int present;
5787 present = snd_hda_codec_read(codec, 0x14, 0,
5788 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
5789 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
5790 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
5791 snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
5792 present ? 1 : 3);
5795 static void alc882_targa_unsol_event(struct hda_codec *codec, unsigned int res)
5797 /* Looks like the unsol event is incompatible with the standard
5798 * definition. 4bit tag is placed at 26 bit!
5800 if (((res >> 26) == ALC880_HP_EVENT)) {
5801 alc882_targa_automute(codec);
5805 static struct hda_verb alc882_asus_a7j_verbs[] = {
5806 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5807 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5809 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5810 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5811 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5813 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
5814 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
5815 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
5817 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
5818 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
5819 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
5820 { } /* end */
5823 static struct hda_verb alc882_asus_a7m_verbs[] = {
5824 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5825 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5827 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5828 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5829 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5831 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
5832 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
5833 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
5835 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
5836 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
5837 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
5838 { } /* end */
5841 static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
5843 unsigned int gpiostate, gpiomask, gpiodir;
5845 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
5846 AC_VERB_GET_GPIO_DATA, 0);
5848 if (!muted)
5849 gpiostate |= (1 << pin);
5850 else
5851 gpiostate &= ~(1 << pin);
5853 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
5854 AC_VERB_GET_GPIO_MASK, 0);
5855 gpiomask |= (1 << pin);
5857 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
5858 AC_VERB_GET_GPIO_DIRECTION, 0);
5859 gpiodir |= (1 << pin);
5862 snd_hda_codec_write(codec, codec->afg, 0,
5863 AC_VERB_SET_GPIO_MASK, gpiomask);
5864 snd_hda_codec_write(codec, codec->afg, 0,
5865 AC_VERB_SET_GPIO_DIRECTION, gpiodir);
5867 msleep(1);
5869 snd_hda_codec_write(codec, codec->afg, 0,
5870 AC_VERB_SET_GPIO_DATA, gpiostate);
5873 /* set up GPIO at initialization */
5874 static void alc885_macpro_init_hook(struct hda_codec *codec)
5876 alc882_gpio_mute(codec, 0, 0);
5877 alc882_gpio_mute(codec, 1, 0);
5880 /* set up GPIO and update auto-muting at initialization */
5881 static void alc885_imac24_init_hook(struct hda_codec *codec)
5883 alc885_macpro_init_hook(codec);
5884 alc885_imac24_automute(codec);
5888 * generic initialization of ADC, input mixers and output mixers
5890 static struct hda_verb alc882_auto_init_verbs[] = {
5892 * Unmute ADC0-2 and set the default input to mic-in
5894 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
5895 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5896 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
5897 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5898 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
5899 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5901 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
5902 * mixer widget
5903 * Note: PASD motherboards uses the Line In 2 as the input for
5904 * front panel mic (mic 2)
5906 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
5907 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5908 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5909 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5910 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5911 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5914 * Set up output mixers (0x0c - 0x0f)
5916 /* set vol=0 to output mixers */
5917 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5918 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5919 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5920 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5921 /* set up input amps for analog loopback */
5922 /* Amp Indices: DAC = 0, mixer = 1 */
5923 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5924 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5925 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5926 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5927 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5928 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5929 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5930 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5931 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5932 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5934 /* FIXME: use matrix-type input source selection */
5935 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5936 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
5937 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5938 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
5939 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
5940 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
5941 /* Input mixer2 */
5942 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5943 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
5944 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
5945 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
5946 /* Input mixer3 */
5947 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5948 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
5949 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
5950 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
5955 /* capture mixer elements */
5956 static struct snd_kcontrol_new alc882_capture_alt_mixer[] = {
5957 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
5958 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
5959 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
5960 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
5962 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5963 /* The multiple "Capture Source" controls confuse alsamixer
5964 * So call somewhat different..
5966 /* .name = "Capture Source", */
5967 .name = "Input Source",
5968 .count = 2,
5969 .info = alc882_mux_enum_info,
5970 .get = alc882_mux_enum_get,
5971 .put = alc882_mux_enum_put,
5973 { } /* end */
5976 static struct snd_kcontrol_new alc882_capture_mixer[] = {
5977 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
5978 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
5979 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
5980 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
5981 HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
5982 HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
5984 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5985 /* The multiple "Capture Source" controls confuse alsamixer
5986 * So call somewhat different..
5988 /* .name = "Capture Source", */
5989 .name = "Input Source",
5990 .count = 3,
5991 .info = alc882_mux_enum_info,
5992 .get = alc882_mux_enum_get,
5993 .put = alc882_mux_enum_put,
5995 { } /* end */
5998 #ifdef CONFIG_SND_HDA_POWER_SAVE
5999 #define alc882_loopbacks alc880_loopbacks
6000 #endif
6002 /* pcm configuration: identiacal with ALC880 */
6003 #define alc882_pcm_analog_playback alc880_pcm_analog_playback
6004 #define alc882_pcm_analog_capture alc880_pcm_analog_capture
6005 #define alc882_pcm_digital_playback alc880_pcm_digital_playback
6006 #define alc882_pcm_digital_capture alc880_pcm_digital_capture
6009 * configuration and preset
6011 static const char *alc882_models[ALC882_MODEL_LAST] = {
6012 [ALC882_3ST_DIG] = "3stack-dig",
6013 [ALC882_6ST_DIG] = "6stack-dig",
6014 [ALC882_ARIMA] = "arima",
6015 [ALC882_W2JC] = "w2jc",
6016 [ALC882_TARGA] = "targa",
6017 [ALC882_ASUS_A7J] = "asus-a7j",
6018 [ALC882_ASUS_A7M] = "asus-a7m",
6019 [ALC885_MACPRO] = "macpro",
6020 [ALC885_MBP3] = "mbp3",
6021 [ALC885_IMAC24] = "imac24",
6022 [ALC882_AUTO] = "auto",
6025 static struct snd_pci_quirk alc882_cfg_tbl[] = {
6026 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG),
6027 SND_PCI_QUIRK(0x1043, 0x060d, "Asus A7J", ALC882_ASUS_A7J),
6028 SND_PCI_QUIRK(0x1043, 0x1243, "Asus A7J", ALC882_ASUS_A7J),
6029 SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_ASUS_A7M),
6030 SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_W2JC),
6031 SND_PCI_QUIRK(0x1043, 0x817f, "Asus P5LD2", ALC882_6ST_DIG),
6032 SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG),
6033 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG),
6034 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte P35 DS3R", ALC882_6ST_DIG),
6035 SND_PCI_QUIRK(0x1462, 0x28fb, "Targa T8", ALC882_TARGA), /* MSI-1049 T8 */
6036 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG),
6037 SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA),
6041 static struct alc_config_preset alc882_presets[] = {
6042 [ALC882_3ST_DIG] = {
6043 .mixers = { alc882_base_mixer },
6044 .init_verbs = { alc882_init_verbs },
6045 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6046 .dac_nids = alc882_dac_nids,
6047 .dig_out_nid = ALC882_DIGOUT_NID,
6048 .dig_in_nid = ALC882_DIGIN_NID,
6049 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
6050 .channel_mode = alc882_ch_modes,
6051 .need_dac_fix = 1,
6052 .input_mux = &alc882_capture_source,
6054 [ALC882_6ST_DIG] = {
6055 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
6056 .init_verbs = { alc882_init_verbs },
6057 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6058 .dac_nids = alc882_dac_nids,
6059 .dig_out_nid = ALC882_DIGOUT_NID,
6060 .dig_in_nid = ALC882_DIGIN_NID,
6061 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
6062 .channel_mode = alc882_sixstack_modes,
6063 .input_mux = &alc882_capture_source,
6065 [ALC882_ARIMA] = {
6066 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
6067 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs },
6068 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6069 .dac_nids = alc882_dac_nids,
6070 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
6071 .channel_mode = alc882_sixstack_modes,
6072 .input_mux = &alc882_capture_source,
6074 [ALC882_W2JC] = {
6075 .mixers = { alc882_w2jc_mixer, alc882_chmode_mixer },
6076 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs,
6077 alc880_gpio1_init_verbs },
6078 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6079 .dac_nids = alc882_dac_nids,
6080 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
6081 .channel_mode = alc880_threestack_modes,
6082 .need_dac_fix = 1,
6083 .input_mux = &alc882_capture_source,
6084 .dig_out_nid = ALC882_DIGOUT_NID,
6086 [ALC885_MBP3] = {
6087 .mixers = { alc885_mbp3_mixer, alc882_chmode_mixer },
6088 .init_verbs = { alc885_mbp3_init_verbs,
6089 alc880_gpio1_init_verbs },
6090 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6091 .dac_nids = alc882_dac_nids,
6092 .channel_mode = alc885_mbp_6ch_modes,
6093 .num_channel_mode = ARRAY_SIZE(alc885_mbp_6ch_modes),
6094 .input_mux = &alc882_capture_source,
6095 .dig_out_nid = ALC882_DIGOUT_NID,
6096 .dig_in_nid = ALC882_DIGIN_NID,
6097 .unsol_event = alc885_mbp3_unsol_event,
6098 .init_hook = alc885_mbp3_automute,
6100 [ALC885_MACPRO] = {
6101 .mixers = { alc882_macpro_mixer },
6102 .init_verbs = { alc882_macpro_init_verbs },
6103 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6104 .dac_nids = alc882_dac_nids,
6105 .dig_out_nid = ALC882_DIGOUT_NID,
6106 .dig_in_nid = ALC882_DIGIN_NID,
6107 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
6108 .channel_mode = alc882_ch_modes,
6109 .input_mux = &alc882_capture_source,
6110 .init_hook = alc885_macpro_init_hook,
6112 [ALC885_IMAC24] = {
6113 .mixers = { alc885_imac24_mixer },
6114 .init_verbs = { alc885_imac24_init_verbs },
6115 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6116 .dac_nids = alc882_dac_nids,
6117 .dig_out_nid = ALC882_DIGOUT_NID,
6118 .dig_in_nid = ALC882_DIGIN_NID,
6119 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
6120 .channel_mode = alc882_ch_modes,
6121 .input_mux = &alc882_capture_source,
6122 .unsol_event = alc885_imac24_unsol_event,
6123 .init_hook = alc885_imac24_init_hook,
6125 [ALC882_TARGA] = {
6126 .mixers = { alc882_targa_mixer, alc882_chmode_mixer,
6127 alc882_capture_mixer },
6128 .init_verbs = { alc882_init_verbs, alc882_targa_verbs},
6129 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6130 .dac_nids = alc882_dac_nids,
6131 .dig_out_nid = ALC882_DIGOUT_NID,
6132 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
6133 .adc_nids = alc882_adc_nids,
6134 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
6135 .channel_mode = alc882_3ST_6ch_modes,
6136 .need_dac_fix = 1,
6137 .input_mux = &alc882_capture_source,
6138 .unsol_event = alc882_targa_unsol_event,
6139 .init_hook = alc882_targa_automute,
6141 [ALC882_ASUS_A7J] = {
6142 .mixers = { alc882_asus_a7j_mixer, alc882_chmode_mixer,
6143 alc882_capture_mixer },
6144 .init_verbs = { alc882_init_verbs, alc882_asus_a7j_verbs},
6145 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6146 .dac_nids = alc882_dac_nids,
6147 .dig_out_nid = ALC882_DIGOUT_NID,
6148 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
6149 .adc_nids = alc882_adc_nids,
6150 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
6151 .channel_mode = alc882_3ST_6ch_modes,
6152 .need_dac_fix = 1,
6153 .input_mux = &alc882_capture_source,
6155 [ALC882_ASUS_A7M] = {
6156 .mixers = { alc882_asus_a7m_mixer, alc882_chmode_mixer },
6157 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs,
6158 alc880_gpio1_init_verbs,
6159 alc882_asus_a7m_verbs },
6160 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6161 .dac_nids = alc882_dac_nids,
6162 .dig_out_nid = ALC882_DIGOUT_NID,
6163 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
6164 .channel_mode = alc880_threestack_modes,
6165 .need_dac_fix = 1,
6166 .input_mux = &alc882_capture_source,
6172 * Pin config fixes
6174 enum {
6175 PINFIX_ABIT_AW9D_MAX
6178 static struct alc_pincfg alc882_abit_aw9d_pinfix[] = {
6179 { 0x15, 0x01080104 }, /* side */
6180 { 0x16, 0x01011012 }, /* rear */
6181 { 0x17, 0x01016011 }, /* clfe */
6185 static const struct alc_pincfg *alc882_pin_fixes[] = {
6186 [PINFIX_ABIT_AW9D_MAX] = alc882_abit_aw9d_pinfix,
6189 static struct snd_pci_quirk alc882_pinfix_tbl[] = {
6190 SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", PINFIX_ABIT_AW9D_MAX),
6195 * BIOS auto configuration
6197 static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
6198 hda_nid_t nid, int pin_type,
6199 int dac_idx)
6201 /* set as output */
6202 struct alc_spec *spec = codec->spec;
6203 int idx;
6205 if (spec->multiout.dac_nids[dac_idx] == 0x25)
6206 idx = 4;
6207 else
6208 idx = spec->multiout.dac_nids[dac_idx] - 2;
6210 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
6211 pin_type);
6212 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
6213 AMP_OUT_UNMUTE);
6214 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
6218 static void alc882_auto_init_multi_out(struct hda_codec *codec)
6220 struct alc_spec *spec = codec->spec;
6221 int i;
6223 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
6224 for (i = 0; i <= HDA_SIDE; i++) {
6225 hda_nid_t nid = spec->autocfg.line_out_pins[i];
6226 int pin_type = get_pin_type(spec->autocfg.line_out_type);
6227 if (nid)
6228 alc882_auto_set_output_and_unmute(codec, nid, pin_type,
6233 static void alc882_auto_init_hp_out(struct hda_codec *codec)
6235 struct alc_spec *spec = codec->spec;
6236 hda_nid_t pin;
6238 pin = spec->autocfg.hp_pins[0];
6239 if (pin) /* connect to front */
6240 /* use dac 0 */
6241 alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
6244 #define alc882_is_input_pin(nid) alc880_is_input_pin(nid)
6245 #define ALC882_PIN_CD_NID ALC880_PIN_CD_NID
6247 static void alc882_auto_init_analog_input(struct hda_codec *codec)
6249 struct alc_spec *spec = codec->spec;
6250 int i;
6252 for (i = 0; i < AUTO_PIN_LAST; i++) {
6253 hda_nid_t nid = spec->autocfg.input_pins[i];
6254 if (alc882_is_input_pin(nid)) {
6255 snd_hda_codec_write(codec, nid, 0,
6256 AC_VERB_SET_PIN_WIDGET_CONTROL,
6257 i <= AUTO_PIN_FRONT_MIC ?
6258 PIN_VREF80 : PIN_IN);
6259 if (nid != ALC882_PIN_CD_NID)
6260 snd_hda_codec_write(codec, nid, 0,
6261 AC_VERB_SET_AMP_GAIN_MUTE,
6262 AMP_OUT_MUTE);
6267 /* add mic boosts if needed */
6268 static int alc_auto_add_mic_boost(struct hda_codec *codec)
6270 struct alc_spec *spec = codec->spec;
6271 int err;
6272 hda_nid_t nid;
6274 nid = spec->autocfg.input_pins[AUTO_PIN_MIC];
6275 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
6276 err = add_control(spec, ALC_CTL_WIDGET_VOL,
6277 "Mic Boost",
6278 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
6279 if (err < 0)
6280 return err;
6282 nid = spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC];
6283 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
6284 err = add_control(spec, ALC_CTL_WIDGET_VOL,
6285 "Front Mic Boost",
6286 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
6287 if (err < 0)
6288 return err;
6290 return 0;
6293 /* almost identical with ALC880 parser... */
6294 static int alc882_parse_auto_config(struct hda_codec *codec)
6296 struct alc_spec *spec = codec->spec;
6297 int err = alc880_parse_auto_config(codec);
6299 if (err < 0)
6300 return err;
6301 else if (!err)
6302 return 0; /* no config found */
6304 err = alc_auto_add_mic_boost(codec);
6305 if (err < 0)
6306 return err;
6308 /* hack - override the init verbs */
6309 spec->init_verbs[0] = alc882_auto_init_verbs;
6311 return 1; /* config found */
6314 /* additional initialization for auto-configuration model */
6315 static void alc882_auto_init(struct hda_codec *codec)
6317 alc882_auto_init_multi_out(codec);
6318 alc882_auto_init_hp_out(codec);
6319 alc882_auto_init_analog_input(codec);
6322 static int patch_alc882(struct hda_codec *codec)
6324 struct alc_spec *spec;
6325 int err, board_config;
6327 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
6328 if (spec == NULL)
6329 return -ENOMEM;
6331 codec->spec = spec;
6333 board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST,
6334 alc882_models,
6335 alc882_cfg_tbl);
6337 if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
6338 /* Pick up systems that don't supply PCI SSID */
6339 switch (codec->subsystem_id) {
6340 case 0x106b0c00: /* Mac Pro */
6341 board_config = ALC885_MACPRO;
6342 break;
6343 case 0x106b1000: /* iMac 24 */
6344 board_config = ALC885_IMAC24;
6345 break;
6346 case 0x106b00a1: /* Macbook */
6347 case 0x106b2c00: /* Macbook Pro rev3 */
6348 board_config = ALC885_MBP3;
6349 break;
6350 default:
6351 printk(KERN_INFO "hda_codec: Unknown model for ALC882, "
6352 "trying auto-probe from BIOS...\n");
6353 board_config = ALC882_AUTO;
6357 alc_fix_pincfg(codec, alc882_pinfix_tbl, alc882_pin_fixes);
6359 if (board_config == ALC882_AUTO) {
6360 /* automatic parse from the BIOS config */
6361 err = alc882_parse_auto_config(codec);
6362 if (err < 0) {
6363 alc_free(codec);
6364 return err;
6365 } else if (!err) {
6366 printk(KERN_INFO
6367 "hda_codec: Cannot set up configuration "
6368 "from BIOS. Using base mode...\n");
6369 board_config = ALC882_3ST_DIG;
6373 if (board_config != ALC882_AUTO)
6374 setup_preset(spec, &alc882_presets[board_config]);
6376 spec->stream_name_analog = "ALC882 Analog";
6377 spec->stream_analog_playback = &alc882_pcm_analog_playback;
6378 spec->stream_analog_capture = &alc882_pcm_analog_capture;
6379 /* FIXME: setup DAC5 */
6380 /*spec->stream_analog_alt_playback = &alc880_pcm_analog_alt_playback;*/
6381 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
6383 spec->stream_name_digital = "ALC882 Digital";
6384 spec->stream_digital_playback = &alc882_pcm_digital_playback;
6385 spec->stream_digital_capture = &alc882_pcm_digital_capture;
6387 if (!spec->adc_nids && spec->input_mux) {
6388 /* check whether NID 0x07 is valid */
6389 unsigned int wcap = get_wcaps(codec, 0x07);
6390 /* get type */
6391 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
6392 if (wcap != AC_WID_AUD_IN) {
6393 spec->adc_nids = alc882_adc_nids_alt;
6394 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids_alt);
6395 spec->mixers[spec->num_mixers] =
6396 alc882_capture_alt_mixer;
6397 spec->num_mixers++;
6398 } else {
6399 spec->adc_nids = alc882_adc_nids;
6400 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids);
6401 spec->mixers[spec->num_mixers] = alc882_capture_mixer;
6402 spec->num_mixers++;
6406 spec->vmaster_nid = 0x0c;
6408 codec->patch_ops = alc_patch_ops;
6409 if (board_config == ALC882_AUTO)
6410 spec->init_hook = alc882_auto_init;
6411 #ifdef CONFIG_SND_HDA_POWER_SAVE
6412 if (!spec->loopback.amplist)
6413 spec->loopback.amplist = alc882_loopbacks;
6414 #endif
6416 return 0;
6420 * ALC883 support
6422 * ALC883 is almost identical with ALC880 but has cleaner and more flexible
6423 * configuration. Each pin widget can choose any input DACs and a mixer.
6424 * Each ADC is connected from a mixer of all inputs. This makes possible
6425 * 6-channel independent captures.
6427 * In addition, an independent DAC for the multi-playback (not used in this
6428 * driver yet).
6430 #define ALC883_DIGOUT_NID 0x06
6431 #define ALC883_DIGIN_NID 0x0a
6433 static hda_nid_t alc883_dac_nids[4] = {
6434 /* front, rear, clfe, rear_surr */
6435 0x02, 0x04, 0x03, 0x05
6438 static hda_nid_t alc883_adc_nids[2] = {
6439 /* ADC1-2 */
6440 0x08, 0x09,
6443 /* input MUX */
6444 /* FIXME: should be a matrix-type input source selection */
6446 static struct hda_input_mux alc883_capture_source = {
6447 .num_items = 4,
6448 .items = {
6449 { "Mic", 0x0 },
6450 { "Front Mic", 0x1 },
6451 { "Line", 0x2 },
6452 { "CD", 0x4 },
6456 static struct hda_input_mux alc883_lenovo_101e_capture_source = {
6457 .num_items = 2,
6458 .items = {
6459 { "Mic", 0x1 },
6460 { "Line", 0x2 },
6464 static struct hda_input_mux alc883_lenovo_nb0763_capture_source = {
6465 .num_items = 4,
6466 .items = {
6467 { "Mic", 0x0 },
6468 { "iMic", 0x1 },
6469 { "Line", 0x2 },
6470 { "CD", 0x4 },
6474 #define alc883_mux_enum_info alc_mux_enum_info
6475 #define alc883_mux_enum_get alc_mux_enum_get
6477 static int alc883_mux_enum_put(struct snd_kcontrol *kcontrol,
6478 struct snd_ctl_elem_value *ucontrol)
6480 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
6481 struct alc_spec *spec = codec->spec;
6482 const struct hda_input_mux *imux = spec->input_mux;
6483 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
6484 <<<<<<< HEAD:sound/pci/hda/patch_realtek.c
6485 static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
6486 =======
6487 static hda_nid_t capture_mixers[2] = { 0x23, 0x22 };
6488 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a:sound/pci/hda/patch_realtek.c
6489 hda_nid_t nid = capture_mixers[adc_idx];
6490 unsigned int *cur_val = &spec->cur_mux[adc_idx];
6491 unsigned int i, idx;
6493 idx = ucontrol->value.enumerated.item[0];
6494 if (idx >= imux->num_items)
6495 idx = imux->num_items - 1;
6496 if (*cur_val == idx)
6497 return 0;
6498 for (i = 0; i < imux->num_items; i++) {
6499 unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
6500 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
6501 imux->items[i].index,
6502 HDA_AMP_MUTE, v);
6504 *cur_val = idx;
6505 return 1;
6509 * 2ch mode
6511 static struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
6512 { 2, NULL }
6516 * 2ch mode
6518 static struct hda_verb alc883_3ST_ch2_init[] = {
6519 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6520 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6521 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6522 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6523 { } /* end */
6527 * 4ch mode
6529 static struct hda_verb alc883_3ST_ch4_init[] = {
6530 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6531 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6532 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6533 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6534 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6535 { } /* end */
6539 * 6ch mode
6541 static struct hda_verb alc883_3ST_ch6_init[] = {
6542 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6543 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6544 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
6545 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6546 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6547 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6548 { } /* end */
6551 static struct hda_channel_mode alc883_3ST_6ch_modes[3] = {
6552 { 2, alc883_3ST_ch2_init },
6553 { 4, alc883_3ST_ch4_init },
6554 { 6, alc883_3ST_ch6_init },
6558 * 6ch mode
6560 static struct hda_verb alc883_sixstack_ch6_init[] = {
6561 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
6562 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6563 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6564 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6565 { } /* end */
6569 * 8ch mode
6571 static struct hda_verb alc883_sixstack_ch8_init[] = {
6572 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6573 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6574 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6575 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6576 { } /* end */
6579 static struct hda_channel_mode alc883_sixstack_modes[2] = {
6580 { 6, alc883_sixstack_ch6_init },
6581 { 8, alc883_sixstack_ch8_init },
6584 static struct hda_verb alc883_medion_eapd_verbs[] = {
6585 /* eanable EAPD on medion laptop */
6586 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
6587 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
6591 /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
6592 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
6595 static struct snd_kcontrol_new alc883_base_mixer[] = {
6596 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6597 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6598 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
6599 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
6600 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
6601 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
6602 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
6603 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
6604 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
6605 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
6606 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6607 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6608 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6609 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6610 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6611 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6612 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6613 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6614 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6615 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
6616 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6617 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6618 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6619 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6620 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6621 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6622 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6624 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6625 /* .name = "Capture Source", */
6626 .name = "Input Source",
6627 .count = 2,
6628 .info = alc883_mux_enum_info,
6629 .get = alc883_mux_enum_get,
6630 .put = alc883_mux_enum_put,
6632 { } /* end */
6635 static struct snd_kcontrol_new alc883_mitac_mixer[] = {
6636 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6637 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6638 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
6639 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
6640 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
6641 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
6642 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
6643 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6644 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6645 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6646 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6647 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
6648 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6649 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6650 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6651 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6652 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6654 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6655 /* .name = "Capture Source", */
6656 .name = "Input Source",
6657 .count = 2,
6658 .info = alc883_mux_enum_info,
6659 .get = alc883_mux_enum_get,
6660 .put = alc883_mux_enum_put,
6662 { } /* end */
6665 static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
6666 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6667 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6668 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6669 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6670 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6671 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6672 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6673 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6674 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6675 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6676 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6677 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
6678 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6679 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6680 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6681 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6682 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6683 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6684 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6686 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6687 /* .name = "Capture Source", */
6688 .name = "Input Source",
6689 .count = 2,
6690 .info = alc883_mux_enum_info,
6691 .get = alc883_mux_enum_get,
6692 .put = alc883_mux_enum_put,
6694 { } /* end */
6697 static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
6698 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6699 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6700 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
6701 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
6702 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
6703 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
6704 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
6705 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
6706 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6707 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6708 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6709 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6710 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6711 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6712 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6713 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6714 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6715 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
6716 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6717 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6718 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6719 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6720 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6721 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6722 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6724 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6725 /* .name = "Capture Source", */
6726 .name = "Input Source",
6727 .count = 2,
6728 .info = alc883_mux_enum_info,
6729 .get = alc883_mux_enum_get,
6730 .put = alc883_mux_enum_put,
6732 { } /* end */
6735 static struct snd_kcontrol_new alc883_fivestack_mixer[] = {
6736 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6737 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6738 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
6739 HDA_CODEC_MUTE("Surround Playback Switch", 0x15, 0x0, HDA_OUTPUT),
6740 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
6741 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
6742 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x16, 1, 0x0, HDA_OUTPUT),
6743 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
6744 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6745 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6746 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6747 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6748 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6749 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6750 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6751 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6752 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6753 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
6754 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6755 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6756 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6757 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6758 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6761 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6762 /* .name = "Capture Source", */
6763 .name = "Input Source",
6764 .count = 1,
6765 .info = alc883_mux_enum_info,
6766 .get = alc883_mux_enum_get,
6767 .put = alc883_mux_enum_put,
6769 { } /* end */
6772 static struct snd_kcontrol_new alc883_tagra_mixer[] = {
6773 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6774 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6775 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6776 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
6777 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
6778 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
6779 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
6780 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
6781 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
6782 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6783 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6784 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6785 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6786 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6787 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6788 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6789 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6790 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6791 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6792 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6794 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6795 /* .name = "Capture Source", */
6796 .name = "Input Source",
6797 .count = 2,
6798 .info = alc883_mux_enum_info,
6799 .get = alc883_mux_enum_get,
6800 .put = alc883_mux_enum_put,
6802 { } /* end */
6805 static struct snd_kcontrol_new alc883_tagra_2ch_mixer[] = {
6806 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6807 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6808 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6809 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6810 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6811 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6812 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6813 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6814 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6815 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6816 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6817 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6819 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6820 /* .name = "Capture Source", */
6821 .name = "Input Source",
6822 .count = 2,
6823 .info = alc883_mux_enum_info,
6824 .get = alc883_mux_enum_get,
6825 .put = alc883_mux_enum_put,
6827 { } /* end */
6830 static struct snd_kcontrol_new alc883_lenovo_101e_2ch_mixer[] = {
6831 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6832 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6833 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
6834 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
6835 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6836 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6837 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6838 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6839 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6840 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6842 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6843 /* .name = "Capture Source", */
6844 .name = "Input Source",
6845 .count = 1,
6846 .info = alc883_mux_enum_info,
6847 .get = alc883_mux_enum_get,
6848 .put = alc883_mux_enum_put,
6850 { } /* end */
6853 static struct snd_kcontrol_new alc883_lenovo_nb0763_mixer[] = {
6854 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6855 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
6856 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6857 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6858 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6859 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6860 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6861 HDA_CODEC_VOLUME("iMic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6862 HDA_CODEC_MUTE("iMic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6863 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6864 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6865 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6866 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6868 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6869 /* .name = "Capture Source", */
6870 .name = "Input Source",
6871 .count = 2,
6872 .info = alc883_mux_enum_info,
6873 .get = alc883_mux_enum_get,
6874 .put = alc883_mux_enum_put,
6876 { } /* end */
6879 static struct snd_kcontrol_new alc883_medion_md2_mixer[] = {
6880 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6881 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6882 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
6883 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6884 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6885 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6886 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6887 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6888 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6889 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6890 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6891 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6892 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6894 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6895 /* .name = "Capture Source", */
6896 .name = "Input Source",
6897 .count = 2,
6898 .info = alc883_mux_enum_info,
6899 .get = alc883_mux_enum_get,
6900 .put = alc883_mux_enum_put,
6902 { } /* end */
6905 static struct snd_kcontrol_new alc888_6st_hp_mixer[] = {
6906 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6907 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6908 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
6909 HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
6910 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
6911 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
6912 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
6913 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
6914 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
6915 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
6916 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6917 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6918 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6919 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6920 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6921 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6922 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6923 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6924 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6925 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
6926 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6927 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6928 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6929 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6930 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6931 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6932 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6934 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6935 /* .name = "Capture Source", */
6936 .name = "Input Source",
6937 .count = 2,
6938 .info = alc883_mux_enum_info,
6939 .get = alc883_mux_enum_get,
6940 .put = alc883_mux_enum_put,
6942 { } /* end */
6945 static struct snd_kcontrol_new alc888_3st_hp_mixer[] = {
6946 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6947 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6948 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
6949 HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
6950 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
6951 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
6952 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
6953 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
6954 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6955 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6956 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6957 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6958 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6959 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6960 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6961 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6962 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6963 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
6964 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6965 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6966 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6967 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6968 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6969 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6970 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6972 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6973 /* .name = "Capture Source", */
6974 .name = "Input Source",
6975 .count = 2,
6976 .info = alc883_mux_enum_info,
6977 .get = alc883_mux_enum_get,
6978 .put = alc883_mux_enum_put,
6980 { } /* end */
6983 static struct snd_kcontrol_new alc888_6st_dell_mixer[] = {
6984 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6985 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6986 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
6987 HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
6988 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
6989 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
6990 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
6991 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
6992 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
6993 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
6994 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6995 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6996 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6997 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6998 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6999 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7000 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7001 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7002 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7003 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
7004 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7005 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
7006 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
7007 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7008 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7009 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
7010 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
7012 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7013 /* .name = "Capture Source", */
7014 .name = "Input Source",
7015 .count = 2,
7016 .info = alc883_mux_enum_info,
7017 .get = alc883_mux_enum_get,
7018 .put = alc883_mux_enum_put,
7020 { } /* end */
7023 static struct snd_kcontrol_new alc883_acer_aspire_mixer[] = {
7024 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7025 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7026 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7027 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7028 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7029 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7030 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7031 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7032 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7033 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7034 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
7035 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
7037 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7038 /* .name = "Capture Source", */
7039 .name = "Input Source",
7040 .count = 2,
7041 .info = alc883_mux_enum_info,
7042 .get = alc883_mux_enum_get,
7043 .put = alc883_mux_enum_put,
7045 { } /* end */
7048 static struct snd_kcontrol_new alc883_chmode_mixer[] = {
7050 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7051 .name = "Channel Mode",
7052 .info = alc_ch_mode_info,
7053 .get = alc_ch_mode_get,
7054 .put = alc_ch_mode_put,
7056 { } /* end */
7059 static struct hda_verb alc883_init_verbs[] = {
7060 /* ADC1: mute amp left and right */
7061 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7062 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7063 /* ADC2: mute amp left and right */
7064 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7065 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7066 /* Front mixer: unmute input/output amp left and right (volume = 0) */
7067 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7068 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7069 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7070 /* Rear mixer */
7071 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7072 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7073 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7074 /* CLFE mixer */
7075 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7076 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7077 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7078 /* Side mixer */
7079 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7080 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7081 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7083 /* mute analog input loopbacks */
7084 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7085 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7086 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7087 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7088 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7090 /* Front Pin: output 0 (0x0c) */
7091 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7092 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7093 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7094 /* Rear Pin: output 1 (0x0d) */
7095 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7096 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7097 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
7098 /* CLFE Pin: output 2 (0x0e) */
7099 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7100 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7101 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
7102 /* Side Pin: output 3 (0x0f) */
7103 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7104 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7105 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
7106 /* Mic (rear) pin: input vref at 80% */
7107 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7108 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7109 /* Front Mic pin: input vref at 80% */
7110 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7111 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7112 /* Line In pin: input */
7113 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7114 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7115 /* Line-2 In: Headphone output (output 0 - 0x0c) */
7116 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7117 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7118 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
7119 /* CD pin widget for input */
7120 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7122 /* FIXME: use matrix-type input source selection */
7123 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7124 /* Input mixer2 */
7125 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7126 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7127 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7128 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
7129 /* Input mixer3 */
7130 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7131 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7132 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7133 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
7137 /* toggle speaker-output according to the hp-jack state */
7138 static void alc883_mitac_hp_automute(struct hda_codec *codec)
7140 unsigned int present;
7142 present = snd_hda_codec_read(codec, 0x15, 0,
7143 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7144 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7145 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7146 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
7147 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7150 /* auto-toggle front mic */
7152 static void alc883_mitac_mic_automute(struct hda_codec *codec)
7154 unsigned int present;
7155 unsigned char bits;
7157 present = snd_hda_codec_read(codec, 0x18, 0,
7158 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7159 bits = present ? HDA_AMP_MUTE : 0;
7160 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
7164 static void alc883_mitac_automute(struct hda_codec *codec)
7166 alc883_mitac_hp_automute(codec);
7167 /* alc883_mitac_mic_automute(codec); */
7170 static void alc883_mitac_unsol_event(struct hda_codec *codec,
7171 unsigned int res)
7173 switch (res >> 26) {
7174 case ALC880_HP_EVENT:
7175 alc883_mitac_hp_automute(codec);
7176 break;
7177 case ALC880_MIC_EVENT:
7178 /* alc883_mitac_mic_automute(codec); */
7179 break;
7183 static struct hda_verb alc883_mitac_verbs[] = {
7184 /* HP */
7185 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7186 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7187 /* Subwoofer */
7188 {0x17, AC_VERB_SET_CONNECT_SEL, 0x02},
7189 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7191 /* enable unsolicited event */
7192 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7193 /* {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN}, */
7195 { } /* end */
7198 static struct hda_verb alc883_tagra_verbs[] = {
7199 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7200 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7202 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7203 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7205 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
7206 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
7207 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
7209 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7210 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
7211 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
7212 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
7214 { } /* end */
7217 static struct hda_verb alc883_lenovo_101e_verbs[] = {
7218 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7219 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT|AC_USRSP_EN},
7220 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT|AC_USRSP_EN},
7221 { } /* end */
7224 static struct hda_verb alc883_lenovo_nb0763_verbs[] = {
7225 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7226 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7227 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7228 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7229 { } /* end */
7232 static struct hda_verb alc888_lenovo_ms7195_verbs[] = {
7233 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7234 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7235 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7236 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT | AC_USRSP_EN},
7237 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7238 { } /* end */
7241 static struct hda_verb alc883_haier_w66_verbs[] = {
7242 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7243 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7245 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7247 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
7248 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7249 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7250 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7251 { } /* end */
7254 static struct hda_verb alc888_6st_hp_verbs[] = {
7255 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
7256 {0x15, AC_VERB_SET_CONNECT_SEL, 0x02}, /* Rear : output 2 (0x0e) */
7257 {0x16, AC_VERB_SET_CONNECT_SEL, 0x01}, /* CLFE : output 1 (0x0d) */
7258 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03}, /* Side : output 3 (0x0f) */
7262 static struct hda_verb alc888_3st_hp_verbs[] = {
7263 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
7264 {0x18, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Rear : output 1 (0x0d) */
7265 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02}, /* CLFE : output 2 (0x0e) */
7269 static struct hda_verb alc888_6st_dell_verbs[] = {
7270 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
7271 {0x15, AC_VERB_SET_CONNECT_SEL, 0x02}, /* Rear : output 1 (0x0e) */
7272 {0x16, AC_VERB_SET_CONNECT_SEL, 0x01}, /* CLFE : output 2 (0x0d) */
7273 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03}, /* Side : output 3 (0x0f) */
7274 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7278 static struct hda_verb alc888_3st_hp_2ch_init[] = {
7279 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7280 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7281 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7282 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7286 static struct hda_verb alc888_3st_hp_6ch_init[] = {
7287 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7288 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7289 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7290 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7294 static struct hda_channel_mode alc888_3st_hp_modes[2] = {
7295 { 2, alc888_3st_hp_2ch_init },
7296 { 6, alc888_3st_hp_6ch_init },
7299 /* toggle front-jack and RCA according to the hp-jack state */
7300 static void alc888_lenovo_ms7195_front_automute(struct hda_codec *codec)
7302 unsigned int present;
7304 present = snd_hda_codec_read(codec, 0x1b, 0,
7305 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7306 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7307 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7308 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7309 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7312 /* toggle RCA according to the front-jack state */
7313 static void alc888_lenovo_ms7195_rca_automute(struct hda_codec *codec)
7315 unsigned int present;
7317 present = snd_hda_codec_read(codec, 0x14, 0,
7318 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7319 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7320 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7323 static void alc883_lenovo_ms7195_unsol_event(struct hda_codec *codec,
7324 unsigned int res)
7326 if ((res >> 26) == ALC880_HP_EVENT)
7327 alc888_lenovo_ms7195_front_automute(codec);
7328 if ((res >> 26) == ALC880_FRONT_EVENT)
7329 alc888_lenovo_ms7195_rca_automute(codec);
7332 static struct hda_verb alc883_medion_md2_verbs[] = {
7333 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7334 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7336 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7338 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7339 { } /* end */
7342 /* toggle speaker-output according to the hp-jack state */
7343 static void alc883_medion_md2_automute(struct hda_codec *codec)
7345 unsigned int present;
7347 present = snd_hda_codec_read(codec, 0x14, 0,
7348 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7349 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7350 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7353 static void alc883_medion_md2_unsol_event(struct hda_codec *codec,
7354 unsigned int res)
7356 if ((res >> 26) == ALC880_HP_EVENT)
7357 alc883_medion_md2_automute(codec);
7360 /* toggle speaker-output according to the hp-jack state */
7361 static void alc883_tagra_automute(struct hda_codec *codec)
7363 unsigned int present;
7364 unsigned char bits;
7366 present = snd_hda_codec_read(codec, 0x14, 0,
7367 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7368 bits = present ? HDA_AMP_MUTE : 0;
7369 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
7370 HDA_AMP_MUTE, bits);
7371 snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
7372 present ? 1 : 3);
7375 static void alc883_tagra_unsol_event(struct hda_codec *codec, unsigned int res)
7377 if ((res >> 26) == ALC880_HP_EVENT)
7378 alc883_tagra_automute(codec);
7381 static void alc883_haier_w66_automute(struct hda_codec *codec)
7383 unsigned int present;
7384 unsigned char bits;
7386 present = snd_hda_codec_read(codec, 0x1b, 0,
7387 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7388 bits = present ? 0x80 : 0;
7389 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7390 0x80, bits);
7393 static void alc883_haier_w66_unsol_event(struct hda_codec *codec,
7394 unsigned int res)
7396 if ((res >> 26) == ALC880_HP_EVENT)
7397 alc883_haier_w66_automute(codec);
7400 static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
7402 unsigned int present;
7403 unsigned char bits;
7405 present = snd_hda_codec_read(codec, 0x14, 0,
7406 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7407 bits = present ? HDA_AMP_MUTE : 0;
7408 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7409 HDA_AMP_MUTE, bits);
7412 static void alc883_lenovo_101e_all_automute(struct hda_codec *codec)
7414 unsigned int present;
7415 unsigned char bits;
7417 present = snd_hda_codec_read(codec, 0x1b, 0,
7418 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7419 bits = present ? HDA_AMP_MUTE : 0;
7420 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7421 HDA_AMP_MUTE, bits);
7422 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7423 HDA_AMP_MUTE, bits);
7426 static void alc883_lenovo_101e_unsol_event(struct hda_codec *codec,
7427 unsigned int res)
7429 if ((res >> 26) == ALC880_HP_EVENT)
7430 alc883_lenovo_101e_all_automute(codec);
7431 if ((res >> 26) == ALC880_FRONT_EVENT)
7432 alc883_lenovo_101e_ispeaker_automute(codec);
7435 /* toggle speaker-output according to the hp-jack state */
7436 static void alc883_acer_aspire_automute(struct hda_codec *codec)
7438 unsigned int present;
7440 present = snd_hda_codec_read(codec, 0x14, 0,
7441 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7442 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7443 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7444 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
7445 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7448 static void alc883_acer_aspire_unsol_event(struct hda_codec *codec,
7449 unsigned int res)
7451 if ((res >> 26) == ALC880_HP_EVENT)
7452 alc883_acer_aspire_automute(codec);
7455 static struct hda_verb alc883_acer_eapd_verbs[] = {
7456 /* HP Pin: output 0 (0x0c) */
7457 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7458 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7459 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7460 /* Front Pin: output 0 (0x0c) */
7461 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7462 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7463 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7464 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00},
7465 /* eanable EAPD on medion laptop */
7466 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
7467 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
7468 /* enable unsolicited event */
7469 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7473 static void alc888_6st_dell_front_automute(struct hda_codec *codec)
7475 unsigned int present;
7477 present = snd_hda_codec_read(codec, 0x1b, 0,
7478 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7479 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7480 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7481 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7482 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7483 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
7484 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7485 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
7486 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7489 static void alc888_6st_dell_unsol_event(struct hda_codec *codec,
7490 unsigned int res)
7492 switch (res >> 26) {
7493 case ALC880_HP_EVENT:
7494 printk("hp_event\n");
7495 alc888_6st_dell_front_automute(codec);
7496 break;
7501 * generic initialization of ADC, input mixers and output mixers
7503 static struct hda_verb alc883_auto_init_verbs[] = {
7505 * Unmute ADC0-2 and set the default input to mic-in
7507 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7508 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7509 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7510 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7512 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
7513 * mixer widget
7514 * Note: PASD motherboards uses the Line In 2 as the input for
7515 * front panel mic (mic 2)
7517 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
7518 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7519 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7520 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7521 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7522 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7525 * Set up output mixers (0x0c - 0x0f)
7527 /* set vol=0 to output mixers */
7528 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7529 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7530 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7531 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7532 /* set up input amps for analog loopback */
7533 /* Amp Indices: DAC = 0, mixer = 1 */
7534 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7535 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7536 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7537 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7538 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7539 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7540 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7541 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7542 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7543 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7545 /* FIXME: use matrix-type input source selection */
7546 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7547 /* Input mixer1 */
7548 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7549 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7550 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7551 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
7552 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
7553 /* Input mixer2 */
7554 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7555 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7556 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7557 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
7558 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
7563 /* capture mixer elements */
7564 static struct snd_kcontrol_new alc883_capture_mixer[] = {
7565 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7566 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7567 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
7568 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
7570 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7571 /* The multiple "Capture Source" controls confuse alsamixer
7572 * So call somewhat different..
7574 /* .name = "Capture Source", */
7575 .name = "Input Source",
7576 .count = 2,
7577 .info = alc882_mux_enum_info,
7578 .get = alc882_mux_enum_get,
7579 .put = alc882_mux_enum_put,
7581 { } /* end */
7584 #ifdef CONFIG_SND_HDA_POWER_SAVE
7585 #define alc883_loopbacks alc880_loopbacks
7586 #endif
7588 /* pcm configuration: identiacal with ALC880 */
7589 #define alc883_pcm_analog_playback alc880_pcm_analog_playback
7590 #define alc883_pcm_analog_capture alc880_pcm_analog_capture
7591 #define alc883_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
7592 #define alc883_pcm_digital_playback alc880_pcm_digital_playback
7593 #define alc883_pcm_digital_capture alc880_pcm_digital_capture
7596 * configuration and preset
7598 static const char *alc883_models[ALC883_MODEL_LAST] = {
7599 [ALC883_3ST_2ch_DIG] = "3stack-dig",
7600 [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig",
7601 [ALC883_3ST_6ch] = "3stack-6ch",
7602 [ALC883_6ST_DIG] = "6stack-dig",
7603 [ALC883_TARGA_DIG] = "targa-dig",
7604 [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig",
7605 [ALC883_ACER] = "acer",
7606 [ALC883_ACER_ASPIRE] = "acer-aspire",
7607 [ALC883_MEDION] = "medion",
7608 [ALC883_MEDION_MD2] = "medion-md2",
7609 [ALC883_LAPTOP_EAPD] = "laptop-eapd",
7610 [ALC883_LENOVO_101E_2ch] = "lenovo-101e",
7611 [ALC883_LENOVO_NB0763] = "lenovo-nb0763",
7612 [ALC888_LENOVO_MS7195_DIG] = "lenovo-ms7195-dig",
7613 [ALC883_HAIER_W66] = "haier-w66",
7614 [ALC888_6ST_HP] = "6stack-hp",
7615 [ALC888_3ST_HP] = "3stack-hp",
7616 [ALC888_6ST_DELL] = "6stack-dell",
7617 [ALC883_MITAC] = "mitac",
7618 [ALC883_AUTO] = "auto",
7621 static struct snd_pci_quirk alc883_cfg_tbl[] = {
7622 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC883_3ST_6ch_DIG),
7623 SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_ACER_ASPIRE),
7624 SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_ACER_ASPIRE),
7625 SND_PCI_QUIRK(0x1025, 0x0112, "Acer Aspire 9303", ALC883_ACER_ASPIRE),
7626 SND_PCI_QUIRK(0x1025, 0, "Acer laptop", ALC883_ACER), /* default Acer */
7627 SND_PCI_QUIRK(0x1028, 0x020d, "Dell Inspiron 530", ALC888_6ST_DELL),
7628 SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG),
7629 SND_PCI_QUIRK(0x103c, 0x2a4f, "HP Samba", ALC888_3ST_HP),
7630 SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_3ST_HP),
7631 SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC888_6ST_HP),
7632 SND_PCI_QUIRK(0x1043, 0x8249, "Asus M2A-VM HDMI", ALC883_3ST_6ch_DIG),
7633 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC883_6ST_DIG),
7634 SND_PCI_QUIRK(0x1071, 0x8253, "Mitac 8252d", ALC883_MITAC),
7635 SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD),
7636 SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch),
7637 SND_PCI_QUIRK(0x1458, 0xa002, "MSI", ALC883_6ST_DIG),
7638 SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG),
7639 SND_PCI_QUIRK(0x1462, 0x040d, "MSI", ALC883_TARGA_2ch_DIG),
7640 SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG),
7641 SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG),
7642 SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG),
7643 SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG),
7644 SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG),
7645 SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG),
7646 SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG),
7647 SND_PCI_QUIRK(0x1462, 0x3fdf, "MSI", ALC883_TARGA_DIG),
7648 SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG),
7649 SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG),
7650 SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG),
7651 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG),
7652 SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG),
7653 SND_PCI_QUIRK(0x1462, 0x7250, "MSI", ALC883_6ST_DIG),
7654 SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG),
7655 SND_PCI_QUIRK(0x1462, 0x7327, "MSI", ALC883_6ST_DIG),
7656 SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG),
7657 SND_PCI_QUIRK(0x147b, 0x1083, "Abit IP35-PRO", ALC883_6ST_DIG),
7658 SND_PCI_QUIRK(0x1558, 0, "Clevo laptop", ALC883_LAPTOP_EAPD),
7659 SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch),
7660 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
7661 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch),
7662 SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763),
7663 SND_PCI_QUIRK(0x17aa, 0x3bfc, "Lenovo NB0763", ALC883_LENOVO_NB0763),
7664 SND_PCI_QUIRK(0x17aa, 0x3bfd, "Lenovo NB0763", ALC883_LENOVO_NB0763),
7665 SND_PCI_QUIRK(0x17c0, 0x4071, "MEDION MD2", ALC883_MEDION_MD2),
7666 <<<<<<< HEAD:sound/pci/hda/patch_realtek.c
7667 =======
7668 SND_PCI_QUIRK(0x17f2, 0x5000, "Albatron KI690-AM2", ALC883_6ST_DIG),
7669 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a:sound/pci/hda/patch_realtek.c
7670 SND_PCI_QUIRK(0x1991, 0x5625, "Haier W66", ALC883_HAIER_W66),
7671 SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC883_3ST_6ch),
7675 static struct alc_config_preset alc883_presets[] = {
7676 [ALC883_3ST_2ch_DIG] = {
7677 .mixers = { alc883_3ST_2ch_mixer },
7678 .init_verbs = { alc883_init_verbs },
7679 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7680 .dac_nids = alc883_dac_nids,
7681 .dig_out_nid = ALC883_DIGOUT_NID,
7682 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7683 .adc_nids = alc883_adc_nids,
7684 .dig_in_nid = ALC883_DIGIN_NID,
7685 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7686 .channel_mode = alc883_3ST_2ch_modes,
7687 .input_mux = &alc883_capture_source,
7689 [ALC883_3ST_6ch_DIG] = {
7690 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
7691 .init_verbs = { alc883_init_verbs },
7692 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7693 .dac_nids = alc883_dac_nids,
7694 .dig_out_nid = ALC883_DIGOUT_NID,
7695 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7696 .adc_nids = alc883_adc_nids,
7697 .dig_in_nid = ALC883_DIGIN_NID,
7698 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
7699 .channel_mode = alc883_3ST_6ch_modes,
7700 .need_dac_fix = 1,
7701 .input_mux = &alc883_capture_source,
7703 [ALC883_3ST_6ch] = {
7704 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
7705 .init_verbs = { alc883_init_verbs },
7706 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7707 .dac_nids = alc883_dac_nids,
7708 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7709 .adc_nids = alc883_adc_nids,
7710 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
7711 .channel_mode = alc883_3ST_6ch_modes,
7712 .need_dac_fix = 1,
7713 .input_mux = &alc883_capture_source,
7715 [ALC883_6ST_DIG] = {
7716 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
7717 .init_verbs = { alc883_init_verbs },
7718 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7719 .dac_nids = alc883_dac_nids,
7720 .dig_out_nid = ALC883_DIGOUT_NID,
7721 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7722 .adc_nids = alc883_adc_nids,
7723 .dig_in_nid = ALC883_DIGIN_NID,
7724 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
7725 .channel_mode = alc883_sixstack_modes,
7726 .input_mux = &alc883_capture_source,
7728 [ALC883_TARGA_DIG] = {
7729 .mixers = { alc883_tagra_mixer, alc883_chmode_mixer },
7730 .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
7731 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7732 .dac_nids = alc883_dac_nids,
7733 .dig_out_nid = ALC883_DIGOUT_NID,
7734 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7735 .adc_nids = alc883_adc_nids,
7736 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
7737 .channel_mode = alc883_3ST_6ch_modes,
7738 .need_dac_fix = 1,
7739 .input_mux = &alc883_capture_source,
7740 .unsol_event = alc883_tagra_unsol_event,
7741 .init_hook = alc883_tagra_automute,
7743 [ALC883_TARGA_2ch_DIG] = {
7744 .mixers = { alc883_tagra_2ch_mixer},
7745 .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
7746 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7747 .dac_nids = alc883_dac_nids,
7748 .dig_out_nid = ALC883_DIGOUT_NID,
7749 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7750 .adc_nids = alc883_adc_nids,
7751 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7752 .channel_mode = alc883_3ST_2ch_modes,
7753 .input_mux = &alc883_capture_source,
7754 .unsol_event = alc883_tagra_unsol_event,
7755 .init_hook = alc883_tagra_automute,
7757 [ALC883_ACER] = {
7758 .mixers = { alc883_base_mixer },
7759 /* On TravelMate laptops, GPIO 0 enables the internal speaker
7760 * and the headphone jack. Turn this on and rely on the
7761 * standard mute methods whenever the user wants to turn
7762 * these outputs off.
7764 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs },
7765 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7766 .dac_nids = alc883_dac_nids,
7767 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7768 .adc_nids = alc883_adc_nids,
7769 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7770 .channel_mode = alc883_3ST_2ch_modes,
7771 .input_mux = &alc883_capture_source,
7773 [ALC883_ACER_ASPIRE] = {
7774 .mixers = { alc883_acer_aspire_mixer },
7775 .init_verbs = { alc883_init_verbs, alc883_acer_eapd_verbs },
7776 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7777 .dac_nids = alc883_dac_nids,
7778 .dig_out_nid = ALC883_DIGOUT_NID,
7779 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7780 .adc_nids = alc883_adc_nids,
7781 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7782 .channel_mode = alc883_3ST_2ch_modes,
7783 .input_mux = &alc883_capture_source,
7784 .unsol_event = alc883_acer_aspire_unsol_event,
7785 .init_hook = alc883_acer_aspire_automute,
7787 [ALC883_MEDION] = {
7788 .mixers = { alc883_fivestack_mixer,
7789 alc883_chmode_mixer },
7790 .init_verbs = { alc883_init_verbs,
7791 alc883_medion_eapd_verbs },
7792 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7793 .dac_nids = alc883_dac_nids,
7794 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7795 .adc_nids = alc883_adc_nids,
7796 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
7797 .channel_mode = alc883_sixstack_modes,
7798 .input_mux = &alc883_capture_source,
7800 [ALC883_MEDION_MD2] = {
7801 .mixers = { alc883_medion_md2_mixer},
7802 .init_verbs = { alc883_init_verbs, alc883_medion_md2_verbs},
7803 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7804 .dac_nids = alc883_dac_nids,
7805 .dig_out_nid = ALC883_DIGOUT_NID,
7806 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7807 .adc_nids = alc883_adc_nids,
7808 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7809 .channel_mode = alc883_3ST_2ch_modes,
7810 .input_mux = &alc883_capture_source,
7811 .unsol_event = alc883_medion_md2_unsol_event,
7812 .init_hook = alc883_medion_md2_automute,
7814 [ALC883_LAPTOP_EAPD] = {
7815 .mixers = { alc883_base_mixer },
7816 .init_verbs = { alc883_init_verbs, alc882_eapd_verbs },
7817 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7818 .dac_nids = alc883_dac_nids,
7819 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7820 .adc_nids = alc883_adc_nids,
7821 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7822 .channel_mode = alc883_3ST_2ch_modes,
7823 .input_mux = &alc883_capture_source,
7825 [ALC883_LENOVO_101E_2ch] = {
7826 .mixers = { alc883_lenovo_101e_2ch_mixer},
7827 .init_verbs = { alc883_init_verbs, alc883_lenovo_101e_verbs},
7828 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7829 .dac_nids = alc883_dac_nids,
7830 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7831 .adc_nids = alc883_adc_nids,
7832 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7833 .channel_mode = alc883_3ST_2ch_modes,
7834 .input_mux = &alc883_lenovo_101e_capture_source,
7835 .unsol_event = alc883_lenovo_101e_unsol_event,
7836 .init_hook = alc883_lenovo_101e_all_automute,
7838 [ALC883_LENOVO_NB0763] = {
7839 .mixers = { alc883_lenovo_nb0763_mixer },
7840 .init_verbs = { alc883_init_verbs, alc883_lenovo_nb0763_verbs},
7841 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7842 .dac_nids = alc883_dac_nids,
7843 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7844 .adc_nids = alc883_adc_nids,
7845 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7846 .channel_mode = alc883_3ST_2ch_modes,
7847 .need_dac_fix = 1,
7848 .input_mux = &alc883_lenovo_nb0763_capture_source,
7849 .unsol_event = alc883_medion_md2_unsol_event,
7850 .init_hook = alc883_medion_md2_automute,
7852 [ALC888_LENOVO_MS7195_DIG] = {
7853 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
7854 .init_verbs = { alc883_init_verbs, alc888_lenovo_ms7195_verbs},
7855 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7856 .dac_nids = alc883_dac_nids,
7857 .dig_out_nid = ALC883_DIGOUT_NID,
7858 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7859 .adc_nids = alc883_adc_nids,
7860 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
7861 .channel_mode = alc883_3ST_6ch_modes,
7862 .need_dac_fix = 1,
7863 .input_mux = &alc883_capture_source,
7864 .unsol_event = alc883_lenovo_ms7195_unsol_event,
7865 .init_hook = alc888_lenovo_ms7195_front_automute,
7867 [ALC883_HAIER_W66] = {
7868 .mixers = { alc883_tagra_2ch_mixer},
7869 .init_verbs = { alc883_init_verbs, alc883_haier_w66_verbs},
7870 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7871 .dac_nids = alc883_dac_nids,
7872 .dig_out_nid = ALC883_DIGOUT_NID,
7873 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7874 .adc_nids = alc883_adc_nids,
7875 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7876 .channel_mode = alc883_3ST_2ch_modes,
7877 .input_mux = &alc883_capture_source,
7878 .unsol_event = alc883_haier_w66_unsol_event,
7879 .init_hook = alc883_haier_w66_automute,
7881 [ALC888_6ST_HP] = {
7882 .mixers = { alc888_6st_hp_mixer, alc883_chmode_mixer },
7883 .init_verbs = { alc883_init_verbs, alc888_6st_hp_verbs },
7884 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7885 .dac_nids = alc883_dac_nids,
7886 .dig_out_nid = ALC883_DIGOUT_NID,
7887 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7888 .adc_nids = alc883_adc_nids,
7889 .dig_in_nid = ALC883_DIGIN_NID,
7890 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
7891 .channel_mode = alc883_sixstack_modes,
7892 .input_mux = &alc883_capture_source,
7894 [ALC888_3ST_HP] = {
7895 .mixers = { alc888_3st_hp_mixer, alc883_chmode_mixer },
7896 .init_verbs = { alc883_init_verbs, alc888_3st_hp_verbs },
7897 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7898 .dac_nids = alc883_dac_nids,
7899 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7900 .adc_nids = alc883_adc_nids,
7901 .num_channel_mode = ARRAY_SIZE(alc888_3st_hp_modes),
7902 .channel_mode = alc888_3st_hp_modes,
7903 .need_dac_fix = 1,
7904 .input_mux = &alc883_capture_source,
7906 [ALC888_6ST_DELL] = {
7907 .mixers = { alc888_6st_dell_mixer, alc883_chmode_mixer },
7908 .init_verbs = { alc883_init_verbs, alc888_6st_dell_verbs },
7909 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7910 .dac_nids = alc883_dac_nids,
7911 .dig_out_nid = ALC883_DIGOUT_NID,
7912 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7913 .adc_nids = alc883_adc_nids,
7914 .dig_in_nid = ALC883_DIGIN_NID,
7915 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
7916 .channel_mode = alc883_sixstack_modes,
7917 .input_mux = &alc883_capture_source,
7918 .unsol_event = alc888_6st_dell_unsol_event,
7919 .init_hook = alc888_6st_dell_front_automute,
7921 [ALC883_MITAC] = {
7922 .mixers = { alc883_mitac_mixer },
7923 .init_verbs = { alc883_init_verbs, alc883_mitac_verbs },
7924 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7925 .dac_nids = alc883_dac_nids,
7926 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7927 .adc_nids = alc883_adc_nids,
7928 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7929 .channel_mode = alc883_3ST_2ch_modes,
7930 .input_mux = &alc883_capture_source,
7931 .unsol_event = alc883_mitac_unsol_event,
7932 .init_hook = alc883_mitac_automute,
7938 * BIOS auto configuration
7940 static void alc883_auto_set_output_and_unmute(struct hda_codec *codec,
7941 hda_nid_t nid, int pin_type,
7942 int dac_idx)
7944 /* set as output */
7945 struct alc_spec *spec = codec->spec;
7946 int idx;
7948 if (spec->multiout.dac_nids[dac_idx] == 0x25)
7949 idx = 4;
7950 else
7951 idx = spec->multiout.dac_nids[dac_idx] - 2;
7953 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
7954 pin_type);
7955 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
7956 AMP_OUT_UNMUTE);
7957 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
7961 static void alc883_auto_init_multi_out(struct hda_codec *codec)
7963 struct alc_spec *spec = codec->spec;
7964 int i;
7966 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
7967 for (i = 0; i <= HDA_SIDE; i++) {
7968 hda_nid_t nid = spec->autocfg.line_out_pins[i];
7969 int pin_type = get_pin_type(spec->autocfg.line_out_type);
7970 if (nid)
7971 alc883_auto_set_output_and_unmute(codec, nid, pin_type,
7976 static void alc883_auto_init_hp_out(struct hda_codec *codec)
7978 struct alc_spec *spec = codec->spec;
7979 hda_nid_t pin;
7981 pin = spec->autocfg.hp_pins[0];
7982 if (pin) /* connect to front */
7983 /* use dac 0 */
7984 alc883_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
7987 #define alc883_is_input_pin(nid) alc880_is_input_pin(nid)
7988 #define ALC883_PIN_CD_NID ALC880_PIN_CD_NID
7990 static void alc883_auto_init_analog_input(struct hda_codec *codec)
7992 struct alc_spec *spec = codec->spec;
7993 int i;
7995 for (i = 0; i < AUTO_PIN_LAST; i++) {
7996 hda_nid_t nid = spec->autocfg.input_pins[i];
7997 if (alc883_is_input_pin(nid)) {
7998 snd_hda_codec_write(codec, nid, 0,
7999 AC_VERB_SET_PIN_WIDGET_CONTROL,
8000 (i <= AUTO_PIN_FRONT_MIC ?
8001 PIN_VREF80 : PIN_IN));
8002 if (nid != ALC883_PIN_CD_NID)
8003 snd_hda_codec_write(codec, nid, 0,
8004 AC_VERB_SET_AMP_GAIN_MUTE,
8005 AMP_OUT_MUTE);
8010 /* almost identical with ALC880 parser... */
8011 static int alc883_parse_auto_config(struct hda_codec *codec)
8013 struct alc_spec *spec = codec->spec;
8014 int err = alc880_parse_auto_config(codec);
8016 if (err < 0)
8017 return err;
8018 else if (!err)
8019 return 0; /* no config found */
8021 err = alc_auto_add_mic_boost(codec);
8022 if (err < 0)
8023 return err;
8025 /* hack - override the init verbs */
8026 spec->init_verbs[0] = alc883_auto_init_verbs;
8027 spec->mixers[spec->num_mixers] = alc883_capture_mixer;
8028 spec->num_mixers++;
8030 return 1; /* config found */
8033 /* additional initialization for auto-configuration model */
8034 static void alc883_auto_init(struct hda_codec *codec)
8036 alc883_auto_init_multi_out(codec);
8037 alc883_auto_init_hp_out(codec);
8038 alc883_auto_init_analog_input(codec);
8041 static int patch_alc883(struct hda_codec *codec)
8043 struct alc_spec *spec;
8044 int err, board_config;
8046 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
8047 if (spec == NULL)
8048 return -ENOMEM;
8050 codec->spec = spec;
8052 board_config = snd_hda_check_board_config(codec, ALC883_MODEL_LAST,
8053 alc883_models,
8054 alc883_cfg_tbl);
8055 if (board_config < 0) {
8056 printk(KERN_INFO "hda_codec: Unknown model for ALC883, "
8057 "trying auto-probe from BIOS...\n");
8058 board_config = ALC883_AUTO;
8061 if (board_config == ALC883_AUTO) {
8062 /* automatic parse from the BIOS config */
8063 err = alc883_parse_auto_config(codec);
8064 if (err < 0) {
8065 alc_free(codec);
8066 return err;
8067 } else if (!err) {
8068 printk(KERN_INFO
8069 "hda_codec: Cannot set up configuration "
8070 "from BIOS. Using base mode...\n");
8071 board_config = ALC883_3ST_2ch_DIG;
8075 if (board_config != ALC883_AUTO)
8076 setup_preset(spec, &alc883_presets[board_config]);
8078 spec->stream_name_analog = "ALC883 Analog";
8079 spec->stream_analog_playback = &alc883_pcm_analog_playback;
8080 spec->stream_analog_capture = &alc883_pcm_analog_capture;
8081 spec->stream_analog_alt_capture = &alc883_pcm_analog_alt_capture;
8083 spec->stream_name_digital = "ALC883 Digital";
8084 spec->stream_digital_playback = &alc883_pcm_digital_playback;
8085 spec->stream_digital_capture = &alc883_pcm_digital_capture;
8087 if (!spec->adc_nids && spec->input_mux) {
8088 spec->adc_nids = alc883_adc_nids;
8089 spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids);
8092 spec->vmaster_nid = 0x0c;
8094 codec->patch_ops = alc_patch_ops;
8095 if (board_config == ALC883_AUTO)
8096 spec->init_hook = alc883_auto_init;
8097 #ifdef CONFIG_SND_HDA_POWER_SAVE
8098 if (!spec->loopback.amplist)
8099 spec->loopback.amplist = alc883_loopbacks;
8100 #endif
8102 return 0;
8106 * ALC262 support
8109 #define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
8110 #define ALC262_DIGIN_NID ALC880_DIGIN_NID
8112 #define alc262_dac_nids alc260_dac_nids
8113 #define alc262_adc_nids alc882_adc_nids
8114 #define alc262_adc_nids_alt alc882_adc_nids_alt
8116 #define alc262_modes alc260_modes
8117 #define alc262_capture_source alc882_capture_source
8119 static struct snd_kcontrol_new alc262_base_mixer[] = {
8120 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8121 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8122 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8123 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8124 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8125 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8126 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8127 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8128 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8129 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
8130 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
8131 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
8132 /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
8133 <<<<<<< HEAD:sound/pci/hda/patch_realtek.c
8134 HDA_CODEC_MUTE("PC Beelp Playback Switch", 0x0b, 0x05, HDA_INPUT), */
8135 =======
8136 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT), */
8137 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a:sound/pci/hda/patch_realtek.c
8138 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
8139 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8140 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8141 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
8142 { } /* end */
8145 static struct snd_kcontrol_new alc262_hippo1_mixer[] = {
8146 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8147 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8148 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8149 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8150 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8151 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8152 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8153 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8154 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8155 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
8156 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
8157 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
8158 /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
8159 <<<<<<< HEAD:sound/pci/hda/patch_realtek.c
8160 HDA_CODEC_MUTE("PC Beelp Playback Switch", 0x0b, 0x05, HDA_INPUT), */
8161 =======
8162 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT), */
8163 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a:sound/pci/hda/patch_realtek.c
8164 /*HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),*/
8165 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8166 { } /* end */
8169 /* update HP, line and mono-out pins according to the master switch */
8170 static void alc262_hp_master_update(struct hda_codec *codec)
8172 struct alc_spec *spec = codec->spec;
8173 int val = spec->master_sw;
8175 /* HP & line-out */
8176 snd_hda_codec_write_cache(codec, 0x1b, 0,
8177 AC_VERB_SET_PIN_WIDGET_CONTROL,
8178 val ? PIN_HP : 0);
8179 snd_hda_codec_write_cache(codec, 0x15, 0,
8180 AC_VERB_SET_PIN_WIDGET_CONTROL,
8181 val ? PIN_HP : 0);
8182 /* mono (speaker) depending on the HP jack sense */
8183 val = val && !spec->jack_present;
8184 snd_hda_codec_write_cache(codec, 0x16, 0,
8185 AC_VERB_SET_PIN_WIDGET_CONTROL,
8186 val ? PIN_OUT : 0);
8189 static void alc262_hp_bpc_automute(struct hda_codec *codec)
8191 struct alc_spec *spec = codec->spec;
8192 unsigned int presence;
8193 presence = snd_hda_codec_read(codec, 0x1b, 0,
8194 AC_VERB_GET_PIN_SENSE, 0);
8195 spec->jack_present = !!(presence & AC_PINSENSE_PRESENCE);
8196 alc262_hp_master_update(codec);
8199 static void alc262_hp_bpc_unsol_event(struct hda_codec *codec, unsigned int res)
8201 if ((res >> 26) != ALC880_HP_EVENT)
8202 return;
8203 alc262_hp_bpc_automute(codec);
8206 static void alc262_hp_wildwest_automute(struct hda_codec *codec)
8208 struct alc_spec *spec = codec->spec;
8209 unsigned int presence;
8210 presence = snd_hda_codec_read(codec, 0x15, 0,
8211 AC_VERB_GET_PIN_SENSE, 0);
8212 spec->jack_present = !!(presence & AC_PINSENSE_PRESENCE);
8213 alc262_hp_master_update(codec);
8216 static void alc262_hp_wildwest_unsol_event(struct hda_codec *codec,
8217 unsigned int res)
8219 if ((res >> 26) != ALC880_HP_EVENT)
8220 return;
8221 alc262_hp_wildwest_automute(codec);
8224 static int alc262_hp_master_sw_get(struct snd_kcontrol *kcontrol,
8225 struct snd_ctl_elem_value *ucontrol)
8227 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
8228 struct alc_spec *spec = codec->spec;
8229 *ucontrol->value.integer.value = spec->master_sw;
8230 return 0;
8233 static int alc262_hp_master_sw_put(struct snd_kcontrol *kcontrol,
8234 struct snd_ctl_elem_value *ucontrol)
8236 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
8237 struct alc_spec *spec = codec->spec;
8238 int val = !!*ucontrol->value.integer.value;
8240 if (val == spec->master_sw)
8241 return 0;
8242 spec->master_sw = val;
8243 alc262_hp_master_update(codec);
8244 return 1;
8247 static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
8249 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8250 .name = "Master Playback Switch",
8251 .info = snd_ctl_boolean_mono_info,
8252 .get = alc262_hp_master_sw_get,
8253 .put = alc262_hp_master_sw_put,
8255 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8256 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8257 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8258 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
8259 HDA_OUTPUT),
8260 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
8261 HDA_OUTPUT),
8262 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8263 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8264 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8265 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
8266 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
8267 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
8268 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8269 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8270 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8271 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8272 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
8273 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
8274 HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
8275 HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
8276 { } /* end */
8279 static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = {
8281 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8282 .name = "Master Playback Switch",
8283 .info = snd_ctl_boolean_mono_info,
8284 .get = alc262_hp_master_sw_get,
8285 .put = alc262_hp_master_sw_put,
8287 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8288 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8289 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8290 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8291 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
8292 HDA_OUTPUT),
8293 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
8294 HDA_OUTPUT),
8295 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x02, HDA_INPUT),
8296 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x02, HDA_INPUT),
8297 HDA_CODEC_VOLUME("Front Mic Boost", 0x1a, 0, HDA_INPUT),
8298 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
8299 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
8300 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8301 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8302 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
8303 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
8304 { } /* end */
8307 static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = {
8308 HDA_CODEC_VOLUME("Rear Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8309 HDA_CODEC_MUTE("Rear Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8310 HDA_CODEC_VOLUME("Rear Mic Boost", 0x18, 0, HDA_INPUT),
8311 { } /* end */
8314 /* mute/unmute internal speaker according to the hp jack and mute state */
8315 static void alc262_hp_t5735_automute(struct hda_codec *codec, int force)
8317 struct alc_spec *spec = codec->spec;
8319 if (force || !spec->sense_updated) {
8320 unsigned int present;
8321 present = snd_hda_codec_read(codec, 0x15, 0,
8322 AC_VERB_GET_PIN_SENSE, 0);
8323 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
8324 spec->sense_updated = 1;
8326 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0, HDA_AMP_MUTE,
8327 spec->jack_present ? HDA_AMP_MUTE : 0);
8330 static void alc262_hp_t5735_unsol_event(struct hda_codec *codec,
8331 unsigned int res)
8333 if ((res >> 26) != ALC880_HP_EVENT)
8334 return;
8335 alc262_hp_t5735_automute(codec, 1);
8338 static void alc262_hp_t5735_init_hook(struct hda_codec *codec)
8340 alc262_hp_t5735_automute(codec, 1);
8343 static struct snd_kcontrol_new alc262_hp_t5735_mixer[] = {
8344 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8345 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8346 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8347 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8348 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8349 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8350 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8351 { } /* end */
8354 static struct hda_verb alc262_hp_t5735_verbs[] = {
8355 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8356 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8358 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8362 static struct snd_kcontrol_new alc262_hp_rp5700_mixer[] = {
8363 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8364 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8365 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
8366 HDA_CODEC_MUTE("Speaker Playback Switch", 0x16, 0x0, HDA_OUTPUT),
8367 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
8368 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
8369 { } /* end */
8372 static struct hda_verb alc262_hp_rp5700_verbs[] = {
8373 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8374 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8375 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8376 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8377 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
8378 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
8379 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
8380 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
8381 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
8382 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
8386 static struct hda_input_mux alc262_hp_rp5700_capture_source = {
8387 .num_items = 1,
8388 .items = {
8389 { "Line", 0x1 },
8393 /* bind hp and internal speaker mute (with plug check) */
8394 static int alc262_sony_master_sw_put(struct snd_kcontrol *kcontrol,
8395 struct snd_ctl_elem_value *ucontrol)
8397 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
8398 long *valp = ucontrol->value.integer.value;
8399 int change;
8401 /* change hp mute */
8402 change = snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
8403 HDA_AMP_MUTE,
8404 valp[0] ? 0 : HDA_AMP_MUTE);
8405 change |= snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
8406 HDA_AMP_MUTE,
8407 valp[1] ? 0 : HDA_AMP_MUTE);
8408 if (change) {
8409 /* change speaker according to HP jack state */
8410 struct alc_spec *spec = codec->spec;
8411 unsigned int mute;
8412 if (spec->jack_present)
8413 mute = HDA_AMP_MUTE;
8414 else
8415 mute = snd_hda_codec_amp_read(codec, 0x15, 0,
8416 HDA_OUTPUT, 0);
8417 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8418 HDA_AMP_MUTE, mute);
8420 return change;
8423 static struct snd_kcontrol_new alc262_sony_mixer[] = {
8424 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8426 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8427 .name = "Master Playback Switch",
8428 .info = snd_hda_mixer_amp_switch_info,
8429 .get = snd_hda_mixer_amp_switch_get,
8430 .put = alc262_sony_master_sw_put,
8431 .private_value = HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
8433 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8434 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8435 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
8436 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
8437 { } /* end */
8440 static struct snd_kcontrol_new alc262_benq_t31_mixer[] = {
8441 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8442 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8443 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8444 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8445 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8446 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
8447 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
8448 { } /* end */
8451 #define alc262_capture_mixer alc882_capture_mixer
8452 #define alc262_capture_alt_mixer alc882_capture_alt_mixer
8455 * generic initialization of ADC, input mixers and output mixers
8457 static struct hda_verb alc262_init_verbs[] = {
8459 * Unmute ADC0-2 and set the default input to mic-in
8461 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
8462 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8463 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8464 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8465 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8466 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8468 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
8469 * mixer widget
8470 * Note: PASD motherboards uses the Line In 2 as the input for
8471 * front panel mic (mic 2)
8473 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
8474 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8475 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8476 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8477 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8478 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8481 * Set up output mixers (0x0c - 0x0e)
8483 /* set vol=0 to output mixers */
8484 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8485 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8486 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8487 /* set up input amps for analog loopback */
8488 /* Amp Indices: DAC = 0, mixer = 1 */
8489 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8490 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8491 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8492 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8493 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8494 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8496 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
8497 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
8498 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
8499 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
8500 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
8501 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
8503 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
8504 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
8505 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
8506 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
8507 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
8509 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8510 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
8512 /* FIXME: use matrix-type input source selection */
8513 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
8514 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
8515 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8516 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
8517 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
8518 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
8519 /* Input mixer2 */
8520 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8521 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
8522 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
8523 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
8524 /* Input mixer3 */
8525 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8526 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
8527 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
8528 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
8533 static struct hda_verb alc262_hippo_unsol_verbs[] = {
8534 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
8535 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8539 static struct hda_verb alc262_hippo1_unsol_verbs[] = {
8540 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
8541 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
8542 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
8544 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
8545 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8549 static struct hda_verb alc262_sony_unsol_verbs[] = {
8550 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
8551 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8552 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, // Front Mic
8554 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
8555 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8558 /* mute/unmute internal speaker according to the hp jack and mute state */
8559 static void alc262_hippo_automute(struct hda_codec *codec)
8561 struct alc_spec *spec = codec->spec;
8562 unsigned int mute;
8563 unsigned int present;
8565 /* need to execute and sync at first */
8566 snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
8567 present = snd_hda_codec_read(codec, 0x15, 0,
8568 AC_VERB_GET_PIN_SENSE, 0);
8569 spec->jack_present = (present & 0x80000000) != 0;
8570 if (spec->jack_present) {
8571 /* mute internal speaker */
8572 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8573 HDA_AMP_MUTE, HDA_AMP_MUTE);
8574 } else {
8575 /* unmute internal speaker if necessary */
8576 mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0);
8577 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8578 HDA_AMP_MUTE, mute);
8582 /* unsolicited event for HP jack sensing */
8583 static void alc262_hippo_unsol_event(struct hda_codec *codec,
8584 unsigned int res)
8586 if ((res >> 26) != ALC880_HP_EVENT)
8587 return;
8588 alc262_hippo_automute(codec);
8591 static void alc262_hippo1_automute(struct hda_codec *codec)
8593 unsigned int mute;
8594 unsigned int present;
8596 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
8597 present = snd_hda_codec_read(codec, 0x1b, 0,
8598 AC_VERB_GET_PIN_SENSE, 0);
8599 present = (present & 0x80000000) != 0;
8600 if (present) {
8601 /* mute internal speaker */
8602 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8603 HDA_AMP_MUTE, HDA_AMP_MUTE);
8604 } else {
8605 /* unmute internal speaker if necessary */
8606 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
8607 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8608 HDA_AMP_MUTE, mute);
8612 /* unsolicited event for HP jack sensing */
8613 static void alc262_hippo1_unsol_event(struct hda_codec *codec,
8614 unsigned int res)
8616 if ((res >> 26) != ALC880_HP_EVENT)
8617 return;
8618 alc262_hippo1_automute(codec);
8622 * fujitsu model
8623 * 0x14 = headphone/spdif-out, 0x15 = internal speaker
8626 #define ALC_HP_EVENT 0x37
8628 static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
8629 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
8630 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8634 static struct hda_input_mux alc262_fujitsu_capture_source = {
8635 .num_items = 3,
8636 .items = {
8637 { "Mic", 0x0 },
8638 { "Int Mic", 0x1 },
8639 { "CD", 0x4 },
8643 static struct hda_input_mux alc262_HP_capture_source = {
8644 .num_items = 5,
8645 .items = {
8646 { "Mic", 0x0 },
8647 { "Front Mic", 0x1 },
8648 { "Line", 0x2 },
8649 { "CD", 0x4 },
8650 { "AUX IN", 0x6 },
8654 static struct hda_input_mux alc262_HP_D7000_capture_source = {
8655 .num_items = 4,
8656 .items = {
8657 { "Mic", 0x0 },
8658 { "Front Mic", 0x2 },
8659 { "Line", 0x1 },
8660 { "CD", 0x4 },
8664 /* mute/unmute internal speaker according to the hp jack and mute state */
8665 static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
8667 struct alc_spec *spec = codec->spec;
8668 unsigned int mute;
8670 if (force || !spec->sense_updated) {
8671 unsigned int present;
8672 /* need to execute and sync at first */
8673 snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
8674 present = snd_hda_codec_read(codec, 0x14, 0,
8675 AC_VERB_GET_PIN_SENSE, 0);
8676 spec->jack_present = (present & 0x80000000) != 0;
8677 spec->sense_updated = 1;
8679 if (spec->jack_present) {
8680 /* mute internal speaker */
8681 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8682 HDA_AMP_MUTE, HDA_AMP_MUTE);
8683 } else {
8684 /* unmute internal speaker if necessary */
8685 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
8686 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8687 HDA_AMP_MUTE, mute);
8691 /* unsolicited event for HP jack sensing */
8692 static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
8693 unsigned int res)
8695 if ((res >> 26) != ALC_HP_EVENT)
8696 return;
8697 alc262_fujitsu_automute(codec, 1);
8700 /* bind volumes of both NID 0x0c and 0x0d */
8701 static struct hda_bind_ctls alc262_fujitsu_bind_master_vol = {
8702 .ops = &snd_hda_bind_vol,
8703 .values = {
8704 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
8705 HDA_COMPOSE_AMP_VAL(0x0d, 3, 0, HDA_OUTPUT),
8710 /* bind hp and internal speaker mute (with plug check) */
8711 static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
8712 struct snd_ctl_elem_value *ucontrol)
8714 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
8715 long *valp = ucontrol->value.integer.value;
8716 int change;
8718 change = snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
8719 HDA_AMP_MUTE,
8720 valp[0] ? 0 : HDA_AMP_MUTE);
8721 change |= snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
8722 HDA_AMP_MUTE,
8723 valp[1] ? 0 : HDA_AMP_MUTE);
8724 if (change)
8725 alc262_fujitsu_automute(codec, 0);
8726 return change;
8729 static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
8730 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
8732 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8733 .name = "Master Playback Switch",
8734 .info = snd_hda_mixer_amp_switch_info,
8735 .get = snd_hda_mixer_amp_switch_get,
8736 .put = alc262_fujitsu_master_sw_put,
8737 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
8739 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8740 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8741 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8742 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8743 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8744 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
8745 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8746 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
8747 { } /* end */
8750 /* additional init verbs for Benq laptops */
8751 static struct hda_verb alc262_EAPD_verbs[] = {
8752 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
8753 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
8757 static struct hda_verb alc262_benq_t31_EAPD_verbs[] = {
8758 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8759 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
8761 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
8762 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
8766 /* Samsung Q1 Ultra Vista model setup */
8767 static struct snd_kcontrol_new alc262_ultra_mixer[] = {
8768 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8769 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8770 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8771 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
8772 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
8773 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
8774 { } /* end */
8777 static struct hda_verb alc262_ultra_verbs[] = {
8778 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
8779 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8780 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
8781 /* Mic is on Node 0x19 */
8782 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
8783 {0x22, AC_VERB_SET_CONNECT_SEL, 0x01},
8784 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
8785 {0x23, AC_VERB_SET_CONNECT_SEL, 0x01},
8786 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
8787 {0x24, AC_VERB_SET_CONNECT_SEL, 0x01},
8788 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
8792 static struct hda_input_mux alc262_ultra_capture_source = {
8793 .num_items = 1,
8794 .items = {
8795 { "Mic", 0x1 },
8799 /* mute/unmute internal speaker according to the hp jack and mute state */
8800 static void alc262_ultra_automute(struct hda_codec *codec)
8802 struct alc_spec *spec = codec->spec;
8803 unsigned int mute;
8804 unsigned int present;
8806 /* need to execute and sync at first */
8807 snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
8808 present = snd_hda_codec_read(codec, 0x15, 0,
8809 AC_VERB_GET_PIN_SENSE, 0);
8810 spec->jack_present = (present & 0x80000000) != 0;
8811 if (spec->jack_present) {
8812 /* mute internal speaker */
8813 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8814 HDA_AMP_MUTE, HDA_AMP_MUTE);
8815 } else {
8816 /* unmute internal speaker if necessary */
8817 mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0);
8818 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8819 HDA_AMP_MUTE, mute);
8823 /* unsolicited event for HP jack sensing */
8824 static void alc262_ultra_unsol_event(struct hda_codec *codec,
8825 unsigned int res)
8827 if ((res >> 26) != ALC880_HP_EVENT)
8828 return;
8829 alc262_ultra_automute(codec);
8832 /* add playback controls from the parsed DAC table */
8833 static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec,
8834 const struct auto_pin_cfg *cfg)
8836 hda_nid_t nid;
8837 int err;
8839 spec->multiout.num_dacs = 1; /* only use one dac */
8840 spec->multiout.dac_nids = spec->private_dac_nids;
8841 spec->multiout.dac_nids[0] = 2;
8843 nid = cfg->line_out_pins[0];
8844 if (nid) {
8845 err = add_control(spec, ALC_CTL_WIDGET_VOL,
8846 "Front Playback Volume",
8847 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT));
8848 if (err < 0)
8849 return err;
8850 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
8851 "Front Playback Switch",
8852 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
8853 if (err < 0)
8854 return err;
8857 nid = cfg->speaker_pins[0];
8858 if (nid) {
8859 if (nid == 0x16) {
8860 err = add_control(spec, ALC_CTL_WIDGET_VOL,
8861 "Speaker Playback Volume",
8862 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
8863 HDA_OUTPUT));
8864 if (err < 0)
8865 return err;
8866 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
8867 "Speaker Playback Switch",
8868 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
8869 HDA_OUTPUT));
8870 if (err < 0)
8871 return err;
8872 } else {
8873 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
8874 "Speaker Playback Switch",
8875 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
8876 HDA_OUTPUT));
8877 if (err < 0)
8878 return err;
8881 nid = cfg->hp_pins[0];
8882 if (nid) {
8883 /* spec->multiout.hp_nid = 2; */
8884 if (nid == 0x16) {
8885 err = add_control(spec, ALC_CTL_WIDGET_VOL,
8886 "Headphone Playback Volume",
8887 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
8888 HDA_OUTPUT));
8889 if (err < 0)
8890 return err;
8891 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
8892 "Headphone Playback Switch",
8893 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
8894 HDA_OUTPUT));
8895 if (err < 0)
8896 return err;
8897 } else {
8898 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
8899 "Headphone Playback Switch",
8900 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
8901 HDA_OUTPUT));
8902 if (err < 0)
8903 return err;
8906 return 0;
8909 /* identical with ALC880 */
8910 #define alc262_auto_create_analog_input_ctls \
8911 alc880_auto_create_analog_input_ctls
8914 * generic initialization of ADC, input mixers and output mixers
8916 static struct hda_verb alc262_volume_init_verbs[] = {
8918 * Unmute ADC0-2 and set the default input to mic-in
8920 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
8921 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8922 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8923 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8924 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8925 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8927 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
8928 * mixer widget
8929 * Note: PASD motherboards uses the Line In 2 as the input for
8930 * front panel mic (mic 2)
8932 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
8933 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8934 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8935 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8936 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8937 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8940 * Set up output mixers (0x0c - 0x0f)
8942 /* set vol=0 to output mixers */
8943 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8944 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8945 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8947 /* set up input amps for analog loopback */
8948 /* Amp Indices: DAC = 0, mixer = 1 */
8949 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8950 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8951 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8952 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8953 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8954 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8956 /* FIXME: use matrix-type input source selection */
8957 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
8958 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
8959 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8960 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
8961 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
8962 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
8963 /* Input mixer2 */
8964 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8965 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
8966 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
8967 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
8968 /* Input mixer3 */
8969 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8970 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
8971 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
8972 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
8977 static struct hda_verb alc262_HP_BPC_init_verbs[] = {
8979 * Unmute ADC0-2 and set the default input to mic-in
8981 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
8982 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8983 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8984 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8985 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8986 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8988 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
8989 * mixer widget
8990 * Note: PASD motherboards uses the Line In 2 as the input for
8991 * front panel mic (mic 2)
8993 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
8994 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8995 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8996 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8997 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8998 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8999 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
9000 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
9003 * Set up output mixers (0x0c - 0x0e)
9005 /* set vol=0 to output mixers */
9006 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9007 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9008 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9010 /* set up input amps for analog loopback */
9011 /* Amp Indices: DAC = 0, mixer = 1 */
9012 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9013 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9014 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9015 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9016 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9017 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9019 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9020 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9021 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9023 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
9024 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
9026 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
9027 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9029 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9030 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
9031 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
9032 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9033 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9035 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
9036 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
9037 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
9038 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
9039 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
9040 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
9043 /* FIXME: use matrix-type input source selection */
9044 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
9045 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
9046 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9047 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
9048 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
9049 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
9050 /* Input mixer2 */
9051 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9052 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
9053 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
9054 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
9055 /* Input mixer3 */
9056 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9057 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
9058 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
9059 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
9061 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9066 static struct hda_verb alc262_HP_BPC_WildWest_init_verbs[] = {
9068 * Unmute ADC0-2 and set the default input to mic-in
9070 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
9071 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9072 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
9073 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9074 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
9075 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9077 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
9078 * mixer widget
9079 * Note: PASD motherboards uses the Line In 2 as the input for front
9080 * panel mic (mic 2)
9082 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
9083 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9084 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9085 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
9086 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
9087 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
9088 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
9089 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
9090 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
9092 * Set up output mixers (0x0c - 0x0e)
9094 /* set vol=0 to output mixers */
9095 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9096 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9097 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9099 /* set up input amps for analog loopback */
9100 /* Amp Indices: DAC = 0, mixer = 1 */
9101 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9102 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9103 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9104 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9105 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9106 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9109 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP */
9110 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Mono */
9111 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* rear MIC */
9112 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* Line in */
9113 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
9114 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Line out */
9115 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD in */
9117 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
9118 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
9120 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
9121 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
9123 /* {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, */
9124 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
9125 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
9126 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
9127 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
9128 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
9130 /* FIXME: use matrix-type input source selection */
9131 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
9132 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
9133 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, /*rear MIC*/
9134 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, /*Line in*/
9135 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, /*F MIC*/
9136 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, /*Front*/
9137 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, /*CD*/
9138 /* {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
9139 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, /*HP*/
9140 /* Input mixer2 */
9141 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9142 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
9143 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
9144 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
9145 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
9146 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
9147 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
9148 /* Input mixer3 */
9149 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9150 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
9151 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
9152 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
9153 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
9154 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
9155 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
9157 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9162 #ifdef CONFIG_SND_HDA_POWER_SAVE
9163 #define alc262_loopbacks alc880_loopbacks
9164 #endif
9166 /* pcm configuration: identiacal with ALC880 */
9167 #define alc262_pcm_analog_playback alc880_pcm_analog_playback
9168 #define alc262_pcm_analog_capture alc880_pcm_analog_capture
9169 #define alc262_pcm_digital_playback alc880_pcm_digital_playback
9170 #define alc262_pcm_digital_capture alc880_pcm_digital_capture
9173 * BIOS auto configuration
9175 static int alc262_parse_auto_config(struct hda_codec *codec)
9177 struct alc_spec *spec = codec->spec;
9178 int err;
9179 static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
9181 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
9182 alc262_ignore);
9183 if (err < 0)
9184 return err;
9185 if (!spec->autocfg.line_outs)
9186 return 0; /* can't find valid BIOS pin config */
9187 err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg);
9188 if (err < 0)
9189 return err;
9190 err = alc262_auto_create_analog_input_ctls(spec, &spec->autocfg);
9191 if (err < 0)
9192 return err;
9194 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
9196 if (spec->autocfg.dig_out_pin)
9197 spec->multiout.dig_out_nid = ALC262_DIGOUT_NID;
9198 if (spec->autocfg.dig_in_pin)
9199 spec->dig_in_nid = ALC262_DIGIN_NID;
9201 if (spec->kctl_alloc)
9202 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
9204 spec->init_verbs[spec->num_init_verbs++] = alc262_volume_init_verbs;
9205 spec->num_mux_defs = 1;
9206 spec->input_mux = &spec->private_imux;
9208 err = alc_auto_add_mic_boost(codec);
9209 if (err < 0)
9210 return err;
9212 return 1;
9215 #define alc262_auto_init_multi_out alc882_auto_init_multi_out
9216 #define alc262_auto_init_hp_out alc882_auto_init_hp_out
9217 #define alc262_auto_init_analog_input alc882_auto_init_analog_input
9220 /* init callback for auto-configuration model -- overriding the default init */
9221 static void alc262_auto_init(struct hda_codec *codec)
9223 alc262_auto_init_multi_out(codec);
9224 alc262_auto_init_hp_out(codec);
9225 alc262_auto_init_analog_input(codec);
9229 * configuration and preset
9231 static const char *alc262_models[ALC262_MODEL_LAST] = {
9232 [ALC262_BASIC] = "basic",
9233 [ALC262_HIPPO] = "hippo",
9234 [ALC262_HIPPO_1] = "hippo_1",
9235 [ALC262_FUJITSU] = "fujitsu",
9236 [ALC262_HP_BPC] = "hp-bpc",
9237 [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000",
9238 [ALC262_HP_TC_T5735] = "hp-tc-t5735",
9239 [ALC262_HP_RP5700] = "hp-rp5700",
9240 [ALC262_BENQ_ED8] = "benq",
9241 [ALC262_BENQ_T31] = "benq-t31",
9242 [ALC262_SONY_ASSAMD] = "sony-assamd",
9243 [ALC262_ULTRA] = "ultra",
9244 [ALC262_AUTO] = "auto",
9247 static struct snd_pci_quirk alc262_cfg_tbl[] = {
9248 SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO),
9249 SND_PCI_QUIRK(0x103c, 0x12fe, "HP xw9400", ALC262_HP_BPC),
9250 SND_PCI_QUIRK(0x103c, 0x12ff, "HP xw4550", ALC262_HP_BPC),
9251 SND_PCI_QUIRK(0x103c, 0x1306, "HP xw8600", ALC262_HP_BPC),
9252 SND_PCI_QUIRK(0x103c, 0x1307, "HP xw6600", ALC262_HP_BPC),
9253 SND_PCI_QUIRK(0x103c, 0x1308, "HP xw4600", ALC262_HP_BPC),
9254 SND_PCI_QUIRK(0x103c, 0x1309, "HP xw4*00", ALC262_HP_BPC),
9255 SND_PCI_QUIRK(0x103c, 0x130a, "HP xw6*00", ALC262_HP_BPC),
9256 SND_PCI_QUIRK(0x103c, 0x130b, "HP xw8*00", ALC262_HP_BPC),
9257 SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL),
9258 SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF),
9259 SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL),
9260 SND_PCI_QUIRK(0x103c, 0x2803, "HP D7000", ALC262_HP_BPC_D7000_WF),
9261 SND_PCI_QUIRK(0x103c, 0x2804, "HP D7000", ALC262_HP_BPC_D7000_WL),
9262 SND_PCI_QUIRK(0x103c, 0x2805, "HP D7000", ALC262_HP_BPC_D7000_WF),
9263 SND_PCI_QUIRK(0x103c, 0x2806, "HP D7000", ALC262_HP_BPC_D7000_WL),
9264 SND_PCI_QUIRK(0x103c, 0x2807, "HP D7000", ALC262_HP_BPC_D7000_WF),
9265 SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC),
9266 SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC),
9267 SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC),
9268 SND_PCI_QUIRK(0x103c, 0x302f, "HP Thin Client T5735",
9269 ALC262_HP_TC_T5735),
9270 SND_PCI_QUIRK(0x103c, 0x2817, "HP RP5700", ALC262_HP_RP5700),
9271 SND_PCI_QUIRK(0x104d, 0x1f00, "Sony ASSAMD", ALC262_SONY_ASSAMD),
9272 SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO),
9273 SND_PCI_QUIRK(0x104d, 0x820f, "Sony ASSAMD", ALC262_SONY_ASSAMD),
9274 SND_PCI_QUIRK(0x104d, 0x900e, "Sony ASSAMD", ALC262_SONY_ASSAMD),
9275 SND_PCI_QUIRK(0x104d, 0x9015, "Sony 0x9015", ALC262_SONY_ASSAMD),
9276 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
9277 <<<<<<< HEAD:sound/pci/hda/patch_realtek.c
9278 =======
9279 SND_PCI_QUIRK(0x10cf, 0x142d, "Fujitsu Lifebook E8410", ALC262_FUJITSU),
9280 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a:sound/pci/hda/patch_realtek.c
9281 SND_PCI_QUIRK(0x144d, 0xc032, "Samsung Q1 Ultra", ALC262_ULTRA),
9282 SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
9283 SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_BENQ_T31),
9284 SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1),
9288 static struct alc_config_preset alc262_presets[] = {
9289 [ALC262_BASIC] = {
9290 .mixers = { alc262_base_mixer },
9291 .init_verbs = { alc262_init_verbs },
9292 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9293 .dac_nids = alc262_dac_nids,
9294 .hp_nid = 0x03,
9295 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9296 .channel_mode = alc262_modes,
9297 .input_mux = &alc262_capture_source,
9299 [ALC262_HIPPO] = {
9300 .mixers = { alc262_base_mixer },
9301 .init_verbs = { alc262_init_verbs, alc262_hippo_unsol_verbs},
9302 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9303 .dac_nids = alc262_dac_nids,
9304 .hp_nid = 0x03,
9305 .dig_out_nid = ALC262_DIGOUT_NID,
9306 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9307 .channel_mode = alc262_modes,
9308 .input_mux = &alc262_capture_source,
9309 .unsol_event = alc262_hippo_unsol_event,
9310 .init_hook = alc262_hippo_automute,
9312 [ALC262_HIPPO_1] = {
9313 .mixers = { alc262_hippo1_mixer },
9314 .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs},
9315 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9316 .dac_nids = alc262_dac_nids,
9317 .hp_nid = 0x02,
9318 .dig_out_nid = ALC262_DIGOUT_NID,
9319 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9320 .channel_mode = alc262_modes,
9321 .input_mux = &alc262_capture_source,
9322 .unsol_event = alc262_hippo1_unsol_event,
9323 .init_hook = alc262_hippo1_automute,
9325 [ALC262_FUJITSU] = {
9326 .mixers = { alc262_fujitsu_mixer },
9327 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
9328 alc262_fujitsu_unsol_verbs },
9329 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9330 .dac_nids = alc262_dac_nids,
9331 .hp_nid = 0x03,
9332 .dig_out_nid = ALC262_DIGOUT_NID,
9333 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9334 .channel_mode = alc262_modes,
9335 .input_mux = &alc262_fujitsu_capture_source,
9336 .unsol_event = alc262_fujitsu_unsol_event,
9338 [ALC262_HP_BPC] = {
9339 .mixers = { alc262_HP_BPC_mixer },
9340 .init_verbs = { alc262_HP_BPC_init_verbs },
9341 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9342 .dac_nids = alc262_dac_nids,
9343 .hp_nid = 0x03,
9344 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9345 .channel_mode = alc262_modes,
9346 .input_mux = &alc262_HP_capture_source,
9347 .unsol_event = alc262_hp_bpc_unsol_event,
9348 .init_hook = alc262_hp_bpc_automute,
9350 [ALC262_HP_BPC_D7000_WF] = {
9351 .mixers = { alc262_HP_BPC_WildWest_mixer },
9352 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
9353 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9354 .dac_nids = alc262_dac_nids,
9355 .hp_nid = 0x03,
9356 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9357 .channel_mode = alc262_modes,
9358 .input_mux = &alc262_HP_D7000_capture_source,
9359 .unsol_event = alc262_hp_wildwest_unsol_event,
9360 .init_hook = alc262_hp_wildwest_automute,
9362 [ALC262_HP_BPC_D7000_WL] = {
9363 .mixers = { alc262_HP_BPC_WildWest_mixer,
9364 alc262_HP_BPC_WildWest_option_mixer },
9365 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
9366 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9367 .dac_nids = alc262_dac_nids,
9368 .hp_nid = 0x03,
9369 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9370 .channel_mode = alc262_modes,
9371 .input_mux = &alc262_HP_D7000_capture_source,
9372 .unsol_event = alc262_hp_wildwest_unsol_event,
9373 .init_hook = alc262_hp_wildwest_automute,
9375 [ALC262_HP_TC_T5735] = {
9376 .mixers = { alc262_hp_t5735_mixer },
9377 .init_verbs = { alc262_init_verbs, alc262_hp_t5735_verbs },
9378 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9379 .dac_nids = alc262_dac_nids,
9380 .hp_nid = 0x03,
9381 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9382 .channel_mode = alc262_modes,
9383 .input_mux = &alc262_capture_source,
9384 .unsol_event = alc262_hp_t5735_unsol_event,
9385 .init_hook = alc262_hp_t5735_init_hook,
9387 [ALC262_HP_RP5700] = {
9388 .mixers = { alc262_hp_rp5700_mixer },
9389 .init_verbs = { alc262_init_verbs, alc262_hp_rp5700_verbs },
9390 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9391 .dac_nids = alc262_dac_nids,
9392 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9393 .channel_mode = alc262_modes,
9394 .input_mux = &alc262_hp_rp5700_capture_source,
9396 [ALC262_BENQ_ED8] = {
9397 .mixers = { alc262_base_mixer },
9398 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
9399 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9400 .dac_nids = alc262_dac_nids,
9401 .hp_nid = 0x03,
9402 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9403 .channel_mode = alc262_modes,
9404 .input_mux = &alc262_capture_source,
9406 [ALC262_SONY_ASSAMD] = {
9407 .mixers = { alc262_sony_mixer },
9408 .init_verbs = { alc262_init_verbs, alc262_sony_unsol_verbs},
9409 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9410 .dac_nids = alc262_dac_nids,
9411 .hp_nid = 0x02,
9412 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9413 .channel_mode = alc262_modes,
9414 .input_mux = &alc262_capture_source,
9415 .unsol_event = alc262_hippo_unsol_event,
9416 .init_hook = alc262_hippo_automute,
9418 [ALC262_BENQ_T31] = {
9419 .mixers = { alc262_benq_t31_mixer },
9420 .init_verbs = { alc262_init_verbs, alc262_benq_t31_EAPD_verbs, alc262_hippo_unsol_verbs },
9421 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9422 .dac_nids = alc262_dac_nids,
9423 .hp_nid = 0x03,
9424 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9425 .channel_mode = alc262_modes,
9426 .input_mux = &alc262_capture_source,
9427 .unsol_event = alc262_hippo_unsol_event,
9428 .init_hook = alc262_hippo_automute,
9430 [ALC262_ULTRA] = {
9431 .mixers = { alc262_ultra_mixer },
9432 .init_verbs = { alc262_init_verbs, alc262_ultra_verbs },
9433 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9434 .dac_nids = alc262_dac_nids,
9435 .hp_nid = 0x03,
9436 .dig_out_nid = ALC262_DIGOUT_NID,
9437 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9438 .channel_mode = alc262_modes,
9439 .input_mux = &alc262_ultra_capture_source,
9440 .unsol_event = alc262_ultra_unsol_event,
9441 .init_hook = alc262_ultra_automute,
9445 static int patch_alc262(struct hda_codec *codec)
9447 struct alc_spec *spec;
9448 int board_config;
9449 int err;
9451 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
9452 if (spec == NULL)
9453 return -ENOMEM;
9455 codec->spec = spec;
9456 #if 0
9457 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
9458 * under-run
9461 int tmp;
9462 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
9463 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
9464 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
9465 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
9467 #endif
9469 board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST,
9470 alc262_models,
9471 alc262_cfg_tbl);
9473 if (board_config < 0) {
9474 printk(KERN_INFO "hda_codec: Unknown model for ALC262, "
9475 "trying auto-probe from BIOS...\n");
9476 board_config = ALC262_AUTO;
9479 if (board_config == ALC262_AUTO) {
9480 /* automatic parse from the BIOS config */
9481 err = alc262_parse_auto_config(codec);
9482 if (err < 0) {
9483 alc_free(codec);
9484 return err;
9485 } else if (!err) {
9486 printk(KERN_INFO
9487 "hda_codec: Cannot set up configuration "
9488 "from BIOS. Using base mode...\n");
9489 board_config = ALC262_BASIC;
9493 if (board_config != ALC262_AUTO)
9494 setup_preset(spec, &alc262_presets[board_config]);
9496 spec->stream_name_analog = "ALC262 Analog";
9497 spec->stream_analog_playback = &alc262_pcm_analog_playback;
9498 spec->stream_analog_capture = &alc262_pcm_analog_capture;
9500 spec->stream_name_digital = "ALC262 Digital";
9501 spec->stream_digital_playback = &alc262_pcm_digital_playback;
9502 spec->stream_digital_capture = &alc262_pcm_digital_capture;
9504 if (!spec->adc_nids && spec->input_mux) {
9505 /* check whether NID 0x07 is valid */
9506 unsigned int wcap = get_wcaps(codec, 0x07);
9508 /* get type */
9509 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
9510 if (wcap != AC_WID_AUD_IN) {
9511 spec->adc_nids = alc262_adc_nids_alt;
9512 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids_alt);
9513 spec->mixers[spec->num_mixers] =
9514 alc262_capture_alt_mixer;
9515 spec->num_mixers++;
9516 } else {
9517 spec->adc_nids = alc262_adc_nids;
9518 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids);
9519 spec->mixers[spec->num_mixers] = alc262_capture_mixer;
9520 spec->num_mixers++;
9524 spec->vmaster_nid = 0x0c;
9526 codec->patch_ops = alc_patch_ops;
9527 if (board_config == ALC262_AUTO)
9528 spec->init_hook = alc262_auto_init;
9529 #ifdef CONFIG_SND_HDA_POWER_SAVE
9530 if (!spec->loopback.amplist)
9531 spec->loopback.amplist = alc262_loopbacks;
9532 #endif
9534 return 0;
9538 * ALC268 channel source setting (2 channel)
9540 #define ALC268_DIGOUT_NID ALC880_DIGOUT_NID
9541 #define alc268_modes alc260_modes
9543 static hda_nid_t alc268_dac_nids[2] = {
9544 /* front, hp */
9545 0x02, 0x03
9548 static hda_nid_t alc268_adc_nids[2] = {
9549 /* ADC0-1 */
9550 0x08, 0x07
9553 static hda_nid_t alc268_adc_nids_alt[1] = {
9554 /* ADC0 */
9555 0x08
9558 static struct snd_kcontrol_new alc268_base_mixer[] = {
9559 /* output mixer control */
9560 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
9561 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9562 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
9563 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9564 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9565 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
9566 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
9570 static struct hda_verb alc268_eapd_verbs[] = {
9571 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
9572 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
9576 /* Toshiba specific */
9577 #define alc268_toshiba_automute alc262_hippo_automute
9579 static struct hda_verb alc268_toshiba_verbs[] = {
9580 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9581 { } /* end */
9584 /* Acer specific */
9585 /* bind volumes of both NID 0x02 and 0x03 */
9586 static struct hda_bind_ctls alc268_acer_bind_master_vol = {
9587 .ops = &snd_hda_bind_vol,
9588 .values = {
9589 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
9590 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
9595 /* mute/unmute internal speaker according to the hp jack and mute state */
9596 static void alc268_acer_automute(struct hda_codec *codec, int force)
9598 struct alc_spec *spec = codec->spec;
9599 unsigned int mute;
9601 if (force || !spec->sense_updated) {
9602 unsigned int present;
9603 present = snd_hda_codec_read(codec, 0x14, 0,
9604 AC_VERB_GET_PIN_SENSE, 0);
9605 spec->jack_present = (present & 0x80000000) != 0;
9606 spec->sense_updated = 1;
9608 if (spec->jack_present)
9609 mute = HDA_AMP_MUTE; /* mute internal speaker */
9610 else /* unmute internal speaker if necessary */
9611 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
9612 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
9613 HDA_AMP_MUTE, mute);
9617 /* bind hp and internal speaker mute (with plug check) */
9618 static int alc268_acer_master_sw_put(struct snd_kcontrol *kcontrol,
9619 struct snd_ctl_elem_value *ucontrol)
9621 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
9622 long *valp = ucontrol->value.integer.value;
9623 int change;
9625 change = snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
9626 HDA_AMP_MUTE,
9627 valp[0] ? 0 : HDA_AMP_MUTE);
9628 change |= snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
9629 HDA_AMP_MUTE,
9630 valp[1] ? 0 : HDA_AMP_MUTE);
9631 if (change)
9632 alc268_acer_automute(codec, 0);
9633 return change;
9636 static struct snd_kcontrol_new alc268_acer_mixer[] = {
9637 /* output mixer control */
9638 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
9640 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9641 .name = "Master Playback Switch",
9642 .info = snd_hda_mixer_amp_switch_info,
9643 .get = snd_hda_mixer_amp_switch_get,
9644 .put = alc268_acer_master_sw_put,
9645 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
9647 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9648 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
9649 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
9653 static struct hda_verb alc268_acer_verbs[] = {
9654 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9655 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9657 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9661 /* unsolicited event for HP jack sensing */
9662 static void alc268_toshiba_unsol_event(struct hda_codec *codec,
9663 unsigned int res)
9665 if ((res >> 26) != ALC880_HP_EVENT)
9666 return;
9667 alc268_toshiba_automute(codec);
9670 static void alc268_acer_unsol_event(struct hda_codec *codec,
9671 unsigned int res)
9673 if ((res >> 26) != ALC880_HP_EVENT)
9674 return;
9675 alc268_acer_automute(codec, 1);
9678 static void alc268_acer_init_hook(struct hda_codec *codec)
9680 alc268_acer_automute(codec, 1);
9683 static struct snd_kcontrol_new alc268_dell_mixer[] = {
9684 /* output mixer control */
9685 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
9686 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9687 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
9688 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9689 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9690 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
9694 static struct hda_verb alc268_dell_verbs[] = {
9695 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9696 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9697 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9701 /* mute/unmute internal speaker according to the hp jack and mute state */
9702 static void alc268_dell_automute(struct hda_codec *codec)
9704 unsigned int present;
9705 unsigned int mute;
9707 present = snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_PIN_SENSE, 0);
9708 if (present & 0x80000000)
9709 mute = HDA_AMP_MUTE;
9710 else
9711 mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0);
9712 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9713 HDA_AMP_MUTE, mute);
9716 static void alc268_dell_unsol_event(struct hda_codec *codec,
9717 unsigned int res)
9719 if ((res >> 26) != ALC880_HP_EVENT)
9720 return;
9721 alc268_dell_automute(codec);
9724 #define alc268_dell_init_hook alc268_dell_automute
9727 * generic initialization of ADC, input mixers and output mixers
9729 static struct hda_verb alc268_base_init_verbs[] = {
9730 /* Unmute DAC0-1 and set vol = 0 */
9731 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9732 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9733 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9734 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9735 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9736 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9739 * Set up output mixers (0x0c - 0x0e)
9741 /* set vol=0 to output mixers */
9742 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9743 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9744 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9745 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
9747 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9748 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9750 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
9751 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
9752 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
9753 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
9754 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
9755 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9756 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9757 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9759 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9760 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9761 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9762 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9763 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9764 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9765 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9766 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9768 /* Unmute Selector 23h,24h and set the default input to mic-in */
9770 {0x23, AC_VERB_SET_CONNECT_SEL, 0x00},
9771 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9772 {0x24, AC_VERB_SET_CONNECT_SEL, 0x00},
9773 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9779 * generic initialization of ADC, input mixers and output mixers
9781 static struct hda_verb alc268_volume_init_verbs[] = {
9782 /* set output DAC */
9783 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9784 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9785 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9786 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9788 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
9789 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
9790 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9791 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9792 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9794 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9795 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9796 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9797 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9798 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9800 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9801 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9802 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9803 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9805 /* set PCBEEP vol = 0 */
9806 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, (0xb000 | (0x00 << 8))},
9811 #define alc268_mux_enum_info alc_mux_enum_info
9812 #define alc268_mux_enum_get alc_mux_enum_get
9814 static int alc268_mux_enum_put(struct snd_kcontrol *kcontrol,
9815 struct snd_ctl_elem_value *ucontrol)
9817 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
9818 struct alc_spec *spec = codec->spec;
9820 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
9821 static hda_nid_t capture_mixers[3] = { 0x23, 0x24 };
9822 hda_nid_t nid = capture_mixers[adc_idx];
9824 return snd_hda_input_mux_put(codec, spec->input_mux, ucontrol,
9825 nid,
9826 &spec->cur_mux[adc_idx]);
9829 static struct snd_kcontrol_new alc268_capture_alt_mixer[] = {
9830 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
9831 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
9833 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9834 /* The multiple "Capture Source" controls confuse alsamixer
9835 * So call somewhat different..
9837 /* .name = "Capture Source", */
9838 .name = "Input Source",
9839 .count = 1,
9840 .info = alc268_mux_enum_info,
9841 .get = alc268_mux_enum_get,
9842 .put = alc268_mux_enum_put,
9844 { } /* end */
9847 static struct snd_kcontrol_new alc268_capture_mixer[] = {
9848 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
9849 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
9850 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x24, 0x0, HDA_OUTPUT),
9851 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x24, 0x0, HDA_OUTPUT),
9853 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9854 /* The multiple "Capture Source" controls confuse alsamixer
9855 * So call somewhat different..
9857 /* .name = "Capture Source", */
9858 .name = "Input Source",
9859 .count = 2,
9860 .info = alc268_mux_enum_info,
9861 .get = alc268_mux_enum_get,
9862 .put = alc268_mux_enum_put,
9864 { } /* end */
9867 static struct hda_input_mux alc268_capture_source = {
9868 .num_items = 4,
9869 .items = {
9870 { "Mic", 0x0 },
9871 { "Front Mic", 0x1 },
9872 { "Line", 0x2 },
9873 { "CD", 0x3 },
9877 #ifdef CONFIG_SND_DEBUG
9878 static struct snd_kcontrol_new alc268_test_mixer[] = {
9879 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
9880 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9881 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
9882 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9884 /* Volume widgets */
9885 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x02, 0x0, HDA_OUTPUT),
9886 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x03, 0x0, HDA_OUTPUT),
9887 HDA_BIND_MUTE_MONO("Mono sum Playback Switch", 0x0e, 1, 2, HDA_INPUT),
9888 HDA_BIND_MUTE("LINE-OUT sum Playback Switch", 0x0f, 2, HDA_INPUT),
9889 HDA_BIND_MUTE("HP-OUT sum Playback Switch", 0x10, 2, HDA_INPUT),
9890 HDA_BIND_MUTE("LINE-OUT Playback Switch", 0x14, 2, HDA_OUTPUT),
9891 HDA_BIND_MUTE("HP-OUT Playback Switch", 0x15, 2, HDA_OUTPUT),
9892 HDA_BIND_MUTE("Mono Playback Switch", 0x16, 2, HDA_OUTPUT),
9893 HDA_CODEC_VOLUME("MIC1 Capture Volume", 0x18, 0x0, HDA_INPUT),
9894 HDA_BIND_MUTE("MIC1 Capture Switch", 0x18, 2, HDA_OUTPUT),
9895 HDA_CODEC_VOLUME("MIC2 Capture Volume", 0x19, 0x0, HDA_INPUT),
9896 HDA_CODEC_VOLUME("LINE1 Capture Volume", 0x1a, 0x0, HDA_INPUT),
9897 HDA_BIND_MUTE("LINE1 Capture Switch", 0x1a, 2, HDA_OUTPUT),
9898 /* The below appears problematic on some hardwares */
9899 /*HDA_CODEC_VOLUME("PCBEEP Playback Volume", 0x1d, 0x0, HDA_INPUT),*/
9900 HDA_CODEC_VOLUME("PCM-IN1 Capture Volume", 0x23, 0x0, HDA_OUTPUT),
9901 HDA_BIND_MUTE("PCM-IN1 Capture Switch", 0x23, 2, HDA_OUTPUT),
9902 HDA_CODEC_VOLUME("PCM-IN2 Capture Volume", 0x24, 0x0, HDA_OUTPUT),
9903 HDA_BIND_MUTE("PCM-IN2 Capture Switch", 0x24, 2, HDA_OUTPUT),
9905 /* Modes for retasking pin widgets */
9906 ALC_PIN_MODE("LINE-OUT pin mode", 0x14, ALC_PIN_DIR_INOUT),
9907 ALC_PIN_MODE("HP-OUT pin mode", 0x15, ALC_PIN_DIR_INOUT),
9908 ALC_PIN_MODE("MIC1 pin mode", 0x18, ALC_PIN_DIR_INOUT),
9909 ALC_PIN_MODE("LINE1 pin mode", 0x1a, ALC_PIN_DIR_INOUT),
9911 /* Controls for GPIO pins, assuming they are configured as outputs */
9912 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
9913 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
9914 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
9915 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
9917 /* Switches to allow the digital SPDIF output pin to be enabled.
9918 * The ALC268 does not have an SPDIF input.
9920 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x06, 0x01),
9922 /* A switch allowing EAPD to be enabled. Some laptops seem to use
9923 * this output to turn on an external amplifier.
9925 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
9926 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
9928 { } /* end */
9930 #endif
9932 /* create input playback/capture controls for the given pin */
9933 static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
9934 const char *ctlname, int idx)
9936 char name[32];
9937 int err;
9939 sprintf(name, "%s Playback Volume", ctlname);
9940 if (nid == 0x14) {
9941 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
9942 HDA_COMPOSE_AMP_VAL(0x02, 3, idx,
9943 HDA_OUTPUT));
9944 if (err < 0)
9945 return err;
9946 } else if (nid == 0x15) {
9947 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
9948 HDA_COMPOSE_AMP_VAL(0x03, 3, idx,
9949 HDA_OUTPUT));
9950 if (err < 0)
9951 return err;
9952 } else
9953 return -1;
9954 sprintf(name, "%s Playback Switch", ctlname);
9955 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
9956 HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
9957 if (err < 0)
9958 return err;
9959 return 0;
9962 /* add playback controls from the parsed DAC table */
9963 static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec,
9964 const struct auto_pin_cfg *cfg)
9966 hda_nid_t nid;
9967 int err;
9969 spec->multiout.num_dacs = 2; /* only use one dac */
9970 spec->multiout.dac_nids = spec->private_dac_nids;
9971 spec->multiout.dac_nids[0] = 2;
9972 spec->multiout.dac_nids[1] = 3;
9974 nid = cfg->line_out_pins[0];
9975 if (nid)
9976 alc268_new_analog_output(spec, nid, "Front", 0);
9978 nid = cfg->speaker_pins[0];
9979 if (nid == 0x1d) {
9980 err = add_control(spec, ALC_CTL_WIDGET_VOL,
9981 "Speaker Playback Volume",
9982 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
9983 if (err < 0)
9984 return err;
9986 nid = cfg->hp_pins[0];
9987 if (nid)
9988 alc268_new_analog_output(spec, nid, "Headphone", 0);
9990 nid = cfg->line_out_pins[1] | cfg->line_out_pins[2];
9991 if (nid == 0x16) {
9992 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
9993 "Mono Playback Switch",
9994 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_INPUT));
9995 if (err < 0)
9996 return err;
9998 return 0;
10001 /* create playback/capture controls for input pins */
10002 static int alc268_auto_create_analog_input_ctls(struct alc_spec *spec,
10003 const struct auto_pin_cfg *cfg)
10005 struct hda_input_mux *imux = &spec->private_imux;
10006 int i, idx1;
10008 for (i = 0; i < AUTO_PIN_LAST; i++) {
10009 switch(cfg->input_pins[i]) {
10010 case 0x18:
10011 idx1 = 0; /* Mic 1 */
10012 break;
10013 case 0x19:
10014 idx1 = 1; /* Mic 2 */
10015 break;
10016 case 0x1a:
10017 idx1 = 2; /* Line In */
10018 break;
10019 case 0x1c:
10020 idx1 = 3; /* CD */
10021 break;
10022 default:
10023 continue;
10025 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
10026 imux->items[imux->num_items].index = idx1;
10027 imux->num_items++;
10029 return 0;
10032 static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec)
10034 struct alc_spec *spec = codec->spec;
10035 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
10036 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
10037 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
10038 unsigned int dac_vol1, dac_vol2;
10040 if (speaker_nid) {
10041 snd_hda_codec_write(codec, speaker_nid, 0,
10042 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
10043 snd_hda_codec_write(codec, 0x0f, 0,
10044 AC_VERB_SET_AMP_GAIN_MUTE,
10045 AMP_IN_UNMUTE(1));
10046 snd_hda_codec_write(codec, 0x10, 0,
10047 AC_VERB_SET_AMP_GAIN_MUTE,
10048 AMP_IN_UNMUTE(1));
10049 } else {
10050 snd_hda_codec_write(codec, 0x0f, 0,
10051 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
10052 snd_hda_codec_write(codec, 0x10, 0,
10053 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
10056 dac_vol1 = dac_vol2 = 0xb000 | 0x40; /* set max volume */
10057 if (line_nid == 0x14)
10058 dac_vol2 = AMP_OUT_ZERO;
10059 else if (line_nid == 0x15)
10060 dac_vol1 = AMP_OUT_ZERO;
10061 if (hp_nid == 0x14)
10062 dac_vol2 = AMP_OUT_ZERO;
10063 else if (hp_nid == 0x15)
10064 dac_vol1 = AMP_OUT_ZERO;
10065 if (line_nid != 0x16 || hp_nid != 0x16 ||
10066 spec->autocfg.line_out_pins[1] != 0x16 ||
10067 spec->autocfg.line_out_pins[2] != 0x16)
10068 dac_vol1 = dac_vol2 = AMP_OUT_ZERO;
10070 snd_hda_codec_write(codec, 0x02, 0,
10071 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol1);
10072 snd_hda_codec_write(codec, 0x03, 0,
10073 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol2);
10076 /* pcm configuration: identiacal with ALC880 */
10077 #define alc268_pcm_analog_playback alc880_pcm_analog_playback
10078 #define alc268_pcm_analog_capture alc880_pcm_analog_capture
10079 #define alc268_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
10080 #define alc268_pcm_digital_playback alc880_pcm_digital_playback
10083 * BIOS auto configuration
10085 static int alc268_parse_auto_config(struct hda_codec *codec)
10087 struct alc_spec *spec = codec->spec;
10088 int err;
10089 static hda_nid_t alc268_ignore[] = { 0 };
10091 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
10092 alc268_ignore);
10093 if (err < 0)
10094 return err;
10095 if (!spec->autocfg.line_outs)
10096 return 0; /* can't find valid BIOS pin config */
10098 err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg);
10099 if (err < 0)
10100 return err;
10101 err = alc268_auto_create_analog_input_ctls(spec, &spec->autocfg);
10102 if (err < 0)
10103 return err;
10105 spec->multiout.max_channels = 2;
10107 /* digital only support output */
10108 if (spec->autocfg.dig_out_pin)
10109 spec->multiout.dig_out_nid = ALC268_DIGOUT_NID;
10111 if (spec->kctl_alloc)
10112 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
10114 spec->init_verbs[spec->num_init_verbs++] = alc268_volume_init_verbs;
10115 spec->num_mux_defs = 1;
10116 spec->input_mux = &spec->private_imux;
10118 err = alc_auto_add_mic_boost(codec);
10119 if (err < 0)
10120 return err;
10122 return 1;
10125 #define alc268_auto_init_multi_out alc882_auto_init_multi_out
10126 #define alc268_auto_init_hp_out alc882_auto_init_hp_out
10127 #define alc268_auto_init_analog_input alc882_auto_init_analog_input
10129 /* init callback for auto-configuration model -- overriding the default init */
10130 static void alc268_auto_init(struct hda_codec *codec)
10132 alc268_auto_init_multi_out(codec);
10133 alc268_auto_init_hp_out(codec);
10134 alc268_auto_init_mono_speaker_out(codec);
10135 alc268_auto_init_analog_input(codec);
10139 * configuration and preset
10141 static const char *alc268_models[ALC268_MODEL_LAST] = {
10142 [ALC268_3ST] = "3stack",
10143 [ALC268_TOSHIBA] = "toshiba",
10144 [ALC268_ACER] = "acer",
10145 [ALC268_DELL] = "dell",
10146 #ifdef CONFIG_SND_DEBUG
10147 [ALC268_TEST] = "test",
10148 #endif
10149 [ALC268_AUTO] = "auto",
10152 static struct snd_pci_quirk alc268_cfg_tbl[] = {
10153 SND_PCI_QUIRK(0x1025, 0x0126, "Acer", ALC268_ACER),
10154 SND_PCI_QUIRK(0x1025, 0x012e, "Acer Aspire 5310", ALC268_ACER),
10155 SND_PCI_QUIRK(0x1025, 0x0130, "Acer Extensa 5210", ALC268_ACER),
10156 SND_PCI_QUIRK(0x1025, 0x0136, "Acer Aspire 5315", ALC268_ACER),
10157 SND_PCI_QUIRK(0x1028, 0x0253, "Dell OEM", ALC268_DELL),
10158 SND_PCI_QUIRK(0x103c, 0x30cc, "TOSHIBA", ALC268_TOSHIBA),
10159 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST),
10160 SND_PCI_QUIRK(0x1179, 0xff10, "TOSHIBA A205", ALC268_TOSHIBA),
10161 SND_PCI_QUIRK(0x1179, 0xff50, "TOSHIBA A305", ALC268_TOSHIBA),
10162 SND_PCI_QUIRK(0x152d, 0x0763, "Diverse (CPR2000)", ALC268_ACER),
10166 static struct alc_config_preset alc268_presets[] = {
10167 [ALC268_3ST] = {
10168 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer },
10169 .init_verbs = { alc268_base_init_verbs },
10170 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
10171 .dac_nids = alc268_dac_nids,
10172 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
10173 .adc_nids = alc268_adc_nids_alt,
10174 .hp_nid = 0x03,
10175 .dig_out_nid = ALC268_DIGOUT_NID,
10176 .num_channel_mode = ARRAY_SIZE(alc268_modes),
10177 .channel_mode = alc268_modes,
10178 .input_mux = &alc268_capture_source,
10180 [ALC268_TOSHIBA] = {
10181 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer },
10182 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
10183 alc268_toshiba_verbs },
10184 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
10185 .dac_nids = alc268_dac_nids,
10186 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
10187 .adc_nids = alc268_adc_nids_alt,
10188 .hp_nid = 0x03,
10189 .num_channel_mode = ARRAY_SIZE(alc268_modes),
10190 .channel_mode = alc268_modes,
10191 .input_mux = &alc268_capture_source,
10192 .unsol_event = alc268_toshiba_unsol_event,
10193 .init_hook = alc268_toshiba_automute,
10195 [ALC268_ACER] = {
10196 .mixers = { alc268_acer_mixer, alc268_capture_alt_mixer },
10197 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
10198 alc268_acer_verbs },
10199 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
10200 .dac_nids = alc268_dac_nids,
10201 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
10202 .adc_nids = alc268_adc_nids_alt,
10203 .hp_nid = 0x02,
10204 .num_channel_mode = ARRAY_SIZE(alc268_modes),
10205 .channel_mode = alc268_modes,
10206 .input_mux = &alc268_capture_source,
10207 .unsol_event = alc268_acer_unsol_event,
10208 .init_hook = alc268_acer_init_hook,
10210 [ALC268_DELL] = {
10211 .mixers = { alc268_dell_mixer },
10212 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
10213 alc268_dell_verbs },
10214 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
10215 .dac_nids = alc268_dac_nids,
10216 .hp_nid = 0x02,
10217 .num_channel_mode = ARRAY_SIZE(alc268_modes),
10218 .channel_mode = alc268_modes,
10219 .unsol_event = alc268_dell_unsol_event,
10220 .init_hook = alc268_dell_init_hook,
10221 .input_mux = &alc268_capture_source,
10223 #ifdef CONFIG_SND_DEBUG
10224 [ALC268_TEST] = {
10225 .mixers = { alc268_test_mixer, alc268_capture_mixer },
10226 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
10227 alc268_volume_init_verbs },
10228 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
10229 .dac_nids = alc268_dac_nids,
10230 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
10231 .adc_nids = alc268_adc_nids_alt,
10232 .hp_nid = 0x03,
10233 .dig_out_nid = ALC268_DIGOUT_NID,
10234 .num_channel_mode = ARRAY_SIZE(alc268_modes),
10235 .channel_mode = alc268_modes,
10236 .input_mux = &alc268_capture_source,
10238 #endif
10241 static int patch_alc268(struct hda_codec *codec)
10243 struct alc_spec *spec;
10244 int board_config;
10245 int err;
10247 spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
10248 if (spec == NULL)
10249 return -ENOMEM;
10251 codec->spec = spec;
10253 board_config = snd_hda_check_board_config(codec, ALC268_MODEL_LAST,
10254 alc268_models,
10255 alc268_cfg_tbl);
10257 if (board_config < 0 || board_config >= ALC268_MODEL_LAST) {
10258 printk(KERN_INFO "hda_codec: Unknown model for ALC268, "
10259 "trying auto-probe from BIOS...\n");
10260 board_config = ALC268_AUTO;
10263 if (board_config == ALC268_AUTO) {
10264 /* automatic parse from the BIOS config */
10265 err = alc268_parse_auto_config(codec);
10266 if (err < 0) {
10267 alc_free(codec);
10268 return err;
10269 } else if (!err) {
10270 printk(KERN_INFO
10271 "hda_codec: Cannot set up configuration "
10272 "from BIOS. Using base mode...\n");
10273 board_config = ALC268_3ST;
10277 if (board_config != ALC268_AUTO)
10278 setup_preset(spec, &alc268_presets[board_config]);
10280 spec->stream_name_analog = "ALC268 Analog";
10281 spec->stream_analog_playback = &alc268_pcm_analog_playback;
10282 spec->stream_analog_capture = &alc268_pcm_analog_capture;
10283 spec->stream_analog_alt_capture = &alc268_pcm_analog_alt_capture;
10285 spec->stream_name_digital = "ALC268 Digital";
10286 spec->stream_digital_playback = &alc268_pcm_digital_playback;
10288 if (!spec->adc_nids && spec->input_mux) {
10289 /* check whether NID 0x07 is valid */
10290 unsigned int wcap = get_wcaps(codec, 0x07);
10292 /* get type */
10293 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
10294 if (wcap != AC_WID_AUD_IN) {
10295 spec->adc_nids = alc268_adc_nids_alt;
10296 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt);
10297 spec->mixers[spec->num_mixers] =
10298 alc268_capture_alt_mixer;
10299 spec->num_mixers++;
10300 } else {
10301 spec->adc_nids = alc268_adc_nids;
10302 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids);
10303 spec->mixers[spec->num_mixers] =
10304 alc268_capture_mixer;
10305 spec->num_mixers++;
10309 spec->vmaster_nid = 0x02;
10311 codec->patch_ops = alc_patch_ops;
10312 if (board_config == ALC268_AUTO)
10313 spec->init_hook = alc268_auto_init;
10315 return 0;
10319 * ALC269 channel source setting (2 channel)
10321 #define ALC269_DIGOUT_NID ALC880_DIGOUT_NID
10323 #define alc269_dac_nids alc260_dac_nids
10325 static hda_nid_t alc269_adc_nids[1] = {
10326 /* ADC1 */
10327 0x07,
10330 #define alc269_modes alc260_modes
10331 #define alc269_capture_source alc880_lg_lw_capture_source
10333 static struct snd_kcontrol_new alc269_base_mixer[] = {
10334 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
10335 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
10336 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10337 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10338 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10339 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10340 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10341 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10342 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10343 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10344 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10345 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
10346 { } /* end */
10349 /* capture mixer elements */
10350 static struct snd_kcontrol_new alc269_capture_mixer[] = {
10351 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
10352 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
10354 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10355 /* The multiple "Capture Source" controls confuse alsamixer
10356 * So call somewhat different..
10358 /* .name = "Capture Source", */
10359 .name = "Input Source",
10360 .count = 1,
10361 .info = alc_mux_enum_info,
10362 .get = alc_mux_enum_get,
10363 .put = alc_mux_enum_put,
10365 { } /* end */
10369 * generic initialization of ADC, input mixers and output mixers
10371 static struct hda_verb alc269_init_verbs[] = {
10373 * Unmute ADC0 and set the default input to mic-in
10375 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10377 /* Mute input amps (PCBeep, Line In, Mic 1 & Mic 2) of the
10378 * analog-loopback mixer widget
10379 * Note: PASD motherboards uses the Line In 2 as the input for
10380 * front panel mic (mic 2)
10382 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
10383 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10384 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10385 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10386 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10387 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
10390 * Set up output mixers (0x0c - 0x0e)
10392 /* set vol=0 to output mixers */
10393 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10394 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10396 /* set up input amps for analog loopback */
10397 /* Amp Indices: DAC = 0, mixer = 1 */
10398 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10399 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10400 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10401 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10402 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10403 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10405 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10406 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10407 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10408 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
10409 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
10410 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10411 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10413 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10414 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10415 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10416 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10417 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10418 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10419 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10421 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
10422 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10424 /* FIXME: use matrix-type input source selection */
10425 /* Mixer elements: 0x18, 19, 1a, 1b, 1d, 0b */
10426 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
10427 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10428 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10429 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10430 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10432 /* set EAPD */
10433 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
10434 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
10438 /* add playback controls from the parsed DAC table */
10439 static int alc269_auto_create_multi_out_ctls(struct alc_spec *spec,
10440 const struct auto_pin_cfg *cfg)
10442 hda_nid_t nid;
10443 int err;
10445 spec->multiout.num_dacs = 1; /* only use one dac */
10446 spec->multiout.dac_nids = spec->private_dac_nids;
10447 spec->multiout.dac_nids[0] = 2;
10449 nid = cfg->line_out_pins[0];
10450 if (nid) {
10451 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10452 "Front Playback Volume",
10453 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT));
10454 if (err < 0)
10455 return err;
10456 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10457 "Front Playback Switch",
10458 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
10459 if (err < 0)
10460 return err;
10463 nid = cfg->speaker_pins[0];
10464 if (nid) {
10465 if (!cfg->line_out_pins[0]) {
10466 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10467 "Speaker Playback Volume",
10468 HDA_COMPOSE_AMP_VAL(0x02, 3, 0,
10469 HDA_OUTPUT));
10470 if (err < 0)
10471 return err;
10473 if (nid == 0x16) {
10474 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10475 "Speaker Playback Switch",
10476 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
10477 HDA_OUTPUT));
10478 if (err < 0)
10479 return err;
10480 } else {
10481 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10482 "Speaker Playback Switch",
10483 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
10484 HDA_OUTPUT));
10485 if (err < 0)
10486 return err;
10489 nid = cfg->hp_pins[0];
10490 if (nid) {
10491 /* spec->multiout.hp_nid = 2; */
10492 if (!cfg->line_out_pins[0] && !cfg->speaker_pins[0]) {
10493 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10494 "Headphone Playback Volume",
10495 HDA_COMPOSE_AMP_VAL(0x02, 3, 0,
10496 HDA_OUTPUT));
10497 if (err < 0)
10498 return err;
10500 if (nid == 0x16) {
10501 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10502 "Headphone Playback Switch",
10503 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
10504 HDA_OUTPUT));
10505 if (err < 0)
10506 return err;
10507 } else {
10508 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10509 "Headphone Playback Switch",
10510 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
10511 HDA_OUTPUT));
10512 if (err < 0)
10513 return err;
10516 return 0;
10519 #define alc269_auto_create_analog_input_ctls \
10520 alc880_auto_create_analog_input_ctls
10522 #ifdef CONFIG_SND_HDA_POWER_SAVE
10523 #define alc269_loopbacks alc880_loopbacks
10524 #endif
10526 /* pcm configuration: identiacal with ALC880 */
10527 #define alc269_pcm_analog_playback alc880_pcm_analog_playback
10528 #define alc269_pcm_analog_capture alc880_pcm_analog_capture
10529 #define alc269_pcm_digital_playback alc880_pcm_digital_playback
10530 #define alc269_pcm_digital_capture alc880_pcm_digital_capture
10533 * BIOS auto configuration
10535 static int alc269_parse_auto_config(struct hda_codec *codec)
10537 struct alc_spec *spec = codec->spec;
10538 int err;
10539 static hda_nid_t alc269_ignore[] = { 0x1d, 0 };
10541 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
10542 alc269_ignore);
10543 if (err < 0)
10544 return err;
10546 err = alc269_auto_create_multi_out_ctls(spec, &spec->autocfg);
10547 if (err < 0)
10548 return err;
10549 err = alc269_auto_create_analog_input_ctls(spec, &spec->autocfg);
10550 if (err < 0)
10551 return err;
10553 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
10555 if (spec->autocfg.dig_out_pin)
10556 spec->multiout.dig_out_nid = ALC269_DIGOUT_NID;
10558 if (spec->kctl_alloc)
10559 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
10561 spec->init_verbs[spec->num_init_verbs++] = alc269_init_verbs;
10562 spec->num_mux_defs = 1;
10563 spec->input_mux = &spec->private_imux;
10565 err = alc_auto_add_mic_boost(codec);
10566 if (err < 0)
10567 return err;
10569 return 1;
10572 #define alc269_auto_init_multi_out alc882_auto_init_multi_out
10573 #define alc269_auto_init_hp_out alc882_auto_init_hp_out
10574 #define alc269_auto_init_analog_input alc882_auto_init_analog_input
10577 /* init callback for auto-configuration model -- overriding the default init */
10578 static void alc269_auto_init(struct hda_codec *codec)
10580 alc269_auto_init_multi_out(codec);
10581 alc269_auto_init_hp_out(codec);
10582 alc269_auto_init_analog_input(codec);
10586 * configuration and preset
10588 static const char *alc269_models[ALC269_MODEL_LAST] = {
10589 [ALC269_BASIC] = "basic",
10592 static struct snd_pci_quirk alc269_cfg_tbl[] = {
10596 static struct alc_config_preset alc269_presets[] = {
10597 [ALC269_BASIC] = {
10598 .mixers = { alc269_base_mixer },
10599 .init_verbs = { alc269_init_verbs },
10600 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
10601 .dac_nids = alc269_dac_nids,
10602 .hp_nid = 0x03,
10603 .num_channel_mode = ARRAY_SIZE(alc269_modes),
10604 .channel_mode = alc269_modes,
10605 .input_mux = &alc269_capture_source,
10609 static int patch_alc269(struct hda_codec *codec)
10611 struct alc_spec *spec;
10612 int board_config;
10613 int err;
10615 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
10616 if (spec == NULL)
10617 return -ENOMEM;
10619 codec->spec = spec;
10621 board_config = snd_hda_check_board_config(codec, ALC269_MODEL_LAST,
10622 alc269_models,
10623 alc269_cfg_tbl);
10625 if (board_config < 0) {
10626 printk(KERN_INFO "hda_codec: Unknown model for ALC269, "
10627 "trying auto-probe from BIOS...\n");
10628 board_config = ALC269_AUTO;
10631 if (board_config == ALC269_AUTO) {
10632 /* automatic parse from the BIOS config */
10633 err = alc269_parse_auto_config(codec);
10634 if (err < 0) {
10635 alc_free(codec);
10636 return err;
10637 } else if (!err) {
10638 printk(KERN_INFO
10639 "hda_codec: Cannot set up configuration "
10640 "from BIOS. Using base mode...\n");
10641 board_config = ALC269_BASIC;
10645 if (board_config != ALC269_AUTO)
10646 setup_preset(spec, &alc269_presets[board_config]);
10648 spec->stream_name_analog = "ALC269 Analog";
10649 spec->stream_analog_playback = &alc269_pcm_analog_playback;
10650 spec->stream_analog_capture = &alc269_pcm_analog_capture;
10652 spec->stream_name_digital = "ALC269 Digital";
10653 spec->stream_digital_playback = &alc269_pcm_digital_playback;
10654 spec->stream_digital_capture = &alc269_pcm_digital_capture;
10656 spec->adc_nids = alc269_adc_nids;
10657 spec->num_adc_nids = ARRAY_SIZE(alc269_adc_nids);
10658 spec->mixers[spec->num_mixers] = alc269_capture_mixer;
10659 spec->num_mixers++;
10661 codec->patch_ops = alc_patch_ops;
10662 if (board_config == ALC269_AUTO)
10663 spec->init_hook = alc269_auto_init;
10664 #ifdef CONFIG_SND_HDA_POWER_SAVE
10665 if (!spec->loopback.amplist)
10666 spec->loopback.amplist = alc269_loopbacks;
10667 #endif
10669 return 0;
10673 * ALC861 channel source setting (2/6 channel selection for 3-stack)
10677 * set the path ways for 2 channel output
10678 * need to set the codec line out and mic 1 pin widgets to inputs
10680 static struct hda_verb alc861_threestack_ch2_init[] = {
10681 /* set pin widget 1Ah (line in) for input */
10682 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
10683 /* set pin widget 18h (mic1/2) for input, for mic also enable
10684 * the vref
10686 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
10688 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
10689 #if 0
10690 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
10691 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
10692 #endif
10693 { } /* end */
10696 * 6ch mode
10697 * need to set the codec line out and mic 1 pin widgets to outputs
10699 static struct hda_verb alc861_threestack_ch6_init[] = {
10700 /* set pin widget 1Ah (line in) for output (Back Surround)*/
10701 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
10702 /* set pin widget 18h (mic1) for output (CLFE)*/
10703 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
10705 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
10706 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
10708 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
10709 #if 0
10710 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
10711 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
10712 #endif
10713 { } /* end */
10716 static struct hda_channel_mode alc861_threestack_modes[2] = {
10717 { 2, alc861_threestack_ch2_init },
10718 { 6, alc861_threestack_ch6_init },
10720 /* Set mic1 as input and unmute the mixer */
10721 static struct hda_verb alc861_uniwill_m31_ch2_init[] = {
10722 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
10723 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
10724 { } /* end */
10726 /* Set mic1 as output and mute mixer */
10727 static struct hda_verb alc861_uniwill_m31_ch4_init[] = {
10728 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
10729 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
10730 { } /* end */
10733 static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
10734 { 2, alc861_uniwill_m31_ch2_init },
10735 { 4, alc861_uniwill_m31_ch4_init },
10738 /* Set mic1 and line-in as input and unmute the mixer */
10739 static struct hda_verb alc861_asus_ch2_init[] = {
10740 /* set pin widget 1Ah (line in) for input */
10741 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
10742 /* set pin widget 18h (mic1/2) for input, for mic also enable
10743 * the vref
10745 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
10747 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
10748 #if 0
10749 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
10750 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
10751 #endif
10752 { } /* end */
10754 /* Set mic1 nad line-in as output and mute mixer */
10755 static struct hda_verb alc861_asus_ch6_init[] = {
10756 /* set pin widget 1Ah (line in) for output (Back Surround)*/
10757 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
10758 /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
10759 /* set pin widget 18h (mic1) for output (CLFE)*/
10760 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
10761 /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
10762 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
10763 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
10765 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
10766 #if 0
10767 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
10768 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
10769 #endif
10770 { } /* end */
10773 static struct hda_channel_mode alc861_asus_modes[2] = {
10774 { 2, alc861_asus_ch2_init },
10775 { 6, alc861_asus_ch6_init },
10778 /* patch-ALC861 */
10780 static struct snd_kcontrol_new alc861_base_mixer[] = {
10781 /* output mixer control */
10782 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
10783 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
10784 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
10785 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
10786 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
10788 /*Input mixer control */
10789 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
10790 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
10791 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
10792 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
10793 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
10794 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
10795 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
10796 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
10797 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
10798 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
10800 /* Capture mixer control */
10801 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
10802 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
10804 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10805 .name = "Capture Source",
10806 .count = 1,
10807 .info = alc_mux_enum_info,
10808 .get = alc_mux_enum_get,
10809 .put = alc_mux_enum_put,
10811 { } /* end */
10814 static struct snd_kcontrol_new alc861_3ST_mixer[] = {
10815 /* output mixer control */
10816 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
10817 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
10818 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
10819 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
10820 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
10822 /* Input mixer control */
10823 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
10824 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
10825 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
10826 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
10827 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
10828 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
10829 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
10830 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
10831 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
10832 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
10834 /* Capture mixer control */
10835 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
10836 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
10838 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10839 .name = "Capture Source",
10840 .count = 1,
10841 .info = alc_mux_enum_info,
10842 .get = alc_mux_enum_get,
10843 .put = alc_mux_enum_put,
10846 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10847 .name = "Channel Mode",
10848 .info = alc_ch_mode_info,
10849 .get = alc_ch_mode_get,
10850 .put = alc_ch_mode_put,
10851 .private_value = ARRAY_SIZE(alc861_threestack_modes),
10853 { } /* end */
10856 static struct snd_kcontrol_new alc861_toshiba_mixer[] = {
10857 /* output mixer control */
10858 HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT),
10859 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
10860 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
10862 /*Capture mixer control */
10863 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
10864 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
10866 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10867 .name = "Capture Source",
10868 .count = 1,
10869 .info = alc_mux_enum_info,
10870 .get = alc_mux_enum_get,
10871 .put = alc_mux_enum_put,
10874 { } /* end */
10877 static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
10878 /* output mixer control */
10879 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
10880 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
10881 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
10882 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
10883 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
10885 /* Input mixer control */
10886 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
10887 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
10888 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
10889 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
10890 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
10891 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
10892 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
10893 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
10894 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
10895 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
10897 /* Capture mixer control */
10898 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
10899 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
10901 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10902 .name = "Capture Source",
10903 .count = 1,
10904 .info = alc_mux_enum_info,
10905 .get = alc_mux_enum_get,
10906 .put = alc_mux_enum_put,
10909 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10910 .name = "Channel Mode",
10911 .info = alc_ch_mode_info,
10912 .get = alc_ch_mode_get,
10913 .put = alc_ch_mode_put,
10914 .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
10916 { } /* end */
10919 static struct snd_kcontrol_new alc861_asus_mixer[] = {
10920 /* output mixer control */
10921 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
10922 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
10923 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
10924 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
10925 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
10927 /* Input mixer control */
10928 HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
10929 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10930 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
10931 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
10932 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
10933 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
10934 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
10935 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
10936 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
10937 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT),
10939 /* Capture mixer control */
10940 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
10941 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
10943 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10944 .name = "Capture Source",
10945 .count = 1,
10946 .info = alc_mux_enum_info,
10947 .get = alc_mux_enum_get,
10948 .put = alc_mux_enum_put,
10951 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10952 .name = "Channel Mode",
10953 .info = alc_ch_mode_info,
10954 .get = alc_ch_mode_get,
10955 .put = alc_ch_mode_put,
10956 .private_value = ARRAY_SIZE(alc861_asus_modes),
10961 /* additional mixer */
10962 static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = {
10963 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
10964 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
10965 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x23, 0x0, HDA_OUTPUT),
10966 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x23, 0x0, HDA_OUTPUT),
10971 * generic initialization of ADC, input mixers and output mixers
10973 static struct hda_verb alc861_base_init_verbs[] = {
10975 * Unmute ADC0 and set the default input to mic-in
10977 /* port-A for surround (rear panel) */
10978 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
10979 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
10980 /* port-B for mic-in (rear panel) with vref */
10981 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
10982 /* port-C for line-in (rear panel) */
10983 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
10984 /* port-D for Front */
10985 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
10986 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
10987 /* port-E for HP out (front panel) */
10988 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
10989 /* route front PCM to HP */
10990 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
10991 /* port-F for mic-in (front panel) with vref */
10992 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
10993 /* port-G for CLFE (rear panel) */
10994 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
10995 { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
10996 /* port-H for side (rear panel) */
10997 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
10998 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
10999 /* CD-in */
11000 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
11001 /* route front mic to ADC1*/
11002 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
11003 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11005 /* Unmute DAC0~3 & spdif out*/
11006 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11007 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11008 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11009 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11010 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11012 /* Unmute Mixer 14 (mic) 1c (Line in)*/
11013 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11014 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11015 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11016 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11018 /* Unmute Stereo Mixer 15 */
11019 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11020 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11021 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
11022 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
11024 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11025 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11026 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11027 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11028 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11029 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11030 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11031 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11032 /* hp used DAC 3 (Front) */
11033 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
11034 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
11039 static struct hda_verb alc861_threestack_init_verbs[] = {
11041 * Unmute ADC0 and set the default input to mic-in
11043 /* port-A for surround (rear panel) */
11044 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
11045 /* port-B for mic-in (rear panel) with vref */
11046 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
11047 /* port-C for line-in (rear panel) */
11048 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
11049 /* port-D for Front */
11050 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
11051 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
11052 /* port-E for HP out (front panel) */
11053 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
11054 /* route front PCM to HP */
11055 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
11056 /* port-F for mic-in (front panel) with vref */
11057 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
11058 /* port-G for CLFE (rear panel) */
11059 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
11060 /* port-H for side (rear panel) */
11061 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
11062 /* CD-in */
11063 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
11064 /* route front mic to ADC1*/
11065 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
11066 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11067 /* Unmute DAC0~3 & spdif out*/
11068 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11069 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11070 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11071 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11072 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11074 /* Unmute Mixer 14 (mic) 1c (Line in)*/
11075 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11076 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11077 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11078 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11080 /* Unmute Stereo Mixer 15 */
11081 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11082 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11083 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
11084 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
11086 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11087 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11088 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11089 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11090 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11091 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11092 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11093 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11094 /* hp used DAC 3 (Front) */
11095 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
11096 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
11100 static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
11102 * Unmute ADC0 and set the default input to mic-in
11104 /* port-A for surround (rear panel) */
11105 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
11106 /* port-B for mic-in (rear panel) with vref */
11107 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
11108 /* port-C for line-in (rear panel) */
11109 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
11110 /* port-D for Front */
11111 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
11112 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
11113 /* port-E for HP out (front panel) */
11114 /* this has to be set to VREF80 */
11115 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
11116 /* route front PCM to HP */
11117 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
11118 /* port-F for mic-in (front panel) with vref */
11119 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
11120 /* port-G for CLFE (rear panel) */
11121 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
11122 /* port-H for side (rear panel) */
11123 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
11124 /* CD-in */
11125 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
11126 /* route front mic to ADC1*/
11127 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
11128 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11129 /* Unmute DAC0~3 & spdif out*/
11130 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11131 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11132 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11133 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11134 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11136 /* Unmute Mixer 14 (mic) 1c (Line in)*/
11137 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11138 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11139 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11140 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11142 /* Unmute Stereo Mixer 15 */
11143 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11144 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11145 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
11146 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
11148 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11149 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11150 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11151 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11152 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11153 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11154 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11155 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11156 /* hp used DAC 3 (Front) */
11157 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
11158 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
11162 static struct hda_verb alc861_asus_init_verbs[] = {
11164 * Unmute ADC0 and set the default input to mic-in
11166 /* port-A for surround (rear panel)
11167 * according to codec#0 this is the HP jack
11169 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */
11170 /* route front PCM to HP */
11171 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 },
11172 /* port-B for mic-in (rear panel) with vref */
11173 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
11174 /* port-C for line-in (rear panel) */
11175 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
11176 /* port-D for Front */
11177 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
11178 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
11179 /* port-E for HP out (front panel) */
11180 /* this has to be set to VREF80 */
11181 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
11182 /* route front PCM to HP */
11183 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
11184 /* port-F for mic-in (front panel) with vref */
11185 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
11186 /* port-G for CLFE (rear panel) */
11187 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
11188 /* port-H for side (rear panel) */
11189 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
11190 /* CD-in */
11191 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
11192 /* route front mic to ADC1*/
11193 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
11194 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11195 /* Unmute DAC0~3 & spdif out*/
11196 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11197 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11198 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11199 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11200 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11201 /* Unmute Mixer 14 (mic) 1c (Line in)*/
11202 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11203 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11204 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11205 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11207 /* Unmute Stereo Mixer 15 */
11208 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11209 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11210 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
11211 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
11213 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11214 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11215 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11216 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11217 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11218 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11219 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11220 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11221 /* hp used DAC 3 (Front) */
11222 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
11223 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
11227 /* additional init verbs for ASUS laptops */
11228 static struct hda_verb alc861_asus_laptop_init_verbs[] = {
11229 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */
11230 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */
11235 * generic initialization of ADC, input mixers and output mixers
11237 static struct hda_verb alc861_auto_init_verbs[] = {
11239 * Unmute ADC0 and set the default input to mic-in
11241 /* {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, */
11242 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11244 /* Unmute DAC0~3 & spdif out*/
11245 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11246 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11247 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11248 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11249 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11251 /* Unmute Mixer 14 (mic) 1c (Line in)*/
11252 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11253 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11254 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11255 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11257 /* Unmute Stereo Mixer 15 */
11258 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11259 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11260 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
11261 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
11263 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11264 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11265 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11266 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11267 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11268 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11269 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11270 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11272 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11273 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11274 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
11275 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
11276 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11277 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11278 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
11279 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
11281 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */
11286 static struct hda_verb alc861_toshiba_init_verbs[] = {
11287 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11292 /* toggle speaker-output according to the hp-jack state */
11293 static void alc861_toshiba_automute(struct hda_codec *codec)
11295 unsigned int present;
11297 present = snd_hda_codec_read(codec, 0x0f, 0,
11298 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
11299 snd_hda_codec_amp_stereo(codec, 0x16, HDA_INPUT, 0,
11300 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
11301 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_INPUT, 3,
11302 HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
11305 static void alc861_toshiba_unsol_event(struct hda_codec *codec,
11306 unsigned int res)
11308 if ((res >> 26) == ALC880_HP_EVENT)
11309 alc861_toshiba_automute(codec);
11312 /* pcm configuration: identiacal with ALC880 */
11313 #define alc861_pcm_analog_playback alc880_pcm_analog_playback
11314 #define alc861_pcm_analog_capture alc880_pcm_analog_capture
11315 #define alc861_pcm_digital_playback alc880_pcm_digital_playback
11316 #define alc861_pcm_digital_capture alc880_pcm_digital_capture
11319 #define ALC861_DIGOUT_NID 0x07
11321 static struct hda_channel_mode alc861_8ch_modes[1] = {
11322 { 8, NULL }
11325 static hda_nid_t alc861_dac_nids[4] = {
11326 /* front, surround, clfe, side */
11327 0x03, 0x06, 0x05, 0x04
11330 static hda_nid_t alc660_dac_nids[3] = {
11331 /* front, clfe, surround */
11332 0x03, 0x05, 0x06
11335 static hda_nid_t alc861_adc_nids[1] = {
11336 /* ADC0-2 */
11337 0x08,
11340 static struct hda_input_mux alc861_capture_source = {
11341 .num_items = 5,
11342 .items = {
11343 { "Mic", 0x0 },
11344 { "Front Mic", 0x3 },
11345 { "Line", 0x1 },
11346 { "CD", 0x4 },
11347 { "Mixer", 0x5 },
11351 /* fill in the dac_nids table from the parsed pin configuration */
11352 static int alc861_auto_fill_dac_nids(struct alc_spec *spec,
11353 const struct auto_pin_cfg *cfg)
11355 int i;
11356 hda_nid_t nid;
11358 spec->multiout.dac_nids = spec->private_dac_nids;
11359 for (i = 0; i < cfg->line_outs; i++) {
11360 nid = cfg->line_out_pins[i];
11361 if (nid) {
11362 if (i >= ARRAY_SIZE(alc861_dac_nids))
11363 continue;
11364 spec->multiout.dac_nids[i] = alc861_dac_nids[i];
11367 spec->multiout.num_dacs = cfg->line_outs;
11368 return 0;
11371 /* add playback controls from the parsed DAC table */
11372 static int alc861_auto_create_multi_out_ctls(struct alc_spec *spec,
11373 const struct auto_pin_cfg *cfg)
11375 char name[32];
11376 static const char *chname[4] = {
11377 "Front", "Surround", NULL /*CLFE*/, "Side"
11379 hda_nid_t nid;
11380 int i, idx, err;
11382 for (i = 0; i < cfg->line_outs; i++) {
11383 nid = spec->multiout.dac_nids[i];
11384 if (!nid)
11385 continue;
11386 if (nid == 0x05) {
11387 /* Center/LFE */
11388 err = add_control(spec, ALC_CTL_BIND_MUTE,
11389 "Center Playback Switch",
11390 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
11391 HDA_OUTPUT));
11392 if (err < 0)
11393 return err;
11394 err = add_control(spec, ALC_CTL_BIND_MUTE,
11395 "LFE Playback Switch",
11396 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
11397 HDA_OUTPUT));
11398 if (err < 0)
11399 return err;
11400 } else {
11401 for (idx = 0; idx < ARRAY_SIZE(alc861_dac_nids) - 1;
11402 idx++)
11403 if (nid == alc861_dac_nids[idx])
11404 break;
11405 sprintf(name, "%s Playback Switch", chname[idx]);
11406 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
11407 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
11408 HDA_OUTPUT));
11409 if (err < 0)
11410 return err;
11413 return 0;
11416 static int alc861_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin)
11418 int err;
11419 hda_nid_t nid;
11421 if (!pin)
11422 return 0;
11424 if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
11425 nid = 0x03;
11426 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
11427 "Headphone Playback Switch",
11428 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
11429 if (err < 0)
11430 return err;
11431 spec->multiout.hp_nid = nid;
11433 return 0;
11436 /* create playback/capture controls for input pins */
11437 static int alc861_auto_create_analog_input_ctls(struct alc_spec *spec,
11438 const struct auto_pin_cfg *cfg)
11440 struct hda_input_mux *imux = &spec->private_imux;
11441 int i, err, idx, idx1;
11443 for (i = 0; i < AUTO_PIN_LAST; i++) {
11444 switch (cfg->input_pins[i]) {
11445 case 0x0c:
11446 idx1 = 1;
11447 idx = 2; /* Line In */
11448 break;
11449 case 0x0f:
11450 idx1 = 2;
11451 idx = 2; /* Line In */
11452 break;
11453 case 0x0d:
11454 idx1 = 0;
11455 idx = 1; /* Mic In */
11456 break;
11457 case 0x10:
11458 idx1 = 3;
11459 idx = 1; /* Mic In */
11460 break;
11461 case 0x11:
11462 idx1 = 4;
11463 idx = 0; /* CD */
11464 break;
11465 default:
11466 continue;
11469 err = new_analog_input(spec, cfg->input_pins[i],
11470 auto_pin_cfg_labels[i], idx, 0x15);
11471 if (err < 0)
11472 return err;
11474 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
11475 imux->items[imux->num_items].index = idx1;
11476 imux->num_items++;
11478 return 0;
11481 static struct snd_kcontrol_new alc861_capture_mixer[] = {
11482 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
11483 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
11486 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11487 /* The multiple "Capture Source" controls confuse alsamixer
11488 * So call somewhat different..
11490 /* .name = "Capture Source", */
11491 .name = "Input Source",
11492 .count = 1,
11493 .info = alc_mux_enum_info,
11494 .get = alc_mux_enum_get,
11495 .put = alc_mux_enum_put,
11497 { } /* end */
11500 static void alc861_auto_set_output_and_unmute(struct hda_codec *codec,
11501 hda_nid_t nid,
11502 int pin_type, int dac_idx)
11504 /* set as output */
11506 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
11507 pin_type);
11508 snd_hda_codec_write(codec, dac_idx, 0, AC_VERB_SET_AMP_GAIN_MUTE,
11509 AMP_OUT_UNMUTE);
11513 static void alc861_auto_init_multi_out(struct hda_codec *codec)
11515 struct alc_spec *spec = codec->spec;
11516 int i;
11518 alc_subsystem_id(codec, 0x0e, 0x0f, 0x0b);
11519 for (i = 0; i < spec->autocfg.line_outs; i++) {
11520 hda_nid_t nid = spec->autocfg.line_out_pins[i];
11521 int pin_type = get_pin_type(spec->autocfg.line_out_type);
11522 if (nid)
11523 alc861_auto_set_output_and_unmute(codec, nid, pin_type,
11524 spec->multiout.dac_nids[i]);
11528 static void alc861_auto_init_hp_out(struct hda_codec *codec)
11530 struct alc_spec *spec = codec->spec;
11531 hda_nid_t pin;
11533 pin = spec->autocfg.hp_pins[0];
11534 if (pin) /* connect to front */
11535 alc861_auto_set_output_and_unmute(codec, pin, PIN_HP,
11536 spec->multiout.dac_nids[0]);
11539 static void alc861_auto_init_analog_input(struct hda_codec *codec)
11541 struct alc_spec *spec = codec->spec;
11542 int i;
11544 for (i = 0; i < AUTO_PIN_LAST; i++) {
11545 hda_nid_t nid = spec->autocfg.input_pins[i];
11546 if (nid >= 0x0c && nid <= 0x11) {
11547 snd_hda_codec_write(codec, nid, 0,
11548 AC_VERB_SET_PIN_WIDGET_CONTROL,
11549 i <= AUTO_PIN_FRONT_MIC ?
11550 PIN_VREF80 : PIN_IN);
11555 /* parse the BIOS configuration and set up the alc_spec */
11556 /* return 1 if successful, 0 if the proper config is not found,
11557 * or a negative error code
11559 static int alc861_parse_auto_config(struct hda_codec *codec)
11561 struct alc_spec *spec = codec->spec;
11562 int err;
11563 static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
11565 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
11566 alc861_ignore);
11567 if (err < 0)
11568 return err;
11569 if (!spec->autocfg.line_outs)
11570 return 0; /* can't find valid BIOS pin config */
11572 err = alc861_auto_fill_dac_nids(spec, &spec->autocfg);
11573 if (err < 0)
11574 return err;
11575 err = alc861_auto_create_multi_out_ctls(spec, &spec->autocfg);
11576 if (err < 0)
11577 return err;
11578 err = alc861_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0]);
11579 if (err < 0)
11580 return err;
11581 err = alc861_auto_create_analog_input_ctls(spec, &spec->autocfg);
11582 if (err < 0)
11583 return err;
11585 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
11587 if (spec->autocfg.dig_out_pin)
11588 spec->multiout.dig_out_nid = ALC861_DIGOUT_NID;
11590 if (spec->kctl_alloc)
11591 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
11593 spec->init_verbs[spec->num_init_verbs++] = alc861_auto_init_verbs;
11595 spec->num_mux_defs = 1;
11596 spec->input_mux = &spec->private_imux;
11598 spec->adc_nids = alc861_adc_nids;
11599 spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
11600 spec->mixers[spec->num_mixers] = alc861_capture_mixer;
11601 spec->num_mixers++;
11603 return 1;
11606 /* additional initialization for auto-configuration model */
11607 static void alc861_auto_init(struct hda_codec *codec)
11609 alc861_auto_init_multi_out(codec);
11610 alc861_auto_init_hp_out(codec);
11611 alc861_auto_init_analog_input(codec);
11614 #ifdef CONFIG_SND_HDA_POWER_SAVE
11615 static struct hda_amp_list alc861_loopbacks[] = {
11616 { 0x15, HDA_INPUT, 0 },
11617 { 0x15, HDA_INPUT, 1 },
11618 { 0x15, HDA_INPUT, 2 },
11619 { 0x15, HDA_INPUT, 3 },
11620 { } /* end */
11622 #endif
11626 * configuration and preset
11628 static const char *alc861_models[ALC861_MODEL_LAST] = {
11629 [ALC861_3ST] = "3stack",
11630 [ALC660_3ST] = "3stack-660",
11631 [ALC861_3ST_DIG] = "3stack-dig",
11632 [ALC861_6ST_DIG] = "6stack-dig",
11633 [ALC861_UNIWILL_M31] = "uniwill-m31",
11634 [ALC861_TOSHIBA] = "toshiba",
11635 [ALC861_ASUS] = "asus",
11636 [ALC861_ASUS_LAPTOP] = "asus-laptop",
11637 [ALC861_AUTO] = "auto",
11640 static struct snd_pci_quirk alc861_cfg_tbl[] = {
11641 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST),
11642 SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP),
11643 SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP),
11644 SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS),
11645 SND_PCI_QUIRK(0x1043, 0x13d7, "ASUS A9rp", ALC861_ASUS_LAPTOP),
11646 SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS P1-AH2", ALC861_3ST_DIG),
11647 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA),
11648 /* FIXME: the entry below breaks Toshiba A100 (model=auto works!)
11649 * Any other models that need this preset?
11651 /* SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA), */
11652 SND_PCI_QUIRK(0x1462, 0x7254, "HP dx2200 (MSI MS-7254)", ALC861_3ST),
11653 SND_PCI_QUIRK(0x1462, 0x7297, "HP dx2250 (MSI MS-7297)", ALC861_3ST),
11654 SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31),
11655 SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31),
11656 SND_PCI_QUIRK(0x1584, 0x9075, "Airis Praxis N1212", ALC861_ASUS_LAPTOP),
11657 /* FIXME: the below seems conflict */
11658 /* SND_PCI_QUIRK(0x1584, 0x9075, "Uniwill", ALC861_UNIWILL_M31), */
11659 SND_PCI_QUIRK(0x1849, 0x0660, "Asrock 939SLI32", ALC660_3ST),
11660 SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST),
11664 static struct alc_config_preset alc861_presets[] = {
11665 [ALC861_3ST] = {
11666 .mixers = { alc861_3ST_mixer },
11667 .init_verbs = { alc861_threestack_init_verbs },
11668 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
11669 .dac_nids = alc861_dac_nids,
11670 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
11671 .channel_mode = alc861_threestack_modes,
11672 .need_dac_fix = 1,
11673 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
11674 .adc_nids = alc861_adc_nids,
11675 .input_mux = &alc861_capture_source,
11677 [ALC861_3ST_DIG] = {
11678 .mixers = { alc861_base_mixer },
11679 .init_verbs = { alc861_threestack_init_verbs },
11680 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
11681 .dac_nids = alc861_dac_nids,
11682 .dig_out_nid = ALC861_DIGOUT_NID,
11683 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
11684 .channel_mode = alc861_threestack_modes,
11685 .need_dac_fix = 1,
11686 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
11687 .adc_nids = alc861_adc_nids,
11688 .input_mux = &alc861_capture_source,
11690 [ALC861_6ST_DIG] = {
11691 .mixers = { alc861_base_mixer },
11692 .init_verbs = { alc861_base_init_verbs },
11693 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
11694 .dac_nids = alc861_dac_nids,
11695 .dig_out_nid = ALC861_DIGOUT_NID,
11696 .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
11697 .channel_mode = alc861_8ch_modes,
11698 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
11699 .adc_nids = alc861_adc_nids,
11700 .input_mux = &alc861_capture_source,
11702 [ALC660_3ST] = {
11703 .mixers = { alc861_3ST_mixer },
11704 .init_verbs = { alc861_threestack_init_verbs },
11705 .num_dacs = ARRAY_SIZE(alc660_dac_nids),
11706 .dac_nids = alc660_dac_nids,
11707 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
11708 .channel_mode = alc861_threestack_modes,
11709 .need_dac_fix = 1,
11710 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
11711 .adc_nids = alc861_adc_nids,
11712 .input_mux = &alc861_capture_source,
11714 [ALC861_UNIWILL_M31] = {
11715 .mixers = { alc861_uniwill_m31_mixer },
11716 .init_verbs = { alc861_uniwill_m31_init_verbs },
11717 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
11718 .dac_nids = alc861_dac_nids,
11719 .dig_out_nid = ALC861_DIGOUT_NID,
11720 .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes),
11721 .channel_mode = alc861_uniwill_m31_modes,
11722 .need_dac_fix = 1,
11723 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
11724 .adc_nids = alc861_adc_nids,
11725 .input_mux = &alc861_capture_source,
11727 [ALC861_TOSHIBA] = {
11728 .mixers = { alc861_toshiba_mixer },
11729 .init_verbs = { alc861_base_init_verbs,
11730 alc861_toshiba_init_verbs },
11731 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
11732 .dac_nids = alc861_dac_nids,
11733 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
11734 .channel_mode = alc883_3ST_2ch_modes,
11735 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
11736 .adc_nids = alc861_adc_nids,
11737 .input_mux = &alc861_capture_source,
11738 .unsol_event = alc861_toshiba_unsol_event,
11739 .init_hook = alc861_toshiba_automute,
11741 [ALC861_ASUS] = {
11742 .mixers = { alc861_asus_mixer },
11743 .init_verbs = { alc861_asus_init_verbs },
11744 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
11745 .dac_nids = alc861_dac_nids,
11746 .dig_out_nid = ALC861_DIGOUT_NID,
11747 .num_channel_mode = ARRAY_SIZE(alc861_asus_modes),
11748 .channel_mode = alc861_asus_modes,
11749 .need_dac_fix = 1,
11750 .hp_nid = 0x06,
11751 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
11752 .adc_nids = alc861_adc_nids,
11753 .input_mux = &alc861_capture_source,
11755 [ALC861_ASUS_LAPTOP] = {
11756 .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer },
11757 .init_verbs = { alc861_asus_init_verbs,
11758 alc861_asus_laptop_init_verbs },
11759 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
11760 .dac_nids = alc861_dac_nids,
11761 .dig_out_nid = ALC861_DIGOUT_NID,
11762 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
11763 .channel_mode = alc883_3ST_2ch_modes,
11764 .need_dac_fix = 1,
11765 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
11766 .adc_nids = alc861_adc_nids,
11767 .input_mux = &alc861_capture_source,
11772 static int patch_alc861(struct hda_codec *codec)
11774 struct alc_spec *spec;
11775 int board_config;
11776 int err;
11778 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
11779 if (spec == NULL)
11780 return -ENOMEM;
11782 codec->spec = spec;
11784 board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST,
11785 alc861_models,
11786 alc861_cfg_tbl);
11788 if (board_config < 0) {
11789 printk(KERN_INFO "hda_codec: Unknown model for ALC861, "
11790 "trying auto-probe from BIOS...\n");
11791 board_config = ALC861_AUTO;
11794 if (board_config == ALC861_AUTO) {
11795 /* automatic parse from the BIOS config */
11796 err = alc861_parse_auto_config(codec);
11797 if (err < 0) {
11798 alc_free(codec);
11799 return err;
11800 } else if (!err) {
11801 printk(KERN_INFO
11802 "hda_codec: Cannot set up configuration "
11803 "from BIOS. Using base mode...\n");
11804 board_config = ALC861_3ST_DIG;
11808 if (board_config != ALC861_AUTO)
11809 setup_preset(spec, &alc861_presets[board_config]);
11811 spec->stream_name_analog = "ALC861 Analog";
11812 spec->stream_analog_playback = &alc861_pcm_analog_playback;
11813 spec->stream_analog_capture = &alc861_pcm_analog_capture;
11815 spec->stream_name_digital = "ALC861 Digital";
11816 spec->stream_digital_playback = &alc861_pcm_digital_playback;
11817 spec->stream_digital_capture = &alc861_pcm_digital_capture;
11819 spec->vmaster_nid = 0x03;
11821 codec->patch_ops = alc_patch_ops;
11822 if (board_config == ALC861_AUTO)
11823 spec->init_hook = alc861_auto_init;
11824 #ifdef CONFIG_SND_HDA_POWER_SAVE
11825 if (!spec->loopback.amplist)
11826 spec->loopback.amplist = alc861_loopbacks;
11827 #endif
11829 return 0;
11833 * ALC861-VD support
11835 * Based on ALC882
11837 * In addition, an independent DAC
11839 #define ALC861VD_DIGOUT_NID 0x06
11841 static hda_nid_t alc861vd_dac_nids[4] = {
11842 /* front, surr, clfe, side surr */
11843 0x02, 0x03, 0x04, 0x05
11846 /* dac_nids for ALC660vd are in a different order - according to
11847 * Realtek's driver.
11848 * This should probably tesult in a different mixer for 6stack models
11849 * of ALC660vd codecs, but for now there is only 3stack mixer
11850 * - and it is the same as in 861vd.
11851 * adc_nids in ALC660vd are (is) the same as in 861vd
11853 static hda_nid_t alc660vd_dac_nids[3] = {
11854 /* front, rear, clfe, rear_surr */
11855 0x02, 0x04, 0x03
11858 static hda_nid_t alc861vd_adc_nids[1] = {
11859 /* ADC0 */
11860 0x09,
11863 /* input MUX */
11864 /* FIXME: should be a matrix-type input source selection */
11865 static struct hda_input_mux alc861vd_capture_source = {
11866 .num_items = 4,
11867 .items = {
11868 { "Mic", 0x0 },
11869 { "Front Mic", 0x1 },
11870 { "Line", 0x2 },
11871 { "CD", 0x4 },
11875 static struct hda_input_mux alc861vd_dallas_capture_source = {
11876 .num_items = 3,
11877 .items = {
11878 { "Front Mic", 0x0 },
11879 { "ATAPI Mic", 0x1 },
11880 { "Line In", 0x5 },
11884 static struct hda_input_mux alc861vd_hp_capture_source = {
11885 .num_items = 2,
11886 .items = {
11887 { "Front Mic", 0x0 },
11888 { "ATAPI Mic", 0x1 },
11892 #define alc861vd_mux_enum_info alc_mux_enum_info
11893 #define alc861vd_mux_enum_get alc_mux_enum_get
11895 static int alc861vd_mux_enum_put(struct snd_kcontrol *kcontrol,
11896 struct snd_ctl_elem_value *ucontrol)
11898 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
11899 struct alc_spec *spec = codec->spec;
11900 const struct hda_input_mux *imux = spec->input_mux;
11901 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
11902 static hda_nid_t capture_mixers[1] = { 0x22 };
11903 hda_nid_t nid = capture_mixers[adc_idx];
11904 unsigned int *cur_val = &spec->cur_mux[adc_idx];
11905 unsigned int i, idx;
11907 idx = ucontrol->value.enumerated.item[0];
11908 if (idx >= imux->num_items)
11909 idx = imux->num_items - 1;
11910 if (*cur_val == idx)
11911 return 0;
11912 for (i = 0; i < imux->num_items; i++) {
11913 unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
11914 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
11915 imux->items[i].index,
11916 HDA_AMP_MUTE, v);
11918 *cur_val = idx;
11919 return 1;
11923 * 2ch mode
11925 static struct hda_channel_mode alc861vd_3stack_2ch_modes[1] = {
11926 { 2, NULL }
11930 * 6ch mode
11932 static struct hda_verb alc861vd_6stack_ch6_init[] = {
11933 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
11934 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11935 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11936 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11937 { } /* end */
11941 * 8ch mode
11943 static struct hda_verb alc861vd_6stack_ch8_init[] = {
11944 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11945 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11946 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11947 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11948 { } /* end */
11951 static struct hda_channel_mode alc861vd_6stack_modes[2] = {
11952 { 6, alc861vd_6stack_ch6_init },
11953 { 8, alc861vd_6stack_ch8_init },
11956 static struct snd_kcontrol_new alc861vd_chmode_mixer[] = {
11958 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11959 .name = "Channel Mode",
11960 .info = alc_ch_mode_info,
11961 .get = alc_ch_mode_get,
11962 .put = alc_ch_mode_put,
11964 { } /* end */
11967 static struct snd_kcontrol_new alc861vd_capture_mixer[] = {
11968 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
11969 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
11972 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11973 /* The multiple "Capture Source" controls confuse alsamixer
11974 * So call somewhat different..
11976 /* .name = "Capture Source", */
11977 .name = "Input Source",
11978 .count = 1,
11979 .info = alc861vd_mux_enum_info,
11980 .get = alc861vd_mux_enum_get,
11981 .put = alc861vd_mux_enum_put,
11983 { } /* end */
11986 /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
11987 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
11989 static struct snd_kcontrol_new alc861vd_6st_mixer[] = {
11990 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
11991 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
11993 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
11994 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
11996 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0,
11997 HDA_OUTPUT),
11998 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0,
11999 HDA_OUTPUT),
12000 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
12001 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
12003 HDA_CODEC_VOLUME("Side Playback Volume", 0x05, 0x0, HDA_OUTPUT),
12004 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
12006 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
12008 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12009 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12010 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12012 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
12013 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
12014 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
12016 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
12017 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
12019 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
12020 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
12022 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
12023 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
12025 { } /* end */
12028 static struct snd_kcontrol_new alc861vd_3st_mixer[] = {
12029 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12030 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
12032 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
12034 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12035 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12036 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12038 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
12039 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
12040 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
12042 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
12043 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
12045 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
12046 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
12048 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
12049 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
12051 { } /* end */
12054 static struct snd_kcontrol_new alc861vd_lenovo_mixer[] = {
12055 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12056 /*HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),*/
12057 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12059 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
12061 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12062 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12063 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12065 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
12066 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
12067 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
12069 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
12070 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
12072 { } /* end */
12075 /* Pin assignment: Front=0x14, HP = 0x15,
12076 * Front Mic=0x18, ATAPI Mic = 0x19, Line In = 0x1d
12078 static struct snd_kcontrol_new alc861vd_dallas_mixer[] = {
12079 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12080 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
12081 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
12082 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
12083 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12084 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12085 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
12086 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
12087 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x05, HDA_INPUT),
12088 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x05, HDA_INPUT),
12089 { } /* end */
12092 /* Pin assignment: Speaker=0x14, Line-out = 0x15,
12093 * Front Mic=0x18, ATAPI Mic = 0x19,
12095 static struct snd_kcontrol_new alc861vd_hp_mixer[] = {
12096 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12097 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
12098 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
12099 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
12100 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12101 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12102 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
12103 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
12105 { } /* end */
12109 * generic initialization of ADC, input mixers and output mixers
12111 static struct hda_verb alc861vd_volume_init_verbs[] = {
12113 * Unmute ADC0 and set the default input to mic-in
12115 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
12116 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12118 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of
12119 * the analog-loopback mixer widget
12121 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
12122 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12123 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12124 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
12125 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
12126 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
12128 /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */
12129 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12130 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12131 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
12132 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
12135 * Set up output mixers (0x02 - 0x05)
12137 /* set vol=0 to output mixers */
12138 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12139 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12140 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12141 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12143 /* set up input amps for analog loopback */
12144 /* Amp Indices: DAC = 0, mixer = 1 */
12145 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12146 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12147 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12148 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12149 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12150 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12151 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12152 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12158 * 3-stack pin configuration:
12159 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
12161 static struct hda_verb alc861vd_3stack_init_verbs[] = {
12163 * Set pin mode and muting
12165 /* set front pin widgets 0x14 for output */
12166 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12167 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12168 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
12170 /* Mic (rear) pin: input vref at 80% */
12171 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
12172 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12173 /* Front Mic pin: input vref at 80% */
12174 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
12175 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12176 /* Line In pin: input */
12177 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12178 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12179 /* Line-2 In: Headphone output (output 0 - 0x0c) */
12180 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12181 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12182 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
12183 /* CD pin widget for input */
12184 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12190 * 6-stack pin configuration:
12192 static struct hda_verb alc861vd_6stack_init_verbs[] = {
12194 * Set pin mode and muting
12196 /* set front pin widgets 0x14 for output */
12197 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12198 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12199 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
12201 /* Rear Pin: output 1 (0x0d) */
12202 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12203 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12204 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12205 /* CLFE Pin: output 2 (0x0e) */
12206 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12207 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12208 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
12209 /* Side Pin: output 3 (0x0f) */
12210 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12211 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12212 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
12214 /* Mic (rear) pin: input vref at 80% */
12215 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
12216 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12217 /* Front Mic pin: input vref at 80% */
12218 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
12219 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12220 /* Line In pin: input */
12221 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12222 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12223 /* Line-2 In: Headphone output (output 0 - 0x0c) */
12224 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12225 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12226 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
12227 /* CD pin widget for input */
12228 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12233 static struct hda_verb alc861vd_eapd_verbs[] = {
12234 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
12238 static struct hda_verb alc861vd_lenovo_unsol_verbs[] = {
12239 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12240 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12241 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
12242 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
12243 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12247 /* toggle speaker-output according to the hp-jack state */
12248 static void alc861vd_lenovo_hp_automute(struct hda_codec *codec)
12250 unsigned int present;
12251 unsigned char bits;
12253 present = snd_hda_codec_read(codec, 0x1b, 0,
12254 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12255 bits = present ? HDA_AMP_MUTE : 0;
12256 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
12257 HDA_AMP_MUTE, bits);
12260 static void alc861vd_lenovo_mic_automute(struct hda_codec *codec)
12262 unsigned int present;
12263 unsigned char bits;
12265 present = snd_hda_codec_read(codec, 0x18, 0,
12266 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12267 bits = present ? HDA_AMP_MUTE : 0;
12268 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
12269 HDA_AMP_MUTE, bits);
12272 static void alc861vd_lenovo_automute(struct hda_codec *codec)
12274 alc861vd_lenovo_hp_automute(codec);
12275 alc861vd_lenovo_mic_automute(codec);
12278 static void alc861vd_lenovo_unsol_event(struct hda_codec *codec,
12279 unsigned int res)
12281 switch (res >> 26) {
12282 case ALC880_HP_EVENT:
12283 alc861vd_lenovo_hp_automute(codec);
12284 break;
12285 case ALC880_MIC_EVENT:
12286 alc861vd_lenovo_mic_automute(codec);
12287 break;
12291 static struct hda_verb alc861vd_dallas_verbs[] = {
12292 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12293 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12294 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12295 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12297 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12298 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12299 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12300 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12301 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12302 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12303 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12304 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12306 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12307 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12308 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12309 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12310 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12311 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12312 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12313 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12315 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
12316 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12317 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
12318 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12319 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12320 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12321 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12322 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12324 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12325 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
12326 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
12327 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
12329 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12330 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
12331 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
12333 { } /* end */
12336 /* toggle speaker-output according to the hp-jack state */
12337 static void alc861vd_dallas_automute(struct hda_codec *codec)
12339 unsigned int present;
12341 present = snd_hda_codec_read(codec, 0x15, 0,
12342 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12343 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
12344 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
12347 static void alc861vd_dallas_unsol_event(struct hda_codec *codec, unsigned int res)
12349 if ((res >> 26) == ALC880_HP_EVENT)
12350 alc861vd_dallas_automute(codec);
12353 #ifdef CONFIG_SND_HDA_POWER_SAVE
12354 #define alc861vd_loopbacks alc880_loopbacks
12355 #endif
12357 /* pcm configuration: identiacal with ALC880 */
12358 #define alc861vd_pcm_analog_playback alc880_pcm_analog_playback
12359 #define alc861vd_pcm_analog_capture alc880_pcm_analog_capture
12360 #define alc861vd_pcm_digital_playback alc880_pcm_digital_playback
12361 #define alc861vd_pcm_digital_capture alc880_pcm_digital_capture
12364 * configuration and preset
12366 static const char *alc861vd_models[ALC861VD_MODEL_LAST] = {
12367 [ALC660VD_3ST] = "3stack-660",
12368 [ALC660VD_3ST_DIG] = "3stack-660-digout",
12369 [ALC861VD_3ST] = "3stack",
12370 [ALC861VD_3ST_DIG] = "3stack-digout",
12371 [ALC861VD_6ST_DIG] = "6stack-digout",
12372 [ALC861VD_LENOVO] = "lenovo",
12373 [ALC861VD_DALLAS] = "dallas",
12374 [ALC861VD_HP] = "hp",
12375 [ALC861VD_AUTO] = "auto",
12378 static struct snd_pci_quirk alc861vd_cfg_tbl[] = {
12379 SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST),
12380 SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_HP),
12381 SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST),
12382 SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST),
12383 SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660VD_3ST_DIG),
12384 SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST),
12385 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba A135", ALC861VD_LENOVO),
12386 /*SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),*/ /*lenovo*/
12387 SND_PCI_QUIRK(0x1179, 0xff01, "DALLAS", ALC861VD_DALLAS),
12388 SND_PCI_QUIRK(0x1179, 0xff03, "Toshiba P205", ALC861VD_LENOVO),
12389 SND_PCI_QUIRK(0x1565, 0x820d, "Biostar NF61S SE", ALC861VD_6ST_DIG),
12390 SND_PCI_QUIRK(0x17aa, 0x2066, "Lenovo", ALC861VD_LENOVO),
12391 SND_PCI_QUIRK(0x17aa, 0x3802, "Lenovo 3000 C200", ALC861VD_LENOVO),
12392 SND_PCI_QUIRK(0x1849, 0x0862, "ASRock K8NF6G-VSTA", ALC861VD_6ST_DIG),
12396 static struct alc_config_preset alc861vd_presets[] = {
12397 [ALC660VD_3ST] = {
12398 .mixers = { alc861vd_3st_mixer },
12399 .init_verbs = { alc861vd_volume_init_verbs,
12400 alc861vd_3stack_init_verbs },
12401 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
12402 .dac_nids = alc660vd_dac_nids,
12403 .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
12404 .adc_nids = alc861vd_adc_nids,
12405 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
12406 .channel_mode = alc861vd_3stack_2ch_modes,
12407 .input_mux = &alc861vd_capture_source,
12409 [ALC660VD_3ST_DIG] = {
12410 .mixers = { alc861vd_3st_mixer },
12411 .init_verbs = { alc861vd_volume_init_verbs,
12412 alc861vd_3stack_init_verbs },
12413 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
12414 .dac_nids = alc660vd_dac_nids,
12415 .dig_out_nid = ALC861VD_DIGOUT_NID,
12416 .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
12417 .adc_nids = alc861vd_adc_nids,
12418 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
12419 .channel_mode = alc861vd_3stack_2ch_modes,
12420 .input_mux = &alc861vd_capture_source,
12422 [ALC861VD_3ST] = {
12423 .mixers = { alc861vd_3st_mixer },
12424 .init_verbs = { alc861vd_volume_init_verbs,
12425 alc861vd_3stack_init_verbs },
12426 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
12427 .dac_nids = alc861vd_dac_nids,
12428 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
12429 .channel_mode = alc861vd_3stack_2ch_modes,
12430 .input_mux = &alc861vd_capture_source,
12432 [ALC861VD_3ST_DIG] = {
12433 .mixers = { alc861vd_3st_mixer },
12434 .init_verbs = { alc861vd_volume_init_verbs,
12435 alc861vd_3stack_init_verbs },
12436 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
12437 .dac_nids = alc861vd_dac_nids,
12438 .dig_out_nid = ALC861VD_DIGOUT_NID,
12439 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
12440 .channel_mode = alc861vd_3stack_2ch_modes,
12441 .input_mux = &alc861vd_capture_source,
12443 [ALC861VD_6ST_DIG] = {
12444 .mixers = { alc861vd_6st_mixer, alc861vd_chmode_mixer },
12445 .init_verbs = { alc861vd_volume_init_verbs,
12446 alc861vd_6stack_init_verbs },
12447 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
12448 .dac_nids = alc861vd_dac_nids,
12449 .dig_out_nid = ALC861VD_DIGOUT_NID,
12450 .num_channel_mode = ARRAY_SIZE(alc861vd_6stack_modes),
12451 .channel_mode = alc861vd_6stack_modes,
12452 .input_mux = &alc861vd_capture_source,
12454 [ALC861VD_LENOVO] = {
12455 .mixers = { alc861vd_lenovo_mixer },
12456 .init_verbs = { alc861vd_volume_init_verbs,
12457 alc861vd_3stack_init_verbs,
12458 alc861vd_eapd_verbs,
12459 alc861vd_lenovo_unsol_verbs },
12460 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
12461 .dac_nids = alc660vd_dac_nids,
12462 .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
12463 .adc_nids = alc861vd_adc_nids,
12464 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
12465 .channel_mode = alc861vd_3stack_2ch_modes,
12466 .input_mux = &alc861vd_capture_source,
12467 .unsol_event = alc861vd_lenovo_unsol_event,
12468 .init_hook = alc861vd_lenovo_automute,
12470 [ALC861VD_DALLAS] = {
12471 .mixers = { alc861vd_dallas_mixer },
12472 .init_verbs = { alc861vd_dallas_verbs },
12473 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
12474 .dac_nids = alc861vd_dac_nids,
12475 .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
12476 .adc_nids = alc861vd_adc_nids,
12477 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
12478 .channel_mode = alc861vd_3stack_2ch_modes,
12479 .input_mux = &alc861vd_dallas_capture_source,
12480 .unsol_event = alc861vd_dallas_unsol_event,
12481 .init_hook = alc861vd_dallas_automute,
12483 [ALC861VD_HP] = {
12484 .mixers = { alc861vd_hp_mixer },
12485 .init_verbs = { alc861vd_dallas_verbs, alc861vd_eapd_verbs },
12486 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
12487 .dac_nids = alc861vd_dac_nids,
12488 .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
12489 .dig_out_nid = ALC861VD_DIGOUT_NID,
12490 .adc_nids = alc861vd_adc_nids,
12491 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
12492 .channel_mode = alc861vd_3stack_2ch_modes,
12493 .input_mux = &alc861vd_hp_capture_source,
12494 .unsol_event = alc861vd_dallas_unsol_event,
12495 .init_hook = alc861vd_dallas_automute,
12500 * BIOS auto configuration
12502 static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec,
12503 hda_nid_t nid, int pin_type, int dac_idx)
12505 /* set as output */
12506 snd_hda_codec_write(codec, nid, 0,
12507 AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
12508 snd_hda_codec_write(codec, nid, 0,
12509 AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
12512 static void alc861vd_auto_init_multi_out(struct hda_codec *codec)
12514 struct alc_spec *spec = codec->spec;
12515 int i;
12517 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
12518 for (i = 0; i <= HDA_SIDE; i++) {
12519 hda_nid_t nid = spec->autocfg.line_out_pins[i];
12520 int pin_type = get_pin_type(spec->autocfg.line_out_type);
12521 if (nid)
12522 alc861vd_auto_set_output_and_unmute(codec, nid,
12523 pin_type, i);
12528 static void alc861vd_auto_init_hp_out(struct hda_codec *codec)
12530 struct alc_spec *spec = codec->spec;
12531 hda_nid_t pin;
12533 pin = spec->autocfg.hp_pins[0];
12534 if (pin) /* connect to front and use dac 0 */
12535 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
12538 #define alc861vd_is_input_pin(nid) alc880_is_input_pin(nid)
12539 #define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID
12541 static void alc861vd_auto_init_analog_input(struct hda_codec *codec)
12543 struct alc_spec *spec = codec->spec;
12544 int i;
12546 for (i = 0; i < AUTO_PIN_LAST; i++) {
12547 hda_nid_t nid = spec->autocfg.input_pins[i];
12548 if (alc861vd_is_input_pin(nid)) {
12549 snd_hda_codec_write(codec, nid, 0,
12550 AC_VERB_SET_PIN_WIDGET_CONTROL,
12551 i <= AUTO_PIN_FRONT_MIC ?
12552 PIN_VREF80 : PIN_IN);
12553 if (nid != ALC861VD_PIN_CD_NID)
12554 snd_hda_codec_write(codec, nid, 0,
12555 AC_VERB_SET_AMP_GAIN_MUTE,
12556 AMP_OUT_MUTE);
12561 #define alc861vd_idx_to_mixer_vol(nid) ((nid) + 0x02)
12562 #define alc861vd_idx_to_mixer_switch(nid) ((nid) + 0x0c)
12564 /* add playback controls from the parsed DAC table */
12565 /* Based on ALC880 version. But ALC861VD has separate,
12566 * different NIDs for mute/unmute switch and volume control */
12567 static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
12568 const struct auto_pin_cfg *cfg)
12570 char name[32];
12571 static const char *chname[4] = {"Front", "Surround", "CLFE", "Side"};
12572 hda_nid_t nid_v, nid_s;
12573 int i, err;
12575 for (i = 0; i < cfg->line_outs; i++) {
12576 if (!spec->multiout.dac_nids[i])
12577 continue;
12578 nid_v = alc861vd_idx_to_mixer_vol(
12579 alc880_dac_to_idx(
12580 spec->multiout.dac_nids[i]));
12581 nid_s = alc861vd_idx_to_mixer_switch(
12582 alc880_dac_to_idx(
12583 spec->multiout.dac_nids[i]));
12585 if (i == 2) {
12586 /* Center/LFE */
12587 err = add_control(spec, ALC_CTL_WIDGET_VOL,
12588 "Center Playback Volume",
12589 HDA_COMPOSE_AMP_VAL(nid_v, 1, 0,
12590 HDA_OUTPUT));
12591 if (err < 0)
12592 return err;
12593 err = add_control(spec, ALC_CTL_WIDGET_VOL,
12594 "LFE Playback Volume",
12595 HDA_COMPOSE_AMP_VAL(nid_v, 2, 0,
12596 HDA_OUTPUT));
12597 if (err < 0)
12598 return err;
12599 err = add_control(spec, ALC_CTL_BIND_MUTE,
12600 "Center Playback Switch",
12601 HDA_COMPOSE_AMP_VAL(nid_s, 1, 2,
12602 HDA_INPUT));
12603 if (err < 0)
12604 return err;
12605 err = add_control(spec, ALC_CTL_BIND_MUTE,
12606 "LFE Playback Switch",
12607 HDA_COMPOSE_AMP_VAL(nid_s, 2, 2,
12608 HDA_INPUT));
12609 if (err < 0)
12610 return err;
12611 } else {
12612 sprintf(name, "%s Playback Volume", chname[i]);
12613 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
12614 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0,
12615 HDA_OUTPUT));
12616 if (err < 0)
12617 return err;
12618 sprintf(name, "%s Playback Switch", chname[i]);
12619 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
12620 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2,
12621 HDA_INPUT));
12622 if (err < 0)
12623 return err;
12626 return 0;
12629 /* add playback controls for speaker and HP outputs */
12630 /* Based on ALC880 version. But ALC861VD has separate,
12631 * different NIDs for mute/unmute switch and volume control */
12632 static int alc861vd_auto_create_extra_out(struct alc_spec *spec,
12633 hda_nid_t pin, const char *pfx)
12635 hda_nid_t nid_v, nid_s;
12636 int err;
12637 char name[32];
12639 if (!pin)
12640 return 0;
12642 if (alc880_is_fixed_pin(pin)) {
12643 nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
12644 /* specify the DAC as the extra output */
12645 if (!spec->multiout.hp_nid)
12646 spec->multiout.hp_nid = nid_v;
12647 else
12648 spec->multiout.extra_out_nid[0] = nid_v;
12649 /* control HP volume/switch on the output mixer amp */
12650 nid_v = alc861vd_idx_to_mixer_vol(
12651 alc880_fixed_pin_idx(pin));
12652 nid_s = alc861vd_idx_to_mixer_switch(
12653 alc880_fixed_pin_idx(pin));
12655 sprintf(name, "%s Playback Volume", pfx);
12656 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
12657 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT));
12658 if (err < 0)
12659 return err;
12660 sprintf(name, "%s Playback Switch", pfx);
12661 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
12662 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT));
12663 if (err < 0)
12664 return err;
12665 } else if (alc880_is_multi_pin(pin)) {
12666 /* set manual connection */
12667 /* we have only a switch on HP-out PIN */
12668 sprintf(name, "%s Playback Switch", pfx);
12669 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
12670 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
12671 if (err < 0)
12672 return err;
12674 return 0;
12677 /* parse the BIOS configuration and set up the alc_spec
12678 * return 1 if successful, 0 if the proper config is not found,
12679 * or a negative error code
12680 * Based on ALC880 version - had to change it to override
12681 * alc880_auto_create_extra_out and alc880_auto_create_multi_out_ctls */
12682 static int alc861vd_parse_auto_config(struct hda_codec *codec)
12684 struct alc_spec *spec = codec->spec;
12685 int err;
12686 static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
12688 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
12689 alc861vd_ignore);
12690 if (err < 0)
12691 return err;
12692 if (!spec->autocfg.line_outs)
12693 return 0; /* can't find valid BIOS pin config */
12695 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
12696 if (err < 0)
12697 return err;
12698 err = alc861vd_auto_create_multi_out_ctls(spec, &spec->autocfg);
12699 if (err < 0)
12700 return err;
12701 err = alc861vd_auto_create_extra_out(spec,
12702 spec->autocfg.speaker_pins[0],
12703 "Speaker");
12704 if (err < 0)
12705 return err;
12706 err = alc861vd_auto_create_extra_out(spec,
12707 spec->autocfg.hp_pins[0],
12708 "Headphone");
12709 if (err < 0)
12710 return err;
12711 err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
12712 if (err < 0)
12713 return err;
12715 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
12717 if (spec->autocfg.dig_out_pin)
12718 spec->multiout.dig_out_nid = ALC861VD_DIGOUT_NID;
12720 if (spec->kctl_alloc)
12721 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
12723 spec->init_verbs[spec->num_init_verbs++]
12724 = alc861vd_volume_init_verbs;
12726 spec->num_mux_defs = 1;
12727 spec->input_mux = &spec->private_imux;
12729 err = alc_auto_add_mic_boost(codec);
12730 if (err < 0)
12731 return err;
12733 return 1;
12736 /* additional initialization for auto-configuration model */
12737 static void alc861vd_auto_init(struct hda_codec *codec)
12739 alc861vd_auto_init_multi_out(codec);
12740 alc861vd_auto_init_hp_out(codec);
12741 alc861vd_auto_init_analog_input(codec);
12744 static int patch_alc861vd(struct hda_codec *codec)
12746 struct alc_spec *spec;
12747 int err, board_config;
12749 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
12750 if (spec == NULL)
12751 return -ENOMEM;
12753 codec->spec = spec;
12755 board_config = snd_hda_check_board_config(codec, ALC861VD_MODEL_LAST,
12756 alc861vd_models,
12757 alc861vd_cfg_tbl);
12759 if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) {
12760 printk(KERN_INFO "hda_codec: Unknown model for ALC660VD/"
12761 "ALC861VD, trying auto-probe from BIOS...\n");
12762 board_config = ALC861VD_AUTO;
12765 if (board_config == ALC861VD_AUTO) {
12766 /* automatic parse from the BIOS config */
12767 err = alc861vd_parse_auto_config(codec);
12768 if (err < 0) {
12769 alc_free(codec);
12770 return err;
12771 } else if (!err) {
12772 printk(KERN_INFO
12773 "hda_codec: Cannot set up configuration "
12774 "from BIOS. Using base mode...\n");
12775 board_config = ALC861VD_3ST;
12779 if (board_config != ALC861VD_AUTO)
12780 setup_preset(spec, &alc861vd_presets[board_config]);
12782 spec->stream_name_analog = "ALC861VD Analog";
12783 spec->stream_analog_playback = &alc861vd_pcm_analog_playback;
12784 spec->stream_analog_capture = &alc861vd_pcm_analog_capture;
12786 spec->stream_name_digital = "ALC861VD Digital";
12787 spec->stream_digital_playback = &alc861vd_pcm_digital_playback;
12788 spec->stream_digital_capture = &alc861vd_pcm_digital_capture;
12790 spec->adc_nids = alc861vd_adc_nids;
12791 spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids);
12793 spec->mixers[spec->num_mixers] = alc861vd_capture_mixer;
12794 spec->num_mixers++;
12796 spec->vmaster_nid = 0x02;
12798 codec->patch_ops = alc_patch_ops;
12800 if (board_config == ALC861VD_AUTO)
12801 spec->init_hook = alc861vd_auto_init;
12802 #ifdef CONFIG_SND_HDA_POWER_SAVE
12803 if (!spec->loopback.amplist)
12804 spec->loopback.amplist = alc861vd_loopbacks;
12805 #endif
12807 return 0;
12811 * ALC662 support
12813 * ALC662 is almost identical with ALC880 but has cleaner and more flexible
12814 * configuration. Each pin widget can choose any input DACs and a mixer.
12815 * Each ADC is connected from a mixer of all inputs. This makes possible
12816 * 6-channel independent captures.
12818 * In addition, an independent DAC for the multi-playback (not used in this
12819 * driver yet).
12821 #define ALC662_DIGOUT_NID 0x06
12822 #define ALC662_DIGIN_NID 0x0a
12824 static hda_nid_t alc662_dac_nids[4] = {
12825 /* front, rear, clfe, rear_surr */
12826 0x02, 0x03, 0x04
12829 static hda_nid_t alc662_adc_nids[1] = {
12830 /* ADC1-2 */
12831 0x09,
12833 /* input MUX */
12834 /* FIXME: should be a matrix-type input source selection */
12836 static struct hda_input_mux alc662_capture_source = {
12837 .num_items = 4,
12838 .items = {
12839 { "Mic", 0x0 },
12840 { "Front Mic", 0x1 },
12841 { "Line", 0x2 },
12842 { "CD", 0x4 },
12846 static struct hda_input_mux alc662_lenovo_101e_capture_source = {
12847 .num_items = 2,
12848 .items = {
12849 { "Mic", 0x1 },
12850 { "Line", 0x2 },
12854 static struct hda_input_mux alc662_eeepc_capture_source = {
12855 .num_items = 2,
12856 .items = {
12857 { "i-Mic", 0x1 },
12858 { "e-Mic", 0x0 },
12862 #define alc662_mux_enum_info alc_mux_enum_info
12863 #define alc662_mux_enum_get alc_mux_enum_get
12865 static int alc662_mux_enum_put(struct snd_kcontrol *kcontrol,
12866 struct snd_ctl_elem_value *ucontrol)
12868 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
12869 struct alc_spec *spec = codec->spec;
12870 const struct hda_input_mux *imux = spec->input_mux;
12871 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
12872 static hda_nid_t capture_mixers[2] = { 0x23, 0x22 };
12873 hda_nid_t nid = capture_mixers[adc_idx];
12874 unsigned int *cur_val = &spec->cur_mux[adc_idx];
12875 unsigned int i, idx;
12877 idx = ucontrol->value.enumerated.item[0];
12878 if (idx >= imux->num_items)
12879 idx = imux->num_items - 1;
12880 if (*cur_val == idx)
12881 return 0;
12882 for (i = 0; i < imux->num_items; i++) {
12883 unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
12884 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
12885 imux->items[i].index,
12886 HDA_AMP_MUTE, v);
12888 *cur_val = idx;
12889 return 1;
12892 * 2ch mode
12894 static struct hda_channel_mode alc662_3ST_2ch_modes[1] = {
12895 { 2, NULL }
12899 * 2ch mode
12901 static struct hda_verb alc662_3ST_ch2_init[] = {
12902 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
12903 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
12904 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
12905 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
12906 { } /* end */
12910 * 6ch mode
12912 static struct hda_verb alc662_3ST_ch6_init[] = {
12913 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
12914 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
12915 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
12916 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
12917 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
12918 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
12919 { } /* end */
12922 static struct hda_channel_mode alc662_3ST_6ch_modes[2] = {
12923 { 2, alc662_3ST_ch2_init },
12924 { 6, alc662_3ST_ch6_init },
12928 * 2ch mode
12930 static struct hda_verb alc662_sixstack_ch6_init[] = {
12931 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
12932 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
12933 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
12934 { } /* end */
12938 * 6ch mode
12940 static struct hda_verb alc662_sixstack_ch8_init[] = {
12941 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
12942 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
12943 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
12944 { } /* end */
12947 static struct hda_channel_mode alc662_5stack_modes[2] = {
12948 { 2, alc662_sixstack_ch6_init },
12949 { 6, alc662_sixstack_ch8_init },
12952 /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
12953 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
12956 static struct snd_kcontrol_new alc662_base_mixer[] = {
12957 /* output mixer control */
12958 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
12959 HDA_CODEC_MUTE("Front Playback Switch", 0x02, 0x0, HDA_OUTPUT),
12960 HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT),
12961 HDA_CODEC_MUTE("Surround Playback Switch", 0x03, 0x0, HDA_OUTPUT),
12962 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
12963 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
12964 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT),
12965 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT),
12966 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
12968 /*Input mixer control */
12969 HDA_CODEC_VOLUME("CD Playback Volume", 0xb, 0x4, HDA_INPUT),
12970 HDA_CODEC_MUTE("CD Playback Switch", 0xb, 0x4, HDA_INPUT),
12971 HDA_CODEC_VOLUME("Line Playback Volume", 0xb, 0x02, HDA_INPUT),
12972 HDA_CODEC_MUTE("Line Playback Switch", 0xb, 0x02, HDA_INPUT),
12973 HDA_CODEC_VOLUME("Mic Playback Volume", 0xb, 0x0, HDA_INPUT),
12974 HDA_CODEC_MUTE("Mic Playback Switch", 0xb, 0x0, HDA_INPUT),
12975 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0xb, 0x01, HDA_INPUT),
12976 HDA_CODEC_MUTE("Front Mic Playback Switch", 0xb, 0x01, HDA_INPUT),
12977 { } /* end */
12980 static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = {
12981 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12982 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
12983 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
12984 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
12985 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
12986 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
12987 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
12988 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12989 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12990 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
12991 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
12992 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
12993 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
12994 { } /* end */
12997 static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = {
12998 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12999 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
13000 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
13001 HDA_BIND_MUTE("Surround Playback Switch", 0x03, 2, HDA_INPUT),
13002 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
13003 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
13004 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT),
13005 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT),
13006 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
13007 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
13008 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
13009 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
13010 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
13011 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13012 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
13013 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
13014 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
13015 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
13016 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
13017 { } /* end */
13020 static struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = {
13021 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13022 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
13023 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x03, 0x0, HDA_OUTPUT),
13024 HDA_BIND_MUTE("Speaker Playback Switch", 0x03, 2, HDA_INPUT),
13025 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
13026 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
13027 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
13028 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
13029 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
13030 { } /* end */
13033 static struct snd_kcontrol_new alc662_eeepc_p701_mixer[] = {
13034 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
13036 <<<<<<< HEAD:sound/pci/hda/patch_realtek.c
13037 HDA_CODEC_VOLUME("LineOut Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13038 HDA_CODEC_MUTE("LineOut Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
13039 =======
13040 HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13041 HDA_CODEC_MUTE("Line-Out Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
13042 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a:sound/pci/hda/patch_realtek.c
13044 HDA_CODEC_VOLUME("e-Mic Boost", 0x18, 0, HDA_INPUT),
13045 HDA_CODEC_VOLUME("e-Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13046 HDA_CODEC_MUTE("e-Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
13048 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
13049 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
13050 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
13051 { } /* end */
13054 static struct snd_kcontrol_new alc662_eeepc_ep20_mixer[] = {
13055 <<<<<<< HEAD:sound/pci/hda/patch_realtek.c
13056 HDA_CODEC_VOLUME("LineOut Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13057 HDA_CODEC_MUTE("LineOut Playback Switch", 0x14, 0x0, HDA_OUTPUT),
13058 =======
13059 HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13060 HDA_CODEC_MUTE("Line-Out Playback Switch", 0x14, 0x0, HDA_OUTPUT),
13061 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a:sound/pci/hda/patch_realtek.c
13062 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
13063 HDA_BIND_MUTE("Surround Playback Switch", 0x03, 2, HDA_INPUT),
13064 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
13065 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
13066 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT),
13067 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT),
13068 HDA_CODEC_MUTE("Speaker Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
13069 HDA_BIND_MUTE("MuteCtrl Playback Switch", 0x0c, 2, HDA_INPUT),
13070 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
13071 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
13072 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13073 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
13074 { } /* end */
13077 static struct snd_kcontrol_new alc662_chmode_mixer[] = {
13079 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13080 .name = "Channel Mode",
13081 .info = alc_ch_mode_info,
13082 .get = alc_ch_mode_get,
13083 .put = alc_ch_mode_put,
13085 { } /* end */
13088 static struct hda_verb alc662_init_verbs[] = {
13089 /* ADC: mute amp left and right */
13090 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13091 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
13092 /* Front mixer: unmute input/output amp left and right (volume = 0) */
13094 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13095 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13096 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
13097 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
13098 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
13100 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13101 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13102 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13103 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13104 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13105 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13107 /* Front Pin: output 0 (0x0c) */
13108 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13109 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13111 /* Rear Pin: output 1 (0x0d) */
13112 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13113 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13115 /* CLFE Pin: output 2 (0x0e) */
13116 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13117 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13119 /* Mic (rear) pin: input vref at 80% */
13120 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
13121 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13122 /* Front Mic pin: input vref at 80% */
13123 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
13124 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13125 /* Line In pin: input */
13126 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13127 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13128 /* Line-2 In: Headphone output (output 0 - 0x0c) */
13129 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13130 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13131 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
13132 /* CD pin widget for input */
13133 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13135 /* FIXME: use matrix-type input source selection */
13136 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
13137 /* Input mixer */
13138 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13139 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13140 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13141 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
13143 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13144 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13145 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13146 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
13150 static struct hda_verb alc662_sue_init_verbs[] = {
13151 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
13152 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
13156 static struct hda_verb alc662_eeepc_sue_init_verbs[] = {
13157 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
13158 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
13162 /* Set Unsolicited Event*/
13163 static struct hda_verb alc662_eeepc_ep20_sue_init_verbs[] = {
13164 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13165 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
13170 * generic initialization of ADC, input mixers and output mixers
13172 static struct hda_verb alc662_auto_init_verbs[] = {
13174 * Unmute ADC and set the default input to mic-in
13176 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
13177 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13179 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
13180 * mixer widget
13181 * Note: PASD motherboards uses the Line In 2 as the input for front
13182 * panel mic (mic 2)
13184 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
13185 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13186 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13187 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
13188 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
13189 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
13192 * Set up output mixers (0x0c - 0x0f)
13194 /* set vol=0 to output mixers */
13195 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13196 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13197 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13199 /* set up input amps for analog loopback */
13200 /* Amp Indices: DAC = 0, mixer = 1 */
13201 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13202 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13203 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13204 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13205 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13206 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13209 /* FIXME: use matrix-type input source selection */
13210 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
13211 /* Input mixer */
13212 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13213 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13217 /* capture mixer elements */
13218 static struct snd_kcontrol_new alc662_capture_mixer[] = {
13219 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
13220 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
13222 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13223 /* The multiple "Capture Source" controls confuse alsamixer
13224 * So call somewhat different..
13226 /* .name = "Capture Source", */
13227 .name = "Input Source",
13228 .count = 1,
13229 .info = alc662_mux_enum_info,
13230 .get = alc662_mux_enum_get,
13231 .put = alc662_mux_enum_put,
13233 { } /* end */
13236 static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
13238 unsigned int present;
13239 unsigned char bits;
13241 present = snd_hda_codec_read(codec, 0x14, 0,
13242 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
13243 bits = present ? HDA_AMP_MUTE : 0;
13244 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
13245 HDA_AMP_MUTE, bits);
13248 static void alc662_lenovo_101e_all_automute(struct hda_codec *codec)
13250 unsigned int present;
13251 unsigned char bits;
13253 present = snd_hda_codec_read(codec, 0x1b, 0,
13254 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
13255 bits = present ? HDA_AMP_MUTE : 0;
13256 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
13257 HDA_AMP_MUTE, bits);
13258 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
13259 HDA_AMP_MUTE, bits);
13262 static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec,
13263 unsigned int res)
13265 if ((res >> 26) == ALC880_HP_EVENT)
13266 alc662_lenovo_101e_all_automute(codec);
13267 if ((res >> 26) == ALC880_FRONT_EVENT)
13268 alc662_lenovo_101e_ispeaker_automute(codec);
13271 static void alc662_eeepc_mic_automute(struct hda_codec *codec)
13273 unsigned int present;
13275 present = snd_hda_codec_read(codec, 0x18, 0,
13276 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
13277 snd_hda_codec_write(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
13278 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
13279 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
13280 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
13281 snd_hda_codec_write(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
13282 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
13283 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
13284 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
13287 /* unsolicited event for HP jack sensing */
13288 static void alc662_eeepc_unsol_event(struct hda_codec *codec,
13289 unsigned int res)
13291 if ((res >> 26) == ALC880_HP_EVENT)
13292 alc262_hippo1_automute( codec );
13294 if ((res >> 26) == ALC880_MIC_EVENT)
13295 alc662_eeepc_mic_automute(codec);
13298 static void alc662_eeepc_inithook(struct hda_codec *codec)
13300 alc262_hippo1_automute( codec );
13301 alc662_eeepc_mic_automute(codec);
13304 static void alc662_eeepc_ep20_automute(struct hda_codec *codec)
13306 unsigned int mute;
13307 unsigned int present;
13309 snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
13310 present = snd_hda_codec_read(codec, 0x14, 0,
13311 AC_VERB_GET_PIN_SENSE, 0);
13312 present = (present & 0x80000000) != 0;
13313 if (present) {
13314 /* mute internal speaker */
13315 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
13316 HDA_AMP_MUTE, HDA_AMP_MUTE);
13317 } else {
13318 /* unmute internal speaker if necessary */
13319 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
13320 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
13321 HDA_AMP_MUTE, mute);
13325 /* unsolicited event for HP jack sensing */
13326 static void alc662_eeepc_ep20_unsol_event(struct hda_codec *codec,
13327 unsigned int res)
13329 if ((res >> 26) == ALC880_HP_EVENT)
13330 alc662_eeepc_ep20_automute(codec);
13333 static void alc662_eeepc_ep20_inithook(struct hda_codec *codec)
13335 alc662_eeepc_ep20_automute(codec);
13338 #ifdef CONFIG_SND_HDA_POWER_SAVE
13339 #define alc662_loopbacks alc880_loopbacks
13340 #endif
13343 /* pcm configuration: identiacal with ALC880 */
13344 #define alc662_pcm_analog_playback alc880_pcm_analog_playback
13345 #define alc662_pcm_analog_capture alc880_pcm_analog_capture
13346 #define alc662_pcm_digital_playback alc880_pcm_digital_playback
13347 #define alc662_pcm_digital_capture alc880_pcm_digital_capture
13350 * configuration and preset
13352 static const char *alc662_models[ALC662_MODEL_LAST] = {
13353 [ALC662_3ST_2ch_DIG] = "3stack-dig",
13354 [ALC662_3ST_6ch_DIG] = "3stack-6ch-dig",
13355 [ALC662_3ST_6ch] = "3stack-6ch",
13356 [ALC662_5ST_DIG] = "6stack-dig",
13357 [ALC662_LENOVO_101E] = "lenovo-101e",
13358 [ALC662_ASUS_EEEPC_P701] = "eeepc-p701",
13359 [ALC662_ASUS_EEEPC_EP20] = "eeepc-ep20",
13360 [ALC662_AUTO] = "auto",
13363 static struct snd_pci_quirk alc662_cfg_tbl[] = {
13364 SND_PCI_QUIRK(0x1043, 0x82a1, "ASUS Eeepc", ALC662_ASUS_EEEPC_P701),
13365 SND_PCI_QUIRK(0x1043, 0x82d1, "ASUS Eeepc EP20", ALC662_ASUS_EEEPC_EP20),
13366 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E),
13370 static struct alc_config_preset alc662_presets[] = {
13371 [ALC662_3ST_2ch_DIG] = {
13372 .mixers = { alc662_3ST_2ch_mixer, alc662_capture_mixer },
13373 .init_verbs = { alc662_init_verbs },
13374 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
13375 .dac_nids = alc662_dac_nids,
13376 .dig_out_nid = ALC662_DIGOUT_NID,
13377 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
13378 .adc_nids = alc662_adc_nids,
13379 .dig_in_nid = ALC662_DIGIN_NID,
13380 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
13381 .channel_mode = alc662_3ST_2ch_modes,
13382 .input_mux = &alc662_capture_source,
13384 [ALC662_3ST_6ch_DIG] = {
13385 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer,
13386 alc662_capture_mixer },
13387 .init_verbs = { alc662_init_verbs },
13388 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
13389 .dac_nids = alc662_dac_nids,
13390 .dig_out_nid = ALC662_DIGOUT_NID,
13391 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
13392 .adc_nids = alc662_adc_nids,
13393 .dig_in_nid = ALC662_DIGIN_NID,
13394 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
13395 .channel_mode = alc662_3ST_6ch_modes,
13396 .need_dac_fix = 1,
13397 .input_mux = &alc662_capture_source,
13399 [ALC662_3ST_6ch] = {
13400 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer,
13401 alc662_capture_mixer },
13402 .init_verbs = { alc662_init_verbs },
13403 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
13404 .dac_nids = alc662_dac_nids,
13405 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
13406 .adc_nids = alc662_adc_nids,
13407 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
13408 .channel_mode = alc662_3ST_6ch_modes,
13409 .need_dac_fix = 1,
13410 .input_mux = &alc662_capture_source,
13412 [ALC662_5ST_DIG] = {
13413 .mixers = { alc662_base_mixer, alc662_chmode_mixer,
13414 alc662_capture_mixer },
13415 .init_verbs = { alc662_init_verbs },
13416 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
13417 .dac_nids = alc662_dac_nids,
13418 .dig_out_nid = ALC662_DIGOUT_NID,
13419 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
13420 .adc_nids = alc662_adc_nids,
13421 .dig_in_nid = ALC662_DIGIN_NID,
13422 .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes),
13423 .channel_mode = alc662_5stack_modes,
13424 .input_mux = &alc662_capture_source,
13426 [ALC662_LENOVO_101E] = {
13427 .mixers = { alc662_lenovo_101e_mixer, alc662_capture_mixer },
13428 .init_verbs = { alc662_init_verbs, alc662_sue_init_verbs },
13429 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
13430 .dac_nids = alc662_dac_nids,
13431 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
13432 .adc_nids = alc662_adc_nids,
13433 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
13434 .channel_mode = alc662_3ST_2ch_modes,
13435 .input_mux = &alc662_lenovo_101e_capture_source,
13436 .unsol_event = alc662_lenovo_101e_unsol_event,
13437 .init_hook = alc662_lenovo_101e_all_automute,
13439 [ALC662_ASUS_EEEPC_P701] = {
13440 .mixers = { alc662_eeepc_p701_mixer, alc662_capture_mixer },
13441 .init_verbs = { alc662_init_verbs,
13442 alc662_eeepc_sue_init_verbs },
13443 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
13444 .dac_nids = alc662_dac_nids,
13445 .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
13446 .adc_nids = alc662_adc_nids,
13447 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
13448 .channel_mode = alc662_3ST_2ch_modes,
13449 .input_mux = &alc662_eeepc_capture_source,
13450 .unsol_event = alc662_eeepc_unsol_event,
13451 .init_hook = alc662_eeepc_inithook,
13453 [ALC662_ASUS_EEEPC_EP20] = {
13454 .mixers = { alc662_eeepc_ep20_mixer, alc662_capture_mixer,
13455 alc662_chmode_mixer },
13456 .init_verbs = { alc662_init_verbs,
13457 alc662_eeepc_ep20_sue_init_verbs },
13458 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
13459 .dac_nids = alc662_dac_nids,
13460 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
13461 .adc_nids = alc662_adc_nids,
13462 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
13463 .channel_mode = alc662_3ST_6ch_modes,
13464 .input_mux = &alc662_lenovo_101e_capture_source,
13465 .unsol_event = alc662_eeepc_ep20_unsol_event,
13466 .init_hook = alc662_eeepc_ep20_inithook,
13473 * BIOS auto configuration
13476 /* add playback controls from the parsed DAC table */
13477 static int alc662_auto_create_multi_out_ctls(struct alc_spec *spec,
13478 const struct auto_pin_cfg *cfg)
13480 char name[32];
13481 static const char *chname[4] = {
13482 "Front", "Surround", NULL /*CLFE*/, "Side"
13484 hda_nid_t nid;
13485 int i, err;
13487 for (i = 0; i < cfg->line_outs; i++) {
13488 if (!spec->multiout.dac_nids[i])
13489 continue;
13490 nid = alc880_idx_to_dac(i);
13491 if (i == 2) {
13492 /* Center/LFE */
13493 err = add_control(spec, ALC_CTL_WIDGET_VOL,
13494 "Center Playback Volume",
13495 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
13496 HDA_OUTPUT));
13497 if (err < 0)
13498 return err;
13499 err = add_control(spec, ALC_CTL_WIDGET_VOL,
13500 "LFE Playback Volume",
13501 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
13502 HDA_OUTPUT));
13503 if (err < 0)
13504 return err;
13505 err = add_control(spec, ALC_CTL_BIND_MUTE,
13506 "Center Playback Switch",
13507 HDA_COMPOSE_AMP_VAL(nid, 1, 2,
13508 HDA_INPUT));
13509 if (err < 0)
13510 return err;
13511 err = add_control(spec, ALC_CTL_BIND_MUTE,
13512 "LFE Playback Switch",
13513 HDA_COMPOSE_AMP_VAL(nid, 2, 2,
13514 HDA_INPUT));
13515 if (err < 0)
13516 return err;
13517 } else {
13518 sprintf(name, "%s Playback Volume", chname[i]);
13519 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
13520 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
13521 HDA_OUTPUT));
13522 if (err < 0)
13523 return err;
13524 sprintf(name, "%s Playback Switch", chname[i]);
13525 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
13526 HDA_COMPOSE_AMP_VAL(nid, 3, 2,
13527 HDA_INPUT));
13528 if (err < 0)
13529 return err;
13532 return 0;
13535 /* add playback controls for speaker and HP outputs */
13536 static int alc662_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
13537 const char *pfx)
13539 hda_nid_t nid;
13540 int err;
13541 char name[32];
13543 if (!pin)
13544 return 0;
13546 if (alc880_is_fixed_pin(pin)) {
13547 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
13548 /* printk("DAC nid=%x\n",nid); */
13549 /* specify the DAC as the extra output */
13550 if (!spec->multiout.hp_nid)
13551 spec->multiout.hp_nid = nid;
13552 else
13553 spec->multiout.extra_out_nid[0] = nid;
13554 /* control HP volume/switch on the output mixer amp */
13555 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
13556 sprintf(name, "%s Playback Volume", pfx);
13557 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
13558 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
13559 if (err < 0)
13560 return err;
13561 sprintf(name, "%s Playback Switch", pfx);
13562 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
13563 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
13564 if (err < 0)
13565 return err;
13566 } else if (alc880_is_multi_pin(pin)) {
13567 /* set manual connection */
13568 /* we have only a switch on HP-out PIN */
13569 sprintf(name, "%s Playback Switch", pfx);
13570 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
13571 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
13572 if (err < 0)
13573 return err;
13575 return 0;
13578 /* create playback/capture controls for input pins */
13579 static int alc662_auto_create_analog_input_ctls(struct alc_spec *spec,
13580 const struct auto_pin_cfg *cfg)
13582 struct hda_input_mux *imux = &spec->private_imux;
13583 int i, err, idx;
13585 for (i = 0; i < AUTO_PIN_LAST; i++) {
13586 if (alc880_is_input_pin(cfg->input_pins[i])) {
13587 idx = alc880_input_pin_idx(cfg->input_pins[i]);
13588 err = new_analog_input(spec, cfg->input_pins[i],
13589 auto_pin_cfg_labels[i],
13590 idx, 0x0b);
13591 if (err < 0)
13592 return err;
13593 imux->items[imux->num_items].label =
13594 auto_pin_cfg_labels[i];
13595 imux->items[imux->num_items].index =
13596 alc880_input_pin_idx(cfg->input_pins[i]);
13597 imux->num_items++;
13600 return 0;
13603 static void alc662_auto_set_output_and_unmute(struct hda_codec *codec,
13604 hda_nid_t nid, int pin_type,
13605 int dac_idx)
13607 /* set as output */
13608 snd_hda_codec_write(codec, nid, 0,
13609 AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
13610 snd_hda_codec_write(codec, nid, 0,
13611 AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
13612 /* need the manual connection? */
13613 if (alc880_is_multi_pin(nid)) {
13614 struct alc_spec *spec = codec->spec;
13615 int idx = alc880_multi_pin_idx(nid);
13616 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
13617 AC_VERB_SET_CONNECT_SEL,
13618 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
13622 static void alc662_auto_init_multi_out(struct hda_codec *codec)
13624 struct alc_spec *spec = codec->spec;
13625 int i;
13627 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
13628 for (i = 0; i <= HDA_SIDE; i++) {
13629 hda_nid_t nid = spec->autocfg.line_out_pins[i];
13630 int pin_type = get_pin_type(spec->autocfg.line_out_type);
13631 if (nid)
13632 alc662_auto_set_output_and_unmute(codec, nid, pin_type,
13637 static void alc662_auto_init_hp_out(struct hda_codec *codec)
13639 struct alc_spec *spec = codec->spec;
13640 hda_nid_t pin;
13642 pin = spec->autocfg.hp_pins[0];
13643 if (pin) /* connect to front */
13644 /* use dac 0 */
13645 alc662_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
13648 #define alc662_is_input_pin(nid) alc880_is_input_pin(nid)
13649 #define ALC662_PIN_CD_NID ALC880_PIN_CD_NID
13651 static void alc662_auto_init_analog_input(struct hda_codec *codec)
13653 struct alc_spec *spec = codec->spec;
13654 int i;
13656 for (i = 0; i < AUTO_PIN_LAST; i++) {
13657 hda_nid_t nid = spec->autocfg.input_pins[i];
13658 if (alc662_is_input_pin(nid)) {
13659 snd_hda_codec_write(codec, nid, 0,
13660 AC_VERB_SET_PIN_WIDGET_CONTROL,
13661 (i <= AUTO_PIN_FRONT_MIC ?
13662 PIN_VREF80 : PIN_IN));
13663 if (nid != ALC662_PIN_CD_NID)
13664 snd_hda_codec_write(codec, nid, 0,
13665 AC_VERB_SET_AMP_GAIN_MUTE,
13666 AMP_OUT_MUTE);
13671 static int alc662_parse_auto_config(struct hda_codec *codec)
13673 struct alc_spec *spec = codec->spec;
13674 int err;
13675 static hda_nid_t alc662_ignore[] = { 0x1d, 0 };
13677 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
13678 alc662_ignore);
13679 if (err < 0)
13680 return err;
13681 if (!spec->autocfg.line_outs)
13682 return 0; /* can't find valid BIOS pin config */
13684 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
13685 if (err < 0)
13686 return err;
13687 err = alc662_auto_create_multi_out_ctls(spec, &spec->autocfg);
13688 if (err < 0)
13689 return err;
13690 err = alc662_auto_create_extra_out(spec,
13691 spec->autocfg.speaker_pins[0],
13692 "Speaker");
13693 if (err < 0)
13694 return err;
13695 err = alc662_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
13696 "Headphone");
13697 if (err < 0)
13698 return err;
13699 err = alc662_auto_create_analog_input_ctls(spec, &spec->autocfg);
13700 if (err < 0)
13701 return err;
13703 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
13705 if (spec->autocfg.dig_out_pin)
13706 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
13708 if (spec->kctl_alloc)
13709 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
13711 spec->num_mux_defs = 1;
13712 spec->input_mux = &spec->private_imux;
13714 spec->init_verbs[spec->num_init_verbs++] = alc662_auto_init_verbs;
13715 spec->mixers[spec->num_mixers] = alc662_capture_mixer;
13716 spec->num_mixers++;
13717 return 1;
13720 /* additional initialization for auto-configuration model */
13721 static void alc662_auto_init(struct hda_codec *codec)
13723 alc662_auto_init_multi_out(codec);
13724 alc662_auto_init_hp_out(codec);
13725 alc662_auto_init_analog_input(codec);
13728 static int patch_alc662(struct hda_codec *codec)
13730 struct alc_spec *spec;
13731 int err, board_config;
13733 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
13734 if (!spec)
13735 return -ENOMEM;
13737 codec->spec = spec;
13739 board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST,
13740 alc662_models,
13741 alc662_cfg_tbl);
13742 if (board_config < 0) {
13743 printk(KERN_INFO "hda_codec: Unknown model for ALC662, "
13744 "trying auto-probe from BIOS...\n");
13745 board_config = ALC662_AUTO;
13748 if (board_config == ALC662_AUTO) {
13749 /* automatic parse from the BIOS config */
13750 err = alc662_parse_auto_config(codec);
13751 if (err < 0) {
13752 alc_free(codec);
13753 return err;
13754 } else if (!err) {
13755 printk(KERN_INFO
13756 "hda_codec: Cannot set up configuration "
13757 "from BIOS. Using base mode...\n");
13758 board_config = ALC662_3ST_2ch_DIG;
13762 if (board_config != ALC662_AUTO)
13763 setup_preset(spec, &alc662_presets[board_config]);
13765 spec->stream_name_analog = "ALC662 Analog";
13766 spec->stream_analog_playback = &alc662_pcm_analog_playback;
13767 spec->stream_analog_capture = &alc662_pcm_analog_capture;
13769 spec->stream_name_digital = "ALC662 Digital";
13770 spec->stream_digital_playback = &alc662_pcm_digital_playback;
13771 spec->stream_digital_capture = &alc662_pcm_digital_capture;
13773 if (!spec->adc_nids && spec->input_mux) {
13774 spec->adc_nids = alc662_adc_nids;
13775 spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids);
13778 spec->vmaster_nid = 0x02;
13780 codec->patch_ops = alc_patch_ops;
13781 if (board_config == ALC662_AUTO)
13782 spec->init_hook = alc662_auto_init;
13783 #ifdef CONFIG_SND_HDA_POWER_SAVE
13784 if (!spec->loopback.amplist)
13785 spec->loopback.amplist = alc662_loopbacks;
13786 #endif
13788 return 0;
13792 * patch entries
13794 struct hda_codec_preset snd_hda_preset_realtek[] = {
13795 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
13796 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
13797 { .id = 0x10ec0267, .name = "ALC267", .patch = patch_alc268 },
13798 { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 },
13799 { .id = 0x10ec0269, .name = "ALC269", .patch = patch_alc269 },
13800 { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
13801 .patch = patch_alc861 },
13802 { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
13803 { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
13804 { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
13805 { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2",
13806 .patch = patch_alc883 },
13807 { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
13808 .patch = patch_alc662 },
13809 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
13810 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
13811 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc883 },
13812 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
13813 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc883 },
13814 { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc883 },
13815 {} /* terminator */