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,
236 ALC883_FUJITSU_PI2515,
237 ALC888_FUJITSU_XA3530,
238 ALC883_3ST_6ch_INTEL,
251 #define GPIO_MASK 0x03
253 /* extra amp-initialization sequence types */
262 struct alc_mic_route {
264 unsigned char mux_idx;
265 unsigned char amix_idx;
268 #define MUX_IDX_UNDEF ((unsigned char)-1)
271 /* codec parameterization */
272 struct snd_kcontrol_new *mixers[5]; /* mixer arrays */
273 unsigned int num_mixers;
274 struct snd_kcontrol_new *cap_mixer; /* capture mixer */
275 unsigned int beep_amp; /* beep amp value, set via set_beep_amp() */
277 const struct hda_verb *init_verbs[5]; /* initialization verbs
281 unsigned int num_init_verbs;
283 char stream_name_analog[32]; /* analog PCM stream */
284 struct hda_pcm_stream *stream_analog_playback;
285 struct hda_pcm_stream *stream_analog_capture;
286 struct hda_pcm_stream *stream_analog_alt_playback;
287 struct hda_pcm_stream *stream_analog_alt_capture;
289 char stream_name_digital[32]; /* digital PCM stream */
290 struct hda_pcm_stream *stream_digital_playback;
291 struct hda_pcm_stream *stream_digital_capture;
294 struct hda_multi_out multiout; /* playback set-up
295 * max_channels, dacs must be set
296 * dig_out_nid and hp_nid are optional
298 hda_nid_t alt_dac_nid;
299 hda_nid_t slave_dig_outs[3]; /* optional - for auto-parsing */
303 unsigned int num_adc_nids;
305 hda_nid_t *capsrc_nids;
306 hda_nid_t dig_in_nid; /* digital-in NID; optional */
309 unsigned int num_mux_defs;
310 const struct hda_input_mux *input_mux;
311 unsigned int cur_mux[3];
312 struct alc_mic_route ext_mic;
313 struct alc_mic_route int_mic;
316 const struct hda_channel_mode *channel_mode;
317 int num_channel_mode;
319 int const_channel_count;
320 int ext_channel_count;
322 /* PCM information */
323 struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */
325 /* dynamic controls, init_verbs and input_mux */
326 struct auto_pin_cfg autocfg;
327 struct snd_array kctls;
328 struct hda_input_mux private_imux[3];
329 hda_nid_t private_dac_nids[AUTO_CFG_MAX_OUTS];
330 hda_nid_t private_adc_nids[AUTO_CFG_MAX_OUTS];
331 hda_nid_t private_capsrc_nids[AUTO_CFG_MAX_OUTS];
334 void (*init_hook)(struct hda_codec *codec);
335 void (*unsol_event)(struct hda_codec *codec, unsigned int res);
337 /* for pin sensing */
338 unsigned int sense_updated: 1;
339 unsigned int jack_present: 1;
340 unsigned int master_sw: 1;
341 unsigned int auto_mic:1;
344 unsigned int no_analog :1; /* digital I/O only */
347 /* for virtual master */
348 hda_nid_t vmaster_nid;
349 #ifdef CONFIG_SND_HDA_POWER_SAVE
350 struct hda_loopback_check loopback;
355 unsigned int pll_coef_idx, pll_coef_bit;
359 * configuration template - to be copied to the spec instance
361 struct alc_config_preset {
362 struct snd_kcontrol_new *mixers[5]; /* should be identical size
365 struct snd_kcontrol_new *cap_mixer; /* capture mixer */
366 const struct hda_verb *init_verbs[5];
367 unsigned int num_dacs;
369 hda_nid_t dig_out_nid; /* optional */
370 hda_nid_t hp_nid; /* optional */
371 hda_nid_t *slave_dig_outs;
372 unsigned int num_adc_nids;
374 hda_nid_t *capsrc_nids;
375 hda_nid_t dig_in_nid;
376 unsigned int num_channel_mode;
377 const struct hda_channel_mode *channel_mode;
379 int const_channel_count;
380 unsigned int num_mux_defs;
381 const struct hda_input_mux *input_mux;
382 void (*unsol_event)(struct hda_codec *, unsigned int);
383 void (*setup)(struct hda_codec *);
384 void (*init_hook)(struct hda_codec *);
385 #ifdef CONFIG_SND_HDA_POWER_SAVE
386 struct hda_amp_list *loopbacks;
394 static int alc_mux_enum_info(struct snd_kcontrol *kcontrol,
395 struct snd_ctl_elem_info *uinfo)
397 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
398 struct alc_spec *spec = codec->spec;
399 unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id);
400 if (mux_idx >= spec->num_mux_defs)
402 return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo);
405 static int alc_mux_enum_get(struct snd_kcontrol *kcontrol,
406 struct snd_ctl_elem_value *ucontrol)
408 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
409 struct alc_spec *spec = codec->spec;
410 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
412 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
416 static int alc_mux_enum_put(struct snd_kcontrol *kcontrol,
417 struct snd_ctl_elem_value *ucontrol)
419 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
420 struct alc_spec *spec = codec->spec;
421 const struct hda_input_mux *imux;
422 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
423 unsigned int mux_idx;
424 hda_nid_t nid = spec->capsrc_nids ?
425 spec->capsrc_nids[adc_idx] : spec->adc_nids[adc_idx];
428 mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx;
429 imux = &spec->input_mux[mux_idx];
431 type = get_wcaps_type(get_wcaps(codec, nid));
432 if (type == AC_WID_AUD_MIX) {
433 /* Matrix-mixer style (e.g. ALC882) */
434 unsigned int *cur_val = &spec->cur_mux[adc_idx];
437 idx = ucontrol->value.enumerated.item[0];
438 if (idx >= imux->num_items)
439 idx = imux->num_items - 1;
442 for (i = 0; i < imux->num_items; i++) {
443 unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
444 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
445 imux->items[i].index,
451 /* MUX style (e.g. ALC880) */
452 return snd_hda_input_mux_put(codec, imux, ucontrol, nid,
453 &spec->cur_mux[adc_idx]);
458 * channel mode setting
460 static int alc_ch_mode_info(struct snd_kcontrol *kcontrol,
461 struct snd_ctl_elem_info *uinfo)
463 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
464 struct alc_spec *spec = codec->spec;
465 return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
466 spec->num_channel_mode);
469 static int alc_ch_mode_get(struct snd_kcontrol *kcontrol,
470 struct snd_ctl_elem_value *ucontrol)
472 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
473 struct alc_spec *spec = codec->spec;
474 return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
475 spec->num_channel_mode,
476 spec->ext_channel_count);
479 static int alc_ch_mode_put(struct snd_kcontrol *kcontrol,
480 struct snd_ctl_elem_value *ucontrol)
482 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
483 struct alc_spec *spec = codec->spec;
484 int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
485 spec->num_channel_mode,
486 &spec->ext_channel_count);
487 if (err >= 0 && !spec->const_channel_count) {
488 spec->multiout.max_channels = spec->ext_channel_count;
489 if (spec->need_dac_fix)
490 spec->multiout.num_dacs = spec->multiout.max_channels / 2;
496 * Control the mode of pin widget settings via the mixer. "pc" is used
497 * instead of "%" to avoid consequences of accidently treating the % as
498 * being part of a format specifier. Maximum allowed length of a value is
499 * 63 characters plus NULL terminator.
501 * Note: some retasking pin complexes seem to ignore requests for input
502 * states other than HiZ (eg: PIN_VREFxx) and revert to HiZ if any of these
503 * are requested. Therefore order this list so that this behaviour will not
504 * cause problems when mixer clients move through the enum sequentially.
505 * NIDs 0x0f and 0x10 have been observed to have this behaviour as of
508 static char *alc_pin_mode_names[] = {
509 "Mic 50pc bias", "Mic 80pc bias",
510 "Line in", "Line out", "Headphone out",
512 static unsigned char alc_pin_mode_values[] = {
513 PIN_VREF50, PIN_VREF80, PIN_IN, PIN_OUT, PIN_HP,
515 /* The control can present all 5 options, or it can limit the options based
516 * in the pin being assumed to be exclusively an input or an output pin. In
517 * addition, "input" pins may or may not process the mic bias option
518 * depending on actual widget capability (NIDs 0x0f and 0x10 don't seem to
519 * accept requests for bias as of chip versions up to March 2006) and/or
520 * wiring in the computer.
522 #define ALC_PIN_DIR_IN 0x00
523 #define ALC_PIN_DIR_OUT 0x01
524 #define ALC_PIN_DIR_INOUT 0x02
525 #define ALC_PIN_DIR_IN_NOMICBIAS 0x03
526 #define ALC_PIN_DIR_INOUT_NOMICBIAS 0x04
528 /* Info about the pin modes supported by the different pin direction modes.
529 * For each direction the minimum and maximum values are given.
531 static signed char alc_pin_mode_dir_info[5][2] = {
532 { 0, 2 }, /* ALC_PIN_DIR_IN */
533 { 3, 4 }, /* ALC_PIN_DIR_OUT */
534 { 0, 4 }, /* ALC_PIN_DIR_INOUT */
535 { 2, 2 }, /* ALC_PIN_DIR_IN_NOMICBIAS */
536 { 2, 4 }, /* ALC_PIN_DIR_INOUT_NOMICBIAS */
538 #define alc_pin_mode_min(_dir) (alc_pin_mode_dir_info[_dir][0])
539 #define alc_pin_mode_max(_dir) (alc_pin_mode_dir_info[_dir][1])
540 #define alc_pin_mode_n_items(_dir) \
541 (alc_pin_mode_max(_dir)-alc_pin_mode_min(_dir)+1)
543 static int alc_pin_mode_info(struct snd_kcontrol *kcontrol,
544 struct snd_ctl_elem_info *uinfo)
546 unsigned int item_num = uinfo->value.enumerated.item;
547 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
549 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
551 uinfo->value.enumerated.items = alc_pin_mode_n_items(dir);
553 if (item_num<alc_pin_mode_min(dir) || item_num>alc_pin_mode_max(dir))
554 item_num = alc_pin_mode_min(dir);
555 strcpy(uinfo->value.enumerated.name, alc_pin_mode_names[item_num]);
559 static int alc_pin_mode_get(struct snd_kcontrol *kcontrol,
560 struct snd_ctl_elem_value *ucontrol)
563 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
564 hda_nid_t nid = kcontrol->private_value & 0xffff;
565 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
566 long *valp = ucontrol->value.integer.value;
567 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
568 AC_VERB_GET_PIN_WIDGET_CONTROL,
571 /* Find enumerated value for current pinctl setting */
572 i = alc_pin_mode_min(dir);
573 while (i <= alc_pin_mode_max(dir) && alc_pin_mode_values[i] != pinctl)
575 *valp = i <= alc_pin_mode_max(dir) ? i: alc_pin_mode_min(dir);
579 static int alc_pin_mode_put(struct snd_kcontrol *kcontrol,
580 struct snd_ctl_elem_value *ucontrol)
583 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
584 hda_nid_t nid = kcontrol->private_value & 0xffff;
585 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
586 long val = *ucontrol->value.integer.value;
587 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
588 AC_VERB_GET_PIN_WIDGET_CONTROL,
591 if (val < alc_pin_mode_min(dir) || val > alc_pin_mode_max(dir))
592 val = alc_pin_mode_min(dir);
594 change = pinctl != alc_pin_mode_values[val];
596 /* Set pin mode to that requested */
597 snd_hda_codec_write_cache(codec, nid, 0,
598 AC_VERB_SET_PIN_WIDGET_CONTROL,
599 alc_pin_mode_values[val]);
601 /* Also enable the retasking pin's input/output as required
602 * for the requested pin mode. Enum values of 2 or less are
605 * Dynamically switching the input/output buffers probably
606 * reduces noise slightly (particularly on input) so we'll
607 * do it. However, having both input and output buffers
608 * enabled simultaneously doesn't seem to be problematic if
609 * this turns out to be necessary in the future.
612 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
613 HDA_AMP_MUTE, HDA_AMP_MUTE);
614 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
617 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
618 HDA_AMP_MUTE, HDA_AMP_MUTE);
619 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
626 #define ALC_PIN_MODE(xname, nid, dir) \
627 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
628 .info = alc_pin_mode_info, \
629 .get = alc_pin_mode_get, \
630 .put = alc_pin_mode_put, \
631 .private_value = nid | (dir<<16) }
633 /* A switch control for ALC260 GPIO pins. Multiple GPIOs can be ganged
634 * together using a mask with more than one bit set. This control is
635 * currently used only by the ALC260 test model. At this stage they are not
636 * needed for any "production" models.
638 #ifdef CONFIG_SND_DEBUG
639 #define alc_gpio_data_info snd_ctl_boolean_mono_info
641 static int alc_gpio_data_get(struct snd_kcontrol *kcontrol,
642 struct snd_ctl_elem_value *ucontrol)
644 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
645 hda_nid_t nid = kcontrol->private_value & 0xffff;
646 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
647 long *valp = ucontrol->value.integer.value;
648 unsigned int val = snd_hda_codec_read(codec, nid, 0,
649 AC_VERB_GET_GPIO_DATA, 0x00);
651 *valp = (val & mask) != 0;
654 static int alc_gpio_data_put(struct snd_kcontrol *kcontrol,
655 struct snd_ctl_elem_value *ucontrol)
658 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
659 hda_nid_t nid = kcontrol->private_value & 0xffff;
660 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
661 long val = *ucontrol->value.integer.value;
662 unsigned int gpio_data = snd_hda_codec_read(codec, nid, 0,
663 AC_VERB_GET_GPIO_DATA,
666 /* Set/unset the masked GPIO bit(s) as needed */
667 change = (val == 0 ? 0 : mask) != (gpio_data & mask);
672 snd_hda_codec_write_cache(codec, nid, 0,
673 AC_VERB_SET_GPIO_DATA, gpio_data);
677 #define ALC_GPIO_DATA_SWITCH(xname, nid, mask) \
678 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
679 .info = alc_gpio_data_info, \
680 .get = alc_gpio_data_get, \
681 .put = alc_gpio_data_put, \
682 .private_value = nid | (mask<<16) }
683 #endif /* CONFIG_SND_DEBUG */
685 /* A switch control to allow the enabling of the digital IO pins on the
686 * ALC260. This is incredibly simplistic; the intention of this control is
687 * to provide something in the test model allowing digital outputs to be
688 * identified if present. If models are found which can utilise these
689 * outputs a more complete mixer control can be devised for those models if
692 #ifdef CONFIG_SND_DEBUG
693 #define alc_spdif_ctrl_info snd_ctl_boolean_mono_info
695 static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol,
696 struct snd_ctl_elem_value *ucontrol)
698 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
699 hda_nid_t nid = kcontrol->private_value & 0xffff;
700 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
701 long *valp = ucontrol->value.integer.value;
702 unsigned int val = snd_hda_codec_read(codec, nid, 0,
703 AC_VERB_GET_DIGI_CONVERT_1, 0x00);
705 *valp = (val & mask) != 0;
708 static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol,
709 struct snd_ctl_elem_value *ucontrol)
712 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
713 hda_nid_t nid = kcontrol->private_value & 0xffff;
714 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
715 long val = *ucontrol->value.integer.value;
716 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
717 AC_VERB_GET_DIGI_CONVERT_1,
720 /* Set/unset the masked control bit(s) as needed */
721 change = (val == 0 ? 0 : mask) != (ctrl_data & mask);
726 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1,
731 #define ALC_SPDIF_CTRL_SWITCH(xname, nid, mask) \
732 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
733 .info = alc_spdif_ctrl_info, \
734 .get = alc_spdif_ctrl_get, \
735 .put = alc_spdif_ctrl_put, \
736 .private_value = nid | (mask<<16) }
737 #endif /* CONFIG_SND_DEBUG */
739 /* A switch control to allow the enabling EAPD digital outputs on the ALC26x.
740 * Again, this is only used in the ALC26x test models to help identify when
741 * the EAPD line must be asserted for features to work.
743 #ifdef CONFIG_SND_DEBUG
744 #define alc_eapd_ctrl_info snd_ctl_boolean_mono_info
746 static int alc_eapd_ctrl_get(struct snd_kcontrol *kcontrol,
747 struct snd_ctl_elem_value *ucontrol)
749 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
750 hda_nid_t nid = kcontrol->private_value & 0xffff;
751 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
752 long *valp = ucontrol->value.integer.value;
753 unsigned int val = snd_hda_codec_read(codec, nid, 0,
754 AC_VERB_GET_EAPD_BTLENABLE, 0x00);
756 *valp = (val & mask) != 0;
760 static int alc_eapd_ctrl_put(struct snd_kcontrol *kcontrol,
761 struct snd_ctl_elem_value *ucontrol)
764 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
765 hda_nid_t nid = kcontrol->private_value & 0xffff;
766 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
767 long val = *ucontrol->value.integer.value;
768 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
769 AC_VERB_GET_EAPD_BTLENABLE,
772 /* Set/unset the masked control bit(s) as needed */
773 change = (!val ? 0 : mask) != (ctrl_data & mask);
778 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
784 #define ALC_EAPD_CTRL_SWITCH(xname, nid, mask) \
785 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
786 .info = alc_eapd_ctrl_info, \
787 .get = alc_eapd_ctrl_get, \
788 .put = alc_eapd_ctrl_put, \
789 .private_value = nid | (mask<<16) }
790 #endif /* CONFIG_SND_DEBUG */
793 * set up the input pin config (depending on the given auto-pin type)
795 static void alc_set_input_pin(struct hda_codec *codec, hda_nid_t nid,
798 unsigned int val = PIN_IN;
800 if (auto_pin_type <= AUTO_PIN_FRONT_MIC) {
802 pincap = snd_hda_query_pin_caps(codec, nid);
803 pincap = (pincap & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT;
804 if (pincap & AC_PINCAP_VREF_80)
806 else if (pincap & AC_PINCAP_VREF_50)
808 else if (pincap & AC_PINCAP_VREF_100)
810 else if (pincap & AC_PINCAP_VREF_GRD)
813 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, val);
818 static void add_mixer(struct alc_spec *spec, struct snd_kcontrol_new *mix)
820 if (snd_BUG_ON(spec->num_mixers >= ARRAY_SIZE(spec->mixers)))
822 spec->mixers[spec->num_mixers++] = mix;
825 static void add_verb(struct alc_spec *spec, const struct hda_verb *verb)
827 if (snd_BUG_ON(spec->num_init_verbs >= ARRAY_SIZE(spec->init_verbs)))
829 spec->init_verbs[spec->num_init_verbs++] = verb;
832 #ifdef CONFIG_PROC_FS
836 static void print_realtek_coef(struct snd_info_buffer *buffer,
837 struct hda_codec *codec, hda_nid_t nid)
843 coeff = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_PROC_COEF, 0);
844 snd_iprintf(buffer, " Processing Coefficient: 0x%02x\n", coeff);
845 coeff = snd_hda_codec_read(codec, nid, 0,
846 AC_VERB_GET_COEF_INDEX, 0);
847 snd_iprintf(buffer, " Coefficient Index: 0x%02x\n", coeff);
850 #define print_realtek_coef NULL
854 * set up from the preset table
856 static void setup_preset(struct hda_codec *codec,
857 const struct alc_config_preset *preset)
859 struct alc_spec *spec = codec->spec;
862 for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++)
863 add_mixer(spec, preset->mixers[i]);
864 spec->cap_mixer = preset->cap_mixer;
865 for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i];
867 add_verb(spec, preset->init_verbs[i]);
869 spec->channel_mode = preset->channel_mode;
870 spec->num_channel_mode = preset->num_channel_mode;
871 spec->need_dac_fix = preset->need_dac_fix;
872 spec->const_channel_count = preset->const_channel_count;
874 if (preset->const_channel_count)
875 spec->multiout.max_channels = preset->const_channel_count;
877 spec->multiout.max_channels = spec->channel_mode[0].channels;
878 spec->ext_channel_count = spec->channel_mode[0].channels;
880 spec->multiout.num_dacs = preset->num_dacs;
881 spec->multiout.dac_nids = preset->dac_nids;
882 spec->multiout.dig_out_nid = preset->dig_out_nid;
883 spec->multiout.slave_dig_outs = preset->slave_dig_outs;
884 spec->multiout.hp_nid = preset->hp_nid;
886 spec->num_mux_defs = preset->num_mux_defs;
887 if (!spec->num_mux_defs)
888 spec->num_mux_defs = 1;
889 spec->input_mux = preset->input_mux;
891 spec->num_adc_nids = preset->num_adc_nids;
892 spec->adc_nids = preset->adc_nids;
893 spec->capsrc_nids = preset->capsrc_nids;
894 spec->dig_in_nid = preset->dig_in_nid;
896 spec->unsol_event = preset->unsol_event;
897 spec->init_hook = preset->init_hook;
898 #ifdef CONFIG_SND_HDA_POWER_SAVE
899 spec->loopback.amplist = preset->loopbacks;
903 preset->setup(codec);
906 /* Enable GPIO mask and set output */
907 static struct hda_verb alc_gpio1_init_verbs[] = {
908 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
909 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
910 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
914 static struct hda_verb alc_gpio2_init_verbs[] = {
915 {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
916 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
917 {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
921 static struct hda_verb alc_gpio3_init_verbs[] = {
922 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
923 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
924 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
929 * Fix hardware PLL issue
930 * On some codecs, the analog PLL gating control must be off while
931 * the default value is 1.
933 static void alc_fix_pll(struct hda_codec *codec)
935 struct alc_spec *spec = codec->spec;
940 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX,
942 val = snd_hda_codec_read(codec, spec->pll_nid, 0,
943 AC_VERB_GET_PROC_COEF, 0);
944 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX,
946 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_PROC_COEF,
947 val & ~(1 << spec->pll_coef_bit));
950 static void alc_fix_pll_init(struct hda_codec *codec, hda_nid_t nid,
951 unsigned int coef_idx, unsigned int coef_bit)
953 struct alc_spec *spec = codec->spec;
955 spec->pll_coef_idx = coef_idx;
956 spec->pll_coef_bit = coef_bit;
960 static void alc_automute_pin(struct hda_codec *codec)
962 struct alc_spec *spec = codec->spec;
963 unsigned int present, pincap;
964 unsigned int nid = spec->autocfg.hp_pins[0];
967 pincap = snd_hda_query_pin_caps(codec, nid);
968 if (pincap & AC_PINCAP_TRIG_REQ) /* need trigger? */
969 snd_hda_codec_read(codec, nid, 0, AC_VERB_SET_PIN_SENSE, 0);
970 present = snd_hda_codec_read(codec, nid, 0,
971 AC_VERB_GET_PIN_SENSE, 0);
972 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
973 for (i = 0; i < ARRAY_SIZE(spec->autocfg.speaker_pins); i++) {
974 nid = spec->autocfg.speaker_pins[i];
977 snd_hda_codec_write(codec, nid, 0,
978 AC_VERB_SET_PIN_WIDGET_CONTROL,
979 spec->jack_present ? 0 : PIN_OUT);
983 static int get_connection_index(struct hda_codec *codec, hda_nid_t mux,
986 hda_nid_t conn[HDA_MAX_NUM_INPUTS];
989 nums = snd_hda_get_connections(codec, mux, conn, ARRAY_SIZE(conn));
990 for (i = 0; i < nums; i++)
996 static void alc_mic_automute(struct hda_codec *codec)
998 struct alc_spec *spec = codec->spec;
999 struct alc_mic_route *dead, *alive;
1000 unsigned int present, type;
1003 if (!spec->auto_mic)
1005 if (!spec->int_mic.pin || !spec->ext_mic.pin)
1007 if (snd_BUG_ON(!spec->adc_nids))
1010 cap_nid = spec->capsrc_nids ? spec->capsrc_nids[0] : spec->adc_nids[0];
1012 present = snd_hda_codec_read(codec, spec->ext_mic.pin, 0,
1013 AC_VERB_GET_PIN_SENSE, 0);
1014 present &= AC_PINSENSE_PRESENCE;
1016 alive = &spec->ext_mic;
1017 dead = &spec->int_mic;
1019 alive = &spec->int_mic;
1020 dead = &spec->ext_mic;
1023 type = get_wcaps_type(get_wcaps(codec, cap_nid));
1024 if (type == AC_WID_AUD_MIX) {
1025 /* Matrix-mixer style (e.g. ALC882) */
1026 snd_hda_codec_amp_stereo(codec, cap_nid, HDA_INPUT,
1029 snd_hda_codec_amp_stereo(codec, cap_nid, HDA_INPUT,
1031 HDA_AMP_MUTE, HDA_AMP_MUTE);
1033 /* MUX style (e.g. ALC880) */
1034 snd_hda_codec_write_cache(codec, cap_nid, 0,
1035 AC_VERB_SET_CONNECT_SEL,
1039 /* FIXME: analog mixer */
1042 /* unsolicited event for HP jack sensing */
1043 static void alc_sku_unsol_event(struct hda_codec *codec, unsigned int res)
1045 if (codec->vendor_id == 0x10ec0880)
1050 case ALC880_HP_EVENT:
1051 alc_automute_pin(codec);
1053 case ALC880_MIC_EVENT:
1054 alc_mic_automute(codec);
1059 static void alc_inithook(struct hda_codec *codec)
1061 alc_automute_pin(codec);
1062 alc_mic_automute(codec);
1065 /* additional initialization for ALC888 variants */
1066 static void alc888_coef_init(struct hda_codec *codec)
1070 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 0);
1071 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
1072 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
1073 if ((tmp & 0xf0) == 0x20)
1075 snd_hda_codec_read(codec, 0x20, 0,
1076 AC_VERB_SET_PROC_COEF, 0x830);
1079 snd_hda_codec_read(codec, 0x20, 0,
1080 AC_VERB_SET_PROC_COEF, 0x3030);
1083 static void alc889_coef_init(struct hda_codec *codec)
1087 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
1088 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
1089 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
1090 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_PROC_COEF, tmp|0x2010);
1093 static void alc_auto_init_amp(struct hda_codec *codec, int type)
1098 case ALC_INIT_GPIO1:
1099 snd_hda_sequence_write(codec, alc_gpio1_init_verbs);
1101 case ALC_INIT_GPIO2:
1102 snd_hda_sequence_write(codec, alc_gpio2_init_verbs);
1104 case ALC_INIT_GPIO3:
1105 snd_hda_sequence_write(codec, alc_gpio3_init_verbs);
1107 case ALC_INIT_DEFAULT:
1108 switch (codec->vendor_id) {
1110 snd_hda_codec_write(codec, 0x0f, 0,
1111 AC_VERB_SET_EAPD_BTLENABLE, 2);
1112 snd_hda_codec_write(codec, 0x10, 0,
1113 AC_VERB_SET_EAPD_BTLENABLE, 2);
1125 snd_hda_codec_write(codec, 0x14, 0,
1126 AC_VERB_SET_EAPD_BTLENABLE, 2);
1127 snd_hda_codec_write(codec, 0x15, 0,
1128 AC_VERB_SET_EAPD_BTLENABLE, 2);
1131 switch (codec->vendor_id) {
1133 snd_hda_codec_write(codec, 0x1a, 0,
1134 AC_VERB_SET_COEF_INDEX, 7);
1135 tmp = snd_hda_codec_read(codec, 0x1a, 0,
1136 AC_VERB_GET_PROC_COEF, 0);
1137 snd_hda_codec_write(codec, 0x1a, 0,
1138 AC_VERB_SET_COEF_INDEX, 7);
1139 snd_hda_codec_write(codec, 0x1a, 0,
1140 AC_VERB_SET_PROC_COEF,
1150 alc889_coef_init(codec);
1153 alc888_coef_init(codec);
1157 snd_hda_codec_write(codec, 0x20, 0,
1158 AC_VERB_SET_COEF_INDEX, 7);
1159 tmp = snd_hda_codec_read(codec, 0x20, 0,
1160 AC_VERB_GET_PROC_COEF, 0);
1161 snd_hda_codec_write(codec, 0x20, 0,
1162 AC_VERB_SET_COEF_INDEX, 7);
1163 snd_hda_codec_write(codec, 0x20, 0,
1164 AC_VERB_SET_PROC_COEF,
1172 static void alc_init_auto_hp(struct hda_codec *codec)
1174 struct alc_spec *spec = codec->spec;
1176 if (!spec->autocfg.hp_pins[0])
1179 if (!spec->autocfg.speaker_pins[0]) {
1180 if (spec->autocfg.line_out_pins[0] &&
1181 spec->autocfg.line_out_type == AUTO_PIN_SPEAKER_OUT)
1182 spec->autocfg.speaker_pins[0] =
1183 spec->autocfg.line_out_pins[0];
1188 snd_printdd("realtek: Enable HP auto-muting on NID 0x%x\n",
1189 spec->autocfg.hp_pins[0]);
1190 snd_hda_codec_write_cache(codec, spec->autocfg.hp_pins[0], 0,
1191 AC_VERB_SET_UNSOLICITED_ENABLE,
1192 AC_USRSP_EN | ALC880_HP_EVENT);
1193 spec->unsol_event = alc_sku_unsol_event;
1196 static void alc_init_auto_mic(struct hda_codec *codec)
1198 struct alc_spec *spec = codec->spec;
1199 struct auto_pin_cfg *cfg = &spec->autocfg;
1200 hda_nid_t fixed, ext;
1203 /* there must be only two mic inputs exclusively */
1204 for (i = AUTO_PIN_LINE; i < AUTO_PIN_LAST; i++)
1205 if (cfg->input_pins[i])
1209 for (i = AUTO_PIN_MIC; i <= AUTO_PIN_FRONT_MIC; i++) {
1210 hda_nid_t nid = cfg->input_pins[i];
1211 unsigned int defcfg;
1214 defcfg = snd_hda_codec_get_pincfg(codec, nid);
1215 switch (get_defcfg_connect(defcfg)) {
1216 case AC_JACK_PORT_FIXED:
1218 return; /* already occupied */
1221 case AC_JACK_PORT_COMPLEX:
1223 return; /* already occupied */
1227 return; /* invalid entry */
1230 if (!(get_wcaps(codec, ext) & AC_WCAP_UNSOL_CAP))
1231 return; /* no unsol support */
1232 snd_printdd("realtek: Enable auto-mic switch on NID 0x%x/0x%x\n",
1234 spec->ext_mic.pin = ext;
1235 spec->int_mic.pin = fixed;
1236 spec->ext_mic.mux_idx = MUX_IDX_UNDEF; /* set later */
1237 spec->int_mic.mux_idx = MUX_IDX_UNDEF; /* set later */
1239 snd_hda_codec_write_cache(codec, spec->ext_mic.pin, 0,
1240 AC_VERB_SET_UNSOLICITED_ENABLE,
1241 AC_USRSP_EN | ALC880_MIC_EVENT);
1242 spec->unsol_event = alc_sku_unsol_event;
1245 /* check subsystem ID and set up device-specific initialization;
1246 * return 1 if initialized, 0 if invalid SSID
1248 /* 32-bit subsystem ID for BIOS loading in HD Audio codec.
1249 * 31 ~ 16 : Manufacture ID
1251 * 7 ~ 0 : Assembly ID
1252 * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36
1254 static int alc_subsystem_id(struct hda_codec *codec,
1255 hda_nid_t porta, hda_nid_t porte,
1258 unsigned int ass, tmp, i;
1260 struct alc_spec *spec = codec->spec;
1262 ass = codec->subsystem_id & 0xffff;
1263 if ((ass != codec->bus->pci->subsystem_device) && (ass & 1))
1266 /* invalid SSID, check the special NID pin defcfg instead */
1268 * 31~30 : port connectivity
1271 * 19~16 : Check sum (15:1)
1276 if (codec->vendor_id == 0x10ec0260)
1278 ass = snd_hda_codec_get_pincfg(codec, nid);
1279 snd_printd("realtek: No valid SSID, "
1280 "checking pincfg 0x%08x for NID 0x%x\n",
1282 if (!(ass & 1) && !(ass & 0x100000))
1284 if ((ass >> 30) != 1) /* no physical connection */
1289 for (i = 1; i < 16; i++) {
1293 if (((ass >> 16) & 0xf) != tmp)
1296 snd_printd("realtek: Enabling init ASM_ID=0x%04x CODEC_ID=%08x\n",
1297 ass & 0xffff, codec->vendor_id);
1301 * 2 : 0 --> Desktop, 1 --> Laptop
1302 * 3~5 : External Amplifier control
1305 tmp = (ass & 0x38) >> 3; /* external Amp control */
1308 spec->init_amp = ALC_INIT_GPIO1;
1311 spec->init_amp = ALC_INIT_GPIO2;
1314 spec->init_amp = ALC_INIT_GPIO3;
1317 spec->init_amp = ALC_INIT_DEFAULT;
1321 /* is laptop or Desktop and enable the function "Mute internal speaker
1322 * when the external headphone out jack is plugged"
1324 if (!(ass & 0x8000))
1327 * 10~8 : Jack location
1328 * 12~11: Headphone out -> 00: PortA, 01: PortE, 02: PortD, 03: Resvered
1330 * 15 : 1 --> enable the function "Mute internal speaker
1331 * when the external headphone out jack is plugged"
1333 if (!spec->autocfg.hp_pins[0]) {
1334 tmp = (ass >> 11) & 0x3; /* HP to chassis */
1336 spec->autocfg.hp_pins[0] = porta;
1338 spec->autocfg.hp_pins[0] = porte;
1340 spec->autocfg.hp_pins[0] = portd;
1345 alc_init_auto_hp(codec);
1346 alc_init_auto_mic(codec);
1350 static void alc_ssid_check(struct hda_codec *codec,
1351 hda_nid_t porta, hda_nid_t porte, hda_nid_t portd)
1353 if (!alc_subsystem_id(codec, porta, porte, portd)) {
1354 struct alc_spec *spec = codec->spec;
1355 snd_printd("realtek: "
1356 "Enable default setup for auto mode as fallback\n");
1357 spec->init_amp = ALC_INIT_DEFAULT;
1358 alc_init_auto_hp(codec);
1359 alc_init_auto_mic(codec);
1364 * Fix-up pin default configurations
1372 static void alc_fix_pincfg(struct hda_codec *codec,
1373 const struct snd_pci_quirk *quirk,
1374 const struct alc_pincfg **pinfix)
1376 const struct alc_pincfg *cfg;
1378 quirk = snd_pci_quirk_lookup(codec->bus->pci, quirk);
1382 cfg = pinfix[quirk->value];
1383 for (; cfg->nid; cfg++)
1384 snd_hda_codec_set_pincfg(codec, cfg->nid, cfg->val);
1394 static struct hda_verb alc888_4ST_ch2_intel_init[] = {
1395 /* Mic-in jack as mic in */
1396 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1397 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1398 /* Line-in jack as Line in */
1399 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1400 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1401 /* Line-Out as Front */
1402 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
1409 static struct hda_verb alc888_4ST_ch4_intel_init[] = {
1410 /* Mic-in jack as mic in */
1411 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1412 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1413 /* Line-in jack as Surround */
1414 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1415 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1416 /* Line-Out as Front */
1417 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
1424 static struct hda_verb alc888_4ST_ch6_intel_init[] = {
1425 /* Mic-in jack as CLFE */
1426 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1427 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1428 /* Line-in jack as Surround */
1429 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1430 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1431 /* Line-Out as CLFE (workaround because Mic-in is not loud enough) */
1432 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1439 static struct hda_verb alc888_4ST_ch8_intel_init[] = {
1440 /* Mic-in jack as CLFE */
1441 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1442 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1443 /* Line-in jack as Surround */
1444 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1445 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1446 /* Line-Out as Side */
1447 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1451 static struct hda_channel_mode alc888_4ST_8ch_intel_modes[4] = {
1452 { 2, alc888_4ST_ch2_intel_init },
1453 { 4, alc888_4ST_ch4_intel_init },
1454 { 6, alc888_4ST_ch6_intel_init },
1455 { 8, alc888_4ST_ch8_intel_init },
1459 * ALC888 Fujitsu Siemens Amillo xa3530
1462 static struct hda_verb alc888_fujitsu_xa3530_verbs[] = {
1463 /* Front Mic: set to PIN_IN (empty by default) */
1464 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1465 /* Connect Internal HP to Front */
1466 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1467 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1468 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1469 /* Connect Bass HP to Front */
1470 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1471 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1472 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1473 /* Connect Line-Out side jack (SPDIF) to Side */
1474 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1475 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1476 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1477 /* Connect Mic jack to CLFE */
1478 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1479 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1480 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02},
1481 /* Connect Line-in jack to Surround */
1482 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1483 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1484 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
1485 /* Connect HP out jack to Front */
1486 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1487 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1488 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
1489 /* Enable unsolicited event for HP jack and Line-out jack */
1490 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1491 {0x17, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1495 static void alc_automute_amp(struct hda_codec *codec)
1497 struct alc_spec *spec = codec->spec;
1498 unsigned int val, mute, pincap;
1502 spec->jack_present = 0;
1503 for (i = 0; i < ARRAY_SIZE(spec->autocfg.hp_pins); i++) {
1504 nid = spec->autocfg.hp_pins[i];
1507 pincap = snd_hda_query_pin_caps(codec, nid);
1508 if (pincap & AC_PINCAP_TRIG_REQ) /* need trigger? */
1509 snd_hda_codec_read(codec, nid, 0,
1510 AC_VERB_SET_PIN_SENSE, 0);
1511 val = snd_hda_codec_read(codec, nid, 0,
1512 AC_VERB_GET_PIN_SENSE, 0);
1513 if (val & AC_PINSENSE_PRESENCE) {
1514 spec->jack_present = 1;
1519 mute = spec->jack_present ? HDA_AMP_MUTE : 0;
1520 /* Toggle internal speakers muting */
1521 for (i = 0; i < ARRAY_SIZE(spec->autocfg.speaker_pins); i++) {
1522 nid = spec->autocfg.speaker_pins[i];
1525 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
1526 HDA_AMP_MUTE, mute);
1530 static void alc_automute_amp_unsol_event(struct hda_codec *codec,
1533 if (codec->vendor_id == 0x10ec0880)
1537 if (res == ALC880_HP_EVENT)
1538 alc_automute_amp(codec);
1541 static void alc889_automute_setup(struct hda_codec *codec)
1543 struct alc_spec *spec = codec->spec;
1545 spec->autocfg.hp_pins[0] = 0x15;
1546 spec->autocfg.speaker_pins[0] = 0x14;
1547 spec->autocfg.speaker_pins[1] = 0x16;
1548 spec->autocfg.speaker_pins[2] = 0x17;
1549 spec->autocfg.speaker_pins[3] = 0x19;
1550 spec->autocfg.speaker_pins[4] = 0x1a;
1553 static void alc889_intel_init_hook(struct hda_codec *codec)
1555 alc889_coef_init(codec);
1556 alc_automute_amp(codec);
1559 static void alc888_fujitsu_xa3530_setup(struct hda_codec *codec)
1561 struct alc_spec *spec = codec->spec;
1563 spec->autocfg.hp_pins[0] = 0x17; /* line-out */
1564 spec->autocfg.hp_pins[1] = 0x1b; /* hp */
1565 spec->autocfg.speaker_pins[0] = 0x14; /* speaker */
1566 spec->autocfg.speaker_pins[1] = 0x15; /* bass */
1570 * ALC888 Acer Aspire 4930G model
1573 static struct hda_verb alc888_acer_aspire_4930g_verbs[] = {
1574 /* Front Mic: set to PIN_IN (empty by default) */
1575 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1576 /* Unselect Front Mic by default in input mixer 3 */
1577 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
1578 /* Enable unsolicited event for HP jack */
1579 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1580 /* Connect Internal HP to front */
1581 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1582 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1583 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1584 /* Connect HP out to front */
1585 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1586 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1587 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1592 * ALC888 Acer Aspire 6530G model
1595 static struct hda_verb alc888_acer_aspire_6530g_verbs[] = {
1596 /* Bias voltage on for external mic port */
1597 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN | PIN_VREF80},
1598 /* Front Mic: set to PIN_IN (empty by default) */
1599 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1600 /* Unselect Front Mic by default in input mixer 3 */
1601 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
1602 /* Enable unsolicited event for HP jack */
1603 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1604 /* Enable speaker output */
1605 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1606 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1607 /* Enable headphone output */
1608 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | PIN_HP},
1609 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1610 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1615 * ALC889 Acer Aspire 8930G model
1618 static struct hda_verb alc889_acer_aspire_8930g_verbs[] = {
1619 /* Front Mic: set to PIN_IN (empty by default) */
1620 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1621 /* Unselect Front Mic by default in input mixer 3 */
1622 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
1623 /* Enable unsolicited event for HP jack */
1624 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1625 /* Connect Internal Front to Front */
1626 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1627 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1628 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1629 /* Connect Internal Rear to Rear */
1630 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1631 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1632 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01},
1633 /* Connect Internal CLFE to CLFE */
1634 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1635 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1636 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
1637 /* Connect HP out to Front */
1638 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | PIN_HP},
1639 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1640 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1641 /* Enable all DACs */
1642 /* DAC DISABLE/MUTE 1? */
1643 /* setting bits 1-5 disables DAC nids 0x02-0x06 apparently. Init=0x38 */
1644 {0x20, AC_VERB_SET_COEF_INDEX, 0x03},
1645 {0x20, AC_VERB_SET_PROC_COEF, 0x0000},
1646 /* DAC DISABLE/MUTE 2? */
1647 /* some bit here disables the other DACs. Init=0x4900 */
1648 {0x20, AC_VERB_SET_COEF_INDEX, 0x08},
1649 {0x20, AC_VERB_SET_PROC_COEF, 0x0000},
1650 /* Enable amplifiers */
1651 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
1652 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
1654 * This laptop has a stereo digital microphone. The mics are only 1cm apart
1655 * which makes the stereo useless. However, either the mic or the ALC889
1656 * makes the signal become a difference/sum signal instead of standard
1657 * stereo, which is annoying. So instead we flip this bit which makes the
1658 * codec replicate the sum signal to both channels, turning it into a
1661 /* DMIC_CONTROL? Init value = 0x0001 */
1662 {0x20, AC_VERB_SET_COEF_INDEX, 0x0b},
1663 {0x20, AC_VERB_SET_PROC_COEF, 0x0003},
1667 static struct hda_input_mux alc888_2_capture_sources[2] = {
1668 /* Front mic only available on one ADC */
1675 { "Front Mic", 0xb },
1688 static struct hda_input_mux alc888_acer_aspire_6530_sources[2] = {
1689 /* Interal mic only available on one ADC */
1696 { "Input Mix", 0xa },
1706 { "Input Mix", 0xa },
1711 static struct hda_input_mux alc889_capture_sources[3] = {
1712 /* Digital mic only available on first "ADC" */
1719 { "Front Mic", 0xb },
1720 { "Input Mix", 0xa },
1729 { "Input Mix", 0xa },
1738 { "Input Mix", 0xa },
1743 static struct snd_kcontrol_new alc888_base_mixer[] = {
1744 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1745 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1746 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1747 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
1748 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
1750 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1751 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1752 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1753 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
1754 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
1755 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1756 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1757 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1758 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1759 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1760 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
1761 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1765 static void alc888_acer_aspire_4930g_setup(struct hda_codec *codec)
1767 struct alc_spec *spec = codec->spec;
1769 spec->autocfg.hp_pins[0] = 0x15;
1770 spec->autocfg.speaker_pins[0] = 0x14;
1773 static void alc888_acer_aspire_6530g_setup(struct hda_codec *codec)
1775 struct alc_spec *spec = codec->spec;
1777 spec->autocfg.hp_pins[0] = 0x15;
1778 spec->autocfg.speaker_pins[0] = 0x14;
1779 spec->autocfg.speaker_pins[1] = 0x16;
1780 spec->autocfg.speaker_pins[2] = 0x17;
1783 static void alc889_acer_aspire_8930g_setup(struct hda_codec *codec)
1785 struct alc_spec *spec = codec->spec;
1787 spec->autocfg.hp_pins[0] = 0x15;
1788 spec->autocfg.speaker_pins[0] = 0x14;
1789 spec->autocfg.speaker_pins[1] = 0x16;
1790 spec->autocfg.speaker_pins[2] = 0x1b;
1794 * ALC880 3-stack model
1796 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
1797 * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18,
1798 * F-Mic = 0x1b, HP = 0x19
1801 static hda_nid_t alc880_dac_nids[4] = {
1802 /* front, rear, clfe, rear_surr */
1803 0x02, 0x05, 0x04, 0x03
1806 static hda_nid_t alc880_adc_nids[3] = {
1811 /* The datasheet says the node 0x07 is connected from inputs,
1812 * but it shows zero connection in the real implementation on some devices.
1813 * Note: this is a 915GAV bug, fixed on 915GLV
1815 static hda_nid_t alc880_adc_nids_alt[2] = {
1820 #define ALC880_DIGOUT_NID 0x06
1821 #define ALC880_DIGIN_NID 0x0a
1823 static struct hda_input_mux alc880_capture_source = {
1827 { "Front Mic", 0x3 },
1833 /* channel source setting (2/6 channel selection for 3-stack) */
1835 static struct hda_verb alc880_threestack_ch2_init[] = {
1836 /* set line-in to input, mute it */
1837 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1838 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1839 /* set mic-in to input vref 80%, mute it */
1840 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1841 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1846 static struct hda_verb alc880_threestack_ch6_init[] = {
1847 /* set line-in to output, unmute it */
1848 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1849 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1850 /* set mic-in to output, unmute it */
1851 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1852 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1856 static struct hda_channel_mode alc880_threestack_modes[2] = {
1857 { 2, alc880_threestack_ch2_init },
1858 { 6, alc880_threestack_ch6_init },
1861 static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
1862 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1863 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1864 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
1865 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
1866 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1867 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1868 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1869 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1870 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1871 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1872 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1873 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1874 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1875 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1876 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
1877 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
1878 HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
1880 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1881 .name = "Channel Mode",
1882 .info = alc_ch_mode_info,
1883 .get = alc_ch_mode_get,
1884 .put = alc_ch_mode_put,
1889 /* capture mixer elements */
1890 static int alc_cap_vol_info(struct snd_kcontrol *kcontrol,
1891 struct snd_ctl_elem_info *uinfo)
1893 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1894 struct alc_spec *spec = codec->spec;
1897 mutex_lock(&codec->control_mutex);
1898 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0,
1900 err = snd_hda_mixer_amp_volume_info(kcontrol, uinfo);
1901 mutex_unlock(&codec->control_mutex);
1905 static int alc_cap_vol_tlv(struct snd_kcontrol *kcontrol, int op_flag,
1906 unsigned int size, unsigned int __user *tlv)
1908 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1909 struct alc_spec *spec = codec->spec;
1912 mutex_lock(&codec->control_mutex);
1913 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0,
1915 err = snd_hda_mixer_amp_tlv(kcontrol, op_flag, size, tlv);
1916 mutex_unlock(&codec->control_mutex);
1920 typedef int (*getput_call_t)(struct snd_kcontrol *kcontrol,
1921 struct snd_ctl_elem_value *ucontrol);
1923 static int alc_cap_getput_caller(struct snd_kcontrol *kcontrol,
1924 struct snd_ctl_elem_value *ucontrol,
1927 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1928 struct alc_spec *spec = codec->spec;
1929 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
1932 mutex_lock(&codec->control_mutex);
1933 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[adc_idx],
1935 err = func(kcontrol, ucontrol);
1936 mutex_unlock(&codec->control_mutex);
1940 static int alc_cap_vol_get(struct snd_kcontrol *kcontrol,
1941 struct snd_ctl_elem_value *ucontrol)
1943 return alc_cap_getput_caller(kcontrol, ucontrol,
1944 snd_hda_mixer_amp_volume_get);
1947 static int alc_cap_vol_put(struct snd_kcontrol *kcontrol,
1948 struct snd_ctl_elem_value *ucontrol)
1950 return alc_cap_getput_caller(kcontrol, ucontrol,
1951 snd_hda_mixer_amp_volume_put);
1954 /* capture mixer elements */
1955 #define alc_cap_sw_info snd_ctl_boolean_stereo_info
1957 static int alc_cap_sw_get(struct snd_kcontrol *kcontrol,
1958 struct snd_ctl_elem_value *ucontrol)
1960 return alc_cap_getput_caller(kcontrol, ucontrol,
1961 snd_hda_mixer_amp_switch_get);
1964 static int alc_cap_sw_put(struct snd_kcontrol *kcontrol,
1965 struct snd_ctl_elem_value *ucontrol)
1967 return alc_cap_getput_caller(kcontrol, ucontrol,
1968 snd_hda_mixer_amp_switch_put);
1971 #define _DEFINE_CAPMIX(num) \
1973 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1974 .name = "Capture Switch", \
1975 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, \
1977 .info = alc_cap_sw_info, \
1978 .get = alc_cap_sw_get, \
1979 .put = alc_cap_sw_put, \
1982 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1983 .name = "Capture Volume", \
1984 .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE | \
1985 SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
1986 SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK), \
1988 .info = alc_cap_vol_info, \
1989 .get = alc_cap_vol_get, \
1990 .put = alc_cap_vol_put, \
1991 .tlv = { .c = alc_cap_vol_tlv }, \
1994 #define _DEFINE_CAPSRC(num) \
1996 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1997 /* .name = "Capture Source", */ \
1998 .name = "Input Source", \
2000 .info = alc_mux_enum_info, \
2001 .get = alc_mux_enum_get, \
2002 .put = alc_mux_enum_put, \
2005 #define DEFINE_CAPMIX(num) \
2006 static struct snd_kcontrol_new alc_capture_mixer ## num[] = { \
2007 _DEFINE_CAPMIX(num), \
2008 _DEFINE_CAPSRC(num), \
2012 #define DEFINE_CAPMIX_NOSRC(num) \
2013 static struct snd_kcontrol_new alc_capture_mixer_nosrc ## num[] = { \
2014 _DEFINE_CAPMIX(num), \
2018 /* up to three ADCs */
2022 DEFINE_CAPMIX_NOSRC(1);
2023 DEFINE_CAPMIX_NOSRC(2);
2024 DEFINE_CAPMIX_NOSRC(3);
2027 * ALC880 5-stack model
2029 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d),
2031 * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
2032 * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
2035 /* additional mixers to alc880_three_stack_mixer */
2036 static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
2037 HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2038 HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
2042 /* channel source setting (6/8 channel selection for 5-stack) */
2044 static struct hda_verb alc880_fivestack_ch6_init[] = {
2045 /* set line-in to input, mute it */
2046 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
2047 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
2052 static struct hda_verb alc880_fivestack_ch8_init[] = {
2053 /* set line-in to output, unmute it */
2054 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
2055 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
2059 static struct hda_channel_mode alc880_fivestack_modes[2] = {
2060 { 6, alc880_fivestack_ch6_init },
2061 { 8, alc880_fivestack_ch8_init },
2066 * ALC880 6-stack model
2068 * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e),
2069 * Side = 0x05 (0x0f)
2070 * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
2071 * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
2074 static hda_nid_t alc880_6st_dac_nids[4] = {
2075 /* front, rear, clfe, rear_surr */
2076 0x02, 0x03, 0x04, 0x05
2079 static struct hda_input_mux alc880_6stack_capture_source = {
2083 { "Front Mic", 0x1 },
2089 /* fixed 8-channels */
2090 static struct hda_channel_mode alc880_sixstack_modes[1] = {
2094 static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
2095 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2096 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2097 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2098 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
2099 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2100 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2101 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2102 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2103 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
2104 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
2105 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2106 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2107 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2108 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2109 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2110 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2111 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2112 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
2114 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2115 .name = "Channel Mode",
2116 .info = alc_ch_mode_info,
2117 .get = alc_ch_mode_get,
2118 .put = alc_ch_mode_put,
2127 * W810 has rear IO for:
2130 * Center/LFE (DAC 04)
2133 * The system also has a pair of internal speakers, and a headphone jack.
2134 * These are both connected to Line2 on the codec, hence to DAC 02.
2136 * There is a variable resistor to control the speaker or headphone
2137 * volume. This is a hardware-only device without a software API.
2139 * Plugging headphones in will disable the internal speakers. This is
2140 * implemented in hardware, not via the driver using jack sense. In
2141 * a similar fashion, plugging into the rear socket marked "front" will
2142 * disable both the speakers and headphones.
2144 * For input, there's a microphone jack, and an "audio in" jack.
2145 * These may not do anything useful with this driver yet, because I
2146 * haven't setup any initialization verbs for these yet...
2149 static hda_nid_t alc880_w810_dac_nids[3] = {
2150 /* front, rear/surround, clfe */
2154 /* fixed 6 channels */
2155 static struct hda_channel_mode alc880_w810_modes[1] = {
2159 /* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
2160 static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
2161 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2162 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2163 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2164 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
2165 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2166 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2167 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2168 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2169 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
2177 * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
2178 * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?),
2182 static hda_nid_t alc880_z71v_dac_nids[1] = {
2185 #define ALC880_Z71V_HP_DAC 0x03
2187 /* fixed 2 channels */
2188 static struct hda_channel_mode alc880_2_jack_modes[1] = {
2192 static struct snd_kcontrol_new alc880_z71v_mixer[] = {
2193 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2194 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2195 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2196 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
2197 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2198 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2199 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2200 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2206 * ALC880 F1734 model
2208 * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
2209 * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
2212 static hda_nid_t alc880_f1734_dac_nids[1] = {
2215 #define ALC880_F1734_HP_DAC 0x02
2217 static struct snd_kcontrol_new alc880_f1734_mixer[] = {
2218 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2219 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2220 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2221 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
2222 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2223 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2224 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2225 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
2229 static struct hda_input_mux alc880_f1734_capture_source = {
2241 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
2242 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
2243 * Mic = 0x18, Line = 0x1a
2246 #define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
2247 #define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
2249 static struct snd_kcontrol_new alc880_asus_mixer[] = {
2250 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2251 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2252 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2253 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
2254 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2255 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2256 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2257 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2258 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2259 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2260 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2261 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2262 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2263 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2265 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2266 .name = "Channel Mode",
2267 .info = alc_ch_mode_info,
2268 .get = alc_ch_mode_get,
2269 .put = alc_ch_mode_put,
2275 * ALC880 ASUS W1V model
2277 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
2278 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
2279 * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
2282 /* additional mixers to alc880_asus_mixer */
2283 static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
2284 HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
2285 HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
2290 static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
2291 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2292 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
2293 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
2294 HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
2295 HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
2296 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
2297 HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
2298 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
2299 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
2304 static struct snd_kcontrol_new alc880_uniwill_mixer[] = {
2305 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2306 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2307 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2308 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
2309 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2310 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2311 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2312 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2313 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2314 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2315 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2316 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2317 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2318 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2319 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2320 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
2322 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2323 .name = "Channel Mode",
2324 .info = alc_ch_mode_info,
2325 .get = alc_ch_mode_get,
2326 .put = alc_ch_mode_put,
2331 static struct snd_kcontrol_new alc880_fujitsu_mixer[] = {
2332 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2333 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2334 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2335 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
2336 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2337 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2338 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2339 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2340 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2341 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
2345 static struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = {
2346 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2347 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2348 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2349 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
2350 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2351 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2356 * virtual master controls
2360 * slave controls for virtual master
2362 static const char *alc_slave_vols[] = {
2363 "Front Playback Volume",
2364 "Surround Playback Volume",
2365 "Center Playback Volume",
2366 "LFE Playback Volume",
2367 "Side Playback Volume",
2368 "Headphone Playback Volume",
2369 "Speaker Playback Volume",
2370 "Mono Playback Volume",
2371 "Line-Out Playback Volume",
2372 "PCM Playback Volume",
2376 static const char *alc_slave_sws[] = {
2377 "Front Playback Switch",
2378 "Surround Playback Switch",
2379 "Center Playback Switch",
2380 "LFE Playback Switch",
2381 "Side Playback Switch",
2382 "Headphone Playback Switch",
2383 "Speaker Playback Switch",
2384 "Mono Playback Switch",
2385 "IEC958 Playback Switch",
2390 * build control elements
2393 static void alc_free_kctls(struct hda_codec *codec);
2395 /* additional beep mixers; the actual parameters are overwritten at build */
2396 static struct snd_kcontrol_new alc_beep_mixer[] = {
2397 HDA_CODEC_VOLUME("Beep Playback Volume", 0, 0, HDA_INPUT),
2398 HDA_CODEC_MUTE("Beep Playback Switch", 0, 0, HDA_INPUT),
2402 static int alc_build_controls(struct hda_codec *codec)
2404 struct alc_spec *spec = codec->spec;
2408 for (i = 0; i < spec->num_mixers; i++) {
2409 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
2413 if (spec->cap_mixer) {
2414 err = snd_hda_add_new_ctls(codec, spec->cap_mixer);
2418 if (spec->multiout.dig_out_nid) {
2419 err = snd_hda_create_spdif_out_ctls(codec,
2420 spec->multiout.dig_out_nid);
2423 if (!spec->no_analog) {
2424 err = snd_hda_create_spdif_share_sw(codec,
2428 spec->multiout.share_spdif = 1;
2431 if (spec->dig_in_nid) {
2432 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
2437 /* create beep controls if needed */
2438 if (spec->beep_amp) {
2439 struct snd_kcontrol_new *knew;
2440 for (knew = alc_beep_mixer; knew->name; knew++) {
2441 struct snd_kcontrol *kctl;
2442 kctl = snd_ctl_new1(knew, codec);
2445 kctl->private_value = spec->beep_amp;
2446 err = snd_hda_ctl_add(codec, kctl);
2452 /* if we have no master control, let's create it */
2453 if (!spec->no_analog &&
2454 !snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
2455 unsigned int vmaster_tlv[4];
2456 snd_hda_set_vmaster_tlv(codec, spec->vmaster_nid,
2457 HDA_OUTPUT, vmaster_tlv);
2458 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
2459 vmaster_tlv, alc_slave_vols);
2463 if (!spec->no_analog &&
2464 !snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
2465 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
2466 NULL, alc_slave_sws);
2471 alc_free_kctls(codec); /* no longer needed */
2477 * initialize the codec volumes, etc
2481 * generic initialization of ADC, input mixers and output mixers
2483 static struct hda_verb alc880_volume_init_verbs[] = {
2485 * Unmute ADC0-2 and set the default input to mic-in
2487 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
2488 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2489 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
2490 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2491 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
2492 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2494 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
2496 * Note: PASD motherboards uses the Line In 2 as the input for front
2499 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
2500 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2501 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2502 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
2503 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
2504 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
2505 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
2506 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
2509 * Set up output mixers (0x0c - 0x0f)
2511 /* set vol=0 to output mixers */
2512 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2513 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2514 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2515 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2516 /* set up input amps for analog loopback */
2517 /* Amp Indices: DAC = 0, mixer = 1 */
2518 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2519 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2520 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2521 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2522 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2523 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2524 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2525 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2531 * 3-stack pin configuration:
2532 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
2534 static struct hda_verb alc880_pin_3stack_init_verbs[] = {
2536 * preset connection lists of input pins
2537 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
2539 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
2540 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2541 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
2544 * Set pin mode and muting
2546 /* set front pin widgets 0x14 for output */
2547 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2548 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2549 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2550 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2551 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2552 /* Mic2 (as headphone out) for HP output */
2553 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2554 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2555 /* Line In pin widget for input */
2556 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2557 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2558 /* Line2 (as front mic) pin widget for input and vref at 80% */
2559 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2560 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2561 /* CD pin widget for input */
2562 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2568 * 5-stack pin configuration:
2569 * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
2570 * line-in/side = 0x1a, f-mic = 0x1b
2572 static struct hda_verb alc880_pin_5stack_init_verbs[] = {
2574 * preset connection lists of input pins
2575 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
2577 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2578 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
2581 * Set pin mode and muting
2583 /* set pin widgets 0x14-0x17 for output */
2584 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2585 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2586 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2587 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2588 /* unmute pins for output (no gain on this amp) */
2589 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2590 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2591 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2592 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2594 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2595 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2596 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2597 /* Mic2 (as headphone out) for HP output */
2598 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2599 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2600 /* Line In pin widget for input */
2601 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2602 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2603 /* Line2 (as front mic) pin widget for input and vref at 80% */
2604 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2605 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2606 /* CD pin widget for input */
2607 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2613 * W810 pin configuration:
2614 * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
2616 static struct hda_verb alc880_pin_w810_init_verbs[] = {
2617 /* hphone/speaker input selector: front DAC */
2618 {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
2620 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2621 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2622 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2623 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2624 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2625 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2627 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2628 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2634 * Z71V pin configuration:
2635 * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
2637 static struct hda_verb alc880_pin_z71v_init_verbs[] = {
2638 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2639 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2640 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2641 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2643 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2644 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2645 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2646 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2652 * 6-stack pin configuration:
2653 * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18,
2654 * f-mic = 0x19, line = 0x1a, HP = 0x1b
2656 static struct hda_verb alc880_pin_6stack_init_verbs[] = {
2657 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2659 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2660 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2661 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2662 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2663 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2664 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2665 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2666 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2668 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2669 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2670 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2671 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2672 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2673 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2674 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2675 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2676 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2682 * Uniwill pin configuration:
2683 * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19,
2686 static struct hda_verb alc880_uniwill_init_verbs[] = {
2687 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2689 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2690 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2691 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2692 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2693 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2694 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2695 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2696 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2697 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2698 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2699 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2700 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2701 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2702 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2704 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2705 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2706 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2707 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2708 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2709 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2710 /* {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, */
2711 /* {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
2712 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2714 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
2715 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
2722 * HP = 0x14, InternalSpeaker = 0x15, mic = 0x19,
2724 static struct hda_verb alc880_uniwill_p53_init_verbs[] = {
2725 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2727 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2728 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2729 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2730 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2731 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2732 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2733 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2734 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2735 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2736 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2737 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2738 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2740 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2741 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2742 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2743 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2744 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2745 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2747 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
2748 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_DCVOL_EVENT},
2753 static struct hda_verb alc880_beep_init_verbs[] = {
2754 { 0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5) },
2758 /* auto-toggle front mic */
2759 static void alc880_uniwill_mic_automute(struct hda_codec *codec)
2761 unsigned int present;
2764 present = snd_hda_codec_read(codec, 0x18, 0,
2765 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
2766 bits = present ? HDA_AMP_MUTE : 0;
2767 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
2770 static void alc880_uniwill_setup(struct hda_codec *codec)
2772 struct alc_spec *spec = codec->spec;
2774 spec->autocfg.hp_pins[0] = 0x14;
2775 spec->autocfg.speaker_pins[0] = 0x15;
2776 spec->autocfg.speaker_pins[0] = 0x16;
2779 static void alc880_uniwill_init_hook(struct hda_codec *codec)
2781 alc_automute_amp(codec);
2782 alc880_uniwill_mic_automute(codec);
2785 static void alc880_uniwill_unsol_event(struct hda_codec *codec,
2788 /* Looks like the unsol event is incompatible with the standard
2789 * definition. 4bit tag is placed at 28 bit!
2791 switch (res >> 28) {
2792 case ALC880_MIC_EVENT:
2793 alc880_uniwill_mic_automute(codec);
2796 alc_automute_amp_unsol_event(codec, res);
2801 static void alc880_uniwill_p53_setup(struct hda_codec *codec)
2803 struct alc_spec *spec = codec->spec;
2805 spec->autocfg.hp_pins[0] = 0x14;
2806 spec->autocfg.speaker_pins[0] = 0x15;
2809 static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec)
2811 unsigned int present;
2813 present = snd_hda_codec_read(codec, 0x21, 0,
2814 AC_VERB_GET_VOLUME_KNOB_CONTROL, 0);
2815 present &= HDA_AMP_VOLMASK;
2816 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0,
2817 HDA_AMP_VOLMASK, present);
2818 snd_hda_codec_amp_stereo(codec, 0x0d, HDA_OUTPUT, 0,
2819 HDA_AMP_VOLMASK, present);
2822 static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec,
2825 /* Looks like the unsol event is incompatible with the standard
2826 * definition. 4bit tag is placed at 28 bit!
2828 if ((res >> 28) == ALC880_DCVOL_EVENT)
2829 alc880_uniwill_p53_dcvol_automute(codec);
2831 alc_automute_amp_unsol_event(codec, res);
2835 * F1734 pin configuration:
2836 * HP = 0x14, speaker-out = 0x15, mic = 0x18
2838 static struct hda_verb alc880_pin_f1734_init_verbs[] = {
2839 {0x07, AC_VERB_SET_CONNECT_SEL, 0x01},
2840 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
2841 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
2842 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
2843 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
2845 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2846 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2847 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2848 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2850 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2851 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2852 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
2853 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2854 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2855 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2856 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2857 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2858 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2860 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
2861 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_DCVOL_EVENT},
2867 * ASUS pin configuration:
2868 * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
2870 static struct hda_verb alc880_pin_asus_init_verbs[] = {
2871 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
2872 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
2873 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
2874 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
2876 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2877 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2878 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2879 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2880 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2881 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2882 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2883 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2885 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2886 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2887 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2888 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2889 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2890 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2891 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2892 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2893 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2898 /* Enable GPIO mask and set output */
2899 #define alc880_gpio1_init_verbs alc_gpio1_init_verbs
2900 #define alc880_gpio2_init_verbs alc_gpio2_init_verbs
2901 #define alc880_gpio3_init_verbs alc_gpio3_init_verbs
2903 /* Clevo m520g init */
2904 static struct hda_verb alc880_pin_clevo_init_verbs[] = {
2905 /* headphone output */
2906 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
2908 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2909 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2911 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2912 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2914 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2915 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2916 /* Mic1 (rear panel) */
2917 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2918 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2919 /* Mic2 (front panel) */
2920 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2921 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2923 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2924 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2925 /* change to EAPD mode */
2926 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2927 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
2932 static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
2933 /* change to EAPD mode */
2934 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2935 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
2937 /* Headphone output */
2938 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2940 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2941 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
2943 /* Line In pin widget for input */
2944 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2945 /* CD pin widget for input */
2946 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2947 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2948 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2950 /* change to EAPD mode */
2951 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2952 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
2958 * LG m1 express dual
2961 * Rear Line-In/Out (blue): 0x14
2962 * Build-in Mic-In: 0x15
2964 * HP-Out (green): 0x1b
2965 * Mic-In/Out (red): 0x19
2969 /* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
2970 static hda_nid_t alc880_lg_dac_nids[3] = {
2974 /* seems analog CD is not working */
2975 static struct hda_input_mux alc880_lg_capture_source = {
2980 { "Internal Mic", 0x6 },
2984 /* 2,4,6 channel modes */
2985 static struct hda_verb alc880_lg_ch2_init[] = {
2986 /* set line-in and mic-in to input */
2987 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
2988 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
2992 static struct hda_verb alc880_lg_ch4_init[] = {
2993 /* set line-in to out and mic-in to input */
2994 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
2995 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
2999 static struct hda_verb alc880_lg_ch6_init[] = {
3000 /* set line-in and mic-in to output */
3001 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
3002 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
3006 static struct hda_channel_mode alc880_lg_ch_modes[3] = {
3007 { 2, alc880_lg_ch2_init },
3008 { 4, alc880_lg_ch4_init },
3009 { 6, alc880_lg_ch6_init },
3012 static struct snd_kcontrol_new alc880_lg_mixer[] = {
3013 HDA_CODEC_VOLUME("Front Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
3014 HDA_BIND_MUTE("Front Playback Switch", 0x0f, 2, HDA_INPUT),
3015 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3016 HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
3017 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
3018 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
3019 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
3020 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
3021 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
3022 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
3023 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
3024 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
3025 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
3026 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
3028 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3029 .name = "Channel Mode",
3030 .info = alc_ch_mode_info,
3031 .get = alc_ch_mode_get,
3032 .put = alc_ch_mode_put,
3037 static struct hda_verb alc880_lg_init_verbs[] = {
3038 /* set capture source to mic-in */
3039 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3040 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3041 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3042 /* mute all amp mixer inputs */
3043 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
3044 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
3045 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
3046 /* line-in to input */
3047 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3048 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3050 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3051 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3053 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3054 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3055 /* mic-in to input */
3056 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
3057 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3058 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3060 {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
3061 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3062 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3064 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
3068 /* toggle speaker-output according to the hp-jack state */
3069 static void alc880_lg_setup(struct hda_codec *codec)
3071 struct alc_spec *spec = codec->spec;
3073 spec->autocfg.hp_pins[0] = 0x1b;
3074 spec->autocfg.speaker_pins[0] = 0x17;
3083 * Built-in Mic-In: 0x19
3089 static struct hda_input_mux alc880_lg_lw_capture_source = {
3093 { "Internal Mic", 0x1 },
3098 #define alc880_lg_lw_modes alc880_threestack_modes
3100 static struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
3101 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3102 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
3103 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
3104 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
3105 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
3106 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
3107 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
3108 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
3109 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
3110 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
3111 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
3112 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
3113 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
3114 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
3116 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3117 .name = "Channel Mode",
3118 .info = alc_ch_mode_info,
3119 .get = alc_ch_mode_get,
3120 .put = alc_ch_mode_put,
3125 static struct hda_verb alc880_lg_lw_init_verbs[] = {
3126 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3127 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
3128 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
3130 /* set capture source to mic-in */
3131 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3132 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3133 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3134 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
3136 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3137 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3139 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3140 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3141 /* mic-in to input */
3142 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3143 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3145 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3146 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3148 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
3152 /* toggle speaker-output according to the hp-jack state */
3153 static void alc880_lg_lw_setup(struct hda_codec *codec)
3155 struct alc_spec *spec = codec->spec;
3157 spec->autocfg.hp_pins[0] = 0x1b;
3158 spec->autocfg.speaker_pins[0] = 0x14;
3161 static struct snd_kcontrol_new alc880_medion_rim_mixer[] = {
3162 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3163 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
3164 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
3165 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
3166 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
3167 HDA_CODEC_MUTE("Internal Playback Switch", 0x0b, 0x1, HDA_INPUT),
3171 static struct hda_input_mux alc880_medion_rim_capture_source = {
3175 { "Internal Mic", 0x1 },
3179 static struct hda_verb alc880_medion_rim_init_verbs[] = {
3180 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3182 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3183 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3185 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3186 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3187 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3188 /* Mic2 (as headphone out) for HP output */
3189 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3190 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3191 /* Internal Speaker */
3192 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3193 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3195 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
3196 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
3198 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
3202 /* toggle speaker-output according to the hp-jack state */
3203 static void alc880_medion_rim_automute(struct hda_codec *codec)
3205 struct alc_spec *spec = codec->spec;
3206 alc_automute_amp(codec);
3208 if (spec->jack_present)
3209 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 0);
3211 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 2);
3214 static void alc880_medion_rim_unsol_event(struct hda_codec *codec,
3217 /* Looks like the unsol event is incompatible with the standard
3218 * definition. 4bit tag is placed at 28 bit!
3220 if ((res >> 28) == ALC880_HP_EVENT)
3221 alc880_medion_rim_automute(codec);
3224 static void alc880_medion_rim_setup(struct hda_codec *codec)
3226 struct alc_spec *spec = codec->spec;
3228 spec->autocfg.hp_pins[0] = 0x14;
3229 spec->autocfg.speaker_pins[0] = 0x1b;
3232 #ifdef CONFIG_SND_HDA_POWER_SAVE
3233 static struct hda_amp_list alc880_loopbacks[] = {
3234 { 0x0b, HDA_INPUT, 0 },
3235 { 0x0b, HDA_INPUT, 1 },
3236 { 0x0b, HDA_INPUT, 2 },
3237 { 0x0b, HDA_INPUT, 3 },
3238 { 0x0b, HDA_INPUT, 4 },
3242 static struct hda_amp_list alc880_lg_loopbacks[] = {
3243 { 0x0b, HDA_INPUT, 1 },
3244 { 0x0b, HDA_INPUT, 6 },
3245 { 0x0b, HDA_INPUT, 7 },
3254 static int alc_init(struct hda_codec *codec)
3256 struct alc_spec *spec = codec->spec;
3260 alc_auto_init_amp(codec, spec->init_amp);
3262 for (i = 0; i < spec->num_init_verbs; i++)
3263 snd_hda_sequence_write(codec, spec->init_verbs[i]);
3265 if (spec->init_hook)
3266 spec->init_hook(codec);
3271 static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
3273 struct alc_spec *spec = codec->spec;
3275 if (spec->unsol_event)
3276 spec->unsol_event(codec, res);
3279 #ifdef CONFIG_SND_HDA_POWER_SAVE
3280 static int alc_check_power_status(struct hda_codec *codec, hda_nid_t nid)
3282 struct alc_spec *spec = codec->spec;
3283 return snd_hda_check_amp_list_power(codec, &spec->loopback, nid);
3288 * Analog playback callbacks
3290 static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
3291 struct hda_codec *codec,
3292 struct snd_pcm_substream *substream)
3294 struct alc_spec *spec = codec->spec;
3295 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
3299 static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
3300 struct hda_codec *codec,
3301 unsigned int stream_tag,
3302 unsigned int format,
3303 struct snd_pcm_substream *substream)
3305 struct alc_spec *spec = codec->spec;
3306 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
3307 stream_tag, format, substream);
3310 static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
3311 struct hda_codec *codec,
3312 struct snd_pcm_substream *substream)
3314 struct alc_spec *spec = codec->spec;
3315 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
3321 static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
3322 struct hda_codec *codec,
3323 struct snd_pcm_substream *substream)
3325 struct alc_spec *spec = codec->spec;
3326 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
3329 static int alc880_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
3330 struct hda_codec *codec,
3331 unsigned int stream_tag,
3332 unsigned int format,
3333 struct snd_pcm_substream *substream)
3335 struct alc_spec *spec = codec->spec;
3336 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
3337 stream_tag, format, substream);
3340 static int alc880_dig_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
3341 struct hda_codec *codec,
3342 struct snd_pcm_substream *substream)
3344 struct alc_spec *spec = codec->spec;
3345 return snd_hda_multi_out_dig_cleanup(codec, &spec->multiout);
3348 static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
3349 struct hda_codec *codec,
3350 struct snd_pcm_substream *substream)
3352 struct alc_spec *spec = codec->spec;
3353 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
3359 static int alc880_alt_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
3360 struct hda_codec *codec,
3361 unsigned int stream_tag,
3362 unsigned int format,
3363 struct snd_pcm_substream *substream)
3365 struct alc_spec *spec = codec->spec;
3367 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number + 1],
3368 stream_tag, 0, format);
3372 static int alc880_alt_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
3373 struct hda_codec *codec,
3374 struct snd_pcm_substream *substream)
3376 struct alc_spec *spec = codec->spec;
3378 snd_hda_codec_cleanup_stream(codec,
3379 spec->adc_nids[substream->number + 1]);
3386 static struct hda_pcm_stream alc880_pcm_analog_playback = {
3390 /* NID is set in alc_build_pcms */
3392 .open = alc880_playback_pcm_open,
3393 .prepare = alc880_playback_pcm_prepare,
3394 .cleanup = alc880_playback_pcm_cleanup
3398 static struct hda_pcm_stream alc880_pcm_analog_capture = {
3402 /* NID is set in alc_build_pcms */
3405 static struct hda_pcm_stream alc880_pcm_analog_alt_playback = {
3409 /* NID is set in alc_build_pcms */
3412 static struct hda_pcm_stream alc880_pcm_analog_alt_capture = {
3413 .substreams = 2, /* can be overridden */
3416 /* NID is set in alc_build_pcms */
3418 .prepare = alc880_alt_capture_pcm_prepare,
3419 .cleanup = alc880_alt_capture_pcm_cleanup
3423 static struct hda_pcm_stream alc880_pcm_digital_playback = {
3427 /* NID is set in alc_build_pcms */
3429 .open = alc880_dig_playback_pcm_open,
3430 .close = alc880_dig_playback_pcm_close,
3431 .prepare = alc880_dig_playback_pcm_prepare,
3432 .cleanup = alc880_dig_playback_pcm_cleanup
3436 static struct hda_pcm_stream alc880_pcm_digital_capture = {
3440 /* NID is set in alc_build_pcms */
3443 /* Used by alc_build_pcms to flag that a PCM has no playback stream */
3444 static struct hda_pcm_stream alc_pcm_null_stream = {
3450 static int alc_build_pcms(struct hda_codec *codec)
3452 struct alc_spec *spec = codec->spec;
3453 struct hda_pcm *info = spec->pcm_rec;
3456 codec->num_pcms = 1;
3457 codec->pcm_info = info;
3459 if (spec->no_analog)
3462 snprintf(spec->stream_name_analog, sizeof(spec->stream_name_analog),
3463 "%s Analog", codec->chip_name);
3464 info->name = spec->stream_name_analog;
3466 if (spec->stream_analog_playback) {
3467 if (snd_BUG_ON(!spec->multiout.dac_nids))
3469 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
3470 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
3472 if (spec->stream_analog_capture) {
3473 if (snd_BUG_ON(!spec->adc_nids))
3475 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
3476 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
3479 if (spec->channel_mode) {
3480 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
3481 for (i = 0; i < spec->num_channel_mode; i++) {
3482 if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
3483 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
3489 /* SPDIF for stream index #1 */
3490 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
3491 snprintf(spec->stream_name_digital,
3492 sizeof(spec->stream_name_digital),
3493 "%s Digital", codec->chip_name);
3494 codec->num_pcms = 2;
3495 codec->slave_dig_outs = spec->multiout.slave_dig_outs;
3496 info = spec->pcm_rec + 1;
3497 info->name = spec->stream_name_digital;
3498 if (spec->dig_out_type)
3499 info->pcm_type = spec->dig_out_type;
3501 info->pcm_type = HDA_PCM_TYPE_SPDIF;
3502 if (spec->multiout.dig_out_nid &&
3503 spec->stream_digital_playback) {
3504 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
3505 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
3507 if (spec->dig_in_nid &&
3508 spec->stream_digital_capture) {
3509 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
3510 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
3512 /* FIXME: do we need this for all Realtek codec models? */
3513 codec->spdif_status_reset = 1;
3516 if (spec->no_analog)
3519 /* If the use of more than one ADC is requested for the current
3520 * model, configure a second analog capture-only PCM.
3522 /* Additional Analaog capture for index #2 */
3523 if ((spec->alt_dac_nid && spec->stream_analog_alt_playback) ||
3524 (spec->num_adc_nids > 1 && spec->stream_analog_alt_capture)) {
3525 codec->num_pcms = 3;
3526 info = spec->pcm_rec + 2;
3527 info->name = spec->stream_name_analog;
3528 if (spec->alt_dac_nid) {
3529 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
3530 *spec->stream_analog_alt_playback;
3531 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
3534 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
3535 alc_pcm_null_stream;
3536 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
3538 if (spec->num_adc_nids > 1) {
3539 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
3540 *spec->stream_analog_alt_capture;
3541 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid =
3543 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams =
3544 spec->num_adc_nids - 1;
3546 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
3547 alc_pcm_null_stream;
3548 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = 0;
3555 static void alc_free_kctls(struct hda_codec *codec)
3557 struct alc_spec *spec = codec->spec;
3559 if (spec->kctls.list) {
3560 struct snd_kcontrol_new *kctl = spec->kctls.list;
3562 for (i = 0; i < spec->kctls.used; i++)
3563 kfree(kctl[i].name);
3565 snd_array_free(&spec->kctls);
3568 static void alc_free(struct hda_codec *codec)
3570 struct alc_spec *spec = codec->spec;
3575 alc_free_kctls(codec);
3577 snd_hda_detach_beep_device(codec);
3580 #ifdef SND_HDA_NEEDS_RESUME
3581 static int alc_resume(struct hda_codec *codec)
3583 codec->patch_ops.init(codec);
3584 snd_hda_codec_resume_amp(codec);
3585 snd_hda_codec_resume_cache(codec);
3592 static struct hda_codec_ops alc_patch_ops = {
3593 .build_controls = alc_build_controls,
3594 .build_pcms = alc_build_pcms,
3597 .unsol_event = alc_unsol_event,
3598 #ifdef SND_HDA_NEEDS_RESUME
3599 .resume = alc_resume,
3601 #ifdef CONFIG_SND_HDA_POWER_SAVE
3602 .check_power_status = alc_check_power_status,
3608 * Test configuration for debugging
3610 * Almost all inputs/outputs are enabled. I/O pins can be configured via
3613 #ifdef CONFIG_SND_DEBUG
3614 static hda_nid_t alc880_test_dac_nids[4] = {
3615 0x02, 0x03, 0x04, 0x05
3618 static struct hda_input_mux alc880_test_capture_source = {
3627 { "Surround", 0x6 },
3631 static struct hda_channel_mode alc880_test_modes[4] = {
3638 static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol,
3639 struct snd_ctl_elem_info *uinfo)
3641 static char *texts[] = {
3642 "N/A", "Line Out", "HP Out",
3643 "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
3645 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
3647 uinfo->value.enumerated.items = 8;
3648 if (uinfo->value.enumerated.item >= 8)
3649 uinfo->value.enumerated.item = 7;
3650 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
3654 static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol,
3655 struct snd_ctl_elem_value *ucontrol)
3657 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3658 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3659 unsigned int pin_ctl, item = 0;
3661 pin_ctl = snd_hda_codec_read(codec, nid, 0,
3662 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3663 if (pin_ctl & AC_PINCTL_OUT_EN) {
3664 if (pin_ctl & AC_PINCTL_HP_EN)
3668 } else if (pin_ctl & AC_PINCTL_IN_EN) {
3669 switch (pin_ctl & AC_PINCTL_VREFEN) {
3670 case AC_PINCTL_VREF_HIZ: item = 3; break;
3671 case AC_PINCTL_VREF_50: item = 4; break;
3672 case AC_PINCTL_VREF_GRD: item = 5; break;
3673 case AC_PINCTL_VREF_80: item = 6; break;
3674 case AC_PINCTL_VREF_100: item = 7; break;
3677 ucontrol->value.enumerated.item[0] = item;
3681 static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol,
3682 struct snd_ctl_elem_value *ucontrol)
3684 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3685 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3686 static unsigned int ctls[] = {
3687 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
3688 AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
3689 AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
3690 AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
3691 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
3692 AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
3694 unsigned int old_ctl, new_ctl;
3696 old_ctl = snd_hda_codec_read(codec, nid, 0,
3697 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3698 new_ctl = ctls[ucontrol->value.enumerated.item[0]];
3699 if (old_ctl != new_ctl) {
3701 snd_hda_codec_write_cache(codec, nid, 0,
3702 AC_VERB_SET_PIN_WIDGET_CONTROL,
3704 val = ucontrol->value.enumerated.item[0] >= 3 ?
3706 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
3713 static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol,
3714 struct snd_ctl_elem_info *uinfo)
3716 static char *texts[] = {
3717 "Front", "Surround", "CLFE", "Side"
3719 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
3721 uinfo->value.enumerated.items = 4;
3722 if (uinfo->value.enumerated.item >= 4)
3723 uinfo->value.enumerated.item = 3;
3724 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
3728 static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol,
3729 struct snd_ctl_elem_value *ucontrol)
3731 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3732 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3735 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
3736 ucontrol->value.enumerated.item[0] = sel & 3;
3740 static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol,
3741 struct snd_ctl_elem_value *ucontrol)
3743 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3744 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3747 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
3748 if (ucontrol->value.enumerated.item[0] != sel) {
3749 sel = ucontrol->value.enumerated.item[0] & 3;
3750 snd_hda_codec_write_cache(codec, nid, 0,
3751 AC_VERB_SET_CONNECT_SEL, sel);
3757 #define PIN_CTL_TEST(xname,nid) { \
3758 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
3760 .info = alc_test_pin_ctl_info, \
3761 .get = alc_test_pin_ctl_get, \
3762 .put = alc_test_pin_ctl_put, \
3763 .private_value = nid \
3766 #define PIN_SRC_TEST(xname,nid) { \
3767 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
3769 .info = alc_test_pin_src_info, \
3770 .get = alc_test_pin_src_get, \
3771 .put = alc_test_pin_src_put, \
3772 .private_value = nid \
3775 static struct snd_kcontrol_new alc880_test_mixer[] = {
3776 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3777 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
3778 HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
3779 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
3780 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
3781 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
3782 HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
3783 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
3784 PIN_CTL_TEST("Front Pin Mode", 0x14),
3785 PIN_CTL_TEST("Surround Pin Mode", 0x15),
3786 PIN_CTL_TEST("CLFE Pin Mode", 0x16),
3787 PIN_CTL_TEST("Side Pin Mode", 0x17),
3788 PIN_CTL_TEST("In-1 Pin Mode", 0x18),
3789 PIN_CTL_TEST("In-2 Pin Mode", 0x19),
3790 PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
3791 PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
3792 PIN_SRC_TEST("In-1 Pin Source", 0x18),
3793 PIN_SRC_TEST("In-2 Pin Source", 0x19),
3794 PIN_SRC_TEST("In-3 Pin Source", 0x1a),
3795 PIN_SRC_TEST("In-4 Pin Source", 0x1b),
3796 HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
3797 HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
3798 HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
3799 HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
3800 HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
3801 HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
3802 HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
3803 HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
3804 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
3805 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
3807 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3808 .name = "Channel Mode",
3809 .info = alc_ch_mode_info,
3810 .get = alc_ch_mode_get,
3811 .put = alc_ch_mode_put,
3816 static struct hda_verb alc880_test_init_verbs[] = {
3817 /* Unmute inputs of 0x0c - 0x0f */
3818 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3819 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3820 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3821 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3822 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3823 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3824 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3825 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3826 /* Vol output for 0x0c-0x0f */