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 if (!(ass & 1) && !(ass & 0x100000))
1029 if ((ass >> 30) != 1) /* no physical connection */
1034 for (i = 1; i < 16; i++) {
1038 if (((ass >> 16) & 0xf) != tmp)
1044 * 2 : 0 --> Desktop, 1 --> Laptop
1045 * 3~5 : External Amplifier control
1048 tmp = (ass & 0x38) >> 3; /* external Amp control */
1051 snd_hda_sequence_write(codec, alc_gpio1_init_verbs);
1054 snd_hda_sequence_write(codec, alc_gpio2_init_verbs);
1057 snd_hda_sequence_write(codec, alc_gpio3_init_verbs);
1059 case 5: /* set EAPD output high */
1060 switch (codec->vendor_id) {
1062 snd_hda_codec_write(codec, 0x0f, 0,
1063 AC_VERB_SET_EAPD_BTLENABLE, 2);
1064 snd_hda_codec_write(codec, 0x10, 0,
1065 AC_VERB_SET_EAPD_BTLENABLE, 2);
1077 snd_hda_codec_write(codec, 0x14, 0,
1078 AC_VERB_SET_EAPD_BTLENABLE, 2);
1079 snd_hda_codec_write(codec, 0x15, 0,
1080 AC_VERB_SET_EAPD_BTLENABLE, 2);
1083 switch (codec->vendor_id) {
1085 snd_hda_codec_write(codec, 0x1a, 0,
1086 AC_VERB_SET_COEF_INDEX, 7);
1087 tmp = snd_hda_codec_read(codec, 0x1a, 0,
1088 AC_VERB_GET_PROC_COEF, 0);
1089 snd_hda_codec_write(codec, 0x1a, 0,
1090 AC_VERB_SET_COEF_INDEX, 7);
1091 snd_hda_codec_write(codec, 0x1a, 0,
1092 AC_VERB_SET_PROC_COEF,
1102 snd_hda_codec_write(codec, 0x20, 0,
1103 AC_VERB_SET_COEF_INDEX, 7);
1104 tmp = snd_hda_codec_read(codec, 0x20, 0,
1105 AC_VERB_GET_PROC_COEF, 0);
1106 snd_hda_codec_write(codec, 0x20, 0,
1107 AC_VERB_SET_COEF_INDEX, 7);
1108 snd_hda_codec_write(codec, 0x20, 0,
1109 AC_VERB_SET_PROC_COEF,
1113 /*alc888_coef_init(codec);*/ /* called in alc_init() */
1117 snd_hda_codec_write(codec, 0x20, 0,
1118 AC_VERB_SET_COEF_INDEX, 7);
1119 tmp = snd_hda_codec_read(codec, 0x20, 0,
1120 AC_VERB_GET_PROC_COEF, 0);
1121 snd_hda_codec_write(codec, 0x20, 0,
1122 AC_VERB_SET_COEF_INDEX, 7);
1123 snd_hda_codec_write(codec, 0x20, 0,
1124 AC_VERB_SET_PROC_COEF,
1132 /* is laptop or Desktop and enable the function "Mute internal speaker
1133 * when the external headphone out jack is plugged"
1135 if (!(ass & 0x8000))
1138 * 10~8 : Jack location
1139 * 12~11: Headphone out -> 00: PortA, 01: PortE, 02: PortD, 03: Resvered
1141 * 15 : 1 --> enable the function "Mute internal speaker
1142 * when the external headphone out jack is plugged"
1144 if (!spec->autocfg.speaker_pins[0]) {
1145 if (spec->autocfg.line_out_pins[0])
1146 spec->autocfg.speaker_pins[0] =
1147 spec->autocfg.line_out_pins[0];
1152 if (!spec->autocfg.hp_pins[0]) {
1153 tmp = (ass >> 11) & 0x3; /* HP to chassis */
1155 spec->autocfg.hp_pins[0] = porta;
1157 spec->autocfg.hp_pins[0] = porte;
1159 spec->autocfg.hp_pins[0] = portd;
1163 if (spec->autocfg.hp_pins[0])
1164 snd_hda_codec_write(codec, spec->autocfg.hp_pins[0], 0,
1165 AC_VERB_SET_UNSOLICITED_ENABLE,
1166 AC_USRSP_EN | ALC880_HP_EVENT);
1168 #if 0 /* it's broken in some acses -- temporarily disabled */
1169 if (spec->autocfg.input_pins[AUTO_PIN_MIC] &&
1170 spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC])
1171 snd_hda_codec_write(codec,
1172 spec->autocfg.input_pins[AUTO_PIN_MIC], 0,
1173 AC_VERB_SET_UNSOLICITED_ENABLE,
1174 AC_USRSP_EN | ALC880_MIC_EVENT);
1175 #endif /* disabled */
1177 spec->unsol_event = alc_sku_unsol_event;
1181 * Fix-up pin default configurations
1189 static void alc_fix_pincfg(struct hda_codec *codec,
1190 const struct snd_pci_quirk *quirk,
1191 const struct alc_pincfg **pinfix)
1193 const struct alc_pincfg *cfg;
1195 quirk = snd_pci_quirk_lookup(codec->bus->pci, quirk);
1199 cfg = pinfix[quirk->value];
1200 for (; cfg->nid; cfg++)
1201 snd_hda_codec_set_pincfg(codec, cfg->nid, cfg->val);
1211 static struct hda_verb alc888_4ST_ch2_intel_init[] = {
1212 /* Mic-in jack as mic in */
1213 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1214 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1215 /* Line-in jack as Line in */
1216 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1217 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1218 /* Line-Out as Front */
1219 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
1226 static struct hda_verb alc888_4ST_ch4_intel_init[] = {
1227 /* Mic-in jack as mic in */
1228 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1229 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1230 /* Line-in jack as Surround */
1231 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1232 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1233 /* Line-Out as Front */
1234 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
1241 static struct hda_verb alc888_4ST_ch6_intel_init[] = {
1242 /* Mic-in jack as CLFE */
1243 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1244 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1245 /* Line-in jack as Surround */
1246 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1247 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1248 /* Line-Out as CLFE (workaround because Mic-in is not loud enough) */
1249 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1256 static struct hda_verb alc888_4ST_ch8_intel_init[] = {
1257 /* Mic-in jack as CLFE */
1258 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1259 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1260 /* Line-in jack as Surround */
1261 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1262 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1263 /* Line-Out as Side */
1264 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1268 static struct hda_channel_mode alc888_4ST_8ch_intel_modes[4] = {
1269 { 2, alc888_4ST_ch2_intel_init },
1270 { 4, alc888_4ST_ch4_intel_init },
1271 { 6, alc888_4ST_ch6_intel_init },
1272 { 8, alc888_4ST_ch8_intel_init },
1276 * ALC888 Fujitsu Siemens Amillo xa3530
1279 static struct hda_verb alc888_fujitsu_xa3530_verbs[] = {
1280 /* Front Mic: set to PIN_IN (empty by default) */
1281 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1282 /* Connect Internal HP to Front */
1283 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1284 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1285 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1286 /* Connect Bass HP to Front */
1287 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1288 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1289 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1290 /* Connect Line-Out side jack (SPDIF) to Side */
1291 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1292 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1293 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1294 /* Connect Mic jack to CLFE */
1295 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1296 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1297 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02},
1298 /* Connect Line-in jack to Surround */
1299 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1300 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1301 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
1302 /* Connect HP out jack to Front */
1303 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1304 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1305 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
1306 /* Enable unsolicited event for HP jack and Line-out jack */
1307 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1308 {0x17, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1312 static void alc888_fujitsu_xa3530_automute(struct hda_codec *codec)
1314 unsigned int present;
1316 /* Line out presence */
1317 present = snd_hda_codec_read(codec, 0x17, 0,
1318 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1319 /* HP out presence */
1320 present = present || snd_hda_codec_read(codec, 0x1b, 0,
1321 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1322 bits = present ? HDA_AMP_MUTE : 0;
1323 /* Toggle internal speakers muting */
1324 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
1325 HDA_AMP_MUTE, bits);
1326 /* Toggle internal bass muting */
1327 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
1328 HDA_AMP_MUTE, bits);
1331 static void alc888_fujitsu_xa3530_unsol_event(struct hda_codec *codec,
1334 if (res >> 26 == ALC880_HP_EVENT)
1335 alc888_fujitsu_xa3530_automute(codec);
1340 * ALC888 Acer Aspire 4930G model
1343 static struct hda_verb alc888_acer_aspire_4930g_verbs[] = {
1344 /* Front Mic: set to PIN_IN (empty by default) */
1345 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1346 /* Unselect Front Mic by default in input mixer 3 */
1347 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
1348 /* Enable unsolicited event for HP jack */
1349 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1350 /* Connect Internal HP to front */
1351 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1352 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1353 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1354 /* Connect HP out to front */
1355 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1356 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1357 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1361 static struct hda_input_mux alc888_2_capture_sources[2] = {
1362 /* Front mic only available on one ADC */
1369 { "Front Mic", 0xb },
1382 static struct snd_kcontrol_new alc888_base_mixer[] = {
1383 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1384 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1385 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1386 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
1387 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
1389 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1390 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1391 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1392 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
1393 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
1394 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1395 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1396 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1397 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1398 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1399 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
1400 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1404 static void alc888_acer_aspire_4930g_automute(struct hda_codec *codec)
1406 unsigned int present;
1408 present = snd_hda_codec_read(codec, 0x15, 0,
1409 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1410 bits = present ? HDA_AMP_MUTE : 0;
1411 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
1412 HDA_AMP_MUTE, bits);
1415 static void alc888_acer_aspire_4930g_unsol_event(struct hda_codec *codec,
1418 if (res >> 26 == ALC880_HP_EVENT)
1419 alc888_acer_aspire_4930g_automute(codec);
1423 * ALC880 3-stack model
1425 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
1426 * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18,
1427 * F-Mic = 0x1b, HP = 0x19
1430 static hda_nid_t alc880_dac_nids[4] = {
1431 /* front, rear, clfe, rear_surr */
1432 0x02, 0x05, 0x04, 0x03
1435 static hda_nid_t alc880_adc_nids[3] = {
1440 /* The datasheet says the node 0x07 is connected from inputs,
1441 * but it shows zero connection in the real implementation on some devices.
1442 * Note: this is a 915GAV bug, fixed on 915GLV
1444 static hda_nid_t alc880_adc_nids_alt[2] = {
1449 #define ALC880_DIGOUT_NID 0x06
1450 #define ALC880_DIGIN_NID 0x0a
1452 static struct hda_input_mux alc880_capture_source = {
1456 { "Front Mic", 0x3 },
1462 /* channel source setting (2/6 channel selection for 3-stack) */
1464 static struct hda_verb alc880_threestack_ch2_init[] = {
1465 /* set line-in to input, mute it */
1466 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1467 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1468 /* set mic-in to input vref 80%, mute it */
1469 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1470 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1475 static struct hda_verb alc880_threestack_ch6_init[] = {
1476 /* set line-in to output, unmute it */
1477 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1478 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1479 /* set mic-in to output, unmute it */
1480 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1481 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1485 static struct hda_channel_mode alc880_threestack_modes[2] = {
1486 { 2, alc880_threestack_ch2_init },
1487 { 6, alc880_threestack_ch6_init },
1490 static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
1491 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1492 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1493 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
1494 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
1495 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1496 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1497 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1498 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1499 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1500 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1501 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1502 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1503 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1504 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1505 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
1506 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
1507 HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
1509 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1510 .name = "Channel Mode",
1511 .info = alc_ch_mode_info,
1512 .get = alc_ch_mode_get,
1513 .put = alc_ch_mode_put,
1518 /* capture mixer elements */
1519 static int alc_cap_vol_info(struct snd_kcontrol *kcontrol,
1520 struct snd_ctl_elem_info *uinfo)
1522 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1523 struct alc_spec *spec = codec->spec;
1526 mutex_lock(&codec->control_mutex);
1527 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0,
1529 err = snd_hda_mixer_amp_volume_info(kcontrol, uinfo);
1530 mutex_unlock(&codec->control_mutex);
1534 static int alc_cap_vol_tlv(struct snd_kcontrol *kcontrol, int op_flag,
1535 unsigned int size, unsigned int __user *tlv)
1537 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1538 struct alc_spec *spec = codec->spec;
1541 mutex_lock(&codec->control_mutex);
1542 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0,
1544 err = snd_hda_mixer_amp_tlv(kcontrol, op_flag, size, tlv);
1545 mutex_unlock(&codec->control_mutex);
1549 typedef int (*getput_call_t)(struct snd_kcontrol *kcontrol,
1550 struct snd_ctl_elem_value *ucontrol);
1552 static int alc_cap_getput_caller(struct snd_kcontrol *kcontrol,
1553 struct snd_ctl_elem_value *ucontrol,
1556 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1557 struct alc_spec *spec = codec->spec;
1558 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
1561 mutex_lock(&codec->control_mutex);
1562 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[adc_idx],
1564 err = func(kcontrol, ucontrol);
1565 mutex_unlock(&codec->control_mutex);
1569 static int alc_cap_vol_get(struct snd_kcontrol *kcontrol,
1570 struct snd_ctl_elem_value *ucontrol)
1572 return alc_cap_getput_caller(kcontrol, ucontrol,
1573 snd_hda_mixer_amp_volume_get);
1576 static int alc_cap_vol_put(struct snd_kcontrol *kcontrol,
1577 struct snd_ctl_elem_value *ucontrol)
1579 return alc_cap_getput_caller(kcontrol, ucontrol,
1580 snd_hda_mixer_amp_volume_put);
1583 /* capture mixer elements */
1584 #define alc_cap_sw_info snd_ctl_boolean_stereo_info
1586 static int alc_cap_sw_get(struct snd_kcontrol *kcontrol,
1587 struct snd_ctl_elem_value *ucontrol)
1589 return alc_cap_getput_caller(kcontrol, ucontrol,
1590 snd_hda_mixer_amp_switch_get);
1593 static int alc_cap_sw_put(struct snd_kcontrol *kcontrol,
1594 struct snd_ctl_elem_value *ucontrol)
1596 return alc_cap_getput_caller(kcontrol, ucontrol,
1597 snd_hda_mixer_amp_switch_put);
1600 #define _DEFINE_CAPMIX(num) \
1602 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1603 .name = "Capture Switch", \
1604 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, \
1606 .info = alc_cap_sw_info, \
1607 .get = alc_cap_sw_get, \
1608 .put = alc_cap_sw_put, \
1611 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1612 .name = "Capture Volume", \
1613 .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE | \
1614 SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
1615 SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK), \
1617 .info = alc_cap_vol_info, \
1618 .get = alc_cap_vol_get, \
1619 .put = alc_cap_vol_put, \
1620 .tlv = { .c = alc_cap_vol_tlv }, \
1623 #define _DEFINE_CAPSRC(num) \
1625 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1626 /* .name = "Capture Source", */ \
1627 .name = "Input Source", \
1629 .info = alc_mux_enum_info, \
1630 .get = alc_mux_enum_get, \
1631 .put = alc_mux_enum_put, \
1634 #define DEFINE_CAPMIX(num) \
1635 static struct snd_kcontrol_new alc_capture_mixer ## num[] = { \
1636 _DEFINE_CAPMIX(num), \
1637 _DEFINE_CAPSRC(num), \
1641 #define DEFINE_CAPMIX_NOSRC(num) \
1642 static struct snd_kcontrol_new alc_capture_mixer_nosrc ## num[] = { \
1643 _DEFINE_CAPMIX(num), \
1647 /* up to three ADCs */
1651 DEFINE_CAPMIX_NOSRC(1);
1652 DEFINE_CAPMIX_NOSRC(2);
1653 DEFINE_CAPMIX_NOSRC(3);
1656 * ALC880 5-stack model
1658 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d),
1660 * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
1661 * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
1664 /* additional mixers to alc880_three_stack_mixer */
1665 static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
1666 HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1667 HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
1671 /* channel source setting (6/8 channel selection for 5-stack) */
1673 static struct hda_verb alc880_fivestack_ch6_init[] = {
1674 /* set line-in to input, mute it */
1675 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1676 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1681 static struct hda_verb alc880_fivestack_ch8_init[] = {
1682 /* set line-in to output, unmute it */
1683 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1684 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1688 static struct hda_channel_mode alc880_fivestack_modes[2] = {
1689 { 6, alc880_fivestack_ch6_init },
1690 { 8, alc880_fivestack_ch8_init },
1695 * ALC880 6-stack model
1697 * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e),
1698 * Side = 0x05 (0x0f)
1699 * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
1700 * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
1703 static hda_nid_t alc880_6st_dac_nids[4] = {
1704 /* front, rear, clfe, rear_surr */
1705 0x02, 0x03, 0x04, 0x05
1708 static struct hda_input_mux alc880_6stack_capture_source = {
1712 { "Front Mic", 0x1 },
1718 /* fixed 8-channels */
1719 static struct hda_channel_mode alc880_sixstack_modes[1] = {
1723 static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
1724 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1725 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1726 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1727 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
1728 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1729 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1730 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1731 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1732 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
1733 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
1734 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1735 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1736 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1737 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1738 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1739 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1740 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1741 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1743 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1744 .name = "Channel Mode",
1745 .info = alc_ch_mode_info,
1746 .get = alc_ch_mode_get,
1747 .put = alc_ch_mode_put,
1756 * W810 has rear IO for:
1759 * Center/LFE (DAC 04)
1762 * The system also has a pair of internal speakers, and a headphone jack.
1763 * These are both connected to Line2 on the codec, hence to DAC 02.
1765 * There is a variable resistor to control the speaker or headphone
1766 * volume. This is a hardware-only device without a software API.
1768 * Plugging headphones in will disable the internal speakers. This is
1769 * implemented in hardware, not via the driver using jack sense. In
1770 * a similar fashion, plugging into the rear socket marked "front" will
1771 * disable both the speakers and headphones.
1773 * For input, there's a microphone jack, and an "audio in" jack.
1774 * These may not do anything useful with this driver yet, because I
1775 * haven't setup any initialization verbs for these yet...
1778 static hda_nid_t alc880_w810_dac_nids[3] = {
1779 /* front, rear/surround, clfe */
1783 /* fixed 6 channels */
1784 static struct hda_channel_mode alc880_w810_modes[1] = {
1788 /* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
1789 static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
1790 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1791 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1792 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1793 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
1794 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1795 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1796 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1797 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1798 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
1806 * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
1807 * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?),
1811 static hda_nid_t alc880_z71v_dac_nids[1] = {
1814 #define ALC880_Z71V_HP_DAC 0x03
1816 /* fixed 2 channels */
1817 static struct hda_channel_mode alc880_2_jack_modes[1] = {
1821 static struct snd_kcontrol_new alc880_z71v_mixer[] = {
1822 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1823 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1824 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1825 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
1826 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1827 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1828 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1829 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1835 * ALC880 F1734 model
1837 * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
1838 * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
1841 static hda_nid_t alc880_f1734_dac_nids[1] = {
1844 #define ALC880_F1734_HP_DAC 0x02
1846 static struct snd_kcontrol_new alc880_f1734_mixer[] = {
1847 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1848 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
1849 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1850 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
1851 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1852 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1853 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1854 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1858 static struct hda_input_mux alc880_f1734_capture_source = {
1870 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
1871 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
1872 * Mic = 0x18, Line = 0x1a
1875 #define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
1876 #define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
1878 static struct snd_kcontrol_new alc880_asus_mixer[] = {
1879 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1880 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1881 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1882 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
1883 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1884 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1885 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1886 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1887 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1888 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1889 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1890 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1891 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1892 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1894 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1895 .name = "Channel Mode",
1896 .info = alc_ch_mode_info,
1897 .get = alc_ch_mode_get,
1898 .put = alc_ch_mode_put,
1904 * ALC880 ASUS W1V model
1906 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
1907 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
1908 * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
1911 /* additional mixers to alc880_asus_mixer */
1912 static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
1913 HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
1914 HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
1919 static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
1920 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1921 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
1922 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
1923 HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
1924 HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
1925 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
1926 HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
1927 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
1928 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
1933 static struct snd_kcontrol_new alc880_uniwill_mixer[] = {
1934 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1935 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
1936 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1937 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
1938 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1939 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1940 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1941 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1942 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1943 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1944 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1945 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1946 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1947 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1948 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1949 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1951 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1952 .name = "Channel Mode",
1953 .info = alc_ch_mode_info,
1954 .get = alc_ch_mode_get,
1955 .put = alc_ch_mode_put,
1960 static struct snd_kcontrol_new alc880_fujitsu_mixer[] = {
1961 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1962 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
1963 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1964 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
1965 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1966 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1967 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1968 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1969 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1970 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1974 static struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = {
1975 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1976 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
1977 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1978 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
1979 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1980 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1985 * virtual master controls
1989 * slave controls for virtual master
1991 static const char *alc_slave_vols[] = {
1992 "Front Playback Volume",
1993 "Surround Playback Volume",
1994 "Center Playback Volume",
1995 "LFE Playback Volume",
1996 "Side Playback Volume",
1997 "Headphone Playback Volume",
1998 "Speaker Playback Volume",
1999 "Mono Playback Volume",
2000 "Line-Out Playback Volume",
2001 "PCM Playback Volume",
2005 static const char *alc_slave_sws[] = {
2006 "Front Playback Switch",
2007 "Surround Playback Switch",
2008 "Center Playback Switch",
2009 "LFE Playback Switch",
2010 "Side Playback Switch",
2011 "Headphone Playback Switch",
2012 "Speaker Playback Switch",
2013 "Mono Playback Switch",
2014 "IEC958 Playback Switch",
2019 * build control elements
2022 static void alc_free_kctls(struct hda_codec *codec);
2024 /* additional beep mixers; the actual parameters are overwritten at build */
2025 static struct snd_kcontrol_new alc_beep_mixer[] = {
2026 HDA_CODEC_VOLUME("Beep Playback Volume", 0, 0, HDA_INPUT),
2027 HDA_CODEC_MUTE("Beep Playback Switch", 0, 0, HDA_INPUT),
2031 static int alc_build_controls(struct hda_codec *codec)
2033 struct alc_spec *spec = codec->spec;
2037 for (i = 0; i < spec->num_mixers; i++) {
2038 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
2042 if (spec->cap_mixer) {
2043 err = snd_hda_add_new_ctls(codec, spec->cap_mixer);
2047 if (spec->multiout.dig_out_nid) {
2048 err = snd_hda_create_spdif_out_ctls(codec,
2049 spec->multiout.dig_out_nid);
2052 if (!spec->no_analog) {
2053 err = snd_hda_create_spdif_share_sw(codec,
2057 spec->multiout.share_spdif = 1;
2060 if (spec->dig_in_nid) {
2061 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
2066 /* create beep controls if needed */
2067 if (spec->beep_amp) {
2068 struct snd_kcontrol_new *knew;
2069 for (knew = alc_beep_mixer; knew->name; knew++) {
2070 struct snd_kcontrol *kctl;
2071 kctl = snd_ctl_new1(knew, codec);
2074 kctl->private_value = spec->beep_amp;
2075 err = snd_hda_ctl_add(codec, kctl);
2081 /* if we have no master control, let's create it */
2082 if (!spec->no_analog &&
2083 !snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
2084 unsigned int vmaster_tlv[4];
2085 snd_hda_set_vmaster_tlv(codec, spec->vmaster_nid,
2086 HDA_OUTPUT, vmaster_tlv);
2087 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
2088 vmaster_tlv, alc_slave_vols);
2092 if (!spec->no_analog &&
2093 !snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
2094 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
2095 NULL, alc_slave_sws);
2100 alc_free_kctls(codec); /* no longer needed */
2106 * initialize the codec volumes, etc
2110 * generic initialization of ADC, input mixers and output mixers
2112 static struct hda_verb alc880_volume_init_verbs[] = {
2114 * Unmute ADC0-2 and set the default input to mic-in
2116 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
2117 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2118 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
2119 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2120 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
2121 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2123 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
2125 * Note: PASD motherboards uses the Line In 2 as the input for front
2128 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
2129 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2130 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2131 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
2132 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
2133 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
2134 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
2135 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
2138 * Set up output mixers (0x0c - 0x0f)
2140 /* set vol=0 to output mixers */
2141 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2142 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2143 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2144 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2145 /* set up input amps for analog loopback */
2146 /* Amp Indices: DAC = 0, mixer = 1 */
2147 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2148 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2149 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2150 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2151 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2152 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2153 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2154 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2160 * 3-stack pin configuration:
2161 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
2163 static struct hda_verb alc880_pin_3stack_init_verbs[] = {
2165 * preset connection lists of input pins
2166 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
2168 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
2169 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2170 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
2173 * Set pin mode and muting
2175 /* set front pin widgets 0x14 for output */
2176 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2177 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2178 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2179 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2180 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2181 /* Mic2 (as headphone out) for HP output */
2182 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2183 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2184 /* Line In pin widget for input */
2185 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2186 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2187 /* Line2 (as front mic) pin widget for input and vref at 80% */
2188 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2189 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2190 /* CD pin widget for input */
2191 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2197 * 5-stack pin configuration:
2198 * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
2199 * line-in/side = 0x1a, f-mic = 0x1b
2201 static struct hda_verb alc880_pin_5stack_init_verbs[] = {
2203 * preset connection lists of input pins
2204 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
2206 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2207 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
2210 * Set pin mode and muting
2212 /* set pin widgets 0x14-0x17 for output */
2213 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2214 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2215 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2216 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2217 /* unmute pins for output (no gain on this amp) */
2218 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2219 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2220 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2221 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2223 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2224 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2225 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2226 /* Mic2 (as headphone out) for HP output */
2227 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2228 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2229 /* Line In pin widget for input */
2230 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2231 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2232 /* Line2 (as front mic) pin widget for input and vref at 80% */
2233 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2234 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2235 /* CD pin widget for input */
2236 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2242 * W810 pin configuration:
2243 * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
2245 static struct hda_verb alc880_pin_w810_init_verbs[] = {
2246 /* hphone/speaker input selector: front DAC */
2247 {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
2249 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2250 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2251 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2252 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2253 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2254 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2256 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2257 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2263 * Z71V pin configuration:
2264 * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
2266 static struct hda_verb alc880_pin_z71v_init_verbs[] = {
2267 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2268 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2269 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2270 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2272 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2273 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2274 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2275 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2281 * 6-stack pin configuration:
2282 * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18,
2283 * f-mic = 0x19, line = 0x1a, HP = 0x1b
2285 static struct hda_verb alc880_pin_6stack_init_verbs[] = {
2286 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2288 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2289 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2290 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2291 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2292 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2293 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2294 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2295 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2297 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2298 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2299 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2300 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2301 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2302 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2303 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2304 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2305 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2311 * Uniwill pin configuration:
2312 * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19,
2315 static struct hda_verb alc880_uniwill_init_verbs[] = {
2316 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2318 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2319 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2320 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2321 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2322 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2323 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2324 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2325 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2326 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2327 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2328 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2329 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2330 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2331 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2333 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2334 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2335 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2336 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2337 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2338 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2339 /* {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, */
2340 /* {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
2341 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2343 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
2344 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
2351 * HP = 0x14, InternalSpeaker = 0x15, mic = 0x19,
2353 static struct hda_verb alc880_uniwill_p53_init_verbs[] = {
2354 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2356 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2357 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2358 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2359 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2360 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2361 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2362 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2363 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2364 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2365 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2366 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2367 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2369 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2370 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2371 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2372 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2373 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2374 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2376 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
2377 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_DCVOL_EVENT},
2382 static struct hda_verb alc880_beep_init_verbs[] = {
2383 { 0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5) },
2387 /* toggle speaker-output according to the hp-jack state */
2388 static void alc880_uniwill_hp_automute(struct hda_codec *codec)
2390 unsigned int present;
2393 present = snd_hda_codec_read(codec, 0x14, 0,
2394 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
2395 bits = present ? HDA_AMP_MUTE : 0;
2396 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
2397 HDA_AMP_MUTE, bits);
2398 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
2399 HDA_AMP_MUTE, bits);
2402 /* auto-toggle front mic */
2403 static void alc880_uniwill_mic_automute(struct hda_codec *codec)
2405 unsigned int present;
2408 present = snd_hda_codec_read(codec, 0x18, 0,
2409 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
2410 bits = present ? HDA_AMP_MUTE : 0;
2411 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
2414 static void alc880_uniwill_automute(struct hda_codec *codec)
2416 alc880_uniwill_hp_automute(codec);
2417 alc880_uniwill_mic_automute(codec);
2420 static void alc880_uniwill_unsol_event(struct hda_codec *codec,
2423 /* Looks like the unsol event is incompatible with the standard
2424 * definition. 4bit tag is placed at 28 bit!
2426 switch (res >> 28) {
2427 case ALC880_HP_EVENT:
2428 alc880_uniwill_hp_automute(codec);
2430 case ALC880_MIC_EVENT:
2431 alc880_uniwill_mic_automute(codec);
2436 static void alc880_uniwill_p53_hp_automute(struct hda_codec *codec)
2438 unsigned int present;
2441 present = snd_hda_codec_read(codec, 0x14, 0,
2442 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
2443 bits = present ? HDA_AMP_MUTE : 0;
2444 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, HDA_AMP_MUTE, bits);
2447 static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec)
2449 unsigned int present;
2451 present = snd_hda_codec_read(codec, 0x21, 0,
2452 AC_VERB_GET_VOLUME_KNOB_CONTROL, 0);
2453 present &= HDA_AMP_VOLMASK;
2454 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0,
2455 HDA_AMP_VOLMASK, present);
2456 snd_hda_codec_amp_stereo(codec, 0x0d, HDA_OUTPUT, 0,
2457 HDA_AMP_VOLMASK, present);
2460 static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec,
2463 /* Looks like the unsol event is incompatible with the standard
2464 * definition. 4bit tag is placed at 28 bit!
2466 if ((res >> 28) == ALC880_HP_EVENT)
2467 alc880_uniwill_p53_hp_automute(codec);
2468 if ((res >> 28) == ALC880_DCVOL_EVENT)
2469 alc880_uniwill_p53_dcvol_automute(codec);
2473 * F1734 pin configuration:
2474 * HP = 0x14, speaker-out = 0x15, mic = 0x18
2476 static struct hda_verb alc880_pin_f1734_init_verbs[] = {
2477 {0x07, AC_VERB_SET_CONNECT_SEL, 0x01},
2478 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
2479 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
2480 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
2481 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
2483 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2484 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2485 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2486 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2488 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2489 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2490 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
2491 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2492 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2493 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2494 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2495 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2496 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2498 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
2499 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_DCVOL_EVENT},
2505 * ASUS pin configuration:
2506 * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
2508 static struct hda_verb alc880_pin_asus_init_verbs[] = {
2509 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
2510 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
2511 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
2512 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
2514 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2515 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2516 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2517 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2518 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2519 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2520 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2521 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2523 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2524 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2525 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2526 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2527 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2528 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2529 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2530 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2531 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2536 /* Enable GPIO mask and set output */
2537 #define alc880_gpio1_init_verbs alc_gpio1_init_verbs
2538 #define alc880_gpio2_init_verbs alc_gpio2_init_verbs
2540 /* Clevo m520g init */
2541 static struct hda_verb alc880_pin_clevo_init_verbs[] = {
2542 /* headphone output */
2543 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
2545 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2546 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2548 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2549 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2551 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2552 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2553 /* Mic1 (rear panel) */
2554 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2555 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2556 /* Mic2 (front panel) */
2557 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2558 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2560 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2561 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2562 /* change to EAPD mode */
2563 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2564 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
2569 static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
2570 /* change to EAPD mode */
2571 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2572 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
2574 /* Headphone output */
2575 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2577 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2578 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
2580 /* Line In pin widget for input */
2581 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2582 /* CD pin widget for input */
2583 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2584 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2585 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2587 /* change to EAPD mode */
2588 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2589 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
2595 * LG m1 express dual
2598 * Rear Line-In/Out (blue): 0x14
2599 * Build-in Mic-In: 0x15
2601 * HP-Out (green): 0x1b
2602 * Mic-In/Out (red): 0x19
2606 /* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
2607 static hda_nid_t alc880_lg_dac_nids[3] = {
2611 /* seems analog CD is not working */
2612 static struct hda_input_mux alc880_lg_capture_source = {
2617 { "Internal Mic", 0x6 },
2621 /* 2,4,6 channel modes */
2622 static struct hda_verb alc880_lg_ch2_init[] = {
2623 /* set line-in and mic-in to input */
2624 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
2625 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
2629 static struct hda_verb alc880_lg_ch4_init[] = {
2630 /* set line-in to out and mic-in to input */
2631 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
2632 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
2636 static struct hda_verb alc880_lg_ch6_init[] = {
2637 /* set line-in and mic-in to output */
2638 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
2639 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
2643 static struct hda_channel_mode alc880_lg_ch_modes[3] = {
2644 { 2, alc880_lg_ch2_init },
2645 { 4, alc880_lg_ch4_init },
2646 { 6, alc880_lg_ch6_init },
2649 static struct snd_kcontrol_new alc880_lg_mixer[] = {
2650 HDA_CODEC_VOLUME("Front Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
2651 HDA_BIND_MUTE("Front Playback Switch", 0x0f, 2, HDA_INPUT),
2652 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2653 HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
2654 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
2655 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
2656 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
2657 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
2658 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2659 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
2660 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
2661 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
2662 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
2663 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
2665 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2666 .name = "Channel Mode",
2667 .info = alc_ch_mode_info,
2668 .get = alc_ch_mode_get,
2669 .put = alc_ch_mode_put,
2674 static struct hda_verb alc880_lg_init_verbs[] = {
2675 /* set capture source to mic-in */
2676 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2677 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2678 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2679 /* mute all amp mixer inputs */
2680 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
2681 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
2682 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
2683 /* line-in to input */
2684 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2685 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2687 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2688 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2690 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2691 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2692 /* mic-in to input */
2693 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
2694 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2695 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2697 {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
2698 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2699 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2701 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
2705 /* toggle speaker-output according to the hp-jack state */
2706 static void alc880_lg_automute(struct hda_codec *codec)
2708 unsigned int present;
2711 present = snd_hda_codec_read(codec, 0x1b, 0,
2712 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
2713 bits = present ? HDA_AMP_MUTE : 0;
2714 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
2715 HDA_AMP_MUTE, bits);
2718 static void alc880_lg_unsol_event(struct hda_codec *codec, unsigned int res)
2720 /* Looks like the unsol event is incompatible with the standard
2721 * definition. 4bit tag is placed at 28 bit!
2723 if ((res >> 28) == 0x01)
2724 alc880_lg_automute(codec);
2733 * Built-in Mic-In: 0x19
2739 static struct hda_input_mux alc880_lg_lw_capture_source = {
2743 { "Internal Mic", 0x1 },
2748 #define alc880_lg_lw_modes alc880_threestack_modes
2750 static struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
2751 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2752 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2753 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
2754 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
2755 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2756 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2757 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2758 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2759 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2760 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2761 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2762 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2763 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
2764 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
2766 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2767 .name = "Channel Mode",
2768 .info = alc_ch_mode_info,
2769 .get = alc_ch_mode_get,
2770 .put = alc_ch_mode_put,
2775 static struct hda_verb alc880_lg_lw_init_verbs[] = {
2776 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2777 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
2778 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
2780 /* set capture source to mic-in */
2781 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2782 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2783 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2784 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
2786 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2787 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2789 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2790 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2791 /* mic-in to input */
2792 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2793 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2795 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2796 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2798 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
2802 /* toggle speaker-output according to the hp-jack state */
2803 static void alc880_lg_lw_automute(struct hda_codec *codec)
2805 unsigned int present;
2808 present = snd_hda_codec_read(codec, 0x1b, 0,
2809 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
2810 bits = present ? HDA_AMP_MUTE : 0;
2811 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
2812 HDA_AMP_MUTE, bits);
2815 static void alc880_lg_lw_unsol_event(struct hda_codec *codec, unsigned int res)
2817 /* Looks like the unsol event is incompatible with the standard
2818 * definition. 4bit tag is placed at 28 bit!
2820 if ((res >> 28) == 0x01)
2821 alc880_lg_lw_automute(codec);
2824 static struct snd_kcontrol_new alc880_medion_rim_mixer[] = {
2825 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2826 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
2827 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2828 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2829 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2830 HDA_CODEC_MUTE("Internal Playback Switch", 0x0b, 0x1, HDA_INPUT),
2834 static struct hda_input_mux alc880_medion_rim_capture_source = {
2838 { "Internal Mic", 0x1 },
2842 static struct hda_verb alc880_medion_rim_init_verbs[] = {
2843 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2845 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2846 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2848 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2849 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2850 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2851 /* Mic2 (as headphone out) for HP output */
2852 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2853 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2854 /* Internal Speaker */
2855 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2856 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2858 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2859 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
2861 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
2865 /* toggle speaker-output according to the hp-jack state */
2866 static void alc880_medion_rim_automute(struct hda_codec *codec)
2868 unsigned int present;
2871 present = snd_hda_codec_read(codec, 0x14, 0,
2872 AC_VERB_GET_PIN_SENSE, 0)
2873 & AC_PINSENSE_PRESENCE;
2874 bits = present ? HDA_AMP_MUTE : 0;
2875 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
2876 HDA_AMP_MUTE, bits);
2878 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 0);
2880 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 2);
2883 static void alc880_medion_rim_unsol_event(struct hda_codec *codec,
2886 /* Looks like the unsol event is incompatible with the standard
2887 * definition. 4bit tag is placed at 28 bit!
2889 if ((res >> 28) == ALC880_HP_EVENT)
2890 alc880_medion_rim_automute(codec);
2893 #ifdef CONFIG_SND_HDA_POWER_SAVE
2894 static struct hda_amp_list alc880_loopbacks[] = {
2895 { 0x0b, HDA_INPUT, 0 },
2896 { 0x0b, HDA_INPUT, 1 },
2897 { 0x0b, HDA_INPUT, 2 },
2898 { 0x0b, HDA_INPUT, 3 },
2899 { 0x0b, HDA_INPUT, 4 },
2903 static struct hda_amp_list alc880_lg_loopbacks[] = {
2904 { 0x0b, HDA_INPUT, 1 },
2905 { 0x0b, HDA_INPUT, 6 },
2906 { 0x0b, HDA_INPUT, 7 },
2915 static int alc_init(struct hda_codec *codec)
2917 struct alc_spec *spec = codec->spec;
2921 if (codec->vendor_id == 0x10ec0888)
2922 alc888_coef_init(codec);
2924 for (i = 0; i < spec->num_init_verbs; i++)
2925 snd_hda_sequence_write(codec, spec->init_verbs[i]);
2927 if (spec->init_hook)
2928 spec->init_hook(codec);
2933 static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
2935 struct alc_spec *spec = codec->spec;
2937 if (spec->unsol_event)
2938 spec->unsol_event(codec, res);
2941 #ifdef CONFIG_SND_HDA_POWER_SAVE
2942 static int alc_check_power_status(struct hda_codec *codec, hda_nid_t nid)
2944 struct alc_spec *spec = codec->spec;
2945 return snd_hda_check_amp_list_power(codec, &spec->loopback, nid);
2950 * Analog playback callbacks
2952 static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
2953 struct hda_codec *codec,
2954 struct snd_pcm_substream *substream)
2956 struct alc_spec *spec = codec->spec;
2957 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
2961 static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2962 struct hda_codec *codec,
2963 unsigned int stream_tag,
2964 unsigned int format,
2965 struct snd_pcm_substream *substream)
2967 struct alc_spec *spec = codec->spec;
2968 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
2969 stream_tag, format, substream);
2972 static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
2973 struct hda_codec *codec,
2974 struct snd_pcm_substream *substream)
2976 struct alc_spec *spec = codec->spec;
2977 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
2983 static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
2984 struct hda_codec *codec,
2985 struct snd_pcm_substream *substream)
2987 struct alc_spec *spec = codec->spec;
2988 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
2991 static int alc880_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2992 struct hda_codec *codec,
2993 unsigned int stream_tag,
2994 unsigned int format,
2995 struct snd_pcm_substream *substream)
2997 struct alc_spec *spec = codec->spec;
2998 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
2999 stream_tag, format, substream);
3002 static int alc880_dig_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
3003 struct hda_codec *codec,
3004 struct snd_pcm_substream *substream)
3006 struct alc_spec *spec = codec->spec;
3007 return snd_hda_multi_out_dig_cleanup(codec, &spec->multiout);
3010 static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
3011 struct hda_codec *codec,
3012 struct snd_pcm_substream *substream)
3014 struct alc_spec *spec = codec->spec;
3015 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
3021 static int alc880_alt_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
3022 struct hda_codec *codec,
3023 unsigned int stream_tag,
3024 unsigned int format,
3025 struct snd_pcm_substream *substream)
3027 struct alc_spec *spec = codec->spec;
3029 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number + 1],
3030 stream_tag, 0, format);
3034 static int alc880_alt_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
3035 struct hda_codec *codec,
3036 struct snd_pcm_substream *substream)
3038 struct alc_spec *spec = codec->spec;
3040 snd_hda_codec_cleanup_stream(codec,
3041 spec->adc_nids[substream->number + 1]);
3048 static struct hda_pcm_stream alc880_pcm_analog_playback = {
3052 /* NID is set in alc_build_pcms */
3054 .open = alc880_playback_pcm_open,
3055 .prepare = alc880_playback_pcm_prepare,
3056 .cleanup = alc880_playback_pcm_cleanup
3060 static struct hda_pcm_stream alc880_pcm_analog_capture = {
3064 /* NID is set in alc_build_pcms */
3067 static struct hda_pcm_stream alc880_pcm_analog_alt_playback = {
3071 /* NID is set in alc_build_pcms */
3074 static struct hda_pcm_stream alc880_pcm_analog_alt_capture = {
3075 .substreams = 2, /* can be overridden */
3078 /* NID is set in alc_build_pcms */
3080 .prepare = alc880_alt_capture_pcm_prepare,
3081 .cleanup = alc880_alt_capture_pcm_cleanup
3085 static struct hda_pcm_stream alc880_pcm_digital_playback = {
3089 /* NID is set in alc_build_pcms */
3091 .open = alc880_dig_playback_pcm_open,
3092 .close = alc880_dig_playback_pcm_close,
3093 .prepare = alc880_dig_playback_pcm_prepare,
3094 .cleanup = alc880_dig_playback_pcm_cleanup
3098 static struct hda_pcm_stream alc880_pcm_digital_capture = {
3102 /* NID is set in alc_build_pcms */
3105 /* Used by alc_build_pcms to flag that a PCM has no playback stream */
3106 static struct hda_pcm_stream alc_pcm_null_stream = {
3112 static int alc_build_pcms(struct hda_codec *codec)
3114 struct alc_spec *spec = codec->spec;
3115 struct hda_pcm *info = spec->pcm_rec;
3118 codec->num_pcms = 1;
3119 codec->pcm_info = info;
3121 if (spec->no_analog)
3124 info->name = spec->stream_name_analog;
3125 if (spec->stream_analog_playback) {
3126 if (snd_BUG_ON(!spec->multiout.dac_nids))
3128 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
3129 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
3131 if (spec->stream_analog_capture) {
3132 if (snd_BUG_ON(!spec->adc_nids))
3134 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
3135 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
3138 if (spec->channel_mode) {
3139 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
3140 for (i = 0; i < spec->num_channel_mode; i++) {
3141 if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
3142 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
3148 /* SPDIF for stream index #1 */