2 * Universal Interface for Intel High Definition Audio Codec
4 * HD audio interface patch for Realtek ALC 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@just42.net>
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 <linux/dmi.h>
31 #include <linux/module.h>
32 #include <linux/input.h>
33 #include <sound/core.h>
34 #include <sound/jack.h>
35 #include <sound/hda_codec.h>
36 #include "hda_local.h"
37 #include "hda_auto_parser.h"
39 #include "hda_generic.h"
41 /* keep halting ALC5505 DSP, for power saving */
42 #define HALT_REALTEK_ALC5505
44 /* extra amp-initialization sequence types */
52 ALC_HEADSET_MODE_UNKNOWN,
53 ALC_HEADSET_MODE_UNPLUGGED,
54 ALC_HEADSET_MODE_HEADSET,
56 ALC_HEADSET_MODE_HEADPHONE,
60 ALC_HEADSET_TYPE_UNKNOWN,
61 ALC_HEADSET_TYPE_CTIA,
62 ALC_HEADSET_TYPE_OMTP,
66 ALC_KEY_MICMUTE_INDEX,
69 struct alc_customize_define {
71 unsigned char port_connectivity;
72 unsigned char check_sum;
73 unsigned char customization;
74 unsigned char external_amp;
75 unsigned int enable_pcbeep:1;
76 unsigned int platform_type:1;
78 unsigned int override:1;
79 unsigned int fixup:1; /* Means that this sku is set by driver, not read from hw */
83 struct hda_gen_spec gen; /* must be at head */
85 /* codec parameterization */
86 struct alc_customize_define cdefine;
87 unsigned int parse_flags; /* flag for snd_hda_parse_pin_defcfg() */
90 unsigned int gpio_mask;
91 unsigned int gpio_dir;
92 unsigned int gpio_data;
93 bool gpio_write_delay; /* add a delay before writing gpio_data */
95 /* mute LED for HP laptops, see alc269_fixup_mic_mute_hook() */
96 int mute_led_polarity;
97 hda_nid_t mute_led_nid;
98 hda_nid_t cap_mute_led_nid;
100 unsigned int gpio_mute_led_mask;
101 unsigned int gpio_mic_led_mask;
103 hda_nid_t headset_mic_pin;
104 hda_nid_t headphone_mic_pin;
105 int current_headset_mode;
106 int current_headset_type;
109 void (*init_hook)(struct hda_codec *codec);
111 void (*power_hook)(struct hda_codec *codec);
113 void (*shutup)(struct hda_codec *codec);
114 void (*reboot_notify)(struct hda_codec *codec);
117 int codec_variant; /* flag for other variants */
118 unsigned int has_alc5505_dsp:1;
119 unsigned int no_depop_delay:1;
123 unsigned int pll_coef_idx, pll_coef_bit;
125 struct input_dev *kb_dev;
126 u8 alc_mute_keycode_map[1];
130 * COEF access helper functions
133 static int alc_read_coefex_idx(struct hda_codec *codec, hda_nid_t nid,
134 unsigned int coef_idx)
138 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_COEF_INDEX, coef_idx);
139 val = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_PROC_COEF, 0);
143 #define alc_read_coef_idx(codec, coef_idx) \
144 alc_read_coefex_idx(codec, 0x20, coef_idx)
146 static void alc_write_coefex_idx(struct hda_codec *codec, hda_nid_t nid,
147 unsigned int coef_idx, unsigned int coef_val)
149 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_COEF_INDEX, coef_idx);
150 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PROC_COEF, coef_val);
153 #define alc_write_coef_idx(codec, coef_idx, coef_val) \
154 alc_write_coefex_idx(codec, 0x20, coef_idx, coef_val)
156 static void alc_update_coefex_idx(struct hda_codec *codec, hda_nid_t nid,
157 unsigned int coef_idx, unsigned int mask,
158 unsigned int bits_set)
160 unsigned int val = alc_read_coefex_idx(codec, nid, coef_idx);
163 alc_write_coefex_idx(codec, nid, coef_idx,
164 (val & ~mask) | bits_set);
167 #define alc_update_coef_idx(codec, coef_idx, mask, bits_set) \
168 alc_update_coefex_idx(codec, 0x20, coef_idx, mask, bits_set)
170 /* a special bypass for COEF 0; read the cached value at the second time */
171 static unsigned int alc_get_coef0(struct hda_codec *codec)
173 struct alc_spec *spec = codec->spec;
176 spec->coef0 = alc_read_coef_idx(codec, 0);
180 /* coef writes/updates batch */
188 #define UPDATE_COEFEX(_nid, _idx, _mask, _val) \
189 { .nid = (_nid), .idx = (_idx), .mask = (_mask), .val = (_val) }
190 #define WRITE_COEFEX(_nid, _idx, _val) UPDATE_COEFEX(_nid, _idx, -1, _val)
191 #define WRITE_COEF(_idx, _val) WRITE_COEFEX(0x20, _idx, _val)
192 #define UPDATE_COEF(_idx, _mask, _val) UPDATE_COEFEX(0x20, _idx, _mask, _val)
194 static void alc_process_coef_fw(struct hda_codec *codec,
195 const struct coef_fw *fw)
197 for (; fw->nid; fw++) {
198 if (fw->mask == (unsigned short)-1)
199 alc_write_coefex_idx(codec, fw->nid, fw->idx, fw->val);
201 alc_update_coefex_idx(codec, fw->nid, fw->idx,
207 * GPIO setup tables, used in initialization
210 /* Enable GPIO mask and set output */
211 static void alc_setup_gpio(struct hda_codec *codec, unsigned int mask)
213 struct alc_spec *spec = codec->spec;
215 spec->gpio_mask |= mask;
216 spec->gpio_dir |= mask;
217 spec->gpio_data |= mask;
220 static void alc_write_gpio_data(struct hda_codec *codec)
222 struct alc_spec *spec = codec->spec;
224 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA,
228 static void alc_update_gpio_data(struct hda_codec *codec, unsigned int mask,
231 struct alc_spec *spec = codec->spec;
232 unsigned int oldval = spec->gpio_data;
235 spec->gpio_data |= mask;
237 spec->gpio_data &= ~mask;
238 if (oldval != spec->gpio_data)
239 alc_write_gpio_data(codec);
242 static void alc_write_gpio(struct hda_codec *codec)
244 struct alc_spec *spec = codec->spec;
246 if (!spec->gpio_mask)
249 snd_hda_codec_write(codec, codec->core.afg, 0,
250 AC_VERB_SET_GPIO_MASK, spec->gpio_mask);
251 snd_hda_codec_write(codec, codec->core.afg, 0,
252 AC_VERB_SET_GPIO_DIRECTION, spec->gpio_dir);
253 if (spec->gpio_write_delay)
255 alc_write_gpio_data(codec);
258 static void alc_fixup_gpio(struct hda_codec *codec, int action,
261 if (action == HDA_FIXUP_ACT_PRE_PROBE)
262 alc_setup_gpio(codec, mask);
265 static void alc_fixup_gpio1(struct hda_codec *codec,
266 const struct hda_fixup *fix, int action)
268 alc_fixup_gpio(codec, action, 0x01);
271 static void alc_fixup_gpio2(struct hda_codec *codec,
272 const struct hda_fixup *fix, int action)
274 alc_fixup_gpio(codec, action, 0x02);
277 static void alc_fixup_gpio3(struct hda_codec *codec,
278 const struct hda_fixup *fix, int action)
280 alc_fixup_gpio(codec, action, 0x03);
283 static void alc_fixup_gpio4(struct hda_codec *codec,
284 const struct hda_fixup *fix, int action)
286 alc_fixup_gpio(codec, action, 0x04);
290 * Fix hardware PLL issue
291 * On some codecs, the analog PLL gating control must be off while
292 * the default value is 1.
294 static void alc_fix_pll(struct hda_codec *codec)
296 struct alc_spec *spec = codec->spec;
299 alc_update_coefex_idx(codec, spec->pll_nid, spec->pll_coef_idx,
300 1 << spec->pll_coef_bit, 0);
303 static void alc_fix_pll_init(struct hda_codec *codec, hda_nid_t nid,
304 unsigned int coef_idx, unsigned int coef_bit)
306 struct alc_spec *spec = codec->spec;
308 spec->pll_coef_idx = coef_idx;
309 spec->pll_coef_bit = coef_bit;
313 /* update the master volume per volume-knob's unsol event */
314 static void alc_update_knob_master(struct hda_codec *codec,
315 struct hda_jack_callback *jack)
318 struct snd_kcontrol *kctl;
319 struct snd_ctl_elem_value *uctl;
321 kctl = snd_hda_find_mixer_ctl(codec, "Master Playback Volume");
324 uctl = kzalloc(sizeof(*uctl), GFP_KERNEL);
327 val = snd_hda_codec_read(codec, jack->nid, 0,
328 AC_VERB_GET_VOLUME_KNOB_CONTROL, 0);
329 val &= HDA_AMP_VOLMASK;
330 uctl->value.integer.value[0] = val;
331 uctl->value.integer.value[1] = val;
332 kctl->put(kctl, uctl);
336 static void alc880_unsol_event(struct hda_codec *codec, unsigned int res)
338 /* For some reason, the res given from ALC880 is broken.
339 Here we adjust it properly. */
340 snd_hda_jack_unsol_event(codec, res >> 2);
343 /* Change EAPD to verb control */
344 static void alc_fill_eapd_coef(struct hda_codec *codec)
348 coef = alc_get_coef0(codec);
350 switch (codec->core.vendor_id) {
352 alc_update_coef_idx(codec, 0x7, 0, 1<<5);
356 alc_update_coef_idx(codec, 0x7, 0, 1<<13);
359 if ((coef & 0x00f0) == 0x0010)
360 alc_update_coef_idx(codec, 0xd, 0, 1<<14);
361 if ((coef & 0x00f0) == 0x0020)
362 alc_update_coef_idx(codec, 0x4, 1<<15, 0);
363 if ((coef & 0x00f0) == 0x0030)
364 alc_update_coef_idx(codec, 0x10, 1<<9, 0);
370 alc_update_coef_idx(codec, 0x4, 1<<15, 0);
375 alc_update_coef_idx(codec, 0x67, 0xf000, 0x3000);
392 alc_update_coef_idx(codec, 0x10, 1<<9, 0);
395 alc_update_coef_idx(codec, 0xe, 0, 1<<0);
398 alc_update_coef_idx(codec, 0xa, 1<<13, 0);
406 alc_update_coef_idx(codec, 0x10, 1<<15, 0);
409 if ((coef & 0x00f0) == 0x0030)
410 alc_update_coef_idx(codec, 0x4, 1<<10, 0); /* EAPD Ctrl */
419 alc_update_coef_idx(codec, 0xd, 0, 1<<14); /* EAPD Ctrl */
422 alc_update_coef_idx(codec, 0x7, 3<<13, 0);
425 alc_update_coef_idx(codec, 0x4, 1<<10, 0);
428 if ((coef & 0x00f0) == 0x0020 || (coef & 0x00f0) == 0x0030)
429 alc_update_coef_idx(codec, 0x7, 1<<5, 0);
432 alc_update_coef_idx(codec, 0x7, 1<<5, 0);
438 alc_update_coef_idx(codec, 0x7, 1<<1, 0);
443 /* additional initialization for ALC888 variants */
444 static void alc888_coef_init(struct hda_codec *codec)
446 switch (alc_get_coef0(codec) & 0x00f0) {
451 alc_update_coef_idx(codec, 7, 0, 0x2030); /* Turn EAPD to High */
456 /* turn on/off EAPD control (only if available) */
457 static void set_eapd(struct hda_codec *codec, hda_nid_t nid, int on)
459 if (get_wcaps_type(get_wcaps(codec, nid)) != AC_WID_PIN)
461 if (snd_hda_query_pin_caps(codec, nid) & AC_PINCAP_EAPD)
462 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
466 /* turn on/off EAPD controls of the codec */
467 static void alc_auto_setup_eapd(struct hda_codec *codec, bool on)
469 /* We currently only handle front, HP */
470 static hda_nid_t pins[] = {
471 0x0f, 0x10, 0x14, 0x15, 0x17, 0
474 for (p = pins; *p; p++)
475 set_eapd(codec, *p, on);
478 /* generic shutup callback;
479 * just turning off EAPD and a little pause for avoiding pop-noise
481 static void alc_eapd_shutup(struct hda_codec *codec)
483 struct alc_spec *spec = codec->spec;
485 alc_auto_setup_eapd(codec, false);
486 if (!spec->no_depop_delay)
488 snd_hda_shutup_pins(codec);
491 /* generic EAPD initialization */
492 static void alc_auto_init_amp(struct hda_codec *codec, int type)
494 alc_fill_eapd_coef(codec);
495 alc_auto_setup_eapd(codec, true);
496 alc_write_gpio(codec);
498 case ALC_INIT_DEFAULT:
499 switch (codec->core.vendor_id) {
501 alc_update_coefex_idx(codec, 0x1a, 7, 0, 0x2010);
507 alc_update_coef_idx(codec, 7, 0, 0x2030);
510 alc888_coef_init(codec);
519 * Realtek SSID verification
522 /* Could be any non-zero and even value. When used as fixup, tells
523 * the driver to ignore any present sku defines.
525 #define ALC_FIXUP_SKU_IGNORE (2)
527 static void alc_fixup_sku_ignore(struct hda_codec *codec,
528 const struct hda_fixup *fix, int action)
530 struct alc_spec *spec = codec->spec;
531 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
532 spec->cdefine.fixup = 1;
533 spec->cdefine.sku_cfg = ALC_FIXUP_SKU_IGNORE;
537 static void alc_fixup_no_depop_delay(struct hda_codec *codec,
538 const struct hda_fixup *fix, int action)
540 struct alc_spec *spec = codec->spec;
542 if (action == HDA_FIXUP_ACT_PROBE) {
543 spec->no_depop_delay = 1;
544 codec->depop_delay = 0;
548 static int alc_auto_parse_customize_define(struct hda_codec *codec)
550 unsigned int ass, tmp, i;
552 struct alc_spec *spec = codec->spec;
554 spec->cdefine.enable_pcbeep = 1; /* assume always enabled */
556 if (spec->cdefine.fixup) {
557 ass = spec->cdefine.sku_cfg;
558 if (ass == ALC_FIXUP_SKU_IGNORE)
563 if (!codec->bus->pci)
565 ass = codec->core.subsystem_id & 0xffff;
566 if (ass != codec->bus->pci->subsystem_device && (ass & 1))
570 if (codec->core.vendor_id == 0x10ec0260)
572 ass = snd_hda_codec_get_pincfg(codec, nid);
575 codec_info(codec, "%s: SKU not ready 0x%08x\n",
576 codec->core.chip_name, ass);
582 for (i = 1; i < 16; i++) {
586 if (((ass >> 16) & 0xf) != tmp)
589 spec->cdefine.port_connectivity = ass >> 30;
590 spec->cdefine.enable_pcbeep = (ass & 0x100000) >> 20;
591 spec->cdefine.check_sum = (ass >> 16) & 0xf;
592 spec->cdefine.customization = ass >> 8;
594 spec->cdefine.sku_cfg = ass;
595 spec->cdefine.external_amp = (ass & 0x38) >> 3;
596 spec->cdefine.platform_type = (ass & 0x4) >> 2;
597 spec->cdefine.swap = (ass & 0x2) >> 1;
598 spec->cdefine.override = ass & 0x1;
600 codec_dbg(codec, "SKU: Nid=0x%x sku_cfg=0x%08x\n",
601 nid, spec->cdefine.sku_cfg);
602 codec_dbg(codec, "SKU: port_connectivity=0x%x\n",
603 spec->cdefine.port_connectivity);
604 codec_dbg(codec, "SKU: enable_pcbeep=0x%x\n", spec->cdefine.enable_pcbeep);
605 codec_dbg(codec, "SKU: check_sum=0x%08x\n", spec->cdefine.check_sum);
606 codec_dbg(codec, "SKU: customization=0x%08x\n", spec->cdefine.customization);
607 codec_dbg(codec, "SKU: external_amp=0x%x\n", spec->cdefine.external_amp);
608 codec_dbg(codec, "SKU: platform_type=0x%x\n", spec->cdefine.platform_type);
609 codec_dbg(codec, "SKU: swap=0x%x\n", spec->cdefine.swap);
610 codec_dbg(codec, "SKU: override=0x%x\n", spec->cdefine.override);
615 /* return the position of NID in the list, or -1 if not found */
616 static int find_idx_in_nid_list(hda_nid_t nid, const hda_nid_t *list, int nums)
619 for (i = 0; i < nums; i++)
624 /* return true if the given NID is found in the list */
625 static bool found_in_nid_list(hda_nid_t nid, const hda_nid_t *list, int nums)
627 return find_idx_in_nid_list(nid, list, nums) >= 0;
630 /* check subsystem ID and set up device-specific initialization;
631 * return 1 if initialized, 0 if invalid SSID
633 /* 32-bit subsystem ID for BIOS loading in HD Audio codec.
634 * 31 ~ 16 : Manufacture ID
636 * 7 ~ 0 : Assembly ID
637 * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36
639 static int alc_subsystem_id(struct hda_codec *codec, const hda_nid_t *ports)
641 unsigned int ass, tmp, i;
643 struct alc_spec *spec = codec->spec;
645 if (spec->cdefine.fixup) {
646 ass = spec->cdefine.sku_cfg;
647 if (ass == ALC_FIXUP_SKU_IGNORE)
652 ass = codec->core.subsystem_id & 0xffff;
653 if (codec->bus->pci &&
654 ass != codec->bus->pci->subsystem_device && (ass & 1))
657 /* invalid SSID, check the special NID pin defcfg instead */
659 * 31~30 : port connectivity
662 * 19~16 : Check sum (15:1)
667 if (codec->core.vendor_id == 0x10ec0260)
669 ass = snd_hda_codec_get_pincfg(codec, nid);
671 "realtek: No valid SSID, checking pincfg 0x%08x for NID 0x%x\n",
675 if ((ass >> 30) != 1) /* no physical connection */
680 for (i = 1; i < 16; i++) {
684 if (((ass >> 16) & 0xf) != tmp)
687 codec_dbg(codec, "realtek: Enabling init ASM_ID=0x%04x CODEC_ID=%08x\n",
688 ass & 0xffff, codec->core.vendor_id);
692 * 2 : 0 --> Desktop, 1 --> Laptop
693 * 3~5 : External Amplifier control
696 tmp = (ass & 0x38) >> 3; /* external Amp control */
697 if (spec->init_amp == ALC_INIT_UNDEFINED) {
700 alc_setup_gpio(codec, 0x01);
703 alc_setup_gpio(codec, 0x02);
706 alc_setup_gpio(codec, 0x03);
710 spec->init_amp = ALC_INIT_DEFAULT;
715 /* is laptop or Desktop and enable the function "Mute internal speaker
716 * when the external headphone out jack is plugged"
721 * 10~8 : Jack location
722 * 12~11: Headphone out -> 00: PortA, 01: PortE, 02: PortD, 03: Resvered
724 * 15 : 1 --> enable the function "Mute internal speaker
725 * when the external headphone out jack is plugged"
727 if (!spec->gen.autocfg.hp_pins[0] &&
728 !(spec->gen.autocfg.line_out_pins[0] &&
729 spec->gen.autocfg.line_out_type == AUTO_PIN_HP_OUT)) {
731 tmp = (ass >> 11) & 0x3; /* HP to chassis */
733 if (found_in_nid_list(nid, spec->gen.autocfg.line_out_pins,
734 spec->gen.autocfg.line_outs))
736 spec->gen.autocfg.hp_pins[0] = nid;
741 /* Check the validity of ALC subsystem-id
742 * ports contains an array of 4 pin NIDs for port-A, E, D and I */
743 static void alc_ssid_check(struct hda_codec *codec, const hda_nid_t *ports)
745 if (!alc_subsystem_id(codec, ports)) {
746 struct alc_spec *spec = codec->spec;
748 "realtek: Enable default setup for auto mode as fallback\n");
749 spec->init_amp = ALC_INIT_DEFAULT;
756 static void alc_fixup_inv_dmic(struct hda_codec *codec,
757 const struct hda_fixup *fix, int action)
759 struct alc_spec *spec = codec->spec;
761 spec->gen.inv_dmic_split = 1;
765 static int alc_build_controls(struct hda_codec *codec)
769 err = snd_hda_gen_build_controls(codec);
773 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_BUILD);
782 static int alc_init(struct hda_codec *codec)
784 struct alc_spec *spec = codec->spec;
787 spec->init_hook(codec);
790 alc_auto_init_amp(codec, spec->init_amp);
792 snd_hda_gen_init(codec);
794 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_INIT);
799 static inline void alc_shutup(struct hda_codec *codec)
801 struct alc_spec *spec = codec->spec;
803 if (!snd_hda_get_bool_hint(codec, "shutup"))
804 return; /* disabled explicitly by hints */
806 if (spec && spec->shutup)
809 snd_hda_shutup_pins(codec);
812 static void alc_reboot_notify(struct hda_codec *codec)
814 struct alc_spec *spec = codec->spec;
816 if (spec && spec->reboot_notify)
817 spec->reboot_notify(codec);
822 /* power down codec to D3 at reboot/shutdown; set as reboot_notify ops */
823 static void alc_d3_at_reboot(struct hda_codec *codec)
825 snd_hda_codec_set_power_to_all(codec, codec->core.afg, AC_PWRST_D3);
826 snd_hda_codec_write(codec, codec->core.afg, 0,
827 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
831 #define alc_free snd_hda_gen_free
834 static void alc_power_eapd(struct hda_codec *codec)
836 alc_auto_setup_eapd(codec, false);
839 static int alc_suspend(struct hda_codec *codec)
841 struct alc_spec *spec = codec->spec;
843 if (spec && spec->power_hook)
844 spec->power_hook(codec);
850 static int alc_resume(struct hda_codec *codec)
852 struct alc_spec *spec = codec->spec;
854 if (!spec->no_depop_delay)
855 msleep(150); /* to avoid pop noise */
856 codec->patch_ops.init(codec);
857 regcache_sync(codec->core.regmap);
858 hda_call_check_power_status(codec, 0x01);
865 static const struct hda_codec_ops alc_patch_ops = {
866 .build_controls = alc_build_controls,
867 .build_pcms = snd_hda_gen_build_pcms,
870 .unsol_event = snd_hda_jack_unsol_event,
872 .resume = alc_resume,
873 .suspend = alc_suspend,
874 .check_power_status = snd_hda_gen_check_power_status,
876 .reboot_notify = alc_reboot_notify,
880 #define alc_codec_rename(codec, name) snd_hda_codec_set_name(codec, name)
883 * Rename codecs appropriately from COEF value or subvendor id
885 struct alc_codec_rename_table {
886 unsigned int vendor_id;
887 unsigned short coef_mask;
888 unsigned short coef_bits;
892 struct alc_codec_rename_pci_table {
893 unsigned int codec_vendor_id;
894 unsigned short pci_subvendor;
895 unsigned short pci_subdevice;
899 static struct alc_codec_rename_table rename_tbl[] = {
900 { 0x10ec0221, 0xf00f, 0x1003, "ALC231" },
901 { 0x10ec0269, 0xfff0, 0x3010, "ALC277" },
902 { 0x10ec0269, 0xf0f0, 0x2010, "ALC259" },
903 { 0x10ec0269, 0xf0f0, 0x3010, "ALC258" },
904 { 0x10ec0269, 0x00f0, 0x0010, "ALC269VB" },
905 { 0x10ec0269, 0xffff, 0xa023, "ALC259" },
906 { 0x10ec0269, 0xffff, 0x6023, "ALC281X" },
907 { 0x10ec0269, 0x00f0, 0x0020, "ALC269VC" },
908 { 0x10ec0269, 0x00f0, 0x0030, "ALC269VD" },
909 { 0x10ec0662, 0xffff, 0x4020, "ALC656" },
910 { 0x10ec0887, 0x00f0, 0x0030, "ALC887-VD" },
911 { 0x10ec0888, 0x00f0, 0x0030, "ALC888-VD" },
912 { 0x10ec0888, 0xf0f0, 0x3020, "ALC886" },
913 { 0x10ec0899, 0x2000, 0x2000, "ALC899" },
914 { 0x10ec0892, 0xffff, 0x8020, "ALC661" },
915 { 0x10ec0892, 0xffff, 0x8011, "ALC661" },
916 { 0x10ec0892, 0xffff, 0x4011, "ALC656" },
920 static struct alc_codec_rename_pci_table rename_pci_tbl[] = {
921 { 0x10ec0280, 0x1028, 0, "ALC3220" },
922 { 0x10ec0282, 0x1028, 0, "ALC3221" },
923 { 0x10ec0283, 0x1028, 0, "ALC3223" },
924 { 0x10ec0288, 0x1028, 0, "ALC3263" },
925 { 0x10ec0292, 0x1028, 0, "ALC3226" },
926 { 0x10ec0293, 0x1028, 0, "ALC3235" },
927 { 0x10ec0255, 0x1028, 0, "ALC3234" },
928 { 0x10ec0668, 0x1028, 0, "ALC3661" },
929 { 0x10ec0275, 0x1028, 0, "ALC3260" },
930 { 0x10ec0899, 0x1028, 0, "ALC3861" },
931 { 0x10ec0298, 0x1028, 0, "ALC3266" },
932 { 0x10ec0236, 0x1028, 0, "ALC3204" },
933 { 0x10ec0256, 0x1028, 0, "ALC3246" },
934 { 0x10ec0225, 0x1028, 0, "ALC3253" },
935 { 0x10ec0295, 0x1028, 0, "ALC3254" },
936 { 0x10ec0299, 0x1028, 0, "ALC3271" },
937 { 0x10ec0670, 0x1025, 0, "ALC669X" },
938 { 0x10ec0676, 0x1025, 0, "ALC679X" },
939 { 0x10ec0282, 0x1043, 0, "ALC3229" },
940 { 0x10ec0233, 0x1043, 0, "ALC3236" },
941 { 0x10ec0280, 0x103c, 0, "ALC3228" },
942 { 0x10ec0282, 0x103c, 0, "ALC3227" },
943 { 0x10ec0286, 0x103c, 0, "ALC3242" },
944 { 0x10ec0290, 0x103c, 0, "ALC3241" },
945 { 0x10ec0668, 0x103c, 0, "ALC3662" },
946 { 0x10ec0283, 0x17aa, 0, "ALC3239" },
947 { 0x10ec0292, 0x17aa, 0, "ALC3232" },
951 static int alc_codec_rename_from_preset(struct hda_codec *codec)
953 const struct alc_codec_rename_table *p;
954 const struct alc_codec_rename_pci_table *q;
956 for (p = rename_tbl; p->vendor_id; p++) {
957 if (p->vendor_id != codec->core.vendor_id)
959 if ((alc_get_coef0(codec) & p->coef_mask) == p->coef_bits)
960 return alc_codec_rename(codec, p->name);
963 if (!codec->bus->pci)
965 for (q = rename_pci_tbl; q->codec_vendor_id; q++) {
966 if (q->codec_vendor_id != codec->core.vendor_id)
968 if (q->pci_subvendor != codec->bus->pci->subsystem_vendor)
970 if (!q->pci_subdevice ||
971 q->pci_subdevice == codec->bus->pci->subsystem_device)
972 return alc_codec_rename(codec, q->name);
980 * Digital-beep handlers
982 #ifdef CONFIG_SND_HDA_INPUT_BEEP
984 /* additional beep mixers; private_value will be overwritten */
985 static const struct snd_kcontrol_new alc_beep_mixer[] = {
986 HDA_CODEC_VOLUME("Beep Playback Volume", 0, 0, HDA_INPUT),
987 HDA_CODEC_MUTE_BEEP("Beep Playback Switch", 0, 0, HDA_INPUT),
990 /* set up and create beep controls */
991 static int set_beep_amp(struct alc_spec *spec, hda_nid_t nid,
994 struct snd_kcontrol_new *knew;
995 unsigned int beep_amp = HDA_COMPOSE_AMP_VAL(nid, 3, idx, dir);
998 for (i = 0; i < ARRAY_SIZE(alc_beep_mixer); i++) {
999 knew = snd_hda_gen_add_kctl(&spec->gen, NULL,
1000 &alc_beep_mixer[i]);
1003 knew->private_value = beep_amp;
1008 static const struct snd_pci_quirk beep_white_list[] = {
1009 SND_PCI_QUIRK(0x1043, 0x103c, "ASUS", 1),
1010 SND_PCI_QUIRK(0x1043, 0x115d, "ASUS", 1),
1011 SND_PCI_QUIRK(0x1043, 0x829f, "ASUS", 1),
1012 SND_PCI_QUIRK(0x1043, 0x8376, "EeePC", 1),
1013 SND_PCI_QUIRK(0x1043, 0x83ce, "EeePC", 1),
1014 SND_PCI_QUIRK(0x1043, 0x831a, "EeePC", 1),
1015 SND_PCI_QUIRK(0x1043, 0x834a, "EeePC", 1),
1016 SND_PCI_QUIRK(0x1458, 0xa002, "GA-MA790X", 1),
1017 SND_PCI_QUIRK(0x8086, 0xd613, "Intel", 1),
1021 static inline int has_cdefine_beep(struct hda_codec *codec)
1023 struct alc_spec *spec = codec->spec;
1024 const struct snd_pci_quirk *q;
1025 q = snd_pci_quirk_lookup(codec->bus->pci, beep_white_list);
1028 return spec->cdefine.enable_pcbeep;
1031 #define set_beep_amp(spec, nid, idx, dir) 0
1032 #define has_cdefine_beep(codec) 0
1035 /* parse the BIOS configuration and set up the alc_spec */
1036 /* return 1 if successful, 0 if the proper config is not found,
1037 * or a negative error code
1039 static int alc_parse_auto_config(struct hda_codec *codec,
1040 const hda_nid_t *ignore_nids,
1041 const hda_nid_t *ssid_nids)
1043 struct alc_spec *spec = codec->spec;
1044 struct auto_pin_cfg *cfg = &spec->gen.autocfg;
1047 err = snd_hda_parse_pin_defcfg(codec, cfg, ignore_nids,
1053 alc_ssid_check(codec, ssid_nids);
1055 err = snd_hda_gen_parse_auto_config(codec, cfg);
1062 /* common preparation job for alc_spec */
1063 static int alc_alloc_spec(struct hda_codec *codec, hda_nid_t mixer_nid)
1065 struct alc_spec *spec = kzalloc(sizeof(*spec), GFP_KERNEL);
1071 snd_hda_gen_spec_init(&spec->gen);
1072 spec->gen.mixer_nid = mixer_nid;
1073 spec->gen.own_eapd_ctl = 1;
1074 codec->single_adc_amp = 1;
1075 /* FIXME: do we need this for all Realtek codec models? */
1076 codec->spdif_status_reset = 1;
1077 codec->patch_ops = alc_patch_ops;
1079 err = alc_codec_rename_from_preset(codec);
1087 static int alc880_parse_auto_config(struct hda_codec *codec)
1089 static const hda_nid_t alc880_ignore[] = { 0x1d, 0 };
1090 static const hda_nid_t alc880_ssids[] = { 0x15, 0x1b, 0x14, 0 };
1091 return alc_parse_auto_config(codec, alc880_ignore, alc880_ssids);
1100 ALC880_FIXUP_MEDION_RIM,
1102 ALC880_FIXUP_LG_LW25,
1104 ALC880_FIXUP_EAPD_COEF,
1105 ALC880_FIXUP_TCL_S700,
1106 ALC880_FIXUP_VOL_KNOB,
1107 ALC880_FIXUP_FUJITSU,
1109 ALC880_FIXUP_UNIWILL,
1110 ALC880_FIXUP_UNIWILL_DIG,
1112 ALC880_FIXUP_ASUS_W5A,
1113 ALC880_FIXUP_3ST_BASE,
1115 ALC880_FIXUP_3ST_DIG,
1116 ALC880_FIXUP_5ST_BASE,
1118 ALC880_FIXUP_5ST_DIG,
1119 ALC880_FIXUP_6ST_BASE,
1121 ALC880_FIXUP_6ST_DIG,
1122 ALC880_FIXUP_6ST_AUTOMUTE,
1125 /* enable the volume-knob widget support on NID 0x21 */
1126 static void alc880_fixup_vol_knob(struct hda_codec *codec,
1127 const struct hda_fixup *fix, int action)
1129 if (action == HDA_FIXUP_ACT_PROBE)
1130 snd_hda_jack_detect_enable_callback(codec, 0x21,
1131 alc_update_knob_master);
1134 static const struct hda_fixup alc880_fixups[] = {
1135 [ALC880_FIXUP_GPIO1] = {
1136 .type = HDA_FIXUP_FUNC,
1137 .v.func = alc_fixup_gpio1,
1139 [ALC880_FIXUP_GPIO2] = {
1140 .type = HDA_FIXUP_FUNC,
1141 .v.func = alc_fixup_gpio2,
1143 [ALC880_FIXUP_MEDION_RIM] = {
1144 .type = HDA_FIXUP_VERBS,
1145 .v.verbs = (const struct hda_verb[]) {
1146 { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
1147 { 0x20, AC_VERB_SET_PROC_COEF, 0x3060 },
1151 .chain_id = ALC880_FIXUP_GPIO2,
1153 [ALC880_FIXUP_LG] = {
1154 .type = HDA_FIXUP_PINS,
1155 .v.pins = (const struct hda_pintbl[]) {
1156 /* disable bogus unused pins */
1157 { 0x16, 0x411111f0 },
1158 { 0x18, 0x411111f0 },
1159 { 0x1a, 0x411111f0 },
1163 [ALC880_FIXUP_LG_LW25] = {
1164 .type = HDA_FIXUP_PINS,
1165 .v.pins = (const struct hda_pintbl[]) {
1166 { 0x1a, 0x0181344f }, /* line-in */
1167 { 0x1b, 0x0321403f }, /* headphone */
1171 [ALC880_FIXUP_W810] = {
1172 .type = HDA_FIXUP_PINS,
1173 .v.pins = (const struct hda_pintbl[]) {
1174 /* disable bogus unused pins */
1175 { 0x17, 0x411111f0 },
1179 .chain_id = ALC880_FIXUP_GPIO2,
1181 [ALC880_FIXUP_EAPD_COEF] = {
1182 .type = HDA_FIXUP_VERBS,
1183 .v.verbs = (const struct hda_verb[]) {
1184 /* change to EAPD mode */
1185 { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
1186 { 0x20, AC_VERB_SET_PROC_COEF, 0x3060 },
1190 [ALC880_FIXUP_TCL_S700] = {
1191 .type = HDA_FIXUP_VERBS,
1192 .v.verbs = (const struct hda_verb[]) {
1193 /* change to EAPD mode */
1194 { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
1195 { 0x20, AC_VERB_SET_PROC_COEF, 0x3070 },
1199 .chain_id = ALC880_FIXUP_GPIO2,
1201 [ALC880_FIXUP_VOL_KNOB] = {
1202 .type = HDA_FIXUP_FUNC,
1203 .v.func = alc880_fixup_vol_knob,
1205 [ALC880_FIXUP_FUJITSU] = {
1206 /* override all pins as BIOS on old Amilo is broken */
1207 .type = HDA_FIXUP_PINS,
1208 .v.pins = (const struct hda_pintbl[]) {
1209 { 0x14, 0x0121401f }, /* HP */
1210 { 0x15, 0x99030120 }, /* speaker */
1211 { 0x16, 0x99030130 }, /* bass speaker */
1212 { 0x17, 0x411111f0 }, /* N/A */
1213 { 0x18, 0x411111f0 }, /* N/A */
1214 { 0x19, 0x01a19950 }, /* mic-in */
1215 { 0x1a, 0x411111f0 }, /* N/A */
1216 { 0x1b, 0x411111f0 }, /* N/A */
1217 { 0x1c, 0x411111f0 }, /* N/A */
1218 { 0x1d, 0x411111f0 }, /* N/A */
1219 { 0x1e, 0x01454140 }, /* SPDIF out */
1223 .chain_id = ALC880_FIXUP_VOL_KNOB,
1225 [ALC880_FIXUP_F1734] = {
1226 /* almost compatible with FUJITSU, but no bass and SPDIF */
1227 .type = HDA_FIXUP_PINS,
1228 .v.pins = (const struct hda_pintbl[]) {
1229 { 0x14, 0x0121401f }, /* HP */
1230 { 0x15, 0x99030120 }, /* speaker */
1231 { 0x16, 0x411111f0 }, /* N/A */
1232 { 0x17, 0x411111f0 }, /* N/A */
1233 { 0x18, 0x411111f0 }, /* N/A */
1234 { 0x19, 0x01a19950 }, /* mic-in */
1235 { 0x1a, 0x411111f0 }, /* N/A */
1236 { 0x1b, 0x411111f0 }, /* N/A */
1237 { 0x1c, 0x411111f0 }, /* N/A */
1238 { 0x1d, 0x411111f0 }, /* N/A */
1239 { 0x1e, 0x411111f0 }, /* N/A */
1243 .chain_id = ALC880_FIXUP_VOL_KNOB,
1245 [ALC880_FIXUP_UNIWILL] = {
1246 /* need to fix HP and speaker pins to be parsed correctly */
1247 .type = HDA_FIXUP_PINS,
1248 .v.pins = (const struct hda_pintbl[]) {
1249 { 0x14, 0x0121411f }, /* HP */
1250 { 0x15, 0x99030120 }, /* speaker */
1251 { 0x16, 0x99030130 }, /* bass speaker */
1255 [ALC880_FIXUP_UNIWILL_DIG] = {
1256 .type = HDA_FIXUP_PINS,
1257 .v.pins = (const struct hda_pintbl[]) {
1258 /* disable bogus unused pins */
1259 { 0x17, 0x411111f0 },
1260 { 0x19, 0x411111f0 },
1261 { 0x1b, 0x411111f0 },
1262 { 0x1f, 0x411111f0 },
1266 [ALC880_FIXUP_Z71V] = {
1267 .type = HDA_FIXUP_PINS,
1268 .v.pins = (const struct hda_pintbl[]) {
1269 /* set up the whole pins as BIOS is utterly broken */
1270 { 0x14, 0x99030120 }, /* speaker */
1271 { 0x15, 0x0121411f }, /* HP */
1272 { 0x16, 0x411111f0 }, /* N/A */
1273 { 0x17, 0x411111f0 }, /* N/A */
1274 { 0x18, 0x01a19950 }, /* mic-in */
1275 { 0x19, 0x411111f0 }, /* N/A */
1276 { 0x1a, 0x01813031 }, /* line-in */
1277 { 0x1b, 0x411111f0 }, /* N/A */
1278 { 0x1c, 0x411111f0 }, /* N/A */
1279 { 0x1d, 0x411111f0 }, /* N/A */
1280 { 0x1e, 0x0144111e }, /* SPDIF */
1284 [ALC880_FIXUP_ASUS_W5A] = {
1285 .type = HDA_FIXUP_PINS,
1286 .v.pins = (const struct hda_pintbl[]) {
1287 /* set up the whole pins as BIOS is utterly broken */
1288 { 0x14, 0x0121411f }, /* HP */
1289 { 0x15, 0x411111f0 }, /* N/A */
1290 { 0x16, 0x411111f0 }, /* N/A */
1291 { 0x17, 0x411111f0 }, /* N/A */
1292 { 0x18, 0x90a60160 }, /* mic */
1293 { 0x19, 0x411111f0 }, /* N/A */
1294 { 0x1a, 0x411111f0 }, /* N/A */
1295 { 0x1b, 0x411111f0 }, /* N/A */
1296 { 0x1c, 0x411111f0 }, /* N/A */
1297 { 0x1d, 0x411111f0 }, /* N/A */
1298 { 0x1e, 0xb743111e }, /* SPDIF out */
1302 .chain_id = ALC880_FIXUP_GPIO1,
1304 [ALC880_FIXUP_3ST_BASE] = {
1305 .type = HDA_FIXUP_PINS,
1306 .v.pins = (const struct hda_pintbl[]) {
1307 { 0x14, 0x01014010 }, /* line-out */
1308 { 0x15, 0x411111f0 }, /* N/A */
1309 { 0x16, 0x411111f0 }, /* N/A */
1310 { 0x17, 0x411111f0 }, /* N/A */
1311 { 0x18, 0x01a19c30 }, /* mic-in */
1312 { 0x19, 0x0121411f }, /* HP */
1313 { 0x1a, 0x01813031 }, /* line-in */
1314 { 0x1b, 0x02a19c40 }, /* front-mic */
1315 { 0x1c, 0x411111f0 }, /* N/A */
1316 { 0x1d, 0x411111f0 }, /* N/A */
1317 /* 0x1e is filled in below */
1318 { 0x1f, 0x411111f0 }, /* N/A */
1322 [ALC880_FIXUP_3ST] = {
1323 .type = HDA_FIXUP_PINS,
1324 .v.pins = (const struct hda_pintbl[]) {
1325 { 0x1e, 0x411111f0 }, /* N/A */
1329 .chain_id = ALC880_FIXUP_3ST_BASE,
1331 [ALC880_FIXUP_3ST_DIG] = {
1332 .type = HDA_FIXUP_PINS,
1333 .v.pins = (const struct hda_pintbl[]) {
1334 { 0x1e, 0x0144111e }, /* SPDIF */
1338 .chain_id = ALC880_FIXUP_3ST_BASE,
1340 [ALC880_FIXUP_5ST_BASE] = {
1341 .type = HDA_FIXUP_PINS,
1342 .v.pins = (const struct hda_pintbl[]) {
1343 { 0x14, 0x01014010 }, /* front */
1344 { 0x15, 0x411111f0 }, /* N/A */
1345 { 0x16, 0x01011411 }, /* CLFE */
1346 { 0x17, 0x01016412 }, /* surr */
1347 { 0x18, 0x01a19c30 }, /* mic-in */
1348 { 0x19, 0x0121411f }, /* HP */
1349 { 0x1a, 0x01813031 }, /* line-in */
1350 { 0x1b, 0x02a19c40 }, /* front-mic */
1351 { 0x1c, 0x411111f0 }, /* N/A */
1352 { 0x1d, 0x411111f0 }, /* N/A */
1353 /* 0x1e is filled in below */
1354 { 0x1f, 0x411111f0 }, /* N/A */
1358 [ALC880_FIXUP_5ST] = {
1359 .type = HDA_FIXUP_PINS,
1360 .v.pins = (const struct hda_pintbl[]) {
1361 { 0x1e, 0x411111f0 }, /* N/A */
1365 .chain_id = ALC880_FIXUP_5ST_BASE,
1367 [ALC880_FIXUP_5ST_DIG] = {
1368 .type = HDA_FIXUP_PINS,
1369 .v.pins = (const struct hda_pintbl[]) {
1370 { 0x1e, 0x0144111e }, /* SPDIF */
1374 .chain_id = ALC880_FIXUP_5ST_BASE,
1376 [ALC880_FIXUP_6ST_BASE] = {
1377 .type = HDA_FIXUP_PINS,
1378 .v.pins = (const struct hda_pintbl[]) {
1379 { 0x14, 0x01014010 }, /* front */
1380 { 0x15, 0x01016412 }, /* surr */
1381 { 0x16, 0x01011411 }, /* CLFE */
1382 { 0x17, 0x01012414 }, /* side */
1383 { 0x18, 0x01a19c30 }, /* mic-in */
1384 { 0x19, 0x02a19c40 }, /* front-mic */
1385 { 0x1a, 0x01813031 }, /* line-in */
1386 { 0x1b, 0x0121411f }, /* HP */
1387 { 0x1c, 0x411111f0 }, /* N/A */
1388 { 0x1d, 0x411111f0 }, /* N/A */
1389 /* 0x1e is filled in below */
1390 { 0x1f, 0x411111f0 }, /* N/A */
1394 [ALC880_FIXUP_6ST] = {
1395 .type = HDA_FIXUP_PINS,
1396 .v.pins = (const struct hda_pintbl[]) {
1397 { 0x1e, 0x411111f0 }, /* N/A */
1401 .chain_id = ALC880_FIXUP_6ST_BASE,
1403 [ALC880_FIXUP_6ST_DIG] = {
1404 .type = HDA_FIXUP_PINS,
1405 .v.pins = (const struct hda_pintbl[]) {
1406 { 0x1e, 0x0144111e }, /* SPDIF */
1410 .chain_id = ALC880_FIXUP_6ST_BASE,
1412 [ALC880_FIXUP_6ST_AUTOMUTE] = {
1413 .type = HDA_FIXUP_PINS,
1414 .v.pins = (const struct hda_pintbl[]) {
1415 { 0x1b, 0x0121401f }, /* HP with jack detect */
1418 .chained_before = true,
1419 .chain_id = ALC880_FIXUP_6ST_BASE,
1423 static const struct snd_pci_quirk alc880_fixup_tbl[] = {
1424 SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_FIXUP_W810),
1425 SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS W5A", ALC880_FIXUP_ASUS_W5A),
1426 SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_FIXUP_Z71V),
1427 SND_PCI_QUIRK_VENDOR(0x1043, "ASUS", ALC880_FIXUP_GPIO1),
1428 SND_PCI_QUIRK(0x147b, 0x1045, "ABit AA8XE", ALC880_FIXUP_6ST_AUTOMUTE),
1429 SND_PCI_QUIRK(0x1558, 0x5401, "Clevo GPIO2", ALC880_FIXUP_GPIO2),
1430 SND_PCI_QUIRK_VENDOR(0x1558, "Clevo", ALC880_FIXUP_EAPD_COEF),
1431 SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_FIXUP_UNIWILL_DIG),
1432 SND_PCI_QUIRK(0x1584, 0x9054, "Uniwill", ALC880_FIXUP_F1734),
1433 SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_FIXUP_UNIWILL),
1434 SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_FIXUP_VOL_KNOB),
1435 SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_FIXUP_W810),
1436 SND_PCI_QUIRK(0x161f, 0x205d, "Medion Rim 2150", ALC880_FIXUP_MEDION_RIM),
1437 SND_PCI_QUIRK(0x1631, 0xe011, "PB 13201056", ALC880_FIXUP_6ST_AUTOMUTE),
1438 SND_PCI_QUIRK(0x1734, 0x107c, "FSC Amilo M1437", ALC880_FIXUP_FUJITSU),
1439 SND_PCI_QUIRK(0x1734, 0x1094, "FSC Amilo M1451G", ALC880_FIXUP_FUJITSU),
1440 SND_PCI_QUIRK(0x1734, 0x10ac, "FSC AMILO Xi 1526", ALC880_FIXUP_F1734),
1441 SND_PCI_QUIRK(0x1734, 0x10b0, "FSC Amilo Pi1556", ALC880_FIXUP_FUJITSU),
1442 SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_FIXUP_LG),
1443 SND_PCI_QUIRK(0x1854, 0x005f, "LG P1 Express", ALC880_FIXUP_LG),
1444 SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_FIXUP_LG),
1445 SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_FIXUP_LG_LW25),
1446 SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_FIXUP_TCL_S700),
1448 /* Below is the copied entries from alc880_quirks.c.
1449 * It's not quite sure whether BIOS sets the correct pin-config table
1450 * on these machines, thus they are kept to be compatible with
1451 * the old static quirks. Once when it's confirmed to work without
1452 * these overrides, it'd be better to remove.
1454 SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_FIXUP_5ST_DIG),
1455 SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_FIXUP_6ST),
1456 SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_FIXUP_3ST_DIG),
1457 SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_FIXUP_6ST_DIG),
1458 SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_FIXUP_6ST_DIG),
1459 SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_FIXUP_6ST_DIG),
1460 SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_FIXUP_3ST_DIG),
1461 SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_FIXUP_3ST),
1462 SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_FIXUP_6ST_DIG),
1463 SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_FIXUP_3ST),
1464 SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_FIXUP_3ST),
1465 SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_FIXUP_5ST),
1466 SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_FIXUP_5ST),
1467 SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_FIXUP_5ST),
1468 SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_FIXUP_6ST_DIG),
1469 SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_FIXUP_6ST_DIG),
1470 SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_FIXUP_6ST_DIG),
1471 SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_FIXUP_6ST_DIG),
1472 SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_FIXUP_5ST_DIG),
1473 SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_FIXUP_5ST_DIG),
1474 SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_FIXUP_5ST_DIG),
1475 SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_FIXUP_6ST_DIG), /* broken BIOS */
1476 SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_FIXUP_6ST_DIG),
1477 SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_FIXUP_5ST_DIG),
1478 SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_FIXUP_5ST_DIG),
1479 SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_FIXUP_5ST_DIG),
1480 SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_FIXUP_3ST_DIG),
1481 SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_FIXUP_5ST_DIG),
1482 SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_FIXUP_3ST_DIG),
1483 SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_FIXUP_3ST_DIG),
1484 SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_FIXUP_5ST_DIG),
1485 SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_FIXUP_5ST_DIG),
1486 SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_FIXUP_5ST_DIG),
1488 SND_PCI_QUIRK_VENDOR(0x8086, "Intel mobo", ALC880_FIXUP_3ST),
1489 SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_FIXUP_5ST_DIG),
1490 SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_FIXUP_6ST_DIG),
1494 static const struct hda_model_fixup alc880_fixup_models[] = {
1495 {.id = ALC880_FIXUP_3ST, .name = "3stack"},
1496 {.id = ALC880_FIXUP_3ST_DIG, .name = "3stack-digout"},
1497 {.id = ALC880_FIXUP_5ST, .name = "5stack"},
1498 {.id = ALC880_FIXUP_5ST_DIG, .name = "5stack-digout"},
1499 {.id = ALC880_FIXUP_6ST, .name = "6stack"},
1500 {.id = ALC880_FIXUP_6ST_DIG, .name = "6stack-digout"},
1501 {.id = ALC880_FIXUP_6ST_AUTOMUTE, .name = "6stack-automute"},
1507 * OK, here we have finally the patch for ALC880
1509 static int patch_alc880(struct hda_codec *codec)
1511 struct alc_spec *spec;
1514 err = alc_alloc_spec(codec, 0x0b);
1519 spec->gen.need_dac_fix = 1;
1520 spec->gen.beep_nid = 0x01;
1522 codec->patch_ops.unsol_event = alc880_unsol_event;
1524 snd_hda_pick_fixup(codec, alc880_fixup_models, alc880_fixup_tbl,
1526 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
1528 /* automatic parse from the BIOS config */
1529 err = alc880_parse_auto_config(codec);
1533 if (!spec->gen.no_analog) {
1534 err = set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
1539 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
1552 static int alc260_parse_auto_config(struct hda_codec *codec)
1554 static const hda_nid_t alc260_ignore[] = { 0x17, 0 };
1555 static const hda_nid_t alc260_ssids[] = { 0x10, 0x15, 0x0f, 0 };
1556 return alc_parse_auto_config(codec, alc260_ignore, alc260_ssids);
1563 ALC260_FIXUP_HP_DC5750,
1564 ALC260_FIXUP_HP_PIN_0F,
1567 ALC260_FIXUP_GPIO1_TOGGLE,
1568 ALC260_FIXUP_REPLACER,
1569 ALC260_FIXUP_HP_B1900,
1571 ALC260_FIXUP_FSC_S7020,
1572 ALC260_FIXUP_FSC_S7020_JWSE,
1573 ALC260_FIXUP_VAIO_PINS,
1576 static void alc260_gpio1_automute(struct hda_codec *codec)
1578 struct alc_spec *spec = codec->spec;
1580 alc_update_gpio_data(codec, 0x01, spec->gen.hp_jack_present);
1583 static void alc260_fixup_gpio1_toggle(struct hda_codec *codec,
1584 const struct hda_fixup *fix, int action)
1586 struct alc_spec *spec = codec->spec;
1587 if (action == HDA_FIXUP_ACT_PROBE) {
1588 /* although the machine has only one output pin, we need to
1589 * toggle GPIO1 according to the jack state
1591 spec->gen.automute_hook = alc260_gpio1_automute;
1592 spec->gen.detect_hp = 1;
1593 spec->gen.automute_speaker = 1;
1594 spec->gen.autocfg.hp_pins[0] = 0x0f; /* copy it for automute */
1595 snd_hda_jack_detect_enable_callback(codec, 0x0f,
1596 snd_hda_gen_hp_automute);
1597 alc_setup_gpio(codec, 0x01);
1601 static void alc260_fixup_kn1(struct hda_codec *codec,
1602 const struct hda_fixup *fix, int action)
1604 struct alc_spec *spec = codec->spec;
1605 static const struct hda_pintbl pincfgs[] = {
1606 { 0x0f, 0x02214000 }, /* HP/speaker */
1607 { 0x12, 0x90a60160 }, /* int mic */
1608 { 0x13, 0x02a19000 }, /* ext mic */
1609 { 0x18, 0x01446000 }, /* SPDIF out */
1610 /* disable bogus I/O pins */
1611 { 0x10, 0x411111f0 },
1612 { 0x11, 0x411111f0 },
1613 { 0x14, 0x411111f0 },
1614 { 0x15, 0x411111f0 },
1615 { 0x16, 0x411111f0 },
1616 { 0x17, 0x411111f0 },
1617 { 0x19, 0x411111f0 },
1622 case HDA_FIXUP_ACT_PRE_PROBE:
1623 snd_hda_apply_pincfgs(codec, pincfgs);
1624 spec->init_amp = ALC_INIT_NONE;
1629 static void alc260_fixup_fsc_s7020(struct hda_codec *codec,
1630 const struct hda_fixup *fix, int action)
1632 struct alc_spec *spec = codec->spec;
1633 if (action == HDA_FIXUP_ACT_PRE_PROBE)
1634 spec->init_amp = ALC_INIT_NONE;
1637 static void alc260_fixup_fsc_s7020_jwse(struct hda_codec *codec,
1638 const struct hda_fixup *fix, int action)
1640 struct alc_spec *spec = codec->spec;
1641 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
1642 spec->gen.add_jack_modes = 1;
1643 spec->gen.hp_mic = 1;
1647 static const struct hda_fixup alc260_fixups[] = {
1648 [ALC260_FIXUP_HP_DC5750] = {
1649 .type = HDA_FIXUP_PINS,
1650 .v.pins = (const struct hda_pintbl[]) {
1651 { 0x11, 0x90130110 }, /* speaker */
1655 [ALC260_FIXUP_HP_PIN_0F] = {
1656 .type = HDA_FIXUP_PINS,
1657 .v.pins = (const struct hda_pintbl[]) {
1658 { 0x0f, 0x01214000 }, /* HP */
1662 [ALC260_FIXUP_COEF] = {
1663 .type = HDA_FIXUP_VERBS,
1664 .v.verbs = (const struct hda_verb[]) {
1665 { 0x1a, AC_VERB_SET_COEF_INDEX, 0x07 },
1666 { 0x1a, AC_VERB_SET_PROC_COEF, 0x3040 },
1670 [ALC260_FIXUP_GPIO1] = {
1671 .type = HDA_FIXUP_FUNC,
1672 .v.func = alc_fixup_gpio1,
1674 [ALC260_FIXUP_GPIO1_TOGGLE] = {
1675 .type = HDA_FIXUP_FUNC,
1676 .v.func = alc260_fixup_gpio1_toggle,
1678 .chain_id = ALC260_FIXUP_HP_PIN_0F,
1680 [ALC260_FIXUP_REPLACER] = {
1681 .type = HDA_FIXUP_VERBS,
1682 .v.verbs = (const struct hda_verb[]) {
1683 { 0x1a, AC_VERB_SET_COEF_INDEX, 0x07 },
1684 { 0x1a, AC_VERB_SET_PROC_COEF, 0x3050 },
1688 .chain_id = ALC260_FIXUP_GPIO1_TOGGLE,
1690 [ALC260_FIXUP_HP_B1900] = {
1691 .type = HDA_FIXUP_FUNC,
1692 .v.func = alc260_fixup_gpio1_toggle,
1694 .chain_id = ALC260_FIXUP_COEF,
1696 [ALC260_FIXUP_KN1] = {
1697 .type = HDA_FIXUP_FUNC,
1698 .v.func = alc260_fixup_kn1,
1700 [ALC260_FIXUP_FSC_S7020] = {
1701 .type = HDA_FIXUP_FUNC,
1702 .v.func = alc260_fixup_fsc_s7020,
1704 [ALC260_FIXUP_FSC_S7020_JWSE] = {
1705 .type = HDA_FIXUP_FUNC,
1706 .v.func = alc260_fixup_fsc_s7020_jwse,
1708 .chain_id = ALC260_FIXUP_FSC_S7020,
1710 [ALC260_FIXUP_VAIO_PINS] = {
1711 .type = HDA_FIXUP_PINS,
1712 .v.pins = (const struct hda_pintbl[]) {
1713 /* Pin configs are missing completely on some VAIOs */
1714 { 0x0f, 0x01211020 },
1715 { 0x10, 0x0001003f },
1716 { 0x11, 0x411111f0 },
1717 { 0x12, 0x01a15930 },
1718 { 0x13, 0x411111f0 },
1719 { 0x14, 0x411111f0 },
1720 { 0x15, 0x411111f0 },
1721 { 0x16, 0x411111f0 },
1722 { 0x17, 0x411111f0 },
1723 { 0x18, 0x411111f0 },
1724 { 0x19, 0x411111f0 },
1730 static const struct snd_pci_quirk alc260_fixup_tbl[] = {
1731 SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_FIXUP_GPIO1),
1732 SND_PCI_QUIRK(0x1025, 0x007f, "Acer Aspire 9500", ALC260_FIXUP_COEF),
1733 SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_FIXUP_GPIO1),
1734 SND_PCI_QUIRK(0x103c, 0x280a, "HP dc5750", ALC260_FIXUP_HP_DC5750),
1735 SND_PCI_QUIRK(0x103c, 0x30ba, "HP Presario B1900", ALC260_FIXUP_HP_B1900),
1736 SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_FIXUP_VAIO_PINS),
1737 SND_PCI_QUIRK(0x104d, 0x81e2, "Sony VAIO TX", ALC260_FIXUP_HP_PIN_0F),
1738 SND_PCI_QUIRK(0x10cf, 0x1326, "FSC LifeBook S7020", ALC260_FIXUP_FSC_S7020),
1739 SND_PCI_QUIRK(0x1509, 0x4540, "Favorit 100XS", ALC260_FIXUP_GPIO1),
1740 SND_PCI_QUIRK(0x152d, 0x0729, "Quanta KN1", ALC260_FIXUP_KN1),
1741 SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_FIXUP_REPLACER),
1742 SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_FIXUP_COEF),
1746 static const struct hda_model_fixup alc260_fixup_models[] = {
1747 {.id = ALC260_FIXUP_GPIO1, .name = "gpio1"},
1748 {.id = ALC260_FIXUP_COEF, .name = "coef"},
1749 {.id = ALC260_FIXUP_FSC_S7020, .name = "fujitsu"},
1750 {.id = ALC260_FIXUP_FSC_S7020_JWSE, .name = "fujitsu-jwse"},
1756 static int patch_alc260(struct hda_codec *codec)
1758 struct alc_spec *spec;
1761 err = alc_alloc_spec(codec, 0x07);
1766 /* as quite a few machines require HP amp for speaker outputs,
1767 * it's easier to enable it unconditionally; even if it's unneeded,
1768 * it's almost harmless.
1770 spec->gen.prefer_hp_amp = 1;
1771 spec->gen.beep_nid = 0x01;
1773 spec->shutup = alc_eapd_shutup;
1775 snd_hda_pick_fixup(codec, alc260_fixup_models, alc260_fixup_tbl,
1777 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
1779 /* automatic parse from the BIOS config */
1780 err = alc260_parse_auto_config(codec);
1784 if (!spec->gen.no_analog) {
1785 err = set_beep_amp(spec, 0x07, 0x05, HDA_INPUT);
1790 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
1801 * ALC882/883/885/888/889 support
1803 * ALC882 is almost identical with ALC880 but has cleaner and more flexible
1804 * configuration. Each pin widget can choose any input DACs and a mixer.
1805 * Each ADC is connected from a mixer of all inputs. This makes possible
1806 * 6-channel independent captures.
1808 * In addition, an independent DAC for the multi-playback (not used in this
1816 ALC882_FIXUP_ABIT_AW9D_MAX,
1817 ALC882_FIXUP_LENOVO_Y530,
1818 ALC882_FIXUP_PB_M5210,
1819 ALC882_FIXUP_ACER_ASPIRE_7736,
1820 ALC882_FIXUP_ASUS_W90V,
1822 ALC889_FIXUP_FRONT_HP_NO_PRESENCE,
1823 ALC889_FIXUP_VAIO_TT,
1824 ALC888_FIXUP_EEE1601,
1827 ALC883_FIXUP_ACER_EAPD,
1832 ALC882_FIXUP_ASUS_W2JC,
1833 ALC882_FIXUP_ACER_ASPIRE_4930G,
1834 ALC882_FIXUP_ACER_ASPIRE_8930G,
1835 ALC882_FIXUP_ASPIRE_8930G_VERBS,
1836 ALC885_FIXUP_MACPRO_GPIO,
1837 ALC889_FIXUP_DAC_ROUTE,
1838 ALC889_FIXUP_MBP_VREF,
1839 ALC889_FIXUP_IMAC91_VREF,
1840 ALC889_FIXUP_MBA11_VREF,
1841 ALC889_FIXUP_MBA21_VREF,
1842 ALC889_FIXUP_MP11_VREF,
1843 ALC889_FIXUP_MP41_VREF,
1844 ALC882_FIXUP_INV_DMIC,
1845 ALC882_FIXUP_NO_PRIMARY_HP,
1846 ALC887_FIXUP_ASUS_BASS,
1847 ALC887_FIXUP_BASS_CHMAP,
1848 ALC1220_FIXUP_GB_DUAL_CODECS,
1849 ALC1220_FIXUP_CLEVO_P950,
1852 static void alc889_fixup_coef(struct hda_codec *codec,
1853 const struct hda_fixup *fix, int action)
1855 if (action != HDA_FIXUP_ACT_INIT)
1857 alc_update_coef_idx(codec, 7, 0, 0x2030);
1860 /* set up GPIO at initialization */
1861 static void alc885_fixup_macpro_gpio(struct hda_codec *codec,
1862 const struct hda_fixup *fix, int action)
1864 struct alc_spec *spec = codec->spec;
1866 spec->gpio_write_delay = true;
1867 alc_fixup_gpio3(codec, fix, action);
1870 /* Fix the connection of some pins for ALC889:
1871 * At least, Acer Aspire 5935 shows the connections to DAC3/4 don't
1872 * work correctly (bko#42740)
1874 static void alc889_fixup_dac_route(struct hda_codec *codec,
1875 const struct hda_fixup *fix, int action)
1877 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
1878 /* fake the connections during parsing the tree */
1879 hda_nid_t conn1[2] = { 0x0c, 0x0d };
1880 hda_nid_t conn2[2] = { 0x0e, 0x0f };
1881 snd_hda_override_conn_list(codec, 0x14, 2, conn1);
1882 snd_hda_override_conn_list(codec, 0x15, 2, conn1);
1883 snd_hda_override_conn_list(codec, 0x18, 2, conn2);
1884 snd_hda_override_conn_list(codec, 0x1a, 2, conn2);
1885 } else if (action == HDA_FIXUP_ACT_PROBE) {
1886 /* restore the connections */
1887 hda_nid_t conn[5] = { 0x0c, 0x0d, 0x0e, 0x0f, 0x26 };
1888 snd_hda_override_conn_list(codec, 0x14, 5, conn);
1889 snd_hda_override_conn_list(codec, 0x15, 5, conn);
1890 snd_hda_override_conn_list(codec, 0x18, 5, conn);
1891 snd_hda_override_conn_list(codec, 0x1a, 5, conn);
1895 /* Set VREF on HP pin */
1896 static void alc889_fixup_mbp_vref(struct hda_codec *codec,
1897 const struct hda_fixup *fix, int action)
1899 struct alc_spec *spec = codec->spec;
1900 static hda_nid_t nids[3] = { 0x14, 0x15, 0x19 };
1903 if (action != HDA_FIXUP_ACT_INIT)
1905 for (i = 0; i < ARRAY_SIZE(nids); i++) {
1906 unsigned int val = snd_hda_codec_get_pincfg(codec, nids[i]);
1907 if (get_defcfg_device(val) != AC_JACK_HP_OUT)
1909 val = snd_hda_codec_get_pin_target(codec, nids[i]);
1910 val |= AC_PINCTL_VREF_80;
1911 snd_hda_set_pin_ctl(codec, nids[i], val);
1912 spec->gen.keep_vref_in_automute = 1;
1917 static void alc889_fixup_mac_pins(struct hda_codec *codec,
1918 const hda_nid_t *nids, int num_nids)
1920 struct alc_spec *spec = codec->spec;
1923 for (i = 0; i < num_nids; i++) {
1925 val = snd_hda_codec_get_pin_target(codec, nids[i]);
1926 val |= AC_PINCTL_VREF_50;
1927 snd_hda_set_pin_ctl(codec, nids[i], val);
1929 spec->gen.keep_vref_in_automute = 1;
1932 /* Set VREF on speaker pins on imac91 */
1933 static void alc889_fixup_imac91_vref(struct hda_codec *codec,
1934 const struct hda_fixup *fix, int action)
1936 static hda_nid_t nids[2] = { 0x18, 0x1a };
1938 if (action == HDA_FIXUP_ACT_INIT)
1939 alc889_fixup_mac_pins(codec, nids, ARRAY_SIZE(nids));
1942 /* Set VREF on speaker pins on mba11 */
1943 static void alc889_fixup_mba11_vref(struct hda_codec *codec,
1944 const struct hda_fixup *fix, int action)
1946 static hda_nid_t nids[1] = { 0x18 };
1948 if (action == HDA_FIXUP_ACT_INIT)
1949 alc889_fixup_mac_pins(codec, nids, ARRAY_SIZE(nids));
1952 /* Set VREF on speaker pins on mba21 */
1953 static void alc889_fixup_mba21_vref(struct hda_codec *codec,
1954 const struct hda_fixup *fix, int action)
1956 static hda_nid_t nids[2] = { 0x18, 0x19 };
1958 if (action == HDA_FIXUP_ACT_INIT)
1959 alc889_fixup_mac_pins(codec, nids, ARRAY_SIZE(nids));
1962 /* Don't take HP output as primary
1963 * Strangely, the speaker output doesn't work on Vaio Z and some Vaio
1964 * all-in-one desktop PCs (for example VGC-LN51JGB) through DAC 0x05
1966 static void alc882_fixup_no_primary_hp(struct hda_codec *codec,
1967 const struct hda_fixup *fix, int action)
1969 struct alc_spec *spec = codec->spec;
1970 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
1971 spec->gen.no_primary_hp = 1;
1972 spec->gen.no_multi_io = 1;
1976 static void alc_fixup_bass_chmap(struct hda_codec *codec,
1977 const struct hda_fixup *fix, int action);
1979 /* For dual-codec configuration, we need to disable some features to avoid
1980 * conflicts of kctls and PCM streams
1982 static void alc_fixup_dual_codecs(struct hda_codec *codec,
1983 const struct hda_fixup *fix, int action)
1985 struct alc_spec *spec = codec->spec;
1987 if (action != HDA_FIXUP_ACT_PRE_PROBE)
1989 /* disable vmaster */
1990 spec->gen.suppress_vmaster = 1;
1991 /* auto-mute and auto-mic switch don't work with multiple codecs */
1992 spec->gen.suppress_auto_mute = 1;
1993 spec->gen.suppress_auto_mic = 1;
1994 /* disable aamix as well */
1995 spec->gen.mixer_nid = 0;
1996 /* add location prefix to avoid conflicts */
1997 codec->force_pin_prefix = 1;
2000 static void rename_ctl(struct hda_codec *codec, const char *oldname,
2001 const char *newname)
2003 struct snd_kcontrol *kctl;
2005 kctl = snd_hda_find_mixer_ctl(codec, oldname);
2007 strcpy(kctl->id.name, newname);
2010 static void alc1220_fixup_gb_dual_codecs(struct hda_codec *codec,
2011 const struct hda_fixup *fix,
2014 alc_fixup_dual_codecs(codec, fix, action);
2016 case HDA_FIXUP_ACT_PRE_PROBE:
2017 /* override card longname to provide a unique UCM profile */
2018 strcpy(codec->card->longname, "HDAudio-Gigabyte-ALC1220DualCodecs");
2020 case HDA_FIXUP_ACT_BUILD:
2021 /* rename Capture controls depending on the codec */
2022 rename_ctl(codec, "Capture Volume",
2024 "Rear-Panel Capture Volume" :
2025 "Front-Panel Capture Volume");
2026 rename_ctl(codec, "Capture Switch",
2028 "Rear-Panel Capture Switch" :
2029 "Front-Panel Capture Switch");
2034 static void alc1220_fixup_clevo_p950(struct hda_codec *codec,
2035 const struct hda_fixup *fix,
2038 hda_nid_t conn1[1] = { 0x0c };
2040 if (action != HDA_FIXUP_ACT_PRE_PROBE)
2043 alc_update_coef_idx(codec, 0x7, 0, 0x3c3);
2044 /* We therefore want to make sure 0x14 (front headphone) and
2045 * 0x1b (speakers) use the stereo DAC 0x02
2047 snd_hda_override_conn_list(codec, 0x14, 1, conn1);
2048 snd_hda_override_conn_list(codec, 0x1b, 1, conn1);
2051 static const struct hda_fixup alc882_fixups[] = {
2052 [ALC882_FIXUP_ABIT_AW9D_MAX] = {
2053 .type = HDA_FIXUP_PINS,
2054 .v.pins = (const struct hda_pintbl[]) {
2055 { 0x15, 0x01080104 }, /* side */
2056 { 0x16, 0x01011012 }, /* rear */
2057 { 0x17, 0x01016011 }, /* clfe */
2061 [ALC882_FIXUP_LENOVO_Y530] = {
2062 .type = HDA_FIXUP_PINS,
2063 .v.pins = (const struct hda_pintbl[]) {
2064 { 0x15, 0x99130112 }, /* rear int speakers */
2065 { 0x16, 0x99130111 }, /* subwoofer */
2069 [ALC882_FIXUP_PB_M5210] = {
2070 .type = HDA_FIXUP_PINCTLS,
2071 .v.pins = (const struct hda_pintbl[]) {
2072 { 0x19, PIN_VREF50 },
2076 [ALC882_FIXUP_ACER_ASPIRE_7736] = {
2077 .type = HDA_FIXUP_FUNC,
2078 .v.func = alc_fixup_sku_ignore,
2080 [ALC882_FIXUP_ASUS_W90V] = {
2081 .type = HDA_FIXUP_PINS,
2082 .v.pins = (const struct hda_pintbl[]) {
2083 { 0x16, 0x99130110 }, /* fix sequence for CLFE */
2087 [ALC889_FIXUP_CD] = {
2088 .type = HDA_FIXUP_PINS,
2089 .v.pins = (const struct hda_pintbl[]) {
2090 { 0x1c, 0x993301f0 }, /* CD */
2094 [ALC889_FIXUP_FRONT_HP_NO_PRESENCE] = {
2095 .type = HDA_FIXUP_PINS,
2096 .v.pins = (const struct hda_pintbl[]) {
2097 { 0x1b, 0x02214120 }, /* Front HP jack is flaky, disable jack detect */
2101 .chain_id = ALC889_FIXUP_CD,
2103 [ALC889_FIXUP_VAIO_TT] = {
2104 .type = HDA_FIXUP_PINS,
2105 .v.pins = (const struct hda_pintbl[]) {
2106 { 0x17, 0x90170111 }, /* hidden surround speaker */
2110 [ALC888_FIXUP_EEE1601] = {
2111 .type = HDA_FIXUP_VERBS,
2112 .v.verbs = (const struct hda_verb[]) {
2113 { 0x20, AC_VERB_SET_COEF_INDEX, 0x0b },
2114 { 0x20, AC_VERB_SET_PROC_COEF, 0x0838 },
2118 [ALC882_FIXUP_EAPD] = {
2119 .type = HDA_FIXUP_VERBS,
2120 .v.verbs = (const struct hda_verb[]) {
2121 /* change to EAPD mode */
2122 { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
2123 { 0x20, AC_VERB_SET_PROC_COEF, 0x3060 },
2127 [ALC883_FIXUP_EAPD] = {
2128 .type = HDA_FIXUP_VERBS,
2129 .v.verbs = (const struct hda_verb[]) {
2130 /* change to EAPD mode */
2131 { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
2132 { 0x20, AC_VERB_SET_PROC_COEF, 0x3070 },
2136 [ALC883_FIXUP_ACER_EAPD] = {
2137 .type = HDA_FIXUP_VERBS,
2138 .v.verbs = (const struct hda_verb[]) {
2139 /* eanable EAPD on Acer laptops */
2140 { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
2141 { 0x20, AC_VERB_SET_PROC_COEF, 0x3050 },
2145 [ALC882_FIXUP_GPIO1] = {
2146 .type = HDA_FIXUP_FUNC,
2147 .v.func = alc_fixup_gpio1,
2149 [ALC882_FIXUP_GPIO2] = {
2150 .type = HDA_FIXUP_FUNC,
2151 .v.func = alc_fixup_gpio2,
2153 [ALC882_FIXUP_GPIO3] = {
2154 .type = HDA_FIXUP_FUNC,
2155 .v.func = alc_fixup_gpio3,
2157 [ALC882_FIXUP_ASUS_W2JC] = {
2158 .type = HDA_FIXUP_FUNC,
2159 .v.func = alc_fixup_gpio1,
2161 .chain_id = ALC882_FIXUP_EAPD,
2163 [ALC889_FIXUP_COEF] = {
2164 .type = HDA_FIXUP_FUNC,
2165 .v.func = alc889_fixup_coef,
2167 [ALC882_FIXUP_ACER_ASPIRE_4930G] = {
2168 .type = HDA_FIXUP_PINS,
2169 .v.pins = (const struct hda_pintbl[]) {
2170 { 0x16, 0x99130111 }, /* CLFE speaker */
2171 { 0x17, 0x99130112 }, /* surround speaker */
2175 .chain_id = ALC882_FIXUP_GPIO1,
2177 [ALC882_FIXUP_ACER_ASPIRE_8930G] = {
2178 .type = HDA_FIXUP_PINS,
2179 .v.pins = (const struct hda_pintbl[]) {
2180 { 0x16, 0x99130111 }, /* CLFE speaker */
2181 { 0x1b, 0x99130112 }, /* surround speaker */
2185 .chain_id = ALC882_FIXUP_ASPIRE_8930G_VERBS,
2187 [ALC882_FIXUP_ASPIRE_8930G_VERBS] = {
2188 /* additional init verbs for Acer Aspire 8930G */
2189 .type = HDA_FIXUP_VERBS,
2190 .v.verbs = (const struct hda_verb[]) {
2191 /* Enable all DACs */
2192 /* DAC DISABLE/MUTE 1? */
2193 /* setting bits 1-5 disables DAC nids 0x02-0x06
2194 * apparently. Init=0x38 */
2195 { 0x20, AC_VERB_SET_COEF_INDEX, 0x03 },
2196 { 0x20, AC_VERB_SET_PROC_COEF, 0x0000 },
2197 /* DAC DISABLE/MUTE 2? */
2198 /* some bit here disables the other DACs.
2200 { 0x20, AC_VERB_SET_COEF_INDEX, 0x08 },
2201 { 0x20, AC_VERB_SET_PROC_COEF, 0x0000 },
2203 * This laptop has a stereo digital microphone.
2204 * The mics are only 1cm apart which makes the stereo
2205 * useless. However, either the mic or the ALC889
2206 * makes the signal become a difference/sum signal
2207 * instead of standard stereo, which is annoying.
2208 * So instead we flip this bit which makes the
2209 * codec replicate the sum signal to both channels,
2210 * turning it into a normal mono mic.
2212 /* DMIC_CONTROL? Init value = 0x0001 */
2213 { 0x20, AC_VERB_SET_COEF_INDEX, 0x0b },
2214 { 0x20, AC_VERB_SET_PROC_COEF, 0x0003 },
2215 { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
2216 { 0x20, AC_VERB_SET_PROC_COEF, 0x3050 },
2220 .chain_id = ALC882_FIXUP_GPIO1,
2222 [ALC885_FIXUP_MACPRO_GPIO] = {
2223 .type = HDA_FIXUP_FUNC,
2224 .v.func = alc885_fixup_macpro_gpio,
2226 [ALC889_FIXUP_DAC_ROUTE] = {
2227 .type = HDA_FIXUP_FUNC,
2228 .v.func = alc889_fixup_dac_route,
2230 [ALC889_FIXUP_MBP_VREF] = {
2231 .type = HDA_FIXUP_FUNC,
2232 .v.func = alc889_fixup_mbp_vref,
2234 .chain_id = ALC882_FIXUP_GPIO1,
2236 [ALC889_FIXUP_IMAC91_VREF] = {
2237 .type = HDA_FIXUP_FUNC,
2238 .v.func = alc889_fixup_imac91_vref,
2240 .chain_id = ALC882_FIXUP_GPIO1,
2242 [ALC889_FIXUP_MBA11_VREF] = {
2243 .type = HDA_FIXUP_FUNC,
2244 .v.func = alc889_fixup_mba11_vref,
2246 .chain_id = ALC889_FIXUP_MBP_VREF,
2248 [ALC889_FIXUP_MBA21_VREF] = {
2249 .type = HDA_FIXUP_FUNC,
2250 .v.func = alc889_fixup_mba21_vref,
2252 .chain_id = ALC889_FIXUP_MBP_VREF,
2254 [ALC889_FIXUP_MP11_VREF] = {
2255 .type = HDA_FIXUP_FUNC,
2256 .v.func = alc889_fixup_mba11_vref,
2258 .chain_id = ALC885_FIXUP_MACPRO_GPIO,
2260 [ALC889_FIXUP_MP41_VREF] = {
2261 .type = HDA_FIXUP_FUNC,
2262 .v.func = alc889_fixup_mbp_vref,
2264 .chain_id = ALC885_FIXUP_MACPRO_GPIO,
2266 [ALC882_FIXUP_INV_DMIC] = {
2267 .type = HDA_FIXUP_FUNC,
2268 .v.func = alc_fixup_inv_dmic,
2270 [ALC882_FIXUP_NO_PRIMARY_HP] = {
2271 .type = HDA_FIXUP_FUNC,
2272 .v.func = alc882_fixup_no_primary_hp,
2274 [ALC887_FIXUP_ASUS_BASS] = {
2275 .type = HDA_FIXUP_PINS,
2276 .v.pins = (const struct hda_pintbl[]) {
2277 {0x16, 0x99130130}, /* bass speaker */
2281 .chain_id = ALC887_FIXUP_BASS_CHMAP,
2283 [ALC887_FIXUP_BASS_CHMAP] = {
2284 .type = HDA_FIXUP_FUNC,
2285 .v.func = alc_fixup_bass_chmap,
2287 [ALC1220_FIXUP_GB_DUAL_CODECS] = {
2288 .type = HDA_FIXUP_FUNC,
2289 .v.func = alc1220_fixup_gb_dual_codecs,
2291 [ALC1220_FIXUP_CLEVO_P950] = {
2292 .type = HDA_FIXUP_FUNC,
2293 .v.func = alc1220_fixup_clevo_p950,
2297 static const struct snd_pci_quirk alc882_fixup_tbl[] = {
2298 SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_FIXUP_ACER_EAPD),
2299 SND_PCI_QUIRK(0x1025, 0x0090, "Acer Aspire", ALC883_FIXUP_ACER_EAPD),
2300 SND_PCI_QUIRK(0x1025, 0x0107, "Acer Aspire", ALC883_FIXUP_ACER_EAPD),
2301 SND_PCI_QUIRK(0x1025, 0x010a, "Acer Ferrari 5000", ALC883_FIXUP_ACER_EAPD),
2302 SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_FIXUP_ACER_EAPD),
2303 SND_PCI_QUIRK(0x1025, 0x0112, "Acer Aspire 9303", ALC883_FIXUP_ACER_EAPD),
2304 SND_PCI_QUIRK(0x1025, 0x0121, "Acer Aspire 5920G", ALC883_FIXUP_ACER_EAPD),
2305 SND_PCI_QUIRK(0x1025, 0x013e, "Acer Aspire 4930G",
2306 ALC882_FIXUP_ACER_ASPIRE_4930G),
2307 SND_PCI_QUIRK(0x1025, 0x013f, "Acer Aspire 5930G",
2308 ALC882_FIXUP_ACER_ASPIRE_4930G),
2309 SND_PCI_QUIRK(0x1025, 0x0145, "Acer Aspire 8930G",
2310 ALC882_FIXUP_ACER_ASPIRE_8930G),
2311 SND_PCI_QUIRK(0x1025, 0x0146, "Acer Aspire 6935G",
2312 ALC882_FIXUP_ACER_ASPIRE_8930G),
2313 SND_PCI_QUIRK(0x1025, 0x015e, "Acer Aspire 6930G",
2314 ALC882_FIXUP_ACER_ASPIRE_4930G),
2315 SND_PCI_QUIRK(0x1025, 0x0166, "Acer Aspire 6530G",
2316 ALC882_FIXUP_ACER_ASPIRE_4930G),
2317 SND_PCI_QUIRK(0x1025, 0x0142, "Acer Aspire 7730G",
2318 ALC882_FIXUP_ACER_ASPIRE_4930G),
2319 SND_PCI_QUIRK(0x1025, 0x0155, "Packard-Bell M5120", ALC882_FIXUP_PB_M5210),
2320 SND_PCI_QUIRK(0x1025, 0x021e, "Acer Aspire 5739G",
2321 ALC882_FIXUP_ACER_ASPIRE_4930G),
2322 SND_PCI_QUIRK(0x1025, 0x0259, "Acer Aspire 5935", ALC889_FIXUP_DAC_ROUTE),
2323 SND_PCI_QUIRK(0x1025, 0x026b, "Acer Aspire 8940G", ALC882_FIXUP_ACER_ASPIRE_8930G),
2324 SND_PCI_QUIRK(0x1025, 0x0296, "Acer Aspire 7736z", ALC882_FIXUP_ACER_ASPIRE_7736),
2325 SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_FIXUP_EAPD),
2326 SND_PCI_QUIRK(0x1043, 0x1873, "ASUS W90V", ALC882_FIXUP_ASUS_W90V),
2327 SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_FIXUP_ASUS_W2JC),
2328 SND_PCI_QUIRK(0x1043, 0x835f, "Asus Eee 1601", ALC888_FIXUP_EEE1601),
2329 SND_PCI_QUIRK(0x1043, 0x84bc, "ASUS ET2700", ALC887_FIXUP_ASUS_BASS),
2330 SND_PCI_QUIRK(0x1043, 0x8691, "ASUS ROG Ranger VIII", ALC882_FIXUP_GPIO3),
2331 SND_PCI_QUIRK(0x104d, 0x9047, "Sony Vaio TT", ALC889_FIXUP_VAIO_TT),
2332 SND_PCI_QUIRK(0x104d, 0x905a, "Sony Vaio Z", ALC882_FIXUP_NO_PRIMARY_HP),
2333 SND_PCI_QUIRK(0x104d, 0x9060, "Sony Vaio VPCL14M1R", ALC882_FIXUP_NO_PRIMARY_HP),
2334 SND_PCI_QUIRK(0x104d, 0x9043, "Sony Vaio VGC-LN51JGB", ALC882_FIXUP_NO_PRIMARY_HP),
2335 SND_PCI_QUIRK(0x104d, 0x9044, "Sony VAIO AiO", ALC882_FIXUP_NO_PRIMARY_HP),
2337 /* All Apple entries are in codec SSIDs */
2338 SND_PCI_QUIRK(0x106b, 0x00a0, "MacBookPro 3,1", ALC889_FIXUP_MBP_VREF),
2339 SND_PCI_QUIRK(0x106b, 0x00a1, "Macbook", ALC889_FIXUP_MBP_VREF),
2340 SND_PCI_QUIRK(0x106b, 0x00a4, "MacbookPro 4,1", ALC889_FIXUP_MBP_VREF),
2341 SND_PCI_QUIRK(0x106b, 0x0c00, "Mac Pro", ALC889_FIXUP_MP11_VREF),
2342 SND_PCI_QUIRK(0x106b, 0x1000, "iMac 24", ALC885_FIXUP_MACPRO_GPIO),
2343 SND_PCI_QUIRK(0x106b, 0x2800, "AppleTV", ALC885_FIXUP_MACPRO_GPIO),
2344 SND_PCI_QUIRK(0x106b, 0x2c00, "MacbookPro rev3", ALC889_FIXUP_MBP_VREF),
2345 SND_PCI_QUIRK(0x106b, 0x3000, "iMac", ALC889_FIXUP_MBP_VREF),
2346 SND_PCI_QUIRK(0x106b, 0x3200, "iMac 7,1 Aluminum", ALC882_FIXUP_EAPD),
2347 SND_PCI_QUIRK(0x106b, 0x3400, "MacBookAir 1,1", ALC889_FIXUP_MBA11_VREF),
2348 SND_PCI_QUIRK(0x106b, 0x3500, "MacBookAir 2,1", ALC889_FIXUP_MBA21_VREF),
2349 SND_PCI_QUIRK(0x106b, 0x3600, "Macbook 3,1", ALC889_FIXUP_MBP_VREF),
2350 SND_PCI_QUIRK(0x106b, 0x3800, "MacbookPro 4,1", ALC889_FIXUP_MBP_VREF),
2351 SND_PCI_QUIRK(0x106b, 0x3e00, "iMac 24 Aluminum", ALC885_FIXUP_MACPRO_GPIO),
2352 SND_PCI_QUIRK(0x106b, 0x3f00, "Macbook 5,1", ALC889_FIXUP_IMAC91_VREF),
2353 SND_PCI_QUIRK(0x106b, 0x4000, "MacbookPro 5,1", ALC889_FIXUP_IMAC91_VREF),
2354 SND_PCI_QUIRK(0x106b, 0x4100, "Macmini 3,1", ALC889_FIXUP_IMAC91_VREF),
2355 SND_PCI_QUIRK(0x106b, 0x4200, "Mac Pro 4,1/5,1", ALC889_FIXUP_MP41_VREF),
2356 SND_PCI_QUIRK(0x106b, 0x4300, "iMac 9,1", ALC889_FIXUP_IMAC91_VREF),
2357 SND_PCI_QUIRK(0x106b, 0x4600, "MacbookPro 5,2", ALC889_FIXUP_IMAC91_VREF),
2358 SND_PCI_QUIRK(0x106b, 0x4900, "iMac 9,1 Aluminum", ALC889_FIXUP_IMAC91_VREF),
2359 SND_PCI_QUIRK(0x106b, 0x4a00, "Macbook 5,2", ALC889_FIXUP_MBA11_VREF),
2361 SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC882_FIXUP_EAPD),
2362 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte EP45-DS3/Z87X-UD3H", ALC889_FIXUP_FRONT_HP_NO_PRESENCE),
2363 SND_PCI_QUIRK(0x1458, 0xa0b8, "Gigabyte AZ370-Gaming", ALC1220_FIXUP_GB_DUAL_CODECS),
2364 SND_PCI_QUIRK(0x1462, 0x7350, "MSI-7350", ALC889_FIXUP_CD),
2365 SND_PCI_QUIRK(0x1462, 0xda57, "MSI Z270-Gaming", ALC1220_FIXUP_GB_DUAL_CODECS),
2366 SND_PCI_QUIRK_VENDOR(0x1462, "MSI", ALC882_FIXUP_GPIO3),
2367 SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", ALC882_FIXUP_ABIT_AW9D_MAX),
2368 SND_PCI_QUIRK(0x1558, 0x9501, "Clevo P950HR", ALC1220_FIXUP_CLEVO_P950),
2369 SND_PCI_QUIRK(0x1558, 0x95e1, "Clevo P95xER", ALC1220_FIXUP_CLEVO_P950),
2370 SND_PCI_QUIRK(0x1558, 0x95e2, "Clevo P950ER", ALC1220_FIXUP_CLEVO_P950),
2371 SND_PCI_QUIRK_VENDOR(0x1558, "Clevo laptop", ALC882_FIXUP_EAPD),
2372 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_FIXUP_EAPD),
2373 SND_PCI_QUIRK(0x17aa, 0x3a0d, "Lenovo Y530", ALC882_FIXUP_LENOVO_Y530),
2374 SND_PCI_QUIRK(0x8086, 0x0022, "DX58SO", ALC889_FIXUP_COEF),
2378 static const struct hda_model_fixup alc882_fixup_models[] = {
2379 {.id = ALC882_FIXUP_ABIT_AW9D_MAX, .name = "abit-aw9d"},
2380 {.id = ALC882_FIXUP_LENOVO_Y530, .name = "lenovo-y530"},
2381 {.id = ALC882_FIXUP_ACER_ASPIRE_7736, .name = "acer-aspire-7736"},
2382 {.id = ALC882_FIXUP_ASUS_W90V, .name = "asus-w90v"},
2383 {.id = ALC889_FIXUP_CD, .name = "cd"},
2384 {.id = ALC889_FIXUP_FRONT_HP_NO_PRESENCE, .name = "no-front-hp"},
2385 {.id = ALC889_FIXUP_VAIO_TT, .name = "vaio-tt"},
2386 {.id = ALC888_FIXUP_EEE1601, .name = "eee1601"},
2387 {.id = ALC882_FIXUP_EAPD, .name = "alc882-eapd"},
2388 {.id = ALC883_FIXUP_EAPD, .name = "alc883-eapd"},
2389 {.id = ALC882_FIXUP_GPIO1, .name = "gpio1"},
2390 {.id = ALC882_FIXUP_GPIO2, .name = "gpio2"},
2391 {.id = ALC882_FIXUP_GPIO3, .name = "gpio3"},
2392 {.id = ALC889_FIXUP_COEF, .name = "alc889-coef"},
2393 {.id = ALC882_FIXUP_ASUS_W2JC, .name = "asus-w2jc"},
2394 {.id = ALC882_FIXUP_ACER_ASPIRE_4930G, .name = "acer-aspire-4930g"},
2395 {.id = ALC882_FIXUP_ACER_ASPIRE_8930G, .name = "acer-aspire-8930g"},
2396 {.id = ALC883_FIXUP_ACER_EAPD, .name = "acer-aspire"},
2397 {.id = ALC885_FIXUP_MACPRO_GPIO, .name = "macpro-gpio"},
2398 {.id = ALC889_FIXUP_DAC_ROUTE, .name = "dac-route"},
2399 {.id = ALC889_FIXUP_MBP_VREF, .name = "mbp-vref"},
2400 {.id = ALC889_FIXUP_IMAC91_VREF, .name = "imac91-vref"},
2401 {.id = ALC889_FIXUP_MBA11_VREF, .name = "mba11-vref"},
2402 {.id = ALC889_FIXUP_MBA21_VREF, .name = "mba21-vref"},
2403 {.id = ALC889_FIXUP_MP11_VREF, .name = "mp11-vref"},
2404 {.id = ALC889_FIXUP_MP41_VREF, .name = "mp41-vref"},
2405 {.id = ALC882_FIXUP_INV_DMIC, .name = "inv-dmic"},
2406 {.id = ALC882_FIXUP_NO_PRIMARY_HP, .name = "no-primary-hp"},
2407 {.id = ALC887_FIXUP_ASUS_BASS, .name = "asus-bass"},
2408 {.id = ALC1220_FIXUP_GB_DUAL_CODECS, .name = "dual-codecs"},
2409 {.id = ALC1220_FIXUP_CLEVO_P950, .name = "clevo-p950"},
2414 * BIOS auto configuration
2416 /* almost identical with ALC880 parser... */
2417 static int alc882_parse_auto_config(struct hda_codec *codec)
2419 static const hda_nid_t alc882_ignore[] = { 0x1d, 0 };
2420 static const hda_nid_t alc882_ssids[] = { 0x15, 0x1b, 0x14, 0 };
2421 return alc_parse_auto_config(codec, alc882_ignore, alc882_ssids);
2426 static int patch_alc882(struct hda_codec *codec)
2428 struct alc_spec *spec;
2431 err = alc_alloc_spec(codec, 0x0b);
2437 switch (codec->core.vendor_id) {
2444 /* ALC883 and variants */
2445 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
2449 snd_hda_pick_fixup(codec, alc882_fixup_models, alc882_fixup_tbl,
2451 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
2453 alc_auto_parse_customize_define(codec);
2455 if (has_cdefine_beep(codec))
2456 spec->gen.beep_nid = 0x01;
2458 /* automatic parse from the BIOS config */
2459 err = alc882_parse_auto_config(codec);
2463 if (!spec->gen.no_analog && spec->gen.beep_nid) {
2464 err = set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
2469 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
2482 static int alc262_parse_auto_config(struct hda_codec *codec)
2484 static const hda_nid_t alc262_ignore[] = { 0x1d, 0 };
2485 static const hda_nid_t alc262_ssids[] = { 0x15, 0x1b, 0x14, 0 };
2486 return alc_parse_auto_config(codec, alc262_ignore, alc262_ssids);
2493 ALC262_FIXUP_FSC_H270,
2494 ALC262_FIXUP_FSC_S7110,
2495 ALC262_FIXUP_HP_Z200,
2497 ALC262_FIXUP_LENOVO_3000,
2499 ALC262_FIXUP_BENQ_T31,
2500 ALC262_FIXUP_INV_DMIC,
2501 ALC262_FIXUP_INTEL_BAYLEYBAY,
2504 static const struct hda_fixup alc262_fixups[] = {
2505 [ALC262_FIXUP_FSC_H270] = {
2506 .type = HDA_FIXUP_PINS,
2507 .v.pins = (const struct hda_pintbl[]) {
2508 { 0x14, 0x99130110 }, /* speaker */
2509 { 0x15, 0x0221142f }, /* front HP */
2510 { 0x1b, 0x0121141f }, /* rear HP */
2514 [ALC262_FIXUP_FSC_S7110] = {
2515 .type = HDA_FIXUP_PINS,
2516 .v.pins = (const struct hda_pintbl[]) {
2517 { 0x15, 0x90170110 }, /* speaker */
2521 .chain_id = ALC262_FIXUP_BENQ,
2523 [ALC262_FIXUP_HP_Z200] = {
2524 .type = HDA_FIXUP_PINS,
2525 .v.pins = (const struct hda_pintbl[]) {
2526 { 0x16, 0x99130120 }, /* internal speaker */
2530 [ALC262_FIXUP_TYAN] = {
2531 .type = HDA_FIXUP_PINS,
2532 .v.pins = (const struct hda_pintbl[]) {
2533 { 0x14, 0x1993e1f0 }, /* int AUX */
2537 [ALC262_FIXUP_LENOVO_3000] = {
2538 .type = HDA_FIXUP_PINCTLS,
2539 .v.pins = (const struct hda_pintbl[]) {
2540 { 0x19, PIN_VREF50 },
2544 .chain_id = ALC262_FIXUP_BENQ,
2546 [ALC262_FIXUP_BENQ] = {
2547 .type = HDA_FIXUP_VERBS,
2548 .v.verbs = (const struct hda_verb[]) {
2549 { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
2550 { 0x20, AC_VERB_SET_PROC_COEF, 0x3070 },
2554 [ALC262_FIXUP_BENQ_T31] = {
2555 .type = HDA_FIXUP_VERBS,
2556 .v.verbs = (const struct hda_verb[]) {
2557 { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
2558 { 0x20, AC_VERB_SET_PROC_COEF, 0x3050 },
2562 [ALC262_FIXUP_INV_DMIC] = {
2563 .type = HDA_FIXUP_FUNC,
2564 .v.func = alc_fixup_inv_dmic,
2566 [ALC262_FIXUP_INTEL_BAYLEYBAY] = {
2567 .type = HDA_FIXUP_FUNC,
2568 .v.func = alc_fixup_no_depop_delay,
2572 static const struct snd_pci_quirk alc262_fixup_tbl[] = {
2573 SND_PCI_QUIRK(0x103c, 0x170b, "HP Z200", ALC262_FIXUP_HP_Z200),
2574 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu Lifebook S7110", ALC262_FIXUP_FSC_S7110),
2575 SND_PCI_QUIRK(0x10cf, 0x142d, "Fujitsu Lifebook E8410", ALC262_FIXUP_BENQ),
2576 SND_PCI_QUIRK(0x10f1, 0x2915, "Tyan Thunder n6650W", ALC262_FIXUP_TYAN),
2577 SND_PCI_QUIRK(0x1734, 0x1141, "FSC ESPRIMO U9210", ALC262_FIXUP_FSC_H270),
2578 SND_PCI_QUIRK(0x1734, 0x1147, "FSC Celsius H270", ALC262_FIXUP_FSC_H270),
2579 SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000", ALC262_FIXUP_LENOVO_3000),
2580 SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_FIXUP_BENQ),
2581 SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_FIXUP_BENQ_T31),
2582 SND_PCI_QUIRK(0x8086, 0x7270, "BayleyBay", ALC262_FIXUP_INTEL_BAYLEYBAY),
2586 static const struct hda_model_fixup alc262_fixup_models[] = {
2587 {.id = ALC262_FIXUP_INV_DMIC, .name = "inv-dmic"},
2588 {.id = ALC262_FIXUP_FSC_H270, .name = "fsc-h270"},
2589 {.id = ALC262_FIXUP_FSC_S7110, .name = "fsc-s7110"},
2590 {.id = ALC262_FIXUP_HP_Z200, .name = "hp-z200"},
2591 {.id = ALC262_FIXUP_TYAN, .name = "tyan"},
2592 {.id = ALC262_FIXUP_LENOVO_3000, .name = "lenovo-3000"},
2593 {.id = ALC262_FIXUP_BENQ, .name = "benq"},
2594 {.id = ALC262_FIXUP_BENQ_T31, .name = "benq-t31"},
2595 {.id = ALC262_FIXUP_INTEL_BAYLEYBAY, .name = "bayleybay"},
2601 static int patch_alc262(struct hda_codec *codec)
2603 struct alc_spec *spec;
2606 err = alc_alloc_spec(codec, 0x0b);
2611 spec->gen.shared_mic_vref_pin = 0x18;
2613 spec->shutup = alc_eapd_shutup;
2616 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
2619 alc_update_coefex_idx(codec, 0x1a, 7, 0, 0x80);
2621 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
2623 snd_hda_pick_fixup(codec, alc262_fixup_models, alc262_fixup_tbl,
2625 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
2627 alc_auto_parse_customize_define(codec);
2629 if (has_cdefine_beep(codec))
2630 spec->gen.beep_nid = 0x01;
2632 /* automatic parse from the BIOS config */
2633 err = alc262_parse_auto_config(codec);
2637 if (!spec->gen.no_analog && spec->gen.beep_nid) {
2638 err = set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
2643 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
2655 /* bind Beep switches of both NID 0x0f and 0x10 */
2656 static int alc268_beep_switch_put(struct snd_kcontrol *kcontrol,
2657 struct snd_ctl_elem_value *ucontrol)
2659 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2663 mutex_lock(&codec->control_mutex);
2664 pval = kcontrol->private_value;
2665 kcontrol->private_value = (pval & ~0xff) | 0x0f;
2666 err = snd_hda_mixer_amp_switch_put(kcontrol, ucontrol);
2668 kcontrol->private_value = (pval & ~0xff) | 0x10;
2669 err = snd_hda_mixer_amp_switch_put(kcontrol, ucontrol);
2671 kcontrol->private_value = pval;
2672 mutex_unlock(&codec->control_mutex);
2676 static const struct snd_kcontrol_new alc268_beep_mixer[] = {
2677 HDA_CODEC_VOLUME("Beep Playback Volume", 0x1d, 0x0, HDA_INPUT),
2679 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2680 .name = "Beep Playback Switch",
2681 .subdevice = HDA_SUBDEV_AMP_FLAG,
2682 .info = snd_hda_mixer_amp_switch_info,
2683 .get = snd_hda_mixer_amp_switch_get,
2684 .put = alc268_beep_switch_put,
2685 .private_value = HDA_COMPOSE_AMP_VAL(0x0f, 3, 1, HDA_INPUT)
2689 /* set PCBEEP vol = 0, mute connections */
2690 static const struct hda_verb alc268_beep_init_verbs[] = {
2691 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2692 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2693 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2698 ALC268_FIXUP_INV_DMIC,
2699 ALC268_FIXUP_HP_EAPD,
2703 static const struct hda_fixup alc268_fixups[] = {
2704 [ALC268_FIXUP_INV_DMIC] = {
2705 .type = HDA_FIXUP_FUNC,
2706 .v.func = alc_fixup_inv_dmic,
2708 [ALC268_FIXUP_HP_EAPD] = {
2709 .type = HDA_FIXUP_VERBS,
2710 .v.verbs = (const struct hda_verb[]) {
2711 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 0},
2715 [ALC268_FIXUP_SPDIF] = {
2716 .type = HDA_FIXUP_PINS,
2717 .v.pins = (const struct hda_pintbl[]) {
2718 { 0x1e, 0x014b1180 }, /* enable SPDIF out */
2724 static const struct hda_model_fixup alc268_fixup_models[] = {
2725 {.id = ALC268_FIXUP_INV_DMIC, .name = "inv-dmic"},
2726 {.id = ALC268_FIXUP_HP_EAPD, .name = "hp-eapd"},
2727 {.id = ALC268_FIXUP_SPDIF, .name = "spdif"},
2731 static const struct snd_pci_quirk alc268_fixup_tbl[] = {
2732 SND_PCI_QUIRK(0x1025, 0x0139, "Acer TravelMate 6293", ALC268_FIXUP_SPDIF),
2733 SND_PCI_QUIRK(0x1025, 0x015b, "Acer AOA 150 (ZG5)", ALC268_FIXUP_INV_DMIC),
2734 /* below is codec SSID since multiple Toshiba laptops have the
2735 * same PCI SSID 1179:ff00
2737 SND_PCI_QUIRK(0x1179, 0xff06, "Toshiba P200", ALC268_FIXUP_HP_EAPD),
2742 * BIOS auto configuration
2744 static int alc268_parse_auto_config(struct hda_codec *codec)
2746 static const hda_nid_t alc268_ssids[] = { 0x15, 0x1b, 0x14, 0 };
2747 return alc_parse_auto_config(codec, NULL, alc268_ssids);
2752 static int patch_alc268(struct hda_codec *codec)
2754 struct alc_spec *spec;
2757 /* ALC268 has no aa-loopback mixer */
2758 err = alc_alloc_spec(codec, 0);
2763 spec->gen.beep_nid = 0x01;
2765 spec->shutup = alc_eapd_shutup;
2767 snd_hda_pick_fixup(codec, alc268_fixup_models, alc268_fixup_tbl, alc268_fixups);
2768 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
2770 /* automatic parse from the BIOS config */
2771 err = alc268_parse_auto_config(codec);
2775 if (err > 0 && !spec->gen.no_analog &&
2776 spec->gen.autocfg.speaker_pins[0] != 0x1d) {
2777 for (i = 0; i < ARRAY_SIZE(alc268_beep_mixer); i++) {
2778 if (!snd_hda_gen_add_kctl(&spec->gen, NULL,
2779 &alc268_beep_mixer[i])) {
2784 snd_hda_add_verbs(codec, alc268_beep_init_verbs);
2785 if (!query_amp_caps(codec, 0x1d, HDA_INPUT))
2786 /* override the amp caps for beep generator */
2787 snd_hda_override_amp_caps(codec, 0x1d, HDA_INPUT,
2788 (0x0c << AC_AMPCAP_OFFSET_SHIFT) |
2789 (0x0c << AC_AMPCAP_NUM_STEPS_SHIFT) |
2790 (0x07 << AC_AMPCAP_STEP_SIZE_SHIFT) |
2791 (0 << AC_AMPCAP_MUTE_SHIFT));
2794 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
2807 static const struct hda_pcm_stream alc269_44k_pcm_analog_playback = {
2808 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
2811 static const struct hda_pcm_stream alc269_44k_pcm_analog_capture = {
2812 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
2815 /* different alc269-variants */
2817 ALC269_TYPE_ALC269VA,
2818 ALC269_TYPE_ALC269VB,
2819 ALC269_TYPE_ALC269VC,
2820 ALC269_TYPE_ALC269VD,
2839 * BIOS auto configuration
2841 static int alc269_parse_auto_config(struct hda_codec *codec)
2843 static const hda_nid_t alc269_ignore[] = { 0x1d, 0 };
2844 static const hda_nid_t alc269_ssids[] = { 0, 0x1b, 0x14, 0x21 };
2845 static const hda_nid_t alc269va_ssids[] = { 0x15, 0x1b, 0x14, 0 };
2846 struct alc_spec *spec = codec->spec;
2847 const hda_nid_t *ssids;
2849 switch (spec->codec_variant) {
2850 case ALC269_TYPE_ALC269VA:
2851 case ALC269_TYPE_ALC269VC:
2852 case ALC269_TYPE_ALC280:
2853 case ALC269_TYPE_ALC284:
2854 case ALC269_TYPE_ALC293:
2855 ssids = alc269va_ssids;
2857 case ALC269_TYPE_ALC269VB:
2858 case ALC269_TYPE_ALC269VD:
2859 case ALC269_TYPE_ALC282:
2860 case ALC269_TYPE_ALC283:
2861 case ALC269_TYPE_ALC286:
2862 case ALC269_TYPE_ALC298:
2863 case ALC269_TYPE_ALC255:
2864 case ALC269_TYPE_ALC256:
2865 case ALC269_TYPE_ALC257:
2866 case ALC269_TYPE_ALC215:
2867 case ALC269_TYPE_ALC225:
2868 case ALC269_TYPE_ALC294:
2869 case ALC269_TYPE_ALC300:
2870 case ALC269_TYPE_ALC700:
2871 ssids = alc269_ssids;
2874 ssids = alc269_ssids;
2878 return alc_parse_auto_config(codec, alc269_ignore, ssids);
2881 static int find_ext_mic_pin(struct hda_codec *codec);
2883 static void alc286_shutup(struct hda_codec *codec)
2885 const struct hda_pincfg *pin;
2887 int mic_pin = find_ext_mic_pin(codec);
2888 /* don't shut up pins when unloading the driver; otherwise it breaks
2889 * the default pin setup at the next load of the driver
2891 if (codec->bus->shutdown)
2893 snd_array_for_each(&codec->init_pins, i, pin) {
2894 /* use read here for syncing after issuing each verb */
2895 if (pin->nid != mic_pin)
2896 snd_hda_codec_read(codec, pin->nid, 0,
2897 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
2899 codec->pins_shutup = 1;
2902 static void alc269vb_toggle_power_output(struct hda_codec *codec, int power_up)
2904 alc_update_coef_idx(codec, 0x04, 1 << 11, power_up ? (1 << 11) : 0);
2907 static void alc269_shutup(struct hda_codec *codec)
2909 struct alc_spec *spec = codec->spec;
2911 if (spec->codec_variant == ALC269_TYPE_ALC269VB)
2912 alc269vb_toggle_power_output(codec, 0);
2913 if (spec->codec_variant == ALC269_TYPE_ALC269VB &&
2914 (alc_get_coef0(codec) & 0x00ff) == 0x018) {
2917 snd_hda_shutup_pins(codec);
2920 static struct coef_fw alc282_coefs[] = {
2921 WRITE_COEF(0x03, 0x0002), /* Power Down Control */
2922 UPDATE_COEF(0x05, 0xff3f, 0x0700), /* FIFO and filter clock */
2923 WRITE_COEF(0x07, 0x0200), /* DMIC control */
2924 UPDATE_COEF(0x06, 0x00f0, 0), /* Analog clock */
2925 UPDATE_COEF(0x08, 0xfffc, 0x0c2c), /* JD */
2926 WRITE_COEF(0x0a, 0xcccc), /* JD offset1 */
2927 WRITE_COEF(0x0b, 0xcccc), /* JD offset2 */
2928 WRITE_COEF(0x0e, 0x6e00), /* LDO1/2/3, DAC/ADC */
2929 UPDATE_COEF(0x0f, 0xf800, 0x1000), /* JD */
2930 UPDATE_COEF(0x10, 0xfc00, 0x0c00), /* Capless */
2931 WRITE_COEF(0x6f, 0x0), /* Class D test 4 */
2932 UPDATE_COEF(0x0c, 0xfe00, 0), /* IO power down directly */
2933 WRITE_COEF(0x34, 0xa0c0), /* ANC */
2934 UPDATE_COEF(0x16, 0x0008, 0), /* AGC MUX */
2935 UPDATE_COEF(0x1d, 0x00e0, 0), /* DAC simple content protection */
2936 UPDATE_COEF(0x1f, 0x00e0, 0), /* ADC simple content protection */
2937 WRITE_COEF(0x21, 0x8804), /* DAC ADC Zero Detection */
2938 WRITE_COEF(0x63, 0x2902), /* PLL */
2939 WRITE_COEF(0x68, 0xa080), /* capless control 2 */
2940 WRITE_COEF(0x69, 0x3400), /* capless control 3 */
2941 WRITE_COEF(0x6a, 0x2f3e), /* capless control 4 */
2942 WRITE_COEF(0x6b, 0x0), /* capless control 5 */
2943 UPDATE_COEF(0x6d, 0x0fff, 0x0900), /* class D test 2 */
2944 WRITE_COEF(0x6e, 0x110a), /* class D test 3 */
2945 UPDATE_COEF(0x70, 0x00f8, 0x00d8), /* class D test 5 */
2946 WRITE_COEF(0x71, 0x0014), /* class D test 6 */
2947 WRITE_COEF(0x72, 0xc2ba), /* classD OCP */
2948 UPDATE_COEF(0x77, 0x0f80, 0), /* classD pure DC test */
2949 WRITE_COEF(0x6c, 0xfc06), /* Class D amp control */
2953 static void alc282_restore_default_value(struct hda_codec *codec)
2955 alc_process_coef_fw(codec, alc282_coefs);
2958 static void alc282_init(struct hda_codec *codec)
2960 struct alc_spec *spec = codec->spec;
2961 hda_nid_t hp_pin = spec->gen.autocfg.hp_pins[0];
2965 alc282_restore_default_value(codec);
2969 hp_pin_sense = snd_hda_jack_detect(codec, hp_pin);
2970 coef78 = alc_read_coef_idx(codec, 0x78);
2972 /* Index 0x78 Direct Drive HP AMP LPM Control 1 */
2973 /* Headphone capless set to high power mode */
2974 alc_write_coef_idx(codec, 0x78, 0x9004);
2979 snd_hda_codec_write(codec, hp_pin, 0,
2980 AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
2985 snd_hda_codec_write(codec, hp_pin, 0,
2986 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
2991 /* Headphone capless set to normal mode */
2992 alc_write_coef_idx(codec, 0x78, coef78);
2995 static void alc282_shutup(struct hda_codec *codec)
2997 struct alc_spec *spec = codec->spec;
2998 hda_nid_t hp_pin = spec->gen.autocfg.hp_pins[0];
3003 alc269_shutup(codec);
3007 hp_pin_sense = snd_hda_jack_detect(codec, hp_pin);
3008 coef78 = alc_read_coef_idx(codec, 0x78);
3009 alc_write_coef_idx(codec, 0x78, 0x9004);
3014 snd_hda_codec_write(codec, hp_pin, 0,
3015 AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
3020 snd_hda_codec_write(codec, hp_pin, 0,
3021 AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0);
3026 alc_auto_setup_eapd(codec, false);
3027 snd_hda_shutup_pins(codec);
3028 alc_write_coef_idx(codec, 0x78, coef78);
3031 static struct coef_fw alc283_coefs[] = {
3032 WRITE_COEF(0x03, 0x0002), /* Power Down Control */
3033 UPDATE_COEF(0x05, 0xff3f, 0x0700), /* FIFO and filter clock */
3034 WRITE_COEF(0x07, 0x0200), /* DMIC control */
3035 UPDATE_COEF(0x06, 0x00f0, 0), /* Analog clock */
3036 UPDATE_COEF(0x08, 0xfffc, 0x0c2c), /* JD */
3037 WRITE_COEF(0x0a, 0xcccc), /* JD offset1 */
3038 WRITE_COEF(0x0b, 0xcccc), /* JD offset2 */
3039 WRITE_COEF(0x0e, 0x6fc0), /* LDO1/2/3, DAC/ADC */
3040 UPDATE_COEF(0x0f, 0xf800, 0x1000), /* JD */
3041 UPDATE_COEF(0x10, 0xfc00, 0x0c00), /* Capless */
3042 WRITE_COEF(0x3a, 0x0), /* Class D test 4 */
3043 UPDATE_COEF(0x0c, 0xfe00, 0x0), /* IO power down directly */
3044 WRITE_COEF(0x22, 0xa0c0), /* ANC */
3045 UPDATE_COEFEX(0x53, 0x01, 0x000f, 0x0008), /* AGC MUX */
3046 UPDATE_COEF(0x1d, 0x00e0, 0), /* DAC simple content protection */
3047 UPDATE_COEF(0x1f, 0x00e0, 0), /* ADC simple content protection */
3048 WRITE_COEF(0x21, 0x8804), /* DAC ADC Zero Detection */
3049 WRITE_COEF(0x2e, 0x2902), /* PLL */
3050 WRITE_COEF(0x33, 0xa080), /* capless control 2 */
3051 WRITE_COEF(0x34, 0x3400), /* capless control 3 */
3052 WRITE_COEF(0x35, 0x2f3e), /* capless control 4 */
3053 WRITE_COEF(0x36, 0x0), /* capless control 5 */
3054 UPDATE_COEF(0x38, 0x0fff, 0x0900), /* class D test 2 */
3055 WRITE_COEF(0x39, 0x110a), /* class D test 3 */
3056 UPDATE_COEF(0x3b, 0x00f8, 0x00d8), /* class D test 5 */
3057 WRITE_COEF(0x3c, 0x0014), /* class D test 6 */
3058 WRITE_COEF(0x3d, 0xc2ba), /* classD OCP */
3059 UPDATE_COEF(0x42, 0x0f80, 0x0), /* classD pure DC test */
3060 WRITE_COEF(0x49, 0x0), /* test mode */
3061 UPDATE_COEF(0x40, 0xf800, 0x9800), /* Class D DC enable */
3062 UPDATE_COEF(0x42, 0xf000, 0x2000), /* DC offset */
3063 WRITE_COEF(0x37, 0xfc06), /* Class D amp control */
3064 UPDATE_COEF(0x1b, 0x8000, 0), /* HP JD control */
3068 static void alc283_restore_default_value(struct hda_codec *codec)
3070 alc_process_coef_fw(codec, alc283_coefs);
3073 static void alc283_init(struct hda_codec *codec)
3075 struct alc_spec *spec = codec->spec;
3076 hda_nid_t hp_pin = spec->gen.autocfg.hp_pins[0];
3079 if (!spec->gen.autocfg.hp_outs) {
3080 if (spec->gen.autocfg.line_out_type == AC_JACK_HP_OUT)
3081 hp_pin = spec->gen.autocfg.line_out_pins[0];
3084 alc283_restore_default_value(codec);
3090 hp_pin_sense = snd_hda_jack_detect(codec, hp_pin);
3092 /* Index 0x43 Direct Drive HP AMP LPM Control 1 */
3093 /* Headphone capless set to high power mode */
3094 alc_write_coef_idx(codec, 0x43, 0x9004);
3096 snd_hda_codec_write(codec, hp_pin, 0,
3097 AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
3102 snd_hda_codec_write(codec, hp_pin, 0,
3103 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
3107 /* Index 0x46 Combo jack auto switch control 2 */
3108 /* 3k pull low control for Headset jack. */
3109 alc_update_coef_idx(codec, 0x46, 3 << 12, 0);
3110 /* Headphone capless set to normal mode */
3111 alc_write_coef_idx(codec, 0x43, 0x9614);
3114 static void alc283_shutup(struct hda_codec *codec)
3116 struct alc_spec *spec = codec->spec;
3117 hda_nid_t hp_pin = spec->gen.autocfg.hp_pins[0];
3120 if (!spec->gen.autocfg.hp_outs) {
3121 if (spec->gen.autocfg.line_out_type == AC_JACK_HP_OUT)
3122 hp_pin = spec->gen.autocfg.line_out_pins[0];
3126 alc269_shutup(codec);
3130 hp_pin_sense = snd_hda_jack_detect(codec, hp_pin);
3132 alc_write_coef_idx(codec, 0x43, 0x9004);
3134 /*depop hp during suspend*/
3135 alc_write_coef_idx(codec, 0x06, 0x2100);
3137 snd_hda_codec_write(codec, hp_pin, 0,
3138 AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
3143 snd_hda_codec_write(codec, hp_pin, 0,
3144 AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0);
3146 alc_update_coef_idx(codec, 0x46, 0, 3 << 12);
3150 alc_auto_setup_eapd(codec, false);
3151 snd_hda_shutup_pins(codec);
3152 alc_write_coef_idx(codec, 0x43, 0x9614);
3155 static void alc256_init(struct hda_codec *codec)
3157 struct alc_spec *spec = codec->spec;
3158 hda_nid_t hp_pin = spec->gen.autocfg.hp_pins[0];
3166 hp_pin_sense = snd_hda_jack_detect(codec, hp_pin);
3171 alc_update_coefex_idx(codec, 0x57, 0x04, 0x0007, 0x1); /* Low power */
3173 snd_hda_codec_write(codec, hp_pin, 0,
3174 AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
3179 snd_hda_codec_write(codec, hp_pin, 0,
3180 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
3185 alc_update_coef_idx(codec, 0x46, 3 << 12, 0);
3186 alc_update_coefex_idx(codec, 0x57, 0x04, 0x0007, 0x4); /* Hight power */
3187 alc_update_coefex_idx(codec, 0x53, 0x02, 0x8000, 1 << 15); /* Clear bit */
3188 alc_update_coefex_idx(codec, 0x53, 0x02, 0x8000, 0 << 15);
3191 static void alc256_shutup(struct hda_codec *codec)
3193 struct alc_spec *spec = codec->spec;
3194 hda_nid_t hp_pin = spec->gen.autocfg.hp_pins[0];
3198 alc269_shutup(codec);
3202 hp_pin_sense = snd_hda_jack_detect(codec, hp_pin);
3207 snd_hda_codec_write(codec, hp_pin, 0,
3208 AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
3213 /* 3k pull low control for Headset jack. */
3214 /* NOTE: call this before clearing the pin, otherwise codec stalls */
3215 alc_update_coef_idx(codec, 0x46, 0, 3 << 12);
3217 snd_hda_codec_write(codec, hp_pin, 0,
3218 AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0);
3223 alc_auto_setup_eapd(codec, false);
3224 snd_hda_shutup_pins(codec);
3227 static void alc225_init(struct hda_codec *codec)
3229 struct alc_spec *spec = codec->spec;
3230 hda_nid_t hp_pin = spec->gen.autocfg.hp_pins[0];
3231 bool hp1_pin_sense, hp2_pin_sense;
3238 hp1_pin_sense = snd_hda_jack_detect(codec, hp_pin);
3239 hp2_pin_sense = snd_hda_jack_detect(codec, 0x16);
3241 if (hp1_pin_sense || hp2_pin_sense)
3244 alc_update_coefex_idx(codec, 0x57, 0x04, 0x0007, 0x1); /* Low power */
3247 snd_hda_codec_write(codec, hp_pin, 0,
3248 AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
3250 snd_hda_codec_write(codec, 0x16, 0,
3251 AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
3253 if (hp1_pin_sense || hp2_pin_sense)
3257 snd_hda_codec_write(codec, hp_pin, 0,
3258 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
3260 snd_hda_codec_write(codec, 0x16, 0,
3261 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
3263 if (hp1_pin_sense || hp2_pin_sense)
3266 alc_update_coef_idx(codec, 0x4a, 3 << 10, 0);
3267 alc_update_coefex_idx(codec, 0x57, 0x04, 0x0007, 0x4); /* Hight power */
3270 static void alc225_shutup(struct hda_codec *codec)
3272 struct alc_spec *spec = codec->spec;
3273 hda_nid_t hp_pin = spec->gen.autocfg.hp_pins[0];
3274 bool hp1_pin_sense, hp2_pin_sense;
3277 alc269_shutup(codec);
3281 /* 3k pull low control for Headset jack. */
3282 alc_update_coef_idx(codec, 0x4a, 0, 3 << 10);
3284 hp1_pin_sense = snd_hda_jack_detect(codec, hp_pin);
3285 hp2_pin_sense = snd_hda_jack_detect(codec, 0x16);
3287 if (hp1_pin_sense || hp2_pin_sense)
3291 snd_hda_codec_write(codec, hp_pin, 0,
3292 AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
3294 snd_hda_codec_write(codec, 0x16, 0,
3295 AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
3297 if (hp1_pin_sense || hp2_pin_sense)
3301 snd_hda_codec_write(codec, hp_pin, 0,
3302 AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0);
3304 snd_hda_codec_write(codec, 0x16, 0,
3305 AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0);
3307 if (hp1_pin_sense || hp2_pin_sense)
3310 alc_auto_setup_eapd(codec, false);
3311 snd_hda_shutup_pins(codec);
3314 static void alc_default_init(struct hda_codec *codec)
3316 struct alc_spec *spec = codec->spec;
3317 hda_nid_t hp_pin = spec->gen.autocfg.hp_pins[0];
3325 hp_pin_sense = snd_hda_jack_detect(codec, hp_pin);
3330 snd_hda_codec_write(codec, hp_pin, 0,
3331 AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
3336 snd_hda_codec_write(codec, hp_pin, 0,
3337 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
3343 static void alc_default_shutup(struct hda_codec *codec)
3345 struct alc_spec *spec = codec->spec;
3346 hda_nid_t hp_pin = spec->gen.autocfg.hp_pins[0];
3350 alc269_shutup(codec);
3354 hp_pin_sense = snd_hda_jack_detect(codec, hp_pin);
3359 snd_hda_codec_write(codec, hp_pin, 0,
3360 AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
3365 snd_hda_codec_write(codec, hp_pin, 0,
3366 AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0);
3371 alc_auto_setup_eapd(codec, false);
3372 snd_hda_shutup_pins(codec);
3375 static void alc5505_coef_set(struct hda_codec *codec, unsigned int index_reg,
3378 snd_hda_codec_write(codec, 0x51, 0, AC_VERB_SET_COEF_INDEX, index_reg >> 1);
3379 snd_hda_codec_write(codec, 0x51, 0, AC_VERB_SET_PROC_COEF, val & 0xffff); /* LSB */
3380 snd_hda_codec_write(codec, 0x51, 0, AC_VERB_SET_PROC_COEF, val >> 16); /* MSB */
3383 static int alc5505_coef_get(struct hda_codec *codec, unsigned int index_reg)
3387 snd_hda_codec_write(codec, 0x51, 0, AC_VERB_SET_COEF_INDEX, index_reg >> 1);
3388 val = snd_hda_codec_read(codec, 0x51, 0, AC_VERB_GET_PROC_COEF, 0)
3390 val |= snd_hda_codec_read(codec, 0x51, 0, AC_VERB_GET_PROC_COEF, 0)
3395 static void alc5505_dsp_halt(struct hda_codec *codec)
3399 alc5505_coef_set(codec, 0x3000, 0x000c); /* DSP CPU stop */
3400 alc5505_coef_set(codec, 0x880c, 0x0008); /* DDR enter self refresh */
3401 alc5505_coef_set(codec, 0x61c0, 0x11110080); /* Clock control for PLL and CPU */
3402 alc5505_coef_set(codec, 0x6230, 0xfc0d4011); /* Disable Input OP */
3403 alc5505_coef_set(codec, 0x61b4, 0x040a2b03); /* Stop PLL2 */
3404 alc5505_coef_set(codec, 0x61b0, 0x00005b17); /* Stop PLL1 */
3405 alc5505_coef_set(codec, 0x61b8, 0x04133303); /* Stop PLL3 */
3406 val = alc5505_coef_get(codec, 0x6220);
3407 alc5505_coef_set(codec, 0x6220, (val | 0x3000)); /* switch Ringbuffer clock to DBUS clock */
3410 static void alc5505_dsp_back_from_halt(struct hda_codec *codec)
3412 alc5505_coef_set(codec, 0x61b8, 0x04133302);
3413 alc5505_coef_set(codec, 0x61b0, 0x00005b16);
3414 alc5505_coef_set(codec, 0x61b4, 0x040a2b02);
3415 alc5505_coef_set(codec, 0x6230, 0xf80d4011);
3416 alc5505_coef_set(codec, 0x6220, 0x2002010f);
3417 alc5505_coef_set(codec, 0x880c, 0x00000004);
3420 static void alc5505_dsp_init(struct hda_codec *codec)
3424 alc5505_dsp_halt(codec);
3425 alc5505_dsp_back_from_halt(codec);
3426 alc5505_coef_set(codec, 0x61b0, 0x5b14); /* PLL1 control */
3427 alc5505_coef_set(codec, 0x61b0, 0x5b16);
3428 alc5505_coef_set(codec, 0x61b4, 0x04132b00); /* PLL2 control */
3429 alc5505_coef_set(codec, 0x61b4, 0x04132b02);
3430 alc5505_coef_set(codec, 0x61b8, 0x041f3300); /* PLL3 control*/
3431 alc5505_coef_set(codec, 0x61b8, 0x041f3302);
3432 snd_hda_codec_write(codec, 0x51, 0, AC_VERB_SET_CODEC_RESET, 0); /* Function reset */
3433 alc5505_coef_set(codec, 0x61b8, 0x041b3302);
3434 alc5505_coef_set(codec, 0x61b8, 0x04173302);
3435 alc5505_coef_set(codec, 0x61b8, 0x04163302);
3436 alc5505_coef_set(codec, 0x8800, 0x348b328b); /* DRAM control */
3437 alc5505_coef_set(codec, 0x8808, 0x00020022); /* DRAM control */
3438 alc5505_coef_set(codec, 0x8818, 0x00000400); /* DRAM control */
3440 val = alc5505_coef_get(codec, 0x6200) >> 16; /* Read revision ID */
3442 alc5505_coef_set(codec, 0x6220, 0x2002010f); /* I/O PAD Configuration */
3444 alc5505_coef_set(codec, 0x6220, 0x6002018f);
3446 alc5505_coef_set(codec, 0x61ac, 0x055525f0); /**/
3447 alc5505_coef_set(codec, 0x61c0, 0x12230080); /* Clock control */
3448 alc5505_coef_set(codec, 0x61b4, 0x040e2b02); /* PLL2 control */
3449 alc5505_coef_set(codec, 0x61bc, 0x010234f8); /* OSC Control */
3450 alc5505_coef_set(codec, 0x880c, 0x00000004); /* DRAM Function control */
3451 alc5505_coef_set(codec, 0x880c, 0x00000003);
3452 alc5505_coef_set(codec, 0x880c, 0x00000010);
3454 #ifdef HALT_REALTEK_ALC5505
3455 alc5505_dsp_halt(codec);
3459 #ifdef HALT_REALTEK_ALC5505
3460 #define alc5505_dsp_suspend(codec) /* NOP */
3461 #define alc5505_dsp_resume(codec) /* NOP */
3463 #define alc5505_dsp_suspend(codec) alc5505_dsp_halt(codec)
3464 #define alc5505_dsp_resume(codec) alc5505_dsp_back_from_halt(codec)
3468 static int alc269_suspend(struct hda_codec *codec)
3470 struct alc_spec *spec = codec->spec;
3472 if (spec->has_alc5505_dsp)
3473 alc5505_dsp_suspend(codec);
3474 return alc_suspend(codec);
3477 static int alc269_resume(struct hda_codec *codec)
3479 struct alc_spec *spec = codec->spec;
3481 if (spec->codec_variant == ALC269_TYPE_ALC269VB)
3482 alc269vb_toggle_power_output(codec, 0);
3483 if (spec->codec_variant == ALC269_TYPE_ALC269VB &&
3484 (alc_get_coef0(codec) & 0x00ff) == 0x018) {
3488 codec->patch_ops.init(codec);
3490 if (spec->codec_variant == ALC269_TYPE_ALC269VB)
3491 alc269vb_toggle_power_output(codec, 1);
3492 if (spec->codec_variant == ALC269_TYPE_ALC269VB &&
3493 (alc_get_coef0(codec) & 0x00ff) == 0x017) {
3497 regcache_sync(codec->core.regmap);
3498 hda_call_check_power_status(codec, 0x01);
3500 /* on some machine, the BIOS will clear the codec gpio data when enter
3501 * suspend, and won't restore the data after resume, so we restore it
3504 if (spec->gpio_data)
3505 alc_write_gpio_data(codec);
3507 if (spec->has_alc5505_dsp)
3508 alc5505_dsp_resume(codec);
3512 #endif /* CONFIG_PM */
3514 static void alc269_fixup_pincfg_no_hp_to_lineout(struct hda_codec *codec,
3515 const struct hda_fixup *fix, int action)
3517 struct alc_spec *spec = codec->spec;
3519 if (action == HDA_FIXUP_ACT_PRE_PROBE)
3520 spec->parse_flags = HDA_PINCFG_NO_HP_FIXUP;
3523 static void alc269_fixup_pincfg_U7x7_headset_mic(struct hda_codec *codec,
3524 const struct hda_fixup *fix,
3527 unsigned int cfg_headphone = snd_hda_codec_get_pincfg(codec, 0x21);
3528 unsigned int cfg_headset_mic = snd_hda_codec_get_pincfg(codec, 0x19);
3530 if (cfg_headphone && cfg_headset_mic == 0x411111f0)
3531 snd_hda_codec_set_pincfg(codec, 0x19,
3532 (cfg_headphone & ~AC_DEFCFG_DEVICE) |
3533 (AC_JACK_MIC_IN << AC_DEFCFG_DEVICE_SHIFT));
3536 static void alc269_fixup_hweq(struct hda_codec *codec,
3537 const struct hda_fixup *fix, int action)
3539 if (action == HDA_FIXUP_ACT_INIT)
3540 alc_update_coef_idx(codec, 0x1e, 0, 0x80);
3543 static void alc269_fixup_headset_mic(struct hda_codec *codec,
3544 const struct hda_fixup *fix, int action)
3546 struct alc_spec *spec = codec->spec;
3548 if (action == HDA_FIXUP_ACT_PRE_PROBE)
3549 spec->parse_flags |= HDA_PINCFG_HEADSET_MIC;
3552 static void alc271_fixup_dmic(struct hda_codec *codec,
3553 const struct hda_fixup *fix, int action)
3555 static const struct hda_verb verbs[] = {
3556 {0x20, AC_VERB_SET_COEF_INDEX, 0x0d},
3557 {0x20, AC_VERB_SET_PROC_COEF, 0x4000},
3562 if (strcmp(codec->core.chip_name, "ALC271X") &&
3563 strcmp(codec->core.chip_name, "ALC269VB"))
3565 cfg = snd_hda_codec_get_pincfg(codec, 0x12);
3566 if (get_defcfg_connect(cfg) == AC_JACK_PORT_FIXED)
3567 snd_hda_sequence_write(codec, verbs);
3570 static void alc269_fixup_pcm_44k(struct hda_codec *codec,
3571 const struct hda_fixup *fix, int action)
3573 struct alc_spec *spec = codec->spec;
3575 if (action != HDA_FIXUP_ACT_PROBE)
3578 /* Due to a hardware problem on Lenovo Ideadpad, we need to
3579 * fix the sample rate of analog I/O to 44.1kHz
3581 spec->gen.stream_analog_playback = &alc269_44k_pcm_analog_playback;
3582 spec->gen.stream_analog_capture = &alc269_44k_pcm_analog_capture;
3585 static void alc269_fixup_stereo_dmic(struct hda_codec *codec,
3586 const struct hda_fixup *fix, int action)
3588 /* The digital-mic unit sends PDM (differential signal) instead of
3589 * the standard PCM, thus you can't record a valid mono stream as is.
3590 * Below is a workaround specific to ALC269 to control the dmic
3591 * signal source as mono.
3593 if (action == HDA_FIXUP_ACT_INIT)
3594 alc_update_coef_idx(codec, 0x07, 0, 0x80);
3597 static void alc269_quanta_automute(struct hda_codec *codec)
3599 snd_hda_gen_update_outputs(codec);
3601 alc_write_coef_idx(codec, 0x0c, 0x680);
3602 alc_write_coef_idx(codec, 0x0c, 0x480);
3605 static void alc269_fixup_quanta_mute(struct hda_codec *codec,
3606 const struct hda_fixup *fix, int action)
3608 struct alc_spec *spec = codec->spec;
3609 if (action != HDA_FIXUP_ACT_PROBE)
3611 spec->gen.automute_hook = alc269_quanta_automute;
3614 static void alc269_x101_hp_automute_hook(struct hda_codec *codec,
3615 struct hda_jack_callback *jack)
3617 struct alc_spec *spec = codec->spec;
3620 snd_hda_gen_hp_automute(codec, jack);
3622 vref = spec->gen.hp_jack_present ? PIN_VREF80 : 0;
3624 snd_hda_codec_write(codec, 0x18, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
3627 snd_hda_codec_write(codec, 0x18, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
3631 static void alc269_fixup_x101_headset_mic(struct hda_codec *codec,
3632 const struct hda_fixup *fix, int action)
3634 struct alc_spec *spec = codec->spec;
3635 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
3636 spec->parse_flags |= HDA_PINCFG_HEADSET_MIC;
3637 spec->gen.hp_automute_hook = alc269_x101_hp_automute_hook;
3642 /* update mute-LED according to the speaker mute state via mic VREF pin */
3643 static void alc269_fixup_mic_mute_hook(void *private_data, int enabled)
3645 struct hda_codec *codec = private_data;
3646 struct alc_spec *spec = codec->spec;
3647 unsigned int pinval;
3649 if (spec->mute_led_polarity)
3651 pinval = snd_hda_codec_get_pin_target(codec, spec->mute_led_nid);
3652 pinval &= ~AC_PINCTL_VREFEN;
3653 pinval |= enabled ? AC_PINCTL_VREF_HIZ : AC_PINCTL_VREF_80;
3654 if (spec->mute_led_nid) {
3655 /* temporarily power up/down for setting VREF */
3656 snd_hda_power_up_pm(codec);
3657 snd_hda_set_pin_ctl_cache(codec, spec->mute_led_nid, pinval);
3658 snd_hda_power_down_pm(codec);
3662 /* Make sure the led works even in runtime suspend */
3663 static unsigned int led_power_filter(struct hda_codec *codec,
3665 unsigned int power_state)
3667 struct alc_spec *spec = codec->spec;
3669 if (power_state != AC_PWRST_D3 || nid == 0 ||
3670 (nid != spec->mute_led_nid && nid != spec->cap_mute_led_nid))
3673 /* Set pin ctl again, it might have just been set to 0 */
3674 snd_hda_set_pin_ctl(codec, nid,
3675 snd_hda_codec_get_pin_target(codec, nid));
3677 return snd_hda_gen_path_power_filter(codec, nid, power_state);
3680 static void alc269_fixup_hp_mute_led(struct hda_codec *codec,
3681 const struct hda_fixup *fix, int action)
3683 struct alc_spec *spec = codec->spec;
3684 const struct dmi_device *dev = NULL;
3686 if (action != HDA_FIXUP_ACT_PRE_PROBE)
3689 while ((dev = dmi_find_device(DMI_DEV_TYPE_OEM_STRING, NULL, dev))) {
3691 if (sscanf(dev->name, "HP_Mute_LED_%d_%x", &pol, &pin) != 2)
3693 if (pin < 0x0a || pin >= 0x10)
3695 spec->mute_led_polarity = pol;
3696 spec->mute_led_nid = pin - 0x0a + 0x18;
3697 spec->gen.vmaster_mute.hook = alc269_fixup_mic_mute_hook;
3698 spec->gen.vmaster_mute_enum = 1;
3699 codec->power_filter = led_power_filter;
3701 "Detected mute LED for %x:%d\n", spec->mute_led_nid,
3702 spec->mute_led_polarity);
3707 static void alc269_fixup_hp_mute_led_micx(struct hda_codec *codec,
3708 const struct hda_fixup *fix,
3709 int action, hda_nid_t pin)
3711 struct alc_spec *spec = codec->spec;
3713 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
3714 spec->mute_led_polarity = 0;
3715 spec->mute_led_nid = pin;
3716 spec->gen.vmaster_mute.hook = alc269_fixup_mic_mute_hook;
3717 spec->gen.vmaster_mute_enum = 1;
3718 codec->power_filter = led_power_filter;
3722 static void alc269_fixup_hp_mute_led_mic1(struct hda_codec *codec,
3723 const struct hda_fixup *fix, int action)
3725 alc269_fixup_hp_mute_led_micx(codec, fix, action, 0x18);
3728 static void alc269_fixup_hp_mute_led_mic2(struct hda_codec *codec,
3729 const struct hda_fixup *fix, int action)
3731 alc269_fixup_hp_mute_led_micx(codec, fix, action, 0x19);
3734 static void alc269_fixup_hp_mute_led_mic3(struct hda_codec *codec,
3735 const struct hda_fixup *fix, int action)
3737 alc269_fixup_hp_mute_led_micx(codec, fix, action, 0x1b);
3740 /* update LED status via GPIO */
3741 static void alc_update_gpio_led(struct hda_codec *codec, unsigned int mask,
3744 struct alc_spec *spec = codec->spec;
3746 if (spec->mute_led_polarity)
3748 alc_update_gpio_data(codec, mask, !enabled); /* muted -> LED on */
3751 /* turn on/off mute LED via GPIO per vmaster hook */
3752 static void alc_fixup_gpio_mute_hook(void *private_data, int enabled)
3754 struct hda_codec *codec = private_data;
3755 struct alc_spec *spec = codec->spec;
3757 alc_update_gpio_led(codec, spec->gpio_mute_led_mask, enabled);
3760 /* turn on/off mic-mute LED via GPIO per capture hook */
3761 static void alc_gpio_micmute_update(struct hda_codec *codec)
3763 struct alc_spec *spec = codec->spec;
3765 alc_update_gpio_led(codec, spec->gpio_mic_led_mask,
3766 spec->gen.micmute_led.led_value);
3769 /* setup mute and mic-mute GPIO bits, add hooks appropriately */
3770 static void alc_fixup_hp_gpio_led(struct hda_codec *codec,
3772 unsigned int mute_mask,
3773 unsigned int micmute_mask)
3775 struct alc_spec *spec = codec->spec;
3777 alc_fixup_gpio(codec, action, mute_mask | micmute_mask);
3779 if (action != HDA_FIXUP_ACT_PRE_PROBE)
3782 spec->gpio_mute_led_mask = mute_mask;
3783 spec->gen.vmaster_mute.hook = alc_fixup_gpio_mute_hook;
3786 spec->gpio_mic_led_mask = micmute_mask;
3787 snd_hda_gen_add_micmute_led(codec, alc_gpio_micmute_update);
3791 static void alc269_fixup_hp_gpio_led(struct hda_codec *codec,
3792 const struct hda_fixup *fix, int action)
3794 alc_fixup_hp_gpio_led(codec, action, 0x08, 0x10);
3797 static void alc286_fixup_hp_gpio_led(struct hda_codec *codec,
3798 const struct hda_fixup *fix, int action)
3800 alc_fixup_hp_gpio_led(codec, action, 0x02, 0x20);
3803 /* turn on/off mic-mute LED per capture hook */
3804 static void alc_cap_micmute_update(struct hda_codec *codec)
3806 struct alc_spec *spec = codec->spec;
3807 unsigned int pinval;
3809 if (!spec->cap_mute_led_nid)
3811 pinval = snd_hda_codec_get_pin_target(codec, spec->cap_mute_led_nid);
3812 pinval &= ~AC_PINCTL_VREFEN;
3813 if (spec->gen.micmute_led.led_value)
3814 pinval |= AC_PINCTL_VREF_80;
3816 pinval |= AC_PINCTL_VREF_HIZ;
3817 snd_hda_set_pin_ctl_cache(codec, spec->cap_mute_led_nid, pinval);
3820 static void alc269_fixup_hp_gpio_mic1_led(struct hda_codec *codec,
3821 const struct hda_fixup *fix, int action)
3823 struct alc_spec *spec = codec->spec;
3825 alc_fixup_hp_gpio_led(codec, action, 0x08, 0);
3826 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
3827 /* Like hp_gpio_mic1_led, but also needs GPIO4 low to
3828 * enable headphone amp
3830 spec->gpio_mask |= 0x10;
3831 spec->gpio_dir |= 0x10;
3832 spec->cap_mute_led_nid = 0x18;
3833 snd_hda_gen_add_micmute_led(codec, alc_cap_micmute_update);
3834 codec->power_filter = led_power_filter;
3838 static void alc280_fixup_hp_gpio4(struct hda_codec *codec,
3839 const struct hda_fixup *fix, int action)
3841 struct alc_spec *spec = codec->spec;
3843 alc_fixup_hp_gpio_led(codec, action, 0x08, 0);
3844 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
3845 spec->cap_mute_led_nid = 0x18;
3846 snd_hda_gen_add_micmute_led(codec, alc_cap_micmute_update);
3847 codec->power_filter = led_power_filter;
3851 #if IS_REACHABLE(CONFIG_INPUT)
3852 static void gpio2_mic_hotkey_event(struct hda_codec *codec,
3853 struct hda_jack_callback *event)
3855 struct alc_spec *spec = codec->spec;
3857 /* GPIO2 just toggles on a keypress/keyrelease cycle. Therefore
3858 send both key on and key off event for every interrupt. */
3859 input_report_key(spec->kb_dev, spec->alc_mute_keycode_map[ALC_KEY_MICMUTE_INDEX], 1);
3860 input_sync(spec->kb_dev);
3861 input_report_key(spec->kb_dev, spec->alc_mute_keycode_map[ALC_KEY_MICMUTE_INDEX], 0);
3862 input_sync(spec->kb_dev);
3865 static int alc_register_micmute_input_device(struct hda_codec *codec)
3867 struct alc_spec *spec = codec->spec;
3870 spec->kb_dev = input_allocate_device();
3871 if (!spec->kb_dev) {
3872 codec_err(codec, "Out of memory (input_allocate_device)\n");