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 */
82 #ifdef CONFIG_SND_DEBUG
86 ALC260_MODEL_LAST /* last tag */
96 ALC262_HP_BPC_D7000_WL,
97 ALC262_HP_BPC_D7000_WF,
110 ALC262_MODEL_LAST /* last tag */
120 ALC268_ACER_ASPIRE_ONE,
123 #ifdef CONFIG_SND_DEBUG
127 ALC268_MODEL_LAST /* last tag */
142 ALC269_MODEL_LAST /* last tag */
159 /* ALC861-VD models */
181 ALC662_ASUS_EEEPC_P701,
182 ALC662_ASUS_EEEPC_EP20,
224 ALC883_TARGA_2ch_DIG,
225 ALC883_TARGA_8ch_DIG,
228 ALC888_ACER_ASPIRE_4930G,
229 ALC888_ACER_ASPIRE_6530G,
230 ALC888_ACER_ASPIRE_8930G,
231 ALC888_ACER_ASPIRE_7730G,
234 ALC883_MEDION_WIM2160,
236 ALC883_LENOVO_101E_2ch,
237 ALC883_LENOVO_NB0763,
238 ALC888_LENOVO_MS7195_DIG,
246 ALC883_FUJITSU_PI2515,
247 ALC888_FUJITSU_XA3530,
248 ALC883_3ST_6ch_INTEL,
268 #define GPIO_MASK 0x03
270 /* extra amp-initialization sequence types */
279 struct alc_mic_route {
281 unsigned char mux_idx;
282 unsigned char amix_idx;
285 #define MUX_IDX_UNDEF ((unsigned char)-1)
287 struct alc_customize_define {
288 unsigned int sku_cfg;
289 unsigned char port_connectivity;
290 unsigned char check_sum;
291 unsigned char customization;
292 unsigned char external_amp;
293 unsigned int enable_pcbeep:1;
294 unsigned int platform_type:1;
296 unsigned int override:1;
300 /* codec parameterization */
301 struct snd_kcontrol_new *mixers[5]; /* mixer arrays */
302 unsigned int num_mixers;
303 struct snd_kcontrol_new *cap_mixer; /* capture mixer */
304 unsigned int beep_amp; /* beep amp value, set via set_beep_amp() */
306 const struct hda_verb *init_verbs[10]; /* initialization verbs
310 unsigned int num_init_verbs;
312 char stream_name_analog[32]; /* analog PCM stream */
313 struct hda_pcm_stream *stream_analog_playback;
314 struct hda_pcm_stream *stream_analog_capture;
315 struct hda_pcm_stream *stream_analog_alt_playback;
316 struct hda_pcm_stream *stream_analog_alt_capture;
318 char stream_name_digital[32]; /* digital PCM stream */
319 struct hda_pcm_stream *stream_digital_playback;
320 struct hda_pcm_stream *stream_digital_capture;
323 struct hda_multi_out multiout; /* playback set-up
324 * max_channels, dacs must be set
325 * dig_out_nid and hp_nid are optional
327 hda_nid_t alt_dac_nid;
328 hda_nid_t slave_dig_outs[3]; /* optional - for auto-parsing */
332 unsigned int num_adc_nids;
334 hda_nid_t *capsrc_nids;
335 hda_nid_t dig_in_nid; /* digital-in NID; optional */
337 /* capture setup for dynamic dual-adc switch */
338 unsigned int cur_adc_idx;
340 unsigned int cur_adc_stream_tag;
341 unsigned int cur_adc_format;
344 unsigned int num_mux_defs;
345 const struct hda_input_mux *input_mux;
346 unsigned int cur_mux[3];
347 struct alc_mic_route ext_mic;
348 struct alc_mic_route int_mic;
351 const struct hda_channel_mode *channel_mode;
352 int num_channel_mode;
354 int const_channel_count;
355 int ext_channel_count;
357 /* PCM information */
358 struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */
360 /* dynamic controls, init_verbs and input_mux */
361 struct auto_pin_cfg autocfg;
362 struct alc_customize_define cdefine;
363 struct snd_array kctls;
364 struct hda_input_mux private_imux[3];
365 hda_nid_t private_dac_nids[AUTO_CFG_MAX_OUTS];
366 hda_nid_t private_adc_nids[AUTO_CFG_MAX_OUTS];
367 hda_nid_t private_capsrc_nids[AUTO_CFG_MAX_OUTS];
370 void (*init_hook)(struct hda_codec *codec);
371 void (*unsol_event)(struct hda_codec *codec, unsigned int res);
372 #ifdef CONFIG_SND_HDA_POWER_SAVE
373 void (*power_hook)(struct hda_codec *codec);
376 /* for pin sensing */
377 unsigned int sense_updated: 1;
378 unsigned int jack_present: 1;
379 unsigned int master_sw: 1;
380 unsigned int auto_mic:1;
383 unsigned int no_analog :1; /* digital I/O only */
384 unsigned int dual_adc_switch:1; /* switch ADCs (for ALC275) */
387 /* for virtual master */
388 hda_nid_t vmaster_nid;
389 #ifdef CONFIG_SND_HDA_POWER_SAVE
390 struct hda_loopback_check loopback;
395 unsigned int pll_coef_idx, pll_coef_bit;
399 * configuration template - to be copied to the spec instance
401 struct alc_config_preset {
402 struct snd_kcontrol_new *mixers[5]; /* should be identical size
405 struct snd_kcontrol_new *cap_mixer; /* capture mixer */
406 const struct hda_verb *init_verbs[5];
407 unsigned int num_dacs;
409 hda_nid_t dig_out_nid; /* optional */
410 hda_nid_t hp_nid; /* optional */
411 hda_nid_t *slave_dig_outs;
412 unsigned int num_adc_nids;
414 hda_nid_t *capsrc_nids;
415 hda_nid_t dig_in_nid;
416 unsigned int num_channel_mode;
417 const struct hda_channel_mode *channel_mode;
419 int const_channel_count;
420 unsigned int num_mux_defs;
421 const struct hda_input_mux *input_mux;
422 void (*unsol_event)(struct hda_codec *, unsigned int);
423 void (*setup)(struct hda_codec *);
424 void (*init_hook)(struct hda_codec *);
425 #ifdef CONFIG_SND_HDA_POWER_SAVE
426 struct hda_amp_list *loopbacks;
427 void (*power_hook)(struct hda_codec *codec);
435 static int alc_mux_enum_info(struct snd_kcontrol *kcontrol,
436 struct snd_ctl_elem_info *uinfo)
438 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
439 struct alc_spec *spec = codec->spec;
440 unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id);
441 if (mux_idx >= spec->num_mux_defs)
443 if (!spec->input_mux[mux_idx].num_items && mux_idx > 0)
445 return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo);
448 static int alc_mux_enum_get(struct snd_kcontrol *kcontrol,
449 struct snd_ctl_elem_value *ucontrol)
451 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
452 struct alc_spec *spec = codec->spec;
453 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
455 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
459 static int alc_mux_enum_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 const struct hda_input_mux *imux;
465 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
466 unsigned int mux_idx;
467 hda_nid_t nid = spec->capsrc_nids ?
468 spec->capsrc_nids[adc_idx] : spec->adc_nids[adc_idx];
471 mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx;
472 imux = &spec->input_mux[mux_idx];
473 if (!imux->num_items && mux_idx > 0)
474 imux = &spec->input_mux[0];
476 type = get_wcaps_type(get_wcaps(codec, nid));
477 if (type == AC_WID_AUD_MIX) {
478 /* Matrix-mixer style (e.g. ALC882) */
479 unsigned int *cur_val = &spec->cur_mux[adc_idx];
482 idx = ucontrol->value.enumerated.item[0];
483 if (idx >= imux->num_items)
484 idx = imux->num_items - 1;
487 for (i = 0; i < imux->num_items; i++) {
488 unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
489 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
490 imux->items[i].index,
496 /* MUX style (e.g. ALC880) */
497 return snd_hda_input_mux_put(codec, imux, ucontrol, nid,
498 &spec->cur_mux[adc_idx]);
503 * channel mode setting
505 static int alc_ch_mode_info(struct snd_kcontrol *kcontrol,
506 struct snd_ctl_elem_info *uinfo)
508 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
509 struct alc_spec *spec = codec->spec;
510 return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
511 spec->num_channel_mode);
514 static int alc_ch_mode_get(struct snd_kcontrol *kcontrol,
515 struct snd_ctl_elem_value *ucontrol)
517 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
518 struct alc_spec *spec = codec->spec;
519 return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
520 spec->num_channel_mode,
521 spec->ext_channel_count);
524 static int alc_ch_mode_put(struct snd_kcontrol *kcontrol,
525 struct snd_ctl_elem_value *ucontrol)
527 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
528 struct alc_spec *spec = codec->spec;
529 int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
530 spec->num_channel_mode,
531 &spec->ext_channel_count);
532 if (err >= 0 && !spec->const_channel_count) {
533 spec->multiout.max_channels = spec->ext_channel_count;
534 if (spec->need_dac_fix)
535 spec->multiout.num_dacs = spec->multiout.max_channels / 2;
541 * Control the mode of pin widget settings via the mixer. "pc" is used
542 * instead of "%" to avoid consequences of accidently treating the % as
543 * being part of a format specifier. Maximum allowed length of a value is
544 * 63 characters plus NULL terminator.
546 * Note: some retasking pin complexes seem to ignore requests for input
547 * states other than HiZ (eg: PIN_VREFxx) and revert to HiZ if any of these
548 * are requested. Therefore order this list so that this behaviour will not
549 * cause problems when mixer clients move through the enum sequentially.
550 * NIDs 0x0f and 0x10 have been observed to have this behaviour as of
553 static char *alc_pin_mode_names[] = {
554 "Mic 50pc bias", "Mic 80pc bias",
555 "Line in", "Line out", "Headphone out",
557 static unsigned char alc_pin_mode_values[] = {
558 PIN_VREF50, PIN_VREF80, PIN_IN, PIN_OUT, PIN_HP,
560 /* The control can present all 5 options, or it can limit the options based
561 * in the pin being assumed to be exclusively an input or an output pin. In
562 * addition, "input" pins may or may not process the mic bias option
563 * depending on actual widget capability (NIDs 0x0f and 0x10 don't seem to
564 * accept requests for bias as of chip versions up to March 2006) and/or
565 * wiring in the computer.
567 #define ALC_PIN_DIR_IN 0x00
568 #define ALC_PIN_DIR_OUT 0x01
569 #define ALC_PIN_DIR_INOUT 0x02
570 #define ALC_PIN_DIR_IN_NOMICBIAS 0x03
571 #define ALC_PIN_DIR_INOUT_NOMICBIAS 0x04
573 /* Info about the pin modes supported by the different pin direction modes.
574 * For each direction the minimum and maximum values are given.
576 static signed char alc_pin_mode_dir_info[5][2] = {
577 { 0, 2 }, /* ALC_PIN_DIR_IN */
578 { 3, 4 }, /* ALC_PIN_DIR_OUT */
579 { 0, 4 }, /* ALC_PIN_DIR_INOUT */
580 { 2, 2 }, /* ALC_PIN_DIR_IN_NOMICBIAS */
581 { 2, 4 }, /* ALC_PIN_DIR_INOUT_NOMICBIAS */
583 #define alc_pin_mode_min(_dir) (alc_pin_mode_dir_info[_dir][0])
584 #define alc_pin_mode_max(_dir) (alc_pin_mode_dir_info[_dir][1])
585 #define alc_pin_mode_n_items(_dir) \
586 (alc_pin_mode_max(_dir)-alc_pin_mode_min(_dir)+1)
588 static int alc_pin_mode_info(struct snd_kcontrol *kcontrol,
589 struct snd_ctl_elem_info *uinfo)
591 unsigned int item_num = uinfo->value.enumerated.item;
592 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
594 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
596 uinfo->value.enumerated.items = alc_pin_mode_n_items(dir);
598 if (item_num<alc_pin_mode_min(dir) || item_num>alc_pin_mode_max(dir))
599 item_num = alc_pin_mode_min(dir);
600 strcpy(uinfo->value.enumerated.name, alc_pin_mode_names[item_num]);
604 static int alc_pin_mode_get(struct snd_kcontrol *kcontrol,
605 struct snd_ctl_elem_value *ucontrol)
608 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
609 hda_nid_t nid = kcontrol->private_value & 0xffff;
610 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
611 long *valp = ucontrol->value.integer.value;
612 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
613 AC_VERB_GET_PIN_WIDGET_CONTROL,
616 /* Find enumerated value for current pinctl setting */
617 i = alc_pin_mode_min(dir);
618 while (i <= alc_pin_mode_max(dir) && alc_pin_mode_values[i] != pinctl)
620 *valp = i <= alc_pin_mode_max(dir) ? i: alc_pin_mode_min(dir);
624 static int alc_pin_mode_put(struct snd_kcontrol *kcontrol,
625 struct snd_ctl_elem_value *ucontrol)
628 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
629 hda_nid_t nid = kcontrol->private_value & 0xffff;
630 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
631 long val = *ucontrol->value.integer.value;
632 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
633 AC_VERB_GET_PIN_WIDGET_CONTROL,
636 if (val < alc_pin_mode_min(dir) || val > alc_pin_mode_max(dir))
637 val = alc_pin_mode_min(dir);
639 change = pinctl != alc_pin_mode_values[val];
641 /* Set pin mode to that requested */
642 snd_hda_codec_write_cache(codec, nid, 0,
643 AC_VERB_SET_PIN_WIDGET_CONTROL,
644 alc_pin_mode_values[val]);
646 /* Also enable the retasking pin's input/output as required
647 * for the requested pin mode. Enum values of 2 or less are
650 * Dynamically switching the input/output buffers probably
651 * reduces noise slightly (particularly on input) so we'll
652 * do it. However, having both input and output buffers
653 * enabled simultaneously doesn't seem to be problematic if
654 * this turns out to be necessary in the future.
657 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
658 HDA_AMP_MUTE, HDA_AMP_MUTE);
659 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
662 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
663 HDA_AMP_MUTE, HDA_AMP_MUTE);
664 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
671 #define ALC_PIN_MODE(xname, nid, dir) \
672 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
673 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
674 .info = alc_pin_mode_info, \
675 .get = alc_pin_mode_get, \
676 .put = alc_pin_mode_put, \
677 .private_value = nid | (dir<<16) }
679 /* A switch control for ALC260 GPIO pins. Multiple GPIOs can be ganged
680 * together using a mask with more than one bit set. This control is
681 * currently used only by the ALC260 test model. At this stage they are not
682 * needed for any "production" models.
684 #ifdef CONFIG_SND_DEBUG
685 #define alc_gpio_data_info snd_ctl_boolean_mono_info
687 static int alc_gpio_data_get(struct snd_kcontrol *kcontrol,
688 struct snd_ctl_elem_value *ucontrol)
690 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
691 hda_nid_t nid = kcontrol->private_value & 0xffff;
692 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
693 long *valp = ucontrol->value.integer.value;
694 unsigned int val = snd_hda_codec_read(codec, nid, 0,
695 AC_VERB_GET_GPIO_DATA, 0x00);
697 *valp = (val & mask) != 0;
700 static int alc_gpio_data_put(struct snd_kcontrol *kcontrol,
701 struct snd_ctl_elem_value *ucontrol)
704 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
705 hda_nid_t nid = kcontrol->private_value & 0xffff;
706 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
707 long val = *ucontrol->value.integer.value;
708 unsigned int gpio_data = snd_hda_codec_read(codec, nid, 0,
709 AC_VERB_GET_GPIO_DATA,
712 /* Set/unset the masked GPIO bit(s) as needed */
713 change = (val == 0 ? 0 : mask) != (gpio_data & mask);
718 snd_hda_codec_write_cache(codec, nid, 0,
719 AC_VERB_SET_GPIO_DATA, gpio_data);
723 #define ALC_GPIO_DATA_SWITCH(xname, nid, mask) \
724 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
725 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
726 .info = alc_gpio_data_info, \
727 .get = alc_gpio_data_get, \
728 .put = alc_gpio_data_put, \
729 .private_value = nid | (mask<<16) }
730 #endif /* CONFIG_SND_DEBUG */
732 /* A switch control to allow the enabling of the digital IO pins on the
733 * ALC260. This is incredibly simplistic; the intention of this control is
734 * to provide something in the test model allowing digital outputs to be
735 * identified if present. If models are found which can utilise these
736 * outputs a more complete mixer control can be devised for those models if
739 #ifdef CONFIG_SND_DEBUG
740 #define alc_spdif_ctrl_info snd_ctl_boolean_mono_info
742 static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol,
743 struct snd_ctl_elem_value *ucontrol)
745 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
746 hda_nid_t nid = kcontrol->private_value & 0xffff;
747 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
748 long *valp = ucontrol->value.integer.value;
749 unsigned int val = snd_hda_codec_read(codec, nid, 0,
750 AC_VERB_GET_DIGI_CONVERT_1, 0x00);
752 *valp = (val & mask) != 0;
755 static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol,
756 struct snd_ctl_elem_value *ucontrol)
759 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
760 hda_nid_t nid = kcontrol->private_value & 0xffff;
761 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
762 long val = *ucontrol->value.integer.value;
763 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
764 AC_VERB_GET_DIGI_CONVERT_1,
767 /* Set/unset the masked control bit(s) as needed */
768 change = (val == 0 ? 0 : mask) != (ctrl_data & mask);
773 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1,
778 #define ALC_SPDIF_CTRL_SWITCH(xname, nid, mask) \
779 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
780 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
781 .info = alc_spdif_ctrl_info, \
782 .get = alc_spdif_ctrl_get, \
783 .put = alc_spdif_ctrl_put, \
784 .private_value = nid | (mask<<16) }
785 #endif /* CONFIG_SND_DEBUG */
787 /* A switch control to allow the enabling EAPD digital outputs on the ALC26x.
788 * Again, this is only used in the ALC26x test models to help identify when
789 * the EAPD line must be asserted for features to work.
791 #ifdef CONFIG_SND_DEBUG
792 #define alc_eapd_ctrl_info snd_ctl_boolean_mono_info
794 static int alc_eapd_ctrl_get(struct snd_kcontrol *kcontrol,
795 struct snd_ctl_elem_value *ucontrol)
797 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
798 hda_nid_t nid = kcontrol->private_value & 0xffff;
799 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
800 long *valp = ucontrol->value.integer.value;
801 unsigned int val = snd_hda_codec_read(codec, nid, 0,
802 AC_VERB_GET_EAPD_BTLENABLE, 0x00);
804 *valp = (val & mask) != 0;
808 static int alc_eapd_ctrl_put(struct snd_kcontrol *kcontrol,
809 struct snd_ctl_elem_value *ucontrol)
812 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
813 hda_nid_t nid = kcontrol->private_value & 0xffff;
814 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
815 long val = *ucontrol->value.integer.value;
816 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
817 AC_VERB_GET_EAPD_BTLENABLE,
820 /* Set/unset the masked control bit(s) as needed */
821 change = (!val ? 0 : mask) != (ctrl_data & mask);
826 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
832 #define ALC_EAPD_CTRL_SWITCH(xname, nid, mask) \
833 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
834 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
835 .info = alc_eapd_ctrl_info, \
836 .get = alc_eapd_ctrl_get, \
837 .put = alc_eapd_ctrl_put, \
838 .private_value = nid | (mask<<16) }
839 #endif /* CONFIG_SND_DEBUG */
842 * set up the input pin config (depending on the given auto-pin type)
844 static void alc_set_input_pin(struct hda_codec *codec, hda_nid_t nid,
847 unsigned int val = PIN_IN;
849 if (auto_pin_type <= AUTO_PIN_FRONT_MIC) {
852 oldval = snd_hda_codec_read(codec, nid, 0,
853 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
854 pincap = snd_hda_query_pin_caps(codec, nid);
855 pincap = (pincap & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT;
856 /* if the default pin setup is vref50, we give it priority */
857 if ((pincap & AC_PINCAP_VREF_80) && oldval != PIN_VREF50)
859 else if (pincap & AC_PINCAP_VREF_50)
861 else if (pincap & AC_PINCAP_VREF_100)
863 else if (pincap & AC_PINCAP_VREF_GRD)
866 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, val);
871 static void add_mixer(struct alc_spec *spec, struct snd_kcontrol_new *mix)
873 if (snd_BUG_ON(spec->num_mixers >= ARRAY_SIZE(spec->mixers)))
875 spec->mixers[spec->num_mixers++] = mix;
878 static void add_verb(struct alc_spec *spec, const struct hda_verb *verb)
880 if (snd_BUG_ON(spec->num_init_verbs >= ARRAY_SIZE(spec->init_verbs)))
882 spec->init_verbs[spec->num_init_verbs++] = verb;
886 * set up from the preset table
888 static void setup_preset(struct hda_codec *codec,
889 const struct alc_config_preset *preset)
891 struct alc_spec *spec = codec->spec;
894 for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++)
895 add_mixer(spec, preset->mixers[i]);
896 spec->cap_mixer = preset->cap_mixer;
897 for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i];
899 add_verb(spec, preset->init_verbs[i]);
901 spec->channel_mode = preset->channel_mode;
902 spec->num_channel_mode = preset->num_channel_mode;
903 spec->need_dac_fix = preset->need_dac_fix;
904 spec->const_channel_count = preset->const_channel_count;
906 if (preset->const_channel_count)
907 spec->multiout.max_channels = preset->const_channel_count;
909 spec->multiout.max_channels = spec->channel_mode[0].channels;
910 spec->ext_channel_count = spec->channel_mode[0].channels;
912 spec->multiout.num_dacs = preset->num_dacs;
913 spec->multiout.dac_nids = preset->dac_nids;
914 spec->multiout.dig_out_nid = preset->dig_out_nid;
915 spec->multiout.slave_dig_outs = preset->slave_dig_outs;
916 spec->multiout.hp_nid = preset->hp_nid;
918 spec->num_mux_defs = preset->num_mux_defs;
919 if (!spec->num_mux_defs)
920 spec->num_mux_defs = 1;
921 spec->input_mux = preset->input_mux;
923 spec->num_adc_nids = preset->num_adc_nids;
924 spec->adc_nids = preset->adc_nids;
925 spec->capsrc_nids = preset->capsrc_nids;
926 spec->dig_in_nid = preset->dig_in_nid;
928 spec->unsol_event = preset->unsol_event;
929 spec->init_hook = preset->init_hook;
930 #ifdef CONFIG_SND_HDA_POWER_SAVE
931 spec->power_hook = preset->power_hook;
932 spec->loopback.amplist = preset->loopbacks;
936 preset->setup(codec);
939 /* Enable GPIO mask and set output */
940 static struct hda_verb alc_gpio1_init_verbs[] = {
941 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
942 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
943 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
947 static struct hda_verb alc_gpio2_init_verbs[] = {
948 {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
949 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
950 {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
954 static struct hda_verb alc_gpio3_init_verbs[] = {
955 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
956 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
957 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
962 * Fix hardware PLL issue
963 * On some codecs, the analog PLL gating control must be off while
964 * the default value is 1.
966 static void alc_fix_pll(struct hda_codec *codec)
968 struct alc_spec *spec = codec->spec;
973 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX,
975 val = snd_hda_codec_read(codec, spec->pll_nid, 0,
976 AC_VERB_GET_PROC_COEF, 0);
977 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX,
979 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_PROC_COEF,
980 val & ~(1 << spec->pll_coef_bit));
983 static void alc_fix_pll_init(struct hda_codec *codec, hda_nid_t nid,
984 unsigned int coef_idx, unsigned int coef_bit)
986 struct alc_spec *spec = codec->spec;
988 spec->pll_coef_idx = coef_idx;
989 spec->pll_coef_bit = coef_bit;
993 static void alc_automute_pin(struct hda_codec *codec)
995 struct alc_spec *spec = codec->spec;
996 unsigned int nid = spec->autocfg.hp_pins[0];
1001 spec->jack_present = snd_hda_jack_detect(codec, nid);
1002 for (i = 0; i < ARRAY_SIZE(spec->autocfg.speaker_pins); i++) {
1003 nid = spec->autocfg.speaker_pins[i];
1006 snd_hda_codec_write(codec, nid, 0,
1007 AC_VERB_SET_PIN_WIDGET_CONTROL,
1008 spec->jack_present ? 0 : PIN_OUT);
1012 static int get_connection_index(struct hda_codec *codec, hda_nid_t mux,
1015 hda_nid_t conn[HDA_MAX_NUM_INPUTS];
1018 nums = snd_hda_get_connections(codec, mux, conn, ARRAY_SIZE(conn));
1019 for (i = 0; i < nums; i++)
1025 /* switch the current ADC according to the jack state */
1026 static void alc_dual_mic_adc_auto_switch(struct hda_codec *codec)
1028 struct alc_spec *spec = codec->spec;
1029 unsigned int present;
1032 present = snd_hda_jack_detect(codec, spec->ext_mic.pin);
1034 spec->cur_adc_idx = 1;
1036 spec->cur_adc_idx = 0;
1037 new_adc = spec->adc_nids[spec->cur_adc_idx];
1038 if (spec->cur_adc && spec->cur_adc != new_adc) {
1039 /* stream is running, let's swap the current ADC */
1040 __snd_hda_codec_cleanup_stream(codec, spec->cur_adc, 1);
1041 spec->cur_adc = new_adc;
1042 snd_hda_codec_setup_stream(codec, new_adc,
1043 spec->cur_adc_stream_tag, 0,
1044 spec->cur_adc_format);
1048 static void alc_mic_automute(struct hda_codec *codec)
1050 struct alc_spec *spec = codec->spec;
1051 struct alc_mic_route *dead, *alive;
1052 unsigned int present, type;
1055 if (!spec->auto_mic)
1057 if (!spec->int_mic.pin || !spec->ext_mic.pin)
1059 if (snd_BUG_ON(!spec->adc_nids))
1062 if (spec->dual_adc_switch) {
1063 alc_dual_mic_adc_auto_switch(codec);
1067 cap_nid = spec->capsrc_nids ? spec->capsrc_nids[0] : spec->adc_nids[0];
1069 present = snd_hda_jack_detect(codec, spec->ext_mic.pin);
1071 alive = &spec->ext_mic;
1072 dead = &spec->int_mic;
1074 alive = &spec->int_mic;
1075 dead = &spec->ext_mic;
1078 type = get_wcaps_type(get_wcaps(codec, cap_nid));
1079 if (type == AC_WID_AUD_MIX) {
1080 /* Matrix-mixer style (e.g. ALC882) */
1081 snd_hda_codec_amp_stereo(codec, cap_nid, HDA_INPUT,
1084 snd_hda_codec_amp_stereo(codec, cap_nid, HDA_INPUT,
1086 HDA_AMP_MUTE, HDA_AMP_MUTE);
1088 /* MUX style (e.g. ALC880) */
1089 snd_hda_codec_write_cache(codec, cap_nid, 0,
1090 AC_VERB_SET_CONNECT_SEL,
1094 /* FIXME: analog mixer */
1097 /* unsolicited event for HP jack sensing */
1098 static void alc_sku_unsol_event(struct hda_codec *codec, unsigned int res)
1100 if (codec->vendor_id == 0x10ec0880)
1105 case ALC880_HP_EVENT:
1106 alc_automute_pin(codec);
1108 case ALC880_MIC_EVENT:
1109 alc_mic_automute(codec);
1114 static void alc_inithook(struct hda_codec *codec)
1116 alc_automute_pin(codec);
1117 alc_mic_automute(codec);
1120 /* additional initialization for ALC888 variants */
1121 static void alc888_coef_init(struct hda_codec *codec)
1125 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 0);
1126 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
1127 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
1128 if ((tmp & 0xf0) == 0x20)
1130 snd_hda_codec_read(codec, 0x20, 0,
1131 AC_VERB_SET_PROC_COEF, 0x830);
1134 snd_hda_codec_read(codec, 0x20, 0,
1135 AC_VERB_SET_PROC_COEF, 0x3030);
1138 static void alc889_coef_init(struct hda_codec *codec)
1142 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
1143 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
1144 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
1145 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_PROC_COEF, tmp|0x2010);
1148 /* turn on/off EAPD control (only if available) */
1149 static void set_eapd(struct hda_codec *codec, hda_nid_t nid, int on)
1151 if (get_wcaps_type(get_wcaps(codec, nid)) != AC_WID_PIN)
1153 if (snd_hda_query_pin_caps(codec, nid) & AC_PINCAP_EAPD)
1154 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
1158 static void alc_auto_init_amp(struct hda_codec *codec, int type)
1163 case ALC_INIT_GPIO1:
1164 snd_hda_sequence_write(codec, alc_gpio1_init_verbs);
1166 case ALC_INIT_GPIO2:
1167 snd_hda_sequence_write(codec, alc_gpio2_init_verbs);
1169 case ALC_INIT_GPIO3:
1170 snd_hda_sequence_write(codec, alc_gpio3_init_verbs);
1172 case ALC_INIT_DEFAULT:
1173 switch (codec->vendor_id) {
1175 set_eapd(codec, 0x0f, 1);
1176 set_eapd(codec, 0x10, 1);
1189 set_eapd(codec, 0x14, 1);
1190 set_eapd(codec, 0x15, 1);
1193 switch (codec->vendor_id) {
1195 snd_hda_codec_write(codec, 0x1a, 0,
1196 AC_VERB_SET_COEF_INDEX, 7);
1197 tmp = snd_hda_codec_read(codec, 0x1a, 0,
1198 AC_VERB_GET_PROC_COEF, 0);
1199 snd_hda_codec_write(codec, 0x1a, 0,
1200 AC_VERB_SET_COEF_INDEX, 7);
1201 snd_hda_codec_write(codec, 0x1a, 0,
1202 AC_VERB_SET_PROC_COEF,
1212 alc889_coef_init(codec);
1215 alc888_coef_init(codec);
1217 #if 0 /* XXX: This may cause the silent output on speaker on some machines */
1220 snd_hda_codec_write(codec, 0x20, 0,
1221 AC_VERB_SET_COEF_INDEX, 7);
1222 tmp = snd_hda_codec_read(codec, 0x20, 0,
1223 AC_VERB_GET_PROC_COEF, 0);
1224 snd_hda_codec_write(codec, 0x20, 0,
1225 AC_VERB_SET_COEF_INDEX, 7);
1226 snd_hda_codec_write(codec, 0x20, 0,
1227 AC_VERB_SET_PROC_COEF,
1236 static void alc_init_auto_hp(struct hda_codec *codec)
1238 struct alc_spec *spec = codec->spec;
1240 if (!spec->autocfg.hp_pins[0])
1243 if (!spec->autocfg.speaker_pins[0]) {
1244 if (spec->autocfg.line_out_pins[0] &&
1245 spec->autocfg.line_out_type == AUTO_PIN_SPEAKER_OUT)
1246 spec->autocfg.speaker_pins[0] =
1247 spec->autocfg.line_out_pins[0];
1252 snd_printdd("realtek: Enable HP auto-muting on NID 0x%x\n",
1253 spec->autocfg.hp_pins[0]);
1254 snd_hda_codec_write_cache(codec, spec->autocfg.hp_pins[0], 0,
1255 AC_VERB_SET_UNSOLICITED_ENABLE,
1256 AC_USRSP_EN | ALC880_HP_EVENT);
1257 spec->unsol_event = alc_sku_unsol_event;
1260 static void alc_init_auto_mic(struct hda_codec *codec)
1262 struct alc_spec *spec = codec->spec;
1263 struct auto_pin_cfg *cfg = &spec->autocfg;
1264 hda_nid_t fixed, ext;
1267 /* there must be only two mic inputs exclusively */
1268 for (i = AUTO_PIN_LINE; i < AUTO_PIN_LAST; i++)
1269 if (cfg->input_pins[i])
1273 for (i = AUTO_PIN_MIC; i <= AUTO_PIN_FRONT_MIC; i++) {
1274 hda_nid_t nid = cfg->input_pins[i];
1275 unsigned int defcfg;
1278 defcfg = snd_hda_codec_get_pincfg(codec, nid);
1279 switch (get_defcfg_connect(defcfg)) {
1280 case AC_JACK_PORT_FIXED:
1282 return; /* already occupied */
1285 case AC_JACK_PORT_COMPLEX:
1287 return; /* already occupied */
1291 return; /* invalid entry */
1296 if (!(get_wcaps(codec, ext) & AC_WCAP_UNSOL_CAP))
1297 return; /* no unsol support */
1298 snd_printdd("realtek: Enable auto-mic switch on NID 0x%x/0x%x\n",
1300 spec->ext_mic.pin = ext;
1301 spec->int_mic.pin = fixed;
1302 spec->ext_mic.mux_idx = MUX_IDX_UNDEF; /* set later */
1303 spec->int_mic.mux_idx = MUX_IDX_UNDEF; /* set later */
1305 snd_hda_codec_write_cache(codec, spec->ext_mic.pin, 0,
1306 AC_VERB_SET_UNSOLICITED_ENABLE,
1307 AC_USRSP_EN | ALC880_MIC_EVENT);
1308 spec->unsol_event = alc_sku_unsol_event;
1311 static int alc_auto_parse_customize_define(struct hda_codec *codec)
1313 unsigned int ass, tmp, i;
1315 struct alc_spec *spec = codec->spec;
1317 spec->cdefine.enable_pcbeep = 1; /* assume always enabled */
1319 ass = codec->subsystem_id & 0xffff;
1320 if (ass != codec->bus->pci->subsystem_device && (ass & 1))
1324 if (codec->vendor_id == 0x10ec0260)
1326 ass = snd_hda_codec_get_pincfg(codec, nid);
1329 printk(KERN_INFO "hda_codec: %s: SKU not ready 0x%08x\n",
1330 codec->chip_name, ass);
1336 for (i = 1; i < 16; i++) {
1340 if (((ass >> 16) & 0xf) != tmp)
1343 spec->cdefine.port_connectivity = ass >> 30;
1344 spec->cdefine.enable_pcbeep = (ass & 0x100000) >> 20;
1345 spec->cdefine.check_sum = (ass >> 16) & 0xf;
1346 spec->cdefine.customization = ass >> 8;
1348 spec->cdefine.sku_cfg = ass;
1349 spec->cdefine.external_amp = (ass & 0x38) >> 3;
1350 spec->cdefine.platform_type = (ass & 0x4) >> 2;
1351 spec->cdefine.swap = (ass & 0x2) >> 1;
1352 spec->cdefine.override = ass & 0x1;
1354 snd_printd("SKU: Nid=0x%x sku_cfg=0x%08x\n",
1355 nid, spec->cdefine.sku_cfg);
1356 snd_printd("SKU: port_connectivity=0x%x\n",
1357 spec->cdefine.port_connectivity);
1358 snd_printd("SKU: enable_pcbeep=0x%x\n", spec->cdefine.enable_pcbeep);
1359 snd_printd("SKU: check_sum=0x%08x\n", spec->cdefine.check_sum);
1360 snd_printd("SKU: customization=0x%08x\n", spec->cdefine.customization);
1361 snd_printd("SKU: external_amp=0x%x\n", spec->cdefine.external_amp);
1362 snd_printd("SKU: platform_type=0x%x\n", spec->cdefine.platform_type);
1363 snd_printd("SKU: swap=0x%x\n", spec->cdefine.swap);
1364 snd_printd("SKU: override=0x%x\n", spec->cdefine.override);
1369 /* check subsystem ID and set up device-specific initialization;
1370 * return 1 if initialized, 0 if invalid SSID
1372 /* 32-bit subsystem ID for BIOS loading in HD Audio codec.
1373 * 31 ~ 16 : Manufacture ID
1375 * 7 ~ 0 : Assembly ID
1376 * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36
1378 static int alc_subsystem_id(struct hda_codec *codec,
1379 hda_nid_t porta, hda_nid_t porte,
1380 hda_nid_t portd, hda_nid_t porti)
1382 unsigned int ass, tmp, i;
1384 struct alc_spec *spec = codec->spec;
1386 ass = codec->subsystem_id & 0xffff;
1387 if ((ass != codec->bus->pci->subsystem_device) && (ass & 1))
1390 /* invalid SSID, check the special NID pin defcfg instead */
1392 * 31~30 : port connectivity
1395 * 19~16 : Check sum (15:1)
1400 if (codec->vendor_id == 0x10ec0260)
1402 ass = snd_hda_codec_get_pincfg(codec, nid);
1403 snd_printd("realtek: No valid SSID, "
1404 "checking pincfg 0x%08x for NID 0x%x\n",
1408 if ((ass >> 30) != 1) /* no physical connection */
1413 for (i = 1; i < 16; i++) {
1417 if (((ass >> 16) & 0xf) != tmp)
1420 snd_printd("realtek: Enabling init ASM_ID=0x%04x CODEC_ID=%08x\n",
1421 ass & 0xffff, codec->vendor_id);
1425 * 2 : 0 --> Desktop, 1 --> Laptop
1426 * 3~5 : External Amplifier control
1429 tmp = (ass & 0x38) >> 3; /* external Amp control */
1432 spec->init_amp = ALC_INIT_GPIO1;
1435 spec->init_amp = ALC_INIT_GPIO2;
1438 spec->init_amp = ALC_INIT_GPIO3;
1441 spec->init_amp = ALC_INIT_DEFAULT;
1445 /* is laptop or Desktop and enable the function "Mute internal speaker
1446 * when the external headphone out jack is plugged"
1448 if (!(ass & 0x8000))
1451 * 10~8 : Jack location
1452 * 12~11: Headphone out -> 00: PortA, 01: PortE, 02: PortD, 03: Resvered
1454 * 15 : 1 --> enable the function "Mute internal speaker
1455 * when the external headphone out jack is plugged"
1457 if (!spec->autocfg.hp_pins[0]) {
1459 tmp = (ass >> 11) & 0x3; /* HP to chassis */
1470 for (i = 0; i < spec->autocfg.line_outs; i++)
1471 if (spec->autocfg.line_out_pins[i] == nid)
1473 spec->autocfg.hp_pins[0] = nid;
1476 alc_init_auto_hp(codec);
1477 alc_init_auto_mic(codec);
1481 static void alc_ssid_check(struct hda_codec *codec,
1482 hda_nid_t porta, hda_nid_t porte,
1483 hda_nid_t portd, hda_nid_t porti)
1485 if (!alc_subsystem_id(codec, porta, porte, portd, porti)) {
1486 struct alc_spec *spec = codec->spec;
1487 snd_printd("realtek: "
1488 "Enable default setup for auto mode as fallback\n");
1489 spec->init_amp = ALC_INIT_DEFAULT;
1490 alc_init_auto_hp(codec);
1491 alc_init_auto_mic(codec);
1496 * Fix-up pin default configurations and add default verbs
1505 const struct alc_pincfg *pins;
1506 const struct hda_verb *verbs;
1509 static void alc_pick_fixup(struct hda_codec *codec,
1510 const struct snd_pci_quirk *quirk,
1511 const struct alc_fixup *fix,
1514 const struct alc_pincfg *cfg;
1516 quirk = snd_pci_quirk_lookup(codec->bus->pci, quirk);
1519 fix += quirk->value;
1521 if (pre_init && cfg) {
1522 #ifdef CONFIG_SND_DEBUG_VERBOSE
1523 snd_printdd(KERN_INFO "hda_codec: %s: Apply pincfg for %s\n",
1524 codec->chip_name, quirk->name);
1526 for (; cfg->nid; cfg++)
1527 snd_hda_codec_set_pincfg(codec, cfg->nid, cfg->val);
1529 if (!pre_init && fix->verbs) {
1530 #ifdef CONFIG_SND_DEBUG_VERBOSE
1531 snd_printdd(KERN_INFO "hda_codec: %s: Apply fix-verbs for %s\n",
1532 codec->chip_name, quirk->name);
1534 add_verb(codec->spec, fix->verbs);
1538 static int alc_read_coef_idx(struct hda_codec *codec,
1539 unsigned int coef_idx)
1542 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX,
1544 val = snd_hda_codec_read(codec, 0x20, 0,
1545 AC_VERB_GET_PROC_COEF, 0);
1549 /* set right pin controls for digital I/O */
1550 static void alc_auto_init_digital(struct hda_codec *codec)
1552 struct alc_spec *spec = codec->spec;
1556 for (i = 0; i < spec->autocfg.dig_outs; i++) {
1557 pin = spec->autocfg.dig_out_pins[i];
1559 snd_hda_codec_write(codec, pin, 0,
1560 AC_VERB_SET_PIN_WIDGET_CONTROL,
1564 pin = spec->autocfg.dig_in_pin;
1566 snd_hda_codec_write(codec, pin, 0,
1567 AC_VERB_SET_PIN_WIDGET_CONTROL,
1571 /* parse digital I/Os and set up NIDs in BIOS auto-parse mode */
1572 static void alc_auto_parse_digital(struct hda_codec *codec)
1574 struct alc_spec *spec = codec->spec;
1578 /* support multiple SPDIFs; the secondary is set up as a slave */
1579 for (i = 0; i < spec->autocfg.dig_outs; i++) {
1580 err = snd_hda_get_connections(codec,
1581 spec->autocfg.dig_out_pins[i],
1586 spec->multiout.dig_out_nid = dig_nid;
1587 spec->dig_out_type = spec->autocfg.dig_out_type[0];
1589 spec->multiout.slave_dig_outs = spec->slave_dig_outs;
1590 if (i >= ARRAY_SIZE(spec->slave_dig_outs) - 1)
1592 spec->slave_dig_outs[i - 1] = dig_nid;
1596 if (spec->autocfg.dig_in_pin) {
1597 dig_nid = codec->start_nid;
1598 for (i = 0; i < codec->num_nodes; i++, dig_nid++) {
1599 unsigned int wcaps = get_wcaps(codec, dig_nid);
1600 if (get_wcaps_type(wcaps) != AC_WID_AUD_IN)
1602 if (!(wcaps & AC_WCAP_DIGITAL))
1604 if (!(wcaps & AC_WCAP_CONN_LIST))
1606 err = get_connection_index(codec, dig_nid,
1607 spec->autocfg.dig_in_pin);
1609 spec->dig_in_nid = dig_nid;
1623 static struct hda_verb alc888_4ST_ch2_intel_init[] = {
1624 /* Mic-in jack as mic in */
1625 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1626 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1627 /* Line-in jack as Line in */
1628 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1629 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1630 /* Line-Out as Front */
1631 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
1638 static struct hda_verb alc888_4ST_ch4_intel_init[] = {
1639 /* Mic-in jack as mic in */
1640 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1641 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1642 /* Line-in jack as Surround */
1643 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1644 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1645 /* Line-Out as Front */
1646 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
1653 static struct hda_verb alc888_4ST_ch6_intel_init[] = {
1654 /* Mic-in jack as CLFE */
1655 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1656 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1657 /* Line-in jack as Surround */
1658 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1659 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1660 /* Line-Out as CLFE (workaround because Mic-in is not loud enough) */
1661 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1668 static struct hda_verb alc888_4ST_ch8_intel_init[] = {
1669 /* Mic-in jack as CLFE */
1670 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1671 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1672 /* Line-in jack as Surround */
1673 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1674 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1675 /* Line-Out as Side */
1676 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1680 static struct hda_channel_mode alc888_4ST_8ch_intel_modes[4] = {
1681 { 2, alc888_4ST_ch2_intel_init },
1682 { 4, alc888_4ST_ch4_intel_init },
1683 { 6, alc888_4ST_ch6_intel_init },
1684 { 8, alc888_4ST_ch8_intel_init },
1688 * ALC888 Fujitsu Siemens Amillo xa3530
1691 static struct hda_verb alc888_fujitsu_xa3530_verbs[] = {
1692 /* Front Mic: set to PIN_IN (empty by default) */
1693 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1694 /* Connect Internal HP to Front */
1695 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1696 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1697 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1698 /* Connect Bass HP to Front */
1699 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1700 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1701 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1702 /* Connect Line-Out side jack (SPDIF) to Side */
1703 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1704 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1705 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1706 /* Connect Mic jack to CLFE */
1707 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1708 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1709 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02},
1710 /* Connect Line-in jack to Surround */
1711 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1712 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1713 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
1714 /* Connect HP out jack to Front */
1715 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1716 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1717 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
1718 /* Enable unsolicited event for HP jack and Line-out jack */
1719 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1720 {0x17, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1724 static void alc_automute_amp(struct hda_codec *codec)
1726 struct alc_spec *spec = codec->spec;
1731 spec->jack_present = 0;
1732 for (i = 0; i < ARRAY_SIZE(spec->autocfg.hp_pins); i++) {
1733 nid = spec->autocfg.hp_pins[i];
1736 if (snd_hda_jack_detect(codec, nid)) {
1737 spec->jack_present = 1;
1742 mute = spec->jack_present ? HDA_AMP_MUTE : 0;
1743 /* Toggle internal speakers muting */
1744 for (i = 0; i < ARRAY_SIZE(spec->autocfg.speaker_pins); i++) {
1745 nid = spec->autocfg.speaker_pins[i];
1748 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
1749 HDA_AMP_MUTE, mute);
1753 static void alc_automute_amp_unsol_event(struct hda_codec *codec,
1756 if (codec->vendor_id == 0x10ec0880)
1760 if (res == ALC880_HP_EVENT)
1761 alc_automute_amp(codec);
1764 static void alc889_automute_setup(struct hda_codec *codec)
1766 struct alc_spec *spec = codec->spec;
1768 spec->autocfg.hp_pins[0] = 0x15;
1769 spec->autocfg.speaker_pins[0] = 0x14;
1770 spec->autocfg.speaker_pins[1] = 0x16;
1771 spec->autocfg.speaker_pins[2] = 0x17;
1772 spec->autocfg.speaker_pins[3] = 0x19;
1773 spec->autocfg.speaker_pins[4] = 0x1a;
1776 static void alc889_intel_init_hook(struct hda_codec *codec)
1778 alc889_coef_init(codec);
1779 alc_automute_amp(codec);
1782 static void alc888_fujitsu_xa3530_setup(struct hda_codec *codec)
1784 struct alc_spec *spec = codec->spec;
1786 spec->autocfg.hp_pins[0] = 0x17; /* line-out */
1787 spec->autocfg.hp_pins[1] = 0x1b; /* hp */
1788 spec->autocfg.speaker_pins[0] = 0x14; /* speaker */
1789 spec->autocfg.speaker_pins[1] = 0x15; /* bass */
1793 * ALC888 Acer Aspire 4930G model
1796 static struct hda_verb alc888_acer_aspire_4930g_verbs[] = {
1797 /* Front Mic: set to PIN_IN (empty by default) */
1798 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1799 /* Unselect Front Mic by default in input mixer 3 */
1800 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
1801 /* Enable unsolicited event for HP jack */
1802 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1803 /* Connect Internal HP to front */
1804 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1805 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1806 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1807 /* Connect HP out to front */
1808 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1809 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1810 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1815 * ALC888 Acer Aspire 6530G model
1818 static struct hda_verb alc888_acer_aspire_6530g_verbs[] = {
1819 /* Route to built-in subwoofer as well as speakers */
1820 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1821 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1822 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1823 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1824 /* Bias voltage on for external mic port */
1825 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN | PIN_VREF80},
1826 /* Front Mic: set to PIN_IN (empty by default) */
1827 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1828 /* Unselect Front Mic by default in input mixer 3 */
1829 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
1830 /* Enable unsolicited event for HP jack */
1831 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1832 /* Enable speaker output */
1833 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1834 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1835 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
1836 /* Enable headphone output */
1837 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | PIN_HP},
1838 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1839 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1840 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
1845 * ALC889 Acer Aspire 8930G model
1848 static struct hda_verb alc889_acer_aspire_8930g_verbs[] = {
1849 /* Front Mic: set to PIN_IN (empty by default) */
1850 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1851 /* Unselect Front Mic by default in input mixer 3 */
1852 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
1853 /* Enable unsolicited event for HP jack */
1854 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1855 /* Connect Internal Front to Front */
1856 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1857 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1858 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1859 /* Connect Internal Rear to Rear */
1860 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1861 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1862 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01},
1863 /* Connect Internal CLFE to CLFE */
1864 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1865 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1866 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
1867 /* Connect HP out to Front */
1868 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | PIN_HP},
1869 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1870 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1871 /* Enable all DACs */
1872 /* DAC DISABLE/MUTE 1? */
1873 /* setting bits 1-5 disables DAC nids 0x02-0x06 apparently. Init=0x38 */
1874 {0x20, AC_VERB_SET_COEF_INDEX, 0x03},
1875 {0x20, AC_VERB_SET_PROC_COEF, 0x0000},
1876 /* DAC DISABLE/MUTE 2? */
1877 /* some bit here disables the other DACs. Init=0x4900 */
1878 {0x20, AC_VERB_SET_COEF_INDEX, 0x08},
1879 {0x20, AC_VERB_SET_PROC_COEF, 0x0000},
1881 * This laptop has a stereo digital microphone. The mics are only 1cm apart
1882 * which makes the stereo useless. However, either the mic or the ALC889
1883 * makes the signal become a difference/sum signal instead of standard
1884 * stereo, which is annoying. So instead we flip this bit which makes the
1885 * codec replicate the sum signal to both channels, turning it into a
1888 /* DMIC_CONTROL? Init value = 0x0001 */
1889 {0x20, AC_VERB_SET_COEF_INDEX, 0x0b},
1890 {0x20, AC_VERB_SET_PROC_COEF, 0x0003},
1894 static struct hda_input_mux alc888_2_capture_sources[2] = {
1895 /* Front mic only available on one ADC */
1902 { "Front Mic", 0xb },
1915 static struct hda_input_mux alc888_acer_aspire_6530_sources[2] = {
1916 /* Interal mic only available on one ADC */
1923 { "Input Mix", 0xa },
1933 { "Input Mix", 0xa },
1938 static struct hda_input_mux alc889_capture_sources[3] = {
1939 /* Digital mic only available on first "ADC" */
1946 { "Front Mic", 0xb },
1947 { "Input Mix", 0xa },
1956 { "Input Mix", 0xa },
1965 { "Input Mix", 0xa },
1970 static struct snd_kcontrol_new alc888_base_mixer[] = {
1971 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1972 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1973 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1974 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
1975 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
1977 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1978 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1979 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1980 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
1981 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
1982 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1983 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1984 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1985 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1986 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1987 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
1988 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1992 static struct snd_kcontrol_new alc889_acer_aspire_8930g_mixer[] = {
1993 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1994 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1995 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1996 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
1997 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
1999 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2000 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2001 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2002 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2003 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2004 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2005 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
2006 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2011 static void alc888_acer_aspire_4930g_setup(struct hda_codec *codec)
2013 struct alc_spec *spec = codec->spec;
2015 spec->autocfg.hp_pins[0] = 0x15;
2016 spec->autocfg.speaker_pins[0] = 0x14;
2017 spec->autocfg.speaker_pins[1] = 0x16;
2018 spec->autocfg.speaker_pins[2] = 0x17;
2021 static void alc888_acer_aspire_6530g_setup(struct hda_codec *codec)
2023 struct alc_spec *spec = codec->spec;
2025 spec->autocfg.hp_pins[0] = 0x15;
2026 spec->autocfg.speaker_pins[0] = 0x14;
2027 spec->autocfg.speaker_pins[1] = 0x16;
2028 spec->autocfg.speaker_pins[2] = 0x17;
2031 static void alc889_acer_aspire_8930g_setup(struct hda_codec *codec)
2033 struct alc_spec *spec = codec->spec;
2035 spec->autocfg.hp_pins[0] = 0x15;
2036 spec->autocfg.speaker_pins[0] = 0x14;
2037 spec->autocfg.speaker_pins[1] = 0x16;
2038 spec->autocfg.speaker_pins[2] = 0x1b;
2042 * ALC880 3-stack model
2044 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
2045 * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18,
2046 * F-Mic = 0x1b, HP = 0x19
2049 static hda_nid_t alc880_dac_nids[4] = {
2050 /* front, rear, clfe, rear_surr */
2051 0x02, 0x05, 0x04, 0x03
2054 static hda_nid_t alc880_adc_nids[3] = {
2059 /* The datasheet says the node 0x07 is connected from inputs,
2060 * but it shows zero connection in the real implementation on some devices.
2061 * Note: this is a 915GAV bug, fixed on 915GLV
2063 static hda_nid_t alc880_adc_nids_alt[2] = {
2068 #define ALC880_DIGOUT_NID 0x06
2069 #define ALC880_DIGIN_NID 0x0a
2071 static struct hda_input_mux alc880_capture_source = {
2075 { "Front Mic", 0x3 },
2081 /* channel source setting (2/6 channel selection for 3-stack) */
2083 static struct hda_verb alc880_threestack_ch2_init[] = {
2084 /* set line-in to input, mute it */
2085 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
2086 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
2087 /* set mic-in to input vref 80%, mute it */
2088 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
2089 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
2094 static struct hda_verb alc880_threestack_ch6_init[] = {
2095 /* set line-in to output, unmute it */
2096 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
2097 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
2098 /* set mic-in to output, unmute it */
2099 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
2100 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
2104 static struct hda_channel_mode alc880_threestack_modes[2] = {
2105 { 2, alc880_threestack_ch2_init },
2106 { 6, alc880_threestack_ch6_init },
2109 static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
2110 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2111 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2112 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
2113 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
2114 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2115 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2116 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2117 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2118 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2119 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2120 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2121 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2122 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2123 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2124 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
2125 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
2126 HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
2128 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2129 .name = "Channel Mode",
2130 .info = alc_ch_mode_info,
2131 .get = alc_ch_mode_get,
2132 .put = alc_ch_mode_put,
2137 /* capture mixer elements */
2138 static int alc_cap_vol_info(struct snd_kcontrol *kcontrol,
2139 struct snd_ctl_elem_info *uinfo)
2141 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2142 struct alc_spec *spec = codec->spec;
2145 mutex_lock(&codec->control_mutex);
2146 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0,
2148 err = snd_hda_mixer_amp_volume_info(kcontrol, uinfo);
2149 mutex_unlock(&codec->control_mutex);
2153 static int alc_cap_vol_tlv(struct snd_kcontrol *kcontrol, int op_flag,
2154 unsigned int size, unsigned int __user *tlv)
2156 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2157 struct alc_spec *spec = codec->spec;
2160 mutex_lock(&codec->control_mutex);
2161 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0,
2163 err = snd_hda_mixer_amp_tlv(kcontrol, op_flag, size, tlv);
2164 mutex_unlock(&codec->control_mutex);
2168 typedef int (*getput_call_t)(struct snd_kcontrol *kcontrol,
2169 struct snd_ctl_elem_value *ucontrol);
2171 static int alc_cap_getput_caller(struct snd_kcontrol *kcontrol,
2172 struct snd_ctl_elem_value *ucontrol,
2175 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2176 struct alc_spec *spec = codec->spec;
2177 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
2180 mutex_lock(&codec->control_mutex);
2181 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[adc_idx],
2183 err = func(kcontrol, ucontrol);
2184 mutex_unlock(&codec->control_mutex);
2188 static int alc_cap_vol_get(struct snd_kcontrol *kcontrol,
2189 struct snd_ctl_elem_value *ucontrol)
2191 return alc_cap_getput_caller(kcontrol, ucontrol,
2192 snd_hda_mixer_amp_volume_get);
2195 static int alc_cap_vol_put(struct snd_kcontrol *kcontrol,
2196 struct snd_ctl_elem_value *ucontrol)
2198 return alc_cap_getput_caller(kcontrol, ucontrol,
2199 snd_hda_mixer_amp_volume_put);
2202 /* capture mixer elements */
2203 #define alc_cap_sw_info snd_ctl_boolean_stereo_info
2205 static int alc_cap_sw_get(struct snd_kcontrol *kcontrol,
2206 struct snd_ctl_elem_value *ucontrol)
2208 return alc_cap_getput_caller(kcontrol, ucontrol,
2209 snd_hda_mixer_amp_switch_get);
2212 static int alc_cap_sw_put(struct snd_kcontrol *kcontrol,
2213 struct snd_ctl_elem_value *ucontrol)
2215 return alc_cap_getput_caller(kcontrol, ucontrol,
2216 snd_hda_mixer_amp_switch_put);
2219 #define _DEFINE_CAPMIX(num) \
2221 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2222 .name = "Capture Switch", \
2223 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, \
2225 .info = alc_cap_sw_info, \
2226 .get = alc_cap_sw_get, \
2227 .put = alc_cap_sw_put, \
2230 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2231 .name = "Capture Volume", \
2232 .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE | \
2233 SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
2234 SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK), \
2236 .info = alc_cap_vol_info, \
2237 .get = alc_cap_vol_get, \
2238 .put = alc_cap_vol_put, \
2239 .tlv = { .c = alc_cap_vol_tlv }, \
2242 #define _DEFINE_CAPSRC(num) \
2244 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2245 /* .name = "Capture Source", */ \
2246 .name = "Input Source", \
2248 .info = alc_mux_enum_info, \
2249 .get = alc_mux_enum_get, \
2250 .put = alc_mux_enum_put, \
2253 #define DEFINE_CAPMIX(num) \
2254 static struct snd_kcontrol_new alc_capture_mixer ## num[] = { \
2255 _DEFINE_CAPMIX(num), \
2256 _DEFINE_CAPSRC(num), \
2260 #define DEFINE_CAPMIX_NOSRC(num) \
2261 static struct snd_kcontrol_new alc_capture_mixer_nosrc ## num[] = { \
2262 _DEFINE_CAPMIX(num), \
2266 /* up to three ADCs */
2270 DEFINE_CAPMIX_NOSRC(1);
2271 DEFINE_CAPMIX_NOSRC(2);
2272 DEFINE_CAPMIX_NOSRC(3);
2275 * ALC880 5-stack model
2277 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d),
2279 * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
2280 * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
2283 /* additional mixers to alc880_three_stack_mixer */
2284 static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
2285 HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2286 HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
2290 /* channel source setting (6/8 channel selection for 5-stack) */
2292 static struct hda_verb alc880_fivestack_ch6_init[] = {
2293 /* set line-in to input, mute it */
2294 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
2295 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
2300 static struct hda_verb alc880_fivestack_ch8_init[] = {
2301 /* set line-in to output, unmute it */
2302 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
2303 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
2307 static struct hda_channel_mode alc880_fivestack_modes[2] = {
2308 { 6, alc880_fivestack_ch6_init },
2309 { 8, alc880_fivestack_ch8_init },
2314 * ALC880 6-stack model
2316 * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e),
2317 * Side = 0x05 (0x0f)
2318 * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
2319 * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
2322 static hda_nid_t alc880_6st_dac_nids[4] = {
2323 /* front, rear, clfe, rear_surr */
2324 0x02, 0x03, 0x04, 0x05
2327 static struct hda_input_mux alc880_6stack_capture_source = {
2331 { "Front Mic", 0x1 },
2337 /* fixed 8-channels */
2338 static struct hda_channel_mode alc880_sixstack_modes[1] = {
2342 static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
2343 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2344 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2345 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2346 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
2347 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2348 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2349 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2350 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2351 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
2352 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
2353 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2354 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2355 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2356 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2357 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2358 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2359 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2360 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
2362 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2363 .name = "Channel Mode",
2364 .info = alc_ch_mode_info,
2365 .get = alc_ch_mode_get,
2366 .put = alc_ch_mode_put,
2375 * W810 has rear IO for:
2378 * Center/LFE (DAC 04)
2381 * The system also has a pair of internal speakers, and a headphone jack.
2382 * These are both connected to Line2 on the codec, hence to DAC 02.
2384 * There is a variable resistor to control the speaker or headphone
2385 * volume. This is a hardware-only device without a software API.
2387 * Plugging headphones in will disable the internal speakers. This is
2388 * implemented in hardware, not via the driver using jack sense. In
2389 * a similar fashion, plugging into the rear socket marked "front" will
2390 * disable both the speakers and headphones.
2392 * For input, there's a microphone jack, and an "audio in" jack.
2393 * These may not do anything useful with this driver yet, because I
2394 * haven't setup any initialization verbs for these yet...
2397 static hda_nid_t alc880_w810_dac_nids[3] = {
2398 /* front, rear/surround, clfe */
2402 /* fixed 6 channels */
2403 static struct hda_channel_mode alc880_w810_modes[1] = {
2407 /* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
2408 static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
2409 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2410 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2411 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2412 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
2413 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2414 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2415 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2416 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2417 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
2425 * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
2426 * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?),
2430 static hda_nid_t alc880_z71v_dac_nids[1] = {
2433 #define ALC880_Z71V_HP_DAC 0x03
2435 /* fixed 2 channels */
2436 static struct hda_channel_mode alc880_2_jack_modes[1] = {
2440 static struct snd_kcontrol_new alc880_z71v_mixer[] = {
2441 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2442 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2443 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2444 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
2445 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2446 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2447 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2448 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2454 * ALC880 F1734 model
2456 * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
2457 * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
2460 static hda_nid_t alc880_f1734_dac_nids[1] = {
2463 #define ALC880_F1734_HP_DAC 0x02
2465 static struct snd_kcontrol_new alc880_f1734_mixer[] = {
2466 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2467 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2468 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2469 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
2470 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2471 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2472 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2473 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
2477 static struct hda_input_mux alc880_f1734_capture_source = {
2489 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
2490 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
2491 * Mic = 0x18, Line = 0x1a
2494 #define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
2495 #define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
2497 static struct snd_kcontrol_new alc880_asus_mixer[] = {
2498 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2499 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2500 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2501 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
2502 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2503 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2504 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2505 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2506 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2507 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2508 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2509 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2510 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2511 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2513 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2514 .name = "Channel Mode",
2515 .info = alc_ch_mode_info,
2516 .get = alc_ch_mode_get,
2517 .put = alc_ch_mode_put,
2523 * ALC880 ASUS W1V model
2525 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
2526 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
2527 * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
2530 /* additional mixers to alc880_asus_mixer */
2531 static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
2532 HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
2533 HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
2538 static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
2539 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2540 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
2541 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
2542 HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
2543 HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
2544 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
2545 HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
2546 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
2547 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
2552 static struct snd_kcontrol_new alc880_uniwill_mixer[] = {
2553 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2554 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2555 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2556 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
2557 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2558 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2559 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2560 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2561 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2562 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2563 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2564 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2565 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2566 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2567 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2568 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
2570 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2571 .name = "Channel Mode",
2572 .info = alc_ch_mode_info,
2573 .get = alc_ch_mode_get,
2574 .put = alc_ch_mode_put,
2579 static struct snd_kcontrol_new alc880_fujitsu_mixer[] = {
2580 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2581 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2582 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2583 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
2584 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2585 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2586 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2587 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2588 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2589 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
2593 static struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = {
2594 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2595 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2596 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2597 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
2598 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2599 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2604 * virtual master controls
2608 * slave controls for virtual master
2610 static const char *alc_slave_vols[] = {
2611 "Front Playback Volume",
2612 "Surround Playback Volume",
2613 "Center Playback Volume",
2614 "LFE Playback Volume",
2615 "Side Playback Volume",
2616 "Headphone Playback Volume",
2617 "Speaker Playback Volume",
2618 "Mono Playback Volume",
2619 "Line-Out Playback Volume",
2620 "PCM Playback Volume",
2624 static const char *alc_slave_sws[] = {
2625 "Front Playback Switch",
2626 "Surround Playback Switch",
2627 "Center Playback Switch",
2628 "LFE Playback Switch",
2629 "Side Playback Switch",
2630 "Headphone Playback Switch",
2631 "Speaker Playback Switch",
2632 "Mono Playback Switch",
2633 "IEC958 Playback Switch",
2634 "Line-Out Playback Switch",
2635 "PCM Playback Switch",
2640 * build control elements
2643 #define NID_MAPPING (-1)
2645 #define SUBDEV_SPEAKER_ (0 << 6)
2646 #define SUBDEV_HP_ (1 << 6)
2647 #define SUBDEV_LINE_ (2 << 6)
2648 #define SUBDEV_SPEAKER(x) (SUBDEV_SPEAKER_ | ((x) & 0x3f))
2649 #define SUBDEV_HP(x) (SUBDEV_HP_ | ((x) & 0x3f))
2650 #define SUBDEV_LINE(x) (SUBDEV_LINE_ | ((x) & 0x3f))
2652 static void alc_free_kctls(struct hda_codec *codec);
2654 #ifdef CONFIG_SND_HDA_INPUT_BEEP
2655 /* additional beep mixers; the actual parameters are overwritten at build */
2656 static struct snd_kcontrol_new alc_beep_mixer[] = {
2657 HDA_CODEC_VOLUME("Beep Playback Volume", 0, 0, HDA_INPUT),
2658 HDA_CODEC_MUTE_BEEP("Beep Playback Switch", 0, 0, HDA_INPUT),
2663 static int alc_build_controls(struct hda_codec *codec)
2665 struct alc_spec *spec = codec->spec;
2666 struct snd_kcontrol *kctl = NULL;
2667 struct snd_kcontrol_new *knew;
2672 for (i = 0; i < spec->num_mixers; i++) {
2673 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
2677 if (spec->cap_mixer) {
2678 err = snd_hda_add_new_ctls(codec, spec->cap_mixer);
2682 if (spec->multiout.dig_out_nid) {
2683 err = snd_hda_create_spdif_out_ctls(codec,
2684 spec->multiout.dig_out_nid);
2687 if (!spec->no_analog) {
2688 err = snd_hda_create_spdif_share_sw(codec,
2692 spec->multiout.share_spdif = 1;
2695 if (spec->dig_in_nid) {
2696 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
2701 #ifdef CONFIG_SND_HDA_INPUT_BEEP
2702 /* create beep controls if needed */
2703 if (spec->beep_amp) {
2704 struct snd_kcontrol_new *knew;
2705 for (knew = alc_beep_mixer; knew->name; knew++) {
2706 struct snd_kcontrol *kctl;
2707 kctl = snd_ctl_new1(knew, codec);
2710 kctl->private_value = spec->beep_amp;
2711 err = snd_hda_ctl_add(codec, 0, kctl);
2718 /* if we have no master control, let's create it */
2719 if (!spec->no_analog &&
2720 !snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
2721 unsigned int vmaster_tlv[4];
2722 snd_hda_set_vmaster_tlv(codec, spec->vmaster_nid,
2723 HDA_OUTPUT, vmaster_tlv);
2724 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
2725 vmaster_tlv, alc_slave_vols);
2729 if (!spec->no_analog &&
2730 !snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
2731 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
2732 NULL, alc_slave_sws);
2737 /* assign Capture Source enums to NID */
2738 if (spec->capsrc_nids || spec->adc_nids) {
2739 kctl = snd_hda_find_mixer_ctl(codec, "Capture Source");
2741 kctl = snd_hda_find_mixer_ctl(codec, "Input Source");
2742 for (i = 0; kctl && i < kctl->count; i++) {
2743 hda_nid_t *nids = spec->capsrc_nids;
2745 nids = spec->adc_nids;
2746 err = snd_hda_add_nid(codec, kctl, i, nids[i]);
2751 if (spec->cap_mixer) {
2752 const char *kname = kctl ? kctl->id.name : NULL;
2753 for (knew = spec->cap_mixer; knew->name; knew++) {
2754 if (kname && strcmp(knew->name, kname) == 0)
2756 kctl = snd_hda_find_mixer_ctl(codec, knew->name);
2757 for (i = 0; kctl && i < kctl->count; i++) {
2758 err = snd_hda_add_nid(codec, kctl, i,
2766 /* other nid->control mapping */
2767 for (i = 0; i < spec->num_mixers; i++) {
2768 for (knew = spec->mixers[i]; knew->name; knew++) {
2769 if (knew->iface != NID_MAPPING)
2771 kctl = snd_hda_find_mixer_ctl(codec, knew->name);
2774 u = knew->subdevice;
2775 for (j = 0; j < 4; j++, u >>= 8) {
2780 case SUBDEV_SPEAKER_:
2781 nid = spec->autocfg.speaker_pins[nid];
2784 nid = spec->autocfg.line_out_pins[nid];
2787 nid = spec->autocfg.hp_pins[nid];
2792 err = snd_hda_add_nid(codec, kctl, 0, nid);
2796 u = knew->private_value;
2797 for (j = 0; j < 4; j++, u >>= 8) {
2801 err = snd_hda_add_nid(codec, kctl, 0, nid);
2808 alc_free_kctls(codec); /* no longer needed */
2815 * initialize the codec volumes, etc
2819 * generic initialization of ADC, input mixers and output mixers
2821 static struct hda_verb alc880_volume_init_verbs[] = {
2823 * Unmute ADC0-2 and set the default input to mic-in
2825 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
2826 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2827 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
2828 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2829 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
2830 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2832 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
2834 * Note: PASD motherboards uses the Line In 2 as the input for front
2837 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
2838 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2839 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2840 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
2841 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
2842 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
2843 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
2844 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
2847 * Set up output mixers (0x0c - 0x0f)
2849 /* set vol=0 to output mixers */
2850 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2851 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2852 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2853 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2854 /* set up input amps for analog loopback */
2855 /* Amp Indices: DAC = 0, mixer = 1 */
2856 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2857 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2858 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2859 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2860 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2861 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2862 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2863 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2869 * 3-stack pin configuration:
2870 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
2872 static struct hda_verb alc880_pin_3stack_init_verbs[] = {
2874 * preset connection lists of input pins
2875 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
2877 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
2878 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2879 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
2882 * Set pin mode and muting
2884 /* set front pin widgets 0x14 for output */
2885 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2886 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2887 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2888 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2889 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2890 /* Mic2 (as headphone out) for HP output */
2891 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2892 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2893 /* Line In pin widget for input */
2894 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2895 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2896 /* Line2 (as front mic) pin widget for input and vref at 80% */
2897 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2898 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2899 /* CD pin widget for input */
2900 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2906 * 5-stack pin configuration:
2907 * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
2908 * line-in/side = 0x1a, f-mic = 0x1b
2910 static struct hda_verb alc880_pin_5stack_init_verbs[] = {
2912 * preset connection lists of input pins
2913 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
2915 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2916 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
2919 * Set pin mode and muting
2921 /* set pin widgets 0x14-0x17 for output */
2922 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2923 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2924 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2925 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2926 /* unmute pins for output (no gain on this amp) */
2927 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2928 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2929 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2930 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2932 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2933 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2934 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2935 /* Mic2 (as headphone out) for HP output */
2936 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2937 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2938 /* Line In pin widget for input */
2939 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2940 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2941 /* Line2 (as front mic) pin widget for input and vref at 80% */
2942 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2943 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2944 /* CD pin widget for input */
2945 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2951 * W810 pin configuration:
2952 * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
2954 static struct hda_verb alc880_pin_w810_init_verbs[] = {
2955 /* hphone/speaker input selector: front DAC */
2956 {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
2958 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2959 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2960 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2961 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2962 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2963 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2965 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2966 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2972 * Z71V pin configuration:
2973 * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
2975 static struct hda_verb alc880_pin_z71v_init_verbs[] = {
2976 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2977 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2978 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2979 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2981 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2982 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2983 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2984 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2990 * 6-stack pin configuration:
2991 * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18,
2992 * f-mic = 0x19, line = 0x1a, HP = 0x1b
2994 static struct hda_verb alc880_pin_6stack_init_verbs[] = {
2995 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2997 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2998 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2999 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3000 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3001 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3002 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3003 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3004 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3006 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3007 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3008 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3009 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3010 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3011 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3012 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3013 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3014 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3020 * Uniwill pin configuration:
3021 * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19,
3024 static struct hda_verb alc880_uniwill_init_verbs[] = {
3025 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3027 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3028 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3029 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3030 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3031 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3032 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3033 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3034 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3035 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3036 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3037 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3038 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3039 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3040 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3042 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3043 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3044 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3045 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3046 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3047 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3048 /* {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, */
3049 /* {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
3050 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3052 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
3053 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
3060 * HP = 0x14, InternalSpeaker = 0x15, mic = 0x19,
3062 static struct hda_verb alc880_uniwill_p53_init_verbs[] = {
3063 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3065 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3066 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3067 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3068 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3069 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3070 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3071 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3072 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3073 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3074 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3075 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3076 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3078 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3079 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3080 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3081 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3082 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3083 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3085 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
3086 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_DCVOL_EVENT},
3091 static struct hda_verb alc880_beep_init_verbs[] = {
3092 { 0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5) },
3096 /* auto-toggle front mic */
3097 static void alc880_uniwill_mic_automute(struct hda_codec *codec)
3099 unsigned int present;
3102 present = snd_hda_jack_detect(codec, 0x18);
3103 bits = present ? HDA_AMP_MUTE : 0;
3104 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
3107 static void alc880_uniwill_setup(struct hda_codec *codec)
3109 struct alc_spec *spec = codec->spec;
3111 spec->autocfg.hp_pins[0] = 0x14;
3112 spec->autocfg.speaker_pins[0] = 0x15;
3113 spec->autocfg.speaker_pins[0] = 0x16;
3116 static void alc880_uniwill_init_hook(struct hda_codec *codec)
3118 alc_automute_amp(codec);
3119 alc880_uniwill_mic_automute(codec);
3122 static void alc880_uniwill_unsol_event(struct hda_codec *codec,
3125 /* Looks like the unsol event is incompatible with the standard
3126 * definition. 4bit tag is placed at 28 bit!
3128 switch (res >> 28) {
3129 case ALC880_MIC_EVENT:
3130 alc880_uniwill_mic_automute(codec);
3133 alc_automute_amp_unsol_event(codec, res);
3138 static void alc880_uniwill_p53_setup(struct hda_codec *codec)
3140 struct alc_spec *spec = codec->spec;
3142 spec->autocfg.hp_pins[0] = 0x14;
3143 spec->autocfg.speaker_pins[0] = 0x15;
3146 static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec)
3148 unsigned int present;
3150 present = snd_hda_codec_read(codec, 0x21, 0,
3151 AC_VERB_GET_VOLUME_KNOB_CONTROL, 0);
3152 present &= HDA_AMP_VOLMASK;
3153 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0,
3154 HDA_AMP_VOLMASK, present);
3155 snd_hda_codec_amp_stereo(codec, 0x0d, HDA_OUTPUT, 0,
3156 HDA_AMP_VOLMASK, present);
3159 static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec,
3162 /* Looks like the unsol event is incompatible with the standard
3163 * definition. 4bit tag is placed at 28 bit!
3165 if ((res >> 28) == ALC880_DCVOL_EVENT)
3166 alc880_uniwill_p53_dcvol_automute(codec);
3168 alc_automute_amp_unsol_event(codec, res);
3172 * F1734 pin configuration:
3173 * HP = 0x14, speaker-out = 0x15, mic = 0x18
3175 static struct hda_verb alc880_pin_f1734_init_verbs[] = {
3176 {0x07, AC_VERB_SET_CONNECT_SEL, 0x01},
3177 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
3178 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
3179 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
3180 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
3182 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3183 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3184 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3185 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3187 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3188 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3189 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
3190 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3191 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3192 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3193 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3194 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3195 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3197 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
3198 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_DCVOL_EVENT},
3204 * ASUS pin configuration:
3205 * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
3207 static struct hda_verb alc880_pin_asus_init_verbs[] = {
3208 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
3209 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
3210 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
3211 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
3213 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3214 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3215 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3216 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3217 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3218 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3219 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3220 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3222 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3223 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3224 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3225 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3226 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3227 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3228 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3229 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3230 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3235 /* Enable GPIO mask and set output */
3236 #define alc880_gpio1_init_verbs alc_gpio1_init_verbs
3237 #define alc880_gpio2_init_verbs alc_gpio2_init_verbs
3238 #define alc880_gpio3_init_verbs alc_gpio3_init_verbs
3240 /* Clevo m520g init */
3241 static struct hda_verb alc880_pin_clevo_init_verbs[] = {
3242 /* headphone output */
3243 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
3245 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3246 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3248 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3249 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3251 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3252 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3253 /* Mic1 (rear panel) */
3254 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3255 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3256 /* Mic2 (front panel) */
3257 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3258 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3260 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3261 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3262 /* change to EAPD mode */
3263 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
3264 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
3269 static struct hda_verb alc880_pin_tcl_S700_init_verbs[]&n