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 <sound/driver.h>
27 #include <linux/init.h>
28 #include <linux/delay.h>
29 #include <linux/slab.h>
30 #include <linux/pci.h>
31 #include <sound/core.h>
32 #include "hda_codec.h"
33 #include "hda_local.h"
35 #define ALC880_FRONT_EVENT 0x01
36 #define ALC880_DCVOL_EVENT 0x02
37 #define ALC880_HP_EVENT 0x04
38 #define ALC880_MIC_EVENT 0x08
40 /* ALC880 board config type */
63 #ifdef CONFIG_SND_DEBUG
67 ALC880_MODEL_LAST /* last tag */
79 #ifdef CONFIG_SND_DEBUG
83 ALC260_MODEL_LAST /* last tag */
93 ALC262_HP_BPC_D7000_WL,
94 ALC262_HP_BPC_D7000_WF,
101 ALC262_MODEL_LAST /* last tag */
110 ALC268_MODEL_LAST /* last tag */
127 /* ALC861-VD models */
148 ALC662_ASUS_EEEPC_P701,
176 ALC883_TARGA_2ch_DIG,
182 ALC883_LENOVO_101E_2ch,
183 ALC883_LENOVO_NB0763,
184 ALC888_LENOVO_MS7195_DIG,
193 #define GPIO_MASK 0x03
196 /* codec parameterization */
197 struct snd_kcontrol_new *mixers[5]; /* mixer arrays */
198 unsigned int num_mixers;
200 const struct hda_verb *init_verbs[5]; /* initialization verbs
204 unsigned int num_init_verbs;
206 char *stream_name_analog; /* analog PCM stream */
207 struct hda_pcm_stream *stream_analog_playback;
208 struct hda_pcm_stream *stream_analog_capture;
210 char *stream_name_digital; /* digital PCM stream */
211 struct hda_pcm_stream *stream_digital_playback;
212 struct hda_pcm_stream *stream_digital_capture;
215 struct hda_multi_out multiout; /* playback set-up
216 * max_channels, dacs must be set
217 * dig_out_nid and hp_nid are optional
221 unsigned int num_adc_nids;
223 hda_nid_t dig_in_nid; /* digital-in NID; optional */
226 unsigned int num_mux_defs;
227 const struct hda_input_mux *input_mux;
228 unsigned int cur_mux[3];
231 const struct hda_channel_mode *channel_mode;
232 int num_channel_mode;
235 /* PCM information */
236 struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */
238 /* dynamic controls, init_verbs and input_mux */
239 struct auto_pin_cfg autocfg;
240 unsigned int num_kctl_alloc, num_kctl_used;
241 struct snd_kcontrol_new *kctl_alloc;
242 struct hda_input_mux private_imux;
243 hda_nid_t private_dac_nids[AUTO_CFG_MAX_OUTS];
246 void (*init_hook)(struct hda_codec *codec);
247 void (*unsol_event)(struct hda_codec *codec, unsigned int res);
249 /* for pin sensing */
250 unsigned int sense_updated: 1;
251 unsigned int jack_present: 1;
253 #ifdef CONFIG_SND_HDA_POWER_SAVE
254 struct hda_loopback_check loopback;
259 * configuration template - to be copied to the spec instance
261 struct alc_config_preset {
262 struct snd_kcontrol_new *mixers[5]; /* should be identical size
265 const struct hda_verb *init_verbs[5];
266 unsigned int num_dacs;
268 hda_nid_t dig_out_nid; /* optional */
269 hda_nid_t hp_nid; /* optional */
270 unsigned int num_adc_nids;
272 hda_nid_t dig_in_nid;
273 unsigned int num_channel_mode;
274 const struct hda_channel_mode *channel_mode;
276 unsigned int num_mux_defs;
277 const struct hda_input_mux *input_mux;
278 void (*unsol_event)(struct hda_codec *, unsigned int);
279 void (*init_hook)(struct hda_codec *);
280 #ifdef CONFIG_SND_HDA_POWER_SAVE
281 struct hda_amp_list *loopbacks;
289 static int alc_mux_enum_info(struct snd_kcontrol *kcontrol,
290 struct snd_ctl_elem_info *uinfo)
292 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
293 struct alc_spec *spec = codec->spec;
294 unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id);
295 if (mux_idx >= spec->num_mux_defs)
297 return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo);
300 static int alc_mux_enum_get(struct snd_kcontrol *kcontrol,
301 struct snd_ctl_elem_value *ucontrol)
303 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
304 struct alc_spec *spec = codec->spec;
305 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
307 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
311 static int alc_mux_enum_put(struct snd_kcontrol *kcontrol,
312 struct snd_ctl_elem_value *ucontrol)
314 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
315 struct alc_spec *spec = codec->spec;
316 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
317 unsigned int mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx;
318 return snd_hda_input_mux_put(codec, &spec->input_mux[mux_idx], ucontrol,
319 spec->adc_nids[adc_idx],
320 &spec->cur_mux[adc_idx]);
325 * channel mode setting
327 static int alc_ch_mode_info(struct snd_kcontrol *kcontrol,
328 struct snd_ctl_elem_info *uinfo)
330 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
331 struct alc_spec *spec = codec->spec;
332 return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
333 spec->num_channel_mode);
336 static int alc_ch_mode_get(struct snd_kcontrol *kcontrol,
337 struct snd_ctl_elem_value *ucontrol)
339 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
340 struct alc_spec *spec = codec->spec;
341 return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
342 spec->num_channel_mode,
343 spec->multiout.max_channels);
346 static int alc_ch_mode_put(struct snd_kcontrol *kcontrol,
347 struct snd_ctl_elem_value *ucontrol)
349 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
350 struct alc_spec *spec = codec->spec;
351 int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
352 spec->num_channel_mode,
353 &spec->multiout.max_channels);
354 if (err >= 0 && spec->need_dac_fix)
355 spec->multiout.num_dacs = spec->multiout.max_channels / 2;
360 * Control the mode of pin widget settings via the mixer. "pc" is used
361 * instead of "%" to avoid consequences of accidently treating the % as
362 * being part of a format specifier. Maximum allowed length of a value is
363 * 63 characters plus NULL terminator.
365 * Note: some retasking pin complexes seem to ignore requests for input
366 * states other than HiZ (eg: PIN_VREFxx) and revert to HiZ if any of these
367 * are requested. Therefore order this list so that this behaviour will not
368 * cause problems when mixer clients move through the enum sequentially.
369 * NIDs 0x0f and 0x10 have been observed to have this behaviour as of
372 static char *alc_pin_mode_names[] = {
373 "Mic 50pc bias", "Mic 80pc bias",
374 "Line in", "Line out", "Headphone out",
376 static unsigned char alc_pin_mode_values[] = {
377 PIN_VREF50, PIN_VREF80, PIN_IN, PIN_OUT, PIN_HP,
379 /* The control can present all 5 options, or it can limit the options based
380 * in the pin being assumed to be exclusively an input or an output pin. In
381 * addition, "input" pins may or may not process the mic bias option
382 * depending on actual widget capability (NIDs 0x0f and 0x10 don't seem to
383 * accept requests for bias as of chip versions up to March 2006) and/or
384 * wiring in the computer.
386 #define ALC_PIN_DIR_IN 0x00
387 #define ALC_PIN_DIR_OUT 0x01
388 #define ALC_PIN_DIR_INOUT 0x02
389 #define ALC_PIN_DIR_IN_NOMICBIAS 0x03
390 #define ALC_PIN_DIR_INOUT_NOMICBIAS 0x04
392 /* Info about the pin modes supported by the different pin direction modes.
393 * For each direction the minimum and maximum values are given.
395 static signed char alc_pin_mode_dir_info[5][2] = {
396 { 0, 2 }, /* ALC_PIN_DIR_IN */
397 { 3, 4 }, /* ALC_PIN_DIR_OUT */
398 { 0, 4 }, /* ALC_PIN_DIR_INOUT */
399 { 2, 2 }, /* ALC_PIN_DIR_IN_NOMICBIAS */
400 { 2, 4 }, /* ALC_PIN_DIR_INOUT_NOMICBIAS */
402 #define alc_pin_mode_min(_dir) (alc_pin_mode_dir_info[_dir][0])
403 #define alc_pin_mode_max(_dir) (alc_pin_mode_dir_info[_dir][1])
404 #define alc_pin_mode_n_items(_dir) \
405 (alc_pin_mode_max(_dir)-alc_pin_mode_min(_dir)+1)
407 static int alc_pin_mode_info(struct snd_kcontrol *kcontrol,
408 struct snd_ctl_elem_info *uinfo)
410 unsigned int item_num = uinfo->value.enumerated.item;
411 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
413 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
415 uinfo->value.enumerated.items = alc_pin_mode_n_items(dir);
417 if (item_num<alc_pin_mode_min(dir) || item_num>alc_pin_mode_max(dir))
418 item_num = alc_pin_mode_min(dir);
419 strcpy(uinfo->value.enumerated.name, alc_pin_mode_names[item_num]);
423 static int alc_pin_mode_get(struct snd_kcontrol *kcontrol,
424 struct snd_ctl_elem_value *ucontrol)
427 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
428 hda_nid_t nid = kcontrol->private_value & 0xffff;
429 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
430 long *valp = ucontrol->value.integer.value;
431 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
432 AC_VERB_GET_PIN_WIDGET_CONTROL,
435 /* Find enumerated value for current pinctl setting */
436 i = alc_pin_mode_min(dir);
437 while (alc_pin_mode_values[i] != pinctl && i <= alc_pin_mode_max(dir))
439 *valp = i <= alc_pin_mode_max(dir) ? i: alc_pin_mode_min(dir);
443 static int alc_pin_mode_put(struct snd_kcontrol *kcontrol,
444 struct snd_ctl_elem_value *ucontrol)
447 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
448 hda_nid_t nid = kcontrol->private_value & 0xffff;
449 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
450 long val = *ucontrol->value.integer.value;
451 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
452 AC_VERB_GET_PIN_WIDGET_CONTROL,
455 if (val < alc_pin_mode_min(dir) || val > alc_pin_mode_max(dir))
456 val = alc_pin_mode_min(dir);
458 change = pinctl != alc_pin_mode_values[val];
460 /* Set pin mode to that requested */
461 snd_hda_codec_write_cache(codec, nid, 0,
462 AC_VERB_SET_PIN_WIDGET_CONTROL,
463 alc_pin_mode_values[val]);
465 /* Also enable the retasking pin's input/output as required
466 * for the requested pin mode. Enum values of 2 or less are
469 * Dynamically switching the input/output buffers probably
470 * reduces noise slightly (particularly on input) so we'll
471 * do it. However, having both input and output buffers
472 * enabled simultaneously doesn't seem to be problematic if
473 * this turns out to be necessary in the future.
476 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
477 HDA_AMP_MUTE, HDA_AMP_MUTE);
478 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
481 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
482 HDA_AMP_MUTE, HDA_AMP_MUTE);
483 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
490 #define ALC_PIN_MODE(xname, nid, dir) \
491 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
492 .info = alc_pin_mode_info, \
493 .get = alc_pin_mode_get, \
494 .put = alc_pin_mode_put, \
495 .private_value = nid | (dir<<16) }
497 /* A switch control for ALC260 GPIO pins. Multiple GPIOs can be ganged
498 * together using a mask with more than one bit set. This control is
499 * currently used only by the ALC260 test model. At this stage they are not
500 * needed for any "production" models.
502 #ifdef CONFIG_SND_DEBUG
503 #define alc_gpio_data_info snd_ctl_boolean_mono_info
505 static int alc_gpio_data_get(struct snd_kcontrol *kcontrol,
506 struct snd_ctl_elem_value *ucontrol)
508 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
509 hda_nid_t nid = kcontrol->private_value & 0xffff;
510 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
511 long *valp = ucontrol->value.integer.value;
512 unsigned int val = snd_hda_codec_read(codec, nid, 0,
513 AC_VERB_GET_GPIO_DATA, 0x00);
515 *valp = (val & mask) != 0;
518 static int alc_gpio_data_put(struct snd_kcontrol *kcontrol,
519 struct snd_ctl_elem_value *ucontrol)
522 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
523 hda_nid_t nid = kcontrol->private_value & 0xffff;
524 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
525 long val = *ucontrol->value.integer.value;
526 unsigned int gpio_data = snd_hda_codec_read(codec, nid, 0,
527 AC_VERB_GET_GPIO_DATA,
530 /* Set/unset the masked GPIO bit(s) as needed */
531 change = (val == 0 ? 0 : mask) != (gpio_data & mask);
536 snd_hda_codec_write_cache(codec, nid, 0,
537 AC_VERB_SET_GPIO_DATA, gpio_data);
541 #define ALC_GPIO_DATA_SWITCH(xname, nid, mask) \
542 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
543 .info = alc_gpio_data_info, \
544 .get = alc_gpio_data_get, \
545 .put = alc_gpio_data_put, \
546 .private_value = nid | (mask<<16) }
547 #endif /* CONFIG_SND_DEBUG */
549 /* A switch control to allow the enabling of the digital IO pins on the
550 * ALC260. This is incredibly simplistic; the intention of this control is
551 * to provide something in the test model allowing digital outputs to be
552 * identified if present. If models are found which can utilise these
553 * outputs a more complete mixer control can be devised for those models if
556 #ifdef CONFIG_SND_DEBUG
557 #define alc_spdif_ctrl_info snd_ctl_boolean_mono_info
559 static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol,
560 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 *valp = ucontrol->value.integer.value;
566 unsigned int val = snd_hda_codec_read(codec, nid, 0,
567 AC_VERB_GET_DIGI_CONVERT, 0x00);
569 *valp = (val & mask) != 0;
572 static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol,
573 struct snd_ctl_elem_value *ucontrol)
576 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
577 hda_nid_t nid = kcontrol->private_value & 0xffff;
578 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
579 long val = *ucontrol->value.integer.value;
580 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
581 AC_VERB_GET_DIGI_CONVERT,
584 /* Set/unset the masked control bit(s) as needed */
585 change = (val == 0 ? 0 : mask) != (ctrl_data & mask);
590 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1,
595 #define ALC_SPDIF_CTRL_SWITCH(xname, nid, mask) \
596 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
597 .info = alc_spdif_ctrl_info, \
598 .get = alc_spdif_ctrl_get, \
599 .put = alc_spdif_ctrl_put, \
600 .private_value = nid | (mask<<16) }
601 #endif /* CONFIG_SND_DEBUG */
604 * set up from the preset table
606 static void setup_preset(struct alc_spec *spec,
607 const struct alc_config_preset *preset)
611 for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++)
612 spec->mixers[spec->num_mixers++] = preset->mixers[i];
613 for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i];
615 spec->init_verbs[spec->num_init_verbs++] =
616 preset->init_verbs[i];
618 spec->channel_mode = preset->channel_mode;
619 spec->num_channel_mode = preset->num_channel_mode;
620 spec->need_dac_fix = preset->need_dac_fix;
622 spec->multiout.max_channels = spec->channel_mode[0].channels;
624 spec->multiout.num_dacs = preset->num_dacs;
625 spec->multiout.dac_nids = preset->dac_nids;
626 spec->multiout.dig_out_nid = preset->dig_out_nid;
627 spec->multiout.hp_nid = preset->hp_nid;
629 spec->num_mux_defs = preset->num_mux_defs;
630 if (!spec->num_mux_defs)
631 spec->num_mux_defs = 1;
632 spec->input_mux = preset->input_mux;
634 spec->num_adc_nids = preset->num_adc_nids;
635 spec->adc_nids = preset->adc_nids;
636 spec->dig_in_nid = preset->dig_in_nid;
638 spec->unsol_event = preset->unsol_event;
639 spec->init_hook = preset->init_hook;
640 #ifdef CONFIG_SND_HDA_POWER_SAVE
641 spec->loopback.amplist = preset->loopbacks;
645 /* Enable GPIO mask and set output */
646 static struct hda_verb alc_gpio1_init_verbs[] = {
647 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
648 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
649 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
653 static struct hda_verb alc_gpio2_init_verbs[] = {
654 {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
655 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
656 {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
660 static struct hda_verb alc_gpio3_init_verbs[] = {
661 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
662 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
663 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
667 static void alc_sku_automute(struct hda_codec *codec)
669 struct alc_spec *spec = codec->spec;
671 unsigned int present;
672 unsigned int hp_nid = spec->autocfg.hp_pins[0];
673 unsigned int sp_nid = spec->autocfg.speaker_pins[0];
675 /* need to execute and sync at first */
676 snd_hda_codec_read(codec, hp_nid, 0, AC_VERB_SET_PIN_SENSE, 0);
677 present = snd_hda_codec_read(codec, hp_nid, 0,
678 AC_VERB_GET_PIN_SENSE, 0);
679 spec->jack_present = (present & 0x80000000) != 0;
680 if (spec->jack_present) {
681 /* mute internal speaker */
682 snd_hda_codec_amp_stereo(codec, sp_nid, HDA_OUTPUT, 0,
683 HDA_AMP_MUTE, HDA_AMP_MUTE);
685 /* unmute internal speaker if necessary */
686 mute = snd_hda_codec_amp_read(codec, hp_nid, 0, HDA_OUTPUT, 0);
687 snd_hda_codec_amp_stereo(codec, sp_nid, HDA_OUTPUT, 0,
692 /* unsolicited event for HP jack sensing */
693 static void alc_sku_unsol_event(struct hda_codec *codec, unsigned int res)
695 if (codec->vendor_id == 0x10ec0880)
699 if (res != ALC880_HP_EVENT)
702 alc_sku_automute(codec);
705 /* 32-bit subsystem ID for BIOS loading in HD Audio codec.
706 * 31 ~ 16 : Manufacture ID
708 * 7 ~ 0 : Assembly ID
709 * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36
711 static void alc_subsystem_id(struct hda_codec *codec,
712 unsigned int porta, unsigned int porte,
715 unsigned int ass, tmp, i;
717 struct alc_spec *spec = codec->spec;
719 ass = codec->subsystem_id & 0xffff;
720 if ((ass != codec->bus->pci->subsystem_device) && (ass & 1))
724 * 31~30 : port conetcivity
727 * 19~16 : Check sum (15:1)
732 if (codec->vendor_id == 0x10ec0260)
734 ass = snd_hda_codec_read(codec, nid, 0,
735 AC_VERB_GET_CONFIG_DEFAULT, 0);
736 if (!(ass & 1) && !(ass & 0x100000))
738 if ((ass >> 30) != 1) /* no physical connection */
743 for (i = 1; i < 16; i++) {
747 if (((ass >> 16) & 0xf) != tmp)
753 * 2 : 0 --> Desktop, 1 --> Laptop
754 * 3~5 : External Amplifier control
757 tmp = (ass & 0x38) >> 3; /* external Amp control */
760 snd_hda_sequence_write(codec, alc_gpio1_init_verbs);
763 snd_hda_sequence_write(codec, alc_gpio2_init_verbs);
766 snd_hda_sequence_write(codec, alc_gpio3_init_verbs);
768 case 5: /* set EAPD output high */
769 switch (codec->vendor_id) {
771 snd_hda_codec_write(codec, 0x0f, 0,
772 AC_VERB_SET_EAPD_BTLENABLE, 2);
773 snd_hda_codec_write(codec, 0x10, 0,
774 AC_VERB_SET_EAPD_BTLENABLE, 2);
782 snd_hda_codec_write(codec, 0x14, 0,
783 AC_VERB_SET_EAPD_BTLENABLE, 2);
784 snd_hda_codec_write(codec, 0x15, 0,
785 AC_VERB_SET_EAPD_BTLENABLE, 2);
788 switch (codec->vendor_id) {
790 snd_hda_codec_write(codec, 0x1a, 0,
791 AC_VERB_SET_COEF_INDEX, 7);
792 tmp = snd_hda_codec_read(codec, 0x1a, 0,
793 AC_VERB_GET_PROC_COEF, 0);
794 snd_hda_codec_write(codec, 0x1a, 0,
795 AC_VERB_SET_COEF_INDEX, 7);
796 snd_hda_codec_write(codec, 0x1a, 0,
797 AC_VERB_SET_PROC_COEF,
806 snd_hda_codec_write(codec, 0x20, 0,
807 AC_VERB_SET_COEF_INDEX, 7);
808 tmp = snd_hda_codec_read(codec, 0x20, 0,
809 AC_VERB_GET_PROC_COEF, 0);
810 snd_hda_codec_write(codec, 0x20, 0,
811 AC_VERB_SET_COEF_INDEX, 7);
812 snd_hda_codec_write(codec, 0x20, 0,
813 AC_VERB_SET_PROC_COEF,
818 snd_hda_codec_write(codec, 0x20, 0,
819 AC_VERB_SET_COEF_INDEX, 7);
820 tmp = snd_hda_codec_read(codec, 0x20, 0,
821 AC_VERB_GET_PROC_COEF, 0);
822 snd_hda_codec_write(codec, 0x20, 0,
823 AC_VERB_SET_COEF_INDEX, 7);
824 snd_hda_codec_write(codec, 0x20, 0,
825 AC_VERB_SET_PROC_COEF,
833 /* is laptop and enable the function "Mute internal speaker
834 * when the external headphone out jack is plugged"
836 if (!(ass & 0x4) || !(ass & 0x8000))
839 * 10~8 : Jack location
840 * 12~11: Headphone out -> 00: PortA, 01: PortE, 02: PortD, 03: Resvered
842 * 15 : 1 --> enable the function "Mute internal speaker
843 * when the external headphone out jack is plugged"
845 if (!spec->autocfg.speaker_pins[0]) {
846 if (spec->multiout.dac_nids[0])
847 spec->autocfg.speaker_pins[0] =
848 spec->multiout.dac_nids[0];
853 if (!spec->autocfg.hp_pins[0]) {
854 tmp = (ass >> 11) & 0x3; /* HP to chassis */
856 spec->autocfg.hp_pins[0] = porta;
858 spec->autocfg.hp_pins[0] = porte;
860 spec->autocfg.hp_pins[0] = portd;
865 snd_hda_codec_write(codec, spec->autocfg.hp_pins[0], 0,
866 AC_VERB_SET_UNSOLICITED_ENABLE,
867 AC_USRSP_EN | ALC880_HP_EVENT);
868 spec->unsol_event = alc_sku_unsol_event;
869 spec->init_hook = alc_sku_automute;
873 * Fix-up pin default configurations
881 static void alc_fix_pincfg(struct hda_codec *codec,
882 const struct snd_pci_quirk *quirk,
883 const struct alc_pincfg **pinfix)
885 const struct alc_pincfg *cfg;
887 quirk = snd_pci_quirk_lookup(codec->bus->pci, quirk);
891 cfg = pinfix[quirk->value];
892 for (; cfg->nid; cfg++) {
895 for (i = 0; i < 4; i++) {
896 snd_hda_codec_write(codec, cfg->nid, 0,
897 AC_VERB_SET_CONFIG_DEFAULT_BYTES_0 + i,
905 * ALC880 3-stack model
907 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
908 * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18,
909 * F-Mic = 0x1b, HP = 0x19
912 static hda_nid_t alc880_dac_nids[4] = {
913 /* front, rear, clfe, rear_surr */
914 0x02, 0x05, 0x04, 0x03
917 static hda_nid_t alc880_adc_nids[3] = {
922 /* The datasheet says the node 0x07 is connected from inputs,
923 * but it shows zero connection in the real implementation on some devices.
924 * Note: this is a 915GAV bug, fixed on 915GLV
926 static hda_nid_t alc880_adc_nids_alt[2] = {
931 #define ALC880_DIGOUT_NID 0x06
932 #define ALC880_DIGIN_NID 0x0a
934 static struct hda_input_mux alc880_capture_source = {
938 { "Front Mic", 0x3 },
944 /* channel source setting (2/6 channel selection for 3-stack) */
946 static struct hda_verb alc880_threestack_ch2_init[] = {
947 /* set line-in to input, mute it */
948 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
949 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
950 /* set mic-in to input vref 80%, mute it */
951 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
952 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
957 static struct hda_verb alc880_threestack_ch6_init[] = {
958 /* set line-in to output, unmute it */
959 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
960 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
961 /* set mic-in to output, unmute it */
962 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
963 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
967 static struct hda_channel_mode alc880_threestack_modes[2] = {
968 { 2, alc880_threestack_ch2_init },
969 { 6, alc880_threestack_ch6_init },
972 static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
973 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
974 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
975 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
976 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
977 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
978 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
979 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
980 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
981 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
982 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
983 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
984 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
985 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
986 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
987 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
988 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
989 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
990 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
991 HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
993 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
994 .name = "Channel Mode",
995 .info = alc_ch_mode_info,
996 .get = alc_ch_mode_get,
997 .put = alc_ch_mode_put,
1002 /* capture mixer elements */
1003 static struct snd_kcontrol_new alc880_capture_mixer[] = {
1004 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
1005 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
1006 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
1007 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
1008 HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
1009 HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
1011 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1012 /* The multiple "Capture Source" controls confuse alsamixer
1013 * So call somewhat different..
1014 * FIXME: the controls appear in the "playback" view!
1016 /* .name = "Capture Source", */
1017 .name = "Input Source",
1019 .info = alc_mux_enum_info,
1020 .get = alc_mux_enum_get,
1021 .put = alc_mux_enum_put,
1026 /* capture mixer elements (in case NID 0x07 not available) */
1027 static struct snd_kcontrol_new alc880_capture_alt_mixer[] = {
1028 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
1029 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
1030 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
1031 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
1033 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1034 /* The multiple "Capture Source" controls confuse alsamixer
1035 * So call somewhat different..
1036 * FIXME: the controls appear in the "playback" view!
1038 /* .name = "Capture Source", */
1039 .name = "Input Source",
1041 .info = alc_mux_enum_info,
1042 .get = alc_mux_enum_get,
1043 .put = alc_mux_enum_put,
1051 * ALC880 5-stack model
1053 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d),
1055 * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
1056 * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
1059 /* additional mixers to alc880_three_stack_mixer */
1060 static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
1061 HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1062 HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
1066 /* channel source setting (6/8 channel selection for 5-stack) */
1068 static struct hda_verb alc880_fivestack_ch6_init[] = {
1069 /* set line-in to input, mute it */
1070 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1071 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1076 static struct hda_verb alc880_fivestack_ch8_init[] = {
1077 /* set line-in to output, unmute it */
1078 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1079 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1083 static struct hda_channel_mode alc880_fivestack_modes[2] = {
1084 { 6, alc880_fivestack_ch6_init },
1085 { 8, alc880_fivestack_ch8_init },
1090 * ALC880 6-stack model
1092 * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e),
1093 * Side = 0x05 (0x0f)
1094 * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
1095 * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
1098 static hda_nid_t alc880_6st_dac_nids[4] = {
1099 /* front, rear, clfe, rear_surr */
1100 0x02, 0x03, 0x04, 0x05
1103 static struct hda_input_mux alc880_6stack_capture_source = {
1107 { "Front Mic", 0x1 },
1113 /* fixed 8-channels */
1114 static struct hda_channel_mode alc880_sixstack_modes[1] = {
1118 static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
1119 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1120 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1121 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1122 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
1123 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1124 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1125 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1126 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1127 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
1128 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
1129 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1130 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1131 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1132 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1133 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1134 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1135 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1136 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1137 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1138 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
1140 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1141 .name = "Channel Mode",
1142 .info = alc_ch_mode_info,
1143 .get = alc_ch_mode_get,
1144 .put = alc_ch_mode_put,
1153 * W810 has rear IO for:
1156 * Center/LFE (DAC 04)
1159 * The system also has a pair of internal speakers, and a headphone jack.
1160 * These are both connected to Line2 on the codec, hence to DAC 02.
1162 * There is a variable resistor to control the speaker or headphone
1163 * volume. This is a hardware-only device without a software API.
1165 * Plugging headphones in will disable the internal speakers. This is
1166 * implemented in hardware, not via the driver using jack sense. In
1167 * a similar fashion, plugging into the rear socket marked "front" will
1168 * disable both the speakers and headphones.
1170 * For input, there's a microphone jack, and an "audio in" jack.
1171 * These may not do anything useful with this driver yet, because I
1172 * haven't setup any initialization verbs for these yet...
1175 static hda_nid_t alc880_w810_dac_nids[3] = {
1176 /* front, rear/surround, clfe */
1180 /* fixed 6 channels */
1181 static struct hda_channel_mode alc880_w810_modes[1] = {
1185 /* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
1186 static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
1187 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1188 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1189 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1190 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
1191 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1192 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1193 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1194 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1195 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
1203 * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
1204 * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?),
1208 static hda_nid_t alc880_z71v_dac_nids[1] = {
1211 #define ALC880_Z71V_HP_DAC 0x03
1213 /* fixed 2 channels */
1214 static struct hda_channel_mode alc880_2_jack_modes[1] = {
1218 static struct snd_kcontrol_new alc880_z71v_mixer[] = {
1219 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1220 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1221 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1222 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
1223 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1224 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1225 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1226 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1233 * ALC880 F1734 model
1235 * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
1236 * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
1239 static hda_nid_t alc880_f1734_dac_nids[1] = {
1242 #define ALC880_F1734_HP_DAC 0x02
1244 static struct snd_kcontrol_new alc880_f1734_mixer[] = {
1245 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1246 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
1247 HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1248 HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
1249 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1250 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1251 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1252 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1261 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
1262 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
1263 * Mic = 0x18, Line = 0x1a
1266 #define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
1267 #define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
1269 static struct snd_kcontrol_new alc880_asus_mixer[] = {
1270 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1271 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1272 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1273 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
1274 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1275 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1276 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1277 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1278 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1279 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1280 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1281 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1282 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1283 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1285 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1286 .name = "Channel Mode",
1287 .info = alc_ch_mode_info,
1288 .get = alc_ch_mode_get,
1289 .put = alc_ch_mode_put,
1296 * ALC880 ASUS W1V model
1298 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
1299 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
1300 * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
1303 /* additional mixers to alc880_asus_mixer */
1304 static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
1305 HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
1306 HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
1310 /* additional mixers to alc880_asus_mixer */
1311 static struct snd_kcontrol_new alc880_pcbeep_mixer[] = {
1312 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1313 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
1318 static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
1319 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1320 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
1321 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
1322 HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
1323 HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
1324 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
1325 HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
1326 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
1327 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
1329 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1330 /* The multiple "Capture Source" controls confuse alsamixer
1331 * So call somewhat different..
1332 * FIXME: the controls appear in the "playback" view!
1334 /* .name = "Capture Source", */
1335 .name = "Input Source",
1337 .info = alc_mux_enum_info,
1338 .get = alc_mux_enum_get,
1339 .put = alc_mux_enum_put,
1345 static struct snd_kcontrol_new alc880_uniwill_mixer[] = {
1346 HDA_CODEC_VOLUME("HPhone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1347 HDA_BIND_MUTE("HPhone Playback Switch", 0x0c, 2, HDA_INPUT),
1348 HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1349 HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT),
1350 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1351 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1352 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1353 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1354 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1355 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1356 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1357 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1358 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1359 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1360 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1361 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1362 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1363 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
1365 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1366 .name = "Channel Mode",
1367 .info = alc_ch_mode_info,
1368 .get = alc_ch_mode_get,
1369 .put = alc_ch_mode_put,
1374 static struct snd_kcontrol_new alc880_fujitsu_mixer[] = {
1375 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1376 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
1377 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1378 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
1379 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1380 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1381 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1382 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1383 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1384 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1388 static struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = {
1389 HDA_CODEC_VOLUME("HPhone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1390 HDA_BIND_MUTE("HPhone Playback Switch", 0x0c, 2, HDA_INPUT),
1391 HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1392 HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT),
1393 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1394 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1399 * build control elements
1401 static int alc_build_controls(struct hda_codec *codec)
1403 struct alc_spec *spec = codec->spec;
1407 for (i = 0; i < spec->num_mixers; i++) {
1408 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
1413 if (spec->multiout.dig_out_nid) {
1414 err = snd_hda_create_spdif_out_ctls(codec,
1415 spec->multiout.dig_out_nid);
1419 if (spec->dig_in_nid) {
1420 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
1429 * initialize the codec volumes, etc
1433 * generic initialization of ADC, input mixers and output mixers
1435 static struct hda_verb alc880_volume_init_verbs[] = {
1437 * Unmute ADC0-2 and set the default input to mic-in
1439 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
1440 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1441 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
1442 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1443 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
1444 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1446 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
1448 * Note: PASD motherboards uses the Line In 2 as the input for front
1451 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
1452 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1453 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1454 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
1455 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
1456 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
1457 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
1458 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
1461 * Set up output mixers (0x0c - 0x0f)
1463 /* set vol=0 to output mixers */
1464 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1465 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1466 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1467 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1468 /* set up input amps for analog loopback */
1469 /* Amp Indices: DAC = 0, mixer = 1 */
1470 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1471 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1472 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1473 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1474 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1475 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1476 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1477 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1483 * 3-stack pin configuration:
1484 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
1486 static struct hda_verb alc880_pin_3stack_init_verbs[] = {
1488 * preset connection lists of input pins
1489 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
1491 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
1492 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1493 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
1496 * Set pin mode and muting
1498 /* set front pin widgets 0x14 for output */
1499 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1500 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1501 /* Mic1 (rear panel) pin widget for input and vref at 80% */
1502 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1503 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1504 /* Mic2 (as headphone out) for HP output */
1505 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1506 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1507 /* Line In pin widget for input */
1508 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1509 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1510 /* Line2 (as front mic) pin widget for input and vref at 80% */
1511 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1512 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1513 /* CD pin widget for input */
1514 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1520 * 5-stack pin configuration:
1521 * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
1522 * line-in/side = 0x1a, f-mic = 0x1b
1524 static struct hda_verb alc880_pin_5stack_init_verbs[] = {
1526 * preset connection lists of input pins
1527 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
1529 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1530 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
1533 * Set pin mode and muting
1535 /* set pin widgets 0x14-0x17 for output */
1536 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1537 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1538 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1539 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1540 /* unmute pins for output (no gain on this amp) */
1541 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1542 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1543 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1544 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1546 /* Mic1 (rear panel) pin widget for input and vref at 80% */
1547 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1548 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1549 /* Mic2 (as headphone out) for HP output */
1550 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1551 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1552 /* Line In pin widget for input */
1553 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1554 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1555 /* Line2 (as front mic) pin widget for input and vref at 80% */
1556 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1557 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1558 /* CD pin widget for input */
1559 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1565 * W810 pin configuration:
1566 * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
1568 static struct hda_verb alc880_pin_w810_init_verbs[] = {
1569 /* hphone/speaker input selector: front DAC */
1570 {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
1572 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1573 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1574 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1575 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1576 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1577 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1579 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1580 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1586 * Z71V pin configuration:
1587 * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
1589 static struct hda_verb alc880_pin_z71v_init_verbs[] = {
1590 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1591 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1592 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1593 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1595 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1596 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1597 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1598 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1604 * 6-stack pin configuration:
1605 * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18,
1606 * f-mic = 0x19, line = 0x1a, HP = 0x1b
1608 static struct hda_verb alc880_pin_6stack_init_verbs[] = {
1609 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1611 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1612 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1613 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1614 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1615 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1616 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1617 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1618 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1620 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1621 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1622 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1623 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1624 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1625 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1626 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1627 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1628 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1634 * Uniwill pin configuration:
1635 * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19,
1638 static struct hda_verb alc880_uniwill_init_verbs[] = {
1639 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1641 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1642 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1643 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1644 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1645 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1646 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1647 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1648 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1649 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1650 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1651 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1652 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1653 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1654 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1656 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1657 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1658 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1659 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1660 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1661 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1662 /* {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, */
1663 /* {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
1664 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1666 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
1667 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
1674 * HP = 0x14, InternalSpeaker = 0x15, mic = 0x19,
1676 static struct hda_verb alc880_uniwill_p53_init_verbs[] = {
1677 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1679 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1680 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1681 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1682 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1683 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1684 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1685 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1686 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1687 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1688 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1689 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1690 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1692 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1693 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1694 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1695 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1696 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1697 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1699 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
1700 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_DCVOL_EVENT},
1705 static struct hda_verb alc880_beep_init_verbs[] = {
1706 { 0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5) },
1710 /* toggle speaker-output according to the hp-jack state */
1711 static void alc880_uniwill_hp_automute(struct hda_codec *codec)
1713 unsigned int present;
1716 present = snd_hda_codec_read(codec, 0x14, 0,
1717 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1718 bits = present ? HDA_AMP_MUTE : 0;
1719 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
1720 HDA_AMP_MUTE, bits);
1721 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
1722 HDA_AMP_MUTE, bits);
1725 /* auto-toggle front mic */
1726 static void alc880_uniwill_mic_automute(struct hda_codec *codec)
1728 unsigned int present;
1731 present = snd_hda_codec_read(codec, 0x18, 0,
1732 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1733 bits = present ? HDA_AMP_MUTE : 0;
1734 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
1737 static void alc880_uniwill_automute(struct hda_codec *codec)
1739 alc880_uniwill_hp_automute(codec);
1740 alc880_uniwill_mic_automute(codec);
1743 static void alc880_uniwill_unsol_event(struct hda_codec *codec,
1746 /* Looks like the unsol event is incompatible with the standard
1747 * definition. 4bit tag is placed at 28 bit!
1749 switch (res >> 28) {
1750 case ALC880_HP_EVENT:
1751 alc880_uniwill_hp_automute(codec);
1753 case ALC880_MIC_EVENT:
1754 alc880_uniwill_mic_automute(codec);
1759 static void alc880_uniwill_p53_hp_automute(struct hda_codec *codec)
1761 unsigned int present;
1764 present = snd_hda_codec_read(codec, 0x14, 0,
1765 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1766 bits = present ? HDA_AMP_MUTE : 0;
1767 snd_hda_codec_amp_stereo(codec, 0x15, HDA_INPUT, 0, HDA_AMP_MUTE, bits);
1770 static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec)
1772 unsigned int present;
1774 present = snd_hda_codec_read(codec, 0x21, 0,
1775 AC_VERB_GET_VOLUME_KNOB_CONTROL, 0);
1776 present &= HDA_AMP_VOLMASK;
1777 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0,
1778 HDA_AMP_VOLMASK, present);
1779 snd_hda_codec_amp_stereo(codec, 0x0d, HDA_OUTPUT, 0,
1780 HDA_AMP_VOLMASK, present);
1783 static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec,
1786 /* Looks like the unsol event is incompatible with the standard
1787 * definition. 4bit tag is placed at 28 bit!
1789 if ((res >> 28) == ALC880_HP_EVENT)
1790 alc880_uniwill_p53_hp_automute(codec);
1791 if ((res >> 28) == ALC880_DCVOL_EVENT)
1792 alc880_uniwill_p53_dcvol_automute(codec);
1797 * F1734 pin configuration:
1798 * HP = 0x14, speaker-out = 0x15, mic = 0x18
1800 static struct hda_verb alc880_pin_f1734_init_verbs[] = {
1801 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
1802 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
1803 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
1804 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
1806 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1807 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1808 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1809 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1811 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1812 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1813 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1814 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1815 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1816 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1817 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1818 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1819 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1826 * ASUS pin configuration:
1827 * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
1829 static struct hda_verb alc880_pin_asus_init_verbs[] = {
1830 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
1831 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
1832 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
1833 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
1835 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1836 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1837 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1838 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1839 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1840 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1841 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1842 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1844 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1845 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1846 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1847 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1848 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1849 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1850 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1851 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1852 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1857 /* Enable GPIO mask and set output */
1858 #define alc880_gpio1_init_verbs alc_gpio1_init_verbs
1859 #define alc880_gpio2_init_verbs alc_gpio2_init_verbs
1861 /* Clevo m520g init */
1862 static struct hda_verb alc880_pin_clevo_init_verbs[] = {
1863 /* headphone output */
1864 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
1866 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1867 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1869 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1870 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1872 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1873 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1874 /* Mic1 (rear panel) */
1875 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1876 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1877 /* Mic2 (front panel) */
1878 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1879 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1881 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1882 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1883 /* change to EAPD mode */
1884 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
1885 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
1890 static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
1891 /* change to EAPD mode */
1892 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
1893 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
1895 /* Headphone output */
1896 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1898 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1899 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
1901 /* Line In pin widget for input */
1902 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1903 /* CD pin widget for input */
1904 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1905 /* Mic1 (rear panel) pin widget for input and vref at 80% */
1906 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1908 /* change to EAPD mode */
1909 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
1910 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
1916 * LG m1 express dual
1919 * Rear Line-In/Out (blue): 0x14
1920 * Build-in Mic-In: 0x15
1922 * HP-Out (green): 0x1b
1923 * Mic-In/Out (red): 0x19
1927 /* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
1928 static hda_nid_t alc880_lg_dac_nids[3] = {
1932 /* seems analog CD is not working */
1933 static struct hda_input_mux alc880_lg_capture_source = {
1938 { "Internal Mic", 0x6 },
1942 /* 2,4,6 channel modes */
1943 static struct hda_verb alc880_lg_ch2_init[] = {
1944 /* set line-in and mic-in to input */
1945 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1946 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1950 static struct hda_verb alc880_lg_ch4_init[] = {
1951 /* set line-in to out and mic-in to input */
1952 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
1953 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1957 static struct hda_verb alc880_lg_ch6_init[] = {
1958 /* set line-in and mic-in to output */
1959 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
1960 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
1964 static struct hda_channel_mode alc880_lg_ch_modes[3] = {
1965 { 2, alc880_lg_ch2_init },
1966 { 4, alc880_lg_ch4_init },
1967 { 6, alc880_lg_ch6_init },
1970 static struct snd_kcontrol_new alc880_lg_mixer[] = {
1971 /* FIXME: it's not really "master" but front channels */
1972 HDA_CODEC_VOLUME("Master Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
1973 HDA_BIND_MUTE("Master Playback Switch", 0x0f, 2, HDA_INPUT),
1974 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1975 HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
1976 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
1977 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
1978 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
1979 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
1980 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1981 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1982 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
1983 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
1984 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
1985 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
1987 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1988 .name = "Channel Mode",
1989 .info = alc_ch_mode_info,
1990 .get = alc_ch_mode_get,
1991 .put = alc_ch_mode_put,
1996 static struct hda_verb alc880_lg_init_verbs[] = {
1997 /* set capture source to mic-in */
1998 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1999 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2000 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2001 /* mute all amp mixer inputs */
2002 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
2003 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
2004 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
2005 /* line-in to input */
2006 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2007 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2009 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2010 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2012 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2013 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2014 /* mic-in to input */
2015 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
2016 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2017 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2019 {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
2020 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2021 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2023 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
2027 /* toggle speaker-output according to the hp-jack state */
2028 static void alc880_lg_automute(struct hda_codec *codec)
2030 unsigned int present;
2033 present = snd_hda_codec_read(codec, 0x1b, 0,
2034 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
2035 bits = present ? HDA_AMP_MUTE : 0;
2036 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
2037 HDA_AMP_MUTE, bits);
2040 static void alc880_lg_unsol_event(struct hda_codec *codec, unsigned int res)
2042 /* Looks like the unsol event is incompatible with the standard
2043 * definition. 4bit tag is placed at 28 bit!
2045 if ((res >> 28) == 0x01)
2046 alc880_lg_automute(codec);
2055 * Built-in Mic-In: 0x19
2061 static struct hda_input_mux alc880_lg_lw_capture_source = {
2065 { "Internal Mic", 0x1 },
2070 #define alc880_lg_lw_modes alc880_threestack_modes
2072 static struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
2073 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2074 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2075 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
2076 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
2077 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2078 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2079 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2080 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2081 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2082 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2083 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2084 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2085 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
2086 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
2088 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2089 .name = "Channel Mode",
2090 .info = alc_ch_mode_info,
2091 .get = alc_ch_mode_get,
2092 .put = alc_ch_mode_put,
2097 static struct hda_verb alc880_lg_lw_init_verbs[] = {
2098 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2099 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
2100 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
2102 /* set capture source to mic-in */
2103 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2104 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2105 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2106 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
2108 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2109 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2111 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2112 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2113 /* mic-in to input */
2114 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2115 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2117 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2118 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2120 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
2124 /* toggle speaker-output according to the hp-jack state */
2125 static void alc880_lg_lw_automute(struct hda_codec *codec)
2127 unsigned int present;
2130 present = snd_hda_codec_read(codec, 0x1b, 0,
2131 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
2132 bits = present ? HDA_AMP_MUTE : 0;
2133 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
2134 HDA_AMP_MUTE, bits);
2137 static void alc880_lg_lw_unsol_event(struct hda_codec *codec, unsigned int res)
2139 /* Looks like the unsol event is incompatible with the standard
2140 * definition. 4bit tag is placed at 28 bit!
2142 if ((res >> 28) == 0x01)
2143 alc880_lg_lw_automute(codec);
2146 #ifdef CONFIG_SND_HDA_POWER_SAVE
2147 static struct hda_amp_list alc880_loopbacks[] = {
2148 { 0x0b, HDA_INPUT, 0 },
2149 { 0x0b, HDA_INPUT, 1 },
2150 { 0x0b, HDA_INPUT, 2 },
2151 { 0x0b, HDA_INPUT, 3 },
2152 { 0x0b, HDA_INPUT, 4 },
2156 static struct hda_amp_list alc880_lg_loopbacks[] = {
2157 { 0x0b, HDA_INPUT, 1 },
2158 { 0x0b, HDA_INPUT, 6 },
2159 { 0x0b, HDA_INPUT, 7 },
2168 static int alc_init(struct hda_codec *codec)
2170 struct alc_spec *spec = codec->spec;
2173 for (i = 0; i < spec->num_init_verbs; i++)
2174 snd_hda_sequence_write(codec, spec->init_verbs[i]);
2176 if (spec->init_hook)
2177 spec->init_hook(codec);
2182 static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
2184 struct alc_spec *spec = codec->spec;
2186 if (spec->unsol_event)
2187 spec->unsol_event(codec, res);
2190 #ifdef CONFIG_SND_HDA_POWER_SAVE
2191 static int alc_check_power_status(struct hda_codec *codec, hda_nid_t nid)
2193 struct alc_spec *spec = codec->spec;
2194 return snd_hda_check_amp_list_power(codec, &spec->loopback, nid);
2199 * Analog playback callbacks
2201 static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
2202 struct hda_codec *codec,
2203 struct snd_pcm_substream *substream)
2205 struct alc_spec *spec = codec->spec;
2206 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream);
2209 static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2210 struct hda_codec *codec,
2211 unsigned int stream_tag,
2212 unsigned int format,
2213 struct snd_pcm_substream *substream)
2215 struct alc_spec *spec = codec->spec;
2216 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
2217 stream_tag, format, substream);
2220 static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
2221 struct hda_codec *codec,
2222 struct snd_pcm_substream *substream)
2224 struct alc_spec *spec = codec->spec;
2225 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
2231 static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
2232 struct hda_codec *codec,
2233 struct snd_pcm_substream *substream)
2235 struct alc_spec *spec = codec->spec;
2236 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
2239 static int alc880_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2240 struct hda_codec *codec,
2241 unsigned int stream_tag,
2242 unsigned int format,
2243 struct snd_pcm_substream *substream)
2245 struct alc_spec *spec = codec->spec;
2246 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
2247 stream_tag, format, substream);
2250 static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
2251 struct hda_codec *codec,
2252 struct snd_pcm_substream *substream)
2254 struct alc_spec *spec = codec->spec;
2255 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
2261 static int alc880_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
2262 struct hda_codec *codec,
2263 unsigned int stream_tag,
2264 unsigned int format,
2265 struct snd_pcm_substream *substream)
2267 struct alc_spec *spec = codec->spec;
2269 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
2270 stream_tag, 0, format);
2274 static int alc880_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
2275 struct hda_codec *codec,
2276 struct snd_pcm_substream *substream)
2278 struct alc_spec *spec = codec->spec;
2280 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
2288 static struct hda_pcm_stream alc880_pcm_analog_playback = {
2292 /* NID is set in alc_build_pcms */
2294 .open = alc880_playback_pcm_open,
2295 .prepare = alc880_playback_pcm_prepare,
2296 .cleanup = alc880_playback_pcm_cleanup
2300 static struct hda_pcm_stream alc880_pcm_analog_capture = {
2304 /* NID is set in alc_build_pcms */
2306 .prepare = alc880_capture_pcm_prepare,
2307 .cleanup = alc880_capture_pcm_cleanup
2311 static struct hda_pcm_stream alc880_pcm_digital_playback = {
2315 /* NID is set in alc_build_pcms */
2317 .open = alc880_dig_playback_pcm_open,
2318 .close = alc880_dig_playback_pcm_close,
2319 .prepare = alc880_dig_playback_pcm_prepare
2323 static struct hda_pcm_stream alc880_pcm_digital_capture = {
2327 /* NID is set in alc_build_pcms */
2330 /* Used by alc_build_pcms to flag that a PCM has no playback stream */
2331 static struct hda_pcm_stream alc_pcm_null_playback = {
2337 static int alc_build_pcms(struct hda_codec *codec)
2339 struct alc_spec *spec = codec->spec;
2340 struct hda_pcm *info = spec->pcm_rec;
2343 codec->num_pcms = 1;
2344 codec->pcm_info = info;
2346 info->name = spec->stream_name_analog;
2347 if (spec->stream_analog_playback) {
2348 snd_assert(spec->multiout.dac_nids, return -EINVAL);
2349 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
2350 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
2352 if (spec->stream_analog_capture) {
2353 snd_assert(spec->adc_nids, return -EINVAL);
2354 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
2355 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
2358 if (spec->channel_mode) {
2359 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
2360 for (i = 0; i < spec->num_channel_mode; i++) {
2361 if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
2362 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
2367 /* SPDIF for stream index #1 */
2368 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
2369 codec->num_pcms = 2;
2370 info = spec->pcm_rec + 1;
2371 info->name = spec->stream_name_digital;
2372 if (spec->multiout.dig_out_nid &&
2373 spec->stream_digital_playback) {
2374 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
2375 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
2377 if (spec->dig_in_nid &&
2378 spec->stream_digital_capture) {
2379 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
2380 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
2384 /* If the use of more than one ADC is requested for the current
2385 * model, configure a second analog capture-only PCM.
2387 /* Additional Analaog capture for index #2 */
2388 if (spec->num_adc_nids > 1 && spec->stream_analog_capture &&
2390 codec->num_pcms = 3;
2391 info = spec->pcm_rec + 2;
2392 info->name = spec->stream_name_analog;
2393 /* No playback stream for second PCM */
2394 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = alc_pcm_null_playback;
2395 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
2396 if (spec->stream_analog_capture) {
2397 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
2398 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[1];
2405 static void alc_free(struct hda_codec *codec)
2407 struct alc_spec *spec = codec->spec;
2413 if (spec->kctl_alloc) {
2414 for (i = 0; i < spec->num_kctl_used; i++)
2415 kfree(spec->kctl_alloc[i].name);
2416 kfree(spec->kctl_alloc);
2423 static struct hda_codec_ops alc_patch_ops = {
2424 .build_controls = alc_build_controls,
2425 .build_pcms = alc_build_pcms,
2428 .unsol_event = alc_unsol_event,
2429 #ifdef CONFIG_SND_HDA_POWER_SAVE
2430 .check_power_status = alc_check_power_status,
2436 * Test configuration for debugging
2438 * Almost all inputs/outputs are enabled. I/O pins can be configured via
2441 #ifdef CONFIG_SND_DEBUG
2442 static hda_nid_t alc880_test_dac_nids[4] = {
2443 0x02, 0x03, 0x04, 0x05
2446 static struct hda_input_mux alc880_test_capture_source = {
2455 { "Surround", 0x6 },
2459 static struct hda_channel_mode alc880_test_modes[4] = {
2466 static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol,
2467 struct snd_ctl_elem_info *uinfo)
2469 static char *texts[] = {
2470 "N/A", "Line Out", "HP Out",
2471 "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
2473 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
2475 uinfo->value.enumerated.items = 8;
2476 if (uinfo->value.enumerated.item >= 8)
2477 uinfo->value.enumerated.item = 7;
2478 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
2482 static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol,
2483 struct snd_ctl_elem_value *ucontrol)
2485 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2486 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2487 unsigned int pin_ctl, item = 0;
2489 pin_ctl = snd_hda_codec_read(codec, nid, 0,
2490 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
2491 if (pin_ctl & AC_PINCTL_OUT_EN) {
2492 if (pin_ctl & AC_PINCTL_HP_EN)
2496 } else if (pin_ctl & AC_PINCTL_IN_EN) {
2497 switch (pin_ctl & AC_PINCTL_VREFEN) {
2498 case AC_PINCTL_VREF_HIZ: item = 3; break;
2499 case AC_PINCTL_VREF_50: item = 4; break;
2500 case AC_PINCTL_VREF_GRD: item = 5; break;
2501 case AC_PINCTL_VREF_80: item = 6; break;
2502 case AC_PINCTL_VREF_100: item = 7; break;
2505 ucontrol->value.enumerated.item[0] = item;
2509 static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol,
2510 struct snd_ctl_elem_value *ucontrol)
2512 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2513 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2514 static unsigned int ctls[] = {
2515 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
2516 AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
2517 AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
2518 AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
2519 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
2520 AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
2522 unsigned int old_ctl, new_ctl;
2524 old_ctl = snd_hda_codec_read(codec, nid, 0,
2525 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
2526 new_ctl = ctls[ucontrol->value.enumerated.item[0]];
2527 if (old_ctl != new_ctl) {
2529 snd_hda_codec_write_cache(codec, nid, 0,
2530 AC_VERB_SET_PIN_WIDGET_CONTROL,
2532 val = ucontrol->value.enumerated.item[0] >= 3 ?
2534 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
2541 static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol,
2542 struct snd_ctl_elem_info *uinfo)
2544 static char *texts[] = {
2545 "Front", "Surround", "CLFE", "Side"
2547 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
2549 uinfo->value.enumerated.items = 4;
2550 if (uinfo->value.enumerated.item >= 4)
2551 uinfo->value.enumerated.item = 3;
2552 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
2556 static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol,
2557 struct snd_ctl_elem_value *ucontrol)
2559 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2560 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2563 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
2564 ucontrol->value.enumerated.item[0] = sel & 3;
2568 static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol,
2569 struct snd_ctl_elem_value *ucontrol)
2571 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2572 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2575 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
2576 if (ucontrol->value.enumerated.item[0] != sel) {
2577 sel = ucontrol->value.enumerated.item[0] & 3;
2578 snd_hda_codec_write_cache(codec, nid, 0,
2579 AC_VERB_SET_CONNECT_SEL, sel);
2585 #define PIN_CTL_TEST(xname,nid) { \
2586 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2588 .info = alc_test_pin_ctl_info, \
2589 .get = alc_test_pin_ctl_get, \
2590 .put = alc_test_pin_ctl_put, \
2591 .private_value = nid \
2594 #define PIN_SRC_TEST(xname,nid) { \
2595 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2597 .info = alc_test_pin_src_info, \
2598 .get = alc_test_pin_src_get, \
2599 .put = alc_test_pin_src_put, \
2600 .private_value = nid \
2603 static struct snd_kcontrol_new alc880_test_mixer[] = {
2604 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2605 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2606 HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
2607 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
2608 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2609 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
2610 HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
2611 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
2612 PIN_CTL_TEST("Front Pin Mode", 0x14),
2613 PIN_CTL_TEST("Surround Pin Mode", 0x15),
2614 PIN_CTL_TEST("CLFE Pin Mode", 0x16),
2615 PIN_CTL_TEST("Side Pin Mode", 0x17),
2616 PIN_CTL_TEST("In-1 Pin Mode", 0x18),
2617 PIN_CTL_TEST("In-2 Pin Mode", 0x19),
2618 PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
2619 PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
2620 PIN_SRC_TEST("In-1 Pin Source", 0x18),
2621 PIN_SRC_TEST("In-2 Pin Source", 0x19),
2622 PIN_SRC_TEST("In-3 Pin Source", 0x1a),
2623 PIN_SRC_TEST("In-4 Pin Source", 0x1b),
2624 HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
2625 HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
2626 HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
2627 HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
2628 HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
2629 HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
2630 HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
2631 HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
2632 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
2633 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
2635 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2636 .name = "Channel Mode",
2637 .info = alc_ch_mode_info,
2638 .get = alc_ch_mode_get,
2639 .put = alc_ch_mode_put,
2644 static struct hda_verb alc880_test_init_verbs[] = {
2645 /* Unmute inputs of 0x0c - 0x0f */
2646 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2647 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2648 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2649 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2650 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2651 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2652 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2653 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2654 /* Vol output for 0x0c-0x0f */
2655 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2656 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2657 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2658 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2659 /* Set output pins 0x14-0x17 */
2660 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2661 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2662 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2663 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2664 /* Unmute output pins 0x14-0x17 */
2665 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2666 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2667 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2668 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2669 /* Set input pins 0x18-0x1c */
2670 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2671 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2672 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2673 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2674 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2675 /* Mute input pins 0x18-0x1b */
2676 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2677 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2678 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2679 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2681 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2682 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
2683 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2684 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
2685 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2686 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
2687 /* Analog input/passthru */
2688 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2689 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2690 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
2691 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
2692 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
2700 static const char *alc880_models[ALC880_MODEL_LAST] = {
2701 [ALC880_3ST] = "3stack",
2702 [ALC880_TCL_S700] = "tcl",
2703 [ALC880_3ST_DIG] = "3stack-digout",
2704 [ALC880_CLEVO] = "clevo",
2705 [ALC880_5ST] = "5stack",
2706 [ALC880_5ST_DIG] = "5stack-digout",
2707 [ALC880_W810] = "w810",
2708 [ALC880_Z71V] = "z71v",
2709 [ALC880_6ST] = "6stack",
2710 [ALC880_6ST_DIG] = "6stack-digout",
2711 [ALC880_ASUS] = "asus",
2712 [ALC880_ASUS_W1V] = "asus-w1v",
2713 [ALC880_ASUS_DIG] = "asus-dig",
2714 [ALC880_ASUS_DIG2] = "asus-dig2",
2715 [ALC880_UNIWILL_DIG] = "uniwill",
2716 [ALC880_UNIWILL_P53] = "uniwill-p53",
2717 [ALC880_FUJITSU] = "fujitsu",
2718 [ALC880_F1734] = "F1734",
2720 [ALC880_LG_LW] = "lg-lw",
2721 #ifdef CONFIG_SND_DEBUG
2722 [ALC880_TEST] = "test",
2724 [ALC880_AUTO] = "auto",
2727 static struct snd_pci_quirk alc880_cfg_tbl[] = {
2728 /* Broken BIOS configuration */
2729 SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_6ST_DIG),
2730 SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_6ST_DIG),
2732 SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_5ST_DIG),
2733 SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_6ST),
2734 SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_W810),
2735 SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_3ST_DIG),
2736 SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_6ST_DIG),
2737 SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_6ST_DIG),
2738 SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_6ST_DIG),
2739 SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_3ST_DIG),
2740 SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_3ST),
2742 SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_6ST_DIG),
2743 SND_PCI_QUIRK(0x103c, 0x2a09, "HP", ALC880_5ST),
2745 SND_PCI_QUIRK(0x1043, 0x10b3, "ASUS W1V", ALC880_ASUS_W1V),
2746 SND_PCI_QUIRK(0x1043, 0x10c2, "ASUS W6A", ALC880_ASUS_DIG),
2747 SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS Wxx", ALC880_ASUS_DIG),
2748 SND_PCI_QUIRK(0x1043, 0x1113, "ASUS", ALC880_ASUS_DIG),
2749 SND_PCI_QUIRK(0x1043, 0x1123, "ASUS", ALC880_ASUS_DIG),
2750 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS", ALC880_ASUS_DIG),
2751 SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_Z71V),
2752 /* SND_PCI_QUIRK(0x1043, 0x1964, "ASUS", ALC880_ASUS_DIG), */
2753 SND_PCI_QUIRK(0x1043, 0x1973, "ASUS", ALC880_ASUS_DIG),
2754 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS", ALC880_ASUS_DIG),
2755 SND_PCI_QUIRK(0x1043, 0x814e, "ASUS", ALC880_ASUS),
2756 SND_PCI_QUIRK(0x1043, 0x8181, "ASUS P4GPL", ALC880_ASUS_DIG),
2757 SND_PCI_QUIRK(0x1043, 0x8196, "ASUS P5GD1", ALC880_6ST),
2758 SND_PCI_QUIRK(0x1043, 0x81b4, "ASUS", ALC880_6ST),
2759 SND_PCI_QUIRK(0x1043, 0, "ASUS", ALC880_ASUS),
2761 SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_3ST),
2762 SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_3ST),
2763 SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_5ST),
2764 SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_5ST),
2765 SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_5ST),
2766 SND_PCI_QUIRK(0x1558, 0x0520, "Clevo m520G", ALC880_CLEVO),
2767 SND_PCI_QUIRK(0x1558, 0x0660, "Clevo m655n", ALC880_CLEVO),
2768 SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_5ST_DIG),
2769 SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_W810),
2770 SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_5ST_DIG),
2771 SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_TCL_S700),
2772 SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_5ST_DIG),
2773 SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_6ST_DIG),
2774 SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_6ST_DIG),
2775 SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_6ST_DIG),
2776 SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_6ST_DIG),
2777 SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_6ST_DIG),
2778 SND_PCI_QUIRK(0x1558, 0x5401, "ASUS", ALC880_ASUS_DIG2),
2780 SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_UNIWILL_DIG),
2781 SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_UNIWILL),
2782 SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_UNIWILL_P53),
2783 SND_PCI_QUIRK(0x1584, 0x9054, "Uniwlll", ALC880_F1734),
2785 SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_5ST_DIG),
2786 SND_PCI_QUIRK(0x1734, 0x10ac, "FSC", ALC880_UNIWILL),
2787 SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_F1734),
2788 SND_PCI_QUIRK(0x1734, 0x10b0, "Fujitsu", ALC880_FUJITSU),
2790 SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_LG),
2791 SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_LG),
2792 SND_PCI_QUIRK(0x1854, 0x0018, "LG LW20", ALC880_LG_LW),
2793 SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_LG_LW),
2795 SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_3ST_DIG),
2796 SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_3ST_DIG),
2797 SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_3ST_DIG),
2798 SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_5ST_DIG),
2799 SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_5ST_DIG),
2800 SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_5ST_DIG),
2801 SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_5ST_DIG),
2802 SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_5ST_DIG),
2803 SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_5ST_DIG),
2804 SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_5ST_DIG),
2805 SND_PCI_QUIRK(0x8086, 0, "Intel mobo", ALC880_3ST),
2811 * ALC880 codec presets
2813 static struct alc_config_preset alc880_presets[] = {
2815 .mixers = { alc880_three_stack_mixer },
2816 .init_verbs = { alc880_volume_init_verbs,
2817 alc880_pin_3stack_init_verbs },
2818 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2819 .dac_nids = alc880_dac_nids,
2820 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
2821 .channel_mode = alc880_threestack_modes,
2823 .input_mux = &alc880_capture_source,
2825 [ALC880_3ST_DIG] = {
2826 .mixers = { alc880_three_stack_mixer },
2827 .init_verbs = { alc880_volume_init_verbs,
2828 alc880_pin_3stack_init_verbs },
2829 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2830 .dac_nids = alc880_dac_nids,
2831 .dig_out_nid = ALC880_DIGOUT_NID,
2832 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
2833 .channel_mode = alc880_threestack_modes,
2835 .input_mux = &alc880_capture_source,
2837 [ALC880_TCL_S700] = {
2838 .mixers = { alc880_tcl_s700_mixer },
2839 .init_verbs = { alc880_volume_init_verbs,
2840 alc880_pin_tcl_S700_init_verbs,
2841 alc880_gpio2_init_verbs },
2842 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2843 .dac_nids = alc880_dac_nids,
2845 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
2846 .channel_mode = alc880_2_jack_modes,
2847 .input_mux = &alc880_capture_source,
2850 .mixers = { alc880_three_stack_mixer,
2851 alc880_five_stack_mixer},
2852 .init_verbs = { alc880_volume_init_verbs,
2853 alc880_pin_5stack_init_verbs },
2854 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2855 .dac_nids = alc880_dac_nids,
2856 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
2857 .channel_mode = alc880_fivestack_modes,
2858 .input_mux = &alc880_capture_source,
2860 [ALC880_5ST_DIG] = {
2861 .mixers = { alc880_three_stack_mixer,
2862 alc880_five_stack_mixer },
2863 .init_verbs = { alc880_volume_init_verbs,
2864 alc880_pin_5stack_init_verbs },
2865 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2866 .dac_nids = alc880_dac_nids,
2867 .dig_out_nid = ALC880_DIGOUT_NID,
2868 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
2869 .channel_mode = alc880_fivestack_modes,
2870 .input_mux = &alc880_capture_source,
2873 .mixers = { alc880_six_stack_mixer },
2874 .init_verbs = { alc880_volume_init_verbs,
2875 alc880_pin_6stack_init_verbs },
2876 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
2877 .dac_nids = alc880_6st_dac_nids,
2878 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
2879 .channel_mode = alc880_sixstack_modes,
2880 .input_mux = &alc880_6stack_capture_source,
2882 [ALC880_6ST_DIG] = {
2883 .mixers = { alc880_six_stack_mixer },
2884 .init_verbs = { alc880_volume_init_verbs,
2885 alc880_pin_6stack_init_verbs },
2886 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
2887 .dac_nids = alc880_6st_dac_nids,
2888 .dig_out_nid = ALC880_DIGOUT_NID,
2889 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
2890 .channel_mode = alc880_sixstack_modes,
2891 .input_mux = &alc880_6stack_capture_source,
2894 .mixers = { alc880_w810_base_mixer },
2895 .init_verbs = { alc880_volume_init_verbs,
2896 alc880_pin_w810_init_verbs,
2897 alc880_gpio2_init_verbs },
2898 .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
2899 .dac_nids = alc880_w810_dac_nids,
2900 .dig_out_nid = ALC880_DIGOUT_NID,
2901 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
2902 .channel_mode = alc880_w810_modes,
2903 .input_mux = &alc880_capture_source,
2906 .mixers = { alc880_z71v_mixer },
2907 .init_verbs = { alc880_volume_init_verbs,
2908 alc880_pin_z71v_init_verbs },
2909 .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
2910 .dac_nids = alc880_z71v_dac_nids,
2911 .dig_out_nid = ALC880_DIGOUT_NID,
2913 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
2914 .channel_mode = alc880_2_jack_modes,
2915 .input_mux = &alc880_capture_source,
2918 .mixers = { alc880_f1734_mixer },
2919 .init_verbs = { alc880_volume_init_verbs,
2920 alc880_pin_f1734_init_verbs },
2921 .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
2922 .dac_nids = alc880_f1734_dac_nids,
2924 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
2925 .channel_mode = alc880_2_jack_modes,
2926 .input_mux = &alc880_capture_source,
2929 .mixers = { alc880_asus_mixer },
2930 .init_verbs = { alc880_volume_init_verbs,
2931 alc880_pin_asus_init_verbs,
2932 alc880_gpio1_init_verbs },
2933 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2934 .dac_nids = alc880_asus_dac_nids,
2935 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2936 .channel_mode = alc880_asus_modes,
2938 .input_mux = &alc880_capture_source,
2940 [ALC880_ASUS_DIG] = {
2941 .mixers = { alc880_asus_mixer },
2942 .init_verbs = { alc880_volume_init_verbs,
2943 alc880_pin_asus_init_verbs,
2944 alc880_gpio1_init_verbs },
2945 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2946 .dac_nids = alc880_asus_dac_nids,
2947 .dig_out_nid = ALC880_DIGOUT_NID,
2948 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2949 .channel_mode = alc880_asus_modes,
2951 .input_mux = &alc880_capture_source,
2953 [ALC880_ASUS_DIG2] = {
2954 .mixers = { alc880_asus_mixer },
2955 .init_verbs = { alc880_volume_init_verbs,
2956 alc880_pin_asus_init_verbs,
2957 alc880_gpio2_init_verbs }, /* use GPIO2 */
2958 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2959 .dac_nids = alc880_asus_dac_nids,
2960 .dig_out_nid = ALC880_DIGOUT_NID,
2961 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2962 .channel_mode = alc880_asus_modes,
2964 .input_mux = &alc880_capture_source,
2966 [ALC880_ASUS_W1V] = {
2967 .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
2968 .init_verbs = { alc880_volume_init_verbs,
2969 alc880_pin_asus_init_verbs,
2970 alc880_gpio1_init_verbs },
2971 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2972 .dac_nids = alc880_asus_dac_nids,
2973 .dig_out_nid = ALC880_DIGOUT_NID,
2974 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2975 .channel_mode = alc880_asus_modes,
2977 .input_mux = &alc880_capture_source,
2979 [ALC880_UNIWILL_DIG] = {
2980 .mixers = { alc880_asus_mixer, alc880_pcbeep_mixer },
2981 .init_verbs = { alc880_volume_init_verbs,
2982 alc880_pin_asus_init_verbs },
2983 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2984 .dac_nids = alc880_asus_dac_nids,
2985 .dig_out_nid = ALC880_DIGOUT_NID,
2986 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2987 .channel_mode = alc880_asus_modes,
2989 .input_mux = &alc880_capture_source,
2991 [ALC880_UNIWILL] = {
2992 .mixers = { alc880_uniwill_mixer },
2993 .init_verbs = { alc880_volume_init_verbs,
2994 alc880_uniwill_init_verbs },
2995 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2996 .dac_nids = alc880_asus_dac_nids,
2997 .dig_out_nid = ALC880_DIGOUT_NID,
2998 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
2999 .channel_mode = alc880_threestack_modes,
3001 .input_mux = &alc880_capture_source,
3002 .unsol_event = alc880_uniwill_unsol_event,
3003 .init_hook = alc880_uniwill_automute,
3005 [ALC880_UNIWILL_P53] = {
3006 .mixers = { alc880_uniwill_p53_mixer },
3007 .init_verbs = { alc880_volume_init_verbs,
3008 alc880_uniwill_p53_init_verbs },
3009 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3010 .dac_nids = alc880_asus_dac_nids,
3011 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
3012 .channel_mode = alc880_threestack_modes,
3013 .input_mux = &alc880_capture_source,
3014 .unsol_event = alc880_uniwill_p53_unsol_event,
3015 .init_hook = alc880_uniwill_p53_hp_automute,
3017 [ALC880_FUJITSU] = {
3018 .mixers = { alc880_fujitsu_mixer,
3019 alc880_pcbeep_mixer, },
3020 .init_verbs = { alc880_volume_init_verbs,
3021 alc880_uniwill_p53_init_verbs,
3022 alc880_beep_init_verbs },
3023 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3024 .dac_nids = alc880_dac_nids,
3025 .dig_out_nid = ALC880_DIGOUT_NID,
3026 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3027 .channel_mode = alc880_2_jack_modes,
3028 .input_mux = &alc880_capture_source,
3029 .unsol_event = alc880_uniwill_p53_unsol_event,
3030 .init_hook = alc880_uniwill_p53_hp_automute,
3033 .mixers = { alc880_three_stack_mixer },
3034 .init_verbs = { alc880_volume_init_verbs,
3035 alc880_pin_clevo_init_verbs },
3036 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3037 .dac_nids = alc880_dac_nids,
3039 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3040 .channel_mode = alc880_threestack_modes,
3042 .input_mux = &alc880_capture_source,
3045 .mixers = { alc880_lg_mixer },
3046 .init_verbs = { alc880_volume_init_verbs,
3047 alc880_lg_init_verbs },
3048 .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids),
3049 .dac_nids = alc880_lg_dac_nids,
3050 .dig_out_nid = ALC880_DIGOUT_NID,
3051 .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes),
3052 .channel_mode = alc880_lg_ch_modes,
3054 .input_mux = &alc880_lg_capture_source,
3055 .unsol_event = alc880_lg_unsol_event,
3056 .init_hook = alc880_lg_automute,
3057 #ifdef CONFIG_SND_HDA_POWER_SAVE
3058 .loopbacks = alc880_lg_loopbacks,
3062 .mixers = { alc880_lg_lw_mixer },
3063 .init_verbs = { alc880_volume_init_verbs,
3064 alc880_lg_lw_init_verbs },
3065 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3066 .dac_nids = alc880_dac_nids,
3067 .dig_out_nid = ALC880_DIGOUT_NID,
3068 .num_channel_mode = ARRAY_SIZE(alc880_lg_lw_modes),
3069 .channel_mode = alc880_lg_lw_modes,
3070 .input_mux = &alc880_lg_lw_capture_source,
3071 .unsol_event = alc880_lg_lw_unsol_event,
3072 .init_hook = alc880_lg_lw_automute,
3074 #ifdef CONFIG_SND_DEBUG
3076 .mixers = { alc880_test_mixer },
3077 .init_verbs = { alc880_test_init_verbs },
3078 .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
3079 .dac_nids = alc880_test_dac_nids,
3080 .dig_out_nid = ALC880_DIGOUT_NID,
3081 .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
3082 .channel_mode = alc880_test_modes,
3083 .input_mux = &alc880_test_capture_source,
3089 * Automatic parse of I/O pins from the BIOS configuration
3092 #define NUM_CONTROL_ALLOC 32
3093 #define NUM_VERB_ALLOC 32
3097 ALC_CTL_WIDGET_MUTE,
3100 static struct snd_kcontrol_new alc880_control_templates[] = {
3101 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
3102 HDA_CODEC_MUTE(NULL, 0, 0, 0),
3103 HDA_BIND_MUTE(NULL, 0, 0, 0),
3106 /* add dynamic controls */
3107 static int add_control(struct alc_spec *spec, int type, const char *name,
3110 struct snd_kcontrol_new *knew;
3112 if (spec->num_kctl_used >= spec->num_kctl_alloc) {
3113 int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC;
3115 /* array + terminator */
3116 knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL);
3119 if (spec->kctl_alloc) {
3120 memcpy(knew, spec->kctl_alloc,
3121 sizeof(*knew) * spec->num_kctl_alloc);
3122 kfree(spec->kctl_alloc);
3124 spec->kctl_alloc = knew;
3125 spec->num_kctl_alloc = num;
3128 knew = &spec->kctl_alloc[spec->num_kctl_used];
3129 *knew = alc880_control_templates[type];
3130 knew->name = kstrdup(name, GFP_KERNEL);
3133 knew->private_value = val;
3134 spec->num_kctl_used++;
3138 #define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
3139 #define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
3140 #define alc880_is_multi_pin(nid) ((nid) >= 0x18)
3141 #define alc880_multi_pin_idx(nid) ((nid) - 0x18)
3142 #define alc880_is_input_pin(nid) ((nid) >= 0x18)
3143 #define alc880_input_pin_idx(nid) ((nid) - 0x18)
3144 #define alc880_idx_to_dac(nid) ((nid) + 0x02)
3145 #define alc880_dac_to_idx(nid) ((nid) - 0x02)
3146 #define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
3147 #define alc880_idx_to_selector(nid) ((nid) + 0x10)
3148 #define ALC880_PIN_CD_NID 0x1c
3150 /* fill in the dac_nids table from the parsed pin configuration */
3151 static int alc880_auto_fill_dac_nids(struct alc_spec *spec,
3152 const struct auto_pin_cfg *cfg)
3158 memset(assigned, 0, sizeof(assigned));
3159 spec->multiout.dac_nids = spec->private_dac_nids;
3161 /* check the pins hardwired to audio widget */
3162 for (i = 0; i < cfg->line_outs; i++) {
3163 nid = cfg->line_out_pins[i];
3164 if (alc880_is_fixed_pin(nid)) {
3165 int idx = alc880_fixed_pin_idx(nid);
3166 spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
3170 /* left pins can be connect to any audio widget */
3171 for (i = 0; i < cfg->line_outs; i++) {
3172 nid = cfg->line_out_pins[i];
3173 if (alc880_is_fixed_pin(nid))
3175 /* search for an empty channel */
3176 for (j = 0; j < cfg->line_outs; j++) {
3178 spec->multiout.dac_nids[i] =
3179 alc880_idx_to_dac(j);
3185 spec->multiout.num_dacs = cfg->line_outs;
3189 /* add playback controls from the parsed DAC table */
3190 static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
3191 const struct auto_pin_cfg *cfg)
3194 static const char *chname[4] = {
3195 "Front", "Surround", NULL /*CLFE*/, "Side"
3200 for (i = 0; i < cfg->line_outs; i++) {
3201 if (!spec->multiout.dac_nids[i])
3203 nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
3206 err = add_control(spec, ALC_CTL_WIDGET_VOL,
3207 "Center Playback Volume",
3208 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
3212 err = add_control(spec, ALC_CTL_WIDGET_VOL,
3213 "LFE Playback Volume",
3214 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
3218 err = add_control(spec, ALC_CTL_BIND_MUTE,
3219 "Center Playback Switch",
3220 HDA_COMPOSE_AMP_VAL(nid, 1, 2,
3224 err = add_control(spec, ALC_CTL_BIND_MUTE,
3225 "LFE Playback Switch",
3226 HDA_COMPOSE_AMP_VAL(nid, 2, 2,
3231 sprintf(name, "%s Playback Volume", chname[i]);
3232 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
3233 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
3237 sprintf(name, "%s Playback Switch", chname[i]);
3238 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
3239 HDA_COMPOSE_AMP_VAL(nid, 3, 2,
3248 /* add playback controls for speaker and HP outputs */
3249 static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
3259 if (alc880_is_fixed_pin(pin)) {
3260 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
3261 /* specify the DAC as the extra output */
3262 if (!spec->multiout.hp_nid)
3263 spec->multiout.hp_nid = nid;
3265 spec->multiout.extra_out_nid[0] = nid;
3266 /* control HP volume/switch on the output mixer amp */
3267 nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
3268 sprintf(name, "%s Playback Volume", pfx);
3269 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
3270 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
3273 sprintf(name, "%s Playback Switch", pfx);
3274 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
3275 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
3278 } else if (alc880_is_multi_pin(pin)) {
3279 /* set manual connection */
3280 /* we have only a switch on HP-out PIN */
3281 sprintf(name, "%s Playback Switch", pfx);
3282 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
3283 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
3290 /* create input playback/capture controls for the given pin */
3291 static int new_analog_input(struct alc_spec *spec, hda_nid_t pin,
3292 const char *ctlname,
3293 int idx, hda_nid_t mix_nid)
3298 sprintf(name, "%s Playback Volume", ctlname);
3299 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
3300 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
3303 sprintf(name, "%s Playback Switch", ctlname);
3304 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
3305 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
3311 /* create playback/capture controls for input pins */
3312 static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec,
3313 const struct auto_pin_cfg *cfg)
3315 struct hda_input_mux *imux = &spec->private_imux;
3318 for (i = 0; i < AUTO_PIN_LAST; i++) {
3319 if (alc880_is_input_pin(cfg->input_pins[i])) {
3320 idx = alc880_input_pin_idx(cfg->input_pins[i]);
3321 err = new_analog_input(spec, cfg->input_pins[i],
3322 auto_pin_cfg_labels[i],
3326 imux->items[imux->num_items].label =
3327 auto_pin_cfg_labels[i];
3328 imux->items[imux->num_items].index =
3329 alc880_input_pin_idx(cfg->input_pins[i]);
3336 static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
3337 hda_nid_t nid, int pin_type,
3341 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
3343 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
3345 /* need the manual connection? */
3346 if (alc880_is_multi_pin(nid)) {
3347 struct alc_spec *spec = codec->spec;
3348 int idx = alc880_multi_pin_idx(nid);
3349 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
3350 AC_VERB_SET_CONNECT_SEL,
3351 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
3355 static int get_pin_type(int line_out_type)
3357 if (line_out_type == AUTO_PIN_HP_OUT)
3363 static void alc880_auto_init_multi_out(struct hda_codec *codec)
3365 struct alc_spec *spec = codec->spec;
3368 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
3369 for (i = 0; i < spec->autocfg.line_outs; i++) {
3370 hda_nid_t nid = spec->autocfg.line_out_pins[i];
3371 int pin_type = get_pin_type(spec->autocfg.line_out_type);
3372 alc880_auto_set_output_and_unmute(codec, nid, pin_type, i);
3376 static void alc880_auto_init_extra_out(struct hda_codec *codec)
3378 struct alc_spec *spec = codec->spec;
3381 pin = spec->autocfg.speaker_pins[0];
3382 if (pin) /* connect to front */
3383 alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
3384 pin = spec->autocfg.hp_pins[0];
3385 if (pin) /* connect to front */
3386 alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
3389 static void alc880_auto_init_analog_input(struct hda_codec *codec)
3391 struct alc_spec *spec = codec->spec;
3394 for (i = 0; i < AUTO_PIN_LAST; i++) {
3395 hda_nid_t nid = spec->autocfg.input_pins[i];
3396 if (alc880_is_input_pin(nid)) {
3397 snd_hda_codec_write(codec, nid, 0,
3398 AC_VERB_SET_PIN_WIDGET_CONTROL,
3399 i <= AUTO_PIN_FRONT_MIC ?
3400 PIN_VREF80 : PIN_IN);
3401 if (nid != ALC880_PIN_CD_NID)
3402 snd_hda_codec_write(codec, nid, 0,
3403 AC_VERB_SET_AMP_GAIN_MUTE,
3409 /* parse the BIOS configuration and set up the alc_spec */
3410 /* return 1 if successful, 0 if the proper config is not found,
3411 * or a negative error code
3413 static int alc880_parse_auto_config(struct hda_codec *codec)
3415 struct alc_spec *spec = codec->spec;
3417 static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
3419 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
3423 if (!spec->autocfg.line_outs)
3424 return 0; /* can't find valid BIOS pin config */
3426 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
3429 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
3432 err = alc880_auto_create_extra_out(spec,
3433 spec->autocfg.speaker_pins[0],
3437 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
3441 err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
3445 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
3447 if (spec->autocfg.dig_out_pin)
3448 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
3449 if (spec->autocfg.dig_in_pin)
3450 spec->dig_in_nid = ALC880_DIGIN_NID;
3452 if (spec->kctl_alloc)
3453 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
3455 spec->init_verbs[spec->num_init_verbs++] = alc880_volume_init_verbs;
3457 spec->num_mux_defs = 1;
3458 spec->input_mux = &spec->private_imux;
3463 /* additional initialization for auto-configuration model */
3464 static void alc880_auto_init(struct hda_codec *codec)
3466 alc880_auto_init_multi_out(codec);
3467 alc880_auto_init_extra_out(codec);
3468 alc880_auto_init_analog_input(codec);
3472 * OK, here we have finally the patch for ALC880
3475 static int patch_alc880(struct hda_codec *codec)
3477 struct alc_spec *spec;
3481 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
3487 board_config = snd_hda_check_board_config(codec, ALC880_MODEL_LAST,
3490 if (board_config < 0) {
3491 printk(KERN_INFO "hda_codec: Unknown model for ALC880, "
3492 "trying auto-probe from BIOS...\n");
3493 board_config = ALC880_AUTO;
3496 if (board_config == ALC880_AUTO) {
3497 /* automatic parse from the BIOS config */
3498 err = alc880_parse_auto_config(codec);
3504 "hda_codec: Cannot set up configuration "
3505 "from BIOS. Using 3-stack mode...\n");
3506 board_config = ALC880_3ST;
3510 if (board_config != ALC880_AUTO)
3511 setup_preset(spec, &alc880_presets[board_config]);
3513 spec->stream_name_analog = "ALC880 Analog";
3514 spec->stream_analog_playback = &alc880_pcm_analog_playback;
3515 spec->stream_analog_capture = &alc880_pcm_analog_capture;
3517 spec->stream_name_digital = "ALC880 Digital";
3518 spec->stream_digital_playback = &alc880_pcm_digital_playback;
3519 spec->stream_digital_capture = &alc880_pcm_digital_capture;
3521 if (!spec->adc_nids && spec->input_mux) {
3522 /* check whether NID 0x07 is valid */
3523 unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
3525 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
3526 if (wcap != AC_WID_AUD_IN) {
3527 spec->adc_nids = alc880_adc_nids_alt;
3528 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
3529 spec->mixers[spec->num_mixers] =
3530 alc880_capture_alt_mixer;
3533 spec->adc_nids = alc880_adc_nids;
3534 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
3535 spec->mixers[spec->num_mixers] = alc880_capture_mixer;
3540 codec->patch_ops = alc_patch_ops;
3541 if (board_config == ALC880_AUTO)
3542 spec->init_hook = alc880_auto_init;
3543 #ifdef CONFIG_SND_HDA_POWER_SAVE
3544 if (!spec->loopback.amplist)
3545 spec->loopback.amplist = alc880_loopbacks;
3556 static hda_nid_t alc260_dac_nids[1] = {
3561 static hda_nid_t alc260_adc_nids[1] = {
3566 static hda_nid_t alc260_adc_nids_alt[1] = {
3571 static hda_nid_t alc260_hp_adc_nids[2] = {
3576 /* NIDs used when simultaneous access to both ADCs makes sense. Note that
3577 * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
3579 static hda_nid_t alc260_dual_adc_nids[2] = {
3584 #define ALC260_DIGOUT_NID 0x03
3585 #define ALC260_DIGIN_NID 0x06
3587 static struct hda_input_mux alc260_capture_source = {
3591 { "Front Mic", 0x1 },
3597 /* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
3598 * headphone jack and the internal CD lines since these are the only pins at
3599 * which audio can appear. For flexibility, also allow the option of
3600 * recording the mixer output on the second ADC (ADC0 doesn't have a
3601 * connection to the mixer output).
3603 static struct hda_input_mux alc260_fujitsu_capture_sources[2] = {
3607 { "Mic/Line", 0x0 },
3609 { "Headphone", 0x2 },
3615 { "Mic/Line", 0x0 },
3617 { "Headphone", 0x2 },
3624 /* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to
3625 * the Fujitsu S702x, but jacks are marked differently.
3627 static struct hda_input_mux alc260_acer_capture_sources[2] = {
3634 { "Headphone", 0x5 },
3643 { "Headphone", 0x6 },
3649 * This is just place-holder, so there's something for alc_build_pcms to look
3650 * at when it calculates the maximum number of channels. ALC260 has no mixer
3651 * element which allows changing the channel mode, so the verb list is
3654 static struct hda_channel_mode alc260_modes[1] = {
3659 /* Mixer combinations
3661 * basic: base_output + input + pc_beep + capture
3662 * HP: base_output + input + capture_alt
3663 * HP_3013: hp_3013 + input + capture
3664 * fujitsu: fujitsu + capture
3665 * acer: acer + capture
3668 static struct snd_kcontrol_new alc260_base_output_mixer[] = {
3669 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3670 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
3671 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
3672 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
3673 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
3674 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
3678 static struct snd_kcontrol_new alc260_input_mixer[] = {
3679 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3680 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
3681 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
3682 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
3683 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
3684 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
3685 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
3686 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
3690 static struct snd_kcontrol_new alc260_pc_beep_mixer[] = {
3691 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x07, 0x05, HDA_INPUT),
3692 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x07, 0x05, HDA_INPUT),
3696 static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
3697 HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
3698 HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
3699 HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
3700 HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
3701 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3702 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
3703 HDA_CODEC_VOLUME_MONO("iSpeaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
3704 HDA_CODEC_MUTE_MONO("iSpeaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
3708 /* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12,
3709 * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10.
3711 static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
3712 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3713 HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
3714 ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
3715 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3716 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
3717 HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
3718 HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
3719 ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
3720 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
3721 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
3722 HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
3723 HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x09, 2, HDA_INPUT),
3727 /* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current
3728 * versions of the ALC260 don't act on requests to enable mic bias from NID
3729 * 0x0f (used to drive the headphone jack in these laptops). The ALC260
3730 * datasheet doesn't mention this restriction. At this stage it's not clear
3731 * whether this behaviour is intentional or is a hardware bug in chip
3732 * revisions available in early 2006. Therefore for now allow the
3733 * "Headphone Jack Mode" control to span all choices, but if it turns out
3734 * that the lack of mic bias for this NID is intentional we could change the
3735 * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
3737 * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006
3738 * don't appear to make the mic bias available from the "line" jack, even
3739 * though the NID used for this jack (0x14) can supply it. The theory is
3740 * that perhaps Acer have included blocking capacitors between the ALC260
3741 * and the output jack. If this turns out to be the case for all such
3742 * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
3743 * to ALC_PIN_DIR_INOUT_NOMICBIAS.
3745 * The C20x Tablet series have a mono internal speaker which is controlled
3746 * via the chip's Mono sum widget and pin complex, so include the necessary
3747 * controls for such models. On models without a "mono speaker" the control
3748 * won't do anything.
3750 static struct snd_kcontrol_new alc260_acer_mixer[] = {
3751 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3752 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
3753 ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
3754 HDA_CODEC_VOLUME_MONO("Mono Speaker Playback Volume", 0x0a, 1, 0x0,
3756 HDA_BIND_MUTE_MONO("Mono Speaker Playback Switch", 0x0a, 1, 2,
3758 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3759 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
3760 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
3761 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
3762 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
3763 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
3764 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
3765 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
3766 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
3767 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
3771 /* Packard bell V7900 ALC260 pin usage: HP = 0x0f, Mic jack = 0x12,
3772 * Line In jack = 0x14, CD audio = 0x16, pc beep = 0x17.
3774 static struct snd_kcontrol_new alc260_will_mixer[] = {
3775 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3776 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
3777 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
3778 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
3779 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
3780 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
3781 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
3782 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
3783 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3784 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
3785 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
3786 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
3790 /* Replacer 672V ALC260 pin usage: Mic jack = 0x12,
3791 * Line In jack = 0x14, ATAPI Mic = 0x13, speaker = 0x0f.
3793 static struct snd_kcontrol_new alc260_replacer_672v_mixer[] = {
3794 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3795 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
3796 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
3797 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
3798 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
3799 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x07, 0x1, HDA_INPUT),
3800 HDA_CODEC_MUTE("ATATI Mic Playback Switch", 0x07, 0x1, HDA_INPUT),
3801 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
3802 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
3803 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
3807 /* capture mixer elements */
3808 static struct snd_kcontrol_new alc260_capture_mixer[] = {
3809 HDA_CODEC_VOLUME("Capture Volume", 0x04, 0x0, HDA_INPUT),
3810 HDA_CODEC_MUTE("Capture Switch", 0x04, 0x0, HDA_INPUT),
3811 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x05, 0x0, HDA_INPUT),
3812 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x05, 0x0, HDA_INPUT),
3814 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3815 /* The multiple "Capture Source" controls confuse alsamixer
3816 * So call somewhat different..
3817 * FIXME: the controls appear in the "playback" view!
3819 /* .name = "Capture Source", */
3820 .name = "Input Source",
3822 .info = alc_mux_enum_info,
3823 .get = alc_mux_enum_get,
3824 .put = alc_mux_enum_put,
3829 static struct snd_kcontrol_new alc260_capture_alt_mixer[] = {
3830 HDA_CODEC_VOLUME("Capture Volume", 0x05, 0x0, HDA_INPUT),
3831 HDA_CODEC_MUTE("Capture Switch", 0x05, 0x0, HDA_INPUT),
3833 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3834 /* The multiple "Capture Source" controls confuse alsamixer
3835 * So call somewhat different..
3836 * FIXME: the controls appear in the "playback" view!
3838 /* .name = "Capture Source", */
3839 .name = "Input Source",
3841 .info = alc_mux_enum_info,
3842 .get = alc_mux_enum_get,
3843 .put = alc_mux_enum_put,
3849 * initialization verbs
3851 static struct hda_verb alc260_init_verbs[] = {
3852 /* Line In pin widget for input */
3853 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3854 /* CD pin widget for input */
3855 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3856 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3857 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3858 /* Mic2 (front panel) pin widget for input and vref at 80% */
3859 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3860 /* LINE-2 is used for line-out in rear */
3861 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3862 /* select line-out */
3863 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
3865 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3867 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3869 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3870 /* mute capture amp left and right */
3871 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3872 /* set connection select to line in (default select for this ADC) */
3873 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
3874 /* mute capture amp left and right */
3875 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3876 /* set connection select to line in (default select for this ADC) */
3877 {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
3878 /* set vol=0 Line-Out mixer amp left and right */
3879 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3880 /* unmute pin widget amp left and right (no gain on this amp) */
3881 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3882 /* set vol=0 HP mixer amp left and right */
3883 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3884 /* unmute pin widget amp left and right (no gain on this amp) */
3885 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3886 /* set vol=0 Mono mixer amp left and right */
3887 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3888 /* unmute pin widget amp left and right (no gain on this amp) */
3889 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3890 /* unmute LINE-2 out pin */
3891 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3892 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
3895 /* mute analog inputs */
3896 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3897 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3898 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
3899 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
3900 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
3901 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
3902 /* mute Front out path */
3903 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3904 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3905 /* mute Headphone out path */
3906 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3907 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3908 /* mute Mono out path */
3909 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3910 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3914 #if 0 /* should be identical with alc260_init_verbs? */
3915 static struct hda_verb alc260_hp_init_verbs[] = {
3916 /* Headphone and output */
3917 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
3919 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
3920 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3921 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
3922 /* Mic2 (front panel) pin widget for input and vref at 80% */
3923 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
3924 /* Line In pin widget for input */
3925 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
3926 /* Line-2 pin widget for output */
3927 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
3928 /* CD pin widget for input */
3929 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
3930 /* unmute amp left and right */
3931 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
3932 /* set connection select to line in (default select for this ADC) */
3933 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
3934 /* unmute Line-Out mixer amp left and right (volume = 0) */
3935 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
3936 /* mute pin widget amp left and right (no gain on this amp) */
3937 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
3938 /* unmute HP mixer amp left and right (volume = 0) */
3939 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
3940 /* mute pin widget amp left and right (no gain on this amp) */
3941 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
3942 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
3945 /* mute analog inputs */
3946 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3947 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3948 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
3949 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
3950 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
3951 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
3952 /* Unmute Front out path */
3953 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3954 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3955 /* Unmute Headphone out path */
3956 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3957 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3958 /* Unmute Mono out path */
3959 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3960 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3965 static struct hda_verb alc260_hp_3013_init_verbs[] = {
3966 /* Line out and output */
3967 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
3969 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
3970 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3971 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
3972 /* Mic2 (front panel) pin widget for input and vref at 80% */
3973 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
3974 /* Line In pin widget for input */
3975 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
3976 /* Headphone pin widget for output */
3977 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
3978 /* CD pin widget for input */
3979 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
3980 /* unmute amp left and right */
3981 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
3982 /* set connection select to line in (default select for this ADC) */
3983 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
3984 /* unmute Line-Out mixer amp left and right (volume = 0) */
3985 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
3986 /* mute pin widget amp left and right (no gain on this amp) */
3987 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
3988 /* unmute HP mixer amp left and right (volume = 0) */
3989 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
3990 /* mute pin widget amp left and right (no gain on this amp) */
3991 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
3992 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
3995 /* mute analog inputs */
3996 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3997 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3998 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
3999 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4000 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
4001 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
4002 /* Unmute Front out path */
4003 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4004 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4005 /* Unmute Headphone out path */
4006 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4007 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4008 /* Unmute Mono out path */
4009 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4010 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4014 /* Initialisation sequence for ALC260 as configured in Fujitsu S702x
4015 * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD
4016 * audio = 0x16, internal speaker = 0x10.
4018 static struct hda_verb alc260_fujitsu_init_verbs[] = {
4019 /* Disable all GPIOs */
4020 {0x01, AC_VERB_SET_GPIO_MASK, 0},
4021 /* Internal speaker is connected to headphone pin */
4022 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4023 /* Headphone/Line-out jack connects to Line1 pin; make it an output */
4024 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4025 /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
4026 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
4027 /* Ensure all other unused pins are disabled and muted. */
4028 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
4029 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4030 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
4031 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4032 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
4033 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4034 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
4035 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4037 /* Disable digital (SPDIF) pins */
4038 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
4039 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
4041 /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
4042 * when acting as an output.
4044 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
4046 /* Start with output sum widgets muted and their output gains at min */
4047 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4048 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4049 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4050 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4051 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4052 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4053 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4054 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4055 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4057 /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
4058 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4059 /* Unmute Line1 pin widget output buffer since it starts as an output.
4060 * If the pin mode is changed by the user the pin mode control will
4061 * take care of enabling the pin's input/output buffers as needed.
4062 * Therefore there's no need to enable the input buffer at this
4065 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4066 /* Unmute input buffer of pin widget used for Line-in (no equiv
4069 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4071 /* Mute capture amp left and right */
4072 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4073 /* Set ADC connection select to match default mixer setting - line
4076 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
4078 /* Do the same for the second ADC: mute capture input amp and
4079 * set ADC connection to line in (on mic1 pin)
4081 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4082 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
4084 /* Mute all inputs to mixer widget (even unconnected ones) */
4085 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
4086 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
4087 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
4088 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
4089 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
4090 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
4091 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
4092 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
4097 /* Initialisation sequence for ALC260 as configured in Acer TravelMate and
4098 * similar laptops (adapted from Fujitsu init verbs).
4100 static struct hda_verb alc260_acer_init_verbs[] = {
4101 /* On TravelMate laptops, GPIO 0 enables the internal speaker and
4102 * the headphone jack. Turn this on and rely on the standard mute
4103 * methods whenever the user wants to turn these outputs off.
4105 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
4106 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
4107 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
4108 /* Internal speaker/Headphone jack is connected to Line-out pin */
4109 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4110 /* Internal microphone/Mic jack is connected to Mic1 pin */
4111 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
4112 /* Line In jack is connected to Line1 pin */
4113 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
4114 /* Some Acers (eg: C20x Tablets) use Mono pin for internal speaker */
4115 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4116 /* Ensure all other unused pins are disabled and muted. */
4117 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
4118 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4119 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
4120 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4121 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
4122 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4123 /* Disable digital (SPDIF) pins */
4124 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
4125 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
4127 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
4128 * bus when acting as outputs.
4130 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
4131 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
4133 /* Start with output sum widgets muted and their output gains at min */
4134 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4135 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4136 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4137 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4138 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4139 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4140 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4141 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4142 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4144 /* Unmute Line-out pin widget amp left and right
4145 * (no equiv mixer ctrl)
4147 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4148 /* Unmute mono pin widget amp output (no equiv mixer ctrl) */
4149 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4150 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
4151 * inputs. If the pin mode is changed by the user the pin mode control
4152 * will take care of enabling the pin's input/output buffers as needed.
4153 * Therefore there's no need to enable the input buffer at this
4156 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4157 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4159 /* Mute capture amp left and right */
4160 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4161 /* Set ADC connection select to match default mixer setting - mic
4164 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
4166 /* Do similar with the second ADC: mute capture input amp and
4167 * set ADC connection to mic to match ALSA's default state.
4169 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4170 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
4172 /* Mute all inputs to mixer widget (even unconnected ones) */
4173 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
4174 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
4175 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
4176 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
4177 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
4178 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
4179 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
4180 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
4185 static struct hda_verb alc260_will_verbs[] = {
4186 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4187 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x00},
4188 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
4189 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
4190 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
4191 {0x1a, AC_VERB_SET_PROC_COEF, 0x3040},
4195 static struct hda_verb alc260_replacer_672v_verbs[] = {
4196 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
4197 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
4198 {0x1a, AC_VERB_SET_PROC_COEF, 0x3050},
4200 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
4201 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
4202 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
4204 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
4208 /* toggle speaker-output according to the hp-jack state */
4209 static void alc260_replacer_672v_automute(struct hda_codec *codec)
4211 unsigned int present;
4213 /* speaker --> GPIO Data 0, hp or spdif --> GPIO data 1 */
4214 present = snd_hda_codec_read(codec, 0x0f, 0,
4215 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
4217 snd_hda_codec_write_cache(codec, 0x01, 0,
4218 AC_VERB_SET_GPIO_DATA, 1);
4219 snd_hda_codec_write_cache(codec, 0x0f, 0,
4220 AC_VERB_SET_PIN_WIDGET_CONTROL,
4223 snd_hda_codec_write_cache(codec, 0x01, 0,
4224 AC_VERB_SET_GPIO_DATA, 0);
4225 snd_hda_codec_write_cache(codec, 0x0f, 0,
4226 AC_VERB_SET_PIN_WIDGET_CONTROL,
4231 static void alc260_replacer_672v_unsol_event(struct hda_codec *codec,
4234 if ((res >> 26) == ALC880_HP_EVENT)
4235 alc260_replacer_672v_automute(codec);
4238 /* Test configuration for debugging, modelled after the ALC880 test
4241 #ifdef CONFIG_SND_DEBUG
4242 static hda_nid_t alc260_test_dac_nids[1] = {
4245 static hda_nid_t alc260_test_adc_nids[2] = {
4248 /* For testing the ALC260, each input MUX needs its own definition since
4249 * the signal assignments are different. This assumes that the first ADC
4252 static struct hda_input_mux alc260_test_capture_sources[2] = {
4256 { "MIC1 pin", 0x0 },
4257 { "MIC2 pin", 0x1 },
4258 { "LINE1 pin", 0x2 },
4259 { "LINE2 pin", 0x3 },
4261 { "LINE-OUT pin", 0x5 },
4262 { "HP-OUT pin", 0x6 },
4268 { "MIC1 pin", 0x0 },
4269 { "MIC2 pin", 0x1 },
4270 { "LINE1 pin", 0x2 },
4271 { "LINE2 pin", 0x3 },
4274 { "LINE-OUT pin", 0x6 },
4275 { "HP-OUT pin", 0x7 },
4279 static struct snd_kcontrol_new alc260_test_mixer[] = {
4280 /* Output driver widgets */
4281 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
4282 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
4283 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4284 HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
4285 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4286 HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
4288 /* Modes for retasking pin widgets
4289 * Note: the ALC260 doesn't seem to act on requests to enable mic
4290 * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't
4291 * mention this restriction. At this stage it's not clear whether
4292 * this behaviour is intentional or is a hardware bug in chip
4293 * revisions available at least up until early 2006. Therefore for
4294 * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all
4295 * choices, but if it turns out that the lack of mic bias for these
4296 * NIDs is intentional we could change their modes from
4297 * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
4299 ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
4300 ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
4301 ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
4302 ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
4303 ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
4304 ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
4306 /* Loopback mixer controls */
4307 HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
4308 HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
4309 HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
4310 HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
4311 HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
4312 HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
4313 HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
4314 HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
4315 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4316 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4317 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
4318 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
4319 HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
4320 HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
4321 HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
4322 HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
4324 /* Controls for GPIO pins, assuming they are configured as outputs */
4325 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
4326 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
4327 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
4328 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
4330 /* Switches to allow the digital IO pins to be enabled. The datasheet
4331 * is ambigious as to which NID is which; testing on laptops which
4332 * make this output available should provide clarification.
4334 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
4335 ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
4339 static struct hda_verb alc260_test_init_verbs[] = {
4340 /* Enable all GPIOs as outputs with an initial value of 0 */
4341 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
4342 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
4343 {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
4345 /* Enable retasking pins as output, initially without power amp */
4346 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4347 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4348 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4349 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4350 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4351 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4353 /* Disable digital (SPDIF) pins initially, but users can enable
4354 * them via a mixer switch. In the case of SPDIF-out, this initverb
4355 * payload also sets the generation to 0, output to be in "consumer"
4356 * PCM format, copyright asserted, no pre-emphasis and no validity
4359 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
4360 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
4362 /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
4363 * OUT1 sum bus when acting as an output.
4365 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
4366 {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
4367 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
4368 {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
4370 /* Start with output sum widgets muted and their output gains at min */
4371 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4372 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4373 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4374 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4375 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4376 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4377 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4378 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4379 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4381 /* Unmute retasking pin widget output buffers since the default
4382 * state appears to be output. As the pin mode is changed by the
4383 * user the pin mode control will take care of enabling the pin's
4384 * input/output buffers as needed.
4386 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4387 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4388 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4389 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4390 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4391 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4392 /* Also unmute the mono-out pin widget */
4393 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4395 /* Mute capture amp left and right */
4396 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4397 /* Set ADC connection select to match default mixer setting (mic1
4400 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
4402 /* Do the same for the second ADC: mute capture input amp and
4403 * set ADC connection to mic1 pin
4405 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4406 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
4408 /* Mute all inputs to mixer widget (even unconnected ones) */
4409 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
4410 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
4411 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
4412 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
4413 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
4414 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
4415 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
4416 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
4422 static struct hda_pcm_stream alc260_pcm_analog_playback = {
4428 static struct hda_pcm_stream alc260_pcm_analog_capture = {
4434 #define alc260_pcm_digital_playback alc880_pcm_digital_playback
4435 #define alc260_pcm_digital_capture alc880_pcm_digital_capture
4438 * for BIOS auto-configuration
4441 static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
4445 unsigned long vol_val, sw_val;
4449 if (nid >= 0x0f && nid < 0x11) {
4450 nid_vol = nid - 0x7;
4451 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
4452 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
4453 } else if (nid == 0x11) {
4454 nid_vol = nid - 0x7;
4455 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
4456 sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
4457 } else if (nid >= 0x12 && nid <= 0x15) {
4459 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
4460 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
4464 snprintf(name, sizeof(name), "%s Playback Volume", pfx);
4465 err = add_control(spec, ALC_CTL_WIDGET_VOL, name, vol_val);
4468 snprintf(name, sizeof(name), "%s Playback Switch", pfx);
4469 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, sw_val);
4475 /* add playback controls from the parsed DAC table */
4476 static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
4477 const struct auto_pin_cfg *cfg)
4482 spec->multiout.num_dacs = 1;
4483 spec->multiout.dac_nids = spec->private_dac_nids;
4484 spec->multiout.dac_nids[0] = 0x02;
4486 nid = cfg->line_out_pins[0];
4488 err = alc260_add_playback_controls(spec, nid, "Front");
4493 nid = cfg->speaker_pins[0];
4495 err = alc260_add_playback_controls(spec, nid, "Speaker");
4500 nid = cfg->hp_pins[0];
4502 err = alc260_add_playback_controls(spec, nid, "Headphone");
4509 /* create playback/capture controls for input pins */
4510 static int alc260_auto_create_analog_input_ctls(struct alc_spec *spec,
4511 const struct auto_pin_cfg *cfg)
4513 struct hda_input_mux *imux = &spec->private_imux;
4516 for (i = 0; i < AUTO_PIN_LAST; i++) {
4517 if (cfg->input_pins[i] >= 0x12) {
4518 idx = cfg->input_pins[i] - 0x12;
4519 err = new_analog_input(spec, cfg->input_pins[i],
4520 auto_pin_cfg_labels[i], idx,
4524 imux->items[imux->num_items].label =
4525 auto_pin_cfg_labels[i];
4526 imux->items[imux->num_items].index = idx;
4529 if (cfg->input_pins[i] >= 0x0f && cfg->input_pins[i] <= 0x10){
4530 idx = cfg->input_pins[i] - 0x09;
4531 err = new_analog_input(spec, cfg->input_pins[i],
4532 auto_pin_cfg_labels[i], idx,
4536 imux->items[imux->num_items].label =
4537 auto_pin_cfg_labels[i];
4538 imux->items[imux->num_items].index = idx;
4545 static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
4546 hda_nid_t nid, int pin_type,
4550 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4552 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
4554 /* need the manual connection? */
4556 int idx = nid - 0x12;
4557 snd_hda_codec_write(codec, idx + 0x0b, 0,
4558 AC_VERB_SET_CONNECT_SEL, sel_idx);
4562 static void alc260_auto_init_multi_out(struct hda_codec *codec)
4564 struct alc_spec *spec = codec->spec;
4567 alc_subsystem_id(codec, 0x10, 0x15, 0x0f);
4568 nid = spec->autocfg.line_out_pins[0];
4570 int pin_type = get_pin_type(spec->autocfg.line_out_type);
4571 alc260_auto_set_output_and_unmute(codec, nid, pin_type, 0);
4574 nid = spec->autocfg.speaker_pins[0];
4576 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
4578 nid = spec->autocfg.hp_pins[0];
4580 alc260_auto_set_output_and_unmute(codec, nid, PIN_HP, 0);
4583 #define ALC260_PIN_CD_NID 0x16
4584 static void alc260_auto_init_analog_input(struct hda_codec *codec)
4586 struct alc_spec *spec = codec->spec;
4589 for (i = 0; i < AUTO_PIN_LAST; i++) {
4590 hda_nid_t nid = spec->autocfg.input_pins[i];
4592 snd_hda_codec_write(codec, nid, 0,
4593 AC_VERB_SET_PIN_WIDGET_CONTROL,
4594 i <= AUTO_PIN_FRONT_MIC ?
4595 PIN_VREF80 : PIN_IN);
4596 if (nid != ALC260_PIN_CD_NID)
4597 snd_hda_codec_write(codec, nid, 0,
4598 AC_VERB_SET_AMP_GAIN_MUTE,
4605 * generic initialization of ADC, input mixers and output mixers
4607 static struct hda_verb alc260_volume_init_verbs[] = {
4609 * Unmute ADC0-1 and set the default input to mic-in
4611 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
4612 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4613 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
4614 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4616 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
4618 * Note: PASD motherboards uses the Line In 2 as the input for
4619 * front panel mic (mic 2)
4621 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
4622 /* mute analog inputs */
4623 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4624 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4625 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4626 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4627 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
4630 * Set up output mixers (0x08 - 0x0a)
4632 /* set vol=0 to output mixers */
4633 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4634 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4635 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4636 /* set up input amps for analog loopback */
4637 /* Amp Indices: DAC = 0, mixer = 1 */
4638 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4639 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4640 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4641 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4642 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4643 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4648 static int alc260_parse_auto_config(struct hda_codec *codec)
4650 struct alc_spec *spec = codec->spec;
4653 static hda_nid_t alc260_ignore[] = { 0x17, 0 };
4655 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
4659 err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg);
4662 if (!spec->kctl_alloc)
4663 return 0; /* can't find valid BIOS pin config */
4664 err = alc260_auto_create_analog_input_ctls(spec, &spec->autocfg);
4668 spec->multiout.max_channels = 2;
4670 if (spec->autocfg.dig_out_pin)
4671 spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
4672 if (spec->kctl_alloc)
4673 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
4675 spec->init_verbs[spec->num_init_verbs++] = alc260_volume_init_verbs;
4677 spec->num_mux_defs = 1;
4678 spec->input_mux = &spec->private_imux;
4680 /* check whether NID 0x04 is valid */
4681 wcap = get_wcaps(codec, 0x04);
4682 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
4683 if (wcap != AC_WID_AUD_IN) {
4684 spec->adc_nids = alc260_adc_nids_alt;
4685 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
4686 spec->mixers[spec->num_mixers] = alc260_capture_alt_mixer;
4688 spec->adc_nids = alc260_adc_nids;
4689 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
4690 spec->mixers[spec->num_mixers] = alc260_capture_mixer;
4697 /* additional initialization for auto-configuration model */
4698 static void alc260_auto_init(struct hda_codec *codec)
4700 alc260_auto_init_multi_out(codec);
4701 alc260_auto_init_analog_input(codec);
4704 #ifdef CONFIG_SND_HDA_POWER_SAVE
4705 static struct hda_amp_list alc260_loopbacks[] = {
4706 { 0x07, HDA_INPUT, 0 },
4707 { 0x07, HDA_INPUT, 1 },
4708 { 0x07, HDA_INPUT, 2 },
4709 { 0x07, HDA_INPUT, 3 },
4710 { 0x07, HDA_INPUT, 4 },
4716 * ALC260 configurations
4718 static const char *alc260_models[ALC260_MODEL_LAST] = {
4719 [ALC260_BASIC] = "basic",
4721 [ALC260_HP_3013] = "hp-3013",
4722 [ALC260_FUJITSU_S702X] = "fujitsu",
4723 [ALC260_ACER] = "acer",
4724 [ALC260_WILL] = "will",
4725 [ALC260_REPLACER_672V] = "replacer",
4726 #ifdef CONFIG_SND_DEBUG
4727 [ALC260_TEST] = "test",
4729 [ALC260_AUTO] = "auto",
4732 static struct snd_pci_quirk alc260_cfg_tbl[] = {
4733 SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER),
4734 SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER),
4735 SND_PCI_QUIRK(0x103c, 0x2808, "HP d5700", ALC260_HP_3013),
4736 SND_PCI_QUIRK(0x103c, 0x280a, "HP d5750", ALC260_HP_3013),
4737 SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013),
4738 SND_PCI_QUIRK(0x103c, 0x3011, "HP", ALC260_HP),
4739 SND_PCI_QUIRK(0x103c, 0x3012, "HP", ALC260_HP_3013),
4740 SND_PCI_QUIRK(0x103c, 0x3013, "HP", ALC260_HP_3013),
4741 SND_PCI_QUIRK(0x103c, 0x3014, "HP", ALC260_HP),
4742 SND_PCI_QUIRK(0x103c, 0x3015, "HP", ALC260_HP),
4743 SND_PCI_QUIRK(0x103c, 0x3016, "HP", ALC260_HP),
4744 SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_BASIC),
4745 SND_PCI_QUIRK(0x104d, 0x81cc, "Sony VAIO", ALC260_BASIC),
4746 SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC),
4747 SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X),
4748 SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC),
4749 SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_WILL),
4750 SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_REPLACER_672V),
4754 static struct alc_config_preset alc260_presets[] = {
4756 .mixers = { alc260_base_output_mixer,
4758 alc260_pc_beep_mixer,
4759 alc260_capture_mixer },
4760 .init_verbs = { alc260_init_verbs },
4761 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4762 .dac_nids = alc260_dac_nids,
4763 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
4764 .adc_nids = alc260_adc_nids,
4765 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4766 .channel_mode = alc260_modes,
4767 .input_mux = &alc260_capture_source,
4770 .mixers = { alc260_base_output_mixer,
4772 alc260_capture_alt_mixer },
4773 .init_verbs = { alc260_init_verbs },
4774 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4775 .dac_nids = alc260_dac_nids,
4776 .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
4777 .adc_nids = alc260_hp_adc_nids,
4778 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4779 .channel_mode = alc260_modes,
4780 .input_mux = &alc260_capture_source,
4782 [ALC260_HP_3013] = {
4783 .mixers = { alc260_hp_3013_mixer,
4785 alc260_capture_alt_mixer },
4786 .init_verbs = { alc260_hp_3013_init_verbs },
4787 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4788 .dac_nids = alc260_dac_nids,
4789 .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
4790 .adc_nids = alc260_hp_adc_nids,
4791 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4792 .channel_mode = alc260_modes,
4793 .input_mux = &alc260_capture_source,
4795 [ALC260_FUJITSU_S702X] = {
4796 .mixers = { alc260_fujitsu_mixer,
4797 alc260_capture_mixer },
4798 .init_verbs = { alc260_fujitsu_init_verbs },
4799 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4800 .dac_nids = alc260_dac_nids,
4801 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
4802 .adc_nids = alc260_dual_adc_nids,
4803 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4804 .channel_mode = alc260_modes,
4805 .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources),
4806 .input_mux = alc260_fujitsu_capture_sources,
4809 .mixers = { alc260_acer_mixer,
4810 alc260_capture_mixer },
4811 .init_verbs = { alc260_acer_init_verbs },
4812 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4813 .dac_nids = alc260_dac_nids,
4814 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
4815 .adc_nids = alc260_dual_adc_nids,
4816 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4817 .channel_mode = alc260_modes,
4818 .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
4819 .input_mux = alc260_acer_capture_sources,
4822 .mixers = { alc260_will_mixer,
4823 alc260_capture_mixer },
4824 .init_verbs = { alc260_init_verbs, alc260_will_verbs },
4825 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4826 .dac_nids = alc260_dac_nids,
4827 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
4828 .adc_nids = alc260_adc_nids,
4829 .dig_out_nid = ALC260_DIGOUT_NID,
4830 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4831 .channel_mode = alc260_modes,
4832 .input_mux = &alc260_capture_source,
4834 [ALC260_REPLACER_672V] = {
4835 .mixers = { alc260_replacer_672v_mixer,
4836 alc260_capture_mixer },
4837 .init_verbs = { alc260_init_verbs, alc260_replacer_672v_verbs },
4838 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4839 .dac_nids = alc260_dac_nids,
4840 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
4841 .adc_nids = alc260_adc_nids,
4842 .dig_out_nid = ALC260_DIGOUT_NID,
4843 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4844 .channel_mode = alc260_modes,
4845 .input_mux = &alc260_capture_source,
4846 .unsol_event = alc260_replacer_672v_unsol_event,
4847 .init_hook = alc260_replacer_672v_automute,
4849 #ifdef CONFIG_SND_DEBUG
4851 .mixers = { alc260_test_mixer,
4852 alc260_capture_mixer },
4853 .init_verbs = { alc260_test_init_verbs },
4854 .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
4855 .dac_nids = alc260_test_dac_nids,
4856 .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
4857 .adc_nids = alc260_test_adc_nids,
4858 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4859 .channel_mode = alc260_modes,
4860 .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources),
4861 .input_mux = alc260_test_capture_sources,
4866 static int patch_alc260(struct hda_codec *codec)
4868 struct alc_spec *spec;
4869 int err, board_config;
4871 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4877 board_config = snd_hda_check_board_config(codec, ALC260_MODEL_LAST,
4880 if (board_config < 0) {
4881 snd_printd(KERN_INFO "hda_codec: Unknown model for ALC260, "
4882 "trying auto-probe from BIOS...\n");
4883 board_config = ALC260_AUTO;
4886 if (board_config == ALC260_AUTO) {
4887 /* automatic parse from the BIOS config */
4888 err = alc260_parse_auto_config(codec);
4894 "hda_codec: Cannot set up configuration "
4895 "from BIOS. Using base mode...\n");
4896 board_config = ALC260_BASIC;
4900 if (board_config != ALC260_AUTO)
4901 setup_preset(spec, &alc260_presets[board_config]);
4903 spec->stream_name_analog = "ALC260 Analog";
4904 spec->stream_analog_playback = &alc260_pcm_analog_playback;
4905 spec->stream_analog_capture = &alc260_pcm_analog_capture;
4907 spec->stream_name_digital = "ALC260 Digital";
4908 spec->stream_digital_playback = &alc260_pcm_digital_playback;
4909 spec->stream_digital_capture = &alc260_pcm_digital_capture;
4911 codec->patch_ops = alc_patch_ops;
4912 if (board_config == ALC260_AUTO)
4913 spec->init_hook = alc260_auto_init;
4914 #ifdef CONFIG_SND_HDA_POWER_SAVE
4915 if (!spec->loopback.amplist)
4916 spec->loopback.amplist = alc260_loopbacks;
4926 * ALC882 is almost identical with ALC880 but has cleaner and more flexible
4927 * configuration. Each pin widget can choose any input DACs and a mixer.
4928 * Each ADC is connected from a mixer of all inputs. This makes possible
4929 * 6-channel independent captures.
4931 * In addition, an independent DAC for the multi-playback (not used in this
4934 #define ALC882_DIGOUT_NID 0x06
4935 #define ALC882_DIGIN_NID 0x0a
4937 static struct hda_channel_mode alc882_ch_modes[1] = {
4941 static hda_nid_t alc882_dac_nids[4] = {
4942 /* front, rear, clfe, rear_surr */
4943 0x02, 0x03, 0x04, 0x05
4946 /* identical with ALC880 */
4947 #define alc882_adc_nids alc880_adc_nids
4948 #define alc882_adc_nids_alt alc880_adc_nids_alt
4951 /* FIXME: should be a matrix-type input source selection */
4953 static struct hda_input_mux alc882_capture_source = {
4957 { "Front Mic", 0x1 },
4962 #define alc882_mux_enum_info alc_mux_enum_info
4963 #define alc882_mux_enum_get alc_mux_enum_get
4965 static int alc882_mux_enum_put(struct snd_kcontrol *kcontrol,
4966 struct snd_ctl_elem_value *ucontrol)
4968 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4969 struct alc_spec *spec = codec->spec;
4970 const struct hda_input_mux *imux = spec->input_mux;
4971 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
4972 static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
4973 hda_nid_t nid = capture_mixers[adc_idx];
4974 unsigned int *cur_val = &spec->cur_mux[adc_idx];
4975 unsigned int i, idx;
4977 idx = ucontrol->value.enumerated.item[0];
4978 if (idx >= imux->num_items)
4979 idx = imux->num_items - 1;
4980 if (*cur_val == idx)
4982 for (i = 0; i < imux->num_items; i++) {
4983 unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
4984 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
4985 imux->items[i].index,
4995 static struct hda_verb alc882_3ST_ch2_init[] = {
4996 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
4997 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
4998 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
4999 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
5006 static struct hda_verb alc882_3ST_ch6_init[] = {
5007 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5008 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
5009 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
5010 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5011 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
5012 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
5016 static struct hda_channel_mode alc882_3ST_6ch_modes[2] = {
5017 { 2, alc882_3ST_ch2_init },
5018 { 6, alc882_3ST_ch6_init },
5024 static struct hda_verb alc882_sixstack_ch6_init[] = {
5025 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
5026 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5027 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5028 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5035 static struct hda_verb alc882_sixstack_ch8_init[] = {
5036 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5037 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5038 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5039 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5043 static struct hda_channel_mode alc882_sixstack_modes[2] = {
5044 { 6, alc882_sixstack_ch6_init },
5045 { 8, alc882_sixstack_ch8_init },
5049 * macbook pro ALC885 can switch LineIn to LineOut without loosing Mic
5055 static struct hda_verb alc885_mbp_ch2_init[] = {
5056 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
5057 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5058 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5065 static struct hda_verb alc885_mbp_ch6_init[] = {
5066 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5067 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5068 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
5069 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5070 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5074 static struct hda_channel_mode alc885_mbp_6ch_modes[2] = {
5075 { 2, alc885_mbp_ch2_init },
5076 { 6, alc885_mbp_ch6_init },
5080 /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
5081 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
5083 static struct snd_kcontrol_new alc882_base_mixer[] = {
5084 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5085 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5086 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
5087 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
5088 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
5089 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
5090 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
5091 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
5092 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
5093 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
5094 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5095 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5096 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5097 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5098 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5099 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5100 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
5101 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5102 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
5103 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
5104 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
5105 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
5106 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
5110 static struct snd_kcontrol_new alc885_mbp3_mixer[] = {
5111 HDA_CODEC_VOLUME("Master Volume", 0x0c, 0x00, HDA_OUTPUT),
5112 HDA_BIND_MUTE ("Master Switch", 0x0c, 0x02, HDA_INPUT),
5113 HDA_CODEC_MUTE ("Speaker Switch", 0x14, 0x00, HDA_OUTPUT),
5114 HDA_CODEC_VOLUME("Line Out Volume", 0x0d,0x00, HDA_OUTPUT),
5115 HDA_CODEC_VOLUME("Line In Playback Volume", 0x0b, 0x02, HDA_INPUT),
5116 HDA_CODEC_MUTE ("Line In Playback Switch", 0x0b, 0x02, HDA_INPUT),
5117 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
5118 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
5119 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0x00, HDA_INPUT),
5120 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
5123 static struct snd_kcontrol_new alc882_w2jc_mixer[] = {
5124 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5125 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5126 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5127 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5128 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5129 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5130 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5131 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
5132 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5133 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
5134 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
5138 static struct snd_kcontrol_new alc882_targa_mixer[] = {
5139 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5140 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5141 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5142 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5143 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5144 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5145 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5146 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5147 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5148 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
5149 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
5150 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
5151 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
5155 /* Pin assignment: Front=0x14, HP = 0x15, Front = 0x16, ???
5156 * Front Mic=0x18, Line In = 0x1a, Line In = 0x1b, CD = 0x1c
5158 static struct snd_kcontrol_new alc882_asus_a7j_mixer[] = {
5159 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5160 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
5161 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
5162 HDA_CODEC_MUTE("Mobile Front Playback Switch", 0x16, 0x0, HDA_OUTPUT),
5163 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5164 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5165 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5166 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5167 HDA_CODEC_VOLUME("Mobile Line Playback Volume", 0x0b, 0x03, HDA_INPUT),
5168 HDA_CODEC_MUTE("Mobile Line Playback Switch", 0x0b, 0x03, HDA_INPUT),
5169 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5170 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5171 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
5175 static struct snd_kcontrol_new alc882_asus_a7m_mixer[] = {
5176 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5177 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5178 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
5179 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5180 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5181 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5182 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5183 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5184 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
5185 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5186 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
5187 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
5191 static struct snd_kcontrol_new alc882_chmode_mixer[] = {
5193 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5194 .name = "Channel Mode",
5195 .info = alc_ch_mode_info,
5196 .get = alc_ch_mode_get,
5197 .put = alc_ch_mode_put,
5202 static struct hda_verb alc882_init_verbs[] = {
5203 /* Front mixer: unmute input/output amp left and right (volume = 0) */
5204 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5205 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5206 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5208 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5209 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5210 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5212 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5213 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5214 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5216 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5217 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5218 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5220 /* Front Pin: output 0 (0x0c) */
5221 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5222 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5223 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
5224 /* Rear Pin: output 1 (0x0d) */
5225 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5226 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5227 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
5228 /* CLFE Pin: output 2 (0x0e) */
5229 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5230 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5231 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
5232 /* Side Pin: output 3 (0x0f) */
5233 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5234 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5235 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
5236 /* Mic (rear) pin: input vref at 80% */
5237 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5238 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5239 /* Front Mic pin: input vref at 80% */
5240 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5241 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5242 /* Line In pin: input */
5243 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
5244 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5245 /* Line-2 In: Headphone output (output 0 - 0x0c) */
5246 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5247 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5248 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
5249 /* CD pin widget for input */
5250 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
5252 /* FIXME: use matrix-type input source selection */
5253 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5254 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
5255 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5256 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5257 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5258 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5260 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5261 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5262 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5263 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5265 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5266 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5267 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5268 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5269 /* ADC1: mute amp left and right */
5270 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5271 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
5272 /* ADC2: mute amp left and right */
5273 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5274 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
5275 /* ADC3: mute amp left and right */
5276 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5277 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
5282 static struct hda_verb alc882_eapd_verbs[] = {
5283 /* change to EAPD mode */
5284 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
5285 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
5290 static struct snd_kcontrol_new alc882_macpro_mixer[] = {
5291 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5292 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5293 HDA_CODEC_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT),
5294 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
5295 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
5296 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x02, HDA_INPUT),
5297 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x02, HDA_INPUT),
5301 static struct hda_verb alc882_macpro_init_verbs[] = {
5302 /* Front mixer: unmute input/output amp left and right (volume = 0) */
5303 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5304 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5305 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5306 /* Front Pin: output 0 (0x0c) */
5307 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5308 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5309 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
5310 /* Front Mic pin: input vref at 80% */
5311 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5312 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5313 /* Speaker: output */
5314 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5315 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5316 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x04},
5317 /* Headphone output (output 0 - 0x0c) */
5318 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5319 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5320 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
5322 /* FIXME: use matrix-type input source selection */
5323 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5324 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
5325 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5326 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5327 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5328 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5330 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5331 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5332 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5333 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5335 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5336 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5337 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5338 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5339 /* ADC1: mute amp left and right */
5340 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5341 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
5342 /* ADC2: mute amp left and right */
5343 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5344 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
5345 /* ADC3: mute amp left and right */
5346 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5347 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
5352 /* Macbook Pro rev3 */
5353 static struct hda_verb alc885_mbp3_init_verbs[] = {
5354 /* Front mixer: unmute input/output amp left and right (volume = 0) */
5355 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5356 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5357 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5359 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5360 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5361 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5362 /* Front Pin: output 0 (0x0c) */
5363 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5364 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5365 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
5366 /* HP Pin: output 0 (0x0d) */
5367 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4},
5368 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5369 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
5370 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
5371 /* Mic (rear) pin: input vref at 80% */
5372 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5373 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5374 /* Front Mic pin: input vref at 80% */
5375 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5376 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5377 /* Line In pin: use output 1 when in LineOut mode */
5378 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
5379 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5380 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
5382 /* FIXME: use matrix-type input source selection */
5383 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5384 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
5385 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5386 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5387 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5388 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5390 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5391 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5392 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5393 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5395 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5396 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5397 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5398 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5399 /* ADC1: mute amp left and right */
5400 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5401 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
5402 /* ADC2: mute amp left and right */
5403 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5404 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
5405 /* ADC3: mute amp left and right */
5406 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5407 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
5412 /* iMac 24 mixer. */
5413 static struct snd_kcontrol_new alc885_imac24_mixer[] = {
5414 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
5415 HDA_CODEC_MUTE("Master Playback Switch", 0x0c, 0x00, HDA_INPUT),
5419 /* iMac 24 init verbs. */
5420 static struct hda_verb alc885_imac24_init_verbs[] = {
5421 /* Internal speakers: output 0 (0x0c) */
5422 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5423 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5424 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
5425 /* Internal speakers: output 0 (0x0c) */
5426 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5427 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5428 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
5429 /* Headphone: output 0 (0x0c) */
5430 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5431 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5432 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
5433 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
5434 /* Front Mic: input vref at 80% */
5435 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5436 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5440 /* Toggle speaker-output according to the hp-jack state */
5441 static void alc885_imac24_automute(struct hda_codec *codec)
5443 unsigned int present;
5445 present = snd_hda_codec_read(codec, 0x14, 0,
5446 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
5447 snd_hda_codec_amp_stereo(codec, 0x18, HDA_OUTPUT, 0,
5448 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
5449 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_OUTPUT, 0,
5450 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
5453 /* Processes unsolicited events. */
5454 static void alc885_imac24_unsol_event(struct hda_codec *codec,
5457 /* Headphone insertion or removal. */
5458 if ((res >> 26) == ALC880_HP_EVENT)
5459 alc885_imac24_automute(codec);
5462 static void alc885_mbp3_automute(struct hda_codec *codec)
5464 unsigned int present;
5466 present = snd_hda_codec_read(codec, 0x15, 0,
5467 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
5468 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
5469 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
5470 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
5471 HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
5474 static void alc885_mbp3_unsol_event(struct hda_codec *codec,
5477 /* Headphone insertion or removal. */
5478 if ((res >> 26) == ALC880_HP_EVENT)
5479 alc885_mbp3_automute(codec);
5483 static struct hda_verb alc882_targa_verbs[] = {
5484 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5485 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5487 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5488 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5490 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
5491 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
5492 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
5494 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
5495 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
5496 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
5497 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
5501 /* toggle speaker-output according to the hp-jack state */
5502 static void alc882_targa_automute(struct hda_codec *codec)
5504 unsigned int present;
5506 present = snd_hda_codec_read(codec, 0x14, 0,
5507 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
5508 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
5509 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
5510 snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
5514 static void alc882_targa_unsol_event(struct hda_codec *codec, unsigned int res)
5516 /* Looks like the unsol event is incompatible with the standard
5517 * definition. 4bit tag is placed at 26 bit!
5519 if (((res >> 26) == ALC880_HP_EVENT)) {
5520 alc882_targa_automute(codec);
5524 static struct hda_verb alc882_asus_a7j_verbs[] = {
5525 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5526 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5528 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5529 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5530 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5532 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
5533 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
5534 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
5536 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
5537 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
5538 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
5542 static struct hda_verb alc882_asus_a7m_verbs[] = {
5543 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5544 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5546 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5547 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5548 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5550 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
5551 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
5552 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
5554 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
5555 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
5556 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
5560 static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
5562 unsigned int gpiostate, gpiomask, gpiodir;
5564 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
5565 AC_VERB_GET_GPIO_DATA, 0);
5568 gpiostate |= (1 << pin);
5570 gpiostate &= ~(1 << pin);
5572 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
5573 AC_VERB_GET_GPIO_MASK, 0);
5574 gpiomask |= (1 << pin);
5576 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
5577 AC_VERB_GET_GPIO_DIRECTION, 0);
5578 gpiodir |= (1 << pin);
5581 snd_hda_codec_write(codec, codec->afg, 0,
5582 AC_VERB_SET_GPIO_MASK, gpiomask);
5583 snd_hda_codec_write(codec, codec->afg, 0,
5584 AC_VERB_SET_GPIO_DIRECTION, gpiodir);
5588 snd_hda_codec_write(codec, codec->afg, 0,
5589 AC_VERB_SET_GPIO_DATA, gpiostate);
5592 /* set up GPIO at initialization */
5593 static void alc885_macpro_init_hook(struct hda_codec *codec)
5595 alc882_gpio_mute(codec, 0, 0);
5596 alc882_gpio_mute(codec, 1, 0);
5599 /* set up GPIO and update auto-muting at initialization */
5600 static void alc885_imac24_init_hook(struct hda_codec *codec)
5602 alc885_macpro_init_hook(codec);
5603 alc885_imac24_automute(codec);
5607 * generic initialization of ADC, input mixers and output mixers
5609 static struct hda_verb alc882_auto_init_verbs[] = {
5611 * Unmute ADC0-2 and set the default input to mic-in
5613 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
5614 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5615 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
5616 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5617 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
5618 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5620 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
5622 * Note: PASD motherboards uses the Line In 2 as the input for
5623 * front panel mic (mic 2)
5625 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
5626 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5627 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5628 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5629 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5630 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5633 * Set up output mixers (0x0c - 0x0f)
5635 /* set vol=0 to output mixers */
5636 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5637 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5638 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5639 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5640 /* set up input amps for analog loopback */
5641 /* Amp Indices: DAC = 0, mixer = 1 */
5642 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5643 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5644 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5645 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5646 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5647 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5648 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5649 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5650 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5651 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5653 /* FIXME: use matrix-type input source selection */
5654 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5655 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
5656 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5657 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
5658 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
5659 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
5661 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5662 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
5663 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
5664 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
5666 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5667 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
5668 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
5669 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
5674 /* capture mixer elements */
5675 static struct snd_kcontrol_new alc882_capture_alt_mixer[] = {
5676 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
5677 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
5678 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
5679 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
5681 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5682 /* The multiple "Capture Source" controls confuse alsamixer
5683 * So call somewhat different..
5684 * FIXME: the controls appear in the "playback" view!
5686 /* .name = "Capture Source", */
5687 .name = "Input Source",
5689 .info = alc882_mux_enum_info,
5690 .get = alc882_mux_enum_get,
5691 .put = alc882_mux_enum_put,
5696 static struct snd_kcontrol_new alc882_capture_mixer[] = {
5697 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
5698 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
5699 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
5700 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
5701 HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
5702 HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
5704 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5705 /* The multiple "Capture Source" controls confuse alsamixer
5706 * So call somewhat different..
5707 * FIXME: the controls appear in the "playback" view!
5709 /* .name = "Capture Source", */
5710 .name = "Input Source",
5712 .info = alc882_mux_enum_info,
5713 .get = alc882_mux_enum_get,
5714 .put = alc882_mux_enum_put,
5719 #ifdef CONFIG_SND_HDA_POWER_SAVE
5720 #define alc882_loopbacks alc880_loopbacks
5723 /* pcm configuration: identiacal with ALC880 */
5724 #define alc882_pcm_analog_playback alc880_pcm_analog_playback
5725 #define alc882_pcm_analog_capture alc880_pcm_analog_capture
5726 #define alc882_pcm_digital_playback alc880_pcm_digital_playback
5727 #define alc882_pcm_digital_capture alc880_pcm_digital_capture
5730 * configuration and preset
5732 static const char *alc882_models[ALC882_MODEL_LAST] = {
5733 [ALC882_3ST_DIG] = "3stack-dig",
5734 [ALC882_6ST_DIG] = "6stack-dig",
5735 [ALC882_ARIMA] = "arima",
5736 [ALC882_W2JC] = "w2jc",
5737 [ALC882_TARGA] = "targa",
5738 [ALC882_ASUS_A7J] = "asus-a7j",
5739 [ALC882_ASUS_A7M] = "asus-a7m",
5740 [ALC885_MACPRO] = "macpro",
5741 [ALC885_MBP3] = "mbp3",
5742 [ALC885_IMAC24] = "imac24",
5743 [ALC882_AUTO] = "auto",
5746 static struct snd_pci_quirk alc882_cfg_tbl[] = {
5747 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG),
5748 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG),
5749 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG),
5750 SND_PCI_QUIRK(0x1462, 0x28fb, "Targa T8", ALC882_TARGA), /* MSI-1049 T8 */
5751 SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA),
5752 SND_PCI_QUIRK(0x1043, 0x060d, "Asus A7J", ALC882_ASUS_A7J),
5753 SND_PCI_QUIRK(0x1043, 0x1243, "Asus A7J", ALC882_ASUS_A7J),
5754 SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_ASUS_A7M),
5755 SND_PCI_QUIRK(0x1043, 0x817f, "Asus P5LD2", ALC882_6ST_DIG),
5756 SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG),
5757 SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_W2JC),
5761 static struct alc_config_preset alc882_presets[] = {
5762 [ALC882_3ST_DIG] = {
5763 .mixers = { alc882_base_mixer },
5764 .init_verbs = { alc882_init_verbs },
5765 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5766 .dac_nids = alc882_dac_nids,
5767 .dig_out_nid = ALC882_DIGOUT_NID,
5768 .dig_in_nid = ALC882_DIGIN_NID,
5769 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
5770 .channel_mode = alc882_ch_modes,
5772 .input_mux = &alc882_capture_source,
5774 [ALC882_6ST_DIG] = {
5775 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
5776 .init_verbs = { alc882_init_verbs },
5777 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5778 .dac_nids = alc882_dac_nids,
5779 .dig_out_nid = ALC882_DIGOUT_NID,
5780 .dig_in_nid = ALC882_DIGIN_NID,
5781 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
5782 .channel_mode = alc882_sixstack_modes,
5783 .input_mux = &alc882_capture_source,
5786 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
5787 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs },
5788 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5789 .dac_nids = alc882_dac_nids,
5790 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
5791 .channel_mode = alc882_sixstack_modes,
5792 .input_mux = &alc882_capture_source,
5795 .mixers = { alc882_w2jc_mixer, alc882_chmode_mixer },
5796 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs,
5797 alc880_gpio1_init_verbs },
5798 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5799 .dac_nids = alc882_dac_nids,
5800 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
5801 .channel_mode = alc880_threestack_modes,
5803 .input_mux = &alc882_capture_source,
5804 .dig_out_nid = ALC882_DIGOUT_NID,
5807 .mixers = { alc885_mbp3_mixer, alc882_chmode_mixer },
5808 .init_verbs = { alc885_mbp3_init_verbs,
5809 alc880_gpio1_init_verbs },
5810 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5811 .dac_nids = alc882_dac_nids,
5812 .channel_mode = alc885_mbp_6ch_modes,
5813 .num_channel_mode = ARRAY_SIZE(alc885_mbp_6ch_modes),
5814 .input_mux = &alc882_capture_source,
5815 .dig_out_nid = ALC882_DIGOUT_NID,
5816 .dig_in_nid = ALC882_DIGIN_NID,
5817 .unsol_event = alc885_mbp3_unsol_event,
5818 .init_hook = alc885_mbp3_automute,
5821 .mixers = { alc882_macpro_mixer },
5822 .init_verbs = { alc882_macpro_init_verbs },
5823 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5824 .dac_nids = alc882_dac_nids,
5825 .dig_out_nid = ALC882_DIGOUT_NID,
5826 .dig_in_nid = ALC882_DIGIN_NID,
5827 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
5828 .channel_mode = alc882_ch_modes,
5829 .input_mux = &alc882_capture_source,
5830 .init_hook = alc885_macpro_init_hook,
5833 .mixers = { alc885_imac24_mixer },
5834 .init_verbs = { alc885_imac24_init_verbs },
5835 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5836 .dac_nids = alc882_dac_nids,
5837 .dig_out_nid = ALC882_DIGOUT_NID,
5838 .dig_in_nid = ALC882_DIGIN_NID,
5839 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
5840 .channel_mode = alc882_ch_modes,
5841 .input_mux = &alc882_capture_source,
5842 .unsol_event = alc885_imac24_unsol_event,
5843 .init_hook = alc885_imac24_init_hook,
5846 .mixers = { alc882_targa_mixer, alc882_chmode_mixer,
5847 alc882_capture_mixer },
5848 .init_verbs = { alc882_init_verbs, alc882_targa_verbs},
5849 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5850 .dac_nids = alc882_dac_nids,
5851 .dig_out_nid = ALC882_DIGOUT_NID,
5852 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
5853 .adc_nids = alc882_adc_nids,
5854 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
5855 .channel_mode = alc882_3ST_6ch_modes,
5857 .input_mux = &alc882_capture_source,
5858 .unsol_event = alc882_targa_unsol_event,
5859 .init_hook = alc882_targa_automute,
5861 [ALC882_ASUS_A7J] = {
5862 .mixers = { alc882_asus_a7j_mixer, alc882_chmode_mixer,
5863 alc882_capture_mixer },
5864 .init_verbs = { alc882_init_verbs, alc882_asus_a7j_verbs},
5865 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5866 .dac_nids = alc882_dac_nids,
5867 .dig_out_nid = ALC882_DIGOUT_NID,
5868 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
5869 .adc_nids = alc882_adc_nids,
5870 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
5871 .channel_mode = alc882_3ST_6ch_modes,
5873 .input_mux = &alc882_capture_source,
5875 [ALC882_ASUS_A7M] = {
5876 .mixers = { alc882_asus_a7m_mixer, alc882_chmode_mixer },
5877 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs,
5878 alc880_gpio1_init_verbs,
5879 alc882_asus_a7m_verbs },
5880 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5881 .dac_nids = alc882_dac_nids,
5882 .dig_out_nid = ALC882_DIGOUT_NID,
5883 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
5884 .channel_mode = alc880_threestack_modes,
5886 .input_mux = &alc882_capture_source,
5895 PINFIX_ABIT_AW9D_MAX
5898 static struct alc_pincfg alc882_abit_aw9d_pinfix[] = {
5899 { 0x15, 0x01080104 }, /* side */
5900 { 0x16, 0x01011012 }, /* rear */
5901 { 0x17, 0x01016011 }, /* clfe */
5905 static const struct alc_pincfg *alc882_pin_fixes[] = {
5906 [PINFIX_ABIT_AW9D_MAX] = alc882_abit_aw9d_pinfix,
5909 static struct snd_pci_quirk alc882_pinfix_tbl[] = {
5910 SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", PINFIX_ABIT_AW9D_MAX),
5915 * BIOS auto configuration
5917 static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
5918 hda_nid_t nid, int pin_type,
5922 struct alc_spec *spec = codec->spec;
5925 if (spec->multiout.dac_nids[dac_idx] == 0x25)
5928 idx = spec->multiout.dac_nids[dac_idx] - 2;
5930 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5932 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
5934 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
5938 static void alc882_auto_init_multi_out(struct hda_codec *codec)
5940 struct alc_spec *spec = codec->spec;
5943 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
5944 for (i = 0; i <= HDA_SIDE; i++) {
5945 hda_nid_t nid = spec->autocfg.line_out_pins[i];
5946 int pin_type = get_pin_type(spec->autocfg.line_out_type);
5948 alc882_auto_set_output_and_unmute(codec, nid, pin_type,
5953 static void alc882_auto_init_hp_out(struct hda_codec *codec)
5955 struct alc_spec *spec = codec->spec;
5958 pin = spec->autocfg.hp_pins[0];
5959 if (pin) /* connect to front */
5961 alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
5964 #define alc882_is_input_pin(nid) alc880_is_input_pin(nid)
5965 #define ALC882_PIN_CD_NID ALC880_PIN_CD_NID
5967 static void alc882_auto_init_analog_input(struct hda_codec *codec)
5969 struct alc_spec *spec = codec->spec;
5972 for (i = 0; i < AUTO_PIN_LAST; i++) {
5973 hda_nid_t nid = spec->autocfg.input_pins[i];
5974 if (alc882_is_input_pin(nid)) {
5975 snd_hda_codec_write(codec, nid, 0,
5976 AC_VERB_SET_PIN_WIDGET_CONTROL,
5977 i <= AUTO_PIN_FRONT_MIC ?
5978 PIN_VREF80 : PIN_IN);
5979 if (nid != ALC882_PIN_CD_NID)
5980 snd_hda_codec_write(codec, nid, 0,
5981 AC_VERB_SET_AMP_GAIN_MUTE,
5987 /* add mic boosts if needed */
5988 static int alc_auto_add_mic_boost(struct hda_codec *codec)
5990 struct alc_spec *spec = codec->spec;
5994 nid = spec->autocfg.input_pins[AUTO_PIN_MIC];
5996 err = add_control(spec, ALC_CTL_WIDGET_VOL,
5998 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
6002 nid = spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC];
6004 err = add_control(spec, ALC_CTL_WIDGET_VOL,
6006 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
6013 /* almost identical with ALC880 parser... */
6014 static int alc882_parse_auto_config(struct hda_codec *codec)
6016 struct alc_spec *spec = codec->spec;
6017 int err = alc880_parse_auto_config(codec);
6022 return 0; /* no config found */
6024 err = alc_auto_add_mic_boost(codec);
6028 /* hack - override the init verbs */
6029 spec->init_verbs[0] = alc882_auto_init_verbs;
6031 return 1; /* config found */
6034 /* additional initialization for auto-configuration model */
6035 static void alc882_auto_init(struct hda_codec *codec)
6037 alc882_auto_init_multi_out(codec);
6038 alc882_auto_init_hp_out(codec);
6039 alc882_auto_init_analog_input(codec);
6042 static int patch_alc882(struct hda_codec *codec)
6044 struct alc_spec *spec;
6045 int err, board_config;
6047 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
6053 board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST,
6057 if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
6058 /* Pick up systems that don't supply PCI SSID */
6059 switch (codec->subsystem_id) {
6060 case 0x106b0c00: /* Mac Pro */
6061 board_config = ALC885_MACPRO;
6063 case 0x106b1000: /* iMac 24 */
6064 board_config = ALC885_IMAC24;
6066 case 0x106b2c00: /* Macbook Pro rev3 */
6067 board_config = ALC885_MBP3;
6070 printk(KERN_INFO "hda_codec: Unknown model for ALC882, "
6071 "trying auto-probe from BIOS...\n");
6072 board_config = ALC882_AUTO;
6076 alc_fix_pincfg(codec, alc882_pinfix_tbl, alc882_pin_fixes);
6078 if (board_config == ALC882_AUTO) {
6079 /* automatic parse from the BIOS config */
6080 err = alc882_parse_auto_config(codec);
6086 "hda_codec: Cannot set up configuration "
6087 "from BIOS. Using base mode...\n");
6088 board_config = ALC882_3ST_DIG;
6092 if (board_config != ALC882_AUTO)
6093 setup_preset(spec, &alc882_presets[board_config]);
6095 spec->stream_name_analog = "ALC882 Analog";
6096 spec->stream_analog_playback = &alc882_pcm_analog_playback;
6097 spec->stream_analog_capture = &alc882_pcm_analog_capture;
6099 spec->stream_name_digital = "ALC882 Digital";
6100 spec->stream_digital_playback = &alc882_pcm_digital_playback;
6101 spec->stream_digital_capture = &alc882_pcm_digital_capture;
6103 if (!spec->adc_nids && spec->input_mux) {
6104 /* check whether NID 0x07 is valid */
6105 unsigned int wcap = get_wcaps(codec, 0x07);
6107 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
6108 if (wcap != AC_WID_AUD_IN) {
6109 spec->adc_nids = alc882_adc_nids_alt;
6110 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids_alt);
6111 spec->mixers[spec->num_mixers] =
6112 alc882_capture_alt_mixer;
6115 spec->adc_nids = alc882_adc_nids;
6116 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids);
6117 spec->mixers[spec->num_mixers] = alc882_capture_mixer;
6122 codec->patch_ops = alc_patch_ops;
6123 if (board_config == ALC882_AUTO)
6124 spec->init_hook = alc882_auto_init;
6125 #ifdef CONFIG_SND_HDA_POWER_SAVE
6126 if (!spec->loopback.amplist)
6127 spec->loopback.amplist = alc882_loopbacks;
6136 * ALC883 is almost identical with ALC880 but has cleaner and more flexible
6137 * configuration. Each pin widget can choose any input DACs and a mixer.
6138 * Each ADC is connected from a mixer of all inputs. This makes possible
6139 * 6-channel independent captures.
6141 * In addition, an independent DAC for the multi-playback (not used in this
6144 #define ALC883_DIGOUT_NID 0x06
6145 #define ALC883_DIGIN_NID 0x0a
6147 static hda_nid_t alc883_dac_nids[4] = {
6148 /* front, rear, clfe, rear_surr */
6149 0x02, 0x04, 0x03, 0x05
6152 static hda_nid_t alc883_adc_nids[2] = {
6158 /* FIXME: should be a matrix-type input source selection */
6160 static struct hda_input_mux alc883_capture_source = {
6164 { "Front Mic", 0x1 },
6170 static struct hda_input_mux alc883_lenovo_101e_capture_source = {
6178 static struct hda_input_mux alc883_lenovo_nb0763_capture_source = {
6188 #define alc883_mux_enum_info alc_mux_enum_info
6189 #define alc883_mux_enum_get alc_mux_enum_get
6191 static int alc883_mux_enum_put(struct snd_kcontrol *kcontrol,
6192 struct snd_ctl_elem_value *ucontrol)
6194 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
6195 struct alc_spec *spec = codec->spec;
6196 const struct hda_input_mux *imux = spec->input_mux;
6197 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
6198 static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
6199 hda_nid_t nid = capture_mixers[adc_idx];
6200 unsigned int *cur_val = &spec->cur_mux[adc_idx];
6201 unsigned int i, idx;
6203 idx = ucontrol->value.enumerated.item[0];
6204 if (idx >= imux->num_items)
6205 idx = imux->num_items - 1;
6206 if (*cur_val == idx)
6208 for (i = 0; i < imux->num_items; i++) {
6209 unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
6210 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
6211 imux->items[i].index,
6221 static struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
6228 static struct hda_verb alc883_3ST_ch2_init[] = {
6229 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6230 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6231 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6232 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6239 static struct hda_verb alc883_3ST_ch4_init[] = {
6240 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6241 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6242 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6243 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6244 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6251 static struct hda_verb alc883_3ST_ch6_init[] = {
6252 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6253 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6254 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
6255 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6256 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6257 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6261 static struct hda_channel_mode alc883_3ST_6ch_modes[3] = {
6262 { 2, alc883_3ST_ch2_init },
6263 { 4, alc883_3ST_ch4_init },
6264 { 6, alc883_3ST_ch6_init },
6270 static struct hda_verb alc883_sixstack_ch6_init[] = {
6271 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
6272 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6273 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6274 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6281 static struct hda_verb alc883_sixstack_ch8_init[] = {
6282 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6283 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6284 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6285 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6289 static struct hda_channel_mode alc883_sixstack_modes[2] = {
6290 { 6, alc883_sixstack_ch6_init },
6291 { 8, alc883_sixstack_ch8_init },
6294 static struct hda_verb alc883_medion_eapd_verbs[] = {
6295 /* eanable EAPD on medion laptop */
6296 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
6297 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
6301 /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
6302 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
6305 static struct snd_kcontrol_new alc883_base_mixer[] = {
6306 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6307 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6308 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
6309 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
6310 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
6311 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
6312 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
6313 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
6314 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
6315 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
6316 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6317 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6318 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6319 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6320 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6321 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6322 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6323 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6324 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6325 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
6326 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6327 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6328 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6329 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6330 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6331 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6332 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6334 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6335 /* .name = "Capture Source", */
6336 .name = "Input Source",
6338 .info = alc883_mux_enum_info,
6339 .get = alc883_mux_enum_get,
6340 .put = alc883_mux_enum_put,
6345 static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
6346 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6347 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6348 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6349 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6350 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6351 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6352 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6353 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6354 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6355 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6356 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6357 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
6358 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6359 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6360 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6361 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6362 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6363 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6364 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6366 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6367 /* .name = "Capture Source", */
6368 .name = "Input Source",
6370 .info = alc883_mux_enum_info,
6371 .get = alc883_mux_enum_get,
6372 .put = alc883_mux_enum_put,
6377 static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
6378 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6379 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6380 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
6381 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
6382 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
6383 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
6384 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
6385 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
6386 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6387 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6388 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6389 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6390 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6391 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6392 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6393 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6394 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6395 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
6396 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6397 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6398 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6399 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6400 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6401 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6402 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6404 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6405 /* .name = "Capture Source", */
6406 .name = "Input Source",
6408 .info = alc883_mux_enum_info,
6409 .get = alc883_mux_enum_get,
6410 .put = alc883_mux_enum_put,
6415 static struct snd_kcontrol_new alc883_fivestack_mixer[] = {
6416 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6417 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6418 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
6419 HDA_CODEC_MUTE("Surround Playback Switch", 0x15, 0x0, HDA_OUTPUT),
6420 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
6421 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
6422 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x16, 1, 0x0, HDA_OUTPUT),
6423 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
6424 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6425 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6426 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6427 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6428 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6429 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6430 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6431 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6432 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6433 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
6434 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6435 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6436 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6437 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6438 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6441 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6442 /* .name = "Capture Source", */
6443 .name = "Input Source",
6445 .info = alc883_mux_enum_info,
6446 .get = alc883_mux_enum_get,
6447 .put = alc883_mux_enum_put,
6452 static struct snd_kcontrol_new alc883_tagra_mixer[] = {
6453 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6454 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6455 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6456 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
6457 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
6458 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
6459 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
6460 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
6461 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
6462 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6463 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6464 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6465 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6466 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6467 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6468 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6469 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6470 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6471 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6472 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6474 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6475 /* .name = "Capture Source", */
6476 .name = "Input Source",
6478 .info = alc883_mux_enum_info,
6479 .get = alc883_mux_enum_get,
6480 .put = alc883_mux_enum_put,
6485 static struct snd_kcontrol_new alc883_tagra_2ch_mixer[] = {
6486 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6487 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6488 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6489 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6490 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6491 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6492 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6493 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6494 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6495 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6496 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6497 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6499 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6500 /* .name = "Capture Source", */
6501 .name = "Input Source",
6503 .info = alc883_mux_enum_info,
6504 .get = alc883_mux_enum_get,
6505 .put = alc883_mux_enum_put,
6510 static struct snd_kcontrol_new alc883_lenovo_101e_2ch_mixer[] = {
6511 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6512 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6513 HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
6514 HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT),
6515 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6516 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6517 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6518 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6519 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6520 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6522 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6523 /* .name = "Capture Source", */
6524 .name = "Input Source",
6526 .info = alc883_mux_enum_info,
6527 .get = alc883_mux_enum_get,
6528 .put = alc883_mux_enum_put,
6533 static struct snd_kcontrol_new alc883_lenovo_nb0763_mixer[] = {
6534 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6535 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
6536 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6537 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6538 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6539 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6540 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6541 HDA_CODEC_VOLUME("iMic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6542 HDA_CODEC_MUTE("iMic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6543 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6544 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6545 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6546 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6548 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6549 /* .name = "Capture Source", */
6550 .name = "Input Source",
6552 .info = alc883_mux_enum_info,
6553 .get = alc883_mux_enum_get,
6554 .put = alc883_mux_enum_put,
6559 static struct snd_kcontrol_new alc883_medion_md2_mixer[] = {
6560 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6561 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6562 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
6563 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6564 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6565 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6566 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6567 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6568 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6569 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6570 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6571 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6572 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6574 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6575 /* .name = "Capture Source", */
6576 .name = "Input Source",
6578 .info = alc883_mux_enum_info,
6579 .get = alc883_mux_enum_get,
6580 .put = alc883_mux_enum_put,
6585 static struct snd_kcontrol_new alc888_6st_hp_mixer[] = {
6586 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6587 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6588 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
6589 HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
6590 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
6591 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
6592 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
6593 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
6594 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
6595 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
6596 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6597 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6598 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6599 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6600 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6601 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6602 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6603 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6604 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6605 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
6606 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6607 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6608 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6609 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6610 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6611 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6612 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6614 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6615 /* .name = "Capture Source", */
6616 .name = "Input Source",
6618 .info = alc883_mux_enum_info,
6619 .get = alc883_mux_enum_get,
6620 .put = alc883_mux_enum_put,
6625 static struct snd_kcontrol_new alc888_3st_hp_mixer[] = {
6626 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6627 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6628 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
6629 HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
6630 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
6631 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
6632 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
6633 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
6634 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6635 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6636 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6637 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6638 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6639 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6640 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6641 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6642 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6643 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
6644 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6645 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6646 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6647 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6648 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6649 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6650 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6652 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6653 /* .name = "Capture Source", */
6654 .name = "Input Source",
6656 .info = alc883_mux_enum_info,
6657 .get = alc883_mux_enum_get,
6658 .put = alc883_mux_enum_put,
6663 static struct snd_kcontrol_new alc883_acer_aspire_mixer[] = {
6664 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6665 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6666 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6667 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6668 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6669 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6670 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6671 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6672 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6673 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6674 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6675 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6677 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6678 /* .name = "Capture Source", */
6679 .name = "Input Source",
6681 .info = alc883_mux_enum_info,
6682 .get = alc883_mux_enum_get,
6683 .put = alc883_mux_enum_put,
6688 static struct snd_kcontrol_new alc883_chmode_mixer[] = {
6690 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6691 .name = "Channel Mode",
6692 .info = alc_ch_mode_info,
6693 .get = alc_ch_mode_get,
6694 .put = alc_ch_mode_put,
6699 static struct hda_verb alc883_init_verbs[] = {
6700 /* ADC1: mute amp left and right */
6701 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6702 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6703 /* ADC2: mute amp left and right */
6704 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6705 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
6706 /* Front mixer: unmute input/output amp left and right (volume = 0) */
6707 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6708 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6709 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6711 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6712 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6713 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6715 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6716 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6717 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6719 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6720 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6721 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6723 /* mute analog input loopbacks */
6724 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6725 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6726 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6727 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6728 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6730 /* Front Pin: output 0 (0x0c) */
6731 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6732 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6733 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
6734 /* Rear Pin: output 1 (0x0d) */
6735 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6736 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6737 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
6738 /* CLFE Pin: output 2 (0x0e) */
6739 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6740 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6741 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
6742 /* Side Pin: output 3 (0x0f) */
6743 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6744 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6745 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
6746 /* Mic (rear) pin: input vref at 80% */
6747 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6748 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6749 /* Front Mic pin: input vref at 80% */
6750 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6751 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6752 /* Line In pin: input */
6753 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
6754 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6755 /* Line-2 In: Headphone output (output 0 - 0x0c) */
6756 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6757 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6758 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
6759 /* CD pin widget for input */
6760 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
6762 /* FIXME: use matrix-type input source selection */
6763 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6765 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6766 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6767 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
6768 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
6770 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6771 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6772 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
6773 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
6777 static struct hda_verb alc883_tagra_verbs[] = {
6778 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6779 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6781 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6782 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6784 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
6785 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
6786 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6788 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
6789 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
6790 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
6791 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
6796 static struct hda_verb alc883_lenovo_101e_verbs[] = {
6797 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
6798 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT|AC_USRSP_EN},
6799 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT|AC_USRSP_EN},
6803 static struct hda_verb alc883_lenovo_nb0763_verbs[] = {
6804 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
6805 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6806 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
6807 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6811 static struct hda_verb alc888_lenovo_ms7195_verbs[] = {
6812 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6813 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6814 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
6815 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT | AC_USRSP_EN},
6816 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
6820 static struct hda_verb alc883_haier_w66_verbs[] = {
6821 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6822 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6824 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6826 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
6827 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6828 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
6829 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6833 static struct hda_verb alc888_6st_hp_verbs[] = {
6834 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
6835 {0x15, AC_VERB_SET_CONNECT_SEL, 0x02}, /* Rear : output 2 (0x0e) */
6836 {0x16, AC_VERB_SET_CONNECT_SEL, 0x01}, /* CLFE : output 1 (0x0d) */
6837 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03}, /* Side : output 3 (0x0f) */
6841 static struct hda_verb alc888_3st_hp_verbs[] = {
6842 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
6843 {0x18, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Rear : output 1 (0x0d) */
6844 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02}, /* CLFE : output 2 (0x0e) */
6848 static struct hda_verb alc888_3st_hp_2ch_init[] = {
6849 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6850 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6851 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6852 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6856 static struct hda_verb alc888_3st_hp_6ch_init[] = {
6857 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6858 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6859 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6860 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6864 static struct hda_channel_mode alc888_3st_hp_modes[2] = {
6865 { 2, alc888_3st_hp_2ch_init },
6866 { 6, alc888_3st_hp_6ch_init },
6869 /* toggle front-jack and RCA according to the hp-jack state */
6870 static void alc888_lenovo_ms7195_front_automute(struct hda_codec *codec)
6872 unsigned int present;
6874 present = snd_hda_codec_read(codec, 0x1b, 0,
6875 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
6876 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
6877 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
6878 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
6879 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
6882 /* toggle RCA according to the front-jack state */
6883 static void alc888_lenovo_ms7195_rca_automute(struct hda_codec *codec)
6885 unsigned int present;
6887 present = snd_hda_codec_read(codec, 0x14, 0,
6888 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
6889 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
6890 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
6893 static void alc883_lenovo_ms7195_unsol_event(struct hda_codec *codec,
6896 if ((res >> 26) == ALC880_HP_EVENT)
6897 alc888_lenovo_ms7195_front_automute(codec);
6898 if ((res >> 26) == ALC880_FRONT_EVENT)
6899 alc888_lenovo_ms7195_rca_automute(codec);
6902 static struct hda_verb alc883_medion_md2_verbs[] = {
6903 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6904 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6906 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6908 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
6912 /* toggle speaker-output according to the hp-jack state */
6913 static void alc883_medion_md2_automute(struct hda_codec *codec)
6915 unsigned int present;
6917 present = snd_hda_codec_read(codec, 0x14, 0,
6918 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
6919 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
6920 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
6923 static void alc883_medion_md2_unsol_event(struct hda_codec *codec,
6926 if ((res >> 26) == ALC880_HP_EVENT)
6927 alc883_medion_md2_automute(codec);
6930 /* toggle speaker-output according to the hp-jack state */
6931 static void alc883_tagra_automute(struct hda_codec *codec)
6933 unsigned int present;
6936 present = snd_hda_codec_read(codec, 0x14, 0,
6937 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
6938 bits = present ? HDA_AMP_MUTE : 0;
6939 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
6940 HDA_AMP_MUTE, bits);
6941 snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
6945 static void alc883_tagra_unsol_event(struct hda_codec *codec, unsigned int res)
6947 if ((res >> 26) == ALC880_HP_EVENT)
6948 alc883_tagra_automute(codec);
6951 static void alc883_haier_w66_automute(struct hda_codec *codec)
6953 unsigned int present;
6956 present = snd_hda_codec_read(codec, 0x1b, 0,
6957 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
6958 bits = present ? 0x80 : 0;
6959 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
6963 static void alc883_haier_w66_unsol_event(struct hda_codec *codec,
6966 if ((res >> 26) == ALC880_HP_EVENT)
6967 alc883_haier_w66_automute(codec);
6970 static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
6972 unsigned int present;
6975 present = snd_hda_codec_read(codec, 0x14, 0,
6976 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
6977 bits = present ? HDA_AMP_MUTE : 0;
6978 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
6979 HDA_AMP_MUTE, bits);
6982 static void alc883_lenovo_101e_all_automute(struct hda_codec *codec)
6984 unsigned int present;
6987 present = snd_hda_codec_read(codec, 0x1b, 0,
6988 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
6989 bits = present ? HDA_AMP_MUTE : 0;
6990 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
6991 HDA_AMP_MUTE, bits);
6992 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
6993 HDA_AMP_MUTE, bits);
6996 static void alc883_lenovo_101e_unsol_event(struct hda_codec *codec,
6999 if ((res >> 26) == ALC880_HP_EVENT)
7000 alc883_lenovo_101e_all_automute(codec);
7001 if ((res >> 26) == ALC880_FRONT_EVENT)
7002 alc883_lenovo_101e_ispeaker_automute(codec);
7005 /* toggle speaker-output according to the hp-jack state */
7006 static void alc883_acer_aspire_automute(struct hda_codec *codec)
7008 unsigned int present;
7010 present = snd_hda_codec_read(codec, 0x14, 0,
7011 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7012 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7013 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7014 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
7015 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7018 static void alc883_acer_aspire_unsol_event(struct hda_codec *codec,
7021 if ((res >> 26) == ALC880_HP_EVENT)
7022 alc883_acer_aspire_automute(codec);
7025 static struct hda_verb alc883_acer_eapd_verbs[] = {
7026 /* HP Pin: output 0 (0x0c) */
7027 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7028 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7029 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7030 /* Front Pin: output 0 (0x0c) */
7031 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7032 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7033 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7034 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00},
7035 /* eanable EAPD on medion laptop */
7036 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
7037 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
7038 /* enable unsolicited event */
7039 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7044 * generic initialization of ADC, input mixers and output mixers
7046 static struct hda_verb alc883_auto_init_verbs[] = {
7048 * Unmute ADC0-2 and set the default input to mic-in
7050 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7051 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7052 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7053 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7055 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
7057 * Note: PASD motherboards uses the Line In 2 as the input for
7058 * front panel mic (mic 2)
7060 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
7061 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7062 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7063 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7064 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7065 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7068 * Set up output mixers (0x0c - 0x0f)
7070 /* set vol=0 to output mixers */
7071 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7072 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7073 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7074 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7075 /* set up input amps for analog loopback */
7076 /* Amp Indices: DAC = 0, mixer = 1 */
7077 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7078 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7079 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7080 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7081 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7082 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7083 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7084 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7085 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7086 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7088 /* FIXME: use matrix-type input source selection */
7089 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7091 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7092 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7093 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7094 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
7095 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
7097 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7098 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7099 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7100 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
7101 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
7106 /* capture mixer elements */
7107 static struct snd_kcontrol_new alc883_capture_mixer[] = {
7108 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7109 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7110 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
7111 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
7113 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7114 /* The multiple "Capture Source" controls confuse alsamixer
7115 * So call somewhat different..
7116 * FIXME: the controls appear in the "playback" view!
7118 /* .name = "Capture Source", */
7119 .name = "Input Source",
7121 .info = alc882_mux_enum_info,
7122 .get = alc882_mux_enum_get,
7123 .put = alc882_mux_enum_put,
7128 #ifdef CONFIG_SND_HDA_POWER_SAVE
7129 #define alc883_loopbacks alc880_loopbacks
7132 /* pcm configuration: identiacal with ALC880 */
7133 #define alc883_pcm_analog_playback alc880_pcm_analog_playback
7134 #define alc883_pcm_analog_capture alc880_pcm_analog_capture
7135 #define alc883_pcm_digital_playback alc880_pcm_digital_playback
7136 #define alc883_pcm_digital_capture alc880_pcm_digital_capture
7139 * configuration and preset
7141 static const char *alc883_models[ALC883_MODEL_LAST] = {
7142 [ALC883_3ST_2ch_DIG] = "3stack-dig",
7143 [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig",
7144 [ALC883_3ST_6ch] = "3stack-6ch",
7145 [ALC883_6ST_DIG] = "6stack-dig",
7146 [ALC883_TARGA_DIG] = "targa-dig",
7147 [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig",
7148 [ALC883_ACER] = "acer",
7149 [ALC883_ACER_ASPIRE] = "acer-aspire",
7150 [ALC883_MEDION] = "medion",
7151 [ALC883_MEDION_MD2] = "medion-md2",
7152 [ALC883_LAPTOP_EAPD] = "laptop-eapd",
7153 [ALC883_LENOVO_101E_2ch] = "lenovo-101e",
7154 [ALC883_LENOVO_NB0763] = "lenovo-nb0763",
7155 [ALC888_LENOVO_MS7195_DIG] = "lenovo-ms7195-dig",
7156 [ALC883_HAIER_W66] = "haier-w66",
7157 [ALC888_6ST_HP] = "6stack-hp",
7158 [ALC888_3ST_HP] = "3stack-hp",
7159 [ALC883_AUTO] = "auto",
7162 static struct snd_pci_quirk alc883_cfg_tbl[] = {
7163 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC883_3ST_6ch_DIG),
7164 SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG),
7165 SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch),
7166 SND_PCI_QUIRK(0x1558, 0, "Clevo laptop", ALC883_LAPTOP_EAPD),
7167 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC883_6ST_DIG),
7168 SND_PCI_QUIRK(0x1458, 0xa002, "MSI", ALC883_6ST_DIG),
7169 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG),
7170 SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG),
7171 SND_PCI_QUIRK(0x1462, 0x7250, "MSI", ALC883_6ST_DIG),
7172 SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG),
7173 SND_PCI_QUIRK(0x1462, 0x7327, "MSI", ALC883_6ST_DIG),
7174 SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG),
7175 SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG),
7176 SND_PCI_QUIRK(0x1462, 0x040d, "MSI", ALC883_TARGA_2ch_DIG),
7177 SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG),
7178 SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG),
7179 SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG),
7180 SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG),
7181 SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG),
7182 SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG),
7183 SND_PCI_QUIRK(0x1462, 0x3fdf, "MSI", ALC883_TARGA_DIG),
7184 SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG),
7185 SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG),
7186 SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG),
7187 SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG),
7188 SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_ACER_ASPIRE),
7189 SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_ACER_ASPIRE),
7190 SND_PCI_QUIRK(0x1025, 0x0112, "Acer Aspire 9303", ALC883_ACER_ASPIRE),
7191 SND_PCI_QUIRK(0x1025, 0, "Acer laptop", ALC883_ACER),
7192 SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch),
7193 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
7194 SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD),
7195 SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC883_3ST_6ch),
7196 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch),
7197 SND_PCI_QUIRK(0x17aa, 0x3bfd, "Lenovo NB0763", ALC883_LENOVO_NB0763),
7198 SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763),
7199 SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC888_6ST_HP),
7200 SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_3ST_HP),
7201 SND_PCI_QUIRK(0x103c, 0x2a4f, "HP Samba", ALC888_3ST_HP),
7202 SND_PCI_QUIRK(0x17c0, 0x4071, "MEDION MD2", ALC883_MEDION_MD2),
7203 SND_PCI_QUIRK(0x1991, 0x5625, "Haier W66", ALC883_HAIER_W66),
7204 SND_PCI_QUIRK(0x17aa, 0x3bfc, "Lenovo NB0763", ALC883_LENOVO_NB0763),
7205 SND_PCI_QUIRK(0x1043, 0x8249, "Asus M2A-VM HDMI", ALC883_3ST_6ch_DIG),
7206 SND_PCI_QUIRK(0x147b, 0x1083, "Abit IP35-PRO", ALC883_6ST_DIG),
7210 static struct alc_config_preset alc883_presets[] = {
7211 [ALC883_3ST_2ch_DIG] = {
7212 .mixers = { alc883_3ST_2ch_mixer },
7213 .init_verbs = { alc883_init_verbs },
7214 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7215 .dac_nids = alc883_dac_nids,
7216 .dig_out_nid = ALC883_DIGOUT_NID,
7217 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7218 .adc_nids = alc883_adc_nids,
7219 .dig_in_nid = ALC883_DIGIN_NID,
7220 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7221 .channel_mode = alc883_3ST_2ch_modes,
7222 .input_mux = &alc883_capture_source,
7224 [ALC883_3ST_6ch_DIG] = {
7225 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
7226 .init_verbs = { alc883_init_verbs },
7227 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7228 .dac_nids = alc883_dac_nids,
7229 .dig_out_nid = ALC883_DIGOUT_NID,
7230 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7231 .adc_nids = alc883_adc_nids,
7232 .dig_in_nid = ALC883_DIGIN_NID,
7233 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
7234 .channel_mode = alc883_3ST_6ch_modes,
7236 .input_mux = &alc883_capture_source,
7238 [ALC883_3ST_6ch] = {
7239 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
7240 .init_verbs = { alc883_init_verbs },
7241 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7242 .dac_nids = alc883_dac_nids,
7243 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7244 .adc_nids = alc883_adc_nids,
7245 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
7246 .channel_mode = alc883_3ST_6ch_modes,
7248 .input_mux = &alc883_capture_source,
7250 [ALC883_6ST_DIG] = {
7251 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
7252 .init_verbs = { alc883_init_verbs },
7253 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7254 .dac_nids = alc883_dac_nids,
7255 .dig_out_nid = ALC883_DIGOUT_NID,
7256 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7257 .adc_nids = alc883_adc_nids,
7258 .dig_in_nid = ALC883_DIGIN_NID,
7259 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
7260 .channel_mode = alc883_sixstack_modes,
7261 .input_mux = &alc883_capture_source,
7263 [ALC883_TARGA_DIG] = {
7264 .mixers = { alc883_tagra_mixer, alc883_chmode_mixer },
7265 .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
7266 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7267 .dac_nids = alc883_dac_nids,
7268 .dig_out_nid = ALC883_DIGOUT_NID,
7269 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7270 .adc_nids = alc883_adc_nids,
7271 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
7272 .channel_mode = alc883_3ST_6ch_modes,
7274 .input_mux = &alc883_capture_source,
7275 .unsol_event = alc883_tagra_unsol_event,
7276 .init_hook = alc883_tagra_automute,
7278 [ALC883_TARGA_2ch_DIG] = {
7279 .mixers = { alc883_tagra_2ch_mixer},
7280 .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
7281 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7282 .dac_nids = alc883_dac_nids,
7283 .dig_out_nid = ALC883_DIGOUT_NID,
7284 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7285 .adc_nids = alc883_adc_nids,
7286 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7287 .channel_mode = alc883_3ST_2ch_modes,
7288 .input_mux = &alc883_capture_source,
7289 .unsol_event = alc883_tagra_unsol_event,
7290 .init_hook = alc883_tagra_automute,
7293 .mixers = { alc883_base_mixer },
7294 /* On TravelMate laptops, GPIO 0 enables the internal speaker
7295 * and the headphone jack. Turn this on and rely on the
7296 * standard mute methods whenever the user wants to turn
7297 * these outputs off.
7299 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs },
7300 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7301 .dac_nids = alc883_dac_nids,
7302 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7303 .adc_nids = alc883_adc_nids,
7304 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7305 .channel_mode = alc883_3ST_2ch_modes,
7306 .input_mux = &alc883_capture_source,
7308 [ALC883_ACER_ASPIRE] = {
7309 .mixers = { alc883_acer_aspire_mixer },
7310 .init_verbs = { alc883_init_verbs, alc883_acer_eapd_verbs },
7311 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7312 .dac_nids = alc883_dac_nids,
7313 .dig_out_nid = ALC883_DIGOUT_NID,
7314 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7315 .adc_nids = alc883_adc_nids,
7316 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7317 .channel_mode = alc883_3ST_2ch_modes,
7318 .input_mux = &alc883_capture_source,
7319 .unsol_event = alc883_acer_aspire_unsol_event,
7320 .init_hook = alc883_acer_aspire_automute,
7323 .mixers = { alc883_fivestack_mixer,
7324 alc883_chmode_mixer },
7325 .init_verbs = { alc883_init_verbs,
7326 alc883_medion_eapd_verbs },
7327 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7328 .dac_nids = alc883_dac_nids,
7329 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7330 .adc_nids = alc883_adc_nids,
7331 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
7332 .channel_mode = alc883_sixstack_modes,
7333 .input_mux = &alc883_capture_source,
7335 [ALC883_MEDION_MD2] = {
7336 .mixers = { alc883_medion_md2_mixer},
7337 .init_verbs = { alc883_init_verbs, alc883_medion_md2_verbs},
7338 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7339 .dac_nids = alc883_dac_nids,
7340 .dig_out_nid = ALC883_DIGOUT_NID,
7341 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7342 .adc_nids = alc883_adc_nids,
7343 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7344 .channel_mode = alc883_3ST_2ch_modes,
7345 .input_mux = &alc883_capture_source,
7346 .unsol_event = alc883_medion_md2_unsol_event,
7347 .init_hook = alc883_medion_md2_automute,
7349 [ALC883_LAPTOP_EAPD] = {
7350 .mixers = { alc883_base_mixer },
7351 .init_verbs = { alc883_init_verbs, alc882_eapd_verbs },
7352 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7353 .dac_nids = alc883_dac_nids,
7354 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7355 .adc_nids = alc883_adc_nids,
7356 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7357 .channel_mode = alc883_3ST_2ch_modes,
7358 .input_mux = &alc883_capture_source,
7360 [ALC883_LENOVO_101E_2ch] = {
7361 .mixers = { alc883_lenovo_101e_2ch_mixer},
7362 .init_verbs = { alc883_init_verbs, alc883_lenovo_101e_verbs},
7363 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7364 .dac_nids = alc883_dac_nids,
7365 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7366 .adc_nids = alc883_adc_nids,
7367 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7368 .channel_mode = alc883_3ST_2ch_modes,
7369 .input_mux = &alc883_lenovo_101e_capture_source,
7370 .unsol_event = alc883_lenovo_101e_unsol_event,
7371 .init_hook = alc883_lenovo_101e_all_automute,
7373 [ALC883_LENOVO_NB0763] = {
7374 .mixers = { alc883_lenovo_nb0763_mixer },
7375 .init_verbs = { alc883_init_verbs, alc883_lenovo_nb0763_verbs},
7376 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7377 .dac_nids = alc883_dac_nids,
7378 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7379 .adc_nids = alc883_adc_nids,
7380 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7381 .channel_mode = alc883_3ST_2ch_modes,
7383 .input_mux = &alc883_lenovo_nb0763_capture_source,
7384 .unsol_event = alc883_medion_md2_unsol_event,
7385 .init_hook = alc883_medion_md2_automute,
7387 [ALC888_LENOVO_MS7195_DIG] = {
7388 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
7389 .init_verbs = { alc883_init_verbs, alc888_lenovo_ms7195_verbs},
7390 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7391 .dac_nids = alc883_dac_nids,
7392 .dig_out_nid = ALC883_DIGOUT_NID,
7393 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7394 .adc_nids = alc883_adc_nids,
7395 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
7396 .channel_mode = alc883_3ST_6ch_modes,
7398 .input_mux = &alc883_capture_source,
7399 .unsol_event = alc883_lenovo_ms7195_unsol_event,
7400 .init_hook = alc888_lenovo_ms7195_front_automute,
7402 [ALC883_HAIER_W66] = {
7403 .mixers = { alc883_tagra_2ch_mixer},
7404 .init_verbs = { alc883_init_verbs, alc883_haier_w66_verbs},
7405 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7406 .dac_nids = alc883_dac_nids,
7407 .dig_out_nid = ALC883_DIGOUT_NID,
7408 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7409 .adc_nids = alc883_adc_nids,
7410 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7411 .channel_mode = alc883_3ST_2ch_modes,
7412 .input_mux = &alc883_capture_source,
7413 .unsol_event = alc883_haier_w66_unsol_event,
7414 .init_hook = alc883_haier_w66_automute,
7417 .mixers = { alc888_6st_hp_mixer, alc883_chmode_mixer },
7418 .init_verbs = { alc883_init_verbs, alc888_6st_hp_verbs },
7419 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7420 .dac_nids = alc883_dac_nids,
7421 .dig_out_nid = ALC883_DIGOUT_NID,
7422 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7423 .adc_nids = alc883_adc_nids,
7424 .dig_in_nid = ALC883_DIGIN_NID,
7425 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
7426 .channel_mode = alc883_sixstack_modes,
7427 .input_mux = &alc883_capture_source,
7430 .mixers = { alc888_3st_hp_mixer, alc883_chmode_mixer },
7431 .init_verbs = { alc883_init_verbs, alc888_3st_hp_verbs },
7432 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7433 .dac_nids = alc883_dac_nids,
7434 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7435 .adc_nids = alc883_adc_nids,
7436 .num_channel_mode = ARRAY_SIZE(alc888_3st_hp_modes),
7437 .channel_mode = alc888_3st_hp_modes,
7439 .input_mux = &alc883_capture_source,
7445 * BIOS auto configuration
7447 static void alc883_auto_set_output_and_unmute(struct hda_codec *codec,
7448 hda_nid_t nid, int pin_type,
7452 struct alc_spec *spec = codec->spec;
7455 if (spec->multiout.dac_nids[dac_idx] == 0x25)
7458 idx = spec->multiout.dac_nids[dac_idx] - 2;
7460 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
7462 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
7464 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
7468 static void alc883_auto_init_multi_out(struct hda_codec *codec)
7470 struct alc_spec *spec = codec->spec;
7473 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
7474 for (i = 0; i <= HDA_SIDE; i++) {
7475 hda_nid_t nid = spec->autocfg.line_out_pins[i];
7476 int pin_type = get_pin_type(spec->autocfg.line_out_type);
7478 alc883_auto_set_output_and_unmute(codec, nid, pin_type,
7483 static void alc883_auto_init_hp_out(struct hda_codec *codec)
7485 struct alc_spec *spec = codec->spec;
7488 pin = spec->autocfg.hp_pins[0];
7489 if (pin) /* connect to front */
7491 alc883_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
7494 #define alc883_is_input_pin(nid) alc880_is_input_pin(nid)
7495 #define ALC883_PIN_CD_NID ALC880_PIN_CD_NID
7497 static void alc883_auto_init_analog_input(struct hda_codec *codec)
7499 struct alc_spec *spec = codec->spec;
7502 for (i = 0; i < AUTO_PIN_LAST; i++) {
7503 hda_nid_t nid = spec->autocfg.input_pins[i];
7504 if (alc883_is_input_pin(nid)) {
7505 snd_hda_codec_write(codec, nid, 0,
7506 AC_VERB_SET_PIN_WIDGET_CONTROL,
7507 (i <= AUTO_PIN_FRONT_MIC ?
7508 PIN_VREF80 : PIN_IN));
7509 if (nid != ALC883_PIN_CD_NID)
7510 snd_hda_codec_write(codec, nid, 0,
7511 AC_VERB_SET_AMP_GAIN_MUTE,
7517 /* almost identical with ALC880 parser... */
7518 static int alc883_parse_auto_config(struct hda_codec *codec)
7520 struct alc_spec *spec = codec->spec;
7521 int err = alc880_parse_auto_config(codec);
7526 return 0; /* no config found */
7528 err = alc_auto_add_mic_boost(codec);
7532 /* hack - override the init verbs */
7533 spec->init_verbs[0] = alc883_auto_init_verbs;
7534 spec->mixers[spec->num_mixers] = alc883_capture_mixer;
7537 return 1; /* config found */
7540 /* additional initialization for auto-configuration model */
7541 static void alc883_auto_init(struct hda_codec *codec)
7543 alc883_auto_init_multi_out(codec);
7544 alc883_auto_init_hp_out(codec);
7545 alc883_auto_init_analog_input(codec);
7548 static int patch_alc883(struct hda_codec *codec)
7550 struct alc_spec *spec;
7551 int err, board_config;
7553 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
7559 board_config = snd_hda_check_board_config(codec, ALC883_MODEL_LAST,
7562 if (board_config < 0) {
7563 printk(KERN_INFO "hda_codec: Unknown model for ALC883, "
7564 "trying auto-probe from BIOS...\n");
7565 board_config = ALC883_AUTO;
7568 if (board_config == ALC883_AUTO) {
7569 /* automatic parse from the BIOS config */
7570 err = alc883_parse_auto_config(codec);
7576 "hda_codec: Cannot set up configuration "
7577 "from BIOS. Using base mode...\n");
7578 board_config = ALC883_3ST_2ch_DIG;
7582 if (board_config != ALC883_AUTO)
7583 setup_preset(spec, &alc883_presets[board_config]);
7585 spec->stream_name_analog = "ALC883 Analog";
7586 spec->stream_analog_playback = &alc883_pcm_analog_playback;
7587 spec->stream_analog_capture = &alc883_pcm_analog_capture;
7589 spec->stream_name_digital = "ALC883 Digital";
7590 spec->stream_digital_playback = &alc883_pcm_digital_playback;
7591 spec->stream_digital_capture = &alc883_pcm_digital_capture;
7593 if (!spec->adc_nids && spec->input_mux) {
7594 spec->adc_nids = alc883_adc_nids;
7595 spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids);
7598 codec->patch_ops = alc_patch_ops;
7599 if (board_config == ALC883_AUTO)
7600 spec->init_hook = alc883_auto_init;
7601 #ifdef CONFIG_SND_HDA_POWER_SAVE
7602 if (!spec->loopback.amplist)
7603 spec->loopback.amplist = alc883_loopbacks;
7613 #define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
7614 #define ALC262_DIGIN_NID ALC880_DIGIN_NID
7616 #define alc262_dac_nids alc260_dac_nids
7617 #define alc262_adc_nids alc882_adc_nids
7618 #define alc262_adc_nids_alt alc882_adc_nids_alt
7620 #define alc262_modes alc260_modes
7621 #define alc262_capture_source alc882_capture_source
7623 static struct snd_kcontrol_new alc262_base_mixer[] = {
7624 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7625 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7626 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7627 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7628 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7629 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7630 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7631 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7632 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7633 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
7634 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
7635 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
7636 /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
7637 HDA_CODEC_MUTE("PC Beelp Playback Switch", 0x0b, 0x05, HDA_INPUT), */
7638 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
7639 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7640 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7641 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
7645 static struct snd_kcontrol_new alc262_hippo1_mixer[] = {
7646 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7647 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7648 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7649 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7650 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7651 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7652 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7653 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7654 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7655 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
7656 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
7657 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
7658 /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
7659 HDA_CODEC_MUTE("PC Beelp Playback Switch", 0x0b, 0x05, HDA_INPUT), */
7660 /*HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),*/
7661 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7665 static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
7666 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7667 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7668 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7669 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7670 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
7672 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7673 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7674 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7675 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
7676 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
7677 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
7678 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7679 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7680 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7681 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7682 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
7683 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
7684 HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
7685 HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
7689 static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = {
7690 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7691 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7692 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7693 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7694 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7695 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
7696 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x02, HDA_INPUT),
7697 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x02, HDA_INPUT),
7698 HDA_CODEC_VOLUME("Front Mic Boost", 0x1a, 0, HDA_INPUT),
7699 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
7700 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
7701 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7702 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7703 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
7704 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
7708 static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = {
7709 HDA_CODEC_VOLUME("Rear Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7710 HDA_CODEC_MUTE("Rear Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7711 HDA_CODEC_VOLUME("Rear Mic Boost", 0x18, 0, HDA_INPUT),
7715 static struct hda_bind_ctls alc262_hp_t5735_bind_front_vol = {
7716 .ops = &snd_hda_bind_vol,
7718 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
7719 HDA_COMPOSE_AMP_VAL(0x0d, 3, 0, HDA_OUTPUT),
7724 static struct hda_bind_ctls alc262_hp_t5735_bind_front_sw = {
7725 .ops = &snd_hda_bind_sw,
7727 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
7728 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
7733 /* mute/unmute internal speaker according to the hp jack and mute state */
7734 static void alc262_hp_t5735_automute(struct hda_codec *codec, int force)
7736 struct alc_spec *spec = codec->spec;
7739 if (force || !spec->sense_updated) {
7740 unsigned int present;
7741 present = snd_hda_codec_read(codec, 0x15, 0,
7742 AC_VERB_GET_PIN_SENSE, 0);
7743 spec->jack_present = (present & 0x80000000) != 0;
7744 spec->sense_updated = 1;
7746 if (spec->jack_present)
7747 mute = (0x7080 | ((0)<<8)); /* mute internal speaker */
7748 else /* unmute internal speaker if necessary */
7749 mute = (0x7000 | ((0)<<8));
7750 snd_hda_codec_write(codec, 0x0c, 0,
7751 AC_VERB_SET_AMP_GAIN_MUTE, mute );
7754 static void alc262_hp_t5735_unsol_event(struct hda_codec *codec,
7757 if ((res >> 26) != ALC880_HP_EVENT)
7759 alc262_hp_t5735_automute(codec, 1);
7762 static void alc262_hp_t5735_init_hook(struct hda_codec *codec)
7764 alc262_hp_t5735_automute(codec, 1);
7767 static struct snd_kcontrol_new alc262_hp_t5735_mixer[] = {
7768 HDA_BIND_VOL("PCM Playback Volume", &alc262_hp_t5735_bind_front_vol),
7769 HDA_BIND_SW("PCM Playback Switch",&alc262_hp_t5735_bind_front_sw),
7770 HDA_CODEC_VOLUME("LineOut Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7771 HDA_CODEC_MUTE("LineOut Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7772 HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7773 HDA_CODEC_MUTE("iSpeaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7774 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7775 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7776 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7777 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7778 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7782 static struct hda_verb alc262_hp_t5735_verbs[] = {
7783 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7784 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7786 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7790 /* bind hp and internal speaker mute (with plug check) */
7791 static int alc262_sony_master_sw_put(struct snd_kcontrol *kcontrol,
7792 struct snd_ctl_elem_value *ucontrol)
7794 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
7795 long *valp = ucontrol->value.integer.value;
7798 /* change hp mute */
7799 change = snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
7801 valp[0] ? 0 : HDA_AMP_MUTE);
7802 change |= snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
7804 valp[1] ? 0 : HDA_AMP_MUTE);
7806 /* change speaker according to HP jack state */
7807 struct alc_spec *spec = codec->spec;
7809 if (spec->jack_present)
7810 mute = HDA_AMP_MUTE;
7812 mute = snd_hda_codec_amp_read(codec, 0x15, 0,
7814 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7815 HDA_AMP_MUTE, mute);
7820 static struct snd_kcontrol_new alc262_sony_mixer[] = {
7821 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7823 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7824 .name = "Master Playback Switch",
7825 .info = snd_hda_mixer_amp_switch_info,
7826 .get = snd_hda_mixer_amp_switch_get,
7827 .put = alc262_sony_master_sw_put,
7828 .private_value = HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
7830 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7831 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7832 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
7833 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
7837 static struct snd_kcontrol_new alc262_benq_t31_mixer[] = {
7838 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7839 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7840 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7841 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7842 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7843 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
7844 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
7848 #define alc262_capture_mixer alc882_capture_mixer
7849 #define alc262_capture_alt_mixer alc882_capture_alt_mixer
7852 * generic initialization of ADC, input mixers and output mixers
7854 static struct hda_verb alc262_init_verbs[] = {
7856 * Unmute ADC0-2 and set the default input to mic-in
7858 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7859 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7860 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7861 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7862 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7863 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7865 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
7867 * Note: PASD motherboards uses the Line In 2 as the input for
7868 * front panel mic (mic 2)
7870 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
7871 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7872 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7873 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7874 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7875 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7878 * Set up output mixers (0x0c - 0x0e)
7880 /* set vol=0 to output mixers */
7881 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7882 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7883 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7884 /* set up input amps for analog loopback */
7885 /* Amp Indices: DAC = 0, mixer = 1 */
7886 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7887 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7888 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7889 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7890 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7891 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7893 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
7894 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
7895 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
7896 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
7897 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
7898 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
7900 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
7901 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
7902 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
7903 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
7904 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
7906 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7907 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
7909 /* FIXME: use matrix-type input source selection */
7910 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7911 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7912 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7913 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
7914 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
7915 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
7917 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7918 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
7919 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
7920 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
7922 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7923 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
7924 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
7925 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
7930 static struct hda_verb alc262_hippo_unsol_verbs[] = {
7931 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
7932 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7936 static struct hda_verb alc262_hippo1_unsol_verbs[] = {
7937 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
7938 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
7939 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
7941 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
7942 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7946 static struct hda_verb alc262_sony_unsol_verbs[] = {
7947 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
7948 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7949 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, // Front Mic
7951 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
7952 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7955 /* mute/unmute internal speaker according to the hp jack and mute state */
7956 static void alc262_hippo_automute(struct hda_codec *codec)
7958 struct alc_spec *spec = codec->spec;
7960 unsigned int present;
7962 /* need to execute and sync at first */
7963 snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
7964 present = snd_hda_codec_read(codec, 0x15, 0,
7965 AC_VERB_GET_PIN_SENSE, 0);
7966 spec->jack_present = (present & 0x80000000) != 0;
7967 if (spec->jack_present) {
7968 /* mute internal speaker */
7969 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7970 HDA_AMP_MUTE, HDA_AMP_MUTE);
7972 /* unmute internal speaker if necessary */
7973 mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0);
7974 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7975 HDA_AMP_MUTE, mute);
7979 /* unsolicited event for HP jack sensing */
7980 static void alc262_hippo_unsol_event(struct hda_codec *codec,
7983 if ((res >> 26) != ALC880_HP_EVENT)
7985 alc262_hippo_automute(codec);
7988 static void alc262_hippo1_automute(struct hda_codec *codec)
7991 unsigned int present;
7993 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
7994 present = snd_hda_codec_read(codec, 0x1b, 0,
7995 AC_VERB_GET_PIN_SENSE, 0);
7996 present = (present & 0x80000000) != 0;
7998 /* mute internal speaker */
7999 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8000 HDA_AMP_MUTE, HDA_AMP_MUTE);
8002 /* unmute internal speaker if necessary */
8003 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
8004 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8005 HDA_AMP_MUTE, mute);
8009 /* unsolicited event for HP jack sensing */
8010 static void alc262_hippo1_unsol_event(struct hda_codec *codec,
8013 if ((res >> 26) != ALC880_HP_EVENT)
8015 alc262_hippo1_automute(codec);
8020 * 0x14 = headphone/spdif-out, 0x15 = internal speaker
8023 #define ALC_HP_EVENT 0x37
8025 static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
8026 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
8027 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8031 static struct hda_input_mux alc262_fujitsu_capture_source = {
8040 static struct hda_input_mux alc262_HP_capture_source = {
8044 { "Front Mic", 0x1 },
8051 static struct hda_input_mux alc262_HP_D7000_capture_source = {
8055 { "Front Mic", 0x2 },
8061 /* mute/unmute internal speaker according to the hp jack and mute state */
8062 static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
8064 struct alc_spec *spec = codec->spec;
8067 if (force || !spec->sense_updated) {
8068 unsigned int present;
8069 /* need to execute and sync at first */
8070 snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
8071 present = snd_hda_codec_read(codec, 0x14, 0,
8072 AC_VERB_GET_PIN_SENSE, 0);
8073 spec->jack_present = (present & 0x80000000) != 0;
8074 spec->sense_updated = 1;
8076 if (spec->jack_present) {
8077 /* mute internal speaker */
8078 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8079 HDA_AMP_MUTE, HDA_AMP_MUTE);
8081 /* unmute internal speaker if necessary */
8082 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
8083 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8084 HDA_AMP_MUTE, mute);
8088 /* unsolicited event for HP jack sensing */
8089 static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
8092 if ((res >> 26) != ALC_HP_EVENT)
8094 alc262_fujitsu_automute(codec, 1);
8097 /* bind volumes of both NID 0x0c and 0x0d */
8098 static struct hda_bind_ctls alc262_fujitsu_bind_master_vol = {
8099 .ops = &snd_hda_bind_vol,
8101 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
8102 HDA_COMPOSE_AMP_VAL(0x0d, 3, 0, HDA_OUTPUT),
8107 /* bind hp and internal speaker mute (with plug check) */
8108 static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
8109 struct snd_ctl_elem_value *ucontrol)
8111 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
8112 long *valp = ucontrol->value.integer.value;
8115 change = snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
8117 valp[0] ? 0 : HDA_AMP_MUTE);
8118 change |= snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
8120 valp[1] ? 0 : HDA_AMP_MUTE);
8122 alc262_fujitsu_automute(codec, 0);
8126 static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
8127 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
8129 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8130 .name = "Master Playback Switch",
8131 .info = snd_hda_mixer_amp_switch_info,
8132 .get = snd_hda_mixer_amp_switch_get,
8133 .put = alc262_fujitsu_master_sw_put,
8134 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
8136 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8137 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8138 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8139 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8140 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8141 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
8142 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8143 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
8147 /* additional init verbs for Benq laptops */
8148 static struct hda_verb alc262_EAPD_verbs[] = {
8149 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
8150 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
8154 static struct hda_verb alc262_benq_t31_EAPD_verbs[] = {
8155 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8156 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
8158 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
8159 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
8163 /* Samsung Q1 Ultra Vista model setup */
8164 static struct snd_kcontrol_new alc262_ultra_mixer[] = {
8165 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8166 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8167 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8168 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
8169 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
8170 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
8174 static struct hda_verb alc262_ultra_verbs[] = {
8175 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
8176 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8177 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
8178 /* Mic is on Node 0x19 */
8179 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
8180 {0x22, AC_VERB_SET_CONNECT_SEL, 0x01},
8181 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
8182 {0x23, AC_VERB_SET_CONNECT_SEL, 0x01},
8183 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
8184 {0x24, AC_VERB_SET_CONNECT_SEL, 0x01},
8185 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
8189 static struct hda_input_mux alc262_ultra_capture_source = {
8196 /* mute/unmute internal speaker according to the hp jack and mute state */
8197 static void alc262_ultra_automute(struct hda_codec *codec)
8199 struct alc_spec *spec = codec->spec;
8201 unsigned int present;
8203 /* need to execute and sync at first */
8204 snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
8205 present = snd_hda_codec_read(codec, 0x15, 0,
8206 AC_VERB_GET_PIN_SENSE, 0);
8207 spec->jack_present = (present & 0x80000000) != 0;
8208 if (spec->jack_present) {
8209 /* mute internal speaker */
8210 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8211 HDA_AMP_MUTE, HDA_AMP_MUTE);
8213 /* unmute internal speaker if necessary */
8214 mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0);
8215 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8216 HDA_AMP_MUTE, mute);
8220 /* unsolicited event for HP jack sensing */
8221 static void alc262_ultra_unsol_event(struct hda_codec *codec,
8224 if ((res >> 26) != ALC880_HP_EVENT)
8226 alc262_ultra_automute(codec);
8229 /* add playback controls from the parsed DAC table */
8230 static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec,
8231 const struct auto_pin_cfg *cfg)
8236 spec->multiout.num_dacs = 1; /* only use one dac */
8237 spec->multiout.dac_nids = spec->private_dac_nids;
8238 spec->multiout.dac_nids[0] = 2;
8240 nid = cfg->line_out_pins[0];
8242 err = add_control(spec, ALC_CTL_WIDGET_VOL,
8243 "Front Playback Volume",
8244 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT));
8247 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
8248 "Front Playback Switch",
8249 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
8254 nid = cfg->speaker_pins[0];
8257 err = add_control(spec, ALC_CTL_WIDGET_VOL,
8258 "Speaker Playback Volume",
8259 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
8263 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
8264 "Speaker Playback Switch",
8265 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
8270 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
8271 "Speaker Playback Switch",
8272 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
8278 nid = cfg->hp_pins[0];
8280 /* spec->multiout.hp_nid = 2; */
8282 err = add_control(spec, ALC_CTL_WIDGET_VOL,
8283 "Headphone Playback Volume",
8284 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
8288 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
8289 "Headphone Playback Switch",
8290 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
8295 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
8296 "Headphone Playback Switch",
8297 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
8306 /* identical with ALC880 */
8307 #define alc262_auto_create_analog_input_ctls \
8308 alc880_auto_create_analog_input_ctls
8311 * generic initialization of ADC, input mixers and output mixers
8313 static struct hda_verb alc262_volume_init_verbs[] = {
8315 * Unmute ADC0-2 and set the default input to mic-in
8317 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
8318 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8319 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8320 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8321 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8322 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8324 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
8326 * Note: PASD motherboards uses the Line In 2 as the input for
8327 * front panel mic (mic 2)
8329 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
8330 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8331 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8332 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8333 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8334 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8337 * Set up output mixers (0x0c - 0x0f)
8339 /* set vol=0 to output mixers */
8340 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8341 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8342 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8344 /* set up input amps for analog loopback */
8345 /* Amp Indices: DAC = 0, mixer = 1 */
8346 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8347 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8348 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8349 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8350 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8351 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8353 /* FIXME: use matrix-type input source selection */
8354 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
8355 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
8356 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8357 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
8358 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
8359 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
8361 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8362 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
8363 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
8364 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
8366 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8367 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
8368 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
8369 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
8374 static struct hda_verb alc262_HP_BPC_init_verbs[] = {
8376 * Unmute ADC0-2 and set the default input to mic-in
8378 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
8379 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8380 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8381 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8382 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8383 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8385 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
8387 * Note: PASD motherboards uses the Line In 2 as the input for
8388 * front panel mic (mic 2)
8390 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
8391 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8392 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8393 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8394 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8395 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8396 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
8397 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
8400 * Set up output mixers (0x0c - 0x0e)
8402 /* set vol=0 to output mixers */
8403 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8404 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8405 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8407 /* set up input amps for analog loopback */
8408 /* Amp Indices: DAC = 0, mixer = 1 */
8409 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8410 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8411 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8412 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8413 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8414 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8416 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
8417 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8418 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8420 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
8421 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
8423 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
8424 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8426 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
8427 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
8428 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
8429 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
8430 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
8432 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
8433 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
8434 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
8435 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
8436 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
8437 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
8440 /* FIXME: use matrix-type input source selection */
8441 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
8442 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
8443 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8444 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
8445 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
8446 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
8448 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8449 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
8450 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
8451 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
8453 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8454 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
8455 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
8456 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
8461 static struct hda_verb alc262_HP_BPC_WildWest_init_verbs[] = {
8463 * Unmute ADC0-2 and set the default input to mic-in
8465 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
8466 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8467 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8468 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8469 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8470 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8472 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
8474 * Note: PASD motherboards uses the Line In 2 as the input for front
8477 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
8478 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8479 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8480 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8481 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8482 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8483 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
8484 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
8485 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
8487 * Set up output mixers (0x0c - 0x0e)
8489 /* set vol=0 to output mixers */
8490 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8491 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8492 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8494 /* set up input amps for analog loopback */
8495 /* Amp Indices: DAC = 0, mixer = 1 */
8496 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8497 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8498 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8499 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8500 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8501 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8504 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP */
8505 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Mono */
8506 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* rear MIC */
8507 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* Line in */
8508 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
8509 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Line out */
8510 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD in */
8512 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
8513 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
8515 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
8516 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
8518 /* {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, */
8519 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
8520 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
8521 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
8522 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
8523 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
8525 /* FIXME: use matrix-type input source selection */
8526 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
8527 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
8528 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, /*rear MIC*/
8529 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, /*Line in*/
8530 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, /*F MIC*/
8531 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, /*Front*/
8532 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, /*CD*/
8533 /* {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
8534 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, /*HP*/
8536 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8537 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
8538 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
8539 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
8540 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
8541 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
8542 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
8544 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8545 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
8546 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
8547 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
8548 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
8549 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
8550 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
8555 #ifdef CONFIG_SND_HDA_POWER_SAVE
8556 #define alc262_loopbacks alc880_loopbacks
8559 /* pcm configuration: identiacal with ALC880 */
8560 #define alc262_pcm_analog_playback alc880_pcm_analog_playback
8561 #define alc262_pcm_analog_capture alc880_pcm_analog_capture
8562 #define alc262_pcm_digital_playback alc880_pcm_digital_playback
8563 #define alc262_pcm_digital_capture alc880_pcm_digital_capture
8566 * BIOS auto configuration
8568 static int alc262_parse_auto_config(struct hda_codec *codec)
8570 struct alc_spec *spec = codec->spec;
8572 static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
8574 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
8578 if (!spec->autocfg.line_outs)
8579 return 0; /* can't find valid BIOS pin config */
8580 err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg);
8583 err = alc262_auto_create_analog_input_ctls(spec, &spec->autocfg);
8587 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
8589 if (spec->autocfg.dig_out_pin)
8590 spec->multiout.dig_out_nid = ALC262_DIGOUT_NID;
8591 if (spec->autocfg.dig_in_pin)
8592 spec->dig_in_nid = ALC262_DIGIN_NID;
8594 if (spec->kctl_alloc)
8595 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
8597 spec->init_verbs[spec->num_init_verbs++] = alc262_volume_init_verbs;
8598 spec->num_mux_defs = 1;
8599 spec->input_mux = &spec->private_imux;
8601 err = alc_auto_add_mic_boost(codec);
8608 #define alc262_auto_init_multi_out alc882_auto_init_multi_out
8609 #define alc262_auto_init_hp_out alc882_auto_init_hp_out
8610 #define alc262_auto_init_analog_input alc882_auto_init_analog_input
8613 /* init callback for auto-configuration model -- overriding the default init */
8614 static void alc262_auto_init(struct hda_codec *codec)
8616 alc262_auto_init_multi_out(codec);
8617 alc262_auto_init_hp_out(codec);
8618 alc262_auto_init_analog_input(codec);
8622 * configuration and preset
8624 static const char *alc262_models[ALC262_MODEL_LAST] = {
8625 [ALC262_BASIC] = "basic",
8626 [ALC262_HIPPO] = "hippo",
8627 [ALC262_HIPPO_1] = "hippo_1",
8628 [ALC262_FUJITSU] = "fujitsu",
8629 [ALC262_HP_BPC] = "hp-bpc",
8630 [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000",
8631 [ALC262_HP_TC_T5735] = "hp-tc-t5735",
8632 [ALC262_BENQ_ED8] = "benq",
8633 [ALC262_BENQ_T31] = "benq-t31",
8634 [ALC262_SONY_ASSAMD] = "sony-assamd",
8635 [ALC262_ULTRA] = "ultra",
8636 [ALC262_AUTO] = "auto",
8639 static struct snd_pci_quirk alc262_cfg_tbl[] = {
8640 SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO),
8641 SND_PCI_QUIRK(0x103c, 0x12fe, "HP xw9400", ALC262_HP_BPC),
8642 SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC),
8643 SND_PCI_QUIRK(0x103c, 0x12ff, "HP xw4550", ALC262_HP_BPC),
8644 SND_PCI_QUIRK(0x103c, 0x1308, "HP xw4600", ALC262_HP_BPC),
8645 SND_PCI_QUIRK(0x103c, 0x1309, "HP xw4*00", ALC262_HP_BPC),
8646 SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC),
8647 SND_PCI_QUIRK(0x103c, 0x1307, "HP xw6600", ALC262_HP_BPC),
8648 SND_PCI_QUIRK(0x103c, 0x130a, "HP xw6*00", ALC262_HP_BPC),
8649 SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC),
8650 SND_PCI_QUIRK(0x103c, 0x1306, "HP xw8600", ALC262_HP_BPC),
8651 SND_PCI_QUIRK(0x103c, 0x130b, "HP xw8*00", ALC262_HP_BPC),
8652 SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL),
8653 SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL),
8654 SND_PCI_QUIRK(0x103c, 0x2804, "HP D7000", ALC262_HP_BPC_D7000_WL),
8655 SND_PCI_QUIRK(0x103c, 0x2806, "HP D7000", ALC262_HP_BPC_D7000_WL),
8656 SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF),
8657 SND_PCI_QUIRK(0x103c, 0x2803, "HP D7000", ALC262_HP_BPC_D7000_WF),
8658 SND_PCI_QUIRK(0x103c, 0x2805, "HP D7000", ALC262_HP_BPC_D7000_WF),
8659 SND_PCI_QUIRK(0x103c, 0x2807, "HP D7000", ALC262_HP_BPC_D7000_WF),
8660 SND_PCI_QUIRK(0x103c, 0x302f, "HP Thin Client T5735",
8661 ALC262_HP_TC_T5735),
8662 SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO),
8663 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
8664 SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1),
8665 SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
8666 SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_BENQ_T31),
8667 SND_PCI_QUIRK(0x104d, 0x820f, "Sony ASSAMD", ALC262_SONY_ASSAMD),
8668 SND_PCI_QUIRK(0x104d, 0x9015, "Sony 0x9015", ALC262_SONY_ASSAMD),
8669 SND_PCI_QUIRK(0x104d, 0x900e, "Sony ASSAMD", ALC262_SONY_ASSAMD),
8670 SND_PCI_QUIRK(0x104d, 0x1f00, "Sony ASSAMD", ALC262_SONY_ASSAMD),
8671 SND_PCI_QUIRK(0x144d, 0xc032, "Samsung Q1 Ultra", ALC262_ULTRA),
8675 static struct alc_config_preset alc262_presets[] = {
8677 .mixers = { alc262_base_mixer },
8678 .init_verbs = { alc262_init_verbs },
8679 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
8680 .dac_nids = alc262_dac_nids,
8682 .num_channel_mode = ARRAY_SIZE(alc262_modes),
8683 .channel_mode = alc262_modes,
8684 .input_mux = &alc262_capture_source,
8687 .mixers = { alc262_base_mixer },
8688 .init_verbs = { alc262_init_verbs, alc262_hippo_unsol_verbs},
8689 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
8690 .dac_nids = alc262_dac_nids,
8692 .dig_out_nid = ALC262_DIGOUT_NID,
8693 .num_channel_mode = ARRAY_SIZE(alc262_modes),
8694 .channel_mode = alc262_modes,
8695 .input_mux = &alc262_capture_source,
8696 .unsol_event = alc262_hippo_unsol_event,
8697 .init_hook = alc262_hippo_automute,
8699 [ALC262_HIPPO_1] = {
8700 .mixers = { alc262_hippo1_mixer },
8701 .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs},
8702 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
8703 .dac_nids = alc262_dac_nids,
8705 .dig_out_nid = ALC262_DIGOUT_NID,
8706 .num_channel_mode = ARRAY_SIZE(alc262_modes),
8707 .channel_mode = alc262_modes,
8708 .input_mux = &alc262_capture_source,
8709 .unsol_event = alc262_hippo1_unsol_event,
8710 .init_hook = alc262_hippo1_automute,
8712 [ALC262_FUJITSU] = {
8713 .mixers = { alc262_fujitsu_mixer },
8714 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
8715 alc262_fujitsu_unsol_verbs },
8716 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
8717 .dac_nids = alc262_dac_nids,
8719 .dig_out_nid = ALC262_DIGOUT_NID,
8720 .num_channel_mode = ARRAY_SIZE(alc262_modes),
8721 .channel_mode = alc262_modes,
8722 .input_mux = &alc262_fujitsu_capture_source,
8723 .unsol_event = alc262_fujitsu_unsol_event,
8726 .mixers = { alc262_HP_BPC_mixer },
8727 .init_verbs = { alc262_HP_BPC_init_verbs },
8728 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
8729 .dac_nids = alc262_dac_nids,
8731 .num_channel_mode = ARRAY_SIZE(alc262_modes),
8732 .channel_mode = alc262_modes,
8733 .input_mux = &alc262_HP_capture_source,
8735 [ALC262_HP_BPC_D7000_WF] = {
8736 .mixers = { alc262_HP_BPC_WildWest_mixer },
8737 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
8738 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
8739 .dac_nids = alc262_dac_nids,
8741 .num_channel_mode = ARRAY_SIZE(alc262_modes),
8742 .channel_mode = alc262_modes,
8743 .input_mux = &alc262_HP_D7000_capture_source,
8745 [ALC262_HP_BPC_D7000_WL] = {
8746 .mixers = { alc262_HP_BPC_WildWest_mixer,
8747 alc262_HP_BPC_WildWest_option_mixer },
8748 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
8749 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
8750 .dac_nids = alc262_dac_nids,
8752 .num_channel_mode = ARRAY_SIZE(alc262_modes),
8753 .channel_mode = alc262_modes,
8754 .input_mux = &alc262_HP_D7000_capture_source,
8756 [ALC262_HP_TC_T5735] = {
8757 .mixers = { alc262_hp_t5735_mixer },
8758 .init_verbs = { alc262_init_verbs, alc262_hp_t5735_verbs },
8759 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
8760 .dac_nids = alc262_dac_nids,
8762 .num_channel_mode = ARRAY_SIZE(alc262_modes),
8763 .channel_mode = alc262_modes,
8764 .input_mux = &alc262_capture_source,
8765 .unsol_event = alc262_hp_t5735_unsol_event,
8766 .init_hook = alc262_hp_t5735_init_hook,
8768 [ALC262_BENQ_ED8] = {
8769 .mixers = { alc262_base_mixer },
8770 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
8771 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
8772 .dac_nids = alc262_dac_nids,
8774 .num_channel_mode = ARRAY_SIZE(alc262_modes),
8775 .channel_mode = alc262_modes,
8776 .input_mux = &alc262_capture_source,
8778 [ALC262_SONY_ASSAMD] = {
8779 .mixers = { alc262_sony_mixer },
8780 .init_verbs = { alc262_init_verbs, alc262_sony_unsol_verbs},
8781 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
8782 .dac_nids = alc262_dac_nids,
8784 .num_channel_mode = ARRAY_SIZE(alc262_modes),
8785 .channel_mode = alc262_modes,
8786 .input_mux = &alc262_capture_source,
8787 .unsol_event = alc262_hippo_unsol_event,
8788 .init_hook = alc262_hippo_automute,
8790 [ALC262_BENQ_T31] = {
8791 .mixers = { alc262_benq_t31_mixer },
8792 .init_verbs = { alc262_init_verbs, alc262_benq_t31_EAPD_verbs, alc262_hippo_unsol_verbs },
8793 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
8794 .dac_nids = alc262_dac_nids,
8796 .num_channel_mode = ARRAY_SIZE(alc262_modes),
8797 .channel_mode = alc262_modes,
8798 .input_mux = &alc262_capture_source,
8799 .unsol_event = alc262_hippo_unsol_event,
8800 .init_hook = alc262_hippo_automute,
8803 .mixers = { alc262_ultra_mixer },
8804 .init_verbs = { alc262_init_verbs, alc262_ultra_verbs },
8805 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
8806 .dac_nids = alc262_dac_nids,
8808 .dig_out_nid = ALC262_DIGOUT_NID,
8809 .num_channel_mode = ARRAY_SIZE(alc262_modes),
8810 .channel_mode = alc262_modes,
8811 .input_mux = &alc262_ultra_capture_source,
8812 .unsol_event = alc262_ultra_unsol_event,
8813 .init_hook = alc262_ultra_automute,
8817 static int patch_alc262(struct hda_codec *codec)
8819 struct alc_spec *spec;
8823 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
8829 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
8834 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
8835 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
8836 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
8837 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
8841 board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST,
8845 if (board_config < 0) {
8846 printk(KERN_INFO "hda_codec: Unknown model for ALC262, "
8847 "trying auto-probe from BIOS...\n");
8848 board_config = ALC262_AUTO;
8851 if (board_config == ALC262_AUTO) {
8852 /* automatic parse from the BIOS config */
8853 err = alc262_parse_auto_config(codec);
8859 "hda_codec: Cannot set up configuration "
8860 "from BIOS. Using base mode...\n");
8861 board_config = ALC262_BASIC;
8865 if (board_config != ALC262_AUTO)
8866 setup_preset(spec, &alc262_presets[board_config]);
8868 spec->stream_name_analog = "ALC262 Analog";
8869 spec->stream_analog_playback = &alc262_pcm_analog_playback;
8870 spec->stream_analog_capture = &alc262_pcm_analog_capture;
8872 spec->stream_name_digital = "ALC262 Digital";
8873 spec->stream_digital_playback = &alc262_pcm_digital_playback;
8874 spec->stream_digital_capture = &alc262_pcm_digital_capture;
8876 if (!spec->adc_nids && spec->input_mux) {
8877 /* check whether NID 0x07 is valid */
8878 unsigned int wcap = get_wcaps(codec, 0x07);
8881 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
8882 if (wcap != AC_WID_AUD_IN) {
8883 spec->adc_nids = alc262_adc_nids_alt;
8884 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids_alt);
8885 spec->mixers[spec->num_mixers] =
8886 alc262_capture_alt_mixer;
8889 spec->adc_nids = alc262_adc_nids;
8890 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids);
8891 spec->mixers[spec->num_mixers] = alc262_capture_mixer;
8896 codec->patch_ops = alc_patch_ops;
8897 if (board_config == ALC262_AUTO)
8898 spec->init_hook = alc262_auto_init;
8899 #ifdef CONFIG_SND_HDA_POWER_SAVE
8900 if (!spec->loopback.amplist)
8901 spec->loopback.amplist = alc262_loopbacks;
8908 * ALC268 channel source setting (2 channel)
8910 #define ALC268_DIGOUT_NID ALC880_DIGOUT_NID
8911 #define alc268_modes alc260_modes
8913 static hda_nid_t alc268_dac_nids[2] = {
8918 static hda_nid_t alc268_adc_nids[2] = {
8923 static hda_nid_t alc268_adc_nids_alt[1] = {
8928 static struct snd_kcontrol_new alc268_base_mixer[] = {
8929 /* output mixer control */
8930 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
8931 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8932 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
8933 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8934 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8935 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
8936 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
8940 static struct hda_verb alc268_eapd_verbs[] = {
8941 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
8942 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
8946 /* Toshiba specific */
8947 #define alc268_toshiba_automute alc262_hippo_automute
8949 static struct hda_verb alc268_toshiba_verbs[] = {
8950 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8955 /* bind volumes of both NID 0x02 and 0x03 */
8956 static struct hda_bind_ctls alc268_acer_bind_master_vol = {
8957 .ops = &snd_hda_bind_vol,
8959 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
8960 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
8965 /* mute/unmute internal speaker according to the hp jack and mute state */
8966 static void alc268_acer_automute(struct hda_codec *codec, int force)
8968 struct alc_spec *spec = codec->spec;
8971 if (force || !spec->sense_updated) {
8972 unsigned int present;
8973 present = snd_hda_codec_read(codec, 0x14, 0,
8974 AC_VERB_GET_PIN_SENSE, 0);
8975 spec->jack_present = (present & 0x80000000) != 0;
8976 spec->sense_updated = 1;
8978 if (spec->jack_present)
8979 mute = HDA_AMP_MUTE; /* mute internal speaker */
8980 else /* unmute internal speaker if necessary */
8981 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
8982 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8983 HDA_AMP_MUTE, mute);
8987 /* bind hp and internal speaker mute (with plug check) */
8988 static int alc268_acer_master_sw_put(struct snd_kcontrol *kcontrol,
8989 struct snd_ctl_elem_value *ucontrol)
8991 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
8992 long *valp = ucontrol->value.integer.value;
8995 change = snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
8997 valp[0] ? 0 : HDA_AMP_MUTE);
8998 change |= snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
9000 valp[1] ? 0 : HDA_AMP_MUTE);
9002 alc268_acer_automute(codec, 0);
9006 static struct snd_kcontrol_new alc268_acer_mixer[] = {
9007 /* output mixer control */
9008 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
9010 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9011 .name = "Master Playback Switch",
9012 .info = snd_hda_mixer_amp_switch_info,
9013 .get = snd_hda_mixer_amp_switch_get,
9014 .put = alc268_acer_master_sw_put,
9015 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
9017 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9018 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
9019 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
9023 static struct hda_verb alc268_acer_verbs[] = {
9024 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9025 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9027 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9031 /* unsolicited event for HP jack sensing */
9032 static void alc268_toshiba_unsol_event(struct hda_codec *codec,
9035 if ((res >> 26) != ALC880_HP_EVENT)
9037 alc268_toshiba_automute(codec);
9040 static void alc268_acer_unsol_event(struct hda_codec *codec,
9043 if ((res >> 26) != ALC880_HP_EVENT)
9045 alc268_acer_automute(codec, 1);
9048 static void alc268_acer_init_hook(struct hda_codec *codec)
9050 alc268_acer_automute(codec, 1);
9054 * generic initialization of ADC, input mixers and output mixers
9056 static struct hda_verb alc268_base_init_verbs[] = {
9057 /* Unmute DAC0-1 and set vol = 0 */
9058 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9059 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9060 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9061 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9062 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9063 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9066 * Set up output mixers (0x0c - 0x0e)
9068 /* set vol=0 to output mixers */
9069 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9070 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9071 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9072 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
9074 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9075 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9077 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
9078 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
9079 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
9080 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
9081 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
9082 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9083 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9084 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9086 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9087 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9088 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9089 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9090 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9091 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9092 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9093 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9095 /* FIXME: use matrix-type input source selection */
9096 /* Mixer elements: 0x18, 19, 1a, 1c, 14, 15, 0b */
9097 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
9099 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9100 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
9101 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
9102 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
9104 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9105 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
9106 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
9107 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
9112 * generic initialization of ADC, input mixers and output mixers
9114 static struct hda_verb alc268_volume_init_verbs[] = {
9115 /* set output DAC */
9116 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9117 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9118 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9119 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9121 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
9122 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
9123 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9124 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9125 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9127 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9128 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9129 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9130 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9131 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9133 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9134 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9135 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9136 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9138 /* set PCBEEP vol = 0 */
9139 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, (0xb000 | (0x00 << 8))},
9144 #define alc268_mux_enum_info alc_mux_enum_info
9145 #define alc268_mux_enum_get alc_mux_enum_get
9147 static int alc268_mux_enum_put(struct snd_kcontrol *kcontrol,
9148 struct snd_ctl_elem_value *ucontrol)
9150 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
9151 struct alc_spec *spec = codec->spec;
9152 const struct hda_input_mux *imux = spec->input_mux;
9153 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
9154 static hda_nid_t capture_mixers[3] = { 0x23, 0x24 };
9155 hda_nid_t nid = capture_mixers[adc_idx];
9156 unsigned int *cur_val = &spec->cur_mux[adc_idx];
9157 unsigned int i, idx;
9159 idx = ucontrol->value.enumerated.item[0];
9160 if (idx >= imux->num_items)
9161 idx = imux->num_items - 1;
9162 if (*cur_val == idx)
9164 for (i = 0; i < imux->num_items; i++) {
9165 unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
9166 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
9167 imux->items[i].index,
9169 snd_hda_codec_write_cache(codec, nid, 0,
9170 AC_VERB_SET_CONNECT_SEL,
9177 static struct snd_kcontrol_new alc268_capture_alt_mixer[] = {
9178 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
9179 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
9181 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9182 /* The multiple "Capture Source" controls confuse alsamixer
9183 * So call somewhat different..
9184 * FIXME: the controls appear in the "playback" view!
9186 /* .name = "Capture Source", */
9187 .name = "Input Source",
9189 .info = alc268_mux_enum_info,
9190 .get = alc268_mux_enum_get,
9191 .put = alc268_mux_enum_put,
9196 static struct snd_kcontrol_new alc268_capture_mixer[] = {
9197 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
9198 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
9199 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x24, 0x0, HDA_OUTPUT),
9200 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x24, 0x0, HDA_OUTPUT),
9202 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9203 /* The multiple "Capture Source" controls confuse alsamixer
9204 * So call somewhat different..
9205 * FIXME: the controls appear in the "playback" view!
9207 /* .name = "Capture Source", */
9208 .name = "Input Source",
9210 .info = alc268_mux_enum_info,
9211 .get = alc268_mux_enum_get,
9212 .put = alc268_mux_enum_put,
9217 static struct hda_input_mux alc268_capture_source = {
9221 { "Front Mic", 0x1 },
9227 /* create input playback/capture controls for the given pin */
9228 static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
9229 const char *ctlname, int idx)
9234 sprintf(name, "%s Playback Volume", ctlname);
9236 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
9237 HDA_COMPOSE_AMP_VAL(0x02, 3, idx,
9241 } else if (nid == 0x15) {
9242 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
9243 HDA_COMPOSE_AMP_VAL(0x03, 3, idx,
9249 sprintf(name, "%s Playback Switch", ctlname);
9250 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
9251 HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
9257 /* add playback controls from the parsed DAC table */
9258 static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec,
9259 const struct auto_pin_cfg *cfg)
9264 spec->multiout.num_dacs = 2; /* only use one dac */
9265 spec->multiout.dac_nids = spec->private_dac_nids;
9266 spec->multiout.dac_nids[0] = 2;
9267 spec->multiout.dac_nids[1] = 3;
9269 nid = cfg->line_out_pins[0];
9271 alc268_new_analog_output(spec, nid, "Front", 0);
9273 nid = cfg->speaker_pins[0];
9275 err = add_control(spec, ALC_CTL_WIDGET_VOL,
9276 "Speaker Playback Volume",
9277 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
9281 nid = cfg->hp_pins[0];
9283 alc268_new_analog_output(spec, nid, "Headphone", 0);
9285 nid = cfg->line_out_pins[1] | cfg->line_out_pins[2];
9287 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
9288 "Mono Playback Switch",
9289 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_INPUT));
9296 /* create playback/capture controls for input pins */
9297 static int alc268_auto_create_analog_input_ctls(struct alc_spec *spec,
9298 const struct auto_pin_cfg *cfg)
9300 struct hda_input_mux *imux = &spec->private_imux;
9303 for (i = 0; i < AUTO_PIN_LAST; i++) {
9304 switch(cfg->input_pins[i]) {
9306 idx1 = 0; /* Mic 1 */
9309 idx1 = 1; /* Mic 2 */
9312 idx1 = 2; /* Line In */
9320 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
9321 imux->items[imux->num_items].index = idx1;
9327 static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec)
9329 struct alc_spec *spec = codec->spec;
9330 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
9331 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
9332 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
9333 unsigned int dac_vol1, dac_vol2;
9336 snd_hda_codec_write(codec, speaker_nid, 0,
9337 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
9338 snd_hda_codec_write(codec, 0x0f, 0,
9339 AC_VERB_SET_AMP_GAIN_MUTE,
9341 snd_hda_codec_write(codec, 0x10, 0,
9342 AC_VERB_SET_AMP_GAIN_MUTE,
9345 snd_hda_codec_write(codec, 0x0f, 0,
9346 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
9347 snd_hda_codec_write(codec, 0x10, 0,
9348 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
9351 dac_vol1 = dac_vol2 = 0xb000 | 0x40; /* set max volume */
9352 if (line_nid == 0x14)
9353 dac_vol2 = AMP_OUT_ZERO;
9354 else if (line_nid == 0x15)
9355 dac_vol1 = AMP_OUT_ZERO;
9357 dac_vol2 = AMP_OUT_ZERO;
9358 else if (hp_nid == 0x15)
9359 dac_vol1 = AMP_OUT_ZERO;
9360 if (line_nid != 0x16 || hp_nid != 0x16 ||
9361 spec->autocfg.line_out_pins[1] != 0x16 ||
9362 spec->autocfg.line_out_pins[2] != 0x16)
9363 dac_vol1 = dac_vol2 = AMP_OUT_ZERO;
9365 snd_hda_codec_write(codec, 0x02, 0,
9366 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol1);
9367 snd_hda_codec_write(codec, 0x03, 0,
9368 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol2);
9371 /* pcm configuration: identiacal with ALC880 */
9372 #define alc268_pcm_analog_playback alc880_pcm_analog_playback
9373 #define alc268_pcm_analog_capture alc880_pcm_analog_capture
9374 #define alc268_pcm_digital_playback alc880_pcm_digital_playback
9377 * BIOS auto configuration
9379 static int alc268_parse_auto_config(struct hda_codec *codec)
9381 struct alc_spec *spec = codec->spec;
9383 static hda_nid_t alc268_ignore[] = { 0 };
9385 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
9389 if (!spec->autocfg.line_outs)
9390 return 0; /* can't find valid BIOS pin config */
9392 err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg);
9395 err = alc268_auto_create_analog_input_ctls(spec, &spec->autocfg);
9399 spec->multiout.max_channels = 2;
9401 /* digital only support output */
9402 if (spec->autocfg.dig_out_pin)
9403 spec->multiout.dig_out_nid = ALC268_DIGOUT_NID;
9405 if (spec->kctl_alloc)
9406 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
9408 spec->init_verbs[spec->num_init_verbs++] = alc268_volume_init_verbs;
9409 spec->num_mux_defs = 1;
9410 spec->input_mux = &spec->private_imux;
9412 err = alc_auto_add_mic_boost(codec);
9419 #define alc268_auto_init_multi_out alc882_auto_init_multi_out
9420 #define alc268_auto_init_hp_out alc882_auto_init_hp_out
9421 #define alc268_auto_init_analog_input alc882_auto_init_analog_input
9423 /* init callback for auto-configuration model -- overriding the default init */
9424 static void alc268_auto_init(struct hda_codec *codec)
9426 alc268_auto_init_multi_out(codec);
9427 alc268_auto_init_hp_out(codec);
9428 alc268_auto_init_mono_speaker_out(codec);
9429 alc268_auto_init_analog_input(codec);
9433 * configuration and preset
9435 static const char *alc268_models[ALC268_MODEL_LAST] = {
9436 [ALC268_3ST] = "3stack",
9437 [ALC268_TOSHIBA] = "toshiba",
9438 [ALC268_ACER] = "acer",
9439 [ALC268_AUTO] = "auto",
9442 static struct snd_pci_quirk alc268_cfg_tbl[] = {
9443 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST),
9444 SND_PCI_QUIRK(0x1179, 0xff10, "TOSHIBA A205", ALC268_TOSHIBA),
9445 SND_PCI_QUIRK(0x1179, 0xff50, "TOSHIBA A305", ALC268_TOSHIBA),
9446 SND_PCI_QUIRK(0x103c, 0x30cc, "TOSHIBA", ALC268_TOSHIBA),
9447 SND_PCI_QUIRK(0x1025, 0x0126, "Acer", ALC268_ACER),
9448 SND_PCI_QUIRK(0x1025, 0x0130, "Acer Extensa 5210", ALC268_ACER),
9449 SND_PCI_QUIRK(0x152d, 0x0763, "Diverse (CPR2000)", ALC268_ACER),
9453 static struct alc_config_preset alc268_presets[] = {
9455 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer },
9456 .init_verbs = { alc268_base_init_verbs },
9457 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
9458 .dac_nids = alc268_dac_nids,
9459 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
9460 .adc_nids = alc268_adc_nids_alt,
9462 .dig_out_nid = ALC268_DIGOUT_NID,
9463 .num_channel_mode = ARRAY_SIZE(alc268_modes),
9464 .channel_mode = alc268_modes,
9465 .input_mux = &alc268_capture_source,
9467 [ALC268_TOSHIBA] = {
9468 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer },
9469 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
9470 alc268_toshiba_verbs },
9471 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
9472 .dac_nids = alc268_dac_nids,
9473 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
9474 .adc_nids = alc268_adc_nids_alt,
9476 .num_channel_mode = ARRAY_SIZE(alc268_modes),
9477 .channel_mode = alc268_modes,
9478 .input_mux = &alc268_capture_source,
9479 .unsol_event = alc268_toshiba_unsol_event,
9480 .init_hook = alc268_toshiba_automute,
9483 .mixers = { alc268_acer_mixer, alc268_capture_alt_mixer },
9484 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
9485 alc268_acer_verbs },
9486 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
9487 .dac_nids = alc268_dac_nids,
9488 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
9489 .adc_nids = alc268_adc_nids_alt,
9491 .num_channel_mode = ARRAY_SIZE(alc268_modes),
9492 .channel_mode = alc268_modes,
9493 .input_mux = &alc268_capture_source,
9494 .unsol_event = alc268_acer_unsol_event,
9495 .init_hook = alc268_acer_init_hook,
9499 static int patch_alc268(struct hda_codec *codec)
9501 struct alc_spec *spec;
9505 spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
9511 board_config = snd_hda_check_board_config(codec, ALC268_MODEL_LAST,
9515 if (board_config < 0 || board_config >= ALC268_MODEL_LAST) {
9516 printk(KERN_INFO "hda_codec: Unknown model for ALC268, "
9517 "trying auto-probe from BIOS...\n");
9518 board_config = ALC268_AUTO;
9521 if (board_config == ALC268_AUTO) {
9522 /* automatic parse from the BIOS config */
9523 err = alc268_parse_auto_config(codec);
9529 "hda_codec: Cannot set up configuration "
9530 "from BIOS. Using base mode...\n");
9531 board_config = ALC268_3ST;
9535 if (board_config != ALC268_AUTO)
9536 setup_preset(spec, &alc268_presets[board_config]);
9538 spec->stream_name_analog = "ALC268 Analog";
9539 spec->stream_analog_playback = &alc268_pcm_analog_playback;
9540 spec->stream_analog_capture = &alc268_pcm_analog_capture;
9542 spec->stream_name_digital = "ALC268 Digital";
9543 spec->stream_digital_playback = &alc268_pcm_digital_playback;
9545 if (board_config == ALC268_AUTO) {
9546 if (!spec->adc_nids && spec->input_mux) {
9547 /* check whether NID 0x07 is valid */
9548 unsigned int wcap = get_wcaps(codec, 0x07);
9551 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
9552 if (wcap != AC_WID_AUD_IN) {
9553 spec->adc_nids = alc268_adc_nids_alt;
9554 spec->num_adc_nids =
9555 ARRAY_SIZE(alc268_adc_nids_alt);
9556 spec->mixers[spec->num_mixers] =
9557 alc268_capture_alt_mixer;
9560 spec->adc_nids = alc268_adc_nids;
9561 spec->num_adc_nids =
9562 ARRAY_SIZE(alc268_adc_nids);
9563 spec->mixers[spec->num_mixers] =
9564 alc268_capture_mixer;
9569 codec->patch_ops = alc_patch_ops;
9570 if (board_config == ALC268_AUTO)
9571 spec->init_hook = alc268_auto_init;
9577 * ALC861 channel source setting (2/6 channel selection for 3-stack)
9581 * set the path ways for 2 channel output
9582 * need to set the codec line out and mic 1 pin widgets to inputs
9584 static struct hda_verb alc861_threestack_ch2_init[] = {
9585 /* set pin widget 1Ah (line in) for input */
9586 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
9587 /* set pin widget 18h (mic1/2) for input, for mic also enable
9590 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
9592 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
9594 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
9595 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
9601 * need to set the codec line out and mic 1 pin widgets to outputs
9603 static struct hda_verb alc861_threestack_ch6_init[] = {
9604 /* set pin widget 1Ah (line in) for output (Back Surround)*/
9605 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
9606 /* set pin widget 18h (mic1) for output (CLFE)*/
9607 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
9609 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
9610 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
9612 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
9614 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
9615 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
9620 static struct hda_channel_mode alc861_threestack_modes[2] = {
9621 { 2, alc861_threestack_ch2_init },
9622 { 6, alc861_threestack_ch6_init },
9624 /* Set mic1 as input and unmute the mixer */
9625 static struct hda_verb alc861_uniwill_m31_ch2_init[] = {
9626 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
9627 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
9630 /* Set mic1 as output and mute mixer */
9631 static struct hda_verb alc861_uniwill_m31_ch4_init[] = {
9632 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
9633 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
9637 static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
9638 { 2, alc861_uniwill_m31_ch2_init },
9639 { 4, alc861_uniwill_m31_ch4_init },
9642 /* Set mic1 and line-in as input and unmute the mixer */
9643 static struct hda_verb alc861_asus_ch2_init[] = {
9644 /* set pin widget 1Ah (line in) for input */
9645 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
9646 /* set pin widget 18h (mic1/2) for input, for mic also enable
9649 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
9651 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
9653 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
9654 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
9658 /* Set mic1 nad line-in as output and mute mixer */
9659 static struct hda_verb alc861_asus_ch6_init[] = {
9660 /* set pin widget 1Ah (line in) for output (Back Surround)*/
9661 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
9662 /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
9663 /* set pin widget 18h (mic1) for output (CLFE)*/
9664 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
9665 /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
9666 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
9667 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
9669 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
9671 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
9672 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
9677 static struct hda_channel_mode alc861_asus_modes[2] = {
9678 { 2, alc861_asus_ch2_init },
9679 { 6, alc861_asus_ch6_init },
9684 static struct snd_kcontrol_new alc861_base_mixer[] = {
9685 /* output mixer control */
9686 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
9687 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
9688 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
9689 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
9690 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
9692 /*Input mixer control */
9693 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
9694 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
9695 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
9696 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
9697 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
9698 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
9699 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
9700 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
9701 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
9702 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
9704 /* Capture mixer control */
9705 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
9706 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
9708 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9709 .name = "Capture Source",
9711 .info = alc_mux_enum_info,
9712 .get = alc_mux_enum_get,
9713 .put = alc_mux_enum_put,
9718 static struct snd_kcontrol_new alc861_3ST_mixer[] = {
9719 /* output mixer control */
9720 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
9721 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
9722 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
9723 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
9724 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
9726 /* Input mixer control */
9727 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
9728 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
9729 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
9730 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
9731 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
9732 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
9733 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
9734 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
9735 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
9736 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
9738 /* Capture mixer control */
9739 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
9740 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
9742 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9743 .name = "Capture Source",
9745 .info = alc_mux_enum_info,
9746 .get = alc_mux_enum_get,
9747 .put = alc_mux_enum_put,
9750 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9751 .name = "Channel Mode",
9752 .info = alc_ch_mode_info,
9753 .get = alc_ch_mode_get,
9754 .put = alc_ch_mode_put,
9755 .private_value = ARRAY_SIZE(alc861_threestack_modes),
9760 static struct snd_kcontrol_new alc861_toshiba_mixer[] = {
9761 /* output mixer control */
9762 HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT),
9763 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
9764 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
9766 /*Capture mixer control */
9767 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
9768 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
9770 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9771 .name = "Capture Source",
9773 .info = alc_mux_enum_info,
9774 .get = alc_mux_enum_get,
9775 .put = alc_mux_enum_put,
9781 static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
9782 /* output mixer control */
9783 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
9784 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
9785 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
9786 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
9787 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
9789 /* Input mixer control */
9790 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
9791 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
9792 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
9793 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
9794 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
9795 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
9796 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
9797 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
9798 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
9799 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
9801 /* Capture mixer control */
9802 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
9803 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
9805 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9806 .name = "Capture Source",
9808 .info = alc_mux_enum_info,
9809 .get = alc_mux_enum_get,
9810 .put = alc_mux_enum_put,
9813 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9814 .name = "Channel Mode",
9815 .info = alc_ch_mode_info,
9816 .get = alc_ch_mode_get,
9817 .put = alc_ch_mode_put,
9818 .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
9823 static struct snd_kcontrol_new alc861_asus_mixer[] = {
9824 /* output mixer control */
9825 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
9826 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
9827 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
9828 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
9829 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
9831 /* Input mixer control */
9832 HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
9833 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9834 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
9835 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
9836 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
9837 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
9838 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
9839 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
9840 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
9841 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT),
9843 /* Capture mixer control */
9844 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
9845 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
9847 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9848 .name = "Capture Source",
9850 .info = alc_mux_enum_info,
9851 .get = alc_mux_enum_get,
9852 .put = alc_mux_enum_put,
9855 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9856 .name = "Channel Mode",
9857 .info = alc_ch_mode_info,
9858 .get = alc_ch_mode_get,
9859 .put = alc_ch_mode_put,
9860 .private_value = ARRAY_SIZE(alc861_asus_modes),
9865 /* additional mixer */
9866 static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = {
9867 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
9868 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
9869 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x23, 0x0, HDA_OUTPUT),
9870 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x23, 0x0, HDA_OUTPUT),
9875 * generic initialization of ADC, input mixers and output mixers
9877 static struct hda_verb alc861_base_init_verbs[] = {
9879 * Unmute ADC0 and set the default input to mic-in
9881 /* port-A for surround (rear panel) */
9882 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
9883 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
9884 /* port-B for mic-in (rear panel) with vref */
9885 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
9886 /* port-C for line-in (rear panel) */
9887 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
9888 /* port-D for Front */
9889 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
9890 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
9891 /* port-E for HP out (front panel) */
9892 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
9893 /* route front PCM to HP */
9894 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
9895 /* port-F for mic-in (front panel) with vref */
9896 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
9897 /* port-G for CLFE (rear panel) */
9898 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
9899 { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
9900 /* port-H for side (rear panel) */
9901 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
9902 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
9904 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
9905 /* route front mic to ADC1*/
9906 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
9907 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9909 /* Unmute DAC0~3 & spdif out*/
9910 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9911 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9912 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9913 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9914 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9916 /* Unmute Mixer 14 (mic) 1c (Line in)*/
9917 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9918 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9919 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9920 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9922 /* Unmute Stereo Mixer 15 */
9923 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9924 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9925 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
9926 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
9928 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9929 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9930 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9931 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9932 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9933 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9934 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9935 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9936 /* hp used DAC 3 (Front) */
9937 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
9938 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
9943 static struct hda_verb alc861_threestack_init_verbs[] = {
9945 * Unmute ADC0 and set the default input to mic-in
9947 /* port-A for surround (rear panel) */
9948 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
9949 /* port-B for mic-in (rear panel) with vref */
9950 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
9951 /* port-C for line-in (rear panel) */
9952 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
9953 /* port-D for Front */
9954 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
9955 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
9956 /* port-E for HP out (front panel) */
9957 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
9958 /* route front PCM to HP */
9959 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
9960 /* port-F for mic-in (front panel) with vref */
9961 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
9962 /* port-G for CLFE (rear panel) */
9963 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
9964 /* port-H for side (rear panel) */
9965 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
9967 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
9968 /* route front mic to ADC1*/
9969 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
9970 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9971 /* Unmute DAC0~3 & spdif out*/
9972 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9973 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9974 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9975 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9976 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9978 /* Unmute Mixer 14 (mic) 1c (Line in)*/
9979 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9980 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9981 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9982 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9984 /* Unmute Stereo Mixer 15 */
9985 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9986 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9987 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
9988 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
9990 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9991 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9992 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9993 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9994 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9995 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9996 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9997 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9998 /* hp used DAC 3 (Front) */
9999 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
10000 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
10004 static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
10006 * Unmute ADC0 and set the default input to mic-in
10008 /* port-A for surround (rear panel) */
10009 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
10010 /* port-B for mic-in (rear panel) with vref */
10011 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
10012 /* port-C for line-in (rear panel) */
10013 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
10014 /* port-D for Front */
10015 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
10016 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
10017 /* port-E for HP out (front panel) */
10018 /* this has to be set to VREF80 */
10019 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
10020 /* route front PCM to HP */
10021 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
10022 /* port-F for mic-in (front panel) with vref */
10023 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
10024 /* port-G for CLFE (rear panel) */
10025 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
10026 /* port-H for side (rear panel) */
10027 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
10029 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
10030 /* route front mic to ADC1*/
10031 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
10032 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10033 /* Unmute DAC0~3 & spdif out*/
10034 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10035 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10036 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10037 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10038 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10040 /* Unmute Mixer 14 (mic) 1c (Line in)*/
10041 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10042 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10043 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10044 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10046 /* Unmute Stereo Mixer 15 */
10047 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10048 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10049 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
10050 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
10052 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10053 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10054 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10055 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10056 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10057 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10058 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10059 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10060 /* hp used DAC 3 (Front) */
10061 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
10062 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
10066 static struct hda_verb alc861_asus_init_verbs[] = {
10068 * Unmute ADC0 and set the default input to mic-in
10070 /* port-A for surround (rear panel)
10071 * according to codec#0 this is the HP jack
10073 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */
10074 /* route front PCM to HP */
10075 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 },
10076 /* port-B for mic-in (rear panel) with vref */
10077 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
10078 /* port-C for line-in (rear panel) */
10079 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
10080 /* port-D for Front */
10081 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
10082 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
10083 /* port-E for HP out (front panel) */
10084 /* this has to be set to VREF80 */
10085 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
10086 /* route front PCM to HP */
10087 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
10088 /* port-F for mic-in (front panel) with vref */
10089 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
10090 /* port-G for CLFE (rear panel) */
10091 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
10092 /* port-H for side (rear panel) */
10093 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
10095 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
10096 /* route front mic to ADC1*/
10097 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
10098 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10099 /* Unmute DAC0~3 & spdif out*/
10100 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10101 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10102 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10103 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10104 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10105 /* Unmute Mixer 14 (mic) 1c (Line in)*/
10106 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10107 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10108 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10109 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10111 /* Unmute Stereo Mixer 15 */
10112 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10113 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10114 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
10115 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
10117 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10118 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10119 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10120 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10121 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10122 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10123 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10124 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10125 /* hp used DAC 3 (Front) */
10126 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
10127 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
10131 /* additional init verbs for ASUS laptops */
10132 static struct hda_verb alc861_asus_laptop_init_verbs[] = {
10133 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */
10134 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */
10139 * generic initialization of ADC, input mixers and output mixers
10141 static struct hda_verb alc861_auto_init_verbs[] = {
10143 * Unmute ADC0 and set the default input to mic-in
10145 /* {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, */
10146 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10148 /* Unmute DAC0~3 & spdif out*/
10149 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10150 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10151 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10152 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10153 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10155 /* Unmute Mixer 14 (mic) 1c (Line in)*/
10156 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10157 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10158 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10159 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10161 /* Unmute Stereo Mixer 15 */
10162 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10163 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10164 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
10165 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
10167 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10168 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10169 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10170 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10171 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10172 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10173 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10174 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10176 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10177 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10178 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
10179 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
10180 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10181 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10182 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
10183 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
10185 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */
10190 static struct hda_verb alc861_toshiba_init_verbs[] = {
10191 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10196 /* toggle speaker-output according to the hp-jack state */
10197 static void alc861_toshiba_automute(struct hda_codec *codec)
10199 unsigned int present;
10201 present = snd_hda_codec_read(codec, 0x0f, 0,
10202 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
10203 snd_hda_codec_amp_stereo(codec, 0x16, HDA_INPUT, 0,
10204 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
10205 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_INPUT, 3,
10206 HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
10209 static void alc861_toshiba_unsol_event(struct hda_codec *codec,
10212 if ((res >> 26) == ALC880_HP_EVENT)
10213 alc861_toshiba_automute(codec);
10216 /* pcm configuration: identiacal with ALC880 */
10217 #define alc861_pcm_analog_playback alc880_pcm_analog_playback
10218 #define alc861_pcm_analog_capture alc880_pcm_analog_capture
10219 #define alc861_pcm_digital_playback alc880_pcm_digital_playback
10220 #define alc861_pcm_digital_capture alc880_pcm_digital_capture
10223 #define ALC861_DIGOUT_NID 0x07
10225 static struct hda_channel_mode alc861_8ch_modes[1] = {
10229 static hda_nid_t alc861_dac_nids[4] = {
10230 /* front, surround, clfe, side */
10231 0x03, 0x06, 0x05, 0x04
10234 static hda_nid_t alc660_dac_nids[3] = {
10235 /* front, clfe, surround */
10239 static hda_nid_t alc861_adc_nids[1] = {
10244 static struct hda_input_mux alc861_capture_source = {
10248 { "Front Mic", 0x3 },
10255 /* fill in the dac_nids table from the parsed pin configuration */
10256 static int alc861_auto_fill_dac_nids(struct alc_spec *spec,
10257 const struct auto_pin_cfg *cfg)
10262 spec->multiout.dac_nids = spec->private_dac_nids;
10263 for (i = 0; i < cfg->line_outs; i++) {
10264 nid = cfg->line_out_pins[i];
10266 if (i >= ARRAY_SIZE(alc861_dac_nids))
10268 spec->multiout.dac_nids[i] = alc861_dac_nids[i];
10271 spec->multiout.num_dacs = cfg->line_outs;
10275 /* add playback controls from the parsed DAC table */
10276 static int alc861_auto_create_multi_out_ctls(struct alc_spec *spec,
10277 const struct auto_pin_cfg *cfg)
10280 static const char *chname[4] = {
10281 "Front", "Surround", NULL /*CLFE*/, "Side"
10286 for (i = 0; i < cfg->line_outs; i++) {
10287 nid = spec->multiout.dac_nids[i];
10292 err = add_control(spec, ALC_CTL_BIND_MUTE,
10293 "Center Playback Switch",
10294 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
10298 err = add_control(spec, ALC_CTL_BIND_MUTE,
10299 "LFE Playback Switch",
10300 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
10305 for (idx = 0; idx < ARRAY_SIZE(alc861_dac_nids) - 1;
10307 if (nid == alc861_dac_nids[idx])
10309 sprintf(name, "%s Playback Switch", chname[idx]);
10310 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
10311 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
10320 static int alc861_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin)
10328 if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
10330 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10331 "Headphone Playback Switch",
10332 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
10335 spec->multiout.hp_nid = nid;
10340 /* create playback/capture controls for input pins */
10341 static int alc861_auto_create_analog_input_ctls(struct alc_spec *spec,
10342 const struct auto_pin_cfg *cfg)
10344 struct hda_input_mux *imux = &spec->private_imux;
10345 int i, err, idx, idx1;
10347 for (i = 0; i < AUTO_PIN_LAST; i++) {
10348 switch (cfg->input_pins[i]) {
10351 idx = 2; /* Line In */
10355 idx = 2; /* Line In */
10359 idx = 1; /* Mic In */
10363 idx = 1; /* Mic In */
10373 err = new_analog_input(spec, cfg->input_pins[i],
10374 auto_pin_cfg_labels[i], idx, 0x15);
10378 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
10379 imux->items[imux->num_items].index = idx1;
10385 static struct snd_kcontrol_new alc861_capture_mixer[] = {
10386 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
10387 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
10390 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10391 /* The multiple "Capture Source" controls confuse alsamixer
10392 * So call somewhat different..
10393 *FIXME: the controls appear in the "playback" view!
10395 /* .name = "Capture Source", */
10396 .name = "Input Source",
10398 .info = alc_mux_enum_info,
10399 .get = alc_mux_enum_get,
10400 .put = alc_mux_enum_put,
10405 static void alc861_auto_set_output_and_unmute(struct hda_codec *codec,
10407 int pin_type, int dac_idx)
10409 /* set as output */
10411 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
10413 snd_hda_codec_write(codec, dac_idx, 0, AC_VERB_SET_AMP_GAIN_MUTE,
10418 static void alc861_auto_init_multi_out(struct hda_codec *codec)
10420 struct alc_spec *spec = codec->spec;
10423 alc_subsystem_id(codec, 0x0e, 0x0f, 0x0b);
10424 for (i = 0; i < spec->autocfg.line_outs; i++) {
10425 hda_nid_t nid = spec->autocfg.line_out_pins[i];
10426 int pin_type = get_pin_type(spec->autocfg.line_out_type);
10428 alc861_auto_set_output_and_unmute(codec, nid, pin_type,
10429 spec->multiout.dac_nids[i]);
10433 static void alc861_auto_init_hp_out(struct hda_codec *codec)
10435 struct alc_spec *spec = codec->spec;
10438 pin = spec->autocfg.hp_pins[0];
10439 if (pin) /* connect to front */
10440 alc861_auto_set_output_and_unmute(codec, pin, PIN_HP,
10441 spec->multiout.dac_nids[0]);
10444 static void alc861_auto_init_analog_input(struct hda_codec *codec)
10446 struct alc_spec *spec = codec->spec;
10449 for (i = 0; i < AUTO_PIN_LAST; i++) {
10450 hda_nid_t nid = spec->autocfg.input_pins[i];
10451 if (nid >= 0x0c && nid <= 0x11) {
10452 snd_hda_codec_write(codec, nid, 0,
10453 AC_VERB_SET_PIN_WIDGET_CONTROL,
10454 i <= AUTO_PIN_FRONT_MIC ?
10455 PIN_VREF80 : PIN_IN);
10460 /* parse the BIOS configuration and set up the alc_spec */
10461 /* return 1 if successful, 0 if the proper config is not found,
10462 * or a negative error code
10464 static int alc861_parse_auto_config(struct hda_codec *codec)
10466 struct alc_spec *spec = codec->spec;
10468 static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
10470 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
10474 if (!spec->autocfg.line_outs)
10475 return 0; /* can't find valid BIOS pin config */
10477 err = alc861_auto_fill_dac_nids(spec, &spec->autocfg);
10480 err = alc861_auto_create_multi_out_ctls(spec, &spec->autocfg);
10483 err = alc861_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0]);
10486 err = alc861_auto_create_analog_input_ctls(spec, &spec->autocfg);
10490 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
10492 if (spec->autocfg.dig_out_pin)
10493 spec->multiout.dig_out_nid = ALC861_DIGOUT_NID;
10495 if (spec->kctl_alloc)
10496 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
10498 spec->init_verbs[spec->num_init_verbs++] = alc861_auto_init_verbs;
10500 spec->num_mux_defs = 1;
10501 spec->input_mux = &spec->private_imux;
10503 spec->adc_nids = alc861_adc_nids;
10504 spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
10505 spec->mixers[spec->num_mixers] = alc861_capture_mixer;
10506 spec->num_mixers++;
10511 /* additional initialization for auto-configuration model */
10512 static void alc861_auto_init(struct hda_codec *codec)
10514 alc861_auto_init_multi_out(codec);
10515 alc861_auto_init_hp_out(codec);
10516 alc861_auto_init_analog_input(codec);
10519 #ifdef CONFIG_SND_HDA_POWER_SAVE
10520 static struct hda_amp_list alc861_loopbacks[] = {
10521 { 0x15, HDA_INPUT, 0 },
10522 { 0x15, HDA_INPUT, 1 },
10523 { 0x15, HDA_INPUT, 2 },
10524 { 0x15, HDA_INPUT, 3 },
10531 * configuration and preset
10533 static const char *alc861_models[ALC861_MODEL_LAST] = {
10534 [ALC861_3ST] = "3stack",
10535 [ALC660_3ST] = "3stack-660",
10536 [ALC861_3ST_DIG] = "3stack-dig",
10537 [ALC861_6ST_DIG] = "6stack-dig",
10538 [ALC861_UNIWILL_M31] = "uniwill-m31",
10539 [ALC861_TOSHIBA] = "toshiba",
10540 [ALC861_ASUS] = "asus",
10541 [ALC861_ASUS_LAPTOP] = "asus-laptop",
10542 [ALC861_AUTO] = "auto",
10545 static struct snd_pci_quirk alc861_cfg_tbl[] = {
10546 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST),
10547 SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP),
10548 SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP),
10549 SND_PCI_QUIRK(0x1043, 0x13d7, "ASUS A9rp", ALC861_ASUS_LAPTOP),
10550 SND_PCI_QUIRK(0x1584, 0x9075, "Airis Praxis N1212", ALC861_ASUS_LAPTOP),
10551 SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS),
10552 SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS P1-AH2", ALC861_3ST_DIG),
10553 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA),
10554 /* FIXME: the entry below breaks Toshiba A100 (model=auto works!)
10555 * Any other models that need this preset?
10557 /* SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA), */
10558 SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31),
10559 SND_PCI_QUIRK(0x1584, 0x9075, "Uniwill", ALC861_UNIWILL_M31),
10560 SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31),
10561 SND_PCI_QUIRK(0x1849, 0x0660, "Asrock 939SLI32", ALC660_3ST),
10562 SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST),
10563 SND_PCI_QUIRK(0x1462, 0x7254, "HP dx2200 (MSI MS-7254)", ALC861_3ST),
10564 SND_PCI_QUIRK(0x1462, 0x7297, "HP dx2250 (MSI MS-7297)", ALC861_3ST),
10568 static struct alc_config_preset alc861_presets[] = {
10570 .mixers = { alc861_3ST_mixer },
10571 .init_verbs = { alc861_threestack_init_verbs },
10572 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
10573 .dac_nids = alc861_dac_nids,
10574 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
10575 .channel_mode = alc861_threestack_modes,
10577 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
10578 .adc_nids = alc861_adc_nids,
10579 .input_mux = &alc861_capture_source,
10581 [ALC861_3ST_DIG] = {
10582 .mixers = { alc861_base_mixer },
10583 .init_verbs = { alc861_threestack_init_verbs },
10584 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
10585 .dac_nids = alc861_dac_nids,
10586 .dig_out_nid = ALC861_DIGOUT_NID,
10587 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
10588 .channel_mode = alc861_threestack_modes,
10590 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
10591 .adc_nids = alc861_adc_nids,
10592 .input_mux = &alc861_capture_source,
10594 [ALC861_6ST_DIG] = {
10595 .mixers = { alc861_base_mixer },
10596 .init_verbs = { alc861_base_init_verbs },
10597 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
10598 .dac_nids = alc861_dac_nids,
10599 .dig_out_nid = ALC861_DIGOUT_NID,
10600 .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
10601 .channel_mode = alc861_8ch_modes,
10602 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
10603 .adc_nids = alc861_adc_nids,
10604 .input_mux = &alc861_capture_source,
10607 .mixers = { alc861_3ST_mixer },
10608 .init_verbs = { alc861_threestack_init_verbs },
10609 .num_dacs = ARRAY_SIZE(alc660_dac_nids),
10610 .dac_nids = alc660_dac_nids,
10611 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
10612 .channel_mode = alc861_threestack_modes,
10614 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
10615 .adc_nids = alc861_adc_nids,
10616 .input_mux = &alc861_capture_source,
10618 [ALC861_UNIWILL_M31] = {
10619 .mixers = { alc861_uniwill_m31_mixer },
10620 .init_verbs = { alc861_uniwill_m31_init_verbs },
10621 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
10622 .dac_nids = alc861_dac_nids,
10623 .dig_out_nid = ALC861_DIGOUT_NID,
10624 .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes),
10625 .channel_mode = alc861_uniwill_m31_modes,
10627 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
10628 .adc_nids = alc861_adc_nids,
10629 .input_mux = &alc861_capture_source,
10631 [ALC861_TOSHIBA] = {
10632 .mixers = { alc861_toshiba_mixer },
10633 .init_verbs = { alc861_base_init_verbs,
10634 alc861_toshiba_init_verbs },
10635 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
10636 .dac_nids = alc861_dac_nids,
10637 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10638 .channel_mode = alc883_3ST_2ch_modes,
10639 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
10640 .adc_nids = alc861_adc_nids,
10641 .input_mux = &alc861_capture_source,
10642 .unsol_event = alc861_toshiba_unsol_event,
10643 .init_hook = alc861_toshiba_automute,
10646 .mixers = { alc861_asus_mixer },
10647 .init_verbs = { alc861_asus_init_verbs },
10648 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
10649 .dac_nids = alc861_dac_nids,
10650 .dig_out_nid = ALC861_DIGOUT_NID,
10651 .num_channel_mode = ARRAY_SIZE(alc861_asus_modes),
10652 .channel_mode = alc861_asus_modes,
10655 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
10656 .adc_nids = alc861_adc_nids,
10657 .input_mux = &alc861_capture_source,
10659 [ALC861_ASUS_LAPTOP] = {
10660 .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer },
10661 .init_verbs = { alc861_asus_init_verbs,
10662 alc861_asus_laptop_init_verbs },
10663 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
10664 .dac_nids = alc861_dac_nids,
10665 .dig_out_nid = ALC861_DIGOUT_NID,
10666 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10667 .channel_mode = alc883_3ST_2ch_modes,
10669 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
10670 .adc_nids = alc861_adc_nids,
10671 .input_mux = &alc861_capture_source,
10676 static int patch_alc861(struct hda_codec *codec)
10678 struct alc_spec *spec;
10682 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
10686 codec->spec = spec;
10688 board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST,
10692 if (board_config < 0) {
10693 printk(KERN_INFO "hda_codec: Unknown model for ALC861, "
10694 "trying auto-probe from BIOS...\n");
10695 board_config = ALC861_AUTO;
10698 if (board_config == ALC861_AUTO) {
10699 /* automatic parse from the BIOS config */
10700 err = alc861_parse_auto_config(codec);
10706 "hda_codec: Cannot set up configuration "
10707 "from BIOS. Using base mode...\n");
10708 board_config = ALC861_3ST_DIG;
10712 if (board_config != ALC861_AUTO)
10713 setup_preset(spec, &alc861_presets[board_config]);
10715 spec->stream_name_analog = "ALC861 Analog";
10716 spec->stream_analog_playback = &alc861_pcm_analog_playback;
10717 spec->stream_analog_capture = &alc861_pcm_analog_capture;
10719 spec->stream_name_digital = "ALC861 Digital";
10720 spec->stream_digital_playback = &alc861_pcm_digital_playback;
10721 spec->stream_digital_capture = &alc861_pcm_digital_capture;
10723 codec->patch_ops = alc_patch_ops;
10724 if (board_config == ALC861_AUTO)
10725 spec->init_hook = alc861_auto_init;
10726 #ifdef CONFIG_SND_HDA_POWER_SAVE
10727 if (!spec->loopback.amplist)
10728 spec->loopback.amplist = alc861_loopbacks;
10735 * ALC861-VD support
10739 * In addition, an independent DAC
10741 #define ALC861VD_DIGOUT_NID 0x06
10743 static hda_nid_t alc861vd_dac_nids[4] = {
10744 /* front, surr, clfe, side surr */
10745 0x02, 0x03, 0x04, 0x05
10748 /* dac_nids for ALC660vd are in a different order - according to
10749 * Realtek's driver.
10750 * This should probably tesult in a different mixer for 6stack models
10751 * of ALC660vd codecs, but for now there is only 3stack mixer
10752 * - and it is the same as in 861vd.
10753 * adc_nids in ALC660vd are (is) the same as in 861vd
10755 static hda_nid_t alc660vd_dac_nids[3] = {
10756 /* front, rear, clfe, rear_surr */
10760 static hda_nid_t alc861vd_adc_nids[1] = {
10766 /* FIXME: should be a matrix-type input source selection */
10767 static struct hda_input_mux alc861vd_capture_source = {
10771 { "Front Mic", 0x1 },
10777 static struct hda_input_mux alc861vd_dallas_capture_source = {
10780 { "Front Mic", 0x0 },
10781 { "ATAPI Mic", 0x1 },
10782 { "Line In", 0x5 },
10786 static struct hda_input_mux alc861vd_hp_capture_source = {
10789 { "Front Mic", 0x0 },
10790 { "ATAPI Mic", 0x1 },
10794 #define alc861vd_mux_enum_info alc_mux_enum_info
10795 #define alc861vd_mux_enum_get alc_mux_enum_get
10797 static int alc861vd_mux_enum_put(struct snd_kcontrol *kcontrol,
10798 struct snd_ctl_elem_value *ucontrol)
10800 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10801 struct alc_spec *spec = codec->spec;
10802 const struct hda_input_mux *imux = spec->input_mux;
10803 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
10804 static hda_nid_t capture_mixers[1] = { 0x22 };
10805 hda_nid_t nid = capture_mixers[adc_idx];
10806 unsigned int *cur_val = &spec->cur_mux[adc_idx];
10807 unsigned int i, idx;
10809 idx = ucontrol->value.enumerated.item[0];
10810 if (idx >= imux->num_items)
10811 idx = imux->num_items - 1;
10812 if (*cur_val == idx)
10814 for (i = 0; i < imux->num_items; i++) {
10815 unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
10816 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
10817 imux->items[i].index,
10827 static struct hda_channel_mode alc861vd_3stack_2ch_modes[1] = {
10834 static struct hda_verb alc861vd_6stack_ch6_init[] = {
10835 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
10836 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10837 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10838 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10845 static struct hda_verb alc861vd_6stack_ch8_init[] = {
10846 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10847 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10848 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10849 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10853 static struct hda_channel_mode alc861vd_6stack_modes[2] = {
10854 { 6, alc861vd_6stack_ch6_init },
10855 { 8, alc861vd_6stack_ch8_init },
10858 static struct snd_kcontrol_new alc861vd_chmode_mixer[] = {
10860 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10861 .name = "Channel Mode",
10862 .info = alc_ch_mode_info,
10863 .get = alc_ch_mode_get,
10864 .put = alc_ch_mode_put,
10869 static struct snd_kcontrol_new alc861vd_capture_mixer[] = {
10870 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
10871 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
10874 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10875 /* The multiple "Capture Source" controls confuse alsamixer
10876 * So call somewhat different..
10877 *FIXME: the controls appear in the "playback" view!
10879 /* .name = "Capture Source", */
10880 .name = "Input Source",
10882 .info = alc861vd_mux_enum_info,
10883 .get = alc861vd_mux_enum_get,
10884 .put = alc861vd_mux_enum_put,
10889 /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
10890 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
10892 static struct snd_kcontrol_new alc861vd_6st_mixer[] = {
10893 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
10894 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
10896 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
10897 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
10899 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0,
10901 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0,
10903 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
10904 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
10906 HDA_CODEC_VOLUME("Side Playback Volume", 0x05, 0x0, HDA_OUTPUT),
10907 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
10909 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
10911 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10912 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10913 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10915 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10916 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
10917 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
10919 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10920 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10922 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10923 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10925 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
10926 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
10931 static struct snd_kcontrol_new alc861vd_3st_mixer[] = {
10932 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
10933 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
10935 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
10937 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10938 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10939 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10941 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10942 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
10943 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
10945 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10946 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10948 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10949 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10951 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
10952 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
10957 static struct snd_kcontrol_new alc861vd_lenovo_mixer[] = {
10958 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
10959 /*HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),*/
10960 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
10962 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
10964 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10965 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10966 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10968 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10969 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
10970 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
10972 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10973 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10978 /* Pin assignment: Front=0x14, HP = 0x15,
10979 * Front Mic=0x18, ATAPI Mic = 0x19, Line In = 0x1d
10981 static struct snd_kcontrol_new alc861vd_dallas_mixer[] = {
10982 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
10983 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
10984 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
10985 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
10986 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10987 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10988 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
10989 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
10990 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x05, HDA_INPUT),
10991 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x05, HDA_INPUT),
10995 /* Pin assignment: Speaker=0x14, Line-out = 0x15,
10996 * Front Mic=0x18, ATAPI Mic = 0x19,
10998 static struct snd_kcontrol_new alc861vd_hp_mixer[] = {
10999 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
11000 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
11001 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
11002 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
11003 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11004 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11005 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
11006 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
11012 * generic initialization of ADC, input mixers and output mixers
11014 static struct hda_verb alc861vd_volume_init_verbs[] = {
11016 * Unmute ADC0 and set the default input to mic-in
11018 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
11019 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11021 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of
11022 * the analog-loopback mixer widget
11024 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
11025 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11026 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11027 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11028 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11029 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
11031 /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */
11032 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11033 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11034 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
11035 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
11038 * Set up output mixers (0x02 - 0x05)
11040 /* set vol=0 to output mixers */
11041 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11042 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11043 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11044 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11046 /* set up input amps for analog loopback */
11047 /* Amp Indices: DAC = 0, mixer = 1 */
11048 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11049 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11050 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11051 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11052 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11053 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11054 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11055 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11061 * 3-stack pin configuration:
11062 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
11064 static struct hda_verb alc861vd_3stack_init_verbs[] = {
11066 * Set pin mode and muting
11068 /* set front pin widgets 0x14 for output */
11069 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11070 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11071 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
11073 /* Mic (rear) pin: input vref at 80% */
11074 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
11075 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11076 /* Front Mic pin: input vref at 80% */
11077 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
11078 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11079 /* Line In pin: input */
11080 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11081 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11082 /* Line-2 In: Headphone output (output 0 - 0x0c) */
11083 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11084 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11085 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
11086 /* CD pin widget for input */
11087 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11093 * 6-stack pin configuration:
11095 static struct hda_verb alc861vd_6stack_init_verbs[] = {
11097 * Set pin mode and muting
11099 /* set front pin widgets 0x14 for output */
11100 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11101 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11102 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
11104 /* Rear Pin: output 1 (0x0d) */
11105 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11106 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11107 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
11108 /* CLFE Pin: output 2 (0x0e) */
11109 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11110 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11111 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
11112 /* Side Pin: output 3 (0x0f) */
11113 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11114 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11115 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
11117 /* Mic (rear) pin: input vref at 80% */
11118 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
11119 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11120 /* Front Mic pin: input vref at 80% */
11121 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
11122 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11123 /* Line In pin: input */
11124 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11125 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11126 /* Line-2 In: Headphone output (output 0 - 0x0c) */
11127 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11128 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11129 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
11130 /* CD pin widget for input */
11131 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11136 static struct hda_verb alc861vd_eapd_verbs[] = {
11137 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
11141 static struct hda_verb alc861vd_lenovo_unsol_verbs[] = {
11142 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11143 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11144 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
11145 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11146 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
11150 /* toggle speaker-output according to the hp-jack state */
11151 static void alc861vd_lenovo_hp_automute(struct hda_codec *codec)
11153 unsigned int present;
11154 unsigned char bits;
11156 present = snd_hda_codec_read(codec, 0x1b, 0,
11157 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
11158 bits = present ? HDA_AMP_MUTE : 0;
11159 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
11160 HDA_AMP_MUTE, bits);
11163 static void alc861vd_lenovo_mic_automute(struct hda_codec *codec)
11165 unsigned int present;
11166 unsigned char bits;
11168 present = snd_hda_codec_read(codec, 0x18, 0,
11169 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
11170 bits = present ? HDA_AMP_MUTE : 0;
11171 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
11172 HDA_AMP_MUTE, bits);
11175 static void alc861vd_lenovo_automute(struct hda_codec *codec)
11177 alc861vd_lenovo_hp_automute(codec);
11178 alc861vd_lenovo_mic_automute(codec);
11181 static void alc861vd_lenovo_unsol_event(struct hda_codec *codec,
11184 switch (res >> 26) {
11185 case ALC880_HP_EVENT:
11186 alc861vd_lenovo_hp_automute(codec);
11188 case ALC880_MIC_EVENT:
11189 alc861vd_lenovo_mic_automute(codec);
11194 static struct hda_verb alc861vd_dallas_verbs[] = {
11195 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11196 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11197 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11198 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11200 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11201 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11202 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11203 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11204 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11205 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11206 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11207 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11209 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11210 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11211 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11212 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11213 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11214 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11215 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11216 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11218 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
11219 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11220 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
11221 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11222 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11223 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11224 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11225 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11227 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11228 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11229 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11230 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
11232 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11233 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
11234 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11239 /* toggle speaker-output according to the hp-jack state */
11240 static void alc861vd_dallas_automute(struct hda_codec *codec)
11242 unsigned int present;
11244 present = snd_hda_codec_read(codec, 0x15, 0,
11245 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
11246 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
11247 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
11250 static void alc861vd_dallas_unsol_event(struct hda_codec *codec, unsigned int res)
11252 if ((res >> 26) == ALC880_HP_EVENT)
11253 alc861vd_dallas_automute(codec);
11256 #ifdef CONFIG_SND_HDA_POWER_SAVE
11257 #define alc861vd_loopbacks alc880_loopbacks
11260 /* pcm configuration: identiacal with ALC880 */
11261 #define alc861vd_pcm_analog_playback alc880_pcm_analog_playback
11262 #define alc861vd_pcm_analog_capture alc880_pcm_analog_capture
11263 #define alc861vd_pcm_digital_playback alc880_pcm_digital_playback
11264 #define alc861vd_pcm_digital_capture alc880_pcm_digital_capture
11267 * configuration and preset
11269 static const char *alc861vd_models[ALC861VD_MODEL_LAST] = {
11270 [ALC660VD_3ST] = "3stack-660",
11271 [ALC660VD_3ST_DIG] = "3stack-660-digout",
11272 [ALC861VD_3ST] = "3stack",
11273 [ALC861VD_3ST_DIG] = "3stack-digout",
11274 [ALC861VD_6ST_DIG] = "6stack-digout",
11275 [ALC861VD_LENOVO] = "lenovo",
11276 [ALC861VD_DALLAS] = "dallas",
11277 [ALC861VD_HP] = "hp",
11278 [ALC861VD_AUTO] = "auto",
11281 static struct snd_pci_quirk alc861vd_cfg_tbl[] = {
11282 SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST),
11283 SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST),
11284 SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660VD_3ST_DIG),
11285 SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST),
11286 SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST),
11288 /*SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),*/ /*lenovo*/
11289 SND_PCI_QUIRK(0x1179, 0xff01, "DALLAS", ALC861VD_DALLAS),
11290 SND_PCI_QUIRK(0x17aa, 0x3802, "Lenovo 3000 C200", ALC861VD_LENOVO),
11291 SND_PCI_QUIRK(0x17aa, 0x2066, "Lenovo", ALC861VD_LENOVO),
11292 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba A135", ALC861VD_LENOVO),
11293 SND_PCI_QUIRK(0x1179, 0xff03, "Toshiba P205", ALC861VD_LENOVO),
11294 SND_PCI_QUIRK(0x1565, 0x820d, "Biostar NF61S SE", ALC861VD_6ST_DIG),
11295 SND_PCI_QUIRK(0x1849, 0x0862, "ASRock K8NF6G-VSTA", ALC861VD_6ST_DIG),
11296 SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_HP),
11300 static struct alc_config_preset alc861vd_presets[] = {
11302 .mixers = { alc861vd_3st_mixer },
11303 .init_verbs = { alc861vd_volume_init_verbs,
11304 alc861vd_3stack_init_verbs },
11305 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
11306 .dac_nids = alc660vd_dac_nids,
11307 .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
11308 .adc_nids = alc861vd_adc_nids,
11309 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
11310 .channel_mode = alc861vd_3stack_2ch_modes,
11311 .input_mux = &alc861vd_capture_source,
11313 [ALC660VD_3ST_DIG] = {
11314 .mixers = { alc861vd_3st_mixer },
11315 .init_verbs = { alc861vd_volume_init_verbs,
11316 alc861vd_3stack_init_verbs },
11317 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
11318 .dac_nids = alc660vd_dac_nids,
11319 .dig_out_nid = ALC861VD_DIGOUT_NID,
11320 .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
11321 .adc_nids = alc861vd_adc_nids,
11322 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
11323 .channel_mode = alc861vd_3stack_2ch_modes,
11324 .input_mux = &alc861vd_capture_source,
11327 .mixers = { alc861vd_3st_mixer },
11328 .init_verbs = { alc861vd_volume_init_verbs,
11329 alc861vd_3stack_init_verbs },
11330 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
11331 .dac_nids = alc861vd_dac_nids,
11332 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
11333 .channel_mode = alc861vd_3stack_2ch_modes,
11334 .input_mux = &alc861vd_capture_source,
11336 [ALC861VD_3ST_DIG] = {
11337 .mixers = { alc861vd_3st_mixer },
11338 .init_verbs = { alc861vd_volume_init_verbs,
11339 alc861vd_3stack_init_verbs },
11340 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
11341 .dac_nids = alc861vd_dac_nids,
11342 .dig_out_nid = ALC861VD_DIGOUT_NID,
11343 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
11344 .channel_mode = alc861vd_3stack_2ch_modes,
11345 .input_mux = &alc861vd_capture_source,
11347 [ALC861VD_6ST_DIG] = {
11348 .mixers = { alc861vd_6st_mixer, alc861vd_chmode_mixer },
11349 .init_verbs = { alc861vd_volume_init_verbs,
11350 alc861vd_6stack_init_verbs },
11351 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
11352 .dac_nids = alc861vd_dac_nids,
11353 .dig_out_nid = ALC861VD_DIGOUT_NID,
11354 .num_channel_mode = ARRAY_SIZE(alc861vd_6stack_modes),
11355 .channel_mode = alc861vd_6stack_modes,
11356 .input_mux = &alc861vd_capture_source,
11358 [ALC861VD_LENOVO] = {
11359 .mixers = { alc861vd_lenovo_mixer },
11360 .init_verbs = { alc861vd_volume_init_verbs,
11361 alc861vd_3stack_init_verbs,
11362 alc861vd_eapd_verbs,
11363 alc861vd_lenovo_unsol_verbs },
11364 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
11365 .dac_nids = alc660vd_dac_nids,
11366 .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
11367 .adc_nids = alc861vd_adc_nids,
11368 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
11369 .channel_mode = alc861vd_3stack_2ch_modes,
11370 .input_mux = &alc861vd_capture_source,
11371 .unsol_event = alc861vd_lenovo_unsol_event,
11372 .init_hook = alc861vd_lenovo_automute,
11374 [ALC861VD_DALLAS] = {
11375 .mixers = { alc861vd_dallas_mixer },
11376 .init_verbs = { alc861vd_dallas_verbs },
11377 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
11378 .dac_nids = alc861vd_dac_nids,
11379 .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
11380 .adc_nids = alc861vd_adc_nids,
11381 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
11382 .channel_mode = alc861vd_3stack_2ch_modes,
11383 .input_mux = &alc861vd_dallas_capture_source,
11384 .unsol_event = alc861vd_dallas_unsol_event,
11385 .init_hook = alc861vd_dallas_automute,
11388 .mixers = { alc861vd_hp_mixer },
11389 .init_verbs = { alc861vd_dallas_verbs, alc861vd_eapd_verbs },
11390 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
11391 .dac_nids = alc861vd_dac_nids,
11392 .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
11393 .dig_out_nid = ALC861VD_DIGOUT_NID,
11394 .adc_nids = alc861vd_adc_nids,
11395 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
11396 .channel_mode = alc861vd_3stack_2ch_modes,
11397 .input_mux = &alc861vd_hp_capture_source,
11398 .unsol_event = alc861vd_dallas_unsol_event,
11399 .init_hook = alc861vd_dallas_automute,
11404 * BIOS auto configuration
11406 static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec,
11407 hda_nid_t nid, int pin_type, int dac_idx)
11409 /* set as output */
11410 snd_hda_codec_write(codec, nid, 0,
11411 AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
11412 snd_hda_codec_write(codec, nid, 0,
11413 AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
11416 static void alc861vd_auto_init_multi_out(struct hda_codec *codec)
11418 struct alc_spec *spec = codec->spec;
11421 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
11422 for (i = 0; i <= HDA_SIDE; i++) {
11423 hda_nid_t nid = spec->autocfg.line_out_pins[i];
11424 int pin_type = get_pin_type(spec->autocfg.line_out_type);
11426 alc861vd_auto_set_output_and_unmute(codec, nid,
11432 static void alc861vd_auto_init_hp_out(struct hda_codec *codec)
11434 struct alc_spec *spec = codec->spec;
11437 pin = spec->autocfg.hp_pins[0];
11438 if (pin) /* connect to front and use dac 0 */
11439 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
11442 #define alc861vd_is_input_pin(nid) alc880_is_input_pin(nid)
11443 #define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID
11445 static void alc861vd_auto_init_analog_input(struct hda_codec *codec)
11447 struct alc_spec *spec = codec->spec;
11450 for (i = 0; i < AUTO_PIN_LAST; i++) {
11451 hda_nid_t nid = spec->autocfg.input_pins[i];
11452 if (alc861vd_is_input_pin(nid)) {
11453 snd_hda_codec_write(codec, nid, 0,
11454 AC_VERB_SET_PIN_WIDGET_CONTROL,
11455 i <= AUTO_PIN_FRONT_MIC ?
11456 PIN_VREF80 : PIN_IN);
11457 if (nid != ALC861VD_PIN_CD_NID)
11458 snd_hda_codec_write(codec, nid, 0,
11459 AC_VERB_SET_AMP_GAIN_MUTE,
11465 #define alc861vd_idx_to_mixer_vol(nid) ((nid) + 0x02)
11466 #define alc861vd_idx_to_mixer_switch(nid) ((nid) + 0x0c)
11468 /* add playback controls from the parsed DAC table */
11469 /* Based on ALC880 version. But ALC861VD has separate,
11470 * different NIDs for mute/unmute switch and volume control */
11471 static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
11472 const struct auto_pin_cfg *cfg)
11475 static const char *chname[4] = {"Front", "Surround", "CLFE", "Side"};
11476 hda_nid_t nid_v, nid_s;
11479 for (i = 0; i < cfg->line_outs; i++) {
11480 if (!spec->multiout.dac_nids[i])
11482 nid_v = alc861vd_idx_to_mixer_vol(
11484 spec->multiout.dac_nids[i]));
11485 nid_s = alc861vd_idx_to_mixer_switch(
11487 spec->multiout.dac_nids[i]));
11491 err = add_control(spec, ALC_CTL_WIDGET_VOL,
11492 "Center Playback Volume",
11493 HDA_COMPOSE_AMP_VAL(nid_v, 1, 0,
11497 err = add_control(spec, ALC_CTL_WIDGET_VOL,
11498 "LFE Playback Volume",
11499 HDA_COMPOSE_AMP_VAL(nid_v, 2, 0,
11503 err = add_control(spec, ALC_CTL_BIND_MUTE,
11504 "Center Playback Switch",
11505 HDA_COMPOSE_AMP_VAL(nid_s, 1, 2,
11509 err = add_control(spec, ALC_CTL_BIND_MUTE,
11510 "LFE Playback Switch",
11511 HDA_COMPOSE_AMP_VAL(nid_s, 2, 2,
11516 sprintf(name, "%s Playback Volume", chname[i]);
11517 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
11518 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0,
11522 sprintf(name, "%s Playback Switch", chname[i]);
11523 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
11524 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2,
11533 /* add playback controls for speaker and HP outputs */
11534 /* Based on ALC880 version. But ALC861VD has separate,
11535 * different NIDs for mute/unmute switch and volume control */
11536 static int alc861vd_auto_create_extra_out(struct alc_spec *spec,
11537 hda_nid_t pin, const char *pfx)
11539 hda_nid_t nid_v, nid_s;
11546 if (alc880_is_fixed_pin(pin)) {
11547 nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
11548 /* specify the DAC as the extra output */
11549 if (!spec->multiout.hp_nid)
11550 spec->multiout.hp_nid = nid_v;
11552 spec->multiout.extra_out_nid[0] = nid_v;
11553 /* control HP volume/switch on the output mixer amp */
11554 nid_v = alc861vd_idx_to_mixer_vol(
11555 alc880_fixed_pin_idx(pin));
11556 nid_s = alc861vd_idx_to_mixer_switch(
11557 alc880_fixed_pin_idx(pin));
11559 sprintf(name, "%s Playback Volume", pfx);
11560 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
11561 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT));
11564 sprintf(name, "%s Playback Switch", pfx);
11565 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
11566 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT));
11569 } else if (alc880_is_multi_pin(pin)) {
11570 /* set manual connection */
11571 /* we have only a switch on HP-out PIN */
11572 sprintf(name, "%s Playback Switch", pfx);
11573 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
11574 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
11581 /* parse the BIOS configuration and set up the alc_spec
11582 * return 1 if successful, 0 if the proper config is not found,
11583 * or a negative error code
11584 * Based on ALC880 version - had to change it to override
11585 * alc880_auto_create_extra_out and alc880_auto_create_multi_out_ctls */
11586 static int alc861vd_parse_auto_config(struct hda_codec *codec)
11588 struct alc_spec *spec = codec->spec;
11590 static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
11592 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
11596 if (!spec->autocfg.line_outs)
11597 return 0; /* can't find valid BIOS pin config */
11599 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
11602 err = alc861vd_auto_create_multi_out_ctls(spec, &spec->autocfg);
11605 err = alc861vd_auto_create_extra_out(spec,
11606 spec->autocfg.speaker_pins[0],
11610 err = alc861vd_auto_create_extra_out(spec,
11611 spec->autocfg.hp_pins[0],
11615 err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
11619 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
11621 if (spec->autocfg.dig_out_pin)
11622 spec->multiout.dig_out_nid = ALC861VD_DIGOUT_NID;
11624 if (spec->kctl_alloc)
11625 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
11627 spec->init_verbs[spec->num_init_verbs++]
11628 = alc861vd_volume_init_verbs;
11630 spec->num_mux_defs = 1;
11631 spec->input_mux = &spec->private_imux;
11633 err = alc_auto_add_mic_boost(codec);
11640 /* additional initialization for auto-configuration model */
11641 static void alc861vd_auto_init(struct hda_codec *codec)
11643 alc861vd_auto_init_multi_out(codec);
11644 alc861vd_auto_init_hp_out(codec);
11645 alc861vd_auto_init_analog_input(codec);
11648 static int patch_alc861vd(struct hda_codec *codec)
11650 struct alc_spec *spec;
11651 int err, board_config;
11653 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
11657 codec->spec = spec;
11659 board_config = snd_hda_check_board_config(codec, ALC861VD_MODEL_LAST,
11663 if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) {
11664 printk(KERN_INFO "hda_codec: Unknown model for ALC660VD/"
11665 "ALC861VD, trying auto-probe from BIOS...\n");
11666 board_config = ALC861VD_AUTO;
11669 if (board_config == ALC861VD_AUTO) {
11670 /* automatic parse from the BIOS config */
11671 err = alc861vd_parse_auto_config(codec);
11677 "hda_codec: Cannot set up configuration "
11678 "from BIOS. Using base mode...\n");
11679 board_config = ALC861VD_3ST;
11683 if (board_config != ALC861VD_AUTO)
11684 setup_preset(spec, &alc861vd_presets[board_config]);
11686 spec->stream_name_analog = "ALC861VD Analog";
11687 spec->stream_analog_playback = &alc861vd_pcm_analog_playback;
11688 spec->stream_analog_capture = &alc861vd_pcm_analog_capture;
11690 spec->stream_name_digital = "ALC861VD Digital";
11691 spec->stream_digital_playback = &alc861vd_pcm_digital_playback;
11692 spec->stream_digital_capture = &alc861vd_pcm_digital_capture;
11694 spec->adc_nids = alc861vd_adc_nids;
11695 spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids);
11697 spec->mixers[spec->num_mixers] = alc861vd_capture_mixer;
11698 spec->num_mixers++;
11700 codec->patch_ops = alc_patch_ops;
11702 if (board_config == ALC861VD_AUTO)
11703 spec->init_hook = alc861vd_auto_init;
11704 #ifdef CONFIG_SND_HDA_POWER_SAVE
11705 if (!spec->loopback.amplist)
11706 spec->loopback.amplist = alc861vd_loopbacks;
11715 * ALC662 is almost identical with ALC880 but has cleaner and more flexible
11716 * configuration. Each pin widget can choose any input DACs and a mixer.
11717 * Each ADC is connected from a mixer of all inputs. This makes possible
11718 * 6-channel independent captures.
11720 * In addition, an independent DAC for the multi-playback (not used in this
11723 #define ALC662_DIGOUT_NID 0x06
11724 #define ALC662_DIGIN_NID 0x0a
11726 static hda_nid_t alc662_dac_nids[4] = {
11727 /* front, rear, clfe, rear_surr */
11731 static hda_nid_t alc662_adc_nids[1] = {
11736 /* FIXME: should be a matrix-type input source selection */
11738 static struct hda_input_mux alc662_capture_source = {
11742 { "Front Mic", 0x1 },
11748 static struct hda_input_mux alc662_lenovo_101e_capture_source = {
11756 static struct hda_input_mux alc662_eeepc_capture_source = {
11764 #define alc662_mux_enum_info alc_mux_enum_info
11765 #define alc662_mux_enum_get alc_mux_enum_get
11767 static int alc662_mux_enum_put(struct snd_kcontrol *kcontrol,
11768 struct snd_ctl_elem_value *ucontrol)
11770 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
11771 struct alc_spec *spec = codec->spec;
11772 const struct hda_input_mux *imux = spec->input_mux;
11773 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
11774 static hda_nid_t capture_mixers[2] = { 0x23, 0x22 };
11775 hda_nid_t nid = capture_mixers[adc_idx];
11776 unsigned int *cur_val = &spec->cur_mux[adc_idx];
11777 unsigned int i, idx;
11779 idx = ucontrol->value.enumerated.item[0];
11780 if (idx >= imux->num_items)
11781 idx = imux->num_items - 1;
11782 if (*cur_val == idx)
11784 for (i = 0; i < imux->num_items; i++) {
11785 unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
11786 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
11787 imux->items[i].index,
11796 static struct hda_channel_mode alc662_3ST_2ch_modes[1] = {
11803 static struct hda_verb alc662_3ST_ch2_init[] = {
11804 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
11805 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
11806 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
11807 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
11814 static struct hda_verb alc662_3ST_ch6_init[] = {
11815 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11816 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
11817 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
11818 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11819 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
11820 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
11824 static struct hda_channel_mode alc662_3ST_6ch_modes[2] = {
11825 { 2, alc662_3ST_ch2_init },
11826 { 6, alc662_3ST_ch6_init },
11832 static struct hda_verb alc662_sixstack_ch6_init[] = {
11833 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
11834 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
11835 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11842 static struct hda_verb alc662_sixstack_ch8_init[] = {
11843 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11844 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11845 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11849 static struct hda_channel_mode alc662_5stack_modes[2] = {
11850 { 2, alc662_sixstack_ch6_init },
11851 { 6, alc662_sixstack_ch8_init },
11854 /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
11855 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
11858 static struct snd_kcontrol_new alc662_base_mixer[] = {
11859 /* output mixer control */
11860 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
11861 HDA_CODEC_MUTE("Front Playback Switch", 0x02, 0x0, HDA_OUTPUT),
11862 HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT),
11863 HDA_CODEC_MUTE("Surround Playback Switch", 0x03, 0x0, HDA_OUTPUT),
11864 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
11865 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
11866 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT),
11867 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT),
11868 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
11870 /*Input mixer control */
11871 HDA_CODEC_VOLUME("CD Playback Volume", 0xb, 0x4, HDA_INPUT),
11872 HDA_CODEC_MUTE("CD Playback Switch", 0xb, 0x4, HDA_INPUT),
11873 HDA_CODEC_VOLUME("Line Playback Volume", 0xb, 0x02, HDA_INPUT),
11874 HDA_CODEC_MUTE("Line Playback Switch", 0xb, 0x02, HDA_INPUT),
11875 HDA_CODEC_VOLUME("Mic Playback Volume", 0xb, 0x0, HDA_INPUT),
11876 HDA_CODEC_MUTE("Mic Playback Switch", 0xb, 0x0, HDA_INPUT),
11877 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0xb, 0x01, HDA_INPUT),
11878 HDA_CODEC_MUTE("Front Mic Playback Switch", 0xb, 0x01, HDA_INPUT),
11880 /* Capture mixer control */
11881 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
11882 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
11884 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11885 .name = "Capture Source",
11887 .info = alc_mux_enum_info,
11888 .get = alc_mux_enum_get,
11889 .put = alc_mux_enum_put,
11894 static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = {
11895 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
11896 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
11897 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
11898 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11899 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
11900 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
11901 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
11902 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11903 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11904 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
11905 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
11906 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
11907 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
11908 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
11909 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
11911 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11912 /* .name = "Capture Source", */
11913 .name = "Input Source",
11915 .info = alc662_mux_enum_info,
11916 .get = alc662_mux_enum_get,
11917 .put = alc662_mux_enum_put,
11922 static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = {
11923 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
11924 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
11925 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
11926 HDA_BIND_MUTE("Surround Playback Switch", 0x03, 2, HDA_INPUT),
11927 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
11928 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
11929 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT),
11930 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT),
11931 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
11932 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11933 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
11934 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
11935 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
11936 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11937 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11938 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
11939 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
11940 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
11941 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
11942 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
11943 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
11945 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11946 /* .name = "Capture Source", */
11947 .name = "Input Source",
11949 .info = alc662_mux_enum_info,
11950 .get = alc662_mux_enum_get,
11951 .put = alc662_mux_enum_put,
11956 static struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = {
11957 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
11958 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
11959 HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x03, 0x0, HDA_OUTPUT),
11960 HDA_BIND_MUTE("iSpeaker Playback Switch", 0x03, 2, HDA_INPUT),
11961 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
11962 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
11963 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
11964 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
11965 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
11966 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
11967 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
11969 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11970 /* .name = "Capture Source", */
11971 .name = "Input Source",
11973 .info = alc662_mux_enum_info,
11974 .get = alc662_mux_enum_get,
11975 .put = alc662_mux_enum_put,
11980 static struct snd_kcontrol_new alc662_eeepc_p701_mixer[] = {
11981 HDA_CODEC_MUTE("iSpeaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11983 HDA_CODEC_VOLUME("LineOut Playback Volume", 0x02, 0x0, HDA_OUTPUT),
11984 HDA_CODEC_MUTE("LineOut Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
11986 HDA_CODEC_VOLUME("e-Mic Boost", 0x18, 0, HDA_INPUT),
11987 HDA_CODEC_VOLUME("e-Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11988 HDA_CODEC_MUTE("e-Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11990 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
11991 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
11992 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
11996 static struct snd_kcontrol_new alc662_chmode_mixer[] = {
11998 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11999 .name = "Channel Mode",
12000 .info = alc_ch_mode_info,
12001 .get = alc_ch_mode_get,
12002 .put = alc_ch_mode_put,
12007 static struct hda_verb alc662_init_verbs[] = {
12008 /* ADC: mute amp left and right */
12009 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12010 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
12011 /* Front mixer: unmute input/output amp left and right (volume = 0) */
12013 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12014 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12015 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
12016 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
12017 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
12019 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12020 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12021 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12022 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12023 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12024 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12026 /* Front Pin: output 0 (0x0c) */
12027 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12028 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12030 /* Rear Pin: output 1 (0x0d) */
12031 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12032 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12034 /* CLFE Pin: output 2 (0x0e) */
12035 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12036 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12038 /* Mic (rear) pin: input vref at 80% */
12039 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
12040 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12041 /* Front Mic pin: input vref at 80% */
12042 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
12043 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12044 /* Line In pin: input */
12045 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12046 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12047 /* Line-2 In: Headphone output (output 0 - 0x0c) */
12048 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12049 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12050 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
12051 /* CD pin widget for input */
12052 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12054 /* FIXME: use matrix-type input source selection */
12055 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
12057 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12058 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12059 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
12060 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
12062 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12063 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12064 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
12065 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
12069 static struct hda_verb alc662_sue_init_verbs[] = {
12070 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
12071 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
12075 static struct hda_verb alc662_eeepc_sue_init_verbs[] = {
12076 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12077 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
12082 * generic initialization of ADC, input mixers and output mixers
12084 static struct hda_verb alc662_auto_init_verbs[] = {
12086 * Unmute ADC and set the default input to mic-in
12088 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
12089 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12091 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
12093 * Note: PASD motherboards uses the Line In 2 as the input for front
12094 * panel mic (mic 2)
12096 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
12097 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12098 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12099 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
12100 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
12101 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
12104 * Set up output mixers (0x0c - 0x0f)
12106 /* set vol=0 to output mixers */
12107 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12108 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12109 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12111 /* set up input amps for analog loopback */
12112 /* Amp Indices: DAC = 0, mixer = 1 */
12113 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12114 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12115 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12116 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12117 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12118 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12121 /* FIXME: use matrix-type input source selection */
12122 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
12124 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12125 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12129 /* capture mixer elements */
12130 static struct snd_kcontrol_new alc662_capture_mixer[] = {
12131 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
12132 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
12134 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12135 /* The multiple "Capture Source" controls confuse alsamixer
12136 * So call somewhat different..
12137 * FIXME: the controls appear in the "playback" view!
12139 /* .name = "Capture Source", */
12140 .name = "Input Source",
12142 .info = alc882_mux_enum_info,
12143 .get = alc882_mux_enum_get,
12144 .put = alc882_mux_enum_put,
12149 static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
12151 unsigned int present;
12152 unsigned char bits;
12154 present = snd_hda_codec_read(codec, 0x14, 0,
12155 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12156 bits = present ? HDA_AMP_MUTE : 0;
12157 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
12158 HDA_AMP_MUTE, bits);
12161 static void alc662_lenovo_101e_all_automute(struct hda_codec *codec)
12163 unsigned int present;
12164 unsigned char bits;
12166 present = snd_hda_codec_read(codec, 0x1b, 0,
12167 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12168 bits = present ? HDA_AMP_MUTE : 0;
12169 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
12170 HDA_AMP_MUTE, bits);
12171 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
12172 HDA_AMP_MUTE, bits);
12175 static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec,
12178 if ((res >> 26) == ALC880_HP_EVENT)
12179 alc662_lenovo_101e_all_automute(codec);
12180 if ((res >> 26) == ALC880_FRONT_EVENT)
12181 alc662_lenovo_101e_ispeaker_automute(codec);
12184 static void alc662_eeepc_mic_automute(struct hda_codec *codec)
12186 unsigned int present;
12188 present = snd_hda_codec_read(codec, 0x18, 0,
12189 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12190 snd_hda_codec_write(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
12191 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
12192 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
12193 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
12194 snd_hda_codec_write(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
12195 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
12196 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
12197 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
12200 /* unsolicited event for HP jack sensing */
12201 static void alc662_eeepc_unsol_event(struct hda_codec *codec,
12204 if ((res >> 26) == ALC880_HP_EVENT)
12205 alc262_hippo1_automute( codec );
12207 if ((res >> 26) == ALC880_MIC_EVENT)
12208 alc662_eeepc_mic_automute(codec);
12211 static void alc662_eeepc_inithook(struct hda_codec *codec)
12213 alc262_hippo1_automute( codec );
12214 alc662_eeepc_mic_automute(codec);
12217 #ifdef CONFIG_SND_HDA_POWER_SAVE
12218 #define alc662_loopbacks alc880_loopbacks
12222 /* pcm configuration: identiacal with ALC880 */
12223 #define alc662_pcm_analog_playback alc880_pcm_analog_playback
12224 #define alc662_pcm_analog_capture alc880_pcm_analog_capture
12225 #define alc662_pcm_digital_playback alc880_pcm_digital_playback
12226 #define alc662_pcm_digital_capture alc880_pcm_digital_capture
12229 * configuration and preset
12231 static const char *alc662_models[ALC662_MODEL_LAST] = {
12232 [ALC662_3ST_2ch_DIG] = "3stack-dig",
12233 [ALC662_3ST_6ch_DIG] = "3stack-6ch-dig",
12234 [ALC662_3ST_6ch] = "3stack-6ch",
12235 [ALC662_5ST_DIG] = "6stack-dig",
12236 [ALC662_LENOVO_101E] = "lenovo-101e",
12237 [ALC662_ASUS_EEEPC_P701] = "eeepc-p701",
12238 [ALC662_AUTO] = "auto",
12241 static struct snd_pci_quirk alc662_cfg_tbl[] = {
12242 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E),
12243 SND_PCI_QUIRK(0x1043, 0x82a1, "ASUS Eeepc", ALC662_ASUS_EEEPC_P701),
12247 static struct alc_config_preset alc662_presets[] = {
12248 [ALC662_3ST_2ch_DIG] = {
12249 .mixers = { alc662_3ST_2ch_mixer, alc662_capture_mixer },
12250 .init_verbs = { alc662_init_verbs },
12251 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
12252 .dac_nids = alc662_dac_nids,
12253 .dig_out_nid = ALC662_DIGOUT_NID,
12254 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
12255 .adc_nids = alc662_adc_nids,
12256 .dig_in_nid = ALC662_DIGIN_NID,
12257 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
12258 .channel_mode = alc662_3ST_2ch_modes,
12259 .input_mux = &alc662_capture_source,
12261 [ALC662_3ST_6ch_DIG] = {
12262 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer,
12263 alc662_capture_mixer },
12264 .init_verbs = { alc662_init_verbs },
12265 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
12266 .dac_nids = alc662_dac_nids,
12267 .dig_out_nid = ALC662_DIGOUT_NID,
12268 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
12269 .adc_nids = alc662_adc_nids,
12270 .dig_in_nid = ALC662_DIGIN_NID,
12271 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
12272 .channel_mode = alc662_3ST_6ch_modes,
12274 .input_mux = &alc662_capture_source,
12276 [ALC662_3ST_6ch] = {
12277 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer,
12278 alc662_capture_mixer },
12279 .init_verbs = { alc662_init_verbs },
12280 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
12281 .dac_nids = alc662_dac_nids,
12282 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
12283 .adc_nids = alc662_adc_nids,
12284 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
12285 .channel_mode = alc662_3ST_6ch_modes,
12287 .input_mux = &alc662_capture_source,
12289 [ALC662_5ST_DIG] = {
12290 .mixers = { alc662_base_mixer, alc662_chmode_mixer,
12291 alc662_capture_mixer },
12292 .init_verbs = { alc662_init_verbs },
12293 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
12294 .dac_nids = alc662_dac_nids,
12295 .dig_out_nid = ALC662_DIGOUT_NID,
12296 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
12297 .adc_nids = alc662_adc_nids,
12298 .dig_in_nid = ALC662_DIGIN_NID,
12299 .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes),
12300 .channel_mode = alc662_5stack_modes,
12301 .input_mux = &alc662_capture_source,
12303 [ALC662_LENOVO_101E] = {
12304 .mixers = { alc662_lenovo_101e_mixer, alc662_capture_mixer },
12305 .init_verbs = { alc662_init_verbs, alc662_sue_init_verbs },
12306 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
12307 .dac_nids = alc662_dac_nids,
12308 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
12309 .adc_nids = alc662_adc_nids,
12310 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
12311 .channel_mode = alc662_3ST_2ch_modes,
12312 .input_mux = &alc662_lenovo_101e_capture_source,
12313 .unsol_event = alc662_lenovo_101e_unsol_event,
12314 .init_hook = alc662_lenovo_101e_all_automute,
12316 [ALC662_ASUS_EEEPC_P701] = {
12317 .mixers = { alc662_eeepc_p701_mixer, alc662_capture_mixer },
12318 .init_verbs = { alc662_init_verbs,
12319 alc662_eeepc_sue_init_verbs },
12320 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
12321 .dac_nids = alc662_dac_nids,
12322 .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
12323 .adc_nids = alc662_adc_nids,
12324 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
12325 .channel_mode = alc662_3ST_2ch_modes,
12326 .input_mux = &alc662_eeepc_capture_source,
12327 .unsol_event = alc662_eeepc_unsol_event,
12328 .init_hook = alc662_eeepc_inithook,
12335 * BIOS auto configuration
12338 /* add playback controls from the parsed DAC table */
12339 static int alc662_auto_create_multi_out_ctls(struct alc_spec *spec,
12340 const struct auto_pin_cfg *cfg)
12343 static const char *chname[4] = {
12344 "Front", "Surround", NULL /*CLFE*/, "Side"
12349 for (i = 0; i < cfg->line_outs; i++) {
12350 if (!spec->multiout.dac_nids[i])
12352 nid = alc880_idx_to_dac(i);
12355 err = add_control(spec, ALC_CTL_WIDGET_VOL,
12356 "Center Playback Volume",
12357 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
12361 err = add_control(spec, ALC_CTL_WIDGET_VOL,
12362 "LFE Playback Volume",
12363 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
12367 err = add_control(spec, ALC_CTL_BIND_MUTE,
12368 "Center Playback Switch",
12369 HDA_COMPOSE_AMP_VAL(nid, 1, 2,
12373 err = add_control(spec, ALC_CTL_BIND_MUTE,
12374 "LFE Playback Switch",
12375 HDA_COMPOSE_AMP_VAL(nid, 2, 2,
12380 sprintf(name, "%s Playback Volume", chname[i]);
12381 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
12382 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
12386 sprintf(name, "%s Playback Switch", chname[i]);
12387 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
12388 HDA_COMPOSE_AMP_VAL(nid, 3, 2,
12397 /* add playback controls for speaker and HP outputs */
12398 static int alc662_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
12408 if (alc880_is_fixed_pin(pin)) {
12409 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
12410 /* printk("DAC nid=%x\n",nid); */
12411 /* specify the DAC as the extra output */
12412 if (!spec->multiout.hp_nid)
12413 spec->multiout.hp_nid = nid;
12415 spec->multiout.extra_out_nid[0] = nid;
12416 /* control HP volume/switch on the output mixer amp */
12417 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
12418 sprintf(name, "%s Playback Volume", pfx);
12419 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
12420 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
12423 sprintf(name, "%s Playback Switch", pfx);
12424 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
12425 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
12428 } else if (alc880_is_multi_pin(pin)) {
12429 /* set manual connection */
12430 /* we have only a switch on HP-out PIN */
12431 sprintf(name, "%s Playback Switch", pfx);
12432 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
12433 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
12440 /* create playback/capture controls for input pins */
12441 static int alc662_auto_create_analog_input_ctls(struct alc_spec *spec,
12442 const struct auto_pin_cfg *cfg)
12444 struct hda_input_mux *imux = &spec->private_imux;
12447 for (i = 0; i < AUTO_PIN_LAST; i++) {
12448 if (alc880_is_input_pin(cfg->input_pins[i])) {
12449 idx = alc880_input_pin_idx(cfg->input_pins[i]);
12450 err = new_analog_input(spec, cfg->input_pins[i],
12451 auto_pin_cfg_labels[i],
12455 imux->items[imux->num_items].label =
12456 auto_pin_cfg_labels[i];
12457 imux->items[imux->num_items].index =
12458 alc880_input_pin_idx(cfg->input_pins[i]);
12465 static void alc662_auto_set_output_and_unmute(struct hda_codec *codec,
12466 hda_nid_t nid, int pin_type,
12469 /* set as output */
12470 snd_hda_codec_write(codec, nid, 0,
12471 AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
12472 snd_hda_codec_write(codec, nid, 0,
12473 AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
12474 /* need the manual connection? */
12475 if (alc880_is_multi_pin(nid)) {
12476 struct alc_spec *spec = codec->spec;
12477 int idx = alc880_multi_pin_idx(nid);
12478 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
12479 AC_VERB_SET_CONNECT_SEL,
12480 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
12484 static void alc662_auto_init_multi_out(struct hda_codec *codec)
12486 struct alc_spec *spec = codec->spec;
12489 for (i = 0; i <= HDA_SIDE; i++) {
12490 hda_nid_t nid = spec->autocfg.line_out_pins[i];
12491 int pin_type = get_pin_type(spec->autocfg.line_out_type);
12493 alc662_auto_set_output_and_unmute(codec, nid, pin_type,
12498 static void alc662_auto_init_hp_out(struct hda_codec *codec)
12500 struct alc_spec *spec = codec->spec;
12503 pin = spec->autocfg.hp_pins[0];
12504 if (pin) /* connect to front */
12506 alc662_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
12509 #define alc662_is_input_pin(nid) alc880_is_input_pin(nid)
12510 #define ALC662_PIN_CD_NID ALC880_PIN_CD_NID
12512 static void alc662_auto_init_analog_input(struct hda_codec *codec)
12514 struct alc_spec *spec = codec->spec;
12517 for (i = 0; i < AUTO_PIN_LAST; i++) {
12518 hda_nid_t nid = spec->autocfg.input_pins[i];
12519 if (alc662_is_input_pin(nid)) {
12520 snd_hda_codec_write(codec, nid, 0,
12521 AC_VERB_SET_PIN_WIDGET_CONTROL,
12522 (i <= AUTO_PIN_FRONT_MIC ?
12523 PIN_VREF80 : PIN_IN));
12524 if (nid != ALC662_PIN_CD_NID)
12525 snd_hda_codec_write(codec, nid, 0,
12526 AC_VERB_SET_AMP_GAIN_MUTE,
12532 static int alc662_parse_auto_config(struct hda_codec *codec)
12534 struct alc_spec *spec = codec->spec;
12536 static hda_nid_t alc662_ignore[] = { 0x1d, 0 };
12538 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
12542 if (!spec->autocfg.line_outs)
12543 return 0; /* can't find valid BIOS pin config */
12545 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
12548 err = alc662_auto_create_multi_out_ctls(spec, &spec->autocfg);
12551 err = alc662_auto_create_extra_out(spec,
12552 spec->autocfg.speaker_pins[0],
12556 err = alc662_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
12560 err = alc662_auto_create_analog_input_ctls(spec, &spec->autocfg);
12564 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
12566 if (spec->autocfg.dig_out_pin)
12567 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
12569 if (spec->kctl_alloc)
12570 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
12572 spec->num_mux_defs = 1;
12573 spec->input_mux = &spec->private_imux;
12575 spec->init_verbs[spec->num_init_verbs++] = alc662_auto_init_verbs;
12576 spec->mixers[spec->num_mixers] = alc662_capture_mixer;
12577 spec->num_mixers++;
12581 /* additional initialization for auto-configuration model */
12582 static void alc662_auto_init(struct hda_codec *codec)
12584 alc662_auto_init_multi_out(codec);
12585 alc662_auto_init_hp_out(codec);
12586 alc662_auto_init_analog_input(codec);
12589 static int patch_alc662(struct hda_codec *codec)
12591 struct alc_spec *spec;
12592 int err, board_config;
12594 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
12598 codec->spec = spec;
12600 board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST,
12603 if (board_config < 0) {
12604 printk(KERN_INFO "hda_codec: Unknown model for ALC662, "
12605 "trying auto-probe from BIOS...\n");
12606 board_config = ALC662_AUTO;
12609 if (board_config == ALC662_AUTO) {
12610 /* automatic parse from the BIOS config */
12611 err = alc662_parse_auto_config(codec);
12617 "hda_codec: Cannot set up configuration "
12618 "from BIOS. Using base mode...\n");
12619 board_config = ALC662_3ST_2ch_DIG;
12623 if (board_config != ALC662_AUTO)
12624 setup_preset(spec, &alc662_presets[board_config]);
12626 spec->stream_name_analog = "ALC662 Analog";
12627 spec->stream_analog_playback = &alc662_pcm_analog_playback;
12628 spec->stream_analog_capture = &alc662_pcm_analog_capture;
12630 spec->stream_name_digital = "ALC662 Digital";
12631 spec->stream_digital_playback = &alc662_pcm_digital_playback;
12632 spec->stream_digital_capture = &alc662_pcm_digital_capture;
12634 if (!spec->adc_nids && spec->input_mux) {
12635 spec->adc_nids = alc662_adc_nids;
12636 spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids);
12639 codec->patch_ops = alc_patch_ops;
12640 if (board_config == ALC662_AUTO)
12641 spec->init_hook = alc662_auto_init;
12642 #ifdef CONFIG_SND_HDA_POWER_SAVE
12643 if (!spec->loopback.amplist)
12644 spec->loopback.amplist = alc662_loopbacks;
12653 struct hda_codec_preset snd_hda_preset_realtek[] = {
12654 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
12655 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
12656 { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 },
12657 { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
12658 .patch = patch_alc861 },
12659 { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
12660 { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
12661 { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
12662 { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2",
12663 .patch = patch_alc883 },
12664 { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
12665 .patch = patch_alc662 },
12666 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
12667 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
12668 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc883 },
12669 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
12670 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc883 },
12671 {} /* terminator */