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,
223 ALC888_ACER_ASPIRE_7730G,
227 ALC883_LENOVO_101E_2ch,
228 ALC883_LENOVO_NB0763,
229 ALC888_LENOVO_MS7195_DIG,
237 ALC883_FUJITSU_PI2515,
238 ALC888_FUJITSU_XA3530,
239 ALC883_3ST_6ch_INTEL,
252 #define GPIO_MASK 0x03
254 /* extra amp-initialization sequence types */
263 struct alc_mic_route {
265 unsigned char mux_idx;
266 unsigned char amix_idx;
269 #define MUX_IDX_UNDEF ((unsigned char)-1)
272 /* codec parameterization */
273 struct snd_kcontrol_new *mixers[5]; /* mixer arrays */
274 unsigned int num_mixers;
275 struct snd_kcontrol_new *cap_mixer; /* capture mixer */
276 unsigned int beep_amp; /* beep amp value, set via set_beep_amp() */
278 const struct hda_verb *init_verbs[5]; /* initialization verbs
282 unsigned int num_init_verbs;
284 char stream_name_analog[32]; /* analog PCM stream */
285 struct hda_pcm_stream *stream_analog_playback;
286 struct hda_pcm_stream *stream_analog_capture;
287 struct hda_pcm_stream *stream_analog_alt_playback;
288 struct hda_pcm_stream *stream_analog_alt_capture;
290 char stream_name_digital[32]; /* digital PCM stream */
291 struct hda_pcm_stream *stream_digital_playback;
292 struct hda_pcm_stream *stream_digital_capture;
295 struct hda_multi_out multiout; /* playback set-up
296 * max_channels, dacs must be set
297 * dig_out_nid and hp_nid are optional
299 hda_nid_t alt_dac_nid;
300 hda_nid_t slave_dig_outs[3]; /* optional - for auto-parsing */
304 unsigned int num_adc_nids;
306 hda_nid_t *capsrc_nids;
307 hda_nid_t dig_in_nid; /* digital-in NID; optional */
310 unsigned int num_mux_defs;
311 const struct hda_input_mux *input_mux;
312 unsigned int cur_mux[3];
313 struct alc_mic_route ext_mic;
314 struct alc_mic_route int_mic;
317 const struct hda_channel_mode *channel_mode;
318 int num_channel_mode;
320 int const_channel_count;
321 int ext_channel_count;
323 /* PCM information */
324 struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */
326 /* dynamic controls, init_verbs and input_mux */
327 struct auto_pin_cfg autocfg;
328 struct snd_array kctls;
329 struct hda_input_mux private_imux[3];
330 hda_nid_t private_dac_nids[AUTO_CFG_MAX_OUTS];
331 hda_nid_t private_adc_nids[AUTO_CFG_MAX_OUTS];
332 hda_nid_t private_capsrc_nids[AUTO_CFG_MAX_OUTS];
335 void (*init_hook)(struct hda_codec *codec);
336 void (*unsol_event)(struct hda_codec *codec, unsigned int res);
338 /* for pin sensing */
339 unsigned int sense_updated: 1;
340 unsigned int jack_present: 1;
341 unsigned int master_sw: 1;
342 unsigned int auto_mic:1;
345 unsigned int no_analog :1; /* digital I/O only */
348 /* for virtual master */
349 hda_nid_t vmaster_nid;
350 #ifdef CONFIG_SND_HDA_POWER_SAVE
351 struct hda_loopback_check loopback;
356 unsigned int pll_coef_idx, pll_coef_bit;
360 * configuration template - to be copied to the spec instance
362 struct alc_config_preset {
363 struct snd_kcontrol_new *mixers[5]; /* should be identical size
366 struct snd_kcontrol_new *cap_mixer; /* capture mixer */
367 const struct hda_verb *init_verbs[5];
368 unsigned int num_dacs;
370 hda_nid_t dig_out_nid; /* optional */
371 hda_nid_t hp_nid; /* optional */
372 hda_nid_t *slave_dig_outs;
373 unsigned int num_adc_nids;
375 hda_nid_t *capsrc_nids;
376 hda_nid_t dig_in_nid;
377 unsigned int num_channel_mode;
378 const struct hda_channel_mode *channel_mode;
380 int const_channel_count;
381 unsigned int num_mux_defs;
382 const struct hda_input_mux *input_mux;
383 void (*unsol_event)(struct hda_codec *, unsigned int);
384 void (*setup)(struct hda_codec *);
385 void (*init_hook)(struct hda_codec *);
386 #ifdef CONFIG_SND_HDA_POWER_SAVE
387 struct hda_amp_list *loopbacks;
395 static int alc_mux_enum_info(struct snd_kcontrol *kcontrol,
396 struct snd_ctl_elem_info *uinfo)
398 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
399 struct alc_spec *spec = codec->spec;
400 unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id);
401 if (mux_idx >= spec->num_mux_defs)
403 return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo);
406 static int alc_mux_enum_get(struct snd_kcontrol *kcontrol,
407 struct snd_ctl_elem_value *ucontrol)
409 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
410 struct alc_spec *spec = codec->spec;
411 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
413 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
417 static int alc_mux_enum_put(struct snd_kcontrol *kcontrol,
418 struct snd_ctl_elem_value *ucontrol)
420 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
421 struct alc_spec *spec = codec->spec;
422 const struct hda_input_mux *imux;
423 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
424 unsigned int mux_idx;
425 hda_nid_t nid = spec->capsrc_nids ?
426 spec->capsrc_nids[adc_idx] : spec->adc_nids[adc_idx];
429 mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx;
430 imux = &spec->input_mux[mux_idx];
432 type = get_wcaps_type(get_wcaps(codec, nid));
433 if (type == AC_WID_AUD_MIX) {
434 /* Matrix-mixer style (e.g. ALC882) */
435 unsigned int *cur_val = &spec->cur_mux[adc_idx];
438 idx = ucontrol->value.enumerated.item[0];
439 if (idx >= imux->num_items)
440 idx = imux->num_items - 1;
443 for (i = 0; i < imux->num_items; i++) {
444 unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
445 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
446 imux->items[i].index,
452 /* MUX style (e.g. ALC880) */
453 return snd_hda_input_mux_put(codec, imux, ucontrol, nid,
454 &spec->cur_mux[adc_idx]);
459 * channel mode setting
461 static int alc_ch_mode_info(struct snd_kcontrol *kcontrol,
462 struct snd_ctl_elem_info *uinfo)
464 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
465 struct alc_spec *spec = codec->spec;
466 return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
467 spec->num_channel_mode);
470 static int alc_ch_mode_get(struct snd_kcontrol *kcontrol,
471 struct snd_ctl_elem_value *ucontrol)
473 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
474 struct alc_spec *spec = codec->spec;
475 return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
476 spec->num_channel_mode,
477 spec->ext_channel_count);
480 static int alc_ch_mode_put(struct snd_kcontrol *kcontrol,
481 struct snd_ctl_elem_value *ucontrol)
483 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
484 struct alc_spec *spec = codec->spec;
485 int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
486 spec->num_channel_mode,
487 &spec->ext_channel_count);
488 if (err >= 0 && !spec->const_channel_count) {
489 spec->multiout.max_channels = spec->ext_channel_count;
490 if (spec->need_dac_fix)
491 spec->multiout.num_dacs = spec->multiout.max_channels / 2;
497 * Control the mode of pin widget settings via the mixer. "pc" is used
498 * instead of "%" to avoid consequences of accidently treating the % as
499 * being part of a format specifier. Maximum allowed length of a value is
500 * 63 characters plus NULL terminator.
502 * Note: some retasking pin complexes seem to ignore requests for input
503 * states other than HiZ (eg: PIN_VREFxx) and revert to HiZ if any of these
504 * are requested. Therefore order this list so that this behaviour will not
505 * cause problems when mixer clients move through the enum sequentially.
506 * NIDs 0x0f and 0x10 have been observed to have this behaviour as of
509 static char *alc_pin_mode_names[] = {
510 "Mic 50pc bias", "Mic 80pc bias",
511 "Line in", "Line out", "Headphone out",
513 static unsigned char alc_pin_mode_values[] = {
514 PIN_VREF50, PIN_VREF80, PIN_IN, PIN_OUT, PIN_HP,
516 /* The control can present all 5 options, or it can limit the options based
517 * in the pin being assumed to be exclusively an input or an output pin. In
518 * addition, "input" pins may or may not process the mic bias option
519 * depending on actual widget capability (NIDs 0x0f and 0x10 don't seem to
520 * accept requests for bias as of chip versions up to March 2006) and/or
521 * wiring in the computer.
523 #define ALC_PIN_DIR_IN 0x00
524 #define ALC_PIN_DIR_OUT 0x01
525 #define ALC_PIN_DIR_INOUT 0x02
526 #define ALC_PIN_DIR_IN_NOMICBIAS 0x03
527 #define ALC_PIN_DIR_INOUT_NOMICBIAS 0x04
529 /* Info about the pin modes supported by the different pin direction modes.
530 * For each direction the minimum and maximum values are given.
532 static signed char alc_pin_mode_dir_info[5][2] = {
533 { 0, 2 }, /* ALC_PIN_DIR_IN */
534 { 3, 4 }, /* ALC_PIN_DIR_OUT */
535 { 0, 4 }, /* ALC_PIN_DIR_INOUT */
536 { 2, 2 }, /* ALC_PIN_DIR_IN_NOMICBIAS */
537 { 2, 4 }, /* ALC_PIN_DIR_INOUT_NOMICBIAS */
539 #define alc_pin_mode_min(_dir) (alc_pin_mode_dir_info[_dir][0])
540 #define alc_pin_mode_max(_dir) (alc_pin_mode_dir_info[_dir][1])
541 #define alc_pin_mode_n_items(_dir) \
542 (alc_pin_mode_max(_dir)-alc_pin_mode_min(_dir)+1)
544 static int alc_pin_mode_info(struct snd_kcontrol *kcontrol,
545 struct snd_ctl_elem_info *uinfo)
547 unsigned int item_num = uinfo->value.enumerated.item;
548 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
550 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
552 uinfo->value.enumerated.items = alc_pin_mode_n_items(dir);
554 if (item_num<alc_pin_mode_min(dir) || item_num>alc_pin_mode_max(dir))
555 item_num = alc_pin_mode_min(dir);
556 strcpy(uinfo->value.enumerated.name, alc_pin_mode_names[item_num]);
560 static int alc_pin_mode_get(struct snd_kcontrol *kcontrol,
561 struct snd_ctl_elem_value *ucontrol)
564 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
565 hda_nid_t nid = kcontrol->private_value & 0xffff;
566 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
567 long *valp = ucontrol->value.integer.value;
568 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
569 AC_VERB_GET_PIN_WIDGET_CONTROL,
572 /* Find enumerated value for current pinctl setting */
573 i = alc_pin_mode_min(dir);
574 while (i <= alc_pin_mode_max(dir) && alc_pin_mode_values[i] != pinctl)
576 *valp = i <= alc_pin_mode_max(dir) ? i: alc_pin_mode_min(dir);
580 static int alc_pin_mode_put(struct snd_kcontrol *kcontrol,
581 struct snd_ctl_elem_value *ucontrol)
584 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
585 hda_nid_t nid = kcontrol->private_value & 0xffff;
586 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
587 long val = *ucontrol->value.integer.value;
588 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
589 AC_VERB_GET_PIN_WIDGET_CONTROL,
592 if (val < alc_pin_mode_min(dir) || val > alc_pin_mode_max(dir))
593 val = alc_pin_mode_min(dir);
595 change = pinctl != alc_pin_mode_values[val];
597 /* Set pin mode to that requested */
598 snd_hda_codec_write_cache(codec, nid, 0,
599 AC_VERB_SET_PIN_WIDGET_CONTROL,
600 alc_pin_mode_values[val]);
602 /* Also enable the retasking pin's input/output as required
603 * for the requested pin mode. Enum values of 2 or less are
606 * Dynamically switching the input/output buffers probably
607 * reduces noise slightly (particularly on input) so we'll
608 * do it. However, having both input and output buffers
609 * enabled simultaneously doesn't seem to be problematic if
610 * this turns out to be necessary in the future.
613 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
614 HDA_AMP_MUTE, HDA_AMP_MUTE);
615 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
618 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
619 HDA_AMP_MUTE, HDA_AMP_MUTE);
620 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
627 #define ALC_PIN_MODE(xname, nid, dir) \
628 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
629 .info = alc_pin_mode_info, \
630 .get = alc_pin_mode_get, \
631 .put = alc_pin_mode_put, \
632 .private_value = nid | (dir<<16) }
634 /* A switch control for ALC260 GPIO pins. Multiple GPIOs can be ganged
635 * together using a mask with more than one bit set. This control is
636 * currently used only by the ALC260 test model. At this stage they are not
637 * needed for any "production" models.
639 #ifdef CONFIG_SND_DEBUG
640 #define alc_gpio_data_info snd_ctl_boolean_mono_info
642 static int alc_gpio_data_get(struct snd_kcontrol *kcontrol,
643 struct snd_ctl_elem_value *ucontrol)
645 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
646 hda_nid_t nid = kcontrol->private_value & 0xffff;
647 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
648 long *valp = ucontrol->value.integer.value;
649 unsigned int val = snd_hda_codec_read(codec, nid, 0,
650 AC_VERB_GET_GPIO_DATA, 0x00);
652 *valp = (val & mask) != 0;
655 static int alc_gpio_data_put(struct snd_kcontrol *kcontrol,
656 struct snd_ctl_elem_value *ucontrol)
659 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
660 hda_nid_t nid = kcontrol->private_value & 0xffff;
661 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
662 long val = *ucontrol->value.integer.value;
663 unsigned int gpio_data = snd_hda_codec_read(codec, nid, 0,
664 AC_VERB_GET_GPIO_DATA,
667 /* Set/unset the masked GPIO bit(s) as needed */
668 change = (val == 0 ? 0 : mask) != (gpio_data & mask);
673 snd_hda_codec_write_cache(codec, nid, 0,
674 AC_VERB_SET_GPIO_DATA, gpio_data);
678 #define ALC_GPIO_DATA_SWITCH(xname, nid, mask) \
679 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
680 .info = alc_gpio_data_info, \
681 .get = alc_gpio_data_get, \
682 .put = alc_gpio_data_put, \
683 .private_value = nid | (mask<<16) }
684 #endif /* CONFIG_SND_DEBUG */
686 /* A switch control to allow the enabling of the digital IO pins on the
687 * ALC260. This is incredibly simplistic; the intention of this control is
688 * to provide something in the test model allowing digital outputs to be
689 * identified if present. If models are found which can utilise these
690 * outputs a more complete mixer control can be devised for those models if
693 #ifdef CONFIG_SND_DEBUG
694 #define alc_spdif_ctrl_info snd_ctl_boolean_mono_info
696 static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol,
697 struct snd_ctl_elem_value *ucontrol)
699 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
700 hda_nid_t nid = kcontrol->private_value & 0xffff;
701 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
702 long *valp = ucontrol->value.integer.value;
703 unsigned int val = snd_hda_codec_read(codec, nid, 0,
704 AC_VERB_GET_DIGI_CONVERT_1, 0x00);
706 *valp = (val & mask) != 0;
709 static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol,
710 struct snd_ctl_elem_value *ucontrol)
713 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
714 hda_nid_t nid = kcontrol->private_value & 0xffff;
715 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
716 long val = *ucontrol->value.integer.value;
717 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
718 AC_VERB_GET_DIGI_CONVERT_1,
721 /* Set/unset the masked control bit(s) as needed */
722 change = (val == 0 ? 0 : mask) != (ctrl_data & mask);
727 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1,
732 #define ALC_SPDIF_CTRL_SWITCH(xname, nid, mask) \
733 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
734 .info = alc_spdif_ctrl_info, \
735 .get = alc_spdif_ctrl_get, \
736 .put = alc_spdif_ctrl_put, \
737 .private_value = nid | (mask<<16) }
738 #endif /* CONFIG_SND_DEBUG */
740 /* A switch control to allow the enabling EAPD digital outputs on the ALC26x.
741 * Again, this is only used in the ALC26x test models to help identify when
742 * the EAPD line must be asserted for features to work.
744 #ifdef CONFIG_SND_DEBUG
745 #define alc_eapd_ctrl_info snd_ctl_boolean_mono_info
747 static int alc_eapd_ctrl_get(struct snd_kcontrol *kcontrol,
748 struct snd_ctl_elem_value *ucontrol)
750 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
751 hda_nid_t nid = kcontrol->private_value & 0xffff;
752 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
753 long *valp = ucontrol->value.integer.value;
754 unsigned int val = snd_hda_codec_read(codec, nid, 0,
755 AC_VERB_GET_EAPD_BTLENABLE, 0x00);
757 *valp = (val & mask) != 0;
761 static int alc_eapd_ctrl_put(struct snd_kcontrol *kcontrol,
762 struct snd_ctl_elem_value *ucontrol)
765 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
766 hda_nid_t nid = kcontrol->private_value & 0xffff;
767 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
768 long val = *ucontrol->value.integer.value;
769 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
770 AC_VERB_GET_EAPD_BTLENABLE,
773 /* Set/unset the masked control bit(s) as needed */
774 change = (!val ? 0 : mask) != (ctrl_data & mask);
779 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
785 #define ALC_EAPD_CTRL_SWITCH(xname, nid, mask) \
786 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
787 .info = alc_eapd_ctrl_info, \
788 .get = alc_eapd_ctrl_get, \
789 .put = alc_eapd_ctrl_put, \
790 .private_value = nid | (mask<<16) }
791 #endif /* CONFIG_SND_DEBUG */
794 * set up the input pin config (depending on the given auto-pin type)
796 static void alc_set_input_pin(struct hda_codec *codec, hda_nid_t nid,
799 unsigned int val = PIN_IN;
801 if (auto_pin_type <= AUTO_PIN_FRONT_MIC) {
803 pincap = snd_hda_query_pin_caps(codec, nid);
804 pincap = (pincap & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT;
805 if (pincap & AC_PINCAP_VREF_80)
807 else if (pincap & AC_PINCAP_VREF_50)
809 else if (pincap & AC_PINCAP_VREF_100)
811 else if (pincap & AC_PINCAP_VREF_GRD)
814 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, val);
819 static void add_mixer(struct alc_spec *spec, struct snd_kcontrol_new *mix)
821 if (snd_BUG_ON(spec->num_mixers >= ARRAY_SIZE(spec->mixers)))
823 spec->mixers[spec->num_mixers++] = mix;
826 static void add_verb(struct alc_spec *spec, const struct hda_verb *verb)
828 if (snd_BUG_ON(spec->num_init_verbs >= ARRAY_SIZE(spec->init_verbs)))
830 spec->init_verbs[spec->num_init_verbs++] = verb;
833 #ifdef CONFIG_PROC_FS
837 static void print_realtek_coef(struct snd_info_buffer *buffer,
838 struct hda_codec *codec, hda_nid_t nid)
844 coeff = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_PROC_COEF, 0);
845 snd_iprintf(buffer, " Processing Coefficient: 0x%02x\n", coeff);
846 coeff = snd_hda_codec_read(codec, nid, 0,
847 AC_VERB_GET_COEF_INDEX, 0);
848 snd_iprintf(buffer, " Coefficient Index: 0x%02x\n", coeff);
851 #define print_realtek_coef NULL
855 * set up from the preset table
857 static void setup_preset(struct hda_codec *codec,
858 const struct alc_config_preset *preset)
860 struct alc_spec *spec = codec->spec;
863 for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++)
864 add_mixer(spec, preset->mixers[i]);
865 spec->cap_mixer = preset->cap_mixer;
866 for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i];
868 add_verb(spec, preset->init_verbs[i]);
870 spec->channel_mode = preset->channel_mode;
871 spec->num_channel_mode = preset->num_channel_mode;
872 spec->need_dac_fix = preset->need_dac_fix;
873 spec->const_channel_count = preset->const_channel_count;
875 if (preset->const_channel_count)
876 spec->multiout.max_channels = preset->const_channel_count;
878 spec->multiout.max_channels = spec->channel_mode[0].channels;
879 spec->ext_channel_count = spec->channel_mode[0].channels;
881 spec->multiout.num_dacs = preset->num_dacs;
882 spec->multiout.dac_nids = preset->dac_nids;
883 spec->multiout.dig_out_nid = preset->dig_out_nid;
884 spec->multiout.slave_dig_outs = preset->slave_dig_outs;
885 spec->multiout.hp_nid = preset->hp_nid;
887 spec->num_mux_defs = preset->num_mux_defs;
888 if (!spec->num_mux_defs)
889 spec->num_mux_defs = 1;
890 spec->input_mux = preset->input_mux;
892 spec->num_adc_nids = preset->num_adc_nids;
893 spec->adc_nids = preset->adc_nids;
894 spec->capsrc_nids = preset->capsrc_nids;
895 spec->dig_in_nid = preset->dig_in_nid;
897 spec->unsol_event = preset->unsol_event;
898 spec->init_hook = preset->init_hook;
899 #ifdef CONFIG_SND_HDA_POWER_SAVE
900 spec->loopback.amplist = preset->loopbacks;
904 preset->setup(codec);
907 /* Enable GPIO mask and set output */
908 static struct hda_verb alc_gpio1_init_verbs[] = {
909 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
910 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
911 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
915 static struct hda_verb alc_gpio2_init_verbs[] = {
916 {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
917 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
918 {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
922 static struct hda_verb alc_gpio3_init_verbs[] = {
923 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
924 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
925 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
930 * Fix hardware PLL issue
931 * On some codecs, the analog PLL gating control must be off while
932 * the default value is 1.
934 static void alc_fix_pll(struct hda_codec *codec)
936 struct alc_spec *spec = codec->spec;
941 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX,
943 val = snd_hda_codec_read(codec, spec->pll_nid, 0,
944 AC_VERB_GET_PROC_COEF, 0);
945 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX,
947 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_PROC_COEF,
948 val & ~(1 << spec->pll_coef_bit));
951 static void alc_fix_pll_init(struct hda_codec *codec, hda_nid_t nid,
952 unsigned int coef_idx, unsigned int coef_bit)
954 struct alc_spec *spec = codec->spec;
956 spec->pll_coef_idx = coef_idx;
957 spec->pll_coef_bit = coef_bit;
961 static void alc_automute_pin(struct hda_codec *codec)
963 struct alc_spec *spec = codec->spec;
964 unsigned int present, pincap;
965 unsigned int nid = spec->autocfg.hp_pins[0];
968 pincap = snd_hda_query_pin_caps(codec, nid);
969 if (pincap & AC_PINCAP_TRIG_REQ) /* need trigger? */
970 snd_hda_codec_read(codec, nid, 0, AC_VERB_SET_PIN_SENSE, 0);
971 present = snd_hda_codec_read(codec, nid, 0,
972 AC_VERB_GET_PIN_SENSE, 0);
973 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
974 for (i = 0; i < ARRAY_SIZE(spec->autocfg.speaker_pins); i++) {
975 nid = spec->autocfg.speaker_pins[i];
978 snd_hda_codec_write(codec, nid, 0,
979 AC_VERB_SET_PIN_WIDGET_CONTROL,
980 spec->jack_present ? 0 : PIN_OUT);
984 static int get_connection_index(struct hda_codec *codec, hda_nid_t mux,
987 hda_nid_t conn[HDA_MAX_NUM_INPUTS];
990 nums = snd_hda_get_connections(codec, mux, conn, ARRAY_SIZE(conn));
991 for (i = 0; i < nums; i++)
997 static void alc_mic_automute(struct hda_codec *codec)
999 struct alc_spec *spec = codec->spec;
1000 struct alc_mic_route *dead, *alive;
1001 unsigned int present, type;
1004 if (!spec->auto_mic)
1006 if (!spec->int_mic.pin || !spec->ext_mic.pin)
1008 if (snd_BUG_ON(!spec->adc_nids))
1011 cap_nid = spec->capsrc_nids ? spec->capsrc_nids[0] : spec->adc_nids[0];
1013 present = snd_hda_codec_read(codec, spec->ext_mic.pin, 0,
1014 AC_VERB_GET_PIN_SENSE, 0);
1015 present &= AC_PINSENSE_PRESENCE;
1017 alive = &spec->ext_mic;
1018 dead = &spec->int_mic;
1020 alive = &spec->int_mic;
1021 dead = &spec->ext_mic;
1024 type = get_wcaps_type(get_wcaps(codec, cap_nid));
1025 if (type == AC_WID_AUD_MIX) {
1026 /* Matrix-mixer style (e.g. ALC882) */
1027 snd_hda_codec_amp_stereo(codec, cap_nid, HDA_INPUT,
1030 snd_hda_codec_amp_stereo(codec, cap_nid, HDA_INPUT,
1032 HDA_AMP_MUTE, HDA_AMP_MUTE);
1034 /* MUX style (e.g. ALC880) */
1035 snd_hda_codec_write_cache(codec, cap_nid, 0,
1036 AC_VERB_SET_CONNECT_SEL,
1040 /* FIXME: analog mixer */
1043 /* unsolicited event for HP jack sensing */
1044 static void alc_sku_unsol_event(struct hda_codec *codec, unsigned int res)
1046 if (codec->vendor_id == 0x10ec0880)
1051 case ALC880_HP_EVENT:
1052 alc_automute_pin(codec);
1054 case ALC880_MIC_EVENT:
1055 alc_mic_automute(codec);
1060 static void alc_inithook(struct hda_codec *codec)
1062 alc_automute_pin(codec);
1063 alc_mic_automute(codec);
1066 /* additional initialization for ALC888 variants */
1067 static void alc888_coef_init(struct hda_codec *codec)
1071 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 0);
1072 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
1073 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
1074 if ((tmp & 0xf0) == 0x20)
1076 snd_hda_codec_read(codec, 0x20, 0,
1077 AC_VERB_SET_PROC_COEF, 0x830);
1080 snd_hda_codec_read(codec, 0x20, 0,
1081 AC_VERB_SET_PROC_COEF, 0x3030);
1084 static void alc889_coef_init(struct hda_codec *codec)
1088 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
1089 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
1090 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
1091 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_PROC_COEF, tmp|0x2010);
1094 static void alc_auto_init_amp(struct hda_codec *codec, int type)
1099 case ALC_INIT_GPIO1:
1100 snd_hda_sequence_write(codec, alc_gpio1_init_verbs);
1102 case ALC_INIT_GPIO2:
1103 snd_hda_sequence_write(codec, alc_gpio2_init_verbs);
1105 case ALC_INIT_GPIO3:
1106 snd_hda_sequence_write(codec, alc_gpio3_init_verbs);
1108 case ALC_INIT_DEFAULT:
1109 switch (codec->vendor_id) {
1111 snd_hda_codec_write(codec, 0x0f, 0,
1112 AC_VERB_SET_EAPD_BTLENABLE, 2);
1113 snd_hda_codec_write(codec, 0x10, 0,
1114 AC_VERB_SET_EAPD_BTLENABLE, 2);
1126 snd_hda_codec_write(codec, 0x14, 0,
1127 AC_VERB_SET_EAPD_BTLENABLE, 2);
1128 snd_hda_codec_write(codec, 0x15, 0,
1129 AC_VERB_SET_EAPD_BTLENABLE, 2);
1132 switch (codec->vendor_id) {
1134 snd_hda_codec_write(codec, 0x1a, 0,
1135 AC_VERB_SET_COEF_INDEX, 7);
1136 tmp = snd_hda_codec_read(codec, 0x1a, 0,
1137 AC_VERB_GET_PROC_COEF, 0);
1138 snd_hda_codec_write(codec, 0x1a, 0,
1139 AC_VERB_SET_COEF_INDEX, 7);
1140 snd_hda_codec_write(codec, 0x1a, 0,
1141 AC_VERB_SET_PROC_COEF,
1151 alc889_coef_init(codec);
1154 alc888_coef_init(codec);
1158 snd_hda_codec_write(codec, 0x20, 0,
1159 AC_VERB_SET_COEF_INDEX, 7);
1160 tmp = snd_hda_codec_read(codec, 0x20, 0,
1161 AC_VERB_GET_PROC_COEF, 0);
1162 snd_hda_codec_write(codec, 0x20, 0,
1163 AC_VERB_SET_COEF_INDEX, 7);
1164 snd_hda_codec_write(codec, 0x20, 0,
1165 AC_VERB_SET_PROC_COEF,
1173 static void alc_init_auto_hp(struct hda_codec *codec)
1175 struct alc_spec *spec = codec->spec;
1177 if (!spec->autocfg.hp_pins[0])
1180 if (!spec->autocfg.speaker_pins[0]) {
1181 if (spec->autocfg.line_out_pins[0] &&
1182 spec->autocfg.line_out_type == AUTO_PIN_SPEAKER_OUT)
1183 spec->autocfg.speaker_pins[0] =
1184 spec->autocfg.line_out_pins[0];
1189 snd_printdd("realtek: Enable HP auto-muting on NID 0x%x\n",
1190 spec->autocfg.hp_pins[0]);
1191 snd_hda_codec_write_cache(codec, spec->autocfg.hp_pins[0], 0,
1192 AC_VERB_SET_UNSOLICITED_ENABLE,
1193 AC_USRSP_EN | ALC880_HP_EVENT);
1194 spec->unsol_event = alc_sku_unsol_event;
1197 static void alc_init_auto_mic(struct hda_codec *codec)
1199 struct alc_spec *spec = codec->spec;
1200 struct auto_pin_cfg *cfg = &spec->autocfg;
1201 hda_nid_t fixed, ext;
1204 /* there must be only two mic inputs exclusively */
1205 for (i = AUTO_PIN_LINE; i < AUTO_PIN_LAST; i++)
1206 if (cfg->input_pins[i])
1210 for (i = AUTO_PIN_MIC; i <= AUTO_PIN_FRONT_MIC; i++) {
1211 hda_nid_t nid = cfg->input_pins[i];
1212 unsigned int defcfg;
1215 defcfg = snd_hda_codec_get_pincfg(codec, nid);
1216 switch (get_defcfg_connect(defcfg)) {
1217 case AC_JACK_PORT_FIXED:
1219 return; /* already occupied */
1222 case AC_JACK_PORT_COMPLEX:
1224 return; /* already occupied */
1228 return; /* invalid entry */
1231 if (!(get_wcaps(codec, ext) & AC_WCAP_UNSOL_CAP))
1232 return; /* no unsol support */
1233 snd_printdd("realtek: Enable auto-mic switch on NID 0x%x/0x%x\n",
1235 spec->ext_mic.pin = ext;
1236 spec->int_mic.pin = fixed;
1237 spec->ext_mic.mux_idx = MUX_IDX_UNDEF; /* set later */
1238 spec->int_mic.mux_idx = MUX_IDX_UNDEF; /* set later */
1240 snd_hda_codec_write_cache(codec, spec->ext_mic.pin, 0,
1241 AC_VERB_SET_UNSOLICITED_ENABLE,
1242 AC_USRSP_EN | ALC880_MIC_EVENT);
1243 spec->unsol_event = alc_sku_unsol_event;
1246 /* check subsystem ID and set up device-specific initialization;
1247 * return 1 if initialized, 0 if invalid SSID
1249 /* 32-bit subsystem ID for BIOS loading in HD Audio codec.
1250 * 31 ~ 16 : Manufacture ID
1252 * 7 ~ 0 : Assembly ID
1253 * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36
1255 static int alc_subsystem_id(struct hda_codec *codec,
1256 hda_nid_t porta, hda_nid_t porte,
1259 unsigned int ass, tmp, i;
1261 struct alc_spec *spec = codec->spec;
1263 ass = codec->subsystem_id & 0xffff;
1264 if ((ass != codec->bus->pci->subsystem_device) && (ass & 1))
1267 /* invalid SSID, check the special NID pin defcfg instead */
1269 * 31~30 : port connectivity
1272 * 19~16 : Check sum (15:1)
1277 if (codec->vendor_id == 0x10ec0260)
1279 ass = snd_hda_codec_get_pincfg(codec, nid);
1280 snd_printd("realtek: No valid SSID, "
1281 "checking pincfg 0x%08x for NID 0x%x\n",
1283 if (!(ass & 1) && !(ass & 0x100000))
1285 if ((ass >> 30) != 1) /* no physical connection */
1290 for (i = 1; i < 16; i++) {
1294 if (((ass >> 16) & 0xf) != tmp)
1297 snd_printd("realtek: Enabling init ASM_ID=0x%04x CODEC_ID=%08x\n",
1298 ass & 0xffff, codec->vendor_id);
1302 * 2 : 0 --> Desktop, 1 --> Laptop
1303 * 3~5 : External Amplifier control
1306 tmp = (ass & 0x38) >> 3; /* external Amp control */
1309 spec->init_amp = ALC_INIT_GPIO1;
1312 spec->init_amp = ALC_INIT_GPIO2;
1315 spec->init_amp = ALC_INIT_GPIO3;
1318 spec->init_amp = ALC_INIT_DEFAULT;
1322 /* is laptop or Desktop and enable the function "Mute internal speaker
1323 * when the external headphone out jack is plugged"
1325 if (!(ass & 0x8000))
1328 * 10~8 : Jack location
1329 * 12~11: Headphone out -> 00: PortA, 01: PortE, 02: PortD, 03: Resvered
1331 * 15 : 1 --> enable the function "Mute internal speaker
1332 * when the external headphone out jack is plugged"
1334 if (!spec->autocfg.hp_pins[0]) {
1335 tmp = (ass >> 11) & 0x3; /* HP to chassis */
1337 spec->autocfg.hp_pins[0] = porta;
1339 spec->autocfg.hp_pins[0] = porte;
1341 spec->autocfg.hp_pins[0] = portd;
1346 alc_init_auto_hp(codec);
1347 alc_init_auto_mic(codec);
1351 static void alc_ssid_check(struct hda_codec *codec,
1352 hda_nid_t porta, hda_nid_t porte, hda_nid_t portd)
1354 if (!alc_subsystem_id(codec, porta, porte, portd)) {
1355 struct alc_spec *spec = codec->spec;
1356 snd_printd("realtek: "
1357 "Enable default setup for auto mode as fallback\n");
1358 spec->init_amp = ALC_INIT_DEFAULT;
1359 alc_init_auto_hp(codec);
1360 alc_init_auto_mic(codec);
1365 * Fix-up pin default configurations
1373 static void alc_fix_pincfg(struct hda_codec *codec,
1374 const struct snd_pci_quirk *quirk,
1375 const struct alc_pincfg **pinfix)
1377 const struct alc_pincfg *cfg;
1379 quirk = snd_pci_quirk_lookup(codec->bus->pci, quirk);
1383 cfg = pinfix[quirk->value];
1384 for (; cfg->nid; cfg++)
1385 snd_hda_codec_set_pincfg(codec, cfg->nid, cfg->val);
1395 static struct hda_verb alc888_4ST_ch2_intel_init[] = {
1396 /* Mic-in jack as mic in */
1397 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1398 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1399 /* Line-in jack as Line in */
1400 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1401 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1402 /* Line-Out as Front */
1403 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
1410 static struct hda_verb alc888_4ST_ch4_intel_init[] = {
1411 /* Mic-in jack as mic in */
1412 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1413 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1414 /* Line-in jack as Surround */
1415 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1416 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1417 /* Line-Out as Front */
1418 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
1425 static struct hda_verb alc888_4ST_ch6_intel_init[] = {
1426 /* Mic-in jack as CLFE */
1427 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1428 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1429 /* Line-in jack as Surround */
1430 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1431 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1432 /* Line-Out as CLFE (workaround because Mic-in is not loud enough) */
1433 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1440 static struct hda_verb alc888_4ST_ch8_intel_init[] = {
1441 /* Mic-in jack as CLFE */
1442 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1443 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1444 /* Line-in jack as Surround */
1445 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1446 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1447 /* Line-Out as Side */
1448 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1452 static struct hda_channel_mode alc888_4ST_8ch_intel_modes[4] = {
1453 { 2, alc888_4ST_ch2_intel_init },
1454 { 4, alc888_4ST_ch4_intel_init },
1455 { 6, alc888_4ST_ch6_intel_init },
1456 { 8, alc888_4ST_ch8_intel_init },
1460 * ALC888 Fujitsu Siemens Amillo xa3530
1463 static struct hda_verb alc888_fujitsu_xa3530_verbs[] = {
1464 /* Front Mic: set to PIN_IN (empty by default) */
1465 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1466 /* Connect Internal HP to Front */
1467 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1468 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1469 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1470 /* Connect Bass HP to Front */
1471 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1472 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1473 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1474 /* Connect Line-Out side jack (SPDIF) to Side */
1475 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1476 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1477 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1478 /* Connect Mic jack to CLFE */
1479 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1480 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1481 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02},
1482 /* Connect Line-in jack to Surround */
1483 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1484 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1485 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
1486 /* Connect HP out jack to Front */
1487 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1488 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1489 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
1490 /* Enable unsolicited event for HP jack and Line-out jack */
1491 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1492 {0x17, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1496 static void alc_automute_amp(struct hda_codec *codec)
1498 struct alc_spec *spec = codec->spec;
1499 unsigned int val, mute, pincap;
1503 spec->jack_present = 0;
1504 for (i = 0; i < ARRAY_SIZE(spec->autocfg.hp_pins); i++) {
1505 nid = spec->autocfg.hp_pins[i];
1508 pincap = snd_hda_query_pin_caps(codec, nid);
1509 if (pincap & AC_PINCAP_TRIG_REQ) /* need trigger? */
1510 snd_hda_codec_read(codec, nid, 0,
1511 AC_VERB_SET_PIN_SENSE, 0);
1512 val = snd_hda_codec_read(codec, nid, 0,
1513 AC_VERB_GET_PIN_SENSE, 0);
1514 if (val & AC_PINSENSE_PRESENCE) {
1515 spec->jack_present = 1;
1520 mute = spec->jack_present ? HDA_AMP_MUTE : 0;
1521 /* Toggle internal speakers muting */
1522 for (i = 0; i < ARRAY_SIZE(spec->autocfg.speaker_pins); i++) {
1523 nid = spec->autocfg.speaker_pins[i];
1526 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
1527 HDA_AMP_MUTE, mute);
1531 static void alc_automute_amp_unsol_event(struct hda_codec *codec,
1534 if (codec->vendor_id == 0x10ec0880)
1538 if (res == ALC880_HP_EVENT)
1539 alc_automute_amp(codec);
1542 static void alc889_automute_setup(struct hda_codec *codec)
1544 struct alc_spec *spec = codec->spec;
1546 spec->autocfg.hp_pins[0] = 0x15;
1547 spec->autocfg.speaker_pins[0] = 0x14;
1548 spec->autocfg.speaker_pins[1] = 0x16;
1549 spec->autocfg.speaker_pins[2] = 0x17;
1550 spec->autocfg.speaker_pins[3] = 0x19;
1551 spec->autocfg.speaker_pins[4] = 0x1a;
1554 static void alc889_intel_init_hook(struct hda_codec *codec)
1556 alc889_coef_init(codec);
1557 alc_automute_amp(codec);
1560 static void alc888_fujitsu_xa3530_setup(struct hda_codec *codec)
1562 struct alc_spec *spec = codec->spec;
1564 spec->autocfg.hp_pins[0] = 0x17; /* line-out */
1565 spec->autocfg.hp_pins[1] = 0x1b; /* hp */
1566 spec->autocfg.speaker_pins[0] = 0x14; /* speaker */
1567 spec->autocfg.speaker_pins[1] = 0x15; /* bass */
1571 * ALC888 Acer Aspire 4930G model
1574 static struct hda_verb alc888_acer_aspire_4930g_verbs[] = {
1575 /* Front Mic: set to PIN_IN (empty by default) */
1576 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1577 /* Unselect Front Mic by default in input mixer 3 */
1578 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
1579 /* Enable unsolicited event for HP jack */
1580 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1581 /* Connect Internal HP to front */
1582 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1583 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1584 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1585 /* Connect HP out to front */
1586 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1587 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1588 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1593 * ALC888 Acer Aspire 6530G model
1596 static struct hda_verb alc888_acer_aspire_6530g_verbs[] = {
1597 /* Bias voltage on for external mic port */
1598 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN | PIN_VREF80},
1599 /* Front Mic: set to PIN_IN (empty by default) */
1600 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1601 /* Unselect Front Mic by default in input mixer 3 */
1602 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
1603 /* Enable unsolicited event for HP jack */
1604 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1605 /* Enable speaker output */
1606 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1607 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1608 /* Enable headphone output */
1609 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | PIN_HP},
1610 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1611 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1616 * ALC889 Acer Aspire 8930G model
1619 static struct hda_verb alc889_acer_aspire_8930g_verbs[] = {
1620 /* Front Mic: set to PIN_IN (empty by default) */
1621 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1622 /* Unselect Front Mic by default in input mixer 3 */
1623 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
1624 /* Enable unsolicited event for HP jack */
1625 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1626 /* Connect Internal Front to Front */
1627 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1628 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1629 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1630 /* Connect Internal Rear to Rear */
1631 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1632 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1633 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01},
1634 /* Connect Internal CLFE to CLFE */
1635 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1636 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1637 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
1638 /* Connect HP out to Front */
1639 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | PIN_HP},
1640 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1641 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1642 /* Enable all DACs */
1643 /* DAC DISABLE/MUTE 1? */
1644 /* setting bits 1-5 disables DAC nids 0x02-0x06 apparently. Init=0x38 */
1645 {0x20, AC_VERB_SET_COEF_INDEX, 0x03},
1646 {0x20, AC_VERB_SET_PROC_COEF, 0x0000},
1647 /* DAC DISABLE/MUTE 2? */
1648 /* some bit here disables the other DACs. Init=0x4900 */
1649 {0x20, AC_VERB_SET_COEF_INDEX, 0x08},
1650 {0x20, AC_VERB_SET_PROC_COEF, 0x0000},
1651 /* Enable amplifiers */
1652 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
1653 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
1655 * This laptop has a stereo digital microphone. The mics are only 1cm apart
1656 * which makes the stereo useless. However, either the mic or the ALC889
1657 * makes the signal become a difference/sum signal instead of standard
1658 * stereo, which is annoying. So instead we flip this bit which makes the
1659 * codec replicate the sum signal to both channels, turning it into a
1662 /* DMIC_CONTROL? Init value = 0x0001 */
1663 {0x20, AC_VERB_SET_COEF_INDEX, 0x0b},
1664 {0x20, AC_VERB_SET_PROC_COEF, 0x0003},
1668 static struct hda_input_mux alc888_2_capture_sources[2] = {
1669 /* Front mic only available on one ADC */
1676 { "Front Mic", 0xb },
1689 static struct hda_input_mux alc888_acer_aspire_6530_sources[2] = {
1690 /* Interal mic only available on one ADC */
1697 { "Input Mix", 0xa },
1707 { "Input Mix", 0xa },
1712 static struct hda_input_mux alc889_capture_sources[3] = {
1713 /* Digital mic only available on first "ADC" */
1720 { "Front Mic", 0xb },
1721 { "Input Mix", 0xa },
1730 { "Input Mix", 0xa },
1739 { "Input Mix", 0xa },
1744 static struct snd_kcontrol_new alc888_base_mixer[] = {
1745 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1746 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1747 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1748 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
1749 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
1751 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1752 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1753 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1754 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
1755 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
1756 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1757 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1758 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1759 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1760 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1761 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
1762 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1766 static void alc888_acer_aspire_4930g_setup(struct hda_codec *codec)
1768 struct alc_spec *spec = codec->spec;
1770 spec->autocfg.hp_pins[0] = 0x15;
1771 spec->autocfg.speaker_pins[0] = 0x14;
1774 static void alc888_acer_aspire_6530g_setup(struct hda_codec *codec)
1776 struct alc_spec *spec = codec->spec;
1778 spec->autocfg.hp_pins[0] = 0x15;
1779 spec->autocfg.speaker_pins[0] = 0x14;
1780 spec->autocfg.speaker_pins[1] = 0x16;
1781 spec->autocfg.speaker_pins[2] = 0x17;
1784 static void alc889_acer_aspire_8930g_setup(struct hda_codec *codec)
1786 struct alc_spec *spec = codec->spec;
1788 spec->autocfg.hp_pins[0] = 0x15;
1789 spec->autocfg.speaker_pins[0] = 0x14;
1790 spec->autocfg.speaker_pins[1] = 0x16;
1791 spec->autocfg.speaker_pins[2] = 0x1b;
1795 * ALC880 3-stack model
1797 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
1798 * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18,
1799 * F-Mic = 0x1b, HP = 0x19
1802 static hda_nid_t alc880_dac_nids[4] = {
1803 /* front, rear, clfe, rear_surr */
1804 0x02, 0x05, 0x04, 0x03
1807 static hda_nid_t alc880_adc_nids[3] = {
1812 /* The datasheet says the node 0x07 is connected from inputs,
1813 * but it shows zero connection in the real implementation on some devices.
1814 * Note: this is a 915GAV bug, fixed on 915GLV
1816 static hda_nid_t alc880_adc_nids_alt[2] = {
1821 #define ALC880_DIGOUT_NID 0x06
1822 #define ALC880_DIGIN_NID 0x0a
1824 static struct hda_input_mux alc880_capture_source = {
1828 { "Front Mic", 0x3 },
1834 /* channel source setting (2/6 channel selection for 3-stack) */
1836 static struct hda_verb alc880_threestack_ch2_init[] = {
1837 /* set line-in to input, mute it */
1838 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1839 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1840 /* set mic-in to input vref 80%, mute it */
1841 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1842 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1847 static struct hda_verb alc880_threestack_ch6_init[] = {
1848 /* set line-in to output, unmute it */
1849 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1850 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1851 /* set mic-in to output, unmute it */
1852 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1853 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1857 static struct hda_channel_mode alc880_threestack_modes[2] = {
1858 { 2, alc880_threestack_ch2_init },
1859 { 6, alc880_threestack_ch6_init },
1862 static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
1863 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1864 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1865 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
1866 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
1867 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1868 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1869 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1870 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1871 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1872 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1873 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1874 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1875 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1876 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1877 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
1878 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
1879 HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
1881 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1882 .name = "Channel Mode",
1883 .info = alc_ch_mode_info,
1884 .get = alc_ch_mode_get,
1885 .put = alc_ch_mode_put,
1890 /* capture mixer elements */
1891 static int alc_cap_vol_info(struct snd_kcontrol *kcontrol,
1892 struct snd_ctl_elem_info *uinfo)
1894 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1895 struct alc_spec *spec = codec->spec;
1898 mutex_lock(&codec->control_mutex);
1899 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0,
1901 err = snd_hda_mixer_amp_volume_info(kcontrol, uinfo);
1902 mutex_unlock(&codec->control_mutex);
1906 static int alc_cap_vol_tlv(struct snd_kcontrol *kcontrol, int op_flag,
1907 unsigned int size, unsigned int __user *tlv)
1909 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1910 struct alc_spec *spec = codec->spec;
1913 mutex_lock(&codec->control_mutex);
1914 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0,
1916 err = snd_hda_mixer_amp_tlv(kcontrol, op_flag, size, tlv);
1917 mutex_unlock(&codec->control_mutex);
1921 typedef int (*getput_call_t)(struct snd_kcontrol *kcontrol,
1922 struct snd_ctl_elem_value *ucontrol);
1924 static int alc_cap_getput_caller(struct snd_kcontrol *kcontrol,
1925 struct snd_ctl_elem_value *ucontrol,
1928 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1929 struct alc_spec *spec = codec->spec;
1930 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
1933 mutex_lock(&codec->control_mutex);
1934 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[adc_idx],
1936 err = func(kcontrol, ucontrol);
1937 mutex_unlock(&codec->control_mutex);
1941 static int alc_cap_vol_get(struct snd_kcontrol *kcontrol,
1942 struct snd_ctl_elem_value *ucontrol)
1944 return alc_cap_getput_caller(kcontrol, ucontrol,
1945 snd_hda_mixer_amp_volume_get);
1948 static int alc_cap_vol_put(struct snd_kcontrol *kcontrol,
1949 struct snd_ctl_elem_value *ucontrol)
1951 return alc_cap_getput_caller(kcontrol, ucontrol,
1952 snd_hda_mixer_amp_volume_put);
1955 /* capture mixer elements */
1956 #define alc_cap_sw_info snd_ctl_boolean_stereo_info
1958 static int alc_cap_sw_get(struct snd_kcontrol *kcontrol,
1959 struct snd_ctl_elem_value *ucontrol)
1961 return alc_cap_getput_caller(kcontrol, ucontrol,
1962 snd_hda_mixer_amp_switch_get);
1965 static int alc_cap_sw_put(struct snd_kcontrol *kcontrol,
1966 struct snd_ctl_elem_value *ucontrol)
1968 return alc_cap_getput_caller(kcontrol, ucontrol,
1969 snd_hda_mixer_amp_switch_put);
1972 #define _DEFINE_CAPMIX(num) \
1974 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1975 .name = "Capture Switch", \
1976 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, \
1978 .info = alc_cap_sw_info, \
1979 .get = alc_cap_sw_get, \
1980 .put = alc_cap_sw_put, \
1983 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1984 .name = "Capture Volume", \
1985 .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE | \
1986 SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
1987 SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK), \
1989 .info = alc_cap_vol_info, \
1990 .get = alc_cap_vol_get, \
1991 .put = alc_cap_vol_put, \
1992 .tlv = { .c = alc_cap_vol_tlv }, \
1995 #define _DEFINE_CAPSRC(num) \
1997 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1998 /* .name = "Capture Source", */ \
1999 .name = "Input Source", \
2001 .info = alc_mux_enum_info, \
2002 .get = alc_mux_enum_get, \
2003 .put = alc_mux_enum_put, \
2006 #define DEFINE_CAPMIX(num) \
2007 static struct snd_kcontrol_new alc_capture_mixer ## num[] = { \
2008 _DEFINE_CAPMIX(num), \
2009 _DEFINE_CAPSRC(num), \
2013 #define DEFINE_CAPMIX_NOSRC(num) \
2014 static struct snd_kcontrol_new alc_capture_mixer_nosrc ## num[] = { \
2015 _DEFINE_CAPMIX(num), \
2019 /* up to three ADCs */
2023 DEFINE_CAPMIX_NOSRC(1);
2024 DEFINE_CAPMIX_NOSRC(2);
2025 DEFINE_CAPMIX_NOSRC(3);
2028 * ALC880 5-stack model
2030 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d),
2032 * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
2033 * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
2036 /* additional mixers to alc880_three_stack_mixer */
2037 static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
2038 HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2039 HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
2043 /* channel source setting (6/8 channel selection for 5-stack) */
2045 static struct hda_verb alc880_fivestack_ch6_init[] = {
2046 /* set line-in to input, mute it */
2047 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
2048 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
2053 static struct hda_verb alc880_fivestack_ch8_init[] = {
2054 /* set line-in to output, unmute it */
2055 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
2056 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
2060 static struct hda_channel_mode alc880_fivestack_modes[2] = {
2061 { 6, alc880_fivestack_ch6_init },
2062 { 8, alc880_fivestack_ch8_init },
2067 * ALC880 6-stack model
2069 * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e),
2070 * Side = 0x05 (0x0f)
2071 * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
2072 * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
2075 static hda_nid_t alc880_6st_dac_nids[4] = {
2076 /* front, rear, clfe, rear_surr */
2077 0x02, 0x03, 0x04, 0x05
2080 static struct hda_input_mux alc880_6stack_capture_source = {
2084 { "Front Mic", 0x1 },
2090 /* fixed 8-channels */
2091 static struct hda_channel_mode alc880_sixstack_modes[1] = {
2095 static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
2096 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2097 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2098 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2099 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
2100 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2101 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2102 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2103 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2104 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
2105 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
2106 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2107 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2108 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2109 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2110 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2111 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2112 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2113 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
2115 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2116 .name = "Channel Mode",
2117 .info = alc_ch_mode_info,
2118 .get = alc_ch_mode_get,
2119 .put = alc_ch_mode_put,
2128 * W810 has rear IO for:
2131 * Center/LFE (DAC 04)
2134 * The system also has a pair of internal speakers, and a headphone jack.
2135 * These are both connected to Line2 on the codec, hence to DAC 02.
2137 * There is a variable resistor to control the speaker or headphone
2138 * volume. This is a hardware-only device without a software API.
2140 * Plugging headphones in will disable the internal speakers. This is
2141 * implemented in hardware, not via the driver using jack sense. In
2142 * a similar fashion, plugging into the rear socket marked "front" will
2143 * disable both the speakers and headphones.
2145 * For input, there's a microphone jack, and an "audio in" jack.
2146 * These may not do anything useful with this driver yet, because I
2147 * haven't setup any initialization verbs for these yet...
2150 static hda_nid_t alc880_w810_dac_nids[3] = {
2151 /* front, rear/surround, clfe */
2155 /* fixed 6 channels */
2156 static struct hda_channel_mode alc880_w810_modes[1] = {
2160 /* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
2161 static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
2162 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2163 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2164 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2165 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
2166 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2167 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2168 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2169 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2170 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
2178 * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
2179 * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?),
2183 static hda_nid_t alc880_z71v_dac_nids[1] = {
2186 #define ALC880_Z71V_HP_DAC 0x03
2188 /* fixed 2 channels */
2189 static struct hda_channel_mode alc880_2_jack_modes[1] = {
2193 static struct snd_kcontrol_new alc880_z71v_mixer[] = {
2194 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2195 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2196 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2197 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
2198 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2199 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2200 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2201 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2207 * ALC880 F1734 model
2209 * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
2210 * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
2213 static hda_nid_t alc880_f1734_dac_nids[1] = {
2216 #define ALC880_F1734_HP_DAC 0x02
2218 static struct snd_kcontrol_new alc880_f1734_mixer[] = {
2219 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2220 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2221 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2222 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
2223 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2224 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2225 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2226 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
2230 static struct hda_input_mux alc880_f1734_capture_source = {
2242 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
2243 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
2244 * Mic = 0x18, Line = 0x1a
2247 #define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
2248 #define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
2250 static struct snd_kcontrol_new alc880_asus_mixer[] = {
2251 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2252 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2253 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2254 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
2255 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2256 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2257 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2258 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2259 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2260 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2261 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2262 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2263 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2264 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2266 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2267 .name = "Channel Mode",
2268 .info = alc_ch_mode_info,
2269 .get = alc_ch_mode_get,
2270 .put = alc_ch_mode_put,
2276 * ALC880 ASUS W1V model
2278 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
2279 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
2280 * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
2283 /* additional mixers to alc880_asus_mixer */
2284 static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
2285 HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
2286 HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
2291 static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
2292 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2293 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
2294 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
2295 HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
2296 HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
2297 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
2298 HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
2299 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
2300 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
2305 static struct snd_kcontrol_new alc880_uniwill_mixer[] = {
2306 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2307 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2308 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2309 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
2310 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2311 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2312 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2313 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2314 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2315 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2316 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2317 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2318 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2319 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2320 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2321 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
2323 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2324 .name = "Channel Mode",
2325 .info = alc_ch_mode_info,
2326 .get = alc_ch_mode_get,
2327 .put = alc_ch_mode_put,
2332 static struct snd_kcontrol_new alc880_fujitsu_mixer[] = {
2333 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2334 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2335 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2336 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
2337 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2338 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2339 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2340 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2341 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2342 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
2346 static struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = {
2347 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2348 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2349 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2350 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
2351 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2352 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2357 * virtual master controls
2361 * slave controls for virtual master
2363 static const char *alc_slave_vols[] = {
2364 "Front Playback Volume",
2365 "Surround Playback Volume",
2366 "Center Playback Volume",
2367 "LFE Playback Volume",
2368 "Side Playback Volume",
2369 "Headphone Playback Volume",
2370 "Speaker Playback Volume",
2371 "Mono Playback Volume",
2372 "Line-Out Playback Volume",
2373 "PCM Playback Volume",
2377 static const char *alc_slave_sws[] = {
2378 "Front Playback Switch",
2379 "Surround Playback Switch",
2380 "Center Playback Switch",
2381 "LFE Playback Switch",
2382 "Side Playback Switch",
2383 "Headphone Playback Switch",
2384 "Speaker Playback Switch",
2385 "Mono Playback Switch",
2386 "IEC958 Playback Switch",
2391 * build control elements
2394 static void alc_free_kctls(struct hda_codec *codec);
2396 /* additional beep mixers; the actual parameters are overwritten at build */
2397 static struct snd_kcontrol_new alc_beep_mixer[] = {
2398 HDA_CODEC_VOLUME("Beep Playback Volume", 0, 0, HDA_INPUT),
2399 HDA_CODEC_MUTE("Beep Playback Switch", 0, 0, HDA_INPUT),
2403 static int alc_build_controls(struct hda_codec *codec)
2405 struct alc_spec *spec = codec->spec;
2409 for (i = 0; i < spec->num_mixers; i++) {
2410 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
2414 if (spec->cap_mixer) {
2415 err = snd_hda_add_new_ctls(codec, spec->cap_mixer);
2419 if (spec->multiout.dig_out_nid) {
2420 err = snd_hda_create_spdif_out_ctls(codec,
2421 spec->multiout.dig_out_nid);
2424 if (!spec->no_analog) {
2425 err = snd_hda_create_spdif_share_sw(codec,
2429 spec->multiout.share_spdif = 1;
2432 if (spec->dig_in_nid) {
2433 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
2438 /* create beep controls if needed */
2439 if (spec->beep_amp) {
2440 struct snd_kcontrol_new *knew;
2441 for (knew = alc_beep_mixer; knew->name; knew++) {
2442 struct snd_kcontrol *kctl;
2443 kctl = snd_ctl_new1(knew, codec);
2446 kctl->private_value = spec->beep_amp;
2447 err = snd_hda_ctl_add(codec, kctl);
2453 /* if we have no master control, let's create it */
2454 if (!spec->no_analog &&
2455 !snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
2456 unsigned int vmaster_tlv[4];
2457 snd_hda_set_vmaster_tlv(codec, spec->vmaster_nid,
2458 HDA_OUTPUT, vmaster_tlv);
2459 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
2460 vmaster_tlv, alc_slave_vols);
2464 if (!spec->no_analog &&
2465 !snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
2466 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
2467 NULL, alc_slave_sws);
2472 alc_free_kctls(codec); /* no longer needed */
2478 * initialize the codec volumes, etc
2482 * generic initialization of ADC, input mixers and output mixers
2484 static struct hda_verb alc880_volume_init_verbs[] = {
2486 * Unmute ADC0-2 and set the default input to mic-in
2488 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
2489 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2490 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
2491 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2492 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
2493 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2495 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
2497 * Note: PASD motherboards uses the Line In 2 as the input for front
2500 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
2501 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2502 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2503 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
2504 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
2505 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
2506 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
2507 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
2510 * Set up output mixers (0x0c - 0x0f)
2512 /* set vol=0 to output mixers */
2513 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2514 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2515 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2516 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2517 /* set up input amps for analog loopback */
2518 /* Amp Indices: DAC = 0, mixer = 1 */
2519 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2520 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2521 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2522 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2523 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2524 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2525 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2526 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2532 * 3-stack pin configuration:
2533 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
2535 static struct hda_verb alc880_pin_3stack_init_verbs[] = {
2537 * preset connection lists of input pins
2538 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
2540 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
2541 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2542 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
2545 * Set pin mode and muting
2547 /* set front pin widgets 0x14 for output */
2548 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2549 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2550 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2551 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2552 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2553 /* Mic2 (as headphone out) for HP output */
2554 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2555 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2556 /* Line In pin widget for input */
2557 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2558 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2559 /* Line2 (as front mic) pin widget for input and vref at 80% */
2560 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2561 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2562 /* CD pin widget for input */
2563 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2569 * 5-stack pin configuration:
2570 * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
2571 * line-in/side = 0x1a, f-mic = 0x1b
2573 static struct hda_verb alc880_pin_5stack_init_verbs[] = {
2575 * preset connection lists of input pins
2576 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
2578 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2579 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
2582 * Set pin mode and muting
2584 /* set pin widgets 0x14-0x17 for output */
2585 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2586 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2587 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2588 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2589 /* unmute pins for output (no gain on this amp) */
2590 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2591 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2592 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2593 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2595 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2596 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2597 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2598 /* Mic2 (as headphone out) for HP output */
2599 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2600 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2601 /* Line In pin widget for input */
2602 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2603 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2604 /* Line2 (as front mic) pin widget for input and vref at 80% */
2605 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2606 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2607 /* CD pin widget for input */
2608 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2614 * W810 pin configuration:
2615 * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
2617 static struct hda_verb alc880_pin_w810_init_verbs[] = {
2618 /* hphone/speaker input selector: front DAC */
2619 {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
2621 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2622 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2623 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2624 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2625 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2626 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2628 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2629 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2635 * Z71V pin configuration:
2636 * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
2638 static struct hda_verb alc880_pin_z71v_init_verbs[] = {
2639 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2640 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2641 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2642 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2644 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2645 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2646 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2647 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2653 * 6-stack pin configuration:
2654 * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18,
2655 * f-mic = 0x19, line = 0x1a, HP = 0x1b
2657 static struct hda_verb alc880_pin_6stack_init_verbs[] = {
2658 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2660 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2661 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2662 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2663 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2664 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2665 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2666 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2667 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2669 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2670 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2671 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2672 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2673 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2674 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2675 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2676 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2677 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2683 * Uniwill pin configuration:
2684 * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19,
2687 static struct hda_verb alc880_uniwill_init_verbs[] = {
2688 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2690 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2691 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2692 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2693 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2694 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2695 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2696 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2697 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2698 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2699 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2700 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2701 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2702 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2703 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2705 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2706 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2707 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2708 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2709 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2710 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2711 /* {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, */
2712 /* {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
2713 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2715 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
2716 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
2723 * HP = 0x14, InternalSpeaker = 0x15, mic = 0x19,
2725 static struct hda_verb alc880_uniwill_p53_init_verbs[] = {
2726 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2728 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2729 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2730 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2731 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2732 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2733 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2734 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2735 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2736 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2737 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2738 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2739 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2741 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2742 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2743 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2744 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2745 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2746 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2748 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
2749 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_DCVOL_EVENT},
2754 static struct hda_verb alc880_beep_init_verbs[] = {
2755 { 0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5) },
2759 /* auto-toggle front mic */
2760 static void alc880_uniwill_mic_automute(struct hda_codec *codec)
2762 unsigned int present;
2765 present = snd_hda_codec_read(codec, 0x18, 0,
2766 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
2767 bits = present ? HDA_AMP_MUTE : 0;
2768 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
2771 static void alc880_uniwill_setup(struct hda_codec *codec)
2773 struct alc_spec *spec = codec->spec;
2775 spec->autocfg.hp_pins[0] = 0x14;
2776 spec->autocfg.speaker_pins[0] = 0x15;
2777 spec->autocfg.speaker_pins[0] = 0x16;
2780 static void alc880_uniwill_init_hook(struct hda_codec *codec)
2782 alc_automute_amp(codec);
2783 alc880_uniwill_mic_automute(codec);
2786 static void alc880_uniwill_unsol_event(struct hda_codec *codec,
2789 /* Looks like the unsol event is incompatible with the standard
2790 * definition. 4bit tag is placed at 28 bit!
2792 switch (res >> 28) {
2793 case ALC880_MIC_EVENT:
2794 alc880_uniwill_mic_automute(codec);
2797 alc_automute_amp_unsol_event(codec, res);
2802 static void alc880_uniwill_p53_setup(struct hda_codec *codec)
2804 struct alc_spec *spec = codec->spec;
2806 spec->autocfg.hp_pins[0] = 0x14;
2807 spec->autocfg.speaker_pins[0] = 0x15;
2810 static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec)
2812 unsigned int present;
2814 present = snd_hda_codec_read(codec, 0x21, 0,
2815 AC_VERB_GET_VOLUME_KNOB_CONTROL, 0);
2816 present &= HDA_AMP_VOLMASK;
2817 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0,
2818 HDA_AMP_VOLMASK, present);
2819 snd_hda_codec_amp_stereo(codec, 0x0d, HDA_OUTPUT, 0,
2820 HDA_AMP_VOLMASK, present);
2823 static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec,
2826 /* Looks like the unsol event is incompatible with the standard
2827 * definition. 4bit tag is placed at 28 bit!
2829 if ((res >> 28) == ALC880_DCVOL_EVENT)
2830 alc880_uniwill_p53_dcvol_automute(codec);
2832 alc_automute_amp_unsol_event(codec, res);
2836 * F1734 pin configuration:
2837 * HP = 0x14, speaker-out = 0x15, mic = 0x18
2839 static struct hda_verb alc880_pin_f1734_init_verbs[] = {
2840 {0x07, AC_VERB_SET_CONNECT_SEL, 0x01},
2841 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
2842 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
2843 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
2844 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
2846 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2847 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2848 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2849 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2851 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2852 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2853 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
2854 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2855 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2856 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2857 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2858 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2859 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2861 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
2862 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_DCVOL_EVENT},
2868 * ASUS pin configuration:
2869 * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
2871 static struct hda_verb alc880_pin_asus_init_verbs[] = {
2872 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
2873 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
2874 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
2875 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
2877 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2878 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2879 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2880 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2881 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2882 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2883 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2884 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2886 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2887 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2888 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2889 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2890 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2891 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2892 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2893 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2894 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2899 /* Enable GPIO mask and set output */
2900 #define alc880_gpio1_init_verbs alc_gpio1_init_verbs
2901 #define alc880_gpio2_init_verbs alc_gpio2_init_verbs
2902 #define alc880_gpio3_init_verbs alc_gpio3_init_verbs
2904 /* Clevo m520g init */
2905 static struct hda_verb alc880_pin_clevo_init_verbs[] = {
2906 /* headphone output */
2907 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
2909 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2910 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2912 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2913 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2915 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2916 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2917 /* Mic1 (rear panel) */
2918 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2919 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2920 /* Mic2 (front panel) */
2921 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2922 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2924 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2925 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2926 /* change to EAPD mode */
2927 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2928 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
2933 static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
2934 /* change to EAPD mode */
2935 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2936 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
2938 /* Headphone output */
2939 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2941 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2942 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
2944 /* Line In pin widget for input */
2945 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2946 /* CD pin widget for input */
2947 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2948 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2949 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2951 /* change to EAPD mode */
2952 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2953 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
2959 * LG m1 express dual
2962 * Rear Line-In/Out (blue): 0x14
2963 * Build-in Mic-In: 0x15
2965 * HP-Out (green): 0x1b
2966 * Mic-In/Out (red): 0x19
2970 /* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
2971 static hda_nid_t alc880_lg_dac_nids[3] = {
2975 /* seems analog CD is not working */
2976 static struct hda_input_mux alc880_lg_capture_source = {
2981 { "Internal Mic", 0x6 },
2985 /* 2,4,6 channel modes */
2986 static struct hda_verb alc880_lg_ch2_init[] = {
2987 /* set line-in and mic-in to input */
2988 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
2989 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
2993 static struct hda_verb alc880_lg_ch4_init[] = {
2994 /* set line-in to out and mic-in to input */
2995 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
2996 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
3000 static struct hda_verb alc880_lg_ch6_init[] = {
3001 /* set line-in and mic-in to output */
3002 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
3003 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
3007 static struct hda_channel_mode alc880_lg_ch_modes[3] = {
3008 { 2, alc880_lg_ch2_init },
3009 { 4, alc880_lg_ch4_init },
3010 { 6, alc880_lg_ch6_init },
3013 static struct snd_kcontrol_new alc880_lg_mixer[] = {
3014 HDA_CODEC_VOLUME("Front Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
3015 HDA_BIND_MUTE("Front Playback Switch", 0x0f, 2, HDA_INPUT),
3016 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3017 HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
3018 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
3019 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
3020 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
3021 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
3022 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
3023 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
3024 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
3025 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
3026 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
3027 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
3029 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3030 .name = "Channel Mode",
3031 .info = alc_ch_mode_info,
3032 .get = alc_ch_mode_get,
3033 .put = alc_ch_mode_put,
3038 static struct hda_verb alc880_lg_init_verbs[] = {
3039 /* set capture source to mic-in */
3040 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3041 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3042 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3043 /* mute all amp mixer inputs */
3044 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
3045 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
3046 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
3047 /* line-in to input */
3048 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3049 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3051 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3052 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3054 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3055 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3056 /* mic-in to input */
3057 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
3058 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3059 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3061 {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
3062 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3063 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3065 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
3069 /* toggle speaker-output according to the hp-jack state */
3070 static void alc880_lg_setup(struct hda_codec *codec)
3072 struct alc_spec *spec = codec->spec;
3074 spec->autocfg.hp_pins[0] = 0x1b;
3075 spec->autocfg.speaker_pins[0] = 0x17;
3084 * Built-in Mic-In: 0x19
3090 static struct hda_input_mux alc880_lg_lw_capture_source = {
3094 { "Internal Mic", 0x1 },
3099 #define alc880_lg_lw_modes alc880_threestack_modes
3101 static struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
3102 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3103 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
3104 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
3105 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
3106 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
3107 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
3108 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
3109 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
3110 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
3111 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
3112 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
3113 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
3114 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
3115 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
3117 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3118 .name = "Channel Mode",
3119 .info = alc_ch_mode_info,
3120 .get = alc_ch_mode_get,
3121 .put = alc_ch_mode_put,
3126 static struct hda_verb alc880_lg_lw_init_verbs[] = {
3127 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3128 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
3129 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
3131 /* set capture source to mic-in */
3132 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3133 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3134 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3135 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
3137 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3138 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3140 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3141 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3142 /* mic-in to input */
3143 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3144 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3146 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3147 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3149 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
3153 /* toggle speaker-output according to the hp-jack state */
3154 static void alc880_lg_lw_setup(struct hda_codec *codec)
3156 struct alc_spec *spec = codec->spec;
3158 spec->autocfg.hp_pins[0] = 0x1b;
3159 spec->autocfg.speaker_pins[0] = 0x14;
3162 static struct snd_kcontrol_new alc880_medion_rim_mixer[] = {
3163 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3164 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
3165 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
3166 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
3167 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
3168 HDA_CODEC_MUTE("Internal Playback Switch", 0x0b, 0x1, HDA_INPUT),
3172 static struct hda_input_mux alc880_medion_rim_capture_source = {
3176 { "Internal Mic", 0x1 },
3180 static struct hda_verb alc880_medion_rim_init_verbs[] = {
3181 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3183 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3184 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3186 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3187 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3188 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3189 /* Mic2 (as headphone out) for HP output */
3190 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3191 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3192 /* Internal Speaker */
3193 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3194 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3196 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
3197 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
3199 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
3203 /* toggle speaker-output according to the hp-jack state */
3204 static void alc880_medion_rim_automute(struct hda_codec *codec)
3206 struct alc_spec *spec = codec->spec;
3207 alc_automute_amp(codec);
3209 if (spec->jack_present)
3210 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 0);
3212 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 2);
3215 static void alc880_medion_rim_unsol_event(struct hda_codec *codec,
3218 /* Looks like the unsol event is incompatible with the standard
3219 * definition. 4bit tag is placed at 28 bit!
3221 if ((res >> 28) == ALC880_HP_EVENT)
3222 alc880_medion_rim_automute(codec);
3225 static void alc880_medion_rim_setup(struct hda_codec *codec)
3227 struct alc_spec *spec = codec->spec;
3229 spec->autocfg.hp_pins[0] = 0x14;
3230 spec->autocfg.speaker_pins[0] = 0x1b;
3233 #ifdef CONFIG_SND_HDA_POWER_SAVE
3234 static struct hda_amp_list alc880_loopbacks[] = {
3235 { 0x0b, HDA_INPUT, 0 },
3236 { 0x0b, HDA_INPUT, 1 },
3237 { 0x0b, HDA_INPUT, 2 },
3238 { 0x0b, HDA_INPUT, 3 },
3239 { 0x0b, HDA_INPUT, 4 },
3243 static struct hda_amp_list alc880_lg_loopbacks[] = {
3244 { 0x0b, HDA_INPUT, 1 },
3245 { 0x0b, HDA_INPUT, 6 },
3246 { 0x0b, HDA_INPUT, 7 },
3255 static int alc_init(struct hda_codec *codec)
3257 struct alc_spec *spec = codec->spec;
3261 alc_auto_init_amp(codec, spec->init_amp);
3263 for (i = 0; i < spec->num_init_verbs; i++)
3264 snd_hda_sequence_write(codec, spec->init_verbs[i]);
3266 if (spec->init_hook)
3267 spec->init_hook(codec);
3272 static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
3274 struct alc_spec *spec = codec->spec;
3276 if (spec->unsol_event)
3277 spec->unsol_event(codec, res);
3280 #ifdef CONFIG_SND_HDA_POWER_SAVE
3281 static int alc_check_power_status(struct hda_codec *codec, hda_nid_t nid)
3283 struct alc_spec *spec = codec->spec;
3284 return snd_hda_check_amp_list_power(codec, &spec->loopback, nid);
3289 * Analog playback callbacks
3291 static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
3292 struct hda_codec *codec,
3293 struct snd_pcm_substream *substream)
3295 struct alc_spec *spec = codec->spec;
3296 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
3300 static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
3301 struct hda_codec *codec,
3302 unsigned int stream_tag,
3303 unsigned int format,
3304 struct snd_pcm_substream *substream)
3306 struct alc_spec *spec = codec->spec;
3307 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
3308 stream_tag, format, substream);
3311 static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
3312 struct hda_codec *codec,
3313 struct snd_pcm_substream *substream)