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 <sound/jack.h>
32 #include "hda_codec.h"
33 #include "hda_local.h"
36 #define ALC880_FRONT_EVENT 0x01
37 #define ALC880_DCVOL_EVENT 0x02
38 #define ALC880_HP_EVENT 0x04
39 #define ALC880_MIC_EVENT 0x08
41 /* ALC880 board config type */
65 #ifdef CONFIG_SND_DEBUG
69 ALC880_MODEL_LAST /* last tag */
83 #ifdef CONFIG_SND_DEBUG
87 ALC260_MODEL_LAST /* last tag */
97 ALC262_HP_BPC_D7000_WL,
98 ALC262_HP_BPC_D7000_WF,
111 ALC262_MODEL_LAST /* last tag */
121 ALC268_ACER_ASPIRE_ONE,
124 #ifdef CONFIG_SND_DEBUG
128 ALC268_MODEL_LAST /* last tag */
143 ALC269_MODEL_LAST /* last tag */
160 /* ALC861-VD models */
182 ALC662_ASUS_EEEPC_P701,
183 ALC662_ASUS_EEEPC_EP20,
225 ALC883_TARGA_2ch_DIG,
226 ALC883_TARGA_8ch_DIG,
229 ALC888_ACER_ASPIRE_4930G,
230 ALC888_ACER_ASPIRE_6530G,
231 ALC888_ACER_ASPIRE_8930G,
232 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;
297 unsigned int fixup:1; /* Means that this sku is set by driver, not read from hw */
303 /* codec parameterization */
304 struct snd_kcontrol_new *mixers[5]; /* mixer arrays */
305 unsigned int num_mixers;
306 struct snd_kcontrol_new *cap_mixer; /* capture mixer */
307 unsigned int beep_amp; /* beep amp value, set via set_beep_amp() */
309 const struct hda_verb *init_verbs[10]; /* initialization verbs
313 unsigned int num_init_verbs;
315 char stream_name_analog[32]; /* analog PCM stream */
316 struct hda_pcm_stream *stream_analog_playback;
317 struct hda_pcm_stream *stream_analog_capture;
318 struct hda_pcm_stream *stream_analog_alt_playback;
319 struct hda_pcm_stream *stream_analog_alt_capture;
321 char stream_name_digital[32]; /* digital PCM stream */
322 struct hda_pcm_stream *stream_digital_playback;
323 struct hda_pcm_stream *stream_digital_capture;
326 struct hda_multi_out multiout; /* playback set-up
327 * max_channels, dacs must be set
328 * dig_out_nid and hp_nid are optional
330 hda_nid_t alt_dac_nid;
331 hda_nid_t slave_dig_outs[3]; /* optional - for auto-parsing */
335 unsigned int num_adc_nids;
337 hda_nid_t *capsrc_nids;
338 hda_nid_t dig_in_nid; /* digital-in NID; optional */
340 /* capture setup for dynamic dual-adc switch */
341 unsigned int cur_adc_idx;
343 unsigned int cur_adc_stream_tag;
344 unsigned int cur_adc_format;
347 unsigned int num_mux_defs;
348 const struct hda_input_mux *input_mux;
349 unsigned int cur_mux[3];
350 struct alc_mic_route ext_mic;
351 struct alc_mic_route int_mic;
354 const struct hda_channel_mode *channel_mode;
355 int num_channel_mode;
357 int const_channel_count;
358 int ext_channel_count;
360 /* PCM information */
361 struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */
363 /* dynamic controls, init_verbs and input_mux */
364 struct auto_pin_cfg autocfg;
365 struct alc_customize_define cdefine;
366 struct snd_array kctls;
367 struct hda_input_mux private_imux[3];
368 hda_nid_t private_dac_nids[AUTO_CFG_MAX_OUTS];
369 hda_nid_t private_adc_nids[AUTO_CFG_MAX_OUTS];
370 hda_nid_t private_capsrc_nids[AUTO_CFG_MAX_OUTS];
373 void (*init_hook)(struct hda_codec *codec);
374 void (*unsol_event)(struct hda_codec *codec, unsigned int res);
375 #ifdef CONFIG_SND_HDA_POWER_SAVE
376 void (*power_hook)(struct hda_codec *codec);
379 /* for pin sensing */
380 unsigned int sense_updated: 1;
381 unsigned int jack_present: 1;
382 unsigned int master_sw: 1;
383 unsigned int auto_mic:1;
386 unsigned int no_analog :1; /* digital I/O only */
387 unsigned int dual_adc_switch:1; /* switch ADCs (for ALC275) */
388 unsigned int single_input_src:1;
390 int codec_variant; /* flag for other variants */
392 /* for virtual master */
393 hda_nid_t vmaster_nid;
394 #ifdef CONFIG_SND_HDA_POWER_SAVE
395 struct hda_loopback_check loopback;
400 unsigned int pll_coef_idx, pll_coef_bit;
404 const struct alc_fixup *fixup_list;
405 const char *fixup_name;
409 * configuration template - to be copied to the spec instance
411 struct alc_config_preset {
412 struct snd_kcontrol_new *mixers[5]; /* should be identical size
415 struct snd_kcontrol_new *cap_mixer; /* capture mixer */
416 const struct hda_verb *init_verbs[5];
417 unsigned int num_dacs;
419 hda_nid_t dig_out_nid; /* optional */
420 hda_nid_t hp_nid; /* optional */
421 hda_nid_t *slave_dig_outs;
422 unsigned int num_adc_nids;
424 hda_nid_t *capsrc_nids;
425 hda_nid_t dig_in_nid;
426 unsigned int num_channel_mode;
427 const struct hda_channel_mode *channel_mode;
429 int const_channel_count;
430 unsigned int num_mux_defs;
431 const struct hda_input_mux *input_mux;
432 void (*unsol_event)(struct hda_codec *, unsigned int);
433 void (*setup)(struct hda_codec *);
434 void (*init_hook)(struct hda_codec *);
435 #ifdef CONFIG_SND_HDA_POWER_SAVE
436 struct hda_amp_list *loopbacks;
437 void (*power_hook)(struct hda_codec *codec);
445 static int alc_mux_enum_info(struct snd_kcontrol *kcontrol,
446 struct snd_ctl_elem_info *uinfo)
448 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
449 struct alc_spec *spec = codec->spec;
450 unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id);
451 if (mux_idx >= spec->num_mux_defs)
453 if (!spec->input_mux[mux_idx].num_items && mux_idx > 0)
455 return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo);
458 static int alc_mux_enum_get(struct snd_kcontrol *kcontrol,
459 struct snd_ctl_elem_value *ucontrol)
461 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
462 struct alc_spec *spec = codec->spec;
463 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
465 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
469 static int alc_mux_enum_put(struct snd_kcontrol *kcontrol,
470 struct snd_ctl_elem_value *ucontrol)
472 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
473 struct alc_spec *spec = codec->spec;
474 const struct hda_input_mux *imux;
475 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
476 unsigned int mux_idx;
477 hda_nid_t nid = spec->capsrc_nids ?
478 spec->capsrc_nids[adc_idx] : spec->adc_nids[adc_idx];
481 mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx;
482 imux = &spec->input_mux[mux_idx];
483 if (!imux->num_items && mux_idx > 0)
484 imux = &spec->input_mux[0];
486 type = get_wcaps_type(get_wcaps(codec, nid));
487 if (type == AC_WID_AUD_MIX) {
488 /* Matrix-mixer style (e.g. ALC882) */
489 unsigned int *cur_val = &spec->cur_mux[adc_idx];
492 idx = ucontrol->value.enumerated.item[0];
493 if (idx >= imux->num_items)
494 idx = imux->num_items - 1;
497 for (i = 0; i < imux->num_items; i++) {
498 unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
499 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
500 imux->items[i].index,
506 /* MUX style (e.g. ALC880) */
507 return snd_hda_input_mux_put(codec, imux, ucontrol, nid,
508 &spec->cur_mux[adc_idx]);
513 * channel mode setting
515 static int alc_ch_mode_info(struct snd_kcontrol *kcontrol,
516 struct snd_ctl_elem_info *uinfo)
518 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
519 struct alc_spec *spec = codec->spec;
520 return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
521 spec->num_channel_mode);
524 static int alc_ch_mode_get(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 return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
530 spec->num_channel_mode,
531 spec->ext_channel_count);
534 static int alc_ch_mode_put(struct snd_kcontrol *kcontrol,
535 struct snd_ctl_elem_value *ucontrol)
537 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
538 struct alc_spec *spec = codec->spec;
539 int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
540 spec->num_channel_mode,
541 &spec->ext_channel_count);
542 if (err >= 0 && !spec->const_channel_count) {
543 spec->multiout.max_channels = spec->ext_channel_count;
544 if (spec->need_dac_fix)
545 spec->multiout.num_dacs = spec->multiout.max_channels / 2;
551 * Control the mode of pin widget settings via the mixer. "pc" is used
552 * instead of "%" to avoid consequences of accidently treating the % as
553 * being part of a format specifier. Maximum allowed length of a value is
554 * 63 characters plus NULL terminator.
556 * Note: some retasking pin complexes seem to ignore requests for input
557 * states other than HiZ (eg: PIN_VREFxx) and revert to HiZ if any of these
558 * are requested. Therefore order this list so that this behaviour will not
559 * cause problems when mixer clients move through the enum sequentially.
560 * NIDs 0x0f and 0x10 have been observed to have this behaviour as of
563 static char *alc_pin_mode_names[] = {
564 "Mic 50pc bias", "Mic 80pc bias",
565 "Line in", "Line out", "Headphone out",
567 static unsigned char alc_pin_mode_values[] = {
568 PIN_VREF50, PIN_VREF80, PIN_IN, PIN_OUT, PIN_HP,
570 /* The control can present all 5 options, or it can limit the options based
571 * in the pin being assumed to be exclusively an input or an output pin. In
572 * addition, "input" pins may or may not process the mic bias option
573 * depending on actual widget capability (NIDs 0x0f and 0x10 don't seem to
574 * accept requests for bias as of chip versions up to March 2006) and/or
575 * wiring in the computer.
577 #define ALC_PIN_DIR_IN 0x00
578 #define ALC_PIN_DIR_OUT 0x01
579 #define ALC_PIN_DIR_INOUT 0x02
580 #define ALC_PIN_DIR_IN_NOMICBIAS 0x03
581 #define ALC_PIN_DIR_INOUT_NOMICBIAS 0x04
583 /* Info about the pin modes supported by the different pin direction modes.
584 * For each direction the minimum and maximum values are given.
586 static signed char alc_pin_mode_dir_info[5][2] = {
587 { 0, 2 }, /* ALC_PIN_DIR_IN */
588 { 3, 4 }, /* ALC_PIN_DIR_OUT */
589 { 0, 4 }, /* ALC_PIN_DIR_INOUT */
590 { 2, 2 }, /* ALC_PIN_DIR_IN_NOMICBIAS */
591 { 2, 4 }, /* ALC_PIN_DIR_INOUT_NOMICBIAS */
593 #define alc_pin_mode_min(_dir) (alc_pin_mode_dir_info[_dir][0])
594 #define alc_pin_mode_max(_dir) (alc_pin_mode_dir_info[_dir][1])
595 #define alc_pin_mode_n_items(_dir) \
596 (alc_pin_mode_max(_dir)-alc_pin_mode_min(_dir)+1)
598 static int alc_pin_mode_info(struct snd_kcontrol *kcontrol,
599 struct snd_ctl_elem_info *uinfo)
601 unsigned int item_num = uinfo->value.enumerated.item;
602 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
604 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
606 uinfo->value.enumerated.items = alc_pin_mode_n_items(dir);
608 if (item_num<alc_pin_mode_min(dir) || item_num>alc_pin_mode_max(dir))
609 item_num = alc_pin_mode_min(dir);
610 strcpy(uinfo->value.enumerated.name, alc_pin_mode_names[item_num]);
614 static int alc_pin_mode_get(struct snd_kcontrol *kcontrol,
615 struct snd_ctl_elem_value *ucontrol)
618 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
619 hda_nid_t nid = kcontrol->private_value & 0xffff;
620 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
621 long *valp = ucontrol->value.integer.value;
622 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
623 AC_VERB_GET_PIN_WIDGET_CONTROL,
626 /* Find enumerated value for current pinctl setting */
627 i = alc_pin_mode_min(dir);
628 while (i <= alc_pin_mode_max(dir) && alc_pin_mode_values[i] != pinctl)
630 *valp = i <= alc_pin_mode_max(dir) ? i: alc_pin_mode_min(dir);
634 static int alc_pin_mode_put(struct snd_kcontrol *kcontrol,
635 struct snd_ctl_elem_value *ucontrol)
638 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
639 hda_nid_t nid = kcontrol->private_value & 0xffff;
640 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
641 long val = *ucontrol->value.integer.value;
642 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
643 AC_VERB_GET_PIN_WIDGET_CONTROL,
646 if (val < alc_pin_mode_min(dir) || val > alc_pin_mode_max(dir))
647 val = alc_pin_mode_min(dir);
649 change = pinctl != alc_pin_mode_values[val];
651 /* Set pin mode to that requested */
652 snd_hda_codec_write_cache(codec, nid, 0,
653 AC_VERB_SET_PIN_WIDGET_CONTROL,
654 alc_pin_mode_values[val]);
656 /* Also enable the retasking pin's input/output as required
657 * for the requested pin mode. Enum values of 2 or less are
660 * Dynamically switching the input/output buffers probably
661 * reduces noise slightly (particularly on input) so we'll
662 * do it. However, having both input and output buffers
663 * enabled simultaneously doesn't seem to be problematic if
664 * this turns out to be necessary in the future.
667 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
668 HDA_AMP_MUTE, HDA_AMP_MUTE);
669 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
672 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
673 HDA_AMP_MUTE, HDA_AMP_MUTE);
674 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
681 #define ALC_PIN_MODE(xname, nid, dir) \
682 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
683 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
684 .info = alc_pin_mode_info, \
685 .get = alc_pin_mode_get, \
686 .put = alc_pin_mode_put, \
687 .private_value = nid | (dir<<16) }
689 /* A switch control for ALC260 GPIO pins. Multiple GPIOs can be ganged
690 * together using a mask with more than one bit set. This control is
691 * currently used only by the ALC260 test model. At this stage they are not
692 * needed for any "production" models.
694 #ifdef CONFIG_SND_DEBUG
695 #define alc_gpio_data_info snd_ctl_boolean_mono_info
697 static int alc_gpio_data_get(struct snd_kcontrol *kcontrol,
698 struct snd_ctl_elem_value *ucontrol)
700 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
701 hda_nid_t nid = kcontrol->private_value & 0xffff;
702 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
703 long *valp = ucontrol->value.integer.value;
704 unsigned int val = snd_hda_codec_read(codec, nid, 0,
705 AC_VERB_GET_GPIO_DATA, 0x00);
707 *valp = (val & mask) != 0;
710 static int alc_gpio_data_put(struct snd_kcontrol *kcontrol,
711 struct snd_ctl_elem_value *ucontrol)
714 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
715 hda_nid_t nid = kcontrol->private_value & 0xffff;
716 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
717 long val = *ucontrol->value.integer.value;
718 unsigned int gpio_data = snd_hda_codec_read(codec, nid, 0,
719 AC_VERB_GET_GPIO_DATA,
722 /* Set/unset the masked GPIO bit(s) as needed */
723 change = (val == 0 ? 0 : mask) != (gpio_data & mask);
728 snd_hda_codec_write_cache(codec, nid, 0,
729 AC_VERB_SET_GPIO_DATA, gpio_data);
733 #define ALC_GPIO_DATA_SWITCH(xname, nid, mask) \
734 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
735 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
736 .info = alc_gpio_data_info, \
737 .get = alc_gpio_data_get, \
738 .put = alc_gpio_data_put, \
739 .private_value = nid | (mask<<16) }
740 #endif /* CONFIG_SND_DEBUG */
742 /* A switch control to allow the enabling of the digital IO pins on the
743 * ALC260. This is incredibly simplistic; the intention of this control is
744 * to provide something in the test model allowing digital outputs to be
745 * identified if present. If models are found which can utilise these
746 * outputs a more complete mixer control can be devised for those models if
749 #ifdef CONFIG_SND_DEBUG
750 #define alc_spdif_ctrl_info snd_ctl_boolean_mono_info
752 static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol,
753 struct snd_ctl_elem_value *ucontrol)
755 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
756 hda_nid_t nid = kcontrol->private_value & 0xffff;
757 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
758 long *valp = ucontrol->value.integer.value;
759 unsigned int val = snd_hda_codec_read(codec, nid, 0,
760 AC_VERB_GET_DIGI_CONVERT_1, 0x00);
762 *valp = (val & mask) != 0;
765 static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol,
766 struct snd_ctl_elem_value *ucontrol)
769 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
770 hda_nid_t nid = kcontrol->private_value & 0xffff;
771 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
772 long val = *ucontrol->value.integer.value;
773 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
774 AC_VERB_GET_DIGI_CONVERT_1,
777 /* Set/unset the masked control bit(s) as needed */
778 change = (val == 0 ? 0 : mask) != (ctrl_data & mask);
783 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1,
788 #define ALC_SPDIF_CTRL_SWITCH(xname, nid, mask) \
789 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
790 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
791 .info = alc_spdif_ctrl_info, \
792 .get = alc_spdif_ctrl_get, \
793 .put = alc_spdif_ctrl_put, \
794 .private_value = nid | (mask<<16) }
795 #endif /* CONFIG_SND_DEBUG */
797 /* A switch control to allow the enabling EAPD digital outputs on the ALC26x.
798 * Again, this is only used in the ALC26x test models to help identify when
799 * the EAPD line must be asserted for features to work.
801 #ifdef CONFIG_SND_DEBUG
802 #define alc_eapd_ctrl_info snd_ctl_boolean_mono_info
804 static int alc_eapd_ctrl_get(struct snd_kcontrol *kcontrol,
805 struct snd_ctl_elem_value *ucontrol)
807 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
808 hda_nid_t nid = kcontrol->private_value & 0xffff;
809 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
810 long *valp = ucontrol->value.integer.value;
811 unsigned int val = snd_hda_codec_read(codec, nid, 0,
812 AC_VERB_GET_EAPD_BTLENABLE, 0x00);
814 *valp = (val & mask) != 0;
818 static int alc_eapd_ctrl_put(struct snd_kcontrol *kcontrol,
819 struct snd_ctl_elem_value *ucontrol)
822 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
823 hda_nid_t nid = kcontrol->private_value & 0xffff;
824 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
825 long val = *ucontrol->value.integer.value;
826 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
827 AC_VERB_GET_EAPD_BTLENABLE,
830 /* Set/unset the masked control bit(s) as needed */
831 change = (!val ? 0 : mask) != (ctrl_data & mask);
836 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
842 #define ALC_EAPD_CTRL_SWITCH(xname, nid, mask) \
843 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
844 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
845 .info = alc_eapd_ctrl_info, \
846 .get = alc_eapd_ctrl_get, \
847 .put = alc_eapd_ctrl_put, \
848 .private_value = nid | (mask<<16) }
849 #endif /* CONFIG_SND_DEBUG */
852 * set up the input pin config (depending on the given auto-pin type)
854 static void alc_set_input_pin(struct hda_codec *codec, hda_nid_t nid,
857 unsigned int val = PIN_IN;
859 if (auto_pin_type == AUTO_PIN_MIC) {
862 oldval = snd_hda_codec_read(codec, nid, 0,
863 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
864 pincap = snd_hda_query_pin_caps(codec, nid);
865 pincap = (pincap & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT;
866 /* if the default pin setup is vref50, we give it priority */
867 if ((pincap & AC_PINCAP_VREF_80) && oldval != PIN_VREF50)
869 else if (pincap & AC_PINCAP_VREF_50)
871 else if (pincap & AC_PINCAP_VREF_100)
873 else if (pincap & AC_PINCAP_VREF_GRD)
876 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, val);
879 static void alc_fixup_autocfg_pin_nums(struct hda_codec *codec)
881 struct alc_spec *spec = codec->spec;
882 struct auto_pin_cfg *cfg = &spec->autocfg;
884 if (!cfg->line_outs) {
885 while (cfg->line_outs < AUTO_CFG_MAX_OUTS &&
886 cfg->line_out_pins[cfg->line_outs])
889 if (!cfg->speaker_outs) {
890 while (cfg->speaker_outs < AUTO_CFG_MAX_OUTS &&
891 cfg->speaker_pins[cfg->speaker_outs])
895 while (cfg->hp_outs < AUTO_CFG_MAX_OUTS &&
896 cfg->hp_pins[cfg->hp_outs])
903 static void add_mixer(struct alc_spec *spec, struct snd_kcontrol_new *mix)
905 if (snd_BUG_ON(spec->num_mixers >= ARRAY_SIZE(spec->mixers)))
907 spec->mixers[spec->num_mixers++] = mix;
910 static void add_verb(struct alc_spec *spec, const struct hda_verb *verb)
912 if (snd_BUG_ON(spec->num_init_verbs >= ARRAY_SIZE(spec->init_verbs)))
914 spec->init_verbs[spec->num_init_verbs++] = verb;
918 * set up from the preset table
920 static void setup_preset(struct hda_codec *codec,
921 const struct alc_config_preset *preset)
923 struct alc_spec *spec = codec->spec;
926 for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++)
927 add_mixer(spec, preset->mixers[i]);
928 spec->cap_mixer = preset->cap_mixer;
929 for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i];
931 add_verb(spec, preset->init_verbs[i]);
933 spec->channel_mode = preset->channel_mode;
934 spec->num_channel_mode = preset->num_channel_mode;
935 spec->need_dac_fix = preset->need_dac_fix;
936 spec->const_channel_count = preset->const_channel_count;
938 if (preset->const_channel_count)
939 spec->multiout.max_channels = preset->const_channel_count;
941 spec->multiout.max_channels = spec->channel_mode[0].channels;
942 spec->ext_channel_count = spec->channel_mode[0].channels;
944 spec->multiout.num_dacs = preset->num_dacs;
945 spec->multiout.dac_nids = preset->dac_nids;
946 spec->multiout.dig_out_nid = preset->dig_out_nid;
947 spec->multiout.slave_dig_outs = preset->slave_dig_outs;
948 spec->multiout.hp_nid = preset->hp_nid;
950 spec->num_mux_defs = preset->num_mux_defs;
951 if (!spec->num_mux_defs)
952 spec->num_mux_defs = 1;
953 spec->input_mux = preset->input_mux;
955 spec->num_adc_nids = preset->num_adc_nids;
956 spec->adc_nids = preset->adc_nids;
957 spec->capsrc_nids = preset->capsrc_nids;
958 spec->dig_in_nid = preset->dig_in_nid;
960 spec->unsol_event = preset->unsol_event;
961 spec->init_hook = preset->init_hook;
962 #ifdef CONFIG_SND_HDA_POWER_SAVE
963 spec->power_hook = preset->power_hook;
964 spec->loopback.amplist = preset->loopbacks;
968 preset->setup(codec);
970 alc_fixup_autocfg_pin_nums(codec);
973 /* Enable GPIO mask and set output */
974 static struct hda_verb alc_gpio1_init_verbs[] = {
975 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
976 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
977 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
981 static struct hda_verb alc_gpio2_init_verbs[] = {
982 {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
983 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
984 {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
988 static struct hda_verb alc_gpio3_init_verbs[] = {
989 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
990 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
991 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
996 * Fix hardware PLL issue
997 * On some codecs, the analog PLL gating control must be off while
998 * the default value is 1.
1000 static void alc_fix_pll(struct hda_codec *codec)
1002 struct alc_spec *spec = codec->spec;
1007 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX,
1008 spec->pll_coef_idx);
1009 val = snd_hda_codec_read(codec, spec->pll_nid, 0,
1010 AC_VERB_GET_PROC_COEF, 0);
1011 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX,
1012 spec->pll_coef_idx);
1013 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_PROC_COEF,
1014 val & ~(1 << spec->pll_coef_bit));
1017 static void alc_fix_pll_init(struct hda_codec *codec, hda_nid_t nid,
1018 unsigned int coef_idx, unsigned int coef_bit)
1020 struct alc_spec *spec = codec->spec;
1021 spec->pll_nid = nid;
1022 spec->pll_coef_idx = coef_idx;
1023 spec->pll_coef_bit = coef_bit;
1027 static int alc_init_jacks(struct hda_codec *codec)
1029 #ifdef CONFIG_SND_HDA_INPUT_JACK
1030 struct alc_spec *spec = codec->spec;
1032 unsigned int hp_nid = spec->autocfg.hp_pins[0];
1033 unsigned int mic_nid = spec->ext_mic.pin;
1036 err = snd_hda_input_jack_add(codec, hp_nid,
1037 SND_JACK_HEADPHONE, NULL);
1040 snd_hda_input_jack_report(codec, hp_nid);
1044 err = snd_hda_input_jack_add(codec, mic_nid,
1045 SND_JACK_MICROPHONE, NULL);
1048 snd_hda_input_jack_report(codec, mic_nid);
1050 #endif /* CONFIG_SND_HDA_INPUT_JACK */
1054 static void alc_automute_speaker(struct hda_codec *codec, int pinctl)
1056 struct alc_spec *spec = codec->spec;
1061 spec->jack_present = 0;
1062 for (i = 0; i < ARRAY_SIZE(spec->autocfg.hp_pins); i++) {
1063 nid = spec->autocfg.hp_pins[i];
1066 snd_hda_input_jack_report(codec, nid);
1067 spec->jack_present |= snd_hda_jack_detect(codec, nid);
1070 mute = spec->jack_present ? HDA_AMP_MUTE : 0;
1071 /* Toggle internal speakers muting */
1072 for (i = 0; i < ARRAY_SIZE(spec->autocfg.speaker_pins); i++) {
1073 nid = spec->autocfg.speaker_pins[i];
1077 snd_hda_codec_write(codec, nid, 0,
1078 AC_VERB_SET_PIN_WIDGET_CONTROL,
1079 spec->jack_present ? 0 : PIN_OUT);
1081 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
1082 HDA_AMP_MUTE, mute);
1087 static void alc_automute_pin(struct hda_codec *codec)
1089 alc_automute_speaker(codec, 1);
1092 static int get_connection_index(struct hda_codec *codec, hda_nid_t mux,
1095 hda_nid_t conn[HDA_MAX_NUM_INPUTS];
1098 nums = snd_hda_get_connections(codec, mux, conn, ARRAY_SIZE(conn));
1099 for (i = 0; i < nums; i++)
1105 /* switch the current ADC according to the jack state */
1106 static void alc_dual_mic_adc_auto_switch(struct hda_codec *codec)
1108 struct alc_spec *spec = codec->spec;
1109 unsigned int present;
1112 present = snd_hda_jack_detect(codec, spec->ext_mic.pin);
1114 spec->cur_adc_idx = 1;
1116 spec->cur_adc_idx = 0;
1117 new_adc = spec->adc_nids[spec->cur_adc_idx];
1118 if (spec->cur_adc && spec->cur_adc != new_adc) {
1119 /* stream is running, let's swap the current ADC */
1120 __snd_hda_codec_cleanup_stream(codec, spec->cur_adc, 1);
1121 spec->cur_adc = new_adc;
1122 snd_hda_codec_setup_stream(codec, new_adc,
1123 spec->cur_adc_stream_tag, 0,
1124 spec->cur_adc_format);
1128 static void alc_mic_automute(struct hda_codec *codec)
1130 struct alc_spec *spec = codec->spec;
1131 struct alc_mic_route *dead, *alive;
1132 unsigned int present, type;
1135 if (!spec->auto_mic)
1137 if (!spec->int_mic.pin || !spec->ext_mic.pin)
1139 if (snd_BUG_ON(!spec->adc_nids))
1142 if (spec->dual_adc_switch) {
1143 alc_dual_mic_adc_auto_switch(codec);
1147 cap_nid = spec->capsrc_nids ? spec->capsrc_nids[0] : spec->adc_nids[0];
1149 present = snd_hda_jack_detect(codec, spec->ext_mic.pin);
1151 alive = &spec->ext_mic;
1152 dead = &spec->int_mic;
1154 alive = &spec->int_mic;
1155 dead = &spec->ext_mic;
1158 type = get_wcaps_type(get_wcaps(codec, cap_nid));
1159 if (type == AC_WID_AUD_MIX) {
1160 /* Matrix-mixer style (e.g. ALC882) */
1161 snd_hda_codec_amp_stereo(codec, cap_nid, HDA_INPUT,
1164 snd_hda_codec_amp_stereo(codec, cap_nid, HDA_INPUT,
1166 HDA_AMP_MUTE, HDA_AMP_MUTE);
1168 /* MUX style (e.g. ALC880) */
1169 snd_hda_codec_write_cache(codec, cap_nid, 0,
1170 AC_VERB_SET_CONNECT_SEL,
1173 snd_hda_input_jack_report(codec, spec->ext_mic.pin);
1175 /* FIXME: analog mixer */
1178 /* unsolicited event for HP jack sensing */
1179 static void alc_sku_unsol_event(struct hda_codec *codec, unsigned int res)
1181 if (codec->vendor_id == 0x10ec0880)
1186 case ALC880_HP_EVENT:
1187 alc_automute_pin(codec);
1189 case ALC880_MIC_EVENT:
1190 alc_mic_automute(codec);
1195 static void alc_inithook(struct hda_codec *codec)
1197 alc_automute_pin(codec);
1198 alc_mic_automute(codec);
1201 /* additional initialization for ALC888 variants */
1202 static void alc888_coef_init(struct hda_codec *codec)
1206 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 0);
1207 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
1208 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
1209 if ((tmp & 0xf0) == 0x20)
1211 snd_hda_codec_read(codec, 0x20, 0,
1212 AC_VERB_SET_PROC_COEF, 0x830);
1215 snd_hda_codec_read(codec, 0x20, 0,
1216 AC_VERB_SET_PROC_COEF, 0x3030);
1219 static void alc889_coef_init(struct hda_codec *codec)
1223 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
1224 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
1225 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
1226 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_PROC_COEF, tmp|0x2010);
1229 /* turn on/off EAPD control (only if available) */
1230 static void set_eapd(struct hda_codec *codec, hda_nid_t nid, int on)
1232 if (get_wcaps_type(get_wcaps(codec, nid)) != AC_WID_PIN)
1234 if (snd_hda_query_pin_caps(codec, nid) & AC_PINCAP_EAPD)
1235 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
1239 static void alc_auto_init_amp(struct hda_codec *codec, int type)
1244 case ALC_INIT_GPIO1:
1245 snd_hda_sequence_write(codec, alc_gpio1_init_verbs);
1247 case ALC_INIT_GPIO2:
1248 snd_hda_sequence_write(codec, alc_gpio2_init_verbs);
1250 case ALC_INIT_GPIO3:
1251 snd_hda_sequence_write(codec, alc_gpio3_init_verbs);
1253 case ALC_INIT_DEFAULT:
1254 switch (codec->vendor_id) {
1256 set_eapd(codec, 0x0f, 1);
1257 set_eapd(codec, 0x10, 1);
1270 set_eapd(codec, 0x14, 1);
1271 set_eapd(codec, 0x15, 1);
1274 switch (codec->vendor_id) {
1276 snd_hda_codec_write(codec, 0x1a, 0,
1277 AC_VERB_SET_COEF_INDEX, 7);
1278 tmp = snd_hda_codec_read(codec, 0x1a, 0,
1279 AC_VERB_GET_PROC_COEF, 0);
1280 snd_hda_codec_write(codec, 0x1a, 0,
1281 AC_VERB_SET_COEF_INDEX, 7);
1282 snd_hda_codec_write(codec, 0x1a, 0,
1283 AC_VERB_SET_PROC_COEF,
1293 alc889_coef_init(codec);
1296 alc888_coef_init(codec);
1298 #if 0 /* XXX: This may cause the silent output on speaker on some machines */
1301 snd_hda_codec_write(codec, 0x20, 0,
1302 AC_VERB_SET_COEF_INDEX, 7);
1303 tmp = snd_hda_codec_read(codec, 0x20, 0,
1304 AC_VERB_GET_PROC_COEF, 0);
1305 snd_hda_codec_write(codec, 0x20, 0,
1306 AC_VERB_SET_COEF_INDEX, 7);
1307 snd_hda_codec_write(codec, 0x20, 0,
1308 AC_VERB_SET_PROC_COEF,
1317 static void alc_init_auto_hp(struct hda_codec *codec)
1319 struct alc_spec *spec = codec->spec;
1320 struct auto_pin_cfg *cfg = &spec->autocfg;
1323 if (!cfg->hp_pins[0]) {
1324 if (cfg->line_out_type != AUTO_PIN_HP_OUT)
1328 if (!cfg->speaker_pins[0]) {
1329 if (cfg->line_out_type != AUTO_PIN_SPEAKER_OUT)
1331 memcpy(cfg->speaker_pins, cfg->line_out_pins,
1332 sizeof(cfg->speaker_pins));
1333 cfg->speaker_outs = cfg->line_outs;
1336 if (!cfg->hp_pins[0]) {
1337 memcpy(cfg->hp_pins, cfg->line_out_pins,
1338 sizeof(cfg->hp_pins));
1339 cfg->hp_outs = cfg->line_outs;
1342 for (i = 0; i < cfg->hp_outs; i++) {
1343 snd_printdd("realtek: Enable HP auto-muting on NID 0x%x\n",
1345 snd_hda_codec_write_cache(codec, cfg->hp_pins[i], 0,
1346 AC_VERB_SET_UNSOLICITED_ENABLE,
1347 AC_USRSP_EN | ALC880_HP_EVENT);
1349 spec->unsol_event = alc_sku_unsol_event;
1352 static void alc_init_auto_mic(struct hda_codec *codec)
1354 struct alc_spec *spec = codec->spec;
1355 struct auto_pin_cfg *cfg = &spec->autocfg;
1356 hda_nid_t fixed, ext;
1359 /* there must be only two mic inputs exclusively */
1360 for (i = 0; i < cfg->num_inputs; i++)
1361 if (cfg->inputs[i].type >= AUTO_PIN_LINE_IN)
1365 for (i = 0; i < cfg->num_inputs; i++) {
1366 hda_nid_t nid = cfg->inputs[i].pin;
1367 unsigned int defcfg;
1368 defcfg = snd_hda_codec_get_pincfg(codec, nid);
1369 switch (snd_hda_get_input_pin_attr(defcfg)) {
1370 case INPUT_PIN_ATTR_INT:
1372 return; /* already occupied */
1375 case INPUT_PIN_ATTR_UNUSED:
1376 return; /* invalid entry */
1379 return; /* already occupied */
1386 if (!(get_wcaps(codec, ext) & AC_WCAP_UNSOL_CAP))
1387 return; /* no unsol support */
1388 snd_printdd("realtek: Enable auto-mic switch on NID 0x%x/0x%x\n",
1390 spec->ext_mic.pin = ext;
1391 spec->int_mic.pin = fixed;
1392 spec->ext_mic.mux_idx = MUX_IDX_UNDEF; /* set later */
1393 spec->int_mic.mux_idx = MUX_IDX_UNDEF; /* set later */
1395 snd_hda_codec_write_cache(codec, spec->ext_mic.pin, 0,
1396 AC_VERB_SET_UNSOLICITED_ENABLE,
1397 AC_USRSP_EN | ALC880_MIC_EVENT);
1398 spec->unsol_event = alc_sku_unsol_event;
1401 /* Could be any non-zero and even value. When used as fixup, tells
1402 * the driver to ignore any present sku defines.
1404 #define ALC_FIXUP_SKU_IGNORE (2)
1406 static int alc_auto_parse_customize_define(struct hda_codec *codec)
1408 unsigned int ass, tmp, i;
1410 struct alc_spec *spec = codec->spec;
1412 spec->cdefine.enable_pcbeep = 1; /* assume always enabled */
1414 if (spec->cdefine.fixup) {
1415 ass = spec->cdefine.sku_cfg;
1416 if (ass == ALC_FIXUP_SKU_IGNORE)
1421 ass = codec->subsystem_id & 0xffff;
1422 if (ass != codec->bus->pci->subsystem_device && (ass & 1))
1426 if (codec->vendor_id == 0x10ec0260)
1428 ass = snd_hda_codec_get_pincfg(codec, nid);
1431 printk(KERN_INFO "hda_codec: %s: SKU not ready 0x%08x\n",
1432 codec->chip_name, ass);
1438 for (i = 1; i < 16; i++) {
1442 if (((ass >> 16) & 0xf) != tmp)
1445 spec->cdefine.port_connectivity = ass >> 30;
1446 spec->cdefine.enable_pcbeep = (ass & 0x100000) >> 20;
1447 spec->cdefine.check_sum = (ass >> 16) & 0xf;
1448 spec->cdefine.customization = ass >> 8;
1450 spec->cdefine.sku_cfg = ass;
1451 spec->cdefine.external_amp = (ass & 0x38) >> 3;
1452 spec->cdefine.platform_type = (ass & 0x4) >> 2;
1453 spec->cdefine.swap = (ass & 0x2) >> 1;
1454 spec->cdefine.override = ass & 0x1;
1456 snd_printd("SKU: Nid=0x%x sku_cfg=0x%08x\n",
1457 nid, spec->cdefine.sku_cfg);
1458 snd_printd("SKU: port_connectivity=0x%x\n",
1459 spec->cdefine.port_connectivity);
1460 snd_printd("SKU: enable_pcbeep=0x%x\n", spec->cdefine.enable_pcbeep);
1461 snd_printd("SKU: check_sum=0x%08x\n", spec->cdefine.check_sum);
1462 snd_printd("SKU: customization=0x%08x\n", spec->cdefine.customization);
1463 snd_printd("SKU: external_amp=0x%x\n", spec->cdefine.external_amp);
1464 snd_printd("SKU: platform_type=0x%x\n", spec->cdefine.platform_type);
1465 snd_printd("SKU: swap=0x%x\n", spec->cdefine.swap);
1466 snd_printd("SKU: override=0x%x\n", spec->cdefine.override);
1471 /* check subsystem ID and set up device-specific initialization;
1472 * return 1 if initialized, 0 if invalid SSID
1474 /* 32-bit subsystem ID for BIOS loading in HD Audio codec.
1475 * 31 ~ 16 : Manufacture ID
1477 * 7 ~ 0 : Assembly ID
1478 * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36
1480 static int alc_subsystem_id(struct hda_codec *codec,
1481 hda_nid_t porta, hda_nid_t porte,
1482 hda_nid_t portd, hda_nid_t porti)
1484 unsigned int ass, tmp, i;
1486 struct alc_spec *spec = codec->spec;
1488 if (spec->cdefine.fixup) {
1489 ass = spec->cdefine.sku_cfg;
1490 if (ass == ALC_FIXUP_SKU_IGNORE)
1495 ass = codec->subsystem_id & 0xffff;
1496 if ((ass != codec->bus->pci->subsystem_device) && (ass & 1))
1499 /* invalid SSID, check the special NID pin defcfg instead */
1501 * 31~30 : port connectivity
1504 * 19~16 : Check sum (15:1)
1509 if (codec->vendor_id == 0x10ec0260)
1511 ass = snd_hda_codec_get_pincfg(codec, nid);
1512 snd_printd("realtek: No valid SSID, "
1513 "checking pincfg 0x%08x for NID 0x%x\n",
1517 if ((ass >> 30) != 1) /* no physical connection */
1522 for (i = 1; i < 16; i++) {
1526 if (((ass >> 16) & 0xf) != tmp)
1529 snd_printd("realtek: Enabling init ASM_ID=0x%04x CODEC_ID=%08x\n",
1530 ass & 0xffff, codec->vendor_id);
1534 * 2 : 0 --> Desktop, 1 --> Laptop
1535 * 3~5 : External Amplifier control
1538 tmp = (ass & 0x38) >> 3; /* external Amp control */
1541 spec->init_amp = ALC_INIT_GPIO1;
1544 spec->init_amp = ALC_INIT_GPIO2;
1547 spec->init_amp = ALC_INIT_GPIO3;
1551 spec->init_amp = ALC_INIT_DEFAULT;
1555 /* is laptop or Desktop and enable the function "Mute internal speaker
1556 * when the external headphone out jack is plugged"
1558 if (!(ass & 0x8000))
1561 * 10~8 : Jack location
1562 * 12~11: Headphone out -> 00: PortA, 01: PortE, 02: PortD, 03: Resvered
1564 * 15 : 1 --> enable the function "Mute internal speaker
1565 * when the external headphone out jack is plugged"
1567 if (!spec->autocfg.hp_pins[0]) {
1569 tmp = (ass >> 11) & 0x3; /* HP to chassis */
1580 for (i = 0; i < spec->autocfg.line_outs; i++)
1581 if (spec->autocfg.line_out_pins[i] == nid)
1583 spec->autocfg.hp_pins[0] = nid;
1586 alc_init_auto_hp(codec);
1587 alc_init_auto_mic(codec);
1591 static void alc_ssid_check(struct hda_codec *codec,
1592 hda_nid_t porta, hda_nid_t porte,
1593 hda_nid_t portd, hda_nid_t porti)
1595 if (!alc_subsystem_id(codec, porta, porte, portd, porti)) {
1596 struct alc_spec *spec = codec->spec;
1597 snd_printd("realtek: "
1598 "Enable default setup for auto mode as fallback\n");
1599 spec->init_amp = ALC_INIT_DEFAULT;
1600 alc_init_auto_hp(codec);
1601 alc_init_auto_mic(codec);
1606 * Fix-up pin default configurations and add default verbs
1614 struct alc_model_fixup {
1625 const struct alc_pincfg *pins;
1626 const struct hda_verb *verbs;
1627 void (*func)(struct hda_codec *codec,
1628 const struct alc_fixup *fix,
1642 ALC_FIXUP_ACT_PRE_PROBE,
1643 ALC_FIXUP_ACT_PROBE,
1647 static void alc_apply_fixup(struct hda_codec *codec, int action)
1649 struct alc_spec *spec = codec->spec;
1650 int id = spec->fixup_id;
1651 #ifdef CONFIG_SND_DEBUG_VERBOSE
1652 const char *modelname = spec->fixup_name;
1656 if (!spec->fixup_list)
1660 const struct alc_fixup *fix = spec->fixup_list + id;
1661 const struct alc_pincfg *cfg;
1663 switch (fix->type) {
1665 if (action != ALC_FIXUP_ACT_PRE_PROBE || !fix->v.sku)
1667 snd_printdd(KERN_INFO "hda_codec: %s: "
1668 "Apply sku override for %s\n",
1669 codec->chip_name, modelname);
1670 spec->cdefine.sku_cfg = fix->v.sku;
1671 spec->cdefine.fixup = 1;
1673 case ALC_FIXUP_PINS:
1675 if (action != ALC_FIXUP_ACT_PRE_PROBE || !cfg)
1677 snd_printdd(KERN_INFO "hda_codec: %s: "
1678 "Apply pincfg for %s\n",
1679 codec->chip_name, modelname);
1680 for (; cfg->nid; cfg++)
1681 snd_hda_codec_set_pincfg(codec, cfg->nid,
1684 case ALC_FIXUP_VERBS:
1685 if (action != ALC_FIXUP_ACT_PROBE || !fix->v.verbs)
1687 snd_printdd(KERN_INFO "hda_codec: %s: "
1688 "Apply fix-verbs for %s\n",
1689 codec->chip_name, modelname);
1690 add_verb(codec->spec, fix->v.verbs);
1692 case ALC_FIXUP_FUNC:
1695 snd_printdd(KERN_INFO "hda_codec: %s: "
1696 "Apply fix-func for %s\n",
1697 codec->chip_name, modelname);
1698 fix->v.func(codec, fix, action);
1701 snd_printk(KERN_ERR "hda_codec: %s: "
1702 "Invalid fixup type %d\n",
1703 codec->chip_name, fix->type);
1706 if (!fix[id].chained)
1710 id = fix[id].chain_id;
1714 static void alc_pick_fixup(struct hda_codec *codec,
1715 const struct alc_model_fixup *models,
1716 const struct snd_pci_quirk *quirk,
1717 const struct alc_fixup *fixlist)
1719 struct alc_spec *spec = codec->spec;
1721 const char *name = NULL;
1723 if (codec->modelname && models) {
1724 while (models->name) {
1725 if (!strcmp(codec->modelname, models->name)) {
1727 name = models->name;
1734 quirk = snd_pci_quirk_lookup(codec->bus->pci, quirk);
1737 #ifdef CONFIG_SND_DEBUG_VERBOSE
1743 spec->fixup_id = id;
1745 spec->fixup_list = fixlist;
1746 spec->fixup_name = name;
1750 static int alc_read_coef_idx(struct hda_codec *codec,
1751 unsigned int coef_idx)
1754 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX,
1756 val = snd_hda_codec_read(codec, 0x20, 0,
1757 AC_VERB_GET_PROC_COEF, 0);
1761 static void alc_write_coef_idx(struct hda_codec *codec, unsigned int coef_idx,
1762 unsigned int coef_val)
1764 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX,
1766 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_PROC_COEF,
1770 /* set right pin controls for digital I/O */
1771 static void alc_auto_init_digital(struct hda_codec *codec)
1773 struct alc_spec *spec = codec->spec;
1777 for (i = 0; i < spec->autocfg.dig_outs; i++) {
1778 pin = spec->autocfg.dig_out_pins[i];
1780 snd_hda_codec_write(codec, pin, 0,
1781 AC_VERB_SET_PIN_WIDGET_CONTROL,
1785 pin = spec->autocfg.dig_in_pin;
1787 snd_hda_codec_write(codec, pin, 0,
1788 AC_VERB_SET_PIN_WIDGET_CONTROL,
1792 /* parse digital I/Os and set up NIDs in BIOS auto-parse mode */
1793 static void alc_auto_parse_digital(struct hda_codec *codec)
1795 struct alc_spec *spec = codec->spec;
1799 /* support multiple SPDIFs; the secondary is set up as a slave */
1800 for (i = 0; i < spec->autocfg.dig_outs; i++) {
1801 err = snd_hda_get_connections(codec,
1802 spec->autocfg.dig_out_pins[i],
1807 spec->multiout.dig_out_nid = dig_nid;
1808 spec->dig_out_type = spec->autocfg.dig_out_type[0];
1810 spec->multiout.slave_dig_outs = spec->slave_dig_outs;
1811 if (i >= ARRAY_SIZE(spec->slave_dig_outs) - 1)
1813 spec->slave_dig_outs[i - 1] = dig_nid;
1817 if (spec->autocfg.dig_in_pin) {
1818 dig_nid = codec->start_nid;
1819 for (i = 0; i < codec->num_nodes; i++, dig_nid++) {
1820 unsigned int wcaps = get_wcaps(codec, dig_nid);
1821 if (get_wcaps_type(wcaps) != AC_WID_AUD_IN)
1823 if (!(wcaps & AC_WCAP_DIGITAL))
1825 if (!(wcaps & AC_WCAP_CONN_LIST))
1827 err = get_connection_index(codec, dig_nid,
1828 spec->autocfg.dig_in_pin);
1830 spec->dig_in_nid = dig_nid;
1844 static struct hda_verb alc888_4ST_ch2_intel_init[] = {
1845 /* Mic-in jack as mic in */
1846 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1847 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1848 /* Line-in jack as Line in */
1849 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1850 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1851 /* Line-Out as Front */
1852 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
1859 static struct hda_verb alc888_4ST_ch4_intel_init[] = {
1860 /* Mic-in jack as mic in */
1861 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1862 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1863 /* Line-in jack as Surround */
1864 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1865 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1866 /* Line-Out as Front */
1867 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
1874 static struct hda_verb alc888_4ST_ch6_intel_init[] = {
1875 /* Mic-in jack as CLFE */
1876 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1877 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1878 /* Line-in jack as Surround */
1879 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1880 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1881 /* Line-Out as CLFE (workaround because Mic-in is not loud enough) */
1882 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1889 static struct hda_verb alc888_4ST_ch8_intel_init[] = {
1890 /* Mic-in jack as CLFE */
1891 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1892 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1893 /* Line-in jack as Surround */
1894 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1895 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1896 /* Line-Out as Side */
1897 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1901 static struct hda_channel_mode alc888_4ST_8ch_intel_modes[4] = {
1902 { 2, alc888_4ST_ch2_intel_init },
1903 { 4, alc888_4ST_ch4_intel_init },
1904 { 6, alc888_4ST_ch6_intel_init },
1905 { 8, alc888_4ST_ch8_intel_init },
1909 * ALC888 Fujitsu Siemens Amillo xa3530
1912 static struct hda_verb alc888_fujitsu_xa3530_verbs[] = {
1913 /* Front Mic: set to PIN_IN (empty by default) */
1914 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1915 /* Connect Internal HP to Front */
1916 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1917 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1918 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1919 /* Connect Bass HP to Front */
1920 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1921 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1922 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1923 /* Connect Line-Out side jack (SPDIF) to Side */
1924 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1925 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1926 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1927 /* Connect Mic jack to CLFE */
1928 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1929 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1930 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02},
1931 /* Connect Line-in jack to Surround */
1932 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1933 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1934 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
1935 /* Connect HP out jack to Front */
1936 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1937 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1938 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
1939 /* Enable unsolicited event for HP jack and Line-out jack */
1940 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1941 {0x17, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1945 static void alc_automute_amp(struct hda_codec *codec)
1947 alc_automute_speaker(codec, 0);
1950 static void alc_automute_amp_unsol_event(struct hda_codec *codec,
1953 if (codec->vendor_id == 0x10ec0880)
1957 if (res == ALC880_HP_EVENT)
1958 alc_automute_amp(codec);
1961 static void alc889_automute_setup(struct hda_codec *codec)
1963 struct alc_spec *spec = codec->spec;
1965 spec->autocfg.hp_pins[0] = 0x15;
1966 spec->autocfg.speaker_pins[0] = 0x14;
1967 spec->autocfg.speaker_pins[1] = 0x16;
1968 spec->autocfg.speaker_pins[2] = 0x17;
1969 spec->autocfg.speaker_pins[3] = 0x19;
1970 spec->autocfg.speaker_pins[4] = 0x1a;
1973 static void alc889_intel_init_hook(struct hda_codec *codec)
1975 alc889_coef_init(codec);
1976 alc_automute_amp(codec);
1979 static void alc888_fujitsu_xa3530_setup(struct hda_codec *codec)
1981 struct alc_spec *spec = codec->spec;
1983 spec->autocfg.hp_pins[0] = 0x17; /* line-out */
1984 spec->autocfg.hp_pins[1] = 0x1b; /* hp */
1985 spec->autocfg.speaker_pins[0] = 0x14; /* speaker */
1986 spec->autocfg.speaker_pins[1] = 0x15; /* bass */
1990 * ALC888 Acer Aspire 4930G model
1993 static struct hda_verb alc888_acer_aspire_4930g_verbs[] = {
1994 /* Front Mic: set to PIN_IN (empty by default) */
1995 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1996 /* Unselect Front Mic by default in input mixer 3 */
1997 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
1998 /* Enable unsolicited event for HP jack */
1999 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
2000 /* Connect Internal HP to front */
2001 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2002 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2003 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
2004 /* Connect HP out to front */
2005 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2006 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2007 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
2008 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
2013 * ALC888 Acer Aspire 6530G model
2016 static struct hda_verb alc888_acer_aspire_6530g_verbs[] = {
2017 /* Route to built-in subwoofer as well as speakers */
2018 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2019 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2020 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2021 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2022 /* Bias voltage on for external mic port */
2023 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN | PIN_VREF80},
2024 /* Front Mic: set to PIN_IN (empty by default) */
2025 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2026 /* Unselect Front Mic by default in input mixer 3 */
2027 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
2028 /* Enable unsolicited event for HP jack */
2029 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
2030 /* Enable speaker output */
2031 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2032 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2033 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
2034 /* Enable headphone output */
2035 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | PIN_HP},
2036 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2037 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
2038 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
2043 *ALC888 Acer Aspire 7730G model
2046 static struct hda_verb alc888_acer_aspire_7730G_verbs[] = {
2047 /* Bias voltage on for external mic port */
2048 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN | PIN_VREF80},
2049 /* Front Mic: set to PIN_IN (empty by default) */
2050 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2051 /* Unselect Front Mic by default in input mixer 3 */
2052 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
2053 /* Enable unsolicited event for HP jack */
2054 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
2055 /* Enable speaker output */
2056 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2057 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2058 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
2059 /* Enable headphone output */
2060 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | PIN_HP},
2061 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2062 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
2063 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
2064 /*Enable internal subwoofer */
2065 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2066 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2067 {0x17, AC_VERB_SET_CONNECT_SEL, 0x02},
2068 {0x17, AC_VERB_SET_EAPD_BTLENABLE, 2},
2073 * ALC889 Acer Aspire 8930G model
2076 static struct hda_verb alc889_acer_aspire_8930g_verbs[] = {
2077 /* Front Mic: set to PIN_IN (empty by default) */
2078 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2079 /* Unselect Front Mic by default in input mixer 3 */
2080 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
2081 /* Enable unsolicited event for HP jack */
2082 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
2083 /* Connect Internal Front to Front */
2084 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2085 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2086 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
2087 /* Connect Internal Rear to Rear */
2088 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2089 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2090 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01},
2091 /* Connect Internal CLFE to CLFE */
2092 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2093 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2094 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
2095 /* Connect HP out to Front */
2096 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | PIN_HP},
2097 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2098 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
2099 /* Enable all DACs */
2100 /* DAC DISABLE/MUTE 1? */
2101 /* setting bits 1-5 disables DAC nids 0x02-0x06 apparently. Init=0x38 */
2102 {0x20, AC_VERB_SET_COEF_INDEX, 0x03},
2103 {0x20, AC_VERB_SET_PROC_COEF, 0x0000},
2104 /* DAC DISABLE/MUTE 2? */
2105 /* some bit here disables the other DACs. Init=0x4900 */
2106 {0x20, AC_VERB_SET_COEF_INDEX, 0x08},
2107 {0x20, AC_VERB_SET_PROC_COEF, 0x0000},
2109 * This laptop has a stereo digital microphone. The mics are only 1cm apart
2110 * which makes the stereo useless. However, either the mic or the ALC889
2111 * makes the signal become a difference/sum signal instead of standard
2112 * stereo, which is annoying. So instead we flip this bit which makes the
2113 * codec replicate the sum signal to both channels, turning it into a
2116 /* DMIC_CONTROL? Init value = 0x0001 */
2117 {0x20, AC_VERB_SET_COEF_INDEX, 0x0b},
2118 {0x20, AC_VERB_SET_PROC_COEF, 0x0003},
2122 static struct hda_input_mux alc888_2_capture_sources[2] = {
2123 /* Front mic only available on one ADC */
2130 { "Front Mic", 0xb },
2143 static struct hda_input_mux alc888_acer_aspire_6530_sources[2] = {
2144 /* Interal mic only available on one ADC */
2151 { "Input Mix", 0xa },
2152 { "Internal Mic", 0xb },
2161 { "Input Mix", 0xa },
2166 static struct hda_input_mux alc889_capture_sources[3] = {
2167 /* Digital mic only available on first "ADC" */
2174 { "Front Mic", 0xb },
2175 { "Input Mix", 0xa },
2184 { "Input Mix", 0xa },
2193 { "Input Mix", 0xa },
2198 static struct snd_kcontrol_new alc888_base_mixer[] = {
2199 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2200 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2201 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2202 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
2203 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
2205 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2206 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2207 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2208 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
2209 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
2210 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2211 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2212 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2213 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2214 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2215 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
2216 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2220 static struct snd_kcontrol_new alc888_acer_aspire_4930g_mixer[] = {
2221 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2222 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2223 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2224 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
2225 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
2227 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2228 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2229 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2230 HDA_CODEC_VOLUME_MONO("Internal LFE Playback Volume", 0x0f, 1, 0x0, HDA_OUTPUT),
2231 HDA_BIND_MUTE_MONO("Internal LFE Playback Switch", 0x0f, 1, 2, HDA_INPUT),
2232 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2233 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2234 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2235 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2236 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2237 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
2238 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2242 static struct snd_kcontrol_new alc889_acer_aspire_8930g_mixer[] = {
2243 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2244 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2245 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2246 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
2247 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
2249 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2250 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2251 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2252 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2253 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2254 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2255 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
2256 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2261 static void alc888_acer_aspire_4930g_setup(struct hda_codec *codec)
2263 struct alc_spec *spec = codec->spec;
2265 spec->autocfg.hp_pins[0] = 0x15;
2266 spec->autocfg.speaker_pins[0] = 0x14;
2267 spec->autocfg.speaker_pins[1] = 0x16;
2268 spec->autocfg.speaker_pins[2] = 0x17;
2271 static void alc888_acer_aspire_6530g_setup(struct hda_codec *codec)
2273 struct alc_spec *spec = codec->spec;
2275 spec->autocfg.hp_pins[0] = 0x15;
2276 spec->autocfg.speaker_pins[0] = 0x14;
2277 spec->autocfg.speaker_pins[1] = 0x16;
2278 spec->autocfg.speaker_pins[2] = 0x17;
2281 static void alc888_acer_aspire_7730g_setup(struct hda_codec *codec)
2283 struct alc_spec *spec = codec->spec;
2285 spec->autocfg.hp_pins[0] = 0x15;
2286 spec->autocfg.speaker_pins[0] = 0x14;
2287 spec->autocfg.speaker_pins[1] = 0x16;
2288 spec->autocfg.speaker_pins[2] = 0x17;
2291 static void alc889_acer_aspire_8930g_setup(struct hda_codec *codec)
2293 struct alc_spec *spec = codec->spec;
2295 spec->autocfg.hp_pins[0] = 0x15;
2296 spec->autocfg.speaker_pins[0] = 0x14;
2297 spec->autocfg.speaker_pins[1] = 0x16;
2298 spec->autocfg.speaker_pins[2] = 0x1b;
2302 * ALC880 3-stack model
2304 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
2305 * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18,
2306 * F-Mic = 0x1b, HP = 0x19
2309 static hda_nid_t alc880_dac_nids[4] = {
2310 /* front, rear, clfe, rear_surr */
2311 0x02, 0x05, 0x04, 0x03
2314 static hda_nid_t alc880_adc_nids[3] = {
2319 /* The datasheet says the node 0x07 is connected from inputs,
2320 * but it shows zero connection in the real implementation on some devices.
2321 * Note: this is a 915GAV bug, fixed on 915GLV
2323 static hda_nid_t alc880_adc_nids_alt[2] = {
2328 #define ALC880_DIGOUT_NID 0x06
2329 #define ALC880_DIGIN_NID 0x0a
2331 static struct hda_input_mux alc880_capture_source = {
2335 { "Front Mic", 0x3 },
2341 /* channel source setting (2/6 channel selection for 3-stack) */
2343 static struct hda_verb alc880_threestack_ch2_init[] = {
2344 /* set line-in to input, mute it */
2345 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
2346 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
2347 /* set mic-in to input vref 80%, mute it */
2348 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
2349 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
2354 static struct hda_verb alc880_threestack_ch6_init[] = {
2355 /* set line-in to output, unmute it */
2356 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
2357 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
2358 /* set mic-in to output, unmute it */
2359 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
2360 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
2364 static struct hda_channel_mode alc880_threestack_modes[2] = {
2365 { 2, alc880_threestack_ch2_init },
2366 { 6, alc880_threestack_ch6_init },
2369 static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
2370 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2371 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2372 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
2373 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
2374 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2375 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2376 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2377 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2378 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2379 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2380 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2381 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2382 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2383 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2384 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
2385 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
2386 HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
2388 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2389 .name = "Channel Mode",
2390 .info = alc_ch_mode_info,
2391 .get = alc_ch_mode_get,
2392 .put = alc_ch_mode_put,
2397 /* capture mixer elements */
2398 static int alc_cap_vol_info(struct snd_kcontrol *kcontrol,
2399 struct snd_ctl_elem_info *uinfo)
2401 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2402 struct alc_spec *spec = codec->spec;
2405 mutex_lock(&codec->control_mutex);
2406 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0,
2408 err = snd_hda_mixer_amp_volume_info(kcontrol, uinfo);
2409 mutex_unlock(&codec->control_mutex);
2413 static int alc_cap_vol_tlv(struct snd_kcontrol *kcontrol, int op_flag,
2414 unsigned int size, unsigned int __user *tlv)
2416 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2417 struct alc_spec *spec = codec->spec;
2420 mutex_lock(&codec->control_mutex);
2421 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0,
2423 err = snd_hda_mixer_amp_tlv(kcontrol, op_flag, size, tlv);
2424 mutex_unlock(&codec->control_mutex);
2428 typedef int (*getput_call_t)(struct snd_kcontrol *kcontrol,
2429 struct snd_ctl_elem_value *ucontrol);
2431 static int alc_cap_getput_caller(struct snd_kcontrol *kcontrol,
2432 struct snd_ctl_elem_value *ucontrol,
2435 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2436 struct alc_spec *spec = codec->spec;
2437 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
2440 mutex_lock(&codec->control_mutex);
2441 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[adc_idx],
2443 err = func(kcontrol, ucontrol);
2444 mutex_unlock(&codec->control_mutex);
2448 static int alc_cap_vol_get(struct snd_kcontrol *kcontrol,
2449 struct snd_ctl_elem_value *ucontrol)
2451 return alc_cap_getput_caller(kcontrol, ucontrol,
2452 snd_hda_mixer_amp_volume_get);
2455 static int alc_cap_vol_put(struct snd_kcontrol *kcontrol,
2456 struct snd_ctl_elem_value *ucontrol)
2458 return alc_cap_getput_caller(kcontrol, ucontrol,
2459 snd_hda_mixer_amp_volume_put);
2462 /* capture mixer elements */
2463 #define alc_cap_sw_info snd_ctl_boolean_stereo_info
2465 static int alc_cap_sw_get(struct snd_kcontrol *kcontrol,
2466 struct snd_ctl_elem_value *ucontrol)
2468 return alc_cap_getput_caller(kcontrol, ucontrol,
2469 snd_hda_mixer_amp_switch_get);
2472 static int alc_cap_sw_put(struct snd_kcontrol *kcontrol,
2473 struct snd_ctl_elem_value *ucontrol)
2475 return alc_cap_getput_caller(kcontrol, ucontrol,
2476 snd_hda_mixer_amp_switch_put);
2479 #define _DEFINE_CAPMIX(num) \
2481 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2482 .name = "Capture Switch", \
2483 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, \
2485 .info = alc_cap_sw_info, \
2486 .get = alc_cap_sw_get, \
2487 .put = alc_cap_sw_put, \
2490 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2491 .name = "Capture Volume", \
2492 .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE | \
2493 SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
2494 SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK), \
2496 .info = alc_cap_vol_info, \
2497 .get = alc_cap_vol_get, \
2498 .put = alc_cap_vol_put, \
2499 .tlv = { .c = alc_cap_vol_tlv }, \
2502 #define _DEFINE_CAPSRC(num) \
2504 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2505 /* .name = "Capture Source", */ \
2506 .name = "Input Source", \
2508 .info = alc_mux_enum_info, \
2509 .get = alc_mux_enum_get, \
2510 .put = alc_mux_enum_put, \
2513 #define DEFINE_CAPMIX(num) \
2514 static struct snd_kcontrol_new alc_capture_mixer ## num[] = { \
2515 _DEFINE_CAPMIX(num), \
2516 _DEFINE_CAPSRC(num), \
2520 #define DEFINE_CAPMIX_NOSRC(num) \
2521 static struct snd_kcontrol_new alc_capture_mixer_nosrc ## num[] = { \
2522 _DEFINE_CAPMIX(num), \
2526 /* up to three ADCs */
2530 DEFINE_CAPMIX_NOSRC(1);
2531 DEFINE_CAPMIX_NOSRC(2);
2532 DEFINE_CAPMIX_NOSRC(3);
2535 * ALC880 5-stack model
2537 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d),
2539 * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
2540 * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
2543 /* additional mixers to alc880_three_stack_mixer */
2544 static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
2545 HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2546 HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
2550 /* channel source setting (6/8 channel selection for 5-stack) */
2552 static struct hda_verb alc880_fivestack_ch6_init[] = {
2553 /* set line-in to input, mute it */
2554 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
2555 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
2560 static struct hda_verb alc880_fivestack_ch8_init[] = {
2561 /* set line-in to output, unmute it */
2562 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
2563 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
2567 static struct hda_channel_mode alc880_fivestack_modes[2] = {
2568 { 6, alc880_fivestack_ch6_init },
2569 { 8, alc880_fivestack_ch8_init },
2574 * ALC880 6-stack model
2576 * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e),
2577 * Side = 0x05 (0x0f)
2578 * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
2579 * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
2582 static hda_nid_t alc880_6st_dac_nids[4] = {
2583 /* front, rear, clfe, rear_surr */
2584 0x02, 0x03, 0x04, 0x05
2587 static struct hda_input_mux alc880_6stack_capture_source = {
2591 { "Front Mic", 0x1 },
2597 /* fixed 8-channels */
2598 static struct hda_channel_mode alc880_sixstack_modes[1] = {
2602 static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
2603 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2604 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2605 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2606 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
2607 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2608 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2609 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2610 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2611 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
2612 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
2613 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2614 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2615 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2616 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2617 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2618 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2619 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2620 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
2622 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2623 .name = "Channel Mode",
2624 .info = alc_ch_mode_info,
2625 .get = alc_ch_mode_get,
2626 .put = alc_ch_mode_put,
2635 * W810 has rear IO for:
2638 * Center/LFE (DAC 04)
2641 * The system also has a pair of internal speakers, and a headphone jack.
2642 * These are both connected to Line2 on the codec, hence to DAC 02.
2644 * There is a variable resistor to control the speaker or headphone
2645 * volume. This is a hardware-only device without a software API.
2647 * Plugging headphones in will disable the internal speakers. This is
2648 * implemented in hardware, not via the driver using jack sense. In
2649 * a similar fashion, plugging into the rear socket marked "front" will
2650 * disable both the speakers and headphones.
2652 * For input, there's a microphone jack, and an "audio in" jack.
2653 * These may not do anything useful with this driver yet, because I
2654 * haven't setup any initialization verbs for these yet...
2657 static hda_nid_t alc880_w810_dac_nids[3] = {
2658 /* front, rear/surround, clfe */
2662 /* fixed 6 channels */
2663 static struct hda_channel_mode alc880_w810_modes[1] = {
2667 /* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
2668 static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
2669 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2670 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2671 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2672 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
2673 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2674 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2675 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2676 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2677 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
2685 * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
2686 * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?),
2690 static hda_nid_t alc880_z71v_dac_nids[1] = {
2693 #define ALC880_Z71V_HP_DAC 0x03
2695 /* fixed 2 channels */
2696 static struct hda_channel_mode alc880_2_jack_modes[1] = {
2700 static struct snd_kcontrol_new alc880_z71v_mixer[] = {
2701 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2702 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2703 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2704 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
2705 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2706 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2707 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2708 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2714 * ALC880 F1734 model
2716 * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
2717 * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
2720 static hda_nid_t alc880_f1734_dac_nids[1] = {
2723 #define ALC880_F1734_HP_DAC 0x02
2725 static struct snd_kcontrol_new alc880_f1734_mixer[] = {
2726 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2727 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2728 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2729 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
2730 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2731 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2732 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2733 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
2737 static struct hda_input_mux alc880_f1734_capture_source = {
2749 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
2750 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
2751 * Mic = 0x18, Line = 0x1a
2754 #define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
2755 #define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
2757 static struct snd_kcontrol_new alc880_asus_mixer[] = {
2758 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2759 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2760 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2761 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
2762 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2763 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2764 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2765 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2766 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2767 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2768 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2769 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2770 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2771 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2773 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2774 .name = "Channel Mode",
2775 .info = alc_ch_mode_info,
2776 .get = alc_ch_mode_get,
2777 .put = alc_ch_mode_put,
2783 * ALC880 ASUS W1V model
2785 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
2786 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
2787 * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
2790 /* additional mixers to alc880_asus_mixer */
2791 static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
2792 HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
2793 HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
2798 static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
2799 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2800 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
2801 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
2802 HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
2803 HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
2804 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
2805 HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
2806 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
2807 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
2812 static struct snd_kcontrol_new alc880_uniwill_mixer[] = {
2813 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2814 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2815 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2816 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
2817 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2818 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2819 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2820 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2821 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2822 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2823 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2824 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2825 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2826 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2827 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2828 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
2830 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2831 .name = "Channel Mode",
2832 .info = alc_ch_mode_info,
2833 .get = alc_ch_mode_get,
2834 .put = alc_ch_mode_put,
2839 static struct snd_kcontrol_new alc880_fujitsu_mixer[] = {
2840 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2841 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2842 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2843 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
2844 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2845 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2846 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2847 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2848 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2849 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
2853 static struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = {
2854 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2855 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2856 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2857 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
2858 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2859 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2864 * virtual master controls
2868 * slave controls for virtual master
2870 static const char * const alc_slave_vols[] = {
2871 "Front Playback Volume",
2872 "Surround Playback Volume",
2873 "Center Playback Volume",
2874 "LFE Playback Volume",
2875 "Side Playback Volume",
2876 "Headphone Playback Volume",
2877 "Speaker Playback Volume",
2878 "Mono Playback Volume",
2879 "Line-Out Playback Volume",
2880 "PCM Playback Volume",
2884 static const char * const alc_slave_sws[] = {
2885 "Front Playback Switch",
2886 "Surround Playback Switch",
2887 "Center Playback Switch",
2888 "LFE Playback Switch",
2889 "Side Playback Switch",
2890 "Headphone Playback Switch",
2891 "Speaker Playback Switch",
2892 "Mono Playback Switch",
2893 "IEC958 Playback Switch",
2894 "Line-Out Playback Switch",
2895 "PCM Playback Switch",
2900 * build control elements
2903 #define NID_MAPPING (-1)
2905 #define SUBDEV_SPEAKER_ (0 << 6)
2906 #define SUBDEV_HP_ (1 << 6)
2907 #define SUBDEV_LINE_ (2 << 6)
2908 #define SUBDEV_SPEAKER(x) (SUBDEV_SPEAKER_ | ((x) & 0x3f))
2909 #define SUBDEV_HP(x) (SUBDEV_HP_ | ((x) & 0x3f))
2910 #define SUBDEV_LINE(x) (SUBDEV_LINE_ | ((x) & 0x3f))
2912 static void alc_free_kctls(struct hda_codec *codec);
2914 #ifdef CONFIG_SND_HDA_INPUT_BEEP
2915 /* additional beep mixers; the actual parameters are overwritten at build */
2916 static struct snd_kcontrol_new alc_beep_mixer[] = {
2917 HDA_CODEC_VOLUME("Beep Playback Volume", 0, 0, HDA_INPUT),
2918 HDA_CODEC_MUTE_BEEP("Beep Playback Switch", 0, 0, HDA_INPUT),
2923 static int alc_build_controls(struct hda_codec *codec)
2925 struct alc_spec *spec = codec->spec;
2926 struct snd_kcontrol *kctl = NULL;
2927 struct snd_kcontrol_new *knew;
2932 for (i = 0; i < spec->num_mixers; i++) {
2933 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
2937 if (spec->cap_mixer) {
2938 err = snd_hda_add_new_ctls(codec, spec->cap_mixer);
2942 if (spec->multiout.dig_out_nid) {
2943 err = snd_hda_create_spdif_out_ctls(codec,
2944 spec->multiout.dig_out_nid);
2947 if (!spec->no_analog) {
2948 err = snd_hda_create_spdif_share_sw(codec,
2952 spec->multiout.share_spdif = 1;
2955 if (spec->dig_in_nid) {
2956 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
2961 #ifdef CONFIG_SND_HDA_INPUT_BEEP
2962 /* create beep controls if needed */
2963 if (spec->beep_amp) {
2964 struct snd_kcontrol_new *knew;
2965 for (knew = alc_beep_mixer; knew->name; knew++) {
2966 struct snd_kcontrol *kctl;
2967 kctl = snd_ctl_new1(knew, codec);
2970 kctl->private_value = spec->beep_amp;
2971 err = snd_hda_ctl_add(codec, 0, kctl);
2978 /* if we have no master control, let's create it */
2979 if (!spec->no_analog &&
2980 !snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
2981 unsigned int vmaster_tlv[4];
2982 snd_hda_set_vmaster_tlv(codec, spec->vmaster_nid,
2983 HDA_OUTPUT, vmaster_tlv);
2984 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
2985 vmaster_tlv, alc_slave_vols);
2989 if (!spec->no_analog &&
2990 !snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
2991 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
2992 NULL, alc_slave_sws);
2997 /* assign Capture Source enums to NID */
2998 if (spec->capsrc_nids || spec->adc_nids) {
2999 kctl = snd_hda_find_mixer_ctl(codec, "Capture Source");
3001 kctl = snd_hda_find_mixer_ctl(codec, "Input Source");
3002 for (i = 0; kctl && i < kctl->count; i++) {
3003 hda_nid_t *nids = spec->capsrc_nids;
3005 nids = spec->adc_nids;
3006 err = snd_hda_add_nid(codec, kctl, i, nids[i]);
3011 if (spec->cap_mixer) {
3012 const char *kname = kctl ? kctl->id.name : NULL;
3013 for (knew = spec->cap_mixer; knew->name; knew++) {
3014 if (kname && strcmp(knew->name, kname) == 0)
3016 kctl = snd_hda_find_mixer_ctl(codec, knew->name);
3017 for (i = 0; kctl && i < kctl->count; i++) {
3018 err = snd_hda_add_nid(codec, kctl, i,
3026 /* other nid->control mapping */
3027 for (i = 0; i < spec->num_mixers; i++) {
3028 for (knew = spec->mixers[i]; knew->name; knew++) {
3029 if (knew->iface != NID_MAPPING)
3031 kctl = snd_hda_find_mixer_ctl(codec, knew->name);
3034 u = knew->subdevice;
3035 for (j = 0; j < 4; j++, u >>= 8) {
3040 case SUBDEV_SPEAKER_:
3041 nid = spec->autocfg.speaker_pins[nid];
3044 nid = spec->autocfg.line_out_pins[nid];
3047 nid = spec->autocfg.hp_pins[nid];
3052 err = snd_hda_add_nid(codec, kctl, 0, nid);
3056 u = knew->private_value;
3057 for (j = 0; j < 4; j++, u >>= 8) {
3061 err = snd_hda_add_nid(codec, kctl, 0, nid);
3068 alc_free_kctls(codec); /* no longer needed */
3075 * initialize the codec volumes, etc
3079 * generic initialization of ADC, input mixers and output mixers
3081 static struct hda_verb alc880_volume_init_verbs[] = {
3083 * Unmute ADC0-2 and set the default input to mic-in
3085 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
3086 {0x07, AC_VERB_SET_AMP_