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) */
396 int codec_variant; /* flag for other variants */
398 /* for virtual master */
399 hda_nid_t vmaster_nid;
400 #ifdef CONFIG_SND_HDA_POWER_SAVE
401 struct hda_loopback_check loopback;
406 unsigned int pll_coef_idx, pll_coef_bit;
410 * configuration template - to be copied to the spec instance
412 struct alc_config_preset {
413 struct snd_kcontrol_new *mixers[5]; /* should be identical size
416 struct snd_kcontrol_new *cap_mixer; /* capture mixer */
417 const struct hda_verb *init_verbs[5];
418 unsigned int num_dacs;
420 hda_nid_t dig_out_nid; /* optional */
421 hda_nid_t hp_nid; /* optional */
422 hda_nid_t *slave_dig_outs;
423 unsigned int num_adc_nids;
425 hda_nid_t *capsrc_nids;
426 hda_nid_t dig_in_nid;
427 unsigned int num_channel_mode;
428 const struct hda_channel_mode *channel_mode;
430 int const_channel_count;
431 unsigned int num_mux_defs;
432 const struct hda_input_mux *input_mux;
433 void (*unsol_event)(struct hda_codec *, unsigned int);
434 void (*setup)(struct hda_codec *);
435 void (*init_hook)(struct hda_codec *);
436 #ifdef CONFIG_SND_HDA_POWER_SAVE
437 struct hda_amp_list *loopbacks;
438 void (*power_hook)(struct hda_codec *codec);
446 static int alc_mux_enum_info(struct snd_kcontrol *kcontrol,
447 struct snd_ctl_elem_info *uinfo)
449 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
450 struct alc_spec *spec = codec->spec;
451 unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id);
452 if (mux_idx >= spec->num_mux_defs)
454 if (!spec->input_mux[mux_idx].num_items && mux_idx > 0)
456 return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo);
459 static int alc_mux_enum_get(struct snd_kcontrol *kcontrol,
460 struct snd_ctl_elem_value *ucontrol)
462 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
463 struct alc_spec *spec = codec->spec;
464 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
466 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
470 static int alc_mux_enum_put(struct snd_kcontrol *kcontrol,
471 struct snd_ctl_elem_value *ucontrol)
473 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
474 struct alc_spec *spec = codec->spec;
475 const struct hda_input_mux *imux;
476 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
477 unsigned int mux_idx;
478 hda_nid_t nid = spec->capsrc_nids ?
479 spec->capsrc_nids[adc_idx] : spec->adc_nids[adc_idx];
482 mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx;
483 imux = &spec->input_mux[mux_idx];
484 if (!imux->num_items && mux_idx > 0)
485 imux = &spec->input_mux[0];
487 type = get_wcaps_type(get_wcaps(codec, nid));
488 if (type == AC_WID_AUD_MIX) {
489 /* Matrix-mixer style (e.g. ALC882) */
490 unsigned int *cur_val = &spec->cur_mux[adc_idx];
493 idx = ucontrol->value.enumerated.item[0];
494 if (idx >= imux->num_items)
495 idx = imux->num_items - 1;
498 for (i = 0; i < imux->num_items; i++) {
499 unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
500 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
501 imux->items[i].index,
507 /* MUX style (e.g. ALC880) */
508 return snd_hda_input_mux_put(codec, imux, ucontrol, nid,
509 &spec->cur_mux[adc_idx]);
514 * channel mode setting
516 static int alc_ch_mode_info(struct snd_kcontrol *kcontrol,
517 struct snd_ctl_elem_info *uinfo)
519 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
520 struct alc_spec *spec = codec->spec;
521 return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
522 spec->num_channel_mode);
525 static int alc_ch_mode_get(struct snd_kcontrol *kcontrol,
526 struct snd_ctl_elem_value *ucontrol)
528 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
529 struct alc_spec *spec = codec->spec;
530 return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
531 spec->num_channel_mode,
532 spec->ext_channel_count);
535 static int alc_ch_mode_put(struct snd_kcontrol *kcontrol,
536 struct snd_ctl_elem_value *ucontrol)
538 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
539 struct alc_spec *spec = codec->spec;
540 int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
541 spec->num_channel_mode,
542 &spec->ext_channel_count);
543 if (err >= 0 && !spec->const_channel_count) {
544 spec->multiout.max_channels = spec->ext_channel_count;
545 if (spec->need_dac_fix)
546 spec->multiout.num_dacs = spec->multiout.max_channels / 2;
552 * Control the mode of pin widget settings via the mixer. "pc" is used
553 * instead of "%" to avoid consequences of accidently treating the % as
554 * being part of a format specifier. Maximum allowed length of a value is
555 * 63 characters plus NULL terminator.
557 * Note: some retasking pin complexes seem to ignore requests for input
558 * states other than HiZ (eg: PIN_VREFxx) and revert to HiZ if any of these
559 * are requested. Therefore order this list so that this behaviour will not
560 * cause problems when mixer clients move through the enum sequentially.
561 * NIDs 0x0f and 0x10 have been observed to have this behaviour as of
564 static char *alc_pin_mode_names[] = {
565 "Mic 50pc bias", "Mic 80pc bias",
566 "Line in", "Line out", "Headphone out",
568 static unsigned char alc_pin_mode_values[] = {
569 PIN_VREF50, PIN_VREF80, PIN_IN, PIN_OUT, PIN_HP,
571 /* The control can present all 5 options, or it can limit the options based
572 * in the pin being assumed to be exclusively an input or an output pin. In
573 * addition, "input" pins may or may not process the mic bias option
574 * depending on actual widget capability (NIDs 0x0f and 0x10 don't seem to
575 * accept requests for bias as of chip versions up to March 2006) and/or
576 * wiring in the computer.
578 #define ALC_PIN_DIR_IN 0x00
579 #define ALC_PIN_DIR_OUT 0x01
580 #define ALC_PIN_DIR_INOUT 0x02
581 #define ALC_PIN_DIR_IN_NOMICBIAS 0x03
582 #define ALC_PIN_DIR_INOUT_NOMICBIAS 0x04
584 /* Info about the pin modes supported by the different pin direction modes.
585 * For each direction the minimum and maximum values are given.
587 static signed char alc_pin_mode_dir_info[5][2] = {
588 { 0, 2 }, /* ALC_PIN_DIR_IN */
589 { 3, 4 }, /* ALC_PIN_DIR_OUT */
590 { 0, 4 }, /* ALC_PIN_DIR_INOUT */
591 { 2, 2 }, /* ALC_PIN_DIR_IN_NOMICBIAS */
592 { 2, 4 }, /* ALC_PIN_DIR_INOUT_NOMICBIAS */
594 #define alc_pin_mode_min(_dir) (alc_pin_mode_dir_info[_dir][0])
595 #define alc_pin_mode_max(_dir) (alc_pin_mode_dir_info[_dir][1])
596 #define alc_pin_mode_n_items(_dir) \
597 (alc_pin_mode_max(_dir)-alc_pin_mode_min(_dir)+1)
599 static int alc_pin_mode_info(struct snd_kcontrol *kcontrol,
600 struct snd_ctl_elem_info *uinfo)
602 unsigned int item_num = uinfo->value.enumerated.item;
603 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
605 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
607 uinfo->value.enumerated.items = alc_pin_mode_n_items(dir);
609 if (item_num<alc_pin_mode_min(dir) || item_num>alc_pin_mode_max(dir))
610 item_num = alc_pin_mode_min(dir);
611 strcpy(uinfo->value.enumerated.name, alc_pin_mode_names[item_num]);
615 static int alc_pin_mode_get(struct snd_kcontrol *kcontrol,
616 struct snd_ctl_elem_value *ucontrol)
619 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
620 hda_nid_t nid = kcontrol->private_value & 0xffff;
621 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
622 long *valp = ucontrol->value.integer.value;
623 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
624 AC_VERB_GET_PIN_WIDGET_CONTROL,
627 /* Find enumerated value for current pinctl setting */
628 i = alc_pin_mode_min(dir);
629 while (i <= alc_pin_mode_max(dir) && alc_pin_mode_values[i] != pinctl)
631 *valp = i <= alc_pin_mode_max(dir) ? i: alc_pin_mode_min(dir);
635 static int alc_pin_mode_put(struct snd_kcontrol *kcontrol,
636 struct snd_ctl_elem_value *ucontrol)
639 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
640 hda_nid_t nid = kcontrol->private_value & 0xffff;
641 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
642 long val = *ucontrol->value.integer.value;
643 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
644 AC_VERB_GET_PIN_WIDGET_CONTROL,
647 if (val < alc_pin_mode_min(dir) || val > alc_pin_mode_max(dir))
648 val = alc_pin_mode_min(dir);
650 change = pinctl != alc_pin_mode_values[val];
652 /* Set pin mode to that requested */
653 snd_hda_codec_write_cache(codec, nid, 0,
654 AC_VERB_SET_PIN_WIDGET_CONTROL,
655 alc_pin_mode_values[val]);
657 /* Also enable the retasking pin's input/output as required
658 * for the requested pin mode. Enum values of 2 or less are
661 * Dynamically switching the input/output buffers probably
662 * reduces noise slightly (particularly on input) so we'll
663 * do it. However, having both input and output buffers
664 * enabled simultaneously doesn't seem to be problematic if
665 * this turns out to be necessary in the future.
668 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
669 HDA_AMP_MUTE, HDA_AMP_MUTE);
670 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
673 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
674 HDA_AMP_MUTE, HDA_AMP_MUTE);
675 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
682 #define ALC_PIN_MODE(xname, nid, dir) \
683 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
684 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
685 .info = alc_pin_mode_info, \
686 .get = alc_pin_mode_get, \
687 .put = alc_pin_mode_put, \
688 .private_value = nid | (dir<<16) }
690 /* A switch control for ALC260 GPIO pins. Multiple GPIOs can be ganged
691 * together using a mask with more than one bit set. This control is
692 * currently used only by the ALC260 test model. At this stage they are not
693 * needed for any "production" models.
695 #ifdef CONFIG_SND_DEBUG
696 #define alc_gpio_data_info snd_ctl_boolean_mono_info
698 static int alc_gpio_data_get(struct snd_kcontrol *kcontrol,
699 struct snd_ctl_elem_value *ucontrol)
701 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
702 hda_nid_t nid = kcontrol->private_value & 0xffff;
703 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
704 long *valp = ucontrol->value.integer.value;
705 unsigned int val = snd_hda_codec_read(codec, nid, 0,
706 AC_VERB_GET_GPIO_DATA, 0x00);
708 *valp = (val & mask) != 0;
711 static int alc_gpio_data_put(struct snd_kcontrol *kcontrol,
712 struct snd_ctl_elem_value *ucontrol)
715 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
716 hda_nid_t nid = kcontrol->private_value & 0xffff;
717 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
718 long val = *ucontrol->value.integer.value;
719 unsigned int gpio_data = snd_hda_codec_read(codec, nid, 0,
720 AC_VERB_GET_GPIO_DATA,
723 /* Set/unset the masked GPIO bit(s) as needed */
724 change = (val == 0 ? 0 : mask) != (gpio_data & mask);
729 snd_hda_codec_write_cache(codec, nid, 0,
730 AC_VERB_SET_GPIO_DATA, gpio_data);
734 #define ALC_GPIO_DATA_SWITCH(xname, nid, mask) \
735 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
736 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
737 .info = alc_gpio_data_info, \
738 .get = alc_gpio_data_get, \
739 .put = alc_gpio_data_put, \
740 .private_value = nid | (mask<<16) }
741 #endif /* CONFIG_SND_DEBUG */
743 /* A switch control to allow the enabling of the digital IO pins on the
744 * ALC260. This is incredibly simplistic; the intention of this control is
745 * to provide something in the test model allowing digital outputs to be
746 * identified if present. If models are found which can utilise these
747 * outputs a more complete mixer control can be devised for those models if
750 #ifdef CONFIG_SND_DEBUG
751 #define alc_spdif_ctrl_info snd_ctl_boolean_mono_info
753 static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol,
754 struct snd_ctl_elem_value *ucontrol)
756 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
757 hda_nid_t nid = kcontrol->private_value & 0xffff;
758 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
759 long *valp = ucontrol->value.integer.value;
760 unsigned int val = snd_hda_codec_read(codec, nid, 0,
761 AC_VERB_GET_DIGI_CONVERT_1, 0x00);
763 *valp = (val & mask) != 0;
766 static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol,
767 struct snd_ctl_elem_value *ucontrol)
770 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
771 hda_nid_t nid = kcontrol->private_value & 0xffff;
772 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
773 long val = *ucontrol->value.integer.value;
774 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
775 AC_VERB_GET_DIGI_CONVERT_1,
778 /* Set/unset the masked control bit(s) as needed */
779 change = (val == 0 ? 0 : mask) != (ctrl_data & mask);
784 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1,
789 #define ALC_SPDIF_CTRL_SWITCH(xname, nid, mask) \
790 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
791 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
792 .info = alc_spdif_ctrl_info, \
793 .get = alc_spdif_ctrl_get, \
794 .put = alc_spdif_ctrl_put, \
795 .private_value = nid | (mask<<16) }
796 #endif /* CONFIG_SND_DEBUG */
798 /* A switch control to allow the enabling EAPD digital outputs on the ALC26x.
799 * Again, this is only used in the ALC26x test models to help identify when
800 * the EAPD line must be asserted for features to work.
802 #ifdef CONFIG_SND_DEBUG
803 #define alc_eapd_ctrl_info snd_ctl_boolean_mono_info
805 static int alc_eapd_ctrl_get(struct snd_kcontrol *kcontrol,
806 struct snd_ctl_elem_value *ucontrol)
808 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
809 hda_nid_t nid = kcontrol->private_value & 0xffff;
810 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
811 long *valp = ucontrol->value.integer.value;
812 unsigned int val = snd_hda_codec_read(codec, nid, 0,
813 AC_VERB_GET_EAPD_BTLENABLE, 0x00);
815 *valp = (val & mask) != 0;
819 static int alc_eapd_ctrl_put(struct snd_kcontrol *kcontrol,
820 struct snd_ctl_elem_value *ucontrol)
823 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
824 hda_nid_t nid = kcontrol->private_value & 0xffff;
825 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
826 long val = *ucontrol->value.integer.value;
827 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
828 AC_VERB_GET_EAPD_BTLENABLE,
831 /* Set/unset the masked control bit(s) as needed */
832 change = (!val ? 0 : mask) != (ctrl_data & mask);
837 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
843 #define ALC_EAPD_CTRL_SWITCH(xname, nid, mask) \
844 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
845 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
846 .info = alc_eapd_ctrl_info, \
847 .get = alc_eapd_ctrl_get, \
848 .put = alc_eapd_ctrl_put, \
849 .private_value = nid | (mask<<16) }
850 #endif /* CONFIG_SND_DEBUG */
853 * set up the input pin config (depending on the given auto-pin type)
855 static void alc_set_input_pin(struct hda_codec *codec, hda_nid_t nid,
858 unsigned int val = PIN_IN;
860 if (auto_pin_type == AUTO_PIN_MIC) {
863 oldval = snd_hda_codec_read(codec, nid, 0,
864 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
865 pincap = snd_hda_query_pin_caps(codec, nid);
866 pincap = (pincap & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT;
867 /* if the default pin setup is vref50, we give it priority */
868 if ((pincap & AC_PINCAP_VREF_80) && oldval != PIN_VREF50)
870 else if (pincap & AC_PINCAP_VREF_50)
872 else if (pincap & AC_PINCAP_VREF_100)
874 else if (pincap & AC_PINCAP_VREF_GRD)
877 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, val);
880 static void alc_fixup_autocfg_pin_nums(struct hda_codec *codec)
882 struct alc_spec *spec = codec->spec;
883 struct auto_pin_cfg *cfg = &spec->autocfg;
885 if (!cfg->line_outs) {
886 while (cfg->line_outs < AUTO_CFG_MAX_OUTS &&
887 cfg->line_out_pins[cfg->line_outs])
890 if (!cfg->speaker_outs) {
891 while (cfg->speaker_outs < AUTO_CFG_MAX_OUTS &&
892 cfg->speaker_pins[cfg->speaker_outs])
896 while (cfg->hp_outs < AUTO_CFG_MAX_OUTS &&
897 cfg->hp_pins[cfg->hp_outs])
904 static void add_mixer(struct alc_spec *spec, struct snd_kcontrol_new *mix)
906 if (snd_BUG_ON(spec->num_mixers >= ARRAY_SIZE(spec->mixers)))
908 spec->mixers[spec->num_mixers++] = mix;
911 static void add_verb(struct alc_spec *spec, const struct hda_verb *verb)
913 if (snd_BUG_ON(spec->num_init_verbs >= ARRAY_SIZE(spec->init_verbs)))
915 spec->init_verbs[spec->num_init_verbs++] = verb;
919 * set up from the preset table
921 static void setup_preset(struct hda_codec *codec,
922 const struct alc_config_preset *preset)
924 struct alc_spec *spec = codec->spec;
927 for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++)
928 add_mixer(spec, preset->mixers[i]);
929 spec->cap_mixer = preset->cap_mixer;
930 for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i];
932 add_verb(spec, preset->init_verbs[i]);
934 spec->channel_mode = preset->channel_mode;
935 spec->num_channel_mode = preset->num_channel_mode;
936 spec->need_dac_fix = preset->need_dac_fix;
937 spec->const_channel_count = preset->const_channel_count;
939 if (preset->const_channel_count)
940 spec->multiout.max_channels = preset->const_channel_count;
942 spec->multiout.max_channels = spec->channel_mode[0].channels;
943 spec->ext_channel_count = spec->channel_mode[0].channels;
945 spec->multiout.num_dacs = preset->num_dacs;
946 spec->multiout.dac_nids = preset->dac_nids;
947 spec->multiout.dig_out_nid = preset->dig_out_nid;
948 spec->multiout.slave_dig_outs = preset->slave_dig_outs;
949 spec->multiout.hp_nid = preset->hp_nid;
951 spec->num_mux_defs = preset->num_mux_defs;
952 if (!spec->num_mux_defs)
953 spec->num_mux_defs = 1;
954 spec->input_mux = preset->input_mux;
956 spec->num_adc_nids = preset->num_adc_nids;
957 spec->adc_nids = preset->adc_nids;
958 spec->capsrc_nids = preset->capsrc_nids;
959 spec->dig_in_nid = preset->dig_in_nid;
961 spec->unsol_event = preset->unsol_event;
962 spec->init_hook = preset->init_hook;
963 #ifdef CONFIG_SND_HDA_POWER_SAVE
964 spec->power_hook = preset->power_hook;
965 spec->loopback.amplist = preset->loopbacks;
969 preset->setup(codec);
971 alc_fixup_autocfg_pin_nums(codec);
974 /* Enable GPIO mask and set output */
975 static struct hda_verb alc_gpio1_init_verbs[] = {
976 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
977 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
978 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
982 static struct hda_verb alc_gpio2_init_verbs[] = {
983 {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
984 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
985 {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
989 static struct hda_verb alc_gpio3_init_verbs[] = {
990 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
991 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
992 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
997 * Fix hardware PLL issue
998 * On some codecs, the analog PLL gating control must be off while
999 * the default value is 1.
1001 static void alc_fix_pll(struct hda_codec *codec)
1003 struct alc_spec *spec = codec->spec;
1008 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX,
1009 spec->pll_coef_idx);
1010 val = snd_hda_codec_read(codec, spec->pll_nid, 0,
1011 AC_VERB_GET_PROC_COEF, 0);
1012 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX,
1013 spec->pll_coef_idx);
1014 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_PROC_COEF,
1015 val & ~(1 << spec->pll_coef_bit));
1018 static void alc_fix_pll_init(struct hda_codec *codec, hda_nid_t nid,
1019 unsigned int coef_idx, unsigned int coef_bit)
1021 struct alc_spec *spec = codec->spec;
1022 spec->pll_nid = nid;
1023 spec->pll_coef_idx = coef_idx;
1024 spec->pll_coef_bit = coef_bit;
1028 #ifdef CONFIG_SND_HDA_INPUT_JACK
1029 static void alc_free_jack_priv(struct snd_jack *jack)
1031 struct alc_jack *jacks = jack->private_data;
1036 static int alc_add_jack(struct hda_codec *codec,
1037 hda_nid_t nid, int type)
1039 struct alc_spec *spec;
1040 struct alc_jack *jack;
1045 snd_array_init(&spec->jacks, sizeof(*jack), 32);
1046 jack = snd_array_new(&spec->jacks);
1052 name = (type == SND_JACK_HEADPHONE) ? "Headphone" : "Mic" ;
1054 err = snd_jack_new(codec->bus->card, name, type, &jack->jack);
1057 jack->jack->private_data = jack;
1058 jack->jack->private_free = alc_free_jack_priv;
1062 static void alc_report_jack(struct hda_codec *codec, hda_nid_t nid)
1064 struct alc_spec *spec = codec->spec;
1065 struct alc_jack *jacks = spec->jacks.list;
1069 for (i = 0; i < spec->jacks.used; i++) {
1070 if (jacks->nid == nid) {
1071 unsigned int present;
1072 present = snd_hda_jack_detect(codec, nid);
1074 present = (present) ? jacks->type : 0;
1076 snd_jack_report(jacks->jack, present);
1083 static int alc_init_jacks(struct hda_codec *codec)
1085 struct alc_spec *spec = codec->spec;
1087 unsigned int hp_nid = spec->autocfg.hp_pins[0];
1088 unsigned int mic_nid = spec->ext_mic.pin;
1090 err = alc_add_jack(codec, hp_nid, SND_JACK_HEADPHONE);
1093 alc_report_jack(codec, hp_nid);
1095 err = alc_add_jack(codec, mic_nid, SND_JACK_MICROPHONE);
1098 alc_report_jack(codec, mic_nid);
1103 static inline void alc_report_jack(struct hda_codec *codec, hda_nid_t nid)
1107 static inline int alc_init_jacks(struct hda_codec *codec)
1113 static void alc_automute_speaker(struct hda_codec *codec, int pinctl)
1115 struct alc_spec *spec = codec->spec;
1120 spec->jack_present = 0;
1121 for (i = 0; i < ARRAY_SIZE(spec->autocfg.hp_pins); i++) {
1122 nid = spec->autocfg.hp_pins[i];
1125 if (snd_hda_jack_detect(codec, nid)) {
1126 spec->jack_present = 1;
1129 alc_report_jack(codec, spec->autocfg.hp_pins[i]);
1132 mute = spec->jack_present ? HDA_AMP_MUTE : 0;
1133 /* Toggle internal speakers muting */
1134 for (i = 0; i < ARRAY_SIZE(spec->autocfg.speaker_pins); i++) {
1135 nid = spec->autocfg.speaker_pins[i];
1139 snd_hda_codec_write(codec, nid, 0,
1140 AC_VERB_SET_PIN_WIDGET_CONTROL,
1141 spec->jack_present ? 0 : PIN_OUT);
1143 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
1144 HDA_AMP_MUTE, mute);
1149 static void alc_automute_pin(struct hda_codec *codec)
1151 alc_automute_speaker(codec, 1);
1154 static int get_connection_index(struct hda_codec *codec, hda_nid_t mux,
1157 hda_nid_t conn[HDA_MAX_NUM_INPUTS];
1160 nums = snd_hda_get_connections(codec, mux, conn, ARRAY_SIZE(conn));
1161 for (i = 0; i < nums; i++)
1167 /* switch the current ADC according to the jack state */
1168 static void alc_dual_mic_adc_auto_switch(struct hda_codec *codec)
1170 struct alc_spec *spec = codec->spec;
1171 unsigned int present;
1174 present = snd_hda_jack_detect(codec, spec->ext_mic.pin);
1176 spec->cur_adc_idx = 1;
1178 spec->cur_adc_idx = 0;
1179 new_adc = spec->adc_nids[spec->cur_adc_idx];
1180 if (spec->cur_adc && spec->cur_adc != new_adc) {
1181 /* stream is running, let's swap the current ADC */
1182 __snd_hda_codec_cleanup_stream(codec, spec->cur_adc, 1);
1183 spec->cur_adc = new_adc;
1184 snd_hda_codec_setup_stream(codec, new_adc,
1185 spec->cur_adc_stream_tag, 0,
1186 spec->cur_adc_format);
1190 static void alc_mic_automute(struct hda_codec *codec)
1192 struct alc_spec *spec = codec->spec;
1193 struct alc_mic_route *dead, *alive;
1194 unsigned int present, type;
1197 if (!spec->auto_mic)
1199 if (!spec->int_mic.pin || !spec->ext_mic.pin)
1201 if (snd_BUG_ON(!spec->adc_nids))
1204 if (spec->dual_adc_switch) {
1205 alc_dual_mic_adc_auto_switch(codec);
1209 cap_nid = spec->capsrc_nids ? spec->capsrc_nids[0] : spec->adc_nids[0];
1211 present = snd_hda_jack_detect(codec, spec->ext_mic.pin);
1213 alive = &spec->ext_mic;
1214 dead = &spec->int_mic;
1216 alive = &spec->int_mic;
1217 dead = &spec->ext_mic;
1220 type = get_wcaps_type(get_wcaps(codec, cap_nid));
1221 if (type == AC_WID_AUD_MIX) {
1222 /* Matrix-mixer style (e.g. ALC882) */
1223 snd_hda_codec_amp_stereo(codec, cap_nid, HDA_INPUT,
1226 snd_hda_codec_amp_stereo(codec, cap_nid, HDA_INPUT,
1228 HDA_AMP_MUTE, HDA_AMP_MUTE);
1230 /* MUX style (e.g. ALC880) */
1231 snd_hda_codec_write_cache(codec, cap_nid, 0,
1232 AC_VERB_SET_CONNECT_SEL,
1235 alc_report_jack(codec, spec->ext_mic.pin);
1237 /* FIXME: analog mixer */
1240 /* unsolicited event for HP jack sensing */
1241 static void alc_sku_unsol_event(struct hda_codec *codec, unsigned int res)
1243 if (codec->vendor_id == 0x10ec0880)
1248 case ALC880_HP_EVENT:
1249 alc_automute_pin(codec);
1251 case ALC880_MIC_EVENT:
1252 alc_mic_automute(codec);
1257 static void alc_inithook(struct hda_codec *codec)
1259 alc_automute_pin(codec);
1260 alc_mic_automute(codec);
1263 /* additional initialization for ALC888 variants */
1264 static void alc888_coef_init(struct hda_codec *codec)
1268 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 0);
1269 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
1270 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
1271 if ((tmp & 0xf0) == 0x20)
1273 snd_hda_codec_read(codec, 0x20, 0,
1274 AC_VERB_SET_PROC_COEF, 0x830);
1277 snd_hda_codec_read(codec, 0x20, 0,
1278 AC_VERB_SET_PROC_COEF, 0x3030);
1281 static void alc889_coef_init(struct hda_codec *codec)
1285 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
1286 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
1287 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
1288 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_PROC_COEF, tmp|0x2010);
1291 /* turn on/off EAPD control (only if available) */
1292 static void set_eapd(struct hda_codec *codec, hda_nid_t nid, int on)
1294 if (get_wcaps_type(get_wcaps(codec, nid)) != AC_WID_PIN)
1296 if (snd_hda_query_pin_caps(codec, nid) & AC_PINCAP_EAPD)
1297 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
1301 static void alc_auto_init_amp(struct hda_codec *codec, int type)
1306 case ALC_INIT_GPIO1:
1307 snd_hda_sequence_write(codec, alc_gpio1_init_verbs);
1309 case ALC_INIT_GPIO2:
1310 snd_hda_sequence_write(codec, alc_gpio2_init_verbs);
1312 case ALC_INIT_GPIO3:
1313 snd_hda_sequence_write(codec, alc_gpio3_init_verbs);
1315 case ALC_INIT_DEFAULT:
1316 switch (codec->vendor_id) {
1318 set_eapd(codec, 0x0f, 1);
1319 set_eapd(codec, 0x10, 1);
1332 set_eapd(codec, 0x14, 1);
1333 set_eapd(codec, 0x15, 1);
1336 switch (codec->vendor_id) {
1338 snd_hda_codec_write(codec, 0x1a, 0,
1339 AC_VERB_SET_COEF_INDEX, 7);
1340 tmp = snd_hda_codec_read(codec, 0x1a, 0,
1341 AC_VERB_GET_PROC_COEF, 0);
1342 snd_hda_codec_write(codec, 0x1a, 0,
1343 AC_VERB_SET_COEF_INDEX, 7);
1344 snd_hda_codec_write(codec, 0x1a, 0,
1345 AC_VERB_SET_PROC_COEF,
1355 alc889_coef_init(codec);
1358 alc888_coef_init(codec);
1360 #if 0 /* XXX: This may cause the silent output on speaker on some machines */
1363 snd_hda_codec_write(codec, 0x20, 0,
1364 AC_VERB_SET_COEF_INDEX, 7);
1365 tmp = snd_hda_codec_read(codec, 0x20, 0,
1366 AC_VERB_GET_PROC_COEF, 0);
1367 snd_hda_codec_write(codec, 0x20, 0,
1368 AC_VERB_SET_COEF_INDEX, 7);
1369 snd_hda_codec_write(codec, 0x20, 0,
1370 AC_VERB_SET_PROC_COEF,
1379 static void alc_init_auto_hp(struct hda_codec *codec)
1381 struct alc_spec *spec = codec->spec;
1382 struct auto_pin_cfg *cfg = &spec->autocfg;
1385 if (!cfg->hp_pins[0]) {
1386 if (cfg->line_out_type != AUTO_PIN_HP_OUT)
1390 if (!cfg->speaker_pins[0]) {
1391 if (cfg->line_out_type != AUTO_PIN_SPEAKER_OUT)
1393 memcpy(cfg->speaker_pins, cfg->line_out_pins,
1394 sizeof(cfg->speaker_pins));
1395 cfg->speaker_outs = cfg->line_outs;
1398 if (!cfg->hp_pins[0]) {
1399 memcpy(cfg->hp_pins, cfg->line_out_pins,
1400 sizeof(cfg->hp_pins));
1401 cfg->hp_outs = cfg->line_outs;
1404 for (i = 0; i < cfg->hp_outs; i++) {
1405 snd_printdd("realtek: Enable HP auto-muting on NID 0x%x\n",
1407 snd_hda_codec_write_cache(codec, cfg->hp_pins[i], 0,
1408 AC_VERB_SET_UNSOLICITED_ENABLE,
1409 AC_USRSP_EN | ALC880_HP_EVENT);
1411 spec->unsol_event = alc_sku_unsol_event;
1414 static void alc_init_auto_mic(struct hda_codec *codec)
1416 struct alc_spec *spec = codec->spec;
1417 struct auto_pin_cfg *cfg = &spec->autocfg;
1418 hda_nid_t fixed, ext;
1421 /* there must be only two mic inputs exclusively */
1422 for (i = 0; i < cfg->num_inputs; i++)
1423 if (cfg->inputs[i].type >= AUTO_PIN_LINE_IN)
1427 for (i = 0; i < cfg->num_inputs; i++) {
1428 hda_nid_t nid = cfg->inputs[i].pin;
1429 unsigned int defcfg;
1430 defcfg = snd_hda_codec_get_pincfg(codec, nid);
1431 switch (snd_hda_get_input_pin_attr(defcfg)) {
1432 case INPUT_PIN_ATTR_INT:
1434 return; /* already occupied */
1437 case INPUT_PIN_ATTR_UNUSED:
1438 return; /* invalid entry */
1441 return; /* already occupied */
1448 if (!(get_wcaps(codec, ext) & AC_WCAP_UNSOL_CAP))
1449 return; /* no unsol support */
1450 snd_printdd("realtek: Enable auto-mic switch on NID 0x%x/0x%x\n",
1452 spec->ext_mic.pin = ext;
1453 spec->int_mic.pin = fixed;
1454 spec->ext_mic.mux_idx = MUX_IDX_UNDEF; /* set later */
1455 spec->int_mic.mux_idx = MUX_IDX_UNDEF; /* set later */
1457 snd_hda_codec_write_cache(codec, spec->ext_mic.pin, 0,
1458 AC_VERB_SET_UNSOLICITED_ENABLE,
1459 AC_USRSP_EN | ALC880_MIC_EVENT);
1460 spec->unsol_event = alc_sku_unsol_event;
1463 static int alc_auto_parse_customize_define(struct hda_codec *codec)
1465 unsigned int ass, tmp, i;
1467 struct alc_spec *spec = codec->spec;
1469 spec->cdefine.enable_pcbeep = 1; /* assume always enabled */
1471 ass = codec->subsystem_id & 0xffff;
1472 if (ass != codec->bus->pci->subsystem_device && (ass & 1))
1476 if (codec->vendor_id == 0x10ec0260)
1478 ass = snd_hda_codec_get_pincfg(codec, nid);
1481 printk(KERN_INFO "hda_codec: %s: SKU not ready 0x%08x\n",
1482 codec->chip_name, ass);
1488 for (i = 1; i < 16; i++) {
1492 if (((ass >> 16) & 0xf) != tmp)
1495 spec->cdefine.port_connectivity = ass >> 30;
1496 spec->cdefine.enable_pcbeep = (ass & 0x100000) >> 20;
1497 spec->cdefine.check_sum = (ass >> 16) & 0xf;
1498 spec->cdefine.customization = ass >> 8;
1500 spec->cdefine.sku_cfg = ass;
1501 spec->cdefine.external_amp = (ass & 0x38) >> 3;
1502 spec->cdefine.platform_type = (ass & 0x4) >> 2;
1503 spec->cdefine.swap = (ass & 0x2) >> 1;
1504 spec->cdefine.override = ass & 0x1;
1506 snd_printd("SKU: Nid=0x%x sku_cfg=0x%08x\n",
1507 nid, spec->cdefine.sku_cfg);
1508 snd_printd("SKU: port_connectivity=0x%x\n",
1509 spec->cdefine.port_connectivity);
1510 snd_printd("SKU: enable_pcbeep=0x%x\n", spec->cdefine.enable_pcbeep);
1511 snd_printd("SKU: check_sum=0x%08x\n", spec->cdefine.check_sum);
1512 snd_printd("SKU: customization=0x%08x\n", spec->cdefine.customization);
1513 snd_printd("SKU: external_amp=0x%x\n", spec->cdefine.external_amp);
1514 snd_printd("SKU: platform_type=0x%x\n", spec->cdefine.platform_type);
1515 snd_printd("SKU: swap=0x%x\n", spec->cdefine.swap);
1516 snd_printd("SKU: override=0x%x\n", spec->cdefine.override);
1521 /* check subsystem ID and set up device-specific initialization;
1522 * return 1 if initialized, 0 if invalid SSID
1524 /* 32-bit subsystem ID for BIOS loading in HD Audio codec.
1525 * 31 ~ 16 : Manufacture ID
1527 * 7 ~ 0 : Assembly ID
1528 * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36
1530 static int alc_subsystem_id(struct hda_codec *codec,
1531 hda_nid_t porta, hda_nid_t porte,
1532 hda_nid_t portd, hda_nid_t porti)
1534 unsigned int ass, tmp, i;
1536 struct alc_spec *spec = codec->spec;
1538 ass = codec->subsystem_id & 0xffff;
1539 if ((ass != codec->bus->pci->subsystem_device) && (ass & 1))
1542 /* invalid SSID, check the special NID pin defcfg instead */
1544 * 31~30 : port connectivity
1547 * 19~16 : Check sum (15:1)
1552 if (codec->vendor_id == 0x10ec0260)
1554 ass = snd_hda_codec_get_pincfg(codec, nid);
1555 snd_printd("realtek: No valid SSID, "
1556 "checking pincfg 0x%08x for NID 0x%x\n",
1560 if ((ass >> 30) != 1) /* no physical connection */
1565 for (i = 1; i < 16; i++) {
1569 if (((ass >> 16) & 0xf) != tmp)
1572 snd_printd("realtek: Enabling init ASM_ID=0x%04x CODEC_ID=%08x\n",
1573 ass & 0xffff, codec->vendor_id);
1577 * 2 : 0 --> Desktop, 1 --> Laptop
1578 * 3~5 : External Amplifier control
1581 tmp = (ass & 0x38) >> 3; /* external Amp control */
1584 spec->init_amp = ALC_INIT_GPIO1;
1587 spec->init_amp = ALC_INIT_GPIO2;
1590 spec->init_amp = ALC_INIT_GPIO3;
1593 spec->init_amp = ALC_INIT_DEFAULT;
1597 /* is laptop or Desktop and enable the function "Mute internal speaker
1598 * when the external headphone out jack is plugged"
1600 if (!(ass & 0x8000))
1603 * 10~8 : Jack location
1604 * 12~11: Headphone out -> 00: PortA, 01: PortE, 02: PortD, 03: Resvered
1606 * 15 : 1 --> enable the function "Mute internal speaker
1607 * when the external headphone out jack is plugged"
1609 if (!spec->autocfg.hp_pins[0]) {
1611 tmp = (ass >> 11) & 0x3; /* HP to chassis */
1622 for (i = 0; i < spec->autocfg.line_outs; i++)
1623 if (spec->autocfg.line_out_pins[i] == nid)
1625 spec->autocfg.hp_pins[0] = nid;
1628 alc_init_auto_hp(codec);
1629 alc_init_auto_mic(codec);
1633 static void alc_ssid_check(struct hda_codec *codec,
1634 hda_nid_t porta, hda_nid_t porte,
1635 hda_nid_t portd, hda_nid_t porti)
1637 if (!alc_subsystem_id(codec, porta, porte, portd, porti)) {
1638 struct alc_spec *spec = codec->spec;
1639 snd_printd("realtek: "
1640 "Enable default setup for auto mode as fallback\n");
1641 spec->init_amp = ALC_INIT_DEFAULT;
1642 alc_init_auto_hp(codec);
1643 alc_init_auto_mic(codec);
1648 * Fix-up pin default configurations and add default verbs
1657 const struct alc_pincfg *pins;
1658 const struct hda_verb *verbs;
1661 static void alc_pick_fixup(struct hda_codec *codec,
1662 const struct snd_pci_quirk *quirk,
1663 const struct alc_fixup *fix,
1666 const struct alc_pincfg *cfg;
1668 quirk = snd_pci_quirk_lookup(codec->bus->pci, quirk);
1671 fix += quirk->value;
1673 if (pre_init && cfg) {
1674 #ifdef CONFIG_SND_DEBUG_VERBOSE
1675 snd_printdd(KERN_INFO "hda_codec: %s: Apply pincfg for %s\n",
1676 codec->chip_name, quirk->name);
1678 for (; cfg->nid; cfg++)
1679 snd_hda_codec_set_pincfg(codec, cfg->nid, cfg->val);
1681 if (!pre_init && fix->verbs) {
1682 #ifdef CONFIG_SND_DEBUG_VERBOSE
1683 snd_printdd(KERN_INFO "hda_codec: %s: Apply fix-verbs for %s\n",
1684 codec->chip_name, quirk->name);
1686 add_verb(codec->spec, fix->verbs);
1690 static int alc_read_coef_idx(struct hda_codec *codec,
1691 unsigned int coef_idx)
1694 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX,
1696 val = snd_hda_codec_read(codec, 0x20, 0,
1697 AC_VERB_GET_PROC_COEF, 0);
1701 static void alc_write_coef_idx(struct hda_codec *codec, unsigned int coef_idx,
1702 unsigned int coef_val)
1704 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX,
1706 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_PROC_COEF,
1710 /* set right pin controls for digital I/O */
1711 static void alc_auto_init_digital(struct hda_codec *codec)
1713 struct alc_spec *spec = codec->spec;
1717 for (i = 0; i < spec->autocfg.dig_outs; i++) {
1718 pin = spec->autocfg.dig_out_pins[i];
1720 snd_hda_codec_write(codec, pin, 0,
1721 AC_VERB_SET_PIN_WIDGET_CONTROL,
1725 pin = spec->autocfg.dig_in_pin;
1727 snd_hda_codec_write(codec, pin, 0,
1728 AC_VERB_SET_PIN_WIDGET_CONTROL,
1732 /* parse digital I/Os and set up NIDs in BIOS auto-parse mode */
1733 static void alc_auto_parse_digital(struct hda_codec *codec)
1735 struct alc_spec *spec = codec->spec;
1739 /* support multiple SPDIFs; the secondary is set up as a slave */
1740 for (i = 0; i < spec->autocfg.dig_outs; i++) {
1741 err = snd_hda_get_connections(codec,
1742 spec->autocfg.dig_out_pins[i],
1747 spec->multiout.dig_out_nid = dig_nid;
1748 spec->dig_out_type = spec->autocfg.dig_out_type[0];
1750 spec->multiout.slave_dig_outs = spec->slave_dig_outs;
1751 if (i >= ARRAY_SIZE(spec->slave_dig_outs) - 1)
1753 spec->slave_dig_outs[i - 1] = dig_nid;
1757 if (spec->autocfg.dig_in_pin) {
1759 err = snd_hda_get_connections(codec,
1760 spec->autocfg.dig_in_pin,
1763 spec->dig_in_nid = dig_nid;
1774 static struct hda_verb alc888_4ST_ch2_intel_init[] = {
1775 /* Mic-in jack as mic in */
1776 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1777 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1778 /* Line-in jack as Line in */
1779 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1780 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1781 /* Line-Out as Front */
1782 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
1789 static struct hda_verb alc888_4ST_ch4_intel_init[] = {
1790 /* Mic-in jack as mic in */
1791 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1792 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1793 /* Line-in jack as Surround */
1794 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1795 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1796 /* Line-Out as Front */
1797 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
1804 static struct hda_verb alc888_4ST_ch6_intel_init[] = {
1805 /* Mic-in jack as CLFE */
1806 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1807 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1808 /* Line-in jack as Surround */
1809 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1810 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1811 /* Line-Out as CLFE (workaround because Mic-in is not loud enough) */
1812 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1819 static struct hda_verb alc888_4ST_ch8_intel_init[] = {
1820 /* Mic-in jack as CLFE */
1821 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1822 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1823 /* Line-in jack as Surround */
1824 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1825 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1826 /* Line-Out as Side */
1827 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1831 static struct hda_channel_mode alc888_4ST_8ch_intel_modes[4] = {
1832 { 2, alc888_4ST_ch2_intel_init },
1833 { 4, alc888_4ST_ch4_intel_init },
1834 { 6, alc888_4ST_ch6_intel_init },
1835 { 8, alc888_4ST_ch8_intel_init },
1839 * ALC888 Fujitsu Siemens Amillo xa3530
1842 static struct hda_verb alc888_fujitsu_xa3530_verbs[] = {
1843 /* Front Mic: set to PIN_IN (empty by default) */
1844 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1845 /* Connect Internal HP to Front */
1846 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1847 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1848 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1849 /* Connect Bass HP to Front */
1850 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1851 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1852 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1853 /* Connect Line-Out side jack (SPDIF) to Side */
1854 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1855 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1856 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1857 /* Connect Mic jack to CLFE */
1858 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1859 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1860 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02},
1861 /* Connect Line-in jack to Surround */
1862 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1863 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1864 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
1865 /* Connect HP out jack to Front */
1866 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1867 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1868 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
1869 /* Enable unsolicited event for HP jack and Line-out jack */
1870 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1871 {0x17, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1875 static void alc_automute_amp(struct hda_codec *codec)
1877 alc_automute_speaker(codec, 0);
1880 static void alc_automute_amp_unsol_event(struct hda_codec *codec,
1883 if (codec->vendor_id == 0x10ec0880)
1887 if (res == ALC880_HP_EVENT)
1888 alc_automute_amp(codec);
1891 static void alc889_automute_setup(struct hda_codec *codec)
1893 struct alc_spec *spec = codec->spec;
1895 spec->autocfg.hp_pins[0] = 0x15;
1896 spec->autocfg.speaker_pins[0] = 0x14;
1897 spec->autocfg.speaker_pins[1] = 0x16;
1898 spec->autocfg.speaker_pins[2] = 0x17;
1899 spec->autocfg.speaker_pins[3] = 0x19;
1900 spec->autocfg.speaker_pins[4] = 0x1a;
1903 static void alc889_intel_init_hook(struct hda_codec *codec)
1905 alc889_coef_init(codec);
1906 alc_automute_amp(codec);
1909 static void alc888_fujitsu_xa3530_setup(struct hda_codec *codec)
1911 struct alc_spec *spec = codec->spec;
1913 spec->autocfg.hp_pins[0] = 0x17; /* line-out */
1914 spec->autocfg.hp_pins[1] = 0x1b; /* hp */
1915 spec->autocfg.speaker_pins[0] = 0x14; /* speaker */
1916 spec->autocfg.speaker_pins[1] = 0x15; /* bass */
1920 * ALC888 Acer Aspire 4930G model
1923 static struct hda_verb alc888_acer_aspire_4930g_verbs[] = {
1924 /* Front Mic: set to PIN_IN (empty by default) */
1925 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1926 /* Unselect Front Mic by default in input mixer 3 */
1927 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
1928 /* Enable unsolicited event for HP jack */
1929 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1930 /* Connect Internal HP to front */
1931 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1932 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1933 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1934 /* Connect HP out to front */
1935 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1936 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1937 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1942 * ALC888 Acer Aspire 6530G model
1945 static struct hda_verb alc888_acer_aspire_6530g_verbs[] = {
1946 /* Route to built-in subwoofer as well as speakers */
1947 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1948 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1949 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1950 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1951 /* Bias voltage on for external mic port */
1952 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN | PIN_VREF80},
1953 /* Front Mic: set to PIN_IN (empty by default) */
1954 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1955 /* Unselect Front Mic by default in input mixer 3 */
1956 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
1957 /* Enable unsolicited event for HP jack */
1958 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1959 /* Enable speaker output */
1960 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1961 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1962 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
1963 /* Enable headphone output */
1964 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | PIN_HP},
1965 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1966 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1967 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
1972 * ALC889 Acer Aspire 8930G model
1975 static struct hda_verb alc889_acer_aspire_8930g_verbs[] = {
1976 /* Front Mic: set to PIN_IN (empty by default) */
1977 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1978 /* Unselect Front Mic by default in input mixer 3 */
1979 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
1980 /* Enable unsolicited event for HP jack */
1981 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1982 /* Connect Internal Front to Front */
1983 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1984 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1985 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1986 /* Connect Internal Rear to Rear */
1987 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1988 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1989 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01},
1990 /* Connect Internal CLFE to CLFE */
1991 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1992 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1993 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
1994 /* Connect HP out to Front */
1995 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | PIN_HP},
1996 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1997 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1998 /* Enable all DACs */
1999 /* DAC DISABLE/MUTE 1? */
2000 /* setting bits 1-5 disables DAC nids 0x02-0x06 apparently. Init=0x38 */
2001 {0x20, AC_VERB_SET_COEF_INDEX, 0x03},
2002 {0x20, AC_VERB_SET_PROC_COEF, 0x0000},
2003 /* DAC DISABLE/MUTE 2? */
2004 /* some bit here disables the other DACs. Init=0x4900 */
2005 {0x20, AC_VERB_SET_COEF_INDEX, 0x08},
2006 {0x20, AC_VERB_SET_PROC_COEF, 0x0000},
2008 * This laptop has a stereo digital microphone. The mics are only 1cm apart
2009 * which makes the stereo useless. However, either the mic or the ALC889
2010 * makes the signal become a difference/sum signal instead of standard
2011 * stereo, which is annoying. So instead we flip this bit which makes the
2012 * codec replicate the sum signal to both channels, turning it into a
2015 /* DMIC_CONTROL? Init value = 0x0001 */
2016 {0x20, AC_VERB_SET_COEF_INDEX, 0x0b},
2017 {0x20, AC_VERB_SET_PROC_COEF, 0x0003},
2021 static struct hda_input_mux alc888_2_capture_sources[2] = {
2022 /* Front mic only available on one ADC */
2029 { "Front Mic", 0xb },
2042 static struct hda_input_mux alc888_acer_aspire_6530_sources[2] = {
2043 /* Interal mic only available on one ADC */
2050 { "Input Mix", 0xa },
2060 { "Input Mix", 0xa },
2065 static struct hda_input_mux alc889_capture_sources[3] = {
2066 /* Digital mic only available on first "ADC" */
2073 { "Front Mic", 0xb },
2074 { "Input Mix", 0xa },
2083 { "Input Mix", 0xa },
2092 { "Input Mix", 0xa },
2097 static struct snd_kcontrol_new alc888_base_mixer[] = {
2098 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2099 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2100 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2101 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
2102 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
2104 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2105 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2106 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2107 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
2108 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
2109 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2110 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2111 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2112 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2113 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2114 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
2115 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2119 static struct snd_kcontrol_new alc889_acer_aspire_8930g_mixer[] = {
2120 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2121 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2122 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2123 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
2124 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
2126 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2127 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2128 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2129 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2130 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2131 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2132 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
2133 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2138 static void alc888_acer_aspire_4930g_setup(struct hda_codec *codec)
2140 struct alc_spec *spec = codec->spec;
2142 spec->autocfg.hp_pins[0] = 0x15;
2143 spec->autocfg.speaker_pins[0] = 0x14;
2144 spec->autocfg.speaker_pins[1] = 0x16;
2145 spec->autocfg.speaker_pins[2] = 0x17;
2148 static void alc888_acer_aspire_6530g_setup(struct hda_codec *codec)
2150 struct alc_spec *spec = codec->spec;
2152 spec->autocfg.hp_pins[0] = 0x15;
2153 spec->autocfg.speaker_pins[0] = 0x14;
2154 spec->autocfg.speaker_pins[1] = 0x16;
2155 spec->autocfg.speaker_pins[2] = 0x17;
2158 static void alc889_acer_aspire_8930g_setup(struct hda_codec *codec)
2160 struct alc_spec *spec = codec->spec;
2162 spec->autocfg.hp_pins[0] = 0x15;
2163 spec->autocfg.speaker_pins[0] = 0x14;
2164 spec->autocfg.speaker_pins[1] = 0x16;
2165 spec->autocfg.speaker_pins[2] = 0x1b;
2169 * ALC880 3-stack model
2171 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
2172 * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18,
2173 * F-Mic = 0x1b, HP = 0x19
2176 static hda_nid_t alc880_dac_nids[4] = {
2177 /* front, rear, clfe, rear_surr */
2178 0x02, 0x05, 0x04, 0x03
2181 static hda_nid_t alc880_adc_nids[3] = {
2186 /* The datasheet says the node 0x07 is connected from inputs,
2187 * but it shows zero connection in the real implementation on some devices.
2188 * Note: this is a 915GAV bug, fixed on 915GLV
2190 static hda_nid_t alc880_adc_nids_alt[2] = {
2195 #define ALC880_DIGOUT_NID 0x06
2196 #define ALC880_DIGIN_NID 0x0a
2198 static struct hda_input_mux alc880_capture_source = {
2202 { "Front Mic", 0x3 },
2208 /* channel source setting (2/6 channel selection for 3-stack) */
2210 static struct hda_verb alc880_threestack_ch2_init[] = {
2211 /* set line-in to input, mute it */
2212 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
2213 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
2214 /* set mic-in to input vref 80%, mute it */
2215 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
2216 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
2221 static struct hda_verb alc880_threestack_ch6_init[] = {
2222 /* set line-in to output, unmute it */
2223 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
2224 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
2225 /* set mic-in to output, unmute it */
2226 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
2227 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
2231 static struct hda_channel_mode alc880_threestack_modes[2] = {
2232 { 2, alc880_threestack_ch2_init },
2233 { 6, alc880_threestack_ch6_init },
2236 static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
2237 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2238 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2239 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
2240 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
2241 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2242 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2243 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2244 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2245 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2246 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2247 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2248 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2249 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2250 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2251 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
2252 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
2253 HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
2255 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2256 .name = "Channel Mode",
2257 .info = alc_ch_mode_info,
2258 .get = alc_ch_mode_get,
2259 .put = alc_ch_mode_put,
2264 /* capture mixer elements */
2265 static int alc_cap_vol_info(struct snd_kcontrol *kcontrol,
2266 struct snd_ctl_elem_info *uinfo)
2268 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2269 struct alc_spec *spec = codec->spec;
2272 mutex_lock(&codec->control_mutex);
2273 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0,
2275 err = snd_hda_mixer_amp_volume_info(kcontrol, uinfo);
2276 mutex_unlock(&codec->control_mutex);
2280 static int alc_cap_vol_tlv(struct snd_kcontrol *kcontrol, int op_flag,
2281 unsigned int size, unsigned int __user *tlv)
2283 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2284 struct alc_spec *spec = codec->spec;
2287 mutex_lock(&codec->control_mutex);
2288 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0,
2290 err = snd_hda_mixer_amp_tlv(kcontrol, op_flag, size, tlv);
2291 mutex_unlock(&codec->control_mutex);
2295 typedef int (*getput_call_t)(struct snd_kcontrol *kcontrol,
2296 struct snd_ctl_elem_value *ucontrol);
2298 static int alc_cap_getput_caller(struct snd_kcontrol *kcontrol,
2299 struct snd_ctl_elem_value *ucontrol,
2302 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2303 struct alc_spec *spec = codec->spec;
2304 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
2307 mutex_lock(&codec->control_mutex);
2308 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[adc_idx],
2310 err = func(kcontrol, ucontrol);
2311 mutex_unlock(&codec->control_mutex);
2315 static int alc_cap_vol_get(struct snd_kcontrol *kcontrol,
2316 struct snd_ctl_elem_value *ucontrol)
2318 return alc_cap_getput_caller(kcontrol, ucontrol,
2319 snd_hda_mixer_amp_volume_get);
2322 static int alc_cap_vol_put(struct snd_kcontrol *kcontrol,
2323 struct snd_ctl_elem_value *ucontrol)
2325 return alc_cap_getput_caller(kcontrol, ucontrol,
2326 snd_hda_mixer_amp_volume_put);
2329 /* capture mixer elements */
2330 #define alc_cap_sw_info snd_ctl_boolean_stereo_info
2332 static int alc_cap_sw_get(struct snd_kcontrol *kcontrol,
2333 struct snd_ctl_elem_value *ucontrol)
2335 return alc_cap_getput_caller(kcontrol, ucontrol,
2336 snd_hda_mixer_amp_switch_get);
2339 static int alc_cap_sw_put(struct snd_kcontrol *kcontrol,
2340 struct snd_ctl_elem_value *ucontrol)
2342 return alc_cap_getput_caller(kcontrol, ucontrol,
2343 snd_hda_mixer_amp_switch_put);
2346 #define _DEFINE_CAPMIX(num) \
2348 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2349 .name = "Capture Switch", \
2350 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, \
2352 .info = alc_cap_sw_info, \
2353 .get = alc_cap_sw_get, \
2354 .put = alc_cap_sw_put, \
2357 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2358 .name = "Capture Volume", \
2359 .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE | \
2360 SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
2361 SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK), \
2363 .info = alc_cap_vol_info, \
2364 .get = alc_cap_vol_get, \
2365 .put = alc_cap_vol_put, \
2366 .tlv = { .c = alc_cap_vol_tlv }, \
2369 #define _DEFINE_CAPSRC(num) \
2371 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2372 /* .name = "Capture Source", */ \
2373 .name = "Input Source", \
2375 .info = alc_mux_enum_info, \
2376 .get = alc_mux_enum_get, \
2377 .put = alc_mux_enum_put, \
2380 #define DEFINE_CAPMIX(num) \
2381 static struct snd_kcontrol_new alc_capture_mixer ## num[] = { \
2382 _DEFINE_CAPMIX(num), \
2383 _DEFINE_CAPSRC(num), \
2387 #define DEFINE_CAPMIX_NOSRC(num) \
2388 static struct snd_kcontrol_new alc_capture_mixer_nosrc ## num[] = { \
2389 _DEFINE_CAPMIX(num), \
2393 /* up to three ADCs */
2397 DEFINE_CAPMIX_NOSRC(1);
2398 DEFINE_CAPMIX_NOSRC(2);
2399 DEFINE_CAPMIX_NOSRC(3);
2402 * ALC880 5-stack model
2404 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d),
2406 * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
2407 * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
2410 /* additional mixers to alc880_three_stack_mixer */
2411 static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
2412 HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2413 HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
2417 /* channel source setting (6/8 channel selection for 5-stack) */
2419 static struct hda_verb alc880_fivestack_ch6_init[] = {
2420 /* set line-in to input, mute it */
2421 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
2422 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
2427 static struct hda_verb alc880_fivestack_ch8_init[] = {
2428 /* set line-in to output, unmute it */
2429 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
2430 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
2434 static struct hda_channel_mode alc880_fivestack_modes[2] = {
2435 { 6, alc880_fivestack_ch6_init },
2436 { 8, alc880_fivestack_ch8_init },
2441 * ALC880 6-stack model
2443 * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e),
2444 * Side = 0x05 (0x0f)
2445 * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
2446 * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
2449 static hda_nid_t alc880_6st_dac_nids[4] = {
2450 /* front, rear, clfe, rear_surr */
2451 0x02, 0x03, 0x04, 0x05
2454 static struct hda_input_mux alc880_6stack_capture_source = {
2458 { "Front Mic", 0x1 },
2464 /* fixed 8-channels */
2465 static struct hda_channel_mode alc880_sixstack_modes[1] = {
2469 static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
2470 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2471 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2472 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2473 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
2474 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2475 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2476 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2477 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2478 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
2479 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
2480 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2481 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2482 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2483 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2484 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2485 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2486 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2487 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
2489 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2490 .name = "Channel Mode",
2491 .info = alc_ch_mode_info,
2492 .get = alc_ch_mode_get,
2493 .put = alc_ch_mode_put,
2502 * W810 has rear IO for:
2505 * Center/LFE (DAC 04)
2508 * The system also has a pair of internal speakers, and a headphone jack.
2509 * These are both connected to Line2 on the codec, hence to DAC 02.
2511 * There is a variable resistor to control the speaker or headphone
2512 * volume. This is a hardware-only device without a software API.
2514 * Plugging headphones in will disable the internal speakers. This is
2515 * implemented in hardware, not via the driver using jack sense. In
2516 * a similar fashion, plugging into the rear socket marked "front" will
2517 * disable both the speakers and headphones.
2519 * For input, there's a microphone jack, and an "audio in" jack.
2520 * These may not do anything useful with this driver yet, because I
2521 * haven't setup any initialization verbs for these yet...
2524 static hda_nid_t alc880_w810_dac_nids[3] = {
2525 /* front, rear/surround, clfe */
2529 /* fixed 6 channels */
2530 static struct hda_channel_mode alc880_w810_modes[1] = {
2534 /* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
2535 static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
2536 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2537 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2538 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2539 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
2540 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2541 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2542 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2543 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2544 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
2552 * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
2553 * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?),
2557 static hda_nid_t alc880_z71v_dac_nids[1] = {
2560 #define ALC880_Z71V_HP_DAC 0x03
2562 /* fixed 2 channels */
2563 static struct hda_channel_mode alc880_2_jack_modes[1] = {
2567 static struct snd_kcontrol_new alc880_z71v_mixer[] = {
2568 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2569 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2570 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2571 HDA_BIND_MUTE("Headphone 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, 0x0, HDA_INPUT),
2575 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2581 * ALC880 F1734 model
2583 * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
2584 * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
2587 static hda_nid_t alc880_f1734_dac_nids[1] = {
2590 #define ALC880_F1734_HP_DAC 0x02
2592 static struct snd_kcontrol_new alc880_f1734_mixer[] = {
2593 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2594 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2595 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2596 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
2597 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2598 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2599 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2600 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
2604 static struct hda_input_mux alc880_f1734_capture_source = {
2616 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
2617 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
2618 * Mic = 0x18, Line = 0x1a
2621 #define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
2622 #define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
2624 static struct snd_kcontrol_new alc880_asus_mixer[] = {
2625 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2626 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2627 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2628 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
2629 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2630 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2631 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2632 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2633 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2634 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2635 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2636 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2637 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2638 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2640 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2641 .name = "Channel Mode",
2642 .info = alc_ch_mode_info,
2643 .get = alc_ch_mode_get,
2644 .put = alc_ch_mode_put,
2650 * ALC880 ASUS W1V model
2652 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
2653 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
2654 * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
2657 /* additional mixers to alc880_asus_mixer */
2658 static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
2659 HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
2660 HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
2665 static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
2666 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2667 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
2668 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
2669 HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
2670 HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
2671 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
2672 HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
2673 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
2674 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
2679 static struct snd_kcontrol_new alc880_uniwill_mixer[] = {
2680 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2681 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2682 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2683 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
2684 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2685 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2686 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2687 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2688 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2689 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2690 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2691 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2692 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2693 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2694 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2695 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
2697 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2698 .name = "Channel Mode",
2699 .info = alc_ch_mode_info,
2700 .get = alc_ch_mode_get,
2701 .put = alc_ch_mode_put,
2706 static struct snd_kcontrol_new alc880_fujitsu_mixer[] = {
2707 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2708 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2709 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2710 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
2711 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2712 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2713 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2714 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2715 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2716 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
2720 static struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = {
2721 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2722 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2723 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2724 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
2725 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2726 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2731 * virtual master controls
2735 * slave controls for virtual master
2737 static const char *alc_slave_vols[] = {
2738 "Front Playback Volume",
2739 "Surround Playback Volume",
2740 "Center Playback Volume",
2741 "LFE Playback Volume",
2742 "Side Playback Volume",
2743 "Headphone Playback Volume",
2744 "Speaker Playback Volume",
2745 "Mono Playback Volume",
2746 "Line-Out Playback Volume",
2747 "PCM Playback Volume",
2751 static const char *alc_slave_sws[] = {
2752 "Front Playback Switch",
2753 "Surround Playback Switch",
2754 "Center Playback Switch",
2755 "LFE Playback Switch",
2756 "Side Playback Switch",
2757 "Headphone Playback Switch",
2758 "Speaker Playback Switch",
2759 "Mono Playback Switch",
2760 "IEC958 Playback Switch",
2761 "Line-Out Playback Switch",
2762 "PCM Playback Switch",
2767 * build control elements
2770 #define NID_MAPPING (-1)
2772 #define SUBDEV_SPEAKER_ (0 << 6)
2773 #define SUBDEV_HP_ (1 << 6)
2774 #define SUBDEV_LINE_ (2 << 6)
2775 #define SUBDEV_SPEAKER(x) (SUBDEV_SPEAKER_ | ((x) & 0x3f))
2776 #define SUBDEV_HP(x) (SUBDEV_HP_ | ((x) & 0x3f))
2777 #define SUBDEV_LINE(x) (SUBDEV_LINE_ | ((x) & 0x3f))
2779 static void alc_free_kctls(struct hda_codec *codec);
2781 #ifdef CONFIG_SND_HDA_INPUT_BEEP
2782 /* additional beep mixers; the actual parameters are overwritten at build */
2783 static struct snd_kcontrol_new alc_beep_mixer[] = {
2784 HDA_CODEC_VOLUME("Beep Playback Volume", 0, 0, HDA_INPUT),
2785 HDA_CODEC_MUTE_BEEP("Beep Playback Switch", 0, 0, HDA_INPUT),
2790 static int alc_build_controls(struct hda_codec *codec)
2792 struct alc_spec *spec = codec->spec;
2793 struct snd_kcontrol *kctl = NULL;
2794 struct snd_kcontrol_new *knew;
2799 for (i = 0; i < spec->num_mixers; i++) {
2800 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
2804 if (spec->cap_mixer) {
2805 err = snd_hda_add_new_ctls(codec, spec->cap_mixer);
2809 if (spec->multiout.dig_out_nid) {
2810 err = snd_hda_create_spdif_out_ctls(codec,
2811 spec->multiout.dig_out_nid);
2814 if (!spec->no_analog) {
2815 err = snd_hda_create_spdif_share_sw(codec,
2819 spec->multiout.share_spdif = 1;
2822 if (spec->dig_in_nid) {
2823 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
2828 #ifdef CONFIG_SND_HDA_INPUT_BEEP
2829 /* create beep controls if needed */
2830 if (spec->beep_amp) {
2831 struct snd_kcontrol_new *knew;
2832 for (knew = alc_beep_mixer; knew->name; knew++) {
2833 struct snd_kcontrol *kctl;
2834 kctl = snd_ctl_new1(knew, codec);
2837 kctl->private_value = spec->beep_amp;
2838 err = snd_hda_ctl_add(codec, 0, kctl);
2845 /* if we have no master control, let's create it */
2846 if (!spec->no_analog &&
2847 !snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
2848 unsigned int vmaster_tlv[4];
2849 snd_hda_set_vmaster_tlv(codec, spec->vmaster_nid,
2850 HDA_OUTPUT, vmaster_tlv);
2851 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
2852 vmaster_tlv, alc_slave_vols);
2856 if (!spec->no_analog &&
2857 !snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
2858 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
2859 NULL, alc_slave_sws);
2864 /* assign Capture Source enums to NID */
2865 if (spec->capsrc_nids || spec->adc_nids) {
2866 kctl = snd_hda_find_mixer_ctl(codec, "Capture Source");
2868 kctl = snd_hda_find_mixer_ctl(codec, "Input Source");
2869 for (i = 0; kctl && i < kctl->count; i++) {
2870 hda_nid_t *nids = spec->capsrc_nids;
2872 nids = spec->adc_nids;
2873 err = snd_hda_add_nid(codec, kctl, i, nids[i]);
2878 if (spec->cap_mixer) {
2879 const char *kname = kctl ? kctl->id.name : NULL;
2880 for (knew = spec->cap_mixer; knew->name; knew++) {
2881 if (kname && strcmp(knew->name, kname) == 0)
2883 kctl = snd_hda_find_mixer_ctl(codec, knew->name);
2884 for (i = 0; kctl && i < kctl->count; i++) {
2885 err = snd_hda_add_nid(codec, kctl, i,
2893 /* other nid->control mapping */
2894 for (i = 0; i < spec->num_mixers; i++) {
2895 for (knew = spec->mixers[i]; knew->name; knew++) {
2896 if (knew->iface != NID_MAPPING)
2898 kctl = snd_hda_find_mixer_ctl(codec, knew->name);
2901 u = knew->subdevice;
2902 for (j = 0; j < 4; j++, u >>= 8) {
2907 case SUBDEV_SPEAKER_:
2908 nid = spec->autocfg.speaker_pins[nid];
2911 nid = spec->autocfg.line_out_pins[nid];
2914 nid = spec->autocfg.hp_pins[nid];
2919 err = snd_hda_add_nid(codec, kctl, 0, nid);
2923 u = knew->private_value;
2924 for (j = 0; j < 4; j++, u >>= 8) {
2928 err = snd_hda_add_nid(codec, kctl, 0, nid);
2935 alc_free_kctls(codec); /* no longer needed */
2942 * initialize the codec volumes, etc
2946 * generic initialization of ADC, input mixers and output mixers
2948 static struct hda_verb alc880_volume_init_verbs[] = {
2950 * Unmute ADC0-2 and set the default input to mic-in
2952 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
2953 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2954 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
2955 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2956 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
2957 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2959 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
2961 * Note: PASD motherboards uses the Line In 2 as the input for front
2964 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
2965 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2966 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2967 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
2968 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
2969 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
2970 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
2971 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
2974 * Set up output mixers (0x0c - 0x0f)
2976 /* set vol=0 to output mixers */
2977 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2978 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2979 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2980 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2981 /* set up input amps for analog loopback */
2982 /* Amp Indices: DAC = 0, mixer = 1 */
2983 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2984 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2985 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2986 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2987 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2988 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2989 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2990 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2996 * 3-stack pin configuration:
2997 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
2999 static struct hda_verb alc880_pin_3stack_init_verbs[] = {
3001 * preset connection lists of input pins
3002 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
3004 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
3005 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3006 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
3009 * Set pin mode and muting
3011 /* set front pin widgets 0x14 for output */
3012 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3013 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3014 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3015 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3016 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3017 /* Mic2 (as headphone out) for HP output */
3018 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3019 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3020 /* Line In pin widget for input */
3021 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3022 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3023 /* Line2 (as front mic) pin widget for input and vref at 80% */
3024 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3025 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3026 /* CD pin widget for input */
3027 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3033 * 5-stack pin configuration:
3034 * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
3035 * line-in/side = 0x1a, f-mic = 0x1b
3037 static struct hda_verb alc880_pin_5stack_init_verbs[] = {
3039 * preset connection lists of input pins
3040 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
3042 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3043 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
3046 * Set pin mode and muting
3048 /* set pin widgets 0x14-0x17 for output */
3049 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3050 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3051 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3052 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3053 /* unmute pins for output (no gain on this amp) */
3054 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3055 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3056 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3057 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3059 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3060 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3061 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3062 /* Mic2 (as headphone out) for HP output */
3063 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3064 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3065 /* Line In pin widget for input */
3066 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3067 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3068 /* Line2 (as front mic) pin widget for input and vref at 80% */
3069 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3070 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3071 /* CD pin widget for input */
3072 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3078 * W810 pin configuration:
3079 * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
3081 static struct hda_verb alc880_pin_w810_init_verbs[] = {
3082 /* hphone/speaker input selector: front DAC */
3083 {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
3085 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3086 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3087 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3088 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3089 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3090 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3092 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3093 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3099 * Z71V pin configuration:
3100 * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
3102 static struct hda_verb alc880_pin_z71v_init_verbs[] = {
3103 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3104 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3105 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3106 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3108 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3109 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3110 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3111 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3117 * 6-stack pin configuration:
3118 * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18,
3119 * f-mic = 0x19, line = 0x1a, HP = 0x1b
3121 static struct hda_verb alc880_pin_6stack_init_verbs[] = {
3122 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3124 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3125 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3126 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3127 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3128 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3129 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3130 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3131 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3133 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3134 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3135 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3136 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3137 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3138 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3139 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3140 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3141 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3147 * Uniwill pin configuration:
3148 * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19,
3151 static struct hda_verb alc880_uniwill_init_verbs[] = {
3152 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3154 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3155 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3156 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3157 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3158 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3159 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3160 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3161 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3162 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3163 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3164 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3165 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3166 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3167 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3169 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3170 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3171 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3172 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3173 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3174 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3175 /* {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, */
3176 /* {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
3177 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3179 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
3180 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
3187 * HP = 0x14, InternalSpeaker = 0x15, mic = 0x19,
3189 static struct hda_verb alc880_uniwill_p53_init_verbs[] = {
3190 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3192 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3193 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3194 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3195 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3196 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3197 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3198 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3199 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3200 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3201 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3202 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3203 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3205 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3206 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3207 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3208 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3209 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3210 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3212 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
3213 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_DCVOL_EVENT},
3218 static struct hda_verb alc880_beep_init_verbs[] = {
3219 { 0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5) },
3223 /* auto-toggle front mic */
3224 static void alc880_uniwill_mic_automute(struct hda_codec *codec)
3226 unsigned int present;
3229 present = snd_hda_jack_detect(codec, 0x18);
3230 bits = present ? HDA_AMP_MUTE : 0;
3231 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
3234 static void alc880_uniwill_setup(struct hda_codec *codec)
3236 struct alc_spec *spec = codec->spec;
3238 spec->autocfg.hp_pins[0] = 0x14;
3239 spec->autocfg.speaker_pins[0] = 0x15;
3240 spec->autocfg.speaker_pins[0] = 0x16;
3243 static void alc880_uniwill_init_hook(struct hda_codec *codec)
3245 alc_automute_amp(codec);
3246 alc880_uniwill_mic_automute(codec);
3249 static void alc880_uniwill_unsol_event(struct hda_codec *codec,
3252 /* Looks like the unsol event is incompatible with the standard
3253 * definition. 4bit tag is placed at 28 bit!
3255 switch (res >> 28) {
3256 case ALC880_MIC_EVENT:
3257 alc880_uniwill_mic_automute(codec);
3260 alc_automute_amp_unsol_event(codec, res);
3265 static void alc880_uniwill_p53_setup(struct hda_codec *codec)
3267 struct alc_spec *spec = codec->spec;
3269 spec->autocfg.hp_pins[0] = 0x14;
3270 spec->autocfg.speaker_pins[0] = 0x15;
3273 static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec)
3275 unsigned int present;
3277 present = snd_hda_codec_read(codec, 0x21, 0,
3278 AC_VERB_GET_VOLUME_KNOB_CONTROL, 0);
3279 present &= HDA_AMP_VOLMASK;
3280 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0,
3281 HDA_AMP_VOLMASK, present);
3282 snd_hda_codec_amp_stereo(codec, 0x0d, HDA_OUTPUT, 0,
3283 HDA_AMP_VOLMASK, present);
3286 static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec,
3289 /* Looks like the unsol event is incompatible with the standard
3290 * definition. 4bit tag is placed at 28 bit!
3292 if ((res >> 28) == ALC880_DCVOL_EVENT)
3293 alc880_uniwill_p53_dcvol_automute(codec);
3295 alc_automute_amp_unsol_event(codec, res);
3299 * F1734 pin configuration:
3300 * HP = 0x14, speaker-out = 0x15, mic = 0x18
3302 static struct hda_verb alc880_pin_f1734_init_verbs[] = {
3303 {0x07, AC_VERB_SET_CONNECT_SEL, 0x01},
3304 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
3305 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
3306 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
3307 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
3309 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3310 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3311 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3312 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3314 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3315 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3316 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
3317 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3318 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3319 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3320 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3321 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3322 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3324 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
3325 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_DCVOL_EVENT},
3331 * ASUS pin configuration:
3332 * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
3334 static struct hda_verb alc880_pin_asus_init_verbs[] = {
3335 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
3336 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
3337 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
3338 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
3340 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3341 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3342 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3343 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3344 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3345 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3346 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3347 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3349 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3350 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3351 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3352 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3353 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3354 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3355 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3356 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3357 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3362 /* Enable GPIO mask and set output */
3363 #define alc880_gpio1_init_verbs alc_gpio1_init_verbs
3364 #define alc880_gpio2_init_verbs alc_gpio2_init_verbs
3365 #define alc880_gpio3_init_verbs alc_gpio3_init_verbs
3367 /* Clevo m520g init */
3368 static struct hda_verb alc880_pin_clevo_init_verbs[] = {
3369 /* headphone output */
3370 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
3372 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3373 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3375 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3376 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3378 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3379 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3380 /* Mic1 (rear panel) */
3381 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3382 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3383 /* Mic2 (front panel) */
3384 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3385 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3387 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3388 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3389 /* change to EAPD mode */
3390 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
3391 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
3396 static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
3397 /* change to EAPD mode */
3398 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
3399 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
3401 /* Headphone output */
3402 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3404 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3405 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
3407 /* Line In pin widget for input */
3408 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3409 /* CD pin widget for input */
3410 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3411 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3412 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3414 /* change to EAPD mode */
3415 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
3416 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
3422 * LG m1 express dual
3425 * Rear Line-In/Out (blue): 0x14
3426 * Build-in Mic-In: 0x15
3428 * HP-Out (green): 0x1b
3429 * Mic-In/Out (red): 0x19
3433 /* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
3434 static hda_nid_t alc880_lg_dac_nids[3] = {
3438 /* seems analog CD is not working */
3439 static struct hda_input_mux alc880_lg_capture_source = {
3444 { "Internal Mic", 0x6 },
3448 /* 2,4,6 channel modes */
3449 static struct hda_verb alc880_lg_ch2_init[] = {
3450 /* set line-in and mic-in to input */
3451 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
3452 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
3456 static struct hda_verb alc880_lg_ch4_init[] = {
3457 /* set line-in to out and mic-in to input */
3458 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
3459 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
3463 static struct hda_verb alc880_lg_ch6_init[] = {
3464 /* set line-in and mic-in to output */
3465 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
3466 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
3470 static struct hda_channel_mode alc880_lg_ch_modes[3] = {
3471 { 2, alc880_lg_ch2_init },
3472 { 4, alc880_lg_ch4_init },
3473 { 6, alc880_lg_ch6_init },
3476 static struct snd_kcontrol_new alc880_lg_mixer[] = {
3477 HDA_CODEC_VOLUME("Front Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
3478 HDA_BIND_MUTE("Front Playback Switch", 0x0f, 2, HDA_INPUT),
3479 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3480 HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
3481 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
3482 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
3483 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
3484 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
3485 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
3486 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
3487 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
3488 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
3489 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
3490 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
3492 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3493 .name = "Channel Mode",
3494 .info = alc_ch_mode_info,
3495 .get = alc_ch_mode_get,
3496 .put = alc_ch_mode_put,
3501 static struct hda_verb alc880_lg_init_verbs[] = {
3502 /* set capture source to mic-in */
3503 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3504 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3505 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3506 /* mute all amp mixer inputs */
3507 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
3508 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
3509 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
3510 /* line-in to input */
3511 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3512 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3514 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3515 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3517 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3518 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3519 /* mic-in to input */
3520 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
3521 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3522 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3524 {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
3525 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3526 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3528 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
3532 /* toggle speaker-output according to the hp-jack state */
3533 static void alc880_lg_setup(struct hda_codec *codec)
3535 struct alc_spec *spec = codec->spec;
3537 spec->autocfg.hp_pins[0] = 0x1b;
3538 spec->autocfg.speaker_pins[0] = 0x17;
3547 * Built-in Mic-In: 0x19
3553 static struct hda_input_mux alc880_lg_lw_capture_source = {
3557 { "Internal Mic", 0x1 },
3562 #define alc880_lg_lw_modes alc880_threestack_modes
3564 static struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
3565 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3566 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
3567 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
3568 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
3569 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
3570 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
3571 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
3572 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
3573 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
3574 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
3575 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
3576 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
3577 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
3578 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
3580 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3581 .name = "Channel Mode",
3582 .info = alc_ch_mode_info,
3583 .get = alc_ch_mode_get,
3584 .put = alc_ch_mode_put,
3589 static struct hda_verb alc880_lg_lw_init_verbs[] = {
3590 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3591 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
3592 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
3594 /* set capture source to mic-in */
3595 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3596 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3597 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3598 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
3600 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3601 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3603 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3604 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3605 /* mic-in to input */
3606 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3607 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3609 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3610 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3612 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
3616 /* toggle speaker-output according to the hp-jack state */
3617 static void alc880_lg_lw_setup(struct hda_codec *codec)
3619 struct alc_spec *spec = codec->spec;
3621 spec->autocfg.hp_pins[0] = 0x1b;
3622 spec->autocfg.speaker_pins[0] = 0x14;
3625 static struct snd_kcontrol_new alc880_medion_rim_mixer[] = {
3626 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3627 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
3628 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
3629 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
3630 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
3631 HDA_CODEC_MUTE("Internal Playback Switch", 0x0b, 0x1, HDA_INPUT),
3635 static struct hda_input_mux alc880_medion_rim_capture_source = {
3639 { "Internal Mic", 0x1 },
3643 static struct hda_verb alc880_medion_rim_init_verbs[] = {
3644 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3646 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3647 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3649 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3650 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3651 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3652 /* Mic2 (as headphone out) for HP output */
3653 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3654 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3655 /* Internal Speaker */
3656 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3657 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3659 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
3660 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
3662 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
3666 /* toggle speaker-output according to the hp-jack state */
3667 static void alc880_medion_rim_automute(struct hda_codec *codec)
3669 struct alc_spec *spec = codec->spec;
3670 alc_automute_amp(codec);
3672 if (spec->jack_present)
3673 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 0);
3675 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 2);
3678 static void alc880_medion_rim_unsol_event(struct hda_codec *codec,
3681 /* Looks like the unsol event is incompatible with the standard
3682 * definition. 4bit tag is placed at 28 bit!
3684 if ((res >> 28) == ALC880_HP_EVENT)
3685 alc880_medion_rim_automute(codec);
3688 static void alc880_medion_rim_setup(struct hda_codec *codec)
3690 struct alc_spec *spec = codec->spec;
3692 spec->autocfg.hp_pins[0] = 0x14;
3693 spec->autocfg.speaker_pins[0] = 0x1b;
3696 #ifdef CONFIG_SND_HDA_POWER_SAVE
3697 static struct hda_amp_list alc880_loopbacks[] = {
3698 { 0x0b, HDA_INPUT, 0 },
3699 { 0x0b, HDA_INPUT, 1 },
3700 { 0x0b, HDA_INPUT, 2 },
3701 { 0x0b, HDA_INPUT, 3 },
3702 { 0x0b, HDA_INPUT, 4 },
3706 static struct hda_amp_list alc880_lg_loopbacks[] = {
3707 { 0x0b, HDA_INPUT, 1 },
3708 { 0x0b, HDA_INPUT, 6 },
3709 { 0x0b, HDA_INPUT, 7 },
3718 static int alc_init(struct hda_codec *codec)
3720 struct alc_spec *spec = codec->spec;
3724 alc_auto_init_amp(codec, spec->init_amp);
3726 for (i = 0; i < spec->num_init_verbs; i++)
3727 snd_hda_sequence_write(codec, spec->init_verbs[i]);
3729 if (spec->init_hook)
3730 spec->init_hook(codec);
3732 #ifdef CONFIG_SND_HDA_POWER_SAVE
3733 if (codec->patch_ops.check_power_status)
3734 codec->patch_ops.check_power_status(codec, 0x01);
3739 static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
3741 struct alc_spec *spec = codec->spec;
3743 if (spec->unsol_event)
3744 spec->unsol_event(codec, res);
3747 #ifdef CONFIG_SND_HDA_POWER_SAVE
3748 static int alc_check_power_status(struct hda_codec *codec, hda_nid_t nid)
3750 struct alc_spec *spec = codec->spec;
3751 return snd_hda_check_amp_list_power(codec, &spec->loopback, nid);
3756 * Analog playback callbacks
3758 static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
3759 struct hda_codec *codec,
3760 struct snd_pcm_substream *substream)
3762 struct alc_spec *spec = codec->spec;
3763 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
3767 static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
3768 struct hda_codec *codec,
3769 unsigned int stream_tag,
3770 unsigned int format,
3771 struct snd_pcm_substream *substream)
3773 struct alc_spec *spec = codec->spec;
3774 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
3775 stream_tag, format, substream);
3778 static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
3779 struct hda_codec *codec,
3780 struct snd_pcm_substream *substream)
3782 struct alc_spec *spec = codec->spec;
3783 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
3789 static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
3790 struct hda_codec *codec,
3791 struct snd_pcm_substream *substream)
3793 struct alc_spec *spec = codec->spec;
3794 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
3797 static int alc880_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
3798 struct hda_codec *codec,
3799 unsigned int stream_tag,
3800 unsigned int format,
3801 struct snd_pcm_substream *substream)
3803 struct alc_spec *spec = codec->spec;
3804 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
3805 stream_tag, format, substream);
3808 static int alc880_dig_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
3809 struct hda_codec *codec,
3810 struct snd_pcm_substream *substream)
3812 struct alc_spec *spec = codec->spec;
3813 return snd_hda_multi_out_dig_cleanup(codec, &spec->multiout);
3816 static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
3817 struct hda_codec *codec,
3818 struct snd_pcm_substream *substream)
3820 struct alc_spec *spec = codec->spec;