1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * Universal Interface for Intel High Definition Audio Codec
5 * HD audio interface patch for Realtek ALC codecs
7 * Copyright (c) 2004 Kailang Yang <kailang@realtek.com.tw>
8 * PeiSen Hou <pshou@realtek.com.tw>
9 * Takashi Iwai <tiwai@suse.de>
10 * Jonathan Woithe <jwoithe@just42.net>
13 #include <linux/init.h>
14 #include <linux/delay.h>
15 #include <linux/slab.h>
16 #include <linux/pci.h>
17 #include <linux/dmi.h>
18 #include <linux/module.h>
19 #include <linux/input.h>
20 #include <sound/core.h>
21 #include <sound/jack.h>
22 #include <sound/hda_codec.h>
23 #include "hda_local.h"
24 #include "hda_auto_parser.h"
26 #include "hda_generic.h"
28 /* keep halting ALC5505 DSP, for power saving */
29 #define HALT_REALTEK_ALC5505
31 /* extra amp-initialization sequence types */
39 ALC_HEADSET_MODE_UNKNOWN,
40 ALC_HEADSET_MODE_UNPLUGGED,
41 ALC_HEADSET_MODE_HEADSET,
43 ALC_HEADSET_MODE_HEADPHONE,
47 ALC_HEADSET_TYPE_UNKNOWN,
48 ALC_HEADSET_TYPE_CTIA,
49 ALC_HEADSET_TYPE_OMTP,
53 ALC_KEY_MICMUTE_INDEX,
56 struct alc_customize_define {
58 unsigned char port_connectivity;
59 unsigned char check_sum;
60 unsigned char customization;
61 unsigned char external_amp;
62 unsigned int enable_pcbeep:1;
63 unsigned int platform_type:1;
65 unsigned int override:1;
66 unsigned int fixup:1; /* Means that this sku is set by driver, not read from hw */
70 struct hda_gen_spec gen; /* must be at head */
72 /* codec parameterization */
73 struct alc_customize_define cdefine;
74 unsigned int parse_flags; /* flag for snd_hda_parse_pin_defcfg() */
77 unsigned int gpio_mask;
78 unsigned int gpio_dir;
79 unsigned int gpio_data;
80 bool gpio_write_delay; /* add a delay before writing gpio_data */
82 /* mute LED for HP laptops, see alc269_fixup_mic_mute_hook() */
83 int mute_led_polarity;
84 hda_nid_t mute_led_nid;
85 hda_nid_t cap_mute_led_nid;
87 unsigned int gpio_mute_led_mask;
88 unsigned int gpio_mic_led_mask;
90 hda_nid_t headset_mic_pin;
91 hda_nid_t headphone_mic_pin;
92 int current_headset_mode;
93 int current_headset_type;
96 void (*init_hook)(struct hda_codec *codec);
98 void (*power_hook)(struct hda_codec *codec);
100 void (*shutup)(struct hda_codec *codec);
101 void (*reboot_notify)(struct hda_codec *codec);
104 int codec_variant; /* flag for other variants */
105 unsigned int has_alc5505_dsp:1;
106 unsigned int no_depop_delay:1;
107 unsigned int done_hp_init:1;
108 unsigned int no_shutup_pins:1;
109 unsigned int ultra_low_power:1;
113 unsigned int pll_coef_idx, pll_coef_bit;
115 struct input_dev *kb_dev;
116 u8 alc_mute_keycode_map[1];
120 * COEF access helper functions
123 static int alc_read_coefex_idx(struct hda_codec *codec, hda_nid_t nid,
124 unsigned int coef_idx)
128 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_COEF_INDEX, coef_idx);
129 val = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_PROC_COEF, 0);
133 #define alc_read_coef_idx(codec, coef_idx) \
134 alc_read_coefex_idx(codec, 0x20, coef_idx)
136 static void alc_write_coefex_idx(struct hda_codec *codec, hda_nid_t nid,
137 unsigned int coef_idx, unsigned int coef_val)
139 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_COEF_INDEX, coef_idx);
140 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PROC_COEF, coef_val);
143 #define alc_write_coef_idx(codec, coef_idx, coef_val) \
144 alc_write_coefex_idx(codec, 0x20, coef_idx, coef_val)
146 static void alc_update_coefex_idx(struct hda_codec *codec, hda_nid_t nid,
147 unsigned int coef_idx, unsigned int mask,
148 unsigned int bits_set)
150 unsigned int val = alc_read_coefex_idx(codec, nid, coef_idx);
153 alc_write_coefex_idx(codec, nid, coef_idx,
154 (val & ~mask) | bits_set);
157 #define alc_update_coef_idx(codec, coef_idx, mask, bits_set) \
158 alc_update_coefex_idx(codec, 0x20, coef_idx, mask, bits_set)
160 /* a special bypass for COEF 0; read the cached value at the second time */
161 static unsigned int alc_get_coef0(struct hda_codec *codec)
163 struct alc_spec *spec = codec->spec;
166 spec->coef0 = alc_read_coef_idx(codec, 0);
170 /* coef writes/updates batch */
178 #define UPDATE_COEFEX(_nid, _idx, _mask, _val) \
179 { .nid = (_nid), .idx = (_idx), .mask = (_mask), .val = (_val) }
180 #define WRITE_COEFEX(_nid, _idx, _val) UPDATE_COEFEX(_nid, _idx, -1, _val)
181 #define WRITE_COEF(_idx, _val) WRITE_COEFEX(0x20, _idx, _val)
182 #define UPDATE_COEF(_idx, _mask, _val) UPDATE_COEFEX(0x20, _idx, _mask, _val)
184 static void alc_process_coef_fw(struct hda_codec *codec,
185 const struct coef_fw *fw)
187 for (; fw->nid; fw++) {
188 if (fw->mask == (unsigned short)-1)
189 alc_write_coefex_idx(codec, fw->nid, fw->idx, fw->val);
191 alc_update_coefex_idx(codec, fw->nid, fw->idx,
197 * GPIO setup tables, used in initialization
200 /* Enable GPIO mask and set output */
201 static void alc_setup_gpio(struct hda_codec *codec, unsigned int mask)
203 struct alc_spec *spec = codec->spec;
205 spec->gpio_mask |= mask;
206 spec->gpio_dir |= mask;
207 spec->gpio_data |= mask;
210 static void alc_write_gpio_data(struct hda_codec *codec)
212 struct alc_spec *spec = codec->spec;
214 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA,
218 static void alc_update_gpio_data(struct hda_codec *codec, unsigned int mask,
221 struct alc_spec *spec = codec->spec;
222 unsigned int oldval = spec->gpio_data;
225 spec->gpio_data |= mask;
227 spec->gpio_data &= ~mask;
228 if (oldval != spec->gpio_data)
229 alc_write_gpio_data(codec);
232 static void alc_write_gpio(struct hda_codec *codec)
234 struct alc_spec *spec = codec->spec;
236 if (!spec->gpio_mask)
239 snd_hda_codec_write(codec, codec->core.afg, 0,
240 AC_VERB_SET_GPIO_MASK, spec->gpio_mask);
241 snd_hda_codec_write(codec, codec->core.afg, 0,
242 AC_VERB_SET_GPIO_DIRECTION, spec->gpio_dir);
243 if (spec->gpio_write_delay)
245 alc_write_gpio_data(codec);
248 static void alc_fixup_gpio(struct hda_codec *codec, int action,
251 if (action == HDA_FIXUP_ACT_PRE_PROBE)
252 alc_setup_gpio(codec, mask);
255 static void alc_fixup_gpio1(struct hda_codec *codec,
256 const struct hda_fixup *fix, int action)
258 alc_fixup_gpio(codec, action, 0x01);
261 static void alc_fixup_gpio2(struct hda_codec *codec,
262 const struct hda_fixup *fix, int action)
264 alc_fixup_gpio(codec, action, 0x02);
267 static void alc_fixup_gpio3(struct hda_codec *codec,
268 const struct hda_fixup *fix, int action)
270 alc_fixup_gpio(codec, action, 0x03);
273 static void alc_fixup_gpio4(struct hda_codec *codec,
274 const struct hda_fixup *fix, int action)
276 alc_fixup_gpio(codec, action, 0x04);
280 * Fix hardware PLL issue
281 * On some codecs, the analog PLL gating control must be off while
282 * the default value is 1.
284 static void alc_fix_pll(struct hda_codec *codec)
286 struct alc_spec *spec = codec->spec;
289 alc_update_coefex_idx(codec, spec->pll_nid, spec->pll_coef_idx,
290 1 << spec->pll_coef_bit, 0);
293 static void alc_fix_pll_init(struct hda_codec *codec, hda_nid_t nid,
294 unsigned int coef_idx, unsigned int coef_bit)
296 struct alc_spec *spec = codec->spec;
298 spec->pll_coef_idx = coef_idx;
299 spec->pll_coef_bit = coef_bit;
303 /* update the master volume per volume-knob's unsol event */
304 static void alc_update_knob_master(struct hda_codec *codec,
305 struct hda_jack_callback *jack)
308 struct snd_kcontrol *kctl;
309 struct snd_ctl_elem_value *uctl;
311 kctl = snd_hda_find_mixer_ctl(codec, "Master Playback Volume");
314 uctl = kzalloc(sizeof(*uctl), GFP_KERNEL);
317 val = snd_hda_codec_read(codec, jack->nid, 0,
318 AC_VERB_GET_VOLUME_KNOB_CONTROL, 0);
319 val &= HDA_AMP_VOLMASK;
320 uctl->value.integer.value[0] = val;
321 uctl->value.integer.value[1] = val;
322 kctl->put(kctl, uctl);
326 static void alc880_unsol_event(struct hda_codec *codec, unsigned int res)
328 /* For some reason, the res given from ALC880 is broken.
329 Here we adjust it properly. */
330 snd_hda_jack_unsol_event(codec, res >> 2);
333 /* Change EAPD to verb control */
334 static void alc_fill_eapd_coef(struct hda_codec *codec)
338 coef = alc_get_coef0(codec);
340 switch (codec->core.vendor_id) {
342 alc_update_coef_idx(codec, 0x7, 0, 1<<5);
346 alc_update_coef_idx(codec, 0x7, 0, 1<<13);
349 if ((coef & 0x00f0) == 0x0010)
350 alc_update_coef_idx(codec, 0xd, 0, 1<<14);
351 if ((coef & 0x00f0) == 0x0020)
352 alc_update_coef_idx(codec, 0x4, 1<<15, 0);
353 if ((coef & 0x00f0) == 0x0030)
354 alc_update_coef_idx(codec, 0x10, 1<<9, 0);
360 alc_update_coef_idx(codec, 0x4, 1<<15, 0);
365 alc_update_coef_idx(codec, 0x67, 0xf000, 0x3000);
380 alc_update_coef_idx(codec, 0x10, 1<<9, 0);
384 alc_write_coef_idx(codec, 0x36, 0x5757);
385 alc_update_coef_idx(codec, 0x10, 1<<9, 0);
388 alc_update_coef_idx(codec, 0xe, 0, 1<<0);
391 alc_update_coef_idx(codec, 0xa, 1<<13, 0);
400 alc_update_coef_idx(codec, 0x10, 1<<15, 0);
403 if ((coef & 0x00f0) == 0x0030)
404 alc_update_coef_idx(codec, 0x4, 1<<10, 0); /* EAPD Ctrl */
413 alc_update_coef_idx(codec, 0xd, 0, 1<<14); /* EAPD Ctrl */
416 alc_update_coef_idx(codec, 0x19, 1<<13, 0);
419 alc_update_coef_idx(codec, 0x7, 3<<13, 0);
422 alc_update_coef_idx(codec, 0x4, 1<<10, 0);
425 if ((coef & 0x00f0) == 0x0020 || (coef & 0x00f0) == 0x0030)
426 alc_update_coef_idx(codec, 0x7, 1<<5, 0);
429 alc_update_coef_idx(codec, 0x7, 1<<5, 0);
436 alc_update_coef_idx(codec, 0x7, 1<<1, 0);
441 /* additional initialization for ALC888 variants */
442 static void alc888_coef_init(struct hda_codec *codec)
444 switch (alc_get_coef0(codec) & 0x00f0) {
449 alc_update_coef_idx(codec, 7, 0, 0x2030); /* Turn EAPD to High */
454 /* turn on/off EAPD control (only if available) */
455 static void set_eapd(struct hda_codec *codec, hda_nid_t nid, int on)
457 if (get_wcaps_type(get_wcaps(codec, nid)) != AC_WID_PIN)
459 if (snd_hda_query_pin_caps(codec, nid) & AC_PINCAP_EAPD)
460 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
464 /* turn on/off EAPD controls of the codec */
465 static void alc_auto_setup_eapd(struct hda_codec *codec, bool on)
467 /* We currently only handle front, HP */
468 static const hda_nid_t pins[] = {
469 0x0f, 0x10, 0x14, 0x15, 0x17, 0
472 for (p = pins; *p; p++)
473 set_eapd(codec, *p, on);
476 static int find_ext_mic_pin(struct hda_codec *codec);
478 static void alc_headset_mic_no_shutup(struct hda_codec *codec)
480 const struct hda_pincfg *pin;
481 int mic_pin = find_ext_mic_pin(codec);
484 /* don't shut up pins when unloading the driver; otherwise it breaks
485 * the default pin setup at the next load of the driver
487 if (codec->bus->shutdown)
490 snd_array_for_each(&codec->init_pins, i, pin) {
491 /* use read here for syncing after issuing each verb */
492 if (pin->nid != mic_pin)
493 snd_hda_codec_read(codec, pin->nid, 0,
494 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
497 codec->pins_shutup = 1;
500 static void alc_shutup_pins(struct hda_codec *codec)
502 struct alc_spec *spec = codec->spec;
504 switch (codec->core.vendor_id) {
509 alc_headset_mic_no_shutup(codec);
512 if (!spec->no_shutup_pins)
513 snd_hda_shutup_pins(codec);
518 /* generic shutup callback;
519 * just turning off EAPD and a little pause for avoiding pop-noise
521 static void alc_eapd_shutup(struct hda_codec *codec)
523 struct alc_spec *spec = codec->spec;
525 alc_auto_setup_eapd(codec, false);
526 if (!spec->no_depop_delay)
528 alc_shutup_pins(codec);
531 /* generic EAPD initialization */
532 static void alc_auto_init_amp(struct hda_codec *codec, int type)
534 alc_auto_setup_eapd(codec, true);
535 alc_write_gpio(codec);
537 case ALC_INIT_DEFAULT:
538 switch (codec->core.vendor_id) {
540 alc_update_coefex_idx(codec, 0x1a, 7, 0, 0x2010);
546 alc_update_coef_idx(codec, 7, 0, 0x2030);
549 alc888_coef_init(codec);
556 /* get a primary headphone pin if available */
557 static hda_nid_t alc_get_hp_pin(struct alc_spec *spec)
559 if (spec->gen.autocfg.hp_pins[0])
560 return spec->gen.autocfg.hp_pins[0];
561 if (spec->gen.autocfg.line_out_type == AC_JACK_HP_OUT)
562 return spec->gen.autocfg.line_out_pins[0];
567 * Realtek SSID verification
570 /* Could be any non-zero and even value. When used as fixup, tells
571 * the driver to ignore any present sku defines.
573 #define ALC_FIXUP_SKU_IGNORE (2)
575 static void alc_fixup_sku_ignore(struct hda_codec *codec,
576 const struct hda_fixup *fix, int action)
578 struct alc_spec *spec = codec->spec;
579 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
580 spec->cdefine.fixup = 1;
581 spec->cdefine.sku_cfg = ALC_FIXUP_SKU_IGNORE;
585 static void alc_fixup_no_depop_delay(struct hda_codec *codec,
586 const struct hda_fixup *fix, int action)
588 struct alc_spec *spec = codec->spec;
590 if (action == HDA_FIXUP_ACT_PROBE) {
591 spec->no_depop_delay = 1;
592 codec->depop_delay = 0;
596 static int alc_auto_parse_customize_define(struct hda_codec *codec)
598 unsigned int ass, tmp, i;
600 struct alc_spec *spec = codec->spec;
602 spec->cdefine.enable_pcbeep = 1; /* assume always enabled */
604 if (spec->cdefine.fixup) {
605 ass = spec->cdefine.sku_cfg;
606 if (ass == ALC_FIXUP_SKU_IGNORE)
611 if (!codec->bus->pci)
613 ass = codec->core.subsystem_id & 0xffff;
614 if (ass != codec->bus->pci->subsystem_device && (ass & 1))
618 if (codec->core.vendor_id == 0x10ec0260)
620 ass = snd_hda_codec_get_pincfg(codec, nid);
623 codec_info(codec, "%s: SKU not ready 0x%08x\n",
624 codec->core.chip_name, ass);
630 for (i = 1; i < 16; i++) {
634 if (((ass >> 16) & 0xf) != tmp)
637 spec->cdefine.port_connectivity = ass >> 30;
638 spec->cdefine.enable_pcbeep = (ass & 0x100000) >> 20;
639 spec->cdefine.check_sum = (ass >> 16) & 0xf;
640 spec->cdefine.customization = ass >> 8;
642 spec->cdefine.sku_cfg = ass;
643 spec->cdefine.external_amp = (ass & 0x38) >> 3;
644 spec->cdefine.platform_type = (ass & 0x4) >> 2;
645 spec->cdefine.swap = (ass & 0x2) >> 1;
646 spec->cdefine.override = ass & 0x1;
648 codec_dbg(codec, "SKU: Nid=0x%x sku_cfg=0x%08x\n",
649 nid, spec->cdefine.sku_cfg);
650 codec_dbg(codec, "SKU: port_connectivity=0x%x\n",
651 spec->cdefine.port_connectivity);
652 codec_dbg(codec, "SKU: enable_pcbeep=0x%x\n", spec->cdefine.enable_pcbeep);
653 codec_dbg(codec, "SKU: check_sum=0x%08x\n", spec->cdefine.check_sum);
654 codec_dbg(codec, "SKU: customization=0x%08x\n", spec->cdefine.customization);
655 codec_dbg(codec, "SKU: external_amp=0x%x\n", spec->cdefine.external_amp);
656 codec_dbg(codec, "SKU: platform_type=0x%x\n", spec->cdefine.platform_type);
657 codec_dbg(codec, "SKU: swap=0x%x\n", spec->cdefine.swap);
658 codec_dbg(codec, "SKU: override=0x%x\n", spec->cdefine.override);
663 /* return the position of NID in the list, or -1 if not found */
664 static int find_idx_in_nid_list(hda_nid_t nid, const hda_nid_t *list, int nums)
667 for (i = 0; i < nums; i++)
672 /* return true if the given NID is found in the list */
673 static bool found_in_nid_list(hda_nid_t nid, const hda_nid_t *list, int nums)
675 return find_idx_in_nid_list(nid, list, nums) >= 0;
678 /* check subsystem ID and set up device-specific initialization;
679 * return 1 if initialized, 0 if invalid SSID
681 /* 32-bit subsystem ID for BIOS loading in HD Audio codec.
682 * 31 ~ 16 : Manufacture ID
684 * 7 ~ 0 : Assembly ID
685 * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36
687 static int alc_subsystem_id(struct hda_codec *codec, const hda_nid_t *ports)
689 unsigned int ass, tmp, i;
691 struct alc_spec *spec = codec->spec;
693 if (spec->cdefine.fixup) {
694 ass = spec->cdefine.sku_cfg;
695 if (ass == ALC_FIXUP_SKU_IGNORE)
700 ass = codec->core.subsystem_id & 0xffff;
701 if (codec->bus->pci &&
702 ass != codec->bus->pci->subsystem_device && (ass & 1))
705 /* invalid SSID, check the special NID pin defcfg instead */
707 * 31~30 : port connectivity
710 * 19~16 : Check sum (15:1)
715 if (codec->core.vendor_id == 0x10ec0260)
717 ass = snd_hda_codec_get_pincfg(codec, nid);
719 "realtek: No valid SSID, checking pincfg 0x%08x for NID 0x%x\n",
723 if ((ass >> 30) != 1) /* no physical connection */
728 for (i = 1; i < 16; i++) {
732 if (((ass >> 16) & 0xf) != tmp)
735 codec_dbg(codec, "realtek: Enabling init ASM_ID=0x%04x CODEC_ID=%08x\n",
736 ass & 0xffff, codec->core.vendor_id);
740 * 2 : 0 --> Desktop, 1 --> Laptop
741 * 3~5 : External Amplifier control
744 tmp = (ass & 0x38) >> 3; /* external Amp control */
745 if (spec->init_amp == ALC_INIT_UNDEFINED) {
748 alc_setup_gpio(codec, 0x01);
751 alc_setup_gpio(codec, 0x02);
754 alc_setup_gpio(codec, 0x03);
758 spec->init_amp = ALC_INIT_DEFAULT;
763 /* is laptop or Desktop and enable the function "Mute internal speaker
764 * when the external headphone out jack is plugged"
769 * 10~8 : Jack location
770 * 12~11: Headphone out -> 00: PortA, 01: PortE, 02: PortD, 03: Resvered
772 * 15 : 1 --> enable the function "Mute internal speaker
773 * when the external headphone out jack is plugged"
775 if (!alc_get_hp_pin(spec)) {
777 tmp = (ass >> 11) & 0x3; /* HP to chassis */
779 if (found_in_nid_list(nid, spec->gen.autocfg.line_out_pins,
780 spec->gen.autocfg.line_outs))
782 spec->gen.autocfg.hp_pins[0] = nid;
787 /* Check the validity of ALC subsystem-id
788 * ports contains an array of 4 pin NIDs for port-A, E, D and I */
789 static void alc_ssid_check(struct hda_codec *codec, const hda_nid_t *ports)
791 if (!alc_subsystem_id(codec, ports)) {
792 struct alc_spec *spec = codec->spec;
794 "realtek: Enable default setup for auto mode as fallback\n");
795 spec->init_amp = ALC_INIT_DEFAULT;
802 static void alc_fixup_inv_dmic(struct hda_codec *codec,
803 const struct hda_fixup *fix, int action)
805 struct alc_spec *spec = codec->spec;
807 spec->gen.inv_dmic_split = 1;
811 static int alc_build_controls(struct hda_codec *codec)
815 err = snd_hda_gen_build_controls(codec);
819 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_BUILD);
828 static void alc_pre_init(struct hda_codec *codec)
830 alc_fill_eapd_coef(codec);
833 #define is_s3_resume(codec) \
834 ((codec)->core.dev.power.power_state.event == PM_EVENT_RESUME)
835 #define is_s4_resume(codec) \
836 ((codec)->core.dev.power.power_state.event == PM_EVENT_RESTORE)
838 static int alc_init(struct hda_codec *codec)
840 struct alc_spec *spec = codec->spec;
842 /* hibernation resume needs the full chip initialization */
843 if (is_s4_resume(codec))
847 spec->init_hook(codec);
849 spec->gen.skip_verbs = 1; /* applied in below */
850 snd_hda_gen_init(codec);
852 alc_auto_init_amp(codec, spec->init_amp);
853 snd_hda_apply_verbs(codec); /* apply verbs here after own init */
855 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_INIT);
860 static inline void alc_shutup(struct hda_codec *codec)
862 struct alc_spec *spec = codec->spec;
864 if (!snd_hda_get_bool_hint(codec, "shutup"))
865 return; /* disabled explicitly by hints */
867 if (spec && spec->shutup)
870 alc_shutup_pins(codec);
873 static void alc_reboot_notify(struct hda_codec *codec)
875 struct alc_spec *spec = codec->spec;
877 if (spec && spec->reboot_notify)
878 spec->reboot_notify(codec);
883 #define alc_free snd_hda_gen_free
886 static void alc_power_eapd(struct hda_codec *codec)
888 alc_auto_setup_eapd(codec, false);
891 static int alc_suspend(struct hda_codec *codec)
893 struct alc_spec *spec = codec->spec;
895 if (spec && spec->power_hook)
896 spec->power_hook(codec);
902 static int alc_resume(struct hda_codec *codec)
904 struct alc_spec *spec = codec->spec;
906 if (!spec->no_depop_delay)
907 msleep(150); /* to avoid pop noise */
908 codec->patch_ops.init(codec);
909 regcache_sync(codec->core.regmap);
910 hda_call_check_power_status(codec, 0x01);
917 static const struct hda_codec_ops alc_patch_ops = {
918 .build_controls = alc_build_controls,
919 .build_pcms = snd_hda_gen_build_pcms,
922 .unsol_event = snd_hda_jack_unsol_event,
924 .resume = alc_resume,
925 .suspend = alc_suspend,
926 .check_power_status = snd_hda_gen_check_power_status,
928 .reboot_notify = alc_reboot_notify,
932 #define alc_codec_rename(codec, name) snd_hda_codec_set_name(codec, name)
935 * Rename codecs appropriately from COEF value or subvendor id
937 struct alc_codec_rename_table {
938 unsigned int vendor_id;
939 unsigned short coef_mask;
940 unsigned short coef_bits;
944 struct alc_codec_rename_pci_table {
945 unsigned int codec_vendor_id;
946 unsigned short pci_subvendor;
947 unsigned short pci_subdevice;
951 static const struct alc_codec_rename_table rename_tbl[] = {
952 { 0x10ec0221, 0xf00f, 0x1003, "ALC231" },
953 { 0x10ec0269, 0xfff0, 0x3010, "ALC277" },
954 { 0x10ec0269, 0xf0f0, 0x2010, "ALC259" },
955 { 0x10ec0269, 0xf0f0, 0x3010, "ALC258" },
956 { 0x10ec0269, 0x00f0, 0x0010, "ALC269VB" },
957 { 0x10ec0269, 0xffff, 0xa023, "ALC259" },
958 { 0x10ec0269, 0xffff, 0x6023, "ALC281X" },
959 { 0x10ec0269, 0x00f0, 0x0020, "ALC269VC" },
960 { 0x10ec0269, 0x00f0, 0x0030, "ALC269VD" },
961 { 0x10ec0662, 0xffff, 0x4020, "ALC656" },
962 { 0x10ec0887, 0x00f0, 0x0030, "ALC887-VD" },
963 { 0x10ec0888, 0x00f0, 0x0030, "ALC888-VD" },
964 { 0x10ec0888, 0xf0f0, 0x3020, "ALC886" },
965 { 0x10ec0899, 0x2000, 0x2000, "ALC899" },
966 { 0x10ec0892, 0xffff, 0x8020, "ALC661" },
967 { 0x10ec0892, 0xffff, 0x8011, "ALC661" },
968 { 0x10ec0892, 0xffff, 0x4011, "ALC656" },
972 static const struct alc_codec_rename_pci_table rename_pci_tbl[] = {
973 { 0x10ec0280, 0x1028, 0, "ALC3220" },
974 { 0x10ec0282, 0x1028, 0, "ALC3221" },
975 { 0x10ec0283, 0x1028, 0, "ALC3223" },
976 { 0x10ec0288, 0x1028, 0, "ALC3263" },
977 { 0x10ec0292, 0x1028, 0, "ALC3226" },
978 { 0x10ec0293, 0x1028, 0, "ALC3235" },
979 { 0x10ec0255, 0x1028, 0, "ALC3234" },
980 { 0x10ec0668, 0x1028, 0, "ALC3661" },
981 { 0x10ec0275, 0x1028, 0, "ALC3260" },
982 { 0x10ec0899, 0x1028, 0, "ALC3861" },
983 { 0x10ec0298, 0x1028, 0, "ALC3266" },
984 { 0x10ec0236, 0x1028, 0, "ALC3204" },
985 { 0x10ec0256, 0x1028, 0, "ALC3246" },
986 { 0x10ec0225, 0x1028, 0, "ALC3253" },
987 { 0x10ec0295, 0x1028, 0, "ALC3254" },
988 { 0x10ec0299, 0x1028, 0, "ALC3271" },
989 { 0x10ec0670, 0x1025, 0, "ALC669X" },
990 { 0x10ec0676, 0x1025, 0, "ALC679X" },
991 { 0x10ec0282, 0x1043, 0, "ALC3229" },
992 { 0x10ec0233, 0x1043, 0, "ALC3236" },
993 { 0x10ec0280, 0x103c, 0, "ALC3228" },
994 { 0x10ec0282, 0x103c, 0, "ALC3227" },
995 { 0x10ec0286, 0x103c, 0, "ALC3242" },
996 { 0x10ec0290, 0x103c, 0, "ALC3241" },
997 { 0x10ec0668, 0x103c, 0, "ALC3662" },
998 { 0x10ec0283, 0x17aa, 0, "ALC3239" },
999 { 0x10ec0292, 0x17aa, 0, "ALC3232" },
1000 { } /* terminator */
1003 static int alc_codec_rename_from_preset(struct hda_codec *codec)
1005 const struct alc_codec_rename_table *p;
1006 const struct alc_codec_rename_pci_table *q;
1008 for (p = rename_tbl; p->vendor_id; p++) {
1009 if (p->vendor_id != codec->core.vendor_id)
1011 if ((alc_get_coef0(codec) & p->coef_mask) == p->coef_bits)
1012 return alc_codec_rename(codec, p->name);
1015 if (!codec->bus->pci)
1017 for (q = rename_pci_tbl; q->codec_vendor_id; q++) {
1018 if (q->codec_vendor_id != codec->core.vendor_id)
1020 if (q->pci_subvendor != codec->bus->pci->subsystem_vendor)
1022 if (!q->pci_subdevice ||
1023 q->pci_subdevice == codec->bus->pci->subsystem_device)
1024 return alc_codec_rename(codec, q->name);
1032 * Digital-beep handlers
1034 #ifdef CONFIG_SND_HDA_INPUT_BEEP
1036 /* additional beep mixers; private_value will be overwritten */
1037 static const struct snd_kcontrol_new alc_beep_mixer[] = {
1038 HDA_CODEC_VOLUME("Beep Playback Volume", 0, 0, HDA_INPUT),
1039 HDA_CODEC_MUTE_BEEP("Beep Playback Switch", 0, 0, HDA_INPUT),
1042 /* set up and create beep controls */
1043 static int set_beep_amp(struct alc_spec *spec, hda_nid_t nid,
1046 struct snd_kcontrol_new *knew;
1047 unsigned int beep_amp = HDA_COMPOSE_AMP_VAL(nid, 3, idx, dir);
1050 for (i = 0; i < ARRAY_SIZE(alc_beep_mixer); i++) {
1051 knew = snd_hda_gen_add_kctl(&spec->gen, NULL,
1052 &alc_beep_mixer[i]);
1055 knew->private_value = beep_amp;
1060 static const struct snd_pci_quirk beep_white_list[] = {
1061 SND_PCI_QUIRK(0x1043, 0x103c, "ASUS", 1),
1062 SND_PCI_QUIRK(0x1043, 0x115d, "ASUS", 1),
1063 SND_PCI_QUIRK(0x1043, 0x829f, "ASUS", 1),
1064 SND_PCI_QUIRK(0x1043, 0x8376, "EeePC", 1),
1065 SND_PCI_QUIRK(0x1043, 0x83ce, "EeePC", 1),
1066 SND_PCI_QUIRK(0x1043, 0x831a, "EeePC", 1),
1067 SND_PCI_QUIRK(0x1043, 0x834a, "EeePC", 1),
1068 SND_PCI_QUIRK(0x1458, 0xa002, "GA-MA790X", 1),
1069 SND_PCI_QUIRK(0x8086, 0xd613, "Intel", 1),
1070 /* blacklist -- no beep available */
1071 SND_PCI_QUIRK(0x17aa, 0x309e, "Lenovo ThinkCentre M73", 0),
1072 SND_PCI_QUIRK(0x17aa, 0x30a3, "Lenovo ThinkCentre M93", 0),
1076 static inline int has_cdefine_beep(struct hda_codec *codec)
1078 struct alc_spec *spec = codec->spec;
1079 const struct snd_pci_quirk *q;
1080 q = snd_pci_quirk_lookup(codec->bus->pci, beep_white_list);
1083 return spec->cdefine.enable_pcbeep;
1086 #define set_beep_amp(spec, nid, idx, dir) 0
1087 #define has_cdefine_beep(codec) 0
1090 /* parse the BIOS configuration and set up the alc_spec */
1091 /* return 1 if successful, 0 if the proper config is not found,
1092 * or a negative error code
1094 static int alc_parse_auto_config(struct hda_codec *codec,
1095 const hda_nid_t *ignore_nids,
1096 const hda_nid_t *ssid_nids)
1098 struct alc_spec *spec = codec->spec;
1099 struct auto_pin_cfg *cfg = &spec->gen.autocfg;
1102 err = snd_hda_parse_pin_defcfg(codec, cfg, ignore_nids,
1108 alc_ssid_check(codec, ssid_nids);
1110 err = snd_hda_gen_parse_auto_config(codec, cfg);
1117 /* common preparation job for alc_spec */
1118 static int alc_alloc_spec(struct hda_codec *codec, hda_nid_t mixer_nid)
1120 struct alc_spec *spec = kzalloc(sizeof(*spec), GFP_KERNEL);
1126 snd_hda_gen_spec_init(&spec->gen);
1127 spec->gen.mixer_nid = mixer_nid;
1128 spec->gen.own_eapd_ctl = 1;
1129 codec->single_adc_amp = 1;
1130 /* FIXME: do we need this for all Realtek codec models? */
1131 codec->spdif_status_reset = 1;
1132 codec->patch_ops = alc_patch_ops;
1134 err = alc_codec_rename_from_preset(codec);
1142 static int alc880_parse_auto_config(struct hda_codec *codec)
1144 static const hda_nid_t alc880_ignore[] = { 0x1d, 0 };
1145 static const hda_nid_t alc880_ssids[] = { 0x15, 0x1b, 0x14, 0 };
1146 return alc_parse_auto_config(codec, alc880_ignore, alc880_ssids);
1155 ALC880_FIXUP_MEDION_RIM,
1157 ALC880_FIXUP_LG_LW25,
1159 ALC880_FIXUP_EAPD_COEF,
1160 ALC880_FIXUP_TCL_S700,
1161 ALC880_FIXUP_VOL_KNOB,
1162 ALC880_FIXUP_FUJITSU,
1164 ALC880_FIXUP_UNIWILL,
1165 ALC880_FIXUP_UNIWILL_DIG,
1167 ALC880_FIXUP_ASUS_W5A,
1168 ALC880_FIXUP_3ST_BASE,
1170 ALC880_FIXUP_3ST_DIG,
1171 ALC880_FIXUP_5ST_BASE,
1173 ALC880_FIXUP_5ST_DIG,
1174 ALC880_FIXUP_6ST_BASE,
1176 ALC880_FIXUP_6ST_DIG,
1177 ALC880_FIXUP_6ST_AUTOMUTE,
1180 /* enable the volume-knob widget support on NID 0x21 */
1181 static void alc880_fixup_vol_knob(struct hda_codec *codec,
1182 const struct hda_fixup *fix, int action)
1184 if (action == HDA_FIXUP_ACT_PROBE)
1185 snd_hda_jack_detect_enable_callback(codec, 0x21,
1186 alc_update_knob_master);
1189 static const struct hda_fixup alc880_fixups[] = {
1190 [ALC880_FIXUP_GPIO1] = {
1191 .type = HDA_FIXUP_FUNC,
1192 .v.func = alc_fixup_gpio1,
1194 [ALC880_FIXUP_GPIO2] = {
1195 .type = HDA_FIXUP_FUNC,
1196 .v.func = alc_fixup_gpio2,
1198 [ALC880_FIXUP_MEDION_RIM] = {
1199 .type = HDA_FIXUP_VERBS,
1200 .v.verbs = (const struct hda_verb[]) {
1201 { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
1202 { 0x20, AC_VERB_SET_PROC_COEF, 0x3060 },
1206 .chain_id = ALC880_FIXUP_GPIO2,
1208 [ALC880_FIXUP_LG] = {
1209 .type = HDA_FIXUP_PINS,
1210 .v.pins = (const struct hda_pintbl[]) {
1211 /* disable bogus unused pins */
1212 { 0x16, 0x411111f0 },
1213 { 0x18, 0x411111f0 },
1214 { 0x1a, 0x411111f0 },
1218 [ALC880_FIXUP_LG_LW25] = {
1219 .type = HDA_FIXUP_PINS,
1220 .v.pins = (const struct hda_pintbl[]) {
1221 { 0x1a, 0x0181344f }, /* line-in */
1222 { 0x1b, 0x0321403f }, /* headphone */
1226 [ALC880_FIXUP_W810] = {
1227 .type = HDA_FIXUP_PINS,
1228 .v.pins = (const struct hda_pintbl[]) {
1229 /* disable bogus unused pins */
1230 { 0x17, 0x411111f0 },
1234 .chain_id = ALC880_FIXUP_GPIO2,
1236 [ALC880_FIXUP_EAPD_COEF] = {
1237 .type = HDA_FIXUP_VERBS,
1238 .v.verbs = (const struct hda_verb[]) {
1239 /* change to EAPD mode */
1240 { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
1241 { 0x20, AC_VERB_SET_PROC_COEF, 0x3060 },
1245 [ALC880_FIXUP_TCL_S700] = {
1246 .type = HDA_FIXUP_VERBS,
1247 .v.verbs = (const struct hda_verb[]) {
1248 /* change to EAPD mode */
1249 { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
1250 { 0x20, AC_VERB_SET_PROC_COEF, 0x3070 },
1254 .chain_id = ALC880_FIXUP_GPIO2,
1256 [ALC880_FIXUP_VOL_KNOB] = {
1257 .type = HDA_FIXUP_FUNC,
1258 .v.func = alc880_fixup_vol_knob,
1260 [ALC880_FIXUP_FUJITSU] = {
1261 /* override all pins as BIOS on old Amilo is broken */
1262 .type = HDA_FIXUP_PINS,
1263 .v.pins = (const struct hda_pintbl[]) {
1264 { 0x14, 0x0121401f }, /* HP */
1265 { 0x15, 0x99030120 }, /* speaker */
1266 { 0x16, 0x99030130 }, /* bass speaker */
1267 { 0x17, 0x411111f0 }, /* N/A */
1268 { 0x18, 0x411111f0 }, /* N/A */
1269 { 0x19, 0x01a19950 }, /* mic-in */
1270 { 0x1a, 0x411111f0 }, /* N/A */
1271 { 0x1b, 0x411111f0 }, /* N/A */
1272 { 0x1c, 0x411111f0 }, /* N/A */
1273 { 0x1d, 0x411111f0 }, /* N/A */
1274 { 0x1e, 0x01454140 }, /* SPDIF out */
1278 .chain_id = ALC880_FIXUP_VOL_KNOB,
1280 [ALC880_FIXUP_F1734] = {
1281 /* almost compatible with FUJITSU, but no bass and SPDIF */
1282 .type = HDA_FIXUP_PINS,
1283 .v.pins = (const struct hda_pintbl[]) {
1284 { 0x14, 0x0121401f }, /* HP */
1285 { 0x15, 0x99030120 }, /* speaker */
1286 { 0x16, 0x411111f0 }, /* N/A */
1287 { 0x17, 0x411111f0 }, /* N/A */
1288 { 0x18, 0x411111f0 }, /* N/A */
1289 { 0x19, 0x01a19950 }, /* mic-in */
1290 { 0x1a, 0x411111f0 }, /* N/A */
1291 { 0x1b, 0x411111f0 }, /* N/A */
1292 { 0x1c, 0x411111f0 }, /* N/A */
1293 { 0x1d, 0x411111f0 }, /* N/A */
1294 { 0x1e, 0x411111f0 }, /* N/A */
1298 .chain_id = ALC880_FIXUP_VOL_KNOB,
1300 [ALC880_FIXUP_UNIWILL] = {
1301 /* need to fix HP and speaker pins to be parsed correctly */
1302 .type = HDA_FIXUP_PINS,
1303 .v.pins = (const struct hda_pintbl[]) {
1304 { 0x14, 0x0121411f }, /* HP */
1305 { 0x15, 0x99030120 }, /* speaker */
1306 { 0x16, 0x99030130 }, /* bass speaker */
1310 [ALC880_FIXUP_UNIWILL_DIG] = {
1311 .type = HDA_FIXUP_PINS,
1312 .v.pins = (const struct hda_pintbl[]) {
1313 /* disable bogus unused pins */
1314 { 0x17, 0x411111f0 },
1315 { 0x19, 0x411111f0 },
1316 { 0x1b, 0x411111f0 },
1317 { 0x1f, 0x411111f0 },
1321 [ALC880_FIXUP_Z71V] = {
1322 .type = HDA_FIXUP_PINS,
1323 .v.pins = (const struct hda_pintbl[]) {
1324 /* set up the whole pins as BIOS is utterly broken */
1325 { 0x14, 0x99030120 }, /* speaker */
1326 { 0x15, 0x0121411f }, /* HP */
1327 { 0x16, 0x411111f0 }, /* N/A */
1328 { 0x17, 0x411111f0 }, /* N/A */
1329 { 0x18, 0x01a19950 }, /* mic-in */
1330 { 0x19, 0x411111f0 }, /* N/A */
1331 { 0x1a, 0x01813031 }, /* line-in */
1332 { 0x1b, 0x411111f0 }, /* N/A */
1333 { 0x1c, 0x411111f0 }, /* N/A */
1334 { 0x1d, 0x411111f0 }, /* N/A */
1335 { 0x1e, 0x0144111e }, /* SPDIF */
1339 [ALC880_FIXUP_ASUS_W5A] = {
1340 .type = HDA_FIXUP_PINS,
1341 .v.pins = (const struct hda_pintbl[]) {
1342 /* set up the whole pins as BIOS is utterly broken */
1343 { 0x14, 0x0121411f }, /* HP */
1344 { 0x15, 0x411111f0 }, /* N/A */
1345 { 0x16, 0x411111f0 }, /* N/A */
1346 { 0x17, 0x411111f0 }, /* N/A */
1347 { 0x18, 0x90a60160 }, /* mic */
1348 { 0x19, 0x411111f0 }, /* N/A */
1349 { 0x1a, 0x411111f0 }, /* N/A */
1350 { 0x1b, 0x411111f0 }, /* N/A */
1351 { 0x1c, 0x411111f0 }, /* N/A */
1352 { 0x1d, 0x411111f0 }, /* N/A */
1353 { 0x1e, 0xb743111e }, /* SPDIF out */
1357 .chain_id = ALC880_FIXUP_GPIO1,
1359 [ALC880_FIXUP_3ST_BASE] = {
1360 .type = HDA_FIXUP_PINS,
1361 .v.pins = (const struct hda_pintbl[]) {
1362 { 0x14, 0x01014010 }, /* line-out */
1363 { 0x15, 0x411111f0 }, /* N/A */
1364 { 0x16, 0x411111f0 }, /* N/A */
1365 { 0x17, 0x411111f0 }, /* N/A */
1366 { 0x18, 0x01a19c30 }, /* mic-in */
1367 { 0x19, 0x0121411f }, /* HP */
1368 { 0x1a, 0x01813031 }, /* line-in */
1369 { 0x1b, 0x02a19c40 }, /* front-mic */
1370 { 0x1c, 0x411111f0 }, /* N/A */
1371 { 0x1d, 0x411111f0 }, /* N/A */
1372 /* 0x1e is filled in below */
1373 { 0x1f, 0x411111f0 }, /* N/A */
1377 [ALC880_FIXUP_3ST] = {
1378 .type = HDA_FIXUP_PINS,
1379 .v.pins = (const struct hda_pintbl[]) {
1380 { 0x1e, 0x411111f0 }, /* N/A */
1384 .chain_id = ALC880_FIXUP_3ST_BASE,
1386 [ALC880_FIXUP_3ST_DIG] = {
1387 .type = HDA_FIXUP_PINS,
1388 .v.pins = (const struct hda_pintbl[]) {
1389 { 0x1e, 0x0144111e }, /* SPDIF */
1393 .chain_id = ALC880_FIXUP_3ST_BASE,
1395 [ALC880_FIXUP_5ST_BASE] = {
1396 .type = HDA_FIXUP_PINS,
1397 .v.pins = (const struct hda_pintbl[]) {
1398 { 0x14, 0x01014010 }, /* front */
1399 { 0x15, 0x411111f0 }, /* N/A */
1400 { 0x16, 0x01011411 }, /* CLFE */
1401 { 0x17, 0x01016412 }, /* surr */
1402 { 0x18, 0x01a19c30 }, /* mic-in */
1403 { 0x19, 0x0121411f }, /* HP */
1404 { 0x1a, 0x01813031 }, /* line-in */
1405 { 0x1b, 0x02a19c40 }, /* front-mic */
1406 { 0x1c, 0x411111f0 }, /* N/A */
1407 { 0x1d, 0x411111f0 }, /* N/A */
1408 /* 0x1e is filled in below */
1409 { 0x1f, 0x411111f0 }, /* N/A */
1413 [ALC880_FIXUP_5ST] = {
1414 .type = HDA_FIXUP_PINS,
1415 .v.pins = (const struct hda_pintbl[]) {
1416 { 0x1e, 0x411111f0 }, /* N/A */
1420 .chain_id = ALC880_FIXUP_5ST_BASE,
1422 [ALC880_FIXUP_5ST_DIG] = {
1423 .type = HDA_FIXUP_PINS,
1424 .v.pins = (const struct hda_pintbl[]) {
1425 { 0x1e, 0x0144111e }, /* SPDIF */
1429 .chain_id = ALC880_FIXUP_5ST_BASE,
1431 [ALC880_FIXUP_6ST_BASE] = {
1432 .type = HDA_FIXUP_PINS,
1433 .v.pins = (const struct hda_pintbl[]) {
1434 { 0x14, 0x01014010 }, /* front */
1435 { 0x15, 0x01016412 }, /* surr */
1436 { 0x16, 0x01011411 }, /* CLFE */
1437 { 0x17, 0x01012414 }, /* side */
1438 { 0x18, 0x01a19c30 }, /* mic-in */
1439 { 0x19, 0x02a19c40 }, /* front-mic */
1440 { 0x1a, 0x01813031 }, /* line-in */
1441 { 0x1b, 0x0121411f }, /* HP */
1442 { 0x1c, 0x411111f0 }, /* N/A */
1443 { 0x1d, 0x411111f0 }, /* N/A */
1444 /* 0x1e is filled in below */
1445 { 0x1f, 0x411111f0 }, /* N/A */
1449 [ALC880_FIXUP_6ST] = {
1450 .type = HDA_FIXUP_PINS,
1451 .v.pins = (const struct hda_pintbl[]) {
1452 { 0x1e, 0x411111f0 }, /* N/A */
1456 .chain_id = ALC880_FIXUP_6ST_BASE,
1458 [ALC880_FIXUP_6ST_DIG] = {
1459 .type = HDA_FIXUP_PINS,
1460 .v.pins = (const struct hda_pintbl[]) {
1461 { 0x1e, 0x0144111e }, /* SPDIF */
1465 .chain_id = ALC880_FIXUP_6ST_BASE,
1467 [ALC880_FIXUP_6ST_AUTOMUTE] = {
1468 .type = HDA_FIXUP_PINS,
1469 .v.pins = (const struct hda_pintbl[]) {
1470 { 0x1b, 0x0121401f }, /* HP with jack detect */
1473 .chained_before = true,
1474 .chain_id = ALC880_FIXUP_6ST_BASE,
1478 static const struct snd_pci_quirk alc880_fixup_tbl[] = {
1479 SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_FIXUP_W810),
1480 SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS W5A", ALC880_FIXUP_ASUS_W5A),
1481 SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_FIXUP_Z71V),
1482 SND_PCI_QUIRK_VENDOR(0x1043, "ASUS", ALC880_FIXUP_GPIO1),
1483 SND_PCI_QUIRK(0x147b, 0x1045, "ABit AA8XE", ALC880_FIXUP_6ST_AUTOMUTE),
1484 SND_PCI_QUIRK(0x1558, 0x5401, "Clevo GPIO2", ALC880_FIXUP_GPIO2),
1485 SND_PCI_QUIRK_VENDOR(0x1558, "Clevo", ALC880_FIXUP_EAPD_COEF),
1486 SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_FIXUP_UNIWILL_DIG),
1487 SND_PCI_QUIRK(0x1584, 0x9054, "Uniwill", ALC880_FIXUP_F1734),
1488 SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_FIXUP_UNIWILL),
1489 SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_FIXUP_VOL_KNOB),
1490 SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_FIXUP_W810),
1491 SND_PCI_QUIRK(0x161f, 0x205d, "Medion Rim 2150", ALC880_FIXUP_MEDION_RIM),
1492 SND_PCI_QUIRK(0x1631, 0xe011, "PB 13201056", ALC880_FIXUP_6ST_AUTOMUTE),
1493 SND_PCI_QUIRK(0x1734, 0x107c, "FSC Amilo M1437", ALC880_FIXUP_FUJITSU),
1494 SND_PCI_QUIRK(0x1734, 0x1094, "FSC Amilo M1451G", ALC880_FIXUP_FUJITSU),
1495 SND_PCI_QUIRK(0x1734, 0x10ac, "FSC AMILO Xi 1526", ALC880_FIXUP_F1734),
1496 SND_PCI_QUIRK(0x1734, 0x10b0, "FSC Amilo Pi1556", ALC880_FIXUP_FUJITSU),
1497 SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_FIXUP_LG),
1498 SND_PCI_QUIRK(0x1854, 0x005f, "LG P1 Express", ALC880_FIXUP_LG),
1499 SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_FIXUP_LG),
1500 SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_FIXUP_LG_LW25),
1501 SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_FIXUP_TCL_S700),
1503 /* Below is the copied entries from alc880_quirks.c.
1504 * It's not quite sure whether BIOS sets the correct pin-config table
1505 * on these machines, thus they are kept to be compatible with
1506 * the old static quirks. Once when it's confirmed to work without
1507 * these overrides, it'd be better to remove.
1509 SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_FIXUP_5ST_DIG),
1510 SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_FIXUP_6ST),
1511 SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_FIXUP_3ST_DIG),
1512 SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_FIXUP_6ST_DIG),
1513 SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_FIXUP_6ST_DIG),
1514 SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_FIXUP_6ST_DIG),
1515 SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_FIXUP_3ST_DIG),
1516 SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_FIXUP_3ST),
1517 SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_FIXUP_6ST_DIG),
1518 SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_FIXUP_3ST),
1519 SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_FIXUP_3ST),
1520 SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_FIXUP_5ST),
1521 SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_FIXUP_5ST),
1522 SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_FIXUP_5ST),
1523 SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_FIXUP_6ST_DIG),
1524 SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_FIXUP_6ST_DIG),
1525 SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_FIXUP_6ST_DIG),
1526 SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_FIXUP_6ST_DIG),
1527 SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_FIXUP_5ST_DIG),
1528 SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_FIXUP_5ST_DIG),
1529 SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_FIXUP_5ST_DIG),
1530 SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_FIXUP_6ST_DIG), /* broken BIOS */
1531 SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_FIXUP_6ST_DIG),
1532 SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_FIXUP_5ST_DIG),
1533 SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_FIXUP_5ST_DIG),
1534 SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_FIXUP_5ST_DIG),
1535 SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_FIXUP_3ST_DIG),
1536 SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_FIXUP_5ST_DIG),
1537 SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_FIXUP_3ST_DIG),
1538 SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_FIXUP_3ST_DIG),
1539 SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_FIXUP_5ST_DIG),
1540 SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_FIXUP_5ST_DIG),
1541 SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_FIXUP_5ST_DIG),
1543 SND_PCI_QUIRK_VENDOR(0x8086, "Intel mobo", ALC880_FIXUP_3ST),
1544 SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_FIXUP_5ST_DIG),
1545 SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_FIXUP_6ST_DIG),
1549 static const struct hda_model_fixup alc880_fixup_models[] = {
1550 {.id = ALC880_FIXUP_3ST, .name = "3stack"},
1551 {.id = ALC880_FIXUP_3ST_DIG, .name = "3stack-digout"},
1552 {.id = ALC880_FIXUP_5ST, .name = "5stack"},
1553 {.id = ALC880_FIXUP_5ST_DIG, .name = "5stack-digout"},
1554 {.id = ALC880_FIXUP_6ST, .name = "6stack"},
1555 {.id = ALC880_FIXUP_6ST_DIG, .name = "6stack-digout"},
1556 {.id = ALC880_FIXUP_6ST_AUTOMUTE, .name = "6stack-automute"},
1562 * OK, here we have finally the patch for ALC880
1564 static int patch_alc880(struct hda_codec *codec)
1566 struct alc_spec *spec;
1569 err = alc_alloc_spec(codec, 0x0b);
1574 spec->gen.need_dac_fix = 1;
1575 spec->gen.beep_nid = 0x01;
1577 codec->patch_ops.unsol_event = alc880_unsol_event;
1579 alc_pre_init(codec);
1581 snd_hda_pick_fixup(codec, alc880_fixup_models, alc880_fixup_tbl,
1583 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
1585 /* automatic parse from the BIOS config */
1586 err = alc880_parse_auto_config(codec);
1590 if (!spec->gen.no_analog) {
1591 err = set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
1596 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
1609 static int alc260_parse_auto_config(struct hda_codec *codec)
1611 static const hda_nid_t alc260_ignore[] = { 0x17, 0 };
1612 static const hda_nid_t alc260_ssids[] = { 0x10, 0x15, 0x0f, 0 };
1613 return alc_parse_auto_config(codec, alc260_ignore, alc260_ssids);
1620 ALC260_FIXUP_HP_DC5750,
1621 ALC260_FIXUP_HP_PIN_0F,
1624 ALC260_FIXUP_GPIO1_TOGGLE,
1625 ALC260_FIXUP_REPLACER,
1626 ALC260_FIXUP_HP_B1900,
1628 ALC260_FIXUP_FSC_S7020,
1629 ALC260_FIXUP_FSC_S7020_JWSE,
1630 ALC260_FIXUP_VAIO_PINS,
1633 static void alc260_gpio1_automute(struct hda_codec *codec)
1635 struct alc_spec *spec = codec->spec;
1637 alc_update_gpio_data(codec, 0x01, spec->gen.hp_jack_present);
1640 static void alc260_fixup_gpio1_toggle(struct hda_codec *codec,
1641 const struct hda_fixup *fix, int action)
1643 struct alc_spec *spec = codec->spec;
1644 if (action == HDA_FIXUP_ACT_PROBE) {
1645 /* although the machine has only one output pin, we need to
1646 * toggle GPIO1 according to the jack state
1648 spec->gen.automute_hook = alc260_gpio1_automute;
1649 spec->gen.detect_hp = 1;
1650 spec->gen.automute_speaker = 1;
1651 spec->gen.autocfg.hp_pins[0] = 0x0f; /* copy it for automute */
1652 snd_hda_jack_detect_enable_callback(codec, 0x0f,
1653 snd_hda_gen_hp_automute);
1654 alc_setup_gpio(codec, 0x01);
1658 static void alc260_fixup_kn1(struct hda_codec *codec,
1659 const struct hda_fixup *fix, int action)
1661 struct alc_spec *spec = codec->spec;
1662 static const struct hda_pintbl pincfgs[] = {
1663 { 0x0f, 0x02214000 }, /* HP/speaker */
1664 { 0x12, 0x90a60160 }, /* int mic */
1665 { 0x13, 0x02a19000 }, /* ext mic */
1666 { 0x18, 0x01446000 }, /* SPDIF out */
1667 /* disable bogus I/O pins */
1668 { 0x10, 0x411111f0 },
1669 { 0x11, 0x411111f0 },
1670 { 0x14, 0x411111f0 },
1671 { 0x15, 0x411111f0 },
1672 { 0x16, 0x411111f0 },
1673 { 0x17, 0x411111f0 },
1674 { 0x19, 0x411111f0 },
1679 case HDA_FIXUP_ACT_PRE_PROBE:
1680 snd_hda_apply_pincfgs(codec, pincfgs);
1681 spec->init_amp = ALC_INIT_NONE;
1686 static void alc260_fixup_fsc_s7020(struct hda_codec *codec,
1687 const struct hda_fixup *fix, int action)
1689 struct alc_spec *spec = codec->spec;
1690 if (action == HDA_FIXUP_ACT_PRE_PROBE)
1691 spec->init_amp = ALC_INIT_NONE;
1694 static void alc260_fixup_fsc_s7020_jwse(struct hda_codec *codec,
1695 const struct hda_fixup *fix, int action)
1697 struct alc_spec *spec = codec->spec;
1698 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
1699 spec->gen.add_jack_modes = 1;
1700 spec->gen.hp_mic = 1;
1704 static const struct hda_fixup alc260_fixups[] = {
1705 [ALC260_FIXUP_HP_DC5750] = {
1706 .type = HDA_FIXUP_PINS,
1707 .v.pins = (const struct hda_pintbl[]) {
1708 { 0x11, 0x90130110 }, /* speaker */
1712 [ALC260_FIXUP_HP_PIN_0F] = {
1713 .type = HDA_FIXUP_PINS,
1714 .v.pins = (const struct hda_pintbl[]) {
1715 { 0x0f, 0x01214000 }, /* HP */
1719 [ALC260_FIXUP_COEF] = {
1720 .type = HDA_FIXUP_VERBS,
1721 .v.verbs = (const struct hda_verb[]) {
1722 { 0x1a, AC_VERB_SET_COEF_INDEX, 0x07 },
1723 { 0x1a, AC_VERB_SET_PROC_COEF, 0x3040 },
1727 [ALC260_FIXUP_GPIO1] = {
1728 .type = HDA_FIXUP_FUNC,
1729 .v.func = alc_fixup_gpio1,
1731 [ALC260_FIXUP_GPIO1_TOGGLE] = {
1732 .type = HDA_FIXUP_FUNC,
1733 .v.func = alc260_fixup_gpio1_toggle,
1735 .chain_id = ALC260_FIXUP_HP_PIN_0F,
1737 [ALC260_FIXUP_REPLACER] = {
1738 .type = HDA_FIXUP_VERBS,
1739 .v.verbs = (const struct hda_verb[]) {
1740 { 0x1a, AC_VERB_SET_COEF_INDEX, 0x07 },
1741 { 0x1a, AC_VERB_SET_PROC_COEF, 0x3050 },
1745 .chain_id = ALC260_FIXUP_GPIO1_TOGGLE,
1747 [ALC260_FIXUP_HP_B1900] = {
1748 .type = HDA_FIXUP_FUNC,
1749 .v.func = alc260_fixup_gpio1_toggle,
1751 .chain_id = ALC260_FIXUP_COEF,
1753 [ALC260_FIXUP_KN1] = {
1754 .type = HDA_FIXUP_FUNC,
1755 .v.func = alc260_fixup_kn1,
1757 [ALC260_FIXUP_FSC_S7020] = {
1758 .type = HDA_FIXUP_FUNC,
1759 .v.func = alc260_fixup_fsc_s7020,
1761 [ALC260_FIXUP_FSC_S7020_JWSE] = {
1762 .type = HDA_FIXUP_FUNC,
1763 .v.func = alc260_fixup_fsc_s7020_jwse,
1765 .chain_id = ALC260_FIXUP_FSC_S7020,
1767 [ALC260_FIXUP_VAIO_PINS] = {
1768 .type = HDA_FIXUP_PINS,
1769 .v.pins = (const struct hda_pintbl[]) {
1770 /* Pin configs are missing completely on some VAIOs */
1771 { 0x0f, 0x01211020 },
1772 { 0x10, 0x0001003f },
1773 { 0x11, 0x411111f0 },
1774 { 0x12, 0x01a15930 },
1775 { 0x13, 0x411111f0 },
1776 { 0x14, 0x411111f0 },
1777 { 0x15, 0x411111f0 },
1778 { 0x16, 0x411111f0 },
1779 { 0x17, 0x411111f0 },
1780 { 0x18, 0x411111f0 },
1781 { 0x19, 0x411111f0 },
1787 static const struct snd_pci_quirk alc260_fixup_tbl[] = {
1788 SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_FIXUP_GPIO1),
1789 SND_PCI_QUIRK(0x1025, 0x007f, "Acer Aspire 9500", ALC260_FIXUP_COEF),
1790 SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_FIXUP_GPIO1),
1791 SND_PCI_QUIRK(0x103c, 0x280a, "HP dc5750", ALC260_FIXUP_HP_DC5750),
1792 SND_PCI_QUIRK(0x103c, 0x30ba, "HP Presario B1900", ALC260_FIXUP_HP_B1900),
1793 SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_FIXUP_VAIO_PINS),
1794 SND_PCI_QUIRK(0x104d, 0x81e2, "Sony VAIO TX", ALC260_FIXUP_HP_PIN_0F),
1795 SND_PCI_QUIRK(0x10cf, 0x1326, "FSC LifeBook S7020", ALC260_FIXUP_FSC_S7020),
1796 SND_PCI_QUIRK(0x1509, 0x4540, "Favorit 100XS", ALC260_FIXUP_GPIO1),
1797 SND_PCI_QUIRK(0x152d, 0x0729, "Quanta KN1", ALC260_FIXUP_KN1),
1798 SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_FIXUP_REPLACER),
1799 SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_FIXUP_COEF),
1803 static const struct hda_model_fixup alc260_fixup_models[] = {
1804 {.id = ALC260_FIXUP_GPIO1, .name = "gpio1"},
1805 {.id = ALC260_FIXUP_COEF, .name = "coef"},
1806 {.id = ALC260_FIXUP_FSC_S7020, .name = "fujitsu"},
1807 {.id = ALC260_FIXUP_FSC_S7020_JWSE, .name = "fujitsu-jwse"},
1813 static int patch_alc260(struct hda_codec *codec)
1815 struct alc_spec *spec;
1818 err = alc_alloc_spec(codec, 0x07);
1823 /* as quite a few machines require HP amp for speaker outputs,
1824 * it's easier to enable it unconditionally; even if it's unneeded,
1825 * it's almost harmless.
1827 spec->gen.prefer_hp_amp = 1;
1828 spec->gen.beep_nid = 0x01;
1830 spec->shutup = alc_eapd_shutup;
1832 alc_pre_init(codec);
1834 snd_hda_pick_fixup(codec, alc260_fixup_models, alc260_fixup_tbl,
1836 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
1838 /* automatic parse from the BIOS config */
1839 err = alc260_parse_auto_config(codec);
1843 if (!spec->gen.no_analog) {
1844 err = set_beep_amp(spec, 0x07, 0x05, HDA_INPUT);
1849 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
1860 * ALC882/883/885/888/889 support
1862 * ALC882 is almost identical with ALC880 but has cleaner and more flexible
1863 * configuration. Each pin widget can choose any input DACs and a mixer.
1864 * Each ADC is connected from a mixer of all inputs. This makes possible
1865 * 6-channel independent captures.
1867 * In addition, an independent DAC for the multi-playback (not used in this
1875 ALC882_FIXUP_ABIT_AW9D_MAX,
1876 ALC882_FIXUP_LENOVO_Y530,
1877 ALC882_FIXUP_PB_M5210,
1878 ALC882_FIXUP_ACER_ASPIRE_7736,
1879 ALC882_FIXUP_ASUS_W90V,
1881 ALC889_FIXUP_FRONT_HP_NO_PRESENCE,
1882 ALC889_FIXUP_VAIO_TT,
1883 ALC888_FIXUP_EEE1601,
1886 ALC883_FIXUP_ACER_EAPD,
1891 ALC882_FIXUP_ASUS_W2JC,
1892 ALC882_FIXUP_ACER_ASPIRE_4930G,
1893 ALC882_FIXUP_ACER_ASPIRE_8930G,
1894 ALC882_FIXUP_ASPIRE_8930G_VERBS,
1895 ALC885_FIXUP_MACPRO_GPIO,
1896 ALC889_FIXUP_DAC_ROUTE,
1897 ALC889_FIXUP_MBP_VREF,
1898 ALC889_FIXUP_IMAC91_VREF,
1899 ALC889_FIXUP_MBA11_VREF,
1900 ALC889_FIXUP_MBA21_VREF,
1901 ALC889_FIXUP_MP11_VREF,
1902 ALC889_FIXUP_MP41_VREF,
1903 ALC882_FIXUP_INV_DMIC,
1904 ALC882_FIXUP_NO_PRIMARY_HP,
1905 ALC887_FIXUP_ASUS_BASS,
1906 ALC887_FIXUP_BASS_CHMAP,
1907 ALC1220_FIXUP_GB_DUAL_CODECS,
1908 ALC1220_FIXUP_CLEVO_P950,
1909 ALC1220_FIXUP_CLEVO_PB51ED,
1910 ALC1220_FIXUP_CLEVO_PB51ED_PINS,
1913 static void alc889_fixup_coef(struct hda_codec *codec,
1914 const struct hda_fixup *fix, int action)
1916 if (action != HDA_FIXUP_ACT_INIT)
1918 alc_update_coef_idx(codec, 7, 0, 0x2030);
1921 /* set up GPIO at initialization */
1922 static void alc885_fixup_macpro_gpio(struct hda_codec *codec,
1923 const struct hda_fixup *fix, int action)
1925 struct alc_spec *spec = codec->spec;
1927 spec->gpio_write_delay = true;
1928 alc_fixup_gpio3(codec, fix, action);
1931 /* Fix the connection of some pins for ALC889:
1932 * At least, Acer Aspire 5935 shows the connections to DAC3/4 don't
1933 * work correctly (bko#42740)
1935 static void alc889_fixup_dac_route(struct hda_codec *codec,
1936 const struct hda_fixup *fix, int action)
1938 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
1939 /* fake the connections during parsing the tree */
1940 static const hda_nid_t conn1[] = { 0x0c, 0x0d };
1941 static const hda_nid_t conn2[] = { 0x0e, 0x0f };
1942 snd_hda_override_conn_list(codec, 0x14, ARRAY_SIZE(conn1), conn1);
1943 snd_hda_override_conn_list(codec, 0x15, ARRAY_SIZE(conn1), conn1);
1944 snd_hda_override_conn_list(codec, 0x18, ARRAY_SIZE(conn2), conn2);
1945 snd_hda_override_conn_list(codec, 0x1a, ARRAY_SIZE(conn2), conn2);
1946 } else if (action == HDA_FIXUP_ACT_PROBE) {
1947 /* restore the connections */
1948 static const hda_nid_t conn[] = { 0x0c, 0x0d, 0x0e, 0x0f, 0x26 };
1949 snd_hda_override_conn_list(codec, 0x14, ARRAY_SIZE(conn), conn);
1950 snd_hda_override_conn_list(codec, 0x15, ARRAY_SIZE(conn), conn);
1951 snd_hda_override_conn_list(codec, 0x18, ARRAY_SIZE(conn), conn);
1952 snd_hda_override_conn_list(codec, 0x1a, ARRAY_SIZE(conn), conn);
1956 /* Set VREF on HP pin */
1957 static void alc889_fixup_mbp_vref(struct hda_codec *codec,
1958 const struct hda_fixup *fix, int action)
1960 static const hda_nid_t nids[] = { 0x14, 0x15, 0x19 };
1961 struct alc_spec *spec = codec->spec;
1964 if (action != HDA_FIXUP_ACT_INIT)
1966 for (i = 0; i < ARRAY_SIZE(nids); i++) {
1967 unsigned int val = snd_hda_codec_get_pincfg(codec, nids[i]);
1968 if (get_defcfg_device(val) != AC_JACK_HP_OUT)
1970 val = snd_hda_codec_get_pin_target(codec, nids[i]);
1971 val |= AC_PINCTL_VREF_80;
1972 snd_hda_set_pin_ctl(codec, nids[i], val);
1973 spec->gen.keep_vref_in_automute = 1;
1978 static void alc889_fixup_mac_pins(struct hda_codec *codec,
1979 const hda_nid_t *nids, int num_nids)
1981 struct alc_spec *spec = codec->spec;
1984 for (i = 0; i < num_nids; i++) {
1986 val = snd_hda_codec_get_pin_target(codec, nids[i]);
1987 val |= AC_PINCTL_VREF_50;
1988 snd_hda_set_pin_ctl(codec, nids[i], val);
1990 spec->gen.keep_vref_in_automute = 1;
1993 /* Set VREF on speaker pins on imac91 */
1994 static void alc889_fixup_imac91_vref(struct hda_codec *codec,
1995 const struct hda_fixup *fix, int action)
1997 static const hda_nid_t nids[] = { 0x18, 0x1a };
1999 if (action == HDA_FIXUP_ACT_INIT)
2000 alc889_fixup_mac_pins(codec, nids, ARRAY_SIZE(nids));
2003 /* Set VREF on speaker pins on mba11 */
2004 static void alc889_fixup_mba11_vref(struct hda_codec *codec,
2005 const struct hda_fixup *fix, int action)
2007 static const hda_nid_t nids[] = { 0x18 };
2009 if (action == HDA_FIXUP_ACT_INIT)
2010 alc889_fixup_mac_pins(codec, nids, ARRAY_SIZE(nids));
2013 /* Set VREF on speaker pins on mba21 */
2014 static void alc889_fixup_mba21_vref(struct hda_codec *codec,
2015 const struct hda_fixup *fix, int action)
2017 static const hda_nid_t nids[] = { 0x18, 0x19 };
2019 if (action == HDA_FIXUP_ACT_INIT)
2020 alc889_fixup_mac_pins(codec, nids, ARRAY_SIZE(nids));
2023 /* Don't take HP output as primary
2024 * Strangely, the speaker output doesn't work on Vaio Z and some Vaio
2025 * all-in-one desktop PCs (for example VGC-LN51JGB) through DAC 0x05
2027 static void alc882_fixup_no_primary_hp(struct hda_codec *codec,
2028 const struct hda_fixup *fix, int action)
2030 struct alc_spec *spec = codec->spec;
2031 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
2032 spec->gen.no_primary_hp = 1;
2033 spec->gen.no_multi_io = 1;
2037 static void alc_fixup_bass_chmap(struct hda_codec *codec,
2038 const struct hda_fixup *fix, int action);
2040 /* For dual-codec configuration, we need to disable some features to avoid
2041 * conflicts of kctls and PCM streams
2043 static void alc_fixup_dual_codecs(struct hda_codec *codec,
2044 const struct hda_fixup *fix, int action)
2046 struct alc_spec *spec = codec->spec;
2048 if (action != HDA_FIXUP_ACT_PRE_PROBE)
2050 /* disable vmaster */
2051 spec->gen.suppress_vmaster = 1;
2052 /* auto-mute and auto-mic switch don't work with multiple codecs */
2053 spec->gen.suppress_auto_mute = 1;
2054 spec->gen.suppress_auto_mic = 1;
2055 /* disable aamix as well */
2056 spec->gen.mixer_nid = 0;
2057 /* add location prefix to avoid conflicts */
2058 codec->force_pin_prefix = 1;
2061 static void rename_ctl(struct hda_codec *codec, const char *oldname,
2062 const char *newname)
2064 struct snd_kcontrol *kctl;
2066 kctl = snd_hda_find_mixer_ctl(codec, oldname);
2068 strcpy(kctl->id.name, newname);
2071 static void alc1220_fixup_gb_dual_codecs(struct hda_codec *codec,
2072 const struct hda_fixup *fix,
2075 alc_fixup_dual_codecs(codec, fix, action);
2077 case HDA_FIXUP_ACT_PRE_PROBE:
2078 /* override card longname to provide a unique UCM profile */
2079 strcpy(codec->card->longname, "HDAudio-Gigabyte-ALC1220DualCodecs");
2081 case HDA_FIXUP_ACT_BUILD:
2082 /* rename Capture controls depending on the codec */
2083 rename_ctl(codec, "Capture Volume",
2085 "Rear-Panel Capture Volume" :
2086 "Front-Panel Capture Volume");
2087 rename_ctl(codec, "Capture Switch",
2089 "Rear-Panel Capture Switch" :
2090 "Front-Panel Capture Switch");
2095 static void alc1220_fixup_clevo_p950(struct hda_codec *codec,
2096 const struct hda_fixup *fix,
2099 static const hda_nid_t conn1[] = { 0x0c };
2101 if (action != HDA_FIXUP_ACT_PRE_PROBE)
2104 alc_update_coef_idx(codec, 0x7, 0, 0x3c3);
2105 /* We therefore want to make sure 0x14 (front headphone) and
2106 * 0x1b (speakers) use the stereo DAC 0x02
2108 snd_hda_override_conn_list(codec, 0x14, ARRAY_SIZE(conn1), conn1);
2109 snd_hda_override_conn_list(codec, 0x1b, ARRAY_SIZE(conn1), conn1);
2112 static void alc_fixup_headset_mode_no_hp_mic(struct hda_codec *codec,
2113 const struct hda_fixup *fix, int action);
2115 static void alc1220_fixup_clevo_pb51ed(struct hda_codec *codec,
2116 const struct hda_fixup *fix,
2119 alc1220_fixup_clevo_p950(codec, fix, action);
2120 alc_fixup_headset_mode_no_hp_mic(codec, fix, action);
2123 static const struct hda_fixup alc882_fixups[] = {
2124 [ALC882_FIXUP_ABIT_AW9D_MAX] = {
2125 .type = HDA_FIXUP_PINS,
2126 .v.pins = (const struct hda_pintbl[]) {
2127 { 0x15, 0x01080104 }, /* side */
2128 { 0x16, 0x01011012 }, /* rear */
2129 { 0x17, 0x01016011 }, /* clfe */
2133 [ALC882_FIXUP_LENOVO_Y530] = {
2134 .type = HDA_FIXUP_PINS,
2135 .v.pins = (const struct hda_pintbl[]) {
2136 { 0x15, 0x99130112 }, /* rear int speakers */
2137 { 0x16, 0x99130111 }, /* subwoofer */
2141 [ALC882_FIXUP_PB_M5210] = {
2142 .type = HDA_FIXUP_PINCTLS,
2143 .v.pins = (const struct hda_pintbl[]) {
2144 { 0x19, PIN_VREF50 },
2148 [ALC882_FIXUP_ACER_ASPIRE_7736] = {
2149 .type = HDA_FIXUP_FUNC,
2150 .v.func = alc_fixup_sku_ignore,
2152 [ALC882_FIXUP_ASUS_W90V] = {
2153 .type = HDA_FIXUP_PINS,
2154 .v.pins = (const struct hda_pintbl[]) {
2155 { 0x16, 0x99130110 }, /* fix sequence for CLFE */
2159 [ALC889_FIXUP_CD] = {
2160 .type = HDA_FIXUP_PINS,
2161 .v.pins = (const struct hda_pintbl[]) {
2162 { 0x1c, 0x993301f0 }, /* CD */
2166 [ALC889_FIXUP_FRONT_HP_NO_PRESENCE] = {
2167 .type = HDA_FIXUP_PINS,
2168 .v.pins = (const struct hda_pintbl[]) {
2169 { 0x1b, 0x02214120 }, /* Front HP jack is flaky, disable jack detect */
2173 .chain_id = ALC889_FIXUP_CD,
2175 [ALC889_FIXUP_VAIO_TT] = {
2176 .type = HDA_FIXUP_PINS,
2177 .v.pins = (const struct hda_pintbl[]) {
2178 { 0x17, 0x90170111 }, /* hidden surround speaker */
2182 [ALC888_FIXUP_EEE1601] = {
2183 .type = HDA_FIXUP_VERBS,
2184 .v.verbs = (const struct hda_verb[]) {
2185 { 0x20, AC_VERB_SET_COEF_INDEX, 0x0b },
2186 { 0x20, AC_VERB_SET_PROC_COEF, 0x0838 },
2190 [ALC882_FIXUP_EAPD] = {
2191 .type = HDA_FIXUP_VERBS,
2192 .v.verbs = (const struct hda_verb[]) {
2193 /* change to EAPD mode */
2194 { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
2195 { 0x20, AC_VERB_SET_PROC_COEF, 0x3060 },
2199 [ALC883_FIXUP_EAPD] = {
2200 .type = HDA_FIXUP_VERBS,
2201 .v.verbs = (const struct hda_verb[]) {
2202 /* change to EAPD mode */
2203 { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
2204 { 0x20, AC_VERB_SET_PROC_COEF, 0x3070 },
2208 [ALC883_FIXUP_ACER_EAPD] = {
2209 .type = HDA_FIXUP_VERBS,
2210 .v.verbs = (const struct hda_verb[]) {
2211 /* eanable EAPD on Acer laptops */
2212 { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
2213 { 0x20, AC_VERB_SET_PROC_COEF, 0x3050 },
2217 [ALC882_FIXUP_GPIO1] = {
2218 .type = HDA_FIXUP_FUNC,
2219 .v.func = alc_fixup_gpio1,
2221 [ALC882_FIXUP_GPIO2] = {
2222 .type = HDA_FIXUP_FUNC,
2223 .v.func = alc_fixup_gpio2,
2225 [ALC882_FIXUP_GPIO3] = {
2226 .type = HDA_FIXUP_FUNC,
2227 .v.func = alc_fixup_gpio3,
2229 [ALC882_FIXUP_ASUS_W2JC] = {
2230 .type = HDA_FIXUP_FUNC,
2231 .v.func = alc_fixup_gpio1,
2233 .chain_id = ALC882_FIXUP_EAPD,
2235 [ALC889_FIXUP_COEF] = {
2236 .type = HDA_FIXUP_FUNC,
2237 .v.func = alc889_fixup_coef,
2239 [ALC882_FIXUP_ACER_ASPIRE_4930G] = {
2240 .type = HDA_FIXUP_PINS,
2241 .v.pins = (const struct hda_pintbl[]) {
2242 { 0x16, 0x99130111 }, /* CLFE speaker */
2243 { 0x17, 0x99130112 }, /* surround speaker */
2247 .chain_id = ALC882_FIXUP_GPIO1,
2249 [ALC882_FIXUP_ACER_ASPIRE_8930G] = {
2250 .type = HDA_FIXUP_PINS,
2251 .v.pins = (const struct hda_pintbl[]) {
2252 { 0x16, 0x99130111 }, /* CLFE speaker */
2253 { 0x1b, 0x99130112 }, /* surround speaker */
2257 .chain_id = ALC882_FIXUP_ASPIRE_8930G_VERBS,
2259 [ALC882_FIXUP_ASPIRE_8930G_VERBS] = {
2260 /* additional init verbs for Acer Aspire 8930G */
2261 .type = HDA_FIXUP_VERBS,
2262 .v.verbs = (const struct hda_verb[]) {
2263 /* Enable all DACs */
2264 /* DAC DISABLE/MUTE 1? */
2265 /* setting bits 1-5 disables DAC nids 0x02-0x06
2266 * apparently. Init=0x38 */
2267 { 0x20, AC_VERB_SET_COEF_INDEX, 0x03 },
2268 { 0x20, AC_VERB_SET_PROC_COEF, 0x0000 },
2269 /* DAC DISABLE/MUTE 2? */
2270 /* some bit here disables the other DACs.
2272 { 0x20, AC_VERB_SET_COEF_INDEX, 0x08 },
2273 { 0x20, AC_VERB_SET_PROC_COEF, 0x0000 },
2275 * This laptop has a stereo digital microphone.
2276 * The mics are only 1cm apart which makes the stereo
2277 * useless. However, either the mic or the ALC889
2278 * makes the signal become a difference/sum signal
2279 * instead of standard stereo, which is annoying.
2280 * So instead we flip this bit which makes the
2281 * codec replicate the sum signal to both channels,
2282 * turning it into a normal mono mic.
2284 /* DMIC_CONTROL? Init value = 0x0001 */
2285 { 0x20, AC_VERB_SET_COEF_INDEX, 0x0b },
2286 { 0x20, AC_VERB_SET_PROC_COEF, 0x0003 },
2287 { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
2288 { 0x20, AC_VERB_SET_PROC_COEF, 0x3050 },
2292 .chain_id = ALC882_FIXUP_GPIO1,
2294 [ALC885_FIXUP_MACPRO_GPIO] = {
2295 .type = HDA_FIXUP_FUNC,
2296 .v.func = alc885_fixup_macpro_gpio,
2298 [ALC889_FIXUP_DAC_ROUTE] = {
2299 .type = HDA_FIXUP_FUNC,
2300 .v.func = alc889_fixup_dac_route,
2302 [ALC889_FIXUP_MBP_VREF] = {
2303 .type = HDA_FIXUP_FUNC,
2304 .v.func = alc889_fixup_mbp_vref,
2306 .chain_id = ALC882_FIXUP_GPIO1,
2308 [ALC889_FIXUP_IMAC91_VREF] = {
2309 .type = HDA_FIXUP_FUNC,
2310 .v.func = alc889_fixup_imac91_vref,
2312 .chain_id = ALC882_FIXUP_GPIO1,
2314 [ALC889_FIXUP_MBA11_VREF] = {
2315 .type = HDA_FIXUP_FUNC,
2316 .v.func = alc889_fixup_mba11_vref,
2318 .chain_id = ALC889_FIXUP_MBP_VREF,
2320 [ALC889_FIXUP_MBA21_VREF] = {
2321 .type = HDA_FIXUP_FUNC,
2322 .v.func = alc889_fixup_mba21_vref,
2324 .chain_id = ALC889_FIXUP_MBP_VREF,
2326 [ALC889_FIXUP_MP11_VREF] = {
2327 .type = HDA_FIXUP_FUNC,
2328 .v.func = alc889_fixup_mba11_vref,
2330 .chain_id = ALC885_FIXUP_MACPRO_GPIO,
2332 [ALC889_FIXUP_MP41_VREF] = {
2333 .type = HDA_FIXUP_FUNC,
2334 .v.func = alc889_fixup_mbp_vref,
2336 .chain_id = ALC885_FIXUP_MACPRO_GPIO,
2338 [ALC882_FIXUP_INV_DMIC] = {
2339 .type = HDA_FIXUP_FUNC,
2340 .v.func = alc_fixup_inv_dmic,
2342 [ALC882_FIXUP_NO_PRIMARY_HP] = {
2343 .type = HDA_FIXUP_FUNC,
2344 .v.func = alc882_fixup_no_primary_hp,
2346 [ALC887_FIXUP_ASUS_BASS] = {
2347 .type = HDA_FIXUP_PINS,
2348 .v.pins = (const struct hda_pintbl[]) {
2349 {0x16, 0x99130130}, /* bass speaker */
2353 .chain_id = ALC887_FIXUP_BASS_CHMAP,
2355 [ALC887_FIXUP_BASS_CHMAP] = {
2356 .type = HDA_FIXUP_FUNC,
2357 .v.func = alc_fixup_bass_chmap,
2359 [ALC1220_FIXUP_GB_DUAL_CODECS] = {
2360 .type = HDA_FIXUP_FUNC,
2361 .v.func = alc1220_fixup_gb_dual_codecs,
2363 [ALC1220_FIXUP_CLEVO_P950] = {
2364 .type = HDA_FIXUP_FUNC,
2365 .v.func = alc1220_fixup_clevo_p950,
2367 [ALC1220_FIXUP_CLEVO_PB51ED] = {
2368 .type = HDA_FIXUP_FUNC,
2369 .v.func = alc1220_fixup_clevo_pb51ed,
2371 [ALC1220_FIXUP_CLEVO_PB51ED_PINS] = {
2372 .type = HDA_FIXUP_PINS,
2373 .v.pins = (const struct hda_pintbl[]) {
2374 { 0x19, 0x01a1913c }, /* use as headset mic, without its own jack detect */
2378 .chain_id = ALC1220_FIXUP_CLEVO_PB51ED,
2382 static const struct snd_pci_quirk alc882_fixup_tbl[] = {
2383 SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_FIXUP_ACER_EAPD),
2384 SND_PCI_QUIRK(0x1025, 0x0090, "Acer Aspire", ALC883_FIXUP_ACER_EAPD),
2385 SND_PCI_QUIRK(0x1025, 0x0107, "Acer Aspire", ALC883_FIXUP_ACER_EAPD),
2386 SND_PCI_QUIRK(0x1025, 0x010a, "Acer Ferrari 5000", ALC883_FIXUP_ACER_EAPD),
2387 SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_FIXUP_ACER_EAPD),
2388 SND_PCI_QUIRK(0x1025, 0x0112, "Acer Aspire 9303", ALC883_FIXUP_ACER_EAPD),
2389 SND_PCI_QUIRK(0x1025, 0x0121, "Acer Aspire 5920G", ALC883_FIXUP_ACER_EAPD),
2390 SND_PCI_QUIRK(0x1025, 0x013e, "Acer Aspire 4930G",
2391 ALC882_FIXUP_ACER_ASPIRE_4930G),
2392 SND_PCI_QUIRK(0x1025, 0x013f, "Acer Aspire 5930G",
2393 ALC882_FIXUP_ACER_ASPIRE_4930G),
2394 SND_PCI_QUIRK(0x1025, 0x0145, "Acer Aspire 8930G",
2395 ALC882_FIXUP_ACER_ASPIRE_8930G),
2396 SND_PCI_QUIRK(0x1025, 0x0146, "Acer Aspire 6935G",
2397 ALC882_FIXUP_ACER_ASPIRE_8930G),
2398 SND_PCI_QUIRK(0x1025, 0x015e, "Acer Aspire 6930G",
2399 ALC882_FIXUP_ACER_ASPIRE_4930G),
2400 SND_PCI_QUIRK(0x1025, 0x0166, "Acer Aspire 6530G",
2401 ALC882_FIXUP_ACER_ASPIRE_4930G),
2402 SND_PCI_QUIRK(0x1025, 0x0142, "Acer Aspire 7730G",
2403 ALC882_FIXUP_ACER_ASPIRE_4930G),
2404 SND_PCI_QUIRK(0x1025, 0x0155, "Packard-Bell M5120", ALC882_FIXUP_PB_M5210),
2405 SND_PCI_QUIRK(0x1025, 0x021e, "Acer Aspire 5739G",
2406 ALC882_FIXUP_ACER_ASPIRE_4930G),
2407 SND_PCI_QUIRK(0x1025, 0x0259, "Acer Aspire 5935", ALC889_FIXUP_DAC_ROUTE),
2408 SND_PCI_QUIRK(0x1025, 0x026b, "Acer Aspire 8940G", ALC882_FIXUP_ACER_ASPIRE_8930G),
2409 SND_PCI_QUIRK(0x1025, 0x0296, "Acer Aspire 7736z", ALC882_FIXUP_ACER_ASPIRE_7736),
2410 SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_FIXUP_EAPD),
2411 SND_PCI_QUIRK(0x1043, 0x1873, "ASUS W90V", ALC882_FIXUP_ASUS_W90V),
2412 SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_FIXUP_ASUS_W2JC),
2413 SND_PCI_QUIRK(0x1043, 0x835f, "Asus Eee 1601", ALC888_FIXUP_EEE1601),
2414 SND_PCI_QUIRK(0x1043, 0x84bc, "ASUS ET2700", ALC887_FIXUP_ASUS_BASS),
2415 SND_PCI_QUIRK(0x1043, 0x8691, "ASUS ROG Ranger VIII", ALC882_FIXUP_GPIO3),
2416 SND_PCI_QUIRK(0x104d, 0x9047, "Sony Vaio TT", ALC889_FIXUP_VAIO_TT),
2417 SND_PCI_QUIRK(0x104d, 0x905a, "Sony Vaio Z", ALC882_FIXUP_NO_PRIMARY_HP),
2418 SND_PCI_QUIRK(0x104d, 0x9060, "Sony Vaio VPCL14M1R", ALC882_FIXUP_NO_PRIMARY_HP),
2419 SND_PCI_QUIRK(0x104d, 0x9043, "Sony Vaio VGC-LN51JGB", ALC882_FIXUP_NO_PRIMARY_HP),
2420 SND_PCI_QUIRK(0x104d, 0x9044, "Sony VAIO AiO", ALC882_FIXUP_NO_PRIMARY_HP),
2422 /* All Apple entries are in codec SSIDs */
2423 SND_PCI_QUIRK(0x106b, 0x00a0, "MacBookPro 3,1", ALC889_FIXUP_MBP_VREF),
2424 SND_PCI_QUIRK(0x106b, 0x00a1, "Macbook", ALC889_FIXUP_MBP_VREF),
2425 SND_PCI_QUIRK(0x106b, 0x00a4, "MacbookPro 4,1", ALC889_FIXUP_MBP_VREF),
2426 SND_PCI_QUIRK(0x106b, 0x0c00, "Mac Pro", ALC889_FIXUP_MP11_VREF),
2427 SND_PCI_QUIRK(0x106b, 0x1000, "iMac 24", ALC885_FIXUP_MACPRO_GPIO),
2428 SND_PCI_QUIRK(0x106b, 0x2800, "AppleTV", ALC885_FIXUP_MACPRO_GPIO),
2429 SND_PCI_QUIRK(0x106b, 0x2c00, "MacbookPro rev3", ALC889_FIXUP_MBP_VREF),
2430 SND_PCI_QUIRK(0x106b, 0x3000, "iMac", ALC889_FIXUP_MBP_VREF),
2431 SND_PCI_QUIRK(0x106b, 0x3200, "iMac 7,1 Aluminum", ALC882_FIXUP_EAPD),
2432 SND_PCI_QUIRK(0x106b, 0x3400, "MacBookAir 1,1", ALC889_FIXUP_MBA11_VREF),
2433 SND_PCI_QUIRK(0x106b, 0x3500, "MacBookAir 2,1", ALC889_FIXUP_MBA21_VREF),
2434 SND_PCI_QUIRK(0x106b, 0x3600, "Macbook 3,1", ALC889_FIXUP_MBP_VREF),
2435 SND_PCI_QUIRK(0x106b, 0x3800, "MacbookPro 4,1", ALC889_FIXUP_MBP_VREF),
2436 SND_PCI_QUIRK(0x106b, 0x3e00, "iMac 24 Aluminum", ALC885_FIXUP_MACPRO_GPIO),
2437 SND_PCI_QUIRK(0x106b, 0x3f00, "Macbook 5,1", ALC889_FIXUP_IMAC91_VREF),
2438 SND_PCI_QUIRK(0x106b, 0x4000, "MacbookPro 5,1", ALC889_FIXUP_IMAC91_VREF),
2439 SND_PCI_QUIRK(0x106b, 0x4100, "Macmini 3,1", ALC889_FIXUP_IMAC91_VREF),
2440 SND_PCI_QUIRK(0x106b, 0x4200, "Mac Pro 4,1/5,1", ALC889_FIXUP_MP41_VREF),
2441 SND_PCI_QUIRK(0x106b, 0x4300, "iMac 9,1", ALC889_FIXUP_IMAC91_VREF),
2442 SND_PCI_QUIRK(0x106b, 0x4600, "MacbookPro 5,2", ALC889_FIXUP_IMAC91_VREF),
2443 SND_PCI_QUIRK(0x106b, 0x4900, "iMac 9,1 Aluminum", ALC889_FIXUP_IMAC91_VREF),
2444 SND_PCI_QUIRK(0x106b, 0x4a00, "Macbook 5,2", ALC889_FIXUP_MBA11_VREF),
2446 SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC882_FIXUP_EAPD),
2447 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte EP45-DS3/Z87X-UD3H", ALC889_FIXUP_FRONT_HP_NO_PRESENCE),
2448 SND_PCI_QUIRK(0x1458, 0xa0b8, "Gigabyte AZ370-Gaming", ALC1220_FIXUP_GB_DUAL_CODECS),
2449 SND_PCI_QUIRK(0x1462, 0x7350, "MSI-7350", ALC889_FIXUP_CD),
2450 SND_PCI_QUIRK(0x1462, 0xda57, "MSI Z270-Gaming", ALC1220_FIXUP_GB_DUAL_CODECS),
2451 SND_PCI_QUIRK_VENDOR(0x1462, "MSI", ALC882_FIXUP_GPIO3),
2452 SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", ALC882_FIXUP_ABIT_AW9D_MAX),
2453 SND_PCI_QUIRK(0x1558, 0x9501, "Clevo P950HR", ALC1220_FIXUP_CLEVO_P950),
2454 SND_PCI_QUIRK(0x1558, 0x95e1, "Clevo P95xER", ALC1220_FIXUP_CLEVO_P950),
2455 SND_PCI_QUIRK(0x1558, 0x95e2, "Clevo P950ER", ALC1220_FIXUP_CLEVO_P950),
2456 SND_PCI_QUIRK(0x1558, 0x96e1, "Clevo P960[ER][CDFN]-K", ALC1220_FIXUP_CLEVO_P950),
2457 SND_PCI_QUIRK(0x1558, 0x97e1, "Clevo P970[ER][CDFN]", ALC1220_FIXUP_CLEVO_P950),
2458 SND_PCI_QUIRK(0x1558, 0x65d1, "Clevo PB51[ER][CDF]", ALC1220_FIXUP_CLEVO_PB51ED_PINS),
2459 SND_PCI_QUIRK(0x1558, 0x67d1, "Clevo PB71[ER][CDF]", ALC1220_FIXUP_CLEVO_PB51ED_PINS),
2460 SND_PCI_QUIRK_VENDOR(0x1558, "Clevo laptop", ALC882_FIXUP_EAPD),
2461 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_FIXUP_EAPD),
2462 SND_PCI_QUIRK(0x17aa, 0x3a0d, "Lenovo Y530", ALC882_FIXUP_LENOVO_Y530),
2463 SND_PCI_QUIRK(0x8086, 0x0022, "DX58SO", ALC889_FIXUP_COEF),
2467 static const struct hda_model_fixup alc882_fixup_models[] = {
2468 {.id = ALC882_FIXUP_ABIT_AW9D_MAX, .name = "abit-aw9d"},
2469 {.id = ALC882_FIXUP_LENOVO_Y530, .name = "lenovo-y530"},
2470 {.id = ALC882_FIXUP_ACER_ASPIRE_7736, .name = "acer-aspire-7736"},
2471 {.id = ALC882_FIXUP_ASUS_W90V, .name = "asus-w90v"},
2472 {.id = ALC889_FIXUP_CD, .name = "cd"},
2473 {.id = ALC889_FIXUP_FRONT_HP_NO_PRESENCE, .name = "no-front-hp"},
2474 {.id = ALC889_FIXUP_VAIO_TT, .name = "vaio-tt"},
2475 {.id = ALC888_FIXUP_EEE1601, .name = "eee1601"},
2476 {.id = ALC882_FIXUP_EAPD, .name = "alc882-eapd"},
2477 {.id = ALC883_FIXUP_EAPD, .name = "alc883-eapd"},
2478 {.id = ALC882_FIXUP_GPIO1, .name = "gpio1"},
2479 {.id = ALC882_FIXUP_GPIO2, .name = "gpio2"},
2480 {.id = ALC882_FIXUP_GPIO3, .name = "gpio3"},
2481 {.id = ALC889_FIXUP_COEF, .name = "alc889-coef"},
2482 {.id = ALC882_FIXUP_ASUS_W2JC, .name = "asus-w2jc"},
2483 {.id = ALC882_FIXUP_ACER_ASPIRE_4930G, .name = "acer-aspire-4930g"},
2484 {.id = ALC882_FIXUP_ACER_ASPIRE_8930G, .name = "acer-aspire-8930g"},
2485 {.id = ALC883_FIXUP_ACER_EAPD, .name = "acer-aspire"},
2486 {.id = ALC885_FIXUP_MACPRO_GPIO, .name = "macpro-gpio"},
2487 {.id = ALC889_FIXUP_DAC_ROUTE, .name = "dac-route"},
2488 {.id = ALC889_FIXUP_MBP_VREF, .name = "mbp-vref"},
2489 {.id = ALC889_FIXUP_IMAC91_VREF, .name = "imac91-vref"},
2490 {.id = ALC889_FIXUP_MBA11_VREF, .name = "mba11-vref"},
2491 {.id = ALC889_FIXUP_MBA21_VREF, .name = "mba21-vref"},
2492 {.id = ALC889_FIXUP_MP11_VREF, .name = "mp11-vref"},
2493 {.id = ALC889_FIXUP_MP41_VREF, .name = "mp41-vref"},
2494 {.id = ALC882_FIXUP_INV_DMIC, .name = "inv-dmic"},
2495 {.id = ALC882_FIXUP_NO_PRIMARY_HP, .name = "no-primary-hp"},
2496 {.id = ALC887_FIXUP_ASUS_BASS, .name = "asus-bass"},
2497 {.id = ALC1220_FIXUP_GB_DUAL_CODECS, .name = "dual-codecs"},
2498 {.id = ALC1220_FIXUP_CLEVO_P950, .name = "clevo-p950"},
2503 * BIOS auto configuration
2505 /* almost identical with ALC880 parser... */
2506 static int alc882_parse_auto_config(struct hda_codec *codec)
2508 static const hda_nid_t alc882_ignore[] = { 0x1d, 0 };
2509 static const hda_nid_t alc882_ssids[] = { 0x15, 0x1b, 0x14, 0 };
2510 return alc_parse_auto_config(codec, alc882_ignore, alc882_ssids);
2515 static int patch_alc882(struct hda_codec *codec)
2517 struct alc_spec *spec;
2520 err = alc_alloc_spec(codec, 0x0b);
2526 switch (codec->core.vendor_id) {
2534 /* ALC883 and variants */
2535 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
2539 alc_pre_init(codec);
2541 snd_hda_pick_fixup(codec, alc882_fixup_models, alc882_fixup_tbl,
2543 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
2545 alc_auto_parse_customize_define(codec);
2547 if (has_cdefine_beep(codec))
2548 spec->gen.beep_nid = 0x01;
2550 /* automatic parse from the BIOS config */
2551 err = alc882_parse_auto_config(codec);
2555 if (!spec->gen.no_analog && spec->gen.beep_nid) {
2556 err = set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
2561 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
2574 static int alc262_parse_auto_config(struct hda_codec *codec)
2576 static const hda_nid_t alc262_ignore[] = { 0x1d, 0 };
2577 static const hda_nid_t alc262_ssids[] = { 0x15, 0x1b, 0x14, 0 };
2578 return alc_parse_auto_config(codec, alc262_ignore, alc262_ssids);
2585 ALC262_FIXUP_FSC_H270,
2586 ALC262_FIXUP_FSC_S7110,
2587 ALC262_FIXUP_HP_Z200,
2589 ALC262_FIXUP_LENOVO_3000,
2591 ALC262_FIXUP_BENQ_T31,
2592 ALC262_FIXUP_INV_DMIC,
2593 ALC262_FIXUP_INTEL_BAYLEYBAY,
2596 static const struct hda_fixup alc262_fixups[] = {
2597 [ALC262_FIXUP_FSC_H270] = {
2598 .type = HDA_FIXUP_PINS,
2599 .v.pins = (const struct hda_pintbl[]) {
2600 { 0x14, 0x99130110 }, /* speaker */
2601 { 0x15, 0x0221142f }, /* front HP */
2602 { 0x1b, 0x0121141f }, /* rear HP */
2606 [ALC262_FIXUP_FSC_S7110] = {
2607 .type = HDA_FIXUP_PINS,
2608 .v.pins = (const struct hda_pintbl[]) {
2609 { 0x15, 0x90170110 }, /* speaker */
2613 .chain_id = ALC262_FIXUP_BENQ,
2615 [ALC262_FIXUP_HP_Z200] = {
2616 .type = HDA_FIXUP_PINS,
2617 .v.pins = (const struct hda_pintbl[]) {
2618 { 0x16, 0x99130120 }, /* internal speaker */
2622 [ALC262_FIXUP_TYAN] = {
2623 .type = HDA_FIXUP_PINS,
2624 .v.pins = (const struct hda_pintbl[]) {
2625 { 0x14, 0x1993e1f0 }, /* int AUX */
2629 [ALC262_FIXUP_LENOVO_3000] = {
2630 .type = HDA_FIXUP_PINCTLS,
2631 .v.pins = (const struct hda_pintbl[]) {
2632 { 0x19, PIN_VREF50 },
2636 .chain_id = ALC262_FIXUP_BENQ,
2638 [ALC262_FIXUP_BENQ] = {
2639 .type = HDA_FIXUP_VERBS,
2640 .v.verbs = (const struct hda_verb[]) {
2641 { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
2642 { 0x20, AC_VERB_SET_PROC_COEF, 0x3070 },
2646 [ALC262_FIXUP_BENQ_T31] = {
2647 .type = HDA_FIXUP_VERBS,
2648 .v.verbs = (const struct hda_verb[]) {
2649 { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
2650 { 0x20, AC_VERB_SET_PROC_COEF, 0x3050 },
2654 [ALC262_FIXUP_INV_DMIC] = {
2655 .type = HDA_FIXUP_FUNC,
2656 .v.func = alc_fixup_inv_dmic,
2658 [ALC262_FIXUP_INTEL_BAYLEYBAY] = {
2659 .type = HDA_FIXUP_FUNC,
2660 .v.func = alc_fixup_no_depop_delay,
2664 static const struct snd_pci_quirk alc262_fixup_tbl[] = {
2665 SND_PCI_QUIRK(0x103c, 0x170b, "HP Z200", ALC262_FIXUP_HP_Z200),
2666 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu Lifebook S7110", ALC262_FIXUP_FSC_S7110),
2667 SND_PCI_QUIRK(0x10cf, 0x142d, "Fujitsu Lifebook E8410", ALC262_FIXUP_BENQ),
2668 SND_PCI_QUIRK(0x10f1, 0x2915, "Tyan Thunder n6650W", ALC262_FIXUP_TYAN),
2669 SND_PCI_QUIRK(0x1734, 0x1141, "FSC ESPRIMO U9210", ALC262_FIXUP_FSC_H270),
2670 SND_PCI_QUIRK(0x1734, 0x1147, "FSC Celsius H270", ALC262_FIXUP_FSC_H270),
2671 SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000", ALC262_FIXUP_LENOVO_3000),
2672 SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_FIXUP_BENQ),
2673 SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_FIXUP_BENQ_T31),
2674 SND_PCI_QUIRK(0x8086, 0x7270, "BayleyBay", ALC262_FIXUP_INTEL_BAYLEYBAY),
2678 static const struct hda_model_fixup alc262_fixup_models[] = {
2679 {.id = ALC262_FIXUP_INV_DMIC, .name = "inv-dmic"},
2680 {.id = ALC262_FIXUP_FSC_H270, .name = "fsc-h270"},
2681 {.id = ALC262_FIXUP_FSC_S7110, .name = "fsc-s7110"},
2682 {.id = ALC262_FIXUP_HP_Z200, .name = "hp-z200"},
2683 {.id = ALC262_FIXUP_TYAN, .name = "tyan"},
2684 {.id = ALC262_FIXUP_LENOVO_3000, .name = "lenovo-3000"},
2685 {.id = ALC262_FIXUP_BENQ, .name = "benq"},
2686 {.id = ALC262_FIXUP_BENQ_T31, .name = "benq-t31"},
2687 {.id = ALC262_FIXUP_INTEL_BAYLEYBAY, .name = "bayleybay"},
2693 static int patch_alc262(struct hda_codec *codec)
2695 struct alc_spec *spec;
2698 err = alc_alloc_spec(codec, 0x0b);
2703 spec->gen.shared_mic_vref_pin = 0x18;
2705 spec->shutup = alc_eapd_shutup;
2708 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
2711 alc_update_coefex_idx(codec, 0x1a, 7, 0, 0x80);
2713 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
2715 alc_pre_init(codec);
2717 snd_hda_pick_fixup(codec, alc262_fixup_models, alc262_fixup_tbl,
2719 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
2721 alc_auto_parse_customize_define(codec);
2723 if (has_cdefine_beep(codec))
2724 spec->gen.beep_nid = 0x01;
2726 /* automatic parse from the BIOS config */
2727 err = alc262_parse_auto_config(codec);
2731 if (!spec->gen.no_analog && spec->gen.beep_nid) {
2732 err = set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
2737 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
2749 /* bind Beep switches of both NID 0x0f and 0x10 */
2750 static int alc268_beep_switch_put(struct snd_kcontrol *kcontrol,
2751 struct snd_ctl_elem_value *ucontrol)
2753 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2757 mutex_lock(&codec->control_mutex);
2758 pval = kcontrol->private_value;
2759 kcontrol->private_value = (pval & ~0xff) | 0x0f;
2760 err = snd_hda_mixer_amp_switch_put(kcontrol, ucontrol);
2762 kcontrol->private_value = (pval & ~0xff) | 0x10;
2763 err = snd_hda_mixer_amp_switch_put(kcontrol, ucontrol);
2765 kcontrol->private_value = pval;
2766 mutex_unlock(&codec->control_mutex);
2770 static const struct snd_kcontrol_new alc268_beep_mixer[] = {
2771 HDA_CODEC_VOLUME("Beep Playback Volume", 0x1d, 0x0, HDA_INPUT),
2773 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2774 .name = "Beep Playback Switch",
2775 .subdevice = HDA_SUBDEV_AMP_FLAG,
2776 .info = snd_hda_mixer_amp_switch_info,
2777 .get = snd_hda_mixer_amp_switch_get,
2778 .put = alc268_beep_switch_put,
2779 .private_value = HDA_COMPOSE_AMP_VAL(0x0f, 3, 1, HDA_INPUT)
2783 /* set PCBEEP vol = 0, mute connections */
2784 static const struct hda_verb alc268_beep_init_verbs[] = {
2785 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2786 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2787 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2792 ALC268_FIXUP_INV_DMIC,
2793 ALC268_FIXUP_HP_EAPD,
2797 static const struct hda_fixup alc268_fixups[] = {
2798 [ALC268_FIXUP_INV_DMIC] = {
2799 .type = HDA_FIXUP_FUNC,
2800 .v.func = alc_fixup_inv_dmic,
2802 [ALC268_FIXUP_HP_EAPD] = {
2803 .type = HDA_FIXUP_VERBS,
2804 .v.verbs = (const struct hda_verb[]) {
2805 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 0},
2809 [ALC268_FIXUP_SPDIF] = {
2810 .type = HDA_FIXUP_PINS,
2811 .v.pins = (const struct hda_pintbl[]) {
2812 { 0x1e, 0x014b1180 }, /* enable SPDIF out */
2818 static const struct hda_model_fixup alc268_fixup_models[] = {
2819 {.id = ALC268_FIXUP_INV_DMIC, .name = "inv-dmic"},
2820 {.id = ALC268_FIXUP_HP_EAPD, .name = "hp-eapd"},
2821 {.id = ALC268_FIXUP_SPDIF, .name = "spdif"},
2825 static const struct snd_pci_quirk alc268_fixup_tbl[] = {
2826 SND_PCI_QUIRK(0x1025, 0x0139, "Acer TravelMate 6293", ALC268_FIXUP_SPDIF),
2827 SND_PCI_QUIRK(0x1025, 0x015b, "Acer AOA 150 (ZG5)", ALC268_FIXUP_INV_DMIC),
2828 /* below is codec SSID since multiple Toshiba laptops have the
2829 * same PCI SSID 1179:ff00
2831 SND_PCI_QUIRK(0x1179, 0xff06, "Toshiba P200", ALC268_FIXUP_HP_EAPD),
2836 * BIOS auto configuration
2838 static int alc268_parse_auto_config(struct hda_codec *codec)
2840 static const hda_nid_t alc268_ssids[] = { 0x15, 0x1b, 0x14, 0 };
2841 return alc_parse_auto_config(codec, NULL, alc268_ssids);
2846 static int patch_alc268(struct hda_codec *codec)
2848 struct alc_spec *spec;
2851 /* ALC268 has no aa-loopback mixer */
2852 err = alc_alloc_spec(codec, 0);
2857 if (has_cdefine_beep(codec))
2858 spec->gen.beep_nid = 0x01;
2860 spec->shutup = alc_eapd_shutup;
2862 alc_pre_init(codec);
2864 snd_hda_pick_fixup(codec, alc268_fixup_models, alc268_fixup_tbl, alc268_fixups);
2865 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
2867 /* automatic parse from the BIOS config */
2868 err = alc268_parse_auto_config(codec);
2872 if (err > 0 && !spec->gen.no_analog &&
2873 spec->gen.autocfg.speaker_pins[0] != 0x1d) {
2874 for (i = 0; i < ARRAY_SIZE(alc268_beep_mixer); i++) {
2875 if (!snd_hda_gen_add_kctl(&spec->gen, NULL,
2876 &alc268_beep_mixer[i])) {
2881 snd_hda_add_verbs(codec, alc268_beep_init_verbs);
2882 if (!query_amp_caps(codec, 0x1d, HDA_INPUT))
2883 /* override the amp caps for beep generator */
2884 snd_hda_override_amp_caps(codec, 0x1d, HDA_INPUT,
2885 (0x0c << AC_AMPCAP_OFFSET_SHIFT) |
2886 (0x0c << AC_AMPCAP_NUM_STEPS_SHIFT) |
2887 (0x07 << AC_AMPCAP_STEP_SIZE_SHIFT) |
2888 (0 << AC_AMPCAP_MUTE_SHIFT));
2891 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
2904 static const struct hda_pcm_stream alc269_44k_pcm_analog_playback = {
2905 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
2908 static const struct hda_pcm_stream alc269_44k_pcm_analog_capture = {
2909 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
2912 /* different alc269-variants */
2914 ALC269_TYPE_ALC269VA,
2915 ALC269_TYPE_ALC269VB,
2916 ALC269_TYPE_ALC269VC,
2917 ALC269_TYPE_ALC269VD,
2937 * BIOS auto configuration
2939 static int alc269_parse_auto_config(struct hda_codec *codec)
2941 static const hda_nid_t alc269_ignore[] = { 0x1d, 0 };
2942 static const hda_nid_t alc269_ssids[] = { 0, 0x1b, 0x14, 0x21 };
2943 static const hda_nid_t alc269va_ssids[] = { 0x15, 0x1b, 0x14, 0 };
2944 struct alc_spec *spec = codec->spec;
2945 const hda_nid_t *ssids;
2947 switch (spec->codec_variant) {
2948 case ALC269_TYPE_ALC269VA:
2949 case ALC269_TYPE_ALC269VC:
2950 case ALC269_TYPE_ALC280:
2951 case ALC269_TYPE_ALC284:
2952 case ALC269_TYPE_ALC293:
2953 ssids = alc269va_ssids;
2955 case ALC269_TYPE_ALC269VB:
2956 case ALC269_TYPE_ALC269VD:
2957 case ALC269_TYPE_ALC282:
2958 case ALC269_TYPE_ALC283:
2959 case ALC269_TYPE_ALC286:
2960 case ALC269_TYPE_ALC298:
2961 case ALC269_TYPE_ALC255:
2962 case ALC269_TYPE_ALC256:
2963 case ALC269_TYPE_ALC257:
2964 case ALC269_TYPE_ALC215:
2965 case ALC269_TYPE_ALC225:
2966 case ALC269_TYPE_ALC294:
2967 case ALC269_TYPE_ALC300:
2968 case ALC269_TYPE_ALC623:
2969 case ALC269_TYPE_ALC700:
2970 ssids = alc269_ssids;
2973 ssids = alc269_ssids;
2977 return alc_parse_auto_config(codec, alc269_ignore, ssids);
2980 static void alc269vb_toggle_power_output(struct hda_codec *codec, int power_up)
2982 alc_update_coef_idx(codec, 0x04, 1 << 11, power_up ? (1 << 11) : 0);
2985 static void alc269_shutup(struct hda_codec *codec)
2987 struct alc_spec *spec = codec->spec;
2989 if (spec->codec_variant == ALC269_TYPE_ALC269VB)
2990 alc269vb_toggle_power_output(codec, 0);
2991 if (spec->codec_variant == ALC269_TYPE_ALC269VB &&
2992 (alc_get_coef0(codec) & 0x00ff) == 0x018) {
2995 alc_shutup_pins(codec);
2998 static const struct coef_fw alc282_coefs[] = {
2999 WRITE_COEF(0x03, 0x0002), /* Power Down Control */
3000 UPDATE_COEF(0x05, 0xff3f, 0x0700), /* FIFO and filter clock */
3001 WRITE_COEF(0x07, 0x0200), /* DMIC control */
3002 UPDATE_COEF(0x06, 0x00f0, 0), /* Analog clock */
3003 UPDATE_COEF(0x08, 0xfffc, 0x0c2c), /* JD */
3004 WRITE_COEF(0x0a, 0xcccc), /* JD offset1 */
3005 WRITE_COEF(0x0b, 0xcccc), /* JD offset2 */
3006 WRITE_COEF(0x0e, 0x6e00), /* LDO1/2/3, DAC/ADC */
3007 UPDATE_COEF(0x0f, 0xf800, 0x1000), /* JD */
3008 UPDATE_COEF(0x10, 0xfc00, 0x0c00), /* Capless */
3009 WRITE_COEF(0x6f, 0x0), /* Class D test 4 */
3010 UPDATE_COEF(0x0c, 0xfe00, 0), /* IO power down directly */
3011 WRITE_COEF(0x34, 0xa0c0), /* ANC */
3012 UPDATE_COEF(0x16, 0x0008, 0), /* AGC MUX */
3013 UPDATE_COEF(0x1d, 0x00e0, 0), /* DAC simple content protection */
3014 UPDATE_COEF(0x1f, 0x00e0, 0), /* ADC simple content protection */
3015 WRITE_COEF(0x21, 0x8804), /* DAC ADC Zero Detection */
3016 WRITE_COEF(0x63, 0x2902), /* PLL */
3017 WRITE_COEF(0x68, 0xa080), /* capless control 2 */
3018 WRITE_COEF(0x69, 0x3400), /* capless control 3 */
3019 WRITE_COEF(0x6a, 0x2f3e), /* capless control 4 */
3020 WRITE_COEF(0x6b, 0x0), /* capless control 5 */
3021 UPDATE_COEF(0x6d, 0x0fff, 0x0900), /* class D test 2 */
3022 WRITE_COEF(0x6e, 0x110a), /* class D test 3 */
3023 UPDATE_COEF(0x70, 0x00f8, 0x00d8), /* class D test 5 */
3024 WRITE_COEF(0x71, 0x0014), /* class D test 6 */
3025 WRITE_COEF(0x72, 0xc2ba), /* classD OCP */
3026 UPDATE_COEF(0x77, 0x0f80, 0), /* classD pure DC test */
3027 WRITE_COEF(0x6c, 0xfc06), /* Class D amp control */
3031 static void alc282_restore_default_value(struct hda_codec *codec)
3033 alc_process_coef_fw(codec, alc282_coefs);
3036 static void alc282_init(struct hda_codec *codec)
3038 struct alc_spec *spec = codec->spec;
3039 hda_nid_t hp_pin = alc_get_hp_pin(spec);
3043 alc282_restore_default_value(codec);
3047 hp_pin_sense = snd_hda_jack_detect(codec, hp_pin);
3048 coef78 = alc_read_coef_idx(codec, 0x78);
3050 /* Index 0x78 Direct Drive HP AMP LPM Control 1 */
3051 /* Headphone capless set to high power mode */
3052 alc_write_coef_idx(codec, 0x78, 0x9004);
3057 snd_hda_codec_write(codec, hp_pin, 0,
3058 AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
3063 snd_hda_codec_write(codec, hp_pin, 0,
3064 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
3069 /* Headphone capless set to normal mode */
3070 alc_write_coef_idx(codec, 0x78, coef78);
3073 static void alc282_shutup(struct hda_codec *codec)
3075 struct alc_spec *spec = codec->spec;
3076 hda_nid_t hp_pin = alc_get_hp_pin(spec);
3081 alc269_shutup(codec);
3085 hp_pin_sense = snd_hda_jack_detect(codec, hp_pin);
3086 coef78 = alc_read_coef_idx(codec, 0x78);
3087 alc_write_coef_idx(codec, 0x78, 0x9004);
3092 snd_hda_codec_write(codec, hp_pin, 0,
3093 AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
3098 if (!spec->no_shutup_pins)
3099 snd_hda_codec_write(codec, hp_pin, 0,
3100 AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0);
3105 alc_auto_setup_eapd(codec, false);
3106 alc_shutup_pins(codec);
3107 alc_write_coef_idx(codec, 0x78, coef78);
3110 static const struct coef_fw alc283_coefs[] = {
3111 WRITE_COEF(0x03, 0x0002), /* Power Down Control */
3112 UPDATE_COEF(0x05, 0xff3f, 0x0700), /* FIFO and filter clock */
3113 WRITE_COEF(0x07, 0x0200), /* DMIC control */
3114 UPDATE_COEF(0x06, 0x00f0, 0), /* Analog clock */
3115 UPDATE_COEF(0x08, 0xfffc, 0x0c2c), /* JD */
3116 WRITE_COEF(0x0a, 0xcccc), /* JD offset1 */
3117 WRITE_COEF(0x0b, 0xcccc), /* JD offset2 */
3118 WRITE_COEF(0x0e, 0x6fc0), /* LDO1/2/3, DAC/ADC */
3119 UPDATE_COEF(0x0f, 0xf800, 0x1000), /* JD */
3120 UPDATE_COEF(0x10, 0xfc00, 0x0c00), /* Capless */
3121 WRITE_COEF(0x3a, 0x0), /* Class D test 4 */
3122 UPDATE_COEF(0x0c, 0xfe00, 0x0), /* IO power down directly */
3123 WRITE_COEF(0x22, 0xa0c0), /* ANC */
3124 UPDATE_COEFEX(0x53, 0x01, 0x000f, 0x0008), /* AGC MUX */
3125 UPDATE_COEF(0x1d, 0x00e0, 0), /* DAC simple content protection */
3126 UPDATE_COEF(0x1f, 0x00e0, 0), /* ADC simple content protection */
3127 WRITE_COEF(0x21, 0x8804), /* DAC ADC Zero Detection */
3128 WRITE_COEF(0x2e, 0x2902), /* PLL */
3129 WRITE_COEF(0x33, 0xa080), /* capless control 2 */
3130 WRITE_COEF(0x34, 0x3400), /* capless control 3 */
3131 WRITE_COEF(0x35, 0x2f3e), /* capless control 4 */
3132 WRITE_COEF(0x36, 0x0), /* capless control 5 */
3133 UPDATE_COEF(0x38, 0x0fff, 0x0900), /* class D test 2 */
3134 WRITE_COEF(0x39, 0x110a), /* class D test 3 */
3135 UPDATE_COEF(0x3b, 0x00f8, 0x00d8), /* class D test 5 */
3136 WRITE_COEF(0x3c, 0x0014), /* class D test 6 */
3137 WRITE_COEF(0x3d, 0xc2ba), /* classD OCP */
3138 UPDATE_COEF(0x42, 0x0f80, 0x0), /* classD pure DC test */
3139 WRITE_COEF(0x49, 0x0), /* test mode */
3140 UPDATE_COEF(0x40, 0xf800, 0x9800), /* Class D DC enable */
3141 UPDATE_COEF(0x42, 0xf000, 0x2000), /* DC offset */
3142 WRITE_COEF(0x37, 0xfc06), /* Class D amp control */
3143 UPDATE_COEF(0x1b, 0x8000, 0), /* HP JD control */
3147 static void alc283_restore_default_value(struct hda_codec *codec)
3149 alc_process_coef_fw(codec, alc283_coefs);
3152 static void alc283_init(struct hda_codec *codec)
3154 struct alc_spec *spec = codec->spec;
3155 hda_nid_t hp_pin = alc_get_hp_pin(spec);
3158 alc283_restore_default_value(codec);
3164 hp_pin_sense = snd_hda_jack_detect(codec, hp_pin);
3166 /* Index 0x43 Direct Drive HP AMP LPM Control 1 */
3167 /* Headphone capless set to high power mode */
3168 alc_write_coef_idx(codec, 0x43, 0x9004);
3170 snd_hda_codec_write(codec, hp_pin, 0,
3171 AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
3176 snd_hda_codec_write(codec, hp_pin, 0,
3177 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
3181 /* Index 0x46 Combo jack auto switch control 2 */
3182 /* 3k pull low control for Headset jack. */
3183 alc_update_coef_idx(codec, 0x46, 3 << 12, 0);
3184 /* Headphone capless set to normal mode */
3185 alc_write_coef_idx(codec, 0x43, 0x9614);
3188 static void alc283_shutup(struct hda_codec *codec)
3190 struct alc_spec *spec = codec->spec;
3191 hda_nid_t hp_pin = alc_get_hp_pin(spec);
3195 alc269_shutup(codec);
3199 hp_pin_sense = snd_hda_jack_detect(codec, hp_pin);
3201 alc_write_coef_idx(codec, 0x43, 0x9004);
3203 /*depop hp during suspend*/
3204 alc_write_coef_idx(codec, 0x06, 0x2100);
3206 snd_hda_codec_write(codec, hp_pin, 0,
3207 AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
3212 if (!spec->no_shutup_pins)
3213 snd_hda_codec_write(codec, hp_pin, 0,
3214 AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0);
3216 alc_update_coef_idx(codec, 0x46, 0, 3 << 12);
3220 alc_auto_setup_eapd(codec, false);
3221 alc_shutup_pins(codec);
3222 alc_write_coef_idx(codec, 0x43, 0x9614);
3225 static void alc256_init(struct hda_codec *codec)
3227 struct alc_spec *spec = codec->spec;
3228 hda_nid_t hp_pin = alc_get_hp_pin(spec);
3236 hp_pin_sense = snd_hda_jack_detect(codec, hp_pin);
3241 alc_update_coefex_idx(codec, 0x57, 0x04, 0x0007, 0x1); /* Low power */
3242 if (spec->ultra_low_power) {
3243 alc_update_coef_idx(codec, 0x03, 1<<1, 1<<1);
3244 alc_update_coef_idx(codec, 0x08, 3<<2, 3<<2);
3245 alc_update_coef_idx(codec, 0x08, 7<<4, 0);
3246 alc_update_coef_idx(codec, 0x3b, 1<<15, 0);
3247 alc_update_coef_idx(codec, 0x0e, 7<<6, 7<<6);
3251 snd_hda_codec_write(codec, hp_pin, 0,
3252 AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
3254 if (hp_pin_sense || spec->ultra_low_power)
3257 snd_hda_codec_write(codec, hp_pin, 0,
3258 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
3260 if (hp_pin_sense || spec->ultra_low_power)
3263 alc_update_coef_idx(codec, 0x46, 3 << 12, 0);
3264 alc_update_coefex_idx(codec, 0x57, 0x04, 0x0007, 0x4); /* Hight power */
3265 alc_update_coefex_idx(codec, 0x53, 0x02, 0x8000, 1 << 15); /* Clear bit */
3266 alc_update_coefex_idx(codec, 0x53, 0x02, 0x8000, 0 << 15);
3267 alc_update_coef_idx(codec, 0x36, 1 << 13, 1 << 5); /* Switch pcbeep path to Line in path*/
3270 static void alc256_shutup(struct hda_codec *codec)
3272 struct alc_spec *spec = codec->spec;
3273 hda_nid_t hp_pin = alc_get_hp_pin(spec);
3279 hp_pin_sense = snd_hda_jack_detect(codec, hp_pin);
3284 snd_hda_codec_write(codec, hp_pin, 0,
3285 AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
3287 if (hp_pin_sense || spec->ultra_low_power)
3290 /* 3k pull low control for Headset jack. */
3291 /* NOTE: call this before clearing the pin, otherwise codec stalls */
3292 alc_update_coef_idx(codec, 0x46, 0, 3 << 12);
3294 if (!spec->no_shutup_pins)
3295 snd_hda_codec_write(codec, hp_pin, 0,
3296 AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0);
3298 if (hp_pin_sense || spec->ultra_low_power)
3301 alc_auto_setup_eapd(codec, false);
3302 alc_shutup_pins(codec);
3303 if (spec->ultra_low_power) {
3305 alc_update_coef_idx(codec, 0x03, 1<<1, 0);
3306 alc_update_coef_idx(codec, 0x08, 7<<4, 7<<4);
3307 alc_update_coef_idx(codec, 0x08, 3<<2, 0);
3308 alc_update_coef_idx(codec, 0x3b, 1<<15, 1<<15);