2 * Universal Interface for Intel High Definition Audio Codec
4 * HD audio interface patch for ALC 260/880/882 codecs
6 * Copyright (c) 2004 Kailang Yang <kailang@realtek.com.tw>
7 * PeiSen Hou <pshou@realtek.com.tw>
8 * Takashi Iwai <tiwai@suse.de>
9 * Jonathan Woithe <jwoithe@physics.adelaide.edu.au>
11 * This driver is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
16 * This driver is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26 #include <sound/driver.h>
27 #include <linux/init.h>
28 #include <linux/delay.h>
29 #include <linux/slab.h>
30 #include <linux/pci.h>
31 #include <sound/core.h>
32 #include "hda_codec.h"
33 #include "hda_local.h"
35 #define ALC880_FRONT_EVENT 0x01
36 #define ALC880_DCVOL_EVENT 0x02
37 #define ALC880_HP_EVENT 0x04
38 #define ALC880_MIC_EVENT 0x08
40 /* ALC880 board config type */
63 #ifdef CONFIG_SND_DEBUG
67 ALC880_MODEL_LAST /* last tag */
79 #ifdef CONFIG_SND_DEBUG
83 ALC260_MODEL_LAST /* last tag */
93 ALC262_HP_BPC_D7000_WL,
94 ALC262_HP_BPC_D7000_WF,
99 ALC262_MODEL_LAST /* last tag */
108 ALC268_MODEL_LAST /* last tag */
125 /* ALC861-VD models */
173 ALC883_TARGA_2ch_DIG,
179 ALC883_LENOVO_101E_2ch,
180 ALC883_LENOVO_NB0763,
181 ALC888_LENOVO_MS7195_DIG,
190 #define GPIO_MASK 0x03
193 /* codec parameterization */
194 struct snd_kcontrol_new *mixers[5]; /* mixer arrays */
195 unsigned int num_mixers;
197 const struct hda_verb *init_verbs[5]; /* initialization verbs
201 unsigned int num_init_verbs;
203 char *stream_name_analog; /* analog PCM stream */
204 struct hda_pcm_stream *stream_analog_playback;
205 struct hda_pcm_stream *stream_analog_capture;
207 char *stream_name_digital; /* digital PCM stream */
208 struct hda_pcm_stream *stream_digital_playback;
209 struct hda_pcm_stream *stream_digital_capture;
212 struct hda_multi_out multiout; /* playback set-up
213 * max_channels, dacs must be set
214 * dig_out_nid and hp_nid are optional
218 unsigned int num_adc_nids;
220 hda_nid_t dig_in_nid; /* digital-in NID; optional */
223 unsigned int num_mux_defs;
224 const struct hda_input_mux *input_mux;
225 unsigned int cur_mux[3];
228 const struct hda_channel_mode *channel_mode;
229 int num_channel_mode;
232 /* PCM information */
233 struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */
235 /* dynamic controls, init_verbs and input_mux */
236 struct auto_pin_cfg autocfg;
237 unsigned int num_kctl_alloc, num_kctl_used;
238 struct snd_kcontrol_new *kctl_alloc;
239 struct hda_input_mux private_imux;
240 hda_nid_t private_dac_nids[5];
243 void (*init_hook)(struct hda_codec *codec);
244 void (*unsol_event)(struct hda_codec *codec, unsigned int res);
246 /* for pin sensing */
247 unsigned int sense_updated: 1;
248 unsigned int jack_present: 1;
250 #ifdef CONFIG_SND_HDA_POWER_SAVE
251 struct hda_loopback_check loopback;
256 * configuration template - to be copied to the spec instance
258 struct alc_config_preset {
259 struct snd_kcontrol_new *mixers[5]; /* should be identical size
262 const struct hda_verb *init_verbs[5];
263 unsigned int num_dacs;
265 hda_nid_t dig_out_nid; /* optional */
266 hda_nid_t hp_nid; /* optional */
267 unsigned int num_adc_nids;
269 hda_nid_t dig_in_nid;
270 unsigned int num_channel_mode;
271 const struct hda_channel_mode *channel_mode;
273 unsigned int num_mux_defs;
274 const struct hda_input_mux *input_mux;
275 void (*unsol_event)(struct hda_codec *, unsigned int);
276 void (*init_hook)(struct hda_codec *);
277 #ifdef CONFIG_SND_HDA_POWER_SAVE
278 struct hda_amp_list *loopbacks;
286 static int alc_mux_enum_info(struct snd_kcontrol *kcontrol,
287 struct snd_ctl_elem_info *uinfo)
289 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
290 struct alc_spec *spec = codec->spec;
291 unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id);
292 if (mux_idx >= spec->num_mux_defs)
294 return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo);
297 static int alc_mux_enum_get(struct snd_kcontrol *kcontrol,
298 struct snd_ctl_elem_value *ucontrol)
300 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
301 struct alc_spec *spec = codec->spec;
302 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
304 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
308 static int alc_mux_enum_put(struct snd_kcontrol *kcontrol,
309 struct snd_ctl_elem_value *ucontrol)
311 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
312 struct alc_spec *spec = codec->spec;
313 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
314 unsigned int mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx;
315 return snd_hda_input_mux_put(codec, &spec->input_mux[mux_idx], ucontrol,
316 spec->adc_nids[adc_idx],
317 &spec->cur_mux[adc_idx]);
322 * channel mode setting
324 static int alc_ch_mode_info(struct snd_kcontrol *kcontrol,
325 struct snd_ctl_elem_info *uinfo)
327 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
328 struct alc_spec *spec = codec->spec;
329 return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
330 spec->num_channel_mode);
333 static int alc_ch_mode_get(struct snd_kcontrol *kcontrol,
334 struct snd_ctl_elem_value *ucontrol)
336 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
337 struct alc_spec *spec = codec->spec;
338 return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
339 spec->num_channel_mode,
340 spec->multiout.max_channels);
343 static int alc_ch_mode_put(struct snd_kcontrol *kcontrol,
344 struct snd_ctl_elem_value *ucontrol)
346 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
347 struct alc_spec *spec = codec->spec;
348 int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
349 spec->num_channel_mode,
350 &spec->multiout.max_channels);
351 if (err >= 0 && spec->need_dac_fix)
352 spec->multiout.num_dacs = spec->multiout.max_channels / 2;
357 * Control the mode of pin widget settings via the mixer. "pc" is used
358 * instead of "%" to avoid consequences of accidently treating the % as
359 * being part of a format specifier. Maximum allowed length of a value is
360 * 63 characters plus NULL terminator.
362 * Note: some retasking pin complexes seem to ignore requests for input
363 * states other than HiZ (eg: PIN_VREFxx) and revert to HiZ if any of these
364 * are requested. Therefore order this list so that this behaviour will not
365 * cause problems when mixer clients move through the enum sequentially.
366 * NIDs 0x0f and 0x10 have been observed to have this behaviour as of
369 static char *alc_pin_mode_names[] = {
370 "Mic 50pc bias", "Mic 80pc bias",
371 "Line in", "Line out", "Headphone out",
373 static unsigned char alc_pin_mode_values[] = {
374 PIN_VREF50, PIN_VREF80, PIN_IN, PIN_OUT, PIN_HP,
376 /* The control can present all 5 options, or it can limit the options based
377 * in the pin being assumed to be exclusively an input or an output pin. In
378 * addition, "input" pins may or may not process the mic bias option
379 * depending on actual widget capability (NIDs 0x0f and 0x10 don't seem to
380 * accept requests for bias as of chip versions up to March 2006) and/or
381 * wiring in the computer.
383 #define ALC_PIN_DIR_IN 0x00
384 #define ALC_PIN_DIR_OUT 0x01
385 #define ALC_PIN_DIR_INOUT 0x02
386 #define ALC_PIN_DIR_IN_NOMICBIAS 0x03
387 #define ALC_PIN_DIR_INOUT_NOMICBIAS 0x04
389 /* Info about the pin modes supported by the different pin direction modes.
390 * For each direction the minimum and maximum values are given.
392 static signed char alc_pin_mode_dir_info[5][2] = {
393 { 0, 2 }, /* ALC_PIN_DIR_IN */
394 { 3, 4 }, /* ALC_PIN_DIR_OUT */
395 { 0, 4 }, /* ALC_PIN_DIR_INOUT */
396 { 2, 2 }, /* ALC_PIN_DIR_IN_NOMICBIAS */
397 { 2, 4 }, /* ALC_PIN_DIR_INOUT_NOMICBIAS */
399 #define alc_pin_mode_min(_dir) (alc_pin_mode_dir_info[_dir][0])
400 #define alc_pin_mode_max(_dir) (alc_pin_mode_dir_info[_dir][1])
401 #define alc_pin_mode_n_items(_dir) \
402 (alc_pin_mode_max(_dir)-alc_pin_mode_min(_dir)+1)
404 static int alc_pin_mode_info(struct snd_kcontrol *kcontrol,
405 struct snd_ctl_elem_info *uinfo)
407 unsigned int item_num = uinfo->value.enumerated.item;
408 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
410 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
412 uinfo->value.enumerated.items = alc_pin_mode_n_items(dir);
414 if (item_num<alc_pin_mode_min(dir) || item_num>alc_pin_mode_max(dir))
415 item_num = alc_pin_mode_min(dir);
416 strcpy(uinfo->value.enumerated.name, alc_pin_mode_names[item_num]);
420 static int alc_pin_mode_get(struct snd_kcontrol *kcontrol,
421 struct snd_ctl_elem_value *ucontrol)
424 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
425 hda_nid_t nid = kcontrol->private_value & 0xffff;
426 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
427 long *valp = ucontrol->value.integer.value;
428 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
429 AC_VERB_GET_PIN_WIDGET_CONTROL,
432 /* Find enumerated value for current pinctl setting */
433 i = alc_pin_mode_min(dir);
434 while (alc_pin_mode_values[i] != pinctl && i <= alc_pin_mode_max(dir))
436 *valp = i <= alc_pin_mode_max(dir) ? i: alc_pin_mode_min(dir);
440 static int alc_pin_mode_put(struct snd_kcontrol *kcontrol,
441 struct snd_ctl_elem_value *ucontrol)
444 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
445 hda_nid_t nid = kcontrol->private_value & 0xffff;
446 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
447 long val = *ucontrol->value.integer.value;
448 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
449 AC_VERB_GET_PIN_WIDGET_CONTROL,
452 if (val < alc_pin_mode_min(dir) || val > alc_pin_mode_max(dir))
453 val = alc_pin_mode_min(dir);
455 change = pinctl != alc_pin_mode_values[val];
457 /* Set pin mode to that requested */
458 snd_hda_codec_write_cache(codec, nid, 0,
459 AC_VERB_SET_PIN_WIDGET_CONTROL,
460 alc_pin_mode_values[val]);
462 /* Also enable the retasking pin's input/output as required
463 * for the requested pin mode. Enum values of 2 or less are
466 * Dynamically switching the input/output buffers probably
467 * reduces noise slightly (particularly on input) so we'll
468 * do it. However, having both input and output buffers
469 * enabled simultaneously doesn't seem to be problematic if
470 * this turns out to be necessary in the future.
473 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
474 HDA_AMP_MUTE, HDA_AMP_MUTE);
475 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
478 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
479 HDA_AMP_MUTE, HDA_AMP_MUTE);
480 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
487 #define ALC_PIN_MODE(xname, nid, dir) \
488 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
489 .info = alc_pin_mode_info, \
490 .get = alc_pin_mode_get, \
491 .put = alc_pin_mode_put, \
492 .private_value = nid | (dir<<16) }
494 /* A switch control for ALC260 GPIO pins. Multiple GPIOs can be ganged
495 * together using a mask with more than one bit set. This control is
496 * currently used only by the ALC260 test model. At this stage they are not
497 * needed for any "production" models.
499 #ifdef CONFIG_SND_DEBUG
500 #define alc_gpio_data_info snd_ctl_boolean_mono_info
502 static int alc_gpio_data_get(struct snd_kcontrol *kcontrol,
503 struct snd_ctl_elem_value *ucontrol)
505 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
506 hda_nid_t nid = kcontrol->private_value & 0xffff;
507 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
508 long *valp = ucontrol->value.integer.value;
509 unsigned int val = snd_hda_codec_read(codec, nid, 0,
510 AC_VERB_GET_GPIO_DATA, 0x00);
512 *valp = (val & mask) != 0;
515 static int alc_gpio_data_put(struct snd_kcontrol *kcontrol,
516 struct snd_ctl_elem_value *ucontrol)
519 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
520 hda_nid_t nid = kcontrol->private_value & 0xffff;
521 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
522 long val = *ucontrol->value.integer.value;
523 unsigned int gpio_data = snd_hda_codec_read(codec, nid, 0,
524 AC_VERB_GET_GPIO_DATA,
527 /* Set/unset the masked GPIO bit(s) as needed */
528 change = (val == 0 ? 0 : mask) != (gpio_data & mask);
533 snd_hda_codec_write_cache(codec, nid, 0,
534 AC_VERB_SET_GPIO_DATA, gpio_data);
538 #define ALC_GPIO_DATA_SWITCH(xname, nid, mask) \
539 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
540 .info = alc_gpio_data_info, \
541 .get = alc_gpio_data_get, \
542 .put = alc_gpio_data_put, \
543 .private_value = nid | (mask<<16) }
544 #endif /* CONFIG_SND_DEBUG */
546 /* A switch control to allow the enabling of the digital IO pins on the
547 * ALC260. This is incredibly simplistic; the intention of this control is
548 * to provide something in the test model allowing digital outputs to be
549 * identified if present. If models are found which can utilise these
550 * outputs a more complete mixer control can be devised for those models if
553 #ifdef CONFIG_SND_DEBUG
554 #define alc_spdif_ctrl_info snd_ctl_boolean_mono_info
556 static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol,
557 struct snd_ctl_elem_value *ucontrol)
559 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
560 hda_nid_t nid = kcontrol->private_value & 0xffff;
561 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
562 long *valp = ucontrol->value.integer.value;
563 unsigned int val = snd_hda_codec_read(codec, nid, 0,
564 AC_VERB_GET_DIGI_CONVERT, 0x00);
566 *valp = (val & mask) != 0;
569 static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol,
570 struct snd_ctl_elem_value *ucontrol)
573 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
574 hda_nid_t nid = kcontrol->private_value & 0xffff;
575 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
576 long val = *ucontrol->value.integer.value;
577 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
578 AC_VERB_GET_DIGI_CONVERT,
581 /* Set/unset the masked control bit(s) as needed */
582 change = (val == 0 ? 0 : mask) != (ctrl_data & mask);
587 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1,
592 #define ALC_SPDIF_CTRL_SWITCH(xname, nid, mask) \
593 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
594 .info = alc_spdif_ctrl_info, \
595 .get = alc_spdif_ctrl_get, \
596 .put = alc_spdif_ctrl_put, \
597 .private_value = nid | (mask<<16) }
598 #endif /* CONFIG_SND_DEBUG */
601 * set up from the preset table
603 static void setup_preset(struct alc_spec *spec,
604 const struct alc_config_preset *preset)
608 for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++)
609 spec->mixers[spec->num_mixers++] = preset->mixers[i];
610 for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i];
612 spec->init_verbs[spec->num_init_verbs++] =
613 preset->init_verbs[i];
615 spec->channel_mode = preset->channel_mode;
616 spec->num_channel_mode = preset->num_channel_mode;
617 spec->need_dac_fix = preset->need_dac_fix;
619 spec->multiout.max_channels = spec->channel_mode[0].channels;
621 spec->multiout.num_dacs = preset->num_dacs;
622 spec->multiout.dac_nids = preset->dac_nids;
623 spec->multiout.dig_out_nid = preset->dig_out_nid;
624 spec->multiout.hp_nid = preset->hp_nid;
626 spec->num_mux_defs = preset->num_mux_defs;
627 if (!spec->num_mux_defs)
628 spec->num_mux_defs = 1;
629 spec->input_mux = preset->input_mux;
631 spec->num_adc_nids = preset->num_adc_nids;
632 spec->adc_nids = preset->adc_nids;
633 spec->dig_in_nid = preset->dig_in_nid;
635 spec->unsol_event = preset->unsol_event;
636 spec->init_hook = preset->init_hook;
637 #ifdef CONFIG_SND_HDA_POWER_SAVE
638 spec->loopback.amplist = preset->loopbacks;
642 /* Enable GPIO mask and set output */
643 static struct hda_verb alc_gpio1_init_verbs[] = {
644 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
645 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
646 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
650 static struct hda_verb alc_gpio2_init_verbs[] = {
651 {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
652 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
653 {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
657 static struct hda_verb alc_gpio3_init_verbs[] = {
658 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
659 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
660 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
664 /* 32-bit subsystem ID for BIOS loading in HD Audio codec.
665 * 31 ~ 16 : Manufacture ID
667 * 7 ~ 0 : Assembly ID
668 * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36
670 static void alc_subsystem_id(struct hda_codec *codec,
671 unsigned int porta, unsigned int porte,
674 unsigned int ass, tmp;
676 ass = codec->subsystem_id;
681 tmp = (ass & 0x38) >> 3; /* external Amp control */
684 snd_hda_sequence_write(codec, alc_gpio1_init_verbs);
687 snd_hda_sequence_write(codec, alc_gpio2_init_verbs);
690 snd_hda_sequence_write(codec, alc_gpio3_init_verbs);
693 switch (codec->vendor_id) {
699 snd_hda_codec_write(codec, 0x14, 0,
700 AC_VERB_SET_EAPD_BTLENABLE, 2);
701 snd_hda_codec_write(codec, 0x15, 0,
702 AC_VERB_SET_EAPD_BTLENABLE, 2);
706 if (ass & 4) { /* bit 2 : 0 = Desktop, 1 = Laptop */
708 tmp = (ass & 0x1800) >> 11;
710 case 0: port = porta; break;
711 case 1: port = porte; break;
712 case 2: port = portd; break;
715 snd_hda_codec_write(codec, port, 0,
716 AC_VERB_SET_EAPD_BTLENABLE,
719 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
720 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF,
721 (tmp == 5 ? 0x3040 : 0x3050));
727 * Fix-up pin default configurations
735 static void alc_fix_pincfg(struct hda_codec *codec,
736 const struct snd_pci_quirk *quirk,
737 const struct alc_pincfg **pinfix)
739 const struct alc_pincfg *cfg;
741 quirk = snd_pci_quirk_lookup(codec->bus->pci, quirk);
745 cfg = pinfix[quirk->value];
746 for (; cfg->nid; cfg++) {
749 for (i = 0; i < 4; i++) {
750 snd_hda_codec_write(codec, cfg->nid, 0,
751 AC_VERB_SET_CONFIG_DEFAULT_BYTES_0 + i,
759 * ALC880 3-stack model
761 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
762 * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18,
763 * F-Mic = 0x1b, HP = 0x19
766 static hda_nid_t alc880_dac_nids[4] = {
767 /* front, rear, clfe, rear_surr */
768 0x02, 0x05, 0x04, 0x03
771 static hda_nid_t alc880_adc_nids[3] = {
776 /* The datasheet says the node 0x07 is connected from inputs,
777 * but it shows zero connection in the real implementation on some devices.
778 * Note: this is a 915GAV bug, fixed on 915GLV
780 static hda_nid_t alc880_adc_nids_alt[2] = {
785 #define ALC880_DIGOUT_NID 0x06
786 #define ALC880_DIGIN_NID 0x0a
788 static struct hda_input_mux alc880_capture_source = {
792 { "Front Mic", 0x3 },
798 /* channel source setting (2/6 channel selection for 3-stack) */
800 static struct hda_verb alc880_threestack_ch2_init[] = {
801 /* set line-in to input, mute it */
802 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
803 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
804 /* set mic-in to input vref 80%, mute it */
805 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
806 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
811 static struct hda_verb alc880_threestack_ch6_init[] = {
812 /* set line-in to output, unmute it */
813 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
814 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
815 /* set mic-in to output, unmute it */
816 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
817 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
821 static struct hda_channel_mode alc880_threestack_modes[2] = {
822 { 2, alc880_threestack_ch2_init },
823 { 6, alc880_threestack_ch6_init },
826 static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
827 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
828 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
829 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
830 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
831 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
832 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
833 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
834 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
835 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
836 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
837 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
838 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
839 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
840 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
841 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
842 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
843 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
844 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
845 HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
847 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
848 .name = "Channel Mode",
849 .info = alc_ch_mode_info,
850 .get = alc_ch_mode_get,
851 .put = alc_ch_mode_put,
856 /* capture mixer elements */
857 static struct snd_kcontrol_new alc880_capture_mixer[] = {
858 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
859 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
860 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
861 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
862 HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
863 HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
865 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
866 /* The multiple "Capture Source" controls confuse alsamixer
867 * So call somewhat different..
868 * FIXME: the controls appear in the "playback" view!
870 /* .name = "Capture Source", */
871 .name = "Input Source",
873 .info = alc_mux_enum_info,
874 .get = alc_mux_enum_get,
875 .put = alc_mux_enum_put,
880 /* capture mixer elements (in case NID 0x07 not available) */
881 static struct snd_kcontrol_new alc880_capture_alt_mixer[] = {
882 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
883 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
884 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
885 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
887 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
888 /* The multiple "Capture Source" controls confuse alsamixer
889 * So call somewhat different..
890 * FIXME: the controls appear in the "playback" view!
892 /* .name = "Capture Source", */
893 .name = "Input Source",
895 .info = alc_mux_enum_info,
896 .get = alc_mux_enum_get,
897 .put = alc_mux_enum_put,
905 * ALC880 5-stack model
907 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d),
909 * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
910 * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
913 /* additional mixers to alc880_three_stack_mixer */
914 static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
915 HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
916 HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
920 /* channel source setting (6/8 channel selection for 5-stack) */
922 static struct hda_verb alc880_fivestack_ch6_init[] = {
923 /* set line-in to input, mute it */
924 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
925 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
930 static struct hda_verb alc880_fivestack_ch8_init[] = {
931 /* set line-in to output, unmute it */
932 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
933 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
937 static struct hda_channel_mode alc880_fivestack_modes[2] = {
938 { 6, alc880_fivestack_ch6_init },
939 { 8, alc880_fivestack_ch8_init },
944 * ALC880 6-stack model
946 * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e),
948 * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
949 * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
952 static hda_nid_t alc880_6st_dac_nids[4] = {
953 /* front, rear, clfe, rear_surr */
954 0x02, 0x03, 0x04, 0x05
957 static struct hda_input_mux alc880_6stack_capture_source = {
961 { "Front Mic", 0x1 },
967 /* fixed 8-channels */
968 static struct hda_channel_mode alc880_sixstack_modes[1] = {
972 static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
973 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
974 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
975 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
976 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
977 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
978 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
979 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
980 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
981 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
982 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
983 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
984 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
985 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
986 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
987 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
988 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
989 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
990 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
991 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
992 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
994 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
995 .name = "Channel Mode",
996 .info = alc_ch_mode_info,
997 .get = alc_ch_mode_get,
998 .put = alc_ch_mode_put,
1007 * W810 has rear IO for:
1010 * Center/LFE (DAC 04)
1013 * The system also has a pair of internal speakers, and a headphone jack.
1014 * These are both connected to Line2 on the codec, hence to DAC 02.
1016 * There is a variable resistor to control the speaker or headphone
1017 * volume. This is a hardware-only device without a software API.
1019 * Plugging headphones in will disable the internal speakers. This is
1020 * implemented in hardware, not via the driver using jack sense. In
1021 * a similar fashion, plugging into the rear socket marked "front" will
1022 * disable both the speakers and headphones.
1024 * For input, there's a microphone jack, and an "audio in" jack.
1025 * These may not do anything useful with this driver yet, because I
1026 * haven't setup any initialization verbs for these yet...
1029 static hda_nid_t alc880_w810_dac_nids[3] = {
1030 /* front, rear/surround, clfe */
1034 /* fixed 6 channels */
1035 static struct hda_channel_mode alc880_w810_modes[1] = {
1039 /* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
1040 static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
1041 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1042 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1043 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1044 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
1045 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1046 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1047 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1048 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1049 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
1057 * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
1058 * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?),
1062 static hda_nid_t alc880_z71v_dac_nids[1] = {
1065 #define ALC880_Z71V_HP_DAC 0x03
1067 /* fixed 2 channels */
1068 static struct hda_channel_mode alc880_2_jack_modes[1] = {
1072 static struct snd_kcontrol_new alc880_z71v_mixer[] = {
1073 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1074 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1075 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1076 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
1077 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1078 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1079 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1080 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1087 * ALC880 F1734 model
1089 * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
1090 * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
1093 static hda_nid_t alc880_f1734_dac_nids[1] = {
1096 #define ALC880_F1734_HP_DAC 0x02
1098 static struct snd_kcontrol_new alc880_f1734_mixer[] = {
1099 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1100 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
1101 HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1102 HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
1103 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1104 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1105 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1106 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1115 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
1116 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
1117 * Mic = 0x18, Line = 0x1a
1120 #define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
1121 #define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
1123 static struct snd_kcontrol_new alc880_asus_mixer[] = {
1124 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1125 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1126 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1127 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
1128 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1129 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1130 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1131 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1132 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1133 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1134 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1135 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1136 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1137 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1139 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1140 .name = "Channel Mode",
1141 .info = alc_ch_mode_info,
1142 .get = alc_ch_mode_get,
1143 .put = alc_ch_mode_put,
1150 * ALC880 ASUS W1V model
1152 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
1153 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
1154 * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
1157 /* additional mixers to alc880_asus_mixer */
1158 static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
1159 HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
1160 HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
1164 /* additional mixers to alc880_asus_mixer */
1165 static struct snd_kcontrol_new alc880_pcbeep_mixer[] = {
1166 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1167 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
1172 static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
1173 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1174 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
1175 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
1176 HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
1177 HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
1178 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
1179 HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
1180 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
1181 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
1183 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1184 /* The multiple "Capture Source" controls confuse alsamixer
1185 * So call somewhat different..
1186 * FIXME: the controls appear in the "playback" view!
1188 /* .name = "Capture Source", */
1189 .name = "Input Source",
1191 .info = alc_mux_enum_info,
1192 .get = alc_mux_enum_get,
1193 .put = alc_mux_enum_put,
1199 static struct snd_kcontrol_new alc880_uniwill_mixer[] = {
1200 HDA_CODEC_VOLUME("HPhone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1201 HDA_BIND_MUTE("HPhone Playback Switch", 0x0c, 2, HDA_INPUT),
1202 HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1203 HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT),
1204 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1205 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1206 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1207 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1208 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1209 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1210 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1211 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1212 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1213 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1214 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1215 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1216 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1217 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
1219 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1220 .name = "Channel Mode",
1221 .info = alc_ch_mode_info,
1222 .get = alc_ch_mode_get,
1223 .put = alc_ch_mode_put,
1228 static struct snd_kcontrol_new alc880_fujitsu_mixer[] = {
1229 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1230 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
1231 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1232 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
1233 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1234 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1235 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1236 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1237 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1238 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1242 static struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = {
1243 HDA_CODEC_VOLUME("HPhone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1244 HDA_BIND_MUTE("HPhone Playback Switch", 0x0c, 2, HDA_INPUT),
1245 HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1246 HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT),
1247 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1248 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1253 * build control elements
1255 static int alc_build_controls(struct hda_codec *codec)
1257 struct alc_spec *spec = codec->spec;
1261 for (i = 0; i < spec->num_mixers; i++) {
1262 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
1267 if (spec->multiout.dig_out_nid) {
1268 err = snd_hda_create_spdif_out_ctls(codec,
1269 spec->multiout.dig_out_nid);
1273 if (spec->dig_in_nid) {
1274 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
1283 * initialize the codec volumes, etc
1287 * generic initialization of ADC, input mixers and output mixers
1289 static struct hda_verb alc880_volume_init_verbs[] = {
1291 * Unmute ADC0-2 and set the default input to mic-in
1293 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
1294 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1295 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
1296 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1297 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
1298 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1300 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
1302 * Note: PASD motherboards uses the Line In 2 as the input for front
1305 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
1306 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1307 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1308 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
1309 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
1310 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
1311 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
1312 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
1315 * Set up output mixers (0x0c - 0x0f)
1317 /* set vol=0 to output mixers */
1318 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1319 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1320 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1321 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1322 /* set up input amps for analog loopback */
1323 /* Amp Indices: DAC = 0, mixer = 1 */
1324 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1325 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1326 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1327 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1328 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1329 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1330 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1331 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1337 * 3-stack pin configuration:
1338 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
1340 static struct hda_verb alc880_pin_3stack_init_verbs[] = {
1342 * preset connection lists of input pins
1343 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
1345 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
1346 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1347 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
1350 * Set pin mode and muting
1352 /* set front pin widgets 0x14 for output */
1353 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1354 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1355 /* Mic1 (rear panel) pin widget for input and vref at 80% */
1356 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1357 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1358 /* Mic2 (as headphone out) for HP output */
1359 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1360 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1361 /* Line In pin widget for input */
1362 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1363 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1364 /* Line2 (as front mic) pin widget for input and vref at 80% */
1365 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1366 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1367 /* CD pin widget for input */
1368 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1374 * 5-stack pin configuration:
1375 * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
1376 * line-in/side = 0x1a, f-mic = 0x1b
1378 static struct hda_verb alc880_pin_5stack_init_verbs[] = {
1380 * preset connection lists of input pins
1381 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
1383 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1384 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
1387 * Set pin mode and muting
1389 /* set pin widgets 0x14-0x17 for output */
1390 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1391 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1392 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1393 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1394 /* unmute pins for output (no gain on this amp) */
1395 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1396 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1397 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1398 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1400 /* Mic1 (rear panel) pin widget for input and vref at 80% */
1401 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1402 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1403 /* Mic2 (as headphone out) for HP output */
1404 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1405 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1406 /* Line In pin widget for input */
1407 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1408 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1409 /* Line2 (as front mic) pin widget for input and vref at 80% */
1410 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1411 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1412 /* CD pin widget for input */
1413 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1419 * W810 pin configuration:
1420 * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
1422 static struct hda_verb alc880_pin_w810_init_verbs[] = {
1423 /* hphone/speaker input selector: front DAC */
1424 {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
1426 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1427 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1428 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1429 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1430 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1431 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1433 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1434 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1440 * Z71V pin configuration:
1441 * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
1443 static struct hda_verb alc880_pin_z71v_init_verbs[] = {
1444 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1445 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1446 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1447 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1449 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1450 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1451 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1452 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1458 * 6-stack pin configuration:
1459 * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18,
1460 * f-mic = 0x19, line = 0x1a, HP = 0x1b
1462 static struct hda_verb alc880_pin_6stack_init_verbs[] = {
1463 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1465 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1466 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1467 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1468 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1469 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1470 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1471 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1472 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1474 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1475 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1476 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1477 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1478 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1479 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1480 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1481 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1482 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1488 * Uniwill pin configuration:
1489 * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19,
1492 static struct hda_verb alc880_uniwill_init_verbs[] = {
1493 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1495 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1496 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1497 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1498 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1499 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1500 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1501 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1502 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1503 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1504 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1505 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1506 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1507 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1508 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1510 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1511 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1512 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1513 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1514 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1515 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1516 /* {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, */
1517 /* {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
1518 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1520 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
1521 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
1528 * HP = 0x14, InternalSpeaker = 0x15, mic = 0x19,
1530 static struct hda_verb alc880_uniwill_p53_init_verbs[] = {
1531 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1533 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1534 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1535 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1536 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1537 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1538 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1539 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1540 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1541 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1542 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1543 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1544 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1546 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1547 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1548 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1549 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1550 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1551 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1553 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
1554 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_DCVOL_EVENT},
1559 static struct hda_verb alc880_beep_init_verbs[] = {
1560 { 0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5) },
1564 /* toggle speaker-output according to the hp-jack state */
1565 static void alc880_uniwill_hp_automute(struct hda_codec *codec)
1567 unsigned int present;
1570 present = snd_hda_codec_read(codec, 0x14, 0,
1571 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1572 bits = present ? HDA_AMP_MUTE : 0;
1573 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
1574 HDA_AMP_MUTE, bits);
1575 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
1576 HDA_AMP_MUTE, bits);
1579 /* auto-toggle front mic */
1580 static void alc880_uniwill_mic_automute(struct hda_codec *codec)
1582 unsigned int present;
1585 present = snd_hda_codec_read(codec, 0x18, 0,
1586 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1587 bits = present ? HDA_AMP_MUTE : 0;
1588 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
1591 static void alc880_uniwill_automute(struct hda_codec *codec)
1593 alc880_uniwill_hp_automute(codec);
1594 alc880_uniwill_mic_automute(codec);
1597 static void alc880_uniwill_unsol_event(struct hda_codec *codec,
1600 /* Looks like the unsol event is incompatible with the standard
1601 * definition. 4bit tag is placed at 28 bit!
1603 switch (res >> 28) {
1604 case ALC880_HP_EVENT:
1605 alc880_uniwill_hp_automute(codec);
1607 case ALC880_MIC_EVENT:
1608 alc880_uniwill_mic_automute(codec);
1613 static void alc880_uniwill_p53_hp_automute(struct hda_codec *codec)
1615 unsigned int present;
1618 present = snd_hda_codec_read(codec, 0x14, 0,
1619 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1620 bits = present ? HDA_AMP_MUTE : 0;
1621 snd_hda_codec_amp_stereo(codec, 0x15, HDA_INPUT, 0, HDA_AMP_MUTE, bits);
1624 static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec)
1626 unsigned int present;
1628 present = snd_hda_codec_read(codec, 0x21, 0,
1629 AC_VERB_GET_VOLUME_KNOB_CONTROL, 0);
1630 present &= HDA_AMP_VOLMASK;
1631 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0,
1632 HDA_AMP_VOLMASK, present);
1633 snd_hda_codec_amp_stereo(codec, 0x0d, HDA_OUTPUT, 0,
1634 HDA_AMP_VOLMASK, present);
1637 static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec,
1640 /* Looks like the unsol event is incompatible with the standard
1641 * definition. 4bit tag is placed at 28 bit!
1643 if ((res >> 28) == ALC880_HP_EVENT)
1644 alc880_uniwill_p53_hp_automute(codec);
1645 if ((res >> 28) == ALC880_DCVOL_EVENT)
1646 alc880_uniwill_p53_dcvol_automute(codec);
1651 * F1734 pin configuration:
1652 * HP = 0x14, speaker-out = 0x15, mic = 0x18
1654 static struct hda_verb alc880_pin_f1734_init_verbs[] = {
1655 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
1656 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
1657 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
1658 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
1660 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1661 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1662 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1663 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1665 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1666 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1667 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1668 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1669 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1670 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1671 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1672 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1673 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1680 * ASUS pin configuration:
1681 * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
1683 static struct hda_verb alc880_pin_asus_init_verbs[] = {
1684 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
1685 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
1686 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
1687 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
1689 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1690 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1691 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1692 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1693 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1694 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1695 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1696 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1698 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1699 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1700 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1701 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1702 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1703 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1704 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1705 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1706 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1711 /* Enable GPIO mask and set output */
1712 #define alc880_gpio1_init_verbs alc_gpio1_init_verbs
1713 #define alc880_gpio2_init_verbs alc_gpio2_init_verbs
1715 /* Clevo m520g init */
1716 static struct hda_verb alc880_pin_clevo_init_verbs[] = {
1717 /* headphone output */
1718 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
1720 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1721 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1723 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1724 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1726 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1727 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1728 /* Mic1 (rear panel) */
1729 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1730 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1731 /* Mic2 (front panel) */
1732 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1733 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1735 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1736 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1737 /* change to EAPD mode */
1738 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
1739 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
1744 static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
1745 /* change to EAPD mode */
1746 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
1747 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
1749 /* Headphone output */
1750 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1752 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1753 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
1755 /* Line In pin widget for input */
1756 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1757 /* CD pin widget for input */
1758 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1759 /* Mic1 (rear panel) pin widget for input and vref at 80% */
1760 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1762 /* change to EAPD mode */
1763 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
1764 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
1770 * LG m1 express dual
1773 * Rear Line-In/Out (blue): 0x14
1774 * Build-in Mic-In: 0x15
1776 * HP-Out (green): 0x1b
1777 * Mic-In/Out (red): 0x19
1781 /* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
1782 static hda_nid_t alc880_lg_dac_nids[3] = {
1786 /* seems analog CD is not working */
1787 static struct hda_input_mux alc880_lg_capture_source = {
1792 { "Internal Mic", 0x6 },
1796 /* 2,4,6 channel modes */
1797 static struct hda_verb alc880_lg_ch2_init[] = {
1798 /* set line-in and mic-in to input */
1799 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1800 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1804 static struct hda_verb alc880_lg_ch4_init[] = {
1805 /* set line-in to out and mic-in to input */
1806 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
1807 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1811 static struct hda_verb alc880_lg_ch6_init[] = {
1812 /* set line-in and mic-in to output */
1813 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
1814 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
1818 static struct hda_channel_mode alc880_lg_ch_modes[3] = {
1819 { 2, alc880_lg_ch2_init },
1820 { 4, alc880_lg_ch4_init },
1821 { 6, alc880_lg_ch6_init },
1824 static struct snd_kcontrol_new alc880_lg_mixer[] = {
1825 /* FIXME: it's not really "master" but front channels */
1826 HDA_CODEC_VOLUME("Master Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
1827 HDA_BIND_MUTE("Master Playback Switch", 0x0f, 2, HDA_INPUT),
1828 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1829 HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
1830 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
1831 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
1832 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
1833 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
1834 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1835 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1836 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
1837 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
1838 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
1839 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
1841 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1842 .name = "Channel Mode",
1843 .info = alc_ch_mode_info,
1844 .get = alc_ch_mode_get,
1845 .put = alc_ch_mode_put,
1850 static struct hda_verb alc880_lg_init_verbs[] = {
1851 /* set capture source to mic-in */
1852 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1853 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1854 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1855 /* mute all amp mixer inputs */
1856 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
1857 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
1858 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
1859 /* line-in to input */
1860 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1861 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1863 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1864 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1866 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1867 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1868 /* mic-in to input */
1869 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
1870 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1871 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1873 {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
1874 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1875 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1877 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
1881 /* toggle speaker-output according to the hp-jack state */
1882 static void alc880_lg_automute(struct hda_codec *codec)
1884 unsigned int present;
1887 present = snd_hda_codec_read(codec, 0x1b, 0,
1888 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1889 bits = present ? HDA_AMP_MUTE : 0;
1890 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
1891 HDA_AMP_MUTE, bits);
1894 static void alc880_lg_unsol_event(struct hda_codec *codec, unsigned int res)
1896 /* Looks like the unsol event is incompatible with the standard
1897 * definition. 4bit tag is placed at 28 bit!
1899 if ((res >> 28) == 0x01)
1900 alc880_lg_automute(codec);
1909 * Built-in Mic-In: 0x19
1915 static struct hda_input_mux alc880_lg_lw_capture_source = {
1919 { "Internal Mic", 0x1 },
1924 #define alc880_lg_lw_modes alc880_threestack_modes
1926 static struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
1927 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1928 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1929 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
1930 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
1931 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1932 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1933 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1934 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1935 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1936 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1937 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1938 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1939 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
1940 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
1942 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1943 .name = "Channel Mode",
1944 .info = alc_ch_mode_info,
1945 .get = alc_ch_mode_get,
1946 .put = alc_ch_mode_put,
1951 static struct hda_verb alc880_lg_lw_init_verbs[] = {
1952 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1953 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
1954 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
1956 /* set capture source to mic-in */
1957 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1958 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1959 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1960 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
1962 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1963 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1965 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1966 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1967 /* mic-in to input */
1968 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1969 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1971 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1972 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1974 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
1978 /* toggle speaker-output according to the hp-jack state */
1979 static void alc880_lg_lw_automute(struct hda_codec *codec)
1981 unsigned int present;
1984 present = snd_hda_codec_read(codec, 0x1b, 0,
1985 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1986 bits = present ? HDA_AMP_MUTE : 0;
1987 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
1988 HDA_AMP_MUTE, bits);
1991 static void alc880_lg_lw_unsol_event(struct hda_codec *codec, unsigned int res)
1993 /* Looks like the unsol event is incompatible with the standard
1994 * definition. 4bit tag is placed at 28 bit!
1996 if ((res >> 28) == 0x01)
1997 alc880_lg_lw_automute(codec);
2000 #ifdef CONFIG_SND_HDA_POWER_SAVE
2001 static struct hda_amp_list alc880_loopbacks[] = {
2002 { 0x0b, HDA_INPUT, 0 },
2003 { 0x0b, HDA_INPUT, 1 },
2004 { 0x0b, HDA_INPUT, 2 },
2005 { 0x0b, HDA_INPUT, 3 },
2006 { 0x0b, HDA_INPUT, 4 },
2010 static struct hda_amp_list alc880_lg_loopbacks[] = {
2011 { 0x0b, HDA_INPUT, 1 },
2012 { 0x0b, HDA_INPUT, 6 },
2013 { 0x0b, HDA_INPUT, 7 },
2022 static int alc_init(struct hda_codec *codec)
2024 struct alc_spec *spec = codec->spec;
2027 for (i = 0; i < spec->num_init_verbs; i++)
2028 snd_hda_sequence_write(codec, spec->init_verbs[i]);
2030 if (spec->init_hook)
2031 spec->init_hook(codec);
2036 static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
2038 struct alc_spec *spec = codec->spec;
2040 if (spec->unsol_event)
2041 spec->unsol_event(codec, res);
2044 #ifdef CONFIG_SND_HDA_POWER_SAVE
2045 static int alc_check_power_status(struct hda_codec *codec, hda_nid_t nid)
2047 struct alc_spec *spec = codec->spec;
2048 return snd_hda_check_amp_list_power(codec, &spec->loopback, nid);
2053 * Analog playback callbacks
2055 static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
2056 struct hda_codec *codec,
2057 struct snd_pcm_substream *substream)
2059 struct alc_spec *spec = codec->spec;
2060 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream);
2063 static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2064 struct hda_codec *codec,
2065 unsigned int stream_tag,
2066 unsigned int format,
2067 struct snd_pcm_substream *substream)
2069 struct alc_spec *spec = codec->spec;
2070 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
2071 stream_tag, format, substream);
2074 static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
2075 struct hda_codec *codec,
2076 struct snd_pcm_substream *substream)
2078 struct alc_spec *spec = codec->spec;
2079 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
2085 static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
2086 struct hda_codec *codec,
2087 struct snd_pcm_substream *substream)
2089 struct alc_spec *spec = codec->spec;
2090 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
2093 static int alc880_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2094 struct hda_codec *codec,
2095 unsigned int stream_tag,
2096 unsigned int format,
2097 struct snd_pcm_substream *substream)
2099 struct alc_spec *spec = codec->spec;
2100 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
2101 stream_tag, format, substream);
2104 static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
2105 struct hda_codec *codec,
2106 struct snd_pcm_substream *substream)
2108 struct alc_spec *spec = codec->spec;
2109 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
2115 static int alc880_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
2116 struct hda_codec *codec,
2117 unsigned int stream_tag,
2118 unsigned int format,
2119 struct snd_pcm_substream *substream)
2121 struct alc_spec *spec = codec->spec;
2123 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
2124 stream_tag, 0, format);
2128 static int alc880_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
2129 struct hda_codec *codec,
2130 struct snd_pcm_substream *substream)
2132 struct alc_spec *spec = codec->spec;
2134 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
2142 static struct hda_pcm_stream alc880_pcm_analog_playback = {
2146 /* NID is set in alc_build_pcms */
2148 .open = alc880_playback_pcm_open,
2149 .prepare = alc880_playback_pcm_prepare,
2150 .cleanup = alc880_playback_pcm_cleanup
2154 static struct hda_pcm_stream alc880_pcm_analog_capture = {
2158 /* NID is set in alc_build_pcms */
2160 .prepare = alc880_capture_pcm_prepare,
2161 .cleanup = alc880_capture_pcm_cleanup
2165 static struct hda_pcm_stream alc880_pcm_digital_playback = {
2169 /* NID is set in alc_build_pcms */
2171 .open = alc880_dig_playback_pcm_open,
2172 .close = alc880_dig_playback_pcm_close,
2173 .prepare = alc880_dig_playback_pcm_prepare
2177 static struct hda_pcm_stream alc880_pcm_digital_capture = {
2181 /* NID is set in alc_build_pcms */
2184 /* Used by alc_build_pcms to flag that a PCM has no playback stream */
2185 static struct hda_pcm_stream alc_pcm_null_playback = {
2191 static int alc_build_pcms(struct hda_codec *codec)
2193 struct alc_spec *spec = codec->spec;
2194 struct hda_pcm *info = spec->pcm_rec;
2197 codec->num_pcms = 1;
2198 codec->pcm_info = info;
2200 info->name = spec->stream_name_analog;
2201 if (spec->stream_analog_playback) {
2202 snd_assert(spec->multiout.dac_nids, return -EINVAL);
2203 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
2204 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
2206 if (spec->stream_analog_capture) {
2207 snd_assert(spec->adc_nids, return -EINVAL);
2208 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
2209 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
2212 if (spec->channel_mode) {
2213 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
2214 for (i = 0; i < spec->num_channel_mode; i++) {
2215 if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
2216 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
2221 /* SPDIF for stream index #1 */
2222 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
2223 codec->num_pcms = 2;
2224 info = spec->pcm_rec + 1;
2225 info->name = spec->stream_name_digital;
2226 if (spec->multiout.dig_out_nid &&
2227 spec->stream_digital_playback) {
2228 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
2229 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
2231 if (spec->dig_in_nid &&
2232 spec->stream_digital_capture) {
2233 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
2234 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
2238 /* If the use of more than one ADC is requested for the current
2239 * model, configure a second analog capture-only PCM.
2241 /* Additional Analaog capture for index #2 */
2242 if (spec->num_adc_nids > 1 && spec->stream_analog_capture &&
2244 codec->num_pcms = 3;
2245 info = spec->pcm_rec + 2;
2246 info->name = spec->stream_name_analog;
2247 /* No playback stream for second PCM */
2248 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = alc_pcm_null_playback;
2249 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
2250 if (spec->stream_analog_capture) {
2251 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
2252 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[1];
2259 static void alc_free(struct hda_codec *codec)
2261 struct alc_spec *spec = codec->spec;
2267 if (spec->kctl_alloc) {
2268 for (i = 0; i < spec->num_kctl_used; i++)
2269 kfree(spec->kctl_alloc[i].name);
2270 kfree(spec->kctl_alloc);
2277 static struct hda_codec_ops alc_patch_ops = {
2278 .build_controls = alc_build_controls,
2279 .build_pcms = alc_build_pcms,
2282 .unsol_event = alc_unsol_event,
2283 #ifdef CONFIG_SND_HDA_POWER_SAVE
2284 .check_power_status = alc_check_power_status,
2290 * Test configuration for debugging
2292 * Almost all inputs/outputs are enabled. I/O pins can be configured via
2295 #ifdef CONFIG_SND_DEBUG
2296 static hda_nid_t alc880_test_dac_nids[4] = {
2297 0x02, 0x03, 0x04, 0x05
2300 static struct hda_input_mux alc880_test_capture_source = {
2309 { "Surround", 0x6 },
2313 static struct hda_channel_mode alc880_test_modes[4] = {
2320 static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol,
2321 struct snd_ctl_elem_info *uinfo)
2323 static char *texts[] = {
2324 "N/A", "Line Out", "HP Out",
2325 "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
2327 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
2329 uinfo->value.enumerated.items = 8;
2330 if (uinfo->value.enumerated.item >= 8)
2331 uinfo->value.enumerated.item = 7;
2332 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
2336 static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol,
2337 struct snd_ctl_elem_value *ucontrol)
2339 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2340 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2341 unsigned int pin_ctl, item = 0;
2343 pin_ctl = snd_hda_codec_read(codec, nid, 0,
2344 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
2345 if (pin_ctl & AC_PINCTL_OUT_EN) {
2346 if (pin_ctl & AC_PINCTL_HP_EN)
2350 } else if (pin_ctl & AC_PINCTL_IN_EN) {
2351 switch (pin_ctl & AC_PINCTL_VREFEN) {
2352 case AC_PINCTL_VREF_HIZ: item = 3; break;
2353 case AC_PINCTL_VREF_50: item = 4; break;
2354 case AC_PINCTL_VREF_GRD: item = 5; break;
2355 case AC_PINCTL_VREF_80: item = 6; break;
2356 case AC_PINCTL_VREF_100: item = 7; break;
2359 ucontrol->value.enumerated.item[0] = item;
2363 static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol,
2364 struct snd_ctl_elem_value *ucontrol)
2366 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2367 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2368 static unsigned int ctls[] = {
2369 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
2370 AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
2371 AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
2372 AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
2373 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
2374 AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
2376 unsigned int old_ctl, new_ctl;
2378 old_ctl = snd_hda_codec_read(codec, nid, 0,
2379 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
2380 new_ctl = ctls[ucontrol->value.enumerated.item[0]];
2381 if (old_ctl != new_ctl) {
2383 snd_hda_codec_write_cache(codec, nid, 0,
2384 AC_VERB_SET_PIN_WIDGET_CONTROL,
2386 val = ucontrol->value.enumerated.item[0] >= 3 ?
2388 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
2395 static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol,
2396 struct snd_ctl_elem_info *uinfo)
2398 static char *texts[] = {
2399 "Front", "Surround", "CLFE", "Side"
2401 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
2403 uinfo->value.enumerated.items = 4;
2404 if (uinfo->value.enumerated.item >= 4)
2405 uinfo->value.enumerated.item = 3;
2406 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
2410 static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol,
2411 struct snd_ctl_elem_value *ucontrol)
2413 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2414 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2417 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
2418 ucontrol->value.enumerated.item[0] = sel & 3;
2422 static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol,
2423 struct snd_ctl_elem_value *ucontrol)
2425 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2426 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2429 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
2430 if (ucontrol->value.enumerated.item[0] != sel) {
2431 sel = ucontrol->value.enumerated.item[0] & 3;
2432 snd_hda_codec_write_cache(codec, nid, 0,
2433 AC_VERB_SET_CONNECT_SEL, sel);
2439 #define PIN_CTL_TEST(xname,nid) { \
2440 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2442 .info = alc_test_pin_ctl_info, \
2443 .get = alc_test_pin_ctl_get, \
2444 .put = alc_test_pin_ctl_put, \
2445 .private_value = nid \
2448 #define PIN_SRC_TEST(xname,nid) { \
2449 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2451 .info = alc_test_pin_src_info, \
2452 .get = alc_test_pin_src_get, \
2453 .put = alc_test_pin_src_put, \
2454 .private_value = nid \
2457 static struct snd_kcontrol_new alc880_test_mixer[] = {
2458 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2459 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2460 HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
2461 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
2462 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2463 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
2464 HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
2465 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
2466 PIN_CTL_TEST("Front Pin Mode", 0x14),
2467 PIN_CTL_TEST("Surround Pin Mode", 0x15),
2468 PIN_CTL_TEST("CLFE Pin Mode", 0x16),
2469 PIN_CTL_TEST("Side Pin Mode", 0x17),
2470 PIN_CTL_TEST("In-1 Pin Mode", 0x18),
2471 PIN_CTL_TEST("In-2 Pin Mode", 0x19),
2472 PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
2473 PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
2474 PIN_SRC_TEST("In-1 Pin Source", 0x18),
2475 PIN_SRC_TEST("In-2 Pin Source", 0x19),
2476 PIN_SRC_TEST("In-3 Pin Source", 0x1a),
2477 PIN_SRC_TEST("In-4 Pin Source", 0x1b),
2478 HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
2479 HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
2480 HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
2481 HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
2482 HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
2483 HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
2484 HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
2485 HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
2486 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
2487 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
2489 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2490 .name = "Channel Mode",
2491 .info = alc_ch_mode_info,
2492 .get = alc_ch_mode_get,
2493 .put = alc_ch_mode_put,
2498 static struct hda_verb alc880_test_init_verbs[] = {
2499 /* Unmute inputs of 0x0c - 0x0f */
2500 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2501 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2502 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2503 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2504 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2505 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2506 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2507 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2508 /* Vol output for 0x0c-0x0f */
2509 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2510 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2511 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2512 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2513 /* Set output pins 0x14-0x17 */
2514 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2515 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2516 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2517 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2518 /* Unmute output pins 0x14-0x17 */
2519 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2520 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2521 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2522 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2523 /* Set input pins 0x18-0x1c */
2524 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2525 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2526 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2527 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2528 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2529 /* Mute input pins 0x18-0x1b */
2530 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2531 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2532 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2533 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2535 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2536 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
2537 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2538 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
2539 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2540 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
2541 /* Analog input/passthru */
2542 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2543 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2544 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
2545 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
2546 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
2554 static const char *alc880_models[ALC880_MODEL_LAST] = {
2555 [ALC880_3ST] = "3stack",
2556 [ALC880_TCL_S700] = "tcl",
2557 [ALC880_3ST_DIG] = "3stack-digout",
2558 [ALC880_CLEVO] = "clevo",
2559 [ALC880_5ST] = "5stack",
2560 [ALC880_5ST_DIG] = "5stack-digout",
2561 [ALC880_W810] = "w810",
2562 [ALC880_Z71V] = "z71v",
2563 [ALC880_6ST] = "6stack",
2564 [ALC880_6ST_DIG] = "6stack-digout",
2565 [ALC880_ASUS] = "asus",
2566 [ALC880_ASUS_W1V] = "asus-w1v",
2567 [ALC880_ASUS_DIG] = "asus-dig",
2568 [ALC880_ASUS_DIG2] = "asus-dig2",
2569 [ALC880_UNIWILL_DIG] = "uniwill",
2570 [ALC880_UNIWILL_P53] = "uniwill-p53",
2571 [ALC880_FUJITSU] = "fujitsu",
2572 [ALC880_F1734] = "F1734",
2574 [ALC880_LG_LW] = "lg-lw",
2575 #ifdef CONFIG_SND_DEBUG
2576 [ALC880_TEST] = "test",
2578 [ALC880_AUTO] = "auto",
2581 static struct snd_pci_quirk alc880_cfg_tbl[] = {
2582 /* Broken BIOS configuration */
2583 SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_6ST_DIG),
2584 SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_6ST_DIG),
2586 SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_5ST_DIG),
2587 SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_6ST),
2588 SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_W810),
2589 SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_3ST_DIG),
2590 SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_6ST_DIG),
2591 SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_6ST_DIG),
2592 SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_6ST_DIG),
2593 SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_3ST_DIG),
2594 SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_3ST),
2596 SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_6ST_DIG),
2597 SND_PCI_QUIRK(0x103c, 0x2a09, "HP", ALC880_5ST),
2599 SND_PCI_QUIRK(0x1043, 0x10b3, "ASUS W1V", ALC880_ASUS_W1V),
2600 SND_PCI_QUIRK(0x1043, 0x10c2, "ASUS W6A", ALC880_ASUS_DIG),
2601 SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS Wxx", ALC880_ASUS_DIG),
2602 SND_PCI_QUIRK(0x1043, 0x1113, "ASUS", ALC880_ASUS_DIG),
2603 SND_PCI_QUIRK(0x1043, 0x1123, "ASUS", ALC880_ASUS_DIG),
2604 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS", ALC880_ASUS_DIG),
2605 SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_Z71V),
2606 /* SND_PCI_QUIRK(0x1043, 0x1964, "ASUS", ALC880_ASUS_DIG), */
2607 SND_PCI_QUIRK(0x1043, 0x1973, "ASUS", ALC880_ASUS_DIG),
2608 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS", ALC880_ASUS_DIG),
2609 SND_PCI_QUIRK(0x1043, 0x814e, "ASUS", ALC880_ASUS),
2610 SND_PCI_QUIRK(0x1043, 0x8181, "ASUS P4GPL", ALC880_ASUS_DIG),
2611 SND_PCI_QUIRK(0x1043, 0x8196, "ASUS P5GD1", ALC880_6ST),
2612 SND_PCI_QUIRK(0x1043, 0x81b4, "ASUS", ALC880_6ST),
2613 SND_PCI_QUIRK(0x1043, 0, "ASUS", ALC880_ASUS),
2615 SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_3ST),
2616 SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_3ST),
2617 SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_5ST),
2618 SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_5ST),
2619 SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_5ST),
2620 SND_PCI_QUIRK(0x1558, 0x0520, "Clevo m520G", ALC880_CLEVO),
2621 SND_PCI_QUIRK(0x1558, 0x0660, "Clevo m655n", ALC880_CLEVO),
2622 SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_5ST_DIG),
2623 SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_W810),
2624 SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_5ST_DIG),
2625 SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_TCL_S700),
2626 SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_5ST_DIG),
2627 SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_6ST_DIG),
2628 SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_6ST_DIG),
2629 SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_6ST_DIG),
2630 SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_6ST_DIG),
2631 SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_6ST_DIG),
2632 SND_PCI_QUIRK(0x1558, 0x5401, "ASUS", ALC880_ASUS_DIG2),
2634 SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_UNIWILL_DIG),
2635 SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_UNIWILL),
2636 SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_UNIWILL_P53),
2637 SND_PCI_QUIRK(0x1584, 0x9054, "Uniwlll", ALC880_F1734),
2639 SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_5ST_DIG),
2640 SND_PCI_QUIRK(0x1734, 0x10ac, "FSC", ALC880_UNIWILL),
2641 SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_F1734),
2642 SND_PCI_QUIRK(0x1734, 0x10b0, "Fujitsu", ALC880_FUJITSU),
2644 SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_LG),
2645 SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_LG),
2646 SND_PCI_QUIRK(0x1854, 0x0018, "LG LW20", ALC880_LG_LW),
2647 SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_LG_LW),
2649 SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_3ST_DIG),
2650 SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_3ST_DIG),
2651 SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_3ST_DIG),
2652 SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_5ST_DIG),
2653 SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_5ST_DIG),
2654 SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_5ST_DIG),
2655 SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_5ST_DIG),
2656 SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_5ST_DIG),
2657 SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_5ST_DIG),
2658 SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_5ST_DIG),
2659 SND_PCI_QUIRK(0x8086, 0, "Intel mobo", ALC880_3ST),
2665 * ALC880 codec presets
2667 static struct alc_config_preset alc880_presets[] = {
2669 .mixers = { alc880_three_stack_mixer },
2670 .init_verbs = { alc880_volume_init_verbs,
2671 alc880_pin_3stack_init_verbs },
2672 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2673 .dac_nids = alc880_dac_nids,
2674 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
2675 .channel_mode = alc880_threestack_modes,
2677 .input_mux = &alc880_capture_source,
2679 [ALC880_3ST_DIG] = {
2680 .mixers = { alc880_three_stack_mixer },
2681 .init_verbs = { alc880_volume_init_verbs,
2682 alc880_pin_3stack_init_verbs },
2683 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2684 .dac_nids = alc880_dac_nids,
2685 .dig_out_nid = ALC880_DIGOUT_NID,
2686 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
2687 .channel_mode = alc880_threestack_modes,
2689 .input_mux = &alc880_capture_source,
2691 [ALC880_TCL_S700] = {
2692 .mixers = { alc880_tcl_s700_mixer },
2693 .init_verbs = { alc880_volume_init_verbs,
2694 alc880_pin_tcl_S700_init_verbs,
2695 alc880_gpio2_init_verbs },
2696 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2697 .dac_nids = alc880_dac_nids,
2699 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
2700 .channel_mode = alc880_2_jack_modes,
2701 .input_mux = &alc880_capture_source,
2704 .mixers = { alc880_three_stack_mixer,
2705 alc880_five_stack_mixer},
2706 .init_verbs = { alc880_volume_init_verbs,
2707 alc880_pin_5stack_init_verbs },
2708 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2709 .dac_nids = alc880_dac_nids,
2710 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
2711 .channel_mode = alc880_fivestack_modes,
2712 .input_mux = &alc880_capture_source,
2714 [ALC880_5ST_DIG] = {
2715 .mixers = { alc880_three_stack_mixer,
2716 alc880_five_stack_mixer },
2717 .init_verbs = { alc880_volume_init_verbs,
2718 alc880_pin_5stack_init_verbs },
2719 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2720 .dac_nids = alc880_dac_nids,
2721 .dig_out_nid = ALC880_DIGOUT_NID,
2722 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
2723 .channel_mode = alc880_fivestack_modes,
2724 .input_mux = &alc880_capture_source,
2727 .mixers = { alc880_six_stack_mixer },
2728 .init_verbs = { alc880_volume_init_verbs,
2729 alc880_pin_6stack_init_verbs },
2730 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
2731 .dac_nids = alc880_6st_dac_nids,
2732 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
2733 .channel_mode = alc880_sixstack_modes,
2734 .input_mux = &alc880_6stack_capture_source,
2736 [ALC880_6ST_DIG] = {
2737 .mixers = { alc880_six_stack_mixer },
2738 .init_verbs = { alc880_volume_init_verbs,
2739 alc880_pin_6stack_init_verbs },
2740 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
2741 .dac_nids = alc880_6st_dac_nids,
2742 .dig_out_nid = ALC880_DIGOUT_NID,
2743 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
2744 .channel_mode = alc880_sixstack_modes,
2745 .input_mux = &alc880_6stack_capture_source,
2748 .mixers = { alc880_w810_base_mixer },
2749 .init_verbs = { alc880_volume_init_verbs,
2750 alc880_pin_w810_init_verbs,
2751 alc880_gpio2_init_verbs },
2752 .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
2753 .dac_nids = alc880_w810_dac_nids,
2754 .dig_out_nid = ALC880_DIGOUT_NID,
2755 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
2756 .channel_mode = alc880_w810_modes,
2757 .input_mux = &alc880_capture_source,
2760 .mixers = { alc880_z71v_mixer },
2761 .init_verbs = { alc880_volume_init_verbs,
2762 alc880_pin_z71v_init_verbs },
2763 .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
2764 .dac_nids = alc880_z71v_dac_nids,
2765 .dig_out_nid = ALC880_DIGOUT_NID,
2767 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
2768 .channel_mode = alc880_2_jack_modes,
2769 .input_mux = &alc880_capture_source,
2772 .mixers = { alc880_f1734_mixer },
2773 .init_verbs = { alc880_volume_init_verbs,
2774 alc880_pin_f1734_init_verbs },
2775 .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
2776 .dac_nids = alc880_f1734_dac_nids,
2778 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
2779 .channel_mode = alc880_2_jack_modes,
2780 .input_mux = &alc880_capture_source,
2783 .mixers = { alc880_asus_mixer },
2784 .init_verbs = { alc880_volume_init_verbs,
2785 alc880_pin_asus_init_verbs,
2786 alc880_gpio1_init_verbs },
2787 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2788 .dac_nids = alc880_asus_dac_nids,
2789 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2790 .channel_mode = alc880_asus_modes,
2792 .input_mux = &alc880_capture_source,
2794 [ALC880_ASUS_DIG] = {
2795 .mixers = { alc880_asus_mixer },
2796 .init_verbs = { alc880_volume_init_verbs,
2797 alc880_pin_asus_init_verbs,
2798 alc880_gpio1_init_verbs },
2799 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2800 .dac_nids = alc880_asus_dac_nids,
2801 .dig_out_nid = ALC880_DIGOUT_NID,
2802 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2803 .channel_mode = alc880_asus_modes,
2805 .input_mux = &alc880_capture_source,
2807 [ALC880_ASUS_DIG2] = {
2808 .mixers = { alc880_asus_mixer },
2809 .init_verbs = { alc880_volume_init_verbs,
2810 alc880_pin_asus_init_verbs,
2811 alc880_gpio2_init_verbs }, /* use GPIO2 */
2812 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2813 .dac_nids = alc880_asus_dac_nids,
2814 .dig_out_nid = ALC880_DIGOUT_NID,
2815 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2816 .channel_mode = alc880_asus_modes,
2818 .input_mux = &alc880_capture_source,
2820 [ALC880_ASUS_W1V] = {
2821 .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
2822 .init_verbs = { alc880_volume_init_verbs,
2823 alc880_pin_asus_init_verbs,
2824 alc880_gpio1_init_verbs },
2825 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2826 .dac_nids = alc880_asus_dac_nids,
2827 .dig_out_nid = ALC880_DIGOUT_NID,
2828 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2829 .channel_mode = alc880_asus_modes,
2831 .input_mux = &alc880_capture_source,
2833 [ALC880_UNIWILL_DIG] = {
2834 .mixers = { alc880_asus_mixer, alc880_pcbeep_mixer },
2835 .init_verbs = { alc880_volume_init_verbs,
2836 alc880_pin_asus_init_verbs },
2837 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2838 .dac_nids = alc880_asus_dac_nids,
2839 .dig_out_nid = ALC880_DIGOUT_NID,
2840 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2841 .channel_mode = alc880_asus_modes,
2843 .input_mux = &alc880_capture_source,
2845 [ALC880_UNIWILL] = {
2846 .mixers = { alc880_uniwill_mixer },
2847 .init_verbs = { alc880_volume_init_verbs,
2848 alc880_uniwill_init_verbs },
2849 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2850 .dac_nids = alc880_asus_dac_nids,
2851 .dig_out_nid = ALC880_DIGOUT_NID,
2852 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
2853 .channel_mode = alc880_threestack_modes,
2855 .input_mux = &alc880_capture_source,
2856 .unsol_event = alc880_uniwill_unsol_event,
2857 .init_hook = alc880_uniwill_automute,
2859 [ALC880_UNIWILL_P53] = {
2860 .mixers = { alc880_uniwill_p53_mixer },
2861 .init_verbs = { alc880_volume_init_verbs,
2862 alc880_uniwill_p53_init_verbs },
2863 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2864 .dac_nids = alc880_asus_dac_nids,
2865 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
2866 .channel_mode = alc880_threestack_modes,
2867 .input_mux = &alc880_capture_source,
2868 .unsol_event = alc880_uniwill_p53_unsol_event,
2869 .init_hook = alc880_uniwill_p53_hp_automute,
2871 [ALC880_FUJITSU] = {
2872 .mixers = { alc880_fujitsu_mixer,
2873 alc880_pcbeep_mixer, },
2874 .init_verbs = { alc880_volume_init_verbs,
2875 alc880_uniwill_p53_init_verbs,
2876 alc880_beep_init_verbs },
2877 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2878 .dac_nids = alc880_dac_nids,
2879 .dig_out_nid = ALC880_DIGOUT_NID,
2880 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
2881 .channel_mode = alc880_2_jack_modes,
2882 .input_mux = &alc880_capture_source,
2883 .unsol_event = alc880_uniwill_p53_unsol_event,
2884 .init_hook = alc880_uniwill_p53_hp_automute,
2887 .mixers = { alc880_three_stack_mixer },
2888 .init_verbs = { alc880_volume_init_verbs,
2889 alc880_pin_clevo_init_verbs },
2890 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2891 .dac_nids = alc880_dac_nids,
2893 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
2894 .channel_mode = alc880_threestack_modes,
2896 .input_mux = &alc880_capture_source,
2899 .mixers = { alc880_lg_mixer },
2900 .init_verbs = { alc880_volume_init_verbs,
2901 alc880_lg_init_verbs },
2902 .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids),
2903 .dac_nids = alc880_lg_dac_nids,
2904 .dig_out_nid = ALC880_DIGOUT_NID,
2905 .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes),
2906 .channel_mode = alc880_lg_ch_modes,
2908 .input_mux = &alc880_lg_capture_source,
2909 .unsol_event = alc880_lg_unsol_event,
2910 .init_hook = alc880_lg_automute,
2911 #ifdef CONFIG_SND_HDA_POWER_SAVE
2912 .loopbacks = alc880_lg_loopbacks,
2916 .mixers = { alc880_lg_lw_mixer },
2917 .init_verbs = { alc880_volume_init_verbs,
2918 alc880_lg_lw_init_verbs },
2919 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2920 .dac_nids = alc880_dac_nids,
2921 .dig_out_nid = ALC880_DIGOUT_NID,
2922 .num_channel_mode = ARRAY_SIZE(alc880_lg_lw_modes),
2923 .channel_mode = alc880_lg_lw_modes,
2924 .input_mux = &alc880_lg_lw_capture_source,
2925 .unsol_event = alc880_lg_lw_unsol_event,
2926 .init_hook = alc880_lg_lw_automute,
2928 #ifdef CONFIG_SND_DEBUG
2930 .mixers = { alc880_test_mixer },
2931 .init_verbs = { alc880_test_init_verbs },
2932 .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
2933 .dac_nids = alc880_test_dac_nids,
2934 .dig_out_nid = ALC880_DIGOUT_NID,
2935 .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
2936 .channel_mode = alc880_test_modes,
2937 .input_mux = &alc880_test_capture_source,
2943 * Automatic parse of I/O pins from the BIOS configuration
2946 #define NUM_CONTROL_ALLOC 32
2947 #define NUM_VERB_ALLOC 32
2951 ALC_CTL_WIDGET_MUTE,
2954 static struct snd_kcontrol_new alc880_control_templates[] = {
2955 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
2956 HDA_CODEC_MUTE(NULL, 0, 0, 0),
2957 HDA_BIND_MUTE(NULL, 0, 0, 0),
2960 /* add dynamic controls */
2961 static int add_control(struct alc_spec *spec, int type, const char *name,
2964 struct snd_kcontrol_new *knew;
2966 if (spec->num_kctl_used >= spec->num_kctl_alloc) {
2967 int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC;
2969 /* array + terminator */
2970 knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL);
2973 if (spec->kctl_alloc) {
2974 memcpy(knew, spec->kctl_alloc,
2975 sizeof(*knew) * spec->num_kctl_alloc);
2976 kfree(spec->kctl_alloc);
2978 spec->kctl_alloc = knew;
2979 spec->num_kctl_alloc = num;
2982 knew = &spec->kctl_alloc[spec->num_kctl_used];
2983 *knew = alc880_control_templates[type];
2984 knew->name = kstrdup(name, GFP_KERNEL);
2987 knew->private_value = val;
2988 spec->num_kctl_used++;
2992 #define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
2993 #define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
2994 #define alc880_is_multi_pin(nid) ((nid) >= 0x18)
2995 #define alc880_multi_pin_idx(nid) ((nid) - 0x18)
2996 #define alc880_is_input_pin(nid) ((nid) >= 0x18)
2997 #define alc880_input_pin_idx(nid) ((nid) - 0x18)
2998 #define alc880_idx_to_dac(nid) ((nid) + 0x02)
2999 #define alc880_dac_to_idx(nid) ((nid) - 0x02)
3000 #define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
3001 #define alc880_idx_to_selector(nid) ((nid) + 0x10)
3002 #define ALC880_PIN_CD_NID 0x1c
3004 /* fill in the dac_nids table from the parsed pin configuration */
3005 static int alc880_auto_fill_dac_nids(struct alc_spec *spec,
3006 const struct auto_pin_cfg *cfg)
3012 memset(assigned, 0, sizeof(assigned));
3013 spec->multiout.dac_nids = spec->private_dac_nids;
3015 /* check the pins hardwired to audio widget */
3016 for (i = 0; i < cfg->line_outs; i++) {
3017 nid = cfg->line_out_pins[i];
3018 if (alc880_is_fixed_pin(nid)) {
3019 int idx = alc880_fixed_pin_idx(nid);
3020 spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
3024 /* left pins can be connect to any audio widget */
3025 for (i = 0; i < cfg->line_outs; i++) {
3026 nid = cfg->line_out_pins[i];
3027 if (alc880_is_fixed_pin(nid))
3029 /* search for an empty channel */
3030 for (j = 0; j < cfg->line_outs; j++) {
3032 spec->multiout.dac_nids[i] =
3033 alc880_idx_to_dac(j);
3039 spec->multiout.num_dacs = cfg->line_outs;
3043 /* add playback controls from the parsed DAC table */
3044 static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
3045 const struct auto_pin_cfg *cfg)
3048 static const char *chname[4] = {
3049 "Front", "Surround", NULL /*CLFE*/, "Side"
3054 for (i = 0; i < cfg->line_outs; i++) {
3055 if (!spec->multiout.dac_nids[i])
3057 nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
3060 err = add_control(spec, ALC_CTL_WIDGET_VOL,
3061 "Center Playback Volume",
3062 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
3066 err = add_control(spec, ALC_CTL_WIDGET_VOL,
3067 "LFE Playback Volume",
3068 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
3072 err = add_control(spec, ALC_CTL_BIND_MUTE,
3073 "Center Playback Switch",
3074 HDA_COMPOSE_AMP_VAL(nid, 1, 2,
3078 err = add_control(spec, ALC_CTL_BIND_MUTE,
3079 "LFE Playback Switch",
3080 HDA_COMPOSE_AMP_VAL(nid, 2, 2,
3085 sprintf(name, "%s Playback Volume", chname[i]);
3086 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
3087 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
3091 sprintf(name, "%s Playback Switch", chname[i]);
3092 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
3093 HDA_COMPOSE_AMP_VAL(nid, 3, 2,
3102 /* add playback controls for speaker and HP outputs */
3103 static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
3113 if (alc880_is_fixed_pin(pin)) {
3114 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
3115 /* specify the DAC as the extra output */
3116 if (!spec->multiout.hp_nid)
3117 spec->multiout.hp_nid = nid;
3119 spec->multiout.extra_out_nid[0] = nid;
3120 /* control HP volume/switch on the output mixer amp */
3121 nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
3122 sprintf(name, "%s Playback Volume", pfx);
3123 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
3124 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
3127 sprintf(name, "%s Playback Switch", pfx);
3128 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
3129 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
3132 } else if (alc880_is_multi_pin(pin)) {
3133 /* set manual connection */
3134 /* we have only a switch on HP-out PIN */
3135 sprintf(name, "%s Playback Switch", pfx);
3136 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
3137 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
3144 /* create input playback/capture controls for the given pin */
3145 static int new_analog_input(struct alc_spec *spec, hda_nid_t pin,
3146 const char *ctlname,
3147 int idx, hda_nid_t mix_nid)
3152 sprintf(name, "%s Playback Volume", ctlname);
3153 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
3154 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
3157 sprintf(name, "%s Playback Switch", ctlname);
3158 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
3159 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
3165 /* create playback/capture controls for input pins */
3166 static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec,
3167 const struct auto_pin_cfg *cfg)
3169 struct hda_input_mux *imux = &spec->private_imux;
3172 for (i = 0; i < AUTO_PIN_LAST; i++) {
3173 if (alc880_is_input_pin(cfg->input_pins[i])) {
3174 idx = alc880_input_pin_idx(cfg->input_pins[i]);
3175 err = new_analog_input(spec, cfg->input_pins[i],
3176 auto_pin_cfg_labels[i],
3180 imux->items[imux->num_items].label =
3181 auto_pin_cfg_labels[i];
3182 imux->items[imux->num_items].index =
3183 alc880_input_pin_idx(cfg->input_pins[i]);
3190 static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
3191 hda_nid_t nid, int pin_type,
3195 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
3197 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
3199 /* need the manual connection? */
3200 if (alc880_is_multi_pin(nid)) {
3201 struct alc_spec *spec = codec->spec;
3202 int idx = alc880_multi_pin_idx(nid);
3203 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
3204 AC_VERB_SET_CONNECT_SEL,
3205 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
3209 static int get_pin_type(int line_out_type)
3211 if (line_out_type == AUTO_PIN_HP_OUT)
3217 static void alc880_auto_init_multi_out(struct hda_codec *codec)
3219 struct alc_spec *spec = codec->spec;
3222 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
3223 for (i = 0; i < spec->autocfg.line_outs; i++) {
3224 hda_nid_t nid = spec->autocfg.line_out_pins[i];
3225 int pin_type = get_pin_type(spec->autocfg.line_out_type);
3226 alc880_auto_set_output_and_unmute(codec, nid, pin_type, i);
3230 static void alc880_auto_init_extra_out(struct hda_codec *codec)
3232 struct alc_spec *spec = codec->spec;
3235 pin = spec->autocfg.speaker_pins[0];
3236 if (pin) /* connect to front */
3237 alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
3238 pin = spec->autocfg.hp_pins[0];
3239 if (pin) /* connect to front */
3240 alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
3243 static void alc880_auto_init_analog_input(struct hda_codec *codec)
3245 struct alc_spec *spec = codec->spec;
3248 for (i = 0; i < AUTO_PIN_LAST; i++) {
3249 hda_nid_t nid = spec->autocfg.input_pins[i];
3250 if (alc880_is_input_pin(nid)) {
3251 snd_hda_codec_write(codec, nid, 0,
3252 AC_VERB_SET_PIN_WIDGET_CONTROL,
3253 i <= AUTO_PIN_FRONT_MIC ?
3254 PIN_VREF80 : PIN_IN);
3255 if (nid != ALC880_PIN_CD_NID)
3256 snd_hda_codec_write(codec, nid, 0,
3257 AC_VERB_SET_AMP_GAIN_MUTE,
3263 /* parse the BIOS configuration and set up the alc_spec */
3264 /* return 1 if successful, 0 if the proper config is not found,
3265 * or a negative error code
3267 static int alc880_parse_auto_config(struct hda_codec *codec)
3269 struct alc_spec *spec = codec->spec;
3271 static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
3273 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
3277 if (!spec->autocfg.line_outs)
3278 return 0; /* can't find valid BIOS pin config */
3280 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
3283 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
3286 err = alc880_auto_create_extra_out(spec,
3287 spec->autocfg.speaker_pins[0],
3291 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
3295 err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
3299 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
3301 if (spec->autocfg.dig_out_pin)
3302 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
3303 if (spec->autocfg.dig_in_pin)
3304 spec->dig_in_nid = ALC880_DIGIN_NID;
3306 if (spec->kctl_alloc)
3307 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
3309 spec->init_verbs[spec->num_init_verbs++] = alc880_volume_init_verbs;
3311 spec->num_mux_defs = 1;
3312 spec->input_mux = &spec->private_imux;
3317 /* additional initialization for auto-configuration model */
3318 static void alc880_auto_init(struct hda_codec *codec)
3320 alc880_auto_init_multi_out(codec);
3321 alc880_auto_init_extra_out(codec);
3322 alc880_auto_init_analog_input(codec);
3326 * OK, here we have finally the patch for ALC880
3329 static int patch_alc880(struct hda_codec *codec)
3331 struct alc_spec *spec;
3335 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
3341 board_config = snd_hda_check_board_config(codec, ALC880_MODEL_LAST,
3344 if (board_config < 0) {
3345 printk(KERN_INFO "hda_codec: Unknown model for ALC880, "
3346 "trying auto-probe from BIOS...\n");
3347 board_config = ALC880_AUTO;
3350 if (board_config == ALC880_AUTO) {
3351 /* automatic parse from the BIOS config */
3352 err = alc880_parse_auto_config(codec);
3358 "hda_codec: Cannot set up configuration "
3359 "from BIOS. Using 3-stack mode...\n");
3360 board_config = ALC880_3ST;
3364 if (board_config != ALC880_AUTO)
3365 setup_preset(spec, &alc880_presets[board_config]);
3367 spec->stream_name_analog = "ALC880 Analog";
3368 spec->stream_analog_playback = &alc880_pcm_analog_playback;
3369 spec->stream_analog_capture = &alc880_pcm_analog_capture;
3371 spec->stream_name_digital = "ALC880 Digital";
3372 spec->stream_digital_playback = &alc880_pcm_digital_playback;
3373 spec->stream_digital_capture = &alc880_pcm_digital_capture;
3375 if (!spec->adc_nids && spec->input_mux) {
3376 /* check whether NID 0x07 is valid */
3377 unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
3379 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
3380 if (wcap != AC_WID_AUD_IN) {
3381 spec->adc_nids = alc880_adc_nids_alt;
3382 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
3383 spec->mixers[spec->num_mixers] =
3384 alc880_capture_alt_mixer;
3387 spec->adc_nids = alc880_adc_nids;
3388 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
3389 spec->mixers[spec->num_mixers] = alc880_capture_mixer;
3394 codec->patch_ops = alc_patch_ops;
3395 if (board_config == ALC880_AUTO)
3396 spec->init_hook = alc880_auto_init;
3397 #ifdef CONFIG_SND_HDA_POWER_SAVE
3398 if (!spec->loopback.amplist)
3399 spec->loopback.amplist = alc880_loopbacks;
3410 static hda_nid_t alc260_dac_nids[1] = {
3415 static hda_nid_t alc260_adc_nids[1] = {
3420 static hda_nid_t alc260_adc_nids_alt[1] = {
3425 static hda_nid_t alc260_hp_adc_nids[2] = {
3430 /* NIDs used when simultaneous access to both ADCs makes sense. Note that
3431 * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
3433 static hda_nid_t alc260_dual_adc_nids[2] = {
3438 #define ALC260_DIGOUT_NID 0x03
3439 #define ALC260_DIGIN_NID 0x06
3441 static struct hda_input_mux alc260_capture_source = {
3445 { "Front Mic", 0x1 },
3451 /* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
3452 * headphone jack and the internal CD lines since these are the only pins at
3453 * which audio can appear. For flexibility, also allow the option of
3454 * recording the mixer output on the second ADC (ADC0 doesn't have a
3455 * connection to the mixer output).
3457 static struct hda_input_mux alc260_fujitsu_capture_sources[2] = {
3461 { "Mic/Line", 0x0 },
3463 { "Headphone", 0x2 },
3469 { "Mic/Line", 0x0 },
3471 { "Headphone", 0x2 },
3478 /* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to
3479 * the Fujitsu S702x, but jacks are marked differently.
3481 static struct hda_input_mux alc260_acer_capture_sources[2] = {
3488 { "Headphone", 0x5 },
3497 { "Headphone", 0x6 },
3503 * This is just place-holder, so there's something for alc_build_pcms to look
3504 * at when it calculates the maximum number of channels. ALC260 has no mixer
3505 * element which allows changing the channel mode, so the verb list is
3508 static struct hda_channel_mode alc260_modes[1] = {
3513 /* Mixer combinations
3515 * basic: base_output + input + pc_beep + capture
3516 * HP: base_output + input + capture_alt
3517 * HP_3013: hp_3013 + input + capture
3518 * fujitsu: fujitsu + capture
3519 * acer: acer + capture
3522 static struct snd_kcontrol_new alc260_base_output_mixer[] = {
3523 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3524 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
3525 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
3526 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
3527 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
3528 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
3532 static struct snd_kcontrol_new alc260_input_mixer[] = {
3533 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3534 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
3535 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
3536 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
3537 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
3538 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
3539 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
3540 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
3544 static struct snd_kcontrol_new alc260_pc_beep_mixer[] = {
3545 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x07, 0x05, HDA_INPUT),
3546 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x07, 0x05, HDA_INPUT),
3550 static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
3551 HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
3552 HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
3553 HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
3554 HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
3555 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3556 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
3557 HDA_CODEC_VOLUME_MONO("iSpeaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
3558 HDA_CODEC_MUTE_MONO("iSpeaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
3562 /* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12,
3563 * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10.
3565 static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
3566 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3567 HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
3568 ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
3569 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3570 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
3571 HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
3572 HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
3573 ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
3574 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
3575 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
3576 HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
3577 HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x09, 2, HDA_INPUT),
3581 /* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current
3582 * versions of the ALC260 don't act on requests to enable mic bias from NID
3583 * 0x0f (used to drive the headphone jack in these laptops). The ALC260
3584 * datasheet doesn't mention this restriction. At this stage it's not clear
3585 * whether this behaviour is intentional or is a hardware bug in chip
3586 * revisions available in early 2006. Therefore for now allow the
3587 * "Headphone Jack Mode" control to span all choices, but if it turns out
3588 * that the lack of mic bias for this NID is intentional we could change the
3589 * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
3591 * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006
3592 * don't appear to make the mic bias available from the "line" jack, even
3593 * though the NID used for this jack (0x14) can supply it. The theory is
3594 * that perhaps Acer have included blocking capacitors between the ALC260
3595 * and the output jack. If this turns out to be the case for all such
3596 * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
3597 * to ALC_PIN_DIR_INOUT_NOMICBIAS.
3599 * The C20x Tablet series have a mono internal speaker which is controlled
3600 * via the chip's Mono sum widget and pin complex, so include the necessary
3601 * controls for such models. On models without a "mono speaker" the control
3602 * won't do anything.
3604 static struct snd_kcontrol_new alc260_acer_mixer[] = {
3605 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3606 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
3607 ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
3608 HDA_CODEC_VOLUME_MONO("Mono Speaker Playback Volume", 0x0a, 1, 0x0,
3610 HDA_BIND_MUTE_MONO("Mono Speaker Playback Switch", 0x0a, 1, 2,
3612 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3613 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
3614 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
3615 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
3616 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
3617 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
3618 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
3619 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
3620 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
3621 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
3625 /* Packard bell V7900 ALC260 pin usage: HP = 0x0f, Mic jack = 0x12,
3626 * Line In jack = 0x14, CD audio = 0x16, pc beep = 0x17.
3628 static struct snd_kcontrol_new alc260_will_mixer[] = {
3629 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3630 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
3631 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
3632 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
3633 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
3634 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
3635 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
3636 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
3637 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3638 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
3639 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
3640 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
3644 /* Replacer 672V ALC260 pin usage: Mic jack = 0x12,
3645 * Line In jack = 0x14, ATAPI Mic = 0x13, speaker = 0x0f.
3647 static struct snd_kcontrol_new alc260_replacer_672v_mixer[] = {
3648 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3649 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
3650 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
3651 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
3652 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
3653 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x07, 0x1, HDA_INPUT),
3654 HDA_CODEC_MUTE("ATATI Mic Playback Switch", 0x07, 0x1, HDA_INPUT),
3655 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
3656 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
3657 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
3661 /* capture mixer elements */
3662 static struct snd_kcontrol_new alc260_capture_mixer[] = {
3663 HDA_CODEC_VOLUME("Capture Volume", 0x04, 0x0, HDA_INPUT),
3664 HDA_CODEC_MUTE("Capture Switch", 0x04, 0x0, HDA_INPUT),
3665 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x05, 0x0, HDA_INPUT),
3666 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x05, 0x0, HDA_INPUT),
3668 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3669 /* The multiple "Capture Source" controls confuse alsamixer
3670 * So call somewhat different..
3671 * FIXME: the controls appear in the "playback" view!
3673 /* .name = "Capture Source", */
3674 .name = "Input Source",
3676 .info = alc_mux_enum_info,
3677 .get = alc_mux_enum_get,
3678 .put = alc_mux_enum_put,
3683 static struct snd_kcontrol_new alc260_capture_alt_mixer[] = {
3684 HDA_CODEC_VOLUME("Capture Volume", 0x05, 0x0, HDA_INPUT),
3685 HDA_CODEC_MUTE("Capture Switch", 0x05, 0x0, HDA_INPUT),
3687 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3688 /* The multiple "Capture Source" controls confuse alsamixer
3689 * So call somewhat different..
3690 * FIXME: the controls appear in the "playback" view!
3692 /* .name = "Capture Source", */
3693 .name = "Input Source",
3695 .info = alc_mux_enum_info,
3696 .get = alc_mux_enum_get,
3697 .put = alc_mux_enum_put,
3703 * initialization verbs
3705 static struct hda_verb alc260_init_verbs[] = {
3706 /* Line In pin widget for input */
3707 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3708 /* CD pin widget for input */
3709 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3710 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3711 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3712 /* Mic2 (front panel) pin widget for input and vref at 80% */
3713 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3714 /* LINE-2 is used for line-out in rear */
3715 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3716 /* select line-out */
3717 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
3719 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3721 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3723 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3724 /* mute capture amp left and right */
3725 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3726 /* set connection select to line in (default select for this ADC) */
3727 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
3728 /* mute capture amp left and right */
3729 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3730 /* set connection select to line in (default select for this ADC) */
3731 {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
3732 /* set vol=0 Line-Out mixer amp left and right */
3733 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3734 /* unmute pin widget amp left and right (no gain on this amp) */
3735 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3736 /* set vol=0 HP mixer amp left and right */
3737 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3738 /* unmute pin widget amp left and right (no gain on this amp) */
3739 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3740 /* set vol=0 Mono mixer amp left and right */
3741 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3742 /* unmute pin widget amp left and right (no gain on this amp) */
3743 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3744 /* unmute LINE-2 out pin */
3745 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3746 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
3749 /* mute analog inputs */
3750 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3751 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3752 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
3753 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
3754 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
3755 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
3756 /* mute Front out path */
3757 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3758 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3759 /* mute Headphone out path */
3760 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3761 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3762 /* mute Mono out path */
3763 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3764 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3768 #if 0 /* should be identical with alc260_init_verbs? */
3769 static struct hda_verb alc260_hp_init_verbs[] = {
3770 /* Headphone and output */
3771 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
3773 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
3774 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3775 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
3776 /* Mic2 (front panel) pin widget for input and vref at 80% */
3777 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
3778 /* Line In pin widget for input */
3779 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
3780 /* Line-2 pin widget for output */
3781 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
3782 /* CD pin widget for input */
3783 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
3784 /* unmute amp left and right */
3785 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
3786 /* set connection select to line in (default select for this ADC) */
3787 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
3788 /* unmute Line-Out mixer amp left and right (volume = 0) */
3789 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
3790 /* mute pin widget amp left and right (no gain on this amp) */
3791 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
3792 /* unmute HP mixer amp left and right (volume = 0) */
3793 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
3794 /* mute pin widget amp left and right (no gain on this amp) */
3795 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
3796 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
3799 /* mute analog inputs */
3800 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3801 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3802 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
3803 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
3804 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
3805 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
3806 /* Unmute Front out path */
3807 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3808 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3809 /* Unmute Headphone out path */
3810 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3811 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3812 /* Unmute Mono out path */
3813 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3814 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3819 static struct hda_verb alc260_hp_3013_init_verbs[] = {
3820 /* Line out and output */
3821 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
3823 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
3824 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3825 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
3826 /* Mic2 (front panel) pin widget for input and vref at 80% */
3827 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
3828 /* Line In pin widget for input */
3829 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
3830 /* Headphone pin widget for output */
3831 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
3832 /* CD pin widget for input */
3833 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
3834 /* unmute amp left and right */
3835 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
3836 /* set connection select to line in (default select for this ADC) */
3837 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
3838 /* unmute Line-Out mixer amp left and right (volume = 0) */
3839 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
3840 /* mute pin widget amp left and right (no gain on this amp) */
3841 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
3842 /* unmute HP mixer amp left and right (volume = 0) */
3843 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
3844 /* mute pin widget amp left and right (no gain on this amp) */
3845 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
3846 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
3849 /* mute analog inputs */
3850 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3851 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3852 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
3853 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
3854 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
3855 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
3856 /* Unmute Front out path */
3857 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3858 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3859 /* Unmute Headphone out path */
3860 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3861 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3862 /* Unmute Mono out path */
3863 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3864 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3868 /* Initialisation sequence for ALC260 as configured in Fujitsu S702x
3869 * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD
3870 * audio = 0x16, internal speaker = 0x10.
3872 static struct hda_verb alc260_fujitsu_init_verbs[] = {
3873 /* Disable all GPIOs */
3874 {0x01, AC_VERB_SET_GPIO_MASK, 0},
3875 /* Internal speaker is connected to headphone pin */
3876 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3877 /* Headphone/Line-out jack connects to Line1 pin; make it an output */
3878 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3879 /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
3880 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3881 /* Ensure all other unused pins are disabled and muted. */
3882 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3883 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3884 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3885 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3886 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3887 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3888 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3889 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3891 /* Disable digital (SPDIF) pins */
3892 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
3893 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
3895 /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
3896 * when acting as an output.
3898 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
3900 /* Start with output sum widgets muted and their output gains at min */
3901 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3902 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3903 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3904 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3905 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3906 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3907 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3908 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3909 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3911 /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
3912 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3913 /* Unmute Line1 pin widget output buffer since it starts as an output.
3914 * If the pin mode is changed by the user the pin mode control will
3915 * take care of enabling the pin's input/output buffers as needed.
3916 * Therefore there's no need to enable the input buffer at this
3919 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3920 /* Unmute input buffer of pin widget used for Line-in (no equiv
3923 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3925 /* Mute capture amp left and right */
3926 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3927 /* Set ADC connection select to match default mixer setting - line
3930 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
3932 /* Do the same for the second ADC: mute capture input amp and
3933 * set ADC connection to line in (on mic1 pin)
3935 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3936 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
3938 /* Mute all inputs to mixer widget (even unconnected ones) */
3939 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
3940 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
3941 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
3942 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
3943 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
3944 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
3945 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
3946 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
3951 /* Initialisation sequence for ALC260 as configured in Acer TravelMate and
3952 * similar laptops (adapted from Fujitsu init verbs).
3954 static struct hda_verb alc260_acer_init_verbs[] = {
3955 /* On TravelMate laptops, GPIO 0 enables the internal speaker and
3956 * the headphone jack. Turn this on and rely on the standard mute
3957 * methods whenever the user wants to turn these outputs off.
3959 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
3960 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
3961 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
3962 /* Internal speaker/Headphone jack is connected to Line-out pin */
3963 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3964 /* Internal microphone/Mic jack is connected to Mic1 pin */
3965 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
3966 /* Line In jack is connected to Line1 pin */
3967 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3968 /* Some Acers (eg: C20x Tablets) use Mono pin for internal speaker */
3969 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3970 /* Ensure all other unused pins are disabled and muted. */
3971 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3972 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3973 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3974 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3975 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3976 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3977 /* Disable digital (SPDIF) pins */
3978 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
3979 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
3981 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
3982 * bus when acting as outputs.
3984 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
3985 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
3987 /* Start with output sum widgets muted and their output gains at min */
3988 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3989 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3990 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3991 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3992 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3993 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3994 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3995 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3996 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3998 /* Unmute Line-out pin widget amp left and right
3999 * (no equiv mixer ctrl)
4001 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4002 /* Unmute mono pin widget amp output (no equiv mixer ctrl) */
4003 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4004 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
4005 * inputs. If the pin mode is changed by the user the pin mode control
4006 * will take care of enabling the pin's input/output buffers as needed.
4007 * Therefore there's no need to enable the input buffer at this
4010 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4011 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4013 /* Mute capture amp left and right */
4014 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4015 /* Set ADC connection select to match default mixer setting - mic
4018 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
4020 /* Do similar with the second ADC: mute capture input amp and
4021 * set ADC connection to mic to match ALSA's default state.
4023 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4024 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
4026 /* Mute all inputs to mixer widget (even unconnected ones) */
4027 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
4028 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
4029 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
4030 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
4031 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
4032 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
4033 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
4034 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
4039 static struct hda_verb alc260_will_verbs[] = {
4040 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4041 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x00},
4042 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
4043 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
4044 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
4045 {0x1a, AC_VERB_SET_PROC_COEF, 0x3040},
4049 static struct hda_verb alc260_replacer_672v_verbs[] = {
4050 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
4051 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
4052 {0x1a, AC_VERB_SET_PROC_COEF, 0x3050},
4054 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
4055 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
4056 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
4058 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
4062 /* toggle speaker-output according to the hp-jack state */
4063 static void alc260_replacer_672v_automute(struct hda_codec *codec)
4065 unsigned int present;
4067 /* speaker --> GPIO Data 0, hp or spdif --> GPIO data 1 */
4068 present = snd_hda_codec_read(codec, 0x0f, 0,
4069 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
4071 snd_hda_codec_write_cache(codec, 0x01, 0,
4072 AC_VERB_SET_GPIO_DATA, 1);
4073 snd_hda_codec_write_cache(codec, 0x0f, 0,
4074 AC_VERB_SET_PIN_WIDGET_CONTROL,
4077 snd_hda_codec_write_cache(codec, 0x01, 0,
4078 AC_VERB_SET_GPIO_DATA, 0);
4079 snd_hda_codec_write_cache(codec, 0x0f, 0,
4080 AC_VERB_SET_PIN_WIDGET_CONTROL,
4085 static void alc260_replacer_672v_unsol_event(struct hda_codec *codec,
4088 if ((res >> 26) == ALC880_HP_EVENT)
4089 alc260_replacer_672v_automute(codec);
4092 /* Test configuration for debugging, modelled after the ALC880 test
4095 #ifdef CONFIG_SND_DEBUG
4096 static hda_nid_t alc260_test_dac_nids[1] = {
4099 static hda_nid_t alc260_test_adc_nids[2] = {
4102 /* For testing the ALC260, each input MUX needs its own definition since
4103 * the signal assignments are different. This assumes that the first ADC
4106 static struct hda_input_mux alc260_test_capture_sources[2] = {
4110 { "MIC1 pin", 0x0 },
4111 { "MIC2 pin", 0x1 },
4112 { "LINE1 pin", 0x2 },
4113 { "LINE2 pin", 0x3 },
4115 { "LINE-OUT pin", 0x5 },
4116 { "HP-OUT pin", 0x6 },
4122 { "MIC1 pin", 0x0 },
4123 { "MIC2 pin", 0x1 },
4124 { "LINE1 pin", 0x2 },
4125 { "LINE2 pin", 0x3 },
4128 { "LINE-OUT pin", 0x6 },
4129 { "HP-OUT pin", 0x7 },
4133 static struct snd_kcontrol_new alc260_test_mixer[] = {
4134 /* Output driver widgets */
4135 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
4136 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
4137 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4138 HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
4139 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4140 HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
4142 /* Modes for retasking pin widgets
4143 * Note: the ALC260 doesn't seem to act on requests to enable mic
4144 * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't
4145 * mention this restriction. At this stage it's not clear whether
4146 * this behaviour is intentional or is a hardware bug in chip
4147 * revisions available at least up until early 2006. Therefore for
4148 * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all
4149 * choices, but if it turns out that the lack of mic bias for these
4150 * NIDs is intentional we could change their modes from
4151 * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
4153 ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
4154 ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
4155 ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
4156 ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
4157 ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
4158 ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
4160 /* Loopback mixer controls */
4161 HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
4162 HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
4163 HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
4164 HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
4165 HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
4166 HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
4167 HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
4168 HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
4169 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4170 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4171 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
4172 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
4173 HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
4174 HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
4175 HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
4176 HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
4178 /* Controls for GPIO pins, assuming they are configured as outputs */
4179 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
4180 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
4181 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
4182 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
4184 /* Switches to allow the digital IO pins to be enabled. The datasheet
4185 * is ambigious as to which NID is which; testing on laptops which
4186 * make this output available should provide clarification.
4188 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
4189 ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
4193 static struct hda_verb alc260_test_init_verbs[] = {
4194 /* Enable all GPIOs as outputs with an initial value of 0 */
4195 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
4196 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
4197 {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
4199 /* Enable retasking pins as output, initially without power amp */
4200 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4201 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4202 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4203 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4204 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4205 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4207 /* Disable digital (SPDIF) pins initially, but users can enable
4208 * them via a mixer switch. In the case of SPDIF-out, this initverb
4209 * payload also sets the generation to 0, output to be in "consumer"
4210 * PCM format, copyright asserted, no pre-emphasis and no validity
4213 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
4214 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
4216 /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
4217 * OUT1 sum bus when acting as an output.
4219 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
4220 {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
4221 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
4222 {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
4224 /* Start with output sum widgets muted and their output gains at min */
4225 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4226 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4227 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4228 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4229 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4230 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4231 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4232 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4233 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4235 /* Unmute retasking pin widget output buffers since the default
4236 * state appears to be output. As the pin mode is changed by the
4237 * user the pin mode control will take care of enabling the pin's
4238 * input/output buffers as needed.
4240 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4241 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4242 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4243 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4244 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4245 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4246 /* Also unmute the mono-out pin widget */
4247 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4249 /* Mute capture amp left and right */
4250 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4251 /* Set ADC connection select to match default mixer setting (mic1
4254 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
4256 /* Do the same for the second ADC: mute capture input amp and
4257 * set ADC connection to mic1 pin
4259 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4260 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
4262 /* Mute all inputs to mixer widget (even unconnected ones) */
4263 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
4264 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
4265 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
4266 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
4267 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
4268 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
4269 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
4270 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
4276 static struct hda_pcm_stream alc260_pcm_analog_playback = {
4282 static struct hda_pcm_stream alc260_pcm_analog_capture = {
4288 #define alc260_pcm_digital_playback alc880_pcm_digital_playback
4289 #define alc260_pcm_digital_capture alc880_pcm_digital_capture
4292 * for BIOS auto-configuration
4295 static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
4299 unsigned long vol_val, sw_val;
4303 if (nid >= 0x0f && nid < 0x11) {
4304 nid_vol = nid - 0x7;
4305 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
4306 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
4307 } else if (nid == 0x11) {
4308 nid_vol = nid - 0x7;
4309 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
4310 sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
4311 } else if (nid >= 0x12 && nid <= 0x15) {
4313 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
4314 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
4318 snprintf(name, sizeof(name), "%s Playback Volume", pfx);
4319 err = add_control(spec, ALC_CTL_WIDGET_VOL, name, vol_val);
4322 snprintf(name, sizeof(name), "%s Playback Switch", pfx);
4323 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, sw_val);
4329 /* add playback controls from the parsed DAC table */
4330 static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
4331 const struct auto_pin_cfg *cfg)
4336 spec->multiout.num_dacs = 1;
4337 spec->multiout.dac_nids = spec->private_dac_nids;
4338 spec->multiout.dac_nids[0] = 0x02;
4340 nid = cfg->line_out_pins[0];
4342 err = alc260_add_playback_controls(spec, nid, "Front");
4347 nid = cfg->speaker_pins[0];
4349 err = alc260_add_playback_controls(spec, nid, "Speaker");
4354 nid = cfg->hp_pins[0];
4356 err = alc260_add_playback_controls(spec, nid, "Headphone");
4363 /* create playback/capture controls for input pins */
4364 static int alc260_auto_create_analog_input_ctls(struct alc_spec *spec,
4365 const struct auto_pin_cfg *cfg)
4367 struct hda_input_mux *imux = &spec->private_imux;
4370 for (i = 0; i < AUTO_PIN_LAST; i++) {
4371 if (cfg->input_pins[i] >= 0x12) {
4372 idx = cfg->input_pins[i] - 0x12;
4373 err = new_analog_input(spec, cfg->input_pins[i],
4374 auto_pin_cfg_labels[i], idx,
4378 imux->items[imux->num_items].label =
4379 auto_pin_cfg_labels[i];
4380 imux->items[imux->num_items].index = idx;
4383 if (cfg->input_pins[i] >= 0x0f && cfg->input_pins[i] <= 0x10){
4384 idx = cfg->input_pins[i] - 0x09;
4385 err = new_analog_input(spec, cfg->input_pins[i],
4386 auto_pin_cfg_labels[i], idx,
4390 imux->items[imux->num_items].label =
4391 auto_pin_cfg_labels[i];
4392 imux->items[imux->num_items].index = idx;
4399 static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
4400 hda_nid_t nid, int pin_type,
4404 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4406 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
4408 /* need the manual connection? */
4410 int idx = nid - 0x12;
4411 snd_hda_codec_write(codec, idx + 0x0b, 0,
4412 AC_VERB_SET_CONNECT_SEL, sel_idx);
4416 static void alc260_auto_init_multi_out(struct hda_codec *codec)
4418 struct alc_spec *spec = codec->spec;
4421 alc_subsystem_id(codec, 0x10, 0x15, 0x0f);
4422 nid = spec->autocfg.line_out_pins[0];
4424 int pin_type = get_pin_type(spec->autocfg.line_out_type);
4425 alc260_auto_set_output_and_unmute(codec, nid, pin_type, 0);
4428 nid = spec->autocfg.speaker_pins[0];
4430 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
4432 nid = spec->autocfg.hp_pins[0];
4434 alc260_auto_set_output_and_unmute(codec, nid, PIN_HP, 0);
4437 #define ALC260_PIN_CD_NID 0x16
4438 static void alc260_auto_init_analog_input(struct hda_codec *codec)
4440 struct alc_spec *spec = codec->spec;
4443 for (i = 0; i < AUTO_PIN_LAST; i++) {
4444 hda_nid_t nid = spec->autocfg.input_pins[i];
4446 snd_hda_codec_write(codec, nid, 0,
4447 AC_VERB_SET_PIN_WIDGET_CONTROL,
4448 i <= AUTO_PIN_FRONT_MIC ?
4449 PIN_VREF80 : PIN_IN);
4450 if (nid != ALC260_PIN_CD_NID)
4451 snd_hda_codec_write(codec, nid, 0,
4452 AC_VERB_SET_AMP_GAIN_MUTE,
4459 * generic initialization of ADC, input mixers and output mixers
4461 static struct hda_verb alc260_volume_init_verbs[] = {
4463 * Unmute ADC0-1 and set the default input to mic-in
4465 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
4466 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4467 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
4468 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4470 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
4472 * Note: PASD motherboards uses the Line In 2 as the input for
4473 * front panel mic (mic 2)
4475 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
4476 /* mute analog inputs */
4477 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4478 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4479 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4480 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4481 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
4484 * Set up output mixers (0x08 - 0x0a)
4486 /* set vol=0 to output mixers */
4487 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4488 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4489 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4490 /* set up input amps for analog loopback */
4491 /* Amp Indices: DAC = 0, mixer = 1 */
4492 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4493 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4494 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4495 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4496 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4497 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4502 static int alc260_parse_auto_config(struct hda_codec *codec)
4504 struct alc_spec *spec = codec->spec;
4507 static hda_nid_t alc260_ignore[] = { 0x17, 0 };
4509 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
4513 err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg);
4516 if (!spec->kctl_alloc)
4517 return 0; /* can't find valid BIOS pin config */
4518 err = alc260_auto_create_analog_input_ctls(spec, &spec->autocfg);
4522 spec->multiout.max_channels = 2;
4524 if (spec->autocfg.dig_out_pin)
4525 spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
4526 if (spec->kctl_alloc)
4527 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
4529 spec->init_verbs[spec->num_init_verbs++] = alc260_volume_init_verbs;
4531 spec->num_mux_defs = 1;
4532 spec->input_mux = &spec->private_imux;
4534 /* check whether NID 0x04 is valid */
4535 wcap = get_wcaps(codec, 0x04);
4536 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
4537 if (wcap != AC_WID_AUD_IN) {
4538 spec->adc_nids = alc260_adc_nids_alt;
4539 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
4540 spec->mixers[spec->num_mixers] = alc260_capture_alt_mixer;
4542 spec->adc_nids = alc260_adc_nids;
4543 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
4544 spec->mixers[spec->num_mixers] = alc260_capture_mixer;
4551 /* additional initialization for auto-configuration model */
4552 static void alc260_auto_init(struct hda_codec *codec)
4554 alc260_auto_init_multi_out(codec);
4555 alc260_auto_init_analog_input(codec);
4558 #ifdef CONFIG_SND_HDA_POWER_SAVE
4559 static struct hda_amp_list alc260_loopbacks[] = {
4560 { 0x07, HDA_INPUT, 0 },
4561 { 0x07, HDA_INPUT, 1 },
4562 { 0x07, HDA_INPUT, 2 },
4563 { 0x07, HDA_INPUT, 3 },
4564 { 0x07, HDA_INPUT, 4 },
4570 * ALC260 configurations
4572 static const char *alc260_models[ALC260_MODEL_LAST] = {
4573 [ALC260_BASIC] = "basic",
4575 [ALC260_HP_3013] = "hp-3013",
4576 [ALC260_FUJITSU_S702X] = "fujitsu",
4577 [ALC260_ACER] = "acer",
4578 [ALC260_WILL] = "will",
4579 [ALC260_REPLACER_672V] = "replacer",
4580 #ifdef CONFIG_SND_DEBUG
4581 [ALC260_TEST] = "test",
4583 [ALC260_AUTO] = "auto",
4586 static struct snd_pci_quirk alc260_cfg_tbl[] = {
4587 SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER),
4588 SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER),
4589 SND_PCI_QUIRK(0x103c, 0x2808, "HP d5700", ALC260_HP_3013),
4590 SND_PCI_QUIRK(0x103c, 0x280a, "HP d5750", ALC260_HP_3013),
4591 SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013),
4592 SND_PCI_QUIRK(0x103c, 0x3011, "HP", ALC260_HP),
4593 SND_PCI_QUIRK(0x103c, 0x3012, "HP", ALC260_HP_3013),
4594 SND_PCI_QUIRK(0x103c, 0x3013, "HP", ALC260_HP_3013),
4595 SND_PCI_QUIRK(0x103c, 0x3014, "HP", ALC260_HP),
4596 SND_PCI_QUIRK(0x103c, 0x3015, "HP", ALC260_HP),
4597 SND_PCI_QUIRK(0x103c, 0x3016, "HP", ALC260_HP),
4598 SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_BASIC),
4599 SND_PCI_QUIRK(0x104d, 0x81cc, "Sony VAIO", ALC260_BASIC),
4600 SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC),
4601 SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X),
4602 SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC),
4603 SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_WILL),
4604 SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_REPLACER_672V),
4608 static struct alc_config_preset alc260_presets[] = {
4610 .mixers = { alc260_base_output_mixer,
4612 alc260_pc_beep_mixer,
4613 alc260_capture_mixer },
4614 .init_verbs = { alc260_init_verbs },
4615 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4616 .dac_nids = alc260_dac_nids,
4617 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
4618 .adc_nids = alc260_adc_nids,
4619 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4620 .channel_mode = alc260_modes,
4621 .input_mux = &alc260_capture_source,
4624 .mixers = { alc260_base_output_mixer,
4626 alc260_capture_alt_mixer },
4627 .init_verbs = { alc260_init_verbs },
4628 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4629 .dac_nids = alc260_dac_nids,
4630 .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
4631 .adc_nids = alc260_hp_adc_nids,
4632 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4633 .channel_mode = alc260_modes,
4634 .input_mux = &alc260_capture_source,
4636 [ALC260_HP_3013] = {
4637 .mixers = { alc260_hp_3013_mixer,
4639 alc260_capture_alt_mixer },
4640 .init_verbs = { alc260_hp_3013_init_verbs },
4641 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4642 .dac_nids = alc260_dac_nids,
4643 .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
4644 .adc_nids = alc260_hp_adc_nids,
4645 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4646 .channel_mode = alc260_modes,
4647 .input_mux = &alc260_capture_source,
4649 [ALC260_FUJITSU_S702X] = {
4650 .mixers = { alc260_fujitsu_mixer,
4651 alc260_capture_mixer },
4652 .init_verbs = { alc260_fujitsu_init_verbs },
4653 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4654 .dac_nids = alc260_dac_nids,
4655 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
4656 .adc_nids = alc260_dual_adc_nids,
4657 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4658 .channel_mode = alc260_modes,
4659 .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources),
4660 .input_mux = alc260_fujitsu_capture_sources,
4663 .mixers = { alc260_acer_mixer,
4664 alc260_capture_mixer },
4665 .init_verbs = { alc260_acer_init_verbs },
4666 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4667 .dac_nids = alc260_dac_nids,
4668 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
4669 .adc_nids = alc260_dual_adc_nids,
4670 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4671 .channel_mode = alc260_modes,
4672 .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
4673 .input_mux = alc260_acer_capture_sources,
4676 .mixers = { alc260_will_mixer,
4677 alc260_capture_mixer },
4678 .init_verbs = { alc260_init_verbs, alc260_will_verbs },
4679 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4680 .dac_nids = alc260_dac_nids,
4681 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
4682 .adc_nids = alc260_adc_nids,
4683 .dig_out_nid = ALC260_DIGOUT_NID,
4684 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4685 .channel_mode = alc260_modes,
4686 .input_mux = &alc260_capture_source,
4688 [ALC260_REPLACER_672V] = {
4689 .mixers = { alc260_replacer_672v_mixer,
4690 alc260_capture_mixer },
4691 .init_verbs = { alc260_init_verbs, alc260_replacer_672v_verbs },
4692 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4693 .dac_nids = alc260_dac_nids,
4694 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
4695 .adc_nids = alc260_adc_nids,
4696 .dig_out_nid = ALC260_DIGOUT_NID,
4697 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4698 .channel_mode = alc260_modes,
4699 .input_mux = &alc260_capture_source,
4700 .unsol_event = alc260_replacer_672v_unsol_event,
4701 .init_hook = alc260_replacer_672v_automute,
4703 #ifdef CONFIG_SND_DEBUG
4705 .mixers = { alc260_test_mixer,
4706 alc260_capture_mixer },
4707 .init_verbs = { alc260_test_init_verbs },
4708 .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
4709 .dac_nids = alc260_test_dac_nids,
4710 .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
4711 .adc_nids = alc260_test_adc_nids,
4712 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4713 .channel_mode = alc260_modes,
4714 .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources),
4715 .input_mux = alc260_test_capture_sources,
4720 static int patch_alc260(struct hda_codec *codec)
4722 struct alc_spec *spec;
4723 int err, board_config;
4725 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4731 board_config = snd_hda_check_board_config(codec, ALC260_MODEL_LAST,
4734 if (board_config < 0) {
4735 snd_printd(KERN_INFO "hda_codec: Unknown model for ALC260, "
4736 "trying auto-probe from BIOS...\n");
4737 board_config = ALC260_AUTO;
4740 if (board_config == ALC260_AUTO) {
4741 /* automatic parse from the BIOS config */
4742 err = alc260_parse_auto_config(codec);
4748 "hda_codec: Cannot set up configuration "
4749 "from BIOS. Using base mode...\n");
4750 board_config = ALC260_BASIC;
4754 if (board_config != ALC260_AUTO)
4755 setup_preset(spec, &alc260_presets[board_config]);
4757 spec->stream_name_analog = "ALC260 Analog";
4758 spec->stream_analog_playback = &alc260_pcm_analog_playback;
4759 spec->stream_analog_capture = &alc260_pcm_analog_capture;
4761 spec->stream_name_digital = "ALC260 Digital";
4762 spec->stream_digital_playback = &alc260_pcm_digital_playback;
4763 spec->stream_digital_capture = &alc260_pcm_digital_capture;
4765 codec->patch_ops = alc_patch_ops;
4766 if (board_config == ALC260_AUTO)
4767 spec->init_hook = alc260_auto_init;
4768 #ifdef CONFIG_SND_HDA_POWER_SAVE
4769 if (!spec->loopback.amplist)
4770 spec->loopback.amplist = alc260_loopbacks;
4780 * ALC882 is almost identical with ALC880 but has cleaner and more flexible
4781 * configuration. Each pin widget can choose any input DACs and a mixer.
4782 * Each ADC is connected from a mixer of all inputs. This makes possible
4783 * 6-channel independent captures.
4785 * In addition, an independent DAC for the multi-playback (not used in this
4788 #define ALC882_DIGOUT_NID 0x06
4789 #define ALC882_DIGIN_NID 0x0a
4791 static struct hda_channel_mode alc882_ch_modes[1] = {
4795 static hda_nid_t alc882_dac_nids[4] = {
4796 /* front, rear, clfe, rear_surr */
4797 0x02, 0x03, 0x04, 0x05
4800 /* identical with ALC880 */
4801 #define alc882_adc_nids alc880_adc_nids
4802 #define alc882_adc_nids_alt alc880_adc_nids_alt
4805 /* FIXME: should be a matrix-type input source selection */
4807 static struct hda_input_mux alc882_capture_source = {
4811 { "Front Mic", 0x1 },
4816 #define alc882_mux_enum_info alc_mux_enum_info
4817 #define alc882_mux_enum_get alc_mux_enum_get
4819 static int alc882_mux_enum_put(struct snd_kcontrol *kcontrol,
4820 struct snd_ctl_elem_value *ucontrol)
4822 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4823 struct alc_spec *spec = codec->spec;
4824 const struct hda_input_mux *imux = spec->input_mux;
4825 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
4826 static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
4827 hda_nid_t nid = capture_mixers[adc_idx];
4828 unsigned int *cur_val = &spec->cur_mux[adc_idx];
4829 unsigned int i, idx;
4831 idx = ucontrol->value.enumerated.item[0];
4832 if (idx >= imux->num_items)
4833 idx = imux->num_items - 1;
4834 if (*cur_val == idx)
4836 for (i = 0; i < imux->num_items; i++) {
4837 unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
4838 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
4839 imux->items[i].index,
4849 static struct hda_verb alc882_3ST_ch2_init[] = {
4850 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
4851 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
4852 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
4853 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
4860 static struct hda_verb alc882_3ST_ch6_init[] = {
4861 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4862 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
4863 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
4864 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4865 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
4866 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
4870 static struct hda_channel_mode alc882_3ST_6ch_modes[2] = {
4871 { 2, alc882_3ST_ch2_init },
4872 { 6, alc882_3ST_ch6_init },
4878 static struct hda_verb alc882_sixstack_ch6_init[] = {
4879 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
4880 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4881 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4882 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4889 static struct hda_verb alc882_sixstack_ch8_init[] = {
4890 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4891 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4892 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4893 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4897 static struct hda_channel_mode alc882_sixstack_modes[2] = {
4898 { 6, alc882_sixstack_ch6_init },
4899 { 8, alc882_sixstack_ch8_init },
4903 * macbook pro ALC885 can switch LineIn to LineOut without loosing Mic
4909 static struct hda_verb alc885_mbp_ch2_init[] = {
4910 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
4911 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4912 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4919 static struct hda_verb alc885_mbp_ch6_init[] = {
4920 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4921 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4922 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
4923 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4924 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4928 static struct hda_channel_mode alc885_mbp_6ch_modes[2] = {
4929 { 2, alc885_mbp_ch2_init },
4930 { 6, alc885_mbp_ch6_init },
4934 /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
4935 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
4937 static struct snd_kcontrol_new alc882_base_mixer[] = {
4938 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
4939 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
4940 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
4941 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
4942 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
4943 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
4944 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
4945 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
4946 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
4947 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
4948 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
4949 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
4950 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
4951 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
4952 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
4953 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
4954 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
4955 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
4956 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
4957 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
4958 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
4959 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
4960 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
4964 static struct snd_kcontrol_new alc885_mbp3_mixer[] = {
4965 HDA_CODEC_VOLUME("Master Volume", 0x0c, 0x00, HDA_OUTPUT),
4966 HDA_BIND_MUTE ("Master Switch", 0x0c, 0x02, HDA_INPUT),
4967 HDA_CODEC_MUTE ("Speaker Switch", 0x14, 0x00, HDA_OUTPUT),
4968 HDA_CODEC_VOLUME("Line Out Volume", 0x0d,0x00, HDA_OUTPUT),
4969 HDA_CODEC_VOLUME("Line In Playback Volume", 0x0b, 0x02, HDA_INPUT),
4970 HDA_CODEC_MUTE ("Line In Playback Switch", 0x0b, 0x02, HDA_INPUT),
4971 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
4972 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
4973 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0x00, HDA_INPUT),
4974 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
4977 static struct snd_kcontrol_new alc882_w2jc_mixer[] = {
4978 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
4979 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
4980 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
4981 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
4982 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
4983 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
4984 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
4985 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
4986 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
4987 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
4988 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
4992 static struct snd_kcontrol_new alc882_targa_mixer[] = {
4993 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
4994 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
4995 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
4996 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
4997 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
4998 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
4999 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5000 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5001 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5002 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
5003 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
5007 /* Pin assignment: Front=0x14, HP = 0x15, Front = 0x16, ???
5008 * Front Mic=0x18, Line In = 0x1a, Line In = 0x1b, CD = 0x1c
5010 static struct snd_kcontrol_new alc882_asus_a7j_mixer[] = {
5011 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5012 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
5013 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
5014 HDA_CODEC_MUTE("Mobile Front Playback Switch", 0x16, 0x0, HDA_OUTPUT),
5015 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5016 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5017 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5018 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5019 HDA_CODEC_VOLUME("Mobile Line Playback Volume", 0x0b, 0x03, HDA_INPUT),
5020 HDA_CODEC_MUTE("Mobile Line Playback Switch", 0x0b, 0x03, HDA_INPUT),
5021 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5022 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5026 static struct snd_kcontrol_new alc882_asus_a7m_mixer[] = {
5027 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5028 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5029 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
5030 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5031 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5032 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5033 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5034 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5035 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
5036 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5037 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
5038 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
5042 static struct snd_kcontrol_new alc882_chmode_mixer[] = {
5044 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5045 .name = "Channel Mode",
5046 .info = alc_ch_mode_info,
5047 .get = alc_ch_mode_get,
5048 .put = alc_ch_mode_put,
5053 static struct hda_verb alc882_init_verbs[] = {
5054 /* Front mixer: unmute input/output amp left and right (volume = 0) */
5055 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5056 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5057 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5059 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5060 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5061 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5063 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5064 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5065 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5067 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5068 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5069 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5071 /* Front Pin: output 0 (0x0c) */
5072 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5073 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5074 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
5075 /* Rear Pin: output 1 (0x0d) */
5076 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5077 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5078 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
5079 /* CLFE Pin: output 2 (0x0e) */
5080 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5081 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5082 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
5083 /* Side Pin: output 3 (0x0f) */
5084 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5085 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5086 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
5087 /* Mic (rear) pin: input vref at 80% */
5088 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5089 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5090 /* Front Mic pin: input vref at 80% */
5091 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5092 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5093 /* Line In pin: input */
5094 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
5095 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5096 /* Line-2 In: Headphone output (output 0 - 0x0c) */
5097 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5098 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5099 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
5100 /* CD pin widget for input */
5101 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
5103 /* FIXME: use matrix-type input source selection */
5104 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5105 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
5106 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5107 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5108 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5109 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5111 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5112 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5113 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5114 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5116 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5117 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5118 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5119 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5120 /* ADC1: mute amp left and right */
5121 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5122 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
5123 /* ADC2: mute amp left and right */
5124 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5125 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
5126 /* ADC3: mute amp left and right */
5127 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5128 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
5133 static struct hda_verb alc882_eapd_verbs[] = {
5134 /* change to EAPD mode */
5135 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
5136 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
5141 static struct snd_kcontrol_new alc882_macpro_mixer[] = {
5142 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5143 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5144 HDA_CODEC_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT),
5145 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
5146 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
5147 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x02, HDA_INPUT),
5148 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x02, HDA_INPUT),
5152 static struct hda_verb alc882_macpro_init_verbs[] = {
5153 /* Front mixer: unmute input/output amp left and right (volume = 0) */
5154 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5155 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5156 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5157 /* Front Pin: output 0 (0x0c) */
5158 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5159 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5160 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
5161 /* Front Mic pin: input vref at 80% */
5162 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5163 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5164 /* Speaker: output */
5165 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5166 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5167 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x04},
5168 /* Headphone output (output 0 - 0x0c) */
5169 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5170 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5171 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
5173 /* FIXME: use matrix-type input source selection */
5174 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5175 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
5176 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5177 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5178 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5179 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5181 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5182 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5183 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5184 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5186 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5187 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5188 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5189 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5190 /* ADC1: mute amp left and right */
5191 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5192 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
5193 /* ADC2: mute amp left and right */
5194 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5195 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
5196 /* ADC3: mute amp left and right */
5197 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5198 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
5203 /* Macbook Pro rev3 */
5204 static struct hda_verb alc885_mbp3_init_verbs[] = {
5205 /* Front mixer: unmute input/output amp left and right (volume = 0) */
5206 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5207 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5208 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5210 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5211 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5212 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5213 /* Front Pin: output 0 (0x0c) */
5214 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5215 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5216 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
5217 /* HP Pin: output 0 (0x0d) */
5218 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4},
5219 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5220 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
5221 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
5222 /* Mic (rear) pin: input vref at 80% */
5223 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5224 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5225 /* Front Mic pin: input vref at 80% */
5226 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5227 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5228 /* Line In pin: use output 1 when in LineOut mode */
5229 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
5230 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5231 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
5233 /* FIXME: use matrix-type input source selection */
5234 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5235 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
5236 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5237 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5238 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5239 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5241 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5242 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5243 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5244 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5246 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5247 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5248 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5249 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5250 /* ADC1: mute amp left and right */
5251 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5252 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
5253 /* ADC2: mute amp left and right */
5254 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5255 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
5256 /* ADC3: mute amp left and right */
5257 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5258 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
5263 /* iMac 24 mixer. */
5264 static struct snd_kcontrol_new alc885_imac24_mixer[] = {
5265 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
5266 HDA_CODEC_MUTE("Master Playback Switch", 0x0c, 0x00, HDA_INPUT),
5270 /* iMac 24 init verbs. */
5271 static struct hda_verb alc885_imac24_init_verbs[] = {
5272 /* Internal speakers: output 0 (0x0c) */
5273 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5274 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5275 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
5276 /* Internal speakers: output 0 (0x0c) */
5277 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5278 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5279 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
5280 /* Headphone: output 0 (0x0c) */
5281 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5282 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5283 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
5284 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
5285 /* Front Mic: input vref at 80% */
5286 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5287 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5291 /* Toggle speaker-output according to the hp-jack state */
5292 static void alc885_imac24_automute(struct hda_codec *codec)
5294 unsigned int present;
5296 present = snd_hda_codec_read(codec, 0x14, 0,
5297 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
5298 snd_hda_codec_amp_stereo(codec, 0x18, HDA_OUTPUT, 0,
5299 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
5300 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_OUTPUT, 0,
5301 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
5304 /* Processes unsolicited events. */
5305 static void alc885_imac24_unsol_event(struct hda_codec *codec,
5308 /* Headphone insertion or removal. */
5309 if ((res >> 26) == ALC880_HP_EVENT)
5310 alc885_imac24_automute(codec);
5313 static void alc885_mbp3_automute(struct hda_codec *codec)
5315 unsigned int present;
5317 present = snd_hda_codec_read(codec, 0x15, 0,
5318 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
5319 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
5320 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
5321 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
5322 HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
5325 static void alc885_mbp3_unsol_event(struct hda_codec *codec,
5328 /* Headphone insertion or removal. */
5329 if ((res >> 26) == ALC880_HP_EVENT)
5330 alc885_mbp3_automute(codec);
5334 static struct hda_verb alc882_targa_verbs[] = {
5335 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5336 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5338 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5339 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5341 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
5342 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
5343 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
5345 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
5346 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
5347 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
5348 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
5352 /* toggle speaker-output according to the hp-jack state */
5353 static void alc882_targa_automute(struct hda_codec *codec)
5355 unsigned int present;
5357 present = snd_hda_codec_read(codec, 0x14, 0,
5358 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
5359 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
5360 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
5361 snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
5365 static void alc882_targa_unsol_event(struct hda_codec *codec, unsigned int res)
5367 /* Looks like the unsol event is incompatible with the standard
5368 * definition. 4bit tag is placed at 26 bit!
5370 if (((res >> 26) == ALC880_HP_EVENT)) {
5371 alc882_targa_automute(codec);
5375 static struct hda_verb alc882_asus_a7j_verbs[] = {
5376 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5377 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5379 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5380 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5381 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5383 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
5384 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
5385 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
5387 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
5388 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
5389 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
5393 static struct hda_verb alc882_asus_a7m_verbs[] = {
5394 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5395 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5397 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5398 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5399 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5401 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
5402 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
5403 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
5405 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
5406 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
5407 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
5411 static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
5413 unsigned int gpiostate, gpiomask, gpiodir;
5415 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
5416 AC_VERB_GET_GPIO_DATA, 0);
5419 gpiostate |= (1 << pin);
5421 gpiostate &= ~(1 << pin);
5423 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
5424 AC_VERB_GET_GPIO_MASK, 0);
5425 gpiomask |= (1 << pin);
5427 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
5428 AC_VERB_GET_GPIO_DIRECTION, 0);
5429 gpiodir |= (1 << pin);
5432 snd_hda_codec_write(codec, codec->afg, 0,
5433 AC_VERB_SET_GPIO_MASK, gpiomask);
5434 snd_hda_codec_write(codec, codec->afg, 0,
5435 AC_VERB_SET_GPIO_DIRECTION, gpiodir);
5439 snd_hda_codec_write(codec, codec->afg, 0,
5440 AC_VERB_SET_GPIO_DATA, gpiostate);
5443 /* set up GPIO at initialization */
5444 static void alc885_macpro_init_hook(struct hda_codec *codec)
5446 alc882_gpio_mute(codec, 0, 0);
5447 alc882_gpio_mute(codec, 1, 0);
5450 /* set up GPIO and update auto-muting at initialization */
5451 static void alc885_imac24_init_hook(struct hda_codec *codec)
5453 alc885_macpro_init_hook(codec);
5454 alc885_imac24_automute(codec);
5458 * generic initialization of ADC, input mixers and output mixers
5460 static struct hda_verb alc882_auto_init_verbs[] = {
5462 * Unmute ADC0-2 and set the default input to mic-in
5464 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
5465 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5466 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
5467 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5468 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
5469 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5471 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
5473 * Note: PASD motherboards uses the Line In 2 as the input for
5474 * front panel mic (mic 2)
5476 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
5477 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5478 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5479 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5480 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5481 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5484 * Set up output mixers (0x0c - 0x0f)
5486 /* set vol=0 to output mixers */
5487 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5488 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5489 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5490 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5491 /* set up input amps for analog loopback */
5492 /* Amp Indices: DAC = 0, mixer = 1 */
5493 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5494 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5495 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5496 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5497 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5498 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5499 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5500 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5501 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5502 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5504 /* FIXME: use matrix-type input source selection */
5505 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5506 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
5507 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5508 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
5509 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
5510 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
5512 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5513 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
5514 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
5515 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
5517 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5518 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
5519 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
5520 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
5525 /* capture mixer elements */
5526 static struct snd_kcontrol_new alc882_capture_alt_mixer[] = {
5527 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
5528 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
5529 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
5530 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
5532 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5533 /* The multiple "Capture Source" controls confuse alsamixer
5534 * So call somewhat different..
5535 * FIXME: the controls appear in the "playback" view!
5537 /* .name = "Capture Source", */
5538 .name = "Input Source",
5540 .info = alc882_mux_enum_info,
5541 .get = alc882_mux_enum_get,
5542 .put = alc882_mux_enum_put,
5547 static struct snd_kcontrol_new alc882_capture_mixer[] = {
5548 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
5549 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
5550 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
5551 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
5552 HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
5553 HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
5555 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5556 /* The multiple "Capture Source" controls confuse alsamixer
5557 * So call somewhat different..
5558 * FIXME: the controls appear in the "playback" view!
5560 /* .name = "Capture Source", */
5561 .name = "Input Source",
5563 .info = alc882_mux_enum_info,
5564 .get = alc882_mux_enum_get,
5565 .put = alc882_mux_enum_put,
5570 #ifdef CONFIG_SND_HDA_POWER_SAVE
5571 #define alc882_loopbacks alc880_loopbacks
5574 /* pcm configuration: identiacal with ALC880 */
5575 #define alc882_pcm_analog_playback alc880_pcm_analog_playback
5576 #define alc882_pcm_analog_capture alc880_pcm_analog_capture
5577 #define alc882_pcm_digital_playback alc880_pcm_digital_playback
5578 #define alc882_pcm_digital_capture alc880_pcm_digital_capture
5581 * configuration and preset
5583 static const char *alc882_models[ALC882_MODEL_LAST] = {
5584 [ALC882_3ST_DIG] = "3stack-dig",
5585 [ALC882_6ST_DIG] = "6stack-dig",
5586 [ALC882_ARIMA] = "arima",
5587 [ALC882_W2JC] = "w2jc",
5588 [ALC882_TARGA] = "targa",
5589 [ALC882_ASUS_A7J] = "asus-a7j",
5590 [ALC882_ASUS_A7M] = "asus-a7m",
5591 [ALC885_MACPRO] = "macpro",
5592 [ALC885_MBP3] = "mbp3",
5593 [ALC885_IMAC24] = "imac24",
5594 [ALC882_AUTO] = "auto",
5597 static struct snd_pci_quirk alc882_cfg_tbl[] = {
5598 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG),
5599 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG),
5600 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG),
5601 SND_PCI_QUIRK(0x1462, 0x28fb, "Targa T8", ALC882_TARGA), /* MSI-1049 T8 */
5602 SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA),
5603 SND_PCI_QUIRK(0x1043, 0x060d, "Asus A7J", ALC882_ASUS_A7J),
5604 SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_ASUS_A7M),
5605 SND_PCI_QUIRK(0x1043, 0x817f, "Asus P5LD2", ALC882_6ST_DIG),
5606 SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG),
5607 SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_W2JC),
5611 static struct alc_config_preset alc882_presets[] = {
5612 [ALC882_3ST_DIG] = {
5613 .mixers = { alc882_base_mixer },
5614 .init_verbs = { alc882_init_verbs },
5615 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5616 .dac_nids = alc882_dac_nids,
5617 .dig_out_nid = ALC882_DIGOUT_NID,
5618 .dig_in_nid = ALC882_DIGIN_NID,
5619 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
5620 .channel_mode = alc882_ch_modes,
5622 .input_mux = &alc882_capture_source,
5624 [ALC882_6ST_DIG] = {
5625 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
5626 .init_verbs = { alc882_init_verbs },
5627 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5628 .dac_nids = alc882_dac_nids,
5629 .dig_out_nid = ALC882_DIGOUT_NID,
5630 .dig_in_nid = ALC882_DIGIN_NID,
5631 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
5632 .channel_mode = alc882_sixstack_modes,
5633 .input_mux = &alc882_capture_source,
5636 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
5637 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs },
5638 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5639 .dac_nids = alc882_dac_nids,
5640 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
5641 .channel_mode = alc882_sixstack_modes,
5642 .input_mux = &alc882_capture_source,
5645 .mixers = { alc882_w2jc_mixer, alc882_chmode_mixer },
5646 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs,
5647 alc880_gpio1_init_verbs },
5648 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5649 .dac_nids = alc882_dac_nids,
5650 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
5651 .channel_mode = alc880_threestack_modes,
5653 .input_mux = &alc882_capture_source,
5654 .dig_out_nid = ALC882_DIGOUT_NID,
5657 .mixers = { alc885_mbp3_mixer, alc882_chmode_mixer },
5658 .init_verbs = { alc885_mbp3_init_verbs,
5659 alc880_gpio1_init_verbs },
5660 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5661 .dac_nids = alc882_dac_nids,
5662 .channel_mode = alc885_mbp_6ch_modes,
5663 .num_channel_mode = ARRAY_SIZE(alc885_mbp_6ch_modes),
5664 .input_mux = &alc882_capture_source,
5665 .dig_out_nid = ALC882_DIGOUT_NID,
5666 .dig_in_nid = ALC882_DIGIN_NID,
5667 .unsol_event = alc885_mbp3_unsol_event,
5668 .init_hook = alc885_mbp3_automute,
5671 .mixers = { alc882_macpro_mixer },
5672 .init_verbs = { alc882_macpro_init_verbs },
5673 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5674 .dac_nids = alc882_dac_nids,
5675 .dig_out_nid = ALC882_DIGOUT_NID,
5676 .dig_in_nid = ALC882_DIGIN_NID,
5677 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
5678 .channel_mode = alc882_ch_modes,
5679 .input_mux = &alc882_capture_source,
5680 .init_hook = alc885_macpro_init_hook,
5683 .mixers = { alc885_imac24_mixer },
5684 .init_verbs = { alc885_imac24_init_verbs },
5685 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5686 .dac_nids = alc882_dac_nids,
5687 .dig_out_nid = ALC882_DIGOUT_NID,
5688 .dig_in_nid = ALC882_DIGIN_NID,
5689 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
5690 .channel_mode = alc882_ch_modes,
5691 .input_mux = &alc882_capture_source,
5692 .unsol_event = alc885_imac24_unsol_event,
5693 .init_hook = alc885_imac24_init_hook,
5696 .mixers = { alc882_targa_mixer, alc882_chmode_mixer,
5697 alc882_capture_mixer },
5698 .init_verbs = { alc882_init_verbs, alc882_targa_verbs},
5699 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5700 .dac_nids = alc882_dac_nids,
5701 .dig_out_nid = ALC882_DIGOUT_NID,
5702 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
5703 .adc_nids = alc882_adc_nids,
5704 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
5705 .channel_mode = alc882_3ST_6ch_modes,
5707 .input_mux = &alc882_capture_source,
5708 .unsol_event = alc882_targa_unsol_event,
5709 .init_hook = alc882_targa_automute,
5711 [ALC882_ASUS_A7J] = {
5712 .mixers = { alc882_asus_a7j_mixer, alc882_chmode_mixer,
5713 alc882_capture_mixer },
5714 .init_verbs = { alc882_init_verbs, alc882_asus_a7j_verbs},
5715 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5716 .dac_nids = alc882_dac_nids,
5717 .dig_out_nid = ALC882_DIGOUT_NID,
5718 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
5719 .adc_nids = alc882_adc_nids,
5720 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
5721 .channel_mode = alc882_3ST_6ch_modes,
5723 .input_mux = &alc882_capture_source,
5725 [ALC882_ASUS_A7M] = {
5726 .mixers = { alc882_asus_a7m_mixer, alc882_chmode_mixer },
5727 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs,
5728 alc880_gpio1_init_verbs,
5729 alc882_asus_a7m_verbs },
5730 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5731 .dac_nids = alc882_dac_nids,
5732 .dig_out_nid = ALC882_DIGOUT_NID,
5733 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
5734 .channel_mode = alc880_threestack_modes,
5736 .input_mux = &alc882_capture_source,
5745 PINFIX_ABIT_AW9D_MAX
5748 static struct alc_pincfg alc882_abit_aw9d_pinfix[] = {
5749 { 0x15, 0x01080104 }, /* side */
5750 { 0x16, 0x01011012 }, /* rear */
5751 { 0x17, 0x01016011 }, /* clfe */
5755 static const struct alc_pincfg *alc882_pin_fixes[] = {
5756 [PINFIX_ABIT_AW9D_MAX] = alc882_abit_aw9d_pinfix,
5759 static struct snd_pci_quirk alc882_pinfix_tbl[] = {
5760 SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", PINFIX_ABIT_AW9D_MAX),
5765 * BIOS auto configuration
5767 static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
5768 hda_nid_t nid, int pin_type,
5772 struct alc_spec *spec = codec->spec;
5775 if (spec->multiout.dac_nids[dac_idx] == 0x25)
5778 idx = spec->multiout.dac_nids[dac_idx] - 2;
5780 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5782 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
5784 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
5788 static void alc882_auto_init_multi_out(struct hda_codec *codec)
5790 struct alc_spec *spec = codec->spec;
5793 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
5794 for (i = 0; i <= HDA_SIDE; i++) {
5795 hda_nid_t nid = spec->autocfg.line_out_pins[i];
5796 int pin_type = get_pin_type(spec->autocfg.line_out_type);
5798 alc882_auto_set_output_and_unmute(codec, nid, pin_type,
5803 static void alc882_auto_init_hp_out(struct hda_codec *codec)
5805 struct alc_spec *spec = codec->spec;
5808 pin = spec->autocfg.hp_pins[0];
5809 if (pin) /* connect to front */
5811 alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
5814 #define alc882_is_input_pin(nid) alc880_is_input_pin(nid)
5815 #define ALC882_PIN_CD_NID ALC880_PIN_CD_NID
5817 static void alc882_auto_init_analog_input(struct hda_codec *codec)
5819 struct alc_spec *spec = codec->spec;
5822 for (i = 0; i < AUTO_PIN_LAST; i++) {
5823 hda_nid_t nid = spec->autocfg.input_pins[i];
5824 if (alc882_is_input_pin(nid)) {
5825 snd_hda_codec_write(codec, nid, 0,
5826 AC_VERB_SET_PIN_WIDGET_CONTROL,
5827 i <= AUTO_PIN_FRONT_MIC ?
5828 PIN_VREF80 : PIN_IN);
5829 if (nid != ALC882_PIN_CD_NID)
5830 snd_hda_codec_write(codec, nid, 0,
5831 AC_VERB_SET_AMP_GAIN_MUTE,
5837 /* add mic boosts if needed */
5838 static int alc_auto_add_mic_boost(struct hda_codec *codec)
5840 struct alc_spec *spec = codec->spec;
5844 nid = spec->autocfg.input_pins[AUTO_PIN_MIC];
5846 err = add_control(spec, ALC_CTL_WIDGET_VOL,
5848 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
5852 nid = spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC];
5854 err = add_control(spec, ALC_CTL_WIDGET_VOL,
5856 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
5863 /* almost identical with ALC880 parser... */
5864 static int alc882_parse_auto_config(struct hda_codec *codec)
5866 struct alc_spec *spec = codec->spec;
5867 int err = alc880_parse_auto_config(codec);
5872 return 0; /* no config found */
5874 err = alc_auto_add_mic_boost(codec);
5878 /* hack - override the init verbs */
5879 spec->init_verbs[0] = alc882_auto_init_verbs;
5881 return 1; /* config found */
5884 /* additional initialization for auto-configuration model */
5885 static void alc882_auto_init(struct hda_codec *codec)
5887 alc882_auto_init_multi_out(codec);
5888 alc882_auto_init_hp_out(codec);
5889 alc882_auto_init_analog_input(codec);
5892 static int patch_alc882(struct hda_codec *codec)
5894 struct alc_spec *spec;
5895 int err, board_config;
5897 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5903 board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST,
5907 if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
5908 /* Pick up systems that don't supply PCI SSID */
5909 switch (codec->subsystem_id) {
5910 case 0x106b0c00: /* Mac Pro */
5911 board_config = ALC885_MACPRO;
5913 case 0x106b1000: /* iMac 24 */
5914 board_config = ALC885_IMAC24;
5916 case 0x106b2c00: /* Macbook Pro rev3 */
5917 board_config = ALC885_MBP3;
5920 printk(KERN_INFO "hda_codec: Unknown model for ALC882, "
5921 "trying auto-probe from BIOS...\n");
5922 board_config = ALC882_AUTO;
5926 alc_fix_pincfg(codec, alc882_pinfix_tbl, alc882_pin_fixes);
5928 if (board_config == ALC882_AUTO) {
5929 /* automatic parse from the BIOS config */
5930 err = alc882_parse_auto_config(codec);
5936 "hda_codec: Cannot set up configuration "
5937 "from BIOS. Using base mode...\n");
5938 board_config = ALC882_3ST_DIG;
5942 if (board_config != ALC882_AUTO)
5943 setup_preset(spec, &alc882_presets[board_config]);
5945 spec->stream_name_analog = "ALC882 Analog";
5946 spec->stream_analog_playback = &alc882_pcm_analog_playback;
5947 spec->stream_analog_capture = &alc882_pcm_analog_capture;
5949 spec->stream_name_digital = "ALC882 Digital";
5950 spec->stream_digital_playback = &alc882_pcm_digital_playback;
5951 spec->stream_digital_capture = &alc882_pcm_digital_capture;
5953 if (!spec->adc_nids && spec->input_mux) {
5954 /* check whether NID 0x07 is valid */
5955 unsigned int wcap = get_wcaps(codec, 0x07);
5957 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
5958 if (wcap != AC_WID_AUD_IN) {
5959 spec->adc_nids = alc882_adc_nids_alt;
5960 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids_alt);
5961 spec->mixers[spec->num_mixers] =
5962 alc882_capture_alt_mixer;
5965 spec->adc_nids = alc882_adc_nids;
5966 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids);
5967 spec->mixers[spec->num_mixers] = alc882_capture_mixer;
5972 codec->patch_ops = alc_patch_ops;
5973 if (board_config == ALC882_AUTO)
5974 spec->init_hook = alc882_auto_init;
5975 #ifdef CONFIG_SND_HDA_POWER_SAVE
5976 if (!spec->loopback.amplist)
5977 spec->loopback.amplist = alc882_loopbacks;
5986 * ALC883 is almost identical with ALC880 but has cleaner and more flexible
5987 * configuration. Each pin widget can choose any input DACs and a mixer.
5988 * Each ADC is connected from a mixer of all inputs. This makes possible
5989 * 6-channel independent captures.
5991 * In addition, an independent DAC for the multi-playback (not used in this
5994 #define ALC883_DIGOUT_NID 0x06
5995 #define ALC883_DIGIN_NID 0x0a
5997 static hda_nid_t alc883_dac_nids[4] = {
5998 /* front, rear, clfe, rear_surr */
5999 0x02, 0x04, 0x03, 0x05
6002 static hda_nid_t alc883_adc_nids[2] = {
6008 /* FIXME: should be a matrix-type input source selection */
6010 static struct hda_input_mux alc883_capture_source = {
6014 { "Front Mic", 0x1 },
6020 static struct hda_input_mux alc883_lenovo_101e_capture_source = {
6028 static struct hda_input_mux alc883_lenovo_nb0763_capture_source = {
6038 #define alc883_mux_enum_info alc_mux_enum_info
6039 #define alc883_mux_enum_get alc_mux_enum_get
6041 static int alc883_mux_enum_put(struct snd_kcontrol *kcontrol,
6042 struct snd_ctl_elem_value *ucontrol)
6044 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
6045 struct alc_spec *spec = codec->spec;
6046 const struct hda_input_mux *imux = spec->input_mux;
6047 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
6048 static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
6049 hda_nid_t nid = capture_mixers[adc_idx];
6050 unsigned int *cur_val = &spec->cur_mux[adc_idx];
6051 unsigned int i, idx;
6053 idx = ucontrol->value.enumerated.item[0];
6054 if (idx >= imux->num_items)
6055 idx = imux->num_items - 1;
6056 if (*cur_val == idx)
6058 for (i = 0; i < imux->num_items; i++) {
6059 unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
6060 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
6061 imux->items[i].index,
6071 static struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
6078 static struct hda_verb alc883_3ST_ch2_init[] = {
6079 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6080 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6081 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6082 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6089 static struct hda_verb alc883_3ST_ch6_init[] = {
6090 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6091 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6092 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
6093 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6094 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6095 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6099 static struct hda_channel_mode alc883_3ST_6ch_modes[2] = {
6100 { 2, alc883_3ST_ch2_init },
6101 { 6, alc883_3ST_ch6_init },
6107 static struct hda_verb alc883_sixstack_ch6_init[] = {
6108 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
6109 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6110 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6111 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6118 static struct hda_verb alc883_sixstack_ch8_init[] = {
6119 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6120 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6121 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6122 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6126 static struct hda_channel_mode alc883_sixstack_modes[2] = {
6127 { 6, alc883_sixstack_ch6_init },
6128 { 8, alc883_sixstack_ch8_init },
6131 static struct hda_verb alc883_medion_eapd_verbs[] = {
6132 /* eanable EAPD on medion laptop */
6133 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
6134 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
6138 /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
6139 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
6142 static struct snd_kcontrol_new alc883_base_mixer[] = {
6143 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6144 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6145 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
6146 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
6147 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
6148 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
6149 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
6150 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
6151 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
6152 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
6153 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6154 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6155 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6156 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6157 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6158 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6159 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6160 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6161 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6162 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
6163 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6164 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6165 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6166 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6167 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6168 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6169 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6171 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6172 /* .name = "Capture Source", */
6173 .name = "Input Source",
6175 .info = alc883_mux_enum_info,
6176 .get = alc883_mux_enum_get,
6177 .put = alc883_mux_enum_put,
6182 static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
6183 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6184 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6185 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6186 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6187 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6188 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6189 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6190 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6191 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6192 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6193 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6194 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
6195 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6196 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6197 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6198 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6199 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6200 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6201 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6203 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6204 /* .name = "Capture Source", */
6205 .name = "Input Source",
6207 .info = alc883_mux_enum_info,
6208 .get = alc883_mux_enum_get,
6209 .put = alc883_mux_enum_put,
6214 static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
6215 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6216 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6217 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
6218 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
6219 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
6220 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
6221 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
6222 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
6223 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6224 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6225 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6226 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6227 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6228 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6229 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6230 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6231 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6232 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
6233 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6234 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6235 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6236 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6237 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6238 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6239 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6241 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6242 /* .name = "Capture Source", */
6243 .name = "Input Source",
6245 .info = alc883_mux_enum_info,
6246 .get = alc883_mux_enum_get,
6247 .put = alc883_mux_enum_put,
6252 static struct snd_kcontrol_new alc883_fivestack_mixer[] = {
6253 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6254 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6255 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
6256 HDA_CODEC_MUTE("Surround Playback Switch", 0x15, 0x0, HDA_OUTPUT),
6257 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
6258 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
6259 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x16, 1, 0x0, HDA_OUTPUT),
6260 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
6261 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6262 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6263 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6264 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6265 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6266 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6267 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6268 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6269 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6270 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
6271 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6272 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6273 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6274 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6275 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6278 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6279 /* .name = "Capture Source", */
6280 .name = "Input Source",
6282 .info = alc883_mux_enum_info,
6283 .get = alc883_mux_enum_get,
6284 .put = alc883_mux_enum_put,
6289 static struct snd_kcontrol_new alc883_tagra_mixer[] = {
6290 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6291 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6292 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6293 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
6294 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
6295 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
6296 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
6297 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
6298 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
6299 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6300 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6301 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6302 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6303 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6304 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6305 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6306 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6307 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6308 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6309 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6311 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6312 /* .name = "Capture Source", */
6313 .name = "Input Source",
6315 .info = alc883_mux_enum_info,
6316 .get = alc883_mux_enum_get,
6317 .put = alc883_mux_enum_put,
6322 static struct snd_kcontrol_new alc883_tagra_2ch_mixer[] = {
6323 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6324 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6325 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6326 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6327 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6328 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6329 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6330 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6331 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6332 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6333 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6334 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6336 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6337 /* .name = "Capture Source", */
6338 .name = "Input Source",
6340 .info = alc883_mux_enum_info,
6341 .get = alc883_mux_enum_get,
6342 .put = alc883_mux_enum_put,
6347 static struct snd_kcontrol_new alc883_lenovo_101e_2ch_mixer[] = {
6348 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6349 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6350 HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
6351 HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT),
6352 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6353 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6354 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6355 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6356 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6357 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6359 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6360 /* .name = "Capture Source", */
6361 .name = "Input Source",
6363 .info = alc883_mux_enum_info,
6364 .get = alc883_mux_enum_get,
6365 .put = alc883_mux_enum_put,
6370 static struct snd_kcontrol_new alc883_lenovo_nb0763_mixer[] = {
6371 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6372 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
6373 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6374 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6375 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6376 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6377 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6378 HDA_CODEC_VOLUME("iMic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6379 HDA_CODEC_MUTE("iMic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6380 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6381 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6382 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6383 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6385 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6386 /* .name = "Capture Source", */
6387 .name = "Input Source",
6389 .info = alc883_mux_enum_info,
6390 .get = alc883_mux_enum_get,
6391 .put = alc883_mux_enum_put,
6396 static struct snd_kcontrol_new alc883_medion_md2_mixer[] = {
6397 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6398 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6399 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
6400 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6401 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6402 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6403 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6404 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6405 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6406 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6407 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6408 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6409 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6411 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6412 /* .name = "Capture Source", */
6413 .name = "Input Source",
6415 .info = alc883_mux_enum_info,
6416 .get = alc883_mux_enum_get,
6417 .put = alc883_mux_enum_put,
6422 static struct snd_kcontrol_new alc888_6st_hp_mixer[] = {
6423 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6424 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6425 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
6426 HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
6427 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
6428 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
6429 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
6430 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
6431 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
6432 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
6433 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6434 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6435 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6436 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6437 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6438 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6439 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6440 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6441 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6442 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
6443 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6444 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6445 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6446 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6447 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6448 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6449 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6451 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6452 /* .name = "Capture Source", */
6453 .name = "Input Source",
6455 .info = alc883_mux_enum_info,
6456 .get = alc883_mux_enum_get,
6457 .put = alc883_mux_enum_put,
6462 static struct snd_kcontrol_new alc888_3st_hp_mixer[] = {
6463 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6464 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6465 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
6466 HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
6467 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
6468 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
6469 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
6470 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
6471 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6472 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6473 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6474 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6475 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6476 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6477 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6478 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6479 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6480 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
6481 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6482 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6483 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6484 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6485 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6486 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6487 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6489 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6490 /* .name = "Capture Source", */
6491 .name = "Input Source",
6493 .info = alc883_mux_enum_info,
6494 .get = alc883_mux_enum_get,
6495 .put = alc883_mux_enum_put,
6500 static struct snd_kcontrol_new alc883_acer_aspire_mixer[] = {
6501 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6502 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6503 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6504 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6505 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6506 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6507 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6508 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6509 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6510 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6511 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6512 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6514 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6515 /* .name = "Capture Source", */
6516 .name = "Input Source",
6518 .info = alc883_mux_enum_info,
6519 .get = alc883_mux_enum_get,
6520 .put = alc883_mux_enum_put,
6525 static struct snd_kcontrol_new alc883_chmode_mixer[] = {
6527 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6528 .name = "Channel Mode",
6529 .info = alc_ch_mode_info,
6530 .get = alc_ch_mode_get,
6531 .put = alc_ch_mode_put,
6536 static struct hda_verb alc883_init_verbs[] = {
6537 /* ADC1: mute amp left and right */
6538 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6539 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6540 /* ADC2: mute amp left and right */
6541 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6542 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
6543 /* Front mixer: unmute input/output amp left and right (volume = 0) */
6544 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6545 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6546 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6548 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6549 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6550 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6552 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6553 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6554 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6556 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6557 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6558 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6560 /* mute analog input loopbacks */
6561 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6562 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6563 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6564 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6565 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6567 /* Front Pin: output 0 (0x0c) */
6568 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6569 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6570 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
6571 /* Rear Pin: output 1 (0x0d) */
6572 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6573 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6574 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
6575 /* CLFE Pin: output 2 (0x0e) */
6576 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6577 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6578 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
6579 /* Side Pin: output 3 (0x0f) */
6580 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6581 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6582 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
6583 /* Mic (rear) pin: input vref at 80% */
6584 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6585 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6586 /* Front Mic pin: input vref at 80% */
6587 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6588 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6589 /* Line In pin: input */
6590 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
6591 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6592 /* Line-2 In: Headphone output (output 0 - 0x0c) */
6593 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6594 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6595 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
6596 /* CD pin widget for input */
6597 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
6599 /* FIXME: use matrix-type input source selection */
6600 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6602 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6603 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6604 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
6605 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
6607 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6608 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6609 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
6610 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
6614 static struct hda_verb alc883_tagra_verbs[] = {
6615 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6616 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6618 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6619 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6621 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
6622 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
6623 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6625 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
6626 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
6627 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
6628 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
6633 static struct hda_verb alc883_lenovo_101e_verbs[] = {
6634 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
6635 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT|AC_USRSP_EN},
6636 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT|AC_USRSP_EN},
6640 static struct hda_verb alc883_lenovo_nb0763_verbs[] = {
6641 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
6642 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6643 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
6644 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6648 static struct hda_verb alc888_lenovo_ms7195_verbs[] = {
6649 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6650 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6651 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
6652 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT | AC_USRSP_EN},
6653 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
6657 static struct hda_verb alc883_haier_w66_verbs[] = {
6658 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6659 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6661 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6663 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
6664 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6665 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
6666 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6670 static struct hda_verb alc888_6st_hp_verbs[] = {
6671 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
6672 {0x15, AC_VERB_SET_CONNECT_SEL, 0x02}, /* Rear : output 2 (0x0e) */
6673 {0x16, AC_VERB_SET_CONNECT_SEL, 0x01}, /* CLFE : output 1 (0x0d) */
6674 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03}, /* Side : output 3 (0x0f) */
6678 static struct hda_verb alc888_3st_hp_verbs[] = {
6679 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
6680 {0x18, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Rear : output 1 (0x0d) */
6681 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02}, /* CLFE : output 2 (0x0e) */
6685 static struct hda_verb alc888_3st_hp_2ch_init[] = {
6686 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6687 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6688 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6689 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6693 static struct hda_verb alc888_3st_hp_6ch_init[] = {
6694 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6695 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6696 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6697 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6701 static struct hda_channel_mode alc888_3st_hp_modes[2] = {
6702 { 2, alc888_3st_hp_2ch_init },
6703 { 6, alc888_3st_hp_6ch_init },
6706 /* toggle front-jack and RCA according to the hp-jack state */
6707 static void alc888_lenovo_ms7195_front_automute(struct hda_codec *codec)
6709 unsigned int present;
6711 present = snd_hda_codec_read(codec, 0x1b, 0,
6712 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
6713 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
6714 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
6715 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
6716 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
6719 /* toggle RCA according to the front-jack state */
6720 static void alc888_lenovo_ms7195_rca_automute(struct hda_codec *codec)
6722 unsigned int present;
6724 present = snd_hda_codec_read(codec, 0x14, 0,
6725 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
6726 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
6727 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
6730 static void alc883_lenovo_ms7195_unsol_event(struct hda_codec *codec,
6733 if ((res >> 26) == ALC880_HP_EVENT)
6734 alc888_lenovo_ms7195_front_automute(codec);
6735 if ((res >> 26) == ALC880_FRONT_EVENT)
6736 alc888_lenovo_ms7195_rca_automute(codec);
6739 static struct hda_verb alc883_medion_md2_verbs[] = {
6740 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6741 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6743 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6745 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
6749 /* toggle speaker-output according to the hp-jack state */
6750 static void alc883_medion_md2_automute(struct hda_codec *codec)
6752 unsigned int present;
6754 present = snd_hda_codec_read(codec, 0x14, 0,
6755 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
6756 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
6757 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
6760 static void alc883_medion_md2_unsol_event(struct hda_codec *codec,
6763 if ((res >> 26) == ALC880_HP_EVENT)
6764 alc883_medion_md2_automute(codec);
6767 /* toggle speaker-output according to the hp-jack state */
6768 static void alc883_tagra_automute(struct hda_codec *codec)
6770 unsigned int present;
6773 present = snd_hda_codec_read(codec, 0x14, 0,
6774 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
6775 bits = present ? HDA_AMP_MUTE : 0;
6776 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
6777 HDA_AMP_MUTE, bits);
6778 snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
6782 static void alc883_tagra_unsol_event(struct hda_codec *codec, unsigned int res)
6784 if ((res >> 26) == ALC880_HP_EVENT)
6785 alc883_tagra_automute(codec);
6788 static void alc883_haier_w66_automute(struct hda_codec *codec)
6790 unsigned int present;
6793 present = snd_hda_codec_read(codec, 0x1b, 0,
6794 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
6795 bits = present ? 0x80 : 0;
6796 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
6800 static void alc883_haier_w66_unsol_event(struct hda_codec *codec,
6803 if ((res >> 26) == ALC880_HP_EVENT)
6804 alc883_haier_w66_automute(codec);
6807 static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
6809 unsigned int present;
6812 present = snd_hda_codec_read(codec, 0x14, 0,
6813 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
6814 bits = present ? HDA_AMP_MUTE : 0;
6815 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
6816 HDA_AMP_MUTE, bits);
6819 static void alc883_lenovo_101e_all_automute(struct hda_codec *codec)
6821 unsigned int present;
6824 present = snd_hda_codec_read(codec, 0x1b, 0,
6825 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
6826 bits = present ? HDA_AMP_MUTE : 0;
6827 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
6828 HDA_AMP_MUTE, bits);
6829 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
6830 HDA_AMP_MUTE, bits);
6833 static void alc883_lenovo_101e_unsol_event(struct hda_codec *codec,
6836 if ((res >> 26) == ALC880_HP_EVENT)
6837 alc883_lenovo_101e_all_automute(codec);
6838 if ((res >> 26) == ALC880_FRONT_EVENT)
6839 alc883_lenovo_101e_ispeaker_automute(codec);
6842 /* toggle speaker-output according to the hp-jack state */
6843 static void alc883_acer_aspire_automute(struct hda_codec *codec)
6845 unsigned int present;
6847 present = snd_hda_codec_read(codec, 0x14, 0,
6848 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
6849 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
6850 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
6851 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
6852 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
6855 static void alc883_acer_aspire_unsol_event(struct hda_codec *codec,
6858 if ((res >> 26) == ALC880_HP_EVENT)
6859 alc883_acer_aspire_automute(codec);
6862 static struct hda_verb alc883_acer_eapd_verbs[] = {
6863 /* HP Pin: output 0 (0x0c) */
6864 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6865 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6866 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
6867 /* Front Pin: output 0 (0x0c) */
6868 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6869 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
6870 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6871 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00},
6872 /* eanable EAPD on medion laptop */
6873 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
6874 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
6875 /* enable unsolicited event */
6876 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
6881 * generic initialization of ADC, input mixers and output mixers
6883 static struct hda_verb alc883_auto_init_verbs[] = {
6885 * Unmute ADC0-2 and set the default input to mic-in
6887 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6888 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6889 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
6890 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6892 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
6894 * Note: PASD motherboards uses the Line In 2 as the input for
6895 * front panel mic (mic 2)
6897 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
6898 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6899 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6900 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6901 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6902 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6905 * Set up output mixers (0x0c - 0x0f)
6907 /* set vol=0 to output mixers */
6908 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6909 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6910 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6911 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6912 /* set up input amps for analog loopback */
6913 /* Amp Indices: DAC = 0, mixer = 1 */
6914 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6915 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6916 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6917 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6918 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6919 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6920 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6921 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6922 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6923 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6925 /* FIXME: use matrix-type input source selection */
6926 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6928 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6929 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6930 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
6931 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
6932 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
6934 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6935 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6936 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
6937 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
6938 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
6943 /* capture mixer elements */
6944 static struct snd_kcontrol_new alc883_capture_mixer[] = {
6945 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6946 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6947 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6948 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6950 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6951 /* The multiple "Capture Source" controls confuse alsamixer
6952 * So call somewhat different..
6953 * FIXME: the controls appear in the "playback" view!
6955 /* .name = "Capture Source", */
6956 .name = "Input Source",
6958 .info = alc882_mux_enum_info,
6959 .get = alc882_mux_enum_get,
6960 .put = alc882_mux_enum_put,
6965 #ifdef CONFIG_SND_HDA_POWER_SAVE
6966 #define alc883_loopbacks alc880_loopbacks
6969 /* pcm configuration: identiacal with ALC880 */
6970 #define alc883_pcm_analog_playback alc880_pcm_analog_playback
6971 #define alc883_pcm_analog_capture alc880_pcm_analog_capture
6972 #define alc883_pcm_digital_playback alc880_pcm_digital_playback
6973 #define alc883_pcm_digital_capture alc880_pcm_digital_capture
6976 * configuration and preset
6978 static const char *alc883_models[ALC883_MODEL_LAST] = {
6979 [ALC883_3ST_2ch_DIG] = "3stack-dig",
6980 [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig",
6981 [ALC883_3ST_6ch] = "3stack-6ch",
6982 [ALC883_6ST_DIG] = "6stack-dig",
6983 [ALC883_TARGA_DIG] = "targa-dig",
6984 [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig",
6985 [ALC883_ACER] = "acer",
6986 [ALC883_ACER_ASPIRE] = "acer-aspire",
6987 [ALC883_MEDION] = "medion",
6988 [ALC883_MEDION_MD2] = "medion-md2",
6989 [ALC883_LAPTOP_EAPD] = "laptop-eapd",
6990 [ALC883_LENOVO_101E_2ch] = "lenovo-101e",
6991 [ALC883_LENOVO_NB0763] = "lenovo-nb0763",
6992 [ALC888_LENOVO_MS7195_DIG] = "lenovo-ms7195-dig",
6993 [ALC883_HAIER_W66] = "haier-w66",
6994 [ALC888_6ST_HP] = "6stack-hp",
6995 [ALC888_3ST_HP] = "3stack-hp",
6996 [ALC883_AUTO] = "auto",
6999 static struct snd_pci_quirk alc883_cfg_tbl[] = {
7000 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC883_3ST_6ch_DIG),
7001 SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG),
7002 SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch),
7003 SND_PCI_QUIRK(0x1558, 0, "Clevo laptop", ALC883_LAPTOP_EAPD),
7004 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC883_6ST_DIG),
7005 SND_PCI_QUIRK(0x1458, 0xa002, "MSI", ALC883_6ST_DIG),
7006 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG),
7007 SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG),
7008 SND_PCI_QUIRK(0x1462, 0x7250, "MSI", ALC883_6ST_DIG),
7009 SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG),
7010 SND_PCI_QUIRK(0x1462, 0x7327, "MSI", ALC883_6ST_DIG),
7011 SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG),
7012 SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG),
7013 SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG),
7014 SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG),
7015 SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG),
7016 SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG),
7017 SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG),
7018 SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG),
7019 SND_PCI_QUIRK(0x1462, 0x3fdf, "MSI", ALC883_TARGA_DIG),
7020 SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG),
7021 SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG),
7022 SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG),
7023 SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG),
7024 SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_ACER_ASPIRE),
7025 SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_ACER_ASPIRE),
7026 SND_PCI_QUIRK(0x1025, 0x0112, "Acer Aspire 9303", ALC883_ACER_ASPIRE),
7027 SND_PCI_QUIRK(0x1025, 0, "Acer laptop", ALC883_ACER),
7028 SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch),
7029 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
7030 SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD),
7031 SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC883_3ST_6ch),
7032 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch),
7033 SND_PCI_QUIRK(0x17aa, 0x3bfd, "Lenovo NB0763", ALC883_LENOVO_NB0763),
7034 SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763),
7035 SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC888_6ST_HP),
7036 SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_3ST_HP),
7037 SND_PCI_QUIRK(0x103c, 0x2a4f, "HP Samba", ALC888_3ST_HP),
7038 SND_PCI_QUIRK(0x17c0, 0x4071, "MEDION MD2", ALC883_MEDION_MD2),
7039 SND_PCI_QUIRK(0x1991, 0x5625, "Haier W66", ALC883_HAIER_W66),
7040 SND_PCI_QUIRK(0x17aa, 0x3bfc, "Lenovo NB0763", ALC883_LENOVO_NB0763),
7044 static struct alc_config_preset alc883_presets[] = {
7045 [ALC883_3ST_2ch_DIG] = {
7046 .mixers = { alc883_3ST_2ch_mixer },
7047 .init_verbs = { alc883_init_verbs },
7048 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7049 .dac_nids = alc883_dac_nids,
7050 .dig_out_nid = ALC883_DIGOUT_NID,
7051 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7052 .adc_nids = alc883_adc_nids,
7053 .dig_in_nid = ALC883_DIGIN_NID,
7054 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7055 .channel_mode = alc883_3ST_2ch_modes,
7056 .input_mux = &alc883_capture_source,
7058 [ALC883_3ST_6ch_DIG] = {
7059 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
7060 .init_verbs = { alc883_init_verbs },
7061 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7062 .dac_nids = alc883_dac_nids,
7063 .dig_out_nid = ALC883_DIGOUT_NID,
7064 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7065 .adc_nids = alc883_adc_nids,
7066 .dig_in_nid = ALC883_DIGIN_NID,
7067 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
7068 .channel_mode = alc883_3ST_6ch_modes,
7070 .input_mux = &alc883_capture_source,
7072 [ALC883_3ST_6ch] = {
7073 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
7074 .init_verbs = { alc883_init_verbs },
7075 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7076 .dac_nids = alc883_dac_nids,
7077 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7078 .adc_nids = alc883_adc_nids,
7079 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
7080 .channel_mode = alc883_3ST_6ch_modes,
7082 .input_mux = &alc883_capture_source,
7084 [ALC883_6ST_DIG] = {
7085 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
7086 .init_verbs = { alc883_init_verbs },
7087 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7088 .dac_nids = alc883_dac_nids,
7089 .dig_out_nid = ALC883_DIGOUT_NID,
7090 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7091 .adc_nids = alc883_adc_nids,
7092 .dig_in_nid = ALC883_DIGIN_NID,
7093 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
7094 .channel_mode = alc883_sixstack_modes,
7095 .input_mux = &alc883_capture_source,
7097 [ALC883_TARGA_DIG] = {
7098 .mixers = { alc883_tagra_mixer, alc883_chmode_mixer },
7099 .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
7100 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7101 .dac_nids = alc883_dac_nids,
7102 .dig_out_nid = ALC883_DIGOUT_NID,
7103 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7104 .adc_nids = alc883_adc_nids,
7105 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
7106 .channel_mode = alc883_3ST_6ch_modes,
7108 .input_mux = &alc883_capture_source,
7109 .unsol_event = alc883_tagra_unsol_event,
7110 .init_hook = alc883_tagra_automute,
7112 [ALC883_TARGA_2ch_DIG] = {
7113 .mixers = { alc883_tagra_2ch_mixer},
7114 .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
7115 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7116 .dac_nids = alc883_dac_nids,
7117 .dig_out_nid = ALC883_DIGOUT_NID,
7118 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7119 .adc_nids = alc883_adc_nids,
7120 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7121 .channel_mode = alc883_3ST_2ch_modes,
7122 .input_mux = &alc883_capture_source,
7123 .unsol_event = alc883_tagra_unsol_event,
7124 .init_hook = alc883_tagra_automute,
7127 .mixers = { alc883_base_mixer },
7128 /* On TravelMate laptops, GPIO 0 enables the internal speaker
7129 * and the headphone jack. Turn this on and rely on the
7130 * standard mute methods whenever the user wants to turn
7131 * these outputs off.
7133 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs },
7134 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7135 .dac_nids = alc883_dac_nids,
7136 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7137 .adc_nids = alc883_adc_nids,
7138 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7139 .channel_mode = alc883_3ST_2ch_modes,
7140 .input_mux = &alc883_capture_source,
7142 [ALC883_ACER_ASPIRE] = {
7143 .mixers = { alc883_acer_aspire_mixer },
7144 .init_verbs = { alc883_init_verbs, alc883_acer_eapd_verbs },
7145 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7146 .dac_nids = alc883_dac_nids,
7147 .dig_out_nid = ALC883_DIGOUT_NID,
7148 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7149 .adc_nids = alc883_adc_nids,
7150 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7151 .channel_mode = alc883_3ST_2ch_modes,
7152 .input_mux = &alc883_capture_source,
7153 .unsol_event = alc883_acer_aspire_unsol_event,
7154 .init_hook = alc883_acer_aspire_automute,
7157 .mixers = { alc883_fivestack_mixer,
7158 alc883_chmode_mixer },
7159 .init_verbs = { alc883_init_verbs,
7160 alc883_medion_eapd_verbs },
7161 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7162 .dac_nids = alc883_dac_nids,
7163 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7164 .adc_nids = alc883_adc_nids,
7165 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
7166 .channel_mode = alc883_sixstack_modes,
7167 .input_mux = &alc883_capture_source,
7169 [ALC883_MEDION_MD2] = {
7170 .mixers = { alc883_medion_md2_mixer},
7171 .init_verbs = { alc883_init_verbs, alc883_medion_md2_verbs},
7172 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7173 .dac_nids = alc883_dac_nids,
7174 .dig_out_nid = ALC883_DIGOUT_NID,
7175 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7176 .adc_nids = alc883_adc_nids,
7177 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7178 .channel_mode = alc883_3ST_2ch_modes,
7179 .input_mux = &alc883_capture_source,
7180 .unsol_event = alc883_medion_md2_unsol_event,
7181 .init_hook = alc883_medion_md2_automute,
7183 [ALC883_LAPTOP_EAPD] = {
7184 .mixers = { alc883_base_mixer },
7185 .init_verbs = { alc883_init_verbs, alc882_eapd_verbs },
7186 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7187 .dac_nids = alc883_dac_nids,
7188 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7189 .adc_nids = alc883_adc_nids,
7190 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7191 .channel_mode = alc883_3ST_2ch_modes,
7192 .input_mux = &alc883_capture_source,
7194 [ALC883_LENOVO_101E_2ch] = {
7195 .mixers = { alc883_lenovo_101e_2ch_mixer},
7196 .init_verbs = { alc883_init_verbs, alc883_lenovo_101e_verbs},
7197 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7198 .dac_nids = alc883_dac_nids,
7199 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7200 .adc_nids = alc883_adc_nids,
7201 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7202 .channel_mode = alc883_3ST_2ch_modes,
7203 .input_mux = &alc883_lenovo_101e_capture_source,
7204 .unsol_event = alc883_lenovo_101e_unsol_event,
7205 .init_hook = alc883_lenovo_101e_all_automute,
7207 [ALC883_LENOVO_NB0763] = {
7208 .mixers = { alc883_lenovo_nb0763_mixer },
7209 .init_verbs = { alc883_init_verbs, alc883_lenovo_nb0763_verbs},
7210 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7211 .dac_nids = alc883_dac_nids,
7212 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7213 .adc_nids = alc883_adc_nids,
7214 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7215 .channel_mode = alc883_3ST_2ch_modes,
7217 .input_mux = &alc883_lenovo_nb0763_capture_source,
7218 .unsol_event = alc883_medion_md2_unsol_event,
7219 .init_hook = alc883_medion_md2_automute,
7221 [ALC888_LENOVO_MS7195_DIG] = {
7222 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
7223 .init_verbs = { alc883_init_verbs, alc888_lenovo_ms7195_verbs},
7224 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7225 .dac_nids = alc883_dac_nids,
7226 .dig_out_nid = ALC883_DIGOUT_NID,
7227 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7228 .adc_nids = alc883_adc_nids,
7229 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
7230 .channel_mode = alc883_3ST_6ch_modes,
7232 .input_mux = &alc883_capture_source,
7233 .unsol_event = alc883_lenovo_ms7195_unsol_event,
7234 .init_hook = alc888_lenovo_ms7195_front_automute,
7236 [ALC883_HAIER_W66] = {
7237 .mixers = { alc883_tagra_2ch_mixer},
7238 .init_verbs = { alc883_init_verbs, alc883_haier_w66_verbs},
7239 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7240 .dac_nids = alc883_dac_nids,
7241 .dig_out_nid = ALC883_DIGOUT_NID,
7242 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7243 .adc_nids = alc883_adc_nids,
7244 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7245 .channel_mode = alc883_3ST_2ch_modes,
7246 .input_mux = &alc883_capture_source,
7247 .unsol_event = alc883_haier_w66_unsol_event,
7248 .init_hook = alc883_haier_w66_automute,
7251 .mixers = { alc888_6st_hp_mixer, alc883_chmode_mixer },
7252 .init_verbs = { alc883_init_verbs, alc888_6st_hp_verbs },
7253 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7254 .dac_nids = alc883_dac_nids,
7255 .dig_out_nid = ALC883_DIGOUT_NID,
7256 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7257 .adc_nids = alc883_adc_nids,
7258 .dig_in_nid = ALC883_DIGIN_NID,
7259 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
7260 .channel_mode = alc883_sixstack_modes,
7261 .input_mux = &alc883_capture_source,
7264 .mixers = { alc888_3st_hp_mixer, alc883_chmode_mixer },
7265 .init_verbs = { alc883_init_verbs, alc888_3st_hp_verbs },
7266 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7267 .dac_nids = alc883_dac_nids,
7268 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7269 .adc_nids = alc883_adc_nids,
7270 .num_channel_mode = ARRAY_SIZE(alc888_3st_hp_modes),
7271 .channel_mode = alc888_3st_hp_modes,
7273 .input_mux = &alc883_capture_source,
7279 * BIOS auto configuration
7281 static void alc883_auto_set_output_and_unmute(struct hda_codec *codec,
7282 hda_nid_t nid, int pin_type,
7286 struct alc_spec *spec = codec->spec;
7289 if (spec->multiout.dac_nids[dac_idx] == 0x25)
7292 idx = spec->multiout.dac_nids[dac_idx] - 2;
7294 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
7296 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
7298 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
7302 static void alc883_auto_init_multi_out(struct hda_codec *codec)
7304 struct alc_spec *spec = codec->spec;
7307 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
7308 for (i = 0; i <= HDA_SIDE; i++) {
7309 hda_nid_t nid = spec->autocfg.line_out_pins[i];
7310 int pin_type = get_pin_type(spec->autocfg.line_out_type);
7312 alc883_auto_set_output_and_unmute(codec, nid, pin_type,
7317 static void alc883_auto_init_hp_out(struct hda_codec *codec)
7319 struct alc_spec *spec = codec->spec;
7322 pin = spec->autocfg.hp_pins[0];
7323 if (pin) /* connect to front */
7325 alc883_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
7328 #define alc883_is_input_pin(nid) alc880_is_input_pin(nid)
7329 #define ALC883_PIN_CD_NID ALC880_PIN_CD_NID
7331 static void alc883_auto_init_analog_input(struct hda_codec *codec)
7333 struct alc_spec *spec = codec->spec;
7336 for (i = 0; i < AUTO_PIN_LAST; i++) {
7337 hda_nid_t nid = spec->autocfg.input_pins[i];
7338 if (alc883_is_input_pin(nid)) {
7339 snd_hda_codec_write(codec, nid, 0,
7340 AC_VERB_SET_PIN_WIDGET_CONTROL,
7341 (i <= AUTO_PIN_FRONT_MIC ?
7342 PIN_VREF80 : PIN_IN));
7343 if (nid != ALC883_PIN_CD_NID)
7344 snd_hda_codec_write(codec, nid, 0,
7345 AC_VERB_SET_AMP_GAIN_MUTE,
7351 /* almost identical with ALC880 parser... */
7352 static int alc883_parse_auto_config(struct hda_codec *codec)
7354 struct alc_spec *spec = codec->spec;
7355 int err = alc880_parse_auto_config(codec);
7360 return 0; /* no config found */
7362 err = alc_auto_add_mic_boost(codec);
7366 /* hack - override the init verbs */
7367 spec->init_verbs[0] = alc883_auto_init_verbs;
7368 spec->mixers[spec->num_mixers] = alc883_capture_mixer;
7371 return 1; /* config found */
7374 /* additional initialization for auto-configuration model */
7375 static void alc883_auto_init(struct hda_codec *codec)
7377 alc883_auto_init_multi_out(codec);
7378 alc883_auto_init_hp_out(codec);
7379 alc883_auto_init_analog_input(codec);
7382 static int patch_alc883(struct hda_codec *codec)
7384 struct alc_spec *spec;
7385 int err, board_config;
7387 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
7393 board_config = snd_hda_check_board_config(codec, ALC883_MODEL_LAST,
7396 if (board_config < 0) {
7397 printk(KERN_INFO "hda_codec: Unknown model for ALC883, "
7398 "trying auto-probe from BIOS...\n");
7399 board_config = ALC883_AUTO;
7402 if (board_config == ALC883_AUTO) {
7403 /* automatic parse from the BIOS config */
7404 err = alc883_parse_auto_config(codec);
7410 "hda_codec: Cannot set up configuration "
7411 "from BIOS. Using base mode...\n");
7412 board_config = ALC883_3ST_2ch_DIG;
7416 if (board_config != ALC883_AUTO)
7417 setup_preset(spec, &alc883_presets[board_config]);
7419 spec->stream_name_analog = "ALC883 Analog";
7420 spec->stream_analog_playback = &alc883_pcm_analog_playback;
7421 spec->stream_analog_capture = &alc883_pcm_analog_capture;
7423 spec->stream_name_digital = "ALC883 Digital";
7424 spec->stream_digital_playback = &alc883_pcm_digital_playback;
7425 spec->stream_digital_capture = &alc883_pcm_digital_capture;
7427 if (!spec->adc_nids && spec->input_mux) {
7428 spec->adc_nids = alc883_adc_nids;
7429 spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids);
7432 codec->patch_ops = alc_patch_ops;
7433 if (board_config == ALC883_AUTO)
7434 spec->init_hook = alc883_auto_init;
7435 #ifdef CONFIG_SND_HDA_POWER_SAVE
7436 if (!spec->loopback.amplist)
7437 spec->loopback.amplist = alc883_loopbacks;
7447 #define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
7448 #define ALC262_DIGIN_NID ALC880_DIGIN_NID
7450 #define alc262_dac_nids alc260_dac_nids
7451 #define alc262_adc_nids alc882_adc_nids
7452 #define alc262_adc_nids_alt alc882_adc_nids_alt
7454 #define alc262_modes alc260_modes
7455 #define alc262_capture_source alc882_capture_source
7457 static struct snd_kcontrol_new alc262_base_mixer[] = {
7458 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7459 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7460 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7461 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7462 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7463 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7464 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7465 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7466 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7467 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
7468 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
7469 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
7470 /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
7471 HDA_CODEC_MUTE("PC Beelp Playback Switch", 0x0b, 0x05, HDA_INPUT), */
7472 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
7473 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7474 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7475 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
7479 static struct snd_kcontrol_new alc262_hippo1_mixer[] = {
7480 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7481 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7482 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7483 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7484 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7485 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7486 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7487 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7488 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7489 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
7490 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
7491 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
7492 /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
7493 HDA_CODEC_MUTE("PC Beelp Playback Switch", 0x0b, 0x05, HDA_INPUT), */
7494 /*HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),*/
7495 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7499 static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
7500 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7501 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7502 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7503 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7504 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
7506 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7507 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7508 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7509 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
7510 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
7511 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
7512 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7513 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7514 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7515 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7516 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
7517 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
7518 HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
7519 HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
7523 static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = {
7524 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7525 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7526 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7527 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7528 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7529 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
7530 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x02, HDA_INPUT),
7531 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x02, HDA_INPUT),
7532 HDA_CODEC_VOLUME("Front Mic Boost", 0x1a, 0, HDA_INPUT),
7533 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
7534 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
7535 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7536 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7537 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
7538 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
7542 static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = {
7543 HDA_CODEC_VOLUME("Rear Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7544 HDA_CODEC_MUTE("Rear Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7545 HDA_CODEC_VOLUME("Rear Mic Boost", 0x18, 0, HDA_INPUT),
7549 /* bind hp and internal speaker mute (with plug check) */
7550 static int alc262_sony_master_sw_put(struct snd_kcontrol *kcontrol,
7551 struct snd_ctl_elem_value *ucontrol)
7553 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
7554 long *valp = ucontrol->value.integer.value;
7557 /* change hp mute */
7558 change = snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
7560 valp[0] ? 0 : HDA_AMP_MUTE);
7561 change |= snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
7563 valp[1] ? 0 : HDA_AMP_MUTE);
7565 /* change speaker according to HP jack state */
7566 struct alc_spec *spec = codec->spec;
7568 if (spec->jack_present)
7569 mute = HDA_AMP_MUTE;
7571 mute = snd_hda_codec_amp_read(codec, 0x15, 0,
7573 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7574 HDA_AMP_MUTE, mute);
7579 static struct snd_kcontrol_new alc262_sony_mixer[] = {
7580 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7582 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7583 .name = "Master Playback Switch",
7584 .info = snd_hda_mixer_amp_switch_info,
7585 .get = snd_hda_mixer_amp_switch_get,
7586 .put = alc262_sony_master_sw_put,
7587 .private_value = HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
7589 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7590 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7591 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
7592 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
7596 static struct snd_kcontrol_new alc262_benq_t31_mixer[] = {
7597 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7598 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7599 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7600 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7601 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7602 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
7603 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
7607 #define alc262_capture_mixer alc882_capture_mixer
7608 #define alc262_capture_alt_mixer alc882_capture_alt_mixer
7611 * generic initialization of ADC, input mixers and output mixers
7613 static struct hda_verb alc262_init_verbs[] = {
7615 * Unmute ADC0-2 and set the default input to mic-in
7617 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7618 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7619 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7620 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7621 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7622 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7624 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
7626 * Note: PASD motherboards uses the Line In 2 as the input for
7627 * front panel mic (mic 2)
7629 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
7630 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7631 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7632 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7633 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7634 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7637 * Set up output mixers (0x0c - 0x0e)
7639 /* set vol=0 to output mixers */
7640 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7641 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7642 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7643 /* set up input amps for analog loopback */
7644 /* Amp Indices: DAC = 0, mixer = 1 */
7645 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7646 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7647 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7648 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7649 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7650 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7652 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
7653 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
7654 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
7655 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
7656 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
7657 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
7659 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
7660 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
7661 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
7662 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
7663 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
7665 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7666 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
7668 /* FIXME: use matrix-type input source selection */
7669 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7670 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7671 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7672 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
7673 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
7674 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
7676 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7677 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
7678 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
7679 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
7681 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7682 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
7683 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
7684 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
7689 static struct hda_verb alc262_hippo_unsol_verbs[] = {
7690 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
7691 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7695 static struct hda_verb alc262_hippo1_unsol_verbs[] = {
7696 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
7697 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
7698 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
7700 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
7701 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7705 static struct hda_verb alc262_sony_unsol_verbs[] = {
7706 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
7707 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7708 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, // Front Mic
7710 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
7711 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7714 /* mute/unmute internal speaker according to the hp jack and mute state */
7715 static void alc262_hippo_automute(struct hda_codec *codec)
7717 struct alc_spec *spec = codec->spec;
7719 unsigned int present;
7721 /* need to execute and sync at first */
7722 snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
7723 present = snd_hda_codec_read(codec, 0x15, 0,
7724 AC_VERB_GET_PIN_SENSE, 0);
7725 spec->jack_present = (present & 0x80000000) != 0;
7726 if (spec->jack_present) {
7727 /* mute internal speaker */
7728 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7729 HDA_AMP_MUTE, HDA_AMP_MUTE);
7731 /* unmute internal speaker if necessary */
7732 mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0);
7733 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7734 HDA_AMP_MUTE, mute);
7738 /* unsolicited event for HP jack sensing */
7739 static void alc262_hippo_unsol_event(struct hda_codec *codec,
7742 if ((res >> 26) != ALC880_HP_EVENT)
7744 alc262_hippo_automute(codec);
7747 static void alc262_hippo1_automute(struct hda_codec *codec)
7750 unsigned int present;
7752 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
7753 present = snd_hda_codec_read(codec, 0x1b, 0,
7754 AC_VERB_GET_PIN_SENSE, 0);
7755 present = (present & 0x80000000) != 0;
7757 /* mute internal speaker */
7758 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7759 HDA_AMP_MUTE, HDA_AMP_MUTE);
7761 /* unmute internal speaker if necessary */
7762 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
7763 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7764 HDA_AMP_MUTE, mute);
7768 /* unsolicited event for HP jack sensing */
7769 static void alc262_hippo1_unsol_event(struct hda_codec *codec,
7772 if ((res >> 26) != ALC880_HP_EVENT)
7774 alc262_hippo1_automute(codec);
7779 * 0x14 = headphone/spdif-out, 0x15 = internal speaker
7782 #define ALC_HP_EVENT 0x37
7784 static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
7785 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
7786 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7790 static struct hda_input_mux alc262_fujitsu_capture_source = {
7798 static struct hda_input_mux alc262_HP_capture_source = {
7802 { "Front Mic", 0x1 },
7809 static struct hda_input_mux alc262_HP_D7000_capture_source = {
7813 { "Front Mic", 0x2 },
7819 /* mute/unmute internal speaker according to the hp jack and mute state */
7820 static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
7822 struct alc_spec *spec = codec->spec;
7825 if (force || !spec->sense_updated) {
7826 unsigned int present;
7827 /* need to execute and sync at first */
7828 snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
7829 present = snd_hda_codec_read(codec, 0x14, 0,
7830 AC_VERB_GET_PIN_SENSE, 0);
7831 spec->jack_present = (present & 0x80000000) != 0;
7832 spec->sense_updated = 1;
7834 if (spec->jack_present) {
7835 /* mute internal speaker */
7836 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7837 HDA_AMP_MUTE, HDA_AMP_MUTE);
7839 /* unmute internal speaker if necessary */
7840 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
7841 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7842 HDA_AMP_MUTE, mute);
7846 /* unsolicited event for HP jack sensing */
7847 static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
7850 if ((res >> 26) != ALC_HP_EVENT)
7852 alc262_fujitsu_automute(codec, 1);
7855 /* bind volumes of both NID 0x0c and 0x0d */
7856 static struct hda_bind_ctls alc262_fujitsu_bind_master_vol = {
7857 .ops = &snd_hda_bind_vol,
7859 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
7860 HDA_COMPOSE_AMP_VAL(0x0d, 3, 0, HDA_OUTPUT),
7865 /* bind hp and internal speaker mute (with plug check) */
7866 static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
7867 struct snd_ctl_elem_value *ucontrol)
7869 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
7870 long *valp = ucontrol->value.integer.value;
7873 change = snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
7875 valp[0] ? 0 : HDA_AMP_MUTE);
7876 change |= snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
7878 valp[1] ? 0 : HDA_AMP_MUTE);
7880 alc262_fujitsu_automute(codec, 0);
7884 static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
7885 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
7887 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7888 .name = "Master Playback Switch",
7889 .info = snd_hda_mixer_amp_switch_info,
7890 .get = snd_hda_mixer_amp_switch_get,
7891 .put = alc262_fujitsu_master_sw_put,
7892 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
7894 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7895 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7896 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7897 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7898 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7902 /* additional init verbs for Benq laptops */
7903 static struct hda_verb alc262_EAPD_verbs[] = {
7904 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
7905 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
7909 static struct hda_verb alc262_benq_t31_EAPD_verbs[] = {
7910 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7911 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
7913 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
7914 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
7918 /* add playback controls from the parsed DAC table */
7919 static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec,
7920 const struct auto_pin_cfg *cfg)
7925 spec->multiout.num_dacs = 1; /* only use one dac */
7926 spec->multiout.dac_nids = spec->private_dac_nids;
7927 spec->multiout.dac_nids[0] = 2;
7929 nid = cfg->line_out_pins[0];
7931 err = add_control(spec, ALC_CTL_WIDGET_VOL,
7932 "Front Playback Volume",
7933 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT));
7936 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
7937 "Front Playback Switch",
7938 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
7943 nid = cfg->speaker_pins[0];
7946 err = add_control(spec, ALC_CTL_WIDGET_VOL,
7947 "Speaker Playback Volume",
7948 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
7952 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
7953 "Speaker Playback Switch",
7954 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
7959 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
7960 "Speaker Playback Switch",
7961 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
7967 nid = cfg->hp_pins[0];
7969 /* spec->multiout.hp_nid = 2; */
7971 err = add_control(spec, ALC_CTL_WIDGET_VOL,
7972 "Headphone Playback Volume",
7973 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
7977 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
7978 "Headphone Playback Switch",
7979 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
7984 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
7985 "Headphone Playback Switch",
7986 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
7995 /* identical with ALC880 */
7996 #define alc262_auto_create_analog_input_ctls \
7997 alc880_auto_create_analog_input_ctls
8000 * generic initialization of ADC, input mixers and output mixers
8002 static struct hda_verb alc262_volume_init_verbs[] = {
8004 * Unmute ADC0-2 and set the default input to mic-in
8006 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
8007 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8008 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8009 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8010 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8011 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8013 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
8015 * Note: PASD motherboards uses the Line In 2 as the input for
8016 * front panel mic (mic 2)
8018 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
8019 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8020 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8021 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8022 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8023 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8026 * Set up output mixers (0x0c - 0x0f)
8028 /* set vol=0 to output mixers */
8029 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8030 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8031 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8033 /* set up input amps for analog loopback */
8034 /* Amp Indices: DAC = 0, mixer = 1 */
8035 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8036 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8037 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8038 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8039 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8040 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8042 /* FIXME: use matrix-type input source selection */
8043 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
8044 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
8045 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8046 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
8047 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
8048 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
8050 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8051 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
8052 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
8053 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
8055 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8056 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
8057 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
8058 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
8063 static struct hda_verb alc262_HP_BPC_init_verbs[] = {
8065 * Unmute ADC0-2 and set the default input to mic-in
8067 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
8068 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8069 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8070 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8071 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8072 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8074 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
8076 * Note: PASD motherboards uses the Line In 2 as the input for
8077 * front panel mic (mic 2)
8079 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
8080 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8081 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8082 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8083 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8084 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8085 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
8086 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
8089 * Set up output mixers (0x0c - 0x0e)
8091 /* set vol=0 to output mixers */
8092 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8093 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8094 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8096 /* set up input amps for analog loopback */
8097 /* Amp Indices: DAC = 0, mixer = 1 */
8098 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8099 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8100 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8101 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8102 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8103 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8105 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
8106 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8107 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8109 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
8110 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
8112 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
8113 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8115 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
8116 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
8117 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
8118 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
8119 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
8121 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
8122 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
8123 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
8124 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
8125 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
8126 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
8129 /* FIXME: use matrix-type input source selection */
8130 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
8131 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
8132 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8133 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
8134 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
8135 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
8137 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8138 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
8139 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
8140 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
8142 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8143 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
8144 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
8145 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
8150 static struct hda_verb alc262_HP_BPC_WildWest_init_verbs[] = {
8152 * Unmute ADC0-2 and set the default input to mic-in
8154 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
8155 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8156 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8157 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8158 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8159 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8161 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
8163 * Note: PASD motherboards uses the Line In 2 as the input for front
8166 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
8167 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8168 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8169 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8170 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8171 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8172 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
8173 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
8174 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
8176 * Set up output mixers (0x0c - 0x0e)
8178 /* set vol=0 to output mixers */
8179 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8180 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8181 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8183 /* set up input amps for analog loopback */
8184 /* Amp Indices: DAC = 0, mixer = 1 */
8185 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8186 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8187 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8188 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8189 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8190 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8193 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP */
8194 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Mono */
8195 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* rear MIC */
8196 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* Line in */
8197 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
8198 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Line out */
8199 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD in */
8201 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
8202 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
8204 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
8205 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
8207 /* {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, */
8208 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
8209 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
8210 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
8211 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
8212 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
8214 /* FIXME: use matrix-type input source selection */
8215 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
8216 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
8217 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, /*rear MIC*/
8218 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, /*Line in*/
8219 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, /*F MIC*/
8220 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, /*Front*/
8221 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, /*CD*/
8222 /* {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
8223 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, /*HP*/
8225 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8226 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
8227 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
8228 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
8229 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
8230 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
8231 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
8233 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8234 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
8235 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
8236 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
8237 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
8238 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
8239 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
8244 #ifdef CONFIG_SND_HDA_POWER_SAVE
8245 #define alc262_loopbacks alc880_loopbacks
8248 /* pcm configuration: identiacal with ALC880 */
8249 #define alc262_pcm_analog_playback alc880_pcm_analog_playback
8250 #define alc262_pcm_analog_capture alc880_pcm_analog_capture
8251 #define alc262_pcm_digital_playback alc880_pcm_digital_playback
8252 #define alc262_pcm_digital_capture alc880_pcm_digital_capture
8255 * BIOS auto configuration
8257 static int alc262_parse_auto_config(struct hda_codec *codec)
8259 struct alc_spec *spec = codec->spec;
8261 static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
8263 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
8267 if (!spec->autocfg.line_outs)
8268 return 0; /* can't find valid BIOS pin config */
8269 err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg);
8272 err = alc262_auto_create_analog_input_ctls(spec, &spec->autocfg);
8276 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
8278 if (spec->autocfg.dig_out_pin)
8279 spec->multiout.dig_out_nid = ALC262_DIGOUT_NID;
8280 if (spec->autocfg.dig_in_pin)
8281 spec->dig_in_nid = ALC262_DIGIN_NID;
8283 if (spec->kctl_alloc)
8284 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
8286 spec->init_verbs[spec->num_init_verbs++] = alc262_volume_init_verbs;
8287 spec->num_mux_defs = 1;
8288 spec->input_mux = &spec->private_imux;
8290 err = alc_auto_add_mic_boost(codec);
8297 #define alc262_auto_init_multi_out alc882_auto_init_multi_out
8298 #define alc262_auto_init_hp_out alc882_auto_init_hp_out
8299 #define alc262_auto_init_analog_input alc882_auto_init_analog_input
8302 /* init callback for auto-configuration model -- overriding the default init */
8303 static void alc262_auto_init(struct hda_codec *codec)
8305 alc262_auto_init_multi_out(codec);
8306 alc262_auto_init_hp_out(codec);
8307 alc262_auto_init_analog_input(codec);
8311 * configuration and preset
8313 static const char *alc262_models[ALC262_MODEL_LAST] = {
8314 [ALC262_BASIC] = "basic",
8315 [ALC262_HIPPO] = "hippo",
8316 [ALC262_HIPPO_1] = "hippo_1",
8317 [ALC262_FUJITSU] = "fujitsu",
8318 [ALC262_HP_BPC] = "hp-bpc",
8319 [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000",
8320 [ALC262_BENQ_ED8] = "benq",
8321 [ALC262_BENQ_T31] = "benq-t31",
8322 [ALC262_SONY_ASSAMD] = "sony-assamd",
8323 [ALC262_AUTO] = "auto",
8326 static struct snd_pci_quirk alc262_cfg_tbl[] = {
8327 SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO),
8328 SND_PCI_QUIRK(0x103c, 0x12fe, "HP xw9400", ALC262_HP_BPC),
8329 SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC),
8330 SND_PCI_QUIRK(0x103c, 0x12ff, "HP xw4550", ALC262_HP_BPC),
8331 SND_PCI_QUIRK(0x103c, 0x1308, "HP xw4600", ALC262_HP_BPC),
8332 SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC),
8333 SND_PCI_QUIRK(0x103c, 0x1307, "HP xw6600", ALC262_HP_BPC),
8334 SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC),
8335 SND_PCI_QUIRK(0x103c, 0x1306, "HP xw8600", ALC262_HP_BPC),
8336 SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL),
8337 SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL),
8338 SND_PCI_QUIRK(0x103c, 0x2804, "HP D7000", ALC262_HP_BPC_D7000_WL),
8339 SND_PCI_QUIRK(0x103c, 0x2806, "HP D7000", ALC262_HP_BPC_D7000_WL),
8340 SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF),
8341 SND_PCI_QUIRK(0x103c, 0x2803, "HP D7000", ALC262_HP_BPC_D7000_WF),
8342 SND_PCI_QUIRK(0x103c, 0x2805, "HP D7000", ALC262_HP_BPC_D7000_WF),
8343 SND_PCI_QUIRK(0x103c, 0x2807, "HP D7000", ALC262_HP_BPC_D7000_WF),
8344 SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO),
8345 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
8346 SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1),
8347 SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
8348 SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_BENQ_T31),
8349 SND_PCI_QUIRK(0x104d, 0x820f, "Sony ASSAMD", ALC262_SONY_ASSAMD),
8350 SND_PCI_QUIRK(0x104d, 0x9015, "Sony 0x9015", ALC262_SONY_ASSAMD),
8351 SND_PCI_QUIRK(0x104d, 0x900e, "Sony ASSAMD", ALC262_SONY_ASSAMD),
8352 SND_PCI_QUIRK(0x104d, 0x1f00, "Sony ASSAMD", ALC262_SONY_ASSAMD),
8356 static struct alc_config_preset alc262_presets[] = {
8358 .mixers = { alc262_base_mixer },
8359 .init_verbs = { alc262_init_verbs },
8360 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
8361 .dac_nids = alc262_dac_nids,
8363 .num_channel_mode = ARRAY_SIZE(alc262_modes),
8364 .channel_mode = alc262_modes,
8365 .input_mux = &alc262_capture_source,
8368 .mixers = { alc262_base_mixer },
8369 .init_verbs = { alc262_init_verbs, alc262_hippo_unsol_verbs},
8370 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
8371 .dac_nids = alc262_dac_nids,
8373 .dig_out_nid = ALC262_DIGOUT_NID,
8374 .num_channel_mode = ARRAY_SIZE(alc262_modes),
8375 .channel_mode = alc262_modes,
8376 .input_mux = &alc262_capture_source,
8377 .unsol_event = alc262_hippo_unsol_event,
8378 .init_hook = alc262_hippo_automute,
8380 [ALC262_HIPPO_1] = {
8381 .mixers = { alc262_hippo1_mixer },
8382 .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs},
8383 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
8384 .dac_nids = alc262_dac_nids,
8386 .dig_out_nid = ALC262_DIGOUT_NID,
8387 .num_channel_mode = ARRAY_SIZE(alc262_modes),
8388 .channel_mode = alc262_modes,
8389 .input_mux = &alc262_capture_source,
8390 .unsol_event = alc262_hippo1_unsol_event,
8391 .init_hook = alc262_hippo1_automute,
8393 [ALC262_FUJITSU] = {
8394 .mixers = { alc262_fujitsu_mixer },
8395 .init_verbs = { alc262_init_verbs, alc262_fujitsu_unsol_verbs },
8396 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
8397 .dac_nids = alc262_dac_nids,
8399 .dig_out_nid = ALC262_DIGOUT_NID,
8400 .num_channel_mode = ARRAY_SIZE(alc262_modes),
8401 .channel_mode = alc262_modes,
8402 .input_mux = &alc262_fujitsu_capture_source,
8403 .unsol_event = alc262_fujitsu_unsol_event,
8406 .mixers = { alc262_HP_BPC_mixer },
8407 .init_verbs = { alc262_HP_BPC_init_verbs },
8408 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
8409 .dac_nids = alc262_dac_nids,
8411 .num_channel_mode = ARRAY_SIZE(alc262_modes),
8412 .channel_mode = alc262_modes,
8413 .input_mux = &alc262_HP_capture_source,
8415 [ALC262_HP_BPC_D7000_WF] = {
8416 .mixers = { alc262_HP_BPC_WildWest_mixer },
8417 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
8418 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
8419 .dac_nids = alc262_dac_nids,
8421 .num_channel_mode = ARRAY_SIZE(alc262_modes),
8422 .channel_mode = alc262_modes,
8423 .input_mux = &alc262_HP_D7000_capture_source,
8425 [ALC262_HP_BPC_D7000_WL] = {
8426 .mixers = { alc262_HP_BPC_WildWest_mixer,
8427 alc262_HP_BPC_WildWest_option_mixer },
8428 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
8429 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
8430 .dac_nids = alc262_dac_nids,
8432 .num_channel_mode = ARRAY_SIZE(alc262_modes),
8433 .channel_mode = alc262_modes,
8434 .input_mux = &alc262_HP_D7000_capture_source,
8436 [ALC262_BENQ_ED8] = {
8437 .mixers = { alc262_base_mixer },
8438 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
8439 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
8440 .dac_nids = alc262_dac_nids,
8442 .num_channel_mode = ARRAY_SIZE(alc262_modes),
8443 .channel_mode = alc262_modes,
8444 .input_mux = &alc262_capture_source,
8446 [ALC262_SONY_ASSAMD] = {
8447 .mixers = { alc262_sony_mixer },
8448 .init_verbs = { alc262_init_verbs, alc262_sony_unsol_verbs},
8449 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
8450 .dac_nids = alc262_dac_nids,
8452 .num_channel_mode = ARRAY_SIZE(alc262_modes),
8453 .channel_mode = alc262_modes,
8454 .input_mux = &alc262_capture_source,
8455 .unsol_event = alc262_hippo_unsol_event,
8456 .init_hook = alc262_hippo_automute,
8458 [ALC262_BENQ_T31] = {
8459 .mixers = { alc262_benq_t31_mixer },
8460 .init_verbs = { alc262_init_verbs, alc262_benq_t31_EAPD_verbs, alc262_hippo_unsol_verbs },
8461 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
8462 .dac_nids = alc262_dac_nids,
8464 .num_channel_mode = ARRAY_SIZE(alc262_modes),
8465 .channel_mode = alc262_modes,
8466 .input_mux = &alc262_capture_source,
8467 .unsol_event = alc262_hippo_unsol_event,
8468 .init_hook = alc262_hippo_automute,
8472 static int patch_alc262(struct hda_codec *codec)
8474 struct alc_spec *spec;
8478 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
8484 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
8489 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
8490 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
8491 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
8492 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
8496 board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST,
8500 if (board_config < 0) {
8501 printk(KERN_INFO "hda_codec: Unknown model for ALC262, "
8502 "trying auto-probe from BIOS...\n");
8503 board_config = ALC262_AUTO;
8506 if (board_config == ALC262_AUTO) {
8507 /* automatic parse from the BIOS config */
8508 err = alc262_parse_auto_config(codec);
8514 "hda_codec: Cannot set up configuration "
8515 "from BIOS. Using base mode...\n");
8516 board_config = ALC262_BASIC;
8520 if (board_config != ALC262_AUTO)
8521 setup_preset(spec, &alc262_presets[board_config]);
8523 spec->stream_name_analog = "ALC262 Analog";
8524 spec->stream_analog_playback = &alc262_pcm_analog_playback;
8525 spec->stream_analog_capture = &alc262_pcm_analog_capture;
8527 spec->stream_name_digital = "ALC262 Digital";
8528 spec->stream_digital_playback = &alc262_pcm_digital_playback;
8529 spec->stream_digital_capture = &alc262_pcm_digital_capture;
8531 if (!spec->adc_nids && spec->input_mux) {
8532 /* check whether NID 0x07 is valid */
8533 unsigned int wcap = get_wcaps(codec, 0x07);
8536 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
8537 if (wcap != AC_WID_AUD_IN) {
8538 spec->adc_nids = alc262_adc_nids_alt;
8539 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids_alt);
8540 spec->mixers[spec->num_mixers] =
8541 alc262_capture_alt_mixer;
8544 spec->adc_nids = alc262_adc_nids;
8545 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids);
8546 spec->mixers[spec->num_mixers] = alc262_capture_mixer;
8551 codec->patch_ops = alc_patch_ops;
8552 if (board_config == ALC262_AUTO)
8553 spec->init_hook = alc262_auto_init;
8554 #ifdef CONFIG_SND_HDA_POWER_SAVE
8555 if (!spec->loopback.amplist)
8556 spec->loopback.amplist = alc262_loopbacks;
8563 * ALC268 channel source setting (2 channel)
8565 #define ALC268_DIGOUT_NID ALC880_DIGOUT_NID
8566 #define alc268_modes alc260_modes
8568 static hda_nid_t alc268_dac_nids[2] = {
8573 static hda_nid_t alc268_adc_nids[2] = {
8578 static hda_nid_t alc268_adc_nids_alt[1] = {
8583 static struct snd_kcontrol_new alc268_base_mixer[] = {
8584 /* output mixer control */
8585 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
8586 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8587 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
8588 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8589 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8590 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
8591 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
8595 static struct hda_verb alc268_eapd_verbs[] = {
8596 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
8597 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
8601 /* Toshiba specific */
8602 #define alc268_toshiba_automute alc262_hippo_automute
8604 static struct hda_verb alc268_toshiba_verbs[] = {
8605 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8610 /* bind volumes of both NID 0x02 and 0x03 */
8611 static struct hda_bind_ctls alc268_acer_bind_master_vol = {
8612 .ops = &snd_hda_bind_vol,
8614 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
8615 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
8620 /* mute/unmute internal speaker according to the hp jack and mute state */
8621 static void alc268_acer_automute(struct hda_codec *codec, int force)
8623 struct alc_spec *spec = codec->spec;
8626 if (force || !spec->sense_updated) {
8627 unsigned int present;
8628 present = snd_hda_codec_read(codec, 0x14, 0,
8629 AC_VERB_GET_PIN_SENSE, 0);
8630 spec->jack_present = (present & 0x80000000) != 0;
8631 spec->sense_updated = 1;
8633 if (spec->jack_present)
8634 mute = HDA_AMP_MUTE; /* mute internal speaker */
8635 else /* unmute internal speaker if necessary */
8636 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
8637 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8638 HDA_AMP_MUTE, mute);
8642 /* bind hp and internal speaker mute (with plug check) */
8643 static int alc268_acer_master_sw_put(struct snd_kcontrol *kcontrol,
8644 struct snd_ctl_elem_value *ucontrol)
8646 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
8647 long *valp = ucontrol->value.integer.value;
8650 change = snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
8652 valp[0] ? 0 : HDA_AMP_MUTE);
8653 change |= snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
8655 valp[1] ? 0 : HDA_AMP_MUTE);
8657 alc268_acer_automute(codec, 0);
8661 static struct snd_kcontrol_new alc268_acer_mixer[] = {
8662 /* output mixer control */
8663 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
8665 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8666 .name = "Master Playback Switch",
8667 .info = snd_hda_mixer_amp_switch_info,
8668 .get = snd_hda_mixer_amp_switch_get,
8669 .put = alc268_acer_master_sw_put,
8670 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
8672 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8673 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
8674 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
8678 static struct hda_verb alc268_acer_verbs[] = {
8679 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8680 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8682 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8686 /* unsolicited event for HP jack sensing */
8687 static void alc268_toshiba_unsol_event(struct hda_codec *codec,
8690 if ((res >> 26) != ALC880_HP_EVENT)
8692 alc268_toshiba_automute(codec);
8695 static void alc268_acer_unsol_event(struct hda_codec *codec,
8698 if ((res >> 26) != ALC880_HP_EVENT)
8700 alc268_acer_automute(codec, 1);
8703 static void alc268_acer_init_hook(struct hda_codec *codec)
8705 alc268_acer_automute(codec, 1);
8709 * generic initialization of ADC, input mixers and output mixers
8711 static struct hda_verb alc268_base_init_verbs[] = {
8712 /* Unmute DAC0-1 and set vol = 0 */
8713 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8714 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8715 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8716 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8717 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8718 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8721 * Set up output mixers (0x0c - 0x0e)
8723 /* set vol=0 to output mixers */
8724 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8725 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8726 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8727 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
8729 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8730 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8732 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
8733 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
8734 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
8735 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
8736 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
8737 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
8738 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
8739 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
8741 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8742 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8743 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8744 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8745 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8746 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8747 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8748 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8750 /* FIXME: use matrix-type input source selection */
8751 /* Mixer elements: 0x18, 19, 1a, 1c, 14, 15, 0b */
8752 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
8754 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8755 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
8756 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
8757 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
8759 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8760 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
8761 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
8762 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
8767 * generic initialization of ADC, input mixers and output mixers
8769 static struct hda_verb alc268_volume_init_verbs[] = {
8770 /* set output DAC */
8771 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8772 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8773 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8774 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8776 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
8777 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
8778 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
8779 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
8780 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
8782 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8783 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8784 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8785 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8786 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8788 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8789 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8790 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8791 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8793 /* set PCBEEP vol = 0 */
8794 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, (0xb000 | (0x00 << 8))},
8799 #define alc268_mux_enum_info alc_mux_enum_info
8800 #define alc268_mux_enum_get alc_mux_enum_get
8802 static int alc268_mux_enum_put(struct snd_kcontrol *kcontrol,
8803 struct snd_ctl_elem_value *ucontrol)
8805 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
8806 struct alc_spec *spec = codec->spec;
8807 const struct hda_input_mux *imux = spec->input_mux;
8808 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
8809 static hda_nid_t capture_mixers[3] = { 0x23, 0x24 };
8810 hda_nid_t nid = capture_mixers[adc_idx];
8811 unsigned int *cur_val = &spec->cur_mux[adc_idx];
8812 unsigned int i, idx;
8814 idx = ucontrol->value.enumerated.item[0];
8815 if (idx >= imux->num_items)
8816 idx = imux->num_items - 1;
8817 if (*cur_val == idx)
8819 for (i = 0; i < imux->num_items; i++) {
8820 unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
8821 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
8822 imux->items[i].index,
8824 snd_hda_codec_write_cache(codec, nid, 0,
8825 AC_VERB_SET_CONNECT_SEL,
8832 static struct snd_kcontrol_new alc268_capture_alt_mixer[] = {
8833 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
8834 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
8836 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8837 /* The multiple "Capture Source" controls confuse alsamixer
8838 * So call somewhat different..
8839 * FIXME: the controls appear in the "playback" view!
8841 /* .name = "Capture Source", */
8842 .name = "Input Source",
8844 .info = alc268_mux_enum_info,
8845 .get = alc268_mux_enum_get,
8846 .put = alc268_mux_enum_put,
8851 static struct snd_kcontrol_new alc268_capture_mixer[] = {
8852 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
8853 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
8854 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x24, 0x0, HDA_OUTPUT),
8855 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x24, 0x0, HDA_OUTPUT),
8857 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8858 /* The multiple "Capture Source" controls confuse alsamixer
8859 * So call somewhat different..
8860 * FIXME: the controls appear in the "playback" view!
8862 /* .name = "Capture Source", */
8863 .name = "Input Source",
8865 .info = alc268_mux_enum_info,
8866 .get = alc268_mux_enum_get,
8867 .put = alc268_mux_enum_put,
8872 static struct hda_input_mux alc268_capture_source = {
8876 { "Front Mic", 0x1 },
8882 /* create input playback/capture controls for the given pin */
8883 static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
8884 const char *ctlname, int idx)
8889 sprintf(name, "%s Playback Volume", ctlname);
8891 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
8892 HDA_COMPOSE_AMP_VAL(0x02, 3, idx,
8896 } else if (nid == 0x15) {
8897 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
8898 HDA_COMPOSE_AMP_VAL(0x03, 3, idx,
8904 sprintf(name, "%s Playback Switch", ctlname);
8905 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
8906 HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
8912 /* add playback controls from the parsed DAC table */
8913 static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec,
8914 const struct auto_pin_cfg *cfg)
8919 spec->multiout.num_dacs = 2; /* only use one dac */
8920 spec->multiout.dac_nids = spec->private_dac_nids;
8921 spec->multiout.dac_nids[0] = 2;
8922 spec->multiout.dac_nids[1] = 3;
8924 nid = cfg->line_out_pins[0];
8926 alc268_new_analog_output(spec, nid, "Front", 0);
8928 nid = cfg->speaker_pins[0];
8930 err = add_control(spec, ALC_CTL_WIDGET_VOL,
8931 "Speaker Playback Volume",
8932 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
8936 nid = cfg->hp_pins[0];
8938 alc268_new_analog_output(spec, nid, "Headphone", 0);
8940 nid = cfg->line_out_pins[1] | cfg->line_out_pins[2];
8942 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
8943 "Mono Playback Switch",
8944 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_INPUT));
8951 /* create playback/capture controls for input pins */
8952 static int alc268_auto_create_analog_input_ctls(struct alc_spec *spec,
8953 const struct auto_pin_cfg *cfg)
8955 struct hda_input_mux *imux = &spec->private_imux;
8958 for (i = 0; i < AUTO_PIN_LAST; i++) {
8959 switch(cfg->input_pins[i]) {
8961 idx1 = 0; /* Mic 1 */
8964 idx1 = 1; /* Mic 2 */
8967 idx1 = 2; /* Line In */
8975 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
8976 imux->items[imux->num_items].index = idx1;
8982 static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec)
8984 struct alc_spec *spec = codec->spec;
8985 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
8986 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
8987 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
8988 unsigned int dac_vol1, dac_vol2;
8991 snd_hda_codec_write(codec, speaker_nid, 0,
8992 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
8993 snd_hda_codec_write(codec, 0x0f, 0,
8994 AC_VERB_SET_AMP_GAIN_MUTE,
8996 snd_hda_codec_write(codec, 0x10, 0,
8997 AC_VERB_SET_AMP_GAIN_MUTE,
9000 snd_hda_codec_write(codec, 0x0f, 0,
9001 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
9002 snd_hda_codec_write(codec, 0x10, 0,
9003 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
9006 dac_vol1 = dac_vol2 = 0xb000 | 0x40; /* set max volume */
9007 if (line_nid == 0x14)
9008 dac_vol2 = AMP_OUT_ZERO;
9009 else if (line_nid == 0x15)
9010 dac_vol1 = AMP_OUT_ZERO;
9012 dac_vol2 = AMP_OUT_ZERO;
9013 else if (hp_nid == 0x15)
9014 dac_vol1 = AMP_OUT_ZERO;
9015 if (line_nid != 0x16 || hp_nid != 0x16 ||
9016 spec->autocfg.line_out_pins[1] != 0x16 ||
9017 spec->autocfg.line_out_pins[2] != 0x16)
9018 dac_vol1 = dac_vol2 = AMP_OUT_ZERO;
9020 snd_hda_codec_write(codec, 0x02, 0,
9021 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol1);
9022 snd_hda_codec_write(codec, 0x03, 0,
9023 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol2);
9026 /* pcm configuration: identiacal with ALC880 */
9027 #define alc268_pcm_analog_playback alc880_pcm_analog_playback
9028 #define alc268_pcm_analog_capture alc880_pcm_analog_capture
9029 #define alc268_pcm_digital_playback alc880_pcm_digital_playback
9032 * BIOS auto configuration
9034 static int alc268_parse_auto_config(struct hda_codec *codec)
9036 struct alc_spec *spec = codec->spec;
9038 static hda_nid_t alc268_ignore[] = { 0 };
9040 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
9044 if (!spec->autocfg.line_outs)
9045 return 0; /* can't find valid BIOS pin config */
9047 err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg);
9050 err = alc268_auto_create_analog_input_ctls(spec, &spec->autocfg);
9054 spec->multiout.max_channels = 2;
9056 /* digital only support output */
9057 if (spec->autocfg.dig_out_pin)
9058 spec->multiout.dig_out_nid = ALC268_DIGOUT_NID;
9060 if (spec->kctl_alloc)
9061 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
9063 spec->init_verbs[spec->num_init_verbs++] = alc268_volume_init_verbs;
9064 spec->num_mux_defs = 1;
9065 spec->input_mux = &spec->private_imux;
9067 err = alc_auto_add_mic_boost(codec);
9074 #define alc268_auto_init_multi_out alc882_auto_init_multi_out
9075 #define alc268_auto_init_hp_out alc882_auto_init_hp_out
9076 #define alc268_auto_init_analog_input alc882_auto_init_analog_input
9078 /* init callback for auto-configuration model -- overriding the default init */
9079 static void alc268_auto_init(struct hda_codec *codec)
9081 alc268_auto_init_multi_out(codec);
9082 alc268_auto_init_hp_out(codec);
9083 alc268_auto_init_mono_speaker_out(codec);
9084 alc268_auto_init_analog_input(codec);
9088 * configuration and preset
9090 static const char *alc268_models[ALC268_MODEL_LAST] = {
9091 [ALC268_3ST] = "3stack",
9092 [ALC268_TOSHIBA] = "toshiba",
9093 [ALC268_ACER] = "acer",
9094 [ALC268_AUTO] = "auto",
9097 static struct snd_pci_quirk alc268_cfg_tbl[] = {
9098 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST),
9099 SND_PCI_QUIRK(0x1179, 0xff10, "TOSHIBA A205", ALC268_TOSHIBA),
9100 SND_PCI_QUIRK(0x103c, 0x30cc, "TOSHIBA", ALC268_TOSHIBA),
9101 SND_PCI_QUIRK(0x1025, 0x0126, "Acer", ALC268_ACER),
9102 SND_PCI_QUIRK(0x1025, 0x0130, "Acer Extensa 5210", ALC268_ACER),
9103 SND_PCI_QUIRK(0x152d, 0x0763, "Diverse (CPR2000)", ALC268_ACER),
9107 static struct alc_config_preset alc268_presets[] = {
9109 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer },
9110 .init_verbs = { alc268_base_init_verbs },
9111 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
9112 .dac_nids = alc268_dac_nids,
9113 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
9114 .adc_nids = alc268_adc_nids_alt,
9116 .dig_out_nid = ALC268_DIGOUT_NID,
9117 .num_channel_mode = ARRAY_SIZE(alc268_modes),
9118 .channel_mode = alc268_modes,
9119 .input_mux = &alc268_capture_source,
9121 [ALC268_TOSHIBA] = {
9122 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer },
9123 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
9124 alc268_toshiba_verbs },
9125 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
9126 .dac_nids = alc268_dac_nids,
9127 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
9128 .adc_nids = alc268_adc_nids_alt,
9130 .num_channel_mode = ARRAY_SIZE(alc268_modes),
9131 .channel_mode = alc268_modes,
9132 .input_mux = &alc268_capture_source,
9133 .input_mux = &alc268_capture_source,
9134 .unsol_event = alc268_toshiba_unsol_event,
9135 .init_hook = alc268_toshiba_automute,
9138 .mixers = { alc268_acer_mixer, alc268_capture_alt_mixer },
9139 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
9140 alc268_acer_verbs },
9141 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
9142 .dac_nids = alc268_dac_nids,
9143 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
9144 .adc_nids = alc268_adc_nids_alt,
9146 .num_channel_mode = ARRAY_SIZE(alc268_modes),
9147 .channel_mode = alc268_modes,
9148 .input_mux = &alc268_capture_source,
9149 .unsol_event = alc268_acer_unsol_event,
9150 .init_hook = alc268_acer_init_hook,
9154 static int patch_alc268(struct hda_codec *codec)
9156 struct alc_spec *spec;
9160 spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
9166 board_config = snd_hda_check_board_config(codec, ALC268_MODEL_LAST,
9170 if (board_config < 0 || board_config >= ALC268_MODEL_LAST) {
9171 printk(KERN_INFO "hda_codec: Unknown model for ALC268, "
9172 "trying auto-probe from BIOS...\n");
9173 board_config = ALC268_AUTO;
9176 if (board_config == ALC268_AUTO) {
9177 /* automatic parse from the BIOS config */
9178 err = alc268_parse_auto_config(codec);
9184 "hda_codec: Cannot set up configuration "
9185 "from BIOS. Using base mode...\n");
9186 board_config = ALC268_3ST;
9190 if (board_config != ALC268_AUTO)
9191 setup_preset(spec, &alc268_presets[board_config]);
9193 spec->stream_name_analog = "ALC268 Analog";
9194 spec->stream_analog_playback = &alc268_pcm_analog_playback;
9195 spec->stream_analog_capture = &alc268_pcm_analog_capture;
9197 spec->stream_name_digital = "ALC268 Digital";
9198 spec->stream_digital_playback = &alc268_pcm_digital_playback;
9200 if (board_config == ALC268_AUTO) {
9201 if (!spec->adc_nids && spec->input_mux) {
9202 /* check whether NID 0x07 is valid */
9203 unsigned int wcap = get_wcaps(codec, 0x07);
9206 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
9207 if (wcap != AC_WID_AUD_IN) {
9208 spec->adc_nids = alc268_adc_nids_alt;
9209 spec->num_adc_nids =
9210 ARRAY_SIZE(alc268_adc_nids_alt);
9211 spec->mixers[spec->num_mixers] =
9212 alc268_capture_alt_mixer;
9215 spec->adc_nids = alc268_adc_nids;
9216 spec->num_adc_nids =
9217 ARRAY_SIZE(alc268_adc_nids);
9218 spec->mixers[spec->num_mixers] =
9219 alc268_capture_mixer;
9224 codec->patch_ops = alc_patch_ops;
9225 if (board_config == ALC268_AUTO)
9226 spec->init_hook = alc268_auto_init;
9232 * ALC861 channel source setting (2/6 channel selection for 3-stack)
9236 * set the path ways for 2 channel output
9237 * need to set the codec line out and mic 1 pin widgets to inputs
9239 static struct hda_verb alc861_threestack_ch2_init[] = {
9240 /* set pin widget 1Ah (line in) for input */
9241 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
9242 /* set pin widget 18h (mic1/2) for input, for mic also enable
9245 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
9247 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
9249 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
9250 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
9256 * need to set the codec line out and mic 1 pin widgets to outputs
9258 static struct hda_verb alc861_threestack_ch6_init[] = {
9259 /* set pin widget 1Ah (line in) for output (Back Surround)*/
9260 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
9261 /* set pin widget 18h (mic1) for output (CLFE)*/
9262 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
9264 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
9265 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
9267 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
9269 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
9270 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
9275 static struct hda_channel_mode alc861_threestack_modes[2] = {
9276 { 2, alc861_threestack_ch2_init },
9277 { 6, alc861_threestack_ch6_init },
9279 /* Set mic1 as input and unmute the mixer */
9280 static struct hda_verb alc861_uniwill_m31_ch2_init[] = {
9281 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
9282 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
9285 /* Set mic1 as output and mute mixer */
9286 static struct hda_verb alc861_uniwill_m31_ch4_init[] = {
9287 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
9288 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
9292 static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
9293 { 2, alc861_uniwill_m31_ch2_init },
9294 { 4, alc861_uniwill_m31_ch4_init },
9297 /* Set mic1 and line-in as input and unmute the mixer */
9298 static struct hda_verb alc861_asus_ch2_init[] = {
9299 /* set pin widget 1Ah (line in) for input */
9300 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
9301 /* set pin widget 18h (mic1/2) for input, for mic also enable
9304 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
9306 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
9308 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
9309 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
9313 /* Set mic1 nad line-in as output and mute mixer */
9314 static struct hda_verb alc861_asus_ch6_init[] = {
9315 /* set pin widget 1Ah (line in) for output (Back Surround)*/
9316 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
9317 /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
9318 /* set pin widget 18h (mic1) for output (CLFE)*/
9319 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
9320 /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
9321 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
9322 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
9324 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
9326 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
9327 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
9332 static struct hda_channel_mode alc861_asus_modes[2] = {
9333 { 2, alc861_asus_ch2_init },
9334 { 6, alc861_asus_ch6_init },
9339 static struct snd_kcontrol_new alc861_base_mixer[] = {
9340 /* output mixer control */
9341 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
9342 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
9343 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
9344 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
9345 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
9347 /*Input mixer control */
9348 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
9349 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
9350 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
9351 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
9352 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
9353 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
9354 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
9355 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
9356 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
9357 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
9359 /* Capture mixer control */
9360 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
9361 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
9363 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9364 .name = "Capture Source",
9366 .info = alc_mux_enum_info,
9367 .get = alc_mux_enum_get,
9368 .put = alc_mux_enum_put,
9373 static struct snd_kcontrol_new alc861_3ST_mixer[] = {
9374 /* output mixer control */
9375 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
9376 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
9377 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
9378 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
9379 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
9381 /* Input mixer control */
9382 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
9383 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
9384 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
9385 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
9386 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
9387 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
9388 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
9389 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
9390 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
9391 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
9393 /* Capture mixer control */
9394 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
9395 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
9397 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9398 .name = "Capture Source",
9400 .info = alc_mux_enum_info,
9401 .get = alc_mux_enum_get,
9402 .put = alc_mux_enum_put,
9405 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9406 .name = "Channel Mode",
9407 .info = alc_ch_mode_info,
9408 .get = alc_ch_mode_get,
9409 .put = alc_ch_mode_put,
9410 .private_value = ARRAY_SIZE(alc861_threestack_modes),
9415 static struct snd_kcontrol_new alc861_toshiba_mixer[] = {
9416 /* output mixer control */
9417 HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT),
9418 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
9419 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
9421 /*Capture mixer control */
9422 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
9423 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
9425 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9426 .name = "Capture Source",
9428 .info = alc_mux_enum_info,
9429 .get = alc_mux_enum_get,
9430 .put = alc_mux_enum_put,
9436 static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
9437 /* output mixer control */
9438 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
9439 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
9440 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
9441 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
9442 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
9444 /* Input mixer control */
9445 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
9446 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
9447 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
9448 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
9449 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
9450 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
9451 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
9452 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
9453 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
9454 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
9456 /* Capture mixer control */
9457 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
9458 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
9460 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9461 .name = "Capture Source",
9463 .info = alc_mux_enum_info,
9464 .get = alc_mux_enum_get,
9465 .put = alc_mux_enum_put,
9468 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9469 .name = "Channel Mode",
9470 .info = alc_ch_mode_info,
9471 .get = alc_ch_mode_get,
9472 .put = alc_ch_mode_put,
9473 .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
9478 static struct snd_kcontrol_new alc861_asus_mixer[] = {
9479 /* output mixer control */
9480 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
9481 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
9482 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
9483 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
9484 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
9486 /* Input mixer control */
9487 HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
9488 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9489 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
9490 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
9491 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
9492 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
9493 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
9494 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
9495 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
9496 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT),
9498 /* Capture mixer control */
9499 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
9500 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
9502 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9503 .name = "Capture Source",
9505 .info = alc_mux_enum_info,
9506 .get = alc_mux_enum_get,
9507 .put = alc_mux_enum_put,
9510 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9511 .name = "Channel Mode",
9512 .info = alc_ch_mode_info,
9513 .get = alc_ch_mode_get,
9514 .put = alc_ch_mode_put,
9515 .private_value = ARRAY_SIZE(alc861_asus_modes),
9520 /* additional mixer */
9521 static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = {
9522 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
9523 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
9524 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x23, 0x0, HDA_OUTPUT),
9525 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x23, 0x0, HDA_OUTPUT),
9530 * generic initialization of ADC, input mixers and output mixers
9532 static struct hda_verb alc861_base_init_verbs[] = {
9534 * Unmute ADC0 and set the default input to mic-in
9536 /* port-A for surround (rear panel) */
9537 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
9538 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
9539 /* port-B for mic-in (rear panel) with vref */
9540 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
9541 /* port-C for line-in (rear panel) */
9542 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
9543 /* port-D for Front */
9544 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
9545 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
9546 /* port-E for HP out (front panel) */
9547 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
9548 /* route front PCM to HP */
9549 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
9550 /* port-F for mic-in (front panel) with vref */
9551 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
9552 /* port-G for CLFE (rear panel) */
9553 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
9554 { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
9555 /* port-H for side (rear panel) */
9556 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
9557 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
9559 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
9560 /* route front mic to ADC1*/
9561 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
9562 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9564 /* Unmute DAC0~3 & spdif out*/
9565 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9566 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9567 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9568 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9569 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9571 /* Unmute Mixer 14 (mic) 1c (Line in)*/
9572 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9573 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9574 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9575 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9577 /* Unmute Stereo Mixer 15 */
9578 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9579 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9580 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
9581 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
9583 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9584 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9585 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9586 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9587 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9588 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9589 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9590 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9591 /* hp used DAC 3 (Front) */
9592 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
9593 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
9598 static struct hda_verb alc861_threestack_init_verbs[] = {
9600 * Unmute ADC0 and set the default input to mic-in
9602 /* port-A for surround (rear panel) */
9603 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
9604 /* port-B for mic-in (rear panel) with vref */
9605 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
9606 /* port-C for line-in (rear panel) */
9607 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
9608 /* port-D for Front */
9609 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
9610 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
9611 /* port-E for HP out (front panel) */
9612 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
9613 /* route front PCM to HP */
9614 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
9615 /* port-F for mic-in (front panel) with vref */
9616 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
9617 /* port-G for CLFE (rear panel) */
9618 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
9619 /* port-H for side (rear panel) */
9620 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
9622 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
9623 /* route front mic to ADC1*/
9624 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
9625 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9626 /* Unmute DAC0~3 & spdif out*/
9627 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9628 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9629 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9630 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9631 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9633 /* Unmute Mixer 14 (mic) 1c (Line in)*/
9634 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9635 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9636 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9637 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9639 /* Unmute Stereo Mixer 15 */
9640 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9641 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9642 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
9643 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
9645 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9646 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9647 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9648 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9649 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9650 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9651 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9652 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9653 /* hp used DAC 3 (Front) */
9654 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
9655 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
9659 static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
9661 * Unmute ADC0 and set the default input to mic-in
9663 /* port-A for surround (rear panel) */
9664 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
9665 /* port-B for mic-in (rear panel) with vref */
9666 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
9667 /* port-C for line-in (rear panel) */
9668 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
9669 /* port-D for Front */
9670 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
9671 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
9672 /* port-E for HP out (front panel) */
9673 /* this has to be set to VREF80 */
9674 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
9675 /* route front PCM to HP */
9676 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
9677 /* port-F for mic-in (front panel) with vref */
9678 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
9679 /* port-G for CLFE (rear panel) */
9680 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
9681 /* port-H for side (rear panel) */
9682 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
9684 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
9685 /* route front mic to ADC1*/
9686 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
9687 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9688 /* Unmute DAC0~3 & spdif out*/
9689 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9690 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9691 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9692 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9693 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9695 /* Unmute Mixer 14 (mic) 1c (Line in)*/
9696 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9697 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9698 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9699 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9701 /* Unmute Stereo Mixer 15 */
9702 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9703 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9704 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
9705 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
9707 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9708 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9709 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9710 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9711 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9712 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9713 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9714 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9715 /* hp used DAC 3 (Front) */
9716 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
9717 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
9721 static struct hda_verb alc861_asus_init_verbs[] = {
9723 * Unmute ADC0 and set the default input to mic-in
9725 /* port-A for surround (rear panel)
9726 * according to codec#0 this is the HP jack
9728 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */
9729 /* route front PCM to HP */
9730 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 },
9731 /* port-B for mic-in (rear panel) with vref */
9732 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
9733 /* port-C for line-in (rear panel) */
9734 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
9735 /* port-D for Front */
9736 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
9737 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
9738 /* port-E for HP out (front panel) */
9739 /* this has to be set to VREF80 */
9740 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
9741 /* route front PCM to HP */
9742 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
9743 /* port-F for mic-in (front panel) with vref */
9744 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
9745 /* port-G for CLFE (rear panel) */
9746 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
9747 /* port-H for side (rear panel) */
9748 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
9750 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
9751 /* route front mic to ADC1*/
9752 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
9753 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9754 /* Unmute DAC0~3 & spdif out*/
9755 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9756 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9757 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9758 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9759 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9760 /* Unmute Mixer 14 (mic) 1c (Line in)*/
9761 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9762 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9763 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9764 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9766 /* Unmute Stereo Mixer 15 */
9767 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9768 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9769 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
9770 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
9772 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9773 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9774 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9775 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9776 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9777 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9778 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9779 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9780 /* hp used DAC 3 (Front) */
9781 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
9782 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
9786 /* additional init verbs for ASUS laptops */
9787 static struct hda_verb alc861_asus_laptop_init_verbs[] = {
9788 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */
9789 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */
9794 * generic initialization of ADC, input mixers and output mixers
9796 static struct hda_verb alc861_auto_init_verbs[] = {
9798 * Unmute ADC0 and set the default input to mic-in
9800 /* {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, */
9801 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9803 /* Unmute DAC0~3 & spdif out*/
9804 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9805 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9806 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9807 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9808 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9810 /* Unmute Mixer 14 (mic) 1c (Line in)*/
9811 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9812 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9813 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9814 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9816 /* Unmute Stereo Mixer 15 */
9817 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9818 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9819 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
9820 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
9822 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9823 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9824 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9825 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9826 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9827 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9828 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9829 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9831 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9832 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9833 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
9834 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
9835 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9836 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9837 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
9838 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
9840 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */
9845 static struct hda_verb alc861_toshiba_init_verbs[] = {
9846 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9851 /* toggle speaker-output according to the hp-jack state */
9852 static void alc861_toshiba_automute(struct hda_codec *codec)
9854 unsigned int present;
9856 present = snd_hda_codec_read(codec, 0x0f, 0,
9857 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
9858 snd_hda_codec_amp_stereo(codec, 0x16, HDA_INPUT, 0,
9859 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
9860 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_INPUT, 3,
9861 HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
9864 static void alc861_toshiba_unsol_event(struct hda_codec *codec,
9867 if ((res >> 26) == ALC880_HP_EVENT)
9868 alc861_toshiba_automute(codec);
9871 /* pcm configuration: identiacal with ALC880 */
9872 #define alc861_pcm_analog_playback alc880_pcm_analog_playback
9873 #define alc861_pcm_analog_capture alc880_pcm_analog_capture
9874 #define alc861_pcm_digital_playback alc880_pcm_digital_playback
9875 #define alc861_pcm_digital_capture alc880_pcm_digital_capture
9878 #define ALC861_DIGOUT_NID 0x07
9880 static struct hda_channel_mode alc861_8ch_modes[1] = {
9884 static hda_nid_t alc861_dac_nids[4] = {
9885 /* front, surround, clfe, side */
9886 0x03, 0x06, 0x05, 0x04
9889 static hda_nid_t alc660_dac_nids[3] = {
9890 /* front, clfe, surround */
9894 static hda_nid_t alc861_adc_nids[1] = {
9899 static struct hda_input_mux alc861_capture_source = {
9903 { "Front Mic", 0x3 },
9910 /* fill in the dac_nids table from the parsed pin configuration */
9911 static int alc861_auto_fill_dac_nids(struct alc_spec *spec,
9912 const struct auto_pin_cfg *cfg)
9917 spec->multiout.dac_nids = spec->private_dac_nids;
9918 for (i = 0; i < cfg->line_outs; i++) {
9919 nid = cfg->line_out_pins[i];
9921 if (i >= ARRAY_SIZE(alc861_dac_nids))
9923 spec->multiout.dac_nids[i] = alc861_dac_nids[i];
9926 spec->multiout.num_dacs = cfg->line_outs;
9930 /* add playback controls from the parsed DAC table */
9931 static int alc861_auto_create_multi_out_ctls(struct alc_spec *spec,
9932 const struct auto_pin_cfg *cfg)
9935 static const char *chname[4] = {
9936 "Front", "Surround", NULL /*CLFE*/, "Side"
9941 for (i = 0; i < cfg->line_outs; i++) {
9942 nid = spec->multiout.dac_nids[i];
9947 err = add_control(spec, ALC_CTL_BIND_MUTE,
9948 "Center Playback Switch",
9949 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
9953 err = add_control(spec, ALC_CTL_BIND_MUTE,
9954 "LFE Playback Switch",
9955 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
9960 for (idx = 0; idx < ARRAY_SIZE(alc861_dac_nids) - 1;
9962 if (nid == alc861_dac_nids[idx])
9964 sprintf(name, "%s Playback Switch", chname[idx]);
9965 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
9966 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
9975 static int alc861_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin)
9983 if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
9985 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
9986 "Headphone Playback Switch",
9987 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
9990 spec->multiout.hp_nid = nid;
9995 /* create playback/capture controls for input pins */
9996 static int alc861_auto_create_analog_input_ctls(struct alc_spec *spec,
9997 const struct auto_pin_cfg *cfg)
9999 struct hda_input_mux *imux = &spec->private_imux;
10000 int i, err, idx, idx1;
10002 for (i = 0; i < AUTO_PIN_LAST; i++) {
10003 switch (cfg->input_pins[i]) {
10006 idx = 2; /* Line In */
10010 idx = 2; /* Line In */
10014 idx = 1; /* Mic In */
10018 idx = 1; /* Mic In */
10028 err = new_analog_input(spec, cfg->input_pins[i],
10029 auto_pin_cfg_labels[i], idx, 0x15);
10033 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
10034 imux->items[imux->num_items].index = idx1;
10040 static struct snd_kcontrol_new alc861_capture_mixer[] = {
10041 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
10042 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
10045 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10046 /* The multiple "Capture Source" controls confuse alsamixer
10047 * So call somewhat different..
10048 *FIXME: the controls appear in the "playback" view!
10050 /* .name = "Capture Source", */
10051 .name = "Input Source",
10053 .info = alc_mux_enum_info,
10054 .get = alc_mux_enum_get,
10055 .put = alc_mux_enum_put,
10060 static void alc861_auto_set_output_and_unmute(struct hda_codec *codec,
10062 int pin_type, int dac_idx)
10064 /* set as output */
10066 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
10068 snd_hda_codec_write(codec, dac_idx, 0, AC_VERB_SET_AMP_GAIN_MUTE,
10073 static void alc861_auto_init_multi_out(struct hda_codec *codec)
10075 struct alc_spec *spec = codec->spec;
10078 alc_subsystem_id(codec, 0x0e, 0x0f, 0x0b);
10079 for (i = 0; i < spec->autocfg.line_outs; i++) {
10080 hda_nid_t nid = spec->autocfg.line_out_pins[i];
10081 int pin_type = get_pin_type(spec->autocfg.line_out_type);
10083 alc861_auto_set_output_and_unmute(codec, nid, pin_type,
10084 spec->multiout.dac_nids[i]);
10088 static void alc861_auto_init_hp_out(struct hda_codec *codec)
10090 struct alc_spec *spec = codec->spec;
10093 pin = spec->autocfg.hp_pins[0];
10094 if (pin) /* connect to front */
10095 alc861_auto_set_output_and_unmute(codec, pin, PIN_HP,
10096 spec->multiout.dac_nids[0]);
10099 static void alc861_auto_init_analog_input(struct hda_codec *codec)
10101 struct alc_spec *spec = codec->spec;
10104 for (i = 0; i < AUTO_PIN_LAST; i++) {
10105 hda_nid_t nid = spec->autocfg.input_pins[i];
10106 if (nid >= 0x0c && nid <= 0x11) {
10107 snd_hda_codec_write(codec, nid, 0,
10108 AC_VERB_SET_PIN_WIDGET_CONTROL,
10109 i <= AUTO_PIN_FRONT_MIC ?
10110 PIN_VREF80 : PIN_IN);
10115 /* parse the BIOS configuration and set up the alc_spec */
10116 /* return 1 if successful, 0 if the proper config is not found,
10117 * or a negative error code
10119 static int alc861_parse_auto_config(struct hda_codec *codec)
10121 struct alc_spec *spec = codec->spec;
10123 static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
10125 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
10129 if (!spec->autocfg.line_outs)
10130 return 0; /* can't find valid BIOS pin config */
10132 err = alc861_auto_fill_dac_nids(spec, &spec->autocfg);
10135 err = alc861_auto_create_multi_out_ctls(spec, &spec->autocfg);
10138 err = alc861_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0]);
10141 err = alc861_auto_create_analog_input_ctls(spec, &spec->autocfg);
10145 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
10147 if (spec->autocfg.dig_out_pin)
10148 spec->multiout.dig_out_nid = ALC861_DIGOUT_NID;
10150 if (spec->kctl_alloc)
10151 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
10153 spec->init_verbs[spec->num_init_verbs++] = alc861_auto_init_verbs;
10155 spec->num_mux_defs = 1;
10156 spec->input_mux = &spec->private_imux;
10158 spec->adc_nids = alc861_adc_nids;
10159 spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
10160 spec->mixers[spec->num_mixers] = alc861_capture_mixer;
10161 spec->num_mixers++;
10166 /* additional initialization for auto-configuration model */
10167 static void alc861_auto_init(struct hda_codec *codec)
10169 alc861_auto_init_multi_out(codec);
10170 alc861_auto_init_hp_out(codec);
10171 alc861_auto_init_analog_input(codec);
10174 #ifdef CONFIG_SND_HDA_POWER_SAVE
10175 static struct hda_amp_list alc861_loopbacks[] = {
10176 { 0x15, HDA_INPUT, 0 },
10177 { 0x15, HDA_INPUT, 1 },
10178 { 0x15, HDA_INPUT, 2 },
10179 { 0x15, HDA_INPUT, 3 },
10186 * configuration and preset
10188 static const char *alc861_models[ALC861_MODEL_LAST] = {
10189 [ALC861_3ST] = "3stack",
10190 [ALC660_3ST] = "3stack-660",
10191 [ALC861_3ST_DIG] = "3stack-dig",
10192 [ALC861_6ST_DIG] = "6stack-dig",
10193 [ALC861_UNIWILL_M31] = "uniwill-m31",
10194 [ALC861_TOSHIBA] = "toshiba",
10195 [ALC861_ASUS] = "asus",
10196 [ALC861_ASUS_LAPTOP] = "asus-laptop",
10197 [ALC861_AUTO] = "auto",
10200 static struct snd_pci_quirk alc861_cfg_tbl[] = {
10201 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST),
10202 SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP),
10203 SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP),
10204 SND_PCI_QUIRK(0x1043, 0x13d7, "ASUS A9rp", ALC861_ASUS_LAPTOP),
10205 SND_PCI_QUIRK(0x1584, 0x9075, "Airis Praxis N1212", ALC861_ASUS_LAPTOP),
10206 SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS),
10207 SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS P1-AH2", ALC861_3ST_DIG),
10208 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA),
10209 /* FIXME: the entry below breaks Toshiba A100 (model=auto works!)
10210 * Any other models that need this preset?
10212 /* SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA), */
10213 SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31),
10214 SND_PCI_QUIRK(0x1584, 0x9075, "Uniwill", ALC861_UNIWILL_M31),
10215 SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31),
10216 SND_PCI_QUIRK(0x1849, 0x0660, "Asrock 939SLI32", ALC660_3ST),
10217 SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST),
10218 SND_PCI_QUIRK(0x1462, 0x7254, "HP dx2200 (MSI MS-7254)", ALC861_3ST),
10219 SND_PCI_QUIRK(0x1462, 0x7297, "HP dx2250 (MSI MS-7297)", ALC861_3ST),
10223 static struct alc_config_preset alc861_presets[] = {
10225 .mixers = { alc861_3ST_mixer },
10226 .init_verbs = { alc861_threestack_init_verbs },
10227 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
10228 .dac_nids = alc861_dac_nids,
10229 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
10230 .channel_mode = alc861_threestack_modes,
10232 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
10233 .adc_nids = alc861_adc_nids,
10234 .input_mux = &alc861_capture_source,
10236 [ALC861_3ST_DIG] = {
10237 .mixers = { alc861_base_mixer },
10238 .init_verbs = { alc861_threestack_init_verbs },
10239 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
10240 .dac_nids = alc861_dac_nids,
10241 .dig_out_nid = ALC861_DIGOUT_NID,
10242 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
10243 .channel_mode = alc861_threestack_modes,
10245 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
10246 .adc_nids = alc861_adc_nids,
10247 .input_mux = &alc861_capture_source,
10249 [ALC861_6ST_DIG] = {
10250 .mixers = { alc861_base_mixer },
10251 .init_verbs = { alc861_base_init_verbs },
10252 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
10253 .dac_nids = alc861_dac_nids,
10254 .dig_out_nid = ALC861_DIGOUT_NID,
10255 .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
10256 .channel_mode = alc861_8ch_modes,
10257 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
10258 .adc_nids = alc861_adc_nids,
10259 .input_mux = &alc861_capture_source,
10262 .mixers = { alc861_3ST_mixer },
10263 .init_verbs = { alc861_threestack_init_verbs },
10264 .num_dacs = ARRAY_SIZE(alc660_dac_nids),
10265 .dac_nids = alc660_dac_nids,
10266 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
10267 .channel_mode = alc861_threestack_modes,
10269 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
10270 .adc_nids = alc861_adc_nids,
10271 .input_mux = &alc861_capture_source,
10273 [ALC861_UNIWILL_M31] = {
10274 .mixers = { alc861_uniwill_m31_mixer },
10275 .init_verbs = { alc861_uniwill_m31_init_verbs },
10276 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
10277 .dac_nids = alc861_dac_nids,
10278 .dig_out_nid = ALC861_DIGOUT_NID,
10279 .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes),
10280 .channel_mode = alc861_uniwill_m31_modes,
10282 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
10283 .adc_nids = alc861_adc_nids,
10284 .input_mux = &alc861_capture_source,
10286 [ALC861_TOSHIBA] = {
10287 .mixers = { alc861_toshiba_mixer },
10288 .init_verbs = { alc861_base_init_verbs,
10289 alc861_toshiba_init_verbs },
10290 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
10291 .dac_nids = alc861_dac_nids,
10292 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10293 .channel_mode = alc883_3ST_2ch_modes,
10294 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
10295 .adc_nids = alc861_adc_nids,
10296 .input_mux = &alc861_capture_source,
10297 .unsol_event = alc861_toshiba_unsol_event,
10298 .init_hook = alc861_toshiba_automute,
10301 .mixers = { alc861_asus_mixer },
10302 .init_verbs = { alc861_asus_init_verbs },
10303 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
10304 .dac_nids = alc861_dac_nids,
10305 .dig_out_nid = ALC861_DIGOUT_NID,
10306 .num_channel_mode = ARRAY_SIZE(alc861_asus_modes),
10307 .channel_mode = alc861_asus_modes,
10310 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
10311 .adc_nids = alc861_adc_nids,
10312 .input_mux = &alc861_capture_source,
10314 [ALC861_ASUS_LAPTOP] = {
10315 .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer },
10316 .init_verbs = { alc861_asus_init_verbs,
10317 alc861_asus_laptop_init_verbs },
10318 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
10319 .dac_nids = alc861_dac_nids,
10320 .dig_out_nid = ALC861_DIGOUT_NID,
10321 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10322 .channel_mode = alc883_3ST_2ch_modes,
10324 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
10325 .adc_nids = alc861_adc_nids,
10326 .input_mux = &alc861_capture_source,
10331 static int patch_alc861(struct hda_codec *codec)
10333 struct alc_spec *spec;
10337 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
10341 codec->spec = spec;
10343 board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST,
10347 if (board_config < 0) {
10348 printk(KERN_INFO "hda_codec: Unknown model for ALC861, "
10349 "trying auto-probe from BIOS...\n");
10350 board_config = ALC861_AUTO;
10353 if (board_config == ALC861_AUTO) {
10354 /* automatic parse from the BIOS config */
10355 err = alc861_parse_auto_config(codec);
10361 "hda_codec: Cannot set up configuration "
10362 "from BIOS. Using base mode...\n");
10363 board_config = ALC861_3ST_DIG;
10367 if (board_config != ALC861_AUTO)
10368 setup_preset(spec, &alc861_presets[board_config]);
10370 spec->stream_name_analog = "ALC861 Analog";
10371 spec->stream_analog_playback = &alc861_pcm_analog_playback;
10372 spec->stream_analog_capture = &alc861_pcm_analog_capture;
10374 spec->stream_name_digital = "ALC861 Digital";
10375 spec->stream_digital_playback = &alc861_pcm_digital_playback;
10376 spec->stream_digital_capture = &alc861_pcm_digital_capture;
10378 codec->patch_ops = alc_patch_ops;
10379 if (board_config == ALC861_AUTO)
10380 spec->init_hook = alc861_auto_init;
10381 #ifdef CONFIG_SND_HDA_POWER_SAVE
10382 if (!spec->loopback.amplist)
10383 spec->loopback.amplist = alc861_loopbacks;
10390 * ALC861-VD support
10394 * In addition, an independent DAC
10396 #define ALC861VD_DIGOUT_NID 0x06
10398 static hda_nid_t alc861vd_dac_nids[4] = {
10399 /* front, surr, clfe, side surr */
10400 0x02, 0x03, 0x04, 0x05
10403 /* dac_nids for ALC660vd are in a different order - according to
10404 * Realtek's driver.
10405 * This should probably tesult in a different mixer for 6stack models
10406 * of ALC660vd codecs, but for now there is only 3stack mixer
10407 * - and it is the same as in 861vd.
10408 * adc_nids in ALC660vd are (is) the same as in 861vd
10410 static hda_nid_t alc660vd_dac_nids[3] = {
10411 /* front, rear, clfe, rear_surr */
10415 static hda_nid_t alc861vd_adc_nids[1] = {
10421 /* FIXME: should be a matrix-type input source selection */
10422 static struct hda_input_mux alc861vd_capture_source = {
10426 { "Front Mic", 0x1 },
10432 static struct hda_input_mux alc861vd_dallas_capture_source = {
10435 { "Front Mic", 0x0 },
10436 { "ATAPI Mic", 0x1 },
10437 { "Line In", 0x5 },
10441 static struct hda_input_mux alc861vd_hp_capture_source = {
10444 { "Front Mic", 0x0 },
10445 { "ATAPI Mic", 0x1 },
10449 #define alc861vd_mux_enum_info alc_mux_enum_info
10450 #define alc861vd_mux_enum_get alc_mux_enum_get
10452 static int alc861vd_mux_enum_put(struct snd_kcontrol *kcontrol,
10453 struct snd_ctl_elem_value *ucontrol)
10455 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10456 struct alc_spec *spec = codec->spec;
10457 const struct hda_input_mux *imux = spec->input_mux;
10458 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
10459 static hda_nid_t capture_mixers[1] = { 0x22 };
10460 hda_nid_t nid = capture_mixers[adc_idx];
10461 unsigned int *cur_val = &spec->cur_mux[adc_idx];
10462 unsigned int i, idx;
10464 idx = ucontrol->value.enumerated.item[0];
10465 if (idx >= imux->num_items)
10466 idx = imux->num_items - 1;
10467 if (*cur_val == idx)
10469 for (i = 0; i < imux->num_items; i++) {
10470 unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
10471 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
10472 imux->items[i].index,
10482 static struct hda_channel_mode alc861vd_3stack_2ch_modes[1] = {
10489 static struct hda_verb alc861vd_6stack_ch6_init[] = {
10490 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
10491 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10492 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10493 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10500 static struct hda_verb alc861vd_6stack_ch8_init[] = {
10501 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10502 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10503 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10504 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10508 static struct hda_channel_mode alc861vd_6stack_modes[2] = {
10509 { 6, alc861vd_6stack_ch6_init },
10510 { 8, alc861vd_6stack_ch8_init },
10513 static struct snd_kcontrol_new alc861vd_chmode_mixer[] = {
10515 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10516 .name = "Channel Mode",
10517 .info = alc_ch_mode_info,
10518 .get = alc_ch_mode_get,
10519 .put = alc_ch_mode_put,
10524 static struct snd_kcontrol_new alc861vd_capture_mixer[] = {
10525 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
10526 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
10529 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10530 /* The multiple "Capture Source" controls confuse alsamixer
10531 * So call somewhat different..
10532 *FIXME: the controls appear in the "playback" view!
10534 /* .name = "Capture Source", */
10535 .name = "Input Source",
10537 .info = alc861vd_mux_enum_info,
10538 .get = alc861vd_mux_enum_get,
10539 .put = alc861vd_mux_enum_put,
10544 /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
10545 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
10547 static struct snd_kcontrol_new alc861vd_6st_mixer[] = {
10548 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
10549 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
10551 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
10552 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
10554 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0,
10556 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0,
10558 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
10559 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
10561 HDA_CODEC_VOLUME("Side Playback Volume", 0x05, 0x0, HDA_OUTPUT),
10562 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
10564 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
10566 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10567 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10568 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10570 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10571 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
10572 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
10574 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10575 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10577 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10578 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10580 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
10581 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
10586 static struct snd_kcontrol_new alc861vd_3st_mixer[] = {
10587 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
10588 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
10590 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
10592 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10593 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10594 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10596 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10597 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
10598 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
10600 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10601 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10603 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10604 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10606 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
10607 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
10612 static struct snd_kcontrol_new alc861vd_lenovo_mixer[] = {
10613 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
10614 /*HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),*/
10615 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
10617 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
10619 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10620 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10621 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10623 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10624 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
10625 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
10627 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10628 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10633 /* Pin assignment: Front=0x14, HP = 0x15,
10634 * Front Mic=0x18, ATAPI Mic = 0x19, Line In = 0x1d
10636 static struct snd_kcontrol_new alc861vd_dallas_mixer[] = {
10637 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
10638 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
10639 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
10640 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
10641 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10642 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10643 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
10644 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
10645 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x05, HDA_INPUT),
10646 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x05, HDA_INPUT),
10650 /* Pin assignment: Speaker=0x14, Line-out = 0x15,
10651 * Front Mic=0x18, ATAPI Mic = 0x19,
10653 static struct snd_kcontrol_new alc861vd_hp_mixer[] = {
10654 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
10655 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
10656 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
10657 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
10658 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10659 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10660 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
10661 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
10667 * generic initialization of ADC, input mixers and output mixers
10669 static struct hda_verb alc861vd_volume_init_verbs[] = {
10671 * Unmute ADC0 and set the default input to mic-in
10673 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
10674 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10676 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of
10677 * the analog-loopback mixer widget
10679 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
10680 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10681 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10682 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10683 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10684 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
10686 /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */
10687 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10688 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10689 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
10690 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
10693 * Set up output mixers (0x02 - 0x05)
10695 /* set vol=0 to output mixers */
10696 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10697 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10698 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10699 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10701 /* set up input amps for analog loopback */
10702 /* Amp Indices: DAC = 0, mixer = 1 */
10703 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10704 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10705 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10706 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10707 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10708 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10709 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10710 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10716 * 3-stack pin configuration:
10717 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
10719 static struct hda_verb alc861vd_3stack_init_verbs[] = {
10721 * Set pin mode and muting
10723 /* set front pin widgets 0x14 for output */
10724 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10725 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10726 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
10728 /* Mic (rear) pin: input vref at 80% */
10729 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
10730 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10731 /* Front Mic pin: input vref at 80% */
10732 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
10733 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10734 /* Line In pin: input */
10735 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10736 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10737 /* Line-2 In: Headphone output (output 0 - 0x0c) */
10738 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10739 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10740 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
10741 /* CD pin widget for input */
10742 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10748 * 6-stack pin configuration:
10750 static struct hda_verb alc861vd_6stack_init_verbs[] = {
10752 * Set pin mode and muting
10754 /* set front pin widgets 0x14 for output */
10755 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10756 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10757 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
10759 /* Rear Pin: output 1 (0x0d) */
10760 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10761 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10762 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
10763 /* CLFE Pin: output 2 (0x0e) */
10764 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10765 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10766 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
10767 /* Side Pin: output 3 (0x0f) */
10768 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10769 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10770 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
10772 /* Mic (rear) pin: input vref at 80% */
10773 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
10774 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10775 /* Front Mic pin: input vref at 80% */
10776 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
10777 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10778 /* Line In pin: input */
10779 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10780 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10781 /* Line-2 In: Headphone output (output 0 - 0x0c) */
10782 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10783 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10784 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
10785 /* CD pin widget for input */
10786 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10791 static struct hda_verb alc861vd_eapd_verbs[] = {
10792 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
10796 static struct hda_verb alc861vd_lenovo_unsol_verbs[] = {
10797 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10798 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10799 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
10800 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10801 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
10805 /* toggle speaker-output according to the hp-jack state */
10806 static void alc861vd_lenovo_hp_automute(struct hda_codec *codec)
10808 unsigned int present;
10809 unsigned char bits;
10811 present = snd_hda_codec_read(codec, 0x1b, 0,
10812 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
10813 bits = present ? HDA_AMP_MUTE : 0;
10814 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10815 HDA_AMP_MUTE, bits);
10818 static void alc861vd_lenovo_mic_automute(struct hda_codec *codec)
10820 unsigned int present;
10821 unsigned char bits;
10823 present = snd_hda_codec_read(codec, 0x18, 0,
10824 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
10825 bits = present ? HDA_AMP_MUTE : 0;
10826 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
10827 HDA_AMP_MUTE, bits);
10830 static void alc861vd_lenovo_automute(struct hda_codec *codec)
10832 alc861vd_lenovo_hp_automute(codec);
10833 alc861vd_lenovo_mic_automute(codec);
10836 static void alc861vd_lenovo_unsol_event(struct hda_codec *codec,
10839 switch (res >> 26) {
10840 case ALC880_HP_EVENT:
10841 alc861vd_lenovo_hp_automute(codec);
10843 case ALC880_MIC_EVENT:
10844 alc861vd_lenovo_mic_automute(codec);
10849 static struct hda_verb alc861vd_dallas_verbs[] = {
10850 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10851 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10852 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10853 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10855 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10856 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10857 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10858 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10859 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10860 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10861 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10862 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10864 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10865 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10866 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10867 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10868 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10869 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10870 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10871 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10873 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
10874 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10875 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
10876 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10877 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10878 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10879 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10880 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10882 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10883 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10884 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10885 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
10887 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10888 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
10889 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10894 /* toggle speaker-output according to the hp-jack state */
10895 static void alc861vd_dallas_automute(struct hda_codec *codec)
10897 unsigned int present;
10899 present = snd_hda_codec_read(codec, 0x15, 0,
10900 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
10901 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10902 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
10905 static void alc861vd_dallas_unsol_event(struct hda_codec *codec, unsigned int res)
10907 if ((res >> 26) == ALC880_HP_EVENT)
10908 alc861vd_dallas_automute(codec);
10911 #ifdef CONFIG_SND_HDA_POWER_SAVE
10912 #define alc861vd_loopbacks alc880_loopbacks
10915 /* pcm configuration: identiacal with ALC880 */
10916 #define alc861vd_pcm_analog_playback alc880_pcm_analog_playback
10917 #define alc861vd_pcm_analog_capture alc880_pcm_analog_capture
10918 #define alc861vd_pcm_digital_playback alc880_pcm_digital_playback
10919 #define alc861vd_pcm_digital_capture alc880_pcm_digital_capture
10922 * configuration and preset
10924 static const char *alc861vd_models[ALC861VD_MODEL_LAST] = {
10925 [ALC660VD_3ST] = "3stack-660",
10926 [ALC660VD_3ST_DIG] = "3stack-660-digout",
10927 [ALC861VD_3ST] = "3stack",
10928 [ALC861VD_3ST_DIG] = "3stack-digout",
10929 [ALC861VD_6ST_DIG] = "6stack-digout",
10930 [ALC861VD_LENOVO] = "lenovo",
10931 [ALC861VD_DALLAS] = "dallas",
10932 [ALC861VD_HP] = "hp",
10933 [ALC861VD_AUTO] = "auto",
10936 static struct snd_pci_quirk alc861vd_cfg_tbl[] = {
10937 SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST),
10938 SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST),
10939 SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660VD_3ST_DIG),
10940 SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST),
10941 SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST),
10943 /*SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),*/ /*lenovo*/
10944 SND_PCI_QUIRK(0x1179, 0xff01, "DALLAS", ALC861VD_DALLAS),
10945 SND_PCI_QUIRK(0x17aa, 0x3802, "Lenovo 3000 C200", ALC861VD_LENOVO),
10946 SND_PCI_QUIRK(0x17aa, 0x2066, "Lenovo", ALC861VD_LENOVO),
10947 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba A135", ALC861VD_LENOVO),
10948 SND_PCI_QUIRK(0x1179, 0xff03, "Toshiba P205", ALC861VD_LENOVO),
10949 SND_PCI_QUIRK(0x1565, 0x820d, "Biostar NF61S SE", ALC861VD_6ST_DIG),
10950 SND_PCI_QUIRK(0x1849, 0x0862, "ASRock K8NF6G-VSTA", ALC861VD_6ST_DIG),
10951 SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_HP),
10955 static struct alc_config_preset alc861vd_presets[] = {
10957 .mixers = { alc861vd_3st_mixer },
10958 .init_verbs = { alc861vd_volume_init_verbs,
10959 alc861vd_3stack_init_verbs },
10960 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
10961 .dac_nids = alc660vd_dac_nids,
10962 .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
10963 .adc_nids = alc861vd_adc_nids,
10964 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
10965 .channel_mode = alc861vd_3stack_2ch_modes,
10966 .input_mux = &alc861vd_capture_source,
10968 [ALC660VD_3ST_DIG] = {
10969 .mixers = { alc861vd_3st_mixer },
10970 .init_verbs = { alc861vd_volume_init_verbs,
10971 alc861vd_3stack_init_verbs },
10972 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
10973 .dac_nids = alc660vd_dac_nids,
10974 .dig_out_nid = ALC861VD_DIGOUT_NID,
10975 .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
10976 .adc_nids = alc861vd_adc_nids,
10977 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
10978 .channel_mode = alc861vd_3stack_2ch_modes,
10979 .input_mux = &alc861vd_capture_source,
10982 .mixers = { alc861vd_3st_mixer },
10983 .init_verbs = { alc861vd_volume_init_verbs,
10984 alc861vd_3stack_init_verbs },
10985 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
10986 .dac_nids = alc861vd_dac_nids,
10987 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
10988 .channel_mode = alc861vd_3stack_2ch_modes,
10989 .input_mux = &alc861vd_capture_source,
10991 [ALC861VD_3ST_DIG] = {
10992 .mixers = { alc861vd_3st_mixer },
10993 .init_verbs = { alc861vd_volume_init_verbs,
10994 alc861vd_3stack_init_verbs },
10995 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
10996 .dac_nids = alc861vd_dac_nids,
10997 .dig_out_nid = ALC861VD_DIGOUT_NID,
10998 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
10999 .channel_mode = alc861vd_3stack_2ch_modes,
11000 .input_mux = &alc861vd_capture_source,
11002 [ALC861VD_6ST_DIG] = {
11003 .mixers = { alc861vd_6st_mixer, alc861vd_chmode_mixer },
11004 .init_verbs = { alc861vd_volume_init_verbs,
11005 alc861vd_6stack_init_verbs },
11006 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
11007 .dac_nids = alc861vd_dac_nids,
11008 .dig_out_nid = ALC861VD_DIGOUT_NID,
11009 .num_channel_mode = ARRAY_SIZE(alc861vd_6stack_modes),
11010 .channel_mode = alc861vd_6stack_modes,
11011 .input_mux = &alc861vd_capture_source,
11013 [ALC861VD_LENOVO] = {
11014 .mixers = { alc861vd_lenovo_mixer },
11015 .init_verbs = { alc861vd_volume_init_verbs,
11016 alc861vd_3stack_init_verbs,
11017 alc861vd_eapd_verbs,
11018 alc861vd_lenovo_unsol_verbs },
11019 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
11020 .dac_nids = alc660vd_dac_nids,
11021 .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
11022 .adc_nids = alc861vd_adc_nids,
11023 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
11024 .channel_mode = alc861vd_3stack_2ch_modes,
11025 .input_mux = &alc861vd_capture_source,
11026 .unsol_event = alc861vd_lenovo_unsol_event,
11027 .init_hook = alc861vd_lenovo_automute,
11029 [ALC861VD_DALLAS] = {
11030 .mixers = { alc861vd_dallas_mixer },
11031 .init_verbs = { alc861vd_dallas_verbs },
11032 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
11033 .dac_nids = alc861vd_dac_nids,
11034 .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
11035 .adc_nids = alc861vd_adc_nids,
11036 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
11037 .channel_mode = alc861vd_3stack_2ch_modes,
11038 .input_mux = &alc861vd_dallas_capture_source,
11039 .unsol_event = alc861vd_dallas_unsol_event,
11040 .init_hook = alc861vd_dallas_automute,
11043 .mixers = { alc861vd_hp_mixer },
11044 .init_verbs = { alc861vd_dallas_verbs, alc861vd_eapd_verbs },
11045 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
11046 .dac_nids = alc861vd_dac_nids,
11047 .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
11048 .dig_out_nid = ALC861VD_DIGOUT_NID,
11049 .adc_nids = alc861vd_adc_nids,
11050 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
11051 .channel_mode = alc861vd_3stack_2ch_modes,
11052 .input_mux = &alc861vd_hp_capture_source,
11053 .unsol_event = alc861vd_dallas_unsol_event,
11054 .init_hook = alc861vd_dallas_automute,
11059 * BIOS auto configuration
11061 static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec,
11062 hda_nid_t nid, int pin_type, int dac_idx)
11064 /* set as output */
11065 snd_hda_codec_write(codec, nid, 0,
11066 AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
11067 snd_hda_codec_write(codec, nid, 0,
11068 AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
11071 static void alc861vd_auto_init_multi_out(struct hda_codec *codec)
11073 struct alc_spec *spec = codec->spec;
11076 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
11077 for (i = 0; i <= HDA_SIDE; i++) {
11078 hda_nid_t nid = spec->autocfg.line_out_pins[i];
11079 int pin_type = get_pin_type(spec->autocfg.line_out_type);
11081 alc861vd_auto_set_output_and_unmute(codec, nid,
11087 static void alc861vd_auto_init_hp_out(struct hda_codec *codec)
11089 struct alc_spec *spec = codec->spec;
11092 pin = spec->autocfg.hp_pins[0];
11093 if (pin) /* connect to front and use dac 0 */
11094 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
11097 #define alc861vd_is_input_pin(nid) alc880_is_input_pin(nid)
11098 #define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID
11100 static void alc861vd_auto_init_analog_input(struct hda_codec *codec)
11102 struct alc_spec *spec = codec->spec;
11105 for (i = 0; i < AUTO_PIN_LAST; i++) {
11106 hda_nid_t nid = spec->autocfg.input_pins[i];
11107 if (alc861vd_is_input_pin(nid)) {
11108 snd_hda_codec_write(codec, nid, 0,
11109 AC_VERB_SET_PIN_WIDGET_CONTROL,
11110 i <= AUTO_PIN_FRONT_MIC ?
11111 PIN_VREF80 : PIN_IN);
11112 if (nid != ALC861VD_PIN_CD_NID)
11113 snd_hda_codec_write(codec, nid, 0,
11114 AC_VERB_SET_AMP_GAIN_MUTE,
11120 #define alc861vd_idx_to_mixer_vol(nid) ((nid) + 0x02)
11121 #define alc861vd_idx_to_mixer_switch(nid) ((nid) + 0x0c)
11123 /* add playback controls from the parsed DAC table */
11124 /* Based on ALC880 version. But ALC861VD has separate,
11125 * different NIDs for mute/unmute switch and volume control */
11126 static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
11127 const struct auto_pin_cfg *cfg)
11130 static const char *chname[4] = {"Front", "Surround", "CLFE", "Side"};
11131 hda_nid_t nid_v, nid_s;
11134 for (i = 0; i < cfg->line_outs; i++) {
11135 if (!spec->multiout.dac_nids[i])
11137 nid_v = alc861vd_idx_to_mixer_vol(
11139 spec->multiout.dac_nids[i]));
11140 nid_s = alc861vd_idx_to_mixer_switch(
11142 spec->multiout.dac_nids[i]));
11146 err = add_control(spec, ALC_CTL_WIDGET_VOL,
11147 "Center Playback Volume",
11148 HDA_COMPOSE_AMP_VAL(nid_v, 1, 0,
11152 err = add_control(spec, ALC_CTL_WIDGET_VOL,
11153 "LFE Playback Volume",
11154 HDA_COMPOSE_AMP_VAL(nid_v, 2, 0,
11158 err = add_control(spec, ALC_CTL_BIND_MUTE,
11159 "Center Playback Switch",
11160 HDA_COMPOSE_AMP_VAL(nid_s, 1, 2,
11164 err = add_control(spec, ALC_CTL_BIND_MUTE,
11165 "LFE Playback Switch",
11166 HDA_COMPOSE_AMP_VAL(nid_s, 2, 2,
11171 sprintf(name, "%s Playback Volume", chname[i]);
11172 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
11173 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0,
11177 sprintf(name, "%s Playback Switch", chname[i]);
11178 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
11179 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2,
11188 /* add playback controls for speaker and HP outputs */
11189 /* Based on ALC880 version. But ALC861VD has separate,
11190 * different NIDs for mute/unmute switch and volume control */
11191 static int alc861vd_auto_create_extra_out(struct alc_spec *spec,
11192 hda_nid_t pin, const char *pfx)
11194 hda_nid_t nid_v, nid_s;
11201 if (alc880_is_fixed_pin(pin)) {
11202 nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
11203 /* specify the DAC as the extra output */
11204 if (!spec->multiout.hp_nid)
11205 spec->multiout.hp_nid = nid_v;
11207 spec->multiout.extra_out_nid[0] = nid_v;
11208 /* control HP volume/switch on the output mixer amp */
11209 nid_v = alc861vd_idx_to_mixer_vol(
11210 alc880_fixed_pin_idx(pin));
11211 nid_s = alc861vd_idx_to_mixer_switch(
11212 alc880_fixed_pin_idx(pin));
11214 sprintf(name, "%s Playback Volume", pfx);
11215 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
11216 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT));
11219 sprintf(name, "%s Playback Switch", pfx);
11220 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
11221 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT));
11224 } else if (alc880_is_multi_pin(pin)) {
11225 /* set manual connection */
11226 /* we have only a switch on HP-out PIN */
11227 sprintf(name, "%s Playback Switch", pfx);
11228 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
11229 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
11236 /* parse the BIOS configuration and set up the alc_spec
11237 * return 1 if successful, 0 if the proper config is not found,
11238 * or a negative error code
11239 * Based on ALC880 version - had to change it to override
11240 * alc880_auto_create_extra_out and alc880_auto_create_multi_out_ctls */
11241 static int alc861vd_parse_auto_config(struct hda_codec *codec)
11243 struct alc_spec *spec = codec->spec;
11245 static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
11247 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
11251 if (!spec->autocfg.line_outs)
11252 return 0; /* can't find valid BIOS pin config */
11254 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
11257 err = alc861vd_auto_create_multi_out_ctls(spec, &spec->autocfg);
11260 err = alc861vd_auto_create_extra_out(spec,
11261 spec->autocfg.speaker_pins[0],
11265 err = alc861vd_auto_create_extra_out(spec,
11266 spec->autocfg.hp_pins[0],
11270 err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
11274 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
11276 if (spec->autocfg.dig_out_pin)
11277 spec->multiout.dig_out_nid = ALC861VD_DIGOUT_NID;
11279 if (spec->kctl_alloc)
11280 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
11282 spec->init_verbs[spec->num_init_verbs++]
11283 = alc861vd_volume_init_verbs;
11285 spec->num_mux_defs = 1;
11286 spec->input_mux = &spec->private_imux;
11288 err = alc_auto_add_mic_boost(codec);
11295 /* additional initialization for auto-configuration model */
11296 static void alc861vd_auto_init(struct hda_codec *codec)
11298 alc861vd_auto_init_multi_out(codec);
11299 alc861vd_auto_init_hp_out(codec);
11300 alc861vd_auto_init_analog_input(codec);
11303 static int patch_alc861vd(struct hda_codec *codec)
11305 struct alc_spec *spec;
11306 int err, board_config;
11308 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
11312 codec->spec = spec;
11314 board_config = snd_hda_check_board_config(codec, ALC861VD_MODEL_LAST,
11318 if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) {
11319 printk(KERN_INFO "hda_codec: Unknown model for ALC660VD/"
11320 "ALC861VD, trying auto-probe from BIOS...\n");
11321 board_config = ALC861VD_AUTO;
11324 if (board_config == ALC861VD_AUTO) {
11325 /* automatic parse from the BIOS config */
11326 err = alc861vd_parse_auto_config(codec);
11332 "hda_codec: Cannot set up configuration "
11333 "from BIOS. Using base mode...\n");
11334 board_config = ALC861VD_3ST;
11338 if (board_config != ALC861VD_AUTO)
11339 setup_preset(spec, &alc861vd_presets[board_config]);
11341 spec->stream_name_analog = "ALC861VD Analog";
11342 spec->stream_analog_playback = &alc861vd_pcm_analog_playback;
11343 spec->stream_analog_capture = &alc861vd_pcm_analog_capture;
11345 spec->stream_name_digital = "ALC861VD Digital";
11346 spec->stream_digital_playback = &alc861vd_pcm_digital_playback;
11347 spec->stream_digital_capture = &alc861vd_pcm_digital_capture;
11349 spec->adc_nids = alc861vd_adc_nids;
11350 spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids);
11352 spec->mixers[spec->num_mixers] = alc861vd_capture_mixer;
11353 spec->num_mixers++;
11355 codec->patch_ops = alc_patch_ops;
11357 if (board_config == ALC861VD_AUTO)
11358 spec->init_hook = alc861vd_auto_init;
11359 #ifdef CONFIG_SND_HDA_POWER_SAVE
11360 if (!spec->loopback.amplist)
11361 spec->loopback.amplist = alc861vd_loopbacks;
11370 * ALC662 is almost identical with ALC880 but has cleaner and more flexible
11371 * configuration. Each pin widget can choose any input DACs and a mixer.
11372 * Each ADC is connected from a mixer of all inputs. This makes possible
11373 * 6-channel independent captures.
11375 * In addition, an independent DAC for the multi-playback (not used in this
11378 #define ALC662_DIGOUT_NID 0x06
11379 #define ALC662_DIGIN_NID 0x0a
11381 static hda_nid_t alc662_dac_nids[4] = {
11382 /* front, rear, clfe, rear_surr */
11386 static hda_nid_t alc662_adc_nids[1] = {
11391 /* FIXME: should be a matrix-type input source selection */
11393 static struct hda_input_mux alc662_capture_source = {
11397 { "Front Mic", 0x1 },
11403 static struct hda_input_mux alc662_lenovo_101e_capture_source = {
11410 #define alc662_mux_enum_info alc_mux_enum_info
11411 #define alc662_mux_enum_get alc_mux_enum_get
11413 static int alc662_mux_enum_put(struct snd_kcontrol *kcontrol,
11414 struct snd_ctl_elem_value *ucontrol)
11416 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
11417 struct alc_spec *spec = codec->spec;
11418 const struct hda_input_mux *imux = spec->input_mux;
11419 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
11420 static hda_nid_t capture_mixers[2] = { 0x23, 0x22 };
11421 hda_nid_t nid = capture_mixers[adc_idx];
11422 unsigned int *cur_val = &spec->cur_mux[adc_idx];
11423 unsigned int i, idx;
11425 idx = ucontrol->value.enumerated.item[0];
11426 if (idx >= imux->num_items)
11427 idx = imux->num_items - 1;
11428 if (*cur_val == idx)
11430 for (i = 0; i < imux->num_items; i++) {
11431 unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
11432 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
11433 imux->items[i].index,
11442 static struct hda_channel_mode alc662_3ST_2ch_modes[1] = {
11449 static struct hda_verb alc662_3ST_ch2_init[] = {
11450 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
11451 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
11452 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
11453 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
11460 static struct hda_verb alc662_3ST_ch6_init[] = {
11461 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11462 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
11463 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
11464 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11465 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
11466 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
11470 static struct hda_channel_mode alc662_3ST_6ch_modes[2] = {
11471 { 2, alc662_3ST_ch2_init },
11472 { 6, alc662_3ST_ch6_init },
11478 static struct hda_verb alc662_sixstack_ch6_init[] = {
11479 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
11480 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
11481 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11488 static struct hda_verb alc662_sixstack_ch8_init[] = {
11489 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11490 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11491 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11495 static struct hda_channel_mode alc662_5stack_modes[2] = {
11496 { 2, alc662_sixstack_ch6_init },
11497 { 6, alc662_sixstack_ch8_init },
11500 /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
11501 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
11504 static struct snd_kcontrol_new alc662_base_mixer[] = {
11505 /* output mixer control */
11506 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
11507 HDA_CODEC_MUTE("Front Playback Switch", 0x02, 0x0, HDA_OUTPUT),
11508 HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT),
11509 HDA_CODEC_MUTE("Surround Playback Switch", 0x03, 0x0, HDA_OUTPUT),
11510 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
11511 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
11512 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT),
11513 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT),
11514 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
11516 /*Input mixer control */
11517 HDA_CODEC_VOLUME("CD Playback Volume", 0xb, 0x4, HDA_INPUT),
11518 HDA_CODEC_MUTE("CD Playback Switch", 0xb, 0x4, HDA_INPUT),
11519 HDA_CODEC_VOLUME("Line Playback Volume", 0xb, 0x02, HDA_INPUT),
11520 HDA_CODEC_MUTE("Line Playback Switch", 0xb, 0x02, HDA_INPUT),
11521 HDA_CODEC_VOLUME("Mic Playback Volume", 0xb, 0x0, HDA_INPUT),
11522 HDA_CODEC_MUTE("Mic Playback Switch", 0xb, 0x0, HDA_INPUT),
11523 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0xb, 0x01, HDA_INPUT),
11524 HDA_CODEC_MUTE("Front Mic Playback Switch", 0xb, 0x01, HDA_INPUT),
11526 /* Capture mixer control */
11527 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
11528 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
11530 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11531 .name = "Capture Source",
11533 .info = alc_mux_enum_info,
11534 .get = alc_mux_enum_get,
11535 .put = alc_mux_enum_put,
11540 static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = {
11541 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
11542 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
11543 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
11544 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11545 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
11546 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
11547 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
11548 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11549 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11550 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
11551 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
11552 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
11553 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
11554 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
11555 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
11557 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11558 /* .name = "Capture Source", */
11559 .name = "Input Source",
11561 .info = alc662_mux_enum_info,
11562 .get = alc662_mux_enum_get,
11563 .put = alc662_mux_enum_put,
11568 static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = {
11569 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
11570 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
11571 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
11572 HDA_BIND_MUTE("Surround Playback Switch", 0x03, 2, HDA_INPUT),
11573 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
11574 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
11575 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT),
11576 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT),
11577 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
11578 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11579 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
11580 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
11581 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
11582 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11583 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11584 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
11585 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
11586 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
11587 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
11588 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
11589 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
11591 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11592 /* .name = "Capture Source", */
11593 .name = "Input Source",
11595 .info = alc662_mux_enum_info,
11596 .get = alc662_mux_enum_get,
11597 .put = alc662_mux_enum_put,
11602 static struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = {
11603 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
11604 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
11605 HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x03, 0x0, HDA_OUTPUT),
11606 HDA_BIND_MUTE("iSpeaker Playback Switch", 0x03, 2, HDA_INPUT),
11607 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
11608 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
11609 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
11610 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
11611 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
11612 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
11613 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
11615 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11616 /* .name = "Capture Source", */
11617 .name = "Input Source",
11619 .info = alc662_mux_enum_info,
11620 .get = alc662_mux_enum_get,
11621 .put = alc662_mux_enum_put,
11626 static struct snd_kcontrol_new alc662_chmode_mixer[] = {
11628 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11629 .name = "Channel Mode",
11630 .info = alc_ch_mode_info,
11631 .get = alc_ch_mode_get,
11632 .put = alc_ch_mode_put,
11637 static struct hda_verb alc662_init_verbs[] = {
11638 /* ADC: mute amp left and right */
11639 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11640 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
11641 /* Front mixer: unmute input/output amp left and right (volume = 0) */
11643 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11644 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11645 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11646 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11647 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
11649 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11650 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11651 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11652 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11653 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11654 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11656 /* Front Pin: output 0 (0x0c) */
11657 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11658 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11660 /* Rear Pin: output 1 (0x0d) */
11661 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11662 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11664 /* CLFE Pin: output 2 (0x0e) */
11665 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11666 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11668 /* Mic (rear) pin: input vref at 80% */
11669 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
11670 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11671 /* Front Mic pin: input vref at 80% */
11672 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
11673 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11674 /* Line In pin: input */
11675 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11676 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11677 /* Line-2 In: Headphone output (output 0 - 0x0c) */
11678 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11679 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11680 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
11681 /* CD pin widget for input */
11682 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11684 /* FIXME: use matrix-type input source selection */
11685 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
11687 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11688 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11689 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
11690 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
11694 static struct hda_verb alc662_sue_init_verbs[] = {
11695 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
11696 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
11701 * generic initialization of ADC, input mixers and output mixers
11703 static struct hda_verb alc662_auto_init_verbs[] = {
11705 * Unmute ADC and set the default input to mic-in
11707 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
11708 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11710 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
11712 * Note: PASD motherboards uses the Line In 2 as the input for front
11713 * panel mic (mic 2)
11715 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
11716 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11717 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11718 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11719 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11720 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
11723 * Set up output mixers (0x0c - 0x0f)
11725 /* set vol=0 to output mixers */
11726 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11727 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11728 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11730 /* set up input amps for analog loopback */
11731 /* Amp Indices: DAC = 0, mixer = 1 */
11732 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11733 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11734 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11735 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11736 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11737 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11740 /* FIXME: use matrix-type input source selection */
11741 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
11743 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11744 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11748 /* capture mixer elements */
11749 static struct snd_kcontrol_new alc662_capture_mixer[] = {
11750 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
11751 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
11753 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11754 /* The multiple "Capture Source" controls confuse alsamixer
11755 * So call somewhat different..
11756 * FIXME: the controls appear in the "playback" view!
11758 /* .name = "Capture Source", */
11759 .name = "Input Source",
11761 .info = alc882_mux_enum_info,
11762 .get = alc882_mux_enum_get,
11763 .put = alc882_mux_enum_put,
11768 static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
11770 unsigned int present;
11771 unsigned char bits;
11773 present = snd_hda_codec_read(codec, 0x14, 0,
11774 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
11775 bits = present ? HDA_AMP_MUTE : 0;
11776 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
11777 HDA_AMP_MUTE, bits);
11780 static void alc662_lenovo_101e_all_automute(struct hda_codec *codec)
11782 unsigned int present;
11783 unsigned char bits;
11785 present = snd_hda_codec_read(codec, 0x1b, 0,
11786 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
11787 bits = present ? HDA_AMP_MUTE : 0;
11788 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
11789 HDA_AMP_MUTE, bits);
11790 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
11791 HDA_AMP_MUTE, bits);
11794 static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec,
11797 if ((res >> 26) == ALC880_HP_EVENT)
11798 alc662_lenovo_101e_all_automute(codec);
11799 if ((res >> 26) == ALC880_FRONT_EVENT)
11800 alc662_lenovo_101e_ispeaker_automute(codec);
11803 #ifdef CONFIG_SND_HDA_POWER_SAVE
11804 #define alc662_loopbacks alc880_loopbacks
11808 /* pcm configuration: identiacal with ALC880 */
11809 #define alc662_pcm_analog_playback alc880_pcm_analog_playback
11810 #define alc662_pcm_analog_capture alc880_pcm_analog_capture
11811 #define alc662_pcm_digital_playback alc880_pcm_digital_playback
11812 #define alc662_pcm_digital_capture alc880_pcm_digital_capture
11815 * configuration and preset
11817 static const char *alc662_models[ALC662_MODEL_LAST] = {
11818 [ALC662_3ST_2ch_DIG] = "3stack-dig",
11819 [ALC662_3ST_6ch_DIG] = "3stack-6ch-dig",
11820 [ALC662_3ST_6ch] = "3stack-6ch",
11821 [ALC662_5ST_DIG] = "6stack-dig",
11822 [ALC662_LENOVO_101E] = "lenovo-101e",
11823 [ALC662_AUTO] = "auto",
11826 static struct snd_pci_quirk alc662_cfg_tbl[] = {
11827 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E),
11831 static struct alc_config_preset alc662_presets[] = {
11832 [ALC662_3ST_2ch_DIG] = {
11833 .mixers = { alc662_3ST_2ch_mixer },
11834 .init_verbs = { alc662_init_verbs },
11835 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
11836 .dac_nids = alc662_dac_nids,
11837 .dig_out_nid = ALC662_DIGOUT_NID,
11838 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
11839 .adc_nids = alc662_adc_nids,
11840 .dig_in_nid = ALC662_DIGIN_NID,
11841 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
11842 .channel_mode = alc662_3ST_2ch_modes,
11843 .input_mux = &alc662_capture_source,
11845 [ALC662_3ST_6ch_DIG] = {
11846 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
11847 .init_verbs = { alc662_init_verbs },
11848 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
11849 .dac_nids = alc662_dac_nids,
11850 .dig_out_nid = ALC662_DIGOUT_NID,
11851 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
11852 .adc_nids = alc662_adc_nids,
11853 .dig_in_nid = ALC662_DIGIN_NID,
11854 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
11855 .channel_mode = alc662_3ST_6ch_modes,
11857 .input_mux = &alc662_capture_source,
11859 [ALC662_3ST_6ch] = {
11860 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
11861 .init_verbs = { alc662_init_verbs },
11862 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
11863 .dac_nids = alc662_dac_nids,
11864 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
11865 .adc_nids = alc662_adc_nids,
11866 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
11867 .channel_mode = alc662_3ST_6ch_modes,
11869 .input_mux = &alc662_capture_source,
11871 [ALC662_5ST_DIG] = {
11872 .mixers = { alc662_base_mixer, alc662_chmode_mixer },
11873 .init_verbs = { alc662_init_verbs },
11874 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
11875 .dac_nids = alc662_dac_nids,
11876 .dig_out_nid = ALC662_DIGOUT_NID,
11877 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
11878 .adc_nids = alc662_adc_nids,
11879 .dig_in_nid = ALC662_DIGIN_NID,
11880 .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes),
11881 .channel_mode = alc662_5stack_modes,
11882 .input_mux = &alc662_capture_source,
11884 [ALC662_LENOVO_101E] = {
11885 .mixers = { alc662_lenovo_101e_mixer },
11886 .init_verbs = { alc662_init_verbs, alc662_sue_init_verbs },
11887 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
11888 .dac_nids = alc662_dac_nids,
11889 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
11890 .adc_nids = alc662_adc_nids,
11891 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
11892 .channel_mode = alc662_3ST_2ch_modes,
11893 .input_mux = &alc662_lenovo_101e_capture_source,
11894 .unsol_event = alc662_lenovo_101e_unsol_event,
11895 .init_hook = alc662_lenovo_101e_all_automute,
11902 * BIOS auto configuration
11905 /* add playback controls from the parsed DAC table */
11906 static int alc662_auto_create_multi_out_ctls(struct alc_spec *spec,
11907 const struct auto_pin_cfg *cfg)
11910 static const char *chname[4] = {
11911 "Front", "Surround", NULL /*CLFE*/, "Side"
11916 for (i = 0; i < cfg->line_outs; i++) {
11917 if (!spec->multiout.dac_nids[i])
11919 nid = alc880_idx_to_mixer(i);
11922 err = add_control(spec, ALC_CTL_WIDGET_VOL,
11923 "Center Playback Volume",
11924 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
11928 err = add_control(spec, ALC_CTL_WIDGET_VOL,
11929 "LFE Playback Volume",
11930 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
11934 err = add_control(spec, ALC_CTL_BIND_MUTE,
11935 "Center Playback Switch",
11936 HDA_COMPOSE_AMP_VAL(nid, 1, 2,
11940 err = add_control(spec, ALC_CTL_BIND_MUTE,
11941 "LFE Playback Switch",
11942 HDA_COMPOSE_AMP_VAL(nid, 2, 2,
11947 sprintf(name, "%s Playback Volume", chname[i]);
11948 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
11949 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
11953 sprintf(name, "%s Playback Switch", chname[i]);
11954 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
11955 HDA_COMPOSE_AMP_VAL(nid, 3, 2,
11964 /* add playback controls for speaker and HP outputs */
11965 static int alc662_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
11975 if (alc880_is_fixed_pin(pin)) {
11976 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
11977 /* printk("DAC nid=%x\n",nid); */
11978 /* specify the DAC as the extra output */
11979 if (!spec->multiout.hp_nid)
11980 spec->multiout.hp_nid = nid;
11982 spec->multiout.extra_out_nid[0] = nid;
11983 /* control HP volume/switch on the output mixer amp */
11984 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
11985 sprintf(name, "%s Playback Volume", pfx);
11986 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
11987 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
11990 sprintf(name, "%s Playback Switch", pfx);
11991 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
11992 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
11995 } else if (alc880_is_multi_pin(pin)) {
11996 /* set manual connection */
11997 /* we have only a switch on HP-out PIN */
11998 sprintf(name, "%s Playback Switch", pfx);
11999 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
12000 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
12007 /* create playback/capture controls for input pins */
12008 static int alc662_auto_create_analog_input_ctls(struct alc_spec *spec,
12009 const struct auto_pin_cfg *cfg)
12011 struct hda_input_mux *imux = &spec->private_imux;
12014 for (i = 0; i < AUTO_PIN_LAST; i++) {
12015 if (alc880_is_input_pin(cfg->input_pins[i])) {
12016 idx = alc880_input_pin_idx(cfg->input_pins[i]);
12017 err = new_analog_input(spec, cfg->input_pins[i],
12018 auto_pin_cfg_labels[i],
12022 imux->items[imux->num_items].label =
12023 auto_pin_cfg_labels[i];
12024 imux->items[imux->num_items].index =
12025 alc880_input_pin_idx(cfg->input_pins[i]);
12032 static void alc662_auto_set_output_and_unmute(struct hda_codec *codec,
12033 hda_nid_t nid, int pin_type,
12036 /* set as output */
12037 snd_hda_codec_write(codec, nid, 0,
12038 AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
12039 snd_hda_codec_write(codec, nid, 0,
12040 AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
12041 /* need the manual connection? */
12042 if (alc880_is_multi_pin(nid)) {
12043 struct alc_spec *spec = codec->spec;
12044 int idx = alc880_multi_pin_idx(nid);
12045 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
12046 AC_VERB_SET_CONNECT_SEL,
12047 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
12051 static void alc662_auto_init_multi_out(struct hda_codec *codec)
12053 struct alc_spec *spec = codec->spec;
12056 for (i = 0; i <= HDA_SIDE; i++) {
12057 hda_nid_t nid = spec->autocfg.line_out_pins[i];
12058 int pin_type = get_pin_type(spec->autocfg.line_out_type);
12060 alc662_auto_set_output_and_unmute(codec, nid, pin_type,
12065 static void alc662_auto_init_hp_out(struct hda_codec *codec)
12067 struct alc_spec *spec = codec->spec;
12070 pin = spec->autocfg.hp_pins[0];
12071 if (pin) /* connect to front */
12073 alc662_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
12076 #define alc662_is_input_pin(nid) alc880_is_input_pin(nid)
12077 #define ALC662_PIN_CD_NID ALC880_PIN_CD_NID
12079 static void alc662_auto_init_analog_input(struct hda_codec *codec)
12081 struct alc_spec *spec = codec->spec;
12084 for (i = 0; i < AUTO_PIN_LAST; i++) {
12085 hda_nid_t nid = spec->autocfg.input_pins[i];
12086 if (alc662_is_input_pin(nid)) {
12087 snd_hda_codec_write(codec, nid, 0,
12088 AC_VERB_SET_PIN_WIDGET_CONTROL,
12089 (i <= AUTO_PIN_FRONT_MIC ?
12090 PIN_VREF80 : PIN_IN));
12091 if (nid != ALC662_PIN_CD_NID)
12092 snd_hda_codec_write(codec, nid, 0,
12093 AC_VERB_SET_AMP_GAIN_MUTE,
12099 static int alc662_parse_auto_config(struct hda_codec *codec)
12101 struct alc_spec *spec = codec->spec;
12103 static hda_nid_t alc662_ignore[] = { 0x1d, 0 };
12105 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
12109 if (!spec->autocfg.line_outs)
12110 return 0; /* can't find valid BIOS pin config */
12112 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
12115 err = alc662_auto_create_multi_out_ctls(spec, &spec->autocfg);
12118 err = alc662_auto_create_extra_out(spec,
12119 spec->autocfg.speaker_pins[0],
12123 err = alc662_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
12127 err = alc662_auto_create_analog_input_ctls(spec, &spec->autocfg);
12131 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
12133 if (spec->autocfg.dig_out_pin)
12134 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
12136 if (spec->kctl_alloc)
12137 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
12139 spec->num_mux_defs = 1;
12140 spec->input_mux = &spec->private_imux;
12142 spec->init_verbs[spec->num_init_verbs++] = alc662_auto_init_verbs;
12143 spec->mixers[spec->num_mixers] = alc662_capture_mixer;
12144 spec->num_mixers++;
12148 /* additional initialization for auto-configuration model */
12149 static void alc662_auto_init(struct hda_codec *codec)
12151 alc662_auto_init_multi_out(codec);
12152 alc662_auto_init_hp_out(codec);
12153 alc662_auto_init_analog_input(codec);
12156 static int patch_alc662(struct hda_codec *codec)
12158 struct alc_spec *spec;
12159 int err, board_config;
12161 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
12165 codec->spec = spec;
12167 board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST,
12170 if (board_config < 0) {
12171 printk(KERN_INFO "hda_codec: Unknown model for ALC662, "
12172 "trying auto-probe from BIOS...\n");
12173 board_config = ALC662_AUTO;
12176 if (board_config == ALC662_AUTO) {
12177 /* automatic parse from the BIOS config */
12178 err = alc662_parse_auto_config(codec);
12184 "hda_codec: Cannot set up configuration "
12185 "from BIOS. Using base mode...\n");
12186 board_config = ALC662_3ST_2ch_DIG;
12190 if (board_config != ALC662_AUTO)
12191 setup_preset(spec, &alc662_presets[board_config]);
12193 spec->stream_name_analog = "ALC662 Analog";
12194 spec->stream_analog_playback = &alc662_pcm_analog_playback;
12195 spec->stream_analog_capture = &alc662_pcm_analog_capture;
12197 spec->stream_name_digital = "ALC662 Digital";
12198 spec->stream_digital_playback = &alc662_pcm_digital_playback;
12199 spec->stream_digital_capture = &alc662_pcm_digital_capture;
12201 if (!spec->adc_nids && spec->input_mux) {
12202 spec->adc_nids = alc662_adc_nids;
12203 spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids);
12206 codec->patch_ops = alc_patch_ops;
12207 if (board_config == ALC662_AUTO)
12208 spec->init_hook = alc662_auto_init;
12209 #ifdef CONFIG_SND_HDA_POWER_SAVE
12210 if (!spec->loopback.amplist)
12211 spec->loopback.amplist = alc662_loopbacks;
12220 struct hda_codec_preset snd_hda_preset_realtek[] = {
12221 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
12222 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
12223 { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 },
12224 { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
12225 .patch = patch_alc861 },
12226 { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
12227 { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
12228 { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
12229 { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2",
12230 .patch = patch_alc883 },
12231 { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
12232 .patch = patch_alc662 },
12233 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
12234 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
12235 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc883 },
12236 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
12237 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc883 },
12238 {} /* terminator */