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,
235 ALC883_MEDION_WIM2160,
237 ALC883_LENOVO_101E_2ch,
238 ALC883_LENOVO_NB0763,
239 ALC888_LENOVO_MS7195_DIG,
247 ALC883_FUJITSU_PI2515,
248 ALC888_FUJITSU_XA3530,
249 ALC883_3ST_6ch_INTEL,
269 #define GPIO_MASK 0x03
271 /* extra amp-initialization sequence types */
280 struct alc_mic_route {
282 unsigned char mux_idx;
283 unsigned char amix_idx;
289 struct snd_jack *jack;
292 #define MUX_IDX_UNDEF ((unsigned char)-1)
294 struct alc_customize_define {
295 unsigned int sku_cfg;
296 unsigned char port_connectivity;
297 unsigned char check_sum;
298 unsigned char customization;
299 unsigned char external_amp;
300 unsigned int enable_pcbeep:1;
301 unsigned int platform_type:1;
303 unsigned int override:1;
307 /* codec parameterization */
308 struct snd_kcontrol_new *mixers[5]; /* mixer arrays */
309 unsigned int num_mixers;
310 struct snd_kcontrol_new *cap_mixer; /* capture mixer */
311 unsigned int beep_amp; /* beep amp value, set via set_beep_amp() */
313 const struct hda_verb *init_verbs[10]; /* initialization verbs
317 unsigned int num_init_verbs;
319 char stream_name_analog[32]; /* analog PCM stream */
320 struct hda_pcm_stream *stream_analog_playback;
321 struct hda_pcm_stream *stream_analog_capture;
322 struct hda_pcm_stream *stream_analog_alt_playback;
323 struct hda_pcm_stream *stream_analog_alt_capture;
325 char stream_name_digital[32]; /* digital PCM stream */
326 struct hda_pcm_stream *stream_digital_playback;
327 struct hda_pcm_stream *stream_digital_capture;
330 struct hda_multi_out multiout; /* playback set-up
331 * max_channels, dacs must be set
332 * dig_out_nid and hp_nid are optional
334 hda_nid_t alt_dac_nid;
335 hda_nid_t slave_dig_outs[3]; /* optional - for auto-parsing */
339 unsigned int num_adc_nids;
341 hda_nid_t *capsrc_nids;
342 hda_nid_t dig_in_nid; /* digital-in NID; optional */
344 /* capture setup for dynamic dual-adc switch */
345 unsigned int cur_adc_idx;
347 unsigned int cur_adc_stream_tag;
348 unsigned int cur_adc_format;
351 unsigned int num_mux_defs;
352 const struct hda_input_mux *input_mux;
353 unsigned int cur_mux[3];
354 struct alc_mic_route ext_mic;
355 struct alc_mic_route int_mic;
358 const struct hda_channel_mode *channel_mode;
359 int num_channel_mode;
361 int const_channel_count;
362 int ext_channel_count;
364 /* PCM information */
365 struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */
368 struct snd_array jacks;
370 /* dynamic controls, init_verbs and input_mux */
371 struct auto_pin_cfg autocfg;
372 struct alc_customize_define cdefine;
373 struct snd_array kctls;
374 struct hda_input_mux private_imux[3];
375 hda_nid_t private_dac_nids[AUTO_CFG_MAX_OUTS];
376 hda_nid_t private_adc_nids[AUTO_CFG_MAX_OUTS];
377 hda_nid_t private_capsrc_nids[AUTO_CFG_MAX_OUTS];
380 void (*init_hook)(struct hda_codec *codec);
381 void (*unsol_event)(struct hda_codec *codec, unsigned int res);
382 #ifdef CONFIG_SND_HDA_POWER_SAVE
383 void (*power_hook)(struct hda_codec *codec);
386 /* for pin sensing */
387 unsigned int sense_updated: 1;
388 unsigned int jack_present: 1;
389 unsigned int master_sw: 1;
390 unsigned int auto_mic:1;
393 unsigned int no_analog :1; /* digital I/O only */
394 unsigned int dual_adc_switch:1; /* switch ADCs (for ALC275) */
397 /* for virtual master */
398 hda_nid_t vmaster_nid;
399 #ifdef CONFIG_SND_HDA_POWER_SAVE
400 struct hda_loopback_check loopback;
405 unsigned int pll_coef_idx, pll_coef_bit;
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);
881 static void add_mixer(struct alc_spec *spec, struct snd_kcontrol_new *mix)
883 if (snd_BUG_ON(spec->num_mixers >= ARRAY_SIZE(spec->mixers)))
885 spec->mixers[spec->num_mixers++] = mix;
888 static void add_verb(struct alc_spec *spec, const struct hda_verb *verb)
890 if (snd_BUG_ON(spec->num_init_verbs >= ARRAY_SIZE(spec->init_verbs)))
892 spec->init_verbs[spec->num_init_verbs++] = verb;
896 * set up from the preset table
898 static void setup_preset(struct hda_codec *codec,
899 const struct alc_config_preset *preset)
901 struct alc_spec *spec = codec->spec;
904 for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++)
905 add_mixer(spec, preset->mixers[i]);
906 spec->cap_mixer = preset->cap_mixer;
907 for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i];
909 add_verb(spec, preset->init_verbs[i]);
911 spec->channel_mode = preset->channel_mode;
912 spec->num_channel_mode = preset->num_channel_mode;
913 spec->need_dac_fix = preset->need_dac_fix;
914 spec->const_channel_count = preset->const_channel_count;
916 if (preset->const_channel_count)
917 spec->multiout.max_channels = preset->const_channel_count;
919 spec->multiout.max_channels = spec->channel_mode[0].channels;
920 spec->ext_channel_count = spec->channel_mode[0].channels;
922 spec->multiout.num_dacs = preset->num_dacs;
923 spec->multiout.dac_nids = preset->dac_nids;
924 spec->multiout.dig_out_nid = preset->dig_out_nid;
925 spec->multiout.slave_dig_outs = preset->slave_dig_outs;
926 spec->multiout.hp_nid = preset->hp_nid;
928 spec->num_mux_defs = preset->num_mux_defs;
929 if (!spec->num_mux_defs)
930 spec->num_mux_defs = 1;
931 spec->input_mux = preset->input_mux;
933 spec->num_adc_nids = preset->num_adc_nids;
934 spec->adc_nids = preset->adc_nids;
935 spec->capsrc_nids = preset->capsrc_nids;
936 spec->dig_in_nid = preset->dig_in_nid;
938 spec->unsol_event = preset->unsol_event;
939 spec->init_hook = preset->init_hook;
940 #ifdef CONFIG_SND_HDA_POWER_SAVE
941 spec->power_hook = preset->power_hook;
942 spec->loopback.amplist = preset->loopbacks;
946 preset->setup(codec);
949 /* Enable GPIO mask and set output */
950 static struct hda_verb alc_gpio1_init_verbs[] = {
951 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
952 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
953 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
957 static struct hda_verb alc_gpio2_init_verbs[] = {
958 {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
959 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
960 {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
964 static struct hda_verb alc_gpio3_init_verbs[] = {
965 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
966 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
967 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
972 * Fix hardware PLL issue
973 * On some codecs, the analog PLL gating control must be off while
974 * the default value is 1.
976 static void alc_fix_pll(struct hda_codec *codec)
978 struct alc_spec *spec = codec->spec;
983 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX,
985 val = snd_hda_codec_read(codec, spec->pll_nid, 0,
986 AC_VERB_GET_PROC_COEF, 0);
987 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX,
989 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_PROC_COEF,
990 val & ~(1 << spec->pll_coef_bit));
993 static void alc_fix_pll_init(struct hda_codec *codec, hda_nid_t nid,
994 unsigned int coef_idx, unsigned int coef_bit)
996 struct alc_spec *spec = codec->spec;
998 spec->pll_coef_idx = coef_idx;
999 spec->pll_coef_bit = coef_bit;
1003 #ifdef CONFIG_SND_HDA_INPUT_JACK
1004 static void alc_free_jack_priv(struct snd_jack *jack)
1006 struct alc_jack *jacks = jack->private_data;
1011 static int alc_add_jack(struct hda_codec *codec,
1012 hda_nid_t nid, int type)
1014 struct alc_spec *spec;
1015 struct alc_jack *jack;
1020 snd_array_init(&spec->jacks, sizeof(*jack), 32);
1021 jack = snd_array_new(&spec->jacks);
1027 name = (type == SND_JACK_HEADPHONE) ? "Headphone" : "Mic" ;
1029 err = snd_jack_new(codec->bus->card, name, type, &jack->jack);
1032 jack->jack->private_data = jack;
1033 jack->jack->private_free = alc_free_jack_priv;
1037 static void alc_report_jack(struct hda_codec *codec, hda_nid_t nid)
1039 struct alc_spec *spec = codec->spec;
1040 struct alc_jack *jacks = spec->jacks.list;
1044 for (i = 0; i < spec->jacks.used; i++) {
1045 if (jacks->nid == nid) {
1046 unsigned int present;
1047 present = snd_hda_jack_detect(codec, nid);
1049 present = (present) ? jacks->type : 0;
1051 snd_jack_report(jacks->jack, present);
1058 static int alc_init_jacks(struct hda_codec *codec)
1060 struct alc_spec *spec = codec->spec;
1062 unsigned int hp_nid = spec->autocfg.hp_pins[0];
1063 unsigned int mic_nid = spec->ext_mic.pin;
1065 err = alc_add_jack(codec, hp_nid, SND_JACK_HEADPHONE);
1068 alc_report_jack(codec, hp_nid);
1070 err = alc_add_jack(codec, mic_nid, SND_JACK_MICROPHONE);
1073 alc_report_jack(codec, mic_nid);
1078 static inline void alc_report_jack(struct hda_codec *codec, hda_nid_t nid)
1082 static inline int alc_init_jacks(struct hda_codec *codec)
1088 static void alc_automute_speaker(struct hda_codec *codec, int pinctl)
1090 struct alc_spec *spec = codec->spec;
1095 spec->jack_present = 0;
1096 for (i = 0; i < ARRAY_SIZE(spec->autocfg.hp_pins); i++) {
1097 nid = spec->autocfg.hp_pins[i];
1100 if (snd_hda_jack_detect(codec, nid)) {
1101 spec->jack_present = 1;
1104 alc_report_jack(codec, spec->autocfg.hp_pins[i]);
1107 mute = spec->jack_present ? HDA_AMP_MUTE : 0;
1108 /* Toggle internal speakers muting */
1109 for (i = 0; i < ARRAY_SIZE(spec->autocfg.speaker_pins); i++) {
1110 nid = spec->autocfg.speaker_pins[i];
1114 snd_hda_codec_write(codec, nid, 0,
1115 AC_VERB_SET_PIN_WIDGET_CONTROL,
1116 spec->jack_present ? 0 : PIN_OUT);
1118 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
1119 HDA_AMP_MUTE, mute);
1124 static void alc_automute_pin(struct hda_codec *codec)
1126 alc_automute_speaker(codec, 1);
1129 static int get_connection_index(struct hda_codec *codec, hda_nid_t mux,
1132 hda_nid_t conn[HDA_MAX_NUM_INPUTS];
1135 nums = snd_hda_get_connections(codec, mux, conn, ARRAY_SIZE(conn));
1136 for (i = 0; i < nums; i++)
1142 /* switch the current ADC according to the jack state */
1143 static void alc_dual_mic_adc_auto_switch(struct hda_codec *codec)
1145 struct alc_spec *spec = codec->spec;
1146 unsigned int present;
1149 present = snd_hda_jack_detect(codec, spec->ext_mic.pin);
1151 spec->cur_adc_idx = 1;
1153 spec->cur_adc_idx = 0;
1154 new_adc = spec->adc_nids[spec->cur_adc_idx];
1155 if (spec->cur_adc && spec->cur_adc != new_adc) {
1156 /* stream is running, let's swap the current ADC */
1157 __snd_hda_codec_cleanup_stream(codec, spec->cur_adc, 1);
1158 spec->cur_adc = new_adc;
1159 snd_hda_codec_setup_stream(codec, new_adc,
1160 spec->cur_adc_stream_tag, 0,
1161 spec->cur_adc_format);
1165 static void alc_mic_automute(struct hda_codec *codec)
1167 struct alc_spec *spec = codec->spec;
1168 struct alc_mic_route *dead, *alive;
1169 unsigned int present, type;
1172 if (!spec->auto_mic)
1174 if (!spec->int_mic.pin || !spec->ext_mic.pin)
1176 if (snd_BUG_ON(!spec->adc_nids))
1179 if (spec->dual_adc_switch) {
1180 alc_dual_mic_adc_auto_switch(codec);
1184 cap_nid = spec->capsrc_nids ? spec->capsrc_nids[0] : spec->adc_nids[0];
1186 present = snd_hda_jack_detect(codec, spec->ext_mic.pin);
1188 alive = &spec->ext_mic;
1189 dead = &spec->int_mic;
1191 alive = &spec->int_mic;
1192 dead = &spec->ext_mic;
1195 type = get_wcaps_type(get_wcaps(codec, cap_nid));
1196 if (type == AC_WID_AUD_MIX) {
1197 /* Matrix-mixer style (e.g. ALC882) */
1198 snd_hda_codec_amp_stereo(codec, cap_nid, HDA_INPUT,
1201 snd_hda_codec_amp_stereo(codec, cap_nid, HDA_INPUT,
1203 HDA_AMP_MUTE, HDA_AMP_MUTE);
1205 /* MUX style (e.g. ALC880) */
1206 snd_hda_codec_write_cache(codec, cap_nid, 0,
1207 AC_VERB_SET_CONNECT_SEL,
1210 alc_report_jack(codec, spec->ext_mic.pin);
1212 /* FIXME: analog mixer */
1215 /* unsolicited event for HP jack sensing */
1216 static void alc_sku_unsol_event(struct hda_codec *codec, unsigned int res)
1218 if (codec->vendor_id == 0x10ec0880)
1223 case ALC880_HP_EVENT:
1224 alc_automute_pin(codec);
1226 case ALC880_MIC_EVENT:
1227 alc_mic_automute(codec);
1232 static void alc_inithook(struct hda_codec *codec)
1234 alc_automute_pin(codec);
1235 alc_mic_automute(codec);
1238 /* additional initialization for ALC888 variants */
1239 static void alc888_coef_init(struct hda_codec *codec)
1243 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 0);
1244 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
1245 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
1246 if ((tmp & 0xf0) == 0x20)
1248 snd_hda_codec_read(codec, 0x20, 0,
1249 AC_VERB_SET_PROC_COEF, 0x830);
1252 snd_hda_codec_read(codec, 0x20, 0,
1253 AC_VERB_SET_PROC_COEF, 0x3030);
1256 static void alc889_coef_init(struct hda_codec *codec)
1260 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
1261 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
1262 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
1263 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_PROC_COEF, tmp|0x2010);
1266 /* turn on/off EAPD control (only if available) */
1267 static void set_eapd(struct hda_codec *codec, hda_nid_t nid, int on)
1269 if (get_wcaps_type(get_wcaps(codec, nid)) != AC_WID_PIN)
1271 if (snd_hda_query_pin_caps(codec, nid) & AC_PINCAP_EAPD)
1272 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
1276 static void alc_auto_init_amp(struct hda_codec *codec, int type)
1281 case ALC_INIT_GPIO1:
1282 snd_hda_sequence_write(codec, alc_gpio1_init_verbs);
1284 case ALC_INIT_GPIO2:
1285 snd_hda_sequence_write(codec, alc_gpio2_init_verbs);
1287 case ALC_INIT_GPIO3:
1288 snd_hda_sequence_write(codec, alc_gpio3_init_verbs);
1290 case ALC_INIT_DEFAULT:
1291 switch (codec->vendor_id) {
1293 set_eapd(codec, 0x0f, 1);
1294 set_eapd(codec, 0x10, 1);
1307 set_eapd(codec, 0x14, 1);
1308 set_eapd(codec, 0x15, 1);
1311 switch (codec->vendor_id) {
1313 snd_hda_codec_write(codec, 0x1a, 0,
1314 AC_VERB_SET_COEF_INDEX, 7);
1315 tmp = snd_hda_codec_read(codec, 0x1a, 0,
1316 AC_VERB_GET_PROC_COEF, 0);
1317 snd_hda_codec_write(codec, 0x1a, 0,
1318 AC_VERB_SET_COEF_INDEX, 7);
1319 snd_hda_codec_write(codec, 0x1a, 0,
1320 AC_VERB_SET_PROC_COEF,
1330 alc889_coef_init(codec);
1333 alc888_coef_init(codec);
1335 #if 0 /* XXX: This may cause the silent output on speaker on some machines */
1338 snd_hda_codec_write(codec, 0x20, 0,
1339 AC_VERB_SET_COEF_INDEX, 7);
1340 tmp = snd_hda_codec_read(codec, 0x20, 0,
1341 AC_VERB_GET_PROC_COEF, 0);
1342 snd_hda_codec_write(codec, 0x20, 0,
1343 AC_VERB_SET_COEF_INDEX, 7);
1344 snd_hda_codec_write(codec, 0x20, 0,
1345 AC_VERB_SET_PROC_COEF,
1354 static void alc_init_auto_hp(struct hda_codec *codec)
1356 struct alc_spec *spec = codec->spec;
1357 struct auto_pin_cfg *cfg = &spec->autocfg;
1360 if (!cfg->hp_pins[0]) {
1361 if (cfg->line_out_type != AUTO_PIN_HP_OUT)
1365 if (!cfg->speaker_pins[0]) {
1366 if (cfg->line_out_type != AUTO_PIN_SPEAKER_OUT)
1368 memcpy(cfg->speaker_pins, cfg->line_out_pins,
1369 sizeof(cfg->speaker_pins));
1370 cfg->speaker_outs = cfg->line_outs;
1373 if (!cfg->hp_pins[0]) {
1374 memcpy(cfg->hp_pins, cfg->line_out_pins,
1375 sizeof(cfg->hp_pins));
1376 cfg->hp_outs = cfg->line_outs;
1379 for (i = 0; i < cfg->hp_outs; i++) {
1380 snd_printdd("realtek: Enable HP auto-muting on NID 0x%x\n",
1382 snd_hda_codec_write_cache(codec, cfg->hp_pins[i], 0,
1383 AC_VERB_SET_UNSOLICITED_ENABLE,
1384 AC_USRSP_EN | ALC880_HP_EVENT);
1386 spec->unsol_event = alc_sku_unsol_event;
1389 static void alc_init_auto_mic(struct hda_codec *codec)
1391 struct alc_spec *spec = codec->spec;
1392 struct auto_pin_cfg *cfg = &spec->autocfg;
1393 hda_nid_t fixed, ext;
1396 /* there must be only two mic inputs exclusively */
1397 for (i = 0; i < cfg->num_inputs; i++)
1398 if (cfg->inputs[i].type >= AUTO_PIN_LINE_IN)
1402 for (i = 0; i < cfg->num_inputs; i++) {
1403 hda_nid_t nid = cfg->inputs[i].pin;
1404 unsigned int defcfg;
1405 defcfg = snd_hda_codec_get_pincfg(codec, nid);
1406 switch (snd_hda_get_input_pin_attr(defcfg)) {
1407 case INPUT_PIN_ATTR_INT:
1409 return; /* already occupied */
1412 case INPUT_PIN_ATTR_UNUSED:
1413 return; /* invalid entry */
1416 return; /* already occupied */
1423 if (!(get_wcaps(codec, ext) & AC_WCAP_UNSOL_CAP))
1424 return; /* no unsol support */
1425 snd_printdd("realtek: Enable auto-mic switch on NID 0x%x/0x%x\n",
1427 spec->ext_mic.pin = ext;
1428 spec->int_mic.pin = fixed;
1429 spec->ext_mic.mux_idx = MUX_IDX_UNDEF; /* set later */
1430 spec->int_mic.mux_idx = MUX_IDX_UNDEF; /* set later */
1432 snd_hda_codec_write_cache(codec, spec->ext_mic.pin, 0,
1433 AC_VERB_SET_UNSOLICITED_ENABLE,
1434 AC_USRSP_EN | ALC880_MIC_EVENT);
1435 spec->unsol_event = alc_sku_unsol_event;
1438 static int alc_auto_parse_customize_define(struct hda_codec *codec)
1440 unsigned int ass, tmp, i;
1442 struct alc_spec *spec = codec->spec;
1444 spec->cdefine.enable_pcbeep = 1; /* assume always enabled */
1446 ass = codec->subsystem_id & 0xffff;
1447 if (ass != codec->bus->pci->subsystem_device && (ass & 1))
1451 if (codec->vendor_id == 0x10ec0260)
1453 ass = snd_hda_codec_get_pincfg(codec, nid);
1456 printk(KERN_INFO "hda_codec: %s: SKU not ready 0x%08x\n",
1457 codec->chip_name, ass);
1463 for (i = 1; i < 16; i++) {
1467 if (((ass >> 16) & 0xf) != tmp)
1470 spec->cdefine.port_connectivity = ass >> 30;
1471 spec->cdefine.enable_pcbeep = (ass & 0x100000) >> 20;
1472 spec->cdefine.check_sum = (ass >> 16) & 0xf;
1473 spec->cdefine.customization = ass >> 8;
1475 spec->cdefine.sku_cfg = ass;
1476 spec->cdefine.external_amp = (ass & 0x38) >> 3;
1477 spec->cdefine.platform_type = (ass & 0x4) >> 2;
1478 spec->cdefine.swap = (ass & 0x2) >> 1;
1479 spec->cdefine.override = ass & 0x1;
1481 snd_printd("SKU: Nid=0x%x sku_cfg=0x%08x\n",
1482 nid, spec->cdefine.sku_cfg);
1483 snd_printd("SKU: port_connectivity=0x%x\n",
1484 spec->cdefine.port_connectivity);
1485 snd_printd("SKU: enable_pcbeep=0x%x\n", spec->cdefine.enable_pcbeep);
1486 snd_printd("SKU: check_sum=0x%08x\n", spec->cdefine.check_sum);
1487 snd_printd("SKU: customization=0x%08x\n", spec->cdefine.customization);
1488 snd_printd("SKU: external_amp=0x%x\n", spec->cdefine.external_amp);
1489 snd_printd("SKU: platform_type=0x%x\n", spec->cdefine.platform_type);
1490 snd_printd("SKU: swap=0x%x\n", spec->cdefine.swap);
1491 snd_printd("SKU: override=0x%x\n", spec->cdefine.override);
1496 /* check subsystem ID and set up device-specific initialization;
1497 * return 1 if initialized, 0 if invalid SSID
1499 /* 32-bit subsystem ID for BIOS loading in HD Audio codec.
1500 * 31 ~ 16 : Manufacture ID
1502 * 7 ~ 0 : Assembly ID
1503 * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36
1505 static int alc_subsystem_id(struct hda_codec *codec,
1506 hda_nid_t porta, hda_nid_t porte,
1507 hda_nid_t portd, hda_nid_t porti)
1509 unsigned int ass, tmp, i;
1511 struct alc_spec *spec = codec->spec;
1513 ass = codec->subsystem_id & 0xffff;
1514 if ((ass != codec->bus->pci->subsystem_device) && (ass & 1))
1517 /* invalid SSID, check the special NID pin defcfg instead */
1519 * 31~30 : port connectivity
1522 * 19~16 : Check sum (15:1)
1527 if (codec->vendor_id == 0x10ec0260)
1529 ass = snd_hda_codec_get_pincfg(codec, nid);
1530 snd_printd("realtek: No valid SSID, "
1531 "checking pincfg 0x%08x for NID 0x%x\n",
1535 if ((ass >> 30) != 1) /* no physical connection */
1540 for (i = 1; i < 16; i++) {
1544 if (((ass >> 16) & 0xf) != tmp)
1547 snd_printd("realtek: Enabling init ASM_ID=0x%04x CODEC_ID=%08x\n",
1548 ass & 0xffff, codec->vendor_id);
1552 * 2 : 0 --> Desktop, 1 --> Laptop
1553 * 3~5 : External Amplifier control
1556 tmp = (ass & 0x38) >> 3; /* external Amp control */
1559 spec->init_amp = ALC_INIT_GPIO1;
1562 spec->init_amp = ALC_INIT_GPIO2;
1565 spec->init_amp = ALC_INIT_GPIO3;
1568 spec->init_amp = ALC_INIT_DEFAULT;
1572 /* is laptop or Desktop and enable the function "Mute internal speaker
1573 * when the external headphone out jack is plugged"
1575 if (!(ass & 0x8000))
1578 * 10~8 : Jack location
1579 * 12~11: Headphone out -> 00: PortA, 01: PortE, 02: PortD, 03: Resvered
1581 * 15 : 1 --> enable the function "Mute internal speaker
1582 * when the external headphone out jack is plugged"
1584 if (!spec->autocfg.hp_pins[0]) {
1586 tmp = (ass >> 11) & 0x3; /* HP to chassis */
1597 for (i = 0; i < spec->autocfg.line_outs; i++)
1598 if (spec->autocfg.line_out_pins[i] == nid)
1600 spec->autocfg.hp_pins[0] = nid;
1603 alc_init_auto_hp(codec);
1604 alc_init_auto_mic(codec);
1608 static void alc_ssid_check(struct hda_codec *codec,
1609 hda_nid_t porta, hda_nid_t porte,
1610 hda_nid_t portd, hda_nid_t porti)
1612 if (!alc_subsystem_id(codec, porta, porte, portd, porti)) {
1613 struct alc_spec *spec = codec->spec;
1614 snd_printd("realtek: "
1615 "Enable default setup for auto mode as fallback\n");
1616 spec->init_amp = ALC_INIT_DEFAULT;
1617 alc_init_auto_hp(codec);
1618 alc_init_auto_mic(codec);
1623 * Fix-up pin default configurations and add default verbs
1632 const struct alc_pincfg *pins;
1633 const struct hda_verb *verbs;
1636 static void alc_pick_fixup(struct hda_codec *codec,
1637 const struct snd_pci_quirk *quirk,
1638 const struct alc_fixup *fix,
1641 const struct alc_pincfg *cfg;
1643 quirk = snd_pci_quirk_lookup(codec->bus->pci, quirk);
1646 fix += quirk->value;
1648 if (pre_init && cfg) {
1649 #ifdef CONFIG_SND_DEBUG_VERBOSE
1650 snd_printdd(KERN_INFO "hda_codec: %s: Apply pincfg for %s\n",
1651 codec->chip_name, quirk->name);
1653 for (; cfg->nid; cfg++)
1654 snd_hda_codec_set_pincfg(codec, cfg->nid, cfg->val);
1656 if (!pre_init && fix->verbs) {
1657 #ifdef CONFIG_SND_DEBUG_VERBOSE
1658 snd_printdd(KERN_INFO "hda_codec: %s: Apply fix-verbs for %s\n",
1659 codec->chip_name, quirk->name);
1661 add_verb(codec->spec, fix->verbs);
1665 static int alc_read_coef_idx(struct hda_codec *codec,
1666 unsigned int coef_idx)
1669 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX,
1671 val = snd_hda_codec_read(codec, 0x20, 0,
1672 AC_VERB_GET_PROC_COEF, 0);
1676 static void alc_write_coef_idx(struct hda_codec *codec, unsigned int coef_idx,
1677 unsigned int coef_val)
1679 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX,
1681 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_PROC_COEF,
1685 /* set right pin controls for digital I/O */
1686 static void alc_auto_init_digital(struct hda_codec *codec)
1688 struct alc_spec *spec = codec->spec;
1692 for (i = 0; i < spec->autocfg.dig_outs; i++) {
1693 pin = spec->autocfg.dig_out_pins[i];
1695 snd_hda_codec_write(codec, pin, 0,
1696 AC_VERB_SET_PIN_WIDGET_CONTROL,
1700 pin = spec->autocfg.dig_in_pin;
1702 snd_hda_codec_write(codec, pin, 0,
1703 AC_VERB_SET_PIN_WIDGET_CONTROL,
1707 /* parse digital I/Os and set up NIDs in BIOS auto-parse mode */
1708 static void alc_auto_parse_digital(struct hda_codec *codec)
1710 struct alc_spec *spec = codec->spec;
1714 /* support multiple SPDIFs; the secondary is set up as a slave */
1715 for (i = 0; i < spec->autocfg.dig_outs; i++) {
1716 err = snd_hda_get_connections(codec,
1717 spec->autocfg.dig_out_pins[i],
1722 spec->multiout.dig_out_nid = dig_nid;
1723 spec->dig_out_type = spec->autocfg.dig_out_type[0];
1725 spec->multiout.slave_dig_outs = spec->slave_dig_outs;
1726 if (i >= ARRAY_SIZE(spec->slave_dig_outs) - 1)
1728 spec->slave_dig_outs[i - 1] = dig_nid;
1732 if (spec->autocfg.dig_in_pin) {
1734 err = snd_hda_get_connections(codec,
1735 spec->autocfg.dig_in_pin,
1738 spec->dig_in_nid = dig_nid;
1749 static struct hda_verb alc888_4ST_ch2_intel_init[] = {
1750 /* Mic-in jack as mic in */
1751 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1752 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1753 /* Line-in jack as Line in */
1754 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1755 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1756 /* Line-Out as Front */
1757 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
1764 static struct hda_verb alc888_4ST_ch4_intel_init[] = {
1765 /* Mic-in jack as mic in */
1766 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1767 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1768 /* Line-in jack as Surround */
1769 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1770 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1771 /* Line-Out as Front */
1772 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
1779 static struct hda_verb alc888_4ST_ch6_intel_init[] = {
1780 /* Mic-in jack as CLFE */
1781 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1782 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1783 /* Line-in jack as Surround */
1784 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1785 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1786 /* Line-Out as CLFE (workaround because Mic-in is not loud enough) */
1787 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1794 static struct hda_verb alc888_4ST_ch8_intel_init[] = {
1795 /* Mic-in jack as CLFE */
1796 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1797 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1798 /* Line-in jack as Surround */
1799 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1800 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1801 /* Line-Out as Side */
1802 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1806 static struct hda_channel_mode alc888_4ST_8ch_intel_modes[4] = {
1807 { 2, alc888_4ST_ch2_intel_init },
1808 { 4, alc888_4ST_ch4_intel_init },
1809 { 6, alc888_4ST_ch6_intel_init },
1810 { 8, alc888_4ST_ch8_intel_init },
1814 * ALC888 Fujitsu Siemens Amillo xa3530
1817 static struct hda_verb alc888_fujitsu_xa3530_verbs[] = {
1818 /* Front Mic: set to PIN_IN (empty by default) */
1819 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1820 /* Connect Internal HP to Front */
1821 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1822 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1823 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1824 /* Connect Bass HP to Front */
1825 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1826 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1827 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1828 /* Connect Line-Out side jack (SPDIF) to Side */
1829 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1830 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1831 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1832 /* Connect Mic jack to CLFE */
1833 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1834 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1835 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02},
1836 /* Connect Line-in jack to Surround */
1837 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1838 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1839 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
1840 /* Connect HP out jack to Front */
1841 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1842 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1843 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
1844 /* Enable unsolicited event for HP jack and Line-out jack */
1845 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1846 {0x17, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1850 static void alc_automute_amp(struct hda_codec *codec)
1852 alc_automute_speaker(codec, 0);
1855 static void alc_automute_amp_unsol_event(struct hda_codec *codec,
1858 if (codec->vendor_id == 0x10ec0880)
1862 if (res == ALC880_HP_EVENT)
1863 alc_automute_amp(codec);
1866 static void alc889_automute_setup(struct hda_codec *codec)
1868 struct alc_spec *spec = codec->spec;
1870 spec->autocfg.hp_pins[0] = 0x15;
1871 spec->autocfg.speaker_pins[0] = 0x14;
1872 spec->autocfg.speaker_pins[1] = 0x16;
1873 spec->autocfg.speaker_pins[2] = 0x17;
1874 spec->autocfg.speaker_pins[3] = 0x19;
1875 spec->autocfg.speaker_pins[4] = 0x1a;
1878 static void alc889_intel_init_hook(struct hda_codec *codec)
1880 alc889_coef_init(codec);
1881 alc_automute_amp(codec);
1884 static void alc888_fujitsu_xa3530_setup(struct hda_codec *codec)
1886 struct alc_spec *spec = codec->spec;
1888 spec->autocfg.hp_pins[0] = 0x17; /* line-out */
1889 spec->autocfg.hp_pins[1] = 0x1b; /* hp */
1890 spec->autocfg.speaker_pins[0] = 0x14; /* speaker */
1891 spec->autocfg.speaker_pins[1] = 0x15; /* bass */
1895 * ALC888 Acer Aspire 4930G model
1898 static struct hda_verb alc888_acer_aspire_4930g_verbs[] = {
1899 /* Front Mic: set to PIN_IN (empty by default) */
1900 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1901 /* Unselect Front Mic by default in input mixer 3 */
1902 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
1903 /* Enable unsolicited event for HP jack */
1904 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1905 /* Connect Internal HP to front */
1906 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1907 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1908 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1909 /* Connect HP out to front */
1910 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1911 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1912 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1917 * ALC888 Acer Aspire 6530G model
1920 static struct hda_verb alc888_acer_aspire_6530g_verbs[] = {
1921 /* Route to built-in subwoofer as well as speakers */
1922 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1923 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1924 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1925 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1926 /* Bias voltage on for external mic port */
1927 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN | PIN_VREF80},
1928 /* Front Mic: set to PIN_IN (empty by default) */
1929 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1930 /* Unselect Front Mic by default in input mixer 3 */
1931 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
1932 /* Enable unsolicited event for HP jack */
1933 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1934 /* Enable speaker output */
1935 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1936 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1937 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
1938 /* Enable headphone output */
1939 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | PIN_HP},
1940 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1941 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1942 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
1947 * ALC889 Acer Aspire 8930G model
1950 static struct hda_verb alc889_acer_aspire_8930g_verbs[] = {
1951 /* Front Mic: set to PIN_IN (empty by default) */
1952 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1953 /* Unselect Front Mic by default in input mixer 3 */
1954 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
1955 /* Enable unsolicited event for HP jack */
1956 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1957 /* Connect Internal Front to Front */
1958 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1959 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1960 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1961 /* Connect Internal Rear to Rear */
1962 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1963 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1964 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01},
1965 /* Connect Internal CLFE to CLFE */
1966 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1967 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1968 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
1969 /* Connect HP out to Front */
1970 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | PIN_HP},
1971 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1972 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1973 /* Enable all DACs */
1974 /* DAC DISABLE/MUTE 1? */
1975 /* setting bits 1-5 disables DAC nids 0x02-0x06 apparently. Init=0x38 */
1976 {0x20, AC_VERB_SET_COEF_INDEX, 0x03},
1977 {0x20, AC_VERB_SET_PROC_COEF, 0x0000},
1978 /* DAC DISABLE/MUTE 2? */
1979 /* some bit here disables the other DACs. Init=0x4900 */
1980 {0x20, AC_VERB_SET_COEF_INDEX, 0x08},
1981 {0x20, AC_VERB_SET_PROC_COEF, 0x0000},
1983 * This laptop has a stereo digital microphone. The mics are only 1cm apart
1984 * which makes the stereo useless. However, either the mic or the ALC889
1985 * makes the signal become a difference/sum signal instead of standard
1986 * stereo, which is annoying. So instead we flip this bit which makes the
1987 * codec replicate the sum signal to both channels, turning it into a
1990 /* DMIC_CONTROL? Init value = 0x0001 */
1991 {0x20, AC_VERB_SET_COEF_INDEX, 0x0b},
1992 {0x20, AC_VERB_SET_PROC_COEF, 0x0003},
1996 static struct hda_input_mux alc888_2_capture_sources[2] = {
1997 /* Front mic only available on one ADC */
2004 { "Front Mic", 0xb },
2017 static struct hda_input_mux alc888_acer_aspire_6530_sources[2] = {
2018 /* Interal mic only available on one ADC */
2025 { "Input Mix", 0xa },
2035 { "Input Mix", 0xa },
2040 static struct hda_input_mux alc889_capture_sources[3] = {
2041 /* Digital mic only available on first "ADC" */
2048 { "Front Mic", 0xb },
2049 { "Input Mix", 0xa },
2058 { "Input Mix", 0xa },
2067 { "Input Mix", 0xa },
2072 static struct snd_kcontrol_new alc888_base_mixer[] = {
2073 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2074 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2075 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2076 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
2077 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
2079 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2080 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2081 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2082 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
2083 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
2084 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2085 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2086 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2087 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2088 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2089 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
2090 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2094 static struct snd_kcontrol_new alc889_acer_aspire_8930g_mixer[] = {
2095 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2096 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2097 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2098 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
2099 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
2101 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2102 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2103 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2104 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2105 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2106 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2107 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
2108 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2113 static void alc888_acer_aspire_4930g_setup(struct hda_codec *codec)
2115 struct alc_spec *spec = codec->spec;
2117 spec->autocfg.hp_pins[0] = 0x15;
2118 spec->autocfg.speaker_pins[0] = 0x14;
2119 spec->autocfg.speaker_pins[1] = 0x16;
2120 spec->autocfg.speaker_pins[2] = 0x17;
2123 static void alc888_acer_aspire_6530g_setup(struct hda_codec *codec)
2125 struct alc_spec *spec = codec->spec;
2127 spec->autocfg.hp_pins[0] = 0x15;
2128 spec->autocfg.speaker_pins[0] = 0x14;
2129 spec->autocfg.speaker_pins[1] = 0x16;
2130 spec->autocfg.speaker_pins[2] = 0x17;
2133 static void alc889_acer_aspire_8930g_setup(struct hda_codec *codec)
2135 struct alc_spec *spec = codec->spec;
2137 spec->autocfg.hp_pins[0] = 0x15;
2138 spec->autocfg.speaker_pins[0] = 0x14;
2139 spec->autocfg.speaker_pins[1] = 0x16;
2140 spec->autocfg.speaker_pins[2] = 0x1b;
2144 * ALC880 3-stack model
2146 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
2147 * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18,
2148 * F-Mic = 0x1b, HP = 0x19
2151 static hda_nid_t alc880_dac_nids[4] = {
2152 /* front, rear, clfe, rear_surr */
2153 0x02, 0x05, 0x04, 0x03
2156 static hda_nid_t alc880_adc_nids[3] = {
2161 /* The datasheet says the node 0x07 is connected from inputs,
2162 * but it shows zero connection in the real implementation on some devices.
2163 * Note: this is a 915GAV bug, fixed on 915GLV
2165 static hda_nid_t alc880_adc_nids_alt[2] = {
2170 #define ALC880_DIGOUT_NID 0x06
2171 #define ALC880_DIGIN_NID 0x0a
2173 static struct hda_input_mux alc880_capture_source = {
2177 { "Front Mic", 0x3 },
2183 /* channel source setting (2/6 channel selection for 3-stack) */
2185 static struct hda_verb alc880_threestack_ch2_init[] = {
2186 /* set line-in to input, mute it */
2187 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
2188 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
2189 /* set mic-in to input vref 80%, mute it */
2190 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
2191 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
2196 static struct hda_verb alc880_threestack_ch6_init[] = {
2197 /* set line-in to output, unmute it */
2198 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
2199 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
2200 /* set mic-in to output, unmute it */
2201 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
2202 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
2206 static struct hda_channel_mode alc880_threestack_modes[2] = {
2207 { 2, alc880_threestack_ch2_init },
2208 { 6, alc880_threestack_ch6_init },
2211 static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
2212 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2213 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2214 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
2215 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
2216 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2217 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2218 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2219 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2220 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2221 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2222 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2223 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2224 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2225 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2226 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
2227 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
2228 HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
2230 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2231 .name = "Channel Mode",
2232 .info = alc_ch_mode_info,
2233 .get = alc_ch_mode_get,
2234 .put = alc_ch_mode_put,
2239 /* capture mixer elements */
2240 static int alc_cap_vol_info(struct snd_kcontrol *kcontrol,
2241 struct snd_ctl_elem_info *uinfo)
2243 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2244 struct alc_spec *spec = codec->spec;
2247 mutex_lock(&codec->control_mutex);
2248 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0,
2250 err = snd_hda_mixer_amp_volume_info(kcontrol, uinfo);
2251 mutex_unlock(&codec->control_mutex);
2255 static int alc_cap_vol_tlv(struct snd_kcontrol *kcontrol, int op_flag,
2256 unsigned int size, unsigned int __user *tlv)
2258 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2259 struct alc_spec *spec = codec->spec;
2262 mutex_lock(&codec->control_mutex);
2263 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0,
2265 err = snd_hda_mixer_amp_tlv(kcontrol, op_flag, size, tlv);
2266 mutex_unlock(&codec->control_mutex);
2270 typedef int (*getput_call_t)(struct snd_kcontrol *kcontrol,
2271 struct snd_ctl_elem_value *ucontrol);
2273 static int alc_cap_getput_caller(struct snd_kcontrol *kcontrol,
2274 struct snd_ctl_elem_value *ucontrol,
2277 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2278 struct alc_spec *spec = codec->spec;
2279 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
2282 mutex_lock(&codec->control_mutex);
2283 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[adc_idx],
2285 err = func(kcontrol, ucontrol);
2286 mutex_unlock(&codec->control_mutex);
2290 static int alc_cap_vol_get(struct snd_kcontrol *kcontrol,
2291 struct snd_ctl_elem_value *ucontrol)
2293 return alc_cap_getput_caller(kcontrol, ucontrol,
2294 snd_hda_mixer_amp_volume_get);
2297 static int alc_cap_vol_put(struct snd_kcontrol *kcontrol,
2298 struct snd_ctl_elem_value *ucontrol)
2300 return alc_cap_getput_caller(kcontrol, ucontrol,
2301 snd_hda_mixer_amp_volume_put);
2304 /* capture mixer elements */
2305 #define alc_cap_sw_info snd_ctl_boolean_stereo_info
2307 static int alc_cap_sw_get(struct snd_kcontrol *kcontrol,
2308 struct snd_ctl_elem_value *ucontrol)
2310 return alc_cap_getput_caller(kcontrol, ucontrol,
2311 snd_hda_mixer_amp_switch_get);
2314 static int alc_cap_sw_put(struct snd_kcontrol *kcontrol,
2315 struct snd_ctl_elem_value *ucontrol)
2317 return alc_cap_getput_caller(kcontrol, ucontrol,
2318 snd_hda_mixer_amp_switch_put);
2321 #define _DEFINE_CAPMIX(num) \
2323 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2324 .name = "Capture Switch", \
2325 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, \
2327 .info = alc_cap_sw_info, \
2328 .get = alc_cap_sw_get, \
2329 .put = alc_cap_sw_put, \
2332 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2333 .name = "Capture Volume", \
2334 .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE | \
2335 SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
2336 SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK), \
2338 .info = alc_cap_vol_info, \
2339 .get = alc_cap_vol_get, \
2340 .put = alc_cap_vol_put, \
2341 .tlv = { .c = alc_cap_vol_tlv }, \
2344 #define _DEFINE_CAPSRC(num) \
2346 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2347 /* .name = "Capture Source", */ \
2348 .name = "Input Source", \
2350 .info = alc_mux_enum_info, \
2351 .get = alc_mux_enum_get, \
2352 .put = alc_mux_enum_put, \
2355 #define DEFINE_CAPMIX(num) \
2356 static struct snd_kcontrol_new alc_capture_mixer ## num[] = { \
2357 _DEFINE_CAPMIX(num), \
2358 _DEFINE_CAPSRC(num), \
2362 #define DEFINE_CAPMIX_NOSRC(num) \
2363 static struct snd_kcontrol_new alc_capture_mixer_nosrc ## num[] = { \
2364 _DEFINE_CAPMIX(num), \
2368 /* up to three ADCs */
2372 DEFINE_CAPMIX_NOSRC(1);
2373 DEFINE_CAPMIX_NOSRC(2);
2374 DEFINE_CAPMIX_NOSRC(3);
2377 * ALC880 5-stack model
2379 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d),
2381 * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
2382 * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
2385 /* additional mixers to alc880_three_stack_mixer */
2386 static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
2387 HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2388 HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
2392 /* channel source setting (6/8 channel selection for 5-stack) */
2394 static struct hda_verb alc880_fivestack_ch6_init[] = {
2395 /* set line-in to input, mute it */
2396 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
2397 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
2402 static struct hda_verb alc880_fivestack_ch8_init[] = {
2403 /* set line-in to output, unmute it */
2404 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
2405 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
2409 static struct hda_channel_mode alc880_fivestack_modes[2] = {
2410 { 6, alc880_fivestack_ch6_init },
2411 { 8, alc880_fivestack_ch8_init },
2416 * ALC880 6-stack model
2418 * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e),
2419 * Side = 0x05 (0x0f)
2420 * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
2421 * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
2424 static hda_nid_t alc880_6st_dac_nids[4] = {
2425 /* front, rear, clfe, rear_surr */
2426 0x02, 0x03, 0x04, 0x05
2429 static struct hda_input_mux alc880_6stack_capture_source = {
2433 { "Front Mic", 0x1 },
2439 /* fixed 8-channels */
2440 static struct hda_channel_mode alc880_sixstack_modes[1] = {
2444 static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
2445 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2446 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2447 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2448 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
2449 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2450 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2451 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2452 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2453 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
2454 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
2455 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2456 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2457 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2458 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2459 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2460 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2461 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2462 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
2464 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2465 .name = "Channel Mode",
2466 .info = alc_ch_mode_info,
2467 .get = alc_ch_mode_get,
2468 .put = alc_ch_mode_put,
2477 * W810 has rear IO for:
2480 * Center/LFE (DAC 04)
2483 * The system also has a pair of internal speakers, and a headphone jack.
2484 * These are both connected to Line2 on the codec, hence to DAC 02.
2486 * There is a variable resistor to control the speaker or headphone
2487 * volume. This is a hardware-only device without a software API.
2489 * Plugging headphones in will disable the internal speakers. This is
2490 * implemented in hardware, not via the driver using jack sense. In
2491 * a similar fashion, plugging into the rear socket marked "front" will
2492 * disable both the speakers and headphones.
2494 * For input, there's a microphone jack, and an "audio in" jack.
2495 * These may not do anything useful with this driver yet, because I
2496 * haven't setup any initialization verbs for these yet...
2499 static hda_nid_t alc880_w810_dac_nids[3] = {
2500 /* front, rear/surround, clfe */
2504 /* fixed 6 channels */
2505 static struct hda_channel_mode alc880_w810_modes[1] = {
2509 /* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
2510 static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
2511 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2512 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2513 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2514 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
2515 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2516 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2517 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2518 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2519 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
2527 * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
2528 * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?),
2532 static hda_nid_t alc880_z71v_dac_nids[1] = {
2535 #define ALC880_Z71V_HP_DAC 0x03
2537 /* fixed 2 channels */
2538 static struct hda_channel_mode alc880_2_jack_modes[1] = {
2542 static struct snd_kcontrol_new alc880_z71v_mixer[] = {
2543 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2544 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2545 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2546 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
2547 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2548 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2549 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2550 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2556 * ALC880 F1734 model
2558 * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
2559 * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
2562 static hda_nid_t alc880_f1734_dac_nids[1] = {
2565 #define ALC880_F1734_HP_DAC 0x02
2567 static struct snd_kcontrol_new alc880_f1734_mixer[] = {
2568 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2569 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2570 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2571 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
2572 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2573 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2574 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2575 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
2579 static struct hda_input_mux alc880_f1734_capture_source = {
2591 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
2592 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
2593 * Mic = 0x18, Line = 0x1a
2596 #define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
2597 #define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
2599 static struct snd_kcontrol_new alc880_asus_mixer[] = {
2600 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2601 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2602 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2603 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
2604 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2605 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2606 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2607 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2608 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2609 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2610 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2611 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2612 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2613 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2615 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2616 .name = "Channel Mode",
2617 .info = alc_ch_mode_info,
2618 .get = alc_ch_mode_get,
2619 .put = alc_ch_mode_put,
2625 * ALC880 ASUS W1V model
2627 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
2628 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
2629 * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
2632 /* additional mixers to alc880_asus_mixer */
2633 static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
2634 HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
2635 HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
2640 static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
2641 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2642 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
2643 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
2644 HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
2645 HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
2646 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
2647 HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
2648 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
2649 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
2654 static struct snd_kcontrol_new alc880_uniwill_mixer[] = {
2655 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2656 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2657 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2658 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
2659 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2660 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2661 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2662 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2663 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2664 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2665 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2666 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2667 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2668 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2669 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2670 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
2672 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2673 .name = "Channel Mode",
2674 .info = alc_ch_mode_info,
2675 .get = alc_ch_mode_get,
2676 .put = alc_ch_mode_put,
2681 static struct snd_kcontrol_new alc880_fujitsu_mixer[] = {
2682 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2683 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2684 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2685 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
2686 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2687 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2688 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2689 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2690 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2691 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
2695 static struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = {
2696 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2697 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2698 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2699 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
2700 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2701 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2706 * virtual master controls
2710 * slave controls for virtual master
2712 static const char *alc_slave_vols[] = {
2713 "Front Playback Volume",
2714 "Surround Playback Volume",
2715 "Center Playback Volume",
2716 "LFE Playback Volume",
2717 "Side Playback Volume",
2718 "Headphone Playback Volume",
2719 "Speaker Playback Volume",
2720 "Mono Playback Volume",
2721 "Line-Out Playback Volume",
2722 "PCM Playback Volume",
2726 static const char *alc_slave_sws[] = {
2727 "Front Playback Switch",
2728 "Surround Playback Switch",
2729 "Center Playback Switch",
2730 "LFE Playback Switch",
2731 "Side Playback Switch",
2732 "Headphone Playback Switch",
2733 "Speaker Playback Switch",
2734 "Mono Playback Switch",
2735 "IEC958 Playback Switch",
2736 "Line-Out Playback Switch",
2737 "PCM Playback Switch",
2742 * build control elements
2745 #define NID_MAPPING (-1)
2747 #define SUBDEV_SPEAKER_ (0 << 6)
2748 #define SUBDEV_HP_ (1 << 6)
2749 #define SUBDEV_LINE_ (2 << 6)
2750 #define SUBDEV_SPEAKER(x) (SUBDEV_SPEAKER_ | ((x) & 0x3f))
2751 #define SUBDEV_HP(x) (SUBDEV_HP_ | ((x) & 0x3f))
2752 #define SUBDEV_LINE(x) (SUBDEV_LINE_ | ((x) & 0x3f))
2754 static void alc_free_kctls(struct hda_codec *codec);
2756 #ifdef CONFIG_SND_HDA_INPUT_BEEP
2757 /* additional beep mixers; the actual parameters are overwritten at build */
2758 static struct snd_kcontrol_new alc_beep_mixer[] = {
2759 HDA_CODEC_VOLUME("Beep Playback Volume", 0, 0, HDA_INPUT),
2760 HDA_CODEC_MUTE_BEEP("Beep Playback Switch", 0, 0, HDA_INPUT),
2765 static int alc_build_controls(struct hda_codec *codec)
2767 struct alc_spec *spec = codec->spec;
2768 struct snd_kcontrol *kctl = NULL;
2769 struct snd_kcontrol_new *knew;
2774 for (i = 0; i < spec->num_mixers; i++) {
2775 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
2779 if (spec->cap_mixer) {
2780 err = snd_hda_add_new_ctls(codec, spec->cap_mixer);
2784 if (spec->multiout.dig_out_nid) {
2785 err = snd_hda_create_spdif_out_ctls(codec,
2786 spec->multiout.dig_out_nid);
2789 if (!spec->no_analog) {
2790 err = snd_hda_create_spdif_share_sw(codec,
2794 spec->multiout.share_spdif = 1;
2797 if (spec->dig_in_nid) {
2798 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
2803 #ifdef CONFIG_SND_HDA_INPUT_BEEP
2804 /* create beep controls if needed */
2805 if (spec->beep_amp) {
2806 struct snd_kcontrol_new *knew;
2807 for (knew = alc_beep_mixer; knew->name; knew++) {
2808 struct snd_kcontrol *kctl;
2809 kctl = snd_ctl_new1(knew, codec);
2812 kctl->private_value = spec->beep_amp;
2813 err = snd_hda_ctl_add(codec, 0, kctl);
2820 /* if we have no master control, let's create it */
2821 if (!spec->no_analog &&
2822 !snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
2823 unsigned int vmaster_tlv[4];
2824 snd_hda_set_vmaster_tlv(codec, spec->vmaster_nid,
2825 HDA_OUTPUT, vmaster_tlv);
2826 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
2827 vmaster_tlv, alc_slave_vols);
2831 if (!spec->no_analog &&
2832 !snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
2833 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
2834 NULL, alc_slave_sws);
2839 /* assign Capture Source enums to NID */
2840 if (spec->capsrc_nids || spec->adc_nids) {
2841 kctl = snd_hda_find_mixer_ctl(codec, "Capture Source");
2843 kctl = snd_hda_find_mixer_ctl(codec, "Input Source");
2844 for (i = 0; kctl && i < kctl->count; i++) {
2845 hda_nid_t *nids = spec->capsrc_nids;
2847 nids = spec->adc_nids;
2848 err = snd_hda_add_nid(codec, kctl, i, nids[i]);
2853 if (spec->cap_mixer) {
2854 const char *kname = kctl ? kctl->id.name : NULL;
2855 for (knew = spec->cap_mixer; knew->name; knew++) {
2856 if (kname && strcmp(knew->name, kname) == 0)
2858 kctl = snd_hda_find_mixer_ctl(codec, knew->name);
2859 for (i = 0; kctl && i < kctl->count; i++) {
2860 err = snd_hda_add_nid(codec, kctl, i,
2868 /* other nid->control mapping */
2869 for (i = 0; i < spec->num_mixers; i++) {
2870 for (knew = spec->mixers[i]; knew->name; knew++) {
2871 if (knew->iface != NID_MAPPING)
2873 kctl = snd_hda_find_mixer_ctl(codec, knew->name);
2876 u = knew->subdevice;
2877 for (j = 0; j < 4; j++, u >>= 8) {
2882 case SUBDEV_SPEAKER_:
2883 nid = spec->autocfg.speaker_pins[nid];
2886 nid = spec->autocfg.line_out_pins[nid];
2889 nid = spec->autocfg.hp_pins[nid];
2894 err = snd_hda_add_nid(codec, kctl, 0, nid);
2898 u = knew->private_value;
2899 for (j = 0; j < 4; j++, u >>= 8) {
2903 err = snd_hda_add_nid(codec, kctl, 0, nid);
2910 alc_free_kctls(codec); /* no longer needed */
2917 * initialize the codec volumes, etc
2921 * generic initialization of ADC, input mixers and output mixers
2923 static struct hda_verb alc880_volume_init_verbs[] = {
2925 * Unmute ADC0-2 and set the default input to mic-in
2927 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
2928 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2929 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
2930 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2931 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
2932 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2934 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
2936 * Note: PASD motherboards uses the Line In 2 as the input for front
2939 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
2940 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2941 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2942 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
2943 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
2944 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
2945 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
2946 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
2949 * Set up output mixers (0x0c - 0x0f)
2951 /* set vol=0 to output mixers */
2952 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2953 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2954 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2955 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2956 /* set up input amps for analog loopback */
2957 /* Amp Indices: DAC = 0, mixer = 1 */
2958 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2959 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2960 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2961 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2962 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2963 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2964 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2965 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2971 * 3-stack pin configuration:
2972 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
2974 static struct hda_verb alc880_pin_3stack_init_verbs[] = {
2976 * preset connection lists of input pins
2977 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
2979 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
2980 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2981 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
2984 * Set pin mode and muting
2986 /* set front pin widgets 0x14 for output */
2987 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2988 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2989 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2990 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2991 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2992 /* Mic2 (as headphone out) for HP output */
2993 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2994 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2995 /* Line In pin widget for input */
2996 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2997 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2998 /* Line2 (as front mic) pin widget for input and vref at 80% */
2999 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3000 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3001 /* CD pin widget for input */
3002 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3008 * 5-stack pin configuration:
3009 * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
3010 * line-in/side = 0x1a, f-mic = 0x1b
3012 static struct hda_verb alc880_pin_5stack_init_verbs[] = {
3014 * preset connection lists of input pins
3015 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
3017 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3018 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
3021 * Set pin mode and muting
3023 /* set pin widgets 0x14-0x17 for output */
3024 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3025 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3026 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3027 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3028 /* unmute pins for output (no gain on this amp) */
3029 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3030 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3031 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3032 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3034 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3035 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3036 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3037 /* Mic2 (as headphone out) for HP output */
3038 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3039 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3040 /* Line In pin widget for input */
3041 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3042 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3043 /* Line2 (as front mic) pin widget for input and vref at 80% */
3044 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3045 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3046 /* CD pin widget for input */
3047 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3053 * W810 pin configuration:
3054 * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
3056 static struct hda_verb alc880_pin_w810_init_verbs[] = {
3057 /* hphone/speaker input selector: front DAC */
3058 {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
3060 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3061 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3062 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3063 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3064 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3065 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3067 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3068 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3074 * Z71V pin configuration:
3075 * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
3077 static struct hda_verb alc880_pin_z71v_init_verbs[] = {
3078 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3079 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3080 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3081 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3083 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3084 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3085 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3086 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3092 * 6-stack pin configuration:
3093 * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18,
3094 * f-mic = 0x19, line = 0x1a, HP = 0x1b
3096 static struct hda_verb alc880_pin_6stack_init_verbs[] = {
3097 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3099 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3100 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3101 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3102 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3103 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3104 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3105 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3106 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3108 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3109 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3110 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3111 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3112 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3113 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3114 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3115 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3116 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3122 * Uniwill pin configuration:
3123 * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19,
3126 static struct hda_verb alc880_uniwill_init_verbs[] = {
3127 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3129 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3130 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3131 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3132 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3133 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3134 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3135 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3136 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3137 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3138 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3139 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3140 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3141 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3142 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3144 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3145 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3146 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3147 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3148 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3149 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3150 /* {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, */
3151 /* {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
3152 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3154 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
3155 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
3162 * HP = 0x14, InternalSpeaker = 0x15, mic = 0x19,
3164 static struct hda_verb alc880_uniwill_p53_init_verbs[] = {
3165 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3167 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3168 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3169 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3170 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3171 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3172 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3173 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3174 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3175 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3176 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3177 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3178 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3180 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3181 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3182 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3183 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3184 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3185 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3187 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
3188 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_DCVOL_EVENT},
3193 static struct hda_verb alc880_beep_init_verbs[] = {
3194 { 0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5) },
3198 /* auto-toggle front mic */
3199 static void alc880_uniwill_mic_automute(struct hda_codec *codec)
3201 unsigned int present;
3204 present = snd_hda_jack_detect(codec, 0x18);
3205 bits = present ? HDA_AMP_MUTE : 0;
3206 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
3209 static void alc880_uniwill_setup(struct hda_codec *codec)
3211 struct alc_spec *spec = codec->spec;
3213 spec->autocfg.hp_pins[0] = 0x14;
3214 spec->autocfg.speaker_pins[0] = 0x15;
3215 spec->autocfg.speaker_pins[0] = 0x16;
3218 static void alc880_uniwill_init_hook(struct hda_codec *codec)
3220 alc_automute_amp(codec);
3221 alc880_uniwill_mic_automute(codec);
3224 static void alc880_uniwill_unsol_event(struct hda_codec *codec,
3227 /* Looks like the unsol event is incompatible with the standard
3228 * definition. 4bit tag is placed at 28 bit!
3230 switch (res >> 28) {
3231 case ALC880_MIC_EVENT:
3232 alc880_uniwill_mic_automute(codec);
3235 alc_automute_amp_unsol_event(codec, res);
3240 static void alc880_uniwill_p53_setup(struct hda_codec *codec)
3242 struct alc_spec *spec = codec->spec;
3244 spec->autocfg.hp_pins[0] = 0x14;
3245 spec->autocfg.speaker_pins[0] = 0x15;
3248 static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec)
3250 unsigned int present;
3252 present = snd_hda_codec_read(codec, 0x21, 0,
3253 AC_VERB_GET_VOLUME_KNOB_CONTROL, 0);
3254 present &= HDA_AMP_VOLMASK;
3255 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0,
3256 HDA_AMP_VOLMASK, present);
3257 snd_hda_codec_amp_stereo(codec, 0x0d, HDA_OUTPUT, 0,
3258 HDA_AMP_VOLMASK, present);
3261 static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec,
3264 /* Looks like the unsol event is incompatible with the standard
3265 * definition. 4bit tag is placed at 28 bit!
3267 if ((res >> 28) == ALC880_DCVOL_EVENT)
3268 alc880_uniwill_p53_dcvol_automute(codec);
3270 alc_automute_amp_unsol_event(codec, res);
3274 * F1734 pin configuration:
3275 * HP = 0x14, speaker-out = 0x15, mic = 0x18
3277 static struct hda_verb alc880_pin_f1734_init_verbs[] = {
3278 {0x07, AC_VERB_SET_CONNECT_SEL, 0x01},
3279 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
3280 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
3281 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
3282 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
3284 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3285 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3286 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3287 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3289 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3290 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3291 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
3292 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3293 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3294 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3295 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3296 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3297 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3299 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
3300 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_DCVOL_EVENT},
3306 * ASUS pin configuration:
3307 * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
3309 static struct hda_verb alc880_pin_asus_init_verbs[] = {
3310 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
3311 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
3312 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
3313 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
3315 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3316 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3317 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3318 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3319 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3320 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3321 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3322 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3324 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3325 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3326 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3327 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3328 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3329 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3330 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3331 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3332 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3337 /* Enable GPIO mask and set output */
3338 #define alc880_gpio1_init_verbs alc_gpio1_init_verbs
3339 #define alc880_gpio2_init_verbs alc_gpio2_init_verbs
3340 #define alc880_gpio3_init_verbs alc_gpio3_init_verbs
3342 /* Clevo m520g init */
3343 static struct hda_verb alc880_pin_clevo_init_verbs[] = {
3344 /* headphone output */
3345 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
3347 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3348 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3350 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3351 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3353 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3354 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3355 /* Mic1 (rear panel) */
3356 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3357 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3358 /* Mic2 (front panel) */
3359 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3360 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3362 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3363 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3364 /* change to EAPD mode */
3365 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
3366 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
3371 static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
3372 /* change to EAPD mode */
3373 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
3374 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
3376 /* Headphone output */
3377 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3379 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3380 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
3382 /* Line In pin widget for input */
3383 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3384 /* CD pin widget for input */
3385 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3386 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3387 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3389 /* change to EAPD mode */
3390 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
3391 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
3397 * LG m1 express dual
3400 * Rear Line-In/Out (blue): 0x14
3401 * Build-in Mic-In: 0x15
3403 * HP-Out (green): 0x1b
3404 * Mic-In/Out (red): 0x19
3408 /* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
3409 static hda_nid_t alc880_lg_dac_nids[3] = {
3413 /* seems analog CD is not working */
3414 static struct hda_input_mux alc880_lg_capture_source = {
3419 { "Internal Mic", 0x6 },
3423 /* 2,4,6 channel modes */
3424 static struct hda_verb alc880_lg_ch2_init[] = {
3425 /* set line-in and mic-in to input */
3426 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
3427 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
3431 static struct hda_verb alc880_lg_ch4_init[] = {
3432 /* set line-in to out and mic-in to input */
3433 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
3434 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
3438 static struct hda_verb alc880_lg_ch6_init[] = {
3439 /* set line-in and mic-in to output */
3440 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
3441 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
3445 static struct hda_channel_mode alc880_lg_ch_modes[3] = {
3446 { 2, alc880_lg_ch2_init },
3447 { 4, alc880_lg_ch4_init },
3448 { 6, alc880_lg_ch6_init },
3451 static struct snd_kcontrol_new alc880_lg_mixer[] = {
3452 HDA_CODEC_VOLUME("Front Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
3453 HDA_BIND_MUTE("Front Playback Switch", 0x0f, 2, HDA_INPUT),
3454 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3455 HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
3456 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
3457 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
3458 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
3459 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
3460 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
3461 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
3462 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
3463 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
3464 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
3465 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
3467 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3468 .name = "Channel Mode",
3469 .info = alc_ch_mode_info,
3470 .get = alc_ch_mode_get,
3471 .put = alc_ch_mode_put,
3476 static struct hda_verb alc880_lg_init_verbs[] = {
3477 /* set capture source to mic-in */
3478 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3479 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3480 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3481 /* mute all amp mixer inputs */
3482 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
3483 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
3484 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
3485 /* line-in to input */
3486 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3487 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3489 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3490 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3492 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3493 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3494 /* mic-in to input */
3495 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
3496 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3497 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3499 {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
3500 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3501 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3503 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
3507 /* toggle speaker-output according to the hp-jack state */
3508 static void alc880_lg_setup(struct hda_codec *codec)
3510 struct alc_spec *spec = codec->spec;
3512 spec->autocfg.hp_pins[0] = 0x1b;
3513 spec->autocfg.speaker_pins[0] = 0x17;
3522 * Built-in Mic-In: 0x19
3528 static struct hda_input_mux alc880_lg_lw_capture_source = {
3532 { "Internal Mic", 0x1 },
3537 #define alc880_lg_lw_modes alc880_threestack_modes
3539 static struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
3540 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3541 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
3542 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
3543 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
3544 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
3545 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
3546 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
3547 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
3548 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
3549 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
3550 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
3551 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
3552 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
3553 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
3555 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3556 .name = "Channel Mode",
3557 .info = alc_ch_mode_info,
3558 .get = alc_ch_mode_get,
3559 .put = alc_ch_mode_put,
3564 static struct hda_verb alc880_lg_lw_init_verbs[] = {
3565 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3566 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
3567 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
3569 /* set capture source to mic-in */
3570 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3571 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3572 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3573 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
3575 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3576 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3578 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3579 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3580 /* mic-in to input */
3581 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3582 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3584 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3585 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3587 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
3591 /* toggle speaker-output according to the hp-jack state */
3592 static void alc880_lg_lw_setup(struct hda_codec *codec)
3594 struct alc_spec *spec = codec->spec;
3596 spec->autocfg.hp_pins[0] = 0x1b;
3597 spec->autocfg.speaker_pins[0] = 0x14;
3600 static struct snd_kcontrol_new alc880_medion_rim_mixer[] = {
3601 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3602 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
3603 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
3604 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
3605 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
3606 HDA_CODEC_MUTE("Internal Playback Switch", 0x0b, 0x1, HDA_INPUT),
3610 static struct hda_input_mux alc880_medion_rim_capture_source = {
3614 { "Internal Mic", 0x1 },
3618 static struct hda_verb alc880_medion_rim_init_verbs[] = {
3619 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3621 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3622 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3624 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3625 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3626 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3627 /* Mic2 (as headphone out) for HP output */
3628 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3629 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3630 /* Internal Speaker */
3631 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3632 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3634 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
3635 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
3637 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
3641 /* toggle speaker-output according to the hp-jack state */
3642 static void alc880_medion_rim_automute(struct hda_codec *codec)
3644 struct alc_spec *spec = codec->spec;
3645 alc_automute_amp(codec);
3647 if (spec->jack_present)
3648 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 0);
3650 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 2);
3653 static void alc880_medion_rim_unsol_event(struct hda_codec *codec,
3656 /* Looks like the unsol event is incompatible with the standard
3657 * definition. 4bit tag is placed at 28 bit!
3659 if ((res >> 28) == ALC880_HP_EVENT)
3660 alc880_medion_rim_automute(codec);
3663 static void alc880_medion_rim_setup(struct hda_codec *codec)
3665 struct alc_spec *spec = codec->spec;
3667 spec->autocfg.hp_pins[0] = 0x14;
3668 spec->autocfg.speaker_pins[0] = 0x1b;
3671 #ifdef CONFIG_SND_HDA_POWER_SAVE
3672 static struct hda_amp_list alc880_loopbacks[] = {
3673 { 0x0b, HDA_INPUT, 0 },
3674 { 0x0b, HDA_INPUT, 1 },
3675 { 0x0b, HDA_INPUT, 2 },
3676 { 0x0b, HDA_INPUT, 3 },
3677 { 0x0b, HDA_INPUT, 4 },
3681 static struct hda_amp_list alc880_lg_loopbacks[] = {
3682 { 0x0b, HDA_INPUT, 1 },
3683 { 0x0b, HDA_INPUT, 6 },
3684 { 0x0b, HDA_INPUT, 7 },
3693 static int alc_init(struct hda_codec *codec)
3695 struct alc_spec *spec = codec->spec;
3699 alc_auto_init_amp(codec, spec->init_amp);
3701 for (i = 0; i < spec->num_init_verbs; i++)
3702 snd_hda_sequence_write(codec, spec->init_verbs[i]);
3704 if (spec->init_hook)
3705 spec->init_hook(codec);
3707 #ifdef CONFIG_SND_HDA_POWER_SAVE
3708 if (codec->patch_ops.check_power_status)
3709 codec->patch_ops.check_power_status(codec, 0x01);
3714 static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
3716 struct alc_spec *spec = codec->spec;
3718 if (spec->unsol_event)
3719 spec->unsol_event(codec, res);
3722 #ifdef CONFIG_SND_HDA_POWER_SAVE
3723 static int alc_check_power_status(struct hda_codec *codec, hda_nid_t nid)
3725 struct alc_spec *spec = codec->spec;
3726 return snd_hda_check_amp_list_power(codec, &spec->loopback, nid);
3731 * Analog playback callbacks
3733 static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
3734 struct hda_codec *codec,
3735 struct snd_pcm_substream *substream)
3737 struct alc_spec *spec = codec->spec;
3738 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
3742 static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
3743 struct hda_codec *codec,
3744 unsigned int stream_tag,
3745 unsigned int format,
3746 struct snd_pcm_substream *substream)
3748 struct alc_spec *spec = codec->spec;
3749 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
3750 stream_tag, format, substream);
3753 static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
3754 struct hda_codec *codec,
3755 struct snd_pcm_substream *substream)
3757 struct alc_spec *spec = codec->spec;
3758 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
3764 static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
3765 struct hda_codec *codec,
3766 struct snd_pcm_substream *substream)
3768 struct alc_spec *spec = codec->spec;
3769 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
3772 static int alc880_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
3773 struct hda_codec *codec,
3774 unsigned int stream_tag,
3775 unsigned int format,
3776 struct snd_pcm_substream *substream)
3778 struct alc_spec *spec = codec->spec;
3779 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
3780 stream_tag, format, substream);
3783 static int alc880_dig_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
3784 struct hda_codec *codec,
3785 struct snd_pcm_substream *substream)
3787 struct alc_spec *spec = codec->spec;
3788 return snd_hda_multi_out_dig_cleanup(codec, &spec->multiout);
3791 static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
3792 struct hda_codec *codec,
3793 struct snd_pcm_substream *substream)
3795 struct alc_spec *spec = codec->spec;
3796 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
3802 static int alc880_alt_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
3803 struct hda_codec *codec,
3804 unsigned int stream_tag,
3805 unsigned int format,
3806 struct snd_pcm_substream *substream)
3808 struct alc_spec *spec = codec->spec;
3810 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number + 1],
3811 stream_tag, 0, format);
3815 static int alc880_alt_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
3816 struct hda_codec *codec,
3817 struct snd_pcm_substream *substream)
3819 struct alc_spec *spec = codec->spec;