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 */
80 #ifdef CONFIG_SND_DEBUG
84 ALC260_MODEL_LAST /* last tag */
94 ALC262_HP_BPC_D7000_WL,
95 ALC262_HP_BPC_D7000_WF,
104 ALC262_MODEL_LAST /* last tag */
115 #ifdef CONFIG_SND_DEBUG
119 ALC268_MODEL_LAST /* last tag */
125 ALC269_ASUS_EEEPC_P703,
126 ALC269_ASUS_EEEPC_P901,
128 ALC269_MODEL_LAST /* last tag */
145 /* ALC861-VD models */
166 ALC662_ASUS_EEEPC_P701,
167 ALC662_ASUS_EEEPC_EP20,
199 ALC883_TARGA_2ch_DIG,
205 ALC883_LENOVO_101E_2ch,
206 ALC883_LENOVO_NB0763,
207 ALC888_LENOVO_MS7195_DIG,
213 ALC883_FUJITSU_PI2515,
214 ALC883_3ST_6ch_INTEL,
220 #define GPIO_MASK 0x03
223 /* codec parameterization */
224 struct snd_kcontrol_new *mixers[5]; /* mixer arrays */
225 unsigned int num_mixers;
227 const struct hda_verb *init_verbs[5]; /* initialization verbs
231 unsigned int num_init_verbs;
233 char *stream_name_analog; /* analog PCM stream */
234 struct hda_pcm_stream *stream_analog_playback;
235 struct hda_pcm_stream *stream_analog_capture;
236 struct hda_pcm_stream *stream_analog_alt_playback;
237 struct hda_pcm_stream *stream_analog_alt_capture;
239 char *stream_name_digital; /* digital PCM stream */
240 struct hda_pcm_stream *stream_digital_playback;
241 struct hda_pcm_stream *stream_digital_capture;
244 struct hda_multi_out multiout; /* playback set-up
245 * max_channels, dacs must be set
246 * dig_out_nid and hp_nid are optional
248 hda_nid_t alt_dac_nid;
251 unsigned int num_adc_nids;
253 hda_nid_t *capsrc_nids;
254 hda_nid_t dig_in_nid; /* digital-in NID; optional */
257 unsigned int num_mux_defs;
258 const struct hda_input_mux *input_mux;
259 unsigned int cur_mux[3];
262 const struct hda_channel_mode *channel_mode;
263 int num_channel_mode;
266 /* PCM information */
267 struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */
269 /* dynamic controls, init_verbs and input_mux */
270 struct auto_pin_cfg autocfg;
271 unsigned int num_kctl_alloc, num_kctl_used;
272 struct snd_kcontrol_new *kctl_alloc;
273 struct hda_input_mux private_imux;
274 hda_nid_t private_dac_nids[AUTO_CFG_MAX_OUTS];
277 void (*init_hook)(struct hda_codec *codec);
278 void (*unsol_event)(struct hda_codec *codec, unsigned int res);
280 /* for pin sensing */
281 unsigned int sense_updated: 1;
282 unsigned int jack_present: 1;
283 unsigned int master_sw: 1;
285 /* for virtual master */
286 hda_nid_t vmaster_nid;
287 #ifdef CONFIG_SND_HDA_POWER_SAVE
288 struct hda_loopback_check loopback;
293 unsigned int pll_coef_idx, pll_coef_bit;
297 * configuration template - to be copied to the spec instance
299 struct alc_config_preset {
300 struct snd_kcontrol_new *mixers[5]; /* should be identical size
303 const struct hda_verb *init_verbs[5];
304 unsigned int num_dacs;
306 hda_nid_t dig_out_nid; /* optional */
307 hda_nid_t hp_nid; /* optional */
308 unsigned int num_adc_nids;
310 hda_nid_t *capsrc_nids;
311 hda_nid_t dig_in_nid;
312 unsigned int num_channel_mode;
313 const struct hda_channel_mode *channel_mode;
315 unsigned int num_mux_defs;
316 const struct hda_input_mux *input_mux;
317 void (*unsol_event)(struct hda_codec *, unsigned int);
318 void (*init_hook)(struct hda_codec *);
319 #ifdef CONFIG_SND_HDA_POWER_SAVE
320 struct hda_amp_list *loopbacks;
328 static int alc_mux_enum_info(struct snd_kcontrol *kcontrol,
329 struct snd_ctl_elem_info *uinfo)
331 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
332 struct alc_spec *spec = codec->spec;
333 unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id);
334 if (mux_idx >= spec->num_mux_defs)
336 return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo);
339 static int alc_mux_enum_get(struct snd_kcontrol *kcontrol,
340 struct snd_ctl_elem_value *ucontrol)
342 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
343 struct alc_spec *spec = codec->spec;
344 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
346 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
350 static int alc_mux_enum_put(struct snd_kcontrol *kcontrol,
351 struct snd_ctl_elem_value *ucontrol)
353 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
354 struct alc_spec *spec = codec->spec;
355 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
356 unsigned int mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx;
357 hda_nid_t nid = spec->capsrc_nids ?
358 spec->capsrc_nids[adc_idx] : spec->adc_nids[adc_idx];
359 return snd_hda_input_mux_put(codec, &spec->input_mux[mux_idx], ucontrol,
360 nid, &spec->cur_mux[adc_idx]);
365 * channel mode setting
367 static int alc_ch_mode_info(struct snd_kcontrol *kcontrol,
368 struct snd_ctl_elem_info *uinfo)
370 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
371 struct alc_spec *spec = codec->spec;
372 return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
373 spec->num_channel_mode);
376 static int alc_ch_mode_get(struct snd_kcontrol *kcontrol,
377 struct snd_ctl_elem_value *ucontrol)
379 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
380 struct alc_spec *spec = codec->spec;
381 return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
382 spec->num_channel_mode,
383 spec->multiout.max_channels);
386 static int alc_ch_mode_put(struct snd_kcontrol *kcontrol,
387 struct snd_ctl_elem_value *ucontrol)
389 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
390 struct alc_spec *spec = codec->spec;
391 int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
392 spec->num_channel_mode,
393 &spec->multiout.max_channels);
394 if (err >= 0 && spec->need_dac_fix)
395 spec->multiout.num_dacs = spec->multiout.max_channels / 2;
400 * Control the mode of pin widget settings via the mixer. "pc" is used
401 * instead of "%" to avoid consequences of accidently treating the % as
402 * being part of a format specifier. Maximum allowed length of a value is
403 * 63 characters plus NULL terminator.
405 * Note: some retasking pin complexes seem to ignore requests for input
406 * states other than HiZ (eg: PIN_VREFxx) and revert to HiZ if any of these
407 * are requested. Therefore order this list so that this behaviour will not
408 * cause problems when mixer clients move through the enum sequentially.
409 * NIDs 0x0f and 0x10 have been observed to have this behaviour as of
412 static char *alc_pin_mode_names[] = {
413 "Mic 50pc bias", "Mic 80pc bias",
414 "Line in", "Line out", "Headphone out",
416 static unsigned char alc_pin_mode_values[] = {
417 PIN_VREF50, PIN_VREF80, PIN_IN, PIN_OUT, PIN_HP,
419 /* The control can present all 5 options, or it can limit the options based
420 * in the pin being assumed to be exclusively an input or an output pin. In
421 * addition, "input" pins may or may not process the mic bias option
422 * depending on actual widget capability (NIDs 0x0f and 0x10 don't seem to
423 * accept requests for bias as of chip versions up to March 2006) and/or
424 * wiring in the computer.
426 #define ALC_PIN_DIR_IN 0x00
427 #define ALC_PIN_DIR_OUT 0x01
428 #define ALC_PIN_DIR_INOUT 0x02
429 #define ALC_PIN_DIR_IN_NOMICBIAS 0x03
430 #define ALC_PIN_DIR_INOUT_NOMICBIAS 0x04
432 /* Info about the pin modes supported by the different pin direction modes.
433 * For each direction the minimum and maximum values are given.
435 static signed char alc_pin_mode_dir_info[5][2] = {
436 { 0, 2 }, /* ALC_PIN_DIR_IN */
437 { 3, 4 }, /* ALC_PIN_DIR_OUT */
438 { 0, 4 }, /* ALC_PIN_DIR_INOUT */
439 { 2, 2 }, /* ALC_PIN_DIR_IN_NOMICBIAS */
440 { 2, 4 }, /* ALC_PIN_DIR_INOUT_NOMICBIAS */
442 #define alc_pin_mode_min(_dir) (alc_pin_mode_dir_info[_dir][0])
443 #define alc_pin_mode_max(_dir) (alc_pin_mode_dir_info[_dir][1])
444 #define alc_pin_mode_n_items(_dir) \
445 (alc_pin_mode_max(_dir)-alc_pin_mode_min(_dir)+1)
447 static int alc_pin_mode_info(struct snd_kcontrol *kcontrol,
448 struct snd_ctl_elem_info *uinfo)
450 unsigned int item_num = uinfo->value.enumerated.item;
451 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
453 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
455 uinfo->value.enumerated.items = alc_pin_mode_n_items(dir);
457 if (item_num<alc_pin_mode_min(dir) || item_num>alc_pin_mode_max(dir))
458 item_num = alc_pin_mode_min(dir);
459 strcpy(uinfo->value.enumerated.name, alc_pin_mode_names[item_num]);
463 static int alc_pin_mode_get(struct snd_kcontrol *kcontrol,
464 struct snd_ctl_elem_value *ucontrol)
467 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
468 hda_nid_t nid = kcontrol->private_value & 0xffff;
469 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
470 long *valp = ucontrol->value.integer.value;
471 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
472 AC_VERB_GET_PIN_WIDGET_CONTROL,
475 /* Find enumerated value for current pinctl setting */
476 i = alc_pin_mode_min(dir);
477 while (alc_pin_mode_values[i] != pinctl && i <= alc_pin_mode_max(dir))
479 *valp = i <= alc_pin_mode_max(dir) ? i: alc_pin_mode_min(dir);
483 static int alc_pin_mode_put(struct snd_kcontrol *kcontrol,
484 struct snd_ctl_elem_value *ucontrol)
487 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
488 hda_nid_t nid = kcontrol->private_value & 0xffff;
489 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
490 long val = *ucontrol->value.integer.value;
491 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
492 AC_VERB_GET_PIN_WIDGET_CONTROL,
495 if (val < alc_pin_mode_min(dir) || val > alc_pin_mode_max(dir))
496 val = alc_pin_mode_min(dir);
498 change = pinctl != alc_pin_mode_values[val];
500 /* Set pin mode to that requested */
501 snd_hda_codec_write_cache(codec, nid, 0,
502 AC_VERB_SET_PIN_WIDGET_CONTROL,
503 alc_pin_mode_values[val]);
505 /* Also enable the retasking pin's input/output as required
506 * for the requested pin mode. Enum values of 2 or less are
509 * Dynamically switching the input/output buffers probably
510 * reduces noise slightly (particularly on input) so we'll
511 * do it. However, having both input and output buffers
512 * enabled simultaneously doesn't seem to be problematic if
513 * this turns out to be necessary in the future.
516 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
517 HDA_AMP_MUTE, HDA_AMP_MUTE);
518 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
521 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
522 HDA_AMP_MUTE, HDA_AMP_MUTE);
523 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
530 #define ALC_PIN_MODE(xname, nid, dir) \
531 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
532 .info = alc_pin_mode_info, \
533 .get = alc_pin_mode_get, \
534 .put = alc_pin_mode_put, \
535 .private_value = nid | (dir<<16) }
537 /* A switch control for ALC260 GPIO pins. Multiple GPIOs can be ganged
538 * together using a mask with more than one bit set. This control is
539 * currently used only by the ALC260 test model. At this stage they are not
540 * needed for any "production" models.
542 #ifdef CONFIG_SND_DEBUG
543 #define alc_gpio_data_info snd_ctl_boolean_mono_info
545 static int alc_gpio_data_get(struct snd_kcontrol *kcontrol,
546 struct snd_ctl_elem_value *ucontrol)
548 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
549 hda_nid_t nid = kcontrol->private_value & 0xffff;
550 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
551 long *valp = ucontrol->value.integer.value;
552 unsigned int val = snd_hda_codec_read(codec, nid, 0,
553 AC_VERB_GET_GPIO_DATA, 0x00);
555 *valp = (val & mask) != 0;
558 static int alc_gpio_data_put(struct snd_kcontrol *kcontrol,
559 struct snd_ctl_elem_value *ucontrol)
562 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
563 hda_nid_t nid = kcontrol->private_value & 0xffff;
564 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
565 long val = *ucontrol->value.integer.value;
566 unsigned int gpio_data = snd_hda_codec_read(codec, nid, 0,
567 AC_VERB_GET_GPIO_DATA,
570 /* Set/unset the masked GPIO bit(s) as needed */
571 change = (val == 0 ? 0 : mask) != (gpio_data & mask);
576 snd_hda_codec_write_cache(codec, nid, 0,
577 AC_VERB_SET_GPIO_DATA, gpio_data);
581 #define ALC_GPIO_DATA_SWITCH(xname, nid, mask) \
582 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
583 .info = alc_gpio_data_info, \
584 .get = alc_gpio_data_get, \
585 .put = alc_gpio_data_put, \
586 .private_value = nid | (mask<<16) }
587 #endif /* CONFIG_SND_DEBUG */
589 /* A switch control to allow the enabling of the digital IO pins on the
590 * ALC260. This is incredibly simplistic; the intention of this control is
591 * to provide something in the test model allowing digital outputs to be
592 * identified if present. If models are found which can utilise these
593 * outputs a more complete mixer control can be devised for those models if
596 #ifdef CONFIG_SND_DEBUG
597 #define alc_spdif_ctrl_info snd_ctl_boolean_mono_info
599 static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol,
600 struct snd_ctl_elem_value *ucontrol)
602 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
603 hda_nid_t nid = kcontrol->private_value & 0xffff;
604 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
605 long *valp = ucontrol->value.integer.value;
606 unsigned int val = snd_hda_codec_read(codec, nid, 0,
607 AC_VERB_GET_DIGI_CONVERT_1, 0x00);
609 *valp = (val & mask) != 0;
612 static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol,
613 struct snd_ctl_elem_value *ucontrol)
616 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
617 hda_nid_t nid = kcontrol->private_value & 0xffff;
618 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
619 long val = *ucontrol->value.integer.value;
620 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
621 AC_VERB_GET_DIGI_CONVERT_1,
624 /* Set/unset the masked control bit(s) as needed */
625 change = (val == 0 ? 0 : mask) != (ctrl_data & mask);
630 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1,
635 #define ALC_SPDIF_CTRL_SWITCH(xname, nid, mask) \
636 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
637 .info = alc_spdif_ctrl_info, \
638 .get = alc_spdif_ctrl_get, \
639 .put = alc_spdif_ctrl_put, \
640 .private_value = nid | (mask<<16) }
641 #endif /* CONFIG_SND_DEBUG */
643 /* A switch control to allow the enabling EAPD digital outputs on the ALC26x.
644 * Again, this is only used in the ALC26x test models to help identify when
645 * the EAPD line must be asserted for features to work.
647 #ifdef CONFIG_SND_DEBUG
648 #define alc_eapd_ctrl_info snd_ctl_boolean_mono_info
650 static int alc_eapd_ctrl_get(struct snd_kcontrol *kcontrol,
651 struct snd_ctl_elem_value *ucontrol)
653 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
654 hda_nid_t nid = kcontrol->private_value & 0xffff;
655 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
656 long *valp = ucontrol->value.integer.value;
657 unsigned int val = snd_hda_codec_read(codec, nid, 0,
658 AC_VERB_GET_EAPD_BTLENABLE, 0x00);
660 *valp = (val & mask) != 0;
664 static int alc_eapd_ctrl_put(struct snd_kcontrol *kcontrol,
665 struct snd_ctl_elem_value *ucontrol)
668 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
669 hda_nid_t nid = kcontrol->private_value & 0xffff;
670 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
671 long val = *ucontrol->value.integer.value;
672 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
673 AC_VERB_GET_EAPD_BTLENABLE,
676 /* Set/unset the masked control bit(s) as needed */
677 change = (!val ? 0 : mask) != (ctrl_data & mask);
682 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
688 #define ALC_EAPD_CTRL_SWITCH(xname, nid, mask) \
689 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
690 .info = alc_eapd_ctrl_info, \
691 .get = alc_eapd_ctrl_get, \
692 .put = alc_eapd_ctrl_put, \
693 .private_value = nid | (mask<<16) }
694 #endif /* CONFIG_SND_DEBUG */
697 * set up from the preset table
699 static void setup_preset(struct alc_spec *spec,
700 const struct alc_config_preset *preset)
704 for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++)
705 spec->mixers[spec->num_mixers++] = preset->mixers[i];
706 for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i];
708 spec->init_verbs[spec->num_init_verbs++] =
709 preset->init_verbs[i];
711 spec->channel_mode = preset->channel_mode;
712 spec->num_channel_mode = preset->num_channel_mode;
713 spec->need_dac_fix = preset->need_dac_fix;
715 spec->multiout.max_channels = spec->channel_mode[0].channels;
717 spec->multiout.num_dacs = preset->num_dacs;
718 spec->multiout.dac_nids = preset->dac_nids;
719 spec->multiout.dig_out_nid = preset->dig_out_nid;
720 spec->multiout.hp_nid = preset->hp_nid;
722 spec->num_mux_defs = preset->num_mux_defs;
723 if (!spec->num_mux_defs)
724 spec->num_mux_defs = 1;
725 spec->input_mux = preset->input_mux;
727 spec->num_adc_nids = preset->num_adc_nids;
728 spec->adc_nids = preset->adc_nids;
729 spec->capsrc_nids = preset->capsrc_nids;
730 spec->dig_in_nid = preset->dig_in_nid;
732 spec->unsol_event = preset->unsol_event;
733 spec->init_hook = preset->init_hook;
734 #ifdef CONFIG_SND_HDA_POWER_SAVE
735 spec->loopback.amplist = preset->loopbacks;
739 /* Enable GPIO mask and set output */
740 static struct hda_verb alc_gpio1_init_verbs[] = {
741 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
742 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
743 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
747 static struct hda_verb alc_gpio2_init_verbs[] = {
748 {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
749 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
750 {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
754 static struct hda_verb alc_gpio3_init_verbs[] = {
755 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
756 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
757 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
762 * Fix hardware PLL issue
763 * On some codecs, the analog PLL gating control must be off while
764 * the default value is 1.
766 static void alc_fix_pll(struct hda_codec *codec)
768 struct alc_spec *spec = codec->spec;
773 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX,
775 val = snd_hda_codec_read(codec, spec->pll_nid, 0,
776 AC_VERB_GET_PROC_COEF, 0);
777 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX,
779 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_PROC_COEF,
780 val & ~(1 << spec->pll_coef_bit));
783 static void alc_fix_pll_init(struct hda_codec *codec, hda_nid_t nid,
784 unsigned int coef_idx, unsigned int coef_bit)
786 struct alc_spec *spec = codec->spec;
788 spec->pll_coef_idx = coef_idx;
789 spec->pll_coef_bit = coef_bit;
793 static void alc_sku_automute(struct hda_codec *codec)
795 struct alc_spec *spec = codec->spec;
796 unsigned int present;
797 unsigned int hp_nid = spec->autocfg.hp_pins[0];
798 unsigned int sp_nid = spec->autocfg.speaker_pins[0];
800 /* need to execute and sync at first */
801 snd_hda_codec_read(codec, hp_nid, 0, AC_VERB_SET_PIN_SENSE, 0);
802 present = snd_hda_codec_read(codec, hp_nid, 0,
803 AC_VERB_GET_PIN_SENSE, 0);
804 spec->jack_present = (present & 0x80000000) != 0;
805 snd_hda_codec_write(codec, sp_nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
806 spec->jack_present ? 0 : PIN_OUT);
809 /* unsolicited event for HP jack sensing */
810 static void alc_sku_unsol_event(struct hda_codec *codec, unsigned int res)
812 if (codec->vendor_id == 0x10ec0880)
816 if (res != ALC880_HP_EVENT)
819 alc_sku_automute(codec);
822 /* additional initialization for ALC888 variants */
823 static void alc888_coef_init(struct hda_codec *codec)
827 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 0);
828 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
829 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
830 if ((tmp & 0xf0) == 2)
832 snd_hda_codec_read(codec, 0x20, 0,
833 AC_VERB_SET_PROC_COEF, 0x830);
836 snd_hda_codec_read(codec, 0x20, 0,
837 AC_VERB_SET_PROC_COEF, 0x3030);
840 /* 32-bit subsystem ID for BIOS loading in HD Audio codec.
841 * 31 ~ 16 : Manufacture ID
843 * 7 ~ 0 : Assembly ID
844 * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36
846 static void alc_subsystem_id(struct hda_codec *codec,
847 unsigned int porta, unsigned int porte,
850 unsigned int ass, tmp, i;
852 struct alc_spec *spec = codec->spec;
854 ass = codec->subsystem_id & 0xffff;
855 if ((ass != codec->bus->pci->subsystem_device) && (ass & 1))
859 * 31~30 : port conetcivity
862 * 19~16 : Check sum (15:1)
867 if (codec->vendor_id == 0x10ec0260)
869 ass = snd_hda_codec_read(codec, nid, 0,
870 AC_VERB_GET_CONFIG_DEFAULT, 0);
871 if (!(ass & 1) && !(ass & 0x100000))
873 if ((ass >> 30) != 1) /* no physical connection */
878 for (i = 1; i < 16; i++) {
882 if (((ass >> 16) & 0xf) != tmp)
888 * 2 : 0 --> Desktop, 1 --> Laptop
889 * 3~5 : External Amplifier control
892 tmp = (ass & 0x38) >> 3; /* external Amp control */
895 snd_hda_sequence_write(codec, alc_gpio1_init_verbs);
898 snd_hda_sequence_write(codec, alc_gpio2_init_verbs);
901 snd_hda_sequence_write(codec, alc_gpio3_init_verbs);
903 case 5: /* set EAPD output high */
904 switch (codec->vendor_id) {
906 snd_hda_codec_write(codec, 0x0f, 0,
907 AC_VERB_SET_EAPD_BTLENABLE, 2);
908 snd_hda_codec_write(codec, 0x10, 0,
909 AC_VERB_SET_EAPD_BTLENABLE, 2);
920 snd_hda_codec_write(codec, 0x14, 0,
921 AC_VERB_SET_EAPD_BTLENABLE, 2);
922 snd_hda_codec_write(codec, 0x15, 0,
923 AC_VERB_SET_EAPD_BTLENABLE, 2);
926 switch (codec->vendor_id) {
928 snd_hda_codec_write(codec, 0x1a, 0,
929 AC_VERB_SET_COEF_INDEX, 7);
930 tmp = snd_hda_codec_read(codec, 0x1a, 0,
931 AC_VERB_GET_PROC_COEF, 0);
932 snd_hda_codec_write(codec, 0x1a, 0,
933 AC_VERB_SET_COEF_INDEX, 7);
934 snd_hda_codec_write(codec, 0x1a, 0,
935 AC_VERB_SET_PROC_COEF,
944 snd_hda_codec_write(codec, 0x20, 0,
945 AC_VERB_SET_COEF_INDEX, 7);
946 tmp = snd_hda_codec_read(codec, 0x20, 0,
947 AC_VERB_GET_PROC_COEF, 0);
948 snd_hda_codec_write(codec, 0x20, 0,
949 AC_VERB_SET_COEF_INDEX, 7);
950 snd_hda_codec_write(codec, 0x20, 0,
951 AC_VERB_SET_PROC_COEF,
955 /*alc888_coef_init(codec);*/ /* called in alc_init() */
959 snd_hda_codec_write(codec, 0x20, 0,
960 AC_VERB_SET_COEF_INDEX, 7);
961 tmp = snd_hda_codec_read(codec, 0x20, 0,
962 AC_VERB_GET_PROC_COEF, 0);
963 snd_hda_codec_write(codec, 0x20, 0,
964 AC_VERB_SET_COEF_INDEX, 7);
965 snd_hda_codec_write(codec, 0x20, 0,
966 AC_VERB_SET_PROC_COEF,
974 /* is laptop or Desktop and enable the function "Mute internal speaker
975 * when the external headphone out jack is plugged"
980 * 10~8 : Jack location
981 * 12~11: Headphone out -> 00: PortA, 01: PortE, 02: PortD, 03: Resvered
983 * 15 : 1 --> enable the function "Mute internal speaker
984 * when the external headphone out jack is plugged"
986 if (!spec->autocfg.speaker_pins[0]) {
987 if (spec->autocfg.line_out_pins[0])
988 spec->autocfg.speaker_pins[0] =
989 spec->autocfg.line_out_pins[0];
994 if (!spec->autocfg.hp_pins[0]) {
995 tmp = (ass >> 11) & 0x3; /* HP to chassis */
997 spec->autocfg.hp_pins[0] = porta;
999 spec->autocfg.hp_pins[0] = porte;
1001 spec->autocfg.hp_pins[0] = portd;
1006 snd_hda_codec_write(codec, spec->autocfg.hp_pins[0], 0,
1007 AC_VERB_SET_UNSOLICITED_ENABLE,
1008 AC_USRSP_EN | ALC880_HP_EVENT);
1009 spec->unsol_event = alc_sku_unsol_event;
1013 * Fix-up pin default configurations
1021 static void alc_fix_pincfg(struct hda_codec *codec,
1022 const struct snd_pci_quirk *quirk,
1023 const struct alc_pincfg **pinfix)
1025 const struct alc_pincfg *cfg;
1027 quirk = snd_pci_quirk_lookup(codec->bus->pci, quirk);
1031 cfg = pinfix[quirk->value];
1032 for (; cfg->nid; cfg++) {
1035 for (i = 0; i < 4; i++) {
1036 snd_hda_codec_write(codec, cfg->nid, 0,
1037 AC_VERB_SET_CONFIG_DEFAULT_BYTES_0 + i,
1045 * ALC880 3-stack model
1047 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
1048 * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18,
1049 * F-Mic = 0x1b, HP = 0x19
1052 static hda_nid_t alc880_dac_nids[4] = {
1053 /* front, rear, clfe, rear_surr */
1054 0x02, 0x05, 0x04, 0x03
1057 static hda_nid_t alc880_adc_nids[3] = {
1062 /* The datasheet says the node 0x07 is connected from inputs,
1063 * but it shows zero connection in the real implementation on some devices.
1064 * Note: this is a 915GAV bug, fixed on 915GLV
1066 static hda_nid_t alc880_adc_nids_alt[2] = {
1071 #define ALC880_DIGOUT_NID 0x06
1072 #define ALC880_DIGIN_NID 0x0a
1074 static struct hda_input_mux alc880_capture_source = {
1078 { "Front Mic", 0x3 },
1084 /* channel source setting (2/6 channel selection for 3-stack) */
1086 static struct hda_verb alc880_threestack_ch2_init[] = {
1087 /* set line-in to input, mute it */
1088 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1089 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1090 /* set mic-in to input vref 80%, mute it */
1091 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1092 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1097 static struct hda_verb alc880_threestack_ch6_init[] = {
1098 /* set line-in to output, unmute it */
1099 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1100 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1101 /* set mic-in to output, unmute it */
1102 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1103 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1107 static struct hda_channel_mode alc880_threestack_modes[2] = {
1108 { 2, alc880_threestack_ch2_init },
1109 { 6, alc880_threestack_ch6_init },
1112 static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
1113 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1114 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1115 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
1116 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
1117 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1118 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1119 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1120 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1121 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1122 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1123 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1124 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1125 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1126 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1127 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
1128 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
1129 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1130 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
1131 HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
1133 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1134 .name = "Channel Mode",
1135 .info = alc_ch_mode_info,
1136 .get = alc_ch_mode_get,
1137 .put = alc_ch_mode_put,
1142 /* capture mixer elements */
1143 static struct snd_kcontrol_new alc880_capture_mixer[] = {
1144 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
1145 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
1146 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
1147 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
1148 HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
1149 HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
1151 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1152 /* The multiple "Capture Source" controls confuse alsamixer
1153 * So call somewhat different..
1155 /* .name = "Capture Source", */
1156 .name = "Input Source",
1158 .info = alc_mux_enum_info,
1159 .get = alc_mux_enum_get,
1160 .put = alc_mux_enum_put,
1165 /* capture mixer elements (in case NID 0x07 not available) */
1166 static struct snd_kcontrol_new alc880_capture_alt_mixer[] = {
1167 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
1168 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
1169 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
1170 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
1172 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1173 /* The multiple "Capture Source" controls confuse alsamixer
1174 * So call somewhat different..
1176 /* .name = "Capture Source", */
1177 .name = "Input Source",
1179 .info = alc_mux_enum_info,
1180 .get = alc_mux_enum_get,
1181 .put = alc_mux_enum_put,
1189 * ALC880 5-stack model
1191 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d),
1193 * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
1194 * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
1197 /* additional mixers to alc880_three_stack_mixer */
1198 static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
1199 HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1200 HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
1204 /* channel source setting (6/8 channel selection for 5-stack) */
1206 static struct hda_verb alc880_fivestack_ch6_init[] = {
1207 /* set line-in to input, mute it */
1208 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1209 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1214 static struct hda_verb alc880_fivestack_ch8_init[] = {
1215 /* set line-in to output, unmute it */
1216 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1217 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1221 static struct hda_channel_mode alc880_fivestack_modes[2] = {
1222 { 6, alc880_fivestack_ch6_init },
1223 { 8, alc880_fivestack_ch8_init },
1228 * ALC880 6-stack model
1230 * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e),
1231 * Side = 0x05 (0x0f)
1232 * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
1233 * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
1236 static hda_nid_t alc880_6st_dac_nids[4] = {
1237 /* front, rear, clfe, rear_surr */
1238 0x02, 0x03, 0x04, 0x05
1241 static struct hda_input_mux alc880_6stack_capture_source = {
1245 { "Front Mic", 0x1 },
1251 /* fixed 8-channels */
1252 static struct hda_channel_mode alc880_sixstack_modes[1] = {
1256 static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
1257 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1258 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1259 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1260 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
1261 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1262 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1263 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1264 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1265 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
1266 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
1267 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1268 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1269 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1270 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1271 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1272 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1273 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1274 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1275 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1276 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
1278 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1279 .name = "Channel Mode",
1280 .info = alc_ch_mode_info,
1281 .get = alc_ch_mode_get,
1282 .put = alc_ch_mode_put,
1291 * W810 has rear IO for:
1294 * Center/LFE (DAC 04)
1297 * The system also has a pair of internal speakers, and a headphone jack.
1298 * These are both connected to Line2 on the codec, hence to DAC 02.
1300 * There is a variable resistor to control the speaker or headphone
1301 * volume. This is a hardware-only device without a software API.
1303 * Plugging headphones in will disable the internal speakers. This is
1304 * implemented in hardware, not via the driver using jack sense. In
1305 * a similar fashion, plugging into the rear socket marked "front" will
1306 * disable both the speakers and headphones.
1308 * For input, there's a microphone jack, and an "audio in" jack.
1309 * These may not do anything useful with this driver yet, because I
1310 * haven't setup any initialization verbs for these yet...
1313 static hda_nid_t alc880_w810_dac_nids[3] = {
1314 /* front, rear/surround, clfe */
1318 /* fixed 6 channels */
1319 static struct hda_channel_mode alc880_w810_modes[1] = {
1323 /* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
1324 static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
1325 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1326 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1327 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1328 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
1329 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1330 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1331 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1332 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1333 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
1341 * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
1342 * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?),
1346 static hda_nid_t alc880_z71v_dac_nids[1] = {
1349 #define ALC880_Z71V_HP_DAC 0x03
1351 /* fixed 2 channels */
1352 static struct hda_channel_mode alc880_2_jack_modes[1] = {
1356 static struct snd_kcontrol_new alc880_z71v_mixer[] = {
1357 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1358 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1359 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1360 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
1361 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1362 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1363 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1364 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1370 * ALC880 F1734 model
1372 * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
1373 * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
1376 static hda_nid_t alc880_f1734_dac_nids[1] = {
1379 #define ALC880_F1734_HP_DAC 0x02
1381 static struct snd_kcontrol_new alc880_f1734_mixer[] = {
1382 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1383 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
1384 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1385 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
1386 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1387 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1388 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1389 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1393 static struct hda_input_mux alc880_f1734_capture_source = {
1405 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
1406 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
1407 * Mic = 0x18, Line = 0x1a
1410 #define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
1411 #define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
1413 static struct snd_kcontrol_new alc880_asus_mixer[] = {
1414 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1415 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1416 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1417 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
1418 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1419 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1420 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1421 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1422 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1423 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1424 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1425 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1426 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1427 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1429 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1430 .name = "Channel Mode",
1431 .info = alc_ch_mode_info,
1432 .get = alc_ch_mode_get,
1433 .put = alc_ch_mode_put,
1439 * ALC880 ASUS W1V model
1441 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
1442 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
1443 * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
1446 /* additional mixers to alc880_asus_mixer */
1447 static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
1448 HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
1449 HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
1453 /* additional mixers to alc880_asus_mixer */
1454 static struct snd_kcontrol_new alc880_pcbeep_mixer[] = {
1455 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1456 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
1461 static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
1462 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1463 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
1464 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
1465 HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
1466 HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
1467 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
1468 HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
1469 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
1470 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
1472 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1473 /* The multiple "Capture Source" controls confuse alsamixer
1474 * So call somewhat different..
1476 /* .name = "Capture Source", */
1477 .name = "Input Source",
1479 .info = alc_mux_enum_info,
1480 .get = alc_mux_enum_get,
1481 .put = alc_mux_enum_put,
1487 static struct snd_kcontrol_new alc880_uniwill_mixer[] = {
1488 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1489 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
1490 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1491 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
1492 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1493 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1494 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1495 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1496 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1497 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1498 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1499 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1500 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1501 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1502 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1503 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1504 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1505 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
1507 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1508 .name = "Channel Mode",
1509 .info = alc_ch_mode_info,
1510 .get = alc_ch_mode_get,
1511 .put = alc_ch_mode_put,
1516 static struct snd_kcontrol_new alc880_fujitsu_mixer[] = {
1517 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1518 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
1519 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1520 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
1521 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1522 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1523 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1524 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1525 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1526 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1530 static struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = {
1531 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1532 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
1533 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1534 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
1535 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1536 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1541 * virtual master controls
1545 * slave controls for virtual master
1547 static const char *alc_slave_vols[] = {
1548 "Front Playback Volume",
1549 "Surround Playback Volume",
1550 "Center Playback Volume",
1551 "LFE Playback Volume",
1552 "Side Playback Volume",
1553 "Headphone Playback Volume",
1554 "Speaker Playback Volume",
1555 "Mono Playback Volume",
1556 "Line-Out Playback Volume",
1560 static const char *alc_slave_sws[] = {
1561 "Front Playback Switch",
1562 "Surround Playback Switch",
1563 "Center Playback Switch",
1564 "LFE Playback Switch",
1565 "Side Playback Switch",
1566 "Headphone Playback Switch",
1567 "Speaker Playback Switch",
1568 "Mono Playback Switch",
1569 "IEC958 Playback Switch",
1574 * build control elements
1576 static int alc_build_controls(struct hda_codec *codec)
1578 struct alc_spec *spec = codec->spec;
1582 for (i = 0; i < spec->num_mixers; i++) {
1583 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
1588 if (spec->multiout.dig_out_nid) {
1589 err = snd_hda_create_spdif_out_ctls(codec,
1590 spec->multiout.dig_out_nid);
1593 err = snd_hda_create_spdif_share_sw(codec,
1597 spec->multiout.share_spdif = 1;
1599 if (spec->dig_in_nid) {
1600 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
1605 /* if we have no master control, let's create it */
1606 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
1607 unsigned int vmaster_tlv[4];
1608 snd_hda_set_vmaster_tlv(codec, spec->vmaster_nid,
1609 HDA_OUTPUT, vmaster_tlv);
1610 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
1611 vmaster_tlv, alc_slave_vols);
1615 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
1616 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
1617 NULL, alc_slave_sws);
1627 * initialize the codec volumes, etc
1631 * generic initialization of ADC, input mixers and output mixers
1633 static struct hda_verb alc880_volume_init_verbs[] = {
1635 * Unmute ADC0-2 and set the default input to mic-in
1637 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
1638 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1639 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
1640 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1641 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
1642 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1644 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
1646 * Note: PASD motherboards uses the Line In 2 as the input for front
1649 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
1650 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1651 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1652 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
1653 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
1654 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
1655 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
1656 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
1659 * Set up output mixers (0x0c - 0x0f)
1661 /* set vol=0 to output mixers */
1662 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1663 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1664 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1665 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1666 /* set up input amps for analog loopback */
1667 /* Amp Indices: DAC = 0, mixer = 1 */
1668 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1669 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1670 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1671 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1672 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1673 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1674 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1675 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1681 * 3-stack pin configuration:
1682 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
1684 static struct hda_verb alc880_pin_3stack_init_verbs[] = {
1686 * preset connection lists of input pins
1687 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
1689 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
1690 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1691 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
1694 * Set pin mode and muting
1696 /* set front pin widgets 0x14 for output */
1697 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1698 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1699 /* Mic1 (rear panel) pin widget for input and vref at 80% */
1700 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1701 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1702 /* Mic2 (as headphone out) for HP output */
1703 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1704 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1705 /* Line In pin widget for input */
1706 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1707 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1708 /* Line2 (as front mic) pin widget for input and vref at 80% */
1709 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1710 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1711 /* CD pin widget for input */
1712 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1718 * 5-stack pin configuration:
1719 * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
1720 * line-in/side = 0x1a, f-mic = 0x1b
1722 static struct hda_verb alc880_pin_5stack_init_verbs[] = {
1724 * preset connection lists of input pins
1725 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
1727 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1728 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
1731 * Set pin mode and muting
1733 /* set pin widgets 0x14-0x17 for output */
1734 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1735 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1736 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1737 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1738 /* unmute pins for output (no gain on this amp) */
1739 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1740 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1741 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1742 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1744 /* Mic1 (rear panel) pin widget for input and vref at 80% */
1745 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1746 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1747 /* Mic2 (as headphone out) for HP output */
1748 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1749 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1750 /* Line In pin widget for input */
1751 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1752 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1753 /* Line2 (as front mic) pin widget for input and vref at 80% */
1754 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1755 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1756 /* CD pin widget for input */
1757 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1763 * W810 pin configuration:
1764 * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
1766 static struct hda_verb alc880_pin_w810_init_verbs[] = {
1767 /* hphone/speaker input selector: front DAC */
1768 {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
1770 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1771 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1772 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1773 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1774 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1775 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1777 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1778 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1784 * Z71V pin configuration:
1785 * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
1787 static struct hda_verb alc880_pin_z71v_init_verbs[] = {
1788 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1789 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1790 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1791 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1793 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1794 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1795 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1796 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1802 * 6-stack pin configuration:
1803 * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18,
1804 * f-mic = 0x19, line = 0x1a, HP = 0x1b
1806 static struct hda_verb alc880_pin_6stack_init_verbs[] = {
1807 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1809 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1810 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1811 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1812 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1813 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1814 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1815 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1816 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1818 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1819 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1820 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1821 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1822 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1823 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1824 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1825 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1826 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1832 * Uniwill pin configuration:
1833 * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19,
1836 static struct hda_verb alc880_uniwill_init_verbs[] = {
1837 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1839 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1840 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1841 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1842 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1843 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1844 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1845 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1846 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1847 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1848 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1849 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1850 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1851 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1852 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1854 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1855 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1856 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1857 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1858 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1859 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1860 /* {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, */
1861 /* {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
1862 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1864 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
1865 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
1872 * HP = 0x14, InternalSpeaker = 0x15, mic = 0x19,
1874 static struct hda_verb alc880_uniwill_p53_init_verbs[] = {
1875 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1877 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1878 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1879 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1880 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1881 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1882 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1883 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1884 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1885 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1886 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1887 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1888 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1890 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1891 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1892 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1893 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1894 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1895 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1897 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
1898 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_DCVOL_EVENT},
1903 static struct hda_verb alc880_beep_init_verbs[] = {
1904 { 0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5) },
1908 /* toggle speaker-output according to the hp-jack state */
1909 static void alc880_uniwill_hp_automute(struct hda_codec *codec)
1911 unsigned int present;
1914 present = snd_hda_codec_read(codec, 0x14, 0,
1915 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1916 bits = present ? HDA_AMP_MUTE : 0;
1917 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
1918 HDA_AMP_MUTE, bits);
1919 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
1920 HDA_AMP_MUTE, bits);
1923 /* auto-toggle front mic */
1924 static void alc880_uniwill_mic_automute(struct hda_codec *codec)
1926 unsigned int present;
1929 present = snd_hda_codec_read(codec, 0x18, 0,
1930 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1931 bits = present ? HDA_AMP_MUTE : 0;
1932 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
1935 static void alc880_uniwill_automute(struct hda_codec *codec)
1937 alc880_uniwill_hp_automute(codec);
1938 alc880_uniwill_mic_automute(codec);
1941 static void alc880_uniwill_unsol_event(struct hda_codec *codec,
1944 /* Looks like the unsol event is incompatible with the standard
1945 * definition. 4bit tag is placed at 28 bit!
1947 switch (res >> 28) {
1948 case ALC880_HP_EVENT:
1949 alc880_uniwill_hp_automute(codec);
1951 case ALC880_MIC_EVENT:
1952 alc880_uniwill_mic_automute(codec);
1957 static void alc880_uniwill_p53_hp_automute(struct hda_codec *codec)
1959 unsigned int present;
1962 present = snd_hda_codec_read(codec, 0x14, 0,
1963 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1964 bits = present ? HDA_AMP_MUTE : 0;
1965 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, HDA_AMP_MUTE, bits);
1968 static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec)
1970 unsigned int present;
1972 present = snd_hda_codec_read(codec, 0x21, 0,
1973 AC_VERB_GET_VOLUME_KNOB_CONTROL, 0);
1974 present &= HDA_AMP_VOLMASK;
1975 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0,
1976 HDA_AMP_VOLMASK, present);
1977 snd_hda_codec_amp_stereo(codec, 0x0d, HDA_OUTPUT, 0,
1978 HDA_AMP_VOLMASK, present);
1981 static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec,
1984 /* Looks like the unsol event is incompatible with the standard
1985 * definition. 4bit tag is placed at 28 bit!
1987 if ((res >> 28) == ALC880_HP_EVENT)
1988 alc880_uniwill_p53_hp_automute(codec);
1989 if ((res >> 28) == ALC880_DCVOL_EVENT)
1990 alc880_uniwill_p53_dcvol_automute(codec);
1994 * F1734 pin configuration:
1995 * HP = 0x14, speaker-out = 0x15, mic = 0x18
1997 static struct hda_verb alc880_pin_f1734_init_verbs[] = {
1998 {0x07, AC_VERB_SET_CONNECT_SEL, 0x01},
1999 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
2000 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
2001 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
2002 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
2004 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2005 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2006 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2007 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2009 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2010 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2011 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
2012 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2013 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2014 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2015 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2016 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2017 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2019 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
2020 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_DCVOL_EVENT},
2026 * ASUS pin configuration:
2027 * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
2029 static struct hda_verb alc880_pin_asus_init_verbs[] = {
2030 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
2031 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
2032 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
2033 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
2035 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2036 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2037 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2038 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2039 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2040 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2041 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2042 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2044 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2045 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2046 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2047 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2048 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2049 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2050 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2051 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2052 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2057 /* Enable GPIO mask and set output */
2058 #define alc880_gpio1_init_verbs alc_gpio1_init_verbs
2059 #define alc880_gpio2_init_verbs alc_gpio2_init_verbs
2061 /* Clevo m520g init */
2062 static struct hda_verb alc880_pin_clevo_init_verbs[] = {
2063 /* headphone output */
2064 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
2066 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2067 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2069 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2070 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2072 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2073 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2074 /* Mic1 (rear panel) */
2075 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2076 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2077 /* Mic2 (front panel) */
2078 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2079 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2081 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2082 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2083 /* change to EAPD mode */
2084 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2085 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
2090 static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
2091 /* change to EAPD mode */
2092 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2093 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
2095 /* Headphone output */
2096 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2098 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2099 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
2101 /* Line In pin widget for input */
2102 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2103 /* CD pin widget for input */
2104 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2105 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2106 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2108 /* change to EAPD mode */
2109 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2110 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
2116 * LG m1 express dual
2119 * Rear Line-In/Out (blue): 0x14
2120 * Build-in Mic-In: 0x15
2122 * HP-Out (green): 0x1b
2123 * Mic-In/Out (red): 0x19
2127 /* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
2128 static hda_nid_t alc880_lg_dac_nids[3] = {
2132 /* seems analog CD is not working */
2133 static struct hda_input_mux alc880_lg_capture_source = {
2138 { "Internal Mic", 0x6 },
2142 /* 2,4,6 channel modes */
2143 static struct hda_verb alc880_lg_ch2_init[] = {
2144 /* set line-in and mic-in to input */
2145 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
2146 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
2150 static struct hda_verb alc880_lg_ch4_init[] = {
2151 /* set line-in to out and mic-in to input */
2152 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
2153 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
2157 static struct hda_verb alc880_lg_ch6_init[] = {
2158 /* set line-in and mic-in to output */
2159 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
2160 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
2164 static struct hda_channel_mode alc880_lg_ch_modes[3] = {
2165 { 2, alc880_lg_ch2_init },
2166 { 4, alc880_lg_ch4_init },
2167 { 6, alc880_lg_ch6_init },
2170 static struct snd_kcontrol_new alc880_lg_mixer[] = {
2171 HDA_CODEC_VOLUME("Front Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
2172 HDA_BIND_MUTE("Front Playback Switch", 0x0f, 2, HDA_INPUT),
2173 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2174 HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
2175 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
2176 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
2177 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
2178 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
2179 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2180 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
2181 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
2182 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
2183 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
2184 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
2186 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2187 .name = "Channel Mode",
2188 .info = alc_ch_mode_info,
2189 .get = alc_ch_mode_get,
2190 .put = alc_ch_mode_put,
2195 static struct hda_verb alc880_lg_init_verbs[] = {
2196 /* set capture source to mic-in */
2197 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2198 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2199 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2200 /* mute all amp mixer inputs */
2201 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
2202 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
2203 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
2204 /* line-in to input */
2205 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2206 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2208 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2209 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2211 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2212 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2213 /* mic-in to input */
2214 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
2215 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2216 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2218 {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
2219 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2220 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2222 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
2226 /* toggle speaker-output according to the hp-jack state */
2227 static void alc880_lg_automute(struct hda_codec *codec)
2229 unsigned int present;
2232 present = snd_hda_codec_read(codec, 0x1b, 0,
2233 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
2234 bits = present ? HDA_AMP_MUTE : 0;
2235 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
2236 HDA_AMP_MUTE, bits);
2239 static void alc880_lg_unsol_event(struct hda_codec *codec, unsigned int res)
2241 /* Looks like the unsol event is incompatible with the standard
2242 * definition. 4bit tag is placed at 28 bit!
2244 if ((res >> 28) == 0x01)
2245 alc880_lg_automute(codec);
2254 * Built-in Mic-In: 0x19
2260 static struct hda_input_mux alc880_lg_lw_capture_source = {
2264 { "Internal Mic", 0x1 },
2269 #define alc880_lg_lw_modes alc880_threestack_modes
2271 static struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
2272 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2273 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2274 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
2275 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
2276 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2277 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2278 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2279 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2280 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2281 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2282 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2283 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2284 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
2285 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
2287 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2288 .name = "Channel Mode",
2289 .info = alc_ch_mode_info,
2290 .get = alc_ch_mode_get,
2291 .put = alc_ch_mode_put,
2296 static struct hda_verb alc880_lg_lw_init_verbs[] = {
2297 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2298 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
2299 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
2301 /* set capture source to mic-in */
2302 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2303 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2304 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2305 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
2307 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2308 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2310 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2311 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2312 /* mic-in to input */
2313 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2314 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2316 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2317 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2319 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
2323 /* toggle speaker-output according to the hp-jack state */
2324 static void alc880_lg_lw_automute(struct hda_codec *codec)
2326 unsigned int present;
2329 present = snd_hda_codec_read(codec, 0x1b, 0,
2330 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
2331 bits = present ? HDA_AMP_MUTE : 0;
2332 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
2333 HDA_AMP_MUTE, bits);
2336 static void alc880_lg_lw_unsol_event(struct hda_codec *codec, unsigned int res)
2338 /* Looks like the unsol event is incompatible with the standard
2339 * definition. 4bit tag is placed at 28 bit!
2341 if ((res >> 28) == 0x01)
2342 alc880_lg_lw_automute(codec);
2345 static struct snd_kcontrol_new alc880_medion_rim_mixer[] = {
2346 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2347 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
2348 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2349 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2350 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2351 HDA_CODEC_MUTE("Internal Playback Switch", 0x0b, 0x1, HDA_INPUT),
2355 static struct hda_input_mux alc880_medion_rim_capture_source = {
2359 { "Internal Mic", 0x1 },
2363 static struct hda_verb alc880_medion_rim_init_verbs[] = {
2364 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2366 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2367 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2369 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2370 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2371 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2372 /* Mic2 (as headphone out) for HP output */
2373 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2374 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2375 /* Internal Speaker */
2376 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2377 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2379 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2380 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
2382 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
2386 /* toggle speaker-output according to the hp-jack state */
2387 static void alc880_medion_rim_automute(struct hda_codec *codec)
2389 unsigned int present;
2392 present = snd_hda_codec_read(codec, 0x14, 0,
2393 AC_VERB_GET_PIN_SENSE, 0)
2394 & AC_PINSENSE_PRESENCE;
2395 bits = present ? HDA_AMP_MUTE : 0;
2396 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
2397 HDA_AMP_MUTE, bits);
2399 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 0);
2401 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 2);
2404 static void alc880_medion_rim_unsol_event(struct hda_codec *codec,
2407 /* Looks like the unsol event is incompatible with the standard
2408 * definition. 4bit tag is placed at 28 bit!
2410 if ((res >> 28) == ALC880_HP_EVENT)
2411 alc880_medion_rim_automute(codec);
2414 #ifdef CONFIG_SND_HDA_POWER_SAVE
2415 static struct hda_amp_list alc880_loopbacks[] = {
2416 { 0x0b, HDA_INPUT, 0 },
2417 { 0x0b, HDA_INPUT, 1 },
2418 { 0x0b, HDA_INPUT, 2 },
2419 { 0x0b, HDA_INPUT, 3 },
2420 { 0x0b, HDA_INPUT, 4 },
2424 static struct hda_amp_list alc880_lg_loopbacks[] = {
2425 { 0x0b, HDA_INPUT, 1 },
2426 { 0x0b, HDA_INPUT, 6 },
2427 { 0x0b, HDA_INPUT, 7 },
2436 static int alc_init(struct hda_codec *codec)
2438 struct alc_spec *spec = codec->spec;
2442 if (codec->vendor_id == 0x10ec0888)
2443 alc888_coef_init(codec);
2445 for (i = 0; i < spec->num_init_verbs; i++)
2446 snd_hda_sequence_write(codec, spec->init_verbs[i]);
2448 if (spec->init_hook)
2449 spec->init_hook(codec);
2454 static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
2456 struct alc_spec *spec = codec->spec;
2458 if (spec->unsol_event)
2459 spec->unsol_event(codec, res);
2462 #ifdef CONFIG_SND_HDA_POWER_SAVE
2463 static int alc_check_power_status(struct hda_codec *codec, hda_nid_t nid)
2465 struct alc_spec *spec = codec->spec;
2466 return snd_hda_check_amp_list_power(codec, &spec->loopback, nid);
2471 * Analog playback callbacks
2473 static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
2474 struct hda_codec *codec,
2475 struct snd_pcm_substream *substream)
2477 struct alc_spec *spec = codec->spec;
2478 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
2482 static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2483 struct hda_codec *codec,
2484 unsigned int stream_tag,
2485 unsigned int format,
2486 struct snd_pcm_substream *substream)
2488 struct alc_spec *spec = codec->spec;
2489 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
2490 stream_tag, format, substream);
2493 static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
2494 struct hda_codec *codec,
2495 struct snd_pcm_substream *substream)
2497 struct alc_spec *spec = codec->spec;
2498 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
2504 static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
2505 struct hda_codec *codec,
2506 struct snd_pcm_substream *substream)
2508 struct alc_spec *spec = codec->spec;
2509 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
2512 static int alc880_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2513 struct hda_codec *codec,
2514 unsigned int stream_tag,
2515 unsigned int format,
2516 struct snd_pcm_substream *substream)
2518 struct alc_spec *spec = codec->spec;
2519 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
2520 stream_tag, format, substream);
2523 static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
2524 struct hda_codec *codec,
2525 struct snd_pcm_substream *substream)
2527 struct alc_spec *spec = codec->spec;
2528 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
2534 static int alc880_alt_capture_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;
2542 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number + 1],
2543 stream_tag, 0, format);
2547 static int alc880_alt_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
2548 struct hda_codec *codec,
2549 struct snd_pcm_substream *substream)
2551 struct alc_spec *spec = codec->spec;
2553 snd_hda_codec_cleanup_stream(codec,
2554 spec->adc_nids[substream->number + 1]);
2561 static struct hda_pcm_stream alc880_pcm_analog_playback = {
2565 /* NID is set in alc_build_pcms */
2567 .open = alc880_playback_pcm_open,
2568 .prepare = alc880_playback_pcm_prepare,
2569 .cleanup = alc880_playback_pcm_cleanup
2573 static struct hda_pcm_stream alc880_pcm_analog_capture = {
2577 /* NID is set in alc_build_pcms */
2580 static struct hda_pcm_stream alc880_pcm_analog_alt_playback = {
2584 /* NID is set in alc_build_pcms */
2587 static struct hda_pcm_stream alc880_pcm_analog_alt_capture = {
2588 .substreams = 2, /* can be overridden */
2591 /* NID is set in alc_build_pcms */
2593 .prepare = alc880_alt_capture_pcm_prepare,
2594 .cleanup = alc880_alt_capture_pcm_cleanup
2598 static struct hda_pcm_stream alc880_pcm_digital_playback = {
2602 /* NID is set in alc_build_pcms */
2604 .open = alc880_dig_playback_pcm_open,
2605 .close = alc880_dig_playback_pcm_close,
2606 .prepare = alc880_dig_playback_pcm_prepare
2610 static struct hda_pcm_stream alc880_pcm_digital_capture = {
2614 /* NID is set in alc_build_pcms */
2617 /* Used by alc_build_pcms to flag that a PCM has no playback stream */
2618 static struct hda_pcm_stream alc_pcm_null_stream = {
2624 static int alc_build_pcms(struct hda_codec *codec)
2626 struct alc_spec *spec = codec->spec;
2627 struct hda_pcm *info = spec->pcm_rec;
2630 codec->num_pcms = 1;
2631 codec->pcm_info = info;
2633 info->name = spec->stream_name_analog;
2634 if (spec->stream_analog_playback) {
2635 snd_assert(spec->multiout.dac_nids, return -EINVAL);
2636 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
2637 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
2639 if (spec->stream_analog_capture) {
2640 snd_assert(spec->adc_nids, return -EINVAL);
2641 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
2642 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
2645 if (spec->channel_mode) {
2646 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
2647 for (i = 0; i < spec->num_channel_mode; i++) {
2648 if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
2649 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
2654 /* SPDIF for stream index #1 */
2655 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
2656 codec->num_pcms = 2;
2657 info = spec->pcm_rec + 1;
2658 info->name = spec->stream_name_digital;
2659 info->pcm_type = HDA_PCM_TYPE_SPDIF;
2660 if (spec->multiout.dig_out_nid &&
2661 spec->stream_digital_playback) {
2662 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
2663 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
2665 if (spec->dig_in_nid &&
2666 spec->stream_digital_capture) {
2667 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
2668 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
2672 /* If the use of more than one ADC is requested for the current
2673 * model, configure a second analog capture-only PCM.
2675 /* Additional Analaog capture for index #2 */
2676 if ((spec->alt_dac_nid && spec->stream_analog_alt_playback) ||
2677 (spec->num_adc_nids > 1 && spec->stream_analog_alt_capture)) {
2678 codec->num_pcms = 3;
2679 info = spec->pcm_rec + 2;
2680 info->name = spec->stream_name_analog;
2681 if (spec->alt_dac_nid) {
2682 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
2683 *spec->stream_analog_alt_playback;
2684 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
2687 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
2688 alc_pcm_null_stream;
2689 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
2691 if (spec->num_adc_nids > 1) {
2692 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
2693 *spec->stream_analog_alt_capture;
2694 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid =
2696 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams =
2697 spec->num_adc_nids - 1;
2699 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
2700 alc_pcm_null_stream;
2701 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = 0;
2708 static void alc_free(struct hda_codec *codec)
2710 struct alc_spec *spec = codec->spec;
2716 if (spec->kctl_alloc) {
2717 for (i = 0; i < spec->num_kctl_used; i++)
2718 kfree(spec->kctl_alloc[i].name);
2719 kfree(spec->kctl_alloc);
2722 codec->spec = NULL; /* to be sure */
2727 static struct hda_codec_ops alc_patch_ops = {
2728 .build_controls = alc_build_controls,
2729 .build_pcms = alc_build_pcms,
2732 .unsol_event = alc_unsol_event,
2733 #ifdef CONFIG_SND_HDA_POWER_SAVE
2734 .check_power_status = alc_check_power_status,
2740 * Test configuration for debugging
2742 * Almost all inputs/outputs are enabled. I/O pins can be configured via
2745 #ifdef CONFIG_SND_DEBUG
2746 static hda_nid_t alc880_test_dac_nids[4] = {
2747 0x02, 0x03, 0x04, 0x05
2750 static struct hda_input_mux alc880_test_capture_source = {
2759 { "Surround", 0x6 },
2763 static struct hda_channel_mode alc880_test_modes[4] = {
2770 static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol,
2771 struct snd_ctl_elem_info *uinfo)
2773 static char *texts[] = {
2774 "N/A", "Line Out", "HP Out",
2775 "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
2777 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
2779 uinfo->value.enumerated.items = 8;
2780 if (uinfo->value.enumerated.item >= 8)
2781 uinfo->value.enumerated.item = 7;
2782 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
2786 static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol,
2787 struct snd_ctl_elem_value *ucontrol)
2789 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2790 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2791 unsigned int pin_ctl, item = 0;
2793 pin_ctl = snd_hda_codec_read(codec, nid, 0,
2794 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
2795 if (pin_ctl & AC_PINCTL_OUT_EN) {
2796 if (pin_ctl & AC_PINCTL_HP_EN)
2800 } else if (pin_ctl & AC_PINCTL_IN_EN) {
2801 switch (pin_ctl & AC_PINCTL_VREFEN) {
2802 case AC_PINCTL_VREF_HIZ: item = 3; break;
2803 case AC_PINCTL_VREF_50: item = 4; break;
2804 case AC_PINCTL_VREF_GRD: item = 5; break;
2805 case AC_PINCTL_VREF_80: item = 6; break;
2806 case AC_PINCTL_VREF_100: item = 7; break;
2809 ucontrol->value.enumerated.item[0] = item;
2813 static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol,
2814 struct snd_ctl_elem_value *ucontrol)
2816 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2817 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2818 static unsigned int ctls[] = {
2819 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
2820 AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
2821 AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
2822 AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
2823 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
2824 AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
2826 unsigned int old_ctl, new_ctl;
2828 old_ctl = snd_hda_codec_read(codec, nid, 0,
2829 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
2830 new_ctl = ctls[ucontrol->value.enumerated.item[0]];
2831 if (old_ctl != new_ctl) {
2833 snd_hda_codec_write_cache(codec, nid, 0,
2834 AC_VERB_SET_PIN_WIDGET_CONTROL,
2836 val = ucontrol->value.enumerated.item[0] >= 3 ?
2838 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
2845 static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol,
2846 struct snd_ctl_elem_info *uinfo)
2848 static char *texts[] = {
2849 "Front", "Surround", "CLFE", "Side"
2851 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
2853 uinfo->value.enumerated.items = 4;
2854 if (uinfo->value.enumerated.item >= 4)
2855 uinfo->value.enumerated.item = 3;
2856 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
2860 static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol,
2861 struct snd_ctl_elem_value *ucontrol)
2863 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2864 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2867 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
2868 ucontrol->value.enumerated.item[0] = sel & 3;
2872 static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol,
2873 struct snd_ctl_elem_value *ucontrol)
2875 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2876 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2879 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
2880 if (ucontrol->value.enumerated.item[0] != sel) {
2881 sel = ucontrol->value.enumerated.item[0] & 3;
2882 snd_hda_codec_write_cache(codec, nid, 0,
2883 AC_VERB_SET_CONNECT_SEL, sel);
2889 #define PIN_CTL_TEST(xname,nid) { \
2890 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2892 .info = alc_test_pin_ctl_info, \
2893 .get = alc_test_pin_ctl_get, \
2894 .put = alc_test_pin_ctl_put, \
2895 .private_value = nid \
2898 #define PIN_SRC_TEST(xname,nid) { \
2899 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2901 .info = alc_test_pin_src_info, \
2902 .get = alc_test_pin_src_get, \
2903 .put = alc_test_pin_src_put, \
2904 .private_value = nid \
2907 static struct snd_kcontrol_new alc880_test_mixer[] = {
2908 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2909 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2910 HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
2911 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
2912 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2913 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
2914 HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
2915 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
2916 PIN_CTL_TEST("Front Pin Mode", 0x14),
2917 PIN_CTL_TEST("Surround Pin Mode", 0x15),
2918 PIN_CTL_TEST("CLFE Pin Mode", 0x16),
2919 PIN_CTL_TEST("Side Pin Mode", 0x17),
2920 PIN_CTL_TEST("In-1 Pin Mode", 0x18),
2921 PIN_CTL_TEST("In-2 Pin Mode", 0x19),
2922 PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
2923 PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
2924 PIN_SRC_TEST("In-1 Pin Source", 0x18),
2925 PIN_SRC_TEST("In-2 Pin Source", 0x19),
2926 PIN_SRC_TEST("In-3 Pin Source", 0x1a),
2927 PIN_SRC_TEST("In-4 Pin Source", 0x1b),
2928 HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
2929 HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
2930 HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
2931 HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
2932 HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
2933 HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
2934 HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
2935 HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
2936 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
2937 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
2939 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2940 .name = "Channel Mode",
2941 .info = alc_ch_mode_info,
2942 .get = alc_ch_mode_get,
2943 .put = alc_ch_mode_put,
2948 static struct hda_verb alc880_test_init_verbs[] = {
2949 /* Unmute inputs of 0x0c - 0x0f */
2950 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2951 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2952 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2953 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2954 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2955 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2956 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2957 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2958 /* Vol output for 0x0c-0x0f */
2959 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2960 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2961 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2962 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2963 /* Set output pins 0x14-0x17 */
2964 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2965 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2966 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2967 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2968 /* Unmute output pins 0x14-0x17 */
2969 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2970 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2971 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2972 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2973 /* Set input pins 0x18-0x1c */
2974 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2975 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2976 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2977 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2978 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2979 /* Mute input pins 0x18-0x1b */
2980 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2981 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2982 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2983 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2985 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2986 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
2987 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2988 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
2989 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2990 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
2991 /* Analog input/passthru */
2992 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2993 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2994 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
2995 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
2996 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
3004 static const char *alc880_models[ALC880_MODEL_LAST] = {
3005 [ALC880_3ST] = "3stack",
3006 [ALC880_TCL_S700] = "tcl",
3007 [ALC880_3ST_DIG] = "3stack-digout",
3008 [ALC880_CLEVO] = "clevo",
3009 [ALC880_5ST] = "5stack",
3010 [ALC880_5ST_DIG] = "5stack-digout",
3011 [ALC880_W810] = "w810",
3012 [ALC880_Z71V] = "z71v",
3013 [ALC880_6ST] = "6stack",
3014 [ALC880_6ST_DIG] = "6stack-digout",
3015 [ALC880_ASUS] = "asus",
3016 [ALC880_ASUS_W1V] = "asus-w1v",
3017 [ALC880_ASUS_DIG] = "asus-dig",
3018 [ALC880_ASUS_DIG2] = "asus-dig2",
3019 [ALC880_UNIWILL_DIG] = "uniwill",
3020 [ALC880_UNIWILL_P53] = "uniwill-p53",
3021 [ALC880_FUJITSU] = "fujitsu",
3022 [ALC880_F1734] = "F1734",
3024 [ALC880_LG_LW] = "lg-lw",
3025 [ALC880_MEDION_RIM] = "medion",
3026 #ifdef CONFIG_SND_DEBUG
3027 [ALC880_TEST] = "test",
3029 [ALC880_AUTO] = "auto",
3032 static struct snd_pci_quirk alc880_cfg_tbl[] = {
3033 SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_W810),
3034 SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_5ST_DIG),
3035 SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_6ST),
3036 SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_3ST_DIG),
3037 SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_6ST_DIG),
3038 SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_6ST_DIG),
3039 SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_6ST_DIG),
3040 SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_3ST_DIG),
3041 SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_3ST),
3042 SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_6ST_DIG),
3043 SND_PCI_QUIRK(0x103c, 0x2a09, "HP", ALC880_5ST),
3044 SND_PCI_QUIRK(0x1043, 0x10b3, "ASUS W1V", ALC880_ASUS_W1V),
3045 SND_PCI_QUIRK(0x1043, 0x10c2, "ASUS W6A", ALC880_ASUS_DIG),
3046 SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS Wxx", ALC880_ASUS_DIG),
3047 SND_PCI_QUIRK(0x1043, 0x1113, "ASUS", ALC880_ASUS_DIG),
3048 SND_PCI_QUIRK(0x1043, 0x1123, "ASUS", ALC880_ASUS_DIG),
3049 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS", ALC880_ASUS_DIG),
3050 SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_Z71V),
3051 /* SND_PCI_QUIRK(0x1043, 0x1964, "ASUS", ALC880_ASUS_DIG), */
3052 SND_PCI_QUIRK(0x1043, 0x1973, "ASUS", ALC880_ASUS_DIG),
3053 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS", ALC880_ASUS_DIG),
3054 SND_PCI_QUIRK(0x1043, 0x814e, "ASUS P5GD1 w/SPDIF", ALC880_6ST_DIG),
3055 SND_PCI_QUIRK(0x1043, 0x8181, "ASUS P4GPL", ALC880_ASUS_DIG),
3056 SND_PCI_QUIRK(0x1043, 0x8196, "ASUS P5GD1", ALC880_6ST),
3057 SND_PCI_QUIRK(0x1043, 0x81b4, "ASUS", ALC880_6ST),
3058 SND_PCI_QUIRK(0x1043, 0, "ASUS", ALC880_ASUS), /* default ASUS */
3059 SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_3ST),
3060 SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_3ST),
3061 SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_5ST),
3062 SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_5ST),
3063 SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_5ST),
3064 SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_6ST_DIG),
3065 SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_6ST_DIG),
3066 SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_6ST_DIG),
3067 SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_6ST_DIG),
3068 SND_PCI_QUIRK(0x1558, 0x0520, "Clevo m520G", ALC880_CLEVO),
3069 SND_PCI_QUIRK(0x1558, 0x0660, "Clevo m655n", ALC880_CLEVO),
3070 SND_PCI_QUIRK(0x1558, 0x5401, "ASUS", ALC880_ASUS_DIG2),
3071 SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_5ST_DIG),
3072 SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_UNIWILL_DIG),
3073 SND_PCI_QUIRK(0x1584, 0x9054, "Uniwlll", ALC880_F1734),
3074 SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_UNIWILL),
3075 SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_UNIWILL_P53),
3076 SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_W810),
3077 SND_PCI_QUIRK(0x161f, 0x205d, "Medion Rim 2150", ALC880_MEDION_RIM),
3078 SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_5ST_DIG),
3079 SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_5ST_DIG),
3080 SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_F1734),
3081 SND_PCI_QUIRK(0x1734, 0x1094, "FSC Amilo M1451G", ALC880_FUJITSU),
3082 SND_PCI_QUIRK(0x1734, 0x10ac, "FSC", ALC880_UNIWILL),
3083 SND_PCI_QUIRK(0x1734, 0x10b0, "Fujitsu", ALC880_FUJITSU),
3084 SND_PCI_QUIRK(0x1854, 0x0018, "LG LW20", ALC880_LG_LW),
3085 SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_LG),
3086 SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_LG),
3087 SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_LG_LW),
3088 SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_TCL_S700),
3089 SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_6ST_DIG), /* broken BIOS */
3090 SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_6ST_DIG),
3091 SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_5ST_DIG),
3092 SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_5ST_DIG),
3093 SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_5ST_DIG),
3094 SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_3ST_DIG),
3095 SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_5ST_DIG),
3096 SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_3ST_DIG),
3097 SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_3ST_DIG),
3098 SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_5ST_DIG),
3099 SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_5ST_DIG),
3100 SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_5ST_DIG),
3101 SND_PCI_QUIRK(0x8086, 0, "Intel mobo", ALC880_3ST), /* default Intel */
3102 SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_5ST_DIG),
3103 SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_6ST_DIG),
3108 * ALC880 codec presets
3110 static struct alc_config_preset alc880_presets[] = {
3112 .mixers = { alc880_three_stack_mixer },
3113 .init_verbs = { alc880_volume_init_verbs,
3114 alc880_pin_3stack_init_verbs },
3115 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3116 .dac_nids = alc880_dac_nids,
3117 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3118 .channel_mode = alc880_threestack_modes,
3120 .input_mux = &alc880_capture_source,
3122 [ALC880_3ST_DIG] = {
3123 .mixers = { alc880_three_stack_mixer },
3124 .init_verbs = { alc880_volume_init_verbs,
3125 alc880_pin_3stack_init_verbs },
3126 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3127 .dac_nids = alc880_dac_nids,
3128 .dig_out_nid = ALC880_DIGOUT_NID,
3129 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3130 .channel_mode = alc880_threestack_modes,
3132 .input_mux = &alc880_capture_source,
3134 [ALC880_TCL_S700] = {
3135 .mixers = { alc880_tcl_s700_mixer },
3136 .init_verbs = { alc880_volume_init_verbs,
3137 alc880_pin_tcl_S700_init_verbs,
3138 alc880_gpio2_init_verbs },
3139 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3140 .dac_nids = alc880_dac_nids,
3142 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3143 .channel_mode = alc880_2_jack_modes,
3144 .input_mux = &alc880_capture_source,
3147 .mixers = { alc880_three_stack_mixer,
3148 alc880_five_stack_mixer},
3149 .init_verbs = { alc880_volume_init_verbs,
3150 alc880_pin_5stack_init_verbs },
3151 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3152 .dac_nids = alc880_dac_nids,
3153 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
3154 .channel_mode = alc880_fivestack_modes,
3155 .input_mux = &alc880_capture_source,
3157 [ALC880_5ST_DIG] = {
3158 .mixers = { alc880_three_stack_mixer,
3159 alc880_five_stack_mixer },
3160 .init_verbs = { alc880_volume_init_verbs,
3161 alc880_pin_5stack_init_verbs },
3162 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3163 .dac_nids = alc880_dac_nids,
3164 .dig_out_nid = ALC880_DIGOUT_NID,
3165 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
3166 .channel_mode = alc880_fivestack_modes,
3167 .input_mux = &alc880_capture_source,
3170 .mixers = { alc880_six_stack_mixer },
3171 .init_verbs = { alc880_volume_init_verbs,
3172 alc880_pin_6stack_init_verbs },
3173 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
3174 .dac_nids = alc880_6st_dac_nids,
3175 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
3176 .channel_mode = alc880_sixstack_modes,
3177 .input_mux = &alc880_6stack_capture_source,
3179 [ALC880_6ST_DIG] = {
3180 .mixers = { alc880_six_stack_mixer },
3181 .init_verbs = { alc880_volume_init_verbs,
3182 alc880_pin_6stack_init_verbs },
3183 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
3184 .dac_nids = alc880_6st_dac_nids,
3185 .dig_out_nid = ALC880_DIGOUT_NID,
3186 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
3187 .channel_mode = alc880_sixstack_modes,
3188 .input_mux = &alc880_6stack_capture_source,
3191 .mixers = { alc880_w810_base_mixer },
3192 .init_verbs = { alc880_volume_init_verbs,
3193 alc880_pin_w810_init_verbs,
3194 alc880_gpio2_init_verbs },
3195 .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
3196 .dac_nids = alc880_w810_dac_nids,
3197 .dig_out_nid = ALC880_DIGOUT_NID,
3198 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
3199 .channel_mode = alc880_w810_modes,
3200 .input_mux = &alc880_capture_source,
3203 .mixers = { alc880_z71v_mixer },
3204 .init_verbs = { alc880_volume_init_verbs,
3205 alc880_pin_z71v_init_verbs },
3206 .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
3207 .dac_nids = alc880_z71v_dac_nids,
3208 .dig_out_nid = ALC880_DIGOUT_NID,
3210 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3211 .channel_mode = alc880_2_jack_modes,
3212 .input_mux = &alc880_capture_source,
3215 .mixers = { alc880_f1734_mixer },
3216 .init_verbs = { alc880_volume_init_verbs,
3217 alc880_pin_f1734_init_verbs },
3218 .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
3219 .dac_nids = alc880_f1734_dac_nids,
3221 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3222 .channel_mode = alc880_2_jack_modes,
3223 .input_mux = &alc880_f1734_capture_source,
3224 .unsol_event = alc880_uniwill_p53_unsol_event,
3225 .init_hook = alc880_uniwill_p53_hp_automute,
3228 .mixers = { alc880_asus_mixer },
3229 .init_verbs = { alc880_volume_init_verbs,
3230 alc880_pin_asus_init_verbs,
3231 alc880_gpio1_init_verbs },
3232 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3233 .dac_nids = alc880_asus_dac_nids,
3234 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3235 .channel_mode = alc880_asus_modes,
3237 .input_mux = &alc880_capture_source,
3239 [ALC880_ASUS_DIG] = {
3240 .mixers = { alc880_asus_mixer },
3241 .init_verbs = { alc880_volume_init_verbs,
3242 alc880_pin_asus_init_verbs,
3243 alc880_gpio1_init_verbs },
3244 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3245 .dac_nids = alc880_asus_dac_nids,
3246 .dig_out_nid = ALC880_DIGOUT_NID,
3247 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3248 .channel_mode = alc880_asus_modes,
3250 .input_mux = &alc880_capture_source,
3252 [ALC880_ASUS_DIG2] = {
3253 .mixers = { alc880_asus_mixer },
3254 .init_verbs = { alc880_volume_init_verbs,
3255 alc880_pin_asus_init_verbs,
3256 alc880_gpio2_init_verbs }, /* use GPIO2 */
3257 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3258 .dac_nids = alc880_asus_dac_nids,
3259 .dig_out_nid = ALC880_DIGOUT_NID,
3260 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3261 .channel_mode = alc880_asus_modes,
3263 .input_mux = &alc880_capture_source,
3265 [ALC880_ASUS_W1V] = {
3266 .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
3267 .init_verbs = { alc880_volume_init_verbs,
3268 alc880_pin_asus_init_verbs,
3269 alc880_gpio1_init_verbs },
3270 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3271 .dac_nids = alc880_asus_dac_nids,
3272 .dig_out_nid = ALC880_DIGOUT_NID,
3273 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3274 .channel_mode = alc880_asus_modes,
3276 .input_mux = &alc880_capture_source,
3278 [ALC880_UNIWILL_DIG] = {
3279 .mixers = { alc880_asus_mixer, alc880_pcbeep_mixer },
3280 .init_verbs = { alc880_volume_init_verbs,
3281 alc880_pin_asus_init_verbs },
3282 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3283 .dac_nids = alc880_asus_dac_nids,
3284 .dig_out_nid = ALC880_DIGOUT_NID,
3285 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3286 .channel_mode = alc880_asus_modes,
3288 .input_mux = &alc880_capture_source,
3290 [ALC880_UNIWILL] = {
3291 .mixers = { alc880_uniwill_mixer },
3292 .init_verbs = { alc880_volume_init_verbs,
3293 alc880_uniwill_init_verbs },
3294 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3295 .dac_nids = alc880_asus_dac_nids,
3296 .dig_out_nid = ALC880_DIGOUT_NID,
3297 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3298 .channel_mode = alc880_threestack_modes,
3300 .input_mux = &alc880_capture_source,
3301 .unsol_event = alc880_uniwill_unsol_event,
3302 .init_hook = alc880_uniwill_automute,
3304 [ALC880_UNIWILL_P53] = {
3305 .mixers = { alc880_uniwill_p53_mixer },
3306 .init_verbs = { alc880_volume_init_verbs,
3307 alc880_uniwill_p53_init_verbs },
3308 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3309 .dac_nids = alc880_asus_dac_nids,
3310 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
3311 .channel_mode = alc880_threestack_modes,
3312 .input_mux = &alc880_capture_source,
3313 .unsol_event = alc880_uniwill_p53_unsol_event,
3314 .init_hook = alc880_uniwill_p53_hp_automute,
3316 [ALC880_FUJITSU] = {
3317 .mixers = { alc880_fujitsu_mixer,
3318 alc880_pcbeep_mixer, },
3319 .init_verbs = { alc880_volume_init_verbs,
3320 alc880_uniwill_p53_init_verbs,
3321 alc880_beep_init_verbs },
3322 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3323 .dac_nids = alc880_dac_nids,
3324 .dig_out_nid = ALC880_DIGOUT_NID,
3325 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3326 .channel_mode = alc880_2_jack_modes,
3327 .input_mux = &alc880_capture_source,
3328 .unsol_event = alc880_uniwill_p53_unsol_event,
3329 .init_hook = alc880_uniwill_p53_hp_automute,
3332 .mixers = { alc880_three_stack_mixer },
3333 .init_verbs = { alc880_volume_init_verbs,
3334 alc880_pin_clevo_init_verbs },
3335 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3336 .dac_nids = alc880_dac_nids,
3338 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3339 .channel_mode = alc880_threestack_modes,
3341 .input_mux = &alc880_capture_source,
3344 .mixers = { alc880_lg_mixer },
3345 .init_verbs = { alc880_volume_init_verbs,
3346 alc880_lg_init_verbs },
3347 .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids),
3348 .dac_nids = alc880_lg_dac_nids,
3349 .dig_out_nid = ALC880_DIGOUT_NID,
3350 .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes),
3351 .channel_mode = alc880_lg_ch_modes,
3353 .input_mux = &alc880_lg_capture_source,
3354 .unsol_event = alc880_lg_unsol_event,
3355 .init_hook = alc880_lg_automute,
3356 #ifdef CONFIG_SND_HDA_POWER_SAVE
3357 .loopbacks = alc880_lg_loopbacks,
3361 .mixers = { alc880_lg_lw_mixer },
3362 .init_verbs = { alc880_volume_init_verbs,
3363 alc880_lg_lw_init_verbs },
3364 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3365 .dac_nids = alc880_dac_nids,
3366 .dig_out_nid = ALC880_DIGOUT_NID,
3367 .num_channel_mode = ARRAY_SIZE(alc880_lg_lw_modes),
3368 .channel_mode = alc880_lg_lw_modes,
3369 .input_mux = &alc880_lg_lw_capture_source,
3370 .unsol_event = alc880_lg_lw_unsol_event,
3371 .init_hook = alc880_lg_lw_automute,
3373 [ALC880_MEDION_RIM] = {
3374 .mixers = { alc880_medion_rim_mixer },
3375 .init_verbs = { alc880_volume_init_verbs,
3376 alc880_medion_rim_init_verbs,
3377 alc_gpio2_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_medion_rim_capture_source,
3384 .unsol_event = alc880_medion_rim_unsol_event,
3385 .init_hook = alc880_medion_rim_automute,
3387 #ifdef CONFIG_SND_DEBUG
3389 .mixers = { alc880_test_mixer },
3390 .init_verbs = { alc880_test_init_verbs },
3391 .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
3392 .dac_nids = alc880_test_dac_nids,
3393 .dig_out_nid = ALC880_DIGOUT_NID,
3394 .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
3395 .channel_mode = alc880_test_modes,
3396 .input_mux = &alc880_test_capture_source,
3402 * Automatic parse of I/O pins from the BIOS configuration
3405 #define NUM_CONTROL_ALLOC 32
3406 #define NUM_VERB_ALLOC 32
3410 ALC_CTL_WIDGET_MUTE,
3413 static struct snd_kcontrol_new alc880_control_templates[] = {
3414 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
3415 HDA_CODEC_MUTE(NULL, 0, 0, 0),
3416 HDA_BIND_MUTE(NULL, 0, 0, 0),
3419 /* add dynamic controls */
3420 static int add_control(struct alc_spec *spec, int type, const char *name,
3423 struct snd_kcontrol_new *knew;
3425 if (spec->num_kctl_used >= spec->num_kctl_alloc) {
3426 int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC;
3428 /* array + terminator */
3429 knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL);
3432 if (spec->kctl_alloc) {
3433 memcpy(knew, spec->kctl_alloc,
3434 sizeof(*knew) * spec->num_kctl_alloc);
3435 kfree(spec->kctl_alloc);
3437 spec->kctl_alloc = knew;
3438 spec->num_kctl_alloc = num;
3441 knew = &spec->kctl_alloc[spec->num_kctl_used];
3442 *knew = alc880_control_templates[type];
3443 knew->name = kstrdup(name, GFP_KERNEL);
3446 knew->private_value = val;
3447 spec->num_kctl_used++;
3451 #define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
3452 #define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
3453 #define alc880_is_multi_pin(nid) ((nid) >= 0x18)
3454 #define alc880_multi_pin_idx(nid) ((nid) - 0x18)
3455 #define alc880_is_input_pin(nid) ((nid) >= 0x18)
3456 #define alc880_input_pin_idx(nid) ((nid) - 0x18)
3457 #define alc880_idx_to_dac(nid) ((nid) + 0x02)
3458 #define alc880_dac_to_idx(nid) ((nid) - 0x02)
3459 #define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
3460 #define alc880_idx_to_selector(nid) ((nid) + 0x10)
3461 #define ALC880_PIN_CD_NID 0x1c
3463 /* fill in the dac_nids table from the parsed pin configuration */
3464 static int alc880_auto_fill_dac_nids(struct alc_spec *spec,
3465 const struct auto_pin_cfg *cfg)
3471 memset(assigned, 0, sizeof(assigned));
3472 spec->multiout.dac_nids = spec->private_dac_nids;
3474 /* check the pins hardwired to audio widget */
3475 for (i = 0; i < cfg->line_outs; i++) {
3476 nid = cfg->line_out_pins[i];
3477 if (alc880_is_fixed_pin(nid)) {
3478 int idx = alc880_fixed_pin_idx(nid);
3479 spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
3483 /* left pins can be connect to any audio widget */
3484 for (i = 0; i < cfg->line_outs; i++) {
3485 nid = cfg->line_out_pins[i];
3486 if (alc880_is_fixed_pin(nid))
3488 /* search for an empty channel */
3489 for (j = 0; j < cfg->line_outs; j++) {
3491 spec->multiout.dac_nids[i] =
3492 alc880_idx_to_dac(j);
3498 spec->multiout.num_dacs = cfg->line_outs;
3502 /* add playback controls from the parsed DAC table */
3503 static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
3504 const struct auto_pin_cfg *cfg)
3507 static const char *chname[4] = {
3508 "Front", "Surround", NULL /*CLFE*/, "Side"
3513 for (i = 0; i < cfg->line_outs; i++) {
3514 if (!spec->multiout.dac_nids[i])
3516 nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
3519 err = add_control(spec, ALC_CTL_WIDGET_VOL,
3520 "Center Playback Volume",
3521 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
3525 err = add_control(spec, ALC_CTL_WIDGET_VOL,
3526 "LFE Playback Volume",
3527 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
3531 err = add_control(spec, ALC_CTL_BIND_MUTE,
3532 "Center Playback Switch",
3533 HDA_COMPOSE_AMP_VAL(nid, 1, 2,
3537 err = add_control(spec, ALC_CTL_BIND_MUTE,
3538 "LFE Playback Switch",
3539 HDA_COMPOSE_AMP_VAL(nid, 2, 2,
3544 sprintf(name, "%s Playback Volume", chname[i]);
3545 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
3546 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
3550 sprintf(name, "%s Playback Switch", chname[i]);
3551 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
3552 HDA_COMPOSE_AMP_VAL(nid, 3, 2,
3561 /* add playback controls for speaker and HP outputs */
3562 static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
3572 if (alc880_is_fixed_pin(pin)) {
3573 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
3574 /* specify the DAC as the extra output */
3575 if (!spec->multiout.hp_nid)
3576 spec->multiout.hp_nid = nid;
3578 spec->multiout.extra_out_nid[0] = nid;
3579 /* control HP volume/switch on the output mixer amp */
3580 nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
3581 sprintf(name, "%s Playback Volume", pfx);
3582 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
3583 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
3586 sprintf(name, "%s Playback Switch", pfx);
3587 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
3588 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
3591 } else if (alc880_is_multi_pin(pin)) {
3592 /* set manual connection */
3593 /* we have only a switch on HP-out PIN */
3594 sprintf(name, "%s Playback Switch", pfx);
3595 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
3596 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
3603 /* create input playback/capture controls for the given pin */
3604 static int new_analog_input(struct alc_spec *spec, hda_nid_t pin,
3605 const char *ctlname,
3606 int idx, hda_nid_t mix_nid)
3611 sprintf(name, "%s Playback Volume", ctlname);
3612 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
3613 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
3616 sprintf(name, "%s Playback Switch", ctlname);
3617 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
3618 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
3624 /* create playback/capture controls for input pins */
3625 static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec,
3626 const struct auto_pin_cfg *cfg)
3628 struct hda_input_mux *imux = &spec->private_imux;
3631 for (i = 0; i < AUTO_PIN_LAST; i++) {
3632 if (alc880_is_input_pin(cfg->input_pins[i])) {
3633 idx = alc880_input_pin_idx(cfg->input_pins[i]);
3634 err = new_analog_input(spec, cfg->input_pins[i],
3635 auto_pin_cfg_labels[i],
3639 imux->items[imux->num_items].label =
3640 auto_pin_cfg_labels[i];
3641 imux->items[imux->num_items].index =
3642 alc880_input_pin_idx(cfg->input_pins[i]);
3649 static void alc_set_pin_output(struct hda_codec *codec, hda_nid_t nid,
3650 unsigned int pin_type)
3652 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
3655 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
3659 static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
3660 hda_nid_t nid, int pin_type,
3663 alc_set_pin_output(codec, nid, pin_type);
3664 /* need the manual connection? */
3665 if (alc880_is_multi_pin(nid)) {
3666 struct alc_spec *spec = codec->spec;
3667 int idx = alc880_multi_pin_idx(nid);
3668 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
3669 AC_VERB_SET_CONNECT_SEL,
3670 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
3674 static int get_pin_type(int line_out_type)
3676 if (line_out_type == AUTO_PIN_HP_OUT)
3682 static void alc880_auto_init_multi_out(struct hda_codec *codec)
3684 struct alc_spec *spec = codec->spec;
3687 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
3688 for (i = 0; i < spec->autocfg.line_outs; i++) {
3689 hda_nid_t nid = spec->autocfg.line_out_pins[i];
3690 int pin_type = get_pin_type(spec->autocfg.line_out_type);
3691 alc880_auto_set_output_and_unmute(codec, nid, pin_type, i);
3695 static void alc880_auto_init_extra_out(struct hda_codec *codec)
3697 struct alc_spec *spec = codec->spec;
3700 pin = spec->autocfg.speaker_pins[0];
3701 if (pin) /* connect to front */
3702 alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
3703 pin = spec->autocfg.hp_pins[0];
3704 if (pin) /* connect to front */
3705 alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
3708 static void alc880_auto_init_analog_input(struct hda_codec *codec)
3710 struct alc_spec *spec = codec->spec;
3713 for (i = 0; i < AUTO_PIN_LAST; i++) {
3714 hda_nid_t nid = spec->autocfg.input_pins[i];
3715 if (alc880_is_input_pin(nid)) {
3716 snd_hda_codec_write(codec, nid, 0,
3717 AC_VERB_SET_PIN_WIDGET_CONTROL,
3718 i <= AUTO_PIN_FRONT_MIC ?
3719 PIN_VREF80 : PIN_IN);
3720 if (nid != ALC880_PIN_CD_NID)
3721 snd_hda_codec_write(codec, nid, 0,
3722 AC_VERB_SET_AMP_GAIN_MUTE,
3728 /* parse the BIOS configuration and set up the alc_spec */
3729 /* return 1 if successful, 0 if the proper config is not found,
3730 * or a negative error code
3732 static int alc880_parse_auto_config(struct hda_codec *codec)
3734 struct alc_spec *spec = codec->spec;
3736 static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
3738 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
3742 if (!spec->autocfg.line_outs)
3743 return 0; /* can't find valid BIOS pin config */
3745 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
3748 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
3751 err = alc880_auto_create_extra_out(spec,
3752 spec->autocfg.speaker_pins[0],
3756 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
3760 err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
3764 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
3766 if (spec->autocfg.dig_out_pin)
3767 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
3768 if (spec->autocfg.dig_in_pin)
3769 spec->dig_in_nid = ALC880_DIGIN_NID;
3771 if (spec->kctl_alloc)
3772 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
3774 spec->init_verbs[spec->num_init_verbs++] = alc880_volume_init_verbs;
3776 spec->num_mux_defs = 1;
3777 spec->input_mux = &spec->private_imux;
3782 /* additional initialization for auto-configuration model */
3783 static void alc880_auto_init(struct hda_codec *codec)
3785 struct alc_spec *spec = codec->spec;
3786 alc880_auto_init_multi_out(codec);
3787 alc880_auto_init_extra_out(codec);
3788 alc880_auto_init_analog_input(codec);
3789 if (spec->unsol_event)
3790 alc_sku_automute(codec);
3794 * OK, here we have finally the patch for ALC880
3797 static int patch_alc880(struct hda_codec *codec)
3799 struct alc_spec *spec;
3803 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
3809 board_config = snd_hda_check_board_config(codec, ALC880_MODEL_LAST,
3812 if (board_config < 0) {
3813 printk(KERN_INFO "hda_codec: Unknown model for ALC880, "
3814 "trying auto-probe from BIOS...\n");
3815 board_config = ALC880_AUTO;
3818 if (board_config == ALC880_AUTO) {
3819 /* automatic parse from the BIOS config */
3820 err = alc880_parse_auto_config(codec);
3826 "hda_codec: Cannot set up configuration "
3827 "from BIOS. Using 3-stack mode...\n");
3828 board_config = ALC880_3ST;
3832 if (board_config != ALC880_AUTO)
3833 setup_preset(spec, &alc880_presets[board_config]);
3835 spec->stream_name_analog = "ALC880 Analog";
3836 spec->stream_analog_playback = &alc880_pcm_analog_playback;
3837 spec->stream_analog_capture = &alc880_pcm_analog_capture;
3838 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
3840 spec->stream_name_digital = "ALC880 Digital";
3841 spec->stream_digital_playback = &alc880_pcm_digital_playback;
3842 spec->stream_digital_capture = &alc880_pcm_digital_capture;
3844 if (!spec->adc_nids && spec->input_mux) {
3845 /* check whether NID 0x07 is valid */
3846 unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
3848 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
3849 if (wcap != AC_WID_AUD_IN) {
3850 spec->adc_nids = alc880_adc_nids_alt;
3851 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
3852 spec->mixers[spec->num_mixers] =
3853 alc880_capture_alt_mixer;
3856 spec->adc_nids = alc880_adc_nids;
3857 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
3858 spec->mixers[spec->num_mixers] = alc880_capture_mixer;
3863 spec->vmaster_nid = 0x0c;
3865 codec->patch_ops = alc_patch_ops;
3866 if (board_config == ALC880_AUTO)
3867 spec->init_hook = alc880_auto_init;
3868 #ifdef CONFIG_SND_HDA_POWER_SAVE
3869 if (!spec->loopback.amplist)
3870 spec->loopback.amplist = alc880_loopbacks;
3881 static hda_nid_t alc260_dac_nids[1] = {
3886 static hda_nid_t alc260_adc_nids[1] = {
3891 static hda_nid_t alc260_adc_nids_alt[1] = {
3896 static hda_nid_t alc260_hp_adc_nids[2] = {
3901 /* NIDs used when simultaneous access to both ADCs makes sense. Note that
3902 * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
3904 static hda_nid_t alc260_dual_adc_nids[2] = {
3909 #define ALC260_DIGOUT_NID 0x03
3910 #define ALC260_DIGIN_NID 0x06
3912 static struct hda_input_mux alc260_capture_source = {
3916 { "Front Mic", 0x1 },
3922 /* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
3923 * headphone jack and the internal CD lines since these are the only pins at
3924 * which audio can appear. For flexibility, also allow the option of
3925 * recording the mixer output on the second ADC (ADC0 doesn't have a
3926 * connection to the mixer output).
3928 static struct hda_input_mux alc260_fujitsu_capture_sources[2] = {
3932 { "Mic/Line", 0x0 },
3934 { "Headphone", 0x2 },
3940 { "Mic/Line", 0x0 },
3942 { "Headphone", 0x2 },
3949 /* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to
3950 * the Fujitsu S702x, but jacks are marked differently.
3952 static struct hda_input_mux alc260_acer_capture_sources[2] = {
3959 { "Headphone", 0x5 },
3968 { "Headphone", 0x6 },
3974 * This is just place-holder, so there's something for alc_build_pcms to look
3975 * at when it calculates the maximum number of channels. ALC260 has no mixer
3976 * element which allows changing the channel mode, so the verb list is
3979 static struct hda_channel_mode alc260_modes[1] = {
3984 /* Mixer combinations
3986 * basic: base_output + input + pc_beep + capture
3987 * HP: base_output + input + capture_alt
3988 * HP_3013: hp_3013 + input + capture
3989 * fujitsu: fujitsu + capture
3990 * acer: acer + capture
3993 static struct snd_kcontrol_new alc260_base_output_mixer[] = {
3994 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3995 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
3996 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
3997 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
3998 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
3999 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
4003 static struct snd_kcontrol_new alc260_input_mixer[] = {
4004 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4005 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4006 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
4007 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
4008 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4009 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4010 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
4011 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
4015 static struct snd_kcontrol_new alc260_pc_beep_mixer[] = {
4016 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x07, 0x05, HDA_INPUT),
4017 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x07, 0x05, HDA_INPUT),
4021 /* update HP, line and mono out pins according to the master switch */
4022 static void alc260_hp_master_update(struct hda_codec *codec,
4023 hda_nid_t hp, hda_nid_t line,
4026 struct alc_spec *spec = codec->spec;
4027 unsigned int val = spec->master_sw ? PIN_HP : 0;
4028 /* change HP and line-out pins */
4029 snd_hda_codec_write(codec, 0x0f, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4031 snd_hda_codec_write(codec, 0x10, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4033 /* mono (speaker) depending on the HP jack sense */
4034 val = (val && !spec->jack_present) ? PIN_OUT : 0;
4035 snd_hda_codec_write(codec, 0x11, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4039 static int alc260_hp_master_sw_get(struct snd_kcontrol *kcontrol,
4040 struct snd_ctl_elem_value *ucontrol)
4042 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4043 struct alc_spec *spec = codec->spec;
4044 *ucontrol->value.integer.value = spec->master_sw;
4048 static int alc260_hp_master_sw_put(struct snd_kcontrol *kcontrol,
4049 struct snd_ctl_elem_value *ucontrol)
4051 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4052 struct alc_spec *spec = codec->spec;
4053 int val = !!*ucontrol->value.integer.value;
4054 hda_nid_t hp, line, mono;
4056 if (val == spec->master_sw)
4058 spec->master_sw = val;
4059 hp = (kcontrol->private_value >> 16) & 0xff;
4060 line = (kcontrol->private_value >> 8) & 0xff;
4061 mono = kcontrol->private_value & 0xff;
4062 alc260_hp_master_update(codec, hp, line, mono);
4066 static struct snd_kcontrol_new alc260_hp_output_mixer[] = {
4068 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4069 .name = "Master Playback Switch",
4070 .info = snd_ctl_boolean_mono_info,
4071 .get = alc260_hp_master_sw_get,
4072 .put = alc260_hp_master_sw_put,
4073 .private_value = (0x0f << 16) | (0x10 << 8) | 0x11
4075 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4076 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
4077 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4078 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
4079 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
4081 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2, HDA_INPUT),
4085 static struct hda_verb alc260_hp_unsol_verbs[] = {
4086 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
4090 static void alc260_hp_automute(struct hda_codec *codec)
4092 struct alc_spec *spec = codec->spec;
4093 unsigned int present;
4095 present = snd_hda_codec_read(codec, 0x10, 0,
4096 AC_VERB_GET_PIN_SENSE, 0);
4097 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
4098 alc260_hp_master_update(codec, 0x0f, 0x10, 0x11);
4101 static void alc260_hp_unsol_event(struct hda_codec *codec, unsigned int res)
4103 if ((res >> 26) == ALC880_HP_EVENT)
4104 alc260_hp_automute(codec);
4107 static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
4109 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4110 .name = "Master Playback Switch",
4111 .info = snd_ctl_boolean_mono_info,
4112 .get = alc260_hp_master_sw_get,
4113 .put = alc260_hp_master_sw_put,
4114 .private_value = (0x10 << 16) | (0x15 << 8) | 0x11
4116 HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4117 HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
4118 HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
4119 HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
4120 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4121 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
4122 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
4123 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
4127 static struct hda_verb alc260_hp_3013_unsol_verbs[] = {
4128 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
4132 static void alc260_hp_3013_automute(struct hda_codec *codec)
4134 struct alc_spec *spec = codec->spec;
4135 unsigned int present;
4137 present = snd_hda_codec_read(codec, 0x15, 0,
4138 AC_VERB_GET_PIN_SENSE, 0);
4139 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
4140 alc260_hp_master_update(codec, 0x10, 0x15, 0x11);
4143 static void alc260_hp_3013_unsol_event(struct hda_codec *codec,
4146 if ((res >> 26) == ALC880_HP_EVENT)
4147 alc260_hp_3013_automute(codec);
4150 /* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12,
4151 * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10.
4153 static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
4154 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4155 HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
4156 ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
4157 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4158 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4159 HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
4160 HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
4161 ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
4162 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
4163 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
4164 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4165 HDA_BIND_MUTE("Speaker Playback Switch", 0x09, 2, HDA_INPUT),
4169 /* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current
4170 * versions of the ALC260 don't act on requests to enable mic bias from NID
4171 * 0x0f (used to drive the headphone jack in these laptops). The ALC260
4172 * datasheet doesn't mention this restriction. At this stage it's not clear
4173 * whether this behaviour is intentional or is a hardware bug in chip
4174 * revisions available in early 2006. Therefore for now allow the
4175 * "Headphone Jack Mode" control to span all choices, but if it turns out
4176 * that the lack of mic bias for this NID is intentional we could change the
4177 * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
4179 * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006
4180 * don't appear to make the mic bias available from the "line" jack, even
4181 * though the NID used for this jack (0x14) can supply it. The theory is
4182 * that perhaps Acer have included blocking capacitors between the ALC260
4183 * and the output jack. If this turns out to be the case for all such
4184 * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
4185 * to ALC_PIN_DIR_INOUT_NOMICBIAS.
4187 * The C20x Tablet series have a mono internal speaker which is controlled
4188 * via the chip's Mono sum widget and pin complex, so include the necessary
4189 * controls for such models. On models without a "mono speaker" the control
4190 * won't do anything.
4192 static struct snd_kcontrol_new alc260_acer_mixer[] = {
4193 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4194 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
4195 ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
4196 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
4198 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2,
4200 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4201 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4202 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4203 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4204 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
4205 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
4206 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
4207 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
4208 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
4209 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
4213 /* Packard bell V7900 ALC260 pin usage: HP = 0x0f, Mic jack = 0x12,
4214 * Line In jack = 0x14, CD audio = 0x16, pc beep = 0x17.
4216 static struct snd_kcontrol_new alc260_will_mixer[] = {
4217 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4218 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
4219 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4220 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4221 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
4222 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
4223 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
4224 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
4225 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4226 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4227 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
4228 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
4232 /* Replacer 672V ALC260 pin usage: Mic jack = 0x12,
4233 * Line In jack = 0x14, ATAPI Mic = 0x13, speaker = 0x0f.
4235 static struct snd_kcontrol_new alc260_replacer_672v_mixer[] = {
4236 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4237 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
4238 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4239 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4240 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
4241 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x07, 0x1, HDA_INPUT),
4242 HDA_CODEC_MUTE("ATATI Mic Playback Switch", 0x07, 0x1, HDA_INPUT),
4243 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
4244 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
4245 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
4249 /* capture mixer elements */
4250 static struct snd_kcontrol_new alc260_capture_mixer[] = {
4251 HDA_CODEC_VOLUME("Capture Volume", 0x04, 0x0, HDA_INPUT),
4252 HDA_CODEC_MUTE("Capture Switch", 0x04, 0x0, HDA_INPUT),
4253 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x05, 0x0, HDA_INPUT),
4254 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x05, 0x0, HDA_INPUT),
4256 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4257 /* The multiple "Capture Source" controls confuse alsamixer
4258 * So call somewhat different..
4260 /* .name = "Capture Source", */
4261 .name = "Input Source",
4263 .info = alc_mux_enum_info,
4264 .get = alc_mux_enum_get,
4265 .put = alc_mux_enum_put,
4270 static struct snd_kcontrol_new alc260_capture_alt_mixer[] = {
4271 HDA_CODEC_VOLUME("Capture Volume", 0x05, 0x0, HDA_INPUT),
4272 HDA_CODEC_MUTE("Capture Switch", 0x05, 0x0, HDA_INPUT),
4274 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4275 /* The multiple "Capture Source" controls confuse alsamixer
4276 * So call somewhat different..
4278 /* .name = "Capture Source", */
4279 .name = "Input Source",
4281 .info = alc_mux_enum_info,
4282 .get = alc_mux_enum_get,
4283 .put = alc_mux_enum_put,
4289 * initialization verbs
4291 static struct hda_verb alc260_init_verbs[] = {
4292 /* Line In pin widget for input */
4293 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
4294 /* CD pin widget for input */
4295 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
4296 /* Mic1 (rear panel) pin widget for input and vref at 80% */
4297 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
4298 /* Mic2 (front panel) pin widget for input and vref at 80% */
4299 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
4300 /* LINE-2 is used for line-out in rear */
4301 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4302 /* select line-out */
4303 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
4305 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4307 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4309 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4310 /* mute capture amp left and right */
4311 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4312 /* set connection select to line in (default select for this ADC) */
4313 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
4314 /* mute capture amp left and right */
4315 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4316 /* set connection select to line in (default select for this ADC) */
4317 {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
4318 /* set vol=0 Line-Out mixer amp left and right */
4319 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4320 /* unmute pin widget amp left and right (no gain on this amp) */
4321 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4322 /* set vol=0 HP mixer amp left and right */
4323 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4324 /* unmute pin widget amp left and right (no gain on this amp) */
4325 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4326 /* set vol=0 Mono mixer amp left and right */
4327 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4328 /* unmute pin widget amp left and right (no gain on this amp) */
4329 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4330 /* unmute LINE-2 out pin */
4331 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4332 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
4335 /* mute analog inputs */
4336 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4337 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4338 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4339 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4340 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
4341 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
4342 /* mute Front out path */
4343 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4344 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4345 /* mute Headphone out path */
4346 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4347 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4348 /* mute Mono out path */
4349 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4350 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4354 #if 0 /* should be identical with alc260_init_verbs? */
4355 static struct hda_verb alc260_hp_init_verbs[] = {
4356 /* Headphone and output */
4357 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
4359 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
4360 /* Mic1 (rear panel) pin widget for input and vref at 80% */
4361 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
4362 /* Mic2 (front panel) pin widget for input and vref at 80% */
4363 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
4364 /* Line In pin widget for input */
4365 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
4366 /* Line-2 pin widget for output */
4367 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
4368 /* CD pin widget for input */
4369 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
4370 /* unmute amp left and right */
4371 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
4372 /* set connection select to line in (default select for this ADC) */
4373 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
4374 /* unmute Line-Out mixer amp left and right (volume = 0) */
4375 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
4376 /* mute pin widget amp left and right (no gain on this amp) */
4377 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
4378 /* unmute HP mixer amp left and right (volume = 0) */
4379 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
4380 /* mute pin widget amp left and right (no gain on this amp) */
4381 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
4382 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
4385 /* mute analog inputs */
4386 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4387 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4388 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4389 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4390 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
4391 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
4392 /* Unmute Front out path */
4393 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4394 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4395 /* Unmute Headphone out path */
4396 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4397 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4398 /* Unmute Mono out path */
4399 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4400 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4405 static struct hda_verb alc260_hp_3013_init_verbs[] = {
4406 /* Line out and output */
4407 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
4409 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
4410 /* Mic1 (rear panel) pin widget for input and vref at 80% */
4411 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
4412 /* Mic2 (front panel) pin widget for input and vref at 80% */
4413 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
4414 /* Line In pin widget for input */
4415 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
4416 /* Headphone pin widget for output */
4417 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
4418 /* CD pin widget for input */
4419 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
4420 /* unmute amp left and right */
4421 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
4422 /* set connection select to line in (default select for this ADC) */
4423 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
4424 /* unmute Line-Out mixer amp left and right (volume = 0) */
4425 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
4426 /* mute pin widget amp left and right (no gain on this amp) */
4427 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
4428 /* unmute HP mixer amp left and right (volume = 0) */
4429 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
4430 /* mute pin widget amp left and right (no gain on this amp) */
4431 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
4432 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
4435 /* mute analog inputs */
4436 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4437 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4438 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4439 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4440 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
4441 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
4442 /* Unmute Front out path */
4443 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4444 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4445 /* Unmute Headphone out path */
4446 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4447 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4448 /* Unmute Mono out path */
4449 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4450 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4454 /* Initialisation sequence for ALC260 as configured in Fujitsu S702x
4455 * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD
4456 * audio = 0x16, internal speaker = 0x10.
4458 static struct hda_verb alc260_fujitsu_init_verbs[] = {
4459 /* Disable all GPIOs */
4460 {0x01, AC_VERB_SET_GPIO_MASK, 0},
4461 /* Internal speaker is connected to headphone pin */
4462 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4463 /* Headphone/Line-out jack connects to Line1 pin; make it an output */
4464 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4465 /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
4466 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
4467 /* Ensure all other unused pins are disabled and muted. */
4468 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
4469 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4470 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
4471 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4472 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
4473 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4474 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
4475 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4477 /* Disable digital (SPDIF) pins */
4478 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
4479 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
4481 /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
4482 * when acting as an output.
4484 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
4486 /* Start with output sum widgets muted and their output gains at min */
4487 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4488 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4489 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4490 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4491 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4492 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4493 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4494 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4495 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4497 /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
4498 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4499 /* Unmute Line1 pin widget output buffer since it starts as an output.
4500 * If the pin mode is changed by the user the pin mode control will
4501 * take care of enabling the pin's input/output buffers as needed.
4502 * Therefore there's no need to enable the input buffer at this
4505 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4506 /* Unmute input buffer of pin widget used for Line-in (no equiv
4509 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4511 /* Mute capture amp left and right */
4512 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4513 /* Set ADC connection select to match default mixer setting - line
4516 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
4518 /* Do the same for the second ADC: mute capture input amp and
4519 * set ADC connection to line in (on mic1 pin)
4521 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4522 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
4524 /* Mute all inputs to mixer widget (even unconnected ones) */
4525 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
4526 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
4527 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
4528 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
4529 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
4530 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
4531 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
4532 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
4537 /* Initialisation sequence for ALC260 as configured in Acer TravelMate and
4538 * similar laptops (adapted from Fujitsu init verbs).
4540 static struct hda_verb alc260_acer_init_verbs[] = {
4541 /* On TravelMate laptops, GPIO 0 enables the internal speaker and
4542 * the headphone jack. Turn this on and rely on the standard mute
4543 * methods whenever the user wants to turn these outputs off.
4545 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
4546 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
4547 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
4548 /* Internal speaker/Headphone jack is connected to Line-out pin */
4549 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4550 /* Internal microphone/Mic jack is connected to Mic1 pin */
4551 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
4552 /* Line In jack is connected to Line1 pin */
4553 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
4554 /* Some Acers (eg: C20x Tablets) use Mono pin for internal speaker */
4555 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4556 /* Ensure all other unused pins are disabled and muted. */
4557 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
4558 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4559 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
4560 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4561 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
4562 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4563 /* Disable digital (SPDIF) pins */
4564 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
4565 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
4567 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
4568 * bus when acting as outputs.
4570 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
4571 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
4573 /* Start with output sum widgets muted and their output gains at min */
4574 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4575 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4576 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4577 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4578 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4579 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4580 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4581 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4582 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4584 /* Unmute Line-out pin widget amp left and right
4585 * (no equiv mixer ctrl)
4587 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4588 /* Unmute mono pin widget amp output (no equiv mixer ctrl) */
4589 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4590 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
4591 * inputs. If the pin mode is changed by the user the pin mode control
4592 * will take care of enabling the pin's input/output buffers as needed.
4593 * Therefore there's no need to enable the input buffer at this
4596 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4597 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4599 /* Mute capture amp left and right */
4600 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4601 /* Set ADC connection select to match default mixer setting - mic
4604 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
4606 /* Do similar with the second ADC: mute capture input amp and
4607 * set ADC connection to mic to match ALSA's default state.
4609 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4610 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
4612 /* Mute all inputs to mixer widget (even unconnected ones) */
4613 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
4614 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
4615 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
4616 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
4617 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
4618 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
4619 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
4620 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
4625 static struct hda_verb alc260_will_verbs[] = {
4626 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4627 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x00},
4628 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
4629 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
4630 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
4631 {0x1a, AC_VERB_SET_PROC_COEF, 0x3040},
4635 static struct hda_verb alc260_replacer_672v_verbs[] = {
4636 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
4637 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
4638 {0x1a, AC_VERB_SET_PROC_COEF, 0x3050},
4640 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
4641 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
4642 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
4644 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
4648 /* toggle speaker-output according to the hp-jack state */
4649 static void alc260_replacer_672v_automute(struct hda_codec *codec)
4651 unsigned int present;
4653 /* speaker --> GPIO Data 0, hp or spdif --> GPIO data 1 */
4654 present = snd_hda_codec_read(codec, 0x0f, 0,
4655 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
4657 snd_hda_codec_write_cache(codec, 0x01, 0,
4658 AC_VERB_SET_GPIO_DATA, 1);
4659 snd_hda_codec_write_cache(codec, 0x0f, 0,
4660 AC_VERB_SET_PIN_WIDGET_CONTROL,
4663 snd_hda_codec_write_cache(codec, 0x01, 0,
4664 AC_VERB_SET_GPIO_DATA, 0);
4665 snd_hda_codec_write_cache(codec, 0x0f, 0,
4666 AC_VERB_SET_PIN_WIDGET_CONTROL,
4671 static void alc260_replacer_672v_unsol_event(struct hda_codec *codec,
4674 if ((res >> 26) == ALC880_HP_EVENT)
4675 alc260_replacer_672v_automute(codec);
4678 /* Test configuration for debugging, modelled after the ALC880 test
4681 #ifdef CONFIG_SND_DEBUG
4682 static hda_nid_t alc260_test_dac_nids[1] = {
4685 static hda_nid_t alc260_test_adc_nids[2] = {
4688 /* For testing the ALC260, each input MUX needs its own definition since
4689 * the signal assignments are different. This assumes that the first ADC
4692 static struct hda_input_mux alc260_test_capture_sources[2] = {
4696 { "MIC1 pin", 0x0 },
4697 { "MIC2 pin", 0x1 },
4698 { "LINE1 pin", 0x2 },
4699 { "LINE2 pin", 0x3 },
4701 { "LINE-OUT pin", 0x5 },
4702 { "HP-OUT pin", 0x6 },
4708 { "MIC1 pin", 0x0 },
4709 { "MIC2 pin", 0x1 },
4710 { "LINE1 pin", 0x2 },
4711 { "LINE2 pin", 0x3 },
4714 { "LINE-OUT pin", 0x6 },
4715 { "HP-OUT pin", 0x7 },
4719 static struct snd_kcontrol_new alc260_test_mixer[] = {
4720 /* Output driver widgets */
4721 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
4722 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
4723 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4724 HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
4725 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4726 HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
4728 /* Modes for retasking pin widgets
4729 * Note: the ALC260 doesn't seem to act on requests to enable mic
4730 * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't
4731 * mention this restriction. At this stage it's not clear whether
4732 * this behaviour is intentional or is a hardware bug in chip
4733 * revisions available at least up until early 2006. Therefore for
4734 * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all
4735 * choices, but if it turns out that the lack of mic bias for these
4736 * NIDs is intentional we could change their modes from
4737 * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
4739 ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
4740 ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
4741 ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
4742 ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
4743 ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
4744 ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
4746 /* Loopback mixer controls */
4747 HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
4748 HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
4749 HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
4750 HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
4751 HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
4752 HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
4753 HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
4754 HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
4755 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4756 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4757 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
4758 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
4759 HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
4760 HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
4761 HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
4762 HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
4764 /* Controls for GPIO pins, assuming they are configured as outputs */
4765 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
4766 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
4767 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
4768 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
4770 /* Switches to allow the digital IO pins to be enabled. The datasheet
4771 * is ambigious as to which NID is which; testing on laptops which
4772 * make this output available should provide clarification.
4774 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
4775 ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
4777 /* A switch allowing EAPD to be enabled. Some laptops seem to use
4778 * this output to turn on an external amplifier.
4780 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
4781 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
4785 static struct hda_verb alc260_test_init_verbs[] = {
4786 /* Enable all GPIOs as outputs with an initial value of 0 */
4787 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
4788 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
4789 {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
4791 /* Enable retasking pins as output, initially without power amp */
4792 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4793 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4794 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4795 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4796 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4797 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4799 /* Disable digital (SPDIF) pins initially, but users can enable
4800 * them via a mixer switch. In the case of SPDIF-out, this initverb
4801 * payload also sets the generation to 0, output to be in "consumer"
4802 * PCM format, copyright asserted, no pre-emphasis and no validity
4805 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
4806 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
4808 /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
4809 * OUT1 sum bus when acting as an output.
4811 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
4812 {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
4813 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
4814 {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
4816 /* Start with output sum widgets muted and their output gains at min */
4817 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4818 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4819 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4820 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4821 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4822 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4823 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4824 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4825 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4827 /* Unmute retasking pin widget output buffers since the default
4828 * state appears to be output. As the pin mode is changed by the
4829 * user the pin mode control will take care of enabling the pin's
4830 * input/output buffers as needed.
4832 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4833 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4834 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4835 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4836 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4837 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4838 /* Also unmute the mono-out pin widget */
4839 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4841 /* Mute capture amp left and right */
4842 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4843 /* Set ADC connection select to match default mixer setting (mic1
4846 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
4848 /* Do the same for the second ADC: mute capture input amp and
4849 * set ADC connection to mic1 pin
4851 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4852 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
4854 /* Mute all inputs to mixer widget (even unconnected ones) */
4855 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
4856 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
4857 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
4858 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
4859 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
4860 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
4861 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
4862 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
4868 #define alc260_pcm_analog_playback alc880_pcm_analog_alt_playback
4869 #define alc260_pcm_analog_capture alc880_pcm_analog_capture
4871 #define alc260_pcm_digital_playback alc880_pcm_digital_playback
4872 #define alc260_pcm_digital_capture alc880_pcm_digital_capture
4875 * for BIOS auto-configuration
4878 static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
4882 unsigned long vol_val, sw_val;
4886 if (nid >= 0x0f && nid < 0x11) {
4887 nid_vol = nid - 0x7;
4888 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
4889 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
4890 } else if (nid == 0x11) {
4891 nid_vol = nid - 0x7;
4892 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
4893 sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
4894 } else if (nid >= 0x12 && nid <= 0x15) {
4896 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
4897 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
4901 snprintf(name, sizeof(name), "%s Playback Volume", pfx);
4902 err = add_control(spec, ALC_CTL_WIDGET_VOL, name, vol_val);
4905 snprintf(name, sizeof(name), "%s Playback Switch", pfx);
4906 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, sw_val);
4912 /* add playback controls from the parsed DAC table */
4913 static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
4914 const struct auto_pin_cfg *cfg)
4919 spec->multiout.num_dacs = 1;
4920 spec->multiout.dac_nids = spec->private_dac_nids;
4921 spec->multiout.dac_nids[0] = 0x02;
4923 nid = cfg->line_out_pins[0];
4925 err = alc260_add_playback_controls(spec, nid, "Front");
4930 nid = cfg->speaker_pins[0];
4932 err = alc260_add_playback_controls(spec, nid, "Speaker");
4937 nid = cfg->hp_pins[0];
4939 err = alc260_add_playback_controls(spec, nid, "Headphone");
4946 /* create playback/capture controls for input pins */
4947 static int alc260_auto_create_analog_input_ctls(struct alc_spec *spec,
4948 const struct auto_pin_cfg *cfg)
4950 struct hda_input_mux *imux = &spec->private_imux;
4953 for (i = 0; i < AUTO_PIN_LAST; i++) {
4954 if (cfg->input_pins[i] >= 0x12) {
4955 idx = cfg->input_pins[i] - 0x12;
4956 err = new_analog_input(spec, cfg->input_pins[i],
4957 auto_pin_cfg_labels[i], idx,
4961 imux->items[imux->num_items].label =
4962 auto_pin_cfg_labels[i];
4963 imux->items[imux->num_items].index = idx;
4966 if (cfg->input_pins[i] >= 0x0f && cfg->input_pins[i] <= 0x10){
4967 idx = cfg->input_pins[i] - 0x09;
4968 err = new_analog_input(spec, cfg->input_pins[i],
4969 auto_pin_cfg_labels[i], idx,
4973 imux->items[imux->num_items].label =
4974 auto_pin_cfg_labels[i];
4975 imux->items[imux->num_items].index = idx;
4982 static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
4983 hda_nid_t nid, int pin_type,
4986 alc_set_pin_output(codec, nid, pin_type);
4987 /* need the manual connection? */
4989 int idx = nid - 0x12;
4990 snd_hda_codec_write(codec, idx + 0x0b, 0,
4991 AC_VERB_SET_CONNECT_SEL, sel_idx);
4995 static void alc260_auto_init_multi_out(struct hda_codec *codec)
4997 struct alc_spec *spec = codec->spec;
5000 alc_subsystem_id(codec, 0x10, 0x15, 0x0f);
5001 nid = spec->autocfg.line_out_pins[0];
5003 int pin_type = get_pin_type(spec->autocfg.line_out_type);
5004 alc260_auto_set_output_and_unmute(codec, nid, pin_type, 0);
5007 nid = spec->autocfg.speaker_pins[0];
5009 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
5011 nid = spec->autocfg.hp_pins[0];
5013 alc260_auto_set_output_and_unmute(codec, nid, PIN_HP, 0);
5016 #define ALC260_PIN_CD_NID 0x16
5017 static void alc260_auto_init_analog_input(struct hda_codec *codec)
5019 struct alc_spec *spec = codec->spec;
5022 for (i = 0; i < AUTO_PIN_LAST; i++) {
5023 hda_nid_t nid = spec->autocfg.input_pins[i];
5025 snd_hda_codec_write(codec, nid, 0,
5026 AC_VERB_SET_PIN_WIDGET_CONTROL,
5027 i <= AUTO_PIN_FRONT_MIC ?
5028 PIN_VREF80 : PIN_IN);
5029 if (nid != ALC260_PIN_CD_NID)
5030 snd_hda_codec_write(codec, nid, 0,
5031 AC_VERB_SET_AMP_GAIN_MUTE,
5038 * generic initialization of ADC, input mixers and output mixers
5040 static struct hda_verb alc260_volume_init_verbs[] = {
5042 * Unmute ADC0-1 and set the default input to mic-in
5044 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5045 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5046 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
5047 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5049 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
5051 * Note: PASD motherboards uses the Line In 2 as the input for
5052 * front panel mic (mic 2)
5054 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
5055 /* mute analog inputs */
5056 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5057 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5058 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5059 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5060 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5063 * Set up output mixers (0x08 - 0x0a)
5065 /* set vol=0 to output mixers */
5066 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5067 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5068 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5069 /* set up input amps for analog loopback */
5070 /* Amp Indices: DAC = 0, mixer = 1 */
5071 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5072 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5073 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5074 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5075 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5076 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5081 static int alc260_parse_auto_config(struct hda_codec *codec)
5083 struct alc_spec *spec = codec->spec;
5086 static hda_nid_t alc260_ignore[] = { 0x17, 0 };
5088 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
5092 err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg);
5095 if (!spec->kctl_alloc)
5096 return 0; /* can't find valid BIOS pin config */
5097 err = alc260_auto_create_analog_input_ctls(spec, &spec->autocfg);
5101 spec->multiout.max_channels = 2;
5103 if (spec->autocfg.dig_out_pin)
5104 spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
5105 if (spec->kctl_alloc)
5106 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
5108 spec->init_verbs[spec->num_init_verbs++] = alc260_volume_init_verbs;
5110 spec->num_mux_defs = 1;
5111 spec->input_mux = &spec->private_imux;
5113 /* check whether NID 0x04 is valid */
5114 wcap = get_wcaps(codec, 0x04);
5115 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
5116 if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
5117 spec->adc_nids = alc260_adc_nids_alt;
5118 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
5119 spec->mixers[spec->num_mixers] = alc260_capture_alt_mixer;
5121 spec->adc_nids = alc260_adc_nids;
5122 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
5123 spec->mixers[spec->num_mixers] = alc260_capture_mixer;
5130 /* additional initialization for auto-configuration model */
5131 static void alc260_auto_init(struct hda_codec *codec)
5133 struct alc_spec *spec = codec->spec;
5134 alc260_auto_init_multi_out(codec);
5135 alc260_auto_init_analog_input(codec);
5136 if (spec->unsol_event)
5137 alc_sku_automute(codec);
5140 #ifdef CONFIG_SND_HDA_POWER_SAVE
5141 static struct hda_amp_list alc260_loopbacks[] = {
5142 { 0x07, HDA_INPUT, 0 },
5143 { 0x07, HDA_INPUT, 1 },
5144 { 0x07, HDA_INPUT, 2 },
5145 { 0x07, HDA_INPUT, 3 },
5146 { 0x07, HDA_INPUT, 4 },
5152 * ALC260 configurations
5154 static const char *alc260_models[ALC260_MODEL_LAST] = {
5155 [ALC260_BASIC] = "basic",
5157 [ALC260_HP_3013] = "hp-3013",
5158 [ALC260_FUJITSU_S702X] = "fujitsu",
5159 [ALC260_ACER] = "acer",
5160 [ALC260_WILL] = "will",
5161 [ALC260_REPLACER_672V] = "replacer",
5162 #ifdef CONFIG_SND_DEBUG
5163 [ALC260_TEST] = "test",
5165 [ALC260_AUTO] = "auto",
5168 static struct snd_pci_quirk alc260_cfg_tbl[] = {
5169 SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER),
5170 SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER),
5171 SND_PCI_QUIRK(0x103c, 0x2808, "HP d5700", ALC260_HP_3013),
5172 SND_PCI_QUIRK(0x103c, 0x280a, "HP d5750", ALC260_HP_3013),
5173 SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013),
5174 SND_PCI_QUIRK(0x103c, 0x3011, "HP", ALC260_HP_3013),
5175 SND_PCI_QUIRK(0x103c, 0x3012, "HP", ALC260_HP_3013),
5176 SND_PCI_QUIRK(0x103c, 0x3013, "HP", ALC260_HP_3013),
5177 SND_PCI_QUIRK(0x103c, 0x3014, "HP", ALC260_HP),
5178 SND_PCI_QUIRK(0x103c, 0x3015, "HP", ALC260_HP),
5179 SND_PCI_QUIRK(0x103c, 0x3016, "HP", ALC260_HP),
5180 SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_BASIC),
5181 SND_PCI_QUIRK(0x104d, 0x81cc, "Sony VAIO", ALC260_BASIC),
5182 SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC),
5183 SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X),
5184 SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC),
5185 SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_REPLACER_672V),
5186 SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_WILL),
5190 static struct alc_config_preset alc260_presets[] = {
5192 .mixers = { alc260_base_output_mixer,
5194 alc260_pc_beep_mixer,
5195 alc260_capture_mixer },
5196 .init_verbs = { alc260_init_verbs },
5197 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5198 .dac_nids = alc260_dac_nids,
5199 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
5200 .adc_nids = alc260_adc_nids,
5201 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5202 .channel_mode = alc260_modes,
5203 .input_mux = &alc260_capture_source,
5206 .mixers = { alc260_hp_output_mixer,
5208 alc260_capture_alt_mixer },
5209 .init_verbs = { alc260_init_verbs,
5210 alc260_hp_unsol_verbs },
5211 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5212 .dac_nids = alc260_dac_nids,
5213 .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
5214 .adc_nids = alc260_hp_adc_nids,
5215 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5216 .channel_mode = alc260_modes,
5217 .input_mux = &alc260_capture_source,
5218 .unsol_event = alc260_hp_unsol_event,
5219 .init_hook = alc260_hp_automute,
5221 [ALC260_HP_3013] = {
5222 .mixers = { alc260_hp_3013_mixer,
5224 alc260_capture_alt_mixer },
5225 .init_verbs = { alc260_hp_3013_init_verbs,
5226 alc260_hp_3013_unsol_verbs },
5227 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5228 .dac_nids = alc260_dac_nids,
5229 .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
5230 .adc_nids = alc260_hp_adc_nids,
5231 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5232 .channel_mode = alc260_modes,
5233 .input_mux = &alc260_capture_source,
5234 .unsol_event = alc260_hp_3013_unsol_event,
5235 .init_hook = alc260_hp_3013_automute,
5237 [ALC260_FUJITSU_S702X] = {
5238 .mixers = { alc260_fujitsu_mixer,
5239 alc260_capture_mixer },
5240 .init_verbs = { alc260_fujitsu_init_verbs },
5241 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5242 .dac_nids = alc260_dac_nids,
5243 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
5244 .adc_nids = alc260_dual_adc_nids,
5245 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5246 .channel_mode = alc260_modes,
5247 .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources),
5248 .input_mux = alc260_fujitsu_capture_sources,
5251 .mixers = { alc260_acer_mixer,
5252 alc260_capture_mixer },
5253 .init_verbs = { alc260_acer_init_verbs },
5254 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5255 .dac_nids = alc260_dac_nids,
5256 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
5257 .adc_nids = alc260_dual_adc_nids,
5258 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5259 .channel_mode = alc260_modes,
5260 .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
5261 .input_mux = alc260_acer_capture_sources,
5264 .mixers = { alc260_will_mixer,
5265 alc260_capture_mixer },
5266 .init_verbs = { alc260_init_verbs, alc260_will_verbs },
5267 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5268 .dac_nids = alc260_dac_nids,
5269 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
5270 .adc_nids = alc260_adc_nids,
5271 .dig_out_nid = ALC260_DIGOUT_NID,
5272 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5273 .channel_mode = alc260_modes,
5274 .input_mux = &alc260_capture_source,
5276 [ALC260_REPLACER_672V] = {
5277 .mixers = { alc260_replacer_672v_mixer,
5278 alc260_capture_mixer },
5279 .init_verbs = { alc260_init_verbs, alc260_replacer_672v_verbs },
5280 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5281 .dac_nids = alc260_dac_nids,
5282 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
5283 .adc_nids = alc260_adc_nids,
5284 .dig_out_nid = ALC260_DIGOUT_NID,
5285 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5286 .channel_mode = alc260_modes,
5287 .input_mux = &alc260_capture_source,
5288 .unsol_event = alc260_replacer_672v_unsol_event,
5289 .init_hook = alc260_replacer_672v_automute,
5291 #ifdef CONFIG_SND_DEBUG
5293 .mixers = { alc260_test_mixer,
5294 alc260_capture_mixer },
5295 .init_verbs = { alc260_test_init_verbs },
5296 .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
5297 .dac_nids = alc260_test_dac_nids,
5298 .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
5299 .adc_nids = alc260_test_adc_nids,
5300 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5301 .channel_mode = alc260_modes,
5302 .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources),
5303 .input_mux = alc260_test_capture_sources,
5308 static int patch_alc260(struct hda_codec *codec)
5310 struct alc_spec *spec;
5311 int err, board_config;
5313 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5319 board_config = snd_hda_check_board_config(codec, ALC260_MODEL_LAST,
5322 if (board_config < 0) {
5323 snd_printd(KERN_INFO "hda_codec: Unknown model for ALC260, "
5324 "trying auto-probe from BIOS...\n");
5325 board_config = ALC260_AUTO;
5328 if (board_config == ALC260_AUTO) {
5329 /* automatic parse from the BIOS config */
5330 err = alc260_parse_auto_config(codec);
5336 "hda_codec: Cannot set up configuration "
5337 "from BIOS. Using base mode...\n");
5338 board_config = ALC260_BASIC;
5342 if (board_config != ALC260_AUTO)
5343 setup_preset(spec, &alc260_presets[board_config]);
5345 spec->stream_name_analog = "ALC260 Analog";
5346 spec->stream_analog_playback = &alc260_pcm_analog_playback;
5347 spec->stream_analog_capture = &alc260_pcm_analog_capture;
5349 spec->stream_name_digital = "ALC260 Digital";
5350 spec->stream_digital_playback = &alc260_pcm_digital_playback;
5351 spec->stream_digital_capture = &alc260_pcm_digital_capture;
5353 spec->vmaster_nid = 0x08;
5355 codec->patch_ops = alc_patch_ops;
5356 if (board_config == ALC260_AUTO)
5357 spec->init_hook = alc260_auto_init;
5358 #ifdef CONFIG_SND_HDA_POWER_SAVE
5359 if (!spec->loopback.amplist)
5360 spec->loopback.amplist = alc260_loopbacks;
5370 * ALC882 is almost identical with ALC880 but has cleaner and more flexible
5371 * configuration. Each pin widget can choose any input DACs and a mixer.
5372 * Each ADC is connected from a mixer of all inputs. This makes possible
5373 * 6-channel independent captures.
5375 * In addition, an independent DAC for the multi-playback (not used in this
5378 #define ALC882_DIGOUT_NID 0x06
5379 #define ALC882_DIGIN_NID 0x0a
5381 static struct hda_channel_mode alc882_ch_modes[1] = {
5385 static hda_nid_t alc882_dac_nids[4] = {
5386 /* front, rear, clfe, rear_surr */
5387 0x02, 0x03, 0x04, 0x05
5390 /* identical with ALC880 */
5391 #define alc882_adc_nids alc880_adc_nids
5392 #define alc882_adc_nids_alt alc880_adc_nids_alt
5394 static hda_nid_t alc882_capsrc_nids[3] = { 0x24, 0x23, 0x22 };
5395 static hda_nid_t alc882_capsrc_nids_alt[2] = { 0x23, 0x22 };
5398 /* FIXME: should be a matrix-type input source selection */
5400 static struct hda_input_mux alc882_capture_source = {
5404 { "Front Mic", 0x1 },
5409 #define alc882_mux_enum_info alc_mux_enum_info
5410 #define alc882_mux_enum_get alc_mux_enum_get
5412 static int alc882_mux_enum_put(struct snd_kcontrol *kcontrol,
5413 struct snd_ctl_elem_value *ucontrol)
5415 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
5416 struct alc_spec *spec = codec->spec;
5417 const struct hda_input_mux *imux = spec->input_mux;
5418 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
5419 hda_nid_t nid = spec->capsrc_nids ?
5420 spec->capsrc_nids[adc_idx] : spec->adc_nids[adc_idx];
5421 unsigned int *cur_val = &spec->cur_mux[adc_idx];
5422 unsigned int i, idx;
5424 idx = ucontrol->value.enumerated.item[0];
5425 if (idx >= imux->num_items)
5426 idx = imux->num_items - 1;
5427 if (*cur_val == idx)
5429 for (i = 0; i < imux->num_items; i++) {
5430 unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
5431 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
5432 imux->items[i].index,
5442 static struct hda_verb alc882_3ST_ch2_init[] = {
5443 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
5444 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
5445 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
5446 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
5453 static struct hda_verb alc882_3ST_ch6_init[] = {
5454 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5455 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
5456 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
5457 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5458 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
5459 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
5463 static struct hda_channel_mode alc882_3ST_6ch_modes[2] = {
5464 { 2, alc882_3ST_ch2_init },
5465 { 6, alc882_3ST_ch6_init },
5471 static struct hda_verb alc882_sixstack_ch6_init[] = {
5472 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
5473 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5474 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5475 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5482 static struct hda_verb alc882_sixstack_ch8_init[] = {
5483 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5484 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5485 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5486 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5490 static struct hda_channel_mode alc882_sixstack_modes[2] = {
5491 { 6, alc882_sixstack_ch6_init },
5492 { 8, alc882_sixstack_ch8_init },
5496 * macbook pro ALC885 can switch LineIn to LineOut without loosing Mic
5502 static struct hda_verb alc885_mbp_ch2_init[] = {
5503 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
5504 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5505 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5512 static struct hda_verb alc885_mbp_ch6_init[] = {
5513 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5514 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5515 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
5516 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5517 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5521 static struct hda_channel_mode alc885_mbp_6ch_modes[2] = {
5522 { 2, alc885_mbp_ch2_init },
5523 { 6, alc885_mbp_ch6_init },
5527 /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
5528 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
5530 static struct snd_kcontrol_new alc882_base_mixer[] = {
5531 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5532 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5533 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
5534 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
5535 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
5536 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
5537 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
5538 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
5539 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
5540 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
5541 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5542 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5543 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5544 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5545 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5546 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5547 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
5548 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5549 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
5550 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
5551 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
5552 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
5553 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
5557 static struct snd_kcontrol_new alc885_mbp3_mixer[] = {
5558 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
5559 HDA_BIND_MUTE ("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
5560 HDA_CODEC_MUTE ("Speaker Playback Switch", 0x14, 0x00, HDA_OUTPUT),
5561 HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
5562 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5563 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5564 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
5565 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
5566 HDA_CODEC_VOLUME("Line Boost", 0x1a, 0x00, HDA_INPUT),
5567 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
5570 static struct snd_kcontrol_new alc882_w2jc_mixer[] = {
5571 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5572 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5573 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5574 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5575 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5576 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5577 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5578 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
5579 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5580 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
5581 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
5585 static struct snd_kcontrol_new alc882_targa_mixer[] = {
5586 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5587 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5588 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5589 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5590 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5591 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5592 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5593 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5594 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5595 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
5596 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
5597 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
5598 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
5602 /* Pin assignment: Front=0x14, HP = 0x15, Front = 0x16, ???
5603 * Front Mic=0x18, Line In = 0x1a, Line In = 0x1b, CD = 0x1c
5605 static struct snd_kcontrol_new alc882_asus_a7j_mixer[] = {
5606 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5607 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
5608 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
5609 HDA_CODEC_MUTE("Mobile Front Playback Switch", 0x16, 0x0, HDA_OUTPUT),
5610 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5611 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5612 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5613 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5614 HDA_CODEC_VOLUME("Mobile Line Playback Volume", 0x0b, 0x03, HDA_INPUT),
5615 HDA_CODEC_MUTE("Mobile Line Playback Switch", 0x0b, 0x03, HDA_INPUT),
5616 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5617 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5618 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
5622 static struct snd_kcontrol_new alc882_asus_a7m_mixer[] = {
5623 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5624 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5625 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
5626 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5627 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5628 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5629 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5630 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5631 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
5632 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5633 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
5634 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
5638 static struct snd_kcontrol_new alc882_chmode_mixer[] = {
5640 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5641 .name = "Channel Mode",
5642 .info = alc_ch_mode_info,
5643 .get = alc_ch_mode_get,
5644 .put = alc_ch_mode_put,
5649 static struct hda_verb alc882_init_verbs[] = {
5650 /* Front mixer: unmute input/output amp left and right (volume = 0) */
5651 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5652 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5653 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5655 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5656 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5657 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5659 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5660 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5661 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5663 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5664 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5665 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5667 /* Front Pin: output 0 (0x0c) */
5668 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5669 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5670 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
5671 /* Rear Pin: output 1 (0x0d) */
5672 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5673 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5674 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
5675 /* CLFE Pin: output 2 (0x0e) */
5676 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5677 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5678 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
5679 /* Side Pin: output 3 (0x0f) */
5680 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5681 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5682 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
5683 /* Mic (rear) pin: input vref at 80% */
5684 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5685 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5686 /* Front Mic pin: input vref at 80% */
5687 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5688 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5689 /* Line In pin: input */
5690 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
5691 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5692 /* Line-2 In: Headphone output (output 0 - 0x0c) */
5693 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5694 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5695 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
5696 /* CD pin widget for input */
5697 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
5699 /* FIXME: use matrix-type input source selection */
5700 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5701 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
5702 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5703 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5704 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5705 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5707 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5708 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5709 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5710 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5712 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5713 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5714 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5715 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5716 /* ADC1: mute amp left and right */
5717 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5718 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
5719 /* ADC2: mute amp left and right */
5720 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5721 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
5722 /* ADC3: mute amp left and right */
5723 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5724 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
5729 static struct hda_verb alc882_eapd_verbs[] = {
5730 /* change to EAPD mode */
5731 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
5732 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
5737 static struct snd_kcontrol_new alc882_macpro_mixer[] = {
5738 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5739 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5740 HDA_CODEC_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT),
5741 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
5742 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
5743 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x02, HDA_INPUT),
5744 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x02, HDA_INPUT),
5748 static struct hda_verb alc882_macpro_init_verbs[] = {
5749 /* Front mixer: unmute input/output amp left and right (volume = 0) */
5750 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5751 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5752 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5753 /* Front Pin: output 0 (0x0c) */
5754 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5755 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5756 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
5757 /* Front Mic pin: input vref at 80% */
5758 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5759 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5760 /* Speaker: output */
5761 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5762 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5763 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x04},
5764 /* Headphone output (output 0 - 0x0c) */
5765 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5766 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5767 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
5769 /* FIXME: use matrix-type input source selection */
5770 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5771 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
5772 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5773 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5774 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5775 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5777 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5778 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5779 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5780 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5782 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5783 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5784 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5785 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5786 /* ADC1: mute amp left and right */
5787 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5788 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
5789 /* ADC2: mute amp left and right */
5790 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5791 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
5792 /* ADC3: mute amp left and right */
5793 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5794 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
5799 /* Macbook Pro rev3 */
5800 static struct hda_verb alc885_mbp3_init_verbs[] = {
5801 /* Front mixer: unmute input/output amp left and right (volume = 0) */
5802 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5803 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5804 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5806 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5807 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5808 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5809 /* Front Pin: output 0 (0x0c) */
5810 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5811 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5812 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
5813 /* HP Pin: output 0 (0x0d) */
5814 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4},
5815 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5816 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
5817 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
5818 /* Mic (rear) pin: input vref at 80% */
5819 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5820 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5821 /* Front Mic pin: input vref at 80% */
5822 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5823 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5824 /* Line In pin: use output 1 when in LineOut mode */
5825 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
5826 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5827 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
5829 /* FIXME: use matrix-type input source selection */
5830 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5831 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
5832 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5833 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5834 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5835 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5837 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5838 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5839 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5840 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5842 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5843 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5844 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5845 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5846 /* ADC1: mute amp left and right */
5847 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5848 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
5849 /* ADC2: mute amp left and right */
5850 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5851 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
5852 /* ADC3: mute amp left and right */
5853 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5854 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
5859 /* iMac 24 mixer. */
5860 static struct snd_kcontrol_new alc885_imac24_mixer[] = {
5861 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
5862 HDA_CODEC_MUTE("Master Playback Switch", 0x0c, 0x00, HDA_INPUT),
5866 /* iMac 24 init verbs. */
5867 static struct hda_verb alc885_imac24_init_verbs[] = {
5868 /* Internal speakers: output 0 (0x0c) */
5869 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5870 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5871 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
5872 /* Internal speakers: output 0 (0x0c) */
5873 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5874 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5875 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
5876 /* Headphone: output 0 (0x0c) */
5877 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5878 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5879 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
5880 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
5881 /* Front Mic: input vref at 80% */
5882 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5883 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5887 /* Toggle speaker-output according to the hp-jack state */
5888 static void alc885_imac24_automute(struct hda_codec *codec)
5890 unsigned int present;
5892 present = snd_hda_codec_read(codec, 0x14, 0,
5893 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
5894 snd_hda_codec_amp_stereo(codec, 0x18, HDA_OUTPUT, 0,
5895 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
5896 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_OUTPUT, 0,
5897 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
5900 /* Processes unsolicited events. */
5901 static void alc885_imac24_unsol_event(struct hda_codec *codec,
5904 /* Headphone insertion or removal. */
5905 if ((res >> 26) == ALC880_HP_EVENT)
5906 alc885_imac24_automute(codec);
5909 static void alc885_mbp3_automute(struct hda_codec *codec)
5911 unsigned int present;
5913 present = snd_hda_codec_read(codec, 0x15, 0,
5914 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
5915 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
5916 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
5917 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
5918 HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
5921 static void alc885_mbp3_unsol_event(struct hda_codec *codec,
5924 /* Headphone insertion or removal. */
5925 if ((res >> 26) == ALC880_HP_EVENT)
5926 alc885_mbp3_automute(codec);
5930 static struct hda_verb alc882_targa_verbs[] = {
5931 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5932 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5934 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5935 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5937 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
5938 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
5939 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
5941 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
5942 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
5943 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
5944 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
5948 /* toggle speaker-output according to the hp-jack state */
5949 static void alc882_targa_automute(struct hda_codec *codec)
5951 unsigned int present;
5953 present = snd_hda_codec_read(codec, 0x14, 0,
5954 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
5955 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
5956 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
5957 snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
5961 static void alc882_targa_unsol_event(struct hda_codec *codec, unsigned int res)
5963 /* Looks like the unsol event is incompatible with the standard
5964 * definition. 4bit tag is placed at 26 bit!
5966 if (((res >> 26) == ALC880_HP_EVENT)) {
5967 alc882_targa_automute(codec);
5971 static struct hda_verb alc882_asus_a7j_verbs[] = {
5972 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5973 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5975 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5976 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5977 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5979 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
5980 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
5981 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
5983 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
5984 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
5985 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
5989 static struct hda_verb alc882_asus_a7m_verbs[] = {
5990 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5991 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5993 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5994 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5995 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5997 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
5998 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
5999 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
6001 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
6002 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
6003 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6007 static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
6009 unsigned int gpiostate, gpiomask, gpiodir;
6011 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
6012 AC_VERB_GET_GPIO_DATA, 0);
6015 gpiostate |= (1 << pin);
6017 gpiostate &= ~(1 << pin);
6019 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
6020 AC_VERB_GET_GPIO_MASK, 0);
6021 gpiomask |= (1 << pin);
6023 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
6024 AC_VERB_GET_GPIO_DIRECTION, 0);
6025 gpiodir |= (1 << pin);
6028 snd_hda_codec_write(codec, codec->afg, 0,
6029 AC_VERB_SET_GPIO_MASK, gpiomask);
6030 snd_hda_codec_write(codec, codec->afg, 0,
6031 AC_VERB_SET_GPIO_DIRECTION, gpiodir);
6035 snd_hda_codec_write(codec, codec->afg, 0,
6036 AC_VERB_SET_GPIO_DATA, gpiostate);
6039 /* set up GPIO at initialization */
6040 static void alc885_macpro_init_hook(struct hda_codec *codec)
6042 alc882_gpio_mute(codec, 0, 0);
6043 alc882_gpio_mute(codec, 1, 0);
6046 /* set up GPIO and update auto-muting at initialization */
6047 static void alc885_imac24_init_hook(struct hda_codec *codec)
6049 alc885_macpro_init_hook(codec);
6050 alc885_imac24_automute(codec);
6054 * generic initialization of ADC, input mixers and output mixers
6056 static struct hda_verb alc882_auto_init_verbs[] = {
6058 * Unmute ADC0-2 and set the default input to mic-in
6060 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
6061 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6062 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6063 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6064 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
6065 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6067 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
6069 * Note: PASD motherboards uses the Line In 2 as the input for
6070 * front panel mic (mic 2)
6072 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
6073 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6074 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6075 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6076 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6077 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6080 * Set up output mixers (0x0c - 0x0f)
6082 /* set vol=0 to output mixers */
6083 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6084 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6085 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6086 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6087 /* set up input amps for analog loopback */
6088 /* Amp Indices: DAC = 0, mixer = 1 */
6089 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6090 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6091 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6092 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6093 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6094 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6095 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6096 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6097 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6098 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6100 /* FIXME: use matrix-type input source selection */
6101 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6102 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
6103 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6104 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
6105 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
6106 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
6108 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6109 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
6110 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
6111 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
6113 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6114 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
6115 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
6116 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
6121 /* capture mixer elements */
6122 static struct snd_kcontrol_new alc882_capture_alt_mixer[] = {
6123 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6124 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6125 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6126 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6128 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6129 /* The multiple "Capture Source" controls confuse alsamixer
6130 * So call somewhat different..
6132 /* .name = "Capture Source", */
6133 .name = "Input Source",
6135 .info = alc882_mux_enum_info,
6136 .get = alc882_mux_enum_get,
6137 .put = alc882_mux_enum_put,
6142 static struct snd_kcontrol_new alc882_capture_mixer[] = {
6143 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
6144 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
6145 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
6146 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
6147 HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
6148 HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
6150 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6151 /* The multiple "Capture Source" controls confuse alsamixer
6152 * So call somewhat different..
6154 /* .name = "Capture Source", */
6155 .name = "Input Source",
6157 .info = alc882_mux_enum_info,
6158 .get = alc882_mux_enum_get,
6159 .put = alc882_mux_enum_put,
6164 #ifdef CONFIG_SND_HDA_POWER_SAVE
6165 #define alc882_loopbacks alc880_loopbacks
6168 /* pcm configuration: identiacal with ALC880 */
6169 #define alc882_pcm_analog_playback alc880_pcm_analog_playback
6170 #define alc882_pcm_analog_capture alc880_pcm_analog_capture
6171 #define alc882_pcm_digital_playback alc880_pcm_digital_playback
6172 #define alc882_pcm_digital_capture alc880_pcm_digital_capture
6175 * configuration and preset
6177 static const char *alc882_models[ALC882_MODEL_LAST] = {
6178 [ALC882_3ST_DIG] = "3stack-dig",
6179 [ALC882_6ST_DIG] = "6stack-dig",
6180 [ALC882_ARIMA] = "arima",
6181 [ALC882_W2JC] = "w2jc",
6182 [ALC882_TARGA] = "targa",
6183 [ALC882_ASUS_A7J] = "asus-a7j",
6184 [ALC882_ASUS_A7M] = "asus-a7m",
6185 [ALC885_MACPRO] = "macpro",
6186 [ALC885_MBP3] = "mbp3",
6187 [ALC885_IMAC24] = "imac24",
6188 [ALC882_AUTO] = "auto",
6191 static struct snd_pci_quirk alc882_cfg_tbl[] = {
6192 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG),
6193 SND_PCI_QUIRK(0x1043, 0x060d, "Asus A7J", ALC882_ASUS_A7J),
6194 SND_PCI_QUIRK(0x1043, 0x1243, "Asus A7J", ALC882_ASUS_A7J),
6195 SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_ASUS_A7M),
6196 SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_W2JC),
6197 SND_PCI_QUIRK(0x1043, 0x817f, "Asus P5LD2", ALC882_6ST_DIG),
6198 SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG),
6199 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG),
6200 SND_PCI_QUIRK(0x106b, 0x00a0, "Apple iMac 24''", ALC885_IMAC24),
6201 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte P35 DS3R", ALC882_6ST_DIG),
6202 SND_PCI_QUIRK(0x1462, 0x28fb, "Targa T8", ALC882_TARGA), /* MSI-1049 T8 */
6203 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG),
6204 SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA),
6208 static struct alc_config_preset alc882_presets[] = {
6209 [ALC882_3ST_DIG] = {
6210 .mixers = { alc882_base_mixer },
6211 .init_verbs = { alc882_init_verbs },
6212 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6213 .dac_nids = alc882_dac_nids,
6214 .dig_out_nid = ALC882_DIGOUT_NID,
6215 .dig_in_nid = ALC882_DIGIN_NID,
6216 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
6217 .channel_mode = alc882_ch_modes,
6219 .input_mux = &alc882_capture_source,
6221 [ALC882_6ST_DIG] = {
6222 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
6223 .init_verbs = { alc882_init_verbs },
6224 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6225 .dac_nids = alc882_dac_nids,
6226 .dig_out_nid = ALC882_DIGOUT_NID,
6227 .dig_in_nid = ALC882_DIGIN_NID,
6228 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
6229 .channel_mode = alc882_sixstack_modes,
6230 .input_mux = &alc882_capture_source,
6233 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
6234 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs },
6235 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6236 .dac_nids = alc882_dac_nids,
6237 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
6238 .channel_mode = alc882_sixstack_modes,
6239 .input_mux = &alc882_capture_source,
6242 .mixers = { alc882_w2jc_mixer, alc882_chmode_mixer },
6243 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs,
6244 alc880_gpio1_init_verbs },
6245 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6246 .dac_nids = alc882_dac_nids,
6247 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
6248 .channel_mode = alc880_threestack_modes,
6250 .input_mux = &alc882_capture_source,
6251 .dig_out_nid = ALC882_DIGOUT_NID,
6254 .mixers = { alc885_mbp3_mixer, alc882_chmode_mixer },
6255 .init_verbs = { alc885_mbp3_init_verbs,
6256 alc880_gpio1_init_verbs },
6257 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6258 .dac_nids = alc882_dac_nids,
6259 .channel_mode = alc885_mbp_6ch_modes,
6260 .num_channel_mode = ARRAY_SIZE(alc885_mbp_6ch_modes),
6261 .input_mux = &alc882_capture_source,
6262 .dig_out_nid = ALC882_DIGOUT_NID,
6263 .dig_in_nid = ALC882_DIGIN_NID,
6264 .unsol_event = alc885_mbp3_unsol_event,
6265 .init_hook = alc885_mbp3_automute,
6268 .mixers = { alc882_macpro_mixer },
6269 .init_verbs = { alc882_macpro_init_verbs },
6270 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6271 .dac_nids = alc882_dac_nids,
6272 .dig_out_nid = ALC882_DIGOUT_NID,
6273 .dig_in_nid = ALC882_DIGIN_NID,
6274 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
6275 .channel_mode = alc882_ch_modes,
6276 .input_mux = &alc882_capture_source,
6277 .init_hook = alc885_macpro_init_hook,
6280 .mixers = { alc885_imac24_mixer },
6281 .init_verbs = { alc885_imac24_init_verbs },
6282 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6283 .dac_nids = alc882_dac_nids,
6284 .dig_out_nid = ALC882_DIGOUT_NID,
6285 .dig_in_nid = ALC882_DIGIN_NID,
6286 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
6287 .channel_mode = alc882_ch_modes,
6288 .input_mux = &alc882_capture_source,
6289 .unsol_event = alc885_imac24_unsol_event,
6290 .init_hook = alc885_imac24_init_hook,
6293 .mixers = { alc882_targa_mixer, alc882_chmode_mixer,
6294 alc882_capture_mixer },
6295 .init_verbs = { alc882_init_verbs, alc882_targa_verbs},
6296 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6297 .dac_nids = alc882_dac_nids,
6298 .dig_out_nid = ALC882_DIGOUT_NID,
6299 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
6300 .adc_nids = alc882_adc_nids,
6301 .capsrc_nids = alc882_capsrc_nids,
6302 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
6303 .channel_mode = alc882_3ST_6ch_modes,
6305 .input_mux = &alc882_capture_source,
6306 .unsol_event = alc882_targa_unsol_event,
6307 .init_hook = alc882_targa_automute,
6309 [ALC882_ASUS_A7J] = {
6310 .mixers = { alc882_asus_a7j_mixer, alc882_chmode_mixer,
6311 alc882_capture_mixer },
6312 .init_verbs = { alc882_init_verbs, alc882_asus_a7j_verbs},
6313 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6314 .dac_nids = alc882_dac_nids,
6315 .dig_out_nid = ALC882_DIGOUT_NID,
6316 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
6317 .adc_nids = alc882_adc_nids,
6318 .capsrc_nids = alc882_capsrc_nids,
6319 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
6320 .channel_mode = alc882_3ST_6ch_modes,
6322 .input_mux = &alc882_capture_source,
6324 [ALC882_ASUS_A7M] = {
6325 .mixers = { alc882_asus_a7m_mixer, alc882_chmode_mixer },
6326 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs,
6327 alc880_gpio1_init_verbs,
6328 alc882_asus_a7m_verbs },
6329 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6330 .dac_nids = alc882_dac_nids,
6331 .dig_out_nid = ALC882_DIGOUT_NID,
6332 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
6333 .channel_mode = alc880_threestack_modes,
6335 .input_mux = &alc882_capture_source,
6344 PINFIX_ABIT_AW9D_MAX
6347 static struct alc_pincfg alc882_abit_aw9d_pinfix[] = {
6348 { 0x15, 0x01080104 }, /* side */
6349 { 0x16, 0x01011012 }, /* rear */
6350 { 0x17, 0x01016011 }, /* clfe */
6354 static const struct alc_pincfg *alc882_pin_fixes[] = {
6355 [PINFIX_ABIT_AW9D_MAX] = alc882_abit_aw9d_pinfix,
6358 static struct snd_pci_quirk alc882_pinfix_tbl[] = {
6359 SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", PINFIX_ABIT_AW9D_MAX),
6364 * BIOS auto configuration
6366 static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
6367 hda_nid_t nid, int pin_type,
6371 struct alc_spec *spec = codec->spec;
6374 alc_set_pin_output(codec, nid, pin_type);
6375 if (spec->multiout.dac_nids[dac_idx] == 0x25)
6378 idx = spec->multiout.dac_nids[dac_idx] - 2;
6379 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
6383 static void alc882_auto_init_multi_out(struct hda_codec *codec)
6385 struct alc_spec *spec = codec->spec;
6388 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
6389 for (i = 0; i <= HDA_SIDE; i++) {
6390 hda_nid_t nid = spec->autocfg.line_out_pins[i];
6391 int pin_type = get_pin_type(spec->autocfg.line_out_type);
6393 alc882_auto_set_output_and_unmute(codec, nid, pin_type,
6398 static void alc882_auto_init_hp_out(struct hda_codec *codec)
6400 struct alc_spec *spec = codec->spec;
6403 pin = spec->autocfg.hp_pins[0];
6404 if (pin) /* connect to front */
6406 alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
6407 pin = spec->autocfg.speaker_pins[0];
6409 alc882_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
6412 #define alc882_is_input_pin(nid) alc880_is_input_pin(nid)
6413 #define ALC882_PIN_CD_NID ALC880_PIN_CD_NID
6415 static void alc882_auto_init_analog_input(struct hda_codec *codec)
6417 struct alc_spec *spec = codec->spec;
6420 for (i = 0; i < AUTO_PIN_LAST; i++) {
6421 hda_nid_t nid = spec->autocfg.input_pins[i];
6426 if (1 /*i <= AUTO_PIN_FRONT_MIC*/) {
6427 unsigned int pincap;
6428 pincap = snd_hda_param_read(codec, nid, AC_PAR_PIN_CAP);
6429 if ((pincap >> AC_PINCAP_VREF_SHIFT) &
6433 snd_hda_codec_write(codec, nid, 0,
6434 AC_VERB_SET_PIN_WIDGET_CONTROL, vref);
6435 if (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP)
6436 snd_hda_codec_write(codec, nid, 0,
6437 AC_VERB_SET_AMP_GAIN_MUTE,
6442 static void alc882_auto_init_input_src(struct hda_codec *codec)
6444 struct alc_spec *spec = codec->spec;
6445 const struct hda_input_mux *imux = spec->input_mux;
6448 for (c = 0; c < spec->num_adc_nids; c++) {
6449 hda_nid_t conn_list[HDA_MAX_NUM_INPUTS];
6450 hda_nid_t nid = spec->capsrc_nids[c];
6451 int conns, mute, idx, item;
6453 conns = snd_hda_get_connections(codec, nid, conn_list,
6454 ARRAY_SIZE(conn_list));
6457 for (idx = 0; idx < conns; idx++) {
6458 /* if the current connection is the selected one,
6459 * unmute it as default - otherwise mute it
6461 mute = AMP_IN_MUTE(idx);
6462 for (item = 0; item < imux->num_items; item++) {
6463 if (imux->items[item].index == idx) {
6464 if (spec->cur_mux[c] == item)
6465 mute = AMP_IN_UNMUTE(idx);
6469 snd_hda_codec_write(codec, nid, 0,
6470 AC_VERB_SET_AMP_GAIN_MUTE, mute);
6475 /* add mic boosts if needed */
6476 static int alc_auto_add_mic_boost(struct hda_codec *codec)
6478 struct alc_spec *spec = codec->spec;
6482 nid = spec->autocfg.input_pins[AUTO_PIN_MIC];
6483 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
6484 err = add_control(spec, ALC_CTL_WIDGET_VOL,
6486 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
6490 nid = spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC];
6491 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
6492 err = add_control(spec, ALC_CTL_WIDGET_VOL,
6494 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
6501 /* almost identical with ALC880 parser... */
6502 static int alc882_parse_auto_config(struct hda_codec *codec)
6504 struct alc_spec *spec = codec->spec;
6505 int err = alc880_parse_auto_config(codec);
6510 return 0; /* no config found */
6512 err = alc_auto_add_mic_boost(codec);
6516 /* hack - override the init verbs */
6517 spec->init_verbs[0] = alc882_auto_init_verbs;
6519 return 1; /* config found */
6522 /* additional initialization for auto-configuration model */
6523 static void alc882_auto_init(struct hda_codec *codec)
6525 struct alc_spec *spec = codec->spec;
6526 alc882_auto_init_multi_out(codec);
6527 alc882_auto_init_hp_out(codec);
6528 alc882_auto_init_analog_input(codec);
6529 alc882_auto_init_input_src(codec);
6530 if (spec->unsol_event)
6531 alc_sku_automute(codec);
6534 static int patch_alc883(struct hda_codec *codec); /* called in patch_alc882() */
6536 static int patch_alc882(struct hda_codec *codec)
6538 struct alc_spec *spec;
6539 int err, board_config;
6541 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
6547 board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST,
6551 if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
6552 /* Pick up systems that don't supply PCI SSID */
6553 switch (codec->subsystem_id) {
6554 case 0x106b0c00: /* Mac Pro */
6555 board_config = ALC885_MACPRO;
6557 case 0x106b1000: /* iMac 24 */
6558 board_config = ALC885_IMAC24;
6560 case 0x106b00a1: /* Macbook (might be wrong - PCI SSID?) */
6561 case 0x106b2c00: /* Macbook Pro rev3 */
6562 case 0x106b3600: /* Macbook 3.1 */
6563 board_config = ALC885_MBP3;
6566 /* ALC889A is handled better as ALC888-compatible */
6567 if (codec->revision_id == 0x100103) {
6569 return patch_alc883(codec);
6571 printk(KERN_INFO "hda_codec: Unknown model for ALC882, "
6572 "trying auto-probe from BIOS...\n");
6573 board_config = ALC882_AUTO;
6577 alc_fix_pincfg(codec, alc882_pinfix_tbl, alc882_pin_fixes);
6579 if (board_config == ALC882_AUTO) {
6580 /* automatic parse from the BIOS config */
6581 err = alc882_parse_auto_config(codec);
6587 "hda_codec: Cannot set up configuration "
6588 "from BIOS. Using base mode...\n");
6589 board_config = ALC882_3ST_DIG;
6593 if (board_config != ALC882_AUTO)
6594 setup_preset(spec, &alc882_presets[board_config]);
6596 if (codec->vendor_id == 0x10ec0885) {
6597 spec->stream_name_analog = "ALC885 Analog";
6598 spec->stream_name_digital = "ALC885 Digital";
6600 spec->stream_name_analog = "ALC882 Analog";
6601 spec->stream_name_digital = "ALC882 Digital";
6604 spec->stream_analog_playback = &alc882_pcm_analog_playback;
6605 spec->stream_analog_capture = &alc882_pcm_analog_capture;
6606 /* FIXME: setup DAC5 */
6607 /*spec->stream_analog_alt_playback = &alc880_pcm_analog_alt_playback;*/
6608 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
6610 spec->stream_digital_playback = &alc882_pcm_digital_playback;
6611 spec->stream_digital_capture = &alc882_pcm_digital_capture;
6613 if (!spec->adc_nids && spec->input_mux) {
6614 /* check whether NID 0x07 is valid */
6615 unsigned int wcap = get_wcaps(codec, 0x07);
6617 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
6618 if (wcap != AC_WID_AUD_IN) {
6619 spec->adc_nids = alc882_adc_nids_alt;
6620 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids_alt);
6621 spec->capsrc_nids = alc882_capsrc_nids_alt;
6622 spec->mixers[spec->num_mixers] =
6623 alc882_capture_alt_mixer;
6626 spec->adc_nids = alc882_adc_nids;
6627 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids);
6628 spec->capsrc_nids = alc882_capsrc_nids;
6629 spec->mixers[spec->num_mixers] = alc882_capture_mixer;
6634 spec->vmaster_nid = 0x0c;
6636 codec->patch_ops = alc_patch_ops;
6637 if (board_config == ALC882_AUTO)
6638 spec->init_hook = alc882_auto_init;
6639 #ifdef CONFIG_SND_HDA_POWER_SAVE
6640 if (!spec->loopback.amplist)
6641 spec->loopback.amplist = alc882_loopbacks;
6650 * ALC883 is almost identical with ALC880 but has cleaner and more flexible
6651 * configuration. Each pin widget can choose any input DACs and a mixer.
6652 * Each ADC is connected from a mixer of all inputs. This makes possible
6653 * 6-channel independent captures.
6655 * In addition, an independent DAC for the multi-playback (not used in this
6658 #define ALC883_DIGOUT_NID 0x06
6659 #define ALC883_DIGIN_NID 0x0a
6661 static hda_nid_t alc883_dac_nids[4] = {
6662 /* front, rear, clfe, rear_surr */
6663 0x02, 0x03, 0x04, 0x05
6666 static hda_nid_t alc883_adc_nids[2] = {
6671 static hda_nid_t alc883_capsrc_nids[2] = { 0x23, 0x22 };
6674 /* FIXME: should be a matrix-type input source selection */
6676 static struct hda_input_mux alc883_capture_source = {
6680 { "Front Mic", 0x1 },
6686 static struct hda_input_mux alc883_3stack_6ch_intel = {
6690 { "Front Mic", 0x0 },
6696 static struct hda_input_mux alc883_lenovo_101e_capture_source = {
6704 static struct hda_input_mux alc883_lenovo_nb0763_capture_source = {
6714 static struct hda_input_mux alc883_fujitsu_pi2515_capture_source = {
6722 #define alc883_mux_enum_info alc_mux_enum_info
6723 #define alc883_mux_enum_get alc_mux_enum_get
6724 /* ALC883 has the ALC882-type input selection */
6725 #define alc883_mux_enum_put alc882_mux_enum_put
6730 static struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
6737 static struct hda_verb alc883_3ST_ch2_init[] = {
6738 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6739 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6740 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6741 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6748 static struct hda_verb alc883_3ST_ch4_init[] = {
6749 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6750 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6751 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6752 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6753 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6760 static struct hda_verb alc883_3ST_ch6_init[] = {
6761 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6762 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6763 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
6764 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6765 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6766 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6770 static struct hda_channel_mode alc883_3ST_6ch_modes[3] = {
6771 { 2, alc883_3ST_ch2_init },
6772 { 4, alc883_3ST_ch4_init },
6773 { 6, alc883_3ST_ch6_init },
6779 static struct hda_verb alc883_3ST_ch2_intel_init[] = {
6780 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6781 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6782 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6783 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6790 static struct hda_verb alc883_3ST_ch4_intel_init[] = {
6791 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6792 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6793 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6794 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6795 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6802 static struct hda_verb alc883_3ST_ch6_intel_init[] = {
6803 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6804 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6805 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x02 },
6806 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6807 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6808 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6812 static struct hda_channel_mode alc883_3ST_6ch_intel_modes[3] = {
6813 { 2, alc883_3ST_ch2_intel_init },
6814 { 4, alc883_3ST_ch4_intel_init },
6815 { 6, alc883_3ST_ch6_intel_init },
6821 static struct hda_verb alc883_sixstack_ch6_init[] = {
6822 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
6823 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6824 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6825 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6832 static struct hda_verb alc883_sixstack_ch8_init[] = {
6833 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6834 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6835 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6836 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6840 static struct hda_channel_mode alc883_sixstack_modes[2] = {
6841 { 6, alc883_sixstack_ch6_init },
6842 { 8, alc883_sixstack_ch8_init },
6845 static struct hda_verb alc883_medion_eapd_verbs[] = {
6846 /* eanable EAPD on medion laptop */
6847 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
6848 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
6852 /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
6853 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
6856 static struct snd_kcontrol_new alc883_base_mixer[] = {
6857 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6858 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6859 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
6860 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
6861 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
6862 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
6863 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
6864 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
6865 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
6866 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
6867 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6868 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6869 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6870 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6871 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6872 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6873 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6874 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6875 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6876 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
6877 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6878 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6879 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6880 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6881 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6882 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6883 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6885 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6886 /* .name = "Capture Source", */
6887 .name = "Input Source",
6889 .info = alc883_mux_enum_info,
6890 .get = alc883_mux_enum_get,
6891 .put = alc883_mux_enum_put,
6896 static struct snd_kcontrol_new alc883_mitac_mixer[] = {
6897 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6898 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6899 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
6900 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
6901 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
6902 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
6903 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
6904 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6905 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6906 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6907 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6908 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
6909 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6910 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6911 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6912 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6913 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6915 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6916 /* .name = "Capture Source", */
6917 .name = "Input Source",
6919 .info = alc883_mux_enum_info,
6920 .get = alc883_mux_enum_get,
6921 .put = alc883_mux_enum_put,
6926 static struct snd_kcontrol_new alc883_clevo_m720_mixer[] = {
6927 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6928 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
6929 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
6930 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
6931 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6932 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6933 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6934 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6935 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
6936 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6937 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6938 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6939 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6940 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6942 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6943 /* .name = "Capture Source", */
6944 .name = "Input Source",
6946 .info = alc883_mux_enum_info,
6947 .get = alc883_mux_enum_get,
6948 .put = alc883_mux_enum_put,
6953 static struct snd_kcontrol_new alc883_2ch_fujitsu_pi2515_mixer[] = {
6954 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6955 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
6956 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
6957 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
6958 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6959 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6960 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6961 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6962 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
6963 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6964 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6965 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6966 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6967 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6969 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6970 /* .name = "Capture Source", */
6971 .name = "Input Source",
6973 .info = alc883_mux_enum_info,
6974 .get = alc883_mux_enum_get,
6975 .put = alc883_mux_enum_put,
6980 static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
6981 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6982 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6983 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6984 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6985 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6986 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6987 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6988 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6989 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6990 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6991 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6992 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
6993 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6994 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6995 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6996 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6997 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6998 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6999 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
7001 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7002 /* .name = "Capture Source", */
7003 .name = "Input Source",
7005 .info = alc883_mux_enum_info,
7006 .get = alc883_mux_enum_get,
7007 .put = alc883_mux_enum_put,
7012 static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
7013 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7014 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7015 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7016 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7017 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7018 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7019 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7020 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7021 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7022 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7023 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7024 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7025 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7026 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7027 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7028 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7029 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7030 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
7031 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7032 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
7033 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
7034 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7035 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7036 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
7037 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
7039 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7040 /* .name = "Capture Source", */
7041 .name = "Input Source",
7043 .info = alc883_mux_enum_info,
7044 .get = alc883_mux_enum_get,
7045 .put = alc883_mux_enum_put,
7050 static struct snd_kcontrol_new alc883_3ST_6ch_intel_mixer[] = {
7051 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7052 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7053 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7054 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7055 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
7057 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7058 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7059 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7060 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7061 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7062 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7063 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7064 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7065 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7066 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
7067 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7068 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7069 HDA_CODEC_VOLUME("Front Mic Boost", 0x18, 0, HDA_INPUT),
7070 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7071 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
7072 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
7073 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7074 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7075 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
7076 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
7078 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7079 /* .name = "Capture Source", */
7080 .name = "Input Source",
7082 .info = alc883_mux_enum_info,
7083 .get = alc883_mux_enum_get,
7084 .put = alc883_mux_enum_put,
7089 static struct snd_kcontrol_new alc883_fivestack_mixer[] = {
7090 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7091 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7092 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7093 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7094 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7095 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7096 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7097 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7098 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7099 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7100 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7101 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7102 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7103 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7104 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7105 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7106 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7107 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
7108 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7109 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
7110 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
7111 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7112 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7115 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7116 /* .name = "Capture Source", */
7117 .name = "Input Source",
7119 .info = alc883_mux_enum_info,
7120 .get = alc883_mux_enum_get,
7121 .put = alc883_mux_enum_put,
7126 static struct snd_kcontrol_new alc883_tagra_mixer[] = {
7127 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7128 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7129 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7130 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7131 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7132 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7133 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7134 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7135 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7136 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7137 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7138 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7139 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7140 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7141 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7142 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7143 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7144 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7145 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
7146 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
7148 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7149 /* .name = "Capture Source", */
7150 .name = "Input Source",
7152 .info = alc883_mux_enum_info,
7153 .get = alc883_mux_enum_get,
7154 .put = alc883_mux_enum_put,
7159 static struct snd_kcontrol_new alc883_tagra_2ch_mixer[] = {
7160 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7161 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7162 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7163 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7164 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7165 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7166 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7167 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7168 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7169 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
7170 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7171 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7172 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7173 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
7174 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
7176 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7177 /* .name = "Capture Source", */
7178 .name = "Input Source",
7180 .info = alc883_mux_enum_info,
7181 .get = alc883_mux_enum_get,
7182 .put = alc883_mux_enum_put,
7187 static struct snd_kcontrol_new alc883_lenovo_101e_2ch_mixer[] = {
7188 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7189 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7190 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7191 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
7192 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7193 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7194 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7195 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7196 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7197 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7199 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7200 /* .name = "Capture Source", */
7201 .name = "Input Source",
7203 .info = alc883_mux_enum_info,
7204 .get = alc883_mux_enum_get,
7205 .put = alc883_mux_enum_put,
7210 static struct snd_kcontrol_new alc883_lenovo_nb0763_mixer[] = {
7211 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7212 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
7213 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7214 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7215 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7216 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7217 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7218 HDA_CODEC_VOLUME("iMic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7219 HDA_CODEC_MUTE("iMic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7220 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7221 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7222 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
7223 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
7225 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7226 /* .name = "Capture Source", */
7227 .name = "Input Source",
7229 .info = alc883_mux_enum_info,
7230 .get = alc883_mux_enum_get,
7231 .put = alc883_mux_enum_put,
7236 static struct snd_kcontrol_new alc883_medion_md2_mixer[] = {
7237 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7238 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7239 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7240 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7241 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7242 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7243 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7244 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7245 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7246 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7247 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7248 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
7249 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
7251 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7252 /* .name = "Capture Source", */
7253 .name = "Input Source",
7255 .info = alc883_mux_enum_info,
7256 .get = alc883_mux_enum_get,
7257 .put = alc883_mux_enum_put,
7262 static struct snd_kcontrol_new alc883_acer_aspire_mixer[] = {
7263 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7264 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7265 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7266 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7267 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7268 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7269 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7270 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7271 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7272 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7273 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
7274 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
7276 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7277 /* .name = "Capture Source", */
7278 .name = "Input Source",
7280 .info = alc883_mux_enum_info,
7281 .get = alc883_mux_enum_get,
7282 .put = alc883_mux_enum_put,
7287 static struct snd_kcontrol_new alc883_chmode_mixer[] = {
7289 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7290 .name = "Channel Mode",
7291 .info = alc_ch_mode_info,
7292 .get = alc_ch_mode_get,
7293 .put = alc_ch_mode_put,
7298 static struct hda_verb alc883_init_verbs[] = {
7299 /* ADC1: mute amp left and right */
7300 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7301 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7302 /* ADC2: mute amp left and right */
7303 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7304 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7305 /* Front mixer: unmute input/output amp left and right (volume = 0) */
7306 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7307 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7308 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7310 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7311 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7312 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7314 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7315 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7316 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7318 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7319 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7320 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7322 /* mute analog input loopbacks */
7323 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7324 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7325 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7326 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7327 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7329 /* Front Pin: output 0 (0x0c) */
7330 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7331 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7332 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7333 /* Rear Pin: output 1 (0x0d) */
7334 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7335 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7336 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
7337 /* CLFE Pin: output 2 (0x0e) */
7338 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7339 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7340 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
7341 /* Side Pin: output 3 (0x0f) */
7342 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7343 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7344 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
7345 /* Mic (rear) pin: input vref at 80% */
7346 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7347 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7348 /* Front Mic pin: input vref at 80% */
7349 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7350 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7351 /* Line In pin: input */
7352 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7353 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7354 /* Line-2 In: Headphone output (output 0 - 0x0c) */
7355 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7356 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7357 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
7358 /* CD pin widget for input */
7359 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7361 /* FIXME: use matrix-type input source selection */
7362 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7364 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7365 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7366 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7367 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
7369 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7370 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7371 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7372 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
7376 /* toggle speaker-output according to the hp-jack state */
7377 static void alc883_mitac_hp_automute(struct hda_codec *codec)
7379 unsigned int present;
7381 present = snd_hda_codec_read(codec, 0x15, 0,
7382 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7383 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7384 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7385 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
7386 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7389 /* auto-toggle front mic */
7391 static void alc883_mitac_mic_automute(struct hda_codec *codec)
7393 unsigned int present;
7396 present = snd_hda_codec_read(codec, 0x18, 0,
7397 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7398 bits = present ? HDA_AMP_MUTE : 0;
7399 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
7403 static void alc883_mitac_automute(struct hda_codec *codec)
7405 alc883_mitac_hp_automute(codec);
7406 /* alc883_mitac_mic_automute(codec); */
7409 static void alc883_mitac_unsol_event(struct hda_codec *codec,
7412 switch (res >> 26) {
7413 case ALC880_HP_EVENT:
7414 alc883_mitac_hp_automute(codec);
7416 case ALC880_MIC_EVENT:
7417 /* alc883_mitac_mic_automute(codec); */
7422 static struct hda_verb alc883_mitac_verbs[] = {
7424 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7425 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7427 {0x17, AC_VERB_SET_CONNECT_SEL, 0x02},
7428 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7430 /* enable unsolicited event */
7431 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7432 /* {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN}, */
7437 static struct hda_verb alc883_clevo_m720_verbs[] = {
7439 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7440 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7442 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
7443 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7445 /* enable unsolicited event */
7446 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7447 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
7452 static struct hda_verb alc883_2ch_fujitsu_pi2515_verbs[] = {
7454 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7455 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7457 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
7458 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7460 /* enable unsolicited event */
7461 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7466 static struct hda_verb alc883_tagra_verbs[] = {
7467 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7468 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7470 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7471 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7473 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
7474 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
7475 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
7477 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7478 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
7479 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
7480 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
7485 static struct hda_verb alc883_lenovo_101e_verbs[] = {
7486 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7487 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT|AC_USRSP_EN},
7488 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT|AC_USRSP_EN},
7492 static struct hda_verb alc883_lenovo_nb0763_verbs[] = {
7493 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7494 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7495 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7496 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7500 static struct hda_verb alc888_lenovo_ms7195_verbs[] = {
7501 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7502 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7503 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7504 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT | AC_USRSP_EN},
7505 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7509 static struct hda_verb alc883_haier_w66_verbs[] = {
7510 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7511 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7513 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7515 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
7516 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7517 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7518 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7522 static struct hda_verb alc888_3st_hp_verbs[] = {
7523 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
7524 {0x16, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Rear : output 1 (0x0d) */
7525 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* CLFE : output 2 (0x0e) */
7529 static struct hda_verb alc888_6st_dell_verbs[] = {
7530 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7534 static struct hda_verb alc888_3st_hp_2ch_init[] = {
7535 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7536 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7537 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7538 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7542 static struct hda_verb alc888_3st_hp_6ch_init[] = {
7543 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7544 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7545 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7546 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7550 static struct hda_channel_mode alc888_3st_hp_modes[2] = {
7551 { 2, alc888_3st_hp_2ch_init },
7552 { 6, alc888_3st_hp_6ch_init },
7555 /* toggle front-jack and RCA according to the hp-jack state */
7556 static void alc888_lenovo_ms7195_front_automute(struct hda_codec *codec)
7558 unsigned int present;
7560 present = snd_hda_codec_read(codec, 0x1b, 0,
7561 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7562 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7563 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7564 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7565 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7568 /* toggle RCA according to the front-jack state */
7569 static void alc888_lenovo_ms7195_rca_automute(struct hda_codec *codec)
7571 unsigned int present;
7573 present = snd_hda_codec_read(codec, 0x14, 0,
7574 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7575 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7576 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7579 static void alc883_lenovo_ms7195_unsol_event(struct hda_codec *codec,
7582 if ((res >> 26) == ALC880_HP_EVENT)
7583 alc888_lenovo_ms7195_front_automute(codec);
7584 if ((res >> 26) == ALC880_FRONT_EVENT)
7585 alc888_lenovo_ms7195_rca_automute(codec);
7588 static struct hda_verb alc883_medion_md2_verbs[] = {
7589 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7590 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7592 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7594 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7598 /* toggle speaker-output according to the hp-jack state */
7599 static void alc883_medion_md2_automute(struct hda_codec *codec)
7601 unsigned int present;
7603 present = snd_hda_codec_read(codec, 0x14, 0,
7604 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7605 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7606 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7609 static void alc883_medion_md2_unsol_event(struct hda_codec *codec,
7612 if ((res >> 26) == ALC880_HP_EVENT)
7613 alc883_medion_md2_automute(codec);
7616 /* toggle speaker-output according to the hp-jack state */
7617 static void alc883_tagra_automute(struct hda_codec *codec)
7619 unsigned int present;
7622 present = snd_hda_codec_read(codec, 0x14, 0,
7623 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7624 bits = present ? HDA_AMP_MUTE : 0;
7625 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
7626 HDA_AMP_MUTE, bits);
7627 snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
7631 static void alc883_tagra_unsol_event(struct hda_codec *codec, unsigned int res)
7633 if ((res >> 26) == ALC880_HP_EVENT)
7634 alc883_tagra_automute(codec);
7637 /* toggle speaker-output according to the hp-jack state */
7638 static void alc883_clevo_m720_hp_automute(struct hda_codec *codec)
7640 unsigned int present;
7643 present = snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_PIN_SENSE, 0)
7644 & AC_PINSENSE_PRESENCE;
7645 bits = present ? HDA_AMP_MUTE : 0;
7646 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7647 HDA_AMP_MUTE, bits);
7650 static void alc883_clevo_m720_mic_automute(struct hda_codec *codec)
7652 unsigned int present;
7654 present = snd_hda_codec_read(codec, 0x18, 0,
7655 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7656 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
7657 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7660 static void alc883_clevo_m720_automute(struct hda_codec *codec)
7662 alc883_clevo_m720_hp_automute(codec);
7663 alc883_clevo_m720_mic_automute(codec);
7666 static void alc883_clevo_m720_unsol_event(struct hda_codec *codec,
7669 switch (res >> 26) {
7670 case ALC880_HP_EVENT:
7671 alc883_clevo_m720_hp_automute(codec);
7673 case ALC880_MIC_EVENT:
7674 alc883_clevo_m720_mic_automute(codec);
7679 /* toggle speaker-output according to the hp-jack state */
7680 static void alc883_2ch_fujitsu_pi2515_automute(struct hda_codec *codec)
7682 unsigned int present;
7685 present = snd_hda_codec_read(codec, 0x14, 0, AC_VERB_GET_PIN_SENSE, 0)
7686 & AC_PINSENSE_PRESENCE;
7687 bits = present ? HDA_AMP_MUTE : 0;
7688 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7689 HDA_AMP_MUTE, bits);
7692 static void alc883_2ch_fujitsu_pi2515_unsol_event(struct hda_codec *codec,
7695 if ((res >> 26) == ALC880_HP_EVENT)
7696 alc883_2ch_fujitsu_pi2515_automute(codec);
7699 static void alc883_haier_w66_automute(struct hda_codec *codec)
7701 unsigned int present;
7704 present = snd_hda_codec_read(codec, 0x1b, 0,
7705 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7706 bits = present ? 0x80 : 0;
7707 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7711 static void alc883_haier_w66_unsol_event(struct hda_codec *codec,
7714 if ((res >> 26) == ALC880_HP_EVENT)
7715 alc883_haier_w66_automute(codec);
7718 static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
7720 unsigned int present;
7723 present = snd_hda_codec_read(codec, 0x14, 0,
7724 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7725 bits = present ? HDA_AMP_MUTE : 0;
7726 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7727 HDA_AMP_MUTE, bits);
7730 static void alc883_lenovo_101e_all_automute(struct hda_codec *codec)
7732 unsigned int present;
7735 present = snd_hda_codec_read(codec, 0x1b, 0,
7736 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7737 bits = present ? HDA_AMP_MUTE : 0;
7738 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7739 HDA_AMP_MUTE, bits);
7740 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7741 HDA_AMP_MUTE, bits);
7744 static void alc883_lenovo_101e_unsol_event(struct hda_codec *codec,
7747 if ((res >> 26) == ALC880_HP_EVENT)
7748 alc883_lenovo_101e_all_automute(codec);
7749 if ((res >> 26) == ALC880_FRONT_EVENT)
7750 alc883_lenovo_101e_ispeaker_automute(codec);
7753 /* toggle speaker-output according to the hp-jack state */
7754 static void alc883_acer_aspire_automute(struct hda_codec *codec)
7756 unsigned int present;
7758 present = snd_hda_codec_read(codec, 0x14, 0,
7759 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7760 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7761 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7762 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
7763 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7766 static void alc883_acer_aspire_unsol_event(struct hda_codec *codec,
7769 if ((res >> 26) == ALC880_HP_EVENT)
7770 alc883_acer_aspire_automute(codec);
7773 static struct hda_verb alc883_acer_eapd_verbs[] = {
7774 /* HP Pin: output 0 (0x0c) */
7775 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7776 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7777 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7778 /* Front Pin: output 0 (0x0c) */
7779 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7780 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7781 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7782 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00},
7783 /* eanable EAPD on medion laptop */
7784 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
7785 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
7786 /* enable unsolicited event */
7787 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7791 static void alc888_6st_dell_front_automute(struct hda_codec *codec)
7793 unsigned int present;
7795 present = snd_hda_codec_read(codec, 0x1b, 0,
7796 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7797 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7798 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7799 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7800 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7801 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
7802 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7803 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
7804 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7807 static void alc888_6st_dell_unsol_event(struct hda_codec *codec,
7810 switch (res >> 26) {
7811 case ALC880_HP_EVENT:
7812 printk("hp_event\n");
7813 alc888_6st_dell_front_automute(codec);
7819 * generic initialization of ADC, input mixers and output mixers
7821 static struct hda_verb alc883_auto_init_verbs[] = {
7823 * Unmute ADC0-2 and set the default input to mic-in
7825 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7826 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7827 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7828 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7830 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
7832 * Note: PASD motherboards uses the Line In 2 as the input for
7833 * front panel mic (mic 2)
7835 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
7836 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7837 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7838 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7839 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7840 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7843 * Set up output mixers (0x0c - 0x0f)
7845 /* set vol=0 to output mixers */
7846 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7847 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7848 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7849 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7850 /* set up input amps for analog loopback */
7851 /* Amp Indices: DAC = 0, mixer = 1 */
7852 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7853 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7854 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7855 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7856 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7857 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7858 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7859 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7860 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7861 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7863 /* FIXME: use matrix-type input source selection */
7864 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7866 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7867 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7868 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7869 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
7870 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
7872 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7873 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7874 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7875 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
7876 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
7881 /* capture mixer elements */
7882 static struct snd_kcontrol_new alc883_capture_mixer[] = {
7883 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7884 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7885 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
7886 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
7888 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7889 /* The multiple "Capture Source" controls confuse alsamixer
7890 * So call somewhat different..
7892 /* .name = "Capture Source", */
7893 .name = "Input Source",
7895 .info = alc882_mux_enum_info,
7896 .get = alc882_mux_enum_get,
7897 .put = alc882_mux_enum_put,
7902 #ifdef CONFIG_SND_HDA_POWER_SAVE
7903 #define alc883_loopbacks alc880_loopbacks
7906 /* pcm configuration: identiacal with ALC880 */
7907 #define alc883_pcm_analog_playback alc880_pcm_analog_playback
7908 #define alc883_pcm_analog_capture alc880_pcm_analog_capture
7909 #define alc883_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
7910 #define alc883_pcm_digital_playback alc880_pcm_digital_playback
7911 #define alc883_pcm_digital_capture alc880_pcm_digital_capture
7914 * configuration and preset
7916 static const char *alc883_models[ALC883_MODEL_LAST] = {
7917 [ALC883_3ST_2ch_DIG] = "3stack-dig",
7918 [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig",
7919 [ALC883_3ST_6ch] = "3stack-6ch",
7920 [ALC883_6ST_DIG] = "6stack-dig",
7921 [ALC883_TARGA_DIG] = "targa-dig",
7922 [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig",
7923 [ALC883_ACER] = "acer",
7924 [ALC883_ACER_ASPIRE] = "acer-aspire",
7925 [ALC883_MEDION] = "medion",
7926 [ALC883_MEDION_MD2] = "medion-md2",
7927 [ALC883_LAPTOP_EAPD] = "laptop-eapd",
7928 [ALC883_LENOVO_101E_2ch] = "lenovo-101e",
7929 [ALC883_LENOVO_NB0763] = "lenovo-nb0763",
7930 [ALC888_LENOVO_MS7195_DIG] = "lenovo-ms7195-dig",
7931 [ALC883_HAIER_W66] = "haier-w66",
7932 [ALC888_3ST_HP] = "3stack-hp",
7933 [ALC888_6ST_DELL] = "6stack-dell",
7934 [ALC883_MITAC] = "mitac",
7935 [ALC883_CLEVO_M720] = "clevo-m720",
7936 [ALC883_FUJITSU_PI2515] = "fujitsu-pi2515",
7937 [ALC883_3ST_6ch_INTEL] = "3stack-6ch-intel",
7938 [ALC883_AUTO] = "auto",
7941 static struct snd_pci_quirk alc883_cfg_tbl[] = {
7942 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC883_3ST_6ch_DIG),
7943 SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_ACER_ASPIRE),
7944 SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_ACER_ASPIRE),
7945 SND_PCI_QUIRK(0x1025, 0x0112, "Acer Aspire 9303", ALC883_ACER_ASPIRE),
7946 SND_PCI_QUIRK(0x1025, 0x0121, "Acer Aspire 5920G", ALC883_ACER_ASPIRE),
7947 SND_PCI_QUIRK(0x1025, 0, "Acer laptop", ALC883_ACER), /* default Acer */
7948 SND_PCI_QUIRK(0x1028, 0x020d, "Dell Inspiron 530", ALC888_6ST_DELL),
7949 SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG),
7950 SND_PCI_QUIRK(0x103c, 0x2a4f, "HP Samba", ALC888_3ST_HP),
7951 SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_3ST_HP),
7952 SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC883_6ST_DIG),
7953 SND_PCI_QUIRK(0x1043, 0x8249, "Asus M2A-VM HDMI", ALC883_3ST_6ch_DIG),
7954 SND_PCI_QUIRK(0x105b, 0x0ce8, "Foxconn P35AX-S", ALC883_6ST_DIG),
7955 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC883_6ST_DIG),
7956 SND_PCI_QUIRK(0x1071, 0x8253, "Mitac 8252d", ALC883_MITAC),
7957 SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD),
7958 SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch),
7959 SND_PCI_QUIRK(0x1458, 0xa002, "MSI", ALC883_6ST_DIG),
7960 SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG),
7961 SND_PCI_QUIRK(0x1462, 0x040d, "MSI", ALC883_TARGA_2ch_DIG),
7962 SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG),
7963 SND_PCI_QUIRK(0x1462, 0x2fb3, "MSI", ALC883_TARGA_2ch_DIG),
7964 SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG),
7965 SND_PCI_QUIRK(0x1462, 0x3783, "NEC S970", ALC883_TARGA_DIG),
7966 SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG),
7967 SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG),
7968 SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG),
7969 SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG),
7970 SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG),
7971 SND_PCI_QUIRK(0x1462, 0x3fdf, "MSI", ALC883_TARGA_DIG),
7972 SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG),
7973 SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG),
7974 SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG),
7975 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG),
7976 SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG),
7977 SND_PCI_QUIRK(0x1462, 0x7250, "MSI", ALC883_6ST_DIG),
7978 SND_PCI_QUIRK(0x1462, 0x7267, "MSI", ALC883_3ST_6ch_DIG),
7979 SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG),
7980 SND_PCI_QUIRK(0x1462, 0x7327, "MSI", ALC883_6ST_DIG),
7981 SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG),
7982 SND_PCI_QUIRK(0x147b, 0x1083, "Abit IP35-PRO", ALC883_6ST_DIG),
7983 SND_PCI_QUIRK(0x1558, 0x0721, "Clevo laptop M720R", ALC883_CLEVO_M720),
7984 SND_PCI_QUIRK(0x1558, 0x0722, "Clevo laptop M720SR", ALC883_CLEVO_M720),
7985 SND_PCI_QUIRK(0x1558, 0, "Clevo laptop", ALC883_LAPTOP_EAPD),
7986 SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch),
7987 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
7988 SND_PCI_QUIRK(0x1734, 0x1108, "Fujitsu AMILO Pi2515", ALC883_FUJITSU_PI2515),
7989 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch),
7990 SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763),
7991 SND_PCI_QUIRK(0x17aa, 0x3bfc, "Lenovo NB0763", ALC883_LENOVO_NB0763),
7992 SND_PCI_QUIRK(0x17aa, 0x3bfd, "Lenovo NB0763", ALC883_LENOVO_NB0763),
7993 SND_PCI_QUIRK(0x17c0, 0x4071, "MEDION MD2", ALC883_MEDION_MD2),
7994 SND_PCI_QUIRK(0x17f2, 0x5000, "Albatron KI690-AM2", ALC883_6ST_DIG),
7995 SND_PCI_QUIRK(0x1991, 0x5625, "Haier W66", ALC883_HAIER_W66),
7996 SND_PCI_QUIRK(0x8086, 0x0001, "DG33BUC", ALC883_3ST_6ch_INTEL),
7997 SND_PCI_QUIRK(0x8086, 0x0002, "DG33FBC", ALC883_3ST_6ch_INTEL),
7998 SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC883_3ST_6ch),
8002 static struct alc_config_preset alc883_presets[] = {
8003 [ALC883_3ST_2ch_DIG] = {
8004 .mixers = { alc883_3ST_2ch_mixer },
8005 .init_verbs = { alc883_init_verbs },
8006 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8007 .dac_nids = alc883_dac_nids,
8008 .dig_out_nid = ALC883_DIGOUT_NID,
8009 .dig_in_nid = ALC883_DIGIN_NID,
8010 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8011 .channel_mode = alc883_3ST_2ch_modes,
8012 .input_mux = &alc883_capture_source,
8014 [ALC883_3ST_6ch_DIG] = {
8015 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
8016 .init_verbs = { alc883_init_verbs },
8017 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8018 .dac_nids = alc883_dac_nids,
8019 .dig_out_nid = ALC883_DIGOUT_NID,
8020 .dig_in_nid = ALC883_DIGIN_NID,
8021 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8022 .channel_mode = alc883_3ST_6ch_modes,
8024 .input_mux = &alc883_capture_source,
8026 [ALC883_3ST_6ch] = {
8027 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
8028 .init_verbs = { alc883_init_verbs },
8029 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8030 .dac_nids = alc883_dac_nids,
8031 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8032 .channel_mode = alc883_3ST_6ch_modes,
8034 .input_mux = &alc883_capture_source,
8036 [ALC883_3ST_6ch_INTEL] = {
8037 .mixers = { alc883_3ST_6ch_intel_mixer, alc883_chmode_mixer },
8038 .init_verbs = { alc883_init_verbs },
8039 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8040 .dac_nids = alc883_dac_nids,
8041 .dig_out_nid = ALC883_DIGOUT_NID,
8042 .dig_in_nid = ALC883_DIGIN_NID,
8043 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_intel_modes),
8044 .channel_mode = alc883_3ST_6ch_intel_modes,
8046 .input_mux = &alc883_3stack_6ch_intel,
8048 [ALC883_6ST_DIG] = {
8049 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
8050 .init_verbs = { alc883_init_verbs },
8051 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8052 .dac_nids = alc883_dac_nids,
8053 .dig_out_nid = ALC883_DIGOUT_NID,
8054 .dig_in_nid = ALC883_DIGIN_NID,
8055 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
8056 .channel_mode = alc883_sixstack_modes,
8057 .input_mux = &alc883_capture_source,
8059 [ALC883_TARGA_DIG] = {
8060 .mixers = { alc883_tagra_mixer, alc883_chmode_mixer },
8061 .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
8062 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8063 .dac_nids = alc883_dac_nids,
8064 .dig_out_nid = ALC883_DIGOUT_NID,
8065 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8066 .channel_mode = alc883_3ST_6ch_modes,
8068 .input_mux = &alc883_capture_source,
8069 .unsol_event = alc883_tagra_unsol_event,
8070 .init_hook = alc883_tagra_automute,
8072 [ALC883_TARGA_2ch_DIG] = {
8073 .mixers = { alc883_tagra_2ch_mixer},
8074 .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
8075 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8076 .dac_nids = alc883_dac_nids,
8077 .dig_out_nid = ALC883_DIGOUT_NID,
8078 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8079 .channel_mode = alc883_3ST_2ch_modes,
8080 .input_mux = &alc883_capture_source,
8081 .unsol_event = alc883_tagra_unsol_event,
8082 .init_hook = alc883_tagra_automute,
8085 .mixers = { alc883_base_mixer },
8086 /* On TravelMate laptops, GPIO 0 enables the internal speaker
8087 * and the headphone jack. Turn this on and rely on the
8088 * standard mute methods whenever the user wants to turn
8089 * these outputs off.
8091 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs },
8092 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8093 .dac_nids = alc883_dac_nids,
8094 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8095 .channel_mode = alc883_3ST_2ch_modes,
8096 .input_mux = &alc883_capture_source,
8098 [ALC883_ACER_ASPIRE] = {
8099 .mixers = { alc883_acer_aspire_mixer },
8100 .init_verbs = { alc883_init_verbs, alc883_acer_eapd_verbs },
8101 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8102 .dac_nids = alc883_dac_nids,
8103 .dig_out_nid = ALC883_DIGOUT_NID,
8104 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8105 .channel_mode = alc883_3ST_2ch_modes,
8106 .input_mux = &alc883_capture_source,
8107 .unsol_event = alc883_acer_aspire_unsol_event,
8108 .init_hook = alc883_acer_aspire_automute,
8111 .mixers = { alc883_fivestack_mixer,
8112 alc883_chmode_mixer },
8113 .init_verbs = { alc883_init_verbs,
8114 alc883_medion_eapd_verbs },
8115 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8116 .dac_nids = alc883_dac_nids,
8117 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
8118 .channel_mode = alc883_sixstack_modes,
8119 .input_mux = &alc883_capture_source,
8121 [ALC883_MEDION_MD2] = {
8122 .mixers = { alc883_medion_md2_mixer},
8123 .init_verbs = { alc883_init_verbs, alc883_medion_md2_verbs},
8124 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8125 .dac_nids = alc883_dac_nids,
8126 .dig_out_nid = ALC883_DIGOUT_NID,
8127 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8128 .channel_mode = alc883_3ST_2ch_modes,
8129 .input_mux = &alc883_capture_source,
8130 .unsol_event = alc883_medion_md2_unsol_event,
8131 .init_hook = alc883_medion_md2_automute,
8133 [ALC883_LAPTOP_EAPD] = {
8134 .mixers = { alc883_base_mixer },
8135 .init_verbs = { alc883_init_verbs, alc882_eapd_verbs },
8136 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8137 .dac_nids = alc883_dac_nids,
8138 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8139 .channel_mode = alc883_3ST_2ch_modes,
8140 .input_mux = &alc883_capture_source,
8142 [ALC883_CLEVO_M720] = {
8143 .mixers = { alc883_clevo_m720_mixer },
8144 .init_verbs = { alc883_init_verbs, alc883_clevo_m720_verbs },
8145 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8146 .dac_nids = alc883_dac_nids,
8147 .dig_out_nid = ALC883_DIGOUT_NID,
8148 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8149 .channel_mode = alc883_3ST_2ch_modes,
8150 .input_mux = &alc883_capture_source,
8151 .unsol_event = alc883_clevo_m720_unsol_event,
8152 .init_hook = alc883_clevo_m720_automute,
8154 [ALC883_LENOVO_101E_2ch] = {
8155 .mixers = { alc883_lenovo_101e_2ch_mixer},
8156 .init_verbs = { alc883_init_verbs, alc883_lenovo_101e_verbs},
8157 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8158 .dac_nids = alc883_dac_nids,
8159 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8160 .channel_mode = alc883_3ST_2ch_modes,
8161 .input_mux = &alc883_lenovo_101e_capture_source,
8162 .unsol_event = alc883_lenovo_101e_unsol_event,
8163 .init_hook = alc883_lenovo_101e_all_automute,
8165 [ALC883_LENOVO_NB0763] = {
8166 .mixers = { alc883_lenovo_nb0763_mixer },
8167 .init_verbs = { alc883_init_verbs, alc883_lenovo_nb0763_verbs},
8168 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8169 .dac_nids = alc883_dac_nids,
8170 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8171 .channel_mode = alc883_3ST_2ch_modes,
8173 .input_mux = &alc883_lenovo_nb0763_capture_source,
8174 .unsol_event = alc883_medion_md2_unsol_event,
8175 .init_hook = alc883_medion_md2_automute,
8177 [ALC888_LENOVO_MS7195_DIG] = {
8178 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
8179 .init_verbs = { alc883_init_verbs, alc888_lenovo_ms7195_verbs},
8180 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8181 .dac_nids = alc883_dac_nids,
8182 .dig_out_nid = ALC883_DIGOUT_NID,
8183 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8184 .channel_mode = alc883_3ST_6ch_modes,
8186 .input_mux = &alc883_capture_source,
8187 .unsol_event = alc883_lenovo_ms7195_unsol_event,
8188 .init_hook = alc888_lenovo_ms7195_front_automute,
8190 [ALC883_HAIER_W66] = {
8191 .mixers = { alc883_tagra_2ch_mixer},
8192 .init_verbs = { alc883_init_verbs, alc883_haier_w66_verbs},
8193 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8194 .dac_nids = alc883_dac_nids,
8195 .dig_out_nid = ALC883_DIGOUT_NID,
8196 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8197 .channel_mode = alc883_3ST_2ch_modes,
8198 .input_mux = &alc883_capture_source,
8199 .unsol_event = alc883_haier_w66_unsol_event,
8200 .init_hook = alc883_haier_w66_automute,
8203 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
8204 .init_verbs = { alc883_init_verbs, alc888_3st_hp_verbs },
8205 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8206 .dac_nids = alc883_dac_nids,
8207 .num_channel_mode = ARRAY_SIZE(alc888_3st_hp_modes),
8208 .channel_mode = alc888_3st_hp_modes,
8210 .input_mux = &alc883_capture_source,
8212 [ALC888_6ST_DELL] = {
8213 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
8214 .init_verbs = { alc883_init_verbs, alc888_6st_dell_verbs },
8215 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8216 .dac_nids = alc883_dac_nids,
8217 .dig_out_nid = ALC883_DIGOUT_NID,
8218 .dig_in_nid = ALC883_DIGIN_NID,
8219 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
8220 .channel_mode = alc883_sixstack_modes,
8221 .input_mux = &alc883_capture_source,
8222 .unsol_event = alc888_6st_dell_unsol_event,
8223 .init_hook = alc888_6st_dell_front_automute,
8226 .mixers = { alc883_mitac_mixer },
8227 .init_verbs = { alc883_init_verbs, alc883_mitac_verbs },
8228 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8229 .dac_nids = alc883_dac_nids,
8230 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8231 .channel_mode = alc883_3ST_2ch_modes,
8232 .input_mux = &alc883_capture_source,
8233 .unsol_event = alc883_mitac_unsol_event,
8234 .init_hook = alc883_mitac_automute,
8236 [ALC883_FUJITSU_PI2515] = {
8237 .mixers = { alc883_2ch_fujitsu_pi2515_mixer },
8238 .init_verbs = { alc883_init_verbs,
8239 alc883_2ch_fujitsu_pi2515_verbs},
8240 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8241 .dac_nids = alc883_dac_nids,
8242 .dig_out_nid = ALC883_DIGOUT_NID,
8243 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8244 .channel_mode = alc883_3ST_2ch_modes,
8245 .input_mux = &alc883_fujitsu_pi2515_capture_source,
8246 .unsol_event = alc883_2ch_fujitsu_pi2515_unsol_event,
8247 .init_hook = alc883_2ch_fujitsu_pi2515_automute,
8253 * BIOS auto configuration
8255 static void alc883_auto_set_output_and_unmute(struct hda_codec *codec,
8256 hda_nid_t nid, int pin_type,
8260 struct alc_spec *spec = codec->spec;
8263 alc_set_pin_output(codec, nid, pin_type);
8264 if (spec->multiout.dac_nids[dac_idx] == 0x25)
8267 idx = spec->multiout.dac_nids[dac_idx] - 2;
8268 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
8272 static void alc883_auto_init_multi_out(struct hda_codec *codec)
8274 struct alc_spec *spec = codec->spec;
8277 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
8278 for (i = 0; i <= HDA_SIDE; i++) {
8279 hda_nid_t nid = spec->autocfg.line_out_pins[i];
8280 int pin_type = get_pin_type(spec->autocfg.line_out_type);
8282 alc883_auto_set_output_and_unmute(codec, nid, pin_type,
8287 static void alc883_auto_init_hp_out(struct hda_codec *codec)
8289 struct alc_spec *spec = codec->spec;
8292 pin = spec->autocfg.hp_pins[0];
8293 if (pin) /* connect to front */
8295 alc883_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
8296 pin = spec->autocfg.speaker_pins[0];
8298 alc883_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
8301 #define alc883_is_input_pin(nid) alc880_is_input_pin(nid)
8302 #define ALC883_PIN_CD_NID ALC880_PIN_CD_NID
8304 static void alc883_auto_init_analog_input(struct hda_codec *codec)
8306 struct alc_spec *spec = codec->spec;
8309 for (i = 0; i < AUTO_PIN_LAST; i++) {
8310 hda_nid_t nid = spec->autocfg.input_pins[i];
8311 if (alc883_is_input_pin(nid)) {
8312 snd_hda_codec_write(codec, nid, 0,
8313 AC_VERB_SET_PIN_WIDGET_CONTROL,
8314 (i <= AUTO_PIN_FRONT_MIC ?
8315 PIN_VREF80 : PIN_IN));
8316 if (nid != ALC883_PIN_CD_NID)
8317 snd_hda_codec_write(codec, nid, 0,
8318 AC_VERB_SET_AMP_GAIN_MUTE,
8324 #define alc883_auto_init_input_src alc882_auto_init_input_src
8326 /* almost identical with ALC880 parser... */
8327 static int alc883_parse_auto_config(struct hda_codec *codec)
8329 struct alc_spec *spec = codec->spec;
8330 int err = alc880_parse_auto_config(codec);
8335 return 0; /* no config found */
8337 err = alc_auto_add_mic_boost(codec);
8341 /* hack - override the init verbs */
8342 spec->init_verbs[0] = alc883_auto_init_verbs;
8343 spec->mixers[spec->num_mixers] = alc883_capture_mixer;
8346 return 1; /* config found */
8349 /* additional initialization for auto-configuration model */
8350 static void alc883_auto_init(struct hda_codec *codec)
8352 struct alc_spec *spec = codec->spec;
8353 alc883_auto_init_multi_out(codec);
8354 alc883_auto_init_hp_out(codec);
8355 alc883_auto_init_analog_input(codec);
8356 alc883_auto_init_input_src(codec);
8357 if (spec->unsol_event)
8358 alc_sku_automute(codec);
8361 static int patch_alc883(struct hda_codec *codec)
8363 struct alc_spec *spec;
8364 int err, board_config;
8366 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
8372 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
8374 board_config = snd_hda_check_board_config(codec, ALC883_MODEL_LAST,
8377 if (board_config < 0) {
8378 printk(KERN_INFO "hda_codec: Unknown model for ALC883, "
8379 "trying auto-probe from BIOS...\n");
8380 board_config = ALC883_AUTO;
8383 if (board_config == ALC883_AUTO) {
8384 /* automatic parse from the BIOS config */
8385 err = alc883_parse_auto_config(codec);
8391 "hda_codec: Cannot set up configuration "
8392 "from BIOS. Using base mode...\n");
8393 board_config = ALC883_3ST_2ch_DIG;
8397 if (board_config != ALC883_AUTO)
8398 setup_preset(spec, &alc883_presets[board_config]);
8400 switch (codec->vendor_id) {
8402 spec->stream_name_analog = "ALC888 Analog";
8403 spec->stream_name_digital = "ALC888 Digital";
8406 spec->stream_name_analog = "ALC889 Analog";
8407 spec->stream_name_digital = "ALC889 Digital";
8410 spec->stream_name_analog = "ALC883 Analog";
8411 spec->stream_name_digital = "ALC883 Digital";
8415 spec->stream_analog_playback = &alc883_pcm_analog_playback;
8416 spec->stream_analog_capture = &alc883_pcm_analog_capture;
8417 spec->stream_analog_alt_capture = &alc883_pcm_analog_alt_capture;
8419 spec->stream_digital_playback = &alc883_pcm_digital_playback;
8420 spec->stream_digital_capture = &alc883_pcm_digital_capture;
8422 spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids);
8423 spec->adc_nids = alc883_adc_nids;
8424 spec->capsrc_nids = alc883_capsrc_nids;
8426 spec->vmaster_nid = 0x0c;
8428 codec->patch_ops = alc_patch_ops;
8429 if (board_config == ALC883_AUTO)
8430 spec->init_hook = alc883_auto_init;
8432 #ifdef CONFIG_SND_HDA_POWER_SAVE
8433 if (!spec->loopback.amplist)
8434 spec->loopback.amplist = alc883_loopbacks;
8444 #define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
8445 #define ALC262_DIGIN_NID ALC880_DIGIN_NID
8447 #define alc262_dac_nids alc260_dac_nids
8448 #define alc262_adc_nids alc882_adc_nids
8449 #define alc262_adc_nids_alt alc882_adc_nids_alt
8450 #define alc262_capsrc_nids alc882_capsrc_nids
8451 #define alc262_capsrc_nids_alt alc882_capsrc_nids_alt
8453 #define alc262_modes alc260_modes
8454 #define alc262_capture_source alc882_capture_source
8456 static struct snd_kcontrol_new alc262_base_mixer[] = {
8457 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8458 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8459 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8460 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8461 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8462 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8463 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8464 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8465 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8466 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
8467 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
8468 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
8469 /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
8470 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT), */
8471 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
8472 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8473 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8474 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
8478 static struct snd_kcontrol_new alc262_hippo1_mixer[] = {
8479 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8480 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8481 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8482 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8483 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8484 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8485 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8486 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8487 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8488 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
8489 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
8490 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
8491 /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
8492 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT), */
8493 /*HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),*/
8494 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8498 /* update HP, line and mono-out pins according to the master switch */
8499 static void alc262_hp_master_update(struct hda_codec *codec)
8501 struct alc_spec *spec = codec->spec;
8502 int val = spec->master_sw;
8505 snd_hda_codec_write_cache(codec, 0x1b, 0,
8506 AC_VERB_SET_PIN_WIDGET_CONTROL,
8508 snd_hda_codec_write_cache(codec, 0x15, 0,
8509 AC_VERB_SET_PIN_WIDGET_CONTROL,
8511 /* mono (speaker) depending on the HP jack sense */
8512 val = val && !spec->jack_present;
8513 snd_hda_codec_write_cache(codec, 0x16, 0,
8514 AC_VERB_SET_PIN_WIDGET_CONTROL,
8518 static void alc262_hp_bpc_automute(struct hda_codec *codec)
8520 struct alc_spec *spec = codec->spec;
8521 unsigned int presence;
8522 presence = snd_hda_codec_read(codec, 0x1b, 0,
8523 AC_VERB_GET_PIN_SENSE, 0);
8524 spec->jack_present = !!(presence & AC_PINSENSE_PRESENCE);
8525 alc262_hp_master_update(codec);
8528 static void alc262_hp_bpc_unsol_event(struct hda_codec *codec, unsigned int res)
8530 if ((res >> 26) != ALC880_HP_EVENT)
8532 alc262_hp_bpc_automute(codec);
8535 static void alc262_hp_wildwest_automute(struct hda_codec *codec)
8537 struct alc_spec *spec = codec->spec;
8538 unsigned int presence;
8539 presence = snd_hda_codec_read(codec, 0x15, 0,
8540 AC_VERB_GET_PIN_SENSE, 0);
8541 spec->jack_present = !!(presence & AC_PINSENSE_PRESENCE);
8542 alc262_hp_master_update(codec);
8545 static void alc262_hp_wildwest_unsol_event(struct hda_codec *codec,
8548 if ((res >> 26) != ALC880_HP_EVENT)
8550 alc262_hp_wildwest_automute(codec);
8553 static int alc262_hp_master_sw_get(struct snd_kcontrol *kcontrol,
8554 struct snd_ctl_elem_value *ucontrol)
8556 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
8557 struct alc_spec *spec = codec->spec;
8558 *ucontrol->value.integer.value = spec->master_sw;
8562 static int alc262_hp_master_sw_put(struct snd_kcontrol *kcontrol,
8563 struct snd_ctl_elem_value *ucontrol)
8565 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
8566 struct alc_spec *spec = codec->spec;
8567 int val = !!*ucontrol->value.integer.value;
8569 if (val == spec->master_sw)
8571 spec->master_sw = val;
8572 alc262_hp_master_update(codec);
8576 static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
8578 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8579 .name = "Master Playback Switch",
8580 .info = snd_ctl_boolean_mono_info,
8581 .get = alc262_hp_master_sw_get,
8582 .put = alc262_hp_master_sw_put,
8584 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8585 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8586 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8587 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
8589 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
8591 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8592 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8593 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8594 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
8595 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
8596 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
8597 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8598 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8599 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8600 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8601 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
8602 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
8603 HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
8604 HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
8608 static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = {
8610 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8611 .name = "Master Playback Switch",
8612 .info = snd_ctl_boolean_mono_info,
8613 .get = alc262_hp_master_sw_get,
8614 .put = alc262_hp_master_sw_put,
8616 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8617 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8618 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8619 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8620 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
8622 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
8624 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x02, HDA_INPUT),
8625 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x02, HDA_INPUT),
8626 HDA_CODEC_VOLUME("Front Mic Boost", 0x1a, 0, HDA_INPUT),
8627 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
8628 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
8629 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8630 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8631 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
8632 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
8636 static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = {
8637 HDA_CODEC_VOLUME("Rear Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8638 HDA_CODEC_MUTE("Rear Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8639 HDA_CODEC_VOLUME("Rear Mic Boost", 0x18, 0, HDA_INPUT),
8643 /* mute/unmute internal speaker according to the hp jack and mute state */
8644 static void alc262_hp_t5735_automute(struct hda_codec *codec, int force)
8646 struct alc_spec *spec = codec->spec;
8648 if (force || !spec->sense_updated) {
8649 unsigned int present;
8650 present = snd_hda_codec_read(codec, 0x15, 0,
8651 AC_VERB_GET_PIN_SENSE, 0);
8652 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
8653 spec->sense_updated = 1;
8655 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0, HDA_AMP_MUTE,
8656 spec->jack_present ? HDA_AMP_MUTE : 0);
8659 static void alc262_hp_t5735_unsol_event(struct hda_codec *codec,
8662 if ((res >> 26) != ALC880_HP_EVENT)
8664 alc262_hp_t5735_automute(codec, 1);
8667 static void alc262_hp_t5735_init_hook(struct hda_codec *codec)
8669 alc262_hp_t5735_automute(codec, 1);
8672 static struct snd_kcontrol_new alc262_hp_t5735_mixer[] = {
8673 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8674 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8675 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8676 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8677 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8678 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8679 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8683 static struct hda_verb alc262_hp_t5735_verbs[] = {
8684 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8685 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8687 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8691 static struct snd_kcontrol_new alc262_hp_rp5700_mixer[] = {
8692 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8693 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8694 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
8695 HDA_CODEC_MUTE("Speaker Playback Switch", 0x16, 0x0, HDA_OUTPUT),
8696 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
8697 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
8701 static struct hda_verb alc262_hp_rp5700_verbs[] = {
8702 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8703 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8704 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8705 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8706 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
8707 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
8708 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
8709 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
8710 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
8711 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
8715 static struct hda_input_mux alc262_hp_rp5700_capture_source = {
8722 /* bind hp and internal speaker mute (with plug check) */
8723 static int alc262_sony_master_sw_put(struct snd_kcontrol *kcontrol,
8724 struct snd_ctl_elem_value *ucontrol)
8726 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
8727 long *valp = ucontrol->value.integer.value;
8730 /* change hp mute */
8731 change = snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
8733 valp[0] ? 0 : HDA_AMP_MUTE);
8734 change |= snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
8736 valp[1] ? 0 : HDA_AMP_MUTE);
8738 /* change speaker according to HP jack state */
8739 struct alc_spec *spec = codec->spec;
8741 if (spec->jack_present)
8742 mute = HDA_AMP_MUTE;
8744 mute = snd_hda_codec_amp_read(codec, 0x15, 0,
8746 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8747 HDA_AMP_MUTE, mute);
8752 static struct snd_kcontrol_new alc262_sony_mixer[] = {
8753 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8755 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8756 .name = "Master Playback Switch",
8757 .info = snd_hda_mixer_amp_switch_info,
8758 .get = snd_hda_mixer_amp_switch_get,
8759 .put = alc262_sony_master_sw_put,
8760 .private_value = HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
8762 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8763 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8764 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
8765 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
8769 static struct snd_kcontrol_new alc262_benq_t31_mixer[] = {
8770 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8771 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8772 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8773 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8774 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8775 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
8776 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
8780 #define alc262_capture_mixer alc882_capture_mixer
8781 #define alc262_capture_alt_mixer alc882_capture_alt_mixer
8784 * generic initialization of ADC, input mixers and output mixers
8786 static struct hda_verb alc262_init_verbs[] = {
8788 * Unmute ADC0-2 and set the default input to mic-in
8790 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
8791 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8792 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8793 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8794 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8795 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8797 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
8799 * Note: PASD motherboards uses the Line In 2 as the input for
8800 * front panel mic (mic 2)
8802 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
8803 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8804 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8805 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8806 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8807 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8810 * Set up output mixers (0x0c - 0x0e)
8812 /* set vol=0 to output mixers */
8813 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8814 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8815 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8816 /* set up input amps for analog loopback */
8817 /* Amp Indices: DAC = 0, mixer = 1 */
8818 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8819 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8820 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8821 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8822 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8823 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8825 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
8826 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
8827 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
8828 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
8829 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
8830 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
8832 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
8833 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
8834 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
8835 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
8836 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
8838 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8839 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
8841 /* FIXME: use matrix-type input source selection */
8842 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
8843 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
8844 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8845 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
8846 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
8847 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
8849 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8850 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
8851 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
8852 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
8854 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8855 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
8856 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
8857 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
8862 static struct hda_verb alc262_hippo_unsol_verbs[] = {
8863 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
8864 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8868 static struct hda_verb alc262_hippo1_unsol_verbs[] = {
8869 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
8870 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
8871 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
8873 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
8874 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8878 static struct hda_verb alc262_sony_unsol_verbs[] = {
8879 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
8880 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8881 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, // Front Mic
8883 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
8884 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8888 /* mute/unmute internal speaker according to the hp jack and mute state */
8889 static void alc262_hippo_automute(struct hda_codec *codec)
8891 struct alc_spec *spec = codec->spec;
8893 unsigned int present;
8895 /* need to execute and sync at first */
8896 snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
8897 present = snd_hda_codec_read(codec, 0x15, 0,
8898 AC_VERB_GET_PIN_SENSE, 0);
8899 spec->jack_present = (present & 0x80000000) != 0;
8900 if (spec->jack_present) {
8901 /* mute internal speaker */
8902 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8903 HDA_AMP_MUTE, HDA_AMP_MUTE);
8905 /* unmute internal speaker if necessary */
8906 mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0);
8907 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8908 HDA_AMP_MUTE, mute);
8912 /* unsolicited event for HP jack sensing */
8913 static void alc262_hippo_unsol_event(struct hda_codec *codec,
8916 if ((res >> 26) != ALC880_HP_EVENT)
8918 alc262_hippo_automute(codec);
8921 static void alc262_hippo1_automute(struct hda_codec *codec)
8924 unsigned int present;
8926 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
8927 present = snd_hda_codec_read(codec, 0x1b, 0,
8928 AC_VERB_GET_PIN_SENSE, 0);
8929 present = (present & 0x80000000) != 0;
8931 /* mute internal speaker */
8932 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8933 HDA_AMP_MUTE, HDA_AMP_MUTE);
8935 /* unmute internal speaker if necessary */
8936 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
8937 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8938 HDA_AMP_MUTE, mute);
8942 /* unsolicited event for HP jack sensing */
8943 static void alc262_hippo1_unsol_event(struct hda_codec *codec,
8946 if ((res >> 26) != ALC880_HP_EVENT)
8948 alc262_hippo1_automute(codec);
8953 * 0x14 = headphone/spdif-out, 0x15 = internal speaker,
8954 * 0x1b = port replicator headphone out
8957 #define ALC_HP_EVENT 0x37
8959 static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
8960 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
8961 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8962 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
8963 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8967 static struct hda_verb alc262_lenovo_3000_unsol_verbs[] = {
8968 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
8969 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8973 static struct hda_input_mux alc262_fujitsu_capture_source = {
8982 static struct hda_input_mux alc262_HP_capture_source = {
8986 { "Front Mic", 0x1 },
8993 static struct hda_input_mux alc262_HP_D7000_capture_source = {
8997 { "Front Mic", 0x2 },
9003 /* mute/unmute internal speaker according to the hp jacks and mute state */
9004 static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
9006 struct alc_spec *spec = codec->spec;
9009 if (force || !spec->sense_updated) {
9010 unsigned int present;
9011 /* need to execute and sync at first */
9012 snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
9013 /* check laptop HP jack */
9014 present = snd_hda_codec_read(codec, 0x14, 0,
9015 AC_VERB_GET_PIN_SENSE, 0);
9016 /* need to execute and sync at first */
9017 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
9018 /* check docking HP jack */
9019 present |= snd_hda_codec_read(codec, 0x1b, 0,
9020 AC_VERB_GET_PIN_SENSE, 0);
9021 if (present & AC_PINSENSE_PRESENCE)
9022 spec->jack_present = 1;
9024 spec->jack_present = 0;
9025 spec->sense_updated = 1;
9027 /* unmute internal speaker only if both HPs are unplugged and
9028 * master switch is on
9030 if (spec->jack_present)
9031 mute = HDA_AMP_MUTE;
9033 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
9034 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
9035 HDA_AMP_MUTE, mute);
9038 /* unsolicited event for HP jack sensing */
9039 static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
9042 if ((res >> 26) != ALC_HP_EVENT)
9044 alc262_fujitsu_automute(codec, 1);
9047 static void alc262_fujitsu_init_hook(struct hda_codec *codec)
9049 alc262_fujitsu_automute(codec, 1);
9052 /* bind volumes of both NID 0x0c and 0x0d */
9053 static struct hda_bind_ctls alc262_fujitsu_bind_master_vol = {
9054 .ops = &snd_hda_bind_vol,
9056 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
9057 HDA_COMPOSE_AMP_VAL(0x0d, 3, 0, HDA_OUTPUT),
9062 /* mute/unmute internal speaker according to the hp jack and mute state */
9063 static void alc262_lenovo_3000_automute(struct hda_codec *codec, int force)
9065 struct alc_spec *spec = codec->spec;
9068 if (force || !spec->sense_updated) {
9069 unsigned int present_int_hp;
9070 /* need to execute and sync at first */
9071 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
9072 present_int_hp = snd_hda_codec_read(codec, 0x1b, 0,
9073 AC_VERB_GET_PIN_SENSE, 0);
9074 spec->jack_present = (present_int_hp & 0x80000000) != 0;
9075 spec->sense_updated = 1;
9077 if (spec->jack_present) {
9078 /* mute internal speaker */
9079 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9080 HDA_AMP_MUTE, HDA_AMP_MUTE);
9081 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
9082 HDA_AMP_MUTE, HDA_AMP_MUTE);
9084 /* unmute internal speaker if necessary */
9085 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
9086 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9087 HDA_AMP_MUTE, mute);
9088 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
9089 HDA_AMP_MUTE, mute);
9093 /* unsolicited event for HP jack sensing */
9094 static void alc262_lenovo_3000_unsol_event(struct hda_codec *codec,
9097 if ((res >> 26) != ALC_HP_EVENT)
9099 alc262_lenovo_3000_automute(codec, 1);
9102 /* bind hp and internal speaker mute (with plug check) */
9103 static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
9104 struct snd_ctl_elem_value *ucontrol)
9106 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
9107 long *valp = ucontrol->value.integer.value;
9110 change = snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9112 valp ? 0 : HDA_AMP_MUTE);
9113 change |= snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
9115 valp ? 0 : HDA_AMP_MUTE);
9118 alc262_fujitsu_automute(codec, 0);
9122 static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
9123 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
9125 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9126 .name = "Master Playback Switch",
9127 .info = snd_hda_mixer_amp_switch_info,
9128 .get = snd_hda_mixer_amp_switch_get,
9129 .put = alc262_fujitsu_master_sw_put,
9130 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
9132 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9133 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9134 HDA_CODEC_VOLUME("PC Speaker Volume", 0x0b, 0x05, HDA_INPUT),
9135 HDA_CODEC_MUTE("PC Speaker Switch", 0x0b, 0x05, HDA_INPUT),
9136 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9137 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9138 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9139 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
9140 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
9141 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
9145 /* bind hp and internal speaker mute (with plug check) */
9146 static int alc262_lenovo_3000_master_sw_put(struct snd_kcontrol *kcontrol,
9147 struct snd_ctl_elem_value *ucontrol)
9149 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
9150 long *valp = ucontrol->value.integer.value;
9153 change = snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
9155 valp ? 0 : HDA_AMP_MUTE);
9158 alc262_lenovo_3000_automute(codec, 0);
9162 static struct snd_kcontrol_new alc262_lenovo_3000_mixer[] = {
9163 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
9165 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9166 .name = "Master Playback Switch",
9167 .info = snd_hda_mixer_amp_switch_info,
9168 .get = snd_hda_mixer_amp_switch_get,
9169 .put = alc262_lenovo_3000_master_sw_put,
9170 .private_value = HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
9172 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9173 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9174 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9175 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9176 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9177 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
9178 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
9179 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
9183 /* additional init verbs for Benq laptops */
9184 static struct hda_verb alc262_EAPD_verbs[] = {
9185 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
9186 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
9190 static struct hda_verb alc262_benq_t31_EAPD_verbs[] = {
9191 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9192 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
9194 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
9195 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
9199 /* Samsung Q1 Ultra Vista model setup */
9200 static struct snd_kcontrol_new alc262_ultra_mixer[] = {
9201 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9202 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
9203 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9204 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
9205 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
9206 HDA_CODEC_VOLUME("Headphone Mic Boost", 0x15, 0, HDA_INPUT),
9210 static struct hda_verb alc262_ultra_verbs[] = {
9212 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9213 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9214 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9216 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9217 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9218 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9219 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
9221 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9222 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9223 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9224 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9225 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9227 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
9228 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9229 /* ADC, choose mic */
9230 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9231 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9232 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9233 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
9234 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
9235 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
9236 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
9237 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
9238 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
9239 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(8)},
9243 /* mute/unmute internal speaker according to the hp jack and mute state */
9244 static void alc262_ultra_automute(struct hda_codec *codec)
9246 struct alc_spec *spec = codec->spec;
9250 /* auto-mute only when HP is used as HP */
9251 if (!spec->cur_mux[0]) {
9252 unsigned int present;
9253 /* need to execute and sync at first */
9254 snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
9255 present = snd_hda_codec_read(codec, 0x15, 0,
9256 AC_VERB_GET_PIN_SENSE, 0);
9257 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
9258 if (spec->jack_present)
9259 mute = HDA_AMP_MUTE;
9261 /* mute/unmute internal speaker */
9262 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9263 HDA_AMP_MUTE, mute);
9264 /* mute/unmute HP */
9265 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
9266 HDA_AMP_MUTE, mute ? 0 : HDA_AMP_MUTE);
9269 /* unsolicited event for HP jack sensing */
9270 static void alc262_ultra_unsol_event(struct hda_codec *codec,
9273 if ((res >> 26) != ALC880_HP_EVENT)
9275 alc262_ultra_automute(codec);
9278 static struct hda_input_mux alc262_ultra_capture_source = {
9282 { "Headphone", 0x7 },
9286 static int alc262_ultra_mux_enum_put(struct snd_kcontrol *kcontrol,
9287 struct snd_ctl_elem_value *ucontrol)
9289 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
9290 struct alc_spec *spec = codec->spec;
9293 ret = alc882_mux_enum_put(kcontrol, ucontrol);
9296 /* reprogram the HP pin as mic or HP according to the input source */
9297 snd_hda_codec_write_cache(codec, 0x15, 0,
9298 AC_VERB_SET_PIN_WIDGET_CONTROL,
9299 spec->cur_mux[0] ? PIN_VREF80 : PIN_HP);
9300 alc262_ultra_automute(codec); /* mute/unmute HP */
9304 static struct snd_kcontrol_new alc262_ultra_capture_mixer[] = {
9305 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
9306 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
9308 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9309 .name = "Capture Source",
9310 .info = alc882_mux_enum_info,
9311 .get = alc882_mux_enum_get,
9312 .put = alc262_ultra_mux_enum_put,
9317 /* add playback controls from the parsed DAC table */
9318 static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec,
9319 const struct auto_pin_cfg *cfg)
9324 spec->multiout.num_dacs = 1; /* only use one dac */
9325 spec->multiout.dac_nids = spec->private_dac_nids;
9326 spec->multiout.dac_nids[0] = 2;
9328 nid = cfg->line_out_pins[0];
9330 err = add_control(spec, ALC_CTL_WIDGET_VOL,
9331 "Front Playback Volume",
9332 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT));
9335 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
9336 "Front Playback Switch",
9337 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
9342 nid = cfg->speaker_pins[0];
9345 err = add_control(spec, ALC_CTL_WIDGET_VOL,
9346 "Speaker Playback Volume",
9347 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
9351 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
9352 "Speaker Playback Switch",
9353 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
9358 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
9359 "Speaker Playback Switch",
9360 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
9366 nid = cfg->hp_pins[0];
9368 /* spec->multiout.hp_nid = 2; */
9370 err = add_control(spec, ALC_CTL_WIDGET_VOL,
9371 "Headphone Playback Volume",
9372 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
9376 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
9377 "Headphone Playback Switch",
9378 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
9383 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
9384 "Headphone Playback Switch",
9385 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
9394 /* identical with ALC880 */
9395 #define alc262_auto_create_analog_input_ctls \
9396 alc880_auto_create_analog_input_ctls
9399 * generic initialization of ADC, input mixers and output mixers
9401 static struct hda_verb alc262_volume_init_verbs[] = {
9403 * Unmute ADC0-2 and set the default input to mic-in
9405 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
9406 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9407 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
9408 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9409 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
9410 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9412 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
9414 * Note: PASD motherboards uses the Line In 2 as the input for
9415 * front panel mic (mic 2)
9417 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
9418 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9419 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9420 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
9421 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
9422 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
9425 * Set up output mixers (0x0c - 0x0f)
9427 /* set vol=0 to output mixers */
9428 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9429 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9430 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9432 /* set up input amps for analog loopback */
9433 /* Amp Indices: DAC = 0, mixer = 1 */
9434 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9435 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9436 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9437 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9438 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9439 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9441 /* FIXME: use matrix-type input source selection */
9442 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
9443 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
9444 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9445 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
9446 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
9447 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
9449 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9450 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
9451 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
9452 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
9454 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9455 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
9456 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
9457 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
9462 static struct hda_verb alc262_HP_BPC_init_verbs[] = {
9464 * Unmute ADC0-2 and set the default input to mic-in
9466 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
9467 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9468 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
9469 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9470 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
9471 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9473 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
9475 * Note: PASD motherboards uses the Line In 2 as the input for
9476 * front panel mic (mic 2)
9478 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
9479 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9480 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9481 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
9482 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
9483 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
9484 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
9485 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
9488 * Set up output mixers (0x0c - 0x0e)
9490 /* set vol=0 to output mixers */
9491 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9492 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9493 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9495 /* set up input amps for analog loopback */
9496 /* Amp Indices: DAC = 0, mixer = 1 */
9497 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9498 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9499 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9500 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9501 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9502 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9504 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9505 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9506 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9508 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
9509 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
9511 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
9512 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9514 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9515 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
9516 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
9517 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9518 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9520 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
9521 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
9522 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
9523 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
9524 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
9525 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
9528 /* FIXME: use matrix-type input source selection */
9529 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
9530 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
9531 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9532 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
9533 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
9534 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
9536 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9537 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
9538 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
9539 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
9541 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9542 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
9543 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
9544 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
9546 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9551 static struct hda_verb alc262_HP_BPC_WildWest_init_verbs[] = {
9553 * Unmute ADC0-2 and set the default input to mic-in
9555 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
9556 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9557 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
9558 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9559 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
9560 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9562 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
9564 * Note: PASD motherboards uses the Line In 2 as the input for front
9567 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
9568 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9569 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9570 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
9571 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
9572 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
9573 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
9574 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
9575 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
9577 * Set up output mixers (0x0c - 0x0e)
9579 /* set vol=0 to output mixers */
9580 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9581 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9582 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9584 /* set up input amps for analog loopback */
9585 /* Amp Indices: DAC = 0, mixer = 1 */
9586 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9587 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9588 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9589 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9590 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9591 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9594 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP */
9595 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Mono */
9596 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* rear MIC */
9597 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* Line in */
9598 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
9599 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Line out */
9600 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD in */
9602 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
9603 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
9605 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
9606 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
9608 /* {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, */
9609 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
9610 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
9611 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
9612 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
9613 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
9615 /* FIXME: use matrix-type input source selection */
9616 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
9617 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
9618 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, /*rear MIC*/
9619 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, /*Line in*/
9620 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, /*F MIC*/
9621 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, /*Front*/
9622 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, /*CD*/
9623 /* {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
9624 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, /*HP*/
9626 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9627 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
9628 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
9629 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
9630 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
9631 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
9632 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
9634 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9635 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
9636 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
9637 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
9638 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
9639 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
9640 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
9642 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9647 #ifdef CONFIG_SND_HDA_POWER_SAVE
9648 #define alc262_loopbacks alc880_loopbacks
9651 /* pcm configuration: identiacal with ALC880 */
9652 #define alc262_pcm_analog_playback alc880_pcm_analog_playback
9653 #define alc262_pcm_analog_capture alc880_pcm_analog_capture
9654 #define alc262_pcm_digital_playback alc880_pcm_digital_playback
9655 #define alc262_pcm_digital_capture alc880_pcm_digital_capture
9658 * BIOS auto configuration
9660 static int alc262_parse_auto_config(struct hda_codec *codec)
9662 struct alc_spec *spec = codec->spec;
9664 static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
9666 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
9670 if (!spec->autocfg.line_outs)
9671 return 0; /* can't find valid BIOS pin config */
9672 err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg);
9675 err = alc262_auto_create_analog_input_ctls(spec, &spec->autocfg);
9679 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
9681 if (spec->autocfg.dig_out_pin)
9682 spec->multiout.dig_out_nid = ALC262_DIGOUT_NID;
9683 if (spec->autocfg.dig_in_pin)
9684 spec->dig_in_nid = ALC262_DIGIN_NID;
9686 if (spec->kctl_alloc)
9687 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
9689 spec->init_verbs[spec->num_init_verbs++] = alc262_volume_init_verbs;
9690 spec->num_mux_defs = 1;
9691 spec->input_mux = &spec->private_imux;
9693 err = alc_auto_add_mic_boost(codec);
9700 #define alc262_auto_init_multi_out alc882_auto_init_multi_out
9701 #define alc262_auto_init_hp_out alc882_auto_init_hp_out
9702 #define alc262_auto_init_analog_input alc882_auto_init_analog_input
9703 #define alc262_auto_init_input_src alc882_auto_init_input_src
9706 /* init callback for auto-configuration model -- overriding the default init */
9707 static void alc262_auto_init(struct hda_codec *codec)
9709 struct alc_spec *spec = codec->spec;
9710 alc262_auto_init_multi_out(codec);
9711 alc262_auto_init_hp_out(codec);
9712 alc262_auto_init_analog_input(codec);
9713 alc262_auto_init_input_src(codec);
9714 if (spec->unsol_event)
9715 alc_sku_automute(codec);
9719 * configuration and preset
9721 static const char *alc262_models[ALC262_MODEL_LAST] = {
9722 [ALC262_BASIC] = "basic",
9723 [ALC262_HIPPO] = "hippo",
9724 [ALC262_HIPPO_1] = "hippo_1",
9725 [ALC262_FUJITSU] = "fujitsu",
9726 [ALC262_HP_BPC] = "hp-bpc",
9727 [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000",
9728 [ALC262_HP_TC_T5735] = "hp-tc-t5735",
9729 [ALC262_HP_RP5700] = "hp-rp5700",
9730 [ALC262_BENQ_ED8] = "benq",
9731 [ALC262_BENQ_T31] = "benq-t31",
9732 [ALC262_SONY_ASSAMD] = "sony-assamd",
9733 [ALC262_ULTRA] = "ultra",
9734 [ALC262_LENOVO_3000] = "lenovo-3000",
9735 [ALC262_AUTO] = "auto",
9738 static struct snd_pci_quirk alc262_cfg_tbl[] = {
9739 SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO),
9740 SND_PCI_QUIRK(0x103c, 0x12fe, "HP xw9400", ALC262_HP_BPC),
9741 SND_PCI_QUIRK(0x103c, 0x12ff, "HP xw4550", ALC262_HP_BPC),
9742 SND_PCI_QUIRK(0x103c, 0x1306, "HP xw8600", ALC262_HP_BPC),
9743 SND_PCI_QUIRK(0x103c, 0x1307, "HP xw6600", ALC262_HP_BPC),
9744 SND_PCI_QUIRK(0x103c, 0x1308, "HP xw4600", ALC262_HP_BPC),
9745 SND_PCI_QUIRK(0x103c, 0x1309, "HP xw4*00", ALC262_HP_BPC),
9746 SND_PCI_QUIRK(0x103c, 0x130a, "HP xw6*00", ALC262_HP_BPC),
9747 SND_PCI_QUIRK(0x103c, 0x130b, "HP xw8*00", ALC262_HP_BPC),
9748 SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL),
9749 SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF),
9750 SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL),
9751 SND_PCI_QUIRK(0x103c, 0x2803, "HP D7000", ALC262_HP_BPC_D7000_WF),
9752 SND_PCI_QUIRK(0x103c, 0x2804, "HP D7000", ALC262_HP_BPC_D7000_WL),
9753 SND_PCI_QUIRK(0x103c, 0x2805, "HP D7000", ALC262_HP_BPC_D7000_WF),
9754 SND_PCI_QUIRK(0x103c, 0x2806, "HP D7000", ALC262_HP_BPC_D7000_WL),
9755 SND_PCI_QUIRK(0x103c, 0x2807, "HP D7000", ALC262_HP_BPC_D7000_WF),
9756 SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC),
9757 SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC),
9758 SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC),
9759 SND_PCI_QUIRK(0x103c, 0x302f, "HP Thin Client T5735",
9760 ALC262_HP_TC_T5735),
9761 SND_PCI_QUIRK(0x103c, 0x2817, "HP RP5700", ALC262_HP_RP5700),
9762 SND_PCI_QUIRK(0x104d, 0x1f00, "Sony ASSAMD", ALC262_SONY_ASSAMD),
9763 SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO),
9764 SND_PCI_QUIRK(0x104d, 0x820f, "Sony ASSAMD", ALC262_SONY_ASSAMD),
9765 SND_PCI_QUIRK(0x104d, 0x900e, "Sony ASSAMD", ALC262_SONY_ASSAMD),
9766 SND_PCI_QUIRK(0x104d, 0x9015, "Sony 0x9015", ALC262_SONY_ASSAMD),
9767 SND_PCI_QUIRK(0x1179, 0x0001, "Toshiba dynabook SS RX1",
9768 ALC262_SONY_ASSAMD),
9769 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
9770 SND_PCI_QUIRK(0x10cf, 0x142d, "Fujitsu Lifebook E8410", ALC262_FUJITSU),
9771 SND_PCI_QUIRK(0x144d, 0xc032, "Samsung Q1 Ultra", ALC262_ULTRA),
9772 SND_PCI_QUIRK(0x144d, 0xc039, "Samsung Q1U EL", ALC262_ULTRA),
9773 SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000 y410", ALC262_LENOVO_3000),
9774 SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
9775 SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_BENQ_T31),
9776 SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1),
9780 static struct alc_config_preset alc262_presets[] = {
9782 .mixers = { alc262_base_mixer },
9783 .init_verbs = { alc262_init_verbs },
9784 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9785 .dac_nids = alc262_dac_nids,
9787 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9788 .channel_mode = alc262_modes,
9789 .input_mux = &alc262_capture_source,
9792 .mixers = { alc262_base_mixer },
9793 .init_verbs = { alc262_init_verbs, alc262_hippo_unsol_verbs},
9794 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9795 .dac_nids = alc262_dac_nids,
9797 .dig_out_nid = ALC262_DIGOUT_NID,
9798 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9799 .channel_mode = alc262_modes,
9800 .input_mux = &alc262_capture_source,
9801 .unsol_event = alc262_hippo_unsol_event,
9802 .init_hook = alc262_hippo_automute,
9804 [ALC262_HIPPO_1] = {
9805 .mixers = { alc262_hippo1_mixer },
9806 .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs},
9807 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9808 .dac_nids = alc262_dac_nids,
9810 .dig_out_nid = ALC262_DIGOUT_NID,
9811 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9812 .channel_mode = alc262_modes,
9813 .input_mux = &alc262_capture_source,
9814 .unsol_event = alc262_hippo1_unsol_event,
9815 .init_hook = alc262_hippo1_automute,
9817 [ALC262_FUJITSU] = {
9818 .mixers = { alc262_fujitsu_mixer },
9819 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
9820 alc262_fujitsu_unsol_verbs },
9821 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9822 .dac_nids = alc262_dac_nids,
9824 .dig_out_nid = ALC262_DIGOUT_NID,
9825 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9826 .channel_mode = alc262_modes,
9827 .input_mux = &alc262_fujitsu_capture_source,
9828 .unsol_event = alc262_fujitsu_unsol_event,
9829 .init_hook = alc262_fujitsu_init_hook,
9832 .mixers = { alc262_HP_BPC_mixer },
9833 .init_verbs = { alc262_HP_BPC_init_verbs },
9834 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9835 .dac_nids = alc262_dac_nids,
9837 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9838 .channel_mode = alc262_modes,
9839 .input_mux = &alc262_HP_capture_source,
9840 .unsol_event = alc262_hp_bpc_unsol_event,
9841 .init_hook = alc262_hp_bpc_automute,
9843 [ALC262_HP_BPC_D7000_WF] = {
9844 .mixers = { alc262_HP_BPC_WildWest_mixer },
9845 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
9846 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9847 .dac_nids = alc262_dac_nids,
9849 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9850 .channel_mode = alc262_modes,
9851 .input_mux = &alc262_HP_D7000_capture_source,
9852 .unsol_event = alc262_hp_wildwest_unsol_event,
9853 .init_hook = alc262_hp_wildwest_automute,
9855 [ALC262_HP_BPC_D7000_WL] = {
9856 .mixers = { alc262_HP_BPC_WildWest_mixer,
9857 alc262_HP_BPC_WildWest_option_mixer },
9858 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
9859 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9860 .dac_nids = alc262_dac_nids,
9862 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9863 .channel_mode = alc262_modes,
9864 .input_mux = &alc262_HP_D7000_capture_source,
9865 .unsol_event = alc262_hp_wildwest_unsol_event,
9866 .init_hook = alc262_hp_wildwest_automute,
9868 [ALC262_HP_TC_T5735] = {
9869 .mixers = { alc262_hp_t5735_mixer },
9870 .init_verbs = { alc262_init_verbs, alc262_hp_t5735_verbs },
9871 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9872 .dac_nids = alc262_dac_nids,
9874 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9875 .channel_mode = alc262_modes,
9876 .input_mux = &alc262_capture_source,
9877 .unsol_event = alc262_hp_t5735_unsol_event,
9878 .init_hook = alc262_hp_t5735_init_hook,
9880 [ALC262_HP_RP5700] = {
9881 .mixers = { alc262_hp_rp5700_mixer },
9882 .init_verbs = { alc262_init_verbs, alc262_hp_rp5700_verbs },
9883 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9884 .dac_nids = alc262_dac_nids,
9885 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9886 .channel_mode = alc262_modes,
9887 .input_mux = &alc262_hp_rp5700_capture_source,
9889 [ALC262_BENQ_ED8] = {
9890 .mixers = { alc262_base_mixer },
9891 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
9892 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9893 .dac_nids = alc262_dac_nids,
9895 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9896 .channel_mode = alc262_modes,
9897 .input_mux = &alc262_capture_source,
9899 [ALC262_SONY_ASSAMD] = {
9900 .mixers = { alc262_sony_mixer },
9901 .init_verbs = { alc262_init_verbs, alc262_sony_unsol_verbs},
9902 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9903 .dac_nids = alc262_dac_nids,
9905 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9906 .channel_mode = alc262_modes,
9907 .input_mux = &alc262_capture_source,
9908 .unsol_event = alc262_hippo_unsol_event,
9909 .init_hook = alc262_hippo_automute,
9911 [ALC262_BENQ_T31] = {
9912 .mixers = { alc262_benq_t31_mixer },
9913 .init_verbs = { alc262_init_verbs, alc262_benq_t31_EAPD_verbs, alc262_hippo_unsol_verbs },
9914 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9915 .dac_nids = alc262_dac_nids,
9917 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9918 .channel_mode = alc262_modes,
9919 .input_mux = &alc262_capture_source,
9920 .unsol_event = alc262_hippo_unsol_event,
9921 .init_hook = alc262_hippo_automute,
9924 .mixers = { alc262_ultra_mixer, alc262_ultra_capture_mixer },
9925 .init_verbs = { alc262_ultra_verbs },
9926 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9927 .dac_nids = alc262_dac_nids,
9928 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9929 .channel_mode = alc262_modes,
9930 .input_mux = &alc262_ultra_capture_source,
9931 .adc_nids = alc262_adc_nids, /* ADC0 */
9932 .capsrc_nids = alc262_capsrc_nids,
9933 .num_adc_nids = 1, /* single ADC */
9934 .unsol_event = alc262_ultra_unsol_event,
9935 .init_hook = alc262_ultra_automute,
9937 [ALC262_LENOVO_3000] = {
9938 .mixers = { alc262_lenovo_3000_mixer },
9939 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
9940 alc262_lenovo_3000_unsol_verbs },
9941 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9942 .dac_nids = alc262_dac_nids,
9944 .dig_out_nid = ALC262_DIGOUT_NID,
9945 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9946 .channel_mode = alc262_modes,
9947 .input_mux = &alc262_fujitsu_capture_source,
9948 .unsol_event = alc262_lenovo_3000_unsol_event,
9952 static int patch_alc262(struct hda_codec *codec)
9954 struct alc_spec *spec;
9958 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
9964 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
9969 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
9970 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
9971 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
9972 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
9976 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
9978 board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST,
9982 if (board_config < 0) {
9983 printk(KERN_INFO "hda_codec: Unknown model for ALC262, "
9984 "trying auto-probe from BIOS...\n");
9985 board_config = ALC262_AUTO;
9988 if (board_config == ALC262_AUTO) {
9989 /* automatic parse from the BIOS config */
9990 err = alc262_parse_auto_config(codec);
9996 "hda_codec: Cannot set up configuration "
9997 "from BIOS. Using base mode...\n");
9998 board_config = ALC262_BASIC;
10002 if (board_config != ALC262_AUTO)
10003 setup_preset(spec, &alc262_presets[board_config]);
10005 spec->stream_name_analog = "ALC262 Analog";
10006 spec->stream_analog_playback = &alc262_pcm_analog_playback;
10007 spec->stream_analog_capture = &alc262_pcm_analog_capture;
10009 spec->stream_name_digital = "ALC262 Digital";
10010 spec->stream_digital_playback = &alc262_pcm_digital_playback;
10011 spec->stream_digital_capture = &alc262_pcm_digital_capture;
10013 if (!spec->adc_nids && spec->input_mux) {
10014 /* check whether NID 0x07 is valid */
10015 unsigned int wcap = get_wcaps(codec, 0x07);
10018 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
10019 if (wcap != AC_WID_AUD_IN) {
10020 spec->adc_nids = alc262_adc_nids_alt;
10021 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids_alt);
10022 spec->capsrc_nids = alc262_capsrc_nids_alt;
10023 spec->mixers[spec->num_mixers] =
10024 alc262_capture_alt_mixer;
10025 spec->num_mixers++;
10027 spec->adc_nids = alc262_adc_nids;
10028 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids);
10029 spec->capsrc_nids = alc262_capsrc_nids;
10030 spec->mixers[spec->num_mixers] = alc262_capture_mixer;
10031 spec->num_mixers++;
10035 spec->vmaster_nid = 0x0c;
10037 codec->patch_ops = alc_patch_ops;
10038 if (board_config == ALC262_AUTO)
10039 spec->init_hook = alc262_auto_init;
10040 #ifdef CONFIG_SND_HDA_POWER_SAVE
10041 if (!spec->loopback.amplist)
10042 spec->loopback.amplist = alc262_loopbacks;
10049 * ALC268 channel source setting (2 channel)
10051 #define ALC268_DIGOUT_NID ALC880_DIGOUT_NID
10052 #define alc268_modes alc260_modes
10054 static hda_nid_t alc268_dac_nids[2] = {
10059 static hda_nid_t alc268_adc_nids[2] = {
10064 static hda_nid_t alc268_adc_nids_alt[1] = {
10069 static hda_nid_t alc268_capsrc_nids[2] = { 0x23, 0x24 };
10071 static struct snd_kcontrol_new alc268_base_mixer[] = {
10072 /* output mixer control */
10073 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
10074 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
10075 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
10076 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10077 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10078 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10079 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
10083 /* bind Beep switches of both NID 0x0f and 0x10 */
10084 static struct hda_bind_ctls alc268_bind_beep_sw = {
10085 .ops = &snd_hda_bind_sw,
10087 HDA_COMPOSE_AMP_VAL(0x0f, 3, 1, HDA_INPUT),
10088 HDA_COMPOSE_AMP_VAL(0x10, 3, 1, HDA_INPUT),
10093 static struct snd_kcontrol_new alc268_beep_mixer[] = {
10094 HDA_CODEC_VOLUME("Beep Playback Volume", 0x1d, 0x0, HDA_INPUT),
10095 HDA_BIND_SW("Beep Playback Switch", &alc268_bind_beep_sw),
10099 static struct hda_verb alc268_eapd_verbs[] = {
10100 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
10101 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
10105 /* Toshiba specific */
10106 #define alc268_toshiba_automute alc262_hippo_automute
10108 static struct hda_verb alc268_toshiba_verbs[] = {
10109 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
10113 /* Acer specific */
10114 /* bind volumes of both NID 0x02 and 0x03 */
10115 static struct hda_bind_ctls alc268_acer_bind_master_vol = {
10116 .ops = &snd_hda_bind_vol,
10118 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
10119 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
10124 /* mute/unmute internal speaker according to the hp jack and mute state */
10125 static void alc268_acer_automute(struct hda_codec *codec, int force)
10127 struct alc_spec *spec = codec->spec;
10130 if (force || !spec->sense_updated) {
10131 unsigned int present;
10132 present = snd_hda_codec_read(codec, 0x14, 0,
10133 AC_VERB_GET_PIN_SENSE, 0);
10134 spec->jack_present = (present & 0x80000000) != 0;
10135 spec->sense_updated = 1;
10137 if (spec->jack_present)
10138 mute = HDA_AMP_MUTE; /* mute internal speaker */
10139 else /* unmute internal speaker if necessary */
10140 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
10141 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
10142 HDA_AMP_MUTE, mute);
10146 /* bind hp and internal speaker mute (with plug check) */
10147 static int alc268_acer_master_sw_put(struct snd_kcontrol *kcontrol,
10148 struct snd_ctl_elem_value *ucontrol)
10150 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10151 long *valp = ucontrol->value.integer.value;
10154 change = snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
10156 valp[0] ? 0 : HDA_AMP_MUTE);
10157 change |= snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
10159 valp[1] ? 0 : HDA_AMP_MUTE);
10161 alc268_acer_automute(codec, 0);
10165 static struct snd_kcontrol_new alc268_acer_mixer[] = {
10166 /* output mixer control */
10167 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
10169 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10170 .name = "Master Playback Switch",
10171 .info = snd_hda_mixer_amp_switch_info,
10172 .get = snd_hda_mixer_amp_switch_get,
10173 .put = alc268_acer_master_sw_put,
10174 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
10176 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10177 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
10178 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
10182 static struct hda_verb alc268_acer_verbs[] = {
10183 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* internal dmic? */
10184 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10185 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10186 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10187 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
10188 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
10190 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
10194 /* unsolicited event for HP jack sensing */
10195 static void alc268_toshiba_unsol_event(struct hda_codec *codec,
10198 if ((res >> 26) != ALC880_HP_EVENT)
10200 alc268_toshiba_automute(codec);
10203 static void alc268_acer_unsol_event(struct hda_codec *codec,
10206 if ((res >> 26) != ALC880_HP_EVENT)
10208 alc268_acer_automute(codec, 1);
10211 static void alc268_acer_init_hook(struct hda_codec *codec)
10213 alc268_acer_automute(codec, 1);
10216 static struct snd_kcontrol_new alc268_dell_mixer[] = {
10217 /* output mixer control */
10218 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
10219 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
10220 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
10221 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10222 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10223 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
10227 static struct hda_verb alc268_dell_verbs[] = {
10228 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10229 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10230 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
10234 /* mute/unmute internal speaker according to the hp jack and mute state */
10235 static void alc268_dell_automute(struct hda_codec *codec)
10237 unsigned int present;
10240 present = snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_PIN_SENSE, 0);
10241 if (present & 0x80000000)
10242 mute = HDA_AMP_MUTE;
10244 mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0);
10245 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10246 HDA_AMP_MUTE, mute);
10249 static void alc268_dell_unsol_event(struct hda_codec *codec,
10252 if ((res >> 26) != ALC880_HP_EVENT)
10254 alc268_dell_automute(codec);
10257 #define alc268_dell_init_hook alc268_dell_automute
10259 static struct snd_kcontrol_new alc267_quanta_il1_mixer[] = {
10260 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x2, 0x0, HDA_OUTPUT),
10261 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
10262 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
10263 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10264 HDA_CODEC_VOLUME("Mic Capture Volume", 0x23, 0x0, HDA_OUTPUT),
10265 HDA_BIND_MUTE("Mic Capture Switch", 0x23, 2, HDA_OUTPUT),
10266 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
10267 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
10271 static struct hda_verb alc267_quanta_il1_verbs[] = {
10272 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
10273 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
10277 static void alc267_quanta_il1_hp_automute(struct hda_codec *codec)
10279 unsigned int present;
10281 present = snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_PIN_SENSE, 0)
10282 & AC_PINSENSE_PRESENCE;
10283 snd_hda_codec_write(codec, 0x14, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
10284 present ? 0 : PIN_OUT);
10287 static void alc267_quanta_il1_mic_automute(struct hda_codec *codec)
10289 unsigned int present;
10291 present = snd_hda_codec_read(codec, 0x18, 0,
10292 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
10293 snd_hda_codec_write(codec, 0x23, 0,
10294 AC_VERB_SET_CONNECT_SEL,
10295 present ? 0x00 : 0x01);
10298 static void alc267_quanta_il1_automute(struct hda_codec *codec)
10300 alc267_quanta_il1_hp_automute(codec);
10301 alc267_quanta_il1_mic_automute(codec);
10304 static void alc267_quanta_il1_unsol_event(struct hda_codec *codec,
10307 switch (res >> 26) {
10308 case ALC880_HP_EVENT:
10309 alc267_quanta_il1_hp_automute(codec);
10311 case ALC880_MIC_EVENT:
10312 alc267_quanta_il1_mic_automute(codec);
10318 * generic initialization of ADC, input mixers and output mixers
10320 static struct hda_verb alc268_base_init_verbs[] = {
10321 /* Unmute DAC0-1 and set vol = 0 */
10322 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10323 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10324 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10325 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10326 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10327 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10330 * Set up output mixers (0x0c - 0x0e)
10332 /* set vol=0 to output mixers */
10333 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10334 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10335 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10336 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
10338 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10339 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10341 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
10342 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
10343 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
10344 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10345 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10346 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10347 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10348 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10350 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10351 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10352 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10353 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10354 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10355 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10356 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10358 /* set PCBEEP vol = 0, mute connections */
10359 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10360 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10361 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10363 /* Unmute Selector 23h,24h and set the default input to mic-in */
10365 {0x23, AC_VERB_SET_CONNECT_SEL, 0x00},
10366 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10367 {0x24, AC_VERB_SET_CONNECT_SEL, 0x00},
10368 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10374 * generic initialization of ADC, input mixers and output mixers
10376 static struct hda_verb alc268_volume_init_verbs[] = {
10377 /* set output DAC */
10378 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10379 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10380 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10381 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10383 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10384 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10385 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10386 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10387 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10389 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10390 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10391 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10392 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10393 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10395 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10396 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10397 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10398 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10400 /* set PCBEEP vol = 0, mute connections */
10401 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10402 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10403 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10408 #define alc268_mux_enum_info alc_mux_enum_info
10409 #define alc268_mux_enum_get alc_mux_enum_get
10410 #define alc268_mux_enum_put alc_mux_enum_put
10412 static struct snd_kcontrol_new alc268_capture_alt_mixer[] = {
10413 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
10414 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
10416 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10417 /* The multiple "Capture Source" controls confuse alsamixer
10418 * So call somewhat different..
10420 /* .name = "Capture Source", */
10421 .name = "Input Source",
10423 .info = alc268_mux_enum_info,
10424 .get = alc268_mux_enum_get,
10425 .put = alc268_mux_enum_put,
10430 static struct snd_kcontrol_new alc268_capture_mixer[] = {
10431 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
10432 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
10433 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x24, 0x0, HDA_OUTPUT),
10434 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x24, 0x0, HDA_OUTPUT),
10436 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10437 /* The multiple "Capture Source" controls confuse alsamixer
10438 * So call somewhat different..
10440 /* .name = "Capture Source", */
10441 .name = "Input Source",
10443 .info = alc268_mux_enum_info,
10444 .get = alc268_mux_enum_get,
10445 .put = alc268_mux_enum_put,
10450 static struct hda_input_mux alc268_capture_source = {
10454 { "Front Mic", 0x1 },
10460 static struct hda_input_mux alc268_acer_capture_source = {
10464 { "Internal Mic", 0x6 },
10469 #ifdef CONFIG_SND_DEBUG
10470 static struct snd_kcontrol_new alc268_test_mixer[] = {
10471 /* Volume widgets */
10472 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x02, 0x0, HDA_OUTPUT),
10473 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x03, 0x0, HDA_OUTPUT),
10474 HDA_BIND_MUTE_MONO("Mono sum Playback Switch", 0x0e, 1, 2, HDA_INPUT),
10475 HDA_BIND_MUTE("LINE-OUT sum Playback Switch", 0x0f, 2, HDA_INPUT),
10476 HDA_BIND_MUTE("HP-OUT sum Playback Switch", 0x10, 2, HDA_INPUT),
10477 HDA_BIND_MUTE("LINE-OUT Playback Switch", 0x14, 2, HDA_OUTPUT),
10478 HDA_BIND_MUTE("HP-OUT Playback Switch", 0x15, 2, HDA_OUTPUT),
10479 HDA_BIND_MUTE("Mono Playback Switch", 0x16, 2, HDA_OUTPUT),
10480 HDA_CODEC_VOLUME("MIC1 Capture Volume", 0x18, 0x0, HDA_INPUT),
10481 HDA_BIND_MUTE("MIC1 Capture Switch", 0x18, 2, HDA_OUTPUT),
10482 HDA_CODEC_VOLUME("MIC2 Capture Volume", 0x19, 0x0, HDA_INPUT),
10483 HDA_CODEC_VOLUME("LINE1 Capture Volume", 0x1a, 0x0, HDA_INPUT),
10484 HDA_BIND_MUTE("LINE1 Capture Switch", 0x1a, 2, HDA_OUTPUT),
10485 /* The below appears problematic on some hardwares */
10486 /*HDA_CODEC_VOLUME("PCBEEP Playback Volume", 0x1d, 0x0, HDA_INPUT),*/
10487 HDA_CODEC_VOLUME("PCM-IN1 Capture Volume", 0x23, 0x0, HDA_OUTPUT),
10488 HDA_BIND_MUTE("PCM-IN1 Capture Switch", 0x23, 2, HDA_OUTPUT),
10489 HDA_CODEC_VOLUME("PCM-IN2 Capture Volume", 0x24, 0x0, HDA_OUTPUT),
10490 HDA_BIND_MUTE("PCM-IN2 Capture Switch", 0x24, 2, HDA_OUTPUT),
10492 /* Modes for retasking pin widgets */
10493 ALC_PIN_MODE("LINE-OUT pin mode", 0x14, ALC_PIN_DIR_INOUT),
10494 ALC_PIN_MODE("HP-OUT pin mode", 0x15, ALC_PIN_DIR_INOUT),
10495 ALC_PIN_MODE("MIC1 pin mode", 0x18, ALC_PIN_DIR_INOUT),
10496 ALC_PIN_MODE("LINE1 pin mode", 0x1a, ALC_PIN_DIR_INOUT),
10498 /* Controls for GPIO pins, assuming they are configured as outputs */
10499 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
10500 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
10501 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
10502 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
10504 /* Switches to allow the digital SPDIF output pin to be enabled.
10505 * The ALC268 does not have an SPDIF input.
10507 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x06, 0x01),
10509 /* A switch allowing EAPD to be enabled. Some laptops seem to use
10510 * this output to turn on an external amplifier.
10512 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
10513 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
10519 /* create input playback/capture controls for the given pin */
10520 static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
10521 const char *ctlname, int idx)
10526 sprintf(name, "%s Playback Volume", ctlname);
10528 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
10529 HDA_COMPOSE_AMP_VAL(0x02, 3, idx,
10533 } else if (nid == 0x15) {
10534 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
10535 HDA_COMPOSE_AMP_VAL(0x03, 3, idx,
10541 sprintf(name, "%s Playback Switch", ctlname);
10542 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
10543 HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
10549 /* add playback controls from the parsed DAC table */
10550 static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec,
10551 const struct auto_pin_cfg *cfg)
10556 spec->multiout.num_dacs = 2; /* only use one dac */
10557 spec->multiout.dac_nids = spec->private_dac_nids;
10558 spec->multiout.dac_nids[0] = 2;
10559 spec->multiout.dac_nids[1] = 3;
10561 nid = cfg->line_out_pins[0];
10563 alc268_new_analog_output(spec, nid, "Front", 0);
10565 nid = cfg->speaker_pins[0];
10567 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10568 "Speaker Playback Volume",
10569 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
10573 nid = cfg->hp_pins[0];
10575 alc268_new_analog_output(spec, nid, "Headphone", 0);
10577 nid = cfg->line_out_pins[1] | cfg->line_out_pins[2];
10579 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10580 "Mono Playback Switch",
10581 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_INPUT));
10588 /* create playback/capture controls for input pins */
10589 static int alc268_auto_create_analog_input_ctls(struct alc_spec *spec,
10590 const struct auto_pin_cfg *cfg)
10592 struct hda_input_mux *imux = &spec->private_imux;
10595 for (i = 0; i < AUTO_PIN_LAST; i++) {
10596 switch(cfg->input_pins[i]) {
10598 idx1 = 0; /* Mic 1 */
10601 idx1 = 1; /* Mic 2 */
10604 idx1 = 2; /* Line In */
10611 idx1 = 6; /* digital mics */
10616 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
10617 imux->items[imux->num_items].index = idx1;
10623 static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec)
10625 struct alc_spec *spec = codec->spec;
10626 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
10627 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
10628 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
10629 unsigned int dac_vol1, dac_vol2;
10632 snd_hda_codec_write(codec, speaker_nid, 0,
10633 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
10634 snd_hda_codec_write(codec, 0x0f, 0,
10635 AC_VERB_SET_AMP_GAIN_MUTE,
10637 snd_hda_codec_write(codec, 0x10, 0,
10638 AC_VERB_SET_AMP_GAIN_MUTE,
10641 snd_hda_codec_write(codec, 0x0f, 0,
10642 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
10643 snd_hda_codec_write(codec, 0x10, 0,
10644 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
10647 dac_vol1 = dac_vol2 = 0xb000 | 0x40; /* set max volume */
10648 if (line_nid == 0x14)
10649 dac_vol2 = AMP_OUT_ZERO;
10650 else if (line_nid == 0x15)
10651 dac_vol1 = AMP_OUT_ZERO;
10652 if (hp_nid == 0x14)
10653 dac_vol2 = AMP_OUT_ZERO;
10654 else if (hp_nid == 0x15)
10655 dac_vol1 = AMP_OUT_ZERO;
10656 if (line_nid != 0x16 || hp_nid != 0x16 ||
10657 spec->autocfg.line_out_pins[1] != 0x16 ||
10658 spec->autocfg.line_out_pins[2] != 0x16)
10659 dac_vol1 = dac_vol2 = AMP_OUT_ZERO;
10661 snd_hda_codec_write(codec, 0x02, 0,
10662 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol1);
10663 snd_hda_codec_write(codec, 0x03, 0,
10664 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol2);
10667 /* pcm configuration: identiacal with ALC880 */
10668 #define alc268_pcm_analog_playback alc880_pcm_analog_playback
10669 #define alc268_pcm_analog_capture alc880_pcm_analog_capture
10670 #define alc268_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
10671 #define alc268_pcm_digital_playback alc880_pcm_digital_playback
10674 * BIOS auto configuration
10676 static int alc268_parse_auto_config(struct hda_codec *codec)
10678 struct alc_spec *spec = codec->spec;
10680 static hda_nid_t alc268_ignore[] = { 0 };
10682 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
10686 if (!spec->autocfg.line_outs)
10687 return 0; /* can't find valid BIOS pin config */
10689 err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg);
10692 err = alc268_auto_create_analog_input_ctls(spec, &spec->autocfg);
10696 spec->multiout.max_channels = 2;
10698 /* digital only support output */
10699 if (spec->autocfg.dig_out_pin)
10700 spec->multiout.dig_out_nid = ALC268_DIGOUT_NID;
10702 if (spec->kctl_alloc)
10703 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
10705 if (spec->autocfg.speaker_pins[0] != 0x1d)
10706 spec->mixers[spec->num_mixers++] = alc268_beep_mixer;
10708 spec->init_verbs[spec->num_init_verbs++] = alc268_volume_init_verbs;
10709 spec->num_mux_defs = 1;
10710 spec->input_mux = &spec->private_imux;
10712 err = alc_auto_add_mic_boost(codec);
10719 #define alc268_auto_init_multi_out alc882_auto_init_multi_out
10720 #define alc268_auto_init_hp_out alc882_auto_init_hp_out
10721 #define alc268_auto_init_analog_input alc882_auto_init_analog_input
10723 /* init callback for auto-configuration model -- overriding the default init */
10724 static void alc268_auto_init(struct hda_codec *codec)
10726 struct alc_spec *spec = codec->spec;
10727 alc268_auto_init_multi_out(codec);
10728 alc268_auto_init_hp_out(codec);
10729 alc268_auto_init_mono_speaker_out(codec);
10730 alc268_auto_init_analog_input(codec);
10731 if (spec->unsol_event)
10732 alc_sku_automute(codec);
10736 * configuration and preset
10738 static const char *alc268_models[ALC268_MODEL_LAST] = {
10739 [ALC267_QUANTA_IL1] = "quanta-il1",
10740 [ALC268_3ST] = "3stack",
10741 [ALC268_TOSHIBA] = "toshiba",
10742 [ALC268_ACER] = "acer",
10743 [ALC268_DELL] = "dell",
10744 [ALC268_ZEPTO] = "zepto",
10745 #ifdef CONFIG_SND_DEBUG
10746 [ALC268_TEST] = "test",
10748 [ALC268_AUTO] = "auto",
10751 static struct snd_pci_quirk alc268_cfg_tbl[] = {
10752 SND_PCI_QUIRK(0x1025, 0x011e, "Acer Aspire 5720z", ALC268_ACER),
10753 SND_PCI_QUIRK(0x1025, 0x0126, "Acer", ALC268_ACER),
10754 SND_PCI_QUIRK(0x1025, 0x012e, "Acer Aspire 5310", ALC268_ACER),
10755 SND_PCI_QUIRK(0x1025, 0x0130, "Acer Extensa 5210", ALC268_ACER),
10756 SND_PCI_QUIRK(0x1025, 0x0136, "Acer Aspire 5315", ALC268_ACER),
10757 SND_PCI_QUIRK(0x1028, 0x0253, "Dell OEM", ALC268_DELL),
10758 SND_PCI_QUIRK(0x103c, 0x30cc, "TOSHIBA", ALC268_TOSHIBA),
10759 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST),
10760 SND_PCI_QUIRK(0x1179, 0xff10, "TOSHIBA A205", ALC268_TOSHIBA),
10761 SND_PCI_QUIRK(0x1179, 0xff50, "TOSHIBA A305", ALC268_TOSHIBA),
10762 SND_PCI_QUIRK(0x14c0, 0x0025, "COMPAL IFL90/JFL-92", ALC268_TOSHIBA),
10763 SND_PCI_QUIRK(0x152d, 0x0763, "Diverse (CPR2000)", ALC268_ACER),
10764 SND_PCI_QUIRK(0x152d, 0x0771, "Quanta IL1", ALC267_QUANTA_IL1),
10765 SND_PCI_QUIRK(0x1170, 0x0040, "ZEPTO", ALC268_ZEPTO),
10769 static struct alc_config_preset alc268_presets[] = {
10770 [ALC267_QUANTA_IL1] = {
10771 .mixers = { alc267_quanta_il1_mixer },
10772 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
10773 alc267_quanta_il1_verbs },
10774 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
10775 .dac_nids = alc268_dac_nids,
10776 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
10777 .adc_nids = alc268_adc_nids_alt,
10779 .num_channel_mode = ARRAY_SIZE(alc268_modes),
10780 .channel_mode = alc268_modes,
10781 .input_mux = &alc268_capture_source,
10782 .unsol_event = alc267_quanta_il1_unsol_event,
10783 .init_hook = alc267_quanta_il1_automute,
10786 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
10787 alc268_beep_mixer },
10788 .init_verbs = { alc268_base_init_verbs },
10789 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
10790 .dac_nids = alc268_dac_nids,
10791 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
10792 .adc_nids = alc268_adc_nids_alt,
10793 .capsrc_nids = alc268_capsrc_nids,
10795 .dig_out_nid = ALC268_DIGOUT_NID,
10796 .num_channel_mode = ARRAY_SIZE(alc268_modes),
10797 .channel_mode = alc268_modes,
10798 .input_mux = &alc268_capture_source,
10800 [ALC268_TOSHIBA] = {
10801 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
10802 alc268_beep_mixer },
10803 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
10804 alc268_toshiba_verbs },
10805 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
10806 .dac_nids = alc268_dac_nids,
10807 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
10808 .adc_nids = alc268_adc_nids_alt,
10809 .capsrc_nids = alc268_capsrc_nids,
10811 .num_channel_mode = ARRAY_SIZE(alc268_modes),
10812 .channel_mode = alc268_modes,
10813 .input_mux = &alc268_capture_source,
10814 .unsol_event = alc268_toshiba_unsol_event,
10815 .init_hook = alc268_toshiba_automute,
10818 .mixers = { alc268_acer_mixer, alc268_capture_alt_mixer,
10819 alc268_beep_mixer },
10820 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
10821 alc268_acer_verbs },
10822 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
10823 .dac_nids = alc268_dac_nids,
10824 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
10825 .adc_nids = alc268_adc_nids_alt,
10826 .capsrc_nids = alc268_capsrc_nids,
10828 .num_channel_mode = ARRAY_SIZE(alc268_modes),
10829 .channel_mode = alc268_modes,
10830 .input_mux = &alc268_acer_capture_source,
10831 .unsol_event = alc268_acer_unsol_event,
10832 .init_hook = alc268_acer_init_hook,
10835 .mixers = { alc268_dell_mixer, alc268_beep_mixer },
10836 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
10837 alc268_dell_verbs },
10838 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
10839 .dac_nids = alc268_dac_nids,
10841 .num_channel_mode = ARRAY_SIZE(alc268_modes),
10842 .channel_mode = alc268_modes,
10843 .unsol_event = alc268_dell_unsol_event,
10844 .init_hook = alc268_dell_init_hook,
10845 .input_mux = &alc268_capture_source,
10848 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
10849 alc268_beep_mixer },
10850 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
10851 alc268_toshiba_verbs },
10852 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
10853 .dac_nids = alc268_dac_nids,
10854 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
10855 .adc_nids = alc268_adc_nids_alt,
10856 .capsrc_nids = alc268_capsrc_nids,
10858 .dig_out_nid = ALC268_DIGOUT_NID,
10859 .num_channel_mode = ARRAY_SIZE(alc268_modes),
10860 .channel_mode = alc268_modes,
10861 .input_mux = &alc268_capture_source,
10862 .unsol_event = alc268_toshiba_unsol_event,
10863 .init_hook = alc268_toshiba_automute
10865 #ifdef CONFIG_SND_DEBUG
10867 .mixers = { alc268_test_mixer, alc268_capture_mixer },
10868 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
10869 alc268_volume_init_verbs },
10870 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
10871 .dac_nids = alc268_dac_nids,
10872 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
10873 .adc_nids = alc268_adc_nids_alt,
10874 .capsrc_nids = alc268_capsrc_nids,
10876 .dig_out_nid = ALC268_DIGOUT_NID,
10877 .num_channel_mode = ARRAY_SIZE(alc268_modes),
10878 .channel_mode = alc268_modes,
10879 .input_mux = &alc268_capture_source,
10884 static int patch_alc268(struct hda_codec *codec)
10886 struct alc_spec *spec;
10890 spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
10894 codec->spec = spec;
10896 board_config = snd_hda_check_board_config(codec, ALC268_MODEL_LAST,
10900 if (board_config < 0 || board_config >= ALC268_MODEL_LAST) {
10901 printk(KERN_INFO "hda_codec: Unknown model for ALC268, "
10902 "trying auto-probe from BIOS...\n");
10903 board_config = ALC268_AUTO;
10906 if (board_config == ALC268_AUTO) {
10907 /* automatic parse from the BIOS config */
10908 err = alc268_parse_auto_config(codec);
10914 "hda_codec: Cannot set up configuration "
10915 "from BIOS. Using base mode...\n");
10916 board_config = ALC268_3ST;
10920 if (board_config != ALC268_AUTO)
10921 setup_preset(spec, &alc268_presets[board_config]);
10923 if (codec->vendor_id == 0x10ec0267) {
10924 spec->stream_name_analog = "ALC267 Analog";
10925 spec->stream_name_digital = "ALC267 Digital";
10927 spec->stream_name_analog = "ALC268 Analog";
10928 spec->stream_name_digital = "ALC268 Digital";
10931 spec->stream_analog_playback = &alc268_pcm_analog_playback;
10932 spec->stream_analog_capture = &alc268_pcm_analog_capture;
10933 spec->stream_analog_alt_capture = &alc268_pcm_analog_alt_capture;
10935 spec->stream_digital_playback = &alc268_pcm_digital_playback;
10937 if (!query_amp_caps(codec, 0x1d, HDA_INPUT))
10938 /* override the amp caps for beep generator */
10939 snd_hda_override_amp_caps(codec, 0x1d, HDA_INPUT,
10940 (0x0c << AC_AMPCAP_OFFSET_SHIFT) |
10941 (0x0c << AC_AMPCAP_NUM_STEPS_SHIFT) |
10942 (0x07 << AC_AMPCAP_STEP_SIZE_SHIFT) |
10943 (0 << AC_AMPCAP_MUTE_SHIFT));
10945 if (!spec->adc_nids && spec->input_mux) {
10946 /* check whether NID 0x07 is valid */
10947 unsigned int wcap = get_wcaps(codec, 0x07);
10951 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
10952 if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
10953 spec->adc_nids = alc268_adc_nids_alt;
10954 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt);
10955 spec->mixers[spec->num_mixers] =
10956 alc268_capture_alt_mixer;
10957 spec->num_mixers++;
10959 spec->adc_nids = alc268_adc_nids;
10960 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids);
10961 spec->mixers[spec->num_mixers] =
10962 alc268_capture_mixer;
10963 spec->num_mixers++;
10965 spec->capsrc_nids = alc268_capsrc_nids;
10966 /* set default input source */
10967 for (i = 0; i < spec->num_adc_nids; i++)
10968 snd_hda_codec_write_cache(codec, alc268_capsrc_nids[i],
10969 0, AC_VERB_SET_CONNECT_SEL,
10970 spec->input_mux->items[0].index);
10973 spec->vmaster_nid = 0x02;
10975 codec->patch_ops = alc_patch_ops;
10976 if (board_config == ALC268_AUTO)
10977 spec->init_hook = alc268_auto_init;
10983 * ALC269 channel source setting (2 channel)
10985 #define ALC269_DIGOUT_NID ALC880_DIGOUT_NID
10987 #define alc269_dac_nids alc260_dac_nids
10989 static hda_nid_t alc269_adc_nids[1] = {
10994 static struct hda_input_mux alc269_eeepc_dmic_capture_source = {
11002 static struct hda_input_mux alc269_eeepc_amic_capture_source = {
11010 #define alc269_modes alc260_modes
11011 #define alc269_capture_source alc880_lg_lw_capture_source
11013 static struct snd_kcontrol_new alc269_base_mixer[] = {
11014 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
11015 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11016 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
11017 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
11018 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11019 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11020 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11021 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11022 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
11023 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
11024 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11025 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
11029 /* bind volumes of both NID 0x0c and 0x0d */
11030 static struct hda_bind_ctls alc269_epc_bind_vol = {
11031 .ops = &snd_hda_bind_vol,
11033 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
11034 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
11039 static struct snd_kcontrol_new alc269_eeepc_mixer[] = {
11040 HDA_CODEC_MUTE("iSpeaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11041 HDA_BIND_VOL("LineOut Playback Volume", &alc269_epc_bind_vol),
11042 HDA_CODEC_MUTE("LineOut Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11046 /* capture mixer elements */
11047 static struct snd_kcontrol_new alc269_capture_mixer[] = {
11048 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
11049 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
11051 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11052 /* The multiple "Capture Source" controls confuse alsamixer
11053 * So call somewhat different..
11055 /* .name = "Capture Source", */
11056 .name = "Input Source",
11058 .info = alc_mux_enum_info,
11059 .get = alc_mux_enum_get,
11060 .put = alc_mux_enum_put,
11065 /* capture mixer elements */
11066 static struct snd_kcontrol_new alc269_epc_capture_mixer[] = {
11067 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
11068 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
11073 * generic initialization of ADC, input mixers and output mixers
11075 static struct hda_verb alc269_init_verbs[] = {
11077 * Unmute ADC0 and set the default input to mic-in
11079 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11081 /* Mute input amps (PCBeep, Line In, Mic 1 & Mic 2) of the
11082 * analog-loopback mixer widget
11083 * Note: PASD motherboards uses the Line In 2 as the input for
11084 * front panel mic (mic 2)
11086 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
11087 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11088 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11089 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11090 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11091 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
11094 * Set up output mixers (0x0c - 0x0e)
11096 /* set vol=0 to output mixers */
11097 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11098 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11100 /* set up input amps for analog loopback */
11101 /* Amp Indices: DAC = 0, mixer = 1 */
11102 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11103 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11104 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11105 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11106 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11107 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11109 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11110 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11111 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11112 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
11113 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
11114 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11115 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11117 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11118 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11119 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11120 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11121 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11122 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11123 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11125 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
11126 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11128 /* FIXME: use matrix-type input source selection */
11129 /* Mixer elements: 0x18, 19, 1a, 1b, 1d, 0b */
11130 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
11131 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11132 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11133 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11134 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11137 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
11138 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
11142 static struct hda_verb alc269_eeepc_dmic_init_verbs[] = {
11143 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
11144 {0x23, AC_VERB_SET_CONNECT_SEL, 0x05},
11145 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
11146 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))},
11147 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11148 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
11149 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11153 static struct hda_verb alc269_eeepc_amic_init_verbs[] = {
11154 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
11155 {0x23, AC_VERB_SET_CONNECT_SEL, 0x01},
11156 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
11157 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x701b | (0x00 << 8))},
11158 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
11159 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11163 /* toggle speaker-output according to the hp-jack state */
11164 static void alc269_speaker_automute(struct hda_codec *codec)
11166 unsigned int present;
11169 present = snd_hda_codec_read(codec, 0x15, 0,
11170 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
11171 bits = present ? AMP_IN_MUTE(0) : 0;
11172 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
11173 AMP_IN_MUTE(0), bits);
11174 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
11175 AMP_IN_MUTE(0), bits);
11178 static void alc269_eeepc_dmic_automute(struct hda_codec *codec)
11180 unsigned int present;
11182 present = snd_hda_codec_read(codec, 0x18, 0, AC_VERB_GET_PIN_SENSE, 0)
11183 & AC_PINSENSE_PRESENCE;
11184 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_CONNECT_SEL,
11188 static void alc269_eeepc_amic_automute(struct hda_codec *codec)
11190 unsigned int present;
11192 present = snd_hda_codec_read(codec, 0x18, 0, AC_VERB_GET_PIN_SENSE, 0)
11193 & AC_PINSENSE_PRESENCE;
11194 snd_hda_codec_write(codec, 0x24, 0, AC_VERB_SET_AMP_GAIN_MUTE,
11195 present ? AMP_IN_UNMUTE(0) : AMP_IN_MUTE(0));
11196 snd_hda_codec_write(codec, 0x24, 0, AC_VERB_SET_AMP_GAIN_MUTE,
11197 present ? AMP_IN_MUTE(1) : AMP_IN_UNMUTE(1));
11200 /* unsolicited event for HP jack sensing */
11201 static void alc269_eeepc_dmic_unsol_event(struct hda_codec *codec,
11204 if ((res >> 26) == ALC880_HP_EVENT)
11205 alc269_speaker_automute(codec);
11207 if ((res >> 26) == ALC880_MIC_EVENT)
11208 alc269_eeepc_dmic_automute(codec);
11211 static void alc269_eeepc_dmic_inithook(struct hda_codec *codec)
11213 alc269_speaker_automute(codec);
11214 alc269_eeepc_dmic_automute(codec);
11217 /* unsolicited event for HP jack sensing */
11218 static void alc269_eeepc_amic_unsol_event(struct hda_codec *codec,
11221 if ((res >> 26) == ALC880_HP_EVENT)
11222 alc269_speaker_automute(codec);
11224 if ((res >> 26) == ALC880_MIC_EVENT)
11225 alc269_eeepc_amic_automute(codec);
11228 static void alc269_eeepc_amic_inithook(struct hda_codec *codec)
11230 alc269_speaker_automute(codec);
11231 alc269_eeepc_amic_automute(codec);
11234 /* add playback controls from the parsed DAC table */
11235 static int alc269_auto_create_multi_out_ctls(struct alc_spec *spec,
11236 const struct auto_pin_cfg *cfg)
11241 spec->multiout.num_dacs = 1; /* only use one dac */
11242 spec->multiout.dac_nids = spec->private_dac_nids;
11243 spec->multiout.dac_nids[0] = 2;
11245 nid = cfg->line_out_pins[0];
11247 err = add_control(spec, ALC_CTL_WIDGET_VOL,
11248 "Front Playback Volume",
11249 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT));
11252 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
11253 "Front Playback Switch",
11254 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
11259 nid = cfg->speaker_pins[0];
11261 if (!cfg->line_out_pins[0]) {
11262 err = add_control(spec, ALC_CTL_WIDGET_VOL,
11263 "Speaker Playback Volume",
11264 HDA_COMPOSE_AMP_VAL(0x02, 3, 0,
11270 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
11271 "Speaker Playback Switch",
11272 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
11277 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
11278 "Speaker Playback Switch",
11279 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
11285 nid = cfg->hp_pins[0];
11287 /* spec->multiout.hp_nid = 2; */
11288 if (!cfg->line_out_pins[0] && !cfg->speaker_pins[0]) {
11289 err = add_control(spec, ALC_CTL_WIDGET_VOL,
11290 "Headphone Playback Volume",
11291 HDA_COMPOSE_AMP_VAL(0x02, 3, 0,
11297 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
11298 "Headphone Playback Switch",
11299 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
11304 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
11305 "Headphone Playback Switch",
11306 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
11315 #define alc269_auto_create_analog_input_ctls \
11316 alc880_auto_create_analog_input_ctls
11318 #ifdef CONFIG_SND_HDA_POWER_SAVE
11319 #define alc269_loopbacks alc880_loopbacks
11322 /* pcm configuration: identiacal with ALC880 */
11323 #define alc269_pcm_analog_playback alc880_pcm_analog_playback
11324 #define alc269_pcm_analog_capture alc880_pcm_analog_capture
11325 #define alc269_pcm_digital_playback alc880_pcm_digital_playback
11326 #define alc269_pcm_digital_capture alc880_pcm_digital_capture
11329 * BIOS auto configuration
11331 static int alc269_parse_auto_config(struct hda_codec *codec)
11333 struct alc_spec *spec = codec->spec;
11335 static hda_nid_t alc269_ignore[] = { 0x1d, 0 };
11337 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
11342 err = alc269_auto_create_multi_out_ctls(spec, &spec->autocfg);
11345 err = alc269_auto_create_analog_input_ctls(spec, &spec->autocfg);
11349 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
11351 if (spec->autocfg.dig_out_pin)
11352 spec->multiout.dig_out_nid = ALC269_DIGOUT_NID;
11354 if (spec->kctl_alloc)
11355 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
11357 spec->init_verbs[spec->num_init_verbs++] = alc269_init_verbs;
11358 spec->num_mux_defs = 1;
11359 spec->input_mux = &spec->private_imux;
11361 err = alc_auto_add_mic_boost(codec);
11365 spec->mixers[spec->num_mixers] = alc269_capture_mixer;
11366 spec->num_mixers++;
11371 #define alc269_auto_init_multi_out alc882_auto_init_multi_out
11372 #define alc269_auto_init_hp_out alc882_auto_init_hp_out
11373 #define alc269_auto_init_analog_input alc882_auto_init_analog_input
11376 /* init callback for auto-configuration model -- overriding the default init */
11377 static void alc269_auto_init(struct hda_codec *codec)
11379 struct alc_spec *spec = codec->spec;
11380 alc269_auto_init_multi_out(codec);
11381 alc269_auto_init_hp_out(codec);
11382 alc269_auto_init_analog_input(codec);
11383 if (spec->unsol_event)
11384 alc_sku_automute(codec);
11388 * configuration and preset
11390 static const char *alc269_models[ALC269_MODEL_LAST] = {
11391 [ALC269_BASIC] = "basic",
11394 static struct snd_pci_quirk alc269_cfg_tbl[] = {
11395 SND_PCI_QUIRK(0x1043, 0x8330, "ASUS Eeepc P703 P900A",
11396 ALC269_ASUS_EEEPC_P703),
11397 SND_PCI_QUIRK(0x1043, 0x831a, "ASUS Eeepc P901",
11398 ALC269_ASUS_EEEPC_P901),
11402 static struct alc_config_preset alc269_presets[] = {
11404 .mixers = { alc269_base_mixer, alc269_capture_mixer },
11405 .init_verbs = { alc269_init_verbs },
11406 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
11407 .dac_nids = alc269_dac_nids,
11409 .num_channel_mode = ARRAY_SIZE(alc269_modes),
11410 .channel_mode = alc269_modes,
11411 .input_mux = &alc269_capture_source,
11413 [ALC269_ASUS_EEEPC_P703] = {
11414 .mixers = { alc269_eeepc_mixer, alc269_epc_capture_mixer },
11415 .init_verbs = { alc269_init_verbs,
11416 alc269_eeepc_amic_init_verbs },
11417 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
11418 .dac_nids = alc269_dac_nids,
11420 .num_channel_mode = ARRAY_SIZE(alc269_modes),
11421 .channel_mode = alc269_modes,
11422 .input_mux = &alc269_eeepc_amic_capture_source,
11423 .unsol_event = alc269_eeepc_amic_unsol_event,
11424 .init_hook = alc269_eeepc_amic_inithook,
11426 [ALC269_ASUS_EEEPC_P901] = {
11427 .mixers = { alc269_eeepc_mixer, alc269_epc_capture_mixer},
11428 .init_verbs = { alc269_init_verbs,
11429 alc269_eeepc_dmic_init_verbs },
11430 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
11431 .dac_nids = alc269_dac_nids,
11433 .num_channel_mode = ARRAY_SIZE(alc269_modes),
11434 .channel_mode = alc269_modes,
11435 .input_mux = &alc269_eeepc_dmic_capture_source,
11436 .unsol_event = alc269_eeepc_dmic_unsol_event,
11437 .init_hook = alc269_eeepc_dmic_inithook,
11441 static int patch_alc269(struct hda_codec *codec)
11443 struct alc_spec *spec;
11447 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
11451 codec->spec = spec;
11453 alc_fix_pll_init(codec, 0x20, 0x04, 15);
11455 board_config = snd_hda_check_board_config(codec, ALC269_MODEL_LAST,
11459 if (board_config < 0) {
11460 printk(KERN_INFO "hda_codec: Unknown model for ALC269, "
11461 "trying auto-probe from BIOS...\n");
11462 board_config = ALC269_AUTO;
11465 if (board_config == ALC269_AUTO) {
11466 /* automatic parse from the BIOS config */
11467 err = alc269_parse_auto_config(codec);
11473 "hda_codec: Cannot set up configuration "
11474 "from BIOS. Using base mode...\n");
11475 board_config = ALC269_BASIC;
11479 if (board_config != ALC269_AUTO)
11480 setup_preset(spec, &alc269_presets[board_config]);
11482 spec->stream_name_analog = "ALC269 Analog";
11483 spec->stream_analog_playback = &alc269_pcm_analog_playback;
11484 spec->stream_analog_capture = &alc269_pcm_analog_capture;
11486 spec->stream_name_digital = "ALC269 Digital";
11487 spec->stream_digital_playback = &alc269_pcm_digital_playback;
11488 spec->stream_digital_capture = &alc269_pcm_digital_capture;
11490 spec->adc_nids = alc269_adc_nids;
11491 spec->num_adc_nids = ARRAY_SIZE(alc269_adc_nids);
11493 codec->patch_ops = alc_patch_ops;
11494 if (board_config == ALC269_AUTO)
11495 spec->init_hook = alc269_auto_init;
11496 #ifdef CONFIG_SND_HDA_POWER_SAVE
11497 if (!spec->loopback.amplist)
11498 spec->loopback.amplist = alc269_loopbacks;
11505 * ALC861 channel source setting (2/6 channel selection for 3-stack)
11509 * set the path ways for 2 channel output
11510 * need to set the codec line out and mic 1 pin widgets to inputs
11512 static struct hda_verb alc861_threestack_ch2_init[] = {
11513 /* set pin widget 1Ah (line in) for input */
11514 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
11515 /* set pin widget 18h (mic1/2) for input, for mic also enable
11518 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
11520 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
11522 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
11523 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
11529 * need to set the codec line out and mic 1 pin widgets to outputs
11531 static struct hda_verb alc861_threestack_ch6_init[] = {
11532 /* set pin widget 1Ah (line in) for output (Back Surround)*/
11533 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
11534 /* set pin widget 18h (mic1) for output (CLFE)*/
11535 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
11537 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
11538 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
11540 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
11542 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
11543 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
11548 static struct hda_channel_mode alc861_threestack_modes[2] = {
11549 { 2, alc861_threestack_ch2_init },
11550 { 6, alc861_threestack_ch6_init },
11552 /* Set mic1 as input and unmute the mixer */
11553 static struct hda_verb alc861_uniwill_m31_ch2_init[] = {
11554 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
11555 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
11558 /* Set mic1 as output and mute mixer */
11559 static struct hda_verb alc861_uniwill_m31_ch4_init[] = {
11560 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
11561 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
11565 static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
11566 { 2, alc861_uniwill_m31_ch2_init },
11567 { 4, alc861_uniwill_m31_ch4_init },
11570 /* Set mic1 and line-in as input and unmute the mixer */
11571 static struct hda_verb alc861_asus_ch2_init[] = {
11572 /* set pin widget 1Ah (line in) for input */
11573 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
11574 /* set pin widget 18h (mic1/2) for input, for mic also enable
11577 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
11579 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
11581 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
11582 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
11586 /* Set mic1 nad line-in as output and mute mixer */
11587 static struct hda_verb alc861_asus_ch6_init[] = {
11588 /* set pin widget 1Ah (line in) for output (Back Surround)*/
11589 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
11590 /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
11591 /* set pin widget 18h (mic1) for output (CLFE)*/
11592 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
11593 /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
11594 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
11595 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
11597 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
11599 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
11600 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
11605 static struct hda_channel_mode alc861_asus_modes[2] = {
11606 { 2, alc861_asus_ch2_init },
11607 { 6, alc861_asus_ch6_init },
11612 static struct snd_kcontrol_new alc861_base_mixer[] = {
11613 /* output mixer control */
11614 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
11615 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
11616 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
11617 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
11618 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
11620 /*Input mixer control */
11621 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
11622 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
11623 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
11624 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
11625 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
11626 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
11627 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
11628 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
11629 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
11630 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
11632 /* Capture mixer control */
11633 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
11634 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
11636 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11637 .name = "Capture Source",
11639 .info = alc_mux_enum_info,
11640 .get = alc_mux_enum_get,
11641 .put = alc_mux_enum_put,
11646 static struct snd_kcontrol_new alc861_3ST_mixer[] = {
11647 /* output mixer control */
11648 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
11649 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
11650 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
11651 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
11652 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
11654 /* Input mixer control */
11655 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
11656 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
11657 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
11658 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
11659 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
11660 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
11661 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
11662 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
11663 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
11664 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
11666 /* Capture mixer control */
11667 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
11668 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
11670 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11671 .name = "Capture Source",
11673 .info = alc_mux_enum_info,
11674 .get = alc_mux_enum_get,
11675 .put = alc_mux_enum_put,
11678 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11679 .name = "Channel Mode",
11680 .info = alc_ch_mode_info,
11681 .get = alc_ch_mode_get,
11682 .put = alc_ch_mode_put,
11683 .private_value = ARRAY_SIZE(alc861_threestack_modes),
11688 static struct snd_kcontrol_new alc861_toshiba_mixer[] = {
11689 /* output mixer control */
11690 HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT),
11691 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
11692 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
11694 /*Capture mixer control */
11695 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
11696 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
11698 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11699 .name = "Capture Source",
11701 .info = alc_mux_enum_info,
11702 .get = alc_mux_enum_get,
11703 .put = alc_mux_enum_put,
11709 static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
11710 /* output mixer control */
11711 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
11712 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
11713 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
11714 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
11715 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
11717 /* Input mixer control */
11718 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
11719 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
11720 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
11721 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
11722 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
11723 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
11724 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
11725 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
11726 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
11727 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
11729 /* Capture mixer control */
11730 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
11731 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
11733 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11734 .name = "Capture Source",
11736 .info = alc_mux_enum_info,
11737 .get = alc_mux_enum_get,
11738 .put = alc_mux_enum_put,
11741 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11742 .name = "Channel Mode",
11743 .info = alc_ch_mode_info,
11744 .get = alc_ch_mode_get,
11745 .put = alc_ch_mode_put,
11746 .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
11751 static struct snd_kcontrol_new alc861_asus_mixer[] = {
11752 /* output mixer control */
11753 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
11754 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
11755 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
11756 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
11757 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
11759 /* Input mixer control */
11760 HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
11761 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11762 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
11763 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
11764 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
11765 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
11766 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
11767 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
11768 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
11769 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT),
11771 /* Capture mixer control */
11772 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
11773 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
11775 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11776 .name = "Capture Source",
11778 .info = alc_mux_enum_info,
11779 .get = alc_mux_enum_get,
11780 .put = alc_mux_enum_put,
11783 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11784 .name = "Channel Mode",
11785 .info = alc_ch_mode_info,
11786 .get = alc_ch_mode_get,
11787 .put = alc_ch_mode_put,
11788 .private_value = ARRAY_SIZE(alc861_asus_modes),
11793 /* additional mixer */
11794 static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = {
11795 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
11796 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
11797 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x23, 0x0, HDA_OUTPUT),
11798 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x23, 0x0, HDA_OUTPUT),
11803 * generic initialization of ADC, input mixers and output mixers
11805 static struct hda_verb alc861_base_init_verbs[] = {
11807 * Unmute ADC0 and set the default input to mic-in
11809 /* port-A for surround (rear panel) */
11810 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
11811 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
11812 /* port-B for mic-in (rear panel) with vref */
11813 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
11814 /* port-C for line-in (rear panel) */
11815 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
11816 /* port-D for Front */
11817 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
11818 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
11819 /* port-E for HP out (front panel) */
11820 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
11821 /* route front PCM to HP */
11822 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
11823 /* port-F for mic-in (front panel) with vref */
11824 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
11825 /* port-G for CLFE (rear panel) */
11826 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
11827 { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
11828 /* port-H for side (rear panel) */
11829 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
11830 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
11832 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
11833 /* route front mic to ADC1*/
11834 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
11835 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11837 /* Unmute DAC0~3 & spdif out*/
11838 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11839 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11840 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11841 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11842 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11844 /* Unmute Mixer 14 (mic) 1c (Line in)*/
11845 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11846 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11847 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11848 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11850 /* Unmute Stereo Mixer 15 */
11851 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11852 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11853 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
11854 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
11856 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11857 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11858 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11859 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11860 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11861 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11862 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11863 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11864 /* hp used DAC 3 (Front) */
11865 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
11866 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
11871 static struct hda_verb alc861_threestack_init_verbs[] = {
11873 * Unmute ADC0 and set the default input to mic-in
11875 /* port-A for surround (rear panel) */
11876 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
11877 /* port-B for mic-in (rear panel) with vref */
11878 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
11879 /* port-C for line-in (rear panel) */
11880 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
11881 /* port-D for Front */
11882 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
11883 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
11884 /* port-E for HP out (front panel) */
11885 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
11886 /* route front PCM to HP */
11887 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
11888 /* port-F for mic-in (front panel) with vref */
11889 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
11890 /* port-G for CLFE (rear panel) */
11891 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
11892 /* port-H for side (rear panel) */
11893 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
11895 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
11896 /* route front mic to ADC1*/
11897 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
11898 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11899 /* Unmute DAC0~3 & spdif out*/
11900 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11901 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11902 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11903 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11904 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11906 /* Unmute Mixer 14 (mic) 1c (Line in)*/
11907 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11908 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11909 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11910 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11912 /* Unmute Stereo Mixer 15 */
11913 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11914 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11915 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
11916 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
11918 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11919 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11920 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11921 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11922 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11923 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11924 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11925 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11926 /* hp used DAC 3 (Front) */
11927 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
11928 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
11932 static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
11934 * Unmute ADC0 and set the default input to mic-in
11936 /* port-A for surround (rear panel) */
11937 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
11938 /* port-B for mic-in (rear panel) with vref */
11939 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
11940 /* port-C for line-in (rear panel) */
11941 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
11942 /* port-D for Front */
11943 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
11944 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
11945 /* port-E for HP out (front panel) */
11946 /* this has to be set to VREF80 */
11947 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
11948 /* route front PCM to HP */
11949 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
11950 /* port-F for mic-in (front panel) with vref */
11951 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
11952 /* port-G for CLFE (rear panel) */
11953 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
11954 /* port-H for side (rear panel) */
11955 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
11957 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
11958 /* route front mic to ADC1*/
11959 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
11960 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11961 /* Unmute DAC0~3 & spdif out*/
11962 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11963 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11964 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11965 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11966 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11968 /* Unmute Mixer 14 (mic) 1c (Line in)*/
11969 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11970 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11971 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11972 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11974 /* Unmute Stereo Mixer 15 */
11975 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11976 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11977 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
11978 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
11980 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11981 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11982 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11983 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11984 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11985 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11986 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11987 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11988 /* hp used DAC 3 (Front) */
11989 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
11990 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
11994 static struct hda_verb alc861_asus_init_verbs[] = {
11996 * Unmute ADC0 and set the default input to mic-in
11998 /* port-A for surround (rear panel)
11999 * according to codec#0 this is the HP jack
12001 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */
12002 /* route front PCM to HP */
12003 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 },
12004 /* port-B for mic-in (rear panel) with vref */
12005 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
12006 /* port-C for line-in (rear panel) */
12007 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
12008 /* port-D for Front */
12009 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
12010 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
12011 /* port-E for HP out (front panel) */
12012 /* this has to be set to VREF80 */
12013 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
12014 /* route front PCM to HP */
12015 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
12016 /* port-F for mic-in (front panel) with vref */
12017 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
12018 /* port-G for CLFE (rear panel) */
12019 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
12020 /* port-H for side (rear panel) */
12021 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
12023 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
12024 /* route front mic to ADC1*/
12025 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
12026 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12027 /* Unmute DAC0~3 & spdif out*/
12028 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12029 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12030 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12031 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12032 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12033 /* Unmute Mixer 14 (mic) 1c (Line in)*/
12034 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12035 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12036 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12037 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12039 /* Unmute Stereo Mixer 15 */
12040 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12041 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12042 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
12043 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
12045 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12046 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12047 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12048 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12049 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12050 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12051 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12052 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12053 /* hp used DAC 3 (Front) */
12054 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
12055 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
12059 /* additional init verbs for ASUS laptops */
12060 static struct hda_verb alc861_asus_laptop_init_verbs[] = {
12061 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */
12062 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */
12067 * generic initialization of ADC, input mixers and output mixers
12069 static struct hda_verb alc861_auto_init_verbs[] = {
12071 * Unmute ADC0 and set the default input to mic-in
12073 /* {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, */
12074 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12076 /* Unmute DAC0~3 & spdif out*/
12077 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12078 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12079 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12080 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12081 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12083 /* Unmute Mixer 14 (mic) 1c (Line in)*/
12084 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12085 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12086 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12087 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12089 /* Unmute Stereo Mixer 15 */
12090 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12091 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12092 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
12093 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
12095 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12096 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12097 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12098 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12099 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12100 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12101 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12102 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12104 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12105 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12106 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
12107 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
12108 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12109 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12110 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
12111 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
12113 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */
12118 static struct hda_verb alc861_toshiba_init_verbs[] = {
12119 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
12124 /* toggle speaker-output according to the hp-jack state */
12125 static void alc861_toshiba_automute(struct hda_codec *codec)
12127 unsigned int present;
12129 present = snd_hda_codec_read(codec, 0x0f, 0,
12130 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12131 snd_hda_codec_amp_stereo(codec, 0x16, HDA_INPUT, 0,
12132 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
12133 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_INPUT, 3,
12134 HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
12137 static void alc861_toshiba_unsol_event(struct hda_codec *codec,
12140 if ((res >> 26) == ALC880_HP_EVENT)
12141 alc861_toshiba_automute(codec);
12144 /* pcm configuration: identiacal with ALC880 */
12145 #define alc861_pcm_analog_playback alc880_pcm_analog_playback
12146 #define alc861_pcm_analog_capture alc880_pcm_analog_capture
12147 #define alc861_pcm_digital_playback alc880_pcm_digital_playback
12148 #define alc861_pcm_digital_capture alc880_pcm_digital_capture
12151 #define ALC861_DIGOUT_NID 0x07
12153 static struct hda_channel_mode alc861_8ch_modes[1] = {
12157 static hda_nid_t alc861_dac_nids[4] = {
12158 /* front, surround, clfe, side */
12159 0x03, 0x06, 0x05, 0x04
12162 static hda_nid_t alc660_dac_nids[3] = {
12163 /* front, clfe, surround */
12167 static hda_nid_t alc861_adc_nids[1] = {
12172 static struct hda_input_mux alc861_capture_source = {
12176 { "Front Mic", 0x3 },
12183 /* fill in the dac_nids table from the parsed pin configuration */
12184 static int alc861_auto_fill_dac_nids(struct alc_spec *spec,
12185 const struct auto_pin_cfg *cfg)
12190 spec->multiout.dac_nids = spec->private_dac_nids;
12191 for (i = 0; i < cfg->line_outs; i++) {
12192 nid = cfg->line_out_pins[i];
12194 if (i >= ARRAY_SIZE(alc861_dac_nids))
12196 spec->multiout.dac_nids[i] = alc861_dac_nids[i];
12199 spec->multiout.num_dacs = cfg->line_outs;
12203 /* add playback controls from the parsed DAC table */
12204 static int alc861_auto_create_multi_out_ctls(struct alc_spec *spec,
12205 const struct auto_pin_cfg *cfg)
12208 static const char *chname[4] = {
12209 "Front", "Surround", NULL /*CLFE*/, "Side"
12214 for (i = 0; i < cfg->line_outs; i++) {
12215 nid = spec->multiout.dac_nids[i];
12220 err = add_control(spec, ALC_CTL_BIND_MUTE,
12221 "Center Playback Switch",
12222 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
12226 err = add_control(spec, ALC_CTL_BIND_MUTE,
12227 "LFE Playback Switch",
12228 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
12233 for (idx = 0; idx < ARRAY_SIZE(alc861_dac_nids) - 1;
12235 if (nid == alc861_dac_nids[idx])
12237 sprintf(name, "%s Playback Switch", chname[idx]);
12238 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
12239 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
12248 static int alc861_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin)
12256 if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
12258 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
12259 "Headphone Playback Switch",
12260 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
12263 spec->multiout.hp_nid = nid;
12268 /* create playback/capture controls for input pins */
12269 static int alc861_auto_create_analog_input_ctls(struct alc_spec *spec,
12270 const struct auto_pin_cfg *cfg)
12272 struct hda_input_mux *imux = &spec->private_imux;
12273 int i, err, idx, idx1;
12275 for (i = 0; i < AUTO_PIN_LAST; i++) {
12276 switch (cfg->input_pins[i]) {
12279 idx = 2; /* Line In */
12283 idx = 2; /* Line In */
12287 idx = 1; /* Mic In */
12291 idx = 1; /* Mic In */
12301 err = new_analog_input(spec, cfg->input_pins[i],
12302 auto_pin_cfg_labels[i], idx, 0x15);
12306 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
12307 imux->items[imux->num_items].index = idx1;
12313 static struct snd_kcontrol_new alc861_capture_mixer[] = {
12314 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
12315 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
12318 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12319 /* The multiple "Capture Source" controls confuse alsamixer
12320 * So call somewhat different..
12322 /* .name = "Capture Source", */
12323 .name = "Input Source",
12325 .info = alc_mux_enum_info,
12326 .get = alc_mux_enum_get,
12327 .put = alc_mux_enum_put,
12332 static void alc861_auto_set_output_and_unmute(struct hda_codec *codec,
12334 int pin_type, int dac_idx)
12336 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
12338 snd_hda_codec_write(codec, dac_idx, 0, AC_VERB_SET_AMP_GAIN_MUTE,
12342 static void alc861_auto_init_multi_out(struct hda_codec *codec)
12344 struct alc_spec *spec = codec->spec;
12347 alc_subsystem_id(codec, 0x0e, 0x0f, 0x0b);
12348 for (i = 0; i < spec->autocfg.line_outs; i++) {
12349 hda_nid_t nid = spec->autocfg.line_out_pins[i];
12350 int pin_type = get_pin_type(spec->autocfg.line_out_type);
12352 alc861_auto_set_output_and_unmute(codec, nid, pin_type,
12353 spec->multiout.dac_nids[i]);
12357 static void alc861_auto_init_hp_out(struct hda_codec *codec)
12359 struct alc_spec *spec = codec->spec;
12362 pin = spec->autocfg.hp_pins[0];
12363 if (pin) /* connect to front */
12364 alc861_auto_set_output_and_unmute(codec, pin, PIN_HP,
12365 spec->multiout.dac_nids[0]);
12366 pin = spec->autocfg.speaker_pins[0];
12368 alc861_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
12371 static void alc861_auto_init_analog_input(struct hda_codec *codec)
12373 struct alc_spec *spec = codec->spec;
12376 for (i = 0; i < AUTO_PIN_LAST; i++) {
12377 hda_nid_t nid = spec->autocfg.input_pins[i];
12378 if (nid >= 0x0c && nid <= 0x11) {
12379 snd_hda_codec_write(codec, nid, 0,
12380 AC_VERB_SET_PIN_WIDGET_CONTROL,
12381 i <= AUTO_PIN_FRONT_MIC ?
12382 PIN_VREF80 : PIN_IN);
12387 /* parse the BIOS configuration and set up the alc_spec */
12388 /* return 1 if successful, 0 if the proper config is not found,
12389 * or a negative error code
12391 static int alc861_parse_auto_config(struct hda_codec *codec)
12393 struct alc_spec *spec = codec->spec;
12395 static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
12397 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
12401 if (!spec->autocfg.line_outs)
12402 return 0; /* can't find valid BIOS pin config */
12404 err = alc861_auto_fill_dac_nids(spec, &spec->autocfg);
12407 err = alc861_auto_create_multi_out_ctls(spec, &spec->autocfg);
12410 err = alc861_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0]);
12413 err = alc861_auto_create_analog_input_ctls(spec, &spec->autocfg);
12417 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
12419 if (spec->autocfg.dig_out_pin)
12420 spec->multiout.dig_out_nid = ALC861_DIGOUT_NID;
12422 if (spec->kctl_alloc)
12423 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
12425 spec->init_verbs[spec->num_init_verbs++] = alc861_auto_init_verbs;
12427 spec->num_mux_defs = 1;
12428 spec->input_mux = &spec->private_imux;
12430 spec->adc_nids = alc861_adc_nids;
12431 spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
12432 spec->mixers[spec->num_mixers] = alc861_capture_mixer;
12433 spec->num_mixers++;
12438 /* additional initialization for auto-configuration model */
12439 static void alc861_auto_init(struct hda_codec *codec)
12441 struct alc_spec *spec = codec->spec;
12442 alc861_auto_init_multi_out(codec);
12443 alc861_auto_init_hp_out(codec);
12444 alc861_auto_init_analog_input(codec);
12445 if (spec->unsol_event)
12446 alc_sku_automute(codec);
12449 #ifdef CONFIG_SND_HDA_POWER_SAVE
12450 static struct hda_amp_list alc861_loopbacks[] = {
12451 { 0x15, HDA_INPUT, 0 },
12452 { 0x15, HDA_INPUT, 1 },
12453 { 0x15, HDA_INPUT, 2 },
12454 { 0x15, HDA_INPUT, 3 },
12461 * configuration and preset
12463 static const char *alc861_models[ALC861_MODEL_LAST] = {
12464 [ALC861_3ST] = "3stack",
12465 [ALC660_3ST] = "3stack-660",
12466 [ALC861_3ST_DIG] = "3stack-dig",
12467 [ALC861_6ST_DIG] = "6stack-dig",
12468 [ALC861_UNIWILL_M31] = "uniwill-m31",
12469 [ALC861_TOSHIBA] = "toshiba",
12470 [ALC861_ASUS] = "asus",
12471 [ALC861_ASUS_LAPTOP] = "asus-laptop",
12472 [ALC861_AUTO] = "auto",
12475 static struct snd_pci_quirk alc861_cfg_tbl[] = {
12476 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST),
12477 SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP),
12478 SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP),
12479 SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS),
12480 SND_PCI_QUIRK(0x1043, 0x13d7, "ASUS A9rp", ALC861_ASUS_LAPTOP),
12481 SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS P1-AH2", ALC861_3ST_DIG),
12482 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA),
12483 /* FIXME: the entry below breaks Toshiba A100 (model=auto works!)
12484 * Any other models that need this preset?
12486 /* SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA), */
12487 SND_PCI_QUIRK(0x1462, 0x7254, "HP dx2200 (MSI MS-7254)", ALC861_3ST),
12488 SND_PCI_QUIRK(0x1462, 0x7297, "HP dx2250 (MSI MS-7297)", ALC861_3ST),
12489 SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31),
12490 SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31),
12491 SND_PCI_QUIRK(0x1584, 0x9075, "Airis Praxis N1212", ALC861_ASUS_LAPTOP),
12492 /* FIXME: the below seems conflict */
12493 /* SND_PCI_QUIRK(0x1584, 0x9075, "Uniwill", ALC861_UNIWILL_M31), */
12494 SND_PCI_QUIRK(0x1849, 0x0660, "Asrock 939SLI32", ALC660_3ST),
12495 SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST),
12499 static struct alc_config_preset alc861_presets[] = {
12501 .mixers = { alc861_3ST_mixer },
12502 .init_verbs = { alc861_threestack_init_verbs },
12503 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
12504 .dac_nids = alc861_dac_nids,
12505 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
12506 .channel_mode = alc861_threestack_modes,
12508 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
12509 .adc_nids = alc861_adc_nids,
12510 .input_mux = &alc861_capture_source,
12512 [ALC861_3ST_DIG] = {
12513 .mixers = { alc861_base_mixer },
12514 .init_verbs = { alc861_threestack_init_verbs },
12515 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
12516 .dac_nids = alc861_dac_nids,
12517 .dig_out_nid = ALC861_DIGOUT_NID,
12518 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
12519 .channel_mode = alc861_threestack_modes,
12521 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
12522 .adc_nids = alc861_adc_nids,
12523 .input_mux = &alc861_capture_source,
12525 [ALC861_6ST_DIG] = {
12526 .mixers = { alc861_base_mixer },
12527 .init_verbs = { alc861_base_init_verbs },
12528 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
12529 .dac_nids = alc861_dac_nids,
12530 .dig_out_nid = ALC861_DIGOUT_NID,
12531 .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
12532 .channel_mode = alc861_8ch_modes,
12533 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
12534 .adc_nids = alc861_adc_nids,
12535 .input_mux = &alc861_capture_source,
12538 .mixers = { alc861_3ST_mixer },
12539 .init_verbs = { alc861_threestack_init_verbs },
12540 .num_dacs = ARRAY_SIZE(alc660_dac_nids),
12541 .dac_nids = alc660_dac_nids,
12542 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
12543 .channel_mode = alc861_threestack_modes,
12545 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
12546 .adc_nids = alc861_adc_nids,
12547 .input_mux = &alc861_capture_source,
12549 [ALC861_UNIWILL_M31] = {
12550 .mixers = { alc861_uniwill_m31_mixer },
12551 .init_verbs = { alc861_uniwill_m31_init_verbs },
12552 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
12553 .dac_nids = alc861_dac_nids,
12554 .dig_out_nid = ALC861_DIGOUT_NID,
12555 .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes),
12556 .channel_mode = alc861_uniwill_m31_modes,
12558 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
12559 .adc_nids = alc861_adc_nids,
12560 .input_mux = &alc861_capture_source,
12562 [ALC861_TOSHIBA] = {
12563 .mixers = { alc861_toshiba_mixer },
12564 .init_verbs = { alc861_base_init_verbs,
12565 alc861_toshiba_init_verbs },
12566 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
12567 .dac_nids = alc861_dac_nids,
12568 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
12569 .channel_mode = alc883_3ST_2ch_modes,
12570 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
12571 .adc_nids = alc861_adc_nids,
12572 .input_mux = &alc861_capture_source,
12573 .unsol_event = alc861_toshiba_unsol_event,
12574 .init_hook = alc861_toshiba_automute,
12577 .mixers = { alc861_asus_mixer },
12578 .init_verbs = { alc861_asus_init_verbs },
12579 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
12580 .dac_nids = alc861_dac_nids,
12581 .dig_out_nid = ALC861_DIGOUT_NID,
12582 .num_channel_mode = ARRAY_SIZE(alc861_asus_modes),
12583 .channel_mode = alc861_asus_modes,
12586 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
12587 .adc_nids = alc861_adc_nids,
12588 .input_mux = &alc861_capture_source,
12590 [ALC861_ASUS_LAPTOP] = {
12591 .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer },
12592 .init_verbs = { alc861_asus_init_verbs,
12593 alc861_asus_laptop_init_verbs },
12594 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
12595 .dac_nids = alc861_dac_nids,
12596 .dig_out_nid = ALC861_DIGOUT_NID,
12597 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
12598 .channel_mode = alc883_3ST_2ch_modes,
12600 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
12601 .adc_nids = alc861_adc_nids,
12602 .input_mux = &alc861_capture_source,
12607 static int patch_alc861(struct hda_codec *codec)
12609 struct alc_spec *spec;
12613 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
12617 codec->spec = spec;
12619 board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST,
12623 if (board_config < 0) {
12624 printk(KERN_INFO "hda_codec: Unknown model for ALC861, "
12625 "trying auto-probe from BIOS...\n");
12626 board_config = ALC861_AUTO;
12629 if (board_config == ALC861_AUTO) {
12630 /* automatic parse from the BIOS config */
12631 err = alc861_parse_auto_config(codec);
12637 "hda_codec: Cannot set up configuration "
12638 "from BIOS. Using base mode...\n");
12639 board_config = ALC861_3ST_DIG;
12643 if (board_config != ALC861_AUTO)
12644 setup_preset(spec, &alc861_presets[board_config]);
12646 spec->stream_name_analog = "ALC861 Analog";
12647 spec->stream_analog_playback = &alc861_pcm_analog_playback;
12648 spec->stream_analog_capture = &alc861_pcm_analog_capture;
12650 spec->stream_name_digital = "ALC861 Digital";
12651 spec->stream_digital_playback = &alc861_pcm_digital_playback;
12652 spec->stream_digital_capture = &alc861_pcm_digital_capture;
12654 spec->vmaster_nid = 0x03;
12656 codec->patch_ops = alc_patch_ops;
12657 if (board_config == ALC861_AUTO)
12658 spec->init_hook = alc861_auto_init;
12659 #ifdef CONFIG_SND_HDA_POWER_SAVE
12660 if (!spec->loopback.amplist)
12661 spec->loopback.amplist = alc861_loopbacks;
12668 * ALC861-VD support
12672 * In addition, an independent DAC
12674 #define ALC861VD_DIGOUT_NID 0x06
12676 static hda_nid_t alc861vd_dac_nids[4] = {
12677 /* front, surr, clfe, side surr */
12678 0x02, 0x03, 0x04, 0x05
12681 /* dac_nids for ALC660vd are in a different order - according to
12682 * Realtek's driver.
12683 * This should probably tesult in a different mixer for 6stack models
12684 * of ALC660vd codecs, but for now there is only 3stack mixer
12685 * - and it is the same as in 861vd.
12686 * adc_nids in ALC660vd are (is) the same as in 861vd
12688 static hda_nid_t alc660vd_dac_nids[3] = {
12689 /* front, rear, clfe, rear_surr */
12693 static hda_nid_t alc861vd_adc_nids[1] = {
12698 static hda_nid_t alc861vd_capsrc_nids[1] = { 0x22 };
12701 /* FIXME: should be a matrix-type input source selection */
12702 static struct hda_input_mux alc861vd_capture_source = {
12706 { "Front Mic", 0x1 },
12712 static struct hda_input_mux alc861vd_dallas_capture_source = {
12715 { "Ext Mic", 0x0 },
12716 { "Int Mic", 0x1 },
12720 static struct hda_input_mux alc861vd_hp_capture_source = {
12723 { "Front Mic", 0x0 },
12724 { "ATAPI Mic", 0x1 },
12728 #define alc861vd_mux_enum_info alc_mux_enum_info
12729 #define alc861vd_mux_enum_get alc_mux_enum_get
12730 /* ALC861VD has the ALC882-type input selection (but has only one ADC) */
12731 #define alc861vd_mux_enum_put alc882_mux_enum_put
12736 static struct hda_channel_mode alc861vd_3stack_2ch_modes[1] = {
12743 static struct hda_verb alc861vd_6stack_ch6_init[] = {
12744 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
12745 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
12746 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
12747 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
12754 static struct hda_verb alc861vd_6stack_ch8_init[] = {
12755 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
12756 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
12757 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
12758 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
12762 static struct hda_channel_mode alc861vd_6stack_modes[2] = {
12763 { 6, alc861vd_6stack_ch6_init },
12764 { 8, alc861vd_6stack_ch8_init },
12767 static struct snd_kcontrol_new alc861vd_chmode_mixer[] = {
12769 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12770 .name = "Channel Mode",
12771 .info = alc_ch_mode_info,
12772 .get = alc_ch_mode_get,
12773 .put = alc_ch_mode_put,
12778 static struct snd_kcontrol_new alc861vd_capture_mixer[] = {
12779 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
12780 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
12783 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12784 /* The multiple "Capture Source" controls confuse alsamixer
12785 * So call somewhat different..
12787 /* .name = "Capture Source", */
12788 .name = "Input Source",
12790 .info = alc861vd_mux_enum_info,
12791 .get = alc861vd_mux_enum_get,
12792 .put = alc861vd_mux_enum_put,
12797 /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
12798 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
12800 static struct snd_kcontrol_new alc861vd_6st_mixer[] = {
12801 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12802 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
12804 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
12805 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
12807 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0,
12809 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0,
12811 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
12812 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
12814 HDA_CODEC_VOLUME("Side Playback Volume", 0x05, 0x0, HDA_OUTPUT),
12815 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
12817 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
12819 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12820 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12821 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12823 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
12824 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
12825 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
12827 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
12828 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
12830 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
12831 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
12833 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
12834 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
12839 static struct snd_kcontrol_new alc861vd_3st_mixer[] = {
12840 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12841 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
12843 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
12845 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12846 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12847 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12849 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
12850 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
12851 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
12853 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
12854 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
12856 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
12857 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
12859 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
12860 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
12865 static struct snd_kcontrol_new alc861vd_lenovo_mixer[] = {
12866 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12867 /*HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),*/
12868 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12870 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
12872 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12873 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12874 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12876 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
12877 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
12878 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
12880 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
12881 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
12886 /* Pin assignment: Speaker=0x14, HP = 0x15,
12887 * Ext Mic=0x18, Int Mic = 0x19, CD = 0x1c, PC Beep = 0x1d
12889 static struct snd_kcontrol_new alc861vd_dallas_mixer[] = {
12890 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12891 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
12892 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
12893 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
12894 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
12895 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12896 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12897 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
12898 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
12899 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
12900 HDA_CODEC_VOLUME("PC Beep Volume", 0x0b, 0x05, HDA_INPUT),
12901 HDA_CODEC_MUTE("PC Beep Switch", 0x0b, 0x05, HDA_INPUT),
12905 /* Pin assignment: Speaker=0x14, Line-out = 0x15,
12906 * Front Mic=0x18, ATAPI Mic = 0x19,
12908 static struct snd_kcontrol_new alc861vd_hp_mixer[] = {
12909 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12910 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
12911 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
12912 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
12913 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12914 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12915 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
12916 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
12922 * generic initialization of ADC, input mixers and output mixers
12924 static struct hda_verb alc861vd_volume_init_verbs[] = {
12926 * Unmute ADC0 and set the default input to mic-in
12928 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
12929 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12931 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of
12932 * the analog-loopback mixer widget
12934 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
12935 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12936 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12937 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
12938 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
12939 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
12941 /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */
12942 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12943 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12944 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
12945 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
12948 * Set up output mixers (0x02 - 0x05)
12950 /* set vol=0 to output mixers */
12951 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12952 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12953 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12954 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12956 /* set up input amps for analog loopback */
12957 /* Amp Indices: DAC = 0, mixer = 1 */
12958 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12959 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12960 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12961 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12962 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12963 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12964 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12965 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12971 * 3-stack pin configuration:
12972 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
12974 static struct hda_verb alc861vd_3stack_init_verbs[] = {
12976 * Set pin mode and muting
12978 /* set front pin widgets 0x14 for output */
12979 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12980 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12981 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
12983 /* Mic (rear) pin: input vref at 80% */
12984 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
12985 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12986 /* Front Mic pin: input vref at 80% */
12987 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
12988 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12989 /* Line In pin: input */
12990 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12991 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12992 /* Line-2 In: Headphone output (output 0 - 0x0c) */
12993 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12994 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12995 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
12996 /* CD pin widget for input */
12997 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13003 * 6-stack pin configuration:
13005 static struct hda_verb alc861vd_6stack_init_verbs[] = {
13007 * Set pin mode and muting
13009 /* set front pin widgets 0x14 for output */
13010 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13011 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13012 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
13014 /* Rear Pin: output 1 (0x0d) */
13015 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13016 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13017 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
13018 /* CLFE Pin: output 2 (0x0e) */
13019 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13020 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13021 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
13022 /* Side Pin: output 3 (0x0f) */
13023 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13024 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13025 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
13027 /* Mic (rear) pin: input vref at 80% */
13028 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
13029 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13030 /* Front Mic pin: input vref at 80% */
13031 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
13032 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13033 /* Line In pin: input */
13034 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13035 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13036 /* Line-2 In: Headphone output (output 0 - 0x0c) */
13037 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13038 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13039 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
13040 /* CD pin widget for input */
13041 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13046 static struct hda_verb alc861vd_eapd_verbs[] = {
13047 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
13051 static struct hda_verb alc660vd_eapd_verbs[] = {
13052 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
13053 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
13057 static struct hda_verb alc861vd_lenovo_unsol_verbs[] = {
13058 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13059 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13060 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
13061 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
13062 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
13066 /* toggle speaker-output according to the hp-jack state */
13067 static void alc861vd_lenovo_hp_automute(struct hda_codec *codec)
13069 unsigned int present;
13070 unsigned char bits;
13072 present = snd_hda_codec_read(codec, 0x1b, 0,
13073 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
13074 bits = present ? HDA_AMP_MUTE : 0;
13075 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
13076 HDA_AMP_MUTE, bits);
13079 static void alc861vd_lenovo_mic_automute(struct hda_codec *codec)
13081 unsigned int present;
13082 unsigned char bits;
13084 present = snd_hda_codec_read(codec, 0x18, 0,
13085 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
13086 bits = present ? HDA_AMP_MUTE : 0;
13087 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
13088 HDA_AMP_MUTE, bits);
13091 static void alc861vd_lenovo_automute(struct hda_codec *codec)
13093 alc861vd_lenovo_hp_automute(codec);
13094 alc861vd_lenovo_mic_automute(codec);
13097 static void alc861vd_lenovo_unsol_event(struct hda_codec *codec,
13100 switch (res >> 26) {
13101 case ALC880_HP_EVENT:
13102 alc861vd_lenovo_hp_automute(codec);
13104 case ALC880_MIC_EVENT:
13105 alc861vd_lenovo_mic_automute(codec);
13110 static struct hda_verb alc861vd_dallas_verbs[] = {
13111 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13112 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13113 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13114 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13116 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13117 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13118 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13119 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13120 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13121 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13122 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13123 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13125 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13126 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13127 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13128 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13129 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13130 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13131 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13132 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13134 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
13135 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13136 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
13137 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13138 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13139 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13140 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13141 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13143 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13144 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
13145 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
13146 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
13148 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13149 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
13150 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
13155 /* toggle speaker-output according to the hp-jack state */
13156 static void alc861vd_dallas_automute(struct hda_codec *codec)
13158 unsigned int present;
13160 present = snd_hda_codec_read(codec, 0x15, 0,
13161 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
13162 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
13163 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
13166 static void alc861vd_dallas_unsol_event(struct hda_codec *codec, unsigned int res)
13168 if ((res >> 26) == ALC880_HP_EVENT)
13169 alc861vd_dallas_automute(codec);
13172 #ifdef CONFIG_SND_HDA_POWER_SAVE
13173 #define alc861vd_loopbacks alc880_loopbacks
13176 /* pcm configuration: identiacal with ALC880 */
13177 #define alc861vd_pcm_analog_playback alc880_pcm_analog_playback
13178 #define alc861vd_pcm_analog_capture alc880_pcm_analog_capture
13179 #define alc861vd_pcm_digital_playback alc880_pcm_digital_playback
13180 #define alc861vd_pcm_digital_capture alc880_pcm_digital_capture
13183 * configuration and preset
13185 static const char *alc861vd_models[ALC861VD_MODEL_LAST] = {
13186 [ALC660VD_3ST] = "3stack-660",
13187 [ALC660VD_3ST_DIG] = "3stack-660-digout",
13188 [ALC861VD_3ST] = "3stack",
13189 [ALC861VD_3ST_DIG] = "3stack-digout",
13190 [ALC861VD_6ST_DIG] = "6stack-digout",
13191 [ALC861VD_LENOVO] = "lenovo",
13192 [ALC861VD_DALLAS] = "dallas",
13193 [ALC861VD_HP] = "hp",
13194 [ALC861VD_AUTO] = "auto",
13197 static struct snd_pci_quirk alc861vd_cfg_tbl[] = {
13198 SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST),
13199 SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_HP),
13200 SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST),
13201 SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST),
13202 SND_PCI_QUIRK(0x1043, 0x1633, "Asus V1Sn", ALC861VD_LENOVO),
13203 SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660VD_3ST_DIG),
13204 SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST),
13205 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba A135", ALC861VD_LENOVO),
13206 /*SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),*/ /*lenovo*/
13207 SND_PCI_QUIRK(0x1179, 0xff01, "DALLAS", ALC861VD_DALLAS),
13208 SND_PCI_QUIRK(0x1179, 0xff03, "Toshiba P205", ALC861VD_LENOVO),
13209 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba L30-149", ALC861VD_DALLAS),
13210 SND_PCI_QUIRK(0x1565, 0x820d, "Biostar NF61S SE", ALC861VD_6ST_DIG),
13211 SND_PCI_QUIRK(0x17aa, 0x2066, "Lenovo", ALC861VD_LENOVO),
13212 SND_PCI_QUIRK(0x17aa, 0x3802, "Lenovo 3000 C200", ALC861VD_LENOVO),
13213 SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000 N200", ALC861VD_LENOVO),
13214 SND_PCI_QUIRK(0x1849, 0x0862, "ASRock K8NF6G-VSTA", ALC861VD_6ST_DIG),
13218 static struct alc_config_preset alc861vd_presets[] = {
13220 .mixers = { alc861vd_3st_mixer },
13221 .init_verbs = { alc861vd_volume_init_verbs,
13222 alc861vd_3stack_init_verbs },
13223 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
13224 .dac_nids = alc660vd_dac_nids,
13225 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
13226 .channel_mode = alc861vd_3stack_2ch_modes,
13227 .input_mux = &alc861vd_capture_source,
13229 [ALC660VD_3ST_DIG] = {
13230 .mixers = { alc861vd_3st_mixer },
13231 .init_verbs = { alc861vd_volume_init_verbs,
13232 alc861vd_3stack_init_verbs },
13233 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
13234 .dac_nids = alc660vd_dac_nids,
13235 .dig_out_nid = ALC861VD_DIGOUT_NID,
13236 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
13237 .channel_mode = alc861vd_3stack_2ch_modes,
13238 .input_mux = &alc861vd_capture_source,
13241 .mixers = { alc861vd_3st_mixer },
13242 .init_verbs = { alc861vd_volume_init_verbs,
13243 alc861vd_3stack_init_verbs },
13244 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
13245 .dac_nids = alc861vd_dac_nids,
13246 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
13247 .channel_mode = alc861vd_3stack_2ch_modes,
13248 .input_mux = &alc861vd_capture_source,
13250 [ALC861VD_3ST_DIG] = {
13251 .mixers = { alc861vd_3st_mixer },
13252 .init_verbs = { alc861vd_volume_init_verbs,
13253 alc861vd_3stack_init_verbs },
13254 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
13255 .dac_nids = alc861vd_dac_nids,
13256 .dig_out_nid = ALC861VD_DIGOUT_NID,
13257 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
13258 .channel_mode = alc861vd_3stack_2ch_modes,
13259 .input_mux = &alc861vd_capture_source,
13261 [ALC861VD_6ST_DIG] = {
13262 .mixers = { alc861vd_6st_mixer, alc861vd_chmode_mixer },
13263 .init_verbs = { alc861vd_volume_init_verbs,
13264 alc861vd_6stack_init_verbs },
13265 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
13266 .dac_nids = alc861vd_dac_nids,
13267 .dig_out_nid = ALC861VD_DIGOUT_NID,
13268 .num_channel_mode = ARRAY_SIZE(alc861vd_6stack_modes),
13269 .channel_mode = alc861vd_6stack_modes,
13270 .input_mux = &alc861vd_capture_source,
13272 [ALC861VD_LENOVO] = {
13273 .mixers = { alc861vd_lenovo_mixer },
13274 .init_verbs = { alc861vd_volume_init_verbs,
13275 alc861vd_3stack_init_verbs,
13276 alc861vd_eapd_verbs,
13277 alc861vd_lenovo_unsol_verbs },
13278 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
13279 .dac_nids = alc660vd_dac_nids,
13280 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
13281 .channel_mode = alc861vd_3stack_2ch_modes,
13282 .input_mux = &alc861vd_capture_source,
13283 .unsol_event = alc861vd_lenovo_unsol_event,
13284 .init_hook = alc861vd_lenovo_automute,
13286 [ALC861VD_DALLAS] = {
13287 .mixers = { alc861vd_dallas_mixer },
13288 .init_verbs = { alc861vd_dallas_verbs },
13289 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
13290 .dac_nids = alc861vd_dac_nids,
13291 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
13292 .channel_mode = alc861vd_3stack_2ch_modes,
13293 .input_mux = &alc861vd_dallas_capture_source,
13294 .unsol_event = alc861vd_dallas_unsol_event,
13295 .init_hook = alc861vd_dallas_automute,
13298 .mixers = { alc861vd_hp_mixer },
13299 .init_verbs = { alc861vd_dallas_verbs, alc861vd_eapd_verbs },
13300 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
13301 .dac_nids = alc861vd_dac_nids,
13302 .dig_out_nid = ALC861VD_DIGOUT_NID,
13303 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
13304 .channel_mode = alc861vd_3stack_2ch_modes,
13305 .input_mux = &alc861vd_hp_capture_source,
13306 .unsol_event = alc861vd_dallas_unsol_event,
13307 .init_hook = alc861vd_dallas_automute,
13312 * BIOS auto configuration
13314 static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec,
13315 hda_nid_t nid, int pin_type, int dac_idx)
13317 alc_set_pin_output(codec, nid, pin_type);
13320 static void alc861vd_auto_init_multi_out(struct hda_codec *codec)
13322 struct alc_spec *spec = codec->spec;
13325 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
13326 for (i = 0; i <= HDA_SIDE; i++) {
13327 hda_nid_t nid = spec->autocfg.line_out_pins[i];
13328 int pin_type = get_pin_type(spec->autocfg.line_out_type);
13330 alc861vd_auto_set_output_and_unmute(codec, nid,
13336 static void alc861vd_auto_init_hp_out(struct hda_codec *codec)
13338 struct alc_spec *spec = codec->spec;
13341 pin = spec->autocfg.hp_pins[0];
13342 if (pin) /* connect to front and use dac 0 */
13343 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
13344 pin = spec->autocfg.speaker_pins[0];
13346 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
13349 #define alc861vd_is_input_pin(nid) alc880_is_input_pin(nid)
13350 #define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID
13352 static void alc861vd_auto_init_analog_input(struct hda_codec *codec)
13354 struct alc_spec *spec = codec->spec;
13357 for (i = 0; i < AUTO_PIN_LAST; i++) {
13358 hda_nid_t nid = spec->autocfg.input_pins[i];
13359 if (alc861vd_is_input_pin(nid)) {
13360 snd_hda_codec_write(codec, nid, 0,
13361 AC_VERB_SET_PIN_WIDGET_CONTROL,
13362 i <= AUTO_PIN_FRONT_MIC ?
13363 PIN_VREF80 : PIN_IN);
13364 if (nid != ALC861VD_PIN_CD_NID)
13365 snd_hda_codec_write(codec, nid, 0,
13366 AC_VERB_SET_AMP_GAIN_MUTE,
13372 #define alc861vd_auto_init_input_src alc882_auto_init_input_src
13374 #define alc861vd_idx_to_mixer_vol(nid) ((nid) + 0x02)
13375 #define alc861vd_idx_to_mixer_switch(nid) ((nid) + 0x0c)
13377 /* add playback controls from the parsed DAC table */
13378 /* Based on ALC880 version. But ALC861VD has separate,
13379 * different NIDs for mute/unmute switch and volume control */
13380 static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
13381 const struct auto_pin_cfg *cfg)
13384 static const char *chname[4] = {"Front", "Surround", "CLFE", "Side"};
13385 hda_nid_t nid_v, nid_s;
13388 for (i = 0; i < cfg->line_outs; i++) {
13389 if (!spec->multiout.dac_nids[i])
13391 nid_v = alc861vd_idx_to_mixer_vol(
13393 spec->multiout.dac_nids[i]));
13394 nid_s = alc861vd_idx_to_mixer_switch(
13396 spec->multiout.dac_nids[i]));
13400 err = add_control(spec, ALC_CTL_WIDGET_VOL,
13401 "Center Playback Volume",
13402 HDA_COMPOSE_AMP_VAL(nid_v, 1, 0,
13406 err = add_control(spec, ALC_CTL_WIDGET_VOL,
13407 "LFE Playback Volume",
13408 HDA_COMPOSE_AMP_VAL(nid_v, 2, 0,
13412 err = add_control(spec, ALC_CTL_BIND_MUTE,
13413 "Center Playback Switch",
13414 HDA_COMPOSE_AMP_VAL(nid_s, 1, 2,
13418 err = add_control(spec, ALC_CTL_BIND_MUTE,
13419 "LFE Playback Switch",
13420 HDA_COMPOSE_AMP_VAL(nid_s, 2, 2,
13425 sprintf(name, "%s Playback Volume", chname[i]);
13426 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
13427 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0,
13431 sprintf(name, "%s Playback Switch", chname[i]);
13432 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
13433 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2,
13442 /* add playback controls for speaker and HP outputs */
13443 /* Based on ALC880 version. But ALC861VD has separate,
13444 * different NIDs for mute/unmute switch and volume control */
13445 static int alc861vd_auto_create_extra_out(struct alc_spec *spec,
13446 hda_nid_t pin, const char *pfx)
13448 hda_nid_t nid_v, nid_s;
13455 if (alc880_is_fixed_pin(pin)) {
13456 nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
13457 /* specify the DAC as the extra output */
13458 if (!spec->multiout.hp_nid)
13459 spec->multiout.hp_nid = nid_v;
13461 spec->multiout.extra_out_nid[0] = nid_v;
13462 /* control HP volume/switch on the output mixer amp */
13463 nid_v = alc861vd_idx_to_mixer_vol(
13464 alc880_fixed_pin_idx(pin));
13465 nid_s = alc861vd_idx_to_mixer_switch(
13466 alc880_fixed_pin_idx(pin));
13468 sprintf(name, "%s Playback Volume", pfx);
13469 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
13470 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT));
13473 sprintf(name, "%s Playback Switch", pfx);
13474 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
13475 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT));
13478 } else if (alc880_is_multi_pin(pin)) {
13479 /* set manual connection */
13480 /* we have only a switch on HP-out PIN */
13481 sprintf(name, "%s Playback Switch", pfx);
13482 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
13483 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
13490 /* parse the BIOS configuration and set up the alc_spec
13491 * return 1 if successful, 0 if the proper config is not found,
13492 * or a negative error code
13493 * Based on ALC880 version - had to change it to override
13494 * alc880_auto_create_extra_out and alc880_auto_create_multi_out_ctls */
13495 static int alc861vd_parse_auto_config(struct hda_codec *codec)
13497 struct alc_spec *spec = codec->spec;
13499 static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
13501 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
13505 if (!spec->autocfg.line_outs)
13506 return 0; /* can't find valid BIOS pin config */
13508 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
13511 err = alc861vd_auto_create_multi_out_ctls(spec, &spec->autocfg);
13514 err = alc861vd_auto_create_extra_out(spec,
13515 spec->autocfg.speaker_pins[0],
13519 err = alc861vd_auto_create_extra_out(spec,
13520 spec->autocfg.hp_pins[0],
13524 err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
13528 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
13530 if (spec->autocfg.dig_out_pin)
13531 spec->multiout.dig_out_nid = ALC861VD_DIGOUT_NID;
13533 if (spec->kctl_alloc)
13534 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
13536 spec->init_verbs[spec->num_init_verbs++]
13537 = alc861vd_volume_init_verbs;
13539 spec->num_mux_defs = 1;
13540 spec->input_mux = &spec->private_imux;
13542 err = alc_auto_add_mic_boost(codec);
13549 /* additional initialization for auto-configuration model */
13550 static void alc861vd_auto_init(struct hda_codec *codec)
13552 struct alc_spec *spec = codec->spec;
13553 alc861vd_auto_init_multi_out(codec);
13554 alc861vd_auto_init_hp_out(codec);
13555 alc861vd_auto_init_analog_input(codec);
13556 alc861vd_auto_init_input_src(codec);
13557 if (spec->unsol_event)
13558 alc_sku_automute(codec);
13561 static int patch_alc861vd(struct hda_codec *codec)
13563 struct alc_spec *spec;
13564 int err, board_config;
13566 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
13570 codec->spec = spec;
13572 board_config = snd_hda_check_board_config(codec, ALC861VD_MODEL_LAST,
13576 if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) {
13577 printk(KERN_INFO "hda_codec: Unknown model for ALC660VD/"
13578 "ALC861VD, trying auto-probe from BIOS...\n");
13579 board_config = ALC861VD_AUTO;
13582 if (board_config == ALC861VD_AUTO) {
13583 /* automatic parse from the BIOS config */
13584 err = alc861vd_parse_auto_config(codec);
13590 "hda_codec: Cannot set up configuration "
13591 "from BIOS. Using base mode...\n");
13592 board_config = ALC861VD_3ST;
13596 if (board_config != ALC861VD_AUTO)
13597 setup_preset(spec, &alc861vd_presets[board_config]);
13599 if (codec->vendor_id == 0x10ec0660) {
13600 spec->stream_name_analog = "ALC660-VD Analog";
13601 spec->stream_name_digital = "ALC660-VD Digital";
13602 /* always turn on EAPD */
13603 spec->init_verbs[spec->num_init_verbs++] = alc660vd_eapd_verbs;
13605 spec->stream_name_analog = "ALC861VD Analog";
13606 spec->stream_name_digital = "ALC861VD Digital";
13609 spec->stream_analog_playback = &alc861vd_pcm_analog_playback;
13610 spec->stream_analog_capture = &alc861vd_pcm_analog_capture;
13612 spec->stream_digital_playback = &alc861vd_pcm_digital_playback;
13613 spec->stream_digital_capture = &alc861vd_pcm_digital_capture;
13615 spec->adc_nids = alc861vd_adc_nids;
13616 spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids);
13617 spec->capsrc_nids = alc861vd_capsrc_nids;
13619 spec->mixers[spec->num_mixers] = alc861vd_capture_mixer;
13620 spec->num_mixers++;
13622 spec->vmaster_nid = 0x02;
13624 codec->patch_ops = alc_patch_ops;
13626 if (board_config == ALC861VD_AUTO)
13627 spec->init_hook = alc861vd_auto_init;
13628 #ifdef CONFIG_SND_HDA_POWER_SAVE
13629 if (!spec->loopback.amplist)
13630 spec->loopback.amplist = alc861vd_loopbacks;
13639 * ALC662 is almost identical with ALC880 but has cleaner and more flexible
13640 * configuration. Each pin widget can choose any input DACs and a mixer.
13641 * Each ADC is connected from a mixer of all inputs. This makes possible
13642 * 6-channel independent captures.
13644 * In addition, an independent DAC for the multi-playback (not used in this
13647 #define ALC662_DIGOUT_NID 0x06
13648 #define ALC662_DIGIN_NID 0x0a
13650 static hda_nid_t alc662_dac_nids[4] = {
13651 /* front, rear, clfe, rear_surr */
13655 static hda_nid_t alc662_adc_nids[1] = {
13660 static hda_nid_t alc662_capsrc_nids[1] = { 0x22 };
13663 /* FIXME: should be a matrix-type input source selection */
13664 static struct hda_input_mux alc662_capture_source = {
13668 { "Front Mic", 0x1 },
13674 static struct hda_input_mux alc662_lenovo_101e_capture_source = {
13682 static struct hda_input_mux alc662_eeepc_capture_source = {
13690 static struct hda_input_mux alc663_capture_source = {
13694 { "Front Mic", 0x1 },
13699 static struct hda_input_mux alc663_m51va_capture_source = {
13702 { "Ext-Mic", 0x0 },
13707 #define alc662_mux_enum_info alc_mux_enum_info
13708 #define alc662_mux_enum_get alc_mux_enum_get
13709 #define alc662_mux_enum_put alc882_mux_enum_put
13714 static struct hda_channel_mode alc662_3ST_2ch_modes[1] = {
13721 static struct hda_verb alc662_3ST_ch2_init[] = {
13722 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
13723 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
13724 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
13725 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
13732 static struct hda_verb alc662_3ST_ch6_init[] = {
13733 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
13734 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
13735 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
13736 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
13737 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
13738 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
13742 static struct hda_channel_mode alc662_3ST_6ch_modes[2] = {
13743 { 2, alc662_3ST_ch2_init },
13744 { 6, alc662_3ST_ch6_init },
13750 static struct hda_verb alc662_sixstack_ch6_init[] = {
13751 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13752 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13753 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
13760 static struct hda_verb alc662_sixstack_ch8_init[] = {
13761 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
13762 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
13763 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
13767 static struct hda_channel_mode alc662_5stack_modes[2] = {
13768 { 2, alc662_sixstack_ch6_init },
13769 { 6, alc662_sixstack_ch8_init },
13772 /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
13773 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
13776 static struct snd_kcontrol_new alc662_base_mixer[] = {
13777 /* output mixer control */
13778 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
13779 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
13780 HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT),
13781 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
13782 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
13783 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
13784 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
13785 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
13786 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
13788 /*Input mixer control */
13789 HDA_CODEC_VOLUME("CD Playback Volume", 0xb, 0x4, HDA_INPUT),
13790 HDA_CODEC_MUTE("CD Playback Switch", 0xb, 0x4, HDA_INPUT),
13791 HDA_CODEC_VOLUME("Line Playback Volume", 0xb, 0x02, HDA_INPUT),
13792 HDA_CODEC_MUTE("Line Playback Switch", 0xb, 0x02, HDA_INPUT),
13793 HDA_CODEC_VOLUME("Mic Playback Volume", 0xb, 0x0, HDA_INPUT),
13794 HDA_CODEC_MUTE("Mic Playback Switch", 0xb, 0x0, HDA_INPUT),
13795 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0xb, 0x01, HDA_INPUT),
13796 HDA_CODEC_MUTE("Front Mic Playback Switch", 0xb, 0x01, HDA_INPUT),
13800 static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = {
13801 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13802 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
13803 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
13804 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
13805 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
13806 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
13807 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
13808 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13809 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
13810 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
13811 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
13812 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
13813 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
13817 static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = {
13818 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13819 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
13820 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
13821 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
13822 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
13823 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
13824 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
13825 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
13826 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
13827 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
13828 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
13829 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
13830 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
13831 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13832 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
13833 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
13834 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
13835 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
13836 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
13840 static struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = {
13841 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13842 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
13843 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x03, 0x0, HDA_OUTPUT),
13844 HDA_BIND_MUTE("Speaker Playback Switch", 0x03, 2, HDA_INPUT),
13845 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
13846 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
13847 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
13848 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
13849 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
13853 static struct snd_kcontrol_new alc662_eeepc_p701_mixer[] = {
13854 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
13856 HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13857 HDA_CODEC_MUTE("Line-Out Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
13859 HDA_CODEC_VOLUME("e-Mic Boost", 0x18, 0, HDA_INPUT),
13860 HDA_CODEC_VOLUME("e-Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13861 HDA_CODEC_MUTE("e-Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
13863 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
13864 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
13865 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
13869 static struct snd_kcontrol_new alc662_eeepc_ep20_mixer[] = {
13870 HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13871 HDA_CODEC_MUTE("Line-Out Playback Switch", 0x14, 0x0, HDA_OUTPUT),
13872 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
13873 HDA_BIND_MUTE("Surround Playback Switch", 0x03, 2, HDA_INPUT),
13874 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
13875 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
13876 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT),
13877 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT),
13878 HDA_CODEC_MUTE("Speaker Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
13879 HDA_BIND_MUTE("MuteCtrl Playback Switch", 0x0c, 2, HDA_INPUT),
13880 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
13881 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
13882 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13883 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
13887 static struct snd_kcontrol_new alc663_m51va_mixer[] = {
13888 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13889 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
13890 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
13891 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13892 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
13893 HDA_CODEC_MUTE("DMic Playback Switch", 0x23, 0x9, HDA_INPUT),
13897 static struct snd_kcontrol_new alc663_g71v_mixer[] = {
13898 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13899 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
13900 HDA_CODEC_VOLUME("Front Playback Volume", 0x03, 0x0, HDA_OUTPUT),
13901 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
13902 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
13904 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13905 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
13906 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
13907 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
13911 static struct snd_kcontrol_new alc663_g50v_mixer[] = {
13912 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13913 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
13914 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
13916 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13917 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
13918 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
13919 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
13920 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
13921 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
13925 static struct snd_kcontrol_new alc662_chmode_mixer[] = {
13927 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13928 .name = "Channel Mode",
13929 .info = alc_ch_mode_info,
13930 .get = alc_ch_mode_get,
13931 .put = alc_ch_mode_put,
13936 static struct hda_verb alc662_init_verbs[] = {
13937 /* ADC: mute amp left and right */
13938 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13939 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
13940 /* Front mixer: unmute input/output amp left and right (volume = 0) */
13942 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13943 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13944 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
13945 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
13946 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
13948 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13949 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13950 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13951 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13952 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13953 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13955 /* Front Pin: output 0 (0x0c) */
13956 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13957 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13959 /* Rear Pin: output 1 (0x0d) */
13960 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13961 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13963 /* CLFE Pin: output 2 (0x0e) */
13964 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13965 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13967 /* Mic (rear) pin: input vref at 80% */
13968 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
13969 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13970 /* Front Mic pin: input vref at 80% */
13971 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
13972 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13973 /* Line In pin: input */
13974 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13975 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13976 /* Line-2 In: Headphone output (output 0 - 0x0c) */
13977 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13978 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13979 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
13980 /* CD pin widget for input */
13981 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13983 /* FIXME: use matrix-type input source selection */
13984 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
13986 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13987 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13988 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13989 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
13991 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13992 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13993 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13994 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
13996 /* always trun on EAPD */
13997 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
13998 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
14003 static struct hda_verb alc662_sue_init_verbs[] = {
14004 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
14005 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
14009 static struct hda_verb alc662_eeepc_sue_init_verbs[] = {
14010 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14011 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14015 /* Set Unsolicited Event*/
14016 static struct hda_verb alc662_eeepc_ep20_sue_init_verbs[] = {
14017 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14018 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14023 * generic initialization of ADC, input mixers and output mixers
14025 static struct hda_verb alc662_auto_init_verbs[] = {
14027 * Unmute ADC and set the default input to mic-in
14029 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
14030 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14032 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
14034 * Note: PASD motherboards uses the Line In 2 as the input for front
14035 * panel mic (mic 2)
14037 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
14038 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14039 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14040 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
14041 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
14042 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
14045 * Set up output mixers (0x0c - 0x0f)
14047 /* set vol=0 to output mixers */
14048 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14049 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14050 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14052 /* set up input amps for analog loopback */
14053 /* Amp Indices: DAC = 0, mixer = 1 */
14054 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14055 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14056 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14057 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14058 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14059 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14062 /* FIXME: use matrix-type input source selection */
14063 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
14065 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14066 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14070 static struct hda_verb alc663_m51va_init_verbs[] = {
14071 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14072 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14073 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
14075 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
14077 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14078 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14082 static struct hda_verb alc663_g71v_init_verbs[] = {
14083 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14084 /* {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
14085 /* {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, */ /* Headphone */
14087 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14088 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14089 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
14091 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
14092 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_MIC_EVENT},
14093 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
14097 static struct hda_verb alc663_g50v_init_verbs[] = {
14098 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14099 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14100 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
14102 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14103 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14107 /* capture mixer elements */
14108 static struct snd_kcontrol_new alc662_capture_mixer[] = {
14109 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
14110 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
14112 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
14113 /* The multiple "Capture Source" controls confuse alsamixer
14114 * So call somewhat different..
14116 /* .name = "Capture Source", */
14117 .name = "Input Source",
14119 .info = alc662_mux_enum_info,
14120 .get = alc662_mux_enum_get,
14121 .put = alc662_mux_enum_put,
14126 static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
14128 unsigned int present;
14129 unsigned char bits;
14131 present = snd_hda_codec_read(codec, 0x14, 0,
14132 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
14133 bits = present ? HDA_AMP_MUTE : 0;
14134 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
14135 HDA_AMP_MUTE, bits);
14138 static void alc662_lenovo_101e_all_automute(struct hda_codec *codec)
14140 unsigned int present;
14141 unsigned char bits;
14143 present = snd_hda_codec_read(codec, 0x1b, 0,
14144 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
14145 bits = present ? HDA_AMP_MUTE : 0;
14146 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
14147 HDA_AMP_MUTE, bits);
14148 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
14149 HDA_AMP_MUTE, bits);
14152 static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec,
14155 if ((res >> 26) == ALC880_HP_EVENT)
14156 alc662_lenovo_101e_all_automute(codec);
14157 if ((res >> 26) == ALC880_FRONT_EVENT)
14158 alc662_lenovo_101e_ispeaker_automute(codec);
14161 static void alc662_eeepc_mic_automute(struct hda_codec *codec)
14163 unsigned int present;
14165 present = snd_hda_codec_read(codec, 0x18, 0,
14166 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
14167 snd_hda_codec_write(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
14168 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
14169 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
14170 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
14171 snd_hda_codec_write(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
14172 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
14173 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
14174 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
14177 /* unsolicited event for HP jack sensing */
14178 static void alc662_eeepc_unsol_event(struct hda_codec *codec,
14181 if ((res >> 26) == ALC880_HP_EVENT)
14182 alc262_hippo1_automute( codec );
14184 if ((res >> 26) == ALC880_MIC_EVENT)
14185 alc662_eeepc_mic_automute(codec);
14188 static void alc662_eeepc_inithook(struct hda_codec *codec)
14190 alc262_hippo1_automute( codec );
14191 alc662_eeepc_mic_automute(codec);
14194 static void alc662_eeepc_ep20_automute(struct hda_codec *codec)
14197 unsigned int present;
14199 snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
14200 present = snd_hda_codec_read(codec, 0x14, 0,
14201 AC_VERB_GET_PIN_SENSE, 0);
14202 present = (present & 0x80000000) != 0;
14204 /* mute internal speaker */
14205 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
14206 HDA_AMP_MUTE, HDA_AMP_MUTE);
14208 /* unmute internal speaker if necessary */
14209 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
14210 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
14211 HDA_AMP_MUTE, mute);
14215 /* unsolicited event for HP jack sensing */
14216 static void alc662_eeepc_ep20_unsol_event(struct hda_codec *codec,
14219 if ((res >> 26) == ALC880_HP_EVENT)
14220 alc662_eeepc_ep20_automute(codec);
14223 static void alc662_eeepc_ep20_inithook(struct hda_codec *codec)
14225 alc662_eeepc_ep20_automute(codec);
14228 static void alc663_m51va_speaker_automute(struct hda_codec *codec)
14230 unsigned int present;
14231 unsigned char bits;
14233 present = snd_hda_codec_read(codec, 0x21, 0,
14234 AC_VERB_GET_PIN_SENSE, 0)
14235 & AC_PINSENSE_PRESENCE;
14236 bits = present ? HDA_AMP_MUTE : 0;
14237 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
14238 HDA_AMP_MUTE, bits);
14241 static void alc663_m51va_mic_automute(struct hda_codec *codec)
14243 unsigned int present;
14245 present = snd_hda_codec_read(codec, 0x18, 0,
14246 AC_VERB_GET_PIN_SENSE, 0)
14247 & AC_PINSENSE_PRESENCE;
14248 snd_hda_codec_write_cache(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
14249 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
14250 snd_hda_codec_write_cache(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
14251 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
14252 snd_hda_codec_write_cache(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
14253 0x7000 | (0x09 << 8) | (present ? 0x80 : 0));
14254 snd_hda_codec_write_cache(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
14255 0x7000 | (0x09 << 8) | (present ? 0x80 : 0));
14258 static void alc663_m51va_unsol_event(struct hda_codec *codec,
14261 switch (res >> 26) {
14262 case ALC880_HP_EVENT:
14263 alc663_m51va_speaker_automute(codec);
14265 case ALC880_MIC_EVENT:
14266 alc663_m51va_mic_automute(codec);
14271 static void alc663_m51va_inithook(struct hda_codec *codec)
14273 alc663_m51va_speaker_automute(codec);
14274 alc663_m51va_mic_automute(codec);
14277 static void alc663_g71v_hp_automute(struct hda_codec *codec)
14279 unsigned int present;
14280 unsigned char bits;
14282 present = snd_hda_codec_read(codec, 0x21, 0,
14283 AC_VERB_GET_PIN_SENSE, 0)
14284 & AC_PINSENSE_PRESENCE;
14285 bits = present ? HDA_AMP_MUTE : 0;
14286 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
14287 HDA_AMP_MUTE, bits);
14288 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
14289 HDA_AMP_MUTE, bits);
14292 static void alc663_g71v_front_automute(struct hda_codec *codec)
14294 unsigned int present;
14295 unsigned char bits;
14297 present = snd_hda_codec_read(codec, 0x15, 0,
14298 AC_VERB_GET_PIN_SENSE, 0)
14299 & AC_PINSENSE_PRESENCE;
14300 bits = present ? HDA_AMP_MUTE : 0;
14301 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
14302 HDA_AMP_MUTE, bits);
14305 static void alc663_g71v_unsol_event(struct hda_codec *codec,
14308 switch (res >> 26) {
14309 case ALC880_HP_EVENT:
14310 alc663_g71v_hp_automute(codec);
14312 case ALC880_FRONT_EVENT:
14313 alc663_g71v_front_automute(codec);
14315 case ALC880_MIC_EVENT:
14316 alc662_eeepc_mic_automute(codec);
14321 static void alc663_g71v_inithook(struct hda_codec *codec)
14323 alc663_g71v_front_automute(codec);
14324 alc663_g71v_hp_automute(codec);
14325 alc662_eeepc_mic_automute(codec);
14328 static void alc663_g50v_unsol_event(struct hda_codec *codec,
14331 switch (res >> 26) {
14332 case ALC880_HP_EVENT:
14333 alc663_m51va_speaker_automute(codec);
14335 case ALC880_MIC_EVENT:
14336 alc662_eeepc_mic_automute(codec);
14341 static void alc663_g50v_inithook(struct hda_codec *codec)
14343 alc663_m51va_speaker_automute(codec);
14344 alc662_eeepc_mic_automute(codec);
14347 #ifdef CONFIG_SND_HDA_POWER_SAVE
14348 #define alc662_loopbacks alc880_loopbacks
14352 /* pcm configuration: identiacal with ALC880 */
14353 #define alc662_pcm_analog_playback alc880_pcm_analog_playback
14354 #define alc662_pcm_analog_capture alc880_pcm_analog_capture
14355 #define alc662_pcm_digital_playback alc880_pcm_digital_playback
14356 #define alc662_pcm_digital_capture alc880_pcm_digital_capture
14359 * configuration and preset
14361 static const char *alc662_models[ALC662_MODEL_LAST] = {
14362 [ALC662_3ST_2ch_DIG] = "3stack-dig",
14363 [ALC662_3ST_6ch_DIG] = "3stack-6ch-dig",
14364 [ALC662_3ST_6ch] = "3stack-6ch",
14365 [ALC662_5ST_DIG] = "6stack-dig",
14366 [ALC662_LENOVO_101E] = "lenovo-101e",
14367 [ALC662_ASUS_EEEPC_P701] = "eeepc-p701",
14368 [ALC662_ASUS_EEEPC_EP20] = "eeepc-ep20",
14369 [ALC663_ASUS_M51VA] = "m51va",
14370 [ALC663_ASUS_G71V] = "g71v",
14371 [ALC663_ASUS_H13] = "h13",
14372 [ALC663_ASUS_G50V] = "g50v",
14373 [ALC662_AUTO] = "auto",
14376 static struct snd_pci_quirk alc662_cfg_tbl[] = {
14377 SND_PCI_QUIRK(0x1043, 0x11c3, "ASUS G71V", ALC663_ASUS_G71V),
14378 SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M51VA", ALC663_ASUS_M51VA),
14379 SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS M51VA", ALC663_ASUS_G50V),
14380 SND_PCI_QUIRK(0x1043, 0x8290, "ASUS P5GC-MX", ALC662_3ST_6ch_DIG),
14381 SND_PCI_QUIRK(0x1043, 0x82a1, "ASUS Eeepc", ALC662_ASUS_EEEPC_P701),
14382 SND_PCI_QUIRK(0x1043, 0x82d1, "ASUS Eeepc EP20", ALC662_ASUS_EEEPC_EP20),
14383 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E),
14384 SND_PCI_QUIRK(0x1854, 0x2000, "ASUS H13-2000", ALC663_ASUS_H13),
14385 SND_PCI_QUIRK(0x1854, 0x2001, "ASUS H13-2001", ALC663_ASUS_H13),
14386 SND_PCI_QUIRK(0x1854, 0x2002, "ASUS H13-2002", ALC663_ASUS_H13),
14390 static struct alc_config_preset alc662_presets[] = {
14391 [ALC662_3ST_2ch_DIG] = {
14392 .mixers = { alc662_3ST_2ch_mixer, alc662_capture_mixer },
14393 .init_verbs = { alc662_init_verbs },
14394 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
14395 .dac_nids = alc662_dac_nids,
14396 .dig_out_nid = ALC662_DIGOUT_NID,
14397 .dig_in_nid = ALC662_DIGIN_NID,
14398 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
14399 .channel_mode = alc662_3ST_2ch_modes,
14400 .input_mux = &alc662_capture_source,
14402 [ALC662_3ST_6ch_DIG] = {
14403 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer,
14404 alc662_capture_mixer },
14405 .init_verbs = { alc662_init_verbs },
14406 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
14407 .dac_nids = alc662_dac_nids,
14408 .dig_out_nid = ALC662_DIGOUT_NID,
14409 .dig_in_nid = ALC662_DIGIN_NID,
14410 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
14411 .channel_mode = alc662_3ST_6ch_modes,
14413 .input_mux = &alc662_capture_source,
14415 [ALC662_3ST_6ch] = {
14416 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer,
14417 alc662_capture_mixer },
14418 .init_verbs = { alc662_init_verbs },
14419 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
14420 .dac_nids = alc662_dac_nids,
14421 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
14422 .channel_mode = alc662_3ST_6ch_modes,
14424 .input_mux = &alc662_capture_source,
14426 [ALC662_5ST_DIG] = {
14427 .mixers = { alc662_base_mixer, alc662_chmode_mixer,
14428 alc662_capture_mixer },
14429 .init_verbs = { alc662_init_verbs },
14430 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
14431 .dac_nids = alc662_dac_nids,
14432 .dig_out_nid = ALC662_DIGOUT_NID,
14433 .dig_in_nid = ALC662_DIGIN_NID,
14434 .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes),
14435 .channel_mode = alc662_5stack_modes,
14436 .input_mux = &alc662_capture_source,
14438 [ALC662_LENOVO_101E] = {
14439 .mixers = { alc662_lenovo_101e_mixer, alc662_capture_mixer },
14440 .init_verbs = { alc662_init_verbs, alc662_sue_init_verbs },
14441 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
14442 .dac_nids = alc662_dac_nids,
14443 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
14444 .channel_mode = alc662_3ST_2ch_modes,
14445 .input_mux = &alc662_lenovo_101e_capture_source,
14446 .unsol_event = alc662_lenovo_101e_unsol_event,
14447 .init_hook = alc662_lenovo_101e_all_automute,
14449 [ALC662_ASUS_EEEPC_P701] = {
14450 .mixers = { alc662_eeepc_p701_mixer, alc662_capture_mixer },
14451 .init_verbs = { alc662_init_verbs,
14452 alc662_eeepc_sue_init_verbs },
14453 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
14454 .dac_nids = alc662_dac_nids,
14455 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
14456 .channel_mode = alc662_3ST_2ch_modes,
14457 .input_mux = &alc662_eeepc_capture_source,
14458 .unsol_event = alc662_eeepc_unsol_event,
14459 .init_hook = alc662_eeepc_inithook,
14461 [ALC662_ASUS_EEEPC_EP20] = {
14462 .mixers = { alc662_eeepc_ep20_mixer, alc662_capture_mixer,
14463 alc662_chmode_mixer },
14464 .init_verbs = { alc662_init_verbs,
14465 alc662_eeepc_ep20_sue_init_verbs },
14466 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
14467 .dac_nids = alc662_dac_nids,
14468 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
14469 .channel_mode = alc662_3ST_6ch_modes,
14470 .input_mux = &alc662_lenovo_101e_capture_source,
14471 .unsol_event = alc662_eeepc_ep20_unsol_event,
14472 .init_hook = alc662_eeepc_ep20_inithook,
14474 [ALC663_ASUS_M51VA] = {
14475 .mixers = { alc663_m51va_mixer, alc662_capture_mixer},
14476 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
14477 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
14478 .dac_nids = alc662_dac_nids,
14479 .dig_out_nid = ALC662_DIGOUT_NID,
14480 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
14481 .channel_mode = alc662_3ST_2ch_modes,
14482 .input_mux = &alc663_m51va_capture_source,
14483 .unsol_event = alc663_m51va_unsol_event,
14484 .init_hook = alc663_m51va_inithook,
14486 [ALC663_ASUS_G71V] = {
14487 .mixers = { alc663_g71v_mixer, alc662_capture_mixer},
14488 .init_verbs = { alc662_init_verbs, alc663_g71v_init_verbs },
14489 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
14490 .dac_nids = alc662_dac_nids,
14491 .dig_out_nid = ALC662_DIGOUT_NID,
14492 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
14493 .channel_mode = alc662_3ST_2ch_modes,
14494 .input_mux = &alc662_eeepc_capture_source,
14495 .unsol_event = alc663_g71v_unsol_event,
14496 .init_hook = alc663_g71v_inithook,
14498 [ALC663_ASUS_H13] = {
14499 .mixers = { alc663_m51va_mixer, alc662_capture_mixer},
14500 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
14501 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
14502 .dac_nids = alc662_dac_nids,
14503 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
14504 .channel_mode = alc662_3ST_2ch_modes,
14505 .input_mux = &alc663_m51va_capture_source,
14506 .unsol_event = alc663_m51va_unsol_event,
14507 .init_hook = alc663_m51va_inithook,
14509 [ALC663_ASUS_G50V] = {
14510 .mixers = { alc663_g50v_mixer, alc662_capture_mixer},
14511 .init_verbs = { alc662_init_verbs, alc663_g50v_init_verbs },
14512 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
14513 .dac_nids = alc662_dac_nids,
14514 .dig_out_nid = ALC662_DIGOUT_NID,
14515 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
14516 .channel_mode = alc662_3ST_6ch_modes,
14517 .input_mux = &alc663_capture_source,
14518 .unsol_event = alc663_g50v_unsol_event,
14519 .init_hook = alc663_g50v_inithook,
14525 * BIOS auto configuration
14528 /* add playback controls from the parsed DAC table */
14529 static int alc662_auto_create_multi_out_ctls(struct alc_spec *spec,
14530 const struct auto_pin_cfg *cfg)
14533 static const char *chname[4] = {
14534 "Front", "Surround", NULL /*CLFE*/, "Side"
14539 for (i = 0; i < cfg->line_outs; i++) {
14540 if (!spec->multiout.dac_nids[i])
14542 nid = alc880_idx_to_dac(i);
14545 err = add_control(spec, ALC_CTL_WIDGET_VOL,
14546 "Center Playback Volume",
14547 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
14551 err = add_control(spec, ALC_CTL_WIDGET_VOL,
14552 "LFE Playback Volume",
14553 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
14557 err = add_control(spec, ALC_CTL_BIND_MUTE,
14558 "Center Playback Switch",
14559 HDA_COMPOSE_AMP_VAL(nid, 1, 2,
14563 err = add_control(spec, ALC_CTL_BIND_MUTE,
14564 "LFE Playback Switch",
14565 HDA_COMPOSE_AMP_VAL(nid, 2, 2,
14570 sprintf(name, "%s Playback Volume", chname[i]);
14571 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
14572 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
14576 sprintf(name, "%s Playback Switch", chname[i]);
14577 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
14578 HDA_COMPOSE_AMP_VAL(nid, 3, 2,
14587 /* add playback controls for speaker and HP outputs */
14588 static int alc662_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
14598 if (alc880_is_fixed_pin(pin)) {
14599 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
14600 /* printk("DAC nid=%x\n",nid); */
14601 /* specify the DAC as the extra output */
14602 if (!spec->multiout.hp_nid)
14603 spec->multiout.hp_nid = nid;
14605 spec->multiout.extra_out_nid[0] = nid;
14606 /* control HP volume/switch on the output mixer amp */
14607 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
14608 sprintf(name, "%s Playback Volume", pfx);
14609 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
14610 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
14613 sprintf(name, "%s Playback Switch", pfx);
14614 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
14615 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
14618 } else if (alc880_is_multi_pin(pin)) {
14619 /* set manual connection */
14620 /* we have only a switch on HP-out PIN */
14621 sprintf(name, "%s Playback Switch", pfx);
14622 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
14623 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
14630 /* create playback/capture controls for input pins */
14631 static int alc662_auto_create_analog_input_ctls(struct alc_spec *spec,
14632 const struct auto_pin_cfg *cfg)
14634 struct hda_input_mux *imux = &spec->private_imux;
14637 for (i = 0; i < AUTO_PIN_LAST; i++) {
14638 if (alc880_is_input_pin(cfg->input_pins[i])) {
14639 idx = alc880_input_pin_idx(cfg->input_pins[i]);
14640 err = new_analog_input(spec, cfg->input_pins[i],
14641 auto_pin_cfg_labels[i],
14645 imux->items[imux->num_items].label =
14646 auto_pin_cfg_labels[i];
14647 imux->items[imux->num_items].index =
14648 alc880_input_pin_idx(cfg->input_pins[i]);
14655 static void alc662_auto_set_output_and_unmute(struct hda_codec *codec,
14656 hda_nid_t nid, int pin_type,
14659 alc_set_pin_output(codec, nid, pin_type);
14660 /* need the manual connection? */
14661 if (alc880_is_multi_pin(nid)) {
14662 struct alc_spec *spec = codec->spec;
14663 int idx = alc880_multi_pin_idx(nid);
14664 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
14665 AC_VERB_SET_CONNECT_SEL,
14666 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
14670 static void alc662_auto_init_multi_out(struct hda_codec *codec)
14672 struct alc_spec *spec = codec->spec;
14675 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
14676 for (i = 0; i <= HDA_SIDE; i++) {
14677 hda_nid_t nid = spec->autocfg.line_out_pins[i];
14678 int pin_type = get_pin_type(spec->autocfg.line_out_type);
14680 alc662_auto_set_output_and_unmute(codec, nid, pin_type,
14685 static void alc662_auto_init_hp_out(struct hda_codec *codec)
14687 struct alc_spec *spec = codec->spec;
14690 pin = spec->autocfg.hp_pins[0];
14691 if (pin) /* connect to front */
14693 alc662_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
14694 pin = spec->autocfg.speaker_pins[0];
14696 alc662_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
14699 #define alc662_is_input_pin(nid) alc880_is_input_pin(nid)
14700 #define ALC662_PIN_CD_NID ALC880_PIN_CD_NID
14702 static void alc662_auto_init_analog_input(struct hda_codec *codec)
14704 struct alc_spec *spec = codec->spec;
14707 for (i = 0; i < AUTO_PIN_LAST; i++) {
14708 hda_nid_t nid = spec->autocfg.input_pins[i];
14709 if (alc662_is_input_pin(nid)) {
14710 snd_hda_codec_write(codec, nid, 0,
14711 AC_VERB_SET_PIN_WIDGET_CONTROL,
14712 (i <= AUTO_PIN_FRONT_MIC ?
14713 PIN_VREF80 : PIN_IN));
14714 if (nid != ALC662_PIN_CD_NID)
14715 snd_hda_codec_write(codec, nid, 0,
14716 AC_VERB_SET_AMP_GAIN_MUTE,
14722 #define alc662_auto_init_input_src alc882_auto_init_input_src
14724 static int alc662_parse_auto_config(struct hda_codec *codec)
14726 struct alc_spec *spec = codec->spec;
14728 static hda_nid_t alc662_ignore[] = { 0x1d, 0 };
14730 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
14734 if (!spec->autocfg.line_outs)
14735 return 0; /* can't find valid BIOS pin config */
14737 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
14740 err = alc662_auto_create_multi_out_ctls(spec, &spec->autocfg);
14743 err = alc662_auto_create_extra_out(spec,
14744 spec->autocfg.speaker_pins[0],
14748 err = alc662_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
14752 err = alc662_auto_create_analog_input_ctls(spec, &spec->autocfg);
14756 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
14758 if (spec->autocfg.dig_out_pin)
14759 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
14761 if (spec->kctl_alloc)
14762 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
14764 spec->num_mux_defs = 1;
14765 spec->input_mux = &spec->private_imux;
14767 spec->init_verbs[spec->num_init_verbs++] = alc662_auto_init_verbs;
14768 spec->mixers[spec->num_mixers] = alc662_capture_mixer;
14769 spec->num_mixers++;
14773 /* additional initialization for auto-configuration model */
14774 static void alc662_auto_init(struct hda_codec *codec)
14776 struct alc_spec *spec = codec->spec;
14777 alc662_auto_init_multi_out(codec);
14778 alc662_auto_init_hp_out(codec);
14779 alc662_auto_init_analog_input(codec);
14780 alc662_auto_init_input_src(codec);
14781 if (spec->unsol_event)
14782 alc_sku_automute(codec);
14785 static int patch_alc662(struct hda_codec *codec)
14787 struct alc_spec *spec;
14788 int err, board_config;
14790 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
14794 codec->spec = spec;
14796 alc_fix_pll_init(codec, 0x20, 0x04, 15);
14798 board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST,
14801 if (board_config < 0) {
14802 printk(KERN_INFO "hda_codec: Unknown model for ALC662, "
14803 "trying auto-probe from BIOS...\n");
14804 board_config = ALC662_AUTO;
14807 if (board_config == ALC662_AUTO) {
14808 /* automatic parse from the BIOS config */
14809 err = alc662_parse_auto_config(codec);
14815 "hda_codec: Cannot set up configuration "
14816 "from BIOS. Using base mode...\n");
14817 board_config = ALC662_3ST_2ch_DIG;
14821 if (board_config != ALC662_AUTO)
14822 setup_preset(spec, &alc662_presets[board_config]);
14824 if (codec->vendor_id == 0x10ec0663) {
14825 spec->stream_name_analog = "ALC663 Analog";
14826 spec->stream_name_digital = "ALC663 Digital";
14828 spec->stream_name_analog = "ALC662 Analog";
14829 spec->stream_name_digital = "ALC662 Digital";
14832 spec->stream_analog_playback = &alc662_pcm_analog_playback;
14833 spec->stream_analog_capture = &alc662_pcm_analog_capture;
14835 spec->stream_digital_playback = &alc662_pcm_digital_playback;
14836 spec->stream_digital_capture = &alc662_pcm_digital_capture;
14838 spec->adc_nids = alc662_adc_nids;
14839 spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids);
14840 spec->capsrc_nids = alc662_capsrc_nids;
14842 spec->vmaster_nid = 0x02;
14844 codec->patch_ops = alc_patch_ops;
14845 if (board_config == ALC662_AUTO)
14846 spec->init_hook = alc662_auto_init;
14847 #ifdef CONFIG_SND_HDA_POWER_SAVE
14848 if (!spec->loopback.amplist)
14849 spec->loopback.amplist = alc662_loopbacks;
14858 struct hda_codec_preset snd_hda_preset_realtek[] = {
14859 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
14860 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
14861 { .id = 0x10ec0267, .name = "ALC267", .patch = patch_alc268 },
14862 { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 },
14863 { .id = 0x10ec0269, .name = "ALC269", .patch = patch_alc269 },
14864 { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
14865 .patch = patch_alc861 },
14866 { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
14867 { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
14868 { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
14869 { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2",
14870 .patch = patch_alc883 },
14871 { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
14872 .patch = patch_alc662 },
14873 { .id = 0x10ec0663, .name = "ALC663", .patch = patch_alc662 },
14874 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
14875 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
14876 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc883 },
14877 { .id = 0x10ec0885, .rev = 0x100103, .name = "ALC889A",
14878 .patch = patch_alc882 }, /* should be patch_alc883() in future */
14879 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
14880 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc883 },
14881 { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc883 },
14882 {} /* terminator */