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,
99 ALC262_MODEL_LAST /* last tag */
108 ALC268_MODEL_LAST /* last tag */
125 /* ALC861-VD models */
171 ALC883_TARGA_2ch_DIG,
177 ALC883_LENOVO_101E_2ch,
178 ALC883_LENOVO_NB0763,
179 ALC888_LENOVO_MS7195_DIG,
187 #define GPIO_MASK 0x03
190 /* codec parameterization */
191 struct snd_kcontrol_new *mixers[5]; /* mixer arrays */
192 unsigned int num_mixers;
194 const struct hda_verb *init_verbs[5]; /* initialization verbs
198 unsigned int num_init_verbs;
200 char *stream_name_analog; /* analog PCM stream */
201 struct hda_pcm_stream *stream_analog_playback;
202 struct hda_pcm_stream *stream_analog_capture;
204 char *stream_name_digital; /* digital PCM stream */
205 struct hda_pcm_stream *stream_digital_playback;
206 struct hda_pcm_stream *stream_digital_capture;
209 struct hda_multi_out multiout; /* playback set-up
210 * max_channels, dacs must be set
211 * dig_out_nid and hp_nid are optional
215 unsigned int num_adc_nids;
217 hda_nid_t dig_in_nid; /* digital-in NID; optional */
220 unsigned int num_mux_defs;
221 const struct hda_input_mux *input_mux;
222 unsigned int cur_mux[3];
225 const struct hda_channel_mode *channel_mode;
226 int num_channel_mode;
229 /* PCM information */
230 struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */
232 /* dynamic controls, init_verbs and input_mux */
233 struct auto_pin_cfg autocfg;
234 unsigned int num_kctl_alloc, num_kctl_used;
235 struct snd_kcontrol_new *kctl_alloc;
236 struct hda_input_mux private_imux;
237 hda_nid_t private_dac_nids[5];
240 void (*init_hook)(struct hda_codec *codec);
241 void (*unsol_event)(struct hda_codec *codec, unsigned int res);
243 /* for pin sensing */
244 unsigned int sense_updated: 1;
245 unsigned int jack_present: 1;
247 #ifdef CONFIG_SND_HDA_POWER_SAVE
248 struct hda_loopback_check loopback;
253 * configuration template - to be copied to the spec instance
255 struct alc_config_preset {
256 struct snd_kcontrol_new *mixers[5]; /* should be identical size
259 const struct hda_verb *init_verbs[5];
260 unsigned int num_dacs;
262 hda_nid_t dig_out_nid; /* optional */
263 hda_nid_t hp_nid; /* optional */
264 unsigned int num_adc_nids;
266 hda_nid_t dig_in_nid;
267 unsigned int num_channel_mode;
268 const struct hda_channel_mode *channel_mode;
270 unsigned int num_mux_defs;
271 const struct hda_input_mux *input_mux;
272 void (*unsol_event)(struct hda_codec *, unsigned int);
273 void (*init_hook)(struct hda_codec *);
274 #ifdef CONFIG_SND_HDA_POWER_SAVE
275 struct hda_amp_list *loopbacks;
283 static int alc_mux_enum_info(struct snd_kcontrol *kcontrol,
284 struct snd_ctl_elem_info *uinfo)
286 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
287 struct alc_spec *spec = codec->spec;
288 unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id);
289 if (mux_idx >= spec->num_mux_defs)
291 return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo);
294 static int alc_mux_enum_get(struct snd_kcontrol *kcontrol,
295 struct snd_ctl_elem_value *ucontrol)
297 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
298 struct alc_spec *spec = codec->spec;
299 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
301 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
305 static int alc_mux_enum_put(struct snd_kcontrol *kcontrol,
306 struct snd_ctl_elem_value *ucontrol)
308 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
309 struct alc_spec *spec = codec->spec;
310 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
311 unsigned int mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx;
312 return snd_hda_input_mux_put(codec, &spec->input_mux[mux_idx], ucontrol,
313 spec->adc_nids[adc_idx],
314 &spec->cur_mux[adc_idx]);
319 * channel mode setting
321 static int alc_ch_mode_info(struct snd_kcontrol *kcontrol,
322 struct snd_ctl_elem_info *uinfo)
324 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
325 struct alc_spec *spec = codec->spec;
326 return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
327 spec->num_channel_mode);
330 static int alc_ch_mode_get(struct snd_kcontrol *kcontrol,
331 struct snd_ctl_elem_value *ucontrol)
333 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
334 struct alc_spec *spec = codec->spec;
335 return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
336 spec->num_channel_mode,
337 spec->multiout.max_channels);
340 static int alc_ch_mode_put(struct snd_kcontrol *kcontrol,
341 struct snd_ctl_elem_value *ucontrol)
343 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
344 struct alc_spec *spec = codec->spec;
345 int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
346 spec->num_channel_mode,
347 &spec->multiout.max_channels);
348 if (err >= 0 && spec->need_dac_fix)
349 spec->multiout.num_dacs = spec->multiout.max_channels / 2;
354 * Control the mode of pin widget settings via the mixer. "pc" is used
355 * instead of "%" to avoid consequences of accidently treating the % as
356 * being part of a format specifier. Maximum allowed length of a value is
357 * 63 characters plus NULL terminator.
359 * Note: some retasking pin complexes seem to ignore requests for input
360 * states other than HiZ (eg: PIN_VREFxx) and revert to HiZ if any of these
361 * are requested. Therefore order this list so that this behaviour will not
362 * cause problems when mixer clients move through the enum sequentially.
363 * NIDs 0x0f and 0x10 have been observed to have this behaviour as of
366 static char *alc_pin_mode_names[] = {
367 "Mic 50pc bias", "Mic 80pc bias",
368 "Line in", "Line out", "Headphone out",
370 static unsigned char alc_pin_mode_values[] = {
371 PIN_VREF50, PIN_VREF80, PIN_IN, PIN_OUT, PIN_HP,
373 /* The control can present all 5 options, or it can limit the options based
374 * in the pin being assumed to be exclusively an input or an output pin. In
375 * addition, "input" pins may or may not process the mic bias option
376 * depending on actual widget capability (NIDs 0x0f and 0x10 don't seem to
377 * accept requests for bias as of chip versions up to March 2006) and/or
378 * wiring in the computer.
380 #define ALC_PIN_DIR_IN 0x00
381 #define ALC_PIN_DIR_OUT 0x01
382 #define ALC_PIN_DIR_INOUT 0x02
383 #define ALC_PIN_DIR_IN_NOMICBIAS 0x03
384 #define ALC_PIN_DIR_INOUT_NOMICBIAS 0x04
386 /* Info about the pin modes supported by the different pin direction modes.
387 * For each direction the minimum and maximum values are given.
389 static signed char alc_pin_mode_dir_info[5][2] = {
390 { 0, 2 }, /* ALC_PIN_DIR_IN */
391 { 3, 4 }, /* ALC_PIN_DIR_OUT */
392 { 0, 4 }, /* ALC_PIN_DIR_INOUT */
393 { 2, 2 }, /* ALC_PIN_DIR_IN_NOMICBIAS */
394 { 2, 4 }, /* ALC_PIN_DIR_INOUT_NOMICBIAS */
396 #define alc_pin_mode_min(_dir) (alc_pin_mode_dir_info[_dir][0])
397 #define alc_pin_mode_max(_dir) (alc_pin_mode_dir_info[_dir][1])
398 #define alc_pin_mode_n_items(_dir) \
399 (alc_pin_mode_max(_dir)-alc_pin_mode_min(_dir)+1)
401 static int alc_pin_mode_info(struct snd_kcontrol *kcontrol,
402 struct snd_ctl_elem_info *uinfo)
404 unsigned int item_num = uinfo->value.enumerated.item;
405 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
407 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
409 uinfo->value.enumerated.items = alc_pin_mode_n_items(dir);
411 if (item_num<alc_pin_mode_min(dir) || item_num>alc_pin_mode_max(dir))
412 item_num = alc_pin_mode_min(dir);
413 strcpy(uinfo->value.enumerated.name, alc_pin_mode_names[item_num]);
417 static int alc_pin_mode_get(struct snd_kcontrol *kcontrol,
418 struct snd_ctl_elem_value *ucontrol)
421 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
422 hda_nid_t nid = kcontrol->private_value & 0xffff;
423 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
424 long *valp = ucontrol->value.integer.value;
425 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
426 AC_VERB_GET_PIN_WIDGET_CONTROL,
429 /* Find enumerated value for current pinctl setting */
430 i = alc_pin_mode_min(dir);
431 while (alc_pin_mode_values[i] != pinctl && i <= alc_pin_mode_max(dir))
433 *valp = i <= alc_pin_mode_max(dir) ? i: alc_pin_mode_min(dir);
437 static int alc_pin_mode_put(struct snd_kcontrol *kcontrol,
438 struct snd_ctl_elem_value *ucontrol)
441 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
442 hda_nid_t nid = kcontrol->private_value & 0xffff;
443 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
444 long val = *ucontrol->value.integer.value;
445 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
446 AC_VERB_GET_PIN_WIDGET_CONTROL,
449 if (val < alc_pin_mode_min(dir) || val > alc_pin_mode_max(dir))
450 val = alc_pin_mode_min(dir);
452 change = pinctl != alc_pin_mode_values[val];
454 /* Set pin mode to that requested */
455 snd_hda_codec_write_cache(codec, nid, 0,
456 AC_VERB_SET_PIN_WIDGET_CONTROL,
457 alc_pin_mode_values[val]);
459 /* Also enable the retasking pin's input/output as required
460 * for the requested pin mode. Enum values of 2 or less are
463 * Dynamically switching the input/output buffers probably
464 * reduces noise slightly (particularly on input) so we'll
465 * do it. However, having both input and output buffers
466 * enabled simultaneously doesn't seem to be problematic if
467 * this turns out to be necessary in the future.
470 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
471 HDA_AMP_MUTE, HDA_AMP_MUTE);
472 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
475 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
476 HDA_AMP_MUTE, HDA_AMP_MUTE);
477 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
484 #define ALC_PIN_MODE(xname, nid, dir) \
485 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
486 .info = alc_pin_mode_info, \
487 .get = alc_pin_mode_get, \
488 .put = alc_pin_mode_put, \
489 .private_value = nid | (dir<<16) }
491 /* A switch control for ALC260 GPIO pins. Multiple GPIOs can be ganged
492 * together using a mask with more than one bit set. This control is
493 * currently used only by the ALC260 test model. At this stage they are not
494 * needed for any "production" models.
496 #ifdef CONFIG_SND_DEBUG
497 #define alc_gpio_data_info snd_ctl_boolean_mono_info
499 static int alc_gpio_data_get(struct snd_kcontrol *kcontrol,
500 struct snd_ctl_elem_value *ucontrol)
502 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
503 hda_nid_t nid = kcontrol->private_value & 0xffff;
504 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
505 long *valp = ucontrol->value.integer.value;
506 unsigned int val = snd_hda_codec_read(codec, nid, 0,
507 AC_VERB_GET_GPIO_DATA, 0x00);
509 *valp = (val & mask) != 0;
512 static int alc_gpio_data_put(struct snd_kcontrol *kcontrol,
513 struct snd_ctl_elem_value *ucontrol)
516 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
517 hda_nid_t nid = kcontrol->private_value & 0xffff;
518 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
519 long val = *ucontrol->value.integer.value;
520 unsigned int gpio_data = snd_hda_codec_read(codec, nid, 0,
521 AC_VERB_GET_GPIO_DATA,
524 /* Set/unset the masked GPIO bit(s) as needed */
525 change = (val == 0 ? 0 : mask) != (gpio_data & mask);
530 snd_hda_codec_write_cache(codec, nid, 0,
531 AC_VERB_SET_GPIO_DATA, gpio_data);
535 #define ALC_GPIO_DATA_SWITCH(xname, nid, mask) \
536 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
537 .info = alc_gpio_data_info, \
538 .get = alc_gpio_data_get, \
539 .put = alc_gpio_data_put, \
540 .private_value = nid | (mask<<16) }
541 #endif /* CONFIG_SND_DEBUG */
543 /* A switch control to allow the enabling of the digital IO pins on the
544 * ALC260. This is incredibly simplistic; the intention of this control is
545 * to provide something in the test model allowing digital outputs to be
546 * identified if present. If models are found which can utilise these
547 * outputs a more complete mixer control can be devised for those models if
550 #ifdef CONFIG_SND_DEBUG
551 #define alc_spdif_ctrl_info snd_ctl_boolean_mono_info
553 static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol,
554 struct snd_ctl_elem_value *ucontrol)
556 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
557 hda_nid_t nid = kcontrol->private_value & 0xffff;
558 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
559 long *valp = ucontrol->value.integer.value;
560 unsigned int val = snd_hda_codec_read(codec, nid, 0,
561 AC_VERB_GET_DIGI_CONVERT, 0x00);
563 *valp = (val & mask) != 0;
566 static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol,
567 struct snd_ctl_elem_value *ucontrol)
570 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
571 hda_nid_t nid = kcontrol->private_value & 0xffff;
572 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
573 long val = *ucontrol->value.integer.value;
574 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
575 AC_VERB_GET_DIGI_CONVERT,
578 /* Set/unset the masked control bit(s) as needed */
579 change = (val == 0 ? 0 : mask) != (ctrl_data & mask);
584 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1,
589 #define ALC_SPDIF_CTRL_SWITCH(xname, nid, mask) \
590 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
591 .info = alc_spdif_ctrl_info, \
592 .get = alc_spdif_ctrl_get, \
593 .put = alc_spdif_ctrl_put, \
594 .private_value = nid | (mask<<16) }
595 #endif /* CONFIG_SND_DEBUG */
598 * set up from the preset table
600 static void setup_preset(struct alc_spec *spec,
601 const struct alc_config_preset *preset)
605 for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++)
606 spec->mixers[spec->num_mixers++] = preset->mixers[i];
607 for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i];
609 spec->init_verbs[spec->num_init_verbs++] =
610 preset->init_verbs[i];
612 spec->channel_mode = preset->channel_mode;
613 spec->num_channel_mode = preset->num_channel_mode;
614 spec->need_dac_fix = preset->need_dac_fix;
616 spec->multiout.max_channels = spec->channel_mode[0].channels;
618 spec->multiout.num_dacs = preset->num_dacs;
619 spec->multiout.dac_nids = preset->dac_nids;
620 spec->multiout.dig_out_nid = preset->dig_out_nid;
621 spec->multiout.hp_nid = preset->hp_nid;
623 spec->num_mux_defs = preset->num_mux_defs;
624 if (!spec->num_mux_defs)
625 spec->num_mux_defs = 1;
626 spec->input_mux = preset->input_mux;
628 spec->num_adc_nids = preset->num_adc_nids;
629 spec->adc_nids = preset->adc_nids;
630 spec->dig_in_nid = preset->dig_in_nid;
632 spec->unsol_event = preset->unsol_event;
633 spec->init_hook = preset->init_hook;
634 #ifdef CONFIG_SND_HDA_POWER_SAVE
635 spec->loopback.amplist = preset->loopbacks;
639 /* Enable GPIO mask and set output */
640 static struct hda_verb alc_gpio1_init_verbs[] = {
641 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
642 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
643 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
647 static struct hda_verb alc_gpio2_init_verbs[] = {
648 {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
649 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
650 {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
654 static struct hda_verb alc_gpio3_init_verbs[] = {
655 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
656 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
657 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
661 /* 32-bit subsystem ID for BIOS loading in HD Audio codec.
662 * 31 ~ 16 : Manufacture ID
664 * 7 ~ 0 : Assembly ID
665 * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36
667 static void alc_subsystem_id(struct hda_codec *codec,
668 unsigned int porta, unsigned int porte,
671 unsigned int ass, tmp;
673 ass = codec->subsystem_id;
678 tmp = (ass & 0x38) >> 3; /* external Amp control */
681 snd_hda_sequence_write(codec, alc_gpio1_init_verbs);
684 snd_hda_sequence_write(codec, alc_gpio2_init_verbs);
687 snd_hda_sequence_write(codec, alc_gpio3_init_verbs);
690 switch (codec->vendor_id) {
696 snd_hda_codec_write(codec, 0x14, 0,
697 AC_VERB_SET_EAPD_BTLENABLE, 2);
698 snd_hda_codec_write(codec, 0x15, 0,
699 AC_VERB_SET_EAPD_BTLENABLE, 2);
703 if (ass & 4) { /* bit 2 : 0 = Desktop, 1 = Laptop */
705 tmp = (ass & 0x1800) >> 11;
707 case 0: port = porta; break;
708 case 1: port = porte; break;
709 case 2: port = portd; break;
712 snd_hda_codec_write(codec, port, 0,
713 AC_VERB_SET_EAPD_BTLENABLE,
716 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
717 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF,
718 (tmp == 5 ? 0x3040 : 0x3050));
724 * Fix-up pin default configurations
732 static void alc_fix_pincfg(struct hda_codec *codec,
733 const struct snd_pci_quirk *quirk,
734 const struct alc_pincfg **pinfix)
736 const struct alc_pincfg *cfg;
738 quirk = snd_pci_quirk_lookup(codec->bus->pci, quirk);
742 cfg = pinfix[quirk->value];
743 for (; cfg->nid; cfg++) {
746 for (i = 0; i < 4; i++) {
747 snd_hda_codec_write(codec, cfg->nid, 0,
748 AC_VERB_SET_CONFIG_DEFAULT_BYTES_0 + i,
756 * ALC880 3-stack model
758 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
759 * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18,
760 * F-Mic = 0x1b, HP = 0x19
763 static hda_nid_t alc880_dac_nids[4] = {
764 /* front, rear, clfe, rear_surr */
765 0x02, 0x05, 0x04, 0x03
768 static hda_nid_t alc880_adc_nids[3] = {
773 /* The datasheet says the node 0x07 is connected from inputs,
774 * but it shows zero connection in the real implementation on some devices.
775 * Note: this is a 915GAV bug, fixed on 915GLV
777 static hda_nid_t alc880_adc_nids_alt[2] = {
782 #define ALC880_DIGOUT_NID 0x06
783 #define ALC880_DIGIN_NID 0x0a
785 static struct hda_input_mux alc880_capture_source = {
789 { "Front Mic", 0x3 },
795 /* channel source setting (2/6 channel selection for 3-stack) */
797 static struct hda_verb alc880_threestack_ch2_init[] = {
798 /* set line-in to input, mute it */
799 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
800 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
801 /* set mic-in to input vref 80%, mute it */
802 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
803 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
808 static struct hda_verb alc880_threestack_ch6_init[] = {
809 /* set line-in to output, unmute it */
810 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
811 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
812 /* set mic-in to output, unmute it */
813 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
814 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
818 static struct hda_channel_mode alc880_threestack_modes[2] = {
819 { 2, alc880_threestack_ch2_init },
820 { 6, alc880_threestack_ch6_init },
823 static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
824 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
825 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
826 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
827 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
828 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
829 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
830 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
831 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
832 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
833 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
834 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
835 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
836 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
837 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
838 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
839 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
840 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
841 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
842 HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
844 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
845 .name = "Channel Mode",
846 .info = alc_ch_mode_info,
847 .get = alc_ch_mode_get,
848 .put = alc_ch_mode_put,
853 /* capture mixer elements */
854 static struct snd_kcontrol_new alc880_capture_mixer[] = {
855 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
856 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
857 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
858 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
859 HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
860 HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
862 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
863 /* The multiple "Capture Source" controls confuse alsamixer
864 * So call somewhat different..
865 * FIXME: the controls appear in the "playback" view!
867 /* .name = "Capture Source", */
868 .name = "Input Source",
870 .info = alc_mux_enum_info,
871 .get = alc_mux_enum_get,
872 .put = alc_mux_enum_put,
877 /* capture mixer elements (in case NID 0x07 not available) */
878 static struct snd_kcontrol_new alc880_capture_alt_mixer[] = {
879 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
880 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
881 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
882 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
884 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
885 /* The multiple "Capture Source" controls confuse alsamixer
886 * So call somewhat different..
887 * FIXME: the controls appear in the "playback" view!
889 /* .name = "Capture Source", */
890 .name = "Input Source",
892 .info = alc_mux_enum_info,
893 .get = alc_mux_enum_get,
894 .put = alc_mux_enum_put,
902 * ALC880 5-stack model
904 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d),
906 * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
907 * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
910 /* additional mixers to alc880_three_stack_mixer */
911 static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
912 HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
913 HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
917 /* channel source setting (6/8 channel selection for 5-stack) */
919 static struct hda_verb alc880_fivestack_ch6_init[] = {
920 /* set line-in to input, mute it */
921 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
922 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
927 static struct hda_verb alc880_fivestack_ch8_init[] = {
928 /* set line-in to output, unmute it */
929 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
930 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
934 static struct hda_channel_mode alc880_fivestack_modes[2] = {
935 { 6, alc880_fivestack_ch6_init },
936 { 8, alc880_fivestack_ch8_init },
941 * ALC880 6-stack model
943 * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e),
945 * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
946 * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
949 static hda_nid_t alc880_6st_dac_nids[4] = {
950 /* front, rear, clfe, rear_surr */
951 0x02, 0x03, 0x04, 0x05
954 static struct hda_input_mux alc880_6stack_capture_source = {
958 { "Front Mic", 0x1 },
964 /* fixed 8-channels */
965 static struct hda_channel_mode alc880_sixstack_modes[1] = {
969 static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
970 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
971 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
972 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
973 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
974 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
975 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
976 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
977 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
978 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
979 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
980 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
981 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
982 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
983 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
984 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
985 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
986 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
987 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
988 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
989 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
991 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
992 .name = "Channel Mode",
993 .info = alc_ch_mode_info,
994 .get = alc_ch_mode_get,
995 .put = alc_ch_mode_put,
1004 * W810 has rear IO for:
1007 * Center/LFE (DAC 04)
1010 * The system also has a pair of internal speakers, and a headphone jack.
1011 * These are both connected to Line2 on the codec, hence to DAC 02.
1013 * There is a variable resistor to control the speaker or headphone
1014 * volume. This is a hardware-only device without a software API.
1016 * Plugging headphones in will disable the internal speakers. This is
1017 * implemented in hardware, not via the driver using jack sense. In
1018 * a similar fashion, plugging into the rear socket marked "front" will
1019 * disable both the speakers and headphones.
1021 * For input, there's a microphone jack, and an "audio in" jack.
1022 * These may not do anything useful with this driver yet, because I
1023 * haven't setup any initialization verbs for these yet...
1026 static hda_nid_t alc880_w810_dac_nids[3] = {
1027 /* front, rear/surround, clfe */
1031 /* fixed 6 channels */
1032 static struct hda_channel_mode alc880_w810_modes[1] = {
1036 /* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
1037 static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
1038 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1039 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1040 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1041 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
1042 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1043 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1044 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1045 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1046 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
1054 * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
1055 * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?),
1059 static hda_nid_t alc880_z71v_dac_nids[1] = {
1062 #define ALC880_Z71V_HP_DAC 0x03
1064 /* fixed 2 channels */
1065 static struct hda_channel_mode alc880_2_jack_modes[1] = {
1069 static struct snd_kcontrol_new alc880_z71v_mixer[] = {
1070 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1071 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1072 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1073 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
1074 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1075 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1076 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1077 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1084 * ALC880 F1734 model
1086 * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
1087 * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
1090 static hda_nid_t alc880_f1734_dac_nids[1] = {
1093 #define ALC880_F1734_HP_DAC 0x02
1095 static struct snd_kcontrol_new alc880_f1734_mixer[] = {
1096 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1097 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
1098 HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1099 HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
1100 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1101 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1102 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1103 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1112 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
1113 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
1114 * Mic = 0x18, Line = 0x1a
1117 #define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
1118 #define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
1120 static struct snd_kcontrol_new alc880_asus_mixer[] = {
1121 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1122 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1123 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1124 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
1125 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1126 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1127 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1128 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 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),
1136 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1137 .name = "Channel Mode",
1138 .info = alc_ch_mode_info,
1139 .get = alc_ch_mode_get,
1140 .put = alc_ch_mode_put,
1147 * ALC880 ASUS W1V model
1149 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
1150 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
1151 * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
1154 /* additional mixers to alc880_asus_mixer */
1155 static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
1156 HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
1157 HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
1161 /* additional mixers to alc880_asus_mixer */
1162 static struct snd_kcontrol_new alc880_pcbeep_mixer[] = {
1163 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1164 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
1169 static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
1170 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1171 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
1172 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
1173 HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
1174 HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
1175 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
1176 HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
1177 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
1178 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
1180 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1181 /* The multiple "Capture Source" controls confuse alsamixer
1182 * So call somewhat different..
1183 * FIXME: the controls appear in the "playback" view!
1185 /* .name = "Capture Source", */
1186 .name = "Input Source",
1188 .info = alc_mux_enum_info,
1189 .get = alc_mux_enum_get,
1190 .put = alc_mux_enum_put,
1196 static struct snd_kcontrol_new alc880_uniwill_mixer[] = {
1197 HDA_CODEC_VOLUME("HPhone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1198 HDA_BIND_MUTE("HPhone Playback Switch", 0x0c, 2, HDA_INPUT),
1199 HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1200 HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT),
1201 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1202 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1203 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1204 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1205 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1206 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1207 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1208 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1209 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1210 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1211 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1212 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1213 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1214 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
1216 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1217 .name = "Channel Mode",
1218 .info = alc_ch_mode_info,
1219 .get = alc_ch_mode_get,
1220 .put = alc_ch_mode_put,
1225 static struct snd_kcontrol_new alc880_fujitsu_mixer[] = {
1226 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1227 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
1228 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1229 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
1230 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1231 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1232 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1233 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1234 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1235 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1239 static struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = {
1240 HDA_CODEC_VOLUME("HPhone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1241 HDA_BIND_MUTE("HPhone Playback Switch", 0x0c, 2, HDA_INPUT),
1242 HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1243 HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT),
1244 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1245 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1250 * build control elements
1252 static int alc_build_controls(struct hda_codec *codec)
1254 struct alc_spec *spec = codec->spec;
1258 for (i = 0; i < spec->num_mixers; i++) {
1259 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
1264 if (spec->multiout.dig_out_nid) {
1265 err = snd_hda_create_spdif_out_ctls(codec,
1266 spec->multiout.dig_out_nid);
1270 if (spec->dig_in_nid) {
1271 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
1280 * initialize the codec volumes, etc
1284 * generic initialization of ADC, input mixers and output mixers
1286 static struct hda_verb alc880_volume_init_verbs[] = {
1288 * Unmute ADC0-2 and set the default input to mic-in
1290 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
1291 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1292 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
1293 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1294 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
1295 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1297 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
1299 * Note: PASD motherboards uses the Line In 2 as the input for front
1302 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
1303 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1304 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1305 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
1306 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
1307 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
1308 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
1309 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
1312 * Set up output mixers (0x0c - 0x0f)
1314 /* set vol=0 to output mixers */
1315 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1316 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1317 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1318 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1319 /* set up input amps for analog loopback */
1320 /* Amp Indices: DAC = 0, mixer = 1 */
1321 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1322 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1323 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1324 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1325 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1326 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1327 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1328 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1334 * 3-stack pin configuration:
1335 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
1337 static struct hda_verb alc880_pin_3stack_init_verbs[] = {
1339 * preset connection lists of input pins
1340 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
1342 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
1343 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1344 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
1347 * Set pin mode and muting
1349 /* set front pin widgets 0x14 for output */
1350 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1351 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1352 /* Mic1 (rear panel) pin widget for input and vref at 80% */
1353 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1354 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1355 /* Mic2 (as headphone out) for HP output */
1356 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1357 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1358 /* Line In pin widget for input */
1359 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1360 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1361 /* Line2 (as front mic) pin widget for input and vref at 80% */
1362 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1363 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1364 /* CD pin widget for input */
1365 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1371 * 5-stack pin configuration:
1372 * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
1373 * line-in/side = 0x1a, f-mic = 0x1b
1375 static struct hda_verb alc880_pin_5stack_init_verbs[] = {
1377 * preset connection lists of input pins
1378 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
1380 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1381 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
1384 * Set pin mode and muting
1386 /* set pin widgets 0x14-0x17 for output */
1387 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1388 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1389 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1390 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1391 /* unmute pins for output (no gain on this amp) */
1392 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1393 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1394 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1395 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1397 /* Mic1 (rear panel) pin widget for input and vref at 80% */
1398 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1399 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1400 /* Mic2 (as headphone out) for HP output */
1401 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1402 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1403 /* Line In pin widget for input */
1404 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1405 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1406 /* Line2 (as front mic) pin widget for input and vref at 80% */
1407 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1408 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1409 /* CD pin widget for input */
1410 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1416 * W810 pin configuration:
1417 * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
1419 static struct hda_verb alc880_pin_w810_init_verbs[] = {
1420 /* hphone/speaker input selector: front DAC */
1421 {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
1423 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1424 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1425 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1426 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1427 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1428 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1430 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1431 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1437 * Z71V pin configuration:
1438 * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
1440 static struct hda_verb alc880_pin_z71v_init_verbs[] = {
1441 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1442 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1443 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1444 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1446 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1447 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1448 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1449 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1455 * 6-stack pin configuration:
1456 * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18,
1457 * f-mic = 0x19, line = 0x1a, HP = 0x1b
1459 static struct hda_verb alc880_pin_6stack_init_verbs[] = {
1460 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1462 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1463 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1464 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1465 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1466 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1467 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1468 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1469 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1471 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1472 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1473 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1474 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1475 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1476 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1477 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1478 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1479 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1485 * Uniwill pin configuration:
1486 * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19,
1489 static struct hda_verb alc880_uniwill_init_verbs[] = {
1490 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1492 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1493 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1494 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1495 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1496 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1497 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1498 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1499 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1500 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1501 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1502 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1503 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1504 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1505 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1507 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1508 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1509 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1510 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1511 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1512 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1513 /* {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, */
1514 /* {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
1515 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1517 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
1518 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
1525 * HP = 0x14, InternalSpeaker = 0x15, mic = 0x19,
1527 static struct hda_verb alc880_uniwill_p53_init_verbs[] = {
1528 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1530 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1531 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1532 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1533 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1534 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1535 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1536 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1537 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1538 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1539 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1540 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1541 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1543 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1544 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1545 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1546 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1547 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1548 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1550 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
1551 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_DCVOL_EVENT},
1556 static struct hda_verb alc880_beep_init_verbs[] = {
1557 { 0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5) },
1561 /* toggle speaker-output according to the hp-jack state */
1562 static void alc880_uniwill_hp_automute(struct hda_codec *codec)
1564 unsigned int present;
1567 present = snd_hda_codec_read(codec, 0x14, 0,
1568 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1569 bits = present ? HDA_AMP_MUTE : 0;
1570 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
1571 HDA_AMP_MUTE, bits);
1572 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
1573 HDA_AMP_MUTE, bits);
1576 /* auto-toggle front mic */
1577 static void alc880_uniwill_mic_automute(struct hda_codec *codec)
1579 unsigned int present;
1582 present = snd_hda_codec_read(codec, 0x18, 0,
1583 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1584 bits = present ? HDA_AMP_MUTE : 0;
1585 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
1588 static void alc880_uniwill_automute(struct hda_codec *codec)
1590 alc880_uniwill_hp_automute(codec);
1591 alc880_uniwill_mic_automute(codec);
1594 static void alc880_uniwill_unsol_event(struct hda_codec *codec,
1597 /* Looks like the unsol event is incompatible with the standard
1598 * definition. 4bit tag is placed at 28 bit!
1600 switch (res >> 28) {
1601 case ALC880_HP_EVENT:
1602 alc880_uniwill_hp_automute(codec);
1604 case ALC880_MIC_EVENT:
1605 alc880_uniwill_mic_automute(codec);
1610 static void alc880_uniwill_p53_hp_automute(struct hda_codec *codec)
1612 unsigned int present;
1615 present = snd_hda_codec_read(codec, 0x14, 0,
1616 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1617 bits = present ? HDA_AMP_MUTE : 0;
1618 snd_hda_codec_amp_stereo(codec, 0x15, HDA_INPUT, 0, HDA_AMP_MUTE, bits);
1621 static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec)
1623 unsigned int present;
1625 present = snd_hda_codec_read(codec, 0x21, 0,
1626 AC_VERB_GET_VOLUME_KNOB_CONTROL, 0);
1627 present &= HDA_AMP_VOLMASK;
1628 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0,
1629 HDA_AMP_VOLMASK, present);
1630 snd_hda_codec_amp_stereo(codec, 0x0d, HDA_OUTPUT, 0,
1631 HDA_AMP_VOLMASK, present);
1634 static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec,
1637 /* Looks like the unsol event is incompatible with the standard
1638 * definition. 4bit tag is placed at 28 bit!
1640 if ((res >> 28) == ALC880_HP_EVENT)
1641 alc880_uniwill_p53_hp_automute(codec);
1642 if ((res >> 28) == ALC880_DCVOL_EVENT)
1643 alc880_uniwill_p53_dcvol_automute(codec);
1648 * F1734 pin configuration:
1649 * HP = 0x14, speaker-out = 0x15, mic = 0x18
1651 static struct hda_verb alc880_pin_f1734_init_verbs[] = {
1652 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
1653 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
1654 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
1655 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
1657 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1658 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1659 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1660 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1662 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1663 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1664 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1665 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1666 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1667 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1668 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1669 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1670 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1677 * ASUS pin configuration:
1678 * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
1680 static struct hda_verb alc880_pin_asus_init_verbs[] = {
1681 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
1682 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
1683 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
1684 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
1686 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1687 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1688 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1689 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1690 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1691 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1692 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1693 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1695 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1696 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1697 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1698 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1699 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1700 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1701 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1702 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1703 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1708 /* Enable GPIO mask and set output */
1709 #define alc880_gpio1_init_verbs alc_gpio1_init_verbs
1710 #define alc880_gpio2_init_verbs alc_gpio2_init_verbs
1712 /* Clevo m520g init */
1713 static struct hda_verb alc880_pin_clevo_init_verbs[] = {
1714 /* headphone output */
1715 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
1717 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1718 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1720 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1721 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1723 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1724 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1725 /* Mic1 (rear panel) */
1726 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1727 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1728 /* Mic2 (front panel) */
1729 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1730 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1732 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1733 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1734 /* change to EAPD mode */
1735 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
1736 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
1741 static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
1742 /* change to EAPD mode */
1743 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
1744 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
1746 /* Headphone output */
1747 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1749 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1750 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
1752 /* Line In pin widget for input */
1753 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1754 /* CD pin widget for input */
1755 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1756 /* Mic1 (rear panel) pin widget for input and vref at 80% */
1757 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1759 /* change to EAPD mode */
1760 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
1761 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
1767 * LG m1 express dual
1770 * Rear Line-In/Out (blue): 0x14
1771 * Build-in Mic-In: 0x15
1773 * HP-Out (green): 0x1b
1774 * Mic-In/Out (red): 0x19
1778 /* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
1779 static hda_nid_t alc880_lg_dac_nids[3] = {
1783 /* seems analog CD is not working */
1784 static struct hda_input_mux alc880_lg_capture_source = {
1789 { "Internal Mic", 0x6 },
1793 /* 2,4,6 channel modes */
1794 static struct hda_verb alc880_lg_ch2_init[] = {
1795 /* set line-in and mic-in to input */
1796 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1797 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1801 static struct hda_verb alc880_lg_ch4_init[] = {
1802 /* set line-in to out and mic-in to input */
1803 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
1804 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1808 static struct hda_verb alc880_lg_ch6_init[] = {
1809 /* set line-in and mic-in to output */
1810 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
1811 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
1815 static struct hda_channel_mode alc880_lg_ch_modes[3] = {
1816 { 2, alc880_lg_ch2_init },
1817 { 4, alc880_lg_ch4_init },
1818 { 6, alc880_lg_ch6_init },
1821 static struct snd_kcontrol_new alc880_lg_mixer[] = {
1822 /* FIXME: it's not really "master" but front channels */
1823 HDA_CODEC_VOLUME("Master Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
1824 HDA_BIND_MUTE("Master Playback Switch", 0x0f, 2, HDA_INPUT),
1825 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1826 HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
1827 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
1828 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
1829 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
1830 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
1831 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1832 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1833 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
1834 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
1835 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
1836 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
1838 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1839 .name = "Channel Mode",
1840 .info = alc_ch_mode_info,
1841 .get = alc_ch_mode_get,
1842 .put = alc_ch_mode_put,
1847 static struct hda_verb alc880_lg_init_verbs[] = {
1848 /* set capture source to mic-in */
1849 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1850 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1851 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1852 /* mute all amp mixer inputs */
1853 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
1854 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
1855 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
1856 /* line-in to input */
1857 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1858 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1860 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1861 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1863 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1864 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1865 /* mic-in to input */
1866 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
1867 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1868 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1870 {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
1871 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1872 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1874 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
1878 /* toggle speaker-output according to the hp-jack state */
1879 static void alc880_lg_automute(struct hda_codec *codec)
1881 unsigned int present;
1884 present = snd_hda_codec_read(codec, 0x1b, 0,
1885 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1886 bits = present ? HDA_AMP_MUTE : 0;
1887 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
1888 HDA_AMP_MUTE, bits);
1891 static void alc880_lg_unsol_event(struct hda_codec *codec, unsigned int res)
1893 /* Looks like the unsol event is incompatible with the standard
1894 * definition. 4bit tag is placed at 28 bit!
1896 if ((res >> 28) == 0x01)
1897 alc880_lg_automute(codec);
1906 * Built-in Mic-In: 0x19
1912 static struct hda_input_mux alc880_lg_lw_capture_source = {
1916 { "Internal Mic", 0x1 },
1921 #define alc880_lg_lw_modes alc880_threestack_modes
1923 static struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
1924 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1925 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1926 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
1927 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
1928 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1929 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1930 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1931 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1932 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1933 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1934 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1935 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1936 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
1937 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
1939 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1940 .name = "Channel Mode",
1941 .info = alc_ch_mode_info,
1942 .get = alc_ch_mode_get,
1943 .put = alc_ch_mode_put,
1948 static struct hda_verb alc880_lg_lw_init_verbs[] = {
1949 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1950 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
1951 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
1953 /* set capture source to mic-in */
1954 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1955 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1956 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1957 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
1959 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1960 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1962 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1963 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1964 /* mic-in to input */
1965 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1966 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1968 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1969 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1971 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
1975 /* toggle speaker-output according to the hp-jack state */
1976 static void alc880_lg_lw_automute(struct hda_codec *codec)
1978 unsigned int present;
1981 present = snd_hda_codec_read(codec, 0x1b, 0,
1982 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1983 bits = present ? HDA_AMP_MUTE : 0;
1984 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
1985 HDA_AMP_MUTE, bits);
1988 static void alc880_lg_lw_unsol_event(struct hda_codec *codec, unsigned int res)
1990 /* Looks like the unsol event is incompatible with the standard
1991 * definition. 4bit tag is placed at 28 bit!
1993 if ((res >> 28) == 0x01)
1994 alc880_lg_lw_automute(codec);
1997 #ifdef CONFIG_SND_HDA_POWER_SAVE
1998 static struct hda_amp_list alc880_loopbacks[] = {
1999 { 0x0b, HDA_INPUT, 0 },
2000 { 0x0b, HDA_INPUT, 1 },
2001 { 0x0b, HDA_INPUT, 2 },
2002 { 0x0b, HDA_INPUT, 3 },
2003 { 0x0b, HDA_INPUT, 4 },
2007 static struct hda_amp_list alc880_lg_loopbacks[] = {
2008 { 0x0b, HDA_INPUT, 1 },
2009 { 0x0b, HDA_INPUT, 6 },
2010 { 0x0b, HDA_INPUT, 7 },
2019 static int alc_init(struct hda_codec *codec)
2021 struct alc_spec *spec = codec->spec;
2024 for (i = 0; i < spec->num_init_verbs; i++)
2025 snd_hda_sequence_write(codec, spec->init_verbs[i]);
2027 if (spec->init_hook)
2028 spec->init_hook(codec);
2033 static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
2035 struct alc_spec *spec = codec->spec;
2037 if (spec->unsol_event)
2038 spec->unsol_event(codec, res);
2041 #ifdef CONFIG_SND_HDA_POWER_SAVE
2042 static int alc_check_power_status(struct hda_codec *codec, hda_nid_t nid)
2044 struct alc_spec *spec = codec->spec;
2045 return snd_hda_check_amp_list_power(codec, &spec->loopback, nid);
2050 * Analog playback callbacks
2052 static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
2053 struct hda_codec *codec,
2054 struct snd_pcm_substream *substream)
2056 struct alc_spec *spec = codec->spec;
2057 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream);
2060 static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2061 struct hda_codec *codec,
2062 unsigned int stream_tag,
2063 unsigned int format,
2064 struct snd_pcm_substream *substream)
2066 struct alc_spec *spec = codec->spec;
2067 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
2068 stream_tag, format, substream);
2071 static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
2072 struct hda_codec *codec,
2073 struct snd_pcm_substream *substream)
2075 struct alc_spec *spec = codec->spec;
2076 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
2082 static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
2083 struct hda_codec *codec,
2084 struct snd_pcm_substream *substream)
2086 struct alc_spec *spec = codec->spec;
2087 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
2090 static int alc880_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2091 struct hda_codec *codec,
2092 unsigned int stream_tag,
2093 unsigned int format,
2094 struct snd_pcm_substream *substream)
2096 struct alc_spec *spec = codec->spec;
2097 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
2098 stream_tag, format, substream);
2101 static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
2102 struct hda_codec *codec,
2103 struct snd_pcm_substream *substream)
2105 struct alc_spec *spec = codec->spec;
2106 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
2112 static int alc880_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
2113 struct hda_codec *codec,
2114 unsigned int stream_tag,
2115 unsigned int format,
2116 struct snd_pcm_substream *substream)
2118 struct alc_spec *spec = codec->spec;
2120 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
2121 stream_tag, 0, format);
2125 static int alc880_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
2126 struct hda_codec *codec,
2127 struct snd_pcm_substream *substream)
2129 struct alc_spec *spec = codec->spec;
2131 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
2139 static struct hda_pcm_stream alc880_pcm_analog_playback = {
2143 /* NID is set in alc_build_pcms */
2145 .open = alc880_playback_pcm_open,
2146 .prepare = alc880_playback_pcm_prepare,
2147 .cleanup = alc880_playback_pcm_cleanup
2151 static struct hda_pcm_stream alc880_pcm_analog_capture = {
2155 /* NID is set in alc_build_pcms */
2157 .prepare = alc880_capture_pcm_prepare,
2158 .cleanup = alc880_capture_pcm_cleanup
2162 static struct hda_pcm_stream alc880_pcm_digital_playback = {
2166 /* NID is set in alc_build_pcms */
2168 .open = alc880_dig_playback_pcm_open,
2169 .close = alc880_dig_playback_pcm_close,
2170 .prepare = alc880_dig_playback_pcm_prepare
2174 static struct hda_pcm_stream alc880_pcm_digital_capture = {
2178 /* NID is set in alc_build_pcms */
2181 /* Used by alc_build_pcms to flag that a PCM has no playback stream */
2182 static struct hda_pcm_stream alc_pcm_null_playback = {
2188 static int alc_build_pcms(struct hda_codec *codec)
2190 struct alc_spec *spec = codec->spec;
2191 struct hda_pcm *info = spec->pcm_rec;
2194 codec->num_pcms = 1;
2195 codec->pcm_info = info;
2197 info->name = spec->stream_name_analog;
2198 if (spec->stream_analog_playback) {
2199 snd_assert(spec->multiout.dac_nids, return -EINVAL);
2200 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
2201 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
2203 if (spec->stream_analog_capture) {
2204 snd_assert(spec->adc_nids, return -EINVAL);
2205 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
2206 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
2209 if (spec->channel_mode) {
2210 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
2211 for (i = 0; i < spec->num_channel_mode; i++) {
2212 if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
2213 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
2218 /* SPDIF for stream index #1 */
2219 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
2220 codec->num_pcms = 2;
2221 info = spec->pcm_rec + 1;
2222 info->name = spec->stream_name_digital;
2223 if (spec->multiout.dig_out_nid &&
2224 spec->stream_digital_playback) {
2225 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
2226 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
2228 if (spec->dig_in_nid &&
2229 spec->stream_digital_capture) {
2230 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
2231 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
2235 /* If the use of more than one ADC is requested for the current
2236 * model, configure a second analog capture-only PCM.
2238 /* Additional Analaog capture for index #2 */
2239 if (spec->num_adc_nids > 1 && spec->stream_analog_capture &&
2241 codec->num_pcms = 3;
2242 info = spec->pcm_rec + 2;
2243 info->name = spec->stream_name_analog;
2244 /* No playback stream for second PCM */
2245 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = alc_pcm_null_playback;
2246 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
2247 if (spec->stream_analog_capture) {
2248 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
2249 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[1];
2256 static void alc_free(struct hda_codec *codec)
2258 struct alc_spec *spec = codec->spec;
2264 if (spec->kctl_alloc) {
2265 for (i = 0; i < spec->num_kctl_used; i++)
2266 kfree(spec->kctl_alloc[i].name);
2267 kfree(spec->kctl_alloc);
2274 static struct hda_codec_ops alc_patch_ops = {
2275 .build_controls = alc_build_controls,
2276 .build_pcms = alc_build_pcms,
2279 .unsol_event = alc_unsol_event,
2280 #ifdef CONFIG_SND_HDA_POWER_SAVE
2281 .check_power_status = alc_check_power_status,
2287 * Test configuration for debugging
2289 * Almost all inputs/outputs are enabled. I/O pins can be configured via
2292 #ifdef CONFIG_SND_DEBUG
2293 static hda_nid_t alc880_test_dac_nids[4] = {
2294 0x02, 0x03, 0x04, 0x05
2297 static struct hda_input_mux alc880_test_capture_source = {
2306 { "Surround", 0x6 },
2310 static struct hda_channel_mode alc880_test_modes[4] = {
2317 static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol,
2318 struct snd_ctl_elem_info *uinfo)
2320 static char *texts[] = {
2321 "N/A", "Line Out", "HP Out",
2322 "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
2324 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
2326 uinfo->value.enumerated.items = 8;
2327 if (uinfo->value.enumerated.item >= 8)
2328 uinfo->value.enumerated.item = 7;
2329 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
2333 static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol,
2334 struct snd_ctl_elem_value *ucontrol)
2336 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2337 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2338 unsigned int pin_ctl, item = 0;
2340 pin_ctl = snd_hda_codec_read(codec, nid, 0,
2341 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
2342 if (pin_ctl & AC_PINCTL_OUT_EN) {
2343 if (pin_ctl & AC_PINCTL_HP_EN)
2347 } else if (pin_ctl & AC_PINCTL_IN_EN) {
2348 switch (pin_ctl & AC_PINCTL_VREFEN) {
2349 case AC_PINCTL_VREF_HIZ: item = 3; break;
2350 case AC_PINCTL_VREF_50: item = 4; break;
2351 case AC_PINCTL_VREF_GRD: item = 5; break;
2352 case AC_PINCTL_VREF_80: item = 6; break;
2353 case AC_PINCTL_VREF_100: item = 7; break;
2356 ucontrol->value.enumerated.item[0] = item;
2360 static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol,
2361 struct snd_ctl_elem_value *ucontrol)
2363 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2364 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2365 static unsigned int ctls[] = {
2366 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
2367 AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
2368 AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
2369 AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
2370 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
2371 AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
2373 unsigned int old_ctl, new_ctl;
2375 old_ctl = snd_hda_codec_read(codec, nid, 0,
2376 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
2377 new_ctl = ctls[ucontrol->value.enumerated.item[0]];
2378 if (old_ctl != new_ctl) {
2380 snd_hda_codec_write_cache(codec, nid, 0,
2381 AC_VERB_SET_PIN_WIDGET_CONTROL,
2383 val = ucontrol->value.enumerated.item[0] >= 3 ?
2385 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
2392 static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol,
2393 struct snd_ctl_elem_info *uinfo)
2395 static char *texts[] = {
2396 "Front", "Surround", "CLFE", "Side"
2398 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
2400 uinfo->value.enumerated.items = 4;
2401 if (uinfo->value.enumerated.item >= 4)
2402 uinfo->value.enumerated.item = 3;
2403 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
2407 static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol,
2408 struct snd_ctl_elem_value *ucontrol)
2410 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2411 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2414 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
2415 ucontrol->value.enumerated.item[0] = sel & 3;
2419 static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol,
2420 struct snd_ctl_elem_value *ucontrol)
2422 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2423 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2426 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
2427 if (ucontrol->value.enumerated.item[0] != sel) {
2428 sel = ucontrol->value.enumerated.item[0] & 3;
2429 snd_hda_codec_write_cache(codec, nid, 0,
2430 AC_VERB_SET_CONNECT_SEL, sel);
2436 #define PIN_CTL_TEST(xname,nid) { \
2437 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2439 .info = alc_test_pin_ctl_info, \
2440 .get = alc_test_pin_ctl_get, \
2441 .put = alc_test_pin_ctl_put, \
2442 .private_value = nid \
2445 #define PIN_SRC_TEST(xname,nid) { \
2446 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2448 .info = alc_test_pin_src_info, \
2449 .get = alc_test_pin_src_get, \
2450 .put = alc_test_pin_src_put, \
2451 .private_value = nid \
2454 static struct snd_kcontrol_new alc880_test_mixer[] = {
2455 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2456 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2457 HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
2458 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
2459 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2460 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
2461 HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
2462 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
2463 PIN_CTL_TEST("Front Pin Mode", 0x14),
2464 PIN_CTL_TEST("Surround Pin Mode", 0x15),
2465 PIN_CTL_TEST("CLFE Pin Mode", 0x16),
2466 PIN_CTL_TEST("Side Pin Mode", 0x17),
2467 PIN_CTL_TEST("In-1 Pin Mode", 0x18),
2468 PIN_CTL_TEST("In-2 Pin Mode", 0x19),
2469 PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
2470 PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
2471 PIN_SRC_TEST("In-1 Pin Source", 0x18),
2472 PIN_SRC_TEST("In-2 Pin Source", 0x19),
2473 PIN_SRC_TEST("In-3 Pin Source", 0x1a),
2474 PIN_SRC_TEST("In-4 Pin Source", 0x1b),
2475 HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
2476 HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
2477 HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
2478 HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
2479 HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
2480 HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
2481 HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
2482 HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
2483 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
2484 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
2486 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2487 .name = "Channel Mode",
2488 .info = alc_ch_mode_info,
2489 .get = alc_ch_mode_get,
2490 .put = alc_ch_mode_put,
2495 static struct hda_verb alc880_test_init_verbs[] = {
2496 /* Unmute inputs of 0x0c - 0x0f */
2497 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2498 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2499 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2500 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2501 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2502 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2503 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2504 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2505 /* Vol output for 0x0c-0x0f */
2506 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2507 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2508 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2509 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2510 /* Set output pins 0x14-0x17 */
2511 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2512 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2513 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2514 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2515 /* Unmute output pins 0x14-0x17 */
2516 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2517 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2518 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2519 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2520 /* Set input pins 0x18-0x1c */
2521 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2522 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2523 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2524 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2525 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2526 /* Mute input pins 0x18-0x1b */
2527 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2528 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2529 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2530 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2532 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2533 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
2534 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2535 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
2536 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2537 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
2538 /* Analog input/passthru */
2539 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2540 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2541 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
2542 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
2543 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
2551 static const char *alc880_models[ALC880_MODEL_LAST] = {
2552 [ALC880_3ST] = "3stack",
2553 [ALC880_TCL_S700] = "tcl",
2554 [ALC880_3ST_DIG] = "3stack-digout",
2555 [ALC880_CLEVO] = "clevo",
2556 [ALC880_5ST] = "5stack",
2557 [ALC880_5ST_DIG] = "5stack-digout",
2558 [ALC880_W810] = "w810",
2559 [ALC880_Z71V] = "z71v",
2560 [ALC880_6ST] = "6stack",
2561 [ALC880_6ST_DIG] = "6stack-digout",
2562 [ALC880_ASUS] = "asus",
2563 [ALC880_ASUS_W1V] = "asus-w1v",
2564 [ALC880_ASUS_DIG] = "asus-dig",
2565 [ALC880_ASUS_DIG2] = "asus-dig2",
2566 [ALC880_UNIWILL_DIG] = "uniwill",
2567 [ALC880_UNIWILL_P53] = "uniwill-p53",
2568 [ALC880_FUJITSU] = "fujitsu",
2569 [ALC880_F1734] = "F1734",
2571 [ALC880_LG_LW] = "lg-lw",
2572 #ifdef CONFIG_SND_DEBUG
2573 [ALC880_TEST] = "test",
2575 [ALC880_AUTO] = "auto",
2578 static struct snd_pci_quirk alc880_cfg_tbl[] = {
2579 /* Broken BIOS configuration */
2580 SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_6ST_DIG),
2581 SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_6ST_DIG),
2583 SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_5ST_DIG),
2584 SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_6ST),
2585 SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_W810),
2586 SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_3ST_DIG),
2587 SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_6ST_DIG),
2588 SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_6ST_DIG),
2589 SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_6ST_DIG),
2590 SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_3ST_DIG),
2591 SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_3ST),
2593 SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_6ST_DIG),
2594 SND_PCI_QUIRK(0x103c, 0x2a09, "HP", ALC880_5ST),
2596 SND_PCI_QUIRK(0x1043, 0x10b3, "ASUS W1V", ALC880_ASUS_W1V),
2597 SND_PCI_QUIRK(0x1043, 0x10c2, "ASUS W6A", ALC880_ASUS_DIG),
2598 SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS Wxx", ALC880_ASUS_DIG),
2599 SND_PCI_QUIRK(0x1043, 0x1113, "ASUS", ALC880_ASUS_DIG),
2600 SND_PCI_QUIRK(0x1043, 0x1123, "ASUS", ALC880_ASUS_DIG),
2601 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS", ALC880_ASUS_DIG),
2602 SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_Z71V),
2603 /* SND_PCI_QUIRK(0x1043, 0x1964, "ASUS", ALC880_ASUS_DIG), */
2604 SND_PCI_QUIRK(0x1043, 0x1973, "ASUS", ALC880_ASUS_DIG),
2605 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS", ALC880_ASUS_DIG),
2606 SND_PCI_QUIRK(0x1043, 0x814e, "ASUS", ALC880_ASUS),
2607 SND_PCI_QUIRK(0x1043, 0x8181, "ASUS P4GPL", ALC880_ASUS_DIG),
2608 SND_PCI_QUIRK(0x1043, 0x8196, "ASUS P5GD1", ALC880_6ST),
2609 SND_PCI_QUIRK(0x1043, 0x81b4, "ASUS", ALC880_6ST),
2610 SND_PCI_QUIRK(0x1043, 0, "ASUS", ALC880_ASUS),
2612 SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_3ST),
2613 SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_3ST),
2614 SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_5ST),
2615 SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_5ST),
2616 SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_5ST),
2617 SND_PCI_QUIRK(0x1558, 0x0520, "Clevo m520G", ALC880_CLEVO),
2618 SND_PCI_QUIRK(0x1558, 0x0660, "Clevo m655n", ALC880_CLEVO),
2619 SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_5ST_DIG),
2620 SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_W810),
2621 SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_5ST_DIG),
2622 SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_TCL_S700),
2623 SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_5ST_DIG),
2624 SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_6ST_DIG),
2625 SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_6ST_DIG),
2626 SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_6ST_DIG),
2627 SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_6ST_DIG),
2628 SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_6ST_DIG),
2629 SND_PCI_QUIRK(0x1558, 0x5401, "ASUS", ALC880_ASUS_DIG2),
2631 SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_UNIWILL_DIG),
2632 SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_UNIWILL),
2633 SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_UNIWILL_P53),
2634 SND_PCI_QUIRK(0x1584, 0x9054, "Uniwlll", ALC880_F1734),
2636 SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_5ST_DIG),
2637 SND_PCI_QUIRK(0x1734, 0x10ac, "FSC", ALC880_UNIWILL),
2638 SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_F1734),
2639 SND_PCI_QUIRK(0x1734, 0x10b0, "Fujitsu", ALC880_FUJITSU),
2641 SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_LG),
2642 SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_LG),
2643 SND_PCI_QUIRK(0x1854, 0x0018, "LG LW20", ALC880_LG_LW),
2644 SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_LG_LW),
2646 SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_3ST_DIG),
2647 SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_3ST_DIG),
2648 SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_3ST_DIG),
2649 SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_5ST_DIG),
2650 SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_5ST_DIG),
2651 SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_5ST_DIG),
2652 SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_5ST_DIG),
2653 SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_5ST_DIG),
2654 SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_5ST_DIG),
2655 SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_5ST_DIG),
2656 SND_PCI_QUIRK(0x8086, 0, "Intel mobo", ALC880_3ST),
2662 * ALC880 codec presets
2664 static struct alc_config_preset alc880_presets[] = {
2666 .mixers = { alc880_three_stack_mixer },
2667 .init_verbs = { alc880_volume_init_verbs,
2668 alc880_pin_3stack_init_verbs },
2669 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2670 .dac_nids = alc880_dac_nids,
2671 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
2672 .channel_mode = alc880_threestack_modes,
2674 .input_mux = &alc880_capture_source,
2676 [ALC880_3ST_DIG] = {
2677 .mixers = { alc880_three_stack_mixer },
2678 .init_verbs = { alc880_volume_init_verbs,
2679 alc880_pin_3stack_init_verbs },
2680 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2681 .dac_nids = alc880_dac_nids,
2682 .dig_out_nid = ALC880_DIGOUT_NID,
2683 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
2684 .channel_mode = alc880_threestack_modes,
2686 .input_mux = &alc880_capture_source,
2688 [ALC880_TCL_S700] = {
2689 .mixers = { alc880_tcl_s700_mixer },
2690 .init_verbs = { alc880_volume_init_verbs,
2691 alc880_pin_tcl_S700_init_verbs,
2692 alc880_gpio2_init_verbs },
2693 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2694 .dac_nids = alc880_dac_nids,
2696 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
2697 .channel_mode = alc880_2_jack_modes,
2698 .input_mux = &alc880_capture_source,
2701 .mixers = { alc880_three_stack_mixer,
2702 alc880_five_stack_mixer},
2703 .init_verbs = { alc880_volume_init_verbs,
2704 alc880_pin_5stack_init_verbs },
2705 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2706 .dac_nids = alc880_dac_nids,
2707 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
2708 .channel_mode = alc880_fivestack_modes,
2709 .input_mux = &alc880_capture_source,
2711 [ALC880_5ST_DIG] = {
2712 .mixers = { alc880_three_stack_mixer,
2713 alc880_five_stack_mixer },
2714 .init_verbs = { alc880_volume_init_verbs,
2715 alc880_pin_5stack_init_verbs },
2716 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2717 .dac_nids = alc880_dac_nids,
2718 .dig_out_nid = ALC880_DIGOUT_NID,
2719 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
2720 .channel_mode = alc880_fivestack_modes,
2721 .input_mux = &alc880_capture_source,
2724 .mixers = { alc880_six_stack_mixer },
2725 .init_verbs = { alc880_volume_init_verbs,
2726 alc880_pin_6stack_init_verbs },
2727 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
2728 .dac_nids = alc880_6st_dac_nids,
2729 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
2730 .channel_mode = alc880_sixstack_modes,
2731 .input_mux = &alc880_6stack_capture_source,
2733 [ALC880_6ST_DIG] = {
2734 .mixers = { alc880_six_stack_mixer },
2735 .init_verbs = { alc880_volume_init_verbs,
2736 alc880_pin_6stack_init_verbs },
2737 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
2738 .dac_nids = alc880_6st_dac_nids,
2739 .dig_out_nid = ALC880_DIGOUT_NID,
2740 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
2741 .channel_mode = alc880_sixstack_modes,
2742 .input_mux = &alc880_6stack_capture_source,
2745 .mixers = { alc880_w810_base_mixer },
2746 .init_verbs = { alc880_volume_init_verbs,
2747 alc880_pin_w810_init_verbs,
2748 alc880_gpio2_init_verbs },
2749 .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
2750 .dac_nids = alc880_w810_dac_nids,
2751 .dig_out_nid = ALC880_DIGOUT_NID,
2752 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
2753 .channel_mode = alc880_w810_modes,
2754 .input_mux = &alc880_capture_source,
2757 .mixers = { alc880_z71v_mixer },
2758 .init_verbs = { alc880_volume_init_verbs,
2759 alc880_pin_z71v_init_verbs },
2760 .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
2761 .dac_nids = alc880_z71v_dac_nids,
2762 .dig_out_nid = ALC880_DIGOUT_NID,
2764 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
2765 .channel_mode = alc880_2_jack_modes,
2766 .input_mux = &alc880_capture_source,
2769 .mixers = { alc880_f1734_mixer },
2770 .init_verbs = { alc880_volume_init_verbs,
2771 alc880_pin_f1734_init_verbs },
2772 .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
2773 .dac_nids = alc880_f1734_dac_nids,
2775 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
2776 .channel_mode = alc880_2_jack_modes,
2777 .input_mux = &alc880_capture_source,
2780 .mixers = { alc880_asus_mixer },
2781 .init_verbs = { alc880_volume_init_verbs,
2782 alc880_pin_asus_init_verbs,
2783 alc880_gpio1_init_verbs },
2784 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2785 .dac_nids = alc880_asus_dac_nids,
2786 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2787 .channel_mode = alc880_asus_modes,
2789 .input_mux = &alc880_capture_source,
2791 [ALC880_ASUS_DIG] = {
2792 .mixers = { alc880_asus_mixer },
2793 .init_verbs = { alc880_volume_init_verbs,
2794 alc880_pin_asus_init_verbs,
2795 alc880_gpio1_init_verbs },
2796 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2797 .dac_nids = alc880_asus_dac_nids,
2798 .dig_out_nid = ALC880_DIGOUT_NID,
2799 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2800 .channel_mode = alc880_asus_modes,
2802 .input_mux = &alc880_capture_source,
2804 [ALC880_ASUS_DIG2] = {
2805 .mixers = { alc880_asus_mixer },
2806 .init_verbs = { alc880_volume_init_verbs,
2807 alc880_pin_asus_init_verbs,
2808 alc880_gpio2_init_verbs }, /* use GPIO2 */
2809 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2810 .dac_nids = alc880_asus_dac_nids,
2811 .dig_out_nid = ALC880_DIGOUT_NID,
2812 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2813 .channel_mode = alc880_asus_modes,
2815 .input_mux = &alc880_capture_source,
2817 [ALC880_ASUS_W1V] = {
2818 .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
2819 .init_verbs = { alc880_volume_init_verbs,
2820 alc880_pin_asus_init_verbs,
2821 alc880_gpio1_init_verbs },
2822 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2823 .dac_nids = alc880_asus_dac_nids,
2824 .dig_out_nid = ALC880_DIGOUT_NID,
2825 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2826 .channel_mode = alc880_asus_modes,
2828 .input_mux = &alc880_capture_source,
2830 [ALC880_UNIWILL_DIG] = {
2831 .mixers = { alc880_asus_mixer, alc880_pcbeep_mixer },
2832 .init_verbs = { alc880_volume_init_verbs,
2833 alc880_pin_asus_init_verbs },
2834 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2835 .dac_nids = alc880_asus_dac_nids,
2836 .dig_out_nid = ALC880_DIGOUT_NID,
2837 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2838 .channel_mode = alc880_asus_modes,
2840 .input_mux = &alc880_capture_source,
2842 [ALC880_UNIWILL] = {
2843 .mixers = { alc880_uniwill_mixer },
2844 .init_verbs = { alc880_volume_init_verbs,
2845 alc880_uniwill_init_verbs },
2846 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2847 .dac_nids = alc880_asus_dac_nids,
2848 .dig_out_nid = ALC880_DIGOUT_NID,
2849 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
2850 .channel_mode = alc880_threestack_modes,
2852 .input_mux = &alc880_capture_source,
2853 .unsol_event = alc880_uniwill_unsol_event,
2854 .init_hook = alc880_uniwill_automute,
2856 [ALC880_UNIWILL_P53] = {
2857 .mixers = { alc880_uniwill_p53_mixer },
2858 .init_verbs = { alc880_volume_init_verbs,
2859 alc880_uniwill_p53_init_verbs },
2860 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2861 .dac_nids = alc880_asus_dac_nids,
2862 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
2863 .channel_mode = alc880_threestack_modes,
2864 .input_mux = &alc880_capture_source,
2865 .unsol_event = alc880_uniwill_p53_unsol_event,
2866 .init_hook = alc880_uniwill_p53_hp_automute,
2868 [ALC880_FUJITSU] = {
2869 .mixers = { alc880_fujitsu_mixer,
2870 alc880_pcbeep_mixer, },
2871 .init_verbs = { alc880_volume_init_verbs,
2872 alc880_uniwill_p53_init_verbs,
2873 alc880_beep_init_verbs },
2874 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2875 .dac_nids = alc880_dac_nids,
2876 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
2877 .channel_mode = alc880_2_jack_modes,
2878 .input_mux = &alc880_capture_source,
2879 .unsol_event = alc880_uniwill_p53_unsol_event,
2880 .init_hook = alc880_uniwill_p53_hp_automute,
2883 .mixers = { alc880_three_stack_mixer },
2884 .init_verbs = { alc880_volume_init_verbs,
2885 alc880_pin_clevo_init_verbs },
2886 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2887 .dac_nids = alc880_dac_nids,
2889 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
2890 .channel_mode = alc880_threestack_modes,
2892 .input_mux = &alc880_capture_source,
2895 .mixers = { alc880_lg_mixer },
2896 .init_verbs = { alc880_volume_init_verbs,
2897 alc880_lg_init_verbs },
2898 .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids),
2899 .dac_nids = alc880_lg_dac_nids,
2900 .dig_out_nid = ALC880_DIGOUT_NID,
2901 .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes),
2902 .channel_mode = alc880_lg_ch_modes,
2904 .input_mux = &alc880_lg_capture_source,
2905 .unsol_event = alc880_lg_unsol_event,
2906 .init_hook = alc880_lg_automute,
2907 #ifdef CONFIG_SND_HDA_POWER_SAVE
2908 .loopbacks = alc880_lg_loopbacks,
2912 .mixers = { alc880_lg_lw_mixer },
2913 .init_verbs = { alc880_volume_init_verbs,
2914 alc880_lg_lw_init_verbs },
2915 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2916 .dac_nids = alc880_dac_nids,
2917 .dig_out_nid = ALC880_DIGOUT_NID,
2918 .num_channel_mode = ARRAY_SIZE(alc880_lg_lw_modes),
2919 .channel_mode = alc880_lg_lw_modes,
2920 .input_mux = &alc880_lg_lw_capture_source,
2921 .unsol_event = alc880_lg_lw_unsol_event,
2922 .init_hook = alc880_lg_lw_automute,
2924 #ifdef CONFIG_SND_DEBUG
2926 .mixers = { alc880_test_mixer },
2927 .init_verbs = { alc880_test_init_verbs },
2928 .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
2929 .dac_nids = alc880_test_dac_nids,
2930 .dig_out_nid = ALC880_DIGOUT_NID,
2931 .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
2932 .channel_mode = alc880_test_modes,
2933 .input_mux = &alc880_test_capture_source,
2939 * Automatic parse of I/O pins from the BIOS configuration
2942 #define NUM_CONTROL_ALLOC 32
2943 #define NUM_VERB_ALLOC 32
2947 ALC_CTL_WIDGET_MUTE,
2950 static struct snd_kcontrol_new alc880_control_templates[] = {
2951 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
2952 HDA_CODEC_MUTE(NULL, 0, 0, 0),
2953 HDA_BIND_MUTE(NULL, 0, 0, 0),
2956 /* add dynamic controls */
2957 static int add_control(struct alc_spec *spec, int type, const char *name,
2960 struct snd_kcontrol_new *knew;
2962 if (spec->num_kctl_used >= spec->num_kctl_alloc) {
2963 int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC;
2965 /* array + terminator */
2966 knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL);
2969 if (spec->kctl_alloc) {
2970 memcpy(knew, spec->kctl_alloc,
2971 sizeof(*knew) * spec->num_kctl_alloc);
2972 kfree(spec->kctl_alloc);
2974 spec->kctl_alloc = knew;
2975 spec->num_kctl_alloc = num;
2978 knew = &spec->kctl_alloc[spec->num_kctl_used];
2979 *knew = alc880_control_templates[type];
2980 knew->name = kstrdup(name, GFP_KERNEL);
2983 knew->private_value = val;
2984 spec->num_kctl_used++;
2988 #define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
2989 #define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
2990 #define alc880_is_multi_pin(nid) ((nid) >= 0x18)
2991 #define alc880_multi_pin_idx(nid) ((nid) - 0x18)
2992 #define alc880_is_input_pin(nid) ((nid) >= 0x18)
2993 #define alc880_input_pin_idx(nid) ((nid) - 0x18)
2994 #define alc880_idx_to_dac(nid) ((nid) + 0x02)
2995 #define alc880_dac_to_idx(nid) ((nid) - 0x02)
2996 #define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
2997 #define alc880_idx_to_selector(nid) ((nid) + 0x10)
2998 #define ALC880_PIN_CD_NID 0x1c
3000 /* fill in the dac_nids table from the parsed pin configuration */
3001 static int alc880_auto_fill_dac_nids(struct alc_spec *spec,
3002 const struct auto_pin_cfg *cfg)
3008 memset(assigned, 0, sizeof(assigned));
3009 spec->multiout.dac_nids = spec->private_dac_nids;
3011 /* check the pins hardwired to audio widget */
3012 for (i = 0; i < cfg->line_outs; i++) {
3013 nid = cfg->line_out_pins[i];
3014 if (alc880_is_fixed_pin(nid)) {
3015 int idx = alc880_fixed_pin_idx(nid);
3016 spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
3020 /* left pins can be connect to any audio widget */
3021 for (i = 0; i < cfg->line_outs; i++) {
3022 nid = cfg->line_out_pins[i];
3023 if (alc880_is_fixed_pin(nid))
3025 /* search for an empty channel */
3026 for (j = 0; j < cfg->line_outs; j++) {
3028 spec->multiout.dac_nids[i] =
3029 alc880_idx_to_dac(j);
3035 spec->multiout.num_dacs = cfg->line_outs;
3039 /* add playback controls from the parsed DAC table */
3040 static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
3041 const struct auto_pin_cfg *cfg)
3044 static const char *chname[4] = {
3045 "Front", "Surround", NULL /*CLFE*/, "Side"
3050 for (i = 0; i < cfg->line_outs; i++) {
3051 if (!spec->multiout.dac_nids[i])
3053 nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
3056 err = add_control(spec, ALC_CTL_WIDGET_VOL,
3057 "Center Playback Volume",
3058 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
3062 err = add_control(spec, ALC_CTL_WIDGET_VOL,
3063 "LFE Playback Volume",
3064 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
3068 err = add_control(spec, ALC_CTL_BIND_MUTE,
3069 "Center Playback Switch",
3070 HDA_COMPOSE_AMP_VAL(nid, 1, 2,
3074 err = add_control(spec, ALC_CTL_BIND_MUTE,
3075 "LFE Playback Switch",
3076 HDA_COMPOSE_AMP_VAL(nid, 2, 2,
3081 sprintf(name, "%s Playback Volume", chname[i]);
3082 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
3083 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
3087 sprintf(name, "%s Playback Switch", chname[i]);
3088 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
3089 HDA_COMPOSE_AMP_VAL(nid, 3, 2,
3098 /* add playback controls for speaker and HP outputs */
3099 static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
3109 if (alc880_is_fixed_pin(pin)) {
3110 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
3111 /* specify the DAC as the extra output */
3112 if (!spec->multiout.hp_nid)
3113 spec->multiout.hp_nid = nid;
3115 spec->multiout.extra_out_nid[0] = nid;
3116 /* control HP volume/switch on the output mixer amp */
3117 nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
3118 sprintf(name, "%s Playback Volume", pfx);
3119 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
3120 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
3123 sprintf(name, "%s Playback Switch", pfx);
3124 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
3125 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
3128 } else if (alc880_is_multi_pin(pin)) {
3129 /* set manual connection */
3130 /* we have only a switch on HP-out PIN */
3131 sprintf(name, "%s Playback Switch", pfx);
3132 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
3133 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
3140 /* create input playback/capture controls for the given pin */
3141 static int new_analog_input(struct alc_spec *spec, hda_nid_t pin,
3142 const char *ctlname,
3143 int idx, hda_nid_t mix_nid)
3148 sprintf(name, "%s Playback Volume", ctlname);
3149 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
3150 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
3153 sprintf(name, "%s Playback Switch", ctlname);
3154 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
3155 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
3161 /* create playback/capture controls for input pins */
3162 static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec,
3163 const struct auto_pin_cfg *cfg)
3165 struct hda_input_mux *imux = &spec->private_imux;
3168 for (i = 0; i < AUTO_PIN_LAST; i++) {
3169 if (alc880_is_input_pin(cfg->input_pins[i])) {
3170 idx = alc880_input_pin_idx(cfg->input_pins[i]);
3171 err = new_analog_input(spec, cfg->input_pins[i],
3172 auto_pin_cfg_labels[i],
3176 imux->items[imux->num_items].label =
3177 auto_pin_cfg_labels[i];
3178 imux->items[imux->num_items].index =
3179 alc880_input_pin_idx(cfg->input_pins[i]);
3186 static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
3187 hda_nid_t nid, int pin_type,
3191 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
3193 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
3195 /* need the manual connection? */
3196 if (alc880_is_multi_pin(nid)) {
3197 struct alc_spec *spec = codec->spec;
3198 int idx = alc880_multi_pin_idx(nid);
3199 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
3200 AC_VERB_SET_CONNECT_SEL,
3201 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
3205 static int get_pin_type(int line_out_type)
3207 if (line_out_type == AUTO_PIN_HP_OUT)
3213 static void alc880_auto_init_multi_out(struct hda_codec *codec)
3215 struct alc_spec *spec = codec->spec;
3218 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
3219 for (i = 0; i < spec->autocfg.line_outs; i++) {
3220 hda_nid_t nid = spec->autocfg.line_out_pins[i];
3221 int pin_type = get_pin_type(spec->autocfg.line_out_type);
3222 alc880_auto_set_output_and_unmute(codec, nid, pin_type, i);
3226 static void alc880_auto_init_extra_out(struct hda_codec *codec)
3228 struct alc_spec *spec = codec->spec;
3231 pin = spec->autocfg.speaker_pins[0];
3232 if (pin) /* connect to front */
3233 alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
3234 pin = spec->autocfg.hp_pins[0];
3235 if (pin) /* connect to front */
3236 alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
3239 static void alc880_auto_init_analog_input(struct hda_codec *codec)
3241 struct alc_spec *spec = codec->spec;
3244 for (i = 0; i < AUTO_PIN_LAST; i++) {
3245 hda_nid_t nid = spec->autocfg.input_pins[i];
3246 if (alc880_is_input_pin(nid)) {
3247 snd_hda_codec_write(codec, nid, 0,
3248 AC_VERB_SET_PIN_WIDGET_CONTROL,
3249 i <= AUTO_PIN_FRONT_MIC ?
3250 PIN_VREF80 : PIN_IN);
3251 if (nid != ALC880_PIN_CD_NID)
3252 snd_hda_codec_write(codec, nid, 0,
3253 AC_VERB_SET_AMP_GAIN_MUTE,
3259 /* parse the BIOS configuration and set up the alc_spec */
3260 /* return 1 if successful, 0 if the proper config is not found,
3261 * or a negative error code
3263 static int alc880_parse_auto_config(struct hda_codec *codec)
3265 struct alc_spec *spec = codec->spec;
3267 static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
3269 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
3273 if (!spec->autocfg.line_outs)
3274 return 0; /* can't find valid BIOS pin config */
3276 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
3279 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
3282 err = alc880_auto_create_extra_out(spec,
3283 spec->autocfg.speaker_pins[0],
3287 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
3291 err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
3295 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
3297 if (spec->autocfg.dig_out_pin)
3298 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
3299 if (spec->autocfg.dig_in_pin)
3300 spec->dig_in_nid = ALC880_DIGIN_NID;
3302 if (spec->kctl_alloc)
3303 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
3305 spec->init_verbs[spec->num_init_verbs++] = alc880_volume_init_verbs;
3307 spec->num_mux_defs = 1;
3308 spec->input_mux = &spec->private_imux;
3313 /* additional initialization for auto-configuration model */
3314 static void alc880_auto_init(struct hda_codec *codec)
3316 alc880_auto_init_multi_out(codec);
3317 alc880_auto_init_extra_out(codec);
3318 alc880_auto_init_analog_input(codec);
3322 * OK, here we have finally the patch for ALC880
3325 static int patch_alc880(struct hda_codec *codec)
3327 struct alc_spec *spec;
3331 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
3337 board_config = snd_hda_check_board_config(codec, ALC880_MODEL_LAST,
3340 if (board_config < 0) {
3341 printk(KERN_INFO "hda_codec: Unknown model for ALC880, "
3342 "trying auto-probe from BIOS...\n");
3343 board_config = ALC880_AUTO;
3346 if (board_config == ALC880_AUTO) {
3347 /* automatic parse from the BIOS config */
3348 err = alc880_parse_auto_config(codec);
3354 "hda_codec: Cannot set up configuration "
3355 "from BIOS. Using 3-stack mode...\n");
3356 board_config = ALC880_3ST;
3360 if (board_config != ALC880_AUTO)
3361 setup_preset(spec, &alc880_presets[board_config]);
3363 spec->stream_name_analog = "ALC880 Analog";
3364 spec->stream_analog_playback = &alc880_pcm_analog_playback;
3365 spec->stream_analog_capture = &alc880_pcm_analog_capture;
3367 spec->stream_name_digital = "ALC880 Digital";
3368 spec->stream_digital_playback = &alc880_pcm_digital_playback;
3369 spec->stream_digital_capture = &alc880_pcm_digital_capture;
3371 if (!spec->adc_nids && spec->input_mux) {
3372 /* check whether NID 0x07 is valid */
3373 unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
3375 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
3376 if (wcap != AC_WID_AUD_IN) {
3377 spec->adc_nids = alc880_adc_nids_alt;
3378 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
3379 spec->mixers[spec->num_mixers] =
3380 alc880_capture_alt_mixer;
3383 spec->adc_nids = alc880_adc_nids;
3384 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
3385 spec->mixers[spec->num_mixers] = alc880_capture_mixer;
3390 codec->patch_ops = alc_patch_ops;
3391 if (board_config == ALC880_AUTO)
3392 spec->init_hook = alc880_auto_init;
3393 #ifdef CONFIG_SND_HDA_POWER_SAVE
3394 if (!spec->loopback.amplist)
3395 spec->loopback.amplist = alc880_loopbacks;
3406 static hda_nid_t alc260_dac_nids[1] = {
3411 static hda_nid_t alc260_adc_nids[1] = {
3416 static hda_nid_t alc260_adc_nids_alt[1] = {
3421 static hda_nid_t alc260_hp_adc_nids[2] = {
3426 /* NIDs used when simultaneous access to both ADCs makes sense. Note that
3427 * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
3429 static hda_nid_t alc260_dual_adc_nids[2] = {
3434 #define ALC260_DIGOUT_NID 0x03
3435 #define ALC260_DIGIN_NID 0x06
3437 static struct hda_input_mux alc260_capture_source = {
3441 { "Front Mic", 0x1 },
3447 /* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
3448 * headphone jack and the internal CD lines since these are the only pins at
3449 * which audio can appear. For flexibility, also allow the option of
3450 * recording the mixer output on the second ADC (ADC0 doesn't have a
3451 * connection to the mixer output).
3453 static struct hda_input_mux alc260_fujitsu_capture_sources[2] = {
3457 { "Mic/Line", 0x0 },
3459 { "Headphone", 0x2 },
3465 { "Mic/Line", 0x0 },
3467 { "Headphone", 0x2 },
3474 /* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to
3475 * the Fujitsu S702x, but jacks are marked differently.
3477 static struct hda_input_mux alc260_acer_capture_sources[2] = {
3484 { "Headphone", 0x5 },
3493 { "Headphone", 0x6 },
3499 * This is just place-holder, so there's something for alc_build_pcms to look
3500 * at when it calculates the maximum number of channels. ALC260 has no mixer
3501 * element which allows changing the channel mode, so the verb list is
3504 static struct hda_channel_mode alc260_modes[1] = {
3509 /* Mixer combinations
3511 * basic: base_output + input + pc_beep + capture
3512 * HP: base_output + input + capture_alt
3513 * HP_3013: hp_3013 + input + capture
3514 * fujitsu: fujitsu + capture
3515 * acer: acer + capture
3518 static struct snd_kcontrol_new alc260_base_output_mixer[] = {
3519 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3520 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
3521 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
3522 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
3523 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
3524 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
3528 static struct snd_kcontrol_new alc260_input_mixer[] = {
3529 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3530 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
3531 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
3532 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
3533 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
3534 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
3535 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
3536 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
3540 static struct snd_kcontrol_new alc260_pc_beep_mixer[] = {
3541 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x07, 0x05, HDA_INPUT),
3542 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x07, 0x05, HDA_INPUT),
3546 static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
3547 HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
3548 HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
3549 HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
3550 HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
3551 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3552 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
3553 HDA_CODEC_VOLUME_MONO("iSpeaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
3554 HDA_CODEC_MUTE_MONO("iSpeaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
3558 /* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12,
3559 * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10.
3561 static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
3562 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3563 HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
3564 ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
3565 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3566 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
3567 HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
3568 HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
3569 ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
3570 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
3571 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
3572 HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
3573 HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x09, 2, HDA_INPUT),
3577 /* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current
3578 * versions of the ALC260 don't act on requests to enable mic bias from NID
3579 * 0x0f (used to drive the headphone jack in these laptops). The ALC260
3580 * datasheet doesn't mention this restriction. At this stage it's not clear
3581 * whether this behaviour is intentional or is a hardware bug in chip
3582 * revisions available in early 2006. Therefore for now allow the
3583 * "Headphone Jack Mode" control to span all choices, but if it turns out
3584 * that the lack of mic bias for this NID is intentional we could change the
3585 * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
3587 * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006
3588 * don't appear to make the mic bias available from the "line" jack, even
3589 * though the NID used for this jack (0x14) can supply it. The theory is
3590 * that perhaps Acer have included blocking capacitors between the ALC260
3591 * and the output jack. If this turns out to be the case for all such
3592 * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
3593 * to ALC_PIN_DIR_INOUT_NOMICBIAS.
3595 * The C20x Tablet series have a mono internal speaker which is controlled
3596 * via the chip's Mono sum widget and pin complex, so include the necessary
3597 * controls for such models. On models without a "mono speaker" the control
3598 * won't do anything.
3600 static struct snd_kcontrol_new alc260_acer_mixer[] = {
3601 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3602 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
3603 ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
3604 HDA_CODEC_VOLUME_MONO("Mono Speaker Playback Volume", 0x0a, 1, 0x0,
3606 HDA_BIND_MUTE_MONO("Mono Speaker Playback Switch", 0x0a, 1, 2,
3608 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3609 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
3610 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
3611 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
3612 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
3613 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
3614 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
3615 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
3616 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
3617 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
3621 /* Packard bell V7900 ALC260 pin usage: HP = 0x0f, Mic jack = 0x12,
3622 * Line In jack = 0x14, CD audio = 0x16, pc beep = 0x17.
3624 static struct snd_kcontrol_new alc260_will_mixer[] = {
3625 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3626 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
3627 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
3628 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
3629 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
3630 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
3631 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
3632 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
3633 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3634 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
3635 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
3636 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
3640 /* Replacer 672V ALC260 pin usage: Mic jack = 0x12,
3641 * Line In jack = 0x14, ATAPI Mic = 0x13, speaker = 0x0f.
3643 static struct snd_kcontrol_new alc260_replacer_672v_mixer[] = {
3644 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3645 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
3646 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
3647 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
3648 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
3649 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x07, 0x1, HDA_INPUT),
3650 HDA_CODEC_MUTE("ATATI Mic Playback Switch", 0x07, 0x1, HDA_INPUT),
3651 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
3652 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
3653 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
3657 /* capture mixer elements */
3658 static struct snd_kcontrol_new alc260_capture_mixer[] = {
3659 HDA_CODEC_VOLUME("Capture Volume", 0x04, 0x0, HDA_INPUT),
3660 HDA_CODEC_MUTE("Capture Switch", 0x04, 0x0, HDA_INPUT),
3661 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x05, 0x0, HDA_INPUT),
3662 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x05, 0x0, HDA_INPUT),
3664 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3665 /* The multiple "Capture Source" controls confuse alsamixer
3666 * So call somewhat different..
3667 * FIXME: the controls appear in the "playback" view!
3669 /* .name = "Capture Source", */
3670 .name = "Input Source",
3672 .info = alc_mux_enum_info,
3673 .get = alc_mux_enum_get,
3674 .put = alc_mux_enum_put,
3679 static struct snd_kcontrol_new alc260_capture_alt_mixer[] = {
3680 HDA_CODEC_VOLUME("Capture Volume", 0x05, 0x0, HDA_INPUT),
3681 HDA_CODEC_MUTE("Capture Switch", 0x05, 0x0, HDA_INPUT),
3683 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3684 /* The multiple "Capture Source" controls confuse alsamixer
3685 * So call somewhat different..
3686 * FIXME: the controls appear in the "playback" view!
3688 /* .name = "Capture Source", */
3689 .name = "Input Source",
3691 .info = alc_mux_enum_info,
3692 .get = alc_mux_enum_get,
3693 .put = alc_mux_enum_put,
3699 * initialization verbs
3701 static struct hda_verb alc260_init_verbs[] = {
3702 /* Line In pin widget for input */
3703 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3704 /* CD pin widget for input */
3705 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3706 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3707 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3708 /* Mic2 (front panel) pin widget for input and vref at 80% */
3709 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3710 /* LINE-2 is used for line-out in rear */
3711 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3712 /* select line-out */
3713 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
3715 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3717 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3719 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3720 /* mute capture amp left and right */
3721 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3722 /* set connection select to line in (default select for this ADC) */
3723 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
3724 /* mute capture amp left and right */
3725 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3726 /* set connection select to line in (default select for this ADC) */
3727 {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
3728 /* set vol=0 Line-Out mixer amp left and right */
3729 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3730 /* unmute pin widget amp left and right (no gain on this amp) */
3731 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3732 /* set vol=0 HP mixer amp left and right */
3733 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3734 /* unmute pin widget amp left and right (no gain on this amp) */
3735 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3736 /* set vol=0 Mono mixer amp left and right */
3737 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3738 /* unmute pin widget amp left and right (no gain on this amp) */
3739 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3740 /* unmute LINE-2 out pin */
3741 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3742 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
3745 /* mute analog inputs */
3746 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3747 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3748 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
3749 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
3750 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
3751 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
3752 /* mute Front out path */
3753 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3754 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3755 /* mute Headphone out path */
3756 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3757 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3758 /* mute Mono out path */
3759 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3760 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3764 #if 0 /* should be identical with alc260_init_verbs? */
3765 static struct hda_verb alc260_hp_init_verbs[] = {
3766 /* Headphone and output */
3767 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
3769 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
3770 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3771 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
3772 /* Mic2 (front panel) pin widget for input and vref at 80% */
3773 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
3774 /* Line In pin widget for input */
3775 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
3776 /* Line-2 pin widget for output */
3777 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
3778 /* CD pin widget for input */
3779 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
3780 /* unmute amp left and right */
3781 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
3782 /* set connection select to line in (default select for this ADC) */
3783 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
3784 /* unmute Line-Out mixer amp left and right (volume = 0) */
3785 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
3786 /* mute pin widget amp left and right (no gain on this amp) */
3787 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
3788 /* unmute HP mixer amp left and right (volume = 0) */
3789 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
3790 /* mute pin widget amp left and right (no gain on this amp) */
3791 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
3792 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
3795 /* mute analog inputs */
3796 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3797 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3798 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
3799 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
3800 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
3801 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
3802 /* Unmute Front out path */
3803 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3804 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3805 /* Unmute Headphone out path */
3806 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3807 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3808 /* Unmute Mono out path */
3809 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3810 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3815 static struct hda_verb alc260_hp_3013_init_verbs[] = {
3816 /* Line out and output */
3817 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
3819 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
3820 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3821 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
3822 /* Mic2 (front panel) pin widget for input and vref at 80% */
3823 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
3824 /* Line In pin widget for input */
3825 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
3826 /* Headphone pin widget for output */
3827 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
3828 /* CD pin widget for input */
3829 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
3830 /* unmute amp left and right */
3831 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
3832 /* set connection select to line in (default select for this ADC) */
3833 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
3834 /* unmute Line-Out mixer amp left and right (volume = 0) */
3835 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
3836 /* mute pin widget amp left and right (no gain on this amp) */
3837 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
3838 /* unmute HP mixer amp left and right (volume = 0) */
3839 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
3840 /* mute pin widget amp left and right (no gain on this amp) */
3841 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
3842 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
3845 /* mute analog inputs */
3846 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3847 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3848 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
3849 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
3850 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
3851 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
3852 /* Unmute Front out path */
3853 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3854 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3855 /* Unmute Headphone out path */
3856 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3857 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3858 /* Unmute Mono out path */
3859 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3860 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3864 /* Initialisation sequence for ALC260 as configured in Fujitsu S702x
3865 * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD
3866 * audio = 0x16, internal speaker = 0x10.
3868 static struct hda_verb alc260_fujitsu_init_verbs[] = {
3869 /* Disable all GPIOs */
3870 {0x01, AC_VERB_SET_GPIO_MASK, 0},
3871 /* Internal speaker is connected to headphone pin */
3872 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3873 /* Headphone/Line-out jack connects to Line1 pin; make it an output */
3874 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3875 /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
3876 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3877 /* Ensure all other unused pins are disabled and muted. */
3878 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3879 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3880 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3881 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3882 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3883 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3884 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3885 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3887 /* Disable digital (SPDIF) pins */
3888 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
3889 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
3891 /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
3892 * when acting as an output.
3894 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
3896 /* Start with output sum widgets muted and their output gains at min */
3897 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3898 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3899 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3900 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3901 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3902 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3903 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3904 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3905 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3907 /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
3908 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3909 /* Unmute Line1 pin widget output buffer since it starts as an output.
3910 * If the pin mode is changed by the user the pin mode control will
3911 * take care of enabling the pin's input/output buffers as needed.
3912 * Therefore there's no need to enable the input buffer at this
3915 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3916 /* Unmute input buffer of pin widget used for Line-in (no equiv
3919 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3921 /* Mute capture amp left and right */
3922 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3923 /* Set ADC connection select to match default mixer setting - line
3926 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
3928 /* Do the same for the second ADC: mute capture input amp and
3929 * set ADC connection to line in (on mic1 pin)
3931 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3932 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
3934 /* Mute all inputs to mixer widget (even unconnected ones) */
3935 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
3936 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
3937 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
3938 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
3939 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
3940 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
3941 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
3942 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
3947 /* Initialisation sequence for ALC260 as configured in Acer TravelMate and
3948 * similar laptops (adapted from Fujitsu init verbs).
3950 static struct hda_verb alc260_acer_init_verbs[] = {
3951 /* On TravelMate laptops, GPIO 0 enables the internal speaker and
3952 * the headphone jack. Turn this on and rely on the standard mute
3953 * methods whenever the user wants to turn these outputs off.
3955 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
3956 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
3957 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
3958 /* Internal speaker/Headphone jack is connected to Line-out pin */
3959 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3960 /* Internal microphone/Mic jack is connected to Mic1 pin */
3961 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
3962 /* Line In jack is connected to Line1 pin */
3963 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3964 /* Some Acers (eg: C20x Tablets) use Mono pin for internal speaker */
3965 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3966 /* Ensure all other unused pins are disabled and muted. */
3967 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3968 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3969 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3970 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3971 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3972 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3973 /* Disable digital (SPDIF) pins */
3974 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
3975 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
3977 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
3978 * bus when acting as outputs.
3980 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
3981 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
3983 /* Start with output sum widgets muted and their output gains at min */
3984 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3985 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3986 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3987 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3988 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3989 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3990 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3991 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3992 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3994 /* Unmute Line-out pin widget amp left and right
3995 * (no equiv mixer ctrl)
3997 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3998 /* Unmute mono pin widget amp output (no equiv mixer ctrl) */
3999 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4000 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
4001 * inputs. If the pin mode is changed by the user the pin mode control
4002 * will take care of enabling the pin's input/output buffers as needed.
4003 * Therefore there's no need to enable the input buffer at this
4006 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4007 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4009 /* Mute capture amp left and right */
4010 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4011 /* Set ADC connection select to match default mixer setting - mic
4014 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
4016 /* Do similar with the second ADC: mute capture input amp and
4017 * set ADC connection to mic to match ALSA's default state.
4019 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4020 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
4022 /* Mute all inputs to mixer widget (even unconnected ones) */
4023 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
4024 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
4025 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
4026 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
4027 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
4028 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
4029 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
4030 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
4035 static struct hda_verb alc260_will_verbs[] = {
4036 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4037 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x00},
4038 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
4039 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
4040 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
4041 {0x1a, AC_VERB_SET_PROC_COEF, 0x3040},
4045 static struct hda_verb alc260_replacer_672v_verbs[] = {
4046 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
4047 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
4048 {0x1a, AC_VERB_SET_PROC_COEF, 0x3050},
4050 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
4051 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
4052 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
4054 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
4058 /* toggle speaker-output according to the hp-jack state */
4059 static void alc260_replacer_672v_automute(struct hda_codec *codec)
4061 unsigned int present;
4063 /* speaker --> GPIO Data 0, hp or spdif --> GPIO data 1 */
4064 present = snd_hda_codec_read(codec, 0x0f, 0,
4065 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
4067 snd_hda_codec_write_cache(codec, 0x01, 0,
4068 AC_VERB_SET_GPIO_DATA, 1);
4069 snd_hda_codec_write_cache(codec, 0x0f, 0,
4070 AC_VERB_SET_PIN_WIDGET_CONTROL,
4073 snd_hda_codec_write_cache(codec, 0x01, 0,
4074 AC_VERB_SET_GPIO_DATA, 0);
4075 snd_hda_codec_write_cache(codec, 0x0f, 0,
4076 AC_VERB_SET_PIN_WIDGET_CONTROL,
4081 static void alc260_replacer_672v_unsol_event(struct hda_codec *codec,
4084 if ((res >> 26) == ALC880_HP_EVENT)
4085 alc260_replacer_672v_automute(codec);
4088 /* Test configuration for debugging, modelled after the ALC880 test
4091 #ifdef CONFIG_SND_DEBUG
4092 static hda_nid_t alc260_test_dac_nids[1] = {
4095 static hda_nid_t alc260_test_adc_nids[2] = {
4098 /* For testing the ALC260, each input MUX needs its own definition since
4099 * the signal assignments are different. This assumes that the first ADC
4102 static struct hda_input_mux alc260_test_capture_sources[2] = {
4106 { "MIC1 pin", 0x0 },
4107 { "MIC2 pin", 0x1 },
4108 { "LINE1 pin", 0x2 },
4109 { "LINE2 pin", 0x3 },
4111 { "LINE-OUT pin", 0x5 },
4112 { "HP-OUT pin", 0x6 },
4118 { "MIC1 pin", 0x0 },
4119 { "MIC2 pin", 0x1 },
4120 { "LINE1 pin", 0x2 },
4121 { "LINE2 pin", 0x3 },
4124 { "LINE-OUT pin", 0x6 },
4125 { "HP-OUT pin", 0x7 },
4129 static struct snd_kcontrol_new alc260_test_mixer[] = {
4130 /* Output driver widgets */
4131 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
4132 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
4133 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4134 HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
4135 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4136 HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
4138 /* Modes for retasking pin widgets
4139 * Note: the ALC260 doesn't seem to act on requests to enable mic
4140 * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't
4141 * mention this restriction. At this stage it's not clear whether
4142 * this behaviour is intentional or is a hardware bug in chip
4143 * revisions available at least up until early 2006. Therefore for
4144 * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all
4145 * choices, but if it turns out that the lack of mic bias for these
4146 * NIDs is intentional we could change their modes from
4147 * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
4149 ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
4150 ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
4151 ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
4152 ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
4153 ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
4154 ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
4156 /* Loopback mixer controls */
4157 HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
4158 HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
4159 HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
4160 HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
4161 HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
4162 HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
4163 HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
4164 HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
4165 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4166 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4167 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
4168 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
4169 HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
4170 HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
4171 HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
4172 HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
4174 /* Controls for GPIO pins, assuming they are configured as outputs */
4175 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
4176 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
4177 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
4178 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
4180 /* Switches to allow the digital IO pins to be enabled. The datasheet
4181 * is ambigious as to which NID is which; testing on laptops which
4182 * make this output available should provide clarification.
4184 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
4185 ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
4189 static struct hda_verb alc260_test_init_verbs[] = {
4190 /* Enable all GPIOs as outputs with an initial value of 0 */
4191 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
4192 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
4193 {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
4195 /* Enable retasking pins as output, initially without power amp */
4196 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4197 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4198 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4199 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4200 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4201 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4203 /* Disable digital (SPDIF) pins initially, but users can enable
4204 * them via a mixer switch. In the case of SPDIF-out, this initverb
4205 * payload also sets the generation to 0, output to be in "consumer"
4206 * PCM format, copyright asserted, no pre-emphasis and no validity
4209 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
4210 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
4212 /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
4213 * OUT1 sum bus when acting as an output.
4215 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
4216 {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
4217 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
4218 {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
4220 /* Start with output sum widgets muted and their output gains at min */
4221 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4222 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4223 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4224 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4225 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4226 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4227 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4228 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4229 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4231 /* Unmute retasking pin widget output buffers since the default
4232 * state appears to be output. As the pin mode is changed by the
4233 * user the pin mode control will take care of enabling the pin's
4234 * input/output buffers as needed.
4236 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4237 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4238 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4239 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4240 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4241 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4242 /* Also unmute the mono-out pin widget */
4243 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4245 /* Mute capture amp left and right */
4246 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4247 /* Set ADC connection select to match default mixer setting (mic1
4250 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
4252 /* Do the same for the second ADC: mute capture input amp and
4253 * set ADC connection to mic1 pin
4255 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4256 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
4258 /* Mute all inputs to mixer widget (even unconnected ones) */
4259 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
4260 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
4261 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
4262 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
4263 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
4264 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
4265 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
4266 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
4272 static struct hda_pcm_stream alc260_pcm_analog_playback = {
4278 static struct hda_pcm_stream alc260_pcm_analog_capture = {
4284 #define alc260_pcm_digital_playback alc880_pcm_digital_playback
4285 #define alc260_pcm_digital_capture alc880_pcm_digital_capture
4288 * for BIOS auto-configuration
4291 static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
4295 unsigned long vol_val, sw_val;
4299 if (nid >= 0x0f && nid < 0x11) {
4300 nid_vol = nid - 0x7;
4301 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
4302 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
4303 } else if (nid == 0x11) {
4304 nid_vol = nid - 0x7;
4305 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
4306 sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
4307 } else if (nid >= 0x12 && nid <= 0x15) {
4309 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
4310 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
4314 snprintf(name, sizeof(name), "%s Playback Volume", pfx);
4315 err = add_control(spec, ALC_CTL_WIDGET_VOL, name, vol_val);
4318 snprintf(name, sizeof(name), "%s Playback Switch", pfx);
4319 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, sw_val);
4325 /* add playback controls from the parsed DAC table */
4326 static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
4327 const struct auto_pin_cfg *cfg)
4332 spec->multiout.num_dacs = 1;
4333 spec->multiout.dac_nids = spec->private_dac_nids;
4334 spec->multiout.dac_nids[0] = 0x02;
4336 nid = cfg->line_out_pins[0];
4338 err = alc260_add_playback_controls(spec, nid, "Front");
4343 nid = cfg->speaker_pins[0];
4345 err = alc260_add_playback_controls(spec, nid, "Speaker");
4350 nid = cfg->hp_pins[0];
4352 err = alc260_add_playback_controls(spec, nid, "Headphone");
4359 /* create playback/capture controls for input pins */
4360 static int alc260_auto_create_analog_input_ctls(struct alc_spec *spec,
4361 const struct auto_pin_cfg *cfg)
4363 struct hda_input_mux *imux = &spec->private_imux;
4366 for (i = 0; i < AUTO_PIN_LAST; i++) {
4367 if (cfg->input_pins[i] >= 0x12) {
4368 idx = cfg->input_pins[i] - 0x12;
4369 err = new_analog_input(spec, cfg->input_pins[i],
4370 auto_pin_cfg_labels[i], idx,
4374 imux->items[imux->num_items].label =
4375 auto_pin_cfg_labels[i];
4376 imux->items[imux->num_items].index = idx;
4379 if (cfg->input_pins[i] >= 0x0f && cfg->input_pins[i] <= 0x10){
4380 idx = cfg->input_pins[i] - 0x09;
4381 err = new_analog_input(spec, cfg->input_pins[i],
4382 auto_pin_cfg_labels[i], idx,
4386 imux->items[imux->num_items].label =
4387 auto_pin_cfg_labels[i];
4388 imux->items[imux->num_items].index = idx;
4395 static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
4396 hda_nid_t nid, int pin_type,
4400 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4402 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
4404 /* need the manual connection? */
4406 int idx = nid - 0x12;
4407 snd_hda_codec_write(codec, idx + 0x0b, 0,
4408 AC_VERB_SET_CONNECT_SEL, sel_idx);
4412 static void alc260_auto_init_multi_out(struct hda_codec *codec)
4414 struct alc_spec *spec = codec->spec;
4417 alc_subsystem_id(codec, 0x10, 0x15, 0x0f);
4418 nid = spec->autocfg.line_out_pins[0];
4420 int pin_type = get_pin_type(spec->autocfg.line_out_type);
4421 alc260_auto_set_output_and_unmute(codec, nid, pin_type, 0);
4424 nid = spec->autocfg.speaker_pins[0];
4426 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
4428 nid = spec->autocfg.hp_pins[0];
4430 alc260_auto_set_output_and_unmute(codec, nid, PIN_HP, 0);
4433 #define ALC260_PIN_CD_NID 0x16
4434 static void alc260_auto_init_analog_input(struct hda_codec *codec)
4436 struct alc_spec *spec = codec->spec;
4439 for (i = 0; i < AUTO_PIN_LAST; i++) {
4440 hda_nid_t nid = spec->autocfg.input_pins[i];
4442 snd_hda_codec_write(codec, nid, 0,
4443 AC_VERB_SET_PIN_WIDGET_CONTROL,
4444 i <= AUTO_PIN_FRONT_MIC ?
4445 PIN_VREF80 : PIN_IN);
4446 if (nid != ALC260_PIN_CD_NID)
4447 snd_hda_codec_write(codec, nid, 0,
4448 AC_VERB_SET_AMP_GAIN_MUTE,
4455 * generic initialization of ADC, input mixers and output mixers
4457 static struct hda_verb alc260_volume_init_verbs[] = {
4459 * Unmute ADC0-1 and set the default input to mic-in
4461 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
4462 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4463 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
4464 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4466 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
4468 * Note: PASD motherboards uses the Line In 2 as the input for
4469 * front panel mic (mic 2)
4471 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
4472 /* mute analog inputs */
4473 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4474 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4475 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4476 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4477 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
4480 * Set up output mixers (0x08 - 0x0a)
4482 /* set vol=0 to output mixers */
4483 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4484 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4485 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4486 /* set up input amps for analog loopback */
4487 /* Amp Indices: DAC = 0, mixer = 1 */
4488 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4489 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4490 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4491 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4492 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4493 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4498 static int alc260_parse_auto_config(struct hda_codec *codec)
4500 struct alc_spec *spec = codec->spec;
4503 static hda_nid_t alc260_ignore[] = { 0x17, 0 };
4505 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
4509 err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg);
4512 if (!spec->kctl_alloc)
4513 return 0; /* can't find valid BIOS pin config */
4514 err = alc260_auto_create_analog_input_ctls(spec, &spec->autocfg);
4518 spec->multiout.max_channels = 2;
4520 if (spec->autocfg.dig_out_pin)
4521 spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
4522 if (spec->kctl_alloc)
4523 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
4525 spec->init_verbs[spec->num_init_verbs++] = alc260_volume_init_verbs;
4527 spec->num_mux_defs = 1;
4528 spec->input_mux = &spec->private_imux;
4530 /* check whether NID 0x04 is valid */
4531 wcap = get_wcaps(codec, 0x04);
4532 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
4533 if (wcap != AC_WID_AUD_IN) {
4534 spec->adc_nids = alc260_adc_nids_alt;
4535 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
4536 spec->mixers[spec->num_mixers] = alc260_capture_alt_mixer;
4538 spec->adc_nids = alc260_adc_nids;
4539 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
4540 spec->mixers[spec->num_mixers] = alc260_capture_mixer;
4547 /* additional initialization for auto-configuration model */
4548 static void alc260_auto_init(struct hda_codec *codec)
4550 alc260_auto_init_multi_out(codec);
4551 alc260_auto_init_analog_input(codec);
4554 #ifdef CONFIG_SND_HDA_POWER_SAVE
4555 static struct hda_amp_list alc260_loopbacks[] = {
4556 { 0x07, HDA_INPUT, 0 },
4557 { 0x07, HDA_INPUT, 1 },
4558 { 0x07, HDA_INPUT, 2 },
4559 { 0x07, HDA_INPUT, 3 },
4560 { 0x07, HDA_INPUT, 4 },
4566 * ALC260 configurations
4568 static const char *alc260_models[ALC260_MODEL_LAST] = {
4569 [ALC260_BASIC] = "basic",
4571 [ALC260_HP_3013] = "hp-3013",
4572 [ALC260_FUJITSU_S702X] = "fujitsu",
4573 [ALC260_ACER] = "acer",
4574 [ALC260_WILL] = "will",
4575 [ALC260_REPLACER_672V] = "replacer",
4576 #ifdef CONFIG_SND_DEBUG
4577 [ALC260_TEST] = "test",
4579 [ALC260_AUTO] = "auto",
4582 static struct snd_pci_quirk alc260_cfg_tbl[] = {
4583 SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER),
4584 SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER),
4585 SND_PCI_QUIRK(0x103c, 0x2808, "HP d5700", ALC260_HP_3013),
4586 SND_PCI_QUIRK(0x103c, 0x280a, "HP d5750", ALC260_HP_3013),
4587 SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013),
4588 SND_PCI_QUIRK(0x103c, 0x3011, "HP", ALC260_HP),
4589 SND_PCI_QUIRK(0x103c, 0x3012, "HP", ALC260_HP_3013),
4590 SND_PCI_QUIRK(0x103c, 0x3013, "HP", ALC260_HP_3013),
4591 SND_PCI_QUIRK(0x103c, 0x3014, "HP", ALC260_HP),
4592 SND_PCI_QUIRK(0x103c, 0x3015, "HP", ALC260_HP),
4593 SND_PCI_QUIRK(0x103c, 0x3016, "HP", ALC260_HP),
4594 SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_BASIC),
4595 SND_PCI_QUIRK(0x104d, 0x81cc, "Sony VAIO", ALC260_BASIC),
4596 SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC),
4597 SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X),
4598 SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC),
4599 SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_WILL),
4600 SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_REPLACER_672V),
4604 static struct alc_config_preset alc260_presets[] = {
4606 .mixers = { alc260_base_output_mixer,
4608 alc260_pc_beep_mixer,
4609 alc260_capture_mixer },
4610 .init_verbs = { alc260_init_verbs },
4611 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4612 .dac_nids = alc260_dac_nids,
4613 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
4614 .adc_nids = alc260_adc_nids,
4615 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4616 .channel_mode = alc260_modes,
4617 .input_mux = &alc260_capture_source,
4620 .mixers = { alc260_base_output_mixer,
4622 alc260_capture_alt_mixer },
4623 .init_verbs = { alc260_init_verbs },
4624 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4625 .dac_nids = alc260_dac_nids,
4626 .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
4627 .adc_nids = alc260_hp_adc_nids,
4628 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4629 .channel_mode = alc260_modes,
4630 .input_mux = &alc260_capture_source,
4632 [ALC260_HP_3013] = {
4633 .mixers = { alc260_hp_3013_mixer,
4635 alc260_capture_alt_mixer },
4636 .init_verbs = { alc260_hp_3013_init_verbs },
4637 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4638 .dac_nids = alc260_dac_nids,
4639 .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
4640 .adc_nids = alc260_hp_adc_nids,
4641 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4642 .channel_mode = alc260_modes,
4643 .input_mux = &alc260_capture_source,
4645 [ALC260_FUJITSU_S702X] = {
4646 .mixers = { alc260_fujitsu_mixer,
4647 alc260_capture_mixer },
4648 .init_verbs = { alc260_fujitsu_init_verbs },
4649 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4650 .dac_nids = alc260_dac_nids,
4651 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
4652 .adc_nids = alc260_dual_adc_nids,
4653 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4654 .channel_mode = alc260_modes,
4655 .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources),
4656 .input_mux = alc260_fujitsu_capture_sources,
4659 .mixers = { alc260_acer_mixer,
4660 alc260_capture_mixer },
4661 .init_verbs = { alc260_acer_init_verbs },
4662 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4663 .dac_nids = alc260_dac_nids,
4664 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
4665 .adc_nids = alc260_dual_adc_nids,
4666 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4667 .channel_mode = alc260_modes,
4668 .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
4669 .input_mux = alc260_acer_capture_sources,
4672 .mixers = { alc260_will_mixer,
4673 alc260_capture_mixer },
4674 .init_verbs = { alc260_init_verbs, alc260_will_verbs },
4675 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4676 .dac_nids = alc260_dac_nids,
4677 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
4678 .adc_nids = alc260_adc_nids,
4679 .dig_out_nid = ALC260_DIGOUT_NID,
4680 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4681 .channel_mode = alc260_modes,
4682 .input_mux = &alc260_capture_source,
4684 [ALC260_REPLACER_672V] = {
4685 .mixers = { alc260_replacer_672v_mixer,
4686 alc260_capture_mixer },
4687 .init_verbs = { alc260_init_verbs, alc260_replacer_672v_verbs },
4688 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4689 .dac_nids = alc260_dac_nids,
4690 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
4691 .adc_nids = alc260_adc_nids,
4692 .dig_out_nid = ALC260_DIGOUT_NID,
4693 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4694 .channel_mode = alc260_modes,
4695 .input_mux = &alc260_capture_source,
4696 .unsol_event = alc260_replacer_672v_unsol_event,
4697 .init_hook = alc260_replacer_672v_automute,
4699 #ifdef CONFIG_SND_DEBUG
4701 .mixers = { alc260_test_mixer,
4702 alc260_capture_mixer },
4703 .init_verbs = { alc260_test_init_verbs },
4704 .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
4705 .dac_nids = alc260_test_dac_nids,
4706 .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
4707 .adc_nids = alc260_test_adc_nids,
4708 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4709 .channel_mode = alc260_modes,
4710 .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources),
4711 .input_mux = alc260_test_capture_sources,
4716 static int patch_alc260(struct hda_codec *codec)
4718 struct alc_spec *spec;
4719 int err, board_config;
4721 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4727 board_config = snd_hda_check_board_config(codec, ALC260_MODEL_LAST,
4730 if (board_config < 0) {
4731 snd_printd(KERN_INFO "hda_codec: Unknown model for ALC260, "
4732 "trying auto-probe from BIOS...\n");
4733 board_config = ALC260_AUTO;
4736 if (board_config == ALC260_AUTO) {
4737 /* automatic parse from the BIOS config */
4738 err = alc260_parse_auto_config(codec);
4744 "hda_codec: Cannot set up configuration "
4745 "from BIOS. Using base mode...\n");
4746 board_config = ALC260_BASIC;
4750 if (board_config != ALC260_AUTO)
4751 setup_preset(spec, &alc260_presets[board_config]);
4753 spec->stream_name_analog = "ALC260 Analog";
4754 spec->stream_analog_playback = &alc260_pcm_analog_playback;
4755 spec->stream_analog_capture = &alc260_pcm_analog_capture;
4757 spec->stream_name_digital = "ALC260 Digital";
4758 spec->stream_digital_playback = &alc260_pcm_digital_playback;
4759 spec->stream_digital_capture = &alc260_pcm_digital_capture;
4761 codec->patch_ops = alc_patch_ops;
4762 if (board_config == ALC260_AUTO)
4763 spec->init_hook = alc260_auto_init;
4764 #ifdef CONFIG_SND_HDA_POWER_SAVE
4765 if (!spec->loopback.amplist)
4766 spec->loopback.amplist = alc260_loopbacks;
4776 * ALC882 is almost identical with ALC880 but has cleaner and more flexible
4777 * configuration. Each pin widget can choose any input DACs and a mixer.
4778 * Each ADC is connected from a mixer of all inputs. This makes possible
4779 * 6-channel independent captures.
4781 * In addition, an independent DAC for the multi-playback (not used in this
4784 #define ALC882_DIGOUT_NID 0x06
4785 #define ALC882_DIGIN_NID 0x0a
4787 static struct hda_channel_mode alc882_ch_modes[1] = {
4791 static hda_nid_t alc882_dac_nids[4] = {
4792 /* front, rear, clfe, rear_surr */
4793 0x02, 0x03, 0x04, 0x05
4796 /* identical with ALC880 */
4797 #define alc882_adc_nids alc880_adc_nids
4798 #define alc882_adc_nids_alt alc880_adc_nids_alt
4801 /* FIXME: should be a matrix-type input source selection */
4803 static struct hda_input_mux alc882_capture_source = {
4807 { "Front Mic", 0x1 },
4812 #define alc882_mux_enum_info alc_mux_enum_info
4813 #define alc882_mux_enum_get alc_mux_enum_get
4815 static int alc882_mux_enum_put(struct snd_kcontrol *kcontrol,
4816 struct snd_ctl_elem_value *ucontrol)
4818 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4819 struct alc_spec *spec = codec->spec;
4820 const struct hda_input_mux *imux = spec->input_mux;
4821 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
4822 static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
4823 hda_nid_t nid = capture_mixers[adc_idx];
4824 unsigned int *cur_val = &spec->cur_mux[adc_idx];
4825 unsigned int i, idx;
4827 idx = ucontrol->value.enumerated.item[0];
4828 if (idx >= imux->num_items)
4829 idx = imux->num_items - 1;
4830 if (*cur_val == idx)
4832 for (i = 0; i < imux->num_items; i++) {
4833 unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
4834 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
4835 imux->items[i].index,
4845 static struct hda_verb alc882_3ST_ch2_init[] = {
4846 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
4847 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
4848 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
4849 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
4856 static struct hda_verb alc882_3ST_ch6_init[] = {
4857 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4858 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
4859 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
4860 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4861 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
4862 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
4866 static struct hda_channel_mode alc882_3ST_6ch_modes[2] = {
4867 { 2, alc882_3ST_ch2_init },
4868 { 6, alc882_3ST_ch6_init },
4874 static struct hda_verb alc882_sixstack_ch6_init[] = {
4875 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
4876 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4877 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4878 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4885 static struct hda_verb alc882_sixstack_ch8_init[] = {
4886 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4887 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4888 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4889 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4893 static struct hda_channel_mode alc882_sixstack_modes[2] = {
4894 { 6, alc882_sixstack_ch6_init },
4895 { 8, alc882_sixstack_ch8_init },
4898 /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
4899 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
4901 static struct snd_kcontrol_new alc882_base_mixer[] = {
4902 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
4903 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
4904 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
4905 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
4906 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
4907 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
4908 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
4909 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
4910 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
4911 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
4912 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
4913 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
4914 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
4915 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
4916 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
4917 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
4918 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
4919 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
4920 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
4921 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
4922 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
4923 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
4924 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
4928 static struct snd_kcontrol_new alc882_w2jc_mixer[] = {
4929 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
4930 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
4931 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
4932 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
4933 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
4934 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
4935 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
4936 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
4937 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
4938 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
4939 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
4943 static struct snd_kcontrol_new alc882_targa_mixer[] = {
4944 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
4945 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
4946 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
4947 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
4948 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
4949 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
4950 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
4951 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
4952 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
4953 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
4954 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
4958 /* Pin assignment: Front=0x14, HP = 0x15, Front = 0x16, ???
4959 * Front Mic=0x18, Line In = 0x1a, Line In = 0x1b, CD = 0x1c
4961 static struct snd_kcontrol_new alc882_asus_a7j_mixer[] = {
4962 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
4963 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
4964 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
4965 HDA_CODEC_MUTE("Mobile Front Playback Switch", 0x16, 0x0, HDA_OUTPUT),
4966 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
4967 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
4968 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
4969 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
4970 HDA_CODEC_VOLUME("Mobile Line Playback Volume", 0x0b, 0x03, HDA_INPUT),
4971 HDA_CODEC_MUTE("Mobile Line Playback Switch", 0x0b, 0x03, HDA_INPUT),
4972 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
4973 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
4977 static struct snd_kcontrol_new alc882_chmode_mixer[] = {
4979 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4980 .name = "Channel Mode",
4981 .info = alc_ch_mode_info,
4982 .get = alc_ch_mode_get,
4983 .put = alc_ch_mode_put,
4988 static struct hda_verb alc882_init_verbs[] = {
4989 /* Front mixer: unmute input/output amp left and right (volume = 0) */
4990 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4991 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4992 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4994 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4995 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4996 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4998 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4999 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5000 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5002 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5003 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5004 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5006 /* Front Pin: output 0 (0x0c) */
5007 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5008 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5009 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
5010 /* Rear Pin: output 1 (0x0d) */
5011 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5012 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5013 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
5014 /* CLFE Pin: output 2 (0x0e) */
5015 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5016 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5017 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
5018 /* Side Pin: output 3 (0x0f) */
5019 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5020 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5021 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
5022 /* Mic (rear) pin: input vref at 80% */
5023 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5024 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5025 /* Front Mic pin: input vref at 80% */
5026 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5027 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5028 /* Line In pin: input */
5029 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
5030 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5031 /* Line-2 In: Headphone output (output 0 - 0x0c) */
5032 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5033 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5034 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
5035 /* CD pin widget for input */
5036 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
5038 /* FIXME: use matrix-type input source selection */
5039 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5040 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
5041 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5042 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5043 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5044 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5046 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5047 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5048 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5049 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5051 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5052 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5053 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5054 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5055 /* ADC1: mute amp left and right */
5056 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5057 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
5058 /* ADC2: mute amp left and right */
5059 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5060 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
5061 /* ADC3: mute amp left and right */
5062 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5063 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
5068 static struct hda_verb alc882_eapd_verbs[] = {
5069 /* change to EAPD mode */
5070 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
5071 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
5076 static struct snd_kcontrol_new alc882_macpro_mixer[] = {
5077 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5078 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5079 HDA_CODEC_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT),
5080 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
5081 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
5082 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x02, HDA_INPUT),
5083 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x02, HDA_INPUT),
5087 static struct hda_verb alc882_macpro_init_verbs[] = {
5088 /* Front mixer: unmute input/output amp left and right (volume = 0) */
5089 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5090 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5091 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5092 /* Front Pin: output 0 (0x0c) */
5093 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5094 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5095 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
5096 /* Front Mic pin: input vref at 80% */
5097 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5098 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5099 /* Speaker: output */
5100 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5101 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5102 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x04},
5103 /* Headphone output (output 0 - 0x0c) */
5104 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5105 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5106 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
5108 /* FIXME: use matrix-type input source selection */
5109 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5110 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
5111 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5112 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5113 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5114 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5116 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5117 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5118 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5119 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5121 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5122 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5123 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5124 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5125 /* ADC1: mute amp left and right */
5126 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5127 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
5128 /* ADC2: mute amp left and right */
5129 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5130 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
5131 /* ADC3: mute amp left and right */
5132 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5133 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
5138 /* iMac 24 mixer. */
5139 static struct snd_kcontrol_new alc885_imac24_mixer[] = {
5140 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
5141 HDA_CODEC_MUTE("Master Playback Switch", 0x0c, 0x00, HDA_INPUT),
5145 /* iMac 24 init verbs. */
5146 static struct hda_verb alc885_imac24_init_verbs[] = {
5147 /* Internal speakers: output 0 (0x0c) */
5148 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5149 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5150 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
5151 /* Internal speakers: output 0 (0x0c) */
5152 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5153 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5154 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
5155 /* Headphone: output 0 (0x0c) */
5156 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5157 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5158 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
5159 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
5160 /* Front Mic: input vref at 80% */
5161 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5162 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5166 /* Toggle speaker-output according to the hp-jack state */
5167 static void alc885_imac24_automute(struct hda_codec *codec)
5169 unsigned int present;
5171 present = snd_hda_codec_read(codec, 0x14, 0,
5172 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
5173 snd_hda_codec_amp_stereo(codec, 0x18, HDA_OUTPUT, 0,
5174 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
5175 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_OUTPUT, 0,
5176 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
5179 /* Processes unsolicited events. */
5180 static void alc885_imac24_unsol_event(struct hda_codec *codec,
5183 /* Headphone insertion or removal. */
5184 if ((res >> 26) == ALC880_HP_EVENT)
5185 alc885_imac24_automute(codec);
5188 static struct hda_verb alc882_targa_verbs[] = {
5189 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5190 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5192 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5193 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5195 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
5196 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
5197 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
5199 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
5200 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
5201 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
5202 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
5206 /* toggle speaker-output according to the hp-jack state */
5207 static void alc882_targa_automute(struct hda_codec *codec)
5209 unsigned int present;
5211 present = snd_hda_codec_read(codec, 0x14, 0,
5212 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
5213 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
5214 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
5215 snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
5219 static void alc882_targa_unsol_event(struct hda_codec *codec, unsigned int res)
5221 /* Looks like the unsol event is incompatible with the standard
5222 * definition. 4bit tag is placed at 26 bit!
5224 if (((res >> 26) == ALC880_HP_EVENT)) {
5225 alc882_targa_automute(codec);
5229 static struct hda_verb alc882_asus_a7j_verbs[] = {
5230 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5231 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5233 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5234 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5235 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5237 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
5238 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
5239 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
5241 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
5242 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
5243 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
5247 static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
5249 unsigned int gpiostate, gpiomask, gpiodir;
5251 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
5252 AC_VERB_GET_GPIO_DATA, 0);
5255 gpiostate |= (1 << pin);
5257 gpiostate &= ~(1 << pin);
5259 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
5260 AC_VERB_GET_GPIO_MASK, 0);
5261 gpiomask |= (1 << pin);
5263 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
5264 AC_VERB_GET_GPIO_DIRECTION, 0);
5265 gpiodir |= (1 << pin);
5268 snd_hda_codec_write(codec, codec->afg, 0,
5269 AC_VERB_SET_GPIO_MASK, gpiomask);
5270 snd_hda_codec_write(codec, codec->afg, 0,
5271 AC_VERB_SET_GPIO_DIRECTION, gpiodir);
5275 snd_hda_codec_write(codec, codec->afg, 0,
5276 AC_VERB_SET_GPIO_DATA, gpiostate);
5279 /* set up GPIO at initialization */
5280 static void alc885_macpro_init_hook(struct hda_codec *codec)
5282 alc882_gpio_mute(codec, 0, 0);
5283 alc882_gpio_mute(codec, 1, 0);
5286 /* set up GPIO and update auto-muting at initialization */
5287 static void alc885_imac24_init_hook(struct hda_codec *codec)
5289 alc885_macpro_init_hook(codec);
5290 alc885_imac24_automute(codec);
5294 * generic initialization of ADC, input mixers and output mixers
5296 static struct hda_verb alc882_auto_init_verbs[] = {
5298 * Unmute ADC0-2 and set the default input to mic-in
5300 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
5301 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5302 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
5303 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5304 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
5305 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5307 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
5309 * Note: PASD motherboards uses the Line In 2 as the input for
5310 * front panel mic (mic 2)
5312 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
5313 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5314 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5315 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5316 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5317 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5320 * Set up output mixers (0x0c - 0x0f)
5322 /* set vol=0 to output mixers */
5323 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5324 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5325 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5326 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5327 /* set up input amps for analog loopback */
5328 /* Amp Indices: DAC = 0, mixer = 1 */
5329 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5330 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5331 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5332 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5333 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5334 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5335 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5336 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5337 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5338 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5340 /* FIXME: use matrix-type input source selection */
5341 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5342 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
5343 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5344 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
5345 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
5346 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
5348 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5349 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
5350 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
5351 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
5353 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5354 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
5355 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
5356 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
5361 /* capture mixer elements */
5362 static struct snd_kcontrol_new alc882_capture_alt_mixer[] = {
5363 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
5364 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
5365 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
5366 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
5368 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5369 /* The multiple "Capture Source" controls confuse alsamixer
5370 * So call somewhat different..
5371 * FIXME: the controls appear in the "playback" view!
5373 /* .name = "Capture Source", */
5374 .name = "Input Source",
5376 .info = alc882_mux_enum_info,
5377 .get = alc882_mux_enum_get,
5378 .put = alc882_mux_enum_put,
5383 static struct snd_kcontrol_new alc882_capture_mixer[] = {
5384 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
5385 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
5386 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
5387 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
5388 HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
5389 HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
5391 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5392 /* The multiple "Capture Source" controls confuse alsamixer
5393 * So call somewhat different..
5394 * FIXME: the controls appear in the "playback" view!
5396 /* .name = "Capture Source", */
5397 .name = "Input Source",
5399 .info = alc882_mux_enum_info,
5400 .get = alc882_mux_enum_get,
5401 .put = alc882_mux_enum_put,
5406 #ifdef CONFIG_SND_HDA_POWER_SAVE
5407 #define alc882_loopbacks alc880_loopbacks
5410 /* pcm configuration: identiacal with ALC880 */
5411 #define alc882_pcm_analog_playback alc880_pcm_analog_playback
5412 #define alc882_pcm_analog_capture alc880_pcm_analog_capture
5413 #define alc882_pcm_digital_playback alc880_pcm_digital_playback
5414 #define alc882_pcm_digital_capture alc880_pcm_digital_capture
5417 * configuration and preset
5419 static const char *alc882_models[ALC882_MODEL_LAST] = {
5420 [ALC882_3ST_DIG] = "3stack-dig",
5421 [ALC882_6ST_DIG] = "6stack-dig",
5422 [ALC882_ARIMA] = "arima",
5423 [ALC882_W2JC] = "w2jc",
5424 [ALC885_MACPRO] = "macpro",
5425 [ALC885_IMAC24] = "imac24",
5426 [ALC882_AUTO] = "auto",
5429 static struct snd_pci_quirk alc882_cfg_tbl[] = {
5430 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG),
5431 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG),
5432 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG),
5433 SND_PCI_QUIRK(0x1462, 0x28fb, "Targa T8", ALC882_TARGA), /* MSI-1049 T8 */
5434 SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA),
5435 SND_PCI_QUIRK(0x1043, 0x060d, "Asus A7J", ALC882_ASUS_A7J),
5436 SND_PCI_QUIRK(0x1043, 0x817f, "Asus P5LD2", ALC882_6ST_DIG),
5437 SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG),
5438 SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_W2JC),
5442 static struct alc_config_preset alc882_presets[] = {
5443 [ALC882_3ST_DIG] = {
5444 .mixers = { alc882_base_mixer },
5445 .init_verbs = { alc882_init_verbs },
5446 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5447 .dac_nids = alc882_dac_nids,
5448 .dig_out_nid = ALC882_DIGOUT_NID,
5449 .dig_in_nid = ALC882_DIGIN_NID,
5450 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
5451 .channel_mode = alc882_ch_modes,
5453 .input_mux = &alc882_capture_source,
5455 [ALC882_6ST_DIG] = {
5456 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
5457 .init_verbs = { alc882_init_verbs },
5458 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5459 .dac_nids = alc882_dac_nids,
5460 .dig_out_nid = ALC882_DIGOUT_NID,
5461 .dig_in_nid = ALC882_DIGIN_NID,
5462 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
5463 .channel_mode = alc882_sixstack_modes,
5464 .input_mux = &alc882_capture_source,
5467 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
5468 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs },
5469 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5470 .dac_nids = alc882_dac_nids,
5471 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
5472 .channel_mode = alc882_sixstack_modes,
5473 .input_mux = &alc882_capture_source,
5476 .mixers = { alc882_w2jc_mixer, alc882_chmode_mixer },
5477 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs,
5478 alc880_gpio1_init_verbs },
5479 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5480 .dac_nids = alc882_dac_nids,
5481 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
5482 .channel_mode = alc880_threestack_modes,
5484 .input_mux = &alc882_capture_source,
5485 .dig_out_nid = ALC882_DIGOUT_NID,
5488 .mixers = { alc882_macpro_mixer },
5489 .init_verbs = { alc882_macpro_init_verbs },
5490 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5491 .dac_nids = alc882_dac_nids,
5492 .dig_out_nid = ALC882_DIGOUT_NID,
5493 .dig_in_nid = ALC882_DIGIN_NID,
5494 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
5495 .channel_mode = alc882_ch_modes,
5496 .input_mux = &alc882_capture_source,
5497 .init_hook = alc885_macpro_init_hook,
5500 .mixers = { alc885_imac24_mixer },
5501 .init_verbs = { alc885_imac24_init_verbs },
5502 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5503 .dac_nids = alc882_dac_nids,
5504 .dig_out_nid = ALC882_DIGOUT_NID,
5505 .dig_in_nid = ALC882_DIGIN_NID,
5506 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
5507 .channel_mode = alc882_ch_modes,
5508 .input_mux = &alc882_capture_source,
5509 .unsol_event = alc885_imac24_unsol_event,
5510 .init_hook = alc885_imac24_init_hook,
5513 .mixers = { alc882_targa_mixer, alc882_chmode_mixer,
5514 alc882_capture_mixer },
5515 .init_verbs = { alc882_init_verbs, alc882_targa_verbs},
5516 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5517 .dac_nids = alc882_dac_nids,
5518 .dig_out_nid = ALC882_DIGOUT_NID,
5519 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
5520 .adc_nids = alc882_adc_nids,
5521 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
5522 .channel_mode = alc882_3ST_6ch_modes,
5524 .input_mux = &alc882_capture_source,
5525 .unsol_event = alc882_targa_unsol_event,
5526 .init_hook = alc882_targa_automute,
5528 [ALC882_ASUS_A7J] = {
5529 .mixers = { alc882_asus_a7j_mixer, alc882_chmode_mixer,
5530 alc882_capture_mixer },
5531 .init_verbs = { alc882_init_verbs, alc882_asus_a7j_verbs},
5532 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5533 .dac_nids = alc882_dac_nids,
5534 .dig_out_nid = ALC882_DIGOUT_NID,
5535 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
5536 .adc_nids = alc882_adc_nids,
5537 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
5538 .channel_mode = alc882_3ST_6ch_modes,
5540 .input_mux = &alc882_capture_source,
5549 PINFIX_ABIT_AW9D_MAX
5552 static struct alc_pincfg alc882_abit_aw9d_pinfix[] = {
5553 { 0x15, 0x01080104 }, /* side */
5554 { 0x16, 0x01011012 }, /* rear */
5555 { 0x17, 0x01016011 }, /* clfe */
5559 static const struct alc_pincfg *alc882_pin_fixes[] = {
5560 [PINFIX_ABIT_AW9D_MAX] = alc882_abit_aw9d_pinfix,
5563 static struct snd_pci_quirk alc882_pinfix_tbl[] = {
5564 SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", PINFIX_ABIT_AW9D_MAX),
5569 * BIOS auto configuration
5571 static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
5572 hda_nid_t nid, int pin_type,
5576 struct alc_spec *spec = codec->spec;
5579 if (spec->multiout.dac_nids[dac_idx] == 0x25)
5582 idx = spec->multiout.dac_nids[dac_idx] - 2;
5584 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5586 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
5588 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
5592 static void alc882_auto_init_multi_out(struct hda_codec *codec)
5594 struct alc_spec *spec = codec->spec;
5597 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
5598 for (i = 0; i <= HDA_SIDE; i++) {
5599 hda_nid_t nid = spec->autocfg.line_out_pins[i];
5600 int pin_type = get_pin_type(spec->autocfg.line_out_type);
5602 alc882_auto_set_output_and_unmute(codec, nid, pin_type,
5607 static void alc882_auto_init_hp_out(struct hda_codec *codec)
5609 struct alc_spec *spec = codec->spec;
5612 pin = spec->autocfg.hp_pins[0];
5613 if (pin) /* connect to front */
5615 alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
5618 #define alc882_is_input_pin(nid) alc880_is_input_pin(nid)
5619 #define ALC882_PIN_CD_NID ALC880_PIN_CD_NID
5621 static void alc882_auto_init_analog_input(struct hda_codec *codec)
5623 struct alc_spec *spec = codec->spec;
5626 for (i = 0; i < AUTO_PIN_LAST; i++) {
5627 hda_nid_t nid = spec->autocfg.input_pins[i];
5628 if (alc882_is_input_pin(nid)) {
5629 snd_hda_codec_write(codec, nid, 0,
5630 AC_VERB_SET_PIN_WIDGET_CONTROL,
5631 i <= AUTO_PIN_FRONT_MIC ?
5632 PIN_VREF80 : PIN_IN);
5633 if (nid != ALC882_PIN_CD_NID)
5634 snd_hda_codec_write(codec, nid, 0,
5635 AC_VERB_SET_AMP_GAIN_MUTE,
5641 /* almost identical with ALC880 parser... */
5642 static int alc882_parse_auto_config(struct hda_codec *codec)
5644 struct alc_spec *spec = codec->spec;
5645 int err = alc880_parse_auto_config(codec);
5650 /* hack - override the init verbs */
5651 spec->init_verbs[0] = alc882_auto_init_verbs;
5655 /* additional initialization for auto-configuration model */
5656 static void alc882_auto_init(struct hda_codec *codec)
5658 alc882_auto_init_multi_out(codec);
5659 alc882_auto_init_hp_out(codec);
5660 alc882_auto_init_analog_input(codec);
5663 static int patch_alc882(struct hda_codec *codec)
5665 struct alc_spec *spec;
5666 int err, board_config;
5668 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5674 board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST,
5678 if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
5679 /* Pick up systems that don't supply PCI SSID */
5680 switch (codec->subsystem_id) {
5681 case 0x106b0c00: /* Mac Pro */
5682 board_config = ALC885_MACPRO;
5684 case 0x106b1000: /* iMac 24 */
5685 board_config = ALC885_IMAC24;
5688 printk(KERN_INFO "hda_codec: Unknown model for ALC882, "
5689 "trying auto-probe from BIOS...\n");
5690 board_config = ALC882_AUTO;
5694 alc_fix_pincfg(codec, alc882_pinfix_tbl, alc882_pin_fixes);
5696 if (board_config == ALC882_AUTO) {
5697 /* automatic parse from the BIOS config */
5698 err = alc882_parse_auto_config(codec);
5704 "hda_codec: Cannot set up configuration "
5705 "from BIOS. Using base mode...\n");
5706 board_config = ALC882_3ST_DIG;
5710 if (board_config != ALC882_AUTO)
5711 setup_preset(spec, &alc882_presets[board_config]);
5713 spec->stream_name_analog = "ALC882 Analog";
5714 spec->stream_analog_playback = &alc882_pcm_analog_playback;
5715 spec->stream_analog_capture = &alc882_pcm_analog_capture;
5717 spec->stream_name_digital = "ALC882 Digital";
5718 spec->stream_digital_playback = &alc882_pcm_digital_playback;
5719 spec->stream_digital_capture = &alc882_pcm_digital_capture;
5721 if (!spec->adc_nids && spec->input_mux) {
5722 /* check whether NID 0x07 is valid */
5723 unsigned int wcap = get_wcaps(codec, 0x07);
5725 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
5726 if (wcap != AC_WID_AUD_IN) {
5727 spec->adc_nids = alc882_adc_nids_alt;
5728 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids_alt);
5729 spec->mixers[spec->num_mixers] =
5730 alc882_capture_alt_mixer;
5733 spec->adc_nids = alc882_adc_nids;
5734 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids);
5735 spec->mixers[spec->num_mixers] = alc882_capture_mixer;
5740 codec->patch_ops = alc_patch_ops;
5741 if (board_config == ALC882_AUTO)
5742 spec->init_hook = alc882_auto_init;
5743 #ifdef CONFIG_SND_HDA_POWER_SAVE
5744 if (!spec->loopback.amplist)
5745 spec->loopback.amplist = alc882_loopbacks;
5754 * ALC883 is almost identical with ALC880 but has cleaner and more flexible
5755 * configuration. Each pin widget can choose any input DACs and a mixer.
5756 * Each ADC is connected from a mixer of all inputs. This makes possible
5757 * 6-channel independent captures.
5759 * In addition, an independent DAC for the multi-playback (not used in this
5762 #define ALC883_DIGOUT_NID 0x06
5763 #define ALC883_DIGIN_NID 0x0a
5765 static hda_nid_t alc883_dac_nids[4] = {
5766 /* front, rear, clfe, rear_surr */
5767 0x02, 0x04, 0x03, 0x05
5770 static hda_nid_t alc883_adc_nids[2] = {
5776 /* FIXME: should be a matrix-type input source selection */
5778 static struct hda_input_mux alc883_capture_source = {
5782 { "Front Mic", 0x1 },
5788 static struct hda_input_mux alc883_lenovo_101e_capture_source = {
5796 static struct hda_input_mux alc883_lenovo_nb0763_capture_source = {
5806 #define alc883_mux_enum_info alc_mux_enum_info
5807 #define alc883_mux_enum_get alc_mux_enum_get
5809 static int alc883_mux_enum_put(struct snd_kcontrol *kcontrol,
5810 struct snd_ctl_elem_value *ucontrol)
5812 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
5813 struct alc_spec *spec = codec->spec;
5814 const struct hda_input_mux *imux = spec->input_mux;
5815 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
5816 static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
5817 hda_nid_t nid = capture_mixers[adc_idx];
5818 unsigned int *cur_val = &spec->cur_mux[adc_idx];
5819 unsigned int i, idx;
5821 idx = ucontrol->value.enumerated.item[0];
5822 if (idx >= imux->num_items)
5823 idx = imux->num_items - 1;
5824 if (*cur_val == idx)
5826 for (i = 0; i < imux->num_items; i++) {
5827 unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
5828 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
5829 imux->items[i].index,
5839 static struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
5846 static struct hda_verb alc883_3ST_ch2_init[] = {
5847 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
5848 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
5849 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
5850 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
5857 static struct hda_verb alc883_3ST_ch6_init[] = {
5858 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5859 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
5860 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
5861 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5862 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
5863 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
5867 static struct hda_channel_mode alc883_3ST_6ch_modes[2] = {
5868 { 2, alc883_3ST_ch2_init },
5869 { 6, alc883_3ST_ch6_init },
5875 static struct hda_verb alc883_sixstack_ch6_init[] = {
5876 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
5877 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5878 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5879 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5886 static struct hda_verb alc883_sixstack_ch8_init[] = {
5887 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5888 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5889 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5890 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5894 static struct hda_channel_mode alc883_sixstack_modes[2] = {
5895 { 6, alc883_sixstack_ch6_init },
5896 { 8, alc883_sixstack_ch8_init },
5899 static struct hda_verb alc883_medion_eapd_verbs[] = {
5900 /* eanable EAPD on medion laptop */
5901 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
5902 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
5906 /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
5907 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
5910 static struct snd_kcontrol_new alc883_base_mixer[] = {
5911 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5912 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5913 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
5914 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
5915 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
5916 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
5917 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
5918 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
5919 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
5920 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
5921 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5922 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5923 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5924 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5925 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5926 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5927 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
5928 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5929 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
5930 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
5931 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
5932 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
5933 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
5934 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
5935 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
5936 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
5937 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
5939 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5940 /* .name = "Capture Source", */
5941 .name = "Input Source",
5943 .info = alc883_mux_enum_info,
5944 .get = alc883_mux_enum_get,
5945 .put = alc883_mux_enum_put,
5950 static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
5951 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5952 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5953 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5954 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5955 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5956 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5957 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5958 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5959 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
5960 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5961 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
5962 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
5963 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
5964 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
5965 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
5966 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
5967 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
5968 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
5969 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
5971 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5972 /* .name = "Capture Source", */
5973 .name = "Input Source",
5975 .info = alc883_mux_enum_info,
5976 .get = alc883_mux_enum_get,
5977 .put = alc883_mux_enum_put,
5982 static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
5983 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5984 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5985 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
5986 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
5987 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
5988 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
5989 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
5990 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
5991 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5992 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5993 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5994 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5995 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5996 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5997 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
5998 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5999 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6000 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
6001 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6002 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6003 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6004 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6005 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6006 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6007 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6009 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6010 /* .name = "Capture Source", */
6011 .name = "Input Source",
6013 .info = alc883_mux_enum_info,
6014 .get = alc883_mux_enum_get,
6015 .put = alc883_mux_enum_put,
6020 static struct snd_kcontrol_new alc883_fivestack_mixer[] = {
6021 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6022 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6023 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
6024 HDA_CODEC_MUTE("Surround Playback Switch", 0x15, 0x0, HDA_OUTPUT),
6025 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
6026 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
6027 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x16, 1, 0x0, HDA_OUTPUT),
6028 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
6029 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6030 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6031 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6032 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6033 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6034 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6035 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6036 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6037 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6038 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
6039 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6040 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6041 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6042 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6043 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6046 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6047 /* .name = "Capture Source", */
6048 .name = "Input Source",
6050 .info = alc883_mux_enum_info,
6051 .get = alc883_mux_enum_get,
6052 .put = alc883_mux_enum_put,
6057 static struct snd_kcontrol_new alc883_tagra_mixer[] = {
6058 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6059 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6060 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6061 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
6062 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
6063 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
6064 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
6065 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
6066 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
6067 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6068 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6069 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6070 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6071 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6072 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6073 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6074 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6075 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6076 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6077 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6079 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6080 /* .name = "Capture Source", */
6081 .name = "Input Source",
6083 .info = alc883_mux_enum_info,
6084 .get = alc883_mux_enum_get,
6085 .put = alc883_mux_enum_put,
6090 static struct snd_kcontrol_new alc883_tagra_2ch_mixer[] = {
6091 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6092 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6093 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6094 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6095 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6096 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6097 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6098 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6099 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6100 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6101 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6102 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6104 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6105 /* .name = "Capture Source", */
6106 .name = "Input Source",
6108 .info = alc883_mux_enum_info,
6109 .get = alc883_mux_enum_get,
6110 .put = alc883_mux_enum_put,
6115 static struct snd_kcontrol_new alc883_lenovo_101e_2ch_mixer[] = {
6116 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6117 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6118 HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
6119 HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT),
6120 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6121 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6122 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6123 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6124 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6125 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6127 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6128 /* .name = "Capture Source", */
6129 .name = "Input Source",
6131 .info = alc883_mux_enum_info,
6132 .get = alc883_mux_enum_get,
6133 .put = alc883_mux_enum_put,
6138 static struct snd_kcontrol_new alc883_lenovo_nb0763_mixer[] = {
6139 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6140 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
6141 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6142 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6143 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6144 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6145 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6146 HDA_CODEC_VOLUME("iMic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6147 HDA_CODEC_MUTE("iMic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6148 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6149 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6150 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6151 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6153 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6154 /* .name = "Capture Source", */
6155 .name = "Input Source",
6157 .info = alc883_mux_enum_info,
6158 .get = alc883_mux_enum_get,
6159 .put = alc883_mux_enum_put,
6164 static struct snd_kcontrol_new alc883_medion_md2_mixer[] = {
6165 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6166 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6167 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
6168 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6169 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6170 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6171 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6172 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6173 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6174 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6175 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6176 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6177 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6179 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6180 /* .name = "Capture Source", */
6181 .name = "Input Source",
6183 .info = alc883_mux_enum_info,
6184 .get = alc883_mux_enum_get,
6185 .put = alc883_mux_enum_put,
6190 static struct snd_kcontrol_new alc888_6st_hp_mixer[] = {
6191 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6192 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6193 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
6194 HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
6195 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
6196 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
6197 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
6198 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
6199 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
6200 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
6201 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6202 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6203 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6204 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6205 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6206 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6207 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6208 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6209 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6210 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
6211 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6212 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6213 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6214 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6215 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6216 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6217 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6219 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6220 /* .name = "Capture Source", */
6221 .name = "Input Source",
6223 .info = alc883_mux_enum_info,
6224 .get = alc883_mux_enum_get,
6225 .put = alc883_mux_enum_put,
6230 static struct snd_kcontrol_new alc888_3st_hp_mixer[] = {
6231 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6232 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6233 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
6234 HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
6235 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
6236 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
6237 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
6238 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
6239 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6240 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6241 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6242 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6243 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6244 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6245 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6246 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6247 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6248 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
6249 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6250 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6251 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6252 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6253 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6254 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6255 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6257 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6258 /* .name = "Capture Source", */
6259 .name = "Input Source",
6261 .info = alc883_mux_enum_info,
6262 .get = alc883_mux_enum_get,
6263 .put = alc883_mux_enum_put,
6268 static struct snd_kcontrol_new alc883_acer_aspire_mixer[] = {
6269 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6270 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6271 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6272 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6273 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6274 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6275 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6276 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6277 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6278 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6279 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6280 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6282 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6283 /* .name = "Capture Source", */
6284 .name = "Input Source",
6286 .info = alc883_mux_enum_info,
6287 .get = alc883_mux_enum_get,
6288 .put = alc883_mux_enum_put,
6293 static struct snd_kcontrol_new alc883_chmode_mixer[] = {
6295 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6296 .name = "Channel Mode",
6297 .info = alc_ch_mode_info,
6298 .get = alc_ch_mode_get,
6299 .put = alc_ch_mode_put,
6304 static struct hda_verb alc883_init_verbs[] = {
6305 /* ADC1: mute amp left and right */
6306 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6307 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6308 /* ADC2: mute amp left and right */
6309 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6310 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
6311 /* Front mixer: unmute input/output amp left and right (volume = 0) */
6312 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6313 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6314 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6316 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6317 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6318 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6320 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6321 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6322 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6324 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6325 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6326 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6328 /* mute analog input loopbacks */
6329 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6330 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6331 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6332 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6333 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6335 /* Front Pin: output 0 (0x0c) */
6336 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6337 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6338 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
6339 /* Rear Pin: output 1 (0x0d) */
6340 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6341 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6342 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
6343 /* CLFE Pin: output 2 (0x0e) */
6344 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6345 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6346 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
6347 /* Side Pin: output 3 (0x0f) */
6348 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6349 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6350 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
6351 /* Mic (rear) pin: input vref at 80% */
6352 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6353 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6354 /* Front Mic pin: input vref at 80% */
6355 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6356 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6357 /* Line In pin: input */
6358 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
6359 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6360 /* Line-2 In: Headphone output (output 0 - 0x0c) */
6361 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6362 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6363 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
6364 /* CD pin widget for input */
6365 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
6367 /* FIXME: use matrix-type input source selection */
6368 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6370 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6371 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6372 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
6373 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
6375 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6376 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6377 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
6378 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
6382 static struct hda_verb alc883_tagra_verbs[] = {
6383 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6384 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6386 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6387 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6389 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
6390 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
6391 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6393 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
6394 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
6395 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
6396 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
6401 static struct hda_verb alc883_lenovo_101e_verbs[] = {
6402 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
6403 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT|AC_USRSP_EN},
6404 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT|AC_USRSP_EN},
6408 static struct hda_verb alc883_lenovo_nb0763_verbs[] = {
6409 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
6410 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6411 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
6412 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6416 static struct hda_verb alc888_lenovo_ms7195_verbs[] = {
6417 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6418 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6419 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
6420 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT | AC_USRSP_EN},
6421 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
6425 static struct hda_verb alc888_6st_hp_verbs[] = {
6426 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
6427 {0x15, AC_VERB_SET_CONNECT_SEL, 0x02}, /* Rear : output 2 (0x0e) */
6428 {0x16, AC_VERB_SET_CONNECT_SEL, 0x01}, /* CLFE : output 1 (0x0d) */
6429 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03}, /* Side : output 3 (0x0f) */
6433 static struct hda_verb alc888_3st_hp_verbs[] = {
6434 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
6435 {0x18, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Rear : output 1 (0x0d) */
6436 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02}, /* CLFE : output 2 (0x0e) */
6440 static struct hda_verb alc888_3st_hp_2ch_init[] = {
6441 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6442 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6443 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6444 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6448 static struct hda_verb alc888_3st_hp_6ch_init[] = {
6449 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6450 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6451 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6452 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6456 static struct hda_channel_mode alc888_3st_hp_modes[2] = {
6457 { 2, alc888_3st_hp_2ch_init },
6458 { 6, alc888_3st_hp_6ch_init },
6461 /* toggle front-jack and RCA according to the hp-jack state */
6462 static void alc888_lenovo_ms7195_front_automute(struct hda_codec *codec)
6464 unsigned int present;
6466 present = snd_hda_codec_read(codec, 0x1b, 0,
6467 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
6468 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
6469 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
6470 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
6471 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
6474 /* toggle RCA according to the front-jack state */
6475 static void alc888_lenovo_ms7195_rca_automute(struct hda_codec *codec)
6477 unsigned int present;
6479 present = snd_hda_codec_read(codec, 0x14, 0,
6480 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
6481 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
6482 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
6485 static void alc883_lenovo_ms7195_unsol_event(struct hda_codec *codec,
6488 if ((res >> 26) == ALC880_HP_EVENT)
6489 alc888_lenovo_ms7195_front_automute(codec);
6490 if ((res >> 26) == ALC880_FRONT_EVENT)
6491 alc888_lenovo_ms7195_rca_automute(codec);
6494 static struct hda_verb alc883_medion_md2_verbs[] = {
6495 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6496 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6498 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6500 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
6504 /* toggle speaker-output according to the hp-jack state */
6505 static void alc883_medion_md2_automute(struct hda_codec *codec)
6507 unsigned int present;
6509 present = snd_hda_codec_read(codec, 0x14, 0,
6510 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
6511 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
6512 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
6515 static void alc883_medion_md2_unsol_event(struct hda_codec *codec,
6518 if ((res >> 26) == ALC880_HP_EVENT)
6519 alc883_medion_md2_automute(codec);
6522 /* toggle speaker-output according to the hp-jack state */
6523 static void alc883_tagra_automute(struct hda_codec *codec)
6525 unsigned int present;
6528 present = snd_hda_codec_read(codec, 0x14, 0,
6529 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
6530 bits = present ? HDA_AMP_MUTE : 0;
6531 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
6532 HDA_AMP_MUTE, bits);
6533 snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
6537 static void alc883_tagra_unsol_event(struct hda_codec *codec, unsigned int res)
6539 if ((res >> 26) == ALC880_HP_EVENT)
6540 alc883_tagra_automute(codec);
6543 static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
6545 unsigned int present;
6548 present = snd_hda_codec_read(codec, 0x14, 0,
6549 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
6550 bits = present ? HDA_AMP_MUTE : 0;
6551 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
6552 HDA_AMP_MUTE, bits);
6555 static void alc883_lenovo_101e_all_automute(struct hda_codec *codec)
6557 unsigned int present;
6560 present = snd_hda_codec_read(codec, 0x1b, 0,
6561 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
6562 bits = present ? HDA_AMP_MUTE : 0;
6563 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
6564 HDA_AMP_MUTE, bits);
6565 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
6566 HDA_AMP_MUTE, bits);
6569 static void alc883_lenovo_101e_unsol_event(struct hda_codec *codec,
6572 if ((res >> 26) == ALC880_HP_EVENT)
6573 alc883_lenovo_101e_all_automute(codec);
6574 if ((res >> 26) == ALC880_FRONT_EVENT)
6575 alc883_lenovo_101e_ispeaker_automute(codec);
6578 /* toggle speaker-output according to the hp-jack state */
6579 static void alc883_acer_aspire_automute(struct hda_codec *codec)
6581 unsigned int present;
6583 present = snd_hda_codec_read(codec, 0x14, 0,
6584 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
6585 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
6586 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
6587 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
6588 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
6591 static void alc883_acer_aspire_unsol_event(struct hda_codec *codec,
6594 if ((res >> 26) == ALC880_HP_EVENT)
6595 alc883_acer_aspire_automute(codec);
6598 static struct hda_verb alc883_acer_eapd_verbs[] = {
6599 /* HP Pin: output 0 (0x0c) */
6600 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6601 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6602 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
6603 /* Front Pin: output 0 (0x0c) */
6604 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6605 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
6606 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6607 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00},
6608 /* eanable EAPD on medion laptop */
6609 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
6610 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
6611 /* enable unsolicited event */
6612 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
6617 * generic initialization of ADC, input mixers and output mixers
6619 static struct hda_verb alc883_auto_init_verbs[] = {
6621 * Unmute ADC0-2 and set the default input to mic-in
6623 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6624 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6625 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
6626 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6628 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
6630 * Note: PASD motherboards uses the Line In 2 as the input for
6631 * front panel mic (mic 2)
6633 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
6634 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6635 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6636 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6637 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6638 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6641 * Set up output mixers (0x0c - 0x0f)
6643 /* set vol=0 to output mixers */
6644 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6645 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6646 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6647 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6648 /* set up input amps for analog loopback */
6649 /* Amp Indices: DAC = 0, mixer = 1 */
6650 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6651 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6652 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6653 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6654 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6655 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6656 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6657 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6658 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6659 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6661 /* FIXME: use matrix-type input source selection */
6662 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6664 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6665 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6666 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
6667 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
6668 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
6670 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6671 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6672 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
6673 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
6674 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
6679 /* capture mixer elements */
6680 static struct snd_kcontrol_new alc883_capture_mixer[] = {
6681 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6682 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6683 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6684 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6686 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6687 /* The multiple "Capture Source" controls confuse alsamixer
6688 * So call somewhat different..
6689 * FIXME: the controls appear in the "playback" view!
6691 /* .name = "Capture Source", */
6692 .name = "Input Source",
6694 .info = alc882_mux_enum_info,
6695 .get = alc882_mux_enum_get,
6696 .put = alc882_mux_enum_put,
6701 #ifdef CONFIG_SND_HDA_POWER_SAVE
6702 #define alc883_loopbacks alc880_loopbacks
6705 /* pcm configuration: identiacal with ALC880 */
6706 #define alc883_pcm_analog_playback alc880_pcm_analog_playback
6707 #define alc883_pcm_analog_capture alc880_pcm_analog_capture
6708 #define alc883_pcm_digital_playback alc880_pcm_digital_playback
6709 #define alc883_pcm_digital_capture alc880_pcm_digital_capture
6712 * configuration and preset
6714 static const char *alc883_models[ALC883_MODEL_LAST] = {
6715 [ALC883_3ST_2ch_DIG] = "3stack-dig",
6716 [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig",
6717 [ALC883_3ST_6ch] = "3stack-6ch",
6718 [ALC883_6ST_DIG] = "6stack-dig",
6719 [ALC883_TARGA_DIG] = "targa-dig",
6720 [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig",
6721 [ALC883_ACER] = "acer",
6722 [ALC883_ACER_ASPIRE] = "acer-aspire",
6723 [ALC883_MEDION] = "medion",
6724 [ALC883_MEDION_MD2] = "medion-md2",
6725 [ALC883_LAPTOP_EAPD] = "laptop-eapd",
6726 [ALC883_LENOVO_101E_2ch] = "lenovo-101e",
6727 [ALC883_LENOVO_NB0763] = "lenovo-nb0763",
6728 [ALC888_LENOVO_MS7195_DIG] = "lenovo-ms7195-dig",
6729 [ALC888_6ST_HP] = "6stack-hp",
6730 [ALC888_3ST_HP] = "3stack-hp",
6731 [ALC883_AUTO] = "auto",
6734 static struct snd_pci_quirk alc883_cfg_tbl[] = {
6735 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC883_3ST_6ch_DIG),
6736 SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG),
6737 SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch),
6738 SND_PCI_QUIRK(0x1558, 0, "Clevo laptop", ALC883_LAPTOP_EAPD),
6739 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC883_6ST_DIG),
6740 SND_PCI_QUIRK(0x1458, 0xa002, "MSI", ALC883_6ST_DIG),
6741 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG),
6742 SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG),
6743 SND_PCI_QUIRK(0x1462, 0x7250, "MSI", ALC883_6ST_DIG),
6744 SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG),
6745 SND_PCI_QUIRK(0x1462, 0x7327, "MSI", ALC883_6ST_DIG),
6746 SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG),
6747 SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG),
6748 SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG),
6749 SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG),
6750 SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG),
6751 SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG),
6752 SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG),
6753 SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG),
6754 SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG),
6755 SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG),
6756 SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG),
6757 SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG),
6758 SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_ACER_ASPIRE),
6759 SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_ACER_ASPIRE),
6760 SND_PCI_QUIRK(0x1025, 0, "Acer laptop", ALC883_ACER),
6761 SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch),
6762 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
6763 SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD),
6764 SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC883_3ST_6ch),
6765 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch),
6766 SND_PCI_QUIRK(0x17aa, 0x3bfd, "Lenovo NB0763", ALC883_LENOVO_NB0763),
6767 SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763),
6768 SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC888_6ST_HP),
6769 SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_3ST_HP),
6770 SND_PCI_QUIRK(0x103c, 0x2a4f, "HP Samba", ALC888_3ST_HP),
6771 SND_PCI_QUIRK(0x17c0, 0x4071, "MEDION MD2", ALC883_MEDION_MD2),
6775 static struct alc_config_preset alc883_presets[] = {
6776 [ALC883_3ST_2ch_DIG] = {
6777 .mixers = { alc883_3ST_2ch_mixer },
6778 .init_verbs = { alc883_init_verbs },
6779 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6780 .dac_nids = alc883_dac_nids,
6781 .dig_out_nid = ALC883_DIGOUT_NID,
6782 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6783 .adc_nids = alc883_adc_nids,
6784 .dig_in_nid = ALC883_DIGIN_NID,
6785 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
6786 .channel_mode = alc883_3ST_2ch_modes,
6787 .input_mux = &alc883_capture_source,
6789 [ALC883_3ST_6ch_DIG] = {
6790 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
6791 .init_verbs = { alc883_init_verbs },
6792 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6793 .dac_nids = alc883_dac_nids,
6794 .dig_out_nid = ALC883_DIGOUT_NID,
6795 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6796 .adc_nids = alc883_adc_nids,
6797 .dig_in_nid = ALC883_DIGIN_NID,
6798 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
6799 .channel_mode = alc883_3ST_6ch_modes,
6801 .input_mux = &alc883_capture_source,
6803 [ALC883_3ST_6ch] = {
6804 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
6805 .init_verbs = { alc883_init_verbs },
6806 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6807 .dac_nids = alc883_dac_nids,
6808 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6809 .adc_nids = alc883_adc_nids,
6810 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
6811 .channel_mode = alc883_3ST_6ch_modes,
6813 .input_mux = &alc883_capture_source,
6815 [ALC883_6ST_DIG] = {
6816 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
6817 .init_verbs = { alc883_init_verbs },
6818 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6819 .dac_nids = alc883_dac_nids,
6820 .dig_out_nid = ALC883_DIGOUT_NID,
6821 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6822 .adc_nids = alc883_adc_nids,
6823 .dig_in_nid = ALC883_DIGIN_NID,
6824 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
6825 .channel_mode = alc883_sixstack_modes,
6826 .input_mux = &alc883_capture_source,
6828 [ALC883_TARGA_DIG] = {
6829 .mixers = { alc883_tagra_mixer, alc883_chmode_mixer },
6830 .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
6831 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6832 .dac_nids = alc883_dac_nids,
6833 .dig_out_nid = ALC883_DIGOUT_NID,
6834 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6835 .adc_nids = alc883_adc_nids,
6836 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
6837 .channel_mode = alc883_3ST_6ch_modes,
6839 .input_mux = &alc883_capture_source,
6840 .unsol_event = alc883_tagra_unsol_event,
6841 .init_hook = alc883_tagra_automute,
6843 [ALC883_TARGA_2ch_DIG] = {
6844 .mixers = { alc883_tagra_2ch_mixer},
6845 .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
6846 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6847 .dac_nids = alc883_dac_nids,
6848 .dig_out_nid = ALC883_DIGOUT_NID,
6849 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6850 .adc_nids = alc883_adc_nids,
6851 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
6852 .channel_mode = alc883_3ST_2ch_modes,
6853 .input_mux = &alc883_capture_source,
6854 .unsol_event = alc883_tagra_unsol_event,
6855 .init_hook = alc883_tagra_automute,
6858 .mixers = { alc883_base_mixer },
6859 /* On TravelMate laptops, GPIO 0 enables the internal speaker
6860 * and the headphone jack. Turn this on and rely on the
6861 * standard mute methods whenever the user wants to turn
6862 * these outputs off.
6864 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs },
6865 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6866 .dac_nids = alc883_dac_nids,
6867 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6868 .adc_nids = alc883_adc_nids,
6869 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
6870 .channel_mode = alc883_3ST_2ch_modes,
6871 .input_mux = &alc883_capture_source,
6873 [ALC883_ACER_ASPIRE] = {
6874 .mixers = { alc883_acer_aspire_mixer },
6875 .init_verbs = { alc883_init_verbs, alc883_acer_eapd_verbs },
6876 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6877 .dac_nids = alc883_dac_nids,
6878 .dig_out_nid = ALC883_DIGOUT_NID,
6879 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6880 .adc_nids = alc883_adc_nids,
6881 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
6882 .channel_mode = alc883_3ST_2ch_modes,
6883 .input_mux = &alc883_capture_source,
6884 .unsol_event = alc883_acer_aspire_unsol_event,
6885 .init_hook = alc883_acer_aspire_automute,
6888 .mixers = { alc883_fivestack_mixer,
6889 alc883_chmode_mixer },
6890 .init_verbs = { alc883_init_verbs,
6891 alc883_medion_eapd_verbs },
6892 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6893 .dac_nids = alc883_dac_nids,
6894 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6895 .adc_nids = alc883_adc_nids,
6896 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
6897 .channel_mode = alc883_sixstack_modes,
6898 .input_mux = &alc883_capture_source,
6900 [ALC883_MEDION_MD2] = {
6901 .mixers = { alc883_medion_md2_mixer},
6902 .init_verbs = { alc883_init_verbs, alc883_medion_md2_verbs},
6903 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6904 .dac_nids = alc883_dac_nids,
6905 .dig_out_nid = ALC883_DIGOUT_NID,
6906 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6907 .adc_nids = alc883_adc_nids,
6908 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
6909 .channel_mode = alc883_3ST_2ch_modes,
6910 .input_mux = &alc883_capture_source,
6911 .unsol_event = alc883_medion_md2_unsol_event,
6912 .init_hook = alc883_medion_md2_automute,
6914 [ALC883_LAPTOP_EAPD] = {
6915 .mixers = { alc883_base_mixer },
6916 .init_verbs = { alc883_init_verbs, alc882_eapd_verbs },
6917 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6918 .dac_nids = alc883_dac_nids,
6919 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6920 .adc_nids = alc883_adc_nids,
6921 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
6922 .channel_mode = alc883_3ST_2ch_modes,
6923 .input_mux = &alc883_capture_source,
6925 [ALC883_LENOVO_101E_2ch] = {
6926 .mixers = { alc883_lenovo_101e_2ch_mixer},
6927 .init_verbs = { alc883_init_verbs, alc883_lenovo_101e_verbs},
6928 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6929 .dac_nids = alc883_dac_nids,
6930 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6931 .adc_nids = alc883_adc_nids,
6932 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
6933 .channel_mode = alc883_3ST_2ch_modes,
6934 .input_mux = &alc883_lenovo_101e_capture_source,
6935 .unsol_event = alc883_lenovo_101e_unsol_event,
6936 .init_hook = alc883_lenovo_101e_all_automute,
6938 [ALC883_LENOVO_NB0763] = {
6939 .mixers = { alc883_lenovo_nb0763_mixer },
6940 .init_verbs = { alc883_init_verbs, alc883_lenovo_nb0763_verbs},
6941 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6942 .dac_nids = alc883_dac_nids,
6943 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6944 .adc_nids = alc883_adc_nids,
6945 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
6946 .channel_mode = alc883_3ST_2ch_modes,
6948 .input_mux = &alc883_lenovo_nb0763_capture_source,
6949 .unsol_event = alc883_medion_md2_unsol_event,
6950 .init_hook = alc883_medion_md2_automute,
6952 [ALC888_LENOVO_MS7195_DIG] = {
6953 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
6954 .init_verbs = { alc883_init_verbs, alc888_lenovo_ms7195_verbs},
6955 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6956 .dac_nids = alc883_dac_nids,
6957 .dig_out_nid = ALC883_DIGOUT_NID,
6958 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6959 .adc_nids = alc883_adc_nids,
6960 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
6961 .channel_mode = alc883_3ST_6ch_modes,
6963 .input_mux = &alc883_capture_source,
6964 .unsol_event = alc883_lenovo_ms7195_unsol_event,
6965 .init_hook = alc888_lenovo_ms7195_front_automute,
6968 .mixers = { alc888_6st_hp_mixer, alc883_chmode_mixer },
6969 .init_verbs = { alc883_init_verbs, alc888_6st_hp_verbs },
6970 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6971 .dac_nids = alc883_dac_nids,
6972 .dig_out_nid = ALC883_DIGOUT_NID,
6973 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6974 .adc_nids = alc883_adc_nids,
6975 .dig_in_nid = ALC883_DIGIN_NID,
6976 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
6977 .channel_mode = alc883_sixstack_modes,
6978 .input_mux = &alc883_capture_source,
6981 .mixers = { alc888_3st_hp_mixer, alc883_chmode_mixer },
6982 .init_verbs = { alc883_init_verbs, alc888_3st_hp_verbs },
6983 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6984 .dac_nids = alc883_dac_nids,
6985 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6986 .adc_nids = alc883_adc_nids,
6987 .num_channel_mode = ARRAY_SIZE(alc888_3st_hp_modes),
6988 .channel_mode = alc888_3st_hp_modes,
6990 .input_mux = &alc883_capture_source,
6996 * BIOS auto configuration
6998 static void alc883_auto_set_output_and_unmute(struct hda_codec *codec,
6999 hda_nid_t nid, int pin_type,
7003 struct alc_spec *spec = codec->spec;
7006 if (spec->multiout.dac_nids[dac_idx] == 0x25)
7009 idx = spec->multiout.dac_nids[dac_idx] - 2;
7011 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
7013 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
7015 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
7019 static void alc883_auto_init_multi_out(struct hda_codec *codec)
7021 struct alc_spec *spec = codec->spec;
7024 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
7025 for (i = 0; i <= HDA_SIDE; i++) {
7026 hda_nid_t nid = spec->autocfg.line_out_pins[i];
7027 int pin_type = get_pin_type(spec->autocfg.line_out_type);
7029 alc883_auto_set_output_and_unmute(codec, nid, pin_type,
7034 static void alc883_auto_init_hp_out(struct hda_codec *codec)
7036 struct alc_spec *spec = codec->spec;
7039 pin = spec->autocfg.hp_pins[0];
7040 if (pin) /* connect to front */
7042 alc883_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
7045 #define alc883_is_input_pin(nid) alc880_is_input_pin(nid)
7046 #define ALC883_PIN_CD_NID ALC880_PIN_CD_NID
7048 static void alc883_auto_init_analog_input(struct hda_codec *codec)
7050 struct alc_spec *spec = codec->spec;
7053 for (i = 0; i < AUTO_PIN_LAST; i++) {
7054 hda_nid_t nid = spec->autocfg.input_pins[i];
7055 if (alc883_is_input_pin(nid)) {
7056 snd_hda_codec_write(codec, nid, 0,
7057 AC_VERB_SET_PIN_WIDGET_CONTROL,
7058 (i <= AUTO_PIN_FRONT_MIC ?
7059 PIN_VREF80 : PIN_IN));
7060 if (nid != ALC883_PIN_CD_NID)
7061 snd_hda_codec_write(codec, nid, 0,
7062 AC_VERB_SET_AMP_GAIN_MUTE,
7068 /* almost identical with ALC880 parser... */
7069 static int alc883_parse_auto_config(struct hda_codec *codec)
7071 struct alc_spec *spec = codec->spec;
7072 int err = alc880_parse_auto_config(codec);
7077 /* hack - override the init verbs */
7078 spec->init_verbs[0] = alc883_auto_init_verbs;
7079 spec->mixers[spec->num_mixers] = alc883_capture_mixer;
7084 /* additional initialization for auto-configuration model */
7085 static void alc883_auto_init(struct hda_codec *codec)
7087 alc883_auto_init_multi_out(codec);
7088 alc883_auto_init_hp_out(codec);
7089 alc883_auto_init_analog_input(codec);
7092 static int patch_alc883(struct hda_codec *codec)
7094 struct alc_spec *spec;
7095 int err, board_config;
7097 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
7103 board_config = snd_hda_check_board_config(codec, ALC883_MODEL_LAST,
7106 if (board_config < 0) {
7107 printk(KERN_INFO "hda_codec: Unknown model for ALC883, "
7108 "trying auto-probe from BIOS...\n");
7109 board_config = ALC883_AUTO;
7112 if (board_config == ALC883_AUTO) {
7113 /* automatic parse from the BIOS config */
7114 err = alc883_parse_auto_config(codec);
7120 "hda_codec: Cannot set up configuration "
7121 "from BIOS. Using base mode...\n");
7122 board_config = ALC883_3ST_2ch_DIG;
7126 if (board_config != ALC883_AUTO)
7127 setup_preset(spec, &alc883_presets[board_config]);
7129 spec->stream_name_analog = "ALC883 Analog";
7130 spec->stream_analog_playback = &alc883_pcm_analog_playback;
7131 spec->stream_analog_capture = &alc883_pcm_analog_capture;
7133 spec->stream_name_digital = "ALC883 Digital";
7134 spec->stream_digital_playback = &alc883_pcm_digital_playback;
7135 spec->stream_digital_capture = &alc883_pcm_digital_capture;
7137 if (!spec->adc_nids && spec->input_mux) {
7138 spec->adc_nids = alc883_adc_nids;
7139 spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids);
7142 codec->patch_ops = alc_patch_ops;
7143 if (board_config == ALC883_AUTO)
7144 spec->init_hook = alc883_auto_init;
7145 #ifdef CONFIG_SND_HDA_POWER_SAVE
7146 if (!spec->loopback.amplist)
7147 spec->loopback.amplist = alc883_loopbacks;
7157 #define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
7158 #define ALC262_DIGIN_NID ALC880_DIGIN_NID
7160 #define alc262_dac_nids alc260_dac_nids
7161 #define alc262_adc_nids alc882_adc_nids
7162 #define alc262_adc_nids_alt alc882_adc_nids_alt
7164 #define alc262_modes alc260_modes
7165 #define alc262_capture_source alc882_capture_source
7167 static struct snd_kcontrol_new alc262_base_mixer[] = {
7168 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7169 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7170 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7171 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7172 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7173 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7174 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7175 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7176 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7177 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
7178 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
7179 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
7180 /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
7181 HDA_CODEC_MUTE("PC Beelp Playback Switch", 0x0b, 0x05, HDA_INPUT), */
7182 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
7183 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7184 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7185 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
7189 static struct snd_kcontrol_new alc262_hippo1_mixer[] = {
7190 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7191 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7192 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7193 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7194 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7195 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7196 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7197 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7198 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7199 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
7200 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
7201 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
7202 /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
7203 HDA_CODEC_MUTE("PC Beelp Playback Switch", 0x0b, 0x05, HDA_INPUT), */
7204 /*HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),*/
7205 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7209 static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
7210 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7211 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7212 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7213 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7214 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
7216 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7217 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7218 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7219 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
7220 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
7221 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
7222 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7223 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7224 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7225 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7226 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
7227 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
7228 HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
7229 HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
7233 static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = {
7234 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7235 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7236 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7237 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7238 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7239 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
7240 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x02, HDA_INPUT),
7241 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x02, HDA_INPUT),
7242 HDA_CODEC_VOLUME("Front Mic Boost", 0x1a, 0, HDA_INPUT),
7243 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
7244 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
7245 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7246 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7247 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
7248 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
7252 static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = {
7253 HDA_CODEC_VOLUME("Rear Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7254 HDA_CODEC_MUTE("Rear Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7255 HDA_CODEC_VOLUME("Rear Mic Boost", 0x18, 0, HDA_INPUT),
7259 static struct hda_bind_ctls alc262_sony_bind_sw = {
7260 .ops = &snd_hda_bind_sw,
7262 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
7263 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
7268 static struct snd_kcontrol_new alc262_sony_mixer[] = {
7269 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7270 HDA_BIND_SW("Front Playback Switch", &alc262_sony_bind_sw),
7271 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7272 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7273 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
7274 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
7278 static struct snd_kcontrol_new alc262_benq_t31_mixer[] = {
7279 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7280 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7281 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7282 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7283 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7284 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
7285 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
7289 #define alc262_capture_mixer alc882_capture_mixer
7290 #define alc262_capture_alt_mixer alc882_capture_alt_mixer
7293 * generic initialization of ADC, input mixers and output mixers
7295 static struct hda_verb alc262_init_verbs[] = {
7297 * Unmute ADC0-2 and set the default input to mic-in
7299 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7300 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7301 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7302 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7303 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7304 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7306 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
7308 * Note: PASD motherboards uses the Line In 2 as the input for
7309 * front panel mic (mic 2)
7311 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
7312 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7313 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7314 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7315 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7316 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7319 * Set up output mixers (0x0c - 0x0e)
7321 /* set vol=0 to output mixers */
7322 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7323 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7324 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7325 /* set up input amps for analog loopback */
7326 /* Amp Indices: DAC = 0, mixer = 1 */
7327 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7328 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7329 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7330 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7331 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7332 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7334 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
7335 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
7336 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
7337 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
7338 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
7339 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
7341 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
7342 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
7343 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
7344 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
7345 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
7347 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7348 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
7350 /* FIXME: use matrix-type input source selection */
7351 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7352 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7353 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7354 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
7355 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
7356 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
7358 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7359 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
7360 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
7361 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
7363 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7364 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
7365 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
7366 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
7371 static struct hda_verb alc262_hippo_unsol_verbs[] = {
7372 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
7373 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7377 static struct hda_verb alc262_hippo1_unsol_verbs[] = {
7378 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
7379 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
7380 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
7382 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
7383 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7387 static struct hda_verb alc262_sony_unsol_verbs[] = {
7388 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
7389 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7390 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, // Front Mic
7392 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
7393 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7396 /* mute/unmute internal speaker according to the hp jack and mute state */
7397 static void alc262_hippo_automute(struct hda_codec *codec)
7399 struct alc_spec *spec = codec->spec;
7401 unsigned int present;
7403 /* need to execute and sync at first */
7404 snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
7405 present = snd_hda_codec_read(codec, 0x15, 0,
7406 AC_VERB_GET_PIN_SENSE, 0);
7407 spec->jack_present = (present & 0x80000000) != 0;
7408 if (spec->jack_present) {
7409 /* mute internal speaker */
7410 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7411 HDA_AMP_MUTE, HDA_AMP_MUTE);
7413 /* unmute internal speaker if necessary */
7414 mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0);
7415 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7416 HDA_AMP_MUTE, mute);
7420 /* unsolicited event for HP jack sensing */
7421 static void alc262_hippo_unsol_event(struct hda_codec *codec,
7424 if ((res >> 26) != ALC880_HP_EVENT)
7426 alc262_hippo_automute(codec);
7429 static void alc262_hippo1_automute(struct hda_codec *codec)
7432 unsigned int present;
7434 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
7435 present = snd_hda_codec_read(codec, 0x1b, 0,
7436 AC_VERB_GET_PIN_SENSE, 0);
7437 present = (present & 0x80000000) != 0;
7439 /* mute internal speaker */
7440 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7441 HDA_AMP_MUTE, HDA_AMP_MUTE);
7443 /* unmute internal speaker if necessary */
7444 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
7445 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7446 HDA_AMP_MUTE, mute);
7450 /* unsolicited event for HP jack sensing */
7451 static void alc262_hippo1_unsol_event(struct hda_codec *codec,
7454 if ((res >> 26) != ALC880_HP_EVENT)
7456 alc262_hippo1_automute(codec);
7461 * 0x14 = headphone/spdif-out, 0x15 = internal speaker
7464 #define ALC_HP_EVENT 0x37
7466 static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
7467 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
7468 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7472 static struct hda_input_mux alc262_fujitsu_capture_source = {
7480 static struct hda_input_mux alc262_HP_capture_source = {
7484 { "Front Mic", 0x3 },
7491 /* mute/unmute internal speaker according to the hp jack and mute state */
7492 static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
7494 struct alc_spec *spec = codec->spec;
7497 if (force || !spec->sense_updated) {
7498 unsigned int present;
7499 /* need to execute and sync at first */
7500 snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
7501 present = snd_hda_codec_read(codec, 0x14, 0,
7502 AC_VERB_GET_PIN_SENSE, 0);
7503 spec->jack_present = (present & 0x80000000) != 0;
7504 spec->sense_updated = 1;
7506 if (spec->jack_present) {
7507 /* mute internal speaker */
7508 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7509 HDA_AMP_MUTE, HDA_AMP_MUTE);
7511 /* unmute internal speaker if necessary */
7512 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
7513 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7514 HDA_AMP_MUTE, mute);
7518 /* unsolicited event for HP jack sensing */
7519 static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
7522 if ((res >> 26) != ALC_HP_EVENT)
7524 alc262_fujitsu_automute(codec, 1);
7527 /* bind volumes of both NID 0x0c and 0x0d */
7528 static struct hda_bind_ctls alc262_fujitsu_bind_master_vol = {
7529 .ops = &snd_hda_bind_vol,
7531 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
7532 HDA_COMPOSE_AMP_VAL(0x0d, 3, 0, HDA_OUTPUT),
7537 /* bind hp and internal speaker mute (with plug check) */
7538 static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
7539 struct snd_ctl_elem_value *ucontrol)
7541 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
7542 long *valp = ucontrol->value.integer.value;
7545 change = snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
7547 valp[0] ? 0 : HDA_AMP_MUTE);
7548 change |= snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
7550 valp[1] ? 0 : HDA_AMP_MUTE);
7552 alc262_fujitsu_automute(codec, 0);
7556 static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
7557 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
7559 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7560 .name = "Master Playback Switch",
7561 .info = snd_hda_mixer_amp_switch_info,
7562 .get = snd_hda_mixer_amp_switch_get,
7563 .put = alc262_fujitsu_master_sw_put,
7564 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
7566 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7567 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7568 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7569 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7570 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7574 /* additional init verbs for Benq laptops */
7575 static struct hda_verb alc262_EAPD_verbs[] = {
7576 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
7577 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
7581 static struct hda_verb alc262_benq_t31_EAPD_verbs[] = {
7582 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7583 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
7585 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
7586 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
7590 /* add playback controls from the parsed DAC table */
7591 static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec,
7592 const struct auto_pin_cfg *cfg)
7597 spec->multiout.num_dacs = 1; /* only use one dac */
7598 spec->multiout.dac_nids = spec->private_dac_nids;
7599 spec->multiout.dac_nids[0] = 2;
7601 nid = cfg->line_out_pins[0];
7603 err = add_control(spec, ALC_CTL_WIDGET_VOL,
7604 "Front Playback Volume",
7605 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT));
7608 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
7609 "Front Playback Switch",
7610 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
7615 nid = cfg->speaker_pins[0];
7618 err = add_control(spec, ALC_CTL_WIDGET_VOL,
7619 "Speaker Playback Volume",
7620 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
7624 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
7625 "Speaker Playback Switch",
7626 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
7631 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
7632 "Speaker Playback Switch",
7633 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
7639 nid = cfg->hp_pins[0];
7641 /* spec->multiout.hp_nid = 2; */
7643 err = add_control(spec, ALC_CTL_WIDGET_VOL,
7644 "Headphone Playback Volume",
7645 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
7649 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
7650 "Headphone Playback Switch",
7651 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
7656 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
7657 "Headphone Playback Switch",
7658 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
7667 /* identical with ALC880 */
7668 #define alc262_auto_create_analog_input_ctls \
7669 alc880_auto_create_analog_input_ctls
7672 * generic initialization of ADC, input mixers and output mixers
7674 static struct hda_verb alc262_volume_init_verbs[] = {
7676 * Unmute ADC0-2 and set the default input to mic-in
7678 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7679 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7680 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7681 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7682 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7683 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7685 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
7687 * Note: PASD motherboards uses the Line In 2 as the input for
7688 * front panel mic (mic 2)
7690 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
7691 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7692 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7693 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7694 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7695 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7698 * Set up output mixers (0x0c - 0x0f)
7700 /* set vol=0 to output mixers */
7701 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7702 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7703 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7705 /* set up input amps for analog loopback */
7706 /* Amp Indices: DAC = 0, mixer = 1 */
7707 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7708 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7709 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7710 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7711 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7712 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7714 /* FIXME: use matrix-type input source selection */
7715 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7716 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7717 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7718 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
7719 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
7720 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
7722 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7723 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
7724 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
7725 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
7727 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7728 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
7729 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
7730 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
7735 static struct hda_verb alc262_HP_BPC_init_verbs[] = {
7737 * Unmute ADC0-2 and set the default input to mic-in
7739 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7740 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7741 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7742 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7743 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7744 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7746 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
7748 * Note: PASD motherboards uses the Line In 2 as the input for
7749 * front panel mic (mic 2)
7751 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
7752 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7753 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7754 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7755 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7756 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7757 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
7758 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
7761 * Set up output mixers (0x0c - 0x0e)
7763 /* set vol=0 to output mixers */
7764 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7765 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7766 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7768 /* set up input amps for analog loopback */
7769 /* Amp Indices: DAC = 0, mixer = 1 */
7770 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7771 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7772 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7773 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7774 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7775 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7777 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
7778 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7779 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7781 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7782 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7784 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
7785 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7787 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
7788 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
7789 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
7790 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
7791 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
7793 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
7794 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
7795 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
7796 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
7797 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
7798 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
7801 /* FIXME: use matrix-type input source selection */
7802 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7803 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7804 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7805 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
7806 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
7807 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
7809 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7810 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
7811 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
7812 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
7814 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7815 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
7816 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
7817 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
7822 static struct hda_verb alc262_HP_BPC_WildWest_init_verbs[] = {
7824 * Unmute ADC0-2 and set the default input to mic-in
7826 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7827 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7828 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7829 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7830 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7831 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7833 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
7835 * Note: PASD motherboards uses the Line In 2 as the input for front
7838 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
7839 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7840 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7841 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7842 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7843 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7844 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
7845 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
7846 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
7848 * Set up output mixers (0x0c - 0x0e)
7850 /* set vol=0 to output mixers */
7851 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7852 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7853 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7855 /* set up input amps for analog loopback */
7856 /* Amp Indices: DAC = 0, mixer = 1 */
7857 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7858 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7859 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7860 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7861 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7862 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7865 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP */
7866 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Mono */
7867 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* rear MIC */
7868 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* Line in */
7869 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
7870 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Line out */
7871 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD in */
7873 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7874 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7876 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
7877 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
7879 /* {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, */
7880 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
7881 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
7882 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
7883 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
7884 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
7886 /* FIXME: use matrix-type input source selection */
7887 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7888 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7889 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, /*rear MIC*/
7890 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, /*Line in*/
7891 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, /*F MIC*/
7892 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, /*Front*/
7893 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, /*CD*/
7894 /* {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
7895 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, /*HP*/
7897 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7898 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
7899 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
7900 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
7901 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
7902 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
7903 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
7905 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7906 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
7907 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
7908 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
7909 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
7910 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
7911 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
7916 #ifdef CONFIG_SND_HDA_POWER_SAVE
7917 #define alc262_loopbacks alc880_loopbacks
7920 /* pcm configuration: identiacal with ALC880 */
7921 #define alc262_pcm_analog_playback alc880_pcm_analog_playback
7922 #define alc262_pcm_analog_capture alc880_pcm_analog_capture
7923 #define alc262_pcm_digital_playback alc880_pcm_digital_playback
7924 #define alc262_pcm_digital_capture alc880_pcm_digital_capture
7927 * BIOS auto configuration
7929 static int alc262_parse_auto_config(struct hda_codec *codec)
7931 struct alc_spec *spec = codec->spec;
7933 static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
7935 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
7939 if (!spec->autocfg.line_outs)
7940 return 0; /* can't find valid BIOS pin config */
7941 err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg);
7944 err = alc262_auto_create_analog_input_ctls(spec, &spec->autocfg);
7948 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
7950 if (spec->autocfg.dig_out_pin)
7951 spec->multiout.dig_out_nid = ALC262_DIGOUT_NID;
7952 if (spec->autocfg.dig_in_pin)
7953 spec->dig_in_nid = ALC262_DIGIN_NID;
7955 if (spec->kctl_alloc)
7956 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
7958 spec->init_verbs[spec->num_init_verbs++] = alc262_volume_init_verbs;
7959 spec->num_mux_defs = 1;
7960 spec->input_mux = &spec->private_imux;
7965 #define alc262_auto_init_multi_out alc882_auto_init_multi_out
7966 #define alc262_auto_init_hp_out alc882_auto_init_hp_out
7967 #define alc262_auto_init_analog_input alc882_auto_init_analog_input
7970 /* init callback for auto-configuration model -- overriding the default init */
7971 static void alc262_auto_init(struct hda_codec *codec)
7973 alc262_auto_init_multi_out(codec);
7974 alc262_auto_init_hp_out(codec);
7975 alc262_auto_init_analog_input(codec);
7979 * configuration and preset
7981 static const char *alc262_models[ALC262_MODEL_LAST] = {
7982 [ALC262_BASIC] = "basic",
7983 [ALC262_HIPPO] = "hippo",
7984 [ALC262_HIPPO_1] = "hippo_1",
7985 [ALC262_FUJITSU] = "fujitsu",
7986 [ALC262_HP_BPC] = "hp-bpc",
7987 [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000",
7988 [ALC262_BENQ_ED8] = "benq",
7989 [ALC262_BENQ_T31] = "benq-t31",
7990 [ALC262_SONY_ASSAMD] = "sony-assamd",
7991 [ALC262_AUTO] = "auto",
7994 static struct snd_pci_quirk alc262_cfg_tbl[] = {
7995 SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO),
7996 SND_PCI_QUIRK(0x103c, 0x12fe, "HP xw9400", ALC262_HP_BPC),
7997 SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC),
7998 SND_PCI_QUIRK(0x103c, 0x12ff, "HP xw4550", ALC262_HP_BPC),
7999 SND_PCI_QUIRK(0x103c, 0x1308, "HP xw4600", ALC262_HP_BPC),
8000 SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC),
8001 SND_PCI_QUIRK(0x103c, 0x1307, "HP xw6600", ALC262_HP_BPC),
8002 SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC),
8003 SND_PCI_QUIRK(0x103c, 0x1306, "HP xw8600", ALC262_HP_BPC),
8004 SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL),
8005 SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL),
8006 SND_PCI_QUIRK(0x103c, 0x2804, "HP D7000", ALC262_HP_BPC_D7000_WL),
8007 SND_PCI_QUIRK(0x103c, 0x2806, "HP D7000", ALC262_HP_BPC_D7000_WL),
8008 SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF),
8009 SND_PCI_QUIRK(0x103c, 0x2803, "HP D7000", ALC262_HP_BPC_D7000_WF),
8010 SND_PCI_QUIRK(0x103c, 0x2805, "HP D7000", ALC262_HP_BPC_D7000_WF),
8011 SND_PCI_QUIRK(0x103c, 0x2807, "HP D7000", ALC262_HP_BPC_D7000_WF),
8012 SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO),
8013 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
8014 SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1),
8015 SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
8016 SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_BENQ_T31),
8017 SND_PCI_QUIRK(0x104d, 0x820f, "Sony ASSAMD", ALC262_SONY_ASSAMD),
8018 SND_PCI_QUIRK(0x104d, 0x9015, "Sony 0x9015", ALC262_SONY_ASSAMD),
8019 SND_PCI_QUIRK(0x104d, 0x900e, "Sony ASSAMD", ALC262_SONY_ASSAMD),
8020 SND_PCI_QUIRK(0x104d, 0x1f00, "Sony ASSAMD", ALC262_SONY_ASSAMD),
8024 static struct alc_config_preset alc262_presets[] = {
8026 .mixers = { alc262_base_mixer },
8027 .init_verbs = { alc262_init_verbs },
8028 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
8029 .dac_nids = alc262_dac_nids,
8031 .num_channel_mode = ARRAY_SIZE(alc262_modes),
8032 .channel_mode = alc262_modes,
8033 .input_mux = &alc262_capture_source,
8036 .mixers = { alc262_base_mixer },
8037 .init_verbs = { alc262_init_verbs, alc262_hippo_unsol_verbs},
8038 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
8039 .dac_nids = alc262_dac_nids,
8041 .dig_out_nid = ALC262_DIGOUT_NID,
8042 .num_channel_mode = ARRAY_SIZE(alc262_modes),
8043 .channel_mode = alc262_modes,
8044 .input_mux = &alc262_capture_source,
8045 .unsol_event = alc262_hippo_unsol_event,
8046 .init_hook = alc262_hippo_automute,
8048 [ALC262_HIPPO_1] = {
8049 .mixers = { alc262_hippo1_mixer },
8050 .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs},
8051 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
8052 .dac_nids = alc262_dac_nids,
8054 .dig_out_nid = ALC262_DIGOUT_NID,
8055 .num_channel_mode = ARRAY_SIZE(alc262_modes),
8056 .channel_mode = alc262_modes,
8057 .input_mux = &alc262_capture_source,
8058 .unsol_event = alc262_hippo1_unsol_event,
8059 .init_hook = alc262_hippo1_automute,
8061 [ALC262_FUJITSU] = {
8062 .mixers = { alc262_fujitsu_mixer },
8063 .init_verbs = { alc262_init_verbs, alc262_fujitsu_unsol_verbs },
8064 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
8065 .dac_nids = alc262_dac_nids,
8067 .dig_out_nid = ALC262_DIGOUT_NID,
8068 .num_channel_mode = ARRAY_SIZE(alc262_modes),
8069 .channel_mode = alc262_modes,
8070 .input_mux = &alc262_fujitsu_capture_source,
8071 .unsol_event = alc262_fujitsu_unsol_event,
8074 .mixers = { alc262_HP_BPC_mixer },
8075 .init_verbs = { alc262_HP_BPC_init_verbs },
8076 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
8077 .dac_nids = alc262_dac_nids,
8079 .num_channel_mode = ARRAY_SIZE(alc262_modes),
8080 .channel_mode = alc262_modes,
8081 .input_mux = &alc262_HP_capture_source,
8083 [ALC262_HP_BPC_D7000_WF] = {
8084 .mixers = { alc262_HP_BPC_WildWest_mixer },
8085 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
8086 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
8087 .dac_nids = alc262_dac_nids,
8089 .num_channel_mode = ARRAY_SIZE(alc262_modes),
8090 .channel_mode = alc262_modes,
8091 .input_mux = &alc262_HP_capture_source,
8093 [ALC262_HP_BPC_D7000_WL] = {
8094 .mixers = { alc262_HP_BPC_WildWest_mixer,
8095 alc262_HP_BPC_WildWest_option_mixer },
8096 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
8097 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
8098 .dac_nids = alc262_dac_nids,
8100 .num_channel_mode = ARRAY_SIZE(alc262_modes),
8101 .channel_mode = alc262_modes,
8102 .input_mux = &alc262_HP_capture_source,
8104 [ALC262_BENQ_ED8] = {
8105 .mixers = { alc262_base_mixer },
8106 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
8107 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
8108 .dac_nids = alc262_dac_nids,
8110 .num_channel_mode = ARRAY_SIZE(alc262_modes),
8111 .channel_mode = alc262_modes,
8112 .input_mux = &alc262_capture_source,
8114 [ALC262_SONY_ASSAMD] = {
8115 .mixers = { alc262_sony_mixer },
8116 .init_verbs = { alc262_init_verbs, alc262_sony_unsol_verbs},
8117 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
8118 .dac_nids = alc262_dac_nids,
8120 .num_channel_mode = ARRAY_SIZE(alc262_modes),
8121 .channel_mode = alc262_modes,
8122 .input_mux = &alc262_capture_source,
8123 .unsol_event = alc262_hippo_unsol_event,
8124 .init_hook = alc262_hippo_automute,
8126 [ALC262_BENQ_T31] = {
8127 .mixers = { alc262_benq_t31_mixer },
8128 .init_verbs = { alc262_init_verbs, alc262_benq_t31_EAPD_verbs, alc262_hippo_unsol_verbs },
8129 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
8130 .dac_nids = alc262_dac_nids,
8132 .num_channel_mode = ARRAY_SIZE(alc262_modes),
8133 .channel_mode = alc262_modes,
8134 .input_mux = &alc262_capture_source,
8135 .unsol_event = alc262_hippo_unsol_event,
8136 .init_hook = alc262_hippo_automute,
8140 static int patch_alc262(struct hda_codec *codec)
8142 struct alc_spec *spec;
8146 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
8152 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
8157 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
8158 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
8159 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
8160 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
8164 board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST,
8168 if (board_config < 0) {
8169 printk(KERN_INFO "hda_codec: Unknown model for ALC262, "
8170 "trying auto-probe from BIOS...\n");
8171 board_config = ALC262_AUTO;
8174 if (board_config == ALC262_AUTO) {
8175 /* automatic parse from the BIOS config */
8176 err = alc262_parse_auto_config(codec);
8182 "hda_codec: Cannot set up configuration "
8183 "from BIOS. Using base mode...\n");
8184 board_config = ALC262_BASIC;
8188 if (board_config != ALC262_AUTO)
8189 setup_preset(spec, &alc262_presets[board_config]);
8191 spec->stream_name_analog = "ALC262 Analog";
8192 spec->stream_analog_playback = &alc262_pcm_analog_playback;
8193 spec->stream_analog_capture = &alc262_pcm_analog_capture;
8195 spec->stream_name_digital = "ALC262 Digital";
8196 spec->stream_digital_playback = &alc262_pcm_digital_playback;
8197 spec->stream_digital_capture = &alc262_pcm_digital_capture;
8199 if (!spec->adc_nids && spec->input_mux) {
8200 /* check whether NID 0x07 is valid */
8201 unsigned int wcap = get_wcaps(codec, 0x07);
8204 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
8205 if (wcap != AC_WID_AUD_IN) {
8206 spec->adc_nids = alc262_adc_nids_alt;
8207 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids_alt);
8208 spec->mixers[spec->num_mixers] =
8209 alc262_capture_alt_mixer;
8212 spec->adc_nids = alc262_adc_nids;
8213 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids);
8214 spec->mixers[spec->num_mixers] = alc262_capture_mixer;
8219 codec->patch_ops = alc_patch_ops;
8220 if (board_config == ALC262_AUTO)
8221 spec->init_hook = alc262_auto_init;
8222 #ifdef CONFIG_SND_HDA_POWER_SAVE
8223 if (!spec->loopback.amplist)
8224 spec->loopback.amplist = alc262_loopbacks;
8231 * ALC268 channel source setting (2 channel)
8233 #define ALC268_DIGOUT_NID ALC880_DIGOUT_NID
8234 #define alc268_modes alc260_modes
8236 static hda_nid_t alc268_dac_nids[2] = {
8241 static hda_nid_t alc268_adc_nids[2] = {
8246 static hda_nid_t alc268_adc_nids_alt[1] = {
8251 static struct snd_kcontrol_new alc268_base_mixer[] = {
8252 /* output mixer control */
8253 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
8254 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8255 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
8256 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8260 static struct hda_verb alc268_eapd_verbs[] = {
8261 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
8262 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
8266 /* Toshiba specific */
8267 #define alc268_toshiba_automute alc262_hippo_automute
8269 static struct hda_verb alc268_toshiba_verbs[] = {
8270 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8275 #define alc268_acer_bind_master_vol alc262_fujitsu_bind_master_vol
8276 #define alc268_acer_master_sw_put alc262_fujitsu_master_sw_put
8277 #define alc268_acer_automute alc262_fujitsu_automute
8279 static struct snd_kcontrol_new alc268_acer_mixer[] = {
8280 /* output mixer control */
8281 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
8283 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8284 .name = "Master Playback Switch",
8285 .info = snd_hda_mixer_amp_switch_info,
8286 .get = snd_hda_mixer_amp_switch_get,
8287 .put = alc268_acer_master_sw_put,
8288 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
8293 static struct hda_verb alc268_acer_verbs[] = {
8294 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8295 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8297 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8301 /* unsolicited event for HP jack sensing */
8302 static void alc268_toshiba_unsol_event(struct hda_codec *codec,
8305 if ((res >> 28) != ALC880_HP_EVENT)
8307 alc268_toshiba_automute(codec);
8310 static void alc268_acer_unsol_event(struct hda_codec *codec,
8313 if ((res >> 28) != ALC880_HP_EVENT)
8315 alc268_acer_automute(codec, 1);
8319 * generic initialization of ADC, input mixers and output mixers
8321 static struct hda_verb alc268_base_init_verbs[] = {
8322 /* Unmute DAC0-1 and set vol = 0 */
8323 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8324 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8325 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8326 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8327 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8328 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8331 * Set up output mixers (0x0c - 0x0e)
8333 /* set vol=0 to output mixers */
8334 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8335 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8336 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8337 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
8339 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8340 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8342 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
8343 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
8344 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
8345 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
8346 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
8347 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
8348 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
8349 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
8351 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8352 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8353 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8354 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8355 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8356 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8357 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8358 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8360 /* FIXME: use matrix-type input source selection */
8361 /* Mixer elements: 0x18, 19, 1a, 1c, 14, 15, 0b */
8362 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
8364 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8365 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
8366 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
8367 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
8369 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8370 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
8371 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
8372 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
8377 * generic initialization of ADC, input mixers and output mixers
8379 static struct hda_verb alc268_volume_init_verbs[] = {
8380 /* set output DAC */
8381 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8382 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8383 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8384 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8386 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
8387 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
8388 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
8389 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
8390 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
8392 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8393 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8394 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8395 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8396 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8398 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8399 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8400 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8401 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8403 /* set PCBEEP vol = 0 */
8404 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, (0xb000 | (0x00 << 8))},
8409 #define alc268_mux_enum_info alc_mux_enum_info
8410 #define alc268_mux_enum_get alc_mux_enum_get
8412 static int alc268_mux_enum_put(struct snd_kcontrol *kcontrol,
8413 struct snd_ctl_elem_value *ucontrol)
8415 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
8416 struct alc_spec *spec = codec->spec;
8417 const struct hda_input_mux *imux = spec->input_mux;
8418 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
8419 static hda_nid_t capture_mixers[3] = { 0x23, 0x24 };
8420 hda_nid_t nid = capture_mixers[adc_idx];
8421 unsigned int *cur_val = &spec->cur_mux[adc_idx];
8422 unsigned int i, idx;
8424 idx = ucontrol->value.enumerated.item[0];
8425 if (idx >= imux->num_items)
8426 idx = imux->num_items - 1;
8427 if (*cur_val == idx)
8429 for (i = 0; i < imux->num_items; i++) {
8430 unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
8431 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
8432 imux->items[i].index,
8434 snd_hda_codec_write_cache(codec, nid, 0,
8435 AC_VERB_SET_CONNECT_SEL,
8442 static struct snd_kcontrol_new alc268_capture_alt_mixer[] = {
8443 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
8444 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
8446 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8447 /* The multiple "Capture Source" controls confuse alsamixer
8448 * So call somewhat different..
8449 * FIXME: the controls appear in the "playback" view!
8451 /* .name = "Capture Source", */
8452 .name = "Input Source",
8454 .info = alc268_mux_enum_info,
8455 .get = alc268_mux_enum_get,
8456 .put = alc268_mux_enum_put,
8461 static struct snd_kcontrol_new alc268_capture_mixer[] = {
8462 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
8463 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
8464 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x24, 0x0, HDA_OUTPUT),
8465 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x24, 0x0, HDA_OUTPUT),
8467 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8468 /* The multiple "Capture Source" controls confuse alsamixer
8469 * So call somewhat different..
8470 * FIXME: the controls appear in the "playback" view!
8472 /* .name = "Capture Source", */
8473 .name = "Input Source",
8475 .info = alc268_mux_enum_info,
8476 .get = alc268_mux_enum_get,
8477 .put = alc268_mux_enum_put,
8482 static struct hda_input_mux alc268_capture_source = {
8486 { "Front Mic", 0x1 },
8492 /* create input playback/capture controls for the given pin */
8493 static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
8494 const char *ctlname, int idx)
8499 sprintf(name, "%s Playback Volume", ctlname);
8501 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
8502 HDA_COMPOSE_AMP_VAL(0x02, 3, idx,
8506 } else if (nid == 0x15) {
8507 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
8508 HDA_COMPOSE_AMP_VAL(0x03, 3, idx,
8514 sprintf(name, "%s Playback Switch", ctlname);
8515 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
8516 HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
8522 /* add playback controls from the parsed DAC table */
8523 static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec,
8524 const struct auto_pin_cfg *cfg)
8529 spec->multiout.num_dacs = 2; /* only use one dac */
8530 spec->multiout.dac_nids = spec->private_dac_nids;
8531 spec->multiout.dac_nids[0] = 2;
8532 spec->multiout.dac_nids[1] = 3;
8534 nid = cfg->line_out_pins[0];
8536 alc268_new_analog_output(spec, nid, "Front", 0);
8538 nid = cfg->speaker_pins[0];
8540 err = add_control(spec, ALC_CTL_WIDGET_VOL,
8541 "Speaker Playback Volume",
8542 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
8546 nid = cfg->hp_pins[0];
8548 alc268_new_analog_output(spec, nid, "Headphone", 0);
8550 nid = cfg->line_out_pins[1] | cfg->line_out_pins[2];
8552 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
8553 "Mono Playback Switch",
8554 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_INPUT));
8561 /* create playback/capture controls for input pins */
8562 static int alc268_auto_create_analog_input_ctls(struct alc_spec *spec,
8563 const struct auto_pin_cfg *cfg)
8565 struct hda_input_mux *imux = &spec->private_imux;
8568 for (i = 0; i < AUTO_PIN_LAST; i++) {
8569 switch(cfg->input_pins[i]) {
8571 idx1 = 0; /* Mic 1 */
8574 idx1 = 1; /* Mic 2 */
8577 idx1 = 2; /* Line In */
8585 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
8586 imux->items[imux->num_items].index = idx1;
8592 static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec)
8594 struct alc_spec *spec = codec->spec;
8595 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
8596 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
8597 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
8598 unsigned int dac_vol1, dac_vol2;
8601 snd_hda_codec_write(codec, speaker_nid, 0,
8602 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
8603 snd_hda_codec_write(codec, 0x0f, 0,
8604 AC_VERB_SET_AMP_GAIN_MUTE,
8606 snd_hda_codec_write(codec, 0x10, 0,
8607 AC_VERB_SET_AMP_GAIN_MUTE,
8610 snd_hda_codec_write(codec, 0x0f, 0,
8611 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
8612 snd_hda_codec_write(codec, 0x10, 0,
8613 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
8616 dac_vol1 = dac_vol2 = 0xb000 | 0x40; /* set max volume */
8617 if (line_nid == 0x14)
8618 dac_vol2 = AMP_OUT_ZERO;
8619 else if (line_nid == 0x15)
8620 dac_vol1 = AMP_OUT_ZERO;
8622 dac_vol2 = AMP_OUT_ZERO;
8623 else if (hp_nid == 0x15)
8624 dac_vol1 = AMP_OUT_ZERO;
8625 if (line_nid != 0x16 || hp_nid != 0x16 ||
8626 spec->autocfg.line_out_pins[1] != 0x16 ||
8627 spec->autocfg.line_out_pins[2] != 0x16)
8628 dac_vol1 = dac_vol2 = AMP_OUT_ZERO;
8630 snd_hda_codec_write(codec, 0x02, 0,
8631 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol1);
8632 snd_hda_codec_write(codec, 0x03, 0,
8633 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol2);
8636 /* pcm configuration: identiacal with ALC880 */
8637 #define alc268_pcm_analog_playback alc880_pcm_analog_playback
8638 #define alc268_pcm_analog_capture alc880_pcm_analog_capture
8639 #define alc268_pcm_digital_playback alc880_pcm_digital_playback
8642 * BIOS auto configuration
8644 static int alc268_parse_auto_config(struct hda_codec *codec)
8646 struct alc_spec *spec = codec->spec;
8648 static hda_nid_t alc268_ignore[] = { 0 };
8650 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
8654 if (!spec->autocfg.line_outs)
8655 return 0; /* can't find valid BIOS pin config */
8657 err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg);
8660 err = alc268_auto_create_analog_input_ctls(spec, &spec->autocfg);
8664 spec->multiout.max_channels = 2;
8666 /* digital only support output */
8667 if (spec->autocfg.dig_out_pin)
8668 spec->multiout.dig_out_nid = ALC268_DIGOUT_NID;
8670 if (spec->kctl_alloc)
8671 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
8673 spec->init_verbs[spec->num_init_verbs++] = alc268_volume_init_verbs;
8674 spec->num_mux_defs = 1;
8675 spec->input_mux = &spec->private_imux;
8680 #define alc268_auto_init_multi_out alc882_auto_init_multi_out
8681 #define alc268_auto_init_hp_out alc882_auto_init_hp_out
8682 #define alc268_auto_init_analog_input alc882_auto_init_analog_input
8684 /* init callback for auto-configuration model -- overriding the default init */
8685 static void alc268_auto_init(struct hda_codec *codec)
8687 alc268_auto_init_multi_out(codec);
8688 alc268_auto_init_hp_out(codec);
8689 alc268_auto_init_mono_speaker_out(codec);
8690 alc268_auto_init_analog_input(codec);
8694 * configuration and preset
8696 static const char *alc268_models[ALC268_MODEL_LAST] = {
8697 [ALC268_3ST] = "3stack",
8698 [ALC268_TOSHIBA] = "toshiba",
8699 [ALC268_ACER] = "acer",
8700 [ALC268_AUTO] = "auto",
8703 static struct snd_pci_quirk alc268_cfg_tbl[] = {
8704 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST),
8705 SND_PCI_QUIRK(0x1179, 0xff10, "TOSHIBA A205", ALC268_TOSHIBA),
8706 SND_PCI_QUIRK(0x103c, 0x30cc, "TOSHIBA", ALC268_TOSHIBA),
8707 SND_PCI_QUIRK(0x1025, 0x0126, "Acer", ALC268_ACER),
8711 static struct alc_config_preset alc268_presets[] = {
8713 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer },
8714 .init_verbs = { alc268_base_init_verbs },
8715 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
8716 .dac_nids = alc268_dac_nids,
8717 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
8718 .adc_nids = alc268_adc_nids_alt,
8720 .dig_out_nid = ALC268_DIGOUT_NID,
8721 .num_channel_mode = ARRAY_SIZE(alc268_modes),
8722 .channel_mode = alc268_modes,
8723 .input_mux = &alc268_capture_source,
8725 [ALC268_TOSHIBA] = {
8726 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer },
8727 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
8728 alc268_toshiba_verbs },
8729 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
8730 .dac_nids = alc268_dac_nids,
8731 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
8732 .adc_nids = alc268_adc_nids_alt,
8734 .num_channel_mode = ARRAY_SIZE(alc268_modes),
8735 .channel_mode = alc268_modes,
8736 .input_mux = &alc268_capture_source,
8737 .input_mux = &alc268_capture_source,
8738 .unsol_event = alc268_toshiba_unsol_event,
8739 .init_hook = alc268_toshiba_automute,
8742 .mixers = { alc268_acer_mixer, alc268_capture_alt_mixer },
8743 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
8744 alc268_acer_verbs },
8745 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
8746 .dac_nids = alc268_dac_nids,
8747 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
8748 .adc_nids = alc268_adc_nids_alt,
8750 .num_channel_mode = ARRAY_SIZE(alc268_modes),
8751 .channel_mode = alc268_modes,
8752 .input_mux = &alc268_capture_source,
8753 .unsol_event = alc268_acer_unsol_event,
8757 static int patch_alc268(struct hda_codec *codec)
8759 struct alc_spec *spec;
8763 spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
8769 board_config = snd_hda_check_board_config(codec, ALC268_MODEL_LAST,
8773 if (board_config < 0 || board_config >= ALC268_MODEL_LAST) {
8774 printk(KERN_INFO "hda_codec: Unknown model for ALC268, "
8775 "trying auto-probe from BIOS...\n");
8776 board_config = ALC268_AUTO;
8779 if (board_config == ALC268_AUTO) {
8780 /* automatic parse from the BIOS config */
8781 err = alc268_parse_auto_config(codec);
8787 "hda_codec: Cannot set up configuration "
8788 "from BIOS. Using base mode...\n");
8789 board_config = ALC268_3ST;
8793 if (board_config != ALC268_AUTO)
8794 setup_preset(spec, &alc268_presets[board_config]);
8796 spec->stream_name_analog = "ALC268 Analog";
8797 spec->stream_analog_playback = &alc268_pcm_analog_playback;
8798 spec->stream_analog_capture = &alc268_pcm_analog_capture;
8800 spec->stream_name_digital = "ALC268 Digital";
8801 spec->stream_digital_playback = &alc268_pcm_digital_playback;
8803 if (board_config == ALC268_AUTO) {
8804 if (!spec->adc_nids && spec->input_mux) {
8805 /* check whether NID 0x07 is valid */
8806 unsigned int wcap = get_wcaps(codec, 0x07);
8809 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
8810 if (wcap != AC_WID_AUD_IN) {
8811 spec->adc_nids = alc268_adc_nids_alt;
8812 spec->num_adc_nids =
8813 ARRAY_SIZE(alc268_adc_nids_alt);
8814 spec->mixers[spec->num_mixers] =
8815 alc268_capture_alt_mixer;
8818 spec->adc_nids = alc268_adc_nids;
8819 spec->num_adc_nids =
8820 ARRAY_SIZE(alc268_adc_nids);
8821 spec->mixers[spec->num_mixers] =
8822 alc268_capture_mixer;
8827 codec->patch_ops = alc_patch_ops;
8828 if (board_config == ALC268_AUTO)
8829 spec->init_hook = alc268_auto_init;
8835 * ALC861 channel source setting (2/6 channel selection for 3-stack)
8839 * set the path ways for 2 channel output
8840 * need to set the codec line out and mic 1 pin widgets to inputs
8842 static struct hda_verb alc861_threestack_ch2_init[] = {
8843 /* set pin widget 1Ah (line in) for input */
8844 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
8845 /* set pin widget 18h (mic1/2) for input, for mic also enable
8848 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
8850 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
8852 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
8853 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
8859 * need to set the codec line out and mic 1 pin widgets to outputs
8861 static struct hda_verb alc861_threestack_ch6_init[] = {
8862 /* set pin widget 1Ah (line in) for output (Back Surround)*/
8863 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
8864 /* set pin widget 18h (mic1) for output (CLFE)*/
8865 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
8867 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
8868 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
8870 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
8872 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
8873 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
8878 static struct hda_channel_mode alc861_threestack_modes[2] = {
8879 { 2, alc861_threestack_ch2_init },
8880 { 6, alc861_threestack_ch6_init },
8882 /* Set mic1 as input and unmute the mixer */
8883 static struct hda_verb alc861_uniwill_m31_ch2_init[] = {
8884 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
8885 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
8888 /* Set mic1 as output and mute mixer */
8889 static struct hda_verb alc861_uniwill_m31_ch4_init[] = {
8890 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
8891 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
8895 static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
8896 { 2, alc861_uniwill_m31_ch2_init },
8897 { 4, alc861_uniwill_m31_ch4_init },
8900 /* Set mic1 and line-in as input and unmute the mixer */
8901 static struct hda_verb alc861_asus_ch2_init[] = {
8902 /* set pin widget 1Ah (line in) for input */
8903 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
8904 /* set pin widget 18h (mic1/2) for input, for mic also enable
8907 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
8909 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
8911 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
8912 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
8916 /* Set mic1 nad line-in as output and mute mixer */
8917 static struct hda_verb alc861_asus_ch6_init[] = {
8918 /* set pin widget 1Ah (line in) for output (Back Surround)*/
8919 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
8920 /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
8921 /* set pin widget 18h (mic1) for output (CLFE)*/
8922 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
8923 /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
8924 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
8925 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
8927 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
8929 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
8930 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
8935 static struct hda_channel_mode alc861_asus_modes[2] = {
8936 { 2, alc861_asus_ch2_init },
8937 { 6, alc861_asus_ch6_init },
8942 static struct snd_kcontrol_new alc861_base_mixer[] = {
8943 /* output mixer control */
8944 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
8945 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
8946 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
8947 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
8948 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
8950 /*Input mixer control */
8951 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
8952 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
8953 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
8954 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
8955 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
8956 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
8957 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
8958 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
8959 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
8960 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
8962 /* Capture mixer control */
8963 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
8964 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
8966 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8967 .name = "Capture Source",
8969 .info = alc_mux_enum_info,
8970 .get = alc_mux_enum_get,
8971 .put = alc_mux_enum_put,
8976 static struct snd_kcontrol_new alc861_3ST_mixer[] = {
8977 /* output mixer control */
8978 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
8979 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
8980 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
8981 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
8982 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
8984 /* Input mixer control */
8985 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
8986 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
8987 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
8988 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
8989 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
8990 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
8991 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
8992 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
8993 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
8994 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
8996 /* Capture mixer control */
8997 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
8998 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
9000 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9001 .name = "Capture Source",
9003 .info = alc_mux_enum_info,
9004 .get = alc_mux_enum_get,
9005 .put = alc_mux_enum_put,
9008 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9009 .name = "Channel Mode",
9010 .info = alc_ch_mode_info,
9011 .get = alc_ch_mode_get,
9012 .put = alc_ch_mode_put,
9013 .private_value = ARRAY_SIZE(alc861_threestack_modes),
9018 static struct snd_kcontrol_new alc861_toshiba_mixer[] = {
9019 /* output mixer control */
9020 HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT),
9021 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
9022 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
9024 /*Capture mixer control */
9025 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
9026 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
9028 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9029 .name = "Capture Source",
9031 .info = alc_mux_enum_info,
9032 .get = alc_mux_enum_get,
9033 .put = alc_mux_enum_put,
9039 static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
9040 /* output mixer control */
9041 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
9042 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
9043 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
9044 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
9045 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
9047 /* Input mixer control */
9048 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
9049 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
9050 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
9051 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
9052 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
9053 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
9054 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
9055 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
9056 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
9057 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
9059 /* Capture mixer control */
9060 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
9061 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
9063 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9064 .name = "Capture Source",
9066 .info = alc_mux_enum_info,
9067 .get = alc_mux_enum_get,
9068 .put = alc_mux_enum_put,
9071 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9072 .name = "Channel Mode",
9073 .info = alc_ch_mode_info,
9074 .get = alc_ch_mode_get,
9075 .put = alc_ch_mode_put,
9076 .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
9081 static struct snd_kcontrol_new alc861_asus_mixer[] = {
9082 /* output mixer control */
9083 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
9084 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
9085 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
9086 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
9087 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
9089 /* Input mixer control */
9090 HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
9091 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9092 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
9093 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
9094 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
9095 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
9096 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
9097 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
9098 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
9099 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT),
9101 /* Capture mixer control */
9102 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
9103 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
9105 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9106 .name = "Capture Source",
9108 .info = alc_mux_enum_info,
9109 .get = alc_mux_enum_get,
9110 .put = alc_mux_enum_put,
9113 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9114 .name = "Channel Mode",
9115 .info = alc_ch_mode_info,
9116 .get = alc_ch_mode_get,
9117 .put = alc_ch_mode_put,
9118 .private_value = ARRAY_SIZE(alc861_asus_modes),
9123 /* additional mixer */
9124 static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = {
9125 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
9126 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
9127 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x23, 0x0, HDA_OUTPUT),
9128 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x23, 0x0, HDA_OUTPUT),
9133 * generic initialization of ADC, input mixers and output mixers
9135 static struct hda_verb alc861_base_init_verbs[] = {
9137 * Unmute ADC0 and set the default input to mic-in
9139 /* port-A for surround (rear panel) */
9140 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
9141 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
9142 /* port-B for mic-in (rear panel) with vref */
9143 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
9144 /* port-C for line-in (rear panel) */
9145 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
9146 /* port-D for Front */
9147 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
9148 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
9149 /* port-E for HP out (front panel) */
9150 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
9151 /* route front PCM to HP */
9152 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
9153 /* port-F for mic-in (front panel) with vref */
9154 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
9155 /* port-G for CLFE (rear panel) */
9156 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
9157 { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
9158 /* port-H for side (rear panel) */
9159 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
9160 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
9162 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
9163 /* route front mic to ADC1*/
9164 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
9165 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9167 /* Unmute DAC0~3 & spdif out*/
9168 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9169 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9170 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9171 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9172 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9174 /* Unmute Mixer 14 (mic) 1c (Line in)*/
9175 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9176 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9177 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9178 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9180 /* Unmute Stereo Mixer 15 */
9181 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9182 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9183 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
9184 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
9186 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9187 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9188 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9189 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9190 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9191 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9192 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9193 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9194 /* hp used DAC 3 (Front) */
9195 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
9196 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
9201 static struct hda_verb alc861_threestack_init_verbs[] = {
9203 * Unmute ADC0 and set the default input to mic-in
9205 /* port-A for surround (rear panel) */
9206 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
9207 /* port-B for mic-in (rear panel) with vref */
9208 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
9209 /* port-C for line-in (rear panel) */
9210 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
9211 /* port-D for Front */
9212 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
9213 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
9214 /* port-E for HP out (front panel) */
9215 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
9216 /* route front PCM to HP */
9217 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
9218 /* port-F for mic-in (front panel) with vref */
9219 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
9220 /* port-G for CLFE (rear panel) */
9221 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
9222 /* port-H for side (rear panel) */
9223 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
9225 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
9226 /* route front mic to ADC1*/
9227 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
9228 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9229 /* Unmute DAC0~3 & spdif out*/
9230 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9231 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9232 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9233 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9234 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9236 /* Unmute Mixer 14 (mic) 1c (Line in)*/
9237 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9238 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9239 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9240 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9242 /* Unmute Stereo Mixer 15 */
9243 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9244 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9245 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
9246 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
9248 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9249 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9250 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9251 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9252 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9253 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9254 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9255 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9256 /* hp used DAC 3 (Front) */
9257 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
9258 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
9262 static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
9264 * Unmute ADC0 and set the default input to mic-in
9266 /* port-A for surround (rear panel) */
9267 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
9268 /* port-B for mic-in (rear panel) with vref */
9269 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
9270 /* port-C for line-in (rear panel) */
9271 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
9272 /* port-D for Front */
9273 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
9274 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
9275 /* port-E for HP out (front panel) */
9276 /* this has to be set to VREF80 */
9277 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
9278 /* route front PCM to HP */
9279 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
9280 /* port-F for mic-in (front panel) with vref */
9281 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
9282 /* port-G for CLFE (rear panel) */
9283 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
9284 /* port-H for side (rear panel) */
9285 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
9287 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
9288 /* route front mic to ADC1*/
9289 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
9290 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9291 /* Unmute DAC0~3 & spdif out*/
9292 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9293 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9294 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9295 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9296 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9298 /* Unmute Mixer 14 (mic) 1c (Line in)*/
9299 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9300 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9301 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9302 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9304 /* Unmute Stereo Mixer 15 */
9305 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9306 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9307 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
9308 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
9310 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9311 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9312 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9313 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9314 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9315 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9316 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9317 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9318 /* hp used DAC 3 (Front) */
9319 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
9320 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
9324 static struct hda_verb alc861_asus_init_verbs[] = {
9326 * Unmute ADC0 and set the default input to mic-in
9328 /* port-A for surround (rear panel)
9329 * according to codec#0 this is the HP jack
9331 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */
9332 /* route front PCM to HP */
9333 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 },
9334 /* port-B for mic-in (rear panel) with vref */
9335 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
9336 /* port-C for line-in (rear panel) */
9337 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
9338 /* port-D for Front */
9339 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
9340 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
9341 /* port-E for HP out (front panel) */
9342 /* this has to be set to VREF80 */
9343 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
9344 /* route front PCM to HP */
9345 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
9346 /* port-F for mic-in (front panel) with vref */
9347 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
9348 /* port-G for CLFE (rear panel) */
9349 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
9350 /* port-H for side (rear panel) */
9351 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
9353 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
9354 /* route front mic to ADC1*/
9355 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
9356 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9357 /* Unmute DAC0~3 & spdif out*/
9358 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9359 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9360 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9361 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9362 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9363 /* Unmute Mixer 14 (mic) 1c (Line in)*/
9364 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9365 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9366 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9367 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9369 /* Unmute Stereo Mixer 15 */
9370 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9371 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9372 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
9373 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
9375 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9376 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9377 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9378 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9379 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9380 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9381 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9382 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9383 /* hp used DAC 3 (Front) */
9384 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
9385 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
9389 /* additional init verbs for ASUS laptops */
9390 static struct hda_verb alc861_asus_laptop_init_verbs[] = {
9391 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */
9392 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */
9397 * generic initialization of ADC, input mixers and output mixers
9399 static struct hda_verb alc861_auto_init_verbs[] = {
9401 * Unmute ADC0 and set the default input to mic-in
9403 /* {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, */
9404 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9406 /* Unmute DAC0~3 & spdif out*/
9407 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9408 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9409 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9410 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9411 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9413 /* Unmute Mixer 14 (mic) 1c (Line in)*/
9414 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9415 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9416 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9417 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9419 /* Unmute Stereo Mixer 15 */
9420 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9421 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9422 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
9423 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
9425 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9426 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9427 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9428 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9429 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9430 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9431 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9432 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9434 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9435 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9436 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
9437 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
9438 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9439 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9440 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
9441 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
9443 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */
9448 static struct hda_verb alc861_toshiba_init_verbs[] = {
9449 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9454 /* toggle speaker-output according to the hp-jack state */
9455 static void alc861_toshiba_automute(struct hda_codec *codec)
9457 unsigned int present;
9459 present = snd_hda_codec_read(codec, 0x0f, 0,
9460 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
9461 snd_hda_codec_amp_stereo(codec, 0x16, HDA_INPUT, 0,
9462 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
9463 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_INPUT, 3,
9464 HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
9467 static void alc861_toshiba_unsol_event(struct hda_codec *codec,
9470 if ((res >> 26) == ALC880_HP_EVENT)
9471 alc861_toshiba_automute(codec);
9474 /* pcm configuration: identiacal with ALC880 */
9475 #define alc861_pcm_analog_playback alc880_pcm_analog_playback
9476 #define alc861_pcm_analog_capture alc880_pcm_analog_capture
9477 #define alc861_pcm_digital_playback alc880_pcm_digital_playback
9478 #define alc861_pcm_digital_capture alc880_pcm_digital_capture
9481 #define ALC861_DIGOUT_NID 0x07
9483 static struct hda_channel_mode alc861_8ch_modes[1] = {
9487 static hda_nid_t alc861_dac_nids[4] = {
9488 /* front, surround, clfe, side */
9489 0x03, 0x06, 0x05, 0x04
9492 static hda_nid_t alc660_dac_nids[3] = {
9493 /* front, clfe, surround */
9497 static hda_nid_t alc861_adc_nids[1] = {
9502 static struct hda_input_mux alc861_capture_source = {
9506 { "Front Mic", 0x3 },
9513 /* fill in the dac_nids table from the parsed pin configuration */
9514 static int alc861_auto_fill_dac_nids(struct alc_spec *spec,
9515 const struct auto_pin_cfg *cfg)
9520 spec->multiout.dac_nids = spec->private_dac_nids;
9521 for (i = 0; i < cfg->line_outs; i++) {
9522 nid = cfg->line_out_pins[i];
9524 if (i >= ARRAY_SIZE(alc861_dac_nids))
9526 spec->multiout.dac_nids[i] = alc861_dac_nids[i];
9529 spec->multiout.num_dacs = cfg->line_outs;
9533 /* add playback controls from the parsed DAC table */
9534 static int alc861_auto_create_multi_out_ctls(struct alc_spec *spec,
9535 const struct auto_pin_cfg *cfg)
9538 static const char *chname[4] = {
9539 "Front", "Surround", NULL /*CLFE*/, "Side"
9544 for (i = 0; i < cfg->line_outs; i++) {
9545 nid = spec->multiout.dac_nids[i];
9550 err = add_control(spec, ALC_CTL_BIND_MUTE,
9551 "Center Playback Switch",
9552 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
9556 err = add_control(spec, ALC_CTL_BIND_MUTE,
9557 "LFE Playback Switch",
9558 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
9563 for (idx = 0; idx < ARRAY_SIZE(alc861_dac_nids) - 1;
9565 if (nid == alc861_dac_nids[idx])
9567 sprintf(name, "%s Playback Switch", chname[idx]);
9568 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
9569 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
9578 static int alc861_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin)
9586 if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
9588 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
9589 "Headphone Playback Switch",
9590 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
9593 spec->multiout.hp_nid = nid;
9598 /* create playback/capture controls for input pins */
9599 static int alc861_auto_create_analog_input_ctls(struct alc_spec *spec,
9600 const struct auto_pin_cfg *cfg)
9602 struct hda_input_mux *imux = &spec->private_imux;
9603 int i, err, idx, idx1;
9605 for (i = 0; i < AUTO_PIN_LAST; i++) {
9606 switch (cfg->input_pins[i]) {
9609 idx = 2; /* Line In */
9613 idx = 2; /* Line In */
9617 idx = 1; /* Mic In */
9621 idx = 1; /* Mic In */
9631 err = new_analog_input(spec, cfg->input_pins[i],
9632 auto_pin_cfg_labels[i], idx, 0x15);
9636 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
9637 imux->items[imux->num_items].index = idx1;
9643 static struct snd_kcontrol_new alc861_capture_mixer[] = {
9644 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
9645 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
9648 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9649 /* The multiple "Capture Source" controls confuse alsamixer
9650 * So call somewhat different..
9651 *FIXME: the controls appear in the "playback" view!
9653 /* .name = "Capture Source", */
9654 .name = "Input Source",
9656 .info = alc_mux_enum_info,
9657 .get = alc_mux_enum_get,
9658 .put = alc_mux_enum_put,
9663 static void alc861_auto_set_output_and_unmute(struct hda_codec *codec,
9665 int pin_type, int dac_idx)
9669 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
9671 snd_hda_codec_write(codec, dac_idx, 0, AC_VERB_SET_AMP_GAIN_MUTE,
9676 static void alc861_auto_init_multi_out(struct hda_codec *codec)
9678 struct alc_spec *spec = codec->spec;
9681 alc_subsystem_id(codec, 0x0e, 0x0f, 0x0b);
9682 for (i = 0; i < spec->autocfg.line_outs; i++) {
9683 hda_nid_t nid = spec->autocfg.line_out_pins[i];
9684 int pin_type = get_pin_type(spec->autocfg.line_out_type);
9686 alc861_auto_set_output_and_unmute(codec, nid, pin_type,
9687 spec->multiout.dac_nids[i]);
9691 static void alc861_auto_init_hp_out(struct hda_codec *codec)
9693 struct alc_spec *spec = codec->spec;
9696 pin = spec->autocfg.hp_pins[0];
9697 if (pin) /* connect to front */
9698 alc861_auto_set_output_and_unmute(codec, pin, PIN_HP,
9699 spec->multiout.dac_nids[0]);
9702 static void alc861_auto_init_analog_input(struct hda_codec *codec)
9704 struct alc_spec *spec = codec->spec;
9707 for (i = 0; i < AUTO_PIN_LAST; i++) {
9708 hda_nid_t nid = spec->autocfg.input_pins[i];
9709 if (nid >= 0x0c && nid <= 0x11) {
9710 snd_hda_codec_write(codec, nid, 0,
9711 AC_VERB_SET_PIN_WIDGET_CONTROL,
9712 i <= AUTO_PIN_FRONT_MIC ?
9713 PIN_VREF80 : PIN_IN);
9718 /* parse the BIOS configuration and set up the alc_spec */
9719 /* return 1 if successful, 0 if the proper config is not found,
9720 * or a negative error code
9722 static int alc861_parse_auto_config(struct hda_codec *codec)
9724 struct alc_spec *spec = codec->spec;
9726 static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
9728 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
9732 if (!spec->autocfg.line_outs)
9733 return 0; /* can't find valid BIOS pin config */
9735 err = alc861_auto_fill_dac_nids(spec, &spec->autocfg);
9738 err = alc861_auto_create_multi_out_ctls(spec, &spec->autocfg);
9741 err = alc861_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0]);
9744 err = alc861_auto_create_analog_input_ctls(spec, &spec->autocfg);
9748 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
9750 if (spec->autocfg.dig_out_pin)
9751 spec->multiout.dig_out_nid = ALC861_DIGOUT_NID;
9753 if (spec->kctl_alloc)
9754 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
9756 spec->init_verbs[spec->num_init_verbs++] = alc861_auto_init_verbs;
9758 spec->num_mux_defs = 1;
9759 spec->input_mux = &spec->private_imux;
9761 spec->adc_nids = alc861_adc_nids;
9762 spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
9763 spec->mixers[spec->num_mixers] = alc861_capture_mixer;
9769 /* additional initialization for auto-configuration model */
9770 static void alc861_auto_init(struct hda_codec *codec)
9772 alc861_auto_init_multi_out(codec);
9773 alc861_auto_init_hp_out(codec);
9774 alc861_auto_init_analog_input(codec);
9777 #ifdef CONFIG_SND_HDA_POWER_SAVE
9778 static struct hda_amp_list alc861_loopbacks[] = {
9779 { 0x15, HDA_INPUT, 0 },
9780 { 0x15, HDA_INPUT, 1 },
9781 { 0x15, HDA_INPUT, 2 },
9782 { 0x15, HDA_INPUT, 3 },
9789 * configuration and preset
9791 static const char *alc861_models[ALC861_MODEL_LAST] = {
9792 [ALC861_3ST] = "3stack",
9793 [ALC660_3ST] = "3stack-660",
9794 [ALC861_3ST_DIG] = "3stack-dig",
9795 [ALC861_6ST_DIG] = "6stack-dig",
9796 [ALC861_UNIWILL_M31] = "uniwill-m31",
9797 [ALC861_TOSHIBA] = "toshiba",
9798 [ALC861_ASUS] = "asus",
9799 [ALC861_ASUS_LAPTOP] = "asus-laptop",
9800 [ALC861_AUTO] = "auto",
9803 static struct snd_pci_quirk alc861_cfg_tbl[] = {
9804 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST),
9805 SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP),
9806 SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP),
9807 SND_PCI_QUIRK(0x1043, 0x13d7, "ASUS A9rp", ALC861_ASUS_LAPTOP),
9808 SND_PCI_QUIRK(0x1584, 0x9075, "Airis Praxis N1212", ALC861_ASUS_LAPTOP),
9809 SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS),
9810 SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS P1-AH2", ALC861_3ST_DIG),
9811 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA),
9812 /* FIXME: the entry below breaks Toshiba A100 (model=auto works!)
9813 * Any other models that need this preset?
9815 /* SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA), */
9816 SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31),
9817 SND_PCI_QUIRK(0x1584, 0x9075, "Uniwill", ALC861_UNIWILL_M31),
9818 SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31),
9819 SND_PCI_QUIRK(0x1849, 0x0660, "Asrock 939SLI32", ALC660_3ST),
9820 SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST),
9821 SND_PCI_QUIRK(0x1462, 0x7254, "HP dx2200 (MSI MS-7254)", ALC861_3ST),
9822 SND_PCI_QUIRK(0x1462, 0x7297, "HP dx2250 (MSI MS-7297)", ALC861_3ST),
9826 static struct alc_config_preset alc861_presets[] = {
9828 .mixers = { alc861_3ST_mixer },
9829 .init_verbs = { alc861_threestack_init_verbs },
9830 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
9831 .dac_nids = alc861_dac_nids,
9832 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
9833 .channel_mode = alc861_threestack_modes,
9835 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
9836 .adc_nids = alc861_adc_nids,
9837 .input_mux = &alc861_capture_source,
9839 [ALC861_3ST_DIG] = {
9840 .mixers = { alc861_base_mixer },
9841 .init_verbs = { alc861_threestack_init_verbs },
9842 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
9843 .dac_nids = alc861_dac_nids,
9844 .dig_out_nid = ALC861_DIGOUT_NID,
9845 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
9846 .channel_mode = alc861_threestack_modes,
9848 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
9849 .adc_nids = alc861_adc_nids,
9850 .input_mux = &alc861_capture_source,
9852 [ALC861_6ST_DIG] = {
9853 .mixers = { alc861_base_mixer },
9854 .init_verbs = { alc861_base_init_verbs },
9855 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
9856 .dac_nids = alc861_dac_nids,
9857 .dig_out_nid = ALC861_DIGOUT_NID,
9858 .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
9859 .channel_mode = alc861_8ch_modes,
9860 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
9861 .adc_nids = alc861_adc_nids,
9862 .input_mux = &alc861_capture_source,
9865 .mixers = { alc861_3ST_mixer },
9866 .init_verbs = { alc861_threestack_init_verbs },
9867 .num_dacs = ARRAY_SIZE(alc660_dac_nids),
9868 .dac_nids = alc660_dac_nids,
9869 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
9870 .channel_mode = alc861_threestack_modes,
9872 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
9873 .adc_nids = alc861_adc_nids,
9874 .input_mux = &alc861_capture_source,
9876 [ALC861_UNIWILL_M31] = {
9877 .mixers = { alc861_uniwill_m31_mixer },
9878 .init_verbs = { alc861_uniwill_m31_init_verbs },
9879 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
9880 .dac_nids = alc861_dac_nids,
9881 .dig_out_nid = ALC861_DIGOUT_NID,
9882 .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes),
9883 .channel_mode = alc861_uniwill_m31_modes,
9885 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
9886 .adc_nids = alc861_adc_nids,
9887 .input_mux = &alc861_capture_source,
9889 [ALC861_TOSHIBA] = {
9890 .mixers = { alc861_toshiba_mixer },
9891 .init_verbs = { alc861_base_init_verbs,
9892 alc861_toshiba_init_verbs },
9893 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
9894 .dac_nids = alc861_dac_nids,
9895 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9896 .channel_mode = alc883_3ST_2ch_modes,
9897 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
9898 .adc_nids = alc861_adc_nids,
9899 .input_mux = &alc861_capture_source,
9900 .unsol_event = alc861_toshiba_unsol_event,
9901 .init_hook = alc861_toshiba_automute,
9904 .mixers = { alc861_asus_mixer },
9905 .init_verbs = { alc861_asus_init_verbs },
9906 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
9907 .dac_nids = alc861_dac_nids,
9908 .dig_out_nid = ALC861_DIGOUT_NID,
9909 .num_channel_mode = ARRAY_SIZE(alc861_asus_modes),
9910 .channel_mode = alc861_asus_modes,
9913 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
9914 .adc_nids = alc861_adc_nids,
9915 .input_mux = &alc861_capture_source,
9917 [ALC861_ASUS_LAPTOP] = {
9918 .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer },
9919 .init_verbs = { alc861_asus_init_verbs,
9920 alc861_asus_laptop_init_verbs },
9921 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
9922 .dac_nids = alc861_dac_nids,
9923 .dig_out_nid = ALC861_DIGOUT_NID,
9924 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9925 .channel_mode = alc883_3ST_2ch_modes,
9927 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
9928 .adc_nids = alc861_adc_nids,
9929 .input_mux = &alc861_capture_source,
9934 static int patch_alc861(struct hda_codec *codec)
9936 struct alc_spec *spec;
9940 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
9946 board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST,
9950 if (board_config < 0) {
9951 printk(KERN_INFO "hda_codec: Unknown model for ALC861, "
9952 "trying auto-probe from BIOS...\n");
9953 board_config = ALC861_AUTO;
9956 if (board_config == ALC861_AUTO) {
9957 /* automatic parse from the BIOS config */
9958 err = alc861_parse_auto_config(codec);
9964 "hda_codec: Cannot set up configuration "
9965 "from BIOS. Using base mode...\n");
9966 board_config = ALC861_3ST_DIG;
9970 if (board_config != ALC861_AUTO)
9971 setup_preset(spec, &alc861_presets[board_config]);
9973 spec->stream_name_analog = "ALC861 Analog";
9974 spec->stream_analog_playback = &alc861_pcm_analog_playback;
9975 spec->stream_analog_capture = &alc861_pcm_analog_capture;
9977 spec->stream_name_digital = "ALC861 Digital";
9978 spec->stream_digital_playback = &alc861_pcm_digital_playback;
9979 spec->stream_digital_capture = &alc861_pcm_digital_capture;
9981 codec->patch_ops = alc_patch_ops;
9982 if (board_config == ALC861_AUTO)
9983 spec->init_hook = alc861_auto_init;
9984 #ifdef CONFIG_SND_HDA_POWER_SAVE
9985 if (!spec->loopback.amplist)
9986 spec->loopback.amplist = alc861_loopbacks;
9997 * In addition, an independent DAC
9999 #define ALC861VD_DIGOUT_NID 0x06
10001 static hda_nid_t alc861vd_dac_nids[4] = {
10002 /* front, surr, clfe, side surr */
10003 0x02, 0x03, 0x04, 0x05
10006 /* dac_nids for ALC660vd are in a different order - according to
10007 * Realtek's driver.
10008 * This should probably tesult in a different mixer for 6stack models
10009 * of ALC660vd codecs, but for now there is only 3stack mixer
10010 * - and it is the same as in 861vd.
10011 * adc_nids in ALC660vd are (is) the same as in 861vd
10013 static hda_nid_t alc660vd_dac_nids[3] = {
10014 /* front, rear, clfe, rear_surr */
10018 static hda_nid_t alc861vd_adc_nids[1] = {
10024 /* FIXME: should be a matrix-type input source selection */
10025 static struct hda_input_mux alc861vd_capture_source = {
10029 { "Front Mic", 0x1 },
10035 static struct hda_input_mux alc861vd_dallas_capture_source = {
10038 { "Front Mic", 0x0 },
10039 { "ATAPI Mic", 0x1 },
10040 { "Line In", 0x5 },
10044 static struct hda_input_mux alc861vd_hp_capture_source = {
10047 { "Front Mic", 0x0 },
10048 { "ATAPI Mic", 0x1 },
10052 #define alc861vd_mux_enum_info alc_mux_enum_info
10053 #define alc861vd_mux_enum_get alc_mux_enum_get
10055 static int alc861vd_mux_enum_put(struct snd_kcontrol *kcontrol,
10056 struct snd_ctl_elem_value *ucontrol)
10058 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10059 struct alc_spec *spec = codec->spec;
10060 const struct hda_input_mux *imux = spec->input_mux;
10061 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
10062 static hda_nid_t capture_mixers[1] = { 0x22 };
10063 hda_nid_t nid = capture_mixers[adc_idx];
10064 unsigned int *cur_val = &spec->cur_mux[adc_idx];
10065 unsigned int i, idx;
10067 idx = ucontrol->value.enumerated.item[0];
10068 if (idx >= imux->num_items)
10069 idx = imux->num_items - 1;
10070 if (*cur_val == idx)
10072 for (i = 0; i < imux->num_items; i++) {
10073 unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
10074 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
10075 imux->items[i].index,
10085 static struct hda_channel_mode alc861vd_3stack_2ch_modes[1] = {
10092 static struct hda_verb alc861vd_6stack_ch6_init[] = {
10093 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
10094 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10095 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10096 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10103 static struct hda_verb alc861vd_6stack_ch8_init[] = {
10104 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10105 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10106 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10107 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10111 static struct hda_channel_mode alc861vd_6stack_modes[2] = {
10112 { 6, alc861vd_6stack_ch6_init },
10113 { 8, alc861vd_6stack_ch8_init },
10116 static struct snd_kcontrol_new alc861vd_chmode_mixer[] = {
10118 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10119 .name = "Channel Mode",
10120 .info = alc_ch_mode_info,
10121 .get = alc_ch_mode_get,
10122 .put = alc_ch_mode_put,
10127 static struct snd_kcontrol_new alc861vd_capture_mixer[] = {
10128 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
10129 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
10132 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10133 /* The multiple "Capture Source" controls confuse alsamixer
10134 * So call somewhat different..
10135 *FIXME: the controls appear in the "playback" view!
10137 /* .name = "Capture Source", */
10138 .name = "Input Source",
10140 .info = alc861vd_mux_enum_info,
10141 .get = alc861vd_mux_enum_get,
10142 .put = alc861vd_mux_enum_put,
10147 /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
10148 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
10150 static struct snd_kcontrol_new alc861vd_6st_mixer[] = {
10151 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
10152 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
10154 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
10155 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
10157 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0,
10159 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0,
10161 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
10162 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
10164 HDA_CODEC_VOLUME("Side Playback Volume", 0x05, 0x0, HDA_OUTPUT),
10165 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
10167 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
10169 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10170 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10171 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10173 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10174 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
10175 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
10177 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10178 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10180 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10181 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10183 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
10184 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
10189 static struct snd_kcontrol_new alc861vd_3st_mixer[] = {
10190 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
10191 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
10193 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
10195 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10196 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10197 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10199 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10200 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
10201 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
10203 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10204 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10206 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10207 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10209 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
10210 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
10215 static struct snd_kcontrol_new alc861vd_lenovo_mixer[] = {
10216 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
10217 /*HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),*/
10218 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
10220 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
10222 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10223 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10224 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10226 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10227 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
10228 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
10230 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10231 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10236 /* Pin assignment: Front=0x14, HP = 0x15,
10237 * Front Mic=0x18, ATAPI Mic = 0x19, Line In = 0x1d
10239 static struct snd_kcontrol_new alc861vd_dallas_mixer[] = {
10240 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
10241 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
10242 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
10243 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
10244 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10245 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10246 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
10247 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
10248 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x05, HDA_INPUT),
10249 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x05, HDA_INPUT),
10253 /* Pin assignment: Speaker=0x14, Line-out = 0x15,
10254 * Front Mic=0x18, ATAPI Mic = 0x19,
10256 static struct snd_kcontrol_new alc861vd_hp_mixer[] = {
10257 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
10258 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
10259 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
10260 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
10261 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10262 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10263 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
10264 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
10270 * generic initialization of ADC, input mixers and output mixers
10272 static struct hda_verb alc861vd_volume_init_verbs[] = {
10274 * Unmute ADC0 and set the default input to mic-in
10276 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
10277 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10279 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of
10280 * the analog-loopback mixer widget
10282 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
10283 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10284 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10285 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10286 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10287 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
10289 /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */
10290 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10291 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10292 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
10293 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
10296 * Set up output mixers (0x02 - 0x05)
10298 /* set vol=0 to output mixers */
10299 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10300 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10301 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10302 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10304 /* set up input amps for analog loopback */
10305 /* Amp Indices: DAC = 0, mixer = 1 */
10306 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10307 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10308 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10309 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10310 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10311 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10312 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10313 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10319 * 3-stack pin configuration:
10320 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
10322 static struct hda_verb alc861vd_3stack_init_verbs[] = {
10324 * Set pin mode and muting
10326 /* set front pin widgets 0x14 for output */
10327 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10328 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10329 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
10331 /* Mic (rear) pin: input vref at 80% */
10332 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
10333 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10334 /* Front Mic pin: input vref at 80% */
10335 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
10336 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10337 /* Line In pin: input */
10338 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10339 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10340 /* Line-2 In: Headphone output (output 0 - 0x0c) */
10341 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10342 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10343 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
10344 /* CD pin widget for input */
10345 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10351 * 6-stack pin configuration:
10353 static struct hda_verb alc861vd_6stack_init_verbs[] = {
10355 * Set pin mode and muting
10357 /* set front pin widgets 0x14 for output */
10358 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10359 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10360 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
10362 /* Rear Pin: output 1 (0x0d) */
10363 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10364 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10365 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
10366 /* CLFE Pin: output 2 (0x0e) */
10367 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10368 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10369 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
10370 /* Side Pin: output 3 (0x0f) */
10371 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10372 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10373 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
10375 /* Mic (rear) pin: input vref at 80% */
10376 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
10377 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10378 /* Front Mic pin: input vref at 80% */
10379 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
10380 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10381 /* Line In pin: input */
10382 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10383 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10384 /* Line-2 In: Headphone output (output 0 - 0x0c) */
10385 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10386 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10387 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
10388 /* CD pin widget for input */
10389 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10394 static struct hda_verb alc861vd_eapd_verbs[] = {
10395 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
10399 static struct hda_verb alc861vd_lenovo_unsol_verbs[] = {
10400 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10401 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10402 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
10403 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10404 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
10408 /* toggle speaker-output according to the hp-jack state */
10409 static void alc861vd_lenovo_hp_automute(struct hda_codec *codec)
10411 unsigned int present;
10412 unsigned char bits;
10414 present = snd_hda_codec_read(codec, 0x1b, 0,
10415 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
10416 bits = present ? HDA_AMP_MUTE : 0;
10417 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10418 HDA_AMP_MUTE, bits);
10421 static void alc861vd_lenovo_mic_automute(struct hda_codec *codec)
10423 unsigned int present;
10424 unsigned char bits;
10426 present = snd_hda_codec_read(codec, 0x18, 0,
10427 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
10428 bits = present ? HDA_AMP_MUTE : 0;
10429 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
10430 HDA_AMP_MUTE, bits);
10433 static void alc861vd_lenovo_automute(struct hda_codec *codec)
10435 alc861vd_lenovo_hp_automute(codec);
10436 alc861vd_lenovo_mic_automute(codec);
10439 static void alc861vd_lenovo_unsol_event(struct hda_codec *codec,
10442 switch (res >> 26) {
10443 case ALC880_HP_EVENT:
10444 alc861vd_lenovo_hp_automute(codec);
10446 case ALC880_MIC_EVENT:
10447 alc861vd_lenovo_mic_automute(codec);
10452 static struct hda_verb alc861vd_dallas_verbs[] = {
10453 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10454 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10455 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10456 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10458 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10459 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10460 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10461 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10462 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10463 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10464 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10465 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10467 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10468 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10469 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10470 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10471 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10472 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10473 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10474 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10476 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
10477 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10478 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
10479 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10480 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10481 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10482 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10483 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10485 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10486 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10487 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10488 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
10490 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10491 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
10492 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10497 /* toggle speaker-output according to the hp-jack state */
10498 static void alc861vd_dallas_automute(struct hda_codec *codec)
10500 unsigned int present;
10502 present = snd_hda_codec_read(codec, 0x15, 0,
10503 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
10504 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10505 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
10508 static void alc861vd_dallas_unsol_event(struct hda_codec *codec, unsigned int res)
10510 if ((res >> 26) == ALC880_HP_EVENT)
10511 alc861vd_dallas_automute(codec);
10514 #ifdef CONFIG_SND_HDA_POWER_SAVE
10515 #define alc861vd_loopbacks alc880_loopbacks
10518 /* pcm configuration: identiacal with ALC880 */
10519 #define alc861vd_pcm_analog_playback alc880_pcm_analog_playback
10520 #define alc861vd_pcm_analog_capture alc880_pcm_analog_capture
10521 #define alc861vd_pcm_digital_playback alc880_pcm_digital_playback
10522 #define alc861vd_pcm_digital_capture alc880_pcm_digital_capture
10525 * configuration and preset
10527 static const char *alc861vd_models[ALC861VD_MODEL_LAST] = {
10528 [ALC660VD_3ST] = "3stack-660",
10529 [ALC660VD_3ST_DIG] = "3stack-660-digout",
10530 [ALC861VD_3ST] = "3stack",
10531 [ALC861VD_3ST_DIG] = "3stack-digout",
10532 [ALC861VD_6ST_DIG] = "6stack-digout",
10533 [ALC861VD_LENOVO] = "lenovo",
10534 [ALC861VD_DALLAS] = "dallas",
10535 [ALC861VD_HP] = "hp",
10536 [ALC861VD_AUTO] = "auto",
10539 static struct snd_pci_quirk alc861vd_cfg_tbl[] = {
10540 SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST),
10541 SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST),
10542 SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660VD_3ST_DIG),
10543 SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST),
10544 SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST),
10546 SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),
10547 SND_PCI_QUIRK(0x1179, 0xff01, "DALLAS", ALC861VD_DALLAS),
10548 SND_PCI_QUIRK(0x17aa, 0x3802, "Lenovo 3000 C200", ALC861VD_LENOVO),
10549 SND_PCI_QUIRK(0x17aa, 0x2066, "Lenovo", ALC861VD_LENOVO),
10550 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba A135", ALC861VD_LENOVO),
10551 SND_PCI_QUIRK(0x1565, 0x820d, "Biostar NF61S SE", ALC861VD_6ST_DIG),
10552 SND_PCI_QUIRK(0x1849, 0x0862, "ASRock K8NF6G-VSTA", ALC861VD_6ST_DIG),
10553 SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_HP),
10557 static struct alc_config_preset alc861vd_presets[] = {
10559 .mixers = { alc861vd_3st_mixer },
10560 .init_verbs = { alc861vd_volume_init_verbs,
10561 alc861vd_3stack_init_verbs },
10562 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
10563 .dac_nids = alc660vd_dac_nids,
10564 .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
10565 .adc_nids = alc861vd_adc_nids,
10566 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
10567 .channel_mode = alc861vd_3stack_2ch_modes,
10568 .input_mux = &alc861vd_capture_source,
10570 [ALC660VD_3ST_DIG] = {
10571 .mixers = { alc861vd_3st_mixer },
10572 .init_verbs = { alc861vd_volume_init_verbs,
10573 alc861vd_3stack_init_verbs },
10574 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
10575 .dac_nids = alc660vd_dac_nids,
10576 .dig_out_nid = ALC861VD_DIGOUT_NID,
10577 .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
10578 .adc_nids = alc861vd_adc_nids,
10579 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
10580 .channel_mode = alc861vd_3stack_2ch_modes,
10581 .input_mux = &alc861vd_capture_source,
10584 .mixers = { alc861vd_3st_mixer },
10585 .init_verbs = { alc861vd_volume_init_verbs,
10586 alc861vd_3stack_init_verbs },
10587 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
10588 .dac_nids = alc861vd_dac_nids,
10589 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
10590 .channel_mode = alc861vd_3stack_2ch_modes,
10591 .input_mux = &alc861vd_capture_source,
10593 [ALC861VD_3ST_DIG] = {
10594 .mixers = { alc861vd_3st_mixer },
10595 .init_verbs = { alc861vd_volume_init_verbs,
10596 alc861vd_3stack_init_verbs },
10597 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
10598 .dac_nids = alc861vd_dac_nids,
10599 .dig_out_nid = ALC861VD_DIGOUT_NID,
10600 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
10601 .channel_mode = alc861vd_3stack_2ch_modes,
10602 .input_mux = &alc861vd_capture_source,
10604 [ALC861VD_6ST_DIG] = {
10605 .mixers = { alc861vd_6st_mixer, alc861vd_chmode_mixer },
10606 .init_verbs = { alc861vd_volume_init_verbs,
10607 alc861vd_6stack_init_verbs },
10608 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
10609 .dac_nids = alc861vd_dac_nids,
10610 .dig_out_nid = ALC861VD_DIGOUT_NID,
10611 .num_channel_mode = ARRAY_SIZE(alc861vd_6stack_modes),
10612 .channel_mode = alc861vd_6stack_modes,
10613 .input_mux = &alc861vd_capture_source,
10615 [ALC861VD_LENOVO] = {
10616 .mixers = { alc861vd_lenovo_mixer },
10617 .init_verbs = { alc861vd_volume_init_verbs,
10618 alc861vd_3stack_init_verbs,
10619 alc861vd_eapd_verbs,
10620 alc861vd_lenovo_unsol_verbs },
10621 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
10622 .dac_nids = alc660vd_dac_nids,
10623 .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
10624 .adc_nids = alc861vd_adc_nids,
10625 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
10626 .channel_mode = alc861vd_3stack_2ch_modes,
10627 .input_mux = &alc861vd_capture_source,
10628 .unsol_event = alc861vd_lenovo_unsol_event,
10629 .init_hook = alc861vd_lenovo_automute,
10631 [ALC861VD_DALLAS] = {
10632 .mixers = { alc861vd_dallas_mixer },
10633 .init_verbs = { alc861vd_dallas_verbs },
10634 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
10635 .dac_nids = alc861vd_dac_nids,
10636 .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
10637 .adc_nids = alc861vd_adc_nids,
10638 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
10639 .channel_mode = alc861vd_3stack_2ch_modes,
10640 .input_mux = &alc861vd_dallas_capture_source,
10641 .unsol_event = alc861vd_dallas_unsol_event,
10642 .init_hook = alc861vd_dallas_automute,
10645 .mixers = { alc861vd_hp_mixer },
10646 .init_verbs = { alc861vd_dallas_verbs, alc861vd_eapd_verbs },
10647 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
10648 .dac_nids = alc861vd_dac_nids,
10649 .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
10650 .dig_out_nid = ALC861VD_DIGOUT_NID,
10651 .adc_nids = alc861vd_adc_nids,
10652 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
10653 .channel_mode = alc861vd_3stack_2ch_modes,
10654 .input_mux = &alc861vd_hp_capture_source,
10655 .unsol_event = alc861vd_dallas_unsol_event,
10656 .init_hook = alc861vd_dallas_automute,
10661 * BIOS auto configuration
10663 static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec,
10664 hda_nid_t nid, int pin_type, int dac_idx)
10666 /* set as output */
10667 snd_hda_codec_write(codec, nid, 0,
10668 AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
10669 snd_hda_codec_write(codec, nid, 0,
10670 AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
10673 static void alc861vd_auto_init_multi_out(struct hda_codec *codec)
10675 struct alc_spec *spec = codec->spec;
10678 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
10679 for (i = 0; i <= HDA_SIDE; i++) {
10680 hda_nid_t nid = spec->autocfg.line_out_pins[i];
10681 int pin_type = get_pin_type(spec->autocfg.line_out_type);
10683 alc861vd_auto_set_output_and_unmute(codec, nid,
10689 static void alc861vd_auto_init_hp_out(struct hda_codec *codec)
10691 struct alc_spec *spec = codec->spec;
10694 pin = spec->autocfg.hp_pins[0];
10695 if (pin) /* connect to front and use dac 0 */
10696 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
10699 #define alc861vd_is_input_pin(nid) alc880_is_input_pin(nid)
10700 #define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID
10702 static void alc861vd_auto_init_analog_input(struct hda_codec *codec)
10704 struct alc_spec *spec = codec->spec;
10707 for (i = 0; i < AUTO_PIN_LAST; i++) {
10708 hda_nid_t nid = spec->autocfg.input_pins[i];
10709 if (alc861vd_is_input_pin(nid)) {
10710 snd_hda_codec_write(codec, nid, 0,
10711 AC_VERB_SET_PIN_WIDGET_CONTROL,
10712 i <= AUTO_PIN_FRONT_MIC ?
10713 PIN_VREF80 : PIN_IN);
10714 if (nid != ALC861VD_PIN_CD_NID)
10715 snd_hda_codec_write(codec, nid, 0,
10716 AC_VERB_SET_AMP_GAIN_MUTE,
10722 #define alc861vd_idx_to_mixer_vol(nid) ((nid) + 0x02)
10723 #define alc861vd_idx_to_mixer_switch(nid) ((nid) + 0x0c)
10725 /* add playback controls from the parsed DAC table */
10726 /* Based on ALC880 version. But ALC861VD has separate,
10727 * different NIDs for mute/unmute switch and volume control */
10728 static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
10729 const struct auto_pin_cfg *cfg)
10732 static const char *chname[4] = {"Front", "Surround", "CLFE", "Side"};
10733 hda_nid_t nid_v, nid_s;
10736 for (i = 0; i < cfg->line_outs; i++) {
10737 if (!spec->multiout.dac_nids[i])
10739 nid_v = alc861vd_idx_to_mixer_vol(
10741 spec->multiout.dac_nids[i]));
10742 nid_s = alc861vd_idx_to_mixer_switch(
10744 spec->multiout.dac_nids[i]));
10748 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10749 "Center Playback Volume",
10750 HDA_COMPOSE_AMP_VAL(nid_v, 1, 0,
10754 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10755 "LFE Playback Volume",
10756 HDA_COMPOSE_AMP_VAL(nid_v, 2, 0,
10760 err = add_control(spec, ALC_CTL_BIND_MUTE,
10761 "Center Playback Switch",
10762 HDA_COMPOSE_AMP_VAL(nid_s, 1, 2,
10766 err = add_control(spec, ALC_CTL_BIND_MUTE,
10767 "LFE Playback Switch",
10768 HDA_COMPOSE_AMP_VAL(nid_s, 2, 2,
10773 sprintf(name, "%s Playback Volume", chname[i]);
10774 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
10775 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0,
10779 sprintf(name, "%s Playback Switch", chname[i]);
10780 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
10781 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2,
10790 /* add playback controls for speaker and HP outputs */
10791 /* Based on ALC880 version. But ALC861VD has separate,
10792 * different NIDs for mute/unmute switch and volume control */
10793 static int alc861vd_auto_create_extra_out(struct alc_spec *spec,
10794 hda_nid_t pin, const char *pfx)
10796 hda_nid_t nid_v, nid_s;
10803 if (alc880_is_fixed_pin(pin)) {
10804 nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
10805 /* specify the DAC as the extra output */
10806 if (!spec->multiout.hp_nid)
10807 spec->multiout.hp_nid = nid_v;
10809 spec->multiout.extra_out_nid[0] = nid_v;
10810 /* control HP volume/switch on the output mixer amp */
10811 nid_v = alc861vd_idx_to_mixer_vol(
10812 alc880_fixed_pin_idx(pin));
10813 nid_s = alc861vd_idx_to_mixer_switch(
10814 alc880_fixed_pin_idx(pin));
10816 sprintf(name, "%s Playback Volume", pfx);
10817 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
10818 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT));
10821 sprintf(name, "%s Playback Switch", pfx);
10822 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
10823 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT));
10826 } else if (alc880_is_multi_pin(pin)) {
10827 /* set manual connection */
10828 /* we have only a switch on HP-out PIN */
10829 sprintf(name, "%s Playback Switch", pfx);
10830 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
10831 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
10838 /* parse the BIOS configuration and set up the alc_spec
10839 * return 1 if successful, 0 if the proper config is not found,
10840 * or a negative error code
10841 * Based on ALC880 version - had to change it to override
10842 * alc880_auto_create_extra_out and alc880_auto_create_multi_out_ctls */
10843 static int alc861vd_parse_auto_config(struct hda_codec *codec)
10845 struct alc_spec *spec = codec->spec;
10847 static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
10849 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
10853 if (!spec->autocfg.line_outs)
10854 return 0; /* can't find valid BIOS pin config */
10856 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
10859 err = alc861vd_auto_create_multi_out_ctls(spec, &spec->autocfg);
10862 err = alc861vd_auto_create_extra_out(spec,
10863 spec->autocfg.speaker_pins[0],
10867 err = alc861vd_auto_create_extra_out(spec,
10868 spec->autocfg.hp_pins[0],
10872 err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
10876 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
10878 if (spec->autocfg.dig_out_pin)
10879 spec->multiout.dig_out_nid = ALC861VD_DIGOUT_NID;
10881 if (spec->kctl_alloc)
10882 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
10884 spec->init_verbs[spec->num_init_verbs++]
10885 = alc861vd_volume_init_verbs;
10887 spec->num_mux_defs = 1;
10888 spec->input_mux = &spec->private_imux;
10893 /* additional initialization for auto-configuration model */
10894 static void alc861vd_auto_init(struct hda_codec *codec)
10896 alc861vd_auto_init_multi_out(codec);
10897 alc861vd_auto_init_hp_out(codec);
10898 alc861vd_auto_init_analog_input(codec);
10901 static int patch_alc861vd(struct hda_codec *codec)
10903 struct alc_spec *spec;
10904 int err, board_config;
10906 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
10910 codec->spec = spec;
10912 board_config = snd_hda_check_board_config(codec, ALC861VD_MODEL_LAST,
10916 if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) {
10917 printk(KERN_INFO "hda_codec: Unknown model for ALC660VD/"
10918 "ALC861VD, trying auto-probe from BIOS...\n");
10919 board_config = ALC861VD_AUTO;
10922 if (board_config == ALC861VD_AUTO) {
10923 /* automatic parse from the BIOS config */
10924 err = alc861vd_parse_auto_config(codec);
10930 "hda_codec: Cannot set up configuration "
10931 "from BIOS. Using base mode...\n");
10932 board_config = ALC861VD_3ST;
10936 if (board_config != ALC861VD_AUTO)
10937 setup_preset(spec, &alc861vd_presets[board_config]);
10939 spec->stream_name_analog = "ALC861VD Analog";
10940 spec->stream_analog_playback = &alc861vd_pcm_analog_playback;
10941 spec->stream_analog_capture = &alc861vd_pcm_analog_capture;
10943 spec->stream_name_digital = "ALC861VD Digital";
10944 spec->stream_digital_playback = &alc861vd_pcm_digital_playback;
10945 spec->stream_digital_capture = &alc861vd_pcm_digital_capture;
10947 spec->adc_nids = alc861vd_adc_nids;
10948 spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids);
10950 spec->mixers[spec->num_mixers] = alc861vd_capture_mixer;
10951 spec->num_mixers++;
10953 codec->patch_ops = alc_patch_ops;
10955 if (board_config == ALC861VD_AUTO)
10956 spec->init_hook = alc861vd_auto_init;
10957 #ifdef CONFIG_SND_HDA_POWER_SAVE
10958 if (!spec->loopback.amplist)
10959 spec->loopback.amplist = alc861vd_loopbacks;
10968 * ALC662 is almost identical with ALC880 but has cleaner and more flexible
10969 * configuration. Each pin widget can choose any input DACs and a mixer.
10970 * Each ADC is connected from a mixer of all inputs. This makes possible
10971 * 6-channel independent captures.
10973 * In addition, an independent DAC for the multi-playback (not used in this
10976 #define ALC662_DIGOUT_NID 0x06
10977 #define ALC662_DIGIN_NID 0x0a
10979 static hda_nid_t alc662_dac_nids[4] = {
10980 /* front, rear, clfe, rear_surr */
10984 static hda_nid_t alc662_adc_nids[1] = {
10989 /* FIXME: should be a matrix-type input source selection */
10991 static struct hda_input_mux alc662_capture_source = {
10995 { "Front Mic", 0x1 },
11001 static struct hda_input_mux alc662_lenovo_101e_capture_source = {
11008 #define alc662_mux_enum_info alc_mux_enum_info
11009 #define alc662_mux_enum_get alc_mux_enum_get
11011 static int alc662_mux_enum_put(struct snd_kcontrol *kcontrol,
11012 struct snd_ctl_elem_value *ucontrol)
11014 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
11015 struct alc_spec *spec = codec->spec;
11016 const struct hda_input_mux *imux = spec->input_mux;
11017 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
11018 static hda_nid_t capture_mixers[2] = { 0x23, 0x22 };
11019 hda_nid_t nid = capture_mixers[adc_idx];
11020 unsigned int *cur_val = &spec->cur_mux[adc_idx];
11021 unsigned int i, idx;
11023 idx = ucontrol->value.enumerated.item[0];
11024 if (idx >= imux->num_items)
11025 idx = imux->num_items - 1;
11026 if (*cur_val == idx)
11028 for (i = 0; i < imux->num_items; i++) {
11029 unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
11030 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
11031 imux->items[i].index,
11040 static struct hda_channel_mode alc662_3ST_2ch_modes[1] = {
11047 static struct hda_verb alc662_3ST_ch2_init[] = {
11048 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
11049 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
11050 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
11051 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
11058 static struct hda_verb alc662_3ST_ch6_init[] = {
11059 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11060 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
11061 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
11062 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11063 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
11064 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
11068 static struct hda_channel_mode alc662_3ST_6ch_modes[2] = {
11069 { 2, alc662_3ST_ch2_init },
11070 { 6, alc662_3ST_ch6_init },
11076 static struct hda_verb alc662_sixstack_ch6_init[] = {
11077 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
11078 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
11079 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11086 static struct hda_verb alc662_sixstack_ch8_init[] = {
11087 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11088 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11089 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11093 static struct hda_channel_mode alc662_5stack_modes[2] = {
11094 { 2, alc662_sixstack_ch6_init },
11095 { 6, alc662_sixstack_ch8_init },
11098 /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
11099 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
11102 static struct snd_kcontrol_new alc662_base_mixer[] = {
11103 /* output mixer control */
11104 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
11105 HDA_CODEC_MUTE("Front Playback Switch", 0x02, 0x0, HDA_OUTPUT),
11106 HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT),
11107 HDA_CODEC_MUTE("Surround Playback Switch", 0x03, 0x0, HDA_OUTPUT),
11108 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
11109 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
11110 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT),
11111 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT),
11112 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
11114 /*Input mixer control */
11115 HDA_CODEC_VOLUME("CD Playback Volume", 0xb, 0x4, HDA_INPUT),
11116 HDA_CODEC_MUTE("CD Playback Switch", 0xb, 0x4, HDA_INPUT),
11117 HDA_CODEC_VOLUME("Line Playback Volume", 0xb, 0x02, HDA_INPUT),
11118 HDA_CODEC_MUTE("Line Playback Switch", 0xb, 0x02, HDA_INPUT),
11119 HDA_CODEC_VOLUME("Mic Playback Volume", 0xb, 0x0, HDA_INPUT),
11120 HDA_CODEC_MUTE("Mic Playback Switch", 0xb, 0x0, HDA_INPUT),
11121 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0xb, 0x01, HDA_INPUT),
11122 HDA_CODEC_MUTE("Front Mic Playback Switch", 0xb, 0x01, HDA_INPUT),
11124 /* Capture mixer control */
11125 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
11126 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
11128 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11129 .name = "Capture Source",
11131 .info = alc_mux_enum_info,
11132 .get = alc_mux_enum_get,
11133 .put = alc_mux_enum_put,
11138 static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = {
11139 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
11140 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
11141 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
11142 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11143 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
11144 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
11145 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
11146 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11147 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11148 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
11149 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
11150 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
11151 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
11152 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
11153 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
11155 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11156 /* .name = "Capture Source", */
11157 .name = "Input Source",
11159 .info = alc662_mux_enum_info,
11160 .get = alc662_mux_enum_get,
11161 .put = alc662_mux_enum_put,
11166 static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = {
11167 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
11168 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
11169 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
11170 HDA_BIND_MUTE("Surround Playback Switch", 0x03, 2, HDA_INPUT),
11171 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
11172 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
11173 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT),
11174 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT),
11175 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
11176 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11177 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
11178 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
11179 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
11180 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11181 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11182 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
11183 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
11184 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
11185 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
11186 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
11187 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
11189 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11190 /* .name = "Capture Source", */
11191 .name = "Input Source",
11193 .info = alc662_mux_enum_info,
11194 .get = alc662_mux_enum_get,
11195 .put = alc662_mux_enum_put,
11200 static struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = {
11201 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
11202 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
11203 HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x03, 0x0, HDA_OUTPUT),
11204 HDA_BIND_MUTE("iSpeaker Playback Switch", 0x03, 2, HDA_INPUT),
11205 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
11206 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
11207 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
11208 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
11209 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
11210 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
11211 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
11213 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11214 /* .name = "Capture Source", */
11215 .name = "Input Source",
11217 .info = alc662_mux_enum_info,
11218 .get = alc662_mux_enum_get,
11219 .put = alc662_mux_enum_put,
11224 static struct snd_kcontrol_new alc662_chmode_mixer[] = {
11226 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11227 .name = "Channel Mode",
11228 .info = alc_ch_mode_info,
11229 .get = alc_ch_mode_get,
11230 .put = alc_ch_mode_put,
11235 static struct hda_verb alc662_init_verbs[] = {
11236 /* ADC: mute amp left and right */
11237 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11238 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
11239 /* Front mixer: unmute input/output amp left and right (volume = 0) */
11241 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11242 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11243 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11244 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11245 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
11247 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11248 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11249 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11250 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11251 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11252 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11254 /* Front Pin: output 0 (0x0c) */
11255 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11256 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11258 /* Rear Pin: output 1 (0x0d) */
11259 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11260 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11262 /* CLFE Pin: output 2 (0x0e) */
11263 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11264 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11266 /* Mic (rear) pin: input vref at 80% */
11267 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
11268 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11269 /* Front Mic pin: input vref at 80% */
11270 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
11271 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11272 /* Line In pin: input */
11273 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11274 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11275 /* Line-2 In: Headphone output (output 0 - 0x0c) */
11276 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11277 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11278 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
11279 /* CD pin widget for input */
11280 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11282 /* FIXME: use matrix-type input source selection */
11283 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
11285 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11286 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11287 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
11288 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
11292 static struct hda_verb alc662_sue_init_verbs[] = {
11293 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
11294 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
11299 * generic initialization of ADC, input mixers and output mixers
11301 static struct hda_verb alc662_auto_init_verbs[] = {
11303 * Unmute ADC and set the default input to mic-in
11305 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
11306 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11308 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
11310 * Note: PASD motherboards uses the Line In 2 as the input for front
11311 * panel mic (mic 2)
11313 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
11314 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11315 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11316 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11317 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11318 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
11321 * Set up output mixers (0x0c - 0x0f)
11323 /* set vol=0 to output mixers */
11324 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11325 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11326 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11328 /* set up input amps for analog loopback */
11329 /* Amp Indices: DAC = 0, mixer = 1 */
11330 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11331 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11332 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11333 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11334 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11335 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11338 /* FIXME: use matrix-type input source selection */
11339 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
11341 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11342 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11346 /* capture mixer elements */
11347 static struct snd_kcontrol_new alc662_capture_mixer[] = {
11348 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
11349 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
11351 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11352 /* The multiple "Capture Source" controls confuse alsamixer
11353 * So call somewhat different..
11354 * FIXME: the controls appear in the "playback" view!
11356 /* .name = "Capture Source", */
11357 .name = "Input Source",
11359 .info = alc882_mux_enum_info,
11360 .get = alc882_mux_enum_get,
11361 .put = alc882_mux_enum_put,
11366 static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
11368 unsigned int present;
11369 unsigned char bits;
11371 present = snd_hda_codec_read(codec, 0x14, 0,
11372 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
11373 bits = present ? HDA_AMP_MUTE : 0;
11374 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
11375 HDA_AMP_MUTE, bits);
11378 static void alc662_lenovo_101e_all_automute(struct hda_codec *codec)
11380 unsigned int present;
11381 unsigned char bits;
11383 present = snd_hda_codec_read(codec, 0x1b, 0,
11384 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
11385 bits = present ? HDA_AMP_MUTE : 0;
11386 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
11387 HDA_AMP_MUTE, bits);
11388 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
11389 HDA_AMP_MUTE, bits);
11392 static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec,
11395 if ((res >> 26) == ALC880_HP_EVENT)
11396 alc662_lenovo_101e_all_automute(codec);
11397 if ((res >> 26) == ALC880_FRONT_EVENT)
11398 alc662_lenovo_101e_ispeaker_automute(codec);
11401 #ifdef CONFIG_SND_HDA_POWER_SAVE
11402 #define alc662_loopbacks alc880_loopbacks
11406 /* pcm configuration: identiacal with ALC880 */
11407 #define alc662_pcm_analog_playback alc880_pcm_analog_playback
11408 #define alc662_pcm_analog_capture alc880_pcm_analog_capture
11409 #define alc662_pcm_digital_playback alc880_pcm_digital_playback
11410 #define alc662_pcm_digital_capture alc880_pcm_digital_capture
11413 * configuration and preset
11415 static const char *alc662_models[ALC662_MODEL_LAST] = {
11416 [ALC662_3ST_2ch_DIG] = "3stack-dig",
11417 [ALC662_3ST_6ch_DIG] = "3stack-6ch-dig",
11418 [ALC662_3ST_6ch] = "3stack-6ch",
11419 [ALC662_5ST_DIG] = "6stack-dig",
11420 [ALC662_LENOVO_101E] = "lenovo-101e",
11421 [ALC662_AUTO] = "auto",
11424 static struct snd_pci_quirk alc662_cfg_tbl[] = {
11425 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E),
11429 static struct alc_config_preset alc662_presets[] = {
11430 [ALC662_3ST_2ch_DIG] = {
11431 .mixers = { alc662_3ST_2ch_mixer },
11432 .init_verbs = { alc662_init_verbs },
11433 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
11434 .dac_nids = alc662_dac_nids,
11435 .dig_out_nid = ALC662_DIGOUT_NID,
11436 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
11437 .adc_nids = alc662_adc_nids,
11438 .dig_in_nid = ALC662_DIGIN_NID,
11439 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
11440 .channel_mode = alc662_3ST_2ch_modes,
11441 .input_mux = &alc662_capture_source,
11443 [ALC662_3ST_6ch_DIG] = {
11444 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
11445 .init_verbs = { alc662_init_verbs },
11446 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
11447 .dac_nids = alc662_dac_nids,
11448 .dig_out_nid = ALC662_DIGOUT_NID,
11449 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
11450 .adc_nids = alc662_adc_nids,
11451 .dig_in_nid = ALC662_DIGIN_NID,
11452 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
11453 .channel_mode = alc662_3ST_6ch_modes,
11455 .input_mux = &alc662_capture_source,
11457 [ALC662_3ST_6ch] = {
11458 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
11459 .init_verbs = { alc662_init_verbs },
11460 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
11461 .dac_nids = alc662_dac_nids,
11462 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
11463 .adc_nids = alc662_adc_nids,
11464 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
11465 .channel_mode = alc662_3ST_6ch_modes,
11467 .input_mux = &alc662_capture_source,
11469 [ALC662_5ST_DIG] = {
11470 .mixers = { alc662_base_mixer, alc662_chmode_mixer },
11471 .init_verbs = { alc662_init_verbs },
11472 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
11473 .dac_nids = alc662_dac_nids,
11474 .dig_out_nid = ALC662_DIGOUT_NID,
11475 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
11476 .adc_nids = alc662_adc_nids,
11477 .dig_in_nid = ALC662_DIGIN_NID,
11478 .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes),
11479 .channel_mode = alc662_5stack_modes,
11480 .input_mux = &alc662_capture_source,
11482 [ALC662_LENOVO_101E] = {
11483 .mixers = { alc662_lenovo_101e_mixer },
11484 .init_verbs = { alc662_init_verbs, alc662_sue_init_verbs },
11485 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
11486 .dac_nids = alc662_dac_nids,
11487 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
11488 .adc_nids = alc662_adc_nids,
11489 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
11490 .channel_mode = alc662_3ST_2ch_modes,
11491 .input_mux = &alc662_lenovo_101e_capture_source,
11492 .unsol_event = alc662_lenovo_101e_unsol_event,
11493 .init_hook = alc662_lenovo_101e_all_automute,
11500 * BIOS auto configuration
11503 /* add playback controls from the parsed DAC table */
11504 static int alc662_auto_create_multi_out_ctls(struct alc_spec *spec,
11505 const struct auto_pin_cfg *cfg)
11508 static const char *chname[4] = {
11509 "Front", "Surround", NULL /*CLFE*/, "Side"
11514 for (i = 0; i < cfg->line_outs; i++) {
11515 if (!spec->multiout.dac_nids[i])
11517 nid = alc880_idx_to_mixer(i);
11520 err = add_control(spec, ALC_CTL_WIDGET_VOL,
11521 "Center Playback Volume",
11522 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
11526 err = add_control(spec, ALC_CTL_WIDGET_VOL,
11527 "LFE Playback Volume",
11528 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
11532 err = add_control(spec, ALC_CTL_BIND_MUTE,
11533 "Center Playback Switch",
11534 HDA_COMPOSE_AMP_VAL(nid, 1, 2,
11538 err = add_control(spec, ALC_CTL_BIND_MUTE,
11539 "LFE Playback Switch",
11540 HDA_COMPOSE_AMP_VAL(nid, 2, 2,
11545 sprintf(name, "%s Playback Volume", chname[i]);
11546 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
11547 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
11551 sprintf(name, "%s Playback Switch", chname[i]);
11552 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
11553 HDA_COMPOSE_AMP_VAL(nid, 3, 2,
11562 /* add playback controls for speaker and HP outputs */
11563 static int alc662_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
11573 if (alc880_is_fixed_pin(pin)) {
11574 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
11575 /* printk("DAC nid=%x\n",nid); */
11576 /* specify the DAC as the extra output */
11577 if (!spec->multiout.hp_nid)
11578 spec->multiout.hp_nid = nid;
11580 spec->multiout.extra_out_nid[0] = nid;
11581 /* control HP volume/switch on the output mixer amp */
11582 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
11583 sprintf(name, "%s Playback Volume", pfx);
11584 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
11585 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
11588 sprintf(name, "%s Playback Switch", pfx);
11589 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
11590 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
11593 } else if (alc880_is_multi_pin(pin)) {
11594 /* set manual connection */
11595 /* we have only a switch on HP-out PIN */
11596 sprintf(name, "%s Playback Switch", pfx);
11597 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
11598 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
11605 /* create playback/capture controls for input pins */
11606 static int alc662_auto_create_analog_input_ctls(struct alc_spec *spec,
11607 const struct auto_pin_cfg *cfg)
11609 struct hda_input_mux *imux = &spec->private_imux;
11612 for (i = 0; i < AUTO_PIN_LAST; i++) {
11613 if (alc880_is_input_pin(cfg->input_pins[i])) {
11614 idx = alc880_input_pin_idx(cfg->input_pins[i]);
11615 err = new_analog_input(spec, cfg->input_pins[i],
11616 auto_pin_cfg_labels[i],
11620 imux->items[imux->num_items].label =
11621 auto_pin_cfg_labels[i];
11622 imux->items[imux->num_items].index =
11623 alc880_input_pin_idx(cfg->input_pins[i]);
11630 static void alc662_auto_set_output_and_unmute(struct hda_codec *codec,
11631 hda_nid_t nid, int pin_type,
11634 /* set as output */
11635 snd_hda_codec_write(codec, nid, 0,
11636 AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
11637 snd_hda_codec_write(codec, nid, 0,
11638 AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
11639 /* need the manual connection? */
11640 if (alc880_is_multi_pin(nid)) {
11641 struct alc_spec *spec = codec->spec;
11642 int idx = alc880_multi_pin_idx(nid);
11643 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
11644 AC_VERB_SET_CONNECT_SEL,
11645 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
11649 static void alc662_auto_init_multi_out(struct hda_codec *codec)
11651 struct alc_spec *spec = codec->spec;
11654 for (i = 0; i <= HDA_SIDE; i++) {
11655 hda_nid_t nid = spec->autocfg.line_out_pins[i];
11656 int pin_type = get_pin_type(spec->autocfg.line_out_type);
11658 alc662_auto_set_output_and_unmute(codec, nid, pin_type,
11663 static void alc662_auto_init_hp_out(struct hda_codec *codec)
11665 struct alc_spec *spec = codec->spec;
11668 pin = spec->autocfg.hp_pins[0];
11669 if (pin) /* connect to front */
11671 alc662_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
11674 #define alc662_is_input_pin(nid) alc880_is_input_pin(nid)
11675 #define ALC662_PIN_CD_NID ALC880_PIN_CD_NID
11677 static void alc662_auto_init_analog_input(struct hda_codec *codec)
11679 struct alc_spec *spec = codec->spec;
11682 for (i = 0; i < AUTO_PIN_LAST; i++) {
11683 hda_nid_t nid = spec->autocfg.input_pins[i];
11684 if (alc662_is_input_pin(nid)) {
11685 snd_hda_codec_write(codec, nid, 0,
11686 AC_VERB_SET_PIN_WIDGET_CONTROL,
11687 (i <= AUTO_PIN_FRONT_MIC ?
11688 PIN_VREF80 : PIN_IN));
11689 if (nid != ALC662_PIN_CD_NID)
11690 snd_hda_codec_write(codec, nid, 0,
11691 AC_VERB_SET_AMP_GAIN_MUTE,
11697 static int alc662_parse_auto_config(struct hda_codec *codec)
11699 struct alc_spec *spec = codec->spec;
11701 static hda_nid_t alc662_ignore[] = { 0x1d, 0 };
11703 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
11707 if (!spec->autocfg.line_outs)
11708 return 0; /* can't find valid BIOS pin config */
11710 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
11713 err = alc662_auto_create_multi_out_ctls(spec, &spec->autocfg);
11716 err = alc662_auto_create_extra_out(spec,
11717 spec->autocfg.speaker_pins[0],
11721 err = alc662_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
11725 err = alc662_auto_create_analog_input_ctls(spec, &spec->autocfg);
11729 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
11731 if (spec->autocfg.dig_out_pin)
11732 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
11734 if (spec->kctl_alloc)
11735 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
11737 spec->num_mux_defs = 1;
11738 spec->input_mux = &spec->private_imux;
11740 spec->init_verbs[spec->num_init_verbs++] = alc662_auto_init_verbs;
11741 spec->mixers[spec->num_mixers] = alc662_capture_mixer;
11742 spec->num_mixers++;
11746 /* additional initialization for auto-configuration model */
11747 static void alc662_auto_init(struct hda_codec *codec)
11749 alc662_auto_init_multi_out(codec);
11750 alc662_auto_init_hp_out(codec);
11751 alc662_auto_init_analog_input(codec);
11754 static int patch_alc662(struct hda_codec *codec)
11756 struct alc_spec *spec;
11757 int err, board_config;
11759 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
11763 codec->spec = spec;
11765 board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST,
11768 if (board_config < 0) {
11769 printk(KERN_INFO "hda_codec: Unknown model for ALC662, "
11770 "trying auto-probe from BIOS...\n");
11771 board_config = ALC662_AUTO;
11774 if (board_config == ALC662_AUTO) {
11775 /* automatic parse from the BIOS config */
11776 err = alc662_parse_auto_config(codec);
11782 "hda_codec: Cannot set up configuration "
11783 "from BIOS. Using base mode...\n");
11784 board_config = ALC662_3ST_2ch_DIG;
11788 if (board_config != ALC662_AUTO)
11789 setup_preset(spec, &alc662_presets[board_config]);
11791 spec->stream_name_analog = "ALC662 Analog";
11792 spec->stream_analog_playback = &alc662_pcm_analog_playback;
11793 spec->stream_analog_capture = &alc662_pcm_analog_capture;
11795 spec->stream_name_digital = "ALC662 Digital";
11796 spec->stream_digital_playback = &alc662_pcm_digital_playback;
11797 spec->stream_digital_capture = &alc662_pcm_digital_capture;
11799 if (!spec->adc_nids && spec->input_mux) {
11800 spec->adc_nids = alc662_adc_nids;
11801 spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids);
11804 codec->patch_ops = alc_patch_ops;
11805 if (board_config == ALC662_AUTO)
11806 spec->init_hook = alc662_auto_init;
11807 #ifdef CONFIG_SND_HDA_POWER_SAVE
11808 if (!spec->loopback.amplist)
11809 spec->loopback.amplist = alc662_loopbacks;
11818 struct hda_codec_preset snd_hda_preset_realtek[] = {
11819 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
11820 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
11821 { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 },
11822 { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
11823 .patch = patch_alc861 },
11824 { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
11825 { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
11826 { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
11827 { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2",
11828 .patch = patch_alc883 },
11829 { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
11830 .patch = patch_alc662 },
11831 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
11832 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
11833 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc883 },
11834 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
11835 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc883 },
11836 {} /* terminator */