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 <linux/init.h>
27 #include <linux/delay.h>
28 #include <linux/slab.h>
29 #include <linux/pci.h>
30 #include <sound/core.h>
31 #include "hda_codec.h"
32 #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 */
64 #ifdef CONFIG_SND_DEBUG
68 ALC880_MODEL_LAST /* last tag */
82 #ifdef CONFIG_SND_DEBUG
86 ALC260_MODEL_LAST /* last tag */
96 ALC262_HP_BPC_D7000_WL,
97 ALC262_HP_BPC_D7000_WF,
110 ALC262_MODEL_LAST /* last tag */
120 ALC268_ACER_ASPIRE_ONE,
123 #ifdef CONFIG_SND_DEBUG
127 ALC268_MODEL_LAST /* last tag */
134 ALC269_ASUS_EEEPC_P703,
135 ALC269_ASUS_EEEPC_P901,
139 ALC269_MODEL_LAST /* last tag */
156 /* ALC861-VD models */
178 ALC662_ASUS_EEEPC_P701,
179 ALC662_ASUS_EEEPC_EP20,
220 ALC883_TARGA_2ch_DIG,
223 ALC888_ACER_ASPIRE_4930G,
227 ALC883_LENOVO_101E_2ch,
228 ALC883_LENOVO_NB0763,
229 ALC888_LENOVO_MS7195_DIG,
236 ALC883_FUJITSU_PI2515,
237 ALC888_FUJITSU_XA3530,
238 ALC883_3ST_6ch_INTEL,
246 /* styles of capture selection */
248 CAPT_MUX = 0, /* only mux based */
249 CAPT_MIX, /* only mixer based */
250 CAPT_1MUX_MIX, /* first mux and other mixers */
254 #define GPIO_MASK 0x03
257 /* codec parameterization */
258 struct snd_kcontrol_new *mixers[5]; /* mixer arrays */
259 unsigned int num_mixers;
260 struct snd_kcontrol_new *cap_mixer; /* capture mixer */
261 unsigned int beep_amp; /* beep amp value, set via set_beep_amp() */
263 const struct hda_verb *init_verbs[5]; /* initialization verbs
267 unsigned int num_init_verbs;
269 char *stream_name_analog; /* analog PCM stream */
270 struct hda_pcm_stream *stream_analog_playback;
271 struct hda_pcm_stream *stream_analog_capture;
272 struct hda_pcm_stream *stream_analog_alt_playback;
273 struct hda_pcm_stream *stream_analog_alt_capture;
275 char *stream_name_digital; /* digital PCM stream */
276 struct hda_pcm_stream *stream_digital_playback;
277 struct hda_pcm_stream *stream_digital_capture;
280 struct hda_multi_out multiout; /* playback set-up
281 * max_channels, dacs must be set
282 * dig_out_nid and hp_nid are optional
284 hda_nid_t alt_dac_nid;
285 hda_nid_t slave_dig_outs[3]; /* optional - for auto-parsing */
289 unsigned int num_adc_nids;
291 hda_nid_t *capsrc_nids;
292 hda_nid_t dig_in_nid; /* digital-in NID; optional */
293 int capture_style; /* capture style (CAPT_*) */
296 unsigned int num_mux_defs;
297 const struct hda_input_mux *input_mux;
298 unsigned int cur_mux[3];
301 const struct hda_channel_mode *channel_mode;
302 int num_channel_mode;
305 /* PCM information */
306 struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */
308 /* dynamic controls, init_verbs and input_mux */
309 struct auto_pin_cfg autocfg;
310 struct snd_array kctls;
311 struct hda_input_mux private_imux[3];
312 hda_nid_t private_dac_nids[AUTO_CFG_MAX_OUTS];
315 void (*init_hook)(struct hda_codec *codec);
316 void (*unsol_event)(struct hda_codec *codec, unsigned int res);
318 /* for pin sensing */
319 unsigned int sense_updated: 1;
320 unsigned int jack_present: 1;
321 unsigned int master_sw: 1;
324 unsigned int no_analog :1; /* digital I/O only */
326 /* for virtual master */
327 hda_nid_t vmaster_nid;
328 #ifdef CONFIG_SND_HDA_POWER_SAVE
329 struct hda_loopback_check loopback;
334 unsigned int pll_coef_idx, pll_coef_bit;
338 * configuration template - to be copied to the spec instance
340 struct alc_config_preset {
341 struct snd_kcontrol_new *mixers[5]; /* should be identical size
344 struct snd_kcontrol_new *cap_mixer; /* capture mixer */
345 const struct hda_verb *init_verbs[5];
346 unsigned int num_dacs;
348 hda_nid_t dig_out_nid; /* optional */
349 hda_nid_t hp_nid; /* optional */
350 hda_nid_t *slave_dig_outs;
351 unsigned int num_adc_nids;
353 hda_nid_t *capsrc_nids;
354 hda_nid_t dig_in_nid;
355 unsigned int num_channel_mode;
356 const struct hda_channel_mode *channel_mode;
358 unsigned int num_mux_defs;
359 const struct hda_input_mux *input_mux;
360 void (*unsol_event)(struct hda_codec *, unsigned int);
361 void (*init_hook)(struct hda_codec *);
362 #ifdef CONFIG_SND_HDA_POWER_SAVE
363 struct hda_amp_list *loopbacks;
371 static int alc_mux_enum_info(struct snd_kcontrol *kcontrol,
372 struct snd_ctl_elem_info *uinfo)
374 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
375 struct alc_spec *spec = codec->spec;
376 unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id);
377 if (mux_idx >= spec->num_mux_defs)
379 return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo);
382 static int alc_mux_enum_get(struct snd_kcontrol *kcontrol,
383 struct snd_ctl_elem_value *ucontrol)
385 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
386 struct alc_spec *spec = codec->spec;
387 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
389 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
393 static int alc_mux_enum_put(struct snd_kcontrol *kcontrol,
394 struct snd_ctl_elem_value *ucontrol)
396 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
397 struct alc_spec *spec = codec->spec;
398 const struct hda_input_mux *imux;
399 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
400 unsigned int mux_idx;
401 hda_nid_t nid = spec->capsrc_nids ?
402 spec->capsrc_nids[adc_idx] : spec->adc_nids[adc_idx];
404 mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx;
405 imux = &spec->input_mux[mux_idx];
407 if (spec->capture_style &&
408 !(spec->capture_style == CAPT_1MUX_MIX && !adc_idx)) {
409 /* Matrix-mixer style (e.g. ALC882) */
410 unsigned int *cur_val = &spec->cur_mux[adc_idx];
413 idx = ucontrol->value.enumerated.item[0];
414 if (idx >= imux->num_items)
415 idx = imux->num_items - 1;
418 for (i = 0; i < imux->num_items; i++) {
419 unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
420 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
421 imux->items[i].index,
427 /* MUX style (e.g. ALC880) */
428 return snd_hda_input_mux_put(codec, imux, ucontrol, nid,
429 &spec->cur_mux[adc_idx]);
434 * channel mode setting
436 static int alc_ch_mode_info(struct snd_kcontrol *kcontrol,
437 struct snd_ctl_elem_info *uinfo)
439 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
440 struct alc_spec *spec = codec->spec;
441 return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
442 spec->num_channel_mode);
445 static int alc_ch_mode_get(struct snd_kcontrol *kcontrol,
446 struct snd_ctl_elem_value *ucontrol)
448 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
449 struct alc_spec *spec = codec->spec;
450 return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
451 spec->num_channel_mode,
452 spec->multiout.max_channels);
455 static int alc_ch_mode_put(struct snd_kcontrol *kcontrol,
456 struct snd_ctl_elem_value *ucontrol)
458 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
459 struct alc_spec *spec = codec->spec;
460 int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
461 spec->num_channel_mode,
462 &spec->multiout.max_channels);
463 if (err >= 0 && spec->need_dac_fix)
464 spec->multiout.num_dacs = spec->multiout.max_channels / 2;
469 * Control the mode of pin widget settings via the mixer. "pc" is used
470 * instead of "%" to avoid consequences of accidently treating the % as
471 * being part of a format specifier. Maximum allowed length of a value is
472 * 63 characters plus NULL terminator.
474 * Note: some retasking pin complexes seem to ignore requests for input
475 * states other than HiZ (eg: PIN_VREFxx) and revert to HiZ if any of these
476 * are requested. Therefore order this list so that this behaviour will not
477 * cause problems when mixer clients move through the enum sequentially.
478 * NIDs 0x0f and 0x10 have been observed to have this behaviour as of
481 static char *alc_pin_mode_names[] = {
482 "Mic 50pc bias", "Mic 80pc bias",
483 "Line in", "Line out", "Headphone out",
485 static unsigned char alc_pin_mode_values[] = {
486 PIN_VREF50, PIN_VREF80, PIN_IN, PIN_OUT, PIN_HP,
488 /* The control can present all 5 options, or it can limit the options based
489 * in the pin being assumed to be exclusively an input or an output pin. In
490 * addition, "input" pins may or may not process the mic bias option
491 * depending on actual widget capability (NIDs 0x0f and 0x10 don't seem to
492 * accept requests for bias as of chip versions up to March 2006) and/or
493 * wiring in the computer.
495 #define ALC_PIN_DIR_IN 0x00
496 #define ALC_PIN_DIR_OUT 0x01
497 #define ALC_PIN_DIR_INOUT 0x02
498 #define ALC_PIN_DIR_IN_NOMICBIAS 0x03
499 #define ALC_PIN_DIR_INOUT_NOMICBIAS 0x04
501 /* Info about the pin modes supported by the different pin direction modes.
502 * For each direction the minimum and maximum values are given.
504 static signed char alc_pin_mode_dir_info[5][2] = {
505 { 0, 2 }, /* ALC_PIN_DIR_IN */
506 { 3, 4 }, /* ALC_PIN_DIR_OUT */
507 { 0, 4 }, /* ALC_PIN_DIR_INOUT */
508 { 2, 2 }, /* ALC_PIN_DIR_IN_NOMICBIAS */
509 { 2, 4 }, /* ALC_PIN_DIR_INOUT_NOMICBIAS */
511 #define alc_pin_mode_min(_dir) (alc_pin_mode_dir_info[_dir][0])
512 #define alc_pin_mode_max(_dir) (alc_pin_mode_dir_info[_dir][1])
513 #define alc_pin_mode_n_items(_dir) \
514 (alc_pin_mode_max(_dir)-alc_pin_mode_min(_dir)+1)
516 static int alc_pin_mode_info(struct snd_kcontrol *kcontrol,
517 struct snd_ctl_elem_info *uinfo)
519 unsigned int item_num = uinfo->value.enumerated.item;
520 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
522 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
524 uinfo->value.enumerated.items = alc_pin_mode_n_items(dir);
526 if (item_num<alc_pin_mode_min(dir) || item_num>alc_pin_mode_max(dir))
527 item_num = alc_pin_mode_min(dir);
528 strcpy(uinfo->value.enumerated.name, alc_pin_mode_names[item_num]);
532 static int alc_pin_mode_get(struct snd_kcontrol *kcontrol,
533 struct snd_ctl_elem_value *ucontrol)
536 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
537 hda_nid_t nid = kcontrol->private_value & 0xffff;
538 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
539 long *valp = ucontrol->value.integer.value;
540 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
541 AC_VERB_GET_PIN_WIDGET_CONTROL,
544 /* Find enumerated value for current pinctl setting */
545 i = alc_pin_mode_min(dir);
546 while (alc_pin_mode_values[i] != pinctl && i <= alc_pin_mode_max(dir))
548 *valp = i <= alc_pin_mode_max(dir) ? i: alc_pin_mode_min(dir);
552 static int alc_pin_mode_put(struct snd_kcontrol *kcontrol,
553 struct snd_ctl_elem_value *ucontrol)
556 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
557 hda_nid_t nid = kcontrol->private_value & 0xffff;
558 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
559 long val = *ucontrol->value.integer.value;
560 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
561 AC_VERB_GET_PIN_WIDGET_CONTROL,
564 if (val < alc_pin_mode_min(dir) || val > alc_pin_mode_max(dir))
565 val = alc_pin_mode_min(dir);
567 change = pinctl != alc_pin_mode_values[val];
569 /* Set pin mode to that requested */
570 snd_hda_codec_write_cache(codec, nid, 0,
571 AC_VERB_SET_PIN_WIDGET_CONTROL,
572 alc_pin_mode_values[val]);
574 /* Also enable the retasking pin's input/output as required
575 * for the requested pin mode. Enum values of 2 or less are
578 * Dynamically switching the input/output buffers probably
579 * reduces noise slightly (particularly on input) so we'll
580 * do it. However, having both input and output buffers
581 * enabled simultaneously doesn't seem to be problematic if
582 * this turns out to be necessary in the future.
585 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
586 HDA_AMP_MUTE, HDA_AMP_MUTE);
587 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
590 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
591 HDA_AMP_MUTE, HDA_AMP_MUTE);
592 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
599 #define ALC_PIN_MODE(xname, nid, dir) \
600 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
601 .info = alc_pin_mode_info, \
602 .get = alc_pin_mode_get, \
603 .put = alc_pin_mode_put, \
604 .private_value = nid | (dir<<16) }
606 /* A switch control for ALC260 GPIO pins. Multiple GPIOs can be ganged
607 * together using a mask with more than one bit set. This control is
608 * currently used only by the ALC260 test model. At this stage they are not
609 * needed for any "production" models.
611 #ifdef CONFIG_SND_DEBUG
612 #define alc_gpio_data_info snd_ctl_boolean_mono_info
614 static int alc_gpio_data_get(struct snd_kcontrol *kcontrol,
615 struct snd_ctl_elem_value *ucontrol)
617 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
618 hda_nid_t nid = kcontrol->private_value & 0xffff;
619 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
620 long *valp = ucontrol->value.integer.value;
621 unsigned int val = snd_hda_codec_read(codec, nid, 0,
622 AC_VERB_GET_GPIO_DATA, 0x00);
624 *valp = (val & mask) != 0;
627 static int alc_gpio_data_put(struct snd_kcontrol *kcontrol,
628 struct snd_ctl_elem_value *ucontrol)
631 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
632 hda_nid_t nid = kcontrol->private_value & 0xffff;
633 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
634 long val = *ucontrol->value.integer.value;
635 unsigned int gpio_data = snd_hda_codec_read(codec, nid, 0,
636 AC_VERB_GET_GPIO_DATA,
639 /* Set/unset the masked GPIO bit(s) as needed */
640 change = (val == 0 ? 0 : mask) != (gpio_data & mask);
645 snd_hda_codec_write_cache(codec, nid, 0,
646 AC_VERB_SET_GPIO_DATA, gpio_data);
650 #define ALC_GPIO_DATA_SWITCH(xname, nid, mask) \
651 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
652 .info = alc_gpio_data_info, \
653 .get = alc_gpio_data_get, \
654 .put = alc_gpio_data_put, \
655 .private_value = nid | (mask<<16) }
656 #endif /* CONFIG_SND_DEBUG */
658 /* A switch control to allow the enabling of the digital IO pins on the
659 * ALC260. This is incredibly simplistic; the intention of this control is
660 * to provide something in the test model allowing digital outputs to be
661 * identified if present. If models are found which can utilise these
662 * outputs a more complete mixer control can be devised for those models if
665 #ifdef CONFIG_SND_DEBUG
666 #define alc_spdif_ctrl_info snd_ctl_boolean_mono_info
668 static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol,
669 struct snd_ctl_elem_value *ucontrol)
671 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
672 hda_nid_t nid = kcontrol->private_value & 0xffff;
673 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
674 long *valp = ucontrol->value.integer.value;
675 unsigned int val = snd_hda_codec_read(codec, nid, 0,
676 AC_VERB_GET_DIGI_CONVERT_1, 0x00);
678 *valp = (val & mask) != 0;
681 static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol,
682 struct snd_ctl_elem_value *ucontrol)
685 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
686 hda_nid_t nid = kcontrol->private_value & 0xffff;
687 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
688 long val = *ucontrol->value.integer.value;
689 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
690 AC_VERB_GET_DIGI_CONVERT_1,
693 /* Set/unset the masked control bit(s) as needed */
694 change = (val == 0 ? 0 : mask) != (ctrl_data & mask);
699 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1,
704 #define ALC_SPDIF_CTRL_SWITCH(xname, nid, mask) \
705 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
706 .info = alc_spdif_ctrl_info, \
707 .get = alc_spdif_ctrl_get, \
708 .put = alc_spdif_ctrl_put, \
709 .private_value = nid | (mask<<16) }
710 #endif /* CONFIG_SND_DEBUG */
712 /* A switch control to allow the enabling EAPD digital outputs on the ALC26x.
713 * Again, this is only used in the ALC26x test models to help identify when
714 * the EAPD line must be asserted for features to work.
716 #ifdef CONFIG_SND_DEBUG
717 #define alc_eapd_ctrl_info snd_ctl_boolean_mono_info
719 static int alc_eapd_ctrl_get(struct snd_kcontrol *kcontrol,
720 struct snd_ctl_elem_value *ucontrol)
722 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
723 hda_nid_t nid = kcontrol->private_value & 0xffff;
724 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
725 long *valp = ucontrol->value.integer.value;
726 unsigned int val = snd_hda_codec_read(codec, nid, 0,
727 AC_VERB_GET_EAPD_BTLENABLE, 0x00);
729 *valp = (val & mask) != 0;
733 static int alc_eapd_ctrl_put(struct snd_kcontrol *kcontrol,
734 struct snd_ctl_elem_value *ucontrol)
737 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
738 hda_nid_t nid = kcontrol->private_value & 0xffff;
739 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
740 long val = *ucontrol->value.integer.value;
741 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
742 AC_VERB_GET_EAPD_BTLENABLE,
745 /* Set/unset the masked control bit(s) as needed */
746 change = (!val ? 0 : mask) != (ctrl_data & mask);
751 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
757 #define ALC_EAPD_CTRL_SWITCH(xname, nid, mask) \
758 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
759 .info = alc_eapd_ctrl_info, \
760 .get = alc_eapd_ctrl_get, \
761 .put = alc_eapd_ctrl_put, \
762 .private_value = nid | (mask<<16) }
763 #endif /* CONFIG_SND_DEBUG */
766 * set up the input pin config (depending on the given auto-pin type)
768 static void alc_set_input_pin(struct hda_codec *codec, hda_nid_t nid,
771 unsigned int val = PIN_IN;
773 if (auto_pin_type <= AUTO_PIN_FRONT_MIC) {
775 pincap = snd_hda_query_pin_caps(codec, nid);
776 pincap = (pincap & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT;
777 if (pincap & AC_PINCAP_VREF_80)
780 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, val);
785 static void add_mixer(struct alc_spec *spec, struct snd_kcontrol_new *mix)
787 if (snd_BUG_ON(spec->num_mixers >= ARRAY_SIZE(spec->mixers)))
789 spec->mixers[spec->num_mixers++] = mix;
792 static void add_verb(struct alc_spec *spec, const struct hda_verb *verb)
794 if (snd_BUG_ON(spec->num_init_verbs >= ARRAY_SIZE(spec->init_verbs)))
796 spec->init_verbs[spec->num_init_verbs++] = verb;
799 #ifdef CONFIG_PROC_FS
803 static void print_realtek_coef(struct snd_info_buffer *buffer,
804 struct hda_codec *codec, hda_nid_t nid)
810 coeff = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_PROC_COEF, 0);
811 snd_iprintf(buffer, " Processing Coefficient: 0x%02x\n", coeff);
812 coeff = snd_hda_codec_read(codec, nid, 0,
813 AC_VERB_GET_COEF_INDEX, 0);
814 snd_iprintf(buffer, " Coefficient Index: 0x%02x\n", coeff);
817 #define print_realtek_coef NULL
821 * set up from the preset table
823 static void setup_preset(struct alc_spec *spec,
824 const struct alc_config_preset *preset)
828 for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++)
829 add_mixer(spec, preset->mixers[i]);
830 spec->cap_mixer = preset->cap_mixer;
831 for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i];
833 add_verb(spec, preset->init_verbs[i]);
835 spec->channel_mode = preset->channel_mode;
836 spec->num_channel_mode = preset->num_channel_mode;
837 spec->need_dac_fix = preset->need_dac_fix;
839 spec->multiout.max_channels = spec->channel_mode[0].channels;
841 spec->multiout.num_dacs = preset->num_dacs;
842 spec->multiout.dac_nids = preset->dac_nids;
843 spec->multiout.dig_out_nid = preset->dig_out_nid;
844 spec->multiout.slave_dig_outs = preset->slave_dig_outs;
845 spec->multiout.hp_nid = preset->hp_nid;
847 spec->num_mux_defs = preset->num_mux_defs;
848 if (!spec->num_mux_defs)
849 spec->num_mux_defs = 1;
850 spec->input_mux = preset->input_mux;
852 spec->num_adc_nids = preset->num_adc_nids;
853 spec->adc_nids = preset->adc_nids;
854 spec->capsrc_nids = preset->capsrc_nids;
855 spec->dig_in_nid = preset->dig_in_nid;
857 spec->unsol_event = preset->unsol_event;
858 spec->init_hook = preset->init_hook;
859 #ifdef CONFIG_SND_HDA_POWER_SAVE
860 spec->loopback.amplist = preset->loopbacks;
864 /* Enable GPIO mask and set output */
865 static struct hda_verb alc_gpio1_init_verbs[] = {
866 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
867 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
868 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
872 static struct hda_verb alc_gpio2_init_verbs[] = {
873 {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
874 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
875 {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
879 static struct hda_verb alc_gpio3_init_verbs[] = {
880 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
881 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
882 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
887 * Fix hardware PLL issue
888 * On some codecs, the analog PLL gating control must be off while
889 * the default value is 1.
891 static void alc_fix_pll(struct hda_codec *codec)
893 struct alc_spec *spec = codec->spec;
898 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX,
900 val = snd_hda_codec_read(codec, spec->pll_nid, 0,
901 AC_VERB_GET_PROC_COEF, 0);
902 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX,
904 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_PROC_COEF,
905 val & ~(1 << spec->pll_coef_bit));
908 static void alc_fix_pll_init(struct hda_codec *codec, hda_nid_t nid,
909 unsigned int coef_idx, unsigned int coef_bit)
911 struct alc_spec *spec = codec->spec;
913 spec->pll_coef_idx = coef_idx;
914 spec->pll_coef_bit = coef_bit;
918 static void alc_sku_automute(struct hda_codec *codec)
920 struct alc_spec *spec = codec->spec;
921 unsigned int present;
922 unsigned int hp_nid = spec->autocfg.hp_pins[0];
923 unsigned int sp_nid = spec->autocfg.speaker_pins[0];
925 /* need to execute and sync at first */
926 snd_hda_codec_read(codec, hp_nid, 0, AC_VERB_SET_PIN_SENSE, 0);
927 present = snd_hda_codec_read(codec, hp_nid, 0,
928 AC_VERB_GET_PIN_SENSE, 0);
929 spec->jack_present = (present & 0x80000000) != 0;
930 snd_hda_codec_write(codec, sp_nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
931 spec->jack_present ? 0 : PIN_OUT);
934 #if 0 /* it's broken in some acses -- temporarily disabled */
935 static void alc_mic_automute(struct hda_codec *codec)
937 struct alc_spec *spec = codec->spec;
938 unsigned int present;
939 unsigned int mic_nid = spec->autocfg.input_pins[AUTO_PIN_MIC];
940 unsigned int fmic_nid = spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC];
941 unsigned int mix_nid = spec->capsrc_nids[0];
942 unsigned int capsrc_idx_mic, capsrc_idx_fmic;
944 capsrc_idx_mic = mic_nid - 0x18;
945 capsrc_idx_fmic = fmic_nid - 0x18;
946 present = snd_hda_codec_read(codec, mic_nid, 0,
947 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
948 snd_hda_codec_write(codec, mix_nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
949 0x7000 | (capsrc_idx_mic << 8) | (present ? 0 : 0x80));
950 snd_hda_codec_write(codec, mix_nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
951 0x7000 | (capsrc_idx_fmic << 8) | (present ? 0x80 : 0));
952 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, capsrc_idx_fmic,
953 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
956 #define alc_mic_automute(codec) do {} while(0) /* NOP */
957 #endif /* disabled */
959 /* unsolicited event for HP jack sensing */
960 static void alc_sku_unsol_event(struct hda_codec *codec, unsigned int res)
962 if (codec->vendor_id == 0x10ec0880)
966 if (res == ALC880_HP_EVENT)
967 alc_sku_automute(codec);
969 if (res == ALC880_MIC_EVENT)
970 alc_mic_automute(codec);
973 static void alc_inithook(struct hda_codec *codec)
975 alc_sku_automute(codec);
976 alc_mic_automute(codec);
979 /* additional initialization for ALC888 variants */
980 static void alc888_coef_init(struct hda_codec *codec)
984 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 0);
985 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
986 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
987 if ((tmp & 0xf0) == 0x20)
989 snd_hda_codec_read(codec, 0x20, 0,
990 AC_VERB_SET_PROC_COEF, 0x830);
993 snd_hda_codec_read(codec, 0x20, 0,
994 AC_VERB_SET_PROC_COEF, 0x3030);
997 /* 32-bit subsystem ID for BIOS loading in HD Audio codec.
998 * 31 ~ 16 : Manufacture ID
1000 * 7 ~ 0 : Assembly ID
1001 * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36
1003 static void alc_subsystem_id(struct hda_codec *codec,
1004 unsigned int porta, unsigned int porte,
1007 unsigned int ass, tmp, i;
1009 struct alc_spec *spec = codec->spec;
1011 ass = codec->subsystem_id & 0xffff;
1012 if ((ass != codec->bus->pci->subsystem_device) && (ass & 1))
1016 * 31~30 : port conetcivity
1019 * 19~16 : Check sum (15:1)
1024 if (codec->vendor_id == 0x10ec0260)
1026 ass = snd_hda_codec_get_pincfg(codec, nid);
1027 snd_printd("realtek: No valid SSID, "
1028 "checking pincfg 0x%08x for NID 0x%x\n",
1030 if (!(ass & 1) && !(ass & 0x100000))
1032 if ((ass >> 30) != 1) /* no physical connection */
1037 for (i = 1; i < 16; i++) {
1041 if (((ass >> 16) & 0xf) != tmp)
1044 snd_printd("realtek: Enabling init ASM_ID=0x%04x CODEC_ID=%08x\n",
1045 ass & 0xffff, codec->vendor_id);
1049 * 2 : 0 --> Desktop, 1 --> Laptop
1050 * 3~5 : External Amplifier control
1053 tmp = (ass & 0x38) >> 3; /* external Amp control */
1056 snd_hda_sequence_write(codec, alc_gpio1_init_verbs);
1059 snd_hda_sequence_write(codec, alc_gpio2_init_verbs);
1062 snd_hda_sequence_write(codec, alc_gpio3_init_verbs);
1064 case 5: /* set EAPD output high */
1065 switch (codec->vendor_id) {
1067 snd_hda_codec_write(codec, 0x0f, 0,
1068 AC_VERB_SET_EAPD_BTLENABLE, 2);
1069 snd_hda_codec_write(codec, 0x10, 0,
1070 AC_VERB_SET_EAPD_BTLENABLE, 2);
1082 snd_hda_codec_write(codec, 0x14, 0,
1083 AC_VERB_SET_EAPD_BTLENABLE, 2);
1084 snd_hda_codec_write(codec, 0x15, 0,
1085 AC_VERB_SET_EAPD_BTLENABLE, 2);
1088 switch (codec->vendor_id) {
1090 snd_hda_codec_write(codec, 0x1a, 0,
1091 AC_VERB_SET_COEF_INDEX, 7);
1092 tmp = snd_hda_codec_read(codec, 0x1a, 0,
1093 AC_VERB_GET_PROC_COEF, 0);
1094 snd_hda_codec_write(codec, 0x1a, 0,
1095 AC_VERB_SET_COEF_INDEX, 7);
1096 snd_hda_codec_write(codec, 0x1a, 0,
1097 AC_VERB_SET_PROC_COEF,
1107 snd_hda_codec_write(codec, 0x20, 0,
1108 AC_VERB_SET_COEF_INDEX, 7);
1109 tmp = snd_hda_codec_read(codec, 0x20, 0,
1110 AC_VERB_GET_PROC_COEF, 0);
1111 snd_hda_codec_write(codec, 0x20, 0,
1112 AC_VERB_SET_COEF_INDEX, 7);
1113 snd_hda_codec_write(codec, 0x20, 0,
1114 AC_VERB_SET_PROC_COEF,
1118 /*alc888_coef_init(codec);*/ /* called in alc_init() */
1122 snd_hda_codec_write(codec, 0x20, 0,
1123 AC_VERB_SET_COEF_INDEX, 7);
1124 tmp = snd_hda_codec_read(codec, 0x20, 0,
1125 AC_VERB_GET_PROC_COEF, 0);
1126 snd_hda_codec_write(codec, 0x20, 0,
1127 AC_VERB_SET_COEF_INDEX, 7);
1128 snd_hda_codec_write(codec, 0x20, 0,
1129 AC_VERB_SET_PROC_COEF,
1137 /* is laptop or Desktop and enable the function "Mute internal speaker
1138 * when the external headphone out jack is plugged"
1140 if (!(ass & 0x8000))
1143 * 10~8 : Jack location
1144 * 12~11: Headphone out -> 00: PortA, 01: PortE, 02: PortD, 03: Resvered
1146 * 15 : 1 --> enable the function "Mute internal speaker
1147 * when the external headphone out jack is plugged"
1149 if (!spec->autocfg.speaker_pins[0]) {
1150 if (spec->autocfg.line_out_pins[0])
1151 spec->autocfg.speaker_pins[0] =
1152 spec->autocfg.line_out_pins[0];
1157 if (!spec->autocfg.hp_pins[0]) {
1158 tmp = (ass >> 11) & 0x3; /* HP to chassis */
1160 spec->autocfg.hp_pins[0] = porta;
1162 spec->autocfg.hp_pins[0] = porte;
1164 spec->autocfg.hp_pins[0] = portd;
1168 if (spec->autocfg.hp_pins[0])
1169 snd_hda_codec_write(codec, spec->autocfg.hp_pins[0], 0,
1170 AC_VERB_SET_UNSOLICITED_ENABLE,
1171 AC_USRSP_EN | ALC880_HP_EVENT);
1173 #if 0 /* it's broken in some acses -- temporarily disabled */
1174 if (spec->autocfg.input_pins[AUTO_PIN_MIC] &&
1175 spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC])
1176 snd_hda_codec_write(codec,
1177 spec->autocfg.input_pins[AUTO_PIN_MIC], 0,
1178 AC_VERB_SET_UNSOLICITED_ENABLE,
1179 AC_USRSP_EN | ALC880_MIC_EVENT);
1180 #endif /* disabled */
1182 spec->unsol_event = alc_sku_unsol_event;
1186 * Fix-up pin default configurations
1194 static void alc_fix_pincfg(struct hda_codec *codec,
1195 const struct snd_pci_quirk *quirk,
1196 const struct alc_pincfg **pinfix)
1198 const struct alc_pincfg *cfg;
1200 quirk = snd_pci_quirk_lookup(codec->bus->pci, quirk);
1204 cfg = pinfix[quirk->value];
1205 for (; cfg->nid; cfg++)
1206 snd_hda_codec_set_pincfg(codec, cfg->nid, cfg->val);
1216 static struct hda_verb alc888_4ST_ch2_intel_init[] = {
1217 /* Mic-in jack as mic in */
1218 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1219 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1220 /* Line-in jack as Line in */
1221 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1222 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1223 /* Line-Out as Front */
1224 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
1231 static struct hda_verb alc888_4ST_ch4_intel_init[] = {
1232 /* Mic-in jack as mic in */
1233 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1234 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1235 /* Line-in jack as Surround */
1236 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1237 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1238 /* Line-Out as Front */
1239 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
1246 static struct hda_verb alc888_4ST_ch6_intel_init[] = {
1247 /* Mic-in jack as CLFE */
1248 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1249 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1250 /* Line-in jack as Surround */
1251 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1252 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1253 /* Line-Out as CLFE (workaround because Mic-in is not loud enough) */
1254 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1261 static struct hda_verb alc888_4ST_ch8_intel_init[] = {
1262 /* Mic-in jack as CLFE */
1263 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1264 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1265 /* Line-in jack as Surround */
1266 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1267 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1268 /* Line-Out as Side */
1269 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1273 static struct hda_channel_mode alc888_4ST_8ch_intel_modes[4] = {
1274 { 2, alc888_4ST_ch2_intel_init },
1275 { 4, alc888_4ST_ch4_intel_init },
1276 { 6, alc888_4ST_ch6_intel_init },
1277 { 8, alc888_4ST_ch8_intel_init },
1281 * ALC888 Fujitsu Siemens Amillo xa3530
1284 static struct hda_verb alc888_fujitsu_xa3530_verbs[] = {
1285 /* Front Mic: set to PIN_IN (empty by default) */
1286 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1287 /* Connect Internal HP to Front */
1288 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1289 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1290 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1291 /* Connect Bass HP to Front */
1292 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1293 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1294 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1295 /* Connect Line-Out side jack (SPDIF) to Side */
1296 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1297 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1298 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1299 /* Connect Mic jack to CLFE */
1300 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1301 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1302 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02},
1303 /* Connect Line-in jack to Surround */
1304 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1305 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1306 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
1307 /* Connect HP out jack to Front */
1308 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1309 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1310 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
1311 /* Enable unsolicited event for HP jack and Line-out jack */
1312 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1313 {0x17, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1317 static void alc888_fujitsu_xa3530_automute(struct hda_codec *codec)
1319 unsigned int present;
1321 /* Line out presence */
1322 present = snd_hda_codec_read(codec, 0x17, 0,
1323 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1324 /* HP out presence */
1325 present = present || snd_hda_codec_read(codec, 0x1b, 0,
1326 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1327 bits = present ? HDA_AMP_MUTE : 0;
1328 /* Toggle internal speakers muting */
1329 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
1330 HDA_AMP_MUTE, bits);
1331 /* Toggle internal bass muting */
1332 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
1333 HDA_AMP_MUTE, bits);
1336 static void alc888_fujitsu_xa3530_unsol_event(struct hda_codec *codec,
1339 if (res >> 26 == ALC880_HP_EVENT)
1340 alc888_fujitsu_xa3530_automute(codec);
1345 * ALC888 Acer Aspire 4930G model
1348 static struct hda_verb alc888_acer_aspire_4930g_verbs[] = {
1349 /* Front Mic: set to PIN_IN (empty by default) */
1350 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1351 /* Unselect Front Mic by default in input mixer 3 */
1352 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
1353 /* Enable unsolicited event for HP jack */
1354 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1355 /* Connect Internal HP to front */
1356 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1357 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1358 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1359 /* Connect HP out to front */
1360 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1361 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1362 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1366 static struct hda_input_mux alc888_2_capture_sources[2] = {
1367 /* Front mic only available on one ADC */
1374 { "Front Mic", 0xb },
1387 static struct snd_kcontrol_new alc888_base_mixer[] = {
1388 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1389 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1390 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1391 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
1392 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
1394 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1395 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1396 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1397 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
1398 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
1399 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1400 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1401 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1402 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1403 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1404 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
1405 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1409 static void alc888_acer_aspire_4930g_automute(struct hda_codec *codec)
1411 unsigned int present;
1413 present = snd_hda_codec_read(codec, 0x15, 0,
1414 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1415 bits = present ? HDA_AMP_MUTE : 0;
1416 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
1417 HDA_AMP_MUTE, bits);
1420 static void alc888_acer_aspire_4930g_unsol_event(struct hda_codec *codec,
1423 if (res >> 26 == ALC880_HP_EVENT)
1424 alc888_acer_aspire_4930g_automute(codec);
1428 * ALC880 3-stack model
1430 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
1431 * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18,
1432 * F-Mic = 0x1b, HP = 0x19
1435 static hda_nid_t alc880_dac_nids[4] = {
1436 /* front, rear, clfe, rear_surr */
1437 0x02, 0x05, 0x04, 0x03
1440 static hda_nid_t alc880_adc_nids[3] = {
1445 /* The datasheet says the node 0x07 is connected from inputs,
1446 * but it shows zero connection in the real implementation on some devices.
1447 * Note: this is a 915GAV bug, fixed on 915GLV
1449 static hda_nid_t alc880_adc_nids_alt[2] = {
1454 #define ALC880_DIGOUT_NID 0x06
1455 #define ALC880_DIGIN_NID 0x0a
1457 static struct hda_input_mux alc880_capture_source = {
1461 { "Front Mic", 0x3 },
1467 /* channel source setting (2/6 channel selection for 3-stack) */
1469 static struct hda_verb alc880_threestack_ch2_init[] = {
1470 /* set line-in to input, mute it */
1471 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1472 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1473 /* set mic-in to input vref 80%, mute it */
1474 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1475 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1480 static struct hda_verb alc880_threestack_ch6_init[] = {
1481 /* set line-in to output, unmute it */
1482 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1483 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1484 /* set mic-in to output, unmute it */
1485 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1486 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1490 static struct hda_channel_mode alc880_threestack_modes[2] = {
1491 { 2, alc880_threestack_ch2_init },
1492 { 6, alc880_threestack_ch6_init },
1495 static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
1496 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1497 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1498 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
1499 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
1500 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1501 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1502 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1503 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1504 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1505 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1506 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1507 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1508 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1509 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1510 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
1511 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
1512 HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
1514 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1515 .name = "Channel Mode",
1516 .info = alc_ch_mode_info,
1517 .get = alc_ch_mode_get,
1518 .put = alc_ch_mode_put,
1523 /* capture mixer elements */
1524 static int alc_cap_vol_info(struct snd_kcontrol *kcontrol,
1525 struct snd_ctl_elem_info *uinfo)
1527 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1528 struct alc_spec *spec = codec->spec;
1531 mutex_lock(&codec->control_mutex);
1532 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0,
1534 err = snd_hda_mixer_amp_volume_info(kcontrol, uinfo);
1535 mutex_unlock(&codec->control_mutex);
1539 static int alc_cap_vol_tlv(struct snd_kcontrol *kcontrol, int op_flag,
1540 unsigned int size, unsigned int __user *tlv)
1542 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1543 struct alc_spec *spec = codec->spec;
1546 mutex_lock(&codec->control_mutex);
1547 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0,
1549 err = snd_hda_mixer_amp_tlv(kcontrol, op_flag, size, tlv);
1550 mutex_unlock(&codec->control_mutex);
1554 typedef int (*getput_call_t)(struct snd_kcontrol *kcontrol,
1555 struct snd_ctl_elem_value *ucontrol);
1557 static int alc_cap_getput_caller(struct snd_kcontrol *kcontrol,
1558 struct snd_ctl_elem_value *ucontrol,
1561 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1562 struct alc_spec *spec = codec->spec;
1563 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
1566 mutex_lock(&codec->control_mutex);
1567 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[adc_idx],
1569 err = func(kcontrol, ucontrol);
1570 mutex_unlock(&codec->control_mutex);
1574 static int alc_cap_vol_get(struct snd_kcontrol *kcontrol,
1575 struct snd_ctl_elem_value *ucontrol)
1577 return alc_cap_getput_caller(kcontrol, ucontrol,
1578 snd_hda_mixer_amp_volume_get);
1581 static int alc_cap_vol_put(struct snd_kcontrol *kcontrol,
1582 struct snd_ctl_elem_value *ucontrol)
1584 return alc_cap_getput_caller(kcontrol, ucontrol,
1585 snd_hda_mixer_amp_volume_put);
1588 /* capture mixer elements */
1589 #define alc_cap_sw_info snd_ctl_boolean_stereo_info
1591 static int alc_cap_sw_get(struct snd_kcontrol *kcontrol,
1592 struct snd_ctl_elem_value *ucontrol)
1594 return alc_cap_getput_caller(kcontrol, ucontrol,
1595 snd_hda_mixer_amp_switch_get);
1598 static int alc_cap_sw_put(struct snd_kcontrol *kcontrol,
1599 struct snd_ctl_elem_value *ucontrol)
1601 return alc_cap_getput_caller(kcontrol, ucontrol,
1602 snd_hda_mixer_amp_switch_put);
1605 #define _DEFINE_CAPMIX(num) \
1607 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1608 .name = "Capture Switch", \
1609 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, \
1611 .info = alc_cap_sw_info, \
1612 .get = alc_cap_sw_get, \
1613 .put = alc_cap_sw_put, \
1616 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1617 .name = "Capture Volume", \
1618 .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE | \
1619 SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
1620 SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK), \
1622 .info = alc_cap_vol_info, \
1623 .get = alc_cap_vol_get, \
1624 .put = alc_cap_vol_put, \
1625 .tlv = { .c = alc_cap_vol_tlv }, \
1628 #define _DEFINE_CAPSRC(num) \
1630 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1631 /* .name = "Capture Source", */ \
1632 .name = "Input Source", \
1634 .info = alc_mux_enum_info, \
1635 .get = alc_mux_enum_get, \
1636 .put = alc_mux_enum_put, \
1639 #define DEFINE_CAPMIX(num) \
1640 static struct snd_kcontrol_new alc_capture_mixer ## num[] = { \
1641 _DEFINE_CAPMIX(num), \
1642 _DEFINE_CAPSRC(num), \
1646 #define DEFINE_CAPMIX_NOSRC(num) \
1647 static struct snd_kcontrol_new alc_capture_mixer_nosrc ## num[] = { \
1648 _DEFINE_CAPMIX(num), \
1652 /* up to three ADCs */
1656 DEFINE_CAPMIX_NOSRC(1);
1657 DEFINE_CAPMIX_NOSRC(2);
1658 DEFINE_CAPMIX_NOSRC(3);
1661 * ALC880 5-stack model
1663 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d),
1665 * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
1666 * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
1669 /* additional mixers to alc880_three_stack_mixer */
1670 static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
1671 HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1672 HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
1676 /* channel source setting (6/8 channel selection for 5-stack) */
1678 static struct hda_verb alc880_fivestack_ch6_init[] = {
1679 /* set line-in to input, mute it */
1680 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1681 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1686 static struct hda_verb alc880_fivestack_ch8_init[] = {
1687 /* set line-in to output, unmute it */
1688 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1689 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1693 static struct hda_channel_mode alc880_fivestack_modes[2] = {
1694 { 6, alc880_fivestack_ch6_init },
1695 { 8, alc880_fivestack_ch8_init },
1700 * ALC880 6-stack model
1702 * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e),
1703 * Side = 0x05 (0x0f)
1704 * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
1705 * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
1708 static hda_nid_t alc880_6st_dac_nids[4] = {
1709 /* front, rear, clfe, rear_surr */
1710 0x02, 0x03, 0x04, 0x05
1713 static struct hda_input_mux alc880_6stack_capture_source = {
1717 { "Front Mic", 0x1 },
1723 /* fixed 8-channels */
1724 static struct hda_channel_mode alc880_sixstack_modes[1] = {
1728 static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
1729 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1730 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1731 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1732 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
1733 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1734 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1735 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1736 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1737 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
1738 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
1739 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1740 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1741 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1742 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1743 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1744 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1745 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1746 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1748 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1749 .name = "Channel Mode",
1750 .info = alc_ch_mode_info,
1751 .get = alc_ch_mode_get,
1752 .put = alc_ch_mode_put,
1761 * W810 has rear IO for:
1764 * Center/LFE (DAC 04)
1767 * The system also has a pair of internal speakers, and a headphone jack.
1768 * These are both connected to Line2 on the codec, hence to DAC 02.
1770 * There is a variable resistor to control the speaker or headphone
1771 * volume. This is a hardware-only device without a software API.
1773 * Plugging headphones in will disable the internal speakers. This is
1774 * implemented in hardware, not via the driver using jack sense. In
1775 * a similar fashion, plugging into the rear socket marked "front" will
1776 * disable both the speakers and headphones.
1778 * For input, there's a microphone jack, and an "audio in" jack.
1779 * These may not do anything useful with this driver yet, because I
1780 * haven't setup any initialization verbs for these yet...
1783 static hda_nid_t alc880_w810_dac_nids[3] = {
1784 /* front, rear/surround, clfe */
1788 /* fixed 6 channels */
1789 static struct hda_channel_mode alc880_w810_modes[1] = {
1793 /* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
1794 static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
1795 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1796 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1797 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1798 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
1799 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1800 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1801 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1802 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1803 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
1811 * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
1812 * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?),
1816 static hda_nid_t alc880_z71v_dac_nids[1] = {
1819 #define ALC880_Z71V_HP_DAC 0x03
1821 /* fixed 2 channels */
1822 static struct hda_channel_mode alc880_2_jack_modes[1] = {
1826 static struct snd_kcontrol_new alc880_z71v_mixer[] = {
1827 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1828 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1829 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1830 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
1831 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1832 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1833 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1834 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1840 * ALC880 F1734 model
1842 * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
1843 * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
1846 static hda_nid_t alc880_f1734_dac_nids[1] = {
1849 #define ALC880_F1734_HP_DAC 0x02
1851 static struct snd_kcontrol_new alc880_f1734_mixer[] = {
1852 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1853 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
1854 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1855 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
1856 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1857 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1858 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1859 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1863 static struct hda_input_mux alc880_f1734_capture_source = {
1875 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
1876 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
1877 * Mic = 0x18, Line = 0x1a
1880 #define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
1881 #define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
1883 static struct snd_kcontrol_new alc880_asus_mixer[] = {
1884 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1885 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1886 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1887 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
1888 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1889 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1890 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1891 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1892 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1893 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1894 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1895 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1896 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1897 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1899 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1900 .name = "Channel Mode",
1901 .info = alc_ch_mode_info,
1902 .get = alc_ch_mode_get,
1903 .put = alc_ch_mode_put,
1909 * ALC880 ASUS W1V model
1911 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
1912 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
1913 * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
1916 /* additional mixers to alc880_asus_mixer */
1917 static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
1918 HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
1919 HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
1924 static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
1925 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1926 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
1927 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
1928 HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
1929 HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
1930 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
1931 HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
1932 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
1933 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
1938 static struct snd_kcontrol_new alc880_uniwill_mixer[] = {
1939 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1940 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
1941 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1942 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
1943 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1944 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1945 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1946 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1947 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1948 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1949 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1950 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1951 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1952 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1953 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1954 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1956 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1957 .name = "Channel Mode",
1958 .info = alc_ch_mode_info,
1959 .get = alc_ch_mode_get,
1960 .put = alc_ch_mode_put,
1965 static struct snd_kcontrol_new alc880_fujitsu_mixer[] = {
1966 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1967 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
1968 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1969 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
1970 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1971 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1972 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1973 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1974 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1975 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1979 static struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = {
1980 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1981 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
1982 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1983 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
1984 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1985 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1990 * virtual master controls
1994 * slave controls for virtual master
1996 static const char *alc_slave_vols[] = {
1997 "Front Playback Volume",
1998 "Surround Playback Volume",
1999 "Center Playback Volume",
2000 "LFE Playback Volume",
2001 "Side Playback Volume",
2002 "Headphone Playback Volume",
2003 "Speaker Playback Volume",
2004 "Mono Playback Volume",
2005 "Line-Out Playback Volume",
2006 "PCM Playback Volume",
2010 static const char *alc_slave_sws[] = {
2011 "Front Playback Switch",
2012 "Surround Playback Switch",
2013 "Center Playback Switch",
2014 "LFE Playback Switch",
2015 "Side Playback Switch",
2016 "Headphone Playback Switch",
2017 "Speaker Playback Switch",
2018 "Mono Playback Switch",
2019 "IEC958 Playback Switch",
2024 * build control elements
2027 static void alc_free_kctls(struct hda_codec *codec);
2029 /* additional beep mixers; the actual parameters are overwritten at build */
2030 static struct snd_kcontrol_new alc_beep_mixer[] = {
2031 HDA_CODEC_VOLUME("Beep Playback Volume", 0, 0, HDA_INPUT),
2032 HDA_CODEC_MUTE("Beep Playback Switch", 0, 0, HDA_INPUT),
2036 static int alc_build_controls(struct hda_codec *codec)
2038 struct alc_spec *spec = codec->spec;
2042 for (i = 0; i < spec->num_mixers; i++) {
2043 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
2047 if (spec->cap_mixer) {
2048 err = snd_hda_add_new_ctls(codec, spec->cap_mixer);
2052 if (spec->multiout.dig_out_nid) {
2053 err = snd_hda_create_spdif_out_ctls(codec,
2054 spec->multiout.dig_out_nid);
2057 if (!spec->no_analog) {
2058 err = snd_hda_create_spdif_share_sw(codec,
2062 spec->multiout.share_spdif = 1;
2065 if (spec->dig_in_nid) {
2066 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
2071 /* create beep controls if needed */
2072 if (spec->beep_amp) {
2073 struct snd_kcontrol_new *knew;
2074 for (knew = alc_beep_mixer; knew->name; knew++) {
2075 struct snd_kcontrol *kctl;
2076 kctl = snd_ctl_new1(knew, codec);
2079 kctl->private_value = spec->beep_amp;
2080 err = snd_hda_ctl_add(codec, kctl);
2086 /* if we have no master control, let's create it */
2087 if (!spec->no_analog &&
2088 !snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
2089 unsigned int vmaster_tlv[4];
2090 snd_hda_set_vmaster_tlv(codec, spec->vmaster_nid,
2091 HDA_OUTPUT, vmaster_tlv);
2092 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
2093 vmaster_tlv, alc_slave_vols);
2097 if (!spec->no_analog &&
2098 !snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
2099 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
2100 NULL, alc_slave_sws);
2105 alc_free_kctls(codec); /* no longer needed */
2111 * initialize the codec volumes, etc
2115 * generic initialization of ADC, input mixers and output mixers
2117 static struct hda_verb alc880_volume_init_verbs[] = {
2119 * Unmute ADC0-2 and set the default input to mic-in
2121 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
2122 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2123 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
2124 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2125 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
2126 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2128 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
2130 * Note: PASD motherboards uses the Line In 2 as the input for front
2133 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
2134 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2135 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2136 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
2137 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
2138 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
2139 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
2140 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
2143 * Set up output mixers (0x0c - 0x0f)
2145 /* set vol=0 to output mixers */
2146 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2147 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2148 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2149 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2150 /* set up input amps for analog loopback */
2151 /* Amp Indices: DAC = 0, mixer = 1 */
2152 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2153 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2154 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2155 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2156 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2157 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2158 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2159 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2165 * 3-stack pin configuration:
2166 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
2168 static struct hda_verb alc880_pin_3stack_init_verbs[] = {
2170 * preset connection lists of input pins
2171 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
2173 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
2174 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2175 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
2178 * Set pin mode and muting
2180 /* set front pin widgets 0x14 for output */
2181 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2182 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2183 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2184 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2185 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2186 /* Mic2 (as headphone out) for HP output */
2187 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2188 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2189 /* Line In pin widget for input */
2190 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2191 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2192 /* Line2 (as front mic) pin widget for input and vref at 80% */
2193 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2194 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2195 /* CD pin widget for input */
2196 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2202 * 5-stack pin configuration:
2203 * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
2204 * line-in/side = 0x1a, f-mic = 0x1b
2206 static struct hda_verb alc880_pin_5stack_init_verbs[] = {
2208 * preset connection lists of input pins
2209 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
2211 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2212 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
2215 * Set pin mode and muting
2217 /* set pin widgets 0x14-0x17 for output */
2218 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2219 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2220 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2221 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2222 /* unmute pins for output (no gain on this amp) */
2223 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2224 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2225 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2226 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2228 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2229 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2230 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2231 /* Mic2 (as headphone out) for HP output */
2232 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2233 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2234 /* Line In pin widget for input */
2235 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2236 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2237 /* Line2 (as front mic) pin widget for input and vref at 80% */
2238 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2239 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2240 /* CD pin widget for input */
2241 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2247 * W810 pin configuration:
2248 * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
2250 static struct hda_verb alc880_pin_w810_init_verbs[] = {
2251 /* hphone/speaker input selector: front DAC */
2252 {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
2254 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2255 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2256 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2257 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2258 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2259 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2261 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2262 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2268 * Z71V pin configuration:
2269 * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
2271 static struct hda_verb alc880_pin_z71v_init_verbs[] = {
2272 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2273 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2274 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2275 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2277 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2278 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2279 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2280 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2286 * 6-stack pin configuration:
2287 * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18,
2288 * f-mic = 0x19, line = 0x1a, HP = 0x1b
2290 static struct hda_verb alc880_pin_6stack_init_verbs[] = {
2291 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2293 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2294 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2295 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2296 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2297 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2298 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2299 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2300 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2302 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2303 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2304 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2305 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2306 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2307 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2308 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2309 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2310 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2316 * Uniwill pin configuration:
2317 * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19,
2320 static struct hda_verb alc880_uniwill_init_verbs[] = {
2321 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2323 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2324 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2325 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2326 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2327 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2328 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2329 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2330 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2331 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2332 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2333 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2334 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2335 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2336 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2338 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2339 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2340 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2341 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2342 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2343 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2344 /* {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, */
2345 /* {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
2346 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2348 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
2349 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
2356 * HP = 0x14, InternalSpeaker = 0x15, mic = 0x19,
2358 static struct hda_verb alc880_uniwill_p53_init_verbs[] = {
2359 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2361 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2362 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2363 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2364 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2365 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2366 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2367 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2368 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2369 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2370 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2371 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2372 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2374 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2375 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2376 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2377 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2378 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2379 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2381 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
2382 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_DCVOL_EVENT},
2387 static struct hda_verb alc880_beep_init_verbs[] = {
2388 { 0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5) },
2392 /* toggle speaker-output according to the hp-jack state */
2393 static void alc880_uniwill_hp_automute(struct hda_codec *codec)
2395 unsigned int present;
2398 present = snd_hda_codec_read(codec, 0x14, 0,
2399 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
2400 bits = present ? HDA_AMP_MUTE : 0;
2401 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
2402 HDA_AMP_MUTE, bits);
2403 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
2404 HDA_AMP_MUTE, bits);
2407 /* auto-toggle front mic */
2408 static void alc880_uniwill_mic_automute(struct hda_codec *codec)
2410 unsigned int present;
2413 present = snd_hda_codec_read(codec, 0x18, 0,
2414 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
2415 bits = present ? HDA_AMP_MUTE : 0;
2416 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
2419 static void alc880_uniwill_automute(struct hda_codec *codec)
2421 alc880_uniwill_hp_automute(codec);
2422 alc880_uniwill_mic_automute(codec);
2425 static void alc880_uniwill_unsol_event(struct hda_codec *codec,
2428 /* Looks like the unsol event is incompatible with the standard
2429 * definition. 4bit tag is placed at 28 bit!
2431 switch (res >> 28) {
2432 case ALC880_HP_EVENT:
2433 alc880_uniwill_hp_automute(codec);
2435 case ALC880_MIC_EVENT:
2436 alc880_uniwill_mic_automute(codec);
2441 static void alc880_uniwill_p53_hp_automute(struct hda_codec *codec)
2443 unsigned int present;
2446 present = snd_hda_codec_read(codec, 0x14, 0,
2447 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
2448 bits = present ? HDA_AMP_MUTE : 0;
2449 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, HDA_AMP_MUTE, bits);
2452 static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec)
2454 unsigned int present;
2456 present = snd_hda_codec_read(codec, 0x21, 0,
2457 AC_VERB_GET_VOLUME_KNOB_CONTROL, 0);
2458 present &= HDA_AMP_VOLMASK;
2459 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0,
2460 HDA_AMP_VOLMASK, present);
2461 snd_hda_codec_amp_stereo(codec, 0x0d, HDA_OUTPUT, 0,
2462 HDA_AMP_VOLMASK, present);
2465 static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec,
2468 /* Looks like the unsol event is incompatible with the standard
2469 * definition. 4bit tag is placed at 28 bit!
2471 if ((res >> 28) == ALC880_HP_EVENT)
2472 alc880_uniwill_p53_hp_automute(codec);
2473 if ((res >> 28) == ALC880_DCVOL_EVENT)
2474 alc880_uniwill_p53_dcvol_automute(codec);
2478 * F1734 pin configuration:
2479 * HP = 0x14, speaker-out = 0x15, mic = 0x18
2481 static struct hda_verb alc880_pin_f1734_init_verbs[] = {
2482 {0x07, AC_VERB_SET_CONNECT_SEL, 0x01},
2483 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
2484 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
2485 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
2486 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
2488 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2489 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2490 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2491 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2493 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2494 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2495 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
2496 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2497 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2498 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2499 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2500 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2501 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2503 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
2504 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_DCVOL_EVENT},
2510 * ASUS pin configuration:
2511 * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
2513 static struct hda_verb alc880_pin_asus_init_verbs[] = {
2514 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
2515 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
2516 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
2517 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
2519 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2520 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2521 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2522 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2523 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2524 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2525 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2526 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2528 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2529 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2530 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2531 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2532 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2533 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2534 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2535 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2536 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2541 /* Enable GPIO mask and set output */
2542 #define alc880_gpio1_init_verbs alc_gpio1_init_verbs
2543 #define alc880_gpio2_init_verbs alc_gpio2_init_verbs
2545 /* Clevo m520g init */
2546 static struct hda_verb alc880_pin_clevo_init_verbs[] = {
2547 /* headphone output */
2548 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
2550 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2551 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2553 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2554 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2556 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2557 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2558 /* Mic1 (rear panel) */
2559 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2560 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2561 /* Mic2 (front panel) */
2562 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2563 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2565 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2566 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2567 /* change to EAPD mode */
2568 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2569 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
2574 static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
2575 /* change to EAPD mode */
2576 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2577 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
2579 /* Headphone output */
2580 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2582 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2583 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
2585 /* Line In pin widget for input */
2586 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2587 /* CD pin widget for input */
2588 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2589 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2590 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2592 /* change to EAPD mode */
2593 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2594 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
2600 * LG m1 express dual
2603 * Rear Line-In/Out (blue): 0x14
2604 * Build-in Mic-In: 0x15
2606 * HP-Out (green): 0x1b
2607 * Mic-In/Out (red): 0x19
2611 /* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
2612 static hda_nid_t alc880_lg_dac_nids[3] = {
2616 /* seems analog CD is not working */
2617 static struct hda_input_mux alc880_lg_capture_source = {
2622 { "Internal Mic", 0x6 },
2626 /* 2,4,6 channel modes */
2627 static struct hda_verb alc880_lg_ch2_init[] = {
2628 /* set line-in and mic-in to input */
2629 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
2630 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
2634 static struct hda_verb alc880_lg_ch4_init[] = {
2635 /* set line-in to out and mic-in to input */
2636 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
2637 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
2641 static struct hda_verb alc880_lg_ch6_init[] = {
2642 /* set line-in and mic-in to output */
2643 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
2644 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
2648 static struct hda_channel_mode alc880_lg_ch_modes[3] = {
2649 { 2, alc880_lg_ch2_init },
2650 { 4, alc880_lg_ch4_init },
2651 { 6, alc880_lg_ch6_init },
2654 static struct snd_kcontrol_new alc880_lg_mixer[] = {
2655 HDA_CODEC_VOLUME("Front Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
2656 HDA_BIND_MUTE("Front Playback Switch", 0x0f, 2, HDA_INPUT),
2657 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2658 HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
2659 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
2660 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
2661 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
2662 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
2663 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2664 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
2665 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
2666 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
2667 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
2668 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
2670 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2671 .name = "Channel Mode",
2672 .info = alc_ch_mode_info,
2673 .get = alc_ch_mode_get,
2674 .put = alc_ch_mode_put,
2679 static struct hda_verb alc880_lg_init_verbs[] = {
2680 /* set capture source to mic-in */
2681 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2682 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2683 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2684 /* mute all amp mixer inputs */
2685 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
2686 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
2687 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
2688 /* line-in to input */
2689 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2690 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2692 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2693 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2695 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2696 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2697 /* mic-in to input */
2698 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
2699 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2700 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2702 {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
2703 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2704 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2706 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
2710 /* toggle speaker-output according to the hp-jack state */
2711 static void alc880_lg_automute(struct hda_codec *codec)
2713 unsigned int present;
2716 present = snd_hda_codec_read(codec, 0x1b, 0,
2717 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
2718 bits = present ? HDA_AMP_MUTE : 0;
2719 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
2720 HDA_AMP_MUTE, bits);
2723 static void alc880_lg_unsol_event(struct hda_codec *codec, unsigned int res)
2725 /* Looks like the unsol event is incompatible with the standard
2726 * definition. 4bit tag is placed at 28 bit!
2728 if ((res >> 28) == 0x01)
2729 alc880_lg_automute(codec);
2738 * Built-in Mic-In: 0x19
2744 static struct hda_input_mux alc880_lg_lw_capture_source = {
2748 { "Internal Mic", 0x1 },
2753 #define alc880_lg_lw_modes alc880_threestack_modes
2755 static struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
2756 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2757 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2758 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
2759 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
2760 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2761 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2762 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2763 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2764 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2765 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2766 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2767 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2768 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
2769 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
2771 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2772 .name = "Channel Mode",
2773 .info = alc_ch_mode_info,
2774 .get = alc_ch_mode_get,
2775 .put = alc_ch_mode_put,
2780 static struct hda_verb alc880_lg_lw_init_verbs[] = {
2781 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2782 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
2783 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
2785 /* set capture source to mic-in */
2786 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2787 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2788 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2789 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
2791 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2792 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2794 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2795 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2796 /* mic-in to input */
2797 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2798 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2800 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2801 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2803 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
2807 /* toggle speaker-output according to the hp-jack state */
2808 static void alc880_lg_lw_automute(struct hda_codec *codec)
2810 unsigned int present;
2813 present = snd_hda_codec_read(codec, 0x1b, 0,
2814 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
2815 bits = present ? HDA_AMP_MUTE : 0;
2816 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
2817 HDA_AMP_MUTE, bits);
2820 static void alc880_lg_lw_unsol_event(struct hda_codec *codec, unsigned int res)
2822 /* Looks like the unsol event is incompatible with the standard
2823 * definition. 4bit tag is placed at 28 bit!
2825 if ((res >> 28) == 0x01)
2826 alc880_lg_lw_automute(codec);
2829 static struct snd_kcontrol_new alc880_medion_rim_mixer[] = {
2830 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2831 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
2832 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2833 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2834 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2835 HDA_CODEC_MUTE("Internal Playback Switch", 0x0b, 0x1, HDA_INPUT),
2839 static struct hda_input_mux alc880_medion_rim_capture_source = {
2843 { "Internal Mic", 0x1 },
2847 static struct hda_verb alc880_medion_rim_init_verbs[] = {
2848 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2850 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2851 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2853 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2854 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2855 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2856 /* Mic2 (as headphone out) for HP output */
2857 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2858 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2859 /* Internal Speaker */
2860 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2861 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2863 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2864 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
2866 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
2870 /* toggle speaker-output according to the hp-jack state */
2871 static void alc880_medion_rim_automute(struct hda_codec *codec)
2873 unsigned int present;
2876 present = snd_hda_codec_read(codec, 0x14, 0,
2877 AC_VERB_GET_PIN_SENSE, 0)
2878 & AC_PINSENSE_PRESENCE;
2879 bits = present ? HDA_AMP_MUTE : 0;
2880 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
2881 HDA_AMP_MUTE, bits);
2883 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 0);
2885 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 2);
2888 static void alc880_medion_rim_unsol_event(struct hda_codec *codec,
2891 /* Looks like the unsol event is incompatible with the standard
2892 * definition. 4bit tag is placed at 28 bit!
2894 if ((res >> 28) == ALC880_HP_EVENT)
2895 alc880_medion_rim_automute(codec);
2898 #ifdef CONFIG_SND_HDA_POWER_SAVE
2899 static struct hda_amp_list alc880_loopbacks[] = {
2900 { 0x0b, HDA_INPUT, 0 },
2901 { 0x0b, HDA_INPUT, 1 },
2902 { 0x0b, HDA_INPUT, 2 },
2903 { 0x0b, HDA_INPUT, 3 },
2904 { 0x0b, HDA_INPUT, 4 },
2908 static struct hda_amp_list alc880_lg_loopbacks[] = {
2909 { 0x0b, HDA_INPUT, 1 },
2910 { 0x0b, HDA_INPUT, 6 },
2911 { 0x0b, HDA_INPUT, 7 },
2920 static int alc_init(struct hda_codec *codec)
2922 struct alc_spec *spec = codec->spec;
2926 if (codec->vendor_id == 0x10ec0888)
2927 alc888_coef_init(codec);
2929 for (i = 0; i < spec->num_init_verbs; i++)
2930 snd_hda_sequence_write(codec, spec->init_verbs[i]);
2932 if (spec->init_hook)
2933 spec->init_hook(codec);
2938 static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
2940 struct alc_spec *spec = codec->spec;
2942 if (spec->unsol_event)
2943 spec->unsol_event(codec, res);
2946 #ifdef CONFIG_SND_HDA_POWER_SAVE
2947 static int alc_check_power_status(struct hda_codec *codec, hda_nid_t nid)
2949 struct alc_spec *spec = codec->spec;
2950 return snd_hda_check_amp_list_power(codec, &spec->loopback, nid);
2955 * Analog playback callbacks
2957 static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
2958 struct hda_codec *codec,
2959 struct snd_pcm_substream *substream)
2961 struct alc_spec *spec = codec->spec;
2962 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
2966 static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2967 struct hda_codec *codec,
2968 unsigned int stream_tag,
2969 unsigned int format,
2970 struct snd_pcm_substream *substream)
2972 struct alc_spec *spec = codec->spec;
2973 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
2974 stream_tag, format, substream);
2977 static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
2978 struct hda_codec *codec,
2979 struct snd_pcm_substream *substream)
2981 struct alc_spec *spec = codec->spec;
2982 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
2988 static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
2989 struct hda_codec *codec,
2990 struct snd_pcm_substream *substream)
2992 struct alc_spec *spec = codec->spec;
2993 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
2996 static int alc880_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2997 struct hda_codec *codec,
2998 unsigned int stream_tag,
2999 unsigned int format,
3000 struct snd_pcm_substream *substream)
3002 struct alc_spec *spec = codec->spec;
3003 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
3004 stream_tag, format, substream);
3007 static int alc880_dig_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
3008 struct hda_codec *codec,
3009 struct snd_pcm_substream *substream)
3011 struct alc_spec *spec = codec->spec;
3012 return snd_hda_multi_out_dig_cleanup(codec, &spec->multiout);
3015 static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
3016 struct hda_codec *codec,
3017 struct snd_pcm_substream *substream)
3019 struct alc_spec *spec = codec->spec;
3020 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
3026 static int alc880_alt_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
3027 struct hda_codec *codec,
3028 unsigned int stream_tag,
3029 unsigned int format,
3030 struct snd_pcm_substream *substream)
3032 struct alc_spec *spec = codec->spec;
3034 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number + 1],
3035 stream_tag, 0, format);
3039 static int alc880_alt_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
3040 struct hda_codec *codec,
3041 struct snd_pcm_substream *substream)
3043 struct alc_spec *spec = codec->spec;
3045 snd_hda_codec_cleanup_stream(codec,
3046 spec->adc_nids[substream->number + 1]);
3053 static struct hda_pcm_stream alc880_pcm_analog_playback = {
3057 /* NID is set in alc_build_pcms */
3059 .open = alc880_playback_pcm_open,
3060 .prepare = alc880_playback_pcm_prepare,
3061 .cleanup = alc880_playback_pcm_cleanup
3065 static struct hda_pcm_stream alc880_pcm_analog_capture = {
3069 /* NID is set in alc_build_pcms */
3072 static struct hda_pcm_stream alc880_pcm_analog_alt_playback = {
3076 /* NID is set in alc_build_pcms */
3079 static struct hda_pcm_stream alc880_pcm_analog_alt_capture = {
3080 .substreams = 2, /* can be overridden */
3083 /* NID is set in alc_build_pcms */
3085 .prepare = alc880_alt_capture_pcm_prepare,
3086 .cleanup = alc880_alt_capture_pcm_cleanup
3090 static struct hda_pcm_stream alc880_pcm_digital_playback = {
3094 /* NID is set in alc_build_pcms */
3096 .open = alc880_dig_playback_pcm_open,
3097 .close = alc880_dig_playback_pcm_close,
3098 .prepare = alc880_dig_playback_pcm_prepare,
3099 .cleanup = alc880_dig_playback_pcm_cleanup
3103 static struct hda_pcm_stream alc880_pcm_digital_capture = {
3107 /* NID is set in alc_build_pcms */
3110 /* Used by alc_build_pcms to flag that a PCM has no playback stream */
3111 static struct hda_pcm_stream alc_pcm_null_stream = {
3117 static int alc_build_pcms(struct hda_codec *codec)
3119 struct alc_spec *spec = codec->spec;
3120 struct hda_pcm *info = spec->pcm_rec;
3123 codec->num_pcms = 1;
3124 codec->pcm_info = info;
3126 if (spec->no_analog)
3129 info->name = spec->stream_name_analog;
3130 if (spec->stream_analog_playback) {
3131 if (snd_BUG_ON(!spec->multiout.dac_nids))
3133 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
3134 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
3136 if (spec->stream_analog_capture) {
3137 if (snd_BUG_ON(!spec->adc_nids))
3139 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
3140 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
3143 if (spec->channel_mode) {
3144 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
3145 for (i = 0; i < spec->num_channel_mode; i++) {
3146 if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
3147 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
3153 /* SPDIF for stream index #1 */
3154 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
3155 codec->num_pcms = 2;
3156 codec->slave_dig_outs = spec->multiout.slave_dig_outs;
3157 info = spec->pcm_rec + 1;
3158 info->name = spec->stream_name_digital;
3159 if (spec->dig_out_type)
3160 info->pcm_type = spec->dig_out_type;
3162 info->pcm_type = HDA_PCM_TYPE_SPDIF;
3163 if (spec->multiout.dig_out_nid &&
3164 spec->stream_digital_playback) {
3165 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
3166 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
3168 if (spec->dig_in_nid &&
3169 spec->stream_digital_capture) {
3170 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
3171 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
3173 /* FIXME: do we need this for all Realtek codec models? */
3174 codec->spdif_status_reset = 1;
3177 if (spec->no_analog)
3180 /* If the use of more than one ADC is requested for the current
3181 * model, configure a second analog capture-only PCM.
3183 /* Additional Analaog capture for index #2 */
3184 if ((spec->alt_dac_nid && spec->stream_analog_alt_playback) ||
3185 (spec->num_adc_nids > 1 && spec->stream_analog_alt_capture)) {
3186 codec->num_pcms = 3;
3187 info = spec->pcm_rec + 2;
3188 info->name = spec->stream_name_analog;
3189 if (spec->alt_dac_nid) {
3190 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
3191 *spec->stream_analog_alt_playback;
3192 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
3195 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
3196 alc_pcm_null_stream;
3197 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
3199 if (spec->num_adc_nids > 1) {
3200 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
3201 *spec->stream_analog_alt_capture;
3202 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid =
3204 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams =
3205 spec->num_adc_nids - 1;
3207 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
3208 alc_pcm_null_stream;
3209 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = 0;
3216 static void alc_free_kctls(struct hda_codec *codec)
3218 struct alc_spec *spec = codec->spec;
3220 if (spec->kctls.list) {
3221 struct snd_kcontrol_new *kctl = spec->kctls.list;
3223 for (i = 0; i < spec->kctls.used; i++)
3224 kfree(kctl[i].name);
3226 snd_array_free(&spec->kctls);
3229 static void alc_free(struct hda_codec *codec)
3231 struct alc_spec *spec = codec->spec;
3236 alc_free_kctls(codec);
3238 snd_hda_detach_beep_device(codec);
3241 #ifdef SND_HDA_NEEDS_RESUME
3242 static int alc_resume(struct hda_codec *codec)
3244 codec->patch_ops.init(codec);
3245 snd_hda_codec_resume_amp(codec);
3246 snd_hda_codec_resume_cache(codec);
3253 static struct hda_codec_ops alc_patch_ops = {
3254 .build_controls = alc_build_controls,
3255 .build_pcms = alc_build_pcms,
3258 .unsol_event = alc_unsol_event,
3259 #ifdef SND_HDA_NEEDS_RESUME
3260 .resume = alc_resume,
3262 #ifdef CONFIG_SND_HDA_POWER_SAVE
3263 .check_power_status = alc_check_power_status,
3269 * Test configuration for debugging
3271 * Almost all inputs/outputs are enabled. I/O pins can be configured via
3274 #ifdef CONFIG_SND_DEBUG
3275 static hda_nid_t alc880_test_dac_nids[4] = {
3276 0x02, 0x03, 0x04, 0x05
3279 static struct hda_input_mux alc880_test_capture_source = {
3288 { "Surround", 0x6 },
3292 static struct hda_channel_mode alc880_test_modes[4] = {