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"
35 #define ALC880_FRONT_EVENT 0x01
36 #define ALC880_DCVOL_EVENT 0x02
37 #define ALC880_HP_EVENT 0x04
38 #define ALC880_MIC_EVENT 0x08
40 /* ALC880 board config type */
64 #ifdef CONFIG_SND_DEBUG
68 ALC880_MODEL_LAST /* last tag */
81 #ifdef CONFIG_SND_DEBUG
85 ALC260_MODEL_LAST /* last tag */
95 ALC262_HP_BPC_D7000_WL,
96 ALC262_HP_BPC_D7000_WF,
109 ALC262_MODEL_LAST /* last tag */
119 ALC268_ACER_ASPIRE_ONE,
122 #ifdef CONFIG_SND_DEBUG
126 ALC268_MODEL_LAST /* last tag */
133 ALC269_ASUS_EEEPC_P703,
134 ALC269_ASUS_EEEPC_P901,
138 ALC269_MODEL_LAST /* last tag */
155 /* ALC861-VD models */
177 ALC662_ASUS_EEEPC_P701,
178 ALC662_ASUS_EEEPC_EP20,
217 ALC883_TARGA_2ch_DIG,
220 ALC888_ACER_ASPIRE_4930G,
224 ALC883_LENOVO_101E_2ch,
225 ALC883_LENOVO_NB0763,
226 ALC888_LENOVO_MS7195_DIG,
233 ALC883_FUJITSU_PI2515,
234 ALC888_FUJITSU_XA3530,
235 ALC883_3ST_6ch_INTEL,
243 /* styles of capture selection */
245 CAPT_MUX = 0, /* only mux based */
246 CAPT_MIX, /* only mixer based */
247 CAPT_1MUX_MIX, /* first mux and other mixers */
251 #define GPIO_MASK 0x03
254 /* codec parameterization */
255 struct snd_kcontrol_new *mixers[5]; /* mixer arrays */
256 unsigned int num_mixers;
257 struct snd_kcontrol_new *cap_mixer; /* capture mixer */
258 unsigned int beep_amp; /* beep amp value, set via set_beep_amp() */
260 const struct hda_verb *init_verbs[5]; /* initialization verbs
264 unsigned int num_init_verbs;
266 char *stream_name_analog; /* analog PCM stream */
267 struct hda_pcm_stream *stream_analog_playback;
268 struct hda_pcm_stream *stream_analog_capture;
269 struct hda_pcm_stream *stream_analog_alt_playback;
270 struct hda_pcm_stream *stream_analog_alt_capture;
272 char *stream_name_digital; /* digital PCM stream */
273 struct hda_pcm_stream *stream_digital_playback;
274 struct hda_pcm_stream *stream_digital_capture;
277 struct hda_multi_out multiout; /* playback set-up
278 * max_channels, dacs must be set
279 * dig_out_nid and hp_nid are optional
281 hda_nid_t alt_dac_nid;
282 hda_nid_t slave_dig_outs[3]; /* optional - for auto-parsing */
286 unsigned int num_adc_nids;
288 hda_nid_t *capsrc_nids;
289 hda_nid_t dig_in_nid; /* digital-in NID; optional */
290 int capture_style; /* capture style (CAPT_*) */
293 unsigned int num_mux_defs;
294 const struct hda_input_mux *input_mux;
295 unsigned int cur_mux[3];
298 const struct hda_channel_mode *channel_mode;
299 int num_channel_mode;
302 /* PCM information */
303 struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */
305 /* dynamic controls, init_verbs and input_mux */
306 struct auto_pin_cfg autocfg;
307 struct snd_array kctls;
308 struct hda_input_mux private_imux[3];
309 hda_nid_t private_dac_nids[AUTO_CFG_MAX_OUTS];
312 void (*init_hook)(struct hda_codec *codec);
313 void (*unsol_event)(struct hda_codec *codec, unsigned int res);
315 /* for pin sensing */
316 unsigned int sense_updated: 1;
317 unsigned int jack_present: 1;
318 unsigned int master_sw: 1;
321 unsigned int no_analog :1; /* digital I/O only */
323 /* for virtual master */
324 hda_nid_t vmaster_nid;
325 #ifdef CONFIG_SND_HDA_POWER_SAVE
326 struct hda_loopback_check loopback;
331 unsigned int pll_coef_idx, pll_coef_bit;
333 #ifdef SND_HDA_NEEDS_RESUME
334 #define ALC_MAX_PINS 16
335 unsigned int num_pins;
336 hda_nid_t pin_nids[ALC_MAX_PINS];
337 unsigned int pin_cfgs[ALC_MAX_PINS];
342 * configuration template - to be copied to the spec instance
344 struct alc_config_preset {
345 struct snd_kcontrol_new *mixers[5]; /* should be identical size
348 struct snd_kcontrol_new *cap_mixer; /* capture mixer */
349 const struct hda_verb *init_verbs[5];
350 unsigned int num_dacs;
352 hda_nid_t dig_out_nid; /* optional */
353 hda_nid_t hp_nid; /* optional */
354 hda_nid_t *slave_dig_outs;
355 unsigned int num_adc_nids;
357 hda_nid_t *capsrc_nids;
358 hda_nid_t dig_in_nid;
359 unsigned int num_channel_mode;
360 const struct hda_channel_mode *channel_mode;
362 unsigned int num_mux_defs;
363 const struct hda_input_mux *input_mux;
364 void (*unsol_event)(struct hda_codec *, unsigned int);
365 void (*init_hook)(struct hda_codec *);
366 #ifdef CONFIG_SND_HDA_POWER_SAVE
367 struct hda_amp_list *loopbacks;
375 static int alc_mux_enum_info(struct snd_kcontrol *kcontrol,
376 struct snd_ctl_elem_info *uinfo)
378 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
379 struct alc_spec *spec = codec->spec;
380 unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id);
381 if (mux_idx >= spec->num_mux_defs)
383 return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo);
386 static int alc_mux_enum_get(struct snd_kcontrol *kcontrol,
387 struct snd_ctl_elem_value *ucontrol)
389 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
390 struct alc_spec *spec = codec->spec;
391 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
393 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
397 static int alc_mux_enum_put(struct snd_kcontrol *kcontrol,
398 struct snd_ctl_elem_value *ucontrol)
400 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
401 struct alc_spec *spec = codec->spec;
402 const struct hda_input_mux *imux;
403 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
404 unsigned int mux_idx;
405 hda_nid_t nid = spec->capsrc_nids ?
406 spec->capsrc_nids[adc_idx] : spec->adc_nids[adc_idx];
408 mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx;
409 imux = &spec->input_mux[mux_idx];
411 if (spec->capture_style &&
412 !(spec->capture_style == CAPT_1MUX_MIX && !adc_idx)) {
413 /* Matrix-mixer style (e.g. ALC882) */
414 unsigned int *cur_val = &spec->cur_mux[adc_idx];
417 idx = ucontrol->value.enumerated.item[0];
418 if (idx >= imux->num_items)
419 idx = imux->num_items - 1;
422 for (i = 0; i < imux->num_items; i++) {
423 unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
424 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
425 imux->items[i].index,
431 /* MUX style (e.g. ALC880) */
432 return snd_hda_input_mux_put(codec, imux, ucontrol, nid,
433 &spec->cur_mux[adc_idx]);
438 * channel mode setting
440 static int alc_ch_mode_info(struct snd_kcontrol *kcontrol,
441 struct snd_ctl_elem_info *uinfo)
443 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
444 struct alc_spec *spec = codec->spec;
445 return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
446 spec->num_channel_mode);
449 static int alc_ch_mode_get(struct snd_kcontrol *kcontrol,
450 struct snd_ctl_elem_value *ucontrol)
452 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
453 struct alc_spec *spec = codec->spec;
454 return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
455 spec->num_channel_mode,
456 spec->multiout.max_channels);
459 static int alc_ch_mode_put(struct snd_kcontrol *kcontrol,
460 struct snd_ctl_elem_value *ucontrol)
462 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
463 struct alc_spec *spec = codec->spec;
464 int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
465 spec->num_channel_mode,
466 &spec->multiout.max_channels);
467 if (err >= 0 && spec->need_dac_fix)
468 spec->multiout.num_dacs = spec->multiout.max_channels / 2;
473 * Control the mode of pin widget settings via the mixer. "pc" is used
474 * instead of "%" to avoid consequences of accidently treating the % as
475 * being part of a format specifier. Maximum allowed length of a value is
476 * 63 characters plus NULL terminator.
478 * Note: some retasking pin complexes seem to ignore requests for input
479 * states other than HiZ (eg: PIN_VREFxx) and revert to HiZ if any of these
480 * are requested. Therefore order this list so that this behaviour will not
481 * cause problems when mixer clients move through the enum sequentially.
482 * NIDs 0x0f and 0x10 have been observed to have this behaviour as of
485 static char *alc_pin_mode_names[] = {
486 "Mic 50pc bias", "Mic 80pc bias",
487 "Line in", "Line out", "Headphone out",
489 static unsigned char alc_pin_mode_values[] = {
490 PIN_VREF50, PIN_VREF80, PIN_IN, PIN_OUT, PIN_HP,
492 /* The control can present all 5 options, or it can limit the options based
493 * in the pin being assumed to be exclusively an input or an output pin. In
494 * addition, "input" pins may or may not process the mic bias option
495 * depending on actual widget capability (NIDs 0x0f and 0x10 don't seem to
496 * accept requests for bias as of chip versions up to March 2006) and/or
497 * wiring in the computer.
499 #define ALC_PIN_DIR_IN 0x00
500 #define ALC_PIN_DIR_OUT 0x01
501 #define ALC_PIN_DIR_INOUT 0x02
502 #define ALC_PIN_DIR_IN_NOMICBIAS 0x03
503 #define ALC_PIN_DIR_INOUT_NOMICBIAS 0x04
505 /* Info about the pin modes supported by the different pin direction modes.
506 * For each direction the minimum and maximum values are given.
508 static signed char alc_pin_mode_dir_info[5][2] = {
509 { 0, 2 }, /* ALC_PIN_DIR_IN */
510 { 3, 4 }, /* ALC_PIN_DIR_OUT */
511 { 0, 4 }, /* ALC_PIN_DIR_INOUT */
512 { 2, 2 }, /* ALC_PIN_DIR_IN_NOMICBIAS */
513 { 2, 4 }, /* ALC_PIN_DIR_INOUT_NOMICBIAS */
515 #define alc_pin_mode_min(_dir) (alc_pin_mode_dir_info[_dir][0])
516 #define alc_pin_mode_max(_dir) (alc_pin_mode_dir_info[_dir][1])
517 #define alc_pin_mode_n_items(_dir) \
518 (alc_pin_mode_max(_dir)-alc_pin_mode_min(_dir)+1)
520 static int alc_pin_mode_info(struct snd_kcontrol *kcontrol,
521 struct snd_ctl_elem_info *uinfo)
523 unsigned int item_num = uinfo->value.enumerated.item;
524 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
526 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
528 uinfo->value.enumerated.items = alc_pin_mode_n_items(dir);
530 if (item_num<alc_pin_mode_min(dir) || item_num>alc_pin_mode_max(dir))
531 item_num = alc_pin_mode_min(dir);
532 strcpy(uinfo->value.enumerated.name, alc_pin_mode_names[item_num]);
536 static int alc_pin_mode_get(struct snd_kcontrol *kcontrol,
537 struct snd_ctl_elem_value *ucontrol)
540 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
541 hda_nid_t nid = kcontrol->private_value & 0xffff;
542 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
543 long *valp = ucontrol->value.integer.value;
544 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
545 AC_VERB_GET_PIN_WIDGET_CONTROL,
548 /* Find enumerated value for current pinctl setting */
549 i = alc_pin_mode_min(dir);
550 while (alc_pin_mode_values[i] != pinctl && i <= alc_pin_mode_max(dir))
552 *valp = i <= alc_pin_mode_max(dir) ? i: alc_pin_mode_min(dir);
556 static int alc_pin_mode_put(struct snd_kcontrol *kcontrol,
557 struct snd_ctl_elem_value *ucontrol)
560 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
561 hda_nid_t nid = kcontrol->private_value & 0xffff;
562 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
563 long val = *ucontrol->value.integer.value;
564 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
565 AC_VERB_GET_PIN_WIDGET_CONTROL,
568 if (val < alc_pin_mode_min(dir) || val > alc_pin_mode_max(dir))
569 val = alc_pin_mode_min(dir);
571 change = pinctl != alc_pin_mode_values[val];
573 /* Set pin mode to that requested */
574 snd_hda_codec_write_cache(codec, nid, 0,
575 AC_VERB_SET_PIN_WIDGET_CONTROL,
576 alc_pin_mode_values[val]);
578 /* Also enable the retasking pin's input/output as required
579 * for the requested pin mode. Enum values of 2 or less are
582 * Dynamically switching the input/output buffers probably
583 * reduces noise slightly (particularly on input) so we'll
584 * do it. However, having both input and output buffers
585 * enabled simultaneously doesn't seem to be problematic if
586 * this turns out to be necessary in the future.
589 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
590 HDA_AMP_MUTE, HDA_AMP_MUTE);
591 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
594 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
595 HDA_AMP_MUTE, HDA_AMP_MUTE);
596 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
603 #define ALC_PIN_MODE(xname, nid, dir) \
604 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
605 .info = alc_pin_mode_info, \
606 .get = alc_pin_mode_get, \
607 .put = alc_pin_mode_put, \
608 .private_value = nid | (dir<<16) }
610 /* A switch control for ALC260 GPIO pins. Multiple GPIOs can be ganged
611 * together using a mask with more than one bit set. This control is
612 * currently used only by the ALC260 test model. At this stage they are not
613 * needed for any "production" models.
615 #ifdef CONFIG_SND_DEBUG
616 #define alc_gpio_data_info snd_ctl_boolean_mono_info
618 static int alc_gpio_data_get(struct snd_kcontrol *kcontrol,
619 struct snd_ctl_elem_value *ucontrol)
621 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
622 hda_nid_t nid = kcontrol->private_value & 0xffff;
623 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
624 long *valp = ucontrol->value.integer.value;
625 unsigned int val = snd_hda_codec_read(codec, nid, 0,
626 AC_VERB_GET_GPIO_DATA, 0x00);
628 *valp = (val & mask) != 0;
631 static int alc_gpio_data_put(struct snd_kcontrol *kcontrol,
632 struct snd_ctl_elem_value *ucontrol)
635 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
636 hda_nid_t nid = kcontrol->private_value & 0xffff;
637 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
638 long val = *ucontrol->value.integer.value;
639 unsigned int gpio_data = snd_hda_codec_read(codec, nid, 0,
640 AC_VERB_GET_GPIO_DATA,
643 /* Set/unset the masked GPIO bit(s) as needed */
644 change = (val == 0 ? 0 : mask) != (gpio_data & mask);
649 snd_hda_codec_write_cache(codec, nid, 0,
650 AC_VERB_SET_GPIO_DATA, gpio_data);
654 #define ALC_GPIO_DATA_SWITCH(xname, nid, mask) \
655 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
656 .info = alc_gpio_data_info, \
657 .get = alc_gpio_data_get, \
658 .put = alc_gpio_data_put, \
659 .private_value = nid | (mask<<16) }
660 #endif /* CONFIG_SND_DEBUG */
662 /* A switch control to allow the enabling of the digital IO pins on the
663 * ALC260. This is incredibly simplistic; the intention of this control is
664 * to provide something in the test model allowing digital outputs to be
665 * identified if present. If models are found which can utilise these
666 * outputs a more complete mixer control can be devised for those models if
669 #ifdef CONFIG_SND_DEBUG
670 #define alc_spdif_ctrl_info snd_ctl_boolean_mono_info
672 static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol,
673 struct snd_ctl_elem_value *ucontrol)
675 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
676 hda_nid_t nid = kcontrol->private_value & 0xffff;
677 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
678 long *valp = ucontrol->value.integer.value;
679 unsigned int val = snd_hda_codec_read(codec, nid, 0,
680 AC_VERB_GET_DIGI_CONVERT_1, 0x00);
682 *valp = (val & mask) != 0;
685 static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol,
686 struct snd_ctl_elem_value *ucontrol)
689 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
690 hda_nid_t nid = kcontrol->private_value & 0xffff;
691 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
692 long val = *ucontrol->value.integer.value;
693 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
694 AC_VERB_GET_DIGI_CONVERT_1,
697 /* Set/unset the masked control bit(s) as needed */
698 change = (val == 0 ? 0 : mask) != (ctrl_data & mask);
703 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1,
708 #define ALC_SPDIF_CTRL_SWITCH(xname, nid, mask) \
709 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
710 .info = alc_spdif_ctrl_info, \
711 .get = alc_spdif_ctrl_get, \
712 .put = alc_spdif_ctrl_put, \
713 .private_value = nid | (mask<<16) }
714 #endif /* CONFIG_SND_DEBUG */
716 /* A switch control to allow the enabling EAPD digital outputs on the ALC26x.
717 * Again, this is only used in the ALC26x test models to help identify when
718 * the EAPD line must be asserted for features to work.
720 #ifdef CONFIG_SND_DEBUG
721 #define alc_eapd_ctrl_info snd_ctl_boolean_mono_info
723 static int alc_eapd_ctrl_get(struct snd_kcontrol *kcontrol,
724 struct snd_ctl_elem_value *ucontrol)
726 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
727 hda_nid_t nid = kcontrol->private_value & 0xffff;
728 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
729 long *valp = ucontrol->value.integer.value;
730 unsigned int val = snd_hda_codec_read(codec, nid, 0,
731 AC_VERB_GET_EAPD_BTLENABLE, 0x00);
733 *valp = (val & mask) != 0;
737 static int alc_eapd_ctrl_put(struct snd_kcontrol *kcontrol,
738 struct snd_ctl_elem_value *ucontrol)
741 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
742 hda_nid_t nid = kcontrol->private_value & 0xffff;
743 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
744 long val = *ucontrol->value.integer.value;
745 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
746 AC_VERB_GET_EAPD_BTLENABLE,
749 /* Set/unset the masked control bit(s) as needed */
750 change = (!val ? 0 : mask) != (ctrl_data & mask);
755 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
761 #define ALC_EAPD_CTRL_SWITCH(xname, nid, mask) \
762 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
763 .info = alc_eapd_ctrl_info, \
764 .get = alc_eapd_ctrl_get, \
765 .put = alc_eapd_ctrl_put, \
766 .private_value = nid | (mask<<16) }
767 #endif /* CONFIG_SND_DEBUG */
771 static void add_mixer(struct alc_spec *spec, struct snd_kcontrol_new *mix)
773 if (snd_BUG_ON(spec->num_mixers >= ARRAY_SIZE(spec->mixers)))
775 spec->mixers[spec->num_mixers++] = mix;
778 static void add_verb(struct alc_spec *spec, const struct hda_verb *verb)
780 if (snd_BUG_ON(spec->num_init_verbs >= ARRAY_SIZE(spec->init_verbs)))
782 spec->init_verbs[spec->num_init_verbs++] = verb;
785 #ifdef CONFIG_PROC_FS
789 static void print_realtek_coef(struct snd_info_buffer *buffer,
790 struct hda_codec *codec, hda_nid_t nid)
796 coeff = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_PROC_COEF, 0);
797 snd_iprintf(buffer, " Processing Coefficient: 0x%02x\n", coeff);
798 coeff = snd_hda_codec_read(codec, nid, 0,
799 AC_VERB_GET_COEF_INDEX, 0);
800 snd_iprintf(buffer, " Coefficient Index: 0x%02x\n", coeff);
803 #define print_realtek_coef NULL
807 * set up from the preset table
809 static void setup_preset(struct alc_spec *spec,
810 const struct alc_config_preset *preset)
814 for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++)
815 add_mixer(spec, preset->mixers[i]);
816 spec->cap_mixer = preset->cap_mixer;
817 for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i];
819 add_verb(spec, preset->init_verbs[i]);
821 spec->channel_mode = preset->channel_mode;
822 spec->num_channel_mode = preset->num_channel_mode;
823 spec->need_dac_fix = preset->need_dac_fix;
825 spec->multiout.max_channels = spec->channel_mode[0].channels;
827 spec->multiout.num_dacs = preset->num_dacs;
828 spec->multiout.dac_nids = preset->dac_nids;
829 spec->multiout.dig_out_nid = preset->dig_out_nid;
830 spec->multiout.slave_dig_outs = preset->slave_dig_outs;
831 spec->multiout.hp_nid = preset->hp_nid;
833 spec->num_mux_defs = preset->num_mux_defs;
834 if (!spec->num_mux_defs)
835 spec->num_mux_defs = 1;
836 spec->input_mux = preset->input_mux;
838 spec->num_adc_nids = preset->num_adc_nids;
839 spec->adc_nids = preset->adc_nids;
840 spec->capsrc_nids = preset->capsrc_nids;
841 spec->dig_in_nid = preset->dig_in_nid;
843 spec->unsol_event = preset->unsol_event;
844 spec->init_hook = preset->init_hook;
845 #ifdef CONFIG_SND_HDA_POWER_SAVE
846 spec->loopback.amplist = preset->loopbacks;
850 /* Enable GPIO mask and set output */
851 static struct hda_verb alc_gpio1_init_verbs[] = {
852 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
853 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
854 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
858 static struct hda_verb alc_gpio2_init_verbs[] = {
859 {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
860 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
861 {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
865 static struct hda_verb alc_gpio3_init_verbs[] = {
866 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
867 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
868 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
873 * Fix hardware PLL issue
874 * On some codecs, the analog PLL gating control must be off while
875 * the default value is 1.
877 static void alc_fix_pll(struct hda_codec *codec)
879 struct alc_spec *spec = codec->spec;
884 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX,
886 val = snd_hda_codec_read(codec, spec->pll_nid, 0,
887 AC_VERB_GET_PROC_COEF, 0);
888 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX,
890 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_PROC_COEF,
891 val & ~(1 << spec->pll_coef_bit));
894 static void alc_fix_pll_init(struct hda_codec *codec, hda_nid_t nid,
895 unsigned int coef_idx, unsigned int coef_bit)
897 struct alc_spec *spec = codec->spec;
899 spec->pll_coef_idx = coef_idx;
900 spec->pll_coef_bit = coef_bit;
904 static void alc_sku_automute(struct hda_codec *codec)
906 struct alc_spec *spec = codec->spec;
907 unsigned int present;
908 unsigned int hp_nid = spec->autocfg.hp_pins[0];
909 unsigned int sp_nid = spec->autocfg.speaker_pins[0];
911 /* need to execute and sync at first */
912 snd_hda_codec_read(codec, hp_nid, 0, AC_VERB_SET_PIN_SENSE, 0);
913 present = snd_hda_codec_read(codec, hp_nid, 0,
914 AC_VERB_GET_PIN_SENSE, 0);
915 spec->jack_present = (present & 0x80000000) != 0;
916 snd_hda_codec_write(codec, sp_nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
917 spec->jack_present ? 0 : PIN_OUT);
920 #if 0 /* it's broken in some acses -- temporarily disabled */
921 static void alc_mic_automute(struct hda_codec *codec)
923 struct alc_spec *spec = codec->spec;
924 unsigned int present;
925 unsigned int mic_nid = spec->autocfg.input_pins[AUTO_PIN_MIC];
926 unsigned int fmic_nid = spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC];
927 unsigned int mix_nid = spec->capsrc_nids[0];
928 unsigned int capsrc_idx_mic, capsrc_idx_fmic;
930 capsrc_idx_mic = mic_nid - 0x18;
931 capsrc_idx_fmic = fmic_nid - 0x18;
932 present = snd_hda_codec_read(codec, mic_nid, 0,
933 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
934 snd_hda_codec_write(codec, mix_nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
935 0x7000 | (capsrc_idx_mic << 8) | (present ? 0 : 0x80));
936 snd_hda_codec_write(codec, mix_nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
937 0x7000 | (capsrc_idx_fmic << 8) | (present ? 0x80 : 0));
938 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, capsrc_idx_fmic,
939 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
942 #define alc_mic_automute(codec) do {} while(0) /* NOP */
943 #endif /* disabled */
945 /* unsolicited event for HP jack sensing */
946 static void alc_sku_unsol_event(struct hda_codec *codec, unsigned int res)
948 if (codec->vendor_id == 0x10ec0880)
952 if (res == ALC880_HP_EVENT)
953 alc_sku_automute(codec);
955 if (res == ALC880_MIC_EVENT)
956 alc_mic_automute(codec);
959 static void alc_inithook(struct hda_codec *codec)
961 alc_sku_automute(codec);
962 alc_mic_automute(codec);
965 /* additional initialization for ALC888 variants */
966 static void alc888_coef_init(struct hda_codec *codec)
970 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 0);
971 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
972 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
973 if ((tmp & 0xf0) == 2)
975 snd_hda_codec_read(codec, 0x20, 0,
976 AC_VERB_SET_PROC_COEF, 0x830);
979 snd_hda_codec_read(codec, 0x20, 0,
980 AC_VERB_SET_PROC_COEF, 0x3030);
983 /* 32-bit subsystem ID for BIOS loading in HD Audio codec.
984 * 31 ~ 16 : Manufacture ID
986 * 7 ~ 0 : Assembly ID
987 * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36
989 static void alc_subsystem_id(struct hda_codec *codec,
990 unsigned int porta, unsigned int porte,
993 unsigned int ass, tmp, i;
995 struct alc_spec *spec = codec->spec;
997 ass = codec->subsystem_id & 0xffff;
998 if ((ass != codec->bus->pci->subsystem_device) && (ass & 1))
1002 * 31~30 : port conetcivity
1005 * 19~16 : Check sum (15:1)
1010 if (codec->vendor_id == 0x10ec0260)
1012 ass = snd_hda_codec_read(codec, nid, 0,
1013 AC_VERB_GET_CONFIG_DEFAULT, 0);
1014 if (!(ass & 1) && !(ass & 0x100000))
1016 if ((ass >> 30) != 1) /* no physical connection */
1021 for (i = 1; i < 16; i++) {
1025 if (((ass >> 16) & 0xf) != tmp)
1031 * 2 : 0 --> Desktop, 1 --> Laptop
1032 * 3~5 : External Amplifier control
1035 tmp = (ass & 0x38) >> 3; /* external Amp control */
1038 snd_hda_sequence_write(codec, alc_gpio1_init_verbs);
1041 snd_hda_sequence_write(codec, alc_gpio2_init_verbs);
1044 snd_hda_sequence_write(codec, alc_gpio3_init_verbs);
1046 case 5: /* set EAPD output high */
1047 switch (codec->vendor_id) {
1049 snd_hda_codec_write(codec, 0x0f, 0,
1050 AC_VERB_SET_EAPD_BTLENABLE, 2);
1051 snd_hda_codec_write(codec, 0x10, 0,
1052 AC_VERB_SET_EAPD_BTLENABLE, 2);
1064 snd_hda_codec_write(codec, 0x14, 0,
1065 AC_VERB_SET_EAPD_BTLENABLE, 2);
1066 snd_hda_codec_write(codec, 0x15, 0,
1067 AC_VERB_SET_EAPD_BTLENABLE, 2);
1070 switch (codec->vendor_id) {
1072 snd_hda_codec_write(codec, 0x1a, 0,
1073 AC_VERB_SET_COEF_INDEX, 7);
1074 tmp = snd_hda_codec_read(codec, 0x1a, 0,
1075 AC_VERB_GET_PROC_COEF, 0);
1076 snd_hda_codec_write(codec, 0x1a, 0,
1077 AC_VERB_SET_COEF_INDEX, 7);
1078 snd_hda_codec_write(codec, 0x1a, 0,
1079 AC_VERB_SET_PROC_COEF,
1089 snd_hda_codec_write(codec, 0x20, 0,
1090 AC_VERB_SET_COEF_INDEX, 7);
1091 tmp = snd_hda_codec_read(codec, 0x20, 0,
1092 AC_VERB_GET_PROC_COEF, 0);
1093 snd_hda_codec_write(codec, 0x20, 0,
1094 AC_VERB_SET_COEF_INDEX, 7);
1095 snd_hda_codec_write(codec, 0x20, 0,
1096 AC_VERB_SET_PROC_COEF,
1100 /*alc888_coef_init(codec);*/ /* called in alc_init() */
1104 snd_hda_codec_write(codec, 0x20, 0,
1105 AC_VERB_SET_COEF_INDEX, 7);
1106 tmp = snd_hda_codec_read(codec, 0x20, 0,
1107 AC_VERB_GET_PROC_COEF, 0);
1108 snd_hda_codec_write(codec, 0x20, 0,
1109 AC_VERB_SET_COEF_INDEX, 7);
1110 snd_hda_codec_write(codec, 0x20, 0,
1111 AC_VERB_SET_PROC_COEF,
1119 /* is laptop or Desktop and enable the function "Mute internal speaker
1120 * when the external headphone out jack is plugged"
1122 if (!(ass & 0x8000))
1125 * 10~8 : Jack location
1126 * 12~11: Headphone out -> 00: PortA, 01: PortE, 02: PortD, 03: Resvered
1128 * 15 : 1 --> enable the function "Mute internal speaker
1129 * when the external headphone out jack is plugged"
1131 if (!spec->autocfg.speaker_pins[0]) {
1132 if (spec->autocfg.line_out_pins[0])
1133 spec->autocfg.speaker_pins[0] =
1134 spec->autocfg.line_out_pins[0];
1139 if (!spec->autocfg.hp_pins[0]) {
1140 tmp = (ass >> 11) & 0x3; /* HP to chassis */
1142 spec->autocfg.hp_pins[0] = porta;
1144 spec->autocfg.hp_pins[0] = porte;
1146 spec->autocfg.hp_pins[0] = portd;
1150 if (spec->autocfg.hp_pins[0])
1151 snd_hda_codec_write(codec, spec->autocfg.hp_pins[0], 0,
1152 AC_VERB_SET_UNSOLICITED_ENABLE,
1153 AC_USRSP_EN | ALC880_HP_EVENT);
1155 #if 0 /* it's broken in some acses -- temporarily disabled */
1156 if (spec->autocfg.input_pins[AUTO_PIN_MIC] &&
1157 spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC])
1158 snd_hda_codec_write(codec,
1159 spec->autocfg.input_pins[AUTO_PIN_MIC], 0,
1160 AC_VERB_SET_UNSOLICITED_ENABLE,
1161 AC_USRSP_EN | ALC880_MIC_EVENT);
1162 #endif /* disabled */
1164 spec->unsol_event = alc_sku_unsol_event;
1168 * Fix-up pin default configurations
1176 static void alc_fix_pincfg(struct hda_codec *codec,
1177 const struct snd_pci_quirk *quirk,
1178 const struct alc_pincfg **pinfix)
1180 const struct alc_pincfg *cfg;
1182 quirk = snd_pci_quirk_lookup(codec->bus->pci, quirk);
1186 cfg = pinfix[quirk->value];
1187 for (; cfg->nid; cfg++) {
1190 for (i = 0; i < 4; i++) {
1191 snd_hda_codec_write(codec, cfg->nid, 0,
1192 AC_VERB_SET_CONFIG_DEFAULT_BYTES_0 + i,
1206 static struct hda_verb alc888_4ST_ch2_intel_init[] = {
1207 /* Mic-in jack as mic in */
1208 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1209 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1210 /* Line-in jack as Line in */
1211 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1212 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1213 /* Line-Out as Front */
1214 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
1221 static struct hda_verb alc888_4ST_ch4_intel_init[] = {
1222 /* Mic-in jack as mic in */
1223 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1224 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1225 /* Line-in jack as Surround */
1226 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1227 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1228 /* Line-Out as Front */
1229 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
1236 static struct hda_verb alc888_4ST_ch6_intel_init[] = {
1237 /* Mic-in jack as CLFE */
1238 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1239 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1240 /* Line-in jack as Surround */
1241 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1242 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1243 /* Line-Out as CLFE (workaround because Mic-in is not loud enough) */
1244 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1251 static struct hda_verb alc888_4ST_ch8_intel_init[] = {
1252 /* Mic-in jack as CLFE */
1253 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1254 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1255 /* Line-in jack as Surround */
1256 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1257 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1258 /* Line-Out as Side */
1259 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1263 static struct hda_channel_mode alc888_4ST_8ch_intel_modes[4] = {
1264 { 2, alc888_4ST_ch2_intel_init },
1265 { 4, alc888_4ST_ch4_intel_init },
1266 { 6, alc888_4ST_ch6_intel_init },
1267 { 8, alc888_4ST_ch8_intel_init },
1271 * ALC888 Fujitsu Siemens Amillo xa3530
1274 static struct hda_verb alc888_fujitsu_xa3530_verbs[] = {
1275 /* Front Mic: set to PIN_IN (empty by default) */
1276 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1277 /* Connect Internal HP to Front */
1278 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1279 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1280 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1281 /* Connect Bass HP to Front */
1282 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1283 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1284 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1285 /* Connect Line-Out side jack (SPDIF) to Side */
1286 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1287 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1288 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1289 /* Connect Mic jack to CLFE */
1290 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1291 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1292 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02},
1293 /* Connect Line-in jack to Surround */
1294 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1295 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1296 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
1297 /* Connect HP out jack to Front */
1298 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1299 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1300 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
1301 /* Enable unsolicited event for HP jack and Line-out jack */
1302 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1303 {0x17, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1307 static void alc888_fujitsu_xa3530_automute(struct hda_codec *codec)
1309 unsigned int present;
1311 /* Line out presence */
1312 present = snd_hda_codec_read(codec, 0x17, 0,
1313 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1314 /* HP out presence */
1315 present = present || snd_hda_codec_read(codec, 0x1b, 0,
1316 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1317 bits = present ? HDA_AMP_MUTE : 0;
1318 /* Toggle internal speakers muting */
1319 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
1320 HDA_AMP_MUTE, bits);
1321 /* Toggle internal bass muting */
1322 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
1323 HDA_AMP_MUTE, bits);
1326 static void alc888_fujitsu_xa3530_unsol_event(struct hda_codec *codec,
1329 if (res >> 26 == ALC880_HP_EVENT)
1330 alc888_fujitsu_xa3530_automute(codec);
1335 * ALC888 Acer Aspire 4930G model
1338 static struct hda_verb alc888_acer_aspire_4930g_verbs[] = {
1339 /* Front Mic: set to PIN_IN (empty by default) */
1340 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1341 /* Unselect Front Mic by default in input mixer 3 */
1342 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
1343 /* Enable unsolicited event for HP jack */
1344 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1345 /* Connect Internal HP to front */
1346 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1347 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1348 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1349 /* Connect HP out to front */
1350 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1351 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1352 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1356 static struct hda_input_mux alc888_2_capture_sources[2] = {
1357 /* Front mic only available on one ADC */
1364 { "Front Mic", 0xb },
1377 static struct snd_kcontrol_new alc888_base_mixer[] = {
1378 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1379 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1380 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1381 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
1382 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
1384 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1385 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1386 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1387 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
1388 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
1389 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1390 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1391 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1392 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1393 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1394 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
1395 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1399 static void alc888_acer_aspire_4930g_automute(struct hda_codec *codec)
1401 unsigned int present;
1403 present = snd_hda_codec_read(codec, 0x15, 0,
1404 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1405 bits = present ? HDA_AMP_MUTE : 0;
1406 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
1407 HDA_AMP_MUTE, bits);
1410 static void alc888_acer_aspire_4930g_unsol_event(struct hda_codec *codec,
1413 if (res >> 26 == ALC880_HP_EVENT)
1414 alc888_acer_aspire_4930g_automute(codec);
1418 * ALC880 3-stack model
1420 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
1421 * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18,
1422 * F-Mic = 0x1b, HP = 0x19
1425 static hda_nid_t alc880_dac_nids[4] = {
1426 /* front, rear, clfe, rear_surr */
1427 0x02, 0x05, 0x04, 0x03
1430 static hda_nid_t alc880_adc_nids[3] = {
1435 /* The datasheet says the node 0x07 is connected from inputs,
1436 * but it shows zero connection in the real implementation on some devices.
1437 * Note: this is a 915GAV bug, fixed on 915GLV
1439 static hda_nid_t alc880_adc_nids_alt[2] = {
1444 #define ALC880_DIGOUT_NID 0x06
1445 #define ALC880_DIGIN_NID 0x0a
1447 static struct hda_input_mux alc880_capture_source = {
1451 { "Front Mic", 0x3 },
1457 /* channel source setting (2/6 channel selection for 3-stack) */
1459 static struct hda_verb alc880_threestack_ch2_init[] = {
1460 /* set line-in to input, mute it */
1461 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1462 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1463 /* set mic-in to input vref 80%, mute it */
1464 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1465 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1470 static struct hda_verb alc880_threestack_ch6_init[] = {
1471 /* set line-in to output, unmute it */
1472 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1473 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1474 /* set mic-in to output, unmute it */
1475 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1476 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1480 static struct hda_channel_mode alc880_threestack_modes[2] = {
1481 { 2, alc880_threestack_ch2_init },
1482 { 6, alc880_threestack_ch6_init },
1485 static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
1486 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1487 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1488 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
1489 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
1490 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1491 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1492 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1493 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1494 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1495 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1496 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1497 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1498 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1499 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1500 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
1501 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
1502 HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
1504 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1505 .name = "Channel Mode",
1506 .info = alc_ch_mode_info,
1507 .get = alc_ch_mode_get,
1508 .put = alc_ch_mode_put,
1513 /* capture mixer elements */
1514 static int alc_cap_vol_info(struct snd_kcontrol *kcontrol,
1515 struct snd_ctl_elem_info *uinfo)
1517 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1518 struct alc_spec *spec = codec->spec;
1521 mutex_lock(&codec->control_mutex);
1522 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0,
1524 err = snd_hda_mixer_amp_volume_info(kcontrol, uinfo);
1525 mutex_unlock(&codec->control_mutex);
1529 static int alc_cap_vol_tlv(struct snd_kcontrol *kcontrol, int op_flag,
1530 unsigned int size, unsigned int __user *tlv)
1532 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1533 struct alc_spec *spec = codec->spec;
1536 mutex_lock(&codec->control_mutex);
1537 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0,
1539 err = snd_hda_mixer_amp_tlv(kcontrol, op_flag, size, tlv);
1540 mutex_unlock(&codec->control_mutex);
1544 typedef int (*getput_call_t)(struct snd_kcontrol *kcontrol,
1545 struct snd_ctl_elem_value *ucontrol);
1547 static int alc_cap_getput_caller(struct snd_kcontrol *kcontrol,
1548 struct snd_ctl_elem_value *ucontrol,
1551 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1552 struct alc_spec *spec = codec->spec;
1553 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
1556 mutex_lock(&codec->control_mutex);
1557 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[adc_idx],
1559 err = func(kcontrol, ucontrol);
1560 mutex_unlock(&codec->control_mutex);
1564 static int alc_cap_vol_get(struct snd_kcontrol *kcontrol,
1565 struct snd_ctl_elem_value *ucontrol)
1567 return alc_cap_getput_caller(kcontrol, ucontrol,
1568 snd_hda_mixer_amp_volume_get);
1571 static int alc_cap_vol_put(struct snd_kcontrol *kcontrol,
1572 struct snd_ctl_elem_value *ucontrol)
1574 return alc_cap_getput_caller(kcontrol, ucontrol,
1575 snd_hda_mixer_amp_volume_put);
1578 /* capture mixer elements */
1579 #define alc_cap_sw_info snd_ctl_boolean_stereo_info
1581 static int alc_cap_sw_get(struct snd_kcontrol *kcontrol,
1582 struct snd_ctl_elem_value *ucontrol)
1584 return alc_cap_getput_caller(kcontrol, ucontrol,
1585 snd_hda_mixer_amp_switch_get);
1588 static int alc_cap_sw_put(struct snd_kcontrol *kcontrol,
1589 struct snd_ctl_elem_value *ucontrol)
1591 return alc_cap_getput_caller(kcontrol, ucontrol,
1592 snd_hda_mixer_amp_switch_put);
1595 #define DEFINE_CAPMIX(num) \
1596 static struct snd_kcontrol_new alc_capture_mixer ## num[] = { \
1598 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1599 .name = "Capture Switch", \
1600 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, \
1602 .info = alc_cap_sw_info, \
1603 .get = alc_cap_sw_get, \
1604 .put = alc_cap_sw_put, \
1607 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1608 .name = "Capture Volume", \
1609 .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE | \
1610 SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
1611 SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK), \
1613 .info = alc_cap_vol_info, \
1614 .get = alc_cap_vol_get, \
1615 .put = alc_cap_vol_put, \
1616 .tlv = { .c = alc_cap_vol_tlv }, \
1619 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1620 /* .name = "Capture Source", */ \
1621 .name = "Input Source", \
1623 .info = alc_mux_enum_info, \
1624 .get = alc_mux_enum_get, \
1625 .put = alc_mux_enum_put, \
1630 /* up to three ADCs */
1637 * ALC880 5-stack model
1639 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d),
1641 * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
1642 * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
1645 /* additional mixers to alc880_three_stack_mixer */
1646 static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
1647 HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1648 HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
1652 /* channel source setting (6/8 channel selection for 5-stack) */
1654 static struct hda_verb alc880_fivestack_ch6_init[] = {
1655 /* set line-in to input, mute it */
1656 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1657 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1662 static struct hda_verb alc880_fivestack_ch8_init[] = {
1663 /* set line-in to output, unmute it */
1664 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1665 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1669 static struct hda_channel_mode alc880_fivestack_modes[2] = {
1670 { 6, alc880_fivestack_ch6_init },
1671 { 8, alc880_fivestack_ch8_init },
1676 * ALC880 6-stack model
1678 * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e),
1679 * Side = 0x05 (0x0f)
1680 * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
1681 * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
1684 static hda_nid_t alc880_6st_dac_nids[4] = {
1685 /* front, rear, clfe, rear_surr */
1686 0x02, 0x03, 0x04, 0x05
1689 static struct hda_input_mux alc880_6stack_capture_source = {
1693 { "Front Mic", 0x1 },
1699 /* fixed 8-channels */
1700 static struct hda_channel_mode alc880_sixstack_modes[1] = {
1704 static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
1705 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1706 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1707 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1708 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
1709 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1710 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1711 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1712 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1713 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
1714 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
1715 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1716 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1717 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1718 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1719 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1720 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1721 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1722 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1724 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1725 .name = "Channel Mode",
1726 .info = alc_ch_mode_info,
1727 .get = alc_ch_mode_get,
1728 .put = alc_ch_mode_put,
1737 * W810 has rear IO for:
1740 * Center/LFE (DAC 04)
1743 * The system also has a pair of internal speakers, and a headphone jack.
1744 * These are both connected to Line2 on the codec, hence to DAC 02.
1746 * There is a variable resistor to control the speaker or headphone
1747 * volume. This is a hardware-only device without a software API.
1749 * Plugging headphones in will disable the internal speakers. This is
1750 * implemented in hardware, not via the driver using jack sense. In
1751 * a similar fashion, plugging into the rear socket marked "front" will
1752 * disable both the speakers and headphones.
1754 * For input, there's a microphone jack, and an "audio in" jack.
1755 * These may not do anything useful with this driver yet, because I
1756 * haven't setup any initialization verbs for these yet...
1759 static hda_nid_t alc880_w810_dac_nids[3] = {
1760 /* front, rear/surround, clfe */
1764 /* fixed 6 channels */
1765 static struct hda_channel_mode alc880_w810_modes[1] = {
1769 /* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
1770 static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
1771 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1772 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1773 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1774 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
1775 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1776 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1777 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1778 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1779 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
1787 * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
1788 * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?),
1792 static hda_nid_t alc880_z71v_dac_nids[1] = {
1795 #define ALC880_Z71V_HP_DAC 0x03
1797 /* fixed 2 channels */
1798 static struct hda_channel_mode alc880_2_jack_modes[1] = {
1802 static struct snd_kcontrol_new alc880_z71v_mixer[] = {
1803 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1804 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1805 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1806 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
1807 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1808 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1809 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1810 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1816 * ALC880 F1734 model
1818 * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
1819 * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
1822 static hda_nid_t alc880_f1734_dac_nids[1] = {
1825 #define ALC880_F1734_HP_DAC 0x02
1827 static struct snd_kcontrol_new alc880_f1734_mixer[] = {
1828 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1829 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
1830 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1831 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
1832 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1833 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1834 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1835 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1839 static struct hda_input_mux alc880_f1734_capture_source = {
1851 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
1852 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
1853 * Mic = 0x18, Line = 0x1a
1856 #define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
1857 #define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
1859 static struct snd_kcontrol_new alc880_asus_mixer[] = {
1860 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1861 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1862 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1863 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
1864 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1865 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1866 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1867 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1868 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1869 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1870 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1871 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1872 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1873 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1875 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1876 .name = "Channel Mode",
1877 .info = alc_ch_mode_info,
1878 .get = alc_ch_mode_get,
1879 .put = alc_ch_mode_put,
1885 * ALC880 ASUS W1V model
1887 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
1888 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
1889 * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
1892 /* additional mixers to alc880_asus_mixer */
1893 static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
1894 HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
1895 HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
1900 static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
1901 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1902 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
1903 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
1904 HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
1905 HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
1906 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
1907 HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
1908 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
1909 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
1914 static struct snd_kcontrol_new alc880_uniwill_mixer[] = {
1915 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1916 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
1917 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1918 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
1919 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1920 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1921 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1922 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1923 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1924 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1925 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1926 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1927 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1928 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1929 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1930 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1932 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1933 .name = "Channel Mode",
1934 .info = alc_ch_mode_info,
1935 .get = alc_ch_mode_get,
1936 .put = alc_ch_mode_put,
1941 static struct snd_kcontrol_new alc880_fujitsu_mixer[] = {
1942 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1943 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
1944 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1945 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
1946 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1947 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1948 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1949 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1950 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1951 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1955 static struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = {
1956 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1957 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
1958 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1959 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
1960 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1961 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1966 * virtual master controls
1970 * slave controls for virtual master
1972 static const char *alc_slave_vols[] = {
1973 "Front Playback Volume",
1974 "Surround Playback Volume",
1975 "Center Playback Volume",
1976 "LFE Playback Volume",
1977 "Side Playback Volume",
1978 "Headphone Playback Volume",
1979 "Speaker Playback Volume",
1980 "Mono Playback Volume",
1981 "Line-Out Playback Volume",
1982 "PCM Playback Volume",
1986 static const char *alc_slave_sws[] = {
1987 "Front Playback Switch",
1988 "Surround Playback Switch",
1989 "Center Playback Switch",
1990 "LFE Playback Switch",
1991 "Side Playback Switch",
1992 "Headphone Playback Switch",
1993 "Speaker Playback Switch",
1994 "Mono Playback Switch",
1995 "IEC958 Playback Switch",
2000 * build control elements
2003 static void alc_free_kctls(struct hda_codec *codec);
2005 /* additional beep mixers; the actual parameters are overwritten at build */
2006 static struct snd_kcontrol_new alc_beep_mixer[] = {
2007 HDA_CODEC_VOLUME("Beep Playback Volume", 0, 0, HDA_INPUT),
2008 HDA_CODEC_MUTE("Beep Playback Switch", 0, 0, HDA_INPUT),
2012 static int alc_build_controls(struct hda_codec *codec)
2014 struct alc_spec *spec = codec->spec;
2018 for (i = 0; i < spec->num_mixers; i++) {
2019 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
2023 if (spec->cap_mixer) {
2024 err = snd_hda_add_new_ctls(codec, spec->cap_mixer);
2028 if (spec->multiout.dig_out_nid) {
2029 err = snd_hda_create_spdif_out_ctls(codec,
2030 spec->multiout.dig_out_nid);
2033 if (!spec->no_analog) {
2034 err = snd_hda_create_spdif_share_sw(codec,
2038 spec->multiout.share_spdif = 1;
2041 if (spec->dig_in_nid) {
2042 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
2047 /* create beep controls if needed */
2048 if (spec->beep_amp) {
2049 struct snd_kcontrol_new *knew;
2050 for (knew = alc_beep_mixer; knew->name; knew++) {
2051 struct snd_kcontrol *kctl;
2052 kctl = snd_ctl_new1(knew, codec);
2055 kctl->private_value = spec->beep_amp;
2056 err = snd_hda_ctl_add(codec, kctl);
2062 /* if we have no master control, let's create it */
2063 if (!spec->no_analog &&
2064 !snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
2065 unsigned int vmaster_tlv[4];
2066 snd_hda_set_vmaster_tlv(codec, spec->vmaster_nid,
2067 HDA_OUTPUT, vmaster_tlv);
2068 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
2069 vmaster_tlv, alc_slave_vols);
2073 if (!spec->no_analog &&
2074 !snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
2075 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
2076 NULL, alc_slave_sws);
2081 alc_free_kctls(codec); /* no longer needed */
2087 * initialize the codec volumes, etc
2091 * generic initialization of ADC, input mixers and output mixers
2093 static struct hda_verb alc880_volume_init_verbs[] = {
2095 * Unmute ADC0-2 and set the default input to mic-in
2097 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
2098 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2099 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
2100 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2101 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
2102 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2104 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
2106 * Note: PASD motherboards uses the Line In 2 as the input for front
2109 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
2110 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2111 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2112 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
2113 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
2114 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
2115 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
2116 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
2119 * Set up output mixers (0x0c - 0x0f)
2121 /* set vol=0 to output mixers */
2122 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2123 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2124 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2125 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2126 /* set up input amps for analog loopback */
2127 /* Amp Indices: DAC = 0, mixer = 1 */
2128 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2129 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2130 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2131 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2132 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2133 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2134 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2135 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2141 * 3-stack pin configuration:
2142 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
2144 static struct hda_verb alc880_pin_3stack_init_verbs[] = {
2146 * preset connection lists of input pins
2147 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
2149 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
2150 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2151 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
2154 * Set pin mode and muting
2156 /* set front pin widgets 0x14 for output */
2157 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2158 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2159 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2160 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2161 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2162 /* Mic2 (as headphone out) for HP output */
2163 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2164 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2165 /* Line In pin widget for input */
2166 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2167 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2168 /* Line2 (as front mic) pin widget for input and vref at 80% */
2169 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2170 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2171 /* CD pin widget for input */
2172 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2178 * 5-stack pin configuration:
2179 * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
2180 * line-in/side = 0x1a, f-mic = 0x1b
2182 static struct hda_verb alc880_pin_5stack_init_verbs[] = {
2184 * preset connection lists of input pins
2185 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
2187 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2188 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
2191 * Set pin mode and muting
2193 /* set pin widgets 0x14-0x17 for output */
2194 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2195 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2196 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2197 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2198 /* unmute pins for output (no gain on this amp) */
2199 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2200 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2201 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2202 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2204 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2205 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2206 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2207 /* Mic2 (as headphone out) for HP output */
2208 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2209 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2210 /* Line In pin widget for input */
2211 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2212 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2213 /* Line2 (as front mic) pin widget for input and vref at 80% */
2214 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2215 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2216 /* CD pin widget for input */
2217 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2223 * W810 pin configuration:
2224 * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
2226 static struct hda_verb alc880_pin_w810_init_verbs[] = {
2227 /* hphone/speaker input selector: front DAC */
2228 {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
2230 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2231 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2232 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2233 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2234 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2235 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2237 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2238 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2244 * Z71V pin configuration:
2245 * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
2247 static struct hda_verb alc880_pin_z71v_init_verbs[] = {
2248 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2249 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2250 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2251 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2253 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2254 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2255 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2256 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2262 * 6-stack pin configuration:
2263 * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18,
2264 * f-mic = 0x19, line = 0x1a, HP = 0x1b
2266 static struct hda_verb alc880_pin_6stack_init_verbs[] = {
2267 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2269 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2270 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2271 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2272 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2273 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2274 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2275 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2276 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2278 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2279 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2280 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2281 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2282 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2283 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2284 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2285 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2286 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2292 * Uniwill pin configuration:
2293 * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19,
2296 static struct hda_verb alc880_uniwill_init_verbs[] = {
2297 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2299 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2300 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2301 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2302 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2303 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2304 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2305 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2306 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2307 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2308 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2309 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2310 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2311 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2312 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2314 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2315 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2316 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2317 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2318 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2319 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2320 /* {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, */
2321 /* {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
2322 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2324 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
2325 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
2332 * HP = 0x14, InternalSpeaker = 0x15, mic = 0x19,
2334 static struct hda_verb alc880_uniwill_p53_init_verbs[] = {
2335 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2337 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2338 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2339 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2340 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2341 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2342 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2343 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2344 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2345 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2346 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2347 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2348 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2350 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2351 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2352 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2353 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2354 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2355 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2357 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
2358 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_DCVOL_EVENT},
2363 static struct hda_verb alc880_beep_init_verbs[] = {
2364 { 0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5) },
2368 /* toggle speaker-output according to the hp-jack state */
2369 static void alc880_uniwill_hp_automute(struct hda_codec *codec)
2371 unsigned int present;
2374 present = snd_hda_codec_read(codec, 0x14, 0,
2375 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
2376 bits = present ? HDA_AMP_MUTE : 0;
2377 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
2378 HDA_AMP_MUTE, bits);
2379 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
2380 HDA_AMP_MUTE, bits);
2383 /* auto-toggle front mic */
2384 static void alc880_uniwill_mic_automute(struct hda_codec *codec)
2386 unsigned int present;
2389 present = snd_hda_codec_read(codec, 0x18, 0,
2390 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
2391 bits = present ? HDA_AMP_MUTE : 0;
2392 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
2395 static void alc880_uniwill_automute(struct hda_codec *codec)
2397 alc880_uniwill_hp_automute(codec);
2398 alc880_uniwill_mic_automute(codec);
2401 static void alc880_uniwill_unsol_event(struct hda_codec *codec,
2404 /* Looks like the unsol event is incompatible with the standard
2405 * definition. 4bit tag is placed at 28 bit!
2407 switch (res >> 28) {
2408 case ALC880_HP_EVENT:
2409 alc880_uniwill_hp_automute(codec);
2411 case ALC880_MIC_EVENT:
2412 alc880_uniwill_mic_automute(codec);
2417 static void alc880_uniwill_p53_hp_automute(struct hda_codec *codec)
2419 unsigned int present;
2422 present = snd_hda_codec_read(codec, 0x14, 0,
2423 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
2424 bits = present ? HDA_AMP_MUTE : 0;
2425 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, HDA_AMP_MUTE, bits);
2428 static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec)
2430 unsigned int present;
2432 present = snd_hda_codec_read(codec, 0x21, 0,
2433 AC_VERB_GET_VOLUME_KNOB_CONTROL, 0);
2434 present &= HDA_AMP_VOLMASK;
2435 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0,
2436 HDA_AMP_VOLMASK, present);
2437 snd_hda_codec_amp_stereo(codec, 0x0d, HDA_OUTPUT, 0,
2438 HDA_AMP_VOLMASK, present);
2441 static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec,
2444 /* Looks like the unsol event is incompatible with the standard
2445 * definition. 4bit tag is placed at 28 bit!
2447 if ((res >> 28) == ALC880_HP_EVENT)
2448 alc880_uniwill_p53_hp_automute(codec);
2449 if ((res >> 28) == ALC880_DCVOL_EVENT)
2450 alc880_uniwill_p53_dcvol_automute(codec);
2454 * F1734 pin configuration:
2455 * HP = 0x14, speaker-out = 0x15, mic = 0x18
2457 static struct hda_verb alc880_pin_f1734_init_verbs[] = {
2458 {0x07, AC_VERB_SET_CONNECT_SEL, 0x01},
2459 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
2460 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
2461 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
2462 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
2464 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2465 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2466 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2467 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2469 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2470 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2471 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
2472 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2473 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2474 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2475 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2476 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2477 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2479 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
2480 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_DCVOL_EVENT},
2486 * ASUS pin configuration:
2487 * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
2489 static struct hda_verb alc880_pin_asus_init_verbs[] = {
2490 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
2491 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
2492 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
2493 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
2495 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2496 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2497 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2498 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2499 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2500 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2501 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2502 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2504 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2505 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2506 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2507 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2508 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2509 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2510 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2511 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2512 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2517 /* Enable GPIO mask and set output */
2518 #define alc880_gpio1_init_verbs alc_gpio1_init_verbs
2519 #define alc880_gpio2_init_verbs alc_gpio2_init_verbs
2521 /* Clevo m520g init */
2522 static struct hda_verb alc880_pin_clevo_init_verbs[] = {
2523 /* headphone output */
2524 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
2526 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2527 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2529 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2530 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2532 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2533 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2534 /* Mic1 (rear panel) */
2535 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2536 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2537 /* Mic2 (front panel) */
2538 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2539 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2541 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2542 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2543 /* change to EAPD mode */
2544 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2545 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
2550 static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
2551 /* change to EAPD mode */
2552 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2553 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
2555 /* Headphone output */
2556 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2558 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2559 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
2561 /* Line In pin widget for input */
2562 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2563 /* CD pin widget for input */
2564 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2565 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2566 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2568 /* change to EAPD mode */
2569 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2570 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
2576 * LG m1 express dual
2579 * Rear Line-In/Out (blue): 0x14
2580 * Build-in Mic-In: 0x15
2582 * HP-Out (green): 0x1b
2583 * Mic-In/Out (red): 0x19
2587 /* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
2588 static hda_nid_t alc880_lg_dac_nids[3] = {
2592 /* seems analog CD is not working */
2593 static struct hda_input_mux alc880_lg_capture_source = {
2598 { "Internal Mic", 0x6 },
2602 /* 2,4,6 channel modes */
2603 static struct hda_verb alc880_lg_ch2_init[] = {
2604 /* set line-in and mic-in to input */
2605 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
2606 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
2610 static struct hda_verb alc880_lg_ch4_init[] = {
2611 /* set line-in to out and mic-in to input */
2612 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
2613 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
2617 static struct hda_verb alc880_lg_ch6_init[] = {
2618 /* set line-in and mic-in to output */
2619 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
2620 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
2624 static struct hda_channel_mode alc880_lg_ch_modes[3] = {
2625 { 2, alc880_lg_ch2_init },
2626 { 4, alc880_lg_ch4_init },
2627 { 6, alc880_lg_ch6_init },
2630 static struct snd_kcontrol_new alc880_lg_mixer[] = {
2631 HDA_CODEC_VOLUME("Front Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
2632 HDA_BIND_MUTE("Front Playback Switch", 0x0f, 2, HDA_INPUT),
2633 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2634 HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
2635 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
2636 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
2637 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
2638 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
2639 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2640 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
2641 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
2642 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
2643 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
2644 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
2646 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2647 .name = "Channel Mode",
2648 .info = alc_ch_mode_info,
2649 .get = alc_ch_mode_get,
2650 .put = alc_ch_mode_put,
2655 static struct hda_verb alc880_lg_init_verbs[] = {
2656 /* set capture source to mic-in */
2657 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2658 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2659 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2660 /* mute all amp mixer inputs */
2661 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
2662 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
2663 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
2664 /* line-in to input */
2665 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2666 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2668 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2669 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2671 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2672 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2673 /* mic-in to input */
2674 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
2675 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2676 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2678 {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
2679 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2680 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2682 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
2686 /* toggle speaker-output according to the hp-jack state */
2687 static void alc880_lg_automute(struct hda_codec *codec)
2689 unsigned int present;
2692 present = snd_hda_codec_read(codec, 0x1b, 0,
2693 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
2694 bits = present ? HDA_AMP_MUTE : 0;
2695 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
2696 HDA_AMP_MUTE, bits);
2699 static void alc880_lg_unsol_event(struct hda_codec *codec, unsigned int res)
2701 /* Looks like the unsol event is incompatible with the standard
2702 * definition. 4bit tag is placed at 28 bit!
2704 if ((res >> 28) == 0x01)
2705 alc880_lg_automute(codec);
2714 * Built-in Mic-In: 0x19
2720 static struct hda_input_mux alc880_lg_lw_capture_source = {
2724 { "Internal Mic", 0x1 },
2729 #define alc880_lg_lw_modes alc880_threestack_modes
2731 static struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
2732 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2733 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2734 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
2735 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
2736 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2737 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2738 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2739 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2740 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2741 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2742 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2743 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2744 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
2745 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
2747 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2748 .name = "Channel Mode",
2749 .info = alc_ch_mode_info,
2750 .get = alc_ch_mode_get,
2751 .put = alc_ch_mode_put,
2756 static struct hda_verb alc880_lg_lw_init_verbs[] = {
2757 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2758 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
2759 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
2761 /* set capture source to mic-in */
2762 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2763 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2764 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2765 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
2767 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2768 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2770 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2771 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2772 /* mic-in to input */
2773 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2774 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2776 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2777 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2779 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
2783 /* toggle speaker-output according to the hp-jack state */
2784 static void alc880_lg_lw_automute(struct hda_codec *codec)
2786 unsigned int present;
2789 present = snd_hda_codec_read(codec, 0x1b, 0,
2790 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
2791 bits = present ? HDA_AMP_MUTE : 0;
2792 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
2793 HDA_AMP_MUTE, bits);
2796 static void alc880_lg_lw_unsol_event(struct hda_codec *codec, unsigned int res)
2798 /* Looks like the unsol event is incompatible with the standard
2799 * definition. 4bit tag is placed at 28 bit!
2801 if ((res >> 28) == 0x01)
2802 alc880_lg_lw_automute(codec);
2805 static struct snd_kcontrol_new alc880_medion_rim_mixer[] = {
2806 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2807 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
2808 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2809 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2810 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2811 HDA_CODEC_MUTE("Internal Playback Switch", 0x0b, 0x1, HDA_INPUT),
2815 static struct hda_input_mux alc880_medion_rim_capture_source = {
2819 { "Internal Mic", 0x1 },
2823 static struct hda_verb alc880_medion_rim_init_verbs[] = {
2824 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2826 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2827 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2829 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2830 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2831 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2832 /* Mic2 (as headphone out) for HP output */
2833 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2834 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2835 /* Internal Speaker */
2836 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2837 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2839 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2840 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
2842 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
2846 /* toggle speaker-output according to the hp-jack state */
2847 static void alc880_medion_rim_automute(struct hda_codec *codec)
2849 unsigned int present;
2852 present = snd_hda_codec_read(codec, 0x14, 0,
2853 AC_VERB_GET_PIN_SENSE, 0)
2854 & AC_PINSENSE_PRESENCE;
2855 bits = present ? HDA_AMP_MUTE : 0;
2856 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
2857 HDA_AMP_MUTE, bits);
2859 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 0);
2861 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 2);
2864 static void alc880_medion_rim_unsol_event(struct hda_codec *codec,
2867 /* Looks like the unsol event is incompatible with the standard
2868 * definition. 4bit tag is placed at 28 bit!
2870 if ((res >> 28) == ALC880_HP_EVENT)
2871 alc880_medion_rim_automute(codec);
2874 #ifdef CONFIG_SND_HDA_POWER_SAVE
2875 static struct hda_amp_list alc880_loopbacks[] = {
2876 { 0x0b, HDA_INPUT, 0 },
2877 { 0x0b, HDA_INPUT, 1 },
2878 { 0x0b, HDA_INPUT, 2 },
2879 { 0x0b, HDA_INPUT, 3 },
2880 { 0x0b, HDA_INPUT, 4 },
2884 static struct hda_amp_list alc880_lg_loopbacks[] = {
2885 { 0x0b, HDA_INPUT, 1 },
2886 { 0x0b, HDA_INPUT, 6 },
2887 { 0x0b, HDA_INPUT, 7 },
2896 static int alc_init(struct hda_codec *codec)
2898 struct alc_spec *spec = codec->spec;
2902 if (codec->vendor_id == 0x10ec0888)
2903 alc888_coef_init(codec);
2905 for (i = 0; i < spec->num_init_verbs; i++)
2906 snd_hda_sequence_write(codec, spec->init_verbs[i]);
2908 if (spec->init_hook)
2909 spec->init_hook(codec);
2914 static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
2916 struct alc_spec *spec = codec->spec;
2918 if (spec->unsol_event)
2919 spec->unsol_event(codec, res);
2922 #ifdef CONFIG_SND_HDA_POWER_SAVE
2923 static int alc_check_power_status(struct hda_codec *codec, hda_nid_t nid)
2925 struct alc_spec *spec = codec->spec;
2926 return snd_hda_check_amp_list_power(codec, &spec->loopback, nid);
2931 * Analog playback callbacks
2933 static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
2934 struct hda_codec *codec,
2935 struct snd_pcm_substream *substream)
2937 struct alc_spec *spec = codec->spec;
2938 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
2942 static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2943 struct hda_codec *codec,
2944 unsigned int stream_tag,
2945 unsigned int format,
2946 struct snd_pcm_substream *substream)
2948 struct alc_spec *spec = codec->spec;
2949 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
2950 stream_tag, format, substream);
2953 static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
2954 struct hda_codec *codec,
2955 struct snd_pcm_substream *substream)
2957 struct alc_spec *spec = codec->spec;
2958 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
2964 static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
2965 struct hda_codec *codec,
2966 struct snd_pcm_substream *substream)
2968 struct alc_spec *spec = codec->spec;
2969 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
2972 static int alc880_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2973 struct hda_codec *codec,
2974 unsigned int stream_tag,
2975 unsigned int format,
2976 struct snd_pcm_substream *substream)
2978 struct alc_spec *spec = codec->spec;
2979 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
2980 stream_tag, format, substream);
2983 static int alc880_dig_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
2984 struct hda_codec *codec,
2985 struct snd_pcm_substream *substream)
2987 struct alc_spec *spec = codec->spec;
2988 return snd_hda_multi_out_dig_cleanup(codec, &spec->multiout);
2991 static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
2992 struct hda_codec *codec,
2993 struct snd_pcm_substream *substream)
2995 struct alc_spec *spec = codec->spec;
2996 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
3002 static int alc880_alt_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
3003 struct hda_codec *codec,
3004 unsigned int stream_tag,
3005 unsigned int format,
3006 struct snd_pcm_substream *substream)
3008 struct alc_spec *spec = codec->spec;
3010 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number + 1],
3011 stream_tag, 0, format);
3015 static int alc880_alt_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
3016 struct hda_codec *codec,
3017 struct snd_pcm_substream *substream)
3019 struct alc_spec *spec = codec->spec;
3021 snd_hda_codec_cleanup_stream(codec,
3022 spec->adc_nids[substream->number + 1]);
3029 static struct hda_pcm_stream alc880_pcm_analog_playback = {
3033 /* NID is set in alc_build_pcms */
3035 .open = alc880_playback_pcm_open,
3036 .prepare = alc880_playback_pcm_prepare,
3037 .cleanup = alc880_playback_pcm_cleanup
3041 static struct hda_pcm_stream alc880_pcm_analog_capture = {
3045 /* NID is set in alc_build_pcms */
3048 static struct hda_pcm_stream alc880_pcm_analog_alt_playback = {
3052 /* NID is set in alc_build_pcms */
3055 static struct hda_pcm_stream alc880_pcm_analog_alt_capture = {
3056 .substreams = 2, /* can be overridden */
3059 /* NID is set in alc_build_pcms */
3061 .prepare = alc880_alt_capture_pcm_prepare,
3062 .cleanup = alc880_alt_capture_pcm_cleanup
3066 static struct hda_pcm_stream alc880_pcm_digital_playback = {
3070 /* NID is set in alc_build_pcms */
3072 .open = alc880_dig_playback_pcm_open,
3073 .close = alc880_dig_playback_pcm_close,
3074 .prepare = alc880_dig_playback_pcm_prepare,
3075 .cleanup = alc880_dig_playback_pcm_cleanup
3079 static struct hda_pcm_stream alc880_pcm_digital_capture = {
3083 /* NID is set in alc_build_pcms */
3086 /* Used by alc_build_pcms to flag that a PCM has no playback stream */
3087 static struct hda_pcm_stream alc_pcm_null_stream = {
3093 static int alc_build_pcms(struct hda_codec *codec)
3095 struct alc_spec *spec = codec->spec;
3096 struct hda_pcm *info = spec->pcm_rec;
3099 codec->num_pcms = 1;
3100 codec->pcm_info = info;
3102 if (spec->no_analog)
3105 info->name = spec->stream_name_analog;
3106 if (spec->stream_analog_playback) {
3107 if (snd_BUG_ON(!spec->multiout.dac_nids))
3109 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
3110 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
3112 if (spec->stream_analog_capture) {
3113 if (snd_BUG_ON(!spec->adc_nids))
3115 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
3116 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
3119 if (spec->channel_mode) {
3120 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
3121 for (i = 0; i < spec->num_channel_mode; i++) {
3122 if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
3123 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
3129 /* SPDIF for stream index #1 */
3130 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
3131 codec->num_pcms = 2;
3132 codec->slave_dig_outs = spec->multiout.slave_dig_outs;
3133 info = spec->pcm_rec + 1;
3134 info->name = spec->stream_name_digital;
3135 if (spec->dig_out_type)
3136 info->pcm_type = spec->dig_out_type;
3138 info->pcm_type = HDA_PCM_TYPE_SPDIF;
3139 if (spec->multiout.dig_out_nid &&
3140 spec->stream_digital_playback) {
3141 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
3142 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
3144 if (spec->dig_in_nid &&
3145 spec->stream_digital_capture) {
3146 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
3147 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
3149 /* FIXME: do we need this for all Realtek codec models? */
3150 codec->spdif_status_reset = 1;
3153 if (spec->no_analog)
3156 /* If the use of more than one ADC is requested for the current
3157 * model, configure a second analog capture-only PCM.
3159 /* Additional Analaog capture for index #2 */
3160 if ((spec->alt_dac_nid && spec->stream_analog_alt_playback) ||
3161 (spec->num_adc_nids > 1 && spec->stream_analog_alt_capture)) {
3162 codec->num_pcms = 3;
3163 info = spec->pcm_rec + 2;
3164 info->name = spec->stream_name_analog;
3165 if (spec->alt_dac_nid) {
3166 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
3167 *spec->stream_analog_alt_playback;
3168 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
3171 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
3172 alc_pcm_null_stream;
3173 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
3175 if (spec->num_adc_nids > 1) {
3176 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
3177 *spec->stream_analog_alt_capture;
3178 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid =
3180 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams =
3181 spec->num_adc_nids - 1;
3183 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
3184 alc_pcm_null_stream;
3185 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = 0;
3192 static void alc_free_kctls(struct hda_codec *codec)
3194 struct alc_spec *spec = codec->spec;
3196 if (spec->kctls.list) {
3197 struct snd_kcontrol_new *kctl = spec->kctls.list;
3199 for (i = 0; i < spec->kctls.used; i++)
3200 kfree(kctl[i].name);
3202 snd_array_free(&spec->kctls);
3205 static void alc_free(struct hda_codec *codec)
3207 struct alc_spec *spec = codec->spec;
3212 alc_free_kctls(codec);
3214 snd_hda_detach_beep_device(codec);
3217 #ifdef SND_HDA_NEEDS_RESUME
3218 static void store_pin_configs(struct hda_codec *codec)
3220 struct alc_spec *spec = codec->spec;
3221 hda_nid_t nid, end_nid;
3223 end_nid = codec->start_nid + codec->num_nodes;
3224 for (nid = codec->start_nid; nid < end_nid; nid++) {
3225 unsigned int wid_caps = get_wcaps(codec, nid);
3226 unsigned int wid_type =
3227 (wid_caps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
3228 if (wid_type != AC_WID_PIN)
3230 if (spec->num_pins >= ARRAY_SIZE(spec->pin_nids))
3232 spec->pin_nids[spec->num_pins] = nid;
3233 spec->pin_cfgs[spec->num_pins] =
3234 snd_hda_codec_read(codec, nid, 0,
3235 AC_VERB_GET_CONFIG_DEFAULT, 0);
3240 static void resume_pin_configs(struct hda_codec *codec)
3242 struct alc_spec *spec = codec->spec;
3245 for (i = 0; i < spec->num_pins; i++) {
3246 hda_nid_t pin_nid = spec->pin_nids[i];
3247 unsigned int pin_config = spec->pin_cfgs[i];
3248 snd_hda_codec_write(codec, pin_nid, 0,
3249 AC_VERB_SET_CONFIG_DEFAULT_BYTES_0,
3250 pin_config & 0x000000ff);
3251 snd_hda_codec_write(codec, pin_nid, 0,
3252 AC_VERB_SET_CONFIG_DEFAULT_BYTES_1,
3253 (pin_config & 0x0000ff00) >> 8);
3254 snd_hda_codec_write(codec, pin_nid, 0,
3255 AC_VERB_SET_CONFIG_DEFAULT_BYTES_2,
3256 (pin_config & 0x00ff0000) >> 16);
3257 snd_hda_codec_write(codec, pin_nid, 0,
3258 AC_VERB_SET_CONFIG_DEFAULT_BYTES_3,
3263 static int alc_resume(struct hda_codec *codec)
3265 resume_pin_configs(codec);
3266 codec->patch_ops.init(codec);
3267 snd_hda_codec_resume_amp(codec);
3268 snd_hda_codec_resume_cache(codec);
3272 #define store_pin_configs(codec)
3277 static struct hda_codec_ops alc_patch_ops = {
3278 .build_controls = alc_build_controls,
3279 .build_pcms = alc_build_pcms,
3282 .unsol_event = alc_unsol_event,
3283 #ifdef SND_HDA_NEEDS_RESUME
3284 .resume = alc_resume,
3286 #ifdef CONFIG_SND_HDA_POWER_SAVE
3287 .check_power_status = alc_check_power_status,
3293 * Test configuration for debugging
3295 * Almost all inputs/outputs are enabled. I/O pins can be configured via
3298 #ifdef CONFIG_SND_DEBUG
3299 static hda_nid_t alc880_test_dac_nids[4] = {
3300 0x02, 0x03, 0x04, 0x05
3303 static struct hda_input_mux alc880_test_capture_source = {
3312 { "Surround", 0x6 },
3316 static struct hda_channel_mode alc880_test_modes[4] = {
3323 static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol,
3324 struct snd_ctl_elem_info *uinfo)
3326 static char *texts[] = {
3327 "N/A", "Line Out", "HP Out",
3328 "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
3330 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
3332 uinfo->value.enumerated.items = 8;
3333 if (uinfo->value.enumerated.item >= 8)
3334 uinfo->value.enumerated.item = 7;
3335 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
3339 static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol,
3340 struct snd_ctl_elem_value *ucontrol)
3342 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3343 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3344 unsigned int pin_ctl, item = 0;
3346 pin_ctl = snd_hda_codec_read(codec, nid, 0,
3347 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3348 if (pin_ctl & AC_PINCTL_OUT_EN) {
3349 if (pin_ctl & AC_PINCTL_HP_EN)
3353 } else if (pin_ctl & AC_PINCTL_IN_EN) {
3354 switch (pin_ctl & AC_PINCTL_VREFEN) {
3355 case AC_PINCTL_VREF_HIZ: item = 3; break;
3356 case AC_PINCTL_VREF_50: item = 4; break;
3357 case AC_PINCTL_VREF_GRD: item = 5; break;
3358 case AC_PINCTL_VREF_80: item = 6; break;
3359 case AC_PINCTL_VREF_100: item = 7; break;
3362 ucontrol->value.enumerated.item[0] = item;
3366 static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol,
3367 struct snd_ctl_elem_value *ucontrol)
3369 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3370 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3371 static unsigned int ctls[] = {
3372 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
3373 AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
3374 AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
3375 AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
3376 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
3377 AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
3379 unsigned int old_ctl, new_ctl;
3381 old_ctl = snd_hda_codec_read(codec, nid, 0,
3382 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3383 new_ctl = ctls[ucontrol->value.enumerated.item[0]];
3384 if (old_ctl != new_ctl) {
3386 snd_hda_codec_write_cache(codec, nid, 0,
3387 AC_VERB_SET_PIN_WIDGET_CONTROL,
3389 val = ucontrol->value.enumerated.item[0] >= 3 ?
3391 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
3398 static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol,
3399 struct snd_ctl_elem_info *uinfo)
3401 static char *texts[] = {
3402 "Front", "Surround", "CLFE", "Side"
3404 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
3406 uinfo->value.enumerated.items = 4;
3407 if (uinfo->value.enumerated.item >= 4)
3408 uinfo->value.enumerated.item = 3;
3409 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
3413 static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol,
3414 struct snd_ctl_elem_value *ucontrol)
3416 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3417 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3420 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
3421 ucontrol->value.enumerated.item[0] = sel & 3;
3425 static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol,
3426 struct snd_ctl_elem_value *ucontrol)
3428 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3429 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3432 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
3433 if (ucontrol->value.enumerated.item[0] != sel) {
3434 sel = ucontrol->value.enumerated.item[0] & 3;
3435 snd_hda_codec_write_cache(codec, nid, 0,
3436 AC_VERB_SET_CONNECT_SEL, sel);
3442 #define PIN_CTL_TEST(xname,nid) { \
3443 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
3445 .info = alc_test_pin_ctl_info, \
3446 .get = alc_test_pin_ctl_get, \
3447 .put = alc_test_pin_ctl_put, \
3448 .private_value = nid \
3451 #define PIN_SRC_TEST(xname,nid) { \
3452 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
3454 .info = alc_test_pin_src_info, \
3455 .get = alc_test_pin_src_get, \
3456 .put = alc_test_pin_src_put, \
3457 .private_value = nid \
3460 static struct snd_kcontrol_new alc880_test_mixer[] = {
3461 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3462 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
3463 HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
3464 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
3465 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
3466 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
3467 HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
3468 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
3469 PIN_CTL_TEST("Front Pin Mode", 0x14),
3470 PIN_CTL_TEST("Surround Pin Mode", 0x15),
3471 PIN_CTL_TEST("CLFE Pin Mode", 0x16),
3472 PIN_CTL_TEST("Side Pin Mode", 0x17),
3473 PIN_CTL_TEST("In-1 Pin Mode", 0x18),
3474 PIN_CTL_TEST("In-2 Pin Mode", 0x19),
3475 PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
3476 PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
3477 PIN_SRC_TEST("In-1 Pin Source", 0x18),
3478 PIN_SRC_TEST("In-2 Pin Source", 0x19),
3479 PIN_SRC_TEST("In-3 Pin Source", 0x1a),
3480 PIN_SRC_TEST("In-4 Pin Source", 0x1b),
3481 HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
3482 HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
3483 HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
3484 HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
3485 HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
3486 HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
3487 HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
3488 HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
3489 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
3490 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
3492 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3493 .name = "Channel Mode",
3494 .info = alc_ch_mode_info,
3495 .get = alc_ch_mode_get,
3496 .put = alc_ch_mode_put,
3501 static struct hda_verb alc880_test_init_verbs[] = {
3502 /* Unmute inputs of 0x0c - 0x0f */
3503 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3504 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3505 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3506 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3507 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3508 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3509 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3510 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3511 /* Vol output for 0x0c-0x0f */
3512 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3513 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3514 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3515 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3516 /* Set output pins 0x14-0x17 */
3517 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3518 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3519 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3520 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3521 /* Unmute output pins 0x14-0x17 */
3522 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3523 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3524 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3525 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3526 /* Set input pins 0x18-0x1c */
3527 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3528 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3529 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3530 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3531 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3532 /* Mute input pins 0x18-0x1b */
3533 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3534 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3535 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3536 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3538 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3539 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
3540 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3541 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
3542 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3543 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
3544 /* Analog input/passthru */
3545 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3546 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3547 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
3548 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
3549 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
3557 static const char *alc880_models[ALC880_MODEL_LAST] = {
3558 [ALC880_3ST] = "3stack",
3559 [ALC880_TCL_S700] = "tcl",
3560 [ALC880_3ST_DIG] = "3stack-digout",
3561 [ALC880_CLEVO] = "clevo",
3562 [ALC880_5ST] = "5stack",
3563 [ALC880_5ST_DIG] = "5stack-digout",
3564 [ALC880_W810] = "w810",
3565 [ALC880_Z71V] = "z71v",
3566 [ALC880_6ST] = "6stack",
3567 [ALC880_6ST_DIG] = "6stack-digout",
3568 [ALC880_ASUS] = "asus",
3569 [ALC880_ASUS_W1V] = "asus-w1v",
3570 [ALC880_ASUS_DIG] = "asus-dig",
3571 [ALC880_ASUS_DIG2] = "asus-dig2",
3572 [ALC880_UNIWILL_DIG] = "uniwill",
3573 [ALC880_UNIWILL_P53] = "uniwill-p53",
3574 [ALC880_FUJITSU] = "fujitsu",
3575 [ALC880_F1734] = "F1734",
3577 [ALC880_LG_LW] = "lg-lw",
3578 [ALC880_MEDION_RIM] = "medion",
3579 #ifdef CONFIG_SND_DEBUG
3580 [ALC880_TEST] = "test",
3582 [ALC880_AUTO] = "auto",
3585 static struct snd_pci_quirk alc880_cfg_tbl[] = {
3586 SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_W810),
3587 SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_5ST_DIG),
3588 SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_6ST),
3589 SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_3ST_DIG),
3590 SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_6ST_DIG),
3591 SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_6ST_DIG),
3592 SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_6ST_DIG),
3593 SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_3ST_DIG),
3594 SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_3ST),
3595 SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_6ST_DIG),
3596 SND_PCI_QUIRK(0x103c, 0x2a09, "HP", ALC880_5ST),
3597 SND_PCI_QUIRK(0x1043, 0x10b3, "ASUS W1V", ALC880_ASUS_W1V),
3598 SND_PCI_QUIRK(0x1043, 0x10c2, "ASUS W6A", ALC880_ASUS_DIG),
3599 SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS Wxx", ALC880_ASUS_DIG),
3600 SND_PCI_QUIRK(0x1043, 0x1113, "ASUS", ALC880_ASUS_DIG),
3601 SND_PCI_QUIRK(0x1043, 0x1123, "ASUS", ALC880_ASUS_DIG),
3602 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS", ALC880_ASUS_DIG),
3603 SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_Z71V),
3604 /* SND_PCI_QUIRK(0x1043, 0x1964, "ASUS", ALC880_ASUS_DIG), */
3605 SND_PCI_QUIRK(0x1043, 0x1973, "ASUS", ALC880_ASUS_DIG),
3606 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS", ALC880_ASUS_DIG),
3607 SND_PCI_QUIRK(0x1043, 0x814e, "ASUS P5GD1 w/SPDIF", ALC880_6ST_DIG),
3608 SND_PCI_QUIRK(0x1043, 0x8181, "ASUS P4GPL", ALC880_ASUS_DIG),
3609 SND_PCI_QUIRK(0x1043, 0x8196, "ASUS P5GD1", ALC880_6ST),
3610 SND_PCI_QUIRK(0x1043, 0x81b4, "ASUS", ALC880_6ST),
3611 SND_PCI_QUIRK_VENDOR(0x1043, "ASUS", ALC880_ASUS), /* default ASUS */
3612 SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_3ST),
3613 SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_3ST),
3614 SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_5ST),
3615 SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_5ST),
3616 SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_5ST),
3617 SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_6ST_DIG),
3618 SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_6ST_DIG),
3619 SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_6ST_DIG),
3620 SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_6ST_DIG),
3621 SND_PCI_QUIRK(0x1558, 0x0520, "Clevo m520G", ALC880_CLEVO),
3622 SND_PCI_QUIRK(0x1558, 0x0660, "Clevo m655n", ALC880_CLEVO),
3623 SND_PCI_QUIRK(0x1558, 0x5401, "ASUS", ALC880_ASUS_DIG2),
3624 SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_5ST_DIG),
3625 SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_UNIWILL_DIG),
3626 SND_PCI_QUIRK(0x1584, 0x9054, "Uniwlll", ALC880_F1734),
3627 SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_UNIWILL),
3628 SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_UNIWILL_P53),
3629 SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_W810),
3630 SND_PCI_QUIRK(0x161f, 0x205d, "Medion Rim 2150", ALC880_MEDION_RIM),
3631 SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_5ST_DIG),
3632 SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_5ST_DIG),
3633 SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_F1734),
3634 SND_PCI_QUIRK(0x1734, 0x1094, "FSC Amilo M1451G", ALC880_FUJITSU),
3635 SND_PCI_QUIRK(0x1734, 0x10ac, "FSC", ALC880_UNIWILL),
3636 SND_PCI_QUIRK(0x1734, 0x10b0, "Fujitsu", ALC880_FUJITSU),
3637 SND_PCI_QUIRK(0x1854, 0x0018, "LG LW20", ALC880_LG_LW),
3638 SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_LG),
3639 SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_LG),
3640 SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_LG_LW),
3641 SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_TCL_S700),
3642 SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_6ST_DIG), /* broken BIOS */
3643 SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_6ST_DIG),
3644 SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_5ST_DIG),
3645 SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_5ST_DIG),
3646 SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_5ST_DIG),
3647 SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_3ST_DIG),
3648 SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_5ST_DIG),
3649 SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_3ST_DIG),
3650 SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_3ST_DIG),
3651 SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_5ST_DIG),
3652 SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_5ST_DIG),
3653 SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_5ST_DIG),
3655 SND_PCI_QUIRK_VENDOR(0x8086, "Intel mobo", ALC880_3ST),
3656 SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_5ST_DIG),
3657 SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_6ST_DIG),
3662 * ALC880 codec presets
3664 static struct alc_config_preset alc880_presets[] = {
3666 .mixers = { alc880_three_stack_mixer },
3667 .init_verbs = { alc880_volume_init_verbs,
3668 alc880_pin_3stack_init_verbs },
3669 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3670 .dac_nids = alc880_dac_nids,
3671 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3672 .channel_mode = alc880_threestack_modes,
3674 .input_mux = &alc880_capture_source,
3676 [ALC880_3ST_DIG] = {
3677 .mixers = { alc880_three_stack_mixer },
3678 .init_verbs = { alc880_volume_init_verbs,
3679 alc880_pin_3stack_init_verbs },
3680 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3681 .dac_nids = alc880_dac_nids,
3682 .dig_out_nid = ALC880_DIGOUT_NID,
3683 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3684 .channel_mode = alc880_threestack_modes,
3686 .input_mux = &alc880_capture_source,
3688 [ALC880_TCL_S700] = {
3689 .mixers = { alc880_tcl_s700_mixer },
3690 .init_verbs = { alc880_volume_init_verbs,
3691 alc880_pin_tcl_S700_init_verbs,
3692 alc880_gpio2_init_verbs },
3693 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3694 .dac_nids = alc880_dac_nids,
3695 .adc_nids = alc880_adc_nids_alt, /* FIXME: correct? */
3696 .num_adc_nids = 1, /* single ADC */
3698 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3699 .channel_mode = alc880_2_jack_modes,
3700 .input_mux = &alc880_capture_source,
3703 .mixers = { alc880_three_stack_mixer,
3704 alc880_five_stack_mixer},
3705 .init_verbs = { alc880_volume_init_verbs,
3706 alc880_pin_5stack_init_verbs },
3707 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3708 .dac_nids = alc880_dac_nids,
3709 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
3710 .channel_mode = alc880_fivestack_modes,
3711 .input_mux = &alc880_capture_source,
3713 [ALC880_5ST_DIG] = {
3714 .mixers = { alc880_three_stack_mixer,
3715 alc880_five_stack_mixer },
3716 .init_verbs = { alc880_volume_init_verbs,
3717 alc880_pin_5stack_init_verbs },
3718 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3719 .dac_nids = alc880_dac_nids,
3720 .dig_out_nid = ALC880_DIGOUT_NID,
3721 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
3722 .channel_mode = alc880_fivestack_modes,
3723 .input_mux = &alc880_capture_source,
3726 .mixers = { alc880_six_stack_mixer },
3727 .init_verbs = { alc880_volume_init_verbs,
3728 alc880_pin_6stack_init_verbs },
3729 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
3730 .dac_nids = alc880_6st_dac_nids,
3731 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
3732 .channel_mode = alc880_sixstack_modes,
3733 .input_mux = &alc880_6stack_capture_source,
3735 [ALC880_6ST_DIG] = {
3736 .mixers = { alc880_six_stack_mixer },
3737 .init_verbs = { alc880_volume_init_verbs,
3738 alc880_pin_6stack_init_verbs },
3739 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
3740 .dac_nids = alc880_6st_dac_nids,
3741 .dig_out_nid = ALC880_DIGOUT_NID,
3742 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
3743 .channel_mode = alc880_sixstack_modes,
3744 .input_mux = &alc880_6stack_capture_source,
3747 .mixers = { alc880_w810_base_mixer },
3748 .init_verbs = { alc880_volume_init_verbs,
3749 alc880_pin_w810_init_verbs,
3750 alc880_gpio2_init_verbs },
3751 .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
3752 .dac_nids = alc880_w810_dac_nids,
3753 .dig_out_nid = ALC880_DIGOUT_NID,
3754 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
3755 .channel_mode = alc880_w810_modes,
3756 .input_mux = &alc880_capture_source,
3759 .mixers = { alc880_z71v_mixer },
3760 .init_verbs = { alc880_volume_init_verbs,
3761 alc880_pin_z71v_init_verbs },
3762 .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
3763 .dac_nids = alc880_z71v_dac_nids,
3764 .dig_out_nid = ALC880_DIGOUT_NID,
3766 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3767 .channel_mode = alc880_2_jack_modes,
3768 .input_mux = &alc880_capture_source,
3771 .mixers = { alc880_f1734_mixer },
3772 .init_verbs = { alc880_volume_init_verbs,
3773 alc880_pin_f1734_init_verbs },
3774 .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
3775 .dac_nids = alc880_f1734_dac_nids,
3777 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3778 .channel_mode = alc880_2_jack_modes,
3779 .input_mux = &alc880_f1734_capture_source,
3780 .unsol_event = alc880_uniwill_p53_unsol_event,
3781 .init_hook = alc880_uniwill_p53_hp_automute,
3784 .mixers = { alc880_asus_mixer },
3785 .init_verbs = { alc880_volume_init_verbs,
3786 alc880_pin_asus_init_verbs,
3787 alc880_gpio1_init_verbs },
3788 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3789 .dac_nids = alc880_asus_dac_nids,
3790 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3791 .channel_mode = alc880_asus_modes,
3793 .input_mux = &alc880_capture_source,
3795 [ALC880_ASUS_DIG] = {
3796 .mixers = { alc880_asus_mixer },
3797 .init_verbs = { alc880_volume_init_verbs,
3798 alc880_pin_asus_init_verbs,
3799 alc880_gpio1_init_verbs },
3800 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3801 .dac_nids = alc880_asus_dac_nids,
3802 .dig_out_nid = ALC880_DIGOUT_NID,
3803 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3804 .channel_mode = alc880_asus_modes,
3806 .input_mux = &alc880_capture_source,
3808 [ALC880_ASUS_DIG2] = {
3809 .mixers = { alc880_asus_mixer },
3810 .init_verbs = { alc880_volume_init_verbs,
3811 alc880_pin_asus_init_verbs,
3812 alc880_gpio2_init_verbs }, /* use GPIO2 */
3813 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3814 .dac_nids = alc880_asus_dac_nids,
3815 .dig_out_nid = ALC880_DIGOUT_NID,
3816 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3817 .channel_mode = alc880_asus_modes,
3819 .input_mux = &alc880_capture_source,
3821 [ALC880_ASUS_W1V] = {
3822 .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
3823 .init_verbs = { alc880_volume_init_verbs,
3824 alc880_pin_asus_init_verbs,
3825 alc880_gpio1_init_verbs },
3826 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3827 .dac_nids = alc880_asus_dac_nids,
3828 .dig_out_nid = ALC880_DIGOUT_NID,
3829 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3830 .channel_mode = alc880_asus_modes,
3832 .input_mux = &alc880_capture_source,
3834 [ALC880_UNIWILL_DIG] = {
3835 .mixers = { alc880_asus_mixer },
3836 .init_verbs = { alc880_volume_init_verbs,
3837 alc880_pin_asus_init_verbs },
3838 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3839 .dac_nids = alc880_asus_dac_nids,
3840 .dig_out_nid = ALC880_DIGOUT_NID,
3841 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3842 .channel_mode = alc880_asus_modes,
3844 .input_mux = &alc880_capture_source,
3846 [ALC880_UNIWILL] = {
3847 .mixers = { alc880_uniwill_mixer },
3848 .init_verbs = { alc880_volume_init_verbs,
3849 alc880_uniwill_init_verbs },
3850 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3851 .dac_nids = alc880_asus_dac_nids,
3852 .dig_out_nid = ALC880_DIGOUT_NID,
3853 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3854 .channel_mode = alc880_threestack_modes,
3856 .input_mux = &alc880_capture_source,
3857 .unsol_event = alc880_uniwill_unsol_event,
3858 .init_hook = alc880_uniwill_automute,
3860 [ALC880_UNIWILL_P53] = {
3861 .mixers = { alc880_uniwill_p53_mixer },
3862 .init_verbs = { alc880_volume_init_verbs,
3863 alc880_uniwill_p53_init_verbs },
3864 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3865 .dac_nids = alc880_asus_dac_nids,
3866 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
3867 .channel_mode = alc880_threestack_modes,
3868 .input_mux = &alc880_capture_source,
3869 .unsol_event = alc880_uniwill_p53_unsol_event,
3870 .init_hook = alc880_uniwill_p53_hp_automute,
3872 [ALC880_FUJITSU] = {
3873 .mixers = { alc880_fujitsu_mixer },
3874 .init_verbs = { alc880_volume_init_verbs,
3875 alc880_uniwill_p53_init_verbs,
3876 alc880_beep_init_verbs },
3877 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3878 .dac_nids = alc880_dac_nids,
3879 .dig_out_nid = ALC880_DIGOUT_NID,
3880 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3881 .channel_mode = alc880_2_jack_modes,
3882 .input_mux = &alc880_capture_source,
3883 .unsol_event = alc880_uniwill_p53_unsol_event,
3884 .init_hook = alc880_uniwill_p53_hp_automute,
3887 .mixers = { alc880_three_stack_mixer },
3888 .init_verbs = { alc880_volume_init_verbs,
3889 alc880_pin_clevo_init_verbs },
3890 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3891 .dac_nids = alc880_dac_nids,
3893 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3894 .channel_mode = alc880_threestack_modes,
3896 .input_mux = &alc880_capture_source,
3899 .mixers = { alc880_lg_mixer },
3900 .init_verbs = { alc880_volume_init_verbs,
3901 alc880_lg_init_verbs },
3902 .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids),
3903 .dac_nids = alc880_lg_dac_nids,
3904 .dig_out_nid = ALC880_DIGOUT_NID,
3905 .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes),
3906 .channel_mode = alc880_lg_ch_modes,
3908 .input_mux = &alc880_lg_capture_source,
3909 .unsol_event = alc880_lg_unsol_event,
3910 .init_hook = alc880_lg_automute,
3911 #ifdef CONFIG_SND_HDA_POWER_SAVE
3912 .loopbacks = alc880_lg_loopbacks,
3916 .mixers = { alc880_lg_lw_mixer },
3917 .init_verbs = { alc880_volume_init_verbs,
3918 alc880_lg_lw_init_verbs },
3919 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3920 .dac_nids = alc880_dac_nids,
3921 .dig_out_nid = ALC880_DIGOUT_NID,
3922 .num_channel_mode = ARRAY_SIZE(alc880_lg_lw_modes),
3923 .channel_mode = alc880_lg_lw_modes,
3924 .input_mux = &alc880_lg_lw_capture_source,
3925 .unsol_event = alc880_lg_lw_unsol_event,
3926 .init_hook = alc880_lg_lw_automute,
3928 [ALC880_MEDION_RIM] = {
3929 .mixers = { alc880_medion_rim_mixer },
3930 .init_verbs = { alc880_volume_init_verbs,
3931 alc880_medion_rim_init_verbs,
3932 alc_gpio2_init_verbs },
3933 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3934 .dac_nids = alc880_dac_nids,
3935 .dig_out_nid = ALC880_DIGOUT_NID,
3936 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3937 .channel_mode = alc880_2_jack_modes,
3938 .input_mux = &alc880_medion_rim_capture_source,
3939 .unsol_event = alc880_medion_rim_unsol_event,
3940 .init_hook = alc880_medion_rim_automute,
3942 #ifdef CONFIG_SND_DEBUG
3944 .mixers = { alc880_test_mixer },
3945 .init_verbs = { alc880_test_init_verbs },
3946 .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
3947 .dac_nids = alc880_test_dac_nids,
3948 .dig_out_nid = ALC880_DIGOUT_NID,
3949 .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
3950 .channel_mode = alc880_test_modes,
3951 .input_mux = &alc880_test_capture_source,
3957 * Automatic parse of I/O pins from the BIOS configuration
3962 ALC_CTL_WIDGET_MUTE,
3965 static struct snd_kcontrol_new alc880_control_templates[] = {
3966 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
3967 HDA_CODEC_MUTE(NULL, 0, 0, 0),
3968 HDA_BIND_MUTE(NULL, 0, 0, 0),
3971 /* add dynamic controls */
3972 static int add_control(struct alc_spec *spec, int type, const char *name,
3975 struct snd_kcontrol_new *knew;
3977 snd_array_init(&spec->kctls, sizeof(*knew), 32);
3978 knew = snd_array_new(&spec->kctls);
3981 *knew = alc880_control_templates[type];
3982 knew->name = kstrdup(name, GFP_KERNEL);
3985 knew->private_value = val;
3989 #define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
3990 #define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
3991 #define alc880_is_multi_pin(nid) ((nid) >= 0x18)
3992 #define alc880_multi_pin_idx(nid) ((nid) - 0x18)
3993 #define alc880_is_input_pin(nid) ((nid) >= 0x18)
3994 #define alc880_input_pin_idx(nid) ((nid) - 0x18)
3995 #define alc880_idx_to_dac(nid) ((nid) + 0x02)
3996 #define alc880_dac_to_idx(nid) ((nid) - 0x02)
3997 #define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
3998 #define alc880_idx_to_selector(nid) ((nid) + 0x10)
3999 #define ALC880_PIN_CD_NID 0x1c
4001 /* fill in the dac_nids table from the parsed pin configuration */
4002 static int alc880_auto_fill_dac_nids(struct alc_spec *spec,
4003 const struct auto_pin_cfg *cfg)
4009 memset(assigned, 0, sizeof(assigned));
4010 spec->multiout.dac_nids = spec->private_dac_nids;
4012 /* check the pins hardwired to audio widget */
4013 for (i = 0; i < cfg->line_outs; i++) {
4014 nid = cfg->line_out_pins[i];
4015 if (alc880_is_fixed_pin(nid)) {
4016 int idx = alc880_fixed_pin_idx(nid);
4017 spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
4021 /* left pins can be connect to any audio widget */
4022 for (i = 0; i < cfg->line_outs; i++) {
4023 nid = cfg->line_out_pins[i];
4024 if (alc880_is_fixed_pin(nid))
4026 /* search for an empty channel */
4027 for (j = 0; j < cfg->line_outs; j++) {
4029 spec->multiout.dac_nids[i] =
4030 alc880_idx_to_dac(j);
4036 spec->multiout.num_dacs = cfg->line_outs;
4040 /* add playback controls from the parsed DAC table */
4041 static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
4042 const struct auto_pin_cfg *cfg)
4045 static const char *chname[4] = {
4046 "Front", "Surround", NULL /*CLFE*/, "Side"
4051 for (i = 0; i < cfg->line_outs; i++) {
4052 if (!spec->multiout.dac_nids[i])
4054 nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
4057 err = add_control(spec, ALC_CTL_WIDGET_VOL,
4058 "Center Playback Volume",
4059 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
4063 err = add_control(spec, ALC_CTL_WIDGET_VOL,
4064 "LFE Playback Volume",
4065 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
4069 err = add_control(spec, ALC_CTL_BIND_MUTE,
4070 "Center Playback Switch",
4071 HDA_COMPOSE_AMP_VAL(nid, 1, 2,
4075 err = add_control(spec, ALC_CTL_BIND_MUTE,
4076 "LFE Playback Switch",
4077 HDA_COMPOSE_AMP_VAL(nid, 2, 2,
4082 sprintf(name, "%s Playback Volume", chname[i]);
4083 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
4084 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
4088 sprintf(name, "%s Playback Switch", chname[i]);
4089 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
4090 HDA_COMPOSE_AMP_VAL(nid, 3, 2,
4099 /* add playback controls for speaker and HP outputs */
4100 static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
4110 if (alc880_is_fixed_pin(pin)) {
4111 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
4112 /* specify the DAC as the extra output */
4113 if (!spec->multiout.hp_nid)
4114 spec->multiout.hp_nid = nid;
4116 spec->multiout.extra_out_nid[0] = nid;
4117 /* control HP volume/switch on the output mixer amp */
4118 nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
4119 sprintf(name, "%s Playback Volume", pfx);
4120 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
4121 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
4124 sprintf(name, "%s Playback Switch", pfx);
4125 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
4126 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
4129 } else if (alc880_is_multi_pin(pin)) {
4130 /* set manual connection */
4131 /* we have only a switch on HP-out PIN */
4132 sprintf(name, "%s Playback Switch", pfx);
4133 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
4134 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
4141 /* create input playback/capture controls for the given pin */
4142 static int new_analog_input(struct alc_spec *spec, hda_nid_t pin,
4143 const char *ctlname,
4144 int idx, hda_nid_t mix_nid)
4149 sprintf(name, "%s Playback Volume", ctlname);
4150 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
4151 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
4154 sprintf(name, "%s Playback Switch", ctlname);
4155 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
4156 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
4162 /* create playback/capture controls for input pins */
4163 static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec,
4164 const struct auto_pin_cfg *cfg)
4166 struct hda_input_mux *imux = &spec->private_imux[0];
4169 for (i = 0; i < AUTO_PIN_LAST; i++) {
4170 if (alc880_is_input_pin(cfg->input_pins[i])) {
4171 idx = alc880_input_pin_idx(cfg->input_pins[i]);
4172 err = new_analog_input(spec, cfg->input_pins[i],
4173 auto_pin_cfg_labels[i],
4177 imux->items[imux->num_items].label =
4178 auto_pin_cfg_labels[i];
4179 imux->items[imux->num_items].index =
4180 alc880_input_pin_idx(cfg->input_pins[i]);
4187 static void alc_set_pin_output(struct hda_codec *codec, hda_nid_t nid,
4188 unsigned int pin_type)
4190 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4193 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
4197 static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
4198 hda_nid_t nid, int pin_type,
4201 alc_set_pin_output(codec, nid, pin_type);
4202 /* need the manual connection? */
4203 if (alc880_is_multi_pin(nid)) {
4204 struct alc_spec *spec = codec->spec;
4205 int idx = alc880_multi_pin_idx(nid);
4206 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
4207 AC_VERB_SET_CONNECT_SEL,
4208 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
4212 static int get_pin_type(int line_out_type)
4214 if (line_out_type == AUTO_PIN_HP_OUT)
4220 static void alc880_auto_init_multi_out(struct hda_codec *codec)
4222 struct alc_spec *spec = codec->spec;
4225 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
4226 for (i = 0; i < spec->autocfg.line_outs; i++) {
4227 hda_nid_t nid = spec->autocfg.line_out_pins[i];
4228 int pin_type = get_pin_type(spec->autocfg.line_out_type);
4229 alc880_auto_set_output_and_unmute(codec, nid, pin_type, i);
4233 static void alc880_auto_init_extra_out(struct hda_codec *codec)
4235 struct alc_spec *spec = codec->spec;
4238 pin = spec->autocfg.speaker_pins[0];
4239 if (pin) /* connect to front */
4240 alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
4241 pin = spec->autocfg.hp_pins[0];
4242 if (pin) /* connect to front */
4243 alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
4246 static void alc880_auto_init_analog_input(struct hda_codec *codec)
4248 struct alc_spec *spec = codec->spec;
4251 for (i = 0; i < AUTO_PIN_LAST; i++) {
4252 hda_nid_t nid = spec->autocfg.input_pins[i];
4253 if (alc880_is_input_pin(nid)) {
4254 snd_hda_codec_write(codec, nid, 0,
4255 AC_VERB_SET_PIN_WIDGET_CONTROL,
4256 i <= AUTO_PIN_FRONT_MIC ?
4257 PIN_VREF80 : PIN_IN);
4258 if (nid != ALC880_PIN_CD_NID)
4259 snd_hda_codec_write(codec, nid, 0,
4260 AC_VERB_SET_AMP_GAIN_MUTE,
4266 /* parse the BIOS configuration and set up the alc_spec */
4267 /* return 1 if successful, 0 if the proper config is not found,
4268 * or a negative error code
4270 static int alc880_parse_auto_config(struct hda_codec *codec)
4272 struct alc_spec *spec = codec->spec;
4274 static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
4276 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
4280 if (!spec->autocfg.line_outs)
4281 return 0; /* can't find valid BIOS pin config */
4283 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
4286 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
4289 err = alc880_auto_create_extra_out(spec,
4290 spec->autocfg.speaker_pins[0],
4294 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
4298 err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
4302 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
4304 /* check multiple SPDIF-out (for recent codecs) */
4305 for (i = 0; i < spec->autocfg.dig_outs; i++) {
4307 err = snd_hda_get_connections(codec,
4308 spec->autocfg.dig_out_pins[i],
4313 spec->multiout.dig_out_nid = dig_nid;
4315 spec->multiout.slave_dig_outs = spec->slave_dig_outs;
4316 spec->slave_dig_outs[i - 1] = dig_nid;
4317 if (i == ARRAY_SIZE(spec->slave_dig_outs) - 1)
4321 if (spec->autocfg.dig_in_pin)
4322 spec->dig_in_nid = ALC880_DIGIN_NID;
4324 if (spec->kctls.list)
4325 add_mixer(spec, spec->kctls.list);
4327 add_verb(spec, alc880_volume_init_verbs);
4329 spec->num_mux_defs = 1;
4330 spec->input_mux = &spec->private_imux[0];
4332 store_pin_configs(codec);
4336 /* additional initialization for auto-configuration model */
4337 static void alc880_auto_init(struct hda_codec *codec)
4339 struct alc_spec *spec = codec->spec;
4340 alc880_auto_init_multi_out(codec);
4341 alc880_auto_init_extra_out(codec);
4342 alc880_auto_init_analog_input(codec);
4343 if (spec->unsol_event)
4344 alc_inithook(codec);
4347 static void set_capture_mixer(struct alc_spec *spec)
4349 static struct snd_kcontrol_new *caps[3] = {
4354 if (spec->num_adc_nids > 0 && spec->num_adc_nids <= 3)
4355 spec->cap_mixer = caps[spec->num_adc_nids - 1];
4358 #define set_beep_amp(spec, nid, idx, dir) \
4359 ((spec)->beep_amp = HDA_COMPOSE_AMP_VAL(nid, 3, idx, dir))
4362 * OK, here we have finally the patch for ALC880
4365 static int patch_alc880(struct hda_codec *codec)
4367 struct alc_spec *spec;
4371 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4377 board_config = snd_hda_check_board_config(codec, ALC880_MODEL_LAST,
4380 if (board_config < 0) {
4381 printk(KERN_INFO "hda_codec: Unknown model for ALC880, "
4382 "trying auto-probe from BIOS...\n");
4383 board_config = ALC880_AUTO;
4386 if (board_config == ALC880_AUTO) {
4387 /* automatic parse from the BIOS config */
4388 err = alc880_parse_auto_config(codec);
4394 "hda_codec: Cannot set up configuration "
4395 "from BIOS. Using 3-stack mode...\n");
4396 board_config = ALC880_3ST;
4400 err = snd_hda_attach_beep_device(codec, 0x1);
4406 if (board_config != ALC880_AUTO)
4407 setup_preset(spec, &alc880_presets[board_config]);
4409 spec->stream_name_analog = "ALC880 Analog";
4410 spec->stream_analog_playback = &alc880_pcm_analog_playback;
4411 spec->stream_analog_capture = &alc880_pcm_analog_capture;
4412 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
4414 spec->stream_name_digital = "ALC880 Digital";
4415 spec->stream_digital_playback = &alc880_pcm_digital_playback;
4416 spec->stream_digital_capture = &alc880_pcm_digital_capture;
4418 if (!spec->adc_nids && spec->input_mux) {
4419 /* check whether NID 0x07 is valid */
4420 unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
4422 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
4423 if (wcap != AC_WID_AUD_IN) {
4424 spec->adc_nids = alc880_adc_nids_alt;
4425 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
4427 spec->adc_nids = alc880_adc_nids;
4428 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
4431 set_capture_mixer(spec);
4432 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
4434 spec->vmaster_nid = 0x0c;
4436 codec->patch_ops = alc_patch_ops;
4437 if (board_config == ALC880_AUTO)
4438 spec->init_hook = alc880_auto_init;
4439 #ifdef CONFIG_SND_HDA_POWER_SAVE
4440 if (!spec->loopback.amplist)
4441 spec->loopback.amplist = alc880_loopbacks;
4443 codec->proc_widget_hook = print_realtek_coef;
4453 static hda_nid_t alc260_dac_nids[1] = {
4458 static hda_nid_t alc260_adc_nids[1] = {
4463 static hda_nid_t alc260_adc_nids_alt[1] = {
4468 /* NIDs used when simultaneous access to both ADCs makes sense. Note that
4469 * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
4471 static hda_nid_t alc260_dual_adc_nids[2] = {
4476 #define ALC260_DIGOUT_NID 0x03
4477 #define ALC260_DIGIN_NID 0x06
4479 static struct hda_input_mux alc260_capture_source = {
4483 { "Front Mic", 0x1 },
4489 /* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
4490 * headphone jack and the internal CD lines since these are the only pins at
4491 * which audio can appear. For flexibility, also allow the option of
4492 * recording the mixer output on the second ADC (ADC0 doesn't have a
4493 * connection to the mixer output).
4495 static struct hda_input_mux alc260_fujitsu_capture_sources[2] = {
4499 { "Mic/Line", 0x0 },
4501 { "Headphone", 0x2 },
4507 { "Mic/Line", 0x0 },
4509 { "Headphone", 0x2 },
4516 /* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to
4517 * the Fujitsu S702x, but jacks are marked differently.
4519 static struct hda_input_mux alc260_acer_capture_sources[2] = {
4526 { "Headphone", 0x5 },
4535 { "Headphone", 0x6 },
4541 * This is just place-holder, so there's something for alc_build_pcms to look
4542 * at when it calculates the maximum number of channels. ALC260 has no mixer
4543 * element which allows changing the channel mode, so the verb list is
4546 static struct hda_channel_mode alc260_modes[1] = {
4551 /* Mixer combinations
4553 * basic: base_output + input + pc_beep + capture
4554 * HP: base_output + input + capture_alt
4555 * HP_3013: hp_3013 + input + capture
4556 * fujitsu: fujitsu + capture
4557 * acer: acer + capture
4560 static struct snd_kcontrol_new alc260_base_output_mixer[] = {
4561 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4562 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
4563 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4564 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
4565 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
4566 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
4570 static struct snd_kcontrol_new alc260_input_mixer[] = {
4571 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4572 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4573 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
4574 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
4575 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4576 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4577 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
4578 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
4582 /* update HP, line and mono out pins according to the master switch */
4583 static void alc260_hp_master_update(struct hda_codec *codec,
4584 hda_nid_t hp, hda_nid_t line,
4587 struct alc_spec *spec = codec->spec;
4588 unsigned int val = spec->master_sw ? PIN_HP : 0;
4589 /* change HP and line-out pins */
4590 snd_hda_codec_write(codec, hp, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4592 snd_hda_codec_write(codec, line, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4594 /* mono (speaker) depending on the HP jack sense */
4595 val = (val && !spec->jack_present) ? PIN_OUT : 0;
4596 snd_hda_codec_write(codec, mono, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4600 static int alc260_hp_master_sw_get(struct snd_kcontrol *kcontrol,
4601 struct snd_ctl_elem_value *ucontrol)
4603 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4604 struct alc_spec *spec = codec->spec;
4605 *ucontrol->value.integer.value = spec->master_sw;
4609 static int alc260_hp_master_sw_put(struct snd_kcontrol *kcontrol,
4610 struct snd_ctl_elem_value *ucontrol)
4612 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4613 struct alc_spec *spec = codec->spec;
4614 int val = !!*ucontrol->value.integer.value;
4615 hda_nid_t hp, line, mono;
4617 if (val == spec->master_sw)
4619 spec->master_sw = val;
4620 hp = (kcontrol->private_value >> 16) & 0xff;
4621 line = (kcontrol->private_value >> 8) & 0xff;
4622 mono = kcontrol->private_value & 0xff;
4623 alc260_hp_master_update(codec, hp, line, mono);
4627 static struct snd_kcontrol_new alc260_hp_output_mixer[] = {
4629 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4630 .name = "Master Playback Switch",
4631 .info = snd_ctl_boolean_mono_info,
4632 .get = alc260_hp_master_sw_get,
4633 .put = alc260_hp_master_sw_put,
4634 .private_value = (0x0f << 16) | (0x10 << 8) | 0x11
4636 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4637 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
4638 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4639 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
4640 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
4642 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2, HDA_INPUT),
4646 static struct hda_verb alc260_hp_unsol_verbs[] = {
4647 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
4651 static void alc260_hp_automute(struct hda_codec *codec)
4653 struct alc_spec *spec = codec->spec;
4654 unsigned int present;
4656 present = snd_hda_codec_read(codec, 0x10, 0,
4657 AC_VERB_GET_PIN_SENSE, 0);
4658 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
4659 alc260_hp_master_update(codec, 0x0f, 0x10, 0x11);
4662 static void alc260_hp_unsol_event(struct hda_codec *codec, unsigned int res)
4664 if ((res >> 26) == ALC880_HP_EVENT)
4665 alc260_hp_automute(codec);
4668 static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
4670 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4671 .name = "Master Playback Switch",
4672 .info = snd_ctl_boolean_mono_info,
4673 .get = alc260_hp_master_sw_get,
4674 .put = alc260_hp_master_sw_put,
4675 .private_value = (0x15 << 16) | (0x10 << 8) | 0x11
4677 HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4678 HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
4679 HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
4680 HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
4681 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4682 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
4683 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
4684 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
4688 static struct hda_bind_ctls alc260_dc7600_bind_master_vol = {
4689 .ops = &snd_hda_bind_vol,
4691 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_OUTPUT),
4692 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_OUTPUT),
4693 HDA_COMPOSE_AMP_VAL(0x0a, 3, 0, HDA_OUTPUT),
4698 static struct hda_bind_ctls alc260_dc7600_bind_switch = {
4699 .ops = &snd_hda_bind_sw,
4701 HDA_COMPOSE_AMP_VAL(0x11, 3, 0, HDA_OUTPUT),
4702 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
4707 static struct snd_kcontrol_new alc260_hp_dc7600_mixer[] = {
4708 HDA_BIND_VOL("Master Playback Volume", &alc260_dc7600_bind_master_vol),
4709 HDA_BIND_SW("LineOut Playback Switch", &alc260_dc7600_bind_switch),
4710 HDA_CODEC_MUTE("Speaker Playback Switch", 0x0f, 0x0, HDA_OUTPUT),
4711 HDA_CODEC_MUTE("Headphone Playback Switch", 0x10, 0x0, HDA_OUTPUT),
4715 static struct hda_verb alc260_hp_3013_unsol_verbs[] = {
4716 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
4720 static void alc260_hp_3013_automute(struct hda_codec *codec)
4722 struct alc_spec *spec = codec->spec;
4723 unsigned int present;
4725 present = snd_hda_codec_read(codec, 0x15, 0,
4726 AC_VERB_GET_PIN_SENSE, 0);
4727 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
4728 alc260_hp_master_update(codec, 0x15, 0x10, 0x11);
4731 static void alc260_hp_3013_unsol_event(struct hda_codec *codec,
4734 if ((res >> 26) == ALC880_HP_EVENT)
4735 alc260_hp_3013_automute(codec);
4738 static void alc260_hp_3012_automute(struct hda_codec *codec)
4740 unsigned int present, bits;
4742 present = snd_hda_codec_read(codec, 0x10, 0,
4743 AC_VERB_GET_PIN_SENSE, 0) & AC_PINSENSE_PRESENCE;
4745 bits = present ? 0 : PIN_OUT;
4746 snd_hda_codec_write(codec, 0x0f, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4748 snd_hda_codec_write(codec, 0x11, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4750 snd_hda_codec_write(codec, 0x15, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4754 static void alc260_hp_3012_unsol_event(struct hda_codec *codec,
4757 if ((res >> 26) == ALC880_HP_EVENT)
4758 alc260_hp_3012_automute(codec);
4761 /* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12,
4762 * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10.
4764 static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
4765 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4766 HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
4767 ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
4768 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4769 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4770 HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
4771 HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
4772 ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
4773 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4774 HDA_BIND_MUTE("Speaker Playback Switch", 0x09, 2, HDA_INPUT),
4778 /* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current
4779 * versions of the ALC260 don't act on requests to enable mic bias from NID
4780 * 0x0f (used to drive the headphone jack in these laptops). The ALC260
4781 * datasheet doesn't mention this restriction. At this stage it's not clear
4782 * whether this behaviour is intentional or is a hardware bug in chip
4783 * revisions available in early 2006. Therefore for now allow the
4784 * "Headphone Jack Mode" control to span all choices, but if it turns out
4785 * that the lack of mic bias for this NID is intentional we could change the
4786 * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
4788 * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006
4789 * don't appear to make the mic bias available from the "line" jack, even
4790 * though the NID used for this jack (0x14) can supply it. The theory is
4791 * that perhaps Acer have included blocking capacitors between the ALC260
4792 * and the output jack. If this turns out to be the case for all such
4793 * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
4794 * to ALC_PIN_DIR_INOUT_NOMICBIAS.
4796 * The C20x Tablet series have a mono internal speaker which is controlled
4797 * via the chip's Mono sum widget and pin complex, so include the necessary
4798 * controls for such models. On models without a "mono speaker" the control
4799 * won't do anything.
4801 static struct snd_kcontrol_new alc260_acer_mixer[] = {
4802 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4803 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
4804 ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
4805 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
4807 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2,
4809 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4810 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4811 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4812 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4813 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
4814 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
4815 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
4816 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
4820 /* Packard bell V7900 ALC260 pin usage: HP = 0x0f, Mic jack = 0x12,
4821 * Line In jack = 0x14, CD audio = 0x16, pc beep = 0x17.
4823 static struct snd_kcontrol_new alc260_will_mixer[] = {
4824 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4825 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
4826 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4827 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4828 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
4829 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
4830 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
4831 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
4832 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4833 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4837 /* Replacer 672V ALC260 pin usage: Mic jack = 0x12,
4838 * Line In jack = 0x14, ATAPI Mic = 0x13, speaker = 0x0f.
4840 static struct snd_kcontrol_new alc260_replacer_672v_mixer[] = {
4841 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4842 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
4843 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4844 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4845 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
4846 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x07, 0x1, HDA_INPUT),
4847 HDA_CODEC_MUTE("ATATI Mic Playback Switch", 0x07, 0x1, HDA_INPUT),
4848 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
4849 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
4850 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
4855 * initialization verbs
4857 static struct hda_verb alc260_init_verbs[] = {
4858 /* Line In pin widget for input */
4859 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
4860 /* CD pin widget for input */
4861 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
4862 /* Mic1 (rear panel) pin widget for input and vref at 80% */
4863 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
4864 /* Mic2 (front panel) pin widget for input and vref at 80% */
4865 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
4866 /* LINE-2 is used for line-out in rear */
4867 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4868 /* select line-out */
4869 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
4871 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4873 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4875 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4876 /* mute capture amp left and right */
4877 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4878 /* set connection select to line in (default select for this ADC) */
4879 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
4880 /* mute capture amp left and right */
4881 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4882 /* set connection select to line in (default select for this ADC) */
4883 {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
4884 /* set vol=0 Line-Out mixer amp left and right */
4885 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4886 /* unmute pin widget amp left and right (no gain on this amp) */
4887 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4888 /* set vol=0 HP mixer amp left and right */
4889 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4890 /* unmute pin widget amp left and right (no gain on this amp) */
4891 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4892 /* set vol=0 Mono mixer amp left and right */
4893 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4894 /* unmute pin widget amp left and right (no gain on this amp) */
4895 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4896 /* unmute LINE-2 out pin */
4897 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4898 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
4901 /* mute analog inputs */
4902 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4903 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4904 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4905 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4906 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
4907 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
4908 /* mute Front out path */
4909 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4910 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4911 /* mute Headphone out path */
4912 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4913 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4914 /* mute Mono out path */
4915 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4916 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4920 #if 0 /* should be identical with alc260_init_verbs? */
4921 static struct hda_verb alc260_hp_init_verbs[] = {
4922 /* Headphone and output */
4923 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
4925 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
4926 /* Mic1 (rear panel) pin widget for input and vref at 80% */
4927 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
4928 /* Mic2 (front panel) pin widget for input and vref at 80% */
4929 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
4930 /* Line In pin widget for input */
4931 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
4932 /* Line-2 pin widget for output */
4933 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
4934 /* CD pin widget for input */
4935 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
4936 /* unmute amp left and right */
4937 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
4938 /* set connection select to line in (default select for this ADC) */
4939 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
4940 /* unmute Line-Out mixer amp left and right (volume = 0) */
4941 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
4942 /* mute pin widget amp left and right (no gain on this amp) */
4943 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
4944 /* unmute HP mixer amp left and right (volume = 0) */
4945 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
4946 /* mute pin widget amp left and right (no gain on this amp) */
4947 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
4948 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
4951 /* mute analog inputs */
4952 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4953 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4954 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4955 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4956 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
4957 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
4958 /* Unmute Front out path */
4959 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4960 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4961 /* Unmute Headphone out path */
4962 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4963 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4964 /* Unmute Mono out path */
4965 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4966 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4971 static struct hda_verb alc260_hp_3013_init_verbs[] = {
4972 /* Line out and output */
4973 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
4975 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
4976 /* Mic1 (rear panel) pin widget for input and vref at 80% */
4977 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
4978 /* Mic2 (front panel) pin widget for input and vref at 80% */
4979 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
4980 /* Line In pin widget for input */
4981 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
4982 /* Headphone pin widget for output */
4983 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
4984 /* CD pin widget for input */
4985 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
4986 /* unmute amp left and right */
4987 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
4988 /* set connection select to line in (default select for this ADC) */
4989 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
4990 /* unmute Line-Out mixer amp left and right (volume = 0) */
4991 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
4992 /* mute pin widget amp left and right (no gain on this amp) */
4993 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
4994 /* unmute HP mixer amp left and right (volume = 0) */
4995 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
4996 /* mute pin widget amp left and right (no gain on this amp) */
4997 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
4998 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
5001 /* mute analog inputs */
5002 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5003 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5004 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5005 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5006 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5007 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
5008 /* Unmute Front out path */
5009 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5010 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5011 /* Unmute Headphone out path */
5012 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5013 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5014 /* Unmute Mono out path */
5015 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5016 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5020 /* Initialisation sequence for ALC260 as configured in Fujitsu S702x
5021 * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD
5022 * audio = 0x16, internal speaker = 0x10.
5024 static struct hda_verb alc260_fujitsu_init_verbs[] = {
5025 /* Disable all GPIOs */
5026 {0x01, AC_VERB_SET_GPIO_MASK, 0},
5027 /* Internal speaker is connected to headphone pin */
5028 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5029 /* Headphone/Line-out jack connects to Line1 pin; make it an output */
5030 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5031 /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
5032 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
5033 /* Ensure all other unused pins are disabled and muted. */
5034 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5035 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5036 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5037 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5038 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5039 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5040 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5041 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5043 /* Disable digital (SPDIF) pins */
5044 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5045 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
5047 /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
5048 * when acting as an output.
5050 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5052 /* Start with output sum widgets muted and their output gains at min */
5053 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5054 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5055 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5056 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5057 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5058 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5059 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5060 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5061 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5063 /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
5064 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5065 /* Unmute Line1 pin widget output buffer since it starts as an output.
5066 * If the pin mode is changed by the user the pin mode control will
5067 * take care of enabling the pin's input/output buffers as needed.
5068 * Therefore there's no need to enable the input buffer at this
5071 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5072 /* Unmute input buffer of pin widget used for Line-in (no equiv
5075 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5077 /* Mute capture amp left and right */
5078 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5079 /* Set ADC connection select to match default mixer setting - line
5082 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5084 /* Do the same for the second ADC: mute capture input amp and
5085 * set ADC connection to line in (on mic1 pin)
5087 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5088 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
5090 /* Mute all inputs to mixer widget (even unconnected ones) */
5091 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5092 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5093 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5094 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5095 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5096 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5097 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5098 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
5103 /* Initialisation sequence for ALC260 as configured in Acer TravelMate and
5104 * similar laptops (adapted from Fujitsu init verbs).
5106 static struct hda_verb alc260_acer_init_verbs[] = {
5107 /* On TravelMate laptops, GPIO 0 enables the internal speaker and
5108 * the headphone jack. Turn this on and rely on the standard mute
5109 * methods whenever the user wants to turn these outputs off.
5111 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
5112 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
5113 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
5114 /* Internal speaker/Headphone jack is connected to Line-out pin */
5115 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5116 /* Internal microphone/Mic jack is connected to Mic1 pin */
5117 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
5118 /* Line In jack is connected to Line1 pin */
5119 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
5120 /* Some Acers (eg: C20x Tablets) use Mono pin for internal speaker */
5121 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5122 /* Ensure all other unused pins are disabled and muted. */
5123 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5124 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5125 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5126 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5127 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5128 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5129 /* Disable digital (SPDIF) pins */
5130 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5131 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
5133 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
5134 * bus when acting as outputs.
5136 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
5137 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5139 /* Start with output sum widgets muted and their output gains at min */
5140 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5141 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5142 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5143 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5144 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5145 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5146 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5147 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5148 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5150 /* Unmute Line-out pin widget amp left and right
5151 * (no equiv mixer ctrl)
5153 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5154 /* Unmute mono pin widget amp output (no equiv mixer ctrl) */
5155 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5156 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
5157 * inputs. If the pin mode is changed by the user the pin mode control
5158 * will take care of enabling the pin's input/output buffers as needed.
5159 * Therefore there's no need to enable the input buffer at this
5162 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5163 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5165 /* Mute capture amp left and right */
5166 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5167 /* Set ADC connection select to match default mixer setting - mic
5170 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5172 /* Do similar with the second ADC: mute capture input amp and
5173 * set ADC connection to mic to match ALSA's default state.
5175 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5176 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
5178 /* Mute all inputs to mixer widget (even unconnected ones) */
5179 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5180 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5181 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5182 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5183 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5184 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5185 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5186 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
5191 static struct hda_verb alc260_will_verbs[] = {
5192 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5193 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x00},
5194 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
5195 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
5196 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
5197 {0x1a, AC_VERB_SET_PROC_COEF, 0x3040},
5201 static struct hda_verb alc260_replacer_672v_verbs[] = {
5202 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
5203 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
5204 {0x1a, AC_VERB_SET_PROC_COEF, 0x3050},
5206 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
5207 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
5208 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
5210 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5214 /* toggle speaker-output according to the hp-jack state */
5215 static void alc260_replacer_672v_automute(struct hda_codec *codec)
5217 unsigned int present;
5219 /* speaker --> GPIO Data 0, hp or spdif --> GPIO data 1 */
5220 present = snd_hda_codec_read(codec, 0x0f, 0,
5221 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
5223 snd_hda_codec_write_cache(codec, 0x01, 0,
5224 AC_VERB_SET_GPIO_DATA, 1);
5225 snd_hda_codec_write_cache(codec, 0x0f, 0,
5226 AC_VERB_SET_PIN_WIDGET_CONTROL,
5229 snd_hda_codec_write_cache(codec, 0x01, 0,
5230 AC_VERB_SET_GPIO_DATA, 0);
5231 snd_hda_codec_write_cache(codec, 0x0f, 0,
5232 AC_VERB_SET_PIN_WIDGET_CONTROL,
5237 static void alc260_replacer_672v_unsol_event(struct hda_codec *codec,
5240 if ((res >> 26) == ALC880_HP_EVENT)
5241 alc260_replacer_672v_automute(codec);
5244 static struct hda_verb alc260_hp_dc7600_verbs[] = {
5245 {0x05, AC_VERB_SET_CONNECT_SEL, 0x01},
5246 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
5247 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5248 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5249 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5250 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5251 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5252 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5253 {0x11, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5254 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5258 /* Test configuration for debugging, modelled after the ALC880 test
5261 #ifdef CONFIG_SND_DEBUG
5262 static hda_nid_t alc260_test_dac_nids[1] = {
5265 static hda_nid_t alc260_test_adc_nids[2] = {
5268 /* For testing the ALC260, each input MUX needs its own definition since
5269 * the signal assignments are different. This assumes that the first ADC
5272 static struct hda_input_mux alc260_test_capture_sources[2] = {
5276 { "MIC1 pin", 0x0 },
5277 { "MIC2 pin", 0x1 },
5278 { "LINE1 pin", 0x2 },
5279 { "LINE2 pin", 0x3 },
5281 { "LINE-OUT pin", 0x5 },
5282 { "HP-OUT pin", 0x6 },
5288 { "MIC1 pin", 0x0 },
5289 { "MIC2 pin", 0x1 },
5290 { "LINE1 pin", 0x2 },
5291 { "LINE2 pin", 0x3 },
5294 { "LINE-OUT pin", 0x6 },
5295 { "HP-OUT pin", 0x7 },
5299 static struct snd_kcontrol_new alc260_test_mixer[] = {
5300 /* Output driver widgets */
5301 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
5302 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
5303 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5304 HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
5305 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5306 HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
5308 /* Modes for retasking pin widgets
5309 * Note: the ALC260 doesn't seem to act on requests to enable mic
5310 * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't
5311 * mention this restriction. At this stage it's not clear whether
5312 * this behaviour is intentional or is a hardware bug in chip
5313 * revisions available at least up until early 2006. Therefore for
5314 * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all
5315 * choices, but if it turns out that the lack of mic bias for these
5316 * NIDs is intentional we could change their modes from
5317 * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
5319 ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
5320 ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
5321 ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
5322 ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
5323 ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
5324 ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
5326 /* Loopback mixer controls */
5327 HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
5328 HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
5329 HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
5330 HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
5331 HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
5332 HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
5333 HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
5334 HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
5335 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5336 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
5337 HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
5338 HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
5339 HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
5340 HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
5342 /* Controls for GPIO pins, assuming they are configured as outputs */
5343 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
5344 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
5345 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
5346 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
5348 /* Switches to allow the digital IO pins to be enabled. The datasheet
5349 * is ambigious as to which NID is which; testing on laptops which
5350 * make this output available should provide clarification.
5352 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
5353 ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
5355 /* A switch allowing EAPD to be enabled. Some laptops seem to use
5356 * this output to turn on an external amplifier.
5358 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
5359 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
5363 static struct hda_verb alc260_test_init_verbs[] = {
5364 /* Enable all GPIOs as outputs with an initial value of 0 */
5365 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
5366 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
5367 {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
5369 /* Enable retasking pins as output, initially without power amp */
5370 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5371 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5372 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5373 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5374 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5375 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5377 /* Disable digital (SPDIF) pins initially, but users can enable
5378 * them via a mixer switch. In the case of SPDIF-out, this initverb
5379 * payload also sets the generation to 0, output to be in "consumer"
5380 * PCM format, copyright asserted, no pre-emphasis and no validity
5383 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5384 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
5386 /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
5387 * OUT1 sum bus when acting as an output.
5389 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
5390 {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
5391 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5392 {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
5394 /* Start with output sum widgets muted and their output gains at min */
5395 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5396 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5397 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5398 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5399 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5400 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5401 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5402 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5403 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5405 /* Unmute retasking pin widget output buffers since the default
5406 * state appears to be output. As the pin mode is changed by the
5407 * user the pin mode control will take care of enabling the pin's
5408 * input/output buffers as needed.
5410 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5411 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5412 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5413 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5414 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5415 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5416 /* Also unmute the mono-out pin widget */
5417 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5419 /* Mute capture amp left and right */
5420 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5421 /* Set ADC connection select to match default mixer setting (mic1
5424 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5426 /* Do the same for the second ADC: mute capture input amp and
5427 * set ADC connection to mic1 pin
5429 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5430 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
5432 /* Mute all inputs to mixer widget (even unconnected ones) */
5433 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5434 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5435 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5436 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5437 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5438 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5439 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5440 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
5446 #define alc260_pcm_analog_playback alc880_pcm_analog_alt_playback
5447 #define alc260_pcm_analog_capture alc880_pcm_analog_capture
5449 #define alc260_pcm_digital_playback alc880_pcm_digital_playback
5450 #define alc260_pcm_digital_capture alc880_pcm_digital_capture
5453 * for BIOS auto-configuration
5456 static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
5457 const char *pfx, int *vol_bits)
5460 unsigned long vol_val, sw_val;
5464 if (nid >= 0x0f && nid < 0x11) {
5465 nid_vol = nid - 0x7;
5466 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
5467 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
5468 } else if (nid == 0x11) {
5469 nid_vol = nid - 0x7;
5470 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
5471 sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
5472 } else if (nid >= 0x12 && nid <= 0x15) {
5474 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
5475 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
5479 if (!(*vol_bits & (1 << nid_vol))) {
5480 /* first control for the volume widget */
5481 snprintf(name, sizeof(name), "%s Playback Volume", pfx);
5482 err = add_control(spec, ALC_CTL_WIDGET_VOL, name, vol_val);
5485 *vol_bits |= (1 << nid_vol);
5487 snprintf(name, sizeof(name), "%s Playback Switch", pfx);
5488 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, sw_val);
5494 /* add playback controls from the parsed DAC table */
5495 static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
5496 const struct auto_pin_cfg *cfg)
5502 spec->multiout.num_dacs = 1;
5503 spec->multiout.dac_nids = spec->private_dac_nids;
5504 spec->multiout.dac_nids[0] = 0x02;
5506 nid = cfg->line_out_pins[0];
5508 err = alc260_add_playback_controls(spec, nid, "Front", &vols);
5513 nid = cfg->speaker_pins[0];
5515 err = alc260_add_playback_controls(spec, nid, "Speaker", &vols);
5520 nid = cfg->hp_pins[0];
5522 err = alc260_add_playback_controls(spec, nid, "Headphone",
5530 /* create playback/capture controls for input pins */
5531 static int alc260_auto_create_analog_input_ctls(struct alc_spec *spec,
5532 const struct auto_pin_cfg *cfg)
5534 struct hda_input_mux *imux = &spec->private_imux[0];
5537 for (i = 0; i < AUTO_PIN_LAST; i++) {
5538 if (cfg->input_pins[i] >= 0x12) {
5539 idx = cfg->input_pins[i] - 0x12;
5540 err = new_analog_input(spec, cfg->input_pins[i],
5541 auto_pin_cfg_labels[i], idx,
5545 imux->items[imux->num_items].label =
5546 auto_pin_cfg_labels[i];
5547 imux->items[imux->num_items].index = idx;
5550 if (cfg->input_pins[i] >= 0x0f && cfg->input_pins[i] <= 0x10){
5551 idx = cfg->input_pins[i] - 0x09;
5552 err = new_analog_input(spec, cfg->input_pins[i],
5553 auto_pin_cfg_labels[i], idx,
5557 imux->items[imux->num_items].label =
5558 auto_pin_cfg_labels[i];
5559 imux->items[imux->num_items].index = idx;
5566 static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
5567 hda_nid_t nid, int pin_type,
5570 alc_set_pin_output(codec, nid, pin_type);
5571 /* need the manual connection? */
5573 int idx = nid - 0x12;
5574 snd_hda_codec_write(codec, idx + 0x0b, 0,
5575 AC_VERB_SET_CONNECT_SEL, sel_idx);
5579 static void alc260_auto_init_multi_out(struct hda_codec *codec)
5581 struct alc_spec *spec = codec->spec;
5584 alc_subsystem_id(codec, 0x10, 0x15, 0x0f);
5585 nid = spec->autocfg.line_out_pins[0];
5587 int pin_type = get_pin_type(spec->autocfg.line_out_type);
5588 alc260_auto_set_output_and_unmute(codec, nid, pin_type, 0);
5591 nid = spec->autocfg.speaker_pins[0];
5593 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
5595 nid = spec->autocfg.hp_pins[0];
5597 alc260_auto_set_output_and_unmute(codec, nid, PIN_HP, 0);
5600 #define ALC260_PIN_CD_NID 0x16
5601 static void alc260_auto_init_analog_input(struct hda_codec *codec)
5603 struct alc_spec *spec = codec->spec;
5606 for (i = 0; i < AUTO_PIN_LAST; i++) {
5607 hda_nid_t nid = spec->autocfg.input_pins[i];
5609 snd_hda_codec_write(codec, nid, 0,
5610 AC_VERB_SET_PIN_WIDGET_CONTROL,
5611 i <= AUTO_PIN_FRONT_MIC ?
5612 PIN_VREF80 : PIN_IN);
5613 if (nid != ALC260_PIN_CD_NID)
5614 snd_hda_codec_write(codec, nid, 0,
5615 AC_VERB_SET_AMP_GAIN_MUTE,
5622 * generic initialization of ADC, input mixers and output mixers
5624 static struct hda_verb alc260_volume_init_verbs[] = {
5626 * Unmute ADC0-1 and set the default input to mic-in
5628 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5629 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5630 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
5631 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5633 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
5635 * Note: PASD motherboards uses the Line In 2 as the input for
5636 * front panel mic (mic 2)
5638 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
5639 /* mute analog inputs */
5640 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5641 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5642 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5643 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5644 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5647 * Set up output mixers (0x08 - 0x0a)
5649 /* set vol=0 to output mixers */
5650 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5651 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5652 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5653 /* set up input amps for analog loopback */
5654 /* Amp Indices: DAC = 0, mixer = 1 */
5655 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5656 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5657 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5658 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5659 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5660 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5665 static int alc260_parse_auto_config(struct hda_codec *codec)
5667 struct alc_spec *spec = codec->spec;
5669 static hda_nid_t alc260_ignore[] = { 0x17, 0 };
5671 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
5675 err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg);
5678 if (!spec->kctls.list)
5679 return 0; /* can't find valid BIOS pin config */
5680 err = alc260_auto_create_analog_input_ctls(spec, &spec->autocfg);
5684 spec->multiout.max_channels = 2;
5686 if (spec->autocfg.dig_outs)
5687 spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
5688 if (spec->kctls.list)
5689 add_mixer(spec, spec->kctls.list);
5691 add_verb(spec, alc260_volume_init_verbs);
5693 spec->num_mux_defs = 1;
5694 spec->input_mux = &spec->private_imux[0];
5696 store_pin_configs(codec);
5700 /* additional initialization for auto-configuration model */
5701 static void alc260_auto_init(struct hda_codec *codec)
5703 struct alc_spec *spec = codec->spec;
5704 alc260_auto_init_multi_out(codec);
5705 alc260_auto_init_analog_input(codec);
5706 if (spec->unsol_event)
5707 alc_inithook(codec);
5710 #ifdef CONFIG_SND_HDA_POWER_SAVE
5711 static struct hda_amp_list alc260_loopbacks[] = {
5712 { 0x07, HDA_INPUT, 0 },
5713 { 0x07, HDA_INPUT, 1 },
5714 { 0x07, HDA_INPUT, 2 },
5715 { 0x07, HDA_INPUT, 3 },
5716 { 0x07, HDA_INPUT, 4 },
5722 * ALC260 configurations
5724 static const char *alc260_models[ALC260_MODEL_LAST] = {
5725 [ALC260_BASIC] = "basic",
5727 [ALC260_HP_3013] = "hp-3013",
5728 [ALC260_HP_DC7600] = "hp-dc7600",
5729 [ALC260_FUJITSU_S702X] = "fujitsu",
5730 [ALC260_ACER] = "acer",
5731 [ALC260_WILL] = "will",
5732 [ALC260_REPLACER_672V] = "replacer",
5733 #ifdef CONFIG_SND_DEBUG
5734 [ALC260_TEST] = "test",
5736 [ALC260_AUTO] = "auto",
5739 static struct snd_pci_quirk alc260_cfg_tbl[] = {
5740 SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER),
5741 SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER),
5742 SND_PCI_QUIRK(0x103c, 0x2808, "HP d5700", ALC260_HP_3013),
5743 SND_PCI_QUIRK(0x103c, 0x280a, "HP d5750", ALC260_HP_3013),
5744 SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013),
5745 SND_PCI_QUIRK(0x103c, 0x3011, "HP", ALC260_HP_3013),
5746 SND_PCI_QUIRK(0x103c, 0x3012, "HP", ALC260_HP_DC7600),
5747 SND_PCI_QUIRK(0x103c, 0x3013, "HP", ALC260_HP_3013),
5748 SND_PCI_QUIRK(0x103c, 0x3014, "HP", ALC260_HP),
5749 SND_PCI_QUIRK(0x103c, 0x3015, "HP", ALC260_HP),
5750 SND_PCI_QUIRK(0x103c, 0x3016, "HP", ALC260_HP),
5751 SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_BASIC),
5752 SND_PCI_QUIRK(0x104d, 0x81cc, "Sony VAIO", ALC260_BASIC),
5753 SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC),
5754 SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X),
5755 SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC),
5756 SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_REPLACER_672V),
5757 SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_WILL),
5761 static struct alc_config_preset alc260_presets[] = {
5763 .mixers = { alc260_base_output_mixer,
5764 alc260_input_mixer },
5765 .init_verbs = { alc260_init_verbs },
5766 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5767 .dac_nids = alc260_dac_nids,
5768 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
5769 .adc_nids = alc260_adc_nids,
5770 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5771 .channel_mode = alc260_modes,
5772 .input_mux = &alc260_capture_source,
5775 .mixers = { alc260_hp_output_mixer,
5776 alc260_input_mixer },
5777 .init_verbs = { alc260_init_verbs,
5778 alc260_hp_unsol_verbs },
5779 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5780 .dac_nids = alc260_dac_nids,
5781 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
5782 .adc_nids = alc260_adc_nids_alt,
5783 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5784 .channel_mode = alc260_modes,
5785 .input_mux = &alc260_capture_source,
5786 .unsol_event = alc260_hp_unsol_event,
5787 .init_hook = alc260_hp_automute,
5789 [ALC260_HP_DC7600] = {
5790 .mixers = { alc260_hp_dc7600_mixer,
5791 alc260_input_mixer },
5792 .init_verbs = { alc260_init_verbs,
5793 alc260_hp_dc7600_verbs },
5794 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5795 .dac_nids = alc260_dac_nids,
5796 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
5797 .adc_nids = alc260_adc_nids_alt,
5798 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5799 .channel_mode = alc260_modes,
5800 .input_mux = &alc260_capture_source,
5801 .unsol_event = alc260_hp_3012_unsol_event,
5802 .init_hook = alc260_hp_3012_automute,
5804 [ALC260_HP_3013] = {
5805 .mixers = { alc260_hp_3013_mixer,
5806 alc260_input_mixer },
5807 .init_verbs = { alc260_hp_3013_init_verbs,
5808 alc260_hp_3013_unsol_verbs },
5809 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5810 .dac_nids = alc260_dac_nids,
5811 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
5812 .adc_nids = alc260_adc_nids_alt,
5813 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5814 .channel_mode = alc260_modes,
5815 .input_mux = &alc260_capture_source,
5816 .unsol_event = alc260_hp_3013_unsol_event,
5817 .init_hook = alc260_hp_3013_automute,
5819 [ALC260_FUJITSU_S702X] = {
5820 .mixers = { alc260_fujitsu_mixer },
5821 .init_verbs = { alc260_fujitsu_init_verbs },
5822 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5823 .dac_nids = alc260_dac_nids,
5824 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
5825 .adc_nids = alc260_dual_adc_nids,
5826 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5827 .channel_mode = alc260_modes,
5828 .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources),
5829 .input_mux = alc260_fujitsu_capture_sources,
5832 .mixers = { alc260_acer_mixer },
5833 .init_verbs = { alc260_acer_init_verbs },
5834 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5835 .dac_nids = alc260_dac_nids,
5836 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
5837 .adc_nids = alc260_dual_adc_nids,
5838 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5839 .channel_mode = alc260_modes,
5840 .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
5841 .input_mux = alc260_acer_capture_sources,
5844 .mixers = { alc260_will_mixer },
5845 .init_verbs = { alc260_init_verbs, alc260_will_verbs },
5846 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5847 .dac_nids = alc260_dac_nids,
5848 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
5849 .adc_nids = alc260_adc_nids,
5850 .dig_out_nid = ALC260_DIGOUT_NID,
5851 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5852 .channel_mode = alc260_modes,
5853 .input_mux = &alc260_capture_source,
5855 [ALC260_REPLACER_672V] = {
5856 .mixers = { alc260_replacer_672v_mixer },
5857 .init_verbs = { alc260_init_verbs, alc260_replacer_672v_verbs },
5858 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5859 .dac_nids = alc260_dac_nids,
5860 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
5861 .adc_nids = alc260_adc_nids,
5862 .dig_out_nid = ALC260_DIGOUT_NID,
5863 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5864 .channel_mode = alc260_modes,
5865 .input_mux = &alc260_capture_source,
5866 .unsol_event = alc260_replacer_672v_unsol_event,
5867 .init_hook = alc260_replacer_672v_automute,
5869 #ifdef CONFIG_SND_DEBUG
5871 .mixers = { alc260_test_mixer },
5872 .init_verbs = { alc260_test_init_verbs },
5873 .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
5874 .dac_nids = alc260_test_dac_nids,
5875 .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
5876 .adc_nids = alc260_test_adc_nids,
5877 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5878 .channel_mode = alc260_modes,
5879 .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources),
5880 .input_mux = alc260_test_capture_sources,
5885 static int patch_alc260(struct hda_codec *codec)
5887 struct alc_spec *spec;
5888 int err, board_config;
5890 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5896 board_config = snd_hda_check_board_config(codec, ALC260_MODEL_LAST,
5899 if (board_config < 0) {
5900 snd_printd(KERN_INFO "hda_codec: Unknown model for ALC260, "
5901 "trying auto-probe from BIOS...\n");
5902 board_config = ALC260_AUTO;
5905 if (board_config == ALC260_AUTO) {
5906 /* automatic parse from the BIOS config */
5907 err = alc260_parse_auto_config(codec);
5913 "hda_codec: Cannot set up configuration "
5914 "from BIOS. Using base mode...\n");
5915 board_config = ALC260_BASIC;
5919 err = snd_hda_attach_beep_device(codec, 0x1);
5925 if (board_config != ALC260_AUTO)
5926 setup_preset(spec, &alc260_presets[board_config]);
5928 spec->stream_name_analog = "ALC260 Analog";
5929 spec->stream_analog_playback = &alc260_pcm_analog_playback;
5930 spec->stream_analog_capture = &alc260_pcm_analog_capture;
5932 spec->stream_name_digital = "ALC260 Digital";
5933 spec->stream_digital_playback = &alc260_pcm_digital_playback;
5934 spec->stream_digital_capture = &alc260_pcm_digital_capture;
5936 if (!spec->adc_nids && spec->input_mux) {
5937 /* check whether NID 0x04 is valid */
5938 unsigned int wcap = get_wcaps(codec, 0x04);
5939 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
5941 if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
5942 spec->adc_nids = alc260_adc_nids_alt;
5943 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
5945 spec->adc_nids = alc260_adc_nids;
5946 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
5949 set_capture_mixer(spec);
5950 set_beep_amp(spec, 0x07, 0x05, HDA_INPUT);
5952 spec->vmaster_nid = 0x08;
5954 codec->patch_ops = alc_patch_ops;
5955 if (board_config == ALC260_AUTO)
5956 spec->init_hook = alc260_auto_init;
5957 #ifdef CONFIG_SND_HDA_POWER_SAVE
5958 if (!spec->loopback.amplist)
5959 spec->loopback.amplist = alc260_loopbacks;
5961 codec->proc_widget_hook = print_realtek_coef;
5970 * ALC882 is almost identical with ALC880 but has cleaner and more flexible
5971 * configuration. Each pin widget can choose any input DACs and a mixer.
5972 * Each ADC is connected from a mixer of all inputs. This makes possible
5973 * 6-channel independent captures.
5975 * In addition, an independent DAC for the multi-playback (not used in this
5978 #define ALC882_DIGOUT_NID 0x06
5979 #define ALC882_DIGIN_NID 0x0a
5981 static struct hda_channel_mode alc882_ch_modes[1] = {
5985 static hda_nid_t alc882_dac_nids[4] = {
5986 /* front, rear, clfe, rear_surr */
5987 0x02, 0x03, 0x04, 0x05
5990 /* identical with ALC880 */
5991 #define alc882_adc_nids alc880_adc_nids
5992 #define alc882_adc_nids_alt alc880_adc_nids_alt
5994 static hda_nid_t alc882_capsrc_nids[3] = { 0x24, 0x23, 0x22 };
5995 static hda_nid_t alc882_capsrc_nids_alt[2] = { 0x23, 0x22 };
5998 /* FIXME: should be a matrix-type input source selection */
6000 static struct hda_input_mux alc882_capture_source = {
6004 { "Front Mic", 0x1 },
6012 static struct hda_verb alc882_3ST_ch2_init[] = {
6013 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6014 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6015 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6016 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6023 static struct hda_verb alc882_3ST_ch6_init[] = {
6024 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6025 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6026 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
6027 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6028 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6029 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6033 static struct hda_channel_mode alc882_3ST_6ch_modes[2] = {
6034 { 2, alc882_3ST_ch2_init },
6035 { 6, alc882_3ST_ch6_init },
6041 static struct hda_verb alc882_sixstack_ch6_init[] = {
6042 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
6043 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6044 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6045 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6052 static struct hda_verb alc882_sixstack_ch8_init[] = {
6053 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6054 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6055 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6056 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6060 static struct hda_channel_mode alc882_sixstack_modes[2] = {
6061 { 6, alc882_sixstack_ch6_init },
6062 { 8, alc882_sixstack_ch8_init },
6066 * macbook pro ALC885 can switch LineIn to LineOut without loosing Mic
6072 static struct hda_verb alc885_mbp_ch2_init[] = {
6073 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6074 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6075 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6082 static struct hda_verb alc885_mbp_ch6_init[] = {
6083 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6084 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6085 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6086 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6087 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6091 static struct hda_channel_mode alc885_mbp_6ch_modes[2] = {
6092 { 2, alc885_mbp_ch2_init },
6093 { 6, alc885_mbp_ch6_init },
6097 /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
6098 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
6100 static struct snd_kcontrol_new alc882_base_mixer[] = {
6101 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6102 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6103 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
6104 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
6105 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
6106 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
6107 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
6108 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
6109 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
6110 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
6111 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6112 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6113 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6114 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6115 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6116 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6117 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6118 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6119 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6120 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
6121 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6125 static struct snd_kcontrol_new alc885_mbp3_mixer[] = {
6126 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
6127 HDA_BIND_MUTE ("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
6128 HDA_CODEC_MUTE ("Speaker Playback Switch", 0x14, 0x00, HDA_OUTPUT),
6129 HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
6130 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6131 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6132 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
6133 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
6134 HDA_CODEC_VOLUME("Line Boost", 0x1a, 0x00, HDA_INPUT),
6135 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
6138 static struct snd_kcontrol_new alc882_w2jc_mixer[] = {
6139 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6140 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6141 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6142 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6143 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6144 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6145 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6146 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6147 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6151 static struct snd_kcontrol_new alc882_targa_mixer[] = {
6152 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6153 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6154 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6155 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6156 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6157 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6158 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6159 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6160 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6161 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6162 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6163 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6164 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
6168 /* Pin assignment: Front=0x14, HP = 0x15, Front = 0x16, ???
6169 * Front Mic=0x18, Line In = 0x1a, Line In = 0x1b, CD = 0x1c
6171 static struct snd_kcontrol_new alc882_asus_a7j_mixer[] = {
6172 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6173 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6174 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
6175 HDA_CODEC_MUTE("Mobile Front Playback Switch", 0x16, 0x0, HDA_OUTPUT),
6176 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6177 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6178 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6179 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6180 HDA_CODEC_VOLUME("Mobile Line Playback Volume", 0x0b, 0x03, HDA_INPUT),
6181 HDA_CODEC_MUTE("Mobile Line Playback Switch", 0x0b, 0x03, HDA_INPUT),
6182 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6183 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6184 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6188 static struct snd_kcontrol_new alc882_asus_a7m_mixer[] = {
6189 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6190 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6191 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
6192 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6193 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6194 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6195 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6196 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6197 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6198 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6202 static struct snd_kcontrol_new alc882_chmode_mixer[] = {
6204 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6205 .name = "Channel Mode",
6206 .info = alc_ch_mode_info,
6207 .get = alc_ch_mode_get,
6208 .put = alc_ch_mode_put,
6213 static struct hda_verb alc882_init_verbs[] = {
6214 /* Front mixer: unmute input/output amp left and right (volume = 0) */
6215 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6216 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6217 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6219 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6220 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6221 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6223 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6224 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6225 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6227 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6228 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6229 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6231 /* Front Pin: output 0 (0x0c) */
6232 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6233 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6234 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
6235 /* Rear Pin: output 1 (0x0d) */
6236 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6237 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6238 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
6239 /* CLFE Pin: output 2 (0x0e) */
6240 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6241 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6242 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
6243 /* Side Pin: output 3 (0x0f) */
6244 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6245 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6246 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
6247 /* Mic (rear) pin: input vref at 80% */
6248 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6249 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6250 /* Front Mic pin: input vref at 80% */
6251 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6252 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6253 /* Line In pin: input */
6254 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
6255 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6256 /* Line-2 In: Headphone output (output 0 - 0x0c) */
6257 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6258 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6259 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
6260 /* CD pin widget for input */
6261 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
6263 /* FIXME: use matrix-type input source selection */
6264 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6265 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
6266 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6267 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6268 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6269 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6271 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6272 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6273 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6274 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6276 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6277 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6278 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6279 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6280 /* ADC1: mute amp left and right */
6281 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6282 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
6283 /* ADC2: mute amp left and right */
6284 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6285 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6286 /* ADC3: mute amp left and right */
6287 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6288 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
6293 static struct hda_verb alc882_eapd_verbs[] = {
6294 /* change to EAPD mode */
6295 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
6296 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
6301 static struct snd_kcontrol_new alc882_macpro_mixer[] = {
6302 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6303 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6304 HDA_CODEC_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT),
6305 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
6306 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
6307 /* FIXME: this looks suspicious...
6308 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x02, HDA_INPUT),
6309 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x02, HDA_INPUT),
6314 static struct hda_verb alc882_macpro_init_verbs[] = {
6315 /* Front mixer: unmute input/output amp left and right (volume = 0) */
6316 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6317 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6318 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6319 /* Front Pin: output 0 (0x0c) */
6320 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6321 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6322 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
6323 /* Front Mic pin: input vref at 80% */
6324 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6325 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6326 /* Speaker: output */
6327 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6328 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6329 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x04},
6330 /* Headphone output (output 0 - 0x0c) */
6331 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6332 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6333 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
6335 /* FIXME: use matrix-type input source selection */
6336 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6337 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
6338 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6339 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6340 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6341 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6343 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6344 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6345 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6346 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6348 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6349 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6350 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6351 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6352 /* ADC1: mute amp left and right */
6353 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6354 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
6355 /* ADC2: mute amp left and right */
6356 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6357 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6358 /* ADC3: mute amp left and right */
6359 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6360 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
6365 /* Macbook Pro rev3 */
6366 static struct hda_verb alc885_mbp3_init_verbs[] = {
6367 /* Front mixer: unmute input/output amp left and right (volume = 0) */
6368 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6369 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6370 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6372 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6373 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6374 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6375 /* Front Pin: output 0 (0x0c) */
6376 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6377 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6378 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
6379 /* HP Pin: output 0 (0x0d) */
6380 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4},
6381 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6382 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
6383 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
6384 /* Mic (rear) pin: input vref at 80% */
6385 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6386 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6387 /* Front Mic pin: input vref at 80% */
6388 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6389 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6390 /* Line In pin: use output 1 when in LineOut mode */
6391 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
6392 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6393 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
6395 /* FIXME: use matrix-type input source selection */
6396 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6397 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
6398 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6399 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6400 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6401 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6403 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6404 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6405 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6406 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6408 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6409 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6410 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6411 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6412 /* ADC1: mute amp left and right */
6413 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6414 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
6415 /* ADC2: mute amp left and right */
6416 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6417 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6418 /* ADC3: mute amp left and right */
6419 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6420 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
6425 /* iMac 24 mixer. */
6426 static struct snd_kcontrol_new alc885_imac24_mixer[] = {
6427 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
6428 HDA_CODEC_MUTE("Master Playback Switch", 0x0c, 0x00, HDA_INPUT),
6432 /* iMac 24 init verbs. */
6433 static struct hda_verb alc885_imac24_init_verbs[] = {
6434 /* Internal speakers: output 0 (0x0c) */
6435 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6436 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6437 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
6438 /* Internal speakers: output 0 (0x0c) */
6439 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6440 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6441 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
6442 /* Headphone: output 0 (0x0c) */
6443 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6444 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6445 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
6446 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
6447 /* Front Mic: input vref at 80% */
6448 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6449 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6453 /* Toggle speaker-output according to the hp-jack state */
6454 static void alc885_imac24_automute(struct hda_codec *codec)
6456 unsigned int present;
6458 present = snd_hda_codec_read(codec, 0x14, 0,
6459 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
6460 snd_hda_codec_amp_stereo(codec, 0x18, HDA_OUTPUT, 0,
6461 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
6462 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_OUTPUT, 0,
6463 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
6466 /* Processes unsolicited events. */
6467 static void alc885_imac24_unsol_event(struct hda_codec *codec,
6470 /* Headphone insertion or removal. */
6471 if ((res >> 26) == ALC880_HP_EVENT)
6472 alc885_imac24_automute(codec);
6475 static void alc885_mbp3_automute(struct hda_codec *codec)
6477 unsigned int present;
6479 present = snd_hda_codec_read(codec, 0x15, 0,
6480 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
6481 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
6482 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
6483 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
6484 HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
6487 static void alc885_mbp3_unsol_event(struct hda_codec *codec,
6490 /* Headphone insertion or removal. */
6491 if ((res >> 26) == ALC880_HP_EVENT)
6492 alc885_mbp3_automute(codec);
6496 static struct hda_verb alc882_targa_verbs[] = {
6497 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6498 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6500 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6501 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6503 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
6504 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
6505 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6507 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
6508 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
6509 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
6510 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
6514 /* toggle speaker-output according to the hp-jack state */
6515 static void alc882_targa_automute(struct hda_codec *codec)
6517 unsigned int present;
6519 present = snd_hda_codec_read(codec, 0x14, 0,
6520 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
6521 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
6522 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
6523 snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
6527 static void alc882_targa_unsol_event(struct hda_codec *codec, unsigned int res)
6529 /* Looks like the unsol event is incompatible with the standard
6530 * definition. 4bit tag is placed at 26 bit!
6532 if (((res >> 26) == ALC880_HP_EVENT)) {
6533 alc882_targa_automute(codec);
6537 static struct hda_verb alc882_asus_a7j_verbs[] = {
6538 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6539 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6541 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6542 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6543 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6545 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
6546 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6547 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
6549 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
6550 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
6551 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6555 static struct hda_verb alc882_asus_a7m_verbs[] = {
6556 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6557 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6559 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6560 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6561 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6563 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
6564 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6565 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
6567 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
6568 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
6569 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6573 static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
6575 unsigned int gpiostate, gpiomask, gpiodir;
6577 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
6578 AC_VERB_GET_GPIO_DATA, 0);
6581 gpiostate |= (1 << pin);
6583 gpiostate &= ~(1 << pin);
6585 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
6586 AC_VERB_GET_GPIO_MASK, 0);
6587 gpiomask |= (1 << pin);
6589 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
6590 AC_VERB_GET_GPIO_DIRECTION, 0);
6591 gpiodir |= (1 << pin);
6594 snd_hda_codec_write(codec, codec->afg, 0,
6595 AC_VERB_SET_GPIO_MASK, gpiomask);
6596 snd_hda_codec_write(codec, codec->afg, 0,
6597 AC_VERB_SET_GPIO_DIRECTION, gpiodir);
6601 snd_hda_codec_write(codec, codec->afg, 0,
6602 AC_VERB_SET_GPIO_DATA, gpiostate);
6605 /* set up GPIO at initialization */
6606 static void alc885_macpro_init_hook(struct hda_codec *codec)
6608 alc882_gpio_mute(codec, 0, 0);
6609 alc882_gpio_mute(codec, 1, 0);
6612 /* set up GPIO and update auto-muting at initialization */
6613 static void alc885_imac24_init_hook(struct hda_codec *codec)
6615 alc885_macpro_init_hook(codec);
6616 alc885_imac24_automute(codec);
6620 * generic initialization of ADC, input mixers and output mixers
6622 static struct hda_verb alc882_auto_init_verbs[] = {
6624 * Unmute ADC0-2 and set the default input to mic-in
6626 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
6627 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6628 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6629 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6630 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
6631 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6633 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
6635 * Note: PASD motherboards uses the Line In 2 as the input for
6636 * front panel mic (mic 2)
6638 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
6639 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6640 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6641 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6642 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6643 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6646 * Set up output mixers (0x0c - 0x0f)
6648 /* set vol=0 to output mixers */
6649 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6650 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6651 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6652 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6653 /* set up input amps for analog loopback */
6654 /* Amp Indices: DAC = 0, mixer = 1 */
6655 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6656 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6657 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6658 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6659 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6660 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6661 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6662 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6663 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6664 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6666 /* FIXME: use matrix-type input source selection */
6667 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6668 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
6669 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6670 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
6671 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
6672 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
6674 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6675 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
6676 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
6677 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
6679 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6680 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
6681 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
6682 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
6687 #ifdef CONFIG_SND_HDA_POWER_SAVE
6688 #define alc882_loopbacks alc880_loopbacks
6691 /* pcm configuration: identiacal with ALC880 */
6692 #define alc882_pcm_analog_playback alc880_pcm_analog_playback
6693 #define alc882_pcm_analog_capture alc880_pcm_analog_capture
6694 #define alc882_pcm_digital_playback alc880_pcm_digital_playback
6695 #define alc882_pcm_digital_capture alc880_pcm_digital_capture
6698 * configuration and preset
6700 static const char *alc882_models[ALC882_MODEL_LAST] = {
6701 [ALC882_3ST_DIG] = "3stack-dig",
6702 [ALC882_6ST_DIG] = "6stack-dig",
6703 [ALC882_ARIMA] = "arima",
6704 [ALC882_W2JC] = "w2jc",
6705 [ALC882_TARGA] = "targa",
6706 [ALC882_ASUS_A7J] = "asus-a7j",
6707 [ALC882_ASUS_A7M] = "asus-a7m",
6708 [ALC885_MACPRO] = "macpro",
6709 [ALC885_MBP3] = "mbp3",
6710 [ALC885_IMAC24] = "imac24",
6711 [ALC882_AUTO] = "auto",
6714 static struct snd_pci_quirk alc882_cfg_tbl[] = {
6715 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG),
6716 SND_PCI_QUIRK(0x1043, 0x060d, "Asus A7J", ALC882_ASUS_A7J),
6717 SND_PCI_QUIRK(0x1043, 0x1243, "Asus A7J", ALC882_ASUS_A7J),
6718 SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_ASUS_A7M),
6719 SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_W2JC),
6720 SND_PCI_QUIRK(0x1043, 0x817f, "Asus P5LD2", ALC882_6ST_DIG),
6721 SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG),
6722 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG),
6723 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte P35 DS3R", ALC882_6ST_DIG),
6724 SND_PCI_QUIRK(0x1462, 0x28fb, "Targa T8", ALC882_TARGA), /* MSI-1049 T8 */
6725 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG),
6726 SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA),
6730 static struct alc_config_preset alc882_presets[] = {
6731 [ALC882_3ST_DIG] = {
6732 .mixers = { alc882_base_mixer },
6733 .init_verbs = { alc882_init_verbs },
6734 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6735 .dac_nids = alc882_dac_nids,
6736 .dig_out_nid = ALC882_DIGOUT_NID,
6737 .dig_in_nid = ALC882_DIGIN_NID,
6738 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
6739 .channel_mode = alc882_ch_modes,
6741 .input_mux = &alc882_capture_source,
6743 [ALC882_6ST_DIG] = {
6744 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
6745 .init_verbs = { alc882_init_verbs },
6746 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6747 .dac_nids = alc882_dac_nids,
6748 .dig_out_nid = ALC882_DIGOUT_NID,
6749 .dig_in_nid = ALC882_DIGIN_NID,
6750 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
6751 .channel_mode = alc882_sixstack_modes,
6752 .input_mux = &alc882_capture_source,
6755 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
6756 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs },
6757 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6758 .dac_nids = alc882_dac_nids,
6759 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
6760 .channel_mode = alc882_sixstack_modes,
6761 .input_mux = &alc882_capture_source,
6764 .mixers = { alc882_w2jc_mixer, alc882_chmode_mixer },
6765 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs,
6766 alc880_gpio1_init_verbs },
6767 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6768 .dac_nids = alc882_dac_nids,
6769 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
6770 .channel_mode = alc880_threestack_modes,
6772 .input_mux = &alc882_capture_source,
6773 .dig_out_nid = ALC882_DIGOUT_NID,
6776 .mixers = { alc885_mbp3_mixer, alc882_chmode_mixer },
6777 .init_verbs = { alc885_mbp3_init_verbs,
6778 alc880_gpio1_init_verbs },
6779 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6780 .dac_nids = alc882_dac_nids,
6781 .channel_mode = alc885_mbp_6ch_modes,
6782 .num_channel_mode = ARRAY_SIZE(alc885_mbp_6ch_modes),
6783 .input_mux = &alc882_capture_source,
6784 .dig_out_nid = ALC882_DIGOUT_NID,
6785 .dig_in_nid = ALC882_DIGIN_NID,
6786 .unsol_event = alc885_mbp3_unsol_event,
6787 .init_hook = alc885_mbp3_automute,
6790 .mixers = { alc882_macpro_mixer },
6791 .init_verbs = { alc882_macpro_init_verbs },
6792 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6793 .dac_nids = alc882_dac_nids,
6794 .dig_out_nid = ALC882_DIGOUT_NID,
6795 .dig_in_nid = ALC882_DIGIN_NID,
6796 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
6797 .channel_mode = alc882_ch_modes,
6798 .input_mux = &alc882_capture_source,
6799 .init_hook = alc885_macpro_init_hook,
6802 .mixers = { alc885_imac24_mixer },
6803 .init_verbs = { alc885_imac24_init_verbs },
6804 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6805 .dac_nids = alc882_dac_nids,
6806 .dig_out_nid = ALC882_DIGOUT_NID,
6807 .dig_in_nid = ALC882_DIGIN_NID,
6808 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
6809 .channel_mode = alc882_ch_modes,
6810 .input_mux = &alc882_capture_source,
6811 .unsol_event = alc885_imac24_unsol_event,
6812 .init_hook = alc885_imac24_init_hook,
6815 .mixers = { alc882_targa_mixer, alc882_chmode_mixer },
6816 .init_verbs = { alc882_init_verbs, alc882_targa_verbs},
6817 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6818 .dac_nids = alc882_dac_nids,
6819 .dig_out_nid = ALC882_DIGOUT_NID,
6820 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
6821 .adc_nids = alc882_adc_nids,
6822 .capsrc_nids = alc882_capsrc_nids,
6823 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
6824 .channel_mode = alc882_3ST_6ch_modes,
6826 .input_mux = &alc882_capture_source,
6827 .unsol_event = alc882_targa_unsol_event,
6828 .init_hook = alc882_targa_automute,
6830 [ALC882_ASUS_A7J] = {
6831 .mixers = { alc882_asus_a7j_mixer, alc882_chmode_mixer },
6832 .init_verbs = { alc882_init_verbs, alc882_asus_a7j_verbs},
6833 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6834 .dac_nids = alc882_dac_nids,
6835 .dig_out_nid = ALC882_DIGOUT_NID,
6836 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
6837 .adc_nids = alc882_adc_nids,
6838 .capsrc_nids = alc882_capsrc_nids,
6839 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
6840 .channel_mode = alc882_3ST_6ch_modes,
6842 .input_mux = &alc882_capture_source,
6844 [ALC882_ASUS_A7M] = {
6845 .mixers = { alc882_asus_a7m_mixer, alc882_chmode_mixer },
6846 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs,
6847 alc880_gpio1_init_verbs,
6848 alc882_asus_a7m_verbs },
6849 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6850 .dac_nids = alc882_dac_nids,
6851 .dig_out_nid = ALC882_DIGOUT_NID,
6852 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
6853 .channel_mode = alc880_threestack_modes,
6855 .input_mux = &alc882_capture_source,
6864 PINFIX_ABIT_AW9D_MAX
6867 static struct alc_pincfg alc882_abit_aw9d_pinfix[] = {
6868 { 0x15, 0x01080104 }, /* side */
6869 { 0x16, 0x01011012 }, /* rear */
6870 { 0x17, 0x01016011 }, /* clfe */
6874 static const struct alc_pincfg *alc882_pin_fixes[] = {
6875 [PINFIX_ABIT_AW9D_MAX] = alc882_abit_aw9d_pinfix,
6878 static struct snd_pci_quirk alc882_pinfix_tbl[] = {
6879 SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", PINFIX_ABIT_AW9D_MAX),
6884 * BIOS auto configuration
6886 static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
6887 hda_nid_t nid, int pin_type,
6891 struct alc_spec *spec = codec->spec;
6894 alc_set_pin_output(codec, nid, pin_type);
6895 if (spec->multiout.dac_nids[dac_idx] == 0x25)
6898 idx = spec->multiout.dac_nids[dac_idx] - 2;
6899 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
6903 static void alc882_auto_init_multi_out(struct hda_codec *codec)
6905 struct alc_spec *spec = codec->spec;
6908 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
6909 for (i = 0; i <= HDA_SIDE; i++) {
6910 hda_nid_t nid = spec->autocfg.line_out_pins[i];
6911 int pin_type = get_pin_type(spec->autocfg.line_out_type);
6913 alc882_auto_set_output_and_unmute(codec, nid, pin_type,
6918 static void alc882_auto_init_hp_out(struct hda_codec *codec)
6920 struct alc_spec *spec = codec->spec;
6923 pin = spec->autocfg.hp_pins[0];
6924 if (pin) /* connect to front */
6926 alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
6927 pin = spec->autocfg.speaker_pins[0];
6929 alc882_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
6932 #define alc882_is_input_pin(nid) alc880_is_input_pin(nid)
6933 #define ALC882_PIN_CD_NID ALC880_PIN_CD_NID
6935 static void alc882_auto_init_analog_input(struct hda_codec *codec)
6937 struct alc_spec *spec = codec->spec;
6940 for (i = 0; i < AUTO_PIN_LAST; i++) {
6941 hda_nid_t nid = spec->autocfg.input_pins[i];
6946 if (1 /*i <= AUTO_PIN_FRONT_MIC*/) {
6947 unsigned int pincap;
6948 pincap = snd_hda_param_read(codec, nid, AC_PAR_PIN_CAP);
6949 if ((pincap >> AC_PINCAP_VREF_SHIFT) &
6953 snd_hda_codec_write(codec, nid, 0,
6954 AC_VERB_SET_PIN_WIDGET_CONTROL, vref);
6955 if (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP)
6956 snd_hda_codec_write(codec, nid, 0,
6957 AC_VERB_SET_AMP_GAIN_MUTE,
6962 static void alc882_auto_init_input_src(struct hda_codec *codec)
6964 struct alc_spec *spec = codec->spec;
6967 for (c = 0; c < spec->num_adc_nids; c++) {
6968 hda_nid_t conn_list[HDA_MAX_NUM_INPUTS];
6969 hda_nid_t nid = spec->capsrc_nids[c];
6970 unsigned int mux_idx;
6971 const struct hda_input_mux *imux;
6972 int conns, mute, idx, item;
6974 conns = snd_hda_get_connections(codec, nid, conn_list,
6975 ARRAY_SIZE(conn_list));
6978 mux_idx = c >= spec->num_mux_defs ? 0 : c;
6979 imux = &spec->input_mux[mux_idx];
6980 for (idx = 0; idx < conns; idx++) {
6981 /* if the current connection is the selected one,
6982 * unmute it as default - otherwise mute it
6984 mute = AMP_IN_MUTE(idx);
6985 for (item = 0; item < imux->num_items; item++) {
6986 if (imux->items[item].index == idx) {
6987 if (spec->cur_mux[c] == item)
6988 mute = AMP_IN_UNMUTE(idx);
6992 /* check if we have a selector or mixer
6993 * we could check for the widget type instead, but
6994 * just check for Amp-In presence (in case of mixer
6995 * without amp-in there is something wrong, this
6996 * function shouldn't be used or capsrc nid is wrong)
6998 if (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)
6999 snd_hda_codec_write(codec, nid, 0,
7000 AC_VERB_SET_AMP_GAIN_MUTE,
7002 else if (mute != AMP_IN_MUTE(idx))
7003 snd_hda_codec_write(codec, nid, 0,
7004 AC_VERB_SET_CONNECT_SEL,
7010 /* add mic boosts if needed */
7011 static int alc_auto_add_mic_boost(struct hda_codec *codec)
7013 struct alc_spec *spec = codec->spec;
7017 nid = spec->autocfg.input_pins[AUTO_PIN_MIC];
7018 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
7019 err = add_control(spec, ALC_CTL_WIDGET_VOL,
7021 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
7025 nid = spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC];
7026 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
7027 err = add_control(spec, ALC_CTL_WIDGET_VOL,
7029 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
7036 /* almost identical with ALC880 parser... */
7037 static int alc882_parse_auto_config(struct hda_codec *codec)
7039 struct alc_spec *spec = codec->spec;
7040 int err = alc880_parse_auto_config(codec);
7045 return 0; /* no config found */
7047 err = alc_auto_add_mic_boost(codec);
7051 /* hack - override the init verbs */
7052 spec->init_verbs[0] = alc882_auto_init_verbs;
7054 return 1; /* config found */
7057 /* additional initialization for auto-configuration model */
7058 static void alc882_auto_init(struct hda_codec *codec)
7060 struct alc_spec *spec = codec->spec;
7061 alc882_auto_init_multi_out(codec);
7062 alc882_auto_init_hp_out(codec);
7063 alc882_auto_init_analog_input(codec);
7064 alc882_auto_init_input_src(codec);
7065 if (spec->unsol_event)
7066 alc_inithook(codec);
7069 static int patch_alc883(struct hda_codec *codec); /* called in patch_alc882() */
7071 static int patch_alc882(struct hda_codec *codec)
7073 struct alc_spec *spec;
7074 int err, board_config;
7076 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
7082 board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST,
7086 if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
7087 /* Pick up systems that don't supply PCI SSID */
7088 switch (codec->subsystem_id) {
7089 case 0x106b0c00: /* Mac Pro */
7090 board_config = ALC885_MACPRO;
7092 case 0x106b1000: /* iMac 24 */
7093 case 0x106b2800: /* AppleTV */
7094 case 0x106b3e00: /* iMac 24 Aluminium */
7095 board_config = ALC885_IMAC24;
7097 case 0x106b00a1: /* Macbook (might be wrong - PCI SSID?) */
7098 case 0x106b00a4: /* MacbookPro4,1 */
7099 case 0x106b2c00: /* Macbook Pro rev3 */
7100 case 0x106b3600: /* Macbook 3.1 */
7101 case 0x106b3800: /* MacbookPro4,1 - latter revision */
7102 board_config = ALC885_MBP3;
7105 /* ALC889A is handled better as ALC888-compatible */
7106 if (codec->revision_id == 0x100101 ||
7107 codec->revision_id == 0x100103) {
7109 return patch_alc883(codec);
7111 printk(KERN_INFO "hda_codec: Unknown model for ALC882, "
7112 "trying auto-probe from BIOS...\n");
7113 board_config = ALC882_AUTO;
7117 alc_fix_pincfg(codec, alc882_pinfix_tbl, alc882_pin_fixes);
7119 if (board_config == ALC882_AUTO) {
7120 /* automatic parse from the BIOS config */
7121 err = alc882_parse_auto_config(codec);
7127 "hda_codec: Cannot set up configuration "
7128 "from BIOS. Using base mode...\n");
7129 board_config = ALC882_3ST_DIG;
7133 err = snd_hda_attach_beep_device(codec, 0x1);
7139 if (board_config != ALC882_AUTO)
7140 setup_preset(spec, &alc882_presets[board_config]);
7142 if (codec->vendor_id == 0x10ec0885) {
7143 spec->stream_name_analog = "ALC885 Analog";
7144 spec->stream_name_digital = "ALC885 Digital";
7146 spec->stream_name_analog = "ALC882 Analog";
7147 spec->stream_name_digital = "ALC882 Digital";
7150 spec->stream_analog_playback = &alc882_pcm_analog_playback;
7151 spec->stream_analog_capture = &alc882_pcm_analog_capture;
7152 /* FIXME: setup DAC5 */
7153 /*spec->stream_analog_alt_playback = &alc880_pcm_analog_alt_playback;*/
7154 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
7156 spec->stream_digital_playback = &alc882_pcm_digital_playback;
7157 spec->stream_digital_capture = &alc882_pcm_digital_capture;
7159 spec->capture_style = CAPT_MIX; /* matrix-style capture */
7160 if (!spec->adc_nids && spec->input_mux) {
7161 /* check whether NID 0x07 is valid */
7162 unsigned int wcap = get_wcaps(codec, 0x07);
7164 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
7165 if (wcap != AC_WID_AUD_IN) {
7166 spec->adc_nids = alc882_adc_nids_alt;
7167 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids_alt);
7168 spec->capsrc_nids = alc882_capsrc_nids_alt;
7170 spec->adc_nids = alc882_adc_nids;
7171 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids);
7172 spec->capsrc_nids = alc882_capsrc_nids;
7175 set_capture_mixer(spec);
7176 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
7178 spec->vmaster_nid = 0x0c;
7180 codec->patch_ops = alc_patch_ops;
7181 if (board_config == ALC882_AUTO)
7182 spec->init_hook = alc882_auto_init;
7183 #ifdef CONFIG_SND_HDA_POWER_SAVE
7184 if (!spec->loopback.amplist)
7185 spec->loopback.amplist = alc882_loopbacks;
7187 codec->proc_widget_hook = print_realtek_coef;
7195 * ALC883 is almost identical with ALC880 but has cleaner and more flexible
7196 * configuration. Each pin widget can choose any input DACs and a mixer.
7197 * Each ADC is connected from a mixer of all inputs. This makes possible
7198 * 6-channel independent captures.
7200 * In addition, an independent DAC for the multi-playback (not used in this
7203 #define ALC883_DIGOUT_NID 0x06
7204 #define ALC883_DIGIN_NID 0x0a
7206 #define ALC1200_DIGOUT_NID 0x10
7208 static hda_nid_t alc883_dac_nids[4] = {
7209 /* front, rear, clfe, rear_surr */
7210 0x02, 0x03, 0x04, 0x05
7213 static hda_nid_t alc883_adc_nids[2] = {
7218 static hda_nid_t alc883_adc_nids_alt[1] = {
7223 static hda_nid_t alc883_adc_nids_rev[2] = {
7228 #define alc889_adc_nids alc880_adc_nids
7230 static hda_nid_t alc883_capsrc_nids[2] = { 0x23, 0x22 };
7232 static hda_nid_t alc883_capsrc_nids_rev[2] = { 0x22, 0x23 };
7234 #define alc889_capsrc_nids alc882_capsrc_nids
7237 /* FIXME: should be a matrix-type input source selection */
7239 static struct hda_input_mux alc883_capture_source = {
7243 { "Front Mic", 0x1 },
7249 static struct hda_input_mux alc883_3stack_6ch_intel = {
7253 { "Front Mic", 0x0 },
7259 static struct hda_input_mux alc883_lenovo_101e_capture_source = {
7267 static struct hda_input_mux alc883_lenovo_nb0763_capture_source = {
7277 static struct hda_input_mux alc883_fujitsu_pi2515_capture_source = {
7285 static struct hda_input_mux alc883_lenovo_sky_capture_source = {
7289 { "Front Mic", 0x1 },
7294 static struct hda_input_mux alc883_asus_eee1601_capture_source = {
7305 static struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
7312 static struct hda_verb alc883_3ST_ch2_init[] = {
7313 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7314 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7315 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7316 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7323 static struct hda_verb alc883_3ST_ch4_init[] = {
7324 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7325 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7326 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7327 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7328 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7335 static struct hda_verb alc883_3ST_ch6_init[] = {
7336 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7337 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7338 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
7339 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7340 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7341 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7345 static struct hda_channel_mode alc883_3ST_6ch_modes[3] = {
7346 { 2, alc883_3ST_ch2_init },
7347 { 4, alc883_3ST_ch4_init },
7348 { 6, alc883_3ST_ch6_init },
7354 static struct hda_verb alc883_3ST_ch2_intel_init[] = {
7355 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7356 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7357 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7358 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7365 static struct hda_verb alc883_3ST_ch4_intel_init[] = {
7366 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7367 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7368 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7369 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7370 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7377 static struct hda_verb alc883_3ST_ch6_intel_init[] = {
7378 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7379 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7380 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x02 },
7381 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7382 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7383 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7387 static struct hda_channel_mode alc883_3ST_6ch_intel_modes[3] = {
7388 { 2, alc883_3ST_ch2_intel_init },
7389 { 4, alc883_3ST_ch4_intel_init },
7390 { 6, alc883_3ST_ch6_intel_init },
7396 static struct hda_verb alc883_sixstack_ch6_init[] = {
7397 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
7398 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7399 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7400 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7407 static struct hda_verb alc883_sixstack_ch8_init[] = {
7408 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7409 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7410 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7411 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7415 static struct hda_channel_mode alc883_sixstack_modes[2] = {
7416 { 6, alc883_sixstack_ch6_init },
7417 { 8, alc883_sixstack_ch8_init },
7420 static struct hda_verb alc883_medion_eapd_verbs[] = {
7421 /* eanable EAPD on medion laptop */
7422 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
7423 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
7427 /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
7428 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
7431 static struct snd_kcontrol_new alc883_base_mixer[] = {
7432 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7433 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7434 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7435 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7436 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7437 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7438 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7439 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7440 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
7441 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
7442 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7443 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7444 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7445 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7446 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7447 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7448 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7449 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7450 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7451 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
7452 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7456 static struct snd_kcontrol_new alc883_mitac_mixer[] = {
7457 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7458 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7459 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7460 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7461 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7462 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7463 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7464 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7465 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7466 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7467 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7468 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
7469 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7473 static struct snd_kcontrol_new alc883_clevo_m720_mixer[] = {
7474 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7475 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
7476 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7477 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
7478 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7479 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7480 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7481 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7482 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
7483 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7487 static struct snd_kcontrol_new alc883_2ch_fujitsu_pi2515_mixer[] = {
7488 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7489 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
7490 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7491 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
7492 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7493 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7494 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7495 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7496 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
7497 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7501 static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
7502 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7503 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7504 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7505 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7506 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7507 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7508 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7509 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7510 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7511 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7512 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7513 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
7514 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7518 static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
7519 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7520 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7521 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7522 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7523 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7524 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7525 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7526 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7527 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7528 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7529 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7530 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7531 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7532 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7533 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7534 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7535 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7536 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
7537 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7541 static struct snd_kcontrol_new alc883_3ST_6ch_intel_mixer[] = {
7542 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7543 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7544 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7545 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7546 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
7548 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7549 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7550 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7551 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7552 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7553 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7554 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7555 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7556 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7557 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
7558 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7559 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7560 HDA_CODEC_VOLUME("Front Mic Boost", 0x18, 0, HDA_INPUT),
7561 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7565 static struct snd_kcontrol_new alc883_fivestack_mixer[] = {
7566 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7567 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7568 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7569 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7570 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7571 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7572 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7573 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7574 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7575 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7576 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7577 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7578 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7579 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7580 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7581 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7582 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7583 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
7584 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7588 static struct snd_kcontrol_new alc883_tagra_mixer[] = {
7589 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7590 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7591 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7592 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7593 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7594 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7595 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7596 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7597 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7598 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7599 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7600 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7601 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7602 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7603 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7604 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7608 static struct snd_kcontrol_new alc883_tagra_2ch_mixer[] = {
7609 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7610 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7611 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7612 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7613 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7614 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7615 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7616 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7617 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7618 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
7619 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7623 static struct snd_kcontrol_new alc883_lenovo_101e_2ch_mixer[] = {
7624 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7625 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7626 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7627 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
7628 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7629 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7630 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7631 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7635 static struct snd_kcontrol_new alc883_lenovo_nb0763_mixer[] = {
7636 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7637 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
7638 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7639 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7640 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7641 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7642 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7643 HDA_CODEC_VOLUME("iMic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7644 HDA_CODEC_MUTE("iMic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7648 static struct snd_kcontrol_new alc883_medion_md2_mixer[] = {
7649 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7650 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7651 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7652 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7653 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7654 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7655 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7656 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7657 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7661 static struct snd_kcontrol_new alc883_acer_aspire_mixer[] = {
7662 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7663 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7664 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7665 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7666 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7667 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7668 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7669 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7673 static struct snd_kcontrol_new alc888_lenovo_sky_mixer[] = {
7674 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7675 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7676 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
7677 HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
7678 HDA_CODEC_VOLUME_MONO("Center Playback Volume",
7679 0x0d, 1, 0x0, HDA_OUTPUT),
7680 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
7681 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
7682 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
7683 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
7684 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
7685 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7686 HDA_CODEC_MUTE("iSpeaker Playback Switch", 0x1a, 0x0, HDA_OUTPUT),
7687 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7688 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7689 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7690 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7691 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7692 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7693 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7694 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7695 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
7696 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7700 static struct hda_bind_ctls alc883_bind_cap_vol = {
7701 .ops = &snd_hda_bind_vol,
7703 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
7704 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
7709 static struct hda_bind_ctls alc883_bind_cap_switch = {
7710 .ops = &snd_hda_bind_sw,
7712 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
7713 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
7718 static struct snd_kcontrol_new alc883_asus_eee1601_mixer[] = {
7719 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7720 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7721 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7722 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7723 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7724 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7725 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7726 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7730 static struct snd_kcontrol_new alc883_asus_eee1601_cap_mixer[] = {
7731 HDA_BIND_VOL("Capture Volume", &alc883_bind_cap_vol),
7732 HDA_BIND_SW("Capture Switch", &alc883_bind_cap_switch),
7734 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7735 /* .name = "Capture Source", */
7736 .name = "Input Source",
7738 .info = alc_mux_enum_info,
7739 .get = alc_mux_enum_get,
7740 .put = alc_mux_enum_put,
7745 static struct snd_kcontrol_new alc883_chmode_mixer[] = {
7747 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7748 .name = "Channel Mode",
7749 .info = alc_ch_mode_info,
7750 .get = alc_ch_mode_get,
7751 .put = alc_ch_mode_put,
7756 static struct hda_verb alc883_init_verbs[] = {
7757 /* ADC1: mute amp left and right */
7758 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7759 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7760 /* ADC2: mute amp left and right */
7761 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7762 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7763 /* Front mixer: unmute input/output amp left and right (volume = 0) */
7764 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7765 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7766 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7768 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7769 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7770 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7772 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7773 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7774 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7776 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7777 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7778 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7780 /* mute analog input loopbacks */
7781 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7782 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7783 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7784 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7785 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7787 /* Front Pin: output 0 (0x0c) */
7788 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7789 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7790 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7791 /* Rear Pin: output 1 (0x0d) */
7792 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7793 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7794 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
7795 /* CLFE Pin: output 2 (0x0e) */
7796 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7797 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7798 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
7799 /* Side Pin: output 3 (0x0f) */
7800 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7801 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7802 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
7803 /* Mic (rear) pin: input vref at 80% */
7804 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7805 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7806 /* Front Mic pin: input vref at 80% */
7807 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7808 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7809 /* Line In pin: input */
7810 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7811 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7812 /* Line-2 In: Headphone output (output 0 - 0x0c) */
7813 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7814 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7815 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
7816 /* CD pin widget for input */
7817 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7819 /* FIXME: use matrix-type input source selection */
7820 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7822 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7823 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7824 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7825 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7827 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7828 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7829 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7830 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7834 /* toggle speaker-output according to the hp-jack state */
7835 static void alc883_mitac_hp_automute(struct hda_codec *codec)
7837 unsigned int present;
7839 present = snd_hda_codec_read(codec, 0x15, 0,
7840 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7841 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7842 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7843 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
7844 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7847 /* auto-toggle front mic */
7849 static void alc883_mitac_mic_automute(struct hda_codec *codec)
7851 unsigned int present;
7854 present = snd_hda_codec_read(codec, 0x18, 0,
7855 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7856 bits = present ? HDA_AMP_MUTE : 0;
7857 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
7861 static void alc883_mitac_automute(struct hda_codec *codec)
7863 alc883_mitac_hp_automute(codec);
7864 /* alc883_mitac_mic_automute(codec); */
7867 static void alc883_mitac_unsol_event(struct hda_codec *codec,
7870 switch (res >> 26) {
7871 case ALC880_HP_EVENT:
7872 alc883_mitac_hp_automute(codec);
7874 case ALC880_MIC_EVENT:
7875 /* alc883_mitac_mic_automute(codec); */
7880 static struct hda_verb alc883_mitac_verbs[] = {
7882 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7883 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7885 {0x17, AC_VERB_SET_CONNECT_SEL, 0x02},
7886 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7888 /* enable unsolicited event */
7889 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7890 /* {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN}, */
7895 static struct hda_verb alc883_clevo_m720_verbs[] = {
7897 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7898 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7900 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
7901 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7903 /* enable unsolicited event */
7904 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7905 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
7910 static struct hda_verb alc883_2ch_fujitsu_pi2515_verbs[] = {
7912 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7913 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7915 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
7916 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7918 /* enable unsolicited event */
7919 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7924 static struct hda_verb alc883_tagra_verbs[] = {
7925 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7926 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7928 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7929 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7931 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
7932 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
7933 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
7935 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7936 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
7937 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
7938 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
7943 static struct hda_verb alc883_lenovo_101e_verbs[] = {
7944 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7945 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT|AC_USRSP_EN},
7946 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT|AC_USRSP_EN},
7950 static struct hda_verb alc883_lenovo_nb0763_verbs[] = {
7951 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7952 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7953 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7954 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7958 static struct hda_verb alc888_lenovo_ms7195_verbs[] = {
7959 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7960 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7961 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7962 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT | AC_USRSP_EN},
7963 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7967 static struct hda_verb alc883_haier_w66_verbs[] = {
7968 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7969 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7971 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7973 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
7974 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7975 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7976 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7980 static struct hda_verb alc888_lenovo_sky_verbs[] = {
7981 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7982 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7983 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7984 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7985 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7986 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7987 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
7988 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7992 static struct hda_verb alc888_3st_hp_verbs[] = {
7993 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
7994 {0x16, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Rear : output 1 (0x0d) */
7995 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* CLFE : output 2 (0x0e) */
7999 static struct hda_verb alc888_6st_dell_verbs[] = {
8000 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8004 static struct hda_verb alc888_3st_hp_2ch_init[] = {
8005 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
8006 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
8007 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
8008 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
8012 static struct hda_verb alc888_3st_hp_6ch_init[] = {
8013 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8014 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
8015 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8016 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
8020 static struct hda_channel_mode alc888_3st_hp_modes[2] = {
8021 { 2, alc888_3st_hp_2ch_init },
8022 { 6, alc888_3st_hp_6ch_init },
8025 /* toggle front-jack and RCA according to the hp-jack state */
8026 static void alc888_lenovo_ms7195_front_automute(struct hda_codec *codec)
8028 unsigned int present;
8030 present = snd_hda_codec_read(codec, 0x1b, 0,
8031 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8032 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8033 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8034 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8035 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8038 /* toggle RCA according to the front-jack state */
8039 static void alc888_lenovo_ms7195_rca_automute(struct hda_codec *codec)
8041 unsigned int present;
8043 present = snd_hda_codec_read(codec, 0x14, 0,
8044 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8045 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8046 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8049 static void alc883_lenovo_ms7195_unsol_event(struct hda_codec *codec,
8052 if ((res >> 26) == ALC880_HP_EVENT)
8053 alc888_lenovo_ms7195_front_automute(codec);
8054 if ((res >> 26) == ALC880_FRONT_EVENT)
8055 alc888_lenovo_ms7195_rca_automute(codec);
8058 static struct hda_verb alc883_medion_md2_verbs[] = {
8059 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8060 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8062 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8064 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8068 /* toggle speaker-output according to the hp-jack state */
8069 static void alc883_medion_md2_automute(struct hda_codec *codec)
8071 unsigned int present;
8073 present = snd_hda_codec_read(codec, 0x14, 0,
8074 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8075 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8076 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8079 static void alc883_medion_md2_unsol_event(struct hda_codec *codec,
8082 if ((res >> 26) == ALC880_HP_EVENT)
8083 alc883_medion_md2_automute(codec);
8086 /* toggle speaker-output according to the hp-jack state */
8087 static void alc883_tagra_automute(struct hda_codec *codec)
8089 unsigned int present;
8092 present = snd_hda_codec_read(codec, 0x14, 0,
8093 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8094 bits = present ? HDA_AMP_MUTE : 0;
8095 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
8096 HDA_AMP_MUTE, bits);
8097 snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
8101 static void alc883_tagra_unsol_event(struct hda_codec *codec, unsigned int res)
8103 if ((res >> 26) == ALC880_HP_EVENT)
8104 alc883_tagra_automute(codec);
8107 /* toggle speaker-output according to the hp-jack state */
8108 static void alc883_clevo_m720_hp_automute(struct hda_codec *codec)
8110 unsigned int present;
8113 present = snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_PIN_SENSE, 0)
8114 & AC_PINSENSE_PRESENCE;
8115 bits = present ? HDA_AMP_MUTE : 0;
8116 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8117 HDA_AMP_MUTE, bits);
8120 static void alc883_clevo_m720_mic_automute(struct hda_codec *codec)
8122 unsigned int present;
8124 present = snd_hda_codec_read(codec, 0x18, 0,
8125 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8126 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
8127 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8130 static void alc883_clevo_m720_automute(struct hda_codec *codec)
8132 alc883_clevo_m720_hp_automute(codec);
8133 alc883_clevo_m720_mic_automute(codec);
8136 static void alc883_clevo_m720_unsol_event(struct hda_codec *codec,
8139 switch (res >> 26) {
8140 case ALC880_HP_EVENT:
8141 alc883_clevo_m720_hp_automute(codec);
8143 case ALC880_MIC_EVENT:
8144 alc883_clevo_m720_mic_automute(codec);
8149 /* toggle speaker-output according to the hp-jack state */
8150 static void alc883_2ch_fujitsu_pi2515_automute(struct hda_codec *codec)
8152 unsigned int present;
8155 present = snd_hda_codec_read(codec, 0x14, 0, AC_VERB_GET_PIN_SENSE, 0)
8156 & AC_PINSENSE_PRESENCE;
8157 bits = present ? HDA_AMP_MUTE : 0;
8158 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8159 HDA_AMP_MUTE, bits);
8162 static void alc883_2ch_fujitsu_pi2515_unsol_event(struct hda_codec *codec,
8165 if ((res >> 26) == ALC880_HP_EVENT)
8166 alc883_2ch_fujitsu_pi2515_automute(codec);
8169 static void alc883_haier_w66_automute(struct hda_codec *codec)
8171 unsigned int present;
8174 present = snd_hda_codec_read(codec, 0x1b, 0,
8175 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8176 bits = present ? 0x80 : 0;
8177 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8181 static void alc883_haier_w66_unsol_event(struct hda_codec *codec,
8184 if ((res >> 26) == ALC880_HP_EVENT)
8185 alc883_haier_w66_automute(codec);
8188 static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
8190 unsigned int present;
8193 present = snd_hda_codec_read(codec, 0x14, 0,
8194 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8195 bits = present ? HDA_AMP_MUTE : 0;
8196 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8197 HDA_AMP_MUTE, bits);
8200 static void alc883_lenovo_101e_all_automute(struct hda_codec *codec)
8202 unsigned int present;
8205 present = snd_hda_codec_read(codec, 0x1b, 0,
8206 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8207 bits = present ? HDA_AMP_MUTE : 0;
8208 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8209 HDA_AMP_MUTE, bits);
8210 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8211 HDA_AMP_MUTE, bits);
8214 static void alc883_lenovo_101e_unsol_event(struct hda_codec *codec,
8217 if ((res >> 26) == ALC880_HP_EVENT)
8218 alc883_lenovo_101e_all_automute(codec);
8219 if ((res >> 26) == ALC880_FRONT_EVENT)
8220 alc883_lenovo_101e_ispeaker_automute(codec);
8223 /* toggle speaker-output according to the hp-jack state */
8224 static void alc883_acer_aspire_automute(struct hda_codec *codec)
8226 unsigned int present;
8228 present = snd_hda_codec_read(codec, 0x14, 0,
8229 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8230 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8231 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8232 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
8233 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8236 static void alc883_acer_aspire_unsol_event(struct hda_codec *codec,
8239 if ((res >> 26) == ALC880_HP_EVENT)
8240 alc883_acer_aspire_automute(codec);
8243 static struct hda_verb alc883_acer_eapd_verbs[] = {
8244 /* HP Pin: output 0 (0x0c) */
8245 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8246 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8247 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8248 /* Front Pin: output 0 (0x0c) */
8249 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8250 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8251 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8252 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00},
8253 /* eanable EAPD on medion laptop */
8254 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
8255 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
8256 /* enable unsolicited event */
8257 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8261 static void alc888_6st_dell_front_automute(struct hda_codec *codec)
8263 unsigned int present;
8265 present = snd_hda_codec_read(codec, 0x1b, 0,
8266 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8267 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8268 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8269 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8270 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8271 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
8272 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8273 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
8274 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8277 static void alc888_6st_dell_unsol_event(struct hda_codec *codec,
8280 switch (res >> 26) {
8281 case ALC880_HP_EVENT:
8282 /* printk(KERN_DEBUG "hp_event\n"); */
8283 alc888_6st_dell_front_automute(codec);
8288 static void alc888_lenovo_sky_front_automute(struct hda_codec *codec)
8291 unsigned int present;
8293 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
8294 present = snd_hda_codec_read(codec, 0x1b, 0,
8295 AC_VERB_GET_PIN_SENSE, 0);
8296 present = (present & 0x80000000) != 0;
8298 /* mute internal speaker */
8299 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8300 HDA_AMP_MUTE, HDA_AMP_MUTE);
8301 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8302 HDA_AMP_MUTE, HDA_AMP_MUTE);
8303 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
8304 HDA_AMP_MUTE, HDA_AMP_MUTE);
8305 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
8306 HDA_AMP_MUTE, HDA_AMP_MUTE);
8307 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_OUTPUT, 0,
8308 HDA_AMP_MUTE, HDA_AMP_MUTE);
8310 /* unmute internal speaker if necessary */
8311 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
8312 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8313 HDA_AMP_MUTE, mute);
8314 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8315 HDA_AMP_MUTE, mute);
8316 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
8317 HDA_AMP_MUTE, mute);
8318 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
8319 HDA_AMP_MUTE, mute);
8320 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_OUTPUT, 0,
8321 HDA_AMP_MUTE, mute);
8325 static void alc883_lenovo_sky_unsol_event(struct hda_codec *codec,
8328 if ((res >> 26) == ALC880_HP_EVENT)
8329 alc888_lenovo_sky_front_automute(codec);
8333 * generic initialization of ADC, input mixers and output mixers
8335 static struct hda_verb alc883_auto_init_verbs[] = {
8337 * Unmute ADC0-2 and set the default input to mic-in
8339 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8340 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8341 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8342 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8344 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
8346 * Note: PASD motherboards uses the Line In 2 as the input for
8347 * front panel mic (mic 2)
8349 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
8350 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8351 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8352 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8353 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8354 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8357 * Set up output mixers (0x0c - 0x0f)
8359 /* set vol=0 to output mixers */
8360 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8361 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8362 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8363 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8364 /* set up input amps for analog loopback */
8365 /* Amp Indices: DAC = 0, mixer = 1 */
8366 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8367 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8368 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8369 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8370 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8371 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8372 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8373 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8374 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8375 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8377 /* FIXME: use matrix-type input source selection */
8378 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
8380 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8381 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8382 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
8383 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
8384 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
8386 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8387 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8388 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
8389 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
8390 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
8395 static struct hda_verb alc888_asus_m90v_verbs[] = {
8396 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8397 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8398 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8399 /* enable unsolicited event */
8400 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8401 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
8405 static void alc883_nb_mic_automute(struct hda_codec *codec)
8407 unsigned int present;
8409 present = snd_hda_codec_read(codec, 0x18, 0,
8410 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8411 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
8412 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
8413 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
8414 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
8417 static void alc883_M90V_speaker_automute(struct hda_codec *codec)
8419 unsigned int present;
8422 present = snd_hda_codec_read(codec, 0x1b, 0,
8423 AC_VERB_GET_PIN_SENSE, 0)
8424 & AC_PINSENSE_PRESENCE;
8425 bits = present ? 0 : PIN_OUT;
8426 snd_hda_codec_write(codec, 0x14, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
8428 snd_hda_codec_write(codec, 0x15, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
8430 snd_hda_codec_write(codec, 0x16, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
8434 static void alc883_mode2_unsol_event(struct hda_codec *codec,
8437 switch (res >> 26) {
8438 case ALC880_HP_EVENT:
8439 alc883_M90V_speaker_automute(codec);
8441 case ALC880_MIC_EVENT:
8442 alc883_nb_mic_automute(codec);
8447 static void alc883_mode2_inithook(struct hda_codec *codec)
8449 alc883_M90V_speaker_automute(codec);
8450 alc883_nb_mic_automute(codec);
8453 static struct hda_verb alc888_asus_eee1601_verbs[] = {
8454 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8455 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8456 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8457 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8458 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8459 {0x20, AC_VERB_SET_COEF_INDEX, 0x0b},
8460 {0x20, AC_VERB_SET_PROC_COEF, 0x0838},
8461 /* enable unsolicited event */
8462 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8466 static void alc883_eee1601_speaker_automute(struct hda_codec *codec)
8468 unsigned int present;
8471 present = snd_hda_codec_read(codec, 0x14, 0,
8472 AC_VERB_GET_PIN_SENSE, 0)
8473 & AC_PINSENSE_PRESENCE;
8474 bits = present ? 0 : PIN_OUT;
8475 snd_hda_codec_write(codec, 0x1b, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
8479 static void alc883_eee1601_unsol_event(struct hda_codec *codec,
8482 switch (res >> 26) {
8483 case ALC880_HP_EVENT:
8484 alc883_eee1601_speaker_automute(codec);
8489 static void alc883_eee1601_inithook(struct hda_codec *codec)
8491 alc883_eee1601_speaker_automute(codec);
8494 #ifdef CONFIG_SND_HDA_POWER_SAVE
8495 #define alc883_loopbacks alc880_loopbacks
8498 /* pcm configuration: identiacal with ALC880 */
8499 #define alc883_pcm_analog_playback alc880_pcm_analog_playback
8500 #define alc883_pcm_analog_capture alc880_pcm_analog_capture
8501 #define alc883_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
8502 #define alc883_pcm_digital_playback alc880_pcm_digital_playback
8503 #define alc883_pcm_digital_capture alc880_pcm_digital_capture
8506 * configuration and preset
8508 static const char *alc883_models[ALC883_MODEL_LAST] = {
8509 [ALC883_3ST_2ch_DIG] = "3stack-dig",
8510 [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig",
8511 [ALC883_3ST_6ch] = "3stack-6ch",
8512 [ALC883_6ST_DIG] = "6stack-dig",
8513 [ALC883_TARGA_DIG] = "targa-dig",
8514 [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig",
8515 [ALC883_ACER] = "acer",
8516 [ALC883_ACER_ASPIRE] = "acer-aspire",
8517 [ALC888_ACER_ASPIRE_4930G] = "acer-aspire-4930g",
8518 [ALC883_MEDION] = "medion",
8519 [ALC883_MEDION_MD2] = "medion-md2",
8520 [ALC883_LAPTOP_EAPD] = "laptop-eapd",
8521 [ALC883_LENOVO_101E_2ch] = "lenovo-101e",
8522 [ALC883_LENOVO_NB0763] = "lenovo-nb0763",
8523 [ALC888_LENOVO_MS7195_DIG] = "lenovo-ms7195-dig",
8524 [ALC888_LENOVO_SKY] = "lenovo-sky",
8525 [ALC883_HAIER_W66] = "haier-w66",
8526 [ALC888_3ST_HP] = "3stack-hp",
8527 [ALC888_6ST_DELL] = "6stack-dell",
8528 [ALC883_MITAC] = "mitac",
8529 [ALC883_CLEVO_M720] = "clevo-m720",
8530 [ALC883_FUJITSU_PI2515] = "fujitsu-pi2515",
8531 [ALC888_FUJITSU_XA3530] = "fujitsu-xa3530",
8532 [ALC883_3ST_6ch_INTEL] = "3stack-6ch-intel",
8533 [ALC1200_ASUS_P5Q] = "asus-p5q",
8534 [ALC883_AUTO] = "auto",
8537 static struct snd_pci_quirk alc883_cfg_tbl[] = {
8538 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC883_3ST_6ch_DIG),
8539 SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_ACER_ASPIRE),
8540 SND_PCI_QUIRK(0x1025, 0x0090, "Acer Aspire", ALC883_ACER_ASPIRE),
8541 SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_ACER_ASPIRE),
8542 SND_PCI_QUIRK(0x1025, 0x0112, "Acer Aspire 9303", ALC883_ACER_ASPIRE),
8543 SND_PCI_QUIRK(0x1025, 0x0121, "Acer Aspire 5920G", ALC883_ACER_ASPIRE),
8544 SND_PCI_QUIRK(0x1025, 0x013e, "Acer Aspire 4930G",
8545 ALC888_ACER_ASPIRE_4930G),
8546 SND_PCI_QUIRK(0x1025, 0x013f, "Acer Aspire 5930G",
8547 ALC888_ACER_ASPIRE_4930G),
8548 SND_PCI_QUIRK(0x1025, 0x0158, "Acer AX1700-U3700A", ALC883_AUTO),
8549 SND_PCI_QUIRK(0x1025, 0x015e, "Acer Aspire 6930G",
8550 ALC888_ACER_ASPIRE_4930G),
8552 SND_PCI_QUIRK_VENDOR(0x1025, "Acer laptop", ALC883_ACER),
8553 SND_PCI_QUIRK(0x1028, 0x020d, "Dell Inspiron 530", ALC888_6ST_DELL),
8554 SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG),
8555 SND_PCI_QUIRK(0x103c, 0x2a4f, "HP Samba", ALC888_3ST_HP),
8556 SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_3ST_HP),
8557 SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC883_6ST_DIG),
8558 SND_PCI_QUIRK(0x103c, 0x2a66, "HP Acacia", ALC888_3ST_HP),
8559 SND_PCI_QUIRK(0x1043, 0x1873, "Asus M90V", ALC888_ASUS_M90V),
8560 SND_PCI_QUIRK(0x1043, 0x8249, "Asus M2A-VM HDMI", ALC883_3ST_6ch_DIG),
8561 SND_PCI_QUIRK(0x1043, 0x8284, "Asus Z37E", ALC883_6ST_DIG),
8562 SND_PCI_QUIRK(0x1043, 0x82fe, "Asus P5Q-EM HDMI", ALC1200_ASUS_P5Q),
8563 SND_PCI_QUIRK(0x1043, 0x835f, "Asus Eee 1601", ALC888_ASUS_EEE1601),
8564 SND_PCI_QUIRK(0x105b, 0x0ce8, "Foxconn P35AX-S", ALC883_6ST_DIG),
8565 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC883_6ST_DIG),
8566 SND_PCI_QUIRK(0x1071, 0x8227, "Mitac 82801H", ALC883_MITAC),
8567 SND_PCI_QUIRK(0x1071, 0x8253, "Mitac 8252d", ALC883_MITAC),
8568 SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD),
8569 SND_PCI_QUIRK(0x10f1, 0x2350, "TYAN-S2350", ALC888_6ST_DELL),
8570 SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch),
8571 SND_PCI_QUIRK(0x1458, 0xa002, "MSI", ALC883_6ST_DIG),
8572 SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG),
8573 SND_PCI_QUIRK(0x1462, 0x040d, "MSI", ALC883_TARGA_2ch_DIG),
8574 SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG),
8575 SND_PCI_QUIRK(0x1462, 0x2fb3, "MSI", ALC883_TARGA_2ch_DIG),
8576 SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG),
8577 SND_PCI_QUIRK(0x1462, 0x3783, "NEC S970", ALC883_TARGA_DIG),
8578 SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG),
8579 SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG),
8580 SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG),
8581 SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG),
8582 SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG),
8583 SND_PCI_QUIRK(0x1462, 0x3fdf, "MSI", ALC883_TARGA_DIG),
8584 SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG),
8585 SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG),
8586 SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG),
8587 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG),
8588 SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG),
8589 SND_PCI_QUIRK(0x1462, 0x7250, "MSI", ALC883_6ST_DIG),
8590 SND_PCI_QUIRK(0x1462, 0x7260, "MSI 7260", ALC883_TARGA_DIG),
8591 SND_PCI_QUIRK(0x1462, 0x7267, "MSI", ALC883_3ST_6ch_DIG),
8592 SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG),
8593 SND_PCI_QUIRK(0x1462, 0x7327, "MSI", ALC883_6ST_DIG),
8594 SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG),
8595 SND_PCI_QUIRK(0x147b, 0x1083, "Abit IP35-PRO", ALC883_6ST_DIG),
8596 SND_PCI_QUIRK(0x1558, 0x0721, "Clevo laptop M720R", ALC883_CLEVO_M720),
8597 SND_PCI_QUIRK(0x1558, 0x0722, "Clevo laptop M720SR", ALC883_CLEVO_M720),
8598 SND_PCI_QUIRK_VENDOR(0x1558, "Clevo laptop", ALC883_LAPTOP_EAPD),
8599 SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch),
8600 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
8601 SND_PCI_QUIRK(0x1734, 0x1107, "FSC AMILO Xi2550",
8602 ALC883_FUJITSU_PI2515),
8603 SND_PCI_QUIRK(0x1734, 0x1108, "Fujitsu AMILO Pi2515", ALC883_FUJITSU_PI2515),
8604 SND_PCI_QUIRK(0x1734, 0x113d, "Fujitsu AMILO Xa3530",
8605 ALC888_FUJITSU_XA3530),
8606 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch),
8607 SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763),
8608 SND_PCI_QUIRK(0x17aa, 0x3bfc, "Lenovo NB0763", ALC883_LENOVO_NB0763),
8609 SND_PCI_QUIRK(0x17aa, 0x3bfd, "Lenovo NB0763", ALC883_LENOVO_NB0763),
8610 SND_PCI_QUIRK(0x17aa, 0x101d, "Lenovo Sky", ALC888_LENOVO_SKY),
8611 SND_PCI_QUIRK(0x17c0, 0x4071, "MEDION MD2", ALC883_MEDION_MD2),
8612 SND_PCI_QUIRK(0x17c0, 0x4085, "MEDION MD96630", ALC888_LENOVO_MS7195_DIG),
8613 SND_PCI_QUIRK(0x17f2, 0x5000, "Albatron KI690-AM2", ALC883_6ST_DIG),
8614 SND_PCI_QUIRK(0x1991, 0x5625, "Haier W66", ALC883_HAIER_W66),
8615 SND_PCI_QUIRK(0x8086, 0x0001, "DG33BUC", ALC883_3ST_6ch_INTEL),
8616 SND_PCI_QUIRK(0x8086, 0x0002, "DG33FBC", ALC883_3ST_6ch_INTEL),
8617 SND_PCI_QUIRK(0x8086, 0x2503, "82801H", ALC883_MITAC),
8618 SND_PCI_QUIRK(0x8086, 0x0022, "DX58SO", ALC883_3ST_6ch_INTEL),
8619 SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC883_3ST_6ch),
8623 static hda_nid_t alc1200_slave_dig_outs[] = {
8624 ALC883_DIGOUT_NID, 0,
8627 static struct alc_config_preset alc883_presets[] = {
8628 [ALC883_3ST_2ch_DIG] = {
8629 .mixers = { alc883_3ST_2ch_mixer },
8630 .init_verbs = { alc883_init_verbs },
8631 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8632 .dac_nids = alc883_dac_nids,
8633 .dig_out_nid = ALC883_DIGOUT_NID,
8634 .dig_in_nid = ALC883_DIGIN_NID,
8635 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8636 .channel_mode = alc883_3ST_2ch_modes,
8637 .input_mux = &alc883_capture_source,
8639 [ALC883_3ST_6ch_DIG] = {
8640 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
8641 .init_verbs = { alc883_init_verbs },
8642 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8643 .dac_nids = alc883_dac_nids,
8644 .dig_out_nid = ALC883_DIGOUT_NID,
8645 .dig_in_nid = ALC883_DIGIN_NID,
8646 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8647 .channel_mode = alc883_3ST_6ch_modes,
8649 .input_mux = &alc883_capture_source,
8651 [ALC883_3ST_6ch] = {
8652 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
8653 .init_verbs = { alc883_init_verbs },
8654 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8655 .dac_nids = alc883_dac_nids,
8656 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8657 .channel_mode = alc883_3ST_6ch_modes,
8659 .input_mux = &alc883_capture_source,
8661 [ALC883_3ST_6ch_INTEL] = {
8662 .mixers = { alc883_3ST_6ch_intel_mixer, alc883_chmode_mixer },
8663 .init_verbs = { alc883_init_verbs },
8664 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8665 .dac_nids = alc883_dac_nids,
8666 .dig_out_nid = ALC883_DIGOUT_NID,
8667 .dig_in_nid = ALC883_DIGIN_NID,
8668 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_intel_modes),
8669 .channel_mode = alc883_3ST_6ch_intel_modes,
8671 .input_mux = &alc883_3stack_6ch_intel,
8673 [ALC883_6ST_DIG] = {
8674 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
8675 .init_verbs = { alc883_init_verbs },
8676 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8677 .dac_nids = alc883_dac_nids,
8678 .dig_out_nid = ALC883_DIGOUT_NID,
8679 .dig_in_nid = ALC883_DIGIN_NID,
8680 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
8681 .channel_mode = alc883_sixstack_modes,
8682 .input_mux = &alc883_capture_source,
8684 [ALC883_TARGA_DIG] = {
8685 .mixers = { alc883_tagra_mixer, alc883_chmode_mixer },
8686 .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
8687 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8688 .dac_nids = alc883_dac_nids,
8689 .dig_out_nid = ALC883_DIGOUT_NID,
8690 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8691 .channel_mode = alc883_3ST_6ch_modes,
8693 .input_mux = &alc883_capture_source,
8694 .unsol_event = alc883_tagra_unsol_event,
8695 .init_hook = alc883_tagra_automute,
8697 [ALC883_TARGA_2ch_DIG] = {
8698 .mixers = { alc883_tagra_2ch_mixer},
8699 .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
8700 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8701 .dac_nids = alc883_dac_nids,
8702 .adc_nids = alc883_adc_nids_alt,
8703 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
8704 .dig_out_nid = ALC883_DIGOUT_NID,
8705 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8706 .channel_mode = alc883_3ST_2ch_modes,
8707 .input_mux = &alc883_capture_source,
8708 .unsol_event = alc883_tagra_unsol_event,
8709 .init_hook = alc883_tagra_automute,
8712 .mixers = { alc883_base_mixer },
8713 /* On TravelMate laptops, GPIO 0 enables the internal speaker
8714 * and the headphone jack. Turn this on and rely on the
8715 * standard mute methods whenever the user wants to turn
8716 * these outputs off.
8718 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs },
8719 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8720 .dac_nids = alc883_dac_nids,
8721 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8722 .channel_mode = alc883_3ST_2ch_modes,
8723 .input_mux = &alc883_capture_source,
8725 [ALC883_ACER_ASPIRE] = {
8726 .mixers = { alc883_acer_aspire_mixer },
8727 .init_verbs = { alc883_init_verbs, alc883_acer_eapd_verbs },
8728 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8729 .dac_nids = alc883_dac_nids,
8730 .dig_out_nid = ALC883_DIGOUT_NID,
8731 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8732 .channel_mode = alc883_3ST_2ch_modes,
8733 .input_mux = &alc883_capture_source,
8734 .unsol_event = alc883_acer_aspire_unsol_event,
8735 .init_hook = alc883_acer_aspire_automute,
8737 [ALC888_ACER_ASPIRE_4930G] = {
8738 .mixers = { alc888_base_mixer,
8739 alc883_chmode_mixer },
8740 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
8741 alc888_acer_aspire_4930g_verbs },
8742 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8743 .dac_nids = alc883_dac_nids,
8744 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
8745 .adc_nids = alc883_adc_nids_rev,
8746 .capsrc_nids = alc883_capsrc_nids_rev,
8747 .dig_out_nid = ALC883_DIGOUT_NID,
8748 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8749 .channel_mode = alc883_3ST_6ch_modes,
8752 ARRAY_SIZE(alc888_2_capture_sources),
8753 .input_mux = alc888_2_capture_sources,
8754 .unsol_event = alc888_acer_aspire_4930g_unsol_event,
8755 .init_hook = alc888_acer_aspire_4930g_automute,
8758 .mixers = { alc883_fivestack_mixer,
8759 alc883_chmode_mixer },
8760 .init_verbs = { alc883_init_verbs,
8761 alc883_medion_eapd_verbs },
8762 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8763 .dac_nids = alc883_dac_nids,
8764 .adc_nids = alc883_adc_nids_alt,
8765 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
8766 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
8767 .channel_mode = alc883_sixstack_modes,
8768 .input_mux = &alc883_capture_source,
8770 [ALC883_MEDION_MD2] = {
8771 .mixers = { alc883_medion_md2_mixer},
8772 .init_verbs = { alc883_init_verbs, alc883_medion_md2_verbs},
8773 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8774 .dac_nids = alc883_dac_nids,
8775 .dig_out_nid = ALC883_DIGOUT_NID,
8776 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8777 .channel_mode = alc883_3ST_2ch_modes,
8778 .input_mux = &alc883_capture_source,
8779 .unsol_event = alc883_medion_md2_unsol_event,
8780 .init_hook = alc883_medion_md2_automute,
8782 [ALC883_LAPTOP_EAPD] = {
8783 .mixers = { alc883_base_mixer },
8784 .init_verbs = { alc883_init_verbs, alc882_eapd_verbs },
8785 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8786 .dac_nids = alc883_dac_nids,
8787 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8788 .channel_mode = alc883_3ST_2ch_modes,
8789 .input_mux = &alc883_capture_source,
8791 [ALC883_CLEVO_M720] = {
8792 .mixers = { alc883_clevo_m720_mixer },
8793 .init_verbs = { alc883_init_verbs, alc883_clevo_m720_verbs },
8794 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8795 .dac_nids = alc883_dac_nids,
8796 .dig_out_nid = ALC883_DIGOUT_NID,
8797 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8798 .channel_mode = alc883_3ST_2ch_modes,
8799 .input_mux = &alc883_capture_source,
8800 .unsol_event = alc883_clevo_m720_unsol_event,
8801 .init_hook = alc883_clevo_m720_automute,
8803 [ALC883_LENOVO_101E_2ch] = {
8804 .mixers = { alc883_lenovo_101e_2ch_mixer},
8805 .init_verbs = { alc883_init_verbs, alc883_lenovo_101e_verbs},
8806 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8807 .dac_nids = alc883_dac_nids,
8808 .adc_nids = alc883_adc_nids_alt,
8809 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
8810 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8811 .channel_mode = alc883_3ST_2ch_modes,
8812 .input_mux = &alc883_lenovo_101e_capture_source,
8813 .unsol_event = alc883_lenovo_101e_unsol_event,
8814 .init_hook = alc883_lenovo_101e_all_automute,
8816 [ALC883_LENOVO_NB0763] = {
8817 .mixers = { alc883_lenovo_nb0763_mixer },
8818 .init_verbs = { alc883_init_verbs, alc883_lenovo_nb0763_verbs},
8819 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8820 .dac_nids = alc883_dac_nids,
8821 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8822 .channel_mode = alc883_3ST_2ch_modes,
8824 .input_mux = &alc883_lenovo_nb0763_capture_source,
8825 .unsol_event = alc883_medion_md2_unsol_event,
8826 .init_hook = alc883_medion_md2_automute,
8828 [ALC888_LENOVO_MS7195_DIG] = {
8829 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
8830 .init_verbs = { alc883_init_verbs, alc888_lenovo_ms7195_verbs},
8831 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8832 .dac_nids = alc883_dac_nids,
8833 .dig_out_nid = ALC883_DIGOUT_NID,
8834 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8835 .channel_mode = alc883_3ST_6ch_modes,
8837 .input_mux = &alc883_capture_source,
8838 .unsol_event = alc883_lenovo_ms7195_unsol_event,
8839 .init_hook = alc888_lenovo_ms7195_front_automute,
8841 [ALC883_HAIER_W66] = {
8842 .mixers = { alc883_tagra_2ch_mixer},
8843 .init_verbs = { alc883_init_verbs, alc883_haier_w66_verbs},
8844 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8845 .dac_nids = alc883_dac_nids,
8846 .dig_out_nid = ALC883_DIGOUT_NID,
8847 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8848 .channel_mode = alc883_3ST_2ch_modes,
8849 .input_mux = &alc883_capture_source,
8850 .unsol_event = alc883_haier_w66_unsol_event,
8851 .init_hook = alc883_haier_w66_automute,
8854 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
8855 .init_verbs = { alc883_init_verbs, alc888_3st_hp_verbs },
8856 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8857 .dac_nids = alc883_dac_nids,
8858 .num_channel_mode = ARRAY_SIZE(alc888_3st_hp_modes),
8859 .channel_mode = alc888_3st_hp_modes,
8861 .input_mux = &alc883_capture_source,
8863 [ALC888_6ST_DELL] = {
8864 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
8865 .init_verbs = { alc883_init_verbs, alc888_6st_dell_verbs },
8866 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8867 .dac_nids = alc883_dac_nids,
8868 .dig_out_nid = ALC883_DIGOUT_NID,
8869 .dig_in_nid = ALC883_DIGIN_NID,
8870 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
8871 .channel_mode = alc883_sixstack_modes,
8872 .input_mux = &alc883_capture_source,
8873 .unsol_event = alc888_6st_dell_unsol_event,
8874 .init_hook = alc888_6st_dell_front_automute,
8877 .mixers = { alc883_mitac_mixer },
8878 .init_verbs = { alc883_init_verbs, alc883_mitac_verbs },
8879 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8880 .dac_nids = alc883_dac_nids,
8881 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8882 .channel_mode = alc883_3ST_2ch_modes,
8883 .input_mux = &alc883_capture_source,
8884 .unsol_event = alc883_mitac_unsol_event,
8885 .init_hook = alc883_mitac_automute,
8887 [ALC883_FUJITSU_PI2515] = {
8888 .mixers = { alc883_2ch_fujitsu_pi2515_mixer },
8889 .init_verbs = { alc883_init_verbs,
8890 alc883_2ch_fujitsu_pi2515_verbs},
8891 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8892 .dac_nids = alc883_dac_nids,
8893 .dig_out_nid = ALC883_DIGOUT_NID,
8894 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8895 .channel_mode = alc883_3ST_2ch_modes,
8896 .input_mux = &alc883_fujitsu_pi2515_capture_source,
8897 .unsol_event = alc883_2ch_fujitsu_pi2515_unsol_event,
8898 .init_hook = alc883_2ch_fujitsu_pi2515_automute,
8900 [ALC888_FUJITSU_XA3530] = {
8901 .mixers = { alc888_base_mixer, alc883_chmode_mixer },
8902 .init_verbs = { alc883_init_verbs,
8903 alc888_fujitsu_xa3530_verbs },
8904 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8905 .dac_nids = alc883_dac_nids,
8906 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
8907 .adc_nids = alc883_adc_nids_rev,
8908 .capsrc_nids = alc883_capsrc_nids_rev,
8909 .dig_out_nid = ALC883_DIGOUT_NID,
8910 .num_channel_mode = ARRAY_SIZE(alc888_4ST_8ch_intel_modes),
8911 .channel_mode = alc888_4ST_8ch_intel_modes,
8913 ARRAY_SIZE(alc888_2_capture_sources),
8914 .input_mux = alc888_2_capture_sources,
8915 .unsol_event = alc888_fujitsu_xa3530_unsol_event,
8916 .init_hook = alc888_fujitsu_xa3530_automute,
8918 [ALC888_LENOVO_SKY] = {
8919 .mixers = { alc888_lenovo_sky_mixer, alc883_chmode_mixer },
8920 .init_verbs = { alc883_init_verbs, alc888_lenovo_sky_verbs},
8921 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8922 .dac_nids = alc883_dac_nids,
8923 .dig_out_nid = ALC883_DIGOUT_NID,
8924 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
8925 .channel_mode = alc883_sixstack_modes,
8927 .input_mux = &alc883_lenovo_sky_capture_source,
8928 .unsol_event = alc883_lenovo_sky_unsol_event,
8929 .init_hook = alc888_lenovo_sky_front_automute,
8931 [ALC888_ASUS_M90V] = {
8932 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
8933 .init_verbs = { alc883_init_verbs, alc888_asus_m90v_verbs },
8934 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8935 .dac_nids = alc883_dac_nids,
8936 .dig_out_nid = ALC883_DIGOUT_NID,
8937 .dig_in_nid = ALC883_DIGIN_NID,
8938 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8939 .channel_mode = alc883_3ST_6ch_modes,
8941 .input_mux = &alc883_fujitsu_pi2515_capture_source,
8942 .unsol_event = alc883_mode2_unsol_event,
8943 .init_hook = alc883_mode2_inithook,
8945 [ALC888_ASUS_EEE1601] = {
8946 .mixers = { alc883_asus_eee1601_mixer },
8947 .cap_mixer = alc883_asus_eee1601_cap_mixer,
8948 .init_verbs = { alc883_init_verbs, alc888_asus_eee1601_verbs },
8949 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8950 .dac_nids = alc883_dac_nids,
8951 .dig_out_nid = ALC883_DIGOUT_NID,
8952 .dig_in_nid = ALC883_DIGIN_NID,
8953 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8954 .channel_mode = alc883_3ST_2ch_modes,
8956 .input_mux = &alc883_asus_eee1601_capture_source,
8957 .unsol_event = alc883_eee1601_unsol_event,
8958 .init_hook = alc883_eee1601_inithook,
8960 [ALC1200_ASUS_P5Q] = {
8961 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
8962 .init_verbs = { alc883_init_verbs },
8963 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8964 .dac_nids = alc883_dac_nids,
8965 .dig_out_nid = ALC1200_DIGOUT_NID,
8966 .dig_in_nid = ALC883_DIGIN_NID,
8967 .slave_dig_outs = alc1200_slave_dig_outs,
8968 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
8969 .channel_mode = alc883_sixstack_modes,
8970 .input_mux = &alc883_capture_source,
8976 * BIOS auto configuration
8978 static void alc883_auto_set_output_and_unmute(struct hda_codec *codec,
8979 hda_nid_t nid, int pin_type,
8983 struct alc_spec *spec = codec->spec;
8986 alc_set_pin_output(codec, nid, pin_type);
8987 if (spec->multiout.dac_nids[dac_idx] == 0x25)
8990 idx = spec->multiout.dac_nids[dac_idx] - 2;
8991 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
8995 static void alc883_auto_init_multi_out(struct hda_codec *codec)
8997 struct alc_spec *spec = codec->spec;
9000 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
9001 for (i = 0; i <= HDA_SIDE; i++) {
9002 hda_nid_t nid = spec->autocfg.line_out_pins[i];
9003 int pin_type = get_pin_type(spec->autocfg.line_out_type);
9005 alc883_auto_set_output_and_unmute(codec, nid, pin_type,
9010 static void alc883_auto_init_hp_out(struct hda_codec *codec)
9012 struct alc_spec *spec = codec->spec;
9015 pin = spec->autocfg.hp_pins[0];
9016 if (pin) /* connect to front */
9018 alc883_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
9019 pin = spec->autocfg.speaker_pins[0];
9021 alc883_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
9024 #define alc883_is_input_pin(nid) alc880_is_input_pin(nid)
9025 #define ALC883_PIN_CD_NID ALC880_PIN_CD_NID
9027 static void alc883_auto_init_analog_input(struct hda_codec *codec)
9029 struct alc_spec *spec = codec->spec;
9032 for (i = 0; i < AUTO_PIN_LAST; i++) {
9033 hda_nid_t nid = spec->autocfg.input_pins[i];
9034 if (alc883_is_input_pin(nid)) {
9035 snd_hda_codec_write(codec, nid, 0,
9036 AC_VERB_SET_PIN_WIDGET_CONTROL,
9037 (i <= AUTO_PIN_FRONT_MIC ?
9038 PIN_VREF80 : PIN_IN));
9039 if (nid != ALC883_PIN_CD_NID)
9040 snd_hda_codec_write(codec, nid, 0,
9041 AC_VERB_SET_AMP_GAIN_MUTE,
9047 #define alc883_auto_init_input_src alc882_auto_init_input_src
9049 /* almost identical with ALC880 parser... */
9050 static int alc883_parse_auto_config(struct hda_codec *codec)
9052 struct alc_spec *spec = codec->spec;
9053 int err = alc880_parse_auto_config(codec);
9054 struct auto_pin_cfg *cfg = &spec->autocfg;
9060 return 0; /* no config found */
9062 err = alc_auto_add_mic_boost(codec);
9066 /* hack - override the init verbs */
9067 spec->init_verbs[0] = alc883_auto_init_verbs;
9069 /* setup input_mux for ALC889 */
9070 if (codec->vendor_id == 0x10ec0889) {
9071 /* digital-mic input pin is excluded in alc880_auto_create..()
9072 * because it's under 0x18
9074 if (cfg->input_pins[AUTO_PIN_MIC] == 0x12 ||
9075 cfg->input_pins[AUTO_PIN_FRONT_MIC] == 0x12) {
9076 struct hda_input_mux *imux = &spec->private_imux[0];
9077 for (i = 1; i < 3; i++)
9078 memcpy(&spec->private_imux[i],
9079 &spec->private_imux[0],
9080 sizeof(spec->private_imux[0]));
9081 imux->items[imux->num_items].label = "Int DMic";
9082 imux->items[imux->num_items].index = 0x0b;
9084 spec->num_mux_defs = 3;
9085 spec->input_mux = spec->private_imux;
9089 return 1; /* config found */
9092 /* additional initialization for auto-configuration model */
9093 static void alc883_auto_init(struct hda_codec *codec)
9095 struct alc_spec *spec = codec->spec;
9096 alc883_auto_init_multi_out(codec);
9097 alc883_auto_init_hp_out(codec);
9098 alc883_auto_init_analog_input(codec);
9099 alc883_auto_init_input_src(codec);
9100 if (spec->unsol_event)
9101 alc_inithook(codec);
9104 static int patch_alc883(struct hda_codec *codec)
9106 struct alc_spec *spec;
9107 int err, board_config;
9109 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
9115 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
9117 board_config = snd_hda_check_board_config(codec, ALC883_MODEL_LAST,
9120 if (board_config < 0) {
9121 printk(KERN_INFO "hda_codec: Unknown model for ALC883, "
9122 "trying auto-probe from BIOS...\n");
9123 board_config = ALC883_AUTO;
9126 if (board_config == ALC883_AUTO) {
9127 /* automatic parse from the BIOS config */
9128 err = alc883_parse_auto_config(codec);
9134 "hda_codec: Cannot set up configuration "
9135 "from BIOS. Using base mode...\n");
9136 board_config = ALC883_3ST_2ch_DIG;
9140 err = snd_hda_attach_beep_device(codec, 0x1);
9146 if (board_config != ALC883_AUTO)
9147 setup_preset(spec, &alc883_presets[board_config]);
9149 switch (codec->vendor_id) {
9151 if (codec->revision_id == 0x100101) {
9152 spec->stream_name_analog = "ALC1200 Analog";
9153 spec->stream_name_digital = "ALC1200 Digital";
9155 spec->stream_name_analog = "ALC888 Analog";
9156 spec->stream_name_digital = "ALC888 Digital";
9158 if (!spec->num_adc_nids) {
9159 spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids);
9160 spec->adc_nids = alc883_adc_nids;
9162 if (!spec->capsrc_nids)
9163 spec->capsrc_nids = alc883_capsrc_nids;
9164 spec->capture_style = CAPT_MIX; /* matrix-style capture */
9167 spec->stream_name_analog = "ALC889 Analog";
9168 spec->stream_name_digital = "ALC889 Digital";
9169 if (!spec->num_adc_nids) {
9170 spec->num_adc_nids = ARRAY_SIZE(alc889_adc_nids);
9171 spec->adc_nids = alc889_adc_nids;
9173 if (!spec->capsrc_nids)
9174 spec->capsrc_nids = alc889_capsrc_nids;
9175 spec->capture_style = CAPT_1MUX_MIX; /* 1mux/Nmix-style
9179 spec->stream_name_analog = "ALC883 Analog";
9180 spec->stream_name_digital = "ALC883 Digital";
9181 if (!spec->num_adc_nids) {
9182 spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids);
9183 spec->adc_nids = alc883_adc_nids;
9185 if (!spec->capsrc_nids)
9186 spec->capsrc_nids = alc883_capsrc_nids;
9187 spec->capture_style = CAPT_MIX; /* matrix-style capture */
9191 spec->stream_analog_playback = &alc883_pcm_analog_playback;
9192 spec->stream_analog_capture = &alc883_pcm_analog_capture;
9193 spec->stream_analog_alt_capture = &alc883_pcm_analog_alt_capture;
9195 spec->stream_digital_playback = &alc883_pcm_digital_playback;
9196 spec->stream_digital_capture = &alc883_pcm_digital_capture;
9198 if (!spec->cap_mixer)
9199 set_capture_mixer(spec);
9200 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
9202 spec->vmaster_nid = 0x0c;
9204 codec->patch_ops = alc_patch_ops;
9205 if (board_config == ALC883_AUTO)
9206 spec->init_hook = alc883_auto_init;
9208 #ifdef CONFIG_SND_HDA_POWER_SAVE
9209 if (!spec->loopback.amplist)
9210 spec->loopback.amplist = alc883_loopbacks;
9212 codec->proc_widget_hook = print_realtek_coef;
9221 #define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
9222 #define ALC262_DIGIN_NID ALC880_DIGIN_NID
9224 #define alc262_dac_nids alc260_dac_nids
9225 #define alc262_adc_nids alc882_adc_nids
9226 #define alc262_adc_nids_alt alc882_adc_nids_alt
9227 #define alc262_capsrc_nids alc882_capsrc_nids
9228 #define alc262_capsrc_nids_alt alc882_capsrc_nids_alt
9230 #define alc262_modes alc260_modes
9231 #define alc262_capture_source alc882_capture_source
9233 static hda_nid_t alc262_dmic_adc_nids[1] = {
9238 static hda_nid_t alc262_dmic_capsrc_nids[1] = { 0x22 };
9240 static struct snd_kcontrol_new alc262_base_mixer[] = {
9241 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9242 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9243 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9244 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9245 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9246 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9247 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9248 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9249 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9250 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9251 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
9252 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
9253 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
9254 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9255 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
9256 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
9260 static struct snd_kcontrol_new alc262_hippo1_mixer[] = {
9261 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9262 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9263 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9264 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9265 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9266 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9267 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9268 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9269 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9270 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9271 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
9272 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
9273 /*HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),*/
9274 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
9278 /* update HP, line and mono-out pins according to the master switch */
9279 static void alc262_hp_master_update(struct hda_codec *codec)
9281 struct alc_spec *spec = codec->spec;
9282 int val = spec->master_sw;
9285 snd_hda_codec_write_cache(codec, 0x1b, 0,
9286 AC_VERB_SET_PIN_WIDGET_CONTROL,
9288 snd_hda_codec_write_cache(codec, 0x15, 0,
9289 AC_VERB_SET_PIN_WIDGET_CONTROL,
9291 /* mono (speaker) depending on the HP jack sense */
9292 val = val && !spec->jack_present;
9293 snd_hda_codec_write_cache(codec, 0x16, 0,
9294 AC_VERB_SET_PIN_WIDGET_CONTROL,
9298 static void alc262_hp_bpc_automute(struct hda_codec *codec)
9300 struct alc_spec *spec = codec->spec;
9301 unsigned int presence;
9302 presence = snd_hda_codec_read(codec, 0x1b, 0,
9303 AC_VERB_GET_PIN_SENSE, 0);
9304 spec->jack_present = !!(presence & AC_PINSENSE_PRESENCE);
9305 alc262_hp_master_update(codec);
9308 static void alc262_hp_bpc_unsol_event(struct hda_codec *codec, unsigned int res)
9310 if ((res >> 26) != ALC880_HP_EVENT)
9312 alc262_hp_bpc_automute(codec);
9315 static void alc262_hp_wildwest_automute(struct hda_codec *codec)
9317 struct alc_spec *spec = codec->spec;
9318 unsigned int presence;
9319 presence = snd_hda_codec_read(codec, 0x15, 0,
9320 AC_VERB_GET_PIN_SENSE, 0);
9321 spec->jack_present = !!(presence & AC_PINSENSE_PRESENCE);
9322 alc262_hp_master_update(codec);
9325 static void alc262_hp_wildwest_unsol_event(struct hda_codec *codec,
9328 if ((res >> 26) != ALC880_HP_EVENT)
9330 alc262_hp_wildwest_automute(codec);
9333 static int alc262_hp_master_sw_get(struct snd_kcontrol *kcontrol,
9334 struct snd_ctl_elem_value *ucontrol)
9336 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
9337 struct alc_spec *spec = codec->spec;
9338 *ucontrol->value.integer.value = spec->master_sw;
9342 static int alc262_hp_master_sw_put(struct snd_kcontrol *kcontrol,
9343 struct snd_ctl_elem_value *ucontrol)
9345 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
9346 struct alc_spec *spec = codec->spec;
9347 int val = !!*ucontrol->value.integer.value;
9349 if (val == spec->master_sw)
9351 spec->master_sw = val;
9352 alc262_hp_master_update(codec);
9356 static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
9358 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9359 .name = "Master Playback Switch",
9360 .info = snd_ctl_boolean_mono_info,
9361 .get = alc262_hp_master_sw_get,
9362 .put = alc262_hp_master_sw_put,
9364 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9365 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9366 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
9367 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
9369 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
9371 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9372 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9373 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9374 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9375 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
9376 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
9377 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9378 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9379 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9380 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9381 HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
9382 HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
9386 static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = {
9388 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9389 .name = "Master Playback Switch",
9390 .info = snd_ctl_boolean_mono_info,
9391 .get = alc262_hp_master_sw_get,
9392 .put = alc262_hp_master_sw_put,
9394 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9395 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
9396 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
9397 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9398 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
9400 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
9402 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x02, HDA_INPUT),
9403 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x02, HDA_INPUT),
9404 HDA_CODEC_VOLUME("Front Mic Boost", 0x1a, 0, HDA_INPUT),
9405 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
9406 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
9407 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9408 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9412 static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = {
9413 HDA_CODEC_VOLUME("Rear Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9414 HDA_CODEC_MUTE("Rear Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9415 HDA_CODEC_VOLUME("Rear Mic Boost", 0x18, 0, HDA_INPUT),
9419 /* mute/unmute internal speaker according to the hp jack and mute state */
9420 static void alc262_hp_t5735_automute(struct hda_codec *codec, int force)
9422 struct alc_spec *spec = codec->spec;
9424 if (force || !spec->sense_updated) {
9425 unsigned int present;
9426 present = snd_hda_codec_read(codec, 0x15, 0,
9427 AC_VERB_GET_PIN_SENSE, 0);
9428 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
9429 spec->sense_updated = 1;
9431 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0, HDA_AMP_MUTE,
9432 spec->jack_present ? HDA_AMP_MUTE : 0);
9435 static void alc262_hp_t5735_unsol_event(struct hda_codec *codec,
9438 if ((res >> 26) != ALC880_HP_EVENT)
9440 alc262_hp_t5735_automute(codec, 1);
9443 static void alc262_hp_t5735_init_hook(struct hda_codec *codec)
9445 alc262_hp_t5735_automute(codec, 1);
9448 static struct snd_kcontrol_new alc262_hp_t5735_mixer[] = {
9449 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9450 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9451 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
9452 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9453 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9454 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9455 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9459 static struct hda_verb alc262_hp_t5735_verbs[] = {
9460 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9461 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9463 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9467 static struct snd_kcontrol_new alc262_hp_rp5700_mixer[] = {
9468 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9469 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
9470 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
9471 HDA_CODEC_MUTE("Speaker Playback Switch", 0x16, 0x0, HDA_OUTPUT),
9472 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
9473 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
9477 static struct hda_verb alc262_hp_rp5700_verbs[] = {
9478 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9479 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9480 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9481 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9482 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
9483 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
9484 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
9485 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
9486 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
9487 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
9491 static struct hda_input_mux alc262_hp_rp5700_capture_source = {
9498 /* bind hp and internal speaker mute (with plug check) */
9499 static int alc262_sony_master_sw_put(struct snd_kcontrol *kcontrol,
9500 struct snd_ctl_elem_value *ucontrol)
9502 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
9503 long *valp = ucontrol->value.integer.value;
9506 /* change hp mute */
9507 change = snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
9509 valp[0] ? 0 : HDA_AMP_MUTE);
9510 change |= snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
9512 valp[1] ? 0 : HDA_AMP_MUTE);
9514 /* change speaker according to HP jack state */
9515 struct alc_spec *spec = codec->spec;
9517 if (spec->jack_present)
9518 mute = HDA_AMP_MUTE;
9520 mute = snd_hda_codec_amp_read(codec, 0x15, 0,
9522 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9523 HDA_AMP_MUTE, mute);
9528 static struct snd_kcontrol_new alc262_sony_mixer[] = {
9529 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9531 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9532 .name = "Master Playback Switch",
9533 .info = snd_hda_mixer_amp_switch_info,
9534 .get = snd_hda_mixer_amp_switch_get,
9535 .put = alc262_sony_master_sw_put,
9536 .private_value = HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
9538 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9539 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9540 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9541 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
9545 static struct snd_kcontrol_new alc262_benq_t31_mixer[] = {
9546 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9547 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9548 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9549 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9550 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9551 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9552 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
9556 static struct snd_kcontrol_new alc262_tyan_mixer[] = {
9557 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9558 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
9559 HDA_CODEC_VOLUME("Aux Playback Volume", 0x0b, 0x06, HDA_INPUT),
9560 HDA_CODEC_MUTE("Aux Playback Switch", 0x0b, 0x06, HDA_INPUT),
9561 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9562 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9563 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9564 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9565 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9566 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9567 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
9568 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
9572 static struct hda_verb alc262_tyan_verbs[] = {
9573 /* Headphone automute */
9574 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9575 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9576 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9578 /* P11 AUX_IN, white 4-pin connector */
9579 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
9580 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_1, 0xe1},
9581 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_2, 0x93},
9582 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_3, 0x19},
9587 /* unsolicited event for HP jack sensing */
9588 static void alc262_tyan_automute(struct hda_codec *codec)
9591 unsigned int present;
9593 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
9594 present = snd_hda_codec_read(codec, 0x1b, 0,
9595 AC_VERB_GET_PIN_SENSE, 0);
9596 present = (present & 0x80000000) != 0;
9598 /* mute line output on ATX panel */
9599 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
9600 HDA_AMP_MUTE, HDA_AMP_MUTE);
9602 /* unmute line output if necessary */
9603 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
9604 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
9605 HDA_AMP_MUTE, mute);
9609 static void alc262_tyan_unsol_event(struct hda_codec *codec,
9612 if ((res >> 26) != ALC880_HP_EVENT)
9614 alc262_tyan_automute(codec);
9617 #define alc262_capture_mixer alc882_capture_mixer
9618 #define alc262_capture_alt_mixer alc882_capture_alt_mixer
9621 * generic initialization of ADC, input mixers and output mixers
9623 static struct hda_verb alc262_init_verbs[] = {
9625 * Unmute ADC0-2 and set the default input to mic-in
9627 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
9628 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9629 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
9630 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9631 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
9632 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9634 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
9636 * Note: PASD motherboards uses the Line In 2 as the input for
9637 * front panel mic (mic 2)
9639 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
9640 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9641 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9642 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
9643 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
9644 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
9647 * Set up output mixers (0x0c - 0x0e)
9649 /* set vol=0 to output mixers */
9650 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9651 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9652 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9653 /* set up input amps for analog loopback */
9654 /* Amp Indices: DAC = 0, mixer = 1 */
9655 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9656 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9657 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9658 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9659 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9660 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9662 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
9663 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
9664 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
9665 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
9666 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9667 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9669 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
9670 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
9671 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
9672 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
9673 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
9675 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
9676 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
9678 /* FIXME: use matrix-type input source selection */
9679 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
9680 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
9681 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9682 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
9683 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
9684 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
9686 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9687 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
9688 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
9689 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
9691 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9692 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
9693 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
9694 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
9699 static struct hda_verb alc262_eapd_verbs[] = {
9700 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
9701 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
9705 static struct hda_verb alc262_hippo_unsol_verbs[] = {
9706 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9707 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9711 static struct hda_verb alc262_hippo1_unsol_verbs[] = {
9712 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
9713 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
9714 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
9716 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9717 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9721 static struct hda_verb alc262_sony_unsol_verbs[] = {
9722 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
9723 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9724 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, // Front Mic
9726 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9727 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9731 static struct hda_input_mux alc262_dmic_capture_source = {
9734 { "Int DMic", 0x9 },
9739 static struct snd_kcontrol_new alc262_toshiba_s06_mixer[] = {
9740 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9741 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9742 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9743 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9744 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9748 static struct hda_verb alc262_toshiba_s06_verbs[] = {
9749 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
9750 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9751 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9752 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9753 {0x22, AC_VERB_SET_CONNECT_SEL, 0x09},
9754 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
9755 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
9756 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9760 static void alc262_dmic_automute(struct hda_codec *codec)
9762 unsigned int present;
9764 present = snd_hda_codec_read(codec, 0x18, 0,
9765 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
9766 snd_hda_codec_write(codec, 0x22, 0,
9767 AC_VERB_SET_CONNECT_SEL, present ? 0x0 : 0x09);
9770 /* toggle speaker-output according to the hp-jack state */
9771 static void alc262_toshiba_s06_speaker_automute(struct hda_codec *codec)
9773 unsigned int present;
9776 present = snd_hda_codec_read(codec, 0x15, 0,
9777 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
9778 bits = present ? 0 : PIN_OUT;
9779 snd_hda_codec_write(codec, 0x14, 0,
9780 AC_VERB_SET_PIN_WIDGET_CONTROL, bits);
9785 /* unsolicited event for HP jack sensing */
9786 static void alc262_toshiba_s06_unsol_event(struct hda_codec *codec,
9789 if ((res >> 26) == ALC880_HP_EVENT)
9790 alc262_toshiba_s06_speaker_automute(codec);
9791 if ((res >> 26) == ALC880_MIC_EVENT)
9792 alc262_dmic_automute(codec);
9796 static void alc262_toshiba_s06_init_hook(struct hda_codec *codec)
9798 alc262_toshiba_s06_speaker_automute(codec);
9799 alc262_dmic_automute(codec);
9802 /* mute/unmute internal speaker according to the hp jack and mute state */
9803 static void alc262_hippo_automute(struct hda_codec *codec)
9805 struct alc_spec *spec = codec->spec;
9807 unsigned int present;
9809 /* need to execute and sync at first */
9810 snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
9811 present = snd_hda_codec_read(codec, 0x15, 0,
9812 AC_VERB_GET_PIN_SENSE, 0);
9813 spec->jack_present = (present & 0x80000000) != 0;
9814 if (spec->jack_present) {
9815 /* mute internal speaker */
9816 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9817 HDA_AMP_MUTE, HDA_AMP_MUTE);
9819 /* unmute internal speaker if necessary */
9820 mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0);
9821 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9822 HDA_AMP_MUTE, mute);
9826 /* unsolicited event for HP jack sensing */
9827 static void alc262_hippo_unsol_event(struct hda_codec *codec,
9830 if ((res >> 26) != ALC880_HP_EVENT)
9832 alc262_hippo_automute(codec);
9835 static void alc262_hippo1_automute(struct hda_codec *codec)
9838 unsigned int present;
9840 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
9841 present = snd_hda_codec_read(codec, 0x1b, 0,
9842 AC_VERB_GET_PIN_SENSE, 0);
9843 present = (present & 0x80000000) != 0;
9845 /* mute internal speaker */
9846 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9847 HDA_AMP_MUTE, HDA_AMP_MUTE);
9849 /* unmute internal speaker if necessary */
9850 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
9851 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9852 HDA_AMP_MUTE, mute);
9856 /* unsolicited event for HP jack sensing */
9857 static void alc262_hippo1_unsol_event(struct hda_codec *codec,
9860 if ((res >> 26) != ALC880_HP_EVENT)
9862 alc262_hippo1_automute(codec);
9868 * 0x16 = internal speaker
9869 * 0x18 = external mic
9872 static struct snd_kcontrol_new alc262_nec_mixer[] = {
9873 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
9874 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 0, 0x0, HDA_OUTPUT),
9876 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9877 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9878 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9880 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
9881 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9885 static struct hda_verb alc262_nec_verbs[] = {
9886 /* Unmute Speaker */
9887 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9890 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9891 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9893 /* External mic to headphone */
9894 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9895 /* External mic to speaker */
9896 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9902 * 0x14 = headphone/spdif-out, 0x15 = internal speaker,
9903 * 0x1b = port replicator headphone out
9906 #define ALC_HP_EVENT 0x37
9908 static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
9909 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
9910 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9911 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
9912 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9916 static struct hda_verb alc262_lenovo_3000_unsol_verbs[] = {
9917 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
9918 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9922 static struct hda_input_mux alc262_fujitsu_capture_source = {
9931 static struct hda_input_mux alc262_HP_capture_source = {
9935 { "Front Mic", 0x1 },
9942 static struct hda_input_mux alc262_HP_D7000_capture_source = {
9946 { "Front Mic", 0x2 },
9952 /* mute/unmute internal speaker according to the hp jacks and mute state */
9953 static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
9955 struct alc_spec *spec = codec->spec;
9958 if (force || !spec->sense_updated) {
9959 unsigned int present;
9960 /* need to execute and sync at first */
9961 snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
9962 /* check laptop HP jack */
9963 present = snd_hda_codec_read(codec, 0x14, 0,
9964 AC_VERB_GET_PIN_SENSE, 0);
9965 /* need to execute and sync at first */
9966 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
9967 /* check docking HP jack */
9968 present |= snd_hda_codec_read(codec, 0x1b, 0,
9969 AC_VERB_GET_PIN_SENSE, 0);
9970 if (present & AC_PINSENSE_PRESENCE)
9971 spec->jack_present = 1;
9973 spec->jack_present = 0;
9974 spec->sense_updated = 1;
9976 /* unmute internal speaker only if both HPs are unplugged and
9977 * master switch is on
9979 if (spec->jack_present)
9980 mute = HDA_AMP_MUTE;
9982 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
9983 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
9984 HDA_AMP_MUTE, mute);
9987 /* unsolicited event for HP jack sensing */
9988 static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
9991 if ((res >> 26) != ALC_HP_EVENT)
9993 alc262_fujitsu_automute(codec, 1);
9996 static void alc262_fujitsu_init_hook(struct hda_codec *codec)
9998 alc262_fujitsu_automute(codec, 1);
10001 /* bind volumes of both NID 0x0c and 0x0d */
10002 static struct hda_bind_ctls alc262_fujitsu_bind_master_vol = {
10003 .ops = &snd_hda_bind_vol,
10005 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
10006 HDA_COMPOSE_AMP_VAL(0x0d, 3, 0, HDA_OUTPUT),
10011 /* mute/unmute internal speaker according to the hp jack and mute state */
10012 static void alc262_lenovo_3000_automute(struct hda_codec *codec, int force)
10014 struct alc_spec *spec = codec->spec;
10017 if (force || !spec->sense_updated) {
10018 unsigned int present_int_hp;
10019 /* need to execute and sync at first */
10020 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
10021 present_int_hp = snd_hda_codec_read(codec, 0x1b, 0,
10022 AC_VERB_GET_PIN_SENSE, 0);
10023 spec->jack_present = (present_int_hp & 0x80000000) != 0;
10024 spec->sense_updated = 1;
10026 if (spec->jack_present) {
10027 /* mute internal speaker */
10028 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10029 HDA_AMP_MUTE, HDA_AMP_MUTE);
10030 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
10031 HDA_AMP_MUTE, HDA_AMP_MUTE);
10033 /* unmute internal speaker if necessary */
10034 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
10035 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10036 HDA_AMP_MUTE, mute);
10037 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
10038 HDA_AMP_MUTE, mute);
10042 /* unsolicited event for HP jack sensing */
10043 static void alc262_lenovo_3000_unsol_event(struct hda_codec *codec,
10046 if ((res >> 26) != ALC_HP_EVENT)
10048 alc262_lenovo_3000_automute(codec, 1);
10051 /* bind hp and internal speaker mute (with plug check) */
10052 static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
10053 struct snd_ctl_elem_value *ucontrol)
10055 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10056 long *valp = ucontrol->value.integer.value;
10059 change = snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10061 valp ? 0 : HDA_AMP_MUTE);
10062 change |= snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
10064 valp ? 0 : HDA_AMP_MUTE);
10067 alc262_fujitsu_automute(codec, 0);
10071 static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
10072 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
10074 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10075 .name = "Master Playback Switch",
10076 .info = snd_hda_mixer_amp_switch_info,
10077 .get = snd_hda_mixer_amp_switch_get,
10078 .put = alc262_fujitsu_master_sw_put,
10079 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
10081 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10082 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10083 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10084 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10085 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10086 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
10087 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
10088 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
10092 /* bind hp and internal speaker mute (with plug check) */
10093 static int alc262_lenovo_3000_master_sw_put(struct snd_kcontrol *kcontrol,
10094 struct snd_ctl_elem_value *ucontrol)
10096 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10097 long *valp = ucontrol->value.integer.value;
10100 change = snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
10102 valp ? 0 : HDA_AMP_MUTE);
10105 alc262_lenovo_3000_automute(codec, 0);
10109 static struct snd_kcontrol_new alc262_lenovo_3000_mixer[] = {
10110 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
10112 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10113 .name = "Master Playback Switch",
10114 .info = snd_hda_mixer_amp_switch_info,
10115 .get = snd_hda_mixer_amp_switch_get,
10116 .put = alc262_lenovo_3000_master_sw_put,
10117 .private_value = HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
10119 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10120 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10121 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10122 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10123 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10124 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
10125 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
10126 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
10130 static struct snd_kcontrol_new alc262_toshiba_rx1_mixer[] = {
10131 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
10133 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10134 .name = "Master Playback Switch",
10135 .info = snd_hda_mixer_amp_switch_info,
10136 .get = snd_hda_mixer_amp_switch_get,
10137 .put = alc262_sony_master_sw_put,
10138 .private_value = HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
10140 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10141 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10142 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10143 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10144 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10145 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10149 /* additional init verbs for Benq laptops */
10150 static struct hda_verb alc262_EAPD_verbs[] = {
10151 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
10152 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
10156 static struct hda_verb alc262_benq_t31_EAPD_verbs[] = {
10157 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10158 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10160 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
10161 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
10165 /* Samsung Q1 Ultra Vista model setup */
10166 static struct snd_kcontrol_new alc262_ultra_mixer[] = {
10167 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10168 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
10169 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10170 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10171 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
10172 HDA_CODEC_VOLUME("Headphone Mic Boost", 0x15, 0, HDA_INPUT),
10176 static struct hda_verb alc262_ultra_verbs[] = {
10178 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10179 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10180 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10182 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10183 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10184 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10185 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
10187 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10188 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10189 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10190 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10191 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10193 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
10194 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10195 /* ADC, choose mic */
10196 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10197 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10198 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10199 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10200 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10201 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
10202 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
10203 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
10204 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
10205 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(8)},
10209 /* mute/unmute internal speaker according to the hp jack and mute state */
10210 static void alc262_ultra_automute(struct hda_codec *codec)
10212 struct alc_spec *spec = codec->spec;
10216 /* auto-mute only when HP is used as HP */
10217 if (!spec->cur_mux[0]) {
10218 unsigned int present;
10219 /* need to execute and sync at first */
10220 snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
10221 present = snd_hda_codec_read(codec, 0x15, 0,
10222 AC_VERB_GET_PIN_SENSE, 0);
10223 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
10224 if (spec->jack_present)
10225 mute = HDA_AMP_MUTE;
10227 /* mute/unmute internal speaker */
10228 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10229 HDA_AMP_MUTE, mute);
10230 /* mute/unmute HP */
10231 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
10232 HDA_AMP_MUTE, mute ? 0 : HDA_AMP_MUTE);
10235 /* unsolicited event for HP jack sensing */
10236 static void alc262_ultra_unsol_event(struct hda_codec *codec,
10239 if ((res >> 26) != ALC880_HP_EVENT)
10241 alc262_ultra_automute(codec);
10244 static struct hda_input_mux alc262_ultra_capture_source = {
10248 { "Headphone", 0x7 },
10252 static int alc262_ultra_mux_enum_put(struct snd_kcontrol *kcontrol,
10253 struct snd_ctl_elem_value *ucontrol)
10255 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10256 struct alc_spec *spec = codec->spec;
10259 ret = alc_mux_enum_put(kcontrol, ucontrol);
10262 /* reprogram the HP pin as mic or HP according to the input source */
10263 snd_hda_codec_write_cache(codec, 0x15, 0,
10264 AC_VERB_SET_PIN_WIDGET_CONTROL,
10265 spec->cur_mux[0] ? PIN_VREF80 : PIN_HP);
10266 alc262_ultra_automute(codec); /* mute/unmute HP */
10270 static struct snd_kcontrol_new alc262_ultra_capture_mixer[] = {
10271 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
10272 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
10274 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10275 .name = "Capture Source",
10276 .info = alc_mux_enum_info,
10277 .get = alc_mux_enum_get,
10278 .put = alc262_ultra_mux_enum_put,
10283 /* add playback controls from the parsed DAC table */
10284 static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec,
10285 const struct auto_pin_cfg *cfg)
10290 spec->multiout.num_dacs = 1; /* only use one dac */
10291 spec->multiout.dac_nids = spec->private_dac_nids;
10292 spec->multiout.dac_nids[0] = 2;
10294 nid = cfg->line_out_pins[0];
10296 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10297 "Front Playback Volume",
10298 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT));
10301 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10302 "Front Playback Switch",
10303 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
10308 nid = cfg->speaker_pins[0];
10311 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10312 "Speaker Playback Volume",
10313 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
10317 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10318 "Speaker Playback Switch",
10319 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
10324 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10325 "Speaker Playback Switch",
10326 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
10332 nid = cfg->hp_pins[0];
10334 /* spec->multiout.hp_nid = 2; */
10336 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10337 "Headphone Playback Volume",
10338 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
10342 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10343 "Headphone Playback Switch",
10344 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
10349 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10350 "Headphone Playback Switch",
10351 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
10360 /* identical with ALC880 */
10361 #define alc262_auto_create_analog_input_ctls \
10362 alc880_auto_create_analog_input_ctls
10365 * generic initialization of ADC, input mixers and output mixers
10367 static struct hda_verb alc262_volume_init_verbs[] = {
10369 * Unmute ADC0-2 and set the default input to mic-in
10371 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
10372 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10373 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
10374 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10375 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
10376 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10378 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
10380 * Note: PASD motherboards uses the Line In 2 as the input for
10381 * front panel mic (mic 2)
10383 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
10384 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10385 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10386 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10387 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10388 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
10391 * Set up output mixers (0x0c - 0x0f)
10393 /* set vol=0 to output mixers */
10394 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10395 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10396 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10398 /* set up input amps for analog loopback */
10399 /* Amp Indices: DAC = 0, mixer = 1 */
10400 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10401 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10402 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10403 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10404 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10405 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10407 /* FIXME: use matrix-type input source selection */
10408 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
10409 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
10410 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10411 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10412 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10413 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10415 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10416 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10417 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10418 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10420 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10421 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10422 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10423 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10428 static struct hda_verb alc262_HP_BPC_init_verbs[] = {
10430 * Unmute ADC0-2 and set the default input to mic-in
10432 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
10433 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10434 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
10435 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10436 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
10437 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10439 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
10441 * Note: PASD motherboards uses the Line In 2 as the input for
10442 * front panel mic (mic 2)
10444 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
10445 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10446 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10447 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10448 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10449 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
10450 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
10451 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
10454 * Set up output mixers (0x0c - 0x0e)
10456 /* set vol=0 to output mixers */
10457 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10458 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10459 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10461 /* set up input amps for analog loopback */
10462 /* Amp Indices: DAC = 0, mixer = 1 */
10463 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10464 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10465 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10466 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10467 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10468 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10470 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10471 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10472 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10474 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10475 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10477 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
10478 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10480 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10481 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10482 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10483 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10484 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10486 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
10487 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10488 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10489 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
10490 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10491 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10494 /* FIXME: use matrix-type input source selection */
10495 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
10496 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
10497 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10498 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
10499 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
10500 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
10502 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10503 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
10504 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
10505 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
10507 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10508 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
10509 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
10510 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
10512 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
10517 static struct hda_verb alc262_HP_BPC_WildWest_init_verbs[] = {
10519 * Unmute ADC0-2 and set the default input to mic-in
10521 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
10522 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10523 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
10524 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10525 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
10526 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10528 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
10530 * Note: PASD motherboards uses the Line In 2 as the input for front
10531 * panel mic (mic 2)
10533 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
10534 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10535 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10536 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10537 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10538 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
10539 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
10540 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
10541 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
10543 * Set up output mixers (0x0c - 0x0e)
10545 /* set vol=0 to output mixers */
10546 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10547 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10548 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10550 /* set up input amps for analog loopback */
10551 /* Amp Indices: DAC = 0, mixer = 1 */
10552 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10553 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10554 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10555 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10556 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10557 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10560 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP */
10561 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Mono */
10562 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* rear MIC */
10563 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* Line in */
10564 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
10565 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Line out */
10566 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD in */
10568 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10569 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10571 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
10572 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
10574 /* {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, */
10575 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10576 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10577 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
10578 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10579 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10581 /* FIXME: use matrix-type input source selection */
10582 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
10583 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
10584 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, /*rear MIC*/
10585 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, /*Line in*/
10586 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, /*F MIC*/
10587 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, /*Front*/
10588 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, /*CD*/
10589 /* {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
10590 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, /*HP*/
10592 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10593 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
10594 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
10595 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
10596 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
10597 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
10598 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
10600 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10601 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
10602 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
10603 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
10604 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
10605 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
10606 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
10608 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
10613 static struct hda_verb alc262_toshiba_rx1_unsol_verbs[] = {
10615 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Front Speaker */
10616 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10617 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
10619 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* MIC jack */
10620 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
10621 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
10622 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
10624 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP jack */
10625 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10626 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10631 #ifdef CONFIG_SND_HDA_POWER_SAVE
10632 #define alc262_loopbacks alc880_loopbacks
10635 /* pcm configuration: identiacal with ALC880 */
10636 #define alc262_pcm_analog_playback alc880_pcm_analog_playback
10637 #define alc262_pcm_analog_capture alc880_pcm_analog_capture
10638 #define alc262_pcm_digital_playback alc880_pcm_digital_playback
10639 #define alc262_pcm_digital_capture alc880_pcm_digital_capture
10642 * BIOS auto configuration
10644 static int alc262_parse_auto_config(struct hda_codec *codec)
10646 struct alc_spec *spec = codec->spec;
10648 static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
10650 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
10654 if (!spec->autocfg.line_outs) {
10655 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
10656 spec->multiout.max_channels = 2;
10657 spec->no_analog = 1;
10660 return 0; /* can't find valid BIOS pin config */
10662 err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg);
10665 err = alc262_auto_create_analog_input_ctls(spec, &spec->autocfg);
10669 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
10672 if (spec->autocfg.dig_outs) {
10673 spec->multiout.dig_out_nid = ALC262_DIGOUT_NID;
10674 spec->dig_out_type = spec->autocfg.dig_out_type[0];
10676 if (spec->autocfg.dig_in_pin)
10677 spec->dig_in_nid = ALC262_DIGIN_NID;
10679 if (spec->kctls.list)
10680 add_mixer(spec, spec->kctls.list);
10682 add_verb(spec, alc262_volume_init_verbs);
10683 spec->num_mux_defs = 1;
10684 spec->input_mux = &spec->private_imux[0];
10686 err = alc_auto_add_mic_boost(codec);
10690 store_pin_configs(codec);
10694 #define alc262_auto_init_multi_out alc882_auto_init_multi_out
10695 #define alc262_auto_init_hp_out alc882_auto_init_hp_out
10696 #define alc262_auto_init_analog_input alc882_auto_init_analog_input
10697 #define alc262_auto_init_input_src alc882_auto_init_input_src
10700 /* init callback for auto-configuration model -- overriding the default init */
10701 static void alc262_auto_init(struct hda_codec *codec)
10703 struct alc_spec *spec = codec->spec;
10704 alc262_auto_init_multi_out(codec);
10705 alc262_auto_init_hp_out(codec);
10706 alc262_auto_init_analog_input(codec);
10707 alc262_auto_init_input_src(codec);
10708 if (spec->unsol_event)
10709 alc_inithook(codec);
10713 * configuration and preset
10715 static const char *alc262_models[ALC262_MODEL_LAST] = {
10716 [ALC262_BASIC] = "basic",
10717 [ALC262_HIPPO] = "hippo",
10718 [ALC262_HIPPO_1] = "hippo_1",
10719 [ALC262_FUJITSU] = "fujitsu",
10720 [ALC262_HP_BPC] = "hp-bpc",
10721 [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000",
10722 [ALC262_HP_TC_T5735] = "hp-tc-t5735",
10723 [ALC262_HP_RP5700] = "hp-rp5700",
10724 [ALC262_BENQ_ED8] = "benq",
10725 [ALC262_BENQ_T31] = "benq-t31",
10726 [ALC262_SONY_ASSAMD] = "sony-assamd",
10727 [ALC262_TOSHIBA_S06] = "toshiba-s06",
10728 [ALC262_TOSHIBA_RX1] = "toshiba-rx1",
10729 [ALC262_ULTRA] = "ultra",
10730 [ALC262_LENOVO_3000] = "lenovo-3000",
10731 [ALC262_NEC] = "nec",
10732 [ALC262_TYAN] = "tyan",
10733 [ALC262_AUTO] = "auto",
10736 static struct snd_pci_quirk alc262_cfg_tbl[] = {
10737 SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO),
10738 SND_PCI_QUIRK(0x1033, 0x8895, "NEC Versa S9100", ALC262_NEC),
10739 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1200, "HP xw series",
10741 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1300, "HP xw series",
10743 SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL),
10744 SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF),
10745 SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL),
10746 SND_PCI_QUIRK(0x103c, 0x2803, "HP D7000", ALC262_HP_BPC_D7000_WF),
10747 SND_PCI_QUIRK(0x103c, 0x2804, "HP D7000", ALC262_HP_BPC_D7000_WL),
10748 SND_PCI_QUIRK(0x103c, 0x2805, "HP D7000", ALC262_HP_BPC_D7000_WF),
10749 SND_PCI_QUIRK(0x103c, 0x2806, "HP D7000", ALC262_HP_BPC_D7000_WL),
10750 SND_PCI_QUIRK(0x103c, 0x2807, "HP D7000", ALC262_HP_BPC_D7000_WF),
10751 SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC),
10752 SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC),
10753 SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC),
10754 SND_PCI_QUIRK(0x103c, 0x302f, "HP Thin Client T5735",
10755 ALC262_HP_TC_T5735),
10756 SND_PCI_QUIRK(0x103c, 0x2817, "HP RP5700", ALC262_HP_RP5700),
10757 SND_PCI_QUIRK(0x104d, 0x1f00, "Sony ASSAMD", ALC262_SONY_ASSAMD),
10758 SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO),
10759 SND_PCI_QUIRK(0x104d, 0x820f, "Sony ASSAMD", ALC262_SONY_ASSAMD),
10760 SND_PCI_QUIRK(0x104d, 0x900e, "Sony ASSAMD", ALC262_SONY_ASSAMD),
10761 SND_PCI_QUIRK(0x104d, 0x9015, "Sony 0x9015", ALC262_SONY_ASSAMD),
10762 SND_PCI_QUIRK(0x104d, 0x9033, "Sony VAIO VGN-SR19XN",
10763 ALC262_SONY_ASSAMD),
10764 SND_PCI_QUIRK(0x1179, 0x0001, "Toshiba dynabook SS RX1",
10765 ALC262_TOSHIBA_RX1),
10766 SND_PCI_QUIRK(0x1179, 0xff7b, "Toshiba S06", ALC262_TOSHIBA_S06),
10767 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
10768 SND_PCI_QUIRK(0x10cf, 0x142d, "Fujitsu Lifebook E8410", ALC262_FUJITSU),
10769 SND_PCI_QUIRK(0x10f1, 0x2915, "Tyan Thunder n6650W", ALC262_TYAN),
10770 SND_PCI_QUIRK_MASK(0x144d, 0xff00, 0xc032, "Samsung Q1",
10772 SND_PCI_QUIRK(0x144d, 0xc510, "Samsung Q45", ALC262_HIPPO),
10773 SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000 y410", ALC262_LENOVO_3000),
10774 SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
10775 SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_BENQ_T31),
10776 SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1),
10780 static struct alc_config_preset alc262_presets[] = {
10782 .mixers = { alc262_base_mixer },
10783 .init_verbs = { alc262_init_verbs },
10784 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10785 .dac_nids = alc262_dac_nids,
10787 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10788 .channel_mode = alc262_modes,
10789 .input_mux = &alc262_capture_source,
10792 .mixers = { alc262_base_mixer },
10793 .init_verbs = { alc262_init_verbs, alc262_hippo_unsol_verbs},
10794 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10795 .dac_nids = alc262_dac_nids,
10797 .dig_out_nid = ALC262_DIGOUT_NID,
10798 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10799 .channel_mode = alc262_modes,
10800 .input_mux = &alc262_capture_source,
10801 .unsol_event = alc262_hippo_unsol_event,
10802 .init_hook = alc262_hippo_automute,
10804 [ALC262_HIPPO_1] = {
10805 .mixers = { alc262_hippo1_mixer },
10806 .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs},
10807 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10808 .dac_nids = alc262_dac_nids,
10810 .dig_out_nid = ALC262_DIGOUT_NID,
10811 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10812 .channel_mode = alc262_modes,
10813 .input_mux = &alc262_capture_source,
10814 .unsol_event = alc262_hippo1_unsol_event,
10815 .init_hook = alc262_hippo1_automute,
10817 [ALC262_FUJITSU] = {
10818 .mixers = { alc262_fujitsu_mixer },
10819 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
10820 alc262_fujitsu_unsol_verbs },
10821 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10822 .dac_nids = alc262_dac_nids,
10824 .dig_out_nid = ALC262_DIGOUT_NID,
10825 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10826 .channel_mode = alc262_modes,
10827 .input_mux = &alc262_fujitsu_capture_source,
10828 .unsol_event = alc262_fujitsu_unsol_event,
10829 .init_hook = alc262_fujitsu_init_hook,
10831 [ALC262_HP_BPC] = {
10832 .mixers = { alc262_HP_BPC_mixer },
10833 .init_verbs = { alc262_HP_BPC_init_verbs },
10834 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10835 .dac_nids = alc262_dac_nids,
10837 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10838 .channel_mode = alc262_modes,
10839 .input_mux = &alc262_HP_capture_source,
10840 .unsol_event = alc262_hp_bpc_unsol_event,
10841 .init_hook = alc262_hp_bpc_automute,
10843 [ALC262_HP_BPC_D7000_WF] = {
10844 .mixers = { alc262_HP_BPC_WildWest_mixer },
10845 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
10846 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10847 .dac_nids = alc262_dac_nids,
10849 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10850 .channel_mode = alc262_modes,
10851 .input_mux = &alc262_HP_D7000_capture_source,
10852 .unsol_event = alc262_hp_wildwest_unsol_event,
10853 .init_hook = alc262_hp_wildwest_automute,
10855 [ALC262_HP_BPC_D7000_WL] = {
10856 .mixers = { alc262_HP_BPC_WildWest_mixer,
10857 alc262_HP_BPC_WildWest_option_mixer },
10858 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
10859 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10860 .dac_nids = alc262_dac_nids,
10862 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10863 .channel_mode = alc262_modes,
10864 .input_mux = &alc262_HP_D7000_capture_source,
10865 .unsol_event = alc262_hp_wildwest_unsol_event,
10866 .init_hook = alc262_hp_wildwest_automute,
10868 [ALC262_HP_TC_T5735] = {
10869 .mixers = { alc262_hp_t5735_mixer },
10870 .init_verbs = { alc262_init_verbs, alc262_hp_t5735_verbs },
10871 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10872 .dac_nids = alc262_dac_nids,
10874 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10875 .channel_mode = alc262_modes,
10876 .input_mux = &alc262_capture_source,
10877 .unsol_event = alc262_hp_t5735_unsol_event,
10878 .init_hook = alc262_hp_t5735_init_hook,
10880 [ALC262_HP_RP5700] = {
10881 .mixers = { alc262_hp_rp5700_mixer },
10882 .init_verbs = { alc262_init_verbs, alc262_hp_rp5700_verbs },
10883 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10884 .dac_nids = alc262_dac_nids,
10885 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10886 .channel_mode = alc262_modes,
10887 .input_mux = &alc262_hp_rp5700_capture_source,
10889 [ALC262_BENQ_ED8] = {
10890 .mixers = { alc262_base_mixer },
10891 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
10892 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10893 .dac_nids = alc262_dac_nids,
10895 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10896 .channel_mode = alc262_modes,
10897 .input_mux = &alc262_capture_source,
10899 [ALC262_SONY_ASSAMD] = {
10900 .mixers = { alc262_sony_mixer },
10901 .init_verbs = { alc262_init_verbs, alc262_sony_unsol_verbs},
10902 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10903 .dac_nids = alc262_dac_nids,
10905 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10906 .channel_mode = alc262_modes,
10907 .input_mux = &alc262_capture_source,
10908 .unsol_event = alc262_hippo_unsol_event,
10909 .init_hook = alc262_hippo_automute,
10911 [ALC262_BENQ_T31] = {
10912 .mixers = { alc262_benq_t31_mixer },
10913 .init_verbs = { alc262_init_verbs, alc262_benq_t31_EAPD_verbs, alc262_hippo_unsol_verbs },
10914 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10915 .dac_nids = alc262_dac_nids,
10917 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10918 .channel_mode = alc262_modes,
10919 .input_mux = &alc262_capture_source,
10920 .unsol_event = alc262_hippo_unsol_event,
10921 .init_hook = alc262_hippo_automute,
10924 .mixers = { alc262_ultra_mixer },
10925 .cap_mixer = alc262_ultra_capture_mixer,
10926 .init_verbs = { alc262_ultra_verbs },
10927 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10928 .dac_nids = alc262_dac_nids,
10929 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10930 .channel_mode = alc262_modes,
10931 .input_mux = &alc262_ultra_capture_source,
10932 .adc_nids = alc262_adc_nids, /* ADC0 */
10933 .capsrc_nids = alc262_capsrc_nids,
10934 .num_adc_nids = 1, /* single ADC */
10935 .unsol_event = alc262_ultra_unsol_event,
10936 .init_hook = alc262_ultra_automute,
10938 [ALC262_LENOVO_3000] = {
10939 .mixers = { alc262_lenovo_3000_mixer },
10940 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
10941 alc262_lenovo_3000_unsol_verbs },
10942 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10943 .dac_nids = alc262_dac_nids,
10945 .dig_out_nid = ALC262_DIGOUT_NID,
10946 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10947 .channel_mode = alc262_modes,
10948 .input_mux = &alc262_fujitsu_capture_source,
10949 .unsol_event = alc262_lenovo_3000_unsol_event,
10952 .mixers = { alc262_nec_mixer },
10953 .init_verbs = { alc262_nec_verbs },
10954 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10955 .dac_nids = alc262_dac_nids,
10957 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10958 .channel_mode = alc262_modes,
10959 .input_mux = &alc262_capture_source,
10961 [ALC262_TOSHIBA_S06] = {
10962 .mixers = { alc262_toshiba_s06_mixer },
10963 .init_verbs = { alc262_init_verbs, alc262_toshiba_s06_verbs,
10964 alc262_eapd_verbs },
10965 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10966 .capsrc_nids = alc262_dmic_capsrc_nids,
10967 .dac_nids = alc262_dac_nids,
10968 .adc_nids = alc262_dmic_adc_nids, /* ADC0 */
10969 .dig_out_nid = ALC262_DIGOUT_NID,
10970 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10971 .channel_mode = alc262_modes,
10972 .input_mux = &alc262_dmic_capture_source,
10973 .unsol_event = alc262_toshiba_s06_unsol_event,
10974 .init_hook = alc262_toshiba_s06_init_hook,
10976 [ALC262_TOSHIBA_RX1] = {
10977 .mixers = { alc262_toshiba_rx1_mixer },
10978 .init_verbs = { alc262_init_verbs, alc262_toshiba_rx1_unsol_verbs },
10979 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10980 .dac_nids = alc262_dac_nids,
10982 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10983 .channel_mode = alc262_modes,
10984 .input_mux = &alc262_capture_source,
10985 .unsol_event = alc262_hippo_unsol_event,
10986 .init_hook = alc262_hippo_automute,
10989 .mixers = { alc262_tyan_mixer },
10990 .init_verbs = { alc262_init_verbs, alc262_tyan_verbs},
10991 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10992 .dac_nids = alc262_dac_nids,
10994 .dig_out_nid = ALC262_DIGOUT_NID,
10995 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10996 .channel_mode = alc262_modes,
10997 .input_mux = &alc262_capture_source,
10998 .unsol_event = alc262_tyan_unsol_event,
10999 .init_hook = alc262_tyan_automute,
11003 static int patch_alc262(struct hda_codec *codec)
11005 struct alc_spec *spec;
11009 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
11013 codec->spec = spec;
11015 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
11020 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
11021 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
11022 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
11023 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
11027 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
11029 board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST,
11033 if (board_config < 0) {
11034 printk(KERN_INFO "hda_codec: Unknown model for ALC262, "
11035 "trying auto-probe from BIOS...\n");
11036 board_config = ALC262_AUTO;
11039 if (board_config == ALC262_AUTO) {
11040 /* automatic parse from the BIOS config */
11041 err = alc262_parse_auto_config(codec);
11047 "hda_codec: Cannot set up configuration "
11048 "from BIOS. Using base mode...\n");
11049 board_config = ALC262_BASIC;
11053 err = snd_hda_attach_beep_device(codec, 0x1);
11059 if (board_config != ALC262_AUTO)
11060 setup_preset(spec, &alc262_presets[board_config]);
11062 spec->stream_name_analog = "ALC262 Analog";
11063 spec->stream_analog_playback = &alc262_pcm_analog_playback;
11064 spec->stream_analog_capture = &alc262_pcm_analog_capture;
11066 spec->stream_name_digital = "ALC262 Digital";
11067 spec->stream_digital_playback = &alc262_pcm_digital_playback;
11068 spec->stream_digital_capture = &alc262_pcm_digital_capture;
11070 spec->capture_style = CAPT_MIX;
11071 if (!spec->adc_nids && spec->input_mux) {
11072 /* check whether NID 0x07 is valid */
11073 unsigned int wcap = get_wcaps(codec, 0x07);
11076 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
11077 if (wcap != AC_WID_AUD_IN) {
11078 spec->adc_nids = alc262_adc_nids_alt;
11079 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids_alt);
11080 spec->capsrc_nids = alc262_capsrc_nids_alt;
11082 spec->adc_nids = alc262_adc_nids;
11083 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids);
11084 spec->capsrc_nids = alc262_capsrc_nids;
11087 if (!spec->cap_mixer && !spec->no_analog)
11088 set_capture_mixer(spec);
11089 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
11091 spec->vmaster_nid = 0x0c;
11093 codec->patch_ops = alc_patch_ops;
11094 if (board_config == ALC262_AUTO)
11095 spec->init_hook = alc262_auto_init;
11096 #ifdef CONFIG_SND_HDA_POWER_SAVE
11097 if (!spec->loopback.amplist)
11098 spec->loopback.amplist = alc262_loopbacks;
11100 codec->proc_widget_hook = print_realtek_coef;
11106 * ALC268 channel source setting (2 channel)
11108 #define ALC268_DIGOUT_NID ALC880_DIGOUT_NID
11109 #define alc268_modes alc260_modes
11111 static hda_nid_t alc268_dac_nids[2] = {
11116 static hda_nid_t alc268_adc_nids[2] = {
11121 static hda_nid_t alc268_adc_nids_alt[1] = {
11126 static hda_nid_t alc268_capsrc_nids[2] = { 0x23, 0x24 };
11128 static struct snd_kcontrol_new alc268_base_mixer[] = {
11129 /* output mixer control */
11130 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
11131 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11132 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
11133 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11134 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11135 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
11136 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
11140 /* bind Beep switches of both NID 0x0f and 0x10 */
11141 static struct hda_bind_ctls alc268_bind_beep_sw = {
11142 .ops = &snd_hda_bind_sw,
11144 HDA_COMPOSE_AMP_VAL(0x0f, 3, 1, HDA_INPUT),
11145 HDA_COMPOSE_AMP_VAL(0x10, 3, 1, HDA_INPUT),
11150 static struct snd_kcontrol_new alc268_beep_mixer[] = {
11151 HDA_CODEC_VOLUME("Beep Playback Volume", 0x1d, 0x0, HDA_INPUT),
11152 HDA_BIND_SW("Beep Playback Switch", &alc268_bind_beep_sw),
11156 static struct hda_verb alc268_eapd_verbs[] = {
11157 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
11158 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
11162 /* Toshiba specific */
11163 #define alc268_toshiba_automute alc262_hippo_automute
11165 static struct hda_verb alc268_toshiba_verbs[] = {
11166 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11170 static struct hda_input_mux alc268_acer_lc_capture_source = {
11178 /* Acer specific */
11179 /* bind volumes of both NID 0x02 and 0x03 */
11180 static struct hda_bind_ctls alc268_acer_bind_master_vol = {
11181 .ops = &snd_hda_bind_vol,
11183 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
11184 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
11189 /* mute/unmute internal speaker according to the hp jack and mute state */
11190 static void alc268_acer_automute(struct hda_codec *codec, int force)
11192 struct alc_spec *spec = codec->spec;
11195 if (force || !spec->sense_updated) {
11196 unsigned int present;
11197 present = snd_hda_codec_read(codec, 0x14, 0,
11198 AC_VERB_GET_PIN_SENSE, 0);
11199 spec->jack_present = (present & 0x80000000) != 0;
11200 spec->sense_updated = 1;
11202 if (spec->jack_present)
11203 mute = HDA_AMP_MUTE; /* mute internal speaker */
11204 else /* unmute internal speaker if necessary */
11205 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
11206 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
11207 HDA_AMP_MUTE, mute);
11211 /* bind hp and internal speaker mute (with plug check) */
11212 static int alc268_acer_master_sw_put(struct snd_kcontrol *kcontrol,
11213 struct snd_ctl_elem_value *ucontrol)
11215 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
11216 long *valp = ucontrol->value.integer.value;
11219 change = snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
11221 valp[0] ? 0 : HDA_AMP_MUTE);
11222 change |= snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
11224 valp[1] ? 0 : HDA_AMP_MUTE);
11226 alc268_acer_automute(codec, 0);
11230 static struct snd_kcontrol_new alc268_acer_aspire_one_mixer[] = {
11231 /* output mixer control */
11232 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
11234 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11235 .name = "Master Playback Switch",
11236 .info = snd_hda_mixer_amp_switch_info,
11237 .get = snd_hda_mixer_amp_switch_get,
11238 .put = alc268_acer_master_sw_put,
11239 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
11241 HDA_CODEC_VOLUME("Mic Boost Capture Volume", 0x18, 0, HDA_INPUT),
11245 static struct snd_kcontrol_new alc268_acer_mixer[] = {
11246 /* output mixer control */
11247 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
11249 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11250 .name = "Master Playback Switch",
11251 .info = snd_hda_mixer_amp_switch_info,
11252 .get = snd_hda_mixer_amp_switch_get,
11253 .put = alc268_acer_master_sw_put,
11254 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
11256 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11257 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
11258 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
11262 static struct snd_kcontrol_new alc268_acer_dmic_mixer[] = {
11263 /* output mixer control */
11264 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
11266 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11267 .name = "Master Playback Switch",
11268 .info = snd_hda_mixer_amp_switch_info,
11269 .get = snd_hda_mixer_amp_switch_get,
11270 .put = alc268_acer_master_sw_put,
11271 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
11273 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11274 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
11278 static struct hda_verb alc268_acer_aspire_one_verbs[] = {
11279 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11280 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11281 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11282 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
11283 {0x23, AC_VERB_SET_CONNECT_SEL, 0x06},
11284 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, 0xa017},
11288 static struct hda_verb alc268_acer_verbs[] = {
11289 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* internal dmic? */
11290 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11291 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11292 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11293 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
11294 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
11295 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11299 /* unsolicited event for HP jack sensing */
11300 static void alc268_toshiba_unsol_event(struct hda_codec *codec,
11303 if ((res >> 26) != ALC880_HP_EVENT)
11305 alc268_toshiba_automute(codec);
11308 static void alc268_acer_unsol_event(struct hda_codec *codec,
11311 if ((res >> 26) != ALC880_HP_EVENT)
11313 alc268_acer_automute(codec, 1);
11316 static void alc268_acer_init_hook(struct hda_codec *codec)
11318 alc268_acer_automute(codec, 1);
11321 /* toggle speaker-output according to the hp-jack state */
11322 static void alc268_aspire_one_speaker_automute(struct hda_codec *codec)
11324 unsigned int present;
11325 unsigned char bits;
11327 present = snd_hda_codec_read(codec, 0x15, 0,
11328 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
11329 bits = present ? AMP_IN_MUTE(0) : 0;
11330 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 0,
11331 AMP_IN_MUTE(0), bits);
11332 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 1,
11333 AMP_IN_MUTE(0), bits);
11337 static void alc268_acer_mic_automute(struct hda_codec *codec)
11339 unsigned int present;
11341 present = snd_hda_codec_read(codec, 0x18, 0,
11342 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
11343 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_CONNECT_SEL,
11344 present ? 0x0 : 0x6);
11347 static void alc268_acer_lc_unsol_event(struct hda_codec *codec,
11350 if ((res >> 26) == ALC880_HP_EVENT)
11351 alc268_aspire_one_speaker_automute(codec);
11352 if ((res >> 26) == ALC880_MIC_EVENT)
11353 alc268_acer_mic_automute(codec);
11356 static void alc268_acer_lc_init_hook(struct hda_codec *codec)
11358 alc268_aspire_one_speaker_automute(codec);
11359 alc268_acer_mic_automute(codec);
11362 static struct snd_kcontrol_new alc268_dell_mixer[] = {
11363 /* output mixer control */
11364 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
11365 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11366 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
11367 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11368 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11369 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
11373 static struct hda_verb alc268_dell_verbs[] = {
11374 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11375 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11376 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11380 /* mute/unmute internal speaker according to the hp jack and mute state */
11381 static void alc268_dell_automute(struct hda_codec *codec)
11383 unsigned int present;
11386 present = snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_PIN_SENSE, 0);
11387 if (present & 0x80000000)
11388 mute = HDA_AMP_MUTE;
11390 mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0);
11391 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
11392 HDA_AMP_MUTE, mute);
11395 static void alc268_dell_unsol_event(struct hda_codec *codec,
11398 if ((res >> 26) != ALC880_HP_EVENT)
11400 alc268_dell_automute(codec);
11403 #define alc268_dell_init_hook alc268_dell_automute
11405 static struct snd_kcontrol_new alc267_quanta_il1_mixer[] = {
11406 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x2, 0x0, HDA_OUTPUT),
11407 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11408 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
11409 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11410 HDA_CODEC_VOLUME("Mic Capture Volume", 0x23, 0x0, HDA_OUTPUT),
11411 HDA_BIND_MUTE("Mic Capture Switch", 0x23, 2, HDA_OUTPUT),
11412 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
11413 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
11417 static struct hda_verb alc267_quanta_il1_verbs[] = {
11418 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11419 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
11423 static void alc267_quanta_il1_hp_automute(struct hda_codec *codec)
11425 unsigned int present;
11427 present = snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_PIN_SENSE, 0)
11428 & AC_PINSENSE_PRESENCE;
11429 snd_hda_codec_write(codec, 0x14, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
11430 present ? 0 : PIN_OUT);
11433 static void alc267_quanta_il1_mic_automute(struct hda_codec *codec)
11435 unsigned int present;
11437 present = snd_hda_codec_read(codec, 0x18, 0,
11438 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
11439 snd_hda_codec_write(codec, 0x23, 0,
11440 AC_VERB_SET_CONNECT_SEL,
11441 present ? 0x00 : 0x01);
11444 static void alc267_quanta_il1_automute(struct hda_codec *codec)
11446 alc267_quanta_il1_hp_automute(codec);
11447 alc267_quanta_il1_mic_automute(codec);
11450 static void alc267_quanta_il1_unsol_event(struct hda_codec *codec,
11453 switch (res >> 26) {
11454 case ALC880_HP_EVENT:
11455 alc267_quanta_il1_hp_automute(codec);
11457 case ALC880_MIC_EVENT:
11458 alc267_quanta_il1_mic_automute(codec);
11464 * generic initialization of ADC, input mixers and output mixers
11466 static struct hda_verb alc268_base_init_verbs[] = {
11467 /* Unmute DAC0-1 and set vol = 0 */
11468 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11469 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11472 * Set up output mixers (0x0c - 0x0e)
11474 /* set vol=0 to output mixers */
11475 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11476 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
11478 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11479 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11481 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
11482 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
11483 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
11484 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11485 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11486 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11487 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11488 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11490 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11491 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11492 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11493 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11494 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11496 /* set PCBEEP vol = 0, mute connections */
11497 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11498 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11499 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11501 /* Unmute Selector 23h,24h and set the default input to mic-in */
11503 {0x23, AC_VERB_SET_CONNECT_SEL, 0x00},
11504 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11505 {0x24, AC_VERB_SET_CONNECT_SEL, 0x00},
11506 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11512 * generic initialization of ADC, input mixers and output mixers
11514 static struct hda_verb alc268_volume_init_verbs[] = {
11515 /* set output DAC */
11516 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11517 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11519 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11520 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11521 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11522 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11523 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11525 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11526 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11527 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11529 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11530 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11532 /* set PCBEEP vol = 0, mute connections */
11533 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11534 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11535 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11540 static struct snd_kcontrol_new alc268_capture_alt_mixer[] = {
11541 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
11542 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
11544 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11545 /* The multiple "Capture Source" controls confuse alsamixer
11546 * So call somewhat different..
11548 /* .name = "Capture Source", */
11549 .name = "Input Source",
11551 .info = alc_mux_enum_info,
11552 .get = alc_mux_enum_get,
11553 .put = alc_mux_enum_put,
11558 static struct snd_kcontrol_new alc268_capture_mixer[] = {
11559 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
11560 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
11561 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x24, 0x0, HDA_OUTPUT),
11562 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x24, 0x0, HDA_OUTPUT),
11564 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11565 /* The multiple "Capture Source" controls confuse alsamixer
11566 * So call somewhat different..
11568 /* .name = "Capture Source", */
11569 .name = "Input Source",
11571 .info = alc_mux_enum_info,
11572 .get = alc_mux_enum_get,
11573 .put = alc_mux_enum_put,
11578 static struct hda_input_mux alc268_capture_source = {
11582 { "Front Mic", 0x1 },
11588 static struct hda_input_mux alc268_acer_capture_source = {
11592 { "Internal Mic", 0x1 },
11597 static struct hda_input_mux alc268_acer_dmic_capture_source = {
11601 { "Internal Mic", 0x6 },
11606 #ifdef CONFIG_SND_DEBUG
11607 static struct snd_kcontrol_new alc268_test_mixer[] = {
11608 /* Volume widgets */
11609 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x02, 0x0, HDA_OUTPUT),
11610 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x03, 0x0, HDA_OUTPUT),
11611 HDA_BIND_MUTE_MONO("Mono sum Playback Switch", 0x0e, 1, 2, HDA_INPUT),
11612 HDA_BIND_MUTE("LINE-OUT sum Playback Switch", 0x0f, 2, HDA_INPUT),
11613 HDA_BIND_MUTE("HP-OUT sum Playback Switch", 0x10, 2, HDA_INPUT),
11614 HDA_BIND_MUTE("LINE-OUT Playback Switch", 0x14, 2, HDA_OUTPUT),
11615 HDA_BIND_MUTE("HP-OUT Playback Switch", 0x15, 2, HDA_OUTPUT),
11616 HDA_BIND_MUTE("Mono Playback Switch", 0x16, 2, HDA_OUTPUT),
11617 HDA_CODEC_VOLUME("MIC1 Capture Volume", 0x18, 0x0, HDA_INPUT),
11618 HDA_BIND_MUTE("MIC1 Capture Switch", 0x18, 2, HDA_OUTPUT),
11619 HDA_CODEC_VOLUME("MIC2 Capture Volume", 0x19, 0x0, HDA_INPUT),
11620 HDA_CODEC_VOLUME("LINE1 Capture Volume", 0x1a, 0x0, HDA_INPUT),
11621 HDA_BIND_MUTE("LINE1 Capture Switch", 0x1a, 2, HDA_OUTPUT),
11622 /* The below appears problematic on some hardwares */
11623 /*HDA_CODEC_VOLUME("PCBEEP Playback Volume", 0x1d, 0x0, HDA_INPUT),*/
11624 HDA_CODEC_VOLUME("PCM-IN1 Capture Volume", 0x23, 0x0, HDA_OUTPUT),
11625 HDA_BIND_MUTE("PCM-IN1 Capture Switch", 0x23, 2, HDA_OUTPUT),
11626 HDA_CODEC_VOLUME("PCM-IN2 Capture Volume", 0x24, 0x0, HDA_OUTPUT),
11627 HDA_BIND_MUTE("PCM-IN2 Capture Switch", 0x24, 2, HDA_OUTPUT),
11629 /* Modes for retasking pin widgets */
11630 ALC_PIN_MODE("LINE-OUT pin mode", 0x14, ALC_PIN_DIR_INOUT),
11631 ALC_PIN_MODE("HP-OUT pin mode", 0x15, ALC_PIN_DIR_INOUT),
11632 ALC_PIN_MODE("MIC1 pin mode", 0x18, ALC_PIN_DIR_INOUT),
11633 ALC_PIN_MODE("LINE1 pin mode", 0x1a, ALC_PIN_DIR_INOUT),
11635 /* Controls for GPIO pins, assuming they are configured as outputs */
11636 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
11637 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
11638 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
11639 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
11641 /* Switches to allow the digital SPDIF output pin to be enabled.
11642 * The ALC268 does not have an SPDIF input.
11644 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x06, 0x01),
11646 /* A switch allowing EAPD to be enabled. Some laptops seem to use
11647 * this output to turn on an external amplifier.
11649 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
11650 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
11656 /* create input playback/capture controls for the given pin */
11657 static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
11658 const char *ctlname, int idx)
11663 sprintf(name, "%s Playback Volume", ctlname);
11665 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
11666 HDA_COMPOSE_AMP_VAL(0x02, 3, idx,
11670 } else if (nid == 0x15) {
11671 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
11672 HDA_COMPOSE_AMP_VAL(0x03, 3, idx,
11678 sprintf(name, "%s Playback Switch", ctlname);
11679 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
11680 HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
11686 /* add playback controls from the parsed DAC table */
11687 static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec,
11688 const struct auto_pin_cfg *cfg)
11693 spec->multiout.num_dacs = 2; /* only use one dac */
11694 spec->multiout.dac_nids = spec->private_dac_nids;
11695 spec->multiout.dac_nids[0] = 2;
11696 spec->multiout.dac_nids[1] = 3;
11698 nid = cfg->line_out_pins[0];
11700 alc268_new_analog_output(spec, nid, "Front", 0);
11702 nid = cfg->speaker_pins[0];
11704 err = add_control(spec, ALC_CTL_WIDGET_VOL,
11705 "Speaker Playback Volume",
11706 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
11710 nid = cfg->hp_pins[0];
11712 alc268_new_analog_output(spec, nid, "Headphone", 0);
11714 nid = cfg->line_out_pins[1] | cfg->line_out_pins[2];
11716 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
11717 "Mono Playback Switch",
11718 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_INPUT));
11725 /* create playback/capture controls for input pins */
11726 static int alc268_auto_create_analog_input_ctls(struct alc_spec *spec,
11727 const struct auto_pin_cfg *cfg)
11729 struct hda_input_mux *imux = &spec->private_imux[0];
11732 for (i = 0; i < AUTO_PIN_LAST; i++) {
11733 switch(cfg->input_pins[i]) {
11735 idx1 = 0; /* Mic 1 */
11738 idx1 = 1; /* Mic 2 */
11741 idx1 = 2; /* Line In */
11748 idx1 = 6; /* digital mics */
11753 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
11754 imux->items[imux->num_items].index = idx1;
11760 static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec)
11762 struct alc_spec *spec = codec->spec;
11763 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
11764 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
11765 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
11766 unsigned int dac_vol1, dac_vol2;
11769 snd_hda_codec_write(codec, speaker_nid, 0,
11770 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
11771 snd_hda_codec_write(codec, 0x0f, 0,
11772 AC_VERB_SET_AMP_GAIN_MUTE,
11774 snd_hda_codec_write(codec, 0x10, 0,
11775 AC_VERB_SET_AMP_GAIN_MUTE,
11778 snd_hda_codec_write(codec, 0x0f, 0,
11779 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
11780 snd_hda_codec_write(codec, 0x10, 0,
11781 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
11784 dac_vol1 = dac_vol2 = 0xb000 | 0x40; /* set max volume */
11785 if (line_nid == 0x14)
11786 dac_vol2 = AMP_OUT_ZERO;
11787 else if (line_nid == 0x15)
11788 dac_vol1 = AMP_OUT_ZERO;
11789 if (hp_nid == 0x14)
11790 dac_vol2 = AMP_OUT_ZERO;
11791 else if (hp_nid == 0x15)
11792 dac_vol1 = AMP_OUT_ZERO;
11793 if (line_nid != 0x16 || hp_nid != 0x16 ||
11794 spec->autocfg.line_out_pins[1] != 0x16 ||
11795 spec->autocfg.line_out_pins[2] != 0x16)
11796 dac_vol1 = dac_vol2 = AMP_OUT_ZERO;
11798 snd_hda_codec_write(codec, 0x02, 0,
11799 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol1);
11800 snd_hda_codec_write(codec, 0x03, 0,
11801 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol2);
11804 /* pcm configuration: identiacal with ALC880 */
11805 #define alc268_pcm_analog_playback alc880_pcm_analog_playback
11806 #define alc268_pcm_analog_capture alc880_pcm_analog_capture
11807 #define alc268_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
11808 #define alc268_pcm_digital_playback alc880_pcm_digital_playback
11811 * BIOS auto configuration
11813 static int alc268_parse_auto_config(struct hda_codec *codec)
11815 struct alc_spec *spec = codec->spec;
11817 static hda_nid_t alc268_ignore[] = { 0 };
11819 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
11823 if (!spec->autocfg.line_outs)
11824 return 0; /* can't find valid BIOS pin config */
11826 err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg);
11829 err = alc268_auto_create_analog_input_ctls(spec, &spec->autocfg);
11833 spec->multiout.max_channels = 2;
11835 /* digital only support output */
11836 if (spec->autocfg.dig_outs)
11837 spec->multiout.dig_out_nid = ALC268_DIGOUT_NID;
11839 if (spec->kctls.list)
11840 add_mixer(spec, spec->kctls.list);
11842 if (spec->autocfg.speaker_pins[0] != 0x1d)
11843 add_mixer(spec, alc268_beep_mixer);
11845 add_verb(spec, alc268_volume_init_verbs);
11846 spec->num_mux_defs = 1;
11847 spec->input_mux = &spec->private_imux[0];
11849 err = alc_auto_add_mic_boost(codec);
11853 store_pin_configs(codec);
11857 #define alc268_auto_init_multi_out alc882_auto_init_multi_out
11858 #define alc268_auto_init_hp_out alc882_auto_init_hp_out
11859 #define alc268_auto_init_analog_input alc882_auto_init_analog_input
11861 /* init callback for auto-configuration model -- overriding the default init */
11862 static void alc268_auto_init(struct hda_codec *codec)
11864 struct alc_spec *spec = codec->spec;
11865 alc268_auto_init_multi_out(codec);
11866 alc268_auto_init_hp_out(codec);
11867 alc268_auto_init_mono_speaker_out(codec);
11868 alc268_auto_init_analog_input(codec);
11869 if (spec->unsol_event)
11870 alc_inithook(codec);
11874 * configuration and preset
11876 static const char *alc268_models[ALC268_MODEL_LAST] = {
11877 [ALC267_QUANTA_IL1] = "quanta-il1",
11878 [ALC268_3ST] = "3stack",
11879 [ALC268_TOSHIBA] = "toshiba",
11880 [ALC268_ACER] = "acer",
11881 [ALC268_ACER_DMIC] = "acer-dmic",
11882 [ALC268_ACER_ASPIRE_ONE] = "acer-aspire",
11883 [ALC268_DELL] = "dell",
11884 [ALC268_ZEPTO] = "zepto",
11885 #ifdef CONFIG_SND_DEBUG
11886 [ALC268_TEST] = "test",
11888 [ALC268_AUTO] = "auto",
11891 static struct snd_pci_quirk alc268_cfg_tbl[] = {
11892 SND_PCI_QUIRK(0x1025, 0x011e, "Acer Aspire 5720z", ALC268_ACER),
11893 SND_PCI_QUIRK(0x1025, 0x0126, "Acer", ALC268_ACER),
11894 SND_PCI_QUIRK(0x1025, 0x012e, "Acer Aspire 5310", ALC268_ACER),
11895 SND_PCI_QUIRK(0x1025, 0x0130, "Acer Extensa 5210", ALC268_ACER),
11896 SND_PCI_QUIRK(0x1025, 0x0136, "Acer Aspire 5315", ALC268_ACER),
11897 SND_PCI_QUIRK(0x1025, 0x015b, "Acer Aspire One",
11898 ALC268_ACER_ASPIRE_ONE),
11899 SND_PCI_QUIRK(0x1028, 0x0253, "Dell OEM", ALC268_DELL),
11900 SND_PCI_QUIRK(0x1028, 0x02b0, "Dell Inspiron Mini9", ALC268_DELL),
11901 SND_PCI_QUIRK(0x103c, 0x30cc, "TOSHIBA", ALC268_TOSHIBA),
11902 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST),
11903 SND_PCI_QUIRK(0x1179, 0xff10, "TOSHIBA A205", ALC268_TOSHIBA),
11904 SND_PCI_QUIRK(0x1179, 0xff50, "TOSHIBA A305", ALC268_TOSHIBA),
11905 SND_PCI_QUIRK(0x1179, 0xff64, "TOSHIBA L305", ALC268_TOSHIBA),
11906 SND_PCI_QUIRK(0x14c0, 0x0025, "COMPAL IFL90/JFL-92", ALC268_TOSHIBA),
11907 SND_PCI_QUIRK(0x152d, 0x0763, "Diverse (CPR2000)", ALC268_ACER),
11908 SND_PCI_QUIRK(0x152d, 0x0771, "Quanta IL1", ALC267_QUANTA_IL1),
11909 SND_PCI_QUIRK(0x1170, 0x0040, "ZEPTO", ALC268_ZEPTO),
11913 static struct alc_config_preset alc268_presets[] = {
11914 [ALC267_QUANTA_IL1] = {
11915 .mixers = { alc267_quanta_il1_mixer, alc268_beep_mixer },
11916 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
11917 alc267_quanta_il1_verbs },
11918 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
11919 .dac_nids = alc268_dac_nids,
11920 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
11921 .adc_nids = alc268_adc_nids_alt,
11923 .num_channel_mode = ARRAY_SIZE(alc268_modes),
11924 .channel_mode = alc268_modes,
11925 .input_mux = &alc268_capture_source,
11926 .unsol_event = alc267_quanta_il1_unsol_event,
11927 .init_hook = alc267_quanta_il1_automute,
11930 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
11931 alc268_beep_mixer },
11932 .init_verbs = { alc268_base_init_verbs },
11933 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
11934 .dac_nids = alc268_dac_nids,
11935 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
11936 .adc_nids = alc268_adc_nids_alt,
11937 .capsrc_nids = alc268_capsrc_nids,
11939 .dig_out_nid = ALC268_DIGOUT_NID,
11940 .num_channel_mode = ARRAY_SIZE(alc268_modes),
11941 .channel_mode = alc268_modes,
11942 .input_mux = &alc268_capture_source,
11944 [ALC268_TOSHIBA] = {
11945 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
11946 alc268_beep_mixer },
11947 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
11948 alc268_toshiba_verbs },
11949 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
11950 .dac_nids = alc268_dac_nids,
11951 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
11952 .adc_nids = alc268_adc_nids_alt,
11953 .capsrc_nids = alc268_capsrc_nids,
11955 .num_channel_mode = ARRAY_SIZE(alc268_modes),
11956 .channel_mode = alc268_modes,
11957 .input_mux = &alc268_capture_source,
11958 .unsol_event = alc268_toshiba_unsol_event,
11959 .init_hook = alc268_toshiba_automute,
11962 .mixers = { alc268_acer_mixer, alc268_capture_alt_mixer,
11963 alc268_beep_mixer },
11964 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
11965 alc268_acer_verbs },
11966 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
11967 .dac_nids = alc268_dac_nids,
11968 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
11969 .adc_nids = alc268_adc_nids_alt,
11970 .capsrc_nids = alc268_capsrc_nids,
11972 .num_channel_mode = ARRAY_SIZE(alc268_modes),
11973 .channel_mode = alc268_modes,
11974 .input_mux = &alc268_acer_capture_source,
11975 .unsol_event = alc268_acer_unsol_event,
11976 .init_hook = alc268_acer_init_hook,
11978 [ALC268_ACER_DMIC] = {
11979 .mixers = { alc268_acer_dmic_mixer, alc268_capture_alt_mixer,
11980 alc268_beep_mixer },
11981 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
11982 alc268_acer_verbs },
11983 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
11984 .dac_nids = alc268_dac_nids,
11985 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
11986 .adc_nids = alc268_adc_nids_alt,
11987 .capsrc_nids = alc268_capsrc_nids,
11989 .num_channel_mode = ARRAY_SIZE(alc268_modes),
11990 .channel_mode = alc268_modes,
11991 .input_mux = &alc268_acer_dmic_capture_source,
11992 .unsol_event = alc268_acer_unsol_event,
11993 .init_hook = alc268_acer_init_hook,
11995 [ALC268_ACER_ASPIRE_ONE] = {
11996 .mixers = { alc268_acer_aspire_one_mixer,
11998 alc268_capture_alt_mixer },
11999 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12000 alc268_acer_aspire_one_verbs },
12001 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12002 .dac_nids = alc268_dac_nids,
12003 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12004 .adc_nids = alc268_adc_nids_alt,
12005 .capsrc_nids = alc268_capsrc_nids,
12007 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12008 .channel_mode = alc268_modes,
12009 .input_mux = &alc268_acer_lc_capture_source,
12010 .unsol_event = alc268_acer_lc_unsol_event,
12011 .init_hook = alc268_acer_lc_init_hook,
12014 .mixers = { alc268_dell_mixer, alc268_beep_mixer },
12015 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12016 alc268_dell_verbs },
12017 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12018 .dac_nids = alc268_dac_nids,
12020 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12021 .channel_mode = alc268_modes,
12022 .unsol_event = alc268_dell_unsol_event,
12023 .init_hook = alc268_dell_init_hook,
12024 .input_mux = &alc268_capture_source,
12027 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
12028 alc268_beep_mixer },
12029 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12030 alc268_toshiba_verbs },
12031 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12032 .dac_nids = alc268_dac_nids,
12033 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12034 .adc_nids = alc268_adc_nids_alt,
12035 .capsrc_nids = alc268_capsrc_nids,
12037 .dig_out_nid = ALC268_DIGOUT_NID,
12038 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12039 .channel_mode = alc268_modes,
12040 .input_mux = &alc268_capture_source,
12041 .unsol_event = alc268_toshiba_unsol_event,
12042 .init_hook = alc268_toshiba_automute
12044 #ifdef CONFIG_SND_DEBUG
12046 .mixers = { alc268_test_mixer, alc268_capture_mixer },
12047 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12048 alc268_volume_init_verbs },
12049 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12050 .dac_nids = alc268_dac_nids,
12051 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12052 .adc_nids = alc268_adc_nids_alt,
12053 .capsrc_nids = alc268_capsrc_nids,
12055 .dig_out_nid = ALC268_DIGOUT_NID,
12056 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12057 .channel_mode = alc268_modes,
12058 .input_mux = &alc268_capture_source,
12063 static int patch_alc268(struct hda_codec *codec)
12065 struct alc_spec *spec;
12067 int i, has_beep, err;
12069 spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
12073 codec->spec = spec;
12075 board_config = snd_hda_check_board_config(codec, ALC268_MODEL_LAST,
12079 if (board_config < 0 || board_config >= ALC268_MODEL_LAST) {
12080 printk(KERN_INFO "hda_codec: Unknown model for ALC268, "
12081 "trying auto-probe from BIOS...\n");
12082 board_config = ALC268_AUTO;
12085 if (board_config == ALC268_AUTO) {
12086 /* automatic parse from the BIOS config */
12087 err = alc268_parse_auto_config(codec);
12093 "hda_codec: Cannot set up configuration "
12094 "from BIOS. Using base mode...\n");
12095 board_config = ALC268_3ST;
12099 err = snd_hda_attach_beep_device(codec, 0x1);
12105 if (board_config != ALC268_AUTO)
12106 setup_preset(spec, &alc268_presets[board_config]);
12108 if (codec->vendor_id == 0x10ec0267) {
12109 spec->stream_name_analog = "ALC267 Analog";
12110 spec->stream_name_digital = "ALC267 Digital";
12112 spec->stream_name_analog = "ALC268 Analog";
12113 spec->stream_name_digital = "ALC268 Digital";
12116 spec->stream_analog_playback = &alc268_pcm_analog_playback;
12117 spec->stream_analog_capture = &alc268_pcm_analog_capture;
12118 spec->stream_analog_alt_capture = &alc268_pcm_analog_alt_capture;
12120 spec->stream_digital_playback = &alc268_pcm_digital_playback;
12123 for (i = 0; i < spec->num_mixers; i++) {
12124 if (spec->mixers[i] == alc268_beep_mixer) {
12131 err = snd_hda_attach_beep_device(codec, 0x1);
12136 if (!query_amp_caps(codec, 0x1d, HDA_INPUT))
12137 /* override the amp caps for beep generator */
12138 snd_hda_override_amp_caps(codec, 0x1d, HDA_INPUT,
12139 (0x0c << AC_AMPCAP_OFFSET_SHIFT) |
12140 (0x0c << AC_AMPCAP_NUM_STEPS_SHIFT) |
12141 (0x07 << AC_AMPCAP_STEP_SIZE_SHIFT) |
12142 (0 << AC_AMPCAP_MUTE_SHIFT));
12145 if (!spec->adc_nids && spec->input_mux) {
12146 /* check whether NID 0x07 is valid */
12147 unsigned int wcap = get_wcaps(codec, 0x07);
12151 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
12152 if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
12153 spec->adc_nids = alc268_adc_nids_alt;
12154 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt);
12155 add_mixer(spec, alc268_capture_alt_mixer);
12157 spec->adc_nids = alc268_adc_nids;
12158 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids);
12159 add_mixer(spec, alc268_capture_mixer);
12161 spec->capsrc_nids = alc268_capsrc_nids;
12162 /* set default input source */
12163 for (i = 0; i < spec->num_adc_nids; i++)
12164 snd_hda_codec_write_cache(codec, alc268_capsrc_nids[i],
12165 0, AC_VERB_SET_CONNECT_SEL,
12166 spec->input_mux->items[0].index);
12169 spec->vmaster_nid = 0x02;
12171 codec->patch_ops = alc_patch_ops;
12172 if (board_config == ALC268_AUTO)
12173 spec->init_hook = alc268_auto_init;
12175 codec->proc_widget_hook = print_realtek_coef;
12181 * ALC269 channel source setting (2 channel)
12183 #define ALC269_DIGOUT_NID ALC880_DIGOUT_NID
12185 #define alc269_dac_nids alc260_dac_nids
12187 static hda_nid_t alc269_adc_nids[1] = {
12192 static hda_nid_t alc269_capsrc_nids[1] = {
12196 /* NOTE: ADC2 (0x07) is connected from a recording *MIXER* (0x24),
12200 static struct hda_input_mux alc269_eeepc_dmic_capture_source = {
12208 static struct hda_input_mux alc269_eeepc_amic_capture_source = {
12216 #define alc269_modes alc260_modes
12217 #define alc269_capture_source alc880_lg_lw_capture_source
12219 static struct snd_kcontrol_new alc269_base_mixer[] = {
12220 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12221 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12222 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
12223 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
12224 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12225 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12226 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12227 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
12228 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
12229 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
12230 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
12231 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
12235 static struct snd_kcontrol_new alc269_quanta_fl1_mixer[] = {
12236 /* output mixer control */
12237 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
12239 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12240 .name = "Master Playback Switch",
12241 .info = snd_hda_mixer_amp_switch_info,
12242 .get = snd_hda_mixer_amp_switch_get,
12243 .put = alc268_acer_master_sw_put,
12244 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
12246 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12247 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12248 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12249 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
12250 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
12251 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
12255 static struct snd_kcontrol_new alc269_lifebook_mixer[] = {
12256 /* output mixer control */
12257 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
12259 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12260 .name = "Master Playback Switch",
12261 .info = snd_hda_mixer_amp_switch_info,
12262 .get = snd_hda_mixer_amp_switch_get,
12263 .put = alc268_acer_master_sw_put,
12264 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
12266 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12267 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12268 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12269 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
12270 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
12271 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
12272 HDA_CODEC_VOLUME("Dock Mic Playback Volume", 0x0b, 0x03, HDA_INPUT),
12273 HDA_CODEC_MUTE("Dock Mic Playback Switch", 0x0b, 0x03, HDA_INPUT),
12274 HDA_CODEC_VOLUME("Dock Mic Boost", 0x1b, 0, HDA_INPUT),
12278 /* bind volumes of both NID 0x0c and 0x0d */
12279 static struct hda_bind_ctls alc269_epc_bind_vol = {
12280 .ops = &snd_hda_bind_vol,
12282 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
12283 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
12288 static struct snd_kcontrol_new alc269_eeepc_mixer[] = {
12289 HDA_CODEC_MUTE("iSpeaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12290 HDA_BIND_VOL("LineOut Playback Volume", &alc269_epc_bind_vol),
12291 HDA_CODEC_MUTE("LineOut Playback Switch", 0x15, 0x0, HDA_OUTPUT),
12295 /* capture mixer elements */
12296 static struct snd_kcontrol_new alc269_epc_capture_mixer[] = {
12297 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
12298 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
12299 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12304 static struct snd_kcontrol_new alc269_fujitsu_mixer[] = {
12305 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12306 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
12307 HDA_BIND_VOL("PCM Playback Volume", &alc269_epc_bind_vol),
12311 static struct hda_verb alc269_quanta_fl1_verbs[] = {
12312 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12313 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12314 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12315 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12316 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12317 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12321 static struct hda_verb alc269_lifebook_verbs[] = {
12322 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12323 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
12324 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12325 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12326 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12327 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12328 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12329 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12330 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12331 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12335 /* toggle speaker-output according to the hp-jack state */
12336 static void alc269_quanta_fl1_speaker_automute(struct hda_codec *codec)
12338 unsigned int present;
12339 unsigned char bits;
12341 present = snd_hda_codec_read(codec, 0x15, 0,
12342 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12343 bits = present ? AMP_IN_MUTE(0) : 0;
12344 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
12345 AMP_IN_MUTE(0), bits);
12346 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
12347 AMP_IN_MUTE(0), bits);
12349 snd_hda_codec_write(codec, 0x20, 0,
12350 AC_VERB_SET_COEF_INDEX, 0x0c);
12351 snd_hda_codec_write(codec, 0x20, 0,
12352 AC_VERB_SET_PROC_COEF, 0x680);
12354 snd_hda_codec_write(codec, 0x20, 0,
12355 AC_VERB_SET_COEF_INDEX, 0x0c);
12356 snd_hda_codec_write(codec, 0x20, 0,
12357 AC_VERB_SET_PROC_COEF, 0x480);
12360 /* toggle speaker-output according to the hp-jacks state */
12361 static void alc269_lifebook_speaker_automute(struct hda_codec *codec)
12363 unsigned int present;
12364 unsigned char bits;
12366 /* Check laptop headphone socket */
12367 present = snd_hda_codec_read(codec, 0x15, 0,
12368 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12370 /* Check port replicator headphone socket */
12371 present |= snd_hda_codec_read(codec, 0x1a, 0,
12372 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12374 bits = present ? AMP_IN_MUTE(0) : 0;
12375 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
12376 AMP_IN_MUTE(0), bits);
12377 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
12378 AMP_IN_MUTE(0), bits);
12380 snd_hda_codec_write(codec, 0x20, 0,
12381 AC_VERB_SET_COEF_INDEX, 0x0c);
12382 snd_hda_codec_write(codec, 0x20, 0,
12383 AC_VERB_SET_PROC_COEF, 0x680);
12385 snd_hda_codec_write(codec, 0x20, 0,
12386 AC_VERB_SET_COEF_INDEX, 0x0c);
12387 snd_hda_codec_write(codec, 0x20, 0,
12388 AC_VERB_SET_PROC_COEF, 0x480);
12391 static void alc269_quanta_fl1_mic_automute(struct hda_codec *codec)
12393 unsigned int present;
12395 present = snd_hda_codec_read(codec, 0x18, 0,
12396 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12397 snd_hda_codec_write(codec, 0x23, 0,
12398 AC_VERB_SET_CONNECT_SEL, present ? 0x0 : 0x1);
12401 static void alc269_lifebook_mic_autoswitch(struct hda_codec *codec)
12403 unsigned int present_laptop;
12404 unsigned int present_dock;
12406 present_laptop = snd_hda_codec_read(codec, 0x18, 0,
12407 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12409 present_dock = snd_hda_codec_read(codec, 0x1b, 0,
12410 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12412 /* Laptop mic port overrides dock mic port, design decision */
12414 snd_hda_codec_write(codec, 0x23, 0,
12415 AC_VERB_SET_CONNECT_SEL, 0x3);
12416 if (present_laptop)
12417 snd_hda_codec_write(codec, 0x23, 0,
12418 AC_VERB_SET_CONNECT_SEL, 0x0);
12419 if (!present_dock && !present_laptop)
12420 snd_hda_codec_write(codec, 0x23, 0,
12421 AC_VERB_SET_CONNECT_SEL, 0x1);
12424 static void alc269_quanta_fl1_unsol_event(struct hda_codec *codec,
12427 if ((res >> 26) == ALC880_HP_EVENT)
12428 alc269_quanta_fl1_speaker_automute(codec);
12429 if ((res >> 26) == ALC880_MIC_EVENT)
12430 alc269_quanta_fl1_mic_automute(codec);
12433 static void alc269_lifebook_unsol_event(struct hda_codec *codec,
12436 if ((res >> 26) == ALC880_HP_EVENT)
12437 alc269_lifebook_speaker_automute(codec);
12438 if ((res >> 26) == ALC880_MIC_EVENT)
12439 alc269_lifebook_mic_autoswitch(codec);
12442 static void alc269_quanta_fl1_init_hook(struct hda_codec *codec)
12444 alc269_quanta_fl1_speaker_automute(codec);
12445 alc269_quanta_fl1_mic_automute(codec);
12448 static void alc269_lifebook_init_hook(struct hda_codec *codec)
12450 alc269_lifebook_speaker_automute(codec);
12451 alc269_lifebook_mic_autoswitch(codec);
12454 static struct hda_verb alc269_eeepc_dmic_init_verbs[] = {
12455 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12456 {0x23, AC_VERB_SET_CONNECT_SEL, 0x05},
12457 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
12458 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))},
12459 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12460 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12461 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
12465 static struct hda_verb alc269_eeepc_amic_init_verbs[] = {
12466 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12467 {0x23, AC_VERB_SET_CONNECT_SEL, 0x01},
12468 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
12469 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x701b | (0x00 << 8))},
12470 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12471 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
12475 /* toggle speaker-output according to the hp-jack state */
12476 static void alc269_speaker_automute(struct hda_codec *codec)
12478 unsigned int present;
12479 unsigned char bits;
12481 present = snd_hda_codec_read(codec, 0x15, 0,
12482 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12483 bits = present ? AMP_IN_MUTE(0) : 0;
12484 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
12485 AMP_IN_MUTE(0), bits);
12486 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
12487 AMP_IN_MUTE(0), bits);
12490 static void alc269_eeepc_dmic_automute(struct hda_codec *codec)
12492 unsigned int present;
12494 present = snd_hda_codec_read(codec, 0x18, 0,
12495 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12496 snd_hda_codec_write(codec, 0x23, 0,
12497 AC_VERB_SET_CONNECT_SEL, (present ? 0 : 5));
12500 static void alc269_eeepc_amic_automute(struct hda_codec *codec)
12502 unsigned int present;
12504 present = snd_hda_codec_read(codec, 0x18, 0,
12505 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12506 snd_hda_codec_write(codec, 0x24, 0, AC_VERB_SET_AMP_GAIN_MUTE,
12507 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
12508 snd_hda_codec_write(codec, 0x24, 0, AC_VERB_SET_AMP_GAIN_MUTE,
12509 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
12512 /* unsolicited event for HP jack sensing */
12513 static void alc269_eeepc_dmic_unsol_event(struct hda_codec *codec,
12516 if ((res >> 26) == ALC880_HP_EVENT)
12517 alc269_speaker_automute(codec);
12519 if ((res >> 26) == ALC880_MIC_EVENT)
12520 alc269_eeepc_dmic_automute(codec);
12523 static void alc269_eeepc_dmic_inithook(struct hda_codec *codec)
12525 alc269_speaker_automute(codec);
12526 alc269_eeepc_dmic_automute(codec);
12529 /* unsolicited event for HP jack sensing */
12530 static void alc269_eeepc_amic_unsol_event(struct hda_codec *codec,
12533 if ((res >> 26) == ALC880_HP_EVENT)
12534 alc269_speaker_automute(codec);
12536 if ((res >> 26) == ALC880_MIC_EVENT)
12537 alc269_eeepc_amic_automute(codec);
12540 static void alc269_eeepc_amic_inithook(struct hda_codec *codec)
12542 alc269_speaker_automute(codec);
12543 alc269_eeepc_amic_automute(codec);
12547 * generic initialization of ADC, input mixers and output mixers
12549 static struct hda_verb alc269_init_verbs[] = {
12551 * Unmute ADC0 and set the default input to mic-in
12553 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12555 /* Mute input amps (PCBeep, Line In, Mic 1 & Mic 2) of the
12556 * analog-loopback mixer widget
12557 * Note: PASD motherboards uses the Line In 2 as the input for
12558 * front panel mic (mic 2)
12560 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
12561 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12562 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12563 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
12564 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
12565 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
12568 * Set up output mixers (0x0c - 0x0e)
12570 /* set vol=0 to output mixers */
12571 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12572 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12574 /* set up input amps for analog loopback */
12575 /* Amp Indices: DAC = 0, mixer = 1 */
12576 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12577 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12578 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12579 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12580 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12581 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12583 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12584 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12585 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12586 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
12587 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
12588 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12589 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12591 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12592 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12593 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12594 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12595 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12596 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12597 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12599 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
12600 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
12602 /* FIXME: use matrix-type input source selection */
12603 /* Mixer elements: 0x18, 19, 1a, 1b, 1d, 0b */
12604 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
12605 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12606 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12607 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
12608 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
12611 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
12612 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
12616 /* add playback controls from the parsed DAC table */
12617 static int alc269_auto_create_multi_out_ctls(struct alc_spec *spec,
12618 const struct auto_pin_cfg *cfg)
12623 spec->multiout.num_dacs = 1; /* only use one dac */
12624 spec->multiout.dac_nids = spec->private_dac_nids;
12625 spec->multiout.dac_nids[0] = 2;
12627 nid = cfg->line_out_pins[0];
12629 err = add_control(spec, ALC_CTL_WIDGET_VOL,
12630 "Front Playback Volume",
12631 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT));
12634 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
12635 "Front Playback Switch",
12636 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
12641 nid = cfg->speaker_pins[0];
12643 if (!cfg->line_out_pins[0]) {
12644 err = add_control(spec, ALC_CTL_WIDGET_VOL,
12645 "Speaker Playback Volume",
12646 HDA_COMPOSE_AMP_VAL(0x02, 3, 0,
12652 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
12653 "Speaker Playback Switch",
12654 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
12659 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
12660 "Speaker Playback Switch",
12661 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
12667 nid = cfg->hp_pins[0];
12669 /* spec->multiout.hp_nid = 2; */
12670 if (!cfg->line_out_pins[0] && !cfg->speaker_pins[0]) {
12671 err = add_control(spec, ALC_CTL_WIDGET_VOL,
12672 "Headphone Playback Volume",
12673 HDA_COMPOSE_AMP_VAL(0x02, 3, 0,
12679 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
12680 "Headphone Playback Switch",
12681 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
12686 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
12687 "Headphone Playback Switch",
12688 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
12697 static int alc269_auto_create_analog_input_ctls(struct alc_spec *spec,
12698 const struct auto_pin_cfg *cfg)
12702 err = alc880_auto_create_analog_input_ctls(spec, cfg);
12705 /* digital-mic input pin is excluded in alc880_auto_create..()
12706 * because it's under 0x18
12708 if (cfg->input_pins[AUTO_PIN_MIC] == 0x12 ||
12709 cfg->input_pins[AUTO_PIN_FRONT_MIC] == 0x12) {
12710 struct hda_input_mux *imux = &spec->private_imux[0];
12711 imux->items[imux->num_items].label = "Int Mic";
12712 imux->items[imux->num_items].index = 0x05;
12718 #ifdef CONFIG_SND_HDA_POWER_SAVE
12719 #define alc269_loopbacks alc880_loopbacks
12722 /* pcm configuration: identiacal with ALC880 */
12723 #define alc269_pcm_analog_playback alc880_pcm_analog_playback
12724 #define alc269_pcm_analog_capture alc880_pcm_analog_capture
12725 #define alc269_pcm_digital_playback alc880_pcm_digital_playback
12726 #define alc269_pcm_digital_capture alc880_pcm_digital_capture
12729 * BIOS auto configuration
12731 static int alc269_parse_auto_config(struct hda_codec *codec)
12733 struct alc_spec *spec = codec->spec;
12735 static hda_nid_t alc269_ignore[] = { 0x1d, 0 };
12737 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
12742 err = alc269_auto_create_multi_out_ctls(spec, &spec->autocfg);
12745 err = alc269_auto_create_analog_input_ctls(spec, &spec->autocfg);
12749 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
12751 if (spec->autocfg.dig_outs)
12752 spec->multiout.dig_out_nid = ALC269_DIGOUT_NID;
12754 if (spec->kctls.list)
12755 add_mixer(spec, spec->kctls.list);
12757 add_verb(spec, alc269_init_verbs);
12758 spec->num_mux_defs = 1;
12759 spec->input_mux = &spec->private_imux[0];
12760 /* set default input source */
12761 snd_hda_codec_write_cache(codec, alc269_capsrc_nids[0],
12762 0, AC_VERB_SET_CONNECT_SEL,
12763 spec->input_mux->items[0].index);
12765 err = alc_auto_add_mic_boost(codec);
12769 if (!spec->cap_mixer)
12770 set_capture_mixer(spec);
12772 store_pin_configs(codec);
12776 #define alc269_auto_init_multi_out alc882_auto_init_multi_out
12777 #define alc269_auto_init_hp_out alc882_auto_init_hp_out
12778 #define alc269_auto_init_analog_input alc882_auto_init_analog_input
12781 /* init callback for auto-configuration model -- overriding the default init */
12782 static void alc269_auto_init(struct hda_codec *codec)
12784 struct alc_spec *spec = codec->spec;
12785 alc269_auto_init_multi_out(codec);
12786 alc269_auto_init_hp_out(codec);
12787 alc269_auto_init_analog_input(codec);
12788 if (spec->unsol_event)
12789 alc_inithook(codec);
12793 * configuration and preset
12795 static const char *alc269_models[ALC269_MODEL_LAST] = {
12796 [ALC269_BASIC] = "basic",
12797 [ALC269_QUANTA_FL1] = "quanta",
12798 [ALC269_ASUS_EEEPC_P703] = "eeepc-p703",
12799 [ALC269_ASUS_EEEPC_P901] = "eeepc-p901",
12800 [ALC269_FUJITSU] = "fujitsu",
12801 [ALC269_LIFEBOOK] = "lifebook"
12804 static struct snd_pci_quirk alc269_cfg_tbl[] = {
12805 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_QUANTA_FL1),
12806 SND_PCI_QUIRK(0x1043, 0x8330, "ASUS Eeepc P703 P900A",
12807 ALC269_ASUS_EEEPC_P703),
12808 SND_PCI_QUIRK(0x1043, 0x831a, "ASUS Eeepc P901",
12809 ALC269_ASUS_EEEPC_P901),
12810 SND_PCI_QUIRK(0x1043, 0x834a, "ASUS Eeepc S101",
12811 ALC269_ASUS_EEEPC_P901),
12812 SND_PCI_QUIRK(0x1734, 0x115d, "FSC Amilo", ALC269_FUJITSU),
12813 SND_PCI_QUIRK(0x10cf, 0x1475, "Lifebook ICH9M-based", ALC269_LIFEBOOK),
12817 static struct alc_config_preset alc269_presets[] = {
12819 .mixers = { alc269_base_mixer },
12820 .init_verbs = { alc269_init_verbs },
12821 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
12822 .dac_nids = alc269_dac_nids,
12824 .num_channel_mode = ARRAY_SIZE(alc269_modes),
12825 .channel_mode = alc269_modes,
12826 .input_mux = &alc269_capture_source,
12828 [ALC269_QUANTA_FL1] = {
12829 .mixers = { alc269_quanta_fl1_mixer },
12830 .init_verbs = { alc269_init_verbs, alc269_quanta_fl1_verbs },
12831 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
12832 .dac_nids = alc269_dac_nids,
12834 .num_channel_mode = ARRAY_SIZE(alc269_modes),
12835 .channel_mode = alc269_modes,
12836 .input_mux = &alc269_capture_source,
12837 .unsol_event = alc269_quanta_fl1_unsol_event,
12838 .init_hook = alc269_quanta_fl1_init_hook,
12840 [ALC269_ASUS_EEEPC_P703] = {
12841 .mixers = { alc269_eeepc_mixer },
12842 .cap_mixer = alc269_epc_capture_mixer,
12843 .init_verbs = { alc269_init_verbs,
12844 alc269_eeepc_amic_init_verbs },
12845 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
12846 .dac_nids = alc269_dac_nids,
12848 .num_channel_mode = ARRAY_SIZE(alc269_modes),
12849 .channel_mode = alc269_modes,
12850 .input_mux = &alc269_eeepc_amic_capture_source,
12851 .unsol_event = alc269_eeepc_amic_unsol_event,
12852 .init_hook = alc269_eeepc_amic_inithook,
12854 [ALC269_ASUS_EEEPC_P901] = {
12855 .mixers = { alc269_eeepc_mixer },
12856 .cap_mixer = alc269_epc_capture_mixer,
12857 .init_verbs = { alc269_init_verbs,
12858 alc269_eeepc_dmic_init_verbs },
12859 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
12860 .dac_nids = alc269_dac_nids,
12862 .num_channel_mode = ARRAY_SIZE(alc269_modes),
12863 .channel_mode = alc269_modes,
12864 .input_mux = &alc269_eeepc_dmic_capture_source,
12865 .unsol_event = alc269_eeepc_dmic_unsol_event,
12866 .init_hook = alc269_eeepc_dmic_inithook,
12868 [ALC269_FUJITSU] = {
12869 .mixers = { alc269_fujitsu_mixer },
12870 .cap_mixer = alc269_epc_capture_mixer,
12871 .init_verbs = { alc269_init_verbs,
12872 alc269_eeepc_dmic_init_verbs },
12873 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
12874 .dac_nids = alc269_dac_nids,
12876 .num_channel_mode = ARRAY_SIZE(alc269_modes),
12877 .channel_mode = alc269_modes,
12878 .input_mux = &alc269_eeepc_dmic_capture_source,
12879 .unsol_event = alc269_eeepc_dmic_unsol_event,
12880 .init_hook = alc269_eeepc_dmic_inithook,
12882 [ALC269_LIFEBOOK] = {
12883 .mixers = { alc269_lifebook_mixer },
12884 .init_verbs = { alc269_init_verbs, alc269_lifebook_verbs },
12885 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
12886 .dac_nids = alc269_dac_nids,
12888 .num_channel_mode = ARRAY_SIZE(alc269_modes),
12889 .channel_mode = alc269_modes,
12890 .input_mux = &alc269_capture_source,
12891 .unsol_event = alc269_lifebook_unsol_event,
12892 .init_hook = alc269_lifebook_init_hook,
12896 static int patch_alc269(struct hda_codec *codec)
12898 struct alc_spec *spec;
12902 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
12906 codec->spec = spec;
12908 alc_fix_pll_init(codec, 0x20, 0x04, 15);
12910 board_config = snd_hda_check_board_config(codec, ALC269_MODEL_LAST,
12914 if (board_config < 0) {
12915 printk(KERN_INFO "hda_codec: Unknown model for ALC269, "
12916 "trying auto-probe from BIOS...\n");
12917 board_config = ALC269_AUTO;
12920 if (board_config == ALC269_AUTO) {
12921 /* automatic parse from the BIOS config */
12922 err = alc269_parse_auto_config(codec);
12928 "hda_codec: Cannot set up configuration "
12929 "from BIOS. Using base mode...\n");
12930 board_config = ALC269_BASIC;
12934 err = snd_hda_attach_beep_device(codec, 0x1);
12940 if (board_config != ALC269_AUTO)
12941 setup_preset(spec, &alc269_presets[board_config]);
12943 spec->stream_name_analog = "ALC269 Analog";
12944 spec->stream_analog_playback = &alc269_pcm_analog_playback;
12945 spec->stream_analog_capture = &alc269_pcm_analog_capture;
12947 spec->stream_name_digital = "ALC269 Digital";
12948 spec->stream_digital_playback = &alc269_pcm_digital_playback;
12949 spec->stream_digital_capture = &alc269_pcm_digital_capture;
12951 spec->adc_nids = alc269_adc_nids;
12952 spec->num_adc_nids = ARRAY_SIZE(alc269_adc_nids);
12953 spec->capsrc_nids = alc269_capsrc_nids;
12954 if (!spec->cap_mixer)
12955 set_capture_mixer(spec);
12956 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
12958 codec->patch_ops = alc_patch_ops;
12959 if (board_config == ALC269_AUTO)
12960 spec->init_hook = alc269_auto_init;
12961 #ifdef CONFIG_SND_HDA_POWER_SAVE
12962 if (!spec->loopback.amplist)
12963 spec->loopback.amplist = alc269_loopbacks;
12965 codec->proc_widget_hook = print_realtek_coef;
12971 * ALC861 channel source setting (2/6 channel selection for 3-stack)
12975 * set the path ways for 2 channel output
12976 * need to set the codec line out and mic 1 pin widgets to inputs
12978 static struct hda_verb alc861_threestack_ch2_init[] = {
12979 /* set pin widget 1Ah (line in) for input */
12980 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
12981 /* set pin widget 18h (mic1/2) for input, for mic also enable
12984 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
12986 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
12988 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
12989 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
12995 * need to set the codec line out and mic 1 pin widgets to outputs
12997 static struct hda_verb alc861_threestack_ch6_init[] = {
12998 /* set pin widget 1Ah (line in) for output (Back Surround)*/
12999 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13000 /* set pin widget 18h (mic1) for output (CLFE)*/
13001 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13003 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
13004 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
13006 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
13008 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
13009 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
13014 static struct hda_channel_mode alc861_threestack_modes[2] = {
13015 { 2, alc861_threestack_ch2_init },
13016 { 6, alc861_threestack_ch6_init },
13018 /* Set mic1 as input and unmute the mixer */
13019 static struct hda_verb alc861_uniwill_m31_ch2_init[] = {
13020 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13021 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
13024 /* Set mic1 as output and mute mixer */
13025 static struct hda_verb alc861_uniwill_m31_ch4_init[] = {
13026 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13027 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
13031 static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
13032 { 2, alc861_uniwill_m31_ch2_init },
13033 { 4, alc861_uniwill_m31_ch4_init },
13036 /* Set mic1 and line-in as input and unmute the mixer */
13037 static struct hda_verb alc861_asus_ch2_init[] = {
13038 /* set pin widget 1Ah (line in) for input */
13039 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13040 /* set pin widget 18h (mic1/2) for input, for mic also enable
13043 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13045 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
13047 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
13048 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
13052 /* Set mic1 nad line-in as output and mute mixer */
13053 static struct hda_verb alc861_asus_ch6_init[] = {
13054 /* set pin widget 1Ah (line in) for output (Back Surround)*/
13055 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13056 /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
13057 /* set pin widget 18h (mic1) for output (CLFE)*/
13058 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13059 /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
13060 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
13061 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
13063 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
13065 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
13066 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
13071 static struct hda_channel_mode alc861_asus_modes[2] = {
13072 { 2, alc861_asus_ch2_init },
13073 { 6, alc861_asus_ch6_init },
13078 static struct snd_kcontrol_new alc861_base_mixer[] = {
13079 /* output mixer control */
13080 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13081 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13082 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13083 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13084 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
13086 /*Input mixer control */
13087 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13088 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
13089 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13090 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13091 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13092 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13093 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13094 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13095 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
13096 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
13101 static struct snd_kcontrol_new alc861_3ST_mixer[] = {
13102 /* output mixer control */
13103 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13104 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13105 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13106 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13107 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
13109 /* Input mixer control */
13110 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13111 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
13112 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13113 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13114 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13115 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13116 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13117 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13118 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
13119 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
13122 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13123 .name = "Channel Mode",
13124 .info = alc_ch_mode_info,
13125 .get = alc_ch_mode_get,
13126 .put = alc_ch_mode_put,
13127 .private_value = ARRAY_SIZE(alc861_threestack_modes),
13132 static struct snd_kcontrol_new alc861_toshiba_mixer[] = {
13133 /* output mixer control */
13134 HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13135 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13136 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13141 static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
13142 /* output mixer control */
13143 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13144 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13145 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13146 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13147 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
13149 /* Input mixer control */
13150 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13151 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
13152 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13153 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13154 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13155 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13156 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13157 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13158 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
13159 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
13162 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13163 .name = "Channel Mode",
13164 .info = alc_ch_mode_info,
13165 .get = alc_ch_mode_get,
13166 .put = alc_ch_mode_put,
13167 .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
13172 static struct snd_kcontrol_new alc861_asus_mixer[] = {
13173 /* output mixer control */
13174 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13175 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13176 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13177 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13178 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
13180 /* Input mixer control */
13181 HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13182 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT),
13183 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13184 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13185 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13186 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13187 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13188 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13189 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
13190 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT),
13193 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13194 .name = "Channel Mode",
13195 .info = alc_ch_mode_info,
13196 .get = alc_ch_mode_get,
13197 .put = alc_ch_mode_put,
13198 .private_value = ARRAY_SIZE(alc861_asus_modes),
13203 /* additional mixer */
13204 static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = {
13205 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13206 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13211 * generic initialization of ADC, input mixers and output mixers
13213 static struct hda_verb alc861_base_init_verbs[] = {
13215 * Unmute ADC0 and set the default input to mic-in
13217 /* port-A for surround (rear panel) */
13218 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13219 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
13220 /* port-B for mic-in (rear panel) with vref */
13221 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13222 /* port-C for line-in (rear panel) */
13223 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13224 /* port-D for Front */
13225 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13226 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
13227 /* port-E for HP out (front panel) */
13228 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
13229 /* route front PCM to HP */
13230 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
13231 /* port-F for mic-in (front panel) with vref */
13232 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13233 /* port-G for CLFE (rear panel) */
13234 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13235 { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
13236 /* port-H for side (rear panel) */
13237 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13238 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
13240 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13241 /* route front mic to ADC1*/
13242 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
13243 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13245 /* Unmute DAC0~3 & spdif out*/
13246 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13247 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13248 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13249 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13250 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13252 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13253 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13254 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13255 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13256 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13258 /* Unmute Stereo Mixer 15 */
13259 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13260 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13261 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13262 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
13264 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13265 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13266 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13267 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13268 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13269 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13270 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13271 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13272 /* hp used DAC 3 (Front) */
13273 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
13274 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13279 static struct hda_verb alc861_threestack_init_verbs[] = {
13281 * Unmute ADC0 and set the default input to mic-in
13283 /* port-A for surround (rear panel) */
13284 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13285 /* port-B for mic-in (rear panel) with vref */
13286 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13287 /* port-C for line-in (rear panel) */
13288 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13289 /* port-D for Front */
13290 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13291 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
13292 /* port-E for HP out (front panel) */
13293 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
13294 /* route front PCM to HP */
13295 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
13296 /* port-F for mic-in (front panel) with vref */
13297 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13298 /* port-G for CLFE (rear panel) */
13299 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13300 /* port-H for side (rear panel) */
13301 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13303 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13304 /* route front mic to ADC1*/
13305 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
13306 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13307 /* Unmute DAC0~3 & spdif out*/
13308 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13309 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13310 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13311 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13312 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13314 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13315 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13316 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13317 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13318 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13320 /* Unmute Stereo Mixer 15 */
13321 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13322 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13323 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13324 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
13326 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13327 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13328 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13329 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13330 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13331 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13332 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13333 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13334 /* hp used DAC 3 (Front) */
13335 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
13336 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13340 static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
13342 * Unmute ADC0 and set the default input to mic-in
13344 /* port-A for surround (rear panel) */
13345 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13346 /* port-B for mic-in (rear panel) with vref */
13347 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13348 /* port-C for line-in (rear panel) */
13349 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13350 /* port-D for Front */
13351 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13352 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
13353 /* port-E for HP out (front panel) */
13354 /* this has to be set to VREF80 */
13355 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13356 /* route front PCM to HP */
13357 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
13358 /* port-F for mic-in (front panel) with vref */
13359 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13360 /* port-G for CLFE (rear panel) */
13361 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13362 /* port-H for side (rear panel) */
13363 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13365 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13366 /* route front mic to ADC1*/
13367 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
13368 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13369 /* Unmute DAC0~3 & spdif out*/
13370 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13371 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13372 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13373 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13374 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13376 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13377 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13378 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13379 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13380 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13382 /* Unmute Stereo Mixer 15 */
13383 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13384 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13385 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13386 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
13388 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13389 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13390 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13391 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13392 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13393 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13394 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13395 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13396 /* hp used DAC 3 (Front) */
13397 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
13398 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13402 static struct hda_verb alc861_asus_init_verbs[] = {
13404 * Unmute ADC0 and set the default input to mic-in
13406 /* port-A for surround (rear panel)
13407 * according to codec#0 this is the HP jack
13409 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */
13410 /* route front PCM to HP */
13411 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 },
13412 /* port-B for mic-in (rear panel) with vref */
13413 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13414 /* port-C for line-in (rear panel) */
13415 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13416 /* port-D for Front */
13417 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13418 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
13419 /* port-E for HP out (front panel) */
13420 /* this has to be set to VREF80 */
13421 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13422 /* route front PCM to HP */
13423 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
13424 /* port-F for mic-in (front panel) with vref */
13425 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13426 /* port-G for CLFE (rear panel) */
13427 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13428 /* port-H for side (rear panel) */
13429 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13431 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13432 /* route front mic to ADC1*/
13433 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
13434 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13435 /* Unmute DAC0~3 & spdif out*/
13436 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13437 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13438 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13439 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13440 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13441 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13442 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13443 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13444 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13445 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13447 /* Unmute Stereo Mixer 15 */
13448 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13449 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13450 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13451 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
13453 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13454 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13455 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13456 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13457 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13458 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13459 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13460 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13461 /* hp used DAC 3 (Front) */
13462 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
13463 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13467 /* additional init verbs for ASUS laptops */
13468 static struct hda_verb alc861_asus_laptop_init_verbs[] = {
13469 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */
13470 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */
13475 * generic initialization of ADC, input mixers and output mixers
13477 static struct hda_verb alc861_auto_init_verbs[] = {
13479 * Unmute ADC0 and set the default input to mic-in
13481 /* {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, */
13482 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13484 /* Unmute DAC0~3 & spdif out*/
13485 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13486 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13487 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13488 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13489 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13491 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13492 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13493 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13494 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13495 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13497 /* Unmute Stereo Mixer 15 */
13498 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13499 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13500 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13501 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
13503 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13504 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13505 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13506 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13507 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13508 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13509 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13510 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13512 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13513 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13514 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13515 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
13516 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13517 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13518 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13519 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
13521 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */
13526 static struct hda_verb alc861_toshiba_init_verbs[] = {
13527 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
13532 /* toggle speaker-output according to the hp-jack state */
13533 static void alc861_toshiba_automute(struct hda_codec *codec)
13535 unsigned int present;
13537 present = snd_hda_codec_read(codec, 0x0f, 0,
13538 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
13539 snd_hda_codec_amp_stereo(codec, 0x16, HDA_INPUT, 0,
13540 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
13541 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_INPUT, 3,
13542 HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
13545 static void alc861_toshiba_unsol_event(struct hda_codec *codec,
13548 if ((res >> 26) == ALC880_HP_EVENT)
13549 alc861_toshiba_automute(codec);
13552 /* pcm configuration: identiacal with ALC880 */
13553 #define alc861_pcm_analog_playback alc880_pcm_analog_playback
13554 #define alc861_pcm_analog_capture alc880_pcm_analog_capture
13555 #define alc861_pcm_digital_playback alc880_pcm_digital_playback
13556 #define alc861_pcm_digital_capture alc880_pcm_digital_capture
13559 #define ALC861_DIGOUT_NID 0x07
13561 static struct hda_channel_mode alc861_8ch_modes[1] = {
13565 static hda_nid_t alc861_dac_nids[4] = {
13566 /* front, surround, clfe, side */
13567 0x03, 0x06, 0x05, 0x04
13570 static hda_nid_t alc660_dac_nids[3] = {
13571 /* front, clfe, surround */
13575 static hda_nid_t alc861_adc_nids[1] = {
13580 static struct hda_input_mux alc861_capture_source = {
13584 { "Front Mic", 0x3 },
13591 /* fill in the dac_nids table from the parsed pin configuration */
13592 static int alc861_auto_fill_dac_nids(struct alc_spec *spec,
13593 const struct auto_pin_cfg *cfg)
13598 spec->multiout.dac_nids = spec->private_dac_nids;
13599 for (i = 0; i < cfg->line_outs; i++) {
13600 nid = cfg->line_out_pins[i];
13602 if (i >= ARRAY_SIZE(alc861_dac_nids))
13604 spec->multiout.dac_nids[i] = alc861_dac_nids[i];
13607 spec->multiout.num_dacs = cfg->line_outs;
13611 /* add playback controls from the parsed DAC table */
13612 static int alc861_auto_create_multi_out_ctls(struct alc_spec *spec,
13613 const struct auto_pin_cfg *cfg)
13616 static const char *chname[4] = {
13617 "Front", "Surround", NULL /*CLFE*/, "Side"
13622 for (i = 0; i < cfg->line_outs; i++) {
13623 nid = spec->multiout.dac_nids[i];
13628 err = add_control(spec, ALC_CTL_BIND_MUTE,
13629 "Center Playback Switch",
13630 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
13634 err = add_control(spec, ALC_CTL_BIND_MUTE,
13635 "LFE Playback Switch",
13636 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
13641 for (idx = 0; idx < ARRAY_SIZE(alc861_dac_nids) - 1;
13643 if (nid == alc861_dac_nids[idx])
13645 sprintf(name, "%s Playback Switch", chname[idx]);
13646 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
13647 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
13656 static int alc861_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin)
13664 if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
13666 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
13667 "Headphone Playback Switch",
13668 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
13671 spec->multiout.hp_nid = nid;
13676 /* create playback/capture controls for input pins */
13677 static int alc861_auto_create_analog_input_ctls(struct alc_spec *spec,
13678 const struct auto_pin_cfg *cfg)
13680 struct hda_input_mux *imux = &spec->private_imux[0];
13681 int i, err, idx, idx1;
13683 for (i = 0; i < AUTO_PIN_LAST; i++) {
13684 switch (cfg->input_pins[i]) {
13687 idx = 2; /* Line In */
13691 idx = 2; /* Line In */
13695 idx = 1; /* Mic In */
13699 idx = 1; /* Mic In */
13709 err = new_analog_input(spec, cfg->input_pins[i],
13710 auto_pin_cfg_labels[i], idx, 0x15);
13714 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
13715 imux->items[imux->num_items].index = idx1;
13721 static void alc861_auto_set_output_and_unmute(struct hda_codec *codec,
13723 int pin_type, int dac_idx)
13725 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
13727 snd_hda_codec_write(codec, dac_idx, 0, AC_VERB_SET_AMP_GAIN_MUTE,
13731 static void alc861_auto_init_multi_out(struct hda_codec *codec)
13733 struct alc_spec *spec = codec->spec;
13736 alc_subsystem_id(codec, 0x0e, 0x0f, 0x0b);
13737 for (i = 0; i < spec->autocfg.line_outs; i++) {
13738 hda_nid_t nid = spec->autocfg.line_out_pins[i];
13739 int pin_type = get_pin_type(spec->autocfg.line_out_type);
13741 alc861_auto_set_output_and_unmute(codec, nid, pin_type,
13742 spec->multiout.dac_nids[i]);
13746 static void alc861_auto_init_hp_out(struct hda_codec *codec)
13748 struct alc_spec *spec = codec->spec;
13751 pin = spec->autocfg.hp_pins[0];
13752 if (pin) /* connect to front */
13753 alc861_auto_set_output_and_unmute(codec, pin, PIN_HP,
13754 spec->multiout.dac_nids[0]);
13755 pin = spec->autocfg.speaker_pins[0];
13757 alc861_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
13760 static void alc861_auto_init_analog_input(struct hda_codec *codec)
13762 struct alc_spec *spec = codec->spec;
13765 for (i = 0; i < AUTO_PIN_LAST; i++) {
13766 hda_nid_t nid = spec->autocfg.input_pins[i];
13767 if (nid >= 0x0c && nid <= 0x11) {
13768 snd_hda_codec_write(codec, nid, 0,
13769 AC_VERB_SET_PIN_WIDGET_CONTROL,
13770 i <= AUTO_PIN_FRONT_MIC ?
13771 PIN_VREF80 : PIN_IN);
13776 /* parse the BIOS configuration and set up the alc_spec */
13777 /* return 1 if successful, 0 if the proper config is not found,
13778 * or a negative error code
13780 static int alc861_parse_auto_config(struct hda_codec *codec)
13782 struct alc_spec *spec = codec->spec;
13784 static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
13786 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
13790 if (!spec->autocfg.line_outs)
13791 return 0; /* can't find valid BIOS pin config */
13793 err = alc861_auto_fill_dac_nids(spec, &spec->autocfg);
13796 err = alc861_auto_create_multi_out_ctls(spec, &spec->autocfg);
13799 err = alc861_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0]);
13802 err = alc861_auto_create_analog_input_ctls(spec, &spec->autocfg);
13806 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
13808 if (spec->autocfg.dig_outs)
13809 spec->multiout.dig_out_nid = ALC861_DIGOUT_NID;
13811 if (spec->kctls.list)
13812 add_mixer(spec, spec->kctls.list);
13814 add_verb(spec, alc861_auto_init_verbs);
13816 spec->num_mux_defs = 1;
13817 spec->input_mux = &spec->private_imux[0];
13819 spec->adc_nids = alc861_adc_nids;
13820 spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
13821 set_capture_mixer(spec);
13823 store_pin_configs(codec);
13827 /* additional initialization for auto-configuration model */
13828 static void alc861_auto_init(struct hda_codec *codec)
13830 struct alc_spec *spec = codec->spec;
13831 alc861_auto_init_multi_out(codec);
13832 alc861_auto_init_hp_out(codec);
13833 alc861_auto_init_analog_input(codec);
13834 if (spec->unsol_event)
13835 alc_inithook(codec);
13838 #ifdef CONFIG_SND_HDA_POWER_SAVE
13839 static struct hda_amp_list alc861_loopbacks[] = {
13840 { 0x15, HDA_INPUT, 0 },
13841 { 0x15, HDA_INPUT, 1 },
13842 { 0x15, HDA_INPUT, 2 },
13843 { 0x15, HDA_INPUT, 3 },
13850 * configuration and preset
13852 static const char *alc861_models[ALC861_MODEL_LAST] = {
13853 [ALC861_3ST] = "3stack",
13854 [ALC660_3ST] = "3stack-660",
13855 [ALC861_3ST_DIG] = "3stack-dig",
13856 [ALC861_6ST_DIG] = "6stack-dig",
13857 [ALC861_UNIWILL_M31] = "uniwill-m31",
13858 [ALC861_TOSHIBA] = "toshiba",
13859 [ALC861_ASUS] = "asus",
13860 [ALC861_ASUS_LAPTOP] = "asus-laptop",
13861 [ALC861_AUTO] = "auto",
13864 static struct snd_pci_quirk alc861_cfg_tbl[] = {
13865 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST),
13866 SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP),
13867 SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP),
13868 SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS),
13869 SND_PCI_QUIRK(0x1043, 0x13d7, "ASUS A9rp", ALC861_ASUS_LAPTOP),
13870 SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS P1-AH2", ALC861_3ST_DIG),
13871 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA),
13872 /* FIXME: the entry below breaks Toshiba A100 (model=auto works!)
13873 * Any other models that need this preset?
13875 /* SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA), */
13876 SND_PCI_QUIRK(0x1462, 0x7254, "HP dx2200 (MSI MS-7254)", ALC861_3ST),
13877 SND_PCI_QUIRK(0x1462, 0x7297, "HP dx2250 (MSI MS-7297)", ALC861_3ST),
13878 SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31),
13879 SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31),
13880 SND_PCI_QUIRK(0x1584, 0x9075, "Airis Praxis N1212", ALC861_ASUS_LAPTOP),
13881 /* FIXME: the below seems conflict */
13882 /* SND_PCI_QUIRK(0x1584, 0x9075, "Uniwill", ALC861_UNIWILL_M31), */
13883 SND_PCI_QUIRK(0x1849, 0x0660, "Asrock 939SLI32", ALC660_3ST),
13884 SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST),
13888 static struct alc_config_preset alc861_presets[] = {
13890 .mixers = { alc861_3ST_mixer },
13891 .init_verbs = { alc861_threestack_init_verbs },
13892 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
13893 .dac_nids = alc861_dac_nids,
13894 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
13895 .channel_mode = alc861_threestack_modes,
13897 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
13898 .adc_nids = alc861_adc_nids,
13899 .input_mux = &alc861_capture_source,
13901 [ALC861_3ST_DIG] = {
13902 .mixers = { alc861_base_mixer },
13903 .init_verbs = { alc861_threestack_init_verbs },
13904 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
13905 .dac_nids = alc861_dac_nids,
13906 .dig_out_nid = ALC861_DIGOUT_NID,
13907 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
13908 .channel_mode = alc861_threestack_modes,
13910 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
13911 .adc_nids = alc861_adc_nids,
13912 .input_mux = &alc861_capture_source,
13914 [ALC861_6ST_DIG] = {
13915 .mixers = { alc861_base_mixer },
13916 .init_verbs = { alc861_base_init_verbs },
13917 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
13918 .dac_nids = alc861_dac_nids,
13919 .dig_out_nid = ALC861_DIGOUT_NID,
13920 .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
13921 .channel_mode = alc861_8ch_modes,
13922 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
13923 .adc_nids = alc861_adc_nids,
13924 .input_mux = &alc861_capture_source,
13927 .mixers = { alc861_3ST_mixer },
13928 .init_verbs = { alc861_threestack_init_verbs },
13929 .num_dacs = ARRAY_SIZE(alc660_dac_nids),
13930 .dac_nids = alc660_dac_nids,
13931 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
13932 .channel_mode = alc861_threestack_modes,
13934 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
13935 .adc_nids = alc861_adc_nids,
13936 .input_mux = &alc861_capture_source,
13938 [ALC861_UNIWILL_M31] = {
13939 .mixers = { alc861_uniwill_m31_mixer },
13940 .init_verbs = { alc861_uniwill_m31_init_verbs },
13941 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
13942 .dac_nids = alc861_dac_nids,
13943 .dig_out_nid = ALC861_DIGOUT_NID,
13944 .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes),
13945 .channel_mode = alc861_uniwill_m31_modes,
13947 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
13948 .adc_nids = alc861_adc_nids,
13949 .input_mux = &alc861_capture_source,
13951 [ALC861_TOSHIBA] = {
13952 .mixers = { alc861_toshiba_mixer },
13953 .init_verbs = { alc861_base_init_verbs,
13954 alc861_toshiba_init_verbs },
13955 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
13956 .dac_nids = alc861_dac_nids,
13957 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
13958 .channel_mode = alc883_3ST_2ch_modes,
13959 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
13960 .adc_nids = alc861_adc_nids,
13961 .input_mux = &alc861_capture_source,
13962 .unsol_event = alc861_toshiba_unsol_event,
13963 .init_hook = alc861_toshiba_automute,
13966 .mixers = { alc861_asus_mixer },
13967 .init_verbs = { alc861_asus_init_verbs },
13968 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
13969 .dac_nids = alc861_dac_nids,
13970 .dig_out_nid = ALC861_DIGOUT_NID,
13971 .num_channel_mode = ARRAY_SIZE(alc861_asus_modes),
13972 .channel_mode = alc861_asus_modes,
13975 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
13976 .adc_nids = alc861_adc_nids,
13977 .input_mux = &alc861_capture_source,
13979 [ALC861_ASUS_LAPTOP] = {
13980 .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer },
13981 .init_verbs = { alc861_asus_init_verbs,
13982 alc861_asus_laptop_init_verbs },
13983 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
13984 .dac_nids = alc861_dac_nids,
13985 .dig_out_nid = ALC861_DIGOUT_NID,
13986 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
13987 .channel_mode = alc883_3ST_2ch_modes,
13989 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
13990 .adc_nids = alc861_adc_nids,
13991 .input_mux = &alc861_capture_source,
13996 static int patch_alc861(struct hda_codec *codec)
13998 struct alc_spec *spec;
14002 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
14006 codec->spec = spec;
14008 board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST,
14012 if (board_config < 0) {
14013 printk(KERN_INFO "hda_codec: Unknown model for ALC861, "
14014 "trying auto-probe from BIOS...\n");
14015 board_config = ALC861_AUTO;
14018 if (board_config == ALC861_AUTO) {
14019 /* automatic parse from the BIOS config */
14020 err = alc861_parse_auto_config(codec);
14026 "hda_codec: Cannot set up configuration "
14027 "from BIOS. Using base mode...\n");
14028 board_config = ALC861_3ST_DIG;
14032 err = snd_hda_attach_beep_device(codec, 0x23);
14038 if (board_config != ALC861_AUTO)
14039 setup_preset(spec, &alc861_presets[board_config]);
14041 spec->stream_name_analog = "ALC861 Analog";
14042 spec->stream_analog_playback = &alc861_pcm_analog_playback;
14043 spec->stream_analog_capture = &alc861_pcm_analog_capture;
14045 spec->stream_name_digital = "ALC861 Digital";
14046 spec->stream_digital_playback = &alc861_pcm_digital_playback;
14047 spec->stream_digital_capture = &alc861_pcm_digital_capture;
14049 set_beep_amp(spec, 0x23, 0, HDA_OUTPUT);
14051 spec->vmaster_nid = 0x03;
14053 codec->patch_ops = alc_patch_ops;
14054 if (board_config == ALC861_AUTO)
14055 spec->init_hook = alc861_auto_init;
14056 #ifdef CONFIG_SND_HDA_POWER_SAVE
14057 if (!spec->loopback.amplist)
14058 spec->loopback.amplist = alc861_loopbacks;
14060 codec->proc_widget_hook = print_realtek_coef;
14066 * ALC861-VD support
14070 * In addition, an independent DAC
14072 #define ALC861VD_DIGOUT_NID 0x06
14074 static hda_nid_t alc861vd_dac_nids[4] = {
14075 /* front, surr, clfe, side surr */
14076 0x02, 0x03, 0x04, 0x05
14079 /* dac_nids for ALC660vd are in a different order - according to
14080 * Realtek's driver.
14081 * This should probably tesult in a different mixer for 6stack models
14082 * of ALC660vd codecs, but for now there is only 3stack mixer
14083 * - and it is the same as in 861vd.
14084 * adc_nids in ALC660vd are (is) the same as in 861vd
14086 static hda_nid_t alc660vd_dac_nids[3] = {
14087 /* front, rear, clfe, rear_surr */
14091 static hda_nid_t alc861vd_adc_nids[1] = {
14096 static hda_nid_t alc861vd_capsrc_nids[1] = { 0x22 };
14099 /* FIXME: should be a matrix-type input source selection */
14100 static struct hda_input_mux alc861vd_capture_source = {
14104 { "Front Mic", 0x1 },
14110 static struct hda_input_mux alc861vd_dallas_capture_source = {
14113 { "Ext Mic", 0x0 },
14114 { "Int Mic", 0x1 },
14118 static struct hda_input_mux alc861vd_hp_capture_source = {
14121 { "Front Mic", 0x0 },
14122 { "ATAPI Mic", 0x1 },
14129 static struct hda_channel_mode alc861vd_3stack_2ch_modes[1] = {
14136 static struct hda_verb alc861vd_6stack_ch6_init[] = {
14137 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
14138 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14139 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14140 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14147 static struct hda_verb alc861vd_6stack_ch8_init[] = {
14148 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14149 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14150 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14151 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14155 static struct hda_channel_mode alc861vd_6stack_modes[2] = {
14156 { 6, alc861vd_6stack_ch6_init },
14157 { 8, alc861vd_6stack_ch8_init },
14160 static struct snd_kcontrol_new alc861vd_chmode_mixer[] = {
14162 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
14163 .name = "Channel Mode",
14164 .info = alc_ch_mode_info,
14165 .get = alc_ch_mode_get,
14166 .put = alc_ch_mode_put,
14171 /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
14172 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
14174 static struct snd_kcontrol_new alc861vd_6st_mixer[] = {
14175 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14176 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
14178 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14179 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
14181 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0,
14183 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0,
14185 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
14186 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
14188 HDA_CODEC_VOLUME("Side Playback Volume", 0x05, 0x0, HDA_OUTPUT),
14189 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
14191 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14193 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14194 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14195 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14197 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
14198 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14199 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14201 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
14202 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
14204 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
14205 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
14210 static struct snd_kcontrol_new alc861vd_3st_mixer[] = {
14211 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14212 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
14214 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14216 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14217 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14218 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14220 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
14221 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14222 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14224 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
14225 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
14227 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
14228 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
14233 static struct snd_kcontrol_new alc861vd_lenovo_mixer[] = {
14234 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14235 /*HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),*/
14236 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
14238 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14240 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14241 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14242 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14244 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
14245 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14246 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14248 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
14249 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
14254 /* Pin assignment: Speaker=0x14, HP = 0x15,
14255 * Ext Mic=0x18, Int Mic = 0x19, CD = 0x1c, PC Beep = 0x1d
14257 static struct snd_kcontrol_new alc861vd_dallas_mixer[] = {
14258 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14259 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
14260 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14261 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
14262 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
14263 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14264 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14265 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
14266 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14267 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14271 /* Pin assignment: Speaker=0x14, Line-out = 0x15,
14272 * Front Mic=0x18, ATAPI Mic = 0x19,
14274 static struct snd_kcontrol_new alc861vd_hp_mixer[] = {
14275 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14276 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
14277 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14278 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
14279 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14280 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14281 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14282 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14288 * generic initialization of ADC, input mixers and output mixers
14290 static struct hda_verb alc861vd_volume_init_verbs[] = {
14292 * Unmute ADC0 and set the default input to mic-in
14294 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
14295 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14297 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of
14298 * the analog-loopback mixer widget
14300 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
14301 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14302 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14303 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
14304 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
14305 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
14307 /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */
14308 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14309 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14310 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
14311 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
14314 * Set up output mixers (0x02 - 0x05)
14316 /* set vol=0 to output mixers */
14317 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14318 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14319 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14320 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14322 /* set up input amps for analog loopback */
14323 /* Amp Indices: DAC = 0, mixer = 1 */
14324 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14325 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14326 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14327 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14328 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14329 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14330 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14331 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14337 * 3-stack pin configuration:
14338 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
14340 static struct hda_verb alc861vd_3stack_init_verbs[] = {
14342 * Set pin mode and muting
14344 /* set front pin widgets 0x14 for output */
14345 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14346 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14347 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
14349 /* Mic (rear) pin: input vref at 80% */
14350 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14351 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14352 /* Front Mic pin: input vref at 80% */
14353 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14354 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14355 /* Line In pin: input */
14356 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14357 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14358 /* Line-2 In: Headphone output (output 0 - 0x0c) */
14359 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14360 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14361 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
14362 /* CD pin widget for input */
14363 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14369 * 6-stack pin configuration:
14371 static struct hda_verb alc861vd_6stack_init_verbs[] = {
14373 * Set pin mode and muting
14375 /* set front pin widgets 0x14 for output */
14376 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14377 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14378 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
14380 /* Rear Pin: output 1 (0x0d) */
14381 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14382 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14383 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
14384 /* CLFE Pin: output 2 (0x0e) */
14385 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14386 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14387 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
14388 /* Side Pin: output 3 (0x0f) */
14389 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14390 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14391 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
14393 /* Mic (rear) pin: input vref at 80% */
14394 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14395 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14396 /* Front Mic pin: input vref at 80% */
14397 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14398 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14399 /* Line In pin: input */
14400 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14401 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14402 /* Line-2 In: Headphone output (output 0 - 0x0c) */
14403 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14404 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14405 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
14406 /* CD pin widget for input */
14407 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14412 static struct hda_verb alc861vd_eapd_verbs[] = {
14413 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
14417 static struct hda_verb alc660vd_eapd_verbs[] = {
14418 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
14419 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
14423 static struct hda_verb alc861vd_lenovo_unsol_verbs[] = {
14424 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14425 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14426 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
14427 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14428 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14432 /* toggle speaker-output according to the hp-jack state */
14433 static void alc861vd_lenovo_hp_automute(struct hda_codec *codec)
14435 unsigned int present;
14436 unsigned char bits;
14438 present = snd_hda_codec_read(codec, 0x1b, 0,
14439 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
14440 bits = present ? HDA_AMP_MUTE : 0;
14441 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
14442 HDA_AMP_MUTE, bits);
14445 static void alc861vd_lenovo_mic_automute(struct hda_codec *codec)
14447 unsigned int present;
14448 unsigned char bits;
14450 present = snd_hda_codec_read(codec, 0x18, 0,
14451 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
14452 bits = present ? HDA_AMP_MUTE : 0;
14453 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
14454 HDA_AMP_MUTE, bits);
14457 static void alc861vd_lenovo_automute(struct hda_codec *codec)
14459 alc861vd_lenovo_hp_automute(codec);
14460 alc861vd_lenovo_mic_automute(codec);
14463 static void alc861vd_lenovo_unsol_event(struct hda_codec *codec,
14466 switch (res >> 26) {
14467 case ALC880_HP_EVENT:
14468 alc861vd_lenovo_hp_automute(codec);
14470 case ALC880_MIC_EVENT:
14471 alc861vd_lenovo_mic_automute(codec);
14476 static struct hda_verb alc861vd_dallas_verbs[] = {
14477 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14478 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14479 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14480 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14482 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14483 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14484 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14485 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14486 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14487 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14488 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14489 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14491 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14492 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14493 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14494 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14495 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14496 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14497 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14498 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14500 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
14501 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14502 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
14503 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14504 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14505 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14506 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14507 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14509 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14510 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
14511 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
14512 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
14514 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14515 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
14516 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14521 /* toggle speaker-output according to the hp-jack state */
14522 static void alc861vd_dallas_automute(struct hda_codec *codec)
14524 unsigned int present;
14526 present = snd_hda_codec_read(codec, 0x15, 0,
14527 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
14528 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
14529 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
14532 static void alc861vd_dallas_unsol_event(struct hda_codec *codec, unsigned int res)
14534 if ((res >> 26) == ALC880_HP_EVENT)
14535 alc861vd_dallas_automute(codec);
14538 #ifdef CONFIG_SND_HDA_POWER_SAVE
14539 #define alc861vd_loopbacks alc880_loopbacks
14542 /* pcm configuration: identiacal with ALC880 */
14543 #define alc861vd_pcm_analog_playback alc880_pcm_analog_playback
14544 #define alc861vd_pcm_analog_capture alc880_pcm_analog_capture
14545 #define alc861vd_pcm_digital_playback alc880_pcm_digital_playback
14546 #define alc861vd_pcm_digital_capture alc880_pcm_digital_capture
14549 * configuration and preset
14551 static const char *alc861vd_models[ALC861VD_MODEL_LAST] = {
14552 [ALC660VD_3ST] = "3stack-660",
14553 [ALC660VD_3ST_DIG] = "3stack-660-digout",
14554 [ALC660VD_ASUS_V1S] = "asus-v1s",
14555 [ALC861VD_3ST] = "3stack",
14556 [ALC861VD_3ST_DIG] = "3stack-digout",
14557 [ALC861VD_6ST_DIG] = "6stack-digout",
14558 [ALC861VD_LENOVO] = "lenovo",
14559 [ALC861VD_DALLAS] = "dallas",
14560 [ALC861VD_HP] = "hp",
14561 [ALC861VD_AUTO] = "auto",
14564 static struct snd_pci_quirk alc861vd_cfg_tbl[] = {
14565 SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST),
14566 SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_HP),
14567 SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST),
14568 SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST),
14569 SND_PCI_QUIRK(0x1043, 0x1633, "Asus V1Sn", ALC660VD_ASUS_V1S),
14570 SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660VD_3ST_DIG),
14571 SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST),
14572 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba A135", ALC861VD_LENOVO),
14573 /*SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),*/ /*lenovo*/
14574 SND_PCI_QUIRK(0x1179, 0xff01, "DALLAS", ALC861VD_DALLAS),
14575 SND_PCI_QUIRK(0x1179, 0xff03, "Toshiba P205", ALC861VD_LENOVO),
14576 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba L30-149", ALC861VD_DALLAS),
14577 SND_PCI_QUIRK(0x1565, 0x820d, "Biostar NF61S SE", ALC861VD_6ST_DIG),
14578 SND_PCI_QUIRK_VENDOR(0x17aa, "Lenovo", ALC861VD_LENOVO),
14579 SND_PCI_QUIRK(0x1849, 0x0862, "ASRock K8NF6G-VSTA", ALC861VD_6ST_DIG),
14583 static struct alc_config_preset alc861vd_presets[] = {
14585 .mixers = { alc861vd_3st_mixer },
14586 .init_verbs = { alc861vd_volume_init_verbs,
14587 alc861vd_3stack_init_verbs },
14588 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
14589 .dac_nids = alc660vd_dac_nids,
14590 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14591 .channel_mode = alc861vd_3stack_2ch_modes,
14592 .input_mux = &alc861vd_capture_source,
14594 [ALC660VD_3ST_DIG] = {
14595 .mixers = { alc861vd_3st_mixer },
14596 .init_verbs = { alc861vd_volume_init_verbs,
14597 alc861vd_3stack_init_verbs },
14598 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
14599 .dac_nids = alc660vd_dac_nids,
14600 .dig_out_nid = ALC861VD_DIGOUT_NID,
14601 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14602 .channel_mode = alc861vd_3stack_2ch_modes,
14603 .input_mux = &alc861vd_capture_source,
14606 .mixers = { alc861vd_3st_mixer },
14607 .init_verbs = { alc861vd_volume_init_verbs,
14608 alc861vd_3stack_init_verbs },
14609 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
14610 .dac_nids = alc861vd_dac_nids,
14611 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14612 .channel_mode = alc861vd_3stack_2ch_modes,
14613 .input_mux = &alc861vd_capture_source,
14615 [ALC861VD_3ST_DIG] = {
14616 .mixers = { alc861vd_3st_mixer },
14617 .init_verbs = { alc861vd_volume_init_verbs,
14618 alc861vd_3stack_init_verbs },
14619 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
14620 .dac_nids = alc861vd_dac_nids,
14621 .dig_out_nid = ALC861VD_DIGOUT_NID,
14622 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14623 .channel_mode = alc861vd_3stack_2ch_modes,
14624 .input_mux = &alc861vd_capture_source,
14626 [ALC861VD_6ST_DIG] = {
14627 .mixers = { alc861vd_6st_mixer, alc861vd_chmode_mixer },
14628 .init_verbs = { alc861vd_volume_init_verbs,
14629 alc861vd_6stack_init_verbs },
14630 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
14631 .dac_nids = alc861vd_dac_nids,
14632 .dig_out_nid = ALC861VD_DIGOUT_NID,
14633 .num_channel_mode = ARRAY_SIZE(alc861vd_6stack_modes),
14634 .channel_mode = alc861vd_6stack_modes,
14635 .input_mux = &alc861vd_capture_source,
14637 [ALC861VD_LENOVO] = {
14638 .mixers = { alc861vd_lenovo_mixer },
14639 .init_verbs = { alc861vd_volume_init_verbs,
14640 alc861vd_3stack_init_verbs,
14641 alc861vd_eapd_verbs,
14642 alc861vd_lenovo_unsol_verbs },
14643 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
14644 .dac_nids = alc660vd_dac_nids,
14645 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14646 .channel_mode = alc861vd_3stack_2ch_modes,
14647 .input_mux = &alc861vd_capture_source,
14648 .unsol_event = alc861vd_lenovo_unsol_event,
14649 .init_hook = alc861vd_lenovo_automute,
14651 [ALC861VD_DALLAS] = {
14652 .mixers = { alc861vd_dallas_mixer },
14653 .init_verbs = { alc861vd_dallas_verbs },
14654 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
14655 .dac_nids = alc861vd_dac_nids,
14656 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14657 .channel_mode = alc861vd_3stack_2ch_modes,
14658 .input_mux = &alc861vd_dallas_capture_source,
14659 .unsol_event = alc861vd_dallas_unsol_event,
14660 .init_hook = alc861vd_dallas_automute,
14663 .mixers = { alc861vd_hp_mixer },
14664 .init_verbs = { alc861vd_dallas_verbs, alc861vd_eapd_verbs },
14665 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
14666 .dac_nids = alc861vd_dac_nids,
14667 .dig_out_nid = ALC861VD_DIGOUT_NID,
14668 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14669 .channel_mode = alc861vd_3stack_2ch_modes,
14670 .input_mux = &alc861vd_hp_capture_source,
14671 .unsol_event = alc861vd_dallas_unsol_event,
14672 .init_hook = alc861vd_dallas_automute,
14674 [ALC660VD_ASUS_V1S] = {
14675 .mixers = { alc861vd_lenovo_mixer },
14676 .init_verbs = { alc861vd_volume_init_verbs,
14677 alc861vd_3stack_init_verbs,
14678 alc861vd_eapd_verbs,
14679 alc861vd_lenovo_unsol_verbs },
14680 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
14681 .dac_nids = alc660vd_dac_nids,
14682 .dig_out_nid = ALC861VD_DIGOUT_NID,
14683 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14684 .channel_mode = alc861vd_3stack_2ch_modes,
14685 .input_mux = &alc861vd_capture_source,
14686 .unsol_event = alc861vd_lenovo_unsol_event,
14687 .init_hook = alc861vd_lenovo_automute,
14692 * BIOS auto configuration
14694 static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec,
14695 hda_nid_t nid, int pin_type, int dac_idx)
14697 alc_set_pin_output(codec, nid, pin_type);
14700 static void alc861vd_auto_init_multi_out(struct hda_codec *codec)
14702 struct alc_spec *spec = codec->spec;
14705 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
14706 for (i = 0; i <= HDA_SIDE; i++) {
14707 hda_nid_t nid = spec->autocfg.line_out_pins[i];
14708 int pin_type = get_pin_type(spec->autocfg.line_out_type);
14710 alc861vd_auto_set_output_and_unmute(codec, nid,
14716 static void alc861vd_auto_init_hp_out(struct hda_codec *codec)
14718 struct alc_spec *spec = codec->spec;
14721 pin = spec->autocfg.hp_pins[0];
14722 if (pin) /* connect to front and use dac 0 */
14723 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
14724 pin = spec->autocfg.speaker_pins[0];
14726 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
14729 #define alc861vd_is_input_pin(nid) alc880_is_input_pin(nid)
14730 #define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID
14732 static void alc861vd_auto_init_analog_input(struct hda_codec *codec)
14734 struct alc_spec *spec = codec->spec;
14737 for (i = 0; i < AUTO_PIN_LAST; i++) {
14738 hda_nid_t nid = spec->autocfg.input_pins[i];
14739 if (alc861vd_is_input_pin(nid)) {
14740 snd_hda_codec_write(codec, nid, 0,
14741 AC_VERB_SET_PIN_WIDGET_CONTROL,
14742 i <= AUTO_PIN_FRONT_MIC ?
14743 PIN_VREF80 : PIN_IN);
14744 if (nid != ALC861VD_PIN_CD_NID)
14745 snd_hda_codec_write(codec, nid, 0,
14746 AC_VERB_SET_AMP_GAIN_MUTE,
14752 #define alc861vd_auto_init_input_src alc882_auto_init_input_src
14754 #define alc861vd_idx_to_mixer_vol(nid) ((nid) + 0x02)
14755 #define alc861vd_idx_to_mixer_switch(nid) ((nid) + 0x0c)
14757 /* add playback controls from the parsed DAC table */
14758 /* Based on ALC880 version. But ALC861VD has separate,
14759 * different NIDs for mute/unmute switch and volume control */
14760 static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
14761 const struct auto_pin_cfg *cfg)
14764 static const char *chname[4] = {"Front", "Surround", "CLFE", "Side"};
14765 hda_nid_t nid_v, nid_s;
14768 for (i = 0; i < cfg->line_outs; i++) {
14769 if (!spec->multiout.dac_nids[i])
14771 nid_v = alc861vd_idx_to_mixer_vol(
14773 spec->multiout.dac_nids[i]));
14774 nid_s = alc861vd_idx_to_mixer_switch(
14776 spec->multiout.dac_nids[i]));
14780 err = add_control(spec, ALC_CTL_WIDGET_VOL,
14781 "Center Playback Volume",
14782 HDA_COMPOSE_AMP_VAL(nid_v, 1, 0,
14786 err = add_control(spec, ALC_CTL_WIDGET_VOL,
14787 "LFE Playback Volume",
14788 HDA_COMPOSE_AMP_VAL(nid_v, 2, 0,
14792 err = add_control(spec, ALC_CTL_BIND_MUTE,
14793 "Center Playback Switch",
14794 HDA_COMPOSE_AMP_VAL(nid_s, 1, 2,
14798 err = add_control(spec, ALC_CTL_BIND_MUTE,
14799 "LFE Playback Switch",
14800 HDA_COMPOSE_AMP_VAL(nid_s, 2, 2,
14805 sprintf(name, "%s Playback Volume", chname[i]);
14806 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
14807 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0,
14811 sprintf(name, "%s Playback Switch", chname[i]);
14812 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
14813 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2,
14822 /* add playback controls for speaker and HP outputs */
14823 /* Based on ALC880 version. But ALC861VD has separate,
14824 * different NIDs for mute/unmute switch and volume control */
14825 static int alc861vd_auto_create_extra_out(struct alc_spec *spec,
14826 hda_nid_t pin, const char *pfx)
14828 hda_nid_t nid_v, nid_s;
14835 if (alc880_is_fixed_pin(pin)) {
14836 nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
14837 /* specify the DAC as the extra output */
14838 if (!spec->multiout.hp_nid)
14839 spec->multiout.hp_nid = nid_v;
14841 spec->multiout.extra_out_nid[0] = nid_v;
14842 /* control HP volume/switch on the output mixer amp */
14843 nid_v = alc861vd_idx_to_mixer_vol(
14844 alc880_fixed_pin_idx(pin));
14845 nid_s = alc861vd_idx_to_mixer_switch(
14846 alc880_fixed_pin_idx(pin));
14848 sprintf(name, "%s Playback Volume", pfx);
14849 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
14850 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT));
14853 sprintf(name, "%s Playback Switch", pfx);
14854 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
14855 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT));
14858 } else if (alc880_is_multi_pin(pin)) {
14859 /* set manual connection */
14860 /* we have only a switch on HP-out PIN */
14861 sprintf(name, "%s Playback Switch", pfx);
14862 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
14863 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
14870 /* parse the BIOS configuration and set up the alc_spec
14871 * return 1 if successful, 0 if the proper config is not found,
14872 * or a negative error code
14873 * Based on ALC880 version - had to change it to override
14874 * alc880_auto_create_extra_out and alc880_auto_create_multi_out_ctls */
14875 static int alc861vd_parse_auto_config(struct hda_codec *codec)
14877 struct alc_spec *spec = codec->spec;
14879 static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
14881 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
14885 if (!spec->autocfg.line_outs)
14886 return 0; /* can't find valid BIOS pin config */
14888 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
14891 err = alc861vd_auto_create_multi_out_ctls(spec, &spec->autocfg);
14894 err = alc861vd_auto_create_extra_out(spec,
14895 spec->autocfg.speaker_pins[0],
14899 err = alc861vd_auto_create_extra_out(spec,
14900 spec->autocfg.hp_pins[0],
14904 err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
14908 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
14910 if (spec->autocfg.dig_outs)
14911 spec->multiout.dig_out_nid = ALC861VD_DIGOUT_NID;
14913 if (spec->kctls.list)
14914 add_mixer(spec, spec->kctls.list);
14916 add_verb(spec, alc861vd_volume_init_verbs);
14918 spec->num_mux_defs = 1;
14919 spec->input_mux = &spec->private_imux[0];
14921 err = alc_auto_add_mic_boost(codec);
14925 store_pin_configs(codec);
14929 /* additional initialization for auto-configuration model */
14930 static void alc861vd_auto_init(struct hda_codec *codec)
14932 struct alc_spec *spec = codec->spec;
14933 alc861vd_auto_init_multi_out(codec);
14934 alc861vd_auto_init_hp_out(codec);
14935 alc861vd_auto_init_analog_input(codec);
14936 alc861vd_auto_init_input_src(codec);
14937 if (spec->unsol_event)
14938 alc_inithook(codec);
14941 static int patch_alc861vd(struct hda_codec *codec)
14943 struct alc_spec *spec;
14944 int err, board_config;
14946 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
14950 codec->spec = spec;
14952 board_config = snd_hda_check_board_config(codec, ALC861VD_MODEL_LAST,
14956 if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) {
14957 printk(KERN_INFO "hda_codec: Unknown model for ALC660VD/"
14958 "ALC861VD, trying auto-probe from BIOS...\n");
14959 board_config = ALC861VD_AUTO;
14962 if (board_config == ALC861VD_AUTO) {
14963 /* automatic parse from the BIOS config */
14964 err = alc861vd_parse_auto_config(codec);
14970 "hda_codec: Cannot set up configuration "
14971 "from BIOS. Using base mode...\n");
14972 board_config = ALC861VD_3ST;
14976 err = snd_hda_attach_beep_device(codec, 0x23);
14982 if (board_config != ALC861VD_AUTO)
14983 setup_preset(spec, &alc861vd_presets[board_config]);
14985 if (codec->vendor_id == 0x10ec0660) {
14986 spec->stream_name_analog = "ALC660-VD Analog";
14987 spec->stream_name_digital = "ALC660-VD Digital";
14988 /* always turn on EAPD */
14989 add_verb(spec, alc660vd_eapd_verbs);
14991 spec->stream_name_analog = "ALC861VD Analog";
14992 spec->stream_name_digital = "ALC861VD Digital";
14995 spec->stream_analog_playback = &alc861vd_pcm_analog_playback;
14996 spec->stream_analog_capture = &alc861vd_pcm_analog_capture;
14998 spec->stream_digital_playback = &alc861vd_pcm_digital_playback;
14999 spec->stream_digital_capture = &alc861vd_pcm_digital_capture;
15001 spec->adc_nids = alc861vd_adc_nids;
15002 spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids);
15003 spec->capsrc_nids = alc861vd_capsrc_nids;
15004 spec->capture_style = CAPT_MIX;
15006 set_capture_mixer(spec);
15007 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
15009 spec->vmaster_nid = 0x02;
15011 codec->patch_ops = alc_patch_ops;
15013 if (board_config == ALC861VD_AUTO)
15014 spec->init_hook = alc861vd_auto_init;
15015 #ifdef CONFIG_SND_HDA_POWER_SAVE
15016 if (!spec->loopback.amplist)
15017 spec->loopback.amplist = alc861vd_loopbacks;
15019 codec->proc_widget_hook = print_realtek_coef;
15027 * ALC662 is almost identical with ALC880 but has cleaner and more flexible
15028 * configuration. Each pin widget can choose any input DACs and a mixer.
15029 * Each ADC is connected from a mixer of all inputs. This makes possible
15030 * 6-channel independent captures.
15032 * In addition, an independent DAC for the multi-playback (not used in this
15035 #define ALC662_DIGOUT_NID 0x06
15036 #define ALC662_DIGIN_NID 0x0a
15038 static hda_nid_t alc662_dac_nids[4] = {
15039 /* front, rear, clfe, rear_surr */
15043 static hda_nid_t alc662_adc_nids[1] = {
15048 static hda_nid_t alc662_capsrc_nids[1] = { 0x22 };
15051 /* FIXME: should be a matrix-type input source selection */
15052 static struct hda_input_mux alc662_capture_source = {
15056 { "Front Mic", 0x1 },
15062 static struct hda_input_mux alc662_lenovo_101e_capture_source = {
15070 static struct hda_input_mux alc662_eeepc_capture_source = {
15078 static struct hda_input_mux alc663_capture_source = {
15082 { "Front Mic", 0x1 },
15087 static struct hda_input_mux alc663_m51va_capture_source = {
15090 { "Ext-Mic", 0x0 },
15098 static struct hda_channel_mode alc662_3ST_2ch_modes[1] = {
15105 static struct hda_verb alc662_3ST_ch2_init[] = {
15106 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
15107 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
15108 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
15109 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
15116 static struct hda_verb alc662_3ST_ch6_init[] = {
15117 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15118 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
15119 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
15120 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15121 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
15122 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
15126 static struct hda_channel_mode alc662_3ST_6ch_modes[2] = {
15127 { 2, alc662_3ST_ch2_init },
15128 { 6, alc662_3ST_ch6_init },
15134 static struct hda_verb alc662_sixstack_ch6_init[] = {
15135 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15136 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15137 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15144 static struct hda_verb alc662_sixstack_ch8_init[] = {
15145 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15146 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15147 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15151 static struct hda_channel_mode alc662_5stack_modes[2] = {
15152 { 2, alc662_sixstack_ch6_init },
15153 { 6, alc662_sixstack_ch8_init },
15156 /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
15157 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
15160 static struct snd_kcontrol_new alc662_base_mixer[] = {
15161 /* output mixer control */
15162 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
15163 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
15164 HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT),
15165 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
15166 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
15167 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
15168 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
15169 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
15170 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15172 /*Input mixer control */
15173 HDA_CODEC_VOLUME("CD Playback Volume", 0xb, 0x4, HDA_INPUT),
15174 HDA_CODEC_MUTE("CD Playback Switch", 0xb, 0x4, HDA_INPUT),
15175 HDA_CODEC_VOLUME("Line Playback Volume", 0xb, 0x02, HDA_INPUT),
15176 HDA_CODEC_MUTE("Line Playback Switch", 0xb, 0x02, HDA_INPUT),
15177 HDA_CODEC_VOLUME("Mic Playback Volume", 0xb, 0x0, HDA_INPUT),
15178 HDA_CODEC_MUTE("Mic Playback Switch", 0xb, 0x0, HDA_INPUT),
15179 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0xb, 0x01, HDA_INPUT),
15180 HDA_CODEC_MUTE("Front Mic Playback Switch", 0xb, 0x01, HDA_INPUT),
15184 static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = {
15185 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15186 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
15187 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15188 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
15189 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
15190 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15191 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15192 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15193 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15194 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15195 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15199 static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = {
15200 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15201 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
15202 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15203 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
15204 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
15205 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
15206 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
15207 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
15208 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15209 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
15210 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
15211 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15212 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15213 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15214 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15215 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15216 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15220 static struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = {
15221 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15222 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
15223 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15224 HDA_BIND_MUTE("Speaker Playback Switch", 0x03, 2, HDA_INPUT),
15225 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15226 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15227 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15228 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15229 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15233 static struct snd_kcontrol_new alc662_eeepc_p701_mixer[] = {
15234 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
15236 HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15237 HDA_CODEC_MUTE("Line-Out Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15239 HDA_CODEC_VOLUME("e-Mic Boost", 0x18, 0, HDA_INPUT),
15240 HDA_CODEC_VOLUME("e-Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15241 HDA_CODEC_MUTE("e-Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15243 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
15244 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15245 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15249 static struct snd_kcontrol_new alc662_eeepc_ep20_mixer[] = {
15250 HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15251 HDA_CODEC_MUTE("Line-Out Playback Switch", 0x14, 0x0, HDA_OUTPUT),
15252 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15253 HDA_BIND_MUTE("Surround Playback Switch", 0x03, 2, HDA_INPUT),
15254 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
15255 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
15256 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT),
15257 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT),
15258 HDA_CODEC_MUTE("Speaker Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15259 HDA_BIND_MUTE("MuteCtrl Playback Switch", 0x0c, 2, HDA_INPUT),
15260 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15261 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15262 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15263 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15267 static struct hda_bind_ctls alc663_asus_bind_master_vol = {
15268 .ops = &snd_hda_bind_vol,
15270 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
15271 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
15276 static struct hda_bind_ctls alc663_asus_one_bind_switch = {
15277 .ops = &snd_hda_bind_sw,
15279 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
15280 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
15285 static struct snd_kcontrol_new alc663_m51va_mixer[] = {
15286 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
15287 HDA_BIND_SW("Master Playback Switch", &alc663_asus_one_bind_switch),
15288 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15289 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15293 static struct hda_bind_ctls alc663_asus_tree_bind_switch = {
15294 .ops = &snd_hda_bind_sw,
15296 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
15297 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
15298 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
15303 static struct snd_kcontrol_new alc663_two_hp_m1_mixer[] = {
15304 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
15305 HDA_BIND_SW("Master Playback Switch", &alc663_asus_tree_bind_switch),
15306 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15307 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15308 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15309 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15314 static struct hda_bind_ctls alc663_asus_four_bind_switch = {
15315 .ops = &snd_hda_bind_sw,
15317 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
15318 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
15319 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
15324 static struct snd_kcontrol_new alc663_two_hp_m2_mixer[] = {
15325 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
15326 HDA_BIND_SW("Master Playback Switch", &alc663_asus_four_bind_switch),
15327 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15328 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15329 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15330 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15334 static struct snd_kcontrol_new alc662_1bjd_mixer[] = {
15335 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15336 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
15337 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15338 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15339 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15340 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15341 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15345 static struct hda_bind_ctls alc663_asus_two_bind_master_vol = {
15346 .ops = &snd_hda_bind_vol,
15348 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
15349 HDA_COMPOSE_AMP_VAL(0x04, 3, 0, HDA_OUTPUT),
15354 static struct hda_bind_ctls alc663_asus_two_bind_switch = {
15355 .ops = &snd_hda_bind_sw,
15357 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
15358 HDA_COMPOSE_AMP_VAL(0x16, 3, 0, HDA_OUTPUT),
15363 static struct snd_kcontrol_new alc663_asus_21jd_clfe_mixer[] = {
15364 HDA_BIND_VOL("Master Playback Volume",
15365 &alc663_asus_two_bind_master_vol),
15366 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
15367 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15368 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
15369 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15370 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15374 static struct snd_kcontrol_new alc663_asus_15jd_clfe_mixer[] = {
15375 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
15376 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
15377 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15378 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
15379 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15380 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15384 static struct snd_kcontrol_new alc663_g71v_mixer[] = {
15385 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15386 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
15387 HDA_CODEC_VOLUME("Front Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15388 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
15389 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
15391 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15392 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15393 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15394 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15398 static struct snd_kcontrol_new alc663_g50v_mixer[] = {
15399 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15400 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
15401 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
15403 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15404 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15405 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15406 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15407 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15408 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15412 static struct snd_kcontrol_new alc662_chmode_mixer[] = {
15414 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
15415 .name = "Channel Mode",
15416 .info = alc_ch_mode_info,
15417 .get = alc_ch_mode_get,
15418 .put = alc_ch_mode_put,
15423 static struct hda_verb alc662_init_verbs[] = {
15424 /* ADC: mute amp left and right */
15425 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15426 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
15427 /* Front mixer: unmute input/output amp left and right (volume = 0) */
15429 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15430 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15431 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
15432 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
15433 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
15435 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15436 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15437 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15438 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15439 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15440 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15442 /* Front Pin: output 0 (0x0c) */
15443 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15444 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15446 /* Rear Pin: output 1 (0x0d) */
15447 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15448 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15450 /* CLFE Pin: output 2 (0x0e) */
15451 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15452 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15454 /* Mic (rear) pin: input vref at 80% */
15455 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
15456 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15457 /* Front Mic pin: input vref at 80% */
15458 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
15459 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15460 /* Line In pin: input */
15461 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15462 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15463 /* Line-2 In: Headphone output (output 0 - 0x0c) */
15464 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15465 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15466 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
15467 /* CD pin widget for input */
15468 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15470 /* FIXME: use matrix-type input source selection */
15471 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
15473 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15474 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15475 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
15476 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
15478 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15479 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15480 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
15481 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
15483 /* always trun on EAPD */
15484 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
15485 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
15490 static struct hda_verb alc662_sue_init_verbs[] = {
15491 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
15492 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
15496 static struct hda_verb alc662_eeepc_sue_init_verbs[] = {
15497 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15498 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15502 /* Set Unsolicited Event*/
15503 static struct hda_verb alc662_eeepc_ep20_sue_init_verbs[] = {
15504 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15505 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15510 * generic initialization of ADC, input mixers and output mixers
15512 static struct hda_verb alc662_auto_init_verbs[] = {
15514 * Unmute ADC and set the default input to mic-in
15516 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
15517 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15519 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
15521 * Note: PASD motherboards uses the Line In 2 as the input for front
15522 * panel mic (mic 2)
15524 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
15525 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15526 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15527 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
15528 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
15529 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
15532 * Set up output mixers (0x0c - 0x0f)
15534 /* set vol=0 to output mixers */
15535 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15536 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15537 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15539 /* set up input amps for analog loopback */
15540 /* Amp Indices: DAC = 0, mixer = 1 */
15541 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15542 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15543 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15544 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15545 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15546 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15549 /* FIXME: use matrix-type input source selection */
15550 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
15552 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15553 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15557 /* additional verbs for ALC663 */
15558 static struct hda_verb alc663_auto_init_verbs[] = {
15559 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15560 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15564 static struct hda_verb alc663_m51va_init_verbs[] = {
15565 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15566 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15567 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15568 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15569 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
15570 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15571 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
15572 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15573 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15577 static struct hda_verb alc663_21jd_amic_init_verbs[] = {
15578 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15579 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15580 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
15581 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15582 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15583 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15584 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15588 static struct hda_verb alc662_1bjd_amic_init_verbs[] = {
15589 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15590 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15591 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15592 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
15593 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15594 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15595 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15596 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15600 static struct hda_verb alc663_15jd_amic_init_verbs[] = {
15601 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15602 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15603 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
15604 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15605 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15606 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15607 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15611 static struct hda_verb alc663_two_hp_amic_m1_init_verbs[] = {
15612 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15613 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15614 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15615 {0x21, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
15616 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15617 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15618 {0x15, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
15619 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15620 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15621 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15622 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15623 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15627 static struct hda_verb alc663_two_hp_amic_m2_init_verbs[] = {
15628 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15629 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15630 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15631 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
15632 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15633 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15634 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
15635 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15636 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15637 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15638 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15639 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15643 static struct hda_verb alc663_g71v_init_verbs[] = {
15644 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15645 /* {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
15646 /* {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, */ /* Headphone */
15648 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15649 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15650 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
15652 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
15653 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_MIC_EVENT},
15654 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
15658 static struct hda_verb alc663_g50v_init_verbs[] = {
15659 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15660 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15661 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
15663 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15664 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15668 static struct hda_verb alc662_ecs_init_verbs[] = {
15669 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0x701f},
15670 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15671 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15672 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15676 static struct snd_kcontrol_new alc662_auto_capture_mixer[] = {
15677 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
15678 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
15682 static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
15684 unsigned int present;
15685 unsigned char bits;
15687 present = snd_hda_codec_read(codec, 0x14, 0,
15688 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
15689 bits = present ? HDA_AMP_MUTE : 0;
15690 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
15691 HDA_AMP_MUTE, bits);
15694 static void alc662_lenovo_101e_all_automute(struct hda_codec *codec)
15696 unsigned int present;
15697 unsigned char bits;
15699 present = snd_hda_codec_read(codec, 0x1b, 0,
15700 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
15701 bits = present ? HDA_AMP_MUTE : 0;
15702 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
15703 HDA_AMP_MUTE, bits);
15704 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
15705 HDA_AMP_MUTE, bits);
15708 static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec,
15711 if ((res >> 26) == ALC880_HP_EVENT)
15712 alc662_lenovo_101e_all_automute(codec);
15713 if ((res >> 26) == ALC880_FRONT_EVENT)
15714 alc662_lenovo_101e_ispeaker_automute(codec);
15717 static void alc662_eeepc_mic_automute(struct hda_codec *codec)
15719 unsigned int present;
15721 present = snd_hda_codec_read(codec, 0x18, 0,
15722 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
15723 snd_hda_codec_write(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
15724 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
15725 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
15726 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
15727 snd_hda_codec_write(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
15728 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
15729 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
15730 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
15733 /* unsolicited event for HP jack sensing */
15734 static void alc662_eeepc_unsol_event(struct hda_codec *codec,
15737 if ((res >> 26) == ALC880_HP_EVENT)
15738 alc262_hippo1_automute( codec );
15740 if ((res >> 26) == ALC880_MIC_EVENT)
15741 alc662_eeepc_mic_automute(codec);
15744 static void alc662_eeepc_inithook(struct hda_codec *codec)
15746 alc262_hippo1_automute( codec );
15747 alc662_eeepc_mic_automute(codec);
15750 static void alc662_eeepc_ep20_automute(struct hda_codec *codec)
15753 unsigned int present;
15755 snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
15756 present = snd_hda_codec_read(codec, 0x14, 0,
15757 AC_VERB_GET_PIN_SENSE, 0);
15758 present = (present & 0x80000000) != 0;
15760 /* mute internal speaker */
15761 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
15762 HDA_AMP_MUTE, HDA_AMP_MUTE);
15764 /* unmute internal speaker if necessary */
15765 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
15766 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
15767 HDA_AMP_MUTE, mute);
15771 /* unsolicited event for HP jack sensing */
15772 static void alc662_eeepc_ep20_unsol_event(struct hda_codec *codec,
15775 if ((res >> 26) == ALC880_HP_EVENT)
15776 alc662_eeepc_ep20_automute(codec);
15779 static void alc662_eeepc_ep20_inithook(struct hda_codec *codec)
15781 alc662_eeepc_ep20_automute(codec);
15784 static void alc663_m51va_speaker_automute(struct hda_codec *codec)
15786 unsigned int present;
15787 unsigned char bits;
15789 present = snd_hda_codec_read(codec, 0x21, 0,
15790 AC_VERB_GET_PIN_SENSE, 0)
15791 & AC_PINSENSE_PRESENCE;
15792 bits = present ? HDA_AMP_MUTE : 0;
15793 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
15794 AMP_IN_MUTE(0), bits);
15795 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
15796 AMP_IN_MUTE(0), bits);
15799 static void alc663_21jd_two_speaker_automute(struct hda_codec *codec)
15801 unsigned int present;
15802 unsigned char bits;
15804 present = snd_hda_codec_read(codec, 0x21, 0,
15805 AC_VERB_GET_PIN_SENSE, 0)
15806 & AC_PINSENSE_PRESENCE;
15807 bits = present ? HDA_AMP_MUTE : 0;
15808 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
15809 AMP_IN_MUTE(0), bits);
15810 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
15811 AMP_IN_MUTE(0), bits);
15812 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0,
15813 AMP_IN_MUTE(0), bits);
15814 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
15815 AMP_IN_MUTE(0), bits);
15818 static void alc663_15jd_two_speaker_automute(struct hda_codec *codec)
15820 unsigned int present;
15821 unsigned char bits;
15823 present = snd_hda_codec_read(codec, 0x15, 0,
15824 AC_VERB_GET_PIN_SENSE, 0)
15825 & AC_PINSENSE_PRESENCE;
15826 bits = present ? HDA_AMP_MUTE : 0;
15827 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
15828 AMP_IN_MUTE(0), bits);
15829 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
15830 AMP_IN_MUTE(0), bits);
15831 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0,
15832 AMP_IN_MUTE(0), bits);
15833 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
15834 AMP_IN_MUTE(0), bits);
15837 static void alc662_f5z_speaker_automute(struct hda_codec *codec)
15839 unsigned int present;
15840 unsigned char bits;
15842 present = snd_hda_codec_read(codec, 0x1b, 0,
15843 AC_VERB_GET_PIN_SENSE, 0)
15844 & AC_PINSENSE_PRESENCE;
15845 bits = present ? 0 : PIN_OUT;
15846 snd_hda_codec_write(codec, 0x14, 0,
15847 AC_VERB_SET_PIN_WIDGET_CONTROL, bits);
15850 static void alc663_two_hp_m1_speaker_automute(struct hda_codec *codec)
15852 unsigned int present1, present2;
15854 present1 = snd_hda_codec_read(codec, 0x21, 0,
15855 AC_VERB_GET_PIN_SENSE, 0)
15856 & AC_PINSENSE_PRESENCE;
15857 present2 = snd_hda_codec_read(codec, 0x15, 0,
15858 AC_VERB_GET_PIN_SENSE, 0)
15859 & AC_PINSENSE_PRESENCE;
15861 if (present1 || present2) {
15862 snd_hda_codec_write_cache(codec, 0x14, 0,
15863 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
15865 snd_hda_codec_write_cache(codec, 0x14, 0,
15866 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
15870 static void alc663_two_hp_m2_speaker_automute(struct hda_codec *codec)
15872 unsigned int present1, present2;
15874 present1 = snd_hda_codec_read(codec, 0x1b, 0,
15875 AC_VERB_GET_PIN_SENSE, 0)
15876 & AC_PINSENSE_PRESENCE;
15877 present2 = snd_hda_codec_read(codec, 0x15, 0,
15878 AC_VERB_GET_PIN_SENSE, 0)
15879 & AC_PINSENSE_PRESENCE;
15881 if (present1 || present2) {
15882 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
15883 AMP_IN_MUTE(0), AMP_IN_MUTE(0));
15884 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
15885 AMP_IN_MUTE(0), AMP_IN_MUTE(0));
15887 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
15888 AMP_IN_MUTE(0), 0);
15889 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
15890 AMP_IN_MUTE(0), 0);
15894 static void alc663_m51va_mic_automute(struct hda_codec *codec)
15896 unsigned int present;
15898 present = snd_hda_codec_read(codec, 0x18, 0,
15899 AC_VERB_GET_PIN_SENSE, 0)
15900 & AC_PINSENSE_PRESENCE;
15901 snd_hda_codec_write_cache(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
15902 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
15903 snd_hda_codec_write_cache(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
15904 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
15905 snd_hda_codec_write_cache(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
15906 0x7000 | (0x09 << 8) | (present ? 0x80 : 0));
15907 snd_hda_codec_write_cache(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
15908 0x7000 | (0x09 << 8) | (present ? 0x80 : 0));
15911 static void alc663_m51va_unsol_event(struct hda_codec *codec,
15914 switch (res >> 26) {
15915 case ALC880_HP_EVENT:
15916 alc663_m51va_speaker_automute(codec);
15918 case ALC880_MIC_EVENT:
15919 alc663_m51va_mic_automute(codec);
15924 static void alc663_m51va_inithook(struct hda_codec *codec)
15926 alc663_m51va_speaker_automute(codec);
15927 alc663_m51va_mic_automute(codec);
15930 /* ***************** Mode1 ******************************/
15931 static void alc663_mode1_unsol_event(struct hda_codec *codec,
15934 switch (res >> 26) {
15935 case ALC880_HP_EVENT:
15936 alc663_m51va_speaker_automute(codec);
15938 case ALC880_MIC_EVENT:
15939 alc662_eeepc_mic_automute(codec);
15944 static void alc663_mode1_inithook(struct hda_codec *codec)
15946 alc663_m51va_speaker_automute(codec);
15947 alc662_eeepc_mic_automute(codec);
15949 /* ***************** Mode2 ******************************/
15950 static void alc662_mode2_unsol_event(struct hda_codec *codec,
15953 switch (res >> 26) {
15954 case ALC880_HP_EVENT:
15955 alc662_f5z_speaker_automute(codec);
15957 case ALC880_MIC_EVENT:
15958 alc662_eeepc_mic_automute(codec);
15963 static void alc662_mode2_inithook(struct hda_codec *codec)
15965 alc662_f5z_speaker_automute(codec);
15966 alc662_eeepc_mic_automute(codec);
15968 /* ***************** Mode3 ******************************/
15969 static void alc663_mode3_unsol_event(struct hda_codec *codec,
15972 switch (res >> 26) {
15973 case ALC880_HP_EVENT:
15974 alc663_two_hp_m1_speaker_automute(codec);
15976 case ALC880_MIC_EVENT:
15977 alc662_eeepc_mic_automute(codec);
15982 static void alc663_mode3_inithook(struct hda_codec *codec)
15984 alc663_two_hp_m1_speaker_automute(codec);
15985 alc662_eeepc_mic_automute(codec);
15987 /* ***************** Mode4 ******************************/
15988 static void alc663_mode4_unsol_event(struct hda_codec *codec,
15991 switch (res >> 26) {
15992 case ALC880_HP_EVENT:
15993 alc663_21jd_two_speaker_automute(codec);
15995 case ALC880_MIC_EVENT:
15996 alc662_eeepc_mic_automute(codec);
16001 static void alc663_mode4_inithook(struct hda_codec *codec)
16003 alc663_21jd_two_speaker_automute(codec);
16004 alc662_eeepc_mic_automute(codec);
16006 /* ***************** Mode5 ******************************/
16007 static void alc663_mode5_unsol_event(struct hda_codec *codec,
16010 switch (res >> 26) {
16011 case ALC880_HP_EVENT:
16012 alc663_15jd_two_speaker_automute(codec);
16014 case ALC880_MIC_EVENT:
16015 alc662_eeepc_mic_automute(codec);
16020 static void alc663_mode5_inithook(struct hda_codec *codec)
16022 alc663_15jd_two_speaker_automute(codec);
16023 alc662_eeepc_mic_automute(codec);
16025 /* ***************** Mode6 ******************************/
16026 static void alc663_mode6_unsol_event(struct hda_codec *codec,
16029 switch (res >> 26) {
16030 case ALC880_HP_EVENT:
16031 alc663_two_hp_m2_speaker_automute(codec);
16033 case ALC880_MIC_EVENT:
16034 alc662_eeepc_mic_automute(codec);
16039 static void alc663_mode6_inithook(struct hda_codec *codec)
16041 alc663_two_hp_m2_speaker_automute(codec);
16042 alc662_eeepc_mic_automute(codec);
16045 static void alc663_g71v_hp_automute(struct hda_codec *codec)
16047 unsigned int present;
16048 unsigned char bits;
16050 present = snd_hda_codec_read(codec, 0x21, 0,
16051 AC_VERB_GET_PIN_SENSE, 0)
16052 & AC_PINSENSE_PRESENCE;
16053 bits = present ? HDA_AMP_MUTE : 0;
16054 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
16055 HDA_AMP_MUTE, bits);
16056 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
16057 HDA_AMP_MUTE, bits);
16060 static void alc663_g71v_front_automute(struct hda_codec *codec)
16062 unsigned int present;
16063 unsigned char bits;
16065 present = snd_hda_codec_read(codec, 0x15, 0,
16066 AC_VERB_GET_PIN_SENSE, 0)
16067 & AC_PINSENSE_PRESENCE;
16068 bits = present ? HDA_AMP_MUTE : 0;
16069 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
16070 HDA_AMP_MUTE, bits);
16073 static void alc663_g71v_unsol_event(struct hda_codec *codec,
16076 switch (res >> 26) {
16077 case ALC880_HP_EVENT:
16078 alc663_g71v_hp_automute(codec);
16080 case ALC880_FRONT_EVENT:
16081 alc663_g71v_front_automute(codec);
16083 case ALC880_MIC_EVENT:
16084 alc662_eeepc_mic_automute(codec);
16089 static void alc663_g71v_inithook(struct hda_codec *codec)
16091 alc663_g71v_front_automute(codec);
16092 alc663_g71v_hp_automute(codec);
16093 alc662_eeepc_mic_automute(codec);
16096 static void alc663_g50v_unsol_event(struct hda_codec *codec,
16099 switch (res >> 26) {
16100 case ALC880_HP_EVENT:
16101 alc663_m51va_speaker_automute(codec);
16103 case ALC880_MIC_EVENT:
16104 alc662_eeepc_mic_automute(codec);
16109 static void alc663_g50v_inithook(struct hda_codec *codec)
16111 alc663_m51va_speaker_automute(codec);
16112 alc662_eeepc_mic_automute(codec);
16115 /* bind hp and internal speaker mute (with plug check) */
16116 static int alc662_ecs_master_sw_put(struct snd_kcontrol *kcontrol,
16117 struct snd_ctl_elem_value *ucontrol)
16119 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
16120 long *valp = ucontrol->value.integer.value;
16123 change = snd_hda_codec_amp_update(codec, 0x1b, 0, HDA_OUTPUT, 0,
16125 valp[0] ? 0 : HDA_AMP_MUTE);
16126 change |= snd_hda_codec_amp_update(codec, 0x1b, 1, HDA_OUTPUT, 0,
16128 valp[1] ? 0 : HDA_AMP_MUTE);
16130 alc262_hippo1_automute(codec);
16134 static struct snd_kcontrol_new alc662_ecs_mixer[] = {
16135 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16137 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
16138 .name = "Master Playback Switch",
16139 .info = snd_hda_mixer_amp_switch_info,
16140 .get = snd_hda_mixer_amp_switch_get,
16141 .put = alc662_ecs_master_sw_put,
16142 .private_value = HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
16145 HDA_CODEC_VOLUME("e-Mic/LineIn Boost", 0x18, 0, HDA_INPUT),
16146 HDA_CODEC_VOLUME("e-Mic/LineIn Playback Volume", 0x0b, 0x0, HDA_INPUT),
16147 HDA_CODEC_MUTE("e-Mic/LineIn Playback Switch", 0x0b, 0x0, HDA_INPUT),
16149 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
16150 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16151 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16155 #ifdef CONFIG_SND_HDA_POWER_SAVE
16156 #define alc662_loopbacks alc880_loopbacks
16160 /* pcm configuration: identiacal with ALC880 */
16161 #define alc662_pcm_analog_playback alc880_pcm_analog_playback
16162 #define alc662_pcm_analog_capture alc880_pcm_analog_capture
16163 #define alc662_pcm_digital_playback alc880_pcm_digital_playback
16164 #define alc662_pcm_digital_capture alc880_pcm_digital_capture
16167 * configuration and preset
16169 static const char *alc662_models[ALC662_MODEL_LAST] = {
16170 [ALC662_3ST_2ch_DIG] = "3stack-dig",
16171 [ALC662_3ST_6ch_DIG] = "3stack-6ch-dig",
16172 [ALC662_3ST_6ch] = "3stack-6ch",
16173 [ALC662_5ST_DIG] = "6stack-dig",
16174 [ALC662_LENOVO_101E] = "lenovo-101e",
16175 [ALC662_ASUS_EEEPC_P701] = "eeepc-p701",
16176 [ALC662_ASUS_EEEPC_EP20] = "eeepc-ep20",
16177 [ALC662_ECS] = "ecs",
16178 [ALC663_ASUS_M51VA] = "m51va",
16179 [ALC663_ASUS_G71V] = "g71v",
16180 [ALC663_ASUS_H13] = "h13",
16181 [ALC663_ASUS_G50V] = "g50v",
16182 [ALC663_ASUS_MODE1] = "asus-mode1",
16183 [ALC662_ASUS_MODE2] = "asus-mode2",
16184 [ALC663_ASUS_MODE3] = "asus-mode3",
16185 [ALC663_ASUS_MODE4] = "asus-mode4",
16186 [ALC663_ASUS_MODE5] = "asus-mode5",
16187 [ALC663_ASUS_MODE6] = "asus-mode6",
16188 [ALC662_AUTO] = "auto",
16191 static struct snd_pci_quirk alc662_cfg_tbl[] = {
16192 SND_PCI_QUIRK(0x1019, 0x9087, "ECS", ALC662_ECS),
16193 SND_PCI_QUIRK(0x1043, 0x1000, "ASUS N50Vm", ALC663_ASUS_MODE1),
16194 SND_PCI_QUIRK(0x1043, 0x1092, "ASUS NB", ALC663_ASUS_MODE3),
16195 SND_PCI_QUIRK(0x1043, 0x11c3, "ASUS M70V", ALC663_ASUS_MODE3),
16196 SND_PCI_QUIRK(0x1043, 0x11d3, "ASUS NB", ALC663_ASUS_MODE1),
16197 SND_PCI_QUIRK(0x1043, 0x11f3, "ASUS NB", ALC662_ASUS_MODE2),
16198 SND_PCI_QUIRK(0x1043, 0x1203, "ASUS NB", ALC663_ASUS_MODE1),
16199 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS NB", ALC662_ASUS_MODE2),
16200 SND_PCI_QUIRK(0x1043, 0x16c3, "ASUS NB", ALC662_ASUS_MODE2),
16201 SND_PCI_QUIRK(0x1043, 0x1753, "ASUS NB", ALC662_ASUS_MODE2),
16202 SND_PCI_QUIRK(0x1043, 0x1763, "ASUS NB", ALC663_ASUS_MODE6),
16203 SND_PCI_QUIRK(0x1043, 0x1765, "ASUS NB", ALC663_ASUS_MODE6),
16204 SND_PCI_QUIRK(0x1043, 0x1783, "ASUS NB", ALC662_ASUS_MODE2),
16205 SND_PCI_QUIRK(0x1043, 0x1813, "ASUS NB", ALC662_ASUS_MODE2),
16206 SND_PCI_QUIRK(0x1043, 0x1823, "ASUS NB", ALC663_ASUS_MODE5),
16207 SND_PCI_QUIRK(0x1043, 0x1833, "ASUS NB", ALC663_ASUS_MODE6),
16208 SND_PCI_QUIRK(0x1043, 0x1843, "ASUS NB", ALC662_ASUS_MODE2),
16209 SND_PCI_QUIRK(0x1043, 0x1864, "ASUS NB", ALC662_ASUS_MODE2),
16210 SND_PCI_QUIRK(0x1043, 0x1876, "ASUS NB", ALC662_ASUS_MODE2),
16211 SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M51VA", ALC663_ASUS_M51VA),
16212 /*SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M50Vr", ALC663_ASUS_MODE1),*/
16213 SND_PCI_QUIRK(0x1043, 0x1893, "ASUS M50Vm", ALC663_ASUS_MODE3),
16214 SND_PCI_QUIRK(0x1043, 0x1894, "ASUS X55", ALC663_ASUS_MODE3),
16215 SND_PCI_QUIRK(0x1043, 0x1903, "ASUS F5GL", ALC663_ASUS_MODE1),
16216 SND_PCI_QUIRK(0x1043, 0x1913, "ASUS NB", ALC662_ASUS_MODE2),
16217 SND_PCI_QUIRK(0x1043, 0x1933, "ASUS F80Q", ALC662_ASUS_MODE2),
16218 SND_PCI_QUIRK(0x1043, 0x1953, "ASUS NB", ALC663_ASUS_MODE1),
16219 SND_PCI_QUIRK(0x1043, 0x1963, "ASUS X71C", ALC663_ASUS_MODE3),
16220 SND_PCI_QUIRK(0x1043, 0x1993, "ASUS N20", ALC663_ASUS_MODE1),
16221 SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS G50V", ALC663_ASUS_G50V),
16222 /*SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS NB", ALC663_ASUS_MODE1),*/
16223 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS F7Z", ALC663_ASUS_MODE1),
16224 SND_PCI_QUIRK(0x1043, 0x19c3, "ASUS F5Z/F6x", ALC662_ASUS_MODE2),
16225 SND_PCI_QUIRK(0x1043, 0x19e3, "ASUS NB", ALC663_ASUS_MODE1),
16226 SND_PCI_QUIRK(0x1043, 0x19f3, "ASUS NB", ALC663_ASUS_MODE4),
16227 SND_PCI_QUIRK(0x1043, 0x8290, "ASUS P5GC-MX", ALC662_3ST_6ch_DIG),
16228 SND_PCI_QUIRK(0x1043, 0x82a1, "ASUS Eeepc", ALC662_ASUS_EEEPC_P701),
16229 SND_PCI_QUIRK(0x1043, 0x82d1, "ASUS Eeepc EP20", ALC662_ASUS_EEEPC_EP20),
16230 SND_PCI_QUIRK(0x105b, 0x0cd6, "Foxconn", ALC662_ECS),
16231 SND_PCI_QUIRK(0x105b, 0x0d47, "Foxconn 45CMX/45GMX/45CMX-K",
16232 ALC662_3ST_6ch_DIG),
16233 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte 945GCM-S2L",
16234 ALC662_3ST_6ch_DIG),
16235 SND_PCI_QUIRK(0x1565, 0x820f, "Biostar TA780G M2+", ALC662_3ST_6ch_DIG),
16236 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E),
16237 SND_PCI_QUIRK(0x1849, 0x3662, "ASROCK K10N78FullHD-hSLI R3.0",
16238 ALC662_3ST_6ch_DIG),
16239 SND_PCI_QUIRK_MASK(0x1854, 0xf000, 0x2000, "ASUS H13-200x",
16244 static struct alc_config_preset alc662_presets[] = {
16245 [ALC662_3ST_2ch_DIG] = {
16246 .mixers = { alc662_3ST_2ch_mixer },
16247 .init_verbs = { alc662_init_verbs },
16248 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16249 .dac_nids = alc662_dac_nids,
16250 .dig_out_nid = ALC662_DIGOUT_NID,
16251 .dig_in_nid = ALC662_DIGIN_NID,
16252 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16253 .channel_mode = alc662_3ST_2ch_modes,
16254 .input_mux = &alc662_capture_source,
16256 [ALC662_3ST_6ch_DIG] = {
16257 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
16258 .init_verbs = { alc662_init_verbs },
16259 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16260 .dac_nids = alc662_dac_nids,
16261 .dig_out_nid = ALC662_DIGOUT_NID,
16262 .dig_in_nid = ALC662_DIGIN_NID,
16263 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
16264 .channel_mode = alc662_3ST_6ch_modes,
16266 .input_mux = &alc662_capture_source,
16268 [ALC662_3ST_6ch] = {
16269 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
16270 .init_verbs = { alc662_init_verbs },
16271 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16272 .dac_nids = alc662_dac_nids,
16273 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
16274 .channel_mode = alc662_3ST_6ch_modes,
16276 .input_mux = &alc662_capture_source,
16278 [ALC662_5ST_DIG] = {
16279 .mixers = { alc662_base_mixer, alc662_chmode_mixer },
16280 .init_verbs = { alc662_init_verbs },
16281 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16282 .dac_nids = alc662_dac_nids,
16283 .dig_out_nid = ALC662_DIGOUT_NID,
16284 .dig_in_nid = ALC662_DIGIN_NID,
16285 .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes),
16286 .channel_mode = alc662_5stack_modes,
16287 .input_mux = &alc662_capture_source,
16289 [ALC662_LENOVO_101E] = {
16290 .mixers = { alc662_lenovo_101e_mixer },
16291 .init_verbs = { alc662_init_verbs, alc662_sue_init_verbs },
16292 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16293 .dac_nids = alc662_dac_nids,
16294 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16295 .channel_mode = alc662_3ST_2ch_modes,
16296 .input_mux = &alc662_lenovo_101e_capture_source,
16297 .unsol_event = alc662_lenovo_101e_unsol_event,
16298 .init_hook = alc662_lenovo_101e_all_automute,
16300 [ALC662_ASUS_EEEPC_P701] = {
16301 .mixers = { alc662_eeepc_p701_mixer },
16302 .init_verbs = { alc662_init_verbs,
16303 alc662_eeepc_sue_init_verbs },
16304 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16305 .dac_nids = alc662_dac_nids,
16306 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16307 .channel_mode = alc662_3ST_2ch_modes,
16308 .input_mux = &alc662_eeepc_capture_source,
16309 .unsol_event = alc662_eeepc_unsol_event,
16310 .init_hook = alc662_eeepc_inithook,
16312 [ALC662_ASUS_EEEPC_EP20] = {
16313 .mixers = { alc662_eeepc_ep20_mixer,
16314 alc662_chmode_mixer },
16315 .init_verbs = { alc662_init_verbs,
16316 alc662_eeepc_ep20_sue_init_verbs },
16317 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16318 .dac_nids = alc662_dac_nids,
16319 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
16320 .channel_mode = alc662_3ST_6ch_modes,
16321 .input_mux = &alc662_lenovo_101e_capture_source,
16322 .unsol_event = alc662_eeepc_ep20_unsol_event,
16323 .init_hook = alc662_eeepc_ep20_inithook,
16326 .mixers = { alc662_ecs_mixer },
16327 .init_verbs = { alc662_init_verbs,
16328 alc662_ecs_init_verbs },
16329 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16330 .dac_nids = alc662_dac_nids,
16331 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16332 .channel_mode = alc662_3ST_2ch_modes,
16333 .input_mux = &alc662_eeepc_capture_source,
16334 .unsol_event = alc662_eeepc_unsol_event,
16335 .init_hook = alc662_eeepc_inithook,
16337 [ALC663_ASUS_M51VA] = {
16338 .mixers = { alc663_m51va_mixer },
16339 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
16340 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16341 .dac_nids = alc662_dac_nids,
16342 .dig_out_nid = ALC662_DIGOUT_NID,
16343 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16344 .channel_mode = alc662_3ST_2ch_modes,
16345 .input_mux = &alc663_m51va_capture_source,
16346 .unsol_event = alc663_m51va_unsol_event,
16347 .init_hook = alc663_m51va_inithook,
16349 [ALC663_ASUS_G71V] = {
16350 .mixers = { alc663_g71v_mixer },
16351 .init_verbs = { alc662_init_verbs, alc663_g71v_init_verbs },
16352 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16353 .dac_nids = alc662_dac_nids,
16354 .dig_out_nid = ALC662_DIGOUT_NID,
16355 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16356 .channel_mode = alc662_3ST_2ch_modes,
16357 .input_mux = &alc662_eeepc_capture_source,
16358 .unsol_event = alc663_g71v_unsol_event,
16359 .init_hook = alc663_g71v_inithook,
16361 [ALC663_ASUS_H13] = {
16362 .mixers = { alc663_m51va_mixer },
16363 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
16364 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16365 .dac_nids = alc662_dac_nids,
16366 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16367 .channel_mode = alc662_3ST_2ch_modes,
16368 .input_mux = &alc663_m51va_capture_source,
16369 .unsol_event = alc663_m51va_unsol_event,
16370 .init_hook = alc663_m51va_inithook,
16372 [ALC663_ASUS_G50V] = {
16373 .mixers = { alc663_g50v_mixer },
16374 .init_verbs = { alc662_init_verbs, alc663_g50v_init_verbs },
16375 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16376 .dac_nids = alc662_dac_nids,
16377 .dig_out_nid = ALC662_DIGOUT_NID,
16378 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
16379 .channel_mode = alc662_3ST_6ch_modes,
16380 .input_mux = &alc663_capture_source,
16381 .unsol_event = alc663_g50v_unsol_event,
16382 .init_hook = alc663_g50v_inithook,
16384 [ALC663_ASUS_MODE1] = {
16385 .mixers = { alc663_m51va_mixer },
16386 .cap_mixer = alc662_auto_capture_mixer,
16387 .init_verbs = { alc662_init_verbs,
16388 alc663_21jd_amic_init_verbs },
16389 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16391 .dac_nids = alc662_dac_nids,
16392 .dig_out_nid = ALC662_DIGOUT_NID,
16393 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16394 .channel_mode = alc662_3ST_2ch_modes,
16395 .input_mux = &alc662_eeepc_capture_source,
16396 .unsol_event = alc663_mode1_unsol_event,
16397 .init_hook = alc663_mode1_inithook,
16399 [ALC662_ASUS_MODE2] = {
16400 .mixers = { alc662_1bjd_mixer },
16401 .cap_mixer = alc662_auto_capture_mixer,
16402 .init_verbs = { alc662_init_verbs,
16403 alc662_1bjd_amic_init_verbs },
16404 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16405 .dac_nids = alc662_dac_nids,
16406 .dig_out_nid = ALC662_DIGOUT_NID,
16407 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16408 .channel_mode = alc662_3ST_2ch_modes,
16409 .input_mux = &alc662_eeepc_capture_source,
16410 .unsol_event = alc662_mode2_unsol_event,
16411 .init_hook = alc662_mode2_inithook,
16413 [ALC663_ASUS_MODE3] = {
16414 .mixers = { alc663_two_hp_m1_mixer },
16415 .cap_mixer = alc662_auto_capture_mixer,
16416 .init_verbs = { alc662_init_verbs,
16417 alc663_two_hp_amic_m1_init_verbs },
16418 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16420 .dac_nids = alc662_dac_nids,
16421 .dig_out_nid = ALC662_DIGOUT_NID,
16422 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16423 .channel_mode = alc662_3ST_2ch_modes,
16424 .input_mux = &alc662_eeepc_capture_source,
16425 .unsol_event = alc663_mode3_unsol_event,
16426 .init_hook = alc663_mode3_inithook,
16428 [ALC663_ASUS_MODE4] = {
16429 .mixers = { alc663_asus_21jd_clfe_mixer },
16430 .cap_mixer = alc662_auto_capture_mixer,
16431 .init_verbs = { alc662_init_verbs,
16432 alc663_21jd_amic_init_verbs},
16433 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16435 .dac_nids = alc662_dac_nids,
16436 .dig_out_nid = ALC662_DIGOUT_NID,
16437 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16438 .channel_mode = alc662_3ST_2ch_modes,
16439 .input_mux = &alc662_eeepc_capture_source,
16440 .unsol_event = alc663_mode4_unsol_event,
16441 .init_hook = alc663_mode4_inithook,
16443 [ALC663_ASUS_MODE5] = {
16444 .mixers = { alc663_asus_15jd_clfe_mixer },
16445 .cap_mixer = alc662_auto_capture_mixer,
16446 .init_verbs = { alc662_init_verbs,
16447 alc663_15jd_amic_init_verbs },
16448 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16450 .dac_nids = alc662_dac_nids,
16451 .dig_out_nid = ALC662_DIGOUT_NID,
16452 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16453 .channel_mode = alc662_3ST_2ch_modes,
16454 .input_mux = &alc662_eeepc_capture_source,
16455 .unsol_event = alc663_mode5_unsol_event,
16456 .init_hook = alc663_mode5_inithook,
16458 [ALC663_ASUS_MODE6] = {
16459 .mixers = { alc663_two_hp_m2_mixer },
16460 .cap_mixer = alc662_auto_capture_mixer,
16461 .init_verbs = { alc662_init_verbs,
16462 alc663_two_hp_amic_m2_init_verbs },
16463 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16465 .dac_nids = alc662_dac_nids,
16466 .dig_out_nid = ALC662_DIGOUT_NID,
16467 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16468 .channel_mode = alc662_3ST_2ch_modes,
16469 .input_mux = &alc662_eeepc_capture_source,
16470 .unsol_event = alc663_mode6_unsol_event,
16471 .init_hook = alc663_mode6_inithook,
16477 * BIOS auto configuration
16480 /* add playback controls from the parsed DAC table */
16481 static int alc662_auto_create_multi_out_ctls(struct alc_spec *spec,
16482 const struct auto_pin_cfg *cfg)
16485 static const char *chname[4] = {
16486 "Front", "Surround", NULL /*CLFE*/, "Side"
16491 for (i = 0; i < cfg->line_outs; i++) {
16492 if (!spec->multiout.dac_nids[i])
16494 nid = alc880_idx_to_dac(i);
16497 err = add_control(spec, ALC_CTL_WIDGET_VOL,
16498 "Center Playback Volume",
16499 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
16503 err = add_control(spec, ALC_CTL_WIDGET_VOL,
16504 "LFE Playback Volume",
16505 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
16509 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
16510 "Center Playback Switch",
16511 HDA_COMPOSE_AMP_VAL(0x0e, 1, 0,
16515 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
16516 "LFE Playback Switch",
16517 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
16522 sprintf(name, "%s Playback Volume", chname[i]);
16523 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
16524 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
16528 sprintf(name, "%s Playback Switch", chname[i]);
16529 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
16530 HDA_COMPOSE_AMP_VAL(alc880_idx_to_mixer(i),
16539 /* add playback controls for speaker and HP outputs */
16540 static int alc662_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
16551 /* ALC663 has a mono output pin on 0x17 */
16552 sprintf(name, "%s Playback Switch", pfx);
16553 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
16554 HDA_COMPOSE_AMP_VAL(pin, 2, 0, HDA_OUTPUT));
16558 if (alc880_is_fixed_pin(pin)) {
16559 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
16560 /* printk(KERN_DEBUG "DAC nid=%x\n",nid); */
16561 /* specify the DAC as the extra output */
16562 if (!spec->multiout.hp_nid)
16563 spec->multiout.hp_nid = nid;
16565 spec->multiout.extra_out_nid[0] = nid;
16566 /* control HP volume/switch on the output mixer amp */
16567 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
16568 sprintf(name, "%s Playback Volume", pfx);
16569 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
16570 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
16573 sprintf(name, "%s Playback Switch", pfx);
16574 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
16575 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
16578 } else if (alc880_is_multi_pin(pin)) {
16579 /* set manual connection */
16580 /* we have only a switch on HP-out PIN */
16581 sprintf(name, "%s Playback Switch", pfx);
16582 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
16583 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
16590 /* create playback/capture controls for input pins */
16591 static int alc662_auto_create_analog_input_ctls(struct alc_spec *spec,
16592 const struct auto_pin_cfg *cfg)
16594 struct hda_input_mux *imux = &spec->private_imux[0];
16597 for (i = 0; i < AUTO_PIN_LAST; i++) {
16598 if (alc880_is_input_pin(cfg->input_pins[i])) {
16599 idx = alc880_input_pin_idx(cfg->input_pins[i]);
16600 err = new_analog_input(spec, cfg->input_pins[i],
16601 auto_pin_cfg_labels[i],
16605 imux->items[imux->num_items].label =
16606 auto_pin_cfg_labels[i];
16607 imux->items[imux->num_items].index =
16608 alc880_input_pin_idx(cfg->input_pins[i]);
16615 static void alc662_auto_set_output_and_unmute(struct hda_codec *codec,
16616 hda_nid_t nid, int pin_type,
16619 alc_set_pin_output(codec, nid, pin_type);
16620 /* need the manual connection? */
16621 if (alc880_is_multi_pin(nid)) {
16622 struct alc_spec *spec = codec->spec;
16623 int idx = alc880_multi_pin_idx(nid);
16624 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
16625 AC_VERB_SET_CONNECT_SEL,
16626 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
16630 static void alc662_auto_init_multi_out(struct hda_codec *codec)
16632 struct alc_spec *spec = codec->spec;
16635 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
16636 for (i = 0; i <= HDA_SIDE; i++) {
16637 hda_nid_t nid = spec->autocfg.line_out_pins[i];
16638 int pin_type = get_pin_type(spec->autocfg.line_out_type);
16640 alc662_auto_set_output_and_unmute(codec, nid, pin_type,
16645 static void alc662_auto_init_hp_out(struct hda_codec *codec)
16647 struct alc_spec *spec = codec->spec;
16650 pin = spec->autocfg.hp_pins[0];
16651 if (pin) /* connect to front */
16653 alc662_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
16654 pin = spec->autocfg.speaker_pins[0];
16656 alc662_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
16659 #define alc662_is_input_pin(nid) alc880_is_input_pin(nid)
16660 #define ALC662_PIN_CD_NID ALC880_PIN_CD_NID
16662 static void alc662_auto_init_analog_input(struct hda_codec *codec)
16664 struct alc_spec *spec = codec->spec;
16667 for (i = 0; i < AUTO_PIN_LAST; i++) {
16668 hda_nid_t nid = spec->autocfg.input_pins[i];
16669 if (alc662_is_input_pin(nid)) {
16670 snd_hda_codec_write(codec, nid, 0,
16671 AC_VERB_SET_PIN_WIDGET_CONTROL,
16672 (i <= AUTO_PIN_FRONT_MIC ?
16673 PIN_VREF80 : PIN_IN));
16674 if (nid != ALC662_PIN_CD_NID)
16675 snd_hda_codec_write(codec, nid, 0,
16676 AC_VERB_SET_AMP_GAIN_MUTE,
16682 #define alc662_auto_init_input_src alc882_auto_init_input_src
16684 static int alc662_parse_auto_config(struct hda_codec *codec)
16686 struct alc_spec *spec = codec->spec;
16688 static hda_nid_t alc662_ignore[] = { 0x1d, 0 };
16690 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
16694 if (!spec->autocfg.line_outs)
16695 return 0; /* can't find valid BIOS pin config */
16697 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
16700 err = alc662_auto_create_multi_out_ctls(spec, &spec->autocfg);
16703 err = alc662_auto_create_extra_out(spec,
16704 spec->autocfg.speaker_pins[0],
16708 err = alc662_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
16712 err = alc662_auto_create_analog_input_ctls(spec, &spec->autocfg);
16716 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
16718 if (spec->autocfg.dig_outs)
16719 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
16721 if (spec->kctls.list)
16722 add_mixer(spec, spec->kctls.list);
16724 spec->num_mux_defs = 1;
16725 spec->input_mux = &spec->private_imux[0];
16727 add_verb(spec, alc662_auto_init_verbs);
16728 if (codec->vendor_id == 0x10ec0663)
16729 add_verb(spec, alc663_auto_init_verbs);
16731 err = alc_auto_add_mic_boost(codec);
16735 store_pin_configs(codec);
16739 /* additional initialization for auto-configuration model */
16740 static void alc662_auto_init(struct hda_codec *codec)
16742 struct alc_spec *spec = codec->spec;
16743 alc662_auto_init_multi_out(codec);
16744 alc662_auto_init_hp_out(codec);
16745 alc662_auto_init_analog_input(codec);
16746 alc662_auto_init_input_src(codec);
16747 if (spec->unsol_event)
16748 alc_inithook(codec);
16751 static int patch_alc662(struct hda_codec *codec)
16753 struct alc_spec *spec;
16754 int err, board_config;
16756 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
16760 codec->spec = spec;
16762 alc_fix_pll_init(codec, 0x20, 0x04, 15);
16764 board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST,
16767 if (board_config < 0) {
16768 printk(KERN_INFO "hda_codec: Unknown model for ALC662, "
16769 "trying auto-probe from BIOS...\n");
16770 board_config = ALC662_AUTO;
16773 if (board_config == ALC662_AUTO) {
16774 /* automatic parse from the BIOS config */
16775 err = alc662_parse_auto_config(codec);
16781 "hda_codec: Cannot set up configuration "
16782 "from BIOS. Using base mode...\n");
16783 board_config = ALC662_3ST_2ch_DIG;
16787 err = snd_hda_attach_beep_device(codec, 0x1);
16793 if (board_config != ALC662_AUTO)
16794 setup_preset(spec, &alc662_presets[board_config]);
16796 if (codec->vendor_id == 0x10ec0663) {
16797 spec->stream_name_analog = "ALC663 Analog";
16798 spec->stream_name_digital = "ALC663 Digital";
16799 } else if (codec->vendor_id == 0x10ec0272) {
16800 spec->stream_name_analog = "ALC272 Analog";
16801 spec->stream_name_digital = "ALC272 Digital";
16803 spec->stream_name_analog = "ALC662 Analog";
16804 spec->stream_name_digital = "ALC662 Digital";
16807 spec->stream_analog_playback = &alc662_pcm_analog_playback;
16808 spec->stream_analog_capture = &alc662_pcm_analog_capture;
16810 spec->stream_digital_playback = &alc662_pcm_digital_playback;
16811 spec->stream_digital_capture = &alc662_pcm_digital_capture;
16813 spec->adc_nids = alc662_adc_nids;
16814 spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids);
16815 spec->capsrc_nids = alc662_capsrc_nids;
16816 spec->capture_style = CAPT_MIX;
16818 if (!spec->cap_mixer)
16819 set_capture_mixer(spec);
16820 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
16822 spec->vmaster_nid = 0x02;
16824 codec->patch_ops = alc_patch_ops;
16825 if (board_config == ALC662_AUTO)
16826 spec->init_hook = alc662_auto_init;
16827 #ifdef CONFIG_SND_HDA_POWER_SAVE
16828 if (!spec->loopback.amplist)
16829 spec->loopback.amplist = alc662_loopbacks;
16831 codec->proc_widget_hook = print_realtek_coef;
16839 static struct hda_codec_preset snd_hda_preset_realtek[] = {
16840 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
16841 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
16842 { .id = 0x10ec0267, .name = "ALC267", .patch = patch_alc268 },
16843 { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 },
16844 { .id = 0x10ec0269, .name = "ALC269", .patch = patch_alc269 },
16845 { .id = 0x10ec0272, .name = "ALC272", .patch = patch_alc662 },
16846 { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
16847 .patch = patch_alc861 },
16848 { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
16849 { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
16850 { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
16851 { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2",
16852 .patch = patch_alc883 },
16853 { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
16854 .patch = patch_alc662 },
16855 { .id = 0x10ec0663, .name = "ALC663", .patch = patch_alc662 },
16856 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
16857 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
16858 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc883 },
16859 { .id = 0x10ec0885, .rev = 0x100101, .name = "ALC889A",
16860 .patch = patch_alc882 }, /* should be patch_alc883() in future */
16861 { .id = 0x10ec0885, .rev = 0x100103, .name = "ALC889A",
16862 .patch = patch_alc882 }, /* should be patch_alc883() in future */
16863 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
16864 { .id = 0x10ec0887, .name = "ALC887", .patch = patch_alc883 },
16865 { .id = 0x10ec0888, .rev = 0x100101, .name = "ALC1200",
16866 .patch = patch_alc883 },
16867 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc883 },
16868 { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc883 },
16869 {} /* terminator */
16872 MODULE_ALIAS("snd-hda-codec-id:10ec*");
16874 MODULE_LICENSE("GPL");
16875 MODULE_DESCRIPTION("Realtek HD-audio codec");
16877 static struct hda_codec_preset_list realtek_list = {
16878 .preset = snd_hda_preset_realtek,
16879 .owner = THIS_MODULE,
16882 static int __init patch_realtek_init(void)
16884 return snd_hda_add_codec_preset(&realtek_list);
16887 static void __exit patch_realtek_exit(void)
16889 snd_hda_delete_codec_preset(&realtek_list);
16892 module_init(patch_realtek_init)
16893 module_exit(patch_realtek_exit)