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,
218 ALC883_TARGA_2ch_DIG,
221 ALC888_ACER_ASPIRE_4930G,
225 ALC883_LENOVO_101E_2ch,
226 ALC883_LENOVO_NB0763,
227 ALC888_LENOVO_MS7195_DIG,
234 ALC883_FUJITSU_PI2515,
235 ALC888_FUJITSU_XA3530,
236 ALC883_3ST_6ch_INTEL,
244 /* styles of capture selection */
246 CAPT_MUX = 0, /* only mux based */
247 CAPT_MIX, /* only mixer based */
248 CAPT_1MUX_MIX, /* first mux and other mixers */
252 #define GPIO_MASK 0x03
255 /* codec parameterization */
256 struct snd_kcontrol_new *mixers[5]; /* mixer arrays */
257 unsigned int num_mixers;
258 struct snd_kcontrol_new *cap_mixer; /* capture mixer */
259 unsigned int beep_amp; /* beep amp value, set via set_beep_amp() */
261 const struct hda_verb *init_verbs[5]; /* initialization verbs
265 unsigned int num_init_verbs;
267 char *stream_name_analog; /* analog PCM stream */
268 struct hda_pcm_stream *stream_analog_playback;
269 struct hda_pcm_stream *stream_analog_capture;
270 struct hda_pcm_stream *stream_analog_alt_playback;
271 struct hda_pcm_stream *stream_analog_alt_capture;
273 char *stream_name_digital; /* digital PCM stream */
274 struct hda_pcm_stream *stream_digital_playback;
275 struct hda_pcm_stream *stream_digital_capture;
278 struct hda_multi_out multiout; /* playback set-up
279 * max_channels, dacs must be set
280 * dig_out_nid and hp_nid are optional
282 hda_nid_t alt_dac_nid;
283 hda_nid_t slave_dig_outs[3]; /* optional - for auto-parsing */
287 unsigned int num_adc_nids;
289 hda_nid_t *capsrc_nids;
290 hda_nid_t dig_in_nid; /* digital-in NID; optional */
291 int capture_style; /* capture style (CAPT_*) */
294 unsigned int num_mux_defs;
295 const struct hda_input_mux *input_mux;
296 unsigned int cur_mux[3];
299 const struct hda_channel_mode *channel_mode;
300 int num_channel_mode;
303 /* PCM information */
304 struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */
306 /* dynamic controls, init_verbs and input_mux */
307 struct auto_pin_cfg autocfg;
308 struct snd_array kctls;
309 struct hda_input_mux private_imux[3];
310 hda_nid_t private_dac_nids[AUTO_CFG_MAX_OUTS];
313 void (*init_hook)(struct hda_codec *codec);
314 void (*unsol_event)(struct hda_codec *codec, unsigned int res);
316 /* for pin sensing */
317 unsigned int sense_updated: 1;
318 unsigned int jack_present: 1;
319 unsigned int master_sw: 1;
322 unsigned int no_analog :1; /* digital I/O only */
324 /* for virtual master */
325 hda_nid_t vmaster_nid;
326 #ifdef CONFIG_SND_HDA_POWER_SAVE
327 struct hda_loopback_check loopback;
332 unsigned int pll_coef_idx, pll_coef_bit;
336 * configuration template - to be copied to the spec instance
338 struct alc_config_preset {
339 struct snd_kcontrol_new *mixers[5]; /* should be identical size
342 struct snd_kcontrol_new *cap_mixer; /* capture mixer */
343 const struct hda_verb *init_verbs[5];
344 unsigned int num_dacs;
346 hda_nid_t dig_out_nid; /* optional */
347 hda_nid_t hp_nid; /* optional */
348 hda_nid_t *slave_dig_outs;
349 unsigned int num_adc_nids;
351 hda_nid_t *capsrc_nids;
352 hda_nid_t dig_in_nid;
353 unsigned int num_channel_mode;
354 const struct hda_channel_mode *channel_mode;
356 unsigned int num_mux_defs;
357 const struct hda_input_mux *input_mux;
358 void (*unsol_event)(struct hda_codec *, unsigned int);
359 void (*init_hook)(struct hda_codec *);
360 #ifdef CONFIG_SND_HDA_POWER_SAVE
361 struct hda_amp_list *loopbacks;
369 static int alc_mux_enum_info(struct snd_kcontrol *kcontrol,
370 struct snd_ctl_elem_info *uinfo)
372 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
373 struct alc_spec *spec = codec->spec;
374 unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id);
375 if (mux_idx >= spec->num_mux_defs)
377 return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo);
380 static int alc_mux_enum_get(struct snd_kcontrol *kcontrol,
381 struct snd_ctl_elem_value *ucontrol)
383 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
384 struct alc_spec *spec = codec->spec;
385 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
387 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
391 static int alc_mux_enum_put(struct snd_kcontrol *kcontrol,
392 struct snd_ctl_elem_value *ucontrol)
394 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
395 struct alc_spec *spec = codec->spec;
396 const struct hda_input_mux *imux;
397 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
398 unsigned int mux_idx;
399 hda_nid_t nid = spec->capsrc_nids ?
400 spec->capsrc_nids[adc_idx] : spec->adc_nids[adc_idx];
402 mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx;
403 imux = &spec->input_mux[mux_idx];
405 if (spec->capture_style &&
406 !(spec->capture_style == CAPT_1MUX_MIX && !adc_idx)) {
407 /* Matrix-mixer style (e.g. ALC882) */
408 unsigned int *cur_val = &spec->cur_mux[adc_idx];
411 idx = ucontrol->value.enumerated.item[0];
412 if (idx >= imux->num_items)
413 idx = imux->num_items - 1;
416 for (i = 0; i < imux->num_items; i++) {
417 unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
418 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
419 imux->items[i].index,
425 /* MUX style (e.g. ALC880) */
426 return snd_hda_input_mux_put(codec, imux, ucontrol, nid,
427 &spec->cur_mux[adc_idx]);
432 * channel mode setting
434 static int alc_ch_mode_info(struct snd_kcontrol *kcontrol,
435 struct snd_ctl_elem_info *uinfo)
437 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
438 struct alc_spec *spec = codec->spec;
439 return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
440 spec->num_channel_mode);
443 static int alc_ch_mode_get(struct snd_kcontrol *kcontrol,
444 struct snd_ctl_elem_value *ucontrol)
446 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
447 struct alc_spec *spec = codec->spec;
448 return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
449 spec->num_channel_mode,
450 spec->multiout.max_channels);
453 static int alc_ch_mode_put(struct snd_kcontrol *kcontrol,
454 struct snd_ctl_elem_value *ucontrol)
456 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
457 struct alc_spec *spec = codec->spec;
458 int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
459 spec->num_channel_mode,
460 &spec->multiout.max_channels);
461 if (err >= 0 && spec->need_dac_fix)
462 spec->multiout.num_dacs = spec->multiout.max_channels / 2;
467 * Control the mode of pin widget settings via the mixer. "pc" is used
468 * instead of "%" to avoid consequences of accidently treating the % as
469 * being part of a format specifier. Maximum allowed length of a value is
470 * 63 characters plus NULL terminator.
472 * Note: some retasking pin complexes seem to ignore requests for input
473 * states other than HiZ (eg: PIN_VREFxx) and revert to HiZ if any of these
474 * are requested. Therefore order this list so that this behaviour will not
475 * cause problems when mixer clients move through the enum sequentially.
476 * NIDs 0x0f and 0x10 have been observed to have this behaviour as of
479 static char *alc_pin_mode_names[] = {
480 "Mic 50pc bias", "Mic 80pc bias",
481 "Line in", "Line out", "Headphone out",
483 static unsigned char alc_pin_mode_values[] = {
484 PIN_VREF50, PIN_VREF80, PIN_IN, PIN_OUT, PIN_HP,
486 /* The control can present all 5 options, or it can limit the options based
487 * in the pin being assumed to be exclusively an input or an output pin. In
488 * addition, "input" pins may or may not process the mic bias option
489 * depending on actual widget capability (NIDs 0x0f and 0x10 don't seem to
490 * accept requests for bias as of chip versions up to March 2006) and/or
491 * wiring in the computer.
493 #define ALC_PIN_DIR_IN 0x00
494 #define ALC_PIN_DIR_OUT 0x01
495 #define ALC_PIN_DIR_INOUT 0x02
496 #define ALC_PIN_DIR_IN_NOMICBIAS 0x03
497 #define ALC_PIN_DIR_INOUT_NOMICBIAS 0x04
499 /* Info about the pin modes supported by the different pin direction modes.
500 * For each direction the minimum and maximum values are given.
502 static signed char alc_pin_mode_dir_info[5][2] = {
503 { 0, 2 }, /* ALC_PIN_DIR_IN */
504 { 3, 4 }, /* ALC_PIN_DIR_OUT */
505 { 0, 4 }, /* ALC_PIN_DIR_INOUT */
506 { 2, 2 }, /* ALC_PIN_DIR_IN_NOMICBIAS */
507 { 2, 4 }, /* ALC_PIN_DIR_INOUT_NOMICBIAS */
509 #define alc_pin_mode_min(_dir) (alc_pin_mode_dir_info[_dir][0])
510 #define alc_pin_mode_max(_dir) (alc_pin_mode_dir_info[_dir][1])
511 #define alc_pin_mode_n_items(_dir) \
512 (alc_pin_mode_max(_dir)-alc_pin_mode_min(_dir)+1)
514 static int alc_pin_mode_info(struct snd_kcontrol *kcontrol,
515 struct snd_ctl_elem_info *uinfo)
517 unsigned int item_num = uinfo->value.enumerated.item;
518 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
520 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
522 uinfo->value.enumerated.items = alc_pin_mode_n_items(dir);
524 if (item_num<alc_pin_mode_min(dir) || item_num>alc_pin_mode_max(dir))
525 item_num = alc_pin_mode_min(dir);
526 strcpy(uinfo->value.enumerated.name, alc_pin_mode_names[item_num]);
530 static int alc_pin_mode_get(struct snd_kcontrol *kcontrol,
531 struct snd_ctl_elem_value *ucontrol)
534 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
535 hda_nid_t nid = kcontrol->private_value & 0xffff;
536 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
537 long *valp = ucontrol->value.integer.value;
538 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
539 AC_VERB_GET_PIN_WIDGET_CONTROL,
542 /* Find enumerated value for current pinctl setting */
543 i = alc_pin_mode_min(dir);
544 while (alc_pin_mode_values[i] != pinctl && i <= alc_pin_mode_max(dir))
546 *valp = i <= alc_pin_mode_max(dir) ? i: alc_pin_mode_min(dir);
550 static int alc_pin_mode_put(struct snd_kcontrol *kcontrol,
551 struct snd_ctl_elem_value *ucontrol)
554 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
555 hda_nid_t nid = kcontrol->private_value & 0xffff;
556 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
557 long val = *ucontrol->value.integer.value;
558 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
559 AC_VERB_GET_PIN_WIDGET_CONTROL,
562 if (val < alc_pin_mode_min(dir) || val > alc_pin_mode_max(dir))
563 val = alc_pin_mode_min(dir);
565 change = pinctl != alc_pin_mode_values[val];
567 /* Set pin mode to that requested */
568 snd_hda_codec_write_cache(codec, nid, 0,
569 AC_VERB_SET_PIN_WIDGET_CONTROL,
570 alc_pin_mode_values[val]);
572 /* Also enable the retasking pin's input/output as required
573 * for the requested pin mode. Enum values of 2 or less are
576 * Dynamically switching the input/output buffers probably
577 * reduces noise slightly (particularly on input) so we'll
578 * do it. However, having both input and output buffers
579 * enabled simultaneously doesn't seem to be problematic if
580 * this turns out to be necessary in the future.
583 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
584 HDA_AMP_MUTE, HDA_AMP_MUTE);
585 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
588 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
589 HDA_AMP_MUTE, HDA_AMP_MUTE);
590 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
597 #define ALC_PIN_MODE(xname, nid, dir) \
598 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
599 .info = alc_pin_mode_info, \
600 .get = alc_pin_mode_get, \
601 .put = alc_pin_mode_put, \
602 .private_value = nid | (dir<<16) }
604 /* A switch control for ALC260 GPIO pins. Multiple GPIOs can be ganged
605 * together using a mask with more than one bit set. This control is
606 * currently used only by the ALC260 test model. At this stage they are not
607 * needed for any "production" models.
609 #ifdef CONFIG_SND_DEBUG
610 #define alc_gpio_data_info snd_ctl_boolean_mono_info
612 static int alc_gpio_data_get(struct snd_kcontrol *kcontrol,
613 struct snd_ctl_elem_value *ucontrol)
615 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
616 hda_nid_t nid = kcontrol->private_value & 0xffff;
617 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
618 long *valp = ucontrol->value.integer.value;
619 unsigned int val = snd_hda_codec_read(codec, nid, 0,
620 AC_VERB_GET_GPIO_DATA, 0x00);
622 *valp = (val & mask) != 0;
625 static int alc_gpio_data_put(struct snd_kcontrol *kcontrol,
626 struct snd_ctl_elem_value *ucontrol)
629 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
630 hda_nid_t nid = kcontrol->private_value & 0xffff;
631 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
632 long val = *ucontrol->value.integer.value;
633 unsigned int gpio_data = snd_hda_codec_read(codec, nid, 0,
634 AC_VERB_GET_GPIO_DATA,
637 /* Set/unset the masked GPIO bit(s) as needed */
638 change = (val == 0 ? 0 : mask) != (gpio_data & mask);
643 snd_hda_codec_write_cache(codec, nid, 0,
644 AC_VERB_SET_GPIO_DATA, gpio_data);
648 #define ALC_GPIO_DATA_SWITCH(xname, nid, mask) \
649 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
650 .info = alc_gpio_data_info, \
651 .get = alc_gpio_data_get, \
652 .put = alc_gpio_data_put, \
653 .private_value = nid | (mask<<16) }
654 #endif /* CONFIG_SND_DEBUG */
656 /* A switch control to allow the enabling of the digital IO pins on the
657 * ALC260. This is incredibly simplistic; the intention of this control is
658 * to provide something in the test model allowing digital outputs to be
659 * identified if present. If models are found which can utilise these
660 * outputs a more complete mixer control can be devised for those models if
663 #ifdef CONFIG_SND_DEBUG
664 #define alc_spdif_ctrl_info snd_ctl_boolean_mono_info
666 static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol,
667 struct snd_ctl_elem_value *ucontrol)
669 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
670 hda_nid_t nid = kcontrol->private_value & 0xffff;
671 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
672 long *valp = ucontrol->value.integer.value;
673 unsigned int val = snd_hda_codec_read(codec, nid, 0,
674 AC_VERB_GET_DIGI_CONVERT_1, 0x00);
676 *valp = (val & mask) != 0;
679 static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol,
680 struct snd_ctl_elem_value *ucontrol)
683 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
684 hda_nid_t nid = kcontrol->private_value & 0xffff;
685 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
686 long val = *ucontrol->value.integer.value;
687 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
688 AC_VERB_GET_DIGI_CONVERT_1,
691 /* Set/unset the masked control bit(s) as needed */
692 change = (val == 0 ? 0 : mask) != (ctrl_data & mask);
697 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1,
702 #define ALC_SPDIF_CTRL_SWITCH(xname, nid, mask) \
703 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
704 .info = alc_spdif_ctrl_info, \
705 .get = alc_spdif_ctrl_get, \
706 .put = alc_spdif_ctrl_put, \
707 .private_value = nid | (mask<<16) }
708 #endif /* CONFIG_SND_DEBUG */
710 /* A switch control to allow the enabling EAPD digital outputs on the ALC26x.
711 * Again, this is only used in the ALC26x test models to help identify when
712 * the EAPD line must be asserted for features to work.
714 #ifdef CONFIG_SND_DEBUG
715 #define alc_eapd_ctrl_info snd_ctl_boolean_mono_info
717 static int alc_eapd_ctrl_get(struct snd_kcontrol *kcontrol,
718 struct snd_ctl_elem_value *ucontrol)
720 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
721 hda_nid_t nid = kcontrol->private_value & 0xffff;
722 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
723 long *valp = ucontrol->value.integer.value;
724 unsigned int val = snd_hda_codec_read(codec, nid, 0,
725 AC_VERB_GET_EAPD_BTLENABLE, 0x00);
727 *valp = (val & mask) != 0;
731 static int alc_eapd_ctrl_put(struct snd_kcontrol *kcontrol,
732 struct snd_ctl_elem_value *ucontrol)
735 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
736 hda_nid_t nid = kcontrol->private_value & 0xffff;
737 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
738 long val = *ucontrol->value.integer.value;
739 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
740 AC_VERB_GET_EAPD_BTLENABLE,
743 /* Set/unset the masked control bit(s) as needed */
744 change = (!val ? 0 : mask) != (ctrl_data & mask);
749 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
755 #define ALC_EAPD_CTRL_SWITCH(xname, nid, mask) \
756 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
757 .info = alc_eapd_ctrl_info, \
758 .get = alc_eapd_ctrl_get, \
759 .put = alc_eapd_ctrl_put, \
760 .private_value = nid | (mask<<16) }
761 #endif /* CONFIG_SND_DEBUG */
764 * set up the input pin config (depending on the given auto-pin type)
766 static void alc_set_input_pin(struct hda_codec *codec, hda_nid_t nid,
769 unsigned int val = PIN_IN;
771 if (auto_pin_type <= AUTO_PIN_FRONT_MIC) {
773 pincap = snd_hda_query_pin_caps(codec, nid);
774 pincap = (pincap & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT;
775 if (pincap & AC_PINCAP_VREF_80)
778 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, val);
783 static void add_mixer(struct alc_spec *spec, struct snd_kcontrol_new *mix)
785 if (snd_BUG_ON(spec->num_mixers >= ARRAY_SIZE(spec->mixers)))
787 spec->mixers[spec->num_mixers++] = mix;
790 static void add_verb(struct alc_spec *spec, const struct hda_verb *verb)
792 if (snd_BUG_ON(spec->num_init_verbs >= ARRAY_SIZE(spec->init_verbs)))
794 spec->init_verbs[spec->num_init_verbs++] = verb;
797 #ifdef CONFIG_PROC_FS
801 static void print_realtek_coef(struct snd_info_buffer *buffer,
802 struct hda_codec *codec, hda_nid_t nid)
808 coeff = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_PROC_COEF, 0);
809 snd_iprintf(buffer, " Processing Coefficient: 0x%02x\n", coeff);
810 coeff = snd_hda_codec_read(codec, nid, 0,
811 AC_VERB_GET_COEF_INDEX, 0);
812 snd_iprintf(buffer, " Coefficient Index: 0x%02x\n", coeff);
815 #define print_realtek_coef NULL
819 * set up from the preset table
821 static void setup_preset(struct alc_spec *spec,
822 const struct alc_config_preset *preset)
826 for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++)
827 add_mixer(spec, preset->mixers[i]);
828 spec->cap_mixer = preset->cap_mixer;
829 for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i];
831 add_verb(spec, preset->init_verbs[i]);
833 spec->channel_mode = preset->channel_mode;
834 spec->num_channel_mode = preset->num_channel_mode;
835 spec->need_dac_fix = preset->need_dac_fix;
837 spec->multiout.max_channels = spec->channel_mode[0].channels;
839 spec->multiout.num_dacs = preset->num_dacs;
840 spec->multiout.dac_nids = preset->dac_nids;
841 spec->multiout.dig_out_nid = preset->dig_out_nid;
842 spec->multiout.slave_dig_outs = preset->slave_dig_outs;
843 spec->multiout.hp_nid = preset->hp_nid;
845 spec->num_mux_defs = preset->num_mux_defs;
846 if (!spec->num_mux_defs)
847 spec->num_mux_defs = 1;
848 spec->input_mux = preset->input_mux;
850 spec->num_adc_nids = preset->num_adc_nids;
851 spec->adc_nids = preset->adc_nids;
852 spec->capsrc_nids = preset->capsrc_nids;
853 spec->dig_in_nid = preset->dig_in_nid;
855 spec->unsol_event = preset->unsol_event;
856 spec->init_hook = preset->init_hook;
857 #ifdef CONFIG_SND_HDA_POWER_SAVE
858 spec->loopback.amplist = preset->loopbacks;
862 /* Enable GPIO mask and set output */
863 static struct hda_verb alc_gpio1_init_verbs[] = {
864 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
865 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
866 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
870 static struct hda_verb alc_gpio2_init_verbs[] = {
871 {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
872 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
873 {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
877 static struct hda_verb alc_gpio3_init_verbs[] = {
878 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
879 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
880 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
885 * Fix hardware PLL issue
886 * On some codecs, the analog PLL gating control must be off while
887 * the default value is 1.
889 static void alc_fix_pll(struct hda_codec *codec)
891 struct alc_spec *spec = codec->spec;
896 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX,
898 val = snd_hda_codec_read(codec, spec->pll_nid, 0,
899 AC_VERB_GET_PROC_COEF, 0);
900 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX,
902 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_PROC_COEF,
903 val & ~(1 << spec->pll_coef_bit));
906 static void alc_fix_pll_init(struct hda_codec *codec, hda_nid_t nid,
907 unsigned int coef_idx, unsigned int coef_bit)
909 struct alc_spec *spec = codec->spec;
911 spec->pll_coef_idx = coef_idx;
912 spec->pll_coef_bit = coef_bit;
916 static void alc_sku_automute(struct hda_codec *codec)
918 struct alc_spec *spec = codec->spec;
919 unsigned int present;
920 unsigned int hp_nid = spec->autocfg.hp_pins[0];
921 unsigned int sp_nid = spec->autocfg.speaker_pins[0];
923 /* need to execute and sync at first */
924 snd_hda_codec_read(codec, hp_nid, 0, AC_VERB_SET_PIN_SENSE, 0);
925 present = snd_hda_codec_read(codec, hp_nid, 0,
926 AC_VERB_GET_PIN_SENSE, 0);
927 spec->jack_present = (present & 0x80000000) != 0;
928 snd_hda_codec_write(codec, sp_nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
929 spec->jack_present ? 0 : PIN_OUT);
932 #if 0 /* it's broken in some acses -- temporarily disabled */
933 static void alc_mic_automute(struct hda_codec *codec)
935 struct alc_spec *spec = codec->spec;
936 unsigned int present;
937 unsigned int mic_nid = spec->autocfg.input_pins[AUTO_PIN_MIC];
938 unsigned int fmic_nid = spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC];
939 unsigned int mix_nid = spec->capsrc_nids[0];
940 unsigned int capsrc_idx_mic, capsrc_idx_fmic;
942 capsrc_idx_mic = mic_nid - 0x18;
943 capsrc_idx_fmic = fmic_nid - 0x18;
944 present = snd_hda_codec_read(codec, mic_nid, 0,
945 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
946 snd_hda_codec_write(codec, mix_nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
947 0x7000 | (capsrc_idx_mic << 8) | (present ? 0 : 0x80));
948 snd_hda_codec_write(codec, mix_nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
949 0x7000 | (capsrc_idx_fmic << 8) | (present ? 0x80 : 0));
950 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, capsrc_idx_fmic,
951 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
954 #define alc_mic_automute(codec) do {} while(0) /* NOP */
955 #endif /* disabled */
957 /* unsolicited event for HP jack sensing */
958 static void alc_sku_unsol_event(struct hda_codec *codec, unsigned int res)
960 if (codec->vendor_id == 0x10ec0880)
964 if (res == ALC880_HP_EVENT)
965 alc_sku_automute(codec);
967 if (res == ALC880_MIC_EVENT)
968 alc_mic_automute(codec);
971 static void alc_inithook(struct hda_codec *codec)
973 alc_sku_automute(codec);
974 alc_mic_automute(codec);
977 /* additional initialization for ALC888 variants */
978 static void alc888_coef_init(struct hda_codec *codec)
982 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 0);
983 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
984 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
985 if ((tmp & 0xf0) == 0x20)
987 snd_hda_codec_read(codec, 0x20, 0,
988 AC_VERB_SET_PROC_COEF, 0x830);
991 snd_hda_codec_read(codec, 0x20, 0,
992 AC_VERB_SET_PROC_COEF, 0x3030);
995 /* 32-bit subsystem ID for BIOS loading in HD Audio codec.
996 * 31 ~ 16 : Manufacture ID
998 * 7 ~ 0 : Assembly ID
999 * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36
1001 static void alc_subsystem_id(struct hda_codec *codec,
1002 unsigned int porta, unsigned int porte,
1005 unsigned int ass, tmp, i;
1007 struct alc_spec *spec = codec->spec;
1009 ass = codec->subsystem_id & 0xffff;
1010 if ((ass != codec->bus->pci->subsystem_device) && (ass & 1))
1014 * 31~30 : port conetcivity
1017 * 19~16 : Check sum (15:1)
1022 if (codec->vendor_id == 0x10ec0260)
1024 ass = snd_hda_codec_get_pincfg(codec, nid);
1025 snd_printd("realtek: No valid SSID, "
1026 "checking pincfg 0x%08x for NID 0x%x\n",
1028 if (!(ass & 1) && !(ass & 0x100000))
1030 if ((ass >> 30) != 1) /* no physical connection */
1035 for (i = 1; i < 16; i++) {
1039 if (((ass >> 16) & 0xf) != tmp)
1042 snd_printd("realtek: Enabling init ASM_ID=0x%04x CODEC_ID=%08x\n",
1043 ass & 0xffff, codec->vendor_id);
1047 * 2 : 0 --> Desktop, 1 --> Laptop
1048 * 3~5 : External Amplifier control
1051 tmp = (ass & 0x38) >> 3; /* external Amp control */
1054 snd_hda_sequence_write(codec, alc_gpio1_init_verbs);
1057 snd_hda_sequence_write(codec, alc_gpio2_init_verbs);
1060 snd_hda_sequence_write(codec, alc_gpio3_init_verbs);
1062 case 5: /* set EAPD output high */
1063 switch (codec->vendor_id) {
1065 snd_hda_codec_write(codec, 0x0f, 0,
1066 AC_VERB_SET_EAPD_BTLENABLE, 2);
1067 snd_hda_codec_write(codec, 0x10, 0,
1068 AC_VERB_SET_EAPD_BTLENABLE, 2);
1080 snd_hda_codec_write(codec, 0x14, 0,
1081 AC_VERB_SET_EAPD_BTLENABLE, 2);
1082 snd_hda_codec_write(codec, 0x15, 0,
1083 AC_VERB_SET_EAPD_BTLENABLE, 2);
1086 switch (codec->vendor_id) {
1088 snd_hda_codec_write(codec, 0x1a, 0,
1089 AC_VERB_SET_COEF_INDEX, 7);
1090 tmp = snd_hda_codec_read(codec, 0x1a, 0,
1091 AC_VERB_GET_PROC_COEF, 0);
1092 snd_hda_codec_write(codec, 0x1a, 0,
1093 AC_VERB_SET_COEF_INDEX, 7);
1094 snd_hda_codec_write(codec, 0x1a, 0,
1095 AC_VERB_SET_PROC_COEF,
1105 snd_hda_codec_write(codec, 0x20, 0,
1106 AC_VERB_SET_COEF_INDEX, 7);
1107 tmp = snd_hda_codec_read(codec, 0x20, 0,
1108 AC_VERB_GET_PROC_COEF, 0);
1109 snd_hda_codec_write(codec, 0x20, 0,
1110 AC_VERB_SET_COEF_INDEX, 7);
1111 snd_hda_codec_write(codec, 0x20, 0,
1112 AC_VERB_SET_PROC_COEF,
1116 /*alc888_coef_init(codec);*/ /* called in alc_init() */
1120 snd_hda_codec_write(codec, 0x20, 0,
1121 AC_VERB_SET_COEF_INDEX, 7);
1122 tmp = snd_hda_codec_read(codec, 0x20, 0,
1123 AC_VERB_GET_PROC_COEF, 0);
1124 snd_hda_codec_write(codec, 0x20, 0,
1125 AC_VERB_SET_COEF_INDEX, 7);
1126 snd_hda_codec_write(codec, 0x20, 0,
1127 AC_VERB_SET_PROC_COEF,
1135 /* is laptop or Desktop and enable the function "Mute internal speaker
1136 * when the external headphone out jack is plugged"
1138 if (!(ass & 0x8000))
1141 * 10~8 : Jack location
1142 * 12~11: Headphone out -> 00: PortA, 01: PortE, 02: PortD, 03: Resvered
1144 * 15 : 1 --> enable the function "Mute internal speaker
1145 * when the external headphone out jack is plugged"
1147 if (!spec->autocfg.speaker_pins[0]) {
1148 if (spec->autocfg.line_out_pins[0])
1149 spec->autocfg.speaker_pins[0] =
1150 spec->autocfg.line_out_pins[0];
1155 if (!spec->autocfg.hp_pins[0]) {
1156 tmp = (ass >> 11) & 0x3; /* HP to chassis */
1158 spec->autocfg.hp_pins[0] = porta;
1160 spec->autocfg.hp_pins[0] = porte;
1162 spec->autocfg.hp_pins[0] = portd;
1166 if (spec->autocfg.hp_pins[0])
1167 snd_hda_codec_write(codec, spec->autocfg.hp_pins[0], 0,
1168 AC_VERB_SET_UNSOLICITED_ENABLE,
1169 AC_USRSP_EN | ALC880_HP_EVENT);
1171 #if 0 /* it's broken in some acses -- temporarily disabled */
1172 if (spec->autocfg.input_pins[AUTO_PIN_MIC] &&
1173 spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC])
1174 snd_hda_codec_write(codec,
1175 spec->autocfg.input_pins[AUTO_PIN_MIC], 0,
1176 AC_VERB_SET_UNSOLICITED_ENABLE,
1177 AC_USRSP_EN | ALC880_MIC_EVENT);
1178 #endif /* disabled */
1180 spec->unsol_event = alc_sku_unsol_event;
1184 * Fix-up pin default configurations
1192 static void alc_fix_pincfg(struct hda_codec *codec,
1193 const struct snd_pci_quirk *quirk,
1194 const struct alc_pincfg **pinfix)
1196 const struct alc_pincfg *cfg;
1198 quirk = snd_pci_quirk_lookup(codec->bus->pci, quirk);
1202 cfg = pinfix[quirk->value];
1203 for (; cfg->nid; cfg++)
1204 snd_hda_codec_set_pincfg(codec, cfg->nid, cfg->val);
1214 static struct hda_verb alc888_4ST_ch2_intel_init[] = {
1215 /* Mic-in jack as mic in */
1216 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1217 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1218 /* Line-in jack as Line in */
1219 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1220 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1221 /* Line-Out as Front */
1222 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
1229 static struct hda_verb alc888_4ST_ch4_intel_init[] = {
1230 /* Mic-in jack as mic in */
1231 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1232 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1233 /* Line-in jack as Surround */
1234 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1235 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1236 /* Line-Out as Front */
1237 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
1244 static struct hda_verb alc888_4ST_ch6_intel_init[] = {
1245 /* Mic-in jack as CLFE */
1246 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1247 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1248 /* Line-in jack as Surround */
1249 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1250 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1251 /* Line-Out as CLFE (workaround because Mic-in is not loud enough) */
1252 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1259 static struct hda_verb alc888_4ST_ch8_intel_init[] = {
1260 /* Mic-in jack as CLFE */
1261 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1262 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1263 /* Line-in jack as Surround */
1264 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1265 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1266 /* Line-Out as Side */
1267 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1271 static struct hda_channel_mode alc888_4ST_8ch_intel_modes[4] = {
1272 { 2, alc888_4ST_ch2_intel_init },
1273 { 4, alc888_4ST_ch4_intel_init },
1274 { 6, alc888_4ST_ch6_intel_init },
1275 { 8, alc888_4ST_ch8_intel_init },
1279 * ALC888 Fujitsu Siemens Amillo xa3530
1282 static struct hda_verb alc888_fujitsu_xa3530_verbs[] = {
1283 /* Front Mic: set to PIN_IN (empty by default) */
1284 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1285 /* Connect Internal HP to Front */
1286 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1287 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1288 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1289 /* Connect Bass HP to Front */
1290 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1291 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1292 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1293 /* Connect Line-Out side jack (SPDIF) to Side */
1294 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1295 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1296 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1297 /* Connect Mic jack to CLFE */
1298 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1299 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1300 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02},
1301 /* Connect Line-in jack to Surround */
1302 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1303 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1304 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
1305 /* Connect HP out jack to Front */
1306 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1307 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1308 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
1309 /* Enable unsolicited event for HP jack and Line-out jack */
1310 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1311 {0x17, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1315 static void alc888_fujitsu_xa3530_automute(struct hda_codec *codec)
1317 unsigned int present;
1319 /* Line out presence */
1320 present = snd_hda_codec_read(codec, 0x17, 0,
1321 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1322 /* HP out presence */
1323 present = present || snd_hda_codec_read(codec, 0x1b, 0,
1324 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1325 bits = present ? HDA_AMP_MUTE : 0;
1326 /* Toggle internal speakers muting */
1327 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
1328 HDA_AMP_MUTE, bits);
1329 /* Toggle internal bass muting */
1330 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
1331 HDA_AMP_MUTE, bits);
1334 static void alc888_fujitsu_xa3530_unsol_event(struct hda_codec *codec,
1337 if (res >> 26 == ALC880_HP_EVENT)
1338 alc888_fujitsu_xa3530_automute(codec);
1343 * ALC888 Acer Aspire 4930G model
1346 static struct hda_verb alc888_acer_aspire_4930g_verbs[] = {
1347 /* Front Mic: set to PIN_IN (empty by default) */
1348 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1349 /* Unselect Front Mic by default in input mixer 3 */
1350 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
1351 /* Enable unsolicited event for HP jack */
1352 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1353 /* Connect Internal HP to front */
1354 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1355 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1356 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1357 /* Connect HP out to front */
1358 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1359 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1360 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1364 static struct hda_input_mux alc888_2_capture_sources[2] = {
1365 /* Front mic only available on one ADC */
1372 { "Front Mic", 0xb },
1385 static struct snd_kcontrol_new alc888_base_mixer[] = {
1386 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1387 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1388 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1389 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
1390 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
1392 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1393 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1394 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1395 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
1396 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
1397 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1398 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1399 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1400 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1401 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1402 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
1403 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1407 static void alc888_acer_aspire_4930g_automute(struct hda_codec *codec)
1409 unsigned int present;
1411 present = snd_hda_codec_read(codec, 0x15, 0,
1412 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1413 bits = present ? HDA_AMP_MUTE : 0;
1414 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
1415 HDA_AMP_MUTE, bits);
1418 static void alc888_acer_aspire_4930g_unsol_event(struct hda_codec *codec,
1421 if (res >> 26 == ALC880_HP_EVENT)
1422 alc888_acer_aspire_4930g_automute(codec);
1426 * ALC880 3-stack model
1428 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
1429 * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18,
1430 * F-Mic = 0x1b, HP = 0x19
1433 static hda_nid_t alc880_dac_nids[4] = {
1434 /* front, rear, clfe, rear_surr */
1435 0x02, 0x05, 0x04, 0x03
1438 static hda_nid_t alc880_adc_nids[3] = {
1443 /* The datasheet says the node 0x07 is connected from inputs,
1444 * but it shows zero connection in the real implementation on some devices.
1445 * Note: this is a 915GAV bug, fixed on 915GLV
1447 static hda_nid_t alc880_adc_nids_alt[2] = {
1452 #define ALC880_DIGOUT_NID 0x06
1453 #define ALC880_DIGIN_NID 0x0a
1455 static struct hda_input_mux alc880_capture_source = {
1459 { "Front Mic", 0x3 },
1465 /* channel source setting (2/6 channel selection for 3-stack) */
1467 static struct hda_verb alc880_threestack_ch2_init[] = {
1468 /* set line-in to input, mute it */
1469 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1470 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1471 /* set mic-in to input vref 80%, mute it */
1472 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1473 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1478 static struct hda_verb alc880_threestack_ch6_init[] = {
1479 /* set line-in to output, unmute it */
1480 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1481 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1482 /* set mic-in to output, unmute it */
1483 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1484 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1488 static struct hda_channel_mode alc880_threestack_modes[2] = {
1489 { 2, alc880_threestack_ch2_init },
1490 { 6, alc880_threestack_ch6_init },
1493 static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
1494 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1495 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1496 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
1497 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
1498 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1499 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1500 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1501 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1502 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1503 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1504 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1505 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1506 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1507 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1508 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
1509 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
1510 HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
1512 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1513 .name = "Channel Mode",
1514 .info = alc_ch_mode_info,
1515 .get = alc_ch_mode_get,
1516 .put = alc_ch_mode_put,
1521 /* capture mixer elements */
1522 static int alc_cap_vol_info(struct snd_kcontrol *kcontrol,
1523 struct snd_ctl_elem_info *uinfo)
1525 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1526 struct alc_spec *spec = codec->spec;
1529 mutex_lock(&codec->control_mutex);
1530 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0,
1532 err = snd_hda_mixer_amp_volume_info(kcontrol, uinfo);
1533 mutex_unlock(&codec->control_mutex);
1537 static int alc_cap_vol_tlv(struct snd_kcontrol *kcontrol, int op_flag,
1538 unsigned int size, unsigned int __user *tlv)
1540 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1541 struct alc_spec *spec = codec->spec;
1544 mutex_lock(&codec->control_mutex);
1545 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0,
1547 err = snd_hda_mixer_amp_tlv(kcontrol, op_flag, size, tlv);
1548 mutex_unlock(&codec->control_mutex);
1552 typedef int (*getput_call_t)(struct snd_kcontrol *kcontrol,
1553 struct snd_ctl_elem_value *ucontrol);
1555 static int alc_cap_getput_caller(struct snd_kcontrol *kcontrol,
1556 struct snd_ctl_elem_value *ucontrol,
1559 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1560 struct alc_spec *spec = codec->spec;
1561 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
1564 mutex_lock(&codec->control_mutex);
1565 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[adc_idx],
1567 err = func(kcontrol, ucontrol);
1568 mutex_unlock(&codec->control_mutex);
1572 static int alc_cap_vol_get(struct snd_kcontrol *kcontrol,
1573 struct snd_ctl_elem_value *ucontrol)
1575 return alc_cap_getput_caller(kcontrol, ucontrol,
1576 snd_hda_mixer_amp_volume_get);
1579 static int alc_cap_vol_put(struct snd_kcontrol *kcontrol,
1580 struct snd_ctl_elem_value *ucontrol)
1582 return alc_cap_getput_caller(kcontrol, ucontrol,
1583 snd_hda_mixer_amp_volume_put);
1586 /* capture mixer elements */
1587 #define alc_cap_sw_info snd_ctl_boolean_stereo_info
1589 static int alc_cap_sw_get(struct snd_kcontrol *kcontrol,
1590 struct snd_ctl_elem_value *ucontrol)
1592 return alc_cap_getput_caller(kcontrol, ucontrol,
1593 snd_hda_mixer_amp_switch_get);
1596 static int alc_cap_sw_put(struct snd_kcontrol *kcontrol,
1597 struct snd_ctl_elem_value *ucontrol)
1599 return alc_cap_getput_caller(kcontrol, ucontrol,
1600 snd_hda_mixer_amp_switch_put);
1603 #define _DEFINE_CAPMIX(num) \
1605 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1606 .name = "Capture Switch", \
1607 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, \
1609 .info = alc_cap_sw_info, \
1610 .get = alc_cap_sw_get, \
1611 .put = alc_cap_sw_put, \
1614 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1615 .name = "Capture Volume", \
1616 .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE | \
1617 SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
1618 SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK), \
1620 .info = alc_cap_vol_info, \
1621 .get = alc_cap_vol_get, \
1622 .put = alc_cap_vol_put, \
1623 .tlv = { .c = alc_cap_vol_tlv }, \
1626 #define _DEFINE_CAPSRC(num) \
1628 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1629 /* .name = "Capture Source", */ \
1630 .name = "Input Source", \
1632 .info = alc_mux_enum_info, \
1633 .get = alc_mux_enum_get, \
1634 .put = alc_mux_enum_put, \
1637 #define DEFINE_CAPMIX(num) \
1638 static struct snd_kcontrol_new alc_capture_mixer ## num[] = { \
1639 _DEFINE_CAPMIX(num), \
1640 _DEFINE_CAPSRC(num), \
1644 #define DEFINE_CAPMIX_NOSRC(num) \
1645 static struct snd_kcontrol_new alc_capture_mixer_nosrc ## num[] = { \
1646 _DEFINE_CAPMIX(num), \
1650 /* up to three ADCs */
1654 DEFINE_CAPMIX_NOSRC(1);
1655 DEFINE_CAPMIX_NOSRC(2);
1656 DEFINE_CAPMIX_NOSRC(3);
1659 * ALC880 5-stack model
1661 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d),
1663 * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
1664 * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
1667 /* additional mixers to alc880_three_stack_mixer */
1668 static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
1669 HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1670 HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
1674 /* channel source setting (6/8 channel selection for 5-stack) */
1676 static struct hda_verb alc880_fivestack_ch6_init[] = {
1677 /* set line-in to input, mute it */
1678 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1679 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1684 static struct hda_verb alc880_fivestack_ch8_init[] = {
1685 /* set line-in to output, unmute it */
1686 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1687 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1691 static struct hda_channel_mode alc880_fivestack_modes[2] = {
1692 { 6, alc880_fivestack_ch6_init },
1693 { 8, alc880_fivestack_ch8_init },
1698 * ALC880 6-stack model
1700 * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e),
1701 * Side = 0x05 (0x0f)
1702 * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
1703 * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
1706 static hda_nid_t alc880_6st_dac_nids[4] = {
1707 /* front, rear, clfe, rear_surr */
1708 0x02, 0x03, 0x04, 0x05
1711 static struct hda_input_mux alc880_6stack_capture_source = {
1715 { "Front Mic", 0x1 },
1721 /* fixed 8-channels */
1722 static struct hda_channel_mode alc880_sixstack_modes[1] = {
1726 static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
1727 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1728 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1729 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1730 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
1731 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1732 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1733 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1734 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1735 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
1736 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
1737 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1738 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1739 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1740 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1741 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1742 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1743 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1744 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1746 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1747 .name = "Channel Mode",
1748 .info = alc_ch_mode_info,
1749 .get = alc_ch_mode_get,
1750 .put = alc_ch_mode_put,
1759 * W810 has rear IO for:
1762 * Center/LFE (DAC 04)
1765 * The system also has a pair of internal speakers, and a headphone jack.
1766 * These are both connected to Line2 on the codec, hence to DAC 02.
1768 * There is a variable resistor to control the speaker or headphone
1769 * volume. This is a hardware-only device without a software API.
1771 * Plugging headphones in will disable the internal speakers. This is
1772 * implemented in hardware, not via the driver using jack sense. In
1773 * a similar fashion, plugging into the rear socket marked "front" will
1774 * disable both the speakers and headphones.
1776 * For input, there's a microphone jack, and an "audio in" jack.
1777 * These may not do anything useful with this driver yet, because I
1778 * haven't setup any initialization verbs for these yet...
1781 static hda_nid_t alc880_w810_dac_nids[3] = {
1782 /* front, rear/surround, clfe */
1786 /* fixed 6 channels */
1787 static struct hda_channel_mode alc880_w810_modes[1] = {
1791 /* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
1792 static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
1793 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1794 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1795 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1796 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
1797 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1798 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1799 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1800 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1801 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
1809 * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
1810 * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?),
1814 static hda_nid_t alc880_z71v_dac_nids[1] = {
1817 #define ALC880_Z71V_HP_DAC 0x03
1819 /* fixed 2 channels */
1820 static struct hda_channel_mode alc880_2_jack_modes[1] = {
1824 static struct snd_kcontrol_new alc880_z71v_mixer[] = {
1825 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1826 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1827 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1828 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
1829 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1830 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1831 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1832 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1838 * ALC880 F1734 model
1840 * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
1841 * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
1844 static hda_nid_t alc880_f1734_dac_nids[1] = {
1847 #define ALC880_F1734_HP_DAC 0x02
1849 static struct snd_kcontrol_new alc880_f1734_mixer[] = {
1850 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1851 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
1852 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1853 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
1854 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1855 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1856 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1857 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1861 static struct hda_input_mux alc880_f1734_capture_source = {
1873 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
1874 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
1875 * Mic = 0x18, Line = 0x1a
1878 #define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
1879 #define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
1881 static struct snd_kcontrol_new alc880_asus_mixer[] = {
1882 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1883 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1884 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1885 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
1886 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1887 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1888 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1889 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1890 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1891 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1892 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1893 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1894 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1895 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1897 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1898 .name = "Channel Mode",
1899 .info = alc_ch_mode_info,
1900 .get = alc_ch_mode_get,
1901 .put = alc_ch_mode_put,
1907 * ALC880 ASUS W1V model
1909 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
1910 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
1911 * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
1914 /* additional mixers to alc880_asus_mixer */
1915 static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
1916 HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
1917 HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
1922 static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
1923 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1924 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
1925 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
1926 HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
1927 HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
1928 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
1929 HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
1930 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
1931 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
1936 static struct snd_kcontrol_new alc880_uniwill_mixer[] = {
1937 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1938 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
1939 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1940 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
1941 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1942 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1943 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1944 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1945 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1946 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1947 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1948 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1949 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1950 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1951 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1952 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1954 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1955 .name = "Channel Mode",
1956 .info = alc_ch_mode_info,
1957 .get = alc_ch_mode_get,
1958 .put = alc_ch_mode_put,
1963 static struct snd_kcontrol_new alc880_fujitsu_mixer[] = {
1964 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1965 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
1966 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1967 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
1968 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1969 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1970 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1971 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1972 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1973 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1977 static struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = {
1978 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1979 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
1980 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1981 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
1982 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1983 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1988 * virtual master controls
1992 * slave controls for virtual master
1994 static const char *alc_slave_vols[] = {
1995 "Front Playback Volume",
1996 "Surround Playback Volume",
1997 "Center Playback Volume",
1998 "LFE Playback Volume",
1999 "Side Playback Volume",
2000 "Headphone Playback Volume",
2001 "Speaker Playback Volume",
2002 "Mono Playback Volume",
2003 "Line-Out Playback Volume",
2004 "PCM Playback Volume",
2008 static const char *alc_slave_sws[] = {
2009 "Front Playback Switch",
2010 "Surround Playback Switch",
2011 "Center Playback Switch",
2012 "LFE Playback Switch",
2013 "Side Playback Switch",
2014 "Headphone Playback Switch",
2015 "Speaker Playback Switch",
2016 "Mono Playback Switch",
2017 "IEC958 Playback Switch",
2022 * build control elements
2025 static void alc_free_kctls(struct hda_codec *codec);
2027 /* additional beep mixers; the actual parameters are overwritten at build */
2028 static struct snd_kcontrol_new alc_beep_mixer[] = {
2029 HDA_CODEC_VOLUME("Beep Playback Volume", 0, 0, HDA_INPUT),
2030 HDA_CODEC_MUTE("Beep Playback Switch", 0, 0, HDA_INPUT),
2034 static int alc_build_controls(struct hda_codec *codec)
2036 struct alc_spec *spec = codec->spec;
2040 for (i = 0; i < spec->num_mixers; i++) {
2041 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
2045 if (spec->cap_mixer) {
2046 err = snd_hda_add_new_ctls(codec, spec->cap_mixer);
2050 if (spec->multiout.dig_out_nid) {
2051 err = snd_hda_create_spdif_out_ctls(codec,
2052 spec->multiout.dig_out_nid);
2055 if (!spec->no_analog) {
2056 err = snd_hda_create_spdif_share_sw(codec,
2060 spec->multiout.share_spdif = 1;
2063 if (spec->dig_in_nid) {
2064 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
2069 /* create beep controls if needed */
2070 if (spec->beep_amp) {
2071 struct snd_kcontrol_new *knew;
2072 for (knew = alc_beep_mixer; knew->name; knew++) {
2073 struct snd_kcontrol *kctl;
2074 kctl = snd_ctl_new1(knew, codec);
2077 kctl->private_value = spec->beep_amp;
2078 err = snd_hda_ctl_add(codec, kctl);
2084 /* if we have no master control, let's create it */
2085 if (!spec->no_analog &&
2086 !snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
2087 unsigned int vmaster_tlv[4];
2088 snd_hda_set_vmaster_tlv(codec, spec->vmaster_nid,
2089 HDA_OUTPUT, vmaster_tlv);
2090 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
2091 vmaster_tlv, alc_slave_vols);
2095 if (!spec->no_analog &&
2096 !snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
2097 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
2098 NULL, alc_slave_sws);
2103 alc_free_kctls(codec); /* no longer needed */
2109 * initialize the codec volumes, etc
2113 * generic initialization of ADC, input mixers and output mixers
2115 static struct hda_verb alc880_volume_init_verbs[] = {
2117 * Unmute ADC0-2 and set the default input to mic-in
2119 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
2120 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2121 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
2122 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2123 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
2124 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2126 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
2128 * Note: PASD motherboards uses the Line In 2 as the input for front
2131 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
2132 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2133 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2134 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
2135 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
2136 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
2137 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
2138 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
2141 * Set up output mixers (0x0c - 0x0f)
2143 /* set vol=0 to output mixers */
2144 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2145 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2146 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2147 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2148 /* set up input amps for analog loopback */
2149 /* Amp Indices: DAC = 0, mixer = 1 */
2150 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2151 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2152 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2153 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2154 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2155 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2156 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2157 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2163 * 3-stack pin configuration:
2164 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
2166 static struct hda_verb alc880_pin_3stack_init_verbs[] = {
2168 * preset connection lists of input pins
2169 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
2171 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
2172 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2173 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
2176 * Set pin mode and muting
2178 /* set front pin widgets 0x14 for output */
2179 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2180 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2181 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2182 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2183 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2184 /* Mic2 (as headphone out) for HP output */
2185 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2186 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2187 /* Line In pin widget for input */
2188 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2189 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2190 /* Line2 (as front mic) pin widget for input and vref at 80% */
2191 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2192 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2193 /* CD pin widget for input */
2194 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2200 * 5-stack pin configuration:
2201 * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
2202 * line-in/side = 0x1a, f-mic = 0x1b
2204 static struct hda_verb alc880_pin_5stack_init_verbs[] = {
2206 * preset connection lists of input pins
2207 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
2209 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2210 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
2213 * Set pin mode and muting
2215 /* set pin widgets 0x14-0x17 for output */
2216 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2217 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2218 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2219 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2220 /* unmute pins for output (no gain on this amp) */
2221 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2222 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2223 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2224 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2226 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2227 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2228 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2229 /* Mic2 (as headphone out) for HP output */
2230 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2231 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2232 /* Line In pin widget for input */
2233 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2234 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2235 /* Line2 (as front mic) pin widget for input and vref at 80% */
2236 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2237 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2238 /* CD pin widget for input */
2239 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2245 * W810 pin configuration:
2246 * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
2248 static struct hda_verb alc880_pin_w810_init_verbs[] = {
2249 /* hphone/speaker input selector: front DAC */
2250 {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
2252 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2253 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2254 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2255 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2256 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2257 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2259 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2260 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2266 * Z71V pin configuration:
2267 * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
2269 static struct hda_verb alc880_pin_z71v_init_verbs[] = {
2270 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2271 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2272 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2273 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2275 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2276 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2277 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2278 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2284 * 6-stack pin configuration:
2285 * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18,
2286 * f-mic = 0x19, line = 0x1a, HP = 0x1b
2288 static struct hda_verb alc880_pin_6stack_init_verbs[] = {
2289 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2291 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2292 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2293 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2294 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2295 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2296 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2297 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2298 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2300 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2301 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2302 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2303 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2304 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2305 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2306 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2307 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2308 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2314 * Uniwill pin configuration:
2315 * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19,
2318 static struct hda_verb alc880_uniwill_init_verbs[] = {
2319 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2321 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2322 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2323 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2324 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2325 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2326 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2327 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2328 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2329 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2330 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2331 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2332 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2333 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2334 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2336 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2337 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2338 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2339 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2340 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2341 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2342 /* {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, */
2343 /* {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
2344 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2346 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
2347 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
2354 * HP = 0x14, InternalSpeaker = 0x15, mic = 0x19,
2356 static struct hda_verb alc880_uniwill_p53_init_verbs[] = {
2357 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2359 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2360 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2361 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2362 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2363 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2364 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2365 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2366 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2367 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2368 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2369 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2370 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2372 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2373 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2374 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2375 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2376 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2377 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2379 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
2380 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_DCVOL_EVENT},
2385 static struct hda_verb alc880_beep_init_verbs[] = {
2386 { 0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5) },
2390 /* toggle speaker-output according to the hp-jack state */
2391 static void alc880_uniwill_hp_automute(struct hda_codec *codec)
2393 unsigned int present;
2396 present = snd_hda_codec_read(codec, 0x14, 0,
2397 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
2398 bits = present ? HDA_AMP_MUTE : 0;
2399 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
2400 HDA_AMP_MUTE, bits);
2401 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
2402 HDA_AMP_MUTE, bits);
2405 /* auto-toggle front mic */
2406 static void alc880_uniwill_mic_automute(struct hda_codec *codec)
2408 unsigned int present;
2411 present = snd_hda_codec_read(codec, 0x18, 0,
2412 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
2413 bits = present ? HDA_AMP_MUTE : 0;
2414 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
2417 static void alc880_uniwill_automute(struct hda_codec *codec)
2419 alc880_uniwill_hp_automute(codec);
2420 alc880_uniwill_mic_automute(codec);
2423 static void alc880_uniwill_unsol_event(struct hda_codec *codec,
2426 /* Looks like the unsol event is incompatible with the standard
2427 * definition. 4bit tag is placed at 28 bit!
2429 switch (res >> 28) {
2430 case ALC880_HP_EVENT:
2431 alc880_uniwill_hp_automute(codec);
2433 case ALC880_MIC_EVENT:
2434 alc880_uniwill_mic_automute(codec);
2439 static void alc880_uniwill_p53_hp_automute(struct hda_codec *codec)
2441 unsigned int present;
2444 present = snd_hda_codec_read(codec, 0x14, 0,
2445 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
2446 bits = present ? HDA_AMP_MUTE : 0;
2447 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, HDA_AMP_MUTE, bits);
2450 static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec)
2452 unsigned int present;
2454 present = snd_hda_codec_read(codec, 0x21, 0,
2455 AC_VERB_GET_VOLUME_KNOB_CONTROL, 0);
2456 present &= HDA_AMP_VOLMASK;
2457 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0,
2458 HDA_AMP_VOLMASK, present);
2459 snd_hda_codec_amp_stereo(codec, 0x0d, HDA_OUTPUT, 0,
2460 HDA_AMP_VOLMASK, present);
2463 static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec,
2466 /* Looks like the unsol event is incompatible with the standard
2467 * definition. 4bit tag is placed at 28 bit!
2469 if ((res >> 28) == ALC880_HP_EVENT)
2470 alc880_uniwill_p53_hp_automute(codec);
2471 if ((res >> 28) == ALC880_DCVOL_EVENT)
2472 alc880_uniwill_p53_dcvol_automute(codec);
2476 * F1734 pin configuration:
2477 * HP = 0x14, speaker-out = 0x15, mic = 0x18
2479 static struct hda_verb alc880_pin_f1734_init_verbs[] = {
2480 {0x07, AC_VERB_SET_CONNECT_SEL, 0x01},
2481 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
2482 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
2483 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
2484 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
2486 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2487 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2488 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2489 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2491 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2492 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2493 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
2494 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2495 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2496 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2497 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2498 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2499 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2501 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
2502 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_DCVOL_EVENT},
2508 * ASUS pin configuration:
2509 * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
2511 static struct hda_verb alc880_pin_asus_init_verbs[] = {
2512 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
2513 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
2514 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
2515 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
2517 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2518 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2519 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2520 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2521 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2522 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2523 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2524 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2526 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2527 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2528 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2529 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2530 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2531 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2532 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2533 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2534 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2539 /* Enable GPIO mask and set output */
2540 #define alc880_gpio1_init_verbs alc_gpio1_init_verbs
2541 #define alc880_gpio2_init_verbs alc_gpio2_init_verbs
2543 /* Clevo m520g init */
2544 static struct hda_verb alc880_pin_clevo_init_verbs[] = {
2545 /* headphone output */
2546 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
2548 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2549 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2551 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2552 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2554 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2555 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2556 /* Mic1 (rear panel) */
2557 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2558 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2559 /* Mic2 (front panel) */
2560 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2561 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2563 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2564 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2565 /* change to EAPD mode */
2566 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2567 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
2572 static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
2573 /* change to EAPD mode */
2574 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2575 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
2577 /* Headphone output */
2578 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2580 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2581 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
2583 /* Line In pin widget for input */
2584 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2585 /* CD pin widget for input */
2586 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2587 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2588 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2590 /* change to EAPD mode */
2591 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2592 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
2598 * LG m1 express dual
2601 * Rear Line-In/Out (blue): 0x14
2602 * Build-in Mic-In: 0x15
2604 * HP-Out (green): 0x1b
2605 * Mic-In/Out (red): 0x19
2609 /* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
2610 static hda_nid_t alc880_lg_dac_nids[3] = {
2614 /* seems analog CD is not working */
2615 static struct hda_input_mux alc880_lg_capture_source = {
2620 { "Internal Mic", 0x6 },
2624 /* 2,4,6 channel modes */
2625 static struct hda_verb alc880_lg_ch2_init[] = {
2626 /* set line-in and mic-in to input */
2627 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
2628 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
2632 static struct hda_verb alc880_lg_ch4_init[] = {
2633 /* set line-in to out and mic-in to input */
2634 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
2635 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
2639 static struct hda_verb alc880_lg_ch6_init[] = {
2640 /* set line-in and mic-in to output */
2641 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
2642 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
2646 static struct hda_channel_mode alc880_lg_ch_modes[3] = {
2647 { 2, alc880_lg_ch2_init },
2648 { 4, alc880_lg_ch4_init },
2649 { 6, alc880_lg_ch6_init },
2652 static struct snd_kcontrol_new alc880_lg_mixer[] = {
2653 HDA_CODEC_VOLUME("Front Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
2654 HDA_BIND_MUTE("Front Playback Switch", 0x0f, 2, HDA_INPUT),
2655 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2656 HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
2657 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
2658 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
2659 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
2660 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
2661 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2662 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
2663 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
2664 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
2665 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
2666 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
2668 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2669 .name = "Channel Mode",
2670 .info = alc_ch_mode_info,
2671 .get = alc_ch_mode_get,
2672 .put = alc_ch_mode_put,
2677 static struct hda_verb alc880_lg_init_verbs[] = {
2678 /* set capture source to mic-in */
2679 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2680 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2681 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2682 /* mute all amp mixer inputs */
2683 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
2684 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
2685 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
2686 /* line-in to input */
2687 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2688 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2690 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2691 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2693 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2694 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2695 /* mic-in to input */
2696 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
2697 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2698 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2700 {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
2701 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2702 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2704 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
2708 /* toggle speaker-output according to the hp-jack state */
2709 static void alc880_lg_automute(struct hda_codec *codec)
2711 unsigned int present;
2714 present = snd_hda_codec_read(codec, 0x1b, 0,
2715 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
2716 bits = present ? HDA_AMP_MUTE : 0;
2717 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
2718 HDA_AMP_MUTE, bits);
2721 static void alc880_lg_unsol_event(struct hda_codec *codec, unsigned int res)
2723 /* Looks like the unsol event is incompatible with the standard
2724 * definition. 4bit tag is placed at 28 bit!
2726 if ((res >> 28) == 0x01)
2727 alc880_lg_automute(codec);
2736 * Built-in Mic-In: 0x19
2742 static struct hda_input_mux alc880_lg_lw_capture_source = {
2746 { "Internal Mic", 0x1 },
2751 #define alc880_lg_lw_modes alc880_threestack_modes
2753 static struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
2754 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2755 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2756 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
2757 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
2758 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2759 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2760 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2761 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2762 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2763 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2764 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2765 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2766 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
2767 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
2769 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2770 .name = "Channel Mode",
2771 .info = alc_ch_mode_info,
2772 .get = alc_ch_mode_get,
2773 .put = alc_ch_mode_put,
2778 static struct hda_verb alc880_lg_lw_init_verbs[] = {
2779 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2780 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
2781 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
2783 /* set capture source to mic-in */
2784 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2785 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2786 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2787 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
2789 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2790 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2792 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2793 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2794 /* mic-in to input */
2795 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2796 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2798 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2799 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2801 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
2805 /* toggle speaker-output according to the hp-jack state */
2806 static void alc880_lg_lw_automute(struct hda_codec *codec)
2808 unsigned int present;
2811 present = snd_hda_codec_read(codec, 0x1b, 0,
2812 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
2813 bits = present ? HDA_AMP_MUTE : 0;
2814 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
2815 HDA_AMP_MUTE, bits);
2818 static void alc880_lg_lw_unsol_event(struct hda_codec *codec, unsigned int res)
2820 /* Looks like the unsol event is incompatible with the standard
2821 * definition. 4bit tag is placed at 28 bit!
2823 if ((res >> 28) == 0x01)
2824 alc880_lg_lw_automute(codec);
2827 static struct snd_kcontrol_new alc880_medion_rim_mixer[] = {
2828 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2829 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
2830 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2831 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2832 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2833 HDA_CODEC_MUTE("Internal Playback Switch", 0x0b, 0x1, HDA_INPUT),
2837 static struct hda_input_mux alc880_medion_rim_capture_source = {
2841 { "Internal Mic", 0x1 },
2845 static struct hda_verb alc880_medion_rim_init_verbs[] = {
2846 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2848 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2849 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2851 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2852 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2853 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2854 /* Mic2 (as headphone out) for HP output */
2855 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2856 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2857 /* Internal Speaker */
2858 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2859 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2861 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2862 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
2864 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
2868 /* toggle speaker-output according to the hp-jack state */
2869 static void alc880_medion_rim_automute(struct hda_codec *codec)
2871 unsigned int present;
2874 present = snd_hda_codec_read(codec, 0x14, 0,
2875 AC_VERB_GET_PIN_SENSE, 0)
2876 & AC_PINSENSE_PRESENCE;
2877 bits = present ? HDA_AMP_MUTE : 0;
2878 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
2879 HDA_AMP_MUTE, bits);
2881 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 0);
2883 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 2);
2886 static void alc880_medion_rim_unsol_event(struct hda_codec *codec,
2889 /* Looks like the unsol event is incompatible with the standard
2890 * definition. 4bit tag is placed at 28 bit!
2892 if ((res >> 28) == ALC880_HP_EVENT)
2893 alc880_medion_rim_automute(codec);
2896 #ifdef CONFIG_SND_HDA_POWER_SAVE
2897 static struct hda_amp_list alc880_loopbacks[] = {
2898 { 0x0b, HDA_INPUT, 0 },
2899 { 0x0b, HDA_INPUT, 1 },
2900 { 0x0b, HDA_INPUT, 2 },
2901 { 0x0b, HDA_INPUT, 3 },
2902 { 0x0b, HDA_INPUT, 4 },
2906 static struct hda_amp_list alc880_lg_loopbacks[] = {
2907 { 0x0b, HDA_INPUT, 1 },
2908 { 0x0b, HDA_INPUT, 6 },
2909 { 0x0b, HDA_INPUT, 7 },
2918 static int alc_init(struct hda_codec *codec)
2920 struct alc_spec *spec = codec->spec;
2924 if (codec->vendor_id == 0x10ec0888)
2925 alc888_coef_init(codec);
2927 for (i = 0; i < spec->num_init_verbs; i++)
2928 snd_hda_sequence_write(codec, spec->init_verbs[i]);
2930 if (spec->init_hook)
2931 spec->init_hook(codec);
2936 static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
2938 struct alc_spec *spec = codec->spec;
2940 if (spec->unsol_event)
2941 spec->unsol_event(codec, res);
2944 #ifdef CONFIG_SND_HDA_POWER_SAVE
2945 static int alc_check_power_status(struct hda_codec *codec, hda_nid_t nid)
2947 struct alc_spec *spec = codec->spec;
2948 return snd_hda_check_amp_list_power(codec, &spec->loopback, nid);
2953 * Analog playback callbacks
2955 static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
2956 struct hda_codec *codec,
2957 struct snd_pcm_substream *substream)
2959 struct alc_spec *spec = codec->spec;
2960 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
2964 static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2965 struct hda_codec *codec,
2966 unsigned int stream_tag,
2967 unsigned int format,
2968 struct snd_pcm_substream *substream)
2970 struct alc_spec *spec = codec->spec;
2971 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
2972 stream_tag, format, substream);
2975 static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
2976 struct hda_codec *codec,
2977 struct snd_pcm_substream *substream)
2979 struct alc_spec *spec = codec->spec;
2980 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
2986 static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
2987 struct hda_codec *codec,
2988 struct snd_pcm_substream *substream)
2990 struct alc_spec *spec = codec->spec;
2991 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
2994 static int alc880_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2995 struct hda_codec *codec,
2996 unsigned int stream_tag,
2997 unsigned int format,
2998 struct snd_pcm_substream *substream)
3000 struct alc_spec *spec = codec->spec;
3001 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
3002 stream_tag, format, substream);
3005 static int alc880_dig_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
3006 struct hda_codec *codec,
3007 struct snd_pcm_substream *substream)
3009 struct alc_spec *spec = codec->spec;
3010 return snd_hda_multi_out_dig_cleanup(codec, &spec->multiout);
3013 static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
3014 struct hda_codec *codec,
3015 struct snd_pcm_substream *substream)
3017 struct alc_spec *spec = codec->spec;
3018 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
3024 static int alc880_alt_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
3025 struct hda_codec *codec,
3026 unsigned int stream_tag,
3027 unsigned int format,
3028 struct snd_pcm_substream *substream)
3030 struct alc_spec *spec = codec->spec;
3032 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number + 1],
3033 stream_tag, 0, format);
3037 static int alc880_alt_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
3038 struct hda_codec *codec,
3039 struct snd_pcm_substream *substream)
3041 struct alc_spec *spec = codec->spec;
3043 snd_hda_codec_cleanup_stream(codec,
3044 spec->adc_nids[substream->number + 1]);
3051 static struct hda_pcm_stream alc880_pcm_analog_playback = {
3055 /* NID is set in alc_build_pcms */
3057 .open = alc880_playback_pcm_open,
3058 .prepare = alc880_playback_pcm_prepare,
3059 .cleanup = alc880_playback_pcm_cleanup
3063 static struct hda_pcm_stream alc880_pcm_analog_capture = {
3067 /* NID is set in alc_build_pcms */
3070 static struct hda_pcm_stream alc880_pcm_analog_alt_playback = {
3074 /* NID is set in alc_build_pcms */
3077 static struct hda_pcm_stream alc880_pcm_analog_alt_capture = {
3078 .substreams = 2, /* can be overridden */
3081 /* NID is set in alc_build_pcms */
3083 .prepare = alc880_alt_capture_pcm_prepare,
3084 .cleanup = alc880_alt_capture_pcm_cleanup
3088 static struct hda_pcm_stream alc880_pcm_digital_playback = {
3092 /* NID is set in alc_build_pcms */
3094 .open = alc880_dig_playback_pcm_open,
3095 .close = alc880_dig_playback_pcm_close,
3096 .prepare = alc880_dig_playback_pcm_prepare,
3097 .cleanup = alc880_dig_playback_pcm_cleanup
3101 static struct hda_pcm_stream alc880_pcm_digital_capture = {
3105 /* NID is set in alc_build_pcms */
3108 /* Used by alc_build_pcms to flag that a PCM has no playback stream */
3109 static struct hda_pcm_stream alc_pcm_null_stream = {
3115 static int alc_build_pcms(struct hda_codec *codec)
3117 struct alc_spec *spec = codec->spec;
3118 struct hda_pcm *info = spec->pcm_rec;
3121 codec->num_pcms = 1;
3122 codec->pcm_info = info;
3124 if (spec->no_analog)
3127 info->name = spec->stream_name_analog;
3128 if (spec->stream_analog_playback) {
3129 if (snd_BUG_ON(!spec->multiout.dac_nids))
3131 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
3132 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
3134 if (spec->stream_analog_capture) {
3135 if (snd_BUG_ON(!spec->adc_nids))
3137 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
3138 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
3141 if (spec->channel_mode) {
3142 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
3143 for (i = 0; i < spec->num_channel_mode; i++) {
3144 if (spec->channel_mode[i].channels &g