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 */
106 ALC268_MODEL_LAST /* last tag */
123 /* ALC861-VD models */
168 ALC883_TARGA_2ch_DIG,
173 ALC883_LENOVO_101E_2ch,
174 ALC883_LENOVO_NB0763,
175 ALC888_LENOVO_MS7195_DIG,
183 #define GPIO_MASK 0x03
186 /* codec parameterization */
187 struct snd_kcontrol_new *mixers[5]; /* mixer arrays */
188 unsigned int num_mixers;
190 const struct hda_verb *init_verbs[5]; /* initialization verbs
194 unsigned int num_init_verbs;
196 char *stream_name_analog; /* analog PCM stream */
197 struct hda_pcm_stream *stream_analog_playback;
198 struct hda_pcm_stream *stream_analog_capture;
200 char *stream_name_digital; /* digital PCM stream */
201 struct hda_pcm_stream *stream_digital_playback;
202 struct hda_pcm_stream *stream_digital_capture;
205 struct hda_multi_out multiout; /* playback set-up
206 * max_channels, dacs must be set
207 * dig_out_nid and hp_nid are optional
211 unsigned int num_adc_nids;
213 hda_nid_t dig_in_nid; /* digital-in NID; optional */
216 unsigned int num_mux_defs;
217 const struct hda_input_mux *input_mux;
218 unsigned int cur_mux[3];
221 const struct hda_channel_mode *channel_mode;
222 int num_channel_mode;
225 /* PCM information */
226 struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */
228 /* dynamic controls, init_verbs and input_mux */
229 struct auto_pin_cfg autocfg;
230 unsigned int num_kctl_alloc, num_kctl_used;
231 struct snd_kcontrol_new *kctl_alloc;
232 struct hda_input_mux private_imux;
233 hda_nid_t private_dac_nids[5];
236 void (*init_hook)(struct hda_codec *codec);
237 void (*unsol_event)(struct hda_codec *codec, unsigned int res);
239 /* for pin sensing */
240 unsigned int sense_updated: 1;
241 unsigned int jack_present: 1;
245 * configuration template - to be copied to the spec instance
247 struct alc_config_preset {
248 struct snd_kcontrol_new *mixers[5]; /* should be identical size
251 const struct hda_verb *init_verbs[5];
252 unsigned int num_dacs;
254 hda_nid_t dig_out_nid; /* optional */
255 hda_nid_t hp_nid; /* optional */
256 unsigned int num_adc_nids;
258 hda_nid_t dig_in_nid;
259 unsigned int num_channel_mode;
260 const struct hda_channel_mode *channel_mode;
262 unsigned int num_mux_defs;
263 const struct hda_input_mux *input_mux;
264 void (*unsol_event)(struct hda_codec *, unsigned int);
265 void (*init_hook)(struct hda_codec *);
272 static int alc_mux_enum_info(struct snd_kcontrol *kcontrol,
273 struct snd_ctl_elem_info *uinfo)
275 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
276 struct alc_spec *spec = codec->spec;
277 unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id);
278 if (mux_idx >= spec->num_mux_defs)
280 return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo);
283 static int alc_mux_enum_get(struct snd_kcontrol *kcontrol,
284 struct snd_ctl_elem_value *ucontrol)
286 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
287 struct alc_spec *spec = codec->spec;
288 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
290 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
294 static int alc_mux_enum_put(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);
300 unsigned int mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx;
301 return snd_hda_input_mux_put(codec, &spec->input_mux[mux_idx], ucontrol,
302 spec->adc_nids[adc_idx],
303 &spec->cur_mux[adc_idx]);
308 * channel mode setting
310 static int alc_ch_mode_info(struct snd_kcontrol *kcontrol,
311 struct snd_ctl_elem_info *uinfo)
313 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
314 struct alc_spec *spec = codec->spec;
315 return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
316 spec->num_channel_mode);
319 static int alc_ch_mode_get(struct snd_kcontrol *kcontrol,
320 struct snd_ctl_elem_value *ucontrol)
322 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
323 struct alc_spec *spec = codec->spec;
324 return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
325 spec->num_channel_mode,
326 spec->multiout.max_channels);
329 static int alc_ch_mode_put(struct snd_kcontrol *kcontrol,
330 struct snd_ctl_elem_value *ucontrol)
332 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
333 struct alc_spec *spec = codec->spec;
334 int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
335 spec->num_channel_mode,
336 &spec->multiout.max_channels);
337 if (err >= 0 && spec->need_dac_fix)
338 spec->multiout.num_dacs = spec->multiout.max_channels / 2;
343 * Control the mode of pin widget settings via the mixer. "pc" is used
344 * instead of "%" to avoid consequences of accidently treating the % as
345 * being part of a format specifier. Maximum allowed length of a value is
346 * 63 characters plus NULL terminator.
348 * Note: some retasking pin complexes seem to ignore requests for input
349 * states other than HiZ (eg: PIN_VREFxx) and revert to HiZ if any of these
350 * are requested. Therefore order this list so that this behaviour will not
351 * cause problems when mixer clients move through the enum sequentially.
352 * NIDs 0x0f and 0x10 have been observed to have this behaviour as of
355 static char *alc_pin_mode_names[] = {
356 "Mic 50pc bias", "Mic 80pc bias",
357 "Line in", "Line out", "Headphone out",
359 static unsigned char alc_pin_mode_values[] = {
360 PIN_VREF50, PIN_VREF80, PIN_IN, PIN_OUT, PIN_HP,
362 /* The control can present all 5 options, or it can limit the options based
363 * in the pin being assumed to be exclusively an input or an output pin. In
364 * addition, "input" pins may or may not process the mic bias option
365 * depending on actual widget capability (NIDs 0x0f and 0x10 don't seem to
366 * accept requests for bias as of chip versions up to March 2006) and/or
367 * wiring in the computer.
369 #define ALC_PIN_DIR_IN 0x00
370 #define ALC_PIN_DIR_OUT 0x01
371 #define ALC_PIN_DIR_INOUT 0x02
372 #define ALC_PIN_DIR_IN_NOMICBIAS 0x03
373 #define ALC_PIN_DIR_INOUT_NOMICBIAS 0x04
375 /* Info about the pin modes supported by the different pin direction modes.
376 * For each direction the minimum and maximum values are given.
378 static signed char alc_pin_mode_dir_info[5][2] = {
379 { 0, 2 }, /* ALC_PIN_DIR_IN */
380 { 3, 4 }, /* ALC_PIN_DIR_OUT */
381 { 0, 4 }, /* ALC_PIN_DIR_INOUT */
382 { 2, 2 }, /* ALC_PIN_DIR_IN_NOMICBIAS */
383 { 2, 4 }, /* ALC_PIN_DIR_INOUT_NOMICBIAS */
385 #define alc_pin_mode_min(_dir) (alc_pin_mode_dir_info[_dir][0])
386 #define alc_pin_mode_max(_dir) (alc_pin_mode_dir_info[_dir][1])
387 #define alc_pin_mode_n_items(_dir) \
388 (alc_pin_mode_max(_dir)-alc_pin_mode_min(_dir)+1)
390 static int alc_pin_mode_info(struct snd_kcontrol *kcontrol,
391 struct snd_ctl_elem_info *uinfo)
393 unsigned int item_num = uinfo->value.enumerated.item;
394 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
396 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
398 uinfo->value.enumerated.items = alc_pin_mode_n_items(dir);
400 if (item_num<alc_pin_mode_min(dir) || item_num>alc_pin_mode_max(dir))
401 item_num = alc_pin_mode_min(dir);
402 strcpy(uinfo->value.enumerated.name, alc_pin_mode_names[item_num]);
406 static int alc_pin_mode_get(struct snd_kcontrol *kcontrol,
407 struct snd_ctl_elem_value *ucontrol)
410 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
411 hda_nid_t nid = kcontrol->private_value & 0xffff;
412 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
413 long *valp = ucontrol->value.integer.value;
414 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
415 AC_VERB_GET_PIN_WIDGET_CONTROL,
418 /* Find enumerated value for current pinctl setting */
419 i = alc_pin_mode_min(dir);
420 while (alc_pin_mode_values[i] != pinctl && i <= alc_pin_mode_max(dir))
422 *valp = i <= alc_pin_mode_max(dir) ? i: alc_pin_mode_min(dir);
426 static int alc_pin_mode_put(struct snd_kcontrol *kcontrol,
427 struct snd_ctl_elem_value *ucontrol)
430 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
431 hda_nid_t nid = kcontrol->private_value & 0xffff;
432 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
433 long val = *ucontrol->value.integer.value;
434 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
435 AC_VERB_GET_PIN_WIDGET_CONTROL,
438 if (val < alc_pin_mode_min(dir) || val > alc_pin_mode_max(dir))
439 val = alc_pin_mode_min(dir);
441 change = pinctl != alc_pin_mode_values[val];
443 /* Set pin mode to that requested */
444 snd_hda_codec_write(codec,nid,0,AC_VERB_SET_PIN_WIDGET_CONTROL,
445 alc_pin_mode_values[val]);
447 /* Also enable the retasking pin's input/output as required
448 * for the requested pin mode. Enum values of 2 or less are
451 * Dynamically switching the input/output buffers probably
452 * reduces noise slightly (particularly on input) so we'll
453 * do it. However, having both input and output buffers
454 * enabled simultaneously doesn't seem to be problematic if
455 * this turns out to be necessary in the future.
458 snd_hda_codec_write(codec, nid, 0,
459 AC_VERB_SET_AMP_GAIN_MUTE,
461 snd_hda_codec_write(codec, nid, 0,
462 AC_VERB_SET_AMP_GAIN_MUTE,
465 snd_hda_codec_write(codec, nid, 0,
466 AC_VERB_SET_AMP_GAIN_MUTE,
468 snd_hda_codec_write(codec, nid, 0,
469 AC_VERB_SET_AMP_GAIN_MUTE,
476 #define ALC_PIN_MODE(xname, nid, dir) \
477 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
478 .info = alc_pin_mode_info, \
479 .get = alc_pin_mode_get, \
480 .put = alc_pin_mode_put, \
481 .private_value = nid | (dir<<16) }
483 /* A switch control for ALC260 GPIO pins. Multiple GPIOs can be ganged
484 * together using a mask with more than one bit set. This control is
485 * currently used only by the ALC260 test model. At this stage they are not
486 * needed for any "production" models.
488 #ifdef CONFIG_SND_DEBUG
489 static int alc_gpio_data_info(struct snd_kcontrol *kcontrol,
490 struct snd_ctl_elem_info *uinfo)
492 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
494 uinfo->value.integer.min = 0;
495 uinfo->value.integer.max = 1;
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(codec, nid, 0, AC_VERB_SET_GPIO_DATA, gpio_data);
534 #define ALC_GPIO_DATA_SWITCH(xname, nid, mask) \
535 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
536 .info = alc_gpio_data_info, \
537 .get = alc_gpio_data_get, \
538 .put = alc_gpio_data_put, \
539 .private_value = nid | (mask<<16) }
540 #endif /* CONFIG_SND_DEBUG */
542 /* A switch control to allow the enabling of the digital IO pins on the
543 * ALC260. This is incredibly simplistic; the intention of this control is
544 * to provide something in the test model allowing digital outputs to be
545 * identified if present. If models are found which can utilise these
546 * outputs a more complete mixer control can be devised for those models if
549 #ifdef CONFIG_SND_DEBUG
550 static int alc_spdif_ctrl_info(struct snd_kcontrol *kcontrol,
551 struct snd_ctl_elem_info *uinfo)
553 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
555 uinfo->value.integer.min = 0;
556 uinfo->value.integer.max = 1;
560 static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol,
561 struct snd_ctl_elem_value *ucontrol)
563 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
564 hda_nid_t nid = kcontrol->private_value & 0xffff;
565 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
566 long *valp = ucontrol->value.integer.value;
567 unsigned int val = snd_hda_codec_read(codec, nid, 0,
568 AC_VERB_GET_DIGI_CONVERT, 0x00);
570 *valp = (val & mask) != 0;
573 static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol,
574 struct snd_ctl_elem_value *ucontrol)
577 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
578 hda_nid_t nid = kcontrol->private_value & 0xffff;
579 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
580 long val = *ucontrol->value.integer.value;
581 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
582 AC_VERB_GET_DIGI_CONVERT,
585 /* Set/unset the masked control bit(s) as needed */
586 change = (val == 0 ? 0 : mask) != (ctrl_data & mask);
591 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1,
596 #define ALC_SPDIF_CTRL_SWITCH(xname, nid, mask) \
597 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
598 .info = alc_spdif_ctrl_info, \
599 .get = alc_spdif_ctrl_get, \
600 .put = alc_spdif_ctrl_put, \
601 .private_value = nid | (mask<<16) }
602 #endif /* CONFIG_SND_DEBUG */
605 * set up from the preset table
607 static void setup_preset(struct alc_spec *spec,
608 const struct alc_config_preset *preset)
612 for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++)
613 spec->mixers[spec->num_mixers++] = preset->mixers[i];
614 for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i];
616 spec->init_verbs[spec->num_init_verbs++] =
617 preset->init_verbs[i];
619 spec->channel_mode = preset->channel_mode;
620 spec->num_channel_mode = preset->num_channel_mode;
621 spec->need_dac_fix = preset->need_dac_fix;
623 spec->multiout.max_channels = spec->channel_mode[0].channels;
625 spec->multiout.num_dacs = preset->num_dacs;
626 spec->multiout.dac_nids = preset->dac_nids;
627 spec->multiout.dig_out_nid = preset->dig_out_nid;
628 spec->multiout.hp_nid = preset->hp_nid;
630 spec->num_mux_defs = preset->num_mux_defs;
631 if (!spec->num_mux_defs)
632 spec->num_mux_defs = 1;
633 spec->input_mux = preset->input_mux;
635 spec->num_adc_nids = preset->num_adc_nids;
636 spec->adc_nids = preset->adc_nids;
637 spec->dig_in_nid = preset->dig_in_nid;
639 spec->unsol_event = preset->unsol_event;
640 spec->init_hook = preset->init_hook;
643 /* Enable GPIO mask and set output */
644 static struct hda_verb alc_gpio1_init_verbs[] = {
645 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
646 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
647 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
651 static struct hda_verb alc_gpio2_init_verbs[] = {
652 {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
653 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
654 {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
658 static struct hda_verb alc_gpio3_init_verbs[] = {
659 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
660 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
661 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
665 /* 32-bit subsystem ID for BIOS loading in HD Audio codec.
666 * 31 ~ 16 : Manufacture ID
668 * 7 ~ 0 : Assembly ID
669 * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36
671 static void alc_subsystem_id(struct hda_codec *codec,
672 unsigned int porta, unsigned int porte,
675 unsigned int ass, tmp;
677 ass = codec->subsystem_id;
682 tmp = (ass & 0x38) >> 3; /* external Amp control */
685 snd_hda_sequence_write(codec, alc_gpio1_init_verbs);
688 snd_hda_sequence_write(codec, alc_gpio2_init_verbs);
691 snd_hda_sequence_write(codec, alc_gpio3_init_verbs);
694 switch (codec->vendor_id) {
700 snd_hda_codec_write(codec, 0x14, 0,
701 AC_VERB_SET_EAPD_BTLENABLE, 2);
702 snd_hda_codec_write(codec, 0x15, 0,
703 AC_VERB_SET_EAPD_BTLENABLE, 2);
707 if (ass & 4) { /* bit 2 : 0 = Desktop, 1 = Laptop */
709 tmp = (ass & 0x1800) >> 11;
711 case 0: port = porta; break;
712 case 1: port = porte; break;
713 case 2: port = portd; break;
716 snd_hda_codec_write(codec, port, 0,
717 AC_VERB_SET_EAPD_BTLENABLE,
720 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
721 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF,
722 (tmp == 5 ? 0x3040 : 0x3050));
728 * Fix-up pin default configurations
736 static void alc_fix_pincfg(struct hda_codec *codec,
737 const struct snd_pci_quirk *quirk,
738 const struct alc_pincfg **pinfix)
740 const struct alc_pincfg *cfg;
742 quirk = snd_pci_quirk_lookup(codec->bus->pci, quirk);
746 cfg = pinfix[quirk->value];
747 for (; cfg->nid; cfg++) {
750 for (i = 0; i < 4; i++) {
751 snd_hda_codec_write(codec, cfg->nid, 0,
752 AC_VERB_SET_CONFIG_DEFAULT_BYTES_0 + i,
760 * ALC880 3-stack model
762 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
763 * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18,
764 * F-Mic = 0x1b, HP = 0x19
767 static hda_nid_t alc880_dac_nids[4] = {
768 /* front, rear, clfe, rear_surr */
769 0x02, 0x05, 0x04, 0x03
772 static hda_nid_t alc880_adc_nids[3] = {
777 /* The datasheet says the node 0x07 is connected from inputs,
778 * but it shows zero connection in the real implementation on some devices.
779 * Note: this is a 915GAV bug, fixed on 915GLV
781 static hda_nid_t alc880_adc_nids_alt[2] = {
786 #define ALC880_DIGOUT_NID 0x06
787 #define ALC880_DIGIN_NID 0x0a
789 static struct hda_input_mux alc880_capture_source = {
793 { "Front Mic", 0x3 },
799 /* channel source setting (2/6 channel selection for 3-stack) */
801 static struct hda_verb alc880_threestack_ch2_init[] = {
802 /* set line-in to input, mute it */
803 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
804 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
805 /* set mic-in to input vref 80%, mute it */
806 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
807 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
812 static struct hda_verb alc880_threestack_ch6_init[] = {
813 /* set line-in to output, unmute it */
814 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
815 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
816 /* set mic-in to output, unmute it */
817 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
818 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
822 static struct hda_channel_mode alc880_threestack_modes[2] = {
823 { 2, alc880_threestack_ch2_init },
824 { 6, alc880_threestack_ch6_init },
827 static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
828 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
829 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
830 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
831 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
832 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
833 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
834 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
835 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
836 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
837 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
838 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
839 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
840 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
841 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
842 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
843 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
844 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
845 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
846 HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
848 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
849 .name = "Channel Mode",
850 .info = alc_ch_mode_info,
851 .get = alc_ch_mode_get,
852 .put = alc_ch_mode_put,
857 /* capture mixer elements */
858 static struct snd_kcontrol_new alc880_capture_mixer[] = {
859 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
860 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
861 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
862 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
863 HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
864 HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
866 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
867 /* The multiple "Capture Source" controls confuse alsamixer
868 * So call somewhat different..
869 * FIXME: the controls appear in the "playback" view!
871 /* .name = "Capture Source", */
872 .name = "Input Source",
874 .info = alc_mux_enum_info,
875 .get = alc_mux_enum_get,
876 .put = alc_mux_enum_put,
881 /* capture mixer elements (in case NID 0x07 not available) */
882 static struct snd_kcontrol_new alc880_capture_alt_mixer[] = {
883 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
884 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
885 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
886 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
888 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
889 /* The multiple "Capture Source" controls confuse alsamixer
890 * So call somewhat different..
891 * FIXME: the controls appear in the "playback" view!
893 /* .name = "Capture Source", */
894 .name = "Input Source",
896 .info = alc_mux_enum_info,
897 .get = alc_mux_enum_get,
898 .put = alc_mux_enum_put,
906 * ALC880 5-stack model
908 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d),
910 * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
911 * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
914 /* additional mixers to alc880_three_stack_mixer */
915 static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
916 HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
917 HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
921 /* channel source setting (6/8 channel selection for 5-stack) */
923 static struct hda_verb alc880_fivestack_ch6_init[] = {
924 /* set line-in to input, mute it */
925 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
926 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
931 static struct hda_verb alc880_fivestack_ch8_init[] = {
932 /* set line-in to output, unmute it */
933 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
934 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
938 static struct hda_channel_mode alc880_fivestack_modes[2] = {
939 { 6, alc880_fivestack_ch6_init },
940 { 8, alc880_fivestack_ch8_init },
945 * ALC880 6-stack model
947 * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e),
949 * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
950 * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
953 static hda_nid_t alc880_6st_dac_nids[4] = {
954 /* front, rear, clfe, rear_surr */
955 0x02, 0x03, 0x04, 0x05
958 static struct hda_input_mux alc880_6stack_capture_source = {
962 { "Front Mic", 0x1 },
968 /* fixed 8-channels */
969 static struct hda_channel_mode alc880_sixstack_modes[1] = {
973 static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
974 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
975 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
976 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
977 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
978 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
979 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
980 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
981 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
982 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
983 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
984 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
985 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
986 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
987 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
988 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
989 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
990 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
991 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
992 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
993 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
995 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
996 .name = "Channel Mode",
997 .info = alc_ch_mode_info,
998 .get = alc_ch_mode_get,
999 .put = alc_ch_mode_put,
1008 * W810 has rear IO for:
1011 * Center/LFE (DAC 04)
1014 * The system also has a pair of internal speakers, and a headphone jack.
1015 * These are both connected to Line2 on the codec, hence to DAC 02.
1017 * There is a variable resistor to control the speaker or headphone
1018 * volume. This is a hardware-only device without a software API.
1020 * Plugging headphones in will disable the internal speakers. This is
1021 * implemented in hardware, not via the driver using jack sense. In
1022 * a similar fashion, plugging into the rear socket marked "front" will
1023 * disable both the speakers and headphones.
1025 * For input, there's a microphone jack, and an "audio in" jack.
1026 * These may not do anything useful with this driver yet, because I
1027 * haven't setup any initialization verbs for these yet...
1030 static hda_nid_t alc880_w810_dac_nids[3] = {
1031 /* front, rear/surround, clfe */
1035 /* fixed 6 channels */
1036 static struct hda_channel_mode alc880_w810_modes[1] = {
1040 /* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
1041 static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
1042 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1043 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1044 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1045 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
1046 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1047 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1048 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1049 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1050 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
1058 * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
1059 * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?),
1063 static hda_nid_t alc880_z71v_dac_nids[1] = {
1066 #define ALC880_Z71V_HP_DAC 0x03
1068 /* fixed 2 channels */
1069 static struct hda_channel_mode alc880_2_jack_modes[1] = {
1073 static struct snd_kcontrol_new alc880_z71v_mixer[] = {
1074 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1075 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1076 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1077 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
1078 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1079 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1080 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1081 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1088 * ALC880 F1734 model
1090 * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
1091 * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
1094 static hda_nid_t alc880_f1734_dac_nids[1] = {
1097 #define ALC880_F1734_HP_DAC 0x02
1099 static struct snd_kcontrol_new alc880_f1734_mixer[] = {
1100 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1101 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
1102 HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1103 HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
1104 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1105 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1106 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1107 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1116 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
1117 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
1118 * Mic = 0x18, Line = 0x1a
1121 #define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
1122 #define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
1124 static struct snd_kcontrol_new alc880_asus_mixer[] = {
1125 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1126 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1127 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1128 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
1129 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1130 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1131 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1132 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1133 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1134 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1135 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1136 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1137 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1138 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1140 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1141 .name = "Channel Mode",
1142 .info = alc_ch_mode_info,
1143 .get = alc_ch_mode_get,
1144 .put = alc_ch_mode_put,
1151 * ALC880 ASUS W1V model
1153 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
1154 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
1155 * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
1158 /* additional mixers to alc880_asus_mixer */
1159 static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
1160 HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
1161 HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
1165 /* additional mixers to alc880_asus_mixer */
1166 static struct snd_kcontrol_new alc880_pcbeep_mixer[] = {
1167 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1168 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
1173 static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
1174 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1175 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
1176 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
1177 HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
1178 HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
1179 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
1180 HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
1181 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
1182 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
1184 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1185 /* The multiple "Capture Source" controls confuse alsamixer
1186 * So call somewhat different..
1187 * FIXME: the controls appear in the "playback" view!
1189 /* .name = "Capture Source", */
1190 .name = "Input Source",
1192 .info = alc_mux_enum_info,
1193 .get = alc_mux_enum_get,
1194 .put = alc_mux_enum_put,
1200 static struct snd_kcontrol_new alc880_uniwill_mixer[] = {
1201 HDA_CODEC_VOLUME("HPhone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1202 HDA_BIND_MUTE("HPhone Playback Switch", 0x0c, 2, HDA_INPUT),
1203 HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1204 HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT),
1205 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1206 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1207 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1208 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1209 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1210 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1211 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1212 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1213 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1214 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1215 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1216 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1217 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1218 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
1220 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1221 .name = "Channel Mode",
1222 .info = alc_ch_mode_info,
1223 .get = alc_ch_mode_get,
1224 .put = alc_ch_mode_put,
1229 static struct snd_kcontrol_new alc880_fujitsu_mixer[] = {
1230 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1231 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
1232 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1233 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
1234 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1235 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1236 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1237 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1238 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1239 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1243 static struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = {
1244 HDA_CODEC_VOLUME("HPhone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1245 HDA_BIND_MUTE("HPhone Playback Switch", 0x0c, 2, HDA_INPUT),
1246 HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1247 HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT),
1248 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1249 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1254 * build control elements
1256 static int alc_build_controls(struct hda_codec *codec)
1258 struct alc_spec *spec = codec->spec;
1262 for (i = 0; i < spec->num_mixers; i++) {
1263 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
1268 if (spec->multiout.dig_out_nid) {
1269 err = snd_hda_create_spdif_out_ctls(codec,
1270 spec->multiout.dig_out_nid);
1274 if (spec->dig_in_nid) {
1275 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
1284 * initialize the codec volumes, etc
1288 * generic initialization of ADC, input mixers and output mixers
1290 static struct hda_verb alc880_volume_init_verbs[] = {
1292 * Unmute ADC0-2 and set the default input to mic-in
1294 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
1295 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1296 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
1297 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1298 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
1299 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1301 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
1303 * Note: PASD motherboards uses the Line In 2 as the input for front
1306 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
1307 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1308 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1309 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
1310 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
1311 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
1314 * Set up output mixers (0x0c - 0x0f)
1316 /* set vol=0 to output mixers */
1317 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1318 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1319 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1320 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1321 /* set up input amps for analog loopback */
1322 /* Amp Indices: DAC = 0, mixer = 1 */
1323 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1324 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1325 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1326 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1327 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1328 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1329 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1330 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1336 * 3-stack pin configuration:
1337 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
1339 static struct hda_verb alc880_pin_3stack_init_verbs[] = {
1341 * preset connection lists of input pins
1342 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
1344 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
1345 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1346 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
1349 * Set pin mode and muting
1351 /* set front pin widgets 0x14 for output */
1352 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1353 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1354 /* Mic1 (rear panel) pin widget for input and vref at 80% */
1355 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1356 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1357 /* Mic2 (as headphone out) for HP output */
1358 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1359 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1360 /* Line In pin widget for input */
1361 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1362 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1363 /* Line2 (as front mic) pin widget for input and vref at 80% */
1364 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1365 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1366 /* CD pin widget for input */
1367 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1373 * 5-stack pin configuration:
1374 * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
1375 * line-in/side = 0x1a, f-mic = 0x1b
1377 static struct hda_verb alc880_pin_5stack_init_verbs[] = {
1379 * preset connection lists of input pins
1380 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
1382 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1383 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
1386 * Set pin mode and muting
1388 /* set pin widgets 0x14-0x17 for output */
1389 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1390 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1391 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1392 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1393 /* unmute pins for output (no gain on this amp) */
1394 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1395 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1396 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1397 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1399 /* Mic1 (rear panel) pin widget for input and vref at 80% */
1400 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1401 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1402 /* Mic2 (as headphone out) for HP output */
1403 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1404 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1405 /* Line In pin widget for input */
1406 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1407 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1408 /* Line2 (as front mic) pin widget for input and vref at 80% */
1409 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1410 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1411 /* CD pin widget for input */
1412 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1418 * W810 pin configuration:
1419 * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
1421 static struct hda_verb alc880_pin_w810_init_verbs[] = {
1422 /* hphone/speaker input selector: front DAC */
1423 {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
1425 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1426 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1427 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1428 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1429 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1430 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1432 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1433 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1439 * Z71V pin configuration:
1440 * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
1442 static struct hda_verb alc880_pin_z71v_init_verbs[] = {
1443 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1444 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1445 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1446 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1448 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1449 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1450 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1451 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1457 * 6-stack pin configuration:
1458 * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18,
1459 * f-mic = 0x19, line = 0x1a, HP = 0x1b
1461 static struct hda_verb alc880_pin_6stack_init_verbs[] = {
1462 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1464 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1465 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1466 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1467 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1468 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1469 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1470 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1471 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1473 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1474 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1475 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1476 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1477 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1478 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1479 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1480 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1481 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1487 * Uniwill pin configuration:
1488 * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19,
1491 static struct hda_verb alc880_uniwill_init_verbs[] = {
1492 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1494 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1495 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1496 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1497 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1498 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1499 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1500 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1501 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1502 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1503 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1504 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1505 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1506 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1507 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1509 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1510 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1511 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1512 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1513 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1514 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1515 /* {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, */
1516 /* {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
1517 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1519 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
1520 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
1527 * HP = 0x14, InternalSpeaker = 0x15, mic = 0x19,
1529 static struct hda_verb alc880_uniwill_p53_init_verbs[] = {
1530 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1532 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1533 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1534 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1535 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1536 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1537 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1538 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1539 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1540 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1541 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1542 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1543 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1545 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1546 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1547 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1548 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1549 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1550 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1552 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
1553 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_DCVOL_EVENT},
1558 static struct hda_verb alc880_beep_init_verbs[] = {
1559 { 0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5) },
1563 /* toggle speaker-output according to the hp-jack state */
1564 static void alc880_uniwill_hp_automute(struct hda_codec *codec)
1566 unsigned int present;
1569 present = snd_hda_codec_read(codec, 0x14, 0,
1570 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1571 bits = present ? 0x80 : 0;
1572 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
1574 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
1576 snd_hda_codec_amp_update(codec, 0x16, 0, HDA_OUTPUT, 0,
1578 snd_hda_codec_amp_update(codec, 0x16, 1, HDA_OUTPUT, 0,
1582 /* auto-toggle front mic */
1583 static void alc880_uniwill_mic_automute(struct hda_codec *codec)
1585 unsigned int present;
1588 present = snd_hda_codec_read(codec, 0x18, 0,
1589 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1590 bits = present ? 0x80 : 0;
1591 snd_hda_codec_amp_update(codec, 0x0b, 0, HDA_INPUT, 1,
1593 snd_hda_codec_amp_update(codec, 0x0b, 1, HDA_INPUT, 1,
1597 static void alc880_uniwill_automute(struct hda_codec *codec)
1599 alc880_uniwill_hp_automute(codec);
1600 alc880_uniwill_mic_automute(codec);
1603 static void alc880_uniwill_unsol_event(struct hda_codec *codec,
1606 /* Looks like the unsol event is incompatible with the standard
1607 * definition. 4bit tag is placed at 28 bit!
1609 switch (res >> 28) {
1610 case ALC880_HP_EVENT:
1611 alc880_uniwill_hp_automute(codec);
1613 case ALC880_MIC_EVENT:
1614 alc880_uniwill_mic_automute(codec);
1619 static void alc880_uniwill_p53_hp_automute(struct hda_codec *codec)
1621 unsigned int present;
1624 present = snd_hda_codec_read(codec, 0x14, 0,
1625 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1626 bits = present ? 0x80 : 0;
1627 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_INPUT, 0,
1629 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_INPUT, 0,
1633 static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec)
1635 unsigned int present;
1637 present = snd_hda_codec_read(codec, 0x21, 0,
1638 AC_VERB_GET_VOLUME_KNOB_CONTROL, 0) & 0x7f;
1640 snd_hda_codec_amp_update(codec, 0x0c, 0, HDA_OUTPUT, 0,
1642 snd_hda_codec_amp_update(codec, 0x0c, 1, HDA_OUTPUT, 0,
1645 snd_hda_codec_amp_update(codec, 0x0d, 0, HDA_OUTPUT, 0,
1647 snd_hda_codec_amp_update(codec, 0x0d, 1, HDA_OUTPUT, 0,
1651 static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec,
1654 /* Looks like the unsol event is incompatible with the standard
1655 * definition. 4bit tag is placed at 28 bit!
1657 if ((res >> 28) == ALC880_HP_EVENT)
1658 alc880_uniwill_p53_hp_automute(codec);
1659 if ((res >> 28) == ALC880_DCVOL_EVENT)
1660 alc880_uniwill_p53_dcvol_automute(codec);
1665 * F1734 pin configuration:
1666 * HP = 0x14, speaker-out = 0x15, mic = 0x18
1668 static struct hda_verb alc880_pin_f1734_init_verbs[] = {
1669 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
1670 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
1671 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
1672 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
1674 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1675 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1676 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1677 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1679 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1680 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1681 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1682 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1683 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1684 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1685 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1686 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1687 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1694 * ASUS pin configuration:
1695 * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
1697 static struct hda_verb alc880_pin_asus_init_verbs[] = {
1698 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
1699 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
1700 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
1701 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
1703 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1704 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1705 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1706 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1707 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1708 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1709 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1710 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1712 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1713 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1714 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1715 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1716 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1717 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1718 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1719 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1720 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1725 /* Enable GPIO mask and set output */
1726 #define alc880_gpio1_init_verbs alc_gpio1_init_verbs
1727 #define alc880_gpio2_init_verbs alc_gpio2_init_verbs
1729 /* Clevo m520g init */
1730 static struct hda_verb alc880_pin_clevo_init_verbs[] = {
1731 /* headphone output */
1732 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
1734 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1735 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1737 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1738 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1740 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1741 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1742 /* Mic1 (rear panel) */
1743 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1744 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1745 /* Mic2 (front panel) */
1746 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1747 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1749 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1750 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1751 /* change to EAPD mode */
1752 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
1753 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
1758 static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
1759 /* change to EAPD mode */
1760 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
1761 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
1763 /* Headphone output */
1764 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1766 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1767 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
1769 /* Line In pin widget for input */
1770 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1771 /* CD pin widget for input */
1772 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1773 /* Mic1 (rear panel) pin widget for input and vref at 80% */
1774 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1776 /* change to EAPD mode */
1777 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
1778 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
1784 * LG m1 express dual
1787 * Rear Line-In/Out (blue): 0x14
1788 * Build-in Mic-In: 0x15
1790 * HP-Out (green): 0x1b
1791 * Mic-In/Out (red): 0x19
1795 /* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
1796 static hda_nid_t alc880_lg_dac_nids[3] = {
1800 /* seems analog CD is not working */
1801 static struct hda_input_mux alc880_lg_capture_source = {
1806 { "Internal Mic", 0x6 },
1810 /* 2,4,6 channel modes */
1811 static struct hda_verb alc880_lg_ch2_init[] = {
1812 /* set line-in and mic-in to input */
1813 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1814 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1818 static struct hda_verb alc880_lg_ch4_init[] = {
1819 /* set line-in to out and mic-in to input */
1820 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
1821 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1825 static struct hda_verb alc880_lg_ch6_init[] = {
1826 /* set line-in and mic-in to output */
1827 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
1828 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
1832 static struct hda_channel_mode alc880_lg_ch_modes[3] = {
1833 { 2, alc880_lg_ch2_init },
1834 { 4, alc880_lg_ch4_init },
1835 { 6, alc880_lg_ch6_init },
1838 static struct snd_kcontrol_new alc880_lg_mixer[] = {
1839 /* FIXME: it's not really "master" but front channels */
1840 HDA_CODEC_VOLUME("Master Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
1841 HDA_BIND_MUTE("Master Playback Switch", 0x0f, 2, HDA_INPUT),
1842 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1843 HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
1844 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
1845 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
1846 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
1847 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
1848 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1849 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1850 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
1851 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
1852 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
1853 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
1855 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1856 .name = "Channel Mode",
1857 .info = alc_ch_mode_info,
1858 .get = alc_ch_mode_get,
1859 .put = alc_ch_mode_put,
1864 static struct hda_verb alc880_lg_init_verbs[] = {
1865 /* set capture source to mic-in */
1866 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1867 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1868 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1869 /* mute all amp mixer inputs */
1870 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
1871 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(6)},
1872 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(7)},
1873 /* line-in to input */
1874 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1875 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1877 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1878 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1880 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1881 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1882 /* mic-in to input */
1883 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
1884 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1885 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1887 {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
1888 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1889 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1891 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
1895 /* toggle speaker-output according to the hp-jack state */
1896 static void alc880_lg_automute(struct hda_codec *codec)
1898 unsigned int present;
1901 present = snd_hda_codec_read(codec, 0x1b, 0,
1902 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1903 bits = present ? 0x80 : 0;
1904 snd_hda_codec_amp_update(codec, 0x17, 0, HDA_OUTPUT, 0,
1906 snd_hda_codec_amp_update(codec, 0x17, 1, HDA_OUTPUT, 0,
1910 static void alc880_lg_unsol_event(struct hda_codec *codec, unsigned int res)
1912 /* Looks like the unsol event is incompatible with the standard
1913 * definition. 4bit tag is placed at 28 bit!
1915 if ((res >> 28) == 0x01)
1916 alc880_lg_automute(codec);
1925 * Built-in Mic-In: 0x19
1931 static struct hda_input_mux alc880_lg_lw_capture_source = {
1935 { "Internal Mic", 0x1 },
1940 #define alc880_lg_lw_modes alc880_threestack_modes
1942 static struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
1943 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1944 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1945 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
1946 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
1947 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1948 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1949 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1950 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1951 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1952 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1953 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1954 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1955 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
1956 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
1958 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1959 .name = "Channel Mode",
1960 .info = alc_ch_mode_info,
1961 .get = alc_ch_mode_get,
1962 .put = alc_ch_mode_put,
1967 static struct hda_verb alc880_lg_lw_init_verbs[] = {
1968 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1969 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
1970 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
1972 /* set capture source to mic-in */
1973 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1974 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1975 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1976 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(7)},
1978 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1979 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1981 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1982 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1983 /* mic-in to input */
1984 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1985 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1987 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1988 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1990 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
1994 /* toggle speaker-output according to the hp-jack state */
1995 static void alc880_lg_lw_automute(struct hda_codec *codec)
1997 unsigned int present;
2000 present = snd_hda_codec_read(codec, 0x1b, 0,
2001 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
2002 bits = present ? 0x80 : 0;
2003 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
2005 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
2009 static void alc880_lg_lw_unsol_event(struct hda_codec *codec, unsigned int res)
2011 /* Looks like the unsol event is incompatible with the standard
2012 * definition. 4bit tag is placed at 28 bit!
2014 if ((res >> 28) == 0x01)
2015 alc880_lg_lw_automute(codec);
2022 static int alc_init(struct hda_codec *codec)
2024 struct alc_spec *spec = codec->spec;
2027 for (i = 0; i < spec->num_init_verbs; i++)
2028 snd_hda_sequence_write(codec, spec->init_verbs[i]);
2030 if (spec->init_hook)
2031 spec->init_hook(codec);
2036 static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
2038 struct alc_spec *spec = codec->spec;
2040 if (spec->unsol_event)
2041 spec->unsol_event(codec, res);
2048 static int alc_resume(struct hda_codec *codec)
2050 struct alc_spec *spec = codec->spec;
2054 for (i = 0; i < spec->num_mixers; i++)
2055 snd_hda_resume_ctls(codec, spec->mixers[i]);
2056 if (spec->multiout.dig_out_nid)
2057 snd_hda_resume_spdif_out(codec);
2058 if (spec->dig_in_nid)
2059 snd_hda_resume_spdif_in(codec);
2066 * Analog playback callbacks
2068 static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
2069 struct hda_codec *codec,
2070 struct snd_pcm_substream *substream)
2072 struct alc_spec *spec = codec->spec;
2073 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream);
2076 static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2077 struct hda_codec *codec,
2078 unsigned int stream_tag,
2079 unsigned int format,
2080 struct snd_pcm_substream *substream)
2082 struct alc_spec *spec = codec->spec;
2083 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
2084 stream_tag, format, substream);
2087 static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
2088 struct hda_codec *codec,
2089 struct snd_pcm_substream *substream)
2091 struct alc_spec *spec = codec->spec;
2092 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
2098 static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
2099 struct hda_codec *codec,
2100 struct snd_pcm_substream *substream)
2102 struct alc_spec *spec = codec->spec;
2103 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
2106 static int alc880_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2107 struct hda_codec *codec,
2108 unsigned int stream_tag,
2109 unsigned int format,
2110 struct snd_pcm_substream *substream)
2112 struct alc_spec *spec = codec->spec;
2113 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
2114 stream_tag, format, substream);
2117 static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
2118 struct hda_codec *codec,
2119 struct snd_pcm_substream *substream)
2121 struct alc_spec *spec = codec->spec;
2122 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
2128 static int alc880_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
2129 struct hda_codec *codec,
2130 unsigned int stream_tag,
2131 unsigned int format,
2132 struct snd_pcm_substream *substream)
2134 struct alc_spec *spec = codec->spec;
2136 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
2137 stream_tag, 0, format);
2141 static int alc880_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
2142 struct hda_codec *codec,
2143 struct snd_pcm_substream *substream)
2145 struct alc_spec *spec = codec->spec;
2147 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
2155 static struct hda_pcm_stream alc880_pcm_analog_playback = {
2159 /* NID is set in alc_build_pcms */
2161 .open = alc880_playback_pcm_open,
2162 .prepare = alc880_playback_pcm_prepare,
2163 .cleanup = alc880_playback_pcm_cleanup
2167 static struct hda_pcm_stream alc880_pcm_analog_capture = {
2171 /* NID is set in alc_build_pcms */
2173 .prepare = alc880_capture_pcm_prepare,
2174 .cleanup = alc880_capture_pcm_cleanup
2178 static struct hda_pcm_stream alc880_pcm_digital_playback = {
2182 /* NID is set in alc_build_pcms */
2184 .open = alc880_dig_playback_pcm_open,
2185 .close = alc880_dig_playback_pcm_close,
2186 .prepare = alc880_dig_playback_pcm_prepare
2190 static struct hda_pcm_stream alc880_pcm_digital_capture = {
2194 /* NID is set in alc_build_pcms */
2197 /* Used by alc_build_pcms to flag that a PCM has no playback stream */
2198 static struct hda_pcm_stream alc_pcm_null_playback = {
2204 static int alc_build_pcms(struct hda_codec *codec)
2206 struct alc_spec *spec = codec->spec;
2207 struct hda_pcm *info = spec->pcm_rec;
2210 codec->num_pcms = 1;
2211 codec->pcm_info = info;
2213 info->name = spec->stream_name_analog;
2214 if (spec->stream_analog_playback) {
2215 snd_assert(spec->multiout.dac_nids, return -EINVAL);
2216 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
2217 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
2219 if (spec->stream_analog_capture) {
2220 snd_assert(spec->adc_nids, return -EINVAL);
2221 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
2222 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
2225 if (spec->channel_mode) {
2226 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
2227 for (i = 0; i < spec->num_channel_mode; i++) {
2228 if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
2229 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
2234 /* SPDIF for stream index #1 */
2235 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
2236 codec->num_pcms = 2;
2237 info = spec->pcm_rec + 1;
2238 info->name = spec->stream_name_digital;
2239 if (spec->multiout.dig_out_nid &&
2240 spec->stream_digital_playback) {
2241 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
2242 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
2244 if (spec->dig_in_nid &&
2245 spec->stream_digital_capture) {
2246 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
2247 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
2251 /* If the use of more than one ADC is requested for the current
2252 * model, configure a second analog capture-only PCM.
2254 /* Additional Analaog capture for index #2 */
2255 if (spec->num_adc_nids > 1 && spec->stream_analog_capture &&
2257 codec->num_pcms = 3;
2258 info = spec->pcm_rec + 2;
2259 info->name = spec->stream_name_analog;
2260 /* No playback stream for second PCM */
2261 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = alc_pcm_null_playback;
2262 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
2263 if (spec->stream_analog_capture) {
2264 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
2265 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[1];
2272 static void alc_free(struct hda_codec *codec)
2274 struct alc_spec *spec = codec->spec;
2280 if (spec->kctl_alloc) {
2281 for (i = 0; i < spec->num_kctl_used; i++)
2282 kfree(spec->kctl_alloc[i].name);
2283 kfree(spec->kctl_alloc);
2290 static struct hda_codec_ops alc_patch_ops = {
2291 .build_controls = alc_build_controls,
2292 .build_pcms = alc_build_pcms,
2295 .unsol_event = alc_unsol_event,
2297 .resume = alc_resume,
2303 * Test configuration for debugging
2305 * Almost all inputs/outputs are enabled. I/O pins can be configured via
2308 #ifdef CONFIG_SND_DEBUG
2309 static hda_nid_t alc880_test_dac_nids[4] = {
2310 0x02, 0x03, 0x04, 0x05
2313 static struct hda_input_mux alc880_test_capture_source = {
2322 { "Surround", 0x6 },
2326 static struct hda_channel_mode alc880_test_modes[4] = {
2333 static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol,
2334 struct snd_ctl_elem_info *uinfo)
2336 static char *texts[] = {
2337 "N/A", "Line Out", "HP Out",
2338 "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
2340 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
2342 uinfo->value.enumerated.items = 8;
2343 if (uinfo->value.enumerated.item >= 8)
2344 uinfo->value.enumerated.item = 7;
2345 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
2349 static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol,
2350 struct snd_ctl_elem_value *ucontrol)
2352 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2353 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2354 unsigned int pin_ctl, item = 0;
2356 pin_ctl = snd_hda_codec_read(codec, nid, 0,
2357 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
2358 if (pin_ctl & AC_PINCTL_OUT_EN) {
2359 if (pin_ctl & AC_PINCTL_HP_EN)
2363 } else if (pin_ctl & AC_PINCTL_IN_EN) {
2364 switch (pin_ctl & AC_PINCTL_VREFEN) {
2365 case AC_PINCTL_VREF_HIZ: item = 3; break;
2366 case AC_PINCTL_VREF_50: item = 4; break;
2367 case AC_PINCTL_VREF_GRD: item = 5; break;
2368 case AC_PINCTL_VREF_80: item = 6; break;
2369 case AC_PINCTL_VREF_100: item = 7; break;
2372 ucontrol->value.enumerated.item[0] = item;
2376 static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol,
2377 struct snd_ctl_elem_value *ucontrol)
2379 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2380 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2381 static unsigned int ctls[] = {
2382 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
2383 AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
2384 AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
2385 AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
2386 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
2387 AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
2389 unsigned int old_ctl, new_ctl;
2391 old_ctl = snd_hda_codec_read(codec, nid, 0,
2392 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
2393 new_ctl = ctls[ucontrol->value.enumerated.item[0]];
2394 if (old_ctl != new_ctl) {
2395 snd_hda_codec_write(codec, nid, 0,
2396 AC_VERB_SET_PIN_WIDGET_CONTROL, new_ctl);
2397 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
2398 (ucontrol->value.enumerated.item[0] >= 3 ?
2405 static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol,
2406 struct snd_ctl_elem_info *uinfo)
2408 static char *texts[] = {
2409 "Front", "Surround", "CLFE", "Side"
2411 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
2413 uinfo->value.enumerated.items = 4;
2414 if (uinfo->value.enumerated.item >= 4)
2415 uinfo->value.enumerated.item = 3;
2416 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
2420 static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol,
2421 struct snd_ctl_elem_value *ucontrol)
2423 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2424 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2427 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
2428 ucontrol->value.enumerated.item[0] = sel & 3;
2432 static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol,
2433 struct snd_ctl_elem_value *ucontrol)
2435 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2436 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2439 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
2440 if (ucontrol->value.enumerated.item[0] != sel) {
2441 sel = ucontrol->value.enumerated.item[0] & 3;
2442 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, sel);
2448 #define PIN_CTL_TEST(xname,nid) { \
2449 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2451 .info = alc_test_pin_ctl_info, \
2452 .get = alc_test_pin_ctl_get, \
2453 .put = alc_test_pin_ctl_put, \
2454 .private_value = nid \
2457 #define PIN_SRC_TEST(xname,nid) { \
2458 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2460 .info = alc_test_pin_src_info, \
2461 .get = alc_test_pin_src_get, \
2462 .put = alc_test_pin_src_put, \
2463 .private_value = nid \
2466 static struct snd_kcontrol_new alc880_test_mixer[] = {
2467 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2468 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2469 HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
2470 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
2471 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2472 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
2473 HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
2474 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
2475 PIN_CTL_TEST("Front Pin Mode", 0x14),
2476 PIN_CTL_TEST("Surround Pin Mode", 0x15),
2477 PIN_CTL_TEST("CLFE Pin Mode", 0x16),
2478 PIN_CTL_TEST("Side Pin Mode", 0x17),
2479 PIN_CTL_TEST("In-1 Pin Mode", 0x18),
2480 PIN_CTL_TEST("In-2 Pin Mode", 0x19),
2481 PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
2482 PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
2483 PIN_SRC_TEST("In-1 Pin Source", 0x18),
2484 PIN_SRC_TEST("In-2 Pin Source", 0x19),
2485 PIN_SRC_TEST("In-3 Pin Source", 0x1a),
2486 PIN_SRC_TEST("In-4 Pin Source", 0x1b),
2487 HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
2488 HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
2489 HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
2490 HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
2491 HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
2492 HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
2493 HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
2494 HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
2495 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
2496 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
2498 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2499 .name = "Channel Mode",
2500 .info = alc_ch_mode_info,
2501 .get = alc_ch_mode_get,
2502 .put = alc_ch_mode_put,
2507 static struct hda_verb alc880_test_init_verbs[] = {
2508 /* Unmute inputs of 0x0c - 0x0f */
2509 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2510 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2511 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2512 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2513 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2514 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2515 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2516 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2517 /* Vol output for 0x0c-0x0f */
2518 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2519 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2520 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2521 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2522 /* Set output pins 0x14-0x17 */
2523 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2524 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2525 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2526 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2527 /* Unmute output pins 0x14-0x17 */
2528 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2529 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2530 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2531 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2532 /* Set input pins 0x18-0x1c */
2533 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2534 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2535 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2536 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2537 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2538 /* Mute input pins 0x18-0x1b */
2539 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2540 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2541 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2542 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2544 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2545 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
2546 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2547 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
2548 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2549 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
2550 /* Analog input/passthru */
2551 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2552 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2553 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
2554 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
2555 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
2563 static const char *alc880_models[ALC880_MODEL_LAST] = {
2564 [ALC880_3ST] = "3stack",
2565 [ALC880_TCL_S700] = "tcl",
2566 [ALC880_3ST_DIG] = "3stack-digout",
2567 [ALC880_CLEVO] = "clevo",
2568 [ALC880_5ST] = "5stack",
2569 [ALC880_5ST_DIG] = "5stack-digout",
2570 [ALC880_W810] = "w810",
2571 [ALC880_Z71V] = "z71v",
2572 [ALC880_6ST] = "6stack",
2573 [ALC880_6ST_DIG] = "6stack-digout",
2574 [ALC880_ASUS] = "asus",
2575 [ALC880_ASUS_W1V] = "asus-w1v",
2576 [ALC880_ASUS_DIG] = "asus-dig",
2577 [ALC880_ASUS_DIG2] = "asus-dig2",
2578 [ALC880_UNIWILL_DIG] = "uniwill",
2579 [ALC880_UNIWILL_P53] = "uniwill-p53",
2580 [ALC880_FUJITSU] = "fujitsu",
2581 [ALC880_F1734] = "F1734",
2583 [ALC880_LG_LW] = "lg-lw",
2584 #ifdef CONFIG_SND_DEBUG
2585 [ALC880_TEST] = "test",
2587 [ALC880_AUTO] = "auto",
2590 static struct snd_pci_quirk alc880_cfg_tbl[] = {
2591 /* Broken BIOS configuration */
2592 SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_6ST_DIG),
2593 SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_6ST_DIG),
2595 SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_5ST_DIG),
2596 SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_6ST),
2597 SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_W810),
2598 SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_3ST_DIG),
2599 SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_6ST_DIG),
2600 SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_6ST_DIG),
2601 SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_6ST_DIG),
2602 SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_3ST_DIG),
2603 SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_3ST),
2605 SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_6ST_DIG),
2606 SND_PCI_QUIRK(0x103c, 0x2a09, "HP", ALC880_5ST),
2608 SND_PCI_QUIRK(0x1043, 0x10b3, "ASUS W1V", ALC880_ASUS_W1V),
2609 SND_PCI_QUIRK(0x1043, 0x10c2, "ASUS W6A", ALC880_ASUS_DIG),
2610 SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS Wxx", ALC880_ASUS_DIG),
2611 SND_PCI_QUIRK(0x1043, 0x1113, "ASUS", ALC880_ASUS_DIG),
2612 SND_PCI_QUIRK(0x1043, 0x1123, "ASUS", ALC880_ASUS_DIG),
2613 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS", ALC880_ASUS_DIG),
2614 SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_Z71V),
2615 /* SND_PCI_QUIRK(0x1043, 0x1964, "ASUS", ALC880_ASUS_DIG), */
2616 SND_PCI_QUIRK(0x1043, 0x1973, "ASUS", ALC880_ASUS_DIG),
2617 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS", ALC880_ASUS_DIG),
2618 SND_PCI_QUIRK(0x1043, 0x814e, "ASUS", ALC880_ASUS),
2619 SND_PCI_QUIRK(0x1043, 0x8181, "ASUS P4GPL", ALC880_ASUS_DIG),
2620 SND_PCI_QUIRK(0x1043, 0x8196, "ASUS P5GD1", ALC880_6ST),
2621 SND_PCI_QUIRK(0x1043, 0x81b4, "ASUS", ALC880_6ST),
2622 SND_PCI_QUIRK(0x1043, 0, "ASUS", ALC880_ASUS),
2624 SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_3ST),
2625 SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_3ST),
2626 SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_5ST),
2627 SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_5ST),
2628 SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_5ST),
2629 SND_PCI_QUIRK(0x1558, 0x0520, "Clevo m520G", ALC880_CLEVO),
2630 SND_PCI_QUIRK(0x1558, 0x0660, "Clevo m655n", ALC880_CLEVO),
2631 SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_5ST_DIG),
2632 SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_W810),
2633 SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_5ST_DIG),
2634 SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_TCL_S700),
2635 SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_5ST_DIG),
2636 SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_6ST_DIG),
2637 SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_6ST_DIG),
2638 SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_6ST_DIG),
2639 SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_6ST_DIG),
2640 SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_6ST_DIG),
2641 SND_PCI_QUIRK(0x1558, 0x5401, "ASUS", ALC880_ASUS_DIG2),
2643 SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_UNIWILL_DIG),
2644 SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_UNIWILL),
2645 SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_UNIWILL_P53),
2646 SND_PCI_QUIRK(0x1584, 0x9054, "Uniwlll", ALC880_F1734),
2648 SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_5ST_DIG),
2649 SND_PCI_QUIRK(0x1734, 0x10ac, "FSC", ALC880_UNIWILL),
2650 SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_F1734),
2651 SND_PCI_QUIRK(0x1734, 0x10b0, "Fujitsu", ALC880_FUJITSU),
2653 SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_LG),
2654 SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_LG),
2655 SND_PCI_QUIRK(0x1854, 0x0018, "LG LW20", ALC880_LG_LW),
2656 SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_LG_LW),
2658 SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_3ST_DIG),
2659 SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_3ST_DIG),
2660 SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_3ST_DIG),
2661 SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_5ST_DIG),
2662 SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_5ST_DIG),
2663 SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_5ST_DIG),
2664 SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_5ST_DIG),
2665 SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_5ST_DIG),
2666 SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_5ST_DIG),
2667 SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_5ST_DIG),
2668 SND_PCI_QUIRK(0x8086, 0, "Intel mobo", ALC880_3ST),
2674 * ALC880 codec presets
2676 static struct alc_config_preset alc880_presets[] = {
2678 .mixers = { alc880_three_stack_mixer },
2679 .init_verbs = { alc880_volume_init_verbs,
2680 alc880_pin_3stack_init_verbs },
2681 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2682 .dac_nids = alc880_dac_nids,
2683 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
2684 .channel_mode = alc880_threestack_modes,
2686 .input_mux = &alc880_capture_source,
2688 [ALC880_3ST_DIG] = {
2689 .mixers = { alc880_three_stack_mixer },
2690 .init_verbs = { alc880_volume_init_verbs,
2691 alc880_pin_3stack_init_verbs },
2692 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2693 .dac_nids = alc880_dac_nids,
2694 .dig_out_nid = ALC880_DIGOUT_NID,
2695 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
2696 .channel_mode = alc880_threestack_modes,
2698 .input_mux = &alc880_capture_source,
2700 [ALC880_TCL_S700] = {
2701 .mixers = { alc880_tcl_s700_mixer },
2702 .init_verbs = { alc880_volume_init_verbs,
2703 alc880_pin_tcl_S700_init_verbs,
2704 alc880_gpio2_init_verbs },
2705 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2706 .dac_nids = alc880_dac_nids,
2708 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
2709 .channel_mode = alc880_2_jack_modes,
2710 .input_mux = &alc880_capture_source,
2713 .mixers = { alc880_three_stack_mixer,
2714 alc880_five_stack_mixer},
2715 .init_verbs = { alc880_volume_init_verbs,
2716 alc880_pin_5stack_init_verbs },
2717 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2718 .dac_nids = alc880_dac_nids,
2719 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
2720 .channel_mode = alc880_fivestack_modes,
2721 .input_mux = &alc880_capture_source,
2723 [ALC880_5ST_DIG] = {
2724 .mixers = { alc880_three_stack_mixer,
2725 alc880_five_stack_mixer },
2726 .init_verbs = { alc880_volume_init_verbs,
2727 alc880_pin_5stack_init_verbs },
2728 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2729 .dac_nids = alc880_dac_nids,
2730 .dig_out_nid = ALC880_DIGOUT_NID,
2731 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
2732 .channel_mode = alc880_fivestack_modes,
2733 .input_mux = &alc880_capture_source,
2736 .mixers = { alc880_six_stack_mixer },
2737 .init_verbs = { alc880_volume_init_verbs,
2738 alc880_pin_6stack_init_verbs },
2739 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
2740 .dac_nids = alc880_6st_dac_nids,
2741 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
2742 .channel_mode = alc880_sixstack_modes,
2743 .input_mux = &alc880_6stack_capture_source,
2745 [ALC880_6ST_DIG] = {
2746 .mixers = { alc880_six_stack_mixer },
2747 .init_verbs = { alc880_volume_init_verbs,
2748 alc880_pin_6stack_init_verbs },
2749 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
2750 .dac_nids = alc880_6st_dac_nids,
2751 .dig_out_nid = ALC880_DIGOUT_NID,
2752 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
2753 .channel_mode = alc880_sixstack_modes,
2754 .input_mux = &alc880_6stack_capture_source,
2757 .mixers = { alc880_w810_base_mixer },
2758 .init_verbs = { alc880_volume_init_verbs,
2759 alc880_pin_w810_init_verbs,
2760 alc880_gpio2_init_verbs },
2761 .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
2762 .dac_nids = alc880_w810_dac_nids,
2763 .dig_out_nid = ALC880_DIGOUT_NID,
2764 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
2765 .channel_mode = alc880_w810_modes,
2766 .input_mux = &alc880_capture_source,
2769 .mixers = { alc880_z71v_mixer },
2770 .init_verbs = { alc880_volume_init_verbs,
2771 alc880_pin_z71v_init_verbs },
2772 .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
2773 .dac_nids = alc880_z71v_dac_nids,
2774 .dig_out_nid = ALC880_DIGOUT_NID,
2776 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
2777 .channel_mode = alc880_2_jack_modes,
2778 .input_mux = &alc880_capture_source,
2781 .mixers = { alc880_f1734_mixer },
2782 .init_verbs = { alc880_volume_init_verbs,
2783 alc880_pin_f1734_init_verbs },
2784 .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
2785 .dac_nids = alc880_f1734_dac_nids,
2787 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
2788 .channel_mode = alc880_2_jack_modes,
2789 .input_mux = &alc880_capture_source,
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 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2799 .channel_mode = alc880_asus_modes,
2801 .input_mux = &alc880_capture_source,
2803 [ALC880_ASUS_DIG] = {
2804 .mixers = { alc880_asus_mixer },
2805 .init_verbs = { alc880_volume_init_verbs,
2806 alc880_pin_asus_init_verbs,
2807 alc880_gpio1_init_verbs },
2808 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2809 .dac_nids = alc880_asus_dac_nids,
2810 .dig_out_nid = ALC880_DIGOUT_NID,
2811 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2812 .channel_mode = alc880_asus_modes,
2814 .input_mux = &alc880_capture_source,
2816 [ALC880_ASUS_DIG2] = {
2817 .mixers = { alc880_asus_mixer },
2818 .init_verbs = { alc880_volume_init_verbs,
2819 alc880_pin_asus_init_verbs,
2820 alc880_gpio2_init_verbs }, /* use GPIO2 */
2821 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2822 .dac_nids = alc880_asus_dac_nids,
2823 .dig_out_nid = ALC880_DIGOUT_NID,
2824 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2825 .channel_mode = alc880_asus_modes,
2827 .input_mux = &alc880_capture_source,
2829 [ALC880_ASUS_W1V] = {
2830 .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
2831 .init_verbs = { alc880_volume_init_verbs,
2832 alc880_pin_asus_init_verbs,
2833 alc880_gpio1_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_DIG] = {
2843 .mixers = { alc880_asus_mixer, alc880_pcbeep_mixer },
2844 .init_verbs = { alc880_volume_init_verbs,
2845 alc880_pin_asus_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_asus_modes),
2850 .channel_mode = alc880_asus_modes,
2852 .input_mux = &alc880_capture_source,
2854 [ALC880_UNIWILL] = {
2855 .mixers = { alc880_uniwill_mixer },
2856 .init_verbs = { alc880_volume_init_verbs,
2857 alc880_uniwill_init_verbs },
2858 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2859 .dac_nids = alc880_asus_dac_nids,
2860 .dig_out_nid = ALC880_DIGOUT_NID,
2861 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
2862 .channel_mode = alc880_threestack_modes,
2864 .input_mux = &alc880_capture_source,
2865 .unsol_event = alc880_uniwill_unsol_event,
2866 .init_hook = alc880_uniwill_automute,
2868 [ALC880_UNIWILL_P53] = {
2869 .mixers = { alc880_uniwill_p53_mixer },
2870 .init_verbs = { alc880_volume_init_verbs,
2871 alc880_uniwill_p53_init_verbs },
2872 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2873 .dac_nids = alc880_asus_dac_nids,
2874 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
2875 .channel_mode = alc880_threestack_modes,
2876 .input_mux = &alc880_capture_source,
2877 .unsol_event = alc880_uniwill_p53_unsol_event,
2878 .init_hook = alc880_uniwill_p53_hp_automute,
2880 [ALC880_FUJITSU] = {
2881 .mixers = { alc880_fujitsu_mixer,
2882 alc880_pcbeep_mixer, },
2883 .init_verbs = { alc880_volume_init_verbs,
2884 alc880_uniwill_p53_init_verbs,
2885 alc880_beep_init_verbs },
2886 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2887 .dac_nids = alc880_dac_nids,
2888 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
2889 .channel_mode = alc880_2_jack_modes,
2890 .input_mux = &alc880_capture_source,
2891 .unsol_event = alc880_uniwill_p53_unsol_event,
2892 .init_hook = alc880_uniwill_p53_hp_automute,
2895 .mixers = { alc880_three_stack_mixer },
2896 .init_verbs = { alc880_volume_init_verbs,
2897 alc880_pin_clevo_init_verbs },
2898 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2899 .dac_nids = alc880_dac_nids,
2901 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
2902 .channel_mode = alc880_threestack_modes,
2904 .input_mux = &alc880_capture_source,
2907 .mixers = { alc880_lg_mixer },
2908 .init_verbs = { alc880_volume_init_verbs,
2909 alc880_lg_init_verbs },
2910 .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids),
2911 .dac_nids = alc880_lg_dac_nids,
2912 .dig_out_nid = ALC880_DIGOUT_NID,
2913 .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes),
2914 .channel_mode = alc880_lg_ch_modes,
2916 .input_mux = &alc880_lg_capture_source,
2917 .unsol_event = alc880_lg_unsol_event,
2918 .init_hook = alc880_lg_automute,
2921 .mixers = { alc880_lg_lw_mixer },
2922 .init_verbs = { alc880_volume_init_verbs,
2923 alc880_lg_lw_init_verbs },
2924 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2925 .dac_nids = alc880_dac_nids,
2926 .dig_out_nid = ALC880_DIGOUT_NID,
2927 .num_channel_mode = ARRAY_SIZE(alc880_lg_lw_modes),
2928 .channel_mode = alc880_lg_lw_modes,
2929 .input_mux = &alc880_lg_lw_capture_source,
2930 .unsol_event = alc880_lg_lw_unsol_event,
2931 .init_hook = alc880_lg_lw_automute,
2933 #ifdef CONFIG_SND_DEBUG
2935 .mixers = { alc880_test_mixer },
2936 .init_verbs = { alc880_test_init_verbs },
2937 .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
2938 .dac_nids = alc880_test_dac_nids,
2939 .dig_out_nid = ALC880_DIGOUT_NID,
2940 .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
2941 .channel_mode = alc880_test_modes,
2942 .input_mux = &alc880_test_capture_source,
2948 * Automatic parse of I/O pins from the BIOS configuration
2951 #define NUM_CONTROL_ALLOC 32
2952 #define NUM_VERB_ALLOC 32
2956 ALC_CTL_WIDGET_MUTE,
2959 static struct snd_kcontrol_new alc880_control_templates[] = {
2960 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
2961 HDA_CODEC_MUTE(NULL, 0, 0, 0),
2962 HDA_BIND_MUTE(NULL, 0, 0, 0),
2965 /* add dynamic controls */
2966 static int add_control(struct alc_spec *spec, int type, const char *name,
2969 struct snd_kcontrol_new *knew;
2971 if (spec->num_kctl_used >= spec->num_kctl_alloc) {
2972 int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC;
2974 /* array + terminator */
2975 knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL);
2978 if (spec->kctl_alloc) {
2979 memcpy(knew, spec->kctl_alloc,
2980 sizeof(*knew) * spec->num_kctl_alloc);
2981 kfree(spec->kctl_alloc);
2983 spec->kctl_alloc = knew;
2984 spec->num_kctl_alloc = num;
2987 knew = &spec->kctl_alloc[spec->num_kctl_used];
2988 *knew = alc880_control_templates[type];
2989 knew->name = kstrdup(name, GFP_KERNEL);
2992 knew->private_value = val;
2993 spec->num_kctl_used++;
2997 #define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
2998 #define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
2999 #define alc880_is_multi_pin(nid) ((nid) >= 0x18)
3000 #define alc880_multi_pin_idx(nid) ((nid) - 0x18)
3001 #define alc880_is_input_pin(nid) ((nid) >= 0x18)
3002 #define alc880_input_pin_idx(nid) ((nid) - 0x18)
3003 #define alc880_idx_to_dac(nid) ((nid) + 0x02)
3004 #define alc880_dac_to_idx(nid) ((nid) - 0x02)
3005 #define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
3006 #define alc880_idx_to_selector(nid) ((nid) + 0x10)
3007 #define ALC880_PIN_CD_NID 0x1c
3009 /* fill in the dac_nids table from the parsed pin configuration */
3010 static int alc880_auto_fill_dac_nids(struct alc_spec *spec,
3011 const struct auto_pin_cfg *cfg)
3017 memset(assigned, 0, sizeof(assigned));
3018 spec->multiout.dac_nids = spec->private_dac_nids;
3020 /* check the pins hardwired to 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)) {
3024 int idx = alc880_fixed_pin_idx(nid);
3025 spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
3029 /* left pins can be connect to any audio widget */
3030 for (i = 0; i < cfg->line_outs; i++) {
3031 nid = cfg->line_out_pins[i];
3032 if (alc880_is_fixed_pin(nid))
3034 /* search for an empty channel */
3035 for (j = 0; j < cfg->line_outs; j++) {
3037 spec->multiout.dac_nids[i] =
3038 alc880_idx_to_dac(j);
3044 spec->multiout.num_dacs = cfg->line_outs;
3048 /* add playback controls from the parsed DAC table */
3049 static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
3050 const struct auto_pin_cfg *cfg)
3053 static const char *chname[4] = {
3054 "Front", "Surround", NULL /*CLFE*/, "Side"
3059 for (i = 0; i < cfg->line_outs; i++) {
3060 if (!spec->multiout.dac_nids[i])
3062 nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
3065 err = add_control(spec, ALC_CTL_WIDGET_VOL,
3066 "Center Playback Volume",
3067 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
3071 err = add_control(spec, ALC_CTL_WIDGET_VOL,
3072 "LFE Playback Volume",
3073 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
3077 err = add_control(spec, ALC_CTL_BIND_MUTE,
3078 "Center Playback Switch",
3079 HDA_COMPOSE_AMP_VAL(nid, 1, 2,
3083 err = add_control(spec, ALC_CTL_BIND_MUTE,
3084 "LFE Playback Switch",
3085 HDA_COMPOSE_AMP_VAL(nid, 2, 2,
3090 sprintf(name, "%s Playback Volume", chname[i]);
3091 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
3092 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
3096 sprintf(name, "%s Playback Switch", chname[i]);
3097 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
3098 HDA_COMPOSE_AMP_VAL(nid, 3, 2,
3107 /* add playback controls for speaker and HP outputs */
3108 static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
3118 if (alc880_is_fixed_pin(pin)) {
3119 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
3120 /* specify the DAC as the extra output */
3121 if (!spec->multiout.hp_nid)
3122 spec->multiout.hp_nid = nid;
3124 spec->multiout.extra_out_nid[0] = nid;
3125 /* control HP volume/switch on the output mixer amp */
3126 nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
3127 sprintf(name, "%s Playback Volume", pfx);
3128 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
3129 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
3132 sprintf(name, "%s Playback Switch", pfx);
3133 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
3134 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
3137 } else if (alc880_is_multi_pin(pin)) {
3138 /* set manual connection */
3139 /* we have only a switch on HP-out PIN */
3140 sprintf(name, "%s Playback Switch", pfx);
3141 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
3142 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
3149 /* create input playback/capture controls for the given pin */
3150 static int new_analog_input(struct alc_spec *spec, hda_nid_t pin,
3151 const char *ctlname,
3152 int idx, hda_nid_t mix_nid)
3157 sprintf(name, "%s Playback Volume", ctlname);
3158 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
3159 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
3162 sprintf(name, "%s Playback Switch", ctlname);
3163 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
3164 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
3170 /* create playback/capture controls for input pins */
3171 static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec,
3172 const struct auto_pin_cfg *cfg)
3174 struct hda_input_mux *imux = &spec->private_imux;
3177 for (i = 0; i < AUTO_PIN_LAST; i++) {
3178 if (alc880_is_input_pin(cfg->input_pins[i])) {
3179 idx = alc880_input_pin_idx(cfg->input_pins[i]);
3180 err = new_analog_input(spec, cfg->input_pins[i],
3181 auto_pin_cfg_labels[i],
3185 imux->items[imux->num_items].label =
3186 auto_pin_cfg_labels[i];
3187 imux->items[imux->num_items].index =
3188 alc880_input_pin_idx(cfg->input_pins[i]);
3195 static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
3196 hda_nid_t nid, int pin_type,
3200 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
3202 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
3204 /* need the manual connection? */
3205 if (alc880_is_multi_pin(nid)) {
3206 struct alc_spec *spec = codec->spec;
3207 int idx = alc880_multi_pin_idx(nid);
3208 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
3209 AC_VERB_SET_CONNECT_SEL,
3210 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
3214 static int get_pin_type(int line_out_type)
3216 if (line_out_type == AUTO_PIN_HP_OUT)
3222 static void alc880_auto_init_multi_out(struct hda_codec *codec)
3224 struct alc_spec *spec = codec->spec;
3227 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
3228 for (i = 0; i < spec->autocfg.line_outs; i++) {
3229 hda_nid_t nid = spec->autocfg.line_out_pins[i];
3230 int pin_type = get_pin_type(spec->autocfg.line_out_type);
3231 alc880_auto_set_output_and_unmute(codec, nid, pin_type, i);
3235 static void alc880_auto_init_extra_out(struct hda_codec *codec)
3237 struct alc_spec *spec = codec->spec;
3240 pin = spec->autocfg.speaker_pins[0];
3241 if (pin) /* connect to front */
3242 alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
3243 pin = spec->autocfg.hp_pins[0];
3244 if (pin) /* connect to front */
3245 alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
3248 static void alc880_auto_init_analog_input(struct hda_codec *codec)
3250 struct alc_spec *spec = codec->spec;
3253 for (i = 0; i < AUTO_PIN_LAST; i++) {
3254 hda_nid_t nid = spec->autocfg.input_pins[i];
3255 if (alc880_is_input_pin(nid)) {
3256 snd_hda_codec_write(codec, nid, 0,
3257 AC_VERB_SET_PIN_WIDGET_CONTROL,
3258 i <= AUTO_PIN_FRONT_MIC ?
3259 PIN_VREF80 : PIN_IN);
3260 if (nid != ALC880_PIN_CD_NID)
3261 snd_hda_codec_write(codec, nid, 0,
3262 AC_VERB_SET_AMP_GAIN_MUTE,
3268 /* parse the BIOS configuration and set up the alc_spec */
3269 /* return 1 if successful, 0 if the proper config is not found,
3270 * or a negative error code
3272 static int alc880_parse_auto_config(struct hda_codec *codec)
3274 struct alc_spec *spec = codec->spec;
3276 static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
3278 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
3282 if (!spec->autocfg.line_outs)
3283 return 0; /* can't find valid BIOS pin config */
3285 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
3288 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
3291 err = alc880_auto_create_extra_out(spec,
3292 spec->autocfg.speaker_pins[0],
3296 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
3300 err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
3304 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
3306 if (spec->autocfg.dig_out_pin)
3307 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
3308 if (spec->autocfg.dig_in_pin)
3309 spec->dig_in_nid = ALC880_DIGIN_NID;
3311 if (spec->kctl_alloc)
3312 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
3314 spec->init_verbs[spec->num_init_verbs++] = alc880_volume_init_verbs;
3316 spec->num_mux_defs = 1;
3317 spec->input_mux = &spec->private_imux;
3322 /* additional initialization for auto-configuration model */
3323 static void alc880_auto_init(struct hda_codec *codec)
3325 alc880_auto_init_multi_out(codec);
3326 alc880_auto_init_extra_out(codec);
3327 alc880_auto_init_analog_input(codec);
3331 * OK, here we have finally the patch for ALC880
3334 static int patch_alc880(struct hda_codec *codec)
3336 struct alc_spec *spec;
3340 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
3346 board_config = snd_hda_check_board_config(codec, ALC880_MODEL_LAST,
3349 if (board_config < 0) {
3350 printk(KERN_INFO "hda_codec: Unknown model for ALC880, "
3351 "trying auto-probe from BIOS...\n");
3352 board_config = ALC880_AUTO;
3355 if (board_config == ALC880_AUTO) {
3356 /* automatic parse from the BIOS config */
3357 err = alc880_parse_auto_config(codec);
3363 "hda_codec: Cannot set up configuration "
3364 "from BIOS. Using 3-stack mode...\n");
3365 board_config = ALC880_3ST;
3369 if (board_config != ALC880_AUTO)
3370 setup_preset(spec, &alc880_presets[board_config]);
3372 spec->stream_name_analog = "ALC880 Analog";
3373 spec->stream_analog_playback = &alc880_pcm_analog_playback;
3374 spec->stream_analog_capture = &alc880_pcm_analog_capture;
3376 spec->stream_name_digital = "ALC880 Digital";
3377 spec->stream_digital_playback = &alc880_pcm_digital_playback;
3378 spec->stream_digital_capture = &alc880_pcm_digital_capture;
3380 if (!spec->adc_nids && spec->input_mux) {
3381 /* check whether NID 0x07 is valid */
3382 unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
3384 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
3385 if (wcap != AC_WID_AUD_IN) {
3386 spec->adc_nids = alc880_adc_nids_alt;
3387 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
3388 spec->mixers[spec->num_mixers] =
3389 alc880_capture_alt_mixer;
3392 spec->adc_nids = alc880_adc_nids;
3393 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
3394 spec->mixers[spec->num_mixers] = alc880_capture_mixer;
3399 codec->patch_ops = alc_patch_ops;
3400 if (board_config == ALC880_AUTO)
3401 spec->init_hook = alc880_auto_init;
3411 static hda_nid_t alc260_dac_nids[1] = {
3416 static hda_nid_t alc260_adc_nids[1] = {
3421 static hda_nid_t alc260_adc_nids_alt[1] = {
3426 static hda_nid_t alc260_hp_adc_nids[2] = {
3431 /* NIDs used when simultaneous access to both ADCs makes sense. Note that
3432 * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
3434 static hda_nid_t alc260_dual_adc_nids[2] = {
3439 #define ALC260_DIGOUT_NID 0x03
3440 #define ALC260_DIGIN_NID 0x06
3442 static struct hda_input_mux alc260_capture_source = {
3446 { "Front Mic", 0x1 },
3452 /* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
3453 * headphone jack and the internal CD lines since these are the only pins at
3454 * which audio can appear. For flexibility, also allow the option of
3455 * recording the mixer output on the second ADC (ADC0 doesn't have a
3456 * connection to the mixer output).
3458 static struct hda_input_mux alc260_fujitsu_capture_sources[2] = {
3462 { "Mic/Line", 0x0 },
3464 { "Headphone", 0x2 },
3470 { "Mic/Line", 0x0 },
3472 { "Headphone", 0x2 },
3479 /* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to
3480 * the Fujitsu S702x, but jacks are marked differently.
3482 static struct hda_input_mux alc260_acer_capture_sources[2] = {
3489 { "Headphone", 0x5 },
3498 { "Headphone", 0x6 },
3504 * This is just place-holder, so there's something for alc_build_pcms to look
3505 * at when it calculates the maximum number of channels. ALC260 has no mixer
3506 * element which allows changing the channel mode, so the verb list is
3509 static struct hda_channel_mode alc260_modes[1] = {
3514 /* Mixer combinations
3516 * basic: base_output + input + pc_beep + capture
3517 * HP: base_output + input + capture_alt
3518 * HP_3013: hp_3013 + input + capture
3519 * fujitsu: fujitsu + capture
3520 * acer: acer + capture
3523 static struct snd_kcontrol_new alc260_base_output_mixer[] = {
3524 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3525 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
3526 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
3527 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
3528 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
3529 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
3533 static struct snd_kcontrol_new alc260_input_mixer[] = {
3534 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3535 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
3536 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
3537 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
3538 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
3539 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
3540 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
3541 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
3545 static struct snd_kcontrol_new alc260_pc_beep_mixer[] = {
3546 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x07, 0x05, HDA_INPUT),
3547 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x07, 0x05, HDA_INPUT),
3551 static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
3552 HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
3553 HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
3554 HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
3555 HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
3556 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3557 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
3558 HDA_CODEC_VOLUME_MONO("iSpeaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
3559 HDA_CODEC_MUTE_MONO("iSpeaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
3563 /* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12,
3564 * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10.
3566 static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
3567 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3568 HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
3569 ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
3570 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3571 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
3572 HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
3573 HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
3574 ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
3575 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
3576 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
3577 HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
3578 HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x09, 2, HDA_INPUT),
3582 /* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current
3583 * versions of the ALC260 don't act on requests to enable mic bias from NID
3584 * 0x0f (used to drive the headphone jack in these laptops). The ALC260
3585 * datasheet doesn't mention this restriction. At this stage it's not clear
3586 * whether this behaviour is intentional or is a hardware bug in chip
3587 * revisions available in early 2006. Therefore for now allow the
3588 * "Headphone Jack Mode" control to span all choices, but if it turns out
3589 * that the lack of mic bias for this NID is intentional we could change the
3590 * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
3592 * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006
3593 * don't appear to make the mic bias available from the "line" jack, even
3594 * though the NID used for this jack (0x14) can supply it. The theory is
3595 * that perhaps Acer have included blocking capacitors between the ALC260
3596 * and the output jack. If this turns out to be the case for all such
3597 * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
3598 * to ALC_PIN_DIR_INOUT_NOMICBIAS.
3600 * The C20x Tablet series have a mono internal speaker which is controlled
3601 * via the chip's Mono sum widget and pin complex, so include the necessary
3602 * controls for such models. On models without a "mono speaker" the control
3603 * won't do anything.
3605 static struct snd_kcontrol_new alc260_acer_mixer[] = {
3606 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3607 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
3608 ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
3609 HDA_CODEC_VOLUME_MONO("Mono Speaker Playback Volume", 0x0a, 1, 0x0,
3611 HDA_BIND_MUTE_MONO("Mono Speaker Playback Switch", 0x0a, 1, 2,
3613 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3614 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
3615 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
3616 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
3617 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
3618 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
3619 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
3620 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
3621 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
3622 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
3626 /* Packard bell V7900 ALC260 pin usage: HP = 0x0f, Mic jack = 0x12,
3627 * Line In jack = 0x14, CD audio = 0x16, pc beep = 0x17.
3629 static struct snd_kcontrol_new alc260_will_mixer[] = {
3630 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3631 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
3632 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
3633 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
3634 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
3635 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
3636 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
3637 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
3638 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3639 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
3640 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
3641 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
3645 /* Replacer 672V ALC260 pin usage: Mic jack = 0x12,
3646 * Line In jack = 0x14, ATAPI Mic = 0x13, speaker = 0x0f.
3648 static struct snd_kcontrol_new alc260_replacer_672v_mixer[] = {
3649 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3650 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
3651 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
3652 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
3653 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
3654 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x07, 0x1, HDA_INPUT),
3655 HDA_CODEC_MUTE("ATATI Mic Playback Switch", 0x07, 0x1, HDA_INPUT),
3656 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
3657 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
3658 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
3662 /* capture mixer elements */
3663 static struct snd_kcontrol_new alc260_capture_mixer[] = {
3664 HDA_CODEC_VOLUME("Capture Volume", 0x04, 0x0, HDA_INPUT),
3665 HDA_CODEC_MUTE("Capture Switch", 0x04, 0x0, HDA_INPUT),
3666 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x05, 0x0, HDA_INPUT),
3667 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x05, 0x0, HDA_INPUT),
3669 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3670 /* The multiple "Capture Source" controls confuse alsamixer
3671 * So call somewhat different..
3672 * FIXME: the controls appear in the "playback" view!
3674 /* .name = "Capture Source", */
3675 .name = "Input Source",
3677 .info = alc_mux_enum_info,
3678 .get = alc_mux_enum_get,
3679 .put = alc_mux_enum_put,
3684 static struct snd_kcontrol_new alc260_capture_alt_mixer[] = {
3685 HDA_CODEC_VOLUME("Capture Volume", 0x05, 0x0, HDA_INPUT),
3686 HDA_CODEC_MUTE("Capture Switch", 0x05, 0x0, HDA_INPUT),
3688 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3689 /* The multiple "Capture Source" controls confuse alsamixer
3690 * So call somewhat different..
3691 * FIXME: the controls appear in the "playback" view!
3693 /* .name = "Capture Source", */
3694 .name = "Input Source",
3696 .info = alc_mux_enum_info,
3697 .get = alc_mux_enum_get,
3698 .put = alc_mux_enum_put,
3704 * initialization verbs
3706 static struct hda_verb alc260_init_verbs[] = {
3707 /* Line In pin widget for input */
3708 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3709 /* CD pin widget for input */
3710 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3711 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3712 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3713 /* Mic2 (front panel) pin widget for input and vref at 80% */
3714 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3715 /* LINE-2 is used for line-out in rear */
3716 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3717 /* select line-out */
3718 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
3720 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3722 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3724 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3725 /* mute capture amp left and right */
3726 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3727 /* set connection select to line in (default select for this ADC) */
3728 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
3729 /* mute capture amp left and right */
3730 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3731 /* set connection select to line in (default select for this ADC) */
3732 {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
3733 /* set vol=0 Line-Out mixer amp left and right */
3734 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3735 /* unmute pin widget amp left and right (no gain on this amp) */
3736 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3737 /* set vol=0 HP mixer amp left and right */
3738 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3739 /* unmute pin widget amp left and right (no gain on this amp) */
3740 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3741 /* set vol=0 Mono mixer amp left and right */
3742 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3743 /* unmute pin widget amp left and right (no gain on this amp) */
3744 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3745 /* unmute LINE-2 out pin */
3746 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3747 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
3751 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
3753 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
3755 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3756 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
3757 /* mute Front out path */
3758 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3759 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3760 /* mute Headphone out path */
3761 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3762 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3763 /* mute Mono out path */
3764 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3765 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3769 #if 0 /* should be identical with alc260_init_verbs? */
3770 static struct hda_verb alc260_hp_init_verbs[] = {
3771 /* Headphone and output */
3772 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
3774 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
3775 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3776 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
3777 /* Mic2 (front panel) pin widget for input and vref at 80% */
3778 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
3779 /* Line In pin widget for input */
3780 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
3781 /* Line-2 pin widget for output */
3782 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
3783 /* CD pin widget for input */
3784 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
3785 /* unmute amp left and right */
3786 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
3787 /* set connection select to line in (default select for this ADC) */
3788 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
3789 /* unmute Line-Out mixer amp left and right (volume = 0) */
3790 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
3791 /* mute pin widget amp left and right (no gain on this amp) */
3792 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
3793 /* unmute HP mixer amp left and right (volume = 0) */
3794 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
3795 /* mute pin widget amp left and right (no gain on this amp) */
3796 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
3797 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
3801 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
3802 /* unmute Line In */
3803 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
3805 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3806 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
3807 /* Unmute Front out path */
3808 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3809 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3810 /* Unmute Headphone out path */
3811 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3812 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3813 /* Unmute Mono out path */
3814 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3815 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3820 static struct hda_verb alc260_hp_3013_init_verbs[] = {
3821 /* Line out and output */
3822 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
3824 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
3825 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3826 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
3827 /* Mic2 (front panel) pin widget for input and vref at 80% */
3828 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
3829 /* Line In pin widget for input */
3830 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
3831 /* Headphone pin widget for output */
3832 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
3833 /* CD pin widget for input */
3834 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
3835 /* unmute amp left and right */
3836 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
3837 /* set connection select to line in (default select for this ADC) */
3838 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
3839 /* unmute Line-Out mixer amp left and right (volume = 0) */
3840 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
3841 /* mute pin widget amp left and right (no gain on this amp) */
3842 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
3843 /* unmute HP mixer amp left and right (volume = 0) */
3844 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
3845 /* mute pin widget amp left and right (no gain on this amp) */
3846 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
3847 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
3851 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
3852 /* unmute Line In */
3853 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
3855 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3856 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
3857 /* Unmute Front out path */
3858 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3859 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3860 /* Unmute Headphone out path */
3861 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3862 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3863 /* Unmute Mono out path */
3864 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3865 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3869 /* Initialisation sequence for ALC260 as configured in Fujitsu S702x
3870 * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD
3871 * audio = 0x16, internal speaker = 0x10.
3873 static struct hda_verb alc260_fujitsu_init_verbs[] = {
3874 /* Disable all GPIOs */
3875 {0x01, AC_VERB_SET_GPIO_MASK, 0},
3876 /* Internal speaker is connected to headphone pin */
3877 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3878 /* Headphone/Line-out jack connects to Line1 pin; make it an output */
3879 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3880 /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
3881 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3882 /* Ensure all other unused pins are disabled and muted. */
3883 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3884 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3885 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3886 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3887 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3888 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3889 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3890 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3892 /* Disable digital (SPDIF) pins */
3893 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
3894 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
3896 /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
3897 * when acting as an output.
3899 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
3901 /* Start with output sum widgets muted and their output gains at min */
3902 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3903 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3904 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3905 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3906 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3907 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3908 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3909 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3910 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3912 /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
3913 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3914 /* Unmute Line1 pin widget output buffer since it starts as an output.
3915 * If the pin mode is changed by the user the pin mode control will
3916 * take care of enabling the pin's input/output buffers as needed.
3917 * Therefore there's no need to enable the input buffer at this
3920 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3921 /* Unmute input buffer of pin widget used for Line-in (no equiv
3924 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3926 /* Mute capture amp left and right */
3927 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3928 /* Set ADC connection select to match default mixer setting - line
3931 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
3933 /* Do the same for the second ADC: mute capture input amp and
3934 * set ADC connection to line in (on mic1 pin)
3936 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3937 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
3939 /* Mute all inputs to mixer widget (even unconnected ones) */
3940 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
3941 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
3942 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
3943 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
3944 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
3945 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
3946 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
3947 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
3952 /* Initialisation sequence for ALC260 as configured in Acer TravelMate and
3953 * similar laptops (adapted from Fujitsu init verbs).
3955 static struct hda_verb alc260_acer_init_verbs[] = {
3956 /* On TravelMate laptops, GPIO 0 enables the internal speaker and
3957 * the headphone jack. Turn this on and rely on the standard mute
3958 * methods whenever the user wants to turn these outputs off.
3960 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
3961 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
3962 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
3963 /* Internal speaker/Headphone jack is connected to Line-out pin */
3964 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3965 /* Internal microphone/Mic jack is connected to Mic1 pin */
3966 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
3967 /* Line In jack is connected to Line1 pin */
3968 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3969 /* Some Acers (eg: C20x Tablets) use Mono pin for internal speaker */
3970 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3971 /* Ensure all other unused pins are disabled and muted. */
3972 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3973 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3974 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3975 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3976 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3977 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3978 /* Disable digital (SPDIF) pins */
3979 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
3980 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
3982 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
3983 * bus when acting as outputs.
3985 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
3986 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
3988 /* Start with output sum widgets muted and their output gains at min */
3989 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3990 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3991 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3992 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3993 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3994 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3995 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3996 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3997 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3999 /* Unmute Line-out pin widget amp left and right
4000 * (no equiv mixer ctrl)
4002 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4003 /* Unmute mono pin widget amp output (no equiv mixer ctrl) */
4004 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4005 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
4006 * inputs. If the pin mode is changed by the user the pin mode control
4007 * will take care of enabling the pin's input/output buffers as needed.
4008 * Therefore there's no need to enable the input buffer at this
4011 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4012 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4014 /* Mute capture amp left and right */
4015 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4016 /* Set ADC connection select to match default mixer setting - mic
4019 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
4021 /* Do similar with the second ADC: mute capture input amp and
4022 * set ADC connection to mic to match ALSA's default state.
4024 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4025 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
4027 /* Mute all inputs to mixer widget (even unconnected ones) */
4028 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
4029 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
4030 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
4031 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
4032 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
4033 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
4034 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
4035 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
4040 static struct hda_verb alc260_will_verbs[] = {
4041 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4042 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x00},
4043 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
4044 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
4045 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
4046 {0x1a, AC_VERB_SET_PROC_COEF, 0x3040},
4050 static struct hda_verb alc260_replacer_672v_verbs[] = {
4051 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
4052 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
4053 {0x1a, AC_VERB_SET_PROC_COEF, 0x3050},
4055 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
4056 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
4057 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
4059 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
4063 /* toggle speaker-output according to the hp-jack state */
4064 static void alc260_replacer_672v_automute(struct hda_codec *codec)
4066 unsigned int present;
4068 /* speaker --> GPIO Data 0, hp or spdif --> GPIO data 1 */
4069 present = snd_hda_codec_read(codec, 0x0f, 0,
4070 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
4072 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 1);
4073 snd_hda_codec_write(codec, 0x0f, 0,
4074 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP);
4076 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 0);
4077 snd_hda_codec_write(codec, 0x0f, 0,
4078 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
4082 static void alc260_replacer_672v_unsol_event(struct hda_codec *codec,
4085 if ((res >> 26) == ALC880_HP_EVENT)
4086 alc260_replacer_672v_automute(codec);
4089 /* Test configuration for debugging, modelled after the ALC880 test
4092 #ifdef CONFIG_SND_DEBUG
4093 static hda_nid_t alc260_test_dac_nids[1] = {
4096 static hda_nid_t alc260_test_adc_nids[2] = {
4099 /* For testing the ALC260, each input MUX needs its own definition since
4100 * the signal assignments are different. This assumes that the first ADC
4103 static struct hda_input_mux alc260_test_capture_sources[2] = {
4107 { "MIC1 pin", 0x0 },
4108 { "MIC2 pin", 0x1 },
4109 { "LINE1 pin", 0x2 },
4110 { "LINE2 pin", 0x3 },
4112 { "LINE-OUT pin", 0x5 },
4113 { "HP-OUT pin", 0x6 },
4119 { "MIC1 pin", 0x0 },
4120 { "MIC2 pin", 0x1 },
4121 { "LINE1 pin", 0x2 },
4122 { "LINE2 pin", 0x3 },
4125 { "LINE-OUT pin", 0x6 },
4126 { "HP-OUT pin", 0x7 },
4130 static struct snd_kcontrol_new alc260_test_mixer[] = {
4131 /* Output driver widgets */
4132 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
4133 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
4134 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4135 HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
4136 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4137 HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
4139 /* Modes for retasking pin widgets
4140 * Note: the ALC260 doesn't seem to act on requests to enable mic
4141 * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't
4142 * mention this restriction. At this stage it's not clear whether
4143 * this behaviour is intentional or is a hardware bug in chip
4144 * revisions available at least up until early 2006. Therefore for
4145 * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all
4146 * choices, but if it turns out that the lack of mic bias for these
4147 * NIDs is intentional we could change their modes from
4148 * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
4150 ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
4151 ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
4152 ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
4153 ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
4154 ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
4155 ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
4157 /* Loopback mixer controls */
4158 HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
4159 HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
4160 HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
4161 HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
4162 HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
4163 HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
4164 HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
4165 HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
4166 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4167 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4168 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
4169 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
4170 HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
4171 HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
4172 HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
4173 HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
4175 /* Controls for GPIO pins, assuming they are configured as outputs */
4176 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
4177 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
4178 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
4179 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
4181 /* Switches to allow the digital IO pins to be enabled. The datasheet
4182 * is ambigious as to which NID is which; testing on laptops which
4183 * make this output available should provide clarification.
4185 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
4186 ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
4190 static struct hda_verb alc260_test_init_verbs[] = {
4191 /* Enable all GPIOs as outputs with an initial value of 0 */
4192 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
4193 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
4194 {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
4196 /* Enable retasking pins as output, initially without power amp */
4197 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4198 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4199 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4200 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4201 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4202 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4204 /* Disable digital (SPDIF) pins initially, but users can enable
4205 * them via a mixer switch. In the case of SPDIF-out, this initverb
4206 * payload also sets the generation to 0, output to be in "consumer"
4207 * PCM format, copyright asserted, no pre-emphasis and no validity
4210 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
4211 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
4213 /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
4214 * OUT1 sum bus when acting as an output.
4216 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
4217 {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
4218 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
4219 {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
4221 /* Start with output sum widgets muted and their output gains at min */
4222 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4223 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4224 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4225 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4226 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4227 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4228 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4229 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4230 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4232 /* Unmute retasking pin widget output buffers since the default
4233 * state appears to be output. As the pin mode is changed by the
4234 * user the pin mode control will take care of enabling the pin's
4235 * input/output buffers as needed.
4237 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4238 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4239 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4240 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4241 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4242 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4243 /* Also unmute the mono-out pin widget */
4244 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4246 /* Mute capture amp left and right */
4247 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4248 /* Set ADC connection select to match default mixer setting (mic1
4251 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
4253 /* Do the same for the second ADC: mute capture input amp and
4254 * set ADC connection to mic1 pin
4256 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4257 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
4259 /* Mute all inputs to mixer widget (even unconnected ones) */
4260 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
4261 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
4262 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
4263 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
4264 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
4265 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
4266 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
4267 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
4273 static struct hda_pcm_stream alc260_pcm_analog_playback = {
4279 static struct hda_pcm_stream alc260_pcm_analog_capture = {
4285 #define alc260_pcm_digital_playback alc880_pcm_digital_playback
4286 #define alc260_pcm_digital_capture alc880_pcm_digital_capture
4289 * for BIOS auto-configuration
4292 static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
4296 unsigned long vol_val, sw_val;
4300 if (nid >= 0x0f && nid < 0x11) {
4301 nid_vol = nid - 0x7;
4302 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
4303 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
4304 } else if (nid == 0x11) {
4305 nid_vol = nid - 0x7;
4306 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
4307 sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
4308 } else if (nid >= 0x12 && nid <= 0x15) {
4310 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
4311 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
4315 snprintf(name, sizeof(name), "%s Playback Volume", pfx);
4316 err = add_control(spec, ALC_CTL_WIDGET_VOL, name, vol_val);
4319 snprintf(name, sizeof(name), "%s Playback Switch", pfx);
4320 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, sw_val);
4326 /* add playback controls from the parsed DAC table */
4327 static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
4328 const struct auto_pin_cfg *cfg)
4333 spec->multiout.num_dacs = 1;
4334 spec->multiout.dac_nids = spec->private_dac_nids;
4335 spec->multiout.dac_nids[0] = 0x02;
4337 nid = cfg->line_out_pins[0];
4339 err = alc260_add_playback_controls(spec, nid, "Front");
4344 nid = cfg->speaker_pins[0];
4346 err = alc260_add_playback_controls(spec, nid, "Speaker");
4351 nid = cfg->hp_pins[0];
4353 err = alc260_add_playback_controls(spec, nid, "Headphone");
4360 /* create playback/capture controls for input pins */
4361 static int alc260_auto_create_analog_input_ctls(struct alc_spec *spec,
4362 const struct auto_pin_cfg *cfg)
4364 struct hda_input_mux *imux = &spec->private_imux;
4367 for (i = 0; i < AUTO_PIN_LAST; i++) {
4368 if (cfg->input_pins[i] >= 0x12) {
4369 idx = cfg->input_pins[i] - 0x12;
4370 err = new_analog_input(spec, cfg->input_pins[i],
4371 auto_pin_cfg_labels[i], idx,
4375 imux->items[imux->num_items].label =
4376 auto_pin_cfg_labels[i];
4377 imux->items[imux->num_items].index = idx;
4380 if (cfg->input_pins[i] >= 0x0f && cfg->input_pins[i] <= 0x10){
4381 idx = cfg->input_pins[i] - 0x09;
4382 err = new_analog_input(spec, cfg->input_pins[i],
4383 auto_pin_cfg_labels[i], idx,
4387 imux->items[imux->num_items].label =
4388 auto_pin_cfg_labels[i];
4389 imux->items[imux->num_items].index = idx;
4396 static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
4397 hda_nid_t nid, int pin_type,
4401 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4403 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
4405 /* need the manual connection? */
4407 int idx = nid - 0x12;
4408 snd_hda_codec_write(codec, idx + 0x0b, 0,
4409 AC_VERB_SET_CONNECT_SEL, sel_idx);
4413 static void alc260_auto_init_multi_out(struct hda_codec *codec)
4415 struct alc_spec *spec = codec->spec;
4418 alc_subsystem_id(codec, 0x10, 0x15, 0x0f);
4419 nid = spec->autocfg.line_out_pins[0];
4421 int pin_type = get_pin_type(spec->autocfg.line_out_type);
4422 alc260_auto_set_output_and_unmute(codec, nid, pin_type, 0);
4425 nid = spec->autocfg.speaker_pins[0];
4427 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
4429 nid = spec->autocfg.hp_pins[0];
4431 alc260_auto_set_output_and_unmute(codec, nid, PIN_HP, 0);
4434 #define ALC260_PIN_CD_NID 0x16
4435 static void alc260_auto_init_analog_input(struct hda_codec *codec)
4437 struct alc_spec *spec = codec->spec;
4440 for (i = 0; i < AUTO_PIN_LAST; i++) {
4441 hda_nid_t nid = spec->autocfg.input_pins[i];
4443 snd_hda_codec_write(codec, nid, 0,
4444 AC_VERB_SET_PIN_WIDGET_CONTROL,
4445 i <= AUTO_PIN_FRONT_MIC ?
4446 PIN_VREF80 : PIN_IN);
4447 if (nid != ALC260_PIN_CD_NID)
4448 snd_hda_codec_write(codec, nid, 0,
4449 AC_VERB_SET_AMP_GAIN_MUTE,
4456 * generic initialization of ADC, input mixers and output mixers
4458 static struct hda_verb alc260_volume_init_verbs[] = {
4460 * Unmute ADC0-1 and set the default input to mic-in
4462 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
4463 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4464 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
4465 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4467 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
4469 * Note: PASD motherboards uses the Line In 2 as the input for
4470 * front panel mic (mic 2)
4472 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
4473 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4474 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4475 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
4476 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
4477 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(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);
4555 * ALC260 configurations
4557 static const char *alc260_models[ALC260_MODEL_LAST] = {
4558 [ALC260_BASIC] = "basic",
4560 [ALC260_HP_3013] = "hp-3013",
4561 [ALC260_FUJITSU_S702X] = "fujitsu",
4562 [ALC260_ACER] = "acer",
4563 [ALC260_WILL] = "will",
4564 [ALC260_REPLACER_672V] = "replacer",
4565 #ifdef CONFIG_SND_DEBUG
4566 [ALC260_TEST] = "test",
4568 [ALC260_AUTO] = "auto",
4571 static struct snd_pci_quirk alc260_cfg_tbl[] = {
4572 SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER),
4573 SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER),
4574 SND_PCI_QUIRK(0x103c, 0x2808, "HP d5700", ALC260_HP_3013),
4575 SND_PCI_QUIRK(0x103c, 0x280a, "HP d5750", ALC260_HP_3013),
4576 SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013),
4577 SND_PCI_QUIRK(0x103c, 0x3011, "HP", ALC260_HP),
4578 SND_PCI_QUIRK(0x103c, 0x3012, "HP", ALC260_HP_3013),
4579 SND_PCI_QUIRK(0x103c, 0x3013, "HP", ALC260_HP_3013),
4580 SND_PCI_QUIRK(0x103c, 0x3014, "HP", ALC260_HP),
4581 SND_PCI_QUIRK(0x103c, 0x3015, "HP", ALC260_HP),
4582 SND_PCI_QUIRK(0x103c, 0x3016, "HP", ALC260_HP),
4583 SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_BASIC),
4584 SND_PCI_QUIRK(0x104d, 0x81cc, "Sony VAIO", ALC260_BASIC),
4585 SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC),
4586 SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X),
4587 SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC),
4588 SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_WILL),
4589 SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_REPLACER_672V),
4593 static struct alc_config_preset alc260_presets[] = {
4595 .mixers = { alc260_base_output_mixer,
4597 alc260_pc_beep_mixer,
4598 alc260_capture_mixer },
4599 .init_verbs = { alc260_init_verbs },
4600 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4601 .dac_nids = alc260_dac_nids,
4602 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
4603 .adc_nids = alc260_adc_nids,
4604 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4605 .channel_mode = alc260_modes,
4606 .input_mux = &alc260_capture_source,
4609 .mixers = { alc260_base_output_mixer,
4611 alc260_capture_alt_mixer },
4612 .init_verbs = { alc260_init_verbs },
4613 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4614 .dac_nids = alc260_dac_nids,
4615 .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
4616 .adc_nids = alc260_hp_adc_nids,
4617 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4618 .channel_mode = alc260_modes,
4619 .input_mux = &alc260_capture_source,
4621 [ALC260_HP_3013] = {
4622 .mixers = { alc260_hp_3013_mixer,
4624 alc260_capture_alt_mixer },
4625 .init_verbs = { alc260_hp_3013_init_verbs },
4626 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4627 .dac_nids = alc260_dac_nids,
4628 .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
4629 .adc_nids = alc260_hp_adc_nids,
4630 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4631 .channel_mode = alc260_modes,
4632 .input_mux = &alc260_capture_source,
4634 [ALC260_FUJITSU_S702X] = {
4635 .mixers = { alc260_fujitsu_mixer,
4636 alc260_capture_mixer },
4637 .init_verbs = { alc260_fujitsu_init_verbs },
4638 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4639 .dac_nids = alc260_dac_nids,
4640 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
4641 .adc_nids = alc260_dual_adc_nids,
4642 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4643 .channel_mode = alc260_modes,
4644 .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources),
4645 .input_mux = alc260_fujitsu_capture_sources,
4648 .mixers = { alc260_acer_mixer,
4649 alc260_capture_mixer },
4650 .init_verbs = { alc260_acer_init_verbs },
4651 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4652 .dac_nids = alc260_dac_nids,
4653 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
4654 .adc_nids = alc260_dual_adc_nids,
4655 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4656 .channel_mode = alc260_modes,
4657 .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
4658 .input_mux = alc260_acer_capture_sources,
4661 .mixers = { alc260_will_mixer,
4662 alc260_capture_mixer },
4663 .init_verbs = { alc260_init_verbs, alc260_will_verbs },
4664 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4665 .dac_nids = alc260_dac_nids,
4666 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
4667 .adc_nids = alc260_adc_nids,
4668 .dig_out_nid = ALC260_DIGOUT_NID,
4669 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4670 .channel_mode = alc260_modes,
4671 .input_mux = &alc260_capture_source,
4673 [ALC260_REPLACER_672V] = {
4674 .mixers = { alc260_replacer_672v_mixer,
4675 alc260_capture_mixer },
4676 .init_verbs = { alc260_init_verbs, alc260_replacer_672v_verbs },
4677 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4678 .dac_nids = alc260_dac_nids,
4679 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
4680 .adc_nids = alc260_adc_nids,
4681 .dig_out_nid = ALC260_DIGOUT_NID,
4682 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4683 .channel_mode = alc260_modes,
4684 .input_mux = &alc260_capture_source,
4685 .unsol_event = alc260_replacer_672v_unsol_event,
4686 .init_hook = alc260_replacer_672v_automute,
4688 #ifdef CONFIG_SND_DEBUG
4690 .mixers = { alc260_test_mixer,
4691 alc260_capture_mixer },
4692 .init_verbs = { alc260_test_init_verbs },
4693 .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
4694 .dac_nids = alc260_test_dac_nids,
4695 .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
4696 .adc_nids = alc260_test_adc_nids,
4697 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4698 .channel_mode = alc260_modes,
4699 .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources),
4700 .input_mux = alc260_test_capture_sources,
4705 static int patch_alc260(struct hda_codec *codec)
4707 struct alc_spec *spec;
4708 int err, board_config;
4710 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4716 board_config = snd_hda_check_board_config(codec, ALC260_MODEL_LAST,
4719 if (board_config < 0) {
4720 snd_printd(KERN_INFO "hda_codec: Unknown model for ALC260, "
4721 "trying auto-probe from BIOS...\n");
4722 board_config = ALC260_AUTO;
4725 if (board_config == ALC260_AUTO) {
4726 /* automatic parse from the BIOS config */
4727 err = alc260_parse_auto_config(codec);
4733 "hda_codec: Cannot set up configuration "
4734 "from BIOS. Using base mode...\n");
4735 board_config = ALC260_BASIC;
4739 if (board_config != ALC260_AUTO)
4740 setup_preset(spec, &alc260_presets[board_config]);
4742 spec->stream_name_analog = "ALC260 Analog";
4743 spec->stream_analog_playback = &alc260_pcm_analog_playback;
4744 spec->stream_analog_capture = &alc260_pcm_analog_capture;
4746 spec->stream_name_digital = "ALC260 Digital";
4747 spec->stream_digital_playback = &alc260_pcm_digital_playback;
4748 spec->stream_digital_capture = &alc260_pcm_digital_capture;
4750 codec->patch_ops = alc_patch_ops;
4751 if (board_config == ALC260_AUTO)
4752 spec->init_hook = alc260_auto_init;
4761 * ALC882 is almost identical with ALC880 but has cleaner and more flexible
4762 * configuration. Each pin widget can choose any input DACs and a mixer.
4763 * Each ADC is connected from a mixer of all inputs. This makes possible
4764 * 6-channel independent captures.
4766 * In addition, an independent DAC for the multi-playback (not used in this
4769 #define ALC882_DIGOUT_NID 0x06
4770 #define ALC882_DIGIN_NID 0x0a
4772 static struct hda_channel_mode alc882_ch_modes[1] = {
4776 static hda_nid_t alc882_dac_nids[4] = {
4777 /* front, rear, clfe, rear_surr */
4778 0x02, 0x03, 0x04, 0x05
4781 /* identical with ALC880 */
4782 #define alc882_adc_nids alc880_adc_nids
4783 #define alc882_adc_nids_alt alc880_adc_nids_alt
4786 /* FIXME: should be a matrix-type input source selection */
4788 static struct hda_input_mux alc882_capture_source = {
4792 { "Front Mic", 0x1 },
4797 #define alc882_mux_enum_info alc_mux_enum_info
4798 #define alc882_mux_enum_get alc_mux_enum_get
4800 static int alc882_mux_enum_put(struct snd_kcontrol *kcontrol,
4801 struct snd_ctl_elem_value *ucontrol)
4803 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4804 struct alc_spec *spec = codec->spec;
4805 const struct hda_input_mux *imux = spec->input_mux;
4806 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
4807 static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
4808 hda_nid_t nid = capture_mixers[adc_idx];
4809 unsigned int *cur_val = &spec->cur_mux[adc_idx];
4810 unsigned int i, idx;
4812 idx = ucontrol->value.enumerated.item[0];
4813 if (idx >= imux->num_items)
4814 idx = imux->num_items - 1;
4815 if (*cur_val == idx && !codec->in_resume)
4817 for (i = 0; i < imux->num_items; i++) {
4818 unsigned int v = (i == idx) ? 0x7000 : 0x7080;
4819 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
4820 v | (imux->items[i].index << 8));
4829 static struct hda_verb alc882_3ST_ch2_init[] = {
4830 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
4831 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
4832 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
4833 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
4840 static struct hda_verb alc882_3ST_ch6_init[] = {
4841 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4842 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
4843 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
4844 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4845 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
4846 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
4850 static struct hda_channel_mode alc882_3ST_6ch_modes[2] = {
4851 { 2, alc882_3ST_ch2_init },
4852 { 6, alc882_3ST_ch6_init },
4858 static struct hda_verb alc882_sixstack_ch6_init[] = {
4859 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
4860 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4861 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4862 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4869 static struct hda_verb alc882_sixstack_ch8_init[] = {
4870 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4871 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4872 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4873 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4877 static struct hda_channel_mode alc882_sixstack_modes[2] = {
4878 { 6, alc882_sixstack_ch6_init },
4879 { 8, alc882_sixstack_ch8_init },
4882 /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
4883 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
4885 static struct snd_kcontrol_new alc882_base_mixer[] = {
4886 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
4887 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
4888 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
4889 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
4890 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
4891 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
4892 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
4893 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
4894 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
4895 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
4896 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
4897 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
4898 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
4899 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
4900 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
4901 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
4902 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
4903 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
4904 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
4905 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
4906 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
4907 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
4908 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
4912 static struct snd_kcontrol_new alc882_w2jc_mixer[] = {
4913 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
4914 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
4915 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
4916 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
4917 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
4918 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
4919 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
4920 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
4921 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
4922 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
4923 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
4927 static struct snd_kcontrol_new alc882_targa_mixer[] = {
4928 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
4929 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
4930 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
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_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
4937 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
4938 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
4942 /* Pin assignment: Front=0x14, HP = 0x15, Front = 0x16, ???
4943 * Front Mic=0x18, Line In = 0x1a, Line In = 0x1b, CD = 0x1c
4945 static struct snd_kcontrol_new alc882_asus_a7j_mixer[] = {
4946 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
4947 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
4948 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
4949 HDA_CODEC_MUTE("Mobile Front Playback Switch", 0x16, 0x0, HDA_OUTPUT),
4950 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
4951 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
4952 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
4953 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
4954 HDA_CODEC_VOLUME("Mobile Line Playback Volume", 0x0b, 0x03, HDA_INPUT),
4955 HDA_CODEC_MUTE("Mobile Line Playback Switch", 0x0b, 0x03, HDA_INPUT),
4956 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
4957 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
4961 static struct snd_kcontrol_new alc882_chmode_mixer[] = {
4963 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4964 .name = "Channel Mode",
4965 .info = alc_ch_mode_info,
4966 .get = alc_ch_mode_get,
4967 .put = alc_ch_mode_put,
4972 static struct hda_verb alc882_init_verbs[] = {
4973 /* Front mixer: unmute input/output amp left and right (volume = 0) */
4974 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4975 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4976 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4978 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4979 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4980 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4982 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4983 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4984 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4986 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4987 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4988 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4990 /* Front Pin: output 0 (0x0c) */
4991 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4992 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4993 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
4994 /* Rear Pin: output 1 (0x0d) */
4995 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4996 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4997 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
4998 /* CLFE Pin: output 2 (0x0e) */
4999 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5000 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5001 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
5002 /* Side Pin: output 3 (0x0f) */
5003 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5004 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5005 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
5006 /* Mic (rear) pin: input vref at 80% */
5007 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5008 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5009 /* Front Mic pin: input vref at 80% */
5010 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5011 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5012 /* Line In pin: input */
5013 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
5014 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5015 /* Line-2 In: Headphone output (output 0 - 0x0c) */
5016 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5017 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5018 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
5019 /* CD pin widget for input */
5020 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
5022 /* FIXME: use matrix-type input source selection */
5023 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5024 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
5025 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5026 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5027 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5028 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5030 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5031 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5032 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5033 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5035 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5036 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5037 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5038 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5039 /* ADC1: mute amp left and right */
5040 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5041 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
5042 /* ADC2: mute amp left and right */
5043 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5044 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
5045 /* ADC3: mute amp left and right */
5046 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5047 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
5052 static struct hda_verb alc882_eapd_verbs[] = {
5053 /* change to EAPD mode */
5054 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
5055 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
5060 static struct snd_kcontrol_new alc882_macpro_mixer[] = {
5061 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5062 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5063 HDA_CODEC_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT),
5064 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
5065 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
5066 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x02, HDA_INPUT),
5067 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x02, HDA_INPUT),
5071 static struct hda_verb alc882_macpro_init_verbs[] = {
5072 /* Front mixer: unmute input/output amp left and right (volume = 0) */
5073 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5074 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5075 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5076 /* Front Pin: output 0 (0x0c) */
5077 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5078 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5079 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
5080 /* Front Mic pin: input vref at 80% */
5081 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5082 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5083 /* Speaker: output */
5084 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5085 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5086 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x04},
5087 /* Headphone output (output 0 - 0x0c) */
5088 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5089 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5090 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
5092 /* FIXME: use matrix-type input source selection */
5093 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5094 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
5095 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5096 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5097 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5098 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5100 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5101 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5102 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5103 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5105 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5106 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5107 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5108 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5109 /* ADC1: mute amp left and right */
5110 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5111 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
5112 /* ADC2: mute amp left and right */
5113 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5114 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
5115 /* ADC3: mute amp left and right */
5116 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5117 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
5122 /* iMac 24 mixer. */
5123 static struct snd_kcontrol_new alc885_imac24_mixer[] = {
5124 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
5125 HDA_CODEC_MUTE("Master Playback Switch", 0x0c, 0x00, HDA_INPUT),
5129 /* iMac 24 init verbs. */
5130 static struct hda_verb alc885_imac24_init_verbs[] = {
5131 /* Internal speakers: output 0 (0x0c) */
5132 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5133 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5134 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
5135 /* Internal speakers: output 0 (0x0c) */
5136 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5137 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5138 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
5139 /* Headphone: output 0 (0x0c) */
5140 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5141 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5142 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
5143 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
5144 /* Front Mic: input vref at 80% */
5145 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5146 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5150 /* Toggle speaker-output according to the hp-jack state */
5151 static void alc885_imac24_automute(struct hda_codec *codec)
5153 unsigned int present;
5155 present = snd_hda_codec_read(codec, 0x14, 0,
5156 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
5157 snd_hda_codec_amp_update(codec, 0x18, 0, HDA_OUTPUT, 0,
5158 0x80, present ? 0x80 : 0);
5159 snd_hda_codec_amp_update(codec, 0x18, 1, HDA_OUTPUT, 0,
5160 0x80, present ? 0x80 : 0);
5161 snd_hda_codec_amp_update(codec, 0x1a, 0, HDA_OUTPUT, 0,
5162 0x80, present ? 0x80 : 0);
5163 snd_hda_codec_amp_update(codec, 0x1a, 1, HDA_OUTPUT, 0,
5164 0x80, present ? 0x80 : 0);
5167 /* Processes unsolicited events. */
5168 static void alc885_imac24_unsol_event(struct hda_codec *codec,
5171 /* Headphone insertion or removal. */
5172 if ((res >> 26) == ALC880_HP_EVENT)
5173 alc885_imac24_automute(codec);
5176 static struct hda_verb alc882_targa_verbs[] = {
5177 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5178 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5180 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5181 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5183 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
5184 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
5185 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
5187 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
5188 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
5189 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
5190 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
5194 /* toggle speaker-output according to the hp-jack state */
5195 static void alc882_targa_automute(struct hda_codec *codec)
5197 unsigned int present;
5199 present = snd_hda_codec_read(codec, 0x14, 0,
5200 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
5201 snd_hda_codec_amp_update(codec, 0x1b, 0, HDA_OUTPUT, 0,
5202 0x80, present ? 0x80 : 0);
5203 snd_hda_codec_amp_update(codec, 0x1b, 1, HDA_OUTPUT, 0,
5204 0x80, present ? 0x80 : 0);
5205 snd_hda_codec_write(codec, 1, 0, AC_VERB_SET_GPIO_DATA, present ? 1 : 3);
5208 static void alc882_targa_unsol_event(struct hda_codec *codec, unsigned int res)
5210 /* Looks like the unsol event is incompatible with the standard
5211 * definition. 4bit tag is placed at 26 bit!
5213 if (((res >> 26) == ALC880_HP_EVENT)) {
5214 alc882_targa_automute(codec);
5218 static struct hda_verb alc882_asus_a7j_verbs[] = {
5219 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5220 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5222 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5223 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5224 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5226 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
5227 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
5228 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
5230 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
5231 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
5232 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
5236 static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
5238 unsigned int gpiostate, gpiomask, gpiodir;
5240 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
5241 AC_VERB_GET_GPIO_DATA, 0);
5244 gpiostate |= (1 << pin);
5246 gpiostate &= ~(1 << pin);
5248 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
5249 AC_VERB_GET_GPIO_MASK, 0);
5250 gpiomask |= (1 << pin);
5252 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
5253 AC_VERB_GET_GPIO_DIRECTION, 0);
5254 gpiodir |= (1 << pin);
5257 snd_hda_codec_write(codec, codec->afg, 0,
5258 AC_VERB_SET_GPIO_MASK, gpiomask);
5259 snd_hda_codec_write(codec, codec->afg, 0,
5260 AC_VERB_SET_GPIO_DIRECTION, gpiodir);
5264 snd_hda_codec_write(codec, codec->afg, 0,
5265 AC_VERB_SET_GPIO_DATA, gpiostate);
5269 * generic initialization of ADC, input mixers and output mixers
5271 static struct hda_verb alc882_auto_init_verbs[] = {
5273 * Unmute ADC0-2 and set the default input to mic-in
5275 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
5276 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5277 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
5278 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5279 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
5280 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5282 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
5284 * Note: PASD motherboards uses the Line In 2 as the input for
5285 * front panel mic (mic 2)
5287 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
5288 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5289 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5290 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
5291 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
5292 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
5295 * Set up output mixers (0x0c - 0x0f)
5297 /* set vol=0 to output mixers */
5298 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5299 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5300 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5301 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5302 /* set up input amps for analog loopback */
5303 /* Amp Indices: DAC = 0, mixer = 1 */
5304 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5305 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5306 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5307 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5308 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5309 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5310 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5311 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5312 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5313 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5315 /* FIXME: use matrix-type input source selection */
5316 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5317 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
5318 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5319 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
5320 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
5321 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
5323 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5324 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
5325 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
5326 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
5328 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5329 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
5330 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
5331 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
5336 /* capture mixer elements */
5337 static struct snd_kcontrol_new alc882_capture_alt_mixer[] = {
5338 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
5339 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
5340 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
5341 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
5343 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5344 /* The multiple "Capture Source" controls confuse alsamixer
5345 * So call somewhat different..
5346 * FIXME: the controls appear in the "playback" view!
5348 /* .name = "Capture Source", */
5349 .name = "Input Source",
5351 .info = alc882_mux_enum_info,
5352 .get = alc882_mux_enum_get,
5353 .put = alc882_mux_enum_put,
5358 static struct snd_kcontrol_new alc882_capture_mixer[] = {
5359 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
5360 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
5361 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
5362 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
5363 HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
5364 HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
5366 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5367 /* The multiple "Capture Source" controls confuse alsamixer
5368 * So call somewhat different..
5369 * FIXME: the controls appear in the "playback" view!
5371 /* .name = "Capture Source", */
5372 .name = "Input Source",
5374 .info = alc882_mux_enum_info,
5375 .get = alc882_mux_enum_get,
5376 .put = alc882_mux_enum_put,
5381 /* pcm configuration: identiacal with ALC880 */
5382 #define alc882_pcm_analog_playback alc880_pcm_analog_playback
5383 #define alc882_pcm_analog_capture alc880_pcm_analog_capture
5384 #define alc882_pcm_digital_playback alc880_pcm_digital_playback
5385 #define alc882_pcm_digital_capture alc880_pcm_digital_capture
5388 * configuration and preset
5390 static const char *alc882_models[ALC882_MODEL_LAST] = {
5391 [ALC882_3ST_DIG] = "3stack-dig",
5392 [ALC882_6ST_DIG] = "6stack-dig",
5393 [ALC882_ARIMA] = "arima",
5394 [ALC882_W2JC] = "w2jc",
5395 [ALC885_MACPRO] = "macpro",
5396 [ALC885_IMAC24] = "imac24",
5397 [ALC882_AUTO] = "auto",
5400 static struct snd_pci_quirk alc882_cfg_tbl[] = {
5401 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG),
5402 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG),
5403 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG),
5404 SND_PCI_QUIRK(0x1462, 0x28fb, "Targa T8", ALC882_TARGA), /* MSI-1049 T8 */
5405 SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA),
5406 SND_PCI_QUIRK(0x1043, 0x060d, "Asus A7J", ALC882_ASUS_A7J),
5407 SND_PCI_QUIRK(0x1043, 0x817f, "Asus P5LD2", ALC882_6ST_DIG),
5408 SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG),
5409 SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_W2JC),
5413 static struct alc_config_preset alc882_presets[] = {
5414 [ALC882_3ST_DIG] = {
5415 .mixers = { alc882_base_mixer },
5416 .init_verbs = { alc882_init_verbs },
5417 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5418 .dac_nids = alc882_dac_nids,
5419 .dig_out_nid = ALC882_DIGOUT_NID,
5420 .dig_in_nid = ALC882_DIGIN_NID,
5421 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
5422 .channel_mode = alc882_ch_modes,
5424 .input_mux = &alc882_capture_source,
5426 [ALC882_6ST_DIG] = {
5427 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
5428 .init_verbs = { alc882_init_verbs },
5429 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5430 .dac_nids = alc882_dac_nids,
5431 .dig_out_nid = ALC882_DIGOUT_NID,
5432 .dig_in_nid = ALC882_DIGIN_NID,
5433 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
5434 .channel_mode = alc882_sixstack_modes,
5435 .input_mux = &alc882_capture_source,
5438 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
5439 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs },
5440 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5441 .dac_nids = alc882_dac_nids,
5442 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
5443 .channel_mode = alc882_sixstack_modes,
5444 .input_mux = &alc882_capture_source,
5447 .mixers = { alc882_w2jc_mixer, alc882_chmode_mixer },
5448 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs,
5449 alc880_gpio1_init_verbs },
5450 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5451 .dac_nids = alc882_dac_nids,
5452 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
5453 .channel_mode = alc880_threestack_modes,
5455 .input_mux = &alc882_capture_source,
5456 .dig_out_nid = ALC882_DIGOUT_NID,
5459 .mixers = { alc882_macpro_mixer },
5460 .init_verbs = { alc882_macpro_init_verbs },
5461 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5462 .dac_nids = alc882_dac_nids,
5463 .dig_out_nid = ALC882_DIGOUT_NID,
5464 .dig_in_nid = ALC882_DIGIN_NID,
5465 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
5466 .channel_mode = alc882_ch_modes,
5467 .input_mux = &alc882_capture_source,
5470 .mixers = { alc885_imac24_mixer },
5471 .init_verbs = { alc885_imac24_init_verbs },
5472 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5473 .dac_nids = alc882_dac_nids,
5474 .dig_out_nid = ALC882_DIGOUT_NID,
5475 .dig_in_nid = ALC882_DIGIN_NID,
5476 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
5477 .channel_mode = alc882_ch_modes,
5478 .input_mux = &alc882_capture_source,
5479 .unsol_event = alc885_imac24_unsol_event,
5480 .init_hook = alc885_imac24_automute,
5483 .mixers = { alc882_targa_mixer, alc882_chmode_mixer,
5484 alc882_capture_mixer },
5485 .init_verbs = { alc882_init_verbs, alc882_targa_verbs},
5486 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5487 .dac_nids = alc882_dac_nids,
5488 .dig_out_nid = ALC882_DIGOUT_NID,
5489 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
5490 .adc_nids = alc882_adc_nids,
5491 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
5492 .channel_mode = alc882_3ST_6ch_modes,
5494 .input_mux = &alc882_capture_source,
5495 .unsol_event = alc882_targa_unsol_event,
5496 .init_hook = alc882_targa_automute,
5498 [ALC882_ASUS_A7J] = {
5499 .mixers = { alc882_asus_a7j_mixer, alc882_chmode_mixer,
5500 alc882_capture_mixer },
5501 .init_verbs = { alc882_init_verbs, alc882_asus_a7j_verbs},
5502 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5503 .dac_nids = alc882_dac_nids,
5504 .dig_out_nid = ALC882_DIGOUT_NID,
5505 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
5506 .adc_nids = alc882_adc_nids,
5507 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
5508 .channel_mode = alc882_3ST_6ch_modes,
5510 .input_mux = &alc882_capture_source,
5519 PINFIX_ABIT_AW9D_MAX
5522 static struct alc_pincfg alc882_abit_aw9d_pinfix[] = {
5523 { 0x15, 0x01080104 }, /* side */
5524 { 0x16, 0x01011012 }, /* rear */
5525 { 0x17, 0x01016011 }, /* clfe */
5529 static const struct alc_pincfg *alc882_pin_fixes[] = {
5530 [PINFIX_ABIT_AW9D_MAX] = alc882_abit_aw9d_pinfix,
5533 static struct snd_pci_quirk alc882_pinfix_tbl[] = {
5534 SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", PINFIX_ABIT_AW9D_MAX),
5539 * BIOS auto configuration
5541 static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
5542 hda_nid_t nid, int pin_type,
5546 struct alc_spec *spec = codec->spec;
5549 if (spec->multiout.dac_nids[dac_idx] == 0x25)
5552 idx = spec->multiout.dac_nids[dac_idx] - 2;
5554 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5556 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
5558 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
5562 static void alc882_auto_init_multi_out(struct hda_codec *codec)
5564 struct alc_spec *spec = codec->spec;
5567 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
5568 for (i = 0; i <= HDA_SIDE; i++) {
5569 hda_nid_t nid = spec->autocfg.line_out_pins[i];
5570 int pin_type = get_pin_type(spec->autocfg.line_out_type);
5572 alc882_auto_set_output_and_unmute(codec, nid, pin_type,
5577 static void alc882_auto_init_hp_out(struct hda_codec *codec)
5579 struct alc_spec *spec = codec->spec;
5582 pin = spec->autocfg.hp_pins[0];
5583 if (pin) /* connect to front */
5585 alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
5588 #define alc882_is_input_pin(nid) alc880_is_input_pin(nid)
5589 #define ALC882_PIN_CD_NID ALC880_PIN_CD_NID
5591 static void alc882_auto_init_analog_input(struct hda_codec *codec)
5593 struct alc_spec *spec = codec->spec;
5596 for (i = 0; i < AUTO_PIN_LAST; i++) {
5597 hda_nid_t nid = spec->autocfg.input_pins[i];
5598 if (alc882_is_input_pin(nid)) {
5599 snd_hda_codec_write(codec, nid, 0,
5600 AC_VERB_SET_PIN_WIDGET_CONTROL,
5601 i <= AUTO_PIN_FRONT_MIC ?
5602 PIN_VREF80 : PIN_IN);
5603 if (nid != ALC882_PIN_CD_NID)
5604 snd_hda_codec_write(codec, nid, 0,
5605 AC_VERB_SET_AMP_GAIN_MUTE,
5611 /* almost identical with ALC880 parser... */
5612 static int alc882_parse_auto_config(struct hda_codec *codec)
5614 struct alc_spec *spec = codec->spec;
5615 int err = alc880_parse_auto_config(codec);
5620 /* hack - override the init verbs */
5621 spec->init_verbs[0] = alc882_auto_init_verbs;
5625 /* additional initialization for auto-configuration model */
5626 static void alc882_auto_init(struct hda_codec *codec)
5628 alc882_auto_init_multi_out(codec);
5629 alc882_auto_init_hp_out(codec);
5630 alc882_auto_init_analog_input(codec);
5633 static int patch_alc882(struct hda_codec *codec)
5635 struct alc_spec *spec;
5636 int err, board_config;
5638 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5644 board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST,
5648 if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
5649 /* Pick up systems that don't supply PCI SSID */
5650 switch (codec->subsystem_id) {
5651 case 0x106b0c00: /* Mac Pro */
5652 board_config = ALC885_MACPRO;
5654 case 0x106b1000: /* iMac 24 */
5655 board_config = ALC885_IMAC24;
5658 printk(KERN_INFO "hda_codec: Unknown model for ALC882, "
5659 "trying auto-probe from BIOS...\n");
5660 board_config = ALC882_AUTO;
5664 alc_fix_pincfg(codec, alc882_pinfix_tbl, alc882_pin_fixes);
5666 if (board_config == ALC882_AUTO) {
5667 /* automatic parse from the BIOS config */
5668 err = alc882_parse_auto_config(codec);
5674 "hda_codec: Cannot set up configuration "
5675 "from BIOS. Using base mode...\n");
5676 board_config = ALC882_3ST_DIG;
5680 if (board_config != ALC882_AUTO)
5681 setup_preset(spec, &alc882_presets[board_config]);
5683 if (board_config == ALC885_MACPRO || board_config == ALC885_IMAC24) {
5684 alc882_gpio_mute(codec, 0, 0);
5685 alc882_gpio_mute(codec, 1, 0);
5688 spec->stream_name_analog = "ALC882 Analog";
5689 spec->stream_analog_playback = &alc882_pcm_analog_playback;
5690 spec->stream_analog_capture = &alc882_pcm_analog_capture;
5692 spec->stream_name_digital = "ALC882 Digital";
5693 spec->stream_digital_playback = &alc882_pcm_digital_playback;
5694 spec->stream_digital_capture = &alc882_pcm_digital_capture;
5696 if (!spec->adc_nids && spec->input_mux) {
5697 /* check whether NID 0x07 is valid */
5698 unsigned int wcap = get_wcaps(codec, 0x07);
5700 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
5701 if (wcap != AC_WID_AUD_IN) {
5702 spec->adc_nids = alc882_adc_nids_alt;
5703 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids_alt);
5704 spec->mixers[spec->num_mixers] =
5705 alc882_capture_alt_mixer;
5708 spec->adc_nids = alc882_adc_nids;
5709 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids);
5710 spec->mixers[spec->num_mixers] = alc882_capture_mixer;
5715 codec->patch_ops = alc_patch_ops;
5716 if (board_config == ALC882_AUTO)
5717 spec->init_hook = alc882_auto_init;
5725 * ALC883 is almost identical with ALC880 but has cleaner and more flexible
5726 * configuration. Each pin widget can choose any input DACs and a mixer.
5727 * Each ADC is connected from a mixer of all inputs. This makes possible
5728 * 6-channel independent captures.
5730 * In addition, an independent DAC for the multi-playback (not used in this
5733 #define ALC883_DIGOUT_NID 0x06
5734 #define ALC883_DIGIN_NID 0x0a
5736 static hda_nid_t alc883_dac_nids[4] = {
5737 /* front, rear, clfe, rear_surr */
5738 0x02, 0x04, 0x03, 0x05
5741 static hda_nid_t alc883_adc_nids[2] = {
5747 /* FIXME: should be a matrix-type input source selection */
5749 static struct hda_input_mux alc883_capture_source = {
5753 { "Front Mic", 0x1 },
5759 static struct hda_input_mux alc883_lenovo_101e_capture_source = {
5767 static struct hda_input_mux alc883_lenovo_nb0763_capture_source = {
5777 #define alc883_mux_enum_info alc_mux_enum_info
5778 #define alc883_mux_enum_get alc_mux_enum_get
5780 static int alc883_mux_enum_put(struct snd_kcontrol *kcontrol,
5781 struct snd_ctl_elem_value *ucontrol)
5783 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
5784 struct alc_spec *spec = codec->spec;
5785 const struct hda_input_mux *imux = spec->input_mux;
5786 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
5787 static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
5788 hda_nid_t nid = capture_mixers[adc_idx];
5789 unsigned int *cur_val = &spec->cur_mux[adc_idx];
5790 unsigned int i, idx;
5792 idx = ucontrol->value.enumerated.item[0];
5793 if (idx >= imux->num_items)
5794 idx = imux->num_items - 1;
5795 if (*cur_val == idx && !codec->in_resume)
5797 for (i = 0; i < imux->num_items; i++) {
5798 unsigned int v = (i == idx) ? 0x7000 : 0x7080;
5799 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
5800 v | (imux->items[i].index << 8));
5809 static struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
5816 static struct hda_verb alc883_3ST_ch2_init[] = {
5817 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
5818 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
5819 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
5820 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
5827 static struct hda_verb alc883_3ST_ch6_init[] = {
5828 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5829 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
5830 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
5831 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5832 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
5833 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
5837 static struct hda_channel_mode alc883_3ST_6ch_modes[2] = {
5838 { 2, alc883_3ST_ch2_init },
5839 { 6, alc883_3ST_ch6_init },
5845 static struct hda_verb alc883_sixstack_ch6_init[] = {
5846 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
5847 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5848 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5849 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5856 static struct hda_verb alc883_sixstack_ch8_init[] = {
5857 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5858 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5859 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5860 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5864 static struct hda_channel_mode alc883_sixstack_modes[2] = {
5865 { 6, alc883_sixstack_ch6_init },
5866 { 8, alc883_sixstack_ch8_init },
5869 static struct hda_verb alc883_medion_eapd_verbs[] = {
5870 /* eanable EAPD on medion laptop */
5871 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
5872 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
5876 /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
5877 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
5880 static struct snd_kcontrol_new alc883_base_mixer[] = {
5881 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5882 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5883 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
5884 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
5885 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
5886 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
5887 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
5888 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
5889 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
5890 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
5891 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5892 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5893 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5894 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5895 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5896 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5897 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
5898 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5899 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
5900 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
5901 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
5902 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
5903 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
5904 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
5905 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
5906 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
5907 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
5909 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5910 /* .name = "Capture Source", */
5911 .name = "Input Source",
5913 .info = alc883_mux_enum_info,
5914 .get = alc883_mux_enum_get,
5915 .put = alc883_mux_enum_put,
5920 static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
5921 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5922 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5923 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5924 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5925 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5926 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5927 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5928 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5929 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
5930 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5931 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
5932 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
5933 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
5934 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
5935 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
5936 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
5937 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
5938 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
5939 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
5941 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5942 /* .name = "Capture Source", */
5943 .name = "Input Source",
5945 .info = alc883_mux_enum_info,
5946 .get = alc883_mux_enum_get,
5947 .put = alc883_mux_enum_put,
5952 static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
5953 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5954 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5955 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
5956 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
5957 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
5958 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
5959 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
5960 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
5961 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5962 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5963 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5964 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5965 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5966 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5967 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
5968 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5969 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
5970 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
5971 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
5972 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
5973 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
5974 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
5975 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
5976 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
5977 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
5979 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5980 /* .name = "Capture Source", */
5981 .name = "Input Source",
5983 .info = alc883_mux_enum_info,
5984 .get = alc883_mux_enum_get,
5985 .put = alc883_mux_enum_put,
5990 static struct snd_kcontrol_new alc883_fivestack_mixer[] = {
5991 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5992 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
5993 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
5994 HDA_CODEC_MUTE("Surround Playback Switch", 0x15, 0x0, HDA_OUTPUT),
5995 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
5996 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
5997 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x16, 1, 0x0, HDA_OUTPUT),
5998 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
5999 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6000 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6001 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6002 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6003 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6004 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6005 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6006 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6007 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6008 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
6009 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6010 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6011 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6012 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6013 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6016 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6017 /* .name = "Capture Source", */
6018 .name = "Input Source",
6020 .info = alc883_mux_enum_info,
6021 .get = alc883_mux_enum_get,
6022 .put = alc883_mux_enum_put,
6027 static struct snd_kcontrol_new alc883_tagra_mixer[] = {
6028 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6029 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6030 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6031 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
6032 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
6033 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
6034 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
6035 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
6036 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
6037 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6038 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6039 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6040 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6041 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6042 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6043 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6044 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6045 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6046 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6047 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6049 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6050 /* .name = "Capture Source", */
6051 .name = "Input Source",
6053 .info = alc883_mux_enum_info,
6054 .get = alc883_mux_enum_get,
6055 .put = alc883_mux_enum_put,
6060 static struct snd_kcontrol_new alc883_tagra_2ch_mixer[] = {
6061 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6062 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6063 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6064 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6065 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6066 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6067 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6068 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6069 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6070 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6071 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6072 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6074 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6075 /* .name = "Capture Source", */
6076 .name = "Input Source",
6078 .info = alc883_mux_enum_info,
6079 .get = alc883_mux_enum_get,
6080 .put = alc883_mux_enum_put,
6085 static struct snd_kcontrol_new alc883_lenovo_101e_2ch_mixer[] = {
6086 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6087 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6088 HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
6089 HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT),
6090 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6091 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6092 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6093 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6094 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6095 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6097 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6098 /* .name = "Capture Source", */
6099 .name = "Input Source",
6101 .info = alc883_mux_enum_info,
6102 .get = alc883_mux_enum_get,
6103 .put = alc883_mux_enum_put,
6108 static struct snd_kcontrol_new alc883_lenovo_nb0763_mixer[] = {
6109 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6110 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
6111 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6112 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6113 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6114 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6115 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6116 HDA_CODEC_VOLUME("iMic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6117 HDA_CODEC_MUTE("iMic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6118 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6119 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6120 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6121 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6123 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6124 /* .name = "Capture Source", */
6125 .name = "Input Source",
6127 .info = alc883_mux_enum_info,
6128 .get = alc883_mux_enum_get,
6129 .put = alc883_mux_enum_put,
6134 static struct snd_kcontrol_new alc883_medion_md2_mixer[] = {
6135 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6136 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6137 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
6138 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6139 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6140 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6141 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6142 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6143 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6144 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6145 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6146 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6147 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6149 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6150 /* .name = "Capture Source", */
6151 .name = "Input Source",
6153 .info = alc883_mux_enum_info,
6154 .get = alc883_mux_enum_get,
6155 .put = alc883_mux_enum_put,
6160 static struct snd_kcontrol_new alc888_6st_hp_mixer[] = {
6161 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6162 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6163 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
6164 HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
6165 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
6166 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
6167 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
6168 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
6169 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
6170 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
6171 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6172 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6173 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6174 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6175 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6176 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6177 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6178 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6179 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6180 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
6181 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6182 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6183 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6184 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6185 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6186 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6187 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6189 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6190 /* .name = "Capture Source", */
6191 .name = "Input Source",
6193 .info = alc883_mux_enum_info,
6194 .get = alc883_mux_enum_get,
6195 .put = alc883_mux_enum_put,
6200 static struct snd_kcontrol_new alc888_3st_hp_mixer[] = {
6201 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6202 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6203 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
6204 HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
6205 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
6206 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
6207 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
6208 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
6209 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6210 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6211 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6212 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6213 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6214 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6215 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6216 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6217 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6218 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
6219 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6220 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6221 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6222 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6223 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6224 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6225 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6227 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6228 /* .name = "Capture Source", */
6229 .name = "Input Source",
6231 .info = alc883_mux_enum_info,
6232 .get = alc883_mux_enum_get,
6233 .put = alc883_mux_enum_put,
6238 static struct snd_kcontrol_new alc883_chmode_mixer[] = {
6240 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6241 .name = "Channel Mode",
6242 .info = alc_ch_mode_info,
6243 .get = alc_ch_mode_get,
6244 .put = alc_ch_mode_put,
6249 static struct hda_verb alc883_init_verbs[] = {
6250 /* ADC1: mute amp left and right */
6251 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6252 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6253 /* ADC2: mute amp left and right */
6254 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6255 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
6256 /* Front mixer: unmute input/output amp left and right (volume = 0) */
6257 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6258 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6259 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6261 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6262 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6263 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6265 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6266 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6267 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6269 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6270 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6271 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6273 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6274 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6275 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
6276 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
6277 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
6279 /* Front Pin: output 0 (0x0c) */
6280 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6281 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6282 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
6283 /* Rear Pin: output 1 (0x0d) */
6284 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6285 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6286 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
6287 /* CLFE Pin: output 2 (0x0e) */
6288 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6289 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6290 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
6291 /* Side Pin: output 3 (0x0f) */
6292 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6293 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6294 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
6295 /* Mic (rear) pin: input vref at 80% */
6296 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6297 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6298 /* Front Mic pin: input vref at 80% */
6299 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6300 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6301 /* Line In pin: input */
6302 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
6303 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6304 /* Line-2 In: Headphone output (output 0 - 0x0c) */
6305 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6306 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6307 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
6308 /* CD pin widget for input */
6309 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
6311 /* FIXME: use matrix-type input source selection */
6312 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6314 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6315 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6316 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
6317 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
6319 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6320 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6321 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
6322 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
6326 static struct hda_verb alc883_tagra_verbs[] = {
6327 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6328 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6330 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6331 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6333 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
6334 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
6335 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6337 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
6338 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
6339 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
6340 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
6345 static struct hda_verb alc883_lenovo_101e_verbs[] = {
6346 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
6347 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT|AC_USRSP_EN},
6348 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT|AC_USRSP_EN},
6352 static struct hda_verb alc883_lenovo_nb0763_verbs[] = {
6353 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
6354 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6355 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
6356 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6360 static struct hda_verb alc888_lenovo_ms7195_verbs[] = {
6361 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6362 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6363 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
6364 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT | AC_USRSP_EN},
6365 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
6369 static struct hda_verb alc888_6st_hp_verbs[] = {
6370 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
6371 {0x15, AC_VERB_SET_CONNECT_SEL, 0x02}, /* Rear : output 2 (0x0e) */
6372 {0x16, AC_VERB_SET_CONNECT_SEL, 0x01}, /* CLFE : output 1 (0x0d) */
6373 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03}, /* Side : output 3 (0x0f) */
6377 static struct hda_verb alc888_3st_hp_verbs[] = {
6378 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
6379 {0x18, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Rear : output 1 (0x0d) */
6380 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02}, /* CLFE : output 2 (0x0e) */
6384 static struct hda_verb alc888_3st_hp_2ch_init[] = {
6385 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6386 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6387 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6388 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6392 static struct hda_verb alc888_3st_hp_6ch_init[] = {
6393 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6394 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6395 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6396 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6400 static struct hda_channel_mode alc888_3st_hp_modes[2] = {
6401 { 2, alc888_3st_hp_2ch_init },
6402 { 6, alc888_3st_hp_6ch_init },
6405 /* toggle front-jack and RCA according to the hp-jack state */
6406 static void alc888_lenovo_ms7195_front_automute(struct hda_codec *codec)
6408 unsigned int present;
6410 present = snd_hda_codec_read(codec, 0x1b, 0,
6411 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
6412 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
6413 0x80, present ? 0x80 : 0);
6414 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
6415 0x80, present ? 0x80 : 0);
6416 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
6417 0x80, present ? 0x80 : 0);
6418 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
6419 0x80, present ? 0x80 : 0);
6423 /* toggle RCA according to the front-jack state */
6424 static void alc888_lenovo_ms7195_rca_automute(struct hda_codec *codec)
6426 unsigned int present;
6428 present = snd_hda_codec_read(codec, 0x14, 0,
6429 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
6430 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
6431 0x80, present ? 0x80 : 0);
6432 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
6433 0x80, present ? 0x80 : 0);
6436 static void alc883_lenovo_ms7195_unsol_event(struct hda_codec *codec,
6439 if ((res >> 26) == ALC880_HP_EVENT)
6440 alc888_lenovo_ms7195_front_automute(codec);
6441 if ((res >> 26) == ALC880_FRONT_EVENT)
6442 alc888_lenovo_ms7195_rca_automute(codec);
6445 static struct hda_verb alc883_medion_md2_verbs[] = {
6446 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6447 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6449 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6451 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
6455 /* toggle speaker-output according to the hp-jack state */
6456 static void alc883_medion_md2_automute(struct hda_codec *codec)
6458 unsigned int present;
6460 present = snd_hda_codec_read(codec, 0x14, 0,
6461 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
6462 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
6463 0x80, present ? 0x80 : 0);
6464 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
6465 0x80, present ? 0x80 : 0);
6468 static void alc883_medion_md2_unsol_event(struct hda_codec *codec,
6471 if ((res >> 26) == ALC880_HP_EVENT)
6472 alc883_medion_md2_automute(codec);
6475 /* toggle speaker-output according to the hp-jack state */
6476 static void alc883_tagra_automute(struct hda_codec *codec)
6478 unsigned int present;
6481 present = snd_hda_codec_read(codec, 0x14, 0,
6482 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
6483 bits = present ? 0x80 : 0;
6484 snd_hda_codec_amp_update(codec, 0x1b, 0, HDA_OUTPUT, 0,
6486 snd_hda_codec_amp_update(codec, 0x1b, 1, HDA_OUTPUT, 0,
6488 snd_hda_codec_write(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
6492 static void alc883_tagra_unsol_event(struct hda_codec *codec, unsigned int res)
6494 if ((res >> 26) == ALC880_HP_EVENT)
6495 alc883_tagra_automute(codec);
6498 static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
6500 unsigned int present;
6503 present = snd_hda_codec_read(codec, 0x14, 0,
6504 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
6505 bits = present ? 0x80 : 0;
6506 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
6508 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
6512 static void alc883_lenovo_101e_all_automute(struct hda_codec *codec)
6514 unsigned int present;
6517 present = snd_hda_codec_read(codec, 0x1b, 0,
6518 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
6519 bits = present ? 0x80 : 0;
6520 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
6522 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
6524 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
6526 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
6530 static void alc883_lenovo_101e_unsol_event(struct hda_codec *codec,
6533 if ((res >> 26) == ALC880_HP_EVENT)
6534 alc883_lenovo_101e_all_automute(codec);
6535 if ((res >> 26) == ALC880_FRONT_EVENT)
6536 alc883_lenovo_101e_ispeaker_automute(codec);
6540 * generic initialization of ADC, input mixers and output mixers
6542 static struct hda_verb alc883_auto_init_verbs[] = {
6544 * Unmute ADC0-2 and set the default input to mic-in
6546 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6547 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6548 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
6549 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6551 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
6553 * Note: PASD motherboards uses the Line In 2 as the input for
6554 * front panel mic (mic 2)
6556 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
6557 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6558 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6559 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
6560 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
6561 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
6564 * Set up output mixers (0x0c - 0x0f)
6566 /* set vol=0 to output mixers */
6567 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6568 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6569 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6570 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6571 /* set up input amps for analog loopback */
6572 /* Amp Indices: DAC = 0, mixer = 1 */
6573 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6574 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6575 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6576 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6577 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6578 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6579 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6580 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6581 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6582 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6584 /* FIXME: use matrix-type input source selection */
6585 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6587 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6588 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6589 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
6590 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
6591 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
6593 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6594 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6595 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
6596 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
6597 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
6602 /* capture mixer elements */
6603 static struct snd_kcontrol_new alc883_capture_mixer[] = {
6604 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6605 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6606 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6607 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6609 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6610 /* The multiple "Capture Source" controls confuse alsamixer
6611 * So call somewhat different..
6612 * FIXME: the controls appear in the "playback" view!
6614 /* .name = "Capture Source", */
6615 .name = "Input Source",
6617 .info = alc882_mux_enum_info,
6618 .get = alc882_mux_enum_get,
6619 .put = alc882_mux_enum_put,
6624 /* pcm configuration: identiacal with ALC880 */
6625 #define alc883_pcm_analog_playback alc880_pcm_analog_playback
6626 #define alc883_pcm_analog_capture alc880_pcm_analog_capture
6627 #define alc883_pcm_digital_playback alc880_pcm_digital_playback
6628 #define alc883_pcm_digital_capture alc880_pcm_digital_capture
6631 * configuration and preset
6633 static const char *alc883_models[ALC883_MODEL_LAST] = {
6634 [ALC883_3ST_2ch_DIG] = "3stack-dig",
6635 [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig",
6636 [ALC883_3ST_6ch] = "3stack-6ch",
6637 [ALC883_6ST_DIG] = "6stack-dig",
6638 [ALC883_TARGA_DIG] = "targa-dig",
6639 [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig",
6640 [ALC883_ACER] = "acer",
6641 [ALC883_MEDION] = "medion",
6642 [ALC883_MEDION_MD2] = "medion-md2",
6643 [ALC883_LAPTOP_EAPD] = "laptop-eapd",
6644 [ALC883_LENOVO_101E_2ch] = "lenovo-101e",
6645 [ALC883_LENOVO_NB0763] = "lenovo-nb0763",
6646 [ALC888_LENOVO_MS7195_DIG] = "lenovo-ms7195-dig",
6647 [ALC888_6ST_HP] = "6stack-hp",
6648 [ALC888_3ST_HP] = "3stack-hp",
6649 [ALC883_AUTO] = "auto",
6652 static struct snd_pci_quirk alc883_cfg_tbl[] = {
6653 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC883_3ST_6ch_DIG),
6654 SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG),
6655 SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch),
6656 SND_PCI_QUIRK(0x1558, 0, "Clevo laptop", ALC883_LAPTOP_EAPD),
6657 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC883_6ST_DIG),
6658 SND_PCI_QUIRK(0x1458, 0xa002, "MSI", ALC883_6ST_DIG),
6659 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG),
6660 SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG),
6661 SND_PCI_QUIRK(0x1462, 0x7250, "MSI", ALC883_6ST_DIG),
6662 SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG),
6663 SND_PCI_QUIRK(0x1462, 0x7327, "MSI", ALC883_6ST_DIG),
6664 SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG),
6665 SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG),
6666 SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG),
6667 SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG),
6668 SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG),
6669 SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG),
6670 SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG),
6671 SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG),
6672 SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG),
6673 SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG),
6674 SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG),
6675 SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG),
6676 SND_PCI_QUIRK(0x1025, 0, "Acer laptop", ALC883_ACER),
6677 SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch),
6678 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
6679 SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD),
6680 SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC883_3ST_6ch),
6681 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch),
6682 SND_PCI_QUIRK(0x17aa, 0x3bfd, "Lenovo NB0763", ALC883_LENOVO_NB0763),
6683 SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763),
6684 SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC888_6ST_HP),
6685 SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_3ST_HP),
6686 SND_PCI_QUIRK(0x103c, 0x2a4f, "HP Samba", ALC888_3ST_HP),
6687 SND_PCI_QUIRK(0x17c0, 0x4071, "MEDION MD2", ALC883_MEDION_MD2),
6691 static struct alc_config_preset alc883_presets[] = {
6692 [ALC883_3ST_2ch_DIG] = {
6693 .mixers = { alc883_3ST_2ch_mixer },
6694 .init_verbs = { alc883_init_verbs },
6695 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6696 .dac_nids = alc883_dac_nids,
6697 .dig_out_nid = ALC883_DIGOUT_NID,
6698 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6699 .adc_nids = alc883_adc_nids,
6700 .dig_in_nid = ALC883_DIGIN_NID,
6701 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
6702 .channel_mode = alc883_3ST_2ch_modes,
6703 .input_mux = &alc883_capture_source,
6705 [ALC883_3ST_6ch_DIG] = {
6706 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
6707 .init_verbs = { alc883_init_verbs },
6708 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6709 .dac_nids = alc883_dac_nids,
6710 .dig_out_nid = ALC883_DIGOUT_NID,
6711 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6712 .adc_nids = alc883_adc_nids,
6713 .dig_in_nid = ALC883_DIGIN_NID,
6714 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
6715 .channel_mode = alc883_3ST_6ch_modes,
6717 .input_mux = &alc883_capture_source,
6719 [ALC883_3ST_6ch] = {
6720 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
6721 .init_verbs = { alc883_init_verbs },
6722 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6723 .dac_nids = alc883_dac_nids,
6724 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6725 .adc_nids = alc883_adc_nids,
6726 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
6727 .channel_mode = alc883_3ST_6ch_modes,
6729 .input_mux = &alc883_capture_source,
6731 [ALC883_6ST_DIG] = {
6732 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
6733 .init_verbs = { alc883_init_verbs },
6734 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6735 .dac_nids = alc883_dac_nids,
6736 .dig_out_nid = ALC883_DIGOUT_NID,
6737 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6738 .adc_nids = alc883_adc_nids,
6739 .dig_in_nid = ALC883_DIGIN_NID,
6740 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
6741 .channel_mode = alc883_sixstack_modes,
6742 .input_mux = &alc883_capture_source,
6744 [ALC883_TARGA_DIG] = {
6745 .mixers = { alc883_tagra_mixer, alc883_chmode_mixer },
6746 .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
6747 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6748 .dac_nids = alc883_dac_nids,
6749 .dig_out_nid = ALC883_DIGOUT_NID,
6750 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6751 .adc_nids = alc883_adc_nids,
6752 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
6753 .channel_mode = alc883_3ST_6ch_modes,
6755 .input_mux = &alc883_capture_source,
6756 .unsol_event = alc883_tagra_unsol_event,
6757 .init_hook = alc883_tagra_automute,
6759 [ALC883_TARGA_2ch_DIG] = {
6760 .mixers = { alc883_tagra_2ch_mixer},
6761 .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
6762 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6763 .dac_nids = alc883_dac_nids,
6764 .dig_out_nid = ALC883_DIGOUT_NID,
6765 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6766 .adc_nids = alc883_adc_nids,
6767 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
6768 .channel_mode = alc883_3ST_2ch_modes,
6769 .input_mux = &alc883_capture_source,
6770 .unsol_event = alc883_tagra_unsol_event,
6771 .init_hook = alc883_tagra_automute,
6774 .mixers = { alc883_base_mixer,
6775 alc883_chmode_mixer },
6776 /* On TravelMate laptops, GPIO 0 enables the internal speaker
6777 * and the headphone jack. Turn this on and rely on the
6778 * standard mute methods whenever the user wants to turn
6779 * these outputs off.
6781 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs },
6782 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6783 .dac_nids = alc883_dac_nids,
6784 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6785 .adc_nids = alc883_adc_nids,
6786 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
6787 .channel_mode = alc883_3ST_2ch_modes,
6788 .input_mux = &alc883_capture_source,
6791 .mixers = { alc883_fivestack_mixer,
6792 alc883_chmode_mixer },
6793 .init_verbs = { alc883_init_verbs,
6794 alc883_medion_eapd_verbs },
6795 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6796 .dac_nids = alc883_dac_nids,
6797 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6798 .adc_nids = alc883_adc_nids,
6799 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
6800 .channel_mode = alc883_sixstack_modes,
6801 .input_mux = &alc883_capture_source,
6803 [ALC883_MEDION_MD2] = {
6804 .mixers = { alc883_medion_md2_mixer},
6805 .init_verbs = { alc883_init_verbs, alc883_medion_md2_verbs},
6806 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6807 .dac_nids = alc883_dac_nids,
6808 .dig_out_nid = ALC883_DIGOUT_NID,
6809 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6810 .adc_nids = alc883_adc_nids,
6811 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
6812 .channel_mode = alc883_3ST_2ch_modes,
6813 .input_mux = &alc883_capture_source,
6814 .unsol_event = alc883_medion_md2_unsol_event,
6815 .init_hook = alc883_medion_md2_automute,
6817 [ALC883_LAPTOP_EAPD] = {
6818 .mixers = { alc883_base_mixer,
6819 alc883_chmode_mixer },
6820 .init_verbs = { alc883_init_verbs, alc882_eapd_verbs },
6821 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6822 .dac_nids = alc883_dac_nids,
6823 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6824 .adc_nids = alc883_adc_nids,
6825 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
6826 .channel_mode = alc883_3ST_2ch_modes,
6827 .input_mux = &alc883_capture_source,
6829 [ALC883_LENOVO_101E_2ch] = {
6830 .mixers = { alc883_lenovo_101e_2ch_mixer},
6831 .init_verbs = { alc883_init_verbs, alc883_lenovo_101e_verbs},
6832 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6833 .dac_nids = alc883_dac_nids,
6834 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6835 .adc_nids = alc883_adc_nids,
6836 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
6837 .channel_mode = alc883_3ST_2ch_modes,
6838 .input_mux = &alc883_lenovo_101e_capture_source,
6839 .unsol_event = alc883_lenovo_101e_unsol_event,
6840 .init_hook = alc883_lenovo_101e_all_automute,
6842 [ALC883_LENOVO_NB0763] = {
6843 .mixers = { alc883_lenovo_nb0763_mixer },
6844 .init_verbs = { alc883_init_verbs, alc883_lenovo_nb0763_verbs},
6845 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6846 .dac_nids = alc883_dac_nids,
6847 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6848 .adc_nids = alc883_adc_nids,
6849 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
6850 .channel_mode = alc883_3ST_2ch_modes,
6852 .input_mux = &alc883_lenovo_nb0763_capture_source,
6853 .unsol_event = alc883_medion_md2_unsol_event,
6854 .init_hook = alc883_medion_md2_automute,
6856 [ALC888_LENOVO_MS7195_DIG] = {
6857 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
6858 .init_verbs = { alc883_init_verbs, alc888_lenovo_ms7195_verbs},
6859 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6860 .dac_nids = alc883_dac_nids,
6861 .dig_out_nid = ALC883_DIGOUT_NID,
6862 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6863 .adc_nids = alc883_adc_nids,
6864 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
6865 .channel_mode = alc883_3ST_6ch_modes,
6867 .input_mux = &alc883_capture_source,
6868 .unsol_event = alc883_lenovo_ms7195_unsol_event,
6869 .init_hook = alc888_lenovo_ms7195_front_automute,
6872 .mixers = { alc888_6st_hp_mixer, alc883_chmode_mixer },
6873 .init_verbs = { alc883_init_verbs, alc888_6st_hp_verbs },
6874 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6875 .dac_nids = alc883_dac_nids,
6876 .dig_out_nid = ALC883_DIGOUT_NID,
6877 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6878 .adc_nids = alc883_adc_nids,
6879 .dig_in_nid = ALC883_DIGIN_NID,
6880 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
6881 .channel_mode = alc883_sixstack_modes,
6882 .input_mux = &alc883_capture_source,
6885 .mixers = { alc888_3st_hp_mixer, alc883_chmode_mixer },
6886 .init_verbs = { alc883_init_verbs, alc888_3st_hp_verbs },
6887 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6888 .dac_nids = alc883_dac_nids,
6889 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6890 .adc_nids = alc883_adc_nids,
6891 .num_channel_mode = ARRAY_SIZE(alc888_3st_hp_modes),
6892 .channel_mode = alc888_3st_hp_modes,
6894 .input_mux = &alc883_capture_source,
6900 * BIOS auto configuration
6902 static void alc883_auto_set_output_and_unmute(struct hda_codec *codec,
6903 hda_nid_t nid, int pin_type,
6907 struct alc_spec *spec = codec->spec;
6910 if (spec->multiout.dac_nids[dac_idx] == 0x25)
6913 idx = spec->multiout.dac_nids[dac_idx] - 2;
6915 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
6917 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
6919 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
6923 static void alc883_auto_init_multi_out(struct hda_codec *codec)
6925 struct alc_spec *spec = codec->spec;
6928 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
6929 for (i = 0; i <= HDA_SIDE; i++) {
6930 hda_nid_t nid = spec->autocfg.line_out_pins[i];
6931 int pin_type = get_pin_type(spec->autocfg.line_out_type);
6933 alc883_auto_set_output_and_unmute(codec, nid, pin_type,
6938 static void alc883_auto_init_hp_out(struct hda_codec *codec)
6940 struct alc_spec *spec = codec->spec;
6943 pin = spec->autocfg.hp_pins[0];
6944 if (pin) /* connect to front */
6946 alc883_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
6949 #define alc883_is_input_pin(nid) alc880_is_input_pin(nid)
6950 #define ALC883_PIN_CD_NID ALC880_PIN_CD_NID
6952 static void alc883_auto_init_analog_input(struct hda_codec *codec)
6954 struct alc_spec *spec = codec->spec;
6957 for (i = 0; i < AUTO_PIN_LAST; i++) {
6958 hda_nid_t nid = spec->autocfg.input_pins[i];
6959 if (alc883_is_input_pin(nid)) {
6960 snd_hda_codec_write(codec, nid, 0,
6961 AC_VERB_SET_PIN_WIDGET_CONTROL,
6962 (i <= AUTO_PIN_FRONT_MIC ?
6963 PIN_VREF80 : PIN_IN));
6964 if (nid != ALC883_PIN_CD_NID)
6965 snd_hda_codec_write(codec, nid, 0,
6966 AC_VERB_SET_AMP_GAIN_MUTE,
6972 /* almost identical with ALC880 parser... */
6973 static int alc883_parse_auto_config(struct hda_codec *codec)
6975 struct alc_spec *spec = codec->spec;
6976 int err = alc880_parse_auto_config(codec);
6981 /* hack - override the init verbs */
6982 spec->init_verbs[0] = alc883_auto_init_verbs;
6983 spec->mixers[spec->num_mixers] = alc883_capture_mixer;
6988 /* additional initialization for auto-configuration model */
6989 static void alc883_auto_init(struct hda_codec *codec)
6991 alc883_auto_init_multi_out(codec);
6992 alc883_auto_init_hp_out(codec);
6993 alc883_auto_init_analog_input(codec);
6996 static int patch_alc883(struct hda_codec *codec)
6998 struct alc_spec *spec;
6999 int err, board_config;
7001 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
7007 board_config = snd_hda_check_board_config(codec, ALC883_MODEL_LAST,
7010 if (board_config < 0) {
7011 printk(KERN_INFO "hda_codec: Unknown model for ALC883, "
7012 "trying auto-probe from BIOS...\n");
7013 board_config = ALC883_AUTO;
7016 if (board_config == ALC883_AUTO) {
7017 /* automatic parse from the BIOS config */
7018 err = alc883_parse_auto_config(codec);
7024 "hda_codec: Cannot set up configuration "
7025 "from BIOS. Using base mode...\n");
7026 board_config = ALC883_3ST_2ch_DIG;
7030 if (board_config != ALC883_AUTO)
7031 setup_preset(spec, &alc883_presets[board_config]);
7033 spec->stream_name_analog = "ALC883 Analog";
7034 spec->stream_analog_playback = &alc883_pcm_analog_playback;
7035 spec->stream_analog_capture = &alc883_pcm_analog_capture;
7037 spec->stream_name_digital = "ALC883 Digital";
7038 spec->stream_digital_playback = &alc883_pcm_digital_playback;
7039 spec->stream_digital_capture = &alc883_pcm_digital_capture;
7041 if (!spec->adc_nids && spec->input_mux) {
7042 spec->adc_nids = alc883_adc_nids;
7043 spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids);
7046 codec->patch_ops = alc_patch_ops;
7047 if (board_config == ALC883_AUTO)
7048 spec->init_hook = alc883_auto_init;
7057 #define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
7058 #define ALC262_DIGIN_NID ALC880_DIGIN_NID
7060 #define alc262_dac_nids alc260_dac_nids
7061 #define alc262_adc_nids alc882_adc_nids
7062 #define alc262_adc_nids_alt alc882_adc_nids_alt
7064 #define alc262_modes alc260_modes
7065 #define alc262_capture_source alc882_capture_source
7067 static struct snd_kcontrol_new alc262_base_mixer[] = {
7068 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7069 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7070 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7071 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7072 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7073 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7074 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7075 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7076 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7077 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
7078 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
7079 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
7080 /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
7081 HDA_CODEC_MUTE("PC Beelp Playback Switch", 0x0b, 0x05, HDA_INPUT), */
7082 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
7083 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7084 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7085 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
7089 static struct snd_kcontrol_new alc262_hippo1_mixer[] = {
7090 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7091 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7092 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7093 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7094 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7095 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7096 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7097 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7098 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7099 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
7100 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
7101 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
7102 /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
7103 HDA_CODEC_MUTE("PC Beelp Playback Switch", 0x0b, 0x05, HDA_INPUT), */
7104 /*HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),*/
7105 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7109 static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
7110 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7111 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7112 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7113 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7114 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
7116 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7117 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7118 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7119 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
7120 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
7121 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
7122 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7123 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7124 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7125 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7126 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
7127 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
7128 HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
7129 HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
7133 static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = {
7134 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7135 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7136 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7137 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7138 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7139 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
7140 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x02, HDA_INPUT),
7141 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x02, HDA_INPUT),
7142 HDA_CODEC_VOLUME("Front Mic Boost", 0x1a, 0, HDA_INPUT),
7143 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
7144 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
7145 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7146 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7147 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
7148 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
7152 static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = {
7153 HDA_CODEC_VOLUME("Rear Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7154 HDA_CODEC_MUTE("Rear Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7155 HDA_CODEC_VOLUME("Rear Mic Boost", 0x18, 0, HDA_INPUT),
7159 static struct snd_kcontrol_new alc262_sony_mixer[] = {
7160 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7161 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7162 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7163 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7164 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
7165 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
7169 static struct snd_kcontrol_new alc262_benq_t31_mixer[] = {
7170 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7171 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7172 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7173 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7174 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7175 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
7176 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
7180 #define alc262_capture_mixer alc882_capture_mixer
7181 #define alc262_capture_alt_mixer alc882_capture_alt_mixer
7184 * generic initialization of ADC, input mixers and output mixers
7186 static struct hda_verb alc262_init_verbs[] = {
7188 * Unmute ADC0-2 and set the default input to mic-in
7190 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7191 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7192 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7193 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7194 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7195 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7197 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
7199 * Note: PASD motherboards uses the Line In 2 as the input for
7200 * front panel mic (mic 2)
7202 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
7203 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7204 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7205 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7206 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
7207 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
7210 * Set up output mixers (0x0c - 0x0e)
7212 /* set vol=0 to output mixers */
7213 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7214 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7215 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7216 /* set up input amps for analog loopback */
7217 /* Amp Indices: DAC = 0, mixer = 1 */
7218 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7219 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7220 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7221 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7222 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7223 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7225 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
7226 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
7227 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
7228 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
7229 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
7230 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
7232 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
7233 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
7234 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
7235 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
7236 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
7238 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7239 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
7241 /* FIXME: use matrix-type input source selection */
7242 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7243 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7244 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7245 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
7246 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
7247 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
7249 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7250 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
7251 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
7252 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
7254 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7255 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
7256 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
7257 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
7262 static struct hda_verb alc262_hippo_unsol_verbs[] = {
7263 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
7264 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7268 static struct hda_verb alc262_hippo1_unsol_verbs[] = {
7269 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
7270 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
7271 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
7273 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
7274 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7278 static struct hda_verb alc262_sony_unsol_verbs[] = {
7279 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
7280 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7281 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, // Front Mic
7283 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
7284 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7287 /* mute/unmute internal speaker according to the hp jack and mute state */
7288 static void alc262_hippo_automute(struct hda_codec *codec, int force)
7290 struct alc_spec *spec = codec->spec;
7293 if (force || !spec->sense_updated) {
7294 unsigned int present;
7295 /* need to execute and sync at first */
7296 snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
7297 present = snd_hda_codec_read(codec, 0x15, 0,
7298 AC_VERB_GET_PIN_SENSE, 0);
7299 spec->jack_present = (present & 0x80000000) != 0;
7300 spec->sense_updated = 1;
7302 if (spec->jack_present) {
7303 /* mute internal speaker */
7304 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
7306 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
7309 /* unmute internal speaker if necessary */
7310 mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0);
7311 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
7313 mute = snd_hda_codec_amp_read(codec, 0x15, 1, HDA_OUTPUT, 0);
7314 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
7319 /* unsolicited event for HP jack sensing */
7320 static void alc262_hippo_unsol_event(struct hda_codec *codec,
7323 if ((res >> 26) != ALC880_HP_EVENT)
7325 alc262_hippo_automute(codec, 1);
7328 static void alc262_hippo1_automute(struct hda_codec *codec, int force)
7330 struct alc_spec *spec = codec->spec;
7333 if (force || !spec->sense_updated) {
7334 unsigned int present;
7335 /* need to execute and sync at first */
7336 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
7337 present = snd_hda_codec_read(codec, 0x1b, 0,
7338 AC_VERB_GET_PIN_SENSE, 0);
7339 spec->jack_present = (present & 0x80000000) != 0;
7340 spec->sense_updated = 1;
7342 if (spec->jack_present) {
7343 /* mute internal speaker */
7344 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
7346 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
7349 /* unmute internal speaker if necessary */
7350 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
7351 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
7353 mute = snd_hda_codec_amp_read(codec, 0x1b, 1, HDA_OUTPUT, 0);
7354 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
7359 /* unsolicited event for HP jack sensing */
7360 static void alc262_hippo1_unsol_event(struct hda_codec *codec,
7363 if ((res >> 26) != ALC880_HP_EVENT)
7365 alc262_hippo1_automute(codec, 1);
7370 * 0x14 = headphone/spdif-out, 0x15 = internal speaker
7373 #define ALC_HP_EVENT 0x37
7375 static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
7376 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
7377 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7381 static struct hda_input_mux alc262_fujitsu_capture_source = {
7389 static struct hda_input_mux alc262_HP_capture_source = {
7393 { "Front Mic", 0x3 },
7400 /* mute/unmute internal speaker according to the hp jack and mute state */
7401 static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
7403 struct alc_spec *spec = codec->spec;
7406 if (force || !spec->sense_updated) {
7407 unsigned int present;
7408 /* need to execute and sync at first */
7409 snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
7410 present = snd_hda_codec_read(codec, 0x14, 0,
7411 AC_VERB_GET_PIN_SENSE, 0);
7412 spec->jack_present = (present & 0x80000000) != 0;
7413 spec->sense_updated = 1;
7415 if (spec->jack_present) {
7416 /* mute internal speaker */
7417 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
7419 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
7422 /* unmute internal speaker if necessary */
7423 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
7424 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
7426 mute = snd_hda_codec_amp_read(codec, 0x14, 1, HDA_OUTPUT, 0);
7427 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
7432 /* unsolicited event for HP jack sensing */
7433 static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
7436 if ((res >> 26) != ALC_HP_EVENT)
7438 alc262_fujitsu_automute(codec, 1);
7441 /* bind volumes of both NID 0x0c and 0x0d */
7442 static int alc262_fujitsu_master_vol_put(struct snd_kcontrol *kcontrol,
7443 struct snd_ctl_elem_value *ucontrol)
7445 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
7446 long *valp = ucontrol->value.integer.value;
7449 change = snd_hda_codec_amp_update(codec, 0x0c, 0, HDA_OUTPUT, 0,
7450 0x7f, valp[0] & 0x7f);
7451 change |= snd_hda_codec_amp_update(codec, 0x0c, 1, HDA_OUTPUT, 0,
7452 0x7f, valp[1] & 0x7f);
7453 snd_hda_codec_amp_update(codec, 0x0d, 0, HDA_OUTPUT, 0,
7454 0x7f, valp[0] & 0x7f);
7455 snd_hda_codec_amp_update(codec, 0x0d, 1, HDA_OUTPUT, 0,
7456 0x7f, valp[1] & 0x7f);
7460 /* bind hp and internal speaker mute (with plug check) */
7461 static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
7462 struct snd_ctl_elem_value *ucontrol)
7464 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
7465 long *valp = ucontrol->value.integer.value;
7468 change = snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
7469 0x80, valp[0] ? 0 : 0x80);
7470 change |= snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
7471 0x80, valp[1] ? 0 : 0x80);
7472 if (change || codec->in_resume)
7473 alc262_fujitsu_automute(codec, codec->in_resume);
7477 static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
7479 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7480 .name = "Master Playback Volume",
7481 .info = snd_hda_mixer_amp_volume_info,
7482 .get = snd_hda_mixer_amp_volume_get,
7483 .put = alc262_fujitsu_master_vol_put,
7484 .tlv = { .c = snd_hda_mixer_amp_tlv },
7485 .private_value = HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
7488 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7489 .name = "Master Playback Switch",
7490 .info = snd_hda_mixer_amp_switch_info,
7491 .get = snd_hda_mixer_amp_switch_get,
7492 .put = alc262_fujitsu_master_sw_put,
7493 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
7495 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7496 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7497 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7498 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7499 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7503 /* additional init verbs for Benq laptops */
7504 static struct hda_verb alc262_EAPD_verbs[] = {
7505 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
7506 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
7510 static struct hda_verb alc262_benq_t31_EAPD_verbs[] = {
7511 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7512 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
7514 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
7515 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
7519 /* add playback controls from the parsed DAC table */
7520 static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec,
7521 const struct auto_pin_cfg *cfg)
7526 spec->multiout.num_dacs = 1; /* only use one dac */
7527 spec->multiout.dac_nids = spec->private_dac_nids;
7528 spec->multiout.dac_nids[0] = 2;
7530 nid = cfg->line_out_pins[0];
7532 err = add_control(spec, ALC_CTL_WIDGET_VOL,
7533 "Front Playback Volume",
7534 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT));
7537 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
7538 "Front Playback Switch",
7539 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
7544 nid = cfg->speaker_pins[0];
7547 err = add_control(spec, ALC_CTL_WIDGET_VOL,
7548 "Speaker Playback Volume",
7549 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
7553 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
7554 "Speaker Playback Switch",
7555 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
7560 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
7561 "Speaker Playback Switch",
7562 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
7568 nid = cfg->hp_pins[0];
7570 /* spec->multiout.hp_nid = 2; */
7572 err = add_control(spec, ALC_CTL_WIDGET_VOL,
7573 "Headphone Playback Volume",
7574 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
7578 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
7579 "Headphone Playback Switch",
7580 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
7585 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
7586 "Headphone Playback Switch",
7587 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
7596 /* identical with ALC880 */
7597 #define alc262_auto_create_analog_input_ctls \
7598 alc880_auto_create_analog_input_ctls
7601 * generic initialization of ADC, input mixers and output mixers
7603 static struct hda_verb alc262_volume_init_verbs[] = {
7605 * Unmute ADC0-2 and set the default input to mic-in
7607 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7608 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7609 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7610 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7611 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7612 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7614 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
7616 * Note: PASD motherboards uses the Line In 2 as the input for
7617 * front panel mic (mic 2)
7619 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
7620 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7621 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7622 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7623 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
7624 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
7627 * Set up output mixers (0x0c - 0x0f)
7629 /* set vol=0 to output mixers */
7630 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7631 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7632 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7634 /* set up input amps for analog loopback */
7635 /* Amp Indices: DAC = 0, mixer = 1 */
7636 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7637 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7638 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7639 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7640 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7641 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7643 /* FIXME: use matrix-type input source selection */
7644 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7645 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7646 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7647 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
7648 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
7649 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
7651 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7652 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
7653 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
7654 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
7656 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7657 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
7658 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
7659 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
7664 static struct hda_verb alc262_HP_BPC_init_verbs[] = {
7666 * Unmute ADC0-2 and set the default input to mic-in
7668 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7669 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7670 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7671 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7672 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7673 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7675 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
7677 * Note: PASD motherboards uses the Line In 2 as the input for
7678 * front panel mic (mic 2)
7680 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
7681 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7682 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7683 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7684 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
7685 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
7686 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
7687 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(6)},
7690 * Set up output mixers (0x0c - 0x0e)
7692 /* set vol=0 to output mixers */
7693 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7694 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7695 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7697 /* set up input amps for analog loopback */
7698 /* Amp Indices: DAC = 0, mixer = 1 */
7699 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7700 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7701 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7702 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7703 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7704 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7706 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
7707 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7708 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7710 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7711 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7713 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
7714 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7716 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
7717 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
7718 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
7719 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
7720 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
7722 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
7723 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
7724 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
7725 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
7726 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
7727 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
7730 /* FIXME: use matrix-type input source selection */
7731 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7732 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7733 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7734 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
7735 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
7736 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
7738 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7739 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
7740 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
7741 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
7743 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7744 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
7745 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
7746 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
7751 static struct hda_verb alc262_HP_BPC_WildWest_init_verbs[] = {
7753 * Unmute ADC0-2 and set the default input to mic-in
7755 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7756 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7757 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7758 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7759 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7760 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7762 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
7764 * Note: PASD motherboards uses the Line In 2 as the input for front
7767 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
7768 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7769 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7770 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7771 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
7772 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
7773 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
7774 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(6)},
7775 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(7)},
7777 * Set up output mixers (0x0c - 0x0e)
7779 /* set vol=0 to output mixers */
7780 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7781 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7782 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7784 /* set up input amps for analog loopback */
7785 /* Amp Indices: DAC = 0, mixer = 1 */
7786 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7787 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7788 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7789 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7790 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7791 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7794 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP */
7795 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Mono */
7796 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* rear MIC */
7797 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* Line in */
7798 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
7799 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Line out */
7800 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD in */
7802 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7803 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7805 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
7806 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
7808 /* {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, */
7809 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
7810 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
7811 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
7812 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
7813 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
7815 /* FIXME: use matrix-type input source selection */
7816 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7817 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7818 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, /*rear MIC*/
7819 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, /*Line in*/
7820 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, /*F MIC*/
7821 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, /*Front*/
7822 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, /*CD*/
7823 /* {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
7824 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, /*HP*/
7826 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7827 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
7828 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
7829 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
7830 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
7831 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
7832 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
7834 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7835 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
7836 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
7837 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
7838 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
7839 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
7840 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
7845 /* pcm configuration: identiacal with ALC880 */
7846 #define alc262_pcm_analog_playback alc880_pcm_analog_playback
7847 #define alc262_pcm_analog_capture alc880_pcm_analog_capture
7848 #define alc262_pcm_digital_playback alc880_pcm_digital_playback
7849 #define alc262_pcm_digital_capture alc880_pcm_digital_capture
7852 * BIOS auto configuration
7854 static int alc262_parse_auto_config(struct hda_codec *codec)
7856 struct alc_spec *spec = codec->spec;
7858 static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
7860 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
7864 if (!spec->autocfg.line_outs)
7865 return 0; /* can't find valid BIOS pin config */
7866 err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg);
7869 err = alc262_auto_create_analog_input_ctls(spec, &spec->autocfg);
7873 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
7875 if (spec->autocfg.dig_out_pin)
7876 spec->multiout.dig_out_nid = ALC262_DIGOUT_NID;
7877 if (spec->autocfg.dig_in_pin)
7878 spec->dig_in_nid = ALC262_DIGIN_NID;
7880 if (spec->kctl_alloc)
7881 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
7883 spec->init_verbs[spec->num_init_verbs++] = alc262_volume_init_verbs;
7884 spec->num_mux_defs = 1;
7885 spec->input_mux = &spec->private_imux;
7890 #define alc262_auto_init_multi_out alc882_auto_init_multi_out
7891 #define alc262_auto_init_hp_out alc882_auto_init_hp_out
7892 #define alc262_auto_init_analog_input alc882_auto_init_analog_input
7895 /* init callback for auto-configuration model -- overriding the default init */
7896 static void alc262_auto_init(struct hda_codec *codec)
7898 alc262_auto_init_multi_out(codec);
7899 alc262_auto_init_hp_out(codec);
7900 alc262_auto_init_analog_input(codec);
7904 * configuration and preset
7906 static const char *alc262_models[ALC262_MODEL_LAST] = {
7907 [ALC262_BASIC] = "basic",
7908 [ALC262_HIPPO] = "hippo",
7909 [ALC262_HIPPO_1] = "hippo_1",
7910 [ALC262_FUJITSU] = "fujitsu",
7911 [ALC262_HP_BPC] = "hp-bpc",
7912 [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000",
7913 [ALC262_BENQ_ED8] = "benq",
7914 [ALC262_BENQ_T31] = "benq-t31",
7915 [ALC262_SONY_ASSAMD] = "sony-assamd",
7916 [ALC262_AUTO] = "auto",
7919 static struct snd_pci_quirk alc262_cfg_tbl[] = {
7920 SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO),
7921 SND_PCI_QUIRK(0x103c, 0x12fe, "HP xw9400", ALC262_HP_BPC),
7922 SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC),
7923 SND_PCI_QUIRK(0x103c, 0x12ff, "HP xw4550", ALC262_HP_BPC),
7924 SND_PCI_QUIRK(0x103c, 0x1308, "HP xw4600", ALC262_HP_BPC),
7925 SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC),
7926 SND_PCI_QUIRK(0x103c, 0x1307, "HP xw6600", ALC262_HP_BPC),
7927 SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC),
7928 SND_PCI_QUIRK(0x103c, 0x1306, "HP xw8600", ALC262_HP_BPC),
7929 SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL),
7930 SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL),
7931 SND_PCI_QUIRK(0x103c, 0x2804, "HP D7000", ALC262_HP_BPC_D7000_WL),
7932 SND_PCI_QUIRK(0x103c, 0x2806, "HP D7000", ALC262_HP_BPC_D7000_WL),
7933 SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF),
7934 SND_PCI_QUIRK(0x103c, 0x2803, "HP D7000", ALC262_HP_BPC_D7000_WF),
7935 SND_PCI_QUIRK(0x103c, 0x2805, "HP D7000", ALC262_HP_BPC_D7000_WF),
7936 SND_PCI_QUIRK(0x103c, 0x2807, "HP D7000", ALC262_HP_BPC_D7000_WF),
7937 SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO),
7938 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
7939 SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1),
7940 SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
7941 SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_BENQ_T31),
7942 SND_PCI_QUIRK(0x104d, 0x9015, "Sony 0x9015", ALC262_SONY_ASSAMD),
7943 SND_PCI_QUIRK(0x104d, 0x900e, "Sony ASSAMD", ALC262_SONY_ASSAMD),
7944 SND_PCI_QUIRK(0x104d, 0x1f00, "Sony ASSAMD", ALC262_SONY_ASSAMD),
7948 static struct alc_config_preset alc262_presets[] = {
7950 .mixers = { alc262_base_mixer },
7951 .init_verbs = { alc262_init_verbs },
7952 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
7953 .dac_nids = alc262_dac_nids,
7955 .num_channel_mode = ARRAY_SIZE(alc262_modes),
7956 .channel_mode = alc262_modes,
7957 .input_mux = &alc262_capture_source,
7960 .mixers = { alc262_base_mixer },
7961 .init_verbs = { alc262_init_verbs, alc262_hippo_unsol_verbs},
7962 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
7963 .dac_nids = alc262_dac_nids,
7965 .dig_out_nid = ALC262_DIGOUT_NID,
7966 .num_channel_mode = ARRAY_SIZE(alc262_modes),
7967 .channel_mode = alc262_modes,
7968 .input_mux = &alc262_capture_source,
7969 .unsol_event = alc262_hippo_unsol_event,
7971 [ALC262_HIPPO_1] = {
7972 .mixers = { alc262_hippo1_mixer },
7973 .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs},
7974 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
7975 .dac_nids = alc262_dac_nids,
7977 .dig_out_nid = ALC262_DIGOUT_NID,
7978 .num_channel_mode = ARRAY_SIZE(alc262_modes),
7979 .channel_mode = alc262_modes,
7980 .input_mux = &alc262_capture_source,
7981 .unsol_event = alc262_hippo1_unsol_event,
7983 [ALC262_FUJITSU] = {
7984 .mixers = { alc262_fujitsu_mixer },
7985 .init_verbs = { alc262_init_verbs, alc262_fujitsu_unsol_verbs },
7986 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
7987 .dac_nids = alc262_dac_nids,
7989 .dig_out_nid = ALC262_DIGOUT_NID,
7990 .num_channel_mode = ARRAY_SIZE(alc262_modes),
7991 .channel_mode = alc262_modes,
7992 .input_mux = &alc262_fujitsu_capture_source,
7993 .unsol_event = alc262_fujitsu_unsol_event,
7996 .mixers = { alc262_HP_BPC_mixer },
7997 .init_verbs = { alc262_HP_BPC_init_verbs },
7998 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
7999 .dac_nids = alc262_dac_nids,
8001 .num_channel_mode = ARRAY_SIZE(alc262_modes),
8002 .channel_mode = alc262_modes,
8003 .input_mux = &alc262_HP_capture_source,
8005 [ALC262_HP_BPC_D7000_WF] = {
8006 .mixers = { alc262_HP_BPC_WildWest_mixer },
8007 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
8008 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
8009 .dac_nids = alc262_dac_nids,
8011 .num_channel_mode = ARRAY_SIZE(alc262_modes),
8012 .channel_mode = alc262_modes,
8013 .input_mux = &alc262_HP_capture_source,
8015 [ALC262_HP_BPC_D7000_WL] = {
8016 .mixers = { alc262_HP_BPC_WildWest_mixer,
8017 alc262_HP_BPC_WildWest_option_mixer },
8018 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
8019 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
8020 .dac_nids = alc262_dac_nids,
8022 .num_channel_mode = ARRAY_SIZE(alc262_modes),
8023 .channel_mode = alc262_modes,
8024 .input_mux = &alc262_HP_capture_source,
8026 [ALC262_BENQ_ED8] = {
8027 .mixers = { alc262_base_mixer },
8028 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
8029 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
8030 .dac_nids = alc262_dac_nids,
8032 .num_channel_mode = ARRAY_SIZE(alc262_modes),
8033 .channel_mode = alc262_modes,
8034 .input_mux = &alc262_capture_source,
8036 [ALC262_SONY_ASSAMD] = {
8037 .mixers = { alc262_sony_mixer },
8038 .init_verbs = { alc262_init_verbs, alc262_sony_unsol_verbs},
8039 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
8040 .dac_nids = alc262_dac_nids,
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,
8047 [ALC262_BENQ_T31] = {
8048 .mixers = { alc262_benq_t31_mixer },
8049 .init_verbs = { alc262_init_verbs, alc262_benq_t31_EAPD_verbs, alc262_hippo_unsol_verbs },
8050 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
8051 .dac_nids = alc262_dac_nids,
8053 .num_channel_mode = ARRAY_SIZE(alc262_modes),
8054 .channel_mode = alc262_modes,
8055 .input_mux = &alc262_capture_source,
8056 .unsol_event = alc262_hippo_unsol_event,
8060 static int patch_alc262(struct hda_codec *codec)
8062 struct alc_spec *spec;
8066 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
8072 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
8077 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
8078 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
8079 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
8080 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
8084 board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST,
8088 if (board_config < 0) {
8089 printk(KERN_INFO "hda_codec: Unknown model for ALC262, "
8090 "trying auto-probe from BIOS...\n");
8091 board_config = ALC262_AUTO;
8094 if (board_config == ALC262_AUTO) {
8095 /* automatic parse from the BIOS config */
8096 err = alc262_parse_auto_config(codec);
8102 "hda_codec: Cannot set up configuration "
8103 "from BIOS. Using base mode...\n");
8104 board_config = ALC262_BASIC;
8108 if (board_config != ALC262_AUTO)
8109 setup_preset(spec, &alc262_presets[board_config]);
8111 spec->stream_name_analog = "ALC262 Analog";
8112 spec->stream_analog_playback = &alc262_pcm_analog_playback;
8113 spec->stream_analog_capture = &alc262_pcm_analog_capture;
8115 spec->stream_name_digital = "ALC262 Digital";
8116 spec->stream_digital_playback = &alc262_pcm_digital_playback;
8117 spec->stream_digital_capture = &alc262_pcm_digital_capture;
8119 if (!spec->adc_nids && spec->input_mux) {
8120 /* check whether NID 0x07 is valid */
8121 unsigned int wcap = get_wcaps(codec, 0x07);
8124 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
8125 if (wcap != AC_WID_AUD_IN) {
8126 spec->adc_nids = alc262_adc_nids_alt;
8127 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids_alt);
8128 spec->mixers[spec->num_mixers] =
8129 alc262_capture_alt_mixer;
8132 spec->adc_nids = alc262_adc_nids;
8133 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids);
8134 spec->mixers[spec->num_mixers] = alc262_capture_mixer;
8139 codec->patch_ops = alc_patch_ops;
8140 if (board_config == ALC262_AUTO)
8141 spec->init_hook = alc262_auto_init;
8147 * ALC268 channel source setting (2 channel)
8149 #define ALC268_DIGOUT_NID ALC880_DIGOUT_NID
8150 #define alc268_modes alc260_modes
8152 static hda_nid_t alc268_dac_nids[2] = {
8157 static hda_nid_t alc268_adc_nids[2] = {
8162 static hda_nid_t alc268_adc_nids_alt[1] = {
8167 static struct snd_kcontrol_new alc268_base_mixer[] = {
8168 /* output mixer control */
8169 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
8170 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8171 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
8172 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8177 * generic initialization of ADC, input mixers and output mixers
8179 static struct hda_verb alc268_base_init_verbs[] = {
8180 /* Unmute DAC0-1 and set vol = 0 */
8181 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8182 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8183 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8184 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8185 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8186 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8189 * Set up output mixers (0x0c - 0x0e)
8191 /* set vol=0 to output mixers */
8192 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8193 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8194 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8195 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
8197 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8198 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8200 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
8201 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
8202 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
8203 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
8204 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
8205 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
8206 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
8207 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
8209 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8210 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8211 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8212 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8213 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8214 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8215 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8216 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8218 /* FIXME: use matrix-type input source selection */
8219 /* Mixer elements: 0x18, 19, 1a, 1c, 14, 15, 0b */
8220 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
8222 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8223 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
8224 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
8225 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
8227 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8228 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
8229 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
8230 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
8235 * generic initialization of ADC, input mixers and output mixers
8237 static struct hda_verb alc268_volume_init_verbs[] = {
8238 /* set output DAC */
8239 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8240 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8241 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8242 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8244 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
8245 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
8246 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
8247 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
8248 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
8250 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8251 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8252 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8253 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8254 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8256 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8257 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8258 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8259 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8261 /* set PCBEEP vol = 0 */
8262 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, (0xb000 | (0x00 << 8))},
8267 #define alc268_mux_enum_info alc_mux_enum_info
8268 #define alc268_mux_enum_get alc_mux_enum_get
8270 static int alc268_mux_enum_put(struct snd_kcontrol *kcontrol,
8271 struct snd_ctl_elem_value *ucontrol)
8273 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
8274 struct alc_spec *spec = codec->spec;
8275 const struct hda_input_mux *imux = spec->input_mux;
8276 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
8277 static hda_nid_t capture_mixers[3] = { 0x23, 0x24 };
8278 hda_nid_t nid = capture_mixers[adc_idx];
8279 unsigned int *cur_val = &spec->cur_mux[adc_idx];
8280 unsigned int i, idx;
8282 idx = ucontrol->value.enumerated.item[0];
8283 if (idx >= imux->num_items)
8284 idx = imux->num_items - 1;
8285 if (*cur_val == idx && !codec->in_resume)
8287 for (i = 0; i < imux->num_items; i++) {
8288 unsigned int v = (i == idx) ? 0x7000 : 0x7080;
8289 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
8290 v | (imux->items[i].index << 8));
8291 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL,
8298 static struct snd_kcontrol_new alc268_capture_alt_mixer[] = {
8299 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
8300 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
8302 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8303 /* The multiple "Capture Source" controls confuse alsamixer
8304 * So call somewhat different..
8305 * FIXME: the controls appear in the "playback" view!
8307 /* .name = "Capture Source", */
8308 .name = "Input Source",
8310 .info = alc268_mux_enum_info,
8311 .get = alc268_mux_enum_get,
8312 .put = alc268_mux_enum_put,
8317 static struct snd_kcontrol_new alc268_capture_mixer[] = {
8318 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
8319 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
8320 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x24, 0x0, HDA_OUTPUT),
8321 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x24, 0x0, HDA_OUTPUT),
8323 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8324 /* The multiple "Capture Source" controls confuse alsamixer
8325 * So call somewhat different..
8326 * FIXME: the controls appear in the "playback" view!
8328 /* .name = "Capture Source", */
8329 .name = "Input Source",
8331 .info = alc268_mux_enum_info,
8332 .get = alc268_mux_enum_get,
8333 .put = alc268_mux_enum_put,
8338 static struct hda_input_mux alc268_capture_source = {
8342 { "Front Mic", 0x1 },
8348 /* create input playback/capture controls for the given pin */
8349 static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
8350 const char *ctlname, int idx)
8355 sprintf(name, "%s Playback Volume", ctlname);
8357 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
8358 HDA_COMPOSE_AMP_VAL(0x02, 3, idx,
8362 } else if (nid == 0x15) {
8363 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
8364 HDA_COMPOSE_AMP_VAL(0x03, 3, idx,
8370 sprintf(name, "%s Playback Switch", ctlname);
8371 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
8372 HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
8378 /* add playback controls from the parsed DAC table */
8379 static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec,
8380 const struct auto_pin_cfg *cfg)
8385 spec->multiout.num_dacs = 2; /* only use one dac */
8386 spec->multiout.dac_nids = spec->private_dac_nids;
8387 spec->multiout.dac_nids[0] = 2;
8388 spec->multiout.dac_nids[1] = 3;
8390 nid = cfg->line_out_pins[0];
8392 alc268_new_analog_output(spec, nid, "Front", 0);
8394 nid = cfg->speaker_pins[0];
8396 err = add_control(spec, ALC_CTL_WIDGET_VOL,
8397 "Speaker Playback Volume",
8398 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
8402 nid = cfg->hp_pins[0];
8404 alc268_new_analog_output(spec, nid, "Headphone", 0);
8406 nid = cfg->line_out_pins[1] | cfg->line_out_pins[2];
8408 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
8409 "Mono Playback Switch",
8410 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_INPUT));
8417 /* create playback/capture controls for input pins */
8418 static int alc268_auto_create_analog_input_ctls(struct alc_spec *spec,
8419 const struct auto_pin_cfg *cfg)
8421 struct hda_input_mux *imux = &spec->private_imux;
8424 for (i = 0; i < AUTO_PIN_LAST; i++) {
8425 switch(cfg->input_pins[i]) {
8427 idx1 = 0; /* Mic 1 */
8430 idx1 = 1; /* Mic 2 */
8433 idx1 = 2; /* Line In */
8441 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
8442 imux->items[imux->num_items].index = idx1;
8448 static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec)
8450 struct alc_spec *spec = codec->spec;
8451 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
8452 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
8453 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
8454 unsigned int dac_vol1, dac_vol2;
8457 snd_hda_codec_write(codec, speaker_nid, 0,
8458 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
8459 snd_hda_codec_write(codec, 0x0f, 0,
8460 AC_VERB_SET_AMP_GAIN_MUTE,
8462 snd_hda_codec_write(codec, 0x10, 0,
8463 AC_VERB_SET_AMP_GAIN_MUTE,
8466 snd_hda_codec_write(codec, 0x0f, 0,
8467 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
8468 snd_hda_codec_write(codec, 0x10, 0,
8469 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
8472 dac_vol1 = dac_vol2 = 0xb000 | 0x40; /* set max volume */
8473 if (line_nid == 0x14)
8474 dac_vol2 = AMP_OUT_ZERO;
8475 else if (line_nid == 0x15)
8476 dac_vol1 = AMP_OUT_ZERO;
8478 dac_vol2 = AMP_OUT_ZERO;
8479 else if (hp_nid == 0x15)
8480 dac_vol1 = AMP_OUT_ZERO;
8481 if (line_nid != 0x16 || hp_nid != 0x16 ||
8482 spec->autocfg.line_out_pins[1] != 0x16 ||
8483 spec->autocfg.line_out_pins[2] != 0x16)
8484 dac_vol1 = dac_vol2 = AMP_OUT_ZERO;
8486 snd_hda_codec_write(codec, 0x02, 0,
8487 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol1);
8488 snd_hda_codec_write(codec, 0x03, 0,
8489 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol2);
8492 /* pcm configuration: identiacal with ALC880 */
8493 #define alc268_pcm_analog_playback alc880_pcm_analog_playback
8494 #define alc268_pcm_analog_capture alc880_pcm_analog_capture
8495 #define alc268_pcm_digital_playback alc880_pcm_digital_playback
8498 * BIOS auto configuration
8500 static int alc268_parse_auto_config(struct hda_codec *codec)
8502 struct alc_spec *spec = codec->spec;
8504 static hda_nid_t alc268_ignore[] = { 0 };
8506 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
8510 if (!spec->autocfg.line_outs)
8511 return 0; /* can't find valid BIOS pin config */
8513 err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg);
8516 err = alc268_auto_create_analog_input_ctls(spec, &spec->autocfg);
8520 spec->multiout.max_channels = 2;
8522 /* digital only support output */
8523 if (spec->autocfg.dig_out_pin)
8524 spec->multiout.dig_out_nid = ALC268_DIGOUT_NID;
8526 if (spec->kctl_alloc)
8527 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
8529 spec->init_verbs[spec->num_init_verbs++] = alc268_volume_init_verbs;
8530 spec->num_mux_defs = 1;
8531 spec->input_mux = &spec->private_imux;
8536 #define alc268_auto_init_multi_out alc882_auto_init_multi_out
8537 #define alc268_auto_init_hp_out alc882_auto_init_hp_out
8538 #define alc268_auto_init_analog_input alc882_auto_init_analog_input
8540 /* init callback for auto-configuration model -- overriding the default init */
8541 static void alc268_auto_init(struct hda_codec *codec)
8543 alc268_auto_init_multi_out(codec);
8544 alc268_auto_init_hp_out(codec);
8545 alc268_auto_init_mono_speaker_out(codec);
8546 alc268_auto_init_analog_input(codec);
8550 * configuration and preset
8552 static const char *alc268_models[ALC268_MODEL_LAST] = {
8553 [ALC268_3ST] = "3stack",
8554 [ALC268_AUTO] = "auto",
8557 static struct snd_pci_quirk alc268_cfg_tbl[] = {
8558 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST),
8562 static struct alc_config_preset alc268_presets[] = {
8564 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer },
8565 .init_verbs = { alc268_base_init_verbs },
8566 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
8567 .dac_nids = alc268_dac_nids,
8568 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
8569 .adc_nids = alc268_adc_nids_alt,
8571 .dig_out_nid = ALC268_DIGOUT_NID,
8572 .num_channel_mode = ARRAY_SIZE(alc268_modes),
8573 .channel_mode = alc268_modes,
8574 .input_mux = &alc268_capture_source,
8578 static int patch_alc268(struct hda_codec *codec)
8580 struct alc_spec *spec;
8584 spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
8590 board_config = snd_hda_check_board_config(codec, ALC268_MODEL_LAST,
8594 if (board_config < 0 || board_config >= ALC268_MODEL_LAST) {
8595 printk(KERN_INFO "hda_codec: Unknown model for ALC268, "
8596 "trying auto-probe from BIOS...\n");
8597 board_config = ALC268_AUTO;
8600 if (board_config == ALC268_AUTO) {
8601 /* automatic parse from the BIOS config */
8602 err = alc268_parse_auto_config(codec);
8608 "hda_codec: Cannot set up configuration "
8609 "from BIOS. Using base mode...\n");
8610 board_config = ALC268_3ST;
8614 if (board_config != ALC268_AUTO)
8615 setup_preset(spec, &alc268_presets[board_config]);
8617 spec->stream_name_analog = "ALC268 Analog";
8618 spec->stream_analog_playback = &alc268_pcm_analog_playback;
8619 spec->stream_analog_capture = &alc268_pcm_analog_capture;
8621 spec->stream_name_digital = "ALC268 Digital";
8622 spec->stream_digital_playback = &alc268_pcm_digital_playback;
8624 if (board_config == ALC268_AUTO) {
8625 if (!spec->adc_nids && spec->input_mux) {
8626 /* check whether NID 0x07 is valid */
8627 unsigned int wcap = get_wcaps(codec, 0x07);
8630 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
8631 if (wcap != AC_WID_AUD_IN) {
8632 spec->adc_nids = alc268_adc_nids_alt;
8633 spec->num_adc_nids =
8634 ARRAY_SIZE(alc268_adc_nids_alt);
8635 spec->mixers[spec->num_mixers] =
8636 alc268_capture_alt_mixer;
8639 spec->adc_nids = alc268_adc_nids;
8640 spec->num_adc_nids =
8641 ARRAY_SIZE(alc268_adc_nids);
8642 spec->mixers[spec->num_mixers] =
8643 alc268_capture_mixer;
8648 codec->patch_ops = alc_patch_ops;
8649 if (board_config == ALC268_AUTO)
8650 spec->init_hook = alc268_auto_init;
8656 * ALC861 channel source setting (2/6 channel selection for 3-stack)
8660 * set the path ways for 2 channel output
8661 * need to set the codec line out and mic 1 pin widgets to inputs
8663 static struct hda_verb alc861_threestack_ch2_init[] = {
8664 /* set pin widget 1Ah (line in) for input */
8665 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
8666 /* set pin widget 18h (mic1/2) for input, for mic also enable
8669 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
8671 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
8673 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
8674 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
8680 * need to set the codec line out and mic 1 pin widgets to outputs
8682 static struct hda_verb alc861_threestack_ch6_init[] = {
8683 /* set pin widget 1Ah (line in) for output (Back Surround)*/
8684 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
8685 /* set pin widget 18h (mic1) for output (CLFE)*/
8686 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
8688 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
8689 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
8691 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
8693 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
8694 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
8699 static struct hda_channel_mode alc861_threestack_modes[2] = {
8700 { 2, alc861_threestack_ch2_init },
8701 { 6, alc861_threestack_ch6_init },
8703 /* Set mic1 as input and unmute the mixer */
8704 static struct hda_verb alc861_uniwill_m31_ch2_init[] = {
8705 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
8706 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
8709 /* Set mic1 as output and mute mixer */
8710 static struct hda_verb alc861_uniwill_m31_ch4_init[] = {
8711 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
8712 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
8716 static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
8717 { 2, alc861_uniwill_m31_ch2_init },
8718 { 4, alc861_uniwill_m31_ch4_init },
8721 /* Set mic1 and line-in as input and unmute the mixer */
8722 static struct hda_verb alc861_asus_ch2_init[] = {
8723 /* set pin widget 1Ah (line in) for input */
8724 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
8725 /* set pin widget 18h (mic1/2) for input, for mic also enable
8728 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
8730 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
8732 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
8733 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
8737 /* Set mic1 nad line-in as output and mute mixer */
8738 static struct hda_verb alc861_asus_ch6_init[] = {
8739 /* set pin widget 1Ah (line in) for output (Back Surround)*/
8740 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
8741 /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
8742 /* set pin widget 18h (mic1) for output (CLFE)*/
8743 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
8744 /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
8745 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
8746 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
8748 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
8750 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
8751 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
8756 static struct hda_channel_mode alc861_asus_modes[2] = {
8757 { 2, alc861_asus_ch2_init },
8758 { 6, alc861_asus_ch6_init },
8763 static struct snd_kcontrol_new alc861_base_mixer[] = {
8764 /* output mixer control */
8765 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
8766 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
8767 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
8768 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
8769 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
8771 /*Input mixer control */
8772 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
8773 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
8774 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
8775 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
8776 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
8777 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
8778 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
8779 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
8780 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
8781 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
8783 /* Capture mixer control */
8784 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
8785 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
8787 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8788 .name = "Capture Source",
8790 .info = alc_mux_enum_info,
8791 .get = alc_mux_enum_get,
8792 .put = alc_mux_enum_put,
8797 static struct snd_kcontrol_new alc861_3ST_mixer[] = {
8798 /* output mixer control */
8799 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
8800 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
8801 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
8802 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
8803 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
8805 /* Input mixer control */
8806 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
8807 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
8808 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
8809 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
8810 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
8811 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
8812 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
8813 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
8814 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
8815 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
8817 /* Capture mixer control */
8818 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
8819 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
8821 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8822 .name = "Capture Source",
8824 .info = alc_mux_enum_info,
8825 .get = alc_mux_enum_get,
8826 .put = alc_mux_enum_put,
8829 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8830 .name = "Channel Mode",
8831 .info = alc_ch_mode_info,
8832 .get = alc_ch_mode_get,
8833 .put = alc_ch_mode_put,
8834 .private_value = ARRAY_SIZE(alc861_threestack_modes),
8839 static struct snd_kcontrol_new alc861_toshiba_mixer[] = {
8840 /* output mixer control */
8841 HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT),
8842 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
8843 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
8845 /*Capture mixer control */
8846 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
8847 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
8849 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8850 .name = "Capture Source",
8852 .info = alc_mux_enum_info,
8853 .get = alc_mux_enum_get,
8854 .put = alc_mux_enum_put,
8860 static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
8861 /* output mixer control */
8862 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
8863 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
8864 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
8865 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
8866 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
8868 /* Input mixer control */
8869 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
8870 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
8871 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
8872 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
8873 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
8874 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
8875 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
8876 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
8877 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
8878 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
8880 /* Capture mixer control */
8881 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
8882 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
8884 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8885 .name = "Capture Source",
8887 .info = alc_mux_enum_info,
8888 .get = alc_mux_enum_get,
8889 .put = alc_mux_enum_put,
8892 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8893 .name = "Channel Mode",
8894 .info = alc_ch_mode_info,
8895 .get = alc_ch_mode_get,
8896 .put = alc_ch_mode_put,
8897 .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
8902 static struct snd_kcontrol_new alc861_asus_mixer[] = {
8903 /* output mixer control */
8904 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
8905 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
8906 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
8907 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
8908 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
8910 /* Input mixer control */
8911 HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
8912 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8913 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
8914 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
8915 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
8916 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
8917 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
8918 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
8919 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
8920 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT),
8922 /* Capture mixer control */
8923 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
8924 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
8926 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8927 .name = "Capture Source",
8929 .info = alc_mux_enum_info,
8930 .get = alc_mux_enum_get,
8931 .put = alc_mux_enum_put,
8934 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8935 .name = "Channel Mode",
8936 .info = alc_ch_mode_info,
8937 .get = alc_ch_mode_get,
8938 .put = alc_ch_mode_put,
8939 .private_value = ARRAY_SIZE(alc861_asus_modes),
8944 /* additional mixer */
8945 static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = {
8946 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
8947 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
8948 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x23, 0x0, HDA_OUTPUT),
8949 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x23, 0x0, HDA_OUTPUT),
8954 * generic initialization of ADC, input mixers and output mixers
8956 static struct hda_verb alc861_base_init_verbs[] = {
8958 * Unmute ADC0 and set the default input to mic-in
8960 /* port-A for surround (rear panel) */
8961 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
8962 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
8963 /* port-B for mic-in (rear panel) with vref */
8964 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
8965 /* port-C for line-in (rear panel) */
8966 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
8967 /* port-D for Front */
8968 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
8969 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
8970 /* port-E for HP out (front panel) */
8971 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
8972 /* route front PCM to HP */
8973 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
8974 /* port-F for mic-in (front panel) with vref */
8975 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
8976 /* port-G for CLFE (rear panel) */
8977 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
8978 { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
8979 /* port-H for side (rear panel) */
8980 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
8981 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
8983 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
8984 /* route front mic to ADC1*/
8985 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8986 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8988 /* Unmute DAC0~3 & spdif out*/
8989 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8990 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8991 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8992 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8993 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8995 /* Unmute Mixer 14 (mic) 1c (Line in)*/
8996 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8997 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8998 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8999 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9001 /* Unmute Stereo Mixer 15 */
9002 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9003 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9004 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
9005 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
9007 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9008 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9009 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9010 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9011 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9012 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9013 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9014 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9015 /* hp used DAC 3 (Front) */
9016 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
9017 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
9022 static struct hda_verb alc861_threestack_init_verbs[] = {
9024 * Unmute ADC0 and set the default input to mic-in
9026 /* port-A for surround (rear panel) */
9027 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
9028 /* port-B for mic-in (rear panel) with vref */
9029 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
9030 /* port-C for line-in (rear panel) */
9031 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
9032 /* port-D for Front */
9033 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
9034 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
9035 /* port-E for HP out (front panel) */
9036 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
9037 /* route front PCM to HP */
9038 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
9039 /* port-F for mic-in (front panel) with vref */
9040 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
9041 /* port-G for CLFE (rear panel) */
9042 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
9043 /* port-H for side (rear panel) */
9044 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
9046 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
9047 /* route front mic to ADC1*/
9048 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
9049 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9050 /* Unmute DAC0~3 & spdif out*/
9051 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9052 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9053 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9054 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9055 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9057 /* Unmute Mixer 14 (mic) 1c (Line in)*/
9058 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9059 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9060 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9061 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9063 /* Unmute Stereo Mixer 15 */
9064 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9065 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9066 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
9067 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
9069 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9070 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9071 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9072 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9073 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9074 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9075 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9076 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9077 /* hp used DAC 3 (Front) */
9078 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
9079 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
9083 static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
9085 * Unmute ADC0 and set the default input to mic-in
9087 /* port-A for surround (rear panel) */
9088 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
9089 /* port-B for mic-in (rear panel) with vref */
9090 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
9091 /* port-C for line-in (rear panel) */
9092 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
9093 /* port-D for Front */
9094 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
9095 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
9096 /* port-E for HP out (front panel) */
9097 /* this has to be set to VREF80 */
9098 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
9099 /* route front PCM to HP */
9100 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
9101 /* port-F for mic-in (front panel) with vref */
9102 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
9103 /* port-G for CLFE (rear panel) */
9104 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
9105 /* port-H for side (rear panel) */
9106 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
9108 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
9109 /* route front mic to ADC1*/
9110 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
9111 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9112 /* Unmute DAC0~3 & spdif out*/
9113 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9114 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9115 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9116 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9117 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9119 /* Unmute Mixer 14 (mic) 1c (Line in)*/
9120 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9121 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9122 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9123 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9125 /* Unmute Stereo Mixer 15 */
9126 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9127 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9128 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
9129 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
9131 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9132 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9133 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9134 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9135 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9136 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9137 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9138 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9139 /* hp used DAC 3 (Front) */
9140 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
9141 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
9145 static struct hda_verb alc861_asus_init_verbs[] = {
9147 * Unmute ADC0 and set the default input to mic-in
9149 /* port-A for surround (rear panel)
9150 * according to codec#0 this is the HP jack
9152 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */
9153 /* route front PCM to HP */
9154 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 },
9155 /* port-B for mic-in (rear panel) with vref */
9156 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
9157 /* port-C for line-in (rear panel) */
9158 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
9159 /* port-D for Front */
9160 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
9161 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
9162 /* port-E for HP out (front panel) */
9163 /* this has to be set to VREF80 */
9164 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
9165 /* route front PCM to HP */
9166 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
9167 /* port-F for mic-in (front panel) with vref */
9168 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
9169 /* port-G for CLFE (rear panel) */
9170 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
9171 /* port-H for side (rear panel) */
9172 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
9174 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
9175 /* route front mic to ADC1*/
9176 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
9177 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9178 /* Unmute DAC0~3 & spdif out*/
9179 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9180 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9181 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9182 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9183 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9184 /* Unmute Mixer 14 (mic) 1c (Line in)*/
9185 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9186 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9187 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9188 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9190 /* Unmute Stereo Mixer 15 */
9191 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9192 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9193 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
9194 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
9196 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9197 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9198 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9199 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9200 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9201 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9202 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9203 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9204 /* hp used DAC 3 (Front) */
9205 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
9206 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
9210 /* additional init verbs for ASUS laptops */
9211 static struct hda_verb alc861_asus_laptop_init_verbs[] = {
9212 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */
9213 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */
9218 * generic initialization of ADC, input mixers and output mixers
9220 static struct hda_verb alc861_auto_init_verbs[] = {
9222 * Unmute ADC0 and set the default input to mic-in
9224 /* {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, */
9225 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9227 /* Unmute DAC0~3 & spdif out*/
9228 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9229 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9230 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9231 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9232 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9234 /* Unmute Mixer 14 (mic) 1c (Line in)*/
9235 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9236 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9237 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9238 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9240 /* Unmute Stereo Mixer 15 */
9241 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9242 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9243 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
9244 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
9246 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9247 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9248 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9249 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9250 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9251 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9252 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9253 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9255 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9256 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9257 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
9258 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
9259 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9260 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9261 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
9262 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
9264 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */
9269 static struct hda_verb alc861_toshiba_init_verbs[] = {
9270 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9275 /* toggle speaker-output according to the hp-jack state */
9276 static void alc861_toshiba_automute(struct hda_codec *codec)
9278 unsigned int present;
9280 present = snd_hda_codec_read(codec, 0x0f, 0,
9281 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
9282 snd_hda_codec_amp_update(codec, 0x16, 0, HDA_INPUT, 0,
9283 0x80, present ? 0x80 : 0);
9284 snd_hda_codec_amp_update(codec, 0x16, 1, HDA_INPUT, 0,
9285 0x80, present ? 0x80 : 0);
9286 snd_hda_codec_amp_update(codec, 0x1a, 0, HDA_INPUT, 3,
9287 0x80, present ? 0 : 0x80);
9288 snd_hda_codec_amp_update(codec, 0x1a, 1, HDA_INPUT, 3,
9289 0x80, present ? 0 : 0x80);
9292 static void alc861_toshiba_unsol_event(struct hda_codec *codec,
9295 if ((res >> 26) == ALC880_HP_EVENT)
9296 alc861_toshiba_automute(codec);
9299 /* pcm configuration: identiacal with ALC880 */
9300 #define alc861_pcm_analog_playback alc880_pcm_analog_playback
9301 #define alc861_pcm_analog_capture alc880_pcm_analog_capture
9302 #define alc861_pcm_digital_playback alc880_pcm_digital_playback
9303 #define alc861_pcm_digital_capture alc880_pcm_digital_capture
9306 #define ALC861_DIGOUT_NID 0x07
9308 static struct hda_channel_mode alc861_8ch_modes[1] = {
9312 static hda_nid_t alc861_dac_nids[4] = {
9313 /* front, surround, clfe, side */
9314 0x03, 0x06, 0x05, 0x04
9317 static hda_nid_t alc660_dac_nids[3] = {
9318 /* front, clfe, surround */
9322 static hda_nid_t alc861_adc_nids[1] = {
9327 static struct hda_input_mux alc861_capture_source = {
9331 { "Front Mic", 0x3 },
9338 /* fill in the dac_nids table from the parsed pin configuration */
9339 static int alc861_auto_fill_dac_nids(struct alc_spec *spec,
9340 const struct auto_pin_cfg *cfg)
9345 spec->multiout.dac_nids = spec->private_dac_nids;
9346 for (i = 0; i < cfg->line_outs; i++) {
9347 nid = cfg->line_out_pins[i];
9349 if (i >= ARRAY_SIZE(alc861_dac_nids))
9351 spec->multiout.dac_nids[i] = alc861_dac_nids[i];
9354 spec->multiout.num_dacs = cfg->line_outs;
9358 /* add playback controls from the parsed DAC table */
9359 static int alc861_auto_create_multi_out_ctls(struct alc_spec *spec,
9360 const struct auto_pin_cfg *cfg)
9363 static const char *chname[4] = {
9364 "Front", "Surround", NULL /*CLFE*/, "Side"
9369 for (i = 0; i < cfg->line_outs; i++) {
9370 nid = spec->multiout.dac_nids[i];
9375 err = add_control(spec, ALC_CTL_BIND_MUTE,
9376 "Center Playback Switch",
9377 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
9381 err = add_control(spec, ALC_CTL_BIND_MUTE,
9382 "LFE Playback Switch",
9383 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
9388 for (idx = 0; idx < ARRAY_SIZE(alc861_dac_nids) - 1;
9390 if (nid == alc861_dac_nids[idx])
9392 sprintf(name, "%s Playback Switch", chname[idx]);
9393 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
9394 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
9403 static int alc861_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin)
9411 if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
9413 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
9414 "Headphone Playback Switch",
9415 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
9418 spec->multiout.hp_nid = nid;
9423 /* create playback/capture controls for input pins */
9424 static int alc861_auto_create_analog_input_ctls(struct alc_spec *spec,
9425 const struct auto_pin_cfg *cfg)
9427 struct hda_input_mux *imux = &spec->private_imux;
9428 int i, err, idx, idx1;
9430 for (i = 0; i < AUTO_PIN_LAST; i++) {
9431 switch (cfg->input_pins[i]) {
9434 idx = 2; /* Line In */
9438 idx = 2; /* Line In */
9442 idx = 1; /* Mic In */
9446 idx = 1; /* Mic In */
9456 err = new_analog_input(spec, cfg->input_pins[i],
9457 auto_pin_cfg_labels[i], idx, 0x15);
9461 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
9462 imux->items[imux->num_items].index = idx1;
9468 static struct snd_kcontrol_new alc861_capture_mixer[] = {
9469 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
9470 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
9473 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9474 /* The multiple "Capture Source" controls confuse alsamixer
9475 * So call somewhat different..
9476 *FIXME: the controls appear in the "playback" view!
9478 /* .name = "Capture Source", */
9479 .name = "Input Source",
9481 .info = alc_mux_enum_info,
9482 .get = alc_mux_enum_get,
9483 .put = alc_mux_enum_put,
9488 static void alc861_auto_set_output_and_unmute(struct hda_codec *codec,
9490 int pin_type, int dac_idx)
9494 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
9496 snd_hda_codec_write(codec, dac_idx, 0, AC_VERB_SET_AMP_GAIN_MUTE,
9501 static void alc861_auto_init_multi_out(struct hda_codec *codec)
9503 struct alc_spec *spec = codec->spec;
9506 alc_subsystem_id(codec, 0x0e, 0x0f, 0x0b);
9507 for (i = 0; i < spec->autocfg.line_outs; i++) {
9508 hda_nid_t nid = spec->autocfg.line_out_pins[i];
9509 int pin_type = get_pin_type(spec->autocfg.line_out_type);
9511 alc861_auto_set_output_and_unmute(codec, nid, pin_type,
9512 spec->multiout.dac_nids[i]);
9516 static void alc861_auto_init_hp_out(struct hda_codec *codec)
9518 struct alc_spec *spec = codec->spec;
9521 pin = spec->autocfg.hp_pins[0];
9522 if (pin) /* connect to front */
9523 alc861_auto_set_output_and_unmute(codec, pin, PIN_HP,
9524 spec->multiout.dac_nids[0]);
9527 static void alc861_auto_init_analog_input(struct hda_codec *codec)
9529 struct alc_spec *spec = codec->spec;
9532 for (i = 0; i < AUTO_PIN_LAST; i++) {
9533 hda_nid_t nid = spec->autocfg.input_pins[i];
9534 if (nid >= 0x0c && nid <= 0x11) {
9535 snd_hda_codec_write(codec, nid, 0,
9536 AC_VERB_SET_PIN_WIDGET_CONTROL,
9537 i <= AUTO_PIN_FRONT_MIC ?
9538 PIN_VREF80 : PIN_IN);
9543 /* parse the BIOS configuration and set up the alc_spec */
9544 /* return 1 if successful, 0 if the proper config is not found,
9545 * or a negative error code
9547 static int alc861_parse_auto_config(struct hda_codec *codec)
9549 struct alc_spec *spec = codec->spec;
9551 static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
9553 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
9557 if (!spec->autocfg.line_outs)
9558 return 0; /* can't find valid BIOS pin config */
9560 err = alc861_auto_fill_dac_nids(spec, &spec->autocfg);
9563 err = alc861_auto_create_multi_out_ctls(spec, &spec->autocfg);
9566 err = alc861_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0]);
9569 err = alc861_auto_create_analog_input_ctls(spec, &spec->autocfg);
9573 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
9575 if (spec->autocfg.dig_out_pin)
9576 spec->multiout.dig_out_nid = ALC861_DIGOUT_NID;
9578 if (spec->kctl_alloc)
9579 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
9581 spec->init_verbs[spec->num_init_verbs++] = alc861_auto_init_verbs;
9583 spec->num_mux_defs = 1;
9584 spec->input_mux = &spec->private_imux;
9586 spec->adc_nids = alc861_adc_nids;
9587 spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
9588 spec->mixers[spec->num_mixers] = alc861_capture_mixer;
9594 /* additional initialization for auto-configuration model */
9595 static void alc861_auto_init(struct hda_codec *codec)
9597 alc861_auto_init_multi_out(codec);
9598 alc861_auto_init_hp_out(codec);
9599 alc861_auto_init_analog_input(codec);
9604 * configuration and preset
9606 static const char *alc861_models[ALC861_MODEL_LAST] = {
9607 [ALC861_3ST] = "3stack",
9608 [ALC660_3ST] = "3stack-660",
9609 [ALC861_3ST_DIG] = "3stack-dig",
9610 [ALC861_6ST_DIG] = "6stack-dig",
9611 [ALC861_UNIWILL_M31] = "uniwill-m31",
9612 [ALC861_TOSHIBA] = "toshiba",
9613 [ALC861_ASUS] = "asus",
9614 [ALC861_ASUS_LAPTOP] = "asus-laptop",
9615 [ALC861_AUTO] = "auto",
9618 static struct snd_pci_quirk alc861_cfg_tbl[] = {
9619 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST),
9620 SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP),
9621 SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP),
9622 SND_PCI_QUIRK(0x1043, 0x13d7, "ASUS A9rp", ALC861_ASUS_LAPTOP),
9623 SND_PCI_QUIRK(0x1584, 0x9075, "Airis Praxis N1212", ALC861_ASUS_LAPTOP),
9624 SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS),
9625 SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS P1-AH2", ALC861_3ST_DIG),
9626 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA),
9627 /* FIXME: the entry below breaks Toshiba A100 (model=auto works!)
9628 * Any other models that need this preset?
9630 /* SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA), */
9631 SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31),
9632 SND_PCI_QUIRK(0x1584, 0x9075, "Uniwill", ALC861_UNIWILL_M31),
9633 SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31),
9634 SND_PCI_QUIRK(0x1849, 0x0660, "Asrock 939SLI32", ALC660_3ST),
9635 SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST),
9636 SND_PCI_QUIRK(0x1462, 0x7254, "HP dx2200 (MSI MS-7254)", ALC861_3ST),
9637 SND_PCI_QUIRK(0x1462, 0x7297, "HP dx2250 (MSI MS-7297)", ALC861_3ST),
9641 static struct alc_config_preset alc861_presets[] = {
9643 .mixers = { alc861_3ST_mixer },
9644 .init_verbs = { alc861_threestack_init_verbs },
9645 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
9646 .dac_nids = alc861_dac_nids,
9647 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
9648 .channel_mode = alc861_threestack_modes,
9650 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
9651 .adc_nids = alc861_adc_nids,
9652 .input_mux = &alc861_capture_source,
9654 [ALC861_3ST_DIG] = {
9655 .mixers = { alc861_base_mixer },
9656 .init_verbs = { alc861_threestack_init_verbs },
9657 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
9658 .dac_nids = alc861_dac_nids,
9659 .dig_out_nid = ALC861_DIGOUT_NID,
9660 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
9661 .channel_mode = alc861_threestack_modes,
9663 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
9664 .adc_nids = alc861_adc_nids,
9665 .input_mux = &alc861_capture_source,
9667 [ALC861_6ST_DIG] = {
9668 .mixers = { alc861_base_mixer },
9669 .init_verbs = { alc861_base_init_verbs },
9670 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
9671 .dac_nids = alc861_dac_nids,
9672 .dig_out_nid = ALC861_DIGOUT_NID,
9673 .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
9674 .channel_mode = alc861_8ch_modes,
9675 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
9676 .adc_nids = alc861_adc_nids,
9677 .input_mux = &alc861_capture_source,
9680 .mixers = { alc861_3ST_mixer },
9681 .init_verbs = { alc861_threestack_init_verbs },
9682 .num_dacs = ARRAY_SIZE(alc660_dac_nids),
9683 .dac_nids = alc660_dac_nids,
9684 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
9685 .channel_mode = alc861_threestack_modes,
9687 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
9688 .adc_nids = alc861_adc_nids,
9689 .input_mux = &alc861_capture_source,
9691 [ALC861_UNIWILL_M31] = {
9692 .mixers = { alc861_uniwill_m31_mixer },
9693 .init_verbs = { alc861_uniwill_m31_init_verbs },
9694 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
9695 .dac_nids = alc861_dac_nids,
9696 .dig_out_nid = ALC861_DIGOUT_NID,
9697 .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes),
9698 .channel_mode = alc861_uniwill_m31_modes,
9700 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
9701 .adc_nids = alc861_adc_nids,
9702 .input_mux = &alc861_capture_source,
9704 [ALC861_TOSHIBA] = {
9705 .mixers = { alc861_toshiba_mixer },
9706 .init_verbs = { alc861_base_init_verbs,
9707 alc861_toshiba_init_verbs },
9708 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
9709 .dac_nids = alc861_dac_nids,
9710 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9711 .channel_mode = alc883_3ST_2ch_modes,
9712 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
9713 .adc_nids = alc861_adc_nids,
9714 .input_mux = &alc861_capture_source,
9715 .unsol_event = alc861_toshiba_unsol_event,
9716 .init_hook = alc861_toshiba_automute,
9719 .mixers = { alc861_asus_mixer },
9720 .init_verbs = { alc861_asus_init_verbs },
9721 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
9722 .dac_nids = alc861_dac_nids,
9723 .dig_out_nid = ALC861_DIGOUT_NID,
9724 .num_channel_mode = ARRAY_SIZE(alc861_asus_modes),
9725 .channel_mode = alc861_asus_modes,
9728 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
9729 .adc_nids = alc861_adc_nids,
9730 .input_mux = &alc861_capture_source,
9732 [ALC861_ASUS_LAPTOP] = {
9733 .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer },
9734 .init_verbs = { alc861_asus_init_verbs,
9735 alc861_asus_laptop_init_verbs },
9736 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
9737 .dac_nids = alc861_dac_nids,
9738 .dig_out_nid = ALC861_DIGOUT_NID,
9739 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9740 .channel_mode = alc883_3ST_2ch_modes,
9742 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
9743 .adc_nids = alc861_adc_nids,
9744 .input_mux = &alc861_capture_source,
9749 static int patch_alc861(struct hda_codec *codec)
9751 struct alc_spec *spec;
9755 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
9761 board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST,
9765 if (board_config < 0) {
9766 printk(KERN_INFO "hda_codec: Unknown model for ALC861, "
9767 "trying auto-probe from BIOS...\n");
9768 board_config = ALC861_AUTO;
9771 if (board_config == ALC861_AUTO) {
9772 /* automatic parse from the BIOS config */
9773 err = alc861_parse_auto_config(codec);
9779 "hda_codec: Cannot set up configuration "
9780 "from BIOS. Using base mode...\n");
9781 board_config = ALC861_3ST_DIG;
9785 if (board_config != ALC861_AUTO)
9786 setup_preset(spec, &alc861_presets[board_config]);
9788 spec->stream_name_analog = "ALC861 Analog";
9789 spec->stream_analog_playback = &alc861_pcm_analog_playback;
9790 spec->stream_analog_capture = &alc861_pcm_analog_capture;
9792 spec->stream_name_digital = "ALC861 Digital";
9793 spec->stream_digital_playback = &alc861_pcm_digital_playback;
9794 spec->stream_digital_capture = &alc861_pcm_digital_capture;
9796 codec->patch_ops = alc_patch_ops;
9797 if (board_config == ALC861_AUTO)
9798 spec->init_hook = alc861_auto_init;
9808 * In addition, an independent DAC
9810 #define ALC861VD_DIGOUT_NID 0x06
9812 static hda_nid_t alc861vd_dac_nids[4] = {
9813 /* front, surr, clfe, side surr */
9814 0x02, 0x03, 0x04, 0x05
9817 /* dac_nids for ALC660vd are in a different order - according to
9819 * This should probably tesult in a different mixer for 6stack models
9820 * of ALC660vd codecs, but for now there is only 3stack mixer
9821 * - and it is the same as in 861vd.
9822 * adc_nids in ALC660vd are (is) the same as in 861vd
9824 static hda_nid_t alc660vd_dac_nids[3] = {
9825 /* front, rear, clfe, rear_surr */
9829 static hda_nid_t alc861vd_adc_nids[1] = {
9835 /* FIXME: should be a matrix-type input source selection */
9836 static struct hda_input_mux alc861vd_capture_source = {
9840 { "Front Mic", 0x1 },
9846 static struct hda_input_mux alc861vd_dallas_capture_source = {
9849 { "Front Mic", 0x0 },
9850 { "ATAPI Mic", 0x1 },
9855 #define alc861vd_mux_enum_info alc_mux_enum_info
9856 #define alc861vd_mux_enum_get alc_mux_enum_get
9858 static int alc861vd_mux_enum_put(struct snd_kcontrol *kcontrol,
9859 struct snd_ctl_elem_value *ucontrol)
9861 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
9862 struct alc_spec *spec = codec->spec;
9863 const struct hda_input_mux *imux = spec->input_mux;
9864 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
9865 static hda_nid_t capture_mixers[1] = { 0x22 };
9866 hda_nid_t nid = capture_mixers[adc_idx];
9867 unsigned int *cur_val = &spec->cur_mux[adc_idx];
9868 unsigned int i, idx;
9870 idx = ucontrol->value.enumerated.item[0];
9871 if (idx >= imux->num_items)
9872 idx = imux->num_items - 1;
9873 if (*cur_val == idx && !codec->in_resume)
9875 for (i = 0; i < imux->num_items; i++) {
9876 unsigned int v = (i == idx) ? 0x7000 : 0x7080;
9877 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
9878 v | (imux->items[i].index << 8));
9887 static struct hda_channel_mode alc861vd_3stack_2ch_modes[1] = {
9894 static struct hda_verb alc861vd_6stack_ch6_init[] = {
9895 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
9896 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9897 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9898 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9905 static struct hda_verb alc861vd_6stack_ch8_init[] = {
9906 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9907 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9908 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9909 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9913 static struct hda_channel_mode alc861vd_6stack_modes[2] = {
9914 { 6, alc861vd_6stack_ch6_init },
9915 { 8, alc861vd_6stack_ch8_init },
9918 static struct snd_kcontrol_new alc861vd_chmode_mixer[] = {
9920 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9921 .name = "Channel Mode",
9922 .info = alc_ch_mode_info,
9923 .get = alc_ch_mode_get,
9924 .put = alc_ch_mode_put,
9929 static struct snd_kcontrol_new alc861vd_capture_mixer[] = {
9930 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
9931 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
9934 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9935 /* The multiple "Capture Source" controls confuse alsamixer
9936 * So call somewhat different..
9937 *FIXME: the controls appear in the "playback" view!
9939 /* .name = "Capture Source", */
9940 .name = "Input Source",
9942 .info = alc861vd_mux_enum_info,
9943 .get = alc861vd_mux_enum_get,
9944 .put = alc861vd_mux_enum_put,
9949 /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
9950 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
9952 static struct snd_kcontrol_new alc861vd_6st_mixer[] = {
9953 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
9954 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
9956 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
9957 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
9959 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0,
9961 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0,
9963 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
9964 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
9966 HDA_CODEC_VOLUME("Side Playback Volume", 0x05, 0x0, HDA_OUTPUT),
9967 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
9969 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
9971 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9972 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9973 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9975 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
9976 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
9977 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
9979 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9980 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9982 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9983 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9985 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
9986 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
9991 static struct snd_kcontrol_new alc861vd_3st_mixer[] = {
9992 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
9993 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
9995 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
9997 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9998 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9999 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10001 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10002 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
10003 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
10005 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10006 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10008 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10009 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10011 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
10012 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
10017 static struct snd_kcontrol_new alc861vd_lenovo_mixer[] = {
10018 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
10019 /*HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),*/
10020 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
10022 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
10024 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10025 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10026 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10028 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10029 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
10030 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
10032 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10033 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10038 /* Pin assignment: Front=0x14, HP = 0x15,
10039 * Front Mic=0x18, ATAPI Mic = 0x19, Line In = 0x1d
10041 static struct snd_kcontrol_new alc861vd_dallas_mixer[] = {
10042 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
10043 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
10044 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
10045 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
10046 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10047 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10048 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
10049 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
10050 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x05, HDA_INPUT),
10051 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x05, HDA_INPUT),
10052 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
10053 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
10055 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10056 /* .name = "Capture Source", */
10057 .name = "Input Source",
10059 .info = alc882_mux_enum_info,
10060 .get = alc882_mux_enum_get,
10061 .put = alc882_mux_enum_put,
10067 * generic initialization of ADC, input mixers and output mixers
10069 static struct hda_verb alc861vd_volume_init_verbs[] = {
10071 * Unmute ADC0 and set the default input to mic-in
10073 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
10074 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10076 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of
10077 * the analog-loopback mixer widget
10079 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
10080 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10081 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10082 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
10083 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
10084 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
10086 /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */
10087 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10088 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10089 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
10090 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
10093 * Set up output mixers (0x02 - 0x05)
10095 /* set vol=0 to output mixers */
10096 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10097 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10098 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10099 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10101 /* set up input amps for analog loopback */
10102 /* Amp Indices: DAC = 0, mixer = 1 */
10103 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10104 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10105 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10106 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10107 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10108 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10109 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10110 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10116 * 3-stack pin configuration:
10117 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
10119 static struct hda_verb alc861vd_3stack_init_verbs[] = {
10121 * Set pin mode and muting
10123 /* set front pin widgets 0x14 for output */
10124 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10125 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10126 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
10128 /* Mic (rear) pin: input vref at 80% */
10129 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
10130 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10131 /* Front Mic pin: input vref at 80% */
10132 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
10133 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10134 /* Line In pin: input */
10135 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10136 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10137 /* Line-2 In: Headphone output (output 0 - 0x0c) */
10138 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10139 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10140 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
10141 /* CD pin widget for input */
10142 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10148 * 6-stack pin configuration:
10150 static struct hda_verb alc861vd_6stack_init_verbs[] = {
10152 * Set pin mode and muting
10154 /* set front pin widgets 0x14 for output */
10155 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10156 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10157 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
10159 /* Rear Pin: output 1 (0x0d) */
10160 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10161 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10162 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
10163 /* CLFE Pin: output 2 (0x0e) */
10164 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10165 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10166 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
10167 /* Side Pin: output 3 (0x0f) */
10168 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10169 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10170 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
10172 /* Mic (rear) pin: input vref at 80% */
10173 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
10174 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10175 /* Front Mic pin: input vref at 80% */
10176 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
10177 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10178 /* Line In pin: input */
10179 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10180 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10181 /* Line-2 In: Headphone output (output 0 - 0x0c) */
10182 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10183 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10184 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
10185 /* CD pin widget for input */
10186 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10191 static struct hda_verb alc861vd_eapd_verbs[] = {
10192 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
10196 static struct hda_verb alc861vd_lenovo_unsol_verbs[] = {
10197 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10198 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10199 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
10200 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10201 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
10205 /* toggle speaker-output according to the hp-jack state */
10206 static void alc861vd_lenovo_hp_automute(struct hda_codec *codec)
10208 unsigned int present;
10209 unsigned char bits;
10211 present = snd_hda_codec_read(codec, 0x1b, 0,
10212 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
10213 bits = present ? 0x80 : 0;
10214 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
10216 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
10220 static void alc861vd_lenovo_mic_automute(struct hda_codec *codec)
10222 unsigned int present;
10223 unsigned char bits;
10225 present = snd_hda_codec_read(codec, 0x18, 0,
10226 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
10227 bits = present ? 0x80 : 0;
10228 snd_hda_codec_amp_update(codec, 0x0b, 0, HDA_INPUT, 1,
10230 snd_hda_codec_amp_update(codec, 0x0b, 1, HDA_INPUT, 1,
10234 static void alc861vd_lenovo_automute(struct hda_codec *codec)
10236 alc861vd_lenovo_hp_automute(codec);
10237 alc861vd_lenovo_mic_automute(codec);
10240 static void alc861vd_lenovo_unsol_event(struct hda_codec *codec,
10243 switch (res >> 26) {
10244 case ALC880_HP_EVENT:
10245 alc861vd_lenovo_hp_automute(codec);
10247 case ALC880_MIC_EVENT:
10248 alc861vd_lenovo_mic_automute(codec);
10253 static struct hda_verb alc861vd_dallas_verbs[] = {
10254 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10255 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10256 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10257 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10259 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10260 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10261 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10262 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10263 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10264 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10265 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10266 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10268 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10269 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10270 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10271 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10272 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10273 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10274 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10275 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10277 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
10278 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10279 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
10280 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10281 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10282 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10283 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10284 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10286 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10287 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10288 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10289 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
10291 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10292 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
10293 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10298 /* toggle speaker-output according to the hp-jack state */
10299 static void alc861vd_dallas_automute(struct hda_codec *codec)
10301 unsigned int present;
10303 present = snd_hda_codec_read(codec, 0x15, 0,
10304 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
10305 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
10306 0x80, present ? 0x80 : 0);
10307 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
10308 0x80, present ? 0x80 : 0);
10311 static void alc861vd_dallas_unsol_event(struct hda_codec *codec, unsigned int res)
10313 if ((res >> 26) == ALC880_HP_EVENT)
10314 alc861vd_dallas_automute(codec);
10317 /* pcm configuration: identiacal with ALC880 */
10318 #define alc861vd_pcm_analog_playback alc880_pcm_analog_playback
10319 #define alc861vd_pcm_analog_capture alc880_pcm_analog_capture
10320 #define alc861vd_pcm_digital_playback alc880_pcm_digital_playback
10321 #define alc861vd_pcm_digital_capture alc880_pcm_digital_capture
10324 * configuration and preset
10326 static const char *alc861vd_models[ALC861VD_MODEL_LAST] = {
10327 [ALC660VD_3ST] = "3stack-660",
10328 [ALC660VD_3ST_DIG]= "3stack-660-digout",
10329 [ALC861VD_3ST] = "3stack",
10330 [ALC861VD_3ST_DIG] = "3stack-digout",
10331 [ALC861VD_6ST_DIG] = "6stack-digout",
10332 [ALC861VD_LENOVO] = "lenovo",
10333 [ALC861VD_DALLAS] = "dallas",
10334 [ALC861VD_AUTO] = "auto",
10337 static struct snd_pci_quirk alc861vd_cfg_tbl[] = {
10338 SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST),
10339 SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST),
10340 SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660VD_3ST_DIG),
10341 SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST),
10342 SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST),
10344 SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),
10345 SND_PCI_QUIRK(0x1179, 0xff01, "DALLAS", ALC861VD_DALLAS),
10346 SND_PCI_QUIRK(0x17aa, 0x3802, "Lenovo 3000 C200", ALC861VD_LENOVO),
10347 SND_PCI_QUIRK(0x17aa, 0x2066, "Lenovo", ALC861VD_LENOVO),
10348 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba A135", ALC861VD_LENOVO),
10352 static struct alc_config_preset alc861vd_presets[] = {
10354 .mixers = { alc861vd_3st_mixer },
10355 .init_verbs = { alc861vd_volume_init_verbs,
10356 alc861vd_3stack_init_verbs },
10357 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
10358 .dac_nids = alc660vd_dac_nids,
10359 .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
10360 .adc_nids = alc861vd_adc_nids,
10361 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
10362 .channel_mode = alc861vd_3stack_2ch_modes,
10363 .input_mux = &alc861vd_capture_source,
10365 [ALC660VD_3ST_DIG] = {
10366 .mixers = { alc861vd_3st_mixer },
10367 .init_verbs = { alc861vd_volume_init_verbs,
10368 alc861vd_3stack_init_verbs },
10369 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
10370 .dac_nids = alc660vd_dac_nids,
10371 .dig_out_nid = ALC861VD_DIGOUT_NID,
10372 .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
10373 .adc_nids = alc861vd_adc_nids,
10374 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
10375 .channel_mode = alc861vd_3stack_2ch_modes,
10376 .input_mux = &alc861vd_capture_source,
10379 .mixers = { alc861vd_3st_mixer },
10380 .init_verbs = { alc861vd_volume_init_verbs,
10381 alc861vd_3stack_init_verbs },
10382 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
10383 .dac_nids = alc861vd_dac_nids,
10384 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
10385 .channel_mode = alc861vd_3stack_2ch_modes,
10386 .input_mux = &alc861vd_capture_source,
10388 [ALC861VD_3ST_DIG] = {
10389 .mixers = { alc861vd_3st_mixer },
10390 .init_verbs = { alc861vd_volume_init_verbs,
10391 alc861vd_3stack_init_verbs },
10392 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
10393 .dac_nids = alc861vd_dac_nids,
10394 .dig_out_nid = ALC861VD_DIGOUT_NID,
10395 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
10396 .channel_mode = alc861vd_3stack_2ch_modes,
10397 .input_mux = &alc861vd_capture_source,
10399 [ALC861VD_6ST_DIG] = {
10400 .mixers = { alc861vd_6st_mixer, alc861vd_chmode_mixer },
10401 .init_verbs = { alc861vd_volume_init_verbs,
10402 alc861vd_6stack_init_verbs },
10403 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
10404 .dac_nids = alc861vd_dac_nids,
10405 .dig_out_nid = ALC861VD_DIGOUT_NID,
10406 .num_channel_mode = ARRAY_SIZE(alc861vd_6stack_modes),
10407 .channel_mode = alc861vd_6stack_modes,
10408 .input_mux = &alc861vd_capture_source,
10410 [ALC861VD_LENOVO] = {
10411 .mixers = { alc861vd_lenovo_mixer },
10412 .init_verbs = { alc861vd_volume_init_verbs,
10413 alc861vd_3stack_init_verbs,
10414 alc861vd_eapd_verbs,
10415 alc861vd_lenovo_unsol_verbs },
10416 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
10417 .dac_nids = alc660vd_dac_nids,
10418 .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
10419 .adc_nids = alc861vd_adc_nids,
10420 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
10421 .channel_mode = alc861vd_3stack_2ch_modes,
10422 .input_mux = &alc861vd_capture_source,
10423 .unsol_event = alc861vd_lenovo_unsol_event,
10424 .init_hook = alc861vd_lenovo_automute,
10426 [ALC861VD_DALLAS] = {
10427 .mixers = { alc861vd_dallas_mixer },
10428 .init_verbs = { alc861vd_dallas_verbs },
10429 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
10430 .dac_nids = alc861vd_dac_nids,
10431 .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
10432 .adc_nids = alc861vd_adc_nids,
10433 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
10434 .channel_mode = alc861vd_3stack_2ch_modes,
10435 .input_mux = &alc861vd_dallas_capture_source,
10436 .unsol_event = alc861vd_dallas_unsol_event,
10437 .init_hook = alc861vd_dallas_automute,
10442 * BIOS auto configuration
10444 static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec,
10445 hda_nid_t nid, int pin_type, int dac_idx)
10447 /* set as output */
10448 snd_hda_codec_write(codec, nid, 0,
10449 AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
10450 snd_hda_codec_write(codec, nid, 0,
10451 AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
10454 static void alc861vd_auto_init_multi_out(struct hda_codec *codec)
10456 struct alc_spec *spec = codec->spec;
10459 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
10460 for (i = 0; i <= HDA_SIDE; i++) {
10461 hda_nid_t nid = spec->autocfg.line_out_pins[i];
10462 int pin_type = get_pin_type(spec->autocfg.line_out_type);
10464 alc861vd_auto_set_output_and_unmute(codec, nid,
10470 static void alc861vd_auto_init_hp_out(struct hda_codec *codec)
10472 struct alc_spec *spec = codec->spec;
10475 pin = spec->autocfg.hp_pins[0];
10476 if (pin) /* connect to front and use dac 0 */
10477 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
10480 #define alc861vd_is_input_pin(nid) alc880_is_input_pin(nid)
10481 #define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID
10483 static void alc861vd_auto_init_analog_input(struct hda_codec *codec)
10485 struct alc_spec *spec = codec->spec;
10488 for (i = 0; i < AUTO_PIN_LAST; i++) {
10489 hda_nid_t nid = spec->autocfg.input_pins[i];
10490 if (alc861vd_is_input_pin(nid)) {
10491 snd_hda_codec_write(codec, nid, 0,
10492 AC_VERB_SET_PIN_WIDGET_CONTROL,
10493 i <= AUTO_PIN_FRONT_MIC ?
10494 PIN_VREF80 : PIN_IN);
10495 if (nid != ALC861VD_PIN_CD_NID)
10496 snd_hda_codec_write(codec, nid, 0,
10497 AC_VERB_SET_AMP_GAIN_MUTE,
10503 #define alc861vd_idx_to_mixer_vol(nid) ((nid) + 0x02)
10504 #define alc861vd_idx_to_mixer_switch(nid) ((nid) + 0x0c)
10506 /* add playback controls from the parsed DAC table */
10507 /* Based on ALC880 version. But ALC861VD has separate,
10508 * different NIDs for mute/unmute switch and volume control */
10509 static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
10510 const struct auto_pin_cfg *cfg)
10513 static const char *chname[4] = {"Front", "Surround", "CLFE", "Side"};
10514 hda_nid_t nid_v, nid_s;
10517 for (i = 0; i < cfg->line_outs; i++) {
10518 if (!spec->multiout.dac_nids[i])
10520 nid_v = alc861vd_idx_to_mixer_vol(
10522 spec->multiout.dac_nids[i]));
10523 nid_s = alc861vd_idx_to_mixer_switch(
10525 spec->multiout.dac_nids[i]));
10529 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10530 "Center Playback Volume",
10531 HDA_COMPOSE_AMP_VAL(nid_v, 1, 0,
10535 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10536 "LFE Playback Volume",
10537 HDA_COMPOSE_AMP_VAL(nid_v, 2, 0,
10541 err = add_control(spec, ALC_CTL_BIND_MUTE,
10542 "Center Playback Switch",
10543 HDA_COMPOSE_AMP_VAL(nid_s, 1, 2,
10547 err = add_control(spec, ALC_CTL_BIND_MUTE,
10548 "LFE Playback Switch",
10549 HDA_COMPOSE_AMP_VAL(nid_s, 2, 2,
10554 sprintf(name, "%s Playback Volume", chname[i]);
10555 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
10556 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0,
10560 sprintf(name, "%s Playback Switch", chname[i]);
10561 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
10562 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2,
10571 /* add playback controls for speaker and HP outputs */
10572 /* Based on ALC880 version. But ALC861VD has separate,
10573 * different NIDs for mute/unmute switch and volume control */
10574 static int alc861vd_auto_create_extra_out(struct alc_spec *spec,
10575 hda_nid_t pin, const char *pfx)
10577 hda_nid_t nid_v, nid_s;
10584 if (alc880_is_fixed_pin(pin)) {
10585 nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
10586 /* specify the DAC as the extra output */
10587 if (!spec->multiout.hp_nid)
10588 spec->multiout.hp_nid = nid_v;
10590 spec->multiout.extra_out_nid[0] = nid_v;
10591 /* control HP volume/switch on the output mixer amp */
10592 nid_v = alc861vd_idx_to_mixer_vol(
10593 alc880_fixed_pin_idx(pin));
10594 nid_s = alc861vd_idx_to_mixer_switch(
10595 alc880_fixed_pin_idx(pin));
10597 sprintf(name, "%s Playback Volume", pfx);
10598 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
10599 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT));
10602 sprintf(name, "%s Playback Switch", pfx);
10603 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
10604 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT));
10607 } else if (alc880_is_multi_pin(pin)) {
10608 /* set manual connection */
10609 /* we have only a switch on HP-out PIN */
10610 sprintf(name, "%s Playback Switch", pfx);
10611 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
10612 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
10619 /* parse the BIOS configuration and set up the alc_spec
10620 * return 1 if successful, 0 if the proper config is not found,
10621 * or a negative error code
10622 * Based on ALC880 version - had to change it to override
10623 * alc880_auto_create_extra_out and alc880_auto_create_multi_out_ctls */
10624 static int alc861vd_parse_auto_config(struct hda_codec *codec)
10626 struct alc_spec *spec = codec->spec;
10628 static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
10630 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
10634 if (!spec->autocfg.line_outs)
10635 return 0; /* can't find valid BIOS pin config */
10637 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
10640 err = alc861vd_auto_create_multi_out_ctls(spec, &spec->autocfg);
10643 err = alc861vd_auto_create_extra_out(spec,
10644 spec->autocfg.speaker_pins[0],
10648 err = alc861vd_auto_create_extra_out(spec,
10649 spec->autocfg.hp_pins[0],
10653 err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
10657 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
10659 if (spec->autocfg.dig_out_pin)
10660 spec->multiout.dig_out_nid = ALC861VD_DIGOUT_NID;
10662 if (spec->kctl_alloc)
10663 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
10665 spec->init_verbs[spec->num_init_verbs++]
10666 = alc861vd_volume_init_verbs;
10668 spec->num_mux_defs = 1;
10669 spec->input_mux = &spec->private_imux;
10674 /* additional initialization for auto-configuration model */
10675 static void alc861vd_auto_init(struct hda_codec *codec)
10677 alc861vd_auto_init_multi_out(codec);
10678 alc861vd_auto_init_hp_out(codec);
10679 alc861vd_auto_init_analog_input(codec);
10682 static int patch_alc861vd(struct hda_codec *codec)
10684 struct alc_spec *spec;
10685 int err, board_config;
10687 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
10691 codec->spec = spec;
10693 board_config = snd_hda_check_board_config(codec, ALC861VD_MODEL_LAST,
10697 if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) {
10698 printk(KERN_INFO "hda_codec: Unknown model for ALC660VD/"
10699 "ALC861VD, trying auto-probe from BIOS...\n");
10700 board_config = ALC861VD_AUTO;
10703 if (board_config == ALC861VD_AUTO) {
10704 /* automatic parse from the BIOS config */
10705 err = alc861vd_parse_auto_config(codec);
10711 "hda_codec: Cannot set up configuration "
10712 "from BIOS. Using base mode...\n");
10713 board_config = ALC861VD_3ST;
10717 if (board_config != ALC861VD_AUTO)
10718 setup_preset(spec, &alc861vd_presets[board_config]);
10720 spec->stream_name_analog = "ALC861VD Analog";
10721 spec->stream_analog_playback = &alc861vd_pcm_analog_playback;
10722 spec->stream_analog_capture = &alc861vd_pcm_analog_capture;
10724 spec->stream_name_digital = "ALC861VD Digital";
10725 spec->stream_digital_playback = &alc861vd_pcm_digital_playback;
10726 spec->stream_digital_capture = &alc861vd_pcm_digital_capture;
10728 spec->adc_nids = alc861vd_adc_nids;
10729 spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids);
10731 spec->mixers[spec->num_mixers] = alc861vd_capture_mixer;
10732 spec->num_mixers++;
10734 codec->patch_ops = alc_patch_ops;
10736 if (board_config == ALC861VD_AUTO)
10737 spec->init_hook = alc861vd_auto_init;
10745 * ALC662 is almost identical with ALC880 but has cleaner and more flexible
10746 * configuration. Each pin widget can choose any input DACs and a mixer.
10747 * Each ADC is connected from a mixer of all inputs. This makes possible
10748 * 6-channel independent captures.
10750 * In addition, an independent DAC for the multi-playback (not used in this
10753 #define ALC662_DIGOUT_NID 0x06
10754 #define ALC662_DIGIN_NID 0x0a
10756 static hda_nid_t alc662_dac_nids[4] = {
10757 /* front, rear, clfe, rear_surr */
10761 static hda_nid_t alc662_adc_nids[1] = {
10766 /* FIXME: should be a matrix-type input source selection */
10768 static struct hda_input_mux alc662_capture_source = {
10772 { "Front Mic", 0x1 },
10778 static struct hda_input_mux alc662_lenovo_101e_capture_source = {
10785 #define alc662_mux_enum_info alc_mux_enum_info
10786 #define alc662_mux_enum_get alc_mux_enum_get
10788 static int alc662_mux_enum_put(struct snd_kcontrol *kcontrol,
10789 struct snd_ctl_elem_value *ucontrol)
10791 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10792 struct alc_spec *spec = codec->spec;
10793 const struct hda_input_mux *imux = spec->input_mux;
10794 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
10795 static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
10796 hda_nid_t nid = capture_mixers[adc_idx];
10797 unsigned int *cur_val = &spec->cur_mux[adc_idx];
10798 unsigned int i, idx;
10800 idx = ucontrol->value.enumerated.item[0];
10801 if (idx >= imux->num_items)
10802 idx = imux->num_items - 1;
10803 if (*cur_val == idx && !codec->in_resume)
10805 for (i = 0; i < imux->num_items; i++) {
10806 unsigned int v = (i == idx) ? 0x7000 : 0x7080;
10807 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
10808 v | (imux->items[i].index << 8));
10816 static struct hda_channel_mode alc662_3ST_2ch_modes[1] = {
10823 static struct hda_verb alc662_3ST_ch2_init[] = {
10824 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
10825 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
10826 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
10827 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
10834 static struct hda_verb alc662_3ST_ch6_init[] = {
10835 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10836 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10837 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
10838 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10839 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10840 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
10844 static struct hda_channel_mode alc662_3ST_6ch_modes[2] = {
10845 { 2, alc662_3ST_ch2_init },
10846 { 6, alc662_3ST_ch6_init },
10852 static struct hda_verb alc662_sixstack_ch6_init[] = {
10853 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
10854 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
10855 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10862 static struct hda_verb alc662_sixstack_ch8_init[] = {
10863 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10864 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10865 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10869 static struct hda_channel_mode alc662_5stack_modes[2] = {
10870 { 2, alc662_sixstack_ch6_init },
10871 { 6, alc662_sixstack_ch8_init },
10874 /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
10875 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
10878 static struct snd_kcontrol_new alc662_base_mixer[] = {
10879 /* output mixer control */
10880 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
10881 HDA_CODEC_MUTE("Front Playback Switch", 0x02, 0x0, HDA_OUTPUT),
10882 HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT),
10883 HDA_CODEC_MUTE("Surround Playback Switch", 0x03, 0x0, HDA_OUTPUT),
10884 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
10885 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
10886 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT),
10887 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT),
10888 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
10890 /*Input mixer control */
10891 HDA_CODEC_VOLUME("CD Playback Volume", 0xb, 0x4, HDA_INPUT),
10892 HDA_CODEC_MUTE("CD Playback Switch", 0xb, 0x4, HDA_INPUT),
10893 HDA_CODEC_VOLUME("Line Playback Volume", 0xb, 0x02, HDA_INPUT),
10894 HDA_CODEC_MUTE("Line Playback Switch", 0xb, 0x02, HDA_INPUT),
10895 HDA_CODEC_VOLUME("Mic Playback Volume", 0xb, 0x0, HDA_INPUT),
10896 HDA_CODEC_MUTE("Mic Playback Switch", 0xb, 0x0, HDA_INPUT),
10897 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0xb, 0x01, HDA_INPUT),
10898 HDA_CODEC_MUTE("Front Mic Playback Switch", 0xb, 0x01, HDA_INPUT),
10900 /* Capture mixer control */
10901 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
10902 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
10904 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10905 .name = "Capture Source",
10907 .info = alc_mux_enum_info,
10908 .get = alc_mux_enum_get,
10909 .put = alc_mux_enum_put,
10914 static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = {
10915 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
10916 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
10917 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
10918 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10919 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10920 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10921 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10922 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10923 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10924 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
10925 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
10926 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
10927 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
10928 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
10929 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
10931 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10932 /* .name = "Capture Source", */
10933 .name = "Input Source",
10935 .info = alc662_mux_enum_info,
10936 .get = alc662_mux_enum_get,
10937 .put = alc662_mux_enum_put,
10942 static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = {
10943 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
10944 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
10945 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
10946 HDA_BIND_MUTE("Surround Playback Switch", 0x03, 2, HDA_INPUT),
10947 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
10948 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
10949 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT),
10950 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT),
10951 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
10952 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10953 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10954 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10955 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10956 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10957 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10958 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
10959 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
10960 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
10961 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
10962 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
10963 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
10965 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10966 /* .name = "Capture Source", */
10967 .name = "Input Source",
10969 .info = alc662_mux_enum_info,
10970 .get = alc662_mux_enum_get,
10971 .put = alc662_mux_enum_put,
10976 static struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = {
10977 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
10978 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
10979 HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x03, 0x0, HDA_OUTPUT),
10980 HDA_BIND_MUTE("iSpeaker Playback Switch", 0x03, 2, HDA_INPUT),
10981 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
10982 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10983 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10984 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
10985 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
10986 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
10987 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
10989 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10990 /* .name = "Capture Source", */
10991 .name = "Input Source",
10993 .info = alc662_mux_enum_info,
10994 .get = alc662_mux_enum_get,
10995 .put = alc662_mux_enum_put,
11000 static struct snd_kcontrol_new alc662_chmode_mixer[] = {
11002 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11003 .name = "Channel Mode",
11004 .info = alc_ch_mode_info,
11005 .get = alc_ch_mode_get,
11006 .put = alc_ch_mode_put,
11011 static struct hda_verb alc662_init_verbs[] = {
11012 /* ADC: mute amp left and right */
11013 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11014 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
11015 /* Front mixer: unmute input/output amp left and right (volume = 0) */
11017 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11018 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11019 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
11020 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
11021 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
11023 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11024 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11025 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11026 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11027 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11028 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11030 /* Front Pin: output 0 (0x0c) */
11031 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11032 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11034 /* Rear Pin: output 1 (0x0d) */
11035 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11036 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11038 /* CLFE Pin: output 2 (0x0e) */
11039 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11040 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11042 /* Mic (rear) pin: input vref at 80% */
11043 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
11044 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11045 /* Front Mic pin: input vref at 80% */
11046 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
11047 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11048 /* Line In pin: input */
11049 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11050 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11051 /* Line-2 In: Headphone output (output 0 - 0x0c) */
11052 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11053 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11054 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
11055 /* CD pin widget for input */
11056 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11058 /* FIXME: use matrix-type input source selection */
11059 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
11061 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11062 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11063 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
11064 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
11068 static struct hda_verb alc662_sue_init_verbs[] = {
11069 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
11070 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
11075 * generic initialization of ADC, input mixers and output mixers
11077 static struct hda_verb alc662_auto_init_verbs[] = {
11079 * Unmute ADC and set the default input to mic-in
11081 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
11082 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11084 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
11086 * Note: PASD motherboards uses the Line In 2 as the input for front
11087 * panel mic (mic 2)
11089 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
11090 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11091 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11092 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
11093 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
11094 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
11097 * Set up output mixers (0x0c - 0x0f)
11099 /* set vol=0 to output mixers */
11100 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11101 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11102 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11104 /* set up input amps for analog loopback */
11105 /* Amp Indices: DAC = 0, mixer = 1 */
11106 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11107 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11108 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11109 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11110 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11111 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11114 /* FIXME: use matrix-type input source selection */
11115 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
11117 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11118 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11119 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
11120 /*{0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},*/
11121 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
11126 /* capture mixer elements */
11127 static struct snd_kcontrol_new alc662_capture_mixer[] = {
11128 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
11129 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
11131 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11132 /* The multiple "Capture Source" controls confuse alsamixer
11133 * So call somewhat different..
11134 * FIXME: the controls appear in the "playback" view!
11136 /* .name = "Capture Source", */
11137 .name = "Input Source",
11139 .info = alc882_mux_enum_info,
11140 .get = alc882_mux_enum_get,
11141 .put = alc882_mux_enum_put,
11146 static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
11148 unsigned int present;
11149 unsigned char bits;
11151 present = snd_hda_codec_read(codec, 0x14, 0,
11152 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
11153 bits = present ? 0x80 : 0;
11154 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
11156 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
11160 static void alc662_lenovo_101e_all_automute(struct hda_codec *codec)
11162 unsigned int present;
11163 unsigned char bits;
11165 present = snd_hda_codec_read(codec, 0x1b, 0,
11166 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
11167 bits = present ? 0x80 : 0;
11168 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
11170 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
11172 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
11174 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
11178 static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec,
11181 if ((res >> 26) == ALC880_HP_EVENT)
11182 alc662_lenovo_101e_all_automute(codec);
11183 if ((res >> 26) == ALC880_FRONT_EVENT)
11184 alc662_lenovo_101e_ispeaker_automute(codec);
11188 /* pcm configuration: identiacal with ALC880 */
11189 #define alc662_pcm_analog_playback alc880_pcm_analog_playback
11190 #define alc662_pcm_analog_capture alc880_pcm_analog_capture
11191 #define alc662_pcm_digital_playback alc880_pcm_digital_playback
11192 #define alc662_pcm_digital_capture alc880_pcm_digital_capture
11195 * configuration and preset
11197 static const char *alc662_models[ALC662_MODEL_LAST] = {
11198 [ALC662_3ST_2ch_DIG] = "3stack-dig",
11199 [ALC662_3ST_6ch_DIG] = "3stack-6ch-dig",
11200 [ALC662_3ST_6ch] = "3stack-6ch",
11201 [ALC662_5ST_DIG] = "6stack-dig",
11202 [ALC662_LENOVO_101E] = "lenovo-101e",
11203 [ALC662_AUTO] = "auto",
11206 static struct snd_pci_quirk alc662_cfg_tbl[] = {
11207 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E),
11211 static struct alc_config_preset alc662_presets[] = {
11212 [ALC662_3ST_2ch_DIG] = {
11213 .mixers = { alc662_3ST_2ch_mixer },
11214 .init_verbs = { alc662_init_verbs },
11215 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
11216 .dac_nids = alc662_dac_nids,
11217 .dig_out_nid = ALC662_DIGOUT_NID,
11218 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
11219 .adc_nids = alc662_adc_nids,
11220 .dig_in_nid = ALC662_DIGIN_NID,
11221 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
11222 .channel_mode = alc662_3ST_2ch_modes,
11223 .input_mux = &alc662_capture_source,
11225 [ALC662_3ST_6ch_DIG] = {
11226 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
11227 .init_verbs = { alc662_init_verbs },
11228 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
11229 .dac_nids = alc662_dac_nids,
11230 .dig_out_nid = ALC662_DIGOUT_NID,
11231 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
11232 .adc_nids = alc662_adc_nids,
11233 .dig_in_nid = ALC662_DIGIN_NID,
11234 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
11235 .channel_mode = alc662_3ST_6ch_modes,
11237 .input_mux = &alc662_capture_source,
11239 [ALC662_3ST_6ch] = {
11240 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
11241 .init_verbs = { alc662_init_verbs },
11242 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
11243 .dac_nids = alc662_dac_nids,
11244 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
11245 .adc_nids = alc662_adc_nids,
11246 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
11247 .channel_mode = alc662_3ST_6ch_modes,
11249 .input_mux = &alc662_capture_source,
11251 [ALC662_5ST_DIG] = {
11252 .mixers = { alc662_base_mixer, alc662_chmode_mixer },
11253 .init_verbs = { alc662_init_verbs },
11254 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
11255 .dac_nids = alc662_dac_nids,
11256 .dig_out_nid = ALC662_DIGOUT_NID,
11257 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
11258 .adc_nids = alc662_adc_nids,
11259 .dig_in_nid = ALC662_DIGIN_NID,
11260 .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes),
11261 .channel_mode = alc662_5stack_modes,
11262 .input_mux = &alc662_capture_source,
11264 [ALC662_LENOVO_101E] = {
11265 .mixers = { alc662_lenovo_101e_mixer },
11266 .init_verbs = { alc662_init_verbs, alc662_sue_init_verbs },
11267 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
11268 .dac_nids = alc662_dac_nids,
11269 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
11270 .adc_nids = alc662_adc_nids,
11271 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
11272 .channel_mode = alc662_3ST_2ch_modes,
11273 .input_mux = &alc662_lenovo_101e_capture_source,
11274 .unsol_event = alc662_lenovo_101e_unsol_event,
11275 .init_hook = alc662_lenovo_101e_all_automute,
11282 * BIOS auto configuration
11285 /* add playback controls from the parsed DAC table */
11286 static int alc662_auto_create_multi_out_ctls(struct alc_spec *spec,
11287 const struct auto_pin_cfg *cfg)
11290 static const char *chname[4] = {
11291 "Front", "Surround", NULL /*CLFE*/, "Side"
11296 for (i = 0; i < cfg->line_outs; i++) {
11297 if (!spec->multiout.dac_nids[i])
11299 nid = alc880_idx_to_mixer(i);
11302 err = add_control(spec, ALC_CTL_WIDGET_VOL,
11303 "Center Playback Volume",
11304 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
11308 err = add_control(spec, ALC_CTL_WIDGET_VOL,
11309 "LFE Playback Volume",
11310 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
11314 err = add_control(spec, ALC_CTL_BIND_MUTE,
11315 "Center Playback Switch",
11316 HDA_COMPOSE_AMP_VAL(nid, 1, 2,
11320 err = add_control(spec, ALC_CTL_BIND_MUTE,
11321 "LFE Playback Switch",
11322 HDA_COMPOSE_AMP_VAL(nid, 2, 2,
11327 sprintf(name, "%s Playback Volume", chname[i]);
11328 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
11329 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
11333 sprintf(name, "%s Playback Switch", chname[i]);
11334 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
11335 HDA_COMPOSE_AMP_VAL(nid, 3, 2,
11344 /* add playback controls for speaker and HP outputs */
11345 static int alc662_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
11355 if (alc880_is_fixed_pin(pin)) {
11356 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
11357 /* printk("DAC nid=%x\n",nid); */
11358 /* specify the DAC as the extra output */
11359 if (!spec->multiout.hp_nid)
11360 spec->multiout.hp_nid = nid;
11362 spec->multiout.extra_out_nid[0] = nid;
11363 /* control HP volume/switch on the output mixer amp */
11364 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
11365 sprintf(name, "%s Playback Volume", pfx);
11366 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
11367 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
11370 sprintf(name, "%s Playback Switch", pfx);
11371 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
11372 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
11375 } else if (alc880_is_multi_pin(pin)) {
11376 /* set manual connection */
11377 /* we have only a switch on HP-out PIN */
11378 sprintf(name, "%s Playback Switch", pfx);
11379 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
11380 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
11387 /* create playback/capture controls for input pins */
11388 static int alc662_auto_create_analog_input_ctls(struct alc_spec *spec,
11389 const struct auto_pin_cfg *cfg)
11391 struct hda_input_mux *imux = &spec->private_imux;
11394 for (i = 0; i < AUTO_PIN_LAST; i++) {
11395 if (alc880_is_input_pin(cfg->input_pins[i])) {
11396 idx = alc880_input_pin_idx(cfg->input_pins[i]);
11397 err = new_analog_input(spec, cfg->input_pins[i],
11398 auto_pin_cfg_labels[i],
11402 imux->items[imux->num_items].label =
11403 auto_pin_cfg_labels[i];
11404 imux->items[imux->num_items].index =
11405 alc880_input_pin_idx(cfg->input_pins[i]);
11412 static void alc662_auto_set_output_and_unmute(struct hda_codec *codec,
11413 hda_nid_t nid, int pin_type,
11416 /* set as output */
11417 snd_hda_codec_write(codec, nid, 0,
11418 AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
11419 snd_hda_codec_write(codec, nid, 0,
11420 AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
11421 /* need the manual connection? */
11422 if (alc880_is_multi_pin(nid)) {
11423 struct alc_spec *spec = codec->spec;
11424 int idx = alc880_multi_pin_idx(nid);
11425 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
11426 AC_VERB_SET_CONNECT_SEL,
11427 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
11431 static void alc662_auto_init_multi_out(struct hda_codec *codec)
11433 struct alc_spec *spec = codec->spec;
11436 for (i = 0; i <= HDA_SIDE; i++) {
11437 hda_nid_t nid = spec->autocfg.line_out_pins[i];
11438 int pin_type = get_pin_type(spec->autocfg.line_out_type);
11440 alc662_auto_set_output_and_unmute(codec, nid, pin_type,
11445 static void alc662_auto_init_hp_out(struct hda_codec *codec)
11447 struct alc_spec *spec = codec->spec;
11450 pin = spec->autocfg.hp_pins[0];
11451 if (pin) /* connect to front */
11453 alc662_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
11456 #define alc662_is_input_pin(nid) alc880_is_input_pin(nid)
11457 #define ALC662_PIN_CD_NID ALC880_PIN_CD_NID
11459 static void alc662_auto_init_analog_input(struct hda_codec *codec)
11461 struct alc_spec *spec = codec->spec;
11464 for (i = 0; i < AUTO_PIN_LAST; i++) {
11465 hda_nid_t nid = spec->autocfg.input_pins[i];
11466 if (alc662_is_input_pin(nid)) {
11467 snd_hda_codec_write(codec, nid, 0,
11468 AC_VERB_SET_PIN_WIDGET_CONTROL,
11469 (i <= AUTO_PIN_FRONT_MIC ?
11470 PIN_VREF80 : PIN_IN));
11471 if (nid != ALC662_PIN_CD_NID)
11472 snd_hda_codec_write(codec, nid, 0,
11473 AC_VERB_SET_AMP_GAIN_MUTE,
11479 static int alc662_parse_auto_config(struct hda_codec *codec)
11481 struct alc_spec *spec = codec->spec;
11483 static hda_nid_t alc662_ignore[] = { 0x1d, 0 };
11485 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
11489 if (!spec->autocfg.line_outs)
11490 return 0; /* can't find valid BIOS pin config */
11492 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
11495 err = alc662_auto_create_multi_out_ctls(spec, &spec->autocfg);
11498 err = alc662_auto_create_extra_out(spec,
11499 spec->autocfg.speaker_pins[0],
11503 err = alc662_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
11507 err = alc662_auto_create_analog_input_ctls(spec, &spec->autocfg);
11511 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
11513 if (spec->autocfg.dig_out_pin)
11514 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
11516 if (spec->kctl_alloc)
11517 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
11519 spec->num_mux_defs = 1;
11520 spec->input_mux = &spec->private_imux;
11522 spec->init_verbs[spec->num_init_verbs++] = alc662_auto_init_verbs;
11523 spec->mixers[spec->num_mixers] = alc662_capture_mixer;
11524 spec->num_mixers++;
11528 /* additional initialization for auto-configuration model */
11529 static void alc662_auto_init(struct hda_codec *codec)
11531 alc662_auto_init_multi_out(codec);
11532 alc662_auto_init_hp_out(codec);
11533 alc662_auto_init_analog_input(codec);
11536 static int patch_alc662(struct hda_codec *codec)
11538 struct alc_spec *spec;
11539 int err, board_config;
11541 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
11545 codec->spec = spec;
11547 board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST,
11550 if (board_config < 0) {
11551 printk(KERN_INFO "hda_codec: Unknown model for ALC662, "
11552 "trying auto-probe from BIOS...\n");
11553 board_config = ALC662_AUTO;
11556 if (board_config == ALC662_AUTO) {
11557 /* automatic parse from the BIOS config */
11558 err = alc662_parse_auto_config(codec);
11564 "hda_codec: Cannot set up configuration "
11565 "from BIOS. Using base mode...\n");
11566 board_config = ALC662_3ST_2ch_DIG;
11570 if (board_config != ALC662_AUTO)
11571 setup_preset(spec, &alc662_presets[board_config]);
11573 spec->stream_name_analog = "ALC662 Analog";
11574 spec->stream_analog_playback = &alc662_pcm_analog_playback;
11575 spec->stream_analog_capture = &alc662_pcm_analog_capture;
11577 spec->stream_name_digital = "ALC662 Digital";
11578 spec->stream_digital_playback = &alc662_pcm_digital_playback;
11579 spec->stream_digital_capture = &alc662_pcm_digital_capture;
11581 if (!spec->adc_nids && spec->input_mux) {
11582 spec->adc_nids = alc662_adc_nids;
11583 spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids);
11586 codec->patch_ops = alc_patch_ops;
11587 if (board_config == ALC662_AUTO)
11588 spec->init_hook = alc662_auto_init;
11596 struct hda_codec_preset snd_hda_preset_realtek[] = {
11597 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
11598 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
11599 { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 },
11600 { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
11601 .patch = patch_alc861 },
11602 { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
11603 { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
11604 { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
11605 { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2",
11606 .patch = patch_alc883 },
11607 { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
11608 .patch = patch_alc662 },
11609 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
11610 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
11611 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc883 },
11612 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
11613 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc883 },
11614 {} /* terminator */