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;
1091 err = alc_add_jack(codec, hp_nid, SND_JACK_HEADPHONE);
1094 alc_report_jack(codec, hp_nid);
1098 err = alc_add_jack(codec, mic_nid, SND_JACK_MICROPHONE);
1101 alc_report_jack(codec, mic_nid);
1107 static inline void alc_report_jack(struct hda_codec *codec, hda_nid_t nid)
1111 static inline int alc_init_jacks(struct hda_codec *codec)
1117 static void alc_automute_speaker(struct hda_codec *codec, int pinctl)
1119 struct alc_spec *spec = codec->spec;
1124 spec->jack_present = 0;
1125 for (i = 0; i < ARRAY_SIZE(spec->autocfg.hp_pins); i++) {
1126 nid = spec->autocfg.hp_pins[i];
1129 if (snd_hda_jack_detect(codec, nid)) {
1130 spec->jack_present = 1;
1133 alc_report_jack(codec, spec->autocfg.hp_pins[i]);
1136 mute = spec->jack_present ? HDA_AMP_MUTE : 0;
1137 /* Toggle internal speakers muting */
1138 for (i = 0; i < ARRAY_SIZE(spec->autocfg.speaker_pins); i++) {
1139 nid = spec->autocfg.speaker_pins[i];
1143 snd_hda_codec_write(codec, nid, 0,
1144 AC_VERB_SET_PIN_WIDGET_CONTROL,
1145 spec->jack_present ? 0 : PIN_OUT);
1147 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
1148 HDA_AMP_MUTE, mute);
1153 static void alc_automute_pin(struct hda_codec *codec)
1155 alc_automute_speaker(codec, 1);
1158 static int get_connection_index(struct hda_codec *codec, hda_nid_t mux,
1161 hda_nid_t conn[HDA_MAX_NUM_INPUTS];
1164 nums = snd_hda_get_connections(codec, mux, conn, ARRAY_SIZE(conn));
1165 for (i = 0; i < nums; i++)
1171 /* switch the current ADC according to the jack state */
1172 static void alc_dual_mic_adc_auto_switch(struct hda_codec *codec)
1174 struct alc_spec *spec = codec->spec;
1175 unsigned int present;
1178 present = snd_hda_jack_detect(codec, spec->ext_mic.pin);
1180 spec->cur_adc_idx = 1;
1182 spec->cur_adc_idx = 0;
1183 new_adc = spec->adc_nids[spec->cur_adc_idx];
1184 if (spec->cur_adc && spec->cur_adc != new_adc) {
1185 /* stream is running, let's swap the current ADC */
1186 __snd_hda_codec_cleanup_stream(codec, spec->cur_adc, 1);
1187 spec->cur_adc = new_adc;
1188 snd_hda_codec_setup_stream(codec, new_adc,
1189 spec->cur_adc_stream_tag, 0,
1190 spec->cur_adc_format);
1194 static void alc_mic_automute(struct hda_codec *codec)
1196 struct alc_spec *spec = codec->spec;
1197 struct alc_mic_route *dead, *alive;
1198 unsigned int present, type;
1201 if (!spec->auto_mic)
1203 if (!spec->int_mic.pin || !spec->ext_mic.pin)
1205 if (snd_BUG_ON(!spec->adc_nids))
1208 if (spec->dual_adc_switch) {
1209 alc_dual_mic_adc_auto_switch(codec);
1213 cap_nid = spec->capsrc_nids ? spec->capsrc_nids[0] : spec->adc_nids[0];
1215 present = snd_hda_jack_detect(codec, spec->ext_mic.pin);
1217 alive = &spec->ext_mic;
1218 dead = &spec->int_mic;
1220 alive = &spec->int_mic;
1221 dead = &spec->ext_mic;
1224 type = get_wcaps_type(get_wcaps(codec, cap_nid));
1225 if (type == AC_WID_AUD_MIX) {
1226 /* Matrix-mixer style (e.g. ALC882) */
1227 snd_hda_codec_amp_stereo(codec, cap_nid, HDA_INPUT,
1230 snd_hda_codec_amp_stereo(codec, cap_nid, HDA_INPUT,
1232 HDA_AMP_MUTE, HDA_AMP_MUTE);
1234 /* MUX style (e.g. ALC880) */
1235 snd_hda_codec_write_cache(codec, cap_nid, 0,
1236 AC_VERB_SET_CONNECT_SEL,
1239 alc_report_jack(codec, spec->ext_mic.pin);
1241 /* FIXME: analog mixer */
1244 /* unsolicited event for HP jack sensing */
1245 static void alc_sku_unsol_event(struct hda_codec *codec, unsigned int res)
1247 if (codec->vendor_id == 0x10ec0880)
1252 case ALC880_HP_EVENT:
1253 alc_automute_pin(codec);
1255 case ALC880_MIC_EVENT:
1256 alc_mic_automute(codec);
1261 static void alc_inithook(struct hda_codec *codec)
1263 alc_automute_pin(codec);
1264 alc_mic_automute(codec);
1267 /* additional initialization for ALC888 variants */
1268 static void alc888_coef_init(struct hda_codec *codec)
1272 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 0);
1273 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
1274 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
1275 if ((tmp & 0xf0) == 0x20)
1277 snd_hda_codec_read(codec, 0x20, 0,
1278 AC_VERB_SET_PROC_COEF, 0x830);
1281 snd_hda_codec_read(codec, 0x20, 0,
1282 AC_VERB_SET_PROC_COEF, 0x3030);
1285 static void alc889_coef_init(struct hda_codec *codec)
1289 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
1290 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
1291 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
1292 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_PROC_COEF, tmp|0x2010);
1295 /* turn on/off EAPD control (only if available) */
1296 static void set_eapd(struct hda_codec *codec, hda_nid_t nid, int on)
1298 if (get_wcaps_type(get_wcaps(codec, nid)) != AC_WID_PIN)
1300 if (snd_hda_query_pin_caps(codec, nid) & AC_PINCAP_EAPD)
1301 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
1305 static void alc_auto_init_amp(struct hda_codec *codec, int type)
1310 case ALC_INIT_GPIO1:
1311 snd_hda_sequence_write(codec, alc_gpio1_init_verbs);
1313 case ALC_INIT_GPIO2:
1314 snd_hda_sequence_write(codec, alc_gpio2_init_verbs);
1316 case ALC_INIT_GPIO3:
1317 snd_hda_sequence_write(codec, alc_gpio3_init_verbs);
1319 case ALC_INIT_DEFAULT:
1320 switch (codec->vendor_id) {
1322 set_eapd(codec, 0x0f, 1);
1323 set_eapd(codec, 0x10, 1);
1336 set_eapd(codec, 0x14, 1);
1337 set_eapd(codec, 0x15, 1);
1340 switch (codec->vendor_id) {
1342 snd_hda_codec_write(codec, 0x1a, 0,
1343 AC_VERB_SET_COEF_INDEX, 7);
1344 tmp = snd_hda_codec_read(codec, 0x1a, 0,
1345 AC_VERB_GET_PROC_COEF, 0);
1346 snd_hda_codec_write(codec, 0x1a, 0,
1347 AC_VERB_SET_COEF_INDEX, 7);
1348 snd_hda_codec_write(codec, 0x1a, 0,
1349 AC_VERB_SET_PROC_COEF,
1359 alc889_coef_init(codec);
1362 alc888_coef_init(codec);
1364 #if 0 /* XXX: This may cause the silent output on speaker on some machines */
1367 snd_hda_codec_write(codec, 0x20, 0,
1368 AC_VERB_SET_COEF_INDEX, 7);
1369 tmp = snd_hda_codec_read(codec, 0x20, 0,
1370 AC_VERB_GET_PROC_COEF, 0);
1371 snd_hda_codec_write(codec, 0x20, 0,
1372 AC_VERB_SET_COEF_INDEX, 7);
1373 snd_hda_codec_write(codec, 0x20, 0,
1374 AC_VERB_SET_PROC_COEF,
1383 static void alc_init_auto_hp(struct hda_codec *codec)
1385 struct alc_spec *spec = codec->spec;
1386 struct auto_pin_cfg *cfg = &spec->autocfg;
1389 if (!cfg->hp_pins[0]) {
1390 if (cfg->line_out_type != AUTO_PIN_HP_OUT)
1394 if (!cfg->speaker_pins[0]) {
1395 if (cfg->line_out_type != AUTO_PIN_SPEAKER_OUT)
1397 memcpy(cfg->speaker_pins, cfg->line_out_pins,
1398 sizeof(cfg->speaker_pins));
1399 cfg->speaker_outs = cfg->line_outs;
1402 if (!cfg->hp_pins[0]) {
1403 memcpy(cfg->hp_pins, cfg->line_out_pins,
1404 sizeof(cfg->hp_pins));
1405 cfg->hp_outs = cfg->line_outs;
1408 for (i = 0; i < cfg->hp_outs; i++) {
1409 snd_printdd("realtek: Enable HP auto-muting on NID 0x%x\n",
1411 snd_hda_codec_write_cache(codec, cfg->hp_pins[i], 0,
1412 AC_VERB_SET_UNSOLICITED_ENABLE,
1413 AC_USRSP_EN | ALC880_HP_EVENT);
1415 spec->unsol_event = alc_sku_unsol_event;
1418 static void alc_init_auto_mic(struct hda_codec *codec)
1420 struct alc_spec *spec = codec->spec;
1421 struct auto_pin_cfg *cfg = &spec->autocfg;
1422 hda_nid_t fixed, ext;
1425 /* there must be only two mic inputs exclusively */
1426 for (i = 0; i < cfg->num_inputs; i++)
1427 if (cfg->inputs[i].type >= AUTO_PIN_LINE_IN)
1431 for (i = 0; i < cfg->num_inputs; i++) {
1432 hda_nid_t nid = cfg->inputs[i].pin;
1433 unsigned int defcfg;
1434 defcfg = snd_hda_codec_get_pincfg(codec, nid);
1435 switch (snd_hda_get_input_pin_attr(defcfg)) {
1436 case INPUT_PIN_ATTR_INT:
1438 return; /* already occupied */
1441 case INPUT_PIN_ATTR_UNUSED:
1442 return; /* invalid entry */
1445 return; /* already occupied */
1452 if (!(get_wcaps(codec, ext) & AC_WCAP_UNSOL_CAP))
1453 return; /* no unsol support */
1454 snd_printdd("realtek: Enable auto-mic switch on NID 0x%x/0x%x\n",
1456 spec->ext_mic.pin = ext;
1457 spec->int_mic.pin = fixed;
1458 spec->ext_mic.mux_idx = MUX_IDX_UNDEF; /* set later */
1459 spec->int_mic.mux_idx = MUX_IDX_UNDEF; /* set later */
1461 snd_hda_codec_write_cache(codec, spec->ext_mic.pin, 0,
1462 AC_VERB_SET_UNSOLICITED_ENABLE,
1463 AC_USRSP_EN | ALC880_MIC_EVENT);
1464 spec->unsol_event = alc_sku_unsol_event;
1467 static int alc_auto_parse_customize_define(struct hda_codec *codec)
1469 unsigned int ass, tmp, i;
1471 struct alc_spec *spec = codec->spec;
1473 spec->cdefine.enable_pcbeep = 1; /* assume always enabled */
1475 ass = codec->subsystem_id & 0xffff;
1476 if (ass != codec->bus->pci->subsystem_device && (ass & 1))
1480 if (codec->vendor_id == 0x10ec0260)
1482 ass = snd_hda_codec_get_pincfg(codec, nid);
1485 printk(KERN_INFO "hda_codec: %s: SKU not ready 0x%08x\n",
1486 codec->chip_name, ass);
1492 for (i = 1; i < 16; i++) {
1496 if (((ass >> 16) & 0xf) != tmp)
1499 spec->cdefine.port_connectivity = ass >> 30;
1500 spec->cdefine.enable_pcbeep = (ass & 0x100000) >> 20;
1501 spec->cdefine.check_sum = (ass >> 16) & 0xf;
1502 spec->cdefine.customization = ass >> 8;
1504 spec->cdefine.sku_cfg = ass;
1505 spec->cdefine.external_amp = (ass & 0x38) >> 3;
1506 spec->cdefine.platform_type = (ass & 0x4) >> 2;
1507 spec->cdefine.swap = (ass & 0x2) >> 1;
1508 spec->cdefine.override = ass & 0x1;
1510 snd_printd("SKU: Nid=0x%x sku_cfg=0x%08x\n",
1511 nid, spec->cdefine.sku_cfg);
1512 snd_printd("SKU: port_connectivity=0x%x\n",
1513 spec->cdefine.port_connectivity);
1514 snd_printd("SKU: enable_pcbeep=0x%x\n", spec->cdefine.enable_pcbeep);
1515 snd_printd("SKU: check_sum=0x%08x\n", spec->cdefine.check_sum);
1516 snd_printd("SKU: customization=0x%08x\n", spec->cdefine.customization);
1517 snd_printd("SKU: external_amp=0x%x\n", spec->cdefine.external_amp);
1518 snd_printd("SKU: platform_type=0x%x\n", spec->cdefine.platform_type);
1519 snd_printd("SKU: swap=0x%x\n", spec->cdefine.swap);
1520 snd_printd("SKU: override=0x%x\n", spec->cdefine.override);
1525 /* check subsystem ID and set up device-specific initialization;
1526 * return 1 if initialized, 0 if invalid SSID
1528 /* 32-bit subsystem ID for BIOS loading in HD Audio codec.
1529 * 31 ~ 16 : Manufacture ID
1531 * 7 ~ 0 : Assembly ID
1532 * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36
1534 static int alc_subsystem_id(struct hda_codec *codec,
1535 hda_nid_t porta, hda_nid_t porte,
1536 hda_nid_t portd, hda_nid_t porti)
1538 unsigned int ass, tmp, i;
1540 struct alc_spec *spec = codec->spec;
1542 ass = codec->subsystem_id & 0xffff;
1543 if ((ass != codec->bus->pci->subsystem_device) && (ass & 1))
1546 /* invalid SSID, check the special NID pin defcfg instead */
1548 * 31~30 : port connectivity
1551 * 19~16 : Check sum (15:1)
1556 if (codec->vendor_id == 0x10ec0260)
1558 ass = snd_hda_codec_get_pincfg(codec, nid);
1559 snd_printd("realtek: No valid SSID, "
1560 "checking pincfg 0x%08x for NID 0x%x\n",
1564 if ((ass >> 30) != 1) /* no physical connection */
1569 for (i = 1; i < 16; i++) {
1573 if (((ass >> 16) & 0xf) != tmp)
1576 snd_printd("realtek: Enabling init ASM_ID=0x%04x CODEC_ID=%08x\n",
1577 ass & 0xffff, codec->vendor_id);
1581 * 2 : 0 --> Desktop, 1 --> Laptop
1582 * 3~5 : External Amplifier control
1585 tmp = (ass & 0x38) >> 3; /* external Amp control */
1588 spec->init_amp = ALC_INIT_GPIO1;
1591 spec->init_amp = ALC_INIT_GPIO2;
1594 spec->init_amp = ALC_INIT_GPIO3;
1597 spec->init_amp = ALC_INIT_DEFAULT;
1601 /* is laptop or Desktop and enable the function "Mute internal speaker
1602 * when the external headphone out jack is plugged"
1604 if (!(ass & 0x8000))
1607 * 10~8 : Jack location
1608 * 12~11: Headphone out -> 00: PortA, 01: PortE, 02: PortD, 03: Resvered
1610 * 15 : 1 --> enable the function "Mute internal speaker
1611 * when the external headphone out jack is plugged"
1613 if (!spec->autocfg.hp_pins[0]) {
1615 tmp = (ass >> 11) & 0x3; /* HP to chassis */
1626 for (i = 0; i < spec->autocfg.line_outs; i++)
1627 if (spec->autocfg.line_out_pins[i] == nid)
1629 spec->autocfg.hp_pins[0] = nid;
1632 alc_init_auto_hp(codec);
1633 alc_init_auto_mic(codec);
1637 static void alc_ssid_check(struct hda_codec *codec,
1638 hda_nid_t porta, hda_nid_t porte,
1639 hda_nid_t portd, hda_nid_t porti)
1641 if (!alc_subsystem_id(codec, porta, porte, portd, porti)) {
1642 struct alc_spec *spec = codec->spec;
1643 snd_printd("realtek: "
1644 "Enable default setup for auto mode as fallback\n");
1645 spec->init_amp = ALC_INIT_DEFAULT;
1646 alc_init_auto_hp(codec);
1647 alc_init_auto_mic(codec);
1652 * Fix-up pin default configurations and add default verbs
1661 const struct alc_pincfg *pins;
1662 const struct hda_verb *verbs;
1665 static void alc_pick_fixup(struct hda_codec *codec,
1666 const struct snd_pci_quirk *quirk,
1667 const struct alc_fixup *fix,
1670 const struct alc_pincfg *cfg;
1672 quirk = snd_pci_quirk_lookup(codec->bus->pci, quirk);
1675 fix += quirk->value;
1677 if (pre_init && cfg) {
1678 #ifdef CONFIG_SND_DEBUG_VERBOSE
1679 snd_printdd(KERN_INFO "hda_codec: %s: Apply pincfg for %s\n",
1680 codec->chip_name, quirk->name);
1682 for (; cfg->nid; cfg++)
1683 snd_hda_codec_set_pincfg(codec, cfg->nid, cfg->val);
1685 if (!pre_init && fix->verbs) {
1686 #ifdef CONFIG_SND_DEBUG_VERBOSE
1687 snd_printdd(KERN_INFO "hda_codec: %s: Apply fix-verbs for %s\n",
1688 codec->chip_name, quirk->name);
1690 add_verb(codec->spec, fix->verbs);
1694 static int alc_read_coef_idx(struct hda_codec *codec,
1695 unsigned int coef_idx)
1698 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX,
1700 val = snd_hda_codec_read(codec, 0x20, 0,
1701 AC_VERB_GET_PROC_COEF, 0);
1705 static void alc_write_coef_idx(struct hda_codec *codec, unsigned int coef_idx,
1706 unsigned int coef_val)
1708 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX,
1710 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_PROC_COEF,
1714 /* set right pin controls for digital I/O */
1715 static void alc_auto_init_digital(struct hda_codec *codec)
1717 struct alc_spec *spec = codec->spec;
1721 for (i = 0; i < spec->autocfg.dig_outs; i++) {
1722 pin = spec->autocfg.dig_out_pins[i];
1724 snd_hda_codec_write(codec, pin, 0,
1725 AC_VERB_SET_PIN_WIDGET_CONTROL,
1729 pin = spec->autocfg.dig_in_pin;
1731 snd_hda_codec_write(codec, pin, 0,
1732 AC_VERB_SET_PIN_WIDGET_CONTROL,
1736 /* parse digital I/Os and set up NIDs in BIOS auto-parse mode */
1737 static void alc_auto_parse_digital(struct hda_codec *codec)
1739 struct alc_spec *spec = codec->spec;
1743 /* support multiple SPDIFs; the secondary is set up as a slave */
1744 for (i = 0; i < spec->autocfg.dig_outs; i++) {
1745 err = snd_hda_get_connections(codec,
1746 spec->autocfg.dig_out_pins[i],
1751 spec->multiout.dig_out_nid = dig_nid;
1752 spec->dig_out_type = spec->autocfg.dig_out_type[0];
1754 spec->multiout.slave_dig_outs = spec->slave_dig_outs;
1755 if (i >= ARRAY_SIZE(spec->slave_dig_outs) - 1)
1757 spec->slave_dig_outs[i - 1] = dig_nid;
1761 if (spec->autocfg.dig_in_pin) {
1763 err = snd_hda_get_connections(codec,
1764 spec->autocfg.dig_in_pin,
1767 spec->dig_in_nid = dig_nid;
1778 static struct hda_verb alc888_4ST_ch2_intel_init[] = {
1779 /* Mic-in jack as mic in */
1780 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1781 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1782 /* Line-in jack as Line in */
1783 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1784 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1785 /* Line-Out as Front */
1786 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
1793 static struct hda_verb alc888_4ST_ch4_intel_init[] = {
1794 /* Mic-in jack as mic in */
1795 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1796 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1797 /* Line-in jack as Surround */
1798 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1799 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1800 /* Line-Out as Front */
1801 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
1808 static struct hda_verb alc888_4ST_ch6_intel_init[] = {
1809 /* Mic-in jack as CLFE */
1810 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1811 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1812 /* Line-in jack as Surround */
1813 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1814 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1815 /* Line-Out as CLFE (workaround because Mic-in is not loud enough) */
1816 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1823 static struct hda_verb alc888_4ST_ch8_intel_init[] = {
1824 /* Mic-in jack as CLFE */
1825 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1826 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1827 /* Line-in jack as Surround */
1828 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1829 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1830 /* Line-Out as Side */
1831 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1835 static struct hda_channel_mode alc888_4ST_8ch_intel_modes[4] = {
1836 { 2, alc888_4ST_ch2_intel_init },
1837 { 4, alc888_4ST_ch4_intel_init },
1838 { 6, alc888_4ST_ch6_intel_init },
1839 { 8, alc888_4ST_ch8_intel_init },
1843 * ALC888 Fujitsu Siemens Amillo xa3530
1846 static struct hda_verb alc888_fujitsu_xa3530_verbs[] = {
1847 /* Front Mic: set to PIN_IN (empty by default) */
1848 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1849 /* Connect Internal HP to Front */
1850 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1851 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1852 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1853 /* Connect Bass HP to Front */
1854 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1855 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1856 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1857 /* Connect Line-Out side jack (SPDIF) to Side */
1858 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1859 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1860 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1861 /* Connect Mic jack to CLFE */
1862 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1863 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1864 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02},
1865 /* Connect Line-in jack to Surround */
1866 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1867 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1868 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
1869 /* Connect HP out jack to Front */
1870 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1871 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1872 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
1873 /* Enable unsolicited event for HP jack and Line-out jack */
1874 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1875 {0x17, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1879 static void alc_automute_amp(struct hda_codec *codec)
1881 alc_automute_speaker(codec, 0);
1884 static void alc_automute_amp_unsol_event(struct hda_codec *codec,
1887 if (codec->vendor_id == 0x10ec0880)
1891 if (res == ALC880_HP_EVENT)
1892 alc_automute_amp(codec);
1895 static void alc889_automute_setup(struct hda_codec *codec)
1897 struct alc_spec *spec = codec->spec;
1899 spec->autocfg.hp_pins[0] = 0x15;
1900 spec->autocfg.speaker_pins[0] = 0x14;
1901 spec->autocfg.speaker_pins[1] = 0x16;
1902 spec->autocfg.speaker_pins[2] = 0x17;
1903 spec->autocfg.speaker_pins[3] = 0x19;
1904 spec->autocfg.speaker_pins[4] = 0x1a;
1907 static void alc889_intel_init_hook(struct hda_codec *codec)
1909 alc889_coef_init(codec);
1910 alc_automute_amp(codec);
1913 static void alc888_fujitsu_xa3530_setup(struct hda_codec *codec)
1915 struct alc_spec *spec = codec->spec;
1917 spec->autocfg.hp_pins[0] = 0x17; /* line-out */
1918 spec->autocfg.hp_pins[1] = 0x1b; /* hp */
1919 spec->autocfg.speaker_pins[0] = 0x14; /* speaker */
1920 spec->autocfg.speaker_pins[1] = 0x15; /* bass */
1924 * ALC888 Acer Aspire 4930G model
1927 static struct hda_verb alc888_acer_aspire_4930g_verbs[] = {
1928 /* Front Mic: set to PIN_IN (empty by default) */
1929 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1930 /* Unselect Front Mic by default in input mixer 3 */
1931 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
1932 /* Enable unsolicited event for HP jack */
1933 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1934 /* Connect Internal HP to front */
1935 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1936 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1937 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1938 /* Connect HP out to front */
1939 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1940 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1941 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1946 * ALC888 Acer Aspire 6530G model
1949 static struct hda_verb alc888_acer_aspire_6530g_verbs[] = {
1950 /* Route to built-in subwoofer as well as speakers */
1951 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1952 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1953 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1954 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1955 /* Bias voltage on for external mic port */
1956 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN | PIN_VREF80},
1957 /* Front Mic: set to PIN_IN (empty by default) */
1958 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1959 /* Unselect Front Mic by default in input mixer 3 */
1960 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
1961 /* Enable unsolicited event for HP jack */
1962 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1963 /* Enable speaker output */
1964 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1965 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1966 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
1967 /* Enable headphone output */
1968 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | PIN_HP},
1969 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1970 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1971 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
1976 * ALC889 Acer Aspire 8930G model
1979 static struct hda_verb alc889_acer_aspire_8930g_verbs[] = {
1980 /* Front Mic: set to PIN_IN (empty by default) */
1981 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1982 /* Unselect Front Mic by default in input mixer 3 */
1983 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
1984 /* Enable unsolicited event for HP jack */
1985 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1986 /* Connect Internal Front to Front */
1987 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1988 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1989 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1990 /* Connect Internal Rear to Rear */
1991 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1992 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1993 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01},
1994 /* Connect Internal CLFE to CLFE */
1995 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1996 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1997 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
1998 /* Connect HP out to Front */
1999 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | PIN_HP},
2000 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2001 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
2002 /* Enable all DACs */
2003 /* DAC DISABLE/MUTE 1? */
2004 /* setting bits 1-5 disables DAC nids 0x02-0x06 apparently. Init=0x38 */
2005 {0x20, AC_VERB_SET_COEF_INDEX, 0x03},
2006 {0x20, AC_VERB_SET_PROC_COEF, 0x0000},
2007 /* DAC DISABLE/MUTE 2? */
2008 /* some bit here disables the other DACs. Init=0x4900 */
2009 {0x20, AC_VERB_SET_COEF_INDEX, 0x08},
2010 {0x20, AC_VERB_SET_PROC_COEF, 0x0000},
2012 * This laptop has a stereo digital microphone. The mics are only 1cm apart
2013 * which makes the stereo useless. However, either the mic or the ALC889
2014 * makes the signal become a difference/sum signal instead of standard
2015 * stereo, which is annoying. So instead we flip this bit which makes the
2016 * codec replicate the sum signal to both channels, turning it into a
2019 /* DMIC_CONTROL? Init value = 0x0001 */
2020 {0x20, AC_VERB_SET_COEF_INDEX, 0x0b},
2021 {0x20, AC_VERB_SET_PROC_COEF, 0x0003},
2025 static struct hda_input_mux alc888_2_capture_sources[2] = {
2026 /* Front mic only available on one ADC */
2033 { "Front Mic", 0xb },
2046 static struct hda_input_mux alc888_acer_aspire_6530_sources[2] = {
2047 /* Interal mic only available on one ADC */
2054 { "Input Mix", 0xa },
2064 { "Input Mix", 0xa },
2069 static struct hda_input_mux alc889_capture_sources[3] = {
2070 /* Digital mic only available on first "ADC" */
2077 { "Front Mic", 0xb },
2078 { "Input Mix", 0xa },
2087 { "Input Mix", 0xa },
2096 { "Input Mix", 0xa },
2101 static struct snd_kcontrol_new alc888_base_mixer[] = {
2102 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2103 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2104 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2105 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
2106 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
2108 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2109 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2110 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2111 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
2112 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
2113 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2114 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2115 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2116 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2117 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2118 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
2119 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2123 static struct snd_kcontrol_new alc889_acer_aspire_8930g_mixer[] = {
2124 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2125 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2126 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2127 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
2128 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
2130 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2131 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2132 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2133 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2134 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2135 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2136 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
2137 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2142 static void alc888_acer_aspire_4930g_setup(struct hda_codec *codec)
2144 struct alc_spec *spec = codec->spec;
2146 spec->autocfg.hp_pins[0] = 0x15;
2147 spec->autocfg.speaker_pins[0] = 0x14;
2148 spec->autocfg.speaker_pins[1] = 0x16;
2149 spec->autocfg.speaker_pins[2] = 0x17;
2152 static void alc888_acer_aspire_6530g_setup(struct hda_codec *codec)
2154 struct alc_spec *spec = codec->spec;
2156 spec->autocfg.hp_pins[0] = 0x15;
2157 spec->autocfg.speaker_pins[0] = 0x14;
2158 spec->autocfg.speaker_pins[1] = 0x16;
2159 spec->autocfg.speaker_pins[2] = 0x17;
2162 static void alc889_acer_aspire_8930g_setup(struct hda_codec *codec)
2164 struct alc_spec *spec = codec->spec;
2166 spec->autocfg.hp_pins[0] = 0x15;
2167 spec->autocfg.speaker_pins[0] = 0x14;
2168 spec->autocfg.speaker_pins[1] = 0x16;
2169 spec->autocfg.speaker_pins[2] = 0x1b;
2173 * ALC880 3-stack model
2175 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
2176 * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18,
2177 * F-Mic = 0x1b, HP = 0x19
2180 static hda_nid_t alc880_dac_nids[4] = {
2181 /* front, rear, clfe, rear_surr */
2182 0x02, 0x05, 0x04, 0x03
2185 static hda_nid_t alc880_adc_nids[3] = {
2190 /* The datasheet says the node 0x07 is connected from inputs,
2191 * but it shows zero connection in the real implementation on some devices.
2192 * Note: this is a 915GAV bug, fixed on 915GLV
2194 static hda_nid_t alc880_adc_nids_alt[2] = {
2199 #define ALC880_DIGOUT_NID 0x06
2200 #define ALC880_DIGIN_NID 0x0a
2202 static struct hda_input_mux alc880_capture_source = {
2206 { "Front Mic", 0x3 },
2212 /* channel source setting (2/6 channel selection for 3-stack) */
2214 static struct hda_verb alc880_threestack_ch2_init[] = {
2215 /* set line-in to input, mute it */
2216 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
2217 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
2218 /* set mic-in to input vref 80%, mute it */
2219 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
2220 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
2225 static struct hda_verb alc880_threestack_ch6_init[] = {
2226 /* set line-in to output, unmute it */
2227 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
2228 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
2229 /* set mic-in to output, unmute it */
2230 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
2231 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
2235 static struct hda_channel_mode alc880_threestack_modes[2] = {
2236 { 2, alc880_threestack_ch2_init },
2237 { 6, alc880_threestack_ch6_init },
2240 static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
2241 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2242 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2243 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
2244 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
2245 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2246 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2247 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2248 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2249 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2250 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2251 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2252 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2253 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2254 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2255 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
2256 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
2257 HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
2259 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2260 .name = "Channel Mode",
2261 .info = alc_ch_mode_info,
2262 .get = alc_ch_mode_get,
2263 .put = alc_ch_mode_put,
2268 /* capture mixer elements */
2269 static int alc_cap_vol_info(struct snd_kcontrol *kcontrol,
2270 struct snd_ctl_elem_info *uinfo)
2272 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2273 struct alc_spec *spec = codec->spec;
2276 mutex_lock(&codec->control_mutex);
2277 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0,
2279 err = snd_hda_mixer_amp_volume_info(kcontrol, uinfo);
2280 mutex_unlock(&codec->control_mutex);
2284 static int alc_cap_vol_tlv(struct snd_kcontrol *kcontrol, int op_flag,
2285 unsigned int size, unsigned int __user *tlv)
2287 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2288 struct alc_spec *spec = codec->spec;
2291 mutex_lock(&codec->control_mutex);
2292 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0,
2294 err = snd_hda_mixer_amp_tlv(kcontrol, op_flag, size, tlv);
2295 mutex_unlock(&codec->control_mutex);
2299 typedef int (*getput_call_t)(struct snd_kcontrol *kcontrol,
2300 struct snd_ctl_elem_value *ucontrol);
2302 static int alc_cap_getput_caller(struct snd_kcontrol *kcontrol,
2303 struct snd_ctl_elem_value *ucontrol,
2306 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2307 struct alc_spec *spec = codec->spec;
2308 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
2311 mutex_lock(&codec->control_mutex);
2312 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[adc_idx],
2314 err = func(kcontrol, ucontrol);
2315 mutex_unlock(&codec->control_mutex);
2319 static int alc_cap_vol_get(struct snd_kcontrol *kcontrol,
2320 struct snd_ctl_elem_value *ucontrol)
2322 return alc_cap_getput_caller(kcontrol, ucontrol,
2323 snd_hda_mixer_amp_volume_get);
2326 static int alc_cap_vol_put(struct snd_kcontrol *kcontrol,
2327 struct snd_ctl_elem_value *ucontrol)
2329 return alc_cap_getput_caller(kcontrol, ucontrol,
2330 snd_hda_mixer_amp_volume_put);
2333 /* capture mixer elements */
2334 #define alc_cap_sw_info snd_ctl_boolean_stereo_info
2336 static int alc_cap_sw_get(struct snd_kcontrol *kcontrol,
2337 struct snd_ctl_elem_value *ucontrol)
2339 return alc_cap_getput_caller(kcontrol, ucontrol,
2340 snd_hda_mixer_amp_switch_get);
2343 static int alc_cap_sw_put(struct snd_kcontrol *kcontrol,
2344 struct snd_ctl_elem_value *ucontrol)
2346 return alc_cap_getput_caller(kcontrol, ucontrol,
2347 snd_hda_mixer_amp_switch_put);
2350 #define _DEFINE_CAPMIX(num) \
2352 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2353 .name = "Capture Switch", \
2354 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, \
2356 .info = alc_cap_sw_info, \
2357 .get = alc_cap_sw_get, \
2358 .put = alc_cap_sw_put, \
2361 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2362 .name = "Capture Volume", \
2363 .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE | \
2364 SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
2365 SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK), \
2367 .info = alc_cap_vol_info, \
2368 .get = alc_cap_vol_get, \
2369 .put = alc_cap_vol_put, \
2370 .tlv = { .c = alc_cap_vol_tlv }, \
2373 #define _DEFINE_CAPSRC(num) \
2375 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2376 /* .name = "Capture Source", */ \
2377 .name = "Input Source", \
2379 .info = alc_mux_enum_info, \
2380 .get = alc_mux_enum_get, \
2381 .put = alc_mux_enum_put, \
2384 #define DEFINE_CAPMIX(num) \
2385 static struct snd_kcontrol_new alc_capture_mixer ## num[] = { \
2386 _DEFINE_CAPMIX(num), \
2387 _DEFINE_CAPSRC(num), \
2391 #define DEFINE_CAPMIX_NOSRC(num) \
2392 static struct snd_kcontrol_new alc_capture_mixer_nosrc ## num[] = { \
2393 _DEFINE_CAPMIX(num), \
2397 /* up to three ADCs */
2401 DEFINE_CAPMIX_NOSRC(1);
2402 DEFINE_CAPMIX_NOSRC(2);
2403 DEFINE_CAPMIX_NOSRC(3);
2406 * ALC880 5-stack model
2408 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d),
2410 * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
2411 * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
2414 /* additional mixers to alc880_three_stack_mixer */
2415 static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
2416 HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2417 HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
2421 /* channel source setting (6/8 channel selection for 5-stack) */
2423 static struct hda_verb alc880_fivestack_ch6_init[] = {
2424 /* set line-in to input, mute it */
2425 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
2426 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
2431 static struct hda_verb alc880_fivestack_ch8_init[] = {
2432 /* set line-in to output, unmute it */
2433 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
2434 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
2438 static struct hda_channel_mode alc880_fivestack_modes[2] = {
2439 { 6, alc880_fivestack_ch6_init },
2440 { 8, alc880_fivestack_ch8_init },
2445 * ALC880 6-stack model
2447 * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e),
2448 * Side = 0x05 (0x0f)
2449 * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
2450 * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
2453 static hda_nid_t alc880_6st_dac_nids[4] = {
2454 /* front, rear, clfe, rear_surr */
2455 0x02, 0x03, 0x04, 0x05
2458 static struct hda_input_mux alc880_6stack_capture_source = {
2462 { "Front Mic", 0x1 },
2468 /* fixed 8-channels */
2469 static struct hda_channel_mode alc880_sixstack_modes[1] = {
2473 static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
2474 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2475 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2476 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2477 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
2478 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2479 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2480 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2481 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2482 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
2483 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
2484 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2485 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2486 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2487 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2488 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2489 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2490 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2491 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
2493 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2494 .name = "Channel Mode",
2495 .info = alc_ch_mode_info,
2496 .get = alc_ch_mode_get,
2497 .put = alc_ch_mode_put,
2506 * W810 has rear IO for:
2509 * Center/LFE (DAC 04)
2512 * The system also has a pair of internal speakers, and a headphone jack.
2513 * These are both connected to Line2 on the codec, hence to DAC 02.
2515 * There is a variable resistor to control the speaker or headphone
2516 * volume. This is a hardware-only device without a software API.
2518 * Plugging headphones in will disable the internal speakers. This is
2519 * implemented in hardware, not via the driver using jack sense. In
2520 * a similar fashion, plugging into the rear socket marked "front" will
2521 * disable both the speakers and headphones.
2523 * For input, there's a microphone jack, and an "audio in" jack.
2524 * These may not do anything useful with this driver yet, because I
2525 * haven't setup any initialization verbs for these yet...
2528 static hda_nid_t alc880_w810_dac_nids[3] = {
2529 /* front, rear/surround, clfe */
2533 /* fixed 6 channels */
2534 static struct hda_channel_mode alc880_w810_modes[1] = {
2538 /* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
2539 static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
2540 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2541 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2542 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2543 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
2544 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2545 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2546 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2547 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2548 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
2556 * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
2557 * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?),
2561 static hda_nid_t alc880_z71v_dac_nids[1] = {
2564 #define ALC880_Z71V_HP_DAC 0x03
2566 /* fixed 2 channels */
2567 static struct hda_channel_mode alc880_2_jack_modes[1] = {
2571 static struct snd_kcontrol_new alc880_z71v_mixer[] = {
2572 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2573 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2574 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2575 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
2576 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2577 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2578 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2579 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2585 * ALC880 F1734 model
2587 * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
2588 * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
2591 static hda_nid_t alc880_f1734_dac_nids[1] = {
2594 #define ALC880_F1734_HP_DAC 0x02
2596 static struct snd_kcontrol_new alc880_f1734_mixer[] = {
2597 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2598 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2599 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2600 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
2601 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2602 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2603 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2604 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
2608 static struct hda_input_mux alc880_f1734_capture_source = {
2620 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
2621 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
2622 * Mic = 0x18, Line = 0x1a
2625 #define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
2626 #define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
2628 static struct snd_kcontrol_new alc880_asus_mixer[] = {
2629 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2630 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2631 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2632 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
2633 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2634 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2635 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2636 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2637 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2638 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2639 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2640 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2641 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2642 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2644 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2645 .name = "Channel Mode",
2646 .info = alc_ch_mode_info,
2647 .get = alc_ch_mode_get,
2648 .put = alc_ch_mode_put,
2654 * ALC880 ASUS W1V model
2656 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
2657 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
2658 * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
2661 /* additional mixers to alc880_asus_mixer */
2662 static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
2663 HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
2664 HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
2669 static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
2670 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2671 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
2672 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
2673 HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
2674 HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
2675 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
2676 HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
2677 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
2678 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
2683 static struct snd_kcontrol_new alc880_uniwill_mixer[] = {
2684 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2685 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2686 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2687 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
2688 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2689 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2690 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2691 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2692 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2693 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2694 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2695 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2696 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2697 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2698 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2699 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
2701 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2702 .name = "Channel Mode",
2703 .info = alc_ch_mode_info,
2704 .get = alc_ch_mode_get,
2705 .put = alc_ch_mode_put,
2710 static struct snd_kcontrol_new alc880_fujitsu_mixer[] = {
2711 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2712 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2713 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2714 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
2715 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2716 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2717 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2718 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2719 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2720 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
2724 static struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = {
2725 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2726 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2727 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2728 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
2729 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2730 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2735 * virtual master controls
2739 * slave controls for virtual master
2741 static const char *alc_slave_vols[] = {
2742 "Front Playback Volume",
2743 "Surround Playback Volume",
2744 "Center Playback Volume",
2745 "LFE Playback Volume",
2746 "Side Playback Volume",
2747 "Headphone Playback Volume",
2748 "Speaker Playback Volume",
2749 "Mono Playback Volume",
2750 "Line-Out Playback Volume",
2751 "PCM Playback Volume",
2755 static const char *alc_slave_sws[] = {
2756 "Front Playback Switch",
2757 "Surround Playback Switch",
2758 "Center Playback Switch",
2759 "LFE Playback Switch",
2760 "Side Playback Switch",
2761 "Headphone Playback Switch",
2762 "Speaker Playback Switch",
2763 "Mono Playback Switch",
2764 "IEC958 Playback Switch",
2765 "Line-Out Playback Switch",
2766 "PCM Playback Switch",
2771 * build control elements
2774 #define NID_MAPPING (-1)
2776 #define SUBDEV_SPEAKER_ (0 << 6)
2777 #define SUBDEV_HP_ (1 << 6)
2778 #define SUBDEV_LINE_ (2 << 6)
2779 #define SUBDEV_SPEAKER(x) (SUBDEV_SPEAKER_ | ((x) & 0x3f))
2780 #define SUBDEV_HP(x) (SUBDEV_HP_ | ((x) & 0x3f))
2781 #define SUBDEV_LINE(x) (SUBDEV_LINE_ | ((x) & 0x3f))
2783 static void alc_free_kctls(struct hda_codec *codec);
2785 #ifdef CONFIG_SND_HDA_INPUT_BEEP
2786 /* additional beep mixers; the actual parameters are overwritten at build */
2787 static struct snd_kcontrol_new alc_beep_mixer[] = {
2788 HDA_CODEC_VOLUME("Beep Playback Volume", 0, 0, HDA_INPUT),
2789 HDA_CODEC_MUTE_BEEP("Beep Playback Switch", 0, 0, HDA_INPUT),
2794 static int alc_build_controls(struct hda_codec *codec)
2796 struct alc_spec *spec = codec->spec;
2797 struct snd_kcontrol *kctl = NULL;
2798 struct snd_kcontrol_new *knew;
2803 for (i = 0; i < spec->num_mixers; i++) {
2804 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
2808 if (spec->cap_mixer) {
2809 err = snd_hda_add_new_ctls(codec, spec->cap_mixer);
2813 if (spec->multiout.dig_out_nid) {
2814 err = snd_hda_create_spdif_out_ctls(codec,
2815 spec->multiout.dig_out_nid);
2818 if (!spec->no_analog) {
2819 err = snd_hda_create_spdif_share_sw(codec,
2823 spec->multiout.share_spdif = 1;
2826 if (spec->dig_in_nid) {
2827 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
2832 #ifdef CONFIG_SND_HDA_INPUT_BEEP
2833 /* create beep controls if needed */
2834 if (spec->beep_amp) {
2835 struct snd_kcontrol_new *knew;
2836 for (knew = alc_beep_mixer; knew->name; knew++) {
2837 struct snd_kcontrol *kctl;
2838 kctl = snd_ctl_new1(knew, codec);
2841 kctl->private_value = spec->beep_amp;
2842 err = snd_hda_ctl_add(codec, 0, kctl);
2849 /* if we have no master control, let's create it */
2850 if (!spec->no_analog &&
2851 !snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
2852 unsigned int vmaster_tlv[4];
2853 snd_hda_set_vmaster_tlv(codec, spec->vmaster_nid,
2854 HDA_OUTPUT, vmaster_tlv);
2855 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
2856 vmaster_tlv, alc_slave_vols);
2860 if (!spec->no_analog &&
2861 !snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
2862 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
2863 NULL, alc_slave_sws);
2868 /* assign Capture Source enums to NID */
2869 if (spec->capsrc_nids || spec->adc_nids) {
2870 kctl = snd_hda_find_mixer_ctl(codec, "Capture Source");
2872 kctl = snd_hda_find_mixer_ctl(codec, "Input Source");
2873 for (i = 0; kctl && i < kctl->count; i++) {
2874 hda_nid_t *nids = spec->capsrc_nids;
2876 nids = spec->adc_nids;
2877 err = snd_hda_add_nid(codec, kctl, i, nids[i]);
2882 if (spec->cap_mixer) {
2883 const char *kname = kctl ? kctl->id.name : NULL;
2884 for (knew = spec->cap_mixer; knew->name; knew++) {
2885 if (kname && strcmp(knew->name, kname) == 0)
2887 kctl = snd_hda_find_mixer_ctl(codec, knew->name);
2888 for (i = 0; kctl && i < kctl->count; i++) {
2889 err = snd_hda_add_nid(codec, kctl, i,
2897 /* other nid->control mapping */
2898 for (i = 0; i < spec->num_mixers; i++) {
2899 for (knew = spec->mixers[i]; knew->name; knew++) {
2900 if (knew->iface != NID_MAPPING)
2902 kctl = snd_hda_find_mixer_ctl(codec, knew->name);
2905 u = knew->subdevice;
2906 for (j = 0; j < 4; j++, u >>= 8) {
2911 case SUBDEV_SPEAKER_:
2912 nid = spec->autocfg.speaker_pins[nid];
2915 nid = spec->autocfg.line_out_pins[nid];
2918 nid = spec->autocfg.hp_pins[nid];
2923 err = snd_hda_add_nid(codec, kctl, 0, nid);
2927 u = knew->private_value;
2928 for (j = 0; j < 4; j++, u >>= 8) {
2932 err = snd_hda_add_nid(codec, kctl, 0, nid);
2939 alc_free_kctls(codec); /* no longer needed */
2946 * initialize the codec volumes, etc
2950 * generic initialization of ADC, input mixers and output mixers
2952 static struct hda_verb alc880_volume_init_verbs[] = {
2954 * Unmute ADC0-2 and set the default input to mic-in
2956 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
2957 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2958 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
2959 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2960 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
2961 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2963 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
2965 * Note: PASD motherboards uses the Line In 2 as the input for front
2968 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
2969 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2970 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2971 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
2972 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
2973 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
2974 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
2975 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
2978 * Set up output mixers (0x0c - 0x0f)
2980 /* set vol=0 to output mixers */
2981 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2982 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2983 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2984 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2985 /* set up input amps for analog loopback */
2986 /* Amp Indices: DAC = 0, mixer = 1 */
2987 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2988 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2989 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2990 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2991 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2992 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2993 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2994 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3000 * 3-stack pin configuration:
3001 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
3003 static struct hda_verb alc880_pin_3stack_init_verbs[] = {
3005 * preset connection lists of input pins
3006 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
3008 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
3009 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3010 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
3013 * Set pin mode and muting
3015 /* set front pin widgets 0x14 for output */
3016 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3017 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3018 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3019 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3020 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3021 /* Mic2 (as headphone out) for HP output */
3022 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3023 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3024 /* Line In pin widget for input */
3025 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3026 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3027 /* Line2 (as front mic) pin widget for input and vref at 80% */
3028 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3029 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3030 /* CD pin widget for input */
3031 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3037 * 5-stack pin configuration:
3038 * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
3039 * line-in/side = 0x1a, f-mic = 0x1b
3041 static struct hda_verb alc880_pin_5stack_init_verbs[] = {
3043 * preset connection lists of input pins
3044 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
3046 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3047 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
3050 * Set pin mode and muting
3052 /* set pin widgets 0x14-0x17 for output */
3053 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3054 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3055 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3056 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3057 /* unmute pins for output (no gain on this amp) */
3058 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3059 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3060 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3061 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3063 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3064 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3065 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3066 /* Mic2 (as headphone out) for HP output */
3067 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3068 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3069 /* Line In pin widget for input */
3070 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3071 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3072 /* Line2 (as front mic) pin widget for input and vref at 80% */
3073 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3074 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3075 /* CD pin widget for input */
3076 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3082 * W810 pin configuration:
3083 * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
3085 static struct hda_verb alc880_pin_w810_init_verbs[] = {
3086 /* hphone/speaker input selector: front DAC */
3087 {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
3089 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3090 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3091 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3092 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3093 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3094 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3096 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3097 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3103 * Z71V pin configuration:
3104 * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
3106 static struct hda_verb alc880_pin_z71v_init_verbs[] = {
3107 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3108 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3109 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3110 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3112 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3113 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3114 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3115 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3121 * 6-stack pin configuration:
3122 * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18,
3123 * f-mic = 0x19, line = 0x1a, HP = 0x1b
3125 static struct hda_verb alc880_pin_6stack_init_verbs[] = {
3126 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3128 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3129 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3130 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3131 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3132 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3133 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3134 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3135 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3137 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3138 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3139 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3140 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3141 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3142 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3143 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3144 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3145 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3151 * Uniwill pin configuration:
3152 * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19,
3155 static struct hda_verb alc880_uniwill_init_verbs[] = {
3156 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3158 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3159 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3160 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3161 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3162 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3163 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3164 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3165 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3166 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3167 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3168 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3169 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3170 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3171 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3173 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3174 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3175 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3176 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3177 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3178 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3179 /* {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, */
3180 /* {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
3181 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3183 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
3184 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
3191 * HP = 0x14, InternalSpeaker = 0x15, mic = 0x19,
3193 static struct hda_verb alc880_uniwill_p53_init_verbs[] = {
3194 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3196 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3197 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3198 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3199 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3200 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3201 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3202 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3203 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3204 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3205 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3206 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3207 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3209 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3210 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3211 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3212 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3213 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3214 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3216 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
3217 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_DCVOL_EVENT},
3222 static struct hda_verb alc880_beep_init_verbs[] = {
3223 { 0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5) },
3227 /* auto-toggle front mic */
3228 static void alc880_uniwill_mic_automute(struct hda_codec *codec)
3230 unsigned int present;
3233 present = snd_hda_jack_detect(codec, 0x18);
3234 bits = present ? HDA_AMP_MUTE : 0;
3235 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
3238 static void alc880_uniwill_setup(struct hda_codec *codec)
3240 struct alc_spec *spec = codec->spec;
3242 spec->autocfg.hp_pins[0] = 0x14;
3243 spec->autocfg.speaker_pins[0] = 0x15;
3244 spec->autocfg.speaker_pins[0] = 0x16;
3247 static void alc880_uniwill_init_hook(struct hda_codec *codec)
3249 alc_automute_amp(codec);
3250 alc880_uniwill_mic_automute(codec);
3253 static void alc880_uniwill_unsol_event(struct hda_codec *codec,
3256 /* Looks like the unsol event is incompatible with the standard
3257 * definition. 4bit tag is placed at 28 bit!
3259 switch (res >> 28) {
3260 case ALC880_MIC_EVENT:
3261 alc880_uniwill_mic_automute(codec);
3264 alc_automute_amp_unsol_event(codec, res);
3269 static void alc880_uniwill_p53_setup(struct hda_codec *codec)
3271 struct alc_spec *spec = codec->spec;
3273 spec->autocfg.hp_pins[0] = 0x14;
3274 spec->autocfg.speaker_pins[0] = 0x15;
3277 static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec)
3279 unsigned int present;
3281 present = snd_hda_codec_read(codec, 0x21, 0,
3282 AC_VERB_GET_VOLUME_KNOB_CONTROL, 0);
3283 present &= HDA_AMP_VOLMASK;
3284 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0,
3285 HDA_AMP_VOLMASK, present);
3286 snd_hda_codec_amp_stereo(codec, 0x0d, HDA_OUTPUT, 0,
3287 HDA_AMP_VOLMASK, present);
3290 static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec,
3293 /* Looks like the unsol event is incompatible with the standard
3294 * definition. 4bit tag is placed at 28 bit!
3296 if ((res >> 28) == ALC880_DCVOL_EVENT)
3297 alc880_uniwill_p53_dcvol_automute(codec);
3299 alc_automute_amp_unsol_event(codec, res);
3303 * F1734 pin configuration:
3304 * HP = 0x14, speaker-out = 0x15, mic = 0x18
3306 static struct hda_verb alc880_pin_f1734_init_verbs[] = {
3307 {0x07, AC_VERB_SET_CONNECT_SEL, 0x01},
3308 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
3309 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
3310 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
3311 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
3313 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3314 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3315 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3316 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3318 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3319 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3320 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
3321 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3322 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3323 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3324 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3325 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3326 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3328 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
3329 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_DCVOL_EVENT},
3335 * ASUS pin configuration:
3336 * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
3338 static struct hda_verb alc880_pin_asus_init_verbs[] = {
3339 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
3340 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
3341 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
3342 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
3344 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3345 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3346 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3347 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3348 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3349 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3350 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3351 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3353 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3354 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3355 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3356 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3357 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3358 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3359 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3360 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3361 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3366 /* Enable GPIO mask and set output */
3367 #define alc880_gpio1_init_verbs alc_gpio1_init_verbs
3368 #define alc880_gpio2_init_verbs alc_gpio2_init_verbs
3369 #define alc880_gpio3_init_verbs alc_gpio3_init_verbs
3371 /* Clevo m520g init */
3372 static struct hda_verb alc880_pin_clevo_init_verbs[] = {
3373 /* headphone output */
3374 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
3376 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3377 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3379 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3380 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3382 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3383 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3384 /* Mic1 (rear panel) */
3385 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3386 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3387 /* Mic2 (front panel) */
3388 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3389 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3391 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3392 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3393 /* change to EAPD mode */
3394 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
3395 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
3400 static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
3401 /* change to EAPD mode */
3402 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
3403 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
3405 /* Headphone output */
3406 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3408 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3409 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
3411 /* Line In pin widget for input */
3412 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3413 /* CD pin widget for input */
3414 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3415 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3416 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3418 /* change to EAPD mode */
3419 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
3420 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
3426 * LG m1 express dual
3429 * Rear Line-In/Out (blue): 0x14
3430 * Build-in Mic-In: 0x15
3432 * HP-Out (green): 0x1b
3433 * Mic-In/Out (red): 0x19
3437 /* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
3438 static hda_nid_t alc880_lg_dac_nids[3] = {
3442 /* seems analog CD is not working */
3443 static struct hda_input_mux alc880_lg_capture_source = {
3448 { "Internal Mic", 0x6 },
3452 /* 2,4,6 channel modes */
3453 static struct hda_verb alc880_lg_ch2_init[] = {
3454 /* set line-in and mic-in to input */
3455 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
3456 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
3460 static struct hda_verb alc880_lg_ch4_init[] = {
3461 /* set line-in to out and mic-in to input */
3462 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
3463 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
3467 static struct hda_verb alc880_lg_ch6_init[] = {
3468 /* set line-in and mic-in to output */
3469 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
3470 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
3474 static struct hda_channel_mode alc880_lg_ch_modes[3] = {
3475 { 2, alc880_lg_ch2_init },
3476 { 4, alc880_lg_ch4_init },
3477 { 6, alc880_lg_ch6_init },
3480 static struct snd_kcontrol_new alc880_lg_mixer[] = {
3481 HDA_CODEC_VOLUME("Front Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
3482 HDA_BIND_MUTE("Front Playback Switch", 0x0f, 2, HDA_INPUT),
3483 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3484 HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
3485 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
3486 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
3487 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
3488 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
3489 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
3490 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
3491 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
3492 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
3493 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
3494 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
3496 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3497 .name = "Channel Mode",
3498 .info = alc_ch_mode_info,
3499 .get = alc_ch_mode_get,
3500 .put = alc_ch_mode_put,
3505 static struct hda_verb alc880_lg_init_verbs[] = {
3506 /* set capture source to mic-in */
3507 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3508 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3509 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3510 /* mute all amp mixer inputs */
3511 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
3512 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
3513 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
3514 /* line-in to input */
3515 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3516 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3518 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3519 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3521 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3522 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3523 /* mic-in to input */
3524 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
3525 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3526 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3528 {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
3529 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3530 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3532 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
3536 /* toggle speaker-output according to the hp-jack state */
3537 static void alc880_lg_setup(struct hda_codec *codec)
3539 struct alc_spec *spec = codec->spec;
3541 spec->autocfg.hp_pins[0] = 0x1b;
3542 spec->autocfg.speaker_pins[0] = 0x17;
3551 * Built-in Mic-In: 0x19
3557 static struct hda_input_mux alc880_lg_lw_capture_source = {
3561 { "Internal Mic", 0x1 },
3566 #define alc880_lg_lw_modes alc880_threestack_modes
3568 static struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
3569 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3570 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
3571 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
3572 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
3573 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
3574 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
3575 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
3576 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
3577 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
3578 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
3579 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
3580 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
3581 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
3582 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
3584 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3585 .name = "Channel Mode",
3586 .info = alc_ch_mode_info,
3587 .get = alc_ch_mode_get,
3588 .put = alc_ch_mode_put,
3593 static struct hda_verb alc880_lg_lw_init_verbs[] = {
3594 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3595 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
3596 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
3598 /* set capture source to mic-in */
3599 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3600 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3601 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3602 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
3604 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3605 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3607 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3608 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3609 /* mic-in to input */
3610 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3611 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3613 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3614 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3616 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
3620 /* toggle speaker-output according to the hp-jack state */
3621 static void alc880_lg_lw_setup(struct hda_codec *codec)
3623 struct alc_spec *spec = codec->spec;
3625 spec->autocfg.hp_pins[0] = 0x1b;
3626 spec->autocfg.speaker_pins[0] = 0x14;
3629 static struct snd_kcontrol_new alc880_medion_rim_mixer[] = {
3630 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3631 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
3632 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
3633 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
3634 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
3635 HDA_CODEC_MUTE("Internal Playback Switch", 0x0b, 0x1, HDA_INPUT),
3639 static struct hda_input_mux alc880_medion_rim_capture_source = {
3643 { "Internal Mic", 0x1 },
3647 static struct hda_verb alc880_medion_rim_init_verbs[] = {
3648 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3650 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3651 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3653 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3654 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3655 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3656 /* Mic2 (as headphone out) for HP output */
3657 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3658 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3659 /* Internal Speaker */
3660 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3661 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3663 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
3664 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
3666 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
3670 /* toggle speaker-output according to the hp-jack state */
3671 static void alc880_medion_rim_automute(struct hda_codec *codec)
3673 struct alc_spec *spec = codec->spec;
3674 alc_automute_amp(codec);
3676 if (spec->jack_present)
3677 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 0);
3679 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 2);
3682 static void alc880_medion_rim_unsol_event(struct hda_codec *codec,
3685 /* Looks like the unsol event is incompatible with the standard
3686 * definition. 4bit tag is placed at 28 bit!
3688 if ((res >> 28) == ALC880_HP_EVENT)
3689 alc880_medion_rim_automute(codec);
3692 static void alc880_medion_rim_setup(struct hda_codec *codec)
3694 struct alc_spec *spec = codec->spec;
3696 spec->autocfg.hp_pins[0] = 0x14;
3697 spec->autocfg.speaker_pins[0] = 0x1b;
3700 #ifdef CONFIG_SND_HDA_POWER_SAVE
3701 static struct hda_amp_list alc880_loopbacks[] = {
3702 { 0x0b, HDA_INPUT, 0 },
3703 { 0x0b, HDA_INPUT, 1 },
3704 { 0x0b, HDA_INPUT, 2 },
3705 { 0x0b, HDA_INPUT, 3 },
3706 { 0x0b, HDA_INPUT, 4 },
3710 static struct hda_amp_list alc880_lg_loopbacks[] = {
3711 { 0x0b, HDA_INPUT, 1 },
3712 { 0x0b, HDA_INPUT, 6 },
3713 { 0x0b, HDA_INPUT, 7 },
3722 static int alc_init(struct hda_codec *codec)
3724 struct alc_spec *spec = codec->spec;
3728 alc_auto_init_amp(codec, spec->init_amp);
3730 for (i = 0; i < spec->num_init_verbs; i++)
3731 snd_hda_sequence_write(codec, spec->init_verbs[i]);
3733 if (spec->init_hook)
3734 spec->init_hook(codec);
3736 hda_call_check_power_status(codec, 0x01);
3740 static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
3742 struct alc_spec *spec = codec->spec;
3744 if (spec->unsol_event)
3745 spec->unsol_event(codec, res);
3748 #ifdef CONFIG_SND_HDA_POWER_SAVE
3749 static int alc_check_power_status(struct hda_codec *codec, hda_nid_t nid)
3751 struct alc_spec *spec = codec->spec;
3752 return snd_hda_check_amp_list_power(codec, &spec->loopback, nid);
3757 * Analog playback callbacks
3759 static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
3760 struct hda_codec *codec,
3761 struct snd_pcm_substream *substream)
3763 struct alc_spec *spec = codec->spec;
3764 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
3768 static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
3769 struct hda_codec *codec,
3770 unsigned int stream_tag,
3771 unsigned int format,
3772 struct snd_pcm_substream *substream)
3774 struct alc_spec *spec = codec->spec;
3775 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
3776 stream_tag, format, substream);
3779 static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
3780 struct hda_codec *codec,
3781 struct snd_pcm_substream *substream)
3783 struct alc_spec *spec = codec->spec;
3784 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
3790 static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
3791 struct hda_codec *codec,
3792 struct snd_pcm_substream *substream)
3794 struct alc_spec *spec = codec->spec;
3795 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
3798 static int alc880_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
3799 struct hda_codec *codec,
3800 unsigned int stream_tag,
3801 unsigned int format,
3802 struct snd_pcm_substream *substream)
3804 struct alc_spec *spec = codec->spec;
3805 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
3806 stream_tag, format, substream);
3809 static int alc880_dig_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
3810 struct hda_codec *codec,
3811 struct snd_pcm_substream *substream)
3813 struct alc_spec *spec = codec->spec;
3814 return snd_hda_multi_out_dig_cleanup(codec, &spec->multiout);
3817 static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
3818 struct hda_codec *codec,
3819 struct snd_pcm_substream *substream)