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,
222 ALC883_TARGA_2ch_DIG,
223 ALC883_TARGA_8ch_DIG,
226 ALC888_ACER_ASPIRE_4930G,
227 ALC888_ACER_ASPIRE_6530G,
228 ALC888_ACER_ASPIRE_8930G,
232 ALC883_LENOVO_101E_2ch,
233 ALC883_LENOVO_NB0763,
234 ALC888_LENOVO_MS7195_DIG,
241 ALC883_FUJITSU_PI2515,
242 ALC888_FUJITSU_XA3530,
243 ALC883_3ST_6ch_INTEL,
254 #define GPIO_MASK 0x03
256 /* extra amp-initialization sequence types */
266 /* codec parameterization */
267 struct snd_kcontrol_new *mixers[5]; /* mixer arrays */
268 unsigned int num_mixers;
269 struct snd_kcontrol_new *cap_mixer; /* capture mixer */
270 unsigned int beep_amp; /* beep amp value, set via set_beep_amp() */
272 const struct hda_verb *init_verbs[5]; /* initialization verbs
276 unsigned int num_init_verbs;
278 char stream_name_analog[16]; /* analog PCM stream */
279 struct hda_pcm_stream *stream_analog_playback;
280 struct hda_pcm_stream *stream_analog_capture;
281 struct hda_pcm_stream *stream_analog_alt_playback;
282 struct hda_pcm_stream *stream_analog_alt_capture;
284 char stream_name_digital[16]; /* digital PCM stream */
285 struct hda_pcm_stream *stream_digital_playback;
286 struct hda_pcm_stream *stream_digital_capture;
289 struct hda_multi_out multiout; /* playback set-up
290 * max_channels, dacs must be set
291 * dig_out_nid and hp_nid are optional
293 hda_nid_t alt_dac_nid;
294 hda_nid_t slave_dig_outs[3]; /* optional - for auto-parsing */
298 unsigned int num_adc_nids;
300 hda_nid_t *capsrc_nids;
301 hda_nid_t dig_in_nid; /* digital-in NID; optional */
304 unsigned int num_mux_defs;
305 const struct hda_input_mux *input_mux;
306 unsigned int cur_mux[3];
309 const struct hda_channel_mode *channel_mode;
310 int num_channel_mode;
312 int const_channel_count;
313 int ext_channel_count;
315 /* PCM information */
316 struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */
318 /* dynamic controls, init_verbs and input_mux */
319 struct auto_pin_cfg autocfg;
320 struct snd_array kctls;
321 struct hda_input_mux private_imux[3];
322 hda_nid_t private_dac_nids[AUTO_CFG_MAX_OUTS];
325 void (*init_hook)(struct hda_codec *codec);
326 void (*unsol_event)(struct hda_codec *codec, unsigned int res);
328 /* for pin sensing */
329 unsigned int sense_updated: 1;
330 unsigned int jack_present: 1;
331 unsigned int master_sw: 1;
334 unsigned int no_analog :1; /* digital I/O only */
337 /* for virtual master */
338 hda_nid_t vmaster_nid;
339 #ifdef CONFIG_SND_HDA_POWER_SAVE
340 struct hda_loopback_check loopback;
345 unsigned int pll_coef_idx, pll_coef_bit;
349 * configuration template - to be copied to the spec instance
351 struct alc_config_preset {
352 struct snd_kcontrol_new *mixers[5]; /* should be identical size
355 struct snd_kcontrol_new *cap_mixer; /* capture mixer */
356 const struct hda_verb *init_verbs[5];
357 unsigned int num_dacs;
359 hda_nid_t dig_out_nid; /* optional */
360 hda_nid_t hp_nid; /* optional */
361 hda_nid_t *slave_dig_outs;
362 unsigned int num_adc_nids;
364 hda_nid_t *capsrc_nids;
365 hda_nid_t dig_in_nid;
366 unsigned int num_channel_mode;
367 const struct hda_channel_mode *channel_mode;
369 int const_channel_count;
370 unsigned int num_mux_defs;
371 const struct hda_input_mux *input_mux;
372 void (*unsol_event)(struct hda_codec *, unsigned int);
373 void (*init_hook)(struct hda_codec *);
374 #ifdef CONFIG_SND_HDA_POWER_SAVE
375 struct hda_amp_list *loopbacks;
383 static int alc_mux_enum_info(struct snd_kcontrol *kcontrol,
384 struct snd_ctl_elem_info *uinfo)
386 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
387 struct alc_spec *spec = codec->spec;
388 unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id);
389 if (mux_idx >= spec->num_mux_defs)
391 return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo);
394 static int alc_mux_enum_get(struct snd_kcontrol *kcontrol,
395 struct snd_ctl_elem_value *ucontrol)
397 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
398 struct alc_spec *spec = codec->spec;
399 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
401 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
405 static int alc_mux_enum_put(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 const struct hda_input_mux *imux;
411 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
412 unsigned int mux_idx;
413 hda_nid_t nid = spec->capsrc_nids ?
414 spec->capsrc_nids[adc_idx] : spec->adc_nids[adc_idx];
417 mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx;
418 imux = &spec->input_mux[mux_idx];
420 type = (get_wcaps(codec, nid) & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
421 if (type == AC_WID_AUD_MIX) {
422 /* Matrix-mixer style (e.g. ALC882) */
423 unsigned int *cur_val = &spec->cur_mux[adc_idx];
426 idx = ucontrol->value.enumerated.item[0];
427 if (idx >= imux->num_items)
428 idx = imux->num_items - 1;
431 for (i = 0; i < imux->num_items; i++) {
432 unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
433 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
434 imux->items[i].index,
440 /* MUX style (e.g. ALC880) */
441 return snd_hda_input_mux_put(codec, imux, ucontrol, nid,
442 &spec->cur_mux[adc_idx]);
447 * channel mode setting
449 static int alc_ch_mode_info(struct snd_kcontrol *kcontrol,
450 struct snd_ctl_elem_info *uinfo)
452 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
453 struct alc_spec *spec = codec->spec;
454 return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
455 spec->num_channel_mode);
458 static int alc_ch_mode_get(struct snd_kcontrol *kcontrol,
459 struct snd_ctl_elem_value *ucontrol)
461 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
462 struct alc_spec *spec = codec->spec;
463 return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
464 spec->num_channel_mode,
465 spec->ext_channel_count);
468 static int alc_ch_mode_put(struct snd_kcontrol *kcontrol,
469 struct snd_ctl_elem_value *ucontrol)
471 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
472 struct alc_spec *spec = codec->spec;
473 int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
474 spec->num_channel_mode,
475 &spec->ext_channel_count);
476 if (err >= 0 && !spec->const_channel_count) {
477 spec->multiout.max_channels = spec->ext_channel_count;
478 if (spec->need_dac_fix)
479 spec->multiout.num_dacs = spec->multiout.max_channels / 2;
485 * Control the mode of pin widget settings via the mixer. "pc" is used
486 * instead of "%" to avoid consequences of accidently treating the % as
487 * being part of a format specifier. Maximum allowed length of a value is
488 * 63 characters plus NULL terminator.
490 * Note: some retasking pin complexes seem to ignore requests for input
491 * states other than HiZ (eg: PIN_VREFxx) and revert to HiZ if any of these
492 * are requested. Therefore order this list so that this behaviour will not
493 * cause problems when mixer clients move through the enum sequentially.
494 * NIDs 0x0f and 0x10 have been observed to have this behaviour as of
497 static char *alc_pin_mode_names[] = {
498 "Mic 50pc bias", "Mic 80pc bias",
499 "Line in", "Line out", "Headphone out",
501 static unsigned char alc_pin_mode_values[] = {
502 PIN_VREF50, PIN_VREF80, PIN_IN, PIN_OUT, PIN_HP,
504 /* The control can present all 5 options, or it can limit the options based
505 * in the pin being assumed to be exclusively an input or an output pin. In
506 * addition, "input" pins may or may not process the mic bias option
507 * depending on actual widget capability (NIDs 0x0f and 0x10 don't seem to
508 * accept requests for bias as of chip versions up to March 2006) and/or
509 * wiring in the computer.
511 #define ALC_PIN_DIR_IN 0x00
512 #define ALC_PIN_DIR_OUT 0x01
513 #define ALC_PIN_DIR_INOUT 0x02
514 #define ALC_PIN_DIR_IN_NOMICBIAS 0x03
515 #define ALC_PIN_DIR_INOUT_NOMICBIAS 0x04
517 /* Info about the pin modes supported by the different pin direction modes.
518 * For each direction the minimum and maximum values are given.
520 static signed char alc_pin_mode_dir_info[5][2] = {
521 { 0, 2 }, /* ALC_PIN_DIR_IN */
522 { 3, 4 }, /* ALC_PIN_DIR_OUT */
523 { 0, 4 }, /* ALC_PIN_DIR_INOUT */
524 { 2, 2 }, /* ALC_PIN_DIR_IN_NOMICBIAS */
525 { 2, 4 }, /* ALC_PIN_DIR_INOUT_NOMICBIAS */
527 #define alc_pin_mode_min(_dir) (alc_pin_mode_dir_info[_dir][0])
528 #define alc_pin_mode_max(_dir) (alc_pin_mode_dir_info[_dir][1])
529 #define alc_pin_mode_n_items(_dir) \
530 (alc_pin_mode_max(_dir)-alc_pin_mode_min(_dir)+1)
532 static int alc_pin_mode_info(struct snd_kcontrol *kcontrol,
533 struct snd_ctl_elem_info *uinfo)
535 unsigned int item_num = uinfo->value.enumerated.item;
536 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
538 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
540 uinfo->value.enumerated.items = alc_pin_mode_n_items(dir);
542 if (item_num<alc_pin_mode_min(dir) || item_num>alc_pin_mode_max(dir))
543 item_num = alc_pin_mode_min(dir);
544 strcpy(uinfo->value.enumerated.name, alc_pin_mode_names[item_num]);
548 static int alc_pin_mode_get(struct snd_kcontrol *kcontrol,
549 struct snd_ctl_elem_value *ucontrol)
552 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
553 hda_nid_t nid = kcontrol->private_value & 0xffff;
554 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
555 long *valp = ucontrol->value.integer.value;
556 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
557 AC_VERB_GET_PIN_WIDGET_CONTROL,
560 /* Find enumerated value for current pinctl setting */
561 i = alc_pin_mode_min(dir);
562 while (alc_pin_mode_values[i] != pinctl && i <= alc_pin_mode_max(dir))
564 *valp = i <= alc_pin_mode_max(dir) ? i: alc_pin_mode_min(dir);
568 static int alc_pin_mode_put(struct snd_kcontrol *kcontrol,
569 struct snd_ctl_elem_value *ucontrol)
572 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
573 hda_nid_t nid = kcontrol->private_value & 0xffff;
574 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
575 long val = *ucontrol->value.integer.value;
576 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
577 AC_VERB_GET_PIN_WIDGET_CONTROL,
580 if (val < alc_pin_mode_min(dir) || val > alc_pin_mode_max(dir))
581 val = alc_pin_mode_min(dir);
583 change = pinctl != alc_pin_mode_values[val];
585 /* Set pin mode to that requested */
586 snd_hda_codec_write_cache(codec, nid, 0,
587 AC_VERB_SET_PIN_WIDGET_CONTROL,
588 alc_pin_mode_values[val]);
590 /* Also enable the retasking pin's input/output as required
591 * for the requested pin mode. Enum values of 2 or less are
594 * Dynamically switching the input/output buffers probably
595 * reduces noise slightly (particularly on input) so we'll
596 * do it. However, having both input and output buffers
597 * enabled simultaneously doesn't seem to be problematic if
598 * this turns out to be necessary in the future.
601 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
602 HDA_AMP_MUTE, HDA_AMP_MUTE);
603 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
606 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
607 HDA_AMP_MUTE, HDA_AMP_MUTE);
608 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
615 #define ALC_PIN_MODE(xname, nid, dir) \
616 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
617 .info = alc_pin_mode_info, \
618 .get = alc_pin_mode_get, \
619 .put = alc_pin_mode_put, \
620 .private_value = nid | (dir<<16) }
622 /* A switch control for ALC260 GPIO pins. Multiple GPIOs can be ganged
623 * together using a mask with more than one bit set. This control is
624 * currently used only by the ALC260 test model. At this stage they are not
625 * needed for any "production" models.
627 #ifdef CONFIG_SND_DEBUG
628 #define alc_gpio_data_info snd_ctl_boolean_mono_info
630 static int alc_gpio_data_get(struct snd_kcontrol *kcontrol,
631 struct snd_ctl_elem_value *ucontrol)
633 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
634 hda_nid_t nid = kcontrol->private_value & 0xffff;
635 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
636 long *valp = ucontrol->value.integer.value;
637 unsigned int val = snd_hda_codec_read(codec, nid, 0,
638 AC_VERB_GET_GPIO_DATA, 0x00);
640 *valp = (val & mask) != 0;
643 static int alc_gpio_data_put(struct snd_kcontrol *kcontrol,
644 struct snd_ctl_elem_value *ucontrol)
647 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
648 hda_nid_t nid = kcontrol->private_value & 0xffff;
649 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
650 long val = *ucontrol->value.integer.value;
651 unsigned int gpio_data = snd_hda_codec_read(codec, nid, 0,
652 AC_VERB_GET_GPIO_DATA,
655 /* Set/unset the masked GPIO bit(s) as needed */
656 change = (val == 0 ? 0 : mask) != (gpio_data & mask);
661 snd_hda_codec_write_cache(codec, nid, 0,
662 AC_VERB_SET_GPIO_DATA, gpio_data);
666 #define ALC_GPIO_DATA_SWITCH(xname, nid, mask) \
667 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
668 .info = alc_gpio_data_info, \
669 .get = alc_gpio_data_get, \
670 .put = alc_gpio_data_put, \
671 .private_value = nid | (mask<<16) }
672 #endif /* CONFIG_SND_DEBUG */
674 /* A switch control to allow the enabling of the digital IO pins on the
675 * ALC260. This is incredibly simplistic; the intention of this control is
676 * to provide something in the test model allowing digital outputs to be
677 * identified if present. If models are found which can utilise these
678 * outputs a more complete mixer control can be devised for those models if
681 #ifdef CONFIG_SND_DEBUG
682 #define alc_spdif_ctrl_info snd_ctl_boolean_mono_info
684 static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol,
685 struct snd_ctl_elem_value *ucontrol)
687 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
688 hda_nid_t nid = kcontrol->private_value & 0xffff;
689 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
690 long *valp = ucontrol->value.integer.value;
691 unsigned int val = snd_hda_codec_read(codec, nid, 0,
692 AC_VERB_GET_DIGI_CONVERT_1, 0x00);
694 *valp = (val & mask) != 0;
697 static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol,
698 struct snd_ctl_elem_value *ucontrol)
701 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
702 hda_nid_t nid = kcontrol->private_value & 0xffff;
703 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
704 long val = *ucontrol->value.integer.value;
705 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
706 AC_VERB_GET_DIGI_CONVERT_1,
709 /* Set/unset the masked control bit(s) as needed */
710 change = (val == 0 ? 0 : mask) != (ctrl_data & mask);
715 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1,
720 #define ALC_SPDIF_CTRL_SWITCH(xname, nid, mask) \
721 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
722 .info = alc_spdif_ctrl_info, \
723 .get = alc_spdif_ctrl_get, \
724 .put = alc_spdif_ctrl_put, \
725 .private_value = nid | (mask<<16) }
726 #endif /* CONFIG_SND_DEBUG */
728 /* A switch control to allow the enabling EAPD digital outputs on the ALC26x.
729 * Again, this is only used in the ALC26x test models to help identify when
730 * the EAPD line must be asserted for features to work.
732 #ifdef CONFIG_SND_DEBUG
733 #define alc_eapd_ctrl_info snd_ctl_boolean_mono_info
735 static int alc_eapd_ctrl_get(struct snd_kcontrol *kcontrol,
736 struct snd_ctl_elem_value *ucontrol)
738 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
739 hda_nid_t nid = kcontrol->private_value & 0xffff;
740 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
741 long *valp = ucontrol->value.integer.value;
742 unsigned int val = snd_hda_codec_read(codec, nid, 0,
743 AC_VERB_GET_EAPD_BTLENABLE, 0x00);
745 *valp = (val & mask) != 0;
749 static int alc_eapd_ctrl_put(struct snd_kcontrol *kcontrol,
750 struct snd_ctl_elem_value *ucontrol)
753 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
754 hda_nid_t nid = kcontrol->private_value & 0xffff;
755 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
756 long val = *ucontrol->value.integer.value;
757 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
758 AC_VERB_GET_EAPD_BTLENABLE,
761 /* Set/unset the masked control bit(s) as needed */
762 change = (!val ? 0 : mask) != (ctrl_data & mask);
767 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
773 #define ALC_EAPD_CTRL_SWITCH(xname, nid, mask) \
774 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
775 .info = alc_eapd_ctrl_info, \
776 .get = alc_eapd_ctrl_get, \
777 .put = alc_eapd_ctrl_put, \
778 .private_value = nid | (mask<<16) }
779 #endif /* CONFIG_SND_DEBUG */
782 * set up the input pin config (depending on the given auto-pin type)
784 static void alc_set_input_pin(struct hda_codec *codec, hda_nid_t nid,
787 unsigned int val = PIN_IN;
789 if (auto_pin_type <= AUTO_PIN_FRONT_MIC) {
791 pincap = snd_hda_query_pin_caps(codec, nid);
792 pincap = (pincap & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT;
793 if (pincap & AC_PINCAP_VREF_80)
795 else if (pincap & AC_PINCAP_VREF_50)
797 else if (pincap & AC_PINCAP_VREF_100)
799 else if (pincap & AC_PINCAP_VREF_GRD)
802 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, val);
807 static void add_mixer(struct alc_spec *spec, struct snd_kcontrol_new *mix)
809 if (snd_BUG_ON(spec->num_mixers >= ARRAY_SIZE(spec->mixers)))
811 spec->mixers[spec->num_mixers++] = mix;
814 static void add_verb(struct alc_spec *spec, const struct hda_verb *verb)
816 if (snd_BUG_ON(spec->num_init_verbs >= ARRAY_SIZE(spec->init_verbs)))
818 spec->init_verbs[spec->num_init_verbs++] = verb;
821 #ifdef CONFIG_PROC_FS
825 static void print_realtek_coef(struct snd_info_buffer *buffer,
826 struct hda_codec *codec, hda_nid_t nid)
832 coeff = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_PROC_COEF, 0);
833 snd_iprintf(buffer, " Processing Coefficient: 0x%02x\n", coeff);
834 coeff = snd_hda_codec_read(codec, nid, 0,
835 AC_VERB_GET_COEF_INDEX, 0);
836 snd_iprintf(buffer, " Coefficient Index: 0x%02x\n", coeff);
839 #define print_realtek_coef NULL
843 * set up from the preset table
845 static void setup_preset(struct alc_spec *spec,
846 const struct alc_config_preset *preset)
850 for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++)
851 add_mixer(spec, preset->mixers[i]);
852 spec->cap_mixer = preset->cap_mixer;
853 for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i];
855 add_verb(spec, preset->init_verbs[i]);
857 spec->channel_mode = preset->channel_mode;
858 spec->num_channel_mode = preset->num_channel_mode;
859 spec->need_dac_fix = preset->need_dac_fix;
860 spec->const_channel_count = preset->const_channel_count;
862 if (preset->const_channel_count)
863 spec->multiout.max_channels = preset->const_channel_count;
865 spec->multiout.max_channels = spec->channel_mode[0].channels;
866 spec->ext_channel_count = spec->channel_mode[0].channels;
868 spec->multiout.num_dacs = preset->num_dacs;
869 spec->multiout.dac_nids = preset->dac_nids;
870 spec->multiout.dig_out_nid = preset->dig_out_nid;
871 spec->multiout.slave_dig_outs = preset->slave_dig_outs;
872 spec->multiout.hp_nid = preset->hp_nid;
874 spec->num_mux_defs = preset->num_mux_defs;
875 if (!spec->num_mux_defs)
876 spec->num_mux_defs = 1;
877 spec->input_mux = preset->input_mux;
879 spec->num_adc_nids = preset->num_adc_nids;
880 spec->adc_nids = preset->adc_nids;
881 spec->capsrc_nids = preset->capsrc_nids;
882 spec->dig_in_nid = preset->dig_in_nid;
884 spec->unsol_event = preset->unsol_event;
885 spec->init_hook = preset->init_hook;
886 #ifdef CONFIG_SND_HDA_POWER_SAVE
887 spec->loopback.amplist = preset->loopbacks;
891 /* Enable GPIO mask and set output */
892 static struct hda_verb alc_gpio1_init_verbs[] = {
893 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
894 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
895 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
899 static struct hda_verb alc_gpio2_init_verbs[] = {
900 {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
901 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
902 {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
906 static struct hda_verb alc_gpio3_init_verbs[] = {
907 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
908 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
909 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
914 * Fix hardware PLL issue
915 * On some codecs, the analog PLL gating control must be off while
916 * the default value is 1.
918 static void alc_fix_pll(struct hda_codec *codec)
920 struct alc_spec *spec = codec->spec;
925 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX,
927 val = snd_hda_codec_read(codec, spec->pll_nid, 0,
928 AC_VERB_GET_PROC_COEF, 0);
929 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX,
931 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_PROC_COEF,
932 val & ~(1 << spec->pll_coef_bit));
935 static void alc_fix_pll_init(struct hda_codec *codec, hda_nid_t nid,
936 unsigned int coef_idx, unsigned int coef_bit)
938 struct alc_spec *spec = codec->spec;
940 spec->pll_coef_idx = coef_idx;
941 spec->pll_coef_bit = coef_bit;
945 static void alc_automute_pin(struct hda_codec *codec)
947 struct alc_spec *spec = codec->spec;
948 unsigned int present;
949 unsigned int nid = spec->autocfg.hp_pins[0];
952 /* need to execute and sync at first */
953 snd_hda_codec_read(codec, nid, 0, AC_VERB_SET_PIN_SENSE, 0);
954 present = snd_hda_codec_read(codec, nid, 0,
955 AC_VERB_GET_PIN_SENSE, 0);
956 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
957 for (i = 0; i < ARRAY_SIZE(spec->autocfg.speaker_pins); i++) {
958 nid = spec->autocfg.speaker_pins[i];
961 snd_hda_codec_write(codec, nid, 0,
962 AC_VERB_SET_PIN_WIDGET_CONTROL,
963 spec->jack_present ? 0 : PIN_OUT);
967 #if 0 /* it's broken in some cases -- temporarily disabled */
968 static void alc_mic_automute(struct hda_codec *codec)
970 struct alc_spec *spec = codec->spec;
971 unsigned int present;
972 unsigned int mic_nid = spec->autocfg.input_pins[AUTO_PIN_MIC];
973 unsigned int fmic_nid = spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC];
974 unsigned int mix_nid = spec->capsrc_nids[0];
975 unsigned int capsrc_idx_mic, capsrc_idx_fmic;
977 capsrc_idx_mic = mic_nid - 0x18;
978 capsrc_idx_fmic = fmic_nid - 0x18;
979 present = snd_hda_codec_read(codec, mic_nid, 0,
980 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
981 snd_hda_codec_write(codec, mix_nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
982 0x7000 | (capsrc_idx_mic << 8) | (present ? 0 : 0x80));
983 snd_hda_codec_write(codec, mix_nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
984 0x7000 | (capsrc_idx_fmic << 8) | (present ? 0x80 : 0));
985 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, capsrc_idx_fmic,
986 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
989 #define alc_mic_automute(codec) do {} while(0) /* NOP */
990 #endif /* disabled */
992 /* unsolicited event for HP jack sensing */
993 static void alc_sku_unsol_event(struct hda_codec *codec, unsigned int res)
995 if (codec->vendor_id == 0x10ec0880)
1000 case ALC880_HP_EVENT:
1001 alc_automute_pin(codec);
1003 case ALC880_MIC_EVENT:
1004 alc_mic_automute(codec);
1009 static void alc_inithook(struct hda_codec *codec)
1011 alc_automute_pin(codec);
1012 alc_mic_automute(codec);
1015 /* additional initialization for ALC888 variants */
1016 static void alc888_coef_init(struct hda_codec *codec)
1020 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 0);
1021 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
1022 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
1023 if ((tmp & 0xf0) == 0x20)
1025 snd_hda_codec_read(codec, 0x20, 0,
1026 AC_VERB_SET_PROC_COEF, 0x830);
1029 snd_hda_codec_read(codec, 0x20, 0,
1030 AC_VERB_SET_PROC_COEF, 0x3030);
1033 static void alc_auto_init_amp(struct hda_codec *codec, int type)
1038 case ALC_INIT_GPIO1:
1039 snd_hda_sequence_write(codec, alc_gpio1_init_verbs);
1041 case ALC_INIT_GPIO2:
1042 snd_hda_sequence_write(codec, alc_gpio2_init_verbs);
1044 case ALC_INIT_GPIO3:
1045 snd_hda_sequence_write(codec, alc_gpio3_init_verbs);
1047 case ALC_INIT_DEFAULT:
1048 switch (codec->vendor_id) {
1050 snd_hda_codec_write(codec, 0x0f, 0,
1051 AC_VERB_SET_EAPD_BTLENABLE, 2);
1052 snd_hda_codec_write(codec, 0x10, 0,
1053 AC_VERB_SET_EAPD_BTLENABLE, 2);
1065 snd_hda_codec_write(codec, 0x14, 0,
1066 AC_VERB_SET_EAPD_BTLENABLE, 2);
1067 snd_hda_codec_write(codec, 0x15, 0,
1068 AC_VERB_SET_EAPD_BTLENABLE, 2);
1071 switch (codec->vendor_id) {
1073 snd_hda_codec_write(codec, 0x1a, 0,
1074 AC_VERB_SET_COEF_INDEX, 7);
1075 tmp = snd_hda_codec_read(codec, 0x1a, 0,
1076 AC_VERB_GET_PROC_COEF, 0);
1077 snd_hda_codec_write(codec, 0x1a, 0,
1078 AC_VERB_SET_COEF_INDEX, 7);
1079 snd_hda_codec_write(codec, 0x1a, 0,
1080 AC_VERB_SET_PROC_COEF,
1090 snd_hda_codec_write(codec, 0x20, 0,
1091 AC_VERB_SET_COEF_INDEX, 7);
1092 tmp = snd_hda_codec_read(codec, 0x20, 0,
1093 AC_VERB_GET_PROC_COEF, 0);
1094 snd_hda_codec_write(codec, 0x20, 0,
1095 AC_VERB_SET_COEF_INDEX, 7);
1096 snd_hda_codec_write(codec, 0x20, 0,
1097 AC_VERB_SET_PROC_COEF,
1101 alc888_coef_init(codec);
1105 snd_hda_codec_write(codec, 0x20, 0,
1106 AC_VERB_SET_COEF_INDEX, 7);
1107 tmp = snd_hda_codec_read(codec, 0x20, 0,
1108 AC_VERB_GET_PROC_COEF, 0);
1109 snd_hda_codec_write(codec, 0x20, 0,
1110 AC_VERB_SET_COEF_INDEX, 7);
1111 snd_hda_codec_write(codec, 0x20, 0,
1112 AC_VERB_SET_PROC_COEF,
1120 static void alc_init_auto_hp(struct hda_codec *codec)
1122 struct alc_spec *spec = codec->spec;
1124 if (!spec->autocfg.hp_pins[0])
1127 if (!spec->autocfg.speaker_pins[0]) {
1128 if (spec->autocfg.line_out_pins[0] &&
1129 spec->autocfg.line_out_type == AUTO_PIN_SPEAKER_OUT)
1130 spec->autocfg.speaker_pins[0] =
1131 spec->autocfg.line_out_pins[0];
1136 snd_printdd("realtek: Enable HP auto-muting on NID 0x%x\n",
1137 spec->autocfg.hp_pins[0]);
1138 snd_hda_codec_write_cache(codec, spec->autocfg.hp_pins[0], 0,
1139 AC_VERB_SET_UNSOLICITED_ENABLE,
1140 AC_USRSP_EN | ALC880_HP_EVENT);
1141 spec->unsol_event = alc_sku_unsol_event;
1144 /* check subsystem ID and set up device-specific initialization;
1145 * return 1 if initialized, 0 if invalid SSID
1147 /* 32-bit subsystem ID for BIOS loading in HD Audio codec.
1148 * 31 ~ 16 : Manufacture ID
1150 * 7 ~ 0 : Assembly ID
1151 * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36
1153 static int alc_subsystem_id(struct hda_codec *codec,
1154 hda_nid_t porta, hda_nid_t porte,
1157 unsigned int ass, tmp, i;
1159 struct alc_spec *spec = codec->spec;
1161 ass = codec->subsystem_id & 0xffff;
1162 if ((ass != codec->bus->pci->subsystem_device) && (ass & 1))
1165 /* invalid SSID, check the special NID pin defcfg instead */
1167 * 31~30 : port connectivity
1170 * 19~16 : Check sum (15:1)
1175 if (codec->vendor_id == 0x10ec0260)
1177 ass = snd_hda_codec_get_pincfg(codec, nid);
1178 snd_printd("realtek: No valid SSID, "
1179 "checking pincfg 0x%08x for NID 0x%x\n",
1181 if (!(ass & 1) && !(ass & 0x100000))
1183 if ((ass >> 30) != 1) /* no physical connection */
1188 for (i = 1; i < 16; i++) {
1192 if (((ass >> 16) & 0xf) != tmp)
1195 snd_printd("realtek: Enabling init ASM_ID=0x%04x CODEC_ID=%08x\n",
1196 ass & 0xffff, codec->vendor_id);
1200 * 2 : 0 --> Desktop, 1 --> Laptop
1201 * 3~5 : External Amplifier control
1204 tmp = (ass & 0x38) >> 3; /* external Amp control */
1207 spec->init_amp = ALC_INIT_GPIO1;
1210 spec->init_amp = ALC_INIT_GPIO2;
1213 spec->init_amp = ALC_INIT_GPIO3;
1216 spec->init_amp = ALC_INIT_DEFAULT;
1220 /* is laptop or Desktop and enable the function "Mute internal speaker
1221 * when the external headphone out jack is plugged"
1223 if (!(ass & 0x8000))
1226 * 10~8 : Jack location
1227 * 12~11: Headphone out -> 00: PortA, 01: PortE, 02: PortD, 03: Resvered
1229 * 15 : 1 --> enable the function "Mute internal speaker
1230 * when the external headphone out jack is plugged"
1232 if (!spec->autocfg.hp_pins[0]) {
1233 tmp = (ass >> 11) & 0x3; /* HP to chassis */
1235 spec->autocfg.hp_pins[0] = porta;
1237 spec->autocfg.hp_pins[0] = porte;
1239 spec->autocfg.hp_pins[0] = portd;
1244 alc_init_auto_hp(codec);
1248 static void alc_ssid_check(struct hda_codec *codec,
1249 hda_nid_t porta, hda_nid_t porte, hda_nid_t portd)
1251 if (!alc_subsystem_id(codec, porta, porte, portd)) {
1252 struct alc_spec *spec = codec->spec;
1253 snd_printd("realtek: "
1254 "Enable default setup for auto mode as fallback\n");
1255 spec->init_amp = ALC_INIT_DEFAULT;
1256 alc_init_auto_hp(codec);
1261 * Fix-up pin default configurations
1269 static void alc_fix_pincfg(struct hda_codec *codec,
1270 const struct snd_pci_quirk *quirk,
1271 const struct alc_pincfg **pinfix)
1273 const struct alc_pincfg *cfg;
1275 quirk = snd_pci_quirk_lookup(codec->bus->pci, quirk);
1279 cfg = pinfix[quirk->value];
1280 for (; cfg->nid; cfg++)
1281 snd_hda_codec_set_pincfg(codec, cfg->nid, cfg->val);
1291 static struct hda_verb alc888_4ST_ch2_intel_init[] = {
1292 /* Mic-in jack as mic in */
1293 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1294 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1295 /* Line-in jack as Line in */
1296 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1297 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1298 /* Line-Out as Front */
1299 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
1306 static struct hda_verb alc888_4ST_ch4_intel_init[] = {
1307 /* Mic-in jack as mic in */
1308 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1309 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1310 /* Line-in jack as Surround */
1311 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1312 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1313 /* Line-Out as Front */
1314 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
1321 static struct hda_verb alc888_4ST_ch6_intel_init[] = {
1322 /* Mic-in jack as CLFE */
1323 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1324 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1325 /* Line-in jack as Surround */
1326 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1327 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1328 /* Line-Out as CLFE (workaround because Mic-in is not loud enough) */
1329 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1336 static struct hda_verb alc888_4ST_ch8_intel_init[] = {
1337 /* Mic-in jack as CLFE */
1338 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1339 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1340 /* Line-in jack as Surround */
1341 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1342 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1343 /* Line-Out as Side */
1344 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1348 static struct hda_channel_mode alc888_4ST_8ch_intel_modes[4] = {
1349 { 2, alc888_4ST_ch2_intel_init },
1350 { 4, alc888_4ST_ch4_intel_init },
1351 { 6, alc888_4ST_ch6_intel_init },
1352 { 8, alc888_4ST_ch8_intel_init },
1356 * ALC888 Fujitsu Siemens Amillo xa3530
1359 static struct hda_verb alc888_fujitsu_xa3530_verbs[] = {
1360 /* Front Mic: set to PIN_IN (empty by default) */
1361 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1362 /* Connect Internal HP to Front */
1363 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1364 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1365 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1366 /* Connect Bass HP to Front */
1367 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1368 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1369 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1370 /* Connect Line-Out side jack (SPDIF) to Side */
1371 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1372 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1373 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1374 /* Connect Mic jack to CLFE */
1375 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1376 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1377 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02},
1378 /* Connect Line-in jack to Surround */
1379 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1380 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1381 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
1382 /* Connect HP out jack to Front */
1383 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1384 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1385 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
1386 /* Enable unsolicited event for HP jack and Line-out jack */
1387 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1388 {0x17, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1392 static void alc_automute_amp(struct hda_codec *codec)
1394 struct alc_spec *spec = codec->spec;
1395 unsigned int val, mute;
1399 spec->jack_present = 0;
1400 for (i = 0; i < ARRAY_SIZE(spec->autocfg.hp_pins); i++) {
1401 nid = spec->autocfg.hp_pins[i];
1404 val = snd_hda_codec_read(codec, nid, 0,
1405 AC_VERB_GET_PIN_SENSE, 0);
1406 if (val & AC_PINSENSE_PRESENCE) {
1407 spec->jack_present = 1;
1412 mute = spec->jack_present ? HDA_AMP_MUTE : 0;
1413 /* Toggle internal speakers muting */
1414 for (i = 0; i < ARRAY_SIZE(spec->autocfg.speaker_pins); i++) {
1415 nid = spec->autocfg.speaker_pins[i];
1418 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
1419 HDA_AMP_MUTE, mute);
1423 static void alc_automute_amp_unsol_event(struct hda_codec *codec,
1426 if (codec->vendor_id == 0x10ec0880)
1430 if (res == ALC880_HP_EVENT)
1431 alc_automute_amp(codec);
1434 static void alc888_fujitsu_xa3530_init_hook(struct hda_codec *codec)
1436 struct alc_spec *spec = codec->spec;
1438 spec->autocfg.hp_pins[0] = 0x17; /* line-out */
1439 spec->autocfg.hp_pins[1] = 0x1b; /* hp */
1440 spec->autocfg.speaker_pins[0] = 0x14; /* speaker */
1441 spec->autocfg.speaker_pins[1] = 0x15; /* bass */
1442 alc_automute_amp(codec);
1446 * ALC888 Acer Aspire 4930G model
1449 static struct hda_verb alc888_acer_aspire_4930g_verbs[] = {
1450 /* Front Mic: set to PIN_IN (empty by default) */
1451 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1452 /* Unselect Front Mic by default in input mixer 3 */
1453 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
1454 /* Enable unsolicited event for HP jack */
1455 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1456 /* Connect Internal HP to front */
1457 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1458 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1459 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1460 /* Connect HP out to front */
1461 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1462 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1463 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1468 * ALC888 Acer Aspire 6530G model
1471 static struct hda_verb alc888_acer_aspire_6530g_verbs[] = {
1472 /* Bias voltage on for external mic port */
1473 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN | PIN_VREF80},
1474 /* Enable unsolicited event for HP jack */
1475 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1476 /* Enable speaker output */
1477 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1478 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1479 /* Enable headphone output */
1480 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | PIN_HP},
1481 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1482 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1487 * ALC889 Acer Aspire 8930G model
1490 static struct hda_verb alc889_acer_aspire_8930g_verbs[] = {
1491 /* Front Mic: set to PIN_IN (empty by default) */
1492 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1493 /* Unselect Front Mic by default in input mixer 3 */
1494 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
1495 /* Enable unsolicited event for HP jack */
1496 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1497 /* Connect Internal Front to Front */
1498 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1499 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1500 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1501 /* Connect Internal Rear to Rear */
1502 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1503 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1504 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01},
1505 /* Connect Internal CLFE to CLFE */
1506 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1507 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1508 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
1509 /* Connect HP out to Front */
1510 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | PIN_HP},
1511 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1512 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1513 /* Enable all DACs */
1514 /* DAC DISABLE/MUTE 1? */
1515 /* setting bits 1-5 disables DAC nids 0x02-0x06 apparently. Init=0x38 */
1516 {0x20, AC_VERB_SET_COEF_INDEX, 0x03},
1517 {0x20, AC_VERB_SET_PROC_COEF, 0x0000},
1518 /* DAC DISABLE/MUTE 2? */
1519 /* some bit here disables the other DACs. Init=0x4900 */
1520 {0x20, AC_VERB_SET_COEF_INDEX, 0x08},
1521 {0x20, AC_VERB_SET_PROC_COEF, 0x0000},
1522 /* Enable amplifiers */
1523 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
1524 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
1526 * This laptop has a stereo digital microphone. The mics are only 1cm apart
1527 * which makes the stereo useless. However, either the mic or the ALC889
1528 * makes the signal become a difference/sum signal instead of standard
1529 * stereo, which is annoying. So instead we flip this bit which makes the
1530 * codec replicate the sum signal to both channels, turning it into a
1533 /* DMIC_CONTROL? Init value = 0x0001 */
1534 {0x20, AC_VERB_SET_COEF_INDEX, 0x0b},
1535 {0x20, AC_VERB_SET_PROC_COEF, 0x0003},
1539 static struct hda_input_mux alc888_2_capture_sources[2] = {
1540 /* Front mic only available on one ADC */
1547 { "Front Mic", 0xb },
1560 static struct hda_input_mux alc888_acer_aspire_6530_sources[2] = {
1561 /* Interal mic only available on one ADC */
1579 static struct hda_input_mux alc889_capture_sources[3] = {
1580 /* Digital mic only available on first "ADC" */
1587 { "Front Mic", 0xb },
1588 { "Input Mix", 0xa },
1597 { "Input Mix", 0xa },
1606 { "Input Mix", 0xa },
1611 static struct snd_kcontrol_new alc888_base_mixer[] = {
1612 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1613 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1614 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1615 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
1616 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
1618 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1619 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1620 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1621 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
1622 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
1623 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1624 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1625 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1626 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1627 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1628 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
1629 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1633 static void alc888_acer_aspire_4930g_init_hook(struct hda_codec *codec)
1635 struct alc_spec *spec = codec->spec;
1637 spec->autocfg.hp_pins[0] = 0x15;
1638 spec->autocfg.speaker_pins[0] = 0x14;
1639 alc_automute_amp(codec);
1642 static void alc889_acer_aspire_8930g_init_hook(struct hda_codec *codec)
1644 struct alc_spec *spec = codec->spec;
1646 spec->autocfg.hp_pins[0] = 0x15;
1647 spec->autocfg.speaker_pins[0] = 0x14;
1648 spec->autocfg.speaker_pins[1] = 0x16;
1649 spec->autocfg.speaker_pins[2] = 0x1b;
1650 alc_automute_amp(codec);
1654 * ALC880 3-stack model
1656 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
1657 * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18,
1658 * F-Mic = 0x1b, HP = 0x19
1661 static hda_nid_t alc880_dac_nids[4] = {
1662 /* front, rear, clfe, rear_surr */
1663 0x02, 0x05, 0x04, 0x03
1666 static hda_nid_t alc880_adc_nids[3] = {
1671 /* The datasheet says the node 0x07 is connected from inputs,
1672 * but it shows zero connection in the real implementation on some devices.
1673 * Note: this is a 915GAV bug, fixed on 915GLV
1675 static hda_nid_t alc880_adc_nids_alt[2] = {
1680 #define ALC880_DIGOUT_NID 0x06
1681 #define ALC880_DIGIN_NID 0x0a
1683 static struct hda_input_mux alc880_capture_source = {
1687 { "Front Mic", 0x3 },
1693 /* channel source setting (2/6 channel selection for 3-stack) */
1695 static struct hda_verb alc880_threestack_ch2_init[] = {
1696 /* set line-in to input, mute it */
1697 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1698 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1699 /* set mic-in to input vref 80%, mute it */
1700 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1701 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1706 static struct hda_verb alc880_threestack_ch6_init[] = {
1707 /* set line-in to output, unmute it */
1708 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1709 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1710 /* set mic-in to output, unmute it */
1711 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1712 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1716 static struct hda_channel_mode alc880_threestack_modes[2] = {
1717 { 2, alc880_threestack_ch2_init },
1718 { 6, alc880_threestack_ch6_init },
1721 static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
1722 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1723 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1724 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
1725 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
1726 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1727 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1728 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1729 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1730 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1731 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1732 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1733 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1734 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1735 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1736 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
1737 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
1738 HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
1740 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1741 .name = "Channel Mode",
1742 .info = alc_ch_mode_info,
1743 .get = alc_ch_mode_get,
1744 .put = alc_ch_mode_put,
1749 /* capture mixer elements */
1750 static int alc_cap_vol_info(struct snd_kcontrol *kcontrol,
1751 struct snd_ctl_elem_info *uinfo)
1753 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1754 struct alc_spec *spec = codec->spec;
1757 mutex_lock(&codec->control_mutex);
1758 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0,
1760 err = snd_hda_mixer_amp_volume_info(kcontrol, uinfo);
1761 mutex_unlock(&codec->control_mutex);
1765 static int alc_cap_vol_tlv(struct snd_kcontrol *kcontrol, int op_flag,
1766 unsigned int size, unsigned int __user *tlv)
1768 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1769 struct alc_spec *spec = codec->spec;
1772 mutex_lock(&codec->control_mutex);
1773 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0,
1775 err = snd_hda_mixer_amp_tlv(kcontrol, op_flag, size, tlv);
1776 mutex_unlock(&codec->control_mutex);
1780 typedef int (*getput_call_t)(struct snd_kcontrol *kcontrol,
1781 struct snd_ctl_elem_value *ucontrol);
1783 static int alc_cap_getput_caller(struct snd_kcontrol *kcontrol,
1784 struct snd_ctl_elem_value *ucontrol,
1787 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1788 struct alc_spec *spec = codec->spec;
1789 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
1792 mutex_lock(&codec->control_mutex);
1793 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[adc_idx],
1795 err = func(kcontrol, ucontrol);
1796 mutex_unlock(&codec->control_mutex);
1800 static int alc_cap_vol_get(struct snd_kcontrol *kcontrol,
1801 struct snd_ctl_elem_value *ucontrol)
1803 return alc_cap_getput_caller(kcontrol, ucontrol,
1804 snd_hda_mixer_amp_volume_get);
1807 static int alc_cap_vol_put(struct snd_kcontrol *kcontrol,
1808 struct snd_ctl_elem_value *ucontrol)
1810 return alc_cap_getput_caller(kcontrol, ucontrol,
1811 snd_hda_mixer_amp_volume_put);
1814 /* capture mixer elements */
1815 #define alc_cap_sw_info snd_ctl_boolean_stereo_info
1817 static int alc_cap_sw_get(struct snd_kcontrol *kcontrol,
1818 struct snd_ctl_elem_value *ucontrol)
1820 return alc_cap_getput_caller(kcontrol, ucontrol,
1821 snd_hda_mixer_amp_switch_get);
1824 static int alc_cap_sw_put(struct snd_kcontrol *kcontrol,
1825 struct snd_ctl_elem_value *ucontrol)
1827 return alc_cap_getput_caller(kcontrol, ucontrol,
1828 snd_hda_mixer_amp_switch_put);
1831 #define _DEFINE_CAPMIX(num) \
1833 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1834 .name = "Capture Switch", \
1835 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, \
1837 .info = alc_cap_sw_info, \
1838 .get = alc_cap_sw_get, \
1839 .put = alc_cap_sw_put, \
1842 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1843 .name = "Capture Volume", \
1844 .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE | \
1845 SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
1846 SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK), \
1848 .info = alc_cap_vol_info, \
1849 .get = alc_cap_vol_get, \
1850 .put = alc_cap_vol_put, \
1851 .tlv = { .c = alc_cap_vol_tlv }, \
1854 #define _DEFINE_CAPSRC(num) \
1856 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1857 /* .name = "Capture Source", */ \
1858 .name = "Input Source", \
1860 .info = alc_mux_enum_info, \
1861 .get = alc_mux_enum_get, \
1862 .put = alc_mux_enum_put, \
1865 #define DEFINE_CAPMIX(num) \
1866 static struct snd_kcontrol_new alc_capture_mixer ## num[] = { \
1867 _DEFINE_CAPMIX(num), \
1868 _DEFINE_CAPSRC(num), \
1872 #define DEFINE_CAPMIX_NOSRC(num) \
1873 static struct snd_kcontrol_new alc_capture_mixer_nosrc ## num[] = { \
1874 _DEFINE_CAPMIX(num), \
1878 /* up to three ADCs */
1882 DEFINE_CAPMIX_NOSRC(1);
1883 DEFINE_CAPMIX_NOSRC(2);
1884 DEFINE_CAPMIX_NOSRC(3);
1887 * ALC880 5-stack model
1889 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d),
1891 * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
1892 * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
1895 /* additional mixers to alc880_three_stack_mixer */
1896 static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
1897 HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1898 HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
1902 /* channel source setting (6/8 channel selection for 5-stack) */
1904 static struct hda_verb alc880_fivestack_ch6_init[] = {
1905 /* set line-in to input, mute it */
1906 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1907 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1912 static struct hda_verb alc880_fivestack_ch8_init[] = {
1913 /* set line-in to output, unmute it */
1914 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1915 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1919 static struct hda_channel_mode alc880_fivestack_modes[2] = {
1920 { 6, alc880_fivestack_ch6_init },
1921 { 8, alc880_fivestack_ch8_init },
1926 * ALC880 6-stack model
1928 * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e),
1929 * Side = 0x05 (0x0f)
1930 * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
1931 * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
1934 static hda_nid_t alc880_6st_dac_nids[4] = {
1935 /* front, rear, clfe, rear_surr */
1936 0x02, 0x03, 0x04, 0x05
1939 static struct hda_input_mux alc880_6stack_capture_source = {
1943 { "Front Mic", 0x1 },
1949 /* fixed 8-channels */
1950 static struct hda_channel_mode alc880_sixstack_modes[1] = {
1954 static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
1955 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1956 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1957 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1958 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
1959 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1960 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1961 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1962 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1963 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
1964 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
1965 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1966 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1967 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1968 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1969 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1970 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1971 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1972 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1974 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1975 .name = "Channel Mode",
1976 .info = alc_ch_mode_info,
1977 .get = alc_ch_mode_get,
1978 .put = alc_ch_mode_put,
1987 * W810 has rear IO for:
1990 * Center/LFE (DAC 04)
1993 * The system also has a pair of internal speakers, and a headphone jack.
1994 * These are both connected to Line2 on the codec, hence to DAC 02.
1996 * There is a variable resistor to control the speaker or headphone
1997 * volume. This is a hardware-only device without a software API.
1999 * Plugging headphones in will disable the internal speakers. This is
2000 * implemented in hardware, not via the driver using jack sense. In
2001 * a similar fashion, plugging into the rear socket marked "front" will
2002 * disable both the speakers and headphones.
2004 * For input, there's a microphone jack, and an "audio in" jack.
2005 * These may not do anything useful with this driver yet, because I
2006 * haven't setup any initialization verbs for these yet...
2009 static hda_nid_t alc880_w810_dac_nids[3] = {
2010 /* front, rear/surround, clfe */
2014 /* fixed 6 channels */
2015 static struct hda_channel_mode alc880_w810_modes[1] = {
2019 /* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
2020 static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
2021 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2022 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2023 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2024 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
2025 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2026 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2027 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2028 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2029 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
2037 * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
2038 * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?),
2042 static hda_nid_t alc880_z71v_dac_nids[1] = {
2045 #define ALC880_Z71V_HP_DAC 0x03
2047 /* fixed 2 channels */
2048 static struct hda_channel_mode alc880_2_jack_modes[1] = {
2052 static struct snd_kcontrol_new alc880_z71v_mixer[] = {
2053 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2054 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2055 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2056 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
2057 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2058 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2059 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2060 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2066 * ALC880 F1734 model
2068 * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
2069 * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
2072 static hda_nid_t alc880_f1734_dac_nids[1] = {
2075 #define ALC880_F1734_HP_DAC 0x02
2077 static struct snd_kcontrol_new alc880_f1734_mixer[] = {
2078 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2079 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2080 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2081 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
2082 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2083 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2084 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2085 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
2089 static struct hda_input_mux alc880_f1734_capture_source = {
2101 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
2102 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
2103 * Mic = 0x18, Line = 0x1a
2106 #define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
2107 #define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
2109 static struct snd_kcontrol_new alc880_asus_mixer[] = {
2110 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2111 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2112 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2113 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
2114 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2115 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2116 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2117 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2118 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2119 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2120 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2121 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2122 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2123 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2125 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2126 .name = "Channel Mode",
2127 .info = alc_ch_mode_info,
2128 .get = alc_ch_mode_get,
2129 .put = alc_ch_mode_put,
2135 * ALC880 ASUS W1V model
2137 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
2138 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
2139 * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
2142 /* additional mixers to alc880_asus_mixer */
2143 static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
2144 HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
2145 HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
2150 static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
2151 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2152 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
2153 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
2154 HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
2155 HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
2156 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
2157 HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
2158 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
2159 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
2164 static struct snd_kcontrol_new alc880_uniwill_mixer[] = {
2165 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2166 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2167 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2168 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
2169 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2170 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2171 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2172 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2173 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2174 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2175 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2176 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2177 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2178 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2179 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2180 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
2182 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2183 .name = "Channel Mode",
2184 .info = alc_ch_mode_info,
2185 .get = alc_ch_mode_get,
2186 .put = alc_ch_mode_put,
2191 static struct snd_kcontrol_new alc880_fujitsu_mixer[] = {
2192 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2193 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2194 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2195 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
2196 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2197 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2198 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2199 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2200 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2201 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
2205 static struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = {
2206 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2207 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2208 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2209 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
2210 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2211 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2216 * virtual master controls
2220 * slave controls for virtual master
2222 static const char *alc_slave_vols[] = {
2223 "Front Playback Volume",
2224 "Surround Playback Volume",
2225 "Center Playback Volume",
2226 "LFE Playback Volume",
2227 "Side Playback Volume",
2228 "Headphone Playback Volume",
2229 "Speaker Playback Volume",
2230 "Mono Playback Volume",
2231 "Line-Out Playback Volume",
2232 "PCM Playback Volume",
2236 static const char *alc_slave_sws[] = {
2237 "Front Playback Switch",
2238 "Surround Playback Switch",
2239 "Center Playback Switch",
2240 "LFE Playback Switch",
2241 "Side Playback Switch",
2242 "Headphone Playback Switch",
2243 "Speaker Playback Switch",
2244 "Mono Playback Switch",
2245 "IEC958 Playback Switch",
2250 * build control elements
2253 static void alc_free_kctls(struct hda_codec *codec);
2255 /* additional beep mixers; the actual parameters are overwritten at build */
2256 static struct snd_kcontrol_new alc_beep_mixer[] = {
2257 HDA_CODEC_VOLUME("Beep Playback Volume", 0, 0, HDA_INPUT),
2258 HDA_CODEC_MUTE("Beep Playback Switch", 0, 0, HDA_INPUT),
2262 static int alc_build_controls(struct hda_codec *codec)
2264 struct alc_spec *spec = codec->spec;
2268 for (i = 0; i < spec->num_mixers; i++) {
2269 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
2273 if (spec->cap_mixer) {
2274 err = snd_hda_add_new_ctls(codec, spec->cap_mixer);
2278 if (spec->multiout.dig_out_nid) {
2279 err = snd_hda_create_spdif_out_ctls(codec,
2280 spec->multiout.dig_out_nid);
2283 if (!spec->no_analog) {
2284 err = snd_hda_create_spdif_share_sw(codec,
2288 spec->multiout.share_spdif = 1;
2291 if (spec->dig_in_nid) {
2292 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
2297 /* create beep controls if needed */
2298 if (spec->beep_amp) {
2299 struct snd_kcontrol_new *knew;
2300 for (knew = alc_beep_mixer; knew->name; knew++) {
2301 struct snd_kcontrol *kctl;
2302 kctl = snd_ctl_new1(knew, codec);
2305 kctl->private_value = spec->beep_amp;
2306 err = snd_hda_ctl_add(codec, kctl);
2312 /* if we have no master control, let's create it */
2313 if (!spec->no_analog &&
2314 !snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
2315 unsigned int vmaster_tlv[4];
2316 snd_hda_set_vmaster_tlv(codec, spec->vmaster_nid,
2317 HDA_OUTPUT, vmaster_tlv);
2318 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
2319 vmaster_tlv, alc_slave_vols);
2323 if (!spec->no_analog &&
2324 !snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
2325 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
2326 NULL, alc_slave_sws);
2331 alc_free_kctls(codec); /* no longer needed */
2337 * initialize the codec volumes, etc
2341 * generic initialization of ADC, input mixers and output mixers
2343 static struct hda_verb alc880_volume_init_verbs[] = {
2345 * Unmute ADC0-2 and set the default input to mic-in
2347 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
2348 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2349 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
2350 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2351 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
2352 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2354 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
2356 * Note: PASD motherboards uses the Line In 2 as the input for front
2359 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
2360 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2361 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2362 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
2363 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
2364 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
2365 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
2366 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
2369 * Set up output mixers (0x0c - 0x0f)
2371 /* set vol=0 to output mixers */
2372 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2373 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2374 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2375 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2376 /* set up input amps for analog loopback */
2377 /* Amp Indices: DAC = 0, mixer = 1 */
2378 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2379 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2380 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2381 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2382 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2383 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2384 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2385 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2391 * 3-stack pin configuration:
2392 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
2394 static struct hda_verb alc880_pin_3stack_init_verbs[] = {
2396 * preset connection lists of input pins
2397 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
2399 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
2400 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2401 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
2404 * Set pin mode and muting
2406 /* set front pin widgets 0x14 for output */
2407 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2408 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2409 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2410 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2411 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2412 /* Mic2 (as headphone out) for HP output */
2413 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2414 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2415 /* Line In pin widget for input */
2416 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2417 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2418 /* Line2 (as front mic) pin widget for input and vref at 80% */
2419 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2420 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2421 /* CD pin widget for input */
2422 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2428 * 5-stack pin configuration:
2429 * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
2430 * line-in/side = 0x1a, f-mic = 0x1b
2432 static struct hda_verb alc880_pin_5stack_init_verbs[] = {
2434 * preset connection lists of input pins
2435 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
2437 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2438 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
2441 * Set pin mode and muting
2443 /* set pin widgets 0x14-0x17 for output */
2444 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2445 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2446 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2447 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2448 /* unmute pins for output (no gain on this amp) */
2449 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2450 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2451 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2452 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2454 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2455 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2456 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2457 /* Mic2 (as headphone out) for HP output */
2458 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2459 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2460 /* Line In pin widget for input */
2461 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2462 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2463 /* Line2 (as front mic) pin widget for input and vref at 80% */
2464 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2465 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2466 /* CD pin widget for input */
2467 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2473 * W810 pin configuration:
2474 * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
2476 static struct hda_verb alc880_pin_w810_init_verbs[] = {
2477 /* hphone/speaker input selector: front DAC */
2478 {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
2480 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2481 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2482 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2483 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2484 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2485 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2487 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2488 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2494 * Z71V pin configuration:
2495 * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
2497 static struct hda_verb alc880_pin_z71v_init_verbs[] = {
2498 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2499 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2500 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2501 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2503 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2504 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2505 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2506 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2512 * 6-stack pin configuration:
2513 * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18,
2514 * f-mic = 0x19, line = 0x1a, HP = 0x1b
2516 static struct hda_verb alc880_pin_6stack_init_verbs[] = {
2517 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2519 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2520 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2521 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2522 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2523 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2524 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2525 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2526 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2528 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2529 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2530 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2531 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2532 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2533 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2534 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2535 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2536 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2542 * Uniwill pin configuration:
2543 * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19,
2546 static struct hda_verb alc880_uniwill_init_verbs[] = {
2547 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2549 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2550 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2551 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2552 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2553 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2554 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2555 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2556 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2557 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2558 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2559 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2560 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2561 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2562 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2564 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2565 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2566 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2567 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2568 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2569 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2570 /* {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, */
2571 /* {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
2572 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2574 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
2575 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
2582 * HP = 0x14, InternalSpeaker = 0x15, mic = 0x19,
2584 static struct hda_verb alc880_uniwill_p53_init_verbs[] = {
2585 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2587 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2588 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2589 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2590 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2591 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2592 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2593 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2594 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2595 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2596 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2597 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2598 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2600 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2601 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2602 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2603 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2604 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2605 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2607 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
2608 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_DCVOL_EVENT},
2613 static struct hda_verb alc880_beep_init_verbs[] = {
2614 { 0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5) },
2618 /* auto-toggle front mic */
2619 static void alc880_uniwill_mic_automute(struct hda_codec *codec)
2621 unsigned int present;
2624 present = snd_hda_codec_read(codec, 0x18, 0,
2625 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
2626 bits = present ? HDA_AMP_MUTE : 0;
2627 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
2630 static void alc880_uniwill_init_hook(struct hda_codec *codec)
2632 struct alc_spec *spec = codec->spec;
2634 spec->autocfg.hp_pins[0] = 0x14;
2635 spec->autocfg.speaker_pins[0] = 0x15;
2636 spec->autocfg.speaker_pins[0] = 0x16;
2637 alc_automute_amp(codec);
2638 alc880_uniwill_mic_automute(codec);
2641 static void alc880_uniwill_unsol_event(struct hda_codec *codec,
2644 /* Looks like the unsol event is incompatible with the standard
2645 * definition. 4bit tag is placed at 28 bit!
2647 switch (res >> 28) {
2648 case ALC880_MIC_EVENT:
2649 alc880_uniwill_mic_automute(codec);
2652 alc_automute_amp_unsol_event(codec, res);
2657 static void alc880_uniwill_p53_init_hook(struct hda_codec *codec)
2659 struct alc_spec *spec = codec->spec;
2661 spec->autocfg.hp_pins[0] = 0x14;
2662 spec->autocfg.speaker_pins[0] = 0x15;
2663 alc_automute_amp(codec);
2666 static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec)
2668 unsigned int present;
2670 present = snd_hda_codec_read(codec, 0x21, 0,
2671 AC_VERB_GET_VOLUME_KNOB_CONTROL, 0);
2672 present &= HDA_AMP_VOLMASK;
2673 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0,
2674 HDA_AMP_VOLMASK, present);
2675 snd_hda_codec_amp_stereo(codec, 0x0d, HDA_OUTPUT, 0,
2676 HDA_AMP_VOLMASK, present);
2679 static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec,
2682 /* Looks like the unsol event is incompatible with the standard
2683 * definition. 4bit tag is placed at 28 bit!
2685 if ((res >> 28) == ALC880_DCVOL_EVENT)
2686 alc880_uniwill_p53_dcvol_automute(codec);
2688 alc_automute_amp_unsol_event(codec, res);
2692 * F1734 pin configuration:
2693 * HP = 0x14, speaker-out = 0x15, mic = 0x18
2695 static struct hda_verb alc880_pin_f1734_init_verbs[] = {
2696 {0x07, AC_VERB_SET_CONNECT_SEL, 0x01},
2697 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
2698 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
2699 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
2700 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
2702 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2703 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2704 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2705 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2707 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2708 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2709 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
2710 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2711 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2712 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2713 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2714 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2715 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2717 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
2718 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_DCVOL_EVENT},
2724 * ASUS pin configuration:
2725 * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
2727 static struct hda_verb alc880_pin_asus_init_verbs[] = {
2728 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
2729 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
2730 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
2731 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
2733 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2734 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2735 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2736 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2737 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2738 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2739 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2740 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2742 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2743 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2744 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2745 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2746 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2747 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2748 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2749 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2750 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2755 /* Enable GPIO mask and set output */
2756 #define alc880_gpio1_init_verbs alc_gpio1_init_verbs
2757 #define alc880_gpio2_init_verbs alc_gpio2_init_verbs
2758 #define alc880_gpio3_init_verbs alc_gpio3_init_verbs
2760 /* Clevo m520g init */
2761 static struct hda_verb alc880_pin_clevo_init_verbs[] = {
2762 /* headphone output */
2763 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
2765 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2766 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2768 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2769 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2771 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2772 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2773 /* Mic1 (rear panel) */
2774 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2775 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2776 /* Mic2 (front panel) */
2777 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2778 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2780 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2781 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2782 /* change to EAPD mode */
2783 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2784 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
2789 static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
2790 /* change to EAPD mode */
2791 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2792 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
2794 /* Headphone output */
2795 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2797 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2798 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
2800 /* Line In pin widget for input */
2801 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2802 /* CD pin widget for input */
2803 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2804 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2805 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2807 /* change to EAPD mode */
2808 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2809 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
2815 * LG m1 express dual
2818 * Rear Line-In/Out (blue): 0x14
2819 * Build-in Mic-In: 0x15
2821 * HP-Out (green): 0x1b
2822 * Mic-In/Out (red): 0x19
2826 /* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
2827 static hda_nid_t alc880_lg_dac_nids[3] = {
2831 /* seems analog CD is not working */
2832 static struct hda_input_mux alc880_lg_capture_source = {
2837 { "Internal Mic", 0x6 },
2841 /* 2,4,6 channel modes */
2842 static struct hda_verb alc880_lg_ch2_init[] = {
2843 /* set line-in and mic-in to input */
2844 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
2845 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
2849 static struct hda_verb alc880_lg_ch4_init[] = {
2850 /* set line-in to out and mic-in to input */
2851 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
2852 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
2856 static struct hda_verb alc880_lg_ch6_init[] = {
2857 /* set line-in and mic-in to output */
2858 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
2859 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
2863 static struct hda_channel_mode alc880_lg_ch_modes[3] = {
2864 { 2, alc880_lg_ch2_init },
2865 { 4, alc880_lg_ch4_init },
2866 { 6, alc880_lg_ch6_init },
2869 static struct snd_kcontrol_new alc880_lg_mixer[] = {
2870 HDA_CODEC_VOLUME("Front Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
2871 HDA_BIND_MUTE("Front Playback Switch", 0x0f, 2, HDA_INPUT),
2872 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2873 HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
2874 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
2875 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
2876 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
2877 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
2878 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2879 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
2880 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
2881 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
2882 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
2883 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
2885 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2886 .name = "Channel Mode",
2887 .info = alc_ch_mode_info,
2888 .get = alc_ch_mode_get,
2889 .put = alc_ch_mode_put,
2894 static struct hda_verb alc880_lg_init_verbs[] = {
2895 /* set capture source to mic-in */
2896 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2897 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2898 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2899 /* mute all amp mixer inputs */
2900 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
2901 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
2902 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
2903 /* line-in to input */
2904 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2905 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2907 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2908 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2910 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2911 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2912 /* mic-in to input */
2913 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
2914 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2915 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2917 {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
2918 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2919 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2921 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
2925 /* toggle speaker-output according to the hp-jack state */
2926 static void alc880_lg_init_hook(struct hda_codec *codec)
2928 struct alc_spec *spec = codec->spec;
2930 spec->autocfg.hp_pins[0] = 0x1b;
2931 spec->autocfg.speaker_pins[0] = 0x17;
2932 alc_automute_amp(codec);
2941 * Built-in Mic-In: 0x19
2947 static struct hda_input_mux alc880_lg_lw_capture_source = {
2951 { "Internal Mic", 0x1 },
2956 #define alc880_lg_lw_modes alc880_threestack_modes
2958 static struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
2959 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2960 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2961 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
2962 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
2963 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2964 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2965 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2966 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2967 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2968 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2969 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2970 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2971 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
2972 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
2974 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2975 .name = "Channel Mode",
2976 .info = alc_ch_mode_info,
2977 .get = alc_ch_mode_get,
2978 .put = alc_ch_mode_put,
2983 static struct hda_verb alc880_lg_lw_init_verbs[] = {
2984 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2985 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
2986 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
2988 /* set capture source to mic-in */
2989 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2990 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2991 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2992 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
2994 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2995 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2997 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2998 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2999 /* mic-in to input */
3000 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3001 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3003 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3004 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3006 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
3010 /* toggle speaker-output according to the hp-jack state */
3011 static void alc880_lg_lw_init_hook(struct hda_codec *codec)
3013 struct alc_spec *spec = codec->spec;
3015 spec->autocfg.hp_pins[0] = 0x1b;
3016 spec->autocfg.speaker_pins[0] = 0x14;
3017 alc_automute_amp(codec);
3020 static struct snd_kcontrol_new alc880_medion_rim_mixer[] = {
3021 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3022 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
3023 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
3024 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
3025 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
3026 HDA_CODEC_MUTE("Internal Playback Switch", 0x0b, 0x1, HDA_INPUT),
3030 static struct hda_input_mux alc880_medion_rim_capture_source = {
3034 { "Internal Mic", 0x1 },
3038 static struct hda_verb alc880_medion_rim_init_verbs[] = {
3039 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3041 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3042 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3044 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3045 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3046 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3047 /* Mic2 (as headphone out) for HP output */
3048 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3049 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3050 /* Internal Speaker */
3051 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3052 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3054 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
3055 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
3057 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
3061 /* toggle speaker-output according to the hp-jack state */
3062 static void alc880_medion_rim_automute(struct hda_codec *codec)
3064 struct alc_spec *spec = codec->spec;
3065 alc_automute_amp(codec);
3067 if (spec->jack_present)
3068 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 0);
3070 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 2);
3073 static void alc880_medion_rim_unsol_event(struct hda_codec *codec,
3076 /* Looks like the unsol event is incompatible with the standard
3077 * definition. 4bit tag is placed at 28 bit!
3079 if ((res >> 28) == ALC880_HP_EVENT)
3080 alc880_medion_rim_automute(codec);
3083 static void alc880_medion_rim_init_hook(struct hda_codec *codec)
3085 struct alc_spec *spec = codec->spec;
3087 spec->autocfg.hp_pins[0] = 0x14;
3088 spec->autocfg.speaker_pins[0] = 0x1b;
3089 alc880_medion_rim_automute(codec);
3092 #ifdef CONFIG_SND_HDA_POWER_SAVE
3093 static struct hda_amp_list alc880_loopbacks[] = {
3094 { 0x0b, HDA_INPUT, 0 },
3095 { 0x0b, HDA_INPUT, 1 },
3096 { 0x0b, HDA_INPUT, 2 },
3097 { 0x0b, HDA_INPUT, 3 },
3098 { 0x0b, HDA_INPUT, 4 },
3102 static struct hda_amp_list alc880_lg_loopbacks[] = {
3103 { 0x0b, HDA_INPUT, 1 },
3104 { 0x0b, HDA_INPUT, 6 },
3105 { 0x0b, HDA_INPUT, 7 },
3114 static int alc_init(struct hda_codec *codec)
3116 struct alc_spec *spec = codec->spec;
3120 alc_auto_init_amp(codec, spec->init_amp);
3122 for (i = 0; i < spec->num_init_verbs; i++)
3123 snd_hda_sequence_write(codec, spec->init_verbs[i]);
3125 if (spec->init_hook)
3126 spec->init_hook(codec);
3131 static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
3133 struct alc_spec *spec = codec->spec;
3135 if (spec->unsol_event)
3136 spec->unsol_event(codec, res);
3139 #ifdef CONFIG_SND_HDA_POWER_SAVE
3140 static int alc_check_power_status(struct hda_codec *codec, hda_nid_t nid)
3142 struct alc_spec *spec = codec->spec;
3143 return snd_hda_check_amp_list_power(codec, &spec->loopback, nid);
3148 * Analog playback callbacks
3150 static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
3151 struct hda_codec *codec,
3152 struct snd_pcm_substream *substream)
3154 struct alc_spec *spec = codec->spec;