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 #define alc880_lg_lw_modes alc880_threestack_modes
1905 static struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
1906 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1907 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1908 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
1909 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
1910 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1911 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1912 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1913 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1914 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1915 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1916 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1917 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1918 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
1919 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
1921 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1922 .name = "Channel Mode",
1923 .info = alc_ch_mode_info,
1924 .get = alc_ch_mode_get,
1925 .put = alc_ch_mode_put,
1930 static struct hda_verb alc880_lg_lw_init_verbs[] = {
1931 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1932 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
1933 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
1935 /* set capture source to mic-in */
1936 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1937 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1938 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1939 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(7)},
1941 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1942 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1944 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1945 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1946 /* mic-in to input */
1947 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1948 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1950 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1951 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1953 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
1957 /* toggle speaker-output according to the hp-jack state */
1958 static void alc880_lg_lw_automute(struct hda_codec *codec)
1960 unsigned int present;
1963 present = snd_hda_codec_read(codec, 0x1b, 0,
1964 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1965 bits = present ? 0x80 : 0;
1966 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
1968 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
1972 static void alc880_lg_lw_unsol_event(struct hda_codec *codec, unsigned int res)
1974 /* Looks like the unsol event is incompatible with the standard
1975 * definition. 4bit tag is placed at 28 bit!
1977 if ((res >> 28) == 0x01)
1978 alc880_lg_lw_automute(codec);
1985 static int alc_init(struct hda_codec *codec)
1987 struct alc_spec *spec = codec->spec;
1990 for (i = 0; i < spec->num_init_verbs; i++)
1991 snd_hda_sequence_write(codec, spec->init_verbs[i]);
1993 if (spec->init_hook)
1994 spec->init_hook(codec);
1999 static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
2001 struct alc_spec *spec = codec->spec;
2003 if (spec->unsol_event)
2004 spec->unsol_event(codec, res);
2011 static int alc_resume(struct hda_codec *codec)
2013 struct alc_spec *spec = codec->spec;
2017 for (i = 0; i < spec->num_mixers; i++)
2018 snd_hda_resume_ctls(codec, spec->mixers[i]);
2019 if (spec->multiout.dig_out_nid)
2020 snd_hda_resume_spdif_out(codec);
2021 if (spec->dig_in_nid)
2022 snd_hda_resume_spdif_in(codec);
2029 * Analog playback callbacks
2031 static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
2032 struct hda_codec *codec,
2033 struct snd_pcm_substream *substream)
2035 struct alc_spec *spec = codec->spec;
2036 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream);
2039 static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2040 struct hda_codec *codec,
2041 unsigned int stream_tag,
2042 unsigned int format,
2043 struct snd_pcm_substream *substream)
2045 struct alc_spec *spec = codec->spec;
2046 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
2047 stream_tag, format, substream);
2050 static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
2051 struct hda_codec *codec,
2052 struct snd_pcm_substream *substream)
2054 struct alc_spec *spec = codec->spec;
2055 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
2061 static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
2062 struct hda_codec *codec,
2063 struct snd_pcm_substream *substream)
2065 struct alc_spec *spec = codec->spec;
2066 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
2069 static int alc880_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2070 struct hda_codec *codec,
2071 unsigned int stream_tag,
2072 unsigned int format,
2073 struct snd_pcm_substream *substream)
2075 struct alc_spec *spec = codec->spec;
2076 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
2077 stream_tag, format, substream);
2080 static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
2081 struct hda_codec *codec,
2082 struct snd_pcm_substream *substream)
2084 struct alc_spec *spec = codec->spec;
2085 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
2091 static int alc880_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
2092 struct hda_codec *codec,
2093 unsigned int stream_tag,
2094 unsigned int format,
2095 struct snd_pcm_substream *substream)
2097 struct alc_spec *spec = codec->spec;
2099 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
2100 stream_tag, 0, format);
2104 static int alc880_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
2105 struct hda_codec *codec,
2106 struct snd_pcm_substream *substream)
2108 struct alc_spec *spec = codec->spec;
2110 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
2118 static struct hda_pcm_stream alc880_pcm_analog_playback = {
2122 /* NID is set in alc_build_pcms */
2124 .open = alc880_playback_pcm_open,
2125 .prepare = alc880_playback_pcm_prepare,
2126 .cleanup = alc880_playback_pcm_cleanup
2130 static struct hda_pcm_stream alc880_pcm_analog_capture = {
2134 /* NID is set in alc_build_pcms */
2136 .prepare = alc880_capture_pcm_prepare,
2137 .cleanup = alc880_capture_pcm_cleanup
2141 static struct hda_pcm_stream alc880_pcm_digital_playback = {
2145 /* NID is set in alc_build_pcms */
2147 .open = alc880_dig_playback_pcm_open,
2148 .close = alc880_dig_playback_pcm_close,
2149 .prepare = alc880_dig_playback_pcm_prepare
2153 static struct hda_pcm_stream alc880_pcm_digital_capture = {
2157 /* NID is set in alc_build_pcms */
2160 /* Used by alc_build_pcms to flag that a PCM has no playback stream */
2161 static struct hda_pcm_stream alc_pcm_null_playback = {
2167 static int alc_build_pcms(struct hda_codec *codec)
2169 struct alc_spec *spec = codec->spec;
2170 struct hda_pcm *info = spec->pcm_rec;
2173 codec->num_pcms = 1;
2174 codec->pcm_info = info;
2176 info->name = spec->stream_name_analog;
2177 if (spec->stream_analog_playback) {
2178 snd_assert(spec->multiout.dac_nids, return -EINVAL);
2179 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
2180 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
2182 if (spec->stream_analog_capture) {
2183 snd_assert(spec->adc_nids, return -EINVAL);
2184 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
2185 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
2188 if (spec->channel_mode) {
2189 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
2190 for (i = 0; i < spec->num_channel_mode; i++) {
2191 if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
2192 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
2197 /* SPDIF for stream index #1 */
2198 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
2199 codec->num_pcms = 2;
2200 info = spec->pcm_rec + 1;
2201 info->name = spec->stream_name_digital;
2202 if (spec->multiout.dig_out_nid &&
2203 spec->stream_digital_playback) {
2204 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
2205 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
2207 if (spec->dig_in_nid &&
2208 spec->stream_digital_capture) {
2209 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
2210 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
2214 /* If the use of more than one ADC is requested for the current
2215 * model, configure a second analog capture-only PCM.
2217 /* Additional Analaog capture for index #2 */
2218 if (spec->num_adc_nids > 1 && spec->stream_analog_capture &&
2220 codec->num_pcms = 3;
2221 info = spec->pcm_rec + 2;
2222 info->name = spec->stream_name_analog;
2223 /* No playback stream for second PCM */
2224 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = alc_pcm_null_playback;
2225 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
2226 if (spec->stream_analog_capture) {
2227 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
2228 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[1];
2235 static void alc_free(struct hda_codec *codec)
2237 struct alc_spec *spec = codec->spec;
2243 if (spec->kctl_alloc) {
2244 for (i = 0; i < spec->num_kctl_used; i++)
2245 kfree(spec->kctl_alloc[i].name);
2246 kfree(spec->kctl_alloc);
2253 static struct hda_codec_ops alc_patch_ops = {
2254 .build_controls = alc_build_controls,
2255 .build_pcms = alc_build_pcms,
2258 .unsol_event = alc_unsol_event,
2260 .resume = alc_resume,
2266 * Test configuration for debugging
2268 * Almost all inputs/outputs are enabled. I/O pins can be configured via
2271 #ifdef CONFIG_SND_DEBUG
2272 static hda_nid_t alc880_test_dac_nids[4] = {
2273 0x02, 0x03, 0x04, 0x05
2276 static struct hda_input_mux alc880_test_capture_source = {
2285 { "Surround", 0x6 },
2289 static struct hda_channel_mode alc880_test_modes[4] = {
2296 static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol,
2297 struct snd_ctl_elem_info *uinfo)
2299 static char *texts[] = {
2300 "N/A", "Line Out", "HP Out",
2301 "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
2303 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
2305 uinfo->value.enumerated.items = 8;
2306 if (uinfo->value.enumerated.item >= 8)
2307 uinfo->value.enumerated.item = 7;
2308 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
2312 static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol,
2313 struct snd_ctl_elem_value *ucontrol)
2315 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2316 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2317 unsigned int pin_ctl, item = 0;
2319 pin_ctl = snd_hda_codec_read(codec, nid, 0,
2320 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
2321 if (pin_ctl & AC_PINCTL_OUT_EN) {
2322 if (pin_ctl & AC_PINCTL_HP_EN)
2326 } else if (pin_ctl & AC_PINCTL_IN_EN) {
2327 switch (pin_ctl & AC_PINCTL_VREFEN) {
2328 case AC_PINCTL_VREF_HIZ: item = 3; break;
2329 case AC_PINCTL_VREF_50: item = 4; break;
2330 case AC_PINCTL_VREF_GRD: item = 5; break;
2331 case AC_PINCTL_VREF_80: item = 6; break;
2332 case AC_PINCTL_VREF_100: item = 7; break;
2335 ucontrol->value.enumerated.item[0] = item;
2339 static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol,
2340 struct snd_ctl_elem_value *ucontrol)
2342 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2343 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2344 static unsigned int ctls[] = {
2345 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
2346 AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
2347 AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
2348 AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
2349 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
2350 AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
2352 unsigned int old_ctl, new_ctl;
2354 old_ctl = snd_hda_codec_read(codec, nid, 0,
2355 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
2356 new_ctl = ctls[ucontrol->value.enumerated.item[0]];
2357 if (old_ctl != new_ctl) {
2358 snd_hda_codec_write(codec, nid, 0,
2359 AC_VERB_SET_PIN_WIDGET_CONTROL, new_ctl);
2360 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
2361 (ucontrol->value.enumerated.item[0] >= 3 ?
2368 static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol,
2369 struct snd_ctl_elem_info *uinfo)
2371 static char *texts[] = {
2372 "Front", "Surround", "CLFE", "Side"
2374 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
2376 uinfo->value.enumerated.items = 4;
2377 if (uinfo->value.enumerated.item >= 4)
2378 uinfo->value.enumerated.item = 3;
2379 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
2383 static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol,
2384 struct snd_ctl_elem_value *ucontrol)
2386 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2387 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2390 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
2391 ucontrol->value.enumerated.item[0] = sel & 3;
2395 static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol,
2396 struct snd_ctl_elem_value *ucontrol)
2398 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2399 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2402 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
2403 if (ucontrol->value.enumerated.item[0] != sel) {
2404 sel = ucontrol->value.enumerated.item[0] & 3;
2405 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, sel);
2411 #define PIN_CTL_TEST(xname,nid) { \
2412 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2414 .info = alc_test_pin_ctl_info, \
2415 .get = alc_test_pin_ctl_get, \
2416 .put = alc_test_pin_ctl_put, \
2417 .private_value = nid \
2420 #define PIN_SRC_TEST(xname,nid) { \
2421 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2423 .info = alc_test_pin_src_info, \
2424 .get = alc_test_pin_src_get, \
2425 .put = alc_test_pin_src_put, \
2426 .private_value = nid \
2429 static struct snd_kcontrol_new alc880_test_mixer[] = {
2430 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2431 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2432 HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
2433 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
2434 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2435 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
2436 HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
2437 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
2438 PIN_CTL_TEST("Front Pin Mode", 0x14),
2439 PIN_CTL_TEST("Surround Pin Mode", 0x15),
2440 PIN_CTL_TEST("CLFE Pin Mode", 0x16),
2441 PIN_CTL_TEST("Side Pin Mode", 0x17),
2442 PIN_CTL_TEST("In-1 Pin Mode", 0x18),
2443 PIN_CTL_TEST("In-2 Pin Mode", 0x19),
2444 PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
2445 PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
2446 PIN_SRC_TEST("In-1 Pin Source", 0x18),
2447 PIN_SRC_TEST("In-2 Pin Source", 0x19),
2448 PIN_SRC_TEST("In-3 Pin Source", 0x1a),
2449 PIN_SRC_TEST("In-4 Pin Source", 0x1b),
2450 HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
2451 HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
2452 HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
2453 HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
2454 HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
2455 HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
2456 HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
2457 HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
2458 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
2459 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
2461 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2462 .name = "Channel Mode",
2463 .info = alc_ch_mode_info,
2464 .get = alc_ch_mode_get,
2465 .put = alc_ch_mode_put,
2470 static struct hda_verb alc880_test_init_verbs[] = {
2471 /* Unmute inputs of 0x0c - 0x0f */
2472 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2473 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2474 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2475 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2476 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2477 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2478 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2479 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2480 /* Vol output for 0x0c-0x0f */
2481 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2482 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2483 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2484 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2485 /* Set output pins 0x14-0x17 */
2486 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2487 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2488 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2489 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2490 /* Unmute output pins 0x14-0x17 */
2491 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2492 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2493 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2494 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2495 /* Set input pins 0x18-0x1c */
2496 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2497 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2498 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2499 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2500 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2501 /* Mute input pins 0x18-0x1b */
2502 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2503 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2504 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2505 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2507 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2508 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
2509 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2510 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
2511 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2512 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
2513 /* Analog input/passthru */
2514 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2515 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2516 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
2517 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
2518 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
2526 static const char *alc880_models[ALC880_MODEL_LAST] = {
2527 [ALC880_3ST] = "3stack",
2528 [ALC880_TCL_S700] = "tcl",
2529 [ALC880_3ST_DIG] = "3stack-digout",
2530 [ALC880_CLEVO] = "clevo",
2531 [ALC880_5ST] = "5stack",
2532 [ALC880_5ST_DIG] = "5stack-digout",
2533 [ALC880_W810] = "w810",
2534 [ALC880_Z71V] = "z71v",
2535 [ALC880_6ST] = "6stack",
2536 [ALC880_6ST_DIG] = "6stack-digout",
2537 [ALC880_ASUS] = "asus",
2538 [ALC880_ASUS_W1V] = "asus-w1v",
2539 [ALC880_ASUS_DIG] = "asus-dig",
2540 [ALC880_ASUS_DIG2] = "asus-dig2",
2541 [ALC880_UNIWILL_DIG] = "uniwill",
2542 [ALC880_UNIWILL_P53] = "uniwill-p53",
2543 [ALC880_FUJITSU] = "fujitsu",
2544 [ALC880_F1734] = "F1734",
2546 [ALC880_LG_LW] = "lg-lw",
2547 #ifdef CONFIG_SND_DEBUG
2548 [ALC880_TEST] = "test",
2550 [ALC880_AUTO] = "auto",
2553 static struct snd_pci_quirk alc880_cfg_tbl[] = {
2554 /* Broken BIOS configuration */
2555 SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_6ST_DIG),
2556 SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_6ST_DIG),
2558 SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_5ST_DIG),
2559 SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_6ST),
2560 SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_W810),
2561 SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_3ST_DIG),
2562 SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_6ST_DIG),
2563 SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_6ST_DIG),
2564 SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_6ST_DIG),
2565 SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_3ST_DIG),
2566 SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_3ST),
2568 SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_6ST_DIG),
2569 SND_PCI_QUIRK(0x103c, 0x2a09, "HP", ALC880_5ST),
2571 SND_PCI_QUIRK(0x1043, 0x10b3, "ASUS W1V", ALC880_ASUS_W1V),
2572 SND_PCI_QUIRK(0x1043, 0x10c2, "ASUS W6A", ALC880_ASUS_DIG),
2573 SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS Wxx", ALC880_ASUS_DIG),
2574 SND_PCI_QUIRK(0x1043, 0x1113, "ASUS", ALC880_ASUS_DIG),
2575 SND_PCI_QUIRK(0x1043, 0x1123, "ASUS", ALC880_ASUS_DIG),
2576 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS", ALC880_ASUS_DIG),
2577 SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_Z71V),
2578 /* SND_PCI_QUIRK(0x1043, 0x1964, "ASUS", ALC880_ASUS_DIG), */
2579 SND_PCI_QUIRK(0x1043, 0x1973, "ASUS", ALC880_ASUS_DIG),
2580 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS", ALC880_ASUS_DIG),
2581 SND_PCI_QUIRK(0x1043, 0x814e, "ASUS", ALC880_ASUS),
2582 SND_PCI_QUIRK(0x1043, 0x8181, "ASUS P4GPL", ALC880_ASUS_DIG),
2583 SND_PCI_QUIRK(0x1043, 0x8196, "ASUS P5GD1", ALC880_6ST),
2584 SND_PCI_QUIRK(0x1043, 0x81b4, "ASUS", ALC880_6ST),
2585 SND_PCI_QUIRK(0x1043, 0, "ASUS", ALC880_ASUS),
2587 SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_3ST),
2588 SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_3ST),
2589 SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_5ST),
2590 SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_5ST),
2591 SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_5ST),
2592 SND_PCI_QUIRK(0x1558, 0x0520, "Clevo m520G", ALC880_CLEVO),
2593 SND_PCI_QUIRK(0x1558, 0x0660, "Clevo m655n", ALC880_CLEVO),
2594 SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_5ST_DIG),
2595 SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_W810),
2596 SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_5ST_DIG),
2597 SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_TCL_S700),
2598 SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_5ST_DIG),
2599 SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_6ST_DIG),
2600 SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_6ST_DIG),
2601 SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_6ST_DIG),
2602 SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_6ST_DIG),
2603 SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_6ST_DIG),
2604 SND_PCI_QUIRK(0x1558, 0x5401, "ASUS", ALC880_ASUS_DIG2),
2606 SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_UNIWILL_DIG),
2607 SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_UNIWILL),
2608 SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_UNIWILL_P53),
2609 SND_PCI_QUIRK(0x1584, 0x9054, "Uniwlll", ALC880_F1734),
2611 SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_5ST_DIG),
2612 SND_PCI_QUIRK(0x1734, 0x10ac, "FSC", ALC880_UNIWILL),
2613 SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_F1734),
2614 SND_PCI_QUIRK(0x1734, 0x10b0, "Fujitsu", ALC880_FUJITSU),
2616 SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_LG),
2617 SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_LG),
2618 SND_PCI_QUIRK(0x1854, 0x0018, "LG LW20", ALC880_LG_LW),
2619 SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_LG_LW),
2621 SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_3ST_DIG),
2622 SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_3ST_DIG),
2623 SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_3ST_DIG),
2624 SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_5ST_DIG),
2625 SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_5ST_DIG),
2626 SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_5ST_DIG),
2627 SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_5ST_DIG),
2628 SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_5ST_DIG),
2629 SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_5ST_DIG),
2630 SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_5ST_DIG),
2631 SND_PCI_QUIRK(0x8086, 0, "Intel mobo", ALC880_3ST),
2637 * ALC880 codec presets
2639 static struct alc_config_preset alc880_presets[] = {
2641 .mixers = { alc880_three_stack_mixer },
2642 .init_verbs = { alc880_volume_init_verbs,
2643 alc880_pin_3stack_init_verbs },
2644 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2645 .dac_nids = alc880_dac_nids,
2646 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
2647 .channel_mode = alc880_threestack_modes,
2649 .input_mux = &alc880_capture_source,
2651 [ALC880_3ST_DIG] = {
2652 .mixers = { alc880_three_stack_mixer },
2653 .init_verbs = { alc880_volume_init_verbs,
2654 alc880_pin_3stack_init_verbs },
2655 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2656 .dac_nids = alc880_dac_nids,
2657 .dig_out_nid = ALC880_DIGOUT_NID,
2658 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
2659 .channel_mode = alc880_threestack_modes,
2661 .input_mux = &alc880_capture_source,
2663 [ALC880_TCL_S700] = {
2664 .mixers = { alc880_tcl_s700_mixer },
2665 .init_verbs = { alc880_volume_init_verbs,
2666 alc880_pin_tcl_S700_init_verbs,
2667 alc880_gpio2_init_verbs },
2668 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2669 .dac_nids = alc880_dac_nids,
2671 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
2672 .channel_mode = alc880_2_jack_modes,
2673 .input_mux = &alc880_capture_source,
2676 .mixers = { alc880_three_stack_mixer,
2677 alc880_five_stack_mixer},
2678 .init_verbs = { alc880_volume_init_verbs,
2679 alc880_pin_5stack_init_verbs },
2680 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2681 .dac_nids = alc880_dac_nids,
2682 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
2683 .channel_mode = alc880_fivestack_modes,
2684 .input_mux = &alc880_capture_source,
2686 [ALC880_5ST_DIG] = {
2687 .mixers = { alc880_three_stack_mixer,
2688 alc880_five_stack_mixer },
2689 .init_verbs = { alc880_volume_init_verbs,
2690 alc880_pin_5stack_init_verbs },
2691 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2692 .dac_nids = alc880_dac_nids,
2693 .dig_out_nid = ALC880_DIGOUT_NID,
2694 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
2695 .channel_mode = alc880_fivestack_modes,
2696 .input_mux = &alc880_capture_source,
2699 .mixers = { alc880_six_stack_mixer },
2700 .init_verbs = { alc880_volume_init_verbs,
2701 alc880_pin_6stack_init_verbs },
2702 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
2703 .dac_nids = alc880_6st_dac_nids,
2704 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
2705 .channel_mode = alc880_sixstack_modes,
2706 .input_mux = &alc880_6stack_capture_source,
2708 [ALC880_6ST_DIG] = {
2709 .mixers = { alc880_six_stack_mixer },
2710 .init_verbs = { alc880_volume_init_verbs,
2711 alc880_pin_6stack_init_verbs },
2712 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
2713 .dac_nids = alc880_6st_dac_nids,
2714 .dig_out_nid = ALC880_DIGOUT_NID,
2715 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
2716 .channel_mode = alc880_sixstack_modes,
2717 .input_mux = &alc880_6stack_capture_source,
2720 .mixers = { alc880_w810_base_mixer },
2721 .init_verbs = { alc880_volume_init_verbs,
2722 alc880_pin_w810_init_verbs,
2723 alc880_gpio2_init_verbs },
2724 .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
2725 .dac_nids = alc880_w810_dac_nids,
2726 .dig_out_nid = ALC880_DIGOUT_NID,
2727 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
2728 .channel_mode = alc880_w810_modes,
2729 .input_mux = &alc880_capture_source,
2732 .mixers = { alc880_z71v_mixer },
2733 .init_verbs = { alc880_volume_init_verbs,
2734 alc880_pin_z71v_init_verbs },
2735 .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
2736 .dac_nids = alc880_z71v_dac_nids,
2737 .dig_out_nid = ALC880_DIGOUT_NID,
2739 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
2740 .channel_mode = alc880_2_jack_modes,
2741 .input_mux = &alc880_capture_source,
2744 .mixers = { alc880_f1734_mixer },
2745 .init_verbs = { alc880_volume_init_verbs,
2746 alc880_pin_f1734_init_verbs },
2747 .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
2748 .dac_nids = alc880_f1734_dac_nids,
2750 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
2751 .channel_mode = alc880_2_jack_modes,
2752 .input_mux = &alc880_capture_source,
2755 .mixers = { alc880_asus_mixer },
2756 .init_verbs = { alc880_volume_init_verbs,
2757 alc880_pin_asus_init_verbs,
2758 alc880_gpio1_init_verbs },
2759 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2760 .dac_nids = alc880_asus_dac_nids,
2761 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2762 .channel_mode = alc880_asus_modes,
2764 .input_mux = &alc880_capture_source,
2766 [ALC880_ASUS_DIG] = {
2767 .mixers = { alc880_asus_mixer },
2768 .init_verbs = { alc880_volume_init_verbs,
2769 alc880_pin_asus_init_verbs,
2770 alc880_gpio1_init_verbs },
2771 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2772 .dac_nids = alc880_asus_dac_nids,
2773 .dig_out_nid = ALC880_DIGOUT_NID,
2774 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2775 .channel_mode = alc880_asus_modes,
2777 .input_mux = &alc880_capture_source,
2779 [ALC880_ASUS_DIG2] = {
2780 .mixers = { alc880_asus_mixer },
2781 .init_verbs = { alc880_volume_init_verbs,
2782 alc880_pin_asus_init_verbs,
2783 alc880_gpio2_init_verbs }, /* use GPIO2 */
2784 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2785 .dac_nids = alc880_asus_dac_nids,
2786 .dig_out_nid = ALC880_DIGOUT_NID,
2787 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2788 .channel_mode = alc880_asus_modes,
2790 .input_mux = &alc880_capture_source,
2792 [ALC880_ASUS_W1V] = {
2793 .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
2794 .init_verbs = { alc880_volume_init_verbs,
2795 alc880_pin_asus_init_verbs,
2796 alc880_gpio1_init_verbs },
2797 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2798 .dac_nids = alc880_asus_dac_nids,
2799 .dig_out_nid = ALC880_DIGOUT_NID,
2800 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2801 .channel_mode = alc880_asus_modes,
2803 .input_mux = &alc880_capture_source,
2805 [ALC880_UNIWILL_DIG] = {
2806 .mixers = { alc880_asus_mixer, alc880_pcbeep_mixer },
2807 .init_verbs = { alc880_volume_init_verbs,
2808 alc880_pin_asus_init_verbs },
2809 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2810 .dac_nids = alc880_asus_dac_nids,
2811 .dig_out_nid = ALC880_DIGOUT_NID,
2812 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2813 .channel_mode = alc880_asus_modes,
2815 .input_mux = &alc880_capture_source,
2817 [ALC880_UNIWILL] = {
2818 .mixers = { alc880_uniwill_mixer },
2819 .init_verbs = { alc880_volume_init_verbs,
2820 alc880_uniwill_init_verbs },
2821 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2822 .dac_nids = alc880_asus_dac_nids,
2823 .dig_out_nid = ALC880_DIGOUT_NID,
2824 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
2825 .channel_mode = alc880_threestack_modes,
2827 .input_mux = &alc880_capture_source,
2828 .unsol_event = alc880_uniwill_unsol_event,
2829 .init_hook = alc880_uniwill_automute,
2831 [ALC880_UNIWILL_P53] = {
2832 .mixers = { alc880_uniwill_p53_mixer },
2833 .init_verbs = { alc880_volume_init_verbs,
2834 alc880_uniwill_p53_init_verbs },
2835 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2836 .dac_nids = alc880_asus_dac_nids,
2837 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
2838 .channel_mode = alc880_threestack_modes,
2839 .input_mux = &alc880_capture_source,
2840 .unsol_event = alc880_uniwill_p53_unsol_event,
2841 .init_hook = alc880_uniwill_p53_hp_automute,
2843 [ALC880_FUJITSU] = {
2844 .mixers = { alc880_fujitsu_mixer,
2845 alc880_pcbeep_mixer, },
2846 .init_verbs = { alc880_volume_init_verbs,
2847 alc880_uniwill_p53_init_verbs,
2848 alc880_beep_init_verbs },
2849 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2850 .dac_nids = alc880_dac_nids,
2851 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
2852 .channel_mode = alc880_2_jack_modes,
2853 .input_mux = &alc880_capture_source,
2854 .unsol_event = alc880_uniwill_p53_unsol_event,
2855 .init_hook = alc880_uniwill_p53_hp_automute,
2858 .mixers = { alc880_three_stack_mixer },
2859 .init_verbs = { alc880_volume_init_verbs,
2860 alc880_pin_clevo_init_verbs },
2861 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2862 .dac_nids = alc880_dac_nids,
2864 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
2865 .channel_mode = alc880_threestack_modes,
2867 .input_mux = &alc880_capture_source,
2870 .mixers = { alc880_lg_mixer },
2871 .init_verbs = { alc880_volume_init_verbs,
2872 alc880_lg_init_verbs },
2873 .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids),
2874 .dac_nids = alc880_lg_dac_nids,
2875 .dig_out_nid = ALC880_DIGOUT_NID,
2876 .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes),
2877 .channel_mode = alc880_lg_ch_modes,
2879 .input_mux = &alc880_lg_capture_source,
2880 .unsol_event = alc880_lg_unsol_event,
2881 .init_hook = alc880_lg_automute,
2884 .mixers = { alc880_lg_lw_mixer },
2885 .init_verbs = { alc880_volume_init_verbs,
2886 alc880_lg_lw_init_verbs },
2887 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2888 .dac_nids = alc880_dac_nids,
2889 .dig_out_nid = ALC880_DIGOUT_NID,
2890 .num_channel_mode = ARRAY_SIZE(alc880_lg_lw_modes),
2891 .channel_mode = alc880_lg_lw_modes,
2892 .input_mux = &alc880_lg_lw_capture_source,
2893 .unsol_event = alc880_lg_lw_unsol_event,
2894 .init_hook = alc880_lg_lw_automute,
2896 #ifdef CONFIG_SND_DEBUG
2898 .mixers = { alc880_test_mixer },
2899 .init_verbs = { alc880_test_init_verbs },
2900 .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
2901 .dac_nids = alc880_test_dac_nids,
2902 .dig_out_nid = ALC880_DIGOUT_NID,
2903 .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
2904 .channel_mode = alc880_test_modes,
2905 .input_mux = &alc880_test_capture_source,
2911 * Automatic parse of I/O pins from the BIOS configuration
2914 #define NUM_CONTROL_ALLOC 32
2915 #define NUM_VERB_ALLOC 32
2919 ALC_CTL_WIDGET_MUTE,
2922 static struct snd_kcontrol_new alc880_control_templates[] = {
2923 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
2924 HDA_CODEC_MUTE(NULL, 0, 0, 0),
2925 HDA_BIND_MUTE(NULL, 0, 0, 0),
2928 /* add dynamic controls */
2929 static int add_control(struct alc_spec *spec, int type, const char *name,
2932 struct snd_kcontrol_new *knew;
2934 if (spec->num_kctl_used >= spec->num_kctl_alloc) {
2935 int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC;
2937 /* array + terminator */
2938 knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL);
2941 if (spec->kctl_alloc) {
2942 memcpy(knew, spec->kctl_alloc,
2943 sizeof(*knew) * spec->num_kctl_alloc);
2944 kfree(spec->kctl_alloc);
2946 spec->kctl_alloc = knew;
2947 spec->num_kctl_alloc = num;
2950 knew = &spec->kctl_alloc[spec->num_kctl_used];
2951 *knew = alc880_control_templates[type];
2952 knew->name = kstrdup(name, GFP_KERNEL);
2955 knew->private_value = val;
2956 spec->num_kctl_used++;
2960 #define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
2961 #define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
2962 #define alc880_is_multi_pin(nid) ((nid) >= 0x18)
2963 #define alc880_multi_pin_idx(nid) ((nid) - 0x18)
2964 #define alc880_is_input_pin(nid) ((nid) >= 0x18)
2965 #define alc880_input_pin_idx(nid) ((nid) - 0x18)
2966 #define alc880_idx_to_dac(nid) ((nid) + 0x02)
2967 #define alc880_dac_to_idx(nid) ((nid) - 0x02)
2968 #define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
2969 #define alc880_idx_to_selector(nid) ((nid) + 0x10)
2970 #define ALC880_PIN_CD_NID 0x1c
2972 /* fill in the dac_nids table from the parsed pin configuration */
2973 static int alc880_auto_fill_dac_nids(struct alc_spec *spec,
2974 const struct auto_pin_cfg *cfg)
2980 memset(assigned, 0, sizeof(assigned));
2981 spec->multiout.dac_nids = spec->private_dac_nids;
2983 /* check the pins hardwired to audio widget */
2984 for (i = 0; i < cfg->line_outs; i++) {
2985 nid = cfg->line_out_pins[i];
2986 if (alc880_is_fixed_pin(nid)) {
2987 int idx = alc880_fixed_pin_idx(nid);
2988 spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
2992 /* left pins can be connect to any audio widget */
2993 for (i = 0; i < cfg->line_outs; i++) {
2994 nid = cfg->line_out_pins[i];
2995 if (alc880_is_fixed_pin(nid))
2997 /* search for an empty channel */
2998 for (j = 0; j < cfg->line_outs; j++) {
3000 spec->multiout.dac_nids[i] =
3001 alc880_idx_to_dac(j);
3007 spec->multiout.num_dacs = cfg->line_outs;
3011 /* add playback controls from the parsed DAC table */
3012 static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
3013 const struct auto_pin_cfg *cfg)
3016 static const char *chname[4] = {
3017 "Front", "Surround", NULL /*CLFE*/, "Side"
3022 for (i = 0; i < cfg->line_outs; i++) {
3023 if (!spec->multiout.dac_nids[i])
3025 nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
3028 err = add_control(spec, ALC_CTL_WIDGET_VOL,
3029 "Center Playback Volume",
3030 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
3034 err = add_control(spec, ALC_CTL_WIDGET_VOL,
3035 "LFE Playback Volume",
3036 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
3040 err = add_control(spec, ALC_CTL_BIND_MUTE,
3041 "Center Playback Switch",
3042 HDA_COMPOSE_AMP_VAL(nid, 1, 2,
3046 err = add_control(spec, ALC_CTL_BIND_MUTE,
3047 "LFE Playback Switch",
3048 HDA_COMPOSE_AMP_VAL(nid, 2, 2,
3053 sprintf(name, "%s Playback Volume", chname[i]);
3054 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
3055 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
3059 sprintf(name, "%s Playback Switch", chname[i]);
3060 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
3061 HDA_COMPOSE_AMP_VAL(nid, 3, 2,
3070 /* add playback controls for speaker and HP outputs */
3071 static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
3081 if (alc880_is_fixed_pin(pin)) {
3082 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
3083 /* specify the DAC as the extra output */
3084 if (!spec->multiout.hp_nid)
3085 spec->multiout.hp_nid = nid;
3087 spec->multiout.extra_out_nid[0] = nid;
3088 /* control HP volume/switch on the output mixer amp */
3089 nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
3090 sprintf(name, "%s Playback Volume", pfx);
3091 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
3092 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
3095 sprintf(name, "%s Playback Switch", pfx);
3096 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
3097 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
3100 } else if (alc880_is_multi_pin(pin)) {
3101 /* set manual connection */
3102 /* we have only a switch on HP-out PIN */
3103 sprintf(name, "%s Playback Switch", pfx);
3104 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
3105 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
3112 /* create input playback/capture controls for the given pin */
3113 static int new_analog_input(struct alc_spec *spec, hda_nid_t pin,
3114 const char *ctlname,
3115 int idx, hda_nid_t mix_nid)
3120 sprintf(name, "%s Playback Volume", ctlname);
3121 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
3122 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
3125 sprintf(name, "%s Playback Switch", ctlname);
3126 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
3127 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
3133 /* create playback/capture controls for input pins */
3134 static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec,
3135 const struct auto_pin_cfg *cfg)
3137 struct hda_input_mux *imux = &spec->private_imux;
3140 for (i = 0; i < AUTO_PIN_LAST; i++) {
3141 if (alc880_is_input_pin(cfg->input_pins[i])) {
3142 idx = alc880_input_pin_idx(cfg->input_pins[i]);
3143 err = new_analog_input(spec, cfg->input_pins[i],
3144 auto_pin_cfg_labels[i],
3148 imux->items[imux->num_items].label =
3149 auto_pin_cfg_labels[i];
3150 imux->items[imux->num_items].index =
3151 alc880_input_pin_idx(cfg->input_pins[i]);
3158 static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
3159 hda_nid_t nid, int pin_type,
3163 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
3165 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
3167 /* need the manual connection? */
3168 if (alc880_is_multi_pin(nid)) {
3169 struct alc_spec *spec = codec->spec;
3170 int idx = alc880_multi_pin_idx(nid);
3171 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
3172 AC_VERB_SET_CONNECT_SEL,
3173 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
3177 static int get_pin_type(int line_out_type)
3179 if (line_out_type == AUTO_PIN_HP_OUT)
3185 static void alc880_auto_init_multi_out(struct hda_codec *codec)
3187 struct alc_spec *spec = codec->spec;
3190 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
3191 for (i = 0; i < spec->autocfg.line_outs; i++) {
3192 hda_nid_t nid = spec->autocfg.line_out_pins[i];
3193 int pin_type = get_pin_type(spec->autocfg.line_out_type);
3194 alc880_auto_set_output_and_unmute(codec, nid, pin_type, i);
3198 static void alc880_auto_init_extra_out(struct hda_codec *codec)
3200 struct alc_spec *spec = codec->spec;
3203 pin = spec->autocfg.speaker_pins[0];
3204 if (pin) /* connect to front */
3205 alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
3206 pin = spec->autocfg.hp_pins[0];
3207 if (pin) /* connect to front */
3208 alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
3211 static void alc880_auto_init_analog_input(struct hda_codec *codec)
3213 struct alc_spec *spec = codec->spec;
3216 for (i = 0; i < AUTO_PIN_LAST; i++) {
3217 hda_nid_t nid = spec->autocfg.input_pins[i];
3218 if (alc880_is_input_pin(nid)) {
3219 snd_hda_codec_write(codec, nid, 0,
3220 AC_VERB_SET_PIN_WIDGET_CONTROL,
3221 i <= AUTO_PIN_FRONT_MIC ?
3222 PIN_VREF80 : PIN_IN);
3223 if (nid != ALC880_PIN_CD_NID)
3224 snd_hda_codec_write(codec, nid, 0,
3225 AC_VERB_SET_AMP_GAIN_MUTE,
3231 /* parse the BIOS configuration and set up the alc_spec */
3232 /* return 1 if successful, 0 if the proper config is not found,
3233 * or a negative error code
3235 static int alc880_parse_auto_config(struct hda_codec *codec)
3237 struct alc_spec *spec = codec->spec;
3239 static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
3241 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
3245 if (!spec->autocfg.line_outs)
3246 return 0; /* can't find valid BIOS pin config */
3248 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
3251 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
3254 err = alc880_auto_create_extra_out(spec,
3255 spec->autocfg.speaker_pins[0],
3259 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
3263 err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
3267 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
3269 if (spec->autocfg.dig_out_pin)
3270 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
3271 if (spec->autocfg.dig_in_pin)
3272 spec->dig_in_nid = ALC880_DIGIN_NID;
3274 if (spec->kctl_alloc)
3275 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
3277 spec->init_verbs[spec->num_init_verbs++] = alc880_volume_init_verbs;
3279 spec->num_mux_defs = 1;
3280 spec->input_mux = &spec->private_imux;
3285 /* additional initialization for auto-configuration model */
3286 static void alc880_auto_init(struct hda_codec *codec)
3288 alc880_auto_init_multi_out(codec);
3289 alc880_auto_init_extra_out(codec);
3290 alc880_auto_init_analog_input(codec);
3294 * OK, here we have finally the patch for ALC880
3297 static int patch_alc880(struct hda_codec *codec)
3299 struct alc_spec *spec;
3303 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
3309 board_config = snd_hda_check_board_config(codec, ALC880_MODEL_LAST,
3312 if (board_config < 0) {
3313 printk(KERN_INFO "hda_codec: Unknown model for ALC880, "
3314 "trying auto-probe from BIOS...\n");
3315 board_config = ALC880_AUTO;
3318 if (board_config == ALC880_AUTO) {
3319 /* automatic parse from the BIOS config */
3320 err = alc880_parse_auto_config(codec);
3326 "hda_codec: Cannot set up configuration "
3327 "from BIOS. Using 3-stack mode...\n");
3328 board_config = ALC880_3ST;
3332 if (board_config != ALC880_AUTO)
3333 setup_preset(spec, &alc880_presets[board_config]);
3335 spec->stream_name_analog = "ALC880 Analog";
3336 spec->stream_analog_playback = &alc880_pcm_analog_playback;
3337 spec->stream_analog_capture = &alc880_pcm_analog_capture;
3339 spec->stream_name_digital = "ALC880 Digital";
3340 spec->stream_digital_playback = &alc880_pcm_digital_playback;
3341 spec->stream_digital_capture = &alc880_pcm_digital_capture;
3343 if (!spec->adc_nids && spec->input_mux) {
3344 /* check whether NID 0x07 is valid */
3345 unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
3347 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
3348 if (wcap != AC_WID_AUD_IN) {
3349 spec->adc_nids = alc880_adc_nids_alt;
3350 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
3351 spec->mixers[spec->num_mixers] =
3352 alc880_capture_alt_mixer;
3355 spec->adc_nids = alc880_adc_nids;
3356 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
3357 spec->mixers[spec->num_mixers] = alc880_capture_mixer;
3362 codec->patch_ops = alc_patch_ops;
3363 if (board_config == ALC880_AUTO)
3364 spec->init_hook = alc880_auto_init;
3374 static hda_nid_t alc260_dac_nids[1] = {
3379 static hda_nid_t alc260_adc_nids[1] = {
3384 static hda_nid_t alc260_adc_nids_alt[1] = {
3389 static hda_nid_t alc260_hp_adc_nids[2] = {
3394 /* NIDs used when simultaneous access to both ADCs makes sense. Note that
3395 * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
3397 static hda_nid_t alc260_dual_adc_nids[2] = {
3402 #define ALC260_DIGOUT_NID 0x03
3403 #define ALC260_DIGIN_NID 0x06
3405 static struct hda_input_mux alc260_capture_source = {
3409 { "Front Mic", 0x1 },
3415 /* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
3416 * headphone jack and the internal CD lines since these are the only pins at
3417 * which audio can appear. For flexibility, also allow the option of
3418 * recording the mixer output on the second ADC (ADC0 doesn't have a
3419 * connection to the mixer output).
3421 static struct hda_input_mux alc260_fujitsu_capture_sources[2] = {
3425 { "Mic/Line", 0x0 },
3427 { "Headphone", 0x2 },
3433 { "Mic/Line", 0x0 },
3435 { "Headphone", 0x2 },
3442 /* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to
3443 * the Fujitsu S702x, but jacks are marked differently.
3445 static struct hda_input_mux alc260_acer_capture_sources[2] = {
3452 { "Headphone", 0x5 },
3461 { "Headphone", 0x6 },
3467 * This is just place-holder, so there's something for alc_build_pcms to look
3468 * at when it calculates the maximum number of channels. ALC260 has no mixer
3469 * element which allows changing the channel mode, so the verb list is
3472 static struct hda_channel_mode alc260_modes[1] = {
3477 /* Mixer combinations
3479 * basic: base_output + input + pc_beep + capture
3480 * HP: base_output + input + capture_alt
3481 * HP_3013: hp_3013 + input + capture
3482 * fujitsu: fujitsu + capture
3483 * acer: acer + capture
3486 static struct snd_kcontrol_new alc260_base_output_mixer[] = {
3487 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3488 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
3489 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
3490 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
3491 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
3492 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
3496 static struct snd_kcontrol_new alc260_input_mixer[] = {
3497 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3498 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
3499 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
3500 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
3501 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
3502 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
3503 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
3504 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
3508 static struct snd_kcontrol_new alc260_pc_beep_mixer[] = {
3509 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x07, 0x05, HDA_INPUT),
3510 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x07, 0x05, HDA_INPUT),
3514 static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
3515 HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
3516 HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
3517 HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
3518 HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
3519 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3520 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
3521 HDA_CODEC_VOLUME_MONO("iSpeaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
3522 HDA_CODEC_MUTE_MONO("iSpeaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
3526 /* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12,
3527 * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10.
3529 static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
3530 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3531 HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
3532 ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
3533 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3534 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
3535 HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
3536 HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
3537 ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
3538 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
3539 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
3540 HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
3541 HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x09, 2, HDA_INPUT),
3545 /* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current
3546 * versions of the ALC260 don't act on requests to enable mic bias from NID
3547 * 0x0f (used to drive the headphone jack in these laptops). The ALC260
3548 * datasheet doesn't mention this restriction. At this stage it's not clear
3549 * whether this behaviour is intentional or is a hardware bug in chip
3550 * revisions available in early 2006. Therefore for now allow the
3551 * "Headphone Jack Mode" control to span all choices, but if it turns out
3552 * that the lack of mic bias for this NID is intentional we could change the
3553 * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
3555 * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006
3556 * don't appear to make the mic bias available from the "line" jack, even
3557 * though the NID used for this jack (0x14) can supply it. The theory is
3558 * that perhaps Acer have included blocking capacitors between the ALC260
3559 * and the output jack. If this turns out to be the case for all such
3560 * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
3561 * to ALC_PIN_DIR_INOUT_NOMICBIAS.
3563 * The C20x Tablet series have a mono internal speaker which is controlled
3564 * via the chip's Mono sum widget and pin complex, so include the necessary
3565 * controls for such models. On models without a "mono speaker" the control
3566 * won't do anything.
3568 static struct snd_kcontrol_new alc260_acer_mixer[] = {
3569 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3570 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
3571 ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
3572 HDA_CODEC_VOLUME_MONO("Mono Speaker Playback Volume", 0x0a, 1, 0x0,
3574 HDA_BIND_MUTE_MONO("Mono Speaker Playback Switch", 0x0a, 1, 2,
3576 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3577 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
3578 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
3579 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
3580 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
3581 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
3582 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
3583 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
3584 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
3585 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
3589 /* Packard bell V7900 ALC260 pin usage: HP = 0x0f, Mic jack = 0x12,
3590 * Line In jack = 0x14, CD audio = 0x16, pc beep = 0x17.
3592 static struct snd_kcontrol_new alc260_will_mixer[] = {
3593 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3594 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
3595 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
3596 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
3597 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
3598 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
3599 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
3600 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
3601 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3602 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
3603 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
3604 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
3608 /* Replacer 672V ALC260 pin usage: Mic jack = 0x12,
3609 * Line In jack = 0x14, ATAPI Mic = 0x13, speaker = 0x0f.
3611 static struct snd_kcontrol_new alc260_replacer_672v_mixer[] = {
3612 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3613 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
3614 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
3615 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
3616 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
3617 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x07, 0x1, HDA_INPUT),
3618 HDA_CODEC_MUTE("ATATI Mic Playback Switch", 0x07, 0x1, HDA_INPUT),
3619 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
3620 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
3621 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
3625 /* capture mixer elements */
3626 static struct snd_kcontrol_new alc260_capture_mixer[] = {
3627 HDA_CODEC_VOLUME("Capture Volume", 0x04, 0x0, HDA_INPUT),
3628 HDA_CODEC_MUTE("Capture Switch", 0x04, 0x0, HDA_INPUT),
3629 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x05, 0x0, HDA_INPUT),
3630 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x05, 0x0, HDA_INPUT),
3632 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3633 /* The multiple "Capture Source" controls confuse alsamixer
3634 * So call somewhat different..
3635 * FIXME: the controls appear in the "playback" view!
3637 /* .name = "Capture Source", */
3638 .name = "Input Source",
3640 .info = alc_mux_enum_info,
3641 .get = alc_mux_enum_get,
3642 .put = alc_mux_enum_put,
3647 static struct snd_kcontrol_new alc260_capture_alt_mixer[] = {
3648 HDA_CODEC_VOLUME("Capture Volume", 0x05, 0x0, HDA_INPUT),
3649 HDA_CODEC_MUTE("Capture Switch", 0x05, 0x0, HDA_INPUT),
3651 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3652 /* The multiple "Capture Source" controls confuse alsamixer
3653 * So call somewhat different..
3654 * FIXME: the controls appear in the "playback" view!
3656 /* .name = "Capture Source", */
3657 .name = "Input Source",
3659 .info = alc_mux_enum_info,
3660 .get = alc_mux_enum_get,
3661 .put = alc_mux_enum_put,
3667 * initialization verbs
3669 static struct hda_verb alc260_init_verbs[] = {
3670 /* Line In pin widget for input */
3671 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3672 /* CD pin widget for input */
3673 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3674 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3675 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3676 /* Mic2 (front panel) pin widget for input and vref at 80% */
3677 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3678 /* LINE-2 is used for line-out in rear */
3679 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3680 /* select line-out */
3681 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
3683 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3685 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3687 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3688 /* mute capture amp left and right */
3689 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3690 /* set connection select to line in (default select for this ADC) */
3691 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
3692 /* mute capture amp left and right */
3693 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3694 /* set connection select to line in (default select for this ADC) */
3695 {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
3696 /* set vol=0 Line-Out mixer amp left and right */
3697 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3698 /* unmute pin widget amp left and right (no gain on this amp) */
3699 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3700 /* set vol=0 HP mixer amp left and right */
3701 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3702 /* unmute pin widget amp left and right (no gain on this amp) */
3703 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3704 /* set vol=0 Mono mixer amp left and right */
3705 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3706 /* unmute pin widget amp left and right (no gain on this amp) */
3707 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3708 /* unmute LINE-2 out pin */
3709 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3710 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
3714 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
3716 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
3718 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3719 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
3720 /* mute Front out path */
3721 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3722 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3723 /* mute Headphone out path */
3724 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3725 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3726 /* mute Mono out path */
3727 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3728 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3732 #if 0 /* should be identical with alc260_init_verbs? */
3733 static struct hda_verb alc260_hp_init_verbs[] = {
3734 /* Headphone and output */
3735 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
3737 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
3738 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3739 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
3740 /* Mic2 (front panel) pin widget for input and vref at 80% */
3741 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
3742 /* Line In pin widget for input */
3743 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
3744 /* Line-2 pin widget for output */
3745 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
3746 /* CD pin widget for input */
3747 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
3748 /* unmute amp left and right */
3749 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
3750 /* set connection select to line in (default select for this ADC) */
3751 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
3752 /* unmute Line-Out mixer amp left and right (volume = 0) */
3753 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
3754 /* mute pin widget amp left and right (no gain on this amp) */
3755 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
3756 /* unmute HP mixer amp left and right (volume = 0) */
3757 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
3758 /* mute pin widget amp left and right (no gain on this amp) */
3759 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
3760 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
3764 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
3765 /* unmute Line In */
3766 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
3768 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3769 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
3770 /* Unmute Front out path */
3771 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3772 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3773 /* Unmute Headphone out path */
3774 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3775 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3776 /* Unmute Mono out path */
3777 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3778 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3783 static struct hda_verb alc260_hp_3013_init_verbs[] = {
3784 /* Line out and output */
3785 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
3787 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
3788 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3789 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
3790 /* Mic2 (front panel) pin widget for input and vref at 80% */
3791 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
3792 /* Line In pin widget for input */
3793 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
3794 /* Headphone pin widget for output */
3795 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
3796 /* CD pin widget for input */
3797 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
3798 /* unmute amp left and right */
3799 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
3800 /* set connection select to line in (default select for this ADC) */
3801 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
3802 /* unmute Line-Out mixer amp left and right (volume = 0) */
3803 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
3804 /* mute pin widget amp left and right (no gain on this amp) */
3805 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
3806 /* unmute HP mixer amp left and right (volume = 0) */
3807 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
3808 /* mute pin widget amp left and right (no gain on this amp) */
3809 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
3810 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
3814 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
3815 /* unmute Line In */
3816 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
3818 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3819 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
3820 /* Unmute Front out path */
3821 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3822 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3823 /* Unmute Headphone out path */
3824 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3825 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3826 /* Unmute Mono out path */
3827 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3828 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3832 /* Initialisation sequence for ALC260 as configured in Fujitsu S702x
3833 * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD
3834 * audio = 0x16, internal speaker = 0x10.
3836 static struct hda_verb alc260_fujitsu_init_verbs[] = {
3837 /* Disable all GPIOs */
3838 {0x01, AC_VERB_SET_GPIO_MASK, 0},
3839 /* Internal speaker is connected to headphone pin */
3840 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3841 /* Headphone/Line-out jack connects to Line1 pin; make it an output */
3842 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3843 /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
3844 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3845 /* Ensure all other unused pins are disabled and muted. */
3846 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3847 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3848 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3849 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3850 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3851 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3852 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3853 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3855 /* Disable digital (SPDIF) pins */
3856 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
3857 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
3859 /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
3860 * when acting as an output.
3862 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
3864 /* Start with output sum widgets muted and their output gains at min */
3865 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3866 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3867 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3868 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3869 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3870 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3871 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3872 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3873 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3875 /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
3876 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3877 /* Unmute Line1 pin widget output buffer since it starts as an output.
3878 * If the pin mode is changed by the user the pin mode control will
3879 * take care of enabling the pin's input/output buffers as needed.
3880 * Therefore there's no need to enable the input buffer at this
3883 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3884 /* Unmute input buffer of pin widget used for Line-in (no equiv
3887 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3889 /* Mute capture amp left and right */
3890 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3891 /* Set ADC connection select to match default mixer setting - line
3894 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
3896 /* Do the same for the second ADC: mute capture input amp and
3897 * set ADC connection to line in (on mic1 pin)
3899 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3900 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
3902 /* Mute all inputs to mixer widget (even unconnected ones) */
3903 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
3904 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
3905 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
3906 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
3907 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
3908 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
3909 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
3910 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
3915 /* Initialisation sequence for ALC260 as configured in Acer TravelMate and
3916 * similar laptops (adapted from Fujitsu init verbs).
3918 static struct hda_verb alc260_acer_init_verbs[] = {
3919 /* On TravelMate laptops, GPIO 0 enables the internal speaker and
3920 * the headphone jack. Turn this on and rely on the standard mute
3921 * methods whenever the user wants to turn these outputs off.
3923 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
3924 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
3925 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
3926 /* Internal speaker/Headphone jack is connected to Line-out pin */
3927 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3928 /* Internal microphone/Mic jack is connected to Mic1 pin */
3929 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
3930 /* Line In jack is connected to Line1 pin */
3931 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3932 /* Some Acers (eg: C20x Tablets) use Mono pin for internal speaker */
3933 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3934 /* Ensure all other unused pins are disabled and muted. */
3935 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3936 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3937 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3938 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3939 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3940 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3941 /* Disable digital (SPDIF) pins */
3942 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
3943 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
3945 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
3946 * bus when acting as outputs.
3948 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
3949 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
3951 /* Start with output sum widgets muted and their output gains at min */
3952 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3953 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3954 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3955 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3956 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3957 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3958 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3959 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3960 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3962 /* Unmute Line-out pin widget amp left and right
3963 * (no equiv mixer ctrl)
3965 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3966 /* Unmute mono pin widget amp output (no equiv mixer ctrl) */
3967 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3968 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
3969 * inputs. If the pin mode is changed by the user the pin mode control
3970 * will take care of enabling the pin's input/output buffers as needed.
3971 * Therefore there's no need to enable the input buffer at this
3974 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3975 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3977 /* Mute capture amp left and right */
3978 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3979 /* Set ADC connection select to match default mixer setting - mic
3982 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
3984 /* Do similar with the second ADC: mute capture input amp and
3985 * set ADC connection to mic to match ALSA's default state.
3987 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3988 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
3990 /* Mute all inputs to mixer widget (even unconnected ones) */
3991 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
3992 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
3993 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
3994 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
3995 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
3996 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
3997 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
3998 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
4003 static struct hda_verb alc260_will_verbs[] = {
4004 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4005 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x00},
4006 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
4007 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
4008 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
4009 {0x1a, AC_VERB_SET_PROC_COEF, 0x3040},
4013 static struct hda_verb alc260_replacer_672v_verbs[] = {
4014 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
4015 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
4016 {0x1a, AC_VERB_SET_PROC_COEF, 0x3050},
4018 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
4019 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
4020 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
4022 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
4026 /* toggle speaker-output according to the hp-jack state */
4027 static void alc260_replacer_672v_automute(struct hda_codec *codec)
4029 unsigned int present;
4031 /* speaker --> GPIO Data 0, hp or spdif --> GPIO data 1 */
4032 present = snd_hda_codec_read(codec, 0x0f, 0,
4033 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
4035 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 1);
4036 snd_hda_codec_write(codec, 0x0f, 0,
4037 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP);
4039 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 0);
4040 snd_hda_codec_write(codec, 0x0f, 0,
4041 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
4045 static void alc260_replacer_672v_unsol_event(struct hda_codec *codec,
4048 if ((res >> 26) == ALC880_HP_EVENT)
4049 alc260_replacer_672v_automute(codec);
4052 /* Test configuration for debugging, modelled after the ALC880 test
4055 #ifdef CONFIG_SND_DEBUG
4056 static hda_nid_t alc260_test_dac_nids[1] = {
4059 static hda_nid_t alc260_test_adc_nids[2] = {
4062 /* For testing the ALC260, each input MUX needs its own definition since
4063 * the signal assignments are different. This assumes that the first ADC
4066 static struct hda_input_mux alc260_test_capture_sources[2] = {
4070 { "MIC1 pin", 0x0 },
4071 { "MIC2 pin", 0x1 },
4072 { "LINE1 pin", 0x2 },
4073 { "LINE2 pin", 0x3 },
4075 { "LINE-OUT pin", 0x5 },
4076 { "HP-OUT pin", 0x6 },
4082 { "MIC1 pin", 0x0 },
4083 { "MIC2 pin", 0x1 },
4084 { "LINE1 pin", 0x2 },
4085 { "LINE2 pin", 0x3 },
4088 { "LINE-OUT pin", 0x6 },
4089 { "HP-OUT pin", 0x7 },
4093 static struct snd_kcontrol_new alc260_test_mixer[] = {
4094 /* Output driver widgets */
4095 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
4096 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
4097 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4098 HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
4099 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4100 HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
4102 /* Modes for retasking pin widgets
4103 * Note: the ALC260 doesn't seem to act on requests to enable mic
4104 * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't
4105 * mention this restriction. At this stage it's not clear whether
4106 * this behaviour is intentional or is a hardware bug in chip
4107 * revisions available at least up until early 2006. Therefore for
4108 * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all
4109 * choices, but if it turns out that the lack of mic bias for these
4110 * NIDs is intentional we could change their modes from
4111 * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
4113 ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
4114 ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
4115 ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
4116 ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
4117 ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
4118 ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
4120 /* Loopback mixer controls */
4121 HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
4122 HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
4123 HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
4124 HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
4125 HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
4126 HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
4127 HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
4128 HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
4129 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4130 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4131 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
4132 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
4133 HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
4134 HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
4135 HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
4136 HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
4138 /* Controls for GPIO pins, assuming they are configured as outputs */
4139 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
4140 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
4141 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
4142 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
4144 /* Switches to allow the digital IO pins to be enabled. The datasheet
4145 * is ambigious as to which NID is which; testing on laptops which
4146 * make this output available should provide clarification.
4148 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
4149 ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
4153 static struct hda_verb alc260_test_init_verbs[] = {
4154 /* Enable all GPIOs as outputs with an initial value of 0 */
4155 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
4156 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
4157 {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
4159 /* Enable retasking pins as output, initially without power amp */
4160 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4161 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4162 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4163 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4164 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4165 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4167 /* Disable digital (SPDIF) pins initially, but users can enable
4168 * them via a mixer switch. In the case of SPDIF-out, this initverb
4169 * payload also sets the generation to 0, output to be in "consumer"
4170 * PCM format, copyright asserted, no pre-emphasis and no validity
4173 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
4174 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
4176 /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
4177 * OUT1 sum bus when acting as an output.
4179 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
4180 {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
4181 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
4182 {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
4184 /* Start with output sum widgets muted and their output gains at min */
4185 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4186 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4187 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4188 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4189 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4190 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4191 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4192 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4193 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4195 /* Unmute retasking pin widget output buffers since the default
4196 * state appears to be output. As the pin mode is changed by the
4197 * user the pin mode control will take care of enabling the pin's
4198 * input/output buffers as needed.
4200 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4201 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4202 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4203 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4204 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4205 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4206 /* Also unmute the mono-out pin widget */
4207 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4209 /* Mute capture amp left and right */
4210 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4211 /* Set ADC connection select to match default mixer setting (mic1
4214 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
4216 /* Do the same for the second ADC: mute capture input amp and
4217 * set ADC connection to mic1 pin
4219 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4220 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
4222 /* Mute all inputs to mixer widget (even unconnected ones) */
4223 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
4224 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
4225 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
4226 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
4227 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
4228 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
4229 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
4230 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
4236 static struct hda_pcm_stream alc260_pcm_analog_playback = {
4242 static struct hda_pcm_stream alc260_pcm_analog_capture = {
4248 #define alc260_pcm_digital_playback alc880_pcm_digital_playback
4249 #define alc260_pcm_digital_capture alc880_pcm_digital_capture
4252 * for BIOS auto-configuration
4255 static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
4259 unsigned long vol_val, sw_val;
4263 if (nid >= 0x0f && nid < 0x11) {
4264 nid_vol = nid - 0x7;
4265 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
4266 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
4267 } else if (nid == 0x11) {
4268 nid_vol = nid - 0x7;
4269 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
4270 sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
4271 } else if (nid >= 0x12 && nid <= 0x15) {
4273 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
4274 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
4278 snprintf(name, sizeof(name), "%s Playback Volume", pfx);
4279 err = add_control(spec, ALC_CTL_WIDGET_VOL, name, vol_val);
4282 snprintf(name, sizeof(name), "%s Playback Switch", pfx);
4283 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, sw_val);
4289 /* add playback controls from the parsed DAC table */
4290 static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
4291 const struct auto_pin_cfg *cfg)
4296 spec->multiout.num_dacs = 1;
4297 spec->multiout.dac_nids = spec->private_dac_nids;
4298 spec->multiout.dac_nids[0] = 0x02;
4300 nid = cfg->line_out_pins[0];
4302 err = alc260_add_playback_controls(spec, nid, "Front");
4307 nid = cfg->speaker_pins[0];
4309 err = alc260_add_playback_controls(spec, nid, "Speaker");
4314 nid = cfg->hp_pins[0];
4316 err = alc260_add_playback_controls(spec, nid, "Headphone");
4323 /* create playback/capture controls for input pins */
4324 static int alc260_auto_create_analog_input_ctls(struct alc_spec *spec,
4325 const struct auto_pin_cfg *cfg)
4327 struct hda_input_mux *imux = &spec->private_imux;
4330 for (i = 0; i < AUTO_PIN_LAST; i++) {
4331 if (cfg->input_pins[i] >= 0x12) {
4332 idx = cfg->input_pins[i] - 0x12;
4333 err = new_analog_input(spec, cfg->input_pins[i],
4334 auto_pin_cfg_labels[i], idx,
4338 imux->items[imux->num_items].label =
4339 auto_pin_cfg_labels[i];
4340 imux->items[imux->num_items].index = idx;
4343 if (cfg->input_pins[i] >= 0x0f && cfg->input_pins[i] <= 0x10){
4344 idx = cfg->input_pins[i] - 0x09;
4345 err = new_analog_input(spec, cfg->input_pins[i],
4346 auto_pin_cfg_labels[i], idx,
4350 imux->items[imux->num_items].label =
4351 auto_pin_cfg_labels[i];
4352 imux->items[imux->num_items].index = idx;
4359 static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
4360 hda_nid_t nid, int pin_type,
4364 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4366 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
4368 /* need the manual connection? */
4370 int idx = nid - 0x12;
4371 snd_hda_codec_write(codec, idx + 0x0b, 0,
4372 AC_VERB_SET_CONNECT_SEL, sel_idx);
4376 static void alc260_auto_init_multi_out(struct hda_codec *codec)
4378 struct alc_spec *spec = codec->spec;
4381 alc_subsystem_id(codec, 0x10, 0x15, 0x0f);
4382 nid = spec->autocfg.line_out_pins[0];
4384 int pin_type = get_pin_type(spec->autocfg.line_out_type);
4385 alc260_auto_set_output_and_unmute(codec, nid, pin_type, 0);
4388 nid = spec->autocfg.speaker_pins[0];
4390 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
4392 nid = spec->autocfg.hp_pins[0];
4394 alc260_auto_set_output_and_unmute(codec, nid, PIN_HP, 0);
4397 #define ALC260_PIN_CD_NID 0x16
4398 static void alc260_auto_init_analog_input(struct hda_codec *codec)
4400 struct alc_spec *spec = codec->spec;
4403 for (i = 0; i < AUTO_PIN_LAST; i++) {
4404 hda_nid_t nid = spec->autocfg.input_pins[i];
4406 snd_hda_codec_write(codec, nid, 0,
4407 AC_VERB_SET_PIN_WIDGET_CONTROL,
4408 i <= AUTO_PIN_FRONT_MIC ?
4409 PIN_VREF80 : PIN_IN);
4410 if (nid != ALC260_PIN_CD_NID)
4411 snd_hda_codec_write(codec, nid, 0,
4412 AC_VERB_SET_AMP_GAIN_MUTE,
4419 * generic initialization of ADC, input mixers and output mixers
4421 static struct hda_verb alc260_volume_init_verbs[] = {
4423 * Unmute ADC0-1 and set the default input to mic-in
4425 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
4426 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4427 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
4428 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4430 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
4432 * Note: PASD motherboards uses the Line In 2 as the input for
4433 * front panel mic (mic 2)
4435 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
4436 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4437 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4438 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
4439 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
4440 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
4443 * Set up output mixers (0x08 - 0x0a)
4445 /* set vol=0 to output mixers */
4446 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4447 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4448 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4449 /* set up input amps for analog loopback */
4450 /* Amp Indices: DAC = 0, mixer = 1 */
4451 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4452 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4453 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4454 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4455 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4456 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4461 static int alc260_parse_auto_config(struct hda_codec *codec)
4463 struct alc_spec *spec = codec->spec;
4466 static hda_nid_t alc260_ignore[] = { 0x17, 0 };
4468 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
4472 err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg);
4475 if (!spec->kctl_alloc)
4476 return 0; /* can't find valid BIOS pin config */
4477 err = alc260_auto_create_analog_input_ctls(spec, &spec->autocfg);
4481 spec->multiout.max_channels = 2;
4483 if (spec->autocfg.dig_out_pin)
4484 spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
4485 if (spec->kctl_alloc)
4486 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
4488 spec->init_verbs[spec->num_init_verbs++] = alc260_volume_init_verbs;
4490 spec->num_mux_defs = 1;
4491 spec->input_mux = &spec->private_imux;
4493 /* check whether NID 0x04 is valid */
4494 wcap = get_wcaps(codec, 0x04);
4495 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
4496 if (wcap != AC_WID_AUD_IN) {
4497 spec->adc_nids = alc260_adc_nids_alt;
4498 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
4499 spec->mixers[spec->num_mixers] = alc260_capture_alt_mixer;
4501 spec->adc_nids = alc260_adc_nids;
4502 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
4503 spec->mixers[spec->num_mixers] = alc260_capture_mixer;
4510 /* additional initialization for auto-configuration model */
4511 static void alc260_auto_init(struct hda_codec *codec)
4513 alc260_auto_init_multi_out(codec);
4514 alc260_auto_init_analog_input(codec);
4518 * ALC260 configurations
4520 static const char *alc260_models[ALC260_MODEL_LAST] = {
4521 [ALC260_BASIC] = "basic",
4523 [ALC260_HP_3013] = "hp-3013",
4524 [ALC260_FUJITSU_S702X] = "fujitsu",
4525 [ALC260_ACER] = "acer",
4526 [ALC260_WILL] = "will",
4527 [ALC260_REPLACER_672V] = "replacer",
4528 #ifdef CONFIG_SND_DEBUG
4529 [ALC260_TEST] = "test",
4531 [ALC260_AUTO] = "auto",
4534 static struct snd_pci_quirk alc260_cfg_tbl[] = {
4535 SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER),
4536 SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER),
4537 SND_PCI_QUIRK(0x103c, 0x2808, "HP d5700", ALC260_HP_3013),
4538 SND_PCI_QUIRK(0x103c, 0x280a, "HP d5750", ALC260_HP_3013),
4539 SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013),
4540 SND_PCI_QUIRK(0x103c, 0x3011, "HP", ALC260_HP),
4541 SND_PCI_QUIRK(0x103c, 0x3012, "HP", ALC260_HP_3013),
4542 SND_PCI_QUIRK(0x103c, 0x3013, "HP", ALC260_HP_3013),
4543 SND_PCI_QUIRK(0x103c, 0x3014, "HP", ALC260_HP),
4544 SND_PCI_QUIRK(0x103c, 0x3015, "HP", ALC260_HP),
4545 SND_PCI_QUIRK(0x103c, 0x3016, "HP", ALC260_HP),
4546 SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_BASIC),
4547 SND_PCI_QUIRK(0x104d, 0x81cc, "Sony VAIO", ALC260_BASIC),
4548 SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC),
4549 SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X),
4550 SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC),
4551 SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_WILL),
4552 SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_REPLACER_672V),
4556 static struct alc_config_preset alc260_presets[] = {
4558 .mixers = { alc260_base_output_mixer,
4560 alc260_pc_beep_mixer,
4561 alc260_capture_mixer },
4562 .init_verbs = { alc260_init_verbs },
4563 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4564 .dac_nids = alc260_dac_nids,
4565 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
4566 .adc_nids = alc260_adc_nids,
4567 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4568 .channel_mode = alc260_modes,
4569 .input_mux = &alc260_capture_source,
4572 .mixers = { alc260_base_output_mixer,
4574 alc260_capture_alt_mixer },
4575 .init_verbs = { alc260_init_verbs },
4576 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4577 .dac_nids = alc260_dac_nids,
4578 .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
4579 .adc_nids = alc260_hp_adc_nids,
4580 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4581 .channel_mode = alc260_modes,
4582 .input_mux = &alc260_capture_source,
4584 [ALC260_HP_3013] = {
4585 .mixers = { alc260_hp_3013_mixer,
4587 alc260_capture_alt_mixer },
4588 .init_verbs = { alc260_hp_3013_init_verbs },
4589 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4590 .dac_nids = alc260_dac_nids,
4591 .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
4592 .adc_nids = alc260_hp_adc_nids,
4593 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4594 .channel_mode = alc260_modes,
4595 .input_mux = &alc260_capture_source,
4597 [ALC260_FUJITSU_S702X] = {
4598 .mixers = { alc260_fujitsu_mixer,
4599 alc260_capture_mixer },
4600 .init_verbs = { alc260_fujitsu_init_verbs },
4601 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4602 .dac_nids = alc260_dac_nids,
4603 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
4604 .adc_nids = alc260_dual_adc_nids,
4605 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4606 .channel_mode = alc260_modes,
4607 .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources),
4608 .input_mux = alc260_fujitsu_capture_sources,
4611 .mixers = { alc260_acer_mixer,
4612 alc260_capture_mixer },
4613 .init_verbs = { alc260_acer_init_verbs },
4614 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4615 .dac_nids = alc260_dac_nids,
4616 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
4617 .adc_nids = alc260_dual_adc_nids,
4618 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4619 .channel_mode = alc260_modes,
4620 .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
4621 .input_mux = alc260_acer_capture_sources,
4624 .mixers = { alc260_will_mixer,
4625 alc260_capture_mixer },
4626 .init_verbs = { alc260_init_verbs, alc260_will_verbs },
4627 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4628 .dac_nids = alc260_dac_nids,
4629 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
4630 .adc_nids = alc260_adc_nids,
4631 .dig_out_nid = ALC260_DIGOUT_NID,
4632 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4633 .channel_mode = alc260_modes,
4634 .input_mux = &alc260_capture_source,
4636 [ALC260_REPLACER_672V] = {
4637 .mixers = { alc260_replacer_672v_mixer,
4638 alc260_capture_mixer },
4639 .init_verbs = { alc260_init_verbs, alc260_replacer_672v_verbs },
4640 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4641 .dac_nids = alc260_dac_nids,
4642 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
4643 .adc_nids = alc260_adc_nids,
4644 .dig_out_nid = ALC260_DIGOUT_NID,
4645 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4646 .channel_mode = alc260_modes,
4647 .input_mux = &alc260_capture_source,
4648 .unsol_event = alc260_replacer_672v_unsol_event,
4649 .init_hook = alc260_replacer_672v_automute,
4651 #ifdef CONFIG_SND_DEBUG
4653 .mixers = { alc260_test_mixer,
4654 alc260_capture_mixer },
4655 .init_verbs = { alc260_test_init_verbs },
4656 .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
4657 .dac_nids = alc260_test_dac_nids,
4658 .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
4659 .adc_nids = alc260_test_adc_nids,
4660 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4661 .channel_mode = alc260_modes,
4662 .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources),
4663 .input_mux = alc260_test_capture_sources,
4668 static int patch_alc260(struct hda_codec *codec)
4670 struct alc_spec *spec;
4671 int err, board_config;
4673 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4679 board_config = snd_hda_check_board_config(codec, ALC260_MODEL_LAST,
4682 if (board_config < 0) {
4683 snd_printd(KERN_INFO "hda_codec: Unknown model for ALC260, "
4684 "trying auto-probe from BIOS...\n");
4685 board_config = ALC260_AUTO;
4688 if (board_config == ALC260_AUTO) {
4689 /* automatic parse from the BIOS config */
4690 err = alc260_parse_auto_config(codec);
4696 "hda_codec: Cannot set up configuration "
4697 "from BIOS. Using base mode...\n");
4698 board_config = ALC260_BASIC;
4702 if (board_config != ALC260_AUTO)
4703 setup_preset(spec, &alc260_presets[board_config]);
4705 spec->stream_name_analog = "ALC260 Analog";
4706 spec->stream_analog_playback = &alc260_pcm_analog_playback;
4707 spec->stream_analog_capture = &alc260_pcm_analog_capture;
4709 spec->stream_name_digital = "ALC260 Digital";
4710 spec->stream_digital_playback = &alc260_pcm_digital_playback;
4711 spec->stream_digital_capture = &alc260_pcm_digital_capture;
4713 codec->patch_ops = alc_patch_ops;
4714 if (board_config == ALC260_AUTO)
4715 spec->init_hook = alc260_auto_init;
4724 * ALC882 is almost identical with ALC880 but has cleaner and more flexible
4725 * configuration. Each pin widget can choose any input DACs and a mixer.
4726 * Each ADC is connected from a mixer of all inputs. This makes possible
4727 * 6-channel independent captures.
4729 * In addition, an independent DAC for the multi-playback (not used in this
4732 #define ALC882_DIGOUT_NID 0x06
4733 #define ALC882_DIGIN_NID 0x0a
4735 static struct hda_channel_mode alc882_ch_modes[1] = {
4739 static hda_nid_t alc882_dac_nids[4] = {
4740 /* front, rear, clfe, rear_surr */
4741 0x02, 0x03, 0x04, 0x05
4744 /* identical with ALC880 */
4745 #define alc882_adc_nids alc880_adc_nids
4746 #define alc882_adc_nids_alt alc880_adc_nids_alt
4749 /* FIXME: should be a matrix-type input source selection */
4751 static struct hda_input_mux alc882_capture_source = {
4755 { "Front Mic", 0x1 },
4760 #define alc882_mux_enum_info alc_mux_enum_info
4761 #define alc882_mux_enum_get alc_mux_enum_get
4763 static int alc882_mux_enum_put(struct snd_kcontrol *kcontrol,
4764 struct snd_ctl_elem_value *ucontrol)
4766 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4767 struct alc_spec *spec = codec->spec;
4768 const struct hda_input_mux *imux = spec->input_mux;
4769 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
4770 static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
4771 hda_nid_t nid = capture_mixers[adc_idx];
4772 unsigned int *cur_val = &spec->cur_mux[adc_idx];
4773 unsigned int i, idx;
4775 idx = ucontrol->value.enumerated.item[0];
4776 if (idx >= imux->num_items)
4777 idx = imux->num_items - 1;
4778 if (*cur_val == idx && !codec->in_resume)
4780 for (i = 0; i < imux->num_items; i++) {
4781 unsigned int v = (i == idx) ? 0x7000 : 0x7080;
4782 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
4783 v | (imux->items[i].index << 8));
4792 static struct hda_verb alc882_3ST_ch2_init[] = {
4793 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
4794 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
4795 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
4796 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
4803 static struct hda_verb alc882_3ST_ch6_init[] = {
4804 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4805 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
4806 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
4807 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4808 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
4809 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
4813 static struct hda_channel_mode alc882_3ST_6ch_modes[2] = {
4814 { 2, alc882_3ST_ch2_init },
4815 { 6, alc882_3ST_ch6_init },
4821 static struct hda_verb alc882_sixstack_ch6_init[] = {
4822 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
4823 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4824 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4825 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4832 static struct hda_verb alc882_sixstack_ch8_init[] = {
4833 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4834 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4835 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4836 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4840 static struct hda_channel_mode alc882_sixstack_modes[2] = {
4841 { 6, alc882_sixstack_ch6_init },
4842 { 8, alc882_sixstack_ch8_init },
4845 /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
4846 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
4848 static struct snd_kcontrol_new alc882_base_mixer[] = {
4849 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
4850 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
4851 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
4852 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
4853 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
4854 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
4855 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
4856 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
4857 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
4858 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
4859 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
4860 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
4861 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
4862 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
4863 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
4864 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
4865 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
4866 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
4867 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
4868 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
4869 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
4870 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
4871 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
4875 static struct snd_kcontrol_new alc882_w2jc_mixer[] = {
4876 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
4877 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
4878 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
4879 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
4880 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
4881 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
4882 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
4883 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
4884 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
4885 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
4886 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
4890 static struct snd_kcontrol_new alc882_targa_mixer[] = {
4891 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
4892 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
4893 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
4894 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
4895 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
4896 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
4897 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
4898 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
4899 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
4900 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
4901 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
4905 /* Pin assignment: Front=0x14, HP = 0x15, Front = 0x16, ???
4906 * Front Mic=0x18, Line In = 0x1a, Line In = 0x1b, CD = 0x1c
4908 static struct snd_kcontrol_new alc882_asus_a7j_mixer[] = {
4909 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
4910 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
4911 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
4912 HDA_CODEC_MUTE("Mobile Front Playback Switch", 0x16, 0x0, HDA_OUTPUT),
4913 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
4914 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
4915 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
4916 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
4917 HDA_CODEC_VOLUME("Mobile Line Playback Volume", 0x0b, 0x03, HDA_INPUT),
4918 HDA_CODEC_MUTE("Mobile Line Playback Switch", 0x0b, 0x03, HDA_INPUT),
4919 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
4920 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
4924 static struct snd_kcontrol_new alc882_chmode_mixer[] = {
4926 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4927 .name = "Channel Mode",
4928 .info = alc_ch_mode_info,
4929 .get = alc_ch_mode_get,
4930 .put = alc_ch_mode_put,
4935 static struct hda_verb alc882_init_verbs[] = {
4936 /* Front mixer: unmute input/output amp left and right (volume = 0) */
4937 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4938 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4939 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4941 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4942 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4943 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4945 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4946 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4947 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4949 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4950 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4951 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4953 /* Front Pin: output 0 (0x0c) */
4954 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4955 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4956 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
4957 /* Rear Pin: output 1 (0x0d) */
4958 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4959 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4960 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
4961 /* CLFE Pin: output 2 (0x0e) */
4962 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4963 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4964 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
4965 /* Side Pin: output 3 (0x0f) */
4966 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4967 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4968 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
4969 /* Mic (rear) pin: input vref at 80% */
4970 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
4971 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4972 /* Front Mic pin: input vref at 80% */
4973 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
4974 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4975 /* Line In pin: input */
4976 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
4977 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4978 /* Line-2 In: Headphone output (output 0 - 0x0c) */
4979 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4980 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4981 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
4982 /* CD pin widget for input */
4983 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
4985 /* FIXME: use matrix-type input source selection */
4986 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
4987 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
4988 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4989 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4990 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4991 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
4993 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4994 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4995 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4996 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
4998 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4999 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5000 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5001 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5002 /* ADC1: mute amp left and right */
5003 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5004 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
5005 /* ADC2: mute amp left and right */
5006 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5007 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
5008 /* ADC3: mute amp left and right */
5009 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5010 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
5015 static struct hda_verb alc882_eapd_verbs[] = {
5016 /* change to EAPD mode */
5017 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
5018 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
5023 static struct snd_kcontrol_new alc882_macpro_mixer[] = {
5024 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5025 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5026 HDA_CODEC_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT),
5027 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
5028 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
5029 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x02, HDA_INPUT),
5030 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x02, HDA_INPUT),
5034 static struct hda_verb alc882_macpro_init_verbs[] = {
5035 /* Front mixer: unmute input/output amp left and right (volume = 0) */
5036 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5037 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5038 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5039 /* Front Pin: output 0 (0x0c) */
5040 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5041 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5042 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
5043 /* Front Mic pin: input vref at 80% */
5044 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5045 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5046 /* Speaker: output */
5047 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5048 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5049 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x04},
5050 /* Headphone output (output 0 - 0x0c) */
5051 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5052 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5053 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
5055 /* FIXME: use matrix-type input source selection */
5056 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5057 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
5058 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5059 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5060 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5061 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5063 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5064 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5065 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5066 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5068 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5069 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5070 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5071 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5072 /* ADC1: mute amp left and right */
5073 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5074 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
5075 /* ADC2: mute amp left and right */
5076 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5077 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
5078 /* ADC3: mute amp left and right */
5079 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5080 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
5085 static struct hda_verb alc882_targa_verbs[] = {
5086 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5087 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5089 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5090 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5092 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
5093 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
5094 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
5096 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
5097 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
5098 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
5099 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
5103 /* toggle speaker-output according to the hp-jack state */
5104 static void alc882_targa_automute(struct hda_codec *codec)
5106 unsigned int present;
5108 present = snd_hda_codec_read(codec, 0x14, 0,
5109 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
5110 snd_hda_codec_amp_update(codec, 0x1b, 0, HDA_OUTPUT, 0,
5111 0x80, present ? 0x80 : 0);
5112 snd_hda_codec_amp_update(codec, 0x1b, 1, HDA_OUTPUT, 0,
5113 0x80, present ? 0x80 : 0);
5114 snd_hda_codec_write(codec, 1, 0, AC_VERB_SET_GPIO_DATA, present ? 1 : 3);
5117 static void alc882_targa_unsol_event(struct hda_codec *codec, unsigned int res)
5119 /* Looks like the unsol event is incompatible with the standard
5120 * definition. 4bit tag is placed at 26 bit!
5122 if (((res >> 26) == ALC880_HP_EVENT)) {
5123 alc882_targa_automute(codec);
5127 static struct hda_verb alc882_asus_a7j_verbs[] = {
5128 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5129 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5131 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5132 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5133 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5135 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
5136 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
5137 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
5139 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
5140 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
5141 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
5145 static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
5147 unsigned int gpiostate, gpiomask, gpiodir;
5149 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
5150 AC_VERB_GET_GPIO_DATA, 0);
5153 gpiostate |= (1 << pin);
5155 gpiostate &= ~(1 << pin);
5157 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
5158 AC_VERB_GET_GPIO_MASK, 0);
5159 gpiomask |= (1 << pin);
5161 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
5162 AC_VERB_GET_GPIO_DIRECTION, 0);
5163 gpiodir |= (1 << pin);
5166 snd_hda_codec_write(codec, codec->afg, 0,
5167 AC_VERB_SET_GPIO_MASK, gpiomask);
5168 snd_hda_codec_write(codec, codec->afg, 0,
5169 AC_VERB_SET_GPIO_DIRECTION, gpiodir);
5173 snd_hda_codec_write(codec, codec->afg, 0,
5174 AC_VERB_SET_GPIO_DATA, gpiostate);
5178 * generic initialization of ADC, input mixers and output mixers
5180 static struct hda_verb alc882_auto_init_verbs[] = {
5182 * Unmute ADC0-2 and set the default input to mic-in
5184 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
5185 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5186 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
5187 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5188 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
5189 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5191 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
5193 * Note: PASD motherboards uses the Line In 2 as the input for
5194 * front panel mic (mic 2)
5196 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
5197 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5198 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5199 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
5200 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
5201 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
5204 * Set up output mixers (0x0c - 0x0f)
5206 /* set vol=0 to output mixers */
5207 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5208 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5209 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5210 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5211 /* set up input amps for analog loopback */
5212 /* Amp Indices: DAC = 0, mixer = 1 */
5213 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5214 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5215 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5216 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5217 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5218 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5219 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5220 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5221 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5222 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5224 /* FIXME: use matrix-type input source selection */
5225 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5226 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
5227 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5228 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
5229 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
5230 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
5232 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5233 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
5234 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
5235 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
5237 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5238 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
5239 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
5240 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
5245 /* capture mixer elements */
5246 static struct snd_kcontrol_new alc882_capture_alt_mixer[] = {
5247 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
5248 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
5249 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
5250 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
5252 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5253 /* The multiple "Capture Source" controls confuse alsamixer
5254 * So call somewhat different..
5255 * FIXME: the controls appear in the "playback" view!
5257 /* .name = "Capture Source", */
5258 .name = "Input Source",
5260 .info = alc882_mux_enum_info,
5261 .get = alc882_mux_enum_get,
5262 .put = alc882_mux_enum_put,
5267 static struct snd_kcontrol_new alc882_capture_mixer[] = {
5268 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
5269 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
5270 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
5271 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
5272 HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
5273 HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
5275 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5276 /* The multiple "Capture Source" controls confuse alsamixer
5277 * So call somewhat different..
5278 * FIXME: the controls appear in the "playback" view!
5280 /* .name = "Capture Source", */
5281 .name = "Input Source",
5283 .info = alc882_mux_enum_info,
5284 .get = alc882_mux_enum_get,
5285 .put = alc882_mux_enum_put,
5290 /* pcm configuration: identiacal with ALC880 */
5291 #define alc882_pcm_analog_playback alc880_pcm_analog_playback
5292 #define alc882_pcm_analog_capture alc880_pcm_analog_capture
5293 #define alc882_pcm_digital_playback alc880_pcm_digital_playback
5294 #define alc882_pcm_digital_capture alc880_pcm_digital_capture
5297 * configuration and preset
5299 static const char *alc882_models[ALC882_MODEL_LAST] = {
5300 [ALC882_3ST_DIG] = "3stack-dig",
5301 [ALC882_6ST_DIG] = "6stack-dig",
5302 [ALC882_ARIMA] = "arima",
5303 [ALC882_W2JC] = "w2jc",
5304 [ALC885_MACPRO] = "macpro",
5305 [ALC882_AUTO] = "auto",
5308 static struct snd_pci_quirk alc882_cfg_tbl[] = {
5309 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG),
5310 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG),
5311 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG),
5312 SND_PCI_QUIRK(0x1462, 0x28fb, "Targa T8", ALC882_TARGA), /* MSI-1049 T8 */
5313 SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA),
5314 SND_PCI_QUIRK(0x1043, 0x060d, "Asus A7J", ALC882_ASUS_A7J),
5315 SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG),
5316 SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_W2JC),
5320 static struct alc_config_preset alc882_presets[] = {
5321 [ALC882_3ST_DIG] = {
5322 .mixers = { alc882_base_mixer },
5323 .init_verbs = { alc882_init_verbs },
5324 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5325 .dac_nids = alc882_dac_nids,
5326 .dig_out_nid = ALC882_DIGOUT_NID,
5327 .dig_in_nid = ALC882_DIGIN_NID,
5328 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
5329 .channel_mode = alc882_ch_modes,
5331 .input_mux = &alc882_capture_source,
5333 [ALC882_6ST_DIG] = {
5334 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
5335 .init_verbs = { alc882_init_verbs },
5336 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5337 .dac_nids = alc882_dac_nids,
5338 .dig_out_nid = ALC882_DIGOUT_NID,
5339 .dig_in_nid = ALC882_DIGIN_NID,
5340 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
5341 .channel_mode = alc882_sixstack_modes,
5342 .input_mux = &alc882_capture_source,
5345 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
5346 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs },
5347 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5348 .dac_nids = alc882_dac_nids,
5349 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
5350 .channel_mode = alc882_sixstack_modes,
5351 .input_mux = &alc882_capture_source,
5354 .mixers = { alc882_w2jc_mixer, alc882_chmode_mixer },
5355 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs,
5356 alc880_gpio1_init_verbs },
5357 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5358 .dac_nids = alc882_dac_nids,
5359 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
5360 .channel_mode = alc880_threestack_modes,
5362 .input_mux = &alc882_capture_source,
5363 .dig_out_nid = ALC882_DIGOUT_NID,
5366 .mixers = { alc882_macpro_mixer },
5367 .init_verbs = { alc882_macpro_init_verbs },
5368 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5369 .dac_nids = alc882_dac_nids,
5370 .dig_out_nid = ALC882_DIGOUT_NID,
5371 .dig_in_nid = ALC882_DIGIN_NID,
5372 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
5373 .channel_mode = alc882_ch_modes,
5374 .input_mux = &alc882_capture_source,
5377 .mixers = { alc882_targa_mixer, alc882_chmode_mixer,
5378 alc882_capture_mixer },
5379 .init_verbs = { alc882_init_verbs, alc882_targa_verbs},
5380 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5381 .dac_nids = alc882_dac_nids,
5382 .dig_out_nid = ALC882_DIGOUT_NID,
5383 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
5384 .adc_nids = alc882_adc_nids,
5385 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
5386 .channel_mode = alc882_3ST_6ch_modes,
5388 .input_mux = &alc882_capture_source,
5389 .unsol_event = alc882_targa_unsol_event,
5390 .init_hook = alc882_targa_automute,
5392 [ALC882_ASUS_A7J] = {
5393 .mixers = { alc882_asus_a7j_mixer, alc882_chmode_mixer,
5394 alc882_capture_mixer },
5395 .init_verbs = { alc882_init_verbs, alc882_asus_a7j_verbs},
5396 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5397 .dac_nids = alc882_dac_nids,
5398 .dig_out_nid = ALC882_DIGOUT_NID,
5399 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
5400 .adc_nids = alc882_adc_nids,
5401 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
5402 .channel_mode = alc882_3ST_6ch_modes,
5404 .input_mux = &alc882_capture_source,
5410 * BIOS auto configuration
5412 static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
5413 hda_nid_t nid, int pin_type,
5417 struct alc_spec *spec = codec->spec;
5420 if (spec->multiout.dac_nids[dac_idx] == 0x25)
5423 idx = spec->multiout.dac_nids[dac_idx] - 2;
5425 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5427 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
5429 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
5433 static void alc882_auto_init_multi_out(struct hda_codec *codec)
5435 struct alc_spec *spec = codec->spec;
5438 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
5439 for (i = 0; i <= HDA_SIDE; i++) {
5440 hda_nid_t nid = spec->autocfg.line_out_pins[i];
5441 int pin_type = get_pin_type(spec->autocfg.line_out_type);
5443 alc882_auto_set_output_and_unmute(codec, nid, pin_type,
5448 static void alc882_auto_init_hp_out(struct hda_codec *codec)
5450 struct alc_spec *spec = codec->spec;
5453 pin = spec->autocfg.hp_pins[0];
5454 if (pin) /* connect to front */
5456 alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
5459 #define alc882_is_input_pin(nid) alc880_is_input_pin(nid)
5460 #define ALC882_PIN_CD_NID ALC880_PIN_CD_NID
5462 static void alc882_auto_init_analog_input(struct hda_codec *codec)
5464 struct alc_spec *spec = codec->spec;
5467 for (i = 0; i < AUTO_PIN_LAST; i++) {
5468 hda_nid_t nid = spec->autocfg.input_pins[i];
5469 if (alc882_is_input_pin(nid)) {
5470 snd_hda_codec_write(codec, nid, 0,
5471 AC_VERB_SET_PIN_WIDGET_CONTROL,
5472 i <= AUTO_PIN_FRONT_MIC ?
5473 PIN_VREF80 : PIN_IN);
5474 if (nid != ALC882_PIN_CD_NID)
5475 snd_hda_codec_write(codec, nid, 0,
5476 AC_VERB_SET_AMP_GAIN_MUTE,
5482 /* almost identical with ALC880 parser... */
5483 static int alc882_parse_auto_config(struct hda_codec *codec)
5485 struct alc_spec *spec = codec->spec;
5486 int err = alc880_parse_auto_config(codec);
5491 /* hack - override the init verbs */
5492 spec->init_verbs[0] = alc882_auto_init_verbs;
5496 /* additional initialization for auto-configuration model */
5497 static void alc882_auto_init(struct hda_codec *codec)
5499 alc882_auto_init_multi_out(codec);
5500 alc882_auto_init_hp_out(codec);
5501 alc882_auto_init_analog_input(codec);
5504 static int patch_alc882(struct hda_codec *codec)
5506 struct alc_spec *spec;
5507 int err, board_config;
5509 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5515 board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST,
5519 if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
5520 /* Pick up systems that don't supply PCI SSID */
5521 switch (codec->subsystem_id) {
5522 case 0x106b0c00: /* Mac Pro */
5523 board_config = ALC885_MACPRO;
5526 printk(KERN_INFO "hda_codec: Unknown model for ALC882, "
5527 "trying auto-probe from BIOS...\n");
5528 board_config = ALC882_AUTO;
5532 if (board_config == ALC882_AUTO) {
5533 /* automatic parse from the BIOS config */
5534 err = alc882_parse_auto_config(codec);
5540 "hda_codec: Cannot set up configuration "
5541 "from BIOS. Using base mode...\n");
5542 board_config = ALC882_3ST_DIG;
5546 if (board_config != ALC882_AUTO)
5547 setup_preset(spec, &alc882_presets[board_config]);
5549 if (board_config == ALC885_MACPRO) {
5550 alc882_gpio_mute(codec, 0, 0);
5551 alc882_gpio_mute(codec, 1, 0);
5554 spec->stream_name_analog = "ALC882 Analog";
5555 spec->stream_analog_playback = &alc882_pcm_analog_playback;
5556 spec->stream_analog_capture = &alc882_pcm_analog_capture;
5558 spec->stream_name_digital = "ALC882 Digital";
5559 spec->stream_digital_playback = &alc882_pcm_digital_playback;
5560 spec->stream_digital_capture = &alc882_pcm_digital_capture;
5562 if (!spec->adc_nids && spec->input_mux) {
5563 /* check whether NID 0x07 is valid */
5564 unsigned int wcap = get_wcaps(codec, 0x07);
5566 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
5567 if (wcap != AC_WID_AUD_IN) {
5568 spec->adc_nids = alc882_adc_nids_alt;
5569 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids_alt);
5570 spec->mixers[spec->num_mixers] =
5571 alc882_capture_alt_mixer;
5574 spec->adc_nids = alc882_adc_nids;
5575 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids);
5576 spec->mixers[spec->num_mixers] = alc882_capture_mixer;
5581 codec->patch_ops = alc_patch_ops;
5582 if (board_config == ALC882_AUTO)
5583 spec->init_hook = alc882_auto_init;
5591 * ALC883 is almost identical with ALC880 but has cleaner and more flexible
5592 * configuration. Each pin widget can choose any input DACs and a mixer.
5593 * Each ADC is connected from a mixer of all inputs. This makes possible
5594 * 6-channel independent captures.
5596 * In addition, an independent DAC for the multi-playback (not used in this
5599 #define ALC883_DIGOUT_NID 0x06
5600 #define ALC883_DIGIN_NID 0x0a
5602 static hda_nid_t alc883_dac_nids[4] = {
5603 /* front, rear, clfe, rear_surr */
5604 0x02, 0x04, 0x03, 0x05
5607 static hda_nid_t alc883_adc_nids[2] = {
5613 /* FIXME: should be a matrix-type input source selection */
5615 static struct hda_input_mux alc883_capture_source = {
5619 { "Front Mic", 0x1 },
5625 static struct hda_input_mux alc883_lenovo_101e_capture_source = {
5633 static struct hda_input_mux alc883_lenovo_nb0763_capture_source = {
5643 #define alc883_mux_enum_info alc_mux_enum_info
5644 #define alc883_mux_enum_get alc_mux_enum_get
5646 static int alc883_mux_enum_put(struct snd_kcontrol *kcontrol,
5647 struct snd_ctl_elem_value *ucontrol)
5649 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
5650 struct alc_spec *spec = codec->spec;
5651 const struct hda_input_mux *imux = spec->input_mux;
5652 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
5653 static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
5654 hda_nid_t nid = capture_mixers[adc_idx];
5655 unsigned int *cur_val = &spec->cur_mux[adc_idx];
5656 unsigned int i, idx;
5658 idx = ucontrol->value.enumerated.item[0];
5659 if (idx >= imux->num_items)
5660 idx = imux->num_items - 1;
5661 if (*cur_val == idx && !codec->in_resume)
5663 for (i = 0; i < imux->num_items; i++) {
5664 unsigned int v = (i == idx) ? 0x7000 : 0x7080;
5665 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
5666 v | (imux->items[i].index << 8));
5675 static struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
5682 static struct hda_verb alc883_3ST_ch2_init[] = {
5683 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
5684 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
5685 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
5686 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
5693 static struct hda_verb alc883_3ST_ch6_init[] = {
5694 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5695 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
5696 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
5697 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5698 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
5699 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
5703 static struct hda_channel_mode alc883_3ST_6ch_modes[2] = {
5704 { 2, alc883_3ST_ch2_init },
5705 { 6, alc883_3ST_ch6_init },
5711 static struct hda_verb alc883_sixstack_ch6_init[] = {
5712 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
5713 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5714 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5715 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5722 static struct hda_verb alc883_sixstack_ch8_init[] = {
5723 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5724 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5725 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5726 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5730 static struct hda_channel_mode alc883_sixstack_modes[2] = {
5731 { 6, alc883_sixstack_ch6_init },
5732 { 8, alc883_sixstack_ch8_init },
5735 static struct hda_verb alc883_medion_eapd_verbs[] = {
5736 /* eanable EAPD on medion laptop */
5737 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
5738 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
5742 /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
5743 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
5746 static struct snd_kcontrol_new alc883_base_mixer[] = {
5747 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5748 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5749 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
5750 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
5751 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
5752 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
5753 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
5754 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
5755 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
5756 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
5757 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5758 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5759 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5760 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5761 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5762 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5763 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
5764 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5765 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
5766 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
5767 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
5768 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
5769 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
5770 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
5771 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
5772 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
5773 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
5775 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5776 /* .name = "Capture Source", */
5777 .name = "Input Source",
5779 .info = alc883_mux_enum_info,
5780 .get = alc883_mux_enum_get,
5781 .put = alc883_mux_enum_put,
5786 static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
5787 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5788 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5789 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5790 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5791 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5792 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5793 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5794 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5795 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
5796 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5797 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
5798 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
5799 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
5800 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
5801 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
5802 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
5803 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
5804 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
5805 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
5807 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5808 /* .name = "Capture Source", */
5809 .name = "Input Source",
5811 .info = alc883_mux_enum_info,
5812 .get = alc883_mux_enum_get,
5813 .put = alc883_mux_enum_put,
5818 static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
5819 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5820 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5821 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
5822 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
5823 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
5824 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
5825 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
5826 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
5827 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5828 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5829 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5830 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5831 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5832 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5833 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
5834 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5835 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
5836 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
5837 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
5838 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
5839 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
5840 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
5841 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
5842 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
5843 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
5845 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5846 /* .name = "Capture Source", */
5847 .name = "Input Source",
5849 .info = alc883_mux_enum_info,
5850 .get = alc883_mux_enum_get,
5851 .put = alc883_mux_enum_put,
5856 static struct snd_kcontrol_new alc883_fivestack_mixer[] = {
5857 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5858 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
5859 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
5860 HDA_CODEC_MUTE("Surround Playback Switch", 0x15, 0x0, HDA_OUTPUT),
5861 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
5862 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
5863 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x16, 1, 0x0, HDA_OUTPUT),
5864 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
5865 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5866 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5867 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5868 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5869 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5870 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5871 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
5872 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5873 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
5874 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
5875 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
5876 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
5877 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
5878 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
5879 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
5882 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5883 /* .name = "Capture Source", */
5884 .name = "Input Source",
5886 .info = alc883_mux_enum_info,
5887 .get = alc883_mux_enum_get,
5888 .put = alc883_mux_enum_put,
5893 static struct snd_kcontrol_new alc883_tagra_mixer[] = {
5894 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5895 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
5896 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5897 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
5898 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
5899 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
5900 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
5901 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
5902 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
5903 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5904 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5905 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5906 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5907 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5908 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
5909 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5910 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
5911 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
5912 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
5913 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
5915 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5916 /* .name = "Capture Source", */
5917 .name = "Input Source",
5919 .info = alc883_mux_enum_info,
5920 .get = alc883_mux_enum_get,
5921 .put = alc883_mux_enum_put,
5926 static struct snd_kcontrol_new alc883_tagra_2ch_mixer[] = {
5927 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5928 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
5929 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5930 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5931 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5932 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5933 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
5934 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5935 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
5936 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
5937 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
5938 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
5940 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5941 /* .name = "Capture Source", */
5942 .name = "Input Source",
5944 .info = alc883_mux_enum_info,
5945 .get = alc883_mux_enum_get,
5946 .put = alc883_mux_enum_put,
5951 static struct snd_kcontrol_new alc883_lenovo_101e_2ch_mixer[] = {
5952 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5953 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5954 HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
5955 HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT),
5956 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5957 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
5958 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
5959 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
5960 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
5961 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
5963 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5964 /* .name = "Capture Source", */
5965 .name = "Input Source",
5967 .info = alc883_mux_enum_info,
5968 .get = alc883_mux_enum_get,
5969 .put = alc883_mux_enum_put,
5974 static struct snd_kcontrol_new alc883_lenovo_nb0763_mixer[] = {
5975 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5976 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
5977 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
5978 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5979 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5980 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5981 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5982 HDA_CODEC_VOLUME("iMic Playback Volume", 0x0b, 0x1, HDA_INPUT),
5983 HDA_CODEC_MUTE("iMic Playback Switch", 0x0b, 0x1, HDA_INPUT),
5984 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
5985 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
5986 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
5987 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
5989 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5990 /* .name = "Capture Source", */
5991 .name = "Input Source",
5993 .info = alc883_mux_enum_info,
5994 .get = alc883_mux_enum_get,
5995 .put = alc883_mux_enum_put,
6000 static struct snd_kcontrol_new alc883_medion_md2_mixer[] = {
6001 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6002 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6003 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
6004 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6005 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6006 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6007 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6008 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6009 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6010 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6011 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6012 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6013 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6015 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6016 /* .name = "Capture Source", */
6017 .name = "Input Source",
6019 .info = alc883_mux_enum_info,
6020 .get = alc883_mux_enum_get,
6021 .put = alc883_mux_enum_put,
6026 static struct snd_kcontrol_new alc883_chmode_mixer[] = {
6028 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6029 .name = "Channel Mode",
6030 .info = alc_ch_mode_info,
6031 .get = alc_ch_mode_get,
6032 .put = alc_ch_mode_put,
6037 static struct hda_verb alc883_init_verbs[] = {
6038 /* ADC1: mute amp left and right */
6039 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6040 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6041 /* ADC2: mute amp left and right */
6042 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6043 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
6044 /* Front mixer: unmute input/output amp left and right (volume = 0) */
6045 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6046 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6047 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6049 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6050 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6051 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6053 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6054 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6055 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6057 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6058 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6059 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6061 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6062 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6063 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
6064 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
6065 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
6067 /* Front Pin: output 0 (0x0c) */
6068 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6069 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6070 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
6071 /* Rear Pin: output 1 (0x0d) */
6072 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6073 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6074 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
6075 /* CLFE Pin: output 2 (0x0e) */
6076 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6077 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6078 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
6079 /* Side Pin: output 3 (0x0f) */
6080 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6081 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6082 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
6083 /* Mic (rear) pin: input vref at 80% */
6084 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6085 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6086 /* Front Mic pin: input vref at 80% */
6087 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6088 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6089 /* Line In pin: input */
6090 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
6091 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6092 /* Line-2 In: Headphone output (output 0 - 0x0c) */
6093 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6094 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6095 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
6096 /* CD pin widget for input */
6097 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
6099 /* FIXME: use matrix-type input source selection */
6100 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6102 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6103 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6104 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
6105 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
6107 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6108 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6109 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
6110 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
6114 static struct hda_verb alc883_tagra_verbs[] = {
6115 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6116 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6118 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6119 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6121 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
6122 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
6123 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6125 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
6126 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
6127 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
6128 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
6133 static struct hda_verb alc883_lenovo_101e_verbs[] = {
6134 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
6135 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT|AC_USRSP_EN},
6136 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT|AC_USRSP_EN},
6140 static struct hda_verb alc883_lenovo_nb0763_verbs[] = {
6141 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
6142 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6143 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
6144 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6148 static struct hda_verb alc888_lenovo_ms7195_verbs[] = {
6149 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6150 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6151 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
6152 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT | AC_USRSP_EN},
6153 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
6157 /* toggle front-jack and RCA according to the hp-jack state */
6158 static void alc888_lenovo_ms7195_front_automute(struct hda_codec *codec)
6160 unsigned int present;
6162 present = snd_hda_codec_read(codec, 0x1b, 0,
6163 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
6164 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
6165 0x80, present ? 0x80 : 0);
6166 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
6167 0x80, present ? 0x80 : 0);
6168 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
6169 0x80, present ? 0x80 : 0);
6170 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
6171 0x80, present ? 0x80 : 0);
6175 /* toggle RCA according to the front-jack state */
6176 static void alc888_lenovo_ms7195_rca_automute(struct hda_codec *codec)
6178 unsigned int present;
6180 present = snd_hda_codec_read(codec, 0x14, 0,
6181 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
6182 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
6183 0x80, present ? 0x80 : 0);
6184 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
6185 0x80, present ? 0x80 : 0);
6188 static void alc883_lenovo_ms7195_unsol_event(struct hda_codec *codec,
6191 if ((res >> 26) == ALC880_HP_EVENT)
6192 alc888_lenovo_ms7195_front_automute(codec);
6193 if ((res >> 26) == ALC880_FRONT_EVENT)
6194 alc888_lenovo_ms7195_rca_automute(codec);
6197 static struct hda_verb alc883_medion_md2_verbs[] = {
6198 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6199 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6201 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6203 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
6207 /* toggle speaker-output according to the hp-jack state */
6208 static void alc883_medion_md2_automute(struct hda_codec *codec)
6210 unsigned int present;
6212 present = snd_hda_codec_read(codec, 0x14, 0,
6213 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
6214 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
6215 0x80, present ? 0x80 : 0);
6216 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
6217 0x80, present ? 0x80 : 0);
6220 static void alc883_medion_md2_unsol_event(struct hda_codec *codec,
6223 if ((res >> 26) == ALC880_HP_EVENT)
6224 alc883_medion_md2_automute(codec);
6227 /* toggle speaker-output according to the hp-jack state */
6228 static void alc883_tagra_automute(struct hda_codec *codec)
6230 unsigned int present;
6233 present = snd_hda_codec_read(codec, 0x14, 0,
6234 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
6235 bits = present ? 0x80 : 0;
6236 snd_hda_codec_amp_update(codec, 0x1b, 0, HDA_OUTPUT, 0,
6238 snd_hda_codec_amp_update(codec, 0x1b, 1, HDA_OUTPUT, 0,
6240 snd_hda_codec_write(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
6244 static void alc883_tagra_unsol_event(struct hda_codec *codec, unsigned int res)
6246 if ((res >> 26) == ALC880_HP_EVENT)
6247 alc883_tagra_automute(codec);
6250 static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
6252 unsigned int present;
6255 present = snd_hda_codec_read(codec, 0x14, 0,
6256 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
6257 bits = present ? 0x80 : 0;
6258 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
6260 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
6264 static void alc883_lenovo_101e_all_automute(struct hda_codec *codec)
6266 unsigned int present;
6269 present = snd_hda_codec_read(codec, 0x1b, 0,
6270 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
6271 bits = present ? 0x80 : 0;
6272 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
6274 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
6276 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
6278 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
6282 static void alc883_lenovo_101e_unsol_event(struct hda_codec *codec,
6285 if ((res >> 26) == ALC880_HP_EVENT)
6286 alc883_lenovo_101e_all_automute(codec);
6287 if ((res >> 26) == ALC880_FRONT_EVENT)
6288 alc883_lenovo_101e_ispeaker_automute(codec);
6292 * generic initialization of ADC, input mixers and output mixers
6294 static struct hda_verb alc883_auto_init_verbs[] = {
6296 * Unmute ADC0-2 and set the default input to mic-in
6298 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6299 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6300 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
6301 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6303 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
6305 * Note: PASD motherboards uses the Line In 2 as the input for
6306 * front panel mic (mic 2)
6308 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
6309 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6310 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6311 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
6312 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
6313 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
6316 * Set up output mixers (0x0c - 0x0f)
6318 /* set vol=0 to output mixers */
6319 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6320 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6321 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6322 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6323 /* set up input amps for analog loopback */
6324 /* Amp Indices: DAC = 0, mixer = 1 */
6325 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6326 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6327 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6328 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6329 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6330 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6331 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6332 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6333 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6334 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6336 /* FIXME: use matrix-type input source selection */
6337 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6339 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6340 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6341 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
6342 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
6343 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
6345 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6346 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6347 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
6348 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
6349 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
6354 /* capture mixer elements */
6355 static struct snd_kcontrol_new alc883_capture_mixer[] = {
6356 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6357 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6358 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6359 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6361 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6362 /* The multiple "Capture Source" controls confuse alsamixer
6363 * So call somewhat different..
6364 * FIXME: the controls appear in the "playback" view!
6366 /* .name = "Capture Source", */
6367 .name = "Input Source",
6369 .info = alc882_mux_enum_info,
6370 .get = alc882_mux_enum_get,
6371 .put = alc882_mux_enum_put,
6376 /* pcm configuration: identiacal with ALC880 */
6377 #define alc883_pcm_analog_playback alc880_pcm_analog_playback
6378 #define alc883_pcm_analog_capture alc880_pcm_analog_capture
6379 #define alc883_pcm_digital_playback alc880_pcm_digital_playback
6380 #define alc883_pcm_digital_capture alc880_pcm_digital_capture
6383 * configuration and preset
6385 static const char *alc883_models[ALC883_MODEL_LAST] = {
6386 [ALC883_3ST_2ch_DIG] = "3stack-dig",
6387 [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig",
6388 [ALC883_3ST_6ch] = "3stack-6ch",
6389 [ALC883_6ST_DIG] = "6stack-dig",
6390 [ALC883_TARGA_DIG] = "targa-dig",
6391 [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig",
6392 [ALC883_ACER] = "acer",
6393 [ALC883_MEDION] = "medion",
6394 [ALC883_MEDION_MD2] = "medion-md2",
6395 [ALC883_LAPTOP_EAPD] = "laptop-eapd",
6396 [ALC883_LENOVO_101E_2ch] = "lenovo-101e",
6397 [ALC883_LENOVO_NB0763] = "lenovo-nb0763",
6398 [ALC888_LENOVO_MS7195_DIG] = "lenovo-ms7195-dig",
6399 [ALC883_AUTO] = "auto",
6402 static struct snd_pci_quirk alc883_cfg_tbl[] = {
6403 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC883_3ST_6ch_DIG),
6404 SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG),
6405 SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch),
6406 SND_PCI_QUIRK(0x1558, 0, "Clevo laptop", ALC883_LAPTOP_EAPD),
6407 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC883_6ST_DIG),
6408 SND_PCI_QUIRK(0x1458, 0xa002, "MSI", ALC883_6ST_DIG),
6409 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG),
6410 SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG),
6411 SND_PCI_QUIRK(0x1462, 0x7250, "MSI", ALC883_6ST_DIG),
6412 SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG),
6413 SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG),
6414 SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG),
6415 SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG),
6416 SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG),
6417 SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG),
6418 SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG),
6419 SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG),
6420 SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG),
6421 SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG),
6422 SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG),
6423 SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG),
6424 SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG),
6425 SND_PCI_QUIRK(0x1025, 0, "Acer laptop", ALC883_ACER),
6426 SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch),
6427 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
6428 SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD),
6429 SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC883_3ST_6ch),
6430 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch),
6431 SND_PCI_QUIRK(0x17aa, 0x3bfd, "Lenovo NB0763", ALC883_LENOVO_NB0763),
6432 SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763),
6433 SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC883_6ST_DIG),
6434 SND_PCI_QUIRK(0x17c0, 0x4071, "MEDION MD2", ALC883_MEDION_MD2),
6438 static struct alc_config_preset alc883_presets[] = {
6439 [ALC883_3ST_2ch_DIG] = {
6440 .mixers = { alc883_3ST_2ch_mixer },
6441 .init_verbs = { alc883_init_verbs },
6442 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6443 .dac_nids = alc883_dac_nids,
6444 .dig_out_nid = ALC883_DIGOUT_NID,
6445 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6446 .adc_nids = alc883_adc_nids,
6447 .dig_in_nid = ALC883_DIGIN_NID,
6448 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
6449 .channel_mode = alc883_3ST_2ch_modes,
6450 .input_mux = &alc883_capture_source,
6452 [ALC883_3ST_6ch_DIG] = {
6453 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
6454 .init_verbs = { alc883_init_verbs },
6455 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6456 .dac_nids = alc883_dac_nids,
6457 .dig_out_nid = ALC883_DIGOUT_NID,
6458 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6459 .adc_nids = alc883_adc_nids,
6460 .dig_in_nid = ALC883_DIGIN_NID,
6461 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
6462 .channel_mode = alc883_3ST_6ch_modes,
6464 .input_mux = &alc883_capture_source,
6466 [ALC883_3ST_6ch] = {
6467 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
6468 .init_verbs = { alc883_init_verbs },
6469 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6470 .dac_nids = alc883_dac_nids,
6471 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6472 .adc_nids = alc883_adc_nids,
6473 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
6474 .channel_mode = alc883_3ST_6ch_modes,
6476 .input_mux = &alc883_capture_source,
6478 [ALC883_6ST_DIG] = {
6479 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
6480 .init_verbs = { alc883_init_verbs },
6481 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6482 .dac_nids = alc883_dac_nids,
6483 .dig_out_nid = ALC883_DIGOUT_NID,
6484 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6485 .adc_nids = alc883_adc_nids,
6486 .dig_in_nid = ALC883_DIGIN_NID,
6487 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
6488 .channel_mode = alc883_sixstack_modes,
6489 .input_mux = &alc883_capture_source,
6491 [ALC883_TARGA_DIG] = {
6492 .mixers = { alc883_tagra_mixer, alc883_chmode_mixer },
6493 .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
6494 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6495 .dac_nids = alc883_dac_nids,
6496 .dig_out_nid = ALC883_DIGOUT_NID,
6497 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6498 .adc_nids = alc883_adc_nids,
6499 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
6500 .channel_mode = alc883_3ST_6ch_modes,
6502 .input_mux = &alc883_capture_source,
6503 .unsol_event = alc883_tagra_unsol_event,
6504 .init_hook = alc883_tagra_automute,
6506 [ALC883_TARGA_2ch_DIG] = {
6507 .mixers = { alc883_tagra_2ch_mixer},
6508 .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
6509 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6510 .dac_nids = alc883_dac_nids,
6511 .dig_out_nid = ALC883_DIGOUT_NID,
6512 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6513 .adc_nids = alc883_adc_nids,
6514 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
6515 .channel_mode = alc883_3ST_2ch_modes,
6516 .input_mux = &alc883_capture_source,
6517 .unsol_event = alc883_tagra_unsol_event,
6518 .init_hook = alc883_tagra_automute,
6521 .mixers = { alc883_base_mixer,
6522 alc883_chmode_mixer },
6523 /* On TravelMate laptops, GPIO 0 enables the internal speaker
6524 * and the headphone jack. Turn this on and rely on the
6525 * standard mute methods whenever the user wants to turn
6526 * these outputs off.
6528 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs },
6529 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6530 .dac_nids = alc883_dac_nids,
6531 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6532 .adc_nids = alc883_adc_nids,
6533 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
6534 .channel_mode = alc883_3ST_2ch_modes,
6535 .input_mux = &alc883_capture_source,
6538 .mixers = { alc883_fivestack_mixer,
6539 alc883_chmode_mixer },
6540 .init_verbs = { alc883_init_verbs,
6541 alc883_medion_eapd_verbs },
6542 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6543 .dac_nids = alc883_dac_nids,
6544 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6545 .adc_nids = alc883_adc_nids,
6546 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
6547 .channel_mode = alc883_sixstack_modes,
6548 .input_mux = &alc883_capture_source,
6550 [ALC883_MEDION_MD2] = {
6551 .mixers = { alc883_medion_md2_mixer},
6552 .init_verbs = { alc883_init_verbs, alc883_medion_md2_verbs},
6553 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6554 .dac_nids = alc883_dac_nids,
6555 .dig_out_nid = ALC883_DIGOUT_NID,
6556 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6557 .adc_nids = alc883_adc_nids,
6558 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
6559 .channel_mode = alc883_3ST_2ch_modes,
6560 .input_mux = &alc883_capture_source,
6561 .unsol_event = alc883_medion_md2_unsol_event,
6562 .init_hook = alc883_medion_md2_automute,
6564 [ALC883_LAPTOP_EAPD] = {
6565 .mixers = { alc883_base_mixer,
6566 alc883_chmode_mixer },
6567 .init_verbs = { alc883_init_verbs, alc882_eapd_verbs },
6568 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6569 .dac_nids = alc883_dac_nids,
6570 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6571 .adc_nids = alc883_adc_nids,
6572 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
6573 .channel_mode = alc883_3ST_2ch_modes,
6574 .input_mux = &alc883_capture_source,
6576 [ALC883_LENOVO_101E_2ch] = {
6577 .mixers = { alc883_lenovo_101e_2ch_mixer},
6578 .init_verbs = { alc883_init_verbs, alc883_lenovo_101e_verbs},
6579 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6580 .dac_nids = alc883_dac_nids,
6581 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6582 .adc_nids = alc883_adc_nids,
6583 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
6584 .channel_mode = alc883_3ST_2ch_modes,
6585 .input_mux = &alc883_lenovo_101e_capture_source,
6586 .unsol_event = alc883_lenovo_101e_unsol_event,
6587 .init_hook = alc883_lenovo_101e_all_automute,
6589 [ALC883_LENOVO_NB0763] = {
6590 .mixers = { alc883_lenovo_nb0763_mixer },
6591 .init_verbs = { alc883_init_verbs, alc883_lenovo_nb0763_verbs},
6592 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6593 .dac_nids = alc883_dac_nids,
6594 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6595 .adc_nids = alc883_adc_nids,
6596 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
6597 .channel_mode = alc883_3ST_2ch_modes,
6599 .input_mux = &alc883_lenovo_nb0763_capture_source,
6600 .unsol_event = alc883_medion_md2_unsol_event,
6601 .init_hook = alc883_medion_md2_automute,
6603 [ALC888_LENOVO_MS7195_DIG] = {
6604 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
6605 .init_verbs = { alc883_init_verbs, alc888_lenovo_ms7195_verbs},
6606 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6607 .dac_nids = alc883_dac_nids,
6608 .dig_out_nid = ALC883_DIGOUT_NID,
6609 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6610 .adc_nids = alc883_adc_nids,
6611 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
6612 .channel_mode = alc883_3ST_6ch_modes,
6614 .input_mux = &alc883_capture_source,
6615 .unsol_event = alc883_lenovo_ms7195_unsol_event,
6616 .init_hook = alc888_lenovo_ms7195_front_automute,
6622 * BIOS auto configuration
6624 static void alc883_auto_set_output_and_unmute(struct hda_codec *codec,
6625 hda_nid_t nid, int pin_type,
6629 struct alc_spec *spec = codec->spec;
6632 if (spec->multiout.dac_nids[dac_idx] == 0x25)
6635 idx = spec->multiout.dac_nids[dac_idx] - 2;
6637 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
6639 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
6641 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
6645 static void alc883_auto_init_multi_out(struct hda_codec *codec)
6647 struct alc_spec *spec = codec->spec;
6650 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
6651 for (i = 0; i <= HDA_SIDE; i++) {
6652 hda_nid_t nid = spec->autocfg.line_out_pins[i];
6653 int pin_type = get_pin_type(spec->autocfg.line_out_type);
6655 alc883_auto_set_output_and_unmute(codec, nid, pin_type,
6660 static void alc883_auto_init_hp_out(struct hda_codec *codec)
6662 struct alc_spec *spec = codec->spec;
6665 pin = spec->autocfg.hp_pins[0];
6666 if (pin) /* connect to front */
6668 alc883_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
6671 #define alc883_is_input_pin(nid) alc880_is_input_pin(nid)
6672 #define ALC883_PIN_CD_NID ALC880_PIN_CD_NID
6674 static void alc883_auto_init_analog_input(struct hda_codec *codec)
6676 struct alc_spec *spec = codec->spec;
6679 for (i = 0; i < AUTO_PIN_LAST; i++) {
6680 hda_nid_t nid = spec->autocfg.input_pins[i];
6681 if (alc883_is_input_pin(nid)) {
6682 snd_hda_codec_write(codec, nid, 0,
6683 AC_VERB_SET_PIN_WIDGET_CONTROL,
6684 (i <= AUTO_PIN_FRONT_MIC ?
6685 PIN_VREF80 : PIN_IN));
6686 if (nid != ALC883_PIN_CD_NID)
6687 snd_hda_codec_write(codec, nid, 0,
6688 AC_VERB_SET_AMP_GAIN_MUTE,
6694 /* almost identical with ALC880 parser... */
6695 static int alc883_parse_auto_config(struct hda_codec *codec)
6697 struct alc_spec *spec = codec->spec;
6698 int err = alc880_parse_auto_config(codec);
6703 /* hack - override the init verbs */
6704 spec->init_verbs[0] = alc883_auto_init_verbs;
6705 spec->mixers[spec->num_mixers] = alc883_capture_mixer;
6710 /* additional initialization for auto-configuration model */
6711 static void alc883_auto_init(struct hda_codec *codec)
6713 alc883_auto_init_multi_out(codec);
6714 alc883_auto_init_hp_out(codec);
6715 alc883_auto_init_analog_input(codec);
6718 static int patch_alc883(struct hda_codec *codec)
6720 struct alc_spec *spec;
6721 int err, board_config;
6723 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
6729 board_config = snd_hda_check_board_config(codec, ALC883_MODEL_LAST,
6732 if (board_config < 0) {
6733 printk(KERN_INFO "hda_codec: Unknown model for ALC883, "
6734 "trying auto-probe from BIOS...\n");
6735 board_config = ALC883_AUTO;
6738 if (board_config == ALC883_AUTO) {
6739 /* automatic parse from the BIOS config */
6740 err = alc883_parse_auto_config(codec);
6746 "hda_codec: Cannot set up configuration "
6747 "from BIOS. Using base mode...\n");
6748 board_config = ALC883_3ST_2ch_DIG;
6752 if (board_config != ALC883_AUTO)
6753 setup_preset(spec, &alc883_presets[board_config]);
6755 spec->stream_name_analog = "ALC883 Analog";
6756 spec->stream_analog_playback = &alc883_pcm_analog_playback;
6757 spec->stream_analog_capture = &alc883_pcm_analog_capture;
6759 spec->stream_name_digital = "ALC883 Digital";
6760 spec->stream_digital_playback = &alc883_pcm_digital_playback;
6761 spec->stream_digital_capture = &alc883_pcm_digital_capture;
6763 if (!spec->adc_nids && spec->input_mux) {
6764 spec->adc_nids = alc883_adc_nids;
6765 spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids);
6768 codec->patch_ops = alc_patch_ops;
6769 if (board_config == ALC883_AUTO)
6770 spec->init_hook = alc883_auto_init;
6779 #define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
6780 #define ALC262_DIGIN_NID ALC880_DIGIN_NID
6782 #define alc262_dac_nids alc260_dac_nids
6783 #define alc262_adc_nids alc882_adc_nids
6784 #define alc262_adc_nids_alt alc882_adc_nids_alt
6786 #define alc262_modes alc260_modes
6787 #define alc262_capture_source alc882_capture_source
6789 static struct snd_kcontrol_new alc262_base_mixer[] = {
6790 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6791 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6792 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6793 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6794 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6795 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6796 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6797 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6798 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6799 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
6800 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
6801 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
6802 /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
6803 HDA_CODEC_MUTE("PC Beelp Playback Switch", 0x0b, 0x05, HDA_INPUT), */
6804 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
6805 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
6806 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
6807 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
6811 static struct snd_kcontrol_new alc262_hippo1_mixer[] = {
6812 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6813 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6814 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6815 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6816 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6817 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
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("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
6825 HDA_CODEC_MUTE("PC Beelp Playback Switch", 0x0b, 0x05, HDA_INPUT), */
6826 /*HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),*/
6827 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6831 static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
6832 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6833 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
6834 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6835 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
6836 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
6838 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6839 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6840 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6841 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
6842 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
6843 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
6844 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6845 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6846 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6847 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6848 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
6849 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
6850 HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
6851 HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
6855 static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = {
6856 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6857 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6858 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
6859 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
6860 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
6861 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
6862 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x02, HDA_INPUT),
6863 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x02, HDA_INPUT),
6864 HDA_CODEC_VOLUME("Front Mic Boost", 0x1a, 0, HDA_INPUT),
6865 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
6866 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
6867 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6868 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6869 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
6870 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
6874 static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = {
6875 HDA_CODEC_VOLUME("Rear Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6876 HDA_CODEC_MUTE("Rear Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6877 HDA_CODEC_VOLUME("Rear Mic Boost", 0x18, 0, HDA_INPUT),
6881 static struct snd_kcontrol_new alc262_sony_mixer[] = {
6882 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6883 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
6884 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6885 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6886 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
6887 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
6893 #define alc262_capture_mixer alc882_capture_mixer
6894 #define alc262_capture_alt_mixer alc882_capture_alt_mixer
6897 * generic initialization of ADC, input mixers and output mixers
6899 static struct hda_verb alc262_init_verbs[] = {
6901 * Unmute ADC0-2 and set the default input to mic-in
6903 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
6904 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6905 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6906 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6907 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
6908 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6910 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
6912 * Note: PASD motherboards uses the Line In 2 as the input for
6913 * front panel mic (mic 2)
6915 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
6916 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6917 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6918 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
6919 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
6920 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
6923 * Set up output mixers (0x0c - 0x0e)
6925 /* set vol=0 to output mixers */
6926 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6927 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6928 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6929 /* set up input amps for analog loopback */
6930 /* Amp Indices: DAC = 0, mixer = 1 */
6931 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6932 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6933 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6934 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6935 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6936 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6938 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
6939 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
6940 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
6941 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
6942 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
6943 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
6945 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
6946 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
6947 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
6948 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
6949 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
6951 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
6952 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
6954 /* FIXME: use matrix-type input source selection */
6955 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6956 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
6957 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6958 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
6959 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
6960 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
6962 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6963 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
6964 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
6965 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
6967 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6968 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
6969 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
6970 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
6975 static struct hda_verb alc262_hippo_unsol_verbs[] = {
6976 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
6977 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6981 static struct hda_verb alc262_hippo1_unsol_verbs[] = {
6982 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
6983 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
6984 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
6986 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
6987 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6991 static struct hda_verb alc262_sony_unsol_verbs[] = {
6992 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
6993 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
6994 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, // Front Mic
6996 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
6997 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7000 /* mute/unmute internal speaker according to the hp jack and mute state */
7001 static void alc262_hippo_automute(struct hda_codec *codec, int force)
7003 struct alc_spec *spec = codec->spec;
7006 if (force || !spec->sense_updated) {
7007 unsigned int present;
7008 /* need to execute and sync at first */
7009 snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
7010 present = snd_hda_codec_read(codec, 0x15, 0,
7011 AC_VERB_GET_PIN_SENSE, 0);
7012 spec->jack_present = (present & 0x80000000) != 0;
7013 spec->sense_updated = 1;
7015 if (spec->jack_present) {
7016 /* mute internal speaker */
7017 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
7019 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
7022 /* unmute internal speaker if necessary */
7023 mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0);
7024 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
7026 mute = snd_hda_codec_amp_read(codec, 0x15, 1, HDA_OUTPUT, 0);
7027 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
7032 /* unsolicited event for HP jack sensing */
7033 static void alc262_hippo_unsol_event(struct hda_codec *codec,
7036 if ((res >> 26) != ALC880_HP_EVENT)
7038 alc262_hippo_automute(codec, 1);
7041 static void alc262_hippo1_automute(struct hda_codec *codec, int force)
7043 struct alc_spec *spec = codec->spec;
7046 if (force || !spec->sense_updated) {
7047 unsigned int present;
7048 /* need to execute and sync at first */
7049 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
7050 present = snd_hda_codec_read(codec, 0x1b, 0,
7051 AC_VERB_GET_PIN_SENSE, 0);
7052 spec->jack_present = (present & 0x80000000) != 0;
7053 spec->sense_updated = 1;
7055 if (spec->jack_present) {
7056 /* mute internal speaker */
7057 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
7059 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
7062 /* unmute internal speaker if necessary */
7063 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
7064 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
7066 mute = snd_hda_codec_amp_read(codec, 0x1b, 1, HDA_OUTPUT, 0);
7067 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
7072 /* unsolicited event for HP jack sensing */
7073 static void alc262_hippo1_unsol_event(struct hda_codec *codec,
7076 if ((res >> 26) != ALC880_HP_EVENT)
7078 alc262_hippo1_automute(codec, 1);
7083 * 0x14 = headphone/spdif-out, 0x15 = internal speaker
7086 #define ALC_HP_EVENT 0x37
7088 static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
7089 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
7090 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7094 static struct hda_input_mux alc262_fujitsu_capture_source = {
7102 static struct hda_input_mux alc262_HP_capture_source = {
7106 { "Front Mic", 0x3 },
7113 /* mute/unmute internal speaker according to the hp jack and mute state */
7114 static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
7116 struct alc_spec *spec = codec->spec;
7119 if (force || !spec->sense_updated) {
7120 unsigned int present;
7121 /* need to execute and sync at first */
7122 snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
7123 present = snd_hda_codec_read(codec, 0x14, 0,
7124 AC_VERB_GET_PIN_SENSE, 0);
7125 spec->jack_present = (present & 0x80000000) != 0;
7126 spec->sense_updated = 1;
7128 if (spec->jack_present) {
7129 /* mute internal speaker */
7130 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
7132 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
7135 /* unmute internal speaker if necessary */
7136 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
7137 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
7139 mute = snd_hda_codec_amp_read(codec, 0x14, 1, HDA_OUTPUT, 0);
7140 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
7145 /* unsolicited event for HP jack sensing */
7146 static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
7149 if ((res >> 26) != ALC_HP_EVENT)
7151 alc262_fujitsu_automute(codec, 1);
7154 /* bind volumes of both NID 0x0c and 0x0d */
7155 static int alc262_fujitsu_master_vol_put(struct snd_kcontrol *kcontrol,
7156 struct snd_ctl_elem_value *ucontrol)
7158 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
7159 long *valp = ucontrol->value.integer.value;
7162 change = snd_hda_codec_amp_update(codec, 0x0c, 0, HDA_OUTPUT, 0,
7163 0x7f, valp[0] & 0x7f);
7164 change |= snd_hda_codec_amp_update(codec, 0x0c, 1, HDA_OUTPUT, 0,
7165 0x7f, valp[1] & 0x7f);
7166 snd_hda_codec_amp_update(codec, 0x0d, 0, HDA_OUTPUT, 0,
7167 0x7f, valp[0] & 0x7f);
7168 snd_hda_codec_amp_update(codec, 0x0d, 1, HDA_OUTPUT, 0,
7169 0x7f, valp[1] & 0x7f);
7173 /* bind hp and internal speaker mute (with plug check) */
7174 static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
7175 struct snd_ctl_elem_value *ucontrol)
7177 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
7178 long *valp = ucontrol->value.integer.value;
7181 change = snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
7182 0x80, valp[0] ? 0 : 0x80);
7183 change |= snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
7184 0x80, valp[1] ? 0 : 0x80);
7185 if (change || codec->in_resume)
7186 alc262_fujitsu_automute(codec, codec->in_resume);
7190 static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
7192 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7193 .name = "Master Playback Volume",
7194 .info = snd_hda_mixer_amp_volume_info,
7195 .get = snd_hda_mixer_amp_volume_get,
7196 .put = alc262_fujitsu_master_vol_put,
7197 .tlv = { .c = snd_hda_mixer_amp_tlv },
7198 .private_value = HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
7201 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7202 .name = "Master Playback Switch",
7203 .info = snd_hda_mixer_amp_switch_info,
7204 .get = snd_hda_mixer_amp_switch_get,
7205 .put = alc262_fujitsu_master_sw_put,
7206 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
7208 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7209 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7210 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7211 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7212 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7216 /* additional init verbs for Benq laptops */
7217 static struct hda_verb alc262_EAPD_verbs[] = {
7218 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
7219 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
7223 /* add playback controls from the parsed DAC table */
7224 static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec,
7225 const struct auto_pin_cfg *cfg)
7230 spec->multiout.num_dacs = 1; /* only use one dac */
7231 spec->multiout.dac_nids = spec->private_dac_nids;
7232 spec->multiout.dac_nids[0] = 2;
7234 nid = cfg->line_out_pins[0];
7236 err = add_control(spec, ALC_CTL_WIDGET_VOL,
7237 "Front Playback Volume",
7238 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT));
7241 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
7242 "Front Playback Switch",
7243 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
7248 nid = cfg->speaker_pins[0];
7251 err = add_control(spec, ALC_CTL_WIDGET_VOL,
7252 "Speaker Playback Volume",
7253 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
7257 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
7258 "Speaker Playback Switch",
7259 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
7264 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
7265 "Speaker Playback Switch",
7266 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
7272 nid = cfg->hp_pins[0];
7274 /* spec->multiout.hp_nid = 2; */
7276 err = add_control(spec, ALC_CTL_WIDGET_VOL,
7277 "Headphone Playback Volume",
7278 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
7282 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
7283 "Headphone Playback Switch",
7284 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
7289 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
7290 "Headphone Playback Switch",
7291 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
7300 /* identical with ALC880 */
7301 #define alc262_auto_create_analog_input_ctls \
7302 alc880_auto_create_analog_input_ctls
7305 * generic initialization of ADC, input mixers and output mixers
7307 static struct hda_verb alc262_volume_init_verbs[] = {
7309 * Unmute ADC0-2 and set the default input to mic-in
7311 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7312 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7313 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7314 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7315 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7316 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7318 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
7320 * Note: PASD motherboards uses the Line In 2 as the input for
7321 * front panel mic (mic 2)
7323 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
7324 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7325 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7326 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7327 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
7328 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
7331 * Set up output mixers (0x0c - 0x0f)
7333 /* set vol=0 to output mixers */
7334 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7335 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7336 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7338 /* set up input amps for analog loopback */
7339 /* Amp Indices: DAC = 0, mixer = 1 */
7340 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7341 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7342 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7343 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7344 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7345 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7347 /* FIXME: use matrix-type input source selection */
7348 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7349 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7350 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7351 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
7352 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
7353 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
7355 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7356 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
7357 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
7358 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
7360 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7361 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
7362 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
7363 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
7368 static struct hda_verb alc262_HP_BPC_init_verbs[] = {
7370 * Unmute ADC0-2 and set the default input to mic-in
7372 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7373 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7374 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7375 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7376 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7377 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7379 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
7381 * Note: PASD motherboards uses the Line In 2 as the input for
7382 * front panel mic (mic 2)
7384 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
7385 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7386 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7387 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7388 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
7389 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
7390 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
7391 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(6)},
7394 * Set up output mixers (0x0c - 0x0e)
7396 /* set vol=0 to output mixers */
7397 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7398 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7399 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7401 /* set up input amps for analog loopback */
7402 /* Amp Indices: DAC = 0, mixer = 1 */
7403 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7404 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7405 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7406 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7407 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7408 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7410 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
7411 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7412 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7414 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7415 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7417 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
7418 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7420 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
7421 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
7422 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
7423 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
7424 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
7426 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
7427 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
7428 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
7429 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
7430 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
7431 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
7434 /* FIXME: use matrix-type input source selection */
7435 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7436 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7437 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7438 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
7439 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
7440 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
7442 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7443 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
7444 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
7445 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
7447 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7448 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
7449 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
7450 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
7455 static struct hda_verb alc262_HP_BPC_WildWest_init_verbs[] = {
7457 * Unmute ADC0-2 and set the default input to mic-in
7459 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7460 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7461 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7462 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7463 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7464 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7466 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
7468 * Note: PASD motherboards uses the Line In 2 as the input for front
7471 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
7472 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7473 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7474 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7475 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
7476 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
7477 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
7478 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(6)},
7479 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(7)},
7481 * Set up output mixers (0x0c - 0x0e)
7483 /* set vol=0 to output mixers */
7484 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7485 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7486 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7488 /* set up input amps for analog loopback */
7489 /* Amp Indices: DAC = 0, mixer = 1 */
7490 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7491 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7492 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7493 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7494 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7495 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7498 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP */
7499 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Mono */
7500 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* rear MIC */
7501 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* Line in */
7502 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
7503 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Line out */
7504 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD in */
7506 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7507 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7509 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
7510 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
7512 /* {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, */
7513 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
7514 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
7515 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
7516 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
7517 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
7519 /* FIXME: use matrix-type input source selection */
7520 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7521 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7522 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, /*rear MIC*/
7523 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, /*Line in*/
7524 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, /*F MIC*/
7525 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, /*Front*/
7526 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, /*CD*/
7527 /* {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
7528 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, /*HP*/
7530 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7531 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
7532 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
7533 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
7534 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
7535 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
7536 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
7538 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7539 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
7540 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
7541 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
7542 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
7543 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
7544 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
7549 /* pcm configuration: identiacal with ALC880 */
7550 #define alc262_pcm_analog_playback alc880_pcm_analog_playback
7551 #define alc262_pcm_analog_capture alc880_pcm_analog_capture
7552 #define alc262_pcm_digital_playback alc880_pcm_digital_playback
7553 #define alc262_pcm_digital_capture alc880_pcm_digital_capture
7556 * BIOS auto configuration
7558 static int alc262_parse_auto_config(struct hda_codec *codec)
7560 struct alc_spec *spec = codec->spec;
7562 static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
7564 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
7568 if (!spec->autocfg.line_outs)
7569 return 0; /* can't find valid BIOS pin config */
7570 err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg);
7573 err = alc262_auto_create_analog_input_ctls(spec, &spec->autocfg);
7577 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
7579 if (spec->autocfg.dig_out_pin)
7580 spec->multiout.dig_out_nid = ALC262_DIGOUT_NID;
7581 if (spec->autocfg.dig_in_pin)
7582 spec->dig_in_nid = ALC262_DIGIN_NID;
7584 if (spec->kctl_alloc)
7585 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
7587 spec->init_verbs[spec->num_init_verbs++] = alc262_volume_init_verbs;
7588 spec->num_mux_defs = 1;
7589 spec->input_mux = &spec->private_imux;
7594 #define alc262_auto_init_multi_out alc882_auto_init_multi_out
7595 #define alc262_auto_init_hp_out alc882_auto_init_hp_out
7596 #define alc262_auto_init_analog_input alc882_auto_init_analog_input
7599 /* init callback for auto-configuration model -- overriding the default init */
7600 static void alc262_auto_init(struct hda_codec *codec)
7602 alc262_auto_init_multi_out(codec);
7603 alc262_auto_init_hp_out(codec);
7604 alc262_auto_init_analog_input(codec);
7608 * configuration and preset
7610 static const char *alc262_models[ALC262_MODEL_LAST] = {
7611 [ALC262_BASIC] = "basic",
7612 [ALC262_HIPPO] = "hippo",
7613 [ALC262_HIPPO_1] = "hippo_1",
7614 [ALC262_FUJITSU] = "fujitsu",
7615 [ALC262_HP_BPC] = "hp-bpc",
7616 [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000",
7617 [ALC262_BENQ_ED8] = "benq",
7618 [ALC262_BENQ_ED8] = "sony-assamd",
7619 [ALC262_AUTO] = "auto",
7622 static struct snd_pci_quirk alc262_cfg_tbl[] = {
7623 SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO),
7624 SND_PCI_QUIRK(0x103c, 0x12fe, "HP xw9400", ALC262_HP_BPC),
7625 SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC),
7626 SND_PCI_QUIRK(0x103c, 0x12ff, "HP xw4550", ALC262_HP_BPC),
7627 SND_PCI_QUIRK(0x103c, 0x1308, "HP xw4600", ALC262_HP_BPC),
7628 SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC),
7629 SND_PCI_QUIRK(0x103c, 0x1307, "HP xw6600", ALC262_HP_BPC),
7630 SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC),
7631 SND_PCI_QUIRK(0x103c, 0x1306, "HP xw8600", ALC262_HP_BPC),
7632 SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL),
7633 SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL),
7634 SND_PCI_QUIRK(0x103c, 0x2804, "HP D7000", ALC262_HP_BPC_D7000_WL),
7635 SND_PCI_QUIRK(0x103c, 0x2806, "HP D7000", ALC262_HP_BPC_D7000_WL),
7636 SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF),
7637 SND_PCI_QUIRK(0x103c, 0x2803, "HP D7000", ALC262_HP_BPC_D7000_WF),
7638 SND_PCI_QUIRK(0x103c, 0x2805, "HP D7000", ALC262_HP_BPC_D7000_WF),
7639 SND_PCI_QUIRK(0x103c, 0x2807, "HP D7000", ALC262_HP_BPC_D7000_WF),
7640 SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO),
7641 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
7642 SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1),
7643 SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
7644 SND_PCI_QUIRK(0x104d, 0x9015, "Sony 0x9015", ALC262_SONY_ASSAMD),
7645 SND_PCI_QUIRK(0x104d, 0x900e, "Sony ASSAMD", ALC262_SONY_ASSAMD),
7646 SND_PCI_QUIRK(0x104d, 0x1f00, "Sony ASSAMD", ALC262_SONY_ASSAMD),
7650 static struct alc_config_preset alc262_presets[] = {
7652 .mixers = { alc262_base_mixer },
7653 .init_verbs = { alc262_init_verbs },
7654 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
7655 .dac_nids = alc262_dac_nids,
7657 .num_channel_mode = ARRAY_SIZE(alc262_modes),
7658 .channel_mode = alc262_modes,
7659 .input_mux = &alc262_capture_source,
7662 .mixers = { alc262_base_mixer },
7663 .init_verbs = { alc262_init_verbs, alc262_hippo_unsol_verbs},
7664 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
7665 .dac_nids = alc262_dac_nids,
7667 .dig_out_nid = ALC262_DIGOUT_NID,
7668 .num_channel_mode = ARRAY_SIZE(alc262_modes),
7669 .channel_mode = alc262_modes,
7670 .input_mux = &alc262_capture_source,
7671 .unsol_event = alc262_hippo_unsol_event,
7673 [ALC262_HIPPO_1] = {
7674 .mixers = { alc262_hippo1_mixer },
7675 .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs},
7676 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
7677 .dac_nids = alc262_dac_nids,
7679 .dig_out_nid = ALC262_DIGOUT_NID,
7680 .num_channel_mode = ARRAY_SIZE(alc262_modes),
7681 .channel_mode = alc262_modes,
7682 .input_mux = &alc262_capture_source,
7683 .unsol_event = alc262_hippo1_unsol_event,
7685 [ALC262_FUJITSU] = {
7686 .mixers = { alc262_fujitsu_mixer },
7687 .init_verbs = { alc262_init_verbs, alc262_fujitsu_unsol_verbs },
7688 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
7689 .dac_nids = alc262_dac_nids,
7691 .dig_out_nid = ALC262_DIGOUT_NID,
7692 .num_channel_mode = ARRAY_SIZE(alc262_modes),
7693 .channel_mode = alc262_modes,
7694 .input_mux = &alc262_fujitsu_capture_source,
7695 .unsol_event = alc262_fujitsu_unsol_event,
7698 .mixers = { alc262_HP_BPC_mixer },
7699 .init_verbs = { alc262_HP_BPC_init_verbs },
7700 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
7701 .dac_nids = alc262_dac_nids,
7703 .num_channel_mode = ARRAY_SIZE(alc262_modes),
7704 .channel_mode = alc262_modes,
7705 .input_mux = &alc262_HP_capture_source,
7707 [ALC262_HP_BPC_D7000_WF] = {
7708 .mixers = { alc262_HP_BPC_WildWest_mixer },
7709 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
7710 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
7711 .dac_nids = alc262_dac_nids,
7713 .num_channel_mode = ARRAY_SIZE(alc262_modes),
7714 .channel_mode = alc262_modes,
7715 .input_mux = &alc262_HP_capture_source,
7717 [ALC262_HP_BPC_D7000_WL] = {
7718 .mixers = { alc262_HP_BPC_WildWest_mixer,
7719 alc262_HP_BPC_WildWest_option_mixer },
7720 .init_verbs = { alc262_HP_BPC_WildWest_init_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_HP_capture_source,
7728 [ALC262_BENQ_ED8] = {
7729 .mixers = { alc262_base_mixer },
7730 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
7731 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
7732 .dac_nids = alc262_dac_nids,
7734 .num_channel_mode = ARRAY_SIZE(alc262_modes),
7735 .channel_mode = alc262_modes,
7736 .input_mux = &alc262_capture_source,
7738 [ALC262_SONY_ASSAMD] = {
7739 .mixers = { alc262_sony_mixer },
7740 .init_verbs = { alc262_init_verbs, alc262_sony_unsol_verbs},
7741 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
7742 .dac_nids = alc262_dac_nids,
7744 .num_channel_mode = ARRAY_SIZE(alc262_modes),
7745 .channel_mode = alc262_modes,
7746 .input_mux = &alc262_capture_source,
7747 .unsol_event = alc262_hippo_unsol_event,
7751 static int patch_alc262(struct hda_codec *codec)
7753 struct alc_spec *spec;
7757 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
7763 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
7768 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
7769 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
7770 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
7771 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
7775 board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST,
7779 if (board_config < 0) {
7780 printk(KERN_INFO "hda_codec: Unknown model for ALC262, "
7781 "trying auto-probe from BIOS...\n");
7782 board_config = ALC262_AUTO;
7785 if (board_config == ALC262_AUTO) {
7786 /* automatic parse from the BIOS config */
7787 err = alc262_parse_auto_config(codec);
7793 "hda_codec: Cannot set up configuration "
7794 "from BIOS. Using base mode...\n");
7795 board_config = ALC262_BASIC;
7799 if (board_config != ALC262_AUTO)
7800 setup_preset(spec, &alc262_presets[board_config]);
7802 spec->stream_name_analog = "ALC262 Analog";
7803 spec->stream_analog_playback = &alc262_pcm_analog_playback;
7804 spec->stream_analog_capture = &alc262_pcm_analog_capture;
7806 spec->stream_name_digital = "ALC262 Digital";
7807 spec->stream_digital_playback = &alc262_pcm_digital_playback;
7808 spec->stream_digital_capture = &alc262_pcm_digital_capture;
7810 if (!spec->adc_nids && spec->input_mux) {
7811 /* check whether NID 0x07 is valid */
7812 unsigned int wcap = get_wcaps(codec, 0x07);
7815 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
7816 if (wcap != AC_WID_AUD_IN) {
7817 spec->adc_nids = alc262_adc_nids_alt;
7818 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids_alt);
7819 spec->mixers[spec->num_mixers] =
7820 alc262_capture_alt_mixer;
7823 spec->adc_nids = alc262_adc_nids;
7824 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids);
7825 spec->mixers[spec->num_mixers] = alc262_capture_mixer;
7830 codec->patch_ops = alc_patch_ops;
7831 if (board_config == ALC262_AUTO)
7832 spec->init_hook = alc262_auto_init;
7838 * ALC268 channel source setting (2 channel)
7840 #define ALC268_DIGOUT_NID ALC880_DIGOUT_NID
7841 #define alc268_modes alc260_modes
7843 static hda_nid_t alc268_dac_nids[2] = {
7848 static hda_nid_t alc268_adc_nids[2] = {
7853 static hda_nid_t alc268_adc_nids_alt[1] = {
7858 static struct snd_kcontrol_new alc268_base_mixer[] = {
7859 /* output mixer control */
7860 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
7861 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7862 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
7863 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7868 * generic initialization of ADC, input mixers and output mixers
7870 static struct hda_verb alc268_base_init_verbs[] = {
7871 /* Unmute DAC0-1 and set vol = 0 */
7872 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7873 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7874 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7875 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7876 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7877 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7880 * Set up output mixers (0x0c - 0x0e)
7882 /* set vol=0 to output mixers */
7883 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7884 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7885 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7886 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
7888 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7889 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7891 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
7892 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
7893 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
7894 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
7895 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
7896 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
7897 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
7898 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
7900 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7901 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7902 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7903 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7904 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7905 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7906 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7907 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7909 /* FIXME: use matrix-type input source selection */
7910 /* Mixer elements: 0x18, 19, 1a, 1c, 14, 15, 0b */
7911 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7913 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7914 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
7915 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
7916 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
7918 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7919 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
7920 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
7921 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
7926 * generic initialization of ADC, input mixers and output mixers
7928 static struct hda_verb alc268_volume_init_verbs[] = {
7929 /* set output DAC */
7930 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7931 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7932 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7933 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7935 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
7936 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
7937 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
7938 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
7939 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
7941 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7942 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7943 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7944 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7945 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7947 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7948 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7949 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7950 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7952 /* set PCBEEP vol = 0 */
7953 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, (0xb000 | (0x00 << 8))},
7958 #define alc268_mux_enum_info alc_mux_enum_info
7959 #define alc268_mux_enum_get alc_mux_enum_get
7961 static int alc268_mux_enum_put(struct snd_kcontrol *kcontrol,
7962 struct snd_ctl_elem_value *ucontrol)
7964 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
7965 struct alc_spec *spec = codec->spec;
7966 const struct hda_input_mux *imux = spec->input_mux;
7967 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
7968 static hda_nid_t capture_mixers[3] = { 0x23, 0x24 };
7969 hda_nid_t nid = capture_mixers[adc_idx];
7970 unsigned int *cur_val = &spec->cur_mux[adc_idx];
7971 unsigned int i, idx;
7973 idx = ucontrol->value.enumerated.item[0];
7974 if (idx >= imux->num_items)
7975 idx = imux->num_items - 1;
7976 if (*cur_val == idx && !codec->in_resume)
7978 for (i = 0; i < imux->num_items; i++) {
7979 unsigned int v = (i == idx) ? 0x7000 : 0x7080;
7980 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
7981 v | (imux->items[i].index << 8));
7982 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL,
7989 static struct snd_kcontrol_new alc268_capture_alt_mixer[] = {
7990 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
7991 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
7993 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7994 /* The multiple "Capture Source" controls confuse alsamixer
7995 * So call somewhat different..
7996 * FIXME: the controls appear in the "playback" view!
7998 /* .name = "Capture Source", */
7999 .name = "Input Source",
8001 .info = alc268_mux_enum_info,
8002 .get = alc268_mux_enum_get,
8003 .put = alc268_mux_enum_put,
8008 static struct snd_kcontrol_new alc268_capture_mixer[] = {
8009 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
8010 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
8011 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x24, 0x0, HDA_OUTPUT),
8012 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x24, 0x0, HDA_OUTPUT),
8014 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8015 /* The multiple "Capture Source" controls confuse alsamixer
8016 * So call somewhat different..
8017 * FIXME: the controls appear in the "playback" view!
8019 /* .name = "Capture Source", */
8020 .name = "Input Source",
8022 .info = alc268_mux_enum_info,
8023 .get = alc268_mux_enum_get,
8024 .put = alc268_mux_enum_put,
8029 static struct hda_input_mux alc268_capture_source = {
8033 { "Front Mic", 0x1 },
8039 /* create input playback/capture controls for the given pin */
8040 static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
8041 const char *ctlname, int idx)
8046 sprintf(name, "%s Playback Volume", ctlname);
8048 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
8049 HDA_COMPOSE_AMP_VAL(0x02, 3, idx,
8053 } else if (nid == 0x15) {
8054 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
8055 HDA_COMPOSE_AMP_VAL(0x03, 3, idx,
8061 sprintf(name, "%s Playback Switch", ctlname);
8062 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
8063 HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
8069 /* add playback controls from the parsed DAC table */
8070 static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec,
8071 const struct auto_pin_cfg *cfg)
8076 spec->multiout.num_dacs = 2; /* only use one dac */
8077 spec->multiout.dac_nids = spec->private_dac_nids;
8078 spec->multiout.dac_nids[0] = 2;
8079 spec->multiout.dac_nids[1] = 3;
8081 nid = cfg->line_out_pins[0];
8083 alc268_new_analog_output(spec, nid, "Front", 0);
8085 nid = cfg->speaker_pins[0];
8087 err = add_control(spec, ALC_CTL_WIDGET_VOL,
8088 "Speaker Playback Volume",
8089 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
8093 nid = cfg->hp_pins[0];
8095 alc268_new_analog_output(spec, nid, "Headphone", 0);
8097 nid = cfg->line_out_pins[1] | cfg->line_out_pins[2];
8099 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
8100 "Mono Playback Switch",
8101 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_INPUT));
8108 /* create playback/capture controls for input pins */
8109 static int alc268_auto_create_analog_input_ctls(struct alc_spec *spec,
8110 const struct auto_pin_cfg *cfg)
8112 struct hda_input_mux *imux = &spec->private_imux;
8115 for (i = 0; i < AUTO_PIN_LAST; i++) {
8116 switch(cfg->input_pins[i]) {
8118 idx1 = 0; /* Mic 1 */
8121 idx1 = 1; /* Mic 2 */
8124 idx1 = 2; /* Line In */
8132 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
8133 imux->items[imux->num_items].index = idx1;
8139 static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec)
8141 struct alc_spec *spec = codec->spec;
8142 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
8143 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
8144 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
8145 unsigned int dac_vol1, dac_vol2;
8148 snd_hda_codec_write(codec, speaker_nid, 0,
8149 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
8150 snd_hda_codec_write(codec, 0x0f, 0,
8151 AC_VERB_SET_AMP_GAIN_MUTE,
8153 snd_hda_codec_write(codec, 0x10, 0,
8154 AC_VERB_SET_AMP_GAIN_MUTE,
8157 snd_hda_codec_write(codec, 0x0f, 0,
8158 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
8159 snd_hda_codec_write(codec, 0x10, 0,
8160 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
8163 dac_vol1 = dac_vol2 = 0xb000 | 0x40; /* set max volume */
8164 if (line_nid == 0x14)
8165 dac_vol2 = AMP_OUT_ZERO;
8166 else if (line_nid == 0x15)
8167 dac_vol1 = AMP_OUT_ZERO;
8169 dac_vol2 = AMP_OUT_ZERO;
8170 else if (hp_nid == 0x15)
8171 dac_vol1 = AMP_OUT_ZERO;
8172 if (line_nid != 0x16 || hp_nid != 0x16 ||
8173 spec->autocfg.line_out_pins[1] != 0x16 ||
8174 spec->autocfg.line_out_pins[2] != 0x16)
8175 dac_vol1 = dac_vol2 = AMP_OUT_ZERO;
8177 snd_hda_codec_write(codec, 0x02, 0,
8178 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol1);
8179 snd_hda_codec_write(codec, 0x03, 0,
8180 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol2);
8183 /* pcm configuration: identiacal with ALC880 */
8184 #define alc268_pcm_analog_playback alc880_pcm_analog_playback
8185 #define alc268_pcm_analog_capture alc880_pcm_analog_capture
8186 #define alc268_pcm_digital_playback alc880_pcm_digital_playback
8189 * BIOS auto configuration
8191 static int alc268_parse_auto_config(struct hda_codec *codec)
8193 struct alc_spec *spec = codec->spec;
8195 static hda_nid_t alc268_ignore[] = { 0 };
8197 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
8201 if (!spec->autocfg.line_outs)
8202 return 0; /* can't find valid BIOS pin config */
8204 err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg);
8207 err = alc268_auto_create_analog_input_ctls(spec, &spec->autocfg);
8211 spec->multiout.max_channels = 2;
8213 /* digital only support output */
8214 if (spec->autocfg.dig_out_pin)
8215 spec->multiout.dig_out_nid = ALC268_DIGOUT_NID;
8217 if (spec->kctl_alloc)
8218 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
8220 spec->init_verbs[spec->num_init_verbs++] = alc268_volume_init_verbs;
8221 spec->num_mux_defs = 1;
8222 spec->input_mux = &spec->private_imux;
8227 #define alc268_auto_init_multi_out alc882_auto_init_multi_out
8228 #define alc268_auto_init_hp_out alc882_auto_init_hp_out
8229 #define alc268_auto_init_analog_input alc882_auto_init_analog_input
8231 /* init callback for auto-configuration model -- overriding the default init */
8232 static void alc268_auto_init(struct hda_codec *codec)
8234 alc268_auto_init_multi_out(codec);
8235 alc268_auto_init_hp_out(codec);
8236 alc268_auto_init_mono_speaker_out(codec);
8237 alc268_auto_init_analog_input(codec);
8241 * configuration and preset
8243 static const char *alc268_models[ALC268_MODEL_LAST] = {
8244 [ALC268_3ST] = "3stack",
8245 [ALC268_AUTO] = "auto",
8248 static struct snd_pci_quirk alc268_cfg_tbl[] = {
8249 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST),
8253 static struct alc_config_preset alc268_presets[] = {
8255 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer },
8256 .init_verbs = { alc268_base_init_verbs },
8257 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
8258 .dac_nids = alc268_dac_nids,
8259 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
8260 .adc_nids = alc268_adc_nids_alt,
8262 .dig_out_nid = ALC268_DIGOUT_NID,
8263 .num_channel_mode = ARRAY_SIZE(alc268_modes),
8264 .channel_mode = alc268_modes,
8265 .input_mux = &alc268_capture_source,
8269 static int patch_alc268(struct hda_codec *codec)
8271 struct alc_spec *spec;
8275 spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
8281 board_config = snd_hda_check_board_config(codec, ALC268_MODEL_LAST,
8285 if (board_config < 0 || board_config >= ALC268_MODEL_LAST) {
8286 printk(KERN_INFO "hda_codec: Unknown model for ALC268, "
8287 "trying auto-probe from BIOS...\n");
8288 board_config = ALC268_AUTO;
8291 if (board_config == ALC268_AUTO) {
8292 /* automatic parse from the BIOS config */
8293 err = alc268_parse_auto_config(codec);
8299 "hda_codec: Cannot set up configuration "
8300 "from BIOS. Using base mode...\n");
8301 board_config = ALC268_3ST;
8305 if (board_config != ALC268_AUTO)
8306 setup_preset(spec, &alc268_presets[board_config]);
8308 spec->stream_name_analog = "ALC268 Analog";
8309 spec->stream_analog_playback = &alc268_pcm_analog_playback;
8310 spec->stream_analog_capture = &alc268_pcm_analog_capture;
8312 spec->stream_name_digital = "ALC268 Digital";
8313 spec->stream_digital_playback = &alc268_pcm_digital_playback;
8315 if (board_config == ALC268_AUTO) {
8316 if (!spec->adc_nids && spec->input_mux) {
8317 /* check whether NID 0x07 is valid */
8318 unsigned int wcap = get_wcaps(codec, 0x07);
8321 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
8322 if (wcap != AC_WID_AUD_IN) {
8323 spec->adc_nids = alc268_adc_nids_alt;
8324 spec->num_adc_nids =
8325 ARRAY_SIZE(alc268_adc_nids_alt);
8326 spec->mixers[spec->num_mixers] =
8327 alc268_capture_alt_mixer;
8330 spec->adc_nids = alc268_adc_nids;
8331 spec->num_adc_nids =
8332 ARRAY_SIZE(alc268_adc_nids);
8333 spec->mixers[spec->num_mixers] =
8334 alc268_capture_mixer;
8339 codec->patch_ops = alc_patch_ops;
8340 if (board_config == ALC268_AUTO)
8341 spec->init_hook = alc268_auto_init;
8347 * ALC861 channel source setting (2/6 channel selection for 3-stack)
8351 * set the path ways for 2 channel output
8352 * need to set the codec line out and mic 1 pin widgets to inputs
8354 static struct hda_verb alc861_threestack_ch2_init[] = {
8355 /* set pin widget 1Ah (line in) for input */
8356 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
8357 /* set pin widget 18h (mic1/2) for input, for mic also enable
8360 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
8362 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
8364 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
8365 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
8371 * need to set the codec line out and mic 1 pin widgets to outputs
8373 static struct hda_verb alc861_threestack_ch6_init[] = {
8374 /* set pin widget 1Ah (line in) for output (Back Surround)*/
8375 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
8376 /* set pin widget 18h (mic1) for output (CLFE)*/
8377 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
8379 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
8380 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
8382 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
8384 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
8385 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
8390 static struct hda_channel_mode alc861_threestack_modes[2] = {
8391 { 2, alc861_threestack_ch2_init },
8392 { 6, alc861_threestack_ch6_init },
8394 /* Set mic1 as input and unmute the mixer */
8395 static struct hda_verb alc861_uniwill_m31_ch2_init[] = {
8396 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
8397 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
8400 /* Set mic1 as output and mute mixer */
8401 static struct hda_verb alc861_uniwill_m31_ch4_init[] = {
8402 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
8403 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
8407 static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
8408 { 2, alc861_uniwill_m31_ch2_init },
8409 { 4, alc861_uniwill_m31_ch4_init },
8412 /* Set mic1 and line-in as input and unmute the mixer */
8413 static struct hda_verb alc861_asus_ch2_init[] = {
8414 /* set pin widget 1Ah (line in) for input */
8415 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
8416 /* set pin widget 18h (mic1/2) for input, for mic also enable
8419 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
8421 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
8423 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
8424 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
8428 /* Set mic1 nad line-in as output and mute mixer */
8429 static struct hda_verb alc861_asus_ch6_init[] = {
8430 /* set pin widget 1Ah (line in) for output (Back Surround)*/
8431 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
8432 /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
8433 /* set pin widget 18h (mic1) for output (CLFE)*/
8434 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
8435 /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
8436 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
8437 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
8439 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
8441 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
8442 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
8447 static struct hda_channel_mode alc861_asus_modes[2] = {
8448 { 2, alc861_asus_ch2_init },
8449 { 6, alc861_asus_ch6_init },
8454 static struct snd_kcontrol_new alc861_base_mixer[] = {
8455 /* output mixer control */
8456 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
8457 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
8458 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
8459 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
8460 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
8462 /*Input mixer control */
8463 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
8464 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
8465 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
8466 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
8467 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
8468 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
8469 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
8470 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
8471 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
8472 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
8474 /* Capture mixer control */
8475 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
8476 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
8478 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8479 .name = "Capture Source",
8481 .info = alc_mux_enum_info,
8482 .get = alc_mux_enum_get,
8483 .put = alc_mux_enum_put,
8488 static struct snd_kcontrol_new alc861_3ST_mixer[] = {
8489 /* output mixer control */
8490 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
8491 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
8492 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
8493 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
8494 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
8496 /* Input mixer control */
8497 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
8498 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
8499 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
8500 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
8501 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
8502 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
8503 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
8504 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
8505 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
8506 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
8508 /* Capture mixer control */
8509 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
8510 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
8512 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8513 .name = "Capture Source",
8515 .info = alc_mux_enum_info,
8516 .get = alc_mux_enum_get,
8517 .put = alc_mux_enum_put,
8520 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8521 .name = "Channel Mode",
8522 .info = alc_ch_mode_info,
8523 .get = alc_ch_mode_get,
8524 .put = alc_ch_mode_put,
8525 .private_value = ARRAY_SIZE(alc861_threestack_modes),
8530 static struct snd_kcontrol_new alc861_toshiba_mixer[] = {
8531 /* output mixer control */
8532 HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT),
8533 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
8534 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
8536 /*Capture mixer control */
8537 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
8538 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
8540 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8541 .name = "Capture Source",
8543 .info = alc_mux_enum_info,
8544 .get = alc_mux_enum_get,
8545 .put = alc_mux_enum_put,
8551 static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
8552 /* output mixer control */
8553 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
8554 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
8555 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
8556 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
8557 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
8559 /* Input mixer control */
8560 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
8561 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
8562 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
8563 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
8564 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
8565 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
8566 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
8567 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
8568 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
8569 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
8571 /* Capture mixer control */
8572 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
8573 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
8575 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8576 .name = "Capture Source",
8578 .info = alc_mux_enum_info,
8579 .get = alc_mux_enum_get,
8580 .put = alc_mux_enum_put,
8583 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8584 .name = "Channel Mode",
8585 .info = alc_ch_mode_info,
8586 .get = alc_ch_mode_get,
8587 .put = alc_ch_mode_put,
8588 .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
8593 static struct snd_kcontrol_new alc861_asus_mixer[] = {
8594 /* output mixer control */
8595 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
8596 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
8597 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
8598 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
8599 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
8601 /* Input mixer control */
8602 HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
8603 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8604 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
8605 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
8606 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
8607 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
8608 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
8609 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
8610 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
8611 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT),
8613 /* Capture mixer control */
8614 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
8615 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
8617 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8618 .name = "Capture Source",
8620 .info = alc_mux_enum_info,
8621 .get = alc_mux_enum_get,
8622 .put = alc_mux_enum_put,
8625 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8626 .name = "Channel Mode",
8627 .info = alc_ch_mode_info,
8628 .get = alc_ch_mode_get,
8629 .put = alc_ch_mode_put,
8630 .private_value = ARRAY_SIZE(alc861_asus_modes),
8635 /* additional mixer */
8636 static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = {
8637 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
8638 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
8639 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x23, 0x0, HDA_OUTPUT),
8640 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x23, 0x0, HDA_OUTPUT),
8645 * generic initialization of ADC, input mixers and output mixers
8647 static struct hda_verb alc861_base_init_verbs[] = {
8649 * Unmute ADC0 and set the default input to mic-in
8651 /* port-A for surround (rear panel) */
8652 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
8653 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
8654 /* port-B for mic-in (rear panel) with vref */
8655 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
8656 /* port-C for line-in (rear panel) */
8657 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
8658 /* port-D for Front */
8659 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
8660 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
8661 /* port-E for HP out (front panel) */
8662 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
8663 /* route front PCM to HP */
8664 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
8665 /* port-F for mic-in (front panel) with vref */
8666 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
8667 /* port-G for CLFE (rear panel) */
8668 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
8669 { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
8670 /* port-H for side (rear panel) */
8671 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
8672 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
8674 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
8675 /* route front mic to ADC1*/
8676 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8677 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8679 /* Unmute DAC0~3 & spdif out*/
8680 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8681 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8682 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8683 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8684 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8686 /* Unmute Mixer 14 (mic) 1c (Line in)*/
8687 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8688 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8689 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8690 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8692 /* Unmute Stereo Mixer 15 */
8693 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8694 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8695 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
8696 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
8698 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8699 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8700 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8701 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8702 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8703 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8704 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8705 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8706 /* hp used DAC 3 (Front) */
8707 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
8708 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
8713 static struct hda_verb alc861_threestack_init_verbs[] = {
8715 * Unmute ADC0 and set the default input to mic-in
8717 /* port-A for surround (rear panel) */
8718 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
8719 /* port-B for mic-in (rear panel) with vref */
8720 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
8721 /* port-C for line-in (rear panel) */
8722 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
8723 /* port-D for Front */
8724 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
8725 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
8726 /* port-E for HP out (front panel) */
8727 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
8728 /* route front PCM to HP */
8729 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
8730 /* port-F for mic-in (front panel) with vref */
8731 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
8732 /* port-G for CLFE (rear panel) */
8733 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
8734 /* port-H for side (rear panel) */
8735 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
8737 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
8738 /* route front mic to ADC1*/
8739 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8740 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8741 /* Unmute DAC0~3 & spdif out*/
8742 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8743 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8744 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8745 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8746 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8748 /* Unmute Mixer 14 (mic) 1c (Line in)*/
8749 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8750 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8751 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8752 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8754 /* Unmute Stereo Mixer 15 */
8755 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8756 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8757 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
8758 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
8760 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8761 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8762 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8763 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8764 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8765 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8766 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8767 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8768 /* hp used DAC 3 (Front) */
8769 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
8770 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
8774 static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
8776 * Unmute ADC0 and set the default input to mic-in
8778 /* port-A for surround (rear panel) */
8779 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
8780 /* port-B for mic-in (rear panel) with vref */
8781 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
8782 /* port-C for line-in (rear panel) */
8783 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
8784 /* port-D for Front */
8785 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
8786 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
8787 /* port-E for HP out (front panel) */
8788 /* this has to be set to VREF80 */
8789 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
8790 /* route front PCM to HP */
8791 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
8792 /* port-F for mic-in (front panel) with vref */
8793 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
8794 /* port-G for CLFE (rear panel) */
8795 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
8796 /* port-H for side (rear panel) */
8797 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
8799 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
8800 /* route front mic to ADC1*/
8801 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8802 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8803 /* Unmute DAC0~3 & spdif out*/
8804 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8805 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8806 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8807 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8808 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8810 /* Unmute Mixer 14 (mic) 1c (Line in)*/
8811 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8812 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8813 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8814 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8816 /* Unmute Stereo Mixer 15 */
8817 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8818 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8819 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
8820 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
8822 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8823 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8824 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8825 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8826 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8827 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8828 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8829 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8830 /* hp used DAC 3 (Front) */
8831 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
8832 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
8836 static struct hda_verb alc861_asus_init_verbs[] = {
8838 * Unmute ADC0 and set the default input to mic-in
8840 /* port-A for surround (rear panel)
8841 * according to codec#0 this is the HP jack
8843 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */
8844 /* route front PCM to HP */
8845 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 },
8846 /* port-B for mic-in (rear panel) with vref */
8847 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
8848 /* port-C for line-in (rear panel) */
8849 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
8850 /* port-D for Front */
8851 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
8852 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
8853 /* port-E for HP out (front panel) */
8854 /* this has to be set to VREF80 */
8855 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
8856 /* route front PCM to HP */
8857 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
8858 /* port-F for mic-in (front panel) with vref */
8859 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
8860 /* port-G for CLFE (rear panel) */
8861 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
8862 /* port-H for side (rear panel) */
8863 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
8865 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
8866 /* route front mic to ADC1*/
8867 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8868 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8869 /* Unmute DAC0~3 & spdif out*/
8870 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8871 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8872 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8873 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8874 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8875 /* Unmute Mixer 14 (mic) 1c (Line in)*/
8876 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8877 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8878 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8879 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8881 /* Unmute Stereo Mixer 15 */
8882 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8883 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8884 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
8885 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
8887 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8888 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8889 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8890 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8891 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8892 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8893 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8894 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8895 /* hp used DAC 3 (Front) */
8896 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
8897 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
8901 /* additional init verbs for ASUS laptops */
8902 static struct hda_verb alc861_asus_laptop_init_verbs[] = {
8903 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */
8904 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */
8909 * generic initialization of ADC, input mixers and output mixers
8911 static struct hda_verb alc861_auto_init_verbs[] = {
8913 * Unmute ADC0 and set the default input to mic-in
8915 /* {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, */
8916 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8918 /* Unmute DAC0~3 & spdif out*/
8919 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8920 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8921 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8922 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8923 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8925 /* Unmute Mixer 14 (mic) 1c (Line in)*/
8926 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8927 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8928 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8929 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8931 /* Unmute Stereo Mixer 15 */
8932 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8933 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8934 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
8935 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
8937 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8938 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8939 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8940 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8941 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8942 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8943 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8944 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8946 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8947 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8948 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
8949 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
8950 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8951 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8952 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
8953 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
8955 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */
8960 static struct hda_verb alc861_toshiba_init_verbs[] = {
8961 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
8966 /* toggle speaker-output according to the hp-jack state */
8967 static void alc861_toshiba_automute(struct hda_codec *codec)
8969 unsigned int present;
8971 present = snd_hda_codec_read(codec, 0x0f, 0,
8972 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8973 snd_hda_codec_amp_update(codec, 0x16, 0, HDA_INPUT, 0,
8974 0x80, present ? 0x80 : 0);
8975 snd_hda_codec_amp_update(codec, 0x16, 1, HDA_INPUT, 0,
8976 0x80, present ? 0x80 : 0);
8977 snd_hda_codec_amp_update(codec, 0x1a, 0, HDA_INPUT, 3,
8978 0x80, present ? 0 : 0x80);
8979 snd_hda_codec_amp_update(codec, 0x1a, 1, HDA_INPUT, 3,
8980 0x80, present ? 0 : 0x80);
8983 static void alc861_toshiba_unsol_event(struct hda_codec *codec,
8986 if ((res >> 26) == ALC880_HP_EVENT)
8987 alc861_toshiba_automute(codec);
8990 /* pcm configuration: identiacal with ALC880 */
8991 #define alc861_pcm_analog_playback alc880_pcm_analog_playback
8992 #define alc861_pcm_analog_capture alc880_pcm_analog_capture
8993 #define alc861_pcm_digital_playback alc880_pcm_digital_playback
8994 #define alc861_pcm_digital_capture alc880_pcm_digital_capture
8997 #define ALC861_DIGOUT_NID 0x07
8999 static struct hda_channel_mode alc861_8ch_modes[1] = {
9003 static hda_nid_t alc861_dac_nids[4] = {
9004 /* front, surround, clfe, side */
9005 0x03, 0x06, 0x05, 0x04
9008 static hda_nid_t alc660_dac_nids[3] = {
9009 /* front, clfe, surround */
9013 static hda_nid_t alc861_adc_nids[1] = {
9018 static struct hda_input_mux alc861_capture_source = {
9022 { "Front Mic", 0x3 },
9029 /* fill in the dac_nids table from the parsed pin configuration */
9030 static int alc861_auto_fill_dac_nids(struct alc_spec *spec,
9031 const struct auto_pin_cfg *cfg)
9036 spec->multiout.dac_nids = spec->private_dac_nids;
9037 for (i = 0; i < cfg->line_outs; i++) {
9038 nid = cfg->line_out_pins[i];
9040 if (i >= ARRAY_SIZE(alc861_dac_nids))
9042 spec->multiout.dac_nids[i] = alc861_dac_nids[i];
9045 spec->multiout.num_dacs = cfg->line_outs;
9049 /* add playback controls from the parsed DAC table */
9050 static int alc861_auto_create_multi_out_ctls(struct alc_spec *spec,
9051 const struct auto_pin_cfg *cfg)
9054 static const char *chname[4] = {
9055 "Front", "Surround", NULL /*CLFE*/, "Side"
9060 for (i = 0; i < cfg->line_outs; i++) {
9061 nid = spec->multiout.dac_nids[i];
9066 err = add_control(spec, ALC_CTL_BIND_MUTE,
9067 "Center Playback Switch",
9068 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
9072 err = add_control(spec, ALC_CTL_BIND_MUTE,
9073 "LFE Playback Switch",
9074 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
9079 for (idx = 0; idx < ARRAY_SIZE(alc861_dac_nids) - 1;
9081 if (nid == alc861_dac_nids[idx])
9083 sprintf(name, "%s Playback Switch", chname[idx]);
9084 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
9085 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
9094 static int alc861_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin)
9102 if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
9104 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
9105 "Headphone Playback Switch",
9106 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
9109 spec->multiout.hp_nid = nid;
9114 /* create playback/capture controls for input pins */
9115 static int alc861_auto_create_analog_input_ctls(struct alc_spec *spec,
9116 const struct auto_pin_cfg *cfg)
9118 struct hda_input_mux *imux = &spec->private_imux;
9119 int i, err, idx, idx1;
9121 for (i = 0; i < AUTO_PIN_LAST; i++) {
9122 switch (cfg->input_pins[i]) {
9125 idx = 2; /* Line In */
9129 idx = 2; /* Line In */
9133 idx = 1; /* Mic In */
9137 idx = 1; /* Mic In */
9147 err = new_analog_input(spec, cfg->input_pins[i],
9148 auto_pin_cfg_labels[i], idx, 0x15);
9152 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
9153 imux->items[imux->num_items].index = idx1;
9159 static struct snd_kcontrol_new alc861_capture_mixer[] = {
9160 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
9161 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
9164 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9165 /* The multiple "Capture Source" controls confuse alsamixer
9166 * So call somewhat different..
9167 *FIXME: the controls appear in the "playback" view!
9169 /* .name = "Capture Source", */
9170 .name = "Input Source",
9172 .info = alc_mux_enum_info,
9173 .get = alc_mux_enum_get,
9174 .put = alc_mux_enum_put,
9179 static void alc861_auto_set_output_and_unmute(struct hda_codec *codec,
9181 int pin_type, int dac_idx)
9185 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
9187 snd_hda_codec_write(codec, dac_idx, 0, AC_VERB_SET_AMP_GAIN_MUTE,
9192 static void alc861_auto_init_multi_out(struct hda_codec *codec)
9194 struct alc_spec *spec = codec->spec;
9197 alc_subsystem_id(codec, 0x0e, 0x0f, 0x0b);
9198 for (i = 0; i < spec->autocfg.line_outs; i++) {
9199 hda_nid_t nid = spec->autocfg.line_out_pins[i];
9200 int pin_type = get_pin_type(spec->autocfg.line_out_type);
9202 alc861_auto_set_output_and_unmute(codec, nid, pin_type,
9203 spec->multiout.dac_nids[i]);
9207 static void alc861_auto_init_hp_out(struct hda_codec *codec)
9209 struct alc_spec *spec = codec->spec;
9212 pin = spec->autocfg.hp_pins[0];
9213 if (pin) /* connect to front */
9214 alc861_auto_set_output_and_unmute(codec, pin, PIN_HP,
9215 spec->multiout.dac_nids[0]);
9218 static void alc861_auto_init_analog_input(struct hda_codec *codec)
9220 struct alc_spec *spec = codec->spec;
9223 for (i = 0; i < AUTO_PIN_LAST; i++) {
9224 hda_nid_t nid = spec->autocfg.input_pins[i];
9225 if (nid >= 0x0c && nid <= 0x11) {
9226 snd_hda_codec_write(codec, nid, 0,
9227 AC_VERB_SET_PIN_WIDGET_CONTROL,
9228 i <= AUTO_PIN_FRONT_MIC ?
9229 PIN_VREF80 : PIN_IN);
9234 /* parse the BIOS configuration and set up the alc_spec */
9235 /* return 1 if successful, 0 if the proper config is not found,
9236 * or a negative error code
9238 static int alc861_parse_auto_config(struct hda_codec *codec)
9240 struct alc_spec *spec = codec->spec;
9242 static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
9244 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
9248 if (!spec->autocfg.line_outs)
9249 return 0; /* can't find valid BIOS pin config */
9251 err = alc861_auto_fill_dac_nids(spec, &spec->autocfg);
9254 err = alc861_auto_create_multi_out_ctls(spec, &spec->autocfg);
9257 err = alc861_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0]);
9260 err = alc861_auto_create_analog_input_ctls(spec, &spec->autocfg);
9264 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
9266 if (spec->autocfg.dig_out_pin)
9267 spec->multiout.dig_out_nid = ALC861_DIGOUT_NID;
9269 if (spec->kctl_alloc)
9270 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
9272 spec->init_verbs[spec->num_init_verbs++] = alc861_auto_init_verbs;
9274 spec->num_mux_defs = 1;
9275 spec->input_mux = &spec->private_imux;
9277 spec->adc_nids = alc861_adc_nids;
9278 spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
9279 spec->mixers[spec->num_mixers] = alc861_capture_mixer;
9285 /* additional initialization for auto-configuration model */
9286 static void alc861_auto_init(struct hda_codec *codec)
9288 alc861_auto_init_multi_out(codec);
9289 alc861_auto_init_hp_out(codec);
9290 alc861_auto_init_analog_input(codec);
9295 * configuration and preset
9297 static const char *alc861_models[ALC861_MODEL_LAST] = {
9298 [ALC861_3ST] = "3stack",
9299 [ALC660_3ST] = "3stack-660",
9300 [ALC861_3ST_DIG] = "3stack-dig",
9301 [ALC861_6ST_DIG] = "6stack-dig",
9302 [ALC861_UNIWILL_M31] = "uniwill-m31",
9303 [ALC861_TOSHIBA] = "toshiba",
9304 [ALC861_ASUS] = "asus",
9305 [ALC861_ASUS_LAPTOP] = "asus-laptop",
9306 [ALC861_AUTO] = "auto",
9309 static struct snd_pci_quirk alc861_cfg_tbl[] = {
9310 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST),
9311 SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP),
9312 SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP),
9313 SND_PCI_QUIRK(0x1043, 0x13d7, "ASUS A9rp", ALC861_ASUS_LAPTOP),
9314 SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS),
9315 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA),
9316 SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA),
9317 SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31),
9318 SND_PCI_QUIRK(0x1584, 0x9075, "Uniwill", ALC861_UNIWILL_M31),
9319 SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31),
9320 SND_PCI_QUIRK(0x1849, 0x0660, "Asrock 939SLI32", ALC660_3ST),
9321 SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST),
9325 static struct alc_config_preset alc861_presets[] = {
9327 .mixers = { alc861_3ST_mixer },
9328 .init_verbs = { alc861_threestack_init_verbs },
9329 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
9330 .dac_nids = alc861_dac_nids,
9331 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
9332 .channel_mode = alc861_threestack_modes,
9334 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
9335 .adc_nids = alc861_adc_nids,
9336 .input_mux = &alc861_capture_source,
9338 [ALC861_3ST_DIG] = {
9339 .mixers = { alc861_base_mixer },
9340 .init_verbs = { alc861_threestack_init_verbs },
9341 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
9342 .dac_nids = alc861_dac_nids,
9343 .dig_out_nid = ALC861_DIGOUT_NID,
9344 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
9345 .channel_mode = alc861_threestack_modes,
9347 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
9348 .adc_nids = alc861_adc_nids,
9349 .input_mux = &alc861_capture_source,
9351 [ALC861_6ST_DIG] = {
9352 .mixers = { alc861_base_mixer },
9353 .init_verbs = { alc861_base_init_verbs },
9354 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
9355 .dac_nids = alc861_dac_nids,
9356 .dig_out_nid = ALC861_DIGOUT_NID,
9357 .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
9358 .channel_mode = alc861_8ch_modes,
9359 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
9360 .adc_nids = alc861_adc_nids,
9361 .input_mux = &alc861_capture_source,
9364 .mixers = { alc861_3ST_mixer },
9365 .init_verbs = { alc861_threestack_init_verbs },
9366 .num_dacs = ARRAY_SIZE(alc660_dac_nids),
9367 .dac_nids = alc660_dac_nids,
9368 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
9369 .channel_mode = alc861_threestack_modes,
9371 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
9372 .adc_nids = alc861_adc_nids,
9373 .input_mux = &alc861_capture_source,
9375 [ALC861_UNIWILL_M31] = {
9376 .mixers = { alc861_uniwill_m31_mixer },
9377 .init_verbs = { alc861_uniwill_m31_init_verbs },
9378 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
9379 .dac_nids = alc861_dac_nids,
9380 .dig_out_nid = ALC861_DIGOUT_NID,
9381 .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes),
9382 .channel_mode = alc861_uniwill_m31_modes,
9384 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
9385 .adc_nids = alc861_adc_nids,
9386 .input_mux = &alc861_capture_source,
9388 [ALC861_TOSHIBA] = {
9389 .mixers = { alc861_toshiba_mixer },
9390 .init_verbs = { alc861_base_init_verbs,
9391 alc861_toshiba_init_verbs },
9392 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
9393 .dac_nids = alc861_dac_nids,
9394 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9395 .channel_mode = alc883_3ST_2ch_modes,
9396 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
9397 .adc_nids = alc861_adc_nids,
9398 .input_mux = &alc861_capture_source,
9399 .unsol_event = alc861_toshiba_unsol_event,
9400 .init_hook = alc861_toshiba_automute,
9403 .mixers = { alc861_asus_mixer },
9404 .init_verbs = { alc861_asus_init_verbs },
9405 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
9406 .dac_nids = alc861_dac_nids,
9407 .dig_out_nid = ALC861_DIGOUT_NID,
9408 .num_channel_mode = ARRAY_SIZE(alc861_asus_modes),
9409 .channel_mode = alc861_asus_modes,
9412 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
9413 .adc_nids = alc861_adc_nids,
9414 .input_mux = &alc861_capture_source,
9416 [ALC861_ASUS_LAPTOP] = {
9417 .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer },
9418 .init_verbs = { alc861_asus_init_verbs,
9419 alc861_asus_laptop_init_verbs },
9420 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
9421 .dac_nids = alc861_dac_nids,
9422 .dig_out_nid = ALC861_DIGOUT_NID,
9423 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9424 .channel_mode = alc883_3ST_2ch_modes,
9426 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
9427 .adc_nids = alc861_adc_nids,
9428 .input_mux = &alc861_capture_source,
9433 static int patch_alc861(struct hda_codec *codec)
9435 struct alc_spec *spec;
9439 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
9445 board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST,
9449 if (board_config < 0) {
9450 printk(KERN_INFO "hda_codec: Unknown model for ALC861, "
9451 "trying auto-probe from BIOS...\n");
9452 board_config = ALC861_AUTO;
9455 if (board_config == ALC861_AUTO) {
9456 /* automatic parse from the BIOS config */
9457 err = alc861_parse_auto_config(codec);
9463 "hda_codec: Cannot set up configuration "
9464 "from BIOS. Using base mode...\n");
9465 board_config = ALC861_3ST_DIG;
9469 if (board_config != ALC861_AUTO)
9470 setup_preset(spec, &alc861_presets[board_config]);
9472 spec->stream_name_analog = "ALC861 Analog";
9473 spec->stream_analog_playback = &alc861_pcm_analog_playback;
9474 spec->stream_analog_capture = &alc861_pcm_analog_capture;
9476 spec->stream_name_digital = "ALC861 Digital";
9477 spec->stream_digital_playback = &alc861_pcm_digital_playback;
9478 spec->stream_digital_capture = &alc861_pcm_digital_capture;
9480 codec->patch_ops = alc_patch_ops;
9481 if (board_config == ALC861_AUTO)
9482 spec->init_hook = alc861_auto_init;
9492 * In addition, an independent DAC
9494 #define ALC861VD_DIGOUT_NID 0x06
9496 static hda_nid_t alc861vd_dac_nids[4] = {
9497 /* front, surr, clfe, side surr */
9498 0x02, 0x03, 0x04, 0x05
9501 /* dac_nids for ALC660vd are in a different order - according to
9503 * This should probably tesult in a different mixer for 6stack models
9504 * of ALC660vd codecs, but for now there is only 3stack mixer
9505 * - and it is the same as in 861vd.
9506 * adc_nids in ALC660vd are (is) the same as in 861vd
9508 static hda_nid_t alc660vd_dac_nids[3] = {
9509 /* front, rear, clfe, rear_surr */
9513 static hda_nid_t alc861vd_adc_nids[1] = {
9519 /* FIXME: should be a matrix-type input source selection */
9520 static struct hda_input_mux alc861vd_capture_source = {
9524 { "Front Mic", 0x1 },
9530 static struct hda_input_mux alc861vd_dallas_capture_source = {
9533 { "Front Mic", 0x0 },
9534 { "ATAPI Mic", 0x1 },
9539 #define alc861vd_mux_enum_info alc_mux_enum_info
9540 #define alc861vd_mux_enum_get alc_mux_enum_get
9542 static int alc861vd_mux_enum_put(struct snd_kcontrol *kcontrol,
9543 struct snd_ctl_elem_value *ucontrol)
9545 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
9546 struct alc_spec *spec = codec->spec;
9547 const struct hda_input_mux *imux = spec->input_mux;
9548 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
9549 static hda_nid_t capture_mixers[1] = { 0x22 };
9550 hda_nid_t nid = capture_mixers[adc_idx];
9551 unsigned int *cur_val = &spec->cur_mux[adc_idx];
9552 unsigned int i, idx;
9554 idx = ucontrol->value.enumerated.item[0];
9555 if (idx >= imux->num_items)
9556 idx = imux->num_items - 1;
9557 if (*cur_val == idx && !codec->in_resume)
9559 for (i = 0; i < imux->num_items; i++) {
9560 unsigned int v = (i == idx) ? 0x7000 : 0x7080;
9561 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
9562 v | (imux->items[i].index << 8));
9571 static struct hda_channel_mode alc861vd_3stack_2ch_modes[1] = {
9578 static struct hda_verb alc861vd_6stack_ch6_init[] = {
9579 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
9580 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9581 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9582 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9589 static struct hda_verb alc861vd_6stack_ch8_init[] = {
9590 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9591 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9592 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9593 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9597 static struct hda_channel_mode alc861vd_6stack_modes[2] = {
9598 { 6, alc861vd_6stack_ch6_init },
9599 { 8, alc861vd_6stack_ch8_init },
9602 static struct snd_kcontrol_new alc861vd_chmode_mixer[] = {
9604 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9605 .name = "Channel Mode",
9606 .info = alc_ch_mode_info,
9607 .get = alc_ch_mode_get,
9608 .put = alc_ch_mode_put,
9613 static struct snd_kcontrol_new alc861vd_capture_mixer[] = {
9614 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
9615 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
9618 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9619 /* The multiple "Capture Source" controls confuse alsamixer
9620 * So call somewhat different..
9621 *FIXME: the controls appear in the "playback" view!
9623 /* .name = "Capture Source", */
9624 .name = "Input Source",
9626 .info = alc861vd_mux_enum_info,
9627 .get = alc861vd_mux_enum_get,
9628 .put = alc861vd_mux_enum_put,
9633 /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
9634 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
9636 static struct snd_kcontrol_new alc861vd_6st_mixer[] = {
9637 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
9638 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
9640 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
9641 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
9643 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0,
9645 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0,
9647 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
9648 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
9650 HDA_CODEC_VOLUME("Side Playback Volume", 0x05, 0x0, HDA_OUTPUT),
9651 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
9653 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
9655 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9656 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9657 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9659 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
9660 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
9661 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
9663 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9664 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9666 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9667 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9669 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
9670 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
9675 static struct snd_kcontrol_new alc861vd_3st_mixer[] = {
9676 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
9677 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
9679 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
9681 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9682 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9683 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9685 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
9686 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
9687 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
9689 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9690 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9692 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9693 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9695 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
9696 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
9701 static struct snd_kcontrol_new alc861vd_lenovo_mixer[] = {
9702 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
9703 /*HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),*/
9704 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9706 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
9708 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9709 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9710 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9712 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
9713 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
9714 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
9716 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9717 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9722 /* Pin assignment: Front=0x14, HP = 0x15,
9723 * Front Mic=0x18, ATAPI Mic = 0x19, Line In = 0x1d
9725 static struct snd_kcontrol_new alc861vd_dallas_mixer[] = {
9726 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
9727 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
9728 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
9729 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
9730 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9731 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9732 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
9733 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
9734 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x05, HDA_INPUT),
9735 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x05, HDA_INPUT),
9736 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
9737 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
9739 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9740 /* .name = "Capture Source", */
9741 .name = "Input Source",
9743 .info = alc882_mux_enum_info,
9744 .get = alc882_mux_enum_get,
9745 .put = alc882_mux_enum_put,
9751 * generic initialization of ADC, input mixers and output mixers
9753 static struct hda_verb alc861vd_volume_init_verbs[] = {
9755 * Unmute ADC0 and set the default input to mic-in
9757 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
9758 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9760 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of
9761 * the analog-loopback mixer widget
9763 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
9764 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9765 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9766 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
9767 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
9768 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
9770 /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */
9771 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9772 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9773 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
9774 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
9777 * Set up output mixers (0x02 - 0x05)
9779 /* set vol=0 to output mixers */
9780 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9781 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9782 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9783 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9785 /* set up input amps for analog loopback */
9786 /* Amp Indices: DAC = 0, mixer = 1 */
9787 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9788 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9789 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9790 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9791 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9792 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9793 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9794 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9800 * 3-stack pin configuration:
9801 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
9803 static struct hda_verb alc861vd_3stack_init_verbs[] = {
9805 * Set pin mode and muting
9807 /* set front pin widgets 0x14 for output */
9808 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9809 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9810 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
9812 /* Mic (rear) pin: input vref at 80% */
9813 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
9814 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9815 /* Front Mic pin: input vref at 80% */
9816 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
9817 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9818 /* Line In pin: input */
9819 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
9820 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9821 /* Line-2 In: Headphone output (output 0 - 0x0c) */
9822 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9823 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9824 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
9825 /* CD pin widget for input */
9826 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
9832 * 6-stack pin configuration:
9834 static struct hda_verb alc861vd_6stack_init_verbs[] = {
9836 * Set pin mode and muting
9838 /* set front pin widgets 0x14 for output */
9839 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9840 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9841 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
9843 /* Rear Pin: output 1 (0x0d) */
9844 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9845 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9846 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
9847 /* CLFE Pin: output 2 (0x0e) */
9848 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9849 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9850 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
9851 /* Side Pin: output 3 (0x0f) */
9852 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9853 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9854 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
9856 /* Mic (rear) pin: input vref at 80% */
9857 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
9858 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9859 /* Front Mic pin: input vref at 80% */
9860 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
9861 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9862 /* Line In pin: input */
9863 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
9864 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9865 /* Line-2 In: Headphone output (output 0 - 0x0c) */
9866 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9867 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9868 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
9869 /* CD pin widget for input */
9870 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
9875 static struct hda_verb alc861vd_eapd_verbs[] = {
9876 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
9880 static struct hda_verb alc861vd_lenovo_unsol_verbs[] = {
9881 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9882 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9883 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
9884 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9885 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
9889 /* toggle speaker-output according to the hp-jack state */
9890 static void alc861vd_lenovo_hp_automute(struct hda_codec *codec)
9892 unsigned int present;
9895 present = snd_hda_codec_read(codec, 0x1b, 0,
9896 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
9897 bits = present ? 0x80 : 0;
9898 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
9900 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
9904 static void alc861vd_lenovo_mic_automute(struct hda_codec *codec)
9906 unsigned int present;
9909 present = snd_hda_codec_read(codec, 0x18, 0,
9910 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
9911 bits = present ? 0x80 : 0;
9912 snd_hda_codec_amp_update(codec, 0x0b, 0, HDA_INPUT, 1,
9914 snd_hda_codec_amp_update(codec, 0x0b, 1, HDA_INPUT, 1,
9918 static void alc861vd_lenovo_automute(struct hda_codec *codec)
9920 alc861vd_lenovo_hp_automute(codec);
9921 alc861vd_lenovo_mic_automute(codec);
9924 static void alc861vd_lenovo_unsol_event(struct hda_codec *codec,
9927 switch (res >> 26) {
9928 case ALC880_HP_EVENT:
9929 alc861vd_lenovo_hp_automute(codec);
9931 case ALC880_MIC_EVENT:
9932 alc861vd_lenovo_mic_automute(codec);
9937 static struct hda_verb alc861vd_dallas_verbs[] = {
9938 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9939 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9940 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9941 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9943 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9944 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9945 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9946 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9947 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9948 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9949 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9950 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9952 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9953 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9954 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9955 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9956 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9957 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9958 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9959 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9961 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
9962 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9963 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
9964 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9965 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
9966 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
9967 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
9968 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
9970 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9971 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
9972 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
9973 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
9975 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9976 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
9977 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9982 /* toggle speaker-output according to the hp-jack state */
9983 static void alc861vd_dallas_automute(struct hda_codec *codec)
9985 unsigned int present;
9987 present = snd_hda_codec_read(codec, 0x15, 0,
9988 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
9989 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
9990 0x80, present ? 0x80 : 0);
9991 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
9992 0x80, present ? 0x80 : 0);
9995 static void alc861vd_dallas_unsol_event(struct hda_codec *codec, unsigned int res)
9997 if ((res >> 26) == ALC880_HP_EVENT)
9998 alc861vd_dallas_automute(codec);
10001 /* pcm configuration: identiacal with ALC880 */
10002 #define alc861vd_pcm_analog_playback alc880_pcm_analog_playback
10003 #define alc861vd_pcm_analog_capture alc880_pcm_analog_capture
10004 #define alc861vd_pcm_digital_playback alc880_pcm_digital_playback
10005 #define alc861vd_pcm_digital_capture alc880_pcm_digital_capture
10008 * configuration and preset
10010 static const char *alc861vd_models[ALC861VD_MODEL_LAST] = {
10011 [ALC660VD_3ST] = "3stack-660",
10012 [ALC660VD_3ST_DIG]= "3stack-660-digout",
10013 [ALC861VD_3ST] = "3stack",
10014 [ALC861VD_3ST_DIG] = "3stack-digout",
10015 [ALC861VD_6ST_DIG] = "6stack-digout",
10016 [ALC861VD_LENOVO] = "lenovo",
10017 [ALC861VD_DALLAS] = "dallas",
10018 [ALC861VD_AUTO] = "auto",
10021 static struct snd_pci_quirk alc861vd_cfg_tbl[] = {
10022 SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST),
10023 SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST),
10024 SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660VD_3ST_DIG),
10025 SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST),
10026 SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST),
10028 SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),
10029 SND_PCI_QUIRK(0x1179, 0xff01, "DALLAS", ALC861VD_DALLAS),
10030 SND_PCI_QUIRK(0x17aa, 0x3802, "Lenovo 3000 C200", ALC861VD_LENOVO),
10031 SND_PCI_QUIRK(0x17aa, 0x2066, "Lenovo", ALC861VD_LENOVO),
10032 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba A135", ALC861VD_LENOVO),
10036 static struct alc_config_preset alc861vd_presets[] = {
10038 .mixers = { alc861vd_3st_mixer },
10039 .init_verbs = { alc861vd_volume_init_verbs,
10040 alc861vd_3stack_init_verbs },
10041 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
10042 .dac_nids = alc660vd_dac_nids,
10043 .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
10044 .adc_nids = alc861vd_adc_nids,
10045 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
10046 .channel_mode = alc861vd_3stack_2ch_modes,
10047 .input_mux = &alc861vd_capture_source,
10049 [ALC660VD_3ST_DIG] = {
10050 .mixers = { alc861vd_3st_mixer },
10051 .init_verbs = { alc861vd_volume_init_verbs,
10052 alc861vd_3stack_init_verbs },
10053 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
10054 .dac_nids = alc660vd_dac_nids,
10055 .dig_out_nid = ALC861VD_DIGOUT_NID,
10056 .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
10057 .adc_nids = alc861vd_adc_nids,
10058 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
10059 .channel_mode = alc861vd_3stack_2ch_modes,
10060 .input_mux = &alc861vd_capture_source,
10063 .mixers = { alc861vd_3st_mixer },
10064 .init_verbs = { alc861vd_volume_init_verbs,
10065 alc861vd_3stack_init_verbs },
10066 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
10067 .dac_nids = alc861vd_dac_nids,
10068 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
10069 .channel_mode = alc861vd_3stack_2ch_modes,
10070 .input_mux = &alc861vd_capture_source,
10072 [ALC861VD_3ST_DIG] = {
10073 .mixers = { alc861vd_3st_mixer },
10074 .init_verbs = { alc861vd_volume_init_verbs,
10075 alc861vd_3stack_init_verbs },
10076 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
10077 .dac_nids = alc861vd_dac_nids,
10078 .dig_out_nid = ALC861VD_DIGOUT_NID,
10079 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
10080 .channel_mode = alc861vd_3stack_2ch_modes,
10081 .input_mux = &alc861vd_capture_source,
10083 [ALC861VD_6ST_DIG] = {
10084 .mixers = { alc861vd_6st_mixer, alc861vd_chmode_mixer },
10085 .init_verbs = { alc861vd_volume_init_verbs,
10086 alc861vd_6stack_init_verbs },
10087 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
10088 .dac_nids = alc861vd_dac_nids,
10089 .dig_out_nid = ALC861VD_DIGOUT_NID,
10090 .num_channel_mode = ARRAY_SIZE(alc861vd_6stack_modes),
10091 .channel_mode = alc861vd_6stack_modes,
10092 .input_mux = &alc861vd_capture_source,
10094 [ALC861VD_LENOVO] = {
10095 .mixers = { alc861vd_lenovo_mixer },
10096 .init_verbs = { alc861vd_volume_init_verbs,
10097 alc861vd_3stack_init_verbs,
10098 alc861vd_eapd_verbs,
10099 alc861vd_lenovo_unsol_verbs },
10100 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
10101 .dac_nids = alc660vd_dac_nids,
10102 .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
10103 .adc_nids = alc861vd_adc_nids,
10104 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
10105 .channel_mode = alc861vd_3stack_2ch_modes,
10106 .input_mux = &alc861vd_capture_source,
10107 .unsol_event = alc861vd_lenovo_unsol_event,
10108 .init_hook = alc861vd_lenovo_automute,
10110 [ALC861VD_DALLAS] = {
10111 .mixers = { alc861vd_dallas_mixer },
10112 .init_verbs = { alc861vd_dallas_verbs },
10113 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
10114 .dac_nids = alc861vd_dac_nids,
10115 .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
10116 .adc_nids = alc861vd_adc_nids,
10117 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
10118 .channel_mode = alc861vd_3stack_2ch_modes,
10119 .input_mux = &alc861vd_dallas_capture_source,
10120 .unsol_event = alc861vd_dallas_unsol_event,
10121 .init_hook = alc861vd_dallas_automute,
10126 * BIOS auto configuration
10128 static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec,
10129 hda_nid_t nid, int pin_type, int dac_idx)
10131 /* set as output */
10132 snd_hda_codec_write(codec, nid, 0,
10133 AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
10134 snd_hda_codec_write(codec, nid, 0,
10135 AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
10138 static void alc861vd_auto_init_multi_out(struct hda_codec *codec)
10140 struct alc_spec *spec = codec->spec;
10143 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
10144 for (i = 0; i <= HDA_SIDE; i++) {
10145 hda_nid_t nid = spec->autocfg.line_out_pins[i];
10146 int pin_type = get_pin_type(spec->autocfg.line_out_type);
10148 alc861vd_auto_set_output_and_unmute(codec, nid,
10154 static void alc861vd_auto_init_hp_out(struct hda_codec *codec)
10156 struct alc_spec *spec = codec->spec;
10159 pin = spec->autocfg.hp_pins[0];
10160 if (pin) /* connect to front and use dac 0 */
10161 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
10164 #define alc861vd_is_input_pin(nid) alc880_is_input_pin(nid)
10165 #define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID
10167 static void alc861vd_auto_init_analog_input(struct hda_codec *codec)
10169 struct alc_spec *spec = codec->spec;
10172 for (i = 0; i < AUTO_PIN_LAST; i++) {
10173 hda_nid_t nid = spec->autocfg.input_pins[i];
10174 if (alc861vd_is_input_pin(nid)) {
10175 snd_hda_codec_write(codec, nid, 0,
10176 AC_VERB_SET_PIN_WIDGET_CONTROL,
10177 i <= AUTO_PIN_FRONT_MIC ?
10178 PIN_VREF80 : PIN_IN);
10179 if (nid != ALC861VD_PIN_CD_NID)
10180 snd_hda_codec_write(codec, nid, 0,
10181 AC_VERB_SET_AMP_GAIN_MUTE,
10187 #define alc861vd_idx_to_mixer_vol(nid) ((nid) + 0x02)
10188 #define alc861vd_idx_to_mixer_switch(nid) ((nid) + 0x0c)
10190 /* add playback controls from the parsed DAC table */
10191 /* Based on ALC880 version. But ALC861VD has separate,
10192 * different NIDs for mute/unmute switch and volume control */
10193 static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
10194 const struct auto_pin_cfg *cfg)
10197 static const char *chname[4] = {"Front", "Surround", "CLFE", "Side"};
10198 hda_nid_t nid_v, nid_s;
10201 for (i = 0; i < cfg->line_outs; i++) {
10202 if (!spec->multiout.dac_nids[i])
10204 nid_v = alc861vd_idx_to_mixer_vol(
10206 spec->multiout.dac_nids[i]));
10207 nid_s = alc861vd_idx_to_mixer_switch(
10209 spec->multiout.dac_nids[i]));
10213 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10214 "Center Playback Volume",
10215 HDA_COMPOSE_AMP_VAL(nid_v, 1, 0,
10219 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10220 "LFE Playback Volume",
10221 HDA_COMPOSE_AMP_VAL(nid_v, 2, 0,
10225 err = add_control(spec, ALC_CTL_BIND_MUTE,
10226 "Center Playback Switch",
10227 HDA_COMPOSE_AMP_VAL(nid_s, 1, 2,
10231 err = add_control(spec, ALC_CTL_BIND_MUTE,
10232 "LFE Playback Switch",
10233 HDA_COMPOSE_AMP_VAL(nid_s, 2, 2,
10238 sprintf(name, "%s Playback Volume", chname[i]);
10239 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
10240 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0,
10244 sprintf(name, "%s Playback Switch", chname[i]);
10245 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
10246 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2,
10255 /* add playback controls for speaker and HP outputs */
10256 /* Based on ALC880 version. But ALC861VD has separate,
10257 * different NIDs for mute/unmute switch and volume control */
10258 static int alc861vd_auto_create_extra_out(struct alc_spec *spec,
10259 hda_nid_t pin, const char *pfx)
10261 hda_nid_t nid_v, nid_s;
10268 if (alc880_is_fixed_pin(pin)) {
10269 nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
10270 /* specify the DAC as the extra output */
10271 if (!spec->multiout.hp_nid)
10272 spec->multiout.hp_nid = nid_v;
10274 spec->multiout.extra_out_nid[0] = nid_v;
10275 /* control HP volume/switch on the output mixer amp */
10276 nid_v = alc861vd_idx_to_mixer_vol(
10277 alc880_fixed_pin_idx(pin));
10278 nid_s = alc861vd_idx_to_mixer_switch(
10279 alc880_fixed_pin_idx(pin));
10281 sprintf(name, "%s Playback Volume", pfx);
10282 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
10283 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT));
10286 sprintf(name, "%s Playback Switch", pfx);
10287 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
10288 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT));
10291 } else if (alc880_is_multi_pin(pin)) {
10292 /* set manual connection */
10293 /* we have only a switch on HP-out PIN */
10294 sprintf(name, "%s Playback Switch", pfx);
10295 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
10296 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
10303 /* parse the BIOS configuration and set up the alc_spec
10304 * return 1 if successful, 0 if the proper config is not found,
10305 * or a negative error code
10306 * Based on ALC880 version - had to change it to override
10307 * alc880_auto_create_extra_out and alc880_auto_create_multi_out_ctls */
10308 static int alc861vd_parse_auto_config(struct hda_codec *codec)
10310 struct alc_spec *spec = codec->spec;
10312 static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
10314 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
10318 if (!spec->autocfg.line_outs)
10319 return 0; /* can't find valid BIOS pin config */
10321 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
10324 err = alc861vd_auto_create_multi_out_ctls(spec, &spec->autocfg);
10327 err = alc861vd_auto_create_extra_out(spec,
10328 spec->autocfg.speaker_pins[0],
10332 err = alc861vd_auto_create_extra_out(spec,
10333 spec->autocfg.hp_pins[0],
10337 err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
10341 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
10343 if (spec->autocfg.dig_out_pin)
10344 spec->multiout.dig_out_nid = ALC861VD_DIGOUT_NID;
10346 if (spec->kctl_alloc)
10347 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
10349 spec->init_verbs[spec->num_init_verbs++]
10350 = alc861vd_volume_init_verbs;
10352 spec->num_mux_defs = 1;
10353 spec->input_mux = &spec->private_imux;
10358 /* additional initialization for auto-configuration model */
10359 static void alc861vd_auto_init(struct hda_codec *codec)
10361 alc861vd_auto_init_multi_out(codec);
10362 alc861vd_auto_init_hp_out(codec);
10363 alc861vd_auto_init_analog_input(codec);
10366 static int patch_alc861vd(struct hda_codec *codec)
10368 struct alc_spec *spec;
10369 int err, board_config;
10371 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
10375 codec->spec = spec;
10377 board_config = snd_hda_check_board_config(codec, ALC861VD_MODEL_LAST,
10381 if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) {
10382 printk(KERN_INFO "hda_codec: Unknown model for ALC660VD/"
10383 "ALC861VD, trying auto-probe from BIOS...\n");
10384 board_config = ALC861VD_AUTO;
10387 if (board_config == ALC861VD_AUTO) {
10388 /* automatic parse from the BIOS config */
10389 err = alc861vd_parse_auto_config(codec);
10395 "hda_codec: Cannot set up configuration "
10396 "from BIOS. Using base mode...\n");
10397 board_config = ALC861VD_3ST;
10401 if (board_config != ALC861VD_AUTO)
10402 setup_preset(spec, &alc861vd_presets[board_config]);
10404 spec->stream_name_analog = "ALC861VD Analog";
10405 spec->stream_analog_playback = &alc861vd_pcm_analog_playback;
10406 spec->stream_analog_capture = &alc861vd_pcm_analog_capture;
10408 spec->stream_name_digital = "ALC861VD Digital";
10409 spec->stream_digital_playback = &alc861vd_pcm_digital_playback;
10410 spec->stream_digital_capture = &alc861vd_pcm_digital_capture;
10412 spec->adc_nids = alc861vd_adc_nids;
10413 spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids);
10415 spec->mixers[spec->num_mixers] = alc861vd_capture_mixer;
10416 spec->num_mixers++;
10418 codec->patch_ops = alc_patch_ops;
10420 if (board_config == ALC861VD_AUTO)
10421 spec->init_hook = alc861vd_auto_init;
10429 * ALC662 is almost identical with ALC880 but has cleaner and more flexible
10430 * configuration. Each pin widget can choose any input DACs and a mixer.
10431 * Each ADC is connected from a mixer of all inputs. This makes possible
10432 * 6-channel independent captures.
10434 * In addition, an independent DAC for the multi-playback (not used in this
10437 #define ALC662_DIGOUT_NID 0x06
10438 #define ALC662_DIGIN_NID 0x0a
10440 static hda_nid_t alc662_dac_nids[4] = {
10441 /* front, rear, clfe, rear_surr */
10445 static hda_nid_t alc662_adc_nids[1] = {
10450 /* FIXME: should be a matrix-type input source selection */
10452 static struct hda_input_mux alc662_capture_source = {
10456 { "Front Mic", 0x1 },
10462 static struct hda_input_mux alc662_lenovo_101e_capture_source = {
10469 #define alc662_mux_enum_info alc_mux_enum_info
10470 #define alc662_mux_enum_get alc_mux_enum_get
10472 static int alc662_mux_enum_put(struct snd_kcontrol *kcontrol,
10473 struct snd_ctl_elem_value *ucontrol)
10475 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10476 struct alc_spec *spec = codec->spec;
10477 const struct hda_input_mux *imux = spec->input_mux;
10478 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
10479 static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
10480 hda_nid_t nid = capture_mixers[adc_idx];
10481 unsigned int *cur_val = &spec->cur_mux[adc_idx];
10482 unsigned int i, idx;
10484 idx = ucontrol->value.enumerated.item[0];
10485 if (idx >= imux->num_items)
10486 idx = imux->num_items - 1;
10487 if (*cur_val == idx && !codec->in_resume)
10489 for (i = 0; i < imux->num_items; i++) {
10490 unsigned int v = (i == idx) ? 0x7000 : 0x7080;
10491 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
10492 v | (imux->items[i].index << 8));
10500 static struct hda_channel_mode alc662_3ST_2ch_modes[1] = {
10507 static struct hda_verb alc662_3ST_ch2_init[] = {
10508 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
10509 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
10510 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
10511 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
10518 static struct hda_verb alc662_3ST_ch6_init[] = {
10519 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10520 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10521 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
10522 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10523 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10524 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
10528 static struct hda_channel_mode alc662_3ST_6ch_modes[2] = {
10529 { 2, alc662_3ST_ch2_init },
10530 { 6, alc662_3ST_ch6_init },
10536 static struct hda_verb alc662_sixstack_ch6_init[] = {
10537 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
10538 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
10539 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10546 static struct hda_verb alc662_sixstack_ch8_init[] = {
10547 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10548 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10549 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10553 static struct hda_channel_mode alc662_5stack_modes[2] = {
10554 { 2, alc662_sixstack_ch6_init },
10555 { 6, alc662_sixstack_ch8_init },
10558 /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
10559 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
10562 static struct snd_kcontrol_new alc662_base_mixer[] = {
10563 /* output mixer control */
10564 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
10565 HDA_CODEC_MUTE("Front Playback Switch", 0x02, 0x0, HDA_OUTPUT),
10566 HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT),
10567 HDA_CODEC_MUTE("Surround Playback Switch", 0x03, 0x0, HDA_OUTPUT),
10568 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
10569 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
10570 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT),
10571 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT),
10572 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
10574 /*Input mixer control */
10575 HDA_CODEC_VOLUME("CD Playback Volume", 0xb, 0x4, HDA_INPUT),
10576 HDA_CODEC_MUTE("CD Playback Switch", 0xb, 0x4, HDA_INPUT),
10577 HDA_CODEC_VOLUME("Line Playback Volume", 0xb, 0x02, HDA_INPUT),
10578 HDA_CODEC_MUTE("Line Playback Switch", 0xb, 0x02, HDA_INPUT),
10579 HDA_CODEC_VOLUME("Mic Playback Volume", 0xb, 0x0, HDA_INPUT),
10580 HDA_CODEC_MUTE("Mic Playback Switch", 0xb, 0x0, HDA_INPUT),
10581 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0xb, 0x01, HDA_INPUT),
10582 HDA_CODEC_MUTE("Front Mic Playback Switch", 0xb, 0x01, HDA_INPUT),
10584 /* Capture mixer control */
10585 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
10586 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
10588 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10589 .name = "Capture Source",
10591 .info = alc_mux_enum_info,
10592 .get = alc_mux_enum_get,
10593 .put = alc_mux_enum_put,
10598 static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = {
10599 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
10600 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
10601 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
10602 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10603 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10604 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10605 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10606 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10607 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10608 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
10609 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
10610 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
10611 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
10612 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
10613 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
10615 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10616 /* .name = "Capture Source", */
10617 .name = "Input Source",
10619 .info = alc662_mux_enum_info,
10620 .get = alc662_mux_enum_get,
10621 .put = alc662_mux_enum_put,
10626 static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = {
10627 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
10628 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
10629 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
10630 HDA_BIND_MUTE("Surround Playback Switch", 0x03, 2, HDA_INPUT),
10631 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
10632 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
10633 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT),
10634 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT),
10635 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
10636 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10637 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10638 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10639 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10640 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10641 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10642 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
10643 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
10644 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
10645 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
10646 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
10647 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
10649 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10650 /* .name = "Capture Source", */
10651 .name = "Input Source",
10653 .info = alc662_mux_enum_info,
10654 .get = alc662_mux_enum_get,
10655 .put = alc662_mux_enum_put,
10660 static struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = {
10661 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
10662 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
10663 HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x03, 0x0, HDA_OUTPUT),
10664 HDA_BIND_MUTE("iSpeaker Playback Switch", 0x03, 2, HDA_INPUT),
10665 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
10666 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10667 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10668 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
10669 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
10670 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
10671 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
10673 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10674 /* .name = "Capture Source", */
10675 .name = "Input Source",
10677 .info = alc662_mux_enum_info,
10678 .get = alc662_mux_enum_get,
10679 .put = alc662_mux_enum_put,
10684 static struct snd_kcontrol_new alc662_chmode_mixer[] = {
10686 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10687 .name = "Channel Mode",
10688 .info = alc_ch_mode_info,
10689 .get = alc_ch_mode_get,
10690 .put = alc_ch_mode_put,
10695 static struct hda_verb alc662_init_verbs[] = {
10696 /* ADC: mute amp left and right */
10697 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10698 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
10699 /* Front mixer: unmute input/output amp left and right (volume = 0) */
10701 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10702 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10703 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
10704 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
10705 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
10707 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10708 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10709 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10710 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10711 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10712 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10714 /* Front Pin: output 0 (0x0c) */
10715 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10716 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10718 /* Rear Pin: output 1 (0x0d) */
10719 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10720 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10722 /* CLFE Pin: output 2 (0x0e) */
10723 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10724 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10726 /* Mic (rear) pin: input vref at 80% */
10727 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
10728 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10729 /* Front Mic pin: input vref at 80% */
10730 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
10731 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10732 /* Line In pin: input */
10733 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10734 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10735 /* Line-2 In: Headphone output (output 0 - 0x0c) */
10736 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10737 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10738 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
10739 /* CD pin widget for input */
10740 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10742 /* FIXME: use matrix-type input source selection */
10743 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
10745 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10746 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10747 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
10748 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
10752 static struct hda_verb alc662_sue_init_verbs[] = {
10753 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
10754 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
10759 * generic initialization of ADC, input mixers and output mixers
10761 static struct hda_verb alc662_auto_init_verbs[] = {
10763 * Unmute ADC and set the default input to mic-in
10765 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
10766 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10768 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
10770 * Note: PASD motherboards uses the Line In 2 as the input for front
10771 * panel mic (mic 2)
10773 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
10774 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10775 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10776 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
10777 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
10778 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
10781 * Set up output mixers (0x0c - 0x0f)
10783 /* set vol=0 to output mixers */
10784 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10785 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10786 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10788 /* set up input amps for analog loopback */
10789 /* Amp Indices: DAC = 0, mixer = 1 */
10790 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10791 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10792 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10793 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10794 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10795 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10798 /* FIXME: use matrix-type input source selection */
10799 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
10801 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10802 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10803 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
10804 /*{0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},*/
10805 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
10810 /* capture mixer elements */
10811 static struct snd_kcontrol_new alc662_capture_mixer[] = {
10812 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
10813 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
10815 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10816 /* The multiple "Capture Source" controls confuse alsamixer
10817 * So call somewhat different..
10818 * FIXME: the controls appear in the "playback" view!
10820 /* .name = "Capture Source", */
10821 .name = "Input Source",
10823 .info = alc882_mux_enum_info,
10824 .get = alc882_mux_enum_get,
10825 .put = alc882_mux_enum_put,
10830 static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
10832 unsigned int present;
10833 unsigned char bits;
10835 present = snd_hda_codec_read(codec, 0x14, 0,
10836 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
10837 bits = present ? 0x80 : 0;
10838 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
10840 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
10844 static void alc662_lenovo_101e_all_automute(struct hda_codec *codec)
10846 unsigned int present;
10847 unsigned char bits;
10849 present = snd_hda_codec_read(codec, 0x1b, 0,
10850 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
10851 bits = present ? 0x80 : 0;
10852 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
10854 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
10856 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
10858 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
10862 static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec,
10865 if ((res >> 26) == ALC880_HP_EVENT)
10866 alc662_lenovo_101e_all_automute(codec);
10867 if ((res >> 26) == ALC880_FRONT_EVENT)
10868 alc662_lenovo_101e_ispeaker_automute(codec);
10872 /* pcm configuration: identiacal with ALC880 */
10873 #define alc662_pcm_analog_playback alc880_pcm_analog_playback
10874 #define alc662_pcm_analog_capture alc880_pcm_analog_capture
10875 #define alc662_pcm_digital_playback alc880_pcm_digital_playback
10876 #define alc662_pcm_digital_capture alc880_pcm_digital_capture
10879 * configuration and preset
10881 static const char *alc662_models[ALC662_MODEL_LAST] = {
10882 [ALC662_3ST_2ch_DIG] = "3stack-dig",
10883 [ALC662_3ST_6ch_DIG] = "3stack-6ch-dig",
10884 [ALC662_3ST_6ch] = "3stack-6ch",
10885 [ALC662_5ST_DIG] = "6stack-dig",
10886 [ALC662_LENOVO_101E] = "lenovo-101e",
10887 [ALC662_AUTO] = "auto",
10890 static struct snd_pci_quirk alc662_cfg_tbl[] = {
10891 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E),
10895 static struct alc_config_preset alc662_presets[] = {
10896 [ALC662_3ST_2ch_DIG] = {
10897 .mixers = { alc662_3ST_2ch_mixer },
10898 .init_verbs = { alc662_init_verbs },
10899 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
10900 .dac_nids = alc662_dac_nids,
10901 .dig_out_nid = ALC662_DIGOUT_NID,
10902 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
10903 .adc_nids = alc662_adc_nids,
10904 .dig_in_nid = ALC662_DIGIN_NID,
10905 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
10906 .channel_mode = alc662_3ST_2ch_modes,
10907 .input_mux = &alc662_capture_source,
10909 [ALC662_3ST_6ch_DIG] = {
10910 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
10911 .init_verbs = { alc662_init_verbs },
10912 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
10913 .dac_nids = alc662_dac_nids,
10914 .dig_out_nid = ALC662_DIGOUT_NID,
10915 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
10916 .adc_nids = alc662_adc_nids,
10917 .dig_in_nid = ALC662_DIGIN_NID,
10918 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
10919 .channel_mode = alc662_3ST_6ch_modes,
10921 .input_mux = &alc662_capture_source,
10923 [ALC662_3ST_6ch] = {
10924 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
10925 .init_verbs = { alc662_init_verbs },
10926 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
10927 .dac_nids = alc662_dac_nids,
10928 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
10929 .adc_nids = alc662_adc_nids,
10930 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
10931 .channel_mode = alc662_3ST_6ch_modes,
10933 .input_mux = &alc662_capture_source,
10935 [ALC662_5ST_DIG] = {
10936 .mixers = { alc662_base_mixer, alc662_chmode_mixer },
10937 .init_verbs = { alc662_init_verbs },
10938 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
10939 .dac_nids = alc662_dac_nids,
10940 .dig_out_nid = ALC662_DIGOUT_NID,
10941 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
10942 .adc_nids = alc662_adc_nids,
10943 .dig_in_nid = ALC662_DIGIN_NID,
10944 .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes),
10945 .channel_mode = alc662_5stack_modes,
10946 .input_mux = &alc662_capture_source,
10948 [ALC662_LENOVO_101E] = {
10949 .mixers = { alc662_lenovo_101e_mixer },
10950 .init_verbs = { alc662_init_verbs, alc662_sue_init_verbs },
10951 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
10952 .dac_nids = alc662_dac_nids,
10953 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
10954 .adc_nids = alc662_adc_nids,
10955 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
10956 .channel_mode = alc662_3ST_2ch_modes,
10957 .input_mux = &alc662_lenovo_101e_capture_source,
10958 .unsol_event = alc662_lenovo_101e_unsol_event,
10959 .init_hook = alc662_lenovo_101e_all_automute,
10966 * BIOS auto configuration
10969 /* add playback controls from the parsed DAC table */
10970 static int alc662_auto_create_multi_out_ctls(struct alc_spec *spec,
10971 const struct auto_pin_cfg *cfg)
10974 static const char *chname[4] = {
10975 "Front", "Surround", NULL /*CLFE*/, "Side"
10980 for (i = 0; i < cfg->line_outs; i++) {
10981 if (!spec->multiout.dac_nids[i])
10983 nid = alc880_idx_to_dac(i);
10986 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10987 "Center Playback Volume",
10988 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
10992 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10993 "LFE Playback Volume",
10994 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
10998 err = add_control(spec, ALC_CTL_BIND_MUTE,
10999 "Center Playback Switch",
11000 HDA_COMPOSE_AMP_VAL(nid, 1, 2,
11004 err = add_control(spec, ALC_CTL_BIND_MUTE,
11005 "LFE Playback Switch",
11006 HDA_COMPOSE_AMP_VAL(nid, 2, 2,
11011 sprintf(name, "%s Playback Volume", chname[i]);
11012 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
11013 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
11017 sprintf(name, "%s Playback Switch", chname[i]);
11018 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
11019 HDA_COMPOSE_AMP_VAL(nid, 3, 2,
11028 /* add playback controls for speaker and HP outputs */
11029 static int alc662_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
11039 if (alc880_is_fixed_pin(pin)) {
11040 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
11041 /* printk("DAC nid=%x\n",nid); */
11042 /* specify the DAC as the extra output */
11043 if (!spec->multiout.hp_nid)
11044 spec->multiout.hp_nid = nid;
11046 spec->multiout.extra_out_nid[0] = nid;
11047 /* control HP volume/switch on the output mixer amp */
11048 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
11049 sprintf(name, "%s Playback Volume", pfx);
11050 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
11051 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
11054 sprintf(name, "%s Playback Switch", pfx);
11055 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
11056 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
11059 } else if (alc880_is_multi_pin(pin)) {
11060 /* set manual connection */
11061 /* we have only a switch on HP-out PIN */
11062 sprintf(name, "%s Playback Switch", pfx);
11063 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
11064 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
11071 /* create playback/capture controls for input pins */
11072 static int alc662_auto_create_analog_input_ctls(struct alc_spec *spec,
11073 const struct auto_pin_cfg *cfg)
11075 struct hda_input_mux *imux = &spec->private_imux;
11078 for (i = 0; i < AUTO_PIN_LAST; i++) {
11079 if (alc880_is_input_pin(cfg->input_pins[i])) {
11080 idx = alc880_input_pin_idx(cfg->input_pins[i]);
11081 err = new_analog_input(spec, cfg->input_pins[i],
11082 auto_pin_cfg_labels[i],
11086 imux->items[imux->num_items].label =
11087 auto_pin_cfg_labels[i];
11088 imux->items[imux->num_items].index =
11089 alc880_input_pin_idx(cfg->input_pins[i]);
11096 static void alc662_auto_set_output_and_unmute(struct hda_codec *codec,
11097 hda_nid_t nid, int pin_type,
11100 /* set as output */
11101 snd_hda_codec_write(codec, nid, 0,
11102 AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
11103 snd_hda_codec_write(codec, nid, 0,
11104 AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
11105 /* need the manual connection? */
11106 if (alc880_is_multi_pin(nid)) {
11107 struct alc_spec *spec = codec->spec;
11108 int idx = alc880_multi_pin_idx(nid);
11109 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
11110 AC_VERB_SET_CONNECT_SEL,
11111 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
11115 static void alc662_auto_init_multi_out(struct hda_codec *codec)
11117 struct alc_spec *spec = codec->spec;
11120 for (i = 0; i <= HDA_SIDE; i++) {
11121 hda_nid_t nid = spec->autocfg.line_out_pins[i];
11122 int pin_type = get_pin_type(spec->autocfg.line_out_type);
11124 alc662_auto_set_output_and_unmute(codec, nid, pin_type,
11129 static void alc662_auto_init_hp_out(struct hda_codec *codec)
11131 struct alc_spec *spec = codec->spec;
11134 pin = spec->autocfg.hp_pins[0];
11135 if (pin) /* connect to front */
11137 alc662_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
11140 #define alc662_is_input_pin(nid) alc880_is_input_pin(nid)
11141 #define ALC662_PIN_CD_NID ALC880_PIN_CD_NID
11143 static void alc662_auto_init_analog_input(struct hda_codec *codec)
11145 struct alc_spec *spec = codec->spec;
11148 for (i = 0; i < AUTO_PIN_LAST; i++) {
11149 hda_nid_t nid = spec->autocfg.input_pins[i];
11150 if (alc662_is_input_pin(nid)) {
11151 snd_hda_codec_write(codec, nid, 0,
11152 AC_VERB_SET_PIN_WIDGET_CONTROL,
11153 (i <= AUTO_PIN_FRONT_MIC ?
11154 PIN_VREF80 : PIN_IN));
11155 if (nid != ALC662_PIN_CD_NID)
11156 snd_hda_codec_write(codec, nid, 0,
11157 AC_VERB_SET_AMP_GAIN_MUTE,
11163 static int alc662_parse_auto_config(struct hda_codec *codec)
11165 struct alc_spec *spec = codec->spec;
11167 static hda_nid_t alc662_ignore[] = { 0x1d, 0 };
11169 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
11173 if (!spec->autocfg.line_outs)
11174 return 0; /* can't find valid BIOS pin config */
11176 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
11179 err = alc662_auto_create_multi_out_ctls(spec, &spec->autocfg);
11182 err = alc662_auto_create_extra_out(spec,
11183 spec->autocfg.speaker_pins[0],
11187 err = alc662_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
11191 err = alc662_auto_create_analog_input_ctls(spec, &spec->autocfg);
11195 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
11197 if (spec->autocfg.dig_out_pin)
11198 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
11200 if (spec->kctl_alloc)
11201 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
11203 spec->num_mux_defs = 1;
11204 spec->input_mux = &spec->private_imux;
11206 spec->init_verbs[spec->num_init_verbs++] = alc662_auto_init_verbs;
11207 spec->mixers[spec->num_mixers] = alc662_capture_mixer;
11208 spec->num_mixers++;
11212 /* additional initialization for auto-configuration model */
11213 static void alc662_auto_init(struct hda_codec *codec)
11215 alc662_auto_init_multi_out(codec);
11216 alc662_auto_init_hp_out(codec);
11217 alc662_auto_init_analog_input(codec);
11220 static int patch_alc662(struct hda_codec *codec)
11222 struct alc_spec *spec;
11223 int err, board_config;
11225 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
11229 codec->spec = spec;
11231 board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST,
11234 if (board_config < 0) {
11235 printk(KERN_INFO "hda_codec: Unknown model for ALC662, "
11236 "trying auto-probe from BIOS...\n");
11237 board_config = ALC662_AUTO;
11240 if (board_config == ALC662_AUTO) {
11241 /* automatic parse from the BIOS config */
11242 err = alc662_parse_auto_config(codec);
11248 "hda_codec: Cannot set up configuration "
11249 "from BIOS. Using base mode...\n");
11250 board_config = ALC662_3ST_2ch_DIG;
11254 if (board_config != ALC662_AUTO)
11255 setup_preset(spec, &alc662_presets[board_config]);
11257 spec->stream_name_analog = "ALC662 Analog";
11258 spec->stream_analog_playback = &alc662_pcm_analog_playback;
11259 spec->stream_analog_capture = &alc662_pcm_analog_capture;
11261 spec->stream_name_digital = "ALC662 Digital";
11262 spec->stream_digital_playback = &alc662_pcm_digital_playback;
11263 spec->stream_digital_capture = &alc662_pcm_digital_capture;
11265 if (!spec->adc_nids && spec->input_mux) {
11266 spec->adc_nids = alc662_adc_nids;
11267 spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids);
11270 codec->patch_ops = alc_patch_ops;
11271 if (board_config == ALC662_AUTO)
11272 spec->init_hook = alc662_auto_init;
11280 struct hda_codec_preset snd_hda_preset_realtek[] = {
11281 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
11282 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
11283 { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 },
11284 { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
11285 .patch = patch_alc861 },
11286 { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
11287 { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
11288 { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
11289 { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2",
11290 .patch = patch_alc883 },
11291 { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
11292 .patch = patch_alc662 },
11293 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
11294 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
11295 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc883 },
11296 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
11297 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc883 },
11298 {} /* terminator */