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"
33 #include "hda_patch.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 */
81 #ifdef CONFIG_SND_DEBUG
85 ALC260_MODEL_LAST /* last tag */
95 ALC262_HP_BPC_D7000_WL,
96 ALC262_HP_BPC_D7000_WF,
108 ALC262_MODEL_LAST /* last tag */
117 ALC268_ACER_ASPIRE_ONE,
120 #ifdef CONFIG_SND_DEBUG
124 ALC268_MODEL_LAST /* last tag */
131 ALC269_ASUS_EEEPC_P703,
132 ALC269_ASUS_EEEPC_P901,
134 ALC269_MODEL_LAST /* last tag */
151 /* ALC861-VD models */
172 ALC662_ASUS_EEEPC_P701,
173 ALC662_ASUS_EEEPC_EP20,
212 ALC883_TARGA_2ch_DIG,
218 ALC883_LENOVO_101E_2ch,
219 ALC883_LENOVO_NB0763,
220 ALC888_LENOVO_MS7195_DIG,
227 ALC883_FUJITSU_PI2515,
228 ALC883_3ST_6ch_INTEL,
236 #define GPIO_MASK 0x03
239 /* codec parameterization */
240 struct snd_kcontrol_new *mixers[5]; /* mixer arrays */
241 unsigned int num_mixers;
243 const struct hda_verb *init_verbs[5]; /* initialization verbs
247 unsigned int num_init_verbs;
249 char *stream_name_analog; /* analog PCM stream */
250 struct hda_pcm_stream *stream_analog_playback;
251 struct hda_pcm_stream *stream_analog_capture;
252 struct hda_pcm_stream *stream_analog_alt_playback;
253 struct hda_pcm_stream *stream_analog_alt_capture;
255 char *stream_name_digital; /* digital PCM stream */
256 struct hda_pcm_stream *stream_digital_playback;
257 struct hda_pcm_stream *stream_digital_capture;
260 struct hda_multi_out multiout; /* playback set-up
261 * max_channels, dacs must be set
262 * dig_out_nid and hp_nid are optional
264 hda_nid_t alt_dac_nid;
267 unsigned int num_adc_nids;
269 hda_nid_t *capsrc_nids;
270 hda_nid_t dig_in_nid; /* digital-in NID; optional */
273 unsigned int num_mux_defs;
274 const struct hda_input_mux *input_mux;
275 unsigned int cur_mux[3];
278 const struct hda_channel_mode *channel_mode;
279 int num_channel_mode;
282 /* PCM information */
283 struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */
285 /* dynamic controls, init_verbs and input_mux */
286 struct auto_pin_cfg autocfg;
287 unsigned int num_kctl_alloc, num_kctl_used;
288 struct snd_kcontrol_new *kctl_alloc;
289 struct hda_input_mux private_imux;
290 hda_nid_t private_dac_nids[AUTO_CFG_MAX_OUTS];
293 void (*init_hook)(struct hda_codec *codec);
294 void (*unsol_event)(struct hda_codec *codec, unsigned int res);
296 /* for pin sensing */
297 unsigned int sense_updated: 1;
298 unsigned int jack_present: 1;
299 unsigned int master_sw: 1;
301 /* for virtual master */
302 hda_nid_t vmaster_nid;
303 #ifdef CONFIG_SND_HDA_POWER_SAVE
304 struct hda_loopback_check loopback;
309 unsigned int pll_coef_idx, pll_coef_bit;
313 * configuration template - to be copied to the spec instance
315 struct alc_config_preset {
316 struct snd_kcontrol_new *mixers[5]; /* should be identical size
319 const struct hda_verb *init_verbs[5];
320 unsigned int num_dacs;
322 hda_nid_t dig_out_nid; /* optional */
323 hda_nid_t hp_nid; /* optional */
324 unsigned int num_adc_nids;
326 hda_nid_t *capsrc_nids;
327 hda_nid_t dig_in_nid;
328 unsigned int num_channel_mode;
329 const struct hda_channel_mode *channel_mode;
331 unsigned int num_mux_defs;
332 const struct hda_input_mux *input_mux;
333 void (*unsol_event)(struct hda_codec *, unsigned int);
334 void (*init_hook)(struct hda_codec *);
335 #ifdef CONFIG_SND_HDA_POWER_SAVE
336 struct hda_amp_list *loopbacks;
344 static int alc_mux_enum_info(struct snd_kcontrol *kcontrol,
345 struct snd_ctl_elem_info *uinfo)
347 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
348 struct alc_spec *spec = codec->spec;
349 unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id);
350 if (mux_idx >= spec->num_mux_defs)
352 return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo);
355 static int alc_mux_enum_get(struct snd_kcontrol *kcontrol,
356 struct snd_ctl_elem_value *ucontrol)
358 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
359 struct alc_spec *spec = codec->spec;
360 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
362 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
366 static int alc_mux_enum_put(struct snd_kcontrol *kcontrol,
367 struct snd_ctl_elem_value *ucontrol)
369 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
370 struct alc_spec *spec = codec->spec;
371 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
372 unsigned int mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx;
373 hda_nid_t nid = spec->capsrc_nids ?
374 spec->capsrc_nids[adc_idx] : spec->adc_nids[adc_idx];
375 return snd_hda_input_mux_put(codec, &spec->input_mux[mux_idx], ucontrol,
376 nid, &spec->cur_mux[adc_idx]);
381 * channel mode setting
383 static int alc_ch_mode_info(struct snd_kcontrol *kcontrol,
384 struct snd_ctl_elem_info *uinfo)
386 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
387 struct alc_spec *spec = codec->spec;
388 return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
389 spec->num_channel_mode);
392 static int alc_ch_mode_get(struct snd_kcontrol *kcontrol,
393 struct snd_ctl_elem_value *ucontrol)
395 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
396 struct alc_spec *spec = codec->spec;
397 return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
398 spec->num_channel_mode,
399 spec->multiout.max_channels);
402 static int alc_ch_mode_put(struct snd_kcontrol *kcontrol,
403 struct snd_ctl_elem_value *ucontrol)
405 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
406 struct alc_spec *spec = codec->spec;
407 int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
408 spec->num_channel_mode,
409 &spec->multiout.max_channels);
410 if (err >= 0 && spec->need_dac_fix)
411 spec->multiout.num_dacs = spec->multiout.max_channels / 2;
416 * Control the mode of pin widget settings via the mixer. "pc" is used
417 * instead of "%" to avoid consequences of accidently treating the % as
418 * being part of a format specifier. Maximum allowed length of a value is
419 * 63 characters plus NULL terminator.
421 * Note: some retasking pin complexes seem to ignore requests for input
422 * states other than HiZ (eg: PIN_VREFxx) and revert to HiZ if any of these
423 * are requested. Therefore order this list so that this behaviour will not
424 * cause problems when mixer clients move through the enum sequentially.
425 * NIDs 0x0f and 0x10 have been observed to have this behaviour as of
428 static char *alc_pin_mode_names[] = {
429 "Mic 50pc bias", "Mic 80pc bias",
430 "Line in", "Line out", "Headphone out",
432 static unsigned char alc_pin_mode_values[] = {
433 PIN_VREF50, PIN_VREF80, PIN_IN, PIN_OUT, PIN_HP,
435 /* The control can present all 5 options, or it can limit the options based
436 * in the pin being assumed to be exclusively an input or an output pin. In
437 * addition, "input" pins may or may not process the mic bias option
438 * depending on actual widget capability (NIDs 0x0f and 0x10 don't seem to
439 * accept requests for bias as of chip versions up to March 2006) and/or
440 * wiring in the computer.
442 #define ALC_PIN_DIR_IN 0x00
443 #define ALC_PIN_DIR_OUT 0x01
444 #define ALC_PIN_DIR_INOUT 0x02
445 #define ALC_PIN_DIR_IN_NOMICBIAS 0x03
446 #define ALC_PIN_DIR_INOUT_NOMICBIAS 0x04
448 /* Info about the pin modes supported by the different pin direction modes.
449 * For each direction the minimum and maximum values are given.
451 static signed char alc_pin_mode_dir_info[5][2] = {
452 { 0, 2 }, /* ALC_PIN_DIR_IN */
453 { 3, 4 }, /* ALC_PIN_DIR_OUT */
454 { 0, 4 }, /* ALC_PIN_DIR_INOUT */
455 { 2, 2 }, /* ALC_PIN_DIR_IN_NOMICBIAS */
456 { 2, 4 }, /* ALC_PIN_DIR_INOUT_NOMICBIAS */
458 #define alc_pin_mode_min(_dir) (alc_pin_mode_dir_info[_dir][0])
459 #define alc_pin_mode_max(_dir) (alc_pin_mode_dir_info[_dir][1])
460 #define alc_pin_mode_n_items(_dir) \
461 (alc_pin_mode_max(_dir)-alc_pin_mode_min(_dir)+1)
463 static int alc_pin_mode_info(struct snd_kcontrol *kcontrol,
464 struct snd_ctl_elem_info *uinfo)
466 unsigned int item_num = uinfo->value.enumerated.item;
467 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
469 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
471 uinfo->value.enumerated.items = alc_pin_mode_n_items(dir);
473 if (item_num<alc_pin_mode_min(dir) || item_num>alc_pin_mode_max(dir))
474 item_num = alc_pin_mode_min(dir);
475 strcpy(uinfo->value.enumerated.name, alc_pin_mode_names[item_num]);
479 static int alc_pin_mode_get(struct snd_kcontrol *kcontrol,
480 struct snd_ctl_elem_value *ucontrol)
483 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
484 hda_nid_t nid = kcontrol->private_value & 0xffff;
485 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
486 long *valp = ucontrol->value.integer.value;
487 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
488 AC_VERB_GET_PIN_WIDGET_CONTROL,
491 /* Find enumerated value for current pinctl setting */
492 i = alc_pin_mode_min(dir);
493 while (alc_pin_mode_values[i] != pinctl && i <= alc_pin_mode_max(dir))
495 *valp = i <= alc_pin_mode_max(dir) ? i: alc_pin_mode_min(dir);
499 static int alc_pin_mode_put(struct snd_kcontrol *kcontrol,
500 struct snd_ctl_elem_value *ucontrol)
503 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
504 hda_nid_t nid = kcontrol->private_value & 0xffff;
505 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
506 long val = *ucontrol->value.integer.value;
507 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
508 AC_VERB_GET_PIN_WIDGET_CONTROL,
511 if (val < alc_pin_mode_min(dir) || val > alc_pin_mode_max(dir))
512 val = alc_pin_mode_min(dir);
514 change = pinctl != alc_pin_mode_values[val];
516 /* Set pin mode to that requested */
517 snd_hda_codec_write_cache(codec, nid, 0,
518 AC_VERB_SET_PIN_WIDGET_CONTROL,
519 alc_pin_mode_values[val]);
521 /* Also enable the retasking pin's input/output as required
522 * for the requested pin mode. Enum values of 2 or less are
525 * Dynamically switching the input/output buffers probably
526 * reduces noise slightly (particularly on input) so we'll
527 * do it. However, having both input and output buffers
528 * enabled simultaneously doesn't seem to be problematic if
529 * this turns out to be necessary in the future.
532 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
533 HDA_AMP_MUTE, HDA_AMP_MUTE);
534 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
537 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
538 HDA_AMP_MUTE, HDA_AMP_MUTE);
539 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
546 #define ALC_PIN_MODE(xname, nid, dir) \
547 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
548 .info = alc_pin_mode_info, \
549 .get = alc_pin_mode_get, \
550 .put = alc_pin_mode_put, \
551 .private_value = nid | (dir<<16) }
553 /* A switch control for ALC260 GPIO pins. Multiple GPIOs can be ganged
554 * together using a mask with more than one bit set. This control is
555 * currently used only by the ALC260 test model. At this stage they are not
556 * needed for any "production" models.
558 #ifdef CONFIG_SND_DEBUG
559 #define alc_gpio_data_info snd_ctl_boolean_mono_info
561 static int alc_gpio_data_get(struct snd_kcontrol *kcontrol,
562 struct snd_ctl_elem_value *ucontrol)
564 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
565 hda_nid_t nid = kcontrol->private_value & 0xffff;
566 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
567 long *valp = ucontrol->value.integer.value;
568 unsigned int val = snd_hda_codec_read(codec, nid, 0,
569 AC_VERB_GET_GPIO_DATA, 0x00);
571 *valp = (val & mask) != 0;
574 static int alc_gpio_data_put(struct snd_kcontrol *kcontrol,
575 struct snd_ctl_elem_value *ucontrol)
578 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
579 hda_nid_t nid = kcontrol->private_value & 0xffff;
580 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
581 long val = *ucontrol->value.integer.value;
582 unsigned int gpio_data = snd_hda_codec_read(codec, nid, 0,
583 AC_VERB_GET_GPIO_DATA,
586 /* Set/unset the masked GPIO bit(s) as needed */
587 change = (val == 0 ? 0 : mask) != (gpio_data & mask);
592 snd_hda_codec_write_cache(codec, nid, 0,
593 AC_VERB_SET_GPIO_DATA, gpio_data);
597 #define ALC_GPIO_DATA_SWITCH(xname, nid, mask) \
598 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
599 .info = alc_gpio_data_info, \
600 .get = alc_gpio_data_get, \
601 .put = alc_gpio_data_put, \
602 .private_value = nid | (mask<<16) }
603 #endif /* CONFIG_SND_DEBUG */
605 /* A switch control to allow the enabling of the digital IO pins on the
606 * ALC260. This is incredibly simplistic; the intention of this control is
607 * to provide something in the test model allowing digital outputs to be
608 * identified if present. If models are found which can utilise these
609 * outputs a more complete mixer control can be devised for those models if
612 #ifdef CONFIG_SND_DEBUG
613 #define alc_spdif_ctrl_info snd_ctl_boolean_mono_info
615 static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol,
616 struct snd_ctl_elem_value *ucontrol)
618 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
619 hda_nid_t nid = kcontrol->private_value & 0xffff;
620 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
621 long *valp = ucontrol->value.integer.value;
622 unsigned int val = snd_hda_codec_read(codec, nid, 0,
623 AC_VERB_GET_DIGI_CONVERT_1, 0x00);
625 *valp = (val & mask) != 0;
628 static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol,
629 struct snd_ctl_elem_value *ucontrol)
632 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
633 hda_nid_t nid = kcontrol->private_value & 0xffff;
634 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
635 long val = *ucontrol->value.integer.value;
636 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
637 AC_VERB_GET_DIGI_CONVERT_1,
640 /* Set/unset the masked control bit(s) as needed */
641 change = (val == 0 ? 0 : mask) != (ctrl_data & mask);
646 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1,
651 #define ALC_SPDIF_CTRL_SWITCH(xname, nid, mask) \
652 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
653 .info = alc_spdif_ctrl_info, \
654 .get = alc_spdif_ctrl_get, \
655 .put = alc_spdif_ctrl_put, \
656 .private_value = nid | (mask<<16) }
657 #endif /* CONFIG_SND_DEBUG */
659 /* A switch control to allow the enabling EAPD digital outputs on the ALC26x.
660 * Again, this is only used in the ALC26x test models to help identify when
661 * the EAPD line must be asserted for features to work.
663 #ifdef CONFIG_SND_DEBUG
664 #define alc_eapd_ctrl_info snd_ctl_boolean_mono_info
666 static int alc_eapd_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_EAPD_BTLENABLE, 0x00);
676 *valp = (val & mask) != 0;
680 static int alc_eapd_ctrl_put(struct snd_kcontrol *kcontrol,
681 struct snd_ctl_elem_value *ucontrol)
684 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
685 hda_nid_t nid = kcontrol->private_value & 0xffff;
686 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
687 long val = *ucontrol->value.integer.value;
688 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
689 AC_VERB_GET_EAPD_BTLENABLE,
692 /* Set/unset the masked control bit(s) as needed */
693 change = (!val ? 0 : mask) != (ctrl_data & mask);
698 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
704 #define ALC_EAPD_CTRL_SWITCH(xname, nid, mask) \
705 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
706 .info = alc_eapd_ctrl_info, \
707 .get = alc_eapd_ctrl_get, \
708 .put = alc_eapd_ctrl_put, \
709 .private_value = nid | (mask<<16) }
710 #endif /* CONFIG_SND_DEBUG */
713 * set up from the preset table
715 static void setup_preset(struct alc_spec *spec,
716 const struct alc_config_preset *preset)
720 for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++)
721 spec->mixers[spec->num_mixers++] = preset->mixers[i];
722 for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i];
724 spec->init_verbs[spec->num_init_verbs++] =
725 preset->init_verbs[i];
727 spec->channel_mode = preset->channel_mode;
728 spec->num_channel_mode = preset->num_channel_mode;
729 spec->need_dac_fix = preset->need_dac_fix;
731 spec->multiout.max_channels = spec->channel_mode[0].channels;
733 spec->multiout.num_dacs = preset->num_dacs;
734 spec->multiout.dac_nids = preset->dac_nids;
735 spec->multiout.dig_out_nid = preset->dig_out_nid;
736 spec->multiout.hp_nid = preset->hp_nid;
738 spec->num_mux_defs = preset->num_mux_defs;
739 if (!spec->num_mux_defs)
740 spec->num_mux_defs = 1;
741 spec->input_mux = preset->input_mux;
743 spec->num_adc_nids = preset->num_adc_nids;
744 spec->adc_nids = preset->adc_nids;
745 spec->capsrc_nids = preset->capsrc_nids;
746 spec->dig_in_nid = preset->dig_in_nid;
748 spec->unsol_event = preset->unsol_event;
749 spec->init_hook = preset->init_hook;
750 #ifdef CONFIG_SND_HDA_POWER_SAVE
751 spec->loopback.amplist = preset->loopbacks;
755 /* Enable GPIO mask and set output */
756 static struct hda_verb alc_gpio1_init_verbs[] = {
757 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
758 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
759 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
763 static struct hda_verb alc_gpio2_init_verbs[] = {
764 {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
765 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
766 {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
770 static struct hda_verb alc_gpio3_init_verbs[] = {
771 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
772 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
773 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
778 * Fix hardware PLL issue
779 * On some codecs, the analog PLL gating control must be off while
780 * the default value is 1.
782 static void alc_fix_pll(struct hda_codec *codec)
784 struct alc_spec *spec = codec->spec;
789 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX,
791 val = snd_hda_codec_read(codec, spec->pll_nid, 0,
792 AC_VERB_GET_PROC_COEF, 0);
793 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX,
795 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_PROC_COEF,
796 val & ~(1 << spec->pll_coef_bit));
799 static void alc_fix_pll_init(struct hda_codec *codec, hda_nid_t nid,
800 unsigned int coef_idx, unsigned int coef_bit)
802 struct alc_spec *spec = codec->spec;
804 spec->pll_coef_idx = coef_idx;
805 spec->pll_coef_bit = coef_bit;
809 static void alc_sku_automute(struct hda_codec *codec)
811 struct alc_spec *spec = codec->spec;
812 unsigned int present;
813 unsigned int hp_nid = spec->autocfg.hp_pins[0];
814 unsigned int sp_nid = spec->autocfg.speaker_pins[0];
816 /* need to execute and sync at first */
817 snd_hda_codec_read(codec, hp_nid, 0, AC_VERB_SET_PIN_SENSE, 0);
818 present = snd_hda_codec_read(codec, hp_nid, 0,
819 AC_VERB_GET_PIN_SENSE, 0);
820 spec->jack_present = (present & 0x80000000) != 0;
821 snd_hda_codec_write(codec, sp_nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
822 spec->jack_present ? 0 : PIN_OUT);
825 static void alc_mic_automute(struct hda_codec *codec)
827 struct alc_spec *spec = codec->spec;
828 unsigned int present;
829 unsigned int mic_nid = spec->autocfg.input_pins[AUTO_PIN_MIC];
830 unsigned int fmic_nid = spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC];
831 unsigned int mix_nid = spec->capsrc_nids[0];
832 unsigned int capsrc_idx_mic, capsrc_idx_fmic;
834 capsrc_idx_mic = mic_nid - 0x18;
835 capsrc_idx_fmic = fmic_nid - 0x18;
836 present = snd_hda_codec_read(codec, mic_nid, 0,
837 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
838 snd_hda_codec_write(codec, mix_nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
839 0x7000 | (capsrc_idx_mic << 8) | (present ? 0 : 0x80));
840 snd_hda_codec_write(codec, mix_nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
841 0x7000 | (capsrc_idx_fmic << 8) | (present ? 0x80 : 0));
842 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, capsrc_idx_fmic,
843 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
846 /* unsolicited event for HP jack sensing */
847 static void alc_sku_unsol_event(struct hda_codec *codec, unsigned int res)
849 if (codec->vendor_id == 0x10ec0880)
853 if (res == ALC880_HP_EVENT)
854 alc_sku_automute(codec);
856 if (res == ALC880_MIC_EVENT)
857 alc_mic_automute(codec);
860 static void alc_inithook(struct hda_codec *codec)
862 alc_sku_automute(codec);
863 alc_mic_automute(codec);
866 /* additional initialization for ALC888 variants */
867 static void alc888_coef_init(struct hda_codec *codec)
871 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 0);
872 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
873 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
874 if ((tmp & 0xf0) == 2)
876 snd_hda_codec_read(codec, 0x20, 0,
877 AC_VERB_SET_PROC_COEF, 0x830);
880 snd_hda_codec_read(codec, 0x20, 0,
881 AC_VERB_SET_PROC_COEF, 0x3030);
884 /* 32-bit subsystem ID for BIOS loading in HD Audio codec.
885 * 31 ~ 16 : Manufacture ID
887 * 7 ~ 0 : Assembly ID
888 * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36
890 static void alc_subsystem_id(struct hda_codec *codec,
891 unsigned int porta, unsigned int porte,
894 unsigned int ass, tmp, i;
896 struct alc_spec *spec = codec->spec;
898 ass = codec->subsystem_id & 0xffff;
899 if ((ass != codec->bus->pci->subsystem_device) && (ass & 1))
903 * 31~30 : port conetcivity
906 * 19~16 : Check sum (15:1)
911 if (codec->vendor_id == 0x10ec0260)
913 ass = snd_hda_codec_read(codec, nid, 0,
914 AC_VERB_GET_CONFIG_DEFAULT, 0);
915 if (!(ass & 1) && !(ass & 0x100000))
917 if ((ass >> 30) != 1) /* no physical connection */
922 for (i = 1; i < 16; i++) {
926 if (((ass >> 16) & 0xf) != tmp)
932 * 2 : 0 --> Desktop, 1 --> Laptop
933 * 3~5 : External Amplifier control
936 tmp = (ass & 0x38) >> 3; /* external Amp control */
939 snd_hda_sequence_write(codec, alc_gpio1_init_verbs);
942 snd_hda_sequence_write(codec, alc_gpio2_init_verbs);
945 snd_hda_sequence_write(codec, alc_gpio3_init_verbs);
947 case 5: /* set EAPD output high */
948 switch (codec->vendor_id) {
950 snd_hda_codec_write(codec, 0x0f, 0,
951 AC_VERB_SET_EAPD_BTLENABLE, 2);
952 snd_hda_codec_write(codec, 0x10, 0,
953 AC_VERB_SET_EAPD_BTLENABLE, 2);
964 snd_hda_codec_write(codec, 0x14, 0,
965 AC_VERB_SET_EAPD_BTLENABLE, 2);
966 snd_hda_codec_write(codec, 0x15, 0,
967 AC_VERB_SET_EAPD_BTLENABLE, 2);
970 switch (codec->vendor_id) {
972 snd_hda_codec_write(codec, 0x1a, 0,
973 AC_VERB_SET_COEF_INDEX, 7);
974 tmp = snd_hda_codec_read(codec, 0x1a, 0,
975 AC_VERB_GET_PROC_COEF, 0);
976 snd_hda_codec_write(codec, 0x1a, 0,
977 AC_VERB_SET_COEF_INDEX, 7);
978 snd_hda_codec_write(codec, 0x1a, 0,
979 AC_VERB_SET_PROC_COEF,
988 snd_hda_codec_write(codec, 0x20, 0,
989 AC_VERB_SET_COEF_INDEX, 7);
990 tmp = snd_hda_codec_read(codec, 0x20, 0,
991 AC_VERB_GET_PROC_COEF, 0);
992 snd_hda_codec_write(codec, 0x20, 0,
993 AC_VERB_SET_COEF_INDEX, 7);
994 snd_hda_codec_write(codec, 0x20, 0,
995 AC_VERB_SET_PROC_COEF,
999 /*alc888_coef_init(codec);*/ /* called in alc_init() */
1003 snd_hda_codec_write(codec, 0x20, 0,
1004 AC_VERB_SET_COEF_INDEX, 7);
1005 tmp = snd_hda_codec_read(codec, 0x20, 0,
1006 AC_VERB_GET_PROC_COEF, 0);
1007 snd_hda_codec_write(codec, 0x20, 0,
1008 AC_VERB_SET_COEF_INDEX, 7);
1009 snd_hda_codec_write(codec, 0x20, 0,
1010 AC_VERB_SET_PROC_COEF,
1018 /* is laptop or Desktop and enable the function "Mute internal speaker
1019 * when the external headphone out jack is plugged"
1021 if (!(ass & 0x8000))
1024 * 10~8 : Jack location
1025 * 12~11: Headphone out -> 00: PortA, 01: PortE, 02: PortD, 03: Resvered
1027 * 15 : 1 --> enable the function "Mute internal speaker
1028 * when the external headphone out jack is plugged"
1030 if (!spec->autocfg.speaker_pins[0]) {
1031 if (spec->autocfg.line_out_pins[0])
1032 spec->autocfg.speaker_pins[0] =
1033 spec->autocfg.line_out_pins[0];
1038 if (!spec->autocfg.hp_pins[0]) {
1039 tmp = (ass >> 11) & 0x3; /* HP to chassis */
1041 spec->autocfg.hp_pins[0] = porta;
1043 spec->autocfg.hp_pins[0] = porte;
1045 spec->autocfg.hp_pins[0] = portd;
1049 if (spec->autocfg.hp_pins[0])
1050 snd_hda_codec_write(codec, spec->autocfg.hp_pins[0], 0,
1051 AC_VERB_SET_UNSOLICITED_ENABLE,
1052 AC_USRSP_EN | ALC880_HP_EVENT);
1054 if (spec->autocfg.input_pins[AUTO_PIN_MIC] &&
1055 spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC])
1056 snd_hda_codec_write(codec,
1057 spec->autocfg.input_pins[AUTO_PIN_MIC], 0,
1058 AC_VERB_SET_UNSOLICITED_ENABLE,
1059 AC_USRSP_EN | ALC880_MIC_EVENT);
1061 spec->unsol_event = alc_sku_unsol_event;
1065 * Fix-up pin default configurations
1073 static void alc_fix_pincfg(struct hda_codec *codec,
1074 const struct snd_pci_quirk *quirk,
1075 const struct alc_pincfg **pinfix)
1077 const struct alc_pincfg *cfg;
1079 quirk = snd_pci_quirk_lookup(codec->bus->pci, quirk);
1083 cfg = pinfix[quirk->value];
1084 for (; cfg->nid; cfg++) {
1087 for (i = 0; i < 4; i++) {
1088 snd_hda_codec_write(codec, cfg->nid, 0,
1089 AC_VERB_SET_CONFIG_DEFAULT_BYTES_0 + i,
1097 * ALC880 3-stack model
1099 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
1100 * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18,
1101 * F-Mic = 0x1b, HP = 0x19
1104 static hda_nid_t alc880_dac_nids[4] = {
1105 /* front, rear, clfe, rear_surr */
1106 0x02, 0x05, 0x04, 0x03
1109 static hda_nid_t alc880_adc_nids[3] = {
1114 /* The datasheet says the node 0x07 is connected from inputs,
1115 * but it shows zero connection in the real implementation on some devices.
1116 * Note: this is a 915GAV bug, fixed on 915GLV
1118 static hda_nid_t alc880_adc_nids_alt[2] = {
1123 #define ALC880_DIGOUT_NID 0x06
1124 #define ALC880_DIGIN_NID 0x0a
1126 static struct hda_input_mux alc880_capture_source = {
1130 { "Front Mic", 0x3 },
1136 /* channel source setting (2/6 channel selection for 3-stack) */
1138 static struct hda_verb alc880_threestack_ch2_init[] = {
1139 /* set line-in to input, mute it */
1140 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1141 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1142 /* set mic-in to input vref 80%, mute it */
1143 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1144 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1149 static struct hda_verb alc880_threestack_ch6_init[] = {
1150 /* set line-in to output, unmute it */
1151 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1152 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1153 /* set mic-in to output, unmute it */
1154 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1155 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1159 static struct hda_channel_mode alc880_threestack_modes[2] = {
1160 { 2, alc880_threestack_ch2_init },
1161 { 6, alc880_threestack_ch6_init },
1164 static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
1165 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1166 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1167 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
1168 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
1169 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1170 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1171 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1172 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1173 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1174 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1175 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1176 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1177 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1178 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1179 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
1180 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
1181 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1182 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
1183 HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
1185 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1186 .name = "Channel Mode",
1187 .info = alc_ch_mode_info,
1188 .get = alc_ch_mode_get,
1189 .put = alc_ch_mode_put,
1194 /* capture mixer elements */
1195 static struct snd_kcontrol_new alc880_capture_mixer[] = {
1196 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
1197 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
1198 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
1199 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
1200 HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
1201 HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
1203 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1204 /* The multiple "Capture Source" controls confuse alsamixer
1205 * So call somewhat different..
1207 /* .name = "Capture Source", */
1208 .name = "Input Source",
1210 .info = alc_mux_enum_info,
1211 .get = alc_mux_enum_get,
1212 .put = alc_mux_enum_put,
1217 /* capture mixer elements (in case NID 0x07 not available) */
1218 static struct snd_kcontrol_new alc880_capture_alt_mixer[] = {
1219 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
1220 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
1221 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
1222 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
1224 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1225 /* The multiple "Capture Source" controls confuse alsamixer
1226 * So call somewhat different..
1228 /* .name = "Capture Source", */
1229 .name = "Input Source",
1231 .info = alc_mux_enum_info,
1232 .get = alc_mux_enum_get,
1233 .put = alc_mux_enum_put,
1241 * ALC880 5-stack model
1243 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d),
1245 * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
1246 * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
1249 /* additional mixers to alc880_three_stack_mixer */
1250 static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
1251 HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1252 HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
1256 /* channel source setting (6/8 channel selection for 5-stack) */
1258 static struct hda_verb alc880_fivestack_ch6_init[] = {
1259 /* set line-in to input, mute it */
1260 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1261 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1266 static struct hda_verb alc880_fivestack_ch8_init[] = {
1267 /* set line-in to output, unmute it */
1268 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1269 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1273 static struct hda_channel_mode alc880_fivestack_modes[2] = {
1274 { 6, alc880_fivestack_ch6_init },
1275 { 8, alc880_fivestack_ch8_init },
1280 * ALC880 6-stack model
1282 * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e),
1283 * Side = 0x05 (0x0f)
1284 * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
1285 * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
1288 static hda_nid_t alc880_6st_dac_nids[4] = {
1289 /* front, rear, clfe, rear_surr */
1290 0x02, 0x03, 0x04, 0x05
1293 static struct hda_input_mux alc880_6stack_capture_source = {
1297 { "Front Mic", 0x1 },
1303 /* fixed 8-channels */
1304 static struct hda_channel_mode alc880_sixstack_modes[1] = {
1308 static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
1309 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1310 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1311 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1312 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
1313 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1314 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1315 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1316 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1317 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
1318 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
1319 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1320 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1321 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1322 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1323 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1324 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1325 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1326 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1327 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1328 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
1330 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1331 .name = "Channel Mode",
1332 .info = alc_ch_mode_info,
1333 .get = alc_ch_mode_get,
1334 .put = alc_ch_mode_put,
1343 * W810 has rear IO for:
1346 * Center/LFE (DAC 04)
1349 * The system also has a pair of internal speakers, and a headphone jack.
1350 * These are both connected to Line2 on the codec, hence to DAC 02.
1352 * There is a variable resistor to control the speaker or headphone
1353 * volume. This is a hardware-only device without a software API.
1355 * Plugging headphones in will disable the internal speakers. This is
1356 * implemented in hardware, not via the driver using jack sense. In
1357 * a similar fashion, plugging into the rear socket marked "front" will
1358 * disable both the speakers and headphones.
1360 * For input, there's a microphone jack, and an "audio in" jack.
1361 * These may not do anything useful with this driver yet, because I
1362 * haven't setup any initialization verbs for these yet...
1365 static hda_nid_t alc880_w810_dac_nids[3] = {
1366 /* front, rear/surround, clfe */
1370 /* fixed 6 channels */
1371 static struct hda_channel_mode alc880_w810_modes[1] = {
1375 /* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
1376 static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
1377 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1378 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1379 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1380 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
1381 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1382 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1383 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1384 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1385 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
1393 * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
1394 * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?),
1398 static hda_nid_t alc880_z71v_dac_nids[1] = {
1401 #define ALC880_Z71V_HP_DAC 0x03
1403 /* fixed 2 channels */
1404 static struct hda_channel_mode alc880_2_jack_modes[1] = {
1408 static struct snd_kcontrol_new alc880_z71v_mixer[] = {
1409 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1410 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1411 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1412 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
1413 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1414 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1415 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1416 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1422 * ALC880 F1734 model
1424 * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
1425 * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
1428 static hda_nid_t alc880_f1734_dac_nids[1] = {
1431 #define ALC880_F1734_HP_DAC 0x02
1433 static struct snd_kcontrol_new alc880_f1734_mixer[] = {
1434 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1435 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
1436 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1437 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
1438 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1439 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1440 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1441 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1445 static struct hda_input_mux alc880_f1734_capture_source = {
1457 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
1458 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
1459 * Mic = 0x18, Line = 0x1a
1462 #define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
1463 #define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
1465 static struct snd_kcontrol_new alc880_asus_mixer[] = {
1466 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1467 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1468 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1469 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
1470 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1471 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1472 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1473 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1474 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1475 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1476 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1477 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1478 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1479 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1481 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1482 .name = "Channel Mode",
1483 .info = alc_ch_mode_info,
1484 .get = alc_ch_mode_get,
1485 .put = alc_ch_mode_put,
1491 * ALC880 ASUS W1V model
1493 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
1494 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
1495 * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
1498 /* additional mixers to alc880_asus_mixer */
1499 static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
1500 HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
1501 HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
1505 /* additional mixers to alc880_asus_mixer */
1506 static struct snd_kcontrol_new alc880_pcbeep_mixer[] = {
1507 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1508 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
1513 static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
1514 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1515 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
1516 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
1517 HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
1518 HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
1519 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
1520 HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
1521 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
1522 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
1524 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1525 /* The multiple "Capture Source" controls confuse alsamixer
1526 * So call somewhat different..
1528 /* .name = "Capture Source", */
1529 .name = "Input Source",
1531 .info = alc_mux_enum_info,
1532 .get = alc_mux_enum_get,
1533 .put = alc_mux_enum_put,
1539 static struct snd_kcontrol_new alc880_uniwill_mixer[] = {
1540 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1541 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
1542 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1543 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
1544 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1545 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1546 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1547 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1548 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1549 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1550 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1551 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1552 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1553 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1554 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1555 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1556 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1557 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
1559 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1560 .name = "Channel Mode",
1561 .info = alc_ch_mode_info,
1562 .get = alc_ch_mode_get,
1563 .put = alc_ch_mode_put,
1568 static struct snd_kcontrol_new alc880_fujitsu_mixer[] = {
1569 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1570 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
1571 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1572 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
1573 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1574 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1575 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1576 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1577 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1578 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1582 static struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = {
1583 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1584 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
1585 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1586 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
1587 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1588 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1593 * virtual master controls
1597 * slave controls for virtual master
1599 static const char *alc_slave_vols[] = {
1600 "Front Playback Volume",
1601 "Surround Playback Volume",
1602 "Center Playback Volume",
1603 "LFE Playback Volume",
1604 "Side Playback Volume",
1605 "Headphone Playback Volume",
1606 "Speaker Playback Volume",
1607 "Mono Playback Volume",
1608 "Line-Out Playback Volume",
1612 static const char *alc_slave_sws[] = {
1613 "Front Playback Switch",
1614 "Surround Playback Switch",
1615 "Center Playback Switch",
1616 "LFE Playback Switch",
1617 "Side Playback Switch",
1618 "Headphone Playback Switch",
1619 "Speaker Playback Switch",
1620 "Mono Playback Switch",
1621 "IEC958 Playback Switch",
1626 * build control elements
1628 static int alc_build_controls(struct hda_codec *codec)
1630 struct alc_spec *spec = codec->spec;
1634 for (i = 0; i < spec->num_mixers; i++) {
1635 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
1640 if (spec->multiout.dig_out_nid) {
1641 err = snd_hda_create_spdif_out_ctls(codec,
1642 spec->multiout.dig_out_nid);
1645 err = snd_hda_create_spdif_share_sw(codec,
1649 spec->multiout.share_spdif = 1;
1651 if (spec->dig_in_nid) {
1652 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
1657 /* if we have no master control, let's create it */
1658 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
1659 unsigned int vmaster_tlv[4];
1660 snd_hda_set_vmaster_tlv(codec, spec->vmaster_nid,
1661 HDA_OUTPUT, vmaster_tlv);
1662 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
1663 vmaster_tlv, alc_slave_vols);
1667 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
1668 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
1669 NULL, alc_slave_sws);
1679 * initialize the codec volumes, etc
1683 * generic initialization of ADC, input mixers and output mixers
1685 static struct hda_verb alc880_volume_init_verbs[] = {
1687 * Unmute ADC0-2 and set the default input to mic-in
1689 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
1690 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1691 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
1692 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1693 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
1694 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1696 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
1698 * Note: PASD motherboards uses the Line In 2 as the input for front
1701 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
1702 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1703 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1704 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
1705 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
1706 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
1707 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
1708 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
1711 * Set up output mixers (0x0c - 0x0f)
1713 /* set vol=0 to output mixers */
1714 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1715 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1716 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1717 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1718 /* set up input amps for analog loopback */
1719 /* Amp Indices: DAC = 0, mixer = 1 */
1720 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1721 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1722 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1723 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1724 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1725 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1726 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1727 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1733 * 3-stack pin configuration:
1734 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
1736 static struct hda_verb alc880_pin_3stack_init_verbs[] = {
1738 * preset connection lists of input pins
1739 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
1741 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
1742 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1743 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
1746 * Set pin mode and muting
1748 /* set front pin widgets 0x14 for output */
1749 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1750 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1751 /* Mic1 (rear panel) pin widget for input and vref at 80% */
1752 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1753 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1754 /* Mic2 (as headphone out) for HP output */
1755 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1756 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1757 /* Line In pin widget for input */
1758 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1759 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1760 /* Line2 (as front mic) pin widget for input and vref at 80% */
1761 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1762 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1763 /* CD pin widget for input */
1764 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1770 * 5-stack pin configuration:
1771 * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
1772 * line-in/side = 0x1a, f-mic = 0x1b
1774 static struct hda_verb alc880_pin_5stack_init_verbs[] = {
1776 * preset connection lists of input pins
1777 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
1779 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1780 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
1783 * Set pin mode and muting
1785 /* set pin widgets 0x14-0x17 for output */
1786 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1787 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1788 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1789 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1790 /* unmute pins for output (no gain on this amp) */
1791 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1792 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1793 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1794 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1796 /* Mic1 (rear panel) pin widget for input and vref at 80% */
1797 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1798 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1799 /* Mic2 (as headphone out) for HP output */
1800 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1801 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1802 /* Line In pin widget for input */
1803 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1804 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1805 /* Line2 (as front mic) pin widget for input and vref at 80% */
1806 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1807 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1808 /* CD pin widget for input */
1809 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1815 * W810 pin configuration:
1816 * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
1818 static struct hda_verb alc880_pin_w810_init_verbs[] = {
1819 /* hphone/speaker input selector: front DAC */
1820 {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
1822 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1823 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1824 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1825 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1826 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1827 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1829 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1830 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1836 * Z71V pin configuration:
1837 * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
1839 static struct hda_verb alc880_pin_z71v_init_verbs[] = {
1840 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1841 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1842 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1843 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1845 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1846 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1847 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1848 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1854 * 6-stack pin configuration:
1855 * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18,
1856 * f-mic = 0x19, line = 0x1a, HP = 0x1b
1858 static struct hda_verb alc880_pin_6stack_init_verbs[] = {
1859 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1861 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1862 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1863 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1864 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1865 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1866 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1867 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1868 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1870 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1871 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1872 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1873 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1874 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1875 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1876 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1877 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1878 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1884 * Uniwill pin configuration:
1885 * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19,
1888 static struct hda_verb alc880_uniwill_init_verbs[] = {
1889 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1891 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1892 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1893 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1894 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1895 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1896 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1897 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1898 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1899 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1900 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1901 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1902 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1903 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1904 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1906 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1907 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1908 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1909 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1910 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1911 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1912 /* {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, */
1913 /* {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
1914 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1916 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
1917 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
1924 * HP = 0x14, InternalSpeaker = 0x15, mic = 0x19,
1926 static struct hda_verb alc880_uniwill_p53_init_verbs[] = {
1927 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1929 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1930 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1931 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1932 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1933 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1934 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1935 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1936 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1937 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1938 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1939 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1940 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1942 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1943 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1944 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1945 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1946 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1947 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1949 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
1950 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_DCVOL_EVENT},
1955 static struct hda_verb alc880_beep_init_verbs[] = {
1956 { 0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5) },
1960 /* toggle speaker-output according to the hp-jack state */
1961 static void alc880_uniwill_hp_automute(struct hda_codec *codec)
1963 unsigned int present;
1966 present = snd_hda_codec_read(codec, 0x14, 0,
1967 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1968 bits = present ? HDA_AMP_MUTE : 0;
1969 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
1970 HDA_AMP_MUTE, bits);
1971 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
1972 HDA_AMP_MUTE, bits);
1975 /* auto-toggle front mic */
1976 static void alc880_uniwill_mic_automute(struct hda_codec *codec)
1978 unsigned int present;
1981 present = snd_hda_codec_read(codec, 0x18, 0,
1982 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1983 bits = present ? HDA_AMP_MUTE : 0;
1984 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
1987 static void alc880_uniwill_automute(struct hda_codec *codec)
1989 alc880_uniwill_hp_automute(codec);
1990 alc880_uniwill_mic_automute(codec);
1993 static void alc880_uniwill_unsol_event(struct hda_codec *codec,
1996 /* Looks like the unsol event is incompatible with the standard
1997 * definition. 4bit tag is placed at 28 bit!
1999 switch (res >> 28) {
2000 case ALC880_HP_EVENT:
2001 alc880_uniwill_hp_automute(codec);
2003 case ALC880_MIC_EVENT:
2004 alc880_uniwill_mic_automute(codec);
2009 static void alc880_uniwill_p53_hp_automute(struct hda_codec *codec)
2011 unsigned int present;
2014 present = snd_hda_codec_read(codec, 0x14, 0,
2015 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
2016 bits = present ? HDA_AMP_MUTE : 0;
2017 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, HDA_AMP_MUTE, bits);
2020 static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec)
2022 unsigned int present;
2024 present = snd_hda_codec_read(codec, 0x21, 0,
2025 AC_VERB_GET_VOLUME_KNOB_CONTROL, 0);
2026 present &= HDA_AMP_VOLMASK;
2027 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0,
2028 HDA_AMP_VOLMASK, present);
2029 snd_hda_codec_amp_stereo(codec, 0x0d, HDA_OUTPUT, 0,
2030 HDA_AMP_VOLMASK, present);
2033 static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec,
2036 /* Looks like the unsol event is incompatible with the standard
2037 * definition. 4bit tag is placed at 28 bit!
2039 if ((res >> 28) == ALC880_HP_EVENT)
2040 alc880_uniwill_p53_hp_automute(codec);
2041 if ((res >> 28) == ALC880_DCVOL_EVENT)
2042 alc880_uniwill_p53_dcvol_automute(codec);
2046 * F1734 pin configuration:
2047 * HP = 0x14, speaker-out = 0x15, mic = 0x18
2049 static struct hda_verb alc880_pin_f1734_init_verbs[] = {
2050 {0x07, AC_VERB_SET_CONNECT_SEL, 0x01},
2051 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
2052 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
2053 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
2054 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
2056 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2057 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2058 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2059 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2061 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2062 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2063 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
2064 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2065 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2066 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2067 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2068 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2069 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2071 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
2072 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_DCVOL_EVENT},
2078 * ASUS pin configuration:
2079 * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
2081 static struct hda_verb alc880_pin_asus_init_verbs[] = {
2082 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
2083 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
2084 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
2085 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
2087 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2088 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2089 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2090 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2091 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2092 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2093 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2094 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2096 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2097 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2098 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2099 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2100 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2101 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2102 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2103 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2104 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2109 /* Enable GPIO mask and set output */
2110 #define alc880_gpio1_init_verbs alc_gpio1_init_verbs
2111 #define alc880_gpio2_init_verbs alc_gpio2_init_verbs
2113 /* Clevo m520g init */
2114 static struct hda_verb alc880_pin_clevo_init_verbs[] = {
2115 /* headphone output */
2116 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
2118 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2119 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2121 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2122 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2124 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2125 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2126 /* Mic1 (rear panel) */
2127 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2128 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2129 /* Mic2 (front panel) */
2130 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2131 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2133 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2134 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2135 /* change to EAPD mode */
2136 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2137 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
2142 static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
2143 /* change to EAPD mode */
2144 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2145 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
2147 /* Headphone output */
2148 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2150 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2151 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
2153 /* Line In pin widget for input */
2154 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2155 /* CD pin widget for input */
2156 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2157 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2158 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2160 /* change to EAPD mode */
2161 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2162 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
2168 * LG m1 express dual
2171 * Rear Line-In/Out (blue): 0x14
2172 * Build-in Mic-In: 0x15
2174 * HP-Out (green): 0x1b
2175 * Mic-In/Out (red): 0x19
2179 /* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
2180 static hda_nid_t alc880_lg_dac_nids[3] = {
2184 /* seems analog CD is not working */
2185 static struct hda_input_mux alc880_lg_capture_source = {
2190 { "Internal Mic", 0x6 },
2194 /* 2,4,6 channel modes */
2195 static struct hda_verb alc880_lg_ch2_init[] = {
2196 /* set line-in and mic-in to input */
2197 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
2198 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
2202 static struct hda_verb alc880_lg_ch4_init[] = {
2203 /* set line-in to out and mic-in to input */
2204 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
2205 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
2209 static struct hda_verb alc880_lg_ch6_init[] = {
2210 /* set line-in and mic-in to output */
2211 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
2212 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
2216 static struct hda_channel_mode alc880_lg_ch_modes[3] = {
2217 { 2, alc880_lg_ch2_init },
2218 { 4, alc880_lg_ch4_init },
2219 { 6, alc880_lg_ch6_init },
2222 static struct snd_kcontrol_new alc880_lg_mixer[] = {
2223 HDA_CODEC_VOLUME("Front Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
2224 HDA_BIND_MUTE("Front Playback Switch", 0x0f, 2, HDA_INPUT),
2225 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2226 HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
2227 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
2228 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
2229 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
2230 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
2231 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2232 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
2233 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
2234 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
2235 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
2236 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
2238 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2239 .name = "Channel Mode",
2240 .info = alc_ch_mode_info,
2241 .get = alc_ch_mode_get,
2242 .put = alc_ch_mode_put,
2247 static struct hda_verb alc880_lg_init_verbs[] = {
2248 /* set capture source to mic-in */
2249 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2250 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2251 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2252 /* mute all amp mixer inputs */
2253 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
2254 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
2255 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
2256 /* line-in to input */
2257 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2258 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2260 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2261 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2263 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2264 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2265 /* mic-in to input */
2266 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
2267 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2268 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2270 {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
2271 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2272 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2274 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
2278 /* toggle speaker-output according to the hp-jack state */
2279 static void alc880_lg_automute(struct hda_codec *codec)
2281 unsigned int present;
2284 present = snd_hda_codec_read(codec, 0x1b, 0,
2285 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
2286 bits = present ? HDA_AMP_MUTE : 0;
2287 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
2288 HDA_AMP_MUTE, bits);
2291 static void alc880_lg_unsol_event(struct hda_codec *codec, unsigned int res)
2293 /* Looks like the unsol event is incompatible with the standard
2294 * definition. 4bit tag is placed at 28 bit!
2296 if ((res >> 28) == 0x01)
2297 alc880_lg_automute(codec);
2306 * Built-in Mic-In: 0x19
2312 static struct hda_input_mux alc880_lg_lw_capture_source = {
2316 { "Internal Mic", 0x1 },
2321 #define alc880_lg_lw_modes alc880_threestack_modes
2323 static struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
2324 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2325 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2326 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
2327 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
2328 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2329 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2330 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2331 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2332 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2333 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2334 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2335 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2336 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
2337 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
2339 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2340 .name = "Channel Mode",
2341 .info = alc_ch_mode_info,
2342 .get = alc_ch_mode_get,
2343 .put = alc_ch_mode_put,
2348 static struct hda_verb alc880_lg_lw_init_verbs[] = {
2349 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2350 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
2351 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
2353 /* set capture source to mic-in */
2354 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2355 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2356 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2357 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
2359 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2360 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2362 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2363 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2364 /* mic-in to input */
2365 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2366 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2368 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2369 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2371 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
2375 /* toggle speaker-output according to the hp-jack state */
2376 static void alc880_lg_lw_automute(struct hda_codec *codec)
2378 unsigned int present;
2381 present = snd_hda_codec_read(codec, 0x1b, 0,
2382 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
2383 bits = present ? HDA_AMP_MUTE : 0;
2384 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
2385 HDA_AMP_MUTE, bits);
2388 static void alc880_lg_lw_unsol_event(struct hda_codec *codec, unsigned int res)
2390 /* Looks like the unsol event is incompatible with the standard
2391 * definition. 4bit tag is placed at 28 bit!
2393 if ((res >> 28) == 0x01)
2394 alc880_lg_lw_automute(codec);
2397 static struct snd_kcontrol_new alc880_medion_rim_mixer[] = {
2398 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2399 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
2400 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2401 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2402 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2403 HDA_CODEC_MUTE("Internal Playback Switch", 0x0b, 0x1, HDA_INPUT),
2407 static struct hda_input_mux alc880_medion_rim_capture_source = {
2411 { "Internal Mic", 0x1 },
2415 static struct hda_verb alc880_medion_rim_init_verbs[] = {
2416 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2418 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2419 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2421 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2422 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2423 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2424 /* Mic2 (as headphone out) for HP output */
2425 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2426 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2427 /* Internal Speaker */
2428 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2429 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2431 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2432 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
2434 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
2438 /* toggle speaker-output according to the hp-jack state */
2439 static void alc880_medion_rim_automute(struct hda_codec *codec)
2441 unsigned int present;
2444 present = snd_hda_codec_read(codec, 0x14, 0,
2445 AC_VERB_GET_PIN_SENSE, 0)
2446 & AC_PINSENSE_PRESENCE;
2447 bits = present ? HDA_AMP_MUTE : 0;
2448 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
2449 HDA_AMP_MUTE, bits);
2451 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 0);
2453 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 2);
2456 static void alc880_medion_rim_unsol_event(struct hda_codec *codec,
2459 /* Looks like the unsol event is incompatible with the standard
2460 * definition. 4bit tag is placed at 28 bit!
2462 if ((res >> 28) == ALC880_HP_EVENT)
2463 alc880_medion_rim_automute(codec);
2466 #ifdef CONFIG_SND_HDA_POWER_SAVE
2467 static struct hda_amp_list alc880_loopbacks[] = {
2468 { 0x0b, HDA_INPUT, 0 },
2469 { 0x0b, HDA_INPUT, 1 },
2470 { 0x0b, HDA_INPUT, 2 },
2471 { 0x0b, HDA_INPUT, 3 },
2472 { 0x0b, HDA_INPUT, 4 },
2476 static struct hda_amp_list alc880_lg_loopbacks[] = {
2477 { 0x0b, HDA_INPUT, 1 },
2478 { 0x0b, HDA_INPUT, 6 },
2479 { 0x0b, HDA_INPUT, 7 },
2488 static int alc_init(struct hda_codec *codec)
2490 struct alc_spec *spec = codec->spec;
2494 if (codec->vendor_id == 0x10ec0888)
2495 alc888_coef_init(codec);
2497 for (i = 0; i < spec->num_init_verbs; i++)
2498 snd_hda_sequence_write(codec, spec->init_verbs[i]);
2500 if (spec->init_hook)
2501 spec->init_hook(codec);
2506 static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
2508 struct alc_spec *spec = codec->spec;
2510 if (spec->unsol_event)
2511 spec->unsol_event(codec, res);
2514 #ifdef CONFIG_SND_HDA_POWER_SAVE
2515 static int alc_check_power_status(struct hda_codec *codec, hda_nid_t nid)
2517 struct alc_spec *spec = codec->spec;
2518 return snd_hda_check_amp_list_power(codec, &spec->loopback, nid);
2523 * Analog playback callbacks
2525 static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
2526 struct hda_codec *codec,
2527 struct snd_pcm_substream *substream)
2529 struct alc_spec *spec = codec->spec;
2530 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
2534 static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2535 struct hda_codec *codec,
2536 unsigned int stream_tag,
2537 unsigned int format,
2538 struct snd_pcm_substream *substream)
2540 struct alc_spec *spec = codec->spec;
2541 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
2542 stream_tag, format, substream);
2545 static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
2546 struct hda_codec *codec,
2547 struct snd_pcm_substream *substream)
2549 struct alc_spec *spec = codec->spec;
2550 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
2556 static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
2557 struct hda_codec *codec,
2558 struct snd_pcm_substream *substream)
2560 struct alc_spec *spec = codec->spec;
2561 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
2564 static int alc880_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2565 struct hda_codec *codec,
2566 unsigned int stream_tag,
2567 unsigned int format,
2568 struct snd_pcm_substream *substream)
2570 struct alc_spec *spec = codec->spec;
2571 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
2572 stream_tag, format, substream);
2575 static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
2576 struct hda_codec *codec,
2577 struct snd_pcm_substream *substream)
2579 struct alc_spec *spec = codec->spec;
2580 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
2586 static int alc880_alt_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
2587 struct hda_codec *codec,
2588 unsigned int stream_tag,
2589 unsigned int format,
2590 struct snd_pcm_substream *substream)
2592 struct alc_spec *spec = codec->spec;
2594 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number + 1],
2595 stream_tag, 0, format);
2599 static int alc880_alt_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
2600 struct hda_codec *codec,
2601 struct snd_pcm_substream *substream)
2603 struct alc_spec *spec = codec->spec;
2605 snd_hda_codec_cleanup_stream(codec,
2606 spec->adc_nids[substream->number + 1]);
2613 static struct hda_pcm_stream alc880_pcm_analog_playback = {
2617 /* NID is set in alc_build_pcms */
2619 .open = alc880_playback_pcm_open,
2620 .prepare = alc880_playback_pcm_prepare,
2621 .cleanup = alc880_playback_pcm_cleanup
2625 static struct hda_pcm_stream alc880_pcm_analog_capture = {
2629 /* NID is set in alc_build_pcms */
2632 static struct hda_pcm_stream alc880_pcm_analog_alt_playback = {
2636 /* NID is set in alc_build_pcms */
2639 static struct hda_pcm_stream alc880_pcm_analog_alt_capture = {
2640 .substreams = 2, /* can be overridden */
2643 /* NID is set in alc_build_pcms */
2645 .prepare = alc880_alt_capture_pcm_prepare,
2646 .cleanup = alc880_alt_capture_pcm_cleanup
2650 static struct hda_pcm_stream alc880_pcm_digital_playback = {
2654 /* NID is set in alc_build_pcms */
2656 .open = alc880_dig_playback_pcm_open,
2657 .close = alc880_dig_playback_pcm_close,
2658 .prepare = alc880_dig_playback_pcm_prepare
2662 static struct hda_pcm_stream alc880_pcm_digital_capture = {
2666 /* NID is set in alc_build_pcms */
2669 /* Used by alc_build_pcms to flag that a PCM has no playback stream */
2670 static struct hda_pcm_stream alc_pcm_null_stream = {
2676 static int alc_build_pcms(struct hda_codec *codec)
2678 struct alc_spec *spec = codec->spec;
2679 struct hda_pcm *info = spec->pcm_rec;
2682 codec->num_pcms = 1;
2683 codec->pcm_info = info;
2685 info->name = spec->stream_name_analog;
2686 if (spec->stream_analog_playback) {
2687 if (snd_BUG_ON(!spec->multiout.dac_nids))
2689 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
2690 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
2692 if (spec->stream_analog_capture) {
2693 if (snd_BUG_ON(!spec->adc_nids))
2695 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
2696 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
2699 if (spec->channel_mode) {
2700 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
2701 for (i = 0; i < spec->num_channel_mode; i++) {
2702 if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
2703 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
2708 /* SPDIF for stream index #1 */
2709 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
2710 codec->num_pcms = 2;
2711 info = spec->pcm_rec + 1;
2712 info->name = spec->stream_name_digital;
2713 info->pcm_type = HDA_PCM_TYPE_SPDIF;
2714 if (spec->multiout.dig_out_nid &&
2715 spec->stream_digital_playback) {
2716 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
2717 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
2719 if (spec->dig_in_nid &&
2720 spec->stream_digital_capture) {
2721 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
2722 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
2724 /* FIXME: do we need this for all Realtek codec models? */
2725 codec->spdif_status_reset = 1;
2728 /* If the use of more than one ADC is requested for the current
2729 * model, configure a second analog capture-only PCM.
2731 /* Additional Analaog capture for index #2 */
2732 if ((spec->alt_dac_nid && spec->stream_analog_alt_playback) ||
2733 (spec->num_adc_nids > 1 && spec->stream_analog_alt_capture)) {
2734 codec->num_pcms = 3;
2735 info = spec->pcm_rec + 2;
2736 info->name = spec->stream_name_analog;
2737 if (spec->alt_dac_nid) {
2738 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
2739 *spec->stream_analog_alt_playback;
2740 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
2743 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
2744 alc_pcm_null_stream;
2745 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
2747 if (spec->num_adc_nids > 1) {
2748 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
2749 *spec->stream_analog_alt_capture;
2750 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid =
2752 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams =
2753 spec->num_adc_nids - 1;
2755 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
2756 alc_pcm_null_stream;
2757 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = 0;
2764 static void alc_free(struct hda_codec *codec)
2766 struct alc_spec *spec = codec->spec;
2772 if (spec->kctl_alloc) {
2773 for (i = 0; i < spec->num_kctl_used; i++)
2774 kfree(spec->kctl_alloc[i].name);
2775 kfree(spec->kctl_alloc);
2778 codec->spec = NULL; /* to be sure */
2783 static struct hda_codec_ops alc_patch_ops = {
2784 .build_controls = alc_build_controls,
2785 .build_pcms = alc_build_pcms,
2788 .unsol_event = alc_unsol_event,
2789 #ifdef CONFIG_SND_HDA_POWER_SAVE
2790 .check_power_status = alc_check_power_status,
2796 * Test configuration for debugging
2798 * Almost all inputs/outputs are enabled. I/O pins can be configured via
2801 #ifdef CONFIG_SND_DEBUG
2802 static hda_nid_t alc880_test_dac_nids[4] = {
2803 0x02, 0x03, 0x04, 0x05
2806 static struct hda_input_mux alc880_test_capture_source = {
2815 { "Surround", 0x6 },
2819 static struct hda_channel_mode alc880_test_modes[4] = {
2826 static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol,
2827 struct snd_ctl_elem_info *uinfo)
2829 static char *texts[] = {
2830 "N/A", "Line Out", "HP Out",
2831 "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
2833 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
2835 uinfo->value.enumerated.items = 8;
2836 if (uinfo->value.enumerated.item >= 8)
2837 uinfo->value.enumerated.item = 7;
2838 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
2842 static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol,
2843 struct snd_ctl_elem_value *ucontrol)
2845 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2846 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2847 unsigned int pin_ctl, item = 0;
2849 pin_ctl = snd_hda_codec_read(codec, nid, 0,
2850 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
2851 if (pin_ctl & AC_PINCTL_OUT_EN) {
2852 if (pin_ctl & AC_PINCTL_HP_EN)
2856 } else if (pin_ctl & AC_PINCTL_IN_EN) {
2857 switch (pin_ctl & AC_PINCTL_VREFEN) {
2858 case AC_PINCTL_VREF_HIZ: item = 3; break;
2859 case AC_PINCTL_VREF_50: item = 4; break;
2860 case AC_PINCTL_VREF_GRD: item = 5; break;
2861 case AC_PINCTL_VREF_80: item = 6; break;
2862 case AC_PINCTL_VREF_100: item = 7; break;
2865 ucontrol->value.enumerated.item[0] = item;
2869 static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol,
2870 struct snd_ctl_elem_value *ucontrol)
2872 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2873 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2874 static unsigned int ctls[] = {
2875 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
2876 AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
2877 AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
2878 AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
2879 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
2880 AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
2882 unsigned int old_ctl, new_ctl;
2884 old_ctl = snd_hda_codec_read(codec, nid, 0,
2885 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
2886 new_ctl = ctls[ucontrol->value.enumerated.item[0]];
2887 if (old_ctl != new_ctl) {
2889 snd_hda_codec_write_cache(codec, nid, 0,
2890 AC_VERB_SET_PIN_WIDGET_CONTROL,
2892 val = ucontrol->value.enumerated.item[0] >= 3 ?
2894 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
2901 static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol,
2902 struct snd_ctl_elem_info *uinfo)
2904 static char *texts[] = {
2905 "Front", "Surround", "CLFE", "Side"
2907 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
2909 uinfo->value.enumerated.items = 4;
2910 if (uinfo->value.enumerated.item >= 4)
2911 uinfo->value.enumerated.item = 3;
2912 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
2916 static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol,
2917 struct snd_ctl_elem_value *ucontrol)
2919 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2920 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2923 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
2924 ucontrol->value.enumerated.item[0] = sel & 3;
2928 static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol,
2929 struct snd_ctl_elem_value *ucontrol)
2931 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2932 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2935 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
2936 if (ucontrol->value.enumerated.item[0] != sel) {
2937 sel = ucontrol->value.enumerated.item[0] & 3;
2938 snd_hda_codec_write_cache(codec, nid, 0,
2939 AC_VERB_SET_CONNECT_SEL, sel);
2945 #define PIN_CTL_TEST(xname,nid) { \
2946 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2948 .info = alc_test_pin_ctl_info, \
2949 .get = alc_test_pin_ctl_get, \
2950 .put = alc_test_pin_ctl_put, \
2951 .private_value = nid \
2954 #define PIN_SRC_TEST(xname,nid) { \
2955 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2957 .info = alc_test_pin_src_info, \
2958 .get = alc_test_pin_src_get, \
2959 .put = alc_test_pin_src_put, \
2960 .private_value = nid \
2963 static struct snd_kcontrol_new alc880_test_mixer[] = {
2964 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2965 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2966 HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
2967 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
2968 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2969 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
2970 HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
2971 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
2972 PIN_CTL_TEST("Front Pin Mode", 0x14),
2973 PIN_CTL_TEST("Surround Pin Mode", 0x15),
2974 PIN_CTL_TEST("CLFE Pin Mode", 0x16),
2975 PIN_CTL_TEST("Side Pin Mode", 0x17),
2976 PIN_CTL_TEST("In-1 Pin Mode", 0x18),
2977 PIN_CTL_TEST("In-2 Pin Mode", 0x19),
2978 PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
2979 PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
2980 PIN_SRC_TEST("In-1 Pin Source", 0x18),
2981 PIN_SRC_TEST("In-2 Pin Source", 0x19),
2982 PIN_SRC_TEST("In-3 Pin Source", 0x1a),
2983 PIN_SRC_TEST("In-4 Pin Source", 0x1b),
2984 HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
2985 HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
2986 HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
2987 HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
2988 HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
2989 HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
2990 HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
2991 HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
2992 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
2993 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
2995 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2996 .name = "Channel Mode",
2997 .info = alc_ch_mode_info,
2998 .get = alc_ch_mode_get,
2999 .put = alc_ch_mode_put,
3004 static struct hda_verb alc880_test_init_verbs[] = {
3005 /* Unmute inputs of 0x0c - 0x0f */
3006 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3007 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3008 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3009 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3010 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3011 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3012 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3013 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3014 /* Vol output for 0x0c-0x0f */
3015 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3016 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3017 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3018 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3019 /* Set output pins 0x14-0x17 */
3020 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3021 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3022 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3023 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3024 /* Unmute output pins 0x14-0x17 */
3025 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3026 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3027 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3028 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3029 /* Set input pins 0x18-0x1c */
3030 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3031 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3032 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3033 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3034 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3035 /* Mute input pins 0x18-0x1b */
3036 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3037 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3038 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3039 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3041 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3042 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
3043 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3044 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
3045 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3046 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
3047 /* Analog input/passthru */
3048 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3049 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3050 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
3051 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
3052 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
3060 static const char *alc880_models[ALC880_MODEL_LAST] = {
3061 [ALC880_3ST] = "3stack",
3062 [ALC880_TCL_S700] = "tcl",
3063 [ALC880_3ST_DIG] = "3stack-digout",
3064 [ALC880_CLEVO] = "clevo",
3065 [ALC880_5ST] = "5stack",
3066 [ALC880_5ST_DIG] = "5stack-digout",
3067 [ALC880_W810] = "w810",
3068 [ALC880_Z71V] = "z71v",
3069 [ALC880_6ST] = "6stack",
3070 [ALC880_6ST_DIG] = "6stack-digout",
3071 [ALC880_ASUS] = "asus",
3072 [ALC880_ASUS_W1V] = "asus-w1v",
3073 [ALC880_ASUS_DIG] = "asus-dig",
3074 [ALC880_ASUS_DIG2] = "asus-dig2",
3075 [ALC880_UNIWILL_DIG] = "uniwill",
3076 [ALC880_UNIWILL_P53] = "uniwill-p53",
3077 [ALC880_FUJITSU] = "fujitsu",
3078 [ALC880_F1734] = "F1734",
3080 [ALC880_LG_LW] = "lg-lw",
3081 [ALC880_MEDION_RIM] = "medion",
3082 #ifdef CONFIG_SND_DEBUG
3083 [ALC880_TEST] = "test",
3085 [ALC880_AUTO] = "auto",
3088 static struct snd_pci_quirk alc880_cfg_tbl[] = {
3089 SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_W810),
3090 SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_5ST_DIG),
3091 SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_6ST),
3092 SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_3ST_DIG),
3093 SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_6ST_DIG),
3094 SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_6ST_DIG),
3095 SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_6ST_DIG),
3096 SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_3ST_DIG),
3097 SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_3ST),
3098 SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_6ST_DIG),
3099 SND_PCI_QUIRK(0x103c, 0x2a09, "HP", ALC880_5ST),
3100 SND_PCI_QUIRK(0x1043, 0x10b3, "ASUS W1V", ALC880_ASUS_W1V),
3101 SND_PCI_QUIRK(0x1043, 0x10c2, "ASUS W6A", ALC880_ASUS_DIG),
3102 SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS Wxx", ALC880_ASUS_DIG),
3103 SND_PCI_QUIRK(0x1043, 0x1113, "ASUS", ALC880_ASUS_DIG),
3104 SND_PCI_QUIRK(0x1043, 0x1123, "ASUS", ALC880_ASUS_DIG),
3105 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS", ALC880_ASUS_DIG),
3106 SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_Z71V),
3107 /* SND_PCI_QUIRK(0x1043, 0x1964, "ASUS", ALC880_ASUS_DIG), */
3108 SND_PCI_QUIRK(0x1043, 0x1973, "ASUS", ALC880_ASUS_DIG),
3109 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS", ALC880_ASUS_DIG),
3110 SND_PCI_QUIRK(0x1043, 0x814e, "ASUS P5GD1 w/SPDIF", ALC880_6ST_DIG),
3111 SND_PCI_QUIRK(0x1043, 0x8181, "ASUS P4GPL", ALC880_ASUS_DIG),
3112 SND_PCI_QUIRK(0x1043, 0x8196, "ASUS P5GD1", ALC880_6ST),
3113 SND_PCI_QUIRK(0x1043, 0x81b4, "ASUS", ALC880_6ST),
3114 SND_PCI_QUIRK(0x1043, 0, "ASUS", ALC880_ASUS), /* default ASUS */
3115 SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_3ST),
3116 SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_3ST),
3117 SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_5ST),
3118 SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_5ST),
3119 SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_5ST),
3120 SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_6ST_DIG),
3121 SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_6ST_DIG),
3122 SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_6ST_DIG),
3123 SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_6ST_DIG),
3124 SND_PCI_QUIRK(0x1558, 0x0520, "Clevo m520G", ALC880_CLEVO),
3125 SND_PCI_QUIRK(0x1558, 0x0660, "Clevo m655n", ALC880_CLEVO),
3126 SND_PCI_QUIRK(0x1558, 0x5401, "ASUS", ALC880_ASUS_DIG2),
3127 SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_5ST_DIG),
3128 SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_UNIWILL_DIG),
3129 SND_PCI_QUIRK(0x1584, 0x9054, "Uniwlll", ALC880_F1734),
3130 SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_UNIWILL),
3131 SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_UNIWILL_P53),
3132 SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_W810),
3133 SND_PCI_QUIRK(0x161f, 0x205d, "Medion Rim 2150", ALC880_MEDION_RIM),
3134 SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_5ST_DIG),
3135 SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_5ST_DIG),
3136 SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_F1734),
3137 SND_PCI_QUIRK(0x1734, 0x1094, "FSC Amilo M1451G", ALC880_FUJITSU),
3138 SND_PCI_QUIRK(0x1734, 0x10ac, "FSC", ALC880_UNIWILL),
3139 SND_PCI_QUIRK(0x1734, 0x10b0, "Fujitsu", ALC880_FUJITSU),
3140 SND_PCI_QUIRK(0x1854, 0x0018, "LG LW20", ALC880_LG_LW),
3141 SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_LG),
3142 SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_LG),
3143 SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_LG_LW),
3144 SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_TCL_S700),
3145 SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_6ST_DIG), /* broken BIOS */
3146 SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_6ST_DIG),
3147 SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_5ST_DIG),
3148 SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_5ST_DIG),
3149 SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_5ST_DIG),
3150 SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_3ST_DIG),
3151 SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_5ST_DIG),
3152 SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_3ST_DIG),
3153 SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_3ST_DIG),
3154 SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_5ST_DIG),
3155 SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_5ST_DIG),
3156 SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_5ST_DIG),
3157 SND_PCI_QUIRK(0x8086, 0, "Intel mobo", ALC880_3ST), /* default Intel */
3158 SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_5ST_DIG),
3159 SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_6ST_DIG),
3164 * ALC880 codec presets
3166 static struct alc_config_preset alc880_presets[] = {
3168 .mixers = { alc880_three_stack_mixer },
3169 .init_verbs = { alc880_volume_init_verbs,
3170 alc880_pin_3stack_init_verbs },
3171 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3172 .dac_nids = alc880_dac_nids,
3173 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3174 .channel_mode = alc880_threestack_modes,
3176 .input_mux = &alc880_capture_source,
3178 [ALC880_3ST_DIG] = {
3179 .mixers = { alc880_three_stack_mixer },
3180 .init_verbs = { alc880_volume_init_verbs,
3181 alc880_pin_3stack_init_verbs },
3182 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3183 .dac_nids = alc880_dac_nids,
3184 .dig_out_nid = ALC880_DIGOUT_NID,
3185 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3186 .channel_mode = alc880_threestack_modes,
3188 .input_mux = &alc880_capture_source,
3190 [ALC880_TCL_S700] = {
3191 .mixers = { alc880_tcl_s700_mixer },
3192 .init_verbs = { alc880_volume_init_verbs,
3193 alc880_pin_tcl_S700_init_verbs,
3194 alc880_gpio2_init_verbs },
3195 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3196 .dac_nids = alc880_dac_nids,
3198 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3199 .channel_mode = alc880_2_jack_modes,
3200 .input_mux = &alc880_capture_source,
3203 .mixers = { alc880_three_stack_mixer,
3204 alc880_five_stack_mixer},
3205 .init_verbs = { alc880_volume_init_verbs,
3206 alc880_pin_5stack_init_verbs },
3207 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3208 .dac_nids = alc880_dac_nids,
3209 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
3210 .channel_mode = alc880_fivestack_modes,
3211 .input_mux = &alc880_capture_source,
3213 [ALC880_5ST_DIG] = {
3214 .mixers = { alc880_three_stack_mixer,
3215 alc880_five_stack_mixer },
3216 .init_verbs = { alc880_volume_init_verbs,
3217 alc880_pin_5stack_init_verbs },
3218 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3219 .dac_nids = alc880_dac_nids,
3220 .dig_out_nid = ALC880_DIGOUT_NID,
3221 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
3222 .channel_mode = alc880_fivestack_modes,
3223 .input_mux = &alc880_capture_source,
3226 .mixers = { alc880_six_stack_mixer },
3227 .init_verbs = { alc880_volume_init_verbs,
3228 alc880_pin_6stack_init_verbs },
3229 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
3230 .dac_nids = alc880_6st_dac_nids,
3231 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
3232 .channel_mode = alc880_sixstack_modes,
3233 .input_mux = &alc880_6stack_capture_source,
3235 [ALC880_6ST_DIG] = {
3236 .mixers = { alc880_six_stack_mixer },
3237 .init_verbs = { alc880_volume_init_verbs,
3238 alc880_pin_6stack_init_verbs },
3239 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
3240 .dac_nids = alc880_6st_dac_nids,
3241 .dig_out_nid = ALC880_DIGOUT_NID,
3242 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
3243 .channel_mode = alc880_sixstack_modes,
3244 .input_mux = &alc880_6stack_capture_source,
3247 .mixers = { alc880_w810_base_mixer },
3248 .init_verbs = { alc880_volume_init_verbs,
3249 alc880_pin_w810_init_verbs,
3250 alc880_gpio2_init_verbs },
3251 .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
3252 .dac_nids = alc880_w810_dac_nids,
3253 .dig_out_nid = ALC880_DIGOUT_NID,
3254 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
3255 .channel_mode = alc880_w810_modes,
3256 .input_mux = &alc880_capture_source,
3259 .mixers = { alc880_z71v_mixer },
3260 .init_verbs = { alc880_volume_init_verbs,
3261 alc880_pin_z71v_init_verbs },
3262 .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
3263 .dac_nids = alc880_z71v_dac_nids,
3264 .dig_out_nid = ALC880_DIGOUT_NID,
3266 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3267 .channel_mode = alc880_2_jack_modes,
3268 .input_mux = &alc880_capture_source,
3271 .mixers = { alc880_f1734_mixer },
3272 .init_verbs = { alc880_volume_init_verbs,
3273 alc880_pin_f1734_init_verbs },
3274 .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
3275 .dac_nids = alc880_f1734_dac_nids,
3277 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3278 .channel_mode = alc880_2_jack_modes,
3279 .input_mux = &alc880_f1734_capture_source,
3280 .unsol_event = alc880_uniwill_p53_unsol_event,
3281 .init_hook = alc880_uniwill_p53_hp_automute,
3284 .mixers = { alc880_asus_mixer },
3285 .init_verbs = { alc880_volume_init_verbs,
3286 alc880_pin_asus_init_verbs,
3287 alc880_gpio1_init_verbs },
3288 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3289 .dac_nids = alc880_asus_dac_nids,
3290 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3291 .channel_mode = alc880_asus_modes,
3293 .input_mux = &alc880_capture_source,
3295 [ALC880_ASUS_DIG] = {
3296 .mixers = { alc880_asus_mixer },
3297 .init_verbs = { alc880_volume_init_verbs,
3298 alc880_pin_asus_init_verbs,
3299 alc880_gpio1_init_verbs },
3300 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3301 .dac_nids = alc880_asus_dac_nids,
3302 .dig_out_nid = ALC880_DIGOUT_NID,
3303 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3304 .channel_mode = alc880_asus_modes,
3306 .input_mux = &alc880_capture_source,
3308 [ALC880_ASUS_DIG2] = {
3309 .mixers = { alc880_asus_mixer },
3310 .init_verbs = { alc880_volume_init_verbs,
3311 alc880_pin_asus_init_verbs,
3312 alc880_gpio2_init_verbs }, /* use GPIO2 */
3313 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3314 .dac_nids = alc880_asus_dac_nids,
3315 .dig_out_nid = ALC880_DIGOUT_NID,
3316 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3317 .channel_mode = alc880_asus_modes,
3319 .input_mux = &alc880_capture_source,
3321 [ALC880_ASUS_W1V] = {
3322 .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
3323 .init_verbs = { alc880_volume_init_verbs,
3324 alc880_pin_asus_init_verbs,
3325 alc880_gpio1_init_verbs },
3326 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3327 .dac_nids = alc880_asus_dac_nids,
3328 .dig_out_nid = ALC880_DIGOUT_NID,
3329 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3330 .channel_mode = alc880_asus_modes,
3332 .input_mux = &alc880_capture_source,
3334 [ALC880_UNIWILL_DIG] = {
3335 .mixers = { alc880_asus_mixer, alc880_pcbeep_mixer },
3336 .init_verbs = { alc880_volume_init_verbs,
3337 alc880_pin_asus_init_verbs },
3338 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3339 .dac_nids = alc880_asus_dac_nids,
3340 .dig_out_nid = ALC880_DIGOUT_NID,
3341 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3342 .channel_mode = alc880_asus_modes,
3344 .input_mux = &alc880_capture_source,
3346 [ALC880_UNIWILL] = {
3347 .mixers = { alc880_uniwill_mixer },
3348 .init_verbs = { alc880_volume_init_verbs,
3349 alc880_uniwill_init_verbs },
3350 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3351 .dac_nids = alc880_asus_dac_nids,
3352 .dig_out_nid = ALC880_DIGOUT_NID,
3353 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3354 .channel_mode = alc880_threestack_modes,
3356 .input_mux = &alc880_capture_source,
3357 .unsol_event = alc880_uniwill_unsol_event,
3358 .init_hook = alc880_uniwill_automute,
3360 [ALC880_UNIWILL_P53] = {
3361 .mixers = { alc880_uniwill_p53_mixer },
3362 .init_verbs = { alc880_volume_init_verbs,
3363 alc880_uniwill_p53_init_verbs },
3364 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3365 .dac_nids = alc880_asus_dac_nids,
3366 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
3367 .channel_mode = alc880_threestack_modes,
3368 .input_mux = &alc880_capture_source,
3369 .unsol_event = alc880_uniwill_p53_unsol_event,
3370 .init_hook = alc880_uniwill_p53_hp_automute,
3372 [ALC880_FUJITSU] = {
3373 .mixers = { alc880_fujitsu_mixer,
3374 alc880_pcbeep_mixer, },
3375 .init_verbs = { alc880_volume_init_verbs,
3376 alc880_uniwill_p53_init_verbs,
3377 alc880_beep_init_verbs },
3378 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3379 .dac_nids = alc880_dac_nids,
3380 .dig_out_nid = ALC880_DIGOUT_NID,
3381 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3382 .channel_mode = alc880_2_jack_modes,
3383 .input_mux = &alc880_capture_source,
3384 .unsol_event = alc880_uniwill_p53_unsol_event,
3385 .init_hook = alc880_uniwill_p53_hp_automute,
3388 .mixers = { alc880_three_stack_mixer },
3389 .init_verbs = { alc880_volume_init_verbs,
3390 alc880_pin_clevo_init_verbs },
3391 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3392 .dac_nids = alc880_dac_nids,
3394 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3395 .channel_mode = alc880_threestack_modes,
3397 .input_mux = &alc880_capture_source,
3400 .mixers = { alc880_lg_mixer },
3401 .init_verbs = { alc880_volume_init_verbs,
3402 alc880_lg_init_verbs },
3403 .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids),
3404 .dac_nids = alc880_lg_dac_nids,
3405 .dig_out_nid = ALC880_DIGOUT_NID,
3406 .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes),
3407 .channel_mode = alc880_lg_ch_modes,
3409 .input_mux = &alc880_lg_capture_source,
3410 .unsol_event = alc880_lg_unsol_event,
3411 .init_hook = alc880_lg_automute,
3412 #ifdef CONFIG_SND_HDA_POWER_SAVE
3413 .loopbacks = alc880_lg_loopbacks,
3417 .mixers = { alc880_lg_lw_mixer },
3418 .init_verbs = { alc880_volume_init_verbs,
3419 alc880_lg_lw_init_verbs },
3420 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3421 .dac_nids = alc880_dac_nids,
3422 .dig_out_nid = ALC880_DIGOUT_NID,
3423 .num_channel_mode = ARRAY_SIZE(alc880_lg_lw_modes),
3424 .channel_mode = alc880_lg_lw_modes,
3425 .input_mux = &alc880_lg_lw_capture_source,
3426 .unsol_event = alc880_lg_lw_unsol_event,
3427 .init_hook = alc880_lg_lw_automute,
3429 [ALC880_MEDION_RIM] = {
3430 .mixers = { alc880_medion_rim_mixer },
3431 .init_verbs = { alc880_volume_init_verbs,
3432 alc880_medion_rim_init_verbs,
3433 alc_gpio2_init_verbs },
3434 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3435 .dac_nids = alc880_dac_nids,
3436 .dig_out_nid = ALC880_DIGOUT_NID,
3437 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3438 .channel_mode = alc880_2_jack_modes,
3439 .input_mux = &alc880_medion_rim_capture_source,
3440 .unsol_event = alc880_medion_rim_unsol_event,
3441 .init_hook = alc880_medion_rim_automute,
3443 #ifdef CONFIG_SND_DEBUG
3445 .mixers = { alc880_test_mixer },
3446 .init_verbs = { alc880_test_init_verbs },
3447 .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
3448 .dac_nids = alc880_test_dac_nids,
3449 .dig_out_nid = ALC880_DIGOUT_NID,
3450 .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
3451 .channel_mode = alc880_test_modes,
3452 .input_mux = &alc880_test_capture_source,
3458 * Automatic parse of I/O pins from the BIOS configuration
3461 #define NUM_CONTROL_ALLOC 32
3462 #define NUM_VERB_ALLOC 32
3466 ALC_CTL_WIDGET_MUTE,
3469 static struct snd_kcontrol_new alc880_control_templates[] = {
3470 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
3471 HDA_CODEC_MUTE(NULL, 0, 0, 0),
3472 HDA_BIND_MUTE(NULL, 0, 0, 0),
3475 /* add dynamic controls */
3476 static int add_control(struct alc_spec *spec, int type, const char *name,
3479 struct snd_kcontrol_new *knew;
3481 if (spec->num_kctl_used >= spec->num_kctl_alloc) {
3482 int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC;
3484 /* array + terminator */
3485 knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL);
3488 if (spec->kctl_alloc) {
3489 memcpy(knew, spec->kctl_alloc,
3490 sizeof(*knew) * spec->num_kctl_alloc);
3491 kfree(spec->kctl_alloc);
3493 spec->kctl_alloc = knew;
3494 spec->num_kctl_alloc = num;
3497 knew = &spec->kctl_alloc[spec->num_kctl_used];
3498 *knew = alc880_control_templates[type];
3499 knew->name = kstrdup(name, GFP_KERNEL);
3502 knew->private_value = val;
3503 spec->num_kctl_used++;
3507 #define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
3508 #define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
3509 #define alc880_is_multi_pin(nid) ((nid) >= 0x18)
3510 #define alc880_multi_pin_idx(nid) ((nid) - 0x18)
3511 #define alc880_is_input_pin(nid) ((nid) >= 0x18)
3512 #define alc880_input_pin_idx(nid) ((nid) - 0x18)
3513 #define alc880_idx_to_dac(nid) ((nid) + 0x02)
3514 #define alc880_dac_to_idx(nid) ((nid) - 0x02)
3515 #define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
3516 #define alc880_idx_to_selector(nid) ((nid) + 0x10)
3517 #define ALC880_PIN_CD_NID 0x1c
3519 /* fill in the dac_nids table from the parsed pin configuration */
3520 static int alc880_auto_fill_dac_nids(struct alc_spec *spec,
3521 const struct auto_pin_cfg *cfg)
3527 memset(assigned, 0, sizeof(assigned));
3528 spec->multiout.dac_nids = spec->private_dac_nids;
3530 /* check the pins hardwired to audio widget */
3531 for (i = 0; i < cfg->line_outs; i++) {
3532 nid = cfg->line_out_pins[i];
3533 if (alc880_is_fixed_pin(nid)) {
3534 int idx = alc880_fixed_pin_idx(nid);
3535 spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
3539 /* left pins can be connect to any audio widget */
3540 for (i = 0; i < cfg->line_outs; i++) {
3541 nid = cfg->line_out_pins[i];
3542 if (alc880_is_fixed_pin(nid))
3544 /* search for an empty channel */
3545 for (j = 0; j < cfg->line_outs; j++) {
3547 spec->multiout.dac_nids[i] =
3548 alc880_idx_to_dac(j);
3554 spec->multiout.num_dacs = cfg->line_outs;
3558 /* add playback controls from the parsed DAC table */
3559 static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
3560 const struct auto_pin_cfg *cfg)
3563 static const char *chname[4] = {
3564 "Front", "Surround", NULL /*CLFE*/, "Side"
3569 for (i = 0; i < cfg->line_outs; i++) {
3570 if (!spec->multiout.dac_nids[i])
3572 nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
3575 err = add_control(spec, ALC_CTL_WIDGET_VOL,
3576 "Center Playback Volume",
3577 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
3581 err = add_control(spec, ALC_CTL_WIDGET_VOL,
3582 "LFE Playback Volume",
3583 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
3587 err = add_control(spec, ALC_CTL_BIND_MUTE,
3588 "Center Playback Switch",
3589 HDA_COMPOSE_AMP_VAL(nid, 1, 2,
3593 err = add_control(spec, ALC_CTL_BIND_MUTE,
3594 "LFE Playback Switch",
3595 HDA_COMPOSE_AMP_VAL(nid, 2, 2,
3600 sprintf(name, "%s Playback Volume", chname[i]);
3601 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
3602 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
3606 sprintf(name, "%s Playback Switch", chname[i]);
3607 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
3608 HDA_COMPOSE_AMP_VAL(nid, 3, 2,
3617 /* add playback controls for speaker and HP outputs */
3618 static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
3628 if (alc880_is_fixed_pin(pin)) {
3629 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
3630 /* specify the DAC as the extra output */
3631 if (!spec->multiout.hp_nid)
3632 spec->multiout.hp_nid = nid;
3634 spec->multiout.extra_out_nid[0] = nid;
3635 /* control HP volume/switch on the output mixer amp */
3636 nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
3637 sprintf(name, "%s Playback Volume", pfx);
3638 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
3639 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
3642 sprintf(name, "%s Playback Switch", pfx);
3643 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
3644 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
3647 } else if (alc880_is_multi_pin(pin)) {
3648 /* set manual connection */
3649 /* we have only a switch on HP-out PIN */
3650 sprintf(name, "%s Playback Switch", pfx);
3651 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
3652 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
3659 /* create input playback/capture controls for the given pin */
3660 static int new_analog_input(struct alc_spec *spec, hda_nid_t pin,
3661 const char *ctlname,
3662 int idx, hda_nid_t mix_nid)
3667 sprintf(name, "%s Playback Volume", ctlname);
3668 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
3669 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
3672 sprintf(name, "%s Playback Switch", ctlname);
3673 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
3674 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
3680 /* create playback/capture controls for input pins */
3681 static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec,
3682 const struct auto_pin_cfg *cfg)
3684 struct hda_input_mux *imux = &spec->private_imux;
3687 for (i = 0; i < AUTO_PIN_LAST; i++) {
3688 if (alc880_is_input_pin(cfg->input_pins[i])) {
3689 idx = alc880_input_pin_idx(cfg->input_pins[i]);
3690 err = new_analog_input(spec, cfg->input_pins[i],
3691 auto_pin_cfg_labels[i],
3695 imux->items[imux->num_items].label =
3696 auto_pin_cfg_labels[i];
3697 imux->items[imux->num_items].index =
3698 alc880_input_pin_idx(cfg->input_pins[i]);
3705 static void alc_set_pin_output(struct hda_codec *codec, hda_nid_t nid,
3706 unsigned int pin_type)
3708 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
3711 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
3715 static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
3716 hda_nid_t nid, int pin_type,
3719 alc_set_pin_output(codec, nid, pin_type);
3720 /* need the manual connection? */
3721 if (alc880_is_multi_pin(nid)) {
3722 struct alc_spec *spec = codec->spec;
3723 int idx = alc880_multi_pin_idx(nid);
3724 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
3725 AC_VERB_SET_CONNECT_SEL,
3726 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
3730 static int get_pin_type(int line_out_type)
3732 if (line_out_type == AUTO_PIN_HP_OUT)
3738 static void alc880_auto_init_multi_out(struct hda_codec *codec)
3740 struct alc_spec *spec = codec->spec;
3743 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
3744 for (i = 0; i < spec->autocfg.line_outs; i++) {
3745 hda_nid_t nid = spec->autocfg.line_out_pins[i];
3746 int pin_type = get_pin_type(spec->autocfg.line_out_type);
3747 alc880_auto_set_output_and_unmute(codec, nid, pin_type, i);
3751 static void alc880_auto_init_extra_out(struct hda_codec *codec)
3753 struct alc_spec *spec = codec->spec;
3756 pin = spec->autocfg.speaker_pins[0];
3757 if (pin) /* connect to front */
3758 alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
3759 pin = spec->autocfg.hp_pins[0];
3760 if (pin) /* connect to front */
3761 alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
3764 static void alc880_auto_init_analog_input(struct hda_codec *codec)
3766 struct alc_spec *spec = codec->spec;
3769 for (i = 0; i < AUTO_PIN_LAST; i++) {
3770 hda_nid_t nid = spec->autocfg.input_pins[i];
3771 if (alc880_is_input_pin(nid)) {
3772 snd_hda_codec_write(codec, nid, 0,
3773 AC_VERB_SET_PIN_WIDGET_CONTROL,
3774 i <= AUTO_PIN_FRONT_MIC ?
3775 PIN_VREF80 : PIN_IN);
3776 if (nid != ALC880_PIN_CD_NID)
3777 snd_hda_codec_write(codec, nid, 0,
3778 AC_VERB_SET_AMP_GAIN_MUTE,
3784 /* parse the BIOS configuration and set up the alc_spec */
3785 /* return 1 if successful, 0 if the proper config is not found,
3786 * or a negative error code
3788 static int alc880_parse_auto_config(struct hda_codec *codec)
3790 struct alc_spec *spec = codec->spec;
3792 static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
3794 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
3798 if (!spec->autocfg.line_outs)
3799 return 0; /* can't find valid BIOS pin config */
3801 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
3804 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
3807 err = alc880_auto_create_extra_out(spec,
3808 spec->autocfg.speaker_pins[0],
3812 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
3816 err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
3820 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
3822 if (spec->autocfg.dig_out_pin)
3823 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
3824 if (spec->autocfg.dig_in_pin)
3825 spec->dig_in_nid = ALC880_DIGIN_NID;
3827 if (spec->kctl_alloc)
3828 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
3830 spec->init_verbs[spec->num_init_verbs++] = alc880_volume_init_verbs;
3832 spec->num_mux_defs = 1;
3833 spec->input_mux = &spec->private_imux;
3838 /* additional initialization for auto-configuration model */
3839 static void alc880_auto_init(struct hda_codec *codec)
3841 struct alc_spec *spec = codec->spec;
3842 alc880_auto_init_multi_out(codec);
3843 alc880_auto_init_extra_out(codec);
3844 alc880_auto_init_analog_input(codec);
3845 if (spec->unsol_event)
3846 alc_inithook(codec);
3850 * OK, here we have finally the patch for ALC880
3853 static int patch_alc880(struct hda_codec *codec)
3855 struct alc_spec *spec;
3859 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
3865 board_config = snd_hda_check_board_config(codec, ALC880_MODEL_LAST,
3868 if (board_config < 0) {
3869 printk(KERN_INFO "hda_codec: Unknown model for ALC880, "
3870 "trying auto-probe from BIOS...\n");
3871 board_config = ALC880_AUTO;
3874 if (board_config == ALC880_AUTO) {
3875 /* automatic parse from the BIOS config */
3876 err = alc880_parse_auto_config(codec);
3882 "hda_codec: Cannot set up configuration "
3883 "from BIOS. Using 3-stack mode...\n");
3884 board_config = ALC880_3ST;
3888 if (board_config != ALC880_AUTO)
3889 setup_preset(spec, &alc880_presets[board_config]);
3891 spec->stream_name_analog = "ALC880 Analog";
3892 spec->stream_analog_playback = &alc880_pcm_analog_playback;
3893 spec->stream_analog_capture = &alc880_pcm_analog_capture;
3894 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
3896 spec->stream_name_digital = "ALC880 Digital";
3897 spec->stream_digital_playback = &alc880_pcm_digital_playback;
3898 spec->stream_digital_capture = &alc880_pcm_digital_capture;
3900 if (!spec->adc_nids && spec->input_mux) {
3901 /* check whether NID 0x07 is valid */
3902 unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
3904 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
3905 if (wcap != AC_WID_AUD_IN) {
3906 spec->adc_nids = alc880_adc_nids_alt;
3907 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
3908 spec->mixers[spec->num_mixers] =
3909 alc880_capture_alt_mixer;
3912 spec->adc_nids = alc880_adc_nids;
3913 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
3914 spec->mixers[spec->num_mixers] = alc880_capture_mixer;
3919 spec->vmaster_nid = 0x0c;
3921 codec->patch_ops = alc_patch_ops;
3922 if (board_config == ALC880_AUTO)
3923 spec->init_hook = alc880_auto_init;
3924 #ifdef CONFIG_SND_HDA_POWER_SAVE
3925 if (!spec->loopback.amplist)
3926 spec->loopback.amplist = alc880_loopbacks;
3937 static hda_nid_t alc260_dac_nids[1] = {
3942 static hda_nid_t alc260_adc_nids[1] = {
3947 static hda_nid_t alc260_adc_nids_alt[1] = {
3952 static hda_nid_t alc260_hp_adc_nids[2] = {
3957 /* NIDs used when simultaneous access to both ADCs makes sense. Note that
3958 * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
3960 static hda_nid_t alc260_dual_adc_nids[2] = {
3965 #define ALC260_DIGOUT_NID 0x03
3966 #define ALC260_DIGIN_NID 0x06
3968 static struct hda_input_mux alc260_capture_source = {
3972 { "Front Mic", 0x1 },
3978 /* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
3979 * headphone jack and the internal CD lines since these are the only pins at
3980 * which audio can appear. For flexibility, also allow the option of
3981 * recording the mixer output on the second ADC (ADC0 doesn't have a
3982 * connection to the mixer output).
3984 static struct hda_input_mux alc260_fujitsu_capture_sources[2] = {
3988 { "Mic/Line", 0x0 },
3990 { "Headphone", 0x2 },
3996 { "Mic/Line", 0x0 },
3998 { "Headphone", 0x2 },
4005 /* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to
4006 * the Fujitsu S702x, but jacks are marked differently.
4008 static struct hda_input_mux alc260_acer_capture_sources[2] = {
4015 { "Headphone", 0x5 },
4024 { "Headphone", 0x6 },
4030 * This is just place-holder, so there's something for alc_build_pcms to look
4031 * at when it calculates the maximum number of channels. ALC260 has no mixer
4032 * element which allows changing the channel mode, so the verb list is
4035 static struct hda_channel_mode alc260_modes[1] = {
4040 /* Mixer combinations
4042 * basic: base_output + input + pc_beep + capture
4043 * HP: base_output + input + capture_alt
4044 * HP_3013: hp_3013 + input + capture
4045 * fujitsu: fujitsu + capture
4046 * acer: acer + capture
4049 static struct snd_kcontrol_new alc260_base_output_mixer[] = {
4050 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4051 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
4052 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4053 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
4054 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
4055 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
4059 static struct snd_kcontrol_new alc260_input_mixer[] = {
4060 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4061 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4062 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
4063 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
4064 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4065 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4066 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
4067 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
4071 static struct snd_kcontrol_new alc260_pc_beep_mixer[] = {
4072 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x07, 0x05, HDA_INPUT),
4073 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x07, 0x05, HDA_INPUT),
4077 /* update HP, line and mono out pins according to the master switch */
4078 static void alc260_hp_master_update(struct hda_codec *codec,
4079 hda_nid_t hp, hda_nid_t line,
4082 struct alc_spec *spec = codec->spec;
4083 unsigned int val = spec->master_sw ? PIN_HP : 0;
4084 /* change HP and line-out pins */
4085 snd_hda_codec_write(codec, 0x0f, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4087 snd_hda_codec_write(codec, 0x10, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4089 /* mono (speaker) depending on the HP jack sense */
4090 val = (val && !spec->jack_present) ? PIN_OUT : 0;
4091 snd_hda_codec_write(codec, 0x11, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4095 static int alc260_hp_master_sw_get(struct snd_kcontrol *kcontrol,
4096 struct snd_ctl_elem_value *ucontrol)
4098 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4099 struct alc_spec *spec = codec->spec;
4100 *ucontrol->value.integer.value = spec->master_sw;
4104 static int alc260_hp_master_sw_put(struct snd_kcontrol *kcontrol,
4105 struct snd_ctl_elem_value *ucontrol)
4107 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4108 struct alc_spec *spec = codec->spec;
4109 int val = !!*ucontrol->value.integer.value;
4110 hda_nid_t hp, line, mono;
4112 if (val == spec->master_sw)
4114 spec->master_sw = val;
4115 hp = (kcontrol->private_value >> 16) & 0xff;
4116 line = (kcontrol->private_value >> 8) & 0xff;
4117 mono = kcontrol->private_value & 0xff;
4118 alc260_hp_master_update(codec, hp, line, mono);
4122 static struct snd_kcontrol_new alc260_hp_output_mixer[] = {
4124 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4125 .name = "Master Playback Switch",
4126 .info = snd_ctl_boolean_mono_info,
4127 .get = alc260_hp_master_sw_get,
4128 .put = alc260_hp_master_sw_put,
4129 .private_value = (0x0f << 16) | (0x10 << 8) | 0x11
4131 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4132 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
4133 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4134 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
4135 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
4137 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2, HDA_INPUT),
4141 static struct hda_verb alc260_hp_unsol_verbs[] = {
4142 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
4146 static void alc260_hp_automute(struct hda_codec *codec)
4148 struct alc_spec *spec = codec->spec;
4149 unsigned int present;
4151 present = snd_hda_codec_read(codec, 0x10, 0,
4152 AC_VERB_GET_PIN_SENSE, 0);
4153 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
4154 alc260_hp_master_update(codec, 0x0f, 0x10, 0x11);
4157 static void alc260_hp_unsol_event(struct hda_codec *codec, unsigned int res)
4159 if ((res >> 26) == ALC880_HP_EVENT)
4160 alc260_hp_automute(codec);
4163 static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
4165 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4166 .name = "Master Playback Switch",
4167 .info = snd_ctl_boolean_mono_info,
4168 .get = alc260_hp_master_sw_get,
4169 .put = alc260_hp_master_sw_put,
4170 .private_value = (0x10 << 16) | (0x15 << 8) | 0x11
4172 HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4173 HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
4174 HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
4175 HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
4176 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4177 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
4178 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
4179 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
4183 static struct hda_bind_ctls alc260_dc7600_bind_master_vol = {
4184 .ops = &snd_hda_bind_vol,
4186 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_OUTPUT),
4187 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_OUTPUT),
4188 HDA_COMPOSE_AMP_VAL(0x0a, 3, 0, HDA_OUTPUT),
4193 static struct hda_bind_ctls alc260_dc7600_bind_switch = {
4194 .ops = &snd_hda_bind_sw,
4196 HDA_COMPOSE_AMP_VAL(0x11, 3, 0, HDA_OUTPUT),
4197 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
4202 static struct snd_kcontrol_new alc260_hp_dc7600_mixer[] = {
4203 HDA_BIND_VOL("Master Playback Volume", &alc260_dc7600_bind_master_vol),
4204 HDA_BIND_SW("LineOut Playback Switch", &alc260_dc7600_bind_switch),
4205 HDA_CODEC_MUTE("Speaker Playback Switch", 0x0f, 0x0, HDA_OUTPUT),
4206 HDA_CODEC_MUTE("Headphone Playback Switch", 0x10, 0x0, HDA_OUTPUT),
4210 static struct hda_verb alc260_hp_3013_unsol_verbs[] = {
4211 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
4215 static void alc260_hp_3013_automute(struct hda_codec *codec)
4217 struct alc_spec *spec = codec->spec;
4218 unsigned int present;
4220 present = snd_hda_codec_read(codec, 0x15, 0,
4221 AC_VERB_GET_PIN_SENSE, 0);
4222 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
4223 alc260_hp_master_update(codec, 0x10, 0x15, 0x11);
4226 static void alc260_hp_3013_unsol_event(struct hda_codec *codec,
4229 if ((res >> 26) == ALC880_HP_EVENT)
4230 alc260_hp_3013_automute(codec);
4233 static void alc260_hp_3012_automute(struct hda_codec *codec)
4235 unsigned int present, bits;
4237 present = snd_hda_codec_read(codec, 0x10, 0,
4238 AC_VERB_GET_PIN_SENSE, 0) & AC_PINSENSE_PRESENCE;
4240 bits = present ? 0 : PIN_OUT;
4241 snd_hda_codec_write(codec, 0x0f, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4243 snd_hda_codec_write(codec, 0x11, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4245 snd_hda_codec_write(codec, 0x15, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4249 static void alc260_hp_3012_unsol_event(struct hda_codec *codec,
4252 if ((res >> 26) == ALC880_HP_EVENT)
4253 alc260_hp_3012_automute(codec);
4256 /* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12,
4257 * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10.
4259 static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
4260 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4261 HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
4262 ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
4263 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4264 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4265 HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
4266 HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
4267 ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
4268 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
4269 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
4270 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4271 HDA_BIND_MUTE("Speaker Playback Switch", 0x09, 2, HDA_INPUT),
4275 /* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current
4276 * versions of the ALC260 don't act on requests to enable mic bias from NID
4277 * 0x0f (used to drive the headphone jack in these laptops). The ALC260
4278 * datasheet doesn't mention this restriction. At this stage it's not clear
4279 * whether this behaviour is intentional or is a hardware bug in chip
4280 * revisions available in early 2006. Therefore for now allow the
4281 * "Headphone Jack Mode" control to span all choices, but if it turns out
4282 * that the lack of mic bias for this NID is intentional we could change the
4283 * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
4285 * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006
4286 * don't appear to make the mic bias available from the "line" jack, even
4287 * though the NID used for this jack (0x14) can supply it. The theory is
4288 * that perhaps Acer have included blocking capacitors between the ALC260
4289 * and the output jack. If this turns out to be the case for all such
4290 * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
4291 * to ALC_PIN_DIR_INOUT_NOMICBIAS.
4293 * The C20x Tablet series have a mono internal speaker which is controlled
4294 * via the chip's Mono sum widget and pin complex, so include the necessary
4295 * controls for such models. On models without a "mono speaker" the control
4296 * won't do anything.
4298 static struct snd_kcontrol_new alc260_acer_mixer[] = {
4299 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4300 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
4301 ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
4302 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
4304 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2,
4306 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4307 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4308 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4309 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4310 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
4311 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
4312 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
4313 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
4314 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
4315 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
4319 /* Packard bell V7900 ALC260 pin usage: HP = 0x0f, Mic jack = 0x12,
4320 * Line In jack = 0x14, CD audio = 0x16, pc beep = 0x17.
4322 static struct snd_kcontrol_new alc260_will_mixer[] = {
4323 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4324 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
4325 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4326 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4327 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
4328 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
4329 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
4330 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
4331 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4332 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4333 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
4334 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
4338 /* Replacer 672V ALC260 pin usage: Mic jack = 0x12,
4339 * Line In jack = 0x14, ATAPI Mic = 0x13, speaker = 0x0f.
4341 static struct snd_kcontrol_new alc260_replacer_672v_mixer[] = {
4342 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4343 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
4344 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4345 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4346 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
4347 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x07, 0x1, HDA_INPUT),
4348 HDA_CODEC_MUTE("ATATI Mic Playback Switch", 0x07, 0x1, HDA_INPUT),
4349 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
4350 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
4351 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
4355 /* capture mixer elements */
4356 static struct snd_kcontrol_new alc260_capture_mixer[] = {
4357 HDA_CODEC_VOLUME("Capture Volume", 0x04, 0x0, HDA_INPUT),
4358 HDA_CODEC_MUTE("Capture Switch", 0x04, 0x0, HDA_INPUT),
4359 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x05, 0x0, HDA_INPUT),
4360 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x05, 0x0, HDA_INPUT),
4362 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4363 /* The multiple "Capture Source" controls confuse alsamixer
4364 * So call somewhat different..
4366 /* .name = "Capture Source", */
4367 .name = "Input Source",
4369 .info = alc_mux_enum_info,
4370 .get = alc_mux_enum_get,
4371 .put = alc_mux_enum_put,
4376 static struct snd_kcontrol_new alc260_capture_alt_mixer[] = {
4377 HDA_CODEC_VOLUME("Capture Volume", 0x05, 0x0, HDA_INPUT),
4378 HDA_CODEC_MUTE("Capture Switch", 0x05, 0x0, HDA_INPUT),
4380 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4381 /* The multiple "Capture Source" controls confuse alsamixer
4382 * So call somewhat different..
4384 /* .name = "Capture Source", */
4385 .name = "Input Source",
4387 .info = alc_mux_enum_info,
4388 .get = alc_mux_enum_get,
4389 .put = alc_mux_enum_put,
4395 * initialization verbs
4397 static struct hda_verb alc260_init_verbs[] = {
4398 /* Line In pin widget for input */
4399 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
4400 /* CD pin widget for input */
4401 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
4402 /* Mic1 (rear panel) pin widget for input and vref at 80% */
4403 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
4404 /* Mic2 (front panel) pin widget for input and vref at 80% */
4405 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
4406 /* LINE-2 is used for line-out in rear */
4407 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4408 /* select line-out */
4409 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
4411 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4413 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4415 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4416 /* mute capture amp left and right */
4417 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4418 /* set connection select to line in (default select for this ADC) */
4419 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
4420 /* mute capture amp left and right */
4421 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4422 /* set connection select to line in (default select for this ADC) */
4423 {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
4424 /* set vol=0 Line-Out mixer amp left and right */
4425 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4426 /* unmute pin widget amp left and right (no gain on this amp) */
4427 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4428 /* set vol=0 HP mixer amp left and right */
4429 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4430 /* unmute pin widget amp left and right (no gain on this amp) */
4431 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4432 /* set vol=0 Mono mixer amp left and right */
4433 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4434 /* unmute pin widget amp left and right (no gain on this amp) */
4435 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4436 /* unmute LINE-2 out pin */
4437 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4438 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
4441 /* mute analog inputs */
4442 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4443 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4444 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4445 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4446 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
4447 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
4448 /* mute Front out path */
4449 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4450 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4451 /* mute Headphone out path */
4452 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4453 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4454 /* mute Mono out path */
4455 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4456 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4460 #if 0 /* should be identical with alc260_init_verbs? */
4461 static struct hda_verb alc260_hp_init_verbs[] = {
4462 /* Headphone and output */
4463 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
4465 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
4466 /* Mic1 (rear panel) pin widget for input and vref at 80% */
4467 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
4468 /* Mic2 (front panel) pin widget for input and vref at 80% */
4469 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
4470 /* Line In pin widget for input */
4471 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
4472 /* Line-2 pin widget for output */
4473 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
4474 /* CD pin widget for input */
4475 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
4476 /* unmute amp left and right */
4477 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
4478 /* set connection select to line in (default select for this ADC) */
4479 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
4480 /* unmute Line-Out mixer amp left and right (volume = 0) */
4481 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
4482 /* mute pin widget amp left and right (no gain on this amp) */
4483 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
4484 /* unmute HP mixer amp left and right (volume = 0) */
4485 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
4486 /* mute pin widget amp left and right (no gain on this amp) */
4487 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
4488 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
4491 /* mute analog inputs */
4492 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4493 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4494 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4495 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4496 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
4497 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
4498 /* Unmute Front out path */
4499 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4500 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4501 /* Unmute Headphone out path */
4502 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4503 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4504 /* Unmute Mono out path */
4505 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4506 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4511 static struct hda_verb alc260_hp_3013_init_verbs[] = {
4512 /* Line out and output */
4513 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
4515 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
4516 /* Mic1 (rear panel) pin widget for input and vref at 80% */
4517 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
4518 /* Mic2 (front panel) pin widget for input and vref at 80% */
4519 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
4520 /* Line In pin widget for input */
4521 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
4522 /* Headphone pin widget for output */
4523 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
4524 /* CD pin widget for input */
4525 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
4526 /* unmute amp left and right */
4527 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
4528 /* set connection select to line in (default select for this ADC) */
4529 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
4530 /* unmute Line-Out mixer amp left and right (volume = 0) */
4531 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
4532 /* mute pin widget amp left and right (no gain on this amp) */
4533 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
4534 /* unmute HP mixer amp left and right (volume = 0) */
4535 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
4536 /* mute pin widget amp left and right (no gain on this amp) */
4537 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
4538 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
4541 /* mute analog inputs */
4542 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4543 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4544 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4545 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4546 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
4547 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
4548 /* Unmute Front out path */
4549 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4550 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4551 /* Unmute Headphone out path */
4552 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4553 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4554 /* Unmute Mono out path */
4555 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4556 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4560 /* Initialisation sequence for ALC260 as configured in Fujitsu S702x
4561 * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD
4562 * audio = 0x16, internal speaker = 0x10.
4564 static struct hda_verb alc260_fujitsu_init_verbs[] = {
4565 /* Disable all GPIOs */
4566 {0x01, AC_VERB_SET_GPIO_MASK, 0},
4567 /* Internal speaker is connected to headphone pin */
4568 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4569 /* Headphone/Line-out jack connects to Line1 pin; make it an output */
4570 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4571 /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
4572 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
4573 /* Ensure all other unused pins are disabled and muted. */
4574 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
4575 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4576 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
4577 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4578 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
4579 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4580 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
4581 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4583 /* Disable digital (SPDIF) pins */
4584 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
4585 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
4587 /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
4588 * when acting as an output.
4590 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
4592 /* Start with output sum widgets muted and their output gains at min */
4593 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4594 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4595 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4596 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4597 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4598 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4599 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4600 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4601 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4603 /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
4604 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4605 /* Unmute Line1 pin widget output buffer since it starts as an output.
4606 * If the pin mode is changed by the user the pin mode control will
4607 * take care of enabling the pin's input/output buffers as needed.
4608 * Therefore there's no need to enable the input buffer at this
4611 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4612 /* Unmute input buffer of pin widget used for Line-in (no equiv
4615 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4617 /* Mute capture amp left and right */
4618 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4619 /* Set ADC connection select to match default mixer setting - line
4622 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
4624 /* Do the same for the second ADC: mute capture input amp and
4625 * set ADC connection to line in (on mic1 pin)
4627 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4628 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
4630 /* Mute all inputs to mixer widget (even unconnected ones) */
4631 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
4632 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
4633 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
4634 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
4635 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
4636 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
4637 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
4638 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
4643 /* Initialisation sequence for ALC260 as configured in Acer TravelMate and
4644 * similar laptops (adapted from Fujitsu init verbs).
4646 static struct hda_verb alc260_acer_init_verbs[] = {
4647 /* On TravelMate laptops, GPIO 0 enables the internal speaker and
4648 * the headphone jack. Turn this on and rely on the standard mute
4649 * methods whenever the user wants to turn these outputs off.
4651 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
4652 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
4653 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
4654 /* Internal speaker/Headphone jack is connected to Line-out pin */
4655 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4656 /* Internal microphone/Mic jack is connected to Mic1 pin */
4657 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
4658 /* Line In jack is connected to Line1 pin */
4659 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
4660 /* Some Acers (eg: C20x Tablets) use Mono pin for internal speaker */
4661 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4662 /* Ensure all other unused pins are disabled and muted. */
4663 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
4664 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4665 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
4666 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4667 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
4668 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4669 /* Disable digital (SPDIF) pins */
4670 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
4671 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
4673 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
4674 * bus when acting as outputs.
4676 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
4677 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
4679 /* Start with output sum widgets muted and their output gains at min */
4680 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4681 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4682 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4683 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4684 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4685 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4686 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4687 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4688 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4690 /* Unmute Line-out pin widget amp left and right
4691 * (no equiv mixer ctrl)
4693 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4694 /* Unmute mono pin widget amp output (no equiv mixer ctrl) */
4695 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4696 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
4697 * inputs. If the pin mode is changed by the user the pin mode control
4698 * will take care of enabling the pin's input/output buffers as needed.
4699 * Therefore there's no need to enable the input buffer at this
4702 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4703 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4705 /* Mute capture amp left and right */
4706 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4707 /* Set ADC connection select to match default mixer setting - mic
4710 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
4712 /* Do similar with the second ADC: mute capture input amp and
4713 * set ADC connection to mic to match ALSA's default state.
4715 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4716 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
4718 /* Mute all inputs to mixer widget (even unconnected ones) */
4719 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
4720 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
4721 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
4722 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
4723 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
4724 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
4725 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
4726 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
4731 static struct hda_verb alc260_will_verbs[] = {
4732 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4733 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x00},
4734 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
4735 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
4736 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
4737 {0x1a, AC_VERB_SET_PROC_COEF, 0x3040},
4741 static struct hda_verb alc260_replacer_672v_verbs[] = {
4742 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
4743 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
4744 {0x1a, AC_VERB_SET_PROC_COEF, 0x3050},
4746 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
4747 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
4748 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
4750 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
4754 /* toggle speaker-output according to the hp-jack state */
4755 static void alc260_replacer_672v_automute(struct hda_codec *codec)
4757 unsigned int present;
4759 /* speaker --> GPIO Data 0, hp or spdif --> GPIO data 1 */
4760 present = snd_hda_codec_read(codec, 0x0f, 0,
4761 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
4763 snd_hda_codec_write_cache(codec, 0x01, 0,
4764 AC_VERB_SET_GPIO_DATA, 1);
4765 snd_hda_codec_write_cache(codec, 0x0f, 0,
4766 AC_VERB_SET_PIN_WIDGET_CONTROL,
4769 snd_hda_codec_write_cache(codec, 0x01, 0,
4770 AC_VERB_SET_GPIO_DATA, 0);
4771 snd_hda_codec_write_cache(codec, 0x0f, 0,
4772 AC_VERB_SET_PIN_WIDGET_CONTROL,
4777 static void alc260_replacer_672v_unsol_event(struct hda_codec *codec,
4780 if ((res >> 26) == ALC880_HP_EVENT)
4781 alc260_replacer_672v_automute(codec);
4784 static struct hda_verb alc260_hp_dc7600_verbs[] = {
4785 {0x05, AC_VERB_SET_CONNECT_SEL, 0x01},
4786 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
4787 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4788 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4789 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4790 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4791 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
4792 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
4793 {0x11, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
4794 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
4798 /* Test configuration for debugging, modelled after the ALC880 test
4801 #ifdef CONFIG_SND_DEBUG
4802 static hda_nid_t alc260_test_dac_nids[1] = {
4805 static hda_nid_t alc260_test_adc_nids[2] = {
4808 /* For testing the ALC260, each input MUX needs its own definition since
4809 * the signal assignments are different. This assumes that the first ADC
4812 static struct hda_input_mux alc260_test_capture_sources[2] = {
4816 { "MIC1 pin", 0x0 },
4817 { "MIC2 pin", 0x1 },
4818 { "LINE1 pin", 0x2 },
4819 { "LINE2 pin", 0x3 },
4821 { "LINE-OUT pin", 0x5 },
4822 { "HP-OUT pin", 0x6 },
4828 { "MIC1 pin", 0x0 },
4829 { "MIC2 pin", 0x1 },
4830 { "LINE1 pin", 0x2 },
4831 { "LINE2 pin", 0x3 },
4834 { "LINE-OUT pin", 0x6 },
4835 { "HP-OUT pin", 0x7 },
4839 static struct snd_kcontrol_new alc260_test_mixer[] = {
4840 /* Output driver widgets */
4841 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
4842 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
4843 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4844 HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
4845 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4846 HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
4848 /* Modes for retasking pin widgets
4849 * Note: the ALC260 doesn't seem to act on requests to enable mic
4850 * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't
4851 * mention this restriction. At this stage it's not clear whether
4852 * this behaviour is intentional or is a hardware bug in chip
4853 * revisions available at least up until early 2006. Therefore for
4854 * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all
4855 * choices, but if it turns out that the lack of mic bias for these
4856 * NIDs is intentional we could change their modes from
4857 * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
4859 ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
4860 ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
4861 ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
4862 ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
4863 ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
4864 ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
4866 /* Loopback mixer controls */
4867 HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
4868 HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
4869 HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
4870 HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
4871 HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
4872 HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
4873 HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
4874 HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
4875 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4876 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4877 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
4878 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
4879 HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
4880 HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
4881 HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
4882 HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
4884 /* Controls for GPIO pins, assuming they are configured as outputs */
4885 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
4886 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
4887 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
4888 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
4890 /* Switches to allow the digital IO pins to be enabled. The datasheet
4891 * is ambigious as to which NID is which; testing on laptops which
4892 * make this output available should provide clarification.
4894 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
4895 ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
4897 /* A switch allowing EAPD to be enabled. Some laptops seem to use
4898 * this output to turn on an external amplifier.
4900 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
4901 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
4905 static struct hda_verb alc260_test_init_verbs[] = {
4906 /* Enable all GPIOs as outputs with an initial value of 0 */
4907 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
4908 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
4909 {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
4911 /* Enable retasking pins as output, initially without power amp */
4912 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4913 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4914 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4915 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4916 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4917 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4919 /* Disable digital (SPDIF) pins initially, but users can enable
4920 * them via a mixer switch. In the case of SPDIF-out, this initverb
4921 * payload also sets the generation to 0, output to be in "consumer"
4922 * PCM format, copyright asserted, no pre-emphasis and no validity
4925 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
4926 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
4928 /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
4929 * OUT1 sum bus when acting as an output.
4931 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
4932 {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
4933 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
4934 {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
4936 /* Start with output sum widgets muted and their output gains at min */
4937 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4938 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4939 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4940 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4941 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4942 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4943 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4944 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4945 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4947 /* Unmute retasking pin widget output buffers since the default
4948 * state appears to be output. As the pin mode is changed by the
4949 * user the pin mode control will take care of enabling the pin's
4950 * input/output buffers as needed.
4952 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4953 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4954 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4955 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4956 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4957 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4958 /* Also unmute the mono-out pin widget */
4959 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4961 /* Mute capture amp left and right */
4962 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4963 /* Set ADC connection select to match default mixer setting (mic1
4966 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
4968 /* Do the same for the second ADC: mute capture input amp and
4969 * set ADC connection to mic1 pin
4971 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4972 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
4974 /* Mute all inputs to mixer widget (even unconnected ones) */
4975 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
4976 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
4977 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
4978 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
4979 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
4980 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
4981 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
4982 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
4988 #define alc260_pcm_analog_playback alc880_pcm_analog_alt_playback
4989 #define alc260_pcm_analog_capture alc880_pcm_analog_capture
4991 #define alc260_pcm_digital_playback alc880_pcm_digital_playback
4992 #define alc260_pcm_digital_capture alc880_pcm_digital_capture
4995 * for BIOS auto-configuration
4998 static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
4999 const char *pfx, int *vol_bits)
5002 unsigned long vol_val, sw_val;
5006 if (nid >= 0x0f && nid < 0x11) {
5007 nid_vol = nid - 0x7;
5008 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
5009 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
5010 } else if (nid == 0x11) {
5011 nid_vol = nid - 0x7;
5012 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
5013 sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
5014 } else if (nid >= 0x12 && nid <= 0x15) {
5016 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
5017 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
5021 if (!(*vol_bits & (1 << nid_vol))) {
5022 /* first control for the volume widget */
5023 snprintf(name, sizeof(name), "%s Playback Volume", pfx);
5024 err = add_control(spec, ALC_CTL_WIDGET_VOL, name, vol_val);
5027 *vol_bits |= (1 << nid_vol);
5029 snprintf(name, sizeof(name), "%s Playback Switch", pfx);
5030 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, sw_val);
5036 /* add playback controls from the parsed DAC table */
5037 static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
5038 const struct auto_pin_cfg *cfg)
5044 spec->multiout.num_dacs = 1;
5045 spec->multiout.dac_nids = spec->private_dac_nids;
5046 spec->multiout.dac_nids[0] = 0x02;
5048 nid = cfg->line_out_pins[0];
5050 err = alc260_add_playback_controls(spec, nid, "Front", &vols);
5055 nid = cfg->speaker_pins[0];
5057 err = alc260_add_playback_controls(spec, nid, "Speaker", &vols);
5062 nid = cfg->hp_pins[0];
5064 err = alc260_add_playback_controls(spec, nid, "Headphone",
5072 /* create playback/capture controls for input pins */
5073 static int alc260_auto_create_analog_input_ctls(struct alc_spec *spec,
5074 const struct auto_pin_cfg *cfg)
5076 struct hda_input_mux *imux = &spec->private_imux;
5079 for (i = 0; i < AUTO_PIN_LAST; i++) {
5080 if (cfg->input_pins[i] >= 0x12) {
5081 idx = cfg->input_pins[i] - 0x12;
5082 err = new_analog_input(spec, cfg->input_pins[i],
5083 auto_pin_cfg_labels[i], idx,
5087 imux->items[imux->num_items].label =
5088 auto_pin_cfg_labels[i];
5089 imux->items[imux->num_items].index = idx;
5092 if (cfg->input_pins[i] >= 0x0f && cfg->input_pins[i] <= 0x10){
5093 idx = cfg->input_pins[i] - 0x09;
5094 err = new_analog_input(spec, cfg->input_pins[i],
5095 auto_pin_cfg_labels[i], idx,
5099 imux->items[imux->num_items].label =
5100 auto_pin_cfg_labels[i];
5101 imux->items[imux->num_items].index = idx;
5108 static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
5109 hda_nid_t nid, int pin_type,
5112 alc_set_pin_output(codec, nid, pin_type);
5113 /* need the manual connection? */
5115 int idx = nid - 0x12;
5116 snd_hda_codec_write(codec, idx + 0x0b, 0,
5117 AC_VERB_SET_CONNECT_SEL, sel_idx);
5121 static void alc260_auto_init_multi_out(struct hda_codec *codec)
5123 struct alc_spec *spec = codec->spec;
5126 alc_subsystem_id(codec, 0x10, 0x15, 0x0f);
5127 nid = spec->autocfg.line_out_pins[0];
5129 int pin_type = get_pin_type(spec->autocfg.line_out_type);
5130 alc260_auto_set_output_and_unmute(codec, nid, pin_type, 0);
5133 nid = spec->autocfg.speaker_pins[0];
5135 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
5137 nid = spec->autocfg.hp_pins[0];
5139 alc260_auto_set_output_and_unmute(codec, nid, PIN_HP, 0);
5142 #define ALC260_PIN_CD_NID 0x16
5143 static void alc260_auto_init_analog_input(struct hda_codec *codec)
5145 struct alc_spec *spec = codec->spec;
5148 for (i = 0; i < AUTO_PIN_LAST; i++) {
5149 hda_nid_t nid = spec->autocfg.input_pins[i];
5151 snd_hda_codec_write(codec, nid, 0,
5152 AC_VERB_SET_PIN_WIDGET_CONTROL,
5153 i <= AUTO_PIN_FRONT_MIC ?
5154 PIN_VREF80 : PIN_IN);
5155 if (nid != ALC260_PIN_CD_NID)
5156 snd_hda_codec_write(codec, nid, 0,
5157 AC_VERB_SET_AMP_GAIN_MUTE,
5164 * generic initialization of ADC, input mixers and output mixers
5166 static struct hda_verb alc260_volume_init_verbs[] = {
5168 * Unmute ADC0-1 and set the default input to mic-in
5170 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5171 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5172 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
5173 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5175 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
5177 * Note: PASD motherboards uses the Line In 2 as the input for
5178 * front panel mic (mic 2)
5180 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
5181 /* mute analog inputs */
5182 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5183 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5184 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5185 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5186 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5189 * Set up output mixers (0x08 - 0x0a)
5191 /* set vol=0 to output mixers */
5192 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5193 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5194 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5195 /* set up input amps for analog loopback */
5196 /* Amp Indices: DAC = 0, mixer = 1 */
5197 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5198 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5199 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5200 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5201 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5202 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5207 static int alc260_parse_auto_config(struct hda_codec *codec)
5209 struct alc_spec *spec = codec->spec;
5212 static hda_nid_t alc260_ignore[] = { 0x17, 0 };
5214 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
5218 err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg);
5221 if (!spec->kctl_alloc)
5222 return 0; /* can't find valid BIOS pin config */
5223 err = alc260_auto_create_analog_input_ctls(spec, &spec->autocfg);
5227 spec->multiout.max_channels = 2;
5229 if (spec->autocfg.dig_out_pin)
5230 spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
5231 if (spec->kctl_alloc)
5232 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
5234 spec->init_verbs[spec->num_init_verbs++] = alc260_volume_init_verbs;
5236 spec->num_mux_defs = 1;
5237 spec->input_mux = &spec->private_imux;
5239 /* check whether NID 0x04 is valid */
5240 wcap = get_wcaps(codec, 0x04);
5241 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
5242 if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
5243 spec->adc_nids = alc260_adc_nids_alt;
5244 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
5245 spec->mixers[spec->num_mixers] = alc260_capture_alt_mixer;
5247 spec->adc_nids = alc260_adc_nids;
5248 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
5249 spec->mixers[spec->num_mixers] = alc260_capture_mixer;
5256 /* additional initialization for auto-configuration model */
5257 static void alc260_auto_init(struct hda_codec *codec)
5259 struct alc_spec *spec = codec->spec;
5260 alc260_auto_init_multi_out(codec);
5261 alc260_auto_init_analog_input(codec);
5262 if (spec->unsol_event)
5263 alc_inithook(codec);
5266 #ifdef CONFIG_SND_HDA_POWER_SAVE
5267 static struct hda_amp_list alc260_loopbacks[] = {
5268 { 0x07, HDA_INPUT, 0 },
5269 { 0x07, HDA_INPUT, 1 },
5270 { 0x07, HDA_INPUT, 2 },
5271 { 0x07, HDA_INPUT, 3 },
5272 { 0x07, HDA_INPUT, 4 },
5278 * ALC260 configurations
5280 static const char *alc260_models[ALC260_MODEL_LAST] = {
5281 [ALC260_BASIC] = "basic",
5283 [ALC260_HP_3013] = "hp-3013",
5284 [ALC260_HP_DC7600] = "hp-dc7600",
5285 [ALC260_FUJITSU_S702X] = "fujitsu",
5286 [ALC260_ACER] = "acer",
5287 [ALC260_WILL] = "will",
5288 [ALC260_REPLACER_672V] = "replacer",
5289 #ifdef CONFIG_SND_DEBUG
5290 [ALC260_TEST] = "test",
5292 [ALC260_AUTO] = "auto",
5295 static struct snd_pci_quirk alc260_cfg_tbl[] = {
5296 SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER),
5297 SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER),
5298 SND_PCI_QUIRK(0x103c, 0x2808, "HP d5700", ALC260_HP_3013),
5299 SND_PCI_QUIRK(0x103c, 0x280a, "HP d5750", ALC260_HP_3013),
5300 SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013),
5301 SND_PCI_QUIRK(0x103c, 0x3011, "HP", ALC260_HP_3013),
5302 SND_PCI_QUIRK(0x103c, 0x3012, "HP", ALC260_HP_DC7600),
5303 SND_PCI_QUIRK(0x103c, 0x3013, "HP", ALC260_HP_3013),
5304 SND_PCI_QUIRK(0x103c, 0x3014, "HP", ALC260_HP),
5305 SND_PCI_QUIRK(0x103c, 0x3015, "HP", ALC260_HP),
5306 SND_PCI_QUIRK(0x103c, 0x3016, "HP", ALC260_HP),
5307 SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_BASIC),
5308 SND_PCI_QUIRK(0x104d, 0x81cc, "Sony VAIO", ALC260_BASIC),
5309 SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC),
5310 SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X),
5311 SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC),
5312 SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_REPLACER_672V),
5313 SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_WILL),
5317 static struct alc_config_preset alc260_presets[] = {
5319 .mixers = { alc260_base_output_mixer,
5321 alc260_pc_beep_mixer,
5322 alc260_capture_mixer },
5323 .init_verbs = { alc260_init_verbs },
5324 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5325 .dac_nids = alc260_dac_nids,
5326 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
5327 .adc_nids = alc260_adc_nids,
5328 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5329 .channel_mode = alc260_modes,
5330 .input_mux = &alc260_capture_source,
5333 .mixers = { alc260_hp_output_mixer,
5335 alc260_capture_alt_mixer },
5336 .init_verbs = { alc260_init_verbs,
5337 alc260_hp_unsol_verbs },
5338 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5339 .dac_nids = alc260_dac_nids,
5340 .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
5341 .adc_nids = alc260_hp_adc_nids,
5342 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5343 .channel_mode = alc260_modes,
5344 .input_mux = &alc260_capture_source,
5345 .unsol_event = alc260_hp_unsol_event,
5346 .init_hook = alc260_hp_automute,
5348 [ALC260_HP_DC7600] = {
5349 .mixers = { alc260_hp_dc7600_mixer,
5351 alc260_capture_alt_mixer },
5352 .init_verbs = { alc260_init_verbs,
5353 alc260_hp_dc7600_verbs },
5354 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5355 .dac_nids = alc260_dac_nids,
5356 .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
5357 .adc_nids = alc260_hp_adc_nids,
5358 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5359 .channel_mode = alc260_modes,
5360 .input_mux = &alc260_capture_source,
5361 .unsol_event = alc260_hp_3012_unsol_event,
5362 .init_hook = alc260_hp_3012_automute,
5364 [ALC260_HP_3013] = {
5365 .mixers = { alc260_hp_3013_mixer,
5367 alc260_capture_alt_mixer },
5368 .init_verbs = { alc260_hp_3013_init_verbs,
5369 alc260_hp_3013_unsol_verbs },
5370 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5371 .dac_nids = alc260_dac_nids,
5372 .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
5373 .adc_nids = alc260_hp_adc_nids,
5374 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5375 .channel_mode = alc260_modes,
5376 .input_mux = &alc260_capture_source,
5377 .unsol_event = alc260_hp_3013_unsol_event,
5378 .init_hook = alc260_hp_3013_automute,
5380 [ALC260_FUJITSU_S702X] = {
5381 .mixers = { alc260_fujitsu_mixer,
5382 alc260_capture_mixer },
5383 .init_verbs = { alc260_fujitsu_init_verbs },
5384 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5385 .dac_nids = alc260_dac_nids,
5386 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
5387 .adc_nids = alc260_dual_adc_nids,
5388 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5389 .channel_mode = alc260_modes,
5390 .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources),
5391 .input_mux = alc260_fujitsu_capture_sources,
5394 .mixers = { alc260_acer_mixer,
5395 alc260_capture_mixer },
5396 .init_verbs = { alc260_acer_init_verbs },
5397 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5398 .dac_nids = alc260_dac_nids,
5399 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
5400 .adc_nids = alc260_dual_adc_nids,
5401 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5402 .channel_mode = alc260_modes,
5403 .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
5404 .input_mux = alc260_acer_capture_sources,
5407 .mixers = { alc260_will_mixer,
5408 alc260_capture_mixer },
5409 .init_verbs = { alc260_init_verbs, alc260_will_verbs },
5410 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5411 .dac_nids = alc260_dac_nids,
5412 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
5413 .adc_nids = alc260_adc_nids,
5414 .dig_out_nid = ALC260_DIGOUT_NID,
5415 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5416 .channel_mode = alc260_modes,
5417 .input_mux = &alc260_capture_source,
5419 [ALC260_REPLACER_672V] = {
5420 .mixers = { alc260_replacer_672v_mixer,
5421 alc260_capture_mixer },
5422 .init_verbs = { alc260_init_verbs, alc260_replacer_672v_verbs },
5423 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5424 .dac_nids = alc260_dac_nids,
5425 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
5426 .adc_nids = alc260_adc_nids,
5427 .dig_out_nid = ALC260_DIGOUT_NID,
5428 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5429 .channel_mode = alc260_modes,
5430 .input_mux = &alc260_capture_source,
5431 .unsol_event = alc260_replacer_672v_unsol_event,
5432 .init_hook = alc260_replacer_672v_automute,
5434 #ifdef CONFIG_SND_DEBUG
5436 .mixers = { alc260_test_mixer,
5437 alc260_capture_mixer },
5438 .init_verbs = { alc260_test_init_verbs },
5439 .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
5440 .dac_nids = alc260_test_dac_nids,
5441 .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
5442 .adc_nids = alc260_test_adc_nids,
5443 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5444 .channel_mode = alc260_modes,
5445 .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources),
5446 .input_mux = alc260_test_capture_sources,
5451 static int patch_alc260(struct hda_codec *codec)
5453 struct alc_spec *spec;
5454 int err, board_config;
5456 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5462 board_config = snd_hda_check_board_config(codec, ALC260_MODEL_LAST,
5465 if (board_config < 0) {
5466 snd_printd(KERN_INFO "hda_codec: Unknown model for ALC260, "
5467 "trying auto-probe from BIOS...\n");
5468 board_config = ALC260_AUTO;
5471 if (board_config == ALC260_AUTO) {
5472 /* automatic parse from the BIOS config */
5473 err = alc260_parse_auto_config(codec);
5479 "hda_codec: Cannot set up configuration "
5480 "from BIOS. Using base mode...\n");
5481 board_config = ALC260_BASIC;
5485 if (board_config != ALC260_AUTO)
5486 setup_preset(spec, &alc260_presets[board_config]);
5488 spec->stream_name_analog = "ALC260 Analog";
5489 spec->stream_analog_playback = &alc260_pcm_analog_playback;
5490 spec->stream_analog_capture = &alc260_pcm_analog_capture;
5492 spec->stream_name_digital = "ALC260 Digital";
5493 spec->stream_digital_playback = &alc260_pcm_digital_playback;
5494 spec->stream_digital_capture = &alc260_pcm_digital_capture;
5496 spec->vmaster_nid = 0x08;
5498 codec->patch_ops = alc_patch_ops;
5499 if (board_config == ALC260_AUTO)
5500 spec->init_hook = alc260_auto_init;
5501 #ifdef CONFIG_SND_HDA_POWER_SAVE
5502 if (!spec->loopback.amplist)
5503 spec->loopback.amplist = alc260_loopbacks;
5513 * ALC882 is almost identical with ALC880 but has cleaner and more flexible
5514 * configuration. Each pin widget can choose any input DACs and a mixer.
5515 * Each ADC is connected from a mixer of all inputs. This makes possible
5516 * 6-channel independent captures.
5518 * In addition, an independent DAC for the multi-playback (not used in this
5521 #define ALC882_DIGOUT_NID 0x06
5522 #define ALC882_DIGIN_NID 0x0a
5524 static struct hda_channel_mode alc882_ch_modes[1] = {
5528 static hda_nid_t alc882_dac_nids[4] = {
5529 /* front, rear, clfe, rear_surr */
5530 0x02, 0x03, 0x04, 0x05
5533 /* identical with ALC880 */
5534 #define alc882_adc_nids alc880_adc_nids
5535 #define alc882_adc_nids_alt alc880_adc_nids_alt
5537 static hda_nid_t alc882_capsrc_nids[3] = { 0x24, 0x23, 0x22 };
5538 static hda_nid_t alc882_capsrc_nids_alt[2] = { 0x23, 0x22 };
5541 /* FIXME: should be a matrix-type input source selection */
5543 static struct hda_input_mux alc882_capture_source = {
5547 { "Front Mic", 0x1 },
5552 #define alc882_mux_enum_info alc_mux_enum_info
5553 #define alc882_mux_enum_get alc_mux_enum_get
5555 static int alc882_mux_enum_put(struct snd_kcontrol *kcontrol,
5556 struct snd_ctl_elem_value *ucontrol)
5558 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
5559 struct alc_spec *spec = codec->spec;
5560 const struct hda_input_mux *imux = spec->input_mux;
5561 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
5562 hda_nid_t nid = spec->capsrc_nids ?
5563 spec->capsrc_nids[adc_idx] : spec->adc_nids[adc_idx];
5564 unsigned int *cur_val = &spec->cur_mux[adc_idx];
5565 unsigned int i, idx;
5567 idx = ucontrol->value.enumerated.item[0];
5568 if (idx >= imux->num_items)
5569 idx = imux->num_items - 1;
5570 if (*cur_val == idx)
5572 for (i = 0; i < imux->num_items; i++) {
5573 unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
5574 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
5575 imux->items[i].index,
5585 static struct hda_verb alc882_3ST_ch2_init[] = {
5586 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
5587 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
5588 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
5589 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
5596 static struct hda_verb alc882_3ST_ch6_init[] = {
5597 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5598 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
5599 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
5600 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5601 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
5602 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
5606 static struct hda_channel_mode alc882_3ST_6ch_modes[2] = {
5607 { 2, alc882_3ST_ch2_init },
5608 { 6, alc882_3ST_ch6_init },
5614 static struct hda_verb alc882_sixstack_ch6_init[] = {
5615 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
5616 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5617 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5618 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5625 static struct hda_verb alc882_sixstack_ch8_init[] = {
5626 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5627 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5628 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5629 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5633 static struct hda_channel_mode alc882_sixstack_modes[2] = {
5634 { 6, alc882_sixstack_ch6_init },
5635 { 8, alc882_sixstack_ch8_init },
5639 * macbook pro ALC885 can switch LineIn to LineOut without loosing Mic
5645 static struct hda_verb alc885_mbp_ch2_init[] = {
5646 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
5647 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5648 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5655 static struct hda_verb alc885_mbp_ch6_init[] = {
5656 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5657 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5658 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
5659 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5660 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5664 static struct hda_channel_mode alc885_mbp_6ch_modes[2] = {
5665 { 2, alc885_mbp_ch2_init },
5666 { 6, alc885_mbp_ch6_init },
5670 /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
5671 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
5673 static struct snd_kcontrol_new alc882_base_mixer[] = {
5674 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5675 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5676 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
5677 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
5678 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
5679 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
5680 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
5681 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
5682 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
5683 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
5684 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5685 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5686 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5687 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5688 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5689 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5690 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
5691 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5692 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
5693 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
5694 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
5695 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
5696 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
5700 static struct snd_kcontrol_new alc885_mbp3_mixer[] = {
5701 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
5702 HDA_BIND_MUTE ("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
5703 HDA_CODEC_MUTE ("Speaker Playback Switch", 0x14, 0x00, HDA_OUTPUT),
5704 HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
5705 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5706 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5707 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
5708 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
5709 HDA_CODEC_VOLUME("Line Boost", 0x1a, 0x00, HDA_INPUT),
5710 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
5713 static struct snd_kcontrol_new alc882_w2jc_mixer[] = {
5714 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5715 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5716 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5717 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5718 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5719 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5720 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5721 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
5722 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5723 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
5724 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
5728 static struct snd_kcontrol_new alc882_targa_mixer[] = {
5729 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5730 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5731 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5732 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5733 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5734 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5735 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5736 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5737 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5738 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
5739 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
5740 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
5741 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
5745 /* Pin assignment: Front=0x14, HP = 0x15, Front = 0x16, ???
5746 * Front Mic=0x18, Line In = 0x1a, Line In = 0x1b, CD = 0x1c
5748 static struct snd_kcontrol_new alc882_asus_a7j_mixer[] = {
5749 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5750 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
5751 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
5752 HDA_CODEC_MUTE("Mobile Front Playback Switch", 0x16, 0x0, HDA_OUTPUT),
5753 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5754 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5755 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5756 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5757 HDA_CODEC_VOLUME("Mobile Line Playback Volume", 0x0b, 0x03, HDA_INPUT),
5758 HDA_CODEC_MUTE("Mobile Line Playback Switch", 0x0b, 0x03, HDA_INPUT),
5759 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5760 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5761 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
5765 static struct snd_kcontrol_new alc882_asus_a7m_mixer[] = {
5766 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5767 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5768 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
5769 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5770 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5771 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5772 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5773 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5774 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
5775 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5776 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
5777 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
5781 static struct snd_kcontrol_new alc882_chmode_mixer[] = {
5783 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5784 .name = "Channel Mode",
5785 .info = alc_ch_mode_info,
5786 .get = alc_ch_mode_get,
5787 .put = alc_ch_mode_put,
5792 static struct hda_verb alc882_init_verbs[] = {
5793 /* Front mixer: unmute input/output amp left and right (volume = 0) */
5794 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5795 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5796 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5798 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5799 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5800 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5802 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5803 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5804 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5806 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5807 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5808 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5810 /* Front Pin: output 0 (0x0c) */
5811 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5812 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5813 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
5814 /* Rear Pin: output 1 (0x0d) */
5815 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5816 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5817 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
5818 /* CLFE Pin: output 2 (0x0e) */
5819 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5820 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5821 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
5822 /* Side Pin: output 3 (0x0f) */
5823 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5824 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5825 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
5826 /* Mic (rear) pin: input vref at 80% */
5827 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5828 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5829 /* Front Mic pin: input vref at 80% */
5830 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5831 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5832 /* Line In pin: input */
5833 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
5834 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5835 /* Line-2 In: Headphone output (output 0 - 0x0c) */
5836 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5837 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5838 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
5839 /* CD pin widget for input */
5840 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
5842 /* FIXME: use matrix-type input source selection */
5843 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5844 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
5845 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5846 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5847 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5848 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5850 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5851 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5852 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5853 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5855 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5856 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5857 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5858 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5859 /* ADC1: mute amp left and right */
5860 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5861 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
5862 /* ADC2: mute amp left and right */
5863 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5864 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
5865 /* ADC3: mute amp left and right */
5866 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5867 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
5872 static struct hda_verb alc882_eapd_verbs[] = {
5873 /* change to EAPD mode */
5874 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
5875 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
5880 static struct snd_kcontrol_new alc882_macpro_mixer[] = {
5881 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5882 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5883 HDA_CODEC_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT),
5884 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
5885 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
5886 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x02, HDA_INPUT),
5887 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x02, HDA_INPUT),
5891 static struct hda_verb alc882_macpro_init_verbs[] = {
5892 /* Front mixer: unmute input/output amp left and right (volume = 0) */
5893 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5894 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5895 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5896 /* Front Pin: output 0 (0x0c) */
5897 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5898 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5899 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
5900 /* Front Mic pin: input vref at 80% */
5901 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5902 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5903 /* Speaker: output */
5904 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5905 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},