2 * Universal Interface for Intel High Definition Audio Codec
4 * HD audio interface patch for ALC 260/880/882 codecs
6 * Copyright (c) 2004 Kailang Yang <kailang@realtek.com.tw>
7 * PeiSen Hou <pshou@realtek.com.tw>
8 * Takashi Iwai <tiwai@suse.de>
9 * Jonathan Woithe <jwoithe@physics.adelaide.edu.au>
11 * This driver is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
16 * This driver is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26 #include <linux/init.h>
27 #include <linux/delay.h>
28 #include <linux/slab.h>
29 #include <linux/pci.h>
30 #include <sound/core.h>
31 #include "hda_codec.h"
32 #include "hda_local.h"
35 #define ALC880_FRONT_EVENT 0x01
36 #define ALC880_DCVOL_EVENT 0x02
37 #define ALC880_HP_EVENT 0x04
38 #define ALC880_MIC_EVENT 0x08
40 /* ALC880 board config type */
64 #ifdef CONFIG_SND_DEBUG
68 ALC880_MODEL_LAST /* last tag */
82 #ifdef CONFIG_SND_DEBUG
86 ALC260_MODEL_LAST /* last tag */
96 ALC262_HP_BPC_D7000_WL,
97 ALC262_HP_BPC_D7000_WF,
110 ALC262_MODEL_LAST /* last tag */
120 ALC268_ACER_ASPIRE_ONE,
123 #ifdef CONFIG_SND_DEBUG
127 ALC268_MODEL_LAST /* last tag */
142 ALC269_MODEL_LAST /* last tag */
159 /* ALC861-VD models */
181 ALC662_ASUS_EEEPC_P701,
182 ALC662_ASUS_EEEPC_EP20,
224 ALC883_TARGA_2ch_DIG,
225 ALC883_TARGA_8ch_DIG,
228 ALC888_ACER_ASPIRE_4930G,
229 ALC888_ACER_ASPIRE_6530G,
230 ALC888_ACER_ASPIRE_8930G,
231 ALC888_ACER_ASPIRE_7730G,
234 ALC883_MEDION_WIM2160,
236 ALC883_LENOVO_101E_2ch,
237 ALC883_LENOVO_NB0763,
238 ALC888_LENOVO_MS7195_DIG,
246 ALC883_FUJITSU_PI2515,
247 ALC888_FUJITSU_XA3530,
248 ALC883_3ST_6ch_INTEL,
268 #define GPIO_MASK 0x03
270 /* extra amp-initialization sequence types */
279 struct alc_mic_route {
281 unsigned char mux_idx;
282 unsigned char amix_idx;
285 #define MUX_IDX_UNDEF ((unsigned char)-1)
287 struct alc_customize_define {
288 unsigned int sku_cfg;
289 unsigned char port_connectivity;
290 unsigned char check_sum;
291 unsigned char customization;
292 unsigned char external_amp;
293 unsigned int enable_pcbeep:1;
294 unsigned int platform_type:1;
296 unsigned int override:1;
300 /* codec parameterization */
301 struct snd_kcontrol_new *mixers[5]; /* mixer arrays */
302 unsigned int num_mixers;
303 struct snd_kcontrol_new *cap_mixer; /* capture mixer */
304 unsigned int beep_amp; /* beep amp value, set via set_beep_amp() */
306 const struct hda_verb *init_verbs[10]; /* initialization verbs
310 unsigned int num_init_verbs;
312 char stream_name_analog[32]; /* analog PCM stream */
313 struct hda_pcm_stream *stream_analog_playback;
314 struct hda_pcm_stream *stream_analog_capture;
315 struct hda_pcm_stream *stream_analog_alt_playback;
316 struct hda_pcm_stream *stream_analog_alt_capture;
318 char stream_name_digital[32]; /* digital PCM stream */
319 struct hda_pcm_stream *stream_digital_playback;
320 struct hda_pcm_stream *stream_digital_capture;
323 struct hda_multi_out multiout; /* playback set-up
324 * max_channels, dacs must be set
325 * dig_out_nid and hp_nid are optional
327 hda_nid_t alt_dac_nid;
328 hda_nid_t slave_dig_outs[3]; /* optional - for auto-parsing */
332 unsigned int num_adc_nids;
334 hda_nid_t *capsrc_nids;
335 hda_nid_t dig_in_nid; /* digital-in NID; optional */
337 /* capture setup for dynamic dual-adc switch */
338 unsigned int cur_adc_idx;
340 unsigned int cur_adc_stream_tag;
341 unsigned int cur_adc_format;
344 unsigned int num_mux_defs;
345 const struct hda_input_mux *input_mux;
346 unsigned int cur_mux[3];
347 struct alc_mic_route ext_mic;
348 struct alc_mic_route int_mic;
351 const struct hda_channel_mode *channel_mode;
352 int num_channel_mode;
354 int const_channel_count;
355 int ext_channel_count;
357 /* PCM information */
358 struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */
360 /* dynamic controls, init_verbs and input_mux */
361 struct auto_pin_cfg autocfg;
362 struct alc_customize_define cdefine;
363 struct snd_array kctls;
364 struct hda_input_mux private_imux[3];
365 hda_nid_t private_dac_nids[AUTO_CFG_MAX_OUTS];
366 hda_nid_t private_adc_nids[AUTO_CFG_MAX_OUTS];
367 hda_nid_t private_capsrc_nids[AUTO_CFG_MAX_OUTS];
370 void (*init_hook)(struct hda_codec *codec);
371 void (*unsol_event)(struct hda_codec *codec, unsigned int res);
372 #ifdef CONFIG_SND_HDA_POWER_SAVE
373 void (*power_hook)(struct hda_codec *codec);
376 /* for pin sensing */
377 unsigned int sense_updated: 1;
378 unsigned int jack_present: 1;
379 unsigned int master_sw: 1;
380 unsigned int auto_mic:1;
383 unsigned int no_analog :1; /* digital I/O only */
384 unsigned int dual_adc_switch:1; /* switch ADCs (for ALC275) */
387 /* for virtual master */
388 hda_nid_t vmaster_nid;
389 #ifdef CONFIG_SND_HDA_POWER_SAVE
390 struct hda_loopback_check loopback;
395 unsigned int pll_coef_idx, pll_coef_bit;
399 * configuration template - to be copied to the spec instance
401 struct alc_config_preset {
402 struct snd_kcontrol_new *mixers[5]; /* should be identical size
405 struct snd_kcontrol_new *cap_mixer; /* capture mixer */
406 const struct hda_verb *init_verbs[5];
407 unsigned int num_dacs;
409 hda_nid_t dig_out_nid; /* optional */
410 hda_nid_t hp_nid; /* optional */
411 hda_nid_t *slave_dig_outs;
412 unsigned int num_adc_nids;
414 hda_nid_t *capsrc_nids;
415 hda_nid_t dig_in_nid;
416 unsigned int num_channel_mode;
417 const struct hda_channel_mode *channel_mode;
419 int const_channel_count;
420 unsigned int num_mux_defs;
421 const struct hda_input_mux *input_mux;
422 void (*unsol_event)(struct hda_codec *, unsigned int);
423 void (*setup)(struct hda_codec *);
424 void (*init_hook)(struct hda_codec *);
425 #ifdef CONFIG_SND_HDA_POWER_SAVE
426 struct hda_amp_list *loopbacks;
427 void (*power_hook)(struct hda_codec *codec);
435 static int alc_mux_enum_info(struct snd_kcontrol *kcontrol,
436 struct snd_ctl_elem_info *uinfo)
438 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
439 struct alc_spec *spec = codec->spec;
440 unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id);
441 if (mux_idx >= spec->num_mux_defs)
443 if (!spec->input_mux[mux_idx].num_items && mux_idx > 0)
445 return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo);
448 static int alc_mux_enum_get(struct snd_kcontrol *kcontrol,
449 struct snd_ctl_elem_value *ucontrol)
451 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
452 struct alc_spec *spec = codec->spec;
453 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
455 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
459 static int alc_mux_enum_put(struct snd_kcontrol *kcontrol,
460 struct snd_ctl_elem_value *ucontrol)
462 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
463 struct alc_spec *spec = codec->spec;
464 const struct hda_input_mux *imux;
465 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
466 unsigned int mux_idx;
467 hda_nid_t nid = spec->capsrc_nids ?
468 spec->capsrc_nids[adc_idx] : spec->adc_nids[adc_idx];
471 mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx;
472 imux = &spec->input_mux[mux_idx];
473 if (!imux->num_items && mux_idx > 0)
474 imux = &spec->input_mux[0];
476 type = get_wcaps_type(get_wcaps(codec, nid));
477 if (type == AC_WID_AUD_MIX) {
478 /* Matrix-mixer style (e.g. ALC882) */
479 unsigned int *cur_val = &spec->cur_mux[adc_idx];
482 idx = ucontrol->value.enumerated.item[0];
483 if (idx >= imux->num_items)
484 idx = imux->num_items - 1;
487 for (i = 0; i < imux->num_items; i++) {
488 unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
489 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
490 imux->items[i].index,
496 /* MUX style (e.g. ALC880) */
497 return snd_hda_input_mux_put(codec, imux, ucontrol, nid,
498 &spec->cur_mux[adc_idx]);
503 * channel mode setting
505 static int alc_ch_mode_info(struct snd_kcontrol *kcontrol,
506 struct snd_ctl_elem_info *uinfo)
508 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
509 struct alc_spec *spec = codec->spec;
510 return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
511 spec->num_channel_mode);
514 static int alc_ch_mode_get(struct snd_kcontrol *kcontrol,
515 struct snd_ctl_elem_value *ucontrol)
517 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
518 struct alc_spec *spec = codec->spec;
519 return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
520 spec->num_channel_mode,
521 spec->ext_channel_count);
524 static int alc_ch_mode_put(struct snd_kcontrol *kcontrol,
525 struct snd_ctl_elem_value *ucontrol)
527 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
528 struct alc_spec *spec = codec->spec;
529 int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
530 spec->num_channel_mode,
531 &spec->ext_channel_count);
532 if (err >= 0 && !spec->const_channel_count) {
533 spec->multiout.max_channels = spec->ext_channel_count;
534 if (spec->need_dac_fix)
535 spec->multiout.num_dacs = spec->multiout.max_channels / 2;
541 * Control the mode of pin widget settings via the mixer. "pc" is used
542 * instead of "%" to avoid consequences of accidently treating the % as
543 * being part of a format specifier. Maximum allowed length of a value is
544 * 63 characters plus NULL terminator.
546 * Note: some retasking pin complexes seem to ignore requests for input
547 * states other than HiZ (eg: PIN_VREFxx) and revert to HiZ if any of these
548 * are requested. Therefore order this list so that this behaviour will not
549 * cause problems when mixer clients move through the enum sequentially.
550 * NIDs 0x0f and 0x10 have been observed to have this behaviour as of
553 static char *alc_pin_mode_names[] = {
554 "Mic 50pc bias", "Mic 80pc bias",
555 "Line in", "Line out", "Headphone out",
557 static unsigned char alc_pin_mode_values[] = {
558 PIN_VREF50, PIN_VREF80, PIN_IN, PIN_OUT, PIN_HP,
560 /* The control can present all 5 options, or it can limit the options based
561 * in the pin being assumed to be exclusively an input or an output pin. In
562 * addition, "input" pins may or may not process the mic bias option
563 * depending on actual widget capability (NIDs 0x0f and 0x10 don't seem to
564 * accept requests for bias as of chip versions up to March 2006) and/or
565 * wiring in the computer.
567 #define ALC_PIN_DIR_IN 0x00
568 #define ALC_PIN_DIR_OUT 0x01
569 #define ALC_PIN_DIR_INOUT 0x02
570 #define ALC_PIN_DIR_IN_NOMICBIAS 0x03
571 #define ALC_PIN_DIR_INOUT_NOMICBIAS 0x04
573 /* Info about the pin modes supported by the different pin direction modes.
574 * For each direction the minimum and maximum values are given.
576 static signed char alc_pin_mode_dir_info[5][2] = {
577 { 0, 2 }, /* ALC_PIN_DIR_IN */
578 { 3, 4 }, /* ALC_PIN_DIR_OUT */
579 { 0, 4 }, /* ALC_PIN_DIR_INOUT */
580 { 2, 2 }, /* ALC_PIN_DIR_IN_NOMICBIAS */
581 { 2, 4 }, /* ALC_PIN_DIR_INOUT_NOMICBIAS */
583 #define alc_pin_mode_min(_dir) (alc_pin_mode_dir_info[_dir][0])
584 #define alc_pin_mode_max(_dir) (alc_pin_mode_dir_info[_dir][1])
585 #define alc_pin_mode_n_items(_dir) \
586 (alc_pin_mode_max(_dir)-alc_pin_mode_min(_dir)+1)
588 static int alc_pin_mode_info(struct snd_kcontrol *kcontrol,
589 struct snd_ctl_elem_info *uinfo)
591 unsigned int item_num = uinfo->value.enumerated.item;
592 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
594 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
596 uinfo->value.enumerated.items = alc_pin_mode_n_items(dir);
598 if (item_num<alc_pin_mode_min(dir) || item_num>alc_pin_mode_max(dir))
599 item_num = alc_pin_mode_min(dir);
600 strcpy(uinfo->value.enumerated.name, alc_pin_mode_names[item_num]);
604 static int alc_pin_mode_get(struct snd_kcontrol *kcontrol,
605 struct snd_ctl_elem_value *ucontrol)
608 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
609 hda_nid_t nid = kcontrol->private_value & 0xffff;
610 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
611 long *valp = ucontrol->value.integer.value;
612 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
613 AC_VERB_GET_PIN_WIDGET_CONTROL,
616 /* Find enumerated value for current pinctl setting */
617 i = alc_pin_mode_min(dir);
618 while (i <= alc_pin_mode_max(dir) && alc_pin_mode_values[i] != pinctl)
620 *valp = i <= alc_pin_mode_max(dir) ? i: alc_pin_mode_min(dir);
624 static int alc_pin_mode_put(struct snd_kcontrol *kcontrol,
625 struct snd_ctl_elem_value *ucontrol)
628 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
629 hda_nid_t nid = kcontrol->private_value & 0xffff;
630 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
631 long val = *ucontrol->value.integer.value;
632 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
633 AC_VERB_GET_PIN_WIDGET_CONTROL,
636 if (val < alc_pin_mode_min(dir) || val > alc_pin_mode_max(dir))
637 val = alc_pin_mode_min(dir);
639 change = pinctl != alc_pin_mode_values[val];
641 /* Set pin mode to that requested */
642 snd_hda_codec_write_cache(codec, nid, 0,
643 AC_VERB_SET_PIN_WIDGET_CONTROL,
644 alc_pin_mode_values[val]);
646 /* Also enable the retasking pin's input/output as required
647 * for the requested pin mode. Enum values of 2 or less are
650 * Dynamically switching the input/output buffers probably
651 * reduces noise slightly (particularly on input) so we'll
652 * do it. However, having both input and output buffers
653 * enabled simultaneously doesn't seem to be problematic if
654 * this turns out to be necessary in the future.
657 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
658 HDA_AMP_MUTE, HDA_AMP_MUTE);
659 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
662 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
663 HDA_AMP_MUTE, HDA_AMP_MUTE);
664 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
671 #define ALC_PIN_MODE(xname, nid, dir) \
672 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
673 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
674 .info = alc_pin_mode_info, \
675 .get = alc_pin_mode_get, \
676 .put = alc_pin_mode_put, \
677 .private_value = nid | (dir<<16) }
679 /* A switch control for ALC260 GPIO pins. Multiple GPIOs can be ganged
680 * together using a mask with more than one bit set. This control is
681 * currently used only by the ALC260 test model. At this stage they are not
682 * needed for any "production" models.
684 #ifdef CONFIG_SND_DEBUG
685 #define alc_gpio_data_info snd_ctl_boolean_mono_info
687 static int alc_gpio_data_get(struct snd_kcontrol *kcontrol,
688 struct snd_ctl_elem_value *ucontrol)
690 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
691 hda_nid_t nid = kcontrol->private_value & 0xffff;
692 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
693 long *valp = ucontrol->value.integer.value;
694 unsigned int val = snd_hda_codec_read(codec, nid, 0,
695 AC_VERB_GET_GPIO_DATA, 0x00);
697 *valp = (val & mask) != 0;
700 static int alc_gpio_data_put(struct snd_kcontrol *kcontrol,
701 struct snd_ctl_elem_value *ucontrol)
704 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
705 hda_nid_t nid = kcontrol->private_value & 0xffff;
706 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
707 long val = *ucontrol->value.integer.value;
708 unsigned int gpio_data = snd_hda_codec_read(codec, nid, 0,
709 AC_VERB_GET_GPIO_DATA,
712 /* Set/unset the masked GPIO bit(s) as needed */
713 change = (val == 0 ? 0 : mask) != (gpio_data & mask);
718 snd_hda_codec_write_cache(codec, nid, 0,
719 AC_VERB_SET_GPIO_DATA, gpio_data);
723 #define ALC_GPIO_DATA_SWITCH(xname, nid, mask) \
724 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
725 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
726 .info = alc_gpio_data_info, \
727 .get = alc_gpio_data_get, \
728 .put = alc_gpio_data_put, \
729 .private_value = nid | (mask<<16) }
730 #endif /* CONFIG_SND_DEBUG */
732 /* A switch control to allow the enabling of the digital IO pins on the
733 * ALC260. This is incredibly simplistic; the intention of this control is
734 * to provide something in the test model allowing digital outputs to be
735 * identified if present. If models are found which can utilise these
736 * outputs a more complete mixer control can be devised for those models if
739 #ifdef CONFIG_SND_DEBUG
740 #define alc_spdif_ctrl_info snd_ctl_boolean_mono_info
742 static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol,
743 struct snd_ctl_elem_value *ucontrol)
745 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
746 hda_nid_t nid = kcontrol->private_value & 0xffff;
747 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
748 long *valp = ucontrol->value.integer.value;
749 unsigned int val = snd_hda_codec_read(codec, nid, 0,
750 AC_VERB_GET_DIGI_CONVERT_1, 0x00);
752 *valp = (val & mask) != 0;
755 static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol,
756 struct snd_ctl_elem_value *ucontrol)
759 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
760 hda_nid_t nid = kcontrol->private_value & 0xffff;
761 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
762 long val = *ucontrol->value.integer.value;
763 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
764 AC_VERB_GET_DIGI_CONVERT_1,
767 /* Set/unset the masked control bit(s) as needed */
768 change = (val == 0 ? 0 : mask) != (ctrl_data & mask);
773 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1,
778 #define ALC_SPDIF_CTRL_SWITCH(xname, nid, mask) \
779 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
780 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
781 .info = alc_spdif_ctrl_info, \
782 .get = alc_spdif_ctrl_get, \
783 .put = alc_spdif_ctrl_put, \
784 .private_value = nid | (mask<<16) }
785 #endif /* CONFIG_SND_DEBUG */
787 /* A switch control to allow the enabling EAPD digital outputs on the ALC26x.
788 * Again, this is only used in the ALC26x test models to help identify when
789 * the EAPD line must be asserted for features to work.
791 #ifdef CONFIG_SND_DEBUG
792 #define alc_eapd_ctrl_info snd_ctl_boolean_mono_info
794 static int alc_eapd_ctrl_get(struct snd_kcontrol *kcontrol,
795 struct snd_ctl_elem_value *ucontrol)
797 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
798 hda_nid_t nid = kcontrol->private_value & 0xffff;
799 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
800 long *valp = ucontrol->value.integer.value;
801 unsigned int val = snd_hda_codec_read(codec, nid, 0,
802 AC_VERB_GET_EAPD_BTLENABLE, 0x00);
804 *valp = (val & mask) != 0;
808 static int alc_eapd_ctrl_put(struct snd_kcontrol *kcontrol,
809 struct snd_ctl_elem_value *ucontrol)
812 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
813 hda_nid_t nid = kcontrol->private_value & 0xffff;
814 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
815 long val = *ucontrol->value.integer.value;
816 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
817 AC_VERB_GET_EAPD_BTLENABLE,
820 /* Set/unset the masked control bit(s) as needed */
821 change = (!val ? 0 : mask) != (ctrl_data & mask);
826 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
832 #define ALC_EAPD_CTRL_SWITCH(xname, nid, mask) \
833 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
834 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
835 .info = alc_eapd_ctrl_info, \
836 .get = alc_eapd_ctrl_get, \
837 .put = alc_eapd_ctrl_put, \
838 .private_value = nid | (mask<<16) }
839 #endif /* CONFIG_SND_DEBUG */
842 * set up the input pin config (depending on the given auto-pin type)
844 static void alc_set_input_pin(struct hda_codec *codec, hda_nid_t nid,
847 unsigned int val = PIN_IN;
849 if (auto_pin_type <= AUTO_PIN_FRONT_MIC) {
852 oldval = snd_hda_codec_read(codec, nid, 0,
853 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
854 pincap = snd_hda_query_pin_caps(codec, nid);
855 pincap = (pincap & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT;
856 /* if the default pin setup is vref50, we give it priority */
857 if ((pincap & AC_PINCAP_VREF_80) && oldval != PIN_VREF50)
859 else if (pincap & AC_PINCAP_VREF_50)
861 else if (pincap & AC_PINCAP_VREF_100)
863 else if (pincap & AC_PINCAP_VREF_GRD)
866 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, val);
871 static void add_mixer(struct alc_spec *spec, struct snd_kcontrol_new *mix)
873 if (snd_BUG_ON(spec->num_mixers >= ARRAY_SIZE(spec->mixers)))
875 spec->mixers[spec->num_mixers++] = mix;
878 static void add_verb(struct alc_spec *spec, const struct hda_verb *verb)
880 if (snd_BUG_ON(spec->num_init_verbs >= ARRAY_SIZE(spec->init_verbs)))
882 spec->init_verbs[spec->num_init_verbs++] = verb;
886 * set up from the preset table
888 static void setup_preset(struct hda_codec *codec,
889 const struct alc_config_preset *preset)
891 struct alc_spec *spec = codec->spec;
894 for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++)
895 add_mixer(spec, preset->mixers[i]);
896 spec->cap_mixer = preset->cap_mixer;
897 for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i];
899 add_verb(spec, preset->init_verbs[i]);
901 spec->channel_mode = preset->channel_mode;
902 spec->num_channel_mode = preset->num_channel_mode;
903 spec->need_dac_fix = preset->need_dac_fix;
904 spec->const_channel_count = preset->const_channel_count;
906 if (preset->const_channel_count)
907 spec->multiout.max_channels = preset->const_channel_count;
909 spec->multiout.max_channels = spec->channel_mode[0].channels;
910 spec->ext_channel_count = spec->channel_mode[0].channels;
912 spec->multiout.num_dacs = preset->num_dacs;
913 spec->multiout.dac_nids = preset->dac_nids;
914 spec->multiout.dig_out_nid = preset->dig_out_nid;
915 spec->multiout.slave_dig_outs = preset->slave_dig_outs;
916 spec->multiout.hp_nid = preset->hp_nid;
918 spec->num_mux_defs = preset->num_mux_defs;
919 if (!spec->num_mux_defs)
920 spec->num_mux_defs = 1;
921 spec->input_mux = preset->input_mux;
923 spec->num_adc_nids = preset->num_adc_nids;
924 spec->adc_nids = preset->adc_nids;
925 spec->capsrc_nids = preset->capsrc_nids;
926 spec->dig_in_nid = preset->dig_in_nid;
928 spec->unsol_event = preset->unsol_event;
929 spec->init_hook = preset->init_hook;
930 #ifdef CONFIG_SND_HDA_POWER_SAVE
931 spec->power_hook = preset->power_hook;
932 spec->loopback.amplist = preset->loopbacks;
936 preset->setup(codec);
939 /* Enable GPIO mask and set output */
940 static struct hda_verb alc_gpio1_init_verbs[] = {
941 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
942 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
943 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
947 static struct hda_verb alc_gpio2_init_verbs[] = {
948 {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
949 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
950 {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
954 static struct hda_verb alc_gpio3_init_verbs[] = {
955 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
956 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
957 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
962 * Fix hardware PLL issue
963 * On some codecs, the analog PLL gating control must be off while
964 * the default value is 1.
966 static void alc_fix_pll(struct hda_codec *codec)
968 struct alc_spec *spec = codec->spec;
973 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX,
975 val = snd_hda_codec_read(codec, spec->pll_nid, 0,
976 AC_VERB_GET_PROC_COEF, 0);
977 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX,
979 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_PROC_COEF,
980 val & ~(1 << spec->pll_coef_bit));
983 static void alc_fix_pll_init(struct hda_codec *codec, hda_nid_t nid,
984 unsigned int coef_idx, unsigned int coef_bit)
986 struct alc_spec *spec = codec->spec;
988 spec->pll_coef_idx = coef_idx;
989 spec->pll_coef_bit = coef_bit;
993 static void alc_automute_pin(struct hda_codec *codec)
995 struct alc_spec *spec = codec->spec;
996 unsigned int nid = spec->autocfg.hp_pins[0];
1001 spec->jack_present = snd_hda_jack_detect(codec, nid);
1002 for (i = 0; i < ARRAY_SIZE(spec->autocfg.speaker_pins); i++) {
1003 nid = spec->autocfg.speaker_pins[i];
1006 snd_hda_codec_write(codec, nid, 0,
1007 AC_VERB_SET_PIN_WIDGET_CONTROL,
1008 spec->jack_present ? 0 : PIN_OUT);
1012 static int get_connection_index(struct hda_codec *codec, hda_nid_t mux,
1015 hda_nid_t conn[HDA_MAX_NUM_INPUTS];
1018 nums = snd_hda_get_connections(codec, mux, conn, ARRAY_SIZE(conn));
1019 for (i = 0; i < nums; i++)
1025 /* switch the current ADC according to the jack state */
1026 static void alc_dual_mic_adc_auto_switch(struct hda_codec *codec)
1028 struct alc_spec *spec = codec->spec;
1029 unsigned int present;
1032 present = snd_hda_jack_detect(codec, spec->ext_mic.pin);
1034 spec->cur_adc_idx = 1;
1036 spec->cur_adc_idx = 0;
1037 new_adc = spec->adc_nids[spec->cur_adc_idx];
1038 if (spec->cur_adc && spec->cur_adc != new_adc) {
1039 /* stream is running, let's swap the current ADC */
1040 __snd_hda_codec_cleanup_stream(codec, spec->cur_adc, 1);
1041 spec->cur_adc = new_adc;
1042 snd_hda_codec_setup_stream(codec, new_adc,
1043 spec->cur_adc_stream_tag, 0,
1044 spec->cur_adc_format);
1048 static void alc_mic_automute(struct hda_codec *codec)
1050 struct alc_spec *spec = codec->spec;
1051 struct alc_mic_route *dead, *alive;
1052 unsigned int present, type;
1055 if (!spec->auto_mic)
1057 if (!spec->int_mic.pin || !spec->ext_mic.pin)
1059 if (snd_BUG_ON(!spec->adc_nids))
1062 if (spec->dual_adc_switch) {
1063 alc_dual_mic_adc_auto_switch(codec);
1067 cap_nid = spec->capsrc_nids ? spec->capsrc_nids[0] : spec->adc_nids[0];
1069 present = snd_hda_jack_detect(codec, spec->ext_mic.pin);
1071 alive = &spec->ext_mic;
1072 dead = &spec->int_mic;
1074 alive = &spec->int_mic;
1075 dead = &spec->ext_mic;
1078 type = get_wcaps_type(get_wcaps(codec, cap_nid));
1079 if (type == AC_WID_AUD_MIX) {
1080 /* Matrix-mixer style (e.g. ALC882) */
1081 snd_hda_codec_amp_stereo(codec, cap_nid, HDA_INPUT,
1084 snd_hda_codec_amp_stereo(codec, cap_nid, HDA_INPUT,
1086 HDA_AMP_MUTE, HDA_AMP_MUTE);
1088 /* MUX style (e.g. ALC880) */
1089 snd_hda_codec_write_cache(codec, cap_nid, 0,
1090 AC_VERB_SET_CONNECT_SEL,
1094 /* FIXME: analog mixer */
1097 /* unsolicited event for HP jack sensing */
1098 static void alc_sku_unsol_event(struct hda_codec *codec, unsigned int res)
1100 if (codec->vendor_id == 0x10ec0880)
1105 case ALC880_HP_EVENT:
1106 alc_automute_pin(codec);
1108 case ALC880_MIC_EVENT:
1109 alc_mic_automute(codec);
1114 static void alc_inithook(struct hda_codec *codec)
1116 alc_automute_pin(codec);
1117 alc_mic_automute(codec);
1120 /* additional initialization for ALC888 variants */
1121 static void alc888_coef_init(struct hda_codec *codec)
1125 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 0);
1126 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
1127 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
1128 if ((tmp & 0xf0) == 0x20)
1130 snd_hda_codec_read(codec, 0x20, 0,
1131 AC_VERB_SET_PROC_COEF, 0x830);
1134 snd_hda_codec_read(codec, 0x20, 0,
1135 AC_VERB_SET_PROC_COEF, 0x3030);
1138 static void alc889_coef_init(struct hda_codec *codec)
1142 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
1143 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
1144 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
1145 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_PROC_COEF, tmp|0x2010);
1148 /* turn on/off EAPD control (only if available) */
1149 static void set_eapd(struct hda_codec *codec, hda_nid_t nid, int on)
1151 if (get_wcaps_type(get_wcaps(codec, nid)) != AC_WID_PIN)
1153 if (snd_hda_query_pin_caps(codec, nid) & AC_PINCAP_EAPD)
1154 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
1158 static void alc_auto_init_amp(struct hda_codec *codec, int type)
1163 case ALC_INIT_GPIO1:
1164 snd_hda_sequence_write(codec, alc_gpio1_init_verbs);
1166 case ALC_INIT_GPIO2:
1167 snd_hda_sequence_write(codec, alc_gpio2_init_verbs);
1169 case ALC_INIT_GPIO3:
1170 snd_hda_sequence_write(codec, alc_gpio3_init_verbs);
1172 case ALC_INIT_DEFAULT:
1173 switch (codec->vendor_id) {
1175 set_eapd(codec, 0x0f, 1);
1176 set_eapd(codec, 0x10, 1);
1189 set_eapd(codec, 0x14, 1);
1190 set_eapd(codec, 0x15, 1);
1193 switch (codec->vendor_id) {
1195 snd_hda_codec_write(codec, 0x1a, 0,
1196 AC_VERB_SET_COEF_INDEX, 7);
1197 tmp = snd_hda_codec_read(codec, 0x1a, 0,
1198 AC_VERB_GET_PROC_COEF, 0);
1199 snd_hda_codec_write(codec, 0x1a, 0,
1200 AC_VERB_SET_COEF_INDEX, 7);
1201 snd_hda_codec_write(codec, 0x1a, 0,
1202 AC_VERB_SET_PROC_COEF,
1212 alc889_coef_init(codec);
1215 alc888_coef_init(codec);
1217 #if 0 /* XXX: This may cause the silent output on speaker on some machines */
1220 snd_hda_codec_write(codec, 0x20, 0,
1221 AC_VERB_SET_COEF_INDEX, 7);
1222 tmp = snd_hda_codec_read(codec, 0x20, 0,
1223 AC_VERB_GET_PROC_COEF, 0);
1224 snd_hda_codec_write(codec, 0x20, 0,
1225 AC_VERB_SET_COEF_INDEX, 7);
1226 snd_hda_codec_write(codec, 0x20, 0,
1227 AC_VERB_SET_PROC_COEF,
1236 static void alc_init_auto_hp(struct hda_codec *codec)
1238 struct alc_spec *spec = codec->spec;
1240 if (!spec->autocfg.hp_pins[0])
1243 if (!spec->autocfg.speaker_pins[0]) {
1244 if (spec->autocfg.line_out_pins[0] &&
1245 spec->autocfg.line_out_type == AUTO_PIN_SPEAKER_OUT)
1246 spec->autocfg.speaker_pins[0] =
1247 spec->autocfg.line_out_pins[0];
1252 snd_printdd("realtek: Enable HP auto-muting on NID 0x%x\n",
1253 spec->autocfg.hp_pins[0]);
1254 snd_hda_codec_write_cache(codec, spec->autocfg.hp_pins[0], 0,
1255 AC_VERB_SET_UNSOLICITED_ENABLE,
1256 AC_USRSP_EN | ALC880_HP_EVENT);
1257 spec->unsol_event = alc_sku_unsol_event;
1260 static void alc_init_auto_mic(struct hda_codec *codec)
1262 struct alc_spec *spec = codec->spec;
1263 struct auto_pin_cfg *cfg = &spec->autocfg;
1264 hda_nid_t fixed, ext;
1267 /* there must be only two mic inputs exclusively */
1268 for (i = AUTO_PIN_LINE; i < AUTO_PIN_LAST; i++)
1269 if (cfg->input_pins[i])
1273 for (i = AUTO_PIN_MIC; i <= AUTO_PIN_FRONT_MIC; i++) {
1274 hda_nid_t nid = cfg->input_pins[i];
1275 unsigned int defcfg;
1278 defcfg = snd_hda_codec_get_pincfg(codec, nid);
1279 switch (get_defcfg_connect(defcfg)) {
1280 case AC_JACK_PORT_FIXED:
1282 return; /* already occupied */
1285 case AC_JACK_PORT_COMPLEX:
1287 return; /* already occupied */
1291 return; /* invalid entry */
1296 if (!(get_wcaps(codec, ext) & AC_WCAP_UNSOL_CAP))
1297 return; /* no unsol support */
1298 snd_printdd("realtek: Enable auto-mic switch on NID 0x%x/0x%x\n",
1300 spec->ext_mic.pin = ext;
1301 spec->int_mic.pin = fixed;
1302 spec->ext_mic.mux_idx = MUX_IDX_UNDEF; /* set later */
1303 spec->int_mic.mux_idx = MUX_IDX_UNDEF; /* set later */
1305 snd_hda_codec_write_cache(codec, spec->ext_mic.pin, 0,
1306 AC_VERB_SET_UNSOLICITED_ENABLE,
1307 AC_USRSP_EN | ALC880_MIC_EVENT);
1308 spec->unsol_event = alc_sku_unsol_event;
1311 static int alc_auto_parse_customize_define(struct hda_codec *codec)
1313 unsigned int ass, tmp, i;
1315 struct alc_spec *spec = codec->spec;
1317 spec->cdefine.enable_pcbeep = 1; /* assume always enabled */
1319 ass = codec->subsystem_id & 0xffff;
1320 if (ass != codec->bus->pci->subsystem_device && (ass & 1))
1324 if (codec->vendor_id == 0x10ec0260)
1326 ass = snd_hda_codec_get_pincfg(codec, nid);
1329 printk(KERN_INFO "hda_codec: %s: SKU not ready 0x%08x\n",
1330 codec->chip_name, ass);
1336 for (i = 1; i < 16; i++) {
1340 if (((ass >> 16) & 0xf) != tmp)
1343 spec->cdefine.port_connectivity = ass >> 30;
1344 spec->cdefine.enable_pcbeep = (ass & 0x100000) >> 20;
1345 spec->cdefine.check_sum = (ass >> 16) & 0xf;
1346 spec->cdefine.customization = ass >> 8;
1348 spec->cdefine.sku_cfg = ass;
1349 spec->cdefine.external_amp = (ass & 0x38) >> 3;
1350 spec->cdefine.platform_type = (ass & 0x4) >> 2;
1351 spec->cdefine.swap = (ass & 0x2) >> 1;
1352 spec->cdefine.override = ass & 0x1;
1354 snd_printd("SKU: Nid=0x%x sku_cfg=0x%08x\n",
1355 nid, spec->cdefine.sku_cfg);
1356 snd_printd("SKU: port_connectivity=0x%x\n",
1357 spec->cdefine.port_connectivity);
1358 snd_printd("SKU: enable_pcbeep=0x%x\n", spec->cdefine.enable_pcbeep);
1359 snd_printd("SKU: check_sum=0x%08x\n", spec->cdefine.check_sum);
1360 snd_printd("SKU: customization=0x%08x\n", spec->cdefine.customization);
1361 snd_printd("SKU: external_amp=0x%x\n", spec->cdefine.external_amp);
1362 snd_printd("SKU: platform_type=0x%x\n", spec->cdefine.platform_type);
1363 snd_printd("SKU: swap=0x%x\n", spec->cdefine.swap);
1364 snd_printd("SKU: override=0x%x\n", spec->cdefine.override);
1369 /* check subsystem ID and set up device-specific initialization;
1370 * return 1 if initialized, 0 if invalid SSID
1372 /* 32-bit subsystem ID for BIOS loading in HD Audio codec.
1373 * 31 ~ 16 : Manufacture ID
1375 * 7 ~ 0 : Assembly ID
1376 * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36
1378 static int alc_subsystem_id(struct hda_codec *codec,
1379 hda_nid_t porta, hda_nid_t porte,
1380 hda_nid_t portd, hda_nid_t porti)
1382 unsigned int ass, tmp, i;
1384 struct alc_spec *spec = codec->spec;
1386 ass = codec->subsystem_id & 0xffff;
1387 if ((ass != codec->bus->pci->subsystem_device) && (ass & 1))
1390 /* invalid SSID, check the special NID pin defcfg instead */
1392 * 31~30 : port connectivity
1395 * 19~16 : Check sum (15:1)
1400 if (codec->vendor_id == 0x10ec0260)
1402 ass = snd_hda_codec_get_pincfg(codec, nid);
1403 snd_printd("realtek: No valid SSID, "
1404 "checking pincfg 0x%08x for NID 0x%x\n",
1408 if ((ass >> 30) != 1) /* no physical connection */
1413 for (i = 1; i < 16; i++) {
1417 if (((ass >> 16) & 0xf) != tmp)
1420 snd_printd("realtek: Enabling init ASM_ID=0x%04x CODEC_ID=%08x\n",
1421 ass & 0xffff, codec->vendor_id);
1425 * 2 : 0 --> Desktop, 1 --> Laptop
1426 * 3~5 : External Amplifier control
1429 tmp = (ass & 0x38) >> 3; /* external Amp control */
1432 spec->init_amp = ALC_INIT_GPIO1;
1435 spec->init_amp = ALC_INIT_GPIO2;
1438 spec->init_amp = ALC_INIT_GPIO3;
1441 spec->init_amp = ALC_INIT_DEFAULT;
1445 /* is laptop or Desktop and enable the function "Mute internal speaker
1446 * when the external headphone out jack is plugged"
1448 if (!(ass & 0x8000))
1451 * 10~8 : Jack location
1452 * 12~11: Headphone out -> 00: PortA, 01: PortE, 02: PortD, 03: Resvered
1454 * 15 : 1 --> enable the function "Mute internal speaker
1455 * when the external headphone out jack is plugged"
1457 if (!spec->autocfg.hp_pins[0]) {
1459 tmp = (ass >> 11) & 0x3; /* HP to chassis */
1470 for (i = 0; i < spec->autocfg.line_outs; i++)
1471 if (spec->autocfg.line_out_pins[i] == nid)
1473 spec->autocfg.hp_pins[0] = nid;
1476 alc_init_auto_hp(codec);
1477 alc_init_auto_mic(codec);
1481 static void alc_ssid_check(struct hda_codec *codec,
1482 hda_nid_t porta, hda_nid_t porte,
1483 hda_nid_t portd, hda_nid_t porti)
1485 if (!alc_subsystem_id(codec, porta, porte, portd, porti)) {
1486 struct alc_spec *spec = codec->spec;
1487 snd_printd("realtek: "
1488 "Enable default setup for auto mode as fallback\n");
1489 spec->init_amp = ALC_INIT_DEFAULT;
1490 alc_init_auto_hp(codec);
1491 alc_init_auto_mic(codec);
1496 * Fix-up pin default configurations and add default verbs
1505 const struct alc_pincfg *pins;
1506 const struct hda_verb *verbs;
1509 static void alc_pick_fixup(struct hda_codec *codec,
1510 const struct snd_pci_quirk *quirk,
1511 const struct alc_fixup *fix,
1514 const struct alc_pincfg *cfg;
1516 quirk = snd_pci_quirk_lookup(codec->bus->pci, quirk);
1519 fix += quirk->value;
1521 if (pre_init && cfg) {
1522 #ifdef CONFIG_SND_DEBUG_VERBOSE
1523 snd_printdd(KERN_INFO "hda_codec: %s: Apply pincfg for %s\n",
1524 codec->chip_name, quirk->name);
1526 for (; cfg->nid; cfg++)
1527 snd_hda_codec_set_pincfg(codec, cfg->nid, cfg->val);
1529 if (!pre_init && fix->verbs) {
1530 #ifdef CONFIG_SND_DEBUG_VERBOSE
1531 snd_printdd(KERN_INFO "hda_codec: %s: Apply fix-verbs for %s\n",
1532 codec->chip_name, quirk->name);
1534 add_verb(codec->spec, fix->verbs);
1538 static int alc_read_coef_idx(struct hda_codec *codec,
1539 unsigned int coef_idx)
1542 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX,
1544 val = snd_hda_codec_read(codec, 0x20, 0,
1545 AC_VERB_GET_PROC_COEF, 0);
1549 /* set right pin controls for digital I/O */
1550 static void alc_auto_init_digital(struct hda_codec *codec)
1552 struct alc_spec *spec = codec->spec;
1556 for (i = 0; i < spec->autocfg.dig_outs; i++) {
1557 pin = spec->autocfg.dig_out_pins[i];
1559 snd_hda_codec_write(codec, pin, 0,
1560 AC_VERB_SET_PIN_WIDGET_CONTROL,
1564 pin = spec->autocfg.dig_in_pin;
1566 snd_hda_codec_write(codec, pin, 0,
1567 AC_VERB_SET_PIN_WIDGET_CONTROL,
1571 /* parse digital I/Os and set up NIDs in BIOS auto-parse mode */
1572 static void alc_auto_parse_digital(struct hda_codec *codec)
1574 struct alc_spec *spec = codec->spec;
1578 /* support multiple SPDIFs; the secondary is set up as a slave */
1579 for (i = 0; i < spec->autocfg.dig_outs; i++) {
1580 err = snd_hda_get_connections(codec,
1581 spec->autocfg.dig_out_pins[i],
1586 spec->multiout.dig_out_nid = dig_nid;
1587 spec->dig_out_type = spec->autocfg.dig_out_type[0];
1589 spec->multiout.slave_dig_outs = spec->slave_dig_outs;
1590 if (i >= ARRAY_SIZE(spec->slave_dig_outs) - 1)
1592 spec->slave_dig_outs[i - 1] = dig_nid;
1596 if (spec->autocfg.dig_in_pin) {
1598 err = snd_hda_get_connections(codec,
1599 spec->autocfg.dig_in_pin,
1602 spec->dig_in_nid = dig_nid;
1613 static struct hda_verb alc888_4ST_ch2_intel_init[] = {
1614 /* Mic-in jack as mic in */
1615 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1616 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1617 /* Line-in jack as Line in */
1618 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1619 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1620 /* Line-Out as Front */
1621 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
1628 static struct hda_verb alc888_4ST_ch4_intel_init[] = {
1629 /* Mic-in jack as mic in */
1630 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1631 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1632 /* Line-in jack as Surround */
1633 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1634 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1635 /* Line-Out as Front */
1636 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
1643 static struct hda_verb alc888_4ST_ch6_intel_init[] = {
1644 /* Mic-in jack as CLFE */
1645 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1646 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1647 /* Line-in jack as Surround */
1648 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1649 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1650 /* Line-Out as CLFE (workaround because Mic-in is not loud enough) */
1651 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1658 static struct hda_verb alc888_4ST_ch8_intel_init[] = {
1659 /* Mic-in jack as CLFE */
1660 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1661 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1662 /* Line-in jack as Surround */
1663 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1664 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1665 /* Line-Out as Side */
1666 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1670 static struct hda_channel_mode alc888_4ST_8ch_intel_modes[4] = {
1671 { 2, alc888_4ST_ch2_intel_init },
1672 { 4, alc888_4ST_ch4_intel_init },
1673 { 6, alc888_4ST_ch6_intel_init },
1674 { 8, alc888_4ST_ch8_intel_init },
1678 * ALC888 Fujitsu Siemens Amillo xa3530
1681 static struct hda_verb alc888_fujitsu_xa3530_verbs[] = {
1682 /* Front Mic: set to PIN_IN (empty by default) */
1683 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1684 /* Connect Internal HP to Front */
1685 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1686 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1687 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1688 /* Connect Bass HP to Front */
1689 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1690 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1691 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1692 /* Connect Line-Out side jack (SPDIF) to Side */
1693 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1694 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1695 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1696 /* Connect Mic jack to CLFE */
1697 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1698 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1699 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02},
1700 /* Connect Line-in jack to Surround */
1701 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1702 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1703 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
1704 /* Connect HP out jack to Front */
1705 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1706 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1707 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
1708 /* Enable unsolicited event for HP jack and Line-out jack */
1709 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1710 {0x17, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1714 static void alc_automute_amp(struct hda_codec *codec)
1716 struct alc_spec *spec = codec->spec;
1721 spec->jack_present = 0;
1722 for (i = 0; i < ARRAY_SIZE(spec->autocfg.hp_pins); i++) {
1723 nid = spec->autocfg.hp_pins[i];
1726 if (snd_hda_jack_detect(codec, nid)) {
1727 spec->jack_present = 1;
1732 mute = spec->jack_present ? HDA_AMP_MUTE : 0;
1733 /* Toggle internal speakers muting */
1734 for (i = 0; i < ARRAY_SIZE(spec->autocfg.speaker_pins); i++) {
1735 nid = spec->autocfg.speaker_pins[i];
1738 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
1739 HDA_AMP_MUTE, mute);
1743 static void alc_automute_amp_unsol_event(struct hda_codec *codec,
1746 if (codec->vendor_id == 0x10ec0880)
1750 if (res == ALC880_HP_EVENT)
1751 alc_automute_amp(codec);
1754 static void alc889_automute_setup(struct hda_codec *codec)
1756 struct alc_spec *spec = codec->spec;
1758 spec->autocfg.hp_pins[0] = 0x15;
1759 spec->autocfg.speaker_pins[0] = 0x14;
1760 spec->autocfg.speaker_pins[1] = 0x16;
1761 spec->autocfg.speaker_pins[2] = 0x17;
1762 spec->autocfg.speaker_pins[3] = 0x19;
1763 spec->autocfg.speaker_pins[4] = 0x1a;
1766 static void alc889_intel_init_hook(struct hda_codec *codec)
1768 alc889_coef_init(codec);
1769 alc_automute_amp(codec);
1772 static void alc888_fujitsu_xa3530_setup(struct hda_codec *codec)
1774 struct alc_spec *spec = codec->spec;
1776 spec->autocfg.hp_pins[0] = 0x17; /* line-out */
1777 spec->autocfg.hp_pins[1] = 0x1b; /* hp */
1778 spec->autocfg.speaker_pins[0] = 0x14; /* speaker */
1779 spec->autocfg.speaker_pins[1] = 0x15; /* bass */
1783 * ALC888 Acer Aspire 4930G model
1786 static struct hda_verb alc888_acer_aspire_4930g_verbs[] = {
1787 /* Front Mic: set to PIN_IN (empty by default) */
1788 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1789 /* Unselect Front Mic by default in input mixer 3 */
1790 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
1791 /* Enable unsolicited event for HP jack */
1792 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1793 /* Connect Internal HP to front */
1794 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1795 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1796 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1797 /* Connect HP out to front */
1798 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1799 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1800 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1805 * ALC888 Acer Aspire 6530G model
1808 static struct hda_verb alc888_acer_aspire_6530g_verbs[] = {
1809 /* Route to built-in subwoofer as well as speakers */
1810 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1811 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1812 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1813 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1814 /* Bias voltage on for external mic port */
1815 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN | PIN_VREF80},
1816 /* Front Mic: set to PIN_IN (empty by default) */
1817 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1818 /* Unselect Front Mic by default in input mixer 3 */
1819 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
1820 /* Enable unsolicited event for HP jack */
1821 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1822 /* Enable speaker output */
1823 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1824 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1825 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
1826 /* Enable headphone output */
1827 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | PIN_HP},
1828 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1829 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1830 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
1835 * ALC889 Acer Aspire 8930G model
1838 static struct hda_verb alc889_acer_aspire_8930g_verbs[] = {
1839 /* Front Mic: set to PIN_IN (empty by default) */
1840 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1841 /* Unselect Front Mic by default in input mixer 3 */
1842 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
1843 /* Enable unsolicited event for HP jack */
1844 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1845 /* Connect Internal Front to Front */
1846 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1847 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1848 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1849 /* Connect Internal Rear to Rear */
1850 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1851 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1852 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01},
1853 /* Connect Internal CLFE to CLFE */
1854 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1855 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1856 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
1857 /* Connect HP out to Front */
1858 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | PIN_HP},
1859 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1860 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1861 /* Enable all DACs */
1862 /* DAC DISABLE/MUTE 1? */
1863 /* setting bits 1-5 disables DAC nids 0x02-0x06 apparently. Init=0x38 */
1864 {0x20, AC_VERB_SET_COEF_INDEX, 0x03},
1865 {0x20, AC_VERB_SET_PROC_COEF, 0x0000},
1866 /* DAC DISABLE/MUTE 2? */
1867 /* some bit here disables the other DACs. Init=0x4900 */
1868 {0x20, AC_VERB_SET_COEF_INDEX, 0x08},
1869 {0x20, AC_VERB_SET_PROC_COEF, 0x0000},
1871 * This laptop has a stereo digital microphone. The mics are only 1cm apart
1872 * which makes the stereo useless. However, either the mic or the ALC889
1873 * makes the signal become a difference/sum signal instead of standard
1874 * stereo, which is annoying. So instead we flip this bit which makes the
1875 * codec replicate the sum signal to both channels, turning it into a
1878 /* DMIC_CONTROL? Init value = 0x0001 */
1879 {0x20, AC_VERB_SET_COEF_INDEX, 0x0b},
1880 {0x20, AC_VERB_SET_PROC_COEF, 0x0003},
1884 static struct hda_input_mux alc888_2_capture_sources[2] = {
1885 /* Front mic only available on one ADC */
1892 { "Front Mic", 0xb },
1905 static struct hda_input_mux alc888_acer_aspire_6530_sources[2] = {
1906 /* Interal mic only available on one ADC */
1913 { "Input Mix", 0xa },
1923 { "Input Mix", 0xa },
1928 static struct hda_input_mux alc889_capture_sources[3] = {
1929 /* Digital mic only available on first "ADC" */
1936 { "Front Mic", 0xb },
1937 { "Input Mix", 0xa },
1946 { "Input Mix", 0xa },
1955 { "Input Mix", 0xa },
1960 static struct snd_kcontrol_new alc888_base_mixer[] = {
1961 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1962 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1963 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1964 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
1965 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
1967 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1968 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1969 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1970 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
1971 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
1972 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1973 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1974 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1975 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1976 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1977 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
1978 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1982 static struct snd_kcontrol_new alc889_acer_aspire_8930g_mixer[] = {
1983 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1984 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1985 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1986 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
1987 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
1989 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1990 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1991 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1992 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1993 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1994 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1995 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
1996 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2001 static void alc888_acer_aspire_4930g_setup(struct hda_codec *codec)
2003 struct alc_spec *spec = codec->spec;
2005 spec->autocfg.hp_pins[0] = 0x15;
2006 spec->autocfg.speaker_pins[0] = 0x14;
2007 spec->autocfg.speaker_pins[1] = 0x16;
2008 spec->autocfg.speaker_pins[2] = 0x17;
2011 static void alc888_acer_aspire_6530g_setup(struct hda_codec *codec)
2013 struct alc_spec *spec = codec->spec;
2015 spec->autocfg.hp_pins[0] = 0x15;
2016 spec->autocfg.speaker_pins[0] = 0x14;
2017 spec->autocfg.speaker_pins[1] = 0x16;
2018 spec->autocfg.speaker_pins[2] = 0x17;
2021 static void alc889_acer_aspire_8930g_setup(struct hda_codec *codec)
2023 struct alc_spec *spec = codec->spec;
2025 spec->autocfg.hp_pins[0] = 0x15;
2026 spec->autocfg.speaker_pins[0] = 0x14;
2027 spec->autocfg.speaker_pins[1] = 0x16;
2028 spec->autocfg.speaker_pins[2] = 0x1b;
2032 * ALC880 3-stack model
2034 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
2035 * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18,
2036 * F-Mic = 0x1b, HP = 0x19
2039 static hda_nid_t alc880_dac_nids[4] = {
2040 /* front, rear, clfe, rear_surr */
2041 0x02, 0x05, 0x04, 0x03
2044 static hda_nid_t alc880_adc_nids[3] = {
2049 /* The datasheet says the node 0x07 is connected from inputs,
2050 * but it shows zero connection in the real implementation on some devices.
2051 * Note: this is a 915GAV bug, fixed on 915GLV
2053 static hda_nid_t alc880_adc_nids_alt[2] = {
2058 #define ALC880_DIGOUT_NID 0x06
2059 #define ALC880_DIGIN_NID 0x0a
2061 static struct hda_input_mux alc880_capture_source = {
2065 { "Front Mic", 0x3 },
2071 /* channel source setting (2/6 channel selection for 3-stack) */
2073 static struct hda_verb alc880_threestack_ch2_init[] = {
2074 /* set line-in to input, mute it */
2075 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
2076 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
2077 /* set mic-in to input vref 80%, mute it */
2078 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
2079 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
2084 static struct hda_verb alc880_threestack_ch6_init[] = {
2085 /* set line-in to output, unmute it */
2086 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
2087 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
2088 /* set mic-in to output, unmute it */
2089 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
2090 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
2094 static struct hda_channel_mode alc880_threestack_modes[2] = {
2095 { 2, alc880_threestack_ch2_init },
2096 { 6, alc880_threestack_ch6_init },
2099 static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
2100 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2101 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2102 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
2103 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
2104 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2105 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2106 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2107 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2108 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2109 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2110 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2111 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2112 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2113 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2114 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
2115 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
2116 HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
2118 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2119 .name = "Channel Mode",
2120 .info = alc_ch_mode_info,
2121 .get = alc_ch_mode_get,
2122 .put = alc_ch_mode_put,
2127 /* capture mixer elements */
2128 static int alc_cap_vol_info(struct snd_kcontrol *kcontrol,
2129 struct snd_ctl_elem_info *uinfo)
2131 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2132 struct alc_spec *spec = codec->spec;
2135 mutex_lock(&codec->control_mutex);
2136 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0,
2138 err = snd_hda_mixer_amp_volume_info(kcontrol, uinfo);
2139 mutex_unlock(&codec->control_mutex);
2143 static int alc_cap_vol_tlv(struct snd_kcontrol *kcontrol, int op_flag,
2144 unsigned int size, unsigned int __user *tlv)
2146 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2147 struct alc_spec *spec = codec->spec;
2150 mutex_lock(&codec->control_mutex);
2151 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0,
2153 err = snd_hda_mixer_amp_tlv(kcontrol, op_flag, size, tlv);
2154 mutex_unlock(&codec->control_mutex);
2158 typedef int (*getput_call_t)(struct snd_kcontrol *kcontrol,
2159 struct snd_ctl_elem_value *ucontrol);
2161 static int alc_cap_getput_caller(struct snd_kcontrol *kcontrol,
2162 struct snd_ctl_elem_value *ucontrol,
2165 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2166 struct alc_spec *spec = codec->spec;
2167 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
2170 mutex_lock(&codec->control_mutex);
2171 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[adc_idx],
2173 err = func(kcontrol, ucontrol);
2174 mutex_unlock(&codec->control_mutex);
2178 static int alc_cap_vol_get(struct snd_kcontrol *kcontrol,
2179 struct snd_ctl_elem_value *ucontrol)
2181 return alc_cap_getput_caller(kcontrol, ucontrol,
2182 snd_hda_mixer_amp_volume_get);
2185 static int alc_cap_vol_put(struct snd_kcontrol *kcontrol,
2186 struct snd_ctl_elem_value *ucontrol)
2188 return alc_cap_getput_caller(kcontrol, ucontrol,
2189 snd_hda_mixer_amp_volume_put);
2192 /* capture mixer elements */
2193 #define alc_cap_sw_info snd_ctl_boolean_stereo_info
2195 static int alc_cap_sw_get(struct snd_kcontrol *kcontrol,
2196 struct snd_ctl_elem_value *ucontrol)
2198 return alc_cap_getput_caller(kcontrol, ucontrol,
2199 snd_hda_mixer_amp_switch_get);
2202 static int alc_cap_sw_put(struct snd_kcontrol *kcontrol,
2203 struct snd_ctl_elem_value *ucontrol)
2205 return alc_cap_getput_caller(kcontrol, ucontrol,
2206 snd_hda_mixer_amp_switch_put);
2209 #define _DEFINE_CAPMIX(num) \
2211 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2212 .name = "Capture Switch", \
2213 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, \
2215 .info = alc_cap_sw_info, \
2216 .get = alc_cap_sw_get, \
2217 .put = alc_cap_sw_put, \
2220 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2221 .name = "Capture Volume", \
2222 .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE | \
2223 SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
2224 SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK), \
2226 .info = alc_cap_vol_info, \
2227 .get = alc_cap_vol_get, \
2228 .put = alc_cap_vol_put, \
2229 .tlv = { .c = alc_cap_vol_tlv }, \
2232 #define _DEFINE_CAPSRC(num) \
2234 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2235 /* .name = "Capture Source", */ \
2236 .name = "Input Source", \
2238 .info = alc_mux_enum_info, \
2239 .get = alc_mux_enum_get, \
2240 .put = alc_mux_enum_put, \
2243 #define DEFINE_CAPMIX(num) \
2244 static struct snd_kcontrol_new alc_capture_mixer ## num[] = { \
2245 _DEFINE_CAPMIX(num), \
2246 _DEFINE_CAPSRC(num), \
2250 #define DEFINE_CAPMIX_NOSRC(num) \
2251 static struct snd_kcontrol_new alc_capture_mixer_nosrc ## num[] = { \
2252 _DEFINE_CAPMIX(num), \
2256 /* up to three ADCs */
2260 DEFINE_CAPMIX_NOSRC(1);
2261 DEFINE_CAPMIX_NOSRC(2);
2262 DEFINE_CAPMIX_NOSRC(3);
2265 * ALC880 5-stack model
2267 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d),
2269 * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
2270 * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
2273 /* additional mixers to alc880_three_stack_mixer */
2274 static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
2275 HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2276 HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
2280 /* channel source setting (6/8 channel selection for 5-stack) */
2282 static struct hda_verb alc880_fivestack_ch6_init[] = {
2283 /* set line-in to input, mute it */
2284 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
2285 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
2290 static struct hda_verb alc880_fivestack_ch8_init[] = {
2291 /* set line-in to output, unmute it */
2292 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
2293 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
2297 static struct hda_channel_mode alc880_fivestack_modes[2] = {
2298 { 6, alc880_fivestack_ch6_init },
2299 { 8, alc880_fivestack_ch8_init },
2304 * ALC880 6-stack model
2306 * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e),
2307 * Side = 0x05 (0x0f)
2308 * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
2309 * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
2312 static hda_nid_t alc880_6st_dac_nids[4] = {
2313 /* front, rear, clfe, rear_surr */
2314 0x02, 0x03, 0x04, 0x05
2317 static struct hda_input_mux alc880_6stack_capture_source = {
2321 { "Front Mic", 0x1 },
2327 /* fixed 8-channels */
2328 static struct hda_channel_mode alc880_sixstack_modes[1] = {
2332 static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
2333 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2334 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2335 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2336 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
2337 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2338 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2339 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2340 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2341 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
2342 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
2343 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2344 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2345 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2346 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2347 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2348 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2349 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2350 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
2352 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2353 .name = "Channel Mode",
2354 .info = alc_ch_mode_info,
2355 .get = alc_ch_mode_get,
2356 .put = alc_ch_mode_put,
2365 * W810 has rear IO for:
2368 * Center/LFE (DAC 04)
2371 * The system also has a pair of internal speakers, and a headphone jack.
2372 * These are both connected to Line2 on the codec, hence to DAC 02.
2374 * There is a variable resistor to control the speaker or headphone
2375 * volume. This is a hardware-only device without a software API.
2377 * Plugging headphones in will disable the internal speakers. This is
2378 * implemented in hardware, not via the driver using jack sense. In
2379 * a similar fashion, plugging into the rear socket marked "front" will
2380 * disable both the speakers and headphones.
2382 * For input, there's a microphone jack, and an "audio in" jack.
2383 * These may not do anything useful with this driver yet, because I
2384 * haven't setup any initialization verbs for these yet...
2387 static hda_nid_t alc880_w810_dac_nids[3] = {
2388 /* front, rear/surround, clfe */
2392 /* fixed 6 channels */
2393 static struct hda_channel_mode alc880_w810_modes[1] = {
2397 /* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
2398 static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
2399 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2400 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2401 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2402 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
2403 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2404 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2405 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2406 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2407 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
2415 * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
2416 * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?),
2420 static hda_nid_t alc880_z71v_dac_nids[1] = {
2423 #define ALC880_Z71V_HP_DAC 0x03
2425 /* fixed 2 channels */
2426 static struct hda_channel_mode alc880_2_jack_modes[1] = {
2430 static struct snd_kcontrol_new alc880_z71v_mixer[] = {
2431 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2432 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2433 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2434 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
2435 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2436 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2437 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2438 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2444 * ALC880 F1734 model
2446 * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
2447 * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
2450 static hda_nid_t alc880_f1734_dac_nids[1] = {
2453 #define ALC880_F1734_HP_DAC 0x02
2455 static struct snd_kcontrol_new alc880_f1734_mixer[] = {
2456 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2457 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2458 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2459 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
2460 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2461 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2462 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2463 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
2467 static struct hda_input_mux alc880_f1734_capture_source = {
2479 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
2480 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
2481 * Mic = 0x18, Line = 0x1a
2484 #define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
2485 #define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
2487 static struct snd_kcontrol_new alc880_asus_mixer[] = {
2488 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2489 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2490 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2491 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
2492 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2493 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2494 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2495 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2496 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2497 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2498 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2499 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2500 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2501 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2503 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2504 .name = "Channel Mode",
2505 .info = alc_ch_mode_info,
2506 .get = alc_ch_mode_get,
2507 .put = alc_ch_mode_put,
2513 * ALC880 ASUS W1V model
2515 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
2516 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
2517 * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
2520 /* additional mixers to alc880_asus_mixer */
2521 static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
2522 HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
2523 HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
2528 static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
2529 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2530 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
2531 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
2532 HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
2533 HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
2534 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
2535 HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
2536 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
2537 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
2542 static struct snd_kcontrol_new alc880_uniwill_mixer[] = {
2543 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2544 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2545 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2546 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
2547 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2548 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2549 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2550 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2551 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2552 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2553 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2554 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2555 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2556 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2557 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2558 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
2560 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2561 .name = "Channel Mode",
2562 .info = alc_ch_mode_info,
2563 .get = alc_ch_mode_get,
2564 .put = alc_ch_mode_put,
2569 static struct snd_kcontrol_new alc880_fujitsu_mixer[] = {
2570 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2571 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2572 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2573 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
2574 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2575 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2576 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2577 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2578 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2579 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
2583 static struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = {
2584 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2585 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2586 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2587 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
2588 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2589 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2594 * virtual master controls
2598 * slave controls for virtual master
2600 static const char *alc_slave_vols[] = {
2601 "Front Playback Volume",
2602 "Surround Playback Volume",
2603 "Center Playback Volume",
2604 "LFE Playback Volume",
2605 "Side Playback Volume",
2606 "Headphone Playback Volume",
2607 "Speaker Playback Volume",
2608 "Mono Playback Volume",
2609 "Line-Out Playback Volume",
2610 "PCM Playback Volume",
2614 static const char *alc_slave_sws[] = {
2615 "Front Playback Switch",
2616 "Surround Playback Switch",
2617 "Center Playback Switch",
2618 "LFE Playback Switch",
2619 "Side Playback Switch",
2620 "Headphone Playback Switch",
2621 "Speaker Playback Switch",
2622 "Mono Playback Switch",
2623 "IEC958 Playback Switch",
2624 "Line-Out Playback Switch",
2625 "PCM Playback Switch",
2630 * build control elements
2633 #define NID_MAPPING (-1)
2635 #define SUBDEV_SPEAKER_ (0 << 6)
2636 #define SUBDEV_HP_ (1 << 6)
2637 #define SUBDEV_LINE_ (2 << 6)
2638 #define SUBDEV_SPEAKER(x) (SUBDEV_SPEAKER_ | ((x) & 0x3f))
2639 #define SUBDEV_HP(x) (SUBDEV_HP_ | ((x) & 0x3f))
2640 #define SUBDEV_LINE(x) (SUBDEV_LINE_ | ((x) & 0x3f))
2642 static void alc_free_kctls(struct hda_codec *codec);
2644 #ifdef CONFIG_SND_HDA_INPUT_BEEP
2645 /* additional beep mixers; the actual parameters are overwritten at build */
2646 static struct snd_kcontrol_new alc_beep_mixer[] = {
2647 HDA_CODEC_VOLUME("Beep Playback Volume", 0, 0, HDA_INPUT),
2648 HDA_CODEC_MUTE_BEEP("Beep Playback Switch", 0, 0, HDA_INPUT),
2653 static int alc_build_controls(struct hda_codec *codec)
2655 struct alc_spec *spec = codec->spec;
2656 struct snd_kcontrol *kctl = NULL;
2657 struct snd_kcontrol_new *knew;
2662 for (i = 0; i < spec->num_mixers; i++) {
2663 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
2667 if (spec->cap_mixer) {
2668 err = snd_hda_add_new_ctls(codec, spec->cap_mixer);
2672 if (spec->multiout.dig_out_nid) {
2673 err = snd_hda_create_spdif_out_ctls(codec,
2674 spec->multiout.dig_out_nid);
2677 if (!spec->no_analog) {
2678 err = snd_hda_create_spdif_share_sw(codec,
2682 spec->multiout.share_spdif = 1;
2685 if (spec->dig_in_nid) {
2686 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
2691 #ifdef CONFIG_SND_HDA_INPUT_BEEP
2692 /* create beep controls if needed */
2693 if (spec->beep_amp) {
2694 struct snd_kcontrol_new *knew;
2695 for (knew = alc_beep_mixer; knew->name; knew++) {
2696 struct snd_kcontrol *kctl;
2697 kctl = snd_ctl_new1(knew, codec);
2700 kctl->private_value = spec->beep_amp;
2701 err = snd_hda_ctl_add(codec, 0, kctl);
2708 /* if we have no master control, let's create it */
2709 if (!spec->no_analog &&
2710 !snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
2711 unsigned int vmaster_tlv[4];
2712 snd_hda_set_vmaster_tlv(codec, spec->vmaster_nid,
2713 HDA_OUTPUT, vmaster_tlv);
2714 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
2715 vmaster_tlv, alc_slave_vols);
2719 if (!spec->no_analog &&
2720 !snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
2721 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
2722 NULL, alc_slave_sws);
2727 /* assign Capture Source enums to NID */
2728 if (spec->capsrc_nids || spec->adc_nids) {
2729 kctl = snd_hda_find_mixer_ctl(codec, "Capture Source");
2731 kctl = snd_hda_find_mixer_ctl(codec, "Input Source");
2732 for (i = 0; kctl && i < kctl->count; i++) {
2733 hda_nid_t *nids = spec->capsrc_nids;
2735 nids = spec->adc_nids;
2736 err = snd_hda_add_nid(codec, kctl, i, nids[i]);
2741 if (spec->cap_mixer) {
2742 const char *kname = kctl ? kctl->id.name : NULL;
2743 for (knew = spec->cap_mixer; knew->name; knew++) {
2744 if (kname && strcmp(knew->name, kname) == 0)
2746 kctl = snd_hda_find_mixer_ctl(codec, knew->name);
2747 for (i = 0; kctl && i < kctl->count; i++) {
2748 err = snd_hda_add_nid(codec, kctl, i,
2756 /* other nid->control mapping */
2757 for (i = 0; i < spec->num_mixers; i++) {
2758 for (knew = spec->mixers[i]; knew->name; knew++) {
2759 if (knew->iface != NID_MAPPING)
2761 kctl = snd_hda_find_mixer_ctl(codec, knew->name);
2764 u = knew->subdevice;
2765 for (j = 0; j < 4; j++, u >>= 8) {
2770 case SUBDEV_SPEAKER_:
2771 nid = spec->autocfg.speaker_pins[nid];
2774 nid = spec->autocfg.line_out_pins[nid];
2777 nid = spec->autocfg.hp_pins[nid];
2782 err = snd_hda_add_nid(codec, kctl, 0, nid);
2786 u = knew->private_value;
2787 for (j = 0; j < 4; j++, u >>= 8) {
2791 err = snd_hda_add_nid(codec, kctl, 0, nid);
2798 alc_free_kctls(codec); /* no longer needed */
2805 * initialize the codec volumes, etc
2809 * generic initialization of ADC, input mixers and output mixers
2811 static struct hda_verb alc880_volume_init_verbs[] = {
2813 * Unmute ADC0-2 and set the default input to mic-in
2815 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
2816 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2817 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
2818 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2819 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
2820 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2822 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
2824 * Note: PASD motherboards uses the Line In 2 as the input for front
2827 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
2828 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2829 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2830 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
2831 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
2832 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
2833 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
2834 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
2837 * Set up output mixers (0x0c - 0x0f)
2839 /* set vol=0 to output mixers */
2840 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2841 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2842 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2843 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2844 /* set up input amps for analog loopback */
2845 /* Amp Indices: DAC = 0, mixer = 1 */
2846 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2847 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2848 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2849 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2850 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2851 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2852 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2853 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2859 * 3-stack pin configuration:
2860 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
2862 static struct hda_verb alc880_pin_3stack_init_verbs[] = {
2864 * preset connection lists of input pins
2865 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
2867 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
2868 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2869 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
2872 * Set pin mode and muting
2874 /* set front pin widgets 0x14 for output */
2875 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2876 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2877 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2878 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2879 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2880 /* Mic2 (as headphone out) for HP output */
2881 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2882 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2883 /* Line In pin widget for input */
2884 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2885 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2886 /* Line2 (as front mic) pin widget for input and vref at 80% */
2887 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2888 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2889 /* CD pin widget for input */
2890 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2896 * 5-stack pin configuration:
2897 * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
2898 * line-in/side = 0x1a, f-mic = 0x1b
2900 static struct hda_verb alc880_pin_5stack_init_verbs[] = {
2902 * preset connection lists of input pins
2903 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
2905 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2906 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
2909 * Set pin mode and muting
2911 /* set pin widgets 0x14-0x17 for output */
2912 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2913 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2914 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2915 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2916 /* unmute pins for output (no gain on this amp) */
2917 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2918 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2919 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2920 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2922 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2923 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2924 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2925 /* Mic2 (as headphone out) for HP output */
2926 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2927 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2928 /* Line In pin widget for input */
2929 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2930 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2931 /* Line2 (as front mic) pin widget for input and vref at 80% */
2932 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2933 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2934 /* CD pin widget for input */
2935 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2941 * W810 pin configuration:
2942 * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
2944 static struct hda_verb alc880_pin_w810_init_verbs[] = {
2945 /* hphone/speaker input selector: front DAC */
2946 {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
2948 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2949 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2950 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2951 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2952 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2953 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2955 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2956 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2962 * Z71V pin configuration:
2963 * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
2965 static struct hda_verb alc880_pin_z71v_init_verbs[] = {
2966 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2967 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2968 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2969 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2971 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2972 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2973 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2974 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2980 * 6-stack pin configuration:
2981 * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18,
2982 * f-mic = 0x19, line = 0x1a, HP = 0x1b
2984 static struct hda_verb alc880_pin_6stack_init_verbs[] = {
2985 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2987 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2988 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2989 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2990 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2991 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2992 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2993 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2994 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2996 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2997 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2998 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2999 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3000 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3001 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3002 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3003 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3004 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3010 * Uniwill pin configuration:
3011 * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19,
3014 static struct hda_verb alc880_uniwill_init_verbs[] = {
3015 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3017 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3018 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3019 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3020 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3021 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3022 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3023 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3024 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3025 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3026 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3027 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3028 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3029 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3030 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3032 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3033 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3034 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3035 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3036 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3037 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3038 /* {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, */
3039 /* {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
3040 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3042 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
3043 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
3050 * HP = 0x14, InternalSpeaker = 0x15, mic = 0x19,
3052 static struct hda_verb alc880_uniwill_p53_init_verbs[] = {
3053 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3055 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3056 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3057 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3058 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3059 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3060 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3061 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3062 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3063 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3064 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3065 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3066 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3068 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3069 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3070 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3071 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3072 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3073 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3075 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
3076 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_DCVOL_EVENT},
3081 static struct hda_verb alc880_beep_init_verbs[] = {
3082 { 0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5) },
3086 /* auto-toggle front mic */
3087 static void alc880_uniwill_mic_automute(struct hda_codec *codec)
3089 unsigned int present;
3092 present = snd_hda_jack_detect(codec, 0x18);
3093 bits = present ? HDA_AMP_MUTE : 0;
3094 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
3097 static void alc880_uniwill_setup(struct hda_codec *codec)
3099 struct alc_spec *spec = codec->spec;
3101 spec->autocfg.hp_pins[0] = 0x14;
3102 spec->autocfg.speaker_pins[0] = 0x15;
3103 spec->autocfg.speaker_pins[0] = 0x16;
3106 static void alc880_uniwill_init_hook(struct hda_codec *codec)
3108 alc_automute_amp(codec);
3109 alc880_uniwill_mic_automute(codec);
3112 static void alc880_uniwill_unsol_event(struct hda_codec *codec,
3115 /* Looks like the unsol event is incompatible with the standard
3116 * definition. 4bit tag is placed at 28 bit!
3118 switch (res >> 28) {
3119 case ALC880_MIC_EVENT:
3120 alc880_uniwill_mic_automute(codec);
3123 alc_automute_amp_unsol_event(codec, res);
3128 static void alc880_uniwill_p53_setup(struct hda_codec *codec)
3130 struct alc_spec *spec = codec->spec;
3132 spec->autocfg.hp_pins[0] = 0x14;
3133 spec->autocfg.speaker_pins[0] = 0x15;
3136 static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec)
3138 unsigned int present;
3140 present = snd_hda_codec_read(codec, 0x21, 0,
3141 AC_VERB_GET_VOLUME_KNOB_CONTROL, 0);
3142 present &= HDA_AMP_VOLMASK;
3143 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0,
3144 HDA_AMP_VOLMASK, present);
3145 snd_hda_codec_amp_stereo(codec, 0x0d, HDA_OUTPUT, 0,
3146 HDA_AMP_VOLMASK, present);
3149 static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec,
3152 /* Looks like the unsol event is incompatible with the standard
3153 * definition. 4bit tag is placed at 28 bit!
3155 if ((res >> 28) == ALC880_DCVOL_EVENT)
3156 alc880_uniwill_p53_dcvol_automute(codec);
3158 alc_automute_amp_unsol_event(codec, res);
3162 * F1734 pin configuration:
3163 * HP = 0x14, speaker-out = 0x15, mic = 0x18
3165 static struct hda_verb alc880_pin_f1734_init_verbs[] = {
3166 {0x07, AC_VERB_SET_CONNECT_SEL, 0x01},
3167 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
3168 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
3169 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
3170 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
3172 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3173 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3174 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3175 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3177 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3178 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3179 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
3180 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3181 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3182 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3183 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3184 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3185 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3187 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
3188 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_DCVOL_EVENT},
3194 * ASUS pin configuration:
3195 * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
3197 static struct hda_verb alc880_pin_asus_init_verbs[] = {
3198 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
3199 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
3200 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
3201 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
3203 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3204 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3205 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3206 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3207 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3208 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3209 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3210 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3212 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3213 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3214 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3215 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3216 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3217 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3218 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3219 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3220 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3225 /* Enable GPIO mask and set output */
3226 #define alc880_gpio1_init_verbs alc_gpio1_init_verbs
3227 #define alc880_gpio2_init_verbs alc_gpio2_init_verbs
3228 #define alc880_gpio3_init_verbs alc_gpio3_init_verbs
3230 /* Clevo m520g init */
3231 static struct hda_verb alc880_pin_clevo_init_verbs[] = {
3232 /* headphone output */
3233 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
3235 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3236 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3238 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3239 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3241 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3242 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3243 /* Mic1 (rear panel) */
3244 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3245 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3246 /* Mic2 (front panel) */
3247 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3248 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3250 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3251 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3252 /* change to EAPD mode */
3253 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
3254 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
3259 static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
3260 /* change to EAPD mode */
3261 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
3262 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
3264 /* Headphone output */
3265 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3267 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3268 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
3270 /* Line In pin widget for input */
3271 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3272 /* CD pin widget for input */
3273 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3274 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3275 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3277 /* change to EAPD mode */
3278 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
3279 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
3285 * LG m1 express dual
3288 * Rear Line-In/Out (blue): 0x14
3289 * Build-in Mic-In: 0x15
3291 * HP-Out (green): 0x1b
3292 * Mic-In/Out (red): 0x19
3296 /* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
3297 static hda_nid_t alc880_lg_dac_nids[3] = {
3301 /* seems analog CD is not working */
3302 static struct hda_input_mux alc880_lg_capture_source = {
3307 { "Internal Mic", 0x6 },
3311 /* 2,4,6 channel modes */
3312 static struct hda_verb alc880_lg_ch2_init[] = {
3313 /* set line-in and mic-in to input */
3314 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
3315 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
3319 static struct hda_verb alc880_lg_ch4_init[] = {
3320 /* set line-in to out and mic-in to input */
3321 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
3322 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
3326 static struct hda_verb alc880_lg_ch6_init[] = {
3327 /* set line-in and mic-in to output */
3328 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
3329 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
3333 static struct hda_channel_mode alc880_lg_ch_modes[3] = {
3334 { 2, alc880_lg_ch2_init },
3335 { 4, alc880_lg_ch4_init },
3336 { 6, alc880_lg_ch6_init },
3339 static struct snd_kcontrol_new alc880_lg_mixer[] = {
3340 HDA_CODEC_VOLUME("Front Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
3341 HDA_BIND_MUTE("Front Playback Switch", 0x0f, 2, HDA_INPUT),
3342 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3343 HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
3344 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
3345 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
3346 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
3347 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
3348 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
3349 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
3350 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
3351 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
3352 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
3353 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
3355 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3356 .name = "Channel Mode",
3357 .info = alc_ch_mode_info,
3358 .get = alc_ch_mode_get,
3359 .put = alc_ch_mode_put,
3364 static struct hda_verb alc880_lg_init_verbs[] = {
3365 /* set capture source to mic-in */
3366 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3367 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3368 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3369 /* mute all amp mixer inputs */
3370 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
3371 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
3372 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
3373 /* line-in to input */
3374 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3375 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3377 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3378 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3380 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3381 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3382 /* mic-in to input */
3383 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
3384 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3385 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3387 {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
3388 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3389 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3391 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
3395 /* toggle speaker-output according to the hp-jack state */
3396 static void alc880_lg_setup(struct hda_codec *codec)
3398 struct alc_spec *spec = codec->spec;
3400 spec->autocfg.hp_pins[0] = 0x1b;
3401 spec->autocfg.speaker_pins[0] = 0x17;
3410 * Built-in Mic-In: 0x19
3416 static struct hda_input_mux alc880_lg_lw_capture_source = {
3420 { "Internal Mic", 0x1 },
3425 #define alc880_lg_lw_modes alc880_threestack_modes
3427 static struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
3428 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3429 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
3430 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
3431 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
3432 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
3433 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
3434 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
3435 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
3436 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
3437 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
3438 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
3439 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
3440 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
3441 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
3443 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3444 .name = "Channel Mode",
3445 .info = alc_ch_mode_info,
3446 .get = alc_ch_mode_get,
3447 .put = alc_ch_mode_put,
3452 static struct hda_verb alc880_lg_lw_init_verbs[] = {
3453 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3454 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
3455 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
3457 /* set capture source to mic-in */
3458 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3459 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3460 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3461 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
3463 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3464 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3466 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3467 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3468 /* mic-in to input */
3469 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3470 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3472 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3473 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3475 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
3479 /* toggle speaker-output according to the hp-jack state */
3480 static void alc880_lg_lw_setup(struct hda_codec *codec)
3482 struct alc_spec *spec = codec->spec;
3484 spec->autocfg.hp_pins[0] = 0x1b;
3485 spec->autocfg.speaker_pins[0] = 0x14;
3488 static struct snd_kcontrol_new alc880_medion_rim_mixer[] = {
3489 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3490 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
3491 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
3492 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
3493 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
3494 HDA_CODEC_MUTE("Internal Playback Switch", 0x0b, 0x1, HDA_INPUT),
3498 static struct hda_input_mux alc880_medion_rim_capture_source = {
3502 { "Internal Mic", 0x1 },
3506 static struct hda_verb alc880_medion_rim_init_verbs[] = {
3507 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3509 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3510 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3512 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3513 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3514 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3515 /* Mic2 (as headphone out) for HP output */
3516 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3517 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3518 /* Internal Speaker */
3519 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3520 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3522 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
3523 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
3525 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
3529 /* toggle speaker-output according to the hp-jack state */
3530 static void alc880_medion_rim_automute(struct hda_codec *codec)
3532 struct alc_spec *spec = codec->spec;
3533 alc_automute_amp(codec);
3535 if (spec->jack_present)
3536 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 0);
3538 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 2);
3541 static void alc880_medion_rim_unsol_event(struct hda_codec *codec,
3544 /* Looks like the unsol event is incompatible with the standard
3545 * definition. 4bit tag is placed at 28 bit!
3547 if ((res >> 28) == ALC880_HP_EVENT)
3548 alc880_medion_rim_automute(codec);
3551 static void alc880_medion_rim_setup(struct hda_codec *codec)
3553 struct alc_spec *spec = codec->spec;
3555 spec->autocfg.hp_pins[0] = 0x14;
3556 spec->autocfg.speaker_pins[0] = 0x1b;
3559 #ifdef CONFIG_SND_HDA_POWER_SAVE
3560 static struct hda_amp_list alc880_loopbacks[] = {
3561 { 0x0b, HDA_INPUT, 0 },
3562 { 0x0b, HDA_INPUT, 1 },
3563 { 0x0b, HDA_INPUT, 2 },
3564 { 0x0b, HDA_INPUT, 3 },
3565 { 0x0b, HDA_INPUT, 4 },
3569 static struct hda_amp_list alc880_lg_loopbacks[] = {
3570 { 0x0b, HDA_INPUT, 1 },
3571 { 0x0b, HDA_INPUT, 6 },
3572 { 0x0b, HDA_INPUT, 7 },
3581 static int alc_init(struct hda_codec *codec)
3583 struct alc_spec *spec = codec->spec;
3587 alc_auto_init_amp(codec, spec->init_amp);
3589 for (i = 0; i < spec->num_init_verbs; i++)
3590 snd_hda_sequence_write(codec, spec->init_verbs[i]);
3592 if (spec->init_hook)
3593 spec->init_hook(codec);
3595 #ifdef CONFIG_SND_HDA_POWER_SAVE
3596 if (codec->patch_ops.check_power_status)
3597 codec->patch_ops.check_power_status(codec, 0x01);
3602 static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
3604 struct alc_spec *spec = codec->spec;
3606 if (spec->unsol_event)
3607 spec->unsol_event(codec, res);
3610 #ifdef CONFIG_SND_HDA_POWER_SAVE
3611 static int alc_check_power_status(struct hda_codec *codec, hda_nid_t nid)
3613 struct alc_spec *spec = codec->spec;
3614 return snd_hda_check_amp_list_power(codec, &spec->loopback, nid);
3619 * Analog playback callbacks
3621 static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
3622 struct hda_codec *codec,
3623 struct snd_pcm_substream *substream)
3625 struct alc_spec *spec = codec->spec;
3626 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
3630 static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
3631 struct hda_codec *codec,
3632 unsigned int stream_tag,
3633 unsigned int format,
3634 struct snd_pcm_substream *substream)
3636 struct alc_spec *spec = codec->spec;
3637 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
3638 stream_tag, format, substream);
3641 static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
3642 struct hda_codec *codec,
3643 struct snd_pcm_substream *substream)
3645 struct alc_spec *spec = codec->spec;
3646 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
3652 static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
3653 struct hda_codec *codec,
3654 struct snd_pcm_substream *substream)
3656 struct alc_spec *spec = codec->spec;
3657 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
3660 static int alc880_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
3661 struct hda_codec *codec,
3662 unsigned int stream_tag,
3663 unsigned int format,
3664 struct snd_pcm_substream *substream)
3666 struct alc_spec *spec = codec->spec;
3667 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
3668 stream_tag, format, substream);
3671 static int alc880_dig_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
3672 struct hda_codec *codec,
3673 struct snd_pcm_substream *substream)
3675 struct alc_spec *spec = codec->spec;
3676 return snd_hda_multi_out_dig_cleanup(codec, &spec->multiout);
3679 static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
3680 struct hda_codec *codec,
3681 struct snd_pcm_substream *substream)
3683 struct alc_spec *spec = codec->spec;
3684 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
3690 static int alc880_alt_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
3691 struct hda_codec *codec,
3692 unsigned int stream_tag,
3693 unsigned int format,
3694 struct snd_pcm_substream *substream)
3696 struct alc_spec *spec = codec->spec;
3698 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number + 1],
3699 stream_tag, 0, format);
3703 static int alc880_alt_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
3704 struct hda_codec *codec,
3705 struct snd_pcm_substream *substream)
3707 struct alc_spec *spec = codec->spec;
3709 snd_hda_codec_cleanup_stream(codec,
3710 spec->adc_nids[substream->number + 1]);
3714 /* analog capture with dynamic dual-adc changes */
3715 static int dualmic_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
3716 struct hda_codec *codec,
3717 unsigned int stream_tag,
3718 unsigned int format,
3719 struct snd_pcm_substream *substream)
3721 struct alc_spec *spec = codec->spec;
3722 spec->cur_adc = spec->adc_nids[spec->cur_adc_idx];
3723 spec->cur_adc_stream_tag = stream_tag;
3724 spec->cur_adc_format = format;
3725 snd_hda_codec_setup_stream(codec, spec->cur_adc, stream_tag, 0, format);
3729 static int dualmic_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
3730 struct hda_codec *codec,
3731 struct snd_pcm_substream *substream)
3733 struct alc_spec *spec = codec->spec;
3734 snd_hda_codec_cleanup_stream(codec, spec->cur_adc);
3739 static struct hda_pcm_stream dualmic_pcm_analog_capture = {
3743 .nid = 0, /* fill later */
3745 .prepare = dualmic_capture_pcm_prepare,
3746 .cleanup = dualmic_capture_pcm_cleanup
3752 static struct hda_pcm_stream alc880_pcm_analog_playback = {
3756 /* NID is set in alc_build_pcms */
3758 .open = alc880_playback_pcm_open,
3759 .prepare = alc880_playback_pcm_prepare,
3760 .cleanup = alc880_playback_pcm_cleanup
3764 static struct hda_pcm_stream alc880_pcm_analog_capture = {
3768 /* NID is set in alc_build_pcms */
3771 static struct hda_pcm_stream alc880_pcm_analog_alt_playback = {
3775 /* NID is set in alc_build_pcms */
3778 static struct hda_pcm_stream alc880_pcm_analog_alt_capture = {
3779 .substreams = 2, /* can be overridden */
3782 /* NID is set in alc_build_pcms */
3784 .prepare = alc880_alt_capture_pcm_prepare,
3785 .cleanup = alc880_alt_capture_pcm_cleanup
3789 static struct hda_pcm_stream alc880_pcm_digital_playback = {
3793 /* NID is set in alc_build_pcms */
3795 .open = alc880_dig_playback_pcm_open,
3796 .close = alc880_dig_playback_pcm_close,
3797 .prepare = alc880_dig_playback_pcm_prepare,
3798 .cleanup = alc880_dig_playback_pcm_cleanup
3802 static struct hda_pcm_stream alc880_pcm_digital_capture = {
3806 /* NID is set in alc_build_pcms */
3809 /* Used by alc_build_pcms to flag that a PCM has no playback stream */
3810 static struct hda_pcm_stream alc_pcm_null_stream = {
3816 static int alc_build_pcms(struct hda_codec *codec)