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,
97 ALC262_MODEL_LAST /* last tag */
114 /* ALC861-VD models */
152 ALC883_TARGA_2ch_DIG,
157 ALC883_LENOVO_101E_2ch,
163 #define GPIO_MASK 0x03
166 /* codec parameterization */
167 struct snd_kcontrol_new *mixers[5]; /* mixer arrays */
168 unsigned int num_mixers;
170 const struct hda_verb *init_verbs[5]; /* initialization verbs
174 unsigned int num_init_verbs;
176 char *stream_name_analog; /* analog PCM stream */
177 struct hda_pcm_stream *stream_analog_playback;
178 struct hda_pcm_stream *stream_analog_capture;
180 char *stream_name_digital; /* digital PCM stream */
181 struct hda_pcm_stream *stream_digital_playback;
182 struct hda_pcm_stream *stream_digital_capture;
185 struct hda_multi_out multiout; /* playback set-up
186 * max_channels, dacs must be set
187 * dig_out_nid and hp_nid are optional
191 unsigned int num_adc_nids;
193 hda_nid_t dig_in_nid; /* digital-in NID; optional */
196 unsigned int num_mux_defs;
197 const struct hda_input_mux *input_mux;
198 unsigned int cur_mux[3];
201 const struct hda_channel_mode *channel_mode;
202 int num_channel_mode;
205 /* PCM information */
206 struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */
208 /* dynamic controls, init_verbs and input_mux */
209 struct auto_pin_cfg autocfg;
210 unsigned int num_kctl_alloc, num_kctl_used;
211 struct snd_kcontrol_new *kctl_alloc;
212 struct hda_input_mux private_imux;
213 hda_nid_t private_dac_nids[5];
216 void (*init_hook)(struct hda_codec *codec);
217 void (*unsol_event)(struct hda_codec *codec, unsigned int res);
219 /* for pin sensing */
220 unsigned int sense_updated: 1;
221 unsigned int jack_present: 1;
225 * configuration template - to be copied to the spec instance
227 struct alc_config_preset {
228 struct snd_kcontrol_new *mixers[5]; /* should be identical size
231 const struct hda_verb *init_verbs[5];
232 unsigned int num_dacs;
234 hda_nid_t dig_out_nid; /* optional */
235 hda_nid_t hp_nid; /* optional */
236 unsigned int num_adc_nids;
238 hda_nid_t dig_in_nid;
239 unsigned int num_channel_mode;
240 const struct hda_channel_mode *channel_mode;
242 unsigned int num_mux_defs;
243 const struct hda_input_mux *input_mux;
244 void (*unsol_event)(struct hda_codec *, unsigned int);
245 void (*init_hook)(struct hda_codec *);
252 static int alc_mux_enum_info(struct snd_kcontrol *kcontrol,
253 struct snd_ctl_elem_info *uinfo)
255 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
256 struct alc_spec *spec = codec->spec;
257 unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id);
258 if (mux_idx >= spec->num_mux_defs)
260 return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo);
263 static int alc_mux_enum_get(struct snd_kcontrol *kcontrol,
264 struct snd_ctl_elem_value *ucontrol)
266 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
267 struct alc_spec *spec = codec->spec;
268 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
270 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
274 static int alc_mux_enum_put(struct snd_kcontrol *kcontrol,
275 struct snd_ctl_elem_value *ucontrol)
277 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
278 struct alc_spec *spec = codec->spec;
279 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
280 unsigned int mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx;
281 return snd_hda_input_mux_put(codec, &spec->input_mux[mux_idx], ucontrol,
282 spec->adc_nids[adc_idx],
283 &spec->cur_mux[adc_idx]);
288 * channel mode setting
290 static int alc_ch_mode_info(struct snd_kcontrol *kcontrol,
291 struct snd_ctl_elem_info *uinfo)
293 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
294 struct alc_spec *spec = codec->spec;
295 return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
296 spec->num_channel_mode);
299 static int alc_ch_mode_get(struct snd_kcontrol *kcontrol,
300 struct snd_ctl_elem_value *ucontrol)
302 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
303 struct alc_spec *spec = codec->spec;
304 return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
305 spec->num_channel_mode,
306 spec->multiout.max_channels);
309 static int alc_ch_mode_put(struct snd_kcontrol *kcontrol,
310 struct snd_ctl_elem_value *ucontrol)
312 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
313 struct alc_spec *spec = codec->spec;
314 int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
315 spec->num_channel_mode,
316 &spec->multiout.max_channels);
317 if (err >= 0 && spec->need_dac_fix)
318 spec->multiout.num_dacs = spec->multiout.max_channels / 2;
323 * Control the mode of pin widget settings via the mixer. "pc" is used
324 * instead of "%" to avoid consequences of accidently treating the % as
325 * being part of a format specifier. Maximum allowed length of a value is
326 * 63 characters plus NULL terminator.
328 * Note: some retasking pin complexes seem to ignore requests for input
329 * states other than HiZ (eg: PIN_VREFxx) and revert to HiZ if any of these
330 * are requested. Therefore order this list so that this behaviour will not
331 * cause problems when mixer clients move through the enum sequentially.
332 * NIDs 0x0f and 0x10 have been observed to have this behaviour as of
335 static char *alc_pin_mode_names[] = {
336 "Mic 50pc bias", "Mic 80pc bias",
337 "Line in", "Line out", "Headphone out",
339 static unsigned char alc_pin_mode_values[] = {
340 PIN_VREF50, PIN_VREF80, PIN_IN, PIN_OUT, PIN_HP,
342 /* The control can present all 5 options, or it can limit the options based
343 * in the pin being assumed to be exclusively an input or an output pin. In
344 * addition, "input" pins may or may not process the mic bias option
345 * depending on actual widget capability (NIDs 0x0f and 0x10 don't seem to
346 * accept requests for bias as of chip versions up to March 2006) and/or
347 * wiring in the computer.
349 #define ALC_PIN_DIR_IN 0x00
350 #define ALC_PIN_DIR_OUT 0x01
351 #define ALC_PIN_DIR_INOUT 0x02
352 #define ALC_PIN_DIR_IN_NOMICBIAS 0x03
353 #define ALC_PIN_DIR_INOUT_NOMICBIAS 0x04
355 /* Info about the pin modes supported by the different pin direction modes.
356 * For each direction the minimum and maximum values are given.
358 static signed char alc_pin_mode_dir_info[5][2] = {
359 { 0, 2 }, /* ALC_PIN_DIR_IN */
360 { 3, 4 }, /* ALC_PIN_DIR_OUT */
361 { 0, 4 }, /* ALC_PIN_DIR_INOUT */
362 { 2, 2 }, /* ALC_PIN_DIR_IN_NOMICBIAS */
363 { 2, 4 }, /* ALC_PIN_DIR_INOUT_NOMICBIAS */
365 #define alc_pin_mode_min(_dir) (alc_pin_mode_dir_info[_dir][0])
366 #define alc_pin_mode_max(_dir) (alc_pin_mode_dir_info[_dir][1])
367 #define alc_pin_mode_n_items(_dir) \
368 (alc_pin_mode_max(_dir)-alc_pin_mode_min(_dir)+1)
370 static int alc_pin_mode_info(struct snd_kcontrol *kcontrol,
371 struct snd_ctl_elem_info *uinfo)
373 unsigned int item_num = uinfo->value.enumerated.item;
374 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
376 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
378 uinfo->value.enumerated.items = alc_pin_mode_n_items(dir);
380 if (item_num<alc_pin_mode_min(dir) || item_num>alc_pin_mode_max(dir))
381 item_num = alc_pin_mode_min(dir);
382 strcpy(uinfo->value.enumerated.name, alc_pin_mode_names[item_num]);
386 static int alc_pin_mode_get(struct snd_kcontrol *kcontrol,
387 struct snd_ctl_elem_value *ucontrol)
390 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
391 hda_nid_t nid = kcontrol->private_value & 0xffff;
392 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
393 long *valp = ucontrol->value.integer.value;
394 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
395 AC_VERB_GET_PIN_WIDGET_CONTROL,
398 /* Find enumerated value for current pinctl setting */
399 i = alc_pin_mode_min(dir);
400 while (alc_pin_mode_values[i] != pinctl && i <= alc_pin_mode_max(dir))
402 *valp = i <= alc_pin_mode_max(dir) ? i: alc_pin_mode_min(dir);
406 static int alc_pin_mode_put(struct snd_kcontrol *kcontrol,
407 struct snd_ctl_elem_value *ucontrol)
410 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
411 hda_nid_t nid = kcontrol->private_value & 0xffff;
412 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
413 long val = *ucontrol->value.integer.value;
414 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
415 AC_VERB_GET_PIN_WIDGET_CONTROL,
418 if (val < alc_pin_mode_min(dir) || val > alc_pin_mode_max(dir))
419 val = alc_pin_mode_min(dir);
421 change = pinctl != alc_pin_mode_values[val];
423 /* Set pin mode to that requested */
424 snd_hda_codec_write(codec,nid,0,AC_VERB_SET_PIN_WIDGET_CONTROL,
425 alc_pin_mode_values[val]);
427 /* Also enable the retasking pin's input/output as required
428 * for the requested pin mode. Enum values of 2 or less are
431 * Dynamically switching the input/output buffers probably
432 * reduces noise slightly (particularly on input) so we'll
433 * do it. However, having both input and output buffers
434 * enabled simultaneously doesn't seem to be problematic if
435 * this turns out to be necessary in the future.
438 snd_hda_codec_write(codec, nid, 0,
439 AC_VERB_SET_AMP_GAIN_MUTE,
441 snd_hda_codec_write(codec, nid, 0,
442 AC_VERB_SET_AMP_GAIN_MUTE,
445 snd_hda_codec_write(codec, nid, 0,
446 AC_VERB_SET_AMP_GAIN_MUTE,
448 snd_hda_codec_write(codec, nid, 0,
449 AC_VERB_SET_AMP_GAIN_MUTE,
456 #define ALC_PIN_MODE(xname, nid, dir) \
457 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
458 .info = alc_pin_mode_info, \
459 .get = alc_pin_mode_get, \
460 .put = alc_pin_mode_put, \
461 .private_value = nid | (dir<<16) }
463 /* A switch control for ALC260 GPIO pins. Multiple GPIOs can be ganged
464 * together using a mask with more than one bit set. This control is
465 * currently used only by the ALC260 test model. At this stage they are not
466 * needed for any "production" models.
468 #ifdef CONFIG_SND_DEBUG
469 static int alc_gpio_data_info(struct snd_kcontrol *kcontrol,
470 struct snd_ctl_elem_info *uinfo)
472 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
474 uinfo->value.integer.min = 0;
475 uinfo->value.integer.max = 1;
478 static int alc_gpio_data_get(struct snd_kcontrol *kcontrol,
479 struct snd_ctl_elem_value *ucontrol)
481 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
482 hda_nid_t nid = kcontrol->private_value & 0xffff;
483 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
484 long *valp = ucontrol->value.integer.value;
485 unsigned int val = snd_hda_codec_read(codec, nid, 0,
486 AC_VERB_GET_GPIO_DATA, 0x00);
488 *valp = (val & mask) != 0;
491 static int alc_gpio_data_put(struct snd_kcontrol *kcontrol,
492 struct snd_ctl_elem_value *ucontrol)
495 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
496 hda_nid_t nid = kcontrol->private_value & 0xffff;
497 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
498 long val = *ucontrol->value.integer.value;
499 unsigned int gpio_data = snd_hda_codec_read(codec, nid, 0,
500 AC_VERB_GET_GPIO_DATA,
503 /* Set/unset the masked GPIO bit(s) as needed */
504 change = (val == 0 ? 0 : mask) != (gpio_data & mask);
509 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_GPIO_DATA, gpio_data);
513 #define ALC_GPIO_DATA_SWITCH(xname, nid, mask) \
514 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
515 .info = alc_gpio_data_info, \
516 .get = alc_gpio_data_get, \
517 .put = alc_gpio_data_put, \
518 .private_value = nid | (mask<<16) }
519 #endif /* CONFIG_SND_DEBUG */
521 /* A switch control to allow the enabling of the digital IO pins on the
522 * ALC260. This is incredibly simplistic; the intention of this control is
523 * to provide something in the test model allowing digital outputs to be
524 * identified if present. If models are found which can utilise these
525 * outputs a more complete mixer control can be devised for those models if
528 #ifdef CONFIG_SND_DEBUG
529 static int alc_spdif_ctrl_info(struct snd_kcontrol *kcontrol,
530 struct snd_ctl_elem_info *uinfo)
532 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
534 uinfo->value.integer.min = 0;
535 uinfo->value.integer.max = 1;
538 static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol,
539 struct snd_ctl_elem_value *ucontrol)
541 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
542 hda_nid_t nid = kcontrol->private_value & 0xffff;
543 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
544 long *valp = ucontrol->value.integer.value;
545 unsigned int val = snd_hda_codec_read(codec, nid, 0,
546 AC_VERB_GET_DIGI_CONVERT, 0x00);
548 *valp = (val & mask) != 0;
551 static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol,
552 struct snd_ctl_elem_value *ucontrol)
555 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
556 hda_nid_t nid = kcontrol->private_value & 0xffff;
557 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
558 long val = *ucontrol->value.integer.value;
559 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
560 AC_VERB_GET_DIGI_CONVERT,
563 /* Set/unset the masked control bit(s) as needed */
564 change = (val == 0 ? 0 : mask) != (ctrl_data & mask);
569 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1,
574 #define ALC_SPDIF_CTRL_SWITCH(xname, nid, mask) \
575 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
576 .info = alc_spdif_ctrl_info, \
577 .get = alc_spdif_ctrl_get, \
578 .put = alc_spdif_ctrl_put, \
579 .private_value = nid | (mask<<16) }
580 #endif /* CONFIG_SND_DEBUG */
583 * set up from the preset table
585 static void setup_preset(struct alc_spec *spec,
586 const struct alc_config_preset *preset)
590 for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++)
591 spec->mixers[spec->num_mixers++] = preset->mixers[i];
592 for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i];
594 spec->init_verbs[spec->num_init_verbs++] =
595 preset->init_verbs[i];
597 spec->channel_mode = preset->channel_mode;
598 spec->num_channel_mode = preset->num_channel_mode;
599 spec->need_dac_fix = preset->need_dac_fix;
601 spec->multiout.max_channels = spec->channel_mode[0].channels;
603 spec->multiout.num_dacs = preset->num_dacs;
604 spec->multiout.dac_nids = preset->dac_nids;
605 spec->multiout.dig_out_nid = preset->dig_out_nid;
606 spec->multiout.hp_nid = preset->hp_nid;
608 spec->num_mux_defs = preset->num_mux_defs;
609 if (! spec->num_mux_defs)
610 spec->num_mux_defs = 1;
611 spec->input_mux = preset->input_mux;
613 spec->num_adc_nids = preset->num_adc_nids;
614 spec->adc_nids = preset->adc_nids;
615 spec->dig_in_nid = preset->dig_in_nid;
617 spec->unsol_event = preset->unsol_event;
618 spec->init_hook = preset->init_hook;
621 /* Enable GPIO mask and set output */
622 static struct hda_verb alc_gpio1_init_verbs[] = {
623 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
624 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
625 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
629 static struct hda_verb alc_gpio2_init_verbs[] = {
630 {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
631 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
632 {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
636 /* 32-bit subsystem ID for BIOS loading in HD Audio codec.
637 * 31 ~ 16 : Manufacture ID
639 * 7 ~ 0 : Assembly ID
640 * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36
642 static void alc_subsystem_id(struct hda_codec *codec,
643 unsigned int porta, unsigned int porte,
646 unsigned int ass, tmp;
648 ass = codec->subsystem_id;
653 tmp = (ass & 0x38) >> 3; /* external Amp control */
656 snd_hda_sequence_write(codec, alc_gpio1_init_verbs);
659 snd_hda_sequence_write(codec, alc_gpio2_init_verbs);
663 if (ass & 4) { /* bit 2 : 0 = Desktop, 1 = Laptop */
665 tmp = (ass & 0x1800) >> 11;
667 case 0: port = porta; break;
668 case 1: port = porte; break;
669 case 2: port = portd; break;
672 snd_hda_codec_write(codec, port, 0,
673 AC_VERB_SET_EAPD_BTLENABLE,
676 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
677 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF,
678 (tmp == 5 ? 0x3040 : 0x3050));
684 * ALC880 3-stack model
686 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
687 * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18,
688 * F-Mic = 0x1b, HP = 0x19
691 static hda_nid_t alc880_dac_nids[4] = {
692 /* front, rear, clfe, rear_surr */
693 0x02, 0x05, 0x04, 0x03
696 static hda_nid_t alc880_adc_nids[3] = {
701 /* The datasheet says the node 0x07 is connected from inputs,
702 * but it shows zero connection in the real implementation on some devices.
703 * Note: this is a 915GAV bug, fixed on 915GLV
705 static hda_nid_t alc880_adc_nids_alt[2] = {
710 #define ALC880_DIGOUT_NID 0x06
711 #define ALC880_DIGIN_NID 0x0a
713 static struct hda_input_mux alc880_capture_source = {
717 { "Front Mic", 0x3 },
723 /* channel source setting (2/6 channel selection for 3-stack) */
725 static struct hda_verb alc880_threestack_ch2_init[] = {
726 /* set line-in to input, mute it */
727 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
728 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
729 /* set mic-in to input vref 80%, mute it */
730 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
731 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
736 static struct hda_verb alc880_threestack_ch6_init[] = {
737 /* set line-in to output, unmute it */
738 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
739 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
740 /* set mic-in to output, unmute it */
741 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
742 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
746 static struct hda_channel_mode alc880_threestack_modes[2] = {
747 { 2, alc880_threestack_ch2_init },
748 { 6, alc880_threestack_ch6_init },
751 static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
752 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
753 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
754 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
755 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
756 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
757 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
758 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
759 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
760 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
761 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
762 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
763 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
764 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
765 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
766 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
767 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
768 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
769 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
770 HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
772 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
773 .name = "Channel Mode",
774 .info = alc_ch_mode_info,
775 .get = alc_ch_mode_get,
776 .put = alc_ch_mode_put,
781 /* capture mixer elements */
782 static struct snd_kcontrol_new alc880_capture_mixer[] = {
783 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
784 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
785 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
786 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
787 HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
788 HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
790 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
791 /* The multiple "Capture Source" controls confuse alsamixer
792 * So call somewhat different..
793 * FIXME: the controls appear in the "playback" view!
795 /* .name = "Capture Source", */
796 .name = "Input Source",
798 .info = alc_mux_enum_info,
799 .get = alc_mux_enum_get,
800 .put = alc_mux_enum_put,
805 /* capture mixer elements (in case NID 0x07 not available) */
806 static struct snd_kcontrol_new alc880_capture_alt_mixer[] = {
807 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
808 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
809 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
810 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
812 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
813 /* The multiple "Capture Source" controls confuse alsamixer
814 * So call somewhat different..
815 * FIXME: the controls appear in the "playback" view!
817 /* .name = "Capture Source", */
818 .name = "Input Source",
820 .info = alc_mux_enum_info,
821 .get = alc_mux_enum_get,
822 .put = alc_mux_enum_put,
830 * ALC880 5-stack model
832 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d),
834 * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
835 * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
838 /* additional mixers to alc880_three_stack_mixer */
839 static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
840 HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
841 HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
845 /* channel source setting (6/8 channel selection for 5-stack) */
847 static struct hda_verb alc880_fivestack_ch6_init[] = {
848 /* set line-in to input, mute it */
849 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
850 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
855 static struct hda_verb alc880_fivestack_ch8_init[] = {
856 /* set line-in to output, unmute it */
857 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
858 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
862 static struct hda_channel_mode alc880_fivestack_modes[2] = {
863 { 6, alc880_fivestack_ch6_init },
864 { 8, alc880_fivestack_ch8_init },
869 * ALC880 6-stack model
871 * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e),
873 * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
874 * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
877 static hda_nid_t alc880_6st_dac_nids[4] = {
878 /* front, rear, clfe, rear_surr */
879 0x02, 0x03, 0x04, 0x05
882 static struct hda_input_mux alc880_6stack_capture_source = {
886 { "Front Mic", 0x1 },
892 /* fixed 8-channels */
893 static struct hda_channel_mode alc880_sixstack_modes[1] = {
897 static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
898 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
899 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
900 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
901 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
902 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
903 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
904 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
905 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
906 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
907 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
908 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
909 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
910 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
911 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
912 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
913 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
914 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
915 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
916 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
917 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
919 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
920 .name = "Channel Mode",
921 .info = alc_ch_mode_info,
922 .get = alc_ch_mode_get,
923 .put = alc_ch_mode_put,
932 * W810 has rear IO for:
935 * Center/LFE (DAC 04)
938 * The system also has a pair of internal speakers, and a headphone jack.
939 * These are both connected to Line2 on the codec, hence to DAC 02.
941 * There is a variable resistor to control the speaker or headphone
942 * volume. This is a hardware-only device without a software API.
944 * Plugging headphones in will disable the internal speakers. This is
945 * implemented in hardware, not via the driver using jack sense. In
946 * a similar fashion, plugging into the rear socket marked "front" will
947 * disable both the speakers and headphones.
949 * For input, there's a microphone jack, and an "audio in" jack.
950 * These may not do anything useful with this driver yet, because I
951 * haven't setup any initialization verbs for these yet...
954 static hda_nid_t alc880_w810_dac_nids[3] = {
955 /* front, rear/surround, clfe */
959 /* fixed 6 channels */
960 static struct hda_channel_mode alc880_w810_modes[1] = {
964 /* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
965 static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
966 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
967 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
968 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
969 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
970 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
971 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
972 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
973 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
974 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
982 * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
983 * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?),
987 static hda_nid_t alc880_z71v_dac_nids[1] = {
990 #define ALC880_Z71V_HP_DAC 0x03
992 /* fixed 2 channels */
993 static struct hda_channel_mode alc880_2_jack_modes[1] = {
997 static struct snd_kcontrol_new alc880_z71v_mixer[] = {
998 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
999 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1000 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1001 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
1002 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1003 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1004 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1005 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1012 * ALC880 F1734 model
1014 * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
1015 * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
1018 static hda_nid_t alc880_f1734_dac_nids[1] = {
1021 #define ALC880_F1734_HP_DAC 0x02
1023 static struct snd_kcontrol_new alc880_f1734_mixer[] = {
1024 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1025 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
1026 HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1027 HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
1028 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1029 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1030 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1031 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1040 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
1041 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
1042 * Mic = 0x18, Line = 0x1a
1045 #define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
1046 #define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
1048 static struct snd_kcontrol_new alc880_asus_mixer[] = {
1049 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1050 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1051 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1052 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
1053 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1054 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1055 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1056 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1057 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1058 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1059 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1060 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1061 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1062 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1064 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1065 .name = "Channel Mode",
1066 .info = alc_ch_mode_info,
1067 .get = alc_ch_mode_get,
1068 .put = alc_ch_mode_put,
1075 * ALC880 ASUS W1V model
1077 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
1078 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
1079 * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
1082 /* additional mixers to alc880_asus_mixer */
1083 static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
1084 HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
1085 HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
1089 /* additional mixers to alc880_asus_mixer */
1090 static struct snd_kcontrol_new alc880_pcbeep_mixer[] = {
1091 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1092 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
1097 static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
1098 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1099 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
1100 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
1101 HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
1102 HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
1103 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
1104 HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
1105 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
1106 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
1108 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1109 /* The multiple "Capture Source" controls confuse alsamixer
1110 * So call somewhat different..
1111 * FIXME: the controls appear in the "playback" view!
1113 /* .name = "Capture Source", */
1114 .name = "Input Source",
1116 .info = alc_mux_enum_info,
1117 .get = alc_mux_enum_get,
1118 .put = alc_mux_enum_put,
1124 static struct snd_kcontrol_new alc880_uniwill_mixer[] = {
1125 HDA_CODEC_VOLUME("HPhone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1126 HDA_BIND_MUTE("HPhone Playback Switch", 0x0c, 2, HDA_INPUT),
1127 HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1128 HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT),
1129 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1130 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1131 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1132 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1133 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1134 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1135 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1136 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1137 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1138 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1139 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1140 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1141 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1142 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
1144 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1145 .name = "Channel Mode",
1146 .info = alc_ch_mode_info,
1147 .get = alc_ch_mode_get,
1148 .put = alc_ch_mode_put,
1153 static struct snd_kcontrol_new alc880_fujitsu_mixer[] = {
1154 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1155 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
1156 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1157 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
1158 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1159 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1160 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1161 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1162 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1163 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1167 static struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = {
1168 HDA_CODEC_VOLUME("HPhone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1169 HDA_BIND_MUTE("HPhone Playback Switch", 0x0c, 2, HDA_INPUT),
1170 HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1171 HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT),
1172 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1173 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1178 * build control elements
1180 static int alc_build_controls(struct hda_codec *codec)
1182 struct alc_spec *spec = codec->spec;
1186 for (i = 0; i < spec->num_mixers; i++) {
1187 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
1192 if (spec->multiout.dig_out_nid) {
1193 err = snd_hda_create_spdif_out_ctls(codec,
1194 spec->multiout.dig_out_nid);
1198 if (spec->dig_in_nid) {
1199 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
1208 * initialize the codec volumes, etc
1212 * generic initialization of ADC, input mixers and output mixers
1214 static struct hda_verb alc880_volume_init_verbs[] = {
1216 * Unmute ADC0-2 and set the default input to mic-in
1218 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
1219 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1220 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
1221 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1222 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
1223 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1225 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
1227 * Note: PASD motherboards uses the Line In 2 as the input for front
1230 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
1231 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1232 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1233 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
1234 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
1235 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
1238 * Set up output mixers (0x0c - 0x0f)
1240 /* set vol=0 to output mixers */
1241 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1242 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1243 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1244 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1245 /* set up input amps for analog loopback */
1246 /* Amp Indices: DAC = 0, mixer = 1 */
1247 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1248 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1249 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1250 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1251 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1252 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1253 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1254 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1260 * 3-stack pin configuration:
1261 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
1263 static struct hda_verb alc880_pin_3stack_init_verbs[] = {
1265 * preset connection lists of input pins
1266 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
1268 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
1269 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1270 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
1273 * Set pin mode and muting
1275 /* set front pin widgets 0x14 for output */
1276 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1277 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1278 /* Mic1 (rear panel) pin widget for input and vref at 80% */
1279 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1280 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1281 /* Mic2 (as headphone out) for HP output */
1282 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1283 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1284 /* Line In pin widget for input */
1285 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1286 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1287 /* Line2 (as front mic) pin widget for input and vref at 80% */
1288 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1289 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1290 /* CD pin widget for input */
1291 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1297 * 5-stack pin configuration:
1298 * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
1299 * line-in/side = 0x1a, f-mic = 0x1b
1301 static struct hda_verb alc880_pin_5stack_init_verbs[] = {
1303 * preset connection lists of input pins
1304 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
1306 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1307 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
1310 * Set pin mode and muting
1312 /* set pin widgets 0x14-0x17 for output */
1313 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1314 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1315 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1316 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1317 /* unmute pins for output (no gain on this amp) */
1318 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1319 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1320 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1321 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1323 /* Mic1 (rear panel) pin widget for input and vref at 80% */
1324 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1325 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1326 /* Mic2 (as headphone out) for HP output */
1327 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1328 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1329 /* Line In pin widget for input */
1330 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1331 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1332 /* Line2 (as front mic) pin widget for input and vref at 80% */
1333 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1334 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1335 /* CD pin widget for input */
1336 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1342 * W810 pin configuration:
1343 * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
1345 static struct hda_verb alc880_pin_w810_init_verbs[] = {
1346 /* hphone/speaker input selector: front DAC */
1347 {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
1349 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1350 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1351 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1352 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1353 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1354 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1356 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1357 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1363 * Z71V pin configuration:
1364 * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
1366 static struct hda_verb alc880_pin_z71v_init_verbs[] = {
1367 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1368 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1369 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1370 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1372 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1373 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1374 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1375 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1381 * 6-stack pin configuration:
1382 * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18,
1383 * f-mic = 0x19, line = 0x1a, HP = 0x1b
1385 static struct hda_verb alc880_pin_6stack_init_verbs[] = {
1386 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1388 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1389 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1390 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1391 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1392 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1393 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1394 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1395 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1397 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1398 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1399 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1400 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1401 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1402 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1403 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1404 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1405 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1411 * Uniwill pin configuration:
1412 * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19,
1415 static struct hda_verb alc880_uniwill_init_verbs[] = {
1416 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1418 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1419 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1420 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1421 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1422 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1423 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1424 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1425 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1426 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1427 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1428 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1429 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1430 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1431 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1433 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1434 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1435 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1436 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1437 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1438 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1439 /* {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, */
1440 /* {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
1441 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1443 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
1444 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
1451 * HP = 0x14, InternalSpeaker = 0x15, mic = 0x19,
1453 static struct hda_verb alc880_uniwill_p53_init_verbs[] = {
1454 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1456 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1457 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1458 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1459 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1460 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1461 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1462 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1463 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1464 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1465 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1466 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1467 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1469 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1470 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1471 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1472 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1473 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1474 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1476 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
1477 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_DCVOL_EVENT},
1482 static struct hda_verb alc880_beep_init_verbs[] = {
1483 { 0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5) },
1487 /* toggle speaker-output according to the hp-jack state */
1488 static void alc880_uniwill_automute(struct hda_codec *codec)
1490 unsigned int present;
1492 present = snd_hda_codec_read(codec, 0x14, 0,
1493 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1494 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
1495 0x80, present ? 0x80 : 0);
1496 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
1497 0x80, present ? 0x80 : 0);
1498 snd_hda_codec_amp_update(codec, 0x16, 0, HDA_OUTPUT, 0,
1499 0x80, present ? 0x80 : 0);
1500 snd_hda_codec_amp_update(codec, 0x16, 1, HDA_OUTPUT, 0,
1501 0x80, present ? 0x80 : 0);
1503 present = snd_hda_codec_read(codec, 0x18, 0,
1504 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1505 snd_hda_codec_write(codec, 0x0b, 0, AC_VERB_SET_AMP_GAIN_MUTE,
1506 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
1509 static void alc880_uniwill_unsol_event(struct hda_codec *codec,
1512 /* Looks like the unsol event is incompatible with the standard
1513 * definition. 4bit tag is placed at 28 bit!
1515 if ((res >> 28) == ALC880_HP_EVENT ||
1516 (res >> 28) == ALC880_MIC_EVENT)
1517 alc880_uniwill_automute(codec);
1520 static void alc880_uniwill_p53_hp_automute(struct hda_codec *codec)
1522 unsigned int present;
1524 present = snd_hda_codec_read(codec, 0x14, 0,
1525 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1527 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_INPUT, 0,
1528 0x80, present ? 0x80 : 0);
1529 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_INPUT, 0,
1530 0x80, present ? 0x80 : 0);
1533 static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec)
1535 unsigned int present;
1537 present = snd_hda_codec_read(codec, 0x21, 0,
1538 AC_VERB_GET_VOLUME_KNOB_CONTROL, 0) & 0x7f;
1540 snd_hda_codec_amp_update(codec, 0x0c, 0, HDA_OUTPUT, 0,
1542 snd_hda_codec_amp_update(codec, 0x0c, 1, HDA_OUTPUT, 0,
1545 snd_hda_codec_amp_update(codec, 0x0d, 0, HDA_OUTPUT, 0,
1547 snd_hda_codec_amp_update(codec, 0x0d, 1, HDA_OUTPUT, 0,
1551 static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec,
1554 /* Looks like the unsol event is incompatible with the standard
1555 * definition. 4bit tag is placed at 28 bit!
1557 if ((res >> 28) == ALC880_HP_EVENT)
1558 alc880_uniwill_p53_hp_automute(codec);
1559 if ((res >> 28) == ALC880_DCVOL_EVENT)
1560 alc880_uniwill_p53_dcvol_automute(codec);
1565 * F1734 pin configuration:
1566 * HP = 0x14, speaker-out = 0x15, mic = 0x18
1568 static struct hda_verb alc880_pin_f1734_init_verbs[] = {
1569 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
1570 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
1571 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
1572 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
1574 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1575 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1576 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1577 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1579 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1580 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1581 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1582 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1583 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1584 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1585 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1586 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1587 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1594 * ASUS pin configuration:
1595 * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
1597 static struct hda_verb alc880_pin_asus_init_verbs[] = {
1598 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
1599 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
1600 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
1601 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
1603 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1604 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1605 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1606 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1607 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1608 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1609 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1610 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1612 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1613 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1614 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1615 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1616 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1617 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1618 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1619 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1620 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1625 /* Enable GPIO mask and set output */
1626 #define alc880_gpio1_init_verbs alc_gpio1_init_verbs
1627 #define alc880_gpio2_init_verbs alc_gpio2_init_verbs
1629 /* Clevo m520g init */
1630 static struct hda_verb alc880_pin_clevo_init_verbs[] = {
1631 /* headphone output */
1632 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
1634 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1635 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1637 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1638 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1640 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1641 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1642 /* Mic1 (rear panel) */
1643 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1644 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1645 /* Mic2 (front panel) */
1646 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1647 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1649 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1650 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1651 /* change to EAPD mode */
1652 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
1653 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
1658 static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
1659 /* change to EAPD mode */
1660 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
1661 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
1663 /* Headphone output */
1664 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1666 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1667 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
1669 /* Line In pin widget for input */
1670 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1671 /* CD pin widget for input */
1672 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1673 /* Mic1 (rear panel) pin widget for input and vref at 80% */
1674 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1676 /* change to EAPD mode */
1677 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
1678 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
1684 * LG m1 express dual
1687 * Rear Line-In/Out (blue): 0x14
1688 * Build-in Mic-In: 0x15
1690 * HP-Out (green): 0x1b
1691 * Mic-In/Out (red): 0x19
1695 /* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
1696 static hda_nid_t alc880_lg_dac_nids[3] = {
1700 /* seems analog CD is not working */
1701 static struct hda_input_mux alc880_lg_capture_source = {
1706 { "Internal Mic", 0x6 },
1710 /* 2,4,6 channel modes */
1711 static struct hda_verb alc880_lg_ch2_init[] = {
1712 /* set line-in and mic-in to input */
1713 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1714 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1718 static struct hda_verb alc880_lg_ch4_init[] = {
1719 /* set line-in to out and mic-in to input */
1720 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
1721 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1725 static struct hda_verb alc880_lg_ch6_init[] = {
1726 /* set line-in and mic-in to output */
1727 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
1728 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
1732 static struct hda_channel_mode alc880_lg_ch_modes[3] = {
1733 { 2, alc880_lg_ch2_init },
1734 { 4, alc880_lg_ch4_init },
1735 { 6, alc880_lg_ch6_init },
1738 static struct snd_kcontrol_new alc880_lg_mixer[] = {
1739 /* FIXME: it's not really "master" but front channels */
1740 HDA_CODEC_VOLUME("Master Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
1741 HDA_BIND_MUTE("Master Playback Switch", 0x0f, 2, HDA_INPUT),
1742 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1743 HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
1744 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
1745 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
1746 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
1747 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
1748 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1749 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1750 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
1751 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
1752 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
1753 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
1755 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1756 .name = "Channel Mode",
1757 .info = alc_ch_mode_info,
1758 .get = alc_ch_mode_get,
1759 .put = alc_ch_mode_put,
1764 static struct hda_verb alc880_lg_init_verbs[] = {
1765 /* set capture source to mic-in */
1766 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1767 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1768 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1769 /* mute all amp mixer inputs */
1770 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
1771 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(6)},
1772 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(7)},
1773 /* line-in to input */
1774 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1775 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1777 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1778 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1780 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1781 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1782 /* mic-in to input */
1783 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
1784 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1785 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1787 {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
1788 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1789 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1791 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
1795 /* toggle speaker-output according to the hp-jack state */
1796 static void alc880_lg_automute(struct hda_codec *codec)
1798 unsigned int present;
1800 present = snd_hda_codec_read(codec, 0x1b, 0,
1801 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1802 snd_hda_codec_amp_update(codec, 0x17, 0, HDA_OUTPUT, 0,
1803 0x80, present ? 0x80 : 0);
1804 snd_hda_codec_amp_update(codec, 0x17, 1, HDA_OUTPUT, 0,
1805 0x80, present ? 0x80 : 0);
1808 static void alc880_lg_unsol_event(struct hda_codec *codec, unsigned int res)
1810 /* Looks like the unsol event is incompatible with the standard
1811 * definition. 4bit tag is placed at 28 bit!
1813 if ((res >> 28) == 0x01)
1814 alc880_lg_automute(codec);
1823 * Built-in Mic-In: 0x19 (?)
1828 /* seems analog CD is not working */
1829 static struct hda_input_mux alc880_lg_lw_capture_source = {
1833 { "Internal Mic", 0x1 },
1837 static struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
1838 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1839 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
1840 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1841 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1842 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
1843 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
1847 static struct hda_verb alc880_lg_lw_init_verbs[] = {
1848 /* set capture source to mic-in */
1849 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1850 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1851 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1852 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(7)},
1854 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1855 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1857 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
1858 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1859 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1860 /* mic-in to input */
1861 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1862 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1864 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1865 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1867 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
1871 /* toggle speaker-output according to the hp-jack state */
1872 static void alc880_lg_lw_automute(struct hda_codec *codec)
1874 unsigned int present;
1876 present = snd_hda_codec_read(codec, 0x1b, 0,
1877 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1878 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
1879 0x80, present ? 0x80 : 0);
1880 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
1881 0x80, present ? 0x80 : 0);
1884 static void alc880_lg_lw_unsol_event(struct hda_codec *codec, unsigned int res)
1886 /* Looks like the unsol event is incompatible with the standard
1887 * definition. 4bit tag is placed at 28 bit!
1889 if ((res >> 28) == 0x01)
1890 alc880_lg_lw_automute(codec);
1897 static int alc_init(struct hda_codec *codec)
1899 struct alc_spec *spec = codec->spec;
1902 for (i = 0; i < spec->num_init_verbs; i++)
1903 snd_hda_sequence_write(codec, spec->init_verbs[i]);
1905 if (spec->init_hook)
1906 spec->init_hook(codec);
1911 static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
1913 struct alc_spec *spec = codec->spec;
1915 if (spec->unsol_event)
1916 spec->unsol_event(codec, res);
1923 static int alc_resume(struct hda_codec *codec)
1925 struct alc_spec *spec = codec->spec;
1929 for (i = 0; i < spec->num_mixers; i++)
1930 snd_hda_resume_ctls(codec, spec->mixers[i]);
1931 if (spec->multiout.dig_out_nid)
1932 snd_hda_resume_spdif_out(codec);
1933 if (spec->dig_in_nid)
1934 snd_hda_resume_spdif_in(codec);
1941 * Analog playback callbacks
1943 static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
1944 struct hda_codec *codec,
1945 struct snd_pcm_substream *substream)
1947 struct alc_spec *spec = codec->spec;
1948 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream);
1951 static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
1952 struct hda_codec *codec,
1953 unsigned int stream_tag,
1954 unsigned int format,
1955 struct snd_pcm_substream *substream)
1957 struct alc_spec *spec = codec->spec;
1958 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
1959 stream_tag, format, substream);
1962 static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
1963 struct hda_codec *codec,
1964 struct snd_pcm_substream *substream)
1966 struct alc_spec *spec = codec->spec;
1967 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
1973 static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
1974 struct hda_codec *codec,
1975 struct snd_pcm_substream *substream)
1977 struct alc_spec *spec = codec->spec;
1978 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
1981 static int alc880_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
1982 struct hda_codec *codec,
1983 unsigned int stream_tag,
1984 unsigned int format,
1985 struct snd_pcm_substream *substream)
1987 struct alc_spec *spec = codec->spec;
1988 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
1989 stream_tag, format, substream);
1992 static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
1993 struct hda_codec *codec,
1994 struct snd_pcm_substream *substream)
1996 struct alc_spec *spec = codec->spec;
1997 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
2003 static int alc880_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
2004 struct hda_codec *codec,
2005 unsigned int stream_tag,
2006 unsigned int format,
2007 struct snd_pcm_substream *substream)
2009 struct alc_spec *spec = codec->spec;
2011 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
2012 stream_tag, 0, format);
2016 static int alc880_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
2017 struct hda_codec *codec,
2018 struct snd_pcm_substream *substream)
2020 struct alc_spec *spec = codec->spec;
2022 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
2030 static struct hda_pcm_stream alc880_pcm_analog_playback = {
2034 /* NID is set in alc_build_pcms */
2036 .open = alc880_playback_pcm_open,
2037 .prepare = alc880_playback_pcm_prepare,
2038 .cleanup = alc880_playback_pcm_cleanup
2042 static struct hda_pcm_stream alc880_pcm_analog_capture = {
2046 /* NID is set in alc_build_pcms */
2048 .prepare = alc880_capture_pcm_prepare,
2049 .cleanup = alc880_capture_pcm_cleanup
2053 static struct hda_pcm_stream alc880_pcm_digital_playback = {
2057 /* NID is set in alc_build_pcms */
2059 .open = alc880_dig_playback_pcm_open,
2060 .close = alc880_dig_playback_pcm_close,
2061 .prepare = alc880_dig_playback_pcm_prepare
2065 static struct hda_pcm_stream alc880_pcm_digital_capture = {
2069 /* NID is set in alc_build_pcms */
2072 /* Used by alc_build_pcms to flag that a PCM has no playback stream */
2073 static struct hda_pcm_stream alc_pcm_null_playback = {
2079 static int alc_build_pcms(struct hda_codec *codec)
2081 struct alc_spec *spec = codec->spec;
2082 struct hda_pcm *info = spec->pcm_rec;
2085 codec->num_pcms = 1;
2086 codec->pcm_info = info;
2088 info->name = spec->stream_name_analog;
2089 if (spec->stream_analog_playback) {
2090 snd_assert(spec->multiout.dac_nids, return -EINVAL);
2091 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
2092 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
2094 if (spec->stream_analog_capture) {
2095 snd_assert(spec->adc_nids, return -EINVAL);
2096 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
2097 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
2100 if (spec->channel_mode) {
2101 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
2102 for (i = 0; i < spec->num_channel_mode; i++) {
2103 if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
2104 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
2109 /* SPDIF for stream index #1 */
2110 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
2111 codec->num_pcms = 2;
2112 info = spec->pcm_rec + 1;
2113 info->name = spec->stream_name_digital;
2114 if (spec->multiout.dig_out_nid &&
2115 spec->stream_digital_playback) {
2116 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
2117 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
2119 if (spec->dig_in_nid &&
2120 spec->stream_digital_capture) {
2121 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
2122 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
2126 /* If the use of more than one ADC is requested for the current
2127 * model, configure a second analog capture-only PCM.
2129 /* Additional Analaog capture for index #2 */
2130 if (spec->num_adc_nids > 1 && spec->stream_analog_capture &&
2132 codec->num_pcms = 3;
2133 info = spec->pcm_rec + 2;
2134 info->name = spec->stream_name_analog;
2135 /* No playback stream for second PCM */
2136 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = alc_pcm_null_playback;
2137 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
2138 if (spec->stream_analog_capture) {
2139 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
2140 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[1];
2147 static void alc_free(struct hda_codec *codec)
2149 struct alc_spec *spec = codec->spec;
2155 if (spec->kctl_alloc) {
2156 for (i = 0; i < spec->num_kctl_used; i++)
2157 kfree(spec->kctl_alloc[i].name);
2158 kfree(spec->kctl_alloc);
2165 static struct hda_codec_ops alc_patch_ops = {
2166 .build_controls = alc_build_controls,
2167 .build_pcms = alc_build_pcms,
2170 .unsol_event = alc_unsol_event,
2172 .resume = alc_resume,
2178 * Test configuration for debugging
2180 * Almost all inputs/outputs are enabled. I/O pins can be configured via
2183 #ifdef CONFIG_SND_DEBUG
2184 static hda_nid_t alc880_test_dac_nids[4] = {
2185 0x02, 0x03, 0x04, 0x05
2188 static struct hda_input_mux alc880_test_capture_source = {
2197 { "Surround", 0x6 },
2201 static struct hda_channel_mode alc880_test_modes[4] = {
2208 static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol,
2209 struct snd_ctl_elem_info *uinfo)
2211 static char *texts[] = {
2212 "N/A", "Line Out", "HP Out",
2213 "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
2215 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
2217 uinfo->value.enumerated.items = 8;
2218 if (uinfo->value.enumerated.item >= 8)
2219 uinfo->value.enumerated.item = 7;
2220 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
2224 static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol,
2225 struct snd_ctl_elem_value *ucontrol)
2227 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2228 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2229 unsigned int pin_ctl, item = 0;
2231 pin_ctl = snd_hda_codec_read(codec, nid, 0,
2232 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
2233 if (pin_ctl & AC_PINCTL_OUT_EN) {
2234 if (pin_ctl & AC_PINCTL_HP_EN)
2238 } else if (pin_ctl & AC_PINCTL_IN_EN) {
2239 switch (pin_ctl & AC_PINCTL_VREFEN) {
2240 case AC_PINCTL_VREF_HIZ: item = 3; break;
2241 case AC_PINCTL_VREF_50: item = 4; break;
2242 case AC_PINCTL_VREF_GRD: item = 5; break;
2243 case AC_PINCTL_VREF_80: item = 6; break;
2244 case AC_PINCTL_VREF_100: item = 7; break;
2247 ucontrol->value.enumerated.item[0] = item;
2251 static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol,
2252 struct snd_ctl_elem_value *ucontrol)
2254 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2255 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2256 static unsigned int ctls[] = {
2257 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
2258 AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
2259 AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
2260 AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
2261 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
2262 AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
2264 unsigned int old_ctl, new_ctl;
2266 old_ctl = snd_hda_codec_read(codec, nid, 0,
2267 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
2268 new_ctl = ctls[ucontrol->value.enumerated.item[0]];
2269 if (old_ctl != new_ctl) {
2270 snd_hda_codec_write(codec, nid, 0,
2271 AC_VERB_SET_PIN_WIDGET_CONTROL, new_ctl);
2272 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
2273 (ucontrol->value.enumerated.item[0] >= 3 ?
2280 static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol,
2281 struct snd_ctl_elem_info *uinfo)
2283 static char *texts[] = {
2284 "Front", "Surround", "CLFE", "Side"
2286 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
2288 uinfo->value.enumerated.items = 4;
2289 if (uinfo->value.enumerated.item >= 4)
2290 uinfo->value.enumerated.item = 3;
2291 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
2295 static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol,
2296 struct snd_ctl_elem_value *ucontrol)
2298 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2299 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2302 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
2303 ucontrol->value.enumerated.item[0] = sel & 3;
2307 static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol,
2308 struct snd_ctl_elem_value *ucontrol)
2310 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2311 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2314 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
2315 if (ucontrol->value.enumerated.item[0] != sel) {
2316 sel = ucontrol->value.enumerated.item[0] & 3;
2317 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, sel);
2323 #define PIN_CTL_TEST(xname,nid) { \
2324 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2326 .info = alc_test_pin_ctl_info, \
2327 .get = alc_test_pin_ctl_get, \
2328 .put = alc_test_pin_ctl_put, \
2329 .private_value = nid \
2332 #define PIN_SRC_TEST(xname,nid) { \
2333 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2335 .info = alc_test_pin_src_info, \
2336 .get = alc_test_pin_src_get, \
2337 .put = alc_test_pin_src_put, \
2338 .private_value = nid \
2341 static struct snd_kcontrol_new alc880_test_mixer[] = {
2342 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2343 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2344 HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
2345 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
2346 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2347 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
2348 HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
2349 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
2350 PIN_CTL_TEST("Front Pin Mode", 0x14),
2351 PIN_CTL_TEST("Surround Pin Mode", 0x15),
2352 PIN_CTL_TEST("CLFE Pin Mode", 0x16),
2353 PIN_CTL_TEST("Side Pin Mode", 0x17),
2354 PIN_CTL_TEST("In-1 Pin Mode", 0x18),
2355 PIN_CTL_TEST("In-2 Pin Mode", 0x19),
2356 PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
2357 PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
2358 PIN_SRC_TEST("In-1 Pin Source", 0x18),
2359 PIN_SRC_TEST("In-2 Pin Source", 0x19),
2360 PIN_SRC_TEST("In-3 Pin Source", 0x1a),
2361 PIN_SRC_TEST("In-4 Pin Source", 0x1b),
2362 HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
2363 HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
2364 HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
2365 HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
2366 HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
2367 HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
2368 HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
2369 HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
2370 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
2371 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
2373 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2374 .name = "Channel Mode",
2375 .info = alc_ch_mode_info,
2376 .get = alc_ch_mode_get,
2377 .put = alc_ch_mode_put,
2382 static struct hda_verb alc880_test_init_verbs[] = {
2383 /* Unmute inputs of 0x0c - 0x0f */
2384 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2385 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2386 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2387 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2388 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2389 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2390 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2391 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2392 /* Vol output for 0x0c-0x0f */
2393 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2394 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2395 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2396 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2397 /* Set output pins 0x14-0x17 */
2398 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2399 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2400 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2401 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2402 /* Unmute output pins 0x14-0x17 */
2403 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2404 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2405 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2406 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2407 /* Set input pins 0x18-0x1c */
2408 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2409 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2410 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2411 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2412 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2413 /* Mute input pins 0x18-0x1b */
2414 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2415 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2416 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2417 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2419 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2420 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
2421 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2422 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
2423 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2424 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
2425 /* Analog input/passthru */
2426 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2427 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2428 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
2429 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
2430 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
2438 static const char *alc880_models[ALC880_MODEL_LAST] = {
2439 [ALC880_3ST] = "3stack",
2440 [ALC880_TCL_S700] = "tcl",
2441 [ALC880_3ST_DIG] = "3stack-digout",
2442 [ALC880_CLEVO] = "clevo",
2443 [ALC880_5ST] = "5stack",
2444 [ALC880_5ST_DIG] = "5stack-digout",
2445 [ALC880_W810] = "w810",
2446 [ALC880_Z71V] = "z71v",
2447 [ALC880_6ST] = "6stack",
2448 [ALC880_6ST_DIG] = "6stack-digout",
2449 [ALC880_ASUS] = "asus",
2450 [ALC880_ASUS_W1V] = "asus-w1v",
2451 [ALC880_ASUS_DIG] = "asus-dig",
2452 [ALC880_ASUS_DIG2] = "asus-dig2",
2453 [ALC880_UNIWILL_DIG] = "uniwill",
2454 [ALC880_UNIWILL_P53] = "uniwill-p53",
2455 [ALC880_FUJITSU] = "fujitsu",
2456 [ALC880_F1734] = "F1734",
2458 [ALC880_LG_LW] = "lg-lw",
2459 #ifdef CONFIG_SND_DEBUG
2460 [ALC880_TEST] = "test",
2462 [ALC880_AUTO] = "auto",
2465 static struct snd_pci_quirk alc880_cfg_tbl[] = {
2466 /* Broken BIOS configuration */
2467 SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_6ST_DIG),
2468 SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_6ST_DIG),
2470 SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_5ST_DIG),
2471 SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_6ST),
2472 SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_W810),
2473 SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_3ST_DIG),
2474 SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_6ST_DIG),
2475 SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_6ST_DIG),
2476 SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_6ST_DIG),
2477 SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_3ST_DIG),
2478 SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_3ST),
2480 SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_6ST_DIG),
2481 SND_PCI_QUIRK(0x103c, 0x2a09, "HP", ALC880_5ST),
2483 SND_PCI_QUIRK(0x1043, 0x10b3, "ASUS W1V", ALC880_ASUS_W1V),
2484 SND_PCI_QUIRK(0x1043, 0x10c2, "ASUS W6A", ALC880_ASUS_DIG),
2485 SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS Wxx", ALC880_ASUS_DIG),
2486 SND_PCI_QUIRK(0x1043, 0x1113, "ASUS", ALC880_ASUS_DIG),
2487 SND_PCI_QUIRK(0x1043, 0x1123, "ASUS", ALC880_ASUS_DIG),
2488 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS", ALC880_ASUS_DIG),
2489 SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_Z71V),
2490 /* SND_PCI_QUIRK(0x1043, 0x1964, "ASUS", ALC880_ASUS_DIG), */
2491 SND_PCI_QUIRK(0x1043, 0x1973, "ASUS", ALC880_ASUS_DIG),
2492 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS", ALC880_ASUS_DIG),
2493 SND_PCI_QUIRK(0x1043, 0x814e, "ASUS", ALC880_ASUS),
2494 SND_PCI_QUIRK(0x1043, 0x8181, "ASUS P4GPL", ALC880_ASUS_DIG),
2495 SND_PCI_QUIRK(0x1043, 0x8196, "ASUS P5GD1", ALC880_6ST),
2496 SND_PCI_QUIRK(0x1043, 0x81b4, "ASUS", ALC880_6ST),
2497 SND_PCI_QUIRK(0x1043, 0, "ASUS", ALC880_ASUS),
2499 SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_3ST),
2500 SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_3ST),
2501 SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_5ST),
2502 SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_5ST),
2503 SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_5ST),
2504 SND_PCI_QUIRK(0x1558, 0x0520, "Clevo m520G", ALC880_CLEVO),
2505 SND_PCI_QUIRK(0x1558, 0x0660, "Clevo m655n", ALC880_CLEVO),
2506 SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_5ST_DIG),
2507 SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_W810),
2508 SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_5ST_DIG),
2509 SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_TCL_S700),
2510 SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_5ST_DIG),
2511 SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_6ST_DIG),
2512 SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_6ST_DIG),
2513 SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_6ST_DIG),
2514 SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_6ST_DIG),
2515 SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_6ST_DIG),
2516 SND_PCI_QUIRK(0x1558, 0x5401, "ASUS", ALC880_ASUS_DIG2),
2518 SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_UNIWILL_DIG),
2519 SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_UNIWILL),
2520 SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_UNIWILL_P53),
2521 SND_PCI_QUIRK(0x1584, 0x9054, "Uniwlll", ALC880_F1734),
2523 SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_5ST_DIG),
2524 SND_PCI_QUIRK(0x1734, 0x10ac, "FSC", ALC880_UNIWILL),
2525 SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_F1734),
2526 SND_PCI_QUIRK(0x1734, 0x10b0, "Fujitsu", ALC880_FUJITSU),
2528 SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_LG),
2529 SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_LG),
2530 SND_PCI_QUIRK(0x1854, 0x0018, "LG LW20", ALC880_LG_LW),
2531 SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_LG_LW),
2533 SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_3ST_DIG),
2534 SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_3ST_DIG),
2535 SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_3ST_DIG),
2536 SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_5ST_DIG),
2537 SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_5ST_DIG),
2538 SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_5ST_DIG),
2539 SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_5ST_DIG),
2540 SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_5ST_DIG),
2541 SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_5ST_DIG),
2542 SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_5ST_DIG),
2543 SND_PCI_QUIRK(0x8086, 0, "Intel mobo", ALC880_3ST),
2549 * ALC880 codec presets
2551 static struct alc_config_preset alc880_presets[] = {
2553 .mixers = { alc880_three_stack_mixer },
2554 .init_verbs = { alc880_volume_init_verbs, alc880_pin_3stack_init_verbs },
2555 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2556 .dac_nids = alc880_dac_nids,
2557 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
2558 .channel_mode = alc880_threestack_modes,
2560 .input_mux = &alc880_capture_source,
2562 [ALC880_3ST_DIG] = {
2563 .mixers = { alc880_three_stack_mixer },
2564 .init_verbs = { alc880_volume_init_verbs, alc880_pin_3stack_init_verbs },
2565 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2566 .dac_nids = alc880_dac_nids,
2567 .dig_out_nid = ALC880_DIGOUT_NID,
2568 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
2569 .channel_mode = alc880_threestack_modes,
2571 .input_mux = &alc880_capture_source,
2573 [ALC880_TCL_S700] = {
2574 .mixers = { alc880_tcl_s700_mixer },
2575 .init_verbs = { alc880_volume_init_verbs,
2576 alc880_pin_tcl_S700_init_verbs,
2577 alc880_gpio2_init_verbs },
2578 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2579 .dac_nids = alc880_dac_nids,
2581 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
2582 .channel_mode = alc880_2_jack_modes,
2583 .input_mux = &alc880_capture_source,
2586 .mixers = { alc880_three_stack_mixer, alc880_five_stack_mixer},
2587 .init_verbs = { alc880_volume_init_verbs, alc880_pin_5stack_init_verbs },
2588 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2589 .dac_nids = alc880_dac_nids,
2590 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
2591 .channel_mode = alc880_fivestack_modes,
2592 .input_mux = &alc880_capture_source,
2594 [ALC880_5ST_DIG] = {
2595 .mixers = { alc880_three_stack_mixer, alc880_five_stack_mixer },
2596 .init_verbs = { alc880_volume_init_verbs, alc880_pin_5stack_init_verbs },
2597 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2598 .dac_nids = alc880_dac_nids,
2599 .dig_out_nid = ALC880_DIGOUT_NID,
2600 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
2601 .channel_mode = alc880_fivestack_modes,
2602 .input_mux = &alc880_capture_source,
2605 .mixers = { alc880_six_stack_mixer },
2606 .init_verbs = { alc880_volume_init_verbs, alc880_pin_6stack_init_verbs },
2607 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
2608 .dac_nids = alc880_6st_dac_nids,
2609 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
2610 .channel_mode = alc880_sixstack_modes,
2611 .input_mux = &alc880_6stack_capture_source,
2613 [ALC880_6ST_DIG] = {
2614 .mixers = { alc880_six_stack_mixer },
2615 .init_verbs = { alc880_volume_init_verbs, alc880_pin_6stack_init_verbs },
2616 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
2617 .dac_nids = alc880_6st_dac_nids,
2618 .dig_out_nid = ALC880_DIGOUT_NID,
2619 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
2620 .channel_mode = alc880_sixstack_modes,
2621 .input_mux = &alc880_6stack_capture_source,
2624 .mixers = { alc880_w810_base_mixer },
2625 .init_verbs = { alc880_volume_init_verbs, alc880_pin_w810_init_verbs,
2626 alc880_gpio2_init_verbs },
2627 .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
2628 .dac_nids = alc880_w810_dac_nids,
2629 .dig_out_nid = ALC880_DIGOUT_NID,
2630 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
2631 .channel_mode = alc880_w810_modes,
2632 .input_mux = &alc880_capture_source,
2635 .mixers = { alc880_z71v_mixer },
2636 .init_verbs = { alc880_volume_init_verbs, alc880_pin_z71v_init_verbs },
2637 .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
2638 .dac_nids = alc880_z71v_dac_nids,
2639 .dig_out_nid = ALC880_DIGOUT_NID,
2641 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
2642 .channel_mode = alc880_2_jack_modes,
2643 .input_mux = &alc880_capture_source,
2646 .mixers = { alc880_f1734_mixer },
2647 .init_verbs = { alc880_volume_init_verbs, alc880_pin_f1734_init_verbs },
2648 .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
2649 .dac_nids = alc880_f1734_dac_nids,
2651 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
2652 .channel_mode = alc880_2_jack_modes,
2653 .input_mux = &alc880_capture_source,
2656 .mixers = { alc880_asus_mixer },
2657 .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs,
2658 alc880_gpio1_init_verbs },
2659 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2660 .dac_nids = alc880_asus_dac_nids,
2661 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2662 .channel_mode = alc880_asus_modes,
2664 .input_mux = &alc880_capture_source,
2666 [ALC880_ASUS_DIG] = {
2667 .mixers = { alc880_asus_mixer },
2668 .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs,
2669 alc880_gpio1_init_verbs },
2670 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2671 .dac_nids = alc880_asus_dac_nids,
2672 .dig_out_nid = ALC880_DIGOUT_NID,
2673 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2674 .channel_mode = alc880_asus_modes,
2676 .input_mux = &alc880_capture_source,
2678 [ALC880_ASUS_DIG2] = {
2679 .mixers = { alc880_asus_mixer },
2680 .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs,
2681 alc880_gpio2_init_verbs }, /* use GPIO2 */
2682 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2683 .dac_nids = alc880_asus_dac_nids,
2684 .dig_out_nid = ALC880_DIGOUT_NID,
2685 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2686 .channel_mode = alc880_asus_modes,
2688 .input_mux = &alc880_capture_source,
2690 [ALC880_ASUS_W1V] = {
2691 .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
2692 .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs,
2693 alc880_gpio1_init_verbs },
2694 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2695 .dac_nids = alc880_asus_dac_nids,
2696 .dig_out_nid = ALC880_DIGOUT_NID,
2697 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2698 .channel_mode = alc880_asus_modes,
2700 .input_mux = &alc880_capture_source,
2702 [ALC880_UNIWILL_DIG] = {
2703 .mixers = { alc880_asus_mixer, alc880_pcbeep_mixer },
2704 .init_verbs = { alc880_volume_init_verbs,
2705 alc880_pin_asus_init_verbs },
2706 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2707 .dac_nids = alc880_asus_dac_nids,
2708 .dig_out_nid = ALC880_DIGOUT_NID,
2709 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2710 .channel_mode = alc880_asus_modes,
2712 .input_mux = &alc880_capture_source,
2714 [ALC880_UNIWILL] = {
2715 .mixers = { alc880_uniwill_mixer },
2716 .init_verbs = { alc880_volume_init_verbs,
2717 alc880_uniwill_init_verbs },
2718 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2719 .dac_nids = alc880_asus_dac_nids,
2720 .dig_out_nid = ALC880_DIGOUT_NID,
2721 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
2722 .channel_mode = alc880_threestack_modes,
2724 .input_mux = &alc880_capture_source,
2725 .unsol_event = alc880_uniwill_unsol_event,
2726 .init_hook = alc880_uniwill_automute,
2728 [ALC880_UNIWILL_P53] = {
2729 .mixers = { alc880_uniwill_p53_mixer },
2730 .init_verbs = { alc880_volume_init_verbs,
2731 alc880_uniwill_p53_init_verbs },
2732 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2733 .dac_nids = alc880_asus_dac_nids,
2734 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
2735 .channel_mode = alc880_threestack_modes,
2736 .input_mux = &alc880_capture_source,
2737 .unsol_event = alc880_uniwill_p53_unsol_event,
2738 .init_hook = alc880_uniwill_p53_hp_automute,
2740 [ALC880_FUJITSU] = {
2741 .mixers = { alc880_fujitsu_mixer,
2742 alc880_pcbeep_mixer, },
2743 .init_verbs = { alc880_volume_init_verbs,
2744 alc880_uniwill_p53_init_verbs,
2745 alc880_beep_init_verbs },
2746 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2747 .dac_nids = alc880_dac_nids,
2748 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
2749 .channel_mode = alc880_2_jack_modes,
2750 .input_mux = &alc880_capture_source,
2751 .unsol_event = alc880_uniwill_p53_unsol_event,
2752 .init_hook = alc880_uniwill_p53_hp_automute,
2755 .mixers = { alc880_three_stack_mixer },
2756 .init_verbs = { alc880_volume_init_verbs,
2757 alc880_pin_clevo_init_verbs },
2758 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2759 .dac_nids = alc880_dac_nids,
2761 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
2762 .channel_mode = alc880_threestack_modes,
2764 .input_mux = &alc880_capture_source,
2767 .mixers = { alc880_lg_mixer },
2768 .init_verbs = { alc880_volume_init_verbs,
2769 alc880_lg_init_verbs },
2770 .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids),
2771 .dac_nids = alc880_lg_dac_nids,
2772 .dig_out_nid = ALC880_DIGOUT_NID,
2773 .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes),
2774 .channel_mode = alc880_lg_ch_modes,
2776 .input_mux = &alc880_lg_capture_source,
2777 .unsol_event = alc880_lg_unsol_event,
2778 .init_hook = alc880_lg_automute,
2781 .mixers = { alc880_lg_lw_mixer },
2782 .init_verbs = { alc880_volume_init_verbs,
2783 alc880_lg_lw_init_verbs },
2785 .dac_nids = alc880_dac_nids,
2786 .dig_out_nid = ALC880_DIGOUT_NID,
2787 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
2788 .channel_mode = alc880_2_jack_modes,
2789 .input_mux = &alc880_lg_lw_capture_source,
2790 .unsol_event = alc880_lg_lw_unsol_event,
2791 .init_hook = alc880_lg_lw_automute,
2793 #ifdef CONFIG_SND_DEBUG
2795 .mixers = { alc880_test_mixer },
2796 .init_verbs = { alc880_test_init_verbs },
2797 .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
2798 .dac_nids = alc880_test_dac_nids,
2799 .dig_out_nid = ALC880_DIGOUT_NID,
2800 .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
2801 .channel_mode = alc880_test_modes,
2802 .input_mux = &alc880_test_capture_source,
2808 * Automatic parse of I/O pins from the BIOS configuration
2811 #define NUM_CONTROL_ALLOC 32
2812 #define NUM_VERB_ALLOC 32
2816 ALC_CTL_WIDGET_MUTE,
2819 static struct snd_kcontrol_new alc880_control_templates[] = {
2820 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
2821 HDA_CODEC_MUTE(NULL, 0, 0, 0),
2822 HDA_BIND_MUTE(NULL, 0, 0, 0),
2825 /* add dynamic controls */
2826 static int add_control(struct alc_spec *spec, int type, const char *name, unsigned long val)
2828 struct snd_kcontrol_new *knew;
2830 if (spec->num_kctl_used >= spec->num_kctl_alloc) {
2831 int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC;
2833 knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL); /* array + terminator */
2836 if (spec->kctl_alloc) {
2837 memcpy(knew, spec->kctl_alloc, sizeof(*knew) * spec->num_kctl_alloc);
2838 kfree(spec->kctl_alloc);
2840 spec->kctl_alloc = knew;
2841 spec->num_kctl_alloc = num;
2844 knew = &spec->kctl_alloc[spec->num_kctl_used];
2845 *knew = alc880_control_templates[type];
2846 knew->name = kstrdup(name, GFP_KERNEL);
2849 knew->private_value = val;
2850 spec->num_kctl_used++;
2854 #define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
2855 #define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
2856 #define alc880_is_multi_pin(nid) ((nid) >= 0x18)
2857 #define alc880_multi_pin_idx(nid) ((nid) - 0x18)
2858 #define alc880_is_input_pin(nid) ((nid) >= 0x18)
2859 #define alc880_input_pin_idx(nid) ((nid) - 0x18)
2860 #define alc880_idx_to_dac(nid) ((nid) + 0x02)
2861 #define alc880_dac_to_idx(nid) ((nid) - 0x02)
2862 #define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
2863 #define alc880_idx_to_selector(nid) ((nid) + 0x10)
2864 #define ALC880_PIN_CD_NID 0x1c
2866 /* fill in the dac_nids table from the parsed pin configuration */
2867 static int alc880_auto_fill_dac_nids(struct alc_spec *spec, const struct auto_pin_cfg *cfg)
2873 memset(assigned, 0, sizeof(assigned));
2874 spec->multiout.dac_nids = spec->private_dac_nids;
2876 /* check the pins hardwired to audio widget */
2877 for (i = 0; i < cfg->line_outs; i++) {
2878 nid = cfg->line_out_pins[i];
2879 if (alc880_is_fixed_pin(nid)) {
2880 int idx = alc880_fixed_pin_idx(nid);
2881 spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
2885 /* left pins can be connect to any audio widget */
2886 for (i = 0; i < cfg->line_outs; i++) {
2887 nid = cfg->line_out_pins[i];
2888 if (alc880_is_fixed_pin(nid))
2890 /* search for an empty channel */
2891 for (j = 0; j < cfg->line_outs; j++) {
2892 if (! assigned[j]) {
2893 spec->multiout.dac_nids[i] = alc880_idx_to_dac(j);
2899 spec->multiout.num_dacs = cfg->line_outs;
2903 /* add playback controls from the parsed DAC table */
2904 static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
2905 const struct auto_pin_cfg *cfg)
2908 static const char *chname[4] = { "Front", "Surround", NULL /*CLFE*/, "Side" };
2912 for (i = 0; i < cfg->line_outs; i++) {
2913 if (! spec->multiout.dac_nids[i])
2915 nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
2918 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Center Playback Volume",
2919 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT))) < 0)
2921 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "LFE Playback Volume",
2922 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0)
2924 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "Center Playback Switch",
2925 HDA_COMPOSE_AMP_VAL(nid, 1, 2, HDA_INPUT))) < 0)
2927 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "LFE Playback Switch",
2928 HDA_COMPOSE_AMP_VAL(nid, 2, 2, HDA_INPUT))) < 0)
2931 sprintf(name, "%s Playback Volume", chname[i]);
2932 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
2933 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
2935 sprintf(name, "%s Playback Switch", chname[i]);
2936 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, name,
2937 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT))) < 0)
2944 /* add playback controls for speaker and HP outputs */
2945 static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
2955 if (alc880_is_fixed_pin(pin)) {
2956 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
2957 /* specify the DAC as the extra output */
2958 if (! spec->multiout.hp_nid)
2959 spec->multiout.hp_nid = nid;
2961 spec->multiout.extra_out_nid[0] = nid;
2962 /* control HP volume/switch on the output mixer amp */
2963 nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
2964 sprintf(name, "%s Playback Volume", pfx);
2965 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
2966 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
2968 sprintf(name, "%s Playback Switch", pfx);
2969 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, name,
2970 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT))) < 0)
2972 } else if (alc880_is_multi_pin(pin)) {
2973 /* set manual connection */
2974 /* we have only a switch on HP-out PIN */
2975 sprintf(name, "%s Playback Switch", pfx);
2976 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
2977 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT))) < 0)
2983 /* create input playback/capture controls for the given pin */
2984 static int new_analog_input(struct alc_spec *spec, hda_nid_t pin, const char *ctlname,
2985 int idx, hda_nid_t mix_nid)
2990 sprintf(name, "%s Playback Volume", ctlname);
2991 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
2992 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT))) < 0)
2994 sprintf(name, "%s Playback Switch", ctlname);
2995 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
2996 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT))) < 0)
3001 /* create playback/capture controls for input pins */
3002 static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec,
3003 const struct auto_pin_cfg *cfg)
3005 struct hda_input_mux *imux = &spec->private_imux;
3008 for (i = 0; i < AUTO_PIN_LAST; i++) {
3009 if (alc880_is_input_pin(cfg->input_pins[i])) {
3010 idx = alc880_input_pin_idx(cfg->input_pins[i]);
3011 err = new_analog_input(spec, cfg->input_pins[i],
3012 auto_pin_cfg_labels[i],
3016 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
3017 imux->items[imux->num_items].index = alc880_input_pin_idx(cfg->input_pins[i]);
3024 static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
3025 hda_nid_t nid, int pin_type,
3029 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
3030 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
3031 /* need the manual connection? */
3032 if (alc880_is_multi_pin(nid)) {
3033 struct alc_spec *spec = codec->spec;
3034 int idx = alc880_multi_pin_idx(nid);
3035 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
3036 AC_VERB_SET_CONNECT_SEL,
3037 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
3041 static void alc880_auto_init_multi_out(struct hda_codec *codec)
3043 struct alc_spec *spec = codec->spec;
3046 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
3047 for (i = 0; i < spec->autocfg.line_outs; i++) {
3048 hda_nid_t nid = spec->autocfg.line_out_pins[i];
3049 alc880_auto_set_output_and_unmute(codec, nid, PIN_OUT, i);
3053 static void alc880_auto_init_extra_out(struct hda_codec *codec)
3055 struct alc_spec *spec = codec->spec;
3058 pin = spec->autocfg.speaker_pins[0];
3059 if (pin) /* connect to front */
3060 alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
3061 pin = spec->autocfg.hp_pins[0];
3062 if (pin) /* connect to front */
3063 alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
3066 static void alc880_auto_init_analog_input(struct hda_codec *codec)
3068 struct alc_spec *spec = codec->spec;
3071 for (i = 0; i < AUTO_PIN_LAST; i++) {
3072 hda_nid_t nid = spec->autocfg.input_pins[i];
3073 if (alc880_is_input_pin(nid)) {
3074 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
3075 i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN);
3076 if (nid != ALC880_PIN_CD_NID)
3077 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
3083 /* parse the BIOS configuration and set up the alc_spec */
3084 /* return 1 if successful, 0 if the proper config is not found, or a negative error code */
3085 static int alc880_parse_auto_config(struct hda_codec *codec)
3087 struct alc_spec *spec = codec->spec;
3089 static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
3091 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
3092 alc880_ignore)) < 0)
3094 if (! spec->autocfg.line_outs)
3095 return 0; /* can't find valid BIOS pin config */
3097 if ((err = alc880_auto_fill_dac_nids(spec, &spec->autocfg)) < 0 ||
3098 (err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 ||
3099 (err = alc880_auto_create_extra_out(spec,
3100 spec->autocfg.speaker_pins[0],
3102 (err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
3103 "Headphone")) < 0 ||
3104 (err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0)
3107 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
3109 if (spec->autocfg.dig_out_pin)
3110 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
3111 if (spec->autocfg.dig_in_pin)
3112 spec->dig_in_nid = ALC880_DIGIN_NID;
3114 if (spec->kctl_alloc)
3115 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
3117 spec->init_verbs[spec->num_init_verbs++] = alc880_volume_init_verbs;
3119 spec->num_mux_defs = 1;
3120 spec->input_mux = &spec->private_imux;
3125 /* additional initialization for auto-configuration model */
3126 static void alc880_auto_init(struct hda_codec *codec)
3128 alc880_auto_init_multi_out(codec);
3129 alc880_auto_init_extra_out(codec);
3130 alc880_auto_init_analog_input(codec);
3134 * OK, here we have finally the patch for ALC880
3137 static int patch_alc880(struct hda_codec *codec)
3139 struct alc_spec *spec;
3143 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
3149 board_config = snd_hda_check_board_config(codec, ALC880_MODEL_LAST,
3152 if (board_config < 0) {
3153 printk(KERN_INFO "hda_codec: Unknown model for ALC880, "
3154 "trying auto-probe from BIOS...\n");
3155 board_config = ALC880_AUTO;
3158 if (board_config == ALC880_AUTO) {
3159 /* automatic parse from the BIOS config */
3160 err = alc880_parse_auto_config(codec);
3166 "hda_codec: Cannot set up configuration "
3167 "from BIOS. Using 3-stack mode...\n");
3168 board_config = ALC880_3ST;
3172 if (board_config != ALC880_AUTO)
3173 setup_preset(spec, &alc880_presets[board_config]);
3175 spec->stream_name_analog = "ALC880 Analog";
3176 spec->stream_analog_playback = &alc880_pcm_analog_playback;
3177 spec->stream_analog_capture = &alc880_pcm_analog_capture;
3179 spec->stream_name_digital = "ALC880 Digital";
3180 spec->stream_digital_playback = &alc880_pcm_digital_playback;
3181 spec->stream_digital_capture = &alc880_pcm_digital_capture;
3183 if (! spec->adc_nids && spec->input_mux) {
3184 /* check whether NID 0x07 is valid */
3185 unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
3186 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
3187 if (wcap != AC_WID_AUD_IN) {
3188 spec->adc_nids = alc880_adc_nids_alt;
3189 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
3190 spec->mixers[spec->num_mixers] = alc880_capture_alt_mixer;
3193 spec->adc_nids = alc880_adc_nids;
3194 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
3195 spec->mixers[spec->num_mixers] = alc880_capture_mixer;
3200 codec->patch_ops = alc_patch_ops;
3201 if (board_config == ALC880_AUTO)
3202 spec->init_hook = alc880_auto_init;
3212 static hda_nid_t alc260_dac_nids[1] = {
3217 static hda_nid_t alc260_adc_nids[1] = {
3222 static hda_nid_t alc260_adc_nids_alt[1] = {
3227 static hda_nid_t alc260_hp_adc_nids[2] = {
3232 /* NIDs used when simultaneous access to both ADCs makes sense. Note that
3233 * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
3235 static hda_nid_t alc260_dual_adc_nids[2] = {
3240 #define ALC260_DIGOUT_NID 0x03
3241 #define ALC260_DIGIN_NID 0x06
3243 static struct hda_input_mux alc260_capture_source = {
3247 { "Front Mic", 0x1 },
3253 /* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
3254 * headphone jack and the internal CD lines since these are the only pins at
3255 * which audio can appear. For flexibility, also allow the option of
3256 * recording the mixer output on the second ADC (ADC0 doesn't have a
3257 * connection to the mixer output).
3259 static struct hda_input_mux alc260_fujitsu_capture_sources[2] = {
3263 { "Mic/Line", 0x0 },
3265 { "Headphone", 0x2 },
3271 { "Mic/Line", 0x0 },
3273 { "Headphone", 0x2 },
3280 /* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to
3281 * the Fujitsu S702x, but jacks are marked differently.
3283 static struct hda_input_mux alc260_acer_capture_sources[2] = {
3290 { "Headphone", 0x5 },
3299 { "Headphone", 0x6 },
3305 * This is just place-holder, so there's something for alc_build_pcms to look
3306 * at when it calculates the maximum number of channels. ALC260 has no mixer
3307 * element which allows changing the channel mode, so the verb list is
3310 static struct hda_channel_mode alc260_modes[1] = {
3315 /* Mixer combinations
3317 * basic: base_output + input + pc_beep + capture
3318 * HP: base_output + input + capture_alt
3319 * HP_3013: hp_3013 + input + capture
3320 * fujitsu: fujitsu + capture
3321 * acer: acer + capture
3324 static struct snd_kcontrol_new alc260_base_output_mixer[] = {
3325 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3326 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
3327 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
3328 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
3329 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
3330 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
3334 static struct snd_kcontrol_new alc260_input_mixer[] = {
3335 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3336 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
3337 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
3338 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
3339 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
3340 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
3341 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
3342 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
3346 static struct snd_kcontrol_new alc260_pc_beep_mixer[] = {
3347 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x07, 0x05, HDA_INPUT),
3348 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x07, 0x05, HDA_INPUT),
3352 static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
3353 HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
3354 HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
3355 HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
3356 HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
3357 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3358 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
3359 HDA_CODEC_VOLUME_MONO("iSpeaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
3360 HDA_CODEC_MUTE_MONO("iSpeaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
3364 /* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12,
3365 * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10.
3367 static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
3368 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3369 HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
3370 ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
3371 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3372 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
3373 HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
3374 HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
3375 ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
3376 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
3377 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
3378 HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
3379 HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x09, 2, HDA_INPUT),
3383 /* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current
3384 * versions of the ALC260 don't act on requests to enable mic bias from NID
3385 * 0x0f (used to drive the headphone jack in these laptops). The ALC260
3386 * datasheet doesn't mention this restriction. At this stage it's not clear
3387 * whether this behaviour is intentional or is a hardware bug in chip
3388 * revisions available in early 2006. Therefore for now allow the
3389 * "Headphone Jack Mode" control to span all choices, but if it turns out
3390 * that the lack of mic bias for this NID is intentional we could change the
3391 * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
3393 * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006
3394 * don't appear to make the mic bias available from the "line" jack, even
3395 * though the NID used for this jack (0x14) can supply it. The theory is
3396 * that perhaps Acer have included blocking capacitors between the ALC260
3397 * and the output jack. If this turns out to be the case for all such
3398 * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
3399 * to ALC_PIN_DIR_INOUT_NOMICBIAS.
3401 * The C20x Tablet series have a mono internal speaker which is controlled
3402 * via the chip's Mono sum widget and pin complex, so include the necessary
3403 * controls for such models. On models without a "mono speaker" the control
3404 * won't do anything.
3406 static struct snd_kcontrol_new alc260_acer_mixer[] = {
3407 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3408 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
3409 ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
3410 HDA_CODEC_VOLUME_MONO("Mono Speaker Playback Volume", 0x0a, 1, 0x0,
3412 HDA_BIND_MUTE_MONO("Mono Speaker Playback Switch", 0x0a, 1, 2,
3414 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3415 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
3416 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
3417 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
3418 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
3419 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
3420 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
3421 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
3422 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
3423 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
3427 /* Packard bell V7900 ALC260 pin usage: HP = 0x0f, Mic jack = 0x12,
3428 * Line In jack = 0x14, CD audio = 0x16, pc beep = 0x17.
3430 static struct snd_kcontrol_new alc260_will_mixer[] = {
3431 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3432 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
3433 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
3434 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
3435 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
3436 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
3437 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
3438 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
3439 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3440 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
3441 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
3442 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
3446 /* Replacer 672V ALC260 pin usage: Mic jack = 0x12,
3447 * Line In jack = 0x14, ATAPI Mic = 0x13, speaker = 0x0f.
3449 static struct snd_kcontrol_new alc260_replacer_672v_mixer[] = {
3450 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3451 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
3452 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
3453 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
3454 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
3455 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x07, 0x1, HDA_INPUT),
3456 HDA_CODEC_MUTE("ATATI Mic Playback Switch", 0x07, 0x1, HDA_INPUT),
3457 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
3458 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
3459 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
3463 /* capture mixer elements */
3464 static struct snd_kcontrol_new alc260_capture_mixer[] = {
3465 HDA_CODEC_VOLUME("Capture Volume", 0x04, 0x0, HDA_INPUT),
3466 HDA_CODEC_MUTE("Capture Switch", 0x04, 0x0, HDA_INPUT),
3467 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x05, 0x0, HDA_INPUT),
3468 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x05, 0x0, HDA_INPUT),
3470 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3471 /* The multiple "Capture Source" controls confuse alsamixer
3472 * So call somewhat different..
3473 * FIXME: the controls appear in the "playback" view!
3475 /* .name = "Capture Source", */
3476 .name = "Input Source",
3478 .info = alc_mux_enum_info,
3479 .get = alc_mux_enum_get,
3480 .put = alc_mux_enum_put,
3485 static struct snd_kcontrol_new alc260_capture_alt_mixer[] = {
3486 HDA_CODEC_VOLUME("Capture Volume", 0x05, 0x0, HDA_INPUT),
3487 HDA_CODEC_MUTE("Capture Switch", 0x05, 0x0, HDA_INPUT),
3489 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3490 /* The multiple "Capture Source" controls confuse alsamixer
3491 * So call somewhat different..
3492 * FIXME: the controls appear in the "playback" view!
3494 /* .name = "Capture Source", */
3495 .name = "Input Source",
3497 .info = alc_mux_enum_info,
3498 .get = alc_mux_enum_get,
3499 .put = alc_mux_enum_put,
3505 * initialization verbs
3507 static struct hda_verb alc260_init_verbs[] = {
3508 /* Line In pin widget for input */
3509 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3510 /* CD pin widget for input */
3511 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3512 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3513 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3514 /* Mic2 (front panel) pin widget for input and vref at 80% */
3515 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3516 /* LINE-2 is used for line-out in rear */
3517 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3518 /* select line-out */
3519 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
3521 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3523 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3525 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3526 /* mute capture amp left and right */
3527 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3528 /* set connection select to line in (default select for this ADC) */
3529 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
3530 /* mute capture amp left and right */
3531 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3532 /* set connection select to line in (default select for this ADC) */
3533 {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
3534 /* set vol=0 Line-Out mixer amp left and right */
3535 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3536 /* unmute pin widget amp left and right (no gain on this amp) */
3537 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3538 /* set vol=0 HP mixer amp left and right */
3539 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3540 /* unmute pin widget amp left and right (no gain on this amp) */
3541 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3542 /* set vol=0 Mono mixer amp left and right */
3543 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3544 /* unmute pin widget amp left and right (no gain on this amp) */
3545 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3546 /* unmute LINE-2 out pin */
3547 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3548 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & Line In 2 = 0x03 */
3550 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
3552 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
3554 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3555 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
3556 /* mute Front out path */
3557 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3558 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3559 /* mute Headphone out path */
3560 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3561 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3562 /* mute Mono out path */
3563 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3564 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3568 #if 0 /* should be identical with alc260_init_verbs? */
3569 static struct hda_verb alc260_hp_init_verbs[] = {
3570 /* Headphone and output */
3571 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
3573 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
3574 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3575 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
3576 /* Mic2 (front panel) pin widget for input and vref at 80% */
3577 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
3578 /* Line In pin widget for input */
3579 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
3580 /* Line-2 pin widget for output */
3581 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
3582 /* CD pin widget for input */
3583 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
3584 /* unmute amp left and right */
3585 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
3586 /* set connection select to line in (default select for this ADC) */
3587 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
3588 /* unmute Line-Out mixer amp left and right (volume = 0) */
3589 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
3590 /* mute pin widget amp left and right (no gain on this amp) */
3591 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
3592 /* unmute HP mixer amp left and right (volume = 0) */
3593 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
3594 /* mute pin widget amp left and right (no gain on this amp) */
3595 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
3596 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & Line In 2 = 0x03 */
3598 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
3599 /* unmute Line In */
3600 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
3602 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3603 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
3604 /* Unmute Front out path */
3605 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3606 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3607 /* Unmute Headphone out path */
3608 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3609 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3610 /* Unmute Mono out path */
3611 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3612 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3617 static struct hda_verb alc260_hp_3013_init_verbs[] = {
3618 /* Line out and output */
3619 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
3621 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
3622 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3623 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
3624 /* Mic2 (front panel) pin widget for input and vref at 80% */
3625 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
3626 /* Line In pin widget for input */
3627 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
3628 /* Headphone pin widget for output */
3629 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
3630 /* CD pin widget for input */
3631 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
3632 /* unmute amp left and right */
3633 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
3634 /* set connection select to line in (default select for this ADC) */
3635 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
3636 /* unmute Line-Out mixer amp left and right (volume = 0) */
3637 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
3638 /* mute pin widget amp left and right (no gain on this amp) */
3639 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
3640 /* unmute HP mixer amp left and right (volume = 0) */
3641 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
3642 /* mute pin widget amp left and right (no gain on this amp) */
3643 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
3644 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & Line In 2 = 0x03 */
3646 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
3647 /* unmute Line In */
3648 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
3650 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3651 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
3652 /* Unmute Front out path */
3653 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3654 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3655 /* Unmute Headphone out path */
3656 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3657 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3658 /* Unmute Mono out path */
3659 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3660 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3664 /* Initialisation sequence for ALC260 as configured in Fujitsu S702x
3665 * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD
3666 * audio = 0x16, internal speaker = 0x10.
3668 static struct hda_verb alc260_fujitsu_init_verbs[] = {
3669 /* Disable all GPIOs */
3670 {0x01, AC_VERB_SET_GPIO_MASK, 0},
3671 /* Internal speaker is connected to headphone pin */
3672 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3673 /* Headphone/Line-out jack connects to Line1 pin; make it an output */
3674 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3675 /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
3676 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3677 /* Ensure all other unused pins are disabled and muted. */
3678 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3679 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3680 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3681 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3682 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3683 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3684 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3685 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3687 /* Disable digital (SPDIF) pins */
3688 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
3689 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
3691 /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
3692 * when acting as an output.
3694 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
3696 /* Start with output sum widgets muted and their output gains at min */
3697 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3698 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3699 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3700 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3701 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3702 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3703 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3704 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3705 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3707 /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
3708 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3709 /* Unmute Line1 pin widget output buffer since it starts as an output.
3710 * If the pin mode is changed by the user the pin mode control will
3711 * take care of enabling the pin's input/output buffers as needed.
3712 * Therefore there's no need to enable the input buffer at this
3715 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3716 /* Unmute input buffer of pin widget used for Line-in (no equiv
3719 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3721 /* Mute capture amp left and right */
3722 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3723 /* Set ADC connection select to match default mixer setting - line
3726 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
3728 /* Do the same for the second ADC: mute capture input amp and
3729 * set ADC connection to line in (on mic1 pin)
3731 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3732 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
3734 /* Mute all inputs to mixer widget (even unconnected ones) */
3735 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
3736 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
3737 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
3738 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
3739 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
3740 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
3741 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
3742 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
3747 /* Initialisation sequence for ALC260 as configured in Acer TravelMate and
3748 * similar laptops (adapted from Fujitsu init verbs).
3750 static struct hda_verb alc260_acer_init_verbs[] = {
3751 /* On TravelMate laptops, GPIO 0 enables the internal speaker and
3752 * the headphone jack. Turn this on and rely on the standard mute
3753 * methods whenever the user wants to turn these outputs off.
3755 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
3756 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
3757 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
3758 /* Internal speaker/Headphone jack is connected to Line-out pin */
3759 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3760 /* Internal microphone/Mic jack is connected to Mic1 pin */
3761 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
3762 /* Line In jack is connected to Line1 pin */
3763 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3764 /* Some Acers (eg: C20x Tablets) use Mono pin for internal speaker */
3765 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3766 /* Ensure all other unused pins are disabled and muted. */
3767 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3768 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3769 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3770 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3771 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3772 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3773 /* Disable digital (SPDIF) pins */
3774 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
3775 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
3777 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
3778 * bus when acting as outputs.
3780 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
3781 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
3783 /* Start with output sum widgets muted and their output gains at min */
3784 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3785 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3786 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3787 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3788 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3789 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3790 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3791 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3792 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3794 /* Unmute Line-out pin widget amp left and right (no equiv mixer ctrl) */
3795 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3796 /* Unmute mono pin widget amp output (no equiv mixer ctrl) */
3797 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3798 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
3799 * inputs. If the pin mode is changed by the user the pin mode control
3800 * will take care of enabling the pin's input/output buffers as needed.
3801 * Therefore there's no need to enable the input buffer at this
3804 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3805 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3807 /* Mute capture amp left and right */
3808 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3809 /* Set ADC connection select to match default mixer setting - mic
3812 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
3814 /* Do similar with the second ADC: mute capture input amp and
3815 * set ADC connection to mic to match ALSA's default state.
3817 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3818 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
3820 /* Mute all inputs to mixer widget (even unconnected ones) */
3821 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
3822 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
3823 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
3824 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
3825 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
3826 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
3827 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
3828 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
3833 static struct hda_verb alc260_will_verbs[] = {
3834 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3835 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x00},
3836 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
3837 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
3838 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
3839 {0x1a, AC_VERB_SET_PROC_COEF, 0x3040},
3843 static struct hda_verb alc260_replacer_672v_verbs[] = {
3844 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
3845 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
3846 {0x1a, AC_VERB_SET_PROC_COEF, 0x3050},
3848 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
3849 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
3850 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
3852 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
3856 /* toggle speaker-output according to the hp-jack state */
3857 static void alc260_replacer_672v_automute(struct hda_codec *codec)
3859 unsigned int present;
3861 /* speaker --> GPIO Data 0, hp or spdif --> GPIO data 1 */
3862 present = snd_hda_codec_read(codec, 0x0f, 0,
3863 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
3865 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 1);
3866 snd_hda_codec_write(codec, 0x0f, 0,
3867 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP);
3869 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 0);
3870 snd_hda_codec_write(codec, 0x0f, 0,
3871 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
3875 static void alc260_replacer_672v_unsol_event(struct hda_codec *codec,
3878 if ((res >> 26) == ALC880_HP_EVENT)
3879 alc260_replacer_672v_automute(codec);
3882 /* Test configuration for debugging, modelled after the ALC880 test
3885 #ifdef CONFIG_SND_DEBUG
3886 static hda_nid_t alc260_test_dac_nids[1] = {
3889 static hda_nid_t alc260_test_adc_nids[2] = {
3892 /* For testing the ALC260, each input MUX needs its own definition since
3893 * the signal assignments are different. This assumes that the first ADC
3896 static struct hda_input_mux alc260_test_capture_sources[2] = {
3900 { "MIC1 pin", 0x0 },
3901 { "MIC2 pin", 0x1 },
3902 { "LINE1 pin", 0x2 },
3903 { "LINE2 pin", 0x3 },
3905 { "LINE-OUT pin", 0x5 },
3906 { "HP-OUT pin", 0x6 },
3912 { "MIC1 pin", 0x0 },
3913 { "MIC2 pin", 0x1 },
3914 { "LINE1 pin", 0x2 },
3915 { "LINE2 pin", 0x3 },
3918 { "LINE-OUT pin", 0x6 },
3919 { "HP-OUT pin", 0x7 },
3923 static struct snd_kcontrol_new alc260_test_mixer[] = {
3924 /* Output driver widgets */
3925 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
3926 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
3927 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
3928 HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
3929 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3930 HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
3932 /* Modes for retasking pin widgets
3933 * Note: the ALC260 doesn't seem to act on requests to enable mic
3934 * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't
3935 * mention this restriction. At this stage it's not clear whether
3936 * this behaviour is intentional or is a hardware bug in chip
3937 * revisions available at least up until early 2006. Therefore for
3938 * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all
3939 * choices, but if it turns out that the lack of mic bias for these
3940 * NIDs is intentional we could change their modes from
3941 * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
3943 ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
3944 ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
3945 ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
3946 ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
3947 ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
3948 ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
3950 /* Loopback mixer controls */
3951 HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
3952 HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
3953 HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
3954 HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
3955 HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
3956 HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
3957 HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
3958 HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
3959 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3960 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
3961 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
3962 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
3963 HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
3964 HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
3965 HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
3966 HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
3968 /* Controls for GPIO pins, assuming they are configured as outputs */
3969 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
3970 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
3971 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
3972 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
3974 /* Switches to allow the digital IO pins to be enabled. The datasheet
3975 * is ambigious as to which NID is which; testing on laptops which
3976 * make this output available should provide clarification.
3978 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
3979 ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
3983 static struct hda_verb alc260_test_init_verbs[] = {
3984 /* Enable all GPIOs as outputs with an initial value of 0 */
3985 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
3986 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
3987 {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
3989 /* Enable retasking pins as output, initially without power amp */
3990 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3991 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3992 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3993 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3994 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3995 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3997 /* Disable digital (SPDIF) pins initially, but users can enable
3998 * them via a mixer switch. In the case of SPDIF-out, this initverb
3999 * payload also sets the generation to 0, output to be in "consumer"
4000 * PCM format, copyright asserted, no pre-emphasis and no validity
4003 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
4004 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
4006 /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
4007 * OUT1 sum bus when acting as an output.
4009 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
4010 {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
4011 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
4012 {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
4014 /* Start with output sum widgets muted and their output gains at min */
4015 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4016 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4017 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4018 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4019 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4020 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4021 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4022 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4023 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4025 /* Unmute retasking pin widget output buffers since the default
4026 * state appears to be output. As the pin mode is changed by the
4027 * user the pin mode control will take care of enabling the pin's
4028 * input/output buffers as needed.
4030 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4031 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4032 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4033 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4034 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4035 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4036 /* Also unmute the mono-out pin widget */
4037 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4039 /* Mute capture amp left and right */
4040 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4041 /* Set ADC connection select to match default mixer setting (mic1
4044 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
4046 /* Do the same for the second ADC: mute capture input amp and
4047 * set ADC connection to mic1 pin
4049 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4050 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
4052 /* Mute all inputs to mixer widget (even unconnected ones) */
4053 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
4054 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
4055 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
4056 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
4057 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
4058 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
4059 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
4060 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
4066 static struct hda_pcm_stream alc260_pcm_analog_playback = {
4072 static struct hda_pcm_stream alc260_pcm_analog_capture = {
4078 #define alc260_pcm_digital_playback alc880_pcm_digital_playback
4079 #define alc260_pcm_digital_capture alc880_pcm_digital_capture
4082 * for BIOS auto-configuration
4085 static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
4089 unsigned long vol_val, sw_val;
4093 if (nid >= 0x0f && nid < 0x11) {
4094 nid_vol = nid - 0x7;
4095 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
4096 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
4097 } else if (nid == 0x11) {
4098 nid_vol = nid - 0x7;
4099 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
4100 sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
4101 } else if (nid >= 0x12 && nid <= 0x15) {
4103 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
4104 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
4108 snprintf(name, sizeof(name), "%s Playback Volume", pfx);
4109 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name, vol_val)) < 0)
4111 snprintf(name, sizeof(name), "%s Playback Switch", pfx);
4112 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, sw_val)) < 0)
4117 /* add playback controls from the parsed DAC table */
4118 static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
4119 const struct auto_pin_cfg *cfg)
4124 spec->multiout.num_dacs = 1;
4125 spec->multiout.dac_nids = spec->private_dac_nids;
4126 spec->multiout.dac_nids[0] = 0x02;
4128 nid = cfg->line_out_pins[0];
4130 err = alc260_add_playback_controls(spec, nid, "Front");
4135 nid = cfg->speaker_pins[0];
4137 err = alc260_add_playback_controls(spec, nid, "Speaker");
4142 nid = cfg->hp_pins[0];
4144 err = alc260_add_playback_controls(spec, nid, "Headphone");
4151 /* create playback/capture controls for input pins */
4152 static int alc260_auto_create_analog_input_ctls(struct alc_spec *spec,
4153 const struct auto_pin_cfg *cfg)
4155 struct hda_input_mux *imux = &spec->private_imux;
4158 for (i = 0; i < AUTO_PIN_LAST; i++) {
4159 if (cfg->input_pins[i] >= 0x12) {
4160 idx = cfg->input_pins[i] - 0x12;
4161 err = new_analog_input(spec, cfg->input_pins[i],
4162 auto_pin_cfg_labels[i], idx, 0x07);
4165 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
4166 imux->items[imux->num_items].index = idx;
4169 if ((cfg->input_pins[i] >= 0x0f) && (cfg->input_pins[i] <= 0x10)){
4170 idx = cfg->input_pins[i] - 0x09;
4171 err = new_analog_input(spec, cfg->input_pins[i],
4172 auto_pin_cfg_labels[i], idx, 0x07);
4175 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
4176 imux->items[imux->num_items].index = idx;
4183 static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
4184 hda_nid_t nid, int pin_type,
4188 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
4189 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
4190 /* need the manual connection? */
4192 int idx = nid - 0x12;
4193 snd_hda_codec_write(codec, idx + 0x0b, 0,
4194 AC_VERB_SET_CONNECT_SEL, sel_idx);
4199 static void alc260_auto_init_multi_out(struct hda_codec *codec)
4201 struct alc_spec *spec = codec->spec;
4204 alc_subsystem_id(codec, 0x10, 0x15, 0x0f);
4205 nid = spec->autocfg.line_out_pins[0];
4207 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
4209 nid = spec->autocfg.speaker_pins[0];
4211 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
4213 nid = spec->autocfg.hp_pins[0];
4215 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
4218 #define ALC260_PIN_CD_NID 0x16
4219 static void alc260_auto_init_analog_input(struct hda_codec *codec)
4221 struct alc_spec *spec = codec->spec;
4224 for (i = 0; i < AUTO_PIN_LAST; i++) {
4225 hda_nid_t nid = spec->autocfg.input_pins[i];
4227 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4228 i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN);
4229 if (nid != ALC260_PIN_CD_NID)
4230 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
4237 * generic initialization of ADC, input mixers and output mixers
4239 static struct hda_verb alc260_volume_init_verbs[] = {
4241 * Unmute ADC0-1 and set the default input to mic-in
4243 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
4244 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4245 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
4246 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4248 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
4250 * Note: PASD motherboards uses the Line In 2 as the input for front panel
4253 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
4254 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4255 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4256 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
4257 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
4258 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
4261 * Set up output mixers (0x08 - 0x0a)
4263 /* set vol=0 to output mixers */
4264 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4265 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4266 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4267 /* set up input amps for analog loopback */
4268 /* Amp Indices: DAC = 0, mixer = 1 */
4269 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4270 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4271 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4272 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4273 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4274 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4279 static int alc260_parse_auto_config(struct hda_codec *codec)
4281 struct alc_spec *spec = codec->spec;
4284 static hda_nid_t alc260_ignore[] = { 0x17, 0 };
4286 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
4287 alc260_ignore)) < 0)
4289 if ((err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0)
4291 if (! spec->kctl_alloc)
4292 return 0; /* can't find valid BIOS pin config */
4293 if ((err = alc260_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0)
4296 spec->multiout.max_channels = 2;
4298 if (spec->autocfg.dig_out_pin)
4299 spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
4300 if (spec->kctl_alloc)
4301 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
4303 spec->init_verbs[spec->num_init_verbs++] = alc260_volume_init_verbs;
4305 spec->num_mux_defs = 1;
4306 spec->input_mux = &spec->private_imux;
4308 /* check whether NID 0x04 is valid */
4309 wcap = get_wcaps(codec, 0x04);
4310 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
4311 if (wcap != AC_WID_AUD_IN) {
4312 spec->adc_nids = alc260_adc_nids_alt;
4313 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
4314 spec->mixers[spec->num_mixers] = alc260_capture_alt_mixer;
4316 spec->adc_nids = alc260_adc_nids;
4317 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
4318 spec->mixers[spec->num_mixers] = alc260_capture_mixer;
4325 /* additional initialization for auto-configuration model */
4326 static void alc260_auto_init(struct hda_codec *codec)
4328 alc260_auto_init_multi_out(codec);
4329 alc260_auto_init_analog_input(codec);
4333 * ALC260 configurations
4335 static const char *alc260_models[ALC260_MODEL_LAST] = {
4336 [ALC260_BASIC] = "basic",
4338 [ALC260_HP_3013] = "hp-3013",
4339 [ALC260_FUJITSU_S702X] = "fujitsu",
4340 [ALC260_ACER] = "acer",
4341 [ALC260_WILL] = "will",
4342 [ALC260_REPLACER_672V] = "replacer",
4343 #ifdef CONFIG_SND_DEBUG
4344 [ALC260_TEST] = "test",
4346 [ALC260_AUTO] = "auto",
4349 static struct snd_pci_quirk alc260_cfg_tbl[] = {
4350 SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER),
4351 SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER),
4352 SND_PCI_QUIRK(0x103c, 0x2808, "HP d5700", ALC260_HP_3013),
4353 SND_PCI_QUIRK(0x103c, 0x280a, "HP d5750", ALC260_HP_3013),
4354 SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013),
4355 SND_PCI_QUIRK(0x103c, 0x3011, "HP", ALC260_HP),
4356 SND_PCI_QUIRK(0x103c, 0x3012, "HP", ALC260_HP_3013),
4357 SND_PCI_QUIRK(0x103c, 0x3013, "HP", ALC260_HP_3013),
4358 SND_PCI_QUIRK(0x103c, 0x3014, "HP", ALC260_HP),
4359 SND_PCI_QUIRK(0x103c, 0x3015, "HP", ALC260_HP),
4360 SND_PCI_QUIRK(0x103c, 0x3016, "HP", ALC260_HP),
4361 SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_BASIC),
4362 SND_PCI_QUIRK(0x104d, 0x81cc, "Sony VAIO", ALC260_BASIC),
4363 SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC),
4364 SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X),
4365 SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC),
4366 SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_WILL),
4367 SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_REPLACER_672V),
4371 static struct alc_config_preset alc260_presets[] = {
4373 .mixers = { alc260_base_output_mixer,
4375 alc260_pc_beep_mixer,
4376 alc260_capture_mixer },
4377 .init_verbs = { alc260_init_verbs },
4378 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4379 .dac_nids = alc260_dac_nids,
4380 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
4381 .adc_nids = alc260_adc_nids,
4382 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4383 .channel_mode = alc260_modes,
4384 .input_mux = &alc260_capture_source,
4387 .mixers = { alc260_base_output_mixer,
4389 alc260_capture_alt_mixer },
4390 .init_verbs = { alc260_init_verbs },
4391 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4392 .dac_nids = alc260_dac_nids,
4393 .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
4394 .adc_nids = alc260_hp_adc_nids,
4395 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4396 .channel_mode = alc260_modes,
4397 .input_mux = &alc260_capture_source,
4399 [ALC260_HP_3013] = {
4400 .mixers = { alc260_hp_3013_mixer,
4402 alc260_capture_alt_mixer },
4403 .init_verbs = { alc260_hp_3013_init_verbs },
4404 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4405 .dac_nids = alc260_dac_nids,
4406 .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
4407 .adc_nids = alc260_hp_adc_nids,
4408 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4409 .channel_mode = alc260_modes,
4410 .input_mux = &alc260_capture_source,
4412 [ALC260_FUJITSU_S702X] = {
4413 .mixers = { alc260_fujitsu_mixer,
4414 alc260_capture_mixer },
4415 .init_verbs = { alc260_fujitsu_init_verbs },
4416 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4417 .dac_nids = alc260_dac_nids,
4418 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
4419 .adc_nids = alc260_dual_adc_nids,
4420 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4421 .channel_mode = alc260_modes,
4422 .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources),
4423 .input_mux = alc260_fujitsu_capture_sources,
4426 .mixers = { alc260_acer_mixer,
4427 alc260_capture_mixer },
4428 .init_verbs = { alc260_acer_init_verbs },
4429 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4430 .dac_nids = alc260_dac_nids,
4431 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
4432 .adc_nids = alc260_dual_adc_nids,
4433 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4434 .channel_mode = alc260_modes,
4435 .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
4436 .input_mux = alc260_acer_capture_sources,
4439 .mixers = { alc260_will_mixer,
4440 alc260_capture_mixer },
4441 .init_verbs = { alc260_init_verbs, alc260_will_verbs },
4442 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4443 .dac_nids = alc260_dac_nids,
4444 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
4445 .adc_nids = alc260_adc_nids,
4446 .dig_out_nid = ALC260_DIGOUT_NID,
4447 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4448 .channel_mode = alc260_modes,
4449 .input_mux = &alc260_capture_source,
4451 [ALC260_REPLACER_672V] = {
4452 .mixers = { alc260_replacer_672v_mixer,
4453 alc260_capture_mixer },
4454 .init_verbs = { alc260_init_verbs, alc260_replacer_672v_verbs },
4455 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4456 .dac_nids = alc260_dac_nids,
4457 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
4458 .adc_nids = alc260_adc_nids,
4459 .dig_out_nid = ALC260_DIGOUT_NID,
4460 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4461 .channel_mode = alc260_modes,
4462 .input_mux = &alc260_capture_source,
4463 .unsol_event = alc260_replacer_672v_unsol_event,
4464 .init_hook = alc260_replacer_672v_automute,
4466 #ifdef CONFIG_SND_DEBUG
4468 .mixers = { alc260_test_mixer,
4469 alc260_capture_mixer },
4470 .init_verbs = { alc260_test_init_verbs },
4471 .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
4472 .dac_nids = alc260_test_dac_nids,
4473 .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
4474 .adc_nids = alc260_test_adc_nids,
4475 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4476 .channel_mode = alc260_modes,
4477 .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources),
4478 .input_mux = alc260_test_capture_sources,
4483 static int patch_alc260(struct hda_codec *codec)
4485 struct alc_spec *spec;
4486 int err, board_config;
4488 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4494 board_config = snd_hda_check_board_config(codec, ALC260_MODEL_LAST,
4497 if (board_config < 0) {
4498 snd_printd(KERN_INFO "hda_codec: Unknown model for ALC260, "
4499 "trying auto-probe from BIOS...\n");
4500 board_config = ALC260_AUTO;
4503 if (board_config == ALC260_AUTO) {
4504 /* automatic parse from the BIOS config */
4505 err = alc260_parse_auto_config(codec);
4511 "hda_codec: Cannot set up configuration "
4512 "from BIOS. Using base mode...\n");
4513 board_config = ALC260_BASIC;
4517 if (board_config != ALC260_AUTO)
4518 setup_preset(spec, &alc260_presets[board_config]);
4520 spec->stream_name_analog = "ALC260 Analog";
4521 spec->stream_analog_playback = &alc260_pcm_analog_playback;
4522 spec->stream_analog_capture = &alc260_pcm_analog_capture;
4524 spec->stream_name_digital = "ALC260 Digital";
4525 spec->stream_digital_playback = &alc260_pcm_digital_playback;
4526 spec->stream_digital_capture = &alc260_pcm_digital_capture;
4528 codec->patch_ops = alc_patch_ops;
4529 if (board_config == ALC260_AUTO)
4530 spec->init_hook = alc260_auto_init;
4539 * ALC882 is almost identical with ALC880 but has cleaner and more flexible
4540 * configuration. Each pin widget can choose any input DACs and a mixer.
4541 * Each ADC is connected from a mixer of all inputs. This makes possible
4542 * 6-channel independent captures.
4544 * In addition, an independent DAC for the multi-playback (not used in this
4547 #define ALC882_DIGOUT_NID 0x06
4548 #define ALC882_DIGIN_NID 0x0a
4550 static struct hda_channel_mode alc882_ch_modes[1] = {
4554 static hda_nid_t alc882_dac_nids[4] = {
4555 /* front, rear, clfe, rear_surr */
4556 0x02, 0x03, 0x04, 0x05
4559 /* identical with ALC880 */
4560 #define alc882_adc_nids alc880_adc_nids
4561 #define alc882_adc_nids_alt alc880_adc_nids_alt
4564 /* FIXME: should be a matrix-type input source selection */
4566 static struct hda_input_mux alc882_capture_source = {
4570 { "Front Mic", 0x1 },
4575 #define alc882_mux_enum_info alc_mux_enum_info
4576 #define alc882_mux_enum_get alc_mux_enum_get
4578 static int alc882_mux_enum_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
4580 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4581 struct alc_spec *spec = codec->spec;
4582 const struct hda_input_mux *imux = spec->input_mux;
4583 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
4584 static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
4585 hda_nid_t nid = capture_mixers[adc_idx];
4586 unsigned int *cur_val = &spec->cur_mux[adc_idx];
4587 unsigned int i, idx;
4589 idx = ucontrol->value.enumerated.item[0];
4590 if (idx >= imux->num_items)
4591 idx = imux->num_items - 1;
4592 if (*cur_val == idx && ! codec->in_resume)
4594 for (i = 0; i < imux->num_items; i++) {
4595 unsigned int v = (i == idx) ? 0x7000 : 0x7080;
4596 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
4597 v | (imux->items[i].index << 8));
4606 static struct hda_verb alc882_sixstack_ch6_init[] = {
4607 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
4608 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4609 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4610 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4617 static struct hda_verb alc882_sixstack_ch8_init[] = {
4618 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4619 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4620 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4621 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4625 static struct hda_channel_mode alc882_sixstack_modes[2] = {
4626 { 6, alc882_sixstack_ch6_init },
4627 { 8, alc882_sixstack_ch8_init },
4630 /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
4631 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
4633 static struct snd_kcontrol_new alc882_base_mixer[] = {
4634 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
4635 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
4636 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
4637 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
4638 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
4639 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
4640 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
4641 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
4642 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
4643 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
4644 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
4645 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
4646 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
4647 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
4648 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
4649 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
4650 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
4651 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
4652 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
4653 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
4654 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
4655 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
4656 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
4660 static struct snd_kcontrol_new alc882_chmode_mixer[] = {
4662 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4663 .name = "Channel Mode",
4664 .info = alc_ch_mode_info,
4665 .get = alc_ch_mode_get,
4666 .put = alc_ch_mode_put,
4671 static struct hda_verb alc882_init_verbs[] = {
4672 /* Front mixer: unmute input/output amp left and right (volume = 0) */
4673 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4674 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4675 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4677 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4678 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4679 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4681 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4682 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4683 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4685 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4686 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4687 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4689 /* Front Pin: output 0 (0x0c) */
4690 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4691 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4692 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
4693 /* Rear Pin: output 1 (0x0d) */
4694 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4695 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4696 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
4697 /* CLFE Pin: output 2 (0x0e) */
4698 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4699 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4700 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
4701 /* Side Pin: output 3 (0x0f) */
4702 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4703 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4704 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
4705 /* Mic (rear) pin: input vref at 80% */
4706 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
4707 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4708 /* Front Mic pin: input vref at 80% */
4709 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
4710 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4711 /* Line In pin: input */
4712 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
4713 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4714 /* Line-2 In: Headphone output (output 0 - 0x0c) */
4715 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4716 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4717 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
4718 /* CD pin widget for input */
4719 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
4721 /* FIXME: use matrix-type input source selection */
4722 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
4723 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
4724 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4725 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4726 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4727 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
4729 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4730 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4731 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4732 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
4734 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4735 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4736 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4737 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
4738 /* ADC1: mute amp left and right */
4739 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4740 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
4741 /* ADC2: mute amp left and right */
4742 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4743 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
4744 /* ADC3: mute amp left and right */
4745 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4746 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
4751 static struct hda_verb alc882_eapd_verbs[] = {
4752 /* change to EAPD mode */
4753 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
4754 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
4759 static struct snd_kcontrol_new alc882_macpro_mixer[] = {
4760 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
4761 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
4762 HDA_CODEC_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT),
4763 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
4764 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
4765 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x02, HDA_INPUT),
4766 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x02, HDA_INPUT),
4770 static struct hda_verb alc882_macpro_init_verbs[] = {
4771 /* Front mixer: unmute input/output amp left and right (volume = 0) */
4772 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4773 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4774 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4775 /* Front Pin: output 0 (0x0c) */
4776 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4777 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4778 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
4779 /* Front Mic pin: input vref at 80% */
4780 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
4781 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4782 /* Speaker: output */
4783 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4784 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4785 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x04},
4786 /* Headphone output (output 0 - 0x0c) */
4787 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4788 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4789 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
4791 /* FIXME: use matrix-type input source selection */
4792 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
4793 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
4794 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4795 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4796 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4797 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
4799 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4800 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4801 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4802 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
4804 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4805 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4806 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4807 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
4808 /* ADC1: mute amp left and right */
4809 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4810 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
4811 /* ADC2: mute amp left and right */
4812 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4813 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
4814 /* ADC3: mute amp left and right */
4815 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4816 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
4820 static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
4822 unsigned int gpiostate, gpiomask, gpiodir;
4824 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
4825 AC_VERB_GET_GPIO_DATA, 0);
4828 gpiostate |= (1 << pin);
4830 gpiostate &= ~(1 << pin);
4832 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
4833 AC_VERB_GET_GPIO_MASK, 0);
4834 gpiomask |= (1 << pin);
4836 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
4837 AC_VERB_GET_GPIO_DIRECTION, 0);
4838 gpiodir |= (1 << pin);
4841 snd_hda_codec_write(codec, codec->afg, 0,
4842 AC_VERB_SET_GPIO_MASK, gpiomask);
4843 snd_hda_codec_write(codec, codec->afg, 0,
4844 AC_VERB_SET_GPIO_DIRECTION, gpiodir);
4848 snd_hda_codec_write(codec, codec->afg, 0,
4849 AC_VERB_SET_GPIO_DATA, gpiostate);
4853 * generic initialization of ADC, input mixers and output mixers
4855 static struct hda_verb alc882_auto_init_verbs[] = {
4857 * Unmute ADC0-2 and set the default input to mic-in
4859 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
4860 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4861 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
4862 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4863 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
4864 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4866 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
4868 * Note: PASD motherboards uses the Line In 2 as the input for front panel
4871 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
4872 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4873 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4874 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
4875 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
4876 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
4879 * Set up output mixers (0x0c - 0x0f)
4881 /* set vol=0 to output mixers */
4882 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4883 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4884 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4885 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4886 /* set up input amps for analog loopback */
4887 /* Amp Indices: DAC = 0, mixer = 1 */
4888 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4889 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4890 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4891 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4892 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4893 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4894 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4895 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4896 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4897 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4899 /* FIXME: use matrix-type input source selection */
4900 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
4901 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
4902 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4903 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
4904 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
4905 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
4907 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4908 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
4909 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
4910 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
4912 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4913 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
4914 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
4915 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
4920 /* capture mixer elements */
4921 static struct snd_kcontrol_new alc882_capture_alt_mixer[] = {
4922 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
4923 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
4924 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
4925 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
4927 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4928 /* The multiple "Capture Source" controls confuse alsamixer
4929 * So call somewhat different..
4930 * FIXME: the controls appear in the "playback" view!
4932 /* .name = "Capture Source", */
4933 .name = "Input Source",
4935 .info = alc882_mux_enum_info,
4936 .get = alc882_mux_enum_get,
4937 .put = alc882_mux_enum_put,
4942 static struct snd_kcontrol_new alc882_capture_mixer[] = {
4943 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
4944 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
4945 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
4946 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
4947 HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
4948 HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
4950 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4951 /* The multiple "Capture Source" controls confuse alsamixer
4952 * So call somewhat different..
4953 * FIXME: the controls appear in the "playback" view!
4955 /* .name = "Capture Source", */
4956 .name = "Input Source",
4958 .info = alc882_mux_enum_info,
4959 .get = alc882_mux_enum_get,
4960 .put = alc882_mux_enum_put,
4965 /* pcm configuration: identiacal with ALC880 */
4966 #define alc882_pcm_analog_playback alc880_pcm_analog_playback
4967 #define alc882_pcm_analog_capture alc880_pcm_analog_capture
4968 #define alc882_pcm_digital_playback alc880_pcm_digital_playback
4969 #define alc882_pcm_digital_capture alc880_pcm_digital_capture
4972 * configuration and preset
4974 static const char *alc882_models[ALC882_MODEL_LAST] = {
4975 [ALC882_3ST_DIG] = "3stack-dig",
4976 [ALC882_6ST_DIG] = "6stack-dig",
4977 [ALC882_ARIMA] = "arima",
4978 [ALC885_MACPRO] = "macpro",
4979 [ALC882_AUTO] = "auto",
4982 static struct snd_pci_quirk alc882_cfg_tbl[] = {
4983 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG),
4984 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG),
4985 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG),
4986 SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA),
4987 SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG),
4991 static struct alc_config_preset alc882_presets[] = {
4992 [ALC882_3ST_DIG] = {
4993 .mixers = { alc882_base_mixer },
4994 .init_verbs = { alc882_init_verbs },
4995 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
4996 .dac_nids = alc882_dac_nids,
4997 .dig_out_nid = ALC882_DIGOUT_NID,
4998 .dig_in_nid = ALC882_DIGIN_NID,
4999 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
5000 .channel_mode = alc882_ch_modes,
5002 .input_mux = &alc882_capture_source,
5004 [ALC882_6ST_DIG] = {
5005 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
5006 .init_verbs = { alc882_init_verbs },
5007 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5008 .dac_nids = alc882_dac_nids,
5009 .dig_out_nid = ALC882_DIGOUT_NID,
5010 .dig_in_nid = ALC882_DIGIN_NID,
5011 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
5012 .channel_mode = alc882_sixstack_modes,
5013 .input_mux = &alc882_capture_source,
5016 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
5017 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs },
5018 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5019 .dac_nids = alc882_dac_nids,
5020 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
5021 .channel_mode = alc882_sixstack_modes,
5022 .input_mux = &alc882_capture_source,
5025 .mixers = { alc882_macpro_mixer },
5026 .init_verbs = { alc882_macpro_init_verbs },
5027 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5028 .dac_nids = alc882_dac_nids,
5029 .dig_out_nid = ALC882_DIGOUT_NID,
5030 .dig_in_nid = ALC882_DIGIN_NID,
5031 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
5032 .channel_mode = alc882_ch_modes,
5033 .input_mux = &alc882_capture_source,
5039 * BIOS auto configuration
5041 static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
5042 hda_nid_t nid, int pin_type,
5046 struct alc_spec *spec = codec->spec;
5049 if (spec->multiout.dac_nids[dac_idx] == 0x25)
5052 idx = spec->multiout.dac_nids[dac_idx] - 2;
5054 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
5055 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
5056 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
5060 static void alc882_auto_init_multi_out(struct hda_codec *codec)
5062 struct alc_spec *spec = codec->spec;
5065 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
5066 for (i = 0; i <= HDA_SIDE; i++) {
5067 hda_nid_t nid = spec->autocfg.line_out_pins[i];
5069 alc882_auto_set_output_and_unmute(codec, nid, PIN_OUT, i);
5073 static void alc882_auto_init_hp_out(struct hda_codec *codec)
5075 struct alc_spec *spec = codec->spec;
5078 pin = spec->autocfg.hp_pins[0];
5079 if (pin) /* connect to front */
5080 alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0); /* use dac 0 */
5083 #define alc882_is_input_pin(nid) alc880_is_input_pin(nid)
5084 #define ALC882_PIN_CD_NID ALC880_PIN_CD_NID
5086 static void alc882_auto_init_analog_input(struct hda_codec *codec)
5088 struct alc_spec *spec = codec->spec;
5091 for (i = 0; i < AUTO_PIN_LAST; i++) {
5092 hda_nid_t nid = spec->autocfg.input_pins[i];
5093 if (alc882_is_input_pin(nid)) {
5094 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5095 i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN);
5096 if (nid != ALC882_PIN_CD_NID)
5097 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
5103 /* almost identical with ALC880 parser... */
5104 static int alc882_parse_auto_config(struct hda_codec *codec)
5106 struct alc_spec *spec = codec->spec;
5107 int err = alc880_parse_auto_config(codec);
5112 /* hack - override the init verbs */
5113 spec->init_verbs[0] = alc882_auto_init_verbs;
5117 /* additional initialization for auto-configuration model */
5118 static void alc882_auto_init(struct hda_codec *codec)
5120 alc882_auto_init_multi_out(codec);
5121 alc882_auto_init_hp_out(codec);
5122 alc882_auto_init_analog_input(codec);
5125 static int patch_alc882(struct hda_codec *codec)
5127 struct alc_spec *spec;
5128 int err, board_config;
5130 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5136 board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST,
5140 if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
5141 /* Pick up systems that don't supply PCI SSID */
5142 switch (codec->subsystem_id) {
5143 case 0x106b0c00: /* Mac Pro */
5144 board_config = ALC885_MACPRO;
5147 printk(KERN_INFO "hda_codec: Unknown model for ALC882, "
5148 "trying auto-probe from BIOS...\n");
5149 board_config = ALC882_AUTO;
5153 if (board_config == ALC882_AUTO) {
5154 /* automatic parse from the BIOS config */
5155 err = alc882_parse_auto_config(codec);
5161 "hda_codec: Cannot set up configuration "
5162 "from BIOS. Using base mode...\n");
5163 board_config = ALC882_3ST_DIG;
5167 if (board_config != ALC882_AUTO)
5168 setup_preset(spec, &alc882_presets[board_config]);
5170 if (board_config == ALC885_MACPRO) {
5171 alc882_gpio_mute(codec, 0, 0);
5172 alc882_gpio_mute(codec, 1, 0);
5175 spec->stream_name_analog = "ALC882 Analog";
5176 spec->stream_analog_playback = &alc882_pcm_analog_playback;
5177 spec->stream_analog_capture = &alc882_pcm_analog_capture;
5179 spec->stream_name_digital = "ALC882 Digital";
5180 spec->stream_digital_playback = &alc882_pcm_digital_playback;
5181 spec->stream_digital_capture = &alc882_pcm_digital_capture;
5183 if (! spec->adc_nids && spec->input_mux) {
5184 /* check whether NID 0x07 is valid */
5185 unsigned int wcap = get_wcaps(codec, 0x07);
5186 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
5187 if (wcap != AC_WID_AUD_IN) {
5188 spec->adc_nids = alc882_adc_nids_alt;
5189 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids_alt);
5190 spec->mixers[spec->num_mixers] = alc882_capture_alt_mixer;
5193 spec->adc_nids = alc882_adc_nids;
5194 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids);
5195 spec->mixers[spec->num_mixers] = alc882_capture_mixer;
5200 codec->patch_ops = alc_patch_ops;
5201 if (board_config == ALC882_AUTO)
5202 spec->init_hook = alc882_auto_init;
5210 * ALC883 is almost identical with ALC880 but has cleaner and more flexible
5211 * configuration. Each pin widget can choose any input DACs and a mixer.
5212 * Each ADC is connected from a mixer of all inputs. This makes possible
5213 * 6-channel independent captures.
5215 * In addition, an independent DAC for the multi-playback (not used in this
5218 #define ALC883_DIGOUT_NID 0x06
5219 #define ALC883_DIGIN_NID 0x0a
5221 static hda_nid_t alc883_dac_nids[4] = {
5222 /* front, rear, clfe, rear_surr */
5223 0x02, 0x04, 0x03, 0x05
5226 static hda_nid_t alc883_adc_nids[2] = {
5231 /* FIXME: should be a matrix-type input source selection */
5233 static struct hda_input_mux alc883_capture_source = {
5237 { "Front Mic", 0x1 },
5243 static struct hda_input_mux alc883_lenovo_101e_capture_source = {
5251 #define alc883_mux_enum_info alc_mux_enum_info
5252 #define alc883_mux_enum_get alc_mux_enum_get
5254 static int alc883_mux_enum_put(struct snd_kcontrol *kcontrol,
5255 struct snd_ctl_elem_value *ucontrol)
5257 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
5258 struct alc_spec *spec = codec->spec;
5259 const struct hda_input_mux *imux = spec->input_mux;
5260 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
5261 static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
5262 hda_nid_t nid = capture_mixers[adc_idx];
5263 unsigned int *cur_val = &spec->cur_mux[adc_idx];
5264 unsigned int i, idx;
5266 idx = ucontrol->value.enumerated.item[0];
5267 if (idx >= imux->num_items)
5268 idx = imux->num_items - 1;
5269 if (*cur_val == idx && ! codec->in_resume)
5271 for (i = 0; i < imux->num_items; i++) {
5272 unsigned int v = (i == idx) ? 0x7000 : 0x7080;
5273 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
5274 v | (imux->items[i].index << 8));
5282 static struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
5289 static struct hda_verb alc883_3ST_ch2_init[] = {
5290 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
5291 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
5292 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
5293 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
5300 static struct hda_verb alc883_3ST_ch6_init[] = {
5301 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5302 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
5303 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
5304 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5305 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
5306 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
5310 static struct hda_channel_mode alc883_3ST_6ch_modes[2] = {
5311 { 2, alc883_3ST_ch2_init },
5312 { 6, alc883_3ST_ch6_init },
5318 static struct hda_verb alc883_sixstack_ch6_init[] = {
5319 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
5320 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5321 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5322 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5329 static struct hda_verb alc883_sixstack_ch8_init[] = {
5330 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5331 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5332 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5333 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5337 static struct hda_channel_mode alc883_sixstack_modes[2] = {
5338 { 6, alc883_sixstack_ch6_init },
5339 { 8, alc883_sixstack_ch8_init },
5342 static struct hda_verb alc883_medion_eapd_verbs[] = {
5343 /* eanable EAPD on medion laptop */
5344 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
5345 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
5349 /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
5350 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
5353 static struct snd_kcontrol_new alc883_base_mixer[] = {
5354 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5355 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5356 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
5357 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
5358 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
5359 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
5360 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
5361 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
5362 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
5363 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
5364 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5365 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5366 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5367 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5368 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5369 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5370 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
5371 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5372 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
5373 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
5374 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
5375 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
5376 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
5377 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
5378 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
5379 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
5380 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
5382 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5383 /* .name = "Capture Source", */
5384 .name = "Input Source",
5386 .info = alc883_mux_enum_info,
5387 .get = alc883_mux_enum_get,
5388 .put = alc883_mux_enum_put,
5393 static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
5394 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5395 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5396 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5397 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5398 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5399 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5400 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5401 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5402 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
5403 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5404 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
5405 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
5406 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
5407 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
5408 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
5409 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
5410 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
5411 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
5412 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
5414 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5415 /* .name = "Capture Source", */
5416 .name = "Input Source",
5418 .info = alc883_mux_enum_info,
5419 .get = alc883_mux_enum_get,
5420 .put = alc883_mux_enum_put,
5425 static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
5426 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5427 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5428 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
5429 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
5430 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
5431 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
5432 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
5433 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
5434 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5435 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5436 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5437 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5438 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5439 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5440 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
5441 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5442 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
5443 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
5444 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
5445 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
5446 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
5447 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
5448 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
5449 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
5450 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
5452 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5453 /* .name = "Capture Source", */
5454 .name = "Input Source",
5456 .info = alc883_mux_enum_info,
5457 .get = alc883_mux_enum_get,
5458 .put = alc883_mux_enum_put,
5463 static struct snd_kcontrol_new alc883_fivestack_mixer[] = {
5464 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5465 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
5466 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
5467 HDA_CODEC_MUTE("Surround Playback Switch", 0x15, 0x0, HDA_OUTPUT),
5468 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
5469 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
5470 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x16, 1, 0x0, HDA_OUTPUT),
5471 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
5472 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5473 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5474 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5475 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5476 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5477 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5478 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
5479 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5480 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
5481 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
5482 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
5483 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
5484 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
5485 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
5486 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
5489 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5490 /* .name = "Capture Source", */
5491 .name = "Input Source",
5493 .info = alc883_mux_enum_info,
5494 .get = alc883_mux_enum_get,
5495 .put = alc883_mux_enum_put,
5500 static struct snd_kcontrol_new alc883_tagra_mixer[] = {
5501 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5502 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
5503 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5504 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
5505 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
5506 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
5507 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
5508 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
5509 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
5510 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5511 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5512 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5513 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5514 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5515 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
5516 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5517 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
5518 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
5519 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
5520 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
5522 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5523 /* .name = "Capture Source", */
5524 .name = "Input Source",
5526 .info = alc883_mux_enum_info,
5527 .get = alc883_mux_enum_get,
5528 .put = alc883_mux_enum_put,
5533 static struct snd_kcontrol_new alc883_tagra_2ch_mixer[] = {
5534 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5535 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
5536 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5537 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5538 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5539 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5540 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
5541 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5542 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
5543 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
5544 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
5545 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
5547 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5548 /* .name = "Capture Source", */
5549 .name = "Input Source",
5551 .info = alc883_mux_enum_info,
5552 .get = alc883_mux_enum_get,
5553 .put = alc883_mux_enum_put,
5558 static struct snd_kcontrol_new alc883_lenovo_101e_2ch_mixer[] = {
5559 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5560 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5561 HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
5562 HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT),
5563 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5564 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
5565 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
5566 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
5567 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
5568 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
5570 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5571 /* .name = "Capture Source", */
5572 .name = "Input Source",
5574 .info = alc883_mux_enum_info,
5575 .get = alc883_mux_enum_get,
5576 .put = alc883_mux_enum_put,
5581 static struct snd_kcontrol_new alc883_chmode_mixer[] = {
5583 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5584 .name = "Channel Mode",
5585 .info = alc_ch_mode_info,
5586 .get = alc_ch_mode_get,
5587 .put = alc_ch_mode_put,
5592 static struct hda_verb alc883_init_verbs[] = {
5593 /* ADC1: mute amp left and right */
5594 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5595 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
5596 /* ADC2: mute amp left and right */
5597 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5598 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
5599 /* Front mixer: unmute input/output amp left and right (volume = 0) */
5600 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5601 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5602 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5604 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5605 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5606 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5608 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5609 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5610 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5612 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5613 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5614 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5616 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5617 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5618 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
5619 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
5620 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
5622 /* Front Pin: output 0 (0x0c) */
5623 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5624 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5625 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
5626 /* Rear Pin: output 1 (0x0d) */
5627 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5628 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5629 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
5630 /* CLFE Pin: output 2 (0x0e) */
5631 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5632 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5633 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
5634 /* Side Pin: output 3 (0x0f) */
5635 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5636 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5637 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
5638 /* Mic (rear) pin: input vref at 80% */
5639 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5640 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5641 /* Front Mic pin: input vref at 80% */
5642 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5643 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5644 /* Line In pin: input */
5645 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
5646 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5647 /* Line-2 In: Headphone output (output 0 - 0x0c) */
5648 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5649 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5650 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
5651 /* CD pin widget for input */
5652 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
5654 /* FIXME: use matrix-type input source selection */
5655 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5657 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5658 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5659 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
5660 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
5662 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5663 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5664 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
5665 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
5669 static struct hda_verb alc883_tagra_verbs[] = {
5670 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5671 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5673 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5674 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5676 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
5677 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
5678 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
5680 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
5681 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
5682 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
5683 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
5688 static struct hda_verb alc883_lenovo_101e_verbs[] = {
5689 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
5690 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT|AC_USRSP_EN},
5691 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT|AC_USRSP_EN},
5695 /* toggle speaker-output according to the hp-jack state */
5696 static void alc883_tagra_automute(struct hda_codec *codec)
5698 unsigned int present;
5700 present = snd_hda_codec_read(codec, 0x14, 0,
5701 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
5702 snd_hda_codec_amp_update(codec, 0x1b, 0, HDA_OUTPUT, 0,
5703 0x80, present ? 0x80 : 0);
5704 snd_hda_codec_amp_update(codec, 0x1b, 1, HDA_OUTPUT, 0,
5705 0x80, present ? 0x80 : 0);
5706 snd_hda_codec_write(codec, 1, 0, AC_VERB_SET_GPIO_DATA, present ? 1 : 3);
5709 static void alc883_tagra_unsol_event(struct hda_codec *codec, unsigned int res)
5711 if ((res >> 26) == ALC880_HP_EVENT)
5712 alc883_tagra_automute(codec);
5715 static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
5717 unsigned int present;
5719 present = snd_hda_codec_read(codec, 0x14, 0,
5720 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
5722 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
5723 0x80, present ? 0x80 : 0);
5724 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
5725 0x80, present ? 0x80 : 0);
5728 static void alc883_lenovo_101e_all_automute(struct hda_codec *codec)
5730 unsigned int present;
5732 present = snd_hda_codec_read(codec, 0x1b, 0,
5733 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
5735 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
5736 0x80, present ? 0x80 : 0);
5737 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
5738 0x80, present ? 0x80 : 0);
5739 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
5740 0x80, present ? 0x80 : 0);
5741 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
5742 0x80, present ? 0x80 : 0);
5745 static void alc883_lenovo_101e_unsol_event(struct hda_codec *codec,
5748 if ((res >> 26) == ALC880_HP_EVENT)
5749 alc883_lenovo_101e_all_automute(codec);
5750 if ((res >> 26) == ALC880_FRONT_EVENT)
5751 alc883_lenovo_101e_ispeaker_automute(codec);
5755 * generic initialization of ADC, input mixers and output mixers
5757 static struct hda_verb alc883_auto_init_verbs[] = {
5759 * Unmute ADC0-2 and set the default input to mic-in
5761 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
5762 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5763 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
5764 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5766 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
5768 * Note: PASD motherboards uses the Line In 2 as the input for front panel
5771 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
5772 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5773 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5774 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
5775 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
5776 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
5779 * Set up output mixers (0x0c - 0x0f)
5781 /* set vol=0 to output mixers */
5782 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5783 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5784 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5785 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5786 /* set up input amps for analog loopback */
5787 /* Amp Indices: DAC = 0, mixer = 1 */
5788 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5789 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5790 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5791 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5792 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5793 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5794 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5795 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5796 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5797 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5799 /* FIXME: use matrix-type input source selection */
5800 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5802 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5803 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5804 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
5805 //{0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
5806 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
5808 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5809 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5810 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
5811 //{0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
5812 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
5817 /* capture mixer elements */
5818 static struct snd_kcontrol_new alc883_capture_mixer[] = {
5819 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
5820 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
5821 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
5822 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
5824 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5825 /* The multiple "Capture Source" controls confuse alsamixer
5826 * So call somewhat different..
5827 * FIXME: the controls appear in the "playback" view!
5829 /* .name = "Capture Source", */
5830 .name = "Input Source",
5832 .info = alc882_mux_enum_info,
5833 .get = alc882_mux_enum_get,
5834 .put = alc882_mux_enum_put,
5839 /* pcm configuration: identiacal with ALC880 */
5840 #define alc883_pcm_analog_playback alc880_pcm_analog_playback
5841 #define alc883_pcm_analog_capture alc880_pcm_analog_capture
5842 #define alc883_pcm_digital_playback alc880_pcm_digital_playback
5843 #define alc883_pcm_digital_capture alc880_pcm_digital_capture
5846 * configuration and preset
5848 static const char *alc883_models[ALC883_MODEL_LAST] = {
5849 [ALC883_3ST_2ch_DIG] = "3stack-dig",
5850 [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig",
5851 [ALC883_3ST_6ch] = "3stack-6ch",
5852 [ALC883_6ST_DIG] = "6stack-dig",
5853 [ALC883_TARGA_DIG] = "targa-dig",
5854 [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig",
5855 [ALC888_DEMO_BOARD] = "6stack-dig-demo",
5856 [ALC883_ACER] = "acer",
5857 [ALC883_MEDION] = "medion",
5858 [ALC883_LAPTOP_EAPD] = "laptop-eapd",
5859 [ALC883_LENOVO_101E_2ch] = "lenovo-101e",
5860 [ALC883_AUTO] = "auto",
5863 static struct snd_pci_quirk alc883_cfg_tbl[] = {
5864 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC883_3ST_6ch_DIG),
5865 SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch),
5866 SND_PCI_QUIRK(0x1558, 0, "Clevo laptop", ALC883_LAPTOP_EAPD),
5867 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC883_6ST_DIG),
5868 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG),
5869 SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG),
5870 SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG),
5871 SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG),
5872 SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG),
5873 SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG),
5874 SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG),
5875 SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG),
5876 SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG),
5877 SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG),
5878 SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG),
5879 SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG),
5880 SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG),
5881 SND_PCI_QUIRK(0x1025, 0, "Acer laptop", ALC883_ACER),
5882 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
5883 SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD),
5884 SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC883_3ST_6ch),
5885 SND_PCI_QUIRK(0x17aa, 0x101e, "lenovo 101e", ALC883_LENOVO_101E_2ch),
5889 static struct alc_config_preset alc883_presets[] = {
5890 [ALC883_3ST_2ch_DIG] = {
5891 .mixers = { alc883_3ST_2ch_mixer },
5892 .init_verbs = { alc883_init_verbs },
5893 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
5894 .dac_nids = alc883_dac_nids,
5895 .dig_out_nid = ALC883_DIGOUT_NID,
5896 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
5897 .adc_nids = alc883_adc_nids,
5898 .dig_in_nid = ALC883_DIGIN_NID,
5899 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
5900 .channel_mode = alc883_3ST_2ch_modes,
5901 .input_mux = &alc883_capture_source,
5903 [ALC883_3ST_6ch_DIG] = {
5904 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
5905 .init_verbs = { alc883_init_verbs },
5906 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
5907 .dac_nids = alc883_dac_nids,
5908 .dig_out_nid = ALC883_DIGOUT_NID,
5909 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
5910 .adc_nids = alc883_adc_nids,
5911 .dig_in_nid = ALC883_DIGIN_NID,
5912 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
5913 .channel_mode = alc883_3ST_6ch_modes,
5915 .input_mux = &alc883_capture_source,
5917 [ALC883_3ST_6ch] = {
5918 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
5919 .init_verbs = { alc883_init_verbs },
5920 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
5921 .dac_nids = alc883_dac_nids,
5922 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
5923 .adc_nids = alc883_adc_nids,
5924 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
5925 .channel_mode = alc883_3ST_6ch_modes,
5927 .input_mux = &alc883_capture_source,
5929 [ALC883_6ST_DIG] = {
5930 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
5931 .init_verbs = { alc883_init_verbs },
5932 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
5933 .dac_nids = alc883_dac_nids,
5934 .dig_out_nid = ALC883_DIGOUT_NID,
5935 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
5936 .adc_nids = alc883_adc_nids,
5937 .dig_in_nid = ALC883_DIGIN_NID,
5938 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
5939 .channel_mode = alc883_sixstack_modes,
5940 .input_mux = &alc883_capture_source,
5942 [ALC883_TARGA_DIG] = {
5943 .mixers = { alc883_tagra_mixer, alc883_chmode_mixer },
5944 .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
5945 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
5946 .dac_nids = alc883_dac_nids,
5947 .dig_out_nid = ALC883_DIGOUT_NID,
5948 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
5949 .adc_nids = alc883_adc_nids,
5950 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
5951 .channel_mode = alc883_3ST_6ch_modes,
5953 .input_mux = &alc883_capture_source,
5954 .unsol_event = alc883_tagra_unsol_event,
5955 .init_hook = alc883_tagra_automute,
5957 [ALC883_TARGA_2ch_DIG] = {
5958 .mixers = { alc883_tagra_2ch_mixer},
5959 .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
5960 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
5961 .dac_nids = alc883_dac_nids,
5962 .dig_out_nid = ALC883_DIGOUT_NID,
5963 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
5964 .adc_nids = alc883_adc_nids,
5965 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
5966 .channel_mode = alc883_3ST_2ch_modes,
5967 .input_mux = &alc883_capture_source,
5968 .unsol_event = alc883_tagra_unsol_event,
5969 .init_hook = alc883_tagra_automute,
5971 [ALC888_DEMO_BOARD] = {
5972 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
5973 .init_verbs = { alc883_init_verbs },
5974 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
5975 .dac_nids = alc883_dac_nids,
5976 .dig_out_nid = ALC883_DIGOUT_NID,
5977 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
5978 .adc_nids = alc883_adc_nids,
5979 .dig_in_nid = ALC883_DIGIN_NID,
5980 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
5981 .channel_mode = alc883_sixstack_modes,
5982 .input_mux = &alc883_capture_source,
5985 .mixers = { alc883_base_mixer,
5986 alc883_chmode_mixer },
5987 /* On TravelMate laptops, GPIO 0 enables the internal speaker
5988 * and the headphone jack. Turn this on and rely on the
5989 * standard mute methods whenever the user wants to turn
5990 * these outputs off.
5992 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs },
5993 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
5994 .dac_nids = alc883_dac_nids,
5995 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
5996 .adc_nids = alc883_adc_nids,
5997 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
5998 .channel_mode = alc883_3ST_2ch_modes,
5999 .input_mux = &alc883_capture_source,
6002 .mixers = { alc883_fivestack_mixer,
6003 alc883_chmode_mixer },
6004 .init_verbs = { alc883_init_verbs,
6005 alc883_medion_eapd_verbs },
6006 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6007 .dac_nids = alc883_dac_nids,
6008 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6009 .adc_nids = alc883_adc_nids,
6010 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
6011 .channel_mode = alc883_sixstack_modes,
6012 .input_mux = &alc883_capture_source,
6014 [ALC883_LAPTOP_EAPD] = {
6015 .mixers = { alc883_base_mixer,
6016 alc883_chmode_mixer },
6017 .init_verbs = { alc883_init_verbs, alc882_eapd_verbs },
6018 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6019 .dac_nids = alc883_dac_nids,
6020 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6021 .adc_nids = alc883_adc_nids,
6022 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
6023 .channel_mode = alc883_3ST_2ch_modes,
6024 .input_mux = &alc883_capture_source,
6026 [ALC883_LENOVO_101E_2ch] = {
6027 .mixers = { alc883_lenovo_101e_2ch_mixer},
6028 .init_verbs = { alc883_init_verbs, alc883_lenovo_101e_verbs},
6029 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6030 .dac_nids = alc883_dac_nids,
6031 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6032 .adc_nids = alc883_adc_nids,
6033 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
6034 .channel_mode = alc883_3ST_2ch_modes,
6035 .input_mux = &alc883_lenovo_101e_capture_source,
6036 .unsol_event = alc883_lenovo_101e_unsol_event,
6037 .init_hook = alc883_lenovo_101e_all_automute,
6043 * BIOS auto configuration
6045 static void alc883_auto_set_output_and_unmute(struct hda_codec *codec,
6046 hda_nid_t nid, int pin_type,
6050 struct alc_spec *spec = codec->spec;
6053 if (spec->multiout.dac_nids[dac_idx] == 0x25)
6056 idx = spec->multiout.dac_nids[dac_idx] - 2;
6058 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
6060 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
6062 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
6066 static void alc883_auto_init_multi_out(struct hda_codec *codec)
6068 struct alc_spec *spec = codec->spec;
6071 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
6072 for (i = 0; i <= HDA_SIDE; i++) {
6073 hda_nid_t nid = spec->autocfg.line_out_pins[i];
6075 alc883_auto_set_output_and_unmute(codec, nid, PIN_OUT, i);
6079 static void alc883_auto_init_hp_out(struct hda_codec *codec)
6081 struct alc_spec *spec = codec->spec;
6084 pin = spec->autocfg.hp_pins[0];
6085 if (pin) /* connect to front */
6087 alc883_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
6090 #define alc883_is_input_pin(nid) alc880_is_input_pin(nid)
6091 #define ALC883_PIN_CD_NID ALC880_PIN_CD_NID
6093 static void alc883_auto_init_analog_input(struct hda_codec *codec)
6095 struct alc_spec *spec = codec->spec;
6098 for (i = 0; i < AUTO_PIN_LAST; i++) {
6099 hda_nid_t nid = spec->autocfg.input_pins[i];
6100 if (alc883_is_input_pin(nid)) {
6101 snd_hda_codec_write(codec, nid, 0,
6102 AC_VERB_SET_PIN_WIDGET_CONTROL,
6103 (i <= AUTO_PIN_FRONT_MIC ?
6104 PIN_VREF80 : PIN_IN));
6105 if (nid != ALC883_PIN_CD_NID)
6106 snd_hda_codec_write(codec, nid, 0,
6107 AC_VERB_SET_AMP_GAIN_MUTE,
6113 /* almost identical with ALC880 parser... */
6114 static int alc883_parse_auto_config(struct hda_codec *codec)
6116 struct alc_spec *spec = codec->spec;
6117 int err = alc880_parse_auto_config(codec);
6122 /* hack - override the init verbs */
6123 spec->init_verbs[0] = alc883_auto_init_verbs;
6124 spec->mixers[spec->num_mixers] = alc883_capture_mixer;
6129 /* additional initialization for auto-configuration model */
6130 static void alc883_auto_init(struct hda_codec *codec)
6132 alc883_auto_init_multi_out(codec);
6133 alc883_auto_init_hp_out(codec);
6134 alc883_auto_init_analog_input(codec);
6137 static int patch_alc883(struct hda_codec *codec)
6139 struct alc_spec *spec;
6140 int err, board_config;
6142 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
6148 board_config = snd_hda_check_board_config(codec, ALC883_MODEL_LAST,
6151 if (board_config < 0) {
6152 printk(KERN_INFO "hda_codec: Unknown model for ALC883, "
6153 "trying auto-probe from BIOS...\n");
6154 board_config = ALC883_AUTO;
6157 if (board_config == ALC883_AUTO) {
6158 /* automatic parse from the BIOS config */
6159 err = alc883_parse_auto_config(codec);
6165 "hda_codec: Cannot set up configuration "
6166 "from BIOS. Using base mode...\n");
6167 board_config = ALC883_3ST_2ch_DIG;
6171 if (board_config != ALC883_AUTO)
6172 setup_preset(spec, &alc883_presets[board_config]);
6174 spec->stream_name_analog = "ALC883 Analog";
6175 spec->stream_analog_playback = &alc883_pcm_analog_playback;
6176 spec->stream_analog_capture = &alc883_pcm_analog_capture;
6178 spec->stream_name_digital = "ALC883 Digital";
6179 spec->stream_digital_playback = &alc883_pcm_digital_playback;
6180 spec->stream_digital_capture = &alc883_pcm_digital_capture;
6182 if (! spec->adc_nids && spec->input_mux) {
6183 spec->adc_nids = alc883_adc_nids;
6184 spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids);
6187 codec->patch_ops = alc_patch_ops;
6188 if (board_config == ALC883_AUTO)
6189 spec->init_hook = alc883_auto_init;
6198 #define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
6199 #define ALC262_DIGIN_NID ALC880_DIGIN_NID
6201 #define alc262_dac_nids alc260_dac_nids
6202 #define alc262_adc_nids alc882_adc_nids
6203 #define alc262_adc_nids_alt alc882_adc_nids_alt
6205 #define alc262_modes alc260_modes
6206 #define alc262_capture_source alc882_capture_source
6208 static struct snd_kcontrol_new alc262_base_mixer[] = {
6209 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6210 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6211 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6212 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6213 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6214 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6215 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6216 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6217 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6218 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
6219 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
6220 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
6221 /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
6222 HDA_CODEC_MUTE("PC Beelp Playback Switch", 0x0b, 0x05, HDA_INPUT), */
6223 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
6224 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
6225 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
6226 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
6230 static struct snd_kcontrol_new alc262_hippo1_mixer[] = {
6231 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6232 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6233 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6234 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6235 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6236 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6237 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6238 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6239 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6240 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
6241 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
6242 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
6243 /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
6244 HDA_CODEC_MUTE("PC Beelp Playback Switch", 0x0b, 0x05, HDA_INPUT), */
6245 /*HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),*/
6246 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6250 static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
6251 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6252 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
6253 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6254 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
6255 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
6257 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6258 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6259 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6260 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
6261 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
6262 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
6263 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6264 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6265 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6266 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6267 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
6268 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
6269 HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
6270 HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
6274 static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = {
6275 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6276 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6277 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
6278 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
6279 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
6280 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
6281 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x02, HDA_INPUT),
6282 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x02, HDA_INPUT),
6283 HDA_CODEC_VOLUME("Front Mic Boost", 0x1a, 0, HDA_INPUT),
6284 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
6285 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
6286 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6287 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6288 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
6289 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
6293 static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = {
6294 HDA_CODEC_VOLUME("Rear Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6295 HDA_CODEC_MUTE("Rear Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6296 HDA_CODEC_VOLUME("Rear Mic Boost", 0x18, 0, HDA_INPUT),
6300 #define alc262_capture_mixer alc882_capture_mixer
6301 #define alc262_capture_alt_mixer alc882_capture_alt_mixer
6304 * generic initialization of ADC, input mixers and output mixers
6306 static struct hda_verb alc262_init_verbs[] = {
6308 * Unmute ADC0-2 and set the default input to mic-in
6310 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
6311 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6312 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6313 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6314 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
6315 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6317 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
6319 * Note: PASD motherboards uses the Line In 2 as the input for front panel
6322 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
6323 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6324 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6325 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
6326 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
6327 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
6330 * Set up output mixers (0x0c - 0x0e)
6332 /* set vol=0 to output mixers */
6333 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6334 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6335 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6336 /* set up input amps for analog loopback */
6337 /* Amp Indices: DAC = 0, mixer = 1 */
6338 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6339 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6340 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6341 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6342 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6343 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6345 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
6346 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
6347 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
6348 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
6349 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
6350 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
6352 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
6353 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
6354 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
6355 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
6356 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
6358 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
6359 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
6361 /* FIXME: use matrix-type input source selection */
6362 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6363 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
6364 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6365 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
6366 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
6367 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
6369 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6370 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
6371 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
6372 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
6374 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6375 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
6376 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
6377 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
6382 static struct hda_verb alc262_hippo_unsol_verbs[] = {
6383 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
6384 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6388 static struct hda_verb alc262_hippo1_unsol_verbs[] = {
6389 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
6390 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
6391 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
6393 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
6394 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6398 /* mute/unmute internal speaker according to the hp jack and mute state */
6399 static void alc262_hippo_automute(struct hda_codec *codec, int force)
6401 struct alc_spec *spec = codec->spec;
6404 if (force || ! spec->sense_updated) {
6405 unsigned int present;
6406 /* need to execute and sync at first */
6407 snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
6408 present = snd_hda_codec_read(codec, 0x15, 0,
6409 AC_VERB_GET_PIN_SENSE, 0);
6410 spec->jack_present = (present & 0x80000000) != 0;
6411 spec->sense_updated = 1;
6413 if (spec->jack_present) {
6414 /* mute internal speaker */
6415 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
6417 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
6420 /* unmute internal speaker if necessary */
6421 mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0);
6422 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
6424 mute = snd_hda_codec_amp_read(codec, 0x15, 1, HDA_OUTPUT, 0);
6425 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
6430 /* unsolicited event for HP jack sensing */
6431 static void alc262_hippo_unsol_event(struct hda_codec *codec,
6434 if ((res >> 26) != ALC880_HP_EVENT)
6436 alc262_hippo_automute(codec, 1);
6439 static void alc262_hippo1_automute(struct hda_codec *codec, int force)
6441 struct alc_spec *spec = codec->spec;
6444 if (force || ! spec->sense_updated) {
6445 unsigned int present;
6446 /* need to execute and sync at first */
6447 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
6448 present = snd_hda_codec_read(codec, 0x1b, 0,
6449 AC_VERB_GET_PIN_SENSE, 0);
6450 spec->jack_present = (present & 0x80000000) != 0;
6451 spec->sense_updated = 1;
6453 if (spec->jack_present) {
6454 /* mute internal speaker */
6455 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
6457 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
6460 /* unmute internal speaker if necessary */
6461 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
6462 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
6464 mute = snd_hda_codec_amp_read(codec, 0x1b, 1, HDA_OUTPUT, 0);
6465 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
6470 /* unsolicited event for HP jack sensing */
6471 static void alc262_hippo1_unsol_event(struct hda_codec *codec,
6474 if ((res >> 26) != ALC880_HP_EVENT)
6476 alc262_hippo1_automute(codec, 1);
6481 * 0x14 = headphone/spdif-out, 0x15 = internal speaker
6484 #define ALC_HP_EVENT 0x37
6486 static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
6487 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
6488 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6492 static struct hda_input_mux alc262_fujitsu_capture_source = {
6500 static struct hda_input_mux alc262_HP_capture_source = {
6504 { "Front Mic", 0x3 },
6511 /* mute/unmute internal speaker according to the hp jack and mute state */
6512 static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
6514 struct alc_spec *spec = codec->spec;
6517 if (force || ! spec->sense_updated) {
6518 unsigned int present;
6519 /* need to execute and sync at first */
6520 snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
6521 present = snd_hda_codec_read(codec, 0x14, 0,
6522 AC_VERB_GET_PIN_SENSE, 0);
6523 spec->jack_present = (present & 0x80000000) != 0;
6524 spec->sense_updated = 1;
6526 if (spec->jack_present) {
6527 /* mute internal speaker */
6528 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
6530 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
6533 /* unmute internal speaker if necessary */
6534 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
6535 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
6537 mute = snd_hda_codec_amp_read(codec, 0x14, 1, HDA_OUTPUT, 0);
6538 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
6543 /* unsolicited event for HP jack sensing */
6544 static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
6547 if ((res >> 26) != ALC_HP_EVENT)
6549 alc262_fujitsu_automute(codec, 1);
6552 /* bind volumes of both NID 0x0c and 0x0d */
6553 static int alc262_fujitsu_master_vol_put(struct snd_kcontrol *kcontrol,
6554 struct snd_ctl_elem_value *ucontrol)
6556 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
6557 long *valp = ucontrol->value.integer.value;
6560 change = snd_hda_codec_amp_update(codec, 0x0c, 0, HDA_OUTPUT, 0,
6561 0x7f, valp[0] & 0x7f);
6562 change |= snd_hda_codec_amp_update(codec, 0x0c, 1, HDA_OUTPUT, 0,
6563 0x7f, valp[1] & 0x7f);
6564 snd_hda_codec_amp_update(codec, 0x0d, 0, HDA_OUTPUT, 0,
6565 0x7f, valp[0] & 0x7f);
6566 snd_hda_codec_amp_update(codec, 0x0d, 1, HDA_OUTPUT, 0,
6567 0x7f, valp[1] & 0x7f);
6571 /* bind hp and internal speaker mute (with plug check) */
6572 static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
6573 struct snd_ctl_elem_value *ucontrol)
6575 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
6576 long *valp = ucontrol->value.integer.value;
6579 change = snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
6580 0x80, valp[0] ? 0 : 0x80);
6581 change |= snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
6582 0x80, valp[1] ? 0 : 0x80);
6583 if (change || codec->in_resume)
6584 alc262_fujitsu_automute(codec, codec->in_resume);
6588 static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
6590 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6591 .name = "Master Playback Volume",
6592 .info = snd_hda_mixer_amp_volume_info,
6593 .get = snd_hda_mixer_amp_volume_get,
6594 .put = alc262_fujitsu_master_vol_put,
6595 .tlv = { .c = snd_hda_mixer_amp_tlv },
6596 .private_value = HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
6599 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6600 .name = "Master Playback Switch",
6601 .info = snd_hda_mixer_amp_switch_info,
6602 .get = snd_hda_mixer_amp_switch_get,
6603 .put = alc262_fujitsu_master_sw_put,
6604 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
6606 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6607 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6608 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6609 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6610 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6614 /* additional init verbs for Benq laptops */
6615 static struct hda_verb alc262_EAPD_verbs[] = {
6616 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
6617 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
6621 /* add playback controls from the parsed DAC table */
6622 static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec, const struct auto_pin_cfg *cfg)
6627 spec->multiout.num_dacs = 1; /* only use one dac */
6628 spec->multiout.dac_nids = spec->private_dac_nids;
6629 spec->multiout.dac_nids[0] = 2;
6631 nid = cfg->line_out_pins[0];
6633 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Front Playback Volume",
6634 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT))) < 0)
6636 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Front Playback Switch",
6637 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
6641 nid = cfg->speaker_pins[0];
6644 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Speaker Playback Volume",
6645 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, HDA_OUTPUT))) < 0)
6647 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Speaker Playback Switch",
6648 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0)
6651 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Speaker Playback Switch",
6652 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
6656 nid = cfg->hp_pins[0];
6658 /* spec->multiout.hp_nid = 2; */
6660 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Headphone Playback Volume",
6661 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, HDA_OUTPUT))) < 0)
6663 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Headphone Playback Switch",
6664 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0)
6667 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Headphone Playback Switch",
6668 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
6675 /* identical with ALC880 */
6676 #define alc262_auto_create_analog_input_ctls alc880_auto_create_analog_input_ctls
6679 * generic initialization of ADC, input mixers and output mixers
6681 static struct hda_verb alc262_volume_init_verbs[] = {
6683 * Unmute ADC0-2 and set the default input to mic-in
6685 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
6686 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6687 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6688 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6689 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
6690 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6692 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
6694 * Note: PASD motherboards uses the Line In 2 as the input for front panel
6697 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
6698 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6699 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6700 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
6701 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
6702 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
6705 * Set up output mixers (0x0c - 0x0f)
6707 /* set vol=0 to output mixers */
6708 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6709 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6710 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6712 /* set up input amps for analog loopback */
6713 /* Amp Indices: DAC = 0, mixer = 1 */
6714 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6715 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6716 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6717 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6718 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6719 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6721 /* FIXME: use matrix-type input source selection */
6722 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6723 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
6724 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6725 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
6726 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
6727 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
6729 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6730 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
6731 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
6732 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
6734 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6735 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
6736 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
6737 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
6742 static struct hda_verb alc262_HP_BPC_init_verbs[] = {
6744 * Unmute ADC0-2 and set the default input to mic-in
6746 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
6747 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6748 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6749 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6750 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
6751 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6753 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
6755 * Note: PASD motherboards uses the Line In 2 as the input for front panel
6758 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
6759 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6760 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6761 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
6762 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
6763 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
6764 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
6765 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(6)},
6768 * Set up output mixers (0x0c - 0x0e)
6770 /* set vol=0 to output mixers */
6771 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6772 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6773 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6775 /* set up input amps for analog loopback */
6776 /* Amp Indices: DAC = 0, mixer = 1 */
6777 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6778 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6779 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6780 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6781 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6782 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6784 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
6785 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6786 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6788 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6789 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6791 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
6792 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
6794 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
6795 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
6796 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
6797 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
6798 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
6800 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
6801 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
6802 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
6803 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
6804 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
6805 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
6808 /* FIXME: use matrix-type input source selection */
6809 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6810 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
6811 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6812 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
6813 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
6814 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
6816 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6817 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
6818 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
6819 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
6821 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6822 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
6823 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
6824 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
6829 static struct hda_verb alc262_HP_BPC_WildWest_init_verbs[] = {
6831 * Unmute ADC0-2 and set the default input to mic-in
6833 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
6834 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6835 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6836 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6837 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
6838 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6840 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
6842 * Note: PASD motherboards uses the Line In 2 as the input for front
6845 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
6846 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6847 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6848 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
6849 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
6850 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
6851 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
6852 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(6)},
6853 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(7)},
6855 * Set up output mixers (0x0c - 0x0e)
6857 /* set vol=0 to output mixers */
6858 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6859 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6860 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6862 /* set up input amps for analog loopback */
6863 /* Amp Indices: DAC = 0, mixer = 1 */
6864 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6865 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6866 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6867 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6868 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6869 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6872 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP */
6873 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Mono */
6874 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* rear MIC */
6875 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* Line in */
6876 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
6877 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Line out */
6878 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD in */
6880 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6881 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6883 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
6884 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
6886 /* {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, */
6887 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
6888 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
6889 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
6890 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
6891 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
6893 /* FIXME: use matrix-type input source selection */
6894 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6895 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
6896 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, /*rear MIC*/
6897 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, /*Line in*/
6898 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, /*F MIC*/
6899 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, /*Front*/
6900 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, /*CD*/
6901 /* {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
6902 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, /*HP*/
6904 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6905 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
6906 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
6907 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
6908 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
6909 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
6910 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
6912 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6913 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
6914 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
6915 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
6916 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
6917 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
6918 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
6923 /* pcm configuration: identiacal with ALC880 */
6924 #define alc262_pcm_analog_playback alc880_pcm_analog_playback
6925 #define alc262_pcm_analog_capture alc880_pcm_analog_capture
6926 #define alc262_pcm_digital_playback alc880_pcm_digital_playback
6927 #define alc262_pcm_digital_capture alc880_pcm_digital_capture
6930 * BIOS auto configuration
6932 static int alc262_parse_auto_config(struct hda_codec *codec)
6934 struct alc_spec *spec = codec->spec;
6936 static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
6938 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
6939 alc262_ignore)) < 0)
6941 if (! spec->autocfg.line_outs)
6942 return 0; /* can't find valid BIOS pin config */
6943 if ((err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 ||
6944 (err = alc262_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0)
6947 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
6949 if (spec->autocfg.dig_out_pin)
6950 spec->multiout.dig_out_nid = ALC262_DIGOUT_NID;
6951 if (spec->autocfg.dig_in_pin)
6952 spec->dig_in_nid = ALC262_DIGIN_NID;
6954 if (spec->kctl_alloc)
6955 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
6957 spec->init_verbs[spec->num_init_verbs++] = alc262_volume_init_verbs;
6958 spec->num_mux_defs = 1;
6959 spec->input_mux = &spec->private_imux;
6964 #define alc262_auto_init_multi_out alc882_auto_init_multi_out
6965 #define alc262_auto_init_hp_out alc882_auto_init_hp_out
6966 #define alc262_auto_init_analog_input alc882_auto_init_analog_input
6969 /* init callback for auto-configuration model -- overriding the default init */
6970 static void alc262_auto_init(struct hda_codec *codec)
6972 alc262_auto_init_multi_out(codec);
6973 alc262_auto_init_hp_out(codec);
6974 alc262_auto_init_analog_input(codec);
6978 * configuration and preset
6980 static const char *alc262_models[ALC262_MODEL_LAST] = {
6981 [ALC262_BASIC] = "basic",
6982 [ALC262_HIPPO] = "hippo",
6983 [ALC262_HIPPO_1] = "hippo_1",
6984 [ALC262_FUJITSU] = "fujitsu",
6985 [ALC262_HP_BPC] = "hp-bpc",
6986 [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000",
6987 [ALC262_BENQ_ED8] = "benq",
6988 [ALC262_AUTO] = "auto",
6991 static struct snd_pci_quirk alc262_cfg_tbl[] = {
6992 SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO),
6993 SND_PCI_QUIRK(0x103c, 0x12fe, "HP xw9400", ALC262_HP_BPC),
6994 SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC),
6995 SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC),
6996 SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC),
6997 SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL),
6998 SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL),
6999 SND_PCI_QUIRK(0x103c, 0x2804, "HP D7000", ALC262_HP_BPC_D7000_WL),
7000 SND_PCI_QUIRK(0x103c, 0x2806, "HP D7000", ALC262_HP_BPC_D7000_WL),
7001 SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF),
7002 SND_PCI_QUIRK(0x103c, 0x2803, "HP D7000", ALC262_HP_BPC_D7000_WF),
7003 SND_PCI_QUIRK(0x103c, 0x2805, "HP D7000", ALC262_HP_BPC_D7000_WF),
7004 SND_PCI_QUIRK(0x103c, 0x2807, "HP D7000", ALC262_HP_BPC_D7000_WF),
7005 SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO),
7006 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
7007 SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1),
7008 SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
7012 static struct alc_config_preset alc262_presets[] = {
7014 .mixers = { alc262_base_mixer },
7015 .init_verbs = { alc262_init_verbs },
7016 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
7017 .dac_nids = alc262_dac_nids,
7019 .num_channel_mode = ARRAY_SIZE(alc262_modes),
7020 .channel_mode = alc262_modes,
7021 .input_mux = &alc262_capture_source,
7024 .mixers = { alc262_base_mixer },
7025 .init_verbs = { alc262_init_verbs, alc262_hippo_unsol_verbs},
7026 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
7027 .dac_nids = alc262_dac_nids,
7029 .dig_out_nid = ALC262_DIGOUT_NID,
7030 .num_channel_mode = ARRAY_SIZE(alc262_modes),
7031 .channel_mode = alc262_modes,
7032 .input_mux = &alc262_capture_source,
7033 .unsol_event = alc262_hippo_unsol_event,
7035 [ALC262_HIPPO_1] = {
7036 .mixers = { alc262_hippo1_mixer },
7037 .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs},
7038 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
7039 .dac_nids = alc262_dac_nids,
7041 .dig_out_nid = ALC262_DIGOUT_NID,
7042 .num_channel_mode = ARRAY_SIZE(alc262_modes),
7043 .channel_mode = alc262_modes,
7044 .input_mux = &alc262_capture_source,
7045 .unsol_event = alc262_hippo1_unsol_event,
7047 [ALC262_FUJITSU] = {
7048 .mixers = { alc262_fujitsu_mixer },
7049 .init_verbs = { alc262_init_verbs, alc262_fujitsu_unsol_verbs },
7050 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
7051 .dac_nids = alc262_dac_nids,
7053 .dig_out_nid = ALC262_DIGOUT_NID,
7054 .num_channel_mode = ARRAY_SIZE(alc262_modes),
7055 .channel_mode = alc262_modes,
7056 .input_mux = &alc262_fujitsu_capture_source,
7057 .unsol_event = alc262_fujitsu_unsol_event,
7060 .mixers = { alc262_HP_BPC_mixer },
7061 .init_verbs = { alc262_HP_BPC_init_verbs },
7062 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
7063 .dac_nids = alc262_dac_nids,
7065 .num_channel_mode = ARRAY_SIZE(alc262_modes),
7066 .channel_mode = alc262_modes,
7067 .input_mux = &alc262_HP_capture_source,
7069 [ALC262_HP_BPC_D7000_WF] = {
7070 .mixers = { alc262_HP_BPC_WildWest_mixer },
7071 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
7072 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
7073 .dac_nids = alc262_dac_nids,
7075 .num_channel_mode = ARRAY_SIZE(alc262_modes),
7076 .channel_mode = alc262_modes,
7077 .input_mux = &alc262_HP_capture_source,
7079 [ALC262_HP_BPC_D7000_WL] = {
7080 .mixers = { alc262_HP_BPC_WildWest_mixer,
7081 alc262_HP_BPC_WildWest_option_mixer },
7082 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
7083 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
7084 .dac_nids = alc262_dac_nids,
7086 .num_channel_mode = ARRAY_SIZE(alc262_modes),
7087 .channel_mode = alc262_modes,
7088 .input_mux = &alc262_HP_capture_source,
7090 [ALC262_BENQ_ED8] = {
7091 .mixers = { alc262_base_mixer },
7092 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
7093 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
7094 .dac_nids = alc262_dac_nids,
7096 .num_channel_mode = ARRAY_SIZE(alc262_modes),
7097 .channel_mode = alc262_modes,
7098 .input_mux = &alc262_capture_source,
7102 static int patch_alc262(struct hda_codec *codec)
7104 struct alc_spec *spec;
7108 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
7114 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is under-run */
7117 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
7118 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
7119 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
7120 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
7124 board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST,
7128 if (board_config < 0) {
7129 printk(KERN_INFO "hda_codec: Unknown model for ALC262, "
7130 "trying auto-probe from BIOS...\n");
7131 board_config = ALC262_AUTO;
7134 if (board_config == ALC262_AUTO) {
7135 /* automatic parse from the BIOS config */
7136 err = alc262_parse_auto_config(codec);
7142 "hda_codec: Cannot set up configuration "
7143 "from BIOS. Using base mode...\n");
7144 board_config = ALC262_BASIC;
7148 if (board_config != ALC262_AUTO)
7149 setup_preset(spec, &alc262_presets[board_config]);
7151 spec->stream_name_analog = "ALC262 Analog";
7152 spec->stream_analog_playback = &alc262_pcm_analog_playback;
7153 spec->stream_analog_capture = &alc262_pcm_analog_capture;
7155 spec->stream_name_digital = "ALC262 Digital";
7156 spec->stream_digital_playback = &alc262_pcm_digital_playback;
7157 spec->stream_digital_capture = &alc262_pcm_digital_capture;
7159 if (! spec->adc_nids && spec->input_mux) {
7160 /* check whether NID 0x07 is valid */
7161 unsigned int wcap = get_wcaps(codec, 0x07);
7163 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
7164 if (wcap != AC_WID_AUD_IN) {
7165 spec->adc_nids = alc262_adc_nids_alt;
7166 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids_alt);
7167 spec->mixers[spec->num_mixers] = alc262_capture_alt_mixer;
7170 spec->adc_nids = alc262_adc_nids;
7171 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids);
7172 spec->mixers[spec->num_mixers] = alc262_capture_mixer;
7177 codec->patch_ops = alc_patch_ops;
7178 if (board_config == ALC262_AUTO)
7179 spec->init_hook = alc262_auto_init;
7185 * ALC861 channel source setting (2/6 channel selection for 3-stack)
7189 * set the path ways for 2 channel output
7190 * need to set the codec line out and mic 1 pin widgets to inputs
7192 static struct hda_verb alc861_threestack_ch2_init[] = {
7193 /* set pin widget 1Ah (line in) for input */
7194 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
7195 /* set pin widget 18h (mic1/2) for input, for mic also enable the vref */
7196 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
7198 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
7200 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
7201 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
7207 * need to set the codec line out and mic 1 pin widgets to outputs
7209 static struct hda_verb alc861_threestack_ch6_init[] = {
7210 /* set pin widget 1Ah (line in) for output (Back Surround)*/
7211 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
7212 /* set pin widget 18h (mic1) for output (CLFE)*/
7213 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
7215 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
7216 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
7218 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
7220 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
7221 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
7226 static struct hda_channel_mode alc861_threestack_modes[2] = {
7227 { 2, alc861_threestack_ch2_init },
7228 { 6, alc861_threestack_ch6_init },
7230 /* Set mic1 as input and unmute the mixer */
7231 static struct hda_verb alc861_uniwill_m31_ch2_init[] = {
7232 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
7233 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
7236 /* Set mic1 as output and mute mixer */
7237 static struct hda_verb alc861_uniwill_m31_ch4_init[] = {
7238 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
7239 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
7243 static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
7244 { 2, alc861_uniwill_m31_ch2_init },
7245 { 4, alc861_uniwill_m31_ch4_init },
7248 /* Set mic1 and line-in as input and unmute the mixer */
7249 static struct hda_verb alc861_asus_ch2_init[] = {
7250 /* set pin widget 1Ah (line in) for input */
7251 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
7252 /* set pin widget 18h (mic1/2) for input, for mic also enable the vref */
7253 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
7255 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
7257 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
7258 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
7262 /* Set mic1 nad line-in as output and mute mixer */
7263 static struct hda_verb alc861_asus_ch6_init[] = {
7264 /* set pin widget 1Ah (line in) for output (Back Surround)*/
7265 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
7266 /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
7267 /* set pin widget 18h (mic1) for output (CLFE)*/
7268 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
7269 /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
7270 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
7271 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
7273 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
7275 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
7276 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
7281 static struct hda_channel_mode alc861_asus_modes[2] = {
7282 { 2, alc861_asus_ch2_init },
7283 { 6, alc861_asus_ch6_init },
7288 static struct snd_kcontrol_new alc861_base_mixer[] = {
7289 /* output mixer control */
7290 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
7291 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
7292 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
7293 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
7294 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
7296 /*Input mixer control */
7297 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
7298 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
7299 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
7300 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
7301 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
7302 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
7303 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
7304 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
7305 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
7306 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
7308 /* Capture mixer control */
7309 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7310 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7312 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7313 .name = "Capture Source",
7315 .info = alc_mux_enum_info,
7316 .get = alc_mux_enum_get,
7317 .put = alc_mux_enum_put,
7322 static struct snd_kcontrol_new alc861_3ST_mixer[] = {
7323 /* output mixer control */
7324 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
7325 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
7326 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
7327 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
7328 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
7330 /* Input mixer control */
7331 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
7332 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
7333 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
7334 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
7335 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
7336 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
7337 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
7338 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
7339 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
7340 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
7342 /* Capture mixer control */
7343 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7344 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7346 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7347 .name = "Capture Source",
7349 .info = alc_mux_enum_info,
7350 .get = alc_mux_enum_get,
7351 .put = alc_mux_enum_put,
7354 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7355 .name = "Channel Mode",
7356 .info = alc_ch_mode_info,
7357 .get = alc_ch_mode_get,
7358 .put = alc_ch_mode_put,
7359 .private_value = ARRAY_SIZE(alc861_threestack_modes),
7364 static struct snd_kcontrol_new alc861_toshiba_mixer[] = {
7365 /* output mixer control */
7366 HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT),
7367 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
7368 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
7370 /*Capture mixer control */
7371 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7372 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7374 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7375 .name = "Capture Source",
7377 .info = alc_mux_enum_info,
7378 .get = alc_mux_enum_get,
7379 .put = alc_mux_enum_put,
7385 static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
7386 /* output mixer control */
7387 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
7388 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
7389 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
7390 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
7391 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
7393 /* Input mixer control */
7394 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
7395 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
7396 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
7397 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
7398 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
7399 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
7400 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
7401 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
7402 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
7403 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
7405 /* Capture mixer control */
7406 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7407 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7409 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7410 .name = "Capture Source",
7412 .info = alc_mux_enum_info,
7413 .get = alc_mux_enum_get,
7414 .put = alc_mux_enum_put,
7417 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7418 .name = "Channel Mode",
7419 .info = alc_ch_mode_info,
7420 .get = alc_ch_mode_get,
7421 .put = alc_ch_mode_put,
7422 .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
7427 static struct snd_kcontrol_new alc861_asus_mixer[] = {
7428 /* output mixer control */
7429 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
7430 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
7431 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
7432 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
7433 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
7435 /* Input mixer control */
7436 HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
7437 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7438 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
7439 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
7440 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
7441 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
7442 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
7443 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
7444 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
7445 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT), /* was HDA_INPUT (why?) */
7447 /* Capture mixer control */
7448 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7449 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7451 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7452 .name = "Capture Source",
7454 .info = alc_mux_enum_info,
7455 .get = alc_mux_enum_get,
7456 .put = alc_mux_enum_put,
7459 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7460 .name = "Channel Mode",
7461 .info = alc_ch_mode_info,
7462 .get = alc_ch_mode_get,
7463 .put = alc_ch_mode_put,
7464 .private_value = ARRAY_SIZE(alc861_asus_modes),
7469 /* additional mixer */
7470 static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = {
7471 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
7472 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
7473 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x23, 0x0, HDA_OUTPUT),
7474 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x23, 0x0, HDA_OUTPUT),
7479 * generic initialization of ADC, input mixers and output mixers
7481 static struct hda_verb alc861_base_init_verbs[] = {
7483 * Unmute ADC0 and set the default input to mic-in
7485 /* port-A for surround (rear panel) */
7486 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
7487 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
7488 /* port-B for mic-in (rear panel) with vref */
7489 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
7490 /* port-C for line-in (rear panel) */
7491 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
7492 /* port-D for Front */
7493 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
7494 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
7495 /* port-E for HP out (front panel) */
7496 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
7497 /* route front PCM to HP */
7498 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
7499 /* port-F for mic-in (front panel) with vref */
7500 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
7501 /* port-G for CLFE (rear panel) */
7502 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
7503 { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
7504 /* port-H for side (rear panel) */
7505 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
7506 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
7508 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
7509 /* route front mic to ADC1*/
7510 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7511 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7513 /* Unmute DAC0~3 & spdif out*/
7514 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7515 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7516 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7517 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7518 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7520 /* Unmute Mixer 14 (mic) 1c (Line in)*/
7521 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7522 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7523 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7524 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7526 /* Unmute Stereo Mixer 15 */
7527 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7528 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7529 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7530 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c }, //Output 0~12 step
7532 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7533 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7534 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7535 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7536 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7537 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7538 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7539 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7540 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, // hp used DAC 3 (Front)
7541 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7546 static struct hda_verb alc861_threestack_init_verbs[] = {
7548 * Unmute ADC0 and set the default input to mic-in
7550 /* port-A for surround (rear panel) */
7551 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
7552 /* port-B for mic-in (rear panel) with vref */
7553 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
7554 /* port-C for line-in (rear panel) */
7555 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
7556 /* port-D for Front */
7557 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
7558 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
7559 /* port-E for HP out (front panel) */
7560 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
7561 /* route front PCM to HP */
7562 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
7563 /* port-F for mic-in (front panel) with vref */
7564 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
7565 /* port-G for CLFE (rear panel) */
7566 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
7567 /* port-H for side (rear panel) */
7568 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
7570 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
7571 /* route front mic to ADC1*/
7572 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7573 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7574 /* Unmute DAC0~3 & spdif out*/
7575 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7576 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7577 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7578 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7579 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7581 /* Unmute Mixer 14 (mic) 1c (Line in)*/
7582 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7583 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7584 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7585 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7587 /* Unmute Stereo Mixer 15 */
7588 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7589 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7590 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7591 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c }, //Output 0~12 step
7593 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7594 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7595 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7596 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7597 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7598 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7599 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7600 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7601 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, // hp used DAC 3 (Front)
7602 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7606 static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
7608 * Unmute ADC0 and set the default input to mic-in
7610 /* port-A for surround (rear panel) */
7611 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
7612 /* port-B for mic-in (rear panel) with vref */
7613 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
7614 /* port-C for line-in (rear panel) */
7615 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
7616 /* port-D for Front */
7617 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
7618 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
7619 /* port-E for HP out (front panel) */
7620 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, // this has to be set to VREF80
7621 /* route front PCM to HP */
7622 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
7623 /* port-F for mic-in (front panel) with vref */
7624 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
7625 /* port-G for CLFE (rear panel) */
7626 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
7627 /* port-H for side (rear panel) */
7628 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
7630 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
7631 /* route front mic to ADC1*/
7632 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7633 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7634 /* Unmute DAC0~3 & spdif out*/
7635 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7636 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7637 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7638 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7639 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7641 /* Unmute Mixer 14 (mic) 1c (Line in)*/
7642 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7643 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7644 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7645 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7647 /* Unmute Stereo Mixer 15 */
7648 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7649 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7650 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7651 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c }, //Output 0~12 step
7653 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7654 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7655 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7656 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7657 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7658 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7659 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7660 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7661 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, // hp used DAC 3 (Front)
7662 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7666 static struct hda_verb alc861_asus_init_verbs[] = {
7668 * Unmute ADC0 and set the default input to mic-in
7670 /* port-A for surround (rear panel) | according to codec#0 this is the HP jack*/
7671 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */
7672 /* route front PCM to HP */
7673 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 },
7674 /* port-B for mic-in (rear panel) with vref */
7675 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
7676 /* port-C for line-in (rear panel) */
7677 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
7678 /* port-D for Front */
7679 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
7680 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
7681 /* port-E for HP out (front panel) */
7682 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, /* this has to be set to VREF80 */
7683 /* route front PCM to HP */
7684 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
7685 /* port-F for mic-in (front panel) with vref */
7686 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
7687 /* port-G for CLFE (rear panel) */
7688 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
7689 /* port-H for side (rear panel) */
7690 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
7692 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
7693 /* route front mic to ADC1*/
7694 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7695 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7696 /* Unmute DAC0~3 & spdif out*/
7697 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7698 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7699 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7700 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7701 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7702 /* Unmute Mixer 14 (mic) 1c (Line in)*/
7703 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7704 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7705 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7706 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7708 /* Unmute Stereo Mixer 15 */
7709 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7710 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7711 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7712 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c }, /* Output 0~12 step */
7714 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7715 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7716 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7717 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7718 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7719 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7720 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7721 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7722 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, /* hp used DAC 3 (Front) */
7723 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7727 /* additional init verbs for ASUS laptops */
7728 static struct hda_verb alc861_asus_laptop_init_verbs[] = {
7729 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */
7730 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */
7735 * generic initialization of ADC, input mixers and output mixers
7737 static struct hda_verb alc861_auto_init_verbs[] = {
7739 * Unmute ADC0 and set the default input to mic-in
7741 // {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7742 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7744 /* Unmute DAC0~3 & spdif out*/
7745 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7746 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7747 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7748 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7749 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7751 /* Unmute Mixer 14 (mic) 1c (Line in)*/
7752 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7753 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7754 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7755 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7757 /* Unmute Stereo Mixer 15 */
7758 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7759 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7760 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7761 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
7763 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7764 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7765 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7766 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7767 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7768 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7769 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7770 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7772 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7773 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7774 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7775 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
7776 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7777 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7778 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7779 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
7781 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, // set Mic 1
7786 static struct hda_verb alc861_toshiba_init_verbs[] = {
7787 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
7792 /* toggle speaker-output according to the hp-jack state */
7793 static void alc861_toshiba_automute(struct hda_codec *codec)
7795 unsigned int present;
7797 present = snd_hda_codec_read(codec, 0x0f, 0,
7798 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7799 snd_hda_codec_amp_update(codec, 0x16, 0, HDA_INPUT, 0,
7800 0x80, present ? 0x80 : 0);
7801 snd_hda_codec_amp_update(codec, 0x16, 1, HDA_INPUT, 0,
7802 0x80, present ? 0x80 : 0);
7803 snd_hda_codec_amp_update(codec, 0x1a, 0, HDA_INPUT, 3,
7804 0x80, present ? 0 : 0x80);
7805 snd_hda_codec_amp_update(codec, 0x1a, 1, HDA_INPUT, 3,
7806 0x80, present ? 0 : 0x80);
7809 static void alc861_toshiba_unsol_event(struct hda_codec *codec,
7812 if ((res >> 26) == ALC880_HP_EVENT)
7813 alc861_toshiba_automute(codec);
7816 /* pcm configuration: identiacal with ALC880 */
7817 #define alc861_pcm_analog_playback alc880_pcm_analog_playback
7818 #define alc861_pcm_analog_capture alc880_pcm_analog_capture
7819 #define alc861_pcm_digital_playback alc880_pcm_digital_playback
7820 #define alc861_pcm_digital_capture alc880_pcm_digital_capture
7823 #define ALC861_DIGOUT_NID 0x07
7825 static struct hda_channel_mode alc861_8ch_modes[1] = {
7829 static hda_nid_t alc861_dac_nids[4] = {
7830 /* front, surround, clfe, side */
7831 0x03, 0x06, 0x05, 0x04
7834 static hda_nid_t alc660_dac_nids[3] = {
7835 /* front, clfe, surround */
7839 static hda_nid_t alc861_adc_nids[1] = {
7844 static struct hda_input_mux alc861_capture_source = {
7848 { "Front Mic", 0x3 },
7855 /* fill in the dac_nids table from the parsed pin configuration */
7856 static int alc861_auto_fill_dac_nids(struct alc_spec *spec, const struct auto_pin_cfg *cfg)
7861 spec->multiout.dac_nids = spec->private_dac_nids;
7862 for (i = 0; i < cfg->line_outs; i++) {
7863 nid = cfg->line_out_pins[i];
7865 if (i >= ARRAY_SIZE(alc861_dac_nids))
7867 spec->multiout.dac_nids[i] = alc861_dac_nids[i];
7870 spec->multiout.num_dacs = cfg->line_outs;
7874 /* add playback controls from the parsed DAC table */
7875 static int alc861_auto_create_multi_out_ctls(struct alc_spec *spec,
7876 const struct auto_pin_cfg *cfg)
7879 static const char *chname[4] = { "Front", "Surround", NULL /*CLFE*/, "Side" };
7883 for (i = 0; i < cfg->line_outs; i++) {
7884 nid = spec->multiout.dac_nids[i];
7889 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "Center Playback Switch",
7890 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT))) < 0)
7892 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "LFE Playback Switch",
7893 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0)
7896 for (idx = 0; idx < ARRAY_SIZE(alc861_dac_nids) - 1; idx++)
7897 if (nid == alc861_dac_nids[idx])
7899 sprintf(name, "%s Playback Switch", chname[idx]);
7900 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, name,
7901 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
7908 static int alc861_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin)
7916 if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
7918 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Headphone Playback Switch",
7919 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
7921 spec->multiout.hp_nid = nid;
7926 /* create playback/capture controls for input pins */
7927 static int alc861_auto_create_analog_input_ctls(struct alc_spec *spec, const struct auto_pin_cfg *cfg)
7929 struct hda_input_mux *imux = &spec->private_imux;
7930 int i, err, idx, idx1;
7932 for (i = 0; i < AUTO_PIN_LAST; i++) {
7933 switch(cfg->input_pins[i]) {
7958 err = new_analog_input(spec, cfg->input_pins[i],
7959 auto_pin_cfg_labels[i], idx, 0x15);
7963 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
7964 imux->items[imux->num_items].index = idx1;
7970 static struct snd_kcontrol_new alc861_capture_mixer[] = {
7971 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7972 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7975 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7976 /* The multiple "Capture Source" controls confuse alsamixer
7977 * So call somewhat different..
7978 *FIXME: the controls appear in the "playback" view!
7980 /* .name = "Capture Source", */
7981 .name = "Input Source",
7983 .info = alc_mux_enum_info,
7984 .get = alc_mux_enum_get,
7985 .put = alc_mux_enum_put,
7990 static void alc861_auto_set_output_and_unmute(struct hda_codec *codec, hda_nid_t nid,
7991 int pin_type, int dac_idx)
7995 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
7996 snd_hda_codec_write(codec, dac_idx, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
8000 static void alc861_auto_init_multi_out(struct hda_codec *codec)
8002 struct alc_spec *spec = codec->spec;
8005 alc_subsystem_id(codec, 0x0e, 0x0f, 0x0b);
8006 for (i = 0; i < spec->autocfg.line_outs; i++) {
8007 hda_nid_t nid = spec->autocfg.line_out_pins[i];
8009 alc861_auto_set_output_and_unmute(codec, nid, PIN_OUT, spec->multiout.dac_nids[i]);
8013 static void alc861_auto_init_hp_out(struct hda_codec *codec)
8015 struct alc_spec *spec = codec->spec;
8018 pin = spec->autocfg.hp_pins[0];
8019 if (pin) /* connect to front */
8020 alc861_auto_set_output_and_unmute(codec, pin, PIN_HP, spec->multiout.dac_nids[0]);
8023 static void alc861_auto_init_analog_input(struct hda_codec *codec)
8025 struct alc_spec *spec = codec->spec;
8028 for (i = 0; i < AUTO_PIN_LAST; i++) {
8029 hda_nid_t nid = spec->autocfg.input_pins[i];
8030 if ((nid>=0x0c) && (nid <=0x11)) {
8031 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
8032 i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN);
8037 /* parse the BIOS configuration and set up the alc_spec */
8038 /* return 1 if successful, 0 if the proper config is not found, or a negative error code */
8039 static int alc861_parse_auto_config(struct hda_codec *codec)
8041 struct alc_spec *spec = codec->spec;
8043 static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
8045 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
8046 alc861_ignore)) < 0)
8048 if (! spec->autocfg.line_outs)
8049 return 0; /* can't find valid BIOS pin config */
8051 if ((err = alc861_auto_fill_dac_nids(spec, &spec->autocfg)) < 0 ||
8052 (err = alc861_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 ||
8053 (err = alc861_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0])) < 0 ||
8054 (err = alc861_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0)
8057 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
8059 if (spec->autocfg.dig_out_pin)
8060 spec->multiout.dig_out_nid = ALC861_DIGOUT_NID;
8062 if (spec->kctl_alloc)
8063 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
8065 spec->init_verbs[spec->num_init_verbs++] = alc861_auto_init_verbs;
8067 spec->num_mux_defs = 1;
8068 spec->input_mux = &spec->private_imux;
8070 spec->adc_nids = alc861_adc_nids;
8071 spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
8072 spec->mixers[spec->num_mixers] = alc861_capture_mixer;
8078 /* additional initialization for auto-configuration model */
8079 static void alc861_auto_init(struct hda_codec *codec)
8081 alc861_auto_init_multi_out(codec);
8082 alc861_auto_init_hp_out(codec);
8083 alc861_auto_init_analog_input(codec);
8088 * configuration and preset
8090 static const char *alc861_models[ALC861_MODEL_LAST] = {
8091 [ALC861_3ST] = "3stack",
8092 [ALC660_3ST] = "3stack-660",
8093 [ALC861_3ST_DIG] = "3stack-dig",
8094 [ALC861_6ST_DIG] = "6stack-dig",
8095 [ALC861_UNIWILL_M31] = "uniwill-m31",
8096 [ALC861_TOSHIBA] = "toshiba",
8097 [ALC861_ASUS] = "asus",
8098 [ALC861_ASUS_LAPTOP] = "asus-laptop",
8099 [ALC861_AUTO] = "auto",
8102 static struct snd_pci_quirk alc861_cfg_tbl[] = {
8103 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST),
8104 SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP),
8105 SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP),
8106 SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS),
8107 SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660_3ST),
8108 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA),
8109 SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA),
8110 SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31),
8111 SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31),
8112 SND_PCI_QUIRK(0x1849, 0x0660, "Asrock 939SLI32", ALC660_3ST),
8113 SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST),
8117 static struct alc_config_preset alc861_presets[] = {
8119 .mixers = { alc861_3ST_mixer },
8120 .init_verbs = { alc861_threestack_init_verbs },
8121 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
8122 .dac_nids = alc861_dac_nids,
8123 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
8124 .channel_mode = alc861_threestack_modes,
8126 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
8127 .adc_nids = alc861_adc_nids,
8128 .input_mux = &alc861_capture_source,
8130 [ALC861_3ST_DIG] = {
8131 .mixers = { alc861_base_mixer },
8132 .init_verbs = { alc861_threestack_init_verbs },
8133 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
8134 .dac_nids = alc861_dac_nids,
8135 .dig_out_nid = ALC861_DIGOUT_NID,
8136 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
8137 .channel_mode = alc861_threestack_modes,
8139 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
8140 .adc_nids = alc861_adc_nids,
8141 .input_mux = &alc861_capture_source,
8143 [ALC861_6ST_DIG] = {
8144 .mixers = { alc861_base_mixer },
8145 .init_verbs = { alc861_base_init_verbs },
8146 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
8147 .dac_nids = alc861_dac_nids,
8148 .dig_out_nid = ALC861_DIGOUT_NID,
8149 .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
8150 .channel_mode = alc861_8ch_modes,
8151 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
8152 .adc_nids = alc861_adc_nids,
8153 .input_mux = &alc861_capture_source,
8156 .mixers = { alc861_3ST_mixer },
8157 .init_verbs = { alc861_threestack_init_verbs },
8158 .num_dacs = ARRAY_SIZE(alc660_dac_nids),
8159 .dac_nids = alc660_dac_nids,
8160 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
8161 .channel_mode = alc861_threestack_modes,
8163 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
8164 .adc_nids = alc861_adc_nids,
8165 .input_mux = &alc861_capture_source,
8167 [ALC861_UNIWILL_M31] = {
8168 .mixers = { alc861_uniwill_m31_mixer },
8169 .init_verbs = { alc861_uniwill_m31_init_verbs },
8170 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
8171 .dac_nids = alc861_dac_nids,
8172 .dig_out_nid = ALC861_DIGOUT_NID,
8173 .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes),
8174 .channel_mode = alc861_uniwill_m31_modes,
8176 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
8177 .adc_nids = alc861_adc_nids,
8178 .input_mux = &alc861_capture_source,
8180 [ALC861_TOSHIBA] = {
8181 .mixers = { alc861_toshiba_mixer },
8182 .init_verbs = { alc861_base_init_verbs, alc861_toshiba_init_verbs },
8183 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
8184 .dac_nids = alc861_dac_nids,
8185 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8186 .channel_mode = alc883_3ST_2ch_modes,
8187 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
8188 .adc_nids = alc861_adc_nids,
8189 .input_mux = &alc861_capture_source,
8190 .unsol_event = alc861_toshiba_unsol_event,
8191 .init_hook = alc861_toshiba_automute,
8194 .mixers = { alc861_asus_mixer },
8195 .init_verbs = { alc861_asus_init_verbs },
8196 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
8197 .dac_nids = alc861_dac_nids,
8198 .dig_out_nid = ALC861_DIGOUT_NID,
8199 .num_channel_mode = ARRAY_SIZE(alc861_asus_modes),
8200 .channel_mode = alc861_asus_modes,
8203 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
8204 .adc_nids = alc861_adc_nids,
8205 .input_mux = &alc861_capture_source,
8207 [ALC861_ASUS_LAPTOP] = {
8208 .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer },
8209 .init_verbs = { alc861_asus_init_verbs,
8210 alc861_asus_laptop_init_verbs },
8211 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
8212 .dac_nids = alc861_dac_nids,
8213 .dig_out_nid = ALC861_DIGOUT_NID,
8214 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8215 .channel_mode = alc883_3ST_2ch_modes,
8217 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
8218 .adc_nids = alc861_adc_nids,
8219 .input_mux = &alc861_capture_source,
8224 static int patch_alc861(struct hda_codec *codec)
8226 struct alc_spec *spec;
8230 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
8236 board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST,
8240 if (board_config < 0) {
8241 printk(KERN_INFO "hda_codec: Unknown model for ALC861, "
8242 "trying auto-probe from BIOS...\n");
8243 board_config = ALC861_AUTO;
8246 if (board_config == ALC861_AUTO) {
8247 /* automatic parse from the BIOS config */
8248 err = alc861_parse_auto_config(codec);
8254 "hda_codec: Cannot set up configuration "
8255 "from BIOS. Using base mode...\n");
8256 board_config = ALC861_3ST_DIG;
8260 if (board_config != ALC861_AUTO)
8261 setup_preset(spec, &alc861_presets[board_config]);
8263 spec->stream_name_analog = "ALC861 Analog";
8264 spec->stream_analog_playback = &alc861_pcm_analog_playback;
8265 spec->stream_analog_capture = &alc861_pcm_analog_capture;
8267 spec->stream_name_digital = "ALC861 Digital";
8268 spec->stream_digital_playback = &alc861_pcm_digital_playback;
8269 spec->stream_digital_capture = &alc861_pcm_digital_capture;
8271 codec->patch_ops = alc_patch_ops;
8272 if (board_config == ALC861_AUTO)
8273 spec->init_hook = alc861_auto_init;
8283 * In addition, an independent DAC
8285 #define ALC861VD_DIGOUT_NID 0x06
8287 static hda_nid_t alc861vd_dac_nids[4] = {
8288 /* front, surr, clfe, side surr */
8289 0x02, 0x03, 0x04, 0x05
8292 /* dac_nids for ALC660vd are in a different order - according to
8294 * This should probably tesult in a different mixer for 6stack models
8295 * of ALC660vd codecs, but for now there is only 3stack mixer
8296 * - and it is the same as in 861vd.
8297 * adc_nids in ALC660vd are (is) the same as in 861vd
8299 static hda_nid_t alc660vd_dac_nids[3] = {
8300 /* front, rear, clfe, rear_surr */
8304 static hda_nid_t alc861vd_adc_nids[1] = {
8310 /* FIXME: should be a matrix-type input source selection */
8311 static struct hda_input_mux alc861vd_capture_source = {
8315 { "Front Mic", 0x1 },
8321 #define alc861vd_mux_enum_info alc_mux_enum_info
8322 #define alc861vd_mux_enum_get alc_mux_enum_get
8324 static int alc861vd_mux_enum_put(struct snd_kcontrol *kcontrol,
8325 struct snd_ctl_elem_value *ucontrol)
8327 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
8328 struct alc_spec *spec = codec->spec;
8329 const struct hda_input_mux *imux = spec->input_mux;
8330 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
8331 static hda_nid_t capture_mixers[1] = { 0x22 };
8332 hda_nid_t nid = capture_mixers[adc_idx];
8333 unsigned int *cur_val = &spec->cur_mux[adc_idx];
8334 unsigned int i, idx;
8336 idx = ucontrol->value.enumerated.item[0];
8337 if (idx >= imux->num_items)
8338 idx = imux->num_items - 1;
8339 if (*cur_val == idx && ! codec->in_resume)
8341 for (i = 0; i < imux->num_items; i++) {
8342 unsigned int v = (i == idx) ? 0x7000 : 0x7080;
8343 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
8344 v | (imux->items[i].index << 8));
8353 static struct hda_channel_mode alc861vd_3stack_2ch_modes[1] = {
8360 static struct hda_verb alc861vd_6stack_ch6_init[] = {
8361 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
8362 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8363 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8364 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8371 static struct hda_verb alc861vd_6stack_ch8_init[] = {
8372 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8373 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8374 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8375 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8379 static struct hda_channel_mode alc861vd_6stack_modes[2] = {
8380 { 6, alc861vd_6stack_ch6_init },
8381 { 8, alc861vd_6stack_ch8_init },
8384 static struct snd_kcontrol_new alc861vd_chmode_mixer[] = {
8386 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8387 .name = "Channel Mode",
8388 .info = alc_ch_mode_info,
8389 .get = alc_ch_mode_get,
8390 .put = alc_ch_mode_put,
8395 static struct snd_kcontrol_new alc861vd_capture_mixer[] = {
8396 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
8397 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
8400 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8401 /* The multiple "Capture Source" controls confuse alsamixer
8402 * So call somewhat different..
8403 *FIXME: the controls appear in the "playback" view!
8405 /* .name = "Capture Source", */
8406 .name = "Input Source",
8408 .info = alc861vd_mux_enum_info,
8409 .get = alc861vd_mux_enum_get,
8410 .put = alc861vd_mux_enum_put,
8415 /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
8416 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
8418 static struct snd_kcontrol_new alc861vd_6st_mixer[] = {
8419 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
8420 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8422 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
8423 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
8425 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0,
8427 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0,
8429 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8430 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8432 HDA_CODEC_VOLUME("Side Playback Volume", 0x05, 0x0, HDA_OUTPUT),
8433 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
8435 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8437 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8438 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8439 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8441 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
8442 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8443 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
8445 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8446 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8448 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8449 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8451 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
8452 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
8457 static struct snd_kcontrol_new alc861vd_3st_mixer[] = {
8458 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
8459 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8461 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8463 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8464 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8465 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8467 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
8468 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8469 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
8471 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8472 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8474 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8475 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8477 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
8478 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
8484 * generic initialization of ADC, input mixers and output mixers
8486 static struct hda_verb alc861vd_volume_init_verbs[] = {
8488 * Unmute ADC0 and set the default input to mic-in
8490 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8491 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8493 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of
8494 * the analog-loopback mixer widget
8496 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
8497 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8498 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8499 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
8500 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
8501 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
8503 /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */
8504 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
8505 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
8506 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(6)},
8507 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(8)},
8510 * Set up output mixers (0x02 - 0x05)
8512 /* set vol=0 to output mixers */
8513 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8514 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8515 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8516 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8518 /* set up input amps for analog loopback */
8519 /* Amp Indices: DAC = 0, mixer = 1 */
8520 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8521 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8522 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8523 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8524 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8525 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8526 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8527 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8533 * 3-stack pin configuration:
8534 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
8536 static struct hda_verb alc861vd_3stack_init_verbs[] = {
8538 * Set pin mode and muting
8540 /* set front pin widgets 0x14 for output */
8541 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8542 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8543 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8545 /* Mic (rear) pin: input vref at 80% */
8546 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8547 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8548 /* Front Mic pin: input vref at 80% */
8549 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8550 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8551 /* Line In pin: input */
8552 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
8553 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8554 /* Line-2 In: Headphone output (output 0 - 0x0c) */
8555 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8556 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8557 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
8558 /* CD pin widget for input */
8559 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
8565 * 6-stack pin configuration:
8567 static struct hda_verb alc861vd_6stack_init_verbs[] = {
8569 * Set pin mode and muting
8571 /* set front pin widgets 0x14 for output */
8572 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8573 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8574 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8576 /* Rear Pin: output 1 (0x0d) */
8577 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8578 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8579 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
8580 /* CLFE Pin: output 2 (0x0e) */
8581 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8582 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8583 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
8584 /* Side Pin: output 3 (0x0f) */
8585 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8586 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8587 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
8589 /* Mic (rear) pin: input vref at 80% */
8590 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8591 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8592 /* Front Mic pin: input vref at 80% */
8593 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8594 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8595 /* Line In pin: input */
8596 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
8597 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8598 /* Line-2 In: Headphone output (output 0 - 0x0c) */
8599 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8600 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8601 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
8602 /* CD pin widget for input */
8603 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
8608 /* pcm configuration: identiacal with ALC880 */
8609 #define alc861vd_pcm_analog_playback alc880_pcm_analog_playback
8610 #define alc861vd_pcm_analog_capture alc880_pcm_analog_capture
8611 #define alc861vd_pcm_digital_playback alc880_pcm_digital_playback
8612 #define alc861vd_pcm_digital_capture alc880_pcm_digital_capture
8615 * configuration and preset
8617 static const char *alc861vd_models[ALC861VD_MODEL_LAST] = {
8618 [ALC660VD_3ST] = "3stack-660",
8619 [ALC861VD_3ST] = "3stack",
8620 [ALC861VD_3ST_DIG] = "3stack-digout",
8621 [ALC861VD_6ST_DIG] = "6stack-digout",
8622 [ALC861VD_AUTO] = "auto",
8625 static struct snd_pci_quirk alc861vd_cfg_tbl[] = {
8626 SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST),
8627 SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST),
8628 SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST),
8629 SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST),
8631 SND_PCI_QUIRK(0x17aa, 0x3802, "Lenovo 3000 C200", ALC861VD_3ST),
8635 static struct alc_config_preset alc861vd_presets[] = {
8637 .mixers = { alc861vd_3st_mixer },
8638 .init_verbs = { alc861vd_volume_init_verbs,
8639 alc861vd_3stack_init_verbs },
8640 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
8641 .dac_nids = alc660vd_dac_nids,
8642 .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
8643 .adc_nids = alc861vd_adc_nids,
8644 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
8645 .channel_mode = alc861vd_3stack_2ch_modes,
8646 .input_mux = &alc861vd_capture_source,
8649 .mixers = { alc861vd_3st_mixer },
8650 .init_verbs = { alc861vd_volume_init_verbs,
8651 alc861vd_3stack_init_verbs },
8652 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
8653 .dac_nids = alc861vd_dac_nids,
8654 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
8655 .channel_mode = alc861vd_3stack_2ch_modes,
8656 .input_mux = &alc861vd_capture_source,
8658 [ALC861VD_3ST_DIG] = {
8659 .mixers = { alc861vd_3st_mixer },
8660 .init_verbs = { alc861vd_volume_init_verbs,
8661 alc861vd_3stack_init_verbs },
8662 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
8663 .dac_nids = alc861vd_dac_nids,
8664 .dig_out_nid = ALC861VD_DIGOUT_NID,
8665 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
8666 .channel_mode = alc861vd_3stack_2ch_modes,
8667 .input_mux = &alc861vd_capture_source,
8669 [ALC861VD_6ST_DIG] = {
8670 .mixers = { alc861vd_6st_mixer, alc861vd_chmode_mixer },
8671 .init_verbs = { alc861vd_volume_init_verbs,
8672 alc861vd_6stack_init_verbs },
8673 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
8674 .dac_nids = alc861vd_dac_nids,
8675 .dig_out_nid = ALC861VD_DIGOUT_NID,
8676 .num_channel_mode = ARRAY_SIZE(alc861vd_6stack_modes),
8677 .channel_mode = alc861vd_6stack_modes,
8678 .input_mux = &alc861vd_capture_source,
8683 * BIOS auto configuration
8685 static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec,
8686 hda_nid_t nid, int pin_type, int dac_idx)
8689 snd_hda_codec_write(codec, nid, 0,
8690 AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
8691 snd_hda_codec_write(codec, nid, 0,
8692 AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
8695 static void alc861vd_auto_init_multi_out(struct hda_codec *codec)
8697 struct alc_spec *spec = codec->spec;
8700 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
8701 for (i = 0; i <= HDA_SIDE; i++) {
8702 hda_nid_t nid = spec->autocfg.line_out_pins[i];
8704 alc861vd_auto_set_output_and_unmute(codec, nid,
8710 static void alc861vd_auto_init_hp_out(struct hda_codec *codec)
8712 struct alc_spec *spec = codec->spec;
8715 pin = spec->autocfg.hp_pins[0];
8716 if (pin) /* connect to front and use dac 0 */
8717 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
8720 #define alc861vd_is_input_pin(nid) alc880_is_input_pin(nid)
8721 #define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID
8723 static void alc861vd_auto_init_analog_input(struct hda_codec *codec)
8725 struct alc_spec *spec = codec->spec;
8728 for (i = 0; i < AUTO_PIN_LAST; i++) {
8729 hda_nid_t nid = spec->autocfg.input_pins[i];
8730 if (alc861vd_is_input_pin(nid)) {
8731 snd_hda_codec_write(codec, nid, 0,
8732 AC_VERB_SET_PIN_WIDGET_CONTROL,
8733 i <= AUTO_PIN_FRONT_MIC ?
8734 PIN_VREF80 : PIN_IN);
8735 if (nid != ALC861VD_PIN_CD_NID)
8736 snd_hda_codec_write(codec, nid, 0,
8737 AC_VERB_SET_AMP_GAIN_MUTE,
8743 #define alc861vd_idx_to_mixer_vol(nid) ((nid) + 0x02)
8744 #define alc861vd_idx_to_mixer_switch(nid) ((nid) + 0x0c)
8746 /* add playback controls from the parsed DAC table */
8747 /* Based on ALC880 version. But ALC861VD has separate,
8748 * different NIDs for mute/unmute switch and volume control */
8749 static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
8750 const struct auto_pin_cfg *cfg)
8753 static const char *chname[4] = {"Front", "Surround", "CLFE", "Side"};
8754 hda_nid_t nid_v, nid_s;
8757 for (i = 0; i < cfg->line_outs; i++) {
8758 if (! spec->multiout.dac_nids[i])
8760 nid_v = alc861vd_idx_to_mixer_vol(
8762 spec->multiout.dac_nids[i]));
8763 nid_s = alc861vd_idx_to_mixer_switch(
8765 spec->multiout.dac_nids[i]));
8769 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL,
8770 "Center Playback Volume",
8771 HDA_COMPOSE_AMP_VAL(nid_v, 1,
8772 0, HDA_OUTPUT))) < 0)
8774 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL,
8775 "LFE Playback Volume",
8776 HDA_COMPOSE_AMP_VAL(nid_v, 2,
8777 0, HDA_OUTPUT))) < 0)
8779 if ((err = add_control(spec, ALC_CTL_BIND_MUTE,
8780 "Center Playback Switch",
8781 HDA_COMPOSE_AMP_VAL(nid_s, 1,
8782 2, HDA_INPUT))) < 0)
8784 if ((err = add_control(spec, ALC_CTL_BIND_MUTE,
8785 "LFE Playback Switch",
8786 HDA_COMPOSE_AMP_VAL(nid_s, 2,
8787 2, HDA_INPUT))) < 0)
8790 sprintf(name, "%s Playback Volume", chname[i]);
8791 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
8792 HDA_COMPOSE_AMP_VAL(nid_v, 3,
8793 0, HDA_OUTPUT))) < 0)
8795 sprintf(name, "%s Playback Switch", chname[i]);
8796 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, name,
8797 HDA_COMPOSE_AMP_VAL(nid_v, 3,
8798 2, HDA_INPUT))) < 0)
8805 /* add playback controls for speaker and HP outputs */
8806 /* Based on ALC880 version. But ALC861VD has separate,
8807 * different NIDs for mute/unmute switch and volume control */
8808 static int alc861vd_auto_create_extra_out(struct alc_spec *spec,
8809 hda_nid_t pin, const char *pfx)
8811 hda_nid_t nid_v, nid_s;
8818 if (alc880_is_fixed_pin(pin)) {
8819 nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
8820 /* specify the DAC as the extra output */
8821 if (! spec->multiout.hp_nid)
8822 spec->multiout.hp_nid = nid_v;
8824 spec->multiout.extra_out_nid[0] = nid_v;
8825 /* control HP volume/switch on the output mixer amp */
8826 nid_v = alc861vd_idx_to_mixer_vol(
8827 alc880_fixed_pin_idx(pin));
8828 nid_s = alc861vd_idx_to_mixer_switch(
8829 alc880_fixed_pin_idx(pin));
8831 sprintf(name, "%s Playback Volume", pfx);
8832 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
8833 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0,
8836 sprintf(name, "%s Playback Switch", pfx);
8837 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, name,
8838 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2,
8841 } else if (alc880_is_multi_pin(pin)) {
8842 /* set manual connection */
8843 /* we have only a switch on HP-out PIN */
8844 sprintf(name, "%s Playback Switch", pfx);
8845 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
8846 HDA_COMPOSE_AMP_VAL(pin, 3, 0,
8853 /* parse the BIOS configuration and set up the alc_spec
8854 * return 1 if successful, 0 if the proper config is not found,
8855 * or a negative error code
8856 * Based on ALC880 version - had to change it to override
8857 * alc880_auto_create_extra_out and alc880_auto_create_multi_out_ctls */
8858 static int alc861vd_parse_auto_config(struct hda_codec *codec)
8860 struct alc_spec *spec = codec->spec;
8862 static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
8864 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
8865 alc861vd_ignore)) < 0)
8867 if (! spec->autocfg.line_outs)
8868 return 0; /* can't find valid BIOS pin config */
8870 if ((err = alc880_auto_fill_dac_nids(spec, &spec->autocfg)) < 0 ||
8871 (err = alc861vd_auto_create_multi_out_ctls(spec,
8872 &spec->autocfg)) < 0 ||
8873 (err = alc861vd_auto_create_extra_out(spec,
8874 spec->autocfg.speaker_pins[0], "Speaker")) < 0 ||
8875 (err = alc861vd_auto_create_extra_out(spec,
8876 spec->autocfg.hp_pins[0], "Headphone")) < 0 ||
8877 (err = alc880_auto_create_analog_input_ctls(spec,
8878 &spec->autocfg)) < 0)
8881 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
8883 if (spec->autocfg.dig_out_pin)
8884 spec->multiout.dig_out_nid = ALC861VD_DIGOUT_NID;
8886 if (spec->kctl_alloc)
8887 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
8889 spec->init_verbs[spec->num_init_verbs++]
8890 = alc861vd_volume_init_verbs;
8892 spec->num_mux_defs = 1;
8893 spec->input_mux = &spec->private_imux;
8898 /* additional initialization for auto-configuration model */
8899 static void alc861vd_auto_init(struct hda_codec *codec)
8901 alc861vd_auto_init_multi_out(codec);
8902 alc861vd_auto_init_hp_out(codec);
8903 alc861vd_auto_init_analog_input(codec);
8906 static int patch_alc861vd(struct hda_codec *codec)
8908 struct alc_spec *spec;
8909 int err, board_config;
8911 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
8917 board_config = snd_hda_check_board_config(codec, ALC861VD_MODEL_LAST,
8921 if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) {
8922 printk(KERN_INFO "hda_codec: Unknown model for ALC660VD/"
8923 "ALC861VD, trying auto-probe from BIOS...\n");
8924 board_config = ALC861VD_AUTO;
8927 if (board_config == ALC861VD_AUTO) {
8928 /* automatic parse from the BIOS config */
8929 err = alc861vd_parse_auto_config(codec);
8935 "hda_codec: Cannot set up configuration "
8936 "from BIOS. Using base mode...\n");
8937 board_config = ALC861VD_3ST;
8941 if (board_config != ALC861VD_AUTO)
8942 setup_preset(spec, &alc861vd_presets[board_config]);
8944 spec->stream_name_analog = "ALC861VD Analog";
8945 spec->stream_analog_playback = &alc861vd_pcm_analog_playback;
8946 spec->stream_analog_capture = &alc861vd_pcm_analog_capture;
8948 spec->stream_name_digital = "ALC861VD Digital";
8949 spec->stream_digital_playback = &alc861vd_pcm_digital_playback;
8950 spec->stream_digital_capture = &alc861vd_pcm_digital_capture;
8952 spec->adc_nids = alc861vd_adc_nids;
8953 spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids);
8955 spec->mixers[spec->num_mixers] = alc861vd_capture_mixer;
8958 codec->patch_ops = alc_patch_ops;
8960 if (board_config == ALC861VD_AUTO)
8961 spec->init_hook = alc861vd_auto_init;
8969 * ALC662 is almost identical with ALC880 but has cleaner and more flexible
8970 * configuration. Each pin widget can choose any input DACs and a mixer.
8971 * Each ADC is connected from a mixer of all inputs. This makes possible
8972 * 6-channel independent captures.
8974 * In addition, an independent DAC for the multi-playback (not used in this
8977 #define ALC662_DIGOUT_NID 0x06
8978 #define ALC662_DIGIN_NID 0x0a
8980 static hda_nid_t alc662_dac_nids[4] = {
8981 /* front, rear, clfe, rear_surr */
8985 static hda_nid_t alc662_adc_nids[1] = {
8990 /* FIXME: should be a matrix-type input source selection */
8992 static struct hda_input_mux alc662_capture_source = {
8996 { "Front Mic", 0x1 },
9002 static struct hda_input_mux alc662_lenovo_101e_capture_source = {
9009 #define alc662_mux_enum_info alc_mux_enum_info
9010 #define alc662_mux_enum_get alc_mux_enum_get
9012 static int alc662_mux_enum_put(struct snd_kcontrol *kcontrol,
9013 struct snd_ctl_elem_value *ucontrol)
9015 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
9016 struct alc_spec *spec = codec->spec;
9017 const struct hda_input_mux *imux = spec->input_mux;
9018 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
9019 static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
9020 hda_nid_t nid = capture_mixers[adc_idx];
9021 unsigned int *cur_val = &spec->cur_mux[adc_idx];
9022 unsigned int i, idx;
9024 idx = ucontrol->value.enumerated.item[0];
9025 if (idx >= imux->num_items)
9026 idx = imux->num_items - 1;
9027 if (*cur_val == idx && ! codec->in_resume)
9029 for (i = 0; i < imux->num_items; i++) {
9030 unsigned int v = (i == idx) ? 0x7000 : 0x7080;
9031 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
9032 v | (imux->items[i].index << 8));
9040 static struct hda_channel_mode alc662_3ST_2ch_modes[1] = {
9047 static struct hda_verb alc662_3ST_ch2_init[] = {
9048 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
9049 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
9050 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
9051 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
9058 static struct hda_verb alc662_3ST_ch6_init[] = {
9059 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9060 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
9061 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
9062 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9063 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
9064 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
9068 static struct hda_channel_mode alc662_3ST_6ch_modes[2] = {
9069 { 2, alc662_3ST_ch2_init },
9070 { 6, alc662_3ST_ch6_init },
9076 static struct hda_verb alc662_sixstack_ch6_init[] = {
9077 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
9078 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
9079 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9086 static struct hda_verb alc662_sixstack_ch8_init[] = {
9087 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9088 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9089 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9093 static struct hda_channel_mode alc662_5stack_modes[2] = {
9094 { 2, alc662_sixstack_ch6_init },
9095 { 6, alc662_sixstack_ch8_init },
9098 /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
9099 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
9102 static struct snd_kcontrol_new alc662_base_mixer[] = {
9103 /* output mixer control */
9104 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
9105 HDA_CODEC_MUTE("Front Playback Switch", 0x02, 0x0, HDA_OUTPUT),
9106 HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT),
9107 HDA_CODEC_MUTE("Surround Playback Switch", 0x03, 0x0, HDA_OUTPUT),
9108 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
9109 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
9110 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT),
9111 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT),
9112 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
9114 /*Input mixer control */
9115 HDA_CODEC_VOLUME("CD Playback Volume", 0xb, 0x4, HDA_INPUT),
9116 HDA_CODEC_MUTE("CD Playback Switch", 0xb, 0x4, HDA_INPUT),
9117 HDA_CODEC_VOLUME("Line Playback Volume", 0xb, 0x02, HDA_INPUT),
9118 HDA_CODEC_MUTE("Line Playback Switch", 0xb, 0x02, HDA_INPUT),
9119 HDA_CODEC_VOLUME("Mic Playback Volume", 0xb, 0x0, HDA_INPUT),
9120 HDA_CODEC_MUTE("Mic Playback Switch", 0xb, 0x0, HDA_INPUT),
9121 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0xb, 0x01, HDA_INPUT),
9122 HDA_CODEC_MUTE("Front Mic Playback Switch", 0xb, 0x01, HDA_INPUT),
9124 /* Capture mixer control */
9125 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
9126 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
9128 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9129 .name = "Capture Source",
9131 .info = alc_mux_enum_info,
9132 .get = alc_mux_enum_get,
9133 .put = alc_mux_enum_put,
9138 static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = {
9139 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
9140 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
9141 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
9142 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9143 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9144 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9145 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9146 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9147 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9148 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
9149 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
9150 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
9151 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
9152 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
9153 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
9155 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9156 /* .name = "Capture Source", */
9157 .name = "Input Source",
9159 .info = alc662_mux_enum_info,
9160 .get = alc662_mux_enum_get,
9161 .put = alc662_mux_enum_put,
9166 static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = {
9167 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
9168 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
9169 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
9170 HDA_BIND_MUTE("Surround Playback Switch", 0x03, 2, HDA_INPUT),
9171 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
9172 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
9173 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT),
9174 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT),
9175 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
9176 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9177 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9178 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9179 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9180 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9181 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9182 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
9183 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
9184 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
9185 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
9186 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
9187 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
9189 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9190 /* .name = "Capture Source", */
9191 .name = "Input Source",
9193 .info = alc662_mux_enum_info,
9194 .get = alc662_mux_enum_get,
9195 .put = alc662_mux_enum_put,
9200 static struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = {
9201 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
9202 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
9203 HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x03, 0x0, HDA_OUTPUT),
9204 HDA_BIND_MUTE("iSpeaker Playback Switch", 0x03, 2, HDA_INPUT),
9205 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
9206 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9207 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9208 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
9209 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
9210 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
9211 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
9213 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9214 /* .name = "Capture Source", */
9215 .name = "Input Source",
9217 .info = alc662_mux_enum_info,
9218 .get = alc662_mux_enum_get,
9219 .put = alc662_mux_enum_put,
9224 static struct snd_kcontrol_new alc662_chmode_mixer[] = {
9226 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9227 .name = "Channel Mode",
9228 .info = alc_ch_mode_info,
9229 .get = alc_ch_mode_get,
9230 .put = alc_ch_mode_put,
9235 static struct hda_verb alc662_init_verbs[] = {
9236 /* ADC: mute amp left and right */
9237 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9238 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
9239 /* Front mixer: unmute input/output amp left and right (volume = 0) */
9241 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9242 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9243 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
9244 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
9245 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
9247 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9248 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9249 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9250 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9251 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9252 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9254 /* Front Pin: output 0 (0x0c) */
9255 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9256 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9258 /* Rear Pin: output 1 (0x0d) */
9259 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9260 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9262 /* CLFE Pin: output 2 (0x0e) */
9263 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9264 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9266 /* Mic (rear) pin: input vref at 80% */
9267 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
9268 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9269 /* Front Mic pin: input vref at 80% */
9270 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
9271 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9272 /* Line In pin: input */
9273 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
9274 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9275 /* Line-2 In: Headphone output (output 0 - 0x0c) */
9276 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9277 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9278 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
9279 /* CD pin widget for input */
9280 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
9282 /* FIXME: use matrix-type input source selection */
9283 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
9285 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9286 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9287 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
9288 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
9292 static struct hda_verb alc662_sue_init_verbs[] = {
9293 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
9294 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
9299 * generic initialization of ADC, input mixers and output mixers
9301 static struct hda_verb alc662_auto_init_verbs[] = {
9303 * Unmute ADC and set the default input to mic-in
9305 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
9306 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9308 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
9310 * Note: PASD motherboards uses the Line In 2 as the input for front
9313 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
9314 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9315 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9316 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
9317 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
9318 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
9321 * Set up output mixers (0x0c - 0x0f)
9323 /* set vol=0 to output mixers */
9324 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9325 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9326 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9328 /* set up input amps for analog loopback */
9329 /* Amp Indices: DAC = 0, mixer = 1 */
9330 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9331 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9332 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9333 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9334 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9335 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9338 /* FIXME: use matrix-type input source selection */
9339 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
9341 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9342 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9343 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
9344 /*{0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},*/
9345 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
9350 /* capture mixer elements */
9351 static struct snd_kcontrol_new alc662_capture_mixer[] = {
9352 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
9353 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
9355 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9356 /* The multiple "Capture Source" controls confuse alsamixer
9357 * So call somewhat different..
9358 * FIXME: the controls appear in the "playback" view!
9360 /* .name = "Capture Source", */
9361 .name = "Input Source",
9363 .info = alc882_mux_enum_info,
9364 .get = alc882_mux_enum_get,
9365 .put = alc882_mux_enum_put,
9370 static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
9372 unsigned int present;
9374 present = snd_hda_codec_read(codec, 0x14, 0,
9375 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
9377 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
9378 0x80, present ? 0x80 : 0);
9379 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
9380 0x80, present ? 0x80 : 0);
9383 static void alc662_lenovo_101e_all_automute(struct hda_codec *codec)
9385 unsigned int present;
9387 present = snd_hda_codec_read(codec, 0x1b, 0,
9388 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
9390 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
9391 0x80, present ? 0x80 : 0);
9392 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
9393 0x80, present ? 0x80 : 0);
9394 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
9395 0x80, present ? 0x80 : 0);
9396 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
9397 0x80, present ? 0x80 : 0);
9400 static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec,
9403 if ((res >> 26) == ALC880_HP_EVENT)
9404 alc662_lenovo_101e_all_automute(codec);
9405 if ((res >> 26) == ALC880_FRONT_EVENT)
9406 alc662_lenovo_101e_ispeaker_automute(codec);
9410 /* pcm configuration: identiacal with ALC880 */
9411 #define alc662_pcm_analog_playback alc880_pcm_analog_playback
9412 #define alc662_pcm_analog_capture alc880_pcm_analog_capture
9413 #define alc662_pcm_digital_playback alc880_pcm_digital_playback
9414 #define alc662_pcm_digital_capture alc880_pcm_digital_capture
9417 * configuration and preset
9419 static const char *alc662_models[ALC662_MODEL_LAST] = {
9420 [ALC662_3ST_2ch_DIG] = "3stack-dig",
9421 [ALC662_3ST_6ch_DIG] = "3stack-6ch-dig",
9422 [ALC662_3ST_6ch] = "3stack-6ch",
9423 [ALC662_5ST_DIG] = "6stack-dig",
9424 [ALC662_LENOVO_101E] = "lenovo-101e",
9425 [ALC662_AUTO] = "auto",
9428 static struct snd_pci_quirk alc662_cfg_tbl[] = {
9429 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E),
9433 static struct alc_config_preset alc662_presets[] = {
9434 [ALC662_3ST_2ch_DIG] = {
9435 .mixers = { alc662_3ST_2ch_mixer },
9436 .init_verbs = { alc662_init_verbs },
9437 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
9438 .dac_nids = alc662_dac_nids,
9439 .dig_out_nid = ALC662_DIGOUT_NID,
9440 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
9441 .adc_nids = alc662_adc_nids,
9442 .dig_in_nid = ALC662_DIGIN_NID,
9443 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
9444 .channel_mode = alc662_3ST_2ch_modes,
9445 .input_mux = &alc662_capture_source,
9447 [ALC662_3ST_6ch_DIG] = {
9448 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
9449 .init_verbs = { alc662_init_verbs },
9450 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
9451 .dac_nids = alc662_dac_nids,
9452 .dig_out_nid = ALC662_DIGOUT_NID,
9453 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
9454 .adc_nids = alc662_adc_nids,
9455 .dig_in_nid = ALC662_DIGIN_NID,
9456 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
9457 .channel_mode = alc662_3ST_6ch_modes,
9459 .input_mux = &alc662_capture_source,
9461 [ALC662_3ST_6ch] = {
9462 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
9463 .init_verbs = { alc662_init_verbs },
9464 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
9465 .dac_nids = alc662_dac_nids,
9466 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
9467 .adc_nids = alc662_adc_nids,
9468 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
9469 .channel_mode = alc662_3ST_6ch_modes,
9471 .input_mux = &alc662_capture_source,
9473 [ALC662_5ST_DIG] = {
9474 .mixers = { alc662_base_mixer, alc662_chmode_mixer },
9475 .init_verbs = { alc662_init_verbs },
9476 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
9477 .dac_nids = alc662_dac_nids,
9478 .dig_out_nid = ALC662_DIGOUT_NID,
9479 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
9480 .adc_nids = alc662_adc_nids,
9481 .dig_in_nid = ALC662_DIGIN_NID,
9482 .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes),
9483 .channel_mode = alc662_5stack_modes,
9484 .input_mux = &alc662_capture_source,
9486 [ALC662_LENOVO_101E] = {
9487 .mixers = { alc662_lenovo_101e_mixer },
9488 .init_verbs = { alc662_init_verbs, alc662_sue_init_verbs },
9489 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
9490 .dac_nids = alc662_dac_nids,
9491 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
9492 .adc_nids = alc662_adc_nids,
9493 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
9494 .channel_mode = alc662_3ST_2ch_modes,
9495 .input_mux = &alc662_lenovo_101e_capture_source,
9496 .unsol_event = alc662_lenovo_101e_unsol_event,
9497 .init_hook = alc662_lenovo_101e_all_automute,
9504 * BIOS auto configuration
9507 /* add playback controls from the parsed DAC table */
9508 static int alc662_auto_create_multi_out_ctls(struct alc_spec *spec,
9509 const struct auto_pin_cfg *cfg)
9512 static const char *chname[4] = {
9513 "Front", "Surround", NULL /*CLFE*/, "Side"
9518 for (i = 0; i < cfg->line_outs; i++) {
9519 if (!spec->multiout.dac_nids[i])
9521 nid = alc880_idx_to_dac(i);
9524 err = add_control(spec, ALC_CTL_WIDGET_VOL,
9525 "Center Playback Volume",
9526 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT));
9529 err = add_control(spec, ALC_CTL_WIDGET_VOL,
9530 "LFE Playback Volume",
9531 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT));
9534 err = add_control(spec, ALC_CTL_BIND_MUTE,
9535 "Center Playback Switch",
9536 HDA_COMPOSE_AMP_VAL(nid, 1, 2, HDA_INPUT));
9539 err = add_control(spec, ALC_CTL_BIND_MUTE,
9540 "LFE Playback Switch",
9541 HDA_COMPOSE_AMP_VAL(nid, 2, 2, HDA_INPUT));
9545 sprintf(name, "%s Playback Volume", chname[i]);
9546 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
9547 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
9550 sprintf(name, "%s Playback Switch", chname[i]);
9551 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
9552 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
9560 /* add playback controls for speaker and HP outputs */
9561 static int alc662_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
9571 if (alc880_is_fixed_pin(pin)) {
9572 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
9573 /* printk("DAC nid=%x\n",nid); */
9574 /* specify the DAC as the extra output */
9575 if (!spec->multiout.hp_nid)
9576 spec->multiout.hp_nid = nid;
9578 spec->multiout.extra_out_nid[0] = nid;
9579 /* control HP volume/switch on the output mixer amp */
9580 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
9581 sprintf(name, "%s Playback Volume", pfx);
9582 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
9583 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
9586 sprintf(name, "%s Playback Switch", pfx);
9587 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
9588 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
9591 } else if (alc880_is_multi_pin(pin)) {
9592 /* set manual connection */
9593 /* we have only a switch on HP-out PIN */
9594 sprintf(name, "%s Playback Switch", pfx);
9595 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
9596 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
9603 /* create playback/capture controls for input pins */
9604 static int alc662_auto_create_analog_input_ctls(struct alc_spec *spec,
9605 const struct auto_pin_cfg *cfg)
9607 struct hda_input_mux *imux = &spec->private_imux;
9610 for (i = 0; i < AUTO_PIN_LAST; i++) {
9611 if (alc880_is_input_pin(cfg->input_pins[i])) {
9612 idx = alc880_input_pin_idx(cfg->input_pins[i]);
9613 err = new_analog_input(spec, cfg->input_pins[i],
9614 auto_pin_cfg_labels[i],
9618 imux->items[imux->num_items].label =
9619 auto_pin_cfg_labels[i];
9620 imux->items[imux->num_items].index =
9621 alc880_input_pin_idx(cfg->input_pins[i]);
9628 static void alc662_auto_set_output_and_unmute(struct hda_codec *codec,
9629 hda_nid_t nid, int pin_type,
9633 snd_hda_codec_write(codec, nid, 0,
9634 AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
9635 snd_hda_codec_write(codec, nid, 0,
9636 AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
9637 /* need the manual connection? */
9638 if (alc880_is_multi_pin(nid)) {
9639 struct alc_spec *spec = codec->spec;
9640 int idx = alc880_multi_pin_idx(nid);
9641 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
9642 AC_VERB_SET_CONNECT_SEL,
9643 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
9647 static void alc662_auto_init_multi_out(struct hda_codec *codec)
9649 struct alc_spec *spec = codec->spec;
9652 for (i = 0; i <= HDA_SIDE; i++) {
9653 hda_nid_t nid = spec->autocfg.line_out_pins[i];
9655 alc662_auto_set_output_and_unmute(codec, nid, PIN_OUT,
9660 static void alc662_auto_init_hp_out(struct hda_codec *codec)
9662 struct alc_spec *spec = codec->spec;
9665 pin = spec->autocfg.hp_pins[0];
9666 if (pin) /* connect to front */
9668 alc662_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
9671 #define alc662_is_input_pin(nid) alc880_is_input_pin(nid)
9672 #define ALC662_PIN_CD_NID ALC880_PIN_CD_NID
9674 static void alc662_auto_init_analog_input(struct hda_codec *codec)
9676 struct alc_spec *spec = codec->spec;
9679 for (i = 0; i < AUTO_PIN_LAST; i++) {
9680 hda_nid_t nid = spec->autocfg.input_pins[i];
9681 if (alc662_is_input_pin(nid)) {
9682 snd_hda_codec_write(codec, nid, 0,
9683 AC_VERB_SET_PIN_WIDGET_CONTROL,
9684 (i <= AUTO_PIN_FRONT_MIC ?
9685 PIN_VREF80 : PIN_IN));
9686 if (nid != ALC662_PIN_CD_NID)
9687 snd_hda_codec_write(codec, nid, 0,
9688 AC_VERB_SET_AMP_GAIN_MUTE,
9694 static int alc662_parse_auto_config(struct hda_codec *codec)
9696 struct alc_spec *spec = codec->spec;
9698 static hda_nid_t alc662_ignore[] = { 0x1d, 0 };
9700 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
9704 if (!spec->autocfg.line_outs)
9705 return 0; /* can't find valid BIOS pin config */
9707 if ((err = alc880_auto_fill_dac_nids(spec, &spec->autocfg)) < 0 ||
9708 (err = alc662_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 ||
9709 (err = alc662_auto_create_extra_out(spec,
9710 spec->autocfg.speaker_pins[0],
9712 (err = alc662_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
9713 "Headphone")) < 0 ||
9714 (err = alc662_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0)
9717 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
9719 if (spec->autocfg.dig_out_pin)
9720 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
9722 if (spec->kctl_alloc)
9723 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
9725 spec->num_mux_defs = 1;
9726 spec->input_mux = &spec->private_imux;
9731 /* hack - override the init verbs */
9732 spec->init_verbs[0] = alc662_auto_init_verbs;
9733 spec->mixers[spec->num_mixers] = alc662_capture_mixer;
9738 /* additional initialization for auto-configuration model */
9739 static void alc662_auto_init(struct hda_codec *codec)
9741 alc662_auto_init_multi_out(codec);
9742 alc662_auto_init_hp_out(codec);
9743 alc662_auto_init_analog_input(codec);
9746 static int patch_alc662(struct hda_codec *codec)
9748 struct alc_spec *spec;
9749 int err, board_config;
9751 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
9757 board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST,
9760 if (board_config < 0) {
9761 printk(KERN_INFO "hda_codec: Unknown model for ALC662, "
9762 "trying auto-probe from BIOS...\n");
9763 board_config = ALC662_AUTO;
9766 if (board_config == ALC662_AUTO) {
9767 /* automatic parse from the BIOS config */
9768 err = alc662_parse_auto_config(codec);
9774 "hda_codec: Cannot set up configuration "
9775 "from BIOS. Using base mode...\n");
9776 board_config = ALC662_3ST_2ch_DIG;
9780 if (board_config != ALC662_AUTO)
9781 setup_preset(spec, &alc662_presets[board_config]);
9783 spec->stream_name_analog = "ALC662 Analog";
9784 spec->stream_analog_playback = &alc662_pcm_analog_playback;
9785 spec->stream_analog_capture = &alc662_pcm_analog_capture;
9787 spec->stream_name_digital = "ALC662 Digital";
9788 spec->stream_digital_playback = &alc662_pcm_digital_playback;
9789 spec->stream_digital_capture = &alc662_pcm_digital_capture;
9791 if (!spec->adc_nids && spec->input_mux) {
9792 spec->adc_nids = alc662_adc_nids;
9793 spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids);
9796 codec->patch_ops = alc_patch_ops;
9797 if (board_config == ALC662_AUTO)
9798 spec->init_hook = alc662_auto_init;
9806 struct hda_codec_preset snd_hda_preset_realtek[] = {
9807 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
9808 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
9809 { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
9810 .patch = patch_alc861 },
9811 { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
9812 { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
9813 { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
9814 { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2",
9815 .patch = patch_alc883 },
9816 { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
9817 .patch = patch_alc662 },
9818 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
9819 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
9820 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc883 },
9821 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
9822 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc883 },