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 */
172 ALC883_TARGA_2ch_DIG,
178 ALC883_LENOVO_101E_2ch,
179 ALC883_LENOVO_NB0763,
180 ALC888_LENOVO_MS7195_DIG,
189 #define GPIO_MASK 0x03
192 /* codec parameterization */
193 struct snd_kcontrol_new *mixers[5]; /* mixer arrays */
194 unsigned int num_mixers;
196 const struct hda_verb *init_verbs[5]; /* initialization verbs
200 unsigned int num_init_verbs;
202 char *stream_name_analog; /* analog PCM stream */
203 struct hda_pcm_stream *stream_analog_playback;
204 struct hda_pcm_stream *stream_analog_capture;
206 char *stream_name_digital; /* digital PCM stream */
207 struct hda_pcm_stream *stream_digital_playback;
208 struct hda_pcm_stream *stream_digital_capture;
211 struct hda_multi_out multiout; /* playback set-up
212 * max_channels, dacs must be set
213 * dig_out_nid and hp_nid are optional
217 unsigned int num_adc_nids;
219 hda_nid_t dig_in_nid; /* digital-in NID; optional */
222 unsigned int num_mux_defs;
223 const struct hda_input_mux *input_mux;
224 unsigned int cur_mux[3];
227 const struct hda_channel_mode *channel_mode;
228 int num_channel_mode;
231 /* PCM information */
232 struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */
234 /* dynamic controls, init_verbs and input_mux */
235 struct auto_pin_cfg autocfg;
236 unsigned int num_kctl_alloc, num_kctl_used;
237 struct snd_kcontrol_new *kctl_alloc;
238 struct hda_input_mux private_imux;
239 hda_nid_t private_dac_nids[5];
242 void (*init_hook)(struct hda_codec *codec);
243 void (*unsol_event)(struct hda_codec *codec, unsigned int res);
245 /* for pin sensing */
246 unsigned int sense_updated: 1;
247 unsigned int jack_present: 1;
249 #ifdef CONFIG_SND_HDA_POWER_SAVE
250 struct hda_loopback_check loopback;
255 * configuration template - to be copied to the spec instance
257 struct alc_config_preset {
258 struct snd_kcontrol_new *mixers[5]; /* should be identical size
261 const struct hda_verb *init_verbs[5];
262 unsigned int num_dacs;
264 hda_nid_t dig_out_nid; /* optional */
265 hda_nid_t hp_nid; /* optional */
266 unsigned int num_adc_nids;
268 hda_nid_t dig_in_nid;
269 unsigned int num_channel_mode;
270 const struct hda_channel_mode *channel_mode;
272 unsigned int num_mux_defs;
273 const struct hda_input_mux *input_mux;
274 void (*unsol_event)(struct hda_codec *, unsigned int);
275 void (*init_hook)(struct hda_codec *);
276 #ifdef CONFIG_SND_HDA_POWER_SAVE
277 struct hda_amp_list *loopbacks;
285 static int alc_mux_enum_info(struct snd_kcontrol *kcontrol,
286 struct snd_ctl_elem_info *uinfo)
288 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
289 struct alc_spec *spec = codec->spec;
290 unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id);
291 if (mux_idx >= spec->num_mux_defs)
293 return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo);
296 static int alc_mux_enum_get(struct snd_kcontrol *kcontrol,
297 struct snd_ctl_elem_value *ucontrol)
299 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
300 struct alc_spec *spec = codec->spec;
301 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
303 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
307 static int alc_mux_enum_put(struct snd_kcontrol *kcontrol,
308 struct snd_ctl_elem_value *ucontrol)
310 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
311 struct alc_spec *spec = codec->spec;
312 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
313 unsigned int mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx;
314 return snd_hda_input_mux_put(codec, &spec->input_mux[mux_idx], ucontrol,
315 spec->adc_nids[adc_idx],
316 &spec->cur_mux[adc_idx]);
321 * channel mode setting
323 static int alc_ch_mode_info(struct snd_kcontrol *kcontrol,
324 struct snd_ctl_elem_info *uinfo)
326 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
327 struct alc_spec *spec = codec->spec;
328 return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
329 spec->num_channel_mode);
332 static int alc_ch_mode_get(struct snd_kcontrol *kcontrol,
333 struct snd_ctl_elem_value *ucontrol)
335 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
336 struct alc_spec *spec = codec->spec;
337 return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
338 spec->num_channel_mode,
339 spec->multiout.max_channels);
342 static int alc_ch_mode_put(struct snd_kcontrol *kcontrol,
343 struct snd_ctl_elem_value *ucontrol)
345 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
346 struct alc_spec *spec = codec->spec;
347 int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
348 spec->num_channel_mode,
349 &spec->multiout.max_channels);
350 if (err >= 0 && spec->need_dac_fix)
351 spec->multiout.num_dacs = spec->multiout.max_channels / 2;
356 * Control the mode of pin widget settings via the mixer. "pc" is used
357 * instead of "%" to avoid consequences of accidently treating the % as
358 * being part of a format specifier. Maximum allowed length of a value is
359 * 63 characters plus NULL terminator.
361 * Note: some retasking pin complexes seem to ignore requests for input
362 * states other than HiZ (eg: PIN_VREFxx) and revert to HiZ if any of these
363 * are requested. Therefore order this list so that this behaviour will not
364 * cause problems when mixer clients move through the enum sequentially.
365 * NIDs 0x0f and 0x10 have been observed to have this behaviour as of
368 static char *alc_pin_mode_names[] = {
369 "Mic 50pc bias", "Mic 80pc bias",
370 "Line in", "Line out", "Headphone out",
372 static unsigned char alc_pin_mode_values[] = {
373 PIN_VREF50, PIN_VREF80, PIN_IN, PIN_OUT, PIN_HP,
375 /* The control can present all 5 options, or it can limit the options based
376 * in the pin being assumed to be exclusively an input or an output pin. In
377 * addition, "input" pins may or may not process the mic bias option
378 * depending on actual widget capability (NIDs 0x0f and 0x10 don't seem to
379 * accept requests for bias as of chip versions up to March 2006) and/or
380 * wiring in the computer.
382 #define ALC_PIN_DIR_IN 0x00
383 #define ALC_PIN_DIR_OUT 0x01
384 #define ALC_PIN_DIR_INOUT 0x02
385 #define ALC_PIN_DIR_IN_NOMICBIAS 0x03
386 #define ALC_PIN_DIR_INOUT_NOMICBIAS 0x04
388 /* Info about the pin modes supported by the different pin direction modes.
389 * For each direction the minimum and maximum values are given.
391 static signed char alc_pin_mode_dir_info[5][2] = {
392 { 0, 2 }, /* ALC_PIN_DIR_IN */
393 { 3, 4 }, /* ALC_PIN_DIR_OUT */
394 { 0, 4 }, /* ALC_PIN_DIR_INOUT */
395 { 2, 2 }, /* ALC_PIN_DIR_IN_NOMICBIAS */
396 { 2, 4 }, /* ALC_PIN_DIR_INOUT_NOMICBIAS */
398 #define alc_pin_mode_min(_dir) (alc_pin_mode_dir_info[_dir][0])
399 #define alc_pin_mode_max(_dir) (alc_pin_mode_dir_info[_dir][1])
400 #define alc_pin_mode_n_items(_dir) \
401 (alc_pin_mode_max(_dir)-alc_pin_mode_min(_dir)+1)
403 static int alc_pin_mode_info(struct snd_kcontrol *kcontrol,
404 struct snd_ctl_elem_info *uinfo)
406 unsigned int item_num = uinfo->value.enumerated.item;
407 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
409 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
411 uinfo->value.enumerated.items = alc_pin_mode_n_items(dir);
413 if (item_num<alc_pin_mode_min(dir) || item_num>alc_pin_mode_max(dir))
414 item_num = alc_pin_mode_min(dir);
415 strcpy(uinfo->value.enumerated.name, alc_pin_mode_names[item_num]);
419 static int alc_pin_mode_get(struct snd_kcontrol *kcontrol,
420 struct snd_ctl_elem_value *ucontrol)
423 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
424 hda_nid_t nid = kcontrol->private_value & 0xffff;
425 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
426 long *valp = ucontrol->value.integer.value;
427 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
428 AC_VERB_GET_PIN_WIDGET_CONTROL,
431 /* Find enumerated value for current pinctl setting */
432 i = alc_pin_mode_min(dir);
433 while (alc_pin_mode_values[i] != pinctl && i <= alc_pin_mode_max(dir))
435 *valp = i <= alc_pin_mode_max(dir) ? i: alc_pin_mode_min(dir);
439 static int alc_pin_mode_put(struct snd_kcontrol *kcontrol,
440 struct snd_ctl_elem_value *ucontrol)
443 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
444 hda_nid_t nid = kcontrol->private_value & 0xffff;
445 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
446 long val = *ucontrol->value.integer.value;
447 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
448 AC_VERB_GET_PIN_WIDGET_CONTROL,
451 if (val < alc_pin_mode_min(dir) || val > alc_pin_mode_max(dir))
452 val = alc_pin_mode_min(dir);
454 change = pinctl != alc_pin_mode_values[val];
456 /* Set pin mode to that requested */
457 snd_hda_codec_write_cache(codec, nid, 0,
458 AC_VERB_SET_PIN_WIDGET_CONTROL,
459 alc_pin_mode_values[val]);
461 /* Also enable the retasking pin's input/output as required
462 * for the requested pin mode. Enum values of 2 or less are
465 * Dynamically switching the input/output buffers probably
466 * reduces noise slightly (particularly on input) so we'll
467 * do it. However, having both input and output buffers
468 * enabled simultaneously doesn't seem to be problematic if
469 * this turns out to be necessary in the future.
472 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
473 HDA_AMP_MUTE, HDA_AMP_MUTE);
474 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
477 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
478 HDA_AMP_MUTE, HDA_AMP_MUTE);
479 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
486 #define ALC_PIN_MODE(xname, nid, dir) \
487 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
488 .info = alc_pin_mode_info, \
489 .get = alc_pin_mode_get, \
490 .put = alc_pin_mode_put, \
491 .private_value = nid | (dir<<16) }
493 /* A switch control for ALC260 GPIO pins. Multiple GPIOs can be ganged
494 * together using a mask with more than one bit set. This control is
495 * currently used only by the ALC260 test model. At this stage they are not
496 * needed for any "production" models.
498 #ifdef CONFIG_SND_DEBUG
499 #define alc_gpio_data_info snd_ctl_boolean_mono_info
501 static int alc_gpio_data_get(struct snd_kcontrol *kcontrol,
502 struct snd_ctl_elem_value *ucontrol)
504 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
505 hda_nid_t nid = kcontrol->private_value & 0xffff;
506 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
507 long *valp = ucontrol->value.integer.value;
508 unsigned int val = snd_hda_codec_read(codec, nid, 0,
509 AC_VERB_GET_GPIO_DATA, 0x00);
511 *valp = (val & mask) != 0;
514 static int alc_gpio_data_put(struct snd_kcontrol *kcontrol,
515 struct snd_ctl_elem_value *ucontrol)
518 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
519 hda_nid_t nid = kcontrol->private_value & 0xffff;
520 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
521 long val = *ucontrol->value.integer.value;
522 unsigned int gpio_data = snd_hda_codec_read(codec, nid, 0,
523 AC_VERB_GET_GPIO_DATA,
526 /* Set/unset the masked GPIO bit(s) as needed */
527 change = (val == 0 ? 0 : mask) != (gpio_data & mask);
532 snd_hda_codec_write_cache(codec, nid, 0,
533 AC_VERB_SET_GPIO_DATA, gpio_data);
537 #define ALC_GPIO_DATA_SWITCH(xname, nid, mask) \
538 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
539 .info = alc_gpio_data_info, \
540 .get = alc_gpio_data_get, \
541 .put = alc_gpio_data_put, \
542 .private_value = nid | (mask<<16) }
543 #endif /* CONFIG_SND_DEBUG */
545 /* A switch control to allow the enabling of the digital IO pins on the
546 * ALC260. This is incredibly simplistic; the intention of this control is
547 * to provide something in the test model allowing digital outputs to be
548 * identified if present. If models are found which can utilise these
549 * outputs a more complete mixer control can be devised for those models if
552 #ifdef CONFIG_SND_DEBUG
553 #define alc_spdif_ctrl_info snd_ctl_boolean_mono_info
555 static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol,
556 struct snd_ctl_elem_value *ucontrol)
558 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
559 hda_nid_t nid = kcontrol->private_value & 0xffff;
560 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
561 long *valp = ucontrol->value.integer.value;
562 unsigned int val = snd_hda_codec_read(codec, nid, 0,
563 AC_VERB_GET_DIGI_CONVERT, 0x00);
565 *valp = (val & mask) != 0;
568 static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol,
569 struct snd_ctl_elem_value *ucontrol)
572 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
573 hda_nid_t nid = kcontrol->private_value & 0xffff;
574 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
575 long val = *ucontrol->value.integer.value;
576 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
577 AC_VERB_GET_DIGI_CONVERT,
580 /* Set/unset the masked control bit(s) as needed */
581 change = (val == 0 ? 0 : mask) != (ctrl_data & mask);
586 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1,
591 #define ALC_SPDIF_CTRL_SWITCH(xname, nid, mask) \
592 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
593 .info = alc_spdif_ctrl_info, \
594 .get = alc_spdif_ctrl_get, \
595 .put = alc_spdif_ctrl_put, \
596 .private_value = nid | (mask<<16) }
597 #endif /* CONFIG_SND_DEBUG */
600 * set up from the preset table
602 static void setup_preset(struct alc_spec *spec,
603 const struct alc_config_preset *preset)
607 for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++)
608 spec->mixers[spec->num_mixers++] = preset->mixers[i];
609 for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i];
611 spec->init_verbs[spec->num_init_verbs++] =
612 preset->init_verbs[i];
614 spec->channel_mode = preset->channel_mode;
615 spec->num_channel_mode = preset->num_channel_mode;
616 spec->need_dac_fix = preset->need_dac_fix;
618 spec->multiout.max_channels = spec->channel_mode[0].channels;
620 spec->multiout.num_dacs = preset->num_dacs;
621 spec->multiout.dac_nids = preset->dac_nids;
622 spec->multiout.dig_out_nid = preset->dig_out_nid;
623 spec->multiout.hp_nid = preset->hp_nid;
625 spec->num_mux_defs = preset->num_mux_defs;
626 if (!spec->num_mux_defs)
627 spec->num_mux_defs = 1;
628 spec->input_mux = preset->input_mux;
630 spec->num_adc_nids = preset->num_adc_nids;
631 spec->adc_nids = preset->adc_nids;
632 spec->dig_in_nid = preset->dig_in_nid;
634 spec->unsol_event = preset->unsol_event;
635 spec->init_hook = preset->init_hook;
636 #ifdef CONFIG_SND_HDA_POWER_SAVE
637 spec->loopback.amplist = preset->loopbacks;
641 /* Enable GPIO mask and set output */
642 static struct hda_verb alc_gpio1_init_verbs[] = {
643 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
644 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
645 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
649 static struct hda_verb alc_gpio2_init_verbs[] = {
650 {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
651 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
652 {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
656 static struct hda_verb alc_gpio3_init_verbs[] = {
657 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
658 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
659 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
663 /* 32-bit subsystem ID for BIOS loading in HD Audio codec.
664 * 31 ~ 16 : Manufacture ID
666 * 7 ~ 0 : Assembly ID
667 * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36
669 static void alc_subsystem_id(struct hda_codec *codec,
670 unsigned int porta, unsigned int porte,
673 unsigned int ass, tmp;
675 ass = codec->subsystem_id;
680 tmp = (ass & 0x38) >> 3; /* external Amp control */
683 snd_hda_sequence_write(codec, alc_gpio1_init_verbs);
686 snd_hda_sequence_write(codec, alc_gpio2_init_verbs);
689 snd_hda_sequence_write(codec, alc_gpio3_init_verbs);
692 switch (codec->vendor_id) {
698 snd_hda_codec_write(codec, 0x14, 0,
699 AC_VERB_SET_EAPD_BTLENABLE, 2);
700 snd_hda_codec_write(codec, 0x15, 0,
701 AC_VERB_SET_EAPD_BTLENABLE, 2);
705 if (ass & 4) { /* bit 2 : 0 = Desktop, 1 = Laptop */
707 tmp = (ass & 0x1800) >> 11;
709 case 0: port = porta; break;
710 case 1: port = porte; break;
711 case 2: port = portd; break;
714 snd_hda_codec_write(codec, port, 0,
715 AC_VERB_SET_EAPD_BTLENABLE,
718 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
719 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF,
720 (tmp == 5 ? 0x3040 : 0x3050));
726 * Fix-up pin default configurations
734 static void alc_fix_pincfg(struct hda_codec *codec,
735 const struct snd_pci_quirk *quirk,
736 const struct alc_pincfg **pinfix)
738 const struct alc_pincfg *cfg;
740 quirk = snd_pci_quirk_lookup(codec->bus->pci, quirk);
744 cfg = pinfix[quirk->value];
745 for (; cfg->nid; cfg++) {
748 for (i = 0; i < 4; i++) {
749 snd_hda_codec_write(codec, cfg->nid, 0,
750 AC_VERB_SET_CONFIG_DEFAULT_BYTES_0 + i,
758 * ALC880 3-stack model
760 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
761 * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18,
762 * F-Mic = 0x1b, HP = 0x19
765 static hda_nid_t alc880_dac_nids[4] = {
766 /* front, rear, clfe, rear_surr */
767 0x02, 0x05, 0x04, 0x03
770 static hda_nid_t alc880_adc_nids[3] = {
775 /* The datasheet says the node 0x07 is connected from inputs,
776 * but it shows zero connection in the real implementation on some devices.
777 * Note: this is a 915GAV bug, fixed on 915GLV
779 static hda_nid_t alc880_adc_nids_alt[2] = {
784 #define ALC880_DIGOUT_NID 0x06
785 #define ALC880_DIGIN_NID 0x0a
787 static struct hda_input_mux alc880_capture_source = {
791 { "Front Mic", 0x3 },
797 /* channel source setting (2/6 channel selection for 3-stack) */
799 static struct hda_verb alc880_threestack_ch2_init[] = {
800 /* set line-in to input, mute it */
801 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
802 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
803 /* set mic-in to input vref 80%, mute it */
804 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
805 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
810 static struct hda_verb alc880_threestack_ch6_init[] = {
811 /* set line-in to output, unmute it */
812 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
813 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
814 /* set mic-in to output, unmute it */
815 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
816 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
820 static struct hda_channel_mode alc880_threestack_modes[2] = {
821 { 2, alc880_threestack_ch2_init },
822 { 6, alc880_threestack_ch6_init },
825 static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
826 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
827 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
828 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
829 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
830 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
831 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
832 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
833 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
834 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
835 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
836 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
837 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
838 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
839 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
840 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
841 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
842 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
843 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
844 HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
846 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
847 .name = "Channel Mode",
848 .info = alc_ch_mode_info,
849 .get = alc_ch_mode_get,
850 .put = alc_ch_mode_put,
855 /* capture mixer elements */
856 static struct snd_kcontrol_new alc880_capture_mixer[] = {
857 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
858 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
859 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
860 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
861 HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
862 HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
864 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
865 /* The multiple "Capture Source" controls confuse alsamixer
866 * So call somewhat different..
867 * FIXME: the controls appear in the "playback" view!
869 /* .name = "Capture Source", */
870 .name = "Input Source",
872 .info = alc_mux_enum_info,
873 .get = alc_mux_enum_get,
874 .put = alc_mux_enum_put,
879 /* capture mixer elements (in case NID 0x07 not available) */
880 static struct snd_kcontrol_new alc880_capture_alt_mixer[] = {
881 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
882 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
883 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
884 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
886 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
887 /* The multiple "Capture Source" controls confuse alsamixer
888 * So call somewhat different..
889 * FIXME: the controls appear in the "playback" view!
891 /* .name = "Capture Source", */
892 .name = "Input Source",
894 .info = alc_mux_enum_info,
895 .get = alc_mux_enum_get,
896 .put = alc_mux_enum_put,
904 * ALC880 5-stack model
906 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d),
908 * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
909 * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
912 /* additional mixers to alc880_three_stack_mixer */
913 static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
914 HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
915 HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
919 /* channel source setting (6/8 channel selection for 5-stack) */
921 static struct hda_verb alc880_fivestack_ch6_init[] = {
922 /* set line-in to input, mute it */
923 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
924 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
929 static struct hda_verb alc880_fivestack_ch8_init[] = {
930 /* set line-in to output, unmute it */
931 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
932 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
936 static struct hda_channel_mode alc880_fivestack_modes[2] = {
937 { 6, alc880_fivestack_ch6_init },
938 { 8, alc880_fivestack_ch8_init },
943 * ALC880 6-stack model
945 * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e),
947 * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
948 * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
951 static hda_nid_t alc880_6st_dac_nids[4] = {
952 /* front, rear, clfe, rear_surr */
953 0x02, 0x03, 0x04, 0x05
956 static struct hda_input_mux alc880_6stack_capture_source = {
960 { "Front Mic", 0x1 },
966 /* fixed 8-channels */
967 static struct hda_channel_mode alc880_sixstack_modes[1] = {
971 static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
972 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
973 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
974 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
975 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
976 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
977 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
978 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
979 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
980 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
981 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
982 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
983 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
984 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
985 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
986 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
987 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
988 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
989 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
990 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
991 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
993 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
994 .name = "Channel Mode",
995 .info = alc_ch_mode_info,
996 .get = alc_ch_mode_get,
997 .put = alc_ch_mode_put,
1006 * W810 has rear IO for:
1009 * Center/LFE (DAC 04)
1012 * The system also has a pair of internal speakers, and a headphone jack.
1013 * These are both connected to Line2 on the codec, hence to DAC 02.
1015 * There is a variable resistor to control the speaker or headphone
1016 * volume. This is a hardware-only device without a software API.
1018 * Plugging headphones in will disable the internal speakers. This is
1019 * implemented in hardware, not via the driver using jack sense. In
1020 * a similar fashion, plugging into the rear socket marked "front" will
1021 * disable both the speakers and headphones.
1023 * For input, there's a microphone jack, and an "audio in" jack.
1024 * These may not do anything useful with this driver yet, because I
1025 * haven't setup any initialization verbs for these yet...
1028 static hda_nid_t alc880_w810_dac_nids[3] = {
1029 /* front, rear/surround, clfe */
1033 /* fixed 6 channels */
1034 static struct hda_channel_mode alc880_w810_modes[1] = {
1038 /* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
1039 static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
1040 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1041 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1042 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1043 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
1044 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1045 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1046 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1047 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1048 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
1056 * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
1057 * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?),
1061 static hda_nid_t alc880_z71v_dac_nids[1] = {
1064 #define ALC880_Z71V_HP_DAC 0x03
1066 /* fixed 2 channels */
1067 static struct hda_channel_mode alc880_2_jack_modes[1] = {
1071 static struct snd_kcontrol_new alc880_z71v_mixer[] = {
1072 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1073 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1074 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1075 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
1076 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1077 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1078 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1079 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1086 * ALC880 F1734 model
1088 * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
1089 * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
1092 static hda_nid_t alc880_f1734_dac_nids[1] = {
1095 #define ALC880_F1734_HP_DAC 0x02
1097 static struct snd_kcontrol_new alc880_f1734_mixer[] = {
1098 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1099 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
1100 HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1101 HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
1102 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1103 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1104 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1105 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1114 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
1115 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
1116 * Mic = 0x18, Line = 0x1a
1119 #define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
1120 #define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
1122 static struct snd_kcontrol_new alc880_asus_mixer[] = {
1123 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1124 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1125 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1126 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
1127 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1128 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1129 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1130 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1131 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1132 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1133 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1134 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1135 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1136 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1138 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1139 .name = "Channel Mode",
1140 .info = alc_ch_mode_info,
1141 .get = alc_ch_mode_get,
1142 .put = alc_ch_mode_put,
1149 * ALC880 ASUS W1V model
1151 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
1152 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
1153 * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
1156 /* additional mixers to alc880_asus_mixer */
1157 static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
1158 HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
1159 HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
1163 /* additional mixers to alc880_asus_mixer */
1164 static struct snd_kcontrol_new alc880_pcbeep_mixer[] = {
1165 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1166 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
1171 static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
1172 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1173 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
1174 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
1175 HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
1176 HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
1177 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
1178 HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
1179 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
1180 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
1182 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1183 /* The multiple "Capture Source" controls confuse alsamixer
1184 * So call somewhat different..
1185 * FIXME: the controls appear in the "playback" view!
1187 /* .name = "Capture Source", */
1188 .name = "Input Source",
1190 .info = alc_mux_enum_info,
1191 .get = alc_mux_enum_get,
1192 .put = alc_mux_enum_put,
1198 static struct snd_kcontrol_new alc880_uniwill_mixer[] = {
1199 HDA_CODEC_VOLUME("HPhone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1200 HDA_BIND_MUTE("HPhone Playback Switch", 0x0c, 2, HDA_INPUT),
1201 HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1202 HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT),
1203 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1204 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1205 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1206 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1207 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1208 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1209 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1210 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1211 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1212 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1213 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1214 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1215 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1216 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
1218 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1219 .name = "Channel Mode",
1220 .info = alc_ch_mode_info,
1221 .get = alc_ch_mode_get,
1222 .put = alc_ch_mode_put,
1227 static struct snd_kcontrol_new alc880_fujitsu_mixer[] = {
1228 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1229 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
1230 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1231 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
1232 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1233 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1234 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1235 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1236 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1237 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1241 static struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = {
1242 HDA_CODEC_VOLUME("HPhone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1243 HDA_BIND_MUTE("HPhone Playback Switch", 0x0c, 2, HDA_INPUT),
1244 HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1245 HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT),
1246 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1247 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1252 * build control elements
1254 static int alc_build_controls(struct hda_codec *codec)
1256 struct alc_spec *spec = codec->spec;
1260 for (i = 0; i < spec->num_mixers; i++) {
1261 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
1266 if (spec->multiout.dig_out_nid) {
1267 err = snd_hda_create_spdif_out_ctls(codec,
1268 spec->multiout.dig_out_nid);
1272 if (spec->dig_in_nid) {
1273 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
1282 * initialize the codec volumes, etc
1286 * generic initialization of ADC, input mixers and output mixers
1288 static struct hda_verb alc880_volume_init_verbs[] = {
1290 * Unmute ADC0-2 and set the default input to mic-in
1292 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
1293 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1294 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
1295 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1296 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
1297 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1299 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
1301 * Note: PASD motherboards uses the Line In 2 as the input for front
1304 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
1305 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1306 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1307 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
1308 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
1309 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
1310 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
1311 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
1314 * Set up output mixers (0x0c - 0x0f)
1316 /* set vol=0 to output mixers */
1317 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1318 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1319 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1320 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1321 /* set up input amps for analog loopback */
1322 /* Amp Indices: DAC = 0, mixer = 1 */
1323 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1324 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1325 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1326 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1327 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1328 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1329 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1330 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1336 * 3-stack pin configuration:
1337 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
1339 static struct hda_verb alc880_pin_3stack_init_verbs[] = {
1341 * preset connection lists of input pins
1342 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
1344 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
1345 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1346 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
1349 * Set pin mode and muting
1351 /* set front pin widgets 0x14 for output */
1352 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1353 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1354 /* Mic1 (rear panel) pin widget for input and vref at 80% */
1355 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1356 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1357 /* Mic2 (as headphone out) for HP output */
1358 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1359 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1360 /* Line In pin widget for input */
1361 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1362 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1363 /* Line2 (as front mic) pin widget for input and vref at 80% */
1364 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1365 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1366 /* CD pin widget for input */
1367 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1373 * 5-stack pin configuration:
1374 * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
1375 * line-in/side = 0x1a, f-mic = 0x1b
1377 static struct hda_verb alc880_pin_5stack_init_verbs[] = {
1379 * preset connection lists of input pins
1380 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
1382 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1383 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
1386 * Set pin mode and muting
1388 /* set pin widgets 0x14-0x17 for output */
1389 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1390 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1391 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1392 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1393 /* unmute pins for output (no gain on this amp) */
1394 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1395 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1396 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1397 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1399 /* Mic1 (rear panel) pin widget for input and vref at 80% */
1400 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1401 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1402 /* Mic2 (as headphone out) for HP output */
1403 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1404 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1405 /* Line In pin widget for input */
1406 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1407 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1408 /* Line2 (as front mic) pin widget for input and vref at 80% */
1409 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1410 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1411 /* CD pin widget for input */
1412 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1418 * W810 pin configuration:
1419 * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
1421 static struct hda_verb alc880_pin_w810_init_verbs[] = {
1422 /* hphone/speaker input selector: front DAC */
1423 {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
1425 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1426 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1427 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1428 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1429 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1430 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1432 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1433 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1439 * Z71V pin configuration:
1440 * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
1442 static struct hda_verb alc880_pin_z71v_init_verbs[] = {
1443 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1444 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1445 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1446 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1448 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1449 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1450 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1451 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1457 * 6-stack pin configuration:
1458 * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18,
1459 * f-mic = 0x19, line = 0x1a, HP = 0x1b
1461 static struct hda_verb alc880_pin_6stack_init_verbs[] = {
1462 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1464 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1465 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1466 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1467 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1468 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1469 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1470 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1471 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1473 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1474 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1475 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1476 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1477 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1478 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1479 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1480 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1481 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1487 * Uniwill pin configuration:
1488 * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19,
1491 static struct hda_verb alc880_uniwill_init_verbs[] = {
1492 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1494 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1495 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1496 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1497 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1498 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1499 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1500 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1501 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1502 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1503 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1504 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1505 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1506 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1507 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1509 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1510 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1511 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1512 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1513 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1514 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1515 /* {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, */
1516 /* {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
1517 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1519 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
1520 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
1527 * HP = 0x14, InternalSpeaker = 0x15, mic = 0x19,
1529 static struct hda_verb alc880_uniwill_p53_init_verbs[] = {
1530 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1532 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1533 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1534 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1535 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1536 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1537 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1538 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1539 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1540 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1541 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1542 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1543 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1545 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1546 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1547 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1548 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1549 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1550 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1552 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
1553 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_DCVOL_EVENT},
1558 static struct hda_verb alc880_beep_init_verbs[] = {
1559 { 0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5) },
1563 /* toggle speaker-output according to the hp-jack state */
1564 static void alc880_uniwill_hp_automute(struct hda_codec *codec)
1566 unsigned int present;
1569 present = snd_hda_codec_read(codec, 0x14, 0,
1570 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1571 bits = present ? HDA_AMP_MUTE : 0;
1572 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
1573 HDA_AMP_MUTE, bits);
1574 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
1575 HDA_AMP_MUTE, bits);
1578 /* auto-toggle front mic */
1579 static void alc880_uniwill_mic_automute(struct hda_codec *codec)
1581 unsigned int present;
1584 present = snd_hda_codec_read(codec, 0x18, 0,
1585 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1586 bits = present ? HDA_AMP_MUTE : 0;
1587 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
1590 static void alc880_uniwill_automute(struct hda_codec *codec)
1592 alc880_uniwill_hp_automute(codec);
1593 alc880_uniwill_mic_automute(codec);
1596 static void alc880_uniwill_unsol_event(struct hda_codec *codec,
1599 /* Looks like the unsol event is incompatible with the standard
1600 * definition. 4bit tag is placed at 28 bit!
1602 switch (res >> 28) {
1603 case ALC880_HP_EVENT:
1604 alc880_uniwill_hp_automute(codec);
1606 case ALC880_MIC_EVENT:
1607 alc880_uniwill_mic_automute(codec);
1612 static void alc880_uniwill_p53_hp_automute(struct hda_codec *codec)
1614 unsigned int present;
1617 present = snd_hda_codec_read(codec, 0x14, 0,
1618 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1619 bits = present ? HDA_AMP_MUTE : 0;
1620 snd_hda_codec_amp_stereo(codec, 0x15, HDA_INPUT, 0, HDA_AMP_MUTE, bits);
1623 static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec)
1625 unsigned int present;
1627 present = snd_hda_codec_read(codec, 0x21, 0,
1628 AC_VERB_GET_VOLUME_KNOB_CONTROL, 0);
1629 present &= HDA_AMP_VOLMASK;
1630 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0,
1631 HDA_AMP_VOLMASK, present);
1632 snd_hda_codec_amp_stereo(codec, 0x0d, HDA_OUTPUT, 0,
1633 HDA_AMP_VOLMASK, present);
1636 static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec,
1639 /* Looks like the unsol event is incompatible with the standard
1640 * definition. 4bit tag is placed at 28 bit!
1642 if ((res >> 28) == ALC880_HP_EVENT)
1643 alc880_uniwill_p53_hp_automute(codec);
1644 if ((res >> 28) == ALC880_DCVOL_EVENT)
1645 alc880_uniwill_p53_dcvol_automute(codec);
1650 * F1734 pin configuration:
1651 * HP = 0x14, speaker-out = 0x15, mic = 0x18
1653 static struct hda_verb alc880_pin_f1734_init_verbs[] = {
1654 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
1655 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
1656 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
1657 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
1659 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1660 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1661 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1662 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1664 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1665 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1666 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1667 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1668 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1669 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1670 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1671 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1672 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1679 * ASUS pin configuration:
1680 * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
1682 static struct hda_verb alc880_pin_asus_init_verbs[] = {
1683 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
1684 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
1685 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
1686 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
1688 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1689 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1690 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1691 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1692 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1693 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1694 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1695 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1697 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1698 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1699 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1700 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1701 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1702 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1703 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1704 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1705 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1710 /* Enable GPIO mask and set output */
1711 #define alc880_gpio1_init_verbs alc_gpio1_init_verbs
1712 #define alc880_gpio2_init_verbs alc_gpio2_init_verbs
1714 /* Clevo m520g init */
1715 static struct hda_verb alc880_pin_clevo_init_verbs[] = {
1716 /* headphone output */
1717 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
1719 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1720 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1722 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1723 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1725 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1726 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1727 /* Mic1 (rear panel) */
1728 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1729 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1730 /* Mic2 (front panel) */
1731 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1732 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1734 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1735 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1736 /* change to EAPD mode */
1737 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
1738 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
1743 static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
1744 /* change to EAPD mode */
1745 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
1746 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
1748 /* Headphone output */
1749 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1751 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1752 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
1754 /* Line In pin widget for input */
1755 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1756 /* CD pin widget for input */
1757 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1758 /* Mic1 (rear panel) pin widget for input and vref at 80% */
1759 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1761 /* change to EAPD mode */
1762 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
1763 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
1769 * LG m1 express dual
1772 * Rear Line-In/Out (blue): 0x14
1773 * Build-in Mic-In: 0x15
1775 * HP-Out (green): 0x1b
1776 * Mic-In/Out (red): 0x19
1780 /* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
1781 static hda_nid_t alc880_lg_dac_nids[3] = {
1785 /* seems analog CD is not working */
1786 static struct hda_input_mux alc880_lg_capture_source = {
1791 { "Internal Mic", 0x6 },
1795 /* 2,4,6 channel modes */
1796 static struct hda_verb alc880_lg_ch2_init[] = {
1797 /* set line-in and mic-in to input */
1798 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1799 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1803 static struct hda_verb alc880_lg_ch4_init[] = {
1804 /* set line-in to out and mic-in to input */
1805 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
1806 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1810 static struct hda_verb alc880_lg_ch6_init[] = {
1811 /* set line-in and mic-in to output */
1812 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
1813 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
1817 static struct hda_channel_mode alc880_lg_ch_modes[3] = {
1818 { 2, alc880_lg_ch2_init },
1819 { 4, alc880_lg_ch4_init },
1820 { 6, alc880_lg_ch6_init },
1823 static struct snd_kcontrol_new alc880_lg_mixer[] = {
1824 /* FIXME: it's not really "master" but front channels */
1825 HDA_CODEC_VOLUME("Master Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
1826 HDA_BIND_MUTE("Master Playback Switch", 0x0f, 2, HDA_INPUT),
1827 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1828 HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
1829 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
1830 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
1831 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
1832 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
1833 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1834 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1835 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
1836 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
1837 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
1838 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
1840 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1841 .name = "Channel Mode",
1842 .info = alc_ch_mode_info,
1843 .get = alc_ch_mode_get,
1844 .put = alc_ch_mode_put,
1849 static struct hda_verb alc880_lg_init_verbs[] = {
1850 /* set capture source to mic-in */
1851 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1852 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1853 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1854 /* mute all amp mixer inputs */
1855 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
1856 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
1857 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
1858 /* line-in to input */
1859 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1860 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1862 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1863 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1865 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1866 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1867 /* mic-in to input */
1868 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
1869 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1870 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1872 {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
1873 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1874 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1876 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
1880 /* toggle speaker-output according to the hp-jack state */
1881 static void alc880_lg_automute(struct hda_codec *codec)
1883 unsigned int present;
1886 present = snd_hda_codec_read(codec, 0x1b, 0,
1887 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1888 bits = present ? HDA_AMP_MUTE : 0;
1889 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
1890 HDA_AMP_MUTE, bits);
1893 static void alc880_lg_unsol_event(struct hda_codec *codec, unsigned int res)
1895 /* Looks like the unsol event is incompatible with the standard
1896 * definition. 4bit tag is placed at 28 bit!
1898 if ((res >> 28) == 0x01)
1899 alc880_lg_automute(codec);
1908 * Built-in Mic-In: 0x19
1914 static struct hda_input_mux alc880_lg_lw_capture_source = {
1918 { "Internal Mic", 0x1 },
1923 #define alc880_lg_lw_modes alc880_threestack_modes
1925 static struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
1926 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1927 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1928 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
1929 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
1930 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1931 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1932 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1933 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1934 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1935 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1936 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1937 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1938 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
1939 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
1941 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1942 .name = "Channel Mode",
1943 .info = alc_ch_mode_info,
1944 .get = alc_ch_mode_get,
1945 .put = alc_ch_mode_put,
1950 static struct hda_verb alc880_lg_lw_init_verbs[] = {
1951 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1952 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
1953 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
1955 /* set capture source to mic-in */
1956 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1957 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1958 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1959 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
1961 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1962 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1964 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1965 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1966 /* mic-in to input */
1967 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1968 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1970 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1971 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1973 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
1977 /* toggle speaker-output according to the hp-jack state */
1978 static void alc880_lg_lw_automute(struct hda_codec *codec)
1980 unsigned int present;
1983 present = snd_hda_codec_read(codec, 0x1b, 0,
1984 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1985 bits = present ? HDA_AMP_MUTE : 0;
1986 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
1987 HDA_AMP_MUTE, bits);
1990 static void alc880_lg_lw_unsol_event(struct hda_codec *codec, unsigned int res)
1992 /* Looks like the unsol event is incompatible with the standard
1993 * definition. 4bit tag is placed at 28 bit!
1995 if ((res >> 28) == 0x01)
1996 alc880_lg_lw_automute(codec);
1999 #ifdef CONFIG_SND_HDA_POWER_SAVE
2000 static struct hda_amp_list alc880_loopbacks[] = {
2001 { 0x0b, HDA_INPUT, 0 },
2002 { 0x0b, HDA_INPUT, 1 },
2003 { 0x0b, HDA_INPUT, 2 },
2004 { 0x0b, HDA_INPUT, 3 },
2005 { 0x0b, HDA_INPUT, 4 },
2009 static struct hda_amp_list alc880_lg_loopbacks[] = {
2010 { 0x0b, HDA_INPUT, 1 },
2011 { 0x0b, HDA_INPUT, 6 },
2012 { 0x0b, HDA_INPUT, 7 },
2021 static int alc_init(struct hda_codec *codec)
2023 struct alc_spec *spec = codec->spec;
2026 for (i = 0; i < spec->num_init_verbs; i++)
2027 snd_hda_sequence_write(codec, spec->init_verbs[i]);
2029 if (spec->init_hook)
2030 spec->init_hook(codec);
2035 static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
2037 struct alc_spec *spec = codec->spec;
2039 if (spec->unsol_event)
2040 spec->unsol_event(codec, res);
2043 #ifdef CONFIG_SND_HDA_POWER_SAVE
2044 static int alc_check_power_status(struct hda_codec *codec, hda_nid_t nid)
2046 struct alc_spec *spec = codec->spec;
2047 return snd_hda_check_amp_list_power(codec, &spec->loopback, nid);
2052 * Analog playback callbacks
2054 static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
2055 struct hda_codec *codec,
2056 struct snd_pcm_substream *substream)
2058 struct alc_spec *spec = codec->spec;
2059 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream);
2062 static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2063 struct hda_codec *codec,
2064 unsigned int stream_tag,
2065 unsigned int format,
2066 struct snd_pcm_substream *substream)
2068 struct alc_spec *spec = codec->spec;
2069 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
2070 stream_tag, format, substream);
2073 static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
2074 struct hda_codec *codec,
2075 struct snd_pcm_substream *substream)
2077 struct alc_spec *spec = codec->spec;
2078 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
2084 static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
2085 struct hda_codec *codec,
2086 struct snd_pcm_substream *substream)
2088 struct alc_spec *spec = codec->spec;
2089 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
2092 static int alc880_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2093 struct hda_codec *codec,
2094 unsigned int stream_tag,
2095 unsigned int format,
2096 struct snd_pcm_substream *substream)
2098 struct alc_spec *spec = codec->spec;
2099 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
2100 stream_tag, format, substream);
2103 static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
2104 struct hda_codec *codec,
2105 struct snd_pcm_substream *substream)
2107 struct alc_spec *spec = codec->spec;
2108 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
2114 static int alc880_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
2115 struct hda_codec *codec,
2116 unsigned int stream_tag,
2117 unsigned int format,
2118 struct snd_pcm_substream *substream)
2120 struct alc_spec *spec = codec->spec;
2122 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
2123 stream_tag, 0, format);
2127 static int alc880_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
2128 struct hda_codec *codec,
2129 struct snd_pcm_substream *substream)
2131 struct alc_spec *spec = codec->spec;
2133 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
2141 static struct hda_pcm_stream alc880_pcm_analog_playback = {
2145 /* NID is set in alc_build_pcms */
2147 .open = alc880_playback_pcm_open,
2148 .prepare = alc880_playback_pcm_prepare,
2149 .cleanup = alc880_playback_pcm_cleanup
2153 static struct hda_pcm_stream alc880_pcm_analog_capture = {
2157 /* NID is set in alc_build_pcms */
2159 .prepare = alc880_capture_pcm_prepare,
2160 .cleanup = alc880_capture_pcm_cleanup
2164 static struct hda_pcm_stream alc880_pcm_digital_playback = {
2168 /* NID is set in alc_build_pcms */
2170 .open = alc880_dig_playback_pcm_open,
2171 .close = alc880_dig_playback_pcm_close,
2172 .prepare = alc880_dig_playback_pcm_prepare
2176 static struct hda_pcm_stream alc880_pcm_digital_capture = {
2180 /* NID is set in alc_build_pcms */
2183 /* Used by alc_build_pcms to flag that a PCM has no playback stream */
2184 static struct hda_pcm_stream alc_pcm_null_playback = {
2190 static int alc_build_pcms(struct hda_codec *codec)
2192 struct alc_spec *spec = codec->spec;
2193 struct hda_pcm *info = spec->pcm_rec;
2196 codec->num_pcms = 1;
2197 codec->pcm_info = info;
2199 info->name = spec->stream_name_analog;
2200 if (spec->stream_analog_playback) {
2201 snd_assert(spec->multiout.dac_nids, return -EINVAL);
2202 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
2203 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
2205 if (spec->stream_analog_capture) {
2206 snd_assert(spec->adc_nids, return -EINVAL);
2207 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
2208 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
2211 if (spec->channel_mode) {
2212 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
2213 for (i = 0; i < spec->num_channel_mode; i++) {
2214 if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
2215 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
2220 /* SPDIF for stream index #1 */
2221 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
2222 codec->num_pcms = 2;
2223 info = spec->pcm_rec + 1;
2224 info->name = spec->stream_name_digital;
2225 if (spec->multiout.dig_out_nid &&
2226 spec->stream_digital_playback) {
2227 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
2228 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
2230 if (spec->dig_in_nid &&
2231 spec->stream_digital_capture) {
2232 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
2233 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
2237 /* If the use of more than one ADC is requested for the current
2238 * model, configure a second analog capture-only PCM.
2240 /* Additional Analaog capture for index #2 */
2241 if (spec->num_adc_nids > 1 && spec->stream_analog_capture &&
2243 codec->num_pcms = 3;
2244 info = spec->pcm_rec + 2;
2245 info->name = spec->stream_name_analog;
2246 /* No playback stream for second PCM */
2247 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = alc_pcm_null_playback;
2248 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
2249 if (spec->stream_analog_capture) {
2250 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
2251 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[1];
2258 static void alc_free(struct hda_codec *codec)
2260 struct alc_spec *spec = codec->spec;
2266 if (spec->kctl_alloc) {
2267 for (i = 0; i < spec->num_kctl_used; i++)
2268 kfree(spec->kctl_alloc[i].name);
2269 kfree(spec->kctl_alloc);
2276 static struct hda_codec_ops alc_patch_ops = {
2277 .build_controls = alc_build_controls,
2278 .build_pcms = alc_build_pcms,
2281 .unsol_event = alc_unsol_event,
2282 #ifdef CONFIG_SND_HDA_POWER_SAVE
2283 .check_power_status = alc_check_power_status,
2289 * Test configuration for debugging
2291 * Almost all inputs/outputs are enabled. I/O pins can be configured via
2294 #ifdef CONFIG_SND_DEBUG
2295 static hda_nid_t alc880_test_dac_nids[4] = {
2296 0x02, 0x03, 0x04, 0x05
2299 static struct hda_input_mux alc880_test_capture_source = {
2308 { "Surround", 0x6 },
2312 static struct hda_channel_mode alc880_test_modes[4] = {
2319 static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol,
2320 struct snd_ctl_elem_info *uinfo)
2322 static char *texts[] = {
2323 "N/A", "Line Out", "HP Out",
2324 "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
2326 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
2328 uinfo->value.enumerated.items = 8;
2329 if (uinfo->value.enumerated.item >= 8)
2330 uinfo->value.enumerated.item = 7;
2331 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
2335 static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol,
2336 struct snd_ctl_elem_value *ucontrol)
2338 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2339 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2340 unsigned int pin_ctl, item = 0;
2342 pin_ctl = snd_hda_codec_read(codec, nid, 0,
2343 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
2344 if (pin_ctl & AC_PINCTL_OUT_EN) {
2345 if (pin_ctl & AC_PINCTL_HP_EN)
2349 } else if (pin_ctl & AC_PINCTL_IN_EN) {
2350 switch (pin_ctl & AC_PINCTL_VREFEN) {
2351 case AC_PINCTL_VREF_HIZ: item = 3; break;
2352 case AC_PINCTL_VREF_50: item = 4; break;
2353 case AC_PINCTL_VREF_GRD: item = 5; break;
2354 case AC_PINCTL_VREF_80: item = 6; break;
2355 case AC_PINCTL_VREF_100: item = 7; break;
2358 ucontrol->value.enumerated.item[0] = item;
2362 static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol,
2363 struct snd_ctl_elem_value *ucontrol)
2365 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2366 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2367 static unsigned int ctls[] = {
2368 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
2369 AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
2370 AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
2371 AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
2372 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
2373 AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
2375 unsigned int old_ctl, new_ctl;
2377 old_ctl = snd_hda_codec_read(codec, nid, 0,
2378 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
2379 new_ctl = ctls[ucontrol->value.enumerated.item[0]];
2380 if (old_ctl != new_ctl) {
2382 snd_hda_codec_write_cache(codec, nid, 0,
2383 AC_VERB_SET_PIN_WIDGET_CONTROL,
2385 val = ucontrol->value.enumerated.item[0] >= 3 ?
2387 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
2394 static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol,
2395 struct snd_ctl_elem_info *uinfo)
2397 static char *texts[] = {
2398 "Front", "Surround", "CLFE", "Side"
2400 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
2402 uinfo->value.enumerated.items = 4;
2403 if (uinfo->value.enumerated.item >= 4)
2404 uinfo->value.enumerated.item = 3;
2405 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
2409 static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol,
2410 struct snd_ctl_elem_value *ucontrol)
2412 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2413 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2416 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
2417 ucontrol->value.enumerated.item[0] = sel & 3;
2421 static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol,
2422 struct snd_ctl_elem_value *ucontrol)
2424 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2425 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2428 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
2429 if (ucontrol->value.enumerated.item[0] != sel) {
2430 sel = ucontrol->value.enumerated.item[0] & 3;
2431 snd_hda_codec_write_cache(codec, nid, 0,
2432 AC_VERB_SET_CONNECT_SEL, sel);
2438 #define PIN_CTL_TEST(xname,nid) { \
2439 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2441 .info = alc_test_pin_ctl_info, \
2442 .get = alc_test_pin_ctl_get, \
2443 .put = alc_test_pin_ctl_put, \
2444 .private_value = nid \
2447 #define PIN_SRC_TEST(xname,nid) { \
2448 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2450 .info = alc_test_pin_src_info, \
2451 .get = alc_test_pin_src_get, \
2452 .put = alc_test_pin_src_put, \
2453 .private_value = nid \
2456 static struct snd_kcontrol_new alc880_test_mixer[] = {
2457 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2458 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2459 HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
2460 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
2461 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2462 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
2463 HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
2464 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
2465 PIN_CTL_TEST("Front Pin Mode", 0x14),
2466 PIN_CTL_TEST("Surround Pin Mode", 0x15),
2467 PIN_CTL_TEST("CLFE Pin Mode", 0x16),
2468 PIN_CTL_TEST("Side Pin Mode", 0x17),
2469 PIN_CTL_TEST("In-1 Pin Mode", 0x18),
2470 PIN_CTL_TEST("In-2 Pin Mode", 0x19),
2471 PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
2472 PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
2473 PIN_SRC_TEST("In-1 Pin Source", 0x18),
2474 PIN_SRC_TEST("In-2 Pin Source", 0x19),
2475 PIN_SRC_TEST("In-3 Pin Source", 0x1a),
2476 PIN_SRC_TEST("In-4 Pin Source", 0x1b),
2477 HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
2478 HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
2479 HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
2480 HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
2481 HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
2482 HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
2483 HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
2484 HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
2485 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
2486 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
2488 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2489 .name = "Channel Mode",
2490 .info = alc_ch_mode_info,
2491 .get = alc_ch_mode_get,
2492 .put = alc_ch_mode_put,
2497 static struct hda_verb alc880_test_init_verbs[] = {
2498 /* Unmute inputs of 0x0c - 0x0f */
2499 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2500 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2501 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2502 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2503 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2504 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2505 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2506 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2507 /* Vol output for 0x0c-0x0f */
2508 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2509 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2510 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2511 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2512 /* Set output pins 0x14-0x17 */
2513 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2514 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2515 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2516 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2517 /* Unmute output pins 0x14-0x17 */
2518 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2519 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2520 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2521 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2522 /* Set input pins 0x18-0x1c */
2523 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2524 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2525 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2526 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2527 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2528 /* Mute input pins 0x18-0x1b */
2529 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2530 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2531 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2532 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2534 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2535 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
2536 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2537 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
2538 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2539 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
2540 /* Analog input/passthru */
2541 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2542 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2543 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
2544 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
2545 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
2553 static const char *alc880_models[ALC880_MODEL_LAST] = {
2554 [ALC880_3ST] = "3stack",
2555 [ALC880_TCL_S700] = "tcl",
2556 [ALC880_3ST_DIG] = "3stack-digout",
2557 [ALC880_CLEVO] = "clevo",
2558 [ALC880_5ST] = "5stack",
2559 [ALC880_5ST_DIG] = "5stack-digout",
2560 [ALC880_W810] = "w810",
2561 [ALC880_Z71V] = "z71v",
2562 [ALC880_6ST] = "6stack",
2563 [ALC880_6ST_DIG] = "6stack-digout",
2564 [ALC880_ASUS] = "asus",
2565 [ALC880_ASUS_W1V] = "asus-w1v",
2566 [ALC880_ASUS_DIG] = "asus-dig",
2567 [ALC880_ASUS_DIG2] = "asus-dig2",
2568 [ALC880_UNIWILL_DIG] = "uniwill",
2569 [ALC880_UNIWILL_P53] = "uniwill-p53",
2570 [ALC880_FUJITSU] = "fujitsu",
2571 [ALC880_F1734] = "F1734",
2573 [ALC880_LG_LW] = "lg-lw",
2574 #ifdef CONFIG_SND_DEBUG
2575 [ALC880_TEST] = "test",
2577 [ALC880_AUTO] = "auto",
2580 static struct snd_pci_quirk alc880_cfg_tbl[] = {
2581 /* Broken BIOS configuration */
2582 SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_6ST_DIG),
2583 SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_6ST_DIG),
2585 SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_5ST_DIG),
2586 SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_6ST),
2587 SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_W810),
2588 SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_3ST_DIG),
2589 SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_6ST_DIG),
2590 SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_6ST_DIG),
2591 SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_6ST_DIG),
2592 SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_3ST_DIG),
2593 SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_3ST),
2595 SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_6ST_DIG),
2596 SND_PCI_QUIRK(0x103c, 0x2a09, "HP", ALC880_5ST),
2598 SND_PCI_QUIRK(0x1043, 0x10b3, "ASUS W1V", ALC880_ASUS_W1V),
2599 SND_PCI_QUIRK(0x1043, 0x10c2, "ASUS W6A", ALC880_ASUS_DIG),
2600 SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS Wxx", ALC880_ASUS_DIG),
2601 SND_PCI_QUIRK(0x1043, 0x1113, "ASUS", ALC880_ASUS_DIG),
2602 SND_PCI_QUIRK(0x1043, 0x1123, "ASUS", ALC880_ASUS_DIG),
2603 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS", ALC880_ASUS_DIG),
2604 SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_Z71V),
2605 /* SND_PCI_QUIRK(0x1043, 0x1964, "ASUS", ALC880_ASUS_DIG), */
2606 SND_PCI_QUIRK(0x1043, 0x1973, "ASUS", ALC880_ASUS_DIG),
2607 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS", ALC880_ASUS_DIG),
2608 SND_PCI_QUIRK(0x1043, 0x814e, "ASUS", ALC880_ASUS),
2609 SND_PCI_QUIRK(0x1043, 0x8181, "ASUS P4GPL", ALC880_ASUS_DIG),
2610 SND_PCI_QUIRK(0x1043, 0x8196, "ASUS P5GD1", ALC880_6ST),
2611 SND_PCI_QUIRK(0x1043, 0x81b4, "ASUS", ALC880_6ST),
2612 SND_PCI_QUIRK(0x1043, 0, "ASUS", ALC880_ASUS),
2614 SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_3ST),
2615 SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_3ST),
2616 SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_5ST),
2617 SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_5ST),
2618 SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_5ST),
2619 SND_PCI_QUIRK(0x1558, 0x0520, "Clevo m520G", ALC880_CLEVO),
2620 SND_PCI_QUIRK(0x1558, 0x0660, "Clevo m655n", ALC880_CLEVO),
2621 SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_5ST_DIG),
2622 SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_W810),
2623 SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_5ST_DIG),
2624 SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_TCL_S700),
2625 SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_5ST_DIG),
2626 SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_6ST_DIG),
2627 SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_6ST_DIG),
2628 SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_6ST_DIG),
2629 SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_6ST_DIG),
2630 SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_6ST_DIG),
2631 SND_PCI_QUIRK(0x1558, 0x5401, "ASUS", ALC880_ASUS_DIG2),
2633 SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_UNIWILL_DIG),
2634 SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_UNIWILL),
2635 SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_UNIWILL_P53),
2636 SND_PCI_QUIRK(0x1584, 0x9054, "Uniwlll", ALC880_F1734),
2638 SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_5ST_DIG),
2639 SND_PCI_QUIRK(0x1734, 0x10ac, "FSC", ALC880_UNIWILL),
2640 SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_F1734),
2641 SND_PCI_QUIRK(0x1734, 0x10b0, "Fujitsu", ALC880_FUJITSU),
2643 SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_LG),
2644 SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_LG),
2645 SND_PCI_QUIRK(0x1854, 0x0018, "LG LW20", ALC880_LG_LW),
2646 SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_LG_LW),
2648 SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_3ST_DIG),
2649 SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_3ST_DIG),
2650 SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_3ST_DIG),
2651 SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_5ST_DIG),
2652 SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_5ST_DIG),
2653 SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_5ST_DIG),
2654 SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_5ST_DIG),
2655 SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_5ST_DIG),
2656 SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_5ST_DIG),
2657 SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_5ST_DIG),
2658 SND_PCI_QUIRK(0x8086, 0, "Intel mobo", ALC880_3ST),
2664 * ALC880 codec presets
2666 static struct alc_config_preset alc880_presets[] = {
2668 .mixers = { alc880_three_stack_mixer },
2669 .init_verbs = { alc880_volume_init_verbs,
2670 alc880_pin_3stack_init_verbs },
2671 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2672 .dac_nids = alc880_dac_nids,
2673 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
2674 .channel_mode = alc880_threestack_modes,
2676 .input_mux = &alc880_capture_source,
2678 [ALC880_3ST_DIG] = {
2679 .mixers = { alc880_three_stack_mixer },
2680 .init_verbs = { alc880_volume_init_verbs,
2681 alc880_pin_3stack_init_verbs },
2682 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2683 .dac_nids = alc880_dac_nids,
2684 .dig_out_nid = ALC880_DIGOUT_NID,
2685 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
2686 .channel_mode = alc880_threestack_modes,
2688 .input_mux = &alc880_capture_source,
2690 [ALC880_TCL_S700] = {
2691 .mixers = { alc880_tcl_s700_mixer },
2692 .init_verbs = { alc880_volume_init_verbs,
2693 alc880_pin_tcl_S700_init_verbs,
2694 alc880_gpio2_init_verbs },
2695 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2696 .dac_nids = alc880_dac_nids,
2698 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
2699 .channel_mode = alc880_2_jack_modes,
2700 .input_mux = &alc880_capture_source,
2703 .mixers = { alc880_three_stack_mixer,
2704 alc880_five_stack_mixer},
2705 .init_verbs = { alc880_volume_init_verbs,
2706 alc880_pin_5stack_init_verbs },
2707 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2708 .dac_nids = alc880_dac_nids,
2709 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
2710 .channel_mode = alc880_fivestack_modes,
2711 .input_mux = &alc880_capture_source,
2713 [ALC880_5ST_DIG] = {
2714 .mixers = { alc880_three_stack_mixer,
2715 alc880_five_stack_mixer },
2716 .init_verbs = { alc880_volume_init_verbs,
2717 alc880_pin_5stack_init_verbs },
2718 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2719 .dac_nids = alc880_dac_nids,
2720 .dig_out_nid = ALC880_DIGOUT_NID,
2721 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
2722 .channel_mode = alc880_fivestack_modes,
2723 .input_mux = &alc880_capture_source,
2726 .mixers = { alc880_six_stack_mixer },
2727 .init_verbs = { alc880_volume_init_verbs,
2728 alc880_pin_6stack_init_verbs },
2729 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
2730 .dac_nids = alc880_6st_dac_nids,
2731 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
2732 .channel_mode = alc880_sixstack_modes,
2733 .input_mux = &alc880_6stack_capture_source,
2735 [ALC880_6ST_DIG] = {
2736 .mixers = { alc880_six_stack_mixer },
2737 .init_verbs = { alc880_volume_init_verbs,
2738 alc880_pin_6stack_init_verbs },
2739 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
2740 .dac_nids = alc880_6st_dac_nids,
2741 .dig_out_nid = ALC880_DIGOUT_NID,
2742 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
2743 .channel_mode = alc880_sixstack_modes,
2744 .input_mux = &alc880_6stack_capture_source,
2747 .mixers = { alc880_w810_base_mixer },
2748 .init_verbs = { alc880_volume_init_verbs,
2749 alc880_pin_w810_init_verbs,
2750 alc880_gpio2_init_verbs },
2751 .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
2752 .dac_nids = alc880_w810_dac_nids,
2753 .dig_out_nid = ALC880_DIGOUT_NID,
2754 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
2755 .channel_mode = alc880_w810_modes,
2756 .input_mux = &alc880_capture_source,
2759 .mixers = { alc880_z71v_mixer },
2760 .init_verbs = { alc880_volume_init_verbs,
2761 alc880_pin_z71v_init_verbs },
2762 .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
2763 .dac_nids = alc880_z71v_dac_nids,
2764 .dig_out_nid = ALC880_DIGOUT_NID,
2766 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
2767 .channel_mode = alc880_2_jack_modes,
2768 .input_mux = &alc880_capture_source,
2771 .mixers = { alc880_f1734_mixer },
2772 .init_verbs = { alc880_volume_init_verbs,
2773 alc880_pin_f1734_init_verbs },
2774 .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
2775 .dac_nids = alc880_f1734_dac_nids,
2777 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
2778 .channel_mode = alc880_2_jack_modes,
2779 .input_mux = &alc880_capture_source,
2782 .mixers = { alc880_asus_mixer },
2783 .init_verbs = { alc880_volume_init_verbs,
2784 alc880_pin_asus_init_verbs,
2785 alc880_gpio1_init_verbs },
2786 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2787 .dac_nids = alc880_asus_dac_nids,
2788 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2789 .channel_mode = alc880_asus_modes,
2791 .input_mux = &alc880_capture_source,
2793 [ALC880_ASUS_DIG] = {
2794 .mixers = { alc880_asus_mixer },
2795 .init_verbs = { alc880_volume_init_verbs,
2796 alc880_pin_asus_init_verbs,
2797 alc880_gpio1_init_verbs },
2798 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2799 .dac_nids = alc880_asus_dac_nids,
2800 .dig_out_nid = ALC880_DIGOUT_NID,
2801 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2802 .channel_mode = alc880_asus_modes,
2804 .input_mux = &alc880_capture_source,
2806 [ALC880_ASUS_DIG2] = {
2807 .mixers = { alc880_asus_mixer },
2808 .init_verbs = { alc880_volume_init_verbs,
2809 alc880_pin_asus_init_verbs,
2810 alc880_gpio2_init_verbs }, /* use GPIO2 */
2811 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2812 .dac_nids = alc880_asus_dac_nids,
2813 .dig_out_nid = ALC880_DIGOUT_NID,
2814 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2815 .channel_mode = alc880_asus_modes,
2817 .input_mux = &alc880_capture_source,
2819 [ALC880_ASUS_W1V] = {
2820 .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
2821 .init_verbs = { alc880_volume_init_verbs,
2822 alc880_pin_asus_init_verbs,
2823 alc880_gpio1_init_verbs },
2824 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2825 .dac_nids = alc880_asus_dac_nids,
2826 .dig_out_nid = ALC880_DIGOUT_NID,
2827 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2828 .channel_mode = alc880_asus_modes,
2830 .input_mux = &alc880_capture_source,
2832 [ALC880_UNIWILL_DIG] = {
2833 .mixers = { alc880_asus_mixer, alc880_pcbeep_mixer },
2834 .init_verbs = { alc880_volume_init_verbs,
2835 alc880_pin_asus_init_verbs },
2836 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2837 .dac_nids = alc880_asus_dac_nids,
2838 .dig_out_nid = ALC880_DIGOUT_NID,
2839 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2840 .channel_mode = alc880_asus_modes,
2842 .input_mux = &alc880_capture_source,
2844 [ALC880_UNIWILL] = {
2845 .mixers = { alc880_uniwill_mixer },
2846 .init_verbs = { alc880_volume_init_verbs,
2847 alc880_uniwill_init_verbs },
2848 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2849 .dac_nids = alc880_asus_dac_nids,
2850 .dig_out_nid = ALC880_DIGOUT_NID,
2851 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
2852 .channel_mode = alc880_threestack_modes,
2854 .input_mux = &alc880_capture_source,
2855 .unsol_event = alc880_uniwill_unsol_event,
2856 .init_hook = alc880_uniwill_automute,
2858 [ALC880_UNIWILL_P53] = {
2859 .mixers = { alc880_uniwill_p53_mixer },
2860 .init_verbs = { alc880_volume_init_verbs,
2861 alc880_uniwill_p53_init_verbs },
2862 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2863 .dac_nids = alc880_asus_dac_nids,
2864 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
2865 .channel_mode = alc880_threestack_modes,
2866 .input_mux = &alc880_capture_source,
2867 .unsol_event = alc880_uniwill_p53_unsol_event,
2868 .init_hook = alc880_uniwill_p53_hp_automute,
2870 [ALC880_FUJITSU] = {
2871 .mixers = { alc880_fujitsu_mixer,
2872 alc880_pcbeep_mixer, },
2873 .init_verbs = { alc880_volume_init_verbs,
2874 alc880_uniwill_p53_init_verbs,
2875 alc880_beep_init_verbs },
2876 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2877 .dac_nids = alc880_dac_nids,
2878 .dig_out_nid = ALC880_DIGOUT_NID,
2879 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
2880 .channel_mode = alc880_2_jack_modes,
2881 .input_mux = &alc880_capture_source,
2882 .unsol_event = alc880_uniwill_p53_unsol_event,
2883 .init_hook = alc880_uniwill_p53_hp_automute,
2886 .mixers = { alc880_three_stack_mixer },
2887 .init_verbs = { alc880_volume_init_verbs,
2888 alc880_pin_clevo_init_verbs },
2889 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2890 .dac_nids = alc880_dac_nids,
2892 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
2893 .channel_mode = alc880_threestack_modes,
2895 .input_mux = &alc880_capture_source,
2898 .mixers = { alc880_lg_mixer },
2899 .init_verbs = { alc880_volume_init_verbs,
2900 alc880_lg_init_verbs },
2901 .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids),
2902 .dac_nids = alc880_lg_dac_nids,
2903 .dig_out_nid = ALC880_DIGOUT_NID,
2904 .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes),
2905 .channel_mode = alc880_lg_ch_modes,
2907 .input_mux = &alc880_lg_capture_source,
2908 .unsol_event = alc880_lg_unsol_event,
2909 .init_hook = alc880_lg_automute,
2910 #ifdef CONFIG_SND_HDA_POWER_SAVE
2911 .loopbacks = alc880_lg_loopbacks,
2915 .mixers = { alc880_lg_lw_mixer },
2916 .init_verbs = { alc880_volume_init_verbs,
2917 alc880_lg_lw_init_verbs },
2918 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2919 .dac_nids = alc880_dac_nids,
2920 .dig_out_nid = ALC880_DIGOUT_NID,
2921 .num_channel_mode = ARRAY_SIZE(alc880_lg_lw_modes),
2922 .channel_mode = alc880_lg_lw_modes,
2923 .input_mux = &alc880_lg_lw_capture_source,
2924 .unsol_event = alc880_lg_lw_unsol_event,
2925 .init_hook = alc880_lg_lw_automute,
2927 #ifdef CONFIG_SND_DEBUG
2929 .mixers = { alc880_test_mixer },
2930 .init_verbs = { alc880_test_init_verbs },
2931 .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
2932 .dac_nids = alc880_test_dac_nids,
2933 .dig_out_nid = ALC880_DIGOUT_NID,
2934 .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
2935 .channel_mode = alc880_test_modes,
2936 .input_mux = &alc880_test_capture_source,
2942 * Automatic parse of I/O pins from the BIOS configuration
2945 #define NUM_CONTROL_ALLOC 32
2946 #define NUM_VERB_ALLOC 32
2950 ALC_CTL_WIDGET_MUTE,
2953 static struct snd_kcontrol_new alc880_control_templates[] = {
2954 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
2955 HDA_CODEC_MUTE(NULL, 0, 0, 0),
2956 HDA_BIND_MUTE(NULL, 0, 0, 0),
2959 /* add dynamic controls */
2960 static int add_control(struct alc_spec *spec, int type, const char *name,
2963 struct snd_kcontrol_new *knew;
2965 if (spec->num_kctl_used >= spec->num_kctl_alloc) {
2966 int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC;
2968 /* array + terminator */
2969 knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL);
2972 if (spec->kctl_alloc) {
2973 memcpy(knew, spec->kctl_alloc,
2974 sizeof(*knew) * spec->num_kctl_alloc);
2975 kfree(spec->kctl_alloc);
2977 spec->kctl_alloc = knew;
2978 spec->num_kctl_alloc = num;
2981 knew = &spec->kctl_alloc[spec->num_kctl_used];
2982 *knew = alc880_control_templates[type];
2983 knew->name = kstrdup(name, GFP_KERNEL);
2986 knew->private_value = val;
2987 spec->num_kctl_used++;
2991 #define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
2992 #define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
2993 #define alc880_is_multi_pin(nid) ((nid) >= 0x18)
2994 #define alc880_multi_pin_idx(nid) ((nid) - 0x18)
2995 #define alc880_is_input_pin(nid) ((nid) >= 0x18)
2996 #define alc880_input_pin_idx(nid) ((nid) - 0x18)
2997 #define alc880_idx_to_dac(nid) ((nid) + 0x02)
2998 #define alc880_dac_to_idx(nid) ((nid) - 0x02)
2999 #define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
3000 #define alc880_idx_to_selector(nid) ((nid) + 0x10)
3001 #define ALC880_PIN_CD_NID 0x1c
3003 /* fill in the dac_nids table from the parsed pin configuration */
3004 static int alc880_auto_fill_dac_nids(struct alc_spec *spec,
3005 const struct auto_pin_cfg *cfg)
3011 memset(assigned, 0, sizeof(assigned));
3012 spec->multiout.dac_nids = spec->private_dac_nids;
3014 /* check the pins hardwired to audio widget */
3015 for (i = 0; i < cfg->line_outs; i++) {
3016 nid = cfg->line_out_pins[i];
3017 if (alc880_is_fixed_pin(nid)) {
3018 int idx = alc880_fixed_pin_idx(nid);
3019 spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
3023 /* left pins can be connect to any audio widget */
3024 for (i = 0; i < cfg->line_outs; i++) {
3025 nid = cfg->line_out_pins[i];
3026 if (alc880_is_fixed_pin(nid))
3028 /* search for an empty channel */
3029 for (j = 0; j < cfg->line_outs; j++) {
3031 spec->multiout.dac_nids[i] =
3032 alc880_idx_to_dac(j);
3038 spec->multiout.num_dacs = cfg->line_outs;
3042 /* add playback controls from the parsed DAC table */
3043 static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
3044 const struct auto_pin_cfg *cfg)
3047 static const char *chname[4] = {
3048 "Front", "Surround", NULL /*CLFE*/, "Side"
3053 for (i = 0; i < cfg->line_outs; i++) {
3054 if (!spec->multiout.dac_nids[i])
3056 nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
3059 err = add_control(spec, ALC_CTL_WIDGET_VOL,
3060 "Center Playback Volume",
3061 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
3065 err = add_control(spec, ALC_CTL_WIDGET_VOL,
3066 "LFE Playback Volume",
3067 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
3071 err = add_control(spec, ALC_CTL_BIND_MUTE,
3072 "Center Playback Switch",
3073 HDA_COMPOSE_AMP_VAL(nid, 1, 2,
3077 err = add_control(spec, ALC_CTL_BIND_MUTE,
3078 "LFE Playback Switch",
3079 HDA_COMPOSE_AMP_VAL(nid, 2, 2,
3084 sprintf(name, "%s Playback Volume", chname[i]);
3085 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
3086 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
3090 sprintf(name, "%s Playback Switch", chname[i]);
3091 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
3092 HDA_COMPOSE_AMP_VAL(nid, 3, 2,
3101 /* add playback controls for speaker and HP outputs */
3102 static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
3112 if (alc880_is_fixed_pin(pin)) {
3113 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
3114 /* specify the DAC as the extra output */
3115 if (!spec->multiout.hp_nid)
3116 spec->multiout.hp_nid = nid;
3118 spec->multiout.extra_out_nid[0] = nid;
3119 /* control HP volume/switch on the output mixer amp */
3120 nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
3121 sprintf(name, "%s Playback Volume", pfx);
3122 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
3123 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
3126 sprintf(name, "%s Playback Switch", pfx);
3127 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
3128 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
3131 } else if (alc880_is_multi_pin(pin)) {
3132 /* set manual connection */
3133 /* we have only a switch on HP-out PIN */
3134 sprintf(name, "%s Playback Switch", pfx);
3135 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
3136 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
3143 /* create input playback/capture controls for the given pin */
3144 static int new_analog_input(struct alc_spec *spec, hda_nid_t pin,
3145 const char *ctlname,
3146 int idx, hda_nid_t mix_nid)
3151 sprintf(name, "%s Playback Volume", ctlname);
3152 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
3153 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
3156 sprintf(name, "%s Playback Switch", ctlname);
3157 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
3158 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
3164 /* create playback/capture controls for input pins */
3165 static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec,
3166 const struct auto_pin_cfg *cfg)
3168 struct hda_input_mux *imux = &spec->private_imux;
3171 for (i = 0; i < AUTO_PIN_LAST; i++) {
3172 if (alc880_is_input_pin(cfg->input_pins[i])) {
3173 idx = alc880_input_pin_idx(cfg->input_pins[i]);
3174 err = new_analog_input(spec, cfg->input_pins[i],
3175 auto_pin_cfg_labels[i],
3179 imux->items[imux->num_items].label =
3180 auto_pin_cfg_labels[i];
3181 imux->items[imux->num_items].index =
3182 alc880_input_pin_idx(cfg->input_pins[i]);
3189 static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
3190 hda_nid_t nid, int pin_type,
3194 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
3196 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
3198 /* need the manual connection? */
3199 if (alc880_is_multi_pin(nid)) {
3200 struct alc_spec *spec = codec->spec;
3201 int idx = alc880_multi_pin_idx(nid);
3202 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
3203 AC_VERB_SET_CONNECT_SEL,
3204 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
3208 static int get_pin_type(int line_out_type)
3210 if (line_out_type == AUTO_PIN_HP_OUT)
3216 static void alc880_auto_init_multi_out(struct hda_codec *codec)
3218 struct alc_spec *spec = codec->spec;
3221 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
3222 for (i = 0; i < spec->autocfg.line_outs; i++) {
3223 hda_nid_t nid = spec->autocfg.line_out_pins[i];
3224 int pin_type = get_pin_type(spec->autocfg.line_out_type);
3225 alc880_auto_set_output_and_unmute(codec, nid, pin_type, i);
3229 static void alc880_auto_init_extra_out(struct hda_codec *codec)
3231 struct alc_spec *spec = codec->spec;
3234 pin = spec->autocfg.speaker_pins[0];
3235 if (pin) /* connect to front */
3236 alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
3237 pin = spec->autocfg.hp_pins[0];
3238 if (pin) /* connect to front */
3239 alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
3242 static void alc880_auto_init_analog_input(struct hda_codec *codec)
3244 struct alc_spec *spec = codec->spec;
3247 for (i = 0; i < AUTO_PIN_LAST; i++) {
3248 hda_nid_t nid = spec->autocfg.input_pins[i];
3249 if (alc880_is_input_pin(nid)) {
3250 snd_hda_codec_write(codec, nid, 0,
3251 AC_VERB_SET_PIN_WIDGET_CONTROL,
3252 i <= AUTO_PIN_FRONT_MIC ?
3253 PIN_VREF80 : PIN_IN);
3254 if (nid != ALC880_PIN_CD_NID)
3255 snd_hda_codec_write(codec, nid, 0,
3256 AC_VERB_SET_AMP_GAIN_MUTE,
3262 /* parse the BIOS configuration and set up the alc_spec */
3263 /* return 1 if successful, 0 if the proper config is not found,
3264 * or a negative error code
3266 static int alc880_parse_auto_config(struct hda_codec *codec)
3268 struct alc_spec *spec = codec->spec;
3270 static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
3272 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
3276 if (!spec->autocfg.line_outs)
3277 return 0; /* can't find valid BIOS pin config */
3279 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
3282 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
3285 err = alc880_auto_create_extra_out(spec,
3286 spec->autocfg.speaker_pins[0],
3290 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
3294 err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
3298 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
3300 if (spec->autocfg.dig_out_pin)
3301 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
3302 if (spec->autocfg.dig_in_pin)
3303 spec->dig_in_nid = ALC880_DIGIN_NID;
3305 if (spec->kctl_alloc)
3306 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
3308 spec->init_verbs[spec->num_init_verbs++] = alc880_volume_init_verbs;
3310 spec->num_mux_defs = 1;
3311 spec->input_mux = &spec->private_imux;
3316 /* additional initialization for auto-configuration model */
3317 static void alc880_auto_init(struct hda_codec *codec)
3319 alc880_auto_init_multi_out(codec);
3320 alc880_auto_init_extra_out(codec);
3321 alc880_auto_init_analog_input(codec);
3325 * OK, here we have finally the patch for ALC880
3328 static int patch_alc880(struct hda_codec *codec)
3330 struct alc_spec *spec;
3334 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
3340 board_config = snd_hda_check_board_config(codec, ALC880_MODEL_LAST,
3343 if (board_config < 0) {
3344 printk(KERN_INFO "hda_codec: Unknown model for ALC880, "
3345 "trying auto-probe from BIOS...\n");
3346 board_config = ALC880_AUTO;
3349 if (board_config == ALC880_AUTO) {
3350 /* automatic parse from the BIOS config */
3351 err = alc880_parse_auto_config(codec);
3357 "hda_codec: Cannot set up configuration "
3358 "from BIOS. Using 3-stack mode...\n");
3359 board_config = ALC880_3ST;
3363 if (board_config != ALC880_AUTO)
3364 setup_preset(spec, &alc880_presets[board_config]);
3366 spec->stream_name_analog = "ALC880 Analog";
3367 spec->stream_analog_playback = &alc880_pcm_analog_playback;
3368 spec->stream_analog_capture = &alc880_pcm_analog_capture;
3370 spec->stream_name_digital = "ALC880 Digital";
3371 spec->stream_digital_playback = &alc880_pcm_digital_playback;
3372 spec->stream_digital_capture = &alc880_pcm_digital_capture;
3374 if (!spec->adc_nids && spec->input_mux) {
3375 /* check whether NID 0x07 is valid */
3376 unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
3378 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
3379 if (wcap != AC_WID_AUD_IN) {
3380 spec->adc_nids = alc880_adc_nids_alt;
3381 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
3382 spec->mixers[spec->num_mixers] =
3383 alc880_capture_alt_mixer;
3386 spec->adc_nids = alc880_adc_nids;
3387 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
3388 spec->mixers[spec->num_mixers] = alc880_capture_mixer;
3393 codec->patch_ops = alc_patch_ops;
3394 if (board_config == ALC880_AUTO)
3395 spec->init_hook = alc880_auto_init;
3396 #ifdef CONFIG_SND_HDA_POWER_SAVE
3397 if (!spec->loopback.amplist)
3398 spec->loopback.amplist = alc880_loopbacks;
3409 static hda_nid_t alc260_dac_nids[1] = {
3414 static hda_nid_t alc260_adc_nids[1] = {
3419 static hda_nid_t alc260_adc_nids_alt[1] = {
3424 static hda_nid_t alc260_hp_adc_nids[2] = {
3429 /* NIDs used when simultaneous access to both ADCs makes sense. Note that
3430 * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
3432 static hda_nid_t alc260_dual_adc_nids[2] = {
3437 #define ALC260_DIGOUT_NID 0x03
3438 #define ALC260_DIGIN_NID 0x06
3440 static struct hda_input_mux alc260_capture_source = {
3444 { "Front Mic", 0x1 },
3450 /* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
3451 * headphone jack and the internal CD lines since these are the only pins at
3452 * which audio can appear. For flexibility, also allow the option of
3453 * recording the mixer output on the second ADC (ADC0 doesn't have a
3454 * connection to the mixer output).
3456 static struct hda_input_mux alc260_fujitsu_capture_sources[2] = {
3460 { "Mic/Line", 0x0 },
3462 { "Headphone", 0x2 },
3468 { "Mic/Line", 0x0 },
3470 { "Headphone", 0x2 },
3477 /* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to
3478 * the Fujitsu S702x, but jacks are marked differently.
3480 static struct hda_input_mux alc260_acer_capture_sources[2] = {
3487 { "Headphone", 0x5 },
3496 { "Headphone", 0x6 },
3502 * This is just place-holder, so there's something for alc_build_pcms to look
3503 * at when it calculates the maximum number of channels. ALC260 has no mixer
3504 * element which allows changing the channel mode, so the verb list is
3507 static struct hda_channel_mode alc260_modes[1] = {
3512 /* Mixer combinations
3514 * basic: base_output + input + pc_beep + capture
3515 * HP: base_output + input + capture_alt
3516 * HP_3013: hp_3013 + input + capture
3517 * fujitsu: fujitsu + capture
3518 * acer: acer + capture
3521 static struct snd_kcontrol_new alc260_base_output_mixer[] = {
3522 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3523 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
3524 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
3525 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
3526 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
3527 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
3531 static struct snd_kcontrol_new alc260_input_mixer[] = {
3532 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3533 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
3534 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
3535 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
3536 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
3537 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
3538 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
3539 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
3543 static struct snd_kcontrol_new alc260_pc_beep_mixer[] = {
3544 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x07, 0x05, HDA_INPUT),
3545 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x07, 0x05, HDA_INPUT),
3549 static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
3550 HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
3551 HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
3552 HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
3553 HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
3554 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3555 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
3556 HDA_CODEC_VOLUME_MONO("iSpeaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
3557 HDA_CODEC_MUTE_MONO("iSpeaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
3561 /* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12,
3562 * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10.
3564 static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
3565 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3566 HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
3567 ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
3568 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3569 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
3570 HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
3571 HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
3572 ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
3573 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
3574 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
3575 HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
3576 HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x09, 2, HDA_INPUT),
3580 /* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current
3581 * versions of the ALC260 don't act on requests to enable mic bias from NID
3582 * 0x0f (used to drive the headphone jack in these laptops). The ALC260
3583 * datasheet doesn't mention this restriction. At this stage it's not clear
3584 * whether this behaviour is intentional or is a hardware bug in chip
3585 * revisions available in early 2006. Therefore for now allow the
3586 * "Headphone Jack Mode" control to span all choices, but if it turns out
3587 * that the lack of mic bias for this NID is intentional we could change the
3588 * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
3590 * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006
3591 * don't appear to make the mic bias available from the "line" jack, even
3592 * though the NID used for this jack (0x14) can supply it. The theory is
3593 * that perhaps Acer have included blocking capacitors between the ALC260
3594 * and the output jack. If this turns out to be the case for all such
3595 * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
3596 * to ALC_PIN_DIR_INOUT_NOMICBIAS.
3598 * The C20x Tablet series have a mono internal speaker which is controlled
3599 * via the chip's Mono sum widget and pin complex, so include the necessary
3600 * controls for such models. On models without a "mono speaker" the control
3601 * won't do anything.
3603 static struct snd_kcontrol_new alc260_acer_mixer[] = {
3604 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3605 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
3606 ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
3607 HDA_CODEC_VOLUME_MONO("Mono Speaker Playback Volume", 0x0a, 1, 0x0,
3609 HDA_BIND_MUTE_MONO("Mono Speaker Playback Switch", 0x0a, 1, 2,
3611 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3612 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
3613 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
3614 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
3615 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
3616 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
3617 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
3618 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
3619 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
3620 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
3624 /* Packard bell V7900 ALC260 pin usage: HP = 0x0f, Mic jack = 0x12,
3625 * Line In jack = 0x14, CD audio = 0x16, pc beep = 0x17.
3627 static struct snd_kcontrol_new alc260_will_mixer[] = {
3628 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3629 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
3630 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
3631 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
3632 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
3633 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
3634 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
3635 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
3636 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3637 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
3638 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
3639 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
3643 /* Replacer 672V ALC260 pin usage: Mic jack = 0x12,
3644 * Line In jack = 0x14, ATAPI Mic = 0x13, speaker = 0x0f.
3646 static struct snd_kcontrol_new alc260_replacer_672v_mixer[] = {
3647 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3648 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
3649 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
3650 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
3651 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
3652 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x07, 0x1, HDA_INPUT),
3653 HDA_CODEC_MUTE("ATATI Mic Playback Switch", 0x07, 0x1, HDA_INPUT),
3654 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
3655 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
3656 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
3660 /* capture mixer elements */
3661 static struct snd_kcontrol_new alc260_capture_mixer[] = {
3662 HDA_CODEC_VOLUME("Capture Volume", 0x04, 0x0, HDA_INPUT),
3663 HDA_CODEC_MUTE("Capture Switch", 0x04, 0x0, HDA_INPUT),
3664 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x05, 0x0, HDA_INPUT),
3665 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x05, 0x0, HDA_INPUT),
3667 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3668 /* The multiple "Capture Source" controls confuse alsamixer
3669 * So call somewhat different..
3670 * FIXME: the controls appear in the "playback" view!
3672 /* .name = "Capture Source", */
3673 .name = "Input Source",
3675 .info = alc_mux_enum_info,
3676 .get = alc_mux_enum_get,
3677 .put = alc_mux_enum_put,
3682 static struct snd_kcontrol_new alc260_capture_alt_mixer[] = {
3683 HDA_CODEC_VOLUME("Capture Volume", 0x05, 0x0, HDA_INPUT),
3684 HDA_CODEC_MUTE("Capture Switch", 0x05, 0x0, HDA_INPUT),
3686 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3687 /* The multiple "Capture Source" controls confuse alsamixer
3688 * So call somewhat different..
3689 * FIXME: the controls appear in the "playback" view!
3691 /* .name = "Capture Source", */
3692 .name = "Input Source",
3694 .info = alc_mux_enum_info,
3695 .get = alc_mux_enum_get,
3696 .put = alc_mux_enum_put,
3702 * initialization verbs
3704 static struct hda_verb alc260_init_verbs[] = {
3705 /* Line In pin widget for input */
3706 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3707 /* CD pin widget for input */
3708 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3709 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3710 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3711 /* Mic2 (front panel) pin widget for input and vref at 80% */
3712 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3713 /* LINE-2 is used for line-out in rear */
3714 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3715 /* select line-out */
3716 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
3718 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3720 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3722 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3723 /* mute capture amp left and right */
3724 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3725 /* set connection select to line in (default select for this ADC) */
3726 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
3727 /* mute capture amp left and right */
3728 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3729 /* set connection select to line in (default select for this ADC) */
3730 {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
3731 /* set vol=0 Line-Out mixer amp left and right */
3732 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3733 /* unmute pin widget amp left and right (no gain on this amp) */
3734 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3735 /* set vol=0 HP mixer amp left and right */
3736 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3737 /* unmute pin widget amp left and right (no gain on this amp) */
3738 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3739 /* set vol=0 Mono mixer amp left and right */
3740 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3741 /* unmute pin widget amp left and right (no gain on this amp) */
3742 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3743 /* unmute LINE-2 out pin */
3744 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3745 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
3748 /* mute analog inputs */
3749 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3750 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3751 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
3752 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
3753 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
3754 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
3755 /* mute Front out path */
3756 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3757 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3758 /* mute Headphone out path */
3759 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3760 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3761 /* mute Mono out path */
3762 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3763 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3767 #if 0 /* should be identical with alc260_init_verbs? */
3768 static struct hda_verb alc260_hp_init_verbs[] = {
3769 /* Headphone and output */
3770 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
3772 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
3773 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3774 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
3775 /* Mic2 (front panel) pin widget for input and vref at 80% */
3776 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
3777 /* Line In pin widget for input */
3778 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
3779 /* Line-2 pin widget for output */
3780 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
3781 /* CD pin widget for input */
3782 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
3783 /* unmute amp left and right */
3784 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
3785 /* set connection select to line in (default select for this ADC) */
3786 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
3787 /* unmute Line-Out mixer amp left and right (volume = 0) */
3788 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
3789 /* mute pin widget amp left and right (no gain on this amp) */
3790 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
3791 /* unmute HP mixer amp left and right (volume = 0) */
3792 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
3793 /* mute pin widget amp left and right (no gain on this amp) */
3794 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
3795 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
3798 /* mute analog inputs */
3799 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3800 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3801 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
3802 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
3803 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
3804 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
3805 /* Unmute Front out path */
3806 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3807 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3808 /* Unmute Headphone out path */
3809 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3810 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3811 /* Unmute Mono out path */
3812 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3813 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3818 static struct hda_verb alc260_hp_3013_init_verbs[] = {
3819 /* Line out and output */
3820 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
3822 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
3823 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3824 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
3825 /* Mic2 (front panel) pin widget for input and vref at 80% */
3826 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
3827 /* Line In pin widget for input */
3828 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
3829 /* Headphone pin widget for output */
3830 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
3831 /* CD pin widget for input */
3832 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
3833 /* unmute amp left and right */
3834 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
3835 /* set connection select to line in (default select for this ADC) */
3836 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
3837 /* unmute Line-Out mixer amp left and right (volume = 0) */
3838 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
3839 /* mute pin widget amp left and right (no gain on this amp) */
3840 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
3841 /* unmute HP mixer amp left and right (volume = 0) */
3842 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
3843 /* mute pin widget amp left and right (no gain on this amp) */
3844 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
3845 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
3848 /* mute analog inputs */
3849 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3850 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3851 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
3852 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
3853 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
3854 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
3855 /* Unmute Front out path */
3856 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3857 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3858 /* Unmute Headphone out path */
3859 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3860 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3861 /* Unmute Mono out path */
3862 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3863 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3867 /* Initialisation sequence for ALC260 as configured in Fujitsu S702x
3868 * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD
3869 * audio = 0x16, internal speaker = 0x10.
3871 static struct hda_verb alc260_fujitsu_init_verbs[] = {
3872 /* Disable all GPIOs */
3873 {0x01, AC_VERB_SET_GPIO_MASK, 0},
3874 /* Internal speaker is connected to headphone pin */
3875 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3876 /* Headphone/Line-out jack connects to Line1 pin; make it an output */
3877 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3878 /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
3879 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3880 /* Ensure all other unused pins are disabled and muted. */
3881 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3882 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3883 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3884 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3885 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3886 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3887 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3888 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3890 /* Disable digital (SPDIF) pins */
3891 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
3892 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
3894 /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
3895 * when acting as an output.
3897 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
3899 /* Start with output sum widgets muted and their output gains at min */
3900 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3901 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3902 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3903 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3904 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3905 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3906 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3907 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3908 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3910 /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
3911 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3912 /* Unmute Line1 pin widget output buffer since it starts as an output.
3913 * If the pin mode is changed by the user the pin mode control will
3914 * take care of enabling the pin's input/output buffers as needed.
3915 * Therefore there's no need to enable the input buffer at this
3918 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3919 /* Unmute input buffer of pin widget used for Line-in (no equiv
3922 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3924 /* Mute capture amp left and right */
3925 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3926 /* Set ADC connection select to match default mixer setting - line
3929 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
3931 /* Do the same for the second ADC: mute capture input amp and
3932 * set ADC connection to line in (on mic1 pin)
3934 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3935 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
3937 /* Mute all inputs to mixer widget (even unconnected ones) */
3938 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
3939 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
3940 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
3941 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
3942 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
3943 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
3944 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
3945 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
3950 /* Initialisation sequence for ALC260 as configured in Acer TravelMate and
3951 * similar laptops (adapted from Fujitsu init verbs).
3953 static struct hda_verb alc260_acer_init_verbs[] = {
3954 /* On TravelMate laptops, GPIO 0 enables the internal speaker and
3955 * the headphone jack. Turn this on and rely on the standard mute
3956 * methods whenever the user wants to turn these outputs off.
3958 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
3959 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
3960 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
3961 /* Internal speaker/Headphone jack is connected to Line-out pin */
3962 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3963 /* Internal microphone/Mic jack is connected to Mic1 pin */
3964 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
3965 /* Line In jack is connected to Line1 pin */
3966 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3967 /* Some Acers (eg: C20x Tablets) use Mono pin for internal speaker */
3968 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3969 /* Ensure all other unused pins are disabled and muted. */
3970 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3971 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3972 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3973 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3974 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3975 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3976 /* Disable digital (SPDIF) pins */
3977 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
3978 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
3980 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
3981 * bus when acting as outputs.
3983 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
3984 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
3986 /* Start with output sum widgets muted and their output gains at min */
3987 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3988 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3989 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3990 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3991 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3992 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3993 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3994 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3995 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3997 /* Unmute Line-out pin widget amp left and right
3998 * (no equiv mixer ctrl)
4000 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4001 /* Unmute mono pin widget amp output (no equiv mixer ctrl) */
4002 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4003 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
4004 * inputs. If the pin mode is changed by the user the pin mode control
4005 * will take care of enabling the pin's input/output buffers as needed.
4006 * Therefore there's no need to enable the input buffer at this
4009 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4010 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4012 /* Mute capture amp left and right */
4013 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4014 /* Set ADC connection select to match default mixer setting - mic
4017 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
4019 /* Do similar with the second ADC: mute capture input amp and
4020 * set ADC connection to mic to match ALSA's default state.
4022 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4023 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
4025 /* Mute all inputs to mixer widget (even unconnected ones) */
4026 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
4027 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
4028 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
4029 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
4030 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
4031 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
4032 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
4033 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
4038 static struct hda_verb alc260_will_verbs[] = {
4039 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4040 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x00},
4041 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
4042 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
4043 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
4044 {0x1a, AC_VERB_SET_PROC_COEF, 0x3040},
4048 static struct hda_verb alc260_replacer_672v_verbs[] = {
4049 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
4050 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
4051 {0x1a, AC_VERB_SET_PROC_COEF, 0x3050},
4053 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
4054 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
4055 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
4057 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
4061 /* toggle speaker-output according to the hp-jack state */
4062 static void alc260_replacer_672v_automute(struct hda_codec *codec)
4064 unsigned int present;
4066 /* speaker --> GPIO Data 0, hp or spdif --> GPIO data 1 */
4067 present = snd_hda_codec_read(codec, 0x0f, 0,
4068 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
4070 snd_hda_codec_write_cache(codec, 0x01, 0,
4071 AC_VERB_SET_GPIO_DATA, 1);
4072 snd_hda_codec_write_cache(codec, 0x0f, 0,
4073 AC_VERB_SET_PIN_WIDGET_CONTROL,
4076 snd_hda_codec_write_cache(codec, 0x01, 0,
4077 AC_VERB_SET_GPIO_DATA, 0);
4078 snd_hda_codec_write_cache(codec, 0x0f, 0,
4079 AC_VERB_SET_PIN_WIDGET_CONTROL,
4084 static void alc260_replacer_672v_unsol_event(struct hda_codec *codec,
4087 if ((res >> 26) == ALC880_HP_EVENT)
4088 alc260_replacer_672v_automute(codec);
4091 /* Test configuration for debugging, modelled after the ALC880 test
4094 #ifdef CONFIG_SND_DEBUG
4095 static hda_nid_t alc260_test_dac_nids[1] = {
4098 static hda_nid_t alc260_test_adc_nids[2] = {
4101 /* For testing the ALC260, each input MUX needs its own definition since
4102 * the signal assignments are different. This assumes that the first ADC
4105 static struct hda_input_mux alc260_test_capture_sources[2] = {
4109 { "MIC1 pin", 0x0 },
4110 { "MIC2 pin", 0x1 },
4111 { "LINE1 pin", 0x2 },
4112 { "LINE2 pin", 0x3 },
4114 { "LINE-OUT pin", 0x5 },
4115 { "HP-OUT pin", 0x6 },
4121 { "MIC1 pin", 0x0 },
4122 { "MIC2 pin", 0x1 },
4123 { "LINE1 pin", 0x2 },
4124 { "LINE2 pin", 0x3 },
4127 { "LINE-OUT pin", 0x6 },
4128 { "HP-OUT pin", 0x7 },
4132 static struct snd_kcontrol_new alc260_test_mixer[] = {
4133 /* Output driver widgets */
4134 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
4135 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
4136 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4137 HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
4138 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4139 HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
4141 /* Modes for retasking pin widgets
4142 * Note: the ALC260 doesn't seem to act on requests to enable mic
4143 * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't
4144 * mention this restriction. At this stage it's not clear whether
4145 * this behaviour is intentional or is a hardware bug in chip
4146 * revisions available at least up until early 2006. Therefore for
4147 * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all
4148 * choices, but if it turns out that the lack of mic bias for these
4149 * NIDs is intentional we could change their modes from
4150 * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
4152 ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
4153 ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
4154 ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
4155 ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
4156 ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
4157 ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
4159 /* Loopback mixer controls */
4160 HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
4161 HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
4162 HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
4163 HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
4164 HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
4165 HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
4166 HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
4167 HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
4168 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4169 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4170 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
4171 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
4172 HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
4173 HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
4174 HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
4175 HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
4177 /* Controls for GPIO pins, assuming they are configured as outputs */
4178 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
4179 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
4180 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
4181 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
4183 /* Switches to allow the digital IO pins to be enabled. The datasheet
4184 * is ambigious as to which NID is which; testing on laptops which
4185 * make this output available should provide clarification.
4187 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
4188 ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
4192 static struct hda_verb alc260_test_init_verbs[] = {
4193 /* Enable all GPIOs as outputs with an initial value of 0 */
4194 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
4195 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
4196 {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
4198 /* Enable retasking pins as output, initially without power amp */
4199 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4200 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4201 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4202 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4203 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4204 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4206 /* Disable digital (SPDIF) pins initially, but users can enable
4207 * them via a mixer switch. In the case of SPDIF-out, this initverb
4208 * payload also sets the generation to 0, output to be in "consumer"
4209 * PCM format, copyright asserted, no pre-emphasis and no validity
4212 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
4213 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
4215 /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
4216 * OUT1 sum bus when acting as an output.
4218 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
4219 {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
4220 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
4221 {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
4223 /* Start with output sum widgets muted and their output gains at min */
4224 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4225 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4226 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4227 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4228 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4229 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4230 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4231 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4232 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4234 /* Unmute retasking pin widget output buffers since the default
4235 * state appears to be output. As the pin mode is changed by the
4236 * user the pin mode control will take care of enabling the pin's
4237 * input/output buffers as needed.
4239 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4240 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4241 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4242 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4243 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4244 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4245 /* Also unmute the mono-out pin widget */
4246 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4248 /* Mute capture amp left and right */
4249 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4250 /* Set ADC connection select to match default mixer setting (mic1
4253 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
4255 /* Do the same for the second ADC: mute capture input amp and
4256 * set ADC connection to mic1 pin
4258 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4259 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
4261 /* Mute all inputs to mixer widget (even unconnected ones) */
4262 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
4263 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
4264 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
4265 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
4266 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
4267 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
4268 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
4269 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
4275 static struct hda_pcm_stream alc260_pcm_analog_playback = {
4281 static struct hda_pcm_stream alc260_pcm_analog_capture = {
4287 #define alc260_pcm_digital_playback alc880_pcm_digital_playback
4288 #define alc260_pcm_digital_capture alc880_pcm_digital_capture
4291 * for BIOS auto-configuration
4294 static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
4298 unsigned long vol_val, sw_val;
4302 if (nid >= 0x0f && nid < 0x11) {
4303 nid_vol = nid - 0x7;
4304 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
4305 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
4306 } else if (nid == 0x11) {
4307 nid_vol = nid - 0x7;
4308 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
4309 sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
4310 } else if (nid >= 0x12 && nid <= 0x15) {
4312 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
4313 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
4317 snprintf(name, sizeof(name), "%s Playback Volume", pfx);
4318 err = add_control(spec, ALC_CTL_WIDGET_VOL, name, vol_val);
4321 snprintf(name, sizeof(name), "%s Playback Switch", pfx);
4322 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, sw_val);
4328 /* add playback controls from the parsed DAC table */
4329 static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
4330 const struct auto_pin_cfg *cfg)
4335 spec->multiout.num_dacs = 1;
4336 spec->multiout.dac_nids = spec->private_dac_nids;
4337 spec->multiout.dac_nids[0] = 0x02;
4339 nid = cfg->line_out_pins[0];
4341 err = alc260_add_playback_controls(spec, nid, "Front");
4346 nid = cfg->speaker_pins[0];
4348 err = alc260_add_playback_controls(spec, nid, "Speaker");
4353 nid = cfg->hp_pins[0];
4355 err = alc260_add_playback_controls(spec, nid, "Headphone");
4362 /* create playback/capture controls for input pins */
4363 static int alc260_auto_create_analog_input_ctls(struct alc_spec *spec,
4364 const struct auto_pin_cfg *cfg)
4366 struct hda_input_mux *imux = &spec->private_imux;
4369 for (i = 0; i < AUTO_PIN_LAST; i++) {
4370 if (cfg->input_pins[i] >= 0x12) {
4371 idx = cfg->input_pins[i] - 0x12;
4372 err = new_analog_input(spec, cfg->input_pins[i],
4373 auto_pin_cfg_labels[i], idx,
4377 imux->items[imux->num_items].label =
4378 auto_pin_cfg_labels[i];
4379 imux->items[imux->num_items].index = idx;
4382 if (cfg->input_pins[i] >= 0x0f && cfg->input_pins[i] <= 0x10){
4383 idx = cfg->input_pins[i] - 0x09;
4384 err = new_analog_input(spec, cfg->input_pins[i],
4385 auto_pin_cfg_labels[i], idx,
4389 imux->items[imux->num_items].label =
4390 auto_pin_cfg_labels[i];
4391 imux->items[imux->num_items].index = idx;
4398 static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
4399 hda_nid_t nid, int pin_type,
4403 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4405 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
4407 /* need the manual connection? */
4409 int idx = nid - 0x12;
4410 snd_hda_codec_write(codec, idx + 0x0b, 0,
4411 AC_VERB_SET_CONNECT_SEL, sel_idx);
4415 static void alc260_auto_init_multi_out(struct hda_codec *codec)
4417 struct alc_spec *spec = codec->spec;
4420 alc_subsystem_id(codec, 0x10, 0x15, 0x0f);
4421 nid = spec->autocfg.line_out_pins[0];
4423 int pin_type = get_pin_type(spec->autocfg.line_out_type);
4424 alc260_auto_set_output_and_unmute(codec, nid, pin_type, 0);
4427 nid = spec->autocfg.speaker_pins[0];
4429 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
4431 nid = spec->autocfg.hp_pins[0];
4433 alc260_auto_set_output_and_unmute(codec, nid, PIN_HP, 0);
4436 #define ALC260_PIN_CD_NID 0x16
4437 static void alc260_auto_init_analog_input(struct hda_codec *codec)
4439 struct alc_spec *spec = codec->spec;
4442 for (i = 0; i < AUTO_PIN_LAST; i++) {
4443 hda_nid_t nid = spec->autocfg.input_pins[i];
4445 snd_hda_codec_write(codec, nid, 0,
4446 AC_VERB_SET_PIN_WIDGET_CONTROL,
4447 i <= AUTO_PIN_FRONT_MIC ?
4448 PIN_VREF80 : PIN_IN);
4449 if (nid != ALC260_PIN_CD_NID)
4450 snd_hda_codec_write(codec, nid, 0,
4451 AC_VERB_SET_AMP_GAIN_MUTE,
4458 * generic initialization of ADC, input mixers and output mixers
4460 static struct hda_verb alc260_volume_init_verbs[] = {
4462 * Unmute ADC0-1 and set the default input to mic-in
4464 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
4465 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4466 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
4467 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4469 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
4471 * Note: PASD motherboards uses the Line In 2 as the input for
4472 * front panel mic (mic 2)
4474 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
4475 /* mute analog inputs */
4476 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4477 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4478 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4479 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4480 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
4483 * Set up output mixers (0x08 - 0x0a)
4485 /* set vol=0 to output mixers */
4486 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4487 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4488 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4489 /* set up input amps for analog loopback */
4490 /* Amp Indices: DAC = 0, mixer = 1 */
4491 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4492 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4493 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4494 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4495 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4496 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4501 static int alc260_parse_auto_config(struct hda_codec *codec)
4503 struct alc_spec *spec = codec->spec;
4506 static hda_nid_t alc260_ignore[] = { 0x17, 0 };
4508 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
4512 err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg);
4515 if (!spec->kctl_alloc)
4516 return 0; /* can't find valid BIOS pin config */
4517 err = alc260_auto_create_analog_input_ctls(spec, &spec->autocfg);
4521 spec->multiout.max_channels = 2;
4523 if (spec->autocfg.dig_out_pin)
4524 spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
4525 if (spec->kctl_alloc)
4526 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
4528 spec->init_verbs[spec->num_init_verbs++] = alc260_volume_init_verbs;
4530 spec->num_mux_defs = 1;
4531 spec->input_mux = &spec->private_imux;
4533 /* check whether NID 0x04 is valid */
4534 wcap = get_wcaps(codec, 0x04);
4535 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
4536 if (wcap != AC_WID_AUD_IN) {
4537 spec->adc_nids = alc260_adc_nids_alt;
4538 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
4539 spec->mixers[spec->num_mixers] = alc260_capture_alt_mixer;
4541 spec->adc_nids = alc260_adc_nids;
4542 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
4543 spec->mixers[spec->num_mixers] = alc260_capture_mixer;
4550 /* additional initialization for auto-configuration model */
4551 static void alc260_auto_init(struct hda_codec *codec)
4553 alc260_auto_init_multi_out(codec);
4554 alc260_auto_init_analog_input(codec);
4557 #ifdef CONFIG_SND_HDA_POWER_SAVE
4558 static struct hda_amp_list alc260_loopbacks[] = {
4559 { 0x07, HDA_INPUT, 0 },
4560 { 0x07, HDA_INPUT, 1 },
4561 { 0x07, HDA_INPUT, 2 },
4562 { 0x07, HDA_INPUT, 3 },
4563 { 0x07, HDA_INPUT, 4 },
4569 * ALC260 configurations
4571 static const char *alc260_models[ALC260_MODEL_LAST] = {
4572 [ALC260_BASIC] = "basic",
4574 [ALC260_HP_3013] = "hp-3013",
4575 [ALC260_FUJITSU_S702X] = "fujitsu",
4576 [ALC260_ACER] = "acer",
4577 [ALC260_WILL] = "will",
4578 [ALC260_REPLACER_672V] = "replacer",
4579 #ifdef CONFIG_SND_DEBUG
4580 [ALC260_TEST] = "test",
4582 [ALC260_AUTO] = "auto",
4585 static struct snd_pci_quirk alc260_cfg_tbl[] = {
4586 SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER),
4587 SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER),
4588 SND_PCI_QUIRK(0x103c, 0x2808, "HP d5700", ALC260_HP_3013),
4589 SND_PCI_QUIRK(0x103c, 0x280a, "HP d5750", ALC260_HP_3013),
4590 SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013),
4591 SND_PCI_QUIRK(0x103c, 0x3011, "HP", ALC260_HP),
4592 SND_PCI_QUIRK(0x103c, 0x3012, "HP", ALC260_HP_3013),
4593 SND_PCI_QUIRK(0x103c, 0x3013, "HP", ALC260_HP_3013),
4594 SND_PCI_QUIRK(0x103c, 0x3014, "HP", ALC260_HP),
4595 SND_PCI_QUIRK(0x103c, 0x3015, "HP", ALC260_HP),
4596 SND_PCI_QUIRK(0x103c, 0x3016, "HP", ALC260_HP),
4597 SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_BASIC),
4598 SND_PCI_QUIRK(0x104d, 0x81cc, "Sony VAIO", ALC260_BASIC),
4599 SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC),
4600 SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X),
4601 SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC),
4602 SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_WILL),
4603 SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_REPLACER_672V),
4607 static struct alc_config_preset alc260_presets[] = {
4609 .mixers = { alc260_base_output_mixer,
4611 alc260_pc_beep_mixer,
4612 alc260_capture_mixer },
4613 .init_verbs = { alc260_init_verbs },
4614 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4615 .dac_nids = alc260_dac_nids,
4616 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
4617 .adc_nids = alc260_adc_nids,
4618 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4619 .channel_mode = alc260_modes,
4620 .input_mux = &alc260_capture_source,
4623 .mixers = { alc260_base_output_mixer,
4625 alc260_capture_alt_mixer },
4626 .init_verbs = { alc260_init_verbs },
4627 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4628 .dac_nids = alc260_dac_nids,
4629 .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
4630 .adc_nids = alc260_hp_adc_nids,
4631 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4632 .channel_mode = alc260_modes,
4633 .input_mux = &alc260_capture_source,
4635 [ALC260_HP_3013] = {
4636 .mixers = { alc260_hp_3013_mixer,
4638 alc260_capture_alt_mixer },
4639 .init_verbs = { alc260_hp_3013_init_verbs },
4640 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4641 .dac_nids = alc260_dac_nids,
4642 .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
4643 .adc_nids = alc260_hp_adc_nids,
4644 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4645 .channel_mode = alc260_modes,
4646 .input_mux = &alc260_capture_source,
4648 [ALC260_FUJITSU_S702X] = {
4649 .mixers = { alc260_fujitsu_mixer,
4650 alc260_capture_mixer },
4651 .init_verbs = { alc260_fujitsu_init_verbs },
4652 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4653 .dac_nids = alc260_dac_nids,
4654 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
4655 .adc_nids = alc260_dual_adc_nids,
4656 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4657 .channel_mode = alc260_modes,
4658 .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources),
4659 .input_mux = alc260_fujitsu_capture_sources,
4662 .mixers = { alc260_acer_mixer,
4663 alc260_capture_mixer },
4664 .init_verbs = { alc260_acer_init_verbs },
4665 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4666 .dac_nids = alc260_dac_nids,
4667 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
4668 .adc_nids = alc260_dual_adc_nids,
4669 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4670 .channel_mode = alc260_modes,
4671 .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
4672 .input_mux = alc260_acer_capture_sources,
4675 .mixers = { alc260_will_mixer,
4676 alc260_capture_mixer },
4677 .init_verbs = { alc260_init_verbs, alc260_will_verbs },
4678 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4679 .dac_nids = alc260_dac_nids,
4680 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
4681 .adc_nids = alc260_adc_nids,
4682 .dig_out_nid = ALC260_DIGOUT_NID,
4683 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4684 .channel_mode = alc260_modes,
4685 .input_mux = &alc260_capture_source,
4687 [ALC260_REPLACER_672V] = {
4688 .mixers = { alc260_replacer_672v_mixer,
4689 alc260_capture_mixer },
4690 .init_verbs = { alc260_init_verbs, alc260_replacer_672v_verbs },
4691 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4692 .dac_nids = alc260_dac_nids,
4693 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
4694 .adc_nids = alc260_adc_nids,
4695 .dig_out_nid = ALC260_DIGOUT_NID,
4696 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4697 .channel_mode = alc260_modes,
4698 .input_mux = &alc260_capture_source,
4699 .unsol_event = alc260_replacer_672v_unsol_event,
4700 .init_hook = alc260_replacer_672v_automute,
4702 #ifdef CONFIG_SND_DEBUG
4704 .mixers = { alc260_test_mixer,
4705 alc260_capture_mixer },
4706 .init_verbs = { alc260_test_init_verbs },
4707 .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
4708 .dac_nids = alc260_test_dac_nids,
4709 .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
4710 .adc_nids = alc260_test_adc_nids,
4711 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4712 .channel_mode = alc260_modes,
4713 .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources),
4714 .input_mux = alc260_test_capture_sources,
4719 static int patch_alc260(struct hda_codec *codec)
4721 struct alc_spec *spec;
4722 int err, board_config;
4724 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4730 board_config = snd_hda_check_board_config(codec, ALC260_MODEL_LAST,
4733 if (board_config < 0) {
4734 snd_printd(KERN_INFO "hda_codec: Unknown model for ALC260, "
4735 "trying auto-probe from BIOS...\n");
4736 board_config = ALC260_AUTO;
4739 if (board_config == ALC260_AUTO) {
4740 /* automatic parse from the BIOS config */
4741 err = alc260_parse_auto_config(codec);
4747 "hda_codec: Cannot set up configuration "
4748 "from BIOS. Using base mode...\n");
4749 board_config = ALC260_BASIC;
4753 if (board_config != ALC260_AUTO)
4754 setup_preset(spec, &alc260_presets[board_config]);
4756 spec->stream_name_analog = "ALC260 Analog";
4757 spec->stream_analog_playback = &alc260_pcm_analog_playback;
4758 spec->stream_analog_capture = &alc260_pcm_analog_capture;
4760 spec->stream_name_digital = "ALC260 Digital";
4761 spec->stream_digital_playback = &alc260_pcm_digital_playback;
4762 spec->stream_digital_capture = &alc260_pcm_digital_capture;
4764 codec->patch_ops = alc_patch_ops;
4765 if (board_config == ALC260_AUTO)
4766 spec->init_hook = alc260_auto_init;
4767 #ifdef CONFIG_SND_HDA_POWER_SAVE
4768 if (!spec->loopback.amplist)
4769 spec->loopback.amplist = alc260_loopbacks;
4779 * ALC882 is almost identical with ALC880 but has cleaner and more flexible
4780 * configuration. Each pin widget can choose any input DACs and a mixer.
4781 * Each ADC is connected from a mixer of all inputs. This makes possible
4782 * 6-channel independent captures.
4784 * In addition, an independent DAC for the multi-playback (not used in this
4787 #define ALC882_DIGOUT_NID 0x06
4788 #define ALC882_DIGIN_NID 0x0a
4790 static struct hda_channel_mode alc882_ch_modes[1] = {
4794 static hda_nid_t alc882_dac_nids[4] = {
4795 /* front, rear, clfe, rear_surr */
4796 0x02, 0x03, 0x04, 0x05
4799 /* identical with ALC880 */
4800 #define alc882_adc_nids alc880_adc_nids
4801 #define alc882_adc_nids_alt alc880_adc_nids_alt
4804 /* FIXME: should be a matrix-type input source selection */
4806 static struct hda_input_mux alc882_capture_source = {
4810 { "Front Mic", 0x1 },
4815 #define alc882_mux_enum_info alc_mux_enum_info
4816 #define alc882_mux_enum_get alc_mux_enum_get
4818 static int alc882_mux_enum_put(struct snd_kcontrol *kcontrol,
4819 struct snd_ctl_elem_value *ucontrol)
4821 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4822 struct alc_spec *spec = codec->spec;
4823 const struct hda_input_mux *imux = spec->input_mux;
4824 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
4825 static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
4826 hda_nid_t nid = capture_mixers[adc_idx];
4827 unsigned int *cur_val = &spec->cur_mux[adc_idx];
4828 unsigned int i, idx;
4830 idx = ucontrol->value.enumerated.item[0];
4831 if (idx >= imux->num_items)
4832 idx = imux->num_items - 1;
4833 if (*cur_val == idx)
4835 for (i = 0; i < imux->num_items; i++) {
4836 unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
4837 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
4838 imux->items[i].index,
4848 static struct hda_verb alc882_3ST_ch2_init[] = {
4849 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
4850 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
4851 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
4852 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
4859 static struct hda_verb alc882_3ST_ch6_init[] = {
4860 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4861 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
4862 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
4863 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4864 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
4865 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
4869 static struct hda_channel_mode alc882_3ST_6ch_modes[2] = {
4870 { 2, alc882_3ST_ch2_init },
4871 { 6, alc882_3ST_ch6_init },
4877 static struct hda_verb alc882_sixstack_ch6_init[] = {
4878 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
4879 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4880 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4881 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4888 static struct hda_verb alc882_sixstack_ch8_init[] = {
4889 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4890 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4891 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4892 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4896 static struct hda_channel_mode alc882_sixstack_modes[2] = {
4897 { 6, alc882_sixstack_ch6_init },
4898 { 8, alc882_sixstack_ch8_init },
4902 * macbook pro ALC885 can switch LineIn to LineOut without loosing Mic
4908 static struct hda_verb alc885_mbp_ch2_init[] = {
4909 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
4910 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4911 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4918 static struct hda_verb alc885_mbp_ch6_init[] = {
4919 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4920 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4921 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
4922 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4923 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4927 static struct hda_channel_mode alc885_mbp_6ch_modes[2] = {
4928 { 2, alc885_mbp_ch2_init },
4929 { 6, alc885_mbp_ch6_init },
4933 /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
4934 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
4936 static struct snd_kcontrol_new alc882_base_mixer[] = {
4937 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
4938 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
4939 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
4940 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
4941 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
4942 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
4943 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
4944 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
4945 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
4946 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
4947 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
4948 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
4949 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
4950 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
4951 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
4952 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
4953 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
4954 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
4955 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
4956 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
4957 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
4958 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
4959 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
4963 static struct snd_kcontrol_new alc885_mbp3_mixer[] = {
4964 HDA_CODEC_VOLUME("Master Volume", 0x0c, 0x00, HDA_OUTPUT),
4965 HDA_BIND_MUTE ("Master Switch", 0x0c, 0x02, HDA_INPUT),
4966 HDA_CODEC_MUTE ("Speaker Switch", 0x14, 0x00, HDA_OUTPUT),
4967 HDA_CODEC_VOLUME("Line Out Volume", 0x0d,0x00, HDA_OUTPUT),
4968 HDA_CODEC_VOLUME("Line In Playback Volume", 0x0b, 0x02, HDA_INPUT),
4969 HDA_CODEC_MUTE ("Line In Playback Switch", 0x0b, 0x02, HDA_INPUT),
4970 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
4971 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
4972 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0x00, HDA_INPUT),
4973 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
4976 static struct snd_kcontrol_new alc882_w2jc_mixer[] = {
4977 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
4978 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
4979 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
4980 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
4981 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
4982 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
4983 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
4984 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
4985 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
4986 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
4987 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
4991 static struct snd_kcontrol_new alc882_targa_mixer[] = {
4992 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
4993 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
4994 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
4995 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
4996 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
4997 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
4998 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
4999 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5000 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5001 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
5002 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
5006 /* Pin assignment: Front=0x14, HP = 0x15, Front = 0x16, ???
5007 * Front Mic=0x18, Line In = 0x1a, Line In = 0x1b, CD = 0x1c
5009 static struct snd_kcontrol_new alc882_asus_a7j_mixer[] = {
5010 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5011 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
5012 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
5013 HDA_CODEC_MUTE("Mobile Front Playback Switch", 0x16, 0x0, HDA_OUTPUT),
5014 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5015 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5016 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5017 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5018 HDA_CODEC_VOLUME("Mobile Line Playback Volume", 0x0b, 0x03, HDA_INPUT),
5019 HDA_CODEC_MUTE("Mobile Line Playback Switch", 0x0b, 0x03, HDA_INPUT),
5020 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5021 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5025 static struct snd_kcontrol_new alc882_chmode_mixer[] = {
5027 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5028 .name = "Channel Mode",
5029 .info = alc_ch_mode_info,
5030 .get = alc_ch_mode_get,
5031 .put = alc_ch_mode_put,
5036 static struct hda_verb alc882_init_verbs[] = {
5037 /* Front mixer: unmute input/output amp left and right (volume = 0) */
5038 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5039 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5040 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5042 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5043 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5044 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5046 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5047 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5048 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5050 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5051 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5052 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5054 /* Front Pin: output 0 (0x0c) */
5055 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5056 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5057 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
5058 /* Rear Pin: output 1 (0x0d) */
5059 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5060 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5061 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
5062 /* CLFE Pin: output 2 (0x0e) */
5063 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5064 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5065 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
5066 /* Side Pin: output 3 (0x0f) */
5067 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5068 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5069 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
5070 /* Mic (rear) pin: input vref at 80% */
5071 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5072 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5073 /* Front Mic pin: input vref at 80% */
5074 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5075 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5076 /* Line In pin: input */
5077 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
5078 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5079 /* Line-2 In: Headphone output (output 0 - 0x0c) */
5080 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5081 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5082 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
5083 /* CD pin widget for input */
5084 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
5086 /* FIXME: use matrix-type input source selection */
5087 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5088 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
5089 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5090 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5091 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5092 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5094 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5095 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5096 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5097 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5099 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5100 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5101 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5102 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5103 /* ADC1: mute amp left and right */
5104 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5105 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
5106 /* ADC2: mute amp left and right */
5107 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5108 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
5109 /* ADC3: mute amp left and right */
5110 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5111 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
5116 static struct hda_verb alc882_eapd_verbs[] = {
5117 /* change to EAPD mode */
5118 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
5119 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
5124 static struct snd_kcontrol_new alc882_macpro_mixer[] = {
5125 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5126 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5127 HDA_CODEC_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT),
5128 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
5129 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
5130 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x02, HDA_INPUT),
5131 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x02, HDA_INPUT),
5135 static struct hda_verb alc882_macpro_init_verbs[] = {
5136 /* Front mixer: unmute input/output amp left and right (volume = 0) */
5137 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5138 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5139 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5140 /* Front Pin: output 0 (0x0c) */
5141 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5142 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5143 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
5144 /* Front Mic pin: input vref at 80% */
5145 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5146 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5147 /* Speaker: output */
5148 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5149 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5150 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x04},
5151 /* Headphone output (output 0 - 0x0c) */
5152 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5153 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5154 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
5156 /* FIXME: use matrix-type input source selection */
5157 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5158 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
5159 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5160 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5161 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5162 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5164 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5165 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5166 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5167 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5169 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5170 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5171 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5172 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5173 /* ADC1: mute amp left and right */
5174 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5175 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
5176 /* ADC2: mute amp left and right */
5177 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5178 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
5179 /* ADC3: mute amp left and right */
5180 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5181 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
5186 /* Macbook Pro rev3 */
5187 static struct hda_verb alc885_mbp3_init_verbs[] = {
5188 /* Front mixer: unmute input/output amp left and right (volume = 0) */
5189 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5190 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5191 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5193 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5194 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5195 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5196 /* Front Pin: output 0 (0x0c) */
5197 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5198 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5199 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
5200 /* HP Pin: output 0 (0x0d) */
5201 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4},
5202 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5203 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
5204 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
5205 /* Mic (rear) pin: input vref at 80% */
5206 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5207 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5208 /* Front Mic pin: input vref at 80% */
5209 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5210 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5211 /* Line In pin: use output 1 when in LineOut mode */
5212 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
5213 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5214 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
5216 /* FIXME: use matrix-type input source selection */
5217 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5218 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
5219 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5220 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5221 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5222 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5224 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5225 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5226 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5227 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5229 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5230 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5231 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5232 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5233 /* ADC1: mute amp left and right */
5234 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5235 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
5236 /* ADC2: mute amp left and right */
5237 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5238 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
5239 /* ADC3: mute amp left and right */
5240 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5241 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
5246 /* iMac 24 mixer. */
5247 static struct snd_kcontrol_new alc885_imac24_mixer[] = {
5248 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
5249 HDA_CODEC_MUTE("Master Playback Switch", 0x0c, 0x00, HDA_INPUT),
5253 /* iMac 24 init verbs. */
5254 static struct hda_verb alc885_imac24_init_verbs[] = {
5255 /* Internal speakers: output 0 (0x0c) */
5256 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5257 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5258 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
5259 /* Internal speakers: output 0 (0x0c) */
5260 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5261 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5262 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
5263 /* Headphone: output 0 (0x0c) */
5264 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5265 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5266 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
5267 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
5268 /* Front Mic: input vref at 80% */
5269 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5270 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5274 /* Toggle speaker-output according to the hp-jack state */
5275 static void alc885_imac24_automute(struct hda_codec *codec)
5277 unsigned int present;
5279 present = snd_hda_codec_read(codec, 0x14, 0,
5280 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
5281 snd_hda_codec_amp_stereo(codec, 0x18, HDA_OUTPUT, 0,
5282 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
5283 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_OUTPUT, 0,
5284 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
5287 /* Processes unsolicited events. */
5288 static void alc885_imac24_unsol_event(struct hda_codec *codec,
5291 /* Headphone insertion or removal. */
5292 if ((res >> 26) == ALC880_HP_EVENT)
5293 alc885_imac24_automute(codec);
5296 static void alc885_mbp3_automute(struct hda_codec *codec)
5298 unsigned int present;
5300 present = snd_hda_codec_read(codec, 0x15, 0,
5301 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
5302 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
5303 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
5304 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
5305 HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
5308 static void alc885_mbp3_unsol_event(struct hda_codec *codec,
5311 /* Headphone insertion or removal. */
5312 if ((res >> 26) == ALC880_HP_EVENT)
5313 alc885_mbp3_automute(codec);
5317 static struct hda_verb alc882_targa_verbs[] = {
5318 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5319 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5321 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5322 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5324 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
5325 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
5326 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
5328 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
5329 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
5330 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
5331 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
5335 /* toggle speaker-output according to the hp-jack state */
5336 static void alc882_targa_automute(struct hda_codec *codec)
5338 unsigned int present;
5340 present = snd_hda_codec_read(codec, 0x14, 0,
5341 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
5342 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
5343 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
5344 snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
5348 static void alc882_targa_unsol_event(struct hda_codec *codec, unsigned int res)
5350 /* Looks like the unsol event is incompatible with the standard
5351 * definition. 4bit tag is placed at 26 bit!
5353 if (((res >> 26) == ALC880_HP_EVENT)) {
5354 alc882_targa_automute(codec);
5358 static struct hda_verb alc882_asus_a7j_verbs[] = {
5359 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5360 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5362 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5363 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5364 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5366 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
5367 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
5368 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
5370 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
5371 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
5372 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
5376 static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
5378 unsigned int gpiostate, gpiomask, gpiodir;
5380 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
5381 AC_VERB_GET_GPIO_DATA, 0);
5384 gpiostate |= (1 << pin);
5386 gpiostate &= ~(1 << pin);
5388 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
5389 AC_VERB_GET_GPIO_MASK, 0);
5390 gpiomask |= (1 << pin);
5392 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
5393 AC_VERB_GET_GPIO_DIRECTION, 0);
5394 gpiodir |= (1 << pin);
5397 snd_hda_codec_write(codec, codec->afg, 0,
5398 AC_VERB_SET_GPIO_MASK, gpiomask);
5399 snd_hda_codec_write(codec, codec->afg, 0,
5400 AC_VERB_SET_GPIO_DIRECTION, gpiodir);
5404 snd_hda_codec_write(codec, codec->afg, 0,
5405 AC_VERB_SET_GPIO_DATA, gpiostate);
5408 /* set up GPIO at initialization */
5409 static void alc885_macpro_init_hook(struct hda_codec *codec)
5411 alc882_gpio_mute(codec, 0, 0);
5412 alc882_gpio_mute(codec, 1, 0);
5415 /* set up GPIO and update auto-muting at initialization */
5416 static void alc885_imac24_init_hook(struct hda_codec *codec)
5418 alc885_macpro_init_hook(codec);
5419 alc885_imac24_automute(codec);
5423 * generic initialization of ADC, input mixers and output mixers
5425 static struct hda_verb alc882_auto_init_verbs[] = {
5427 * Unmute ADC0-2 and set the default input to mic-in
5429 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
5430 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5431 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
5432 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5433 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
5434 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5436 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
5438 * Note: PASD motherboards uses the Line In 2 as the input for
5439 * front panel mic (mic 2)
5441 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
5442 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5443 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5444 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5445 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5446 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5449 * Set up output mixers (0x0c - 0x0f)
5451 /* set vol=0 to output mixers */
5452 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5453 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5454 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5455 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5456 /* set up input amps for analog loopback */
5457 /* Amp Indices: DAC = 0, mixer = 1 */
5458 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5459 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5460 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5461 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5462 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5463 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5464 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5465 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5466 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5467 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5469 /* FIXME: use matrix-type input source selection */
5470 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5471 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
5472 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5473 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
5474 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
5475 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
5477 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5478 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
5479 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
5480 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
5482 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5483 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
5484 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
5485 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
5490 /* capture mixer elements */
5491 static struct snd_kcontrol_new alc882_capture_alt_mixer[] = {
5492 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
5493 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
5494 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
5495 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
5497 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5498 /* The multiple "Capture Source" controls confuse alsamixer
5499 * So call somewhat different..
5500 * FIXME: the controls appear in the "playback" view!
5502 /* .name = "Capture Source", */
5503 .name = "Input Source",
5505 .info = alc882_mux_enum_info,
5506 .get = alc882_mux_enum_get,
5507 .put = alc882_mux_enum_put,
5512 static struct snd_kcontrol_new alc882_capture_mixer[] = {
5513 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
5514 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
5515 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
5516 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
5517 HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
5518 HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
5520 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5521 /* The multiple "Capture Source" controls confuse alsamixer
5522 * So call somewhat different..
5523 * FIXME: the controls appear in the "playback" view!
5525 /* .name = "Capture Source", */
5526 .name = "Input Source",
5528 .info = alc882_mux_enum_info,
5529 .get = alc882_mux_enum_get,
5530 .put = alc882_mux_enum_put,
5535 #ifdef CONFIG_SND_HDA_POWER_SAVE
5536 #define alc882_loopbacks alc880_loopbacks
5539 /* pcm configuration: identiacal with ALC880 */
5540 #define alc882_pcm_analog_playback alc880_pcm_analog_playback
5541 #define alc882_pcm_analog_capture alc880_pcm_analog_capture
5542 #define alc882_pcm_digital_playback alc880_pcm_digital_playback
5543 #define alc882_pcm_digital_capture alc880_pcm_digital_capture
5546 * configuration and preset
5548 static const char *alc882_models[ALC882_MODEL_LAST] = {
5549 [ALC882_3ST_DIG] = "3stack-dig",
5550 [ALC882_6ST_DIG] = "6stack-dig",
5551 [ALC882_ARIMA] = "arima",
5552 [ALC882_W2JC] = "w2jc",
5553 [ALC885_MACPRO] = "macpro",
5554 [ALC885_MBP3] = "mbp3",
5555 [ALC885_IMAC24] = "imac24",
5556 [ALC882_AUTO] = "auto",
5559 static struct snd_pci_quirk alc882_cfg_tbl[] = {
5560 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG),
5561 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG),
5562 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG),
5563 SND_PCI_QUIRK(0x1462, 0x28fb, "Targa T8", ALC882_TARGA), /* MSI-1049 T8 */
5564 SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA),
5565 SND_PCI_QUIRK(0x1043, 0x060d, "Asus A7J", ALC882_ASUS_A7J),
5566 SND_PCI_QUIRK(0x1043, 0x817f, "Asus P5LD2", ALC882_6ST_DIG),
5567 SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG),
5568 SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_W2JC),
5572 static struct alc_config_preset alc882_presets[] = {
5573 [ALC882_3ST_DIG] = {
5574 .mixers = { alc882_base_mixer },
5575 .init_verbs = { alc882_init_verbs },
5576 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5577 .dac_nids = alc882_dac_nids,
5578 .dig_out_nid = ALC882_DIGOUT_NID,
5579 .dig_in_nid = ALC882_DIGIN_NID,
5580 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
5581 .channel_mode = alc882_ch_modes,
5583 .input_mux = &alc882_capture_source,
5585 [ALC882_6ST_DIG] = {
5586 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
5587 .init_verbs = { alc882_init_verbs },
5588 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5589 .dac_nids = alc882_dac_nids,
5590 .dig_out_nid = ALC882_DIGOUT_NID,
5591 .dig_in_nid = ALC882_DIGIN_NID,
5592 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
5593 .channel_mode = alc882_sixstack_modes,
5594 .input_mux = &alc882_capture_source,
5597 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
5598 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs },
5599 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5600 .dac_nids = alc882_dac_nids,
5601 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
5602 .channel_mode = alc882_sixstack_modes,
5603 .input_mux = &alc882_capture_source,
5606 .mixers = { alc882_w2jc_mixer, alc882_chmode_mixer },
5607 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs,
5608 alc880_gpio1_init_verbs },
5609 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5610 .dac_nids = alc882_dac_nids,
5611 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
5612 .channel_mode = alc880_threestack_modes,
5614 .input_mux = &alc882_capture_source,
5615 .dig_out_nid = ALC882_DIGOUT_NID,
5618 .mixers = { alc885_mbp3_mixer, alc882_chmode_mixer },
5619 .init_verbs = { alc885_mbp3_init_verbs,
5620 alc880_gpio1_init_verbs },
5621 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5622 .dac_nids = alc882_dac_nids,
5623 .channel_mode = alc885_mbp_6ch_modes,
5624 .num_channel_mode = ARRAY_SIZE(alc885_mbp_6ch_modes),
5625 .input_mux = &alc882_capture_source,
5626 .dig_out_nid = ALC882_DIGOUT_NID,
5627 .dig_in_nid = ALC882_DIGIN_NID,
5628 .unsol_event = alc885_mbp3_unsol_event,
5629 .init_hook = alc885_mbp3_automute,
5632 .mixers = { alc882_macpro_mixer },
5633 .init_verbs = { alc882_macpro_init_verbs },
5634 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5635 .dac_nids = alc882_dac_nids,
5636 .dig_out_nid = ALC882_DIGOUT_NID,
5637 .dig_in_nid = ALC882_DIGIN_NID,
5638 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
5639 .channel_mode = alc882_ch_modes,
5640 .input_mux = &alc882_capture_source,
5641 .init_hook = alc885_macpro_init_hook,
5644 .mixers = { alc885_imac24_mixer },
5645 .init_verbs = { alc885_imac24_init_verbs },
5646 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5647 .dac_nids = alc882_dac_nids,
5648 .dig_out_nid = ALC882_DIGOUT_NID,
5649 .dig_in_nid = ALC882_DIGIN_NID,
5650 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
5651 .channel_mode = alc882_ch_modes,
5652 .input_mux = &alc882_capture_source,
5653 .unsol_event = alc885_imac24_unsol_event,
5654 .init_hook = alc885_imac24_init_hook,
5657 .mixers = { alc882_targa_mixer, alc882_chmode_mixer,
5658 alc882_capture_mixer },
5659 .init_verbs = { alc882_init_verbs, alc882_targa_verbs},
5660 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5661 .dac_nids = alc882_dac_nids,
5662 .dig_out_nid = ALC882_DIGOUT_NID,
5663 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
5664 .adc_nids = alc882_adc_nids,
5665 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
5666 .channel_mode = alc882_3ST_6ch_modes,
5668 .input_mux = &alc882_capture_source,
5669 .unsol_event = alc882_targa_unsol_event,
5670 .init_hook = alc882_targa_automute,
5672 [ALC882_ASUS_A7J] = {
5673 .mixers = { alc882_asus_a7j_mixer, alc882_chmode_mixer,
5674 alc882_capture_mixer },
5675 .init_verbs = { alc882_init_verbs, alc882_asus_a7j_verbs},
5676 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5677 .dac_nids = alc882_dac_nids,
5678 .dig_out_nid = ALC882_DIGOUT_NID,
5679 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
5680 .adc_nids = alc882_adc_nids,
5681 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
5682 .channel_mode = alc882_3ST_6ch_modes,
5684 .input_mux = &alc882_capture_source,
5693 PINFIX_ABIT_AW9D_MAX
5696 static struct alc_pincfg alc882_abit_aw9d_pinfix[] = {
5697 { 0x15, 0x01080104 }, /* side */
5698 { 0x16, 0x01011012 }, /* rear */
5699 { 0x17, 0x01016011 }, /* clfe */
5703 static const struct alc_pincfg *alc882_pin_fixes[] = {
5704 [PINFIX_ABIT_AW9D_MAX] = alc882_abit_aw9d_pinfix,
5707 static struct snd_pci_quirk alc882_pinfix_tbl[] = {
5708 SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", PINFIX_ABIT_AW9D_MAX),
5713 * BIOS auto configuration
5715 static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
5716 hda_nid_t nid, int pin_type,
5720 struct alc_spec *spec = codec->spec;
5723 if (spec->multiout.dac_nids[dac_idx] == 0x25)
5726 idx = spec->multiout.dac_nids[dac_idx] - 2;
5728 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5730 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
5732 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
5736 static void alc882_auto_init_multi_out(struct hda_codec *codec)
5738 struct alc_spec *spec = codec->spec;
5741 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
5742 for (i = 0; i <= HDA_SIDE; i++) {
5743 hda_nid_t nid = spec->autocfg.line_out_pins[i];
5744 int pin_type = get_pin_type(spec->autocfg.line_out_type);
5746 alc882_auto_set_output_and_unmute(codec, nid, pin_type,
5751 static void alc882_auto_init_hp_out(struct hda_codec *codec)
5753 struct alc_spec *spec = codec->spec;
5756 pin = spec->autocfg.hp_pins[0];
5757 if (pin) /* connect to front */
5759 alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
5762 #define alc882_is_input_pin(nid) alc880_is_input_pin(nid)
5763 #define ALC882_PIN_CD_NID ALC880_PIN_CD_NID
5765 static void alc882_auto_init_analog_input(struct hda_codec *codec)
5767 struct alc_spec *spec = codec->spec;
5770 for (i = 0; i < AUTO_PIN_LAST; i++) {
5771 hda_nid_t nid = spec->autocfg.input_pins[i];
5772 if (alc882_is_input_pin(nid)) {
5773 snd_hda_codec_write(codec, nid, 0,
5774 AC_VERB_SET_PIN_WIDGET_CONTROL,
5775 i <= AUTO_PIN_FRONT_MIC ?
5776 PIN_VREF80 : PIN_IN);
5777 if (nid != ALC882_PIN_CD_NID)
5778 snd_hda_codec_write(codec, nid, 0,
5779 AC_VERB_SET_AMP_GAIN_MUTE,
5785 /* almost identical with ALC880 parser... */
5786 static int alc882_parse_auto_config(struct hda_codec *codec)
5788 struct alc_spec *spec = codec->spec;
5789 int err = alc880_parse_auto_config(codec);
5794 /* hack - override the init verbs */
5795 spec->init_verbs[0] = alc882_auto_init_verbs;
5799 /* additional initialization for auto-configuration model */
5800 static void alc882_auto_init(struct hda_codec *codec)
5802 alc882_auto_init_multi_out(codec);
5803 alc882_auto_init_hp_out(codec);
5804 alc882_auto_init_analog_input(codec);
5807 static int patch_alc882(struct hda_codec *codec)
5809 struct alc_spec *spec;
5810 int err, board_config;
5812 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5818 board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST,
5822 if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
5823 /* Pick up systems that don't supply PCI SSID */
5824 switch (codec->subsystem_id) {
5825 case 0x106b0c00: /* Mac Pro */
5826 board_config = ALC885_MACPRO;
5828 case 0x106b1000: /* iMac 24 */
5829 board_config = ALC885_IMAC24;
5831 case 0x106b2c00: /* Macbook Pro rev3 */
5832 board_config = ALC885_MBP3;
5835 printk(KERN_INFO "hda_codec: Unknown model for ALC882, "
5836 "trying auto-probe from BIOS...\n");
5837 board_config = ALC882_AUTO;
5841 alc_fix_pincfg(codec, alc882_pinfix_tbl, alc882_pin_fixes);
5843 if (board_config == ALC882_AUTO) {
5844 /* automatic parse from the BIOS config */
5845 err = alc882_parse_auto_config(codec);
5851 "hda_codec: Cannot set up configuration "
5852 "from BIOS. Using base mode...\n");
5853 board_config = ALC882_3ST_DIG;
5857 if (board_config != ALC882_AUTO)
5858 setup_preset(spec, &alc882_presets[board_config]);
5860 spec->stream_name_analog = "ALC882 Analog";
5861 spec->stream_analog_playback = &alc882_pcm_analog_playback;
5862 spec->stream_analog_capture = &alc882_pcm_analog_capture;
5864 spec->stream_name_digital = "ALC882 Digital";
5865 spec->stream_digital_playback = &alc882_pcm_digital_playback;
5866 spec->stream_digital_capture = &alc882_pcm_digital_capture;
5868 if (!spec->adc_nids && spec->input_mux) {
5869 /* check whether NID 0x07 is valid */
5870 unsigned int wcap = get_wcaps(codec, 0x07);
5872 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
5873 if (wcap != AC_WID_AUD_IN) {
5874 spec->adc_nids = alc882_adc_nids_alt;
5875 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids_alt);
5876 spec->mixers[spec->num_mixers] =
5877 alc882_capture_alt_mixer;
5880 spec->adc_nids = alc882_adc_nids;
5881 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids);
5882 spec->mixers[spec->num_mixers] = alc882_capture_mixer;
5887 codec->patch_ops = alc_patch_ops;
5888 if (board_config == ALC882_AUTO)
5889 spec->init_hook = alc882_auto_init;
5890 #ifdef CONFIG_SND_HDA_POWER_SAVE
5891 if (!spec->loopback.amplist)
5892 spec->loopback.amplist = alc882_loopbacks;
5901 * ALC883 is almost identical with ALC880 but has cleaner and more flexible
5902 * configuration. Each pin widget can choose any input DACs and a mixer.
5903 * Each ADC is connected from a mixer of all inputs. This makes possible
5904 * 6-channel independent captures.
5906 * In addition, an independent DAC for the multi-playback (not used in this
5909 #define ALC883_DIGOUT_NID 0x06
5910 #define ALC883_DIGIN_NID 0x0a
5912 static hda_nid_t alc883_dac_nids[4] = {
5913 /* front, rear, clfe, rear_surr */
5914 0x02, 0x04, 0x03, 0x05
5917 static hda_nid_t alc883_adc_nids[2] = {
5923 /* FIXME: should be a matrix-type input source selection */
5925 static struct hda_input_mux alc883_capture_source = {
5929 { "Front Mic", 0x1 },
5935 static struct hda_input_mux alc883_lenovo_101e_capture_source = {
5943 static struct hda_input_mux alc883_lenovo_nb0763_capture_source = {
5953 #define alc883_mux_enum_info alc_mux_enum_info
5954 #define alc883_mux_enum_get alc_mux_enum_get
5956 static int alc883_mux_enum_put(struct snd_kcontrol *kcontrol,
5957 struct snd_ctl_elem_value *ucontrol)
5959 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
5960 struct alc_spec *spec = codec->spec;
5961 const struct hda_input_mux *imux = spec->input_mux;
5962 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
5963 static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
5964 hda_nid_t nid = capture_mixers[adc_idx];
5965 unsigned int *cur_val = &spec->cur_mux[adc_idx];
5966 unsigned int i, idx;
5968 idx = ucontrol->value.enumerated.item[0];
5969 if (idx >= imux->num_items)
5970 idx = imux->num_items - 1;
5971 if (*cur_val == idx)
5973 for (i = 0; i < imux->num_items; i++) {
5974 unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
5975 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
5976 imux->items[i].index,
5986 static struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
5993 static struct hda_verb alc883_3ST_ch2_init[] = {
5994 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
5995 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
5996 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
5997 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6004 static struct hda_verb alc883_3ST_ch6_init[] = {
6005 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6006 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6007 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
6008 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6009 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6010 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6014 static struct hda_channel_mode alc883_3ST_6ch_modes[2] = {
6015 { 2, alc883_3ST_ch2_init },
6016 { 6, alc883_3ST_ch6_init },
6022 static struct hda_verb alc883_sixstack_ch6_init[] = {
6023 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
6024 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6025 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6026 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6033 static struct hda_verb alc883_sixstack_ch8_init[] = {
6034 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6035 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6036 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6037 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6041 static struct hda_channel_mode alc883_sixstack_modes[2] = {
6042 { 6, alc883_sixstack_ch6_init },
6043 { 8, alc883_sixstack_ch8_init },
6046 static struct hda_verb alc883_medion_eapd_verbs[] = {
6047 /* eanable EAPD on medion laptop */
6048 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
6049 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
6053 /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
6054 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
6057 static struct snd_kcontrol_new alc883_base_mixer[] = {
6058 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6059 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6060 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
6061 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
6062 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
6063 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
6064 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
6065 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
6066 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
6067 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
6068 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6069 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6070 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6071 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6072 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6073 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6074 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6075 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6076 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6077 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
6078 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6079 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6080 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6081 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6082 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6083 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6084 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6086 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6087 /* .name = "Capture Source", */
6088 .name = "Input Source",
6090 .info = alc883_mux_enum_info,
6091 .get = alc883_mux_enum_get,
6092 .put = alc883_mux_enum_put,
6097 static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
6098 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6099 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6100 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6101 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6102 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6103 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6104 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6105 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6106 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6107 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6108 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6109 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
6110 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6111 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6112 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6113 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6114 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6115 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6116 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6118 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6119 /* .name = "Capture Source", */
6120 .name = "Input Source",
6122 .info = alc883_mux_enum_info,
6123 .get = alc883_mux_enum_get,
6124 .put = alc883_mux_enum_put,
6129 static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
6130 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6131 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6132 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
6133 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
6134 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
6135 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
6136 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
6137 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
6138 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6139 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6140 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6141 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6142 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6143 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6144 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6145 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6146 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6147 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
6148 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6149 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6150 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6151 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6152 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6153 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6154 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6156 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6157 /* .name = "Capture Source", */
6158 .name = "Input Source",
6160 .info = alc883_mux_enum_info,
6161 .get = alc883_mux_enum_get,
6162 .put = alc883_mux_enum_put,
6167 static struct snd_kcontrol_new alc883_fivestack_mixer[] = {
6168 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6169 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6170 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
6171 HDA_CODEC_MUTE("Surround Playback Switch", 0x15, 0x0, HDA_OUTPUT),
6172 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
6173 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
6174 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x16, 1, 0x0, HDA_OUTPUT),
6175 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
6176 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6177 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6178 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6179 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6180 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6181 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6182 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6183 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6184 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6185 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
6186 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6187 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6188 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6189 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6190 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6193 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6194 /* .name = "Capture Source", */
6195 .name = "Input Source",
6197 .info = alc883_mux_enum_info,
6198 .get = alc883_mux_enum_get,
6199 .put = alc883_mux_enum_put,
6204 static struct snd_kcontrol_new alc883_tagra_mixer[] = {
6205 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6206 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6207 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6208 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
6209 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
6210 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
6211 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
6212 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
6213 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
6214 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6215 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6216 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6217 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6218 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6219 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6220 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6221 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6222 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6223 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6224 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6226 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6227 /* .name = "Capture Source", */
6228 .name = "Input Source",
6230 .info = alc883_mux_enum_info,
6231 .get = alc883_mux_enum_get,
6232 .put = alc883_mux_enum_put,
6237 static struct snd_kcontrol_new alc883_tagra_2ch_mixer[] = {
6238 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6239 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6240 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6241 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6242 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6243 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6244 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6245 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6246 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6247 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6248 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6249 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6251 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6252 /* .name = "Capture Source", */
6253 .name = "Input Source",
6255 .info = alc883_mux_enum_info,
6256 .get = alc883_mux_enum_get,
6257 .put = alc883_mux_enum_put,
6262 static struct snd_kcontrol_new alc883_lenovo_101e_2ch_mixer[] = {
6263 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6264 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6265 HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
6266 HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT),
6267 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6268 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6269 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6270 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6271 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6272 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6274 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6275 /* .name = "Capture Source", */
6276 .name = "Input Source",
6278 .info = alc883_mux_enum_info,
6279 .get = alc883_mux_enum_get,
6280 .put = alc883_mux_enum_put,
6285 static struct snd_kcontrol_new alc883_lenovo_nb0763_mixer[] = {
6286 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6287 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
6288 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6289 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6290 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6291 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6292 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6293 HDA_CODEC_VOLUME("iMic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6294 HDA_CODEC_MUTE("iMic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6295 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6296 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6297 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6298 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6300 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6301 /* .name = "Capture Source", */
6302 .name = "Input Source",
6304 .info = alc883_mux_enum_info,
6305 .get = alc883_mux_enum_get,
6306 .put = alc883_mux_enum_put,
6311 static struct snd_kcontrol_new alc883_medion_md2_mixer[] = {
6312 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6313 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6314 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
6315 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6316 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6317 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6318 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6319 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6320 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6321 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6322 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6323 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6324 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6326 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6327 /* .name = "Capture Source", */
6328 .name = "Input Source",
6330 .info = alc883_mux_enum_info,
6331 .get = alc883_mux_enum_get,
6332 .put = alc883_mux_enum_put,
6337 static struct snd_kcontrol_new alc888_6st_hp_mixer[] = {
6338 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6339 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6340 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
6341 HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
6342 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
6343 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
6344 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
6345 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
6346 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
6347 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
6348 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6349 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6350 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6351 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6352 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6353 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6354 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6355 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6356 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6357 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
6358 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6359 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6360 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6361 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6362 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6363 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6364 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6366 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6367 /* .name = "Capture Source", */
6368 .name = "Input Source",
6370 .info = alc883_mux_enum_info,
6371 .get = alc883_mux_enum_get,
6372 .put = alc883_mux_enum_put,
6377 static struct snd_kcontrol_new alc888_3st_hp_mixer[] = {
6378 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6379 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6380 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
6381 HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
6382 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
6383 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
6384 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
6385 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
6386 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6387 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6388 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6389 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6390 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6391 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6392 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6393 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6394 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6395 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
6396 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6397 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6398 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6399 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6400 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6401 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6402 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6404 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6405 /* .name = "Capture Source", */
6406 .name = "Input Source",
6408 .info = alc883_mux_enum_info,
6409 .get = alc883_mux_enum_get,
6410 .put = alc883_mux_enum_put,
6415 static struct snd_kcontrol_new alc883_acer_aspire_mixer[] = {
6416 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6417 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6418 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6419 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6420 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6421 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6422 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6423 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6424 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6425 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6426 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6427 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6429 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6430 /* .name = "Capture Source", */
6431 .name = "Input Source",
6433 .info = alc883_mux_enum_info,
6434 .get = alc883_mux_enum_get,
6435 .put = alc883_mux_enum_put,
6440 static struct snd_kcontrol_new alc883_chmode_mixer[] = {
6442 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6443 .name = "Channel Mode",
6444 .info = alc_ch_mode_info,
6445 .get = alc_ch_mode_get,
6446 .put = alc_ch_mode_put,
6451 static struct hda_verb alc883_init_verbs[] = {
6452 /* ADC1: mute amp left and right */
6453 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6454 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6455 /* ADC2: mute amp left and right */
6456 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6457 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
6458 /* Front mixer: unmute input/output amp left and right (volume = 0) */
6459 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6460 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6461 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6463 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6464 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6465 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6467 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6468 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6469 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6471 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6472 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6473 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6475 /* mute analog input loopbacks */
6476 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6477 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6478 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6479 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6480 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6482 /* Front Pin: output 0 (0x0c) */
6483 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6484 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6485 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
6486 /* Rear Pin: output 1 (0x0d) */
6487 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6488 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6489 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
6490 /* CLFE Pin: output 2 (0x0e) */
6491 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6492 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6493 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
6494 /* Side Pin: output 3 (0x0f) */
6495 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6496 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6497 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
6498 /* Mic (rear) pin: input vref at 80% */
6499 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6500 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6501 /* Front Mic pin: input vref at 80% */
6502 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6503 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6504 /* Line In pin: input */
6505 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
6506 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6507 /* Line-2 In: Headphone output (output 0 - 0x0c) */
6508 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6509 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6510 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
6511 /* CD pin widget for input */
6512 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
6514 /* FIXME: use matrix-type input source selection */
6515 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6517 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6518 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6519 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
6520 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
6522 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6523 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6524 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
6525 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
6529 static struct hda_verb alc883_tagra_verbs[] = {
6530 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6531 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6533 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6534 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6536 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
6537 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
6538 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6540 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
6541 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
6542 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
6543 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
6548 static struct hda_verb alc883_lenovo_101e_verbs[] = {
6549 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
6550 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT|AC_USRSP_EN},
6551 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT|AC_USRSP_EN},
6555 static struct hda_verb alc883_lenovo_nb0763_verbs[] = {
6556 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
6557 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6558 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
6559 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6563 static struct hda_verb alc888_lenovo_ms7195_verbs[] = {
6564 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6565 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6566 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
6567 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT | AC_USRSP_EN},
6568 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
6572 static struct hda_verb alc883_haier_w66_verbs[] = {
6573 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6574 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6576 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6578 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
6579 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6580 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
6581 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6585 static struct hda_verb alc888_6st_hp_verbs[] = {
6586 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
6587 {0x15, AC_VERB_SET_CONNECT_SEL, 0x02}, /* Rear : output 2 (0x0e) */
6588 {0x16, AC_VERB_SET_CONNECT_SEL, 0x01}, /* CLFE : output 1 (0x0d) */
6589 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03}, /* Side : output 3 (0x0f) */
6593 static struct hda_verb alc888_3st_hp_verbs[] = {
6594 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
6595 {0x18, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Rear : output 1 (0x0d) */
6596 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02}, /* CLFE : output 2 (0x0e) */
6600 static struct hda_verb alc888_3st_hp_2ch_init[] = {
6601 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6602 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6603 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6604 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6608 static struct hda_verb alc888_3st_hp_6ch_init[] = {
6609 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6610 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6611 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6612 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6616 static struct hda_channel_mode alc888_3st_hp_modes[2] = {
6617 { 2, alc888_3st_hp_2ch_init },
6618 { 6, alc888_3st_hp_6ch_init },
6621 /* toggle front-jack and RCA according to the hp-jack state */
6622 static void alc888_lenovo_ms7195_front_automute(struct hda_codec *codec)
6624 unsigned int present;
6626 present = snd_hda_codec_read(codec, 0x1b, 0,
6627 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
6628 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
6629 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
6630 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
6631 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
6634 /* toggle RCA according to the front-jack state */
6635 static void alc888_lenovo_ms7195_rca_automute(struct hda_codec *codec)
6637 unsigned int present;
6639 present = snd_hda_codec_read(codec, 0x14, 0,
6640 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
6641 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
6642 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
6645 static void alc883_lenovo_ms7195_unsol_event(struct hda_codec *codec,
6648 if ((res >> 26) == ALC880_HP_EVENT)
6649 alc888_lenovo_ms7195_front_automute(codec);
6650 if ((res >> 26) == ALC880_FRONT_EVENT)
6651 alc888_lenovo_ms7195_rca_automute(codec);
6654 static struct hda_verb alc883_medion_md2_verbs[] = {
6655 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6656 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6658 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6660 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
6664 /* toggle speaker-output according to the hp-jack state */
6665 static void alc883_medion_md2_automute(struct hda_codec *codec)
6667 unsigned int present;
6669 present = snd_hda_codec_read(codec, 0x14, 0,
6670 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
6671 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
6672 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
6675 static void alc883_medion_md2_unsol_event(struct hda_codec *codec,
6678 if ((res >> 26) == ALC880_HP_EVENT)
6679 alc883_medion_md2_automute(codec);
6682 /* toggle speaker-output according to the hp-jack state */
6683 static void alc883_tagra_automute(struct hda_codec *codec)
6685 unsigned int present;
6688 present = snd_hda_codec_read(codec, 0x14, 0,
6689 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
6690 bits = present ? HDA_AMP_MUTE : 0;
6691 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
6692 HDA_AMP_MUTE, bits);
6693 snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
6697 static void alc883_tagra_unsol_event(struct hda_codec *codec, unsigned int res)
6699 if ((res >> 26) == ALC880_HP_EVENT)
6700 alc883_tagra_automute(codec);
6703 static void alc883_haier_w66_automute(struct hda_codec *codec)
6705 unsigned int present;
6708 present = snd_hda_codec_read(codec, 0x1b, 0,
6709 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
6710 bits = present ? 0x80 : 0;
6711 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
6715 static void alc883_haier_w66_unsol_event(struct hda_codec *codec,
6718 if ((res >> 26) == ALC880_HP_EVENT)
6719 alc883_haier_w66_automute(codec);
6722 static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
6724 unsigned int present;
6727 present = snd_hda_codec_read(codec, 0x14, 0,
6728 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
6729 bits = present ? HDA_AMP_MUTE : 0;
6730 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
6731 HDA_AMP_MUTE, bits);
6734 static void alc883_lenovo_101e_all_automute(struct hda_codec *codec)
6736 unsigned int present;
6739 present = snd_hda_codec_read(codec, 0x1b, 0,
6740 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
6741 bits = present ? HDA_AMP_MUTE : 0;
6742 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
6743 HDA_AMP_MUTE, bits);
6744 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
6745 HDA_AMP_MUTE, bits);
6748 static void alc883_lenovo_101e_unsol_event(struct hda_codec *codec,
6751 if ((res >> 26) == ALC880_HP_EVENT)
6752 alc883_lenovo_101e_all_automute(codec);
6753 if ((res >> 26) == ALC880_FRONT_EVENT)
6754 alc883_lenovo_101e_ispeaker_automute(codec);
6757 /* toggle speaker-output according to the hp-jack state */
6758 static void alc883_acer_aspire_automute(struct hda_codec *codec)
6760 unsigned int present;
6762 present = snd_hda_codec_read(codec, 0x14, 0,
6763 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
6764 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
6765 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
6766 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
6767 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
6770 static void alc883_acer_aspire_unsol_event(struct hda_codec *codec,
6773 if ((res >> 26) == ALC880_HP_EVENT)
6774 alc883_acer_aspire_automute(codec);
6777 static struct hda_verb alc883_acer_eapd_verbs[] = {
6778 /* HP Pin: output 0 (0x0c) */
6779 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6780 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6781 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
6782 /* Front Pin: output 0 (0x0c) */
6783 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6784 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
6785 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6786 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00},
6787 /* eanable EAPD on medion laptop */
6788 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
6789 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
6790 /* enable unsolicited event */
6791 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
6796 * generic initialization of ADC, input mixers and output mixers
6798 static struct hda_verb alc883_auto_init_verbs[] = {
6800 * Unmute ADC0-2 and set the default input to mic-in
6802 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6803 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6804 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
6805 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6807 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
6809 * Note: PASD motherboards uses the Line In 2 as the input for
6810 * front panel mic (mic 2)
6812 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
6813 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6814 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6815 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6816 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6817 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6820 * Set up output mixers (0x0c - 0x0f)
6822 /* set vol=0 to output mixers */
6823 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6824 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6825 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6826 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6827 /* set up input amps for analog loopback */
6828 /* Amp Indices: DAC = 0, mixer = 1 */
6829 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6830 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6831 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6832 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6833 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6834 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6835 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6836 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6837 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6838 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6840 /* FIXME: use matrix-type input source selection */
6841 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6843 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6844 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6845 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
6846 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
6847 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
6849 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6850 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6851 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
6852 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
6853 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
6858 /* capture mixer elements */
6859 static struct snd_kcontrol_new alc883_capture_mixer[] = {
6860 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6861 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6862 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6863 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6865 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6866 /* The multiple "Capture Source" controls confuse alsamixer
6867 * So call somewhat different..
6868 * FIXME: the controls appear in the "playback" view!
6870 /* .name = "Capture Source", */
6871 .name = "Input Source",
6873 .info = alc882_mux_enum_info,
6874 .get = alc882_mux_enum_get,
6875 .put = alc882_mux_enum_put,
6880 #ifdef CONFIG_SND_HDA_POWER_SAVE
6881 #define alc883_loopbacks alc880_loopbacks
6884 /* pcm configuration: identiacal with ALC880 */
6885 #define alc883_pcm_analog_playback alc880_pcm_analog_playback
6886 #define alc883_pcm_analog_capture alc880_pcm_analog_capture
6887 #define alc883_pcm_digital_playback alc880_pcm_digital_playback
6888 #define alc883_pcm_digital_capture alc880_pcm_digital_capture
6891 * configuration and preset
6893 static const char *alc883_models[ALC883_MODEL_LAST] = {
6894 [ALC883_3ST_2ch_DIG] = "3stack-dig",
6895 [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig",
6896 [ALC883_3ST_6ch] = "3stack-6ch",
6897 [ALC883_6ST_DIG] = "6stack-dig",
6898 [ALC883_TARGA_DIG] = "targa-dig",
6899 [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig",
6900 [ALC883_ACER] = "acer",
6901 [ALC883_ACER_ASPIRE] = "acer-aspire",
6902 [ALC883_MEDION] = "medion",
6903 [ALC883_MEDION_MD2] = "medion-md2",
6904 [ALC883_LAPTOP_EAPD] = "laptop-eapd",
6905 [ALC883_LENOVO_101E_2ch] = "lenovo-101e",
6906 [ALC883_LENOVO_NB0763] = "lenovo-nb0763",
6907 [ALC888_LENOVO_MS7195_DIG] = "lenovo-ms7195-dig",
6908 [ALC883_HAIER_W66] = "haier-w66",
6909 [ALC888_6ST_HP] = "6stack-hp",
6910 [ALC888_3ST_HP] = "3stack-hp",
6911 [ALC883_AUTO] = "auto",
6914 static struct snd_pci_quirk alc883_cfg_tbl[] = {
6915 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC883_3ST_6ch_DIG),
6916 SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG),
6917 SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch),
6918 SND_PCI_QUIRK(0x1558, 0, "Clevo laptop", ALC883_LAPTOP_EAPD),
6919 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC883_6ST_DIG),
6920 SND_PCI_QUIRK(0x1458, 0xa002, "MSI", ALC883_6ST_DIG),
6921 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG),
6922 SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG),
6923 SND_PCI_QUIRK(0x1462, 0x7250, "MSI", ALC883_6ST_DIG),
6924 SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG),
6925 SND_PCI_QUIRK(0x1462, 0x7327, "MSI", ALC883_6ST_DIG),
6926 SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG),
6927 SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG),
6928 SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG),
6929 SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG),
6930 SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG),
6931 SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG),
6932 SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG),
6933 SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG),
6934 SND_PCI_QUIRK(0x1462, 0x3fdf, "MSI", ALC883_TARGA_DIG),
6935 SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG),
6936 SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG),
6937 SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG),
6938 SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG),
6939 SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_ACER_ASPIRE),
6940 SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_ACER_ASPIRE),
6941 SND_PCI_QUIRK(0x1025, 0, "Acer laptop", ALC883_ACER),
6942 SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch),
6943 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
6944 SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD),
6945 SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC883_3ST_6ch),
6946 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch),
6947 SND_PCI_QUIRK(0x17aa, 0x3bfd, "Lenovo NB0763", ALC883_LENOVO_NB0763),
6948 SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763),
6949 SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC888_6ST_HP),
6950 SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_3ST_HP),
6951 SND_PCI_QUIRK(0x103c, 0x2a4f, "HP Samba", ALC888_3ST_HP),
6952 SND_PCI_QUIRK(0x17c0, 0x4071, "MEDION MD2", ALC883_MEDION_MD2),
6953 SND_PCI_QUIRK(0x1991, 0x5625, "Haier W66", ALC883_HAIER_W66),
6954 SND_PCI_QUIRK(0x17aa, 0x3bfc, "Lenovo NB0763", ALC883_LENOVO_NB0763),
6958 static struct alc_config_preset alc883_presets[] = {
6959 [ALC883_3ST_2ch_DIG] = {
6960 .mixers = { alc883_3ST_2ch_mixer },
6961 .init_verbs = { alc883_init_verbs },
6962 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6963 .dac_nids = alc883_dac_nids,
6964 .dig_out_nid = ALC883_DIGOUT_NID,
6965 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6966 .adc_nids = alc883_adc_nids,
6967 .dig_in_nid = ALC883_DIGIN_NID,
6968 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
6969 .channel_mode = alc883_3ST_2ch_modes,
6970 .input_mux = &alc883_capture_source,
6972 [ALC883_3ST_6ch_DIG] = {
6973 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
6974 .init_verbs = { alc883_init_verbs },
6975 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6976 .dac_nids = alc883_dac_nids,
6977 .dig_out_nid = ALC883_DIGOUT_NID,
6978 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6979 .adc_nids = alc883_adc_nids,
6980 .dig_in_nid = ALC883_DIGIN_NID,
6981 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
6982 .channel_mode = alc883_3ST_6ch_modes,
6984 .input_mux = &alc883_capture_source,
6986 [ALC883_3ST_6ch] = {
6987 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
6988 .init_verbs = { alc883_init_verbs },
6989 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6990 .dac_nids = alc883_dac_nids,
6991 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6992 .adc_nids = alc883_adc_nids,
6993 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
6994 .channel_mode = alc883_3ST_6ch_modes,
6996 .input_mux = &alc883_capture_source,
6998 [ALC883_6ST_DIG] = {
6999 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
7000 .init_verbs = { alc883_init_verbs },
7001 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7002 .dac_nids = alc883_dac_nids,
7003 .dig_out_nid = ALC883_DIGOUT_NID,
7004 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7005 .adc_nids = alc883_adc_nids,
7006 .dig_in_nid = ALC883_DIGIN_NID,
7007 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
7008 .channel_mode = alc883_sixstack_modes,
7009 .input_mux = &alc883_capture_source,
7011 [ALC883_TARGA_DIG] = {
7012 .mixers = { alc883_tagra_mixer, alc883_chmode_mixer },
7013 .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
7014 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7015 .dac_nids = alc883_dac_nids,
7016 .dig_out_nid = ALC883_DIGOUT_NID,
7017 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7018 .adc_nids = alc883_adc_nids,
7019 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
7020 .channel_mode = alc883_3ST_6ch_modes,
7022 .input_mux = &alc883_capture_source,
7023 .unsol_event = alc883_tagra_unsol_event,
7024 .init_hook = alc883_tagra_automute,
7026 [ALC883_TARGA_2ch_DIG] = {
7027 .mixers = { alc883_tagra_2ch_mixer},
7028 .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
7029 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7030 .dac_nids = alc883_dac_nids,
7031 .dig_out_nid = ALC883_DIGOUT_NID,
7032 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7033 .adc_nids = alc883_adc_nids,
7034 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7035 .channel_mode = alc883_3ST_2ch_modes,
7036 .input_mux = &alc883_capture_source,
7037 .unsol_event = alc883_tagra_unsol_event,
7038 .init_hook = alc883_tagra_automute,
7041 .mixers = { alc883_base_mixer },
7042 /* On TravelMate laptops, GPIO 0 enables the internal speaker
7043 * and the headphone jack. Turn this on and rely on the
7044 * standard mute methods whenever the user wants to turn
7045 * these outputs off.
7047 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs },
7048 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7049 .dac_nids = alc883_dac_nids,
7050 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7051 .adc_nids = alc883_adc_nids,
7052 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7053 .channel_mode = alc883_3ST_2ch_modes,
7054 .input_mux = &alc883_capture_source,
7056 [ALC883_ACER_ASPIRE] = {
7057 .mixers = { alc883_acer_aspire_mixer },
7058 .init_verbs = { alc883_init_verbs, alc883_acer_eapd_verbs },
7059 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7060 .dac_nids = alc883_dac_nids,
7061 .dig_out_nid = ALC883_DIGOUT_NID,
7062 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7063 .adc_nids = alc883_adc_nids,
7064 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7065 .channel_mode = alc883_3ST_2ch_modes,
7066 .input_mux = &alc883_capture_source,
7067 .unsol_event = alc883_acer_aspire_unsol_event,
7068 .init_hook = alc883_acer_aspire_automute,
7071 .mixers = { alc883_fivestack_mixer,
7072 alc883_chmode_mixer },
7073 .init_verbs = { alc883_init_verbs,
7074 alc883_medion_eapd_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_sixstack_modes),
7080 .channel_mode = alc883_sixstack_modes,
7081 .input_mux = &alc883_capture_source,
7083 [ALC883_MEDION_MD2] = {
7084 .mixers = { alc883_medion_md2_mixer},
7085 .init_verbs = { alc883_init_verbs, alc883_medion_md2_verbs},
7086 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7087 .dac_nids = alc883_dac_nids,
7088 .dig_out_nid = ALC883_DIGOUT_NID,
7089 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7090 .adc_nids = alc883_adc_nids,
7091 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7092 .channel_mode = alc883_3ST_2ch_modes,
7093 .input_mux = &alc883_capture_source,
7094 .unsol_event = alc883_medion_md2_unsol_event,
7095 .init_hook = alc883_medion_md2_automute,
7097 [ALC883_LAPTOP_EAPD] = {
7098 .mixers = { alc883_base_mixer },
7099 .init_verbs = { alc883_init_verbs, alc882_eapd_verbs },
7100 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7101 .dac_nids = alc883_dac_nids,
7102 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7103 .adc_nids = alc883_adc_nids,
7104 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7105 .channel_mode = alc883_3ST_2ch_modes,
7106 .input_mux = &alc883_capture_source,
7108 [ALC883_LENOVO_101E_2ch] = {
7109 .mixers = { alc883_lenovo_101e_2ch_mixer},
7110 .init_verbs = { alc883_init_verbs, alc883_lenovo_101e_verbs},
7111 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7112 .dac_nids = alc883_dac_nids,
7113 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7114 .adc_nids = alc883_adc_nids,
7115 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7116 .channel_mode = alc883_3ST_2ch_modes,
7117 .input_mux = &alc883_lenovo_101e_capture_source,
7118 .unsol_event = alc883_lenovo_101e_unsol_event,
7119 .init_hook = alc883_lenovo_101e_all_automute,
7121 [ALC883_LENOVO_NB0763] = {
7122 .mixers = { alc883_lenovo_nb0763_mixer },
7123 .init_verbs = { alc883_init_verbs, alc883_lenovo_nb0763_verbs},
7124 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7125 .dac_nids = alc883_dac_nids,
7126 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7127 .adc_nids = alc883_adc_nids,
7128 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7129 .channel_mode = alc883_3ST_2ch_modes,
7131 .input_mux = &alc883_lenovo_nb0763_capture_source,
7132 .unsol_event = alc883_medion_md2_unsol_event,
7133 .init_hook = alc883_medion_md2_automute,
7135 [ALC888_LENOVO_MS7195_DIG] = {
7136 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
7137 .init_verbs = { alc883_init_verbs, alc888_lenovo_ms7195_verbs},
7138 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7139 .dac_nids = alc883_dac_nids,
7140 .dig_out_nid = ALC883_DIGOUT_NID,
7141 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7142 .adc_nids = alc883_adc_nids,
7143 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
7144 .channel_mode = alc883_3ST_6ch_modes,
7146 .input_mux = &alc883_capture_source,
7147 .unsol_event = alc883_lenovo_ms7195_unsol_event,
7148 .init_hook = alc888_lenovo_ms7195_front_automute,
7150 [ALC883_HAIER_W66] = {
7151 .mixers = { alc883_tagra_2ch_mixer},
7152 .init_verbs = { alc883_init_verbs, alc883_haier_w66_verbs},
7153 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7154 .dac_nids = alc883_dac_nids,
7155 .dig_out_nid = ALC883_DIGOUT_NID,
7156 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7157 .adc_nids = alc883_adc_nids,
7158 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7159 .channel_mode = alc883_3ST_2ch_modes,
7160 .input_mux = &alc883_capture_source,
7161 .unsol_event = alc883_haier_w66_unsol_event,
7162 .init_hook = alc883_haier_w66_automute,
7165 .mixers = { alc888_6st_hp_mixer, alc883_chmode_mixer },
7166 .init_verbs = { alc883_init_verbs, alc888_6st_hp_verbs },
7167 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7168 .dac_nids = alc883_dac_nids,
7169 .dig_out_nid = ALC883_DIGOUT_NID,
7170 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7171 .adc_nids = alc883_adc_nids,
7172 .dig_in_nid = ALC883_DIGIN_NID,
7173 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
7174 .channel_mode = alc883_sixstack_modes,
7175 .input_mux = &alc883_capture_source,
7178 .mixers = { alc888_3st_hp_mixer, alc883_chmode_mixer },
7179 .init_verbs = { alc883_init_verbs, alc888_3st_hp_verbs },
7180 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7181 .dac_nids = alc883_dac_nids,
7182 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7183 .adc_nids = alc883_adc_nids,
7184 .num_channel_mode = ARRAY_SIZE(alc888_3st_hp_modes),
7185 .channel_mode = alc888_3st_hp_modes,
7187 .input_mux = &alc883_capture_source,
7193 * BIOS auto configuration
7195 static void alc883_auto_set_output_and_unmute(struct hda_codec *codec,
7196 hda_nid_t nid, int pin_type,
7200 struct alc_spec *spec = codec->spec;
7203 if (spec->multiout.dac_nids[dac_idx] == 0x25)
7206 idx = spec->multiout.dac_nids[dac_idx] - 2;
7208 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
7210 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
7212 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
7216 static void alc883_auto_init_multi_out(struct hda_codec *codec)
7218 struct alc_spec *spec = codec->spec;
7221 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
7222 for (i = 0; i <= HDA_SIDE; i++) {
7223 hda_nid_t nid = spec->autocfg.line_out_pins[i];
7224 int pin_type = get_pin_type(spec->autocfg.line_out_type);
7226 alc883_auto_set_output_and_unmute(codec, nid, pin_type,
7231 static void alc883_auto_init_hp_out(struct hda_codec *codec)
7233 struct alc_spec *spec = codec->spec;
7236 pin = spec->autocfg.hp_pins[0];
7237 if (pin) /* connect to front */
7239 alc883_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
7242 #define alc883_is_input_pin(nid) alc880_is_input_pin(nid)
7243 #define ALC883_PIN_CD_NID ALC880_PIN_CD_NID
7245 static void alc883_auto_init_analog_input(struct hda_codec *codec)
7247 struct alc_spec *spec = codec->spec;
7250 for (i = 0; i < AUTO_PIN_LAST; i++) {
7251 hda_nid_t nid = spec->autocfg.input_pins[i];
7252 if (alc883_is_input_pin(nid)) {
7253 snd_hda_codec_write(codec, nid, 0,
7254 AC_VERB_SET_PIN_WIDGET_CONTROL,
7255 (i <= AUTO_PIN_FRONT_MIC ?
7256 PIN_VREF80 : PIN_IN));
7257 if (nid != ALC883_PIN_CD_NID)
7258 snd_hda_codec_write(codec, nid, 0,
7259 AC_VERB_SET_AMP_GAIN_MUTE,
7265 /* almost identical with ALC880 parser... */
7266 static int alc883_parse_auto_config(struct hda_codec *codec)
7268 struct alc_spec *spec = codec->spec;
7269 int err = alc880_parse_auto_config(codec);
7274 /* hack - override the init verbs */
7275 spec->init_verbs[0] = alc883_auto_init_verbs;
7276 spec->mixers[spec->num_mixers] = alc883_capture_mixer;
7281 /* additional initialization for auto-configuration model */
7282 static void alc883_auto_init(struct hda_codec *codec)
7284 alc883_auto_init_multi_out(codec);
7285 alc883_auto_init_hp_out(codec);
7286 alc883_auto_init_analog_input(codec);
7289 static int patch_alc883(struct hda_codec *codec)
7291 struct alc_spec *spec;
7292 int err, board_config;
7294 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
7300 board_config = snd_hda_check_board_config(codec, ALC883_MODEL_LAST,
7303 if (board_config < 0) {
7304 printk(KERN_INFO "hda_codec: Unknown model for ALC883, "
7305 "trying auto-probe from BIOS...\n");
7306 board_config = ALC883_AUTO;
7309 if (board_config == ALC883_AUTO) {
7310 /* automatic parse from the BIOS config */
7311 err = alc883_parse_auto_config(codec);
7317 "hda_codec: Cannot set up configuration "
7318 "from BIOS. Using base mode...\n");
7319 board_config = ALC883_3ST_2ch_DIG;
7323 if (board_config != ALC883_AUTO)
7324 setup_preset(spec, &alc883_presets[board_config]);
7326 spec->stream_name_analog = "ALC883 Analog";
7327 spec->stream_analog_playback = &alc883_pcm_analog_playback;
7328 spec->stream_analog_capture = &alc883_pcm_analog_capture;
7330 spec->stream_name_digital = "ALC883 Digital";
7331 spec->stream_digital_playback = &alc883_pcm_digital_playback;
7332 spec->stream_digital_capture = &alc883_pcm_digital_capture;
7334 if (!spec->adc_nids && spec->input_mux) {
7335 spec->adc_nids = alc883_adc_nids;
7336 spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids);
7339 codec->patch_ops = alc_patch_ops;
7340 if (board_config == ALC883_AUTO)
7341 spec->init_hook = alc883_auto_init;
7342 #ifdef CONFIG_SND_HDA_POWER_SAVE
7343 if (!spec->loopback.amplist)
7344 spec->loopback.amplist = alc883_loopbacks;
7354 #define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
7355 #define ALC262_DIGIN_NID ALC880_DIGIN_NID
7357 #define alc262_dac_nids alc260_dac_nids
7358 #define alc262_adc_nids alc882_adc_nids
7359 #define alc262_adc_nids_alt alc882_adc_nids_alt
7361 #define alc262_modes alc260_modes
7362 #define alc262_capture_source alc882_capture_source
7364 static struct snd_kcontrol_new alc262_base_mixer[] = {
7365 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7366 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7367 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7368 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7369 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7370 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7371 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7372 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7373 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7374 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
7375 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
7376 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
7377 /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
7378 HDA_CODEC_MUTE("PC Beelp Playback Switch", 0x0b, 0x05, HDA_INPUT), */
7379 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
7380 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7381 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7382 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
7386 static struct snd_kcontrol_new alc262_hippo1_mixer[] = {
7387 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7388 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7389 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7390 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7391 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7392 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7393 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7394 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7395 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7396 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
7397 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
7398 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
7399 /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
7400 HDA_CODEC_MUTE("PC Beelp Playback Switch", 0x0b, 0x05, HDA_INPUT), */
7401 /*HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),*/
7402 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7406 static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
7407 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7408 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7409 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7410 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7411 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
7413 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7414 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7415 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7416 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
7417 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
7418 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
7419 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7420 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7421 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7422 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7423 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
7424 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
7425 HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
7426 HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
7430 static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = {
7431 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7432 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7433 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7434 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7435 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7436 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
7437 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x02, HDA_INPUT),
7438 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x02, HDA_INPUT),
7439 HDA_CODEC_VOLUME("Front Mic Boost", 0x1a, 0, HDA_INPUT),
7440 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
7441 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
7442 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7443 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7444 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
7445 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
7449 static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = {
7450 HDA_CODEC_VOLUME("Rear Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7451 HDA_CODEC_MUTE("Rear Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7452 HDA_CODEC_VOLUME("Rear Mic Boost", 0x18, 0, HDA_INPUT),
7456 /* bind hp and internal speaker mute (with plug check) */
7457 static int alc262_sony_master_sw_put(struct snd_kcontrol *kcontrol,
7458 struct snd_ctl_elem_value *ucontrol)
7460 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
7461 long *valp = ucontrol->value.integer.value;
7464 /* change hp mute */
7465 change = snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
7467 valp[0] ? 0 : HDA_AMP_MUTE);
7468 change |= snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
7470 valp[1] ? 0 : HDA_AMP_MUTE);
7472 /* change speaker according to HP jack state */
7473 struct alc_spec *spec = codec->spec;
7475 if (spec->jack_present)
7476 mute = HDA_AMP_MUTE;
7478 mute = snd_hda_codec_amp_read(codec, 0x15, 0,
7480 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7481 HDA_AMP_MUTE, mute);
7486 static struct snd_kcontrol_new alc262_sony_mixer[] = {
7487 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7489 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7490 .name = "Master Playback Switch",
7491 .info = snd_hda_mixer_amp_switch_info,
7492 .get = snd_hda_mixer_amp_switch_get,
7493 .put = alc262_sony_master_sw_put,
7494 .private_value = HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
7496 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7497 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7498 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
7499 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
7503 static struct snd_kcontrol_new alc262_benq_t31_mixer[] = {
7504 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7505 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7506 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7507 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7508 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7509 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
7510 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
7514 #define alc262_capture_mixer alc882_capture_mixer
7515 #define alc262_capture_alt_mixer alc882_capture_alt_mixer
7518 * generic initialization of ADC, input mixers and output mixers
7520 static struct hda_verb alc262_init_verbs[] = {
7522 * Unmute ADC0-2 and set the default input to mic-in
7524 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7525 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7526 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7527 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7528 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7529 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7531 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
7533 * Note: PASD motherboards uses the Line In 2 as the input for
7534 * front panel mic (mic 2)
7536 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
7537 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7538 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7539 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7540 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7541 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7544 * Set up output mixers (0x0c - 0x0e)
7546 /* set vol=0 to output mixers */
7547 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7548 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7549 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7550 /* set up input amps for analog loopback */
7551 /* Amp Indices: DAC = 0, mixer = 1 */
7552 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7553 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7554 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7555 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7556 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7557 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7559 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
7560 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
7561 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
7562 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
7563 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
7564 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
7566 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
7567 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
7568 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
7569 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
7570 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
7572 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7573 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
7575 /* FIXME: use matrix-type input source selection */
7576 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7577 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7578 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7579 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
7580 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
7581 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
7583 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7584 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
7585 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
7586 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
7588 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7589 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
7590 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
7591 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
7596 static struct hda_verb alc262_hippo_unsol_verbs[] = {
7597 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
7598 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7602 static struct hda_verb alc262_hippo1_unsol_verbs[] = {
7603 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
7604 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
7605 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
7607 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
7608 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7612 static struct hda_verb alc262_sony_unsol_verbs[] = {
7613 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
7614 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7615 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, // Front Mic
7617 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
7618 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7621 /* mute/unmute internal speaker according to the hp jack and mute state */
7622 static void alc262_hippo_automute(struct hda_codec *codec)
7624 struct alc_spec *spec = codec->spec;
7626 unsigned int present;
7628 /* need to execute and sync at first */
7629 snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
7630 present = snd_hda_codec_read(codec, 0x15, 0,
7631 AC_VERB_GET_PIN_SENSE, 0);
7632 spec->jack_present = (present & 0x80000000) != 0;
7633 if (spec->jack_present) {
7634 /* mute internal speaker */
7635 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7636 HDA_AMP_MUTE, HDA_AMP_MUTE);
7638 /* unmute internal speaker if necessary */
7639 mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0);
7640 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7641 HDA_AMP_MUTE, mute);
7645 /* unsolicited event for HP jack sensing */
7646 static void alc262_hippo_unsol_event(struct hda_codec *codec,
7649 if ((res >> 26) != ALC880_HP_EVENT)
7651 alc262_hippo_automute(codec);
7654 static void alc262_hippo1_automute(struct hda_codec *codec)
7657 unsigned int present;
7659 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
7660 present = snd_hda_codec_read(codec, 0x1b, 0,
7661 AC_VERB_GET_PIN_SENSE, 0);
7662 present = (present & 0x80000000) != 0;
7664 /* mute internal speaker */
7665 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7666 HDA_AMP_MUTE, HDA_AMP_MUTE);
7668 /* unmute internal speaker if necessary */
7669 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
7670 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7671 HDA_AMP_MUTE, mute);
7675 /* unsolicited event for HP jack sensing */
7676 static void alc262_hippo1_unsol_event(struct hda_codec *codec,
7679 if ((res >> 26) != ALC880_HP_EVENT)
7681 alc262_hippo1_automute(codec);
7686 * 0x14 = headphone/spdif-out, 0x15 = internal speaker
7689 #define ALC_HP_EVENT 0x37
7691 static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
7692 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
7693 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7697 static struct hda_input_mux alc262_fujitsu_capture_source = {
7705 static struct hda_input_mux alc262_HP_capture_source = {
7709 { "Front Mic", 0x3 },
7716 /* mute/unmute internal speaker according to the hp jack and mute state */
7717 static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
7719 struct alc_spec *spec = codec->spec;
7722 if (force || !spec->sense_updated) {
7723 unsigned int present;
7724 /* need to execute and sync at first */
7725 snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
7726 present = snd_hda_codec_read(codec, 0x14, 0,
7727 AC_VERB_GET_PIN_SENSE, 0);
7728 spec->jack_present = (present & 0x80000000) != 0;
7729 spec->sense_updated = 1;
7731 if (spec->jack_present) {
7732 /* mute internal speaker */
7733 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7734 HDA_AMP_MUTE, HDA_AMP_MUTE);
7736 /* unmute internal speaker if necessary */
7737 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
7738 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7739 HDA_AMP_MUTE, mute);
7743 /* unsolicited event for HP jack sensing */
7744 static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
7747 if ((res >> 26) != ALC_HP_EVENT)
7749 alc262_fujitsu_automute(codec, 1);
7752 /* bind volumes of both NID 0x0c and 0x0d */
7753 static struct hda_bind_ctls alc262_fujitsu_bind_master_vol = {
7754 .ops = &snd_hda_bind_vol,
7756 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
7757 HDA_COMPOSE_AMP_VAL(0x0d, 3, 0, HDA_OUTPUT),
7762 /* bind hp and internal speaker mute (with plug check) */
7763 static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
7764 struct snd_ctl_elem_value *ucontrol)
7766 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
7767 long *valp = ucontrol->value.integer.value;
7770 change = snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
7772 valp[0] ? 0 : HDA_AMP_MUTE);
7773 change |= snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
7775 valp[1] ? 0 : HDA_AMP_MUTE);
7777 alc262_fujitsu_automute(codec, 0);
7781 static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
7782 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
7784 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7785 .name = "Master Playback Switch",
7786 .info = snd_hda_mixer_amp_switch_info,
7787 .get = snd_hda_mixer_amp_switch_get,
7788 .put = alc262_fujitsu_master_sw_put,
7789 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
7791 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7792 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7793 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7794 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7795 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7799 /* additional init verbs for Benq laptops */
7800 static struct hda_verb alc262_EAPD_verbs[] = {
7801 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
7802 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
7806 static struct hda_verb alc262_benq_t31_EAPD_verbs[] = {
7807 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7808 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
7810 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
7811 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
7815 /* add playback controls from the parsed DAC table */
7816 static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec,
7817 const struct auto_pin_cfg *cfg)
7822 spec->multiout.num_dacs = 1; /* only use one dac */
7823 spec->multiout.dac_nids = spec->private_dac_nids;
7824 spec->multiout.dac_nids[0] = 2;
7826 nid = cfg->line_out_pins[0];
7828 err = add_control(spec, ALC_CTL_WIDGET_VOL,
7829 "Front Playback Volume",
7830 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT));
7833 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
7834 "Front Playback Switch",
7835 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
7840 nid = cfg->speaker_pins[0];
7843 err = add_control(spec, ALC_CTL_WIDGET_VOL,
7844 "Speaker Playback Volume",
7845 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
7849 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
7850 "Speaker Playback Switch",
7851 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
7856 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
7857 "Speaker Playback Switch",
7858 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
7864 nid = cfg->hp_pins[0];
7866 /* spec->multiout.hp_nid = 2; */
7868 err = add_control(spec, ALC_CTL_WIDGET_VOL,
7869 "Headphone Playback Volume",
7870 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
7874 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
7875 "Headphone Playback Switch",
7876 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
7881 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
7882 "Headphone Playback Switch",
7883 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
7892 /* identical with ALC880 */
7893 #define alc262_auto_create_analog_input_ctls \
7894 alc880_auto_create_analog_input_ctls
7897 * generic initialization of ADC, input mixers and output mixers
7899 static struct hda_verb alc262_volume_init_verbs[] = {
7901 * Unmute ADC0-2 and set the default input to mic-in
7903 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7904 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7905 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7906 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7907 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7908 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7910 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
7912 * Note: PASD motherboards uses the Line In 2 as the input for
7913 * front panel mic (mic 2)
7915 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
7916 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7917 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7918 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7919 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7920 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7923 * Set up output mixers (0x0c - 0x0f)
7925 /* set vol=0 to output mixers */
7926 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7927 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7928 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7930 /* set up input amps for analog loopback */
7931 /* Amp Indices: DAC = 0, mixer = 1 */
7932 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7933 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7934 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7935 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7936 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7937 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7939 /* FIXME: use matrix-type input source selection */
7940 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7941 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7942 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7943 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
7944 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
7945 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
7947 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7948 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
7949 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
7950 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
7952 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7953 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
7954 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
7955 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
7960 static struct hda_verb alc262_HP_BPC_init_verbs[] = {
7962 * Unmute ADC0-2 and set the default input to mic-in
7964 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7965 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7966 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7967 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7968 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7969 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7971 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
7973 * Note: PASD motherboards uses the Line In 2 as the input for
7974 * front panel mic (mic 2)
7976 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
7977 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7978 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7979 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7980 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7981 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7982 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
7983 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
7986 * Set up output mixers (0x0c - 0x0e)
7988 /* set vol=0 to output mixers */
7989 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7990 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7991 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7993 /* set up input amps for analog loopback */
7994 /* Amp Indices: DAC = 0, mixer = 1 */
7995 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7996 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7997 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7998 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7999 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8000 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8002 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
8003 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8004 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8006 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
8007 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
8009 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
8010 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8012 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
8013 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
8014 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
8015 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
8016 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
8018 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
8019 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
8020 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
8021 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
8022 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
8023 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
8026 /* FIXME: use matrix-type input source selection */
8027 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
8028 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
8029 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8030 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
8031 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
8032 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
8034 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8035 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
8036 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
8037 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
8039 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8040 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
8041 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
8042 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
8047 static struct hda_verb alc262_HP_BPC_WildWest_init_verbs[] = {
8049 * Unmute ADC0-2 and set the default input to mic-in
8051 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
8052 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8053 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8054 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8055 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8056 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8058 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
8060 * Note: PASD motherboards uses the Line In 2 as the input for front
8063 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
8064 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8065 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8066 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8067 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8068 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8069 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
8070 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
8071 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
8073 * Set up output mixers (0x0c - 0x0e)
8075 /* set vol=0 to output mixers */
8076 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8077 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8078 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8080 /* set up input amps for analog loopback */
8081 /* Amp Indices: DAC = 0, mixer = 1 */
8082 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8083 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8084 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8085 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8086 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8087 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8090 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP */
8091 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Mono */
8092 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* rear MIC */
8093 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* Line in */
8094 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
8095 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Line out */
8096 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD in */
8098 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
8099 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
8101 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
8102 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
8104 /* {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, */
8105 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
8106 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
8107 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
8108 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
8109 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
8111 /* FIXME: use matrix-type input source selection */
8112 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
8113 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
8114 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, /*rear MIC*/
8115 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, /*Line in*/
8116 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, /*F MIC*/
8117 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, /*Front*/
8118 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, /*CD*/
8119 /* {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
8120 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, /*HP*/
8122 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8123 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
8124 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
8125 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
8126 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
8127 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
8128 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
8130 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8131 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
8132 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
8133 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
8134 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
8135 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
8136 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
8141 #ifdef CONFIG_SND_HDA_POWER_SAVE
8142 #define alc262_loopbacks alc880_loopbacks
8145 /* pcm configuration: identiacal with ALC880 */
8146 #define alc262_pcm_analog_playback alc880_pcm_analog_playback
8147 #define alc262_pcm_analog_capture alc880_pcm_analog_capture
8148 #define alc262_pcm_digital_playback alc880_pcm_digital_playback
8149 #define alc262_pcm_digital_capture alc880_pcm_digital_capture
8152 * BIOS auto configuration
8154 static int alc262_parse_auto_config(struct hda_codec *codec)
8156 struct alc_spec *spec = codec->spec;
8158 static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
8160 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
8164 if (!spec->autocfg.line_outs)
8165 return 0; /* can't find valid BIOS pin config */
8166 err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg);
8169 err = alc262_auto_create_analog_input_ctls(spec, &spec->autocfg);
8173 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
8175 if (spec->autocfg.dig_out_pin)
8176 spec->multiout.dig_out_nid = ALC262_DIGOUT_NID;
8177 if (spec->autocfg.dig_in_pin)
8178 spec->dig_in_nid = ALC262_DIGIN_NID;
8180 if (spec->kctl_alloc)
8181 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
8183 spec->init_verbs[spec->num_init_verbs++] = alc262_volume_init_verbs;
8184 spec->num_mux_defs = 1;
8185 spec->input_mux = &spec->private_imux;
8190 #define alc262_auto_init_multi_out alc882_auto_init_multi_out
8191 #define alc262_auto_init_hp_out alc882_auto_init_hp_out
8192 #define alc262_auto_init_analog_input alc882_auto_init_analog_input
8195 /* init callback for auto-configuration model -- overriding the default init */
8196 static void alc262_auto_init(struct hda_codec *codec)
8198 alc262_auto_init_multi_out(codec);
8199 alc262_auto_init_hp_out(codec);
8200 alc262_auto_init_analog_input(codec);
8204 * configuration and preset
8206 static const char *alc262_models[ALC262_MODEL_LAST] = {
8207 [ALC262_BASIC] = "basic",
8208 [ALC262_HIPPO] = "hippo",
8209 [ALC262_HIPPO_1] = "hippo_1",
8210 [ALC262_FUJITSU] = "fujitsu",
8211 [ALC262_HP_BPC] = "hp-bpc",
8212 [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000",
8213 [ALC262_BENQ_ED8] = "benq",
8214 [ALC262_BENQ_T31] = "benq-t31",
8215 [ALC262_SONY_ASSAMD] = "sony-assamd",
8216 [ALC262_AUTO] = "auto",
8219 static struct snd_pci_quirk alc262_cfg_tbl[] = {
8220 SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO),
8221 SND_PCI_QUIRK(0x103c, 0x12fe, "HP xw9400", ALC262_HP_BPC),
8222 SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC),
8223 SND_PCI_QUIRK(0x103c, 0x12ff, "HP xw4550", ALC262_HP_BPC),
8224 SND_PCI_QUIRK(0x103c, 0x1308, "HP xw4600", ALC262_HP_BPC),
8225 SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC),
8226 SND_PCI_QUIRK(0x103c, 0x1307, "HP xw6600", ALC262_HP_BPC),
8227 SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC),
8228 SND_PCI_QUIRK(0x103c, 0x1306, "HP xw8600", ALC262_HP_BPC),
8229 SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL),
8230 SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL),
8231 SND_PCI_QUIRK(0x103c, 0x2804, "HP D7000", ALC262_HP_BPC_D7000_WL),
8232 SND_PCI_QUIRK(0x103c, 0x2806, "HP D7000", ALC262_HP_BPC_D7000_WL),
8233 SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF),
8234 SND_PCI_QUIRK(0x103c, 0x2803, "HP D7000", ALC262_HP_BPC_D7000_WF),
8235 SND_PCI_QUIRK(0x103c, 0x2805, "HP D7000", ALC262_HP_BPC_D7000_WF),
8236 SND_PCI_QUIRK(0x103c, 0x2807, "HP D7000", ALC262_HP_BPC_D7000_WF),
8237 SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO),
8238 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
8239 SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1),
8240 SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
8241 SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_BENQ_T31),
8242 SND_PCI_QUIRK(0x104d, 0x820f, "Sony ASSAMD", ALC262_SONY_ASSAMD),
8243 SND_PCI_QUIRK(0x104d, 0x9015, "Sony 0x9015", ALC262_SONY_ASSAMD),
8244 SND_PCI_QUIRK(0x104d, 0x900e, "Sony ASSAMD", ALC262_SONY_ASSAMD),
8245 SND_PCI_QUIRK(0x104d, 0x1f00, "Sony ASSAMD", ALC262_SONY_ASSAMD),
8249 static struct alc_config_preset alc262_presets[] = {
8251 .mixers = { alc262_base_mixer },
8252 .init_verbs = { alc262_init_verbs },
8253 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
8254 .dac_nids = alc262_dac_nids,
8256 .num_channel_mode = ARRAY_SIZE(alc262_modes),
8257 .channel_mode = alc262_modes,
8258 .input_mux = &alc262_capture_source,
8261 .mixers = { alc262_base_mixer },
8262 .init_verbs = { alc262_init_verbs, alc262_hippo_unsol_verbs},
8263 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
8264 .dac_nids = alc262_dac_nids,
8266 .dig_out_nid = ALC262_DIGOUT_NID,
8267 .num_channel_mode = ARRAY_SIZE(alc262_modes),
8268 .channel_mode = alc262_modes,
8269 .input_mux = &alc262_capture_source,
8270 .unsol_event = alc262_hippo_unsol_event,
8271 .init_hook = alc262_hippo_automute,
8273 [ALC262_HIPPO_1] = {
8274 .mixers = { alc262_hippo1_mixer },
8275 .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs},
8276 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
8277 .dac_nids = alc262_dac_nids,
8279 .dig_out_nid = ALC262_DIGOUT_NID,
8280 .num_channel_mode = ARRAY_SIZE(alc262_modes),
8281 .channel_mode = alc262_modes,
8282 .input_mux = &alc262_capture_source,
8283 .unsol_event = alc262_hippo1_unsol_event,
8284 .init_hook = alc262_hippo1_automute,
8286 [ALC262_FUJITSU] = {
8287 .mixers = { alc262_fujitsu_mixer },
8288 .init_verbs = { alc262_init_verbs, alc262_fujitsu_unsol_verbs },
8289 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
8290 .dac_nids = alc262_dac_nids,
8292 .dig_out_nid = ALC262_DIGOUT_NID,
8293 .num_channel_mode = ARRAY_SIZE(alc262_modes),
8294 .channel_mode = alc262_modes,
8295 .input_mux = &alc262_fujitsu_capture_source,
8296 .unsol_event = alc262_fujitsu_unsol_event,
8299 .mixers = { alc262_HP_BPC_mixer },
8300 .init_verbs = { alc262_HP_BPC_init_verbs },
8301 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
8302 .dac_nids = alc262_dac_nids,
8304 .num_channel_mode = ARRAY_SIZE(alc262_modes),
8305 .channel_mode = alc262_modes,
8306 .input_mux = &alc262_HP_capture_source,
8308 [ALC262_HP_BPC_D7000_WF] = {
8309 .mixers = { alc262_HP_BPC_WildWest_mixer },
8310 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
8311 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
8312 .dac_nids = alc262_dac_nids,
8314 .num_channel_mode = ARRAY_SIZE(alc262_modes),
8315 .channel_mode = alc262_modes,
8316 .input_mux = &alc262_HP_capture_source,
8318 [ALC262_HP_BPC_D7000_WL] = {
8319 .mixers = { alc262_HP_BPC_WildWest_mixer,
8320 alc262_HP_BPC_WildWest_option_mixer },
8321 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
8322 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
8323 .dac_nids = alc262_dac_nids,
8325 .num_channel_mode = ARRAY_SIZE(alc262_modes),
8326 .channel_mode = alc262_modes,
8327 .input_mux = &alc262_HP_capture_source,
8329 [ALC262_BENQ_ED8] = {
8330 .mixers = { alc262_base_mixer },
8331 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
8332 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
8333 .dac_nids = alc262_dac_nids,
8335 .num_channel_mode = ARRAY_SIZE(alc262_modes),
8336 .channel_mode = alc262_modes,
8337 .input_mux = &alc262_capture_source,
8339 [ALC262_SONY_ASSAMD] = {
8340 .mixers = { alc262_sony_mixer },
8341 .init_verbs = { alc262_init_verbs, alc262_sony_unsol_verbs},
8342 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
8343 .dac_nids = alc262_dac_nids,
8345 .num_channel_mode = ARRAY_SIZE(alc262_modes),
8346 .channel_mode = alc262_modes,
8347 .input_mux = &alc262_capture_source,
8348 .unsol_event = alc262_hippo_unsol_event,
8349 .init_hook = alc262_hippo_automute,
8351 [ALC262_BENQ_T31] = {
8352 .mixers = { alc262_benq_t31_mixer },
8353 .init_verbs = { alc262_init_verbs, alc262_benq_t31_EAPD_verbs, alc262_hippo_unsol_verbs },
8354 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
8355 .dac_nids = alc262_dac_nids,
8357 .num_channel_mode = ARRAY_SIZE(alc262_modes),
8358 .channel_mode = alc262_modes,
8359 .input_mux = &alc262_capture_source,
8360 .unsol_event = alc262_hippo_unsol_event,
8361 .init_hook = alc262_hippo_automute,
8365 static int patch_alc262(struct hda_codec *codec)
8367 struct alc_spec *spec;
8371 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
8377 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
8382 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
8383 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
8384 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
8385 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
8389 board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST,
8393 if (board_config < 0) {
8394 printk(KERN_INFO "hda_codec: Unknown model for ALC262, "
8395 "trying auto-probe from BIOS...\n");
8396 board_config = ALC262_AUTO;
8399 if (board_config == ALC262_AUTO) {
8400 /* automatic parse from the BIOS config */
8401 err = alc262_parse_auto_config(codec);
8407 "hda_codec: Cannot set up configuration "
8408 "from BIOS. Using base mode...\n");
8409 board_config = ALC262_BASIC;
8413 if (board_config != ALC262_AUTO)
8414 setup_preset(spec, &alc262_presets[board_config]);
8416 spec->stream_name_analog = "ALC262 Analog";
8417 spec->stream_analog_playback = &alc262_pcm_analog_playback;
8418 spec->stream_analog_capture = &alc262_pcm_analog_capture;
8420 spec->stream_name_digital = "ALC262 Digital";
8421 spec->stream_digital_playback = &alc262_pcm_digital_playback;
8422 spec->stream_digital_capture = &alc262_pcm_digital_capture;
8424 if (!spec->adc_nids && spec->input_mux) {
8425 /* check whether NID 0x07 is valid */
8426 unsigned int wcap = get_wcaps(codec, 0x07);
8429 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
8430 if (wcap != AC_WID_AUD_IN) {
8431 spec->adc_nids = alc262_adc_nids_alt;
8432 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids_alt);
8433 spec->mixers[spec->num_mixers] =
8434 alc262_capture_alt_mixer;
8437 spec->adc_nids = alc262_adc_nids;
8438 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids);
8439 spec->mixers[spec->num_mixers] = alc262_capture_mixer;
8444 codec->patch_ops = alc_patch_ops;
8445 if (board_config == ALC262_AUTO)
8446 spec->init_hook = alc262_auto_init;
8447 #ifdef CONFIG_SND_HDA_POWER_SAVE
8448 if (!spec->loopback.amplist)
8449 spec->loopback.amplist = alc262_loopbacks;
8456 * ALC268 channel source setting (2 channel)
8458 #define ALC268_DIGOUT_NID ALC880_DIGOUT_NID
8459 #define alc268_modes alc260_modes
8461 static hda_nid_t alc268_dac_nids[2] = {
8466 static hda_nid_t alc268_adc_nids[2] = {
8471 static hda_nid_t alc268_adc_nids_alt[1] = {
8476 static struct snd_kcontrol_new alc268_base_mixer[] = {
8477 /* output mixer control */
8478 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
8479 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8480 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
8481 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8482 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8483 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
8484 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
8488 static struct hda_verb alc268_eapd_verbs[] = {
8489 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
8490 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
8494 /* Toshiba specific */
8495 #define alc268_toshiba_automute alc262_hippo_automute
8497 static struct hda_verb alc268_toshiba_verbs[] = {
8498 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8503 /* bind volumes of both NID 0x02 and 0x03 */
8504 static struct hda_bind_ctls alc268_acer_bind_master_vol = {
8505 .ops = &snd_hda_bind_vol,
8507 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
8508 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
8513 /* mute/unmute internal speaker according to the hp jack and mute state */
8514 static void alc268_acer_automute(struct hda_codec *codec, int force)
8516 struct alc_spec *spec = codec->spec;
8519 if (force || !spec->sense_updated) {
8520 unsigned int present;
8521 present = snd_hda_codec_read(codec, 0x14, 0,
8522 AC_VERB_GET_PIN_SENSE, 0);
8523 spec->jack_present = (present & 0x80000000) != 0;
8524 spec->sense_updated = 1;
8526 if (spec->jack_present)
8527 mute = HDA_AMP_MUTE; /* mute internal speaker */
8528 else /* unmute internal speaker if necessary */
8529 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
8530 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8531 HDA_AMP_MUTE, mute);
8535 /* bind hp and internal speaker mute (with plug check) */
8536 static int alc268_acer_master_sw_put(struct snd_kcontrol *kcontrol,
8537 struct snd_ctl_elem_value *ucontrol)
8539 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
8540 long *valp = ucontrol->value.integer.value;
8543 change = snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
8545 valp[0] ? 0 : HDA_AMP_MUTE);
8546 change |= snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
8548 valp[1] ? 0 : HDA_AMP_MUTE);
8550 alc268_acer_automute(codec, 0);
8554 static struct snd_kcontrol_new alc268_acer_mixer[] = {
8555 /* output mixer control */
8556 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
8558 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8559 .name = "Master Playback Switch",
8560 .info = snd_hda_mixer_amp_switch_info,
8561 .get = snd_hda_mixer_amp_switch_get,
8562 .put = alc268_acer_master_sw_put,
8563 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
8565 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8566 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
8567 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
8571 static struct hda_verb alc268_acer_verbs[] = {
8572 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8573 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8575 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8579 /* unsolicited event for HP jack sensing */
8580 static void alc268_toshiba_unsol_event(struct hda_codec *codec,
8583 if ((res >> 26) != ALC880_HP_EVENT)
8585 alc268_toshiba_automute(codec);
8588 static void alc268_acer_unsol_event(struct hda_codec *codec,
8591 if ((res >> 26) != ALC880_HP_EVENT)
8593 alc268_acer_automute(codec, 1);
8596 static void alc268_acer_init_hook(struct hda_codec *codec)
8598 alc268_acer_automute(codec, 1);
8602 * generic initialization of ADC, input mixers and output mixers
8604 static struct hda_verb alc268_base_init_verbs[] = {
8605 /* Unmute DAC0-1 and set vol = 0 */
8606 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8607 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8608 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8609 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8610 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8611 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8614 * Set up output mixers (0x0c - 0x0e)
8616 /* set vol=0 to output mixers */
8617 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8618 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8619 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8620 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
8622 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8623 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8625 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
8626 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
8627 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
8628 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
8629 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
8630 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
8631 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
8632 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
8634 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8635 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8636 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8637 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8638 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8639 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8640 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8641 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8643 /* FIXME: use matrix-type input source selection */
8644 /* Mixer elements: 0x18, 19, 1a, 1c, 14, 15, 0b */
8645 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
8647 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8648 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
8649 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
8650 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
8652 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8653 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
8654 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
8655 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
8660 * generic initialization of ADC, input mixers and output mixers
8662 static struct hda_verb alc268_volume_init_verbs[] = {
8663 /* set output DAC */
8664 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8665 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8666 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8667 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8669 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
8670 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
8671 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
8672 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
8673 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
8675 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8676 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8677 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8678 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8679 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8681 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8682 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8683 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8684 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8686 /* set PCBEEP vol = 0 */
8687 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, (0xb000 | (0x00 << 8))},
8692 #define alc268_mux_enum_info alc_mux_enum_info
8693 #define alc268_mux_enum_get alc_mux_enum_get
8695 static int alc268_mux_enum_put(struct snd_kcontrol *kcontrol,
8696 struct snd_ctl_elem_value *ucontrol)
8698 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
8699 struct alc_spec *spec = codec->spec;
8700 const struct hda_input_mux *imux = spec->input_mux;
8701 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
8702 static hda_nid_t capture_mixers[3] = { 0x23, 0x24 };
8703 hda_nid_t nid = capture_mixers[adc_idx];
8704 unsigned int *cur_val = &spec->cur_mux[adc_idx];
8705 unsigned int i, idx;
8707 idx = ucontrol->value.enumerated.item[0];
8708 if (idx >= imux->num_items)
8709 idx = imux->num_items - 1;
8710 if (*cur_val == idx)
8712 for (i = 0; i < imux->num_items; i++) {
8713 unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
8714 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
8715 imux->items[i].index,
8717 snd_hda_codec_write_cache(codec, nid, 0,
8718 AC_VERB_SET_CONNECT_SEL,
8725 static struct snd_kcontrol_new alc268_capture_alt_mixer[] = {
8726 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
8727 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
8729 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8730 /* The multiple "Capture Source" controls confuse alsamixer
8731 * So call somewhat different..
8732 * FIXME: the controls appear in the "playback" view!
8734 /* .name = "Capture Source", */
8735 .name = "Input Source",
8737 .info = alc268_mux_enum_info,
8738 .get = alc268_mux_enum_get,
8739 .put = alc268_mux_enum_put,
8744 static struct snd_kcontrol_new alc268_capture_mixer[] = {
8745 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
8746 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
8747 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x24, 0x0, HDA_OUTPUT),
8748 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x24, 0x0, HDA_OUTPUT),
8750 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8751 /* The multiple "Capture Source" controls confuse alsamixer
8752 * So call somewhat different..
8753 * FIXME: the controls appear in the "playback" view!
8755 /* .name = "Capture Source", */
8756 .name = "Input Source",
8758 .info = alc268_mux_enum_info,
8759 .get = alc268_mux_enum_get,
8760 .put = alc268_mux_enum_put,
8765 static struct hda_input_mux alc268_capture_source = {
8769 { "Front Mic", 0x1 },
8775 /* create input playback/capture controls for the given pin */
8776 static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
8777 const char *ctlname, int idx)
8782 sprintf(name, "%s Playback Volume", ctlname);
8784 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
8785 HDA_COMPOSE_AMP_VAL(0x02, 3, idx,
8789 } else if (nid == 0x15) {
8790 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
8791 HDA_COMPOSE_AMP_VAL(0x03, 3, idx,
8797 sprintf(name, "%s Playback Switch", ctlname);
8798 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
8799 HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
8805 /* add playback controls from the parsed DAC table */
8806 static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec,
8807 const struct auto_pin_cfg *cfg)
8812 spec->multiout.num_dacs = 2; /* only use one dac */
8813 spec->multiout.dac_nids = spec->private_dac_nids;
8814 spec->multiout.dac_nids[0] = 2;
8815 spec->multiout.dac_nids[1] = 3;
8817 nid = cfg->line_out_pins[0];
8819 alc268_new_analog_output(spec, nid, "Front", 0);
8821 nid = cfg->speaker_pins[0];
8823 err = add_control(spec, ALC_CTL_WIDGET_VOL,
8824 "Speaker Playback Volume",
8825 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
8829 nid = cfg->hp_pins[0];
8831 alc268_new_analog_output(spec, nid, "Headphone", 0);
8833 nid = cfg->line_out_pins[1] | cfg->line_out_pins[2];
8835 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
8836 "Mono Playback Switch",
8837 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_INPUT));
8844 /* create playback/capture controls for input pins */
8845 static int alc268_auto_create_analog_input_ctls(struct alc_spec *spec,
8846 const struct auto_pin_cfg *cfg)
8848 struct hda_input_mux *imux = &spec->private_imux;
8851 for (i = 0; i < AUTO_PIN_LAST; i++) {
8852 switch(cfg->input_pins[i]) {
8854 idx1 = 0; /* Mic 1 */
8857 idx1 = 1; /* Mic 2 */
8860 idx1 = 2; /* Line In */
8868 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
8869 imux->items[imux->num_items].index = idx1;
8875 static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec)
8877 struct alc_spec *spec = codec->spec;
8878 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
8879 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
8880 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
8881 unsigned int dac_vol1, dac_vol2;
8884 snd_hda_codec_write(codec, speaker_nid, 0,
8885 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
8886 snd_hda_codec_write(codec, 0x0f, 0,
8887 AC_VERB_SET_AMP_GAIN_MUTE,
8889 snd_hda_codec_write(codec, 0x10, 0,
8890 AC_VERB_SET_AMP_GAIN_MUTE,
8893 snd_hda_codec_write(codec, 0x0f, 0,
8894 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
8895 snd_hda_codec_write(codec, 0x10, 0,
8896 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
8899 dac_vol1 = dac_vol2 = 0xb000 | 0x40; /* set max volume */
8900 if (line_nid == 0x14)
8901 dac_vol2 = AMP_OUT_ZERO;
8902 else if (line_nid == 0x15)
8903 dac_vol1 = AMP_OUT_ZERO;
8905 dac_vol2 = AMP_OUT_ZERO;
8906 else if (hp_nid == 0x15)
8907 dac_vol1 = AMP_OUT_ZERO;
8908 if (line_nid != 0x16 || hp_nid != 0x16 ||
8909 spec->autocfg.line_out_pins[1] != 0x16 ||
8910 spec->autocfg.line_out_pins[2] != 0x16)
8911 dac_vol1 = dac_vol2 = AMP_OUT_ZERO;
8913 snd_hda_codec_write(codec, 0x02, 0,
8914 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol1);
8915 snd_hda_codec_write(codec, 0x03, 0,
8916 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol2);
8919 /* pcm configuration: identiacal with ALC880 */
8920 #define alc268_pcm_analog_playback alc880_pcm_analog_playback
8921 #define alc268_pcm_analog_capture alc880_pcm_analog_capture
8922 #define alc268_pcm_digital_playback alc880_pcm_digital_playback
8925 * BIOS auto configuration
8927 static int alc268_parse_auto_config(struct hda_codec *codec)
8929 struct alc_spec *spec = codec->spec;
8931 static hda_nid_t alc268_ignore[] = { 0 };
8933 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
8937 if (!spec->autocfg.line_outs)
8938 return 0; /* can't find valid BIOS pin config */
8940 err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg);
8943 err = alc268_auto_create_analog_input_ctls(spec, &spec->autocfg);
8947 spec->multiout.max_channels = 2;
8949 /* digital only support output */
8950 if (spec->autocfg.dig_out_pin)
8951 spec->multiout.dig_out_nid = ALC268_DIGOUT_NID;
8953 if (spec->kctl_alloc)
8954 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
8956 spec->init_verbs[spec->num_init_verbs++] = alc268_volume_init_verbs;
8957 spec->num_mux_defs = 1;
8958 spec->input_mux = &spec->private_imux;
8963 #define alc268_auto_init_multi_out alc882_auto_init_multi_out
8964 #define alc268_auto_init_hp_out alc882_auto_init_hp_out
8965 #define alc268_auto_init_analog_input alc882_auto_init_analog_input
8967 /* init callback for auto-configuration model -- overriding the default init */
8968 static void alc268_auto_init(struct hda_codec *codec)
8970 alc268_auto_init_multi_out(codec);
8971 alc268_auto_init_hp_out(codec);
8972 alc268_auto_init_mono_speaker_out(codec);
8973 alc268_auto_init_analog_input(codec);
8977 * configuration and preset
8979 static const char *alc268_models[ALC268_MODEL_LAST] = {
8980 [ALC268_3ST] = "3stack",
8981 [ALC268_TOSHIBA] = "toshiba",
8982 [ALC268_ACER] = "acer",
8983 [ALC268_AUTO] = "auto",
8986 static struct snd_pci_quirk alc268_cfg_tbl[] = {
8987 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST),
8988 SND_PCI_QUIRK(0x1179, 0xff10, "TOSHIBA A205", ALC268_TOSHIBA),
8989 SND_PCI_QUIRK(0x103c, 0x30cc, "TOSHIBA", ALC268_TOSHIBA),
8990 SND_PCI_QUIRK(0x1025, 0x0126, "Acer", ALC268_ACER),
8991 SND_PCI_QUIRK(0x1025, 0x0130, "Acer Extensa 5210", ALC268_ACER),
8995 static struct alc_config_preset alc268_presets[] = {
8997 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer },
8998 .init_verbs = { alc268_base_init_verbs },
8999 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
9000 .dac_nids = alc268_dac_nids,
9001 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
9002 .adc_nids = alc268_adc_nids_alt,
9004 .dig_out_nid = ALC268_DIGOUT_NID,
9005 .num_channel_mode = ARRAY_SIZE(alc268_modes),
9006 .channel_mode = alc268_modes,
9007 .input_mux = &alc268_capture_source,
9009 [ALC268_TOSHIBA] = {
9010 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer },
9011 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
9012 alc268_toshiba_verbs },
9013 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
9014 .dac_nids = alc268_dac_nids,
9015 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
9016 .adc_nids = alc268_adc_nids_alt,
9018 .num_channel_mode = ARRAY_SIZE(alc268_modes),
9019 .channel_mode = alc268_modes,
9020 .input_mux = &alc268_capture_source,
9021 .input_mux = &alc268_capture_source,
9022 .unsol_event = alc268_toshiba_unsol_event,
9023 .init_hook = alc268_toshiba_automute,
9026 .mixers = { alc268_acer_mixer, alc268_capture_alt_mixer },
9027 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
9028 alc268_acer_verbs },
9029 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
9030 .dac_nids = alc268_dac_nids,
9031 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
9032 .adc_nids = alc268_adc_nids_alt,
9034 .num_channel_mode = ARRAY_SIZE(alc268_modes),
9035 .channel_mode = alc268_modes,
9036 .input_mux = &alc268_capture_source,
9037 .unsol_event = alc268_acer_unsol_event,
9038 .init_hook = alc268_acer_init_hook,
9042 static int patch_alc268(struct hda_codec *codec)
9044 struct alc_spec *spec;
9048 spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
9054 board_config = snd_hda_check_board_config(codec, ALC268_MODEL_LAST,
9058 if (board_config < 0 || board_config >= ALC268_MODEL_LAST) {
9059 printk(KERN_INFO "hda_codec: Unknown model for ALC268, "
9060 "trying auto-probe from BIOS...\n");
9061 board_config = ALC268_AUTO;
9064 if (board_config == ALC268_AUTO) {
9065 /* automatic parse from the BIOS config */
9066 err = alc268_parse_auto_config(codec);
9072 "hda_codec: Cannot set up configuration "
9073 "from BIOS. Using base mode...\n");
9074 board_config = ALC268_3ST;
9078 if (board_config != ALC268_AUTO)
9079 setup_preset(spec, &alc268_presets[board_config]);
9081 spec->stream_name_analog = "ALC268 Analog";
9082 spec->stream_analog_playback = &alc268_pcm_analog_playback;
9083 spec->stream_analog_capture = &alc268_pcm_analog_capture;
9085 spec->stream_name_digital = "ALC268 Digital";
9086 spec->stream_digital_playback = &alc268_pcm_digital_playback;
9088 if (board_config == ALC268_AUTO) {
9089 if (!spec->adc_nids && spec->input_mux) {
9090 /* check whether NID 0x07 is valid */
9091 unsigned int wcap = get_wcaps(codec, 0x07);
9094 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
9095 if (wcap != AC_WID_AUD_IN) {
9096 spec->adc_nids = alc268_adc_nids_alt;
9097 spec->num_adc_nids =
9098 ARRAY_SIZE(alc268_adc_nids_alt);
9099 spec->mixers[spec->num_mixers] =
9100 alc268_capture_alt_mixer;
9103 spec->adc_nids = alc268_adc_nids;
9104 spec->num_adc_nids =
9105 ARRAY_SIZE(alc268_adc_nids);
9106 spec->mixers[spec->num_mixers] =
9107 alc268_capture_mixer;
9112 codec->patch_ops = alc_patch_ops;
9113 if (board_config == ALC268_AUTO)
9114 spec->init_hook = alc268_auto_init;
9120 * ALC861 channel source setting (2/6 channel selection for 3-stack)
9124 * set the path ways for 2 channel output
9125 * need to set the codec line out and mic 1 pin widgets to inputs
9127 static struct hda_verb alc861_threestack_ch2_init[] = {
9128 /* set pin widget 1Ah (line in) for input */
9129 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
9130 /* set pin widget 18h (mic1/2) for input, for mic also enable
9133 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
9135 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
9137 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
9138 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
9144 * need to set the codec line out and mic 1 pin widgets to outputs
9146 static struct hda_verb alc861_threestack_ch6_init[] = {
9147 /* set pin widget 1Ah (line in) for output (Back Surround)*/
9148 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
9149 /* set pin widget 18h (mic1) for output (CLFE)*/
9150 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
9152 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
9153 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
9155 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
9157 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
9158 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
9163 static struct hda_channel_mode alc861_threestack_modes[2] = {
9164 { 2, alc861_threestack_ch2_init },
9165 { 6, alc861_threestack_ch6_init },
9167 /* Set mic1 as input and unmute the mixer */
9168 static struct hda_verb alc861_uniwill_m31_ch2_init[] = {
9169 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
9170 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
9173 /* Set mic1 as output and mute mixer */
9174 static struct hda_verb alc861_uniwill_m31_ch4_init[] = {
9175 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
9176 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
9180 static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
9181 { 2, alc861_uniwill_m31_ch2_init },
9182 { 4, alc861_uniwill_m31_ch4_init },
9185 /* Set mic1 and line-in as input and unmute the mixer */
9186 static struct hda_verb alc861_asus_ch2_init[] = {
9187 /* set pin widget 1Ah (line in) for input */
9188 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
9189 /* set pin widget 18h (mic1/2) for input, for mic also enable
9192 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
9194 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
9196 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
9197 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
9201 /* Set mic1 nad line-in as output and mute mixer */
9202 static struct hda_verb alc861_asus_ch6_init[] = {
9203 /* set pin widget 1Ah (line in) for output (Back Surround)*/
9204 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
9205 /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
9206 /* set pin widget 18h (mic1) for output (CLFE)*/
9207 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
9208 /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
9209 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
9210 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
9212 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
9214 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
9215 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
9220 static struct hda_channel_mode alc861_asus_modes[2] = {
9221 { 2, alc861_asus_ch2_init },
9222 { 6, alc861_asus_ch6_init },
9227 static struct snd_kcontrol_new alc861_base_mixer[] = {
9228 /* output mixer control */
9229 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
9230 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
9231 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
9232 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
9233 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
9235 /*Input mixer control */
9236 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
9237 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
9238 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
9239 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
9240 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
9241 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
9242 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
9243 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
9244 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
9245 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
9247 /* Capture mixer control */
9248 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
9249 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
9251 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9252 .name = "Capture Source",
9254 .info = alc_mux_enum_info,
9255 .get = alc_mux_enum_get,
9256 .put = alc_mux_enum_put,
9261 static struct snd_kcontrol_new alc861_3ST_mixer[] = {
9262 /* output mixer control */
9263 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
9264 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
9265 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
9266 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
9267 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
9269 /* Input mixer control */
9270 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
9271 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
9272 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
9273 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
9274 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
9275 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
9276 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
9277 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
9278 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
9279 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
9281 /* Capture mixer control */
9282 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
9283 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
9285 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9286 .name = "Capture Source",
9288 .info = alc_mux_enum_info,
9289 .get = alc_mux_enum_get,
9290 .put = alc_mux_enum_put,
9293 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9294 .name = "Channel Mode",
9295 .info = alc_ch_mode_info,
9296 .get = alc_ch_mode_get,
9297 .put = alc_ch_mode_put,
9298 .private_value = ARRAY_SIZE(alc861_threestack_modes),
9303 static struct snd_kcontrol_new alc861_toshiba_mixer[] = {
9304 /* output mixer control */
9305 HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT),
9306 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
9307 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
9309 /*Capture mixer control */
9310 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
9311 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
9313 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9314 .name = "Capture Source",
9316 .info = alc_mux_enum_info,
9317 .get = alc_mux_enum_get,
9318 .put = alc_mux_enum_put,
9324 static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
9325 /* output mixer control */
9326 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
9327 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
9328 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
9329 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
9330 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
9332 /* Input mixer control */
9333 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
9334 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
9335 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
9336 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
9337 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
9338 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
9339 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
9340 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
9341 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
9342 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
9344 /* Capture mixer control */
9345 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
9346 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
9348 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9349 .name = "Capture Source",
9351 .info = alc_mux_enum_info,
9352 .get = alc_mux_enum_get,
9353 .put = alc_mux_enum_put,
9356 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9357 .name = "Channel Mode",
9358 .info = alc_ch_mode_info,
9359 .get = alc_ch_mode_get,
9360 .put = alc_ch_mode_put,
9361 .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
9366 static struct snd_kcontrol_new alc861_asus_mixer[] = {
9367 /* output mixer control */
9368 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
9369 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
9370 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
9371 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
9372 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
9374 /* Input mixer control */
9375 HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
9376 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9377 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
9378 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
9379 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
9380 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
9381 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
9382 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
9383 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
9384 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT),
9386 /* Capture mixer control */
9387 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
9388 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
9390 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9391 .name = "Capture Source",
9393 .info = alc_mux_enum_info,
9394 .get = alc_mux_enum_get,
9395 .put = alc_mux_enum_put,
9398 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9399 .name = "Channel Mode",
9400 .info = alc_ch_mode_info,
9401 .get = alc_ch_mode_get,
9402 .put = alc_ch_mode_put,
9403 .private_value = ARRAY_SIZE(alc861_asus_modes),
9408 /* additional mixer */
9409 static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = {
9410 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
9411 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
9412 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x23, 0x0, HDA_OUTPUT),
9413 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x23, 0x0, HDA_OUTPUT),
9418 * generic initialization of ADC, input mixers and output mixers
9420 static struct hda_verb alc861_base_init_verbs[] = {
9422 * Unmute ADC0 and set the default input to mic-in
9424 /* port-A for surround (rear panel) */
9425 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
9426 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
9427 /* port-B for mic-in (rear panel) with vref */
9428 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
9429 /* port-C for line-in (rear panel) */
9430 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
9431 /* port-D for Front */
9432 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
9433 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
9434 /* port-E for HP out (front panel) */
9435 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
9436 /* route front PCM to HP */
9437 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
9438 /* port-F for mic-in (front panel) with vref */
9439 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
9440 /* port-G for CLFE (rear panel) */
9441 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
9442 { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
9443 /* port-H for side (rear panel) */
9444 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
9445 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
9447 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
9448 /* route front mic to ADC1*/
9449 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
9450 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9452 /* Unmute DAC0~3 & spdif out*/
9453 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9454 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9455 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9456 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9457 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9459 /* Unmute Mixer 14 (mic) 1c (Line in)*/
9460 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9461 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9462 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9463 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9465 /* Unmute Stereo Mixer 15 */
9466 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9467 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9468 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
9469 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
9471 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9472 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9473 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9474 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9475 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9476 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9477 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9478 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9479 /* hp used DAC 3 (Front) */
9480 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
9481 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
9486 static struct hda_verb alc861_threestack_init_verbs[] = {
9488 * Unmute ADC0 and set the default input to mic-in
9490 /* port-A for surround (rear panel) */
9491 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
9492 /* port-B for mic-in (rear panel) with vref */
9493 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
9494 /* port-C for line-in (rear panel) */
9495 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
9496 /* port-D for Front */
9497 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
9498 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
9499 /* port-E for HP out (front panel) */
9500 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
9501 /* route front PCM to HP */
9502 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
9503 /* port-F for mic-in (front panel) with vref */
9504 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
9505 /* port-G for CLFE (rear panel) */
9506 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
9507 /* port-H for side (rear panel) */
9508 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
9510 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
9511 /* route front mic to ADC1*/
9512 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
9513 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9514 /* Unmute DAC0~3 & spdif out*/
9515 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9516 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9517 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9518 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9519 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9521 /* Unmute Mixer 14 (mic) 1c (Line in)*/
9522 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9523 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9524 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9525 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9527 /* Unmute Stereo Mixer 15 */
9528 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9529 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9530 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
9531 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
9533 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9534 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9535 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9536 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9537 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9538 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9539 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9540 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9541 /* hp used DAC 3 (Front) */
9542 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
9543 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
9547 static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
9549 * Unmute ADC0 and set the default input to mic-in
9551 /* port-A for surround (rear panel) */
9552 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
9553 /* port-B for mic-in (rear panel) with vref */
9554 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
9555 /* port-C for line-in (rear panel) */
9556 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
9557 /* port-D for Front */
9558 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
9559 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
9560 /* port-E for HP out (front panel) */
9561 /* this has to be set to VREF80 */
9562 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
9563 /* route front PCM to HP */
9564 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
9565 /* port-F for mic-in (front panel) with vref */
9566 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
9567 /* port-G for CLFE (rear panel) */
9568 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
9569 /* port-H for side (rear panel) */
9570 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
9572 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
9573 /* route front mic to ADC1*/
9574 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
9575 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9576 /* Unmute DAC0~3 & spdif out*/
9577 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9578 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9579 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9580 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9581 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9583 /* Unmute Mixer 14 (mic) 1c (Line in)*/
9584 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9585 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9586 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9587 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9589 /* Unmute Stereo Mixer 15 */
9590 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9591 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9592 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
9593 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
9595 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9596 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9597 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9598 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9599 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9600 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9601 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9602 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9603 /* hp used DAC 3 (Front) */
9604 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
9605 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
9609 static struct hda_verb alc861_asus_init_verbs[] = {
9611 * Unmute ADC0 and set the default input to mic-in
9613 /* port-A for surround (rear panel)
9614 * according to codec#0 this is the HP jack
9616 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */
9617 /* route front PCM to HP */
9618 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 },
9619 /* port-B for mic-in (rear panel) with vref */
9620 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
9621 /* port-C for line-in (rear panel) */
9622 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
9623 /* port-D for Front */
9624 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
9625 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
9626 /* port-E for HP out (front panel) */
9627 /* this has to be set to VREF80 */
9628 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
9629 /* route front PCM to HP */
9630 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
9631 /* port-F for mic-in (front panel) with vref */
9632 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
9633 /* port-G for CLFE (rear panel) */
9634 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
9635 /* port-H for side (rear panel) */
9636 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
9638 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
9639 /* route front mic to ADC1*/
9640 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
9641 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9642 /* Unmute DAC0~3 & spdif out*/
9643 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9644 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9645 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9646 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9647 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9648 /* Unmute Mixer 14 (mic) 1c (Line in)*/
9649 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9650 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9651 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9652 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9654 /* Unmute Stereo Mixer 15 */
9655 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9656 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9657 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
9658 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
9660 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9661 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9662 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9663 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9664 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9665 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9666 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9667 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9668 /* hp used DAC 3 (Front) */
9669 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
9670 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
9674 /* additional init verbs for ASUS laptops */
9675 static struct hda_verb alc861_asus_laptop_init_verbs[] = {
9676 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */
9677 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */
9682 * generic initialization of ADC, input mixers and output mixers
9684 static struct hda_verb alc861_auto_init_verbs[] = {
9686 * Unmute ADC0 and set the default input to mic-in
9688 /* {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, */
9689 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9691 /* Unmute DAC0~3 & spdif out*/
9692 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9693 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9694 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9695 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9696 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9698 /* Unmute Mixer 14 (mic) 1c (Line in)*/
9699 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9700 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9701 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9702 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9704 /* Unmute Stereo Mixer 15 */
9705 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9706 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9707 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
9708 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
9710 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9711 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9712 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9713 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9714 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9715 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9716 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9717 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9719 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9720 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9721 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
9722 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
9723 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9724 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9725 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
9726 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
9728 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */
9733 static struct hda_verb alc861_toshiba_init_verbs[] = {
9734 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9739 /* toggle speaker-output according to the hp-jack state */
9740 static void alc861_toshiba_automute(struct hda_codec *codec)
9742 unsigned int present;
9744 present = snd_hda_codec_read(codec, 0x0f, 0,
9745 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
9746 snd_hda_codec_amp_stereo(codec, 0x16, HDA_INPUT, 0,
9747 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
9748 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_INPUT, 3,
9749 HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
9752 static void alc861_toshiba_unsol_event(struct hda_codec *codec,
9755 if ((res >> 26) == ALC880_HP_EVENT)
9756 alc861_toshiba_automute(codec);
9759 /* pcm configuration: identiacal with ALC880 */
9760 #define alc861_pcm_analog_playback alc880_pcm_analog_playback
9761 #define alc861_pcm_analog_capture alc880_pcm_analog_capture
9762 #define alc861_pcm_digital_playback alc880_pcm_digital_playback
9763 #define alc861_pcm_digital_capture alc880_pcm_digital_capture
9766 #define ALC861_DIGOUT_NID 0x07
9768 static struct hda_channel_mode alc861_8ch_modes[1] = {
9772 static hda_nid_t alc861_dac_nids[4] = {
9773 /* front, surround, clfe, side */
9774 0x03, 0x06, 0x05, 0x04
9777 static hda_nid_t alc660_dac_nids[3] = {
9778 /* front, clfe, surround */
9782 static hda_nid_t alc861_adc_nids[1] = {
9787 static struct hda_input_mux alc861_capture_source = {
9791 { "Front Mic", 0x3 },
9798 /* fill in the dac_nids table from the parsed pin configuration */
9799 static int alc861_auto_fill_dac_nids(struct alc_spec *spec,
9800 const struct auto_pin_cfg *cfg)
9805 spec->multiout.dac_nids = spec->private_dac_nids;
9806 for (i = 0; i < cfg->line_outs; i++) {
9807 nid = cfg->line_out_pins[i];
9809 if (i >= ARRAY_SIZE(alc861_dac_nids))
9811 spec->multiout.dac_nids[i] = alc861_dac_nids[i];
9814 spec->multiout.num_dacs = cfg->line_outs;
9818 /* add playback controls from the parsed DAC table */
9819 static int alc861_auto_create_multi_out_ctls(struct alc_spec *spec,
9820 const struct auto_pin_cfg *cfg)
9823 static const char *chname[4] = {
9824 "Front", "Surround", NULL /*CLFE*/, "Side"
9829 for (i = 0; i < cfg->line_outs; i++) {
9830 nid = spec->multiout.dac_nids[i];
9835 err = add_control(spec, ALC_CTL_BIND_MUTE,
9836 "Center Playback Switch",
9837 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
9841 err = add_control(spec, ALC_CTL_BIND_MUTE,
9842 "LFE Playback Switch",
9843 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
9848 for (idx = 0; idx < ARRAY_SIZE(alc861_dac_nids) - 1;
9850 if (nid == alc861_dac_nids[idx])
9852 sprintf(name, "%s Playback Switch", chname[idx]);
9853 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
9854 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
9863 static int alc861_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin)
9871 if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
9873 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
9874 "Headphone Playback Switch",
9875 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
9878 spec->multiout.hp_nid = nid;
9883 /* create playback/capture controls for input pins */
9884 static int alc861_auto_create_analog_input_ctls(struct alc_spec *spec,
9885 const struct auto_pin_cfg *cfg)
9887 struct hda_input_mux *imux = &spec->private_imux;
9888 int i, err, idx, idx1;
9890 for (i = 0; i < AUTO_PIN_LAST; i++) {
9891 switch (cfg->input_pins[i]) {
9894 idx = 2; /* Line In */
9898 idx = 2; /* Line In */
9902 idx = 1; /* Mic In */
9906 idx = 1; /* Mic In */
9916 err = new_analog_input(spec, cfg->input_pins[i],
9917 auto_pin_cfg_labels[i], idx, 0x15);
9921 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
9922 imux->items[imux->num_items].index = idx1;
9928 static struct snd_kcontrol_new alc861_capture_mixer[] = {
9929 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
9930 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
9933 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9934 /* The multiple "Capture Source" controls confuse alsamixer
9935 * So call somewhat different..
9936 *FIXME: the controls appear in the "playback" view!
9938 /* .name = "Capture Source", */
9939 .name = "Input Source",
9941 .info = alc_mux_enum_info,
9942 .get = alc_mux_enum_get,
9943 .put = alc_mux_enum_put,
9948 static void alc861_auto_set_output_and_unmute(struct hda_codec *codec,
9950 int pin_type, int dac_idx)
9954 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
9956 snd_hda_codec_write(codec, dac_idx, 0, AC_VERB_SET_AMP_GAIN_MUTE,
9961 static void alc861_auto_init_multi_out(struct hda_codec *codec)
9963 struct alc_spec *spec = codec->spec;
9966 alc_subsystem_id(codec, 0x0e, 0x0f, 0x0b);
9967 for (i = 0; i < spec->autocfg.line_outs; i++) {
9968 hda_nid_t nid = spec->autocfg.line_out_pins[i];
9969 int pin_type = get_pin_type(spec->autocfg.line_out_type);
9971 alc861_auto_set_output_and_unmute(codec, nid, pin_type,
9972 spec->multiout.dac_nids[i]);
9976 static void alc861_auto_init_hp_out(struct hda_codec *codec)
9978 struct alc_spec *spec = codec->spec;
9981 pin = spec->autocfg.hp_pins[0];
9982 if (pin) /* connect to front */
9983 alc861_auto_set_output_and_unmute(codec, pin, PIN_HP,
9984 spec->multiout.dac_nids[0]);
9987 static void alc861_auto_init_analog_input(struct hda_codec *codec)
9989 struct alc_spec *spec = codec->spec;
9992 for (i = 0; i < AUTO_PIN_LAST; i++) {
9993 hda_nid_t nid = spec->autocfg.input_pins[i];
9994 if (nid >= 0x0c && nid <= 0x11) {
9995 snd_hda_codec_write(codec, nid, 0,
9996 AC_VERB_SET_PIN_WIDGET_CONTROL,
9997 i <= AUTO_PIN_FRONT_MIC ?
9998 PIN_VREF80 : PIN_IN);
10003 /* parse the BIOS configuration and set up the alc_spec */
10004 /* return 1 if successful, 0 if the proper config is not found,
10005 * or a negative error code
10007 static int alc861_parse_auto_config(struct hda_codec *codec)
10009 struct alc_spec *spec = codec->spec;
10011 static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
10013 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
10017 if (!spec->autocfg.line_outs)
10018 return 0; /* can't find valid BIOS pin config */
10020 err = alc861_auto_fill_dac_nids(spec, &spec->autocfg);
10023 err = alc861_auto_create_multi_out_ctls(spec, &spec->autocfg);
10026 err = alc861_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0]);
10029 err = alc861_auto_create_analog_input_ctls(spec, &spec->autocfg);
10033 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
10035 if (spec->autocfg.dig_out_pin)
10036 spec->multiout.dig_out_nid = ALC861_DIGOUT_NID;
10038 if (spec->kctl_alloc)
10039 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
10041 spec->init_verbs[spec->num_init_verbs++] = alc861_auto_init_verbs;
10043 spec->num_mux_defs = 1;
10044 spec->input_mux = &spec->private_imux;
10046 spec->adc_nids = alc861_adc_nids;
10047 spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
10048 spec->mixers[spec->num_mixers] = alc861_capture_mixer;
10049 spec->num_mixers++;
10054 /* additional initialization for auto-configuration model */
10055 static void alc861_auto_init(struct hda_codec *codec)
10057 alc861_auto_init_multi_out(codec);
10058 alc861_auto_init_hp_out(codec);
10059 alc861_auto_init_analog_input(codec);
10062 #ifdef CONFIG_SND_HDA_POWER_SAVE
10063 static struct hda_amp_list alc861_loopbacks[] = {
10064 { 0x15, HDA_INPUT, 0 },
10065 { 0x15, HDA_INPUT, 1 },
10066 { 0x15, HDA_INPUT, 2 },
10067 { 0x15, HDA_INPUT, 3 },
10074 * configuration and preset
10076 static const char *alc861_models[ALC861_MODEL_LAST] = {
10077 [ALC861_3ST] = "3stack",
10078 [ALC660_3ST] = "3stack-660",
10079 [ALC861_3ST_DIG] = "3stack-dig",
10080 [ALC861_6ST_DIG] = "6stack-dig",
10081 [ALC861_UNIWILL_M31] = "uniwill-m31",
10082 [ALC861_TOSHIBA] = "toshiba",
10083 [ALC861_ASUS] = "asus",
10084 [ALC861_ASUS_LAPTOP] = "asus-laptop",
10085 [ALC861_AUTO] = "auto",
10088 static struct snd_pci_quirk alc861_cfg_tbl[] = {
10089 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST),
10090 SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP),
10091 SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP),
10092 SND_PCI_QUIRK(0x1043, 0x13d7, "ASUS A9rp", ALC861_ASUS_LAPTOP),
10093 SND_PCI_QUIRK(0x1584, 0x9075, "Airis Praxis N1212", ALC861_ASUS_LAPTOP),
10094 SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS),
10095 SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS P1-AH2", ALC861_3ST_DIG),
10096 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA),
10097 /* FIXME: the entry below breaks Toshiba A100 (model=auto works!)
10098 * Any other models that need this preset?
10100 /* SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA), */
10101 SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31),
10102 SND_PCI_QUIRK(0x1584, 0x9075, "Uniwill", ALC861_UNIWILL_M31),
10103 SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31),
10104 SND_PCI_QUIRK(0x1849, 0x0660, "Asrock 939SLI32", ALC660_3ST),
10105 SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST),
10106 SND_PCI_QUIRK(0x1462, 0x7254, "HP dx2200 (MSI MS-7254)", ALC861_3ST),
10107 SND_PCI_QUIRK(0x1462, 0x7297, "HP dx2250 (MSI MS-7297)", ALC861_3ST),
10111 static struct alc_config_preset alc861_presets[] = {
10113 .mixers = { alc861_3ST_mixer },
10114 .init_verbs = { alc861_threestack_init_verbs },
10115 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
10116 .dac_nids = alc861_dac_nids,
10117 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
10118 .channel_mode = alc861_threestack_modes,
10120 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
10121 .adc_nids = alc861_adc_nids,
10122 .input_mux = &alc861_capture_source,
10124 [ALC861_3ST_DIG] = {
10125 .mixers = { alc861_base_mixer },
10126 .init_verbs = { alc861_threestack_init_verbs },
10127 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
10128 .dac_nids = alc861_dac_nids,
10129 .dig_out_nid = ALC861_DIGOUT_NID,
10130 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
10131 .channel_mode = alc861_threestack_modes,
10133 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
10134 .adc_nids = alc861_adc_nids,
10135 .input_mux = &alc861_capture_source,
10137 [ALC861_6ST_DIG] = {
10138 .mixers = { alc861_base_mixer },
10139 .init_verbs = { alc861_base_init_verbs },
10140 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
10141 .dac_nids = alc861_dac_nids,
10142 .dig_out_nid = ALC861_DIGOUT_NID,
10143 .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
10144 .channel_mode = alc861_8ch_modes,
10145 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
10146 .adc_nids = alc861_adc_nids,
10147 .input_mux = &alc861_capture_source,
10150 .mixers = { alc861_3ST_mixer },
10151 .init_verbs = { alc861_threestack_init_verbs },
10152 .num_dacs = ARRAY_SIZE(alc660_dac_nids),
10153 .dac_nids = alc660_dac_nids,
10154 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
10155 .channel_mode = alc861_threestack_modes,
10157 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
10158 .adc_nids = alc861_adc_nids,
10159 .input_mux = &alc861_capture_source,
10161 [ALC861_UNIWILL_M31] = {
10162 .mixers = { alc861_uniwill_m31_mixer },
10163 .init_verbs = { alc861_uniwill_m31_init_verbs },
10164 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
10165 .dac_nids = alc861_dac_nids,
10166 .dig_out_nid = ALC861_DIGOUT_NID,
10167 .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes),
10168 .channel_mode = alc861_uniwill_m31_modes,
10170 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
10171 .adc_nids = alc861_adc_nids,
10172 .input_mux = &alc861_capture_source,
10174 [ALC861_TOSHIBA] = {
10175 .mixers = { alc861_toshiba_mixer },
10176 .init_verbs = { alc861_base_init_verbs,
10177 alc861_toshiba_init_verbs },
10178 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
10179 .dac_nids = alc861_dac_nids,
10180 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10181 .channel_mode = alc883_3ST_2ch_modes,
10182 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
10183 .adc_nids = alc861_adc_nids,
10184 .input_mux = &alc861_capture_source,
10185 .unsol_event = alc861_toshiba_unsol_event,
10186 .init_hook = alc861_toshiba_automute,
10189 .mixers = { alc861_asus_mixer },
10190 .init_verbs = { alc861_asus_init_verbs },
10191 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
10192 .dac_nids = alc861_dac_nids,
10193 .dig_out_nid = ALC861_DIGOUT_NID,
10194 .num_channel_mode = ARRAY_SIZE(alc861_asus_modes),
10195 .channel_mode = alc861_asus_modes,
10198 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
10199 .adc_nids = alc861_adc_nids,
10200 .input_mux = &alc861_capture_source,
10202 [ALC861_ASUS_LAPTOP] = {
10203 .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer },
10204 .init_verbs = { alc861_asus_init_verbs,
10205 alc861_asus_laptop_init_verbs },
10206 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
10207 .dac_nids = alc861_dac_nids,
10208 .dig_out_nid = ALC861_DIGOUT_NID,
10209 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10210 .channel_mode = alc883_3ST_2ch_modes,
10212 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
10213 .adc_nids = alc861_adc_nids,
10214 .input_mux = &alc861_capture_source,
10219 static int patch_alc861(struct hda_codec *codec)
10221 struct alc_spec *spec;
10225 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
10229 codec->spec = spec;
10231 board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST,
10235 if (board_config < 0) {
10236 printk(KERN_INFO "hda_codec: Unknown model for ALC861, "
10237 "trying auto-probe from BIOS...\n");
10238 board_config = ALC861_AUTO;
10241 if (board_config == ALC861_AUTO) {
10242 /* automatic parse from the BIOS config */
10243 err = alc861_parse_auto_config(codec);
10249 "hda_codec: Cannot set up configuration "
10250 "from BIOS. Using base mode...\n");
10251 board_config = ALC861_3ST_DIG;
10255 if (board_config != ALC861_AUTO)
10256 setup_preset(spec, &alc861_presets[board_config]);
10258 spec->stream_name_analog = "ALC861 Analog";
10259 spec->stream_analog_playback = &alc861_pcm_analog_playback;
10260 spec->stream_analog_capture = &alc861_pcm_analog_capture;
10262 spec->stream_name_digital = "ALC861 Digital";
10263 spec->stream_digital_playback = &alc861_pcm_digital_playback;
10264 spec->stream_digital_capture = &alc861_pcm_digital_capture;
10266 codec->patch_ops = alc_patch_ops;
10267 if (board_config == ALC861_AUTO)
10268 spec->init_hook = alc861_auto_init;
10269 #ifdef CONFIG_SND_HDA_POWER_SAVE
10270 if (!spec->loopback.amplist)
10271 spec->loopback.amplist = alc861_loopbacks;
10278 * ALC861-VD support
10282 * In addition, an independent DAC
10284 #define ALC861VD_DIGOUT_NID 0x06
10286 static hda_nid_t alc861vd_dac_nids[4] = {
10287 /* front, surr, clfe, side surr */
10288 0x02, 0x03, 0x04, 0x05
10291 /* dac_nids for ALC660vd are in a different order - according to
10292 * Realtek's driver.
10293 * This should probably tesult in a different mixer for 6stack models
10294 * of ALC660vd codecs, but for now there is only 3stack mixer
10295 * - and it is the same as in 861vd.
10296 * adc_nids in ALC660vd are (is) the same as in 861vd
10298 static hda_nid_t alc660vd_dac_nids[3] = {
10299 /* front, rear, clfe, rear_surr */
10303 static hda_nid_t alc861vd_adc_nids[1] = {
10309 /* FIXME: should be a matrix-type input source selection */
10310 static struct hda_input_mux alc861vd_capture_source = {
10314 { "Front Mic", 0x1 },
10320 static struct hda_input_mux alc861vd_dallas_capture_source = {
10323 { "Front Mic", 0x0 },
10324 { "ATAPI Mic", 0x1 },
10325 { "Line In", 0x5 },
10329 static struct hda_input_mux alc861vd_hp_capture_source = {
10332 { "Front Mic", 0x0 },
10333 { "ATAPI Mic", 0x1 },
10337 #define alc861vd_mux_enum_info alc_mux_enum_info
10338 #define alc861vd_mux_enum_get alc_mux_enum_get
10340 static int alc861vd_mux_enum_put(struct snd_kcontrol *kcontrol,
10341 struct snd_ctl_elem_value *ucontrol)
10343 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10344 struct alc_spec *spec = codec->spec;
10345 const struct hda_input_mux *imux = spec->input_mux;
10346 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
10347 static hda_nid_t capture_mixers[1] = { 0x22 };
10348 hda_nid_t nid = capture_mixers[adc_idx];
10349 unsigned int *cur_val = &spec->cur_mux[adc_idx];
10350 unsigned int i, idx;
10352 idx = ucontrol->value.enumerated.item[0];
10353 if (idx >= imux->num_items)
10354 idx = imux->num_items - 1;
10355 if (*cur_val == idx)
10357 for (i = 0; i < imux->num_items; i++) {
10358 unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
10359 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
10360 imux->items[i].index,
10370 static struct hda_channel_mode alc861vd_3stack_2ch_modes[1] = {
10377 static struct hda_verb alc861vd_6stack_ch6_init[] = {
10378 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
10379 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10380 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10381 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10388 static struct hda_verb alc861vd_6stack_ch8_init[] = {
10389 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10390 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10391 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10392 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10396 static struct hda_channel_mode alc861vd_6stack_modes[2] = {
10397 { 6, alc861vd_6stack_ch6_init },
10398 { 8, alc861vd_6stack_ch8_init },
10401 static struct snd_kcontrol_new alc861vd_chmode_mixer[] = {
10403 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10404 .name = "Channel Mode",
10405 .info = alc_ch_mode_info,
10406 .get = alc_ch_mode_get,
10407 .put = alc_ch_mode_put,
10412 static struct snd_kcontrol_new alc861vd_capture_mixer[] = {
10413 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
10414 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
10417 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10418 /* The multiple "Capture Source" controls confuse alsamixer
10419 * So call somewhat different..
10420 *FIXME: the controls appear in the "playback" view!
10422 /* .name = "Capture Source", */
10423 .name = "Input Source",
10425 .info = alc861vd_mux_enum_info,
10426 .get = alc861vd_mux_enum_get,
10427 .put = alc861vd_mux_enum_put,
10432 /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
10433 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
10435 static struct snd_kcontrol_new alc861vd_6st_mixer[] = {
10436 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
10437 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
10439 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
10440 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
10442 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0,
10444 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0,
10446 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
10447 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
10449 HDA_CODEC_VOLUME("Side Playback Volume", 0x05, 0x0, HDA_OUTPUT),
10450 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
10452 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
10454 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10455 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10456 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10458 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10459 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
10460 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
10462 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10463 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10465 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10466 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10468 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
10469 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
10474 static struct snd_kcontrol_new alc861vd_3st_mixer[] = {
10475 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
10476 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
10478 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
10480 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10481 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10482 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10484 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10485 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
10486 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
10488 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10489 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10491 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10492 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10494 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
10495 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
10500 static struct snd_kcontrol_new alc861vd_lenovo_mixer[] = {
10501 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
10502 /*HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),*/
10503 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
10505 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
10507 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10508 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10509 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10511 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10512 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
10513 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
10515 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10516 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10521 /* Pin assignment: Front=0x14, HP = 0x15,
10522 * Front Mic=0x18, ATAPI Mic = 0x19, Line In = 0x1d
10524 static struct snd_kcontrol_new alc861vd_dallas_mixer[] = {
10525 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
10526 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
10527 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
10528 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
10529 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10530 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10531 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
10532 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
10533 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x05, HDA_INPUT),
10534 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x05, HDA_INPUT),
10538 /* Pin assignment: Speaker=0x14, Line-out = 0x15,
10539 * Front Mic=0x18, ATAPI Mic = 0x19,
10541 static struct snd_kcontrol_new alc861vd_hp_mixer[] = {
10542 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
10543 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
10544 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
10545 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
10546 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10547 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10548 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
10549 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
10555 * generic initialization of ADC, input mixers and output mixers
10557 static struct hda_verb alc861vd_volume_init_verbs[] = {
10559 * Unmute ADC0 and set the default input to mic-in
10561 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
10562 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10564 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of
10565 * the analog-loopback mixer widget
10567 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
10568 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10569 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10570 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10571 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10572 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
10574 /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */
10575 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10576 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10577 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
10578 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
10581 * Set up output mixers (0x02 - 0x05)
10583 /* set vol=0 to output mixers */
10584 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10585 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10586 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10587 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10589 /* set up input amps for analog loopback */
10590 /* Amp Indices: DAC = 0, mixer = 1 */
10591 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10592 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10593 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10594 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10595 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10596 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10597 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10598 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10604 * 3-stack pin configuration:
10605 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
10607 static struct hda_verb alc861vd_3stack_init_verbs[] = {
10609 * Set pin mode and muting
10611 /* set front pin widgets 0x14 for output */
10612 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10613 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10614 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
10616 /* Mic (rear) pin: input vref at 80% */
10617 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
10618 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10619 /* Front Mic pin: input vref at 80% */
10620 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
10621 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10622 /* Line In pin: input */
10623 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10624 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10625 /* Line-2 In: Headphone output (output 0 - 0x0c) */
10626 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10627 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10628 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
10629 /* CD pin widget for input */
10630 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10636 * 6-stack pin configuration:
10638 static struct hda_verb alc861vd_6stack_init_verbs[] = {
10640 * Set pin mode and muting
10642 /* set front pin widgets 0x14 for output */
10643 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10644 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10645 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
10647 /* Rear Pin: output 1 (0x0d) */
10648 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10649 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10650 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
10651 /* CLFE Pin: output 2 (0x0e) */
10652 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10653 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10654 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
10655 /* Side Pin: output 3 (0x0f) */
10656 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10657 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10658 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
10660 /* Mic (rear) pin: input vref at 80% */
10661 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
10662 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10663 /* Front Mic pin: input vref at 80% */
10664 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
10665 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10666 /* Line In pin: input */
10667 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10668 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10669 /* Line-2 In: Headphone output (output 0 - 0x0c) */
10670 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10671 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10672 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
10673 /* CD pin widget for input */
10674 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10679 static struct hda_verb alc861vd_eapd_verbs[] = {
10680 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
10684 static struct hda_verb alc861vd_lenovo_unsol_verbs[] = {
10685 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10686 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10687 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
10688 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10689 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
10693 /* toggle speaker-output according to the hp-jack state */
10694 static void alc861vd_lenovo_hp_automute(struct hda_codec *codec)
10696 unsigned int present;
10697 unsigned char bits;
10699 present = snd_hda_codec_read(codec, 0x1b, 0,
10700 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
10701 bits = present ? HDA_AMP_MUTE : 0;
10702 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10703 HDA_AMP_MUTE, bits);
10706 static void alc861vd_lenovo_mic_automute(struct hda_codec *codec)
10708 unsigned int present;
10709 unsigned char bits;
10711 present = snd_hda_codec_read(codec, 0x18, 0,
10712 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
10713 bits = present ? HDA_AMP_MUTE : 0;
10714 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
10715 HDA_AMP_MUTE, bits);
10718 static void alc861vd_lenovo_automute(struct hda_codec *codec)
10720 alc861vd_lenovo_hp_automute(codec);
10721 alc861vd_lenovo_mic_automute(codec);
10724 static void alc861vd_lenovo_unsol_event(struct hda_codec *codec,
10727 switch (res >> 26) {
10728 case ALC880_HP_EVENT:
10729 alc861vd_lenovo_hp_automute(codec);
10731 case ALC880_MIC_EVENT:
10732 alc861vd_lenovo_mic_automute(codec);
10737 static struct hda_verb alc861vd_dallas_verbs[] = {
10738 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10739 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10740 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10741 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10743 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10744 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10745 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10746 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10747 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10748 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10749 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10750 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10752 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10753 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10754 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10755 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10756 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10757 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10758 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10759 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10761 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
10762 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10763 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
10764 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10765 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10766 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10767 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10768 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10770 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10771 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10772 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10773 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
10775 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10776 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
10777 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10782 /* toggle speaker-output according to the hp-jack state */
10783 static void alc861vd_dallas_automute(struct hda_codec *codec)
10785 unsigned int present;
10787 present = snd_hda_codec_read(codec, 0x15, 0,
10788 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
10789 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10790 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
10793 static void alc861vd_dallas_unsol_event(struct hda_codec *codec, unsigned int res)
10795 if ((res >> 26) == ALC880_HP_EVENT)
10796 alc861vd_dallas_automute(codec);
10799 #ifdef CONFIG_SND_HDA_POWER_SAVE
10800 #define alc861vd_loopbacks alc880_loopbacks
10803 /* pcm configuration: identiacal with ALC880 */
10804 #define alc861vd_pcm_analog_playback alc880_pcm_analog_playback
10805 #define alc861vd_pcm_analog_capture alc880_pcm_analog_capture
10806 #define alc861vd_pcm_digital_playback alc880_pcm_digital_playback
10807 #define alc861vd_pcm_digital_capture alc880_pcm_digital_capture
10810 * configuration and preset
10812 static const char *alc861vd_models[ALC861VD_MODEL_LAST] = {
10813 [ALC660VD_3ST] = "3stack-660",
10814 [ALC660VD_3ST_DIG] = "3stack-660-digout",
10815 [ALC861VD_3ST] = "3stack",
10816 [ALC861VD_3ST_DIG] = "3stack-digout",
10817 [ALC861VD_6ST_DIG] = "6stack-digout",
10818 [ALC861VD_LENOVO] = "lenovo",
10819 [ALC861VD_DALLAS] = "dallas",
10820 [ALC861VD_HP] = "hp",
10821 [ALC861VD_AUTO] = "auto",
10824 static struct snd_pci_quirk alc861vd_cfg_tbl[] = {
10825 SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST),
10826 SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST),
10827 SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660VD_3ST_DIG),
10828 SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST),
10829 SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST),
10831 /*SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),*/ /*lenovo*/
10832 SND_PCI_QUIRK(0x1179, 0xff01, "DALLAS", ALC861VD_DALLAS),
10833 SND_PCI_QUIRK(0x17aa, 0x3802, "Lenovo 3000 C200", ALC861VD_LENOVO),
10834 SND_PCI_QUIRK(0x17aa, 0x2066, "Lenovo", ALC861VD_LENOVO),
10835 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba A135", ALC861VD_LENOVO),
10836 SND_PCI_QUIRK(0x1179, 0xff03, "Toshiba P205", ALC861VD_LENOVO),
10837 SND_PCI_QUIRK(0x1565, 0x820d, "Biostar NF61S SE", ALC861VD_6ST_DIG),
10838 SND_PCI_QUIRK(0x1849, 0x0862, "ASRock K8NF6G-VSTA", ALC861VD_6ST_DIG),
10839 SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_HP),
10843 static struct alc_config_preset alc861vd_presets[] = {
10845 .mixers = { alc861vd_3st_mixer },
10846 .init_verbs = { alc861vd_volume_init_verbs,
10847 alc861vd_3stack_init_verbs },
10848 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
10849 .dac_nids = alc660vd_dac_nids,
10850 .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
10851 .adc_nids = alc861vd_adc_nids,
10852 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
10853 .channel_mode = alc861vd_3stack_2ch_modes,
10854 .input_mux = &alc861vd_capture_source,
10856 [ALC660VD_3ST_DIG] = {
10857 .mixers = { alc861vd_3st_mixer },
10858 .init_verbs = { alc861vd_volume_init_verbs,
10859 alc861vd_3stack_init_verbs },
10860 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
10861 .dac_nids = alc660vd_dac_nids,
10862 .dig_out_nid = ALC861VD_DIGOUT_NID,
10863 .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
10864 .adc_nids = alc861vd_adc_nids,
10865 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
10866 .channel_mode = alc861vd_3stack_2ch_modes,
10867 .input_mux = &alc861vd_capture_source,
10870 .mixers = { alc861vd_3st_mixer },
10871 .init_verbs = { alc861vd_volume_init_verbs,
10872 alc861vd_3stack_init_verbs },
10873 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
10874 .dac_nids = alc861vd_dac_nids,
10875 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
10876 .channel_mode = alc861vd_3stack_2ch_modes,
10877 .input_mux = &alc861vd_capture_source,
10879 [ALC861VD_3ST_DIG] = {
10880 .mixers = { alc861vd_3st_mixer },
10881 .init_verbs = { alc861vd_volume_init_verbs,
10882 alc861vd_3stack_init_verbs },
10883 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
10884 .dac_nids = alc861vd_dac_nids,
10885 .dig_out_nid = ALC861VD_DIGOUT_NID,
10886 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
10887 .channel_mode = alc861vd_3stack_2ch_modes,
10888 .input_mux = &alc861vd_capture_source,
10890 [ALC861VD_6ST_DIG] = {
10891 .mixers = { alc861vd_6st_mixer, alc861vd_chmode_mixer },
10892 .init_verbs = { alc861vd_volume_init_verbs,
10893 alc861vd_6stack_init_verbs },
10894 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
10895 .dac_nids = alc861vd_dac_nids,
10896 .dig_out_nid = ALC861VD_DIGOUT_NID,
10897 .num_channel_mode = ARRAY_SIZE(alc861vd_6stack_modes),
10898 .channel_mode = alc861vd_6stack_modes,
10899 .input_mux = &alc861vd_capture_source,
10901 [ALC861VD_LENOVO] = {
10902 .mixers = { alc861vd_lenovo_mixer },
10903 .init_verbs = { alc861vd_volume_init_verbs,
10904 alc861vd_3stack_init_verbs,
10905 alc861vd_eapd_verbs,
10906 alc861vd_lenovo_unsol_verbs },
10907 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
10908 .dac_nids = alc660vd_dac_nids,
10909 .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
10910 .adc_nids = alc861vd_adc_nids,
10911 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
10912 .channel_mode = alc861vd_3stack_2ch_modes,
10913 .input_mux = &alc861vd_capture_source,
10914 .unsol_event = alc861vd_lenovo_unsol_event,
10915 .init_hook = alc861vd_lenovo_automute,
10917 [ALC861VD_DALLAS] = {
10918 .mixers = { alc861vd_dallas_mixer },
10919 .init_verbs = { alc861vd_dallas_verbs },
10920 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
10921 .dac_nids = alc861vd_dac_nids,
10922 .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
10923 .adc_nids = alc861vd_adc_nids,
10924 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
10925 .channel_mode = alc861vd_3stack_2ch_modes,
10926 .input_mux = &alc861vd_dallas_capture_source,
10927 .unsol_event = alc861vd_dallas_unsol_event,
10928 .init_hook = alc861vd_dallas_automute,
10931 .mixers = { alc861vd_hp_mixer },
10932 .init_verbs = { alc861vd_dallas_verbs, alc861vd_eapd_verbs },
10933 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
10934 .dac_nids = alc861vd_dac_nids,
10935 .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
10936 .dig_out_nid = ALC861VD_DIGOUT_NID,
10937 .adc_nids = alc861vd_adc_nids,
10938 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
10939 .channel_mode = alc861vd_3stack_2ch_modes,
10940 .input_mux = &alc861vd_hp_capture_source,
10941 .unsol_event = alc861vd_dallas_unsol_event,
10942 .init_hook = alc861vd_dallas_automute,
10947 * BIOS auto configuration
10949 static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec,
10950 hda_nid_t nid, int pin_type, int dac_idx)
10952 /* set as output */
10953 snd_hda_codec_write(codec, nid, 0,
10954 AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
10955 snd_hda_codec_write(codec, nid, 0,
10956 AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
10959 static void alc861vd_auto_init_multi_out(struct hda_codec *codec)
10961 struct alc_spec *spec = codec->spec;
10964 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
10965 for (i = 0; i <= HDA_SIDE; i++) {
10966 hda_nid_t nid = spec->autocfg.line_out_pins[i];
10967 int pin_type = get_pin_type(spec->autocfg.line_out_type);
10969 alc861vd_auto_set_output_and_unmute(codec, nid,
10975 static void alc861vd_auto_init_hp_out(struct hda_codec *codec)
10977 struct alc_spec *spec = codec->spec;
10980 pin = spec->autocfg.hp_pins[0];
10981 if (pin) /* connect to front and use dac 0 */
10982 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
10985 #define alc861vd_is_input_pin(nid) alc880_is_input_pin(nid)
10986 #define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID
10988 static void alc861vd_auto_init_analog_input(struct hda_codec *codec)
10990 struct alc_spec *spec = codec->spec;
10993 for (i = 0; i < AUTO_PIN_LAST; i++) {
10994 hda_nid_t nid = spec->autocfg.input_pins[i];
10995 if (alc861vd_is_input_pin(nid)) {
10996 snd_hda_codec_write(codec, nid, 0,
10997 AC_VERB_SET_PIN_WIDGET_CONTROL,
10998 i <= AUTO_PIN_FRONT_MIC ?
10999 PIN_VREF80 : PIN_IN);
11000 if (nid != ALC861VD_PIN_CD_NID)
11001 snd_hda_codec_write(codec, nid, 0,
11002 AC_VERB_SET_AMP_GAIN_MUTE,
11008 #define alc861vd_idx_to_mixer_vol(nid) ((nid) + 0x02)
11009 #define alc861vd_idx_to_mixer_switch(nid) ((nid) + 0x0c)
11011 /* add playback controls from the parsed DAC table */
11012 /* Based on ALC880 version. But ALC861VD has separate,
11013 * different NIDs for mute/unmute switch and volume control */
11014 static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
11015 const struct auto_pin_cfg *cfg)
11018 static const char *chname[4] = {"Front", "Surround", "CLFE", "Side"};
11019 hda_nid_t nid_v, nid_s;
11022 for (i = 0; i < cfg->line_outs; i++) {
11023 if (!spec->multiout.dac_nids[i])
11025 nid_v = alc861vd_idx_to_mixer_vol(
11027 spec->multiout.dac_nids[i]));
11028 nid_s = alc861vd_idx_to_mixer_switch(
11030 spec->multiout.dac_nids[i]));
11034 err = add_control(spec, ALC_CTL_WIDGET_VOL,
11035 "Center Playback Volume",
11036 HDA_COMPOSE_AMP_VAL(nid_v, 1, 0,
11040 err = add_control(spec, ALC_CTL_WIDGET_VOL,
11041 "LFE Playback Volume",
11042 HDA_COMPOSE_AMP_VAL(nid_v, 2, 0,
11046 err = add_control(spec, ALC_CTL_BIND_MUTE,
11047 "Center Playback Switch",
11048 HDA_COMPOSE_AMP_VAL(nid_s, 1, 2,
11052 err = add_control(spec, ALC_CTL_BIND_MUTE,
11053 "LFE Playback Switch",
11054 HDA_COMPOSE_AMP_VAL(nid_s, 2, 2,
11059 sprintf(name, "%s Playback Volume", chname[i]);
11060 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
11061 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0,
11065 sprintf(name, "%s Playback Switch", chname[i]);
11066 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
11067 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2,
11076 /* add playback controls for speaker and HP outputs */
11077 /* Based on ALC880 version. But ALC861VD has separate,
11078 * different NIDs for mute/unmute switch and volume control */
11079 static int alc861vd_auto_create_extra_out(struct alc_spec *spec,
11080 hda_nid_t pin, const char *pfx)
11082 hda_nid_t nid_v, nid_s;
11089 if (alc880_is_fixed_pin(pin)) {
11090 nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
11091 /* specify the DAC as the extra output */
11092 if (!spec->multiout.hp_nid)
11093 spec->multiout.hp_nid = nid_v;
11095 spec->multiout.extra_out_nid[0] = nid_v;
11096 /* control HP volume/switch on the output mixer amp */
11097 nid_v = alc861vd_idx_to_mixer_vol(
11098 alc880_fixed_pin_idx(pin));
11099 nid_s = alc861vd_idx_to_mixer_switch(
11100 alc880_fixed_pin_idx(pin));
11102 sprintf(name, "%s Playback Volume", pfx);
11103 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
11104 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT));
11107 sprintf(name, "%s Playback Switch", pfx);
11108 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
11109 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT));
11112 } else if (alc880_is_multi_pin(pin)) {
11113 /* set manual connection */
11114 /* we have only a switch on HP-out PIN */
11115 sprintf(name, "%s Playback Switch", pfx);
11116 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
11117 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
11124 /* parse the BIOS configuration and set up the alc_spec
11125 * return 1 if successful, 0 if the proper config is not found,
11126 * or a negative error code
11127 * Based on ALC880 version - had to change it to override
11128 * alc880_auto_create_extra_out and alc880_auto_create_multi_out_ctls */
11129 static int alc861vd_parse_auto_config(struct hda_codec *codec)
11131 struct alc_spec *spec = codec->spec;
11133 static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
11135 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
11139 if (!spec->autocfg.line_outs)
11140 return 0; /* can't find valid BIOS pin config */
11142 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
11145 err = alc861vd_auto_create_multi_out_ctls(spec, &spec->autocfg);
11148 err = alc861vd_auto_create_extra_out(spec,
11149 spec->autocfg.speaker_pins[0],
11153 err = alc861vd_auto_create_extra_out(spec,
11154 spec->autocfg.hp_pins[0],
11158 err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
11162 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
11164 if (spec->autocfg.dig_out_pin)
11165 spec->multiout.dig_out_nid = ALC861VD_DIGOUT_NID;
11167 if (spec->kctl_alloc)
11168 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
11170 spec->init_verbs[spec->num_init_verbs++]
11171 = alc861vd_volume_init_verbs;
11173 spec->num_mux_defs = 1;
11174 spec->input_mux = &spec->private_imux;
11179 /* additional initialization for auto-configuration model */
11180 static void alc861vd_auto_init(struct hda_codec *codec)
11182 alc861vd_auto_init_multi_out(codec);
11183 alc861vd_auto_init_hp_out(codec);
11184 alc861vd_auto_init_analog_input(codec);
11187 static int patch_alc861vd(struct hda_codec *codec)
11189 struct alc_spec *spec;
11190 int err, board_config;
11192 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
11196 codec->spec = spec;
11198 board_config = snd_hda_check_board_config(codec, ALC861VD_MODEL_LAST,
11202 if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) {
11203 printk(KERN_INFO "hda_codec: Unknown model for ALC660VD/"
11204 "ALC861VD, trying auto-probe from BIOS...\n");
11205 board_config = ALC861VD_AUTO;
11208 if (board_config == ALC861VD_AUTO) {
11209 /* automatic parse from the BIOS config */
11210 err = alc861vd_parse_auto_config(codec);
11216 "hda_codec: Cannot set up configuration "
11217 "from BIOS. Using base mode...\n");
11218 board_config = ALC861VD_3ST;
11222 if (board_config != ALC861VD_AUTO)
11223 setup_preset(spec, &alc861vd_presets[board_config]);
11225 spec->stream_name_analog = "ALC861VD Analog";
11226 spec->stream_analog_playback = &alc861vd_pcm_analog_playback;
11227 spec->stream_analog_capture = &alc861vd_pcm_analog_capture;
11229 spec->stream_name_digital = "ALC861VD Digital";
11230 spec->stream_digital_playback = &alc861vd_pcm_digital_playback;
11231 spec->stream_digital_capture = &alc861vd_pcm_digital_capture;
11233 spec->adc_nids = alc861vd_adc_nids;
11234 spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids);
11236 spec->mixers[spec->num_mixers] = alc861vd_capture_mixer;
11237 spec->num_mixers++;
11239 codec->patch_ops = alc_patch_ops;
11241 if (board_config == ALC861VD_AUTO)
11242 spec->init_hook = alc861vd_auto_init;
11243 #ifdef CONFIG_SND_HDA_POWER_SAVE
11244 if (!spec->loopback.amplist)
11245 spec->loopback.amplist = alc861vd_loopbacks;
11254 * ALC662 is almost identical with ALC880 but has cleaner and more flexible
11255 * configuration. Each pin widget can choose any input DACs and a mixer.
11256 * Each ADC is connected from a mixer of all inputs. This makes possible
11257 * 6-channel independent captures.
11259 * In addition, an independent DAC for the multi-playback (not used in this
11262 #define ALC662_DIGOUT_NID 0x06
11263 #define ALC662_DIGIN_NID 0x0a
11265 static hda_nid_t alc662_dac_nids[4] = {
11266 /* front, rear, clfe, rear_surr */
11270 static hda_nid_t alc662_adc_nids[1] = {
11275 /* FIXME: should be a matrix-type input source selection */
11277 static struct hda_input_mux alc662_capture_source = {
11281 { "Front Mic", 0x1 },
11287 static struct hda_input_mux alc662_lenovo_101e_capture_source = {
11294 #define alc662_mux_enum_info alc_mux_enum_info
11295 #define alc662_mux_enum_get alc_mux_enum_get
11297 static int alc662_mux_enum_put(struct snd_kcontrol *kcontrol,
11298 struct snd_ctl_elem_value *ucontrol)
11300 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
11301 struct alc_spec *spec = codec->spec;
11302 const struct hda_input_mux *imux = spec->input_mux;
11303 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
11304 static hda_nid_t capture_mixers[2] = { 0x23, 0x22 };
11305 hda_nid_t nid = capture_mixers[adc_idx];
11306 unsigned int *cur_val = &spec->cur_mux[adc_idx];
11307 unsigned int i, idx;
11309 idx = ucontrol->value.enumerated.item[0];
11310 if (idx >= imux->num_items)
11311 idx = imux->num_items - 1;
11312 if (*cur_val == idx)
11314 for (i = 0; i < imux->num_items; i++) {
11315 unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
11316 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
11317 imux->items[i].index,
11326 static struct hda_channel_mode alc662_3ST_2ch_modes[1] = {
11333 static struct hda_verb alc662_3ST_ch2_init[] = {
11334 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
11335 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
11336 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
11337 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
11344 static struct hda_verb alc662_3ST_ch6_init[] = {
11345 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11346 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
11347 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
11348 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11349 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
11350 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
11354 static struct hda_channel_mode alc662_3ST_6ch_modes[2] = {
11355 { 2, alc662_3ST_ch2_init },
11356 { 6, alc662_3ST_ch6_init },
11362 static struct hda_verb alc662_sixstack_ch6_init[] = {
11363 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
11364 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
11365 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11372 static struct hda_verb alc662_sixstack_ch8_init[] = {
11373 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11374 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11375 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11379 static struct hda_channel_mode alc662_5stack_modes[2] = {
11380 { 2, alc662_sixstack_ch6_init },
11381 { 6, alc662_sixstack_ch8_init },
11384 /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
11385 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
11388 static struct snd_kcontrol_new alc662_base_mixer[] = {
11389 /* output mixer control */
11390 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
11391 HDA_CODEC_MUTE("Front Playback Switch", 0x02, 0x0, HDA_OUTPUT),
11392 HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT),
11393 HDA_CODEC_MUTE("Surround Playback Switch", 0x03, 0x0, HDA_OUTPUT),
11394 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
11395 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
11396 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT),
11397 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT),
11398 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
11400 /*Input mixer control */
11401 HDA_CODEC_VOLUME("CD Playback Volume", 0xb, 0x4, HDA_INPUT),
11402 HDA_CODEC_MUTE("CD Playback Switch", 0xb, 0x4, HDA_INPUT),
11403 HDA_CODEC_VOLUME("Line Playback Volume", 0xb, 0x02, HDA_INPUT),
11404 HDA_CODEC_MUTE("Line Playback Switch", 0xb, 0x02, HDA_INPUT),
11405 HDA_CODEC_VOLUME("Mic Playback Volume", 0xb, 0x0, HDA_INPUT),
11406 HDA_CODEC_MUTE("Mic Playback Switch", 0xb, 0x0, HDA_INPUT),
11407 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0xb, 0x01, HDA_INPUT),
11408 HDA_CODEC_MUTE("Front Mic Playback Switch", 0xb, 0x01, HDA_INPUT),
11410 /* Capture mixer control */
11411 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
11412 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
11414 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11415 .name = "Capture Source",
11417 .info = alc_mux_enum_info,
11418 .get = alc_mux_enum_get,
11419 .put = alc_mux_enum_put,
11424 static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = {
11425 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
11426 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
11427 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
11428 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11429 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
11430 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
11431 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
11432 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11433 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11434 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
11435 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
11436 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
11437 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
11438 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
11439 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
11441 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11442 /* .name = "Capture Source", */
11443 .name = "Input Source",
11445 .info = alc662_mux_enum_info,
11446 .get = alc662_mux_enum_get,
11447 .put = alc662_mux_enum_put,
11452 static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = {
11453 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
11454 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
11455 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
11456 HDA_BIND_MUTE("Surround Playback Switch", 0x03, 2, HDA_INPUT),
11457 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
11458 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
11459 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT),
11460 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT),
11461 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
11462 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11463 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
11464 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
11465 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
11466 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11467 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11468 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
11469 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
11470 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
11471 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
11472 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
11473 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
11475 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11476 /* .name = "Capture Source", */
11477 .name = "Input Source",
11479 .info = alc662_mux_enum_info,
11480 .get = alc662_mux_enum_get,
11481 .put = alc662_mux_enum_put,
11486 static struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = {
11487 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
11488 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
11489 HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x03, 0x0, HDA_OUTPUT),
11490 HDA_BIND_MUTE("iSpeaker Playback Switch", 0x03, 2, HDA_INPUT),
11491 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
11492 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
11493 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
11494 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
11495 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
11496 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
11497 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
11499 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11500 /* .name = "Capture Source", */
11501 .name = "Input Source",
11503 .info = alc662_mux_enum_info,
11504 .get = alc662_mux_enum_get,
11505 .put = alc662_mux_enum_put,
11510 static struct snd_kcontrol_new alc662_chmode_mixer[] = {
11512 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11513 .name = "Channel Mode",
11514 .info = alc_ch_mode_info,
11515 .get = alc_ch_mode_get,
11516 .put = alc_ch_mode_put,
11521 static struct hda_verb alc662_init_verbs[] = {
11522 /* ADC: mute amp left and right */
11523 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11524 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
11525 /* Front mixer: unmute input/output amp left and right (volume = 0) */
11527 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11528 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11529 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11530 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11531 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
11533 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11534 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11535 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11536 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11537 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11538 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11540 /* Front Pin: output 0 (0x0c) */
11541 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11542 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11544 /* Rear Pin: output 1 (0x0d) */
11545 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11546 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11548 /* CLFE Pin: output 2 (0x0e) */
11549 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11550 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11552 /* Mic (rear) pin: input vref at 80% */
11553 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
11554 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11555 /* Front Mic pin: input vref at 80% */
11556 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
11557 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11558 /* Line In pin: input */
11559 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11560 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11561 /* Line-2 In: Headphone output (output 0 - 0x0c) */
11562 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11563 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11564 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
11565 /* CD pin widget for input */
11566 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11568 /* FIXME: use matrix-type input source selection */
11569 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
11571 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11572 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11573 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
11574 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
11578 static struct hda_verb alc662_sue_init_verbs[] = {
11579 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
11580 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
11585 * generic initialization of ADC, input mixers and output mixers
11587 static struct hda_verb alc662_auto_init_verbs[] = {
11589 * Unmute ADC and set the default input to mic-in
11591 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
11592 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11594 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
11596 * Note: PASD motherboards uses the Line In 2 as the input for front
11597 * panel mic (mic 2)
11599 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
11600 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11601 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11602 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11603 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11604 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
11607 * Set up output mixers (0x0c - 0x0f)
11609 /* set vol=0 to output mixers */
11610 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11611 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11612 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11614 /* set up input amps for analog loopback */
11615 /* Amp Indices: DAC = 0, mixer = 1 */
11616 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11617 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11618 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11619 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11620 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11621 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11624 /* FIXME: use matrix-type input source selection */
11625 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
11627 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11628 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11632 /* capture mixer elements */
11633 static struct snd_kcontrol_new alc662_capture_mixer[] = {
11634 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
11635 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
11637 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11638 /* The multiple "Capture Source" controls confuse alsamixer
11639 * So call somewhat different..
11640 * FIXME: the controls appear in the "playback" view!
11642 /* .name = "Capture Source", */
11643 .name = "Input Source",
11645 .info = alc882_mux_enum_info,
11646 .get = alc882_mux_enum_get,
11647 .put = alc882_mux_enum_put,
11652 static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
11654 unsigned int present;
11655 unsigned char bits;
11657 present = snd_hda_codec_read(codec, 0x14, 0,
11658 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
11659 bits = present ? HDA_AMP_MUTE : 0;
11660 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
11661 HDA_AMP_MUTE, bits);
11664 static void alc662_lenovo_101e_all_automute(struct hda_codec *codec)
11666 unsigned int present;
11667 unsigned char bits;
11669 present = snd_hda_codec_read(codec, 0x1b, 0,
11670 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
11671 bits = present ? HDA_AMP_MUTE : 0;
11672 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
11673 HDA_AMP_MUTE, bits);
11674 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
11675 HDA_AMP_MUTE, bits);
11678 static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec,
11681 if ((res >> 26) == ALC880_HP_EVENT)
11682 alc662_lenovo_101e_all_automute(codec);
11683 if ((res >> 26) == ALC880_FRONT_EVENT)
11684 alc662_lenovo_101e_ispeaker_automute(codec);
11687 #ifdef CONFIG_SND_HDA_POWER_SAVE
11688 #define alc662_loopbacks alc880_loopbacks
11692 /* pcm configuration: identiacal with ALC880 */
11693 #define alc662_pcm_analog_playback alc880_pcm_analog_playback
11694 #define alc662_pcm_analog_capture alc880_pcm_analog_capture
11695 #define alc662_pcm_digital_playback alc880_pcm_digital_playback
11696 #define alc662_pcm_digital_capture alc880_pcm_digital_capture
11699 * configuration and preset
11701 static const char *alc662_models[ALC662_MODEL_LAST] = {
11702 [ALC662_3ST_2ch_DIG] = "3stack-dig",
11703 [ALC662_3ST_6ch_DIG] = "3stack-6ch-dig",
11704 [ALC662_3ST_6ch] = "3stack-6ch",
11705 [ALC662_5ST_DIG] = "6stack-dig",
11706 [ALC662_LENOVO_101E] = "lenovo-101e",
11707 [ALC662_AUTO] = "auto",
11710 static struct snd_pci_quirk alc662_cfg_tbl[] = {
11711 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E),
11715 static struct alc_config_preset alc662_presets[] = {
11716 [ALC662_3ST_2ch_DIG] = {
11717 .mixers = { alc662_3ST_2ch_mixer },
11718 .init_verbs = { alc662_init_verbs },
11719 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
11720 .dac_nids = alc662_dac_nids,
11721 .dig_out_nid = ALC662_DIGOUT_NID,
11722 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
11723 .adc_nids = alc662_adc_nids,
11724 .dig_in_nid = ALC662_DIGIN_NID,
11725 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
11726 .channel_mode = alc662_3ST_2ch_modes,
11727 .input_mux = &alc662_capture_source,
11729 [ALC662_3ST_6ch_DIG] = {
11730 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
11731 .init_verbs = { alc662_init_verbs },
11732 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
11733 .dac_nids = alc662_dac_nids,
11734 .dig_out_nid = ALC662_DIGOUT_NID,
11735 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
11736 .adc_nids = alc662_adc_nids,
11737 .dig_in_nid = ALC662_DIGIN_NID,
11738 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
11739 .channel_mode = alc662_3ST_6ch_modes,
11741 .input_mux = &alc662_capture_source,
11743 [ALC662_3ST_6ch] = {
11744 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
11745 .init_verbs = { alc662_init_verbs },
11746 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
11747 .dac_nids = alc662_dac_nids,
11748 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
11749 .adc_nids = alc662_adc_nids,
11750 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
11751 .channel_mode = alc662_3ST_6ch_modes,
11753 .input_mux = &alc662_capture_source,
11755 [ALC662_5ST_DIG] = {
11756 .mixers = { alc662_base_mixer, alc662_chmode_mixer },
11757 .init_verbs = { alc662_init_verbs },
11758 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
11759 .dac_nids = alc662_dac_nids,
11760 .dig_out_nid = ALC662_DIGOUT_NID,
11761 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
11762 .adc_nids = alc662_adc_nids,
11763 .dig_in_nid = ALC662_DIGIN_NID,
11764 .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes),
11765 .channel_mode = alc662_5stack_modes,
11766 .input_mux = &alc662_capture_source,
11768 [ALC662_LENOVO_101E] = {
11769 .mixers = { alc662_lenovo_101e_mixer },
11770 .init_verbs = { alc662_init_verbs, alc662_sue_init_verbs },
11771 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
11772 .dac_nids = alc662_dac_nids,
11773 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
11774 .adc_nids = alc662_adc_nids,
11775 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
11776 .channel_mode = alc662_3ST_2ch_modes,
11777 .input_mux = &alc662_lenovo_101e_capture_source,
11778 .unsol_event = alc662_lenovo_101e_unsol_event,
11779 .init_hook = alc662_lenovo_101e_all_automute,
11786 * BIOS auto configuration
11789 /* add playback controls from the parsed DAC table */
11790 static int alc662_auto_create_multi_out_ctls(struct alc_spec *spec,
11791 const struct auto_pin_cfg *cfg)
11794 static const char *chname[4] = {
11795 "Front", "Surround", NULL /*CLFE*/, "Side"
11800 for (i = 0; i < cfg->line_outs; i++) {
11801 if (!spec->multiout.dac_nids[i])
11803 nid = alc880_idx_to_mixer(i);
11806 err = add_control(spec, ALC_CTL_WIDGET_VOL,
11807 "Center Playback Volume",
11808 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
11812 err = add_control(spec, ALC_CTL_WIDGET_VOL,
11813 "LFE Playback Volume",
11814 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
11818 err = add_control(spec, ALC_CTL_BIND_MUTE,
11819 "Center Playback Switch",
11820 HDA_COMPOSE_AMP_VAL(nid, 1, 2,
11824 err = add_control(spec, ALC_CTL_BIND_MUTE,
11825 "LFE Playback Switch",
11826 HDA_COMPOSE_AMP_VAL(nid, 2, 2,
11831 sprintf(name, "%s Playback Volume", chname[i]);
11832 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
11833 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
11837 sprintf(name, "%s Playback Switch", chname[i]);
11838 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
11839 HDA_COMPOSE_AMP_VAL(nid, 3, 2,
11848 /* add playback controls for speaker and HP outputs */
11849 static int alc662_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
11859 if (alc880_is_fixed_pin(pin)) {
11860 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
11861 /* printk("DAC nid=%x\n",nid); */
11862 /* specify the DAC as the extra output */
11863 if (!spec->multiout.hp_nid)
11864 spec->multiout.hp_nid = nid;
11866 spec->multiout.extra_out_nid[0] = nid;
11867 /* control HP volume/switch on the output mixer amp */
11868 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
11869 sprintf(name, "%s Playback Volume", pfx);
11870 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
11871 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
11874 sprintf(name, "%s Playback Switch", pfx);
11875 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
11876 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
11879 } else if (alc880_is_multi_pin(pin)) {
11880 /* set manual connection */
11881 /* we have only a switch on HP-out PIN */
11882 sprintf(name, "%s Playback Switch", pfx);
11883 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
11884 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
11891 /* create playback/capture controls for input pins */
11892 static int alc662_auto_create_analog_input_ctls(struct alc_spec *spec,
11893 const struct auto_pin_cfg *cfg)
11895 struct hda_input_mux *imux = &spec->private_imux;
11898 for (i = 0; i < AUTO_PIN_LAST; i++) {
11899 if (alc880_is_input_pin(cfg->input_pins[i])) {
11900 idx = alc880_input_pin_idx(cfg->input_pins[i]);
11901 err = new_analog_input(spec, cfg->input_pins[i],
11902 auto_pin_cfg_labels[i],
11906 imux->items[imux->num_items].label =
11907 auto_pin_cfg_labels[i];
11908 imux->items[imux->num_items].index =
11909 alc880_input_pin_idx(cfg->input_pins[i]);
11916 static void alc662_auto_set_output_and_unmute(struct hda_codec *codec,
11917 hda_nid_t nid, int pin_type,
11920 /* set as output */
11921 snd_hda_codec_write(codec, nid, 0,
11922 AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
11923 snd_hda_codec_write(codec, nid, 0,
11924 AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
11925 /* need the manual connection? */
11926 if (alc880_is_multi_pin(nid)) {
11927 struct alc_spec *spec = codec->spec;
11928 int idx = alc880_multi_pin_idx(nid);
11929 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
11930 AC_VERB_SET_CONNECT_SEL,
11931 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
11935 static void alc662_auto_init_multi_out(struct hda_codec *codec)
11937 struct alc_spec *spec = codec->spec;
11940 for (i = 0; i <= HDA_SIDE; i++) {
11941 hda_nid_t nid = spec->autocfg.line_out_pins[i];
11942 int pin_type = get_pin_type(spec->autocfg.line_out_type);
11944 alc662_auto_set_output_and_unmute(codec, nid, pin_type,
11949 static void alc662_auto_init_hp_out(struct hda_codec *codec)
11951 struct alc_spec *spec = codec->spec;
11954 pin = spec->autocfg.hp_pins[0];
11955 if (pin) /* connect to front */
11957 alc662_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
11960 #define alc662_is_input_pin(nid) alc880_is_input_pin(nid)
11961 #define ALC662_PIN_CD_NID ALC880_PIN_CD_NID
11963 static void alc662_auto_init_analog_input(struct hda_codec *codec)
11965 struct alc_spec *spec = codec->spec;
11968 for (i = 0; i < AUTO_PIN_LAST; i++) {
11969 hda_nid_t nid = spec->autocfg.input_pins[i];
11970 if (alc662_is_input_pin(nid)) {
11971 snd_hda_codec_write(codec, nid, 0,
11972 AC_VERB_SET_PIN_WIDGET_CONTROL,
11973 (i <= AUTO_PIN_FRONT_MIC ?
11974 PIN_VREF80 : PIN_IN));
11975 if (nid != ALC662_PIN_CD_NID)
11976 snd_hda_codec_write(codec, nid, 0,
11977 AC_VERB_SET_AMP_GAIN_MUTE,
11983 static int alc662_parse_auto_config(struct hda_codec *codec)
11985 struct alc_spec *spec = codec->spec;
11987 static hda_nid_t alc662_ignore[] = { 0x1d, 0 };
11989 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
11993 if (!spec->autocfg.line_outs)
11994 return 0; /* can't find valid BIOS pin config */
11996 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
11999 err = alc662_auto_create_multi_out_ctls(spec, &spec->autocfg);
12002 err = alc662_auto_create_extra_out(spec,
12003 spec->autocfg.speaker_pins[0],
12007 err = alc662_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
12011 err = alc662_auto_create_analog_input_ctls(spec, &spec->autocfg);
12015 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
12017 if (spec->autocfg.dig_out_pin)
12018 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
12020 if (spec->kctl_alloc)
12021 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
12023 spec->num_mux_defs = 1;
12024 spec->input_mux = &spec->private_imux;
12026 spec->init_verbs[spec->num_init_verbs++] = alc662_auto_init_verbs;
12027 spec->mixers[spec->num_mixers] = alc662_capture_mixer;
12028 spec->num_mixers++;
12032 /* additional initialization for auto-configuration model */
12033 static void alc662_auto_init(struct hda_codec *codec)
12035 alc662_auto_init_multi_out(codec);
12036 alc662_auto_init_hp_out(codec);
12037 alc662_auto_init_analog_input(codec);
12040 static int patch_alc662(struct hda_codec *codec)
12042 struct alc_spec *spec;
12043 int err, board_config;
12045 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
12049 codec->spec = spec;
12051 board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST,
12054 if (board_config < 0) {
12055 printk(KERN_INFO "hda_codec: Unknown model for ALC662, "
12056 "trying auto-probe from BIOS...\n");
12057 board_config = ALC662_AUTO;
12060 if (board_config == ALC662_AUTO) {
12061 /* automatic parse from the BIOS config */
12062 err = alc662_parse_auto_config(codec);
12068 "hda_codec: Cannot set up configuration "
12069 "from BIOS. Using base mode...\n");
12070 board_config = ALC662_3ST_2ch_DIG;
12074 if (board_config != ALC662_AUTO)
12075 setup_preset(spec, &alc662_presets[board_config]);
12077 spec->stream_name_analog = "ALC662 Analog";
12078 spec->stream_analog_playback = &alc662_pcm_analog_playback;
12079 spec->stream_analog_capture = &alc662_pcm_analog_capture;
12081 spec->stream_name_digital = "ALC662 Digital";
12082 spec->stream_digital_playback = &alc662_pcm_digital_playback;
12083 spec->stream_digital_capture = &alc662_pcm_digital_capture;
12085 if (!spec->adc_nids && spec->input_mux) {
12086 spec->adc_nids = alc662_adc_nids;
12087 spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids);
12090 codec->patch_ops = alc_patch_ops;
12091 if (board_config == ALC662_AUTO)
12092 spec->init_hook = alc662_auto_init;
12093 #ifdef CONFIG_SND_HDA_POWER_SAVE
12094 if (!spec->loopback.amplist)
12095 spec->loopback.amplist = alc662_loopbacks;
12104 struct hda_codec_preset snd_hda_preset_realtek[] = {
12105 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
12106 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
12107 { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 },
12108 { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
12109 .patch = patch_alc861 },
12110 { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
12111 { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
12112 { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
12113 { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2",
12114 .patch = patch_alc883 },
12115 { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
12116 .patch = patch_alc662 },
12117 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
12118 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
12119 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc883 },
12120 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
12121 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc883 },
12122 {} /* terminator */