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,
98 ALC262_MODEL_LAST /* last tag */
105 ALC268_MODEL_LAST /* last tag */
122 /* ALC861-VD models */
166 ALC883_TARGA_2ch_DIG,
171 ALC883_LENOVO_101E_2ch,
172 ALC883_LENOVO_NB0763,
173 ALC888_LENOVO_MS7195_DIG,
179 #define GPIO_MASK 0x03
182 /* codec parameterization */
183 struct snd_kcontrol_new *mixers[5]; /* mixer arrays */
184 unsigned int num_mixers;
186 const struct hda_verb *init_verbs[5]; /* initialization verbs
190 unsigned int num_init_verbs;
192 char *stream_name_analog; /* analog PCM stream */
193 struct hda_pcm_stream *stream_analog_playback;
194 struct hda_pcm_stream *stream_analog_capture;
196 char *stream_name_digital; /* digital PCM stream */
197 struct hda_pcm_stream *stream_digital_playback;
198 struct hda_pcm_stream *stream_digital_capture;
201 struct hda_multi_out multiout; /* playback set-up
202 * max_channels, dacs must be set
203 * dig_out_nid and hp_nid are optional
207 unsigned int num_adc_nids;
209 hda_nid_t dig_in_nid; /* digital-in NID; optional */
212 unsigned int num_mux_defs;
213 const struct hda_input_mux *input_mux;
214 unsigned int cur_mux[3];
217 const struct hda_channel_mode *channel_mode;
218 int num_channel_mode;
221 /* PCM information */
222 struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */
224 /* dynamic controls, init_verbs and input_mux */
225 struct auto_pin_cfg autocfg;
226 unsigned int num_kctl_alloc, num_kctl_used;
227 struct snd_kcontrol_new *kctl_alloc;
228 struct hda_input_mux private_imux;
229 hda_nid_t private_dac_nids[5];
232 void (*init_hook)(struct hda_codec *codec);
233 void (*unsol_event)(struct hda_codec *codec, unsigned int res);
235 /* for pin sensing */
236 unsigned int sense_updated: 1;
237 unsigned int jack_present: 1;
241 * configuration template - to be copied to the spec instance
243 struct alc_config_preset {
244 struct snd_kcontrol_new *mixers[5]; /* should be identical size
247 const struct hda_verb *init_verbs[5];
248 unsigned int num_dacs;
250 hda_nid_t dig_out_nid; /* optional */
251 hda_nid_t hp_nid; /* optional */
252 unsigned int num_adc_nids;
254 hda_nid_t dig_in_nid;
255 unsigned int num_channel_mode;
256 const struct hda_channel_mode *channel_mode;
258 unsigned int num_mux_defs;
259 const struct hda_input_mux *input_mux;
260 void (*unsol_event)(struct hda_codec *, unsigned int);
261 void (*init_hook)(struct hda_codec *);
268 static int alc_mux_enum_info(struct snd_kcontrol *kcontrol,
269 struct snd_ctl_elem_info *uinfo)
271 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
272 struct alc_spec *spec = codec->spec;
273 unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id);
274 if (mux_idx >= spec->num_mux_defs)
276 return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo);
279 static int alc_mux_enum_get(struct snd_kcontrol *kcontrol,
280 struct snd_ctl_elem_value *ucontrol)
282 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
283 struct alc_spec *spec = codec->spec;
284 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
286 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
290 static int alc_mux_enum_put(struct snd_kcontrol *kcontrol,
291 struct snd_ctl_elem_value *ucontrol)
293 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
294 struct alc_spec *spec = codec->spec;
295 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
296 unsigned int mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx;
297 return snd_hda_input_mux_put(codec, &spec->input_mux[mux_idx], ucontrol,
298 spec->adc_nids[adc_idx],
299 &spec->cur_mux[adc_idx]);
304 * channel mode setting
306 static int alc_ch_mode_info(struct snd_kcontrol *kcontrol,
307 struct snd_ctl_elem_info *uinfo)
309 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
310 struct alc_spec *spec = codec->spec;
311 return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
312 spec->num_channel_mode);
315 static int alc_ch_mode_get(struct snd_kcontrol *kcontrol,
316 struct snd_ctl_elem_value *ucontrol)
318 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
319 struct alc_spec *spec = codec->spec;
320 return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
321 spec->num_channel_mode,
322 spec->multiout.max_channels);
325 static int alc_ch_mode_put(struct snd_kcontrol *kcontrol,
326 struct snd_ctl_elem_value *ucontrol)
328 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
329 struct alc_spec *spec = codec->spec;
330 int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
331 spec->num_channel_mode,
332 &spec->multiout.max_channels);
333 if (err >= 0 && spec->need_dac_fix)
334 spec->multiout.num_dacs = spec->multiout.max_channels / 2;
339 * Control the mode of pin widget settings via the mixer. "pc" is used
340 * instead of "%" to avoid consequences of accidently treating the % as
341 * being part of a format specifier. Maximum allowed length of a value is
342 * 63 characters plus NULL terminator.
344 * Note: some retasking pin complexes seem to ignore requests for input
345 * states other than HiZ (eg: PIN_VREFxx) and revert to HiZ if any of these
346 * are requested. Therefore order this list so that this behaviour will not
347 * cause problems when mixer clients move through the enum sequentially.
348 * NIDs 0x0f and 0x10 have been observed to have this behaviour as of
351 static char *alc_pin_mode_names[] = {
352 "Mic 50pc bias", "Mic 80pc bias",
353 "Line in", "Line out", "Headphone out",
355 static unsigned char alc_pin_mode_values[] = {
356 PIN_VREF50, PIN_VREF80, PIN_IN, PIN_OUT, PIN_HP,
358 /* The control can present all 5 options, or it can limit the options based
359 * in the pin being assumed to be exclusively an input or an output pin. In
360 * addition, "input" pins may or may not process the mic bias option
361 * depending on actual widget capability (NIDs 0x0f and 0x10 don't seem to
362 * accept requests for bias as of chip versions up to March 2006) and/or
363 * wiring in the computer.
365 #define ALC_PIN_DIR_IN 0x00
366 #define ALC_PIN_DIR_OUT 0x01
367 #define ALC_PIN_DIR_INOUT 0x02
368 #define ALC_PIN_DIR_IN_NOMICBIAS 0x03
369 #define ALC_PIN_DIR_INOUT_NOMICBIAS 0x04
371 /* Info about the pin modes supported by the different pin direction modes.
372 * For each direction the minimum and maximum values are given.
374 static signed char alc_pin_mode_dir_info[5][2] = {
375 { 0, 2 }, /* ALC_PIN_DIR_IN */
376 { 3, 4 }, /* ALC_PIN_DIR_OUT */
377 { 0, 4 }, /* ALC_PIN_DIR_INOUT */
378 { 2, 2 }, /* ALC_PIN_DIR_IN_NOMICBIAS */
379 { 2, 4 }, /* ALC_PIN_DIR_INOUT_NOMICBIAS */
381 #define alc_pin_mode_min(_dir) (alc_pin_mode_dir_info[_dir][0])
382 #define alc_pin_mode_max(_dir) (alc_pin_mode_dir_info[_dir][1])
383 #define alc_pin_mode_n_items(_dir) \
384 (alc_pin_mode_max(_dir)-alc_pin_mode_min(_dir)+1)
386 static int alc_pin_mode_info(struct snd_kcontrol *kcontrol,
387 struct snd_ctl_elem_info *uinfo)
389 unsigned int item_num = uinfo->value.enumerated.item;
390 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
392 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
394 uinfo->value.enumerated.items = alc_pin_mode_n_items(dir);
396 if (item_num<alc_pin_mode_min(dir) || item_num>alc_pin_mode_max(dir))
397 item_num = alc_pin_mode_min(dir);
398 strcpy(uinfo->value.enumerated.name, alc_pin_mode_names[item_num]);
402 static int alc_pin_mode_get(struct snd_kcontrol *kcontrol,
403 struct snd_ctl_elem_value *ucontrol)
406 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
407 hda_nid_t nid = kcontrol->private_value & 0xffff;
408 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
409 long *valp = ucontrol->value.integer.value;
410 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
411 AC_VERB_GET_PIN_WIDGET_CONTROL,
414 /* Find enumerated value for current pinctl setting */
415 i = alc_pin_mode_min(dir);
416 while (alc_pin_mode_values[i] != pinctl && i <= alc_pin_mode_max(dir))
418 *valp = i <= alc_pin_mode_max(dir) ? i: alc_pin_mode_min(dir);
422 static int alc_pin_mode_put(struct snd_kcontrol *kcontrol,
423 struct snd_ctl_elem_value *ucontrol)
426 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
427 hda_nid_t nid = kcontrol->private_value & 0xffff;
428 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
429 long val = *ucontrol->value.integer.value;
430 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
431 AC_VERB_GET_PIN_WIDGET_CONTROL,
434 if (val < alc_pin_mode_min(dir) || val > alc_pin_mode_max(dir))
435 val = alc_pin_mode_min(dir);
437 change = pinctl != alc_pin_mode_values[val];
439 /* Set pin mode to that requested */
440 snd_hda_codec_write(codec,nid,0,AC_VERB_SET_PIN_WIDGET_CONTROL,
441 alc_pin_mode_values[val]);
443 /* Also enable the retasking pin's input/output as required
444 * for the requested pin mode. Enum values of 2 or less are
447 * Dynamically switching the input/output buffers probably
448 * reduces noise slightly (particularly on input) so we'll
449 * do it. However, having both input and output buffers
450 * enabled simultaneously doesn't seem to be problematic if
451 * this turns out to be necessary in the future.
454 snd_hda_codec_write(codec, nid, 0,
455 AC_VERB_SET_AMP_GAIN_MUTE,
457 snd_hda_codec_write(codec, nid, 0,
458 AC_VERB_SET_AMP_GAIN_MUTE,
461 snd_hda_codec_write(codec, nid, 0,
462 AC_VERB_SET_AMP_GAIN_MUTE,
464 snd_hda_codec_write(codec, nid, 0,
465 AC_VERB_SET_AMP_GAIN_MUTE,
472 #define ALC_PIN_MODE(xname, nid, dir) \
473 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
474 .info = alc_pin_mode_info, \
475 .get = alc_pin_mode_get, \
476 .put = alc_pin_mode_put, \
477 .private_value = nid | (dir<<16) }
479 /* A switch control for ALC260 GPIO pins. Multiple GPIOs can be ganged
480 * together using a mask with more than one bit set. This control is
481 * currently used only by the ALC260 test model. At this stage they are not
482 * needed for any "production" models.
484 #ifdef CONFIG_SND_DEBUG
485 static int alc_gpio_data_info(struct snd_kcontrol *kcontrol,
486 struct snd_ctl_elem_info *uinfo)
488 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
490 uinfo->value.integer.min = 0;
491 uinfo->value.integer.max = 1;
495 static int alc_gpio_data_get(struct snd_kcontrol *kcontrol,
496 struct snd_ctl_elem_value *ucontrol)
498 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
499 hda_nid_t nid = kcontrol->private_value & 0xffff;
500 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
501 long *valp = ucontrol->value.integer.value;
502 unsigned int val = snd_hda_codec_read(codec, nid, 0,
503 AC_VERB_GET_GPIO_DATA, 0x00);
505 *valp = (val & mask) != 0;
508 static int alc_gpio_data_put(struct snd_kcontrol *kcontrol,
509 struct snd_ctl_elem_value *ucontrol)
512 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
513 hda_nid_t nid = kcontrol->private_value & 0xffff;
514 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
515 long val = *ucontrol->value.integer.value;
516 unsigned int gpio_data = snd_hda_codec_read(codec, nid, 0,
517 AC_VERB_GET_GPIO_DATA,
520 /* Set/unset the masked GPIO bit(s) as needed */
521 change = (val == 0 ? 0 : mask) != (gpio_data & mask);
526 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_GPIO_DATA, gpio_data);
530 #define ALC_GPIO_DATA_SWITCH(xname, nid, mask) \
531 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
532 .info = alc_gpio_data_info, \
533 .get = alc_gpio_data_get, \
534 .put = alc_gpio_data_put, \
535 .private_value = nid | (mask<<16) }
536 #endif /* CONFIG_SND_DEBUG */
538 /* A switch control to allow the enabling of the digital IO pins on the
539 * ALC260. This is incredibly simplistic; the intention of this control is
540 * to provide something in the test model allowing digital outputs to be
541 * identified if present. If models are found which can utilise these
542 * outputs a more complete mixer control can be devised for those models if
545 #ifdef CONFIG_SND_DEBUG
546 static int alc_spdif_ctrl_info(struct snd_kcontrol *kcontrol,
547 struct snd_ctl_elem_info *uinfo)
549 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
551 uinfo->value.integer.min = 0;
552 uinfo->value.integer.max = 1;
556 static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol,
557 struct snd_ctl_elem_value *ucontrol)
559 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
560 hda_nid_t nid = kcontrol->private_value & 0xffff;
561 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
562 long *valp = ucontrol->value.integer.value;
563 unsigned int val = snd_hda_codec_read(codec, nid, 0,
564 AC_VERB_GET_DIGI_CONVERT, 0x00);
566 *valp = (val & mask) != 0;
569 static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol,
570 struct snd_ctl_elem_value *ucontrol)
573 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
574 hda_nid_t nid = kcontrol->private_value & 0xffff;
575 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
576 long val = *ucontrol->value.integer.value;
577 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
578 AC_VERB_GET_DIGI_CONVERT,
581 /* Set/unset the masked control bit(s) as needed */
582 change = (val == 0 ? 0 : mask) != (ctrl_data & mask);
587 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1,
592 #define ALC_SPDIF_CTRL_SWITCH(xname, nid, mask) \
593 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
594 .info = alc_spdif_ctrl_info, \
595 .get = alc_spdif_ctrl_get, \
596 .put = alc_spdif_ctrl_put, \
597 .private_value = nid | (mask<<16) }
598 #endif /* CONFIG_SND_DEBUG */
601 * set up from the preset table
603 static void setup_preset(struct alc_spec *spec,
604 const struct alc_config_preset *preset)
608 for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++)
609 spec->mixers[spec->num_mixers++] = preset->mixers[i];
610 for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i];
612 spec->init_verbs[spec->num_init_verbs++] =
613 preset->init_verbs[i];
615 spec->channel_mode = preset->channel_mode;
616 spec->num_channel_mode = preset->num_channel_mode;
617 spec->need_dac_fix = preset->need_dac_fix;
619 spec->multiout.max_channels = spec->channel_mode[0].channels;
621 spec->multiout.num_dacs = preset->num_dacs;
622 spec->multiout.dac_nids = preset->dac_nids;
623 spec->multiout.dig_out_nid = preset->dig_out_nid;
624 spec->multiout.hp_nid = preset->hp_nid;
626 spec->num_mux_defs = preset->num_mux_defs;
627 if (!spec->num_mux_defs)
628 spec->num_mux_defs = 1;
629 spec->input_mux = preset->input_mux;
631 spec->num_adc_nids = preset->num_adc_nids;
632 spec->adc_nids = preset->adc_nids;
633 spec->dig_in_nid = preset->dig_in_nid;
635 spec->unsol_event = preset->unsol_event;
636 spec->init_hook = preset->init_hook;
639 /* Enable GPIO mask and set output */
640 static struct hda_verb alc_gpio1_init_verbs[] = {
641 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
642 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
643 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
647 static struct hda_verb alc_gpio2_init_verbs[] = {
648 {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
649 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
650 {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
654 static struct hda_verb alc_gpio3_init_verbs[] = {
655 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
656 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
657 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
661 /* 32-bit subsystem ID for BIOS loading in HD Audio codec.
662 * 31 ~ 16 : Manufacture ID
664 * 7 ~ 0 : Assembly ID
665 * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36
667 static void alc_subsystem_id(struct hda_codec *codec,
668 unsigned int porta, unsigned int porte,
671 unsigned int ass, tmp;
673 ass = codec->subsystem_id;
678 tmp = (ass & 0x38) >> 3; /* external Amp control */
681 snd_hda_sequence_write(codec, alc_gpio1_init_verbs);
684 snd_hda_sequence_write(codec, alc_gpio2_init_verbs);
687 snd_hda_sequence_write(codec, alc_gpio3_init_verbs);
690 switch (codec->vendor_id) {
696 snd_hda_codec_write(codec, 0x14, 0,
697 AC_VERB_SET_EAPD_BTLENABLE, 2);
698 snd_hda_codec_write(codec, 0x15, 0,
699 AC_VERB_SET_EAPD_BTLENABLE, 2);
703 if (ass & 4) { /* bit 2 : 0 = Desktop, 1 = Laptop */
705 tmp = (ass & 0x1800) >> 11;
707 case 0: port = porta; break;
708 case 1: port = porte; break;
709 case 2: port = portd; break;
712 snd_hda_codec_write(codec, port, 0,
713 AC_VERB_SET_EAPD_BTLENABLE,
716 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
717 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF,
718 (tmp == 5 ? 0x3040 : 0x3050));
724 * ALC880 3-stack model
726 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
727 * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18,
728 * F-Mic = 0x1b, HP = 0x19
731 static hda_nid_t alc880_dac_nids[4] = {
732 /* front, rear, clfe, rear_surr */
733 0x02, 0x05, 0x04, 0x03
736 static hda_nid_t alc880_adc_nids[3] = {
741 /* The datasheet says the node 0x07 is connected from inputs,
742 * but it shows zero connection in the real implementation on some devices.
743 * Note: this is a 915GAV bug, fixed on 915GLV
745 static hda_nid_t alc880_adc_nids_alt[2] = {
750 #define ALC880_DIGOUT_NID 0x06
751 #define ALC880_DIGIN_NID 0x0a
753 static struct hda_input_mux alc880_capture_source = {
757 { "Front Mic", 0x3 },
763 /* channel source setting (2/6 channel selection for 3-stack) */
765 static struct hda_verb alc880_threestack_ch2_init[] = {
766 /* set line-in to input, mute it */
767 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
768 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
769 /* set mic-in to input vref 80%, mute it */
770 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
771 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
776 static struct hda_verb alc880_threestack_ch6_init[] = {
777 /* set line-in to output, unmute it */
778 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
779 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
780 /* set mic-in to output, unmute it */
781 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
782 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
786 static struct hda_channel_mode alc880_threestack_modes[2] = {
787 { 2, alc880_threestack_ch2_init },
788 { 6, alc880_threestack_ch6_init },
791 static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
792 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
793 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
794 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
795 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
796 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
797 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
798 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
799 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
800 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
801 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
802 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
803 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
804 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
805 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
806 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
807 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
808 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
809 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
810 HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
812 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
813 .name = "Channel Mode",
814 .info = alc_ch_mode_info,
815 .get = alc_ch_mode_get,
816 .put = alc_ch_mode_put,
821 /* capture mixer elements */
822 static struct snd_kcontrol_new alc880_capture_mixer[] = {
823 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
824 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
825 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
826 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
827 HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
828 HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
830 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
831 /* The multiple "Capture Source" controls confuse alsamixer
832 * So call somewhat different..
833 * FIXME: the controls appear in the "playback" view!
835 /* .name = "Capture Source", */
836 .name = "Input Source",
838 .info = alc_mux_enum_info,
839 .get = alc_mux_enum_get,
840 .put = alc_mux_enum_put,
845 /* capture mixer elements (in case NID 0x07 not available) */
846 static struct snd_kcontrol_new alc880_capture_alt_mixer[] = {
847 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
848 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
849 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
850 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
852 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
853 /* The multiple "Capture Source" controls confuse alsamixer
854 * So call somewhat different..
855 * FIXME: the controls appear in the "playback" view!
857 /* .name = "Capture Source", */
858 .name = "Input Source",
860 .info = alc_mux_enum_info,
861 .get = alc_mux_enum_get,
862 .put = alc_mux_enum_put,
870 * ALC880 5-stack model
872 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d),
874 * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
875 * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
878 /* additional mixers to alc880_three_stack_mixer */
879 static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
880 HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
881 HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
885 /* channel source setting (6/8 channel selection for 5-stack) */
887 static struct hda_verb alc880_fivestack_ch6_init[] = {
888 /* set line-in to input, mute it */
889 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
890 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
895 static struct hda_verb alc880_fivestack_ch8_init[] = {
896 /* set line-in to output, unmute it */
897 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
898 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
902 static struct hda_channel_mode alc880_fivestack_modes[2] = {
903 { 6, alc880_fivestack_ch6_init },
904 { 8, alc880_fivestack_ch8_init },
909 * ALC880 6-stack model
911 * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e),
913 * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
914 * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
917 static hda_nid_t alc880_6st_dac_nids[4] = {
918 /* front, rear, clfe, rear_surr */
919 0x02, 0x03, 0x04, 0x05
922 static struct hda_input_mux alc880_6stack_capture_source = {
926 { "Front Mic", 0x1 },
932 /* fixed 8-channels */
933 static struct hda_channel_mode alc880_sixstack_modes[1] = {
937 static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
938 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
939 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
940 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
941 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
942 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
943 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
944 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
945 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
946 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
947 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
948 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
949 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
950 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
951 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
952 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
953 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
954 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
955 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
956 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
957 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
959 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
960 .name = "Channel Mode",
961 .info = alc_ch_mode_info,
962 .get = alc_ch_mode_get,
963 .put = alc_ch_mode_put,
972 * W810 has rear IO for:
975 * Center/LFE (DAC 04)
978 * The system also has a pair of internal speakers, and a headphone jack.
979 * These are both connected to Line2 on the codec, hence to DAC 02.
981 * There is a variable resistor to control the speaker or headphone
982 * volume. This is a hardware-only device without a software API.
984 * Plugging headphones in will disable the internal speakers. This is
985 * implemented in hardware, not via the driver using jack sense. In
986 * a similar fashion, plugging into the rear socket marked "front" will
987 * disable both the speakers and headphones.
989 * For input, there's a microphone jack, and an "audio in" jack.
990 * These may not do anything useful with this driver yet, because I
991 * haven't setup any initialization verbs for these yet...
994 static hda_nid_t alc880_w810_dac_nids[3] = {
995 /* front, rear/surround, clfe */
999 /* fixed 6 channels */
1000 static struct hda_channel_mode alc880_w810_modes[1] = {
1004 /* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
1005 static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
1006 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1007 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1008 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1009 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
1010 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1011 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1012 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1013 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1014 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
1022 * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
1023 * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?),
1027 static hda_nid_t alc880_z71v_dac_nids[1] = {
1030 #define ALC880_Z71V_HP_DAC 0x03
1032 /* fixed 2 channels */
1033 static struct hda_channel_mode alc880_2_jack_modes[1] = {
1037 static struct snd_kcontrol_new alc880_z71v_mixer[] = {
1038 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1039 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1040 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1041 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
1042 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1043 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1044 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1045 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1052 * ALC880 F1734 model
1054 * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
1055 * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
1058 static hda_nid_t alc880_f1734_dac_nids[1] = {
1061 #define ALC880_F1734_HP_DAC 0x02
1063 static struct snd_kcontrol_new alc880_f1734_mixer[] = {
1064 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1065 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
1066 HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1067 HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
1068 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1069 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1070 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1071 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1080 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
1081 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
1082 * Mic = 0x18, Line = 0x1a
1085 #define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
1086 #define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
1088 static struct snd_kcontrol_new alc880_asus_mixer[] = {
1089 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1090 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1091 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1092 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
1093 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1094 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1095 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1096 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1097 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1098 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1099 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1100 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1101 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1102 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1104 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1105 .name = "Channel Mode",
1106 .info = alc_ch_mode_info,
1107 .get = alc_ch_mode_get,
1108 .put = alc_ch_mode_put,
1115 * ALC880 ASUS W1V model
1117 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
1118 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
1119 * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
1122 /* additional mixers to alc880_asus_mixer */
1123 static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
1124 HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
1125 HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
1129 /* additional mixers to alc880_asus_mixer */
1130 static struct snd_kcontrol_new alc880_pcbeep_mixer[] = {
1131 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1132 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
1137 static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
1138 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1139 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
1140 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
1141 HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
1142 HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
1143 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
1144 HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
1145 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
1146 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
1148 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1149 /* The multiple "Capture Source" controls confuse alsamixer
1150 * So call somewhat different..
1151 * FIXME: the controls appear in the "playback" view!
1153 /* .name = "Capture Source", */
1154 .name = "Input Source",
1156 .info = alc_mux_enum_info,
1157 .get = alc_mux_enum_get,
1158 .put = alc_mux_enum_put,
1164 static struct snd_kcontrol_new alc880_uniwill_mixer[] = {
1165 HDA_CODEC_VOLUME("HPhone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1166 HDA_BIND_MUTE("HPhone Playback Switch", 0x0c, 2, HDA_INPUT),
1167 HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1168 HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT),
1169 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1170 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1171 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1172 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1173 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1174 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1175 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1176 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1177 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1178 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1179 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1180 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1181 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1182 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
1184 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1185 .name = "Channel Mode",
1186 .info = alc_ch_mode_info,
1187 .get = alc_ch_mode_get,
1188 .put = alc_ch_mode_put,
1193 static struct snd_kcontrol_new alc880_fujitsu_mixer[] = {
1194 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1195 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
1196 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1197 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
1198 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1199 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1200 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1201 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1202 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1203 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1207 static struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = {
1208 HDA_CODEC_VOLUME("HPhone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1209 HDA_BIND_MUTE("HPhone Playback Switch", 0x0c, 2, HDA_INPUT),
1210 HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1211 HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT),
1212 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1213 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1218 * build control elements
1220 static int alc_build_controls(struct hda_codec *codec)
1222 struct alc_spec *spec = codec->spec;
1226 for (i = 0; i < spec->num_mixers; i++) {
1227 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
1232 if (spec->multiout.dig_out_nid) {
1233 err = snd_hda_create_spdif_out_ctls(codec,
1234 spec->multiout.dig_out_nid);
1238 if (spec->dig_in_nid) {
1239 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
1248 * initialize the codec volumes, etc
1252 * generic initialization of ADC, input mixers and output mixers
1254 static struct hda_verb alc880_volume_init_verbs[] = {
1256 * Unmute ADC0-2 and set the default input to mic-in
1258 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
1259 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1260 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
1261 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1262 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
1263 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1265 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
1267 * Note: PASD motherboards uses the Line In 2 as the input for front
1270 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
1271 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1272 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1273 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
1274 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
1275 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
1278 * Set up output mixers (0x0c - 0x0f)
1280 /* set vol=0 to output mixers */
1281 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1282 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1283 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1284 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1285 /* set up input amps for analog loopback */
1286 /* Amp Indices: DAC = 0, mixer = 1 */
1287 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1288 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1289 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1290 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1291 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1292 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1293 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1294 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1300 * 3-stack pin configuration:
1301 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
1303 static struct hda_verb alc880_pin_3stack_init_verbs[] = {
1305 * preset connection lists of input pins
1306 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
1308 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
1309 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1310 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
1313 * Set pin mode and muting
1315 /* set front pin widgets 0x14 for output */
1316 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1317 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1318 /* Mic1 (rear panel) pin widget for input and vref at 80% */
1319 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1320 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1321 /* Mic2 (as headphone out) for HP output */
1322 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1323 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1324 /* Line In pin widget for input */
1325 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1326 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1327 /* Line2 (as front mic) pin widget for input and vref at 80% */
1328 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1329 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1330 /* CD pin widget for input */
1331 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1337 * 5-stack pin configuration:
1338 * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
1339 * line-in/side = 0x1a, f-mic = 0x1b
1341 static struct hda_verb alc880_pin_5stack_init_verbs[] = {
1343 * preset connection lists of input pins
1344 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
1346 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1347 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
1350 * Set pin mode and muting
1352 /* set pin widgets 0x14-0x17 for output */
1353 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1354 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1355 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1356 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1357 /* unmute pins for output (no gain on this amp) */
1358 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1359 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1360 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1361 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1363 /* Mic1 (rear panel) pin widget for input and vref at 80% */
1364 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1365 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1366 /* Mic2 (as headphone out) for HP output */
1367 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1368 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1369 /* Line In pin widget for input */
1370 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1371 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1372 /* Line2 (as front mic) pin widget for input and vref at 80% */
1373 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1374 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1375 /* CD pin widget for input */
1376 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1382 * W810 pin configuration:
1383 * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
1385 static struct hda_verb alc880_pin_w810_init_verbs[] = {
1386 /* hphone/speaker input selector: front DAC */
1387 {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
1389 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1390 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1391 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1392 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1393 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1394 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1396 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1397 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1403 * Z71V pin configuration:
1404 * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
1406 static struct hda_verb alc880_pin_z71v_init_verbs[] = {
1407 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1408 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1409 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1410 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1412 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1413 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1414 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1415 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1421 * 6-stack pin configuration:
1422 * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18,
1423 * f-mic = 0x19, line = 0x1a, HP = 0x1b
1425 static struct hda_verb alc880_pin_6stack_init_verbs[] = {
1426 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1428 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1429 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1430 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1431 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1432 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1433 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1434 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1435 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1437 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1438 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1439 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1440 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1441 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1442 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1443 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1444 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1445 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1451 * Uniwill pin configuration:
1452 * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19,
1455 static struct hda_verb alc880_uniwill_init_verbs[] = {
1456 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1458 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1459 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1460 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1461 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1462 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1463 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1464 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1465 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1466 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1467 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1468 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1469 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1470 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1471 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
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},
1483 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
1484 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
1491 * HP = 0x14, InternalSpeaker = 0x15, mic = 0x19,
1493 static struct hda_verb alc880_uniwill_p53_init_verbs[] = {
1494 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1496 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1497 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1498 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1499 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1500 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1501 {0x16, 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},
1516 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
1517 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_DCVOL_EVENT},
1522 static struct hda_verb alc880_beep_init_verbs[] = {
1523 { 0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5) },
1527 /* toggle speaker-output according to the hp-jack state */
1528 static void alc880_uniwill_hp_automute(struct hda_codec *codec)
1530 unsigned int present;
1533 present = snd_hda_codec_read(codec, 0x14, 0,
1534 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1535 bits = present ? 0x80 : 0;
1536 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
1538 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
1540 snd_hda_codec_amp_update(codec, 0x16, 0, HDA_OUTPUT, 0,
1542 snd_hda_codec_amp_update(codec, 0x16, 1, HDA_OUTPUT, 0,
1546 /* auto-toggle front mic */
1547 static void alc880_uniwill_mic_automute(struct hda_codec *codec)
1549 unsigned int present;
1552 present = snd_hda_codec_read(codec, 0x18, 0,
1553 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1554 bits = present ? 0x80 : 0;
1555 snd_hda_codec_amp_update(codec, 0x0b, 0, HDA_INPUT, 1,
1557 snd_hda_codec_amp_update(codec, 0x0b, 1, HDA_INPUT, 1,
1561 static void alc880_uniwill_automute(struct hda_codec *codec)
1563 alc880_uniwill_hp_automute(codec);
1564 alc880_uniwill_mic_automute(codec);
1567 static void alc880_uniwill_unsol_event(struct hda_codec *codec,
1570 /* Looks like the unsol event is incompatible with the standard
1571 * definition. 4bit tag is placed at 28 bit!
1573 switch (res >> 28) {
1574 case ALC880_HP_EVENT:
1575 alc880_uniwill_hp_automute(codec);
1577 case ALC880_MIC_EVENT:
1578 alc880_uniwill_mic_automute(codec);
1583 static void alc880_uniwill_p53_hp_automute(struct hda_codec *codec)
1585 unsigned int present;
1588 present = snd_hda_codec_read(codec, 0x14, 0,
1589 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1590 bits = present ? 0x80 : 0;
1591 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_INPUT, 0,
1593 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_INPUT, 0,
1597 static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec)
1599 unsigned int present;
1601 present = snd_hda_codec_read(codec, 0x21, 0,
1602 AC_VERB_GET_VOLUME_KNOB_CONTROL, 0) & 0x7f;
1604 snd_hda_codec_amp_update(codec, 0x0c, 0, HDA_OUTPUT, 0,
1606 snd_hda_codec_amp_update(codec, 0x0c, 1, HDA_OUTPUT, 0,
1609 snd_hda_codec_amp_update(codec, 0x0d, 0, HDA_OUTPUT, 0,
1611 snd_hda_codec_amp_update(codec, 0x0d, 1, HDA_OUTPUT, 0,
1615 static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec,
1618 /* Looks like the unsol event is incompatible with the standard
1619 * definition. 4bit tag is placed at 28 bit!
1621 if ((res >> 28) == ALC880_HP_EVENT)
1622 alc880_uniwill_p53_hp_automute(codec);
1623 if ((res >> 28) == ALC880_DCVOL_EVENT)
1624 alc880_uniwill_p53_dcvol_automute(codec);
1629 * F1734 pin configuration:
1630 * HP = 0x14, speaker-out = 0x15, mic = 0x18
1632 static struct hda_verb alc880_pin_f1734_init_verbs[] = {
1633 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
1634 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
1635 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
1636 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
1638 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1639 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1640 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1641 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1643 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1644 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1645 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1646 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1647 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1648 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1649 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1650 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1651 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1658 * ASUS pin configuration:
1659 * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
1661 static struct hda_verb alc880_pin_asus_init_verbs[] = {
1662 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
1663 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
1664 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
1665 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
1667 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1668 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1669 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1670 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1671 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1672 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1673 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1674 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1676 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1677 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1678 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1679 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1680 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1681 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1682 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1683 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1684 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1689 /* Enable GPIO mask and set output */
1690 #define alc880_gpio1_init_verbs alc_gpio1_init_verbs
1691 #define alc880_gpio2_init_verbs alc_gpio2_init_verbs
1693 /* Clevo m520g init */
1694 static struct hda_verb alc880_pin_clevo_init_verbs[] = {
1695 /* headphone output */
1696 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
1698 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1699 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1701 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1702 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1704 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1705 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1706 /* Mic1 (rear panel) */
1707 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1708 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1709 /* Mic2 (front panel) */
1710 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1711 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1713 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1714 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1715 /* change to EAPD mode */
1716 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
1717 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
1722 static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
1723 /* change to EAPD mode */
1724 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
1725 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
1727 /* Headphone output */
1728 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1730 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1731 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
1733 /* Line In pin widget for input */
1734 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1735 /* CD pin widget for input */
1736 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1737 /* Mic1 (rear panel) pin widget for input and vref at 80% */
1738 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1740 /* change to EAPD mode */
1741 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
1742 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
1748 * LG m1 express dual
1751 * Rear Line-In/Out (blue): 0x14
1752 * Build-in Mic-In: 0x15
1754 * HP-Out (green): 0x1b
1755 * Mic-In/Out (red): 0x19
1759 /* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
1760 static hda_nid_t alc880_lg_dac_nids[3] = {
1764 /* seems analog CD is not working */
1765 static struct hda_input_mux alc880_lg_capture_source = {
1770 { "Internal Mic", 0x6 },
1774 /* 2,4,6 channel modes */
1775 static struct hda_verb alc880_lg_ch2_init[] = {
1776 /* set line-in and mic-in to input */
1777 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1778 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1782 static struct hda_verb alc880_lg_ch4_init[] = {
1783 /* set line-in to out and mic-in to input */
1784 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
1785 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1789 static struct hda_verb alc880_lg_ch6_init[] = {
1790 /* set line-in and mic-in to output */
1791 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
1792 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
1796 static struct hda_channel_mode alc880_lg_ch_modes[3] = {
1797 { 2, alc880_lg_ch2_init },
1798 { 4, alc880_lg_ch4_init },
1799 { 6, alc880_lg_ch6_init },
1802 static struct snd_kcontrol_new alc880_lg_mixer[] = {
1803 /* FIXME: it's not really "master" but front channels */
1804 HDA_CODEC_VOLUME("Master Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
1805 HDA_BIND_MUTE("Master Playback Switch", 0x0f, 2, HDA_INPUT),
1806 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1807 HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
1808 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
1809 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
1810 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
1811 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
1812 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1813 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1814 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
1815 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
1816 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
1817 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
1819 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1820 .name = "Channel Mode",
1821 .info = alc_ch_mode_info,
1822 .get = alc_ch_mode_get,
1823 .put = alc_ch_mode_put,
1828 static struct hda_verb alc880_lg_init_verbs[] = {
1829 /* set capture source to mic-in */
1830 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1831 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1832 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1833 /* mute all amp mixer inputs */
1834 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
1835 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(6)},
1836 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(7)},
1837 /* line-in to input */
1838 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1839 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1841 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1842 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1844 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1845 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1846 /* mic-in to input */
1847 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
1848 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1849 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1851 {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
1852 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1853 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1855 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
1859 /* toggle speaker-output according to the hp-jack state */
1860 static void alc880_lg_automute(struct hda_codec *codec)
1862 unsigned int present;
1865 present = snd_hda_codec_read(codec, 0x1b, 0,
1866 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1867 bits = present ? 0x80 : 0;
1868 snd_hda_codec_amp_update(codec, 0x17, 0, HDA_OUTPUT, 0,
1870 snd_hda_codec_amp_update(codec, 0x17, 1, HDA_OUTPUT, 0,
1874 static void alc880_lg_unsol_event(struct hda_codec *codec, unsigned int res)
1876 /* Looks like the unsol event is incompatible with the standard
1877 * definition. 4bit tag is placed at 28 bit!
1879 if ((res >> 28) == 0x01)
1880 alc880_lg_automute(codec);
1889 * Built-in Mic-In: 0x19 (?)
1894 /* seems analog CD is not working */
1895 static struct hda_input_mux alc880_lg_lw_capture_source = {
1899 { "Internal Mic", 0x1 },
1903 static struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
1904 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1905 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
1906 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1907 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1908 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
1909 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
1913 static struct hda_verb alc880_lg_lw_init_verbs[] = {
1914 /* set capture source to mic-in */
1915 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1916 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1917 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1918 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(7)},
1920 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1921 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1923 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
1924 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1925 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1926 /* mic-in to input */
1927 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1928 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1930 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1931 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1933 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
1937 /* toggle speaker-output according to the hp-jack state */
1938 static void alc880_lg_lw_automute(struct hda_codec *codec)
1940 unsigned int present;
1943 present = snd_hda_codec_read(codec, 0x1b, 0,
1944 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1945 bits = present ? 0x80 : 0;
1946 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
1948 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
1952 static void alc880_lg_lw_unsol_event(struct hda_codec *codec, unsigned int res)
1954 /* Looks like the unsol event is incompatible with the standard
1955 * definition. 4bit tag is placed at 28 bit!
1957 if ((res >> 28) == 0x01)
1958 alc880_lg_lw_automute(codec);
1965 static int alc_init(struct hda_codec *codec)
1967 struct alc_spec *spec = codec->spec;
1970 for (i = 0; i < spec->num_init_verbs; i++)
1971 snd_hda_sequence_write(codec, spec->init_verbs[i]);
1973 if (spec->init_hook)
1974 spec->init_hook(codec);
1979 static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
1981 struct alc_spec *spec = codec->spec;
1983 if (spec->unsol_event)
1984 spec->unsol_event(codec, res);
1991 static int alc_resume(struct hda_codec *codec)
1993 struct alc_spec *spec = codec->spec;
1997 for (i = 0; i < spec->num_mixers; i++)
1998 snd_hda_resume_ctls(codec, spec->mixers[i]);
1999 if (spec->multiout.dig_out_nid)
2000 snd_hda_resume_spdif_out(codec);
2001 if (spec->dig_in_nid)
2002 snd_hda_resume_spdif_in(codec);
2009 * Analog playback callbacks
2011 static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
2012 struct hda_codec *codec,
2013 struct snd_pcm_substream *substream)
2015 struct alc_spec *spec = codec->spec;
2016 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream);
2019 static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2020 struct hda_codec *codec,
2021 unsigned int stream_tag,
2022 unsigned int format,
2023 struct snd_pcm_substream *substream)
2025 struct alc_spec *spec = codec->spec;
2026 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
2027 stream_tag, format, substream);
2030 static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
2031 struct hda_codec *codec,
2032 struct snd_pcm_substream *substream)
2034 struct alc_spec *spec = codec->spec;
2035 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
2041 static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
2042 struct hda_codec *codec,
2043 struct snd_pcm_substream *substream)
2045 struct alc_spec *spec = codec->spec;
2046 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
2049 static int alc880_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2050 struct hda_codec *codec,
2051 unsigned int stream_tag,
2052 unsigned int format,
2053 struct snd_pcm_substream *substream)
2055 struct alc_spec *spec = codec->spec;
2056 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
2057 stream_tag, format, substream);
2060 static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
2061 struct hda_codec *codec,
2062 struct snd_pcm_substream *substream)
2064 struct alc_spec *spec = codec->spec;
2065 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
2071 static int alc880_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
2072 struct hda_codec *codec,
2073 unsigned int stream_tag,
2074 unsigned int format,
2075 struct snd_pcm_substream *substream)
2077 struct alc_spec *spec = codec->spec;
2079 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
2080 stream_tag, 0, format);
2084 static int alc880_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
2085 struct hda_codec *codec,
2086 struct snd_pcm_substream *substream)
2088 struct alc_spec *spec = codec->spec;
2090 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
2098 static struct hda_pcm_stream alc880_pcm_analog_playback = {
2102 /* NID is set in alc_build_pcms */
2104 .open = alc880_playback_pcm_open,
2105 .prepare = alc880_playback_pcm_prepare,
2106 .cleanup = alc880_playback_pcm_cleanup
2110 static struct hda_pcm_stream alc880_pcm_analog_capture = {
2114 /* NID is set in alc_build_pcms */
2116 .prepare = alc880_capture_pcm_prepare,
2117 .cleanup = alc880_capture_pcm_cleanup
2121 static struct hda_pcm_stream alc880_pcm_digital_playback = {
2125 /* NID is set in alc_build_pcms */
2127 .open = alc880_dig_playback_pcm_open,
2128 .close = alc880_dig_playback_pcm_close,
2129 .prepare = alc880_dig_playback_pcm_prepare
2133 static struct hda_pcm_stream alc880_pcm_digital_capture = {
2137 /* NID is set in alc_build_pcms */
2140 /* Used by alc_build_pcms to flag that a PCM has no playback stream */
2141 static struct hda_pcm_stream alc_pcm_null_playback = {
2147 static int alc_build_pcms(struct hda_codec *codec)
2149 struct alc_spec *spec = codec->spec;
2150 struct hda_pcm *info = spec->pcm_rec;
2153 codec->num_pcms = 1;
2154 codec->pcm_info = info;
2156 info->name = spec->stream_name_analog;
2157 if (spec->stream_analog_playback) {
2158 snd_assert(spec->multiout.dac_nids, return -EINVAL);
2159 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
2160 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
2162 if (spec->stream_analog_capture) {
2163 snd_assert(spec->adc_nids, return -EINVAL);
2164 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
2165 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
2168 if (spec->channel_mode) {
2169 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
2170 for (i = 0; i < spec->num_channel_mode; i++) {
2171 if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
2172 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
2177 /* SPDIF for stream index #1 */
2178 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
2179 codec->num_pcms = 2;
2180 info = spec->pcm_rec + 1;
2181 info->name = spec->stream_name_digital;
2182 if (spec->multiout.dig_out_nid &&
2183 spec->stream_digital_playback) {
2184 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
2185 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
2187 if (spec->dig_in_nid &&
2188 spec->stream_digital_capture) {
2189 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
2190 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
2194 /* If the use of more than one ADC is requested for the current
2195 * model, configure a second analog capture-only PCM.
2197 /* Additional Analaog capture for index #2 */
2198 if (spec->num_adc_nids > 1 && spec->stream_analog_capture &&
2200 codec->num_pcms = 3;
2201 info = spec->pcm_rec + 2;
2202 info->name = spec->stream_name_analog;
2203 /* No playback stream for second PCM */
2204 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = alc_pcm_null_playback;
2205 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
2206 if (spec->stream_analog_capture) {
2207 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
2208 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[1];
2215 static void alc_free(struct hda_codec *codec)
2217 struct alc_spec *spec = codec->spec;
2223 if (spec->kctl_alloc) {
2224 for (i = 0; i < spec->num_kctl_used; i++)
2225 kfree(spec->kctl_alloc[i].name);
2226 kfree(spec->kctl_alloc);
2233 static struct hda_codec_ops alc_patch_ops = {
2234 .build_controls = alc_build_controls,
2235 .build_pcms = alc_build_pcms,
2238 .unsol_event = alc_unsol_event,
2240 .resume = alc_resume,
2246 * Test configuration for debugging
2248 * Almost all inputs/outputs are enabled. I/O pins can be configured via
2251 #ifdef CONFIG_SND_DEBUG
2252 static hda_nid_t alc880_test_dac_nids[4] = {
2253 0x02, 0x03, 0x04, 0x05
2256 static struct hda_input_mux alc880_test_capture_source = {
2265 { "Surround", 0x6 },
2269 static struct hda_channel_mode alc880_test_modes[4] = {
2276 static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol,
2277 struct snd_ctl_elem_info *uinfo)
2279 static char *texts[] = {
2280 "N/A", "Line Out", "HP Out",
2281 "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
2283 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
2285 uinfo->value.enumerated.items = 8;
2286 if (uinfo->value.enumerated.item >= 8)
2287 uinfo->value.enumerated.item = 7;
2288 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
2292 static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol,
2293 struct snd_ctl_elem_value *ucontrol)
2295 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2296 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2297 unsigned int pin_ctl, item = 0;
2299 pin_ctl = snd_hda_codec_read(codec, nid, 0,
2300 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
2301 if (pin_ctl & AC_PINCTL_OUT_EN) {
2302 if (pin_ctl & AC_PINCTL_HP_EN)
2306 } else if (pin_ctl & AC_PINCTL_IN_EN) {
2307 switch (pin_ctl & AC_PINCTL_VREFEN) {
2308 case AC_PINCTL_VREF_HIZ: item = 3; break;
2309 case AC_PINCTL_VREF_50: item = 4; break;
2310 case AC_PINCTL_VREF_GRD: item = 5; break;
2311 case AC_PINCTL_VREF_80: item = 6; break;
2312 case AC_PINCTL_VREF_100: item = 7; break;
2315 ucontrol->value.enumerated.item[0] = item;
2319 static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol,
2320 struct snd_ctl_elem_value *ucontrol)
2322 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2323 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2324 static unsigned int ctls[] = {
2325 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
2326 AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
2327 AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
2328 AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
2329 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
2330 AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
2332 unsigned int old_ctl, new_ctl;
2334 old_ctl = snd_hda_codec_read(codec, nid, 0,
2335 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
2336 new_ctl = ctls[ucontrol->value.enumerated.item[0]];
2337 if (old_ctl != new_ctl) {
2338 snd_hda_codec_write(codec, nid, 0,
2339 AC_VERB_SET_PIN_WIDGET_CONTROL, new_ctl);
2340 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
2341 (ucontrol->value.enumerated.item[0] >= 3 ?
2348 static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol,
2349 struct snd_ctl_elem_info *uinfo)
2351 static char *texts[] = {
2352 "Front", "Surround", "CLFE", "Side"
2354 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
2356 uinfo->value.enumerated.items = 4;
2357 if (uinfo->value.enumerated.item >= 4)
2358 uinfo->value.enumerated.item = 3;
2359 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
2363 static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol,
2364 struct snd_ctl_elem_value *ucontrol)
2366 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2367 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2370 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
2371 ucontrol->value.enumerated.item[0] = sel & 3;
2375 static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol,
2376 struct snd_ctl_elem_value *ucontrol)
2378 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2379 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2382 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
2383 if (ucontrol->value.enumerated.item[0] != sel) {
2384 sel = ucontrol->value.enumerated.item[0] & 3;
2385 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, sel);
2391 #define PIN_CTL_TEST(xname,nid) { \
2392 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2394 .info = alc_test_pin_ctl_info, \
2395 .get = alc_test_pin_ctl_get, \
2396 .put = alc_test_pin_ctl_put, \
2397 .private_value = nid \
2400 #define PIN_SRC_TEST(xname,nid) { \
2401 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2403 .info = alc_test_pin_src_info, \
2404 .get = alc_test_pin_src_get, \
2405 .put = alc_test_pin_src_put, \
2406 .private_value = nid \
2409 static struct snd_kcontrol_new alc880_test_mixer[] = {
2410 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2411 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2412 HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
2413 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
2414 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2415 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
2416 HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
2417 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
2418 PIN_CTL_TEST("Front Pin Mode", 0x14),
2419 PIN_CTL_TEST("Surround Pin Mode", 0x15),
2420 PIN_CTL_TEST("CLFE Pin Mode", 0x16),
2421 PIN_CTL_TEST("Side Pin Mode", 0x17),
2422 PIN_CTL_TEST("In-1 Pin Mode", 0x18),
2423 PIN_CTL_TEST("In-2 Pin Mode", 0x19),
2424 PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
2425 PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
2426 PIN_SRC_TEST("In-1 Pin Source", 0x18),
2427 PIN_SRC_TEST("In-2 Pin Source", 0x19),
2428 PIN_SRC_TEST("In-3 Pin Source", 0x1a),
2429 PIN_SRC_TEST("In-4 Pin Source", 0x1b),
2430 HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
2431 HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
2432 HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
2433 HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
2434 HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
2435 HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
2436 HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
2437 HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
2438 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
2439 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
2441 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2442 .name = "Channel Mode",
2443 .info = alc_ch_mode_info,
2444 .get = alc_ch_mode_get,
2445 .put = alc_ch_mode_put,
2450 static struct hda_verb alc880_test_init_verbs[] = {
2451 /* Unmute inputs of 0x0c - 0x0f */
2452 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2453 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2454 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2455 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2456 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2457 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2458 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2459 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2460 /* Vol output for 0x0c-0x0f */
2461 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2462 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2463 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2464 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2465 /* Set output pins 0x14-0x17 */
2466 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2467 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2468 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2469 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2470 /* Unmute output pins 0x14-0x17 */
2471 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2472 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2473 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2474 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2475 /* Set input pins 0x18-0x1c */
2476 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2477 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2478 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2479 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2480 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2481 /* Mute input pins 0x18-0x1b */
2482 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2483 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2484 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2485 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2487 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2488 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
2489 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2490 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
2491 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2492 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
2493 /* Analog input/passthru */
2494 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2495 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2496 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
2497 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
2498 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
2506 static const char *alc880_models[ALC880_MODEL_LAST] = {
2507 [ALC880_3ST] = "3stack",
2508 [ALC880_TCL_S700] = "tcl",
2509 [ALC880_3ST_DIG] = "3stack-digout",
2510 [ALC880_CLEVO] = "clevo",
2511 [ALC880_5ST] = "5stack",
2512 [ALC880_5ST_DIG] = "5stack-digout",
2513 [ALC880_W810] = "w810",
2514 [ALC880_Z71V] = "z71v",
2515 [ALC880_6ST] = "6stack",
2516 [ALC880_6ST_DIG] = "6stack-digout",
2517 [ALC880_ASUS] = "asus",
2518 [ALC880_ASUS_W1V] = "asus-w1v",
2519 [ALC880_ASUS_DIG] = "asus-dig",
2520 [ALC880_ASUS_DIG2] = "asus-dig2",
2521 [ALC880_UNIWILL_DIG] = "uniwill",
2522 [ALC880_UNIWILL_P53] = "uniwill-p53",
2523 [ALC880_FUJITSU] = "fujitsu",
2524 [ALC880_F1734] = "F1734",
2526 [ALC880_LG_LW] = "lg-lw",
2527 #ifdef CONFIG_SND_DEBUG
2528 [ALC880_TEST] = "test",
2530 [ALC880_AUTO] = "auto",
2533 static struct snd_pci_quirk alc880_cfg_tbl[] = {
2534 /* Broken BIOS configuration */
2535 SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_6ST_DIG),
2536 SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_6ST_DIG),
2538 SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_5ST_DIG),
2539 SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_6ST),
2540 SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_W810),
2541 SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_3ST_DIG),
2542 SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_6ST_DIG),
2543 SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_6ST_DIG),
2544 SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_6ST_DIG),
2545 SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_3ST_DIG),
2546 SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_3ST),
2548 SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_6ST_DIG),
2549 SND_PCI_QUIRK(0x103c, 0x2a09, "HP", ALC880_5ST),
2551 SND_PCI_QUIRK(0x1043, 0x10b3, "ASUS W1V", ALC880_ASUS_W1V),
2552 SND_PCI_QUIRK(0x1043, 0x10c2, "ASUS W6A", ALC880_ASUS_DIG),
2553 SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS Wxx", ALC880_ASUS_DIG),
2554 SND_PCI_QUIRK(0x1043, 0x1113, "ASUS", ALC880_ASUS_DIG),
2555 SND_PCI_QUIRK(0x1043, 0x1123, "ASUS", ALC880_ASUS_DIG),
2556 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS", ALC880_ASUS_DIG),
2557 SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_Z71V),
2558 /* SND_PCI_QUIRK(0x1043, 0x1964, "ASUS", ALC880_ASUS_DIG), */
2559 SND_PCI_QUIRK(0x1043, 0x1973, "ASUS", ALC880_ASUS_DIG),
2560 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS", ALC880_ASUS_DIG),
2561 SND_PCI_QUIRK(0x1043, 0x814e, "ASUS", ALC880_ASUS),
2562 SND_PCI_QUIRK(0x1043, 0x8181, "ASUS P4GPL", ALC880_ASUS_DIG),
2563 SND_PCI_QUIRK(0x1043, 0x8196, "ASUS P5GD1", ALC880_6ST),
2564 SND_PCI_QUIRK(0x1043, 0x81b4, "ASUS", ALC880_6ST),
2565 SND_PCI_QUIRK(0x1043, 0, "ASUS", ALC880_ASUS),
2567 SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_3ST),
2568 SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_3ST),
2569 SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_5ST),
2570 SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_5ST),
2571 SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_5ST),
2572 SND_PCI_QUIRK(0x1558, 0x0520, "Clevo m520G", ALC880_CLEVO),
2573 SND_PCI_QUIRK(0x1558, 0x0660, "Clevo m655n", ALC880_CLEVO),
2574 SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_5ST_DIG),
2575 SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_W810),
2576 SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_5ST_DIG),
2577 SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_TCL_S700),
2578 SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_5ST_DIG),
2579 SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_6ST_DIG),
2580 SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_6ST_DIG),
2581 SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_6ST_DIG),
2582 SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_6ST_DIG),
2583 SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_6ST_DIG),
2584 SND_PCI_QUIRK(0x1558, 0x5401, "ASUS", ALC880_ASUS_DIG2),
2586 SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_UNIWILL_DIG),
2587 SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_UNIWILL),
2588 SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_UNIWILL_P53),
2589 SND_PCI_QUIRK(0x1584, 0x9054, "Uniwlll", ALC880_F1734),
2591 SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_5ST_DIG),
2592 SND_PCI_QUIRK(0x1734, 0x10ac, "FSC", ALC880_UNIWILL),
2593 SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_F1734),
2594 SND_PCI_QUIRK(0x1734, 0x10b0, "Fujitsu", ALC880_FUJITSU),
2596 SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_LG),
2597 SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_LG),
2598 SND_PCI_QUIRK(0x1854, 0x0018, "LG LW20", ALC880_LG_LW),
2599 SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_LG_LW),
2601 SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_3ST_DIG),
2602 SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_3ST_DIG),
2603 SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_3ST_DIG),
2604 SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_5ST_DIG),
2605 SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_5ST_DIG),
2606 SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_5ST_DIG),
2607 SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_5ST_DIG),
2608 SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_5ST_DIG),
2609 SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_5ST_DIG),
2610 SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_5ST_DIG),
2611 SND_PCI_QUIRK(0x8086, 0, "Intel mobo", ALC880_3ST),
2617 * ALC880 codec presets
2619 static struct alc_config_preset alc880_presets[] = {
2621 .mixers = { alc880_three_stack_mixer },
2622 .init_verbs = { alc880_volume_init_verbs,
2623 alc880_pin_3stack_init_verbs },
2624 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2625 .dac_nids = alc880_dac_nids,
2626 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
2627 .channel_mode = alc880_threestack_modes,
2629 .input_mux = &alc880_capture_source,
2631 [ALC880_3ST_DIG] = {
2632 .mixers = { alc880_three_stack_mixer },
2633 .init_verbs = { alc880_volume_init_verbs,
2634 alc880_pin_3stack_init_verbs },
2635 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2636 .dac_nids = alc880_dac_nids,
2637 .dig_out_nid = ALC880_DIGOUT_NID,
2638 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
2639 .channel_mode = alc880_threestack_modes,
2641 .input_mux = &alc880_capture_source,
2643 [ALC880_TCL_S700] = {
2644 .mixers = { alc880_tcl_s700_mixer },
2645 .init_verbs = { alc880_volume_init_verbs,
2646 alc880_pin_tcl_S700_init_verbs,
2647 alc880_gpio2_init_verbs },
2648 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2649 .dac_nids = alc880_dac_nids,
2651 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
2652 .channel_mode = alc880_2_jack_modes,
2653 .input_mux = &alc880_capture_source,
2656 .mixers = { alc880_three_stack_mixer,
2657 alc880_five_stack_mixer},
2658 .init_verbs = { alc880_volume_init_verbs,
2659 alc880_pin_5stack_init_verbs },
2660 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2661 .dac_nids = alc880_dac_nids,
2662 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
2663 .channel_mode = alc880_fivestack_modes,
2664 .input_mux = &alc880_capture_source,
2666 [ALC880_5ST_DIG] = {
2667 .mixers = { alc880_three_stack_mixer,
2668 alc880_five_stack_mixer },
2669 .init_verbs = { alc880_volume_init_verbs,
2670 alc880_pin_5stack_init_verbs },
2671 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2672 .dac_nids = alc880_dac_nids,
2673 .dig_out_nid = ALC880_DIGOUT_NID,
2674 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
2675 .channel_mode = alc880_fivestack_modes,
2676 .input_mux = &alc880_capture_source,
2679 .mixers = { alc880_six_stack_mixer },
2680 .init_verbs = { alc880_volume_init_verbs,
2681 alc880_pin_6stack_init_verbs },
2682 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
2683 .dac_nids = alc880_6st_dac_nids,
2684 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
2685 .channel_mode = alc880_sixstack_modes,
2686 .input_mux = &alc880_6stack_capture_source,
2688 [ALC880_6ST_DIG] = {
2689 .mixers = { alc880_six_stack_mixer },
2690 .init_verbs = { alc880_volume_init_verbs,
2691 alc880_pin_6stack_init_verbs },
2692 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
2693 .dac_nids = alc880_6st_dac_nids,
2694 .dig_out_nid = ALC880_DIGOUT_NID,
2695 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
2696 .channel_mode = alc880_sixstack_modes,
2697 .input_mux = &alc880_6stack_capture_source,
2700 .mixers = { alc880_w810_base_mixer },
2701 .init_verbs = { alc880_volume_init_verbs,
2702 alc880_pin_w810_init_verbs,
2703 alc880_gpio2_init_verbs },
2704 .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
2705 .dac_nids = alc880_w810_dac_nids,
2706 .dig_out_nid = ALC880_DIGOUT_NID,
2707 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
2708 .channel_mode = alc880_w810_modes,
2709 .input_mux = &alc880_capture_source,
2712 .mixers = { alc880_z71v_mixer },
2713 .init_verbs = { alc880_volume_init_verbs,
2714 alc880_pin_z71v_init_verbs },
2715 .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
2716 .dac_nids = alc880_z71v_dac_nids,
2717 .dig_out_nid = ALC880_DIGOUT_NID,
2719 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
2720 .channel_mode = alc880_2_jack_modes,
2721 .input_mux = &alc880_capture_source,
2724 .mixers = { alc880_f1734_mixer },
2725 .init_verbs = { alc880_volume_init_verbs,
2726 alc880_pin_f1734_init_verbs },
2727 .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
2728 .dac_nids = alc880_f1734_dac_nids,
2730 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
2731 .channel_mode = alc880_2_jack_modes,
2732 .input_mux = &alc880_capture_source,
2735 .mixers = { alc880_asus_mixer },
2736 .init_verbs = { alc880_volume_init_verbs,
2737 alc880_pin_asus_init_verbs,
2738 alc880_gpio1_init_verbs },
2739 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2740 .dac_nids = alc880_asus_dac_nids,
2741 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2742 .channel_mode = alc880_asus_modes,
2744 .input_mux = &alc880_capture_source,
2746 [ALC880_ASUS_DIG] = {
2747 .mixers = { alc880_asus_mixer },
2748 .init_verbs = { alc880_volume_init_verbs,
2749 alc880_pin_asus_init_verbs,
2750 alc880_gpio1_init_verbs },
2751 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2752 .dac_nids = alc880_asus_dac_nids,
2753 .dig_out_nid = ALC880_DIGOUT_NID,
2754 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2755 .channel_mode = alc880_asus_modes,
2757 .input_mux = &alc880_capture_source,
2759 [ALC880_ASUS_DIG2] = {
2760 .mixers = { alc880_asus_mixer },
2761 .init_verbs = { alc880_volume_init_verbs,
2762 alc880_pin_asus_init_verbs,
2763 alc880_gpio2_init_verbs }, /* use GPIO2 */
2764 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2765 .dac_nids = alc880_asus_dac_nids,
2766 .dig_out_nid = ALC880_DIGOUT_NID,
2767 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2768 .channel_mode = alc880_asus_modes,
2770 .input_mux = &alc880_capture_source,
2772 [ALC880_ASUS_W1V] = {
2773 .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
2774 .init_verbs = { alc880_volume_init_verbs,
2775 alc880_pin_asus_init_verbs,
2776 alc880_gpio1_init_verbs },
2777 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2778 .dac_nids = alc880_asus_dac_nids,
2779 .dig_out_nid = ALC880_DIGOUT_NID,
2780 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2781 .channel_mode = alc880_asus_modes,
2783 .input_mux = &alc880_capture_source,
2785 [ALC880_UNIWILL_DIG] = {
2786 .mixers = { alc880_asus_mixer, alc880_pcbeep_mixer },
2787 .init_verbs = { alc880_volume_init_verbs,
2788 alc880_pin_asus_init_verbs },
2789 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2790 .dac_nids = alc880_asus_dac_nids,
2791 .dig_out_nid = ALC880_DIGOUT_NID,
2792 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2793 .channel_mode = alc880_asus_modes,
2795 .input_mux = &alc880_capture_source,
2797 [ALC880_UNIWILL] = {
2798 .mixers = { alc880_uniwill_mixer },
2799 .init_verbs = { alc880_volume_init_verbs,
2800 alc880_uniwill_init_verbs },
2801 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2802 .dac_nids = alc880_asus_dac_nids,
2803 .dig_out_nid = ALC880_DIGOUT_NID,
2804 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
2805 .channel_mode = alc880_threestack_modes,
2807 .input_mux = &alc880_capture_source,
2808 .unsol_event = alc880_uniwill_unsol_event,
2809 .init_hook = alc880_uniwill_automute,
2811 [ALC880_UNIWILL_P53] = {
2812 .mixers = { alc880_uniwill_p53_mixer },
2813 .init_verbs = { alc880_volume_init_verbs,
2814 alc880_uniwill_p53_init_verbs },
2815 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2816 .dac_nids = alc880_asus_dac_nids,
2817 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
2818 .channel_mode = alc880_threestack_modes,
2819 .input_mux = &alc880_capture_source,
2820 .unsol_event = alc880_uniwill_p53_unsol_event,
2821 .init_hook = alc880_uniwill_p53_hp_automute,
2823 [ALC880_FUJITSU] = {
2824 .mixers = { alc880_fujitsu_mixer,
2825 alc880_pcbeep_mixer, },
2826 .init_verbs = { alc880_volume_init_verbs,
2827 alc880_uniwill_p53_init_verbs,
2828 alc880_beep_init_verbs },
2829 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2830 .dac_nids = alc880_dac_nids,
2831 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
2832 .channel_mode = alc880_2_jack_modes,
2833 .input_mux = &alc880_capture_source,
2834 .unsol_event = alc880_uniwill_p53_unsol_event,
2835 .init_hook = alc880_uniwill_p53_hp_automute,
2838 .mixers = { alc880_three_stack_mixer },
2839 .init_verbs = { alc880_volume_init_verbs,
2840 alc880_pin_clevo_init_verbs },
2841 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2842 .dac_nids = alc880_dac_nids,
2844 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
2845 .channel_mode = alc880_threestack_modes,
2847 .input_mux = &alc880_capture_source,
2850 .mixers = { alc880_lg_mixer },
2851 .init_verbs = { alc880_volume_init_verbs,
2852 alc880_lg_init_verbs },
2853 .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids),
2854 .dac_nids = alc880_lg_dac_nids,
2855 .dig_out_nid = ALC880_DIGOUT_NID,
2856 .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes),
2857 .channel_mode = alc880_lg_ch_modes,
2859 .input_mux = &alc880_lg_capture_source,
2860 .unsol_event = alc880_lg_unsol_event,
2861 .init_hook = alc880_lg_automute,
2864 .mixers = { alc880_lg_lw_mixer },
2865 .init_verbs = { alc880_volume_init_verbs,
2866 alc880_lg_lw_init_verbs },
2868 .dac_nids = alc880_dac_nids,
2869 .dig_out_nid = ALC880_DIGOUT_NID,
2870 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
2871 .channel_mode = alc880_2_jack_modes,
2872 .input_mux = &alc880_lg_lw_capture_source,
2873 .unsol_event = alc880_lg_lw_unsol_event,
2874 .init_hook = alc880_lg_lw_automute,
2876 #ifdef CONFIG_SND_DEBUG
2878 .mixers = { alc880_test_mixer },
2879 .init_verbs = { alc880_test_init_verbs },
2880 .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
2881 .dac_nids = alc880_test_dac_nids,
2882 .dig_out_nid = ALC880_DIGOUT_NID,
2883 .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
2884 .channel_mode = alc880_test_modes,
2885 .input_mux = &alc880_test_capture_source,
2891 * Automatic parse of I/O pins from the BIOS configuration
2894 #define NUM_CONTROL_ALLOC 32
2895 #define NUM_VERB_ALLOC 32
2899 ALC_CTL_WIDGET_MUTE,
2902 static struct snd_kcontrol_new alc880_control_templates[] = {
2903 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
2904 HDA_CODEC_MUTE(NULL, 0, 0, 0),
2905 HDA_BIND_MUTE(NULL, 0, 0, 0),
2908 /* add dynamic controls */
2909 static int add_control(struct alc_spec *spec, int type, const char *name,
2912 struct snd_kcontrol_new *knew;
2914 if (spec->num_kctl_used >= spec->num_kctl_alloc) {
2915 int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC;
2917 /* array + terminator */
2918 knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL);
2921 if (spec->kctl_alloc) {
2922 memcpy(knew, spec->kctl_alloc,
2923 sizeof(*knew) * spec->num_kctl_alloc);
2924 kfree(spec->kctl_alloc);
2926 spec->kctl_alloc = knew;
2927 spec->num_kctl_alloc = num;
2930 knew = &spec->kctl_alloc[spec->num_kctl_used];
2931 *knew = alc880_control_templates[type];
2932 knew->name = kstrdup(name, GFP_KERNEL);
2935 knew->private_value = val;
2936 spec->num_kctl_used++;
2940 #define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
2941 #define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
2942 #define alc880_is_multi_pin(nid) ((nid) >= 0x18)
2943 #define alc880_multi_pin_idx(nid) ((nid) - 0x18)
2944 #define alc880_is_input_pin(nid) ((nid) >= 0x18)
2945 #define alc880_input_pin_idx(nid) ((nid) - 0x18)
2946 #define alc880_idx_to_dac(nid) ((nid) + 0x02)
2947 #define alc880_dac_to_idx(nid) ((nid) - 0x02)
2948 #define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
2949 #define alc880_idx_to_selector(nid) ((nid) + 0x10)
2950 #define ALC880_PIN_CD_NID 0x1c
2952 /* fill in the dac_nids table from the parsed pin configuration */
2953 static int alc880_auto_fill_dac_nids(struct alc_spec *spec,
2954 const struct auto_pin_cfg *cfg)
2960 memset(assigned, 0, sizeof(assigned));
2961 spec->multiout.dac_nids = spec->private_dac_nids;
2963 /* check the pins hardwired to audio widget */
2964 for (i = 0; i < cfg->line_outs; i++) {
2965 nid = cfg->line_out_pins[i];
2966 if (alc880_is_fixed_pin(nid)) {
2967 int idx = alc880_fixed_pin_idx(nid);
2968 spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
2972 /* left pins can be connect to any audio widget */
2973 for (i = 0; i < cfg->line_outs; i++) {
2974 nid = cfg->line_out_pins[i];
2975 if (alc880_is_fixed_pin(nid))
2977 /* search for an empty channel */
2978 for (j = 0; j < cfg->line_outs; j++) {
2980 spec->multiout.dac_nids[i] =
2981 alc880_idx_to_dac(j);
2987 spec->multiout.num_dacs = cfg->line_outs;
2991 /* add playback controls from the parsed DAC table */
2992 static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
2993 const struct auto_pin_cfg *cfg)
2996 static const char *chname[4] = {
2997 "Front", "Surround", NULL /*CLFE*/, "Side"
3002 for (i = 0; i < cfg->line_outs; i++) {
3003 if (!spec->multiout.dac_nids[i])
3005 nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
3008 err = add_control(spec, ALC_CTL_WIDGET_VOL,
3009 "Center Playback Volume",
3010 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
3014 err = add_control(spec, ALC_CTL_WIDGET_VOL,
3015 "LFE Playback Volume",
3016 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
3020 err = add_control(spec, ALC_CTL_BIND_MUTE,
3021 "Center Playback Switch",
3022 HDA_COMPOSE_AMP_VAL(nid, 1, 2,
3026 err = add_control(spec, ALC_CTL_BIND_MUTE,
3027 "LFE Playback Switch",
3028 HDA_COMPOSE_AMP_VAL(nid, 2, 2,
3033 sprintf(name, "%s Playback Volume", chname[i]);
3034 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
3035 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
3039 sprintf(name, "%s Playback Switch", chname[i]);
3040 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
3041 HDA_COMPOSE_AMP_VAL(nid, 3, 2,
3050 /* add playback controls for speaker and HP outputs */
3051 static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
3061 if (alc880_is_fixed_pin(pin)) {
3062 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
3063 /* specify the DAC as the extra output */
3064 if (!spec->multiout.hp_nid)
3065 spec->multiout.hp_nid = nid;
3067 spec->multiout.extra_out_nid[0] = nid;
3068 /* control HP volume/switch on the output mixer amp */
3069 nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
3070 sprintf(name, "%s Playback Volume", pfx);
3071 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
3072 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
3075 sprintf(name, "%s Playback Switch", pfx);
3076 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
3077 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
3080 } else if (alc880_is_multi_pin(pin)) {
3081 /* set manual connection */
3082 /* we have only a switch on HP-out PIN */
3083 sprintf(name, "%s Playback Switch", pfx);
3084 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
3085 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
3092 /* create input playback/capture controls for the given pin */
3093 static int new_analog_input(struct alc_spec *spec, hda_nid_t pin,
3094 const char *ctlname,
3095 int idx, hda_nid_t mix_nid)
3100 sprintf(name, "%s Playback Volume", ctlname);
3101 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
3102 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
3105 sprintf(name, "%s Playback Switch", ctlname);
3106 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
3107 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
3113 /* create playback/capture controls for input pins */
3114 static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec,
3115 const struct auto_pin_cfg *cfg)
3117 struct hda_input_mux *imux = &spec->private_imux;
3120 for (i = 0; i < AUTO_PIN_LAST; i++) {
3121 if (alc880_is_input_pin(cfg->input_pins[i])) {
3122 idx = alc880_input_pin_idx(cfg->input_pins[i]);
3123 err = new_analog_input(spec, cfg->input_pins[i],
3124 auto_pin_cfg_labels[i],
3128 imux->items[imux->num_items].label =
3129 auto_pin_cfg_labels[i];
3130 imux->items[imux->num_items].index =
3131 alc880_input_pin_idx(cfg->input_pins[i]);
3138 static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
3139 hda_nid_t nid, int pin_type,
3143 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
3145 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
3147 /* need the manual connection? */
3148 if (alc880_is_multi_pin(nid)) {
3149 struct alc_spec *spec = codec->spec;
3150 int idx = alc880_multi_pin_idx(nid);
3151 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
3152 AC_VERB_SET_CONNECT_SEL,
3153 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
3157 static int get_pin_type(int line_out_type)
3159 if (line_out_type == AUTO_PIN_HP_OUT)
3165 static void alc880_auto_init_multi_out(struct hda_codec *codec)
3167 struct alc_spec *spec = codec->spec;
3170 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
3171 for (i = 0; i < spec->autocfg.line_outs; i++) {
3172 hda_nid_t nid = spec->autocfg.line_out_pins[i];
3173 int pin_type = get_pin_type(spec->autocfg.line_out_type);
3174 alc880_auto_set_output_and_unmute(codec, nid, pin_type, i);
3178 static void alc880_auto_init_extra_out(struct hda_codec *codec)
3180 struct alc_spec *spec = codec->spec;
3183 pin = spec->autocfg.speaker_pins[0];
3184 if (pin) /* connect to front */
3185 alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
3186 pin = spec->autocfg.hp_pins[0];
3187 if (pin) /* connect to front */
3188 alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
3191 static void alc880_auto_init_analog_input(struct hda_codec *codec)
3193 struct alc_spec *spec = codec->spec;
3196 for (i = 0; i < AUTO_PIN_LAST; i++) {
3197 hda_nid_t nid = spec->autocfg.input_pins[i];
3198 if (alc880_is_input_pin(nid)) {
3199 snd_hda_codec_write(codec, nid, 0,
3200 AC_VERB_SET_PIN_WIDGET_CONTROL,
3201 i <= AUTO_PIN_FRONT_MIC ?
3202 PIN_VREF80 : PIN_IN);
3203 if (nid != ALC880_PIN_CD_NID)
3204 snd_hda_codec_write(codec, nid, 0,
3205 AC_VERB_SET_AMP_GAIN_MUTE,
3211 /* parse the BIOS configuration and set up the alc_spec */
3212 /* return 1 if successful, 0 if the proper config is not found,
3213 * or a negative error code
3215 static int alc880_parse_auto_config(struct hda_codec *codec)
3217 struct alc_spec *spec = codec->spec;
3219 static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
3221 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
3225 if (!spec->autocfg.line_outs)
3226 return 0; /* can't find valid BIOS pin config */
3228 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
3231 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
3234 err = alc880_auto_create_extra_out(spec,
3235 spec->autocfg.speaker_pins[0],
3239 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
3243 err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
3247 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
3249 if (spec->autocfg.dig_out_pin)
3250 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
3251 if (spec->autocfg.dig_in_pin)
3252 spec->dig_in_nid = ALC880_DIGIN_NID;
3254 if (spec->kctl_alloc)
3255 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
3257 spec->init_verbs[spec->num_init_verbs++] = alc880_volume_init_verbs;
3259 spec->num_mux_defs = 1;
3260 spec->input_mux = &spec->private_imux;
3265 /* additional initialization for auto-configuration model */
3266 static void alc880_auto_init(struct hda_codec *codec)
3268 alc880_auto_init_multi_out(codec);
3269 alc880_auto_init_extra_out(codec);
3270 alc880_auto_init_analog_input(codec);
3274 * OK, here we have finally the patch for ALC880
3277 static int patch_alc880(struct hda_codec *codec)
3279 struct alc_spec *spec;
3283 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
3289 board_config = snd_hda_check_board_config(codec, ALC880_MODEL_LAST,
3292 if (board_config < 0) {
3293 printk(KERN_INFO "hda_codec: Unknown model for ALC880, "
3294 "trying auto-probe from BIOS...\n");
3295 board_config = ALC880_AUTO;
3298 if (board_config == ALC880_AUTO) {
3299 /* automatic parse from the BIOS config */
3300 err = alc880_parse_auto_config(codec);
3306 "hda_codec: Cannot set up configuration "
3307 "from BIOS. Using 3-stack mode...\n");
3308 board_config = ALC880_3ST;
3312 if (board_config != ALC880_AUTO)
3313 setup_preset(spec, &alc880_presets[board_config]);
3315 spec->stream_name_analog = "ALC880 Analog";
3316 spec->stream_analog_playback = &alc880_pcm_analog_playback;
3317 spec->stream_analog_capture = &alc880_pcm_analog_capture;
3319 spec->stream_name_digital = "ALC880 Digital";
3320 spec->stream_digital_playback = &alc880_pcm_digital_playback;
3321 spec->stream_digital_capture = &alc880_pcm_digital_capture;
3323 if (!spec->adc_nids && spec->input_mux) {
3324 /* check whether NID 0x07 is valid */
3325 unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
3327 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
3328 if (wcap != AC_WID_AUD_IN) {
3329 spec->adc_nids = alc880_adc_nids_alt;
3330 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
3331 spec->mixers[spec->num_mixers] =
3332 alc880_capture_alt_mixer;
3335 spec->adc_nids = alc880_adc_nids;
3336 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
3337 spec->mixers[spec->num_mixers] = alc880_capture_mixer;
3342 codec->patch_ops = alc_patch_ops;
3343 if (board_config == ALC880_AUTO)
3344 spec->init_hook = alc880_auto_init;
3354 static hda_nid_t alc260_dac_nids[1] = {
3359 static hda_nid_t alc260_adc_nids[1] = {
3364 static hda_nid_t alc260_adc_nids_alt[1] = {
3369 static hda_nid_t alc260_hp_adc_nids[2] = {
3374 /* NIDs used when simultaneous access to both ADCs makes sense. Note that
3375 * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
3377 static hda_nid_t alc260_dual_adc_nids[2] = {
3382 #define ALC260_DIGOUT_NID 0x03
3383 #define ALC260_DIGIN_NID 0x06
3385 static struct hda_input_mux alc260_capture_source = {
3389 { "Front Mic", 0x1 },
3395 /* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
3396 * headphone jack and the internal CD lines since these are the only pins at
3397 * which audio can appear. For flexibility, also allow the option of
3398 * recording the mixer output on the second ADC (ADC0 doesn't have a
3399 * connection to the mixer output).
3401 static struct hda_input_mux alc260_fujitsu_capture_sources[2] = {
3405 { "Mic/Line", 0x0 },
3407 { "Headphone", 0x2 },
3413 { "Mic/Line", 0x0 },
3415 { "Headphone", 0x2 },
3422 /* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to
3423 * the Fujitsu S702x, but jacks are marked differently.
3425 static struct hda_input_mux alc260_acer_capture_sources[2] = {
3432 { "Headphone", 0x5 },
3441 { "Headphone", 0x6 },
3447 * This is just place-holder, so there's something for alc_build_pcms to look
3448 * at when it calculates the maximum number of channels. ALC260 has no mixer
3449 * element which allows changing the channel mode, so the verb list is
3452 static struct hda_channel_mode alc260_modes[1] = {
3457 /* Mixer combinations
3459 * basic: base_output + input + pc_beep + capture
3460 * HP: base_output + input + capture_alt
3461 * HP_3013: hp_3013 + input + capture
3462 * fujitsu: fujitsu + capture
3463 * acer: acer + capture
3466 static struct snd_kcontrol_new alc260_base_output_mixer[] = {
3467 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3468 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
3469 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
3470 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
3471 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
3472 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
3476 static struct snd_kcontrol_new alc260_input_mixer[] = {
3477 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3478 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
3479 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
3480 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
3481 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
3482 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
3483 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
3484 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
3488 static struct snd_kcontrol_new alc260_pc_beep_mixer[] = {
3489 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x07, 0x05, HDA_INPUT),
3490 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x07, 0x05, HDA_INPUT),
3494 static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
3495 HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
3496 HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
3497 HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
3498 HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
3499 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3500 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
3501 HDA_CODEC_VOLUME_MONO("iSpeaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
3502 HDA_CODEC_MUTE_MONO("iSpeaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
3506 /* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12,
3507 * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10.
3509 static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
3510 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3511 HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
3512 ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
3513 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3514 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
3515 HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
3516 HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
3517 ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
3518 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
3519 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
3520 HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
3521 HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x09, 2, HDA_INPUT),
3525 /* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current
3526 * versions of the ALC260 don't act on requests to enable mic bias from NID
3527 * 0x0f (used to drive the headphone jack in these laptops). The ALC260
3528 * datasheet doesn't mention this restriction. At this stage it's not clear
3529 * whether this behaviour is intentional or is a hardware bug in chip
3530 * revisions available in early 2006. Therefore for now allow the
3531 * "Headphone Jack Mode" control to span all choices, but if it turns out
3532 * that the lack of mic bias for this NID is intentional we could change the
3533 * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
3535 * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006
3536 * don't appear to make the mic bias available from the "line" jack, even
3537 * though the NID used for this jack (0x14) can supply it. The theory is
3538 * that perhaps Acer have included blocking capacitors between the ALC260
3539 * and the output jack. If this turns out to be the case for all such
3540 * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
3541 * to ALC_PIN_DIR_INOUT_NOMICBIAS.
3543 * The C20x Tablet series have a mono internal speaker which is controlled
3544 * via the chip's Mono sum widget and pin complex, so include the necessary
3545 * controls for such models. On models without a "mono speaker" the control
3546 * won't do anything.
3548 static struct snd_kcontrol_new alc260_acer_mixer[] = {
3549 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3550 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
3551 ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
3552 HDA_CODEC_VOLUME_MONO("Mono Speaker Playback Volume", 0x0a, 1, 0x0,
3554 HDA_BIND_MUTE_MONO("Mono Speaker Playback Switch", 0x0a, 1, 2,
3556 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3557 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
3558 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
3559 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
3560 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
3561 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
3562 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
3563 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
3564 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
3565 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
3569 /* Packard bell V7900 ALC260 pin usage: HP = 0x0f, Mic jack = 0x12,
3570 * Line In jack = 0x14, CD audio = 0x16, pc beep = 0x17.
3572 static struct snd_kcontrol_new alc260_will_mixer[] = {
3573 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3574 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
3575 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
3576 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
3577 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
3578 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
3579 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
3580 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
3581 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3582 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
3583 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
3584 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
3588 /* Replacer 672V ALC260 pin usage: Mic jack = 0x12,
3589 * Line In jack = 0x14, ATAPI Mic = 0x13, speaker = 0x0f.
3591 static struct snd_kcontrol_new alc260_replacer_672v_mixer[] = {
3592 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3593 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
3594 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
3595 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
3596 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
3597 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x07, 0x1, HDA_INPUT),
3598 HDA_CODEC_MUTE("ATATI Mic Playback Switch", 0x07, 0x1, HDA_INPUT),
3599 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
3600 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
3601 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
3605 /* capture mixer elements */
3606 static struct snd_kcontrol_new alc260_capture_mixer[] = {
3607 HDA_CODEC_VOLUME("Capture Volume", 0x04, 0x0, HDA_INPUT),
3608 HDA_CODEC_MUTE("Capture Switch", 0x04, 0x0, HDA_INPUT),
3609 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x05, 0x0, HDA_INPUT),
3610 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x05, 0x0, HDA_INPUT),
3612 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3613 /* The multiple "Capture Source" controls confuse alsamixer
3614 * So call somewhat different..
3615 * FIXME: the controls appear in the "playback" view!
3617 /* .name = "Capture Source", */
3618 .name = "Input Source",
3620 .info = alc_mux_enum_info,
3621 .get = alc_mux_enum_get,
3622 .put = alc_mux_enum_put,
3627 static struct snd_kcontrol_new alc260_capture_alt_mixer[] = {
3628 HDA_CODEC_VOLUME("Capture Volume", 0x05, 0x0, HDA_INPUT),
3629 HDA_CODEC_MUTE("Capture Switch", 0x05, 0x0, HDA_INPUT),
3631 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3632 /* The multiple "Capture Source" controls confuse alsamixer
3633 * So call somewhat different..
3634 * FIXME: the controls appear in the "playback" view!
3636 /* .name = "Capture Source", */
3637 .name = "Input Source",
3639 .info = alc_mux_enum_info,
3640 .get = alc_mux_enum_get,
3641 .put = alc_mux_enum_put,
3647 * initialization verbs
3649 static struct hda_verb alc260_init_verbs[] = {
3650 /* Line In pin widget for input */
3651 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3652 /* CD pin widget for input */
3653 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3654 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3655 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3656 /* Mic2 (front panel) pin widget for input and vref at 80% */
3657 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3658 /* LINE-2 is used for line-out in rear */
3659 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3660 /* select line-out */
3661 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
3663 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3665 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3667 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3668 /* mute capture amp left and right */
3669 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3670 /* set connection select to line in (default select for this ADC) */
3671 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
3672 /* mute capture amp left and right */
3673 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3674 /* set connection select to line in (default select for this ADC) */
3675 {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
3676 /* set vol=0 Line-Out mixer amp left and right */
3677 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3678 /* unmute pin widget amp left and right (no gain on this amp) */
3679 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3680 /* set vol=0 HP mixer amp left and right */
3681 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3682 /* unmute pin widget amp left and right (no gain on this amp) */
3683 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3684 /* set vol=0 Mono mixer amp left and right */
3685 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3686 /* unmute pin widget amp left and right (no gain on this amp) */
3687 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3688 /* unmute LINE-2 out pin */
3689 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3690 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
3694 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
3696 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
3698 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3699 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
3700 /* mute Front out path */
3701 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3702 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3703 /* mute Headphone out path */
3704 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3705 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3706 /* mute Mono out path */
3707 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3708 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3712 #if 0 /* should be identical with alc260_init_verbs? */
3713 static struct hda_verb alc260_hp_init_verbs[] = {
3714 /* Headphone and output */
3715 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
3717 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
3718 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3719 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
3720 /* Mic2 (front panel) pin widget for input and vref at 80% */
3721 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
3722 /* Line In pin widget for input */
3723 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
3724 /* Line-2 pin widget for output */
3725 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
3726 /* CD pin widget for input */
3727 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
3728 /* unmute amp left and right */
3729 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
3730 /* set connection select to line in (default select for this ADC) */
3731 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
3732 /* unmute Line-Out mixer amp left and right (volume = 0) */
3733 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
3734 /* mute pin widget amp left and right (no gain on this amp) */
3735 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
3736 /* unmute HP mixer amp left and right (volume = 0) */
3737 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
3738 /* mute pin widget amp left and right (no gain on this amp) */
3739 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
3740 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
3744 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
3745 /* unmute Line In */
3746 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
3748 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3749 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
3750 /* Unmute Front out path */
3751 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3752 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3753 /* Unmute Headphone out path */
3754 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3755 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3756 /* Unmute Mono out path */
3757 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3758 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3763 static struct hda_verb alc260_hp_3013_init_verbs[] = {
3764 /* Line out and output */
3765 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
3767 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
3768 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3769 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
3770 /* Mic2 (front panel) pin widget for input and vref at 80% */
3771 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
3772 /* Line In pin widget for input */
3773 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
3774 /* Headphone pin widget for output */
3775 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
3776 /* CD pin widget for input */
3777 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
3778 /* unmute amp left and right */
3779 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
3780 /* set connection select to line in (default select for this ADC) */
3781 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
3782 /* unmute Line-Out mixer amp left and right (volume = 0) */
3783 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
3784 /* mute pin widget amp left and right (no gain on this amp) */
3785 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
3786 /* unmute HP mixer amp left and right (volume = 0) */
3787 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
3788 /* mute pin widget amp left and right (no gain on this amp) */
3789 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
3790 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
3794 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
3795 /* unmute Line In */
3796 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
3798 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3799 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
3800 /* Unmute Front out path */
3801 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3802 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3803 /* Unmute Headphone out path */
3804 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3805 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3806 /* Unmute Mono out path */
3807 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3808 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3812 /* Initialisation sequence for ALC260 as configured in Fujitsu S702x
3813 * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD
3814 * audio = 0x16, internal speaker = 0x10.
3816 static struct hda_verb alc260_fujitsu_init_verbs[] = {
3817 /* Disable all GPIOs */
3818 {0x01, AC_VERB_SET_GPIO_MASK, 0},
3819 /* Internal speaker is connected to headphone pin */
3820 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3821 /* Headphone/Line-out jack connects to Line1 pin; make it an output */
3822 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3823 /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
3824 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3825 /* Ensure all other unused pins are disabled and muted. */
3826 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3827 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3828 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3829 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3830 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3831 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3832 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3833 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3835 /* Disable digital (SPDIF) pins */
3836 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
3837 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
3839 /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
3840 * when acting as an output.
3842 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
3844 /* Start with output sum widgets muted and their output gains at min */
3845 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3846 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3847 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3848 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3849 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3850 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3851 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3852 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3853 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3855 /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
3856 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3857 /* Unmute Line1 pin widget output buffer since it starts as an output.
3858 * If the pin mode is changed by the user the pin mode control will
3859 * take care of enabling the pin's input/output buffers as needed.
3860 * Therefore there's no need to enable the input buffer at this
3863 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3864 /* Unmute input buffer of pin widget used for Line-in (no equiv
3867 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3869 /* Mute capture amp left and right */
3870 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3871 /* Set ADC connection select to match default mixer setting - line
3874 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
3876 /* Do the same for the second ADC: mute capture input amp and
3877 * set ADC connection to line in (on mic1 pin)
3879 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3880 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
3882 /* Mute all inputs to mixer widget (even unconnected ones) */
3883 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
3884 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
3885 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
3886 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
3887 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
3888 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
3889 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
3890 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
3895 /* Initialisation sequence for ALC260 as configured in Acer TravelMate and
3896 * similar laptops (adapted from Fujitsu init verbs).
3898 static struct hda_verb alc260_acer_init_verbs[] = {
3899 /* On TravelMate laptops, GPIO 0 enables the internal speaker and
3900 * the headphone jack. Turn this on and rely on the standard mute
3901 * methods whenever the user wants to turn these outputs off.
3903 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
3904 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
3905 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
3906 /* Internal speaker/Headphone jack is connected to Line-out pin */
3907 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3908 /* Internal microphone/Mic jack is connected to Mic1 pin */
3909 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
3910 /* Line In jack is connected to Line1 pin */
3911 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3912 /* Some Acers (eg: C20x Tablets) use Mono pin for internal speaker */
3913 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3914 /* Ensure all other unused pins are disabled and muted. */
3915 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3916 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3917 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3918 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3919 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3920 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3921 /* Disable digital (SPDIF) pins */
3922 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
3923 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
3925 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
3926 * bus when acting as outputs.
3928 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
3929 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
3931 /* Start with output sum widgets muted and their output gains at min */
3932 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3933 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3934 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3935 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3936 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3937 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3938 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3939 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3940 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3942 /* Unmute Line-out pin widget amp left and right
3943 * (no equiv mixer ctrl)
3945 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3946 /* Unmute mono pin widget amp output (no equiv mixer ctrl) */
3947 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3948 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
3949 * inputs. If the pin mode is changed by the user the pin mode control
3950 * will take care of enabling the pin's input/output buffers as needed.
3951 * Therefore there's no need to enable the input buffer at this
3954 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3955 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3957 /* Mute capture amp left and right */
3958 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3959 /* Set ADC connection select to match default mixer setting - mic
3962 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
3964 /* Do similar with the second ADC: mute capture input amp and
3965 * set ADC connection to mic to match ALSA's default state.
3967 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3968 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
3970 /* Mute all inputs to mixer widget (even unconnected ones) */
3971 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
3972 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
3973 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
3974 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
3975 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
3976 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
3977 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
3978 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
3983 static struct hda_verb alc260_will_verbs[] = {
3984 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3985 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x00},
3986 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
3987 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
3988 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
3989 {0x1a, AC_VERB_SET_PROC_COEF, 0x3040},
3993 static struct hda_verb alc260_replacer_672v_verbs[] = {
3994 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
3995 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
3996 {0x1a, AC_VERB_SET_PROC_COEF, 0x3050},
3998 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
3999 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
4000 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
4002 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
4006 /* toggle speaker-output according to the hp-jack state */
4007 static void alc260_replacer_672v_automute(struct hda_codec *codec)
4009 unsigned int present;
4011 /* speaker --> GPIO Data 0, hp or spdif --> GPIO data 1 */
4012 present = snd_hda_codec_read(codec, 0x0f, 0,
4013 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
4015 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 1);
4016 snd_hda_codec_write(codec, 0x0f, 0,
4017 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP);
4019 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 0);
4020 snd_hda_codec_write(codec, 0x0f, 0,
4021 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
4025 static void alc260_replacer_672v_unsol_event(struct hda_codec *codec,
4028 if ((res >> 26) == ALC880_HP_EVENT)
4029 alc260_replacer_672v_automute(codec);
4032 /* Test configuration for debugging, modelled after the ALC880 test
4035 #ifdef CONFIG_SND_DEBUG
4036 static hda_nid_t alc260_test_dac_nids[1] = {
4039 static hda_nid_t alc260_test_adc_nids[2] = {
4042 /* For testing the ALC260, each input MUX needs its own definition since
4043 * the signal assignments are different. This assumes that the first ADC
4046 static struct hda_input_mux alc260_test_capture_sources[2] = {
4050 { "MIC1 pin", 0x0 },
4051 { "MIC2 pin", 0x1 },
4052 { "LINE1 pin", 0x2 },
4053 { "LINE2 pin", 0x3 },
4055 { "LINE-OUT pin", 0x5 },
4056 { "HP-OUT pin", 0x6 },
4062 { "MIC1 pin", 0x0 },
4063 { "MIC2 pin", 0x1 },
4064 { "LINE1 pin", 0x2 },
4065 { "LINE2 pin", 0x3 },
4068 { "LINE-OUT pin", 0x6 },
4069 { "HP-OUT pin", 0x7 },
4073 static struct snd_kcontrol_new alc260_test_mixer[] = {
4074 /* Output driver widgets */
4075 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
4076 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
4077 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4078 HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
4079 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4080 HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
4082 /* Modes for retasking pin widgets
4083 * Note: the ALC260 doesn't seem to act on requests to enable mic
4084 * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't
4085 * mention this restriction. At this stage it's not clear whether
4086 * this behaviour is intentional or is a hardware bug in chip
4087 * revisions available at least up until early 2006. Therefore for
4088 * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all
4089 * choices, but if it turns out that the lack of mic bias for these
4090 * NIDs is intentional we could change their modes from
4091 * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
4093 ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
4094 ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
4095 ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
4096 ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
4097 ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
4098 ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
4100 /* Loopback mixer controls */
4101 HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
4102 HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
4103 HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
4104 HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
4105 HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
4106 HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
4107 HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
4108 HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
4109 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4110 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4111 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
4112 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
4113 HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
4114 HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
4115 HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
4116 HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
4118 /* Controls for GPIO pins, assuming they are configured as outputs */
4119 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
4120 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
4121 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
4122 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
4124 /* Switches to allow the digital IO pins to be enabled. The datasheet
4125 * is ambigious as to which NID is which; testing on laptops which
4126 * make this output available should provide clarification.
4128 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
4129 ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
4133 static struct hda_verb alc260_test_init_verbs[] = {
4134 /* Enable all GPIOs as outputs with an initial value of 0 */
4135 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
4136 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
4137 {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
4139 /* Enable retasking pins as output, initially without power amp */
4140 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4141 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4142 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4143 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4144 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4145 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4147 /* Disable digital (SPDIF) pins initially, but users can enable
4148 * them via a mixer switch. In the case of SPDIF-out, this initverb
4149 * payload also sets the generation to 0, output to be in "consumer"
4150 * PCM format, copyright asserted, no pre-emphasis and no validity
4153 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
4154 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
4156 /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
4157 * OUT1 sum bus when acting as an output.
4159 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
4160 {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
4161 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
4162 {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
4164 /* Start with output sum widgets muted and their output gains at min */
4165 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4166 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4167 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4168 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4169 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4170 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4171 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4172 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4173 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4175 /* Unmute retasking pin widget output buffers since the default
4176 * state appears to be output. As the pin mode is changed by the
4177 * user the pin mode control will take care of enabling the pin's
4178 * input/output buffers as needed.
4180 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4181 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4182 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4183 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4184 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4185 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4186 /* Also unmute the mono-out pin widget */
4187 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4189 /* Mute capture amp left and right */
4190 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4191 /* Set ADC connection select to match default mixer setting (mic1
4194 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
4196 /* Do the same for the second ADC: mute capture input amp and
4197 * set ADC connection to mic1 pin
4199 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4200 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
4202 /* Mute all inputs to mixer widget (even unconnected ones) */
4203 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
4204 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
4205 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
4206 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
4207 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
4208 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
4209 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
4210 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
4216 static struct hda_pcm_stream alc260_pcm_analog_playback = {
4222 static struct hda_pcm_stream alc260_pcm_analog_capture = {
4228 #define alc260_pcm_digital_playback alc880_pcm_digital_playback
4229 #define alc260_pcm_digital_capture alc880_pcm_digital_capture
4232 * for BIOS auto-configuration
4235 static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
4239 unsigned long vol_val, sw_val;
4243 if (nid >= 0x0f && nid < 0x11) {
4244 nid_vol = nid - 0x7;
4245 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
4246 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
4247 } else if (nid == 0x11) {
4248 nid_vol = nid - 0x7;
4249 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
4250 sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
4251 } else if (nid >= 0x12 && nid <= 0x15) {
4253 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
4254 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
4258 snprintf(name, sizeof(name), "%s Playback Volume", pfx);
4259 err = add_control(spec, ALC_CTL_WIDGET_VOL, name, vol_val);
4262 snprintf(name, sizeof(name), "%s Playback Switch", pfx);
4263 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, sw_val);
4269 /* add playback controls from the parsed DAC table */
4270 static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
4271 const struct auto_pin_cfg *cfg)
4276 spec->multiout.num_dacs = 1;
4277 spec->multiout.dac_nids = spec->private_dac_nids;
4278 spec->multiout.dac_nids[0] = 0x02;
4280 nid = cfg->line_out_pins[0];
4282 err = alc260_add_playback_controls(spec, nid, "Front");
4287 nid = cfg->speaker_pins[0];
4289 err = alc260_add_playback_controls(spec, nid, "Speaker");
4294 nid = cfg->hp_pins[0];
4296 err = alc260_add_playback_controls(spec, nid, "Headphone");
4303 /* create playback/capture controls for input pins */
4304 static int alc260_auto_create_analog_input_ctls(struct alc_spec *spec,
4305 const struct auto_pin_cfg *cfg)
4307 struct hda_input_mux *imux = &spec->private_imux;
4310 for (i = 0; i < AUTO_PIN_LAST; i++) {
4311 if (cfg->input_pins[i] >= 0x12) {
4312 idx = cfg->input_pins[i] - 0x12;
4313 err = new_analog_input(spec, cfg->input_pins[i],
4314 auto_pin_cfg_labels[i], idx,
4318 imux->items[imux->num_items].label =
4319 auto_pin_cfg_labels[i];
4320 imux->items[imux->num_items].index = idx;
4323 if (cfg->input_pins[i] >= 0x0f && cfg->input_pins[i] <= 0x10){
4324 idx = cfg->input_pins[i] - 0x09;
4325 err = new_analog_input(spec, cfg->input_pins[i],
4326 auto_pin_cfg_labels[i], idx,
4330 imux->items[imux->num_items].label =
4331 auto_pin_cfg_labels[i];
4332 imux->items[imux->num_items].index = idx;
4339 static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
4340 hda_nid_t nid, int pin_type,
4344 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4346 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
4348 /* need the manual connection? */
4350 int idx = nid - 0x12;
4351 snd_hda_codec_write(codec, idx + 0x0b, 0,
4352 AC_VERB_SET_CONNECT_SEL, sel_idx);
4356 static void alc260_auto_init_multi_out(struct hda_codec *codec)
4358 struct alc_spec *spec = codec->spec;
4361 alc_subsystem_id(codec, 0x10, 0x15, 0x0f);
4362 nid = spec->autocfg.line_out_pins[0];
4364 int pin_type = get_pin_type(spec->autocfg.line_out_type);
4365 alc260_auto_set_output_and_unmute(codec, nid, pin_type, 0);
4368 nid = spec->autocfg.speaker_pins[0];
4370 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
4372 nid = spec->autocfg.hp_pins[0];
4374 alc260_auto_set_output_and_unmute(codec, nid, PIN_HP, 0);
4377 #define ALC260_PIN_CD_NID 0x16
4378 static void alc260_auto_init_analog_input(struct hda_codec *codec)
4380 struct alc_spec *spec = codec->spec;
4383 for (i = 0; i < AUTO_PIN_LAST; i++) {
4384 hda_nid_t nid = spec->autocfg.input_pins[i];
4386 snd_hda_codec_write(codec, nid, 0,
4387 AC_VERB_SET_PIN_WIDGET_CONTROL,
4388 i <= AUTO_PIN_FRONT_MIC ?
4389 PIN_VREF80 : PIN_IN);
4390 if (nid != ALC260_PIN_CD_NID)
4391 snd_hda_codec_write(codec, nid, 0,
4392 AC_VERB_SET_AMP_GAIN_MUTE,
4399 * generic initialization of ADC, input mixers and output mixers
4401 static struct hda_verb alc260_volume_init_verbs[] = {
4403 * Unmute ADC0-1 and set the default input to mic-in
4405 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
4406 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4407 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
4408 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4410 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
4412 * Note: PASD motherboards uses the Line In 2 as the input for
4413 * front panel mic (mic 2)
4415 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
4416 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4417 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4418 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
4419 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
4420 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
4423 * Set up output mixers (0x08 - 0x0a)
4425 /* set vol=0 to output mixers */
4426 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4427 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4428 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4429 /* set up input amps for analog loopback */
4430 /* Amp Indices: DAC = 0, mixer = 1 */
4431 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4432 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4433 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4434 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4435 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4436 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4441 static int alc260_parse_auto_config(struct hda_codec *codec)
4443 struct alc_spec *spec = codec->spec;
4446 static hda_nid_t alc260_ignore[] = { 0x17, 0 };
4448 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
4452 err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg);
4455 if (!spec->kctl_alloc)
4456 return 0; /* can't find valid BIOS pin config */
4457 err = alc260_auto_create_analog_input_ctls(spec, &spec->autocfg);
4461 spec->multiout.max_channels = 2;
4463 if (spec->autocfg.dig_out_pin)
4464 spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
4465 if (spec->kctl_alloc)
4466 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
4468 spec->init_verbs[spec->num_init_verbs++] = alc260_volume_init_verbs;
4470 spec->num_mux_defs = 1;
4471 spec->input_mux = &spec->private_imux;
4473 /* check whether NID 0x04 is valid */
4474 wcap = get_wcaps(codec, 0x04);
4475 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
4476 if (wcap != AC_WID_AUD_IN) {
4477 spec->adc_nids = alc260_adc_nids_alt;
4478 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
4479 spec->mixers[spec->num_mixers] = alc260_capture_alt_mixer;
4481 spec->adc_nids = alc260_adc_nids;
4482 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
4483 spec->mixers[spec->num_mixers] = alc260_capture_mixer;
4490 /* additional initialization for auto-configuration model */
4491 static void alc260_auto_init(struct hda_codec *codec)
4493 alc260_auto_init_multi_out(codec);
4494 alc260_auto_init_analog_input(codec);
4498 * ALC260 configurations
4500 static const char *alc260_models[ALC260_MODEL_LAST] = {
4501 [ALC260_BASIC] = "basic",
4503 [ALC260_HP_3013] = "hp-3013",
4504 [ALC260_FUJITSU_S702X] = "fujitsu",
4505 [ALC260_ACER] = "acer",
4506 [ALC260_WILL] = "will",
4507 [ALC260_REPLACER_672V] = "replacer",
4508 #ifdef CONFIG_SND_DEBUG
4509 [ALC260_TEST] = "test",
4511 [ALC260_AUTO] = "auto",
4514 static struct snd_pci_quirk alc260_cfg_tbl[] = {
4515 SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER),
4516 SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER),
4517 SND_PCI_QUIRK(0x103c, 0x2808, "HP d5700", ALC260_HP_3013),
4518 SND_PCI_QUIRK(0x103c, 0x280a, "HP d5750", ALC260_HP_3013),
4519 SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013),
4520 SND_PCI_QUIRK(0x103c, 0x3011, "HP", ALC260_HP),
4521 SND_PCI_QUIRK(0x103c, 0x3012, "HP", ALC260_HP_3013),
4522 SND_PCI_QUIRK(0x103c, 0x3013, "HP", ALC260_HP_3013),
4523 SND_PCI_QUIRK(0x103c, 0x3014, "HP", ALC260_HP),
4524 SND_PCI_QUIRK(0x103c, 0x3015, "HP", ALC260_HP),
4525 SND_PCI_QUIRK(0x103c, 0x3016, "HP", ALC260_HP),
4526 SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_BASIC),
4527 SND_PCI_QUIRK(0x104d, 0x81cc, "Sony VAIO", ALC260_BASIC),
4528 SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC),
4529 SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X),
4530 SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC),
4531 SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_WILL),
4532 SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_REPLACER_672V),
4536 static struct alc_config_preset alc260_presets[] = {
4538 .mixers = { alc260_base_output_mixer,
4540 alc260_pc_beep_mixer,
4541 alc260_capture_mixer },
4542 .init_verbs = { alc260_init_verbs },
4543 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4544 .dac_nids = alc260_dac_nids,
4545 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
4546 .adc_nids = alc260_adc_nids,
4547 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4548 .channel_mode = alc260_modes,
4549 .input_mux = &alc260_capture_source,
4552 .mixers = { alc260_base_output_mixer,
4554 alc260_capture_alt_mixer },
4555 .init_verbs = { alc260_init_verbs },
4556 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4557 .dac_nids = alc260_dac_nids,
4558 .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
4559 .adc_nids = alc260_hp_adc_nids,
4560 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4561 .channel_mode = alc260_modes,
4562 .input_mux = &alc260_capture_source,
4564 [ALC260_HP_3013] = {
4565 .mixers = { alc260_hp_3013_mixer,
4567 alc260_capture_alt_mixer },
4568 .init_verbs = { alc260_hp_3013_init_verbs },
4569 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4570 .dac_nids = alc260_dac_nids,
4571 .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
4572 .adc_nids = alc260_hp_adc_nids,
4573 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4574 .channel_mode = alc260_modes,
4575 .input_mux = &alc260_capture_source,
4577 [ALC260_FUJITSU_S702X] = {
4578 .mixers = { alc260_fujitsu_mixer,
4579 alc260_capture_mixer },
4580 .init_verbs = { alc260_fujitsu_init_verbs },
4581 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4582 .dac_nids = alc260_dac_nids,
4583 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
4584 .adc_nids = alc260_dual_adc_nids,
4585 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4586 .channel_mode = alc260_modes,
4587 .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources),
4588 .input_mux = alc260_fujitsu_capture_sources,
4591 .mixers = { alc260_acer_mixer,
4592 alc260_capture_mixer },
4593 .init_verbs = { alc260_acer_init_verbs },
4594 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4595 .dac_nids = alc260_dac_nids,
4596 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
4597 .adc_nids = alc260_dual_adc_nids,
4598 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4599 .channel_mode = alc260_modes,
4600 .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
4601 .input_mux = alc260_acer_capture_sources,
4604 .mixers = { alc260_will_mixer,
4605 alc260_capture_mixer },
4606 .init_verbs = { alc260_init_verbs, alc260_will_verbs },
4607 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4608 .dac_nids = alc260_dac_nids,
4609 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
4610 .adc_nids = alc260_adc_nids,
4611 .dig_out_nid = ALC260_DIGOUT_NID,
4612 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4613 .channel_mode = alc260_modes,
4614 .input_mux = &alc260_capture_source,
4616 [ALC260_REPLACER_672V] = {
4617 .mixers = { alc260_replacer_672v_mixer,
4618 alc260_capture_mixer },
4619 .init_verbs = { alc260_init_verbs, alc260_replacer_672v_verbs },
4620 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4621 .dac_nids = alc260_dac_nids,
4622 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
4623 .adc_nids = alc260_adc_nids,
4624 .dig_out_nid = ALC260_DIGOUT_NID,
4625 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4626 .channel_mode = alc260_modes,
4627 .input_mux = &alc260_capture_source,
4628 .unsol_event = alc260_replacer_672v_unsol_event,
4629 .init_hook = alc260_replacer_672v_automute,
4631 #ifdef CONFIG_SND_DEBUG
4633 .mixers = { alc260_test_mixer,
4634 alc260_capture_mixer },
4635 .init_verbs = { alc260_test_init_verbs },
4636 .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
4637 .dac_nids = alc260_test_dac_nids,
4638 .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
4639 .adc_nids = alc260_test_adc_nids,
4640 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4641 .channel_mode = alc260_modes,
4642 .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources),
4643 .input_mux = alc260_test_capture_sources,
4648 static int patch_alc260(struct hda_codec *codec)
4650 struct alc_spec *spec;
4651 int err, board_config;
4653 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4659 board_config = snd_hda_check_board_config(codec, ALC260_MODEL_LAST,
4662 if (board_config < 0) {
4663 snd_printd(KERN_INFO "hda_codec: Unknown model for ALC260, "
4664 "trying auto-probe from BIOS...\n");
4665 board_config = ALC260_AUTO;
4668 if (board_config == ALC260_AUTO) {
4669 /* automatic parse from the BIOS config */
4670 err = alc260_parse_auto_config(codec);
4676 "hda_codec: Cannot set up configuration "
4677 "from BIOS. Using base mode...\n");
4678 board_config = ALC260_BASIC;
4682 if (board_config != ALC260_AUTO)
4683 setup_preset(spec, &alc260_presets[board_config]);
4685 spec->stream_name_analog = "ALC260 Analog";
4686 spec->stream_analog_playback = &alc260_pcm_analog_playback;
4687 spec->stream_analog_capture = &alc260_pcm_analog_capture;
4689 spec->stream_name_digital = "ALC260 Digital";
4690 spec->stream_digital_playback = &alc260_pcm_digital_playback;
4691 spec->stream_digital_capture = &alc260_pcm_digital_capture;
4693 codec->patch_ops = alc_patch_ops;
4694 if (board_config == ALC260_AUTO)
4695 spec->init_hook = alc260_auto_init;
4704 * ALC882 is almost identical with ALC880 but has cleaner and more flexible
4705 * configuration. Each pin widget can choose any input DACs and a mixer.
4706 * Each ADC is connected from a mixer of all inputs. This makes possible
4707 * 6-channel independent captures.
4709 * In addition, an independent DAC for the multi-playback (not used in this
4712 #define ALC882_DIGOUT_NID 0x06
4713 #define ALC882_DIGIN_NID 0x0a
4715 static struct hda_channel_mode alc882_ch_modes[1] = {
4719 static hda_nid_t alc882_dac_nids[4] = {
4720 /* front, rear, clfe, rear_surr */
4721 0x02, 0x03, 0x04, 0x05
4724 /* identical with ALC880 */
4725 #define alc882_adc_nids alc880_adc_nids
4726 #define alc882_adc_nids_alt alc880_adc_nids_alt
4729 /* FIXME: should be a matrix-type input source selection */
4731 static struct hda_input_mux alc882_capture_source = {
4735 { "Front Mic", 0x1 },
4740 #define alc882_mux_enum_info alc_mux_enum_info
4741 #define alc882_mux_enum_get alc_mux_enum_get
4743 static int alc882_mux_enum_put(struct snd_kcontrol *kcontrol,
4744 struct snd_ctl_elem_value *ucontrol)
4746 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4747 struct alc_spec *spec = codec->spec;
4748 const struct hda_input_mux *imux = spec->input_mux;
4749 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
4750 static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
4751 hda_nid_t nid = capture_mixers[adc_idx];
4752 unsigned int *cur_val = &spec->cur_mux[adc_idx];
4753 unsigned int i, idx;
4755 idx = ucontrol->value.enumerated.item[0];
4756 if (idx >= imux->num_items)
4757 idx = imux->num_items - 1;
4758 if (*cur_val == idx && !codec->in_resume)
4760 for (i = 0; i < imux->num_items; i++) {
4761 unsigned int v = (i == idx) ? 0x7000 : 0x7080;
4762 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
4763 v | (imux->items[i].index << 8));
4772 static struct hda_verb alc882_3ST_ch2_init[] = {
4773 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
4774 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
4775 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
4776 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
4783 static struct hda_verb alc882_3ST_ch6_init[] = {
4784 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4785 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
4786 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
4787 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4788 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
4789 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
4793 static struct hda_channel_mode alc882_3ST_6ch_modes[2] = {
4794 { 2, alc882_3ST_ch2_init },
4795 { 6, alc882_3ST_ch6_init },
4801 static struct hda_verb alc882_sixstack_ch6_init[] = {
4802 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
4803 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4804 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4805 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4812 static struct hda_verb alc882_sixstack_ch8_init[] = {
4813 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4814 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4815 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4816 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4820 static struct hda_channel_mode alc882_sixstack_modes[2] = {
4821 { 6, alc882_sixstack_ch6_init },
4822 { 8, alc882_sixstack_ch8_init },
4825 /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
4826 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
4828 static struct snd_kcontrol_new alc882_base_mixer[] = {
4829 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
4830 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
4831 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
4832 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
4833 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
4834 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
4835 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
4836 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
4837 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
4838 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
4839 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
4840 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
4841 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
4842 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
4843 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
4844 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
4845 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
4846 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
4847 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
4848 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
4849 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
4850 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
4851 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
4855 static struct snd_kcontrol_new alc882_w2jc_mixer[] = {
4856 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
4857 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
4858 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
4859 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
4860 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
4861 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
4862 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
4863 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
4864 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
4865 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
4866 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
4870 static struct snd_kcontrol_new alc882_targa_mixer[] = {
4871 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
4872 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
4873 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
4874 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
4875 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
4876 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
4877 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
4878 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
4879 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
4880 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
4881 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
4885 /* Pin assignment: Front=0x14, HP = 0x15, Front = 0x16, ???
4886 * Front Mic=0x18, Line In = 0x1a, Line In = 0x1b, CD = 0x1c
4888 static struct snd_kcontrol_new alc882_asus_a7j_mixer[] = {
4889 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
4890 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
4891 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
4892 HDA_CODEC_MUTE("Mobile Front Playback Switch", 0x16, 0x0, HDA_OUTPUT),
4893 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
4894 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
4895 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
4896 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
4897 HDA_CODEC_VOLUME("Mobile Line Playback Volume", 0x0b, 0x03, HDA_INPUT),
4898 HDA_CODEC_MUTE("Mobile Line Playback Switch", 0x0b, 0x03, HDA_INPUT),
4899 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
4900 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
4904 static struct snd_kcontrol_new alc882_chmode_mixer[] = {
4906 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4907 .name = "Channel Mode",
4908 .info = alc_ch_mode_info,
4909 .get = alc_ch_mode_get,
4910 .put = alc_ch_mode_put,
4915 static struct hda_verb alc882_init_verbs[] = {
4916 /* Front mixer: unmute input/output amp left and right (volume = 0) */
4917 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4918 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4919 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4921 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4922 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4923 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4925 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4926 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4927 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4929 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4930 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4931 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4933 /* Front Pin: output 0 (0x0c) */
4934 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4935 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4936 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
4937 /* Rear Pin: output 1 (0x0d) */
4938 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4939 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4940 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
4941 /* CLFE Pin: output 2 (0x0e) */
4942 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4943 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4944 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
4945 /* Side Pin: output 3 (0x0f) */
4946 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4947 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4948 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
4949 /* Mic (rear) pin: input vref at 80% */
4950 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
4951 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4952 /* Front Mic pin: input vref at 80% */
4953 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
4954 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4955 /* Line In pin: input */
4956 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
4957 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4958 /* Line-2 In: Headphone output (output 0 - 0x0c) */
4959 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4960 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4961 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
4962 /* CD pin widget for input */
4963 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
4965 /* FIXME: use matrix-type input source selection */
4966 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
4967 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
4968 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4969 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4970 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4971 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
4973 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4974 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4975 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4976 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
4978 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4979 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4980 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4981 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
4982 /* ADC1: mute amp left and right */
4983 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4984 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
4985 /* ADC2: mute amp left and right */
4986 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4987 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
4988 /* ADC3: mute amp left and right */
4989 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4990 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
4995 static struct hda_verb alc882_eapd_verbs[] = {
4996 /* change to EAPD mode */
4997 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
4998 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
5003 static struct snd_kcontrol_new alc882_macpro_mixer[] = {
5004 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5005 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5006 HDA_CODEC_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT),
5007 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
5008 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
5009 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x02, HDA_INPUT),
5010 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x02, HDA_INPUT),
5014 static struct hda_verb alc882_macpro_init_verbs[] = {
5015 /* Front mixer: unmute input/output amp left and right (volume = 0) */
5016 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5017 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5018 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5019 /* Front Pin: output 0 (0x0c) */
5020 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5021 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5022 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
5023 /* Front Mic pin: input vref at 80% */
5024 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5025 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5026 /* Speaker: output */
5027 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5028 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5029 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x04},
5030 /* Headphone output (output 0 - 0x0c) */
5031 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5032 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5033 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
5035 /* FIXME: use matrix-type input source selection */
5036 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5037 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
5038 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5039 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5040 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5041 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5043 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5044 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5045 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5046 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5048 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5049 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5050 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5051 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5052 /* ADC1: mute amp left and right */
5053 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5054 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
5055 /* ADC2: mute amp left and right */
5056 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5057 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
5058 /* ADC3: mute amp left and right */
5059 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5060 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
5065 static struct hda_verb alc882_targa_verbs[] = {
5066 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5067 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5069 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5070 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5072 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
5073 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
5074 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
5076 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
5077 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
5078 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
5079 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
5083 /* toggle speaker-output according to the hp-jack state */
5084 static void alc882_targa_automute(struct hda_codec *codec)
5086 unsigned int present;
5088 present = snd_hda_codec_read(codec, 0x14, 0,
5089 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
5090 snd_hda_codec_amp_update(codec, 0x1b, 0, HDA_OUTPUT, 0,
5091 0x80, present ? 0x80 : 0);
5092 snd_hda_codec_amp_update(codec, 0x1b, 1, HDA_OUTPUT, 0,
5093 0x80, present ? 0x80 : 0);
5094 snd_hda_codec_write(codec, 1, 0, AC_VERB_SET_GPIO_DATA, present ? 1 : 3);
5097 static void alc882_targa_unsol_event(struct hda_codec *codec, unsigned int res)
5099 /* Looks like the unsol event is incompatible with the standard
5100 * definition. 4bit tag is placed at 26 bit!
5102 if (((res >> 26) == ALC880_HP_EVENT)) {
5103 alc882_targa_automute(codec);
5107 static struct hda_verb alc882_asus_a7j_verbs[] = {
5108 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5109 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5111 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5112 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5113 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5115 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
5116 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
5117 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
5119 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
5120 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
5121 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
5125 static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
5127 unsigned int gpiostate, gpiomask, gpiodir;
5129 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
5130 AC_VERB_GET_GPIO_DATA, 0);
5133 gpiostate |= (1 << pin);
5135 gpiostate &= ~(1 << pin);
5137 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
5138 AC_VERB_GET_GPIO_MASK, 0);
5139 gpiomask |= (1 << pin);
5141 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
5142 AC_VERB_GET_GPIO_DIRECTION, 0);
5143 gpiodir |= (1 << pin);
5146 snd_hda_codec_write(codec, codec->afg, 0,
5147 AC_VERB_SET_GPIO_MASK, gpiomask);
5148 snd_hda_codec_write(codec, codec->afg, 0,
5149 AC_VERB_SET_GPIO_DIRECTION, gpiodir);
5153 snd_hda_codec_write(codec, codec->afg, 0,
5154 AC_VERB_SET_GPIO_DATA, gpiostate);
5158 * generic initialization of ADC, input mixers and output mixers
5160 static struct hda_verb alc882_auto_init_verbs[] = {
5162 * Unmute ADC0-2 and set the default input to mic-in
5164 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
5165 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5166 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
5167 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5168 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
5169 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5171 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
5173 * Note: PASD motherboards uses the Line In 2 as the input for
5174 * front panel mic (mic 2)
5176 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
5177 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5178 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5179 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
5180 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
5181 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
5184 * Set up output mixers (0x0c - 0x0f)
5186 /* set vol=0 to output mixers */
5187 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5188 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5189 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5190 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5191 /* set up input amps for analog loopback */
5192 /* Amp Indices: DAC = 0, mixer = 1 */
5193 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5194 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5195 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5196 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5197 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5198 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5199 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5200 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5201 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5202 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5204 /* FIXME: use matrix-type input source selection */
5205 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5206 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
5207 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5208 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
5209 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
5210 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
5212 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5213 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
5214 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
5215 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
5217 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5218 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
5219 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
5220 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
5225 /* capture mixer elements */
5226 static struct snd_kcontrol_new alc882_capture_alt_mixer[] = {
5227 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
5228 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
5229 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
5230 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
5232 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5233 /* The multiple "Capture Source" controls confuse alsamixer
5234 * So call somewhat different..
5235 * FIXME: the controls appear in the "playback" view!
5237 /* .name = "Capture Source", */
5238 .name = "Input Source",
5240 .info = alc882_mux_enum_info,
5241 .get = alc882_mux_enum_get,
5242 .put = alc882_mux_enum_put,
5247 static struct snd_kcontrol_new alc882_capture_mixer[] = {
5248 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
5249 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
5250 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
5251 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
5252 HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
5253 HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
5255 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5256 /* The multiple "Capture Source" controls confuse alsamixer
5257 * So call somewhat different..
5258 * FIXME: the controls appear in the "playback" view!
5260 /* .name = "Capture Source", */
5261 .name = "Input Source",
5263 .info = alc882_mux_enum_info,
5264 .get = alc882_mux_enum_get,
5265 .put = alc882_mux_enum_put,
5270 /* pcm configuration: identiacal with ALC880 */
5271 #define alc882_pcm_analog_playback alc880_pcm_analog_playback
5272 #define alc882_pcm_analog_capture alc880_pcm_analog_capture
5273 #define alc882_pcm_digital_playback alc880_pcm_digital_playback
5274 #define alc882_pcm_digital_capture alc880_pcm_digital_capture
5277 * configuration and preset
5279 static const char *alc882_models[ALC882_MODEL_LAST] = {
5280 [ALC882_3ST_DIG] = "3stack-dig",
5281 [ALC882_6ST_DIG] = "6stack-dig",
5282 [ALC882_ARIMA] = "arima",
5283 [ALC882_W2JC] = "w2jc",
5284 [ALC885_MACPRO] = "macpro",
5285 [ALC882_AUTO] = "auto",
5288 static struct snd_pci_quirk alc882_cfg_tbl[] = {
5289 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG),
5290 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG),
5291 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG),
5292 SND_PCI_QUIRK(0x1462, 0x28fb, "Targa T8", ALC882_TARGA), /* MSI-1049 T8 */
5293 SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA),
5294 SND_PCI_QUIRK(0x1043, 0x060d, "Asus A7J", ALC882_ASUS_A7J),
5295 SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG),
5296 SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_W2JC),
5300 static struct alc_config_preset alc882_presets[] = {
5301 [ALC882_3ST_DIG] = {
5302 .mixers = { alc882_base_mixer },
5303 .init_verbs = { alc882_init_verbs },
5304 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5305 .dac_nids = alc882_dac_nids,
5306 .dig_out_nid = ALC882_DIGOUT_NID,
5307 .dig_in_nid = ALC882_DIGIN_NID,
5308 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
5309 .channel_mode = alc882_ch_modes,
5311 .input_mux = &alc882_capture_source,
5313 [ALC882_6ST_DIG] = {
5314 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
5315 .init_verbs = { alc882_init_verbs },
5316 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5317 .dac_nids = alc882_dac_nids,
5318 .dig_out_nid = ALC882_DIGOUT_NID,
5319 .dig_in_nid = ALC882_DIGIN_NID,
5320 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
5321 .channel_mode = alc882_sixstack_modes,
5322 .input_mux = &alc882_capture_source,
5325 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
5326 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs },
5327 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5328 .dac_nids = alc882_dac_nids,
5329 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
5330 .channel_mode = alc882_sixstack_modes,
5331 .input_mux = &alc882_capture_source,
5334 .mixers = { alc882_w2jc_mixer, alc882_chmode_mixer },
5335 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs,
5336 alc880_gpio1_init_verbs },
5337 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5338 .dac_nids = alc882_dac_nids,
5339 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
5340 .channel_mode = alc880_threestack_modes,
5342 .input_mux = &alc882_capture_source,
5343 .dig_out_nid = ALC882_DIGOUT_NID,
5346 .mixers = { alc882_macpro_mixer },
5347 .init_verbs = { alc882_macpro_init_verbs },
5348 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5349 .dac_nids = alc882_dac_nids,
5350 .dig_out_nid = ALC882_DIGOUT_NID,
5351 .dig_in_nid = ALC882_DIGIN_NID,
5352 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
5353 .channel_mode = alc882_ch_modes,
5354 .input_mux = &alc882_capture_source,
5357 .mixers = { alc882_targa_mixer, alc882_chmode_mixer,
5358 alc882_capture_mixer },
5359 .init_verbs = { alc882_init_verbs, alc882_targa_verbs},
5360 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5361 .dac_nids = alc882_dac_nids,
5362 .dig_out_nid = ALC882_DIGOUT_NID,
5363 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
5364 .adc_nids = alc882_adc_nids,
5365 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
5366 .channel_mode = alc882_3ST_6ch_modes,
5368 .input_mux = &alc882_capture_source,
5369 .unsol_event = alc882_targa_unsol_event,
5370 .init_hook = alc882_targa_automute,
5372 [ALC882_ASUS_A7J] = {
5373 .mixers = { alc882_asus_a7j_mixer, alc882_chmode_mixer,
5374 alc882_capture_mixer },
5375 .init_verbs = { alc882_init_verbs, alc882_asus_a7j_verbs},
5376 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5377 .dac_nids = alc882_dac_nids,
5378 .dig_out_nid = ALC882_DIGOUT_NID,
5379 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
5380 .adc_nids = alc882_adc_nids,
5381 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
5382 .channel_mode = alc882_3ST_6ch_modes,
5384 .input_mux = &alc882_capture_source,
5390 * BIOS auto configuration
5392 static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
5393 hda_nid_t nid, int pin_type,
5397 struct alc_spec *spec = codec->spec;
5400 if (spec->multiout.dac_nids[dac_idx] == 0x25)
5403 idx = spec->multiout.dac_nids[dac_idx] - 2;
5405 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5407 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
5409 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
5413 static void alc882_auto_init_multi_out(struct hda_codec *codec)
5415 struct alc_spec *spec = codec->spec;
5418 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
5419 for (i = 0; i <= HDA_SIDE; i++) {
5420 hda_nid_t nid = spec->autocfg.line_out_pins[i];
5421 int pin_type = get_pin_type(spec->autocfg.line_out_type);
5423 alc882_auto_set_output_and_unmute(codec, nid, pin_type,
5428 static void alc882_auto_init_hp_out(struct hda_codec *codec)
5430 struct alc_spec *spec = codec->spec;
5433 pin = spec->autocfg.hp_pins[0];
5434 if (pin) /* connect to front */
5436 alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
5439 #define alc882_is_input_pin(nid) alc880_is_input_pin(nid)
5440 #define ALC882_PIN_CD_NID ALC880_PIN_CD_NID
5442 static void alc882_auto_init_analog_input(struct hda_codec *codec)
5444 struct alc_spec *spec = codec->spec;
5447 for (i = 0; i < AUTO_PIN_LAST; i++) {
5448 hda_nid_t nid = spec->autocfg.input_pins[i];
5449 if (alc882_is_input_pin(nid)) {
5450 snd_hda_codec_write(codec, nid, 0,
5451 AC_VERB_SET_PIN_WIDGET_CONTROL,
5452 i <= AUTO_PIN_FRONT_MIC ?
5453 PIN_VREF80 : PIN_IN);
5454 if (nid != ALC882_PIN_CD_NID)
5455 snd_hda_codec_write(codec, nid, 0,
5456 AC_VERB_SET_AMP_GAIN_MUTE,
5462 /* almost identical with ALC880 parser... */
5463 static int alc882_parse_auto_config(struct hda_codec *codec)
5465 struct alc_spec *spec = codec->spec;
5466 int err = alc880_parse_auto_config(codec);
5471 /* hack - override the init verbs */
5472 spec->init_verbs[0] = alc882_auto_init_verbs;
5476 /* additional initialization for auto-configuration model */
5477 static void alc882_auto_init(struct hda_codec *codec)
5479 alc882_auto_init_multi_out(codec);
5480 alc882_auto_init_hp_out(codec);
5481 alc882_auto_init_analog_input(codec);
5484 static int patch_alc882(struct hda_codec *codec)
5486 struct alc_spec *spec;
5487 int err, board_config;
5489 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5495 board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST,
5499 if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
5500 /* Pick up systems that don't supply PCI SSID */
5501 switch (codec->subsystem_id) {
5502 case 0x106b0c00: /* Mac Pro */
5503 board_config = ALC885_MACPRO;
5506 printk(KERN_INFO "hda_codec: Unknown model for ALC882, "
5507 "trying auto-probe from BIOS...\n");
5508 board_config = ALC882_AUTO;
5512 if (board_config == ALC882_AUTO) {
5513 /* automatic parse from the BIOS config */
5514 err = alc882_parse_auto_config(codec);
5520 "hda_codec: Cannot set up configuration "
5521 "from BIOS. Using base mode...\n");
5522 board_config = ALC882_3ST_DIG;
5526 if (board_config != ALC882_AUTO)
5527 setup_preset(spec, &alc882_presets[board_config]);
5529 if (board_config == ALC885_MACPRO) {
5530 alc882_gpio_mute(codec, 0, 0);
5531 alc882_gpio_mute(codec, 1, 0);
5534 spec->stream_name_analog = "ALC882 Analog";
5535 spec->stream_analog_playback = &alc882_pcm_analog_playback;
5536 spec->stream_analog_capture = &alc882_pcm_analog_capture;
5538 spec->stream_name_digital = "ALC882 Digital";
5539 spec->stream_digital_playback = &alc882_pcm_digital_playback;
5540 spec->stream_digital_capture = &alc882_pcm_digital_capture;
5542 if (!spec->adc_nids && spec->input_mux) {
5543 /* check whether NID 0x07 is valid */
5544 unsigned int wcap = get_wcaps(codec, 0x07);
5546 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
5547 if (wcap != AC_WID_AUD_IN) {
5548 spec->adc_nids = alc882_adc_nids_alt;
5549 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids_alt);
5550 spec->mixers[spec->num_mixers] =
5551 alc882_capture_alt_mixer;
5554 spec->adc_nids = alc882_adc_nids;
5555 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids);
5556 spec->mixers[spec->num_mixers] = alc882_capture_mixer;
5561 codec->patch_ops = alc_patch_ops;
5562 if (board_config == ALC882_AUTO)
5563 spec->init_hook = alc882_auto_init;
5571 * ALC883 is almost identical with ALC880 but has cleaner and more flexible
5572 * configuration. Each pin widget can choose any input DACs and a mixer.
5573 * Each ADC is connected from a mixer of all inputs. This makes possible
5574 * 6-channel independent captures.
5576 * In addition, an independent DAC for the multi-playback (not used in this
5579 #define ALC883_DIGOUT_NID 0x06
5580 #define ALC883_DIGIN_NID 0x0a
5582 static hda_nid_t alc883_dac_nids[4] = {
5583 /* front, rear, clfe, rear_surr */
5584 0x02, 0x04, 0x03, 0x05
5587 static hda_nid_t alc883_adc_nids[2] = {
5593 /* FIXME: should be a matrix-type input source selection */
5595 static struct hda_input_mux alc883_capture_source = {
5599 { "Front Mic", 0x1 },
5605 static struct hda_input_mux alc883_lenovo_101e_capture_source = {
5613 static struct hda_input_mux alc883_lenovo_nb0763_capture_source = {
5623 #define alc883_mux_enum_info alc_mux_enum_info
5624 #define alc883_mux_enum_get alc_mux_enum_get
5626 static int alc883_mux_enum_put(struct snd_kcontrol *kcontrol,
5627 struct snd_ctl_elem_value *ucontrol)
5629 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
5630 struct alc_spec *spec = codec->spec;
5631 const struct hda_input_mux *imux = spec->input_mux;
5632 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
5633 static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
5634 hda_nid_t nid = capture_mixers[adc_idx];
5635 unsigned int *cur_val = &spec->cur_mux[adc_idx];
5636 unsigned int i, idx;
5638 idx = ucontrol->value.enumerated.item[0];
5639 if (idx >= imux->num_items)
5640 idx = imux->num_items - 1;
5641 if (*cur_val == idx && !codec->in_resume)
5643 for (i = 0; i < imux->num_items; i++) {
5644 unsigned int v = (i == idx) ? 0x7000 : 0x7080;
5645 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
5646 v | (imux->items[i].index << 8));
5655 static struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
5662 static struct hda_verb alc883_3ST_ch2_init[] = {
5663 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
5664 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
5665 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
5666 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
5673 static struct hda_verb alc883_3ST_ch6_init[] = {
5674 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5675 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
5676 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
5677 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5678 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
5679 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
5683 static struct hda_channel_mode alc883_3ST_6ch_modes[2] = {
5684 { 2, alc883_3ST_ch2_init },
5685 { 6, alc883_3ST_ch6_init },
5691 static struct hda_verb alc883_sixstack_ch6_init[] = {
5692 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
5693 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5694 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5695 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5702 static struct hda_verb alc883_sixstack_ch8_init[] = {
5703 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5704 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5705 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5706 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5710 static struct hda_channel_mode alc883_sixstack_modes[2] = {
5711 { 6, alc883_sixstack_ch6_init },
5712 { 8, alc883_sixstack_ch8_init },
5715 static struct hda_verb alc883_medion_eapd_verbs[] = {
5716 /* eanable EAPD on medion laptop */
5717 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
5718 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
5722 /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
5723 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
5726 static struct snd_kcontrol_new alc883_base_mixer[] = {
5727 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5728 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5729 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
5730 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
5731 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
5732 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
5733 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
5734 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
5735 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
5736 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
5737 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5738 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5739 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5740 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5741 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5742 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5743 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
5744 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5745 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
5746 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
5747 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
5748 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
5749 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
5750 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
5751 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
5752 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
5753 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
5755 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5756 /* .name = "Capture Source", */
5757 .name = "Input Source",
5759 .info = alc883_mux_enum_info,
5760 .get = alc883_mux_enum_get,
5761 .put = alc883_mux_enum_put,
5766 static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
5767 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5768 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5769 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5770 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5771 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5772 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5773 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5774 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5775 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
5776 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5777 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
5778 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
5779 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
5780 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
5781 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
5782 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
5783 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
5784 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
5785 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
5787 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5788 /* .name = "Capture Source", */
5789 .name = "Input Source",
5791 .info = alc883_mux_enum_info,
5792 .get = alc883_mux_enum_get,
5793 .put = alc883_mux_enum_put,
5798 static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
5799 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5800 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5801 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
5802 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
5803 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
5804 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
5805 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
5806 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
5807 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5808 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5809 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5810 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5811 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5812 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5813 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
5814 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5815 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
5816 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
5817 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
5818 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
5819 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
5820 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
5821 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
5822 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
5823 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
5825 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5826 /* .name = "Capture Source", */
5827 .name = "Input Source",
5829 .info = alc883_mux_enum_info,
5830 .get = alc883_mux_enum_get,
5831 .put = alc883_mux_enum_put,
5836 static struct snd_kcontrol_new alc883_fivestack_mixer[] = {
5837 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5838 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
5839 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
5840 HDA_CODEC_MUTE("Surround Playback Switch", 0x15, 0x0, HDA_OUTPUT),
5841 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
5842 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
5843 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x16, 1, 0x0, HDA_OUTPUT),
5844 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
5845 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5846 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5847 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5848 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5849 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5850 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5851 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
5852 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5853 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
5854 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
5855 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
5856 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
5857 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
5858 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
5859 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
5862 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5863 /* .name = "Capture Source", */
5864 .name = "Input Source",
5866 .info = alc883_mux_enum_info,
5867 .get = alc883_mux_enum_get,
5868 .put = alc883_mux_enum_put,
5873 static struct snd_kcontrol_new alc883_tagra_mixer[] = {
5874 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5875 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
5876 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5877 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
5878 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
5879 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
5880 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
5881 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
5882 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
5883 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5884 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5885 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5886 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5887 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5888 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
5889 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5890 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
5891 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
5892 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
5893 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
5895 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5896 /* .name = "Capture Source", */
5897 .name = "Input Source",
5899 .info = alc883_mux_enum_info,
5900 .get = alc883_mux_enum_get,
5901 .put = alc883_mux_enum_put,
5906 static struct snd_kcontrol_new alc883_tagra_2ch_mixer[] = {
5907 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5908 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
5909 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5910 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5911 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5912 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5913 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
5914 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5915 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
5916 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
5917 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
5918 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
5920 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5921 /* .name = "Capture Source", */
5922 .name = "Input Source",
5924 .info = alc883_mux_enum_info,
5925 .get = alc883_mux_enum_get,
5926 .put = alc883_mux_enum_put,
5931 static struct snd_kcontrol_new alc883_lenovo_101e_2ch_mixer[] = {
5932 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5933 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5934 HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
5935 HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT),
5936 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5937 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
5938 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
5939 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
5940 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
5941 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
5943 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5944 /* .name = "Capture Source", */
5945 .name = "Input Source",
5947 .info = alc883_mux_enum_info,
5948 .get = alc883_mux_enum_get,
5949 .put = alc883_mux_enum_put,
5954 static struct snd_kcontrol_new alc883_lenovo_nb0763_mixer[] = {
5955 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5956 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
5957 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
5958 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5959 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5960 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5961 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5962 HDA_CODEC_VOLUME("iMic Playback Volume", 0x0b, 0x1, HDA_INPUT),
5963 HDA_CODEC_MUTE("iMic Playback Switch", 0x0b, 0x1, HDA_INPUT),
5964 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
5965 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
5966 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
5967 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
5969 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5970 /* .name = "Capture Source", */
5971 .name = "Input Source",
5973 .info = alc883_mux_enum_info,
5974 .get = alc883_mux_enum_get,
5975 .put = alc883_mux_enum_put,
5980 static struct snd_kcontrol_new alc883_medion_md2_mixer[] = {
5981 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5982 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
5983 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
5984 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5985 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5986 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5987 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5988 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5989 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5990 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
5991 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
5992 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
5993 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
5995 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5996 /* .name = "Capture Source", */
5997 .name = "Input Source",
5999 .info = alc883_mux_enum_info,
6000 .get = alc883_mux_enum_get,
6001 .put = alc883_mux_enum_put,
6006 static struct snd_kcontrol_new alc883_chmode_mixer[] = {
6008 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6009 .name = "Channel Mode",
6010 .info = alc_ch_mode_info,
6011 .get = alc_ch_mode_get,
6012 .put = alc_ch_mode_put,
6017 static struct hda_verb alc883_init_verbs[] = {
6018 /* ADC1: mute amp left and right */
6019 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6020 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6021 /* ADC2: mute amp left and right */
6022 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6023 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
6024 /* Front mixer: unmute input/output amp left and right (volume = 0) */
6025 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6026 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6027 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6029 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6030 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6031 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6033 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6034 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6035 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6037 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6038 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6039 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6041 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6042 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6043 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
6044 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
6045 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
6047 /* Front Pin: output 0 (0x0c) */
6048 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6049 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6050 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
6051 /* Rear Pin: output 1 (0x0d) */
6052 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6053 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6054 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
6055 /* CLFE Pin: output 2 (0x0e) */
6056 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6057 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6058 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
6059 /* Side Pin: output 3 (0x0f) */
6060 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6061 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6062 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
6063 /* Mic (rear) pin: input vref at 80% */
6064 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6065 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6066 /* Front Mic pin: input vref at 80% */
6067 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6068 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6069 /* Line In pin: input */
6070 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
6071 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6072 /* Line-2 In: Headphone output (output 0 - 0x0c) */
6073 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6074 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6075 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
6076 /* CD pin widget for input */
6077 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
6079 /* FIXME: use matrix-type input source selection */
6080 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6082 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6083 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6084 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
6085 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
6087 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6088 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6089 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
6090 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
6094 static struct hda_verb alc883_tagra_verbs[] = {
6095 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6096 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6098 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6099 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6101 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
6102 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
6103 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6105 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
6106 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
6107 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
6108 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
6113 static struct hda_verb alc883_lenovo_101e_verbs[] = {
6114 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
6115 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT|AC_USRSP_EN},
6116 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT|AC_USRSP_EN},
6120 static struct hda_verb alc883_lenovo_nb0763_verbs[] = {
6121 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
6122 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6123 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
6124 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6128 static struct hda_verb alc888_lenovo_ms7195_verbs[] = {
6129 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6130 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6131 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
6132 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT | AC_USRSP_EN},
6133 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
6137 /* toggle front-jack and RCA according to the hp-jack state */
6138 static void alc888_lenovo_ms7195_front_automute(struct hda_codec *codec)
6140 unsigned int present;
6142 present = snd_hda_codec_read(codec, 0x1b, 0,
6143 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
6144 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
6145 0x80, present ? 0x80 : 0);
6146 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
6147 0x80, present ? 0x80 : 0);
6148 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
6149 0x80, present ? 0x80 : 0);
6150 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
6151 0x80, present ? 0x80 : 0);
6155 /* toggle RCA according to the front-jack state */
6156 static void alc888_lenovo_ms7195_rca_automute(struct hda_codec *codec)
6158 unsigned int present;
6160 present = snd_hda_codec_read(codec, 0x14, 0,
6161 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
6162 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
6163 0x80, present ? 0x80 : 0);
6164 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
6165 0x80, present ? 0x80 : 0);
6168 static void alc883_lenovo_ms7195_unsol_event(struct hda_codec *codec,
6171 if ((res >> 26) == ALC880_HP_EVENT)
6172 alc888_lenovo_ms7195_front_automute(codec);
6173 if ((res >> 26) == ALC880_FRONT_EVENT)
6174 alc888_lenovo_ms7195_rca_automute(codec);
6177 static struct hda_verb alc883_medion_md2_verbs[] = {
6178 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6179 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6181 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6183 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
6187 /* toggle speaker-output according to the hp-jack state */
6188 static void alc883_medion_md2_automute(struct hda_codec *codec)
6190 unsigned int present;
6192 present = snd_hda_codec_read(codec, 0x14, 0,
6193 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
6194 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
6195 0x80, present ? 0x80 : 0);
6196 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
6197 0x80, present ? 0x80 : 0);
6200 static void alc883_medion_md2_unsol_event(struct hda_codec *codec,
6203 if ((res >> 26) == ALC880_HP_EVENT)
6204 alc883_medion_md2_automute(codec);
6207 /* toggle speaker-output according to the hp-jack state */
6208 static void alc883_tagra_automute(struct hda_codec *codec)
6210 unsigned int present;
6213 present = snd_hda_codec_read(codec, 0x14, 0,
6214 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
6215 bits = present ? 0x80 : 0;
6216 snd_hda_codec_amp_update(codec, 0x1b, 0, HDA_OUTPUT, 0,
6218 snd_hda_codec_amp_update(codec, 0x1b, 1, HDA_OUTPUT, 0,
6220 snd_hda_codec_write(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
6224 static void alc883_tagra_unsol_event(struct hda_codec *codec, unsigned int res)
6226 if ((res >> 26) == ALC880_HP_EVENT)
6227 alc883_tagra_automute(codec);
6230 static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
6232 unsigned int present;
6235 present = snd_hda_codec_read(codec, 0x14, 0,
6236 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
6237 bits = present ? 0x80 : 0;
6238 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
6240 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
6244 static void alc883_lenovo_101e_all_automute(struct hda_codec *codec)
6246 unsigned int present;
6249 present = snd_hda_codec_read(codec, 0x1b, 0,
6250 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
6251 bits = present ? 0x80 : 0;
6252 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
6254 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
6256 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
6258 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
6262 static void alc883_lenovo_101e_unsol_event(struct hda_codec *codec,
6265 if ((res >> 26) == ALC880_HP_EVENT)
6266 alc883_lenovo_101e_all_automute(codec);
6267 if ((res >> 26) == ALC880_FRONT_EVENT)
6268 alc883_lenovo_101e_ispeaker_automute(codec);
6272 * generic initialization of ADC, input mixers and output mixers
6274 static struct hda_verb alc883_auto_init_verbs[] = {
6276 * Unmute ADC0-2 and set the default input to mic-in
6278 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6279 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6280 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
6281 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6283 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
6285 * Note: PASD motherboards uses the Line In 2 as the input for
6286 * front panel mic (mic 2)
6288 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
6289 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6290 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6291 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
6292 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
6293 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
6296 * Set up output mixers (0x0c - 0x0f)
6298 /* set vol=0 to output mixers */
6299 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6300 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6301 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6302 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6303 /* set up input amps for analog loopback */
6304 /* Amp Indices: DAC = 0, mixer = 1 */
6305 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6306 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6307 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6308 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6309 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6310 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6311 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6312 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6313 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6314 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6316 /* FIXME: use matrix-type input source selection */
6317 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6319 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6320 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6321 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
6322 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
6323 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
6325 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6326 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6327 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
6328 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
6329 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
6334 /* capture mixer elements */
6335 static struct snd_kcontrol_new alc883_capture_mixer[] = {
6336 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6337 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6338 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6339 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6341 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6342 /* The multiple "Capture Source" controls confuse alsamixer
6343 * So call somewhat different..
6344 * FIXME: the controls appear in the "playback" view!
6346 /* .name = "Capture Source", */
6347 .name = "Input Source",
6349 .info = alc882_mux_enum_info,
6350 .get = alc882_mux_enum_get,
6351 .put = alc882_mux_enum_put,
6356 /* pcm configuration: identiacal with ALC880 */
6357 #define alc883_pcm_analog_playback alc880_pcm_analog_playback
6358 #define alc883_pcm_analog_capture alc880_pcm_analog_capture
6359 #define alc883_pcm_digital_playback alc880_pcm_digital_playback
6360 #define alc883_pcm_digital_capture alc880_pcm_digital_capture
6363 * configuration and preset
6365 static const char *alc883_models[ALC883_MODEL_LAST] = {
6366 [ALC883_3ST_2ch_DIG] = "3stack-dig",
6367 [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig",
6368 [ALC883_3ST_6ch] = "3stack-6ch",
6369 [ALC883_6ST_DIG] = "6stack-dig",
6370 [ALC883_TARGA_DIG] = "targa-dig",
6371 [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig",
6372 [ALC883_ACER] = "acer",
6373 [ALC883_MEDION] = "medion",
6374 [ALC883_MEDION_MD2] = "medion-md2",
6375 [ALC883_LAPTOP_EAPD] = "laptop-eapd",
6376 [ALC883_LENOVO_101E_2ch] = "lenovo-101e",
6377 [ALC883_LENOVO_NB0763] = "lenovo-nb0763",
6378 [ALC888_LENOVO_MS7195_DIG] = "lenovo-ms7195-dig",
6379 [ALC883_AUTO] = "auto",
6382 static struct snd_pci_quirk alc883_cfg_tbl[] = {
6383 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC883_3ST_6ch_DIG),
6384 SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG),
6385 SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch),
6386 SND_PCI_QUIRK(0x1558, 0, "Clevo laptop", ALC883_LAPTOP_EAPD),
6387 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC883_6ST_DIG),
6388 SND_PCI_QUIRK(0x1458, 0xa002, "MSI", ALC883_6ST_DIG),
6389 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG),
6390 SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG),
6391 SND_PCI_QUIRK(0x1462, 0x7250, "MSI", ALC883_6ST_DIG),
6392 SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG),
6393 SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG),
6394 SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG),
6395 SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG),
6396 SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG),
6397 SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG),
6398 SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG),
6399 SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG),
6400 SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG),
6401 SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG),
6402 SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG),
6403 SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG),
6404 SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG),
6405 SND_PCI_QUIRK(0x1025, 0, "Acer laptop", ALC883_ACER),
6406 SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch),
6407 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
6408 SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD),
6409 SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC883_3ST_6ch),
6410 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch),
6411 SND_PCI_QUIRK(0x17aa, 0x3bfd, "Lenovo NB0763", ALC883_LENOVO_NB0763),
6412 SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763),
6413 SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC883_6ST_DIG),
6414 SND_PCI_QUIRK(0x17c0, 0x4071, "MEDION MD2", ALC883_MEDION_MD2),
6418 static struct alc_config_preset alc883_presets[] = {
6419 [ALC883_3ST_2ch_DIG] = {
6420 .mixers = { alc883_3ST_2ch_mixer },
6421 .init_verbs = { alc883_init_verbs },
6422 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6423 .dac_nids = alc883_dac_nids,
6424 .dig_out_nid = ALC883_DIGOUT_NID,
6425 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6426 .adc_nids = alc883_adc_nids,
6427 .dig_in_nid = ALC883_DIGIN_NID,
6428 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
6429 .channel_mode = alc883_3ST_2ch_modes,
6430 .input_mux = &alc883_capture_source,
6432 [ALC883_3ST_6ch_DIG] = {
6433 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
6434 .init_verbs = { alc883_init_verbs },
6435 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6436 .dac_nids = alc883_dac_nids,
6437 .dig_out_nid = ALC883_DIGOUT_NID,
6438 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6439 .adc_nids = alc883_adc_nids,
6440 .dig_in_nid = ALC883_DIGIN_NID,
6441 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
6442 .channel_mode = alc883_3ST_6ch_modes,
6444 .input_mux = &alc883_capture_source,
6446 [ALC883_3ST_6ch] = {
6447 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
6448 .init_verbs = { alc883_init_verbs },
6449 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6450 .dac_nids = alc883_dac_nids,
6451 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6452 .adc_nids = alc883_adc_nids,
6453 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
6454 .channel_mode = alc883_3ST_6ch_modes,
6456 .input_mux = &alc883_capture_source,
6458 [ALC883_6ST_DIG] = {
6459 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
6460 .init_verbs = { alc883_init_verbs },
6461 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6462 .dac_nids = alc883_dac_nids,
6463 .dig_out_nid = ALC883_DIGOUT_NID,
6464 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6465 .adc_nids = alc883_adc_nids,
6466 .dig_in_nid = ALC883_DIGIN_NID,
6467 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
6468 .channel_mode = alc883_sixstack_modes,
6469 .input_mux = &alc883_capture_source,
6471 [ALC883_TARGA_DIG] = {
6472 .mixers = { alc883_tagra_mixer, alc883_chmode_mixer },
6473 .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
6474 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6475 .dac_nids = alc883_dac_nids,
6476 .dig_out_nid = ALC883_DIGOUT_NID,
6477 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6478 .adc_nids = alc883_adc_nids,
6479 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
6480 .channel_mode = alc883_3ST_6ch_modes,
6482 .input_mux = &alc883_capture_source,
6483 .unsol_event = alc883_tagra_unsol_event,
6484 .init_hook = alc883_tagra_automute,
6486 [ALC883_TARGA_2ch_DIG] = {
6487 .mixers = { alc883_tagra_2ch_mixer},
6488 .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
6489 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6490 .dac_nids = alc883_dac_nids,
6491 .dig_out_nid = ALC883_DIGOUT_NID,
6492 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6493 .adc_nids = alc883_adc_nids,
6494 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
6495 .channel_mode = alc883_3ST_2ch_modes,
6496 .input_mux = &alc883_capture_source,
6497 .unsol_event = alc883_tagra_unsol_event,
6498 .init_hook = alc883_tagra_automute,
6501 .mixers = { alc883_base_mixer,
6502 alc883_chmode_mixer },
6503 /* On TravelMate laptops, GPIO 0 enables the internal speaker
6504 * and the headphone jack. Turn this on and rely on the
6505 * standard mute methods whenever the user wants to turn
6506 * these outputs off.
6508 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs },
6509 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6510 .dac_nids = alc883_dac_nids,
6511 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6512 .adc_nids = alc883_adc_nids,
6513 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
6514 .channel_mode = alc883_3ST_2ch_modes,
6515 .input_mux = &alc883_capture_source,
6518 .mixers = { alc883_fivestack_mixer,
6519 alc883_chmode_mixer },
6520 .init_verbs = { alc883_init_verbs,
6521 alc883_medion_eapd_verbs },
6522 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6523 .dac_nids = alc883_dac_nids,
6524 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6525 .adc_nids = alc883_adc_nids,
6526 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
6527 .channel_mode = alc883_sixstack_modes,
6528 .input_mux = &alc883_capture_source,
6530 [ALC883_MEDION_MD2] = {
6531 .mixers = { alc883_medion_md2_mixer},
6532 .init_verbs = { alc883_init_verbs, alc883_medion_md2_verbs},
6533 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6534 .dac_nids = alc883_dac_nids,
6535 .dig_out_nid = ALC883_DIGOUT_NID,
6536 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6537 .adc_nids = alc883_adc_nids,
6538 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
6539 .channel_mode = alc883_3ST_2ch_modes,
6540 .input_mux = &alc883_capture_source,
6541 .unsol_event = alc883_medion_md2_unsol_event,
6542 .init_hook = alc883_medion_md2_automute,
6544 [ALC883_LAPTOP_EAPD] = {
6545 .mixers = { alc883_base_mixer,
6546 alc883_chmode_mixer },
6547 .init_verbs = { alc883_init_verbs, alc882_eapd_verbs },
6548 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6549 .dac_nids = alc883_dac_nids,
6550 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6551 .adc_nids = alc883_adc_nids,
6552 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
6553 .channel_mode = alc883_3ST_2ch_modes,
6554 .input_mux = &alc883_capture_source,
6556 [ALC883_LENOVO_101E_2ch] = {
6557 .mixers = { alc883_lenovo_101e_2ch_mixer},
6558 .init_verbs = { alc883_init_verbs, alc883_lenovo_101e_verbs},
6559 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6560 .dac_nids = alc883_dac_nids,
6561 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6562 .adc_nids = alc883_adc_nids,
6563 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
6564 .channel_mode = alc883_3ST_2ch_modes,
6565 .input_mux = &alc883_lenovo_101e_capture_source,
6566 .unsol_event = alc883_lenovo_101e_unsol_event,
6567 .init_hook = alc883_lenovo_101e_all_automute,
6569 [ALC883_LENOVO_NB0763] = {
6570 .mixers = { alc883_lenovo_nb0763_mixer },
6571 .init_verbs = { alc883_init_verbs, alc883_lenovo_nb0763_verbs},
6572 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6573 .dac_nids = alc883_dac_nids,
6574 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6575 .adc_nids = alc883_adc_nids,
6576 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
6577 .channel_mode = alc883_3ST_2ch_modes,
6579 .input_mux = &alc883_lenovo_nb0763_capture_source,
6580 .unsol_event = alc883_medion_md2_unsol_event,
6581 .init_hook = alc883_medion_md2_automute,
6583 [ALC888_LENOVO_MS7195_DIG] = {
6584 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
6585 .init_verbs = { alc883_init_verbs, alc888_lenovo_ms7195_verbs},
6586 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6587 .dac_nids = alc883_dac_nids,
6588 .dig_out_nid = ALC883_DIGOUT_NID,
6589 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6590 .adc_nids = alc883_adc_nids,
6591 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
6592 .channel_mode = alc883_3ST_6ch_modes,
6594 .input_mux = &alc883_capture_source,
6595 .unsol_event = alc883_lenovo_ms7195_unsol_event,
6596 .init_hook = alc888_lenovo_ms7195_front_automute,
6602 * BIOS auto configuration
6604 static void alc883_auto_set_output_and_unmute(struct hda_codec *codec,
6605 hda_nid_t nid, int pin_type,
6609 struct alc_spec *spec = codec->spec;
6612 if (spec->multiout.dac_nids[dac_idx] == 0x25)
6615 idx = spec->multiout.dac_nids[dac_idx] - 2;
6617 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
6619 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
6621 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
6625 static void alc883_auto_init_multi_out(struct hda_codec *codec)
6627 struct alc_spec *spec = codec->spec;
6630 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
6631 for (i = 0; i <= HDA_SIDE; i++) {
6632 hda_nid_t nid = spec->autocfg.line_out_pins[i];
6633 int pin_type = get_pin_type(spec->autocfg.line_out_type);
6635 alc883_auto_set_output_and_unmute(codec, nid, pin_type,
6640 static void alc883_auto_init_hp_out(struct hda_codec *codec)
6642 struct alc_spec *spec = codec->spec;
6645 pin = spec->autocfg.hp_pins[0];
6646 if (pin) /* connect to front */
6648 alc883_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
6651 #define alc883_is_input_pin(nid) alc880_is_input_pin(nid)
6652 #define ALC883_PIN_CD_NID ALC880_PIN_CD_NID
6654 static void alc883_auto_init_analog_input(struct hda_codec *codec)
6656 struct alc_spec *spec = codec->spec;
6659 for (i = 0; i < AUTO_PIN_LAST; i++) {
6660 hda_nid_t nid = spec->autocfg.input_pins[i];
6661 if (alc883_is_input_pin(nid)) {
6662 snd_hda_codec_write(codec, nid, 0,
6663 AC_VERB_SET_PIN_WIDGET_CONTROL,
6664 (i <= AUTO_PIN_FRONT_MIC ?
6665 PIN_VREF80 : PIN_IN));
6666 if (nid != ALC883_PIN_CD_NID)
6667 snd_hda_codec_write(codec, nid, 0,
6668 AC_VERB_SET_AMP_GAIN_MUTE,
6674 /* almost identical with ALC880 parser... */
6675 static int alc883_parse_auto_config(struct hda_codec *codec)
6677 struct alc_spec *spec = codec->spec;
6678 int err = alc880_parse_auto_config(codec);
6683 /* hack - override the init verbs */
6684 spec->init_verbs[0] = alc883_auto_init_verbs;
6685 spec->mixers[spec->num_mixers] = alc883_capture_mixer;
6690 /* additional initialization for auto-configuration model */
6691 static void alc883_auto_init(struct hda_codec *codec)
6693 alc883_auto_init_multi_out(codec);
6694 alc883_auto_init_hp_out(codec);
6695 alc883_auto_init_analog_input(codec);
6698 static int patch_alc883(struct hda_codec *codec)
6700 struct alc_spec *spec;
6701 int err, board_config;
6703 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
6709 board_config = snd_hda_check_board_config(codec, ALC883_MODEL_LAST,
6712 if (board_config < 0) {
6713 printk(KERN_INFO "hda_codec: Unknown model for ALC883, "
6714 "trying auto-probe from BIOS...\n");
6715 board_config = ALC883_AUTO;
6718 if (board_config == ALC883_AUTO) {
6719 /* automatic parse from the BIOS config */
6720 err = alc883_parse_auto_config(codec);
6726 "hda_codec: Cannot set up configuration "
6727 "from BIOS. Using base mode...\n");
6728 board_config = ALC883_3ST_2ch_DIG;
6732 if (board_config != ALC883_AUTO)
6733 setup_preset(spec, &alc883_presets[board_config]);
6735 spec->stream_name_analog = "ALC883 Analog";
6736 spec->stream_analog_playback = &alc883_pcm_analog_playback;
6737 spec->stream_analog_capture = &alc883_pcm_analog_capture;
6739 spec->stream_name_digital = "ALC883 Digital";
6740 spec->stream_digital_playback = &alc883_pcm_digital_playback;
6741 spec->stream_digital_capture = &alc883_pcm_digital_capture;
6743 if (!spec->adc_nids && spec->input_mux) {
6744 spec->adc_nids = alc883_adc_nids;
6745 spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids);
6748 codec->patch_ops = alc_patch_ops;
6749 if (board_config == ALC883_AUTO)
6750 spec->init_hook = alc883_auto_init;
6759 #define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
6760 #define ALC262_DIGIN_NID ALC880_DIGIN_NID
6762 #define alc262_dac_nids alc260_dac_nids
6763 #define alc262_adc_nids alc882_adc_nids
6764 #define alc262_adc_nids_alt alc882_adc_nids_alt
6766 #define alc262_modes alc260_modes
6767 #define alc262_capture_source alc882_capture_source
6769 static struct snd_kcontrol_new alc262_base_mixer[] = {
6770 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6771 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6772 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6773 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6774 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6775 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6776 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6777 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6778 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6779 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
6780 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
6781 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
6782 /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
6783 HDA_CODEC_MUTE("PC Beelp Playback Switch", 0x0b, 0x05, HDA_INPUT), */
6784 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
6785 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
6786 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
6787 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
6791 static struct snd_kcontrol_new alc262_hippo1_mixer[] = {
6792 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6793 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6794 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6795 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6796 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6797 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6798 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6799 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6800 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6801 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
6802 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
6803 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
6804 /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
6805 HDA_CODEC_MUTE("PC Beelp Playback Switch", 0x0b, 0x05, HDA_INPUT), */
6806 /*HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),*/
6807 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6811 static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
6812 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6813 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
6814 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6815 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
6816 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
6818 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6819 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6820 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6821 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
6822 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
6823 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
6824 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6825 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6826 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6827 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6828 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
6829 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
6830 HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
6831 HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
6835 static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = {
6836 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6837 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6838 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
6839 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
6840 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
6841 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
6842 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x02, HDA_INPUT),
6843 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x02, HDA_INPUT),
6844 HDA_CODEC_VOLUME("Front Mic Boost", 0x1a, 0, HDA_INPUT),
6845 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
6846 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
6847 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6848 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6849 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
6850 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
6854 static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = {
6855 HDA_CODEC_VOLUME("Rear Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6856 HDA_CODEC_MUTE("Rear Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6857 HDA_CODEC_VOLUME("Rear Mic Boost", 0x18, 0, HDA_INPUT),
6861 static struct snd_kcontrol_new alc262_sony_mixer[] = {
6862 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6863 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
6864 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6865 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6866 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
6867 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
6873 #define alc262_capture_mixer alc882_capture_mixer
6874 #define alc262_capture_alt_mixer alc882_capture_alt_mixer
6877 * generic initialization of ADC, input mixers and output mixers
6879 static struct hda_verb alc262_init_verbs[] = {
6881 * Unmute ADC0-2 and set the default input to mic-in
6883 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
6884 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6885 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6886 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6887 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
6888 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6890 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
6892 * Note: PASD motherboards uses the Line In 2 as the input for
6893 * front panel mic (mic 2)
6895 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
6896 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6897 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6898 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
6899 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
6900 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
6903 * Set up output mixers (0x0c - 0x0e)
6905 /* set vol=0 to output mixers */
6906 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6907 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6908 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6909 /* set up input amps for analog loopback */
6910 /* Amp Indices: DAC = 0, mixer = 1 */
6911 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6912 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6913 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6914 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6915 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6916 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6918 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
6919 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
6920 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
6921 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
6922 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
6923 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
6925 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
6926 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
6927 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
6928 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
6929 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
6931 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
6932 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
6934 /* FIXME: use matrix-type input source selection */
6935 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6936 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
6937 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6938 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
6939 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
6940 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
6942 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6943 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
6944 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
6945 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
6947 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6948 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
6949 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
6950 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
6955 static struct hda_verb alc262_hippo_unsol_verbs[] = {
6956 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
6957 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6961 static struct hda_verb alc262_hippo1_unsol_verbs[] = {
6962 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
6963 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
6964 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
6966 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
6967 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6971 static struct hda_verb alc262_sony_unsol_verbs[] = {
6972 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
6973 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
6974 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, // Front Mic
6976 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
6977 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6980 /* mute/unmute internal speaker according to the hp jack and mute state */
6981 static void alc262_hippo_automute(struct hda_codec *codec, int force)
6983 struct alc_spec *spec = codec->spec;
6986 if (force || !spec->sense_updated) {
6987 unsigned int present;
6988 /* need to execute and sync at first */
6989 snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
6990 present = snd_hda_codec_read(codec, 0x15, 0,
6991 AC_VERB_GET_PIN_SENSE, 0);
6992 spec->jack_present = (present & 0x80000000) != 0;
6993 spec->sense_updated = 1;
6995 if (spec->jack_present) {
6996 /* mute internal speaker */
6997 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
6999 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
7002 /* unmute internal speaker if necessary */
7003 mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0);
7004 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
7006 mute = snd_hda_codec_amp_read(codec, 0x15, 1, HDA_OUTPUT, 0);
7007 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
7012 /* unsolicited event for HP jack sensing */
7013 static void alc262_hippo_unsol_event(struct hda_codec *codec,
7016 if ((res >> 26) != ALC880_HP_EVENT)
7018 alc262_hippo_automute(codec, 1);
7021 static void alc262_hippo1_automute(struct hda_codec *codec, int force)
7023 struct alc_spec *spec = codec->spec;
7026 if (force || !spec->sense_updated) {
7027 unsigned int present;
7028 /* need to execute and sync at first */
7029 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
7030 present = snd_hda_codec_read(codec, 0x1b, 0,
7031 AC_VERB_GET_PIN_SENSE, 0);
7032 spec->jack_present = (present & 0x80000000) != 0;
7033 spec->sense_updated = 1;
7035 if (spec->jack_present) {
7036 /* mute internal speaker */
7037 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
7039 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
7042 /* unmute internal speaker if necessary */
7043 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
7044 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
7046 mute = snd_hda_codec_amp_read(codec, 0x1b, 1, HDA_OUTPUT, 0);
7047 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
7052 /* unsolicited event for HP jack sensing */
7053 static void alc262_hippo1_unsol_event(struct hda_codec *codec,
7056 if ((res >> 26) != ALC880_HP_EVENT)
7058 alc262_hippo1_automute(codec, 1);
7063 * 0x14 = headphone/spdif-out, 0x15 = internal speaker
7066 #define ALC_HP_EVENT 0x37
7068 static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
7069 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
7070 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7074 static struct hda_input_mux alc262_fujitsu_capture_source = {
7082 static struct hda_input_mux alc262_HP_capture_source = {
7086 { "Front Mic", 0x3 },
7093 /* mute/unmute internal speaker according to the hp jack and mute state */
7094 static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
7096 struct alc_spec *spec = codec->spec;
7099 if (force || !spec->sense_updated) {
7100 unsigned int present;
7101 /* need to execute and sync at first */
7102 snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
7103 present = snd_hda_codec_read(codec, 0x14, 0,
7104 AC_VERB_GET_PIN_SENSE, 0);
7105 spec->jack_present = (present & 0x80000000) != 0;
7106 spec->sense_updated = 1;
7108 if (spec->jack_present) {
7109 /* mute internal speaker */
7110 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
7112 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
7115 /* unmute internal speaker if necessary */
7116 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
7117 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
7119 mute = snd_hda_codec_amp_read(codec, 0x14, 1, HDA_OUTPUT, 0);
7120 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
7125 /* unsolicited event for HP jack sensing */
7126 static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
7129 if ((res >> 26) != ALC_HP_EVENT)
7131 alc262_fujitsu_automute(codec, 1);
7134 /* bind volumes of both NID 0x0c and 0x0d */
7135 static int alc262_fujitsu_master_vol_put(struct snd_kcontrol *kcontrol,
7136 struct snd_ctl_elem_value *ucontrol)
7138 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
7139 long *valp = ucontrol->value.integer.value;
7142 change = snd_hda_codec_amp_update(codec, 0x0c, 0, HDA_OUTPUT, 0,
7143 0x7f, valp[0] & 0x7f);
7144 change |= snd_hda_codec_amp_update(codec, 0x0c, 1, HDA_OUTPUT, 0,
7145 0x7f, valp[1] & 0x7f);
7146 snd_hda_codec_amp_update(codec, 0x0d, 0, HDA_OUTPUT, 0,
7147 0x7f, valp[0] & 0x7f);
7148 snd_hda_codec_amp_update(codec, 0x0d, 1, HDA_OUTPUT, 0,
7149 0x7f, valp[1] & 0x7f);
7153 /* bind hp and internal speaker mute (with plug check) */
7154 static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
7155 struct snd_ctl_elem_value *ucontrol)
7157 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
7158 long *valp = ucontrol->value.integer.value;
7161 change = snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
7162 0x80, valp[0] ? 0 : 0x80);
7163 change |= snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
7164 0x80, valp[1] ? 0 : 0x80);
7165 if (change || codec->in_resume)
7166 alc262_fujitsu_automute(codec, codec->in_resume);
7170 static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
7172 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7173 .name = "Master Playback Volume",
7174 .info = snd_hda_mixer_amp_volume_info,
7175 .get = snd_hda_mixer_amp_volume_get,
7176 .put = alc262_fujitsu_master_vol_put,
7177 .tlv = { .c = snd_hda_mixer_amp_tlv },
7178 .private_value = HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
7181 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7182 .name = "Master Playback Switch",
7183 .info = snd_hda_mixer_amp_switch_info,
7184 .get = snd_hda_mixer_amp_switch_get,
7185 .put = alc262_fujitsu_master_sw_put,
7186 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
7188 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7189 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7190 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7191 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7192 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7196 /* additional init verbs for Benq laptops */
7197 static struct hda_verb alc262_EAPD_verbs[] = {
7198 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
7199 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
7203 /* add playback controls from the parsed DAC table */
7204 static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec,
7205 const struct auto_pin_cfg *cfg)
7210 spec->multiout.num_dacs = 1; /* only use one dac */
7211 spec->multiout.dac_nids = spec->private_dac_nids;
7212 spec->multiout.dac_nids[0] = 2;
7214 nid = cfg->line_out_pins[0];
7216 err = add_control(spec, ALC_CTL_WIDGET_VOL,
7217 "Front Playback Volume",
7218 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT));
7221 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
7222 "Front Playback Switch",
7223 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
7228 nid = cfg->speaker_pins[0];
7231 err = add_control(spec, ALC_CTL_WIDGET_VOL,
7232 "Speaker Playback Volume",
7233 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
7237 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
7238 "Speaker Playback Switch",
7239 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
7244 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
7245 "Speaker Playback Switch",
7246 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
7252 nid = cfg->hp_pins[0];
7254 /* spec->multiout.hp_nid = 2; */
7256 err = add_control(spec, ALC_CTL_WIDGET_VOL,
7257 "Headphone Playback Volume",
7258 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
7262 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
7263 "Headphone Playback Switch",
7264 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
7269 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
7270 "Headphone Playback Switch",
7271 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
7280 /* identical with ALC880 */
7281 #define alc262_auto_create_analog_input_ctls \
7282 alc880_auto_create_analog_input_ctls
7285 * generic initialization of ADC, input mixers and output mixers
7287 static struct hda_verb alc262_volume_init_verbs[] = {
7289 * Unmute ADC0-2 and set the default input to mic-in
7291 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7292 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7293 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7294 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7295 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7296 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7298 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
7300 * Note: PASD motherboards uses the Line In 2 as the input for
7301 * front panel mic (mic 2)
7303 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
7304 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7305 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7306 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7307 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
7308 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
7311 * Set up output mixers (0x0c - 0x0f)
7313 /* set vol=0 to output mixers */
7314 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7315 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7316 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7318 /* set up input amps for analog loopback */
7319 /* Amp Indices: DAC = 0, mixer = 1 */
7320 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7321 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7322 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7323 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7324 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7325 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7327 /* FIXME: use matrix-type input source selection */
7328 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7329 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7330 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7331 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
7332 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
7333 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
7335 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7336 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
7337 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
7338 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
7340 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7341 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
7342 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
7343 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
7348 static struct hda_verb alc262_HP_BPC_init_verbs[] = {
7350 * Unmute ADC0-2 and set the default input to mic-in
7352 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7353 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7354 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7355 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7356 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7357 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7359 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
7361 * Note: PASD motherboards uses the Line In 2 as the input for
7362 * front panel mic (mic 2)
7364 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
7365 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7366 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7367 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7368 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
7369 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
7370 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
7371 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(6)},
7374 * Set up output mixers (0x0c - 0x0e)
7376 /* set vol=0 to output mixers */
7377 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7378 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7379 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7381 /* set up input amps for analog loopback */
7382 /* Amp Indices: DAC = 0, mixer = 1 */
7383 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7384 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7385 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7386 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7387 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7388 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7390 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
7391 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7392 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7394 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7395 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7397 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
7398 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7400 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
7401 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
7402 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
7403 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
7404 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
7406 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
7407 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
7408 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
7409 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
7410 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
7411 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
7414 /* FIXME: use matrix-type input source selection */
7415 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7416 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7417 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7418 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
7419 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
7420 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
7422 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7423 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
7424 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
7425 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
7427 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7428 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
7429 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
7430 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
7435 static struct hda_verb alc262_HP_BPC_WildWest_init_verbs[] = {
7437 * Unmute ADC0-2 and set the default input to mic-in
7439 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7440 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7441 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7442 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7443 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7444 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7446 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
7448 * Note: PASD motherboards uses the Line In 2 as the input for front
7451 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
7452 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7453 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7454 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7455 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
7456 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
7457 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
7458 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(6)},
7459 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(7)},
7461 * Set up output mixers (0x0c - 0x0e)
7463 /* set vol=0 to output mixers */
7464 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7465 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7466 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7468 /* set up input amps for analog loopback */
7469 /* Amp Indices: DAC = 0, mixer = 1 */
7470 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7471 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7472 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7473 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7474 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7475 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7478 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP */
7479 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Mono */
7480 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* rear MIC */
7481 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* Line in */
7482 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
7483 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Line out */
7484 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD in */
7486 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7487 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7489 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
7490 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
7492 /* {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, */
7493 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
7494 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
7495 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
7496 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
7497 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
7499 /* FIXME: use matrix-type input source selection */
7500 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7501 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7502 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, /*rear MIC*/
7503 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, /*Line in*/
7504 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, /*F MIC*/
7505 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, /*Front*/
7506 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, /*CD*/
7507 /* {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
7508 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, /*HP*/
7510 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7511 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
7512 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
7513 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
7514 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
7515 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
7516 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
7518 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7519 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
7520 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
7521 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
7522 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
7523 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
7524 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
7529 /* pcm configuration: identiacal with ALC880 */
7530 #define alc262_pcm_analog_playback alc880_pcm_analog_playback
7531 #define alc262_pcm_analog_capture alc880_pcm_analog_capture
7532 #define alc262_pcm_digital_playback alc880_pcm_digital_playback
7533 #define alc262_pcm_digital_capture alc880_pcm_digital_capture
7536 * BIOS auto configuration
7538 static int alc262_parse_auto_config(struct hda_codec *codec)
7540 struct alc_spec *spec = codec->spec;
7542 static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
7544 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
7548 if (!spec->autocfg.line_outs)
7549 return 0; /* can't find valid BIOS pin config */
7550 err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg);
7553 err = alc262_auto_create_analog_input_ctls(spec, &spec->autocfg);
7557 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
7559 if (spec->autocfg.dig_out_pin)
7560 spec->multiout.dig_out_nid = ALC262_DIGOUT_NID;
7561 if (spec->autocfg.dig_in_pin)
7562 spec->dig_in_nid = ALC262_DIGIN_NID;
7564 if (spec->kctl_alloc)
7565 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
7567 spec->init_verbs[spec->num_init_verbs++] = alc262_volume_init_verbs;
7568 spec->num_mux_defs = 1;
7569 spec->input_mux = &spec->private_imux;
7574 #define alc262_auto_init_multi_out alc882_auto_init_multi_out
7575 #define alc262_auto_init_hp_out alc882_auto_init_hp_out
7576 #define alc262_auto_init_analog_input alc882_auto_init_analog_input
7579 /* init callback for auto-configuration model -- overriding the default init */
7580 static void alc262_auto_init(struct hda_codec *codec)
7582 alc262_auto_init_multi_out(codec);
7583 alc262_auto_init_hp_out(codec);
7584 alc262_auto_init_analog_input(codec);
7588 * configuration and preset
7590 static const char *alc262_models[ALC262_MODEL_LAST] = {
7591 [ALC262_BASIC] = "basic",
7592 [ALC262_HIPPO] = "hippo",
7593 [ALC262_HIPPO_1] = "hippo_1",
7594 [ALC262_FUJITSU] = "fujitsu",
7595 [ALC262_HP_BPC] = "hp-bpc",
7596 [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000",
7597 [ALC262_BENQ_ED8] = "benq",
7598 [ALC262_BENQ_ED8] = "sony-assamd",
7599 [ALC262_AUTO] = "auto",
7602 static struct snd_pci_quirk alc262_cfg_tbl[] = {
7603 SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO),
7604 SND_PCI_QUIRK(0x103c, 0x12fe, "HP xw9400", ALC262_HP_BPC),
7605 SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC),
7606 SND_PCI_QUIRK(0x103c, 0x12ff, "HP xw4550", ALC262_HP_BPC),
7607 SND_PCI_QUIRK(0x103c, 0x1308, "HP xw4600", ALC262_HP_BPC),
7608 SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC),
7609 SND_PCI_QUIRK(0x103c, 0x1307, "HP xw6600", ALC262_HP_BPC),
7610 SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC),
7611 SND_PCI_QUIRK(0x103c, 0x1306, "HP xw8600", ALC262_HP_BPC),
7612 SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL),
7613 SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL),
7614 SND_PCI_QUIRK(0x103c, 0x2804, "HP D7000", ALC262_HP_BPC_D7000_WL),
7615 SND_PCI_QUIRK(0x103c, 0x2806, "HP D7000", ALC262_HP_BPC_D7000_WL),
7616 SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF),
7617 SND_PCI_QUIRK(0x103c, 0x2803, "HP D7000", ALC262_HP_BPC_D7000_WF),
7618 SND_PCI_QUIRK(0x103c, 0x2805, "HP D7000", ALC262_HP_BPC_D7000_WF),
7619 SND_PCI_QUIRK(0x103c, 0x2807, "HP D7000", ALC262_HP_BPC_D7000_WF),
7620 SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO),
7621 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
7622 SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1),
7623 SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
7624 SND_PCI_QUIRK(0x104d, 0x9015, "Sony 0x9015", ALC262_SONY_ASSAMD),
7625 SND_PCI_QUIRK(0x104d, 0x900e, "Sony ASSAMD", ALC262_SONY_ASSAMD),
7626 SND_PCI_QUIRK(0x104d, 0x1f00, "Sony ASSAMD", ALC262_SONY_ASSAMD),
7630 static struct alc_config_preset alc262_presets[] = {
7632 .mixers = { alc262_base_mixer },
7633 .init_verbs = { alc262_init_verbs },
7634 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
7635 .dac_nids = alc262_dac_nids,
7637 .num_channel_mode = ARRAY_SIZE(alc262_modes),
7638 .channel_mode = alc262_modes,
7639 .input_mux = &alc262_capture_source,
7642 .mixers = { alc262_base_mixer },
7643 .init_verbs = { alc262_init_verbs, alc262_hippo_unsol_verbs},
7644 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
7645 .dac_nids = alc262_dac_nids,
7647 .dig_out_nid = ALC262_DIGOUT_NID,
7648 .num_channel_mode = ARRAY_SIZE(alc262_modes),
7649 .channel_mode = alc262_modes,
7650 .input_mux = &alc262_capture_source,
7651 .unsol_event = alc262_hippo_unsol_event,
7653 [ALC262_HIPPO_1] = {
7654 .mixers = { alc262_hippo1_mixer },
7655 .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs},
7656 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
7657 .dac_nids = alc262_dac_nids,
7659 .dig_out_nid = ALC262_DIGOUT_NID,
7660 .num_channel_mode = ARRAY_SIZE(alc262_modes),
7661 .channel_mode = alc262_modes,
7662 .input_mux = &alc262_capture_source,
7663 .unsol_event = alc262_hippo1_unsol_event,
7665 [ALC262_FUJITSU] = {
7666 .mixers = { alc262_fujitsu_mixer },
7667 .init_verbs = { alc262_init_verbs, alc262_fujitsu_unsol_verbs },
7668 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
7669 .dac_nids = alc262_dac_nids,
7671 .dig_out_nid = ALC262_DIGOUT_NID,
7672 .num_channel_mode = ARRAY_SIZE(alc262_modes),
7673 .channel_mode = alc262_modes,
7674 .input_mux = &alc262_fujitsu_capture_source,
7675 .unsol_event = alc262_fujitsu_unsol_event,
7678 .mixers = { alc262_HP_BPC_mixer },
7679 .init_verbs = { alc262_HP_BPC_init_verbs },
7680 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
7681 .dac_nids = alc262_dac_nids,
7683 .num_channel_mode = ARRAY_SIZE(alc262_modes),
7684 .channel_mode = alc262_modes,
7685 .input_mux = &alc262_HP_capture_source,
7687 [ALC262_HP_BPC_D7000_WF] = {
7688 .mixers = { alc262_HP_BPC_WildWest_mixer },
7689 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
7690 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
7691 .dac_nids = alc262_dac_nids,
7693 .num_channel_mode = ARRAY_SIZE(alc262_modes),
7694 .channel_mode = alc262_modes,
7695 .input_mux = &alc262_HP_capture_source,
7697 [ALC262_HP_BPC_D7000_WL] = {
7698 .mixers = { alc262_HP_BPC_WildWest_mixer,
7699 alc262_HP_BPC_WildWest_option_mixer },
7700 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
7701 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
7702 .dac_nids = alc262_dac_nids,
7704 .num_channel_mode = ARRAY_SIZE(alc262_modes),
7705 .channel_mode = alc262_modes,
7706 .input_mux = &alc262_HP_capture_source,
7708 [ALC262_BENQ_ED8] = {
7709 .mixers = { alc262_base_mixer },
7710 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
7711 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
7712 .dac_nids = alc262_dac_nids,
7714 .num_channel_mode = ARRAY_SIZE(alc262_modes),
7715 .channel_mode = alc262_modes,
7716 .input_mux = &alc262_capture_source,
7718 [ALC262_SONY_ASSAMD] = {
7719 .mixers = { alc262_sony_mixer },
7720 .init_verbs = { alc262_init_verbs, alc262_sony_unsol_verbs},
7721 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
7722 .dac_nids = alc262_dac_nids,
7724 .num_channel_mode = ARRAY_SIZE(alc262_modes),
7725 .channel_mode = alc262_modes,
7726 .input_mux = &alc262_capture_source,
7727 .unsol_event = alc262_hippo_unsol_event,
7731 static int patch_alc262(struct hda_codec *codec)
7733 struct alc_spec *spec;
7737 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
7743 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
7748 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
7749 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
7750 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
7751 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
7755 board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST,
7759 if (board_config < 0) {
7760 printk(KERN_INFO "hda_codec: Unknown model for ALC262, "
7761 "trying auto-probe from BIOS...\n");
7762 board_config = ALC262_AUTO;
7765 if (board_config == ALC262_AUTO) {
7766 /* automatic parse from the BIOS config */
7767 err = alc262_parse_auto_config(codec);
7773 "hda_codec: Cannot set up configuration "
7774 "from BIOS. Using base mode...\n");
7775 board_config = ALC262_BASIC;
7779 if (board_config != ALC262_AUTO)
7780 setup_preset(spec, &alc262_presets[board_config]);
7782 spec->stream_name_analog = "ALC262 Analog";
7783 spec->stream_analog_playback = &alc262_pcm_analog_playback;
7784 spec->stream_analog_capture = &alc262_pcm_analog_capture;
7786 spec->stream_name_digital = "ALC262 Digital";
7787 spec->stream_digital_playback = &alc262_pcm_digital_playback;
7788 spec->stream_digital_capture = &alc262_pcm_digital_capture;
7790 if (!spec->adc_nids && spec->input_mux) {
7791 /* check whether NID 0x07 is valid */
7792 unsigned int wcap = get_wcaps(codec, 0x07);
7795 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
7796 if (wcap != AC_WID_AUD_IN) {
7797 spec->adc_nids = alc262_adc_nids_alt;
7798 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids_alt);
7799 spec->mixers[spec->num_mixers] =
7800 alc262_capture_alt_mixer;
7803 spec->adc_nids = alc262_adc_nids;
7804 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids);
7805 spec->mixers[spec->num_mixers] = alc262_capture_mixer;
7810 codec->patch_ops = alc_patch_ops;
7811 if (board_config == ALC262_AUTO)
7812 spec->init_hook = alc262_auto_init;
7818 * ALC268 channel source setting (2 channel)
7820 #define ALC268_DIGOUT_NID ALC880_DIGOUT_NID
7821 #define alc268_modes alc260_modes
7823 static hda_nid_t alc268_dac_nids[2] = {
7828 static hda_nid_t alc268_adc_nids[2] = {
7833 static hda_nid_t alc268_adc_nids_alt[1] = {
7838 static struct snd_kcontrol_new alc268_base_mixer[] = {
7839 /* output mixer control */
7840 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
7841 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7842 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
7843 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7848 * generic initialization of ADC, input mixers and output mixers
7850 static struct hda_verb alc268_base_init_verbs[] = {
7851 /* Unmute DAC0-1 and set vol = 0 */
7852 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7853 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7854 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7855 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7856 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7857 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7860 * Set up output mixers (0x0c - 0x0e)
7862 /* set vol=0 to output mixers */
7863 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7864 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7865 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7866 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
7868 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7869 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7871 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
7872 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
7873 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
7874 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
7875 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
7876 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
7877 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
7878 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
7880 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7881 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7882 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7883 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7884 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7885 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7886 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7887 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7889 /* FIXME: use matrix-type input source selection */
7890 /* Mixer elements: 0x18, 19, 1a, 1c, 14, 15, 0b */
7891 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7893 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7894 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
7895 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
7896 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
7898 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7899 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
7900 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
7901 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
7906 * generic initialization of ADC, input mixers and output mixers
7908 static struct hda_verb alc268_volume_init_verbs[] = {
7909 /* set output DAC */
7910 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7911 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7912 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7913 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7915 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
7916 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
7917 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
7918 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
7919 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
7921 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7922 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7923 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7924 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7925 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7927 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7928 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7929 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7930 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7932 /* set PCBEEP vol = 0 */
7933 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, (0xb000 | (0x00 << 8))},
7938 #define alc268_mux_enum_info alc_mux_enum_info
7939 #define alc268_mux_enum_get alc_mux_enum_get
7941 static int alc268_mux_enum_put(struct snd_kcontrol *kcontrol,
7942 struct snd_ctl_elem_value *ucontrol)
7944 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
7945 struct alc_spec *spec = codec->spec;
7946 const struct hda_input_mux *imux = spec->input_mux;
7947 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
7948 static hda_nid_t capture_mixers[3] = { 0x23, 0x24 };
7949 hda_nid_t nid = capture_mixers[adc_idx];
7950 unsigned int *cur_val = &spec->cur_mux[adc_idx];
7951 unsigned int i, idx;
7953 idx = ucontrol->value.enumerated.item[0];
7954 if (idx >= imux->num_items)
7955 idx = imux->num_items - 1;
7956 if (*cur_val == idx && !codec->in_resume)
7958 for (i = 0; i < imux->num_items; i++) {
7959 unsigned int v = (i == idx) ? 0x7000 : 0x7080;
7960 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
7961 v | (imux->items[i].index << 8));
7962 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL,
7969 static struct snd_kcontrol_new alc268_capture_alt_mixer[] = {
7970 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
7971 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
7973 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7974 /* The multiple "Capture Source" controls confuse alsamixer
7975 * So call somewhat different..
7976 * FIXME: the controls appear in the "playback" view!
7978 /* .name = "Capture Source", */
7979 .name = "Input Source",
7981 .info = alc268_mux_enum_info,
7982 .get = alc268_mux_enum_get,
7983 .put = alc268_mux_enum_put,
7988 static struct snd_kcontrol_new alc268_capture_mixer[] = {
7989 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
7990 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
7991 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x24, 0x0, HDA_OUTPUT),
7992 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x24, 0x0, HDA_OUTPUT),
7994 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7995 /* The multiple "Capture Source" controls confuse alsamixer
7996 * So call somewhat different..
7997 * FIXME: the controls appear in the "playback" view!
7999 /* .name = "Capture Source", */
8000 .name = "Input Source",
8002 .info = alc268_mux_enum_info,
8003 .get = alc268_mux_enum_get,
8004 .put = alc268_mux_enum_put,
8009 static struct hda_input_mux alc268_capture_source = {
8013 { "Front Mic", 0x1 },
8019 /* create input playback/capture controls for the given pin */
8020 static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
8021 const char *ctlname, int idx)
8026 sprintf(name, "%s Playback Volume", ctlname);
8028 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
8029 HDA_COMPOSE_AMP_VAL(0x02, 3, idx,
8033 } else if (nid == 0x15) {
8034 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
8035 HDA_COMPOSE_AMP_VAL(0x03, 3, idx,
8041 sprintf(name, "%s Playback Switch", ctlname);
8042 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
8043 HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
8049 /* add playback controls from the parsed DAC table */
8050 static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec,
8051 const struct auto_pin_cfg *cfg)
8056 spec->multiout.num_dacs = 2; /* only use one dac */
8057 spec->multiout.dac_nids = spec->private_dac_nids;
8058 spec->multiout.dac_nids[0] = 2;
8059 spec->multiout.dac_nids[1] = 3;
8061 nid = cfg->line_out_pins[0];
8063 alc268_new_analog_output(spec, nid, "Front", 0);
8065 nid = cfg->speaker_pins[0];
8067 err = add_control(spec, ALC_CTL_WIDGET_VOL,
8068 "Speaker Playback Volume",
8069 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
8073 nid = cfg->hp_pins[0];
8075 alc268_new_analog_output(spec, nid, "Headphone", 0);
8077 nid = cfg->line_out_pins[1] | cfg->line_out_pins[2];
8079 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
8080 "Mono Playback Switch",
8081 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_INPUT));
8088 /* create playback/capture controls for input pins */
8089 static int alc268_auto_create_analog_input_ctls(struct alc_spec *spec,
8090 const struct auto_pin_cfg *cfg)
8092 struct hda_input_mux *imux = &spec->private_imux;
8095 for (i = 0; i < AUTO_PIN_LAST; i++) {
8096 switch(cfg->input_pins[i]) {
8098 idx1 = 0; /* Mic 1 */
8101 idx1 = 1; /* Mic 2 */
8104 idx1 = 2; /* Line In */
8112 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
8113 imux->items[imux->num_items].index = idx1;
8119 static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec)
8121 struct alc_spec *spec = codec->spec;
8122 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
8123 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
8124 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
8125 unsigned int dac_vol1, dac_vol2;
8128 snd_hda_codec_write(codec, speaker_nid, 0,
8129 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
8130 snd_hda_codec_write(codec, 0x0f, 0,
8131 AC_VERB_SET_AMP_GAIN_MUTE,
8133 snd_hda_codec_write(codec, 0x10, 0,
8134 AC_VERB_SET_AMP_GAIN_MUTE,
8137 snd_hda_codec_write(codec, 0x0f, 0,
8138 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
8139 snd_hda_codec_write(codec, 0x10, 0,
8140 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
8143 dac_vol1 = dac_vol2 = 0xb000 | 0x40; /* set max volume */
8144 if (line_nid == 0x14)
8145 dac_vol2 = AMP_OUT_ZERO;
8146 else if (line_nid == 0x15)
8147 dac_vol1 = AMP_OUT_ZERO;
8149 dac_vol2 = AMP_OUT_ZERO;
8150 else if (hp_nid == 0x15)
8151 dac_vol1 = AMP_OUT_ZERO;
8152 if (line_nid != 0x16 || hp_nid != 0x16 ||
8153 spec->autocfg.line_out_pins[1] != 0x16 ||
8154 spec->autocfg.line_out_pins[2] != 0x16)
8155 dac_vol1 = dac_vol2 = AMP_OUT_ZERO;
8157 snd_hda_codec_write(codec, 0x02, 0,
8158 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol1);
8159 snd_hda_codec_write(codec, 0x03, 0,
8160 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol2);
8163 /* pcm configuration: identiacal with ALC880 */
8164 #define alc268_pcm_analog_playback alc880_pcm_analog_playback
8165 #define alc268_pcm_analog_capture alc880_pcm_analog_capture
8166 #define alc268_pcm_digital_playback alc880_pcm_digital_playback
8169 * BIOS auto configuration
8171 static int alc268_parse_auto_config(struct hda_codec *codec)
8173 struct alc_spec *spec = codec->spec;
8175 static hda_nid_t alc268_ignore[] = { 0 };
8177 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
8181 if (!spec->autocfg.line_outs)
8182 return 0; /* can't find valid BIOS pin config */
8184 err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg);
8187 err = alc268_auto_create_analog_input_ctls(spec, &spec->autocfg);
8191 spec->multiout.max_channels = 2;
8193 /* digital only support output */
8194 if (spec->autocfg.dig_out_pin)
8195 spec->multiout.dig_out_nid = ALC268_DIGOUT_NID;
8197 if (spec->kctl_alloc)
8198 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
8200 spec->init_verbs[spec->num_init_verbs++] = alc268_volume_init_verbs;
8201 spec->num_mux_defs = 1;
8202 spec->input_mux = &spec->private_imux;
8207 #define alc268_auto_init_multi_out alc882_auto_init_multi_out
8208 #define alc268_auto_init_hp_out alc882_auto_init_hp_out
8209 #define alc268_auto_init_analog_input alc882_auto_init_analog_input
8211 /* init callback for auto-configuration model -- overriding the default init */
8212 static void alc268_auto_init(struct hda_codec *codec)
8214 alc268_auto_init_multi_out(codec);
8215 alc268_auto_init_hp_out(codec);
8216 alc268_auto_init_mono_speaker_out(codec);
8217 alc268_auto_init_analog_input(codec);
8221 * configuration and preset
8223 static const char *alc268_models[ALC268_MODEL_LAST] = {
8224 [ALC268_3ST] = "3stack",
8225 [ALC268_AUTO] = "auto",
8228 static struct snd_pci_quirk alc268_cfg_tbl[] = {
8229 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST),
8233 static struct alc_config_preset alc268_presets[] = {
8235 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer },
8236 .init_verbs = { alc268_base_init_verbs },
8237 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
8238 .dac_nids = alc268_dac_nids,
8239 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
8240 .adc_nids = alc268_adc_nids_alt,
8242 .dig_out_nid = ALC268_DIGOUT_NID,
8243 .num_channel_mode = ARRAY_SIZE(alc268_modes),
8244 .channel_mode = alc268_modes,
8245 .input_mux = &alc268_capture_source,
8249 static int patch_alc268(struct hda_codec *codec)
8251 struct alc_spec *spec;
8255 spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
8261 board_config = snd_hda_check_board_config(codec, ALC268_MODEL_LAST,
8265 if (board_config < 0 || board_config >= ALC268_MODEL_LAST) {
8266 printk(KERN_INFO "hda_codec: Unknown model for ALC268, "
8267 "trying auto-probe from BIOS...\n");
8268 board_config = ALC268_AUTO;
8271 if (board_config == ALC268_AUTO) {
8272 /* automatic parse from the BIOS config */
8273 err = alc268_parse_auto_config(codec);
8279 "hda_codec: Cannot set up configuration "
8280 "from BIOS. Using base mode...\n");
8281 board_config = ALC268_3ST;
8285 if (board_config != ALC268_AUTO)
8286 setup_preset(spec, &alc268_presets[board_config]);
8288 spec->stream_name_analog = "ALC268 Analog";
8289 spec->stream_analog_playback = &alc268_pcm_analog_playback;
8290 spec->stream_analog_capture = &alc268_pcm_analog_capture;
8292 spec->stream_name_digital = "ALC268 Digital";
8293 spec->stream_digital_playback = &alc268_pcm_digital_playback;
8295 if (board_config == ALC268_AUTO) {
8296 if (!spec->adc_nids && spec->input_mux) {
8297 /* check whether NID 0x07 is valid */
8298 unsigned int wcap = get_wcaps(codec, 0x07);
8301 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
8302 if (wcap != AC_WID_AUD_IN) {
8303 spec->adc_nids = alc268_adc_nids_alt;
8304 spec->num_adc_nids =
8305 ARRAY_SIZE(alc268_adc_nids_alt);
8306 spec->mixers[spec->num_mixers] =
8307 alc268_capture_alt_mixer;
8310 spec->adc_nids = alc268_adc_nids;
8311 spec->num_adc_nids =
8312 ARRAY_SIZE(alc268_adc_nids);
8313 spec->mixers[spec->num_mixers] =
8314 alc268_capture_mixer;
8319 codec->patch_ops = alc_patch_ops;
8320 if (board_config == ALC268_AUTO)
8321 spec->init_hook = alc268_auto_init;
8327 * ALC861 channel source setting (2/6 channel selection for 3-stack)
8331 * set the path ways for 2 channel output
8332 * need to set the codec line out and mic 1 pin widgets to inputs
8334 static struct hda_verb alc861_threestack_ch2_init[] = {
8335 /* set pin widget 1Ah (line in) for input */
8336 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
8337 /* set pin widget 18h (mic1/2) for input, for mic also enable
8340 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
8342 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
8344 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
8345 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
8351 * need to set the codec line out and mic 1 pin widgets to outputs
8353 static struct hda_verb alc861_threestack_ch6_init[] = {
8354 /* set pin widget 1Ah (line in) for output (Back Surround)*/
8355 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
8356 /* set pin widget 18h (mic1) for output (CLFE)*/
8357 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
8359 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
8360 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
8362 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
8364 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
8365 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
8370 static struct hda_channel_mode alc861_threestack_modes[2] = {
8371 { 2, alc861_threestack_ch2_init },
8372 { 6, alc861_threestack_ch6_init },
8374 /* Set mic1 as input and unmute the mixer */
8375 static struct hda_verb alc861_uniwill_m31_ch2_init[] = {
8376 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
8377 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
8380 /* Set mic1 as output and mute mixer */
8381 static struct hda_verb alc861_uniwill_m31_ch4_init[] = {
8382 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
8383 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
8387 static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
8388 { 2, alc861_uniwill_m31_ch2_init },
8389 { 4, alc861_uniwill_m31_ch4_init },
8392 /* Set mic1 and line-in as input and unmute the mixer */
8393 static struct hda_verb alc861_asus_ch2_init[] = {
8394 /* set pin widget 1Ah (line in) for input */
8395 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
8396 /* set pin widget 18h (mic1/2) for input, for mic also enable
8399 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
8401 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
8403 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
8404 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
8408 /* Set mic1 nad line-in as output and mute mixer */
8409 static struct hda_verb alc861_asus_ch6_init[] = {
8410 /* set pin widget 1Ah (line in) for output (Back Surround)*/
8411 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
8412 /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
8413 /* set pin widget 18h (mic1) for output (CLFE)*/
8414 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
8415 /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
8416 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
8417 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
8419 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
8421 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
8422 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
8427 static struct hda_channel_mode alc861_asus_modes[2] = {
8428 { 2, alc861_asus_ch2_init },
8429 { 6, alc861_asus_ch6_init },
8434 static struct snd_kcontrol_new alc861_base_mixer[] = {
8435 /* output mixer control */
8436 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
8437 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
8438 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
8439 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
8440 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
8442 /*Input mixer control */
8443 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
8444 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
8445 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
8446 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
8447 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
8448 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
8449 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
8450 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
8451 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
8452 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
8454 /* Capture mixer control */
8455 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
8456 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
8458 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8459 .name = "Capture Source",
8461 .info = alc_mux_enum_info,
8462 .get = alc_mux_enum_get,
8463 .put = alc_mux_enum_put,
8468 static struct snd_kcontrol_new alc861_3ST_mixer[] = {
8469 /* output mixer control */
8470 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
8471 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
8472 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
8473 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
8474 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
8476 /* Input mixer control */
8477 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
8478 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
8479 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
8480 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
8481 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
8482 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
8483 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
8484 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
8485 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
8486 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
8488 /* Capture mixer control */
8489 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
8490 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
8492 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8493 .name = "Capture Source",
8495 .info = alc_mux_enum_info,
8496 .get = alc_mux_enum_get,
8497 .put = alc_mux_enum_put,
8500 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8501 .name = "Channel Mode",
8502 .info = alc_ch_mode_info,
8503 .get = alc_ch_mode_get,
8504 .put = alc_ch_mode_put,
8505 .private_value = ARRAY_SIZE(alc861_threestack_modes),
8510 static struct snd_kcontrol_new alc861_toshiba_mixer[] = {
8511 /* output mixer control */
8512 HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT),
8513 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
8514 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
8516 /*Capture mixer control */
8517 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
8518 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
8520 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8521 .name = "Capture Source",
8523 .info = alc_mux_enum_info,
8524 .get = alc_mux_enum_get,
8525 .put = alc_mux_enum_put,
8531 static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
8532 /* output mixer control */
8533 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
8534 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
8535 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
8536 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
8537 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
8539 /* Input mixer control */
8540 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
8541 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
8542 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
8543 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
8544 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
8545 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
8546 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
8547 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
8548 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
8549 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
8551 /* Capture mixer control */
8552 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
8553 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
8555 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8556 .name = "Capture Source",
8558 .info = alc_mux_enum_info,
8559 .get = alc_mux_enum_get,
8560 .put = alc_mux_enum_put,
8563 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8564 .name = "Channel Mode",
8565 .info = alc_ch_mode_info,
8566 .get = alc_ch_mode_get,
8567 .put = alc_ch_mode_put,
8568 .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
8573 static struct snd_kcontrol_new alc861_asus_mixer[] = {
8574 /* output mixer control */
8575 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
8576 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
8577 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
8578 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
8579 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
8581 /* Input mixer control */
8582 HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
8583 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8584 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
8585 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
8586 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
8587 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
8588 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
8589 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
8590 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
8591 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT),
8593 /* Capture mixer control */
8594 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
8595 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
8597 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8598 .name = "Capture Source",
8600 .info = alc_mux_enum_info,
8601 .get = alc_mux_enum_get,
8602 .put = alc_mux_enum_put,
8605 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8606 .name = "Channel Mode",
8607 .info = alc_ch_mode_info,
8608 .get = alc_ch_mode_get,
8609 .put = alc_ch_mode_put,
8610 .private_value = ARRAY_SIZE(alc861_asus_modes),
8615 /* additional mixer */
8616 static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = {
8617 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
8618 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
8619 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x23, 0x0, HDA_OUTPUT),
8620 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x23, 0x0, HDA_OUTPUT),
8625 * generic initialization of ADC, input mixers and output mixers
8627 static struct hda_verb alc861_base_init_verbs[] = {
8629 * Unmute ADC0 and set the default input to mic-in
8631 /* port-A for surround (rear panel) */
8632 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
8633 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
8634 /* port-B for mic-in (rear panel) with vref */
8635 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
8636 /* port-C for line-in (rear panel) */
8637 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
8638 /* port-D for Front */
8639 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
8640 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
8641 /* port-E for HP out (front panel) */
8642 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
8643 /* route front PCM to HP */
8644 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
8645 /* port-F for mic-in (front panel) with vref */
8646 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
8647 /* port-G for CLFE (rear panel) */
8648 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
8649 { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
8650 /* port-H for side (rear panel) */
8651 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
8652 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
8654 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
8655 /* route front mic to ADC1*/
8656 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8657 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8659 /* Unmute DAC0~3 & spdif out*/
8660 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8661 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8662 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8663 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8664 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8666 /* Unmute Mixer 14 (mic) 1c (Line in)*/
8667 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8668 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8669 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8670 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8672 /* Unmute Stereo Mixer 15 */
8673 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8674 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8675 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
8676 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
8678 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8679 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8680 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8681 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8682 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8683 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8684 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8685 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8686 /* hp used DAC 3 (Front) */
8687 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
8688 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
8693 static struct hda_verb alc861_threestack_init_verbs[] = {
8695 * Unmute ADC0 and set the default input to mic-in
8697 /* port-A for surround (rear panel) */
8698 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
8699 /* port-B for mic-in (rear panel) with vref */
8700 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
8701 /* port-C for line-in (rear panel) */
8702 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
8703 /* port-D for Front */
8704 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
8705 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
8706 /* port-E for HP out (front panel) */
8707 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
8708 /* route front PCM to HP */
8709 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
8710 /* port-F for mic-in (front panel) with vref */
8711 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
8712 /* port-G for CLFE (rear panel) */
8713 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
8714 /* port-H for side (rear panel) */
8715 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
8717 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
8718 /* route front mic to ADC1*/
8719 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8720 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8721 /* Unmute DAC0~3 & spdif out*/
8722 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8723 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8724 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8725 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8726 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8728 /* Unmute Mixer 14 (mic) 1c (Line in)*/
8729 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8730 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8731 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8732 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8734 /* Unmute Stereo Mixer 15 */
8735 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8736 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8737 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
8738 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
8740 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8741 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8742 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8743 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8744 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8745 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8746 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8747 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8748 /* hp used DAC 3 (Front) */
8749 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
8750 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
8754 static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
8756 * Unmute ADC0 and set the default input to mic-in
8758 /* port-A for surround (rear panel) */
8759 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
8760 /* port-B for mic-in (rear panel) with vref */
8761 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
8762 /* port-C for line-in (rear panel) */
8763 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
8764 /* port-D for Front */
8765 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
8766 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
8767 /* port-E for HP out (front panel) */
8768 /* this has to be set to VREF80 */
8769 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
8770 /* route front PCM to HP */
8771 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
8772 /* port-F for mic-in (front panel) with vref */
8773 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
8774 /* port-G for CLFE (rear panel) */
8775 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
8776 /* port-H for side (rear panel) */
8777 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
8779 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
8780 /* route front mic to ADC1*/
8781 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8782 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8783 /* Unmute DAC0~3 & spdif out*/
8784 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8785 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8786 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8787 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8788 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8790 /* Unmute Mixer 14 (mic) 1c (Line in)*/
8791 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8792 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8793 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8794 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8796 /* Unmute Stereo Mixer 15 */
8797 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8798 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8799 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
8800 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
8802 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8803 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8804 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8805 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8806 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8807 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8808 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8809 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8810 /* hp used DAC 3 (Front) */
8811 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
8812 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
8816 static struct hda_verb alc861_asus_init_verbs[] = {
8818 * Unmute ADC0 and set the default input to mic-in
8820 /* port-A for surround (rear panel)
8821 * according to codec#0 this is the HP jack
8823 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */
8824 /* route front PCM to HP */
8825 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 },
8826 /* port-B for mic-in (rear panel) with vref */
8827 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
8828 /* port-C for line-in (rear panel) */
8829 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
8830 /* port-D for Front */
8831 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
8832 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
8833 /* port-E for HP out (front panel) */
8834 /* this has to be set to VREF80 */
8835 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
8836 /* route front PCM to HP */
8837 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
8838 /* port-F for mic-in (front panel) with vref */
8839 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
8840 /* port-G for CLFE (rear panel) */
8841 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
8842 /* port-H for side (rear panel) */
8843 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
8845 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
8846 /* route front mic to ADC1*/
8847 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8848 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8849 /* Unmute DAC0~3 & spdif out*/
8850 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8851 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8852 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8853 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8854 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8855 /* Unmute Mixer 14 (mic) 1c (Line in)*/
8856 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8857 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8858 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8859 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8861 /* Unmute Stereo Mixer 15 */
8862 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8863 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8864 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
8865 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
8867 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8868 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8869 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8870 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8871 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8872 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8873 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8874 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8875 /* hp used DAC 3 (Front) */
8876 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
8877 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
8881 /* additional init verbs for ASUS laptops */
8882 static struct hda_verb alc861_asus_laptop_init_verbs[] = {
8883 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */
8884 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */
8889 * generic initialization of ADC, input mixers and output mixers
8891 static struct hda_verb alc861_auto_init_verbs[] = {
8893 * Unmute ADC0 and set the default input to mic-in
8895 /* {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, */
8896 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8898 /* Unmute DAC0~3 & spdif out*/
8899 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8900 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8901 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8902 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8903 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8905 /* Unmute Mixer 14 (mic) 1c (Line in)*/
8906 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8907 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8908 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8909 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8911 /* Unmute Stereo Mixer 15 */
8912 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8913 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8914 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
8915 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
8917 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8918 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8919 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8920 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8921 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8922 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8923 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8924 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8926 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8927 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8928 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
8929 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
8930 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8931 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8932 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
8933 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
8935 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */
8940 static struct hda_verb alc861_toshiba_init_verbs[] = {
8941 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
8946 /* toggle speaker-output according to the hp-jack state */
8947 static void alc861_toshiba_automute(struct hda_codec *codec)
8949 unsigned int present;
8951 present = snd_hda_codec_read(codec, 0x0f, 0,
8952 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8953 snd_hda_codec_amp_update(codec, 0x16, 0, HDA_INPUT, 0,
8954 0x80, present ? 0x80 : 0);
8955 snd_hda_codec_amp_update(codec, 0x16, 1, HDA_INPUT, 0,
8956 0x80, present ? 0x80 : 0);
8957 snd_hda_codec_amp_update(codec, 0x1a, 0, HDA_INPUT, 3,
8958 0x80, present ? 0 : 0x80);
8959 snd_hda_codec_amp_update(codec, 0x1a, 1, HDA_INPUT, 3,
8960 0x80, present ? 0 : 0x80);
8963 static void alc861_toshiba_unsol_event(struct hda_codec *codec,
8966 if ((res >> 26) == ALC880_HP_EVENT)
8967 alc861_toshiba_automute(codec);
8970 /* pcm configuration: identiacal with ALC880 */
8971 #define alc861_pcm_analog_playback alc880_pcm_analog_playback
8972 #define alc861_pcm_analog_capture alc880_pcm_analog_capture
8973 #define alc861_pcm_digital_playback alc880_pcm_digital_playback
8974 #define alc861_pcm_digital_capture alc880_pcm_digital_capture
8977 #define ALC861_DIGOUT_NID 0x07
8979 static struct hda_channel_mode alc861_8ch_modes[1] = {
8983 static hda_nid_t alc861_dac_nids[4] = {
8984 /* front, surround, clfe, side */
8985 0x03, 0x06, 0x05, 0x04
8988 static hda_nid_t alc660_dac_nids[3] = {
8989 /* front, clfe, surround */
8993 static hda_nid_t alc861_adc_nids[1] = {
8998 static struct hda_input_mux alc861_capture_source = {
9002 { "Front Mic", 0x3 },
9009 /* fill in the dac_nids table from the parsed pin configuration */
9010 static int alc861_auto_fill_dac_nids(struct alc_spec *spec,
9011 const struct auto_pin_cfg *cfg)
9016 spec->multiout.dac_nids = spec->private_dac_nids;
9017 for (i = 0; i < cfg->line_outs; i++) {
9018 nid = cfg->line_out_pins[i];
9020 if (i >= ARRAY_SIZE(alc861_dac_nids))
9022 spec->multiout.dac_nids[i] = alc861_dac_nids[i];
9025 spec->multiout.num_dacs = cfg->line_outs;
9029 /* add playback controls from the parsed DAC table */
9030 static int alc861_auto_create_multi_out_ctls(struct alc_spec *spec,
9031 const struct auto_pin_cfg *cfg)
9034 static const char *chname[4] = {
9035 "Front", "Surround", NULL /*CLFE*/, "Side"
9040 for (i = 0; i < cfg->line_outs; i++) {
9041 nid = spec->multiout.dac_nids[i];
9046 err = add_control(spec, ALC_CTL_BIND_MUTE,
9047 "Center Playback Switch",
9048 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
9052 err = add_control(spec, ALC_CTL_BIND_MUTE,
9053 "LFE Playback Switch",
9054 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
9059 for (idx = 0; idx < ARRAY_SIZE(alc861_dac_nids) - 1;
9061 if (nid == alc861_dac_nids[idx])
9063 sprintf(name, "%s Playback Switch", chname[idx]);
9064 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
9065 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
9074 static int alc861_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin)
9082 if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
9084 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
9085 "Headphone Playback Switch",
9086 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
9089 spec->multiout.hp_nid = nid;
9094 /* create playback/capture controls for input pins */
9095 static int alc861_auto_create_analog_input_ctls(struct alc_spec *spec,
9096 const struct auto_pin_cfg *cfg)
9098 struct hda_input_mux *imux = &spec->private_imux;
9099 int i, err, idx, idx1;
9101 for (i = 0; i < AUTO_PIN_LAST; i++) {
9102 switch (cfg->input_pins[i]) {
9105 idx = 2; /* Line In */
9109 idx = 2; /* Line In */
9113 idx = 1; /* Mic In */
9117 idx = 1; /* Mic In */
9127 err = new_analog_input(spec, cfg->input_pins[i],
9128 auto_pin_cfg_labels[i], idx, 0x15);
9132 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
9133 imux->items[imux->num_items].index = idx1;
9139 static struct snd_kcontrol_new alc861_capture_mixer[] = {
9140 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
9141 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
9144 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9145 /* The multiple "Capture Source" controls confuse alsamixer
9146 * So call somewhat different..
9147 *FIXME: the controls appear in the "playback" view!
9149 /* .name = "Capture Source", */
9150 .name = "Input Source",
9152 .info = alc_mux_enum_info,
9153 .get = alc_mux_enum_get,
9154 .put = alc_mux_enum_put,
9159 static void alc861_auto_set_output_and_unmute(struct hda_codec *codec,
9161 int pin_type, int dac_idx)
9165 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
9167 snd_hda_codec_write(codec, dac_idx, 0, AC_VERB_SET_AMP_GAIN_MUTE,
9172 static void alc861_auto_init_multi_out(struct hda_codec *codec)
9174 struct alc_spec *spec = codec->spec;
9177 alc_subsystem_id(codec, 0x0e, 0x0f, 0x0b);
9178 for (i = 0; i < spec->autocfg.line_outs; i++) {
9179 hda_nid_t nid = spec->autocfg.line_out_pins[i];
9180 int pin_type = get_pin_type(spec->autocfg.line_out_type);
9182 alc861_auto_set_output_and_unmute(codec, nid, pin_type,
9183 spec->multiout.dac_nids[i]);
9187 static void alc861_auto_init_hp_out(struct hda_codec *codec)
9189 struct alc_spec *spec = codec->spec;
9192 pin = spec->autocfg.hp_pins[0];
9193 if (pin) /* connect to front */
9194 alc861_auto_set_output_and_unmute(codec, pin, PIN_HP,
9195 spec->multiout.dac_nids[0]);
9198 static void alc861_auto_init_analog_input(struct hda_codec *codec)
9200 struct alc_spec *spec = codec->spec;
9203 for (i = 0; i < AUTO_PIN_LAST; i++) {
9204 hda_nid_t nid = spec->autocfg.input_pins[i];
9205 if (nid >= 0x0c && nid <= 0x11) {
9206 snd_hda_codec_write(codec, nid, 0,
9207 AC_VERB_SET_PIN_WIDGET_CONTROL,
9208 i <= AUTO_PIN_FRONT_MIC ?
9209 PIN_VREF80 : PIN_IN);
9214 /* parse the BIOS configuration and set up the alc_spec */
9215 /* return 1 if successful, 0 if the proper config is not found,
9216 * or a negative error code
9218 static int alc861_parse_auto_config(struct hda_codec *codec)
9220 struct alc_spec *spec = codec->spec;
9222 static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
9224 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
9228 if (!spec->autocfg.line_outs)
9229 return 0; /* can't find valid BIOS pin config */
9231 err = alc861_auto_fill_dac_nids(spec, &spec->autocfg);
9234 err = alc861_auto_create_multi_out_ctls(spec, &spec->autocfg);
9237 err = alc861_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0]);
9240 err = alc861_auto_create_analog_input_ctls(spec, &spec->autocfg);
9244 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
9246 if (spec->autocfg.dig_out_pin)
9247 spec->multiout.dig_out_nid = ALC861_DIGOUT_NID;
9249 if (spec->kctl_alloc)
9250 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
9252 spec->init_verbs[spec->num_init_verbs++] = alc861_auto_init_verbs;
9254 spec->num_mux_defs = 1;
9255 spec->input_mux = &spec->private_imux;
9257 spec->adc_nids = alc861_adc_nids;
9258 spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
9259 spec->mixers[spec->num_mixers] = alc861_capture_mixer;
9265 /* additional initialization for auto-configuration model */
9266 static void alc861_auto_init(struct hda_codec *codec)
9268 alc861_auto_init_multi_out(codec);
9269 alc861_auto_init_hp_out(codec);
9270 alc861_auto_init_analog_input(codec);
9275 * configuration and preset
9277 static const char *alc861_models[ALC861_MODEL_LAST] = {
9278 [ALC861_3ST] = "3stack",
9279 [ALC660_3ST] = "3stack-660",
9280 [ALC861_3ST_DIG] = "3stack-dig",
9281 [ALC861_6ST_DIG] = "6stack-dig",
9282 [ALC861_UNIWILL_M31] = "uniwill-m31",
9283 [ALC861_TOSHIBA] = "toshiba",
9284 [ALC861_ASUS] = "asus",
9285 [ALC861_ASUS_LAPTOP] = "asus-laptop",
9286 [ALC861_AUTO] = "auto",
9289 static struct snd_pci_quirk alc861_cfg_tbl[] = {
9290 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST),
9291 SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP),
9292 SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP),
9293 SND_PCI_QUIRK(0x1043, 0x13d7, "ASUS A9rp", ALC861_ASUS_LAPTOP),
9294 SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS),
9295 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA),
9296 SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA),
9297 SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31),
9298 SND_PCI_QUIRK(0x1584, 0x9075, "Uniwill", ALC861_UNIWILL_M31),
9299 SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31),
9300 SND_PCI_QUIRK(0x1849, 0x0660, "Asrock 939SLI32", ALC660_3ST),
9301 SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST),
9305 static struct alc_config_preset alc861_presets[] = {
9307 .mixers = { alc861_3ST_mixer },
9308 .init_verbs = { alc861_threestack_init_verbs },
9309 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
9310 .dac_nids = alc861_dac_nids,
9311 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
9312 .channel_mode = alc861_threestack_modes,
9314 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
9315 .adc_nids = alc861_adc_nids,
9316 .input_mux = &alc861_capture_source,
9318 [ALC861_3ST_DIG] = {
9319 .mixers = { alc861_base_mixer },
9320 .init_verbs = { alc861_threestack_init_verbs },
9321 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
9322 .dac_nids = alc861_dac_nids,
9323 .dig_out_nid = ALC861_DIGOUT_NID,
9324 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
9325 .channel_mode = alc861_threestack_modes,
9327 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
9328 .adc_nids = alc861_adc_nids,
9329 .input_mux = &alc861_capture_source,
9331 [ALC861_6ST_DIG] = {
9332 .mixers = { alc861_base_mixer },
9333 .init_verbs = { alc861_base_init_verbs },
9334 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
9335 .dac_nids = alc861_dac_nids,
9336 .dig_out_nid = ALC861_DIGOUT_NID,
9337 .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
9338 .channel_mode = alc861_8ch_modes,
9339 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
9340 .adc_nids = alc861_adc_nids,
9341 .input_mux = &alc861_capture_source,
9344 .mixers = { alc861_3ST_mixer },
9345 .init_verbs = { alc861_threestack_init_verbs },
9346 .num_dacs = ARRAY_SIZE(alc660_dac_nids),
9347 .dac_nids = alc660_dac_nids,
9348 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
9349 .channel_mode = alc861_threestack_modes,
9351 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
9352 .adc_nids = alc861_adc_nids,
9353 .input_mux = &alc861_capture_source,
9355 [ALC861_UNIWILL_M31] = {
9356 .mixers = { alc861_uniwill_m31_mixer },
9357 .init_verbs = { alc861_uniwill_m31_init_verbs },
9358 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
9359 .dac_nids = alc861_dac_nids,
9360 .dig_out_nid = ALC861_DIGOUT_NID,
9361 .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes),
9362 .channel_mode = alc861_uniwill_m31_modes,
9364 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
9365 .adc_nids = alc861_adc_nids,
9366 .input_mux = &alc861_capture_source,
9368 [ALC861_TOSHIBA] = {
9369 .mixers = { alc861_toshiba_mixer },
9370 .init_verbs = { alc861_base_init_verbs,
9371 alc861_toshiba_init_verbs },
9372 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
9373 .dac_nids = alc861_dac_nids,
9374 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9375 .channel_mode = alc883_3ST_2ch_modes,
9376 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
9377 .adc_nids = alc861_adc_nids,
9378 .input_mux = &alc861_capture_source,
9379 .unsol_event = alc861_toshiba_unsol_event,
9380 .init_hook = alc861_toshiba_automute,
9383 .mixers = { alc861_asus_mixer },
9384 .init_verbs = { alc861_asus_init_verbs },
9385 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
9386 .dac_nids = alc861_dac_nids,
9387 .dig_out_nid = ALC861_DIGOUT_NID,
9388 .num_channel_mode = ARRAY_SIZE(alc861_asus_modes),
9389 .channel_mode = alc861_asus_modes,
9392 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
9393 .adc_nids = alc861_adc_nids,
9394 .input_mux = &alc861_capture_source,
9396 [ALC861_ASUS_LAPTOP] = {
9397 .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer },
9398 .init_verbs = { alc861_asus_init_verbs,
9399 alc861_asus_laptop_init_verbs },
9400 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
9401 .dac_nids = alc861_dac_nids,
9402 .dig_out_nid = ALC861_DIGOUT_NID,
9403 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9404 .channel_mode = alc883_3ST_2ch_modes,
9406 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
9407 .adc_nids = alc861_adc_nids,
9408 .input_mux = &alc861_capture_source,
9413 static int patch_alc861(struct hda_codec *codec)
9415 struct alc_spec *spec;
9419 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
9425 board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST,
9429 if (board_config < 0) {
9430 printk(KERN_INFO "hda_codec: Unknown model for ALC861, "
9431 "trying auto-probe from BIOS...\n");
9432 board_config = ALC861_AUTO;
9435 if (board_config == ALC861_AUTO) {
9436 /* automatic parse from the BIOS config */
9437 err = alc861_parse_auto_config(codec);
9443 "hda_codec: Cannot set up configuration "
9444 "from BIOS. Using base mode...\n");
9445 board_config = ALC861_3ST_DIG;
9449 if (board_config != ALC861_AUTO)
9450 setup_preset(spec, &alc861_presets[board_config]);
9452 spec->stream_name_analog = "ALC861 Analog";
9453 spec->stream_analog_playback = &alc861_pcm_analog_playback;
9454 spec->stream_analog_capture = &alc861_pcm_analog_capture;
9456 spec->stream_name_digital = "ALC861 Digital";
9457 spec->stream_digital_playback = &alc861_pcm_digital_playback;
9458 spec->stream_digital_capture = &alc861_pcm_digital_capture;
9460 codec->patch_ops = alc_patch_ops;
9461 if (board_config == ALC861_AUTO)
9462 spec->init_hook = alc861_auto_init;
9472 * In addition, an independent DAC
9474 #define ALC861VD_DIGOUT_NID 0x06
9476 static hda_nid_t alc861vd_dac_nids[4] = {
9477 /* front, surr, clfe, side surr */
9478 0x02, 0x03, 0x04, 0x05
9481 /* dac_nids for ALC660vd are in a different order - according to
9483 * This should probably tesult in a different mixer for 6stack models
9484 * of ALC660vd codecs, but for now there is only 3stack mixer
9485 * - and it is the same as in 861vd.
9486 * adc_nids in ALC660vd are (is) the same as in 861vd
9488 static hda_nid_t alc660vd_dac_nids[3] = {
9489 /* front, rear, clfe, rear_surr */
9493 static hda_nid_t alc861vd_adc_nids[1] = {
9499 /* FIXME: should be a matrix-type input source selection */
9500 static struct hda_input_mux alc861vd_capture_source = {
9504 { "Front Mic", 0x1 },
9510 static struct hda_input_mux alc861vd_dallas_capture_source = {
9513 { "Front Mic", 0x0 },
9514 { "ATAPI Mic", 0x1 },
9519 #define alc861vd_mux_enum_info alc_mux_enum_info
9520 #define alc861vd_mux_enum_get alc_mux_enum_get
9522 static int alc861vd_mux_enum_put(struct snd_kcontrol *kcontrol,
9523 struct snd_ctl_elem_value *ucontrol)
9525 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
9526 struct alc_spec *spec = codec->spec;
9527 const struct hda_input_mux *imux = spec->input_mux;
9528 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
9529 static hda_nid_t capture_mixers[1] = { 0x22 };
9530 hda_nid_t nid = capture_mixers[adc_idx];
9531 unsigned int *cur_val = &spec->cur_mux[adc_idx];
9532 unsigned int i, idx;
9534 idx = ucontrol->value.enumerated.item[0];
9535 if (idx >= imux->num_items)
9536 idx = imux->num_items - 1;
9537 if (*cur_val == idx && !codec->in_resume)
9539 for (i = 0; i < imux->num_items; i++) {
9540 unsigned int v = (i == idx) ? 0x7000 : 0x7080;
9541 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
9542 v | (imux->items[i].index << 8));
9551 static struct hda_channel_mode alc861vd_3stack_2ch_modes[1] = {
9558 static struct hda_verb alc861vd_6stack_ch6_init[] = {
9559 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
9560 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9561 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9562 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9569 static struct hda_verb alc861vd_6stack_ch8_init[] = {
9570 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9571 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9572 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9573 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9577 static struct hda_channel_mode alc861vd_6stack_modes[2] = {
9578 { 6, alc861vd_6stack_ch6_init },
9579 { 8, alc861vd_6stack_ch8_init },
9582 static struct snd_kcontrol_new alc861vd_chmode_mixer[] = {
9584 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9585 .name = "Channel Mode",
9586 .info = alc_ch_mode_info,
9587 .get = alc_ch_mode_get,
9588 .put = alc_ch_mode_put,
9593 static struct snd_kcontrol_new alc861vd_capture_mixer[] = {
9594 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
9595 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
9598 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9599 /* The multiple "Capture Source" controls confuse alsamixer
9600 * So call somewhat different..
9601 *FIXME: the controls appear in the "playback" view!
9603 /* .name = "Capture Source", */
9604 .name = "Input Source",
9606 .info = alc861vd_mux_enum_info,
9607 .get = alc861vd_mux_enum_get,
9608 .put = alc861vd_mux_enum_put,
9613 /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
9614 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
9616 static struct snd_kcontrol_new alc861vd_6st_mixer[] = {
9617 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
9618 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
9620 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
9621 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
9623 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0,
9625 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0,
9627 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
9628 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
9630 HDA_CODEC_VOLUME("Side Playback Volume", 0x05, 0x0, HDA_OUTPUT),
9631 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
9633 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
9635 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9636 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9637 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9639 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
9640 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
9641 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
9643 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9644 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9646 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9647 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9649 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
9650 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
9655 static struct snd_kcontrol_new alc861vd_3st_mixer[] = {
9656 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
9657 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
9659 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
9661 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9662 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9663 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9665 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
9666 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
9667 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
9669 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9670 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9672 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9673 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9675 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
9676 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
9681 static struct snd_kcontrol_new alc861vd_lenovo_mixer[] = {
9682 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
9683 /*HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),*/
9684 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9686 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
9688 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9689 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9690 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9692 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
9693 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
9694 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
9696 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9697 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9702 /* Pin assignment: Front=0x14, HP = 0x15,
9703 * Front Mic=0x18, ATAPI Mic = 0x19, Line In = 0x1d
9705 static struct snd_kcontrol_new alc861vd_dallas_mixer[] = {
9706 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
9707 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
9708 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
9709 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
9710 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9711 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9712 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
9713 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
9714 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x05, HDA_INPUT),
9715 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x05, HDA_INPUT),
9716 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
9717 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
9719 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9720 /* .name = "Capture Source", */
9721 .name = "Input Source",
9723 .info = alc882_mux_enum_info,
9724 .get = alc882_mux_enum_get,
9725 .put = alc882_mux_enum_put,
9731 * generic initialization of ADC, input mixers and output mixers
9733 static struct hda_verb alc861vd_volume_init_verbs[] = {
9735 * Unmute ADC0 and set the default input to mic-in
9737 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
9738 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9740 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of
9741 * the analog-loopback mixer widget
9743 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
9744 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9745 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9746 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
9747 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
9748 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
9750 /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */
9751 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9752 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9753 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
9754 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
9757 * Set up output mixers (0x02 - 0x05)
9759 /* set vol=0 to output mixers */
9760 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9761 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9762 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9763 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9765 /* set up input amps for analog loopback */
9766 /* Amp Indices: DAC = 0, mixer = 1 */
9767 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9768 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9769 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9770 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9771 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9772 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9773 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9774 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9780 * 3-stack pin configuration:
9781 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
9783 static struct hda_verb alc861vd_3stack_init_verbs[] = {
9785 * Set pin mode and muting
9787 /* set front pin widgets 0x14 for output */
9788 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9789 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9790 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
9792 /* Mic (rear) pin: input vref at 80% */
9793 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
9794 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9795 /* Front Mic pin: input vref at 80% */
9796 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
9797 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9798 /* Line In pin: input */
9799 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
9800 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9801 /* Line-2 In: Headphone output (output 0 - 0x0c) */
9802 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9803 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9804 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
9805 /* CD pin widget for input */
9806 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
9812 * 6-stack pin configuration:
9814 static struct hda_verb alc861vd_6stack_init_verbs[] = {
9816 * Set pin mode and muting
9818 /* set front pin widgets 0x14 for output */
9819 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9820 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9821 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
9823 /* Rear Pin: output 1 (0x0d) */
9824 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9825 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9826 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
9827 /* CLFE Pin: output 2 (0x0e) */
9828 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9829 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9830 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
9831 /* Side Pin: output 3 (0x0f) */
9832 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9833 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9834 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
9836 /* Mic (rear) pin: input vref at 80% */
9837 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
9838 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9839 /* Front Mic pin: input vref at 80% */
9840 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
9841 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9842 /* Line In pin: input */
9843 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
9844 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9845 /* Line-2 In: Headphone output (output 0 - 0x0c) */
9846 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9847 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9848 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
9849 /* CD pin widget for input */
9850 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
9855 static struct hda_verb alc861vd_eapd_verbs[] = {
9856 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
9860 static struct hda_verb alc861vd_lenovo_unsol_verbs[] = {
9861 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9862 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9863 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
9864 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9865 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
9869 /* toggle speaker-output according to the hp-jack state */
9870 static void alc861vd_lenovo_hp_automute(struct hda_codec *codec)
9872 unsigned int present;
9875 present = snd_hda_codec_read(codec, 0x1b, 0,
9876 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
9877 bits = present ? 0x80 : 0;
9878 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
9880 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
9884 static void alc861vd_lenovo_mic_automute(struct hda_codec *codec)
9886 unsigned int present;
9889 present = snd_hda_codec_read(codec, 0x18, 0,
9890 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
9891 bits = present ? 0x80 : 0;
9892 snd_hda_codec_amp_update(codec, 0x0b, 0, HDA_INPUT, 1,
9894 snd_hda_codec_amp_update(codec, 0x0b, 1, HDA_INPUT, 1,
9898 static void alc861vd_lenovo_automute(struct hda_codec *codec)
9900 alc861vd_lenovo_hp_automute(codec);
9901 alc861vd_lenovo_mic_automute(codec);
9904 static void alc861vd_lenovo_unsol_event(struct hda_codec *codec,
9907 switch (res >> 26) {
9908 case ALC880_HP_EVENT:
9909 alc861vd_lenovo_hp_automute(codec);
9911 case ALC880_MIC_EVENT:
9912 alc861vd_lenovo_mic_automute(codec);
9917 static struct hda_verb alc861vd_dallas_verbs[] = {
9918 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9919 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9920 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9921 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9923 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9924 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9925 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9926 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9927 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9928 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9929 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9930 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9932 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9933 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9934 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9935 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9936 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9937 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9938 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9939 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9941 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
9942 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9943 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
9944 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9945 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
9946 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
9947 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
9948 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
9950 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9951 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
9952 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
9953 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
9955 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9956 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
9957 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9962 /* toggle speaker-output according to the hp-jack state */
9963 static void alc861vd_dallas_automute(struct hda_codec *codec)
9965 unsigned int present;
9967 present = snd_hda_codec_read(codec, 0x15, 0,
9968 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
9969 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
9970 0x80, present ? 0x80 : 0);
9971 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
9972 0x80, present ? 0x80 : 0);
9975 static void alc861vd_dallas_unsol_event(struct hda_codec *codec, unsigned int res)
9977 if ((res >> 26) == ALC880_HP_EVENT)
9978 alc861vd_dallas_automute(codec);
9981 /* pcm configuration: identiacal with ALC880 */
9982 #define alc861vd_pcm_analog_playback alc880_pcm_analog_playback
9983 #define alc861vd_pcm_analog_capture alc880_pcm_analog_capture
9984 #define alc861vd_pcm_digital_playback alc880_pcm_digital_playback
9985 #define alc861vd_pcm_digital_capture alc880_pcm_digital_capture
9988 * configuration and preset
9990 static const char *alc861vd_models[ALC861VD_MODEL_LAST] = {
9991 [ALC660VD_3ST] = "3stack-660",
9992 [ALC660VD_3ST_DIG]= "3stack-660-digout",
9993 [ALC861VD_3ST] = "3stack",
9994 [ALC861VD_3ST_DIG] = "3stack-digout",
9995 [ALC861VD_6ST_DIG] = "6stack-digout",
9996 [ALC861VD_LENOVO] = "lenovo",
9997 [ALC861VD_DALLAS] = "dallas",
9998 [ALC861VD_AUTO] = "auto",
10001 static struct snd_pci_quirk alc861vd_cfg_tbl[] = {
10002 SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST),
10003 SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST),
10004 SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660VD_3ST_DIG),
10005 SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST),
10006 SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST),
10008 SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),
10009 SND_PCI_QUIRK(0x1179, 0xff01, "DALLAS", ALC861VD_DALLAS),
10010 SND_PCI_QUIRK(0x17aa, 0x3802, "Lenovo 3000 C200", ALC861VD_LENOVO),
10011 SND_PCI_QUIRK(0x17aa, 0x2066, "Lenovo", ALC861VD_LENOVO),
10012 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba A135", ALC861VD_LENOVO),
10016 static struct alc_config_preset alc861vd_presets[] = {
10018 .mixers = { alc861vd_3st_mixer },
10019 .init_verbs = { alc861vd_volume_init_verbs,
10020 alc861vd_3stack_init_verbs },
10021 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
10022 .dac_nids = alc660vd_dac_nids,
10023 .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
10024 .adc_nids = alc861vd_adc_nids,
10025 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
10026 .channel_mode = alc861vd_3stack_2ch_modes,
10027 .input_mux = &alc861vd_capture_source,
10029 [ALC660VD_3ST_DIG] = {
10030 .mixers = { alc861vd_3st_mixer },
10031 .init_verbs = { alc861vd_volume_init_verbs,
10032 alc861vd_3stack_init_verbs },
10033 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
10034 .dac_nids = alc660vd_dac_nids,
10035 .dig_out_nid = ALC861VD_DIGOUT_NID,
10036 .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
10037 .adc_nids = alc861vd_adc_nids,
10038 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
10039 .channel_mode = alc861vd_3stack_2ch_modes,
10040 .input_mux = &alc861vd_capture_source,
10043 .mixers = { alc861vd_3st_mixer },
10044 .init_verbs = { alc861vd_volume_init_verbs,
10045 alc861vd_3stack_init_verbs },
10046 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
10047 .dac_nids = alc861vd_dac_nids,
10048 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
10049 .channel_mode = alc861vd_3stack_2ch_modes,
10050 .input_mux = &alc861vd_capture_source,
10052 [ALC861VD_3ST_DIG] = {
10053 .mixers = { alc861vd_3st_mixer },
10054 .init_verbs = { alc861vd_volume_init_verbs,
10055 alc861vd_3stack_init_verbs },
10056 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
10057 .dac_nids = alc861vd_dac_nids,
10058 .dig_out_nid = ALC861VD_DIGOUT_NID,
10059 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
10060 .channel_mode = alc861vd_3stack_2ch_modes,
10061 .input_mux = &alc861vd_capture_source,
10063 [ALC861VD_6ST_DIG] = {
10064 .mixers = { alc861vd_6st_mixer, alc861vd_chmode_mixer },
10065 .init_verbs = { alc861vd_volume_init_verbs,
10066 alc861vd_6stack_init_verbs },
10067 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
10068 .dac_nids = alc861vd_dac_nids,
10069 .dig_out_nid = ALC861VD_DIGOUT_NID,
10070 .num_channel_mode = ARRAY_SIZE(alc861vd_6stack_modes),
10071 .channel_mode = alc861vd_6stack_modes,
10072 .input_mux = &alc861vd_capture_source,
10074 [ALC861VD_LENOVO] = {
10075 .mixers = { alc861vd_lenovo_mixer },
10076 .init_verbs = { alc861vd_volume_init_verbs,
10077 alc861vd_3stack_init_verbs,
10078 alc861vd_eapd_verbs,
10079 alc861vd_lenovo_unsol_verbs },
10080 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
10081 .dac_nids = alc660vd_dac_nids,
10082 .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
10083 .adc_nids = alc861vd_adc_nids,
10084 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
10085 .channel_mode = alc861vd_3stack_2ch_modes,
10086 .input_mux = &alc861vd_capture_source,
10087 .unsol_event = alc861vd_lenovo_unsol_event,
10088 .init_hook = alc861vd_lenovo_automute,
10090 [ALC861VD_DALLAS] = {
10091 .mixers = { alc861vd_dallas_mixer },
10092 .init_verbs = { alc861vd_dallas_verbs },
10093 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
10094 .dac_nids = alc861vd_dac_nids,
10095 .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
10096 .adc_nids = alc861vd_adc_nids,
10097 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
10098 .channel_mode = alc861vd_3stack_2ch_modes,
10099 .input_mux = &alc861vd_dallas_capture_source,
10100 .unsol_event = alc861vd_dallas_unsol_event,
10101 .init_hook = alc861vd_dallas_automute,
10106 * BIOS auto configuration
10108 static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec,
10109 hda_nid_t nid, int pin_type, int dac_idx)
10111 /* set as output */
10112 snd_hda_codec_write(codec, nid, 0,
10113 AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
10114 snd_hda_codec_write(codec, nid, 0,
10115 AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
10118 static void alc861vd_auto_init_multi_out(struct hda_codec *codec)
10120 struct alc_spec *spec = codec->spec;
10123 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
10124 for (i = 0; i <= HDA_SIDE; i++) {
10125 hda_nid_t nid = spec->autocfg.line_out_pins[i];
10126 int pin_type = get_pin_type(spec->autocfg.line_out_type);
10128 alc861vd_auto_set_output_and_unmute(codec, nid,
10134 static void alc861vd_auto_init_hp_out(struct hda_codec *codec)
10136 struct alc_spec *spec = codec->spec;
10139 pin = spec->autocfg.hp_pins[0];
10140 if (pin) /* connect to front and use dac 0 */
10141 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
10144 #define alc861vd_is_input_pin(nid) alc880_is_input_pin(nid)
10145 #define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID
10147 static void alc861vd_auto_init_analog_input(struct hda_codec *codec)
10149 struct alc_spec *spec = codec->spec;
10152 for (i = 0; i < AUTO_PIN_LAST; i++) {
10153 hda_nid_t nid = spec->autocfg.input_pins[i];
10154 if (alc861vd_is_input_pin(nid)) {
10155 snd_hda_codec_write(codec, nid, 0,
10156 AC_VERB_SET_PIN_WIDGET_CONTROL,
10157 i <= AUTO_PIN_FRONT_MIC ?
10158 PIN_VREF80 : PIN_IN);
10159 if (nid != ALC861VD_PIN_CD_NID)
10160 snd_hda_codec_write(codec, nid, 0,
10161 AC_VERB_SET_AMP_GAIN_MUTE,
10167 #define alc861vd_idx_to_mixer_vol(nid) ((nid) + 0x02)
10168 #define alc861vd_idx_to_mixer_switch(nid) ((nid) + 0x0c)
10170 /* add playback controls from the parsed DAC table */
10171 /* Based on ALC880 version. But ALC861VD has separate,
10172 * different NIDs for mute/unmute switch and volume control */
10173 static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
10174 const struct auto_pin_cfg *cfg)
10177 static const char *chname[4] = {"Front", "Surround", "CLFE", "Side"};
10178 hda_nid_t nid_v, nid_s;
10181 for (i = 0; i < cfg->line_outs; i++) {
10182 if (!spec->multiout.dac_nids[i])
10184 nid_v = alc861vd_idx_to_mixer_vol(
10186 spec->multiout.dac_nids[i]));
10187 nid_s = alc861vd_idx_to_mixer_switch(
10189 spec->multiout.dac_nids[i]));
10193 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10194 "Center Playback Volume",
10195 HDA_COMPOSE_AMP_VAL(nid_v, 1, 0,
10199 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10200 "LFE Playback Volume",
10201 HDA_COMPOSE_AMP_VAL(nid_v, 2, 0,
10205 err = add_control(spec, ALC_CTL_BIND_MUTE,
10206 "Center Playback Switch",
10207 HDA_COMPOSE_AMP_VAL(nid_s, 1, 2,
10211 err = add_control(spec, ALC_CTL_BIND_MUTE,
10212 "LFE Playback Switch",
10213 HDA_COMPOSE_AMP_VAL(nid_s, 2, 2,
10218 sprintf(name, "%s Playback Volume", chname[i]);
10219 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
10220 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0,
10224 sprintf(name, "%s Playback Switch", chname[i]);
10225 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
10226 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2,
10235 /* add playback controls for speaker and HP outputs */
10236 /* Based on ALC880 version. But ALC861VD has separate,
10237 * different NIDs for mute/unmute switch and volume control */
10238 static int alc861vd_auto_create_extra_out(struct alc_spec *spec,
10239 hda_nid_t pin, const char *pfx)
10241 hda_nid_t nid_v, nid_s;
10248 if (alc880_is_fixed_pin(pin)) {
10249 nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
10250 /* specify the DAC as the extra output */
10251 if (!spec->multiout.hp_nid)
10252 spec->multiout.hp_nid = nid_v;
10254 spec->multiout.extra_out_nid[0] = nid_v;
10255 /* control HP volume/switch on the output mixer amp */
10256 nid_v = alc861vd_idx_to_mixer_vol(
10257 alc880_fixed_pin_idx(pin));
10258 nid_s = alc861vd_idx_to_mixer_switch(
10259 alc880_fixed_pin_idx(pin));
10261 sprintf(name, "%s Playback Volume", pfx);
10262 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
10263 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT));
10266 sprintf(name, "%s Playback Switch", pfx);
10267 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
10268 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT));
10271 } else if (alc880_is_multi_pin(pin)) {
10272 /* set manual connection */
10273 /* we have only a switch on HP-out PIN */
10274 sprintf(name, "%s Playback Switch", pfx);
10275 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
10276 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
10283 /* parse the BIOS configuration and set up the alc_spec
10284 * return 1 if successful, 0 if the proper config is not found,
10285 * or a negative error code
10286 * Based on ALC880 version - had to change it to override
10287 * alc880_auto_create_extra_out and alc880_auto_create_multi_out_ctls */
10288 static int alc861vd_parse_auto_config(struct hda_codec *codec)
10290 struct alc_spec *spec = codec->spec;
10292 static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
10294 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
10298 if (!spec->autocfg.line_outs)
10299 return 0; /* can't find valid BIOS pin config */
10301 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
10304 err = alc861vd_auto_create_multi_out_ctls(spec, &spec->autocfg);
10307 err = alc861vd_auto_create_extra_out(spec,
10308 spec->autocfg.speaker_pins[0],
10312 err = alc861vd_auto_create_extra_out(spec,
10313 spec->autocfg.hp_pins[0],
10317 err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
10321 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
10323 if (spec->autocfg.dig_out_pin)
10324 spec->multiout.dig_out_nid = ALC861VD_DIGOUT_NID;
10326 if (spec->kctl_alloc)
10327 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
10329 spec->init_verbs[spec->num_init_verbs++]
10330 = alc861vd_volume_init_verbs;
10332 spec->num_mux_defs = 1;
10333 spec->input_mux = &spec->private_imux;
10338 /* additional initialization for auto-configuration model */
10339 static void alc861vd_auto_init(struct hda_codec *codec)
10341 alc861vd_auto_init_multi_out(codec);
10342 alc861vd_auto_init_hp_out(codec);
10343 alc861vd_auto_init_analog_input(codec);
10346 static int patch_alc861vd(struct hda_codec *codec)
10348 struct alc_spec *spec;
10349 int err, board_config;
10351 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
10355 codec->spec = spec;
10357 board_config = snd_hda_check_board_config(codec, ALC861VD_MODEL_LAST,
10361 if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) {
10362 printk(KERN_INFO "hda_codec: Unknown model for ALC660VD/"
10363 "ALC861VD, trying auto-probe from BIOS...\n");
10364 board_config = ALC861VD_AUTO;
10367 if (board_config == ALC861VD_AUTO) {
10368 /* automatic parse from the BIOS config */
10369 err = alc861vd_parse_auto_config(codec);
10375 "hda_codec: Cannot set up configuration "
10376 "from BIOS. Using base mode...\n");
10377 board_config = ALC861VD_3ST;
10381 if (board_config != ALC861VD_AUTO)
10382 setup_preset(spec, &alc861vd_presets[board_config]);
10384 spec->stream_name_analog = "ALC861VD Analog";
10385 spec->stream_analog_playback = &alc861vd_pcm_analog_playback;
10386 spec->stream_analog_capture = &alc861vd_pcm_analog_capture;
10388 spec->stream_name_digital = "ALC861VD Digital";
10389 spec->stream_digital_playback = &alc861vd_pcm_digital_playback;
10390 spec->stream_digital_capture = &alc861vd_pcm_digital_capture;
10392 spec->adc_nids = alc861vd_adc_nids;
10393 spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids);
10395 spec->mixers[spec->num_mixers] = alc861vd_capture_mixer;
10396 spec->num_mixers++;
10398 codec->patch_ops = alc_patch_ops;
10400 if (board_config == ALC861VD_AUTO)
10401 spec->init_hook = alc861vd_auto_init;
10409 * ALC662 is almost identical with ALC880 but has cleaner and more flexible
10410 * configuration. Each pin widget can choose any input DACs and a mixer.
10411 * Each ADC is connected from a mixer of all inputs. This makes possible
10412 * 6-channel independent captures.
10414 * In addition, an independent DAC for the multi-playback (not used in this
10417 #define ALC662_DIGOUT_NID 0x06
10418 #define ALC662_DIGIN_NID 0x0a
10420 static hda_nid_t alc662_dac_nids[4] = {
10421 /* front, rear, clfe, rear_surr */
10425 static hda_nid_t alc662_adc_nids[1] = {
10430 /* FIXME: should be a matrix-type input source selection */
10432 static struct hda_input_mux alc662_capture_source = {
10436 { "Front Mic", 0x1 },
10442 static struct hda_input_mux alc662_lenovo_101e_capture_source = {
10449 #define alc662_mux_enum_info alc_mux_enum_info
10450 #define alc662_mux_enum_get alc_mux_enum_get
10452 static int alc662_mux_enum_put(struct snd_kcontrol *kcontrol,
10453 struct snd_ctl_elem_value *ucontrol)
10455 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10456 struct alc_spec *spec = codec->spec;
10457 const struct hda_input_mux *imux = spec->input_mux;
10458 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
10459 static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
10460 hda_nid_t nid = capture_mixers[adc_idx];
10461 unsigned int *cur_val = &spec->cur_mux[adc_idx];
10462 unsigned int i, idx;
10464 idx = ucontrol->value.enumerated.item[0];
10465 if (idx >= imux->num_items)
10466 idx = imux->num_items - 1;
10467 if (*cur_val == idx && !codec->in_resume)
10469 for (i = 0; i < imux->num_items; i++) {
10470 unsigned int v = (i == idx) ? 0x7000 : 0x7080;
10471 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
10472 v | (imux->items[i].index << 8));
10480 static struct hda_channel_mode alc662_3ST_2ch_modes[1] = {
10487 static struct hda_verb alc662_3ST_ch2_init[] = {
10488 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
10489 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
10490 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
10491 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
10498 static struct hda_verb alc662_3ST_ch6_init[] = {
10499 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10500 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10501 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
10502 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10503 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10504 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
10508 static struct hda_channel_mode alc662_3ST_6ch_modes[2] = {
10509 { 2, alc662_3ST_ch2_init },
10510 { 6, alc662_3ST_ch6_init },
10516 static struct hda_verb alc662_sixstack_ch6_init[] = {
10517 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
10518 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
10519 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10526 static struct hda_verb alc662_sixstack_ch8_init[] = {
10527 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10528 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10529 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10533 static struct hda_channel_mode alc662_5stack_modes[2] = {
10534 { 2, alc662_sixstack_ch6_init },
10535 { 6, alc662_sixstack_ch8_init },
10538 /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
10539 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
10542 static struct snd_kcontrol_new alc662_base_mixer[] = {
10543 /* output mixer control */
10544 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
10545 HDA_CODEC_MUTE("Front Playback Switch", 0x02, 0x0, HDA_OUTPUT),
10546 HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT),
10547 HDA_CODEC_MUTE("Surround Playback Switch", 0x03, 0x0, HDA_OUTPUT),
10548 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
10549 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
10550 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT),
10551 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT),
10552 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
10554 /*Input mixer control */
10555 HDA_CODEC_VOLUME("CD Playback Volume", 0xb, 0x4, HDA_INPUT),
10556 HDA_CODEC_MUTE("CD Playback Switch", 0xb, 0x4, HDA_INPUT),
10557 HDA_CODEC_VOLUME("Line Playback Volume", 0xb, 0x02, HDA_INPUT),
10558 HDA_CODEC_MUTE("Line Playback Switch", 0xb, 0x02, HDA_INPUT),
10559 HDA_CODEC_VOLUME("Mic Playback Volume", 0xb, 0x0, HDA_INPUT),
10560 HDA_CODEC_MUTE("Mic Playback Switch", 0xb, 0x0, HDA_INPUT),
10561 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0xb, 0x01, HDA_INPUT),
10562 HDA_CODEC_MUTE("Front Mic Playback Switch", 0xb, 0x01, HDA_INPUT),
10564 /* Capture mixer control */
10565 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
10566 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
10568 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10569 .name = "Capture Source",
10571 .info = alc_mux_enum_info,
10572 .get = alc_mux_enum_get,
10573 .put = alc_mux_enum_put,
10578 static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = {
10579 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
10580 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
10581 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
10582 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10583 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10584 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10585 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10586 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10587 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10588 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
10589 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
10590 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
10591 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
10592 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
10593 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
10595 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10596 /* .name = "Capture Source", */
10597 .name = "Input Source",
10599 .info = alc662_mux_enum_info,
10600 .get = alc662_mux_enum_get,
10601 .put = alc662_mux_enum_put,
10606 static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = {
10607 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
10608 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
10609 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
10610 HDA_BIND_MUTE("Surround Playback Switch", 0x03, 2, HDA_INPUT),
10611 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
10612 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
10613 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT),
10614 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT),
10615 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
10616 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10617 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10618 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10619 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10620 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10621 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10622 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
10623 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
10624 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
10625 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
10626 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
10627 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
10629 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10630 /* .name = "Capture Source", */
10631 .name = "Input Source",
10633 .info = alc662_mux_enum_info,
10634 .get = alc662_mux_enum_get,
10635 .put = alc662_mux_enum_put,
10640 static struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = {
10641 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
10642 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
10643 HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x03, 0x0, HDA_OUTPUT),
10644 HDA_BIND_MUTE("iSpeaker Playback Switch", 0x03, 2, HDA_INPUT),
10645 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
10646 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10647 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10648 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
10649 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
10650 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
10651 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
10653 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10654 /* .name = "Capture Source", */
10655 .name = "Input Source",
10657 .info = alc662_mux_enum_info,
10658 .get = alc662_mux_enum_get,
10659 .put = alc662_mux_enum_put,
10664 static struct snd_kcontrol_new alc662_chmode_mixer[] = {
10666 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10667 .name = "Channel Mode",
10668 .info = alc_ch_mode_info,
10669 .get = alc_ch_mode_get,
10670 .put = alc_ch_mode_put,
10675 static struct hda_verb alc662_init_verbs[] = {
10676 /* ADC: mute amp left and right */
10677 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10678 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
10679 /* Front mixer: unmute input/output amp left and right (volume = 0) */
10681 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10682 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10683 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
10684 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
10685 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
10687 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10688 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10689 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10690 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10691 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10692 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10694 /* Front Pin: output 0 (0x0c) */
10695 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10696 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10698 /* Rear Pin: output 1 (0x0d) */
10699 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10700 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10702 /* CLFE Pin: output 2 (0x0e) */
10703 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10704 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10706 /* Mic (rear) pin: input vref at 80% */
10707 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
10708 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10709 /* Front Mic pin: input vref at 80% */
10710 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
10711 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10712 /* Line In pin: input */
10713 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10714 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10715 /* Line-2 In: Headphone output (output 0 - 0x0c) */
10716 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10717 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10718 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
10719 /* CD pin widget for input */
10720 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10722 /* FIXME: use matrix-type input source selection */
10723 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
10725 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10726 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10727 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
10728 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
10732 static struct hda_verb alc662_sue_init_verbs[] = {
10733 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
10734 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
10739 * generic initialization of ADC, input mixers and output mixers
10741 static struct hda_verb alc662_auto_init_verbs[] = {
10743 * Unmute ADC and set the default input to mic-in
10745 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
10746 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10748 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
10750 * Note: PASD motherboards uses the Line In 2 as the input for front
10751 * panel mic (mic 2)
10753 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
10754 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10755 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10756 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
10757 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
10758 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
10761 * Set up output mixers (0x0c - 0x0f)
10763 /* set vol=0 to output mixers */
10764 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10765 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10766 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10768 /* set up input amps for analog loopback */
10769 /* Amp Indices: DAC = 0, mixer = 1 */
10770 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10771 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10772 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10773 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10774 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10775 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10778 /* FIXME: use matrix-type input source selection */
10779 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
10781 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10782 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10783 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
10784 /*{0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},*/
10785 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
10790 /* capture mixer elements */
10791 static struct snd_kcontrol_new alc662_capture_mixer[] = {
10792 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
10793 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
10795 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10796 /* The multiple "Capture Source" controls confuse alsamixer
10797 * So call somewhat different..
10798 * FIXME: the controls appear in the "playback" view!
10800 /* .name = "Capture Source", */
10801 .name = "Input Source",
10803 .info = alc882_mux_enum_info,
10804 .get = alc882_mux_enum_get,
10805 .put = alc882_mux_enum_put,
10810 static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
10812 unsigned int present;
10813 unsigned char bits;
10815 present = snd_hda_codec_read(codec, 0x14, 0,
10816 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
10817 bits = present ? 0x80 : 0;
10818 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
10820 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
10824 static void alc662_lenovo_101e_all_automute(struct hda_codec *codec)
10826 unsigned int present;
10827 unsigned char bits;
10829 present = snd_hda_codec_read(codec, 0x1b, 0,
10830 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
10831 bits = present ? 0x80 : 0;
10832 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
10834 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
10836 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
10838 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
10842 static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec,
10845 if ((res >> 26) == ALC880_HP_EVENT)
10846 alc662_lenovo_101e_all_automute(codec);
10847 if ((res >> 26) == ALC880_FRONT_EVENT)
10848 alc662_lenovo_101e_ispeaker_automute(codec);
10852 /* pcm configuration: identiacal with ALC880 */
10853 #define alc662_pcm_analog_playback alc880_pcm_analog_playback
10854 #define alc662_pcm_analog_capture alc880_pcm_analog_capture
10855 #define alc662_pcm_digital_playback alc880_pcm_digital_playback
10856 #define alc662_pcm_digital_capture alc880_pcm_digital_capture
10859 * configuration and preset
10861 static const char *alc662_models[ALC662_MODEL_LAST] = {
10862 [ALC662_3ST_2ch_DIG] = "3stack-dig",
10863 [ALC662_3ST_6ch_DIG] = "3stack-6ch-dig",
10864 [ALC662_3ST_6ch] = "3stack-6ch",
10865 [ALC662_5ST_DIG] = "6stack-dig",
10866 [ALC662_LENOVO_101E] = "lenovo-101e",
10867 [ALC662_AUTO] = "auto",
10870 static struct snd_pci_quirk alc662_cfg_tbl[] = {
10871 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E),
10875 static struct alc_config_preset alc662_presets[] = {
10876 [ALC662_3ST_2ch_DIG] = {
10877 .mixers = { alc662_3ST_2ch_mixer },
10878 .init_verbs = { alc662_init_verbs },
10879 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
10880 .dac_nids = alc662_dac_nids,
10881 .dig_out_nid = ALC662_DIGOUT_NID,
10882 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
10883 .adc_nids = alc662_adc_nids,
10884 .dig_in_nid = ALC662_DIGIN_NID,
10885 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
10886 .channel_mode = alc662_3ST_2ch_modes,
10887 .input_mux = &alc662_capture_source,
10889 [ALC662_3ST_6ch_DIG] = {
10890 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
10891 .init_verbs = { alc662_init_verbs },
10892 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
10893 .dac_nids = alc662_dac_nids,
10894 .dig_out_nid = ALC662_DIGOUT_NID,
10895 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
10896 .adc_nids = alc662_adc_nids,
10897 .dig_in_nid = ALC662_DIGIN_NID,
10898 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
10899 .channel_mode = alc662_3ST_6ch_modes,
10901 .input_mux = &alc662_capture_source,
10903 [ALC662_3ST_6ch] = {
10904 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
10905 .init_verbs = { alc662_init_verbs },
10906 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
10907 .dac_nids = alc662_dac_nids,
10908 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
10909 .adc_nids = alc662_adc_nids,
10910 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
10911 .channel_mode = alc662_3ST_6ch_modes,
10913 .input_mux = &alc662_capture_source,
10915 [ALC662_5ST_DIG] = {
10916 .mixers = { alc662_base_mixer, alc662_chmode_mixer },
10917 .init_verbs = { alc662_init_verbs },
10918 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
10919 .dac_nids = alc662_dac_nids,
10920 .dig_out_nid = ALC662_DIGOUT_NID,
10921 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
10922 .adc_nids = alc662_adc_nids,
10923 .dig_in_nid = ALC662_DIGIN_NID,
10924 .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes),
10925 .channel_mode = alc662_5stack_modes,
10926 .input_mux = &alc662_capture_source,
10928 [ALC662_LENOVO_101E] = {
10929 .mixers = { alc662_lenovo_101e_mixer },
10930 .init_verbs = { alc662_init_verbs, alc662_sue_init_verbs },
10931 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
10932 .dac_nids = alc662_dac_nids,
10933 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
10934 .adc_nids = alc662_adc_nids,
10935 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
10936 .channel_mode = alc662_3ST_2ch_modes,
10937 .input_mux = &alc662_lenovo_101e_capture_source,
10938 .unsol_event = alc662_lenovo_101e_unsol_event,
10939 .init_hook = alc662_lenovo_101e_all_automute,
10946 * BIOS auto configuration
10949 /* add playback controls from the parsed DAC table */
10950 static int alc662_auto_create_multi_out_ctls(struct alc_spec *spec,
10951 const struct auto_pin_cfg *cfg)
10954 static const char *chname[4] = {
10955 "Front", "Surround", NULL /*CLFE*/, "Side"
10960 for (i = 0; i < cfg->line_outs; i++) {
10961 if (!spec->multiout.dac_nids[i])
10963 nid = alc880_idx_to_dac(i);
10966 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10967 "Center Playback Volume",
10968 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
10972 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10973 "LFE Playback Volume",
10974 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
10978 err = add_control(spec, ALC_CTL_BIND_MUTE,
10979 "Center Playback Switch",
10980 HDA_COMPOSE_AMP_VAL(nid, 1, 2,
10984 err = add_control(spec, ALC_CTL_BIND_MUTE,
10985 "LFE Playback Switch",
10986 HDA_COMPOSE_AMP_VAL(nid, 2, 2,
10991 sprintf(name, "%s Playback Volume", chname[i]);
10992 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
10993 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
10997 sprintf(name, "%s Playback Switch", chname[i]);
10998 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
10999 HDA_COMPOSE_AMP_VAL(nid, 3, 2,
11008 /* add playback controls for speaker and HP outputs */
11009 static int alc662_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
11019 if (alc880_is_fixed_pin(pin)) {
11020 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
11021 /* printk("DAC nid=%x\n",nid); */
11022 /* specify the DAC as the extra output */
11023 if (!spec->multiout.hp_nid)
11024 spec->multiout.hp_nid = nid;
11026 spec->multiout.extra_out_nid[0] = nid;
11027 /* control HP volume/switch on the output mixer amp */
11028 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
11029 sprintf(name, "%s Playback Volume", pfx);
11030 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
11031 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
11034 sprintf(name, "%s Playback Switch", pfx);
11035 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
11036 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
11039 } else if (alc880_is_multi_pin(pin)) {
11040 /* set manual connection */
11041 /* we have only a switch on HP-out PIN */
11042 sprintf(name, "%s Playback Switch", pfx);
11043 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
11044 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
11051 /* create playback/capture controls for input pins */
11052 static int alc662_auto_create_analog_input_ctls(struct alc_spec *spec,
11053 const struct auto_pin_cfg *cfg)
11055 struct hda_input_mux *imux = &spec->private_imux;
11058 for (i = 0; i < AUTO_PIN_LAST; i++) {
11059 if (alc880_is_input_pin(cfg->input_pins[i])) {
11060 idx = alc880_input_pin_idx(cfg->input_pins[i]);
11061 err = new_analog_input(spec, cfg->input_pins[i],
11062 auto_pin_cfg_labels[i],
11066 imux->items[imux->num_items].label =
11067 auto_pin_cfg_labels[i];
11068 imux->items[imux->num_items].index =
11069 alc880_input_pin_idx(cfg->input_pins[i]);
11076 static void alc662_auto_set_output_and_unmute(struct hda_codec *codec,
11077 hda_nid_t nid, int pin_type,
11080 /* set as output */
11081 snd_hda_codec_write(codec, nid, 0,
11082 AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
11083 snd_hda_codec_write(codec, nid, 0,
11084 AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
11085 /* need the manual connection? */
11086 if (alc880_is_multi_pin(nid)) {
11087 struct alc_spec *spec = codec->spec;
11088 int idx = alc880_multi_pin_idx(nid);
11089 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
11090 AC_VERB_SET_CONNECT_SEL,
11091 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
11095 static void alc662_auto_init_multi_out(struct hda_codec *codec)
11097 struct alc_spec *spec = codec->spec;
11100 for (i = 0; i <= HDA_SIDE; i++) {
11101 hda_nid_t nid = spec->autocfg.line_out_pins[i];
11102 int pin_type = get_pin_type(spec->autocfg.line_out_type);
11104 alc662_auto_set_output_and_unmute(codec, nid, pin_type,
11109 static void alc662_auto_init_hp_out(struct hda_codec *codec)
11111 struct alc_spec *spec = codec->spec;
11114 pin = spec->autocfg.hp_pins[0];
11115 if (pin) /* connect to front */
11117 alc662_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
11120 #define alc662_is_input_pin(nid) alc880_is_input_pin(nid)
11121 #define ALC662_PIN_CD_NID ALC880_PIN_CD_NID
11123 static void alc662_auto_init_analog_input(struct hda_codec *codec)
11125 struct alc_spec *spec = codec->spec;
11128 for (i = 0; i < AUTO_PIN_LAST; i++) {
11129 hda_nid_t nid = spec->autocfg.input_pins[i];
11130 if (alc662_is_input_pin(nid)) {
11131 snd_hda_codec_write(codec, nid, 0,
11132 AC_VERB_SET_PIN_WIDGET_CONTROL,
11133 (i <= AUTO_PIN_FRONT_MIC ?
11134 PIN_VREF80 : PIN_IN));
11135 if (nid != ALC662_PIN_CD_NID)
11136 snd_hda_codec_write(codec, nid, 0,
11137 AC_VERB_SET_AMP_GAIN_MUTE,
11143 static int alc662_parse_auto_config(struct hda_codec *codec)
11145 struct alc_spec *spec = codec->spec;
11147 static hda_nid_t alc662_ignore[] = { 0x1d, 0 };
11149 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
11153 if (!spec->autocfg.line_outs)
11154 return 0; /* can't find valid BIOS pin config */
11156 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
11159 err = alc662_auto_create_multi_out_ctls(spec, &spec->autocfg);
11162 err = alc662_auto_create_extra_out(spec,
11163 spec->autocfg.speaker_pins[0],
11167 err = alc662_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
11171 err = alc662_auto_create_analog_input_ctls(spec, &spec->autocfg);
11175 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
11177 if (spec->autocfg.dig_out_pin)
11178 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
11180 if (spec->kctl_alloc)
11181 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
11183 spec->num_mux_defs = 1;
11184 spec->input_mux = &spec->private_imux;
11186 spec->init_verbs[spec->num_init_verbs++] = alc662_auto_init_verbs;
11187 spec->mixers[spec->num_mixers] = alc662_capture_mixer;
11188 spec->num_mixers++;
11192 /* additional initialization for auto-configuration model */
11193 static void alc662_auto_init(struct hda_codec *codec)
11195 alc662_auto_init_multi_out(codec);
11196 alc662_auto_init_hp_out(codec);
11197 alc662_auto_init_analog_input(codec);
11200 static int patch_alc662(struct hda_codec *codec)
11202 struct alc_spec *spec;
11203 int err, board_config;
11205 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
11209 codec->spec = spec;
11211 board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST,
11214 if (board_config < 0) {
11215 printk(KERN_INFO "hda_codec: Unknown model for ALC662, "
11216 "trying auto-probe from BIOS...\n");
11217 board_config = ALC662_AUTO;
11220 if (board_config == ALC662_AUTO) {
11221 /* automatic parse from the BIOS config */
11222 err = alc662_parse_auto_config(codec);
11228 "hda_codec: Cannot set up configuration "
11229 "from BIOS. Using base mode...\n");
11230 board_config = ALC662_3ST_2ch_DIG;
11234 if (board_config != ALC662_AUTO)
11235 setup_preset(spec, &alc662_presets[board_config]);
11237 spec->stream_name_analog = "ALC662 Analog";
11238 spec->stream_analog_playback = &alc662_pcm_analog_playback;
11239 spec->stream_analog_capture = &alc662_pcm_analog_capture;
11241 spec->stream_name_digital = "ALC662 Digital";
11242 spec->stream_digital_playback = &alc662_pcm_digital_playback;
11243 spec->stream_digital_capture = &alc662_pcm_digital_capture;
11245 if (!spec->adc_nids && spec->input_mux) {
11246 spec->adc_nids = alc662_adc_nids;
11247 spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids);
11250 codec->patch_ops = alc_patch_ops;
11251 if (board_config == ALC662_AUTO)
11252 spec->init_hook = alc662_auto_init;
11260 struct hda_codec_preset snd_hda_preset_realtek[] = {
11261 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
11262 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
11263 { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 },
11264 { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
11265 .patch = patch_alc861 },
11266 { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
11267 { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
11268 { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
11269 { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2",
11270 .patch = patch_alc883 },
11271 { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
11272 .patch = patch_alc662 },
11273 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
11274 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
11275 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc883 },
11276 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
11277 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc883 },
11278 {} /* terminator */