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 */
134 ALC269_ASUS_EEEPC_P703,
135 ALC269_ASUS_EEEPC_P901,
139 ALC269_MODEL_LAST /* last tag */
156 /* ALC861-VD models */
178 ALC662_ASUS_EEEPC_P701,
179 ALC662_ASUS_EEEPC_EP20,
216 ALC883_TARGA_2ch_DIG,
217 ALC883_TARGA_8ch_DIG,
220 ALC888_ACER_ASPIRE_4930G,
221 ALC888_ACER_ASPIRE_6530G,
222 ALC888_ACER_ASPIRE_8930G,
226 ALC883_LENOVO_101E_2ch,
227 ALC883_LENOVO_NB0763,
228 ALC888_LENOVO_MS7195_DIG,
235 ALC883_FUJITSU_PI2515,
236 ALC888_FUJITSU_XA3530,
237 ALC883_3ST_6ch_INTEL,
250 #define GPIO_MASK 0x03
252 /* extra amp-initialization sequence types */
261 struct alc_mic_route {
263 unsigned char mux_idx;
264 unsigned char amix_idx;
267 #define MUX_IDX_UNDEF ((unsigned char)-1)
270 /* codec parameterization */
271 struct snd_kcontrol_new *mixers[5]; /* mixer arrays */
272 unsigned int num_mixers;
273 struct snd_kcontrol_new *cap_mixer; /* capture mixer */
274 unsigned int beep_amp; /* beep amp value, set via set_beep_amp() */
276 const struct hda_verb *init_verbs[5]; /* initialization verbs
280 unsigned int num_init_verbs;
282 char stream_name_analog[32]; /* analog PCM stream */
283 struct hda_pcm_stream *stream_analog_playback;
284 struct hda_pcm_stream *stream_analog_capture;
285 struct hda_pcm_stream *stream_analog_alt_playback;
286 struct hda_pcm_stream *stream_analog_alt_capture;
288 char stream_name_digital[32]; /* digital PCM stream */
289 struct hda_pcm_stream *stream_digital_playback;
290 struct hda_pcm_stream *stream_digital_capture;
293 struct hda_multi_out multiout; /* playback set-up
294 * max_channels, dacs must be set
295 * dig_out_nid and hp_nid are optional
297 hda_nid_t alt_dac_nid;
298 hda_nid_t slave_dig_outs[3]; /* optional - for auto-parsing */
302 unsigned int num_adc_nids;
304 hda_nid_t *capsrc_nids;
305 hda_nid_t dig_in_nid; /* digital-in NID; optional */
308 unsigned int num_mux_defs;
309 const struct hda_input_mux *input_mux;
310 unsigned int cur_mux[3];
311 struct alc_mic_route ext_mic;
312 struct alc_mic_route int_mic;
315 const struct hda_channel_mode *channel_mode;
316 int num_channel_mode;
318 int const_channel_count;
319 int ext_channel_count;
321 /* PCM information */
322 struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */
324 /* dynamic controls, init_verbs and input_mux */
325 struct auto_pin_cfg autocfg;
326 struct snd_array kctls;
327 struct hda_input_mux private_imux[3];
328 hda_nid_t private_dac_nids[AUTO_CFG_MAX_OUTS];
329 hda_nid_t private_adc_nids[AUTO_CFG_MAX_OUTS];
330 hda_nid_t private_capsrc_nids[AUTO_CFG_MAX_OUTS];
333 void (*init_hook)(struct hda_codec *codec);
334 void (*unsol_event)(struct hda_codec *codec, unsigned int res);
336 /* for pin sensing */
337 unsigned int sense_updated: 1;
338 unsigned int jack_present: 1;
339 unsigned int master_sw: 1;
340 unsigned int auto_mic:1;
343 unsigned int no_analog :1; /* digital I/O only */
346 /* for virtual master */
347 hda_nid_t vmaster_nid;
348 #ifdef CONFIG_SND_HDA_POWER_SAVE
349 struct hda_loopback_check loopback;
354 unsigned int pll_coef_idx, pll_coef_bit;
358 * configuration template - to be copied to the spec instance
360 struct alc_config_preset {
361 struct snd_kcontrol_new *mixers[5]; /* should be identical size
364 struct snd_kcontrol_new *cap_mixer; /* capture mixer */
365 const struct hda_verb *init_verbs[5];
366 unsigned int num_dacs;
368 hda_nid_t dig_out_nid; /* optional */
369 hda_nid_t hp_nid; /* optional */
370 hda_nid_t *slave_dig_outs;
371 unsigned int num_adc_nids;
373 hda_nid_t *capsrc_nids;
374 hda_nid_t dig_in_nid;
375 unsigned int num_channel_mode;
376 const struct hda_channel_mode *channel_mode;
378 int const_channel_count;
379 unsigned int num_mux_defs;
380 const struct hda_input_mux *input_mux;
381 void (*unsol_event)(struct hda_codec *, unsigned int);
382 void (*init_hook)(struct hda_codec *);
383 #ifdef CONFIG_SND_HDA_POWER_SAVE
384 struct hda_amp_list *loopbacks;
392 static int alc_mux_enum_info(struct snd_kcontrol *kcontrol,
393 struct snd_ctl_elem_info *uinfo)
395 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
396 struct alc_spec *spec = codec->spec;
397 unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id);
398 if (mux_idx >= spec->num_mux_defs)
400 return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo);
403 static int alc_mux_enum_get(struct snd_kcontrol *kcontrol,
404 struct snd_ctl_elem_value *ucontrol)
406 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
407 struct alc_spec *spec = codec->spec;
408 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
410 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
414 static int alc_mux_enum_put(struct snd_kcontrol *kcontrol,
415 struct snd_ctl_elem_value *ucontrol)
417 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
418 struct alc_spec *spec = codec->spec;
419 const struct hda_input_mux *imux;
420 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
421 unsigned int mux_idx;
422 hda_nid_t nid = spec->capsrc_nids ?
423 spec->capsrc_nids[adc_idx] : spec->adc_nids[adc_idx];
426 mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx;
427 imux = &spec->input_mux[mux_idx];
429 type = get_wcaps_type(get_wcaps(codec, nid));
430 if (type == AC_WID_AUD_MIX) {
431 /* Matrix-mixer style (e.g. ALC882) */
432 unsigned int *cur_val = &spec->cur_mux[adc_idx];
435 idx = ucontrol->value.enumerated.item[0];
436 if (idx >= imux->num_items)
437 idx = imux->num_items - 1;
440 for (i = 0; i < imux->num_items; i++) {
441 unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
442 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
443 imux->items[i].index,
449 /* MUX style (e.g. ALC880) */
450 return snd_hda_input_mux_put(codec, imux, ucontrol, nid,
451 &spec->cur_mux[adc_idx]);
456 * channel mode setting
458 static int alc_ch_mode_info(struct snd_kcontrol *kcontrol,
459 struct snd_ctl_elem_info *uinfo)
461 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
462 struct alc_spec *spec = codec->spec;
463 return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
464 spec->num_channel_mode);
467 static int alc_ch_mode_get(struct snd_kcontrol *kcontrol,
468 struct snd_ctl_elem_value *ucontrol)
470 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
471 struct alc_spec *spec = codec->spec;
472 return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
473 spec->num_channel_mode,
474 spec->ext_channel_count);
477 static int alc_ch_mode_put(struct snd_kcontrol *kcontrol,
478 struct snd_ctl_elem_value *ucontrol)
480 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
481 struct alc_spec *spec = codec->spec;
482 int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
483 spec->num_channel_mode,
484 &spec->ext_channel_count);
485 if (err >= 0 && !spec->const_channel_count) {
486 spec->multiout.max_channels = spec->ext_channel_count;
487 if (spec->need_dac_fix)
488 spec->multiout.num_dacs = spec->multiout.max_channels / 2;
494 * Control the mode of pin widget settings via the mixer. "pc" is used
495 * instead of "%" to avoid consequences of accidently treating the % as
496 * being part of a format specifier. Maximum allowed length of a value is
497 * 63 characters plus NULL terminator.
499 * Note: some retasking pin complexes seem to ignore requests for input
500 * states other than HiZ (eg: PIN_VREFxx) and revert to HiZ if any of these
501 * are requested. Therefore order this list so that this behaviour will not
502 * cause problems when mixer clients move through the enum sequentially.
503 * NIDs 0x0f and 0x10 have been observed to have this behaviour as of
506 static char *alc_pin_mode_names[] = {
507 "Mic 50pc bias", "Mic 80pc bias",
508 "Line in", "Line out", "Headphone out",
510 static unsigned char alc_pin_mode_values[] = {
511 PIN_VREF50, PIN_VREF80, PIN_IN, PIN_OUT, PIN_HP,
513 /* The control can present all 5 options, or it can limit the options based
514 * in the pin being assumed to be exclusively an input or an output pin. In
515 * addition, "input" pins may or may not process the mic bias option
516 * depending on actual widget capability (NIDs 0x0f and 0x10 don't seem to
517 * accept requests for bias as of chip versions up to March 2006) and/or
518 * wiring in the computer.
520 #define ALC_PIN_DIR_IN 0x00
521 #define ALC_PIN_DIR_OUT 0x01
522 #define ALC_PIN_DIR_INOUT 0x02
523 #define ALC_PIN_DIR_IN_NOMICBIAS 0x03
524 #define ALC_PIN_DIR_INOUT_NOMICBIAS 0x04
526 /* Info about the pin modes supported by the different pin direction modes.
527 * For each direction the minimum and maximum values are given.
529 static signed char alc_pin_mode_dir_info[5][2] = {
530 { 0, 2 }, /* ALC_PIN_DIR_IN */
531 { 3, 4 }, /* ALC_PIN_DIR_OUT */
532 { 0, 4 }, /* ALC_PIN_DIR_INOUT */
533 { 2, 2 }, /* ALC_PIN_DIR_IN_NOMICBIAS */
534 { 2, 4 }, /* ALC_PIN_DIR_INOUT_NOMICBIAS */
536 #define alc_pin_mode_min(_dir) (alc_pin_mode_dir_info[_dir][0])
537 #define alc_pin_mode_max(_dir) (alc_pin_mode_dir_info[_dir][1])
538 #define alc_pin_mode_n_items(_dir) \
539 (alc_pin_mode_max(_dir)-alc_pin_mode_min(_dir)+1)
541 static int alc_pin_mode_info(struct snd_kcontrol *kcontrol,
542 struct snd_ctl_elem_info *uinfo)
544 unsigned int item_num = uinfo->value.enumerated.item;
545 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
547 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
549 uinfo->value.enumerated.items = alc_pin_mode_n_items(dir);
551 if (item_num<alc_pin_mode_min(dir) || item_num>alc_pin_mode_max(dir))
552 item_num = alc_pin_mode_min(dir);
553 strcpy(uinfo->value.enumerated.name, alc_pin_mode_names[item_num]);
557 static int alc_pin_mode_get(struct snd_kcontrol *kcontrol,
558 struct snd_ctl_elem_value *ucontrol)
561 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
562 hda_nid_t nid = kcontrol->private_value & 0xffff;
563 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
564 long *valp = ucontrol->value.integer.value;
565 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
566 AC_VERB_GET_PIN_WIDGET_CONTROL,
569 /* Find enumerated value for current pinctl setting */
570 i = alc_pin_mode_min(dir);
571 while (i <= alc_pin_mode_max(dir) && alc_pin_mode_values[i] != pinctl)
573 *valp = i <= alc_pin_mode_max(dir) ? i: alc_pin_mode_min(dir);
577 static int alc_pin_mode_put(struct snd_kcontrol *kcontrol,
578 struct snd_ctl_elem_value *ucontrol)
581 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
582 hda_nid_t nid = kcontrol->private_value & 0xffff;
583 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
584 long val = *ucontrol->value.integer.value;
585 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
586 AC_VERB_GET_PIN_WIDGET_CONTROL,
589 if (val < alc_pin_mode_min(dir) || val > alc_pin_mode_max(dir))
590 val = alc_pin_mode_min(dir);
592 change = pinctl != alc_pin_mode_values[val];
594 /* Set pin mode to that requested */
595 snd_hda_codec_write_cache(codec, nid, 0,
596 AC_VERB_SET_PIN_WIDGET_CONTROL,
597 alc_pin_mode_values[val]);
599 /* Also enable the retasking pin's input/output as required
600 * for the requested pin mode. Enum values of 2 or less are
603 * Dynamically switching the input/output buffers probably
604 * reduces noise slightly (particularly on input) so we'll
605 * do it. However, having both input and output buffers
606 * enabled simultaneously doesn't seem to be problematic if
607 * this turns out to be necessary in the future.
610 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
611 HDA_AMP_MUTE, HDA_AMP_MUTE);
612 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
615 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
616 HDA_AMP_MUTE, HDA_AMP_MUTE);
617 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
624 #define ALC_PIN_MODE(xname, nid, dir) \
625 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
626 .info = alc_pin_mode_info, \
627 .get = alc_pin_mode_get, \
628 .put = alc_pin_mode_put, \
629 .private_value = nid | (dir<<16) }
631 /* A switch control for ALC260 GPIO pins. Multiple GPIOs can be ganged
632 * together using a mask with more than one bit set. This control is
633 * currently used only by the ALC260 test model. At this stage they are not
634 * needed for any "production" models.
636 #ifdef CONFIG_SND_DEBUG
637 #define alc_gpio_data_info snd_ctl_boolean_mono_info
639 static int alc_gpio_data_get(struct snd_kcontrol *kcontrol,
640 struct snd_ctl_elem_value *ucontrol)
642 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
643 hda_nid_t nid = kcontrol->private_value & 0xffff;
644 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
645 long *valp = ucontrol->value.integer.value;
646 unsigned int val = snd_hda_codec_read(codec, nid, 0,
647 AC_VERB_GET_GPIO_DATA, 0x00);
649 *valp = (val & mask) != 0;
652 static int alc_gpio_data_put(struct snd_kcontrol *kcontrol,
653 struct snd_ctl_elem_value *ucontrol)
656 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
657 hda_nid_t nid = kcontrol->private_value & 0xffff;
658 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
659 long val = *ucontrol->value.integer.value;
660 unsigned int gpio_data = snd_hda_codec_read(codec, nid, 0,
661 AC_VERB_GET_GPIO_DATA,
664 /* Set/unset the masked GPIO bit(s) as needed */
665 change = (val == 0 ? 0 : mask) != (gpio_data & mask);
670 snd_hda_codec_write_cache(codec, nid, 0,
671 AC_VERB_SET_GPIO_DATA, gpio_data);
675 #define ALC_GPIO_DATA_SWITCH(xname, nid, mask) \
676 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
677 .info = alc_gpio_data_info, \
678 .get = alc_gpio_data_get, \
679 .put = alc_gpio_data_put, \
680 .private_value = nid | (mask<<16) }
681 #endif /* CONFIG_SND_DEBUG */
683 /* A switch control to allow the enabling of the digital IO pins on the
684 * ALC260. This is incredibly simplistic; the intention of this control is
685 * to provide something in the test model allowing digital outputs to be
686 * identified if present. If models are found which can utilise these
687 * outputs a more complete mixer control can be devised for those models if
690 #ifdef CONFIG_SND_DEBUG
691 #define alc_spdif_ctrl_info snd_ctl_boolean_mono_info
693 static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol,
694 struct snd_ctl_elem_value *ucontrol)
696 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
697 hda_nid_t nid = kcontrol->private_value & 0xffff;
698 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
699 long *valp = ucontrol->value.integer.value;
700 unsigned int val = snd_hda_codec_read(codec, nid, 0,
701 AC_VERB_GET_DIGI_CONVERT_1, 0x00);
703 *valp = (val & mask) != 0;
706 static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol,
707 struct snd_ctl_elem_value *ucontrol)
710 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
711 hda_nid_t nid = kcontrol->private_value & 0xffff;
712 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
713 long val = *ucontrol->value.integer.value;
714 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
715 AC_VERB_GET_DIGI_CONVERT_1,
718 /* Set/unset the masked control bit(s) as needed */
719 change = (val == 0 ? 0 : mask) != (ctrl_data & mask);
724 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1,
729 #define ALC_SPDIF_CTRL_SWITCH(xname, nid, mask) \
730 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
731 .info = alc_spdif_ctrl_info, \
732 .get = alc_spdif_ctrl_get, \
733 .put = alc_spdif_ctrl_put, \
734 .private_value = nid | (mask<<16) }
735 #endif /* CONFIG_SND_DEBUG */
737 /* A switch control to allow the enabling EAPD digital outputs on the ALC26x.
738 * Again, this is only used in the ALC26x test models to help identify when
739 * the EAPD line must be asserted for features to work.
741 #ifdef CONFIG_SND_DEBUG
742 #define alc_eapd_ctrl_info snd_ctl_boolean_mono_info
744 static int alc_eapd_ctrl_get(struct snd_kcontrol *kcontrol,
745 struct snd_ctl_elem_value *ucontrol)
747 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
748 hda_nid_t nid = kcontrol->private_value & 0xffff;
749 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
750 long *valp = ucontrol->value.integer.value;
751 unsigned int val = snd_hda_codec_read(codec, nid, 0,
752 AC_VERB_GET_EAPD_BTLENABLE, 0x00);
754 *valp = (val & mask) != 0;
758 static int alc_eapd_ctrl_put(struct snd_kcontrol *kcontrol,
759 struct snd_ctl_elem_value *ucontrol)
762 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
763 hda_nid_t nid = kcontrol->private_value & 0xffff;
764 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
765 long val = *ucontrol->value.integer.value;
766 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
767 AC_VERB_GET_EAPD_BTLENABLE,
770 /* Set/unset the masked control bit(s) as needed */
771 change = (!val ? 0 : mask) != (ctrl_data & mask);
776 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
782 #define ALC_EAPD_CTRL_SWITCH(xname, nid, mask) \
783 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
784 .info = alc_eapd_ctrl_info, \
785 .get = alc_eapd_ctrl_get, \
786 .put = alc_eapd_ctrl_put, \
787 .private_value = nid | (mask<<16) }
788 #endif /* CONFIG_SND_DEBUG */
791 * set up the input pin config (depending on the given auto-pin type)
793 static void alc_set_input_pin(struct hda_codec *codec, hda_nid_t nid,
796 unsigned int val = PIN_IN;
798 if (auto_pin_type <= AUTO_PIN_FRONT_MIC) {
800 pincap = snd_hda_query_pin_caps(codec, nid);
801 pincap = (pincap & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT;
802 if (pincap & AC_PINCAP_VREF_80)
804 else if (pincap & AC_PINCAP_VREF_50)
806 else if (pincap & AC_PINCAP_VREF_100)
808 else if (pincap & AC_PINCAP_VREF_GRD)
811 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, val);
816 static void add_mixer(struct alc_spec *spec, struct snd_kcontrol_new *mix)
818 if (snd_BUG_ON(spec->num_mixers >= ARRAY_SIZE(spec->mixers)))
820 spec->mixers[spec->num_mixers++] = mix;
823 static void add_verb(struct alc_spec *spec, const struct hda_verb *verb)
825 if (snd_BUG_ON(spec->num_init_verbs >= ARRAY_SIZE(spec->init_verbs)))
827 spec->init_verbs[spec->num_init_verbs++] = verb;
830 #ifdef CONFIG_PROC_FS
834 static void print_realtek_coef(struct snd_info_buffer *buffer,
835 struct hda_codec *codec, hda_nid_t nid)
841 coeff = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_PROC_COEF, 0);
842 snd_iprintf(buffer, " Processing Coefficient: 0x%02x\n", coeff);
843 coeff = snd_hda_codec_read(codec, nid, 0,
844 AC_VERB_GET_COEF_INDEX, 0);
845 snd_iprintf(buffer, " Coefficient Index: 0x%02x\n", coeff);
848 #define print_realtek_coef NULL
852 * set up from the preset table
854 static void setup_preset(struct alc_spec *spec,
855 const struct alc_config_preset *preset)
859 for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++)
860 add_mixer(spec, preset->mixers[i]);
861 spec->cap_mixer = preset->cap_mixer;
862 for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i];
864 add_verb(spec, preset->init_verbs[i]);
866 spec->channel_mode = preset->channel_mode;
867 spec->num_channel_mode = preset->num_channel_mode;
868 spec->need_dac_fix = preset->need_dac_fix;
869 spec->const_channel_count = preset->const_channel_count;
871 if (preset->const_channel_count)
872 spec->multiout.max_channels = preset->const_channel_count;
874 spec->multiout.max_channels = spec->channel_mode[0].channels;
875 spec->ext_channel_count = spec->channel_mode[0].channels;
877 spec->multiout.num_dacs = preset->num_dacs;
878 spec->multiout.dac_nids = preset->dac_nids;
879 spec->multiout.dig_out_nid = preset->dig_out_nid;
880 spec->multiout.slave_dig_outs = preset->slave_dig_outs;
881 spec->multiout.hp_nid = preset->hp_nid;
883 spec->num_mux_defs = preset->num_mux_defs;
884 if (!spec->num_mux_defs)
885 spec->num_mux_defs = 1;
886 spec->input_mux = preset->input_mux;
888 spec->num_adc_nids = preset->num_adc_nids;
889 spec->adc_nids = preset->adc_nids;
890 spec->capsrc_nids = preset->capsrc_nids;
891 spec->dig_in_nid = preset->dig_in_nid;
893 spec->unsol_event = preset->unsol_event;
894 spec->init_hook = preset->init_hook;
895 #ifdef CONFIG_SND_HDA_POWER_SAVE
896 spec->loopback.amplist = preset->loopbacks;
900 /* Enable GPIO mask and set output */
901 static struct hda_verb alc_gpio1_init_verbs[] = {
902 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
903 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
904 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
908 static struct hda_verb alc_gpio2_init_verbs[] = {
909 {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
910 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
911 {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
915 static struct hda_verb alc_gpio3_init_verbs[] = {
916 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
917 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
918 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
923 * Fix hardware PLL issue
924 * On some codecs, the analog PLL gating control must be off while
925 * the default value is 1.
927 static void alc_fix_pll(struct hda_codec *codec)
929 struct alc_spec *spec = codec->spec;
934 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX,
936 val = snd_hda_codec_read(codec, spec->pll_nid, 0,
937 AC_VERB_GET_PROC_COEF, 0);
938 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX,
940 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_PROC_COEF,
941 val & ~(1 << spec->pll_coef_bit));
944 static void alc_fix_pll_init(struct hda_codec *codec, hda_nid_t nid,
945 unsigned int coef_idx, unsigned int coef_bit)
947 struct alc_spec *spec = codec->spec;
949 spec->pll_coef_idx = coef_idx;
950 spec->pll_coef_bit = coef_bit;
954 static void alc_automute_pin(struct hda_codec *codec)
956 struct alc_spec *spec = codec->spec;
957 unsigned int present, pincap;
958 unsigned int nid = spec->autocfg.hp_pins[0];
961 pincap = snd_hda_query_pin_caps(codec, nid);
962 if (pincap & AC_PINCAP_TRIG_REQ) /* need trigger? */
963 snd_hda_codec_read(codec, nid, 0, AC_VERB_SET_PIN_SENSE, 0);
964 present = snd_hda_codec_read(codec, nid, 0,
965 AC_VERB_GET_PIN_SENSE, 0);
966 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
967 for (i = 0; i < ARRAY_SIZE(spec->autocfg.speaker_pins); i++) {
968 nid = spec->autocfg.speaker_pins[i];
971 snd_hda_codec_write(codec, nid, 0,
972 AC_VERB_SET_PIN_WIDGET_CONTROL,
973 spec->jack_present ? 0 : PIN_OUT);
977 static int get_connection_index(struct hda_codec *codec, hda_nid_t mux,
980 hda_nid_t conn[HDA_MAX_NUM_INPUTS];
983 nums = snd_hda_get_connections(codec, mux, conn, ARRAY_SIZE(conn));
984 for (i = 0; i < nums; i++)
990 static int set_mic_mux_idx(struct hda_codec *codec, hda_nid_t cap,
991 struct alc_mic_route *mic)
993 int idx = get_connection_index(codec, cap, mic->pin);
995 return 1; /* invalid */
1000 static void alc_mic_automute(struct hda_codec *codec)
1002 struct alc_spec *spec = codec->spec;
1003 struct alc_mic_route *dead, *alive;
1004 unsigned int present, type;
1007 if (!spec->int_mic.pin || !spec->ext_mic.pin)
1009 if (snd_BUG_ON(!spec->adc_nids))
1012 cap_nid = spec->capsrc_nids ? spec->capsrc_nids[0] : spec->adc_nids[0];
1014 present = snd_hda_codec_read(codec, spec->ext_mic.pin, 0,
1015 AC_VERB_GET_PIN_SENSE, 0);
1016 present &= AC_PINSENSE_PRESENCE;
1018 alive = &spec->ext_mic;
1019 dead = &spec->int_mic;
1021 alive = &spec->int_mic;
1022 dead = &spec->ext_mic;
1025 if (alive->mux_idx == MUX_IDX_UNDEF &&
1026 set_mic_mux_idx(codec, cap_nid, alive))
1028 if (dead->mux_idx == MUX_IDX_UNDEF &&
1029 set_mic_mux_idx(codec, cap_nid, dead))
1032 type = get_wcaps_type(get_wcaps(codec, cap_nid));
1033 if (type == AC_WID_AUD_MIX) {
1034 /* Matrix-mixer style (e.g. ALC882) */
1035 snd_hda_codec_amp_stereo(codec, cap_nid, HDA_INPUT,
1038 snd_hda_codec_amp_stereo(codec, cap_nid, HDA_INPUT,
1040 HDA_AMP_MUTE, HDA_AMP_MUTE);
1042 /* MUX style (e.g. ALC880) */
1043 snd_hda_codec_write_cache(codec, cap_nid, 0,
1044 AC_VERB_SET_CONNECT_SEL,
1048 /* FIXME: analog mixer */
1051 /* unsolicited event for HP jack sensing */
1052 static void alc_sku_unsol_event(struct hda_codec *codec, unsigned int res)
1054 if (codec->vendor_id == 0x10ec0880)
1059 case ALC880_HP_EVENT:
1060 alc_automute_pin(codec);
1062 case ALC880_MIC_EVENT:
1063 alc_mic_automute(codec);
1068 static void alc_inithook(struct hda_codec *codec)
1070 alc_automute_pin(codec);
1071 alc_mic_automute(codec);
1074 /* additional initialization for ALC888 variants */
1075 static void alc888_coef_init(struct hda_codec *codec)
1079 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 0);
1080 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
1081 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
1082 if ((tmp & 0xf0) == 0x20)
1084 snd_hda_codec_read(codec, 0x20, 0,
1085 AC_VERB_SET_PROC_COEF, 0x830);
1088 snd_hda_codec_read(codec, 0x20, 0,
1089 AC_VERB_SET_PROC_COEF, 0x3030);
1092 static void alc889_coef_init(struct hda_codec *codec)
1096 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
1097 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
1098 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
1099 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_PROC_COEF, tmp|0x2010);
1102 static void alc_auto_init_amp(struct hda_codec *codec, int type)
1107 case ALC_INIT_GPIO1:
1108 snd_hda_sequence_write(codec, alc_gpio1_init_verbs);
1110 case ALC_INIT_GPIO2:
1111 snd_hda_sequence_write(codec, alc_gpio2_init_verbs);
1113 case ALC_INIT_GPIO3:
1114 snd_hda_sequence_write(codec, alc_gpio3_init_verbs);
1116 case ALC_INIT_DEFAULT:
1117 switch (codec->vendor_id) {
1119 snd_hda_codec_write(codec, 0x0f, 0,
1120 AC_VERB_SET_EAPD_BTLENABLE, 2);
1121 snd_hda_codec_write(codec, 0x10, 0,
1122 AC_VERB_SET_EAPD_BTLENABLE, 2);
1134 snd_hda_codec_write(codec, 0x14, 0,
1135 AC_VERB_SET_EAPD_BTLENABLE, 2);
1136 snd_hda_codec_write(codec, 0x15, 0,
1137 AC_VERB_SET_EAPD_BTLENABLE, 2);
1140 switch (codec->vendor_id) {
1142 snd_hda_codec_write(codec, 0x1a, 0,
1143 AC_VERB_SET_COEF_INDEX, 7);
1144 tmp = snd_hda_codec_read(codec, 0x1a, 0,
1145 AC_VERB_GET_PROC_COEF, 0);
1146 snd_hda_codec_write(codec, 0x1a, 0,
1147 AC_VERB_SET_COEF_INDEX, 7);
1148 snd_hda_codec_write(codec, 0x1a, 0,
1149 AC_VERB_SET_PROC_COEF,
1159 alc889_coef_init(codec);
1162 alc888_coef_init(codec);
1166 snd_hda_codec_write(codec, 0x20, 0,
1167 AC_VERB_SET_COEF_INDEX, 7);
1168 tmp = snd_hda_codec_read(codec, 0x20, 0,
1169 AC_VERB_GET_PROC_COEF, 0);
1170 snd_hda_codec_write(codec, 0x20, 0,
1171 AC_VERB_SET_COEF_INDEX, 7);
1172 snd_hda_codec_write(codec, 0x20, 0,
1173 AC_VERB_SET_PROC_COEF,
1181 static void alc_init_auto_hp(struct hda_codec *codec)
1183 struct alc_spec *spec = codec->spec;
1185 if (!spec->autocfg.hp_pins[0])
1188 if (!spec->autocfg.speaker_pins[0]) {
1189 if (spec->autocfg.line_out_pins[0] &&
1190 spec->autocfg.line_out_type == AUTO_PIN_SPEAKER_OUT)
1191 spec->autocfg.speaker_pins[0] =
1192 spec->autocfg.line_out_pins[0];
1197 snd_printdd("realtek: Enable HP auto-muting on NID 0x%x\n",
1198 spec->autocfg.hp_pins[0]);
1199 snd_hda_codec_write_cache(codec, spec->autocfg.hp_pins[0], 0,
1200 AC_VERB_SET_UNSOLICITED_ENABLE,
1201 AC_USRSP_EN | ALC880_HP_EVENT);
1202 spec->unsol_event = alc_sku_unsol_event;
1205 static void alc_init_auto_mic(struct hda_codec *codec)
1207 struct alc_spec *spec = codec->spec;
1208 struct auto_pin_cfg *cfg = &spec->autocfg;
1209 hda_nid_t fixed, ext;
1212 /* there must be only two mic inputs exclusively */
1213 for (i = AUTO_PIN_LINE; i < AUTO_PIN_LAST; i++)
1214 if (cfg->input_pins[i])
1218 for (i = AUTO_PIN_MIC; i <= AUTO_PIN_FRONT_MIC; i++) {
1219 hda_nid_t nid = cfg->input_pins[i];
1220 unsigned int defcfg;
1223 defcfg = snd_hda_codec_get_pincfg(codec, nid);
1224 switch (get_defcfg_connect(defcfg)) {
1225 case AC_JACK_PORT_FIXED:
1227 return; /* already occupied */
1230 case AC_JACK_PORT_COMPLEX:
1232 return; /* already occupied */
1236 return; /* invalid entry */
1239 if (!(get_wcaps(codec, ext) & AC_WCAP_UNSOL_CAP))
1240 return; /* no unsol support */
1241 snd_printdd("realtek: Enable auto-mic switch on NID 0x%x/0x%x\n",
1243 spec->ext_mic.pin = ext;
1244 spec->int_mic.pin = fixed;
1245 spec->ext_mic.mux_idx = MUX_IDX_UNDEF; /* set later */
1246 spec->int_mic.mux_idx = MUX_IDX_UNDEF; /* set later */
1248 snd_hda_codec_write_cache(codec, spec->ext_mic.pin, 0,
1249 AC_VERB_SET_UNSOLICITED_ENABLE,
1250 AC_USRSP_EN | ALC880_MIC_EVENT);
1251 spec->unsol_event = alc_sku_unsol_event;
1254 /* check subsystem ID and set up device-specific initialization;
1255 * return 1 if initialized, 0 if invalid SSID
1257 /* 32-bit subsystem ID for BIOS loading in HD Audio codec.
1258 * 31 ~ 16 : Manufacture ID
1260 * 7 ~ 0 : Assembly ID
1261 * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36
1263 static int alc_subsystem_id(struct hda_codec *codec,
1264 hda_nid_t porta, hda_nid_t porte,
1267 unsigned int ass, tmp, i;
1269 struct alc_spec *spec = codec->spec;
1271 ass = codec->subsystem_id & 0xffff;
1272 if ((ass != codec->bus->pci->subsystem_device) && (ass & 1))
1275 /* invalid SSID, check the special NID pin defcfg instead */
1277 * 31~30 : port connectivity
1280 * 19~16 : Check sum (15:1)
1285 if (codec->vendor_id == 0x10ec0260)
1287 ass = snd_hda_codec_get_pincfg(codec, nid);
1288 snd_printd("realtek: No valid SSID, "
1289 "checking pincfg 0x%08x for NID 0x%x\n",
1291 if (!(ass & 1) && !(ass & 0x100000))
1293 if ((ass >> 30) != 1) /* no physical connection */
1298 for (i = 1; i < 16; i++) {
1302 if (((ass >> 16) & 0xf) != tmp)
1305 snd_printd("realtek: Enabling init ASM_ID=0x%04x CODEC_ID=%08x\n",
1306 ass & 0xffff, codec->vendor_id);
1310 * 2 : 0 --> Desktop, 1 --> Laptop
1311 * 3~5 : External Amplifier control
1314 tmp = (ass & 0x38) >> 3; /* external Amp control */
1317 spec->init_amp = ALC_INIT_GPIO1;
1320 spec->init_amp = ALC_INIT_GPIO2;
1323 spec->init_amp = ALC_INIT_GPIO3;
1326 spec->init_amp = ALC_INIT_DEFAULT;
1330 /* is laptop or Desktop and enable the function "Mute internal speaker
1331 * when the external headphone out jack is plugged"
1333 if (!(ass & 0x8000))
1336 * 10~8 : Jack location
1337 * 12~11: Headphone out -> 00: PortA, 01: PortE, 02: PortD, 03: Resvered
1339 * 15 : 1 --> enable the function "Mute internal speaker
1340 * when the external headphone out jack is plugged"
1342 if (!spec->autocfg.hp_pins[0]) {
1343 tmp = (ass >> 11) & 0x3; /* HP to chassis */
1345 spec->autocfg.hp_pins[0] = porta;
1347 spec->autocfg.hp_pins[0] = porte;
1349 spec->autocfg.hp_pins[0] = portd;
1354 alc_init_auto_hp(codec);
1355 alc_init_auto_mic(codec);
1359 static void alc_ssid_check(struct hda_codec *codec,
1360 hda_nid_t porta, hda_nid_t porte, hda_nid_t portd)
1362 if (!alc_subsystem_id(codec, porta, porte, portd)) {
1363 struct alc_spec *spec = codec->spec;
1364 snd_printd("realtek: "
1365 "Enable default setup for auto mode as fallback\n");
1366 spec->init_amp = ALC_INIT_DEFAULT;
1367 alc_init_auto_hp(codec);
1368 alc_init_auto_mic(codec);
1373 * Fix-up pin default configurations
1381 static void alc_fix_pincfg(struct hda_codec *codec,
1382 const struct snd_pci_quirk *quirk,
1383 const struct alc_pincfg **pinfix)
1385 const struct alc_pincfg *cfg;
1387 quirk = snd_pci_quirk_lookup(codec->bus->pci, quirk);
1391 cfg = pinfix[quirk->value];
1392 for (; cfg->nid; cfg++)
1393 snd_hda_codec_set_pincfg(codec, cfg->nid, cfg->val);
1403 static struct hda_verb alc888_4ST_ch2_intel_init[] = {
1404 /* Mic-in jack as mic in */
1405 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1406 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1407 /* Line-in jack as Line in */
1408 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1409 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1410 /* Line-Out as Front */
1411 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
1418 static struct hda_verb alc888_4ST_ch4_intel_init[] = {
1419 /* Mic-in jack as mic in */
1420 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1421 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1422 /* Line-in jack as Surround */
1423 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1424 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1425 /* Line-Out as Front */
1426 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
1433 static struct hda_verb alc888_4ST_ch6_intel_init[] = {
1434 /* Mic-in jack as CLFE */
1435 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1436 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1437 /* Line-in jack as Surround */
1438 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1439 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1440 /* Line-Out as CLFE (workaround because Mic-in is not loud enough) */
1441 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1448 static struct hda_verb alc888_4ST_ch8_intel_init[] = {
1449 /* Mic-in jack as CLFE */
1450 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1451 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1452 /* Line-in jack as Surround */
1453 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1454 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1455 /* Line-Out as Side */
1456 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1460 static struct hda_channel_mode alc888_4ST_8ch_intel_modes[4] = {
1461 { 2, alc888_4ST_ch2_intel_init },
1462 { 4, alc888_4ST_ch4_intel_init },
1463 { 6, alc888_4ST_ch6_intel_init },
1464 { 8, alc888_4ST_ch8_intel_init },
1468 * ALC888 Fujitsu Siemens Amillo xa3530
1471 static struct hda_verb alc888_fujitsu_xa3530_verbs[] = {
1472 /* Front Mic: set to PIN_IN (empty by default) */
1473 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1474 /* Connect Internal HP to Front */
1475 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1476 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1477 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1478 /* Connect Bass HP to Front */
1479 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1480 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1481 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1482 /* Connect Line-Out side jack (SPDIF) to Side */
1483 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1484 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1485 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1486 /* Connect Mic jack to CLFE */
1487 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1488 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1489 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02},
1490 /* Connect Line-in jack to Surround */
1491 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1492 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1493 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
1494 /* Connect HP out jack to Front */
1495 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1496 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1497 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
1498 /* Enable unsolicited event for HP jack and Line-out jack */
1499 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1500 {0x17, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1504 static void alc_automute_amp(struct hda_codec *codec)
1506 struct alc_spec *spec = codec->spec;
1507 unsigned int val, mute, pincap;
1511 spec->jack_present = 0;
1512 for (i = 0; i < ARRAY_SIZE(spec->autocfg.hp_pins); i++) {
1513 nid = spec->autocfg.hp_pins[i];
1516 pincap = snd_hda_query_pin_caps(codec, nid);
1517 if (pincap & AC_PINCAP_TRIG_REQ) /* need trigger? */
1518 snd_hda_codec_read(codec, nid, 0,
1519 AC_VERB_SET_PIN_SENSE, 0);
1520 val = snd_hda_codec_read(codec, nid, 0,
1521 AC_VERB_GET_PIN_SENSE, 0);
1522 if (val & AC_PINSENSE_PRESENCE) {
1523 spec->jack_present = 1;
1528 mute = spec->jack_present ? HDA_AMP_MUTE : 0;
1529 /* Toggle internal speakers muting */
1530 for (i = 0; i < ARRAY_SIZE(spec->autocfg.speaker_pins); i++) {
1531 nid = spec->autocfg.speaker_pins[i];
1534 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
1535 HDA_AMP_MUTE, mute);
1539 static void alc_automute_amp_unsol_event(struct hda_codec *codec,
1542 if (codec->vendor_id == 0x10ec0880)
1546 if (res == ALC880_HP_EVENT)
1547 alc_automute_amp(codec);
1550 static void alc889_automute_init(struct hda_codec *codec)
1552 struct alc_spec *spec = codec->spec;
1554 spec->autocfg.hp_pins[0] = 0x15;
1555 spec->autocfg.speaker_pins[0] = 0x14;
1556 spec->autocfg.speaker_pins[1] = 0x16;
1557 spec->autocfg.speaker_pins[2] = 0x17;
1558 spec->autocfg.speaker_pins[3] = 0x19;
1559 spec->autocfg.speaker_pins[4] = 0x1a;
1560 alc_automute_amp(codec);
1563 static void alc889_intel_init_hook(struct hda_codec *codec)
1565 alc889_coef_init(codec);
1566 alc889_automute_init(codec);
1569 static void alc888_fujitsu_xa3530_init_hook(struct hda_codec *codec)
1571 struct alc_spec *spec = codec->spec;
1573 spec->autocfg.hp_pins[0] = 0x17; /* line-out */
1574 spec->autocfg.hp_pins[1] = 0x1b; /* hp */
1575 spec->autocfg.speaker_pins[0] = 0x14; /* speaker */
1576 spec->autocfg.speaker_pins[1] = 0x15; /* bass */
1577 alc_automute_amp(codec);
1581 * ALC888 Acer Aspire 4930G model
1584 static struct hda_verb alc888_acer_aspire_4930g_verbs[] = {
1585 /* Front Mic: set to PIN_IN (empty by default) */
1586 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1587 /* Unselect Front Mic by default in input mixer 3 */
1588 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
1589 /* Enable unsolicited event for HP jack */
1590 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1591 /* Connect Internal HP to front */
1592 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1593 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1594 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1595 /* Connect HP out to front */
1596 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1597 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1598 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1603 * ALC888 Acer Aspire 6530G model
1606 static struct hda_verb alc888_acer_aspire_6530g_verbs[] = {
1607 /* Bias voltage on for external mic port */
1608 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN | PIN_VREF80},
1609 /* Front Mic: set to PIN_IN (empty by default) */
1610 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1611 /* Unselect Front Mic by default in input mixer 3 */
1612 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
1613 /* Enable unsolicited event for HP jack */
1614 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1615 /* Enable speaker output */
1616 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1617 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1618 /* Enable headphone output */
1619 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | PIN_HP},
1620 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1621 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1626 * ALC889 Acer Aspire 8930G model
1629 static struct hda_verb alc889_acer_aspire_8930g_verbs[] = {
1630 /* Front Mic: set to PIN_IN (empty by default) */
1631 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1632 /* Unselect Front Mic by default in input mixer 3 */
1633 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
1634 /* Enable unsolicited event for HP jack */
1635 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1636 /* Connect Internal Front to Front */
1637 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1638 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1639 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1640 /* Connect Internal Rear to Rear */
1641 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1642 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1643 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01},
1644 /* Connect Internal CLFE to CLFE */
1645 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1646 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1647 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
1648 /* Connect HP out to Front */
1649 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | PIN_HP},
1650 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1651 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1652 /* Enable all DACs */
1653 /* DAC DISABLE/MUTE 1? */
1654 /* setting bits 1-5 disables DAC nids 0x02-0x06 apparently. Init=0x38 */
1655 {0x20, AC_VERB_SET_COEF_INDEX, 0x03},
1656 {0x20, AC_VERB_SET_PROC_COEF, 0x0000},
1657 /* DAC DISABLE/MUTE 2? */
1658 /* some bit here disables the other DACs. Init=0x4900 */
1659 {0x20, AC_VERB_SET_COEF_INDEX, 0x08},
1660 {0x20, AC_VERB_SET_PROC_COEF, 0x0000},
1661 /* Enable amplifiers */
1662 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
1663 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
1665 * This laptop has a stereo digital microphone. The mics are only 1cm apart
1666 * which makes the stereo useless. However, either the mic or the ALC889
1667 * makes the signal become a difference/sum signal instead of standard
1668 * stereo, which is annoying. So instead we flip this bit which makes the
1669 * codec replicate the sum signal to both channels, turning it into a
1672 /* DMIC_CONTROL? Init value = 0x0001 */
1673 {0x20, AC_VERB_SET_COEF_INDEX, 0x0b},
1674 {0x20, AC_VERB_SET_PROC_COEF, 0x0003},
1678 static struct hda_input_mux alc888_2_capture_sources[2] = {
1679 /* Front mic only available on one ADC */
1686 { "Front Mic", 0xb },
1699 static struct hda_input_mux alc888_acer_aspire_6530_sources[2] = {
1700 /* Interal mic only available on one ADC */
1707 { "Input Mix", 0xa },
1717 { "Input Mix", 0xa },
1722 static struct hda_input_mux alc889_capture_sources[3] = {
1723 /* Digital mic only available on first "ADC" */
1730 { "Front Mic", 0xb },
1731 { "Input Mix", 0xa },
1740 { "Input Mix", 0xa },
1749 { "Input Mix", 0xa },
1754 static struct snd_kcontrol_new alc888_base_mixer[] = {
1755 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1756 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1757 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1758 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
1759 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
1761 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1762 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1763 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1764 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
1765 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
1766 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1767 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1768 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1769 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1770 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1771 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
1772 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1776 static void alc888_acer_aspire_4930g_init_hook(struct hda_codec *codec)
1778 struct alc_spec *spec = codec->spec;
1780 spec->autocfg.hp_pins[0] = 0x15;
1781 spec->autocfg.speaker_pins[0] = 0x14;
1782 alc_automute_amp(codec);
1785 static void alc888_acer_aspire_6530g_init_hook(struct hda_codec *codec)
1787 struct alc_spec *spec = codec->spec;
1789 spec->autocfg.hp_pins[0] = 0x15;
1790 spec->autocfg.speaker_pins[0] = 0x14;
1791 spec->autocfg.speaker_pins[1] = 0x16;
1792 spec->autocfg.speaker_pins[2] = 0x17;
1793 alc_automute_amp(codec);
1796 static void alc889_acer_aspire_8930g_init_hook(struct hda_codec *codec)
1798 struct alc_spec *spec = codec->spec;
1800 spec->autocfg.hp_pins[0] = 0x15;
1801 spec->autocfg.speaker_pins[0] = 0x14;
1802 spec->autocfg.speaker_pins[1] = 0x16;
1803 spec->autocfg.speaker_pins[2] = 0x1b;
1804 alc_automute_amp(codec);
1808 * ALC880 3-stack model
1810 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
1811 * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18,
1812 * F-Mic = 0x1b, HP = 0x19
1815 static hda_nid_t alc880_dac_nids[4] = {
1816 /* front, rear, clfe, rear_surr */
1817 0x02, 0x05, 0x04, 0x03
1820 static hda_nid_t alc880_adc_nids[3] = {
1825 /* The datasheet says the node 0x07 is connected from inputs,
1826 * but it shows zero connection in the real implementation on some devices.
1827 * Note: this is a 915GAV bug, fixed on 915GLV
1829 static hda_nid_t alc880_adc_nids_alt[2] = {
1834 #define ALC880_DIGOUT_NID 0x06
1835 #define ALC880_DIGIN_NID 0x0a
1837 static struct hda_input_mux alc880_capture_source = {
1841 { "Front Mic", 0x3 },
1847 /* channel source setting (2/6 channel selection for 3-stack) */
1849 static struct hda_verb alc880_threestack_ch2_init[] = {
1850 /* set line-in to input, mute it */
1851 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1852 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1853 /* set mic-in to input vref 80%, mute it */
1854 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1855 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1860 static struct hda_verb alc880_threestack_ch6_init[] = {
1861 /* set line-in to output, unmute it */
1862 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1863 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1864 /* set mic-in to output, unmute it */
1865 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1866 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1870 static struct hda_channel_mode alc880_threestack_modes[2] = {
1871 { 2, alc880_threestack_ch2_init },
1872 { 6, alc880_threestack_ch6_init },
1875 static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
1876 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1877 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1878 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
1879 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
1880 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1881 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1882 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1883 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1884 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1885 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1886 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1887 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1888 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1889 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1890 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
1891 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
1892 HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
1894 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1895 .name = "Channel Mode",
1896 .info = alc_ch_mode_info,
1897 .get = alc_ch_mode_get,
1898 .put = alc_ch_mode_put,
1903 /* capture mixer elements */
1904 static int alc_cap_vol_info(struct snd_kcontrol *kcontrol,
1905 struct snd_ctl_elem_info *uinfo)
1907 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1908 struct alc_spec *spec = codec->spec;
1911 mutex_lock(&codec->control_mutex);
1912 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0,
1914 err = snd_hda_mixer_amp_volume_info(kcontrol, uinfo);
1915 mutex_unlock(&codec->control_mutex);
1919 static int alc_cap_vol_tlv(struct snd_kcontrol *kcontrol, int op_flag,
1920 unsigned int size, unsigned int __user *tlv)
1922 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1923 struct alc_spec *spec = codec->spec;
1926 mutex_lock(&codec->control_mutex);
1927 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0,
1929 err = snd_hda_mixer_amp_tlv(kcontrol, op_flag, size, tlv);
1930 mutex_unlock(&codec->control_mutex);
1934 typedef int (*getput_call_t)(struct snd_kcontrol *kcontrol,
1935 struct snd_ctl_elem_value *ucontrol);
1937 static int alc_cap_getput_caller(struct snd_kcontrol *kcontrol,
1938 struct snd_ctl_elem_value *ucontrol,
1941 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1942 struct alc_spec *spec = codec->spec;
1943 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
1946 mutex_lock(&codec->control_mutex);
1947 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[adc_idx],
1949 err = func(kcontrol, ucontrol);
1950 mutex_unlock(&codec->control_mutex);
1954 static int alc_cap_vol_get(struct snd_kcontrol *kcontrol,
1955 struct snd_ctl_elem_value *ucontrol)
1957 return alc_cap_getput_caller(kcontrol, ucontrol,
1958 snd_hda_mixer_amp_volume_get);
1961 static int alc_cap_vol_put(struct snd_kcontrol *kcontrol,
1962 struct snd_ctl_elem_value *ucontrol)
1964 return alc_cap_getput_caller(kcontrol, ucontrol,
1965 snd_hda_mixer_amp_volume_put);
1968 /* capture mixer elements */
1969 #define alc_cap_sw_info snd_ctl_boolean_stereo_info
1971 static int alc_cap_sw_get(struct snd_kcontrol *kcontrol,
1972 struct snd_ctl_elem_value *ucontrol)
1974 return alc_cap_getput_caller(kcontrol, ucontrol,
1975 snd_hda_mixer_amp_switch_get);
1978 static int alc_cap_sw_put(struct snd_kcontrol *kcontrol,
1979 struct snd_ctl_elem_value *ucontrol)
1981 return alc_cap_getput_caller(kcontrol, ucontrol,
1982 snd_hda_mixer_amp_switch_put);
1985 #define _DEFINE_CAPMIX(num) \
1987 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1988 .name = "Capture Switch", \
1989 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, \
1991 .info = alc_cap_sw_info, \
1992 .get = alc_cap_sw_get, \
1993 .put = alc_cap_sw_put, \
1996 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1997 .name = "Capture Volume", \
1998 .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE | \
1999 SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
2000 SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK), \
2002 .info = alc_cap_vol_info, \
2003 .get = alc_cap_vol_get, \
2004 .put = alc_cap_vol_put, \
2005 .tlv = { .c = alc_cap_vol_tlv }, \
2008 #define _DEFINE_CAPSRC(num) \
2010 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2011 /* .name = "Capture Source", */ \
2012 .name = "Input Source", \
2014 .info = alc_mux_enum_info, \
2015 .get = alc_mux_enum_get, \
2016 .put = alc_mux_enum_put, \
2019 #define DEFINE_CAPMIX(num) \
2020 static struct snd_kcontrol_new alc_capture_mixer ## num[] = { \
2021 _DEFINE_CAPMIX(num), \
2022 _DEFINE_CAPSRC(num), \
2026 #define DEFINE_CAPMIX_NOSRC(num) \
2027 static struct snd_kcontrol_new alc_capture_mixer_nosrc ## num[] = { \
2028 _DEFINE_CAPMIX(num), \
2032 /* up to three ADCs */
2036 DEFINE_CAPMIX_NOSRC(1);
2037 DEFINE_CAPMIX_NOSRC(2);
2038 DEFINE_CAPMIX_NOSRC(3);
2041 * ALC880 5-stack model
2043 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d),
2045 * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
2046 * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
2049 /* additional mixers to alc880_three_stack_mixer */
2050 static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
2051 HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2052 HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
2056 /* channel source setting (6/8 channel selection for 5-stack) */
2058 static struct hda_verb alc880_fivestack_ch6_init[] = {
2059 /* set line-in to input, mute it */
2060 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
2061 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
2066 static struct hda_verb alc880_fivestack_ch8_init[] = {
2067 /* set line-in to output, unmute it */
2068 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
2069 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
2073 static struct hda_channel_mode alc880_fivestack_modes[2] = {
2074 { 6, alc880_fivestack_ch6_init },
2075 { 8, alc880_fivestack_ch8_init },
2080 * ALC880 6-stack model
2082 * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e),
2083 * Side = 0x05 (0x0f)
2084 * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
2085 * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
2088 static hda_nid_t alc880_6st_dac_nids[4] = {
2089 /* front, rear, clfe, rear_surr */
2090 0x02, 0x03, 0x04, 0x05
2093 static struct hda_input_mux alc880_6stack_capture_source = {
2097 { "Front Mic", 0x1 },
2103 /* fixed 8-channels */
2104 static struct hda_channel_mode alc880_sixstack_modes[1] = {
2108 static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
2109 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2110 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2111 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2112 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
2113 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2114 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2115 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2116 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2117 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
2118 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
2119 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2120 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2121 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2122 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2123 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2124 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2125 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2126 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
2128 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2129 .name = "Channel Mode",
2130 .info = alc_ch_mode_info,
2131 .get = alc_ch_mode_get,
2132 .put = alc_ch_mode_put,
2141 * W810 has rear IO for:
2144 * Center/LFE (DAC 04)
2147 * The system also has a pair of internal speakers, and a headphone jack.
2148 * These are both connected to Line2 on the codec, hence to DAC 02.
2150 * There is a variable resistor to control the speaker or headphone
2151 * volume. This is a hardware-only device without a software API.
2153 * Plugging headphones in will disable the internal speakers. This is
2154 * implemented in hardware, not via the driver using jack sense. In
2155 * a similar fashion, plugging into the rear socket marked "front" will
2156 * disable both the speakers and headphones.
2158 * For input, there's a microphone jack, and an "audio in" jack.
2159 * These may not do anything useful with this driver yet, because I
2160 * haven't setup any initialization verbs for these yet...
2163 static hda_nid_t alc880_w810_dac_nids[3] = {
2164 /* front, rear/surround, clfe */
2168 /* fixed 6 channels */
2169 static struct hda_channel_mode alc880_w810_modes[1] = {
2173 /* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
2174 static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
2175 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2176 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2177 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2178 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
2179 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2180 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2181 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2182 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2183 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
2191 * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
2192 * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?),
2196 static hda_nid_t alc880_z71v_dac_nids[1] = {
2199 #define ALC880_Z71V_HP_DAC 0x03
2201 /* fixed 2 channels */
2202 static struct hda_channel_mode alc880_2_jack_modes[1] = {
2206 static struct snd_kcontrol_new alc880_z71v_mixer[] = {
2207 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2208 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2209 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2210 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
2211 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2212 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2213 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2214 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2220 * ALC880 F1734 model
2222 * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
2223 * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
2226 static hda_nid_t alc880_f1734_dac_nids[1] = {
2229 #define ALC880_F1734_HP_DAC 0x02
2231 static struct snd_kcontrol_new alc880_f1734_mixer[] = {
2232 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2233 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2234 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2235 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
2236 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2237 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2238 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2239 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
2243 static struct hda_input_mux alc880_f1734_capture_source = {
2255 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
2256 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
2257 * Mic = 0x18, Line = 0x1a
2260 #define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
2261 #define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
2263 static struct snd_kcontrol_new alc880_asus_mixer[] = {
2264 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2265 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2266 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2267 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
2268 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2269 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2270 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2271 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2272 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2273 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2274 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2275 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2276 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2277 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2279 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2280 .name = "Channel Mode",
2281 .info = alc_ch_mode_info,
2282 .get = alc_ch_mode_get,
2283 .put = alc_ch_mode_put,
2289 * ALC880 ASUS W1V model
2291 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
2292 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
2293 * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
2296 /* additional mixers to alc880_asus_mixer */
2297 static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
2298 HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
2299 HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
2304 static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
2305 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2306 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
2307 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
2308 HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
2309 HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
2310 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
2311 HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
2312 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
2313 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
2318 static struct snd_kcontrol_new alc880_uniwill_mixer[] = {
2319 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2320 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2321 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2322 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
2323 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2324 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2325 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2326 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2327 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2328 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2329 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2330 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2331 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2332 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2333 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2334 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
2336 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2337 .name = "Channel Mode",
2338 .info = alc_ch_mode_info,
2339 .get = alc_ch_mode_get,
2340 .put = alc_ch_mode_put,
2345 static struct snd_kcontrol_new alc880_fujitsu_mixer[] = {
2346 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2347 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2348 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2349 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
2350 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2351 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2352 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2353 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2354 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2355 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
2359 static struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = {
2360 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2361 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2362 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2363 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
2364 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2365 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2370 * virtual master controls
2374 * slave controls for virtual master
2376 static const char *alc_slave_vols[] = {
2377 "Front Playback Volume",
2378 "Surround Playback Volume",
2379 "Center Playback Volume",
2380 "LFE Playback Volume",
2381 "Side Playback Volume",
2382 "Headphone Playback Volume",
2383 "Speaker Playback Volume",
2384 "Mono Playback Volume",
2385 "Line-Out Playback Volume",
2386 "PCM Playback Volume",
2390 static const char *alc_slave_sws[] = {
2391 "Front Playback Switch",
2392 "Surround Playback Switch",
2393 "Center Playback Switch",
2394 "LFE Playback Switch",
2395 "Side Playback Switch",
2396 "Headphone Playback Switch",
2397 "Speaker Playback Switch",
2398 "Mono Playback Switch",
2399 "IEC958 Playback Switch",
2404 * build control elements
2407 static void alc_free_kctls(struct hda_codec *codec);
2409 /* additional beep mixers; the actual parameters are overwritten at build */
2410 static struct snd_kcontrol_new alc_beep_mixer[] = {
2411 HDA_CODEC_VOLUME("Beep Playback Volume", 0, 0, HDA_INPUT),
2412 HDA_CODEC_MUTE("Beep Playback Switch", 0, 0, HDA_INPUT),
2416 static int alc_build_controls(struct hda_codec *codec)
2418 struct alc_spec *spec = codec->spec;
2422 for (i = 0; i < spec->num_mixers; i++) {
2423 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
2427 if (spec->cap_mixer) {
2428 err = snd_hda_add_new_ctls(codec, spec->cap_mixer);
2432 if (spec->multiout.dig_out_nid) {
2433 err = snd_hda_create_spdif_out_ctls(codec,
2434 spec->multiout.dig_out_nid);
2437 if (!spec->no_analog) {
2438 err = snd_hda_create_spdif_share_sw(codec,
2442 spec->multiout.share_spdif = 1;
2445 if (spec->dig_in_nid) {
2446 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
2451 /* create beep controls if needed */
2452 if (spec->beep_amp) {
2453 struct snd_kcontrol_new *knew;
2454 for (knew = alc_beep_mixer; knew->name; knew++) {
2455 struct snd_kcontrol *kctl;
2456 kctl = snd_ctl_new1(knew, codec);
2459 kctl->private_value = spec->beep_amp;
2460 err = snd_hda_ctl_add(codec, kctl);
2466 /* if we have no master control, let's create it */
2467 if (!spec->no_analog &&
2468 !snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
2469 unsigned int vmaster_tlv[4];
2470 snd_hda_set_vmaster_tlv(codec, spec->vmaster_nid,
2471 HDA_OUTPUT, vmaster_tlv);
2472 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
2473 vmaster_tlv, alc_slave_vols);
2477 if (!spec->no_analog &&
2478 !snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
2479 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
2480 NULL, alc_slave_sws);
2485 alc_free_kctls(codec); /* no longer needed */
2491 * initialize the codec volumes, etc
2495 * generic initialization of ADC, input mixers and output mixers
2497 static struct hda_verb alc880_volume_init_verbs[] = {
2499 * Unmute ADC0-2 and set the default input to mic-in
2501 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
2502 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2503 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
2504 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2505 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
2506 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2508 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
2510 * Note: PASD motherboards uses the Line In 2 as the input for front
2513 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
2514 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2515 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2516 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
2517 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
2518 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
2519 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
2520 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
2523 * Set up output mixers (0x0c - 0x0f)
2525 /* set vol=0 to output mixers */
2526 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2527 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2528 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2529 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2530 /* set up input amps for analog loopback */
2531 /* Amp Indices: DAC = 0, mixer = 1 */
2532 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2533 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2534 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2535 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2536 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2537 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2538 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2539 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2545 * 3-stack pin configuration:
2546 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
2548 static struct hda_verb alc880_pin_3stack_init_verbs[] = {
2550 * preset connection lists of input pins
2551 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
2553 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
2554 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2555 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
2558 * Set pin mode and muting
2560 /* set front pin widgets 0x14 for output */
2561 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2562 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2563 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2564 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2565 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2566 /* Mic2 (as headphone out) for HP output */
2567 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2568 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2569 /* Line In pin widget for input */
2570 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2571 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2572 /* Line2 (as front mic) pin widget for input and vref at 80% */
2573 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2574 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2575 /* CD pin widget for input */
2576 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2582 * 5-stack pin configuration:
2583 * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
2584 * line-in/side = 0x1a, f-mic = 0x1b
2586 static struct hda_verb alc880_pin_5stack_init_verbs[] = {
2588 * preset connection lists of input pins
2589 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
2591 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2592 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
2595 * Set pin mode and muting
2597 /* set pin widgets 0x14-0x17 for output */
2598 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2599 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2600 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2601 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2602 /* unmute pins for output (no gain on this amp) */
2603 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2604 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2605 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2606 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2608 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2609 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2610 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2611 /* Mic2 (as headphone out) for HP output */
2612 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2613 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2614 /* Line In pin widget for input */
2615 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2616 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2617 /* Line2 (as front mic) pin widget for input and vref at 80% */
2618 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2619 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2620 /* CD pin widget for input */
2621 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2627 * W810 pin configuration:
2628 * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
2630 static struct hda_verb alc880_pin_w810_init_verbs[] = {
2631 /* hphone/speaker input selector: front DAC */
2632 {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
2634 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2635 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2636 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2637 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2638 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2639 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2641 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2642 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2648 * Z71V pin configuration:
2649 * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
2651 static struct hda_verb alc880_pin_z71v_init_verbs[] = {
2652 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2653 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2654 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2655 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2657 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2658 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2659 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2660 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2666 * 6-stack pin configuration:
2667 * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18,
2668 * f-mic = 0x19, line = 0x1a, HP = 0x1b
2670 static struct hda_verb alc880_pin_6stack_init_verbs[] = {
2671 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2673 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2674 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2675 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2676 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2677 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2678 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2679 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2680 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2682 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2683 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2684 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2685 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2686 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2687 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2688 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2689 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2690 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2696 * Uniwill pin configuration:
2697 * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19,
2700 static struct hda_verb alc880_uniwill_init_verbs[] = {
2701 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2703 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2704 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2705 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2706 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2707 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2708 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2709 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2710 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2711 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2712 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2713 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2714 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2715 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2716 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2718 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2719 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2720 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2721 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2722 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2723 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2724 /* {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, */
2725 /* {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
2726 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2728 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
2729 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
2736 * HP = 0x14, InternalSpeaker = 0x15, mic = 0x19,
2738 static struct hda_verb alc880_uniwill_p53_init_verbs[] = {
2739 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2741 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2742 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2743 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2744 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2745 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2746 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2747 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2748 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2749 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2750 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2751 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2752 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2754 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2755 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2756 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2757 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2758 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2759 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2761 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
2762 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_DCVOL_EVENT},
2767 static struct hda_verb alc880_beep_init_verbs[] = {
2768 { 0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5) },
2772 /* auto-toggle front mic */
2773 static void alc880_uniwill_mic_automute(struct hda_codec *codec)
2775 unsigned int present;
2778 present = snd_hda_codec_read(codec, 0x18, 0,
2779 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
2780 bits = present ? HDA_AMP_MUTE : 0;
2781 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
2784 static void alc880_uniwill_init_hook(struct hda_codec *codec)
2786 struct alc_spec *spec = codec->spec;
2788 spec->autocfg.hp_pins[0] = 0x14;
2789 spec->autocfg.speaker_pins[0] = 0x15;
2790 spec->autocfg.speaker_pins[0] = 0x16;
2791 alc_automute_amp(codec);
2792 alc880_uniwill_mic_automute(codec);
2795 static void alc880_uniwill_unsol_event(struct hda_codec *codec,
2798 /* Looks like the unsol event is incompatible with the standard
2799 * definition. 4bit tag is placed at 28 bit!
2801 switch (res >> 28) {
2802 case ALC880_MIC_EVENT:
2803 alc880_uniwill_mic_automute(codec);
2806 alc_automute_amp_unsol_event(codec, res);
2811 static void alc880_uniwill_p53_init_hook(struct hda_codec *codec)
2813 struct alc_spec *spec = codec->spec;
2815 spec->autocfg.hp_pins[0] = 0x14;
2816 spec->autocfg.speaker_pins[0] = 0x15;
2817 alc_automute_amp(codec);
2820 static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec)
2822 unsigned int present;
2824 present = snd_hda_codec_read(codec, 0x21, 0,
2825 AC_VERB_GET_VOLUME_KNOB_CONTROL, 0);
2826 present &= HDA_AMP_VOLMASK;
2827 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0,
2828 HDA_AMP_VOLMASK, present);
2829 snd_hda_codec_amp_stereo(codec, 0x0d, HDA_OUTPUT, 0,
2830 HDA_AMP_VOLMASK, present);
2833 static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec,
2836 /* Looks like the unsol event is incompatible with the standard
2837 * definition. 4bit tag is placed at 28 bit!
2839 if ((res >> 28) == ALC880_DCVOL_EVENT)
2840 alc880_uniwill_p53_dcvol_automute(codec);
2842 alc_automute_amp_unsol_event(codec, res);
2846 * F1734 pin configuration:
2847 * HP = 0x14, speaker-out = 0x15, mic = 0x18
2849 static struct hda_verb alc880_pin_f1734_init_verbs[] = {
2850 {0x07, AC_VERB_SET_CONNECT_SEL, 0x01},
2851 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
2852 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
2853 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
2854 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
2856 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2857 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2858 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2859 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2861 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2862 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2863 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
2864 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2865 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2866 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2867 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2868 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2869 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2871 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
2872 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_DCVOL_EVENT},
2878 * ASUS pin configuration:
2879 * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
2881 static struct hda_verb alc880_pin_asus_init_verbs[] = {
2882 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
2883 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
2884 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
2885 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
2887 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2888 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2889 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2890 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2891 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2892 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2893 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2894 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2896 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2897 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2898 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2899 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2900 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2901 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2902 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2903 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2904 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2909 /* Enable GPIO mask and set output */
2910 #define alc880_gpio1_init_verbs alc_gpio1_init_verbs
2911 #define alc880_gpio2_init_verbs alc_gpio2_init_verbs
2912 #define alc880_gpio3_init_verbs alc_gpio3_init_verbs
2914 /* Clevo m520g init */
2915 static struct hda_verb alc880_pin_clevo_init_verbs[] = {
2916 /* headphone output */
2917 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
2919 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2920 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2922 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2923 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2925 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2926 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2927 /* Mic1 (rear panel) */
2928 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2929 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2930 /* Mic2 (front panel) */
2931 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2932 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2934 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2935 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2936 /* change to EAPD mode */
2937 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2938 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
2943 static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
2944 /* change to EAPD mode */
2945 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2946 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
2948 /* Headphone output */
2949 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2951 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2952 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
2954 /* Line In pin widget for input */
2955 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2956 /* CD pin widget for input */
2957 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2958 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2959 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2961 /* change to EAPD mode */
2962 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2963 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
2969 * LG m1 express dual
2972 * Rear Line-In/Out (blue): 0x14
2973 * Build-in Mic-In: 0x15
2975 * HP-Out (green): 0x1b
2976 * Mic-In/Out (red): 0x19
2980 /* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
2981 static hda_nid_t alc880_lg_dac_nids[3] = {
2985 /* seems analog CD is not working */
2986 static struct hda_input_mux alc880_lg_capture_source = {
2991 { "Internal Mic", 0x6 },
2995 /* 2,4,6 channel modes */
2996 static struct hda_verb alc880_lg_ch2_init[] = {
2997 /* set line-in and mic-in to input */
2998 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
2999 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
3003 static struct hda_verb alc880_lg_ch4_init[] = {
3004 /* set line-in to out and mic-in to input */
3005 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
3006 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
3010 static struct hda_verb alc880_lg_ch6_init[] = {
3011 /* set line-in and mic-in to output */
3012 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
3013 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
3017 static struct hda_channel_mode alc880_lg_ch_modes[3] = {
3018 { 2, alc880_lg_ch2_init },
3019 { 4, alc880_lg_ch4_init },
3020 { 6, alc880_lg_ch6_init },
3023 static struct snd_kcontrol_new alc880_lg_mixer[] = {
3024 HDA_CODEC_VOLUME("Front Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
3025 HDA_BIND_MUTE("Front Playback Switch", 0x0f, 2, HDA_INPUT),
3026 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3027 HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
3028 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
3029 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
3030 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
3031 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
3032 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
3033 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
3034 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
3035 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
3036 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
3037 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
3039 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3040 .name = "Channel Mode",
3041 .info = alc_ch_mode_info,
3042 .get = alc_ch_mode_get,
3043 .put = alc_ch_mode_put,
3048 static struct hda_verb alc880_lg_init_verbs[] = {
3049 /* set capture source to mic-in */
3050 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3051 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3052 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3053 /* mute all amp mixer inputs */
3054 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
3055 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
3056 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
3057 /* line-in to input */
3058 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3059 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3061 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3062 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3064 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3065 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3066 /* mic-in to input */
3067 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
3068 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3069 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3071 {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
3072 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3073 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3075 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
3079 /* toggle speaker-output according to the hp-jack state */
3080 static void alc880_lg_init_hook(struct hda_codec *codec)
3082 struct alc_spec *spec = codec->spec;
3084 spec->autocfg.hp_pins[0] = 0x1b;
3085 spec->autocfg.speaker_pins[0] = 0x17;
3086 alc_automute_amp(codec);
3095 * Built-in Mic-In: 0x19
3101 static struct hda_input_mux alc880_lg_lw_capture_source = {
3105 { "Internal Mic", 0x1 },
3110 #define alc880_lg_lw_modes alc880_threestack_modes
3112 static struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
3113 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3114 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
3115 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
3116 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
3117 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
3118 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
3119 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
3120 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
3121 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
3122 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
3123 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
3124 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
3125 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
3126 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
3128 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3129 .name = "Channel Mode",
3130 .info = alc_ch_mode_info,
3131 .get = alc_ch_mode_get,
3132 .put = alc_ch_mode_put,
3137 static struct hda_verb alc880_lg_lw_init_verbs[] = {
3138 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3139 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
3140 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
3142 /* set capture source to mic-in */
3143 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3144 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},