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,
218 ALC883_TARGA_2ch_DIG,
221 ALC888_ACER_ASPIRE_4930G,
225 ALC883_LENOVO_101E_2ch,
226 ALC883_LENOVO_NB0763,
227 ALC888_LENOVO_MS7195_DIG,
234 ALC883_FUJITSU_PI2515,
235 ALC888_FUJITSU_XA3530,
236 ALC883_3ST_6ch_INTEL,
244 /* styles of capture selection */
246 CAPT_MUX = 0, /* only mux based */
247 CAPT_MIX, /* only mixer based */
248 CAPT_1MUX_MIX, /* first mux and other mixers */
252 #define GPIO_MASK 0x03
255 /* codec parameterization */
256 struct snd_kcontrol_new *mixers[5]; /* mixer arrays */
257 unsigned int num_mixers;
258 struct snd_kcontrol_new *cap_mixer; /* capture mixer */
259 unsigned int beep_amp; /* beep amp value, set via set_beep_amp() */
261 const struct hda_verb *init_verbs[5]; /* initialization verbs
265 unsigned int num_init_verbs;
267 char *stream_name_analog; /* analog PCM stream */
268 struct hda_pcm_stream *stream_analog_playback;
269 struct hda_pcm_stream *stream_analog_capture;
270 struct hda_pcm_stream *stream_analog_alt_playback;
271 struct hda_pcm_stream *stream_analog_alt_capture;
273 char *stream_name_digital; /* digital PCM stream */
274 struct hda_pcm_stream *stream_digital_playback;
275 struct hda_pcm_stream *stream_digital_capture;
278 struct hda_multi_out multiout; /* playback set-up
279 * max_channels, dacs must be set
280 * dig_out_nid and hp_nid are optional
282 hda_nid_t alt_dac_nid;
283 hda_nid_t slave_dig_outs[3]; /* optional - for auto-parsing */
287 unsigned int num_adc_nids;
289 hda_nid_t *capsrc_nids;
290 hda_nid_t dig_in_nid; /* digital-in NID; optional */
291 int capture_style; /* capture style (CAPT_*) */
294 unsigned int num_mux_defs;
295 const struct hda_input_mux *input_mux;
296 unsigned int cur_mux[3];
299 const struct hda_channel_mode *channel_mode;
300 int num_channel_mode;
303 /* PCM information */
304 struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */
306 /* dynamic controls, init_verbs and input_mux */
307 struct auto_pin_cfg autocfg;
308 struct snd_array kctls;
309 struct hda_input_mux private_imux[3];
310 hda_nid_t private_dac_nids[AUTO_CFG_MAX_OUTS];
313 void (*init_hook)(struct hda_codec *codec);
314 void (*unsol_event)(struct hda_codec *codec, unsigned int res);
316 /* for pin sensing */
317 unsigned int sense_updated: 1;
318 unsigned int jack_present: 1;
319 unsigned int master_sw: 1;
322 unsigned int no_analog :1; /* digital I/O only */
324 /* for virtual master */
325 hda_nid_t vmaster_nid;
326 #ifdef CONFIG_SND_HDA_POWER_SAVE
327 struct hda_loopback_check loopback;
332 unsigned int pll_coef_idx, pll_coef_bit;
336 * configuration template - to be copied to the spec instance
338 struct alc_config_preset {
339 struct snd_kcontrol_new *mixers[5]; /* should be identical size
342 struct snd_kcontrol_new *cap_mixer; /* capture mixer */
343 const struct hda_verb *init_verbs[5];
344 unsigned int num_dacs;
346 hda_nid_t dig_out_nid; /* optional */
347 hda_nid_t hp_nid; /* optional */
348 hda_nid_t *slave_dig_outs;
349 unsigned int num_adc_nids;
351 hda_nid_t *capsrc_nids;
352 hda_nid_t dig_in_nid;
353 unsigned int num_channel_mode;
354 const struct hda_channel_mode *channel_mode;
356 unsigned int num_mux_defs;
357 const struct hda_input_mux *input_mux;
358 void (*unsol_event)(struct hda_codec *, unsigned int);
359 void (*init_hook)(struct hda_codec *);
360 #ifdef CONFIG_SND_HDA_POWER_SAVE
361 struct hda_amp_list *loopbacks;
369 static int alc_mux_enum_info(struct snd_kcontrol *kcontrol,
370 struct snd_ctl_elem_info *uinfo)
372 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
373 struct alc_spec *spec = codec->spec;
374 unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id);
375 if (mux_idx >= spec->num_mux_defs)
377 return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo);
380 static int alc_mux_enum_get(struct snd_kcontrol *kcontrol,
381 struct snd_ctl_elem_value *ucontrol)
383 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
384 struct alc_spec *spec = codec->spec;
385 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
387 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
391 static int alc_mux_enum_put(struct snd_kcontrol *kcontrol,
392 struct snd_ctl_elem_value *ucontrol)
394 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
395 struct alc_spec *spec = codec->spec;
396 const struct hda_input_mux *imux;
397 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
398 unsigned int mux_idx;
399 hda_nid_t nid = spec->capsrc_nids ?
400 spec->capsrc_nids[adc_idx] : spec->adc_nids[adc_idx];
402 mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx;
403 imux = &spec->input_mux[mux_idx];
405 if (spec->capture_style &&
406 !(spec->capture_style == CAPT_1MUX_MIX && !adc_idx)) {
407 /* Matrix-mixer style (e.g. ALC882) */
408 unsigned int *cur_val = &spec->cur_mux[adc_idx];
411 idx = ucontrol->value.enumerated.item[0];
412 if (idx >= imux->num_items)
413 idx = imux->num_items - 1;
416 for (i = 0; i < imux->num_items; i++) {
417 unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
418 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
419 imux->items[i].index,
425 /* MUX style (e.g. ALC880) */
426 return snd_hda_input_mux_put(codec, imux, ucontrol, nid,
427 &spec->cur_mux[adc_idx]);
432 * channel mode setting
434 static int alc_ch_mode_info(struct snd_kcontrol *kcontrol,
435 struct snd_ctl_elem_info *uinfo)
437 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
438 struct alc_spec *spec = codec->spec;
439 return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
440 spec->num_channel_mode);
443 static int alc_ch_mode_get(struct snd_kcontrol *kcontrol,
444 struct snd_ctl_elem_value *ucontrol)
446 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
447 struct alc_spec *spec = codec->spec;
448 return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
449 spec->num_channel_mode,
450 spec->multiout.max_channels);
453 static int alc_ch_mode_put(struct snd_kcontrol *kcontrol,
454 struct snd_ctl_elem_value *ucontrol)
456 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
457 struct alc_spec *spec = codec->spec;
458 int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
459 spec->num_channel_mode,
460 &spec->multiout.max_channels);
461 if (err >= 0 && spec->need_dac_fix)
462 spec->multiout.num_dacs = spec->multiout.max_channels / 2;
467 * Control the mode of pin widget settings via the mixer. "pc" is used
468 * instead of "%" to avoid consequences of accidently treating the % as
469 * being part of a format specifier. Maximum allowed length of a value is
470 * 63 characters plus NULL terminator.
472 * Note: some retasking pin complexes seem to ignore requests for input
473 * states other than HiZ (eg: PIN_VREFxx) and revert to HiZ if any of these
474 * are requested. Therefore order this list so that this behaviour will not
475 * cause problems when mixer clients move through the enum sequentially.
476 * NIDs 0x0f and 0x10 have been observed to have this behaviour as of
479 static char *alc_pin_mode_names[] = {
480 "Mic 50pc bias", "Mic 80pc bias",
481 "Line in", "Line out", "Headphone out",
483 static unsigned char alc_pin_mode_values[] = {
484 PIN_VREF50, PIN_VREF80, PIN_IN, PIN_OUT, PIN_HP,
486 /* The control can present all 5 options, or it can limit the options based
487 * in the pin being assumed to be exclusively an input or an output pin. In
488 * addition, "input" pins may or may not process the mic bias option
489 * depending on actual widget capability (NIDs 0x0f and 0x10 don't seem to
490 * accept requests for bias as of chip versions up to March 2006) and/or
491 * wiring in the computer.
493 #define ALC_PIN_DIR_IN 0x00
494 #define ALC_PIN_DIR_OUT 0x01
495 #define ALC_PIN_DIR_INOUT 0x02
496 #define ALC_PIN_DIR_IN_NOMICBIAS 0x03
497 #define ALC_PIN_DIR_INOUT_NOMICBIAS 0x04
499 /* Info about the pin modes supported by the different pin direction modes.
500 * For each direction the minimum and maximum values are given.
502 static signed char alc_pin_mode_dir_info[5][2] = {
503 { 0, 2 }, /* ALC_PIN_DIR_IN */
504 { 3, 4 }, /* ALC_PIN_DIR_OUT */
505 { 0, 4 }, /* ALC_PIN_DIR_INOUT */
506 { 2, 2 }, /* ALC_PIN_DIR_IN_NOMICBIAS */
507 { 2, 4 }, /* ALC_PIN_DIR_INOUT_NOMICBIAS */
509 #define alc_pin_mode_min(_dir) (alc_pin_mode_dir_info[_dir][0])
510 #define alc_pin_mode_max(_dir) (alc_pin_mode_dir_info[_dir][1])
511 #define alc_pin_mode_n_items(_dir) \
512 (alc_pin_mode_max(_dir)-alc_pin_mode_min(_dir)+1)
514 static int alc_pin_mode_info(struct snd_kcontrol *kcontrol,
515 struct snd_ctl_elem_info *uinfo)
517 unsigned int item_num = uinfo->value.enumerated.item;
518 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
520 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
522 uinfo->value.enumerated.items = alc_pin_mode_n_items(dir);
524 if (item_num<alc_pin_mode_min(dir) || item_num>alc_pin_mode_max(dir))
525 item_num = alc_pin_mode_min(dir);
526 strcpy(uinfo->value.enumerated.name, alc_pin_mode_names[item_num]);
530 static int alc_pin_mode_get(struct snd_kcontrol *kcontrol,
531 struct snd_ctl_elem_value *ucontrol)
534 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
535 hda_nid_t nid = kcontrol->private_value & 0xffff;
536 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
537 long *valp = ucontrol->value.integer.value;
538 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
539 AC_VERB_GET_PIN_WIDGET_CONTROL,
542 /* Find enumerated value for current pinctl setting */
543 i = alc_pin_mode_min(dir);
544 while (alc_pin_mode_values[i] != pinctl && i <= alc_pin_mode_max(dir))
546 *valp = i <= alc_pin_mode_max(dir) ? i: alc_pin_mode_min(dir);
550 static int alc_pin_mode_put(struct snd_kcontrol *kcontrol,
551 struct snd_ctl_elem_value *ucontrol)
554 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
555 hda_nid_t nid = kcontrol->private_value & 0xffff;
556 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
557 long val = *ucontrol->value.integer.value;
558 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
559 AC_VERB_GET_PIN_WIDGET_CONTROL,
562 if (val < alc_pin_mode_min(dir) || val > alc_pin_mode_max(dir))
563 val = alc_pin_mode_min(dir);
565 change = pinctl != alc_pin_mode_values[val];
567 /* Set pin mode to that requested */
568 snd_hda_codec_write_cache(codec, nid, 0,
569 AC_VERB_SET_PIN_WIDGET_CONTROL,
570 alc_pin_mode_values[val]);
572 /* Also enable the retasking pin's input/output as required
573 * for the requested pin mode. Enum values of 2 or less are
576 * Dynamically switching the input/output buffers probably
577 * reduces noise slightly (particularly on input) so we'll
578 * do it. However, having both input and output buffers
579 * enabled simultaneously doesn't seem to be problematic if
580 * this turns out to be necessary in the future.
583 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
584 HDA_AMP_MUTE, HDA_AMP_MUTE);
585 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
588 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
589 HDA_AMP_MUTE, HDA_AMP_MUTE);
590 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
597 #define ALC_PIN_MODE(xname, nid, dir) \
598 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
599 .info = alc_pin_mode_info, \
600 .get = alc_pin_mode_get, \
601 .put = alc_pin_mode_put, \
602 .private_value = nid | (dir<<16) }
604 /* A switch control for ALC260 GPIO pins. Multiple GPIOs can be ganged
605 * together using a mask with more than one bit set. This control is
606 * currently used only by the ALC260 test model. At this stage they are not
607 * needed for any "production" models.
609 #ifdef CONFIG_SND_DEBUG
610 #define alc_gpio_data_info snd_ctl_boolean_mono_info
612 static int alc_gpio_data_get(struct snd_kcontrol *kcontrol,
613 struct snd_ctl_elem_value *ucontrol)
615 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
616 hda_nid_t nid = kcontrol->private_value & 0xffff;
617 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
618 long *valp = ucontrol->value.integer.value;
619 unsigned int val = snd_hda_codec_read(codec, nid, 0,
620 AC_VERB_GET_GPIO_DATA, 0x00);
622 *valp = (val & mask) != 0;
625 static int alc_gpio_data_put(struct snd_kcontrol *kcontrol,
626 struct snd_ctl_elem_value *ucontrol)
629 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
630 hda_nid_t nid = kcontrol->private_value & 0xffff;
631 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
632 long val = *ucontrol->value.integer.value;
633 unsigned int gpio_data = snd_hda_codec_read(codec, nid, 0,
634 AC_VERB_GET_GPIO_DATA,
637 /* Set/unset the masked GPIO bit(s) as needed */
638 change = (val == 0 ? 0 : mask) != (gpio_data & mask);
643 snd_hda_codec_write_cache(codec, nid, 0,
644 AC_VERB_SET_GPIO_DATA, gpio_data);
648 #define ALC_GPIO_DATA_SWITCH(xname, nid, mask) \
649 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
650 .info = alc_gpio_data_info, \
651 .get = alc_gpio_data_get, \
652 .put = alc_gpio_data_put, \
653 .private_value = nid | (mask<<16) }
654 #endif /* CONFIG_SND_DEBUG */
656 /* A switch control to allow the enabling of the digital IO pins on the
657 * ALC260. This is incredibly simplistic; the intention of this control is
658 * to provide something in the test model allowing digital outputs to be
659 * identified if present. If models are found which can utilise these
660 * outputs a more complete mixer control can be devised for those models if
663 #ifdef CONFIG_SND_DEBUG
664 #define alc_spdif_ctrl_info snd_ctl_boolean_mono_info
666 static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol,
667 struct snd_ctl_elem_value *ucontrol)
669 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
670 hda_nid_t nid = kcontrol->private_value & 0xffff;
671 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
672 long *valp = ucontrol->value.integer.value;
673 unsigned int val = snd_hda_codec_read(codec, nid, 0,
674 AC_VERB_GET_DIGI_CONVERT_1, 0x00);
676 *valp = (val & mask) != 0;
679 static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol,
680 struct snd_ctl_elem_value *ucontrol)
683 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
684 hda_nid_t nid = kcontrol->private_value & 0xffff;
685 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
686 long val = *ucontrol->value.integer.value;
687 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
688 AC_VERB_GET_DIGI_CONVERT_1,
691 /* Set/unset the masked control bit(s) as needed */
692 change = (val == 0 ? 0 : mask) != (ctrl_data & mask);
697 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1,
702 #define ALC_SPDIF_CTRL_SWITCH(xname, nid, mask) \
703 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
704 .info = alc_spdif_ctrl_info, \
705 .get = alc_spdif_ctrl_get, \
706 .put = alc_spdif_ctrl_put, \
707 .private_value = nid | (mask<<16) }
708 #endif /* CONFIG_SND_DEBUG */
710 /* A switch control to allow the enabling EAPD digital outputs on the ALC26x.
711 * Again, this is only used in the ALC26x test models to help identify when
712 * the EAPD line must be asserted for features to work.
714 #ifdef CONFIG_SND_DEBUG
715 #define alc_eapd_ctrl_info snd_ctl_boolean_mono_info
717 static int alc_eapd_ctrl_get(struct snd_kcontrol *kcontrol,
718 struct snd_ctl_elem_value *ucontrol)
720 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
721 hda_nid_t nid = kcontrol->private_value & 0xffff;
722 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
723 long *valp = ucontrol->value.integer.value;
724 unsigned int val = snd_hda_codec_read(codec, nid, 0,
725 AC_VERB_GET_EAPD_BTLENABLE, 0x00);
727 *valp = (val & mask) != 0;
731 static int alc_eapd_ctrl_put(struct snd_kcontrol *kcontrol,
732 struct snd_ctl_elem_value *ucontrol)
735 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
736 hda_nid_t nid = kcontrol->private_value & 0xffff;
737 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
738 long val = *ucontrol->value.integer.value;
739 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
740 AC_VERB_GET_EAPD_BTLENABLE,
743 /* Set/unset the masked control bit(s) as needed */
744 change = (!val ? 0 : mask) != (ctrl_data & mask);
749 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
755 #define ALC_EAPD_CTRL_SWITCH(xname, nid, mask) \
756 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
757 .info = alc_eapd_ctrl_info, \
758 .get = alc_eapd_ctrl_get, \
759 .put = alc_eapd_ctrl_put, \
760 .private_value = nid | (mask<<16) }
761 #endif /* CONFIG_SND_DEBUG */
764 * set up the input pin config (depending on the given auto-pin type)
766 static void alc_set_input_pin(struct hda_codec *codec, hda_nid_t nid,
769 unsigned int val = PIN_IN;
771 if (auto_pin_type <= AUTO_PIN_FRONT_MIC) {
773 pincap = snd_hda_query_pin_caps(codec, nid);
774 pincap = (pincap & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT;
775 if (pincap & AC_PINCAP_VREF_80)
778 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, val);
783 static void add_mixer(struct alc_spec *spec, struct snd_kcontrol_new *mix)
785 if (snd_BUG_ON(spec->num_mixers >= ARRAY_SIZE(spec->mixers)))
787 spec->mixers[spec->num_mixers++] = mix;
790 static void add_verb(struct alc_spec *spec, const struct hda_verb *verb)
792 if (snd_BUG_ON(spec->num_init_verbs >= ARRAY_SIZE(spec->init_verbs)))
794 spec->init_verbs[spec->num_init_verbs++] = verb;
797 #ifdef CONFIG_PROC_FS
801 static void print_realtek_coef(struct snd_info_buffer *buffer,
802 struct hda_codec *codec, hda_nid_t nid)
808 coeff = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_PROC_COEF, 0);
809 snd_iprintf(buffer, " Processing Coefficient: 0x%02x\n", coeff);
810 coeff = snd_hda_codec_read(codec, nid, 0,
811 AC_VERB_GET_COEF_INDEX, 0);
812 snd_iprintf(buffer, " Coefficient Index: 0x%02x\n", coeff);
815 #define print_realtek_coef NULL
819 * set up from the preset table
821 static void setup_preset(struct alc_spec *spec,
822 const struct alc_config_preset *preset)
826 for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++)
827 add_mixer(spec, preset->mixers[i]);
828 spec->cap_mixer = preset->cap_mixer;
829 for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i];
831 add_verb(spec, preset->init_verbs[i]);
833 spec->channel_mode = preset->channel_mode;
834 spec->num_channel_mode = preset->num_channel_mode;
835 spec->need_dac_fix = preset->need_dac_fix;
837 spec->multiout.max_channels = spec->channel_mode[0].channels;
839 spec->multiout.num_dacs = preset->num_dacs;
840 spec->multiout.dac_nids = preset->dac_nids;
841 spec->multiout.dig_out_nid = preset->dig_out_nid;
842 spec->multiout.slave_dig_outs = preset->slave_dig_outs;
843 spec->multiout.hp_nid = preset->hp_nid;
845 spec->num_mux_defs = preset->num_mux_defs;
846 if (!spec->num_mux_defs)
847 spec->num_mux_defs = 1;
848 spec->input_mux = preset->input_mux;
850 spec->num_adc_nids = preset->num_adc_nids;
851 spec->adc_nids = preset->adc_nids;
852 spec->capsrc_nids = preset->capsrc_nids;
853 spec->dig_in_nid = preset->dig_in_nid;
855 spec->unsol_event = preset->unsol_event;
856 spec->init_hook = preset->init_hook;
857 #ifdef CONFIG_SND_HDA_POWER_SAVE
858 spec->loopback.amplist = preset->loopbacks;
862 /* Enable GPIO mask and set output */
863 static struct hda_verb alc_gpio1_init_verbs[] = {
864 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
865 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
866 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
870 static struct hda_verb alc_gpio2_init_verbs[] = {
871 {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
872 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
873 {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
877 static struct hda_verb alc_gpio3_init_verbs[] = {
878 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
879 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
880 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
885 * Fix hardware PLL issue
886 * On some codecs, the analog PLL gating control must be off while
887 * the default value is 1.
889 static void alc_fix_pll(struct hda_codec *codec)
891 struct alc_spec *spec = codec->spec;
896 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX,
898 val = snd_hda_codec_read(codec, spec->pll_nid, 0,
899 AC_VERB_GET_PROC_COEF, 0);
900 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX,
902 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_PROC_COEF,
903 val & ~(1 << spec->pll_coef_bit));
906 static void alc_fix_pll_init(struct hda_codec *codec, hda_nid_t nid,
907 unsigned int coef_idx, unsigned int coef_bit)
909 struct alc_spec *spec = codec->spec;
911 spec->pll_coef_idx = coef_idx;
912 spec->pll_coef_bit = coef_bit;
916 static void alc_sku_automute(struct hda_codec *codec)
918 struct alc_spec *spec = codec->spec;
919 unsigned int present;
920 unsigned int hp_nid = spec->autocfg.hp_pins[0];
921 unsigned int sp_nid = spec->autocfg.speaker_pins[0];
923 /* need to execute and sync at first */
924 snd_hda_codec_read(codec, hp_nid, 0, AC_VERB_SET_PIN_SENSE, 0);
925 present = snd_hda_codec_read(codec, hp_nid, 0,
926 AC_VERB_GET_PIN_SENSE, 0);
927 spec->jack_present = (present & 0x80000000) != 0;
928 snd_hda_codec_write(codec, sp_nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
929 spec->jack_present ? 0 : PIN_OUT);
932 #if 0 /* it's broken in some acses -- temporarily disabled */
933 static void alc_mic_automute(struct hda_codec *codec)
935 struct alc_spec *spec = codec->spec;
936 unsigned int present;
937 unsigned int mic_nid = spec->autocfg.input_pins[AUTO_PIN_MIC];
938 unsigned int fmic_nid = spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC];
939 unsigned int mix_nid = spec->capsrc_nids[0];
940 unsigned int capsrc_idx_mic, capsrc_idx_fmic;
942 capsrc_idx_mic = mic_nid - 0x18;
943 capsrc_idx_fmic = fmic_nid - 0x18;
944 present = snd_hda_codec_read(codec, mic_nid, 0,
945 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
946 snd_hda_codec_write(codec, mix_nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
947 0x7000 | (capsrc_idx_mic << 8) | (present ? 0 : 0x80));
948 snd_hda_codec_write(codec, mix_nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
949 0x7000 | (capsrc_idx_fmic << 8) | (present ? 0x80 : 0));
950 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, capsrc_idx_fmic,
951 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
954 #define alc_mic_automute(codec) do {} while(0) /* NOP */
955 #endif /* disabled */
957 /* unsolicited event for HP jack sensing */
958 static void alc_sku_unsol_event(struct hda_codec *codec, unsigned int res)
960 if (codec->vendor_id == 0x10ec0880)
964 if (res == ALC880_HP_EVENT)
965 alc_sku_automute(codec);
967 if (res == ALC880_MIC_EVENT)
968 alc_mic_automute(codec);
971 static void alc_inithook(struct hda_codec *codec)
973 alc_sku_automute(codec);
974 alc_mic_automute(codec);
977 /* additional initialization for ALC888 variants */
978 static void alc888_coef_init(struct hda_codec *codec)
982 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 0);
983 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
984 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
985 if ((tmp & 0xf0) == 0x20)
987 snd_hda_codec_read(codec, 0x20, 0,
988 AC_VERB_SET_PROC_COEF, 0x830);
991 snd_hda_codec_read(codec, 0x20, 0,
992 AC_VERB_SET_PROC_COEF, 0x3030);
995 /* 32-bit subsystem ID for BIOS loading in HD Audio codec.
996 * 31 ~ 16 : Manufacture ID
998 * 7 ~ 0 : Assembly ID
999 * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36
1001 static void alc_subsystem_id(struct hda_codec *codec,
1002 unsigned int porta, unsigned int porte,
1005 unsigned int ass, tmp, i;
1007 struct alc_spec *spec = codec->spec;
1009 ass = codec->subsystem_id & 0xffff;
1010 if ((ass != codec->bus->pci->subsystem_device) && (ass & 1))
1014 * 31~30 : port conetcivity
1017 * 19~16 : Check sum (15:1)
1022 if (codec->vendor_id == 0x10ec0260)
1024 ass = snd_hda_codec_get_pincfg(codec, nid);
1025 if (!(ass & 1) && !(ass & 0x100000))
1027 if ((ass >> 30) != 1) /* no physical connection */
1032 for (i = 1; i < 16; i++) {
1036 if (((ass >> 16) & 0xf) != tmp)
1042 * 2 : 0 --> Desktop, 1 --> Laptop
1043 * 3~5 : External Amplifier control
1046 tmp = (ass & 0x38) >> 3; /* external Amp control */
1049 snd_hda_sequence_write(codec, alc_gpio1_init_verbs);
1052 snd_hda_sequence_write(codec, alc_gpio2_init_verbs);
1055 snd_hda_sequence_write(codec, alc_gpio3_init_verbs);
1057 case 5: /* set EAPD output high */
1058 switch (codec->vendor_id) {
1060 snd_hda_codec_write(codec, 0x0f, 0,
1061 AC_VERB_SET_EAPD_BTLENABLE, 2);
1062 snd_hda_codec_write(codec, 0x10, 0,
1063 AC_VERB_SET_EAPD_BTLENABLE, 2);
1075 snd_hda_codec_write(codec, 0x14, 0,
1076 AC_VERB_SET_EAPD_BTLENABLE, 2);
1077 snd_hda_codec_write(codec, 0x15, 0,
1078 AC_VERB_SET_EAPD_BTLENABLE, 2);
1081 switch (codec->vendor_id) {
1083 snd_hda_codec_write(codec, 0x1a, 0,
1084 AC_VERB_SET_COEF_INDEX, 7);
1085 tmp = snd_hda_codec_read(codec, 0x1a, 0,
1086 AC_VERB_GET_PROC_COEF, 0);
1087 snd_hda_codec_write(codec, 0x1a, 0,
1088 AC_VERB_SET_COEF_INDEX, 7);
1089 snd_hda_codec_write(codec, 0x1a, 0,
1090 AC_VERB_SET_PROC_COEF,
1100 snd_hda_codec_write(codec, 0x20, 0,
1101 AC_VERB_SET_COEF_INDEX, 7);
1102 tmp = snd_hda_codec_read(codec, 0x20, 0,
1103 AC_VERB_GET_PROC_COEF, 0);
1104 snd_hda_codec_write(codec, 0x20, 0,
1105 AC_VERB_SET_COEF_INDEX, 7);
1106 snd_hda_codec_write(codec, 0x20, 0,
1107 AC_VERB_SET_PROC_COEF,
1111 /*alc888_coef_init(codec);*/ /* called in alc_init() */
1115 snd_hda_codec_write(codec, 0x20, 0,
1116 AC_VERB_SET_COEF_INDEX, 7);
1117 tmp = snd_hda_codec_read(codec, 0x20, 0,
1118 AC_VERB_GET_PROC_COEF, 0);
1119 snd_hda_codec_write(codec, 0x20, 0,
1120 AC_VERB_SET_COEF_INDEX, 7);
1121 snd_hda_codec_write(codec, 0x20, 0,
1122 AC_VERB_SET_PROC_COEF,
1130 /* is laptop or Desktop and enable the function "Mute internal speaker
1131 * when the external headphone out jack is plugged"
1133 if (!(ass & 0x8000))
1136 * 10~8 : Jack location
1137 * 12~11: Headphone out -> 00: PortA, 01: PortE, 02: PortD, 03: Resvered
1139 * 15 : 1 --> enable the function "Mute internal speaker
1140 * when the external headphone out jack is plugged"
1142 if (!spec->autocfg.speaker_pins[0]) {
1143 if (spec->autocfg.line_out_pins[0])
1144 spec->autocfg.speaker_pins[0] =
1145 spec->autocfg.line_out_pins[0];
1150 if (!spec->autocfg.hp_pins[0]) {
1151 tmp = (ass >> 11) & 0x3; /* HP to chassis */
1153 spec->autocfg.hp_pins[0] = porta;
1155 spec->autocfg.hp_pins[0] = porte;
1157 spec->autocfg.hp_pins[0] = portd;
1161 if (spec->autocfg.hp_pins[0])
1162 snd_hda_codec_write(codec, spec->autocfg.hp_pins[0], 0,
1163 AC_VERB_SET_UNSOLICITED_ENABLE,
1164 AC_USRSP_EN | ALC880_HP_EVENT);
1166 #if 0 /* it's broken in some acses -- temporarily disabled */
1167 if (spec->autocfg.input_pins[AUTO_PIN_MIC] &&
1168 spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC])
1169 snd_hda_codec_write(codec,
1170 spec->autocfg.input_pins[AUTO_PIN_MIC], 0,
1171 AC_VERB_SET_UNSOLICITED_ENABLE,
1172 AC_USRSP_EN | ALC880_MIC_EVENT);
1173 #endif /* disabled */
1175 spec->unsol_event = alc_sku_unsol_event;
1179 * Fix-up pin default configurations
1187 static void alc_fix_pincfg(struct hda_codec *codec,
1188 const struct snd_pci_quirk *quirk,
1189 const struct alc_pincfg **pinfix)
1191 const struct alc_pincfg *cfg;
1193 quirk = snd_pci_quirk_lookup(codec->bus->pci, quirk);
1197 cfg = pinfix[quirk->value];
1198 for (; cfg->nid; cfg++)
1199 snd_hda_codec_set_pincfg(codec, cfg->nid, cfg->val);
1209 static struct hda_verb alc888_4ST_ch2_intel_init[] = {
1210 /* Mic-in jack as mic in */
1211 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1212 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1213 /* Line-in jack as Line in */
1214 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1215 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1216 /* Line-Out as Front */
1217 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
1224 static struct hda_verb alc888_4ST_ch4_intel_init[] = {
1225 /* Mic-in jack as mic in */
1226 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1227 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1228 /* Line-in jack as Surround */
1229 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1230 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1231 /* Line-Out as Front */
1232 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
1239 static struct hda_verb alc888_4ST_ch6_intel_init[] = {
1240 /* Mic-in jack as CLFE */
1241 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1242 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1243 /* Line-in jack as Surround */
1244 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1245 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1246 /* Line-Out as CLFE (workaround because Mic-in is not loud enough) */
1247 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1254 static struct hda_verb alc888_4ST_ch8_intel_init[] = {
1255 /* Mic-in jack as CLFE */
1256 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1257 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1258 /* Line-in jack as Surround */
1259 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1260 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1261 /* Line-Out as Side */
1262 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1266 static struct hda_channel_mode alc888_4ST_8ch_intel_modes[4] = {
1267 { 2, alc888_4ST_ch2_intel_init },
1268 { 4, alc888_4ST_ch4_intel_init },
1269 { 6, alc888_4ST_ch6_intel_init },
1270 { 8, alc888_4ST_ch8_intel_init },
1274 * ALC888 Fujitsu Siemens Amillo xa3530
1277 static struct hda_verb alc888_fujitsu_xa3530_verbs[] = {
1278 /* Front Mic: set to PIN_IN (empty by default) */
1279 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1280 /* Connect Internal HP to Front */
1281 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1282 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1283 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1284 /* Connect Bass HP to Front */
1285 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1286 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1287 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1288 /* Connect Line-Out side jack (SPDIF) to Side */
1289 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1290 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1291 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1292 /* Connect Mic jack to CLFE */
1293 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1294 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1295 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02},
1296 /* Connect Line-in jack to Surround */
1297 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1298 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1299 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
1300 /* Connect HP out jack to Front */
1301 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1302 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1303 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
1304 /* Enable unsolicited event for HP jack and Line-out jack */
1305 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1306 {0x17, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1310 static void alc888_fujitsu_xa3530_automute(struct hda_codec *codec)
1312 unsigned int present;
1314 /* Line out presence */
1315 present = snd_hda_codec_read(codec, 0x17, 0,
1316 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1317 /* HP out presence */
1318 present = present || snd_hda_codec_read(codec, 0x1b, 0,
1319 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1320 bits = present ? HDA_AMP_MUTE : 0;
1321 /* Toggle internal speakers muting */
1322 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
1323 HDA_AMP_MUTE, bits);
1324 /* Toggle internal bass muting */
1325 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
1326 HDA_AMP_MUTE, bits);
1329 static void alc888_fujitsu_xa3530_unsol_event(struct hda_codec *codec,
1332 if (res >> 26 == ALC880_HP_EVENT)
1333 alc888_fujitsu_xa3530_automute(codec);
1338 * ALC888 Acer Aspire 4930G model
1341 static struct hda_verb alc888_acer_aspire_4930g_verbs[] = {
1342 /* Front Mic: set to PIN_IN (empty by default) */
1343 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1344 /* Unselect Front Mic by default in input mixer 3 */
1345 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
1346 /* Enable unsolicited event for HP jack */
1347 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1348 /* Connect Internal HP to front */
1349 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1350 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1351 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1352 /* Connect HP out to front */
1353 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1354 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1355 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1359 static struct hda_input_mux alc888_2_capture_sources[2] = {
1360 /* Front mic only available on one ADC */
1367 { "Front Mic", 0xb },
1380 static struct snd_kcontrol_new alc888_base_mixer[] = {
1381 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1382 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1383 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1384 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
1385 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
1387 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1388 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1389 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1390 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
1391 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
1392 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1393 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1394 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1395 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1396 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1397 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
1398 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1402 static void alc888_acer_aspire_4930g_automute(struct hda_codec *codec)
1404 unsigned int present;
1406 present = snd_hda_codec_read(codec, 0x15, 0,
1407 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1408 bits = present ? HDA_AMP_MUTE : 0;
1409 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
1410 HDA_AMP_MUTE, bits);
1413 static void alc888_acer_aspire_4930g_unsol_event(struct hda_codec *codec,
1416 if (res >> 26 == ALC880_HP_EVENT)
1417 alc888_acer_aspire_4930g_automute(codec);
1421 * ALC880 3-stack model
1423 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
1424 * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18,
1425 * F-Mic = 0x1b, HP = 0x19
1428 static hda_nid_t alc880_dac_nids[4] = {
1429 /* front, rear, clfe, rear_surr */
1430 0x02, 0x05, 0x04, 0x03
1433 static hda_nid_t alc880_adc_nids[3] = {
1438 /* The datasheet says the node 0x07 is connected from inputs,
1439 * but it shows zero connection in the real implementation on some devices.
1440 * Note: this is a 915GAV bug, fixed on 915GLV
1442 static hda_nid_t alc880_adc_nids_alt[2] = {
1447 #define ALC880_DIGOUT_NID 0x06
1448 #define ALC880_DIGIN_NID 0x0a
1450 static struct hda_input_mux alc880_capture_source = {
1454 { "Front Mic", 0x3 },
1460 /* channel source setting (2/6 channel selection for 3-stack) */
1462 static struct hda_verb alc880_threestack_ch2_init[] = {
1463 /* set line-in to input, mute it */
1464 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1465 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1466 /* set mic-in to input vref 80%, mute it */
1467 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1468 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1473 static struct hda_verb alc880_threestack_ch6_init[] = {
1474 /* set line-in to output, unmute it */
1475 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1476 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1477 /* set mic-in to output, unmute it */
1478 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1479 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1483 static struct hda_channel_mode alc880_threestack_modes[2] = {
1484 { 2, alc880_threestack_ch2_init },
1485 { 6, alc880_threestack_ch6_init },
1488 static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
1489 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1490 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1491 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
1492 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
1493 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1494 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1495 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1496 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1497 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1498 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1499 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1500 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1501 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1502 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1503 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
1504 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
1505 HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
1507 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1508 .name = "Channel Mode",
1509 .info = alc_ch_mode_info,
1510 .get = alc_ch_mode_get,
1511 .put = alc_ch_mode_put,
1516 /* capture mixer elements */
1517 static int alc_cap_vol_info(struct snd_kcontrol *kcontrol,
1518 struct snd_ctl_elem_info *uinfo)
1520 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1521 struct alc_spec *spec = codec->spec;
1524 mutex_lock(&codec->control_mutex);
1525 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0,
1527 err = snd_hda_mixer_amp_volume_info(kcontrol, uinfo);
1528 mutex_unlock(&codec->control_mutex);
1532 static int alc_cap_vol_tlv(struct snd_kcontrol *kcontrol, int op_flag,
1533 unsigned int size, unsigned int __user *tlv)
1535 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1536 struct alc_spec *spec = codec->spec;
1539 mutex_lock(&codec->control_mutex);
1540 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0,
1542 err = snd_hda_mixer_amp_tlv(kcontrol, op_flag, size, tlv);
1543 mutex_unlock(&codec->control_mutex);
1547 typedef int (*getput_call_t)(struct snd_kcontrol *kcontrol,
1548 struct snd_ctl_elem_value *ucontrol);
1550 static int alc_cap_getput_caller(struct snd_kcontrol *kcontrol,
1551 struct snd_ctl_elem_value *ucontrol,
1554 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1555 struct alc_spec *spec = codec->spec;
1556 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
1559 mutex_lock(&codec->control_mutex);
1560 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[adc_idx],
1562 err = func(kcontrol, ucontrol);
1563 mutex_unlock(&codec->control_mutex);
1567 static int alc_cap_vol_get(struct snd_kcontrol *kcontrol,
1568 struct snd_ctl_elem_value *ucontrol)
1570 return alc_cap_getput_caller(kcontrol, ucontrol,
1571 snd_hda_mixer_amp_volume_get);
1574 static int alc_cap_vol_put(struct snd_kcontrol *kcontrol,
1575 struct snd_ctl_elem_value *ucontrol)
1577 return alc_cap_getput_caller(kcontrol, ucontrol,
1578 snd_hda_mixer_amp_volume_put);
1581 /* capture mixer elements */
1582 #define alc_cap_sw_info snd_ctl_boolean_stereo_info
1584 static int alc_cap_sw_get(struct snd_kcontrol *kcontrol,
1585 struct snd_ctl_elem_value *ucontrol)
1587 return alc_cap_getput_caller(kcontrol, ucontrol,
1588 snd_hda_mixer_amp_switch_get);
1591 static int alc_cap_sw_put(struct snd_kcontrol *kcontrol,
1592 struct snd_ctl_elem_value *ucontrol)
1594 return alc_cap_getput_caller(kcontrol, ucontrol,
1595 snd_hda_mixer_amp_switch_put);
1598 #define DEFINE_CAPMIX(num) \
1599 static struct snd_kcontrol_new alc_capture_mixer ## num[] = { \
1601 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1602 .name = "Capture Switch", \
1603 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, \
1605 .info = alc_cap_sw_info, \
1606 .get = alc_cap_sw_get, \
1607 .put = alc_cap_sw_put, \
1610 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1611 .name = "Capture Volume", \
1612 .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE | \
1613 SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
1614 SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK), \
1616 .info = alc_cap_vol_info, \
1617 .get = alc_cap_vol_get, \
1618 .put = alc_cap_vol_put, \
1619 .tlv = { .c = alc_cap_vol_tlv }, \
1622 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1623 /* .name = "Capture Source", */ \
1624 .name = "Input Source", \
1626 .info = alc_mux_enum_info, \
1627 .get = alc_mux_enum_get, \
1628 .put = alc_mux_enum_put, \
1633 /* up to three ADCs */
1640 * ALC880 5-stack model
1642 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d),
1644 * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
1645 * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
1648 /* additional mixers to alc880_three_stack_mixer */
1649 static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
1650 HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1651 HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
1655 /* channel source setting (6/8 channel selection for 5-stack) */
1657 static struct hda_verb alc880_fivestack_ch6_init[] = {
1658 /* set line-in to input, mute it */
1659 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1660 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1665 static struct hda_verb alc880_fivestack_ch8_init[] = {
1666 /* set line-in to output, unmute it */
1667 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1668 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1672 static struct hda_channel_mode alc880_fivestack_modes[2] = {
1673 { 6, alc880_fivestack_ch6_init },
1674 { 8, alc880_fivestack_ch8_init },
1679 * ALC880 6-stack model
1681 * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e),
1682 * Side = 0x05 (0x0f)
1683 * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
1684 * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
1687 static hda_nid_t alc880_6st_dac_nids[4] = {
1688 /* front, rear, clfe, rear_surr */
1689 0x02, 0x03, 0x04, 0x05
1692 static struct hda_input_mux alc880_6stack_capture_source = {
1696 { "Front Mic", 0x1 },
1702 /* fixed 8-channels */
1703 static struct hda_channel_mode alc880_sixstack_modes[1] = {
1707 static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
1708 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1709 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1710 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1711 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
1712 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1713 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1714 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1715 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1716 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
1717 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
1718 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1719 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1720 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1721 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1722 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1723 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1724 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1725 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1727 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1728 .name = "Channel Mode",
1729 .info = alc_ch_mode_info,
1730 .get = alc_ch_mode_get,
1731 .put = alc_ch_mode_put,
1740 * W810 has rear IO for:
1743 * Center/LFE (DAC 04)
1746 * The system also has a pair of internal speakers, and a headphone jack.
1747 * These are both connected to Line2 on the codec, hence to DAC 02.
1749 * There is a variable resistor to control the speaker or headphone
1750 * volume. This is a hardware-only device without a software API.
1752 * Plugging headphones in will disable the internal speakers. This is
1753 * implemented in hardware, not via the driver using jack sense. In
1754 * a similar fashion, plugging into the rear socket marked "front" will
1755 * disable both the speakers and headphones.
1757 * For input, there's a microphone jack, and an "audio in" jack.
1758 * These may not do anything useful with this driver yet, because I
1759 * haven't setup any initialization verbs for these yet...
1762 static hda_nid_t alc880_w810_dac_nids[3] = {
1763 /* front, rear/surround, clfe */
1767 /* fixed 6 channels */
1768 static struct hda_channel_mode alc880_w810_modes[1] = {
1772 /* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
1773 static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
1774 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1775 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1776 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1777 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
1778 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1779 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1780 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1781 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1782 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
1790 * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
1791 * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?),
1795 static hda_nid_t alc880_z71v_dac_nids[1] = {
1798 #define ALC880_Z71V_HP_DAC 0x03
1800 /* fixed 2 channels */
1801 static struct hda_channel_mode alc880_2_jack_modes[1] = {
1805 static struct snd_kcontrol_new alc880_z71v_mixer[] = {
1806 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1807 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1808 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1809 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
1810 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1811 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1812 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1813 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1819 * ALC880 F1734 model
1821 * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
1822 * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
1825 static hda_nid_t alc880_f1734_dac_nids[1] = {
1828 #define ALC880_F1734_HP_DAC 0x02
1830 static struct snd_kcontrol_new alc880_f1734_mixer[] = {
1831 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1832 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
1833 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1834 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
1835 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1836 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1837 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1838 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1842 static struct hda_input_mux alc880_f1734_capture_source = {
1854 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
1855 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
1856 * Mic = 0x18, Line = 0x1a
1859 #define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
1860 #define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
1862 static struct snd_kcontrol_new alc880_asus_mixer[] = {
1863 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1864 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1865 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1866 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
1867 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1868 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1869 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1870 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1871 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1872 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1873 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1874 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1875 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1876 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1878 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1879 .name = "Channel Mode",
1880 .info = alc_ch_mode_info,
1881 .get = alc_ch_mode_get,
1882 .put = alc_ch_mode_put,
1888 * ALC880 ASUS W1V model
1890 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
1891 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
1892 * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
1895 /* additional mixers to alc880_asus_mixer */
1896 static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
1897 HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
1898 HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
1903 static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
1904 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1905 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
1906 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
1907 HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
1908 HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
1909 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
1910 HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
1911 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
1912 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
1917 static struct snd_kcontrol_new alc880_uniwill_mixer[] = {
1918 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1919 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
1920 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1921 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
1922 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1923 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1924 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1925 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1926 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1927 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1928 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1929 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1930 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1931 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1932 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1933 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1935 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1936 .name = "Channel Mode",
1937 .info = alc_ch_mode_info,
1938 .get = alc_ch_mode_get,
1939 .put = alc_ch_mode_put,
1944 static struct snd_kcontrol_new alc880_fujitsu_mixer[] = {
1945 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1946 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
1947 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1948 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
1949 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1950 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1951 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1952 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1953 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1954 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1958 static struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = {
1959 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1960 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
1961 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1962 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
1963 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1964 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1969 * virtual master controls
1973 * slave controls for virtual master
1975 static const char *alc_slave_vols[] = {
1976 "Front Playback Volume",
1977 "Surround Playback Volume",
1978 "Center Playback Volume",
1979 "LFE Playback Volume",
1980 "Side Playback Volume",
1981 "Headphone Playback Volume",
1982 "Speaker Playback Volume",
1983 "Mono Playback Volume",
1984 "Line-Out Playback Volume",
1985 "PCM Playback Volume",
1989 static const char *alc_slave_sws[] = {
1990 "Front Playback Switch",
1991 "Surround Playback Switch",
1992 "Center Playback Switch",
1993 "LFE Playback Switch",
1994 "Side Playback Switch",
1995 "Headphone Playback Switch",
1996 "Speaker Playback Switch",
1997 "Mono Playback Switch",
1998 "IEC958 Playback Switch",
2003 * build control elements
2006 static void alc_free_kctls(struct hda_codec *codec);
2008 /* additional beep mixers; the actual parameters are overwritten at build */
2009 static struct snd_kcontrol_new alc_beep_mixer[] = {
2010 HDA_CODEC_VOLUME("Beep Playback Volume", 0, 0, HDA_INPUT),
2011 HDA_CODEC_MUTE("Beep Playback Switch", 0, 0, HDA_INPUT),
2015 static int alc_build_controls(struct hda_codec *codec)
2017 struct alc_spec *spec = codec->spec;
2021 for (i = 0; i < spec->num_mixers; i++) {
2022 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
2026 if (spec->cap_mixer) {
2027 err = snd_hda_add_new_ctls(codec, spec->cap_mixer);
2031 if (spec->multiout.dig_out_nid) {
2032 err = snd_hda_create_spdif_out_ctls(codec,
2033 spec->multiout.dig_out_nid);
2036 if (!spec->no_analog) {
2037 err = snd_hda_create_spdif_share_sw(codec,
2041 spec->multiout.share_spdif = 1;
2044 if (spec->dig_in_nid) {
2045 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
2050 /* create beep controls if needed */
2051 if (spec->beep_amp) {
2052 struct snd_kcontrol_new *knew;
2053 for (knew = alc_beep_mixer; knew->name; knew++) {
2054 struct snd_kcontrol *kctl;
2055 kctl = snd_ctl_new1(knew, codec);
2058 kctl->private_value = spec->beep_amp;
2059 err = snd_hda_ctl_add(codec, kctl);
2065 /* if we have no master control, let's create it */
2066 if (!spec->no_analog &&
2067 !snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
2068 unsigned int vmaster_tlv[4];
2069 snd_hda_set_vmaster_tlv(codec, spec->vmaster_nid,
2070 HDA_OUTPUT, vmaster_tlv);
2071 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
2072 vmaster_tlv, alc_slave_vols);
2076 if (!spec->no_analog &&
2077 !snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
2078 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
2079 NULL, alc_slave_sws);
2084 alc_free_kctls(codec); /* no longer needed */
2090 * initialize the codec volumes, etc
2094 * generic initialization of ADC, input mixers and output mixers
2096 static struct hda_verb alc880_volume_init_verbs[] = {
2098 * Unmute ADC0-2 and set the default input to mic-in
2100 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
2101 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2102 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
2103 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2104 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
2105 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2107 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
2109 * Note: PASD motherboards uses the Line In 2 as the input for front
2112 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
2113 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2114 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2115 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
2116 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
2117 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
2118 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
2119 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
2122 * Set up output mixers (0x0c - 0x0f)
2124 /* set vol=0 to output mixers */
2125 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2126 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2127 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2128 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2129 /* set up input amps for analog loopback */
2130 /* Amp Indices: DAC = 0, mixer = 1 */
2131 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2132 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2133 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2134 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2135 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2136 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2137 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2138 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2144 * 3-stack pin configuration:
2145 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
2147 static struct hda_verb alc880_pin_3stack_init_verbs[] = {
2149 * preset connection lists of input pins
2150 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
2152 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
2153 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2154 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
2157 * Set pin mode and muting
2159 /* set front pin widgets 0x14 for output */
2160 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2161 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2162 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2163 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2164 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2165 /* Mic2 (as headphone out) for HP output */
2166 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2167 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2168 /* Line In pin widget for input */
2169 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2170 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2171 /* Line2 (as front mic) pin widget for input and vref at 80% */
2172 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2173 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2174 /* CD pin widget for input */
2175 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2181 * 5-stack pin configuration:
2182 * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
2183 * line-in/side = 0x1a, f-mic = 0x1b
2185 static struct hda_verb alc880_pin_5stack_init_verbs[] = {
2187 * preset connection lists of input pins
2188 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
2190 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2191 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
2194 * Set pin mode and muting
2196 /* set pin widgets 0x14-0x17 for output */
2197 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2198 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2199 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2200 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2201 /* unmute pins for output (no gain on this amp) */
2202 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2203 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2204 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2205 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2207 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2208 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2209 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2210 /* Mic2 (as headphone out) for HP output */
2211 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2212 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2213 /* Line In pin widget for input */
2214 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2215 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2216 /* Line2 (as front mic) pin widget for input and vref at 80% */
2217 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2218 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2219 /* CD pin widget for input */
2220 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2226 * W810 pin configuration:
2227 * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
2229 static struct hda_verb alc880_pin_w810_init_verbs[] = {
2230 /* hphone/speaker input selector: front DAC */
2231 {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
2233 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2234 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2235 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2236 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2237 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2238 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2240 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2241 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2247 * Z71V pin configuration:
2248 * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
2250 static struct hda_verb alc880_pin_z71v_init_verbs[] = {
2251 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2252 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2253 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2254 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2256 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2257 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2258 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2259 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2265 * 6-stack pin configuration:
2266 * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18,
2267 * f-mic = 0x19, line = 0x1a, HP = 0x1b
2269 static struct hda_verb alc880_pin_6stack_init_verbs[] = {
2270 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2272 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2273 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2274 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2275 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2276 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2277 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2278 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2279 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2281 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2282 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2283 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2284 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2285 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2286 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2287 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2288 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2289 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2295 * Uniwill pin configuration:
2296 * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19,
2299 static struct hda_verb alc880_uniwill_init_verbs[] = {
2300 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2302 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2303 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2304 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2305 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2306 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2307 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2308 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2309 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2310 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2311 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2312 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2313 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2314 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2315 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2317 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2318 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2319 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2320 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2321 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2322 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2323 /* {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, */
2324 /* {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
2325 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2327 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
2328 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
2335 * HP = 0x14, InternalSpeaker = 0x15, mic = 0x19,
2337 static struct hda_verb alc880_uniwill_p53_init_verbs[] = {
2338 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2340 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2341 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2342 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2343 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2344 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2345 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2346 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2347 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2348 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2349 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2350 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2351 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2353 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2354 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2355 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2356 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2357 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2358 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2360 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
2361 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_DCVOL_EVENT},
2366 static struct hda_verb alc880_beep_init_verbs[] = {
2367 { 0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5) },
2371 /* toggle speaker-output according to the hp-jack state */
2372 static void alc880_uniwill_hp_automute(struct hda_codec *codec)
2374 unsigned int present;
2377 present = snd_hda_codec_read(codec, 0x14, 0,
2378 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
2379 bits = present ? HDA_AMP_MUTE : 0;
2380 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
2381 HDA_AMP_MUTE, bits);
2382 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
2383 HDA_AMP_MUTE, bits);
2386 /* auto-toggle front mic */
2387 static void alc880_uniwill_mic_automute(struct hda_codec *codec)
2389 unsigned int present;
2392 present = snd_hda_codec_read(codec, 0x18, 0,
2393 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
2394 bits = present ? HDA_AMP_MUTE : 0;
2395 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
2398 static void alc880_uniwill_automute(struct hda_codec *codec)
2400 alc880_uniwill_hp_automute(codec);
2401 alc880_uniwill_mic_automute(codec);
2404 static void alc880_uniwill_unsol_event(struct hda_codec *codec,
2407 /* Looks like the unsol event is incompatible with the standard
2408 * definition. 4bit tag is placed at 28 bit!
2410 switch (res >> 28) {
2411 case ALC880_HP_EVENT:
2412 alc880_uniwill_hp_automute(codec);
2414 case ALC880_MIC_EVENT:
2415 alc880_uniwill_mic_automute(codec);
2420 static void alc880_uniwill_p53_hp_automute(struct hda_codec *codec)
2422 unsigned int present;
2425 present = snd_hda_codec_read(codec, 0x14, 0,
2426 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
2427 bits = present ? HDA_AMP_MUTE : 0;
2428 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, HDA_AMP_MUTE, bits);
2431 static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec)
2433 unsigned int present;
2435 present = snd_hda_codec_read(codec, 0x21, 0,
2436 AC_VERB_GET_VOLUME_KNOB_CONTROL, 0);
2437 present &= HDA_AMP_VOLMASK;
2438 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0,
2439 HDA_AMP_VOLMASK, present);
2440 snd_hda_codec_amp_stereo(codec, 0x0d, HDA_OUTPUT, 0,
2441 HDA_AMP_VOLMASK, present);
2444 static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec,
2447 /* Looks like the unsol event is incompatible with the standard
2448 * definition. 4bit tag is placed at 28 bit!
2450 if ((res >> 28) == ALC880_HP_EVENT)
2451 alc880_uniwill_p53_hp_automute(codec);
2452 if ((res >> 28) == ALC880_DCVOL_EVENT)
2453 alc880_uniwill_p53_dcvol_automute(codec);
2457 * F1734 pin configuration:
2458 * HP = 0x14, speaker-out = 0x15, mic = 0x18
2460 static struct hda_verb alc880_pin_f1734_init_verbs[] = {
2461 {0x07, AC_VERB_SET_CONNECT_SEL, 0x01},
2462 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
2463 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
2464 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
2465 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
2467 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2468 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2469 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2470 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2472 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2473 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2474 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
2475 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2476 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2477 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2478 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2479 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2480 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2482 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
2483 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_DCVOL_EVENT},
2489 * ASUS pin configuration:
2490 * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
2492 static struct hda_verb alc880_pin_asus_init_verbs[] = {
2493 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
2494 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
2495 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
2496 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
2498 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2499 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2500 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2501 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2502 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2503 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2504 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2505 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2507 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2508 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2509 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2510 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2511 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2512 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2513 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2514 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2515 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2520 /* Enable GPIO mask and set output */
2521 #define alc880_gpio1_init_verbs alc_gpio1_init_verbs
2522 #define alc880_gpio2_init_verbs alc_gpio2_init_verbs
2524 /* Clevo m520g init */
2525 static struct hda_verb alc880_pin_clevo_init_verbs[] = {
2526 /* headphone output */
2527 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
2529 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2530 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2532 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2533 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2535 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2536 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2537 /* Mic1 (rear panel) */
2538 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2539 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2540 /* Mic2 (front panel) */
2541 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2542 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2544 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2545 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2546 /* change to EAPD mode */
2547 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2548 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
2553 static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
2554 /* change to EAPD mode */
2555 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2556 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
2558 /* Headphone output */
2559 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2561 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2562 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
2564 /* Line In pin widget for input */
2565 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2566 /* CD pin widget for input */
2567 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2568 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2569 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2571 /* change to EAPD mode */
2572 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2573 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
2579 * LG m1 express dual
2582 * Rear Line-In/Out (blue): 0x14
2583 * Build-in Mic-In: 0x15
2585 * HP-Out (green): 0x1b
2586 * Mic-In/Out (red): 0x19
2590 /* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
2591 static hda_nid_t alc880_lg_dac_nids[3] = {
2595 /* seems analog CD is not working */
2596 static struct hda_input_mux alc880_lg_capture_source = {
2601 { "Internal Mic", 0x6 },
2605 /* 2,4,6 channel modes */
2606 static struct hda_verb alc880_lg_ch2_init[] = {
2607 /* set line-in and mic-in to input */
2608 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
2609 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
2613 static struct hda_verb alc880_lg_ch4_init[] = {
2614 /* set line-in to out and mic-in to input */
2615 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
2616 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
2620 static struct hda_verb alc880_lg_ch6_init[] = {
2621 /* set line-in and mic-in to output */
2622 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
2623 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
2627 static struct hda_channel_mode alc880_lg_ch_modes[3] = {
2628 { 2, alc880_lg_ch2_init },
2629 { 4, alc880_lg_ch4_init },
2630 { 6, alc880_lg_ch6_init },
2633 static struct snd_kcontrol_new alc880_lg_mixer[] = {
2634 HDA_CODEC_VOLUME("Front Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
2635 HDA_BIND_MUTE("Front Playback Switch", 0x0f, 2, HDA_INPUT),
2636 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2637 HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
2638 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
2639 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
2640 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
2641 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
2642 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2643 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
2644 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
2645 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
2646 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
2647 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
2649 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2650 .name = "Channel Mode",
2651 .info = alc_ch_mode_info,
2652 .get = alc_ch_mode_get,
2653 .put = alc_ch_mode_put,
2658 static struct hda_verb alc880_lg_init_verbs[] = {
2659 /* set capture source to mic-in */
2660 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2661 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2662 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2663 /* mute all amp mixer inputs */
2664 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
2665 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
2666 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
2667 /* line-in to input */
2668 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2669 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2671 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2672 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2674 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2675 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2676 /* mic-in to input */
2677 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
2678 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2679 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2681 {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
2682 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2683 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2685 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
2689 /* toggle speaker-output according to the hp-jack state */
2690 static void alc880_lg_automute(struct hda_codec *codec)
2692 unsigned int present;
2695 present = snd_hda_codec_read(codec, 0x1b, 0,
2696 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
2697 bits = present ? HDA_AMP_MUTE : 0;
2698 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
2699 HDA_AMP_MUTE, bits);
2702 static void alc880_lg_unsol_event(struct hda_codec *codec, unsigned int res)
2704 /* Looks like the unsol event is incompatible with the standard
2705 * definition. 4bit tag is placed at 28 bit!
2707 if ((res >> 28) == 0x01)
2708 alc880_lg_automute(codec);
2717 * Built-in Mic-In: 0x19
2723 static struct hda_input_mux alc880_lg_lw_capture_source = {
2727 { "Internal Mic", 0x1 },
2732 #define alc880_lg_lw_modes alc880_threestack_modes
2734 static struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
2735 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2736 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2737 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
2738 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
2739 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2740 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2741 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2742 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2743 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2744 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2745 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2746 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2747 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
2748 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
2750 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2751 .name = "Channel Mode",
2752 .info = alc_ch_mode_info,
2753 .get = alc_ch_mode_get,
2754 .put = alc_ch_mode_put,
2759 static struct hda_verb alc880_lg_lw_init_verbs[] = {
2760 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2761 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
2762 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
2764 /* set capture source to mic-in */
2765 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2766 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2767 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2768 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
2770 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2771 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2773 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2774 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2775 /* mic-in to input */
2776 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2777 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2779 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2780 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2782 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
2786 /* toggle speaker-output according to the hp-jack state */
2787 static void alc880_lg_lw_automute(struct hda_codec *codec)
2789 unsigned int present;
2792 present = snd_hda_codec_read(codec, 0x1b, 0,
2793 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
2794 bits = present ? HDA_AMP_MUTE : 0;
2795 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
2796 HDA_AMP_MUTE, bits);
2799 static void alc880_lg_lw_unsol_event(struct hda_codec *codec, unsigned int res)
2801 /* Looks like the unsol event is incompatible with the standard
2802 * definition. 4bit tag is placed at 28 bit!
2804 if ((res >> 28) == 0x01)
2805 alc880_lg_lw_automute(codec);
2808 static struct snd_kcontrol_new alc880_medion_rim_mixer[] = {
2809 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2810 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
2811 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2812 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2813 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2814 HDA_CODEC_MUTE("Internal Playback Switch", 0x0b, 0x1, HDA_INPUT),
2818 static struct hda_input_mux alc880_medion_rim_capture_source = {
2822 { "Internal Mic", 0x1 },
2826 static struct hda_verb alc880_medion_rim_init_verbs[] = {
2827 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2829 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2830 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2832 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2833 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2834 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2835 /* Mic2 (as headphone out) for HP output */
2836 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2837 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2838 /* Internal Speaker */
2839 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2840 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2842 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2843 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
2845 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
2849 /* toggle speaker-output according to the hp-jack state */
2850 static void alc880_medion_rim_automute(struct hda_codec *codec)
2852 unsigned int present;
2855 present = snd_hda_codec_read(codec, 0x14, 0,
2856 AC_VERB_GET_PIN_SENSE, 0)
2857 & AC_PINSENSE_PRESENCE;
2858 bits = present ? HDA_AMP_MUTE : 0;
2859 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
2860 HDA_AMP_MUTE, bits);
2862 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 0);
2864 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 2);
2867 static void alc880_medion_rim_unsol_event(struct hda_codec *codec,
2870 /* Looks like the unsol event is incompatible with the standard
2871 * definition. 4bit tag is placed at 28 bit!
2873 if ((res >> 28) == ALC880_HP_EVENT)
2874 alc880_medion_rim_automute(codec);
2877 #ifdef CONFIG_SND_HDA_POWER_SAVE
2878 static struct hda_amp_list alc880_loopbacks[] = {
2879 { 0x0b, HDA_INPUT, 0 },
2880 { 0x0b, HDA_INPUT, 1 },
2881 { 0x0b, HDA_INPUT, 2 },
2882 { 0x0b, HDA_INPUT, 3 },
2883 { 0x0b, HDA_INPUT, 4 },
2887 static struct hda_amp_list alc880_lg_loopbacks[] = {
2888 { 0x0b, HDA_INPUT, 1 },
2889 { 0x0b, HDA_INPUT, 6 },
2890 { 0x0b, HDA_INPUT, 7 },
2899 static int alc_init(struct hda_codec *codec)
2901 struct alc_spec *spec = codec->spec;
2905 if (codec->vendor_id == 0x10ec0888)
2906 alc888_coef_init(codec);
2908 for (i = 0; i < spec->num_init_verbs; i++)
2909 snd_hda_sequence_write(codec, spec->init_verbs[i]);
2911 if (spec->init_hook)
2912 spec->init_hook(codec);
2917 static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
2919 struct alc_spec *spec = codec->spec;
2921 if (spec->unsol_event)
2922 spec->unsol_event(codec, res);
2925 #ifdef CONFIG_SND_HDA_POWER_SAVE
2926 static int alc_check_power_status(struct hda_codec *codec, hda_nid_t nid)
2928 struct alc_spec *spec = codec->spec;
2929 return snd_hda_check_amp_list_power(codec, &spec->loopback, nid);
2934 * Analog playback callbacks
2936 static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
2937 struct hda_codec *codec,
2938 struct snd_pcm_substream *substream)
2940 struct alc_spec *spec = codec->spec;
2941 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
2945 static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2946 struct hda_codec *codec,
2947 unsigned int stream_tag,
2948 unsigned int format,
2949 struct snd_pcm_substream *substream)
2951 struct alc_spec *spec = codec->spec;
2952 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
2953 stream_tag, format, substream);
2956 static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
2957 struct hda_codec *codec,
2958 struct snd_pcm_substream *substream)
2960 struct alc_spec *spec = codec->spec;
2961 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
2967 static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
2968 struct hda_codec *codec,
2969 struct snd_pcm_substream *substream)
2971 struct alc_spec *spec = codec->spec;
2972 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
2975 static int alc880_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2976 struct hda_codec *codec,
2977 unsigned int stream_tag,
2978 unsigned int format,
2979 struct snd_pcm_substream *substream)
2981 struct alc_spec *spec = codec->spec;
2982 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
2983 stream_tag, format, substream);
2986 static int alc880_dig_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
2987 struct hda_codec *codec,
2988 struct snd_pcm_substream *substream)
2990 struct alc_spec *spec = codec->spec;
2991 return snd_hda_multi_out_dig_cleanup(codec, &spec->multiout);
2994 static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
2995 struct hda_codec *codec,
2996 struct snd_pcm_substream *substream)
2998 struct alc_spec *spec = codec->spec;
2999 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
3005 static int alc880_alt_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
3006 struct hda_codec *codec,
3007 unsigned int stream_tag,
3008 unsigned int format,
3009 struct snd_pcm_substream *substream)
3011 struct alc_spec *spec = codec->spec;
3013 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number + 1],
3014 stream_tag, 0, format);
3018 static int alc880_alt_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
3019 struct hda_codec *codec,
3020 struct snd_pcm_substream *substream)
3022 struct alc_spec *spec = codec->spec;
3024 snd_hda_codec_cleanup_stream(codec,
3025 spec->adc_nids[substream->number + 1]);
3032 static struct hda_pcm_stream alc880_pcm_analog_playback = {
3036 /* NID is set in alc_build_pcms */
3038 .open = alc880_playback_pcm_open,
3039 .prepare = alc880_playback_pcm_prepare,
3040 .cleanup = alc880_playback_pcm_cleanup
3044 static struct hda_pcm_stream alc880_pcm_analog_capture = {
3048 /* NID is set in alc_build_pcms */
3051 static struct hda_pcm_stream alc880_pcm_analog_alt_playback = {
3055 /* NID is set in alc_build_pcms */
3058 static struct hda_pcm_stream alc880_pcm_analog_alt_capture = {
3059 .substreams = 2, /* can be overridden */
3062 /* NID is set in alc_build_pcms */
3064 .prepare = alc880_alt_capture_pcm_prepare,
3065 .cleanup = alc880_alt_capture_pcm_cleanup
3069 static struct hda_pcm_stream alc880_pcm_digital_playback = {
3073 /* NID is set in alc_build_pcms */
3075 .open = alc880_dig_playback_pcm_open,
3076 .close = alc880_dig_playback_pcm_close,
3077 .prepare = alc880_dig_playback_pcm_prepare,
3078 .cleanup = alc880_dig_playback_pcm_cleanup
3082 static struct hda_pcm_stream alc880_pcm_digital_capture = {
3086 /* NID is set in alc_build_pcms */
3089 /* Used by alc_build_pcms to flag that a PCM has no playback stream */
3090 static struct hda_pcm_stream alc_pcm_null_stream = {
3096 static int alc_build_pcms(struct hda_codec *codec)
3098 struct alc_spec *spec = codec->spec;
3099 struct hda_pcm *info = spec->pcm_rec;
3102 codec->num_pcms = 1;
3103 codec->pcm_info = info;
3105 if (spec->no_analog)
3108 info->name = spec->stream_name_analog;
3109 if (spec->stream_analog_playback) {
3110 if (snd_BUG_ON(!spec->multiout.dac_nids))
3112 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
3113 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
3115 if (spec->stream_analog_capture) {
3116 if (snd_BUG_ON(!spec->adc_nids))
3118 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
3119 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
3122 if (spec->channel_mode) {
3123 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
3124 for (i = 0; i < spec->num_channel_mode; i++) {
3125 if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
3126 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
3132 /* SPDIF for stream index #1 */
3133 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
3134 codec->num_pcms = 2;
3135 codec->slave_dig_outs = spec->multiout.slave_dig_outs;
3136 info = spec->pcm_rec + 1;
3137 info->name = spec->stream_name_digital;
3138 if (spec->dig_out_type)
3139 info->pcm_type = spec->dig_out_type;
3141 info->pcm_type = HDA_PCM_TYPE_SPDIF;
3142 if (spec->multiout.dig_out_nid &&
3143 spec->stream_digital_playback) {
3144 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
3145 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
3147 if (spec->dig_in_nid &&
3148 spec->stream_digital_capture) {
3149 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
3150 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
3152 /* FIXME: do we need this for all Realtek codec models? */
3153 codec->spdif_status_reset = 1;
3156 if (spec->no_analog)
3159 /* If the use of more than one ADC is requested for the current
3160 * model, configure a second analog capture-only PCM.
3162 /* Additional Analaog capture for index #2 */
3163 if ((spec->alt_dac_nid && spec->stream_analog_alt_playback) ||
3164 (spec->num_adc_nids > 1 && spec->stream_analog_alt_capture)) {
3165 codec->num_pcms = 3;
3166 info = spec->pcm_rec + 2;
3167 info->name = spec->stream_name_analog;
3168 if (spec->alt_dac_nid) {
3169 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
3170 *spec->stream_analog_alt_playback;
3171 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
3174 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
3175 alc_pcm_null_stream;
3176 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
3178 if (spec->num_adc_nids > 1) {
3179 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
3180 *spec->stream_analog_alt_capture;
3181 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid =
3183 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams =
3184 spec->num_adc_nids - 1;
3186 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
3187 alc_pcm_null_stream;
3188 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = 0;
3195 static void alc_free_kctls(struct hda_codec *codec)
3197 struct alc_spec *spec = codec->spec;
3199 if (spec->kctls.list) {
3200 struct snd_kcontrol_new *kctl = spec->kctls.list;
3202 for (i = 0; i < spec->kctls.used; i++)
3203 kfree(kctl[i].name);
3205 snd_array_free(&spec->kctls);
3208 static void alc_free(struct hda_codec *codec)
3210 struct alc_spec *spec = codec->spec;
3215 alc_free_kctls(codec);
3217 snd_hda_detach_beep_device(codec);
3220 #ifdef SND_HDA_NEEDS_RESUME
3221 static int alc_resume(struct hda_codec *codec)
3223 codec->patch_ops.init(codec);
3224 snd_hda_codec_resume_amp(codec);
3225 snd_hda_codec_resume_cache(codec);
3232 static struct hda_codec_ops alc_patch_ops = {
3233 .build_controls = alc_build_controls,
3234 .build_pcms = alc_build_pcms,
3237 .unsol_event = alc_unsol_event,
3238 #ifdef SND_HDA_NEEDS_RESUME
3239 .resume = alc_resume,
3241 #ifdef CONFIG_SND_HDA_POWER_SAVE
3242 .check_power_status = alc_check_power_status,
3248 * Test configuration for debugging
3250 * Almost all inputs/outputs are enabled. I/O pins can be configured via
3253 #ifdef CONFIG_SND_DEBUG
3254 static hda_nid_t alc880_test_dac_nids[4] = {
3255 0x02, 0x03, 0x04, 0x05
3258 static struct hda_input_mux alc880_test_capture_source = {
3267 { "Surround", 0x6 },
3271 static struct hda_channel_mode alc880_test_modes[4] = {
3278 static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol,
3279 struct snd_ctl_elem_info *uinfo)
3281 static char *texts[] = {
3282 "N/A", "Line Out", "HP Out",
3283 "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
3285 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
3287 uinfo->value.enumerated.items = 8;
3288 if (uinfo->value.enumerated.item >= 8)
3289 uinfo->value.enumerated.item = 7;
3290 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
3294 static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol,
3295 struct snd_ctl_elem_value *ucontrol)
3297 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3298 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3299 unsigned int pin_ctl, item = 0;
3301 pin_ctl = snd_hda_codec_read(codec, nid, 0,
3302 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3303 if (pin_ctl & AC_PINCTL_OUT_EN) {
3304 if (pin_ctl & AC_PINCTL_HP_EN)
3308 } else if (pin_ctl & AC_PINCTL_IN_EN) {
3309 switch (pin_ctl & AC_PINCTL_VREFEN) {
3310 case AC_PINCTL_VREF_HIZ: item = 3; break;
3311 case AC_PINCTL_VREF_50: item = 4; break;
3312 case AC_PINCTL_VREF_GRD: item = 5; break;
3313 case AC_PINCTL_VREF_80: item = 6; break;
3314 case AC_PINCTL_VREF_100: item = 7; break;
3317 ucontrol->value.enumerated.item[0] = item;
3321 static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol,
3322 struct snd_ctl_elem_value *ucontrol)
3324 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3325 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3326 static unsigned int ctls[] = {
3327 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
3328 AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
3329 AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
3330 AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
3331 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
3332 AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
3334 unsigned int old_ctl, new_ctl;
3336 old_ctl = snd_hda_codec_read(codec, nid, 0,
3337 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3338 new_ctl = ctls[ucontrol->value.enumerated.item[0]];
3339 if (old_ctl != new_ctl) {
3341 snd_hda_codec_write_cache(codec, nid, 0,
3342 AC_VERB_SET_PIN_WIDGET_CONTROL,
3344 val = ucontrol->value.enumerated.item[0] >= 3 ?
3346 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
3353 static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol,
3354 struct snd_ctl_elem_info *uinfo)
3356 static char *texts[] = {
3357 "Front", "Surround", "CLFE", "Side"
3359 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
3361 uinfo->value.enumerated.items = 4;
3362 if (uinfo->value.enumerated.item >= 4)
3363 uinfo->value.enumerated.item = 3;
3364 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
3368 static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol,
3369 struct snd_ctl_elem_value *ucontrol)
3371 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3372 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3375 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
3376 ucontrol->value.enumerated.item[0] = sel & 3;
3380 static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol,
3381 struct snd_ctl_elem_value *ucontrol)
3383 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3384 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3387 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
3388 if (ucontrol->value.enumerated.item[0] != sel) {
3389 sel = ucontrol->value.enumerated.item[0] & 3;
3390 snd_hda_codec_write_cache(codec, nid, 0,
3391 AC_VERB_SET_CONNECT_SEL, sel);
3397 #define PIN_CTL_TEST(xname,nid) { \
3398 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
3400 .info = alc_test_pin_ctl_info, \
3401 .get = alc_test_pin_ctl_get, \
3402 .put = alc_test_pin_ctl_put, \
3403 .private_value = nid \
3406 #define PIN_SRC_TEST(xname,nid) { \
3407 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
3409 .info = alc_test_pin_src_info, \
3410 .get = alc_test_pin_src_get, \
3411 .put = alc_test_pin_src_put, \
3412 .private_value = nid \
3415 static struct snd_kcontrol_new alc880_test_mixer[] = {
3416 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3417 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
3418 HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
3419 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
3420 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
3421 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
3422 HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
3423 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
3424 PIN_CTL_TEST("Front Pin Mode", 0x14),
3425 PIN_CTL_TEST("Surround Pin Mode", 0x15),
3426 PIN_CTL_TEST("CLFE Pin Mode", 0x16),
3427 PIN_CTL_TEST("Side Pin Mode", 0x17),
3428 PIN_CTL_TEST("In-1 Pin Mode", 0x18),
3429 PIN_CTL_TEST("In-2 Pin Mode", 0x19),
3430 PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
3431 PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
3432 PIN_SRC_TEST("In-1 Pin Source", 0x18),
3433 PIN_SRC_TEST("In-2 Pin Source", 0x19),
3434 PIN_SRC_TEST("In-3 Pin Source", 0x1a),
3435 PIN_SRC_TEST("In-4 Pin Source", 0x1b),
3436 HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
3437 HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
3438 HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
3439 HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
3440 HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
3441 HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
3442 HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
3443 HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
3444 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
3445 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
3447 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3448 .name = "Channel Mode",
3449 .info = alc_ch_mode_info,
3450 .get = alc_ch_mode_get,
3451 .put = alc_ch_mode_put,
3456 static struct hda_verb alc880_test_init_verbs[] = {
3457 /* Unmute inputs of 0x0c - 0x0f */
3458 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3459 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3460 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3461 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3462 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3463 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3464 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3465 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3466 /* Vol output for 0x0c-0x0f */
3467 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3468 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3469 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3470 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3471 /* Set output pins 0x14-0x17 */
3472 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3473 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3474 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3475 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3476 /* Unmute output pins 0x14-0x17 */
3477 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3478 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3479 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3480 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3481 /* Set input pins 0x18-0x1c */
3482 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3483 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3484 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3485 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3486 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3487 /* Mute input pins 0x18-0x1b */
3488 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3489 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3490 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3491 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3493 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3494 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
3495 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3496 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
3497 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3498 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
3499 /* Analog input/passthru */
3500 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3501 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3502 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
3503 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
3504 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
3512 static const char *alc880_models[ALC880_MODEL_LAST] = {
3513 [ALC880_3ST] = "3stack",
3514 [ALC880_TCL_S700] = "tcl",
3515 [ALC880_3ST_DIG] = "3stack-digout",
3516 [ALC880_CLEVO] = "clevo",
3517 [ALC880_5ST] = "5stack",
3518 [ALC880_5ST_DIG] = "5stack-digout",
3519 [ALC880_W810] = "w810",
3520 [ALC880_Z71V] = "z71v",
3521 [ALC880_6ST] = "6stack",
3522 [ALC880_6ST_DIG] = "6stack-digout",
3523 [ALC880_ASUS] = "asus",
3524 [ALC880_ASUS_W1V] = "asus-w1v",
3525 [ALC880_ASUS_DIG] = "asus-dig",
3526 [ALC880_ASUS_DIG2] = "asus-dig2",
3527 [ALC880_UNIWILL_DIG] = "uniwill",
3528 [ALC880_UNIWILL_P53] = "uniwill-p53",
3529 [ALC880_FUJITSU] = "fujitsu",
3530 [ALC880_F1734] = "F1734",
3532 [ALC880_LG_LW] = "lg-lw",
3533 [ALC880_MEDION_RIM] = "medion",
3534 #ifdef CONFIG_SND_DEBUG
3535 [ALC880_TEST] = "test",
3537 [ALC880_AUTO] = "auto",
3540 static struct snd_pci_quirk alc880_cfg_tbl[] = {
3541 SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_W810),
3542 SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_5ST_DIG),
3543 SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_6ST),
3544 SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_3ST_DIG),
3545 SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_6ST_DIG),
3546 SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_6ST_DIG),
3547 SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_6ST_DIG),
3548 SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_3ST_DIG),
3549 SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_3ST),
3550 SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_6ST_DIG),
3551 SND_PCI_QUIRK(0x103c, 0x2a09, "HP", ALC880_5ST),
3552 SND_PCI_QUIRK(0x1043, 0x10b3, "ASUS W1V", ALC880_ASUS_W1V),
3553 SND_PCI_QUIRK(0x1043, 0x10c2, "ASUS W6A", ALC880_ASUS_DIG),
3554 SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS Wxx", ALC880_ASUS_DIG),
3555 SND_PCI_QUIRK(0x1043, 0x1113, "ASUS", ALC880_ASUS_DIG),
3556 SND_PCI_QUIRK(0x1043, 0x1123, "ASUS", ALC880_ASUS_DIG),
3557 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS", ALC880_ASUS_DIG),
3558 SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_Z71V),
3559 /* SND_PCI_QUIRK(0x1043, 0x1964, "ASUS", ALC880_ASUS_DIG), */
3560 SND_PCI_QUIRK(0x1043, 0x1973, "ASUS", ALC880_ASUS_DIG),
3561 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS", ALC880_ASUS_DIG),
3562 SND_PCI_QUIRK(0x1043, 0x814e, "ASUS P5GD1 w/SPDIF", ALC880_6ST_DIG),
3563 SND_PCI_QUIRK(0x1043, 0x8181, "ASUS P4GPL", ALC880_ASUS_DIG),
3564 SND_PCI_QUIRK(0x1043, 0x8196, "ASUS P5GD1", ALC880_6ST),
3565 SND_PCI_QUIRK(0x1043, 0x81b4, "ASUS", ALC880_6ST),
3566 SND_PCI_QUIRK_VENDOR(0x1043, "ASUS", ALC880_ASUS), /* default ASUS */
3567 SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_3ST),
3568 SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_3ST),
3569 SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_5ST),
3570 SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_5ST),
3571 SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_5ST),
3572 SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_6ST_DIG),
3573 SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_6ST_DIG),
3574 SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_6ST_DIG),
3575 SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_6ST_DIG),
3576 SND_PCI_QUIRK(0x1558, 0x0520, "Clevo m520G", ALC880_CLEVO),
3577 SND_PCI_QUIRK(0x1558, 0x0660, "Clevo m655n", ALC880_CLEVO),
3578 SND_PCI_QUIRK(0x1558, 0x5401, "ASUS", ALC880_ASUS_DIG2),
3579 SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_5ST_DIG),
3580 SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_UNIWILL_DIG),
3581 SND_PCI_QUIRK(0x1584, 0x9054, "Uniwlll", ALC880_F1734),
3582 SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_UNIWILL),
3583 SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_UNIWILL_P53),
3584 SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_W810),
3585 SND_PCI_QUIRK(0x161f, 0x205d, "Medion Rim 2150", ALC880_MEDION_RIM),
3586 SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_5ST_DIG),
3587 SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_5ST_DIG),
3588 SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_F1734),
3589 SND_PCI_QUIRK(0x1734, 0x1094, "FSC Amilo M1451G", ALC880_FUJITSU),
3590 SND_PCI_QUIRK(0x1734, 0x10ac, "FSC", ALC880_UNIWILL),
3591 SND_PCI_QUIRK(0x1734, 0x10b0, "Fujitsu", ALC880_FUJITSU),
3592 SND_PCI_QUIRK(0x1854, 0x0018, "LG LW20", ALC880_LG_LW),
3593 SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_LG),
3594 SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_LG),
3595 SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_LG_LW),
3596 SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_TCL_S700),
3597 SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_6ST_DIG), /* broken BIOS */
3598 SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_6ST_DIG),
3599 SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_5ST_DIG),
3600 SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_5ST_DIG),
3601 SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_5ST_DIG),
3602 SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_3ST_DIG),
3603 SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_5ST_DIG),
3604 SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_3ST_DIG),
3605 SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_3ST_DIG),
3606 SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_5ST_DIG),
3607 SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_5ST_DIG),
3608 SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_5ST_DIG),
3610 SND_PCI_QUIRK_VENDOR(0x8086, "Intel mobo", ALC880_3ST),
3611 SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_5ST_DIG),
3612 SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_6ST_DIG),
3617 * ALC880 codec presets
3619 static struct alc_config_preset alc880_presets[] = {
3621 .mixers = { alc880_three_stack_mixer },
3622 .init_verbs = { alc880_volume_init_verbs,
3623 alc880_pin_3stack_init_verbs },
3624 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3625 .dac_nids = alc880_dac_nids,
3626 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3627 .channel_mode = alc880_threestack_modes,
3629 .input_mux = &alc880_capture_source,
3631 [ALC880_3ST_DIG] = {
3632 .mixers = { alc880_three_stack_mixer },
3633 .init_verbs = { alc880_volume_init_verbs,
3634 alc880_pin_3stack_init_verbs },
3635 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3636 .dac_nids = alc880_dac_nids,
3637 .dig_out_nid = ALC880_DIGOUT_NID,
3638 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3639 .channel_mode = alc880_threestack_modes,
3641 .input_mux = &alc880_capture_source,
3643 [ALC880_TCL_S700] = {
3644 .mixers = { alc880_tcl_s700_mixer },
3645 .init_verbs = { alc880_volume_init_verbs,
3646 alc880_pin_tcl_S700_init_verbs,
3647 alc880_gpio2_init_verbs },
3648 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3649 .dac_nids = alc880_dac_nids,
3650 .adc_nids = alc880_adc_nids_alt, /* FIXME: correct? */
3651 .num_adc_nids = 1, /* single ADC */
3653 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3654 .channel_mode = alc880_2_jack_modes,
3655 .input_mux = &alc880_capture_source,
3658 .mixers = { alc880_three_stack_mixer,
3659 alc880_five_stack_mixer},
3660 .init_verbs = { alc880_volume_init_verbs,
3661 alc880_pin_5stack_init_verbs },
3662 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3663 .dac_nids = alc880_dac_nids,
3664 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
3665 .channel_mode = alc880_fivestack_modes,
3666 .input_mux = &alc880_capture_source,
3668 [ALC880_5ST_DIG] = {
3669 .mixers = { alc880_three_stack_mixer,
3670 alc880_five_stack_mixer },
3671 .init_verbs = { alc880_volume_init_verbs,
3672 alc880_pin_5stack_init_verbs },
3673 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3674 .dac_nids = alc880_dac_nids,
3675 .dig_out_nid = ALC880_DIGOUT_NID,
3676 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
3677 .channel_mode = alc880_fivestack_modes,
3678 .input_mux = &alc880_capture_source,
3681 .mixers = { alc880_six_stack_mixer },
3682 .init_verbs = { alc880_volume_init_verbs,
3683 alc880_pin_6stack_init_verbs },
3684 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
3685 .dac_nids = alc880_6st_dac_nids,
3686 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
3687 .channel_mode = alc880_sixstack_modes,
3688 .input_mux = &alc880_6stack_capture_source,
3690 [ALC880_6ST_DIG] = {
3691 .mixers = { alc880_six_stack_mixer },
3692 .init_verbs = { alc880_volume_init_verbs,
3693 alc880_pin_6stack_init_verbs },
3694 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
3695 .dac_nids = alc880_6st_dac_nids,
3696 .dig_out_nid = ALC880_DIGOUT_NID,
3697 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
3698 .channel_mode = alc880_sixstack_modes,
3699 .input_mux = &alc880_6stack_capture_source,
3702 .mixers = { alc880_w810_base_mixer },
3703 .init_verbs = { alc880_volume_init_verbs,
3704 alc880_pin_w810_init_verbs,
3705 alc880_gpio2_init_verbs },
3706 .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
3707 .dac_nids = alc880_w810_dac_nids,
3708 .dig_out_nid = ALC880_DIGOUT_NID,
3709 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
3710 .channel_mode = alc880_w810_modes,
3711 .input_mux = &alc880_capture_source,
3714 .mixers = { alc880_z71v_mixer },
3715 .init_verbs = { alc880_volume_init_verbs,
3716 alc880_pin_z71v_init_verbs },
3717 .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
3718 .dac_nids = alc880_z71v_dac_nids,
3719 .dig_out_nid = ALC880_DIGOUT_NID,
3721 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3722 .channel_mode = alc880_2_jack_modes,
3723 .input_mux = &alc880_capture_source,
3726 .mixers = { alc880_f1734_mixer },
3727 .init_verbs = { alc880_volume_init_verbs,
3728 alc880_pin_f1734_init_verbs },
3729 .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
3730 .dac_nids = alc880_f1734_dac_nids,
3732 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3733 .channel_mode = alc880_2_jack_modes,
3734 .input_mux = &alc880_f1734_capture_source,
3735 .unsol_event = alc880_uniwill_p53_unsol_event,
3736 .init_hook = alc880_uniwill_p53_hp_automute,
3739 .mixers = { alc880_asus_mixer },
3740 .init_verbs = { alc880_volume_init_verbs,
3741 alc880_pin_asus_init_verbs,
3742 alc880_gpio1_init_verbs },
3743 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3744 .dac_nids = alc880_asus_dac_nids,
3745 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3746 .channel_mode = alc880_asus_modes,
3748 .input_mux = &alc880_capture_source,
3750 [ALC880_ASUS_DIG] = {
3751 .mixers = { alc880_asus_mixer },
3752 .init_verbs = { alc880_volume_init_verbs,
3753 alc880_pin_asus_init_verbs,
3754 alc880_gpio1_init_verbs },
3755 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3756 .dac_nids = alc880_asus_dac_nids,
3757 .dig_out_nid = ALC880_DIGOUT_NID,
3758 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3759 .channel_mode = alc880_asus_modes,
3761 .input_mux = &alc880_capture_source,
3763 [ALC880_ASUS_DIG2] = {
3764 .mixers = { alc880_asus_mixer },
3765 .init_verbs = { alc880_volume_init_verbs,
3766 alc880_pin_asus_init_verbs,
3767 alc880_gpio2_init_verbs }, /* use GPIO2 */
3768 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3769 .dac_nids = alc880_asus_dac_nids,
3770 .dig_out_nid = ALC880_DIGOUT_NID,
3771 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3772 .channel_mode = alc880_asus_modes,
3774 .input_mux = &alc880_capture_source,
3776 [ALC880_ASUS_W1V] = {
3777 .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
3778 .init_verbs = { alc880_volume_init_verbs,
3779 alc880_pin_asus_init_verbs,
3780 alc880_gpio1_init_verbs },
3781 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3782 .dac_nids = alc880_asus_dac_nids,
3783 .dig_out_nid = ALC880_DIGOUT_NID,
3784 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3785 .channel_mode = alc880_asus_modes,
3787 .input_mux = &alc880_capture_source,
3789 [ALC880_UNIWILL_DIG] = {
3790 .mixers = { alc880_asus_mixer },
3791 .init_verbs = { alc880_volume_init_verbs,
3792 alc880_pin_asus_init_verbs },
3793 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3794 .dac_nids = alc880_asus_dac_nids,
3795 .dig_out_nid = ALC880_DIGOUT_NID,
3796 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3797 .channel_mode = alc880_asus_modes,
3799 .input_mux = &alc880_capture_source,
3801 [ALC880_UNIWILL] = {
3802 .mixers = { alc880_uniwill_mixer },
3803 .init_verbs = { alc880_volume_init_verbs,
3804 alc880_uniwill_init_verbs },
3805 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3806 .dac_nids = alc880_asus_dac_nids,
3807 .dig_out_nid = ALC880_DIGOUT_NID,
3808 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3809 .channel_mode = alc880_threestack_modes,
3811 .input_mux = &alc880_capture_source,
3812 .unsol_event = alc880_uniwill_unsol_event,
3813 .init_hook = alc880_uniwill_automute,
3815 [ALC880_UNIWILL_P53] = {
3816 .mixers = { alc880_uniwill_p53_mixer },
3817 .init_verbs = { alc880_volume_init_verbs,
3818 alc880_uniwill_p53_init_verbs },
3819 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3820 .dac_nids = alc880_asus_dac_nids,
3821 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
3822 .channel_mode = alc880_threestack_modes,
3823 .input_mux = &alc880_capture_source,
3824 .unsol_event = alc880_uniwill_p53_unsol_event,
3825 .init_hook = alc880_uniwill_p53_hp_automute,
3827 [ALC880_FUJITSU] = {
3828 .mixers = { alc880_fujitsu_mixer },
3829 .init_verbs = { alc880_volume_init_verbs,
3830 alc880_uniwill_p53_init_verbs,
3831 alc880_beep_init_verbs },
3832 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3833 .dac_nids = alc880_dac_nids,
3834 .dig_out_nid = ALC880_DIGOUT_NID,
3835 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3836 .channel_mode = alc880_2_jack_modes,
3837 .input_mux = &alc880_capture_source,
3838 .unsol_event = alc880_uniwill_p53_unsol_event,
3839 .init_hook = alc880_uniwill_p53_hp_automute,
3842 .mixers = { alc880_three_stack_mixer },
3843 .init_verbs = { alc880_volume_init_verbs,
3844 alc880_pin_clevo_init_verbs },
3845 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3846 .dac_nids = alc880_dac_nids,
3848 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3849 .channel_mode = alc880_threestack_modes,
3851 .input_mux = &alc880_capture_source,
3854 .mixers = { alc880_lg_mixer },
3855 .init_verbs = { alc880_volume_init_verbs,
3856 alc880_lg_init_verbs },
3857 .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids),
3858 .dac_nids = alc880_lg_dac_nids,
3859 .dig_out_nid = ALC880_DIGOUT_NID,
3860 .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes),
3861 .channel_mode = alc880_lg_ch_modes,
3863 .input_mux = &alc880_lg_capture_source,
3864 .unsol_event = alc880_lg_unsol_event,
3865 .init_hook = alc880_lg_automute,
3866 #ifdef CONFIG_SND_HDA_POWER_SAVE
3867 .loopbacks = alc880_lg_loopbacks,
3871 .mixers = { alc880_lg_lw_mixer },
3872 .init_verbs = { alc880_volume_init_verbs,
3873 alc880_lg_lw_init_verbs },
3874 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3875 .dac_nids = alc880_dac_nids,
3876 .dig_out_nid = ALC880_DIGOUT_NID,
3877 .num_channel_mode = ARRAY_SIZE(alc880_lg_lw_modes),
3878 .channel_mode = alc880_lg_lw_modes,
3879 .input_mux = &alc880_lg_lw_capture_source,
3880 .unsol_event = alc880_lg_lw_unsol_event,
3881 .init_hook = alc880_lg_lw_automute,
3883 [ALC880_MEDION_RIM] = {
3884 .mixers = { alc880_medion_rim_mixer },
3885 .init_verbs = { alc880_volume_init_verbs,
3886 alc880_medion_rim_init_verbs,
3887 alc_gpio2_init_verbs },
3888 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3889 .dac_nids = alc880_dac_nids,
3890 .dig_out_nid = ALC880_DIGOUT_NID,
3891 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3892 .channel_mode = alc880_2_jack_modes,
3893 .input_mux = &alc880_medion_rim_capture_source,
3894 .unsol_event = alc880_medion_rim_unsol_event,
3895 .init_hook = alc880_medion_rim_automute,
3897 #ifdef CONFIG_SND_DEBUG
3899 .mixers = { alc880_test_mixer },
3900 .init_verbs = { alc880_test_init_verbs },
3901 .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
3902 .dac_nids = alc880_test_dac_nids,
3903 .dig_out_nid = ALC880_DIGOUT_NID,
3904 .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
3905 .channel_mode = alc880_test_modes,
3906 .input_mux = &alc880_test_capture_source,
3912 * Automatic parse of I/O pins from the BIOS configuration
3917 ALC_CTL_WIDGET_MUTE,
3920 static struct snd_kcontrol_new alc880_control_templates[] = {
3921 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
3922 HDA_CODEC_MUTE(NULL, 0, 0, 0),
3923 HDA_BIND_MUTE(NULL, 0, 0, 0),
3926 /* add dynamic controls */
3927 static int add_control(struct alc_spec *spec, int type, const char *name,
3930 struct snd_kcontrol_new *knew;
3932 snd_array_init(&spec->kctls, sizeof(*knew), 32);
3933 knew = snd_array_new(&spec->kctls);
3936 *knew = alc880_control_templates[type];
3937 knew->name = kstrdup(name, GFP_KERNEL);
3940 knew->private_value = val;
3944 #define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
3945 #define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
3946 #define alc880_is_multi_pin(nid) ((nid) >= 0x18)
3947 #define alc880_multi_pin_idx(nid) ((nid) - 0x18)
3948 #define alc880_is_input_pin(nid) ((nid) >= 0x18)
3949 #define alc880_input_pin_idx(nid) ((nid) - 0x18)
3950 #define alc880_idx_to_dac(nid) ((nid) + 0x02)
3951 #define alc880_dac_to_idx(nid) ((nid) - 0x02)
3952 #define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
3953 #define alc880_idx_to_selector(nid) ((nid) + 0x10)
3954 #define ALC880_PIN_CD_NID 0x1c
3956 /* fill in the dac_nids table from the parsed pin configuration */
3957 static int alc880_auto_fill_dac_nids(struct alc_spec *spec,
3958 const struct auto_pin_cfg *cfg)
3964 memset(assigned, 0, sizeof(assigned));
3965 spec->multiout.dac_nids = spec->private_dac_nids;
3967 /* check the pins hardwired to audio widget */
3968 for (i = 0; i < cfg->line_outs; i++) {
3969 nid = cfg->line_out_pins[i];
3970 if (alc880_is_fixed_pin(nid)) {
3971 int idx = alc880_fixed_pin_idx(nid);
3972 spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
3976 /* left pins can be connect to any audio widget */
3977 for (i = 0; i < cfg->line_outs; i++) {
3978 nid = cfg->line_out_pins[i];
3979 if (alc880_is_fixed_pin(nid))
3981 /* search for an empty channel */
3982 for (j = 0; j < cfg->line_outs; j++) {
3984 spec->multiout.dac_nids[i] =
3985 alc880_idx_to_dac(j);
3991 spec->multiout.num_dacs = cfg->line_outs;
3995 /* add playback controls from the parsed DAC table */
3996 static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
3997 const struct auto_pin_cfg *cfg)
4000 static const char *chname[4] = {
4001 "Front", "Surround", NULL /*CLFE*/, "Side"
4006 for (i = 0; i < cfg->line_outs; i++) {
4007 if (!spec->multiout.dac_nids[i])
4009 nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
4012 err = add_control(spec, ALC_CTL_WIDGET_VOL,
4013 "Center Playback Volume",
4014 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
4018 err = add_control(spec, ALC_CTL_WIDGET_VOL,
4019 "LFE Playback Volume",
4020 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
4024 err = add_control(spec, ALC_CTL_BIND_MUTE,
4025 "Center Playback Switch",
4026 HDA_COMPOSE_AMP_VAL(nid, 1, 2,
4030 err = add_control(spec, ALC_CTL_BIND_MUTE,
4031 "LFE Playback Switch",
4032 HDA_COMPOSE_AMP_VAL(nid, 2, 2,
4037 sprintf(name, "%s Playback Volume", chname[i]);
4038 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
4039 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
4043 sprintf(name, "%s Playback Switch", chname[i]);
4044 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
4045 HDA_COMPOSE_AMP_VAL(nid, 3, 2,
4054 /* add playback controls for speaker and HP outputs */
4055 static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
4065 if (alc880_is_fixed_pin(pin)) {
4066 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
4067 /* specify the DAC as the extra output */
4068 if (!spec->multiout.hp_nid)
4069 spec->multiout.hp_nid = nid;
4071 spec->multiout.extra_out_nid[0] = nid;
4072 /* control HP volume/switch on the output mixer amp */
4073 nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
4074 sprintf(name, "%s Playback Volume", pfx);
4075 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
4076 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
4079 sprintf(name, "%s Playback Switch", pfx);
4080 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
4081 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
4084 } else if (alc880_is_multi_pin(pin)) {
4085 /* set manual connection */
4086 /* we have only a switch on HP-out PIN */
4087 sprintf(name, "%s Playback Switch", pfx);
4088 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
4089 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
4096 /* create input playback/capture controls for the given pin */
4097 static int new_analog_input(struct alc_spec *spec, hda_nid_t pin,
4098 const char *ctlname,
4099 int idx, hda_nid_t mix_nid)
4104 sprintf(name, "%s Playback Volume", ctlname);
4105 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
4106 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
4109 sprintf(name, "%s Playback Switch", ctlname);
4110 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
4111 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
4117 /* create playback/capture controls for input pins */
4118 static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec,
4119 const struct auto_pin_cfg *cfg)
4121 struct hda_input_mux *imux = &spec->private_imux[0];
4124 for (i = 0; i < AUTO_PIN_LAST; i++) {
4125 if (alc880_is_input_pin(cfg->input_pins[i])) {
4126 idx = alc880_input_pin_idx(cfg->input_pins[i]);
4127 err = new_analog_input(spec, cfg->input_pins[i],
4128 auto_pin_cfg_labels[i],
4132 imux->items[imux->num_items].label =
4133 auto_pin_cfg_labels[i];
4134 imux->items[imux->num_items].index =
4135 alc880_input_pin_idx(cfg->input_pins[i]);
4142 static void alc_set_pin_output(struct hda_codec *codec, hda_nid_t nid,
4143 unsigned int pin_type)
4145 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4148 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
4152 static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
4153 hda_nid_t nid, int pin_type,
4156 alc_set_pin_output(codec, nid, pin_type);
4157 /* need the manual connection? */
4158 if (alc880_is_multi_pin(nid)) {
4159 struct alc_spec *spec = codec->spec;
4160 int idx = alc880_multi_pin_idx(nid);
4161 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
4162 AC_VERB_SET_CONNECT_SEL,
4163 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
4167 static int get_pin_type(int line_out_type)
4169 if (line_out_type == AUTO_PIN_HP_OUT)
4175 static void alc880_auto_init_multi_out(struct hda_codec *codec)
4177 struct alc_spec *spec = codec->spec;
4180 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
4181 for (i = 0; i < spec->autocfg.line_outs; i++) {
4182 hda_nid_t nid = spec->autocfg.line_out_pins[i];
4183 int pin_type = get_pin_type(spec->autocfg.line_out_type);
4184 alc880_auto_set_output_and_unmute(codec, nid, pin_type, i);
4188 static void alc880_auto_init_extra_out(struct hda_codec *codec)
4190 struct alc_spec *spec = codec->spec;
4193 pin = spec->autocfg.speaker_pins[0];
4194 if (pin) /* connect to front */
4195 alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
4196 pin = spec->autocfg.hp_pins[0];
4197 if (pin) /* connect to front */
4198 alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
4201 static void alc880_auto_init_analog_input(struct hda_codec *codec)
4203 struct alc_spec *spec = codec->spec;
4206 for (i = 0; i < AUTO_PIN_LAST; i++) {
4207 hda_nid_t nid = spec->autocfg.input_pins[i];
4208 if (alc880_is_input_pin(nid)) {
4209 alc_set_input_pin(codec, nid, i);
4210 if (nid != ALC880_PIN_CD_NID &&
4211 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
4212 snd_hda_codec_write(codec, nid, 0,
4213 AC_VERB_SET_AMP_GAIN_MUTE,
4219 /* parse the BIOS configuration and set up the alc_spec */
4220 /* return 1 if successful, 0 if the proper config is not found,
4221 * or a negative error code
4223 static int alc880_parse_auto_config(struct hda_codec *codec)
4225 struct alc_spec *spec = codec->spec;
4227 static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
4229 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
4233 if (!spec->autocfg.line_outs)
4234 return 0; /* can't find valid BIOS pin config */
4236 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
4239 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
4242 err = alc880_auto_create_extra_out(spec,
4243 spec->autocfg.speaker_pins[0],
4247 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
4251 err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
4255 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
4257 /* check multiple SPDIF-out (for recent codecs) */
4258 for (i = 0; i < spec->autocfg.dig_outs; i++) {
4260 err = snd_hda_get_connections(codec,
4261 spec->autocfg.dig_out_pins[i],
4266 spec->multiout.dig_out_nid = dig_nid;
4268 spec->multiout.slave_dig_outs = spec->slave_dig_outs;
4269 spec->slave_dig_outs[i - 1] = dig_nid;
4270 if (i == ARRAY_SIZE(spec->slave_dig_outs) - 1)
4274 if (spec->autocfg.dig_in_pin)
4275 spec->dig_in_nid = ALC880_DIGIN_NID;
4277 if (spec->kctls.list)
4278 add_mixer(spec, spec->kctls.list);
4280 add_verb(spec, alc880_volume_init_verbs);
4282 spec->num_mux_defs = 1;
4283 spec->input_mux = &spec->private_imux[0];
4288 /* additional initialization for auto-configuration model */
4289 static void alc880_auto_init(struct hda_codec *codec)
4291 struct alc_spec *spec = codec->spec;
4292 alc880_auto_init_multi_out(codec);
4293 alc880_auto_init_extra_out(codec);
4294 alc880_auto_init_analog_input(codec);
4295 if (spec->unsol_event)
4296 alc_inithook(codec);
4299 static void set_capture_mixer(struct alc_spec *spec)
4301 static struct snd_kcontrol_new *caps[3] = {
4306 if (spec->num_adc_nids > 0 && spec->num_adc_nids <= 3)
4307 spec->cap_mixer = caps[spec->num_adc_nids - 1];
4310 #define set_beep_amp(spec, nid, idx, dir) \
4311 ((spec)->beep_amp = HDA_COMPOSE_AMP_VAL(nid, 3, idx, dir))
4314 * OK, here we have finally the patch for ALC880
4317 static int patch_alc880(struct hda_codec *codec)
4319 struct alc_spec *spec;
4323 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4329 board_config = snd_hda_check_board_config(codec, ALC880_MODEL_LAST,
4332 if (board_config < 0) {
4333 printk(KERN_INFO "hda_codec: Unknown model for ALC880, "
4334 "trying auto-probe from BIOS...\n");
4335 board_config = ALC880_AUTO;
4338 if (board_config == ALC880_AUTO) {
4339 /* automatic parse from the BIOS config */
4340 err = alc880_parse_auto_config(codec);
4346 "hda_codec: Cannot set up configuration "
4347 "from BIOS. Using 3-stack mode...\n");
4348 board_config = ALC880_3ST;
4352 err = snd_hda_attach_beep_device(codec, 0x1);
4358 if (board_config != ALC880_AUTO)
4359 setup_preset(spec, &alc880_presets[board_config]);
4361 spec->stream_name_analog = "ALC880 Analog";
4362 spec->stream_analog_playback = &alc880_pcm_analog_playback;
4363 spec->stream_analog_capture = &alc880_pcm_analog_capture;
4364 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
4366 spec->stream_name_digital = "ALC880 Digital";
4367 spec->stream_digital_playback = &alc880_pcm_digital_playback;
4368 spec->stream_digital_capture = &alc880_pcm_digital_capture;
4370 if (!spec->adc_nids && spec->input_mux) {
4371 /* check whether NID 0x07 is valid */
4372 unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
4374 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
4375 if (wcap != AC_WID_AUD_IN) {
4376 spec->adc_nids = alc880_adc_nids_alt;
4377 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
4379 spec->adc_nids = alc880_adc_nids;
4380 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
4383 set_capture_mixer(spec);
4384 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
4386 spec->vmaster_nid = 0x0c;
4388 codec->patch_ops = alc_patch_ops;
4389 if (board_config == ALC880_AUTO)
4390 spec->init_hook = alc880_auto_init;
4391 #ifdef CONFIG_SND_HDA_POWER_SAVE
4392 if (!spec->loopback.amplist)
4393 spec->loopback.amplist = alc880_loopbacks;
4395 codec->proc_widget_hook = print_realtek_coef;
4405 static hda_nid_t alc260_dac_nids[1] = {
4410 static hda_nid_t alc260_adc_nids[1] = {
4415 static hda_nid_t alc260_adc_nids_alt[1] = {
4420 /* NIDs used when simultaneous access to both ADCs makes sense. Note that
4421 * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
4423 static hda_nid_t alc260_dual_adc_nids[2] = {
4428 #define ALC260_DIGOUT_NID 0x03
4429 #define ALC260_DIGIN_NID 0x06
4431 static struct hda_input_mux alc260_capture_source = {
4435 { "Front Mic", 0x1 },
4441 /* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
4442 * headphone jack and the internal CD lines since these are the only pins at
4443 * which audio can appear. For flexibility, also allow the option of
4444 * recording the mixer output on the second ADC (ADC0 doesn't have a
4445 * connection to the mixer output).
4447 static struct hda_input_mux alc260_fujitsu_capture_sources[2] = {
4451 { "Mic/Line", 0x0 },
4453 { "Headphone", 0x2 },
4459 { "Mic/Line", 0x0 },
4461 { "Headphone", 0x2 },
4468 /* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to
4469 * the Fujitsu S702x, but jacks are marked differently.
4471 static struct hda_input_mux alc260_acer_capture_sources[2] = {
4478 { "Headphone", 0x5 },
4487 { "Headphone", 0x6 },
4493 /* Maxdata Favorit 100XS */
4494 static struct hda_input_mux alc260_favorit100_capture_sources[2] = {
4498 { "Line/Mic", 0x0 },
4505 { "Line/Mic", 0x0 },
4513 * This is just place-holder, so there's something for alc_build_pcms to look
4514 * at when it calculates the maximum number of channels. ALC260 has no mixer
4515 * element which allows changing the channel mode, so the verb list is
4518 static struct hda_channel_mode alc260_modes[1] = {
4523 /* Mixer combinations
4525 * basic: base_output + input + pc_beep + capture
4526 * HP: base_output + input + capture_alt
4527 * HP_3013: hp_3013 + input + capture
4528 * fujitsu: fujitsu + capture
4529 * acer: acer + capture
4532 static struct snd_kcontrol_new alc260_base_output_mixer[] = {
4533 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4534 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
4535 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4536 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
4537 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
4538 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
4542 static struct snd_kcontrol_new alc260_input_mixer[] = {
4543 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4544 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4545 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
4546 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
4547 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4548 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4549 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
4550 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
4554 /* update HP, line and mono out pins according to the master switch */
4555 static void alc260_hp_master_update(struct hda_codec *codec,
4556 hda_nid_t hp, hda_nid_t line,
4559 struct alc_spec *spec = codec->spec;
4560 unsigned int val = spec->master_sw ? PIN_HP : 0;
4561 /* change HP and line-out pins */
4562 snd_hda_codec_write(codec, hp, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4564 snd_hda_codec_write(codec, line, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4566 /* mono (speaker) depending on the HP jack sense */
4567 val = (val && !spec->jack_present) ? PIN_OUT : 0;
4568 snd_hda_codec_write(codec, mono, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4572 static int alc260_hp_master_sw_get(struct snd_kcontrol *kcontrol,
4573 struct snd_ctl_elem_value *ucontrol)
4575 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4576 struct alc_spec *spec = codec->spec;
4577 *ucontrol->value.integer.value = spec->master_sw;
4581 static int alc260_hp_master_sw_put(struct snd_kcontrol *kcontrol,
4582 struct snd_ctl_elem_value *ucontrol)
4584 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4585 struct alc_spec *spec = codec->spec;
4586 int val = !!*ucontrol->value.integer.value;
4587 hda_nid_t hp, line, mono;
4589 if (val == spec->master_sw)
4591 spec->master_sw = val;
4592 hp = (kcontrol->private_value >> 16) & 0xff;
4593 line = (kcontrol->private_value >> 8) & 0xff;
4594 mono = kcontrol->private_value & 0xff;
4595 alc260_hp_master_update(codec, hp, line, mono);
4599 static struct snd_kcontrol_new alc260_hp_output_mixer[] = {
4601 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4602 .name = "Master Playback Switch",
4603 .info = snd_ctl_boolean_mono_info,
4604 .get = alc260_hp_master_sw_get,
4605 .put = alc260_hp_master_sw_put,
4606 .private_value = (0x0f << 16) | (0x10 << 8) | 0x11
4608 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4609 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
4610 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4611 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
4612 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
4614 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2, HDA_INPUT),
4618 static struct hda_verb alc260_hp_unsol_verbs[] = {
4619 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
4623 static void alc260_hp_automute(struct hda_codec *codec)
4625 struct alc_spec *spec = codec->spec;
4626 unsigned int present;
4628 present = snd_hda_codec_read(codec, 0x10, 0,
4629 AC_VERB_GET_PIN_SENSE, 0);
4630 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
4631 alc260_hp_master_update(codec, 0x0f, 0x10, 0x11);
4634 static void alc260_hp_unsol_event(struct hda_codec *codec, unsigned int res)
4636 if ((res >> 26) == ALC880_HP_EVENT)
4637 alc260_hp_automute(codec);
4640 static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
4642 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4643 .name = "Master Playback Switch",
4644 .info = snd_ctl_boolean_mono_info,
4645 .get = alc260_hp_master_sw_get,
4646 .put = alc260_hp_master_sw_put,
4647 .private_value = (0x15 << 16) | (0x10 << 8) | 0x11
4649 HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4650 HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
4651 HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
4652 HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
4653 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4654 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
4655 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
4656 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
4660 static struct hda_bind_ctls alc260_dc7600_bind_master_vol = {
4661 .ops = &snd_hda_bind_vol,
4663 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_OUTPUT),
4664 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_OUTPUT),
4665 HDA_COMPOSE_AMP_VAL(0x0a, 3, 0, HDA_OUTPUT),
4670 static struct hda_bind_ctls alc260_dc7600_bind_switch = {
4671 .ops = &snd_hda_bind_sw,
4673 HDA_COMPOSE_AMP_VAL(0x11, 3, 0, HDA_OUTPUT),
4674 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
4679 static struct snd_kcontrol_new alc260_hp_dc7600_mixer[] = {
4680 HDA_BIND_VOL("Master Playback Volume", &alc260_dc7600_bind_master_vol),
4681 HDA_BIND_SW("LineOut Playback Switch", &alc260_dc7600_bind_switch),
4682 HDA_CODEC_MUTE("Speaker Playback Switch", 0x0f, 0x0, HDA_OUTPUT),
4683 HDA_CODEC_MUTE("Headphone Playback Switch", 0x10, 0x0, HDA_OUTPUT),
4687 static struct hda_verb alc260_hp_3013_unsol_verbs[] = {
4688 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
4692 static void alc260_hp_3013_automute(struct hda_codec *codec)
4694 struct alc_spec *spec = codec->spec;
4695 unsigned int present;
4697 present = snd_hda_codec_read(codec, 0x15, 0,
4698 AC_VERB_GET_PIN_SENSE, 0);
4699 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
4700 alc260_hp_master_update(codec, 0x15, 0x10, 0x11);
4703 static void alc260_hp_3013_unsol_event(struct hda_codec *codec,
4706 if ((res >> 26) == ALC880_HP_EVENT)
4707 alc260_hp_3013_automute(codec);
4710 static void alc260_hp_3012_automute(struct hda_codec *codec)
4712 unsigned int present, bits;
4714 present = snd_hda_codec_read(codec, 0x10, 0,
4715 AC_VERB_GET_PIN_SENSE, 0) & AC_PINSENSE_PRESENCE;
4717 bits = present ? 0 : PIN_OUT;
4718 snd_hda_codec_write(codec, 0x0f, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4720 snd_hda_codec_write(codec, 0x11, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4722 snd_hda_codec_write(codec, 0x15, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4726 static void alc260_hp_3012_unsol_event(struct hda_codec *codec,
4729 if ((res >> 26) == ALC880_HP_EVENT)
4730 alc260_hp_3012_automute(codec);
4733 /* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12,
4734 * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10.
4736 static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
4737 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4738 HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
4739 ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
4740 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4741 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4742 HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
4743 HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
4744 ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
4745 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4746 HDA_BIND_MUTE("Speaker Playback Switch", 0x09, 2, HDA_INPUT),
4750 /* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current
4751 * versions of the ALC260 don't act on requests to enable mic bias from NID
4752 * 0x0f (used to drive the headphone jack in these laptops). The ALC260
4753 * datasheet doesn't mention this restriction. At this stage it's not clear
4754 * whether this behaviour is intentional or is a hardware bug in chip
4755 * revisions available in early 2006. Therefore for now allow the
4756 * "Headphone Jack Mode" control to span all choices, but if it turns out
4757 * that the lack of mic bias for this NID is intentional we could change the
4758 * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
4760 * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006
4761 * don't appear to make the mic bias available from the "line" jack, even
4762 * though the NID used for this jack (0x14) can supply it. The theory is
4763 * that perhaps Acer have included blocking capacitors between the ALC260
4764 * and the output jack. If this turns out to be the case for all such
4765 * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
4766 * to ALC_PIN_DIR_INOUT_NOMICBIAS.
4768 * The C20x Tablet series have a mono internal speaker which is controlled
4769 * via the chip's Mono sum widget and pin complex, so include the necessary
4770 * controls for such models. On models without a "mono speaker" the control
4771 * won't do anything.
4773 static struct snd_kcontrol_new alc260_acer_mixer[] = {
4774 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4775 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
4776 ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
4777 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
4779 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2,
4781 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4782 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4783 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4784 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4785 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
4786 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
4787 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
4788 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
4792 /* Maxdata Favorit 100XS: one output and one input (0x12) jack
4794 static struct snd_kcontrol_new alc260_favorit100_mixer[] = {
4795 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4796 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
4797 ALC_PIN_MODE("Output Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
4798 HDA_CODEC_VOLUME("Line/Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4799 HDA_CODEC_MUTE("Line/Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4800 ALC_PIN_MODE("Line/Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
4804 /* Packard bell V7900 ALC260 pin usage: HP = 0x0f, Mic jack = 0x12,
4805 * Line In jack = 0x14, CD audio = 0x16, pc beep = 0x17.
4807 static struct snd_kcontrol_new alc260_will_mixer[] = {
4808 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4809 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
4810 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4811 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4812 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
4813 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
4814 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
4815 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
4816 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4817 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4821 /* Replacer 672V ALC260 pin usage: Mic jack = 0x12,
4822 * Line In jack = 0x14, ATAPI Mic = 0x13, speaker = 0x0f.
4824 static struct snd_kcontrol_new alc260_replacer_672v_mixer[] = {
4825 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4826 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
4827 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4828 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4829 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
4830 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x07, 0x1, HDA_INPUT),
4831 HDA_CODEC_MUTE("ATATI Mic Playback Switch", 0x07, 0x1, HDA_INPUT),
4832 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
4833 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
4834 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
4839 * initialization verbs
4841 static struct hda_verb alc260_init_verbs[] = {
4842 /* Line In pin widget for input */
4843 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
4844 /* CD pin widget for input */
4845 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
4846 /* Mic1 (rear panel) pin widget for input and vref at 80% */
4847 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
4848 /* Mic2 (front panel) pin widget for input and vref at 80% */
4849 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
4850 /* LINE-2 is used for line-out in rear */
4851 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4852 /* select line-out */
4853 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
4855 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4857 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4859 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4860 /* mute capture amp left and right */
4861 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4862 /* set connection select to line in (default select for this ADC) */
4863 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
4864 /* mute capture amp left and right */
4865 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4866 /* set connection select to line in (default select for this ADC) */
4867 {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
4868 /* set vol=0 Line-Out mixer amp left and right */
4869 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4870 /* unmute pin widget amp left and right (no gain on this amp) */
4871 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4872 /* set vol=0 HP mixer amp left and right */
4873 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4874 /* unmute pin widget amp left and right (no gain on this amp) */
4875 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4876 /* set vol=0 Mono mixer amp left and right */
4877 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4878 /* unmute pin widget amp left and right (no gain on this amp) */
4879 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4880 /* unmute LINE-2 out pin */
4881 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4882 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
4885 /* mute analog inputs */
4886 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4887 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4888 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4889 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4890 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
4891 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
4892 /* mute Front out path */
4893 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4894 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4895 /* mute Headphone out path */
4896 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4897 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4898 /* mute Mono out path */
4899 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4900 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4904 #if 0 /* should be identical with alc260_init_verbs? */
4905 static struct hda_verb alc260_hp_init_verbs[] = {
4906 /* Headphone and output */
4907 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
4909 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
4910 /* Mic1 (rear panel) pin widget for input and vref at 80% */
4911 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
4912 /* Mic2 (front panel) pin widget for input and vref at 80% */
4913 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
4914 /* Line In pin widget for input */
4915 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
4916 /* Line-2 pin widget for output */
4917 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
4918 /* CD pin widget for input */
4919 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
4920 /* unmute amp left and right */
4921 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
4922 /* set connection select to line in (default select for this ADC) */
4923 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
4924 /* unmute Line-Out mixer amp left and right (volume = 0) */
4925 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
4926 /* mute pin widget amp left and right (no gain on this amp) */
4927 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
4928 /* unmute HP mixer amp left and right (volume = 0) */
4929 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
4930 /* mute pin widget amp left and right (no gain on this amp) */
4931 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
4932 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
4935 /* mute analog inputs */
4936 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4937 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4938 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4939 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4940 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
4941 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
4942 /* Unmute Front out path */
4943 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4944 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4945 /* Unmute Headphone out path */
4946 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4947 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4948 /* Unmute Mono out path */
4949 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4950 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4955 static struct hda_verb alc260_hp_3013_init_verbs[] = {
4956 /* Line out and output */
4957 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
4959 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
4960 /* Mic1 (rear panel) pin widget for input and vref at 80% */
4961 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
4962 /* Mic2 (front panel) pin widget for input and vref at 80% */
4963 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
4964 /* Line In pin widget for input */
4965 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
4966 /* Headphone pin widget for output */
4967 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
4968 /* CD pin widget for input */
4969 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
4970 /* unmute amp left and right */
4971 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
4972 /* set connection select to line in (default select for this ADC) */
4973 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
4974 /* unmute Line-Out mixer amp left and right (volume = 0) */
4975 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
4976 /* mute pin widget amp left and right (no gain on this amp) */
4977 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
4978 /* unmute HP mixer amp left and right (volume = 0) */
4979 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
4980 /* mute pin widget amp left and right (no gain on this amp) */
4981 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
4982 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
4985 /* mute analog inputs */
4986 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4987 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4988 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4989 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4990 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
4991 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
4992 /* Unmute Front out path */
4993 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4994 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4995 /* Unmute Headphone out path */
4996 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4997 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4998 /* Unmute Mono out path */
4999 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5000 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5004 /* Initialisation sequence for ALC260 as configured in Fujitsu S702x
5005 * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD
5006 * audio = 0x16, internal speaker = 0x10.
5008 static struct hda_verb alc260_fujitsu_init_verbs[] = {
5009 /* Disable all GPIOs */
5010 {0x01, AC_VERB_SET_GPIO_MASK, 0},
5011 /* Internal speaker is connected to headphone pin */
5012 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5013 /* Headphone/Line-out jack connects to Line1 pin; make it an output */
5014 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5015 /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
5016 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
5017 /* Ensure all other unused pins are disabled and muted. */
5018 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5019 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5020 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5021 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5022 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5023 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5024 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5025 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5027 /* Disable digital (SPDIF) pins */
5028 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5029 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
5031 /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
5032 * when acting as an output.
5034 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5036 /* Start with output sum widgets muted and their output gains at min */
5037 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5038 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5039 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5040 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5041 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5042 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5043 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5044 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5045 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5047 /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
5048 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5049 /* Unmute Line1 pin widget output buffer since it starts as an output.
5050 * If the pin mode is changed by the user the pin mode control will
5051 * take care of enabling the pin's input/output buffers as needed.
5052 * Therefore there's no need to enable the input buffer at this
5055 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5056 /* Unmute input buffer of pin widget used for Line-in (no equiv
5059 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5061 /* Mute capture amp left and right */
5062 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5063 /* Set ADC connection select to match default mixer setting - line
5066 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5068 /* Do the same for the second ADC: mute capture input amp and
5069 * set ADC connection to line in (on mic1 pin)
5071 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5072 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
5074 /* Mute all inputs to mixer widget (even unconnected ones) */
5075 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5076 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5077 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5078 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5079 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5080 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5081 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5082 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
5087 /* Initialisation sequence for ALC260 as configured in Acer TravelMate and
5088 * similar laptops (adapted from Fujitsu init verbs).
5090 static struct hda_verb alc260_acer_init_verbs[] = {
5091 /* On TravelMate laptops, GPIO 0 enables the internal speaker and
5092 * the headphone jack. Turn this on and rely on the standard mute
5093 * methods whenever the user wants to turn these outputs off.
5095 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
5096 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
5097 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
5098 /* Internal speaker/Headphone jack is connected to Line-out pin */
5099 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5100 /* Internal microphone/Mic jack is connected to Mic1 pin */
5101 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
5102 /* Line In jack is connected to Line1 pin */
5103 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
5104 /* Some Acers (eg: C20x Tablets) use Mono pin for internal speaker */
5105 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5106 /* Ensure all other unused pins are disabled and muted. */
5107 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5108 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5109 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5110 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5111 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5112 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5113 /* Disable digital (SPDIF) pins */
5114 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5115 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
5117 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
5118 * bus when acting as outputs.
5120 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
5121 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5123 /* Start with output sum widgets muted and their output gains at min */
5124 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5125 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5126 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5127 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5128 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5129 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5130 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5131 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5132 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5134 /* Unmute Line-out pin widget amp left and right
5135 * (no equiv mixer ctrl)
5137 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5138 /* Unmute mono pin widget amp output (no equiv mixer ctrl) */
5139 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5140 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
5141 * inputs. If the pin mode is changed by the user the pin mode control
5142 * will take care of enabling the pin's input/output buffers as needed.
5143 * Therefore there's no need to enable the input buffer at this
5146 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5147 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5149 /* Mute capture amp left and right */
5150 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5151 /* Set ADC connection select to match default mixer setting - mic
5154 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5156 /* Do similar with the second ADC: mute capture input amp and
5157 * set ADC connection to mic to match ALSA's default state.
5159 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5160 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
5162 /* Mute all inputs to mixer widget (even unconnected ones) */
5163 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5164 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5165 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5166 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5167 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5168 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5169 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5170 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
5175 /* Initialisation sequence for Maxdata Favorit 100XS
5176 * (adapted from Acer init verbs).
5178 static struct hda_verb alc260_favorit100_init_verbs[] = {
5179 /* GPIO 0 enables the output jack.
5180 * Turn this on and rely on the standard mute
5181 * methods whenever the user wants to turn these outputs off.
5183 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
5184 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
5185 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
5186 /* Line/Mic input jack is connected to Mic1 pin */
5187 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
5188 /* Ensure all other unused pins are disabled and muted. */
5189 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5190 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5191 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5192 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5193 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5194 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5195 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5196 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5197 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5198 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5199 /* Disable digital (SPDIF) pins */
5200 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5201 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
5203 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
5204 * bus when acting as outputs.
5206 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
5207 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5209 /* Start with output sum widgets muted and their output gains at min */
5210 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5211 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5212 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5213 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5214 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5215 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5216 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5217 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5218 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5220 /* Unmute Line-out pin widget amp left and right
5221 * (no equiv mixer ctrl)
5223 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5224 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
5225 * inputs. If the pin mode is changed by the user the pin mode control
5226 * will take care of enabling the pin's input/output buffers as needed.
5227 * Therefore there's no need to enable the input buffer at this
5230 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5232 /* Mute capture amp left and right */
5233 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5234 /* Set ADC connection select to match default mixer setting - mic
5237 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5239 /* Do similar with the second ADC: mute capture input amp and
5240 * set ADC connection to mic to match ALSA's default state.
5242 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5243 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
5245 /* Mute all inputs to mixer widget (even unconnected ones) */
5246 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5247 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5248 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5249 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5250 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5251 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5252 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5253 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
5258 static struct hda_verb alc260_will_verbs[] = {
5259 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5260 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x00},
5261 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
5262 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
5263 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
5264 {0x1a, AC_VERB_SET_PROC_COEF, 0x3040},
5268 static struct hda_verb alc260_replacer_672v_verbs[] = {
5269 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
5270 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
5271 {0x1a, AC_VERB_SET_PROC_COEF, 0x3050},
5273 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
5274 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
5275 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
5277 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5281 /* toggle speaker-output according to the hp-jack state */
5282 static void alc260_replacer_672v_automute(struct hda_codec *codec)
5284 unsigned int present;
5286 /* speaker --> GPIO Data 0, hp or spdif --> GPIO data 1 */
5287 present = snd_hda_codec_read(codec, 0x0f, 0,
5288 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
5290 snd_hda_codec_write_cache(codec, 0x01, 0,
5291 AC_VERB_SET_GPIO_DATA, 1);
5292 snd_hda_codec_write_cache(codec, 0x0f, 0,
5293 AC_VERB_SET_PIN_WIDGET_CONTROL,
5296 snd_hda_codec_write_cache(codec, 0x01, 0,
5297 AC_VERB_SET_GPIO_DATA, 0);
5298 snd_hda_codec_write_cache(codec, 0x0f, 0,
5299 AC_VERB_SET_PIN_WIDGET_CONTROL,
5304 static void alc260_replacer_672v_unsol_event(struct hda_codec *codec,
5307 if ((res >> 26) == ALC880_HP_EVENT)
5308 alc260_replacer_672v_automute(codec);
5311 static struct hda_verb alc260_hp_dc7600_verbs[] = {
5312 {0x05, AC_VERB_SET_CONNECT_SEL, 0x01},
5313 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
5314 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5315 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5316 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5317 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5318 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5319 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5320 {0x11, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5321 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5325 /* Test configuration for debugging, modelled after the ALC880 test
5328 #ifdef CONFIG_SND_DEBUG
5329 static hda_nid_t alc260_test_dac_nids[1] = {
5332 static hda_nid_t alc260_test_adc_nids[2] = {
5335 /* For testing the ALC260, each input MUX needs its own definition since
5336 * the signal assignments are different. This assumes that the first ADC
5339 static struct hda_input_mux alc260_test_capture_sources[2] = {
5343 { "MIC1 pin", 0x0 },
5344 { "MIC2 pin", 0x1 },
5345 { "LINE1 pin", 0x2 },
5346 { "LINE2 pin", 0x3 },
5348 { "LINE-OUT pin", 0x5 },
5349 { "HP-OUT pin", 0x6 },
5355 { "MIC1 pin", 0x0 },
5356 { "MIC2 pin", 0x1 },
5357 { "LINE1 pin", 0x2 },
5358 { "LINE2 pin", 0x3 },
5361 { "LINE-OUT pin", 0x6 },
5362 { "HP-OUT pin", 0x7 },
5366 static struct snd_kcontrol_new alc260_test_mixer[] = {
5367 /* Output driver widgets */
5368 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
5369 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
5370 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5371 HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
5372 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5373 HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
5375 /* Modes for retasking pin widgets
5376 * Note: the ALC260 doesn't seem to act on requests to enable mic
5377 * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't
5378 * mention this restriction. At this stage it's not clear whether
5379 * this behaviour is intentional or is a hardware bug in chip
5380 * revisions available at least up until early 2006. Therefore for
5381 * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all
5382 * choices, but if it turns out that the lack of mic bias for these
5383 * NIDs is intentional we could change their modes from
5384 * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
5386 ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
5387 ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
5388 ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
5389 ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
5390 ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
5391 ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
5393 /* Loopback mixer controls */
5394 HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
5395 HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
5396 HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
5397 HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
5398 HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
5399 HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
5400 HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
5401 HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
5402 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5403 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
5404 HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
5405 HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
5406 HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
5407 HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
5409 /* Controls for GPIO pins, assuming they are configured as outputs */
5410 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
5411 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
5412 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
5413 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
5415 /* Switches to allow the digital IO pins to be enabled. The datasheet
5416 * is ambigious as to which NID is which; testing on laptops which
5417 * make this output available should provide clarification.
5419 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
5420 ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
5422 /* A switch allowing EAPD to be enabled. Some laptops seem to use
5423 * this output to turn on an external amplifier.
5425 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
5426 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
5430 static struct hda_verb alc260_test_init_verbs[] = {
5431 /* Enable all GPIOs as outputs with an initial value of 0 */
5432 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
5433 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
5434 {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
5436 /* Enable retasking pins as output, initially without power amp */
5437 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5438 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5439 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5440 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5441 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5442 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5444 /* Disable digital (SPDIF) pins initially, but users can enable
5445 * them via a mixer switch. In the case of SPDIF-out, this initverb
5446 * payload also sets the generation to 0, output to be in "consumer"
5447 * PCM format, copyright asserted, no pre-emphasis and no validity
5450 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5451 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
5453 /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
5454 * OUT1 sum bus when acting as an output.
5456 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
5457 {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
5458 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5459 {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
5461 /* Start with output sum widgets muted and their output gains at min */
5462 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5463 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5464 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5465 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5466 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5467 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5468 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5469 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5470 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5472 /* Unmute retasking pin widget output buffers since the default
5473 * state appears to be output. As the pin mode is changed by the
5474 * user the pin mode control will take care of enabling the pin's
5475 * input/output buffers as needed.
5477 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5478 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5479 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5480 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5481 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5482 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5483 /* Also unmute the mono-out pin widget */
5484 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5486 /* Mute capture amp left and right */
5487 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5488 /* Set ADC connection select to match default mixer setting (mic1
5491 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5493 /* Do the same for the second ADC: mute capture input amp and
5494 * set ADC connection to mic1 pin
5496 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5497 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
5499 /* Mute all inputs to mixer widget (even unconnected ones) */
5500 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5501 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5502 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5503 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5504 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5505 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5506 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5507 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
5513 #define alc260_pcm_analog_playback alc880_pcm_analog_alt_playback
5514 #define alc260_pcm_analog_capture alc880_pcm_analog_capture
5516 #define alc260_pcm_digital_playback alc880_pcm_digital_playback
5517 #define alc260_pcm_digital_capture alc880_pcm_digital_capture
5520 * for BIOS auto-configuration
5523 static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
5524 const char *pfx, int *vol_bits)
5527 unsigned long vol_val, sw_val;
5531 if (nid >= 0x0f && nid < 0x11) {
5532 nid_vol = nid - 0x7;
5533 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
5534 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
5535 } else if (nid == 0x11) {
5536 nid_vol = nid - 0x7;
5537 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
5538 sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
5539 } else if (nid >= 0x12 && nid <= 0x15) {
5541 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
5542 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
5546 if (!(*vol_bits & (1 << nid_vol))) {
5547 /* first control for the volume widget */
5548 snprintf(name, sizeof(name), "%s Playback Volume", pfx);
5549 err = add_control(spec, ALC_CTL_WIDGET_VOL, name, vol_val);
5552 *vol_bits |= (1 << nid_vol);
5554 snprintf(name, sizeof(name), "%s Playback Switch", pfx);
5555 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, sw_val);
5561 /* add playback controls from the parsed DAC table */
5562 static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
5563 const struct auto_pin_cfg *cfg)
5569 spec->multiout.num_dacs = 1;
5570 spec->multiout.dac_nids = spec->private_dac_nids;
5571 spec->multiout.dac_nids[0] = 0x02;
5573 nid = cfg->line_out_pins[0];
5575 err = alc260_add_playback_controls(spec, nid, "Front", &vols);
5580 nid = cfg->speaker_pins[0];
5582 err = alc260_add_playback_controls(spec, nid, "Speaker", &vols);
5587 nid = cfg->hp_pins[0];
5589 err = alc260_add_playback_controls(spec, nid, "Headphone",
5597 /* create playback/capture controls for input pins */
5598 static int alc260_auto_create_analog_input_ctls(struct alc_spec *spec,
5599 const struct auto_pin_cfg *cfg)
5601 struct hda_input_mux *imux = &spec->private_imux[0];
5604 for (i = 0; i < AUTO_PIN_LAST; i++) {
5605 if (cfg->input_pins[i] >= 0x12) {
5606 idx = cfg->input_pins[i] - 0x12;
5607 err = new_analog_input(spec, cfg->input_pins[i],
5608 auto_pin_cfg_labels[i], idx,
5612 imux->items[imux->num_items].label =
5613 auto_pin_cfg_labels[i];
5614 imux->items[imux->num_items].index = idx;
5617 if (cfg->input_pins[i] >= 0x0f && cfg->input_pins[i] <= 0x10){
5618 idx = cfg->input_pins[i] - 0x09;
5619 err = new_analog_input(spec, cfg->input_pins[i],
5620 auto_pin_cfg_labels[i], idx,
5624 imux->items[imux->num_items].label =
5625 auto_pin_cfg_labels[i];
5626 imux->items[imux->num_items].index = idx;
5633 static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
5634 hda_nid_t nid, int pin_type,
5637 alc_set_pin_output(codec, nid, pin_type);
5638 /* need the manual connection? */
5640 int idx = nid - 0x12;
5641 snd_hda_codec_write(codec, idx + 0x0b, 0,
5642 AC_VERB_SET_CONNECT_SEL, sel_idx);
5646 static void alc260_auto_init_multi_out(struct hda_codec *codec)
5648 struct alc_spec *spec = codec->spec;
5651 alc_subsystem_id(codec, 0x10, 0x15, 0x0f);
5652 nid = spec->autocfg.line_out_pins[0];
5654 int pin_type = get_pin_type(spec->autocfg.line_out_type);
5655 alc260_auto_set_output_and_unmute(codec, nid, pin_type, 0);
5658 nid = spec->autocfg.speaker_pins[0];
5660 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
5662 nid = spec->autocfg.hp_pins[0];
5664 alc260_auto_set_output_and_unmute(codec, nid, PIN_HP, 0);
5667 #define ALC260_PIN_CD_NID 0x16
5668 static void alc260_auto_init_analog_input(struct hda_codec *codec)
5670 struct alc_spec *spec = codec->spec;
5673 for (i = 0; i < AUTO_PIN_LAST; i++) {
5674 hda_nid_t nid = spec->autocfg.input_pins[i];
5676 alc_set_input_pin(codec, nid, i);
5677 if (nid != ALC260_PIN_CD_NID &&
5678 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
5679 snd_hda_codec_write(codec, nid, 0,
5680 AC_VERB_SET_AMP_GAIN_MUTE,
5687 * generic initialization of ADC, input mixers and output mixers
5689 static struct hda_verb alc260_volume_init_verbs[] = {
5691 * Unmute ADC0-1 and set the default input to mic-in
5693 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5694 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5695 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
5696 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5698 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
5700 * Note: PASD motherboards uses the Line In 2 as the input for
5701 * front panel mic (mic 2)
5703 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
5704 /* mute analog inputs */
5705 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5706 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5707 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5708 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5709 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5712 * Set up output mixers (0x08 - 0x0a)
5714 /* set vol=0 to output mixers */
5715 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5716 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5717 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5718 /* set up input amps for analog loopback */
5719 /* Amp Indices: DAC = 0, mixer = 1 */
5720 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5721 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5722 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5723 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5724 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5725 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5730 static int alc260_parse_auto_config(struct hda_codec *codec)
5732 struct alc_spec *spec = codec->spec;
5734 static hda_nid_t alc260_ignore[] = { 0x17, 0 };
5736 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
5740 err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg);
5743 if (!spec->kctls.list)
5744 return 0; /* can't find valid BIOS pin config */
5745 err = alc260_auto_create_analog_input_ctls(spec, &spec->autocfg);
5749 spec->multiout.max_channels = 2;
5751 if (spec->autocfg.dig_outs)
5752 spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
5753 if (spec->kctls.list)
5754 add_mixer(spec, spec->kctls.list);
5756 add_verb(spec, alc260_volume_init_verbs);
5758 spec->num_mux_defs = 1;
5759 spec->input_mux = &spec->private_imux[0];
5764 /* additional initialization for auto-configuration model */
5765 static void alc260_auto_init(struct hda_codec *codec)
5767 struct alc_spec *spec = codec->spec;
5768 alc260_auto_init_multi_out(codec);
5769 alc260_auto_init_analog_input(codec);
5770 if (spec->unsol_event)
5771 alc_inithook(codec);
5774 #ifdef CONFIG_SND_HDA_POWER_SAVE
5775 static struct hda_amp_list alc260_loopbacks[] = {
5776 { 0x07, HDA_INPUT, 0 },
5777 { 0x07, HDA_INPUT, 1 },
5778 { 0x07, HDA_INPUT, 2 },
5779 { 0x07, HDA_INPUT, 3 },
5780 { 0x07, HDA_INPUT, 4 },
5786 * ALC260 configurations
5788 static const char *alc260_models[ALC260_MODEL_LAST] = {
5789 [ALC260_BASIC] = "basic",
5791 [ALC260_HP_3013] = "hp-3013",
5792 [ALC260_HP_DC7600] = "hp-dc7600",
5793 [ALC260_FUJITSU_S702X] = "fujitsu",
5794 [ALC260_ACER] = "acer",
5795 [ALC260_WILL] = "will",
5796 [ALC260_REPLACER_672V] = "replacer",
5797 [ALC260_FAVORIT100] = "favorit100",
5798 #ifdef CONFIG_SND_DEBUG
5799 [ALC260_TEST] = "test",
5801 [ALC260_AUTO] = "auto",
5804 static struct snd_pci_quirk alc260_cfg_tbl[] = {
5805 SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER),
5806 SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER),
5807 SND_PCI_QUIRK(0x1509, 0x4540, "Favorit 100XS", ALC260_FAVORIT100),
5808 SND_PCI_QUIRK(0x103c, 0x2808, "HP d5700", ALC260_HP_3013),
5809 SND_PCI_QUIRK(0x103c, 0x280a, "HP d5750", ALC260_HP_3013),
5810 SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013),
5811 SND_PCI_QUIRK(0x103c, 0x3011, "HP", ALC260_HP_3013),
5812 SND_PCI_QUIRK(0x103c, 0x3012, "HP", ALC260_HP_DC7600),
5813 SND_PCI_QUIRK(0x103c, 0x3013, "HP", ALC260_HP_3013),
5814 SND_PCI_QUIRK(0x103c, 0x3014, "HP", ALC260_HP),
5815 SND_PCI_QUIRK(0x103c, 0x3015, "HP", ALC260_HP),
5816 SND_PCI_QUIRK(0x103c, 0x3016, "HP", ALC260_HP),
5817 SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_BASIC),
5818 SND_PCI_QUIRK(0x104d, 0x81cc, "Sony VAIO", ALC260_BASIC),
5819 SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC),
5820 SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X),
5821 SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC),
5822 SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_REPLACER_672V),
5823 SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_WILL),
5827 static struct alc_config_preset alc260_presets[] = {
5829 .mixers = { alc260_base_output_mixer,
5830 alc260_input_mixer },
5831 .init_verbs = { alc260_init_verbs },
5832 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5833 .dac_nids = alc260_dac_nids,
5834 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
5835 .adc_nids = alc260_adc_nids,
5836 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5837 .channel_mode = alc260_modes,
5838 .input_mux = &alc260_capture_source,
5841 .mixers = { alc260_hp_output_mixer,
5842 alc260_input_mixer },
5843 .init_verbs = { alc260_init_verbs,
5844 alc260_hp_unsol_verbs },
5845 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5846 .dac_nids = alc260_dac_nids,
5847 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
5848 .adc_nids = alc260_adc_nids_alt,
5849 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5850 .channel_mode = alc260_modes,
5851 .input_mux = &alc260_capture_source,
5852 .unsol_event = alc260_hp_unsol_event,
5853 .init_hook = alc260_hp_automute,
5855 [ALC260_HP_DC7600] = {
5856 .mixers = { alc260_hp_dc7600_mixer,
5857 alc260_input_mixer },
5858 .init_verbs = { alc260_init_verbs,
5859 alc260_hp_dc7600_verbs },
5860 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5861 .dac_nids = alc260_dac_nids,
5862 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
5863 .adc_nids = alc260_adc_nids_alt,
5864 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5865 .channel_mode = alc260_modes,
5866 .input_mux = &alc260_capture_source,
5867 .unsol_event = alc260_hp_3012_unsol_event,
5868 .init_hook = alc260_hp_3012_automute,
5870 [ALC260_HP_3013] = {
5871 .mixers = { alc260_hp_3013_mixer,
5872 alc260_input_mixer },
5873 .init_verbs = { alc260_hp_3013_init_verbs,
5874 alc260_hp_3013_unsol_verbs },
5875 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5876 .dac_nids = alc260_dac_nids,
5877 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
5878 .adc_nids = alc260_adc_nids_alt,
5879 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5880 .channel_mode = alc260_modes,
5881 .input_mux = &alc260_capture_source,
5882 .unsol_event = alc260_hp_3013_unsol_event,
5883 .init_hook = alc260_hp_3013_automute,
5885 [ALC260_FUJITSU_S702X] = {
5886 .mixers = { alc260_fujitsu_mixer },
5887 .init_verbs = { alc260_fujitsu_init_verbs },
5888 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5889 .dac_nids = alc260_dac_nids,
5890 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
5891 .adc_nids = alc260_dual_adc_nids,
5892 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5893 .channel_mode = alc260_modes,
5894 .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources),
5895 .input_mux = alc260_fujitsu_capture_sources,
5898 .mixers = { alc260_acer_mixer },
5899 .init_verbs = { alc260_acer_init_verbs },
5900 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5901 .dac_nids = alc260_dac_nids,
5902 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
5903 .adc_nids = alc260_dual_adc_nids,
5904 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5905 .channel_mode = alc260_modes,
5906 .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
5907 .input_mux = alc260_acer_capture_sources,
5909 [ALC260_FAVORIT100] = {
5910 .mixers = { alc260_favorit100_mixer },
5911 .init_verbs = { alc260_favorit100_init_verbs },
5912 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5913 .dac_nids = alc260_dac_nids,
5914 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
5915 .adc_nids = alc260_dual_adc_nids,
5916 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5917 .channel_mode = alc260_modes,
5918 .num_mux_defs = ARRAY_SIZE(alc260_favorit100_capture_sources),
5919 .input_mux = alc260_favorit100_capture_sources,
5922 .mixers = { alc260_will_mixer },
5923 .init_verbs = { alc260_init_verbs, alc260_will_verbs },
5924 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5925 .dac_nids = alc260_dac_nids,
5926 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
5927 .adc_nids = alc260_adc_nids,
5928 .dig_out_nid = ALC260_DIGOUT_NID,
5929 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5930 .channel_mode = alc260_modes,
5931 .input_mux = &alc260_capture_source,
5933 [ALC260_REPLACER_672V] = {
5934 .mixers = { alc260_replacer_672v_mixer },
5935 .init_verbs = { alc260_init_verbs, alc260_replacer_672v_verbs },
5936 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5937 .dac_nids = alc260_dac_nids,
5938 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
5939 .adc_nids = alc260_adc_nids,
5940 .dig_out_nid = ALC260_DIGOUT_NID,
5941 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5942 .channel_mode = alc260_modes,
5943 .input_mux = &alc260_capture_source,
5944 .unsol_event = alc260_replacer_672v_unsol_event,
5945 .init_hook = alc260_replacer_672v_automute,
5947 #ifdef CONFIG_SND_DEBUG
5949 .mixers = { alc260_test_mixer },
5950 .init_verbs = { alc260_test_init_verbs },
5951 .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
5952 .dac_nids = alc260_test_dac_nids,
5953 .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
5954 .adc_nids = alc260_test_adc_nids,
5955 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5956 .channel_mode = alc260_modes,
5957 .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources),
5958 .input_mux = alc260_test_capture_sources,
5963 static int patch_alc260(struct hda_codec *codec)
5965 struct alc_spec *spec;
5966 int err, board_config;
5968 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5974 board_config = snd_hda_check_board_config(codec, ALC260_MODEL_LAST,
5977 if (board_config < 0) {
5978 snd_printd(KERN_INFO "hda_codec: Unknown model for ALC260, "
5979 "trying auto-probe from BIOS...\n");
5980 board_config = ALC260_AUTO;
5983 if (board_config == ALC260_AUTO) {
5984 /* automatic parse from the BIOS config */
5985 err = alc260_parse_auto_config(codec);
5991 "hda_codec: Cannot set up configuration "
5992 "from BIOS. Using base mode...\n");
5993 board_config = ALC260_BASIC;
5997 err = snd_hda_attach_beep_device(codec, 0x1);
6003 if (board_config != ALC260_AUTO)
6004 setup_preset(spec, &alc260_presets[board_config]);
6006 spec->stream_name_analog = "ALC260 Analog";
6007 spec->stream_analog_playback = &alc260_pcm_analog_playback;
6008 spec->stream_analog_capture = &alc260_pcm_analog_capture;
6010 spec->stream_name_digital = "ALC260 Digital";
6011 spec->stream_digital_playback = &alc260_pcm_digital_playback;
6012 spec->stream_digital_capture = &alc260_pcm_digital_capture;
6014 if (!spec->adc_nids && spec->input_mux) {
6015 /* check whether NID 0x04 is valid */
6016 unsigned int wcap = get_wcaps(codec, 0x04);
6017 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
6019 if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
6020 spec->adc_nids = alc260_adc_nids_alt;
6021 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
6023 spec->adc_nids = alc260_adc_nids;
6024 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
6027 set_capture_mixer(spec);
6028 set_beep_amp(spec, 0x07, 0x05, HDA_INPUT);
6030 spec->vmaster_nid = 0x08;
6032 codec->patch_ops = alc_patch_ops;
6033 if (board_config == ALC260_AUTO)
6034 spec->init_hook = alc260_auto_init;
6035 #ifdef CONFIG_SND_HDA_POWER_SAVE
6036 if (!spec->loopback.amplist)
6037 spec->loopback.amplist = alc260_loopbacks;
6039 codec->proc_widget_hook = print_realtek_coef;
6048 * ALC882 is almost identical with ALC880 but has cleaner and more flexible
6049 * configuration. Each pin widget can choose any input DACs and a mixer.
6050 * Each ADC is connected from a mixer of all inputs. This makes possible
6051 * 6-channel independent captures.
6053 * In addition, an independent DAC for the multi-playback (not used in this
6056 #define ALC882_DIGOUT_NID 0x06
6057 #define ALC882_DIGIN_NID 0x0a
6059 static struct hda_channel_mode alc882_ch_modes[1] = {
6063 static hda_nid_t alc882_dac_nids[4] = {
6064 /* front, rear, clfe, rear_surr */
6065 0x02, 0x03, 0x04, 0x05
6068 /* identical with ALC880 */
6069 #define alc882_adc_nids alc880_adc_nids
6070 #define alc882_adc_nids_alt alc880_adc_nids_alt
6072 static hda_nid_t alc882_capsrc_nids[3] = { 0x24, 0x23, 0x22 };
6073 static hda_nid_t alc882_capsrc_nids_alt[2] = { 0x23, 0x22 };
6076 /* FIXME: should be a matrix-type input source selection */
6078 static struct hda_input_mux alc882_capture_source = {
6082 { "Front Mic", 0x1 },
6090 static struct hda_verb alc882_3ST_ch2_init[] = {
6091 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6092 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6093 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6094 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6101 static struct hda_verb alc882_3ST_ch6_init[] = {
6102 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6103 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6104 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
6105 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6106 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6107 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6111 static struct hda_channel_mode alc882_3ST_6ch_modes[2] = {
6112 { 2, alc882_3ST_ch2_init },
6113 { 6, alc882_3ST_ch6_init },
6119 static struct hda_verb alc882_sixstack_ch6_init[] = {
6120 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
6121 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6122 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6123 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6130 static struct hda_verb alc882_sixstack_ch8_init[] = {
6131 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6132 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6133 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6134 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6138 static struct hda_channel_mode alc882_sixstack_modes[2] = {
6139 { 6, alc882_sixstack_ch6_init },
6140 { 8, alc882_sixstack_ch8_init },
6144 * macbook pro ALC885 can switch LineIn to LineOut without loosing Mic
6150 static struct hda_verb alc885_mbp_ch2_init[] = {
6151 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6152 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6153 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6160 static struct hda_verb alc885_mbp_ch6_init[] = {
6161 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6162 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6163 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6164 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6165 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6169 static struct hda_channel_mode alc885_mbp_6ch_modes[2] = {
6170 { 2, alc885_mbp_ch2_init },
6171 { 6, alc885_mbp_ch6_init },
6175 /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
6176 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
6178 static struct snd_kcontrol_new alc882_base_mixer[] = {
6179 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6180 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6181 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
6182 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
6183 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
6184 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
6185 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
6186 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
6187 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
6188 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
6189 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6190 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6191 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6192 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6193 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6194 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6195 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6196 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6197 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6198 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
6199 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6203 static struct snd_kcontrol_new alc885_mbp3_mixer[] = {
6204 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
6205 HDA_BIND_MUTE ("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
6206 HDA_CODEC_MUTE ("Speaker Playback Switch", 0x14, 0x00, HDA_OUTPUT),
6207 HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
6208 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6209 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6210 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
6211 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
6212 HDA_CODEC_VOLUME("Line Boost", 0x1a, 0x00, HDA_INPUT),
6213 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
6216 static struct snd_kcontrol_new alc882_w2jc_mixer[] = {
6217 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6218 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6219 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6220 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6221 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6222 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6223 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6224 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6225 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6229 static struct snd_kcontrol_new alc882_targa_mixer[] = {
6230 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6231 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6232 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6233 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6234 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6235 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6236 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6237 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6238 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6239 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6240 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6241 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6242 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
6246 /* Pin assignment: Front=0x14, HP = 0x15, Front = 0x16, ???
6247 * Front Mic=0x18, Line In = 0x1a, Line In = 0x1b, CD = 0x1c
6249 static struct snd_kcontrol_new alc882_asus_a7j_mixer[] = {
6250 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6251 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6252 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
6253 HDA_CODEC_MUTE("Mobile Front Playback Switch", 0x16, 0x0, HDA_OUTPUT),
6254 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6255 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6256 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6257 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6258 HDA_CODEC_VOLUME("Mobile Line Playback Volume", 0x0b, 0x03, HDA_INPUT),
6259 HDA_CODEC_MUTE("Mobile Line Playback Switch", 0x0b, 0x03, HDA_INPUT),
6260 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6261 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6262 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6266 static struct snd_kcontrol_new alc882_asus_a7m_mixer[] = {
6267 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6268 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6269 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
6270 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6271 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6272 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6273 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6274 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6275 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6276 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6280 static struct snd_kcontrol_new alc882_chmode_mixer[] = {
6282 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6283 .name = "Channel Mode",
6284 .info = alc_ch_mode_info,
6285 .get = alc_ch_mode_get,
6286 .put = alc_ch_mode_put,
6291 static struct hda_verb alc882_init_verbs[] = {
6292 /* Front mixer: unmute input/output amp left and right (volume = 0) */
6293 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6294 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6295 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6297 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6298 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6299 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6301 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6302 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6303 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6305 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6306 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6307 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6309 /* Front Pin: output 0 (0x0c) */
6310 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6311 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6312 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
6313 /* Rear Pin: output 1 (0x0d) */
6314 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6315 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6316 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
6317 /* CLFE Pin: output 2 (0x0e) */
6318 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6319 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6320 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
6321 /* Side Pin: output 3 (0x0f) */
6322 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6323 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6324 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
6325 /* Mic (rear) pin: input vref at 80% */
6326 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6327 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6328 /* Front Mic pin: input vref at 80% */
6329 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6330 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6331 /* Line In pin: input */
6332 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
6333 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6334 /* Line-2 In: Headphone output (output 0 - 0x0c) */
6335 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6336 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6337 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
6338 /* CD pin widget for input */
6339 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
6341 /* FIXME: use matrix-type input source selection */
6342 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6343 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
6344 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6345 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6346 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6347 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6349 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6350 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6351 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6352 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6354 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6355 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6356 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6357 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6358 /* ADC1: mute amp left and right */
6359 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6360 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
6361 /* ADC2: mute amp left and right */
6362 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6363 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6364 /* ADC3: mute amp left and right */
6365 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6366 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
6371 static struct hda_verb alc882_eapd_verbs[] = {
6372 /* change to EAPD mode */
6373 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
6374 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
6379 static struct snd_kcontrol_new alc882_macpro_mixer[] = {
6380 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6381 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6382 HDA_CODEC_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT),
6383 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
6384 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
6385 /* FIXME: this looks suspicious...
6386 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x02, HDA_INPUT),
6387 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x02, HDA_INPUT),
6392 static struct hda_verb alc882_macpro_init_verbs[] = {
6393 /* Front mixer: unmute input/output amp left and right (volume = 0) */
6394 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6395 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6396 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6397 /* Front Pin: output 0 (0x0c) */
6398 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6399 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6400 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
6401 /* Front Mic pin: input vref at 80% */
6402 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6403 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6404 /* Speaker: output */
6405 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6406 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6407 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x04},
6408 /* Headphone output (output 0 - 0x0c) */
6409 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6410 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6411 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
6413 /* FIXME: use matrix-type input source selection */
6414 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6415 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
6416 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6417 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6418 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6419 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6421 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6422 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6423 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6424 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6426 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6427 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6428 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6429 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6430 /* ADC1: mute amp left and right */
6431 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6432 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
6433 /* ADC2: mute amp left and right */
6434 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6435 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6436 /* ADC3: mute amp left and right */
6437 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6438 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
6443 /* Macbook Pro rev3 */
6444 static struct hda_verb alc885_mbp3_init_verbs[] = {
6445 /* Front mixer: unmute input/output amp left and right (volume = 0) */
6446 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6447 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6448 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6450 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6451 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6452 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6453 /* Front Pin: output 0 (0x0c) */
6454 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6455 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6456 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
6457 /* HP Pin: output 0 (0x0d) */
6458 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4},
6459 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6460 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
6461 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
6462 /* Mic (rear) pin: input vref at 80% */
6463 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6464 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6465 /* Front Mic pin: input vref at 80% */
6466 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6467 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6468 /* Line In pin: use output 1 when in LineOut mode */
6469 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
6470 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6471 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
6473 /* FIXME: use matrix-type input source selection */
6474 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6475 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
6476 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6477 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6478 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6479 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6481 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6482 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6483 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6484 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6486 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6487 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6488 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6489 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6490 /* ADC1: mute amp left and right */
6491 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6492 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
6493 /* ADC2: mute amp left and right */
6494 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6495 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6496 /* ADC3: mute amp left and right */
6497 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6498 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
6503 /* iMac 24 mixer. */
6504 static struct snd_kcontrol_new alc885_imac24_mixer[] = {
6505 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
6506 HDA_CODEC_MUTE("Master Playback Switch", 0x0c, 0x00, HDA_INPUT),
6510 /* iMac 24 init verbs. */
6511 static struct hda_verb alc885_imac24_init_verbs[] = {
6512 /* Internal speakers: output 0 (0x0c) */
6513 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6514 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6515 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
6516 /* Internal speakers: output 0 (0x0c) */
6517 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6518 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6519 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
6520 /* Headphone: output 0 (0x0c) */
6521 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6522 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6523 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
6524 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
6525 /* Front Mic: input vref at 80% */
6526 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6527 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6531 /* Toggle speaker-output according to the hp-jack state */
6532 static void alc885_imac24_automute(struct hda_codec *codec)
6534 unsigned int present;
6536 present = snd_hda_codec_read(codec, 0x14, 0,
6537 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
6538 snd_hda_codec_amp_stereo(codec, 0x18, HDA_OUTPUT, 0,
6539 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
6540 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_OUTPUT, 0,
6541 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
6544 /* Processes unsolicited events. */
6545 static void alc885_imac24_unsol_event(struct hda_codec *codec,
6548 /* Headphone insertion or removal. */
6549 if ((res >> 26) == ALC880_HP_EVENT)
6550 alc885_imac24_automute(codec);
6553 static void alc885_mbp3_automute(struct hda_codec *codec)
6555 unsigned int present;
6557 present = snd_hda_codec_read(codec, 0x15, 0,
6558 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
6559 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
6560 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
6561 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
6562 HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
6565 static void alc885_mbp3_unsol_event(struct hda_codec *codec,
6568 /* Headphone insertion or removal. */
6569 if ((res >> 26) == ALC880_HP_EVENT)
6570 alc885_mbp3_automute(codec);
6574 static struct hda_verb alc882_targa_verbs[] = {
6575 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6576 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6578 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6579 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6581 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
6582 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
6583 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6585 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
6586 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
6587 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
6588 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
6592 /* toggle speaker-output according to the hp-jack state */
6593 static void alc882_targa_automute(struct hda_codec *codec)
6595 unsigned int present;
6597 present = snd_hda_codec_read(codec, 0x14, 0,
6598 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
6599 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
6600 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
6601 snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
6605 static void alc882_targa_unsol_event(struct hda_codec *codec, unsigned int res)
6607 /* Looks like the unsol event is incompatible with the standard
6608 * definition. 4bit tag is placed at 26 bit!
6610 if (((res >> 26) == ALC880_HP_EVENT)) {
6611 alc882_targa_automute(codec);
6615 static struct hda_verb alc882_asus_a7j_verbs[] = {
6616 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6617 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6619 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6620 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6621 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6623 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
6624 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6625 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
6627 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
6628 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
6629 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6633 static struct hda_verb alc882_asus_a7m_verbs[] = {
6634 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6635 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6637 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6638 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6639 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6641 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
6642 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6643 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
6645 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
6646 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
6647 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6651 static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
6653 unsigned int gpiostate, gpiomask, gpiodir;
6655 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
6656 AC_VERB_GET_GPIO_DATA, 0);
6659 gpiostate |= (1 << pin);
6661 gpiostate &= ~(1 << pin);
6663 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
6664 AC_VERB_GET_GPIO_MASK, 0);
6665 gpiomask |= (1 << pin);
6667 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
6668 AC_VERB_GET_GPIO_DIRECTION, 0);
6669 gpiodir |= (1 << pin);
6672 snd_hda_codec_write(codec, codec->afg, 0,
6673 AC_VERB_SET_GPIO_MASK, gpiomask);
6674 snd_hda_codec_write(codec, codec->afg, 0,
6675 AC_VERB_SET_GPIO_DIRECTION, gpiodir);
6679 snd_hda_codec_write(codec, codec->afg, 0,
6680 AC_VERB_SET_GPIO_DATA, gpiostate);
6683 /* set up GPIO at initialization */
6684 static void alc885_macpro_init_hook(struct hda_codec *codec)
6686 alc882_gpio_mute(codec, 0, 0);
6687 alc882_gpio_mute(codec, 1, 0);
6690 /* set up GPIO and update auto-muting at initialization */
6691 static void alc885_imac24_init_hook(struct hda_codec *codec)
6693 alc885_macpro_init_hook(codec);
6694 alc885_imac24_automute(codec);
6698 * generic initialization of ADC, input mixers and output mixers
6700 static struct hda_verb alc882_auto_init_verbs[] = {
6702 * Unmute ADC0-2 and set the default input to mic-in
6704 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
6705 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6706 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6707 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6708 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
6709 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6711 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
6713 * Note: PASD motherboards uses the Line In 2 as the input for
6714 * front panel mic (mic 2)
6716 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
6717 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6718 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6719 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6720 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6721 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6724 * Set up output mixers (0x0c - 0x0f)
6726 /* set vol=0 to output mixers */
6727 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6728 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6729 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6730 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6731 /* set up input amps for analog loopback */
6732 /* Amp Indices: DAC = 0, mixer = 1 */
6733 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6734 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6735 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6736 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6737 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6738 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6739 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6740 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6741 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6742 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6744 /* FIXME: use matrix-type input source selection */
6745 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6746 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
6747 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6748 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
6749 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
6750 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
6752 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6753 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
6754 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
6755 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
6757 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6758 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
6759 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
6760 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
6765 #ifdef CONFIG_SND_HDA_POWER_SAVE
6766 #define alc882_loopbacks alc880_loopbacks
6769 /* pcm configuration: identiacal with ALC880 */
6770 #define alc882_pcm_analog_playback alc880_pcm_analog_playback
6771 #define alc882_pcm_analog_capture alc880_pcm_analog_capture
6772 #define alc882_pcm_digital_playback alc880_pcm_digital_playback
6773 #define alc882_pcm_digital_capture alc880_pcm_digital_capture
6776 * configuration and preset
6778 static const char *alc882_models[ALC882_MODEL_LAST] = {
6779 [ALC882_3ST_DIG] = "3stack-dig",
6780 [ALC882_6ST_DIG] = "6stack-dig",
6781 [ALC882_ARIMA] = "arima",
6782 [ALC882_W2JC] = "w2jc",
6783 [ALC882_TARGA] = "targa",
6784 [ALC882_ASUS_A7J] = "asus-a7j",
6785 [ALC882_ASUS_A7M] = "asus-a7m",
6786 [ALC885_MACPRO] = "macpro",
6787 [ALC885_MBP3] = "mbp3",
6788 [ALC885_IMAC24] = "imac24",
6789 [ALC882_AUTO] = "auto",
6792 static struct snd_pci_quirk alc882_cfg_tbl[] = {
6793 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG),
6794 SND_PCI_QUIRK(0x1043, 0x060d, "Asus A7J", ALC882_ASUS_A7J),
6795 SND_PCI_QUIRK(0x1043, 0x1243, "Asus A7J", ALC882_ASUS_A7J),
6796 SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_ASUS_A7M),
6797 SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_W2JC),
6798 SND_PCI_QUIRK(0x1043, 0x817f, "Asus P5LD2", ALC882_6ST_DIG),
6799 SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG),
6800 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG),
6801 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte P35 DS3R", ALC882_6ST_DIG),
6802 SND_PCI_QUIRK(0x1462, 0x28fb, "Targa T8", ALC882_TARGA), /* MSI-1049 T8 */
6803 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG),
6804 SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA),
6808 static struct alc_config_preset alc882_presets[] = {
6809 [ALC882_3ST_DIG] = {
6810 .mixers = { alc882_base_mixer },
6811 .init_verbs = { alc882_init_verbs },
6812 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6813 .dac_nids = alc882_dac_nids,
6814 .dig_out_nid = ALC882_DIGOUT_NID,
6815 .dig_in_nid = ALC882_DIGIN_NID,
6816 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
6817 .channel_mode = alc882_ch_modes,
6819 .input_mux = &alc882_capture_source,
6821 [ALC882_6ST_DIG] = {
6822 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
6823 .init_verbs = { alc882_init_verbs },
6824 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6825 .dac_nids = alc882_dac_nids,
6826 .dig_out_nid = ALC882_DIGOUT_NID,
6827 .dig_in_nid = ALC882_DIGIN_NID,
6828 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
6829 .channel_mode = alc882_sixstack_modes,
6830 .input_mux = &alc882_capture_source,
6833 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
6834 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs },
6835 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6836 .dac_nids = alc882_dac_nids,
6837 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
6838 .channel_mode = alc882_sixstack_modes,
6839 .input_mux = &alc882_capture_source,
6842 .mixers = { alc882_w2jc_mixer, alc882_chmode_mixer },
6843 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs,
6844 alc880_gpio1_init_verbs },
6845 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6846 .dac_nids = alc882_dac_nids,
6847 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
6848 .channel_mode = alc880_threestack_modes,
6850 .input_mux = &alc882_capture_source,
6851 .dig_out_nid = ALC882_DIGOUT_NID,
6854 .mixers = { alc885_mbp3_mixer, alc882_chmode_mixer },
6855 .init_verbs = { alc885_mbp3_init_verbs,
6856 alc880_gpio1_init_verbs },
6857 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6858 .dac_nids = alc882_dac_nids,
6859 .channel_mode = alc885_mbp_6ch_modes,
6860 .num_channel_mode = ARRAY_SIZE(alc885_mbp_6ch_modes),
6861 .input_mux = &alc882_capture_source,
6862 .dig_out_nid = ALC882_DIGOUT_NID,
6863 .dig_in_nid = ALC882_DIGIN_NID,
6864 .unsol_event = alc885_mbp3_unsol_event,
6865 .init_hook = alc885_mbp3_automute,
6868 .mixers = { alc882_macpro_mixer },
6869 .init_verbs = { alc882_macpro_init_verbs },
6870 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6871 .dac_nids = alc882_dac_nids,
6872 .dig_out_nid = ALC882_DIGOUT_NID,
6873 .dig_in_nid = ALC882_DIGIN_NID,
6874 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
6875 .channel_mode = alc882_ch_modes,
6876 .input_mux = &alc882_capture_source,
6877 .init_hook = alc885_macpro_init_hook,
6880 .mixers = { alc885_imac24_mixer },
6881 .init_verbs = { alc885_imac24_init_verbs },
6882 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6883 .dac_nids = alc882_dac_nids,
6884 .dig_out_nid = ALC882_DIGOUT_NID,
6885 .dig_in_nid = ALC882_DIGIN_NID,
6886 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
6887 .channel_mode = alc882_ch_modes,
6888 .input_mux = &alc882_capture_source,
6889 .unsol_event = alc885_imac24_unsol_event,
6890 .init_hook = alc885_imac24_init_hook,
6893 .mixers = { alc882_targa_mixer, alc882_chmode_mixer },
6894 .init_verbs = { alc882_init_verbs, alc882_targa_verbs},
6895 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6896 .dac_nids = alc882_dac_nids,
6897 .dig_out_nid = ALC882_DIGOUT_NID,
6898 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
6899 .adc_nids = alc882_adc_nids,
6900 .capsrc_nids = alc882_capsrc_nids,
6901 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
6902 .channel_mode = alc882_3ST_6ch_modes,
6904 .input_mux = &alc882_capture_source,
6905 .unsol_event = alc882_targa_unsol_event,
6906 .init_hook = alc882_targa_automute,
6908 [ALC882_ASUS_A7J] = {
6909 .mixers = { alc882_asus_a7j_mixer, alc882_chmode_mixer },
6910 .init_verbs = { alc882_init_verbs, alc882_asus_a7j_verbs},
6911 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6912 .dac_nids = alc882_dac_nids,
6913 .dig_out_nid = ALC882_DIGOUT_NID,
6914 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
6915 .adc_nids = alc882_adc_nids,
6916 .capsrc_nids = alc882_capsrc_nids,
6917 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
6918 .channel_mode = alc882_3ST_6ch_modes,
6920 .input_mux = &alc882_capture_source,
6922 [ALC882_ASUS_A7M] = {
6923 .mixers = { alc882_asus_a7m_mixer, alc882_chmode_mixer },
6924 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs,
6925 alc880_gpio1_init_verbs,
6926 alc882_asus_a7m_verbs },
6927 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6928 .dac_nids = alc882_dac_nids,
6929 .dig_out_nid = ALC882_DIGOUT_NID,
6930 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
6931 .channel_mode = alc880_threestack_modes,
6933 .input_mux = &alc882_capture_source,
6942 PINFIX_ABIT_AW9D_MAX
6945 static struct alc_pincfg alc882_abit_aw9d_pinfix[] = {
6946 { 0x15, 0x01080104 }, /* side */
6947 { 0x16, 0x01011012 }, /* rear */
6948 { 0x17, 0x01016011 }, /* clfe */
6952 static const struct alc_pincfg *alc882_pin_fixes[] = {
6953 [PINFIX_ABIT_AW9D_MAX] = alc882_abit_aw9d_pinfix,
6956 static struct snd_pci_quirk alc882_pinfix_tbl[] = {
6957 SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", PINFIX_ABIT_AW9D_MAX),
6962 * BIOS auto configuration
6964 static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
6965 hda_nid_t nid, int pin_type,
6969 struct alc_spec *spec = codec->spec;
6972 alc_set_pin_output(codec, nid, pin_type);
6973 if (spec->multiout.dac_nids[dac_idx] == 0x25)
6976 idx = spec->multiout.dac_nids[dac_idx] - 2;
6977 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
6981 static void alc882_auto_init_multi_out(struct hda_codec *codec)
6983 struct alc_spec *spec = codec->spec;
6986 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
6987 for (i = 0; i <= HDA_SIDE; i++) {
6988 hda_nid_t nid = spec->autocfg.line_out_pins[i];
6989 int pin_type = get_pin_type(spec->autocfg.line_out_type);
6991 alc882_auto_set_output_and_unmute(codec, nid, pin_type,
6996 static void alc882_auto_init_hp_out(struct hda_codec *codec)
6998 struct alc_spec *spec = codec->spec;
7001 pin = spec->autocfg.hp_pins[0];
7002 if (pin) /* connect to front */
7004 alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
7005 pin = spec->autocfg.speaker_pins[0];
7007 alc882_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
7010 #define alc882_is_input_pin(nid) alc880_is_input_pin(nid)
7011 #define ALC882_PIN_CD_NID ALC880_PIN_CD_NID
7013 static void alc882_auto_init_analog_input(struct hda_codec *codec)
7015 struct alc_spec *spec = codec->spec;
7018 for (i = 0; i < AUTO_PIN_LAST; i++) {
7019 hda_nid_t nid = spec->autocfg.input_pins[i];
7022 alc_set_input_pin(codec, nid, AUTO_PIN_FRONT_MIC /*i*/);
7023 if (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP)
7024 snd_hda_codec_write(codec, nid, 0,
7025 AC_VERB_SET_AMP_GAIN_MUTE,
7030 static void alc882_auto_init_input_src(struct hda_codec *codec)
7032 struct alc_spec *spec = codec->spec;
7035 for (c = 0; c < spec->num_adc_nids; c++) {
7036 hda_nid_t conn_list[HDA_MAX_NUM_INPUTS];
7037 hda_nid_t nid = spec->capsrc_nids[c];
7038 unsigned int mux_idx;
7039 const struct hda_input_mux *imux;
7040 int conns, mute, idx, item;
7042 conns = snd_hda_get_connections(codec, nid, conn_list,
7043 ARRAY_SIZE(conn_list));
7046 mux_idx = c >= spec->num_mux_defs ? 0 : c;
7047 imux = &spec->input_mux[mux_idx];
7048 for (idx = 0; idx < conns; idx++) {
7049 /* if the current connection is the selected one,
7050 * unmute it as default - otherwise mute it
7052 mute = AMP_IN_MUTE(idx);
7053 for (item = 0; item < imux->num_items; item++) {
7054 if (imux->items[item].index == idx) {
7055 if (spec->cur_mux[c] == item)
7056 mute = AMP_IN_UNMUTE(idx);
7060 /* check if we have a selector or mixer
7061 * we could check for the widget type instead, but
7062 * just check for Amp-In presence (in case of mixer
7063 * without amp-in there is something wrong, this
7064 * function shouldn't be used or capsrc nid is wrong)
7066 if (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)
7067 snd_hda_codec_write(codec, nid, 0,
7068 AC_VERB_SET_AMP_GAIN_MUTE,
7070 else if (mute != AMP_IN_MUTE(idx))
7071 snd_hda_codec_write(codec, nid, 0,
7072 AC_VERB_SET_CONNECT_SEL,
7078 /* add mic boosts if needed */
7079 static int alc_auto_add_mic_boost(struct hda_codec *codec)
7081 struct alc_spec *spec = codec->spec;
7085 nid = spec->autocfg.input_pins[AUTO_PIN_MIC];
7086 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
7087 err = add_control(spec, ALC_CTL_WIDGET_VOL,
7089 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
7093 nid = spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC];
7094 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
7095 err = add_control(spec, ALC_CTL_WIDGET_VOL,
7097 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
7104 /* almost identical with ALC880 parser... */
7105 static int alc882_parse_auto_config(struct hda_codec *codec)
7107 struct alc_spec *spec = codec->spec;
7108 int err = alc880_parse_auto_config(codec);
7113 return 0; /* no config found */
7115 err = alc_auto_add_mic_boost(codec);
7119 /* hack - override the init verbs */
7120 spec->init_verbs[0] = alc882_auto_init_verbs;
7122 return 1; /* config found */
7125 /* additional initialization for auto-configuration model */
7126 static void alc882_auto_init(struct hda_codec *codec)
7128 struct alc_spec *spec = codec->spec;
7129 alc882_auto_init_multi_out(codec);
7130 alc882_auto_init_hp_out(codec);
7131 alc882_auto_init_analog_input(codec);
7132 alc882_auto_init_input_src(codec);
7133 if (spec->unsol_event)
7134 alc_inithook(codec);
7137 static int patch_alc883(struct hda_codec *codec); /* called in patch_alc882() */
7139 static int patch_alc882(struct hda_codec *codec)
7141 struct alc_spec *spec;
7142 int err, board_config;
7144 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
7150 board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST,
7154 if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
7155 /* Pick up systems that don't supply PCI SSID */
7156 switch (codec->subsystem_id) {
7157 case 0x106b0c00: /* Mac Pro */
7158 board_config = ALC885_MACPRO;
7160 case 0x106b1000: /* iMac 24 */
7161 case 0x106b2800: /* AppleTV */
7162 case 0x106b3e00: /* iMac 24 Aluminium */
7163 board_config = ALC885_IMAC24;
7165 case 0x106b00a0: /* MacBookPro3,1 - Another revision */
7166 case 0x106b00a1: /* Macbook (might be wrong - PCI SSID?) */
7167 case 0x106b00a4: /* MacbookPro4,1 */
7168 case 0x106b2c00: /* Macbook Pro rev3 */
7169 case 0x106b3600: /* Macbook 3.1 */
7170 case 0x106b3800: /* MacbookPro4,1 - latter revision */
7171 board_config = ALC885_MBP3;
7174 /* ALC889A is handled better as ALC888-compatible */
7175 if (codec->revision_id == 0x100101 ||
7176 codec->revision_id == 0x100103) {
7178 return patch_alc883(codec);
7180 printk(KERN_INFO "hda_codec: Unknown model for ALC882, "
7181 "trying auto-probe from BIOS...\n");
7182 board_config = ALC882_AUTO;
7186 alc_fix_pincfg(codec, alc882_pinfix_tbl, alc882_pin_fixes);
7188 if (board_config == ALC882_AUTO) {
7189 /* automatic parse from the BIOS config */
7190 err = alc882_parse_auto_config(codec);
7196 "hda_codec: Cannot set up configuration "
7197 "from BIOS. Using base mode...\n");
7198 board_config = ALC882_3ST_DIG;
7202 err = snd_hda_attach_beep_device(codec, 0x1);
7208 if (board_config != ALC882_AUTO)
7209 setup_preset(spec, &alc882_presets[board_config]);
7211 if (codec->vendor_id == 0x10ec0885) {
7212 spec->stream_name_analog = "ALC885 Analog";
7213 spec->stream_name_digital = "ALC885 Digital";
7215 spec->stream_name_analog = "ALC882 Analog";
7216 spec->stream_name_digital = "ALC882 Digital";
7219 spec->stream_analog_playback = &alc882_pcm_analog_playback;
7220 spec->stream_analog_capture = &alc882_pcm_analog_capture;
7221 /* FIXME: setup DAC5 */
7222 /*spec->stream_analog_alt_playback = &alc880_pcm_analog_alt_playback;*/
7223 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
7225 spec->stream_digital_playback = &alc882_pcm_digital_playback;
7226 spec->stream_digital_capture = &alc882_pcm_digital_capture;
7228 spec->capture_style = CAPT_MIX; /* matrix-style capture */
7229 if (!spec->adc_nids && spec->input_mux) {
7230 /* check whether NID 0x07 is valid */
7231 unsigned int wcap = get_wcaps(codec, 0x07);
7233 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
7234 if (wcap != AC_WID_AUD_IN) {
7235 spec->adc_nids = alc882_adc_nids_alt;
7236 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids_alt);
7237 spec->capsrc_nids = alc882_capsrc_nids_alt;
7239 spec->adc_nids = alc882_adc_nids;
7240 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids);
7241 spec->capsrc_nids = alc882_capsrc_nids;
7244 set_capture_mixer(spec);
7245 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
7247 spec->vmaster_nid = 0x0c;
7249 codec->patch_ops = alc_patch_ops;
7250 if (board_config == ALC882_AUTO)
7251 spec->init_hook = alc882_auto_init;
7252 #ifdef CONFIG_SND_HDA_POWER_SAVE
7253 if (!spec->loopback.amplist)
7254 spec->loopback.amplist = alc882_loopbacks;
7256 codec->proc_widget_hook = print_realtek_coef;
7264 * ALC883 is almost identical with ALC880 but has cleaner and more flexible
7265 * configuration. Each pin widget can choose any input DACs and a mixer.
7266 * Each ADC is connected from a mixer of all inputs. This makes possible
7267 * 6-channel independent captures.
7269 * In addition, an independent DAC for the multi-playback (not used in this
7272 #define ALC883_DIGOUT_NID 0x06
7273 #define ALC883_DIGIN_NID 0x0a
7275 #define ALC1200_DIGOUT_NID 0x10
7277 static hda_nid_t alc883_dac_nids[4] = {
7278 /* front, rear, clfe, rear_surr */
7279 0x02, 0x03, 0x04, 0x05
7282 static hda_nid_t alc883_adc_nids[2] = {
7287 static hda_nid_t alc883_adc_nids_alt[1] = {
7292 static hda_nid_t alc883_adc_nids_rev[2] = {
7297 #define alc889_adc_nids alc880_adc_nids
7299 static hda_nid_t alc883_capsrc_nids[2] = { 0x23, 0x22 };
7301 static hda_nid_t alc883_capsrc_nids_rev[2] = { 0x22, 0x23 };
7303 #define alc889_capsrc_nids alc882_capsrc_nids
7306 /* FIXME: should be a matrix-type input source selection */
7308 static struct hda_input_mux alc883_capture_source = {
7312 { "Front Mic", 0x1 },
7318 static struct hda_input_mux alc883_3stack_6ch_intel = {
7322 { "Front Mic", 0x0 },
7328 static struct hda_input_mux alc883_lenovo_101e_capture_source = {
7336 static struct hda_input_mux alc883_lenovo_nb0763_capture_source = {
7346 static struct hda_input_mux alc883_fujitsu_pi2515_capture_source = {
7354 static struct hda_input_mux alc883_lenovo_sky_capture_source = {
7358 { "Front Mic", 0x1 },
7363 static struct hda_input_mux alc883_asus_eee1601_capture_source = {
7374 static struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
7381 static struct hda_verb alc883_3ST_ch2_init[] = {
7382 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7383 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7384 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7385 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7392 static struct hda_verb alc883_3ST_ch4_init[] = {
7393 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7394 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7395 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7396 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7397 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7404 static struct hda_verb alc883_3ST_ch6_init[] = {
7405 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7406 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7407 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
7408 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7409 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7410 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7414 static struct hda_channel_mode alc883_3ST_6ch_modes[3] = {
7415 { 2, alc883_3ST_ch2_init },
7416 { 4, alc883_3ST_ch4_init },
7417 { 6, alc883_3ST_ch6_init },
7423 static struct hda_verb alc883_3ST_ch2_intel_init[] = {
7424 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7425 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7426 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7427 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7434 static struct hda_verb alc883_3ST_ch4_intel_init[] = {
7435 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7436 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7437 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7438 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7439 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7446 static struct hda_verb alc883_3ST_ch6_intel_init[] = {
7447 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7448 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7449 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x02 },
7450 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7451 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7452 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7456 static struct hda_channel_mode alc883_3ST_6ch_intel_modes[3] = {
7457 { 2, alc883_3ST_ch2_intel_init },
7458 { 4, alc883_3ST_ch4_intel_init },
7459 { 6, alc883_3ST_ch6_intel_init },
7465 static struct hda_verb alc883_sixstack_ch6_init[] = {
7466 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
7467 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7468 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7469 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7476 static struct hda_verb alc883_sixstack_ch8_init[] = {
7477 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7478 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7479 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7480 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7484 static struct hda_channel_mode alc883_sixstack_modes[2] = {
7485 { 6, alc883_sixstack_ch6_init },
7486 { 8, alc883_sixstack_ch8_init },
7489 static struct hda_verb alc883_medion_eapd_verbs[] = {
7490 /* eanable EAPD on medion laptop */
7491 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
7492 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
7496 /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
7497 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
7500 static struct snd_kcontrol_new alc883_base_mixer[] = {
7501 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7502 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7503 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7504 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7505 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7506 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7507 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7508 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7509 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
7510 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
7511 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7512 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7513 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7514 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7515 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7516 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7517 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7518 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7519 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7520 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
7521 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7525 static struct snd_kcontrol_new alc883_mitac_mixer[] = {
7526 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7527 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7528 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7529 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7530 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7531 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7532 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7533 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7534 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7535 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7536 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7537 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
7538 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7542 static struct snd_kcontrol_new alc883_clevo_m720_mixer[] = {
7543 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7544 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
7545 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7546 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
7547 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7548 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7549 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7550 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7551 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
7552 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7556 static struct snd_kcontrol_new alc883_2ch_fujitsu_pi2515_mixer[] = {
7557 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7558 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
7559 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7560 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
7561 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7562 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7563 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7564 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7565 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
7566 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7570 static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
7571 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7572 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7573 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7574 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7575 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7576 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7577 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7578 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7579 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7580 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7581 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7582 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
7583 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7587 static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
7588 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7589 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7590 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7591 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7592 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7593 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7594 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7595 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7596 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7597 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7598 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7599 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7600 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7601 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7602 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7603 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7604 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7605 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
7606 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7610 static struct snd_kcontrol_new alc883_3ST_6ch_intel_mixer[] = {
7611 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7612 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7613 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7614 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7615 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
7617 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7618 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7619 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7620 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7621 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7622 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7623 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7624 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7625 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7626 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
7627 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7628 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7629 HDA_CODEC_VOLUME("Front Mic Boost", 0x18, 0, HDA_INPUT),
7630 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7634 static struct snd_kcontrol_new alc883_fivestack_mixer[] = {
7635 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7636 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7637 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7638 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7639 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7640 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7641 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7642 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7643 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7644 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7645 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7646 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7647 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7648 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7649 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7650 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7651 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7652 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
7653 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7657 static struct snd_kcontrol_new alc883_tagra_mixer[] = {
7658 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7659 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7660 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7661 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7662 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7663 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7664 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7665 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7666 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7667 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7668 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7669 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7670 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7671 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7672 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7673 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7677 static struct snd_kcontrol_new alc883_tagra_2ch_mixer[] = {
7678 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7679 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7680 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7681 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7682 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7683 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7684 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7685 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7686 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7687 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
7688 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7692 static struct snd_kcontrol_new alc883_lenovo_101e_2ch_mixer[] = {
7693 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7694 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7695 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7696 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
7697 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7698 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7699 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7700 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7704 static struct snd_kcontrol_new alc883_lenovo_nb0763_mixer[] = {
7705 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7706 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
7707 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7708 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7709 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7710 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7711 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7712 HDA_CODEC_VOLUME("iMic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7713 HDA_CODEC_MUTE("iMic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7717 static struct snd_kcontrol_new alc883_medion_md2_mixer[] = {
7718 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7719 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7720 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7721 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7722 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7723 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7724 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7725 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7726 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7730 static struct snd_kcontrol_new alc883_acer_aspire_mixer[] = {
7731 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7732 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7733 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7734 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7735 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7736 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7737 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7738 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7742 static struct snd_kcontrol_new alc888_lenovo_sky_mixer[] = {
7743 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7744 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7745 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
7746 HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
7747 HDA_CODEC_VOLUME_MONO("Center Playback Volume",
7748 0x0d, 1, 0x0, HDA_OUTPUT),
7749 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
7750 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
7751 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
7752 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
7753 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
7754 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7755 HDA_CODEC_MUTE("iSpeaker Playback Switch", 0x1a, 0x0, HDA_OUTPUT),
7756 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7757 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7758 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7759 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7760 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7761 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7762 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7763 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7764 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
7765 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7769 static struct hda_bind_ctls alc883_bind_cap_vol = {
7770 .ops = &snd_hda_bind_vol,
7772 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
7773 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
7778 static struct hda_bind_ctls alc883_bind_cap_switch = {
7779 .ops = &snd_hda_bind_sw,
7781 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
7782 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
7787 static struct snd_kcontrol_new alc883_asus_eee1601_mixer[] = {
7788 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7789 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7790 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7791 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7792 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7793 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7794 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7795 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7799 static struct snd_kcontrol_new alc883_asus_eee1601_cap_mixer[] = {
7800 HDA_BIND_VOL("Capture Volume", &alc883_bind_cap_vol),
7801 HDA_BIND_SW("Capture Switch", &alc883_bind_cap_switch),
7803 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7804 /* .name = "Capture Source", */
7805 .name = "Input Source",
7807 .info = alc_mux_enum_info,
7808 .get = alc_mux_enum_get,
7809 .put = alc_mux_enum_put,
7814 static struct snd_kcontrol_new alc883_chmode_mixer[] = {
7816 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7817 .name = "Channel Mode",
7818 .info = alc_ch_mode_info,
7819 .get = alc_ch_mode_get,
7820 .put = alc_ch_mode_put,
7825 static struct hda_verb alc883_init_verbs[] = {
7826 /* ADC1: mute amp left and right */
7827 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7828 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7829 /* ADC2: mute amp left and right */
7830 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7831 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7832 /* Front mixer: unmute input/output amp left and right (volume = 0) */
7833 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7834 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7835 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7837 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7838 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7839 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7841 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7842 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7843 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7845 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7846 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7847 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7849 /* mute analog input loopbacks */
7850 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7851 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7852 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7853 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7854 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7856 /* Front Pin: output 0 (0x0c) */
7857 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7858 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7859 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7860 /* Rear Pin: output 1 (0x0d) */
7861 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7862 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7863 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
7864 /* CLFE Pin: output 2 (0x0e) */
7865 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7866 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7867 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
7868 /* Side Pin: output 3 (0x0f) */
7869 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7870 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7871 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
7872 /* Mic (rear) pin: input vref at 80% */
7873 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7874 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7875 /* Front Mic pin: input vref at 80% */
7876 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7877 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7878 /* Line In pin: input */
7879 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7880 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7881 /* Line-2 In: Headphone output (output 0 - 0x0c) */
7882 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7883 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7884 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
7885 /* CD pin widget for input */
7886 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7888 /* FIXME: use matrix-type input source selection */
7889 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7891 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7892 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7893 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7894 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7896 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7897 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7898 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7899 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7903 /* toggle speaker-output according to the hp-jack state */
7904 static void alc883_mitac_hp_automute(struct hda_codec *codec)
7906 unsigned int present;
7908 present = snd_hda_codec_read(codec, 0x15, 0,
7909 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7910 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7911 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7912 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
7913 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7916 /* auto-toggle front mic */
7918 static void alc883_mitac_mic_automute(struct hda_codec *codec)
7920 unsigned int present;
7923 present = snd_hda_codec_read(codec, 0x18, 0,
7924 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7925 bits = present ? HDA_AMP_MUTE : 0;
7926 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
7930 static void alc883_mitac_automute(struct hda_codec *codec)
7932 alc883_mitac_hp_automute(codec);
7933 /* alc883_mitac_mic_automute(codec); */
7936 static void alc883_mitac_unsol_event(struct hda_codec *codec,
7939 switch (res >> 26) {
7940 case ALC880_HP_EVENT:
7941 alc883_mitac_hp_automute(codec);
7943 case ALC880_MIC_EVENT:
7944 /* alc883_mitac_mic_automute(codec); */
7949 static struct hda_verb alc883_mitac_verbs[] = {
7951 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7952 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7954 {0x17, AC_VERB_SET_CONNECT_SEL, 0x02},
7955 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7957 /* enable unsolicited event */
7958 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7959 /* {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN}, */
7964 static struct hda_verb alc883_clevo_m720_verbs[] = {
7966 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7967 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7969 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
7970 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7972 /* enable unsolicited event */
7973 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7974 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
7979 static struct hda_verb alc883_2ch_fujitsu_pi2515_verbs[] = {
7981 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7982 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7984 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
7985 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7987 /* enable unsolicited event */
7988 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7993 static struct hda_verb alc883_tagra_verbs[] = {
7994 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7995 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7997 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7998 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8000 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
8001 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
8002 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
8004 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8005 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
8006 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
8007 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
8012 static struct hda_verb alc883_lenovo_101e_verbs[] = {
8013 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8014 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT|AC_USRSP_EN},
8015 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT|AC_USRSP_EN},
8019 static struct hda_verb alc883_lenovo_nb0763_verbs[] = {
8020 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8021 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8022 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8023 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8027 static struct hda_verb alc888_lenovo_ms7195_verbs[] = {
8028 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8029 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8030 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8031 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT | AC_USRSP_EN},
8032 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8036 static struct hda_verb alc883_haier_w66_verbs[] = {
8037 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8038 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8040 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8042 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
8043 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8044 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8045 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8049 static struct hda_verb alc888_lenovo_sky_verbs[] = {
8050 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8051 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8052 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8053 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8054 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8055 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8056 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
8057 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8061 static struct hda_verb alc888_6st_dell_verbs[] = {
8062 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8066 static void alc888_3st_hp_front_automute(struct hda_codec *codec)
8068 unsigned int present, bits;
8070 present = snd_hda_codec_read(codec, 0x1b, 0,
8071 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8072 bits = present ? HDA_AMP_MUTE : 0;
8073 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8074 HDA_AMP_MUTE, bits);
8075 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
8076 HDA_AMP_MUTE, bits);
8077 snd_hda_codec_amp_stereo(codec, 0x18, HDA_OUTPUT, 0,
8078 HDA_AMP_MUTE, bits);
8081 static void alc888_3st_hp_unsol_event(struct hda_codec *codec,
8084 switch (res >> 26) {
8085 case ALC880_HP_EVENT:
8086 alc888_3st_hp_front_automute(codec);
8091 static struct hda_verb alc888_3st_hp_verbs[] = {
8092 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
8093 {0x16, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Rear : output 1 (0x0d) */
8094 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* CLFE : output 2 (0x0e) */
8095 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8102 static struct hda_verb alc888_3st_hp_2ch_init[] = {
8103 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
8104 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
8105 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
8106 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
8113 static struct hda_verb alc888_3st_hp_4ch_init[] = {
8114 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
8115 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
8116 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8117 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
8118 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x01 },
8125 static struct hda_verb alc888_3st_hp_6ch_init[] = {
8126 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8127 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
8128 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
8129 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8130 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
8131 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x01 },
8135 static struct hda_channel_mode alc888_3st_hp_modes[3] = {
8136 { 2, alc888_3st_hp_2ch_init },
8137 { 4, alc888_3st_hp_4ch_init },
8138 { 6, alc888_3st_hp_6ch_init },
8141 /* toggle front-jack and RCA according to the hp-jack state */
8142 static void alc888_lenovo_ms7195_front_automute(struct hda_codec *codec)
8144 unsigned int present;
8146 present = snd_hda_codec_read(codec, 0x1b, 0,
8147 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8148 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8149 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8150 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8151 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8154 /* toggle RCA according to the front-jack state */
8155 static void alc888_lenovo_ms7195_rca_automute(struct hda_codec *codec)
8157 unsigned int present;
8159 present = snd_hda_codec_read(codec, 0x14, 0,
8160 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8161 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8162 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8165 static void alc883_lenovo_ms7195_unsol_event(struct hda_codec *codec,
8168 if ((res >> 26) == ALC880_HP_EVENT)
8169 alc888_lenovo_ms7195_front_automute(codec);
8170 if ((res >> 26) == ALC880_FRONT_EVENT)
8171 alc888_lenovo_ms7195_rca_automute(codec);
8174 static struct hda_verb alc883_medion_md2_verbs[] = {
8175 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8176 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8178 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8180 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8184 /* toggle speaker-output according to the hp-jack state */
8185 static void alc883_medion_md2_automute(struct hda_codec *codec)
8187 unsigned int present;
8189 present = snd_hda_codec_read(codec, 0x14, 0,
8190 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8191 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8192 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8195 static void alc883_medion_md2_unsol_event(struct hda_codec *codec,
8198 if ((res >> 26) == ALC880_HP_EVENT)
8199 alc883_medion_md2_automute(codec);
8202 /* toggle speaker-output according to the hp-jack state */
8203 static void alc883_tagra_automute(struct hda_codec *codec)
8205 unsigned int present;
8208 present = snd_hda_codec_read(codec, 0x14, 0,
8209 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8210 bits = present ? HDA_AMP_MUTE : 0;
8211 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
8212 HDA_AMP_MUTE, bits);
8213 snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
8217 static void alc883_tagra_unsol_event(struct hda_codec *codec, unsigned int res)
8219 if ((res >> 26) == ALC880_HP_EVENT)
8220 alc883_tagra_automute(codec);
8223 /* toggle speaker-output according to the hp-jack state */
8224 static void alc883_clevo_m720_hp_automute(struct hda_codec *codec)
8226 unsigned int present;
8229 present = snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_PIN_SENSE, 0)
8230 & AC_PINSENSE_PRESENCE;
8231 bits = present ? HDA_AMP_MUTE : 0;
8232 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8233 HDA_AMP_MUTE, bits);
8236 static void alc883_clevo_m720_mic_automute(struct hda_codec *codec)
8238 unsigned int present;
8240 present = snd_hda_codec_read(codec, 0x18, 0,
8241 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8242 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
8243 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8246 static void alc883_clevo_m720_automute(struct hda_codec *codec)
8248 alc883_clevo_m720_hp_automute(codec);
8249 alc883_clevo_m720_mic_automute(codec);
8252 static void alc883_clevo_m720_unsol_event(struct hda_codec *codec,
8255 switch (res >> 26) {
8256 case ALC880_HP_EVENT:
8257 alc883_clevo_m720_hp_automute(codec);
8259 case ALC880_MIC_EVENT:
8260 alc883_clevo_m720_mic_automute(codec);
8265 /* toggle speaker-output according to the hp-jack state */
8266 static void alc883_2ch_fujitsu_pi2515_automute(struct hda_codec *codec)
8268 unsigned int present;
8271 present = snd_hda_codec_read(codec, 0x14, 0, AC_VERB_GET_PIN_SENSE, 0)
8272 & AC_PINSENSE_PRESENCE;
8273 bits = present ? HDA_AMP_MUTE : 0;
8274 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8275 HDA_AMP_MUTE, bits);
8278 static void alc883_2ch_fujitsu_pi2515_unsol_event(struct hda_codec *codec,
8281 if ((res >> 26) == ALC880_HP_EVENT)
8282 alc883_2ch_fujitsu_pi2515_automute(codec);
8285 static void alc883_haier_w66_automute(struct hda_codec *codec)
8287 unsigned int present;
8290 present = snd_hda_codec_read(codec, 0x1b, 0,
8291 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8292 bits = present ? 0x80 : 0;
8293 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8297 static void alc883_haier_w66_unsol_event(struct hda_codec *codec,
8300 if ((res >> 26) == ALC880_HP_EVENT)
8301 alc883_haier_w66_automute(codec);
8304 static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
8306 unsigned int present;
8309 present = snd_hda_codec_read(codec, 0x14, 0,
8310 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8311 bits = present ? HDA_AMP_MUTE : 0;
8312 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8313 HDA_AMP_MUTE, bits);
8316 static void alc883_lenovo_101e_all_automute(struct hda_codec *codec)
8318 unsigned int present;
8321 present = snd_hda_codec_read(codec, 0x1b, 0,
8322 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8323 bits = present ? HDA_AMP_MUTE : 0;
8324 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8325 HDA_AMP_MUTE, bits);
8326 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8327 HDA_AMP_MUTE, bits);
8330 static void alc883_lenovo_101e_unsol_event(struct hda_codec *codec,
8333 if ((res >> 26) == ALC880_HP_EVENT)
8334 alc883_lenovo_101e_all_automute(codec);
8335 if ((res >> 26) == ALC880_FRONT_EVENT)
8336 alc883_lenovo_101e_ispeaker_automute(codec);
8339 /* toggle speaker-output according to the hp-jack state */
8340 static void alc883_acer_aspire_automute(struct hda_codec *codec)
8342 unsigned int present;
8344 present = snd_hda_codec_read(codec, 0x14, 0,
8345 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8346 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8347 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8348 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
8349 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8352 static void alc883_acer_aspire_unsol_event(struct hda_codec *codec,
8355 if ((res >> 26) == ALC880_HP_EVENT)
8356 alc883_acer_aspire_automute(codec);
8359 static struct hda_verb alc883_acer_eapd_verbs[] = {
8360 /* HP Pin: output 0 (0x0c) */
8361 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8362 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8363 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8364 /* Front Pin: output 0 (0x0c) */
8365 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8366 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8367 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8368 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00},
8369 /* eanable EAPD on medion laptop */
8370 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
8371 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
8372 /* enable unsolicited event */
8373 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8377 static void alc888_6st_dell_front_automute(struct hda_codec *codec)
8379 unsigned int present;
8381 present = snd_hda_codec_read(codec, 0x1b, 0,
8382 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8383 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8384 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8385 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8386 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8387 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
8388 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8389 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
8390 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8393 static void alc888_6st_dell_unsol_event(struct hda_codec *codec,
8396 switch (res >> 26) {
8397 case ALC880_HP_EVENT:
8398 /* printk(KERN_DEBUG "hp_event\n"); */
8399 alc888_6st_dell_front_automute(codec);
8404 static void alc888_lenovo_sky_front_automute(struct hda_codec *codec)
8407 unsigned int present;
8409 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
8410 present = snd_hda_codec_read(codec, 0x1b, 0,
8411 AC_VERB_GET_PIN_SENSE, 0);
8412 present = (present & 0x80000000) != 0;
8414 /* mute internal speaker */
8415 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8416 HDA_AMP_MUTE, HDA_AMP_MUTE);
8417 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8418 HDA_AMP_MUTE, HDA_AMP_MUTE);
8419 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
8420 HDA_AMP_MUTE, HDA_AMP_MUTE);
8421 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
8422 HDA_AMP_MUTE, HDA_AMP_MUTE);
8423 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_OUTPUT, 0,
8424 HDA_AMP_MUTE, HDA_AMP_MUTE);
8426 /* unmute internal speaker if necessary */
8427 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
8428 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8429 HDA_AMP_MUTE, mute);
8430 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8431 HDA_AMP_MUTE, mute);
8432 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
8433 HDA_AMP_MUTE, mute);
8434 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
8435 HDA_AMP_MUTE, mute);
8436 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_OUTPUT, 0,
8437 HDA_AMP_MUTE, mute);
8441 static void alc883_lenovo_sky_unsol_event(struct hda_codec *codec,
8444 if ((res >> 26) == ALC880_HP_EVENT)
8445 alc888_lenovo_sky_front_automute(codec);
8449 * generic initialization of ADC, input mixers and output mixers
8451 static struct hda_verb alc883_auto_init_verbs[] = {
8453 * Unmute ADC0-2 and set the default input to mic-in
8455 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8456 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8457 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8458 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8460 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
8462 * Note: PASD motherboards uses the Line In 2 as the input for
8463 * front panel mic (mic 2)
8465 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
8466 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8467 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8468 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8469 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8470 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8473 * Set up output mixers (0x0c - 0x0f)
8475 /* set vol=0 to output mixers */
8476 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8477 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8478 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8479 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8480 /* set up input amps for analog loopback */
8481 /* Amp Indices: DAC = 0, mixer = 1 */
8482 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8483 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8484 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8485 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8486 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8487 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8488 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8489 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8490 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8491 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8493 /* FIXME: use matrix-type input source selection */
8494 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
8496 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8497 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8498 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
8499 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
8500 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
8502 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8503 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8504 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
8505 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
8506 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
8511 static struct hda_verb alc888_asus_m90v_verbs[] = {
8512 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8513 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8514 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8515 /* enable unsolicited event */
8516 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8517 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
8521 static void alc883_nb_mic_automute(struct hda_codec *codec)
8523 unsigned int present;
8525 present = snd_hda_codec_read(codec, 0x18, 0,
8526 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8527 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
8528 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
8529 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
8530 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
8533 static void alc883_M90V_speaker_automute(struct hda_codec *codec)
8535 unsigned int present;
8538 present = snd_hda_codec_read(codec, 0x1b, 0,
8539 AC_VERB_GET_PIN_SENSE, 0)
8540 & AC_PINSENSE_PRESENCE;
8541 bits = present ? 0 : PIN_OUT;
8542 snd_hda_codec_write(codec, 0x14, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
8544 snd_hda_codec_write(codec, 0x15, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
8546 snd_hda_codec_write(codec, 0x16, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
8550 static void alc883_mode2_unsol_event(struct hda_codec *codec,
8553 switch (res >> 26) {
8554 case ALC880_HP_EVENT:
8555 alc883_M90V_speaker_automute(codec);
8557 case ALC880_MIC_EVENT:
8558 alc883_nb_mic_automute(codec);
8563 static void alc883_mode2_inithook(struct hda_codec *codec)
8565 alc883_M90V_speaker_automute(codec);
8566 alc883_nb_mic_automute(codec);
8569 static struct hda_verb alc888_asus_eee1601_verbs[] = {
8570 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8571 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8572 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8573 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8574 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8575 {0x20, AC_VERB_SET_COEF_INDEX, 0x0b},
8576 {0x20, AC_VERB_SET_PROC_COEF, 0x0838},
8577 /* enable unsolicited event */
8578 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8582 static void alc883_eee1601_speaker_automute(struct hda_codec *codec)
8584 unsigned int present;
8587 present = snd_hda_codec_read(codec, 0x14, 0,
8588 AC_VERB_GET_PIN_SENSE, 0)
8589 & AC_PINSENSE_PRESENCE;
8590 bits = present ? 0 : PIN_OUT;
8591 snd_hda_codec_write(codec, 0x1b, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
8595 static void alc883_eee1601_unsol_event(struct hda_codec *codec,
8598 switch (res >> 26) {
8599 case ALC880_HP_EVENT:
8600 alc883_eee1601_speaker_automute(codec);
8605 static void alc883_eee1601_inithook(struct hda_codec *codec)
8607 alc883_eee1601_speaker_automute(codec);
8610 #ifdef CONFIG_SND_HDA_POWER_SAVE
8611 #define alc883_loopbacks alc880_loopbacks
8614 /* pcm configuration: identiacal with ALC880 */
8615 #define alc883_pcm_analog_playback alc880_pcm_analog_playback
8616 #define alc883_pcm_analog_capture alc880_pcm_analog_capture
8617 #define alc883_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
8618 #define alc883_pcm_digital_playback alc880_pcm_digital_playback
8619 #define alc883_pcm_digital_capture alc880_pcm_digital_capture
8622 * configuration and preset
8624 static const char *alc883_models[ALC883_MODEL_LAST] = {
8625 [ALC883_3ST_2ch_DIG] = "3stack-dig",
8626 [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig",
8627 [ALC883_3ST_6ch] = "3stack-6ch",
8628 [ALC883_6ST_DIG] = "6stack-dig",
8629 [ALC883_TARGA_DIG] = "targa-dig",
8630 [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig",
8631 [ALC883_ACER] = "acer",
8632 [ALC883_ACER_ASPIRE] = "acer-aspire",
8633 [ALC888_ACER_ASPIRE_4930G] = "acer-aspire-4930g",
8634 [ALC883_MEDION] = "medion",
8635 [ALC883_MEDION_MD2] = "medion-md2",
8636 [ALC883_LAPTOP_EAPD] = "laptop-eapd",
8637 [ALC883_LENOVO_101E_2ch] = "lenovo-101e",
8638 [ALC883_LENOVO_NB0763] = "lenovo-nb0763",
8639 [ALC888_LENOVO_MS7195_DIG] = "lenovo-ms7195-dig",
8640 [ALC888_LENOVO_SKY] = "lenovo-sky",
8641 [ALC883_HAIER_W66] = "haier-w66",
8642 [ALC888_3ST_HP] = "3stack-hp",
8643 [ALC888_6ST_DELL] = "6stack-dell",
8644 [ALC883_MITAC] = "mitac",
8645 [ALC883_CLEVO_M720] = "clevo-m720",
8646 [ALC883_FUJITSU_PI2515] = "fujitsu-pi2515",
8647 [ALC888_FUJITSU_XA3530] = "fujitsu-xa3530",
8648 [ALC883_3ST_6ch_INTEL] = "3stack-6ch-intel",
8649 [ALC1200_ASUS_P5Q] = "asus-p5q",
8650 [ALC883_AUTO] = "auto",
8653 static struct snd_pci_quirk alc883_cfg_tbl[] = {
8654 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC883_3ST_6ch_DIG),
8655 SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_ACER_ASPIRE),
8656 SND_PCI_QUIRK(0x1025, 0x0090, "Acer Aspire", ALC883_ACER_ASPIRE),
8657 SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_ACER_ASPIRE),
8658 SND_PCI_QUIRK(0x1025, 0x0112, "Acer Aspire 9303", ALC883_ACER_ASPIRE),
8659 SND_PCI_QUIRK(0x1025, 0x0121, "Acer Aspire 5920G", ALC883_ACER_ASPIRE),
8660 SND_PCI_QUIRK(0x1025, 0x013e, "Acer Aspire 4930G",
8661 ALC888_ACER_ASPIRE_4930G),
8662 SND_PCI_QUIRK(0x1025, 0x013f, "Acer Aspire 5930G",
8663 ALC888_ACER_ASPIRE_4930G),
8664 SND_PCI_QUIRK(0x1025, 0x0157, "Acer X3200", ALC883_AUTO),
8665 SND_PCI_QUIRK(0x1025, 0x0158, "Acer AX1700-U3700A", ALC883_AUTO),
8666 SND_PCI_QUIRK(0x1025, 0x015e, "Acer Aspire 6930G",
8667 ALC888_ACER_ASPIRE_4930G),
8668 SND_PCI_QUIRK(0x1025, 0x0166, "Acer Aspire 6530G",
8669 ALC888_ACER_ASPIRE_4930G),
8671 SND_PCI_QUIRK_VENDOR(0x1025, "Acer laptop", ALC883_ACER),
8672 SND_PCI_QUIRK(0x1028, 0x020d, "Dell Inspiron 530", ALC888_6ST_DELL),
8673 SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG),
8674 SND_PCI_QUIRK(0x103c, 0x2a4f, "HP Samba", ALC888_3ST_HP),
8675 SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_3ST_HP),
8676 SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC883_6ST_DIG),
8677 SND_PCI_QUIRK(0x103c, 0x2a66, "HP Acacia", ALC888_3ST_HP),
8678 SND_PCI_QUIRK(0x103c, 0x2a72, "HP Educ.ar", ALC888_3ST_HP),
8679 SND_PCI_QUIRK(0x1043, 0x1873, "Asus M90V", ALC888_ASUS_M90V),
8680 SND_PCI_QUIRK(0x1043, 0x8249, "Asus M2A-VM HDMI", ALC883_3ST_6ch_DIG),
8681 SND_PCI_QUIRK(0x1043, 0x8284, "Asus Z37E", ALC883_6ST_DIG),
8682 SND_PCI_QUIRK(0x1043, 0x82fe, "Asus P5Q-EM HDMI", ALC1200_ASUS_P5Q),
8683 SND_PCI_QUIRK(0x1043, 0x835f, "Asus Eee 1601", ALC888_ASUS_EEE1601),
8684 SND_PCI_QUIRK(0x105b, 0x0ce8, "Foxconn P35AX-S", ALC883_6ST_DIG),
8685 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC883_6ST_DIG),
8686 SND_PCI_QUIRK(0x1071, 0x8227, "Mitac 82801H", ALC883_MITAC),
8687 SND_PCI_QUIRK(0x1071, 0x8253, "Mitac 8252d", ALC883_MITAC),
8688 SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD),
8689 SND_PCI_QUIRK(0x10f1, 0x2350, "TYAN-S2350", ALC888_6ST_DELL),
8690 SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch),
8691 SND_PCI_QUIRK(0x1458, 0xa002, "MSI", ALC883_6ST_DIG),
8692 SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG),
8693 SND_PCI_QUIRK(0x1462, 0x040d, "MSI", ALC883_TARGA_2ch_DIG),
8694 SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG),
8695 SND_PCI_QUIRK(0x1462, 0x2fb3, "MSI", ALC883_TARGA_2ch_DIG),
8696 SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG),
8697 SND_PCI_QUIRK(0x1462, 0x3783, "NEC S970", ALC883_TARGA_DIG),
8698 SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG),
8699 SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG),
8700 SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG),
8701 SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG),
8702 SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG),
8703 SND_PCI_QUIRK(0x1462, 0x3fdf, "MSI", ALC883_TARGA_DIG),
8704 SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG),
8705 SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG),
8706 SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG),
8707 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG),
8708 SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG),
8709 SND_PCI_QUIRK(0x1462, 0x7250, "MSI", ALC883_6ST_DIG),
8710 SND_PCI_QUIRK(0x1462, 0x7260, "MSI 7260", ALC883_TARGA_DIG),
8711 SND_PCI_QUIRK(0x1462, 0x7267, "MSI", ALC883_3ST_6ch_DIG),
8712 SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG),
8713 SND_PCI_QUIRK(0x1462, 0x7327, "MSI", ALC883_6ST_DIG),
8714 SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG),
8715 SND_PCI_QUIRK(0x147b, 0x1083, "Abit IP35-PRO", ALC883_6ST_DIG),
8716 SND_PCI_QUIRK(0x1558, 0x0721, "Clevo laptop M720R", ALC883_CLEVO_M720),
8717 SND_PCI_QUIRK(0x1558, 0x0722, "Clevo laptop M720SR", ALC883_CLEVO_M720),
8718 SND_PCI_QUIRK_VENDOR(0x1558, "Clevo laptop", ALC883_LAPTOP_EAPD),
8719 SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch),
8720 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
8721 SND_PCI_QUIRK(0x1734, 0x1107, "FSC AMILO Xi2550",
8722 ALC883_FUJITSU_PI2515),
8723 SND_PCI_QUIRK(0x1734, 0x1108, "Fujitsu AMILO Pi2515", ALC883_FUJITSU_PI2515),
8724 SND_PCI_QUIRK(0x1734, 0x113d, "Fujitsu AMILO Xa3530",
8725 ALC888_FUJITSU_XA3530),
8726 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch),
8727 SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763),
8728 SND_PCI_QUIRK(0x17aa, 0x3bfc, "Lenovo NB0763", ALC883_LENOVO_NB0763),
8729 SND_PCI_QUIRK(0x17aa, 0x3bfd, "Lenovo NB0763", ALC883_LENOVO_NB0763),
8730 SND_PCI_QUIRK(0x17aa, 0x101d, "Lenovo Sky", ALC888_LENOVO_SKY),
8731 SND_PCI_QUIRK(0x17c0, 0x4071, "MEDION MD2", ALC883_MEDION_MD2),
8732 SND_PCI_QUIRK(0x17c0, 0x4085, "MEDION MD96630", ALC888_LENOVO_MS7195_DIG),
8733 SND_PCI_QUIRK(0x17f2, 0x5000, "Albatron KI690-AM2", ALC883_6ST_DIG),
8734 SND_PCI_QUIRK(0x1991, 0x5625, "Haier W66", ALC883_HAIER_W66),
8735 SND_PCI_QUIRK(0x8086, 0x0001, "DG33BUC", ALC883_3ST_6ch_INTEL),
8736 SND_PCI_QUIRK(0x8086, 0x0002, "DG33FBC", ALC883_3ST_6ch_INTEL),
8737 SND_PCI_QUIRK(0x8086, 0x2503, "82801H", ALC883_MITAC),
8738 SND_PCI_QUIRK(0x8086, 0x0022, "DX58SO", ALC883_3ST_6ch_INTEL),
8739 SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC883_3ST_6ch),
8743 static hda_nid_t alc1200_slave_dig_outs[] = {
8744 ALC883_DIGOUT_NID, 0,
8747 static struct alc_config_preset alc883_presets[] = {
8748 [ALC883_3ST_2ch_DIG] = {
8749 .mixers = { alc883_3ST_2ch_mixer },
8750 .init_verbs = { alc883_init_verbs },
8751 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8752 .dac_nids = alc883_dac_nids,
8753 .dig_out_nid = ALC883_DIGOUT_NID,
8754 .dig_in_nid = ALC883_DIGIN_NID,
8755 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8756 .channel_mode = alc883_3ST_2ch_modes,
8757 .input_mux = &alc883_capture_source,
8759 [ALC883_3ST_6ch_DIG] = {
8760 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
8761 .init_verbs = { alc883_init_verbs },
8762 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8763 .dac_nids = alc883_dac_nids,
8764 .dig_out_nid = ALC883_DIGOUT_NID,
8765 .dig_in_nid = ALC883_DIGIN_NID,
8766 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8767 .channel_mode = alc883_3ST_6ch_modes,
8769 .input_mux = &alc883_capture_source,
8771 [ALC883_3ST_6ch] = {
8772 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
8773 .init_verbs = { alc883_init_verbs },
8774 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8775 .dac_nids = alc883_dac_nids,
8776 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8777 .channel_mode = alc883_3ST_6ch_modes,
8779 .input_mux = &alc883_capture_source,
8781 [ALC883_3ST_6ch_INTEL] = {
8782 .mixers = { alc883_3ST_6ch_intel_mixer, alc883_chmode_mixer },
8783 .init_verbs = { alc883_init_verbs },
8784 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8785 .dac_nids = alc883_dac_nids,
8786 .dig_out_nid = ALC883_DIGOUT_NID,
8787 .dig_in_nid = ALC883_DIGIN_NID,
8788 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_intel_modes),
8789 .channel_mode = alc883_3ST_6ch_intel_modes,
8791 .input_mux = &alc883_3stack_6ch_intel,
8793 [ALC883_6ST_DIG] = {
8794 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
8795 .init_verbs = { alc883_init_verbs },
8796 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8797 .dac_nids = alc883_dac_nids,
8798 .dig_out_nid = ALC883_DIGOUT_NID,
8799 .dig_in_nid = ALC883_DIGIN_NID,
8800 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
8801 .channel_mode = alc883_sixstack_modes,
8802 .input_mux = &alc883_capture_source,
8804 [ALC883_TARGA_DIG] = {
8805 .mixers = { alc883_tagra_mixer, alc883_chmode_mixer },
8806 .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
8807 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8808 .dac_nids = alc883_dac_nids,
8809 .dig_out_nid = ALC883_DIGOUT_NID,
8810 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8811 .channel_mode = alc883_3ST_6ch_modes,
8813 .input_mux = &alc883_capture_source,
8814 .unsol_event = alc883_tagra_unsol_event,
8815 .init_hook = alc883_tagra_automute,
8817 [ALC883_TARGA_2ch_DIG] = {
8818 .mixers = { alc883_tagra_2ch_mixer},
8819 .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
8820 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8821 .dac_nids = alc883_dac_nids,
8822 .adc_nids = alc883_adc_nids_alt,
8823 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
8824 .dig_out_nid = ALC883_DIGOUT_NID,
8825 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8826 .channel_mode = alc883_3ST_2ch_modes,
8827 .input_mux = &alc883_capture_source,
8828 .unsol_event = alc883_tagra_unsol_event,
8829 .init_hook = alc883_tagra_automute,
8832 .mixers = { alc883_base_mixer },
8833 /* On TravelMate laptops, GPIO 0 enables the internal speaker
8834 * and the headphone jack. Turn this on and rely on the
8835 * standard mute methods whenever the user wants to turn
8836 * these outputs off.
8838 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs },
8839 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8840 .dac_nids = alc883_dac_nids,
8841 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8842 .channel_mode = alc883_3ST_2ch_modes,
8843 .input_mux = &alc883_capture_source,
8845 [ALC883_ACER_ASPIRE] = {
8846 .mixers = { alc883_acer_aspire_mixer },
8847 .init_verbs = { alc883_init_verbs, alc883_acer_eapd_verbs },
8848 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8849 .dac_nids = alc883_dac_nids,
8850 .dig_out_nid = ALC883_DIGOUT_NID,
8851 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8852 .channel_mode = alc883_3ST_2ch_modes,
8853 .input_mux = &alc883_capture_source,
8854 .unsol_event = alc883_acer_aspire_unsol_event,
8855 .init_hook = alc883_acer_aspire_automute,
8857 [ALC888_ACER_ASPIRE_4930G] = {
8858 .mixers = { alc888_base_mixer,
8859 alc883_chmode_mixer },
8860 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
8861 alc888_acer_aspire_4930g_verbs },
8862 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8863 .dac_nids = alc883_dac_nids,
8864 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
8865 .adc_nids = alc883_adc_nids_rev,
8866 .capsrc_nids = alc883_capsrc_nids_rev,
8867 .dig_out_nid = ALC883_DIGOUT_NID,
8868 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8869 .channel_mode = alc883_3ST_6ch_modes,
8872 ARRAY_SIZE(alc888_2_capture_sources),
8873 .input_mux = alc888_2_capture_sources,
8874 .unsol_event = alc888_acer_aspire_4930g_unsol_event,
8875 .init_hook = alc888_acer_aspire_4930g_automute,
8878 .mixers = { alc883_fivestack_mixer,
8879 alc883_chmode_mixer },
8880 .init_verbs = { alc883_init_verbs,
8881 alc883_medion_eapd_verbs },
8882 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8883 .dac_nids = alc883_dac_nids,
8884 .adc_nids = alc883_adc_nids_alt,
8885 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
8886 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
8887 .channel_mode = alc883_sixstack_modes,
8888 .input_mux = &alc883_capture_source,
8890 [ALC883_MEDION_MD2] = {
8891 .mixers = { alc883_medion_md2_mixer},
8892 .init_verbs = { alc883_init_verbs, alc883_medion_md2_verbs},
8893 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8894 .dac_nids = alc883_dac_nids,
8895 .dig_out_nid = ALC883_DIGOUT_NID,
8896 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8897 .channel_mode = alc883_3ST_2ch_modes,
8898 .input_mux = &alc883_capture_source,
8899 .unsol_event = alc883_medion_md2_unsol_event,
8900 .init_hook = alc883_medion_md2_automute,
8902 [ALC883_LAPTOP_EAPD] = {
8903 .mixers = { alc883_base_mixer },
8904 .init_verbs = { alc883_init_verbs, alc882_eapd_verbs },
8905 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8906 .dac_nids = alc883_dac_nids,
8907 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8908 .channel_mode = alc883_3ST_2ch_modes,
8909 .input_mux = &alc883_capture_source,
8911 [ALC883_CLEVO_M720] = {
8912 .mixers = { alc883_clevo_m720_mixer },
8913 .init_verbs = { alc883_init_verbs, alc883_clevo_m720_verbs },
8914 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8915 .dac_nids = alc883_dac_nids,
8916 .dig_out_nid = ALC883_DIGOUT_NID,
8917 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8918 .channel_mode = alc883_3ST_2ch_modes,
8919 .input_mux = &alc883_capture_source,
8920 .unsol_event = alc883_clevo_m720_unsol_event,
8921 .init_hook = alc883_clevo_m720_automute,
8923 [ALC883_LENOVO_101E_2ch] = {
8924 .mixers = { alc883_lenovo_101e_2ch_mixer},
8925 .init_verbs = { alc883_init_verbs, alc883_lenovo_101e_verbs},
8926 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8927 .dac_nids = alc883_dac_nids,
8928 .adc_nids = alc883_adc_nids_alt,
8929 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
8930 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8931 .channel_mode = alc883_3ST_2ch_modes,
8932 .input_mux = &alc883_lenovo_101e_capture_source,
8933 .unsol_event = alc883_lenovo_101e_unsol_event,
8934 .init_hook = alc883_lenovo_101e_all_automute,
8936 [ALC883_LENOVO_NB0763] = {
8937 .mixers = { alc883_lenovo_nb0763_mixer },
8938 .init_verbs = { alc883_init_verbs, alc883_lenovo_nb0763_verbs},
8939 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8940 .dac_nids = alc883_dac_nids,
8941 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8942 .channel_mode = alc883_3ST_2ch_modes,
8944 .input_mux = &alc883_lenovo_nb0763_capture_source,
8945 .unsol_event = alc883_medion_md2_unsol_event,
8946 .init_hook = alc883_medion_md2_automute,
8948 [ALC888_LENOVO_MS7195_DIG] = {
8949 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
8950 .init_verbs = { alc883_init_verbs, alc888_lenovo_ms7195_verbs},
8951 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8952 .dac_nids = alc883_dac_nids,
8953 .dig_out_nid = ALC883_DIGOUT_NID,
8954 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8955 .channel_mode = alc883_3ST_6ch_modes,
8957 .input_mux = &alc883_capture_source,
8958 .unsol_event = alc883_lenovo_ms7195_unsol_event,
8959 .init_hook = alc888_lenovo_ms7195_front_automute,
8961 [ALC883_HAIER_W66] = {
8962 .mixers = { alc883_tagra_2ch_mixer},
8963 .init_verbs = { alc883_init_verbs, alc883_haier_w66_verbs},
8964 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8965 .dac_nids = alc883_dac_nids,
8966 .dig_out_nid = ALC883_DIGOUT_NID,
8967 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8968 .channel_mode = alc883_3ST_2ch_modes,
8969 .input_mux = &alc883_capture_source,
8970 .unsol_event = alc883_haier_w66_unsol_event,
8971 .init_hook = alc883_haier_w66_automute,
8974 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
8975 .init_verbs = { alc883_init_verbs, alc888_3st_hp_verbs },
8976 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8977 .dac_nids = alc883_dac_nids,
8978 .num_channel_mode = ARRAY_SIZE(alc888_3st_hp_modes),
8979 .channel_mode = alc888_3st_hp_modes,
8981 .input_mux = &alc883_capture_source,
8982 .unsol_event = alc888_3st_hp_unsol_event,
8983 .init_hook = alc888_3st_hp_front_automute,
8985 [ALC888_6ST_DELL] = {
8986 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
8987 .init_verbs = { alc883_init_verbs, alc888_6st_dell_verbs },
8988 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8989 .dac_nids = alc883_dac_nids,
8990 .dig_out_nid = ALC883_DIGOUT_NID,
8991 .dig_in_nid = ALC883_DIGIN_NID,
8992 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
8993 .channel_mode = alc883_sixstack_modes,
8994 .input_mux = &alc883_capture_source,
8995 .unsol_event = alc888_6st_dell_unsol_event,
8996 .init_hook = alc888_6st_dell_front_automute,
8999 .mixers = { alc883_mitac_mixer },
9000 .init_verbs = { alc883_init_verbs, alc883_mitac_verbs },
9001 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9002 .dac_nids = alc883_dac_nids,
9003 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9004 .channel_mode = alc883_3ST_2ch_modes,
9005 .input_mux = &alc883_capture_source,
9006 .unsol_event = alc883_mitac_unsol_event,
9007 .init_hook = alc883_mitac_automute,
9009 [ALC883_FUJITSU_PI2515] = {
9010 .mixers = { alc883_2ch_fujitsu_pi2515_mixer },
9011 .init_verbs = { alc883_init_verbs,
9012 alc883_2ch_fujitsu_pi2515_verbs},
9013 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9014 .dac_nids = alc883_dac_nids,
9015 .dig_out_nid = ALC883_DIGOUT_NID,
9016 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9017 .channel_mode = alc883_3ST_2ch_modes,
9018 .input_mux = &alc883_fujitsu_pi2515_capture_source,
9019 .unsol_event = alc883_2ch_fujitsu_pi2515_unsol_event,
9020 .init_hook = alc883_2ch_fujitsu_pi2515_automute,
9022 [ALC888_FUJITSU_XA3530] = {
9023 .mixers = { alc888_base_mixer, alc883_chmode_mixer },
9024 .init_verbs = { alc883_init_verbs,
9025 alc888_fujitsu_xa3530_verbs },
9026 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9027 .dac_nids = alc883_dac_nids,
9028 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
9029 .adc_nids = alc883_adc_nids_rev,
9030 .capsrc_nids = alc883_capsrc_nids_rev,
9031 .dig_out_nid = ALC883_DIGOUT_NID,
9032 .num_channel_mode = ARRAY_SIZE(alc888_4ST_8ch_intel_modes),
9033 .channel_mode = alc888_4ST_8ch_intel_modes,
9035 ARRAY_SIZE(alc888_2_capture_sources),
9036 .input_mux = alc888_2_capture_sources,
9037 .unsol_event = alc888_fujitsu_xa3530_unsol_event,
9038 .init_hook = alc888_fujitsu_xa3530_automute,
9040 [ALC888_LENOVO_SKY] = {
9041 .mixers = { alc888_lenovo_sky_mixer, alc883_chmode_mixer },
9042 .init_verbs = { alc883_init_verbs, alc888_lenovo_sky_verbs},
9043 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9044 .dac_nids = alc883_dac_nids,
9045 .dig_out_nid = ALC883_DIGOUT_NID,
9046 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9047 .channel_mode = alc883_sixstack_modes,
9049 .input_mux = &alc883_lenovo_sky_capture_source,
9050 .unsol_event = alc883_lenovo_sky_unsol_event,
9051 .init_hook = alc888_lenovo_sky_front_automute,
9053 [ALC888_ASUS_M90V] = {
9054 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
9055 .init_verbs = { alc883_init_verbs, alc888_asus_m90v_verbs },
9056 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9057 .dac_nids = alc883_dac_nids,
9058 .dig_out_nid = ALC883_DIGOUT_NID,
9059 .dig_in_nid = ALC883_DIGIN_NID,
9060 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9061 .channel_mode = alc883_3ST_6ch_modes,
9063 .input_mux = &alc883_fujitsu_pi2515_capture_source,
9064 .unsol_event = alc883_mode2_unsol_event,
9065 .init_hook = alc883_mode2_inithook,
9067 [ALC888_ASUS_EEE1601] = {
9068 .mixers = { alc883_asus_eee1601_mixer },
9069 .cap_mixer = alc883_asus_eee1601_cap_mixer,
9070 .init_verbs = { alc883_init_verbs, alc888_asus_eee1601_verbs },
9071 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9072 .dac_nids = alc883_dac_nids,
9073 .dig_out_nid = ALC883_DIGOUT_NID,
9074 .dig_in_nid = ALC883_DIGIN_NID,
9075 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9076 .channel_mode = alc883_3ST_2ch_modes,
9078 .input_mux = &alc883_asus_eee1601_capture_source,
9079 .unsol_event = alc883_eee1601_unsol_event,
9080 .init_hook = alc883_eee1601_inithook,
9082 [ALC1200_ASUS_P5Q] = {
9083 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
9084 .init_verbs = { alc883_init_verbs },
9085 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9086 .dac_nids = alc883_dac_nids,
9087 .dig_out_nid = ALC1200_DIGOUT_NID,
9088 .dig_in_nid = ALC883_DIGIN_NID,
9089 .slave_dig_outs = alc1200_slave_dig_outs,
9090 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9091 .channel_mode = alc883_sixstack_modes,
9092 .input_mux = &alc883_capture_source,
9098 * BIOS auto configuration
9100 static void alc883_auto_set_output_and_unmute(struct hda_codec *codec,
9101 hda_nid_t nid, int pin_type,
9105 struct alc_spec *spec = codec->spec;
9108 alc_set_pin_output(codec, nid, pin_type);
9109 if (spec->multiout.dac_nids[dac_idx] == 0x25)
9112 idx = spec->multiout.dac_nids[dac_idx] - 2;
9113 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
9117 static void alc883_auto_init_multi_out(struct hda_codec *codec)
9119 struct alc_spec *spec = codec->spec;
9122 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
9123 for (i = 0; i <= HDA_SIDE; i++) {
9124 hda_nid_t nid = spec->autocfg.line_out_pins[i];
9125 int pin_type = get_pin_type(spec->autocfg.line_out_type);
9127 alc883_auto_set_output_and_unmute(codec, nid, pin_type,
9132 static void alc883_auto_init_hp_out(struct hda_codec *codec)
9134 struct alc_spec *spec = codec->spec;
9137 pin = spec->autocfg.hp_pins[0];
9138 if (pin) /* connect to front */
9140 alc883_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
9141 pin = spec->autocfg.speaker_pins[0];
9143 alc883_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
9146 #define alc883_is_input_pin(nid) alc880_is_input_pin(nid)
9147 #define ALC883_PIN_CD_NID ALC880_PIN_CD_NID
9149 static void alc883_auto_init_analog_input(struct hda_codec *codec)
9151 struct alc_spec *spec = codec->spec;
9154 for (i = 0; i < AUTO_PIN_LAST; i++) {
9155 hda_nid_t nid = spec->autocfg.input_pins[i];
9156 if (alc883_is_input_pin(nid)) {
9157 alc_set_input_pin(codec, nid, i);
9158 if (nid != ALC883_PIN_CD_NID &&
9159 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
9160 snd_hda_codec_write(codec, nid, 0,
9161 AC_VERB_SET_AMP_GAIN_MUTE,
9167 #define alc883_auto_init_input_src alc882_auto_init_input_src
9169 /* almost identical with ALC880 parser... */
9170 static int alc883_parse_auto_config(struct hda_codec *codec)
9172 struct alc_spec *spec = codec->spec;
9173 int err = alc880_parse_auto_config(codec);
9174 struct auto_pin_cfg *cfg = &spec->autocfg;
9180 return 0; /* no config found */
9182 err = alc_auto_add_mic_boost(codec);
9186 /* hack - override the init verbs */
9187 spec->init_verbs[0] = alc883_auto_init_verbs;
9189 /* setup input_mux for ALC889 */
9190 if (codec->vendor_id == 0x10ec0889) {
9191 /* digital-mic input pin is excluded in alc880_auto_create..()
9192 * because it's under 0x18
9194 if (cfg->input_pins[AUTO_PIN_MIC] == 0x12 ||
9195 cfg->input_pins[AUTO_PIN_FRONT_MIC] == 0x12) {
9196 struct hda_input_mux *imux = &spec->private_imux[0];
9197 for (i = 1; i < 3; i++)
9198 memcpy(&spec->private_imux[i],
9199 &spec->private_imux[0],
9200 sizeof(spec->private_imux[0]));
9201 imux->items[imux->num_items].label = "Int DMic";
9202 imux->items[imux->num_items].index = 0x0b;
9204 spec->num_mux_defs = 3;
9205 spec->input_mux = spec->private_imux;
9209 return 1; /* config found */
9212 /* additional initialization for auto-configuration model */
9213 static void alc883_auto_init(struct hda_codec *codec)
9215 struct alc_spec *spec = codec->spec;
9216 alc883_auto_init_multi_out(codec);
9217 alc883_auto_init_hp_out(codec);
9218 alc883_auto_init_analog_input(codec);
9219 alc883_auto_init_input_src(codec);
9220 if (spec->unsol_event)
9221 alc_inithook(codec);
9224 static int patch_alc883(struct hda_codec *codec)
9226 struct alc_spec *spec;
9227 int err, board_config;
9229 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
9235 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
9237 board_config = snd_hda_check_board_config(codec, ALC883_MODEL_LAST,
9240 if (board_config < 0) {
9241 printk(KERN_INFO "hda_codec: Unknown model for ALC883, "
9242 "trying auto-probe from BIOS...\n");
9243 board_config = ALC883_AUTO;
9246 if (board_config == ALC883_AUTO) {
9247 /* automatic parse from the BIOS config */
9248 err = alc883_parse_auto_config(codec);
9254 "hda_codec: Cannot set up configuration "
9255 "from BIOS. Using base mode...\n");
9256 board_config = ALC883_3ST_2ch_DIG;
9260 err = snd_hda_attach_beep_device(codec, 0x1);
9266 if (board_config != ALC883_AUTO)
9267 setup_preset(spec, &alc883_presets[board_config]);
9269 switch (codec->vendor_id) {
9271 if (codec->revision_id == 0x100101) {
9272 spec->stream_name_analog = "ALC1200 Analog";
9273 spec->stream_name_digital = "ALC1200 Digital";
9275 spec->stream_name_analog = "ALC888 Analog";
9276 spec->stream_name_digital = "ALC888 Digital";
9278 if (!spec->num_adc_nids) {
9279 spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids);
9280 spec->adc_nids = alc883_adc_nids;
9282 if (!spec->capsrc_nids)
9283 spec->capsrc_nids = alc883_capsrc_nids;
9284 spec->capture_style = CAPT_MIX; /* matrix-style capture */
9287 spec->stream_name_analog = "ALC889 Analog";
9288 spec->stream_name_digital = "ALC889 Digital";
9289 if (!spec->num_adc_nids) {
9290 spec->num_adc_nids = ARRAY_SIZE(alc889_adc_nids);
9291 spec->adc_nids = alc889_adc_nids;
9293 if (!spec->capsrc_nids)
9294 spec->capsrc_nids = alc889_capsrc_nids;
9295 spec->capture_style = CAPT_1MUX_MIX; /* 1mux/Nmix-style
9299 spec->stream_name_analog = "ALC883 Analog";
9300 spec->stream_name_digital = "ALC883 Digital";
9301 if (!spec->num_adc_nids) {
9302 spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids);
9303 spec->adc_nids = alc883_adc_nids;
9305 if (!spec->capsrc_nids)
9306 spec->capsrc_nids = alc883_capsrc_nids;
9307 spec->capture_style = CAPT_MIX; /* matrix-style capture */
9311 spec->stream_analog_playback = &alc883_pcm_analog_playback;
9312 spec->stream_analog_capture = &alc883_pcm_analog_capture;
9313 spec->stream_analog_alt_capture = &alc883_pcm_analog_alt_capture;
9315 spec->stream_digital_playback = &alc883_pcm_digital_playback;
9316 spec->stream_digital_capture = &alc883_pcm_digital_capture;
9318 if (!spec->cap_mixer)
9319 set_capture_mixer(spec);
9320 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
9322 spec->vmaster_nid = 0x0c;
9324 codec->patch_ops = alc_patch_ops;
9325 if (board_config == ALC883_AUTO)
9326 spec->init_hook = alc883_auto_init;
9328 #ifdef CONFIG_SND_HDA_POWER_SAVE
9329 if (!spec->loopback.amplist)
9330 spec->loopback.amplist = alc883_loopbacks;
9332 codec->proc_widget_hook = print_realtek_coef;
9341 #define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
9342 #define ALC262_DIGIN_NID ALC880_DIGIN_NID
9344 #define alc262_dac_nids alc260_dac_nids
9345 #define alc262_adc_nids alc882_adc_nids
9346 #define alc262_adc_nids_alt alc882_adc_nids_alt
9347 #define alc262_capsrc_nids alc882_capsrc_nids
9348 #define alc262_capsrc_nids_alt alc882_capsrc_nids_alt
9350 #define alc262_modes alc260_modes
9351 #define alc262_capture_source alc882_capture_source
9353 static hda_nid_t alc262_dmic_adc_nids[1] = {
9358 static hda_nid_t alc262_dmic_capsrc_nids[1] = { 0x22 };
9360 static struct snd_kcontrol_new alc262_base_mixer[] = {
9361 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9362 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9363 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9364 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9365 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9366 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9367 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9368 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9369 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9370 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9371 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
9372 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
9373 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
9374 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9375 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
9376 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
9380 static struct snd_kcontrol_new alc262_hippo1_mixer[] = {
9381 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9382 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9383 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9384 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9385 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9386 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9387 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9388 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9389 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9390 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9391 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
9392 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
9393 /*HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),*/
9394 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
9398 /* update HP, line and mono-out pins according to the master switch */
9399 static void alc262_hp_master_update(struct hda_codec *codec)
9401 struct alc_spec *spec = codec->spec;
9402 int val = spec->master_sw;
9405 snd_hda_codec_write_cache(codec, 0x1b, 0,
9406 AC_VERB_SET_PIN_WIDGET_CONTROL,
9408 snd_hda_codec_write_cache(codec, 0x15, 0,
9409 AC_VERB_SET_PIN_WIDGET_CONTROL,
9411 /* mono (speaker) depending on the HP jack sense */
9412 val = val && !spec->jack_present;
9413 snd_hda_codec_write_cache(codec, 0x16, 0,
9414 AC_VERB_SET_PIN_WIDGET_CONTROL,
9418 static void alc262_hp_bpc_automute(struct hda_codec *codec)
9420 struct alc_spec *spec = codec->spec;
9421 unsigned int presence;
9422 presence = snd_hda_codec_read(codec, 0x1b, 0,
9423 AC_VERB_GET_PIN_SENSE, 0);
9424 spec->jack_present = !!(presence & AC_PINSENSE_PRESENCE);
9425 alc262_hp_master_update(codec);
9428 static void alc262_hp_bpc_unsol_event(struct hda_codec *codec, unsigned int res)
9430 if ((res >> 26) != ALC880_HP_EVENT)
9432 alc262_hp_bpc_automute(codec);
9435 static void alc262_hp_wildwest_automute(struct hda_codec *codec)
9437 struct alc_spec *spec = codec->spec;
9438 unsigned int presence;
9439 presence = snd_hda_codec_read(codec, 0x15, 0,
9440 AC_VERB_GET_PIN_SENSE, 0);
9441 spec->jack_present = !!(presence & AC_PINSENSE_PRESENCE);
9442 alc262_hp_master_update(codec);
9445 static void alc262_hp_wildwest_unsol_event(struct hda_codec *codec,
9448 if ((res >> 26) != ALC880_HP_EVENT)
9450 alc262_hp_wildwest_automute(codec);
9453 static int alc262_hp_master_sw_get(struct snd_kcontrol *kcontrol,
9454 struct snd_ctl_elem_value *ucontrol)
9456 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
9457 struct alc_spec *spec = codec->spec;
9458 *ucontrol->value.integer.value = spec->master_sw;
9462 static int alc262_hp_master_sw_put(struct snd_kcontrol *kcontrol,
9463 struct snd_ctl_elem_value *ucontrol)
9465 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
9466 struct alc_spec *spec = codec->spec;
9467 int val = !!*ucontrol->value.integer.value;
9469 if (val == spec->master_sw)
9471 spec->master_sw = val;
9472 alc262_hp_master_update(codec);
9476 static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
9478 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9479 .name = "Master Playback Switch",
9480 .info = snd_ctl_boolean_mono_info,
9481 .get = alc262_hp_master_sw_get,
9482 .put = alc262_hp_master_sw_put,
9484 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9485 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9486 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
9487 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
9489 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
9491 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9492 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9493 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9494 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9495 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
9496 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
9497 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9498 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9499 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9500 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9501 HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
9502 HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
9506 static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = {
9508 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9509 .name = "Master Playback Switch",
9510 .info = snd_ctl_boolean_mono_info,
9511 .get = alc262_hp_master_sw_get,
9512 .put = alc262_hp_master_sw_put,
9514 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9515 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
9516 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
9517 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9518 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
9520 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
9522 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x02, HDA_INPUT),
9523 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x02, HDA_INPUT),
9524 HDA_CODEC_VOLUME("Front Mic Boost", 0x1a, 0, HDA_INPUT),
9525 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
9526 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
9527 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9528 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9532 static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = {
9533 HDA_CODEC_VOLUME("Rear Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9534 HDA_CODEC_MUTE("Rear Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9535 HDA_CODEC_VOLUME("Rear Mic Boost", 0x18, 0, HDA_INPUT),
9539 /* mute/unmute internal speaker according to the hp jack and mute state */
9540 static void alc262_hp_t5735_automute(struct hda_codec *codec, int force)
9542 struct alc_spec *spec = codec->spec;
9544 if (force || !spec->sense_updated) {
9545 unsigned int present;
9546 present = snd_hda_codec_read(codec, 0x15, 0,
9547 AC_VERB_GET_PIN_SENSE, 0);
9548 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
9549 spec->sense_updated = 1;
9551 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0, HDA_AMP_MUTE,
9552 spec->jack_present ? HDA_AMP_MUTE : 0);
9555 static void alc262_hp_t5735_unsol_event(struct hda_codec *codec,
9558 if ((res >> 26) != ALC880_HP_EVENT)
9560 alc262_hp_t5735_automute(codec, 1);
9563 static void alc262_hp_t5735_init_hook(struct hda_codec *codec)
9565 alc262_hp_t5735_automute(codec, 1);
9568 static struct snd_kcontrol_new alc262_hp_t5735_mixer[] = {
9569 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9570 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9571 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
9572 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9573 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9574 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9575 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9579 static struct hda_verb alc262_hp_t5735_verbs[] = {
9580 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9581 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9583 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9587 static struct snd_kcontrol_new alc262_hp_rp5700_mixer[] = {
9588 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9589 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
9590 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
9591 HDA_CODEC_MUTE("Speaker Playback Switch", 0x16, 0x0, HDA_OUTPUT),
9592 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
9593 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
9597 static struct hda_verb alc262_hp_rp5700_verbs[] = {
9598 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9599 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9600 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9601 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9602 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
9603 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
9604 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
9605 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
9606 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
9607 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
9611 static struct hda_input_mux alc262_hp_rp5700_capture_source = {
9618 /* bind hp and internal speaker mute (with plug check) */
9619 static int alc262_sony_master_sw_put(struct snd_kcontrol *kcontrol,
9620 struct snd_ctl_elem_value *ucontrol)
9622 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
9623 long *valp = ucontrol->value.integer.value;
9626 /* change hp mute */
9627 change = snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
9629 valp[0] ? 0 : HDA_AMP_MUTE);
9630 change |= snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
9632 valp[1] ? 0 : HDA_AMP_MUTE);
9634 /* change speaker according to HP jack state */
9635 struct alc_spec *spec = codec->spec;
9637 if (spec->jack_present)
9638 mute = HDA_AMP_MUTE;
9640 mute = snd_hda_codec_amp_read(codec, 0x15, 0,
9642 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9643 HDA_AMP_MUTE, mute);
9648 static struct snd_kcontrol_new alc262_sony_mixer[] = {
9649 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9651 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9652 .name = "Master Playback Switch",
9653 .info = snd_hda_mixer_amp_switch_info,
9654 .get = snd_hda_mixer_amp_switch_get,
9655 .put = alc262_sony_master_sw_put,
9656 .private_value = HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
9658 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9659 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9660 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9661 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
9665 static struct snd_kcontrol_new alc262_benq_t31_mixer[] = {
9666 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9667 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9668 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9669 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9670 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9671 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9672 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
9676 static struct snd_kcontrol_new alc262_tyan_mixer[] = {
9677 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9678 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
9679 HDA_CODEC_VOLUME("Aux Playback Volume", 0x0b, 0x06, HDA_INPUT),
9680 HDA_CODEC_MUTE("Aux Playback Switch", 0x0b, 0x06, HDA_INPUT),
9681 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9682 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9683 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9684 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9685 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9686 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9687 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
9688 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
9692 static struct hda_verb alc262_tyan_verbs[] = {
9693 /* Headphone automute */
9694 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9695 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9696 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9698 /* P11 AUX_IN, white 4-pin connector */
9699 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
9700 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_1, 0xe1},
9701 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_2, 0x93},
9702 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_3, 0x19},
9707 /* unsolicited event for HP jack sensing */
9708 static void alc262_tyan_automute(struct hda_codec *codec)
9711 unsigned int present;
9713 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
9714 present = snd_hda_codec_read(codec, 0x1b, 0,
9715 AC_VERB_GET_PIN_SENSE, 0);
9716 present = (present & 0x80000000) != 0;
9718 /* mute line output on ATX panel */
9719 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
9720 HDA_AMP_MUTE, HDA_AMP_MUTE);
9722 /* unmute line output if necessary */
9723 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
9724 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
9725 HDA_AMP_MUTE, mute);
9729 static void alc262_tyan_unsol_event(struct hda_codec *codec,
9732 if ((res >> 26) != ALC880_HP_EVENT)
9734 alc262_tyan_automute(codec);
9737 #define alc262_capture_mixer alc882_capture_mixer
9738 #define alc262_capture_alt_mixer alc882_capture_alt_mixer
9741 * generic initialization of ADC, input mixers and output mixers
9743 static struct hda_verb alc262_init_verbs[] = {
9745 * Unmute ADC0-2 and set the default input to mic-in
9747 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
9748 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9749 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
9750 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9751 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
9752 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9754 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
9756 * Note: PASD motherboards uses the Line In 2 as the input for
9757 * front panel mic (mic 2)
9759 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
9760 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9761 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9762 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
9763 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
9764 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
9767 * Set up output mixers (0x0c - 0x0e)
9769 /* set vol=0 to output mixers */
9770 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9771 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9772 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9773 /* set up input amps for analog loopback */
9774 /* Amp Indices: DAC = 0, mixer = 1 */
9775 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9776 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9777 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9778 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9779 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9780 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9782 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
9783 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
9784 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
9785 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
9786 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9787 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9789 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
9790 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
9791 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
9792 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
9793 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
9795 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
9796 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
9798 /* FIXME: use matrix-type input source selection */
9799 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
9800 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
9801 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9802 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
9803 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
9804 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
9806 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9807 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
9808 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
9809 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
9811 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9812 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
9813 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
9814 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
9819 static struct hda_verb alc262_eapd_verbs[] = {
9820 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
9821 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
9825 static struct hda_verb alc262_hippo_unsol_verbs[] = {
9826 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9827 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9831 static struct hda_verb alc262_hippo1_unsol_verbs[] = {
9832 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
9833 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
9834 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
9836 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9837 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9841 static struct hda_verb alc262_sony_unsol_verbs[] = {
9842 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
9843 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9844 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, // Front Mic
9846 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9847 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9851 static struct hda_input_mux alc262_dmic_capture_source = {
9854 { "Int DMic", 0x9 },
9859 static struct snd_kcontrol_new alc262_toshiba_s06_mixer[] = {
9860 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9861 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9862 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9863 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9864 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9868 static struct hda_verb alc262_toshiba_s06_verbs[] = {
9869 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
9870 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9871 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9872 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9873 {0x22, AC_VERB_SET_CONNECT_SEL, 0x09},
9874 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
9875 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
9876 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9880 static void alc262_dmic_automute(struct hda_codec *codec)
9882 unsigned int present;
9884 present = snd_hda_codec_read(codec, 0x18, 0,
9885 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
9886 snd_hda_codec_write(codec, 0x22, 0,
9887 AC_VERB_SET_CONNECT_SEL, present ? 0x0 : 0x09);
9890 /* toggle speaker-output according to the hp-jack state */
9891 static void alc262_toshiba_s06_speaker_automute(struct hda_codec *codec)
9893 unsigned int present;
9896 present = snd_hda_codec_read(codec, 0x15, 0,
9897 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
9898 bits = present ? 0 : PIN_OUT;
9899 snd_hda_codec_write(codec, 0x14, 0,
9900 AC_VERB_SET_PIN_WIDGET_CONTROL, bits);
9905 /* unsolicited event for HP jack sensing */
9906 static void alc262_toshiba_s06_unsol_event(struct hda_codec *codec,
9909 if ((res >> 26) == ALC880_HP_EVENT)
9910 alc262_toshiba_s06_speaker_automute(codec);
9911 if ((res >> 26) == ALC880_MIC_EVENT)
9912 alc262_dmic_automute(codec);
9916 static void alc262_toshiba_s06_init_hook(struct hda_codec *codec)
9918 alc262_toshiba_s06_speaker_automute(codec);
9919 alc262_dmic_automute(codec);
9922 /* mute/unmute internal speaker according to the hp jack and mute state */
9923 static void alc262_hippo_automute(struct hda_codec *codec)
9925 struct alc_spec *spec = codec->spec;
9927 unsigned int present;
9929 /* need to execute and sync at first */
9930 snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
9931 present = snd_hda_codec_read(codec, 0x15, 0,
9932 AC_VERB_GET_PIN_SENSE, 0);
9933 spec->jack_present = (present & 0x80000000) != 0;
9934 if (spec->jack_present) {
9935 /* mute internal speaker */
9936 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9937 HDA_AMP_MUTE, HDA_AMP_MUTE);
9939 /* unmute internal speaker if necessary */
9940 mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0);
9941 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9942 HDA_AMP_MUTE, mute);
9946 /* unsolicited event for HP jack sensing */
9947 static void alc262_hippo_unsol_event(struct hda_codec *codec,
9950 if ((res >> 26) != ALC880_HP_EVENT)
9952 alc262_hippo_automute(codec);
9955 static void alc262_hippo1_automute(struct hda_codec *codec)
9958 unsigned int present;
9960 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
9961 present = snd_hda_codec_read(codec, 0x1b, 0,
9962 AC_VERB_GET_PIN_SENSE, 0);
9963 present = (present & 0x80000000) != 0;
9965 /* mute internal speaker */
9966 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9967 HDA_AMP_MUTE, HDA_AMP_MUTE);
9969 /* unmute internal speaker if necessary */
9970 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
9971 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9972 HDA_AMP_MUTE, mute);
9976 /* unsolicited event for HP jack sensing */
9977 static void alc262_hippo1_unsol_event(struct hda_codec *codec,
9980 if ((res >> 26) != ALC880_HP_EVENT)
9982 alc262_hippo1_automute(codec);
9988 * 0x16 = internal speaker
9989 * 0x18 = external mic
9992 static struct snd_kcontrol_new alc262_nec_mixer[] = {
9993 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
9994 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 0, 0x0, HDA_OUTPUT),
9996 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9997 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9998 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10000 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
10001 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10005 static struct hda_verb alc262_nec_verbs[] = {
10006 /* Unmute Speaker */
10007 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10010 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10011 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10013 /* External mic to headphone */
10014 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10015 /* External mic to speaker */
10016 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10022 * 0x14 = headphone/spdif-out, 0x15 = internal speaker,
10023 * 0x1b = port replicator headphone out
10026 #define ALC_HP_EVENT 0x37
10028 static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
10029 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
10030 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10031 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
10032 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10036 static struct hda_verb alc262_lenovo_3000_unsol_verbs[] = {
10037 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
10038 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10042 static struct hda_input_mux alc262_fujitsu_capture_source = {
10046 { "Int Mic", 0x1 },
10051 static struct hda_input_mux alc262_HP_capture_source = {
10055 { "Front Mic", 0x1 },
10062 static struct hda_input_mux alc262_HP_D7000_capture_source = {
10066 { "Front Mic", 0x2 },
10072 /* mute/unmute internal speaker according to the hp jacks and mute state */
10073 static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
10075 struct alc_spec *spec = codec->spec;
10078 if (force || !spec->sense_updated) {
10079 unsigned int present;
10080 /* need to execute and sync at first */
10081 snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
10082 /* check laptop HP jack */
10083 present = snd_hda_codec_read(codec, 0x14, 0,
10084 AC_VERB_GET_PIN_SENSE, 0);
10085 /* need to execute and sync at first */
10086 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
10087 /* check docking HP jack */
10088 present |= snd_hda_codec_read(codec, 0x1b, 0,
10089 AC_VERB_GET_PIN_SENSE, 0);
10090 if (present & AC_PINSENSE_PRESENCE)
10091 spec->jack_present = 1;
10093 spec->jack_present = 0;
10094 spec->sense_updated = 1;
10096 /* unmute internal speaker only if both HPs are unplugged and
10097 * master switch is on
10099 if (spec->jack_present)
10100 mute = HDA_AMP_MUTE;
10102 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
10103 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
10104 HDA_AMP_MUTE, mute);
10107 /* unsolicited event for HP jack sensing */
10108 static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
10111 if ((res >> 26) != ALC_HP_EVENT)
10113 alc262_fujitsu_automute(codec, 1);
10116 static void alc262_fujitsu_init_hook(struct hda_codec *codec)
10118 alc262_fujitsu_automute(codec, 1);
10121 /* bind volumes of both NID 0x0c and 0x0d */
10122 static struct hda_bind_ctls alc262_fujitsu_bind_master_vol = {
10123 .ops = &snd_hda_bind_vol,
10125 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
10126 HDA_COMPOSE_AMP_VAL(0x0d, 3, 0, HDA_OUTPUT),
10131 /* mute/unmute internal speaker according to the hp jack and mute state */
10132 static void alc262_lenovo_3000_automute(struct hda_codec *codec, int force)
10134 struct alc_spec *spec = codec->spec;
10137 if (force || !spec->sense_updated) {
10138 unsigned int present_int_hp;
10139 /* need to execute and sync at first */
10140 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
10141 present_int_hp = snd_hda_codec_read(codec, 0x1b, 0,
10142 AC_VERB_GET_PIN_SENSE, 0);
10143 spec->jack_present = (present_int_hp & 0x80000000) != 0;
10144 spec->sense_updated = 1;
10146 if (spec->jack_present) {
10147 /* mute internal speaker */
10148 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10149 HDA_AMP_MUTE, HDA_AMP_MUTE);
10150 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
10151 HDA_AMP_MUTE, HDA_AMP_MUTE);
10153 /* unmute internal speaker if necessary */
10154 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
10155 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10156 HDA_AMP_MUTE, mute);
10157 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
10158 HDA_AMP_MUTE, mute);
10162 /* unsolicited event for HP jack sensing */
10163 static void alc262_lenovo_3000_unsol_event(struct hda_codec *codec,
10166 if ((res >> 26) != ALC_HP_EVENT)
10168 alc262_lenovo_3000_automute(codec, 1);
10171 /* bind hp and internal speaker mute (with plug check) */
10172 static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
10173 struct snd_ctl_elem_value *ucontrol)
10175 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10176 long *valp = ucontrol->value.integer.value;
10179 change = snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10181 valp ? 0 : HDA_AMP_MUTE);
10182 change |= snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
10184 valp ? 0 : HDA_AMP_MUTE);
10187 alc262_fujitsu_automute(codec, 0);
10191 static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
10192 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
10194 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10195 .name = "Master Playback Switch",
10196 .info = snd_hda_mixer_amp_switch_info,
10197 .get = snd_hda_mixer_amp_switch_get,
10198 .put = alc262_fujitsu_master_sw_put,
10199 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
10201 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10202 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10203 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10204 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10205 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10206 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
10207 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
10208 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
10212 /* bind hp and internal speaker mute (with plug check) */
10213 static int alc262_lenovo_3000_master_sw_put(struct snd_kcontrol *kcontrol,
10214 struct snd_ctl_elem_value *ucontrol)
10216 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10217 long *valp = ucontrol->value.integer.value;
10220 change = snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
10222 valp ? 0 : HDA_AMP_MUTE);
10225 alc262_lenovo_3000_automute(codec, 0);
10229 static struct snd_kcontrol_new alc262_lenovo_3000_mixer[] = {
10230 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
10232 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10233 .name = "Master Playback Switch",
10234 .info = snd_hda_mixer_amp_switch_info,
10235 .get = snd_hda_mixer_amp_switch_get,
10236 .put = alc262_lenovo_3000_master_sw_put,
10237 .private_value = HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
10239 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10240 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10241 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10242 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10243 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10244 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
10245 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
10246 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
10250 static struct snd_kcontrol_new alc262_toshiba_rx1_mixer[] = {
10251 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
10253 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10254 .name = "Master Playback Switch",
10255 .info = snd_hda_mixer_amp_switch_info,
10256 .get = snd_hda_mixer_amp_switch_get,
10257 .put = alc262_sony_master_sw_put,
10258 .private_value = HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
10260 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10261 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10262 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10263 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10264 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10265 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10269 /* additional init verbs for Benq laptops */
10270 static struct hda_verb alc262_EAPD_verbs[] = {
10271 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
10272 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
10276 static struct hda_verb alc262_benq_t31_EAPD_verbs[] = {
10277 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10278 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10280 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
10281 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
10285 /* Samsung Q1 Ultra Vista model setup */
10286 static struct snd_kcontrol_new alc262_ultra_mixer[] = {
10287 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10288 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
10289 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10290 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10291 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
10292 HDA_CODEC_VOLUME("Headphone Mic Boost", 0x15, 0, HDA_INPUT),
10296 static struct hda_verb alc262_ultra_verbs[] = {
10298 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10299 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10300 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10302 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10303 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10304 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10305 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
10307 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10308 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10309 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10310 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10311 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10313 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
10314 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10315 /* ADC, choose mic */
10316 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10317 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10318 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10319 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10320 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10321 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
10322 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
10323 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
10324 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
10325 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(8)},
10329 /* mute/unmute internal speaker according to the hp jack and mute state */
10330 static void alc262_ultra_automute(struct hda_codec *codec)
10332 struct alc_spec *spec = codec->spec;
10336 /* auto-mute only when HP is used as HP */
10337 if (!spec->cur_mux[0]) {
10338 unsigned int present;
10339 /* need to execute and sync at first */
10340 snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
10341 present = snd_hda_codec_read(codec, 0x15, 0,
10342 AC_VERB_GET_PIN_SENSE, 0);
10343 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
10344 if (spec->jack_present)
10345 mute = HDA_AMP_MUTE;
10347 /* mute/unmute internal speaker */
10348 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10349 HDA_AMP_MUTE, mute);
10350 /* mute/unmute HP */
10351 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
10352 HDA_AMP_MUTE, mute ? 0 : HDA_AMP_MUTE);
10355 /* unsolicited event for HP jack sensing */
10356 static void alc262_ultra_unsol_event(struct hda_codec *codec,
10359 if ((res >> 26) != ALC880_HP_EVENT)
10361 alc262_ultra_automute(codec);
10364 static struct hda_input_mux alc262_ultra_capture_source = {
10368 { "Headphone", 0x7 },
10372 static int alc262_ultra_mux_enum_put(struct snd_kcontrol *kcontrol,
10373 struct snd_ctl_elem_value *ucontrol)
10375 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10376 struct alc_spec *spec = codec->spec;
10379 ret = alc_mux_enum_put(kcontrol, ucontrol);
10382 /* reprogram the HP pin as mic or HP according to the input source */
10383 snd_hda_codec_write_cache(codec, 0x15, 0,
10384 AC_VERB_SET_PIN_WIDGET_CONTROL,
10385 spec->cur_mux[0] ? PIN_VREF80 : PIN_HP);
10386 alc262_ultra_automute(codec); /* mute/unmute HP */
10390 static struct snd_kcontrol_new alc262_ultra_capture_mixer[] = {
10391 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
10392 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
10394 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10395 .name = "Capture Source",
10396 .info = alc_mux_enum_info,
10397 .get = alc_mux_enum_get,
10398 .put = alc262_ultra_mux_enum_put,
10403 /* add playback controls from the parsed DAC table */
10404 static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec,
10405 const struct auto_pin_cfg *cfg)
10410 spec->multiout.num_dacs = 1; /* only use one dac */
10411 spec->multiout.dac_nids = spec->private_dac_nids;
10412 spec->multiout.dac_nids[0] = 2;
10414 nid = cfg->line_out_pins[0];
10416 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10417 "Front Playback Volume",
10418 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT));
10421 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10422 "Front Playback Switch",
10423 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
10428 nid = cfg->speaker_pins[0];
10431 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10432 "Speaker Playback Volume",
10433 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
10437 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10438 "Speaker Playback Switch",
10439 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
10444 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10445 "Speaker Playback Switch",
10446 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
10452 nid = cfg->hp_pins[0];
10454 /* spec->multiout.hp_nid = 2; */
10456 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10457 "Headphone Playback Volume",
10458 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
10462 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10463 "Headphone Playback Switch",
10464 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
10469 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10470 "Headphone Playback Switch",
10471 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
10480 /* identical with ALC880 */
10481 #define alc262_auto_create_analog_input_ctls \
10482 alc880_auto_create_analog_input_ctls
10485 * generic initialization of ADC, input mixers and output mixers
10487 static struct hda_verb alc262_volume_init_verbs[] = {
10489 * Unmute ADC0-2 and set the default input to mic-in
10491 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
10492 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10493 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
10494 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10495 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
10496 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10498 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
10500 * Note: PASD motherboards uses the Line In 2 as the input for
10501 * front panel mic (mic 2)
10503 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
10504 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10505 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10506 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10507 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10508 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
10511 * Set up output mixers (0x0c - 0x0f)
10513 /* set vol=0 to output mixers */
10514 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10515 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10516 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10518 /* set up input amps for analog loopback */
10519 /* Amp Indices: DAC = 0, mixer = 1 */
10520 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10521 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10522 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10523 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10524 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10525 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10527 /* FIXME: use matrix-type input source selection */
10528 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
10529 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
10530 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10531 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10532 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10533 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10535 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10536 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10537 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10538 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10540 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10541 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10542 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10543 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10548 static struct hda_verb alc262_HP_BPC_init_verbs[] = {
10550 * Unmute ADC0-2 and set the default input to mic-in
10552 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
10553 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10554 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
10555 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10556 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
10557 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10559 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
10561 * Note: PASD motherboards uses the Line In 2 as the input for
10562 * front panel mic (mic 2)
10564 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
10565 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10566 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10567 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10568 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10569 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
10570 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
10571 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
10574 * Set up output mixers (0x0c - 0x0e)
10576 /* set vol=0 to output mixers */
10577 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10578 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10579 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10581 /* set up input amps for analog loopback */
10582 /* Amp Indices: DAC = 0, mixer = 1 */
10583 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10584 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10585 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10586 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10587 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10588 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10590 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10591 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10592 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10594 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10595 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10597 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
10598 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10600 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10601 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10602 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10603 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10604 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10606 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
10607 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10608 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10609 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
10610 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10611 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10614 /* FIXME: use matrix-type input source selection */
10615 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
10616 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
10617 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10618 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
10619 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
10620 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
10622 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10623 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
10624 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
10625 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
10627 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10628 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
10629 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
10630 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
10632 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
10637 static struct hda_verb alc262_HP_BPC_WildWest_init_verbs[] = {
10639 * Unmute ADC0-2 and set the default input to mic-in
10641 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
10642 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10643 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
10644 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10645 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
10646 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10648 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
10650 * Note: PASD motherboards uses the Line In 2 as the input for front
10651 * panel mic (mic 2)
10653 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
10654 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10655 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10656 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10657 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10658 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
10659 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
10660 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
10661 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
10663 * Set up output mixers (0x0c - 0x0e)
10665 /* set vol=0 to output mixers */
10666 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10667 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10668 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10670 /* set up input amps for analog loopback */
10671 /* Amp Indices: DAC = 0, mixer = 1 */
10672 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10673 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10674 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10675 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10676 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10677 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10680 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP */
10681 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Mono */
10682 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* rear MIC */
10683 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* Line in */
10684 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
10685 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Line out */
10686 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD in */
10688 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10689 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10691 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
10692 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
10694 /* {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, */
10695 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10696 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10697 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
10698 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10699 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10701 /* FIXME: use matrix-type input source selection */
10702 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
10703 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
10704 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, /*rear MIC*/
10705 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, /*Line in*/
10706 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, /*F MIC*/
10707 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, /*Front*/
10708 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, /*CD*/
10709 /* {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
10710 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, /*HP*/
10712 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10713 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
10714 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
10715 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
10716 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
10717 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
10718 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
10720 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10721 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
10722 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
10723 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
10724 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
10725 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
10726 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
10728 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
10733 static struct hda_verb alc262_toshiba_rx1_unsol_verbs[] = {
10735 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Front Speaker */
10736 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10737 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
10739 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* MIC jack */
10740 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
10741 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
10742 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
10744 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP jack */
10745 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10746 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10751 #ifdef CONFIG_SND_HDA_POWER_SAVE
10752 #define alc262_loopbacks alc880_loopbacks
10755 /* pcm configuration: identiacal with ALC880 */
10756 #define alc262_pcm_analog_playback alc880_pcm_analog_playback
10757 #define alc262_pcm_analog_capture alc880_pcm_analog_capture
10758 #define alc262_pcm_digital_playback alc880_pcm_digital_playback
10759 #define alc262_pcm_digital_capture alc880_pcm_digital_capture
10762 * BIOS auto configuration
10764 static int alc262_parse_auto_config(struct hda_codec *codec)
10766 struct alc_spec *spec = codec->spec;
10768 static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
10770 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
10774 if (!spec->autocfg.line_outs) {
10775 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
10776 spec->multiout.max_channels = 2;
10777 spec->no_analog = 1;
10780 return 0; /* can't find valid BIOS pin config */
10782 err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg);
10785 err = alc262_auto_create_analog_input_ctls(spec, &spec->autocfg);
10789 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
10792 if (spec->autocfg.dig_outs) {
10793 spec->multiout.dig_out_nid = ALC262_DIGOUT_NID;
10794 spec->dig_out_type = spec->autocfg.dig_out_type[0];
10796 if (spec->autocfg.dig_in_pin)
10797 spec->dig_in_nid = ALC262_DIGIN_NID;
10799 if (spec->kctls.list)
10800 add_mixer(spec, spec->kctls.list);
10802 add_verb(spec, alc262_volume_init_verbs);
10803 spec->num_mux_defs = 1;
10804 spec->input_mux = &spec->private_imux[0];
10806 err = alc_auto_add_mic_boost(codec);
10813 #define alc262_auto_init_multi_out alc882_auto_init_multi_out
10814 #define alc262_auto_init_hp_out alc882_auto_init_hp_out
10815 #define alc262_auto_init_analog_input alc882_auto_init_analog_input
10816 #define alc262_auto_init_input_src alc882_auto_init_input_src
10819 /* init callback for auto-configuration model -- overriding the default init */
10820 static void alc262_auto_init(struct hda_codec *codec)
10822 struct alc_spec *spec = codec->spec;
10823 alc262_auto_init_multi_out(codec);
10824 alc262_auto_init_hp_out(codec);
10825 alc262_auto_init_analog_input(codec);
10826 alc262_auto_init_input_src(codec);
10827 if (spec->unsol_event)
10828 alc_inithook(codec);
10832 * configuration and preset
10834 static const char *alc262_models[ALC262_MODEL_LAST] = {
10835 [ALC262_BASIC] = "basic",
10836 [ALC262_HIPPO] = "hippo",
10837 [ALC262_HIPPO_1] = "hippo_1",
10838 [ALC262_FUJITSU] = "fujitsu",
10839 [ALC262_HP_BPC] = "hp-bpc",
10840 [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000",
10841 [ALC262_HP_TC_T5735] = "hp-tc-t5735",
10842 [ALC262_HP_RP5700] = "hp-rp5700",
10843 [ALC262_BENQ_ED8] = "benq",
10844 [ALC262_BENQ_T31] = "benq-t31",
10845 [ALC262_SONY_ASSAMD] = "sony-assamd",
10846 [ALC262_TOSHIBA_S06] = "toshiba-s06",
10847 [ALC262_TOSHIBA_RX1] = "toshiba-rx1",
10848 [ALC262_ULTRA] = "ultra",
10849 [ALC262_LENOVO_3000] = "lenovo-3000",
10850 [ALC262_NEC] = "nec",
10851 [ALC262_TYAN] = "tyan",
10852 [ALC262_AUTO] = "auto",
10855 static struct snd_pci_quirk alc262_cfg_tbl[] = {
10856 SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO),
10857 SND_PCI_QUIRK(0x1033, 0x8895, "NEC Versa S9100", ALC262_NEC),
10858 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1200, "HP xw series",
10860 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1300, "HP xw series",
10862 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1700, "HP xw series",
10864 SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL),
10865 SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF),
10866 SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL),
10867 SND_PCI_QUIRK(0x103c, 0x2803, "HP D7000", ALC262_HP_BPC_D7000_WF),
10868 SND_PCI_QUIRK(0x103c, 0x2804, "HP D7000", ALC262_HP_BPC_D7000_WL),
10869 SND_PCI_QUIRK(0x103c, 0x2805, "HP D7000", ALC262_HP_BPC_D7000_WF),
10870 SND_PCI_QUIRK(0x103c, 0x2806, "HP D7000", ALC262_HP_BPC_D7000_WL),
10871 SND_PCI_QUIRK(0x103c, 0x2807, "HP D7000", ALC262_HP_BPC_D7000_WF),
10872 SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC),
10873 SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC),
10874 SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC),
10875 SND_PCI_QUIRK(0x103c, 0x302f, "HP Thin Client T5735",
10876 ALC262_HP_TC_T5735),
10877 SND_PCI_QUIRK(0x103c, 0x2817, "HP RP5700", ALC262_HP_RP5700),
10878 SND_PCI_QUIRK(0x104d, 0x1f00, "Sony ASSAMD", ALC262_SONY_ASSAMD),
10879 SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO),
10880 SND_PCI_QUIRK(0x104d, 0x820f, "Sony ASSAMD", ALC262_SONY_ASSAMD),
10881 SND_PCI_QUIRK(0x104d, 0x9016, "Sony VAIO", ALC262_AUTO), /* dig-only */
10882 SND_PCI_QUIRK_MASK(0x104d, 0xff00, 0x9000, "Sony VAIO",
10883 ALC262_SONY_ASSAMD),
10884 SND_PCI_QUIRK(0x1179, 0x0001, "Toshiba dynabook SS RX1",
10885 ALC262_TOSHIBA_RX1),
10886 SND_PCI_QUIRK(0x1179, 0xff7b, "Toshiba S06", ALC262_TOSHIBA_S06),
10887 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
10888 SND_PCI_QUIRK(0x10cf, 0x142d, "Fujitsu Lifebook E8410", ALC262_FUJITSU),
10889 SND_PCI_QUIRK(0x10f1, 0x2915, "Tyan Thunder n6650W", ALC262_TYAN),
10890 SND_PCI_QUIRK_MASK(0x144d, 0xff00, 0xc032, "Samsung Q1",
10892 SND_PCI_QUIRK(0x144d, 0xc510, "Samsung Q45", ALC262_HIPPO),
10893 SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000 y410", ALC262_LENOVO_3000),
10894 SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
10895 SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_BENQ_T31),
10896 SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1),
10900 static struct alc_config_preset alc262_presets[] = {
10902 .mixers = { alc262_base_mixer },
10903 .init_verbs = { alc262_init_verbs },
10904 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10905 .dac_nids = alc262_dac_nids,
10907 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10908 .channel_mode = alc262_modes,
10909 .input_mux = &alc262_capture_source,
10912 .mixers = { alc262_base_mixer },
10913 .init_verbs = { alc262_init_verbs, alc262_hippo_unsol_verbs},
10914 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10915 .dac_nids = alc262_dac_nids,
10917 .dig_out_nid = ALC262_DIGOUT_NID,
10918 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10919 .channel_mode = alc262_modes,
10920 .input_mux = &alc262_capture_source,
10921 .unsol_event = alc262_hippo_unsol_event,
10922 .init_hook = alc262_hippo_automute,
10924 [ALC262_HIPPO_1] = {
10925 .mixers = { alc262_hippo1_mixer },
10926 .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs},
10927 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10928 .dac_nids = alc262_dac_nids,
10930 .dig_out_nid = ALC262_DIGOUT_NID,
10931 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10932 .channel_mode = alc262_modes,
10933 .input_mux = &alc262_capture_source,
10934 .unsol_event = alc262_hippo1_unsol_event,
10935 .init_hook = alc262_hippo1_automute,
10937 [ALC262_FUJITSU] = {
10938 .mixers = { alc262_fujitsu_mixer },
10939 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
10940 alc262_fujitsu_unsol_verbs },
10941 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10942 .dac_nids = alc262_dac_nids,
10944 .dig_out_nid = ALC262_DIGOUT_NID,
10945 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10946 .channel_mode = alc262_modes,
10947 .input_mux = &alc262_fujitsu_capture_source,
10948 .unsol_event = alc262_fujitsu_unsol_event,
10949 .init_hook = alc262_fujitsu_init_hook,
10951 [ALC262_HP_BPC] = {
10952 .mixers = { alc262_HP_BPC_mixer },
10953 .init_verbs = { alc262_HP_BPC_init_verbs },
10954 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10955 .dac_nids = alc262_dac_nids,
10957 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10958 .channel_mode = alc262_modes,
10959 .input_mux = &alc262_HP_capture_source,
10960 .unsol_event = alc262_hp_bpc_unsol_event,
10961 .init_hook = alc262_hp_bpc_automute,
10963 [ALC262_HP_BPC_D7000_WF] = {
10964 .mixers = { alc262_HP_BPC_WildWest_mixer },
10965 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
10966 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10967 .dac_nids = alc262_dac_nids,
10969 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10970 .channel_mode = alc262_modes,
10971 .input_mux = &alc262_HP_D7000_capture_source,
10972 .unsol_event = alc262_hp_wildwest_unsol_event,
10973 .init_hook = alc262_hp_wildwest_automute,
10975 [ALC262_HP_BPC_D7000_WL] = {
10976 .mixers = { alc262_HP_BPC_WildWest_mixer,
10977 alc262_HP_BPC_WildWest_option_mixer },
10978 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
10979 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10980 .dac_nids = alc262_dac_nids,
10982 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10983 .channel_mode = alc262_modes,
10984 .input_mux = &alc262_HP_D7000_capture_source,
10985 .unsol_event = alc262_hp_wildwest_unsol_event,
10986 .init_hook = alc262_hp_wildwest_automute,
10988 [ALC262_HP_TC_T5735] = {
10989 .mixers = { alc262_hp_t5735_mixer },
10990 .init_verbs = { alc262_init_verbs, alc262_hp_t5735_verbs },
10991 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10992 .dac_nids = alc262_dac_nids,
10994 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10995 .channel_mode = alc262_modes,
10996 .input_mux = &alc262_capture_source,
10997 .unsol_event = alc262_hp_t5735_unsol_event,
10998 .init_hook = alc262_hp_t5735_init_hook,
11000 [ALC262_HP_RP5700] = {
11001 .mixers = { alc262_hp_rp5700_mixer },
11002 .init_verbs = { alc262_init_verbs, alc262_hp_rp5700_verbs },
11003 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11004 .dac_nids = alc262_dac_nids,
11005 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11006 .channel_mode = alc262_modes,
11007 .input_mux = &alc262_hp_rp5700_capture_source,
11009 [ALC262_BENQ_ED8] = {
11010 .mixers = { alc262_base_mixer },
11011 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
11012 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11013 .dac_nids = alc262_dac_nids,
11015 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11016 .channel_mode = alc262_modes,
11017 .input_mux = &alc262_capture_source,
11019 [ALC262_SONY_ASSAMD] = {
11020 .mixers = { alc262_sony_mixer },
11021 .init_verbs = { alc262_init_verbs, alc262_sony_unsol_verbs},
11022 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11023 .dac_nids = alc262_dac_nids,
11025 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11026 .channel_mode = alc262_modes,
11027 .input_mux = &alc262_capture_source,
11028 .unsol_event = alc262_hippo_unsol_event,
11029 .init_hook = alc262_hippo_automute,
11031 [ALC262_BENQ_T31] = {
11032 .mixers = { alc262_benq_t31_mixer },
11033 .init_verbs = { alc262_init_verbs, alc262_benq_t31_EAPD_verbs, alc262_hippo_unsol_verbs },
11034 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11035 .dac_nids = alc262_dac_nids,
11037 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11038 .channel_mode = alc262_modes,
11039 .input_mux = &alc262_capture_source,
11040 .unsol_event = alc262_hippo_unsol_event,
11041 .init_hook = alc262_hippo_automute,
11044 .mixers = { alc262_ultra_mixer },
11045 .cap_mixer = alc262_ultra_capture_mixer,
11046 .init_verbs = { alc262_ultra_verbs },
11047 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11048 .dac_nids = alc262_dac_nids,
11049 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11050 .channel_mode = alc262_modes,
11051 .input_mux = &alc262_ultra_capture_source,
11052 .adc_nids = alc262_adc_nids, /* ADC0 */
11053 .capsrc_nids = alc262_capsrc_nids,
11054 .num_adc_nids = 1, /* single ADC */
11055 .unsol_event = alc262_ultra_unsol_event,
11056 .init_hook = alc262_ultra_automute,
11058 [ALC262_LENOVO_3000] = {
11059 .mixers = { alc262_lenovo_3000_mixer },
11060 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
11061 alc262_lenovo_3000_unsol_verbs },
11062 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11063 .dac_nids = alc262_dac_nids,
11065 .dig_out_nid = ALC262_DIGOUT_NID,
11066 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11067 .channel_mode = alc262_modes,
11068 .input_mux = &alc262_fujitsu_capture_source,
11069 .unsol_event = alc262_lenovo_3000_unsol_event,
11072 .mixers = { alc262_nec_mixer },
11073 .init_verbs = { alc262_nec_verbs },
11074 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11075 .dac_nids = alc262_dac_nids,
11077 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11078 .channel_mode = alc262_modes,
11079 .input_mux = &alc262_capture_source,
11081 [ALC262_TOSHIBA_S06] = {
11082 .mixers = { alc262_toshiba_s06_mixer },
11083 .init_verbs = { alc262_init_verbs, alc262_toshiba_s06_verbs,
11084 alc262_eapd_verbs },
11085 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11086 .capsrc_nids = alc262_dmic_capsrc_nids,
11087 .dac_nids = alc262_dac_nids,
11088 .adc_nids = alc262_dmic_adc_nids, /* ADC0 */
11089 .dig_out_nid = ALC262_DIGOUT_NID,
11090 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11091 .channel_mode = alc262_modes,
11092 .input_mux = &alc262_dmic_capture_source,
11093 .unsol_event = alc262_toshiba_s06_unsol_event,
11094 .init_hook = alc262_toshiba_s06_init_hook,
11096 [ALC262_TOSHIBA_RX1] = {
11097 .mixers = { alc262_toshiba_rx1_mixer },
11098 .init_verbs = { alc262_init_verbs, alc262_toshiba_rx1_unsol_verbs },
11099 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11100 .dac_nids = alc262_dac_nids,
11102 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11103 .channel_mode = alc262_modes,
11104 .input_mux = &alc262_capture_source,
11105 .unsol_event = alc262_hippo_unsol_event,
11106 .init_hook = alc262_hippo_automute,
11109 .mixers = { alc262_tyan_mixer },
11110 .init_verbs = { alc262_init_verbs, alc262_tyan_verbs},
11111 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11112 .dac_nids = alc262_dac_nids,
11114 .dig_out_nid = ALC262_DIGOUT_NID,
11115 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11116 .channel_mode = alc262_modes,
11117 .input_mux = &alc262_capture_source,
11118 .unsol_event = alc262_tyan_unsol_event,
11119 .init_hook = alc262_tyan_automute,
11123 static int patch_alc262(struct hda_codec *codec)
11125 struct alc_spec *spec;
11129 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
11133 codec->spec = spec;
11135 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
11140 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
11141 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
11142 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
11143 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
11147 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
11149 board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST,
11153 if (board_config < 0) {
11154 printk(KERN_INFO "hda_codec: Unknown model for ALC262, "
11155 "trying auto-probe from BIOS...\n");
11156 board_config = ALC262_AUTO;
11159 if (board_config == ALC262_AUTO) {
11160 /* automatic parse from the BIOS config */
11161 err = alc262_parse_auto_config(codec);
11167 "hda_codec: Cannot set up configuration "
11168 "from BIOS. Using base mode...\n");
11169 board_config = ALC262_BASIC;
11173 if (!spec->no_analog) {
11174 err = snd_hda_attach_beep_device(codec, 0x1);
11181 if (board_config != ALC262_AUTO)
11182 setup_preset(spec, &alc262_presets[board_config]);
11184 spec->stream_name_analog = "ALC262 Analog";
11185 spec->stream_analog_playback = &alc262_pcm_analog_playback;
11186 spec->stream_analog_capture = &alc262_pcm_analog_capture;
11188 spec->stream_name_digital = "ALC262 Digital";
11189 spec->stream_digital_playback = &alc262_pcm_digital_playback;
11190 spec->stream_digital_capture = &alc262_pcm_digital_capture;
11192 spec->capture_style = CAPT_MIX;
11193 if (!spec->adc_nids && spec->input_mux) {
11194 /* check whether NID 0x07 is valid */
11195 unsigned int wcap = get_wcaps(codec, 0x07);
11198 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
11199 if (wcap != AC_WID_AUD_IN) {
11200 spec->adc_nids = alc262_adc_nids_alt;
11201 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids_alt);
11202 spec->capsrc_nids = alc262_capsrc_nids_alt;
11204 spec->adc_nids = alc262_adc_nids;
11205 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids);
11206 spec->capsrc_nids = alc262_capsrc_nids;
11209 if (!spec->cap_mixer && !spec->no_analog)
11210 set_capture_mixer(spec);
11211 if (!spec->no_analog)
11212 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
11214 spec->vmaster_nid = 0x0c;
11216 codec->patch_ops = alc_patch_ops;
11217 if (board_config == ALC262_AUTO)
11218 spec->init_hook = alc262_auto_init;
11219 #ifdef CONFIG_SND_HDA_POWER_SAVE
11220 if (!spec->loopback.amplist)
11221 spec->loopback.amplist = alc262_loopbacks;
11223 codec->proc_widget_hook = print_realtek_coef;
11229 * ALC268 channel source setting (2 channel)
11231 #define ALC268_DIGOUT_NID ALC880_DIGOUT_NID
11232 #define alc268_modes alc260_modes
11234 static hda_nid_t alc268_dac_nids[2] = {
11239 static hda_nid_t alc268_adc_nids[2] = {
11244 static hda_nid_t alc268_adc_nids_alt[1] = {
11249 static hda_nid_t alc268_capsrc_nids[2] = { 0x23, 0x24 };
11251 static struct snd_kcontrol_new alc268_base_mixer[] = {
11252 /* output mixer control */
11253 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
11254 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11255 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
11256 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11257 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11258 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
11259 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
11263 /* bind Beep switches of both NID 0x0f and 0x10 */
11264 static struct hda_bind_ctls alc268_bind_beep_sw = {
11265 .ops = &snd_hda_bind_sw,
11267 HDA_COMPOSE_AMP_VAL(0x0f, 3, 1, HDA_INPUT),
11268 HDA_COMPOSE_AMP_VAL(0x10, 3, 1, HDA_INPUT),
11273 static struct snd_kcontrol_new alc268_beep_mixer[] = {
11274 HDA_CODEC_VOLUME("Beep Playback Volume", 0x1d, 0x0, HDA_INPUT),
11275 HDA_BIND_SW("Beep Playback Switch", &alc268_bind_beep_sw),
11279 static struct hda_verb alc268_eapd_verbs[] = {
11280 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
11281 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
11285 /* Toshiba specific */
11286 #define alc268_toshiba_automute alc262_hippo_automute
11288 static struct hda_verb alc268_toshiba_verbs[] = {
11289 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11293 static struct hda_input_mux alc268_acer_lc_capture_source = {
11301 /* Acer specific */
11302 /* bind volumes of both NID 0x02 and 0x03 */
11303 static struct hda_bind_ctls alc268_acer_bind_master_vol = {
11304 .ops = &snd_hda_bind_vol,
11306 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
11307 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
11312 /* mute/unmute internal speaker according to the hp jack and mute state */
11313 static void alc268_acer_automute(struct hda_codec *codec, int force)
11315 struct alc_spec *spec = codec->spec;
11318 if (force || !spec->sense_updated) {
11319 unsigned int present;
11320 present = snd_hda_codec_read(codec, 0x14, 0,
11321 AC_VERB_GET_PIN_SENSE, 0);
11322 spec->jack_present = (present & 0x80000000) != 0;
11323 spec->sense_updated = 1;
11325 if (spec->jack_present)
11326 mute = HDA_AMP_MUTE; /* mute internal speaker */
11327 else /* unmute internal speaker if necessary */
11328 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
11329 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
11330 HDA_AMP_MUTE, mute);
11334 /* bind hp and internal speaker mute (with plug check) */
11335 static int alc268_acer_master_sw_put(struct snd_kcontrol *kcontrol,
11336 struct snd_ctl_elem_value *ucontrol)
11338 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
11339 long *valp = ucontrol->value.integer.value;
11342 change = snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
11344 valp[0] ? 0 : HDA_AMP_MUTE);
11345 change |= snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
11347 valp[1] ? 0 : HDA_AMP_MUTE);
11349 alc268_acer_automute(codec, 0);
11353 static struct snd_kcontrol_new alc268_acer_aspire_one_mixer[] = {
11354 /* output mixer control */
11355 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
11357 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11358 .name = "Master Playback Switch",
11359 .info = snd_hda_mixer_amp_switch_info,
11360 .get = snd_hda_mixer_amp_switch_get,
11361 .put = alc268_acer_master_sw_put,
11362 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
11364 HDA_CODEC_VOLUME("Mic Boost Capture Volume", 0x18, 0, HDA_INPUT),
11368 static struct snd_kcontrol_new alc268_acer_mixer[] = {
11369 /* output mixer control */
11370 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
11372 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11373 .name = "Master Playback Switch",
11374 .info = snd_hda_mixer_amp_switch_info,
11375 .get = snd_hda_mixer_amp_switch_get,
11376 .put = alc268_acer_master_sw_put,
11377 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
11379 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11380 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
11381 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
11385 static struct snd_kcontrol_new alc268_acer_dmic_mixer[] = {
11386 /* output mixer control */
11387 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
11389 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11390 .name = "Master Playback Switch",
11391 .info = snd_hda_mixer_amp_switch_info,
11392 .get = snd_hda_mixer_amp_switch_get,
11393 .put = alc268_acer_master_sw_put,
11394 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
11396 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11397 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
11401 static struct hda_verb alc268_acer_aspire_one_verbs[] = {
11402 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11403 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11404 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11405 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
11406 {0x23, AC_VERB_SET_CONNECT_SEL, 0x06},
11407 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, 0xa017},
11411 static struct hda_verb alc268_acer_verbs[] = {
11412 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* internal dmic? */
11413 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11414 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11415 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11416 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
11417 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
11418 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11422 /* unsolicited event for HP jack sensing */
11423 static void alc268_toshiba_unsol_event(struct hda_codec *codec,
11426 if ((res >> 26) != ALC880_HP_EVENT)
11428 alc268_toshiba_automute(codec);
11431 static void alc268_acer_unsol_event(struct hda_codec *codec,
11434 if ((res >> 26) != ALC880_HP_EVENT)
11436 alc268_acer_automute(codec, 1);
11439 static void alc268_acer_init_hook(struct hda_codec *codec)
11441 alc268_acer_automute(codec, 1);
11444 /* toggle speaker-output according to the hp-jack state */
11445 static void alc268_aspire_one_speaker_automute(struct hda_codec *codec)
11447 unsigned int present;
11448 unsigned char bits;
11450 present = snd_hda_codec_read(codec, 0x15, 0,
11451 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
11452 bits = present ? AMP_IN_MUTE(0) : 0;
11453 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 0,
11454 AMP_IN_MUTE(0), bits);
11455 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 1,
11456 AMP_IN_MUTE(0), bits);
11460 static void alc268_acer_mic_automute(struct hda_codec *codec)
11462 unsigned int present;
11464 present = snd_hda_codec_read(codec, 0x18, 0,
11465 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
11466 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_CONNECT_SEL,
11467 present ? 0x0 : 0x6);
11470 static void alc268_acer_lc_unsol_event(struct hda_codec *codec,
11473 if ((res >> 26) == ALC880_HP_EVENT)
11474 alc268_aspire_one_speaker_automute(codec);
11475 if ((res >> 26) == ALC880_MIC_EVENT)
11476 alc268_acer_mic_automute(codec);
11479 static void alc268_acer_lc_init_hook(struct hda_codec *codec)
11481 alc268_aspire_one_speaker_automute(codec);
11482 alc268_acer_mic_automute(codec);
11485 static struct snd_kcontrol_new alc268_dell_mixer[] = {
11486 /* output mixer control */
11487 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
11488 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11489 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
11490 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11491 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11492 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
11496 static struct hda_verb alc268_dell_verbs[] = {
11497 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11498 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11499 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11503 /* mute/unmute internal speaker according to the hp jack and mute state */
11504 static void alc268_dell_automute(struct hda_codec *codec)
11506 unsigned int present;
11509 present = snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_PIN_SENSE, 0);
11510 if (present & 0x80000000)
11511 mute = HDA_AMP_MUTE;
11513 mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0);
11514 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
11515 HDA_AMP_MUTE, mute);
11518 static void alc268_dell_unsol_event(struct hda_codec *codec,
11521 if ((res >> 26) != ALC880_HP_EVENT)
11523 alc268_dell_automute(codec);
11526 #define alc268_dell_init_hook alc268_dell_automute
11528 static struct snd_kcontrol_new alc267_quanta_il1_mixer[] = {
11529 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x2, 0x0, HDA_OUTPUT),
11530 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11531 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
11532 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11533 HDA_CODEC_VOLUME("Mic Capture Volume", 0x23, 0x0, HDA_OUTPUT),
11534 HDA_BIND_MUTE("Mic Capture Switch", 0x23, 2, HDA_OUTPUT),
11535 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
11536 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
11540 static struct hda_verb alc267_quanta_il1_verbs[] = {
11541 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11542 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
11546 static void alc267_quanta_il1_hp_automute(struct hda_codec *codec)
11548 unsigned int present;
11550 present = snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_PIN_SENSE, 0)
11551 & AC_PINSENSE_PRESENCE;
11552 snd_hda_codec_write(codec, 0x14, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
11553 present ? 0 : PIN_OUT);
11556 static void alc267_quanta_il1_mic_automute(struct hda_codec *codec)
11558 unsigned int present;
11560 present = snd_hda_codec_read(codec, 0x18, 0,
11561 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
11562 snd_hda_codec_write(codec, 0x23, 0,
11563 AC_VERB_SET_CONNECT_SEL,
11564 present ? 0x00 : 0x01);
11567 static void alc267_quanta_il1_automute(struct hda_codec *codec)
11569 alc267_quanta_il1_hp_automute(codec);
11570 alc267_quanta_il1_mic_automute(codec);
11573 static void alc267_quanta_il1_unsol_event(struct hda_codec *codec,
11576 switch (res >> 26) {
11577 case ALC880_HP_EVENT:
11578 alc267_quanta_il1_hp_automute(codec);
11580 case ALC880_MIC_EVENT:
11581 alc267_quanta_il1_mic_automute(codec);
11587 * generic initialization of ADC, input mixers and output mixers
11589 static struct hda_verb alc268_base_init_verbs[] = {
11590 /* Unmute DAC0-1 and set vol = 0 */
11591 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11592 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11595 * Set up output mixers (0x0c - 0x0e)
11597 /* set vol=0 to output mixers */
11598 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11599 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
11601 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11602 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11604 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
11605 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
11606 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
11607 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11608 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11609 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11610 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11611 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11613 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11614 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11615 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11616 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11617 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11619 /* set PCBEEP vol = 0, mute connections */
11620 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11621 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11622 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11624 /* Unmute Selector 23h,24h and set the default input to mic-in */
11626 {0x23, AC_VERB_SET_CONNECT_SEL, 0x00},
11627 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11628 {0x24, AC_VERB_SET_CONNECT_SEL, 0x00},
11629 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11635 * generic initialization of ADC, input mixers and output mixers
11637 static struct hda_verb alc268_volume_init_verbs[] = {
11638 /* set output DAC */
11639 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11640 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11642 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11643 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11644 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11645 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11646 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11648 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11649 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11650 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11652 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11653 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11655 /* set PCBEEP vol = 0, mute connections */
11656 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11657 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11658 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11663 static struct snd_kcontrol_new alc268_capture_alt_mixer[] = {
11664 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
11665 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
11667 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11668 /* The multiple "Capture Source" controls confuse alsamixer
11669 * So call somewhat different..
11671 /* .name = "Capture Source", */
11672 .name = "Input Source",
11674 .info = alc_mux_enum_info,
11675 .get = alc_mux_enum_get,
11676 .put = alc_mux_enum_put,
11681 static struct snd_kcontrol_new alc268_capture_mixer[] = {
11682 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
11683 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
11684 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x24, 0x0, HDA_OUTPUT),
11685 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x24, 0x0, HDA_OUTPUT),
11687 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11688 /* The multiple "Capture Source" controls confuse alsamixer
11689 * So call somewhat different..
11691 /* .name = "Capture Source", */
11692 .name = "Input Source",
11694 .info = alc_mux_enum_info,
11695 .get = alc_mux_enum_get,
11696 .put = alc_mux_enum_put,
11701 static struct hda_input_mux alc268_capture_source = {
11705 { "Front Mic", 0x1 },
11711 static struct hda_input_mux alc268_acer_capture_source = {
11715 { "Internal Mic", 0x1 },
11720 static struct hda_input_mux alc268_acer_dmic_capture_source = {
11724 { "Internal Mic", 0x6 },
11729 #ifdef CONFIG_SND_DEBUG
11730 static struct snd_kcontrol_new alc268_test_mixer[] = {
11731 /* Volume widgets */
11732 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x02, 0x0, HDA_OUTPUT),
11733 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x03, 0x0, HDA_OUTPUT),
11734 HDA_BIND_MUTE_MONO("Mono sum Playback Switch", 0x0e, 1, 2, HDA_INPUT),
11735 HDA_BIND_MUTE("LINE-OUT sum Playback Switch", 0x0f, 2, HDA_INPUT),
11736 HDA_BIND_MUTE("HP-OUT sum Playback Switch", 0x10, 2, HDA_INPUT),
11737 HDA_BIND_MUTE("LINE-OUT Playback Switch", 0x14, 2, HDA_OUTPUT),
11738 HDA_BIND_MUTE("HP-OUT Playback Switch", 0x15, 2, HDA_OUTPUT),
11739 HDA_BIND_MUTE("Mono Playback Switch", 0x16, 2, HDA_OUTPUT),
11740 HDA_CODEC_VOLUME("MIC1 Capture Volume", 0x18, 0x0, HDA_INPUT),
11741 HDA_BIND_MUTE("MIC1 Capture Switch", 0x18, 2, HDA_OUTPUT),
11742 HDA_CODEC_VOLUME("MIC2 Capture Volume", 0x19, 0x0, HDA_INPUT),
11743 HDA_CODEC_VOLUME("LINE1 Capture Volume", 0x1a, 0x0, HDA_INPUT),
11744 HDA_BIND_MUTE("LINE1 Capture Switch", 0x1a, 2, HDA_OUTPUT),
11745 /* The below appears problematic on some hardwares */
11746 /*HDA_CODEC_VOLUME("PCBEEP Playback Volume", 0x1d, 0x0, HDA_INPUT),*/
11747 HDA_CODEC_VOLUME("PCM-IN1 Capture Volume", 0x23, 0x0, HDA_OUTPUT),
11748 HDA_BIND_MUTE("PCM-IN1 Capture Switch", 0x23, 2, HDA_OUTPUT),
11749 HDA_CODEC_VOLUME("PCM-IN2 Capture Volume", 0x24, 0x0, HDA_OUTPUT),
11750 HDA_BIND_MUTE("PCM-IN2 Capture Switch", 0x24, 2, HDA_OUTPUT),
11752 /* Modes for retasking pin widgets */
11753 ALC_PIN_MODE("LINE-OUT pin mode", 0x14, ALC_PIN_DIR_INOUT),
11754 ALC_PIN_MODE("HP-OUT pin mode", 0x15, ALC_PIN_DIR_INOUT),
11755 ALC_PIN_MODE("MIC1 pin mode", 0x18, ALC_PIN_DIR_INOUT),
11756 ALC_PIN_MODE("LINE1 pin mode", 0x1a, ALC_PIN_DIR_INOUT),
11758 /* Controls for GPIO pins, assuming they are configured as outputs */
11759 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
11760 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
11761 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
11762 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
11764 /* Switches to allow the digital SPDIF output pin to be enabled.
11765 * The ALC268 does not have an SPDIF input.
11767 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x06, 0x01),
11769 /* A switch allowing EAPD to be enabled. Some laptops seem to use
11770 * this output to turn on an external amplifier.
11772 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
11773 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
11779 /* create input playback/capture controls for the given pin */
11780 static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
11781 const char *ctlname, int idx)
11786 sprintf(name, "%s Playback Volume", ctlname);
11788 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
11789 HDA_COMPOSE_AMP_VAL(0x02, 3, idx,
11793 } else if (nid == 0x15) {
11794 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
11795 HDA_COMPOSE_AMP_VAL(0x03, 3, idx,
11801 sprintf(name, "%s Playback Switch", ctlname);
11802 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
11803 HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
11809 /* add playback controls from the parsed DAC table */
11810 static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec,
11811 const struct auto_pin_cfg *cfg)
11816 spec->multiout.num_dacs = 2; /* only use one dac */
11817 spec->multiout.dac_nids = spec->private_dac_nids;
11818 spec->multiout.dac_nids[0] = 2;
11819 spec->multiout.dac_nids[1] = 3;
11821 nid = cfg->line_out_pins[0];
11823 alc268_new_analog_output(spec, nid, "Front", 0);
11825 nid = cfg->speaker_pins[0];
11827 err = add_control(spec, ALC_CTL_WIDGET_VOL,
11828 "Speaker Playback Volume",
11829 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
11833 nid = cfg->hp_pins[0];
11835 alc268_new_analog_output(spec, nid, "Headphone", 0);
11837 nid = cfg->line_out_pins[1] | cfg->line_out_pins[2];
11839 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
11840 "Mono Playback Switch",
11841 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_INPUT));
11848 /* create playback/capture controls for input pins */
11849 static int alc268_auto_create_analog_input_ctls(struct alc_spec *spec,
11850 const struct auto_pin_cfg *cfg)
11852 struct hda_input_mux *imux = &spec->private_imux[0];
11855 for (i = 0; i < AUTO_PIN_LAST; i++) {
11856 switch(cfg->input_pins[i]) {
11858 idx1 = 0; /* Mic 1 */
11861 idx1 = 1; /* Mic 2 */
11864 idx1 = 2; /* Line In */
11871 idx1 = 6; /* digital mics */
11876 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
11877 imux->items[imux->num_items].index = idx1;
11883 static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec)
11885 struct alc_spec *spec = codec->spec;
11886 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
11887 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
11888 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
11889 unsigned int dac_vol1, dac_vol2;
11892 snd_hda_codec_write(codec, speaker_nid, 0,
11893 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
11894 snd_hda_codec_write(codec, 0x0f, 0,
11895 AC_VERB_SET_AMP_GAIN_MUTE,
11897 snd_hda_codec_write(codec, 0x10, 0,
11898 AC_VERB_SET_AMP_GAIN_MUTE,
11901 snd_hda_codec_write(codec, 0x0f, 0,
11902 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
11903 snd_hda_codec_write(codec, 0x10, 0,
11904 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
11907 dac_vol1 = dac_vol2 = 0xb000 | 0x40; /* set max volume */
11908 if (line_nid == 0x14)
11909 dac_vol2 = AMP_OUT_ZERO;
11910 else if (line_nid == 0x15)
11911 dac_vol1 = AMP_OUT_ZERO;
11912 if (hp_nid == 0x14)
11913 dac_vol2 = AMP_OUT_ZERO;
11914 else if (hp_nid == 0x15)
11915 dac_vol1 = AMP_OUT_ZERO;
11916 if (line_nid != 0x16 || hp_nid != 0x16 ||
11917 spec->autocfg.line_out_pins[1] != 0x16 ||
11918 spec->autocfg.line_out_pins[2] != 0x16)
11919 dac_vol1 = dac_vol2 = AMP_OUT_ZERO;
11921 snd_hda_codec_write(codec, 0x02, 0,
11922 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol1);
11923 snd_hda_codec_write(codec, 0x03, 0,
11924 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol2);
11927 /* pcm configuration: identiacal with ALC880 */
11928 #define alc268_pcm_analog_playback alc880_pcm_analog_playback
11929 #define alc268_pcm_analog_capture alc880_pcm_analog_capture
11930 #define alc268_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
11931 #define alc268_pcm_digital_playback alc880_pcm_digital_playback
11934 * BIOS auto configuration
11936 static int alc268_parse_auto_config(struct hda_codec *codec)
11938 struct alc_spec *spec = codec->spec;
11940 static hda_nid_t alc268_ignore[] = { 0 };
11942 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
11946 if (!spec->autocfg.line_outs) {
11947 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
11948 spec->multiout.max_channels = 2;
11949 spec->no_analog = 1;
11952 return 0; /* can't find valid BIOS pin config */
11954 err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg);
11957 err = alc268_auto_create_analog_input_ctls(spec, &spec->autocfg);
11961 spec->multiout.max_channels = 2;
11964 /* digital only support output */
11965 if (spec->autocfg.dig_outs) {
11966 spec->multiout.dig_out_nid = ALC268_DIGOUT_NID;
11967 spec->dig_out_type = spec->autocfg.dig_out_type[0];
11969 if (spec->kctls.list)
11970 add_mixer(spec, spec->kctls.list);
11972 if (!spec->no_analog && spec->autocfg.speaker_pins[0] != 0x1d)
11973 add_mixer(spec, alc268_beep_mixer);
11975 add_verb(spec, alc268_volume_init_verbs);
11976 spec->num_mux_defs = 1;
11977 spec->input_mux = &spec->private_imux[0];
11979 err = alc_auto_add_mic_boost(codec);
11986 #define alc268_auto_init_multi_out alc882_auto_init_multi_out
11987 #define alc268_auto_init_hp_out alc882_auto_init_hp_out
11988 #define alc268_auto_init_analog_input alc882_auto_init_analog_input
11990 /* init callback for auto-configuration model -- overriding the default init */
11991 static void alc268_auto_init(struct hda_codec *codec)
11993 struct alc_spec *spec = codec->spec;
11994 alc268_auto_init_multi_out(codec);
11995 alc268_auto_init_hp_out(codec);
11996 alc268_auto_init_mono_speaker_out(codec);
11997 alc268_auto_init_analog_input(codec);
11998 if (spec->unsol_event)
11999 alc_inithook(codec);
12003 * configuration and preset
12005 static const char *alc268_models[ALC268_MODEL_LAST] = {
12006 [ALC267_QUANTA_IL1] = "quanta-il1",
12007 [ALC268_3ST] = "3stack",
12008 [ALC268_TOSHIBA] = "toshiba",
12009 [ALC268_ACER] = "acer",
12010 [ALC268_ACER_DMIC] = "acer-dmic",
12011 [ALC268_ACER_ASPIRE_ONE] = "acer-aspire",
12012 [ALC268_DELL] = "dell",
12013 [ALC268_ZEPTO] = "zepto",
12014 #ifdef CONFIG_SND_DEBUG
12015 [ALC268_TEST] = "test",
12017 [ALC268_AUTO] = "auto",
12020 static struct snd_pci_quirk alc268_cfg_tbl[] = {
12021 SND_PCI_QUIRK(0x1025, 0x011e, "Acer Aspire 5720z", ALC268_ACER),
12022 SND_PCI_QUIRK(0x1025, 0x0126, "Acer", ALC268_ACER),
12023 SND_PCI_QUIRK(0x1025, 0x012e, "Acer Aspire 5310", ALC268_ACER),
12024 SND_PCI_QUIRK(0x1025, 0x0130, "Acer Extensa 5210", ALC268_ACER),
12025 SND_PCI_QUIRK(0x1025, 0x0136, "Acer Aspire 5315", ALC268_ACER),
12026 SND_PCI_QUIRK(0x1025, 0x015b, "Acer Aspire One",
12027 ALC268_ACER_ASPIRE_ONE),
12028 SND_PCI_QUIRK(0x1028, 0x0253, "Dell OEM", ALC268_DELL),
12029 SND_PCI_QUIRK(0x1028, 0x02b0, "Dell Inspiron Mini9", ALC268_DELL),
12030 SND_PCI_QUIRK(0x103c, 0x30cc, "TOSHIBA", ALC268_TOSHIBA),
12031 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST),
12032 SND_PCI_QUIRK(0x1179, 0xff10, "TOSHIBA A205", ALC268_TOSHIBA),
12033 SND_PCI_QUIRK(0x1179, 0xff50, "TOSHIBA A305", ALC268_TOSHIBA),
12034 SND_PCI_QUIRK(0x1179, 0xff64, "TOSHIBA L305", ALC268_TOSHIBA),
12035 SND_PCI_QUIRK(0x14c0, 0x0025, "COMPAL IFL90/JFL-92", ALC268_TOSHIBA),
12036 SND_PCI_QUIRK(0x152d, 0x0763, "Diverse (CPR2000)", ALC268_ACER),
12037 SND_PCI_QUIRK(0x152d, 0x0771, "Quanta IL1", ALC267_QUANTA_IL1),
12038 SND_PCI_QUIRK(0x1170, 0x0040, "ZEPTO", ALC268_ZEPTO),
12042 static struct alc_config_preset alc268_presets[] = {
12043 [ALC267_QUANTA_IL1] = {
12044 .mixers = { alc267_quanta_il1_mixer, alc268_beep_mixer },
12045 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12046 alc267_quanta_il1_verbs },
12047 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12048 .dac_nids = alc268_dac_nids,
12049 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12050 .adc_nids = alc268_adc_nids_alt,
12052 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12053 .channel_mode = alc268_modes,
12054 .input_mux = &alc268_capture_source,
12055 .unsol_event = alc267_quanta_il1_unsol_event,
12056 .init_hook = alc267_quanta_il1_automute,
12059 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
12060 alc268_beep_mixer },
12061 .init_verbs = { alc268_base_init_verbs },
12062 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12063 .dac_nids = alc268_dac_nids,
12064 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12065 .adc_nids = alc268_adc_nids_alt,
12066 .capsrc_nids = alc268_capsrc_nids,
12068 .dig_out_nid = ALC268_DIGOUT_NID,
12069 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12070 .channel_mode = alc268_modes,
12071 .input_mux = &alc268_capture_source,
12073 [ALC268_TOSHIBA] = {
12074 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
12075 alc268_beep_mixer },
12076 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12077 alc268_toshiba_verbs },
12078 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12079 .dac_nids = alc268_dac_nids,
12080 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12081 .adc_nids = alc268_adc_nids_alt,
12082 .capsrc_nids = alc268_capsrc_nids,
12084 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12085 .channel_mode = alc268_modes,
12086 .input_mux = &alc268_capture_source,
12087 .unsol_event = alc268_toshiba_unsol_event,
12088 .init_hook = alc268_toshiba_automute,
12091 .mixers = { alc268_acer_mixer, alc268_capture_alt_mixer,
12092 alc268_beep_mixer },
12093 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12094 alc268_acer_verbs },
12095 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12096 .dac_nids = alc268_dac_nids,
12097 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12098 .adc_nids = alc268_adc_nids_alt,
12099 .capsrc_nids = alc268_capsrc_nids,
12101 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12102 .channel_mode = alc268_modes,
12103 .input_mux = &alc268_acer_capture_source,
12104 .unsol_event = alc268_acer_unsol_event,
12105 .init_hook = alc268_acer_init_hook,
12107 [ALC268_ACER_DMIC] = {
12108 .mixers = { alc268_acer_dmic_mixer, alc268_capture_alt_mixer,
12109 alc268_beep_mixer },
12110 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12111 alc268_acer_verbs },
12112 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12113 .dac_nids = alc268_dac_nids,
12114 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12115 .adc_nids = alc268_adc_nids_alt,
12116 .capsrc_nids = alc268_capsrc_nids,
12118 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12119 .channel_mode = alc268_modes,
12120 .input_mux = &alc268_acer_dmic_capture_source,
12121 .unsol_event = alc268_acer_unsol_event,
12122 .init_hook = alc268_acer_init_hook,
12124 [ALC268_ACER_ASPIRE_ONE] = {
12125 .mixers = { alc268_acer_aspire_one_mixer,
12127 alc268_capture_alt_mixer },
12128 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12129 alc268_acer_aspire_one_verbs },
12130 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12131 .dac_nids = alc268_dac_nids,
12132 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12133 .adc_nids = alc268_adc_nids_alt,
12134 .capsrc_nids = alc268_capsrc_nids,
12136 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12137 .channel_mode = alc268_modes,
12138 .input_mux = &alc268_acer_lc_capture_source,
12139 .unsol_event = alc268_acer_lc_unsol_event,
12140 .init_hook = alc268_acer_lc_init_hook,
12143 .mixers = { alc268_dell_mixer, alc268_beep_mixer },
12144 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12145 alc268_dell_verbs },
12146 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12147 .dac_nids = alc268_dac_nids,
12149 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12150 .channel_mode = alc268_modes,
12151 .unsol_event = alc268_dell_unsol_event,
12152 .init_hook = alc268_dell_init_hook,
12153 .input_mux = &alc268_capture_source,
12156 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
12157 alc268_beep_mixer },
12158 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12159 alc268_toshiba_verbs },
12160 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12161 .dac_nids = alc268_dac_nids,
12162 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12163 .adc_nids = alc268_adc_nids_alt,
12164 .capsrc_nids = alc268_capsrc_nids,
12166 .dig_out_nid = ALC268_DIGOUT_NID,
12167 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12168 .channel_mode = alc268_modes,
12169 .input_mux = &alc268_capture_source,
12170 .unsol_event = alc268_toshiba_unsol_event,
12171 .init_hook = alc268_toshiba_automute
12173 #ifdef CONFIG_SND_DEBUG
12175 .mixers = { alc268_test_mixer, alc268_capture_mixer },
12176 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12177 alc268_volume_init_verbs },
12178 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12179 .dac_nids = alc268_dac_nids,
12180 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12181 .adc_nids = alc268_adc_nids_alt,
12182 .capsrc_nids = alc268_capsrc_nids,
12184 .dig_out_nid = ALC268_DIGOUT_NID,
12185 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12186 .channel_mode = alc268_modes,
12187 .input_mux = &alc268_capture_source,
12192 static int patch_alc268(struct hda_codec *codec)
12194 struct alc_spec *spec;
12196 int i, has_beep, err;
12198 spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
12202 codec->spec = spec;
12204 board_config = snd_hda_check_board_config(codec, ALC268_MODEL_LAST,
12208 if (board_config < 0 || board_config >= ALC268_MODEL_LAST) {
12209 printk(KERN_INFO "hda_codec: Unknown model for ALC268, "
12210 "trying auto-probe from BIOS...\n");
12211 board_config = ALC268_AUTO;
12214 if (board_config == ALC268_AUTO) {
12215 /* automatic parse from the BIOS config */
12216 err = alc268_parse_auto_config(codec);
12222 "hda_codec: Cannot set up configuration "
12223 "from BIOS. Using base mode...\n");
12224 board_config = ALC268_3ST;
12228 if (board_config != ALC268_AUTO)
12229 setup_preset(spec, &alc268_presets[board_config]);
12231 if (codec->vendor_id == 0x10ec0267) {
12232 spec->stream_name_analog = "ALC267 Analog";
12233 spec->stream_name_digital = "ALC267 Digital";
12235 spec->stream_name_analog = "ALC268 Analog";
12236 spec->stream_name_digital = "ALC268 Digital";
12239 spec->stream_analog_playback = &alc268_pcm_analog_playback;
12240 spec->stream_analog_capture = &alc268_pcm_analog_capture;
12241 spec->stream_analog_alt_capture = &alc268_pcm_analog_alt_capture;
12243 spec->stream_digital_playback = &alc268_pcm_digital_playback;
12246 for (i = 0; i < spec->num_mixers; i++) {
12247 if (spec->mixers[i] == alc268_beep_mixer) {
12254 err = snd_hda_attach_beep_device(codec, 0x1);
12259 if (!query_amp_caps(codec, 0x1d, HDA_INPUT))
12260 /* override the amp caps for beep generator */
12261 snd_hda_override_amp_caps(codec, 0x1d, HDA_INPUT,
12262 (0x0c << AC_AMPCAP_OFFSET_SHIFT) |
12263 (0x0c << AC_AMPCAP_NUM_STEPS_SHIFT) |
12264 (0x07 << AC_AMPCAP_STEP_SIZE_SHIFT) |
12265 (0 << AC_AMPCAP_MUTE_SHIFT));
12268 if (!spec->no_analog && !spec->adc_nids && spec->input_mux) {
12269 /* check whether NID 0x07 is valid */
12270 unsigned int wcap = get_wcaps(codec, 0x07);
12274 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
12275 if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
12276 spec->adc_nids = alc268_adc_nids_alt;
12277 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt);
12278 add_mixer(spec, alc268_capture_alt_mixer);
12280 spec->adc_nids = alc268_adc_nids;
12281 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids);
12282 add_mixer(spec, alc268_capture_mixer);
12284 spec->capsrc_nids = alc268_capsrc_nids;
12285 /* set default input source */
12286 for (i = 0; i < spec->num_adc_nids; i++)
12287 snd_hda_codec_write_cache(codec, alc268_capsrc_nids[i],
12288 0, AC_VERB_SET_CONNECT_SEL,
12289 spec->input_mux->items[0].index);
12292 spec->vmaster_nid = 0x02;
12294 codec->patch_ops = alc_patch_ops;
12295 if (board_config == ALC268_AUTO)
12296 spec->init_hook = alc268_auto_init;
12298 codec->proc_widget_hook = print_realtek_coef;
12304 * ALC269 channel source setting (2 channel)
12306 #define ALC269_DIGOUT_NID ALC880_DIGOUT_NID
12308 #define alc269_dac_nids alc260_dac_nids
12310 static hda_nid_t alc269_adc_nids[1] = {
12315 static hda_nid_t alc269_capsrc_nids[1] = {
12319 /* NOTE: ADC2 (0x07) is connected from a recording *MIXER* (0x24),
12323 static struct hda_input_mux alc269_eeepc_dmic_capture_source = {
12331 static struct hda_input_mux alc269_eeepc_amic_capture_source = {
12339 #define alc269_modes alc260_modes
12340 #define alc269_capture_source alc880_lg_lw_capture_source
12342 static struct snd_kcontrol_new alc269_base_mixer[] = {
12343 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12344 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12345 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
12346 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
12347 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12348 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12349 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12350 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
12351 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
12352 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
12353 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
12354 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
12358 static struct snd_kcontrol_new alc269_quanta_fl1_mixer[] = {
12359 /* output mixer control */
12360 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
12362 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12363 .name = "Master Playback Switch",
12364 .info = snd_hda_mixer_amp_switch_info,
12365 .get = snd_hda_mixer_amp_switch_get,
12366 .put = alc268_acer_master_sw_put,
12367 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
12369 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12370 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12371 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12372 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
12373 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
12374 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
12378 static struct snd_kcontrol_new alc269_lifebook_mixer[] = {
12379 /* output mixer control */
12380 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
12382 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12383 .name = "Master Playback Switch",
12384 .info = snd_hda_mixer_amp_switch_info,
12385 .get = snd_hda_mixer_amp_switch_get,
12386 .put = alc268_acer_master_sw_put,
12387 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
12389 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12390 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12391 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12392 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
12393 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
12394 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
12395 HDA_CODEC_VOLUME("Dock Mic Playback Volume", 0x0b, 0x03, HDA_INPUT),
12396 HDA_CODEC_MUTE("Dock Mic Playback Switch", 0x0b, 0x03, HDA_INPUT),
12397 HDA_CODEC_VOLUME("Dock Mic Boost", 0x1b, 0, HDA_INPUT),
12401 /* bind volumes of both NID 0x0c and 0x0d */
12402 static struct hda_bind_ctls alc269_epc_bind_vol = {
12403 .ops = &snd_hda_bind_vol,
12405 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
12406 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
12411 static struct snd_kcontrol_new alc269_eeepc_mixer[] = {
12412 HDA_CODEC_MUTE("iSpeaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12413 HDA_BIND_VOL("LineOut Playback Volume", &alc269_epc_bind_vol),
12414 HDA_CODEC_MUTE("LineOut Playback Switch", 0x15, 0x0, HDA_OUTPUT),
12418 /* capture mixer elements */
12419 static struct snd_kcontrol_new alc269_epc_capture_mixer[] = {
12420 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
12421 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
12422 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12427 static struct snd_kcontrol_new alc269_fujitsu_mixer[] = {
12428 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12429 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
12430 HDA_BIND_VOL("PCM Playback Volume", &alc269_epc_bind_vol),
12434 static struct hda_verb alc269_quanta_fl1_verbs[] = {
12435 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12436 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12437 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12438 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12439 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12440 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12444 static struct hda_verb alc269_lifebook_verbs[] = {
12445 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12446 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
12447 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12448 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12449 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12450 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12451 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12452 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12453 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12454 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12458 /* toggle speaker-output according to the hp-jack state */
12459 static void alc269_quanta_fl1_speaker_automute(struct hda_codec *codec)
12461 unsigned int present;
12462 unsigned char bits;
12464 present = snd_hda_codec_read(codec, 0x15, 0,
12465 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12466 bits = present ? AMP_IN_MUTE(0) : 0;
12467 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
12468 AMP_IN_MUTE(0), bits);
12469 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
12470 AMP_IN_MUTE(0), bits);
12472 snd_hda_codec_write(codec, 0x20, 0,
12473 AC_VERB_SET_COEF_INDEX, 0x0c);
12474 snd_hda_codec_write(codec, 0x20, 0,
12475 AC_VERB_SET_PROC_COEF, 0x680);
12477 snd_hda_codec_write(codec, 0x20, 0,
12478 AC_VERB_SET_COEF_INDEX, 0x0c);
12479 snd_hda_codec_write(codec, 0x20, 0,
12480 AC_VERB_SET_PROC_COEF, 0x480);
12483 /* toggle speaker-output according to the hp-jacks state */
12484 static void alc269_lifebook_speaker_automute(struct hda_codec *codec)
12486 unsigned int present;
12487 unsigned char bits;
12489 /* Check laptop headphone socket */
12490 present = snd_hda_codec_read(codec, 0x15, 0,
12491 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12493 /* Check port replicator headphone socket */
12494 present |= snd_hda_codec_read(codec, 0x1a, 0,
12495 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12497 bits = present ? AMP_IN_MUTE(0) : 0;
12498 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
12499 AMP_IN_MUTE(0), bits);
12500 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
12501 AMP_IN_MUTE(0), bits);
12503 snd_hda_codec_write(codec, 0x20, 0,
12504 AC_VERB_SET_COEF_INDEX, 0x0c);
12505 snd_hda_codec_write(codec, 0x20, 0,
12506 AC_VERB_SET_PROC_COEF, 0x680);
12508 snd_hda_codec_write(codec, 0x20, 0,
12509 AC_VERB_SET_COEF_INDEX, 0x0c);
12510 snd_hda_codec_write(codec, 0x20, 0,
12511 AC_VERB_SET_PROC_COEF, 0x480);
12514 static void alc269_quanta_fl1_mic_automute(struct hda_codec *codec)
12516 unsigned int present;
12518 present = snd_hda_codec_read(codec, 0x18, 0,
12519 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12520 snd_hda_codec_write(codec, 0x23, 0,
12521 AC_VERB_SET_CONNECT_SEL, present ? 0x0 : 0x1);
12524 static void alc269_lifebook_mic_autoswitch(struct hda_codec *codec)
12526 unsigned int present_laptop;
12527 unsigned int present_dock;
12529 present_laptop = snd_hda_codec_read(codec, 0x18, 0,
12530 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12532 present_dock = snd_hda_codec_read(codec, 0x1b, 0,
12533 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12535 /* Laptop mic port overrides dock mic port, design decision */
12537 snd_hda_codec_write(codec, 0x23, 0,
12538 AC_VERB_SET_CONNECT_SEL, 0x3);
12539 if (present_laptop)
12540 snd_hda_codec_write(codec, 0x23, 0,
12541 AC_VERB_SET_CONNECT_SEL, 0x0);
12542 if (!present_dock && !present_laptop)
12543 snd_hda_codec_write(codec, 0x23, 0,
12544 AC_VERB_SET_CONNECT_SEL, 0x1);
12547 static void alc269_quanta_fl1_unsol_event(struct hda_codec *codec,
12550 if ((res >> 26) == ALC880_HP_EVENT)
12551 alc269_quanta_fl1_speaker_automute(codec);
12552 if ((res >> 26) == ALC880_MIC_EVENT)
12553 alc269_quanta_fl1_mic_automute(codec);
12556 static void alc269_lifebook_unsol_event(struct hda_codec *codec,
12559 if ((res >> 26) == ALC880_HP_EVENT)
12560 alc269_lifebook_speaker_automute(codec);
12561 if ((res >> 26) == ALC880_MIC_EVENT)
12562 alc269_lifebook_mic_autoswitch(codec);
12565 static void alc269_quanta_fl1_init_hook(struct hda_codec *codec)
12567 alc269_quanta_fl1_speaker_automute(codec);
12568 alc269_quanta_fl1_mic_automute(codec);
12571 static void alc269_lifebook_init_hook(struct hda_codec *codec)
12573 alc269_lifebook_speaker_automute(codec);
12574 alc269_lifebook_mic_autoswitch(codec);
12577 static struct hda_verb alc269_eeepc_dmic_init_verbs[] = {
12578 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12579 {0x23, AC_VERB_SET_CONNECT_SEL, 0x05},
12580 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
12581 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))},
12582 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12583 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12584 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
12588 static struct hda_verb alc269_eeepc_amic_init_verbs[] = {
12589 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12590 {0x23, AC_VERB_SET_CONNECT_SEL, 0x01},
12591 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
12592 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x701b | (0x00 << 8))},
12593 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12594 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
12598 /* toggle speaker-output according to the hp-jack state */
12599 static void alc269_speaker_automute(struct hda_codec *codec)
12601 unsigned int present;
12602 unsigned char bits;
12604 present = snd_hda_codec_read(codec, 0x15, 0,
12605 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12606 bits = present ? AMP_IN_MUTE(0) : 0;
12607 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
12608 AMP_IN_MUTE(0), bits);
12609 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
12610 AMP_IN_MUTE(0), bits);
12613 static void alc269_eeepc_dmic_automute(struct hda_codec *codec)
12615 unsigned int present;
12617 present = snd_hda_codec_read(codec, 0x18, 0,
12618 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12619 snd_hda_codec_write(codec, 0x23, 0,
12620 AC_VERB_SET_CONNECT_SEL, (present ? 0 : 5));
12623 static void alc269_eeepc_amic_automute(struct hda_codec *codec)
12625 unsigned int present;
12627 present = snd_hda_codec_read(codec, 0x18, 0,
12628 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12629 snd_hda_codec_write(codec, 0x24, 0, AC_VERB_SET_AMP_GAIN_MUTE,
12630 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
12631 snd_hda_codec_write(codec, 0x24, 0, AC_VERB_SET_AMP_GAIN_MUTE,
12632 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
12635 /* unsolicited event for HP jack sensing */
12636 static void alc269_eeepc_dmic_unsol_event(struct hda_codec *codec,
12639 if ((res >> 26) == ALC880_HP_EVENT)
12640 alc269_speaker_automute(codec);
12642 if ((res >> 26) == ALC880_MIC_EVENT)
12643 alc269_eeepc_dmic_automute(codec);
12646 static void alc269_eeepc_dmic_inithook(struct hda_codec *codec)
12648 alc269_speaker_automute(codec);
12649 alc269_eeepc_dmic_automute(codec);
12652 /* unsolicited event for HP jack sensing */
12653 static void alc269_eeepc_amic_unsol_event(struct hda_codec *codec,
12656 if ((res >> 26) == ALC880_HP_EVENT)
12657 alc269_speaker_automute(codec);
12659 if ((res >> 26) == ALC880_MIC_EVENT)
12660 alc269_eeepc_amic_automute(codec);
12663 static void alc269_eeepc_amic_inithook(struct hda_codec *codec)
12665 alc269_speaker_automute(codec);
12666 alc269_eeepc_amic_automute(codec);
12670 * generic initialization of ADC, input mixers and output mixers
12672 static struct hda_verb alc269_init_verbs[] = {
12674 * Unmute ADC0 and set the default input to mic-in
12676 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12678 /* Mute input amps (PCBeep, Line In, Mic 1 & Mic 2) of the
12679 * analog-loopback mixer widget
12680 * Note: PASD motherboards uses the Line In 2 as the input for
12681 * front panel mic (mic 2)
12683 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
12684 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12685 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12686 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
12687 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
12688 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
12691 * Set up output mixers (0x0c - 0x0e)
12693 /* set vol=0 to output mixers */
12694 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12695 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12697 /* set up input amps for analog loopback */
12698 /* Amp Indices: DAC = 0, mixer = 1 */
12699 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12700 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12701 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12702 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12703 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12704 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12706 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12707 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12708 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12709 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
12710 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
12711 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12712 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12714 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12715 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12716 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12717 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12718 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12719 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12720 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12722 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
12723 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
12725 /* FIXME: use matrix-type input source selection */
12726 /* Mixer elements: 0x18, 19, 1a, 1b, 1d, 0b */
12727 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
12728 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12729 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12730 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
12731 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
12734 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
12735 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
12739 /* add playback controls from the parsed DAC table */
12740 static int alc269_auto_create_multi_out_ctls(struct alc_spec *spec,
12741 const struct auto_pin_cfg *cfg)
12746 spec->multiout.num_dacs = 1; /* only use one dac */
12747 spec->multiout.dac_nids = spec->private_dac_nids;
12748 spec->multiout.dac_nids[0] = 2;
12750 nid = cfg->line_out_pins[0];
12752 err = add_control(spec, ALC_CTL_WIDGET_VOL,
12753 "Front Playback Volume",
12754 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT));
12757 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
12758 "Front Playback Switch",
12759 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
12764 nid = cfg->speaker_pins[0];
12766 if (!cfg->line_out_pins[0]) {
12767 err = add_control(spec, ALC_CTL_WIDGET_VOL,
12768 "Speaker Playback Volume",
12769 HDA_COMPOSE_AMP_VAL(0x02, 3, 0,
12775 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
12776 "Speaker Playback Switch",
12777 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
12782 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
12783 "Speaker Playback Switch",
12784 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
12790 nid = cfg->hp_pins[0];
12792 /* spec->multiout.hp_nid = 2; */
12793 if (!cfg->line_out_pins[0] && !cfg->speaker_pins[0]) {
12794 err = add_control(spec, ALC_CTL_WIDGET_VOL,
12795 "Headphone Playback Volume",
12796 HDA_COMPOSE_AMP_VAL(0x02, 3, 0,
12802 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
12803 "Headphone Playback Switch",
12804 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
12809 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
12810 "Headphone Playback Switch",
12811 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
12820 static int alc269_auto_create_analog_input_ctls(struct alc_spec *spec,
12821 const struct auto_pin_cfg *cfg)
12825 err = alc880_auto_create_analog_input_ctls(spec, cfg);
12828 /* digital-mic input pin is excluded in alc880_auto_create..()
12829 * because it's under 0x18
12831 if (cfg->input_pins[AUTO_PIN_MIC] == 0x12 ||
12832 cfg->input_pins[AUTO_PIN_FRONT_MIC] == 0x12) {
12833 struct hda_input_mux *imux = &spec->private_imux[0];
12834 imux->items[imux->num_items].label = "Int Mic";
12835 imux->items[imux->num_items].index = 0x05;
12841 #ifdef CONFIG_SND_HDA_POWER_SAVE
12842 #define alc269_loopbacks alc880_loopbacks
12845 /* pcm configuration: identiacal with ALC880 */
12846 #define alc269_pcm_analog_playback alc880_pcm_analog_playback
12847 #define alc269_pcm_analog_capture alc880_pcm_analog_capture
12848 #define alc269_pcm_digital_playback alc880_pcm_digital_playback
12849 #define alc269_pcm_digital_capture alc880_pcm_digital_capture
12851 static struct hda_pcm_stream alc269_44k_pcm_analog_playback = {
12855 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
12856 /* NID is set in alc_build_pcms */
12858 .open = alc880_playback_pcm_open,
12859 .prepare = alc880_playback_pcm_prepare,
12860 .cleanup = alc880_playback_pcm_cleanup
12864 static struct hda_pcm_stream alc269_44k_pcm_analog_capture = {
12868 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
12869 /* NID is set in alc_build_pcms */
12873 * BIOS auto configuration
12875 static int alc269_parse_auto_config(struct hda_codec *codec)
12877 struct alc_spec *spec = codec->spec;
12879 static hda_nid_t alc269_ignore[] = { 0x1d, 0 };
12881 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
12886 err = alc269_auto_create_multi_out_ctls(spec, &spec->autocfg);
12889 err = alc269_auto_create_analog_input_ctls(spec, &spec->autocfg);
12893 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
12895 if (spec->autocfg.dig_outs)
12896 spec->multiout.dig_out_nid = ALC269_DIGOUT_NID;
12898 if (spec->kctls.list)
12899 add_mixer(spec, spec->kctls.list);
12901 add_verb(spec, alc269_init_verbs);
12902 spec->num_mux_defs = 1;
12903 spec->input_mux = &spec->private_imux[0];
12904 /* set default input source */
12905 snd_hda_codec_write_cache(codec, alc269_capsrc_nids[0],
12906 0, AC_VERB_SET_CONNECT_SEL,
12907 spec->input_mux->items[0].index);
12909 err = alc_auto_add_mic_boost(codec);
12913 if (!spec->cap_mixer && !spec->no_analog)
12914 set_capture_mixer(spec);
12919 #define alc269_auto_init_multi_out alc882_auto_init_multi_out
12920 #define alc269_auto_init_hp_out alc882_auto_init_hp_out
12921 #define alc269_auto_init_analog_input alc882_auto_init_analog_input
12924 /* init callback for auto-configuration model -- overriding the default init */
12925 static void alc269_auto_init(struct hda_codec *codec)
12927 struct alc_spec *spec = codec->spec;
12928 alc269_auto_init_multi_out(codec);
12929 alc269_auto_init_hp_out(codec);
12930 alc269_auto_init_analog_input(codec);
12931 if (spec->unsol_event)
12932 alc_inithook(codec);
12936 * configuration and preset
12938 static const char *alc269_models[ALC269_MODEL_LAST] = {
12939 [ALC269_BASIC] = "basic",
12940 [ALC269_QUANTA_FL1] = "quanta",
12941 [ALC269_ASUS_EEEPC_P703] = "eeepc-p703",
12942 [ALC269_ASUS_EEEPC_P901] = "eeepc-p901",
12943 [ALC269_FUJITSU] = "fujitsu",
12944 [ALC269_LIFEBOOK] = "lifebook"
12947 static struct snd_pci_quirk alc269_cfg_tbl[] = {
12948 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_QUANTA_FL1),
12949 SND_PCI_QUIRK(0x1043, 0x8330, "ASUS Eeepc P703 P900A",
12950 ALC269_ASUS_EEEPC_P703),
12951 SND_PCI_QUIRK(0x1043, 0x831a, "ASUS Eeepc P901",
12952 ALC269_ASUS_EEEPC_P901),
12953 SND_PCI_QUIRK(0x1043, 0x834a, "ASUS Eeepc S101",
12954 ALC269_ASUS_EEEPC_P901),
12955 SND_PCI_QUIRK(0x1734, 0x115d, "FSC Amilo", ALC269_FUJITSU),
12956 SND_PCI_QUIRK(0x10cf, 0x1475, "Lifebook ICH9M-based", ALC269_LIFEBOOK),
12960 static struct alc_config_preset alc269_presets[] = {
12962 .mixers = { alc269_base_mixer },
12963 .init_verbs = { alc269_init_verbs },
12964 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
12965 .dac_nids = alc269_dac_nids,
12967 .num_channel_mode = ARRAY_SIZE(alc269_modes),
12968 .channel_mode = alc269_modes,
12969 .input_mux = &alc269_capture_source,
12971 [ALC269_QUANTA_FL1] = {
12972 .mixers = { alc269_quanta_fl1_mixer },
12973 .init_verbs = { alc269_init_verbs, alc269_quanta_fl1_verbs },
12974 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
12975 .dac_nids = alc269_dac_nids,
12977 .num_channel_mode = ARRAY_SIZE(alc269_modes),
12978 .channel_mode = alc269_modes,
12979 .input_mux = &alc269_capture_source,
12980 .unsol_event = alc269_quanta_fl1_unsol_event,
12981 .init_hook = alc269_quanta_fl1_init_hook,
12983 [ALC269_ASUS_EEEPC_P703] = {
12984 .mixers = { alc269_eeepc_mixer },
12985 .cap_mixer = alc269_epc_capture_mixer,
12986 .init_verbs = { alc269_init_verbs,
12987 alc269_eeepc_amic_init_verbs },
12988 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
12989 .dac_nids = alc269_dac_nids,
12991 .num_channel_mode = ARRAY_SIZE(alc269_modes),
12992 .channel_mode = alc269_modes,
12993 .input_mux = &alc269_eeepc_amic_capture_source,
12994 .unsol_event = alc269_eeepc_amic_unsol_event,
12995 .init_hook = alc269_eeepc_amic_inithook,
12997 [ALC269_ASUS_EEEPC_P901] = {
12998 .mixers = { alc269_eeepc_mixer },
12999 .cap_mixer = alc269_epc_capture_mixer,
13000 .init_verbs = { alc269_init_verbs,
13001 alc269_eeepc_dmic_init_verbs },
13002 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13003 .dac_nids = alc269_dac_nids,
13005 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13006 .channel_mode = alc269_modes,
13007 .input_mux = &alc269_eeepc_dmic_capture_source,
13008 .unsol_event = alc269_eeepc_dmic_unsol_event,
13009 .init_hook = alc269_eeepc_dmic_inithook,
13011 [ALC269_FUJITSU] = {
13012 .mixers = { alc269_fujitsu_mixer },
13013 .cap_mixer = alc269_epc_capture_mixer,
13014 .init_verbs = { alc269_init_verbs,
13015 alc269_eeepc_dmic_init_verbs },
13016 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13017 .dac_nids = alc269_dac_nids,
13019 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13020 .channel_mode = alc269_modes,
13021 .input_mux = &alc269_eeepc_dmic_capture_source,
13022 .unsol_event = alc269_eeepc_dmic_unsol_event,
13023 .init_hook = alc269_eeepc_dmic_inithook,
13025 [ALC269_LIFEBOOK] = {
13026 .mixers = { alc269_lifebook_mixer },
13027 .init_verbs = { alc269_init_verbs, alc269_lifebook_verbs },
13028 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13029 .dac_nids = alc269_dac_nids,
13031 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13032 .channel_mode = alc269_modes,
13033 .input_mux = &alc269_capture_source,
13034 .unsol_event = alc269_lifebook_unsol_event,
13035 .init_hook = alc269_lifebook_init_hook,
13039 static int patch_alc269(struct hda_codec *codec)
13041 struct alc_spec *spec;
13045 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
13049 codec->spec = spec;
13051 alc_fix_pll_init(codec, 0x20, 0x04, 15);
13053 board_config = snd_hda_check_board_config(codec, ALC269_MODEL_LAST,
13057 if (board_config < 0) {
13058 printk(KERN_INFO "hda_codec: Unknown model for ALC269, "
13059 "trying auto-probe from BIOS...\n");
13060 board_config = ALC269_AUTO;
13063 if (board_config == ALC269_AUTO) {
13064 /* automatic parse from the BIOS config */
13065 err = alc269_parse_auto_config(codec);
13071 "hda_codec: Cannot set up configuration "
13072 "from BIOS. Using base mode...\n");
13073 board_config = ALC269_BASIC;
13077 err = snd_hda_attach_beep_device(codec, 0x1);
13083 if (board_config != ALC269_AUTO)
13084 setup_preset(spec, &alc269_presets[board_config]);
13086 spec->stream_name_analog = "ALC269 Analog";
13087 if (codec->subsystem_id == 0x17aa3bf8) {
13088 /* Due to a hardware problem on Lenovo Ideadpad, we need to
13089 * fix the sample rate of analog I/O to 44.1kHz
13091 spec->stream_analog_playback = &alc269_44k_pcm_analog_playback;
13092 spec->stream_analog_capture = &alc269_44k_pcm_analog_capture;
13094 spec->stream_analog_playback = &alc269_pcm_analog_playback;
13095 spec->stream_analog_capture = &alc269_pcm_analog_capture;
13097 spec->stream_name_digital = "ALC269 Digital";
13098 spec->stream_digital_playback = &alc269_pcm_digital_playback;
13099 spec->stream_digital_capture = &alc269_pcm_digital_capture;
13101 spec->adc_nids = alc269_adc_nids;
13102 spec->num_adc_nids = ARRAY_SIZE(alc269_adc_nids);
13103 spec->capsrc_nids = alc269_capsrc_nids;
13104 if (!spec->cap_mixer)
13105 set_capture_mixer(spec);
13106 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
13108 codec->patch_ops = alc_patch_ops;
13109 if (board_config == ALC269_AUTO)
13110 spec->init_hook = alc269_auto_init;
13111 #ifdef CONFIG_SND_HDA_POWER_SAVE
13112 if (!spec->loopback.amplist)
13113 spec->loopback.amplist = alc269_loopbacks;
13115 codec->proc_widget_hook = print_realtek_coef;
13121 * ALC861 channel source setting (2/6 channel selection for 3-stack)
13125 * set the path ways for 2 channel output
13126 * need to set the codec line out and mic 1 pin widgets to inputs
13128 static struct hda_verb alc861_threestack_ch2_init[] = {
13129 /* set pin widget 1Ah (line in) for input */
13130 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13131 /* set pin widget 18h (mic1/2) for input, for mic also enable
13134 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13136 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
13138 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
13139 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
13145 * need to set the codec line out and mic 1 pin widgets to outputs
13147 static struct hda_verb alc861_threestack_ch6_init[] = {
13148 /* set pin widget 1Ah (line in) for output (Back Surround)*/
13149 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13150 /* set pin widget 18h (mic1) for output (CLFE)*/
13151 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13153 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
13154 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
13156 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
13158 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
13159 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
13164 static struct hda_channel_mode alc861_threestack_modes[2] = {
13165 { 2, alc861_threestack_ch2_init },
13166 { 6, alc861_threestack_ch6_init },
13168 /* Set mic1 as input and unmute the mixer */
13169 static struct hda_verb alc861_uniwill_m31_ch2_init[] = {
13170 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13171 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
13174 /* Set mic1 as output and mute mixer */
13175 static struct hda_verb alc861_uniwill_m31_ch4_init[] = {
13176 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13177 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
13181 static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
13182 { 2, alc861_uniwill_m31_ch2_init },
13183 { 4, alc861_uniwill_m31_ch4_init },
13186 /* Set mic1 and line-in as input and unmute the mixer */
13187 static struct hda_verb alc861_asus_ch2_init[] = {
13188 /* set pin widget 1Ah (line in) for input */
13189 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13190 /* set pin widget 18h (mic1/2) for input, for mic also enable
13193 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13195 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
13197 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
13198 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
13202 /* Set mic1 nad line-in as output and mute mixer */
13203 static struct hda_verb alc861_asus_ch6_init[] = {
13204 /* set pin widget 1Ah (line in) for output (Back Surround)*/
13205 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13206 /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
13207 /* set pin widget 18h (mic1) for output (CLFE)*/
13208 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13209 /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
13210 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
13211 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
13213 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
13215 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
13216 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
13221 static struct hda_channel_mode alc861_asus_modes[2] = {
13222 { 2, alc861_asus_ch2_init },
13223 { 6, alc861_asus_ch6_init },
13228 static struct snd_kcontrol_new alc861_base_mixer[] = {
13229 /* output mixer control */
13230 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13231 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13232 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13233 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13234 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
13236 /*Input mixer control */
13237 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13238 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
13239 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13240 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13241 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13242 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13243 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13244 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13245 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
13246 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
13251 static struct snd_kcontrol_new alc861_3ST_mixer[] = {
13252 /* output mixer control */
13253 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13254 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13255 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13256 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13257 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
13259 /* Input mixer control */
13260 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13261 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
13262 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13263 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13264 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13265 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13266 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13267 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13268 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
13269 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
13272 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13273 .name = "Channel Mode",
13274 .info = alc_ch_mode_info,
13275 .get = alc_ch_mode_get,
13276 .put = alc_ch_mode_put,
13277 .private_value = ARRAY_SIZE(alc861_threestack_modes),
13282 static struct snd_kcontrol_new alc861_toshiba_mixer[] = {
13283 /* output mixer control */
13284 HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13285 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13286 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13291 static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
13292 /* output mixer control */
13293 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13294 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13295 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13296 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13297 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
13299 /* Input mixer control */
13300 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13301 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
13302 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13303 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13304 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13305 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13306 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13307 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13308 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
13309 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
13312 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13313 .name = "Channel Mode",
13314 .info = alc_ch_mode_info,
13315 .get = alc_ch_mode_get,
13316 .put = alc_ch_mode_put,
13317 .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
13322 static struct snd_kcontrol_new alc861_asus_mixer[] = {
13323 /* output mixer control */
13324 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13325 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13326 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13327 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13328 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
13330 /* Input mixer control */
13331 HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13332 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT),
13333 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13334 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13335 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13336 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13337 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13338 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13339 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
13340 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT),
13343 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13344 .name = "Channel Mode",
13345 .info = alc_ch_mode_info,
13346 .get = alc_ch_mode_get,
13347 .put = alc_ch_mode_put,
13348 .private_value = ARRAY_SIZE(alc861_asus_modes),
13353 /* additional mixer */
13354 static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = {
13355 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13356 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13361 * generic initialization of ADC, input mixers and output mixers
13363 static struct hda_verb alc861_base_init_verbs[] = {
13365 * Unmute ADC0 and set the default input to mic-in
13367 /* port-A for surround (rear panel) */
13368 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13369 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
13370 /* port-B for mic-in (rear panel) with vref */
13371 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13372 /* port-C for line-in (rear panel) */
13373 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13374 /* port-D for Front */
13375 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13376 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
13377 /* port-E for HP out (front panel) */
13378 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
13379 /* route front PCM to HP */
13380 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
13381 /* port-F for mic-in (front panel) with vref */
13382 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13383 /* port-G for CLFE (rear panel) */
13384 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13385 { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
13386 /* port-H for side (rear panel) */
13387 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13388 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
13390 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13391 /* route front mic to ADC1*/
13392 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
13393 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13395 /* Unmute DAC0~3 & spdif out*/
13396 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13397 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13398 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13399 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13400 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13402 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13403 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13404 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13405 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13406 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13408 /* Unmute Stereo Mixer 15 */
13409 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13410 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13411 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13412 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
13414 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13415 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13416 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13417 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13418 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13419 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13420 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13421 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13422 /* hp used DAC 3 (Front) */
13423 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
13424 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13429 static struct hda_verb alc861_threestack_init_verbs[] = {
13431 * Unmute ADC0 and set the default input to mic-in
13433 /* port-A for surround (rear panel) */
13434 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13435 /* port-B for mic-in (rear panel) with vref */
13436 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13437 /* port-C for line-in (rear panel) */
13438 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13439 /* port-D for Front */
13440 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13441 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
13442 /* port-E for HP out (front panel) */
13443 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
13444 /* route front PCM to HP */
13445 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
13446 /* port-F for mic-in (front panel) with vref */
13447 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13448 /* port-G for CLFE (rear panel) */
13449 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13450 /* port-H for side (rear panel) */
13451 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13453 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13454 /* route front mic to ADC1*/
13455 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
13456 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13457 /* Unmute DAC0~3 & spdif out*/
13458 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13459 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13460 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13461 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13462 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13464 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13465 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13466 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13467 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13468 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13470 /* Unmute Stereo Mixer 15 */
13471 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13472 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13473 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13474 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
13476 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13477 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13478 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13479 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13480 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13481 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13482 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13483 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13484 /* hp used DAC 3 (Front) */
13485 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
13486 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13490 static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
13492 * Unmute ADC0 and set the default input to mic-in
13494 /* port-A for surround (rear panel) */
13495 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13496 /* port-B for mic-in (rear panel) with vref */
13497 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13498 /* port-C for line-in (rear panel) */
13499 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13500 /* port-D for Front */
13501 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13502 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
13503 /* port-E for HP out (front panel) */
13504 /* this has to be set to VREF80 */
13505 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13506 /* route front PCM to HP */
13507 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
13508 /* port-F for mic-in (front panel) with vref */
13509 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13510 /* port-G for CLFE (rear panel) */
13511 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13512 /* port-H for side (rear panel) */
13513 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13515 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13516 /* route front mic to ADC1*/
13517 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
13518 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13519 /* Unmute DAC0~3 & spdif out*/
13520 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13521 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13522 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13523 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13524 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13526 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13527 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13528 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13529 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13530 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13532 /* Unmute Stereo Mixer 15 */
13533 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13534 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13535 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13536 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
13538 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13539 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13540 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13541 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13542 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13543 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13544 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13545 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13546 /* hp used DAC 3 (Front) */
13547 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
13548 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13552 static struct hda_verb alc861_asus_init_verbs[] = {
13554 * Unmute ADC0 and set the default input to mic-in
13556 /* port-A for surround (rear panel)
13557 * according to codec#0 this is the HP jack
13559 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */
13560 /* route front PCM to HP */
13561 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 },
13562 /* port-B for mic-in (rear panel) with vref */
13563 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13564 /* port-C for line-in (rear panel) */
13565 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13566 /* port-D for Front */
13567 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13568 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
13569 /* port-E for HP out (front panel) */
13570 /* this has to be set to VREF80 */
13571 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13572 /* route front PCM to HP */
13573 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
13574 /* port-F for mic-in (front panel) with vref */
13575 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13576 /* port-G for CLFE (rear panel) */
13577 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13578 /* port-H for side (rear panel) */
13579 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13581 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13582 /* route front mic to ADC1*/
13583 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
13584 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13585 /* Unmute DAC0~3 & spdif out*/
13586 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13587 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13588 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13589 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13590 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13591 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13592 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13593 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13594 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13595 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13597 /* Unmute Stereo Mixer 15 */
13598 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13599 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13600 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13601 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
13603 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13604 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13605 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13606 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13607 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13608 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13609 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13610 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13611 /* hp used DAC 3 (Front) */
13612 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
13613 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13617 /* additional init verbs for ASUS laptops */
13618 static struct hda_verb alc861_asus_laptop_init_verbs[] = {
13619 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */
13620 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */
13625 * generic initialization of ADC, input mixers and output mixers
13627 static struct hda_verb alc861_auto_init_verbs[] = {
13629 * Unmute ADC0 and set the default input to mic-in
13631 /* {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, */
13632 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13634 /* Unmute DAC0~3 & spdif out*/
13635 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13636 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13637 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13638 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13639 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13641 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13642 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13643 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13644 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13645 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13647 /* Unmute Stereo Mixer 15 */
13648 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13649 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13650 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13651 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
13653 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13654 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13655 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13656 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13657 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13658 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13659 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13660 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13662 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13663 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13664 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13665 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
13666 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13667 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13668 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13669 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
13671 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */
13676 static struct hda_verb alc861_toshiba_init_verbs[] = {
13677 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
13682 /* toggle speaker-output according to the hp-jack state */
13683 static void alc861_toshiba_automute(struct hda_codec *codec)
13685 unsigned int present;
13687 present = snd_hda_codec_read(codec, 0x0f, 0,
13688 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
13689 snd_hda_codec_amp_stereo(codec, 0x16, HDA_INPUT, 0,
13690 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
13691 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_INPUT, 3,
13692 HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
13695 static void alc861_toshiba_unsol_event(struct hda_codec *codec,
13698 if ((res >> 26) == ALC880_HP_EVENT)
13699 alc861_toshiba_automute(codec);
13702 /* pcm configuration: identiacal with ALC880 */
13703 #define alc861_pcm_analog_playback alc880_pcm_analog_playback
13704 #define alc861_pcm_analog_capture alc880_pcm_analog_capture
13705 #define alc861_pcm_digital_playback alc880_pcm_digital_playback
13706 #define alc861_pcm_digital_capture alc880_pcm_digital_capture
13709 #define ALC861_DIGOUT_NID 0x07
13711 static struct hda_channel_mode alc861_8ch_modes[1] = {
13715 static hda_nid_t alc861_dac_nids[4] = {
13716 /* front, surround, clfe, side */
13717 0x03, 0x06, 0x05, 0x04
13720 static hda_nid_t alc660_dac_nids[3] = {
13721 /* front, clfe, surround */
13725 static hda_nid_t alc861_adc_nids[1] = {
13730 static struct hda_input_mux alc861_capture_source = {
13734 { "Front Mic", 0x3 },
13741 /* fill in the dac_nids table from the parsed pin configuration */
13742 static int alc861_auto_fill_dac_nids(struct alc_spec *spec,
13743 const struct auto_pin_cfg *cfg)
13748 spec->multiout.dac_nids = spec->private_dac_nids;
13749 for (i = 0; i < cfg->line_outs; i++) {
13750 nid = cfg->line_out_pins[i];
13752 if (i >= ARRAY_SIZE(alc861_dac_nids))
13754 spec->multiout.dac_nids[i] = alc861_dac_nids[i];
13757 spec->multiout.num_dacs = cfg->line_outs;
13761 /* add playback controls from the parsed DAC table */
13762 static int alc861_auto_create_multi_out_ctls(struct alc_spec *spec,
13763 const struct auto_pin_cfg *cfg)
13766 static const char *chname[4] = {
13767 "Front", "Surround", NULL /*CLFE*/, "Side"
13772 for (i = 0; i < cfg->line_outs; i++) {
13773 nid = spec->multiout.dac_nids[i];
13778 err = add_control(spec, ALC_CTL_BIND_MUTE,
13779 "Center Playback Switch",
13780 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
13784 err = add_control(spec, ALC_CTL_BIND_MUTE,
13785 "LFE Playback Switch",
13786 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
13791 for (idx = 0; idx < ARRAY_SIZE(alc861_dac_nids) - 1;
13793 if (nid == alc861_dac_nids[idx])
13795 sprintf(name, "%s Playback Switch", chname[idx]);
13796 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
13797 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
13806 static int alc861_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin)
13814 if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
13816 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
13817 "Headphone Playback Switch",
13818 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
13821 spec->multiout.hp_nid = nid;
13826 /* create playback/capture controls for input pins */
13827 static int alc861_auto_create_analog_input_ctls(struct alc_spec *spec,
13828 const struct auto_pin_cfg *cfg)
13830 struct hda_input_mux *imux = &spec->private_imux[0];
13831 int i, err, idx, idx1;
13833 for (i = 0; i < AUTO_PIN_LAST; i++) {
13834 switch (cfg->input_pins[i]) {
13837 idx = 2; /* Line In */
13841 idx = 2; /* Line In */
13845 idx = 1; /* Mic In */
13849 idx = 1; /* Mic In */
13859 err = new_analog_input(spec, cfg->input_pins[i],
13860 auto_pin_cfg_labels[i], idx, 0x15);
13864 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
13865 imux->items[imux->num_items].index = idx1;
13871 static void alc861_auto_set_output_and_unmute(struct hda_codec *codec,
13873 int pin_type, int dac_idx)
13875 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
13877 snd_hda_codec_write(codec, dac_idx, 0, AC_VERB_SET_AMP_GAIN_MUTE,
13881 static void alc861_auto_init_multi_out(struct hda_codec *codec)
13883 struct alc_spec *spec = codec->spec;
13886 alc_subsystem_id(codec, 0x0e, 0x0f, 0x0b);
13887 for (i = 0; i < spec->autocfg.line_outs; i++) {
13888 hda_nid_t nid = spec->autocfg.line_out_pins[i];
13889 int pin_type = get_pin_type(spec->autocfg.line_out_type);
13891 alc861_auto_set_output_and_unmute(codec, nid, pin_type,
13892 spec->multiout.dac_nids[i]);
13896 static void alc861_auto_init_hp_out(struct hda_codec *codec)
13898 struct alc_spec *spec = codec->spec;
13901 pin = spec->autocfg.hp_pins[0];
13902 if (pin) /* connect to front */
13903 alc861_auto_set_output_and_unmute(codec, pin, PIN_HP,
13904 spec->multiout.dac_nids[0]);
13905 pin = spec->autocfg.speaker_pins[0];
13907 alc861_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
13910 static void alc861_auto_init_analog_input(struct hda_codec *codec)
13912 struct alc_spec *spec = codec->spec;
13915 for (i = 0; i < AUTO_PIN_LAST; i++) {
13916 hda_nid_t nid = spec->autocfg.input_pins[i];
13917 if (nid >= 0x0c && nid <= 0x11)
13918 alc_set_input_pin(codec, nid, i);
13922 /* parse the BIOS configuration and set up the alc_spec */
13923 /* return 1 if successful, 0 if the proper config is not found,
13924 * or a negative error code
13926 static int alc861_parse_auto_config(struct hda_codec *codec)
13928 struct alc_spec *spec = codec->spec;
13930 static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
13932 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
13936 if (!spec->autocfg.line_outs)
13937 return 0; /* can't find valid BIOS pin config */
13939 err = alc861_auto_fill_dac_nids(spec, &spec->autocfg);
13942 err = alc861_auto_create_multi_out_ctls(spec, &spec->autocfg);
13945 err = alc861_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0]);
13948 err = alc861_auto_create_analog_input_ctls(spec, &spec->autocfg);
13952 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
13954 if (spec->autocfg.dig_outs)
13955 spec->multiout.dig_out_nid = ALC861_DIGOUT_NID;
13957 if (spec->kctls.list)
13958 add_mixer(spec, spec->kctls.list);
13960 add_verb(spec, alc861_auto_init_verbs);
13962 spec->num_mux_defs = 1;
13963 spec->input_mux = &spec->private_imux[0];
13965 spec->adc_nids = alc861_adc_nids;
13966 spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
13967 set_capture_mixer(spec);
13972 /* additional initialization for auto-configuration model */
13973 static void alc861_auto_init(struct hda_codec *codec)
13975 struct alc_spec *spec = codec->spec;
13976 alc861_auto_init_multi_out(codec);
13977 alc861_auto_init_hp_out(codec);
13978 alc861_auto_init_analog_input(codec);
13979 if (spec->unsol_event)
13980 alc_inithook(codec);
13983 #ifdef CONFIG_SND_HDA_POWER_SAVE
13984 static struct hda_amp_list alc861_loopbacks[] = {
13985 { 0x15, HDA_INPUT, 0 },
13986 { 0x15, HDA_INPUT, 1 },
13987 { 0x15, HDA_INPUT, 2 },
13988 { 0x15, HDA_INPUT, 3 },
13995 * configuration and preset
13997 static const char *alc861_models[ALC861_MODEL_LAST] = {
13998 [ALC861_3ST] = "3stack",
13999 [ALC660_3ST] = "3stack-660",
14000 [ALC861_3ST_DIG] = "3stack-dig",
14001 [ALC861_6ST_DIG] = "6stack-dig",
14002 [ALC861_UNIWILL_M31] = "uniwill-m31",
14003 [ALC861_TOSHIBA] = "toshiba",
14004 [ALC861_ASUS] = "asus",
14005 [ALC861_ASUS_LAPTOP] = "asus-laptop",
14006 [ALC861_AUTO] = "auto",
14009 static struct snd_pci_quirk alc861_cfg_tbl[] = {
14010 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST),
14011 SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP),
14012 SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP),
14013 SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS),
14014 SND_PCI_QUIRK(0x1043, 0x13d7, "ASUS A9rp", ALC861_ASUS_LAPTOP),
14015 SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS P1-AH2", ALC861_3ST_DIG),
14016 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA),
14017 /* FIXME: the entry below breaks Toshiba A100 (model=auto works!)
14018 * Any other models that need this preset?
14020 /* SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA), */
14021 SND_PCI_QUIRK(0x1462, 0x7254, "HP dx2200 (MSI MS-7254)", ALC861_3ST),
14022 SND_PCI_QUIRK(0x1462, 0x7297, "HP dx2250 (MSI MS-7297)", ALC861_3ST),
14023 SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31),
14024 SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31),
14025 SND_PCI_QUIRK(0x1584, 0x9075, "Airis Praxis N1212", ALC861_ASUS_LAPTOP),
14026 /* FIXME: the below seems conflict */
14027 /* SND_PCI_QUIRK(0x1584, 0x9075, "Uniwill", ALC861_UNIWILL_M31), */
14028 SND_PCI_QUIRK(0x1849, 0x0660, "Asrock 939SLI32", ALC660_3ST),
14029 SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST),
14033 static struct alc_config_preset alc861_presets[] = {
14035 .mixers = { alc861_3ST_mixer },
14036 .init_verbs = { alc861_threestack_init_verbs },
14037 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14038 .dac_nids = alc861_dac_nids,
14039 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
14040 .channel_mode = alc861_threestack_modes,
14042 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14043 .adc_nids = alc861_adc_nids,
14044 .input_mux = &alc861_capture_source,
14046 [ALC861_3ST_DIG] = {
14047 .mixers = { alc861_base_mixer },
14048 .init_verbs = { alc861_threestack_init_verbs },
14049 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14050 .dac_nids = alc861_dac_nids,
14051 .dig_out_nid = ALC861_DIGOUT_NID,
14052 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
14053 .channel_mode = alc861_threestack_modes,
14055 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14056 .adc_nids = alc861_adc_nids,
14057 .input_mux = &alc861_capture_source,
14059 [ALC861_6ST_DIG] = {
14060 .mixers = { alc861_base_mixer },
14061 .init_verbs = { alc861_base_init_verbs },
14062 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14063 .dac_nids = alc861_dac_nids,
14064 .dig_out_nid = ALC861_DIGOUT_NID,
14065 .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
14066 .channel_mode = alc861_8ch_modes,
14067 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14068 .adc_nids = alc861_adc_nids,
14069 .input_mux = &alc861_capture_source,
14072 .mixers = { alc861_3ST_mixer },
14073 .init_verbs = { alc861_threestack_init_verbs },
14074 .num_dacs = ARRAY_SIZE(alc660_dac_nids),
14075 .dac_nids = alc660_dac_nids,
14076 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
14077 .channel_mode = alc861_threestack_modes,
14079 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14080 .adc_nids = alc861_adc_nids,
14081 .input_mux = &alc861_capture_source,
14083 [ALC861_UNIWILL_M31] = {
14084 .mixers = { alc861_uniwill_m31_mixer },
14085 .init_verbs = { alc861_uniwill_m31_init_verbs },
14086 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14087 .dac_nids = alc861_dac_nids,
14088 .dig_out_nid = ALC861_DIGOUT_NID,
14089 .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes),
14090 .channel_mode = alc861_uniwill_m31_modes,
14092 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14093 .adc_nids = alc861_adc_nids,
14094 .input_mux = &alc861_capture_source,
14096 [ALC861_TOSHIBA] = {
14097 .mixers = { alc861_toshiba_mixer },
14098 .init_verbs = { alc861_base_init_verbs,
14099 alc861_toshiba_init_verbs },
14100 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14101 .dac_nids = alc861_dac_nids,
14102 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
14103 .channel_mode = alc883_3ST_2ch_modes,
14104 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14105 .adc_nids = alc861_adc_nids,
14106 .input_mux = &alc861_capture_source,
14107 .unsol_event = alc861_toshiba_unsol_event,
14108 .init_hook = alc861_toshiba_automute,
14111 .mixers = { alc861_asus_mixer },
14112 .init_verbs = { alc861_asus_init_verbs },
14113 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14114 .dac_nids = alc861_dac_nids,
14115 .dig_out_nid = ALC861_DIGOUT_NID,
14116 .num_channel_mode = ARRAY_SIZE(alc861_asus_modes),
14117 .channel_mode = alc861_asus_modes,
14120 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14121 .adc_nids = alc861_adc_nids,
14122 .input_mux = &alc861_capture_source,
14124 [ALC861_ASUS_LAPTOP] = {
14125 .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer },
14126 .init_verbs = { alc861_asus_init_verbs,
14127 alc861_asus_laptop_init_verbs },
14128 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14129 .dac_nids = alc861_dac_nids,
14130 .dig_out_nid = ALC861_DIGOUT_NID,
14131 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
14132 .channel_mode = alc883_3ST_2ch_modes,
14134 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14135 .adc_nids = alc861_adc_nids,
14136 .input_mux = &alc861_capture_source,
14141 static int patch_alc861(struct hda_codec *codec)
14143 struct alc_spec *spec;
14147 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
14151 codec->spec = spec;
14153 board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST,
14157 if (board_config < 0) {
14158 printk(KERN_INFO "hda_codec: Unknown model for ALC861, "
14159 "trying auto-probe from BIOS...\n");
14160 board_config = ALC861_AUTO;
14163 if (board_config == ALC861_AUTO) {
14164 /* automatic parse from the BIOS config */
14165 err = alc861_parse_auto_config(codec);
14171 "hda_codec: Cannot set up configuration "
14172 "from BIOS. Using base mode...\n");
14173 board_config = ALC861_3ST_DIG;
14177 err = snd_hda_attach_beep_device(codec, 0x23);
14183 if (board_config != ALC861_AUTO)
14184 setup_preset(spec, &alc861_presets[board_config]);
14186 spec->stream_name_analog = "ALC861 Analog";
14187 spec->stream_analog_playback = &alc861_pcm_analog_playback;
14188 spec->stream_analog_capture = &alc861_pcm_analog_capture;
14190 spec->stream_name_digital = "ALC861 Digital";
14191 spec->stream_digital_playback = &alc861_pcm_digital_playback;
14192 spec->stream_digital_capture = &alc861_pcm_digital_capture;
14194 set_beep_amp(spec, 0x23, 0, HDA_OUTPUT);
14196 spec->vmaster_nid = 0x03;
14198 codec->patch_ops = alc_patch_ops;
14199 if (board_config == ALC861_AUTO)
14200 spec->init_hook = alc861_auto_init;
14201 #ifdef CONFIG_SND_HDA_POWER_SAVE
14202 if (!spec->loopback.amplist)
14203 spec->loopback.amplist = alc861_loopbacks;
14205 codec->proc_widget_hook = print_realtek_coef;
14211 * ALC861-VD support
14215 * In addition, an independent DAC
14217 #define ALC861VD_DIGOUT_NID 0x06
14219 static hda_nid_t alc861vd_dac_nids[4] = {
14220 /* front, surr, clfe, side surr */
14221 0x02, 0x03, 0x04, 0x05
14224 /* dac_nids for ALC660vd are in a different order - according to
14225 * Realtek's driver.
14226 * This should probably tesult in a different mixer for 6stack models
14227 * of ALC660vd codecs, but for now there is only 3stack mixer
14228 * - and it is the same as in 861vd.
14229 * adc_nids in ALC660vd are (is) the same as in 861vd
14231 static hda_nid_t alc660vd_dac_nids[3] = {
14232 /* front, rear, clfe, rear_surr */
14236 static hda_nid_t alc861vd_adc_nids[1] = {
14241 static hda_nid_t alc861vd_capsrc_nids[1] = { 0x22 };
14244 /* FIXME: should be a matrix-type input source selection */
14245 static struct hda_input_mux alc861vd_capture_source = {
14249 { "Front Mic", 0x1 },
14255 static struct hda_input_mux alc861vd_dallas_capture_source = {
14258 { "Ext Mic", 0x0 },
14259 { "Int Mic", 0x1 },
14263 static struct hda_input_mux alc861vd_hp_capture_source = {
14266 { "Front Mic", 0x0 },
14267 { "ATAPI Mic", 0x1 },
14274 static struct hda_channel_mode alc861vd_3stack_2ch_modes[1] = {
14281 static struct hda_verb alc861vd_6stack_ch6_init[] = {
14282 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
14283 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14284 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14285 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14292 static struct hda_verb alc861vd_6stack_ch8_init[] = {
14293 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14294 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14295 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14296 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14300 static struct hda_channel_mode alc861vd_6stack_modes[2] = {
14301 { 6, alc861vd_6stack_ch6_init },
14302 { 8, alc861vd_6stack_ch8_init },
14305 static struct snd_kcontrol_new alc861vd_chmode_mixer[] = {
14307 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
14308 .name = "Channel Mode",
14309 .info = alc_ch_mode_info,
14310 .get = alc_ch_mode_get,
14311 .put = alc_ch_mode_put,
14316 /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
14317 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
14319 static struct snd_kcontrol_new alc861vd_6st_mixer[] = {
14320 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14321 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
14323 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14324 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
14326 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0,
14328 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0,
14330 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
14331 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
14333 HDA_CODEC_VOLUME("Side Playback Volume", 0x05, 0x0, HDA_OUTPUT),
14334 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
14336 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14338 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14339 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14340 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14342 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
14343 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14344 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14346 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
14347 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
14349 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
14350 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
14355 static struct snd_kcontrol_new alc861vd_3st_mixer[] = {
14356 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14357 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
14359 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14361 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14362 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14363 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14365 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
14366 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14367 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14369 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
14370 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
14372 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
14373 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
14378 static struct snd_kcontrol_new alc861vd_lenovo_mixer[] = {
14379 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14380 /*HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),*/
14381 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
14383 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14385 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14386 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14387 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14389 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
14390 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14391 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14393 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
14394 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
14399 /* Pin assignment: Speaker=0x14, HP = 0x15,
14400 * Ext Mic=0x18, Int Mic = 0x19, CD = 0x1c, PC Beep = 0x1d
14402 static struct snd_kcontrol_new alc861vd_dallas_mixer[] = {
14403 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14404 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
14405 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14406 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
14407 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
14408 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14409 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14410 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
14411 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14412 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14416 /* Pin assignment: Speaker=0x14, Line-out = 0x15,
14417 * Front Mic=0x18, ATAPI Mic = 0x19,
14419 static struct snd_kcontrol_new alc861vd_hp_mixer[] = {
14420 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14421 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
14422 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14423 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
14424 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14425 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14426 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14427 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14433 * generic initialization of ADC, input mixers and output mixers
14435 static struct hda_verb alc861vd_volume_init_verbs[] = {
14437 * Unmute ADC0 and set the default input to mic-in
14439 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
14440 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14442 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of
14443 * the analog-loopback mixer widget
14445 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
14446 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14447 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14448 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
14449 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
14450 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
14452 /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */
14453 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14454 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14455 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
14456 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
14459 * Set up output mixers (0x02 - 0x05)
14461 /* set vol=0 to output mixers */
14462 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14463 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14464 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14465 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14467 /* set up input amps for analog loopback */
14468 /* Amp Indices: DAC = 0, mixer = 1 */
14469 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14470 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14471 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14472 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14473 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14474 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14475 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14476 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14482 * 3-stack pin configuration:
14483 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
14485 static struct hda_verb alc861vd_3stack_init_verbs[] = {
14487 * Set pin mode and muting
14489 /* set front pin widgets 0x14 for output */
14490 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14491 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14492 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
14494 /* Mic (rear) pin: input vref at 80% */
14495 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14496 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14497 /* Front Mic pin: input vref at 80% */
14498 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14499 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14500 /* Line In pin: input */
14501 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14502 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14503 /* Line-2 In: Headphone output (output 0 - 0x0c) */
14504 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14505 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14506 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
14507 /* CD pin widget for input */
14508 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14514 * 6-stack pin configuration:
14516 static struct hda_verb alc861vd_6stack_init_verbs[] = {
14518 * Set pin mode and muting
14520 /* set front pin widgets 0x14 for output */
14521 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14522 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14523 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
14525 /* Rear Pin: output 1 (0x0d) */
14526 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14527 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14528 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
14529 /* CLFE Pin: output 2 (0x0e) */
14530 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14531 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14532 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
14533 /* Side Pin: output 3 (0x0f) */
14534 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14535 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14536 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
14538 /* Mic (rear) pin: input vref at 80% */
14539 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14540 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14541 /* Front Mic pin: input vref at 80% */
14542 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14543 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14544 /* Line In pin: input */
14545 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14546 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14547 /* Line-2 In: Headphone output (output 0 - 0x0c) */
14548 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14549 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14550 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
14551 /* CD pin widget for input */
14552 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14557 static struct hda_verb alc861vd_eapd_verbs[] = {
14558 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
14562 static struct hda_verb alc660vd_eapd_verbs[] = {
14563 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
14564 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
14568 static struct hda_verb alc861vd_lenovo_unsol_verbs[] = {
14569 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14570 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14571 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
14572 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14573 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14577 /* toggle speaker-output according to the hp-jack state */
14578 static void alc861vd_lenovo_hp_automute(struct hda_codec *codec)
14580 unsigned int present;
14581 unsigned char bits;
14583 present = snd_hda_codec_read(codec, 0x1b, 0,
14584 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
14585 bits = present ? HDA_AMP_MUTE : 0;
14586 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
14587 HDA_AMP_MUTE, bits);
14590 static void alc861vd_lenovo_mic_automute(struct hda_codec *codec)
14592 unsigned int present;
14593 unsigned char bits;
14595 present = snd_hda_codec_read(codec, 0x18, 0,
14596 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
14597 bits = present ? HDA_AMP_MUTE : 0;
14598 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
14599 HDA_AMP_MUTE, bits);
14602 static void alc861vd_lenovo_automute(struct hda_codec *codec)
14604 alc861vd_lenovo_hp_automute(codec);
14605 alc861vd_lenovo_mic_automute(codec);
14608 static void alc861vd_lenovo_unsol_event(struct hda_codec *codec,
14611 switch (res >> 26) {
14612 case ALC880_HP_EVENT:
14613 alc861vd_lenovo_hp_automute(codec);
14615 case ALC880_MIC_EVENT:
14616 alc861vd_lenovo_mic_automute(codec);
14621 static struct hda_verb alc861vd_dallas_verbs[] = {
14622 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14623 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14624 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14625 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14627 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14628 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14629 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14630 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14631 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14632 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14633 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14634 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14636 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14637 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14638 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14639 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14640 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14641 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14642 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14643 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14645 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
14646 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14647 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
14648 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14649 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14650 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14651 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14652 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14654 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14655 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
14656 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
14657 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
14659 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14660 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
14661 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14666 /* toggle speaker-output according to the hp-jack state */
14667 static void alc861vd_dallas_automute(struct hda_codec *codec)
14669 unsigned int present;
14671 present = snd_hda_codec_read(codec, 0x15, 0,
14672 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
14673 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
14674 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
14677 static void alc861vd_dallas_unsol_event(struct hda_codec *codec, unsigned int res)
14679 if ((res >> 26) == ALC880_HP_EVENT)
14680 alc861vd_dallas_automute(codec);
14683 #ifdef CONFIG_SND_HDA_POWER_SAVE
14684 #define alc861vd_loopbacks alc880_loopbacks
14687 /* pcm configuration: identiacal with ALC880 */
14688 #define alc861vd_pcm_analog_playback alc880_pcm_analog_playback
14689 #define alc861vd_pcm_analog_capture alc880_pcm_analog_capture
14690 #define alc861vd_pcm_digital_playback alc880_pcm_digital_playback
14691 #define alc861vd_pcm_digital_capture alc880_pcm_digital_capture
14694 * configuration and preset
14696 static const char *alc861vd_models[ALC861VD_MODEL_LAST] = {
14697 [ALC660VD_3ST] = "3stack-660",
14698 [ALC660VD_3ST_DIG] = "3stack-660-digout",
14699 [ALC660VD_ASUS_V1S] = "asus-v1s",
14700 [ALC861VD_3ST] = "3stack",
14701 [ALC861VD_3ST_DIG] = "3stack-digout",
14702 [ALC861VD_6ST_DIG] = "6stack-digout",
14703 [ALC861VD_LENOVO] = "lenovo",
14704 [ALC861VD_DALLAS] = "dallas",
14705 [ALC861VD_HP] = "hp",
14706 [ALC861VD_AUTO] = "auto",
14709 static struct snd_pci_quirk alc861vd_cfg_tbl[] = {
14710 SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST),
14711 SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_HP),
14712 SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST),
14713 SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST),
14714 SND_PCI_QUIRK(0x1043, 0x1633, "Asus V1Sn", ALC660VD_ASUS_V1S),
14715 SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660VD_3ST_DIG),
14716 SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST),
14717 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba A135", ALC861VD_LENOVO),
14718 /*SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),*/ /*lenovo*/
14719 SND_PCI_QUIRK(0x1179, 0xff01, "DALLAS", ALC861VD_DALLAS),
14720 SND_PCI_QUIRK(0x1179, 0xff03, "Toshiba P205", ALC861VD_LENOVO),
14721 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba L30-149", ALC861VD_DALLAS),
14722 SND_PCI_QUIRK(0x1565, 0x820d, "Biostar NF61S SE", ALC861VD_6ST_DIG),
14723 SND_PCI_QUIRK_VENDOR(0x17aa, "Lenovo", ALC861VD_LENOVO),
14724 SND_PCI_QUIRK(0x1849, 0x0862, "ASRock K8NF6G-VSTA", ALC861VD_6ST_DIG),
14728 static struct alc_config_preset alc861vd_presets[] = {
14730 .mixers = { alc861vd_3st_mixer },
14731 .init_verbs = { alc861vd_volume_init_verbs,
14732 alc861vd_3stack_init_verbs },
14733 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
14734 .dac_nids = alc660vd_dac_nids,
14735 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14736 .channel_mode = alc861vd_3stack_2ch_modes,
14737 .input_mux = &alc861vd_capture_source,
14739 [ALC660VD_3ST_DIG] = {
14740 .mixers = { alc861vd_3st_mixer },
14741 .init_verbs = { alc861vd_volume_init_verbs,
14742 alc861vd_3stack_init_verbs },
14743 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
14744 .dac_nids = alc660vd_dac_nids,
14745 .dig_out_nid = ALC861VD_DIGOUT_NID,
14746 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14747 .channel_mode = alc861vd_3stack_2ch_modes,
14748 .input_mux = &alc861vd_capture_source,
14751 .mixers = { alc861vd_3st_mixer },
14752 .init_verbs = { alc861vd_volume_init_verbs,
14753 alc861vd_3stack_init_verbs },
14754 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
14755 .dac_nids = alc861vd_dac_nids,
14756 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14757 .channel_mode = alc861vd_3stack_2ch_modes,
14758 .input_mux = &alc861vd_capture_source,
14760 [ALC861VD_3ST_DIG] = {
14761 .mixers = { alc861vd_3st_mixer },
14762 .init_verbs = { alc861vd_volume_init_verbs,
14763 alc861vd_3stack_init_verbs },
14764 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
14765 .dac_nids = alc861vd_dac_nids,
14766 .dig_out_nid = ALC861VD_DIGOUT_NID,
14767 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14768 .channel_mode = alc861vd_3stack_2ch_modes,
14769 .input_mux = &alc861vd_capture_source,
14771 [ALC861VD_6ST_DIG] = {
14772 .mixers = { alc861vd_6st_mixer, alc861vd_chmode_mixer },
14773 .init_verbs = { alc861vd_volume_init_verbs,
14774 alc861vd_6stack_init_verbs },
14775 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
14776 .dac_nids = alc861vd_dac_nids,
14777 .dig_out_nid = ALC861VD_DIGOUT_NID,
14778 .num_channel_mode = ARRAY_SIZE(alc861vd_6stack_modes),
14779 .channel_mode = alc861vd_6stack_modes,
14780 .input_mux = &alc861vd_capture_source,
14782 [ALC861VD_LENOVO] = {
14783 .mixers = { alc861vd_lenovo_mixer },
14784 .init_verbs = { alc861vd_volume_init_verbs,
14785 alc861vd_3stack_init_verbs,
14786 alc861vd_eapd_verbs,
14787 alc861vd_lenovo_unsol_verbs },
14788 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
14789 .dac_nids = alc660vd_dac_nids,
14790 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14791 .channel_mode = alc861vd_3stack_2ch_modes,
14792 .input_mux = &alc861vd_capture_source,
14793 .unsol_event = alc861vd_lenovo_unsol_event,
14794 .init_hook = alc861vd_lenovo_automute,
14796 [ALC861VD_DALLAS] = {
14797 .mixers = { alc861vd_dallas_mixer },
14798 .init_verbs = { alc861vd_dallas_verbs },
14799 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
14800 .dac_nids = alc861vd_dac_nids,
14801 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14802 .channel_mode = alc861vd_3stack_2ch_modes,
14803 .input_mux = &alc861vd_dallas_capture_source,
14804 .unsol_event = alc861vd_dallas_unsol_event,
14805 .init_hook = alc861vd_dallas_automute,
14808 .mixers = { alc861vd_hp_mixer },
14809 .init_verbs = { alc861vd_dallas_verbs, alc861vd_eapd_verbs },
14810 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
14811 .dac_nids = alc861vd_dac_nids,
14812 .dig_out_nid = ALC861VD_DIGOUT_NID,
14813 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14814 .channel_mode = alc861vd_3stack_2ch_modes,
14815 .input_mux = &alc861vd_hp_capture_source,
14816 .unsol_event = alc861vd_dallas_unsol_event,
14817 .init_hook = alc861vd_dallas_automute,
14819 [ALC660VD_ASUS_V1S] = {
14820 .mixers = { alc861vd_lenovo_mixer },
14821 .init_verbs = { alc861vd_volume_init_verbs,
14822 alc861vd_3stack_init_verbs,
14823 alc861vd_eapd_verbs,
14824 alc861vd_lenovo_unsol_verbs },
14825 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
14826 .dac_nids = alc660vd_dac_nids,
14827 .dig_out_nid = ALC861VD_DIGOUT_NID,
14828 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14829 .channel_mode = alc861vd_3stack_2ch_modes,
14830 .input_mux = &alc861vd_capture_source,
14831 .unsol_event = alc861vd_lenovo_unsol_event,
14832 .init_hook = alc861vd_lenovo_automute,
14837 * BIOS auto configuration
14839 static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec,
14840 hda_nid_t nid, int pin_type, int dac_idx)
14842 alc_set_pin_output(codec, nid, pin_type);
14845 static void alc861vd_auto_init_multi_out(struct hda_codec *codec)
14847 struct alc_spec *spec = codec->spec;
14850 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
14851 for (i = 0; i <= HDA_SIDE; i++) {
14852 hda_nid_t nid = spec->autocfg.line_out_pins[i];
14853 int pin_type = get_pin_type(spec->autocfg.line_out_type);
14855 alc861vd_auto_set_output_and_unmute(codec, nid,
14861 static void alc861vd_auto_init_hp_out(struct hda_codec *codec)
14863 struct alc_spec *spec = codec->spec;
14866 pin = spec->autocfg.hp_pins[0];
14867 if (pin) /* connect to front and use dac 0 */
14868 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
14869 pin = spec->autocfg.speaker_pins[0];
14871 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
14874 #define alc861vd_is_input_pin(nid) alc880_is_input_pin(nid)
14875 #define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID
14877 static void alc861vd_auto_init_analog_input(struct hda_codec *codec)
14879 struct alc_spec *spec = codec->spec;
14882 for (i = 0; i < AUTO_PIN_LAST; i++) {
14883 hda_nid_t nid = spec->autocfg.input_pins[i];
14884 if (alc861vd_is_input_pin(nid)) {
14885 alc_set_input_pin(codec, nid, i);
14886 if (nid != ALC861VD_PIN_CD_NID &&
14887 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
14888 snd_hda_codec_write(codec, nid, 0,
14889 AC_VERB_SET_AMP_GAIN_MUTE,
14895 #define alc861vd_auto_init_input_src alc882_auto_init_input_src
14897 #define alc861vd_idx_to_mixer_vol(nid) ((nid) + 0x02)
14898 #define alc861vd_idx_to_mixer_switch(nid) ((nid) + 0x0c)
14900 /* add playback controls from the parsed DAC table */
14901 /* Based on ALC880 version. But ALC861VD has separate,
14902 * different NIDs for mute/unmute switch and volume control */
14903 static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
14904 const struct auto_pin_cfg *cfg)
14907 static const char *chname[4] = {"Front", "Surround", "CLFE", "Side"};
14908 hda_nid_t nid_v, nid_s;
14911 for (i = 0; i < cfg->line_outs; i++) {
14912 if (!spec->multiout.dac_nids[i])
14914 nid_v = alc861vd_idx_to_mixer_vol(
14916 spec->multiout.dac_nids[i]));
14917 nid_s = alc861vd_idx_to_mixer_switch(
14919 spec->multiout.dac_nids[i]));
14923 err = add_control(spec, ALC_CTL_WIDGET_VOL,
14924 "Center Playback Volume",
14925 HDA_COMPOSE_AMP_VAL(nid_v, 1, 0,
14929 err = add_control(spec, ALC_CTL_WIDGET_VOL,
14930 "LFE Playback Volume",
14931 HDA_COMPOSE_AMP_VAL(nid_v, 2, 0,
14935 err = add_control(spec, ALC_CTL_BIND_MUTE,
14936 "Center Playback Switch",
14937 HDA_COMPOSE_AMP_VAL(nid_s, 1, 2,
14941 err = add_control(spec, ALC_CTL_BIND_MUTE,
14942 "LFE Playback Switch",
14943 HDA_COMPOSE_AMP_VAL(nid_s, 2, 2,
14948 sprintf(name, "%s Playback Volume", chname[i]);
14949 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
14950 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0,
14954 sprintf(name, "%s Playback Switch", chname[i]);
14955 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
14956 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2,
14965 /* add playback controls for speaker and HP outputs */
14966 /* Based on ALC880 version. But ALC861VD has separate,
14967 * different NIDs for mute/unmute switch and volume control */
14968 static int alc861vd_auto_create_extra_out(struct alc_spec *spec,
14969 hda_nid_t pin, const char *pfx)
14971 hda_nid_t nid_v, nid_s;
14978 if (alc880_is_fixed_pin(pin)) {
14979 nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
14980 /* specify the DAC as the extra output */
14981 if (!spec->multiout.hp_nid)
14982 spec->multiout.hp_nid = nid_v;
14984 spec->multiout.extra_out_nid[0] = nid_v;
14985 /* control HP volume/switch on the output mixer amp */
14986 nid_v = alc861vd_idx_to_mixer_vol(
14987 alc880_fixed_pin_idx(pin));
14988 nid_s = alc861vd_idx_to_mixer_switch(
14989 alc880_fixed_pin_idx(pin));
14991 sprintf(name, "%s Playback Volume", pfx);
14992 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
14993 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT));
14996 sprintf(name, "%s Playback Switch", pfx);
14997 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
14998 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT));
15001 } else if (alc880_is_multi_pin(pin)) {
15002 /* set manual connection */
15003 /* we have only a switch on HP-out PIN */
15004 sprintf(name, "%s Playback Switch", pfx);
15005 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
15006 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
15013 /* parse the BIOS configuration and set up the alc_spec
15014 * return 1 if successful, 0 if the proper config is not found,
15015 * or a negative error code
15016 * Based on ALC880 version - had to change it to override
15017 * alc880_auto_create_extra_out and alc880_auto_create_multi_out_ctls */
15018 static int alc861vd_parse_auto_config(struct hda_codec *codec)
15020 struct alc_spec *spec = codec->spec;
15022 static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
15024 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
15028 if (!spec->autocfg.line_outs)
15029 return 0; /* can't find valid BIOS pin config */
15031 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
15034 err = alc861vd_auto_create_multi_out_ctls(spec, &spec->autocfg);
15037 err = alc861vd_auto_create_extra_out(spec,
15038 spec->autocfg.speaker_pins[0],
15042 err = alc861vd_auto_create_extra_out(spec,
15043 spec->autocfg.hp_pins[0],
15047 err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
15051 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
15053 if (spec->autocfg.dig_outs)
15054 spec->multiout.dig_out_nid = ALC861VD_DIGOUT_NID;
15056 if (spec->kctls.list)
15057 add_mixer(spec, spec->kctls.list);
15059 add_verb(spec, alc861vd_volume_init_verbs);
15061 spec->num_mux_defs = 1;
15062 spec->input_mux = &spec->private_imux[0];
15064 err = alc_auto_add_mic_boost(codec);
15071 /* additional initialization for auto-configuration model */
15072 static void alc861vd_auto_init(struct hda_codec *codec)
15074 struct alc_spec *spec = codec->spec;
15075 alc861vd_auto_init_multi_out(codec);
15076 alc861vd_auto_init_hp_out(codec);
15077 alc861vd_auto_init_analog_input(codec);
15078 alc861vd_auto_init_input_src(codec);
15079 if (spec->unsol_event)
15080 alc_inithook(codec);
15083 static int patch_alc861vd(struct hda_codec *codec)
15085 struct alc_spec *spec;
15086 int err, board_config;
15088 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
15092 codec->spec = spec;
15094 board_config = snd_hda_check_board_config(codec, ALC861VD_MODEL_LAST,
15098 if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) {
15099 printk(KERN_INFO "hda_codec: Unknown model for ALC660VD/"
15100 "ALC861VD, trying auto-probe from BIOS...\n");
15101 board_config = ALC861VD_AUTO;
15104 if (board_config == ALC861VD_AUTO) {
15105 /* automatic parse from the BIOS config */
15106 err = alc861vd_parse_auto_config(codec);
15112 "hda_codec: Cannot set up configuration "
15113 "from BIOS. Using base mode...\n");
15114 board_config = ALC861VD_3ST;
15118 err = snd_hda_attach_beep_device(codec, 0x23);
15124 if (board_config != ALC861VD_AUTO)
15125 setup_preset(spec, &alc861vd_presets[board_config]);
15127 if (codec->vendor_id == 0x10ec0660) {
15128 spec->stream_name_analog = "ALC660-VD Analog";
15129 spec->stream_name_digital = "ALC660-VD Digital";
15130 /* always turn on EAPD */
15131 add_verb(spec, alc660vd_eapd_verbs);
15133 spec->stream_name_analog = "ALC861VD Analog";
15134 spec->stream_name_digital = "ALC861VD Digital";
15137 spec->stream_analog_playback = &alc861vd_pcm_analog_playback;
15138 spec->stream_analog_capture = &alc861vd_pcm_analog_capture;
15140 spec->stream_digital_playback = &alc861vd_pcm_digital_playback;
15141 spec->stream_digital_capture = &alc861vd_pcm_digital_capture;
15143 spec->adc_nids = alc861vd_adc_nids;
15144 spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids);
15145 spec->capsrc_nids = alc861vd_capsrc_nids;
15146 spec->capture_style = CAPT_MIX;
15148 set_capture_mixer(spec);
15149 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
15151 spec->vmaster_nid = 0x02;
15153 codec->patch_ops = alc_patch_ops;
15155 if (board_config == ALC861VD_AUTO)
15156 spec->init_hook = alc861vd_auto_init;
15157 #ifdef CONFIG_SND_HDA_POWER_SAVE
15158 if (!spec->loopback.amplist)
15159 spec->loopback.amplist = alc861vd_loopbacks;
15161 codec->proc_widget_hook = print_realtek_coef;
15169 * ALC662 is almost identical with ALC880 but has cleaner and more flexible
15170 * configuration. Each pin widget can choose any input DACs and a mixer.
15171 * Each ADC is connected from a mixer of all inputs. This makes possible
15172 * 6-channel independent captures.
15174 * In addition, an independent DAC for the multi-playback (not used in this
15177 #define ALC662_DIGOUT_NID 0x06
15178 #define ALC662_DIGIN_NID 0x0a
15180 static hda_nid_t alc662_dac_nids[4] = {
15181 /* front, rear, clfe, rear_surr */
15185 static hda_nid_t alc662_adc_nids[1] = {
15190 static hda_nid_t alc662_capsrc_nids[1] = { 0x22 };
15193 /* FIXME: should be a matrix-type input source selection */
15194 static struct hda_input_mux alc662_capture_source = {
15198 { "Front Mic", 0x1 },
15204 static struct hda_input_mux alc662_lenovo_101e_capture_source = {
15212 static struct hda_input_mux alc662_eeepc_capture_source = {
15220 static struct hda_input_mux alc663_capture_source = {
15224 { "Front Mic", 0x1 },
15229 static struct hda_input_mux alc663_m51va_capture_source = {
15232 { "Ext-Mic", 0x0 },
15240 static struct hda_channel_mode alc662_3ST_2ch_modes[1] = {
15247 static struct hda_verb alc662_3ST_ch2_init[] = {
15248 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
15249 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
15250 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
15251 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
15258 static struct hda_verb alc662_3ST_ch6_init[] = {
15259 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15260 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
15261 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
15262 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15263 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
15264 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
15268 static struct hda_channel_mode alc662_3ST_6ch_modes[2] = {
15269 { 2, alc662_3ST_ch2_init },
15270 { 6, alc662_3ST_ch6_init },
15276 static struct hda_verb alc662_sixstack_ch6_init[] = {
15277 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15278 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15279 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15286 static struct hda_verb alc662_sixstack_ch8_init[] = {
15287 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15288 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15289 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15293 static struct hda_channel_mode alc662_5stack_modes[2] = {
15294 { 2, alc662_sixstack_ch6_init },
15295 { 6, alc662_sixstack_ch8_init },
15298 /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
15299 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
15302 static struct snd_kcontrol_new alc662_base_mixer[] = {
15303 /* output mixer control */
15304 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
15305 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
15306 HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT),
15307 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
15308 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
15309 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
15310 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
15311 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
15312 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15314 /*Input mixer control */
15315 HDA_CODEC_VOLUME("CD Playback Volume", 0xb, 0x4, HDA_INPUT),
15316 HDA_CODEC_MUTE("CD Playback Switch", 0xb, 0x4, HDA_INPUT),
15317 HDA_CODEC_VOLUME("Line Playback Volume", 0xb, 0x02, HDA_INPUT),
15318 HDA_CODEC_MUTE("Line Playback Switch", 0xb, 0x02, HDA_INPUT),
15319 HDA_CODEC_VOLUME("Mic Playback Volume", 0xb, 0x0, HDA_INPUT),
15320 HDA_CODEC_MUTE("Mic Playback Switch", 0xb, 0x0, HDA_INPUT),
15321 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0xb, 0x01, HDA_INPUT),
15322 HDA_CODEC_MUTE("Front Mic Playback Switch", 0xb, 0x01, HDA_INPUT),
15326 static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = {
15327 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15328 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
15329 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15330 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
15331 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
15332 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15333 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15334 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15335 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15336 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15337 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15341 static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = {
15342 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15343 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
15344 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15345 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
15346 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
15347 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
15348 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
15349 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
15350 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15351 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
15352 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
15353 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15354 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15355 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15356 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15357 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15358 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15362 static struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = {
15363 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15364 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
15365 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15366 HDA_BIND_MUTE("Speaker Playback Switch", 0x03, 2, HDA_INPUT),
15367 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15368 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15369 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15370 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15371 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15375 static struct snd_kcontrol_new alc662_eeepc_p701_mixer[] = {
15376 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
15378 HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15379 HDA_CODEC_MUTE("Line-Out Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15381 HDA_CODEC_VOLUME("e-Mic Boost", 0x18, 0, HDA_INPUT),
15382 HDA_CODEC_VOLUME("e-Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15383 HDA_CODEC_MUTE("e-Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15385 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
15386 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15387 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15391 static struct snd_kcontrol_new alc662_eeepc_ep20_mixer[] = {
15392 HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15393 HDA_CODEC_MUTE("Line-Out Playback Switch", 0x14, 0x0, HDA_OUTPUT),
15394 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15395 HDA_BIND_MUTE("Surround Playback Switch", 0x03, 2, HDA_INPUT),
15396 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
15397 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
15398 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT),
15399 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT),
15400 HDA_CODEC_MUTE("Speaker Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15401 HDA_BIND_MUTE("MuteCtrl Playback Switch", 0x0c, 2, HDA_INPUT),
15402 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15403 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15404 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15405 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15409 static struct hda_bind_ctls alc663_asus_bind_master_vol = {
15410 .ops = &snd_hda_bind_vol,
15412 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
15413 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
15418 static struct hda_bind_ctls alc663_asus_one_bind_switch = {
15419 .ops = &snd_hda_bind_sw,
15421 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
15422 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
15427 static struct snd_kcontrol_new alc663_m51va_mixer[] = {
15428 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
15429 HDA_BIND_SW("Master Playback Switch", &alc663_asus_one_bind_switch),
15430 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15431 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15435 static struct hda_bind_ctls alc663_asus_tree_bind_switch = {
15436 .ops = &snd_hda_bind_sw,
15438 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
15439 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
15440 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
15445 static struct snd_kcontrol_new alc663_two_hp_m1_mixer[] = {
15446 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
15447 HDA_BIND_SW("Master Playback Switch", &alc663_asus_tree_bind_switch),
15448 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15449 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15450 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15451 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15456 static struct hda_bind_ctls alc663_asus_four_bind_switch = {
15457 .ops = &snd_hda_bind_sw,
15459 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
15460 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
15461 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
15466 static struct snd_kcontrol_new alc663_two_hp_m2_mixer[] = {
15467 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
15468 HDA_BIND_SW("Master Playback Switch", &alc663_asus_four_bind_switch),
15469 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15470 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15471 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15472 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15476 static struct snd_kcontrol_new alc662_1bjd_mixer[] = {
15477 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15478 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
15479 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15480 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15481 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15482 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15483 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15487 static struct hda_bind_ctls alc663_asus_two_bind_master_vol = {
15488 .ops = &snd_hda_bind_vol,
15490 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
15491 HDA_COMPOSE_AMP_VAL(0x04, 3, 0, HDA_OUTPUT),
15496 static struct hda_bind_ctls alc663_asus_two_bind_switch = {
15497 .ops = &snd_hda_bind_sw,
15499 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
15500 HDA_COMPOSE_AMP_VAL(0x16, 3, 0, HDA_OUTPUT),
15505 static struct snd_kcontrol_new alc663_asus_21jd_clfe_mixer[] = {
15506 HDA_BIND_VOL("Master Playback Volume",
15507 &alc663_asus_two_bind_master_vol),
15508 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
15509 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15510 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
15511 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15512 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15516 static struct snd_kcontrol_new alc663_asus_15jd_clfe_mixer[] = {
15517 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
15518 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
15519 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15520 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
15521 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15522 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15526 static struct snd_kcontrol_new alc663_g71v_mixer[] = {
15527 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15528 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
15529 HDA_CODEC_VOLUME("Front Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15530 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
15531 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
15533 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15534 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15535 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15536 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15540 static struct snd_kcontrol_new alc663_g50v_mixer[] = {
15541 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15542 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
15543 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
15545 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15546 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15547 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15548 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15549 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15550 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15554 static struct snd_kcontrol_new alc662_chmode_mixer[] = {
15556 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
15557 .name = "Channel Mode",
15558 .info = alc_ch_mode_info,
15559 .get = alc_ch_mode_get,
15560 .put = alc_ch_mode_put,
15565 static struct hda_verb alc662_init_verbs[] = {
15566 /* ADC: mute amp left and right */
15567 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15568 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
15569 /* Front mixer: unmute input/output amp left and right (volume = 0) */
15571 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15572 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15573 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
15574 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
15575 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
15577 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15578 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15579 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15580 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15581 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15582 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15584 /* Front Pin: output 0 (0x0c) */
15585 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15586 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15588 /* Rear Pin: output 1 (0x0d) */
15589 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15590 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15592 /* CLFE Pin: output 2 (0x0e) */
15593 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15594 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15596 /* Mic (rear) pin: input vref at 80% */
15597 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
15598 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15599 /* Front Mic pin: input vref at 80% */
15600 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
15601 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15602 /* Line In pin: input */
15603 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15604 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15605 /* Line-2 In: Headphone output (output 0 - 0x0c) */
15606 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15607 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15608 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
15609 /* CD pin widget for input */
15610 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15612 /* FIXME: use matrix-type input source selection */
15613 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
15615 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15616 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15617 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
15618 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
15620 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15621 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15622 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
15623 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
15625 /* always trun on EAPD */
15626 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
15627 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
15632 static struct hda_verb alc662_sue_init_verbs[] = {
15633 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
15634 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
15638 static struct hda_verb alc662_eeepc_sue_init_verbs[] = {
15639 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15640 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15644 /* Set Unsolicited Event*/
15645 static struct hda_verb alc662_eeepc_ep20_sue_init_verbs[] = {
15646 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15647 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15652 * generic initialization of ADC, input mixers and output mixers
15654 static struct hda_verb alc662_auto_init_verbs[] = {
15656 * Unmute ADC and set the default input to mic-in
15658 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
15659 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15661 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
15663 * Note: PASD motherboards uses the Line In 2 as the input for front
15664 * panel mic (mic 2)
15666 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
15667 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15668 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15669 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
15670 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
15671 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
15674 * Set up output mixers (0x0c - 0x0f)
15676 /* set vol=0 to output mixers */
15677 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15678 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15679 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15681 /* set up input amps for analog loopback */
15682 /* Amp Indices: DAC = 0, mixer = 1 */
15683 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15684 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15685 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15686 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15687 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15688 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15691 /* FIXME: use matrix-type input source selection */
15692 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
15694 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15695 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15699 /* additional verbs for ALC663 */
15700 static struct hda_verb alc663_auto_init_verbs[] = {
15701 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15702 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15706 static struct hda_verb alc663_m51va_init_verbs[] = {
15707 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15708 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15709 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15710 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15711 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
15712 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15713 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
15714 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15715 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15719 static struct hda_verb alc663_21jd_amic_init_verbs[] = {
15720 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15721 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15722 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
15723 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15724 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15725 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15726 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15730 static struct hda_verb alc662_1bjd_amic_init_verbs[] = {
15731 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15732 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15733 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15734 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
15735 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15736 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15737 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15738 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15742 static struct hda_verb alc663_15jd_amic_init_verbs[] = {
15743 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15744 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15745 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
15746 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15747 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15748 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15749 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15753 static struct hda_verb alc663_two_hp_amic_m1_init_verbs[] = {
15754 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15755 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15756 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15757 {0x21, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
15758 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15759 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15760 {0x15, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
15761 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15762 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15763 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15764 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15765 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15769 static struct hda_verb alc663_two_hp_amic_m2_init_verbs[] = {
15770 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15771 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15772 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15773 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
15774 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15775 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15776 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
15777 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15778 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15779 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15780 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15781 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15785 static struct hda_verb alc663_g71v_init_verbs[] = {
15786 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15787 /* {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
15788 /* {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, */ /* Headphone */
15790 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15791 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15792 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
15794 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
15795 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_MIC_EVENT},
15796 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
15800 static struct hda_verb alc663_g50v_init_verbs[] = {
15801 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15802 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15803 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
15805 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15806 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15810 static struct hda_verb alc662_ecs_init_verbs[] = {
15811 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0x701f},
15812 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15813 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15814 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15818 static struct snd_kcontrol_new alc662_auto_capture_mixer[] = {
15819 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
15820 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
15824 static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
15826 unsigned int present;
15827 unsigned char bits;
15829 present = snd_hda_codec_read(codec, 0x14, 0,
15830 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
15831 bits = present ? HDA_AMP_MUTE : 0;
15832 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
15833 HDA_AMP_MUTE, bits);
15836 static void alc662_lenovo_101e_all_automute(struct hda_codec *codec)
15838 unsigned int present;
15839 unsigned char bits;
15841 present = snd_hda_codec_read(codec, 0x1b, 0,
15842 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
15843 bits = present ? HDA_AMP_MUTE : 0;
15844 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
15845 HDA_AMP_MUTE, bits);
15846 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
15847 HDA_AMP_MUTE, bits);
15850 static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec,
15853 if ((res >> 26) == ALC880_HP_EVENT)
15854 alc662_lenovo_101e_all_automute(codec);
15855 if ((res >> 26) == ALC880_FRONT_EVENT)
15856 alc662_lenovo_101e_ispeaker_automute(codec);
15859 static void alc662_eeepc_mic_automute(struct hda_codec *codec)
15861 unsigned int present;
15863 present = snd_hda_codec_read(codec, 0x18, 0,
15864 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
15865 snd_hda_codec_write(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
15866 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
15867 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
15868 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
15869 snd_hda_codec_write(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
15870 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
15871 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
15872 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
15875 /* unsolicited event for HP jack sensing */
15876 static void alc662_eeepc_unsol_event(struct hda_codec *codec,
15879 if ((res >> 26) == ALC880_HP_EVENT)
15880 alc262_hippo1_automute( codec );
15882 if ((res >> 26) == ALC880_MIC_EVENT)
15883 alc662_eeepc_mic_automute(codec);
15886 static void alc662_eeepc_inithook(struct hda_codec *codec)
15888 alc262_hippo1_automute( codec );
15889 alc662_eeepc_mic_automute(codec);
15892 static void alc662_eeepc_ep20_automute(struct hda_codec *codec)
15895 unsigned int present;
15897 snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
15898 present = snd_hda_codec_read(codec, 0x14, 0,
15899 AC_VERB_GET_PIN_SENSE, 0);
15900 present = (present & 0x80000000) != 0;
15902 /* mute internal speaker */
15903 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
15904 HDA_AMP_MUTE, HDA_AMP_MUTE);
15906 /* unmute internal speaker if necessary */
15907 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
15908 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
15909 HDA_AMP_MUTE, mute);
15913 /* unsolicited event for HP jack sensing */
15914 static void alc662_eeepc_ep20_unsol_event(struct hda_codec *codec,
15917 if ((res >> 26) == ALC880_HP_EVENT)
15918 alc662_eeepc_ep20_automute(codec);
15921 static void alc662_eeepc_ep20_inithook(struct hda_codec *codec)
15923 alc662_eeepc_ep20_automute(codec);
15926 static void alc663_m51va_speaker_automute(struct hda_codec *codec)
15928 unsigned int present;
15929 unsigned char bits;
15931 present = snd_hda_codec_read(codec, 0x21, 0,
15932 AC_VERB_GET_PIN_SENSE, 0)
15933 & AC_PINSENSE_PRESENCE;
15934 bits = present ? HDA_AMP_MUTE : 0;
15935 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
15936 AMP_IN_MUTE(0), bits);
15937 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
15938 AMP_IN_MUTE(0), bits);
15941 static void alc663_21jd_two_speaker_automute(struct hda_codec *codec)
15943 unsigned int present;
15944 unsigned char bits;
15946 present = snd_hda_codec_read(codec, 0x21, 0,
15947 AC_VERB_GET_PIN_SENSE, 0)
15948 & AC_PINSENSE_PRESENCE;
15949 bits = present ? HDA_AMP_MUTE : 0;
15950 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
15951 AMP_IN_MUTE(0), bits);
15952 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
15953 AMP_IN_MUTE(0), bits);
15954 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0,
15955 AMP_IN_MUTE(0), bits);
15956 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
15957 AMP_IN_MUTE(0), bits);
15960 static void alc663_15jd_two_speaker_automute(struct hda_codec *codec)
15962 unsigned int present;
15963 unsigned char bits;
15965 present = snd_hda_codec_read(codec, 0x15, 0,
15966 AC_VERB_GET_PIN_SENSE, 0)
15967 & AC_PINSENSE_PRESENCE;
15968 bits = present ? HDA_AMP_MUTE : 0;
15969 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
15970 AMP_IN_MUTE(0), bits);
15971 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
15972 AMP_IN_MUTE(0), bits);
15973 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0,
15974 AMP_IN_MUTE(0), bits);
15975 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
15976 AMP_IN_MUTE(0), bits);
15979 static void alc662_f5z_speaker_automute(struct hda_codec *codec)
15981 unsigned int present;
15982 unsigned char bits;
15984 present = snd_hda_codec_read(codec, 0x1b, 0,
15985 AC_VERB_GET_PIN_SENSE, 0)
15986 & AC_PINSENSE_PRESENCE;
15987 bits = present ? 0 : PIN_OUT;
15988 snd_hda_codec_write(codec, 0x14, 0,
15989 AC_VERB_SET_PIN_WIDGET_CONTROL, bits);
15992 static void alc663_two_hp_m1_speaker_automute(struct hda_codec *codec)
15994 unsigned int present1, present2;
15996 present1 = snd_hda_codec_read(codec, 0x21, 0,
15997 AC_VERB_GET_PIN_SENSE, 0)
15998 & AC_PINSENSE_PRESENCE;
15999 present2 = snd_hda_codec_read(codec, 0x15, 0,
16000 AC_VERB_GET_PIN_SENSE, 0)
16001 & AC_PINSENSE_PRESENCE;
16003 if (present1 || present2) {
16004 snd_hda_codec_write_cache(codec, 0x14, 0,
16005 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
16007 snd_hda_codec_write_cache(codec, 0x14, 0,
16008 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
16012 static void alc663_two_hp_m2_speaker_automute(struct hda_codec *codec)
16014 unsigned int present1, present2;
16016 present1 = snd_hda_codec_read(codec, 0x1b, 0,
16017 AC_VERB_GET_PIN_SENSE, 0)
16018 & AC_PINSENSE_PRESENCE;
16019 present2 = snd_hda_codec_read(codec, 0x15, 0,
16020 AC_VERB_GET_PIN_SENSE, 0)
16021 & AC_PINSENSE_PRESENCE;
16023 if (present1 || present2) {
16024 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
16025 AMP_IN_MUTE(0), AMP_IN_MUTE(0));
16026 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
16027 AMP_IN_MUTE(0), AMP_IN_MUTE(0));
16029 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
16030 AMP_IN_MUTE(0), 0);
16031 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
16032 AMP_IN_MUTE(0), 0);
16036 static void alc663_m51va_mic_automute(struct hda_codec *codec)
16038 unsigned int present;
16040 present = snd_hda_codec_read(codec, 0x18, 0,
16041 AC_VERB_GET_PIN_SENSE, 0)
16042 & AC_PINSENSE_PRESENCE;
16043 snd_hda_codec_write_cache(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
16044 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
16045 snd_hda_codec_write_cache(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
16046 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
16047 snd_hda_codec_write_cache(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
16048 0x7000 | (0x09 << 8) | (present ? 0x80 : 0));
16049 snd_hda_codec_write_cache(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
16050 0x7000 | (0x09 << 8) | (present ? 0x80 : 0));
16053 static void alc663_m51va_unsol_event(struct hda_codec *codec,
16056 switch (res >> 26) {
16057 case ALC880_HP_EVENT:
16058 alc663_m51va_speaker_automute(codec);
16060 case ALC880_MIC_EVENT:
16061 alc663_m51va_mic_automute(codec);
16066 static void alc663_m51va_inithook(struct hda_codec *codec)
16068 alc663_m51va_speaker_automute(codec);
16069 alc663_m51va_mic_automute(codec);
16072 /* ***************** Mode1 ******************************/
16073 static void alc663_mode1_unsol_event(struct hda_codec *codec,
16076 switch (res >> 26) {
16077 case ALC880_HP_EVENT:
16078 alc663_m51va_speaker_automute(codec);
16080 case ALC880_MIC_EVENT:
16081 alc662_eeepc_mic_automute(codec);
16086 static void alc663_mode1_inithook(struct hda_codec *codec)
16088 alc663_m51va_speaker_automute(codec);
16089 alc662_eeepc_mic_automute(codec);
16091 /* ***************** Mode2 ******************************/
16092 static void alc662_mode2_unsol_event(struct hda_codec *codec,
16095 switch (res >> 26) {
16096 case ALC880_HP_EVENT:
16097 alc662_f5z_speaker_automute(codec);
16099 case ALC880_MIC_EVENT:
16100 alc662_eeepc_mic_automute(codec);
16105 static void alc662_mode2_inithook(struct hda_codec *codec)
16107 alc662_f5z_speaker_automute(codec);
16108 alc662_eeepc_mic_automute(codec);
16110 /* ***************** Mode3 ******************************/
16111 static void alc663_mode3_unsol_event(struct hda_codec *codec,
16114 switch (res >> 26) {
16115 case ALC880_HP_EVENT:
16116 alc663_two_hp_m1_speaker_automute(codec);
16118 case ALC880_MIC_EVENT:
16119 alc662_eeepc_mic_automute(codec);
16124 static void alc663_mode3_inithook(struct hda_codec *codec)
16126 alc663_two_hp_m1_speaker_automute(codec);
16127 alc662_eeepc_mic_automute(codec);
16129 /* ***************** Mode4 ******************************/
16130 static void alc663_mode4_unsol_event(struct hda_codec *codec,
16133 switch (res >> 26) {
16134 case ALC880_HP_EVENT:
16135 alc663_21jd_two_speaker_automute(codec);
16137 case ALC880_MIC_EVENT:
16138 alc662_eeepc_mic_automute(codec);
16143 static void alc663_mode4_inithook(struct hda_codec *codec)
16145 alc663_21jd_two_speaker_automute(codec);
16146 alc662_eeepc_mic_automute(codec);
16148 /* ***************** Mode5 ******************************/
16149 static void alc663_mode5_unsol_event(struct hda_codec *codec,
16152 switch (res >> 26) {
16153 case ALC880_HP_EVENT:
16154 alc663_15jd_two_speaker_automute(codec);
16156 case ALC880_MIC_EVENT:
16157 alc662_eeepc_mic_automute(codec);
16162 static void alc663_mode5_inithook(struct hda_codec *codec)
16164 alc663_15jd_two_speaker_automute(codec);
16165 alc662_eeepc_mic_automute(codec);
16167 /* ***************** Mode6 ******************************/
16168 static void alc663_mode6_unsol_event(struct hda_codec *codec,
16171 switch (res >> 26) {
16172 case ALC880_HP_EVENT:
16173 alc663_two_hp_m2_speaker_automute(codec);
16175 case ALC880_MIC_EVENT:
16176 alc662_eeepc_mic_automute(codec);
16181 static void alc663_mode6_inithook(struct hda_codec *codec)
16183 alc663_two_hp_m2_speaker_automute(codec);
16184 alc662_eeepc_mic_automute(codec);
16187 static void alc663_g71v_hp_automute(struct hda_codec *codec)
16189 unsigned int present;
16190 unsigned char bits;
16192 present = snd_hda_codec_read(codec, 0x21, 0,
16193 AC_VERB_GET_PIN_SENSE, 0)
16194 & AC_PINSENSE_PRESENCE;
16195 bits = present ? HDA_AMP_MUTE : 0;
16196 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
16197 HDA_AMP_MUTE, bits);
16198 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
16199 HDA_AMP_MUTE, bits);
16202 static void alc663_g71v_front_automute(struct hda_codec *codec)
16204 unsigned int present;
16205 unsigned char bits;
16207 present = snd_hda_codec_read(codec, 0x15, 0,
16208 AC_VERB_GET_PIN_SENSE, 0)
16209 & AC_PINSENSE_PRESENCE;
16210 bits = present ? HDA_AMP_MUTE : 0;
16211 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
16212 HDA_AMP_MUTE, bits);
16215 static void alc663_g71v_unsol_event(struct hda_codec *codec,
16218 switch (res >> 26) {
16219 case ALC880_HP_EVENT:
16220 alc663_g71v_hp_automute(codec);
16222 case ALC880_FRONT_EVENT:
16223 alc663_g71v_front_automute(codec);
16225 case ALC880_MIC_EVENT:
16226 alc662_eeepc_mic_automute(codec);
16231 static void alc663_g71v_inithook(struct hda_codec *codec)
16233 alc663_g71v_front_automute(codec);
16234 alc663_g71v_hp_automute(codec);
16235 alc662_eeepc_mic_automute(codec);
16238 static void alc663_g50v_unsol_event(struct hda_codec *codec,
16241 switch (res >> 26) {
16242 case ALC880_HP_EVENT:
16243 alc663_m51va_speaker_automute(codec);
16245 case ALC880_MIC_EVENT:
16246 alc662_eeepc_mic_automute(codec);
16251 static void alc663_g50v_inithook(struct hda_codec *codec)
16253 alc663_m51va_speaker_automute(codec);
16254 alc662_eeepc_mic_automute(codec);
16257 /* bind hp and internal speaker mute (with plug check) */
16258 static int alc662_ecs_master_sw_put(struct snd_kcontrol *kcontrol,
16259 struct snd_ctl_elem_value *ucontrol)
16261 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
16262 long *valp = ucontrol->value.integer.value;
16265 change = snd_hda_codec_amp_update(codec, 0x1b, 0, HDA_OUTPUT, 0,
16267 valp[0] ? 0 : HDA_AMP_MUTE);
16268 change |= snd_hda_codec_amp_update(codec, 0x1b, 1, HDA_OUTPUT, 0,
16270 valp[1] ? 0 : HDA_AMP_MUTE);
16272 alc262_hippo1_automute(codec);
16276 static struct snd_kcontrol_new alc662_ecs_mixer[] = {
16277 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16279 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
16280 .name = "Master Playback Switch",
16281 .info = snd_hda_mixer_amp_switch_info,
16282 .get = snd_hda_mixer_amp_switch_get,
16283 .put = alc662_ecs_master_sw_put,
16284 .private_value = HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
16287 HDA_CODEC_VOLUME("e-Mic/LineIn Boost", 0x18, 0, HDA_INPUT),
16288 HDA_CODEC_VOLUME("e-Mic/LineIn Playback Volume", 0x0b, 0x0, HDA_INPUT),
16289 HDA_CODEC_MUTE("e-Mic/LineIn Playback Switch", 0x0b, 0x0, HDA_INPUT),
16291 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
16292 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16293 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16297 #ifdef CONFIG_SND_HDA_POWER_SAVE
16298 #define alc662_loopbacks alc880_loopbacks
16302 /* pcm configuration: identiacal with ALC880 */
16303 #define alc662_pcm_analog_playback alc880_pcm_analog_playback
16304 #define alc662_pcm_analog_capture alc880_pcm_analog_capture
16305 #define alc662_pcm_digital_playback alc880_pcm_digital_playback
16306 #define alc662_pcm_digital_capture alc880_pcm_digital_capture
16309 * configuration and preset
16311 static const char *alc662_models[ALC662_MODEL_LAST] = {
16312 [ALC662_3ST_2ch_DIG] = "3stack-dig",
16313 [ALC662_3ST_6ch_DIG] = "3stack-6ch-dig",
16314 [ALC662_3ST_6ch] = "3stack-6ch",
16315 [ALC662_5ST_DIG] = "6stack-dig",
16316 [ALC662_LENOVO_101E] = "lenovo-101e",
16317 [ALC662_ASUS_EEEPC_P701] = "eeepc-p701",
16318 [ALC662_ASUS_EEEPC_EP20] = "eeepc-ep20",
16319 [ALC662_ECS] = "ecs",
16320 [ALC663_ASUS_M51VA] = "m51va",
16321 [ALC663_ASUS_G71V] = "g71v",
16322 [ALC663_ASUS_H13] = "h13",
16323 [ALC663_ASUS_G50V] = "g50v",
16324 [ALC663_ASUS_MODE1] = "asus-mode1",
16325 [ALC662_ASUS_MODE2] = "asus-mode2",
16326 [ALC663_ASUS_MODE3] = "asus-mode3",
16327 [ALC663_ASUS_MODE4] = "asus-mode4",
16328 [ALC663_ASUS_MODE5] = "asus-mode5",
16329 [ALC663_ASUS_MODE6] = "asus-mode6",
16330 [ALC662_AUTO] = "auto",
16333 static struct snd_pci_quirk alc662_cfg_tbl[] = {
16334 SND_PCI_QUIRK(0x1019, 0x9087, "ECS", ALC662_ECS),
16335 SND_PCI_QUIRK(0x1043, 0x1000, "ASUS N50Vm", ALC663_ASUS_MODE1),
16336 SND_PCI_QUIRK(0x1043, 0x1092, "ASUS NB", ALC663_ASUS_MODE3),
16337 SND_PCI_QUIRK(0x1043, 0x11c3, "ASUS M70V", ALC663_ASUS_MODE3),
16338 SND_PCI_QUIRK(0x1043, 0x11d3, "ASUS NB", ALC663_ASUS_MODE1),
16339 SND_PCI_QUIRK(0x1043, 0x11f3, "ASUS NB", ALC662_ASUS_MODE2),
16340 SND_PCI_QUIRK(0x1043, 0x1203, "ASUS NB", ALC663_ASUS_MODE1),
16341 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS NB", ALC662_ASUS_MODE2),
16342 SND_PCI_QUIRK(0x1043, 0x16c3, "ASUS NB", ALC662_ASUS_MODE2),
16343 SND_PCI_QUIRK(0x1043, 0x1753, "ASUS NB", ALC662_ASUS_MODE2),
16344 SND_PCI_QUIRK(0x1043, 0x1763, "ASUS NB", ALC663_ASUS_MODE6),
16345 SND_PCI_QUIRK(0x1043, 0x1765, "ASUS NB", ALC663_ASUS_MODE6),
16346 SND_PCI_QUIRK(0x1043, 0x1783, "ASUS NB", ALC662_ASUS_MODE2),
16347 SND_PCI_QUIRK(0x1043, 0x1813, "ASUS NB", ALC662_ASUS_MODE2),
16348 SND_PCI_QUIRK(0x1043, 0x1823, "ASUS NB", ALC663_ASUS_MODE5),
16349 SND_PCI_QUIRK(0x1043, 0x1833, "ASUS NB", ALC663_ASUS_MODE6),
16350 SND_PCI_QUIRK(0x1043, 0x1843, "ASUS NB", ALC662_ASUS_MODE2),
16351 SND_PCI_QUIRK(0x1043, 0x1864, "ASUS NB", ALC662_ASUS_MODE2),
16352 SND_PCI_QUIRK(0x1043, 0x1876, "ASUS NB", ALC662_ASUS_MODE2),
16353 SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M51VA", ALC663_ASUS_M51VA),
16354 /*SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M50Vr", ALC663_ASUS_MODE1),*/
16355 SND_PCI_QUIRK(0x1043, 0x1893, "ASUS M50Vm", ALC663_ASUS_MODE3),
16356 SND_PCI_QUIRK(0x1043, 0x1894, "ASUS X55", ALC663_ASUS_MODE3),
16357 SND_PCI_QUIRK(0x1043, 0x1903, "ASUS F5GL", ALC663_ASUS_MODE1),
16358 SND_PCI_QUIRK(0x1043, 0x1913, "ASUS NB", ALC662_ASUS_MODE2),
16359 SND_PCI_QUIRK(0x1043, 0x1933, "ASUS F80Q", ALC662_ASUS_MODE2),
16360 SND_PCI_QUIRK(0x1043, 0x1953, "ASUS NB", ALC663_ASUS_MODE1),
16361 SND_PCI_QUIRK(0x1043, 0x1963, "ASUS X71C", ALC663_ASUS_MODE3),
16362 SND_PCI_QUIRK(0x1043, 0x1993, "ASUS N20", ALC663_ASUS_MODE1),
16363 SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS G50V", ALC663_ASUS_G50V),
16364 /*SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS NB", ALC663_ASUS_MODE1),*/
16365 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS F7Z", ALC663_ASUS_MODE1),
16366 SND_PCI_QUIRK(0x1043, 0x19c3, "ASUS F5Z/F6x", ALC662_ASUS_MODE2),
16367 SND_PCI_QUIRK(0x1043, 0x19e3, "ASUS NB", ALC663_ASUS_MODE1),
16368 SND_PCI_QUIRK(0x1043, 0x19f3, "ASUS NB", ALC663_ASUS_MODE4),
16369 SND_PCI_QUIRK(0x1043, 0x8290, "ASUS P5GC-MX", ALC662_3ST_6ch_DIG),
16370 SND_PCI_QUIRK(0x1043, 0x82a1, "ASUS Eeepc", ALC662_ASUS_EEEPC_P701),
16371 SND_PCI_QUIRK(0x1043, 0x82d1, "ASUS Eeepc EP20", ALC662_ASUS_EEEPC_EP20),
16372 SND_PCI_QUIRK(0x105b, 0x0cd6, "Foxconn", ALC662_ECS),
16373 SND_PCI_QUIRK(0x105b, 0x0d47, "Foxconn 45CMX/45GMX/45CMX-K",
16374 ALC662_3ST_6ch_DIG),
16375 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte 945GCM-S2L",
16376 ALC662_3ST_6ch_DIG),
16377 SND_PCI_QUIRK(0x1565, 0x820f, "Biostar TA780G M2+", ALC662_3ST_6ch_DIG),
16378 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E),
16379 SND_PCI_QUIRK(0x1849, 0x3662, "ASROCK K10N78FullHD-hSLI R3.0",
16380 ALC662_3ST_6ch_DIG),
16381 SND_PCI_QUIRK_MASK(0x1854, 0xf000, 0x2000, "ASUS H13-200x",
16386 static struct alc_config_preset alc662_presets[] = {
16387 [ALC662_3ST_2ch_DIG] = {
16388 .mixers = { alc662_3ST_2ch_mixer },
16389 .init_verbs = { alc662_init_verbs },
16390 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16391 .dac_nids = alc662_dac_nids,
16392 .dig_out_nid = ALC662_DIGOUT_NID,
16393 .dig_in_nid = ALC662_DIGIN_NID,
16394 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16395 .channel_mode = alc662_3ST_2ch_modes,
16396 .input_mux = &alc662_capture_source,
16398 [ALC662_3ST_6ch_DIG] = {
16399 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
16400 .init_verbs = { alc662_init_verbs },
16401 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16402 .dac_nids = alc662_dac_nids,
16403 .dig_out_nid = ALC662_DIGOUT_NID,
16404 .dig_in_nid = ALC662_DIGIN_NID,
16405 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
16406 .channel_mode = alc662_3ST_6ch_modes,
16408 .input_mux = &alc662_capture_source,
16410 [ALC662_3ST_6ch] = {
16411 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
16412 .init_verbs = { alc662_init_verbs },
16413 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16414 .dac_nids = alc662_dac_nids,
16415 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
16416 .channel_mode = alc662_3ST_6ch_modes,
16418 .input_mux = &alc662_capture_source,
16420 [ALC662_5ST_DIG] = {
16421 .mixers = { alc662_base_mixer, alc662_chmode_mixer },
16422 .init_verbs = { alc662_init_verbs },
16423 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16424 .dac_nids = alc662_dac_nids,
16425 .dig_out_nid = ALC662_DIGOUT_NID,
16426 .dig_in_nid = ALC662_DIGIN_NID,
16427 .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes),
16428 .channel_mode = alc662_5stack_modes,
16429 .input_mux = &alc662_capture_source,
16431 [ALC662_LENOVO_101E] = {
16432 .mixers = { alc662_lenovo_101e_mixer },
16433 .init_verbs = { alc662_init_verbs, alc662_sue_init_verbs },
16434 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16435 .dac_nids = alc662_dac_nids,
16436 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16437 .channel_mode = alc662_3ST_2ch_modes,
16438 .input_mux = &alc662_lenovo_101e_capture_source,
16439 .unsol_event = alc662_lenovo_101e_unsol_event,
16440 .init_hook = alc662_lenovo_101e_all_automute,
16442 [ALC662_ASUS_EEEPC_P701] = {
16443 .mixers = { alc662_eeepc_p701_mixer },
16444 .init_verbs = { alc662_init_verbs,
16445 alc662_eeepc_sue_init_verbs },
16446 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16447 .dac_nids = alc662_dac_nids,
16448 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16449 .channel_mode = alc662_3ST_2ch_modes,
16450 .input_mux = &alc662_eeepc_capture_source,
16451 .unsol_event = alc662_eeepc_unsol_event,
16452 .init_hook = alc662_eeepc_inithook,
16454 [ALC662_ASUS_EEEPC_EP20] = {
16455 .mixers = { alc662_eeepc_ep20_mixer,
16456 alc662_chmode_mixer },
16457 .init_verbs = { alc662_init_verbs,
16458 alc662_eeepc_ep20_sue_init_verbs },
16459 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16460 .dac_nids = alc662_dac_nids,
16461 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
16462 .channel_mode = alc662_3ST_6ch_modes,
16463 .input_mux = &alc662_lenovo_101e_capture_source,
16464 .unsol_event = alc662_eeepc_ep20_unsol_event,
16465 .init_hook = alc662_eeepc_ep20_inithook,
16468 .mixers = { alc662_ecs_mixer },
16469 .init_verbs = { alc662_init_verbs,
16470 alc662_ecs_init_verbs },
16471 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16472 .dac_nids = alc662_dac_nids,
16473 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16474 .channel_mode = alc662_3ST_2ch_modes,
16475 .input_mux = &alc662_eeepc_capture_source,
16476 .unsol_event = alc662_eeepc_unsol_event,
16477 .init_hook = alc662_eeepc_inithook,
16479 [ALC663_ASUS_M51VA] = {
16480 .mixers = { alc663_m51va_mixer },
16481 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
16482 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16483 .dac_nids = alc662_dac_nids,
16484 .dig_out_nid = ALC662_DIGOUT_NID,
16485 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16486 .channel_mode = alc662_3ST_2ch_modes,
16487 .input_mux = &alc663_m51va_capture_source,
16488 .unsol_event = alc663_m51va_unsol_event,
16489 .init_hook = alc663_m51va_inithook,
16491 [ALC663_ASUS_G71V] = {
16492 .mixers = { alc663_g71v_mixer },
16493 .init_verbs = { alc662_init_verbs, alc663_g71v_init_verbs },
16494 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16495 .dac_nids = alc662_dac_nids,
16496 .dig_out_nid = ALC662_DIGOUT_NID,
16497 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16498 .channel_mode = alc662_3ST_2ch_modes,
16499 .input_mux = &alc662_eeepc_capture_source,
16500 .unsol_event = alc663_g71v_unsol_event,
16501 .init_hook = alc663_g71v_inithook,
16503 [ALC663_ASUS_H13] = {
16504 .mixers = { alc663_m51va_mixer },
16505 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
16506 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16507 .dac_nids = alc662_dac_nids,
16508 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16509 .channel_mode = alc662_3ST_2ch_modes,
16510 .input_mux = &alc663_m51va_capture_source,
16511 .unsol_event = alc663_m51va_unsol_event,
16512 .init_hook = alc663_m51va_inithook,
16514 [ALC663_ASUS_G50V] = {
16515 .mixers = { alc663_g50v_mixer },
16516 .init_verbs = { alc662_init_verbs, alc663_g50v_init_verbs },
16517 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16518 .dac_nids = alc662_dac_nids,
16519 .dig_out_nid = ALC662_DIGOUT_NID,
16520 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
16521 .channel_mode = alc662_3ST_6ch_modes,
16522 .input_mux = &alc663_capture_source,
16523 .unsol_event = alc663_g50v_unsol_event,
16524 .init_hook = alc663_g50v_inithook,
16526 [ALC663_ASUS_MODE1] = {
16527 .mixers = { alc663_m51va_mixer },
16528 .cap_mixer = alc662_auto_capture_mixer,
16529 .init_verbs = { alc662_init_verbs,
16530 alc663_21jd_amic_init_verbs },
16531 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16533 .dac_nids = alc662_dac_nids,
16534 .dig_out_nid = ALC662_DIGOUT_NID,
16535 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16536 .channel_mode = alc662_3ST_2ch_modes,
16537 .input_mux = &alc662_eeepc_capture_source,
16538 .unsol_event = alc663_mode1_unsol_event,
16539 .init_hook = alc663_mode1_inithook,
16541 [ALC662_ASUS_MODE2] = {
16542 .mixers = { alc662_1bjd_mixer },
16543 .cap_mixer = alc662_auto_capture_mixer,
16544 .init_verbs = { alc662_init_verbs,
16545 alc662_1bjd_amic_init_verbs },
16546 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16547 .dac_nids = alc662_dac_nids,
16548 .dig_out_nid = ALC662_DIGOUT_NID,
16549 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16550 .channel_mode = alc662_3ST_2ch_modes,
16551 .input_mux = &alc662_eeepc_capture_source,
16552 .unsol_event = alc662_mode2_unsol_event,
16553 .init_hook = alc662_mode2_inithook,
16555 [ALC663_ASUS_MODE3] = {
16556 .mixers = { alc663_two_hp_m1_mixer },
16557 .cap_mixer = alc662_auto_capture_mixer,
16558 .init_verbs = { alc662_init_verbs,
16559 alc663_two_hp_amic_m1_init_verbs },
16560 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16562 .dac_nids = alc662_dac_nids,
16563 .dig_out_nid = ALC662_DIGOUT_NID,
16564 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16565 .channel_mode = alc662_3ST_2ch_modes,
16566 .input_mux = &alc662_eeepc_capture_source,
16567 .unsol_event = alc663_mode3_unsol_event,
16568 .init_hook = alc663_mode3_inithook,
16570 [ALC663_ASUS_MODE4] = {
16571 .mixers = { alc663_asus_21jd_clfe_mixer },
16572 .cap_mixer = alc662_auto_capture_mixer,
16573 .init_verbs = { alc662_init_verbs,
16574 alc663_21jd_amic_init_verbs},
16575 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16577 .dac_nids = alc662_dac_nids,
16578 .dig_out_nid = ALC662_DIGOUT_NID,
16579 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16580 .channel_mode = alc662_3ST_2ch_modes,
16581 .input_mux = &alc662_eeepc_capture_source,
16582 .unsol_event = alc663_mode4_unsol_event,
16583 .init_hook = alc663_mode4_inithook,
16585 [ALC663_ASUS_MODE5] = {
16586 .mixers = { alc663_asus_15jd_clfe_mixer },
16587 .cap_mixer = alc662_auto_capture_mixer,
16588 .init_verbs = { alc662_init_verbs,
16589 alc663_15jd_amic_init_verbs },
16590 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16592 .dac_nids = alc662_dac_nids,
16593 .dig_out_nid = ALC662_DIGOUT_NID,
16594 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16595 .channel_mode = alc662_3ST_2ch_modes,
16596 .input_mux = &alc662_eeepc_capture_source,
16597 .unsol_event = alc663_mode5_unsol_event,
16598 .init_hook = alc663_mode5_inithook,
16600 [ALC663_ASUS_MODE6] = {
16601 .mixers = { alc663_two_hp_m2_mixer },
16602 .cap_mixer = alc662_auto_capture_mixer,
16603 .init_verbs = { alc662_init_verbs,
16604 alc663_two_hp_amic_m2_init_verbs },
16605 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16607 .dac_nids = alc662_dac_nids,
16608 .dig_out_nid = ALC662_DIGOUT_NID,
16609 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16610 .channel_mode = alc662_3ST_2ch_modes,
16611 .input_mux = &alc662_eeepc_capture_source,
16612 .unsol_event = alc663_mode6_unsol_event,
16613 .init_hook = alc663_mode6_inithook,
16619 * BIOS auto configuration
16622 /* add playback controls from the parsed DAC table */
16623 static int alc662_auto_create_multi_out_ctls(struct alc_spec *spec,
16624 const struct auto_pin_cfg *cfg)
16627 static const char *chname[4] = {
16628 "Front", "Surround", NULL /*CLFE*/, "Side"
16633 for (i = 0; i < cfg->line_outs; i++) {
16634 if (!spec->multiout.dac_nids[i])
16636 nid = alc880_idx_to_dac(i);
16639 err = add_control(spec, ALC_CTL_WIDGET_VOL,
16640 "Center Playback Volume",
16641 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
16645 err = add_control(spec, ALC_CTL_WIDGET_VOL,
16646 "LFE Playback Volume",
16647 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
16651 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
16652 "Center Playback Switch",
16653 HDA_COMPOSE_AMP_VAL(0x0e, 1, 0,
16657 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
16658 "LFE Playback Switch",
16659 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
16664 sprintf(name, "%s Playback Volume", chname[i]);
16665 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
16666 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
16670 sprintf(name, "%s Playback Switch", chname[i]);
16671 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
16672 HDA_COMPOSE_AMP_VAL(alc880_idx_to_mixer(i),
16681 /* add playback controls for speaker and HP outputs */
16682 static int alc662_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
16693 /* ALC663 has a mono output pin on 0x17 */
16694 sprintf(name, "%s Playback Switch", pfx);
16695 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
16696 HDA_COMPOSE_AMP_VAL(pin, 2, 0, HDA_OUTPUT));
16700 if (alc880_is_fixed_pin(pin)) {
16701 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
16702 /* printk(KERN_DEBUG "DAC nid=%x\n",nid); */
16703 /* specify the DAC as the extra output */
16704 if (!spec->multiout.hp_nid)
16705 spec->multiout.hp_nid = nid;
16707 spec->multiout.extra_out_nid[0] = nid;
16708 /* control HP volume/switch on the output mixer amp */
16709 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
16710 sprintf(name, "%s Playback Volume", pfx);
16711 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
16712 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
16715 sprintf(name, "%s Playback Switch", pfx);
16716 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
16717 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
16720 } else if (alc880_is_multi_pin(pin)) {
16721 /* set manual connection */
16722 /* we have only a switch on HP-out PIN */
16723 sprintf(name, "%s Playback Switch", pfx);
16724 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
16725 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
16732 /* return the index of the src widget from the connection list of the nid.
16733 * return -1 if not found
16735 static int alc662_input_pin_idx(struct hda_codec *codec, hda_nid_t nid,
16738 hda_nid_t conn_list[HDA_MAX_CONNECTIONS];
16741 conns = snd_hda_get_connections(codec, nid, conn_list,
16742 ARRAY_SIZE(conn_list));
16745 for (i = 0; i < conns; i++)
16746 if (conn_list[i] == src)
16751 static int alc662_is_input_pin(struct hda_codec *codec, hda_nid_t nid)
16753 unsigned int pincap = snd_hda_query_pin_caps(codec, nid);
16754 return (pincap & AC_PINCAP_IN) != 0;
16757 /* create playback/capture controls for input pins */
16758 static int alc662_auto_create_analog_input_ctls(struct hda_codec *codec,
16759 const struct auto_pin_cfg *cfg)
16761 struct alc_spec *spec = codec->spec;
16762 struct hda_input_mux *imux = &spec->private_imux[0];
16765 for (i = 0; i < AUTO_PIN_LAST; i++) {
16766 if (alc662_is_input_pin(codec, cfg->input_pins[i])) {
16767 idx = alc662_input_pin_idx(codec, 0x0b,
16768 cfg->input_pins[i]);
16770 err = new_analog_input(spec, cfg->input_pins[i],
16771 auto_pin_cfg_labels[i],
16776 idx = alc662_input_pin_idx(codec, 0x22,
16777 cfg->input_pins[i]);
16779 imux->items[imux->num_items].label =
16780 auto_pin_cfg_labels[i];
16781 imux->items[imux->num_items].index = idx;
16789 static void alc662_auto_set_output_and_unmute(struct hda_codec *codec,
16790 hda_nid_t nid, int pin_type,
16793 alc_set_pin_output(codec, nid, pin_type);
16794 /* need the manual connection? */
16795 if (alc880_is_multi_pin(nid)) {
16796 struct alc_spec *spec = codec->spec;
16797 int idx = alc880_multi_pin_idx(nid);
16798 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
16799 AC_VERB_SET_CONNECT_SEL,
16800 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
16804 static void alc662_auto_init_multi_out(struct hda_codec *codec)
16806 struct alc_spec *spec = codec->spec;
16809 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
16810 for (i = 0; i <= HDA_SIDE; i++) {
16811 hda_nid_t nid = spec->autocfg.line_out_pins[i];
16812 int pin_type = get_pin_type(spec->autocfg.line_out_type);
16814 alc662_auto_set_output_and_unmute(codec, nid, pin_type,
16819 static void alc662_auto_init_hp_out(struct hda_codec *codec)
16821 struct alc_spec *spec = codec->spec;
16824 pin = spec->autocfg.hp_pins[0];
16825 if (pin) /* connect to front */
16827 alc662_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
16828 pin = spec->autocfg.speaker_pins[0];
16830 alc662_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
16833 #define ALC662_PIN_CD_NID ALC880_PIN_CD_NID
16835 static void alc662_auto_init_analog_input(struct hda_codec *codec)
16837 struct alc_spec *spec = codec->spec;
16840 for (i = 0; i < AUTO_PIN_LAST; i++) {
16841 hda_nid_t nid = spec->autocfg.input_pins[i];
16842 if (alc662_is_input_pin(codec, nid)) {
16843 alc_set_input_pin(codec, nid, i);
16844 if (nid != ALC662_PIN_CD_NID &&
16845 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
16846 snd_hda_codec_write(codec, nid, 0,
16847 AC_VERB_SET_AMP_GAIN_MUTE,
16853 #define alc662_auto_init_input_src alc882_auto_init_input_src
16855 static int alc662_parse_auto_config(struct hda_codec *codec)
16857 struct alc_spec *spec = codec->spec;
16859 static hda_nid_t alc662_ignore[] = { 0x1d, 0 };
16861 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
16865 if (!spec->autocfg.line_outs)
16866 return 0; /* can't find valid BIOS pin config */
16868 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
16871 err = alc662_auto_create_multi_out_ctls(spec, &spec->autocfg);
16874 err = alc662_auto_create_extra_out(spec,
16875 spec->autocfg.speaker_pins[0],
16879 err = alc662_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
16883 err = alc662_auto_create_analog_input_ctls(codec, &spec->autocfg);
16887 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
16889 if (spec->autocfg.dig_outs)
16890 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
16892 if (spec->kctls.list)
16893 add_mixer(spec, spec->kctls.list);
16895 spec->num_mux_defs = 1;
16896 spec->input_mux = &spec->private_imux[0];
16898 add_verb(spec, alc662_auto_init_verbs);
16899 if (codec->vendor_id == 0x10ec0663)
16900 add_verb(spec, alc663_auto_init_verbs);
16902 err = alc_auto_add_mic_boost(codec);
16909 /* additional initialization for auto-configuration model */
16910 static void alc662_auto_init(struct hda_codec *codec)
16912 struct alc_spec *spec = codec->spec;
16913 alc662_auto_init_multi_out(codec);
16914 alc662_auto_init_hp_out(codec);
16915 alc662_auto_init_analog_input(codec);
16916 alc662_auto_init_input_src(codec);
16917 if (spec->unsol_event)
16918 alc_inithook(codec);
16921 static int patch_alc662(struct hda_codec *codec)
16923 struct alc_spec *spec;
16924 int err, board_config;
16926 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
16930 codec->spec = spec;
16932 alc_fix_pll_init(codec, 0x20, 0x04, 15);
16934 board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST,
16937 if (board_config < 0) {
16938 printk(KERN_INFO "hda_codec: Unknown model for ALC662, "
16939 "trying auto-probe from BIOS...\n");
16940 board_config = ALC662_AUTO;
16943 if (board_config == ALC662_AUTO) {
16944 /* automatic parse from the BIOS config */
16945 err = alc662_parse_auto_config(codec);
16951 "hda_codec: Cannot set up configuration "
16952 "from BIOS. Using base mode...\n");
16953 board_config = ALC662_3ST_2ch_DIG;
16957 err = snd_hda_attach_beep_device(codec, 0x1);
16963 if (board_config != ALC662_AUTO)
16964 setup_preset(spec, &alc662_presets[board_config]);
16966 if (codec->vendor_id == 0x10ec0663) {
16967 spec->stream_name_analog = "ALC663 Analog";
16968 spec->stream_name_digital = "ALC663 Digital";
16969 } else if (codec->vendor_id == 0x10ec0272) {
16970 spec->stream_name_analog = "ALC272 Analog";
16971 spec->stream_name_digital = "ALC272 Digital";
16973 spec->stream_name_analog = "ALC662 Analog";
16974 spec->stream_name_digital = "ALC662 Digital";
16977 spec->stream_analog_playback = &alc662_pcm_analog_playback;
16978 spec->stream_analog_capture = &alc662_pcm_analog_capture;
16980 spec->stream_digital_playback = &alc662_pcm_digital_playback;
16981 spec->stream_digital_capture = &alc662_pcm_digital_capture;
16983 spec->adc_nids = alc662_adc_nids;
16984 spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids);
16985 spec->capsrc_nids = alc662_capsrc_nids;
16986 spec->capture_style = CAPT_MIX;
16988 if (!spec->cap_mixer)
16989 set_capture_mixer(spec);
16990 if (codec->vendor_id == 0x10ec0662)
16991 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
16993 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
16995 spec->vmaster_nid = 0x02;
16997 codec->patch_ops = alc_patch_ops;
16998 if (board_config == ALC662_AUTO)
16999 spec->init_hook = alc662_auto_init;
17000 #ifdef CONFIG_SND_HDA_POWER_SAVE
17001 if (!spec->loopback.amplist)
17002 spec->loopback.amplist = alc662_loopbacks;
17004 codec->proc_widget_hook = print_realtek_coef;
17012 static struct hda_codec_preset snd_hda_preset_realtek[] = {
17013 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
17014 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
17015 { .id = 0x10ec0267, .name = "ALC267", .patch = patch_alc268 },
17016 { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 },
17017 { .id = 0x10ec0269, .name = "ALC269", .patch = patch_alc269 },
17018 { .id = 0x10ec0272, .name = "ALC272", .patch = patch_alc662 },
17019 { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
17020 .patch = patch_alc861 },
17021 { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
17022 { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
17023 { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
17024 { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2",
17025 .patch = patch_alc883 },
17026 { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
17027 .patch = patch_alc662 },
17028 { .id = 0x10ec0663, .name = "ALC663", .patch = patch_alc662 },
17029 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
17030 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
17031 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc883 },
17032 { .id = 0x10ec0885, .rev = 0x100101, .name = "ALC889A",
17033 .patch = patch_alc882 }, /* should be patch_alc883() in future */
17034 { .id = 0x10ec0885, .rev = 0x100103, .name = "ALC889A",
17035 .patch = patch_alc882 }, /* should be patch_alc883() in future */
17036 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
17037 { .id = 0x10ec0887, .name = "ALC887", .patch = patch_alc883 },
17038 { .id = 0x10ec0888, .rev = 0x100101, .name = "ALC1200",
17039 .patch = patch_alc883 },
17040 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc883 },
17041 { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc883 },
17042 {} /* terminator */
17045 MODULE_ALIAS("snd-hda-codec-id:10ec*");
17047 MODULE_LICENSE("GPL");
17048 MODULE_DESCRIPTION("Realtek HD-audio codec");
17050 static struct hda_codec_preset_list realtek_list = {
17051 .preset = snd_hda_preset_realtek,
17052 .owner = THIS_MODULE,
17055 static int __init patch_realtek_init(void)
17057 return snd_hda_add_codec_preset(&realtek_list);
17060 static void __exit patch_realtek_exit(void)
17062 snd_hda_delete_codec_preset(&realtek_list);
17065 module_init(patch_realtek_init)
17066 module_exit(patch_realtek_exit)