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;
120 unsigned int done_hp_init:1;
121 unsigned int no_shutup_pins:1;
125 unsigned int pll_coef_idx, pll_coef_bit;
127 struct input_dev *kb_dev;
128 u8 alc_mute_keycode_map[1];
132 * COEF access helper functions
135 static int alc_read_coefex_idx(struct hda_codec *codec, hda_nid_t nid,
136 unsigned int coef_idx)
140 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_COEF_INDEX, coef_idx);
141 val = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_PROC_COEF, 0);
145 #define alc_read_coef_idx(codec, coef_idx) \
146 alc_read_coefex_idx(codec, 0x20, coef_idx)
148 static void alc_write_coefex_idx(struct hda_codec *codec, hda_nid_t nid,
149 unsigned int coef_idx, unsigned int coef_val)
151 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_COEF_INDEX, coef_idx);
152 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PROC_COEF, coef_val);
155 #define alc_write_coef_idx(codec, coef_idx, coef_val) \
156 alc_write_coefex_idx(codec, 0x20, coef_idx, coef_val)
158 static void alc_update_coefex_idx(struct hda_codec *codec, hda_nid_t nid,
159 unsigned int coef_idx, unsigned int mask,
160 unsigned int bits_set)
162 unsigned int val = alc_read_coefex_idx(codec, nid, coef_idx);
165 alc_write_coefex_idx(codec, nid, coef_idx,
166 (val & ~mask) | bits_set);
169 #define alc_update_coef_idx(codec, coef_idx, mask, bits_set) \
170 alc_update_coefex_idx(codec, 0x20, coef_idx, mask, bits_set)
172 /* a special bypass for COEF 0; read the cached value at the second time */
173 static unsigned int alc_get_coef0(struct hda_codec *codec)
175 struct alc_spec *spec = codec->spec;
178 spec->coef0 = alc_read_coef_idx(codec, 0);
182 /* coef writes/updates batch */
190 #define UPDATE_COEFEX(_nid, _idx, _mask, _val) \
191 { .nid = (_nid), .idx = (_idx), .mask = (_mask), .val = (_val) }
192 #define WRITE_COEFEX(_nid, _idx, _val) UPDATE_COEFEX(_nid, _idx, -1, _val)
193 #define WRITE_COEF(_idx, _val) WRITE_COEFEX(0x20, _idx, _val)
194 #define UPDATE_COEF(_idx, _mask, _val) UPDATE_COEFEX(0x20, _idx, _mask, _val)
196 static void alc_process_coef_fw(struct hda_codec *codec,
197 const struct coef_fw *fw)
199 for (; fw->nid; fw++) {
200 if (fw->mask == (unsigned short)-1)
201 alc_write_coefex_idx(codec, fw->nid, fw->idx, fw->val);
203 alc_update_coefex_idx(codec, fw->nid, fw->idx,
209 * GPIO setup tables, used in initialization
212 /* Enable GPIO mask and set output */
213 static void alc_setup_gpio(struct hda_codec *codec, unsigned int mask)
215 struct alc_spec *spec = codec->spec;
217 spec->gpio_mask |= mask;
218 spec->gpio_dir |= mask;
219 spec->gpio_data |= mask;
222 static void alc_write_gpio_data(struct hda_codec *codec)
224 struct alc_spec *spec = codec->spec;
226 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA,
230 static void alc_update_gpio_data(struct hda_codec *codec, unsigned int mask,
233 struct alc_spec *spec = codec->spec;
234 unsigned int oldval = spec->gpio_data;
237 spec->gpio_data |= mask;
239 spec->gpio_data &= ~mask;
240 if (oldval != spec->gpio_data)
241 alc_write_gpio_data(codec);
244 static void alc_write_gpio(struct hda_codec *codec)
246 struct alc_spec *spec = codec->spec;
248 if (!spec->gpio_mask)
251 snd_hda_codec_write(codec, codec->core.afg, 0,
252 AC_VERB_SET_GPIO_MASK, spec->gpio_mask);
253 snd_hda_codec_write(codec, codec->core.afg, 0,
254 AC_VERB_SET_GPIO_DIRECTION, spec->gpio_dir);
255 if (spec->gpio_write_delay)
257 alc_write_gpio_data(codec);
260 static void alc_fixup_gpio(struct hda_codec *codec, int action,
263 if (action == HDA_FIXUP_ACT_PRE_PROBE)
264 alc_setup_gpio(codec, mask);
267 static void alc_fixup_gpio1(struct hda_codec *codec,
268 const struct hda_fixup *fix, int action)
270 alc_fixup_gpio(codec, action, 0x01);
273 static void alc_fixup_gpio2(struct hda_codec *codec,
274 const struct hda_fixup *fix, int action)
276 alc_fixup_gpio(codec, action, 0x02);
279 static void alc_fixup_gpio3(struct hda_codec *codec,
280 const struct hda_fixup *fix, int action)
282 alc_fixup_gpio(codec, action, 0x03);
285 static void alc_fixup_gpio4(struct hda_codec *codec,
286 const struct hda_fixup *fix, int action)
288 alc_fixup_gpio(codec, action, 0x04);
292 * Fix hardware PLL issue
293 * On some codecs, the analog PLL gating control must be off while
294 * the default value is 1.
296 static void alc_fix_pll(struct hda_codec *codec)
298 struct alc_spec *spec = codec->spec;
301 alc_update_coefex_idx(codec, spec->pll_nid, spec->pll_coef_idx,
302 1 << spec->pll_coef_bit, 0);
305 static void alc_fix_pll_init(struct hda_codec *codec, hda_nid_t nid,
306 unsigned int coef_idx, unsigned int coef_bit)
308 struct alc_spec *spec = codec->spec;
310 spec->pll_coef_idx = coef_idx;
311 spec->pll_coef_bit = coef_bit;
315 /* update the master volume per volume-knob's unsol event */
316 static void alc_update_knob_master(struct hda_codec *codec,
317 struct hda_jack_callback *jack)
320 struct snd_kcontrol *kctl;
321 struct snd_ctl_elem_value *uctl;
323 kctl = snd_hda_find_mixer_ctl(codec, "Master Playback Volume");
326 uctl = kzalloc(sizeof(*uctl), GFP_KERNEL);
329 val = snd_hda_codec_read(codec, jack->nid, 0,
330 AC_VERB_GET_VOLUME_KNOB_CONTROL, 0);
331 val &= HDA_AMP_VOLMASK;
332 uctl->value.integer.value[0] = val;
333 uctl->value.integer.value[1] = val;
334 kctl->put(kctl, uctl);
338 static void alc880_unsol_event(struct hda_codec *codec, unsigned int res)
340 /* For some reason, the res given from ALC880 is broken.
341 Here we adjust it properly. */
342 snd_hda_jack_unsol_event(codec, res >> 2);
345 /* Change EAPD to verb control */
346 static void alc_fill_eapd_coef(struct hda_codec *codec)
350 coef = alc_get_coef0(codec);
352 switch (codec->core.vendor_id) {
354 alc_update_coef_idx(codec, 0x7, 0, 1<<5);
358 alc_update_coef_idx(codec, 0x7, 0, 1<<13);
361 if ((coef & 0x00f0) == 0x0010)
362 alc_update_coef_idx(codec, 0xd, 0, 1<<14);
363 if ((coef & 0x00f0) == 0x0020)
364 alc_update_coef_idx(codec, 0x4, 1<<15, 0);
365 if ((coef & 0x00f0) == 0x0030)
366 alc_update_coef_idx(codec, 0x10, 1<<9, 0);
372 alc_update_coef_idx(codec, 0x4, 1<<15, 0);
377 alc_update_coef_idx(codec, 0x67, 0xf000, 0x3000);
394 alc_update_coef_idx(codec, 0x10, 1<<9, 0);
397 alc_update_coef_idx(codec, 0xe, 0, 1<<0);
400 alc_update_coef_idx(codec, 0xa, 1<<13, 0);
408 alc_update_coef_idx(codec, 0x10, 1<<15, 0);
411 if ((coef & 0x00f0) == 0x0030)
412 alc_update_coef_idx(codec, 0x4, 1<<10, 0); /* EAPD Ctrl */
421 alc_update_coef_idx(codec, 0xd, 0, 1<<14); /* EAPD Ctrl */
424 alc_update_coef_idx(codec, 0x7, 3<<13, 0);
427 alc_update_coef_idx(codec, 0x4, 1<<10, 0);
430 if ((coef & 0x00f0) == 0x0020 || (coef & 0x00f0) == 0x0030)
431 alc_update_coef_idx(codec, 0x7, 1<<5, 0);
434 alc_update_coef_idx(codec, 0x7, 1<<5, 0);
440 alc_update_coef_idx(codec, 0x7, 1<<1, 0);
445 /* additional initialization for ALC888 variants */
446 static void alc888_coef_init(struct hda_codec *codec)
448 switch (alc_get_coef0(codec) & 0x00f0) {
453 alc_update_coef_idx(codec, 7, 0, 0x2030); /* Turn EAPD to High */
458 /* turn on/off EAPD control (only if available) */
459 static void set_eapd(struct hda_codec *codec, hda_nid_t nid, int on)
461 if (get_wcaps_type(get_wcaps(codec, nid)) != AC_WID_PIN)
463 if (snd_hda_query_pin_caps(codec, nid) & AC_PINCAP_EAPD)
464 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
468 /* turn on/off EAPD controls of the codec */
469 static void alc_auto_setup_eapd(struct hda_codec *codec, bool on)
471 /* We currently only handle front, HP */
472 static hda_nid_t pins[] = {
473 0x0f, 0x10, 0x14, 0x15, 0x17, 0
476 for (p = pins; *p; p++)
477 set_eapd(codec, *p, on);
480 static void alc_shutup_pins(struct hda_codec *codec)
482 struct alc_spec *spec = codec->spec;
484 if (!spec->no_shutup_pins)
485 snd_hda_shutup_pins(codec);
488 /* generic shutup callback;
489 * just turning off EAPD and a little pause for avoiding pop-noise
491 static void alc_eapd_shutup(struct hda_codec *codec)
493 struct alc_spec *spec = codec->spec;
495 alc_auto_setup_eapd(codec, false);
496 if (!spec->no_depop_delay)
498 alc_shutup_pins(codec);
501 /* generic EAPD initialization */
502 static void alc_auto_init_amp(struct hda_codec *codec, int type)
504 alc_fill_eapd_coef(codec);
505 alc_auto_setup_eapd(codec, true);
506 alc_write_gpio(codec);
508 case ALC_INIT_DEFAULT:
509 switch (codec->core.vendor_id) {
511 alc_update_coefex_idx(codec, 0x1a, 7, 0, 0x2010);
517 alc_update_coef_idx(codec, 7, 0, 0x2030);
520 alc888_coef_init(codec);
527 /* get a primary headphone pin if available */
528 static hda_nid_t alc_get_hp_pin(struct alc_spec *spec)
530 if (spec->gen.autocfg.hp_pins[0])
531 return spec->gen.autocfg.hp_pins[0];
532 if (spec->gen.autocfg.line_out_type == AC_JACK_HP_OUT)
533 return spec->gen.autocfg.line_out_pins[0];
538 * Realtek SSID verification
541 /* Could be any non-zero and even value. When used as fixup, tells
542 * the driver to ignore any present sku defines.
544 #define ALC_FIXUP_SKU_IGNORE (2)
546 static void alc_fixup_sku_ignore(struct hda_codec *codec,
547 const struct hda_fixup *fix, int action)
549 struct alc_spec *spec = codec->spec;
550 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
551 spec->cdefine.fixup = 1;
552 spec->cdefine.sku_cfg = ALC_FIXUP_SKU_IGNORE;
556 static void alc_fixup_no_depop_delay(struct hda_codec *codec,
557 const struct hda_fixup *fix, int action)
559 struct alc_spec *spec = codec->spec;
561 if (action == HDA_FIXUP_ACT_PROBE) {
562 spec->no_depop_delay = 1;
563 codec->depop_delay = 0;
567 static int alc_auto_parse_customize_define(struct hda_codec *codec)
569 unsigned int ass, tmp, i;
571 struct alc_spec *spec = codec->spec;
573 spec->cdefine.enable_pcbeep = 1; /* assume always enabled */
575 if (spec->cdefine.fixup) {
576 ass = spec->cdefine.sku_cfg;
577 if (ass == ALC_FIXUP_SKU_IGNORE)
582 if (!codec->bus->pci)
584 ass = codec->core.subsystem_id & 0xffff;
585 if (ass != codec->bus->pci->subsystem_device && (ass & 1))
589 if (codec->core.vendor_id == 0x10ec0260)
591 ass = snd_hda_codec_get_pincfg(codec, nid);
594 codec_info(codec, "%s: SKU not ready 0x%08x\n",
595 codec->core.chip_name, ass);
601 for (i = 1; i < 16; i++) {
605 if (((ass >> 16) & 0xf) != tmp)
608 spec->cdefine.port_connectivity = ass >> 30;
609 spec->cdefine.enable_pcbeep = (ass & 0x100000) >> 20;
610 spec->cdefine.check_sum = (ass >> 16) & 0xf;
611 spec->cdefine.customization = ass >> 8;
613 spec->cdefine.sku_cfg = ass;
614 spec->cdefine.external_amp = (ass & 0x38) >> 3;
615 spec->cdefine.platform_type = (ass & 0x4) >> 2;
616 spec->cdefine.swap = (ass & 0x2) >> 1;
617 spec->cdefine.override = ass & 0x1;
619 codec_dbg(codec, "SKU: Nid=0x%x sku_cfg=0x%08x\n",
620 nid, spec->cdefine.sku_cfg);
621 codec_dbg(codec, "SKU: port_connectivity=0x%x\n",
622 spec->cdefine.port_connectivity);
623 codec_dbg(codec, "SKU: enable_pcbeep=0x%x\n", spec->cdefine.enable_pcbeep);
624 codec_dbg(codec, "SKU: check_sum=0x%08x\n", spec->cdefine.check_sum);
625 codec_dbg(codec, "SKU: customization=0x%08x\n", spec->cdefine.customization);
626 codec_dbg(codec, "SKU: external_amp=0x%x\n", spec->cdefine.external_amp);
627 codec_dbg(codec, "SKU: platform_type=0x%x\n", spec->cdefine.platform_type);
628 codec_dbg(codec, "SKU: swap=0x%x\n", spec->cdefine.swap);
629 codec_dbg(codec, "SKU: override=0x%x\n", spec->cdefine.override);
634 /* return the position of NID in the list, or -1 if not found */
635 static int find_idx_in_nid_list(hda_nid_t nid, const hda_nid_t *list, int nums)
638 for (i = 0; i < nums; i++)
643 /* return true if the given NID is found in the list */
644 static bool found_in_nid_list(hda_nid_t nid, const hda_nid_t *list, int nums)
646 return find_idx_in_nid_list(nid, list, nums) >= 0;
649 /* check subsystem ID and set up device-specific initialization;
650 * return 1 if initialized, 0 if invalid SSID
652 /* 32-bit subsystem ID for BIOS loading in HD Audio codec.
653 * 31 ~ 16 : Manufacture ID
655 * 7 ~ 0 : Assembly ID
656 * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36
658 static int alc_subsystem_id(struct hda_codec *codec, const hda_nid_t *ports)
660 unsigned int ass, tmp, i;
662 struct alc_spec *spec = codec->spec;
664 if (spec->cdefine.fixup) {
665 ass = spec->cdefine.sku_cfg;
666 if (ass == ALC_FIXUP_SKU_IGNORE)
671 ass = codec->core.subsystem_id & 0xffff;
672 if (codec->bus->pci &&
673 ass != codec->bus->pci->subsystem_device && (ass & 1))
676 /* invalid SSID, check the special NID pin defcfg instead */
678 * 31~30 : port connectivity
681 * 19~16 : Check sum (15:1)
686 if (codec->core.vendor_id == 0x10ec0260)
688 ass = snd_hda_codec_get_pincfg(codec, nid);
690 "realtek: No valid SSID, checking pincfg 0x%08x for NID 0x%x\n",
694 if ((ass >> 30) != 1) /* no physical connection */
699 for (i = 1; i < 16; i++) {
703 if (((ass >> 16) & 0xf) != tmp)
706 codec_dbg(codec, "realtek: Enabling init ASM_ID=0x%04x CODEC_ID=%08x\n",
707 ass & 0xffff, codec->core.vendor_id);
711 * 2 : 0 --> Desktop, 1 --> Laptop
712 * 3~5 : External Amplifier control
715 tmp = (ass & 0x38) >> 3; /* external Amp control */
716 if (spec->init_amp == ALC_INIT_UNDEFINED) {
719 alc_setup_gpio(codec, 0x01);
722 alc_setup_gpio(codec, 0x02);
725 alc_setup_gpio(codec, 0x03);
729 spec->init_amp = ALC_INIT_DEFAULT;
734 /* is laptop or Desktop and enable the function "Mute internal speaker
735 * when the external headphone out jack is plugged"
740 * 10~8 : Jack location
741 * 12~11: Headphone out -> 00: PortA, 01: PortE, 02: PortD, 03: Resvered
743 * 15 : 1 --> enable the function "Mute internal speaker
744 * when the external headphone out jack is plugged"
746 if (!alc_get_hp_pin(spec)) {
748 tmp = (ass >> 11) & 0x3; /* HP to chassis */
750 if (found_in_nid_list(nid, spec->gen.autocfg.line_out_pins,
751 spec->gen.autocfg.line_outs))
753 spec->gen.autocfg.hp_pins[0] = nid;
758 /* Check the validity of ALC subsystem-id
759 * ports contains an array of 4 pin NIDs for port-A, E, D and I */
760 static void alc_ssid_check(struct hda_codec *codec, const hda_nid_t *ports)
762 if (!alc_subsystem_id(codec, ports)) {
763 struct alc_spec *spec = codec->spec;
765 "realtek: Enable default setup for auto mode as fallback\n");
766 spec->init_amp = ALC_INIT_DEFAULT;
773 static void alc_fixup_inv_dmic(struct hda_codec *codec,
774 const struct hda_fixup *fix, int action)
776 struct alc_spec *spec = codec->spec;
778 spec->gen.inv_dmic_split = 1;
782 static int alc_build_controls(struct hda_codec *codec)
786 err = snd_hda_gen_build_controls(codec);
790 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_BUILD);
799 static int alc_init(struct hda_codec *codec)
801 struct alc_spec *spec = codec->spec;
804 spec->init_hook(codec);
807 alc_auto_init_amp(codec, spec->init_amp);
809 snd_hda_gen_init(codec);
811 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_INIT);
816 static inline void alc_shutup(struct hda_codec *codec)
818 struct alc_spec *spec = codec->spec;
820 if (!snd_hda_get_bool_hint(codec, "shutup"))
821 return; /* disabled explicitly by hints */
823 if (spec && spec->shutup)
826 alc_shutup_pins(codec);
829 static void alc_reboot_notify(struct hda_codec *codec)
831 struct alc_spec *spec = codec->spec;
833 if (spec && spec->reboot_notify)
834 spec->reboot_notify(codec);
839 /* power down codec to D3 at reboot/shutdown; set as reboot_notify ops */
840 static void alc_d3_at_reboot(struct hda_codec *codec)
842 snd_hda_codec_set_power_to_all(codec, codec->core.afg, AC_PWRST_D3);
843 snd_hda_codec_write(codec, codec->core.afg, 0,
844 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
848 #define alc_free snd_hda_gen_free
851 static void alc_power_eapd(struct hda_codec *codec)
853 alc_auto_setup_eapd(codec, false);
856 static int alc_suspend(struct hda_codec *codec)
858 struct alc_spec *spec = codec->spec;
860 if (spec && spec->power_hook)
861 spec->power_hook(codec);
867 static int alc_resume(struct hda_codec *codec)
869 struct alc_spec *spec = codec->spec;
871 if (!spec->no_depop_delay)
872 msleep(150); /* to avoid pop noise */
873 codec->patch_ops.init(codec);
874 regcache_sync(codec->core.regmap);
875 hda_call_check_power_status(codec, 0x01);
882 static const struct hda_codec_ops alc_patch_ops = {
883 .build_controls = alc_build_controls,
884 .build_pcms = snd_hda_gen_build_pcms,
887 .unsol_event = snd_hda_jack_unsol_event,
889 .resume = alc_resume,
890 .suspend = alc_suspend,
891 .check_power_status = snd_hda_gen_check_power_status,
893 .reboot_notify = alc_reboot_notify,
897 #define alc_codec_rename(codec, name) snd_hda_codec_set_name(codec, name)
900 * Rename codecs appropriately from COEF value or subvendor id
902 struct alc_codec_rename_table {
903 unsigned int vendor_id;
904 unsigned short coef_mask;
905 unsigned short coef_bits;
909 struct alc_codec_rename_pci_table {
910 unsigned int codec_vendor_id;
911 unsigned short pci_subvendor;
912 unsigned short pci_subdevice;
916 static struct alc_codec_rename_table rename_tbl[] = {
917 { 0x10ec0221, 0xf00f, 0x1003, "ALC231" },
918 { 0x10ec0269, 0xfff0, 0x3010, "ALC277" },
919 { 0x10ec0269, 0xf0f0, 0x2010, "ALC259" },
920 { 0x10ec0269, 0xf0f0, 0x3010, "ALC258" },
921 { 0x10ec0269, 0x00f0, 0x0010, "ALC269VB" },
922 { 0x10ec0269, 0xffff, 0xa023, "ALC259" },
923 { 0x10ec0269, 0xffff, 0x6023, "ALC281X" },
924 { 0x10ec0269, 0x00f0, 0x0020, "ALC269VC" },
925 { 0x10ec0269, 0x00f0, 0x0030, "ALC269VD" },
926 { 0x10ec0662, 0xffff, 0x4020, "ALC656" },
927 { 0x10ec0887, 0x00f0, 0x0030, "ALC887-VD" },
928 { 0x10ec0888, 0x00f0, 0x0030, "ALC888-VD" },
929 { 0x10ec0888, 0xf0f0, 0x3020, "ALC886" },
930 { 0x10ec0899, 0x2000, 0x2000, "ALC899" },
931 { 0x10ec0892, 0xffff, 0x8020, "ALC661" },
932 { 0x10ec0892, 0xffff, 0x8011, "ALC661" },
933 { 0x10ec0892, 0xffff, 0x4011, "ALC656" },
937 static struct alc_codec_rename_pci_table rename_pci_tbl[] = {
938 { 0x10ec0280, 0x1028, 0, "ALC3220" },
939 { 0x10ec0282, 0x1028, 0, "ALC3221" },
940 { 0x10ec0283, 0x1028, 0, "ALC3223" },
941 { 0x10ec0288, 0x1028, 0, "ALC3263" },
942 { 0x10ec0292, 0x1028, 0, "ALC3226" },
943 { 0x10ec0293, 0x1028, 0, "ALC3235" },
944 { 0x10ec0255, 0x1028, 0, "ALC3234" },
945 { 0x10ec0668, 0x1028, 0, "ALC3661" },
946 { 0x10ec0275, 0x1028, 0, "ALC3260" },
947 { 0x10ec0899, 0x1028, 0, "ALC3861" },
948 { 0x10ec0298, 0x1028, 0, "ALC3266" },
949 { 0x10ec0236, 0x1028, 0, "ALC3204" },
950 { 0x10ec0256, 0x1028, 0, "ALC3246" },
951 { 0x10ec0225, 0x1028, 0, "ALC3253" },
952 { 0x10ec0295, 0x1028, 0, "ALC3254" },
953 { 0x10ec0299, 0x1028, 0, "ALC3271" },
954 { 0x10ec0670, 0x1025, 0, "ALC669X" },
955 { 0x10ec0676, 0x1025, 0, "ALC679X" },
956 { 0x10ec0282, 0x1043, 0, "ALC3229" },
957 { 0x10ec0233, 0x1043, 0, "ALC3236" },
958 { 0x10ec0280, 0x103c, 0, "ALC3228" },
959 { 0x10ec0282, 0x103c, 0, "ALC3227" },
960 { 0x10ec0286, 0x103c, 0, "ALC3242" },
961 { 0x10ec0290, 0x103c, 0, "ALC3241" },
962 { 0x10ec0668, 0x103c, 0, "ALC3662" },
963 { 0x10ec0283, 0x17aa, 0, "ALC3239" },
964 { 0x10ec0292, 0x17aa, 0, "ALC3232" },
968 static int alc_codec_rename_from_preset(struct hda_codec *codec)
970 const struct alc_codec_rename_table *p;
971 const struct alc_codec_rename_pci_table *q;
973 for (p = rename_tbl; p->vendor_id; p++) {
974 if (p->vendor_id != codec->core.vendor_id)
976 if ((alc_get_coef0(codec) & p->coef_mask) == p->coef_bits)
977 return alc_codec_rename(codec, p->name);
980 if (!codec->bus->pci)
982 for (q = rename_pci_tbl; q->codec_vendor_id; q++) {
983 if (q->codec_vendor_id != codec->core.vendor_id)
985 if (q->pci_subvendor != codec->bus->pci->subsystem_vendor)
987 if (!q->pci_subdevice ||
988 q->pci_subdevice == codec->bus->pci->subsystem_device)
989 return alc_codec_rename(codec, q->name);
997 * Digital-beep handlers
999 #ifdef CONFIG_SND_HDA_INPUT_BEEP
1001 /* additional beep mixers; private_value will be overwritten */
1002 static const struct snd_kcontrol_new alc_beep_mixer[] = {
1003 HDA_CODEC_VOLUME("Beep Playback Volume", 0, 0, HDA_INPUT),
1004 HDA_CODEC_MUTE_BEEP("Beep Playback Switch", 0, 0, HDA_INPUT),
1007 /* set up and create beep controls */
1008 static int set_beep_amp(struct alc_spec *spec, hda_nid_t nid,
1011 struct snd_kcontrol_new *knew;
1012 unsigned int beep_amp = HDA_COMPOSE_AMP_VAL(nid, 3, idx, dir);
1015 for (i = 0; i < ARRAY_SIZE(alc_beep_mixer); i++) {
1016 knew = snd_hda_gen_add_kctl(&spec->gen, NULL,
1017 &alc_beep_mixer[i]);
1020 knew->private_value = beep_amp;
1025 static const struct snd_pci_quirk beep_white_list[] = {
1026 SND_PCI_QUIRK(0x1043, 0x103c, "ASUS", 1),
1027 SND_PCI_QUIRK(0x1043, 0x115d, "ASUS", 1),
1028 SND_PCI_QUIRK(0x1043, 0x829f, "ASUS", 1),
1029 SND_PCI_QUIRK(0x1043, 0x8376, "EeePC", 1),
1030 SND_PCI_QUIRK(0x1043, 0x83ce, "EeePC", 1),
1031 SND_PCI_QUIRK(0x1043, 0x831a, "EeePC", 1),
1032 SND_PCI_QUIRK(0x1043, 0x834a, "EeePC", 1),
1033 SND_PCI_QUIRK(0x1458, 0xa002, "GA-MA790X", 1),
1034 SND_PCI_QUIRK(0x8086, 0xd613, "Intel", 1),
1038 static inline int has_cdefine_beep(struct hda_codec *codec)
1040 struct alc_spec *spec = codec->spec;
1041 const struct snd_pci_quirk *q;
1042 q = snd_pci_quirk_lookup(codec->bus->pci, beep_white_list);
1045 return spec->cdefine.enable_pcbeep;
1048 #define set_beep_amp(spec, nid, idx, dir) 0
1049 #define has_cdefine_beep(codec) 0
1052 /* parse the BIOS configuration and set up the alc_spec */
1053 /* return 1 if successful, 0 if the proper config is not found,
1054 * or a negative error code
1056 static int alc_parse_auto_config(struct hda_codec *codec,
1057 const hda_nid_t *ignore_nids,
1058 const hda_nid_t *ssid_nids)
1060 struct alc_spec *spec = codec->spec;
1061 struct auto_pin_cfg *cfg = &spec->gen.autocfg;
1064 err = snd_hda_parse_pin_defcfg(codec, cfg, ignore_nids,
1070 alc_ssid_check(codec, ssid_nids);
1072 err = snd_hda_gen_parse_auto_config(codec, cfg);
1079 /* common preparation job for alc_spec */
1080 static int alc_alloc_spec(struct hda_codec *codec, hda_nid_t mixer_nid)
1082 struct alc_spec *spec = kzalloc(sizeof(*spec), GFP_KERNEL);
1088 snd_hda_gen_spec_init(&spec->gen);
1089 spec->gen.mixer_nid = mixer_nid;
1090 spec->gen.own_eapd_ctl = 1;
1091 codec->single_adc_amp = 1;
1092 /* FIXME: do we need this for all Realtek codec models? */
1093 codec->spdif_status_reset = 1;
1094 codec->patch_ops = alc_patch_ops;
1096 err = alc_codec_rename_from_preset(codec);
1104 static int alc880_parse_auto_config(struct hda_codec *codec)
1106 static const hda_nid_t alc880_ignore[] = { 0x1d, 0 };
1107 static const hda_nid_t alc880_ssids[] = { 0x15, 0x1b, 0x14, 0 };
1108 return alc_parse_auto_config(codec, alc880_ignore, alc880_ssids);
1117 ALC880_FIXUP_MEDION_RIM,
1119 ALC880_FIXUP_LG_LW25,
1121 ALC880_FIXUP_EAPD_COEF,
1122 ALC880_FIXUP_TCL_S700,
1123 ALC880_FIXUP_VOL_KNOB,
1124 ALC880_FIXUP_FUJITSU,
1126 ALC880_FIXUP_UNIWILL,
1127 ALC880_FIXUP_UNIWILL_DIG,
1129 ALC880_FIXUP_ASUS_W5A,
1130 ALC880_FIXUP_3ST_BASE,
1132 ALC880_FIXUP_3ST_DIG,
1133 ALC880_FIXUP_5ST_BASE,
1135 ALC880_FIXUP_5ST_DIG,
1136 ALC880_FIXUP_6ST_BASE,
1138 ALC880_FIXUP_6ST_DIG,
1139 ALC880_FIXUP_6ST_AUTOMUTE,
1142 /* enable the volume-knob widget support on NID 0x21 */
1143 static void alc880_fixup_vol_knob(struct hda_codec *codec,
1144 const struct hda_fixup *fix, int action)
1146 if (action == HDA_FIXUP_ACT_PROBE)
1147 snd_hda_jack_detect_enable_callback(codec, 0x21,
1148 alc_update_knob_master);
1151 static const struct hda_fixup alc880_fixups[] = {
1152 [ALC880_FIXUP_GPIO1] = {
1153 .type = HDA_FIXUP_FUNC,
1154 .v.func = alc_fixup_gpio1,
1156 [ALC880_FIXUP_GPIO2] = {
1157 .type = HDA_FIXUP_FUNC,
1158 .v.func = alc_fixup_gpio2,
1160 [ALC880_FIXUP_MEDION_RIM] = {
1161 .type = HDA_FIXUP_VERBS,
1162 .v.verbs = (const struct hda_verb[]) {
1163 { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
1164 { 0x20, AC_VERB_SET_PROC_COEF, 0x3060 },
1168 .chain_id = ALC880_FIXUP_GPIO2,
1170 [ALC880_FIXUP_LG] = {
1171 .type = HDA_FIXUP_PINS,
1172 .v.pins = (const struct hda_pintbl[]) {
1173 /* disable bogus unused pins */
1174 { 0x16, 0x411111f0 },
1175 { 0x18, 0x411111f0 },
1176 { 0x1a, 0x411111f0 },
1180 [ALC880_FIXUP_LG_LW25] = {
1181 .type = HDA_FIXUP_PINS,
1182 .v.pins = (const struct hda_pintbl[]) {
1183 { 0x1a, 0x0181344f }, /* line-in */
1184 { 0x1b, 0x0321403f }, /* headphone */
1188 [ALC880_FIXUP_W810] = {
1189 .type = HDA_FIXUP_PINS,
1190 .v.pins = (const struct hda_pintbl[]) {
1191 /* disable bogus unused pins */
1192 { 0x17, 0x411111f0 },
1196 .chain_id = ALC880_FIXUP_GPIO2,
1198 [ALC880_FIXUP_EAPD_COEF] = {
1199 .type = HDA_FIXUP_VERBS,
1200 .v.verbs = (const struct hda_verb[]) {
1201 /* change to EAPD mode */
1202 { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
1203 { 0x20, AC_VERB_SET_PROC_COEF, 0x3060 },
1207 [ALC880_FIXUP_TCL_S700] = {
1208 .type = HDA_FIXUP_VERBS,
1209 .v.verbs = (const struct hda_verb[]) {
1210 /* change to EAPD mode */
1211 { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
1212 { 0x20, AC_VERB_SET_PROC_COEF, 0x3070 },
1216 .chain_id = ALC880_FIXUP_GPIO2,
1218 [ALC880_FIXUP_VOL_KNOB] = {
1219 .type = HDA_FIXUP_FUNC,
1220 .v.func = alc880_fixup_vol_knob,
1222 [ALC880_FIXUP_FUJITSU] = {
1223 /* override all pins as BIOS on old Amilo is broken */
1224 .type = HDA_FIXUP_PINS,
1225 .v.pins = (const struct hda_pintbl[]) {
1226 { 0x14, 0x0121401f }, /* HP */
1227 { 0x15, 0x99030120 }, /* speaker */
1228 { 0x16, 0x99030130 }, /* bass speaker */
1229 { 0x17, 0x411111f0 }, /* N/A */
1230 { 0x18, 0x411111f0 }, /* N/A */
1231 { 0x19, 0x01a19950 }, /* mic-in */
1232 { 0x1a, 0x411111f0 }, /* N/A */
1233 { 0x1b, 0x411111f0 }, /* N/A */
1234 { 0x1c, 0x411111f0 }, /* N/A */
1235 { 0x1d, 0x411111f0 }, /* N/A */
1236 { 0x1e, 0x01454140 }, /* SPDIF out */
1240 .chain_id = ALC880_FIXUP_VOL_KNOB,
1242 [ALC880_FIXUP_F1734] = {
1243 /* almost compatible with FUJITSU, but no bass and SPDIF */
1244 .type = HDA_FIXUP_PINS,
1245 .v.pins = (const struct hda_pintbl[]) {
1246 { 0x14, 0x0121401f }, /* HP */
1247 { 0x15, 0x99030120 }, /* speaker */
1248 { 0x16, 0x411111f0 }, /* N/A */
1249 { 0x17, 0x411111f0 }, /* N/A */
1250 { 0x18, 0x411111f0 }, /* N/A */
1251 { 0x19, 0x01a19950 }, /* mic-in */
1252 { 0x1a, 0x411111f0 }, /* N/A */
1253 { 0x1b, 0x411111f0 }, /* N/A */
1254 { 0x1c, 0x411111f0 }, /* N/A */
1255 { 0x1d, 0x411111f0 }, /* N/A */
1256 { 0x1e, 0x411111f0 }, /* N/A */
1260 .chain_id = ALC880_FIXUP_VOL_KNOB,
1262 [ALC880_FIXUP_UNIWILL] = {
1263 /* need to fix HP and speaker pins to be parsed correctly */
1264 .type = HDA_FIXUP_PINS,
1265 .v.pins = (const struct hda_pintbl[]) {
1266 { 0x14, 0x0121411f }, /* HP */
1267 { 0x15, 0x99030120 }, /* speaker */
1268 { 0x16, 0x99030130 }, /* bass speaker */
1272 [ALC880_FIXUP_UNIWILL_DIG] = {
1273 .type = HDA_FIXUP_PINS,
1274 .v.pins = (const struct hda_pintbl[]) {
1275 /* disable bogus unused pins */
1276 { 0x17, 0x411111f0 },
1277 { 0x19, 0x411111f0 },
1278 { 0x1b, 0x411111f0 },
1279 { 0x1f, 0x411111f0 },
1283 [ALC880_FIXUP_Z71V] = {
1284 .type = HDA_FIXUP_PINS,
1285 .v.pins = (const struct hda_pintbl[]) {
1286 /* set up the whole pins as BIOS is utterly broken */
1287 { 0x14, 0x99030120 }, /* speaker */
1288 { 0x15, 0x0121411f }, /* HP */
1289 { 0x16, 0x411111f0 }, /* N/A */
1290 { 0x17, 0x411111f0 }, /* N/A */
1291 { 0x18, 0x01a19950 }, /* mic-in */
1292 { 0x19, 0x411111f0 }, /* N/A */
1293 { 0x1a, 0x01813031 }, /* line-in */
1294 { 0x1b, 0x411111f0 }, /* N/A */
1295 { 0x1c, 0x411111f0 }, /* N/A */
1296 { 0x1d, 0x411111f0 }, /* N/A */
1297 { 0x1e, 0x0144111e }, /* SPDIF */
1301 [ALC880_FIXUP_ASUS_W5A] = {
1302 .type = HDA_FIXUP_PINS,
1303 .v.pins = (const struct hda_pintbl[]) {
1304 /* set up the whole pins as BIOS is utterly broken */
1305 { 0x14, 0x0121411f }, /* HP */
1306 { 0x15, 0x411111f0 }, /* N/A */
1307 { 0x16, 0x411111f0 }, /* N/A */
1308 { 0x17, 0x411111f0 }, /* N/A */
1309 { 0x18, 0x90a60160 }, /* mic */
1310 { 0x19, 0x411111f0 }, /* N/A */
1311 { 0x1a, 0x411111f0 }, /* N/A */
1312 { 0x1b, 0x411111f0 }, /* N/A */
1313 { 0x1c, 0x411111f0 }, /* N/A */
1314 { 0x1d, 0x411111f0 }, /* N/A */
1315 { 0x1e, 0xb743111e }, /* SPDIF out */
1319 .chain_id = ALC880_FIXUP_GPIO1,
1321 [ALC880_FIXUP_3ST_BASE] = {
1322 .type = HDA_FIXUP_PINS,
1323 .v.pins = (const struct hda_pintbl[]) {
1324 { 0x14, 0x01014010 }, /* line-out */
1325 { 0x15, 0x411111f0 }, /* N/A */
1326 { 0x16, 0x411111f0 }, /* N/A */
1327 { 0x17, 0x411111f0 }, /* N/A */
1328 { 0x18, 0x01a19c30 }, /* mic-in */
1329 { 0x19, 0x0121411f }, /* HP */
1330 { 0x1a, 0x01813031 }, /* line-in */
1331 { 0x1b, 0x02a19c40 }, /* front-mic */
1332 { 0x1c, 0x411111f0 }, /* N/A */
1333 { 0x1d, 0x411111f0 }, /* N/A */
1334 /* 0x1e is filled in below */
1335 { 0x1f, 0x411111f0 }, /* N/A */
1339 [ALC880_FIXUP_3ST] = {
1340 .type = HDA_FIXUP_PINS,
1341 .v.pins = (const struct hda_pintbl[]) {
1342 { 0x1e, 0x411111f0 }, /* N/A */
1346 .chain_id = ALC880_FIXUP_3ST_BASE,
1348 [ALC880_FIXUP_3ST_DIG] = {
1349 .type = HDA_FIXUP_PINS,
1350 .v.pins = (const struct hda_pintbl[]) {
1351 { 0x1e, 0x0144111e }, /* SPDIF */
1355 .chain_id = ALC880_FIXUP_3ST_BASE,
1357 [ALC880_FIXUP_5ST_BASE] = {
1358 .type = HDA_FIXUP_PINS,
1359 .v.pins = (const struct hda_pintbl[]) {
1360 { 0x14, 0x01014010 }, /* front */
1361 { 0x15, 0x411111f0 }, /* N/A */
1362 { 0x16, 0x01011411 }, /* CLFE */
1363 { 0x17, 0x01016412 }, /* surr */
1364 { 0x18, 0x01a19c30 }, /* mic-in */
1365 { 0x19, 0x0121411f }, /* HP */
1366 { 0x1a, 0x01813031 }, /* line-in */
1367 { 0x1b, 0x02a19c40 }, /* front-mic */
1368 { 0x1c, 0x411111f0 }, /* N/A */
1369 { 0x1d, 0x411111f0 }, /* N/A */
1370 /* 0x1e is filled in below */
1371 { 0x1f, 0x411111f0 }, /* N/A */
1375 [ALC880_FIXUP_5ST] = {
1376 .type = HDA_FIXUP_PINS,
1377 .v.pins = (const struct hda_pintbl[]) {
1378 { 0x1e, 0x411111f0 }, /* N/A */
1382 .chain_id = ALC880_FIXUP_5ST_BASE,
1384 [ALC880_FIXUP_5ST_DIG] = {
1385 .type = HDA_FIXUP_PINS,
1386 .v.pins = (const struct hda_pintbl[]) {
1387 { 0x1e, 0x0144111e }, /* SPDIF */
1391 .chain_id = ALC880_FIXUP_5ST_BASE,
1393 [ALC880_FIXUP_6ST_BASE] = {
1394 .type = HDA_FIXUP_PINS,
1395 .v.pins = (const struct hda_pintbl[]) {
1396 { 0x14, 0x01014010 }, /* front */
1397 { 0x15, 0x01016412 }, /* surr */
1398 { 0x16, 0x01011411 }, /* CLFE */
1399 { 0x17, 0x01012414 }, /* side */
1400 { 0x18, 0x01a19c30 }, /* mic-in */
1401 { 0x19, 0x02a19c40 }, /* front-mic */
1402 { 0x1a, 0x01813031 }, /* line-in */
1403 { 0x1b, 0x0121411f }, /* HP */
1404 { 0x1c, 0x411111f0 }, /* N/A */
1405 { 0x1d, 0x411111f0 }, /* N/A */
1406 /* 0x1e is filled in below */
1407 { 0x1f, 0x411111f0 }, /* N/A */
1411 [ALC880_FIXUP_6ST] = {
1412 .type = HDA_FIXUP_PINS,
1413 .v.pins = (const struct hda_pintbl[]) {
1414 { 0x1e, 0x411111f0 }, /* N/A */
1418 .chain_id = ALC880_FIXUP_6ST_BASE,
1420 [ALC880_FIXUP_6ST_DIG] = {
1421 .type = HDA_FIXUP_PINS,
1422 .v.pins = (const struct hda_pintbl[]) {
1423 { 0x1e, 0x0144111e }, /* SPDIF */
1427 .chain_id = ALC880_FIXUP_6ST_BASE,
1429 [ALC880_FIXUP_6ST_AUTOMUTE] = {
1430 .type = HDA_FIXUP_PINS,
1431 .v.pins = (const struct hda_pintbl[]) {
1432 { 0x1b, 0x0121401f }, /* HP with jack detect */
1435 .chained_before = true,
1436 .chain_id = ALC880_FIXUP_6ST_BASE,
1440 static const struct snd_pci_quirk alc880_fixup_tbl[] = {
1441 SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_FIXUP_W810),
1442 SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS W5A", ALC880_FIXUP_ASUS_W5A),
1443 SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_FIXUP_Z71V),
1444 SND_PCI_QUIRK_VENDOR(0x1043, "ASUS", ALC880_FIXUP_GPIO1),
1445 SND_PCI_QUIRK(0x147b, 0x1045, "ABit AA8XE", ALC880_FIXUP_6ST_AUTOMUTE),
1446 SND_PCI_QUIRK(0x1558, 0x5401, "Clevo GPIO2", ALC880_FIXUP_GPIO2),
1447 SND_PCI_QUIRK_VENDOR(0x1558, "Clevo", ALC880_FIXUP_EAPD_COEF),
1448 SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_FIXUP_UNIWILL_DIG),
1449 SND_PCI_QUIRK(0x1584, 0x9054, "Uniwill", ALC880_FIXUP_F1734),
1450 SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_FIXUP_UNIWILL),
1451 SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_FIXUP_VOL_KNOB),
1452 SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_FIXUP_W810),
1453 SND_PCI_QUIRK(0x161f, 0x205d, "Medion Rim 2150", ALC880_FIXUP_MEDION_RIM),
1454 SND_PCI_QUIRK(0x1631, 0xe011, "PB 13201056", ALC880_FIXUP_6ST_AUTOMUTE),
1455 SND_PCI_QUIRK(0x1734, 0x107c, "FSC Amilo M1437", ALC880_FIXUP_FUJITSU),
1456 SND_PCI_QUIRK(0x1734, 0x1094, "FSC Amilo M1451G", ALC880_FIXUP_FUJITSU),
1457 SND_PCI_QUIRK(0x1734, 0x10ac, "FSC AMILO Xi 1526", ALC880_FIXUP_F1734),
1458 SND_PCI_QUIRK(0x1734, 0x10b0, "FSC Amilo Pi1556", ALC880_FIXUP_FUJITSU),
1459 SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_FIXUP_LG),
1460 SND_PCI_QUIRK(0x1854, 0x005f, "LG P1 Express", ALC880_FIXUP_LG),
1461 SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_FIXUP_LG),
1462 SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_FIXUP_LG_LW25),
1463 SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_FIXUP_TCL_S700),
1465 /* Below is the copied entries from alc880_quirks.c.
1466 * It's not quite sure whether BIOS sets the correct pin-config table
1467 * on these machines, thus they are kept to be compatible with
1468 * the old static quirks. Once when it's confirmed to work without
1469 * these overrides, it'd be better to remove.
1471 SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_FIXUP_5ST_DIG),
1472 SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_FIXUP_6ST),
1473 SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_FIXUP_3ST_DIG),
1474 SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_FIXUP_6ST_DIG),
1475 SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_FIXUP_6ST_DIG),
1476 SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_FIXUP_6ST_DIG),
1477 SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_FIXUP_3ST_DIG),
1478 SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_FIXUP_3ST),
1479 SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_FIXUP_6ST_DIG),
1480 SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_FIXUP_3ST),
1481 SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_FIXUP_3ST),
1482 SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_FIXUP_5ST),
1483 SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_FIXUP_5ST),
1484 SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_FIXUP_5ST),
1485 SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_FIXUP_6ST_DIG),
1486 SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_FIXUP_6ST_DIG),
1487 SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_FIXUP_6ST_DIG),
1488 SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_FIXUP_6ST_DIG),
1489 SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_FIXUP_5ST_DIG),
1490 SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_FIXUP_5ST_DIG),
1491 SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_FIXUP_5ST_DIG),
1492 SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_FIXUP_6ST_DIG), /* broken BIOS */
1493 SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_FIXUP_6ST_DIG),
1494 SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_FIXUP_5ST_DIG),
1495 SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_FIXUP_5ST_DIG),
1496 SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_FIXUP_5ST_DIG),
1497 SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_FIXUP_3ST_DIG),
1498 SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_FIXUP_5ST_DIG),
1499 SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_FIXUP_3ST_DIG),
1500 SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_FIXUP_3ST_DIG),
1501 SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_FIXUP_5ST_DIG),
1502 SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_FIXUP_5ST_DIG),
1503 SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_FIXUP_5ST_DIG),
1505 SND_PCI_QUIRK_VENDOR(0x8086, "Intel mobo", ALC880_FIXUP_3ST),
1506 SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_FIXUP_5ST_DIG),
1507 SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_FIXUP_6ST_DIG),
1511 static const struct hda_model_fixup alc880_fixup_models[] = {
1512 {.id = ALC880_FIXUP_3ST, .name = "3stack"},
1513 {.id = ALC880_FIXUP_3ST_DIG, .name = "3stack-digout"},
1514 {.id = ALC880_FIXUP_5ST, .name = "5stack"},
1515 {.id = ALC880_FIXUP_5ST_DIG, .name = "5stack-digout"},
1516 {.id = ALC880_FIXUP_6ST, .name = "6stack"},
1517 {.id = ALC880_FIXUP_6ST_DIG, .name = "6stack-digout"},
1518 {.id = ALC880_FIXUP_6ST_AUTOMUTE, .name = "6stack-automute"},
1524 * OK, here we have finally the patch for ALC880
1526 static int patch_alc880(struct hda_codec *codec)
1528 struct alc_spec *spec;
1531 err = alc_alloc_spec(codec, 0x0b);
1536 spec->gen.need_dac_fix = 1;
1537 spec->gen.beep_nid = 0x01;
1539 codec->patch_ops.unsol_event = alc880_unsol_event;
1541 snd_hda_pick_fixup(codec, alc880_fixup_models, alc880_fixup_tbl,
1543 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
1545 /* automatic parse from the BIOS config */
1546 err = alc880_parse_auto_config(codec);
1550 if (!spec->gen.no_analog) {
1551 err = set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
1556 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
1569 static int alc260_parse_auto_config(struct hda_codec *codec)
1571 static const hda_nid_t alc260_ignore[] = { 0x17, 0 };
1572 static const hda_nid_t alc260_ssids[] = { 0x10, 0x15, 0x0f, 0 };
1573 return alc_parse_auto_config(codec, alc260_ignore, alc260_ssids);
1580 ALC260_FIXUP_HP_DC5750,
1581 ALC260_FIXUP_HP_PIN_0F,
1584 ALC260_FIXUP_GPIO1_TOGGLE,
1585 ALC260_FIXUP_REPLACER,
1586 ALC260_FIXUP_HP_B1900,
1588 ALC260_FIXUP_FSC_S7020,
1589 ALC260_FIXUP_FSC_S7020_JWSE,
1590 ALC260_FIXUP_VAIO_PINS,
1593 static void alc260_gpio1_automute(struct hda_codec *codec)
1595 struct alc_spec *spec = codec->spec;
1597 alc_update_gpio_data(codec, 0x01, spec->gen.hp_jack_present);
1600 static void alc260_fixup_gpio1_toggle(struct hda_codec *codec,
1601 const struct hda_fixup *fix, int action)
1603 struct alc_spec *spec = codec->spec;
1604 if (action == HDA_FIXUP_ACT_PROBE) {
1605 /* although the machine has only one output pin, we need to
1606 * toggle GPIO1 according to the jack state
1608 spec->gen.automute_hook = alc260_gpio1_automute;
1609 spec->gen.detect_hp = 1;
1610 spec->gen.automute_speaker = 1;
1611 spec->gen.autocfg.hp_pins[0] = 0x0f; /* copy it for automute */
1612 snd_hda_jack_detect_enable_callback(codec, 0x0f,
1613 snd_hda_gen_hp_automute);
1614 alc_setup_gpio(codec, 0x01);
1618 static void alc260_fixup_kn1(struct hda_codec *codec,
1619 const struct hda_fixup *fix, int action)
1621 struct alc_spec *spec = codec->spec;
1622 static const struct hda_pintbl pincfgs[] = {
1623 { 0x0f, 0x02214000 }, /* HP/speaker */
1624 { 0x12, 0x90a60160 }, /* int mic */
1625 { 0x13, 0x02a19000 }, /* ext mic */
1626 { 0x18, 0x01446000 }, /* SPDIF out */
1627 /* disable bogus I/O pins */
1628 { 0x10, 0x411111f0 },
1629 { 0x11, 0x411111f0 },
1630 { 0x14, 0x411111f0 },
1631 { 0x15, 0x411111f0 },
1632 { 0x16, 0x411111f0 },
1633 { 0x17, 0x411111f0 },
1634 { 0x19, 0x411111f0 },
1639 case HDA_FIXUP_ACT_PRE_PROBE:
1640 snd_hda_apply_pincfgs(codec, pincfgs);
1641 spec->init_amp = ALC_INIT_NONE;
1646 static void alc260_fixup_fsc_s7020(struct hda_codec *codec,
1647 const struct hda_fixup *fix, int action)
1649 struct alc_spec *spec = codec->spec;
1650 if (action == HDA_FIXUP_ACT_PRE_PROBE)
1651 spec->init_amp = ALC_INIT_NONE;
1654 static void alc260_fixup_fsc_s7020_jwse(struct hda_codec *codec,
1655 const struct hda_fixup *fix, int action)
1657 struct alc_spec *spec = codec->spec;
1658 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
1659 spec->gen.add_jack_modes = 1;
1660 spec->gen.hp_mic = 1;
1664 static const struct hda_fixup alc260_fixups[] = {
1665 [ALC260_FIXUP_HP_DC5750] = {
1666 .type = HDA_FIXUP_PINS,
1667 .v.pins = (const struct hda_pintbl[]) {
1668 { 0x11, 0x90130110 }, /* speaker */
1672 [ALC260_FIXUP_HP_PIN_0F] = {
1673 .type = HDA_FIXUP_PINS,
1674 .v.pins = (const struct hda_pintbl[]) {
1675 { 0x0f, 0x01214000 }, /* HP */
1679 [ALC260_FIXUP_COEF] = {
1680 .type = HDA_FIXUP_VERBS,
1681 .v.verbs = (const struct hda_verb[]) {
1682 { 0x1a, AC_VERB_SET_COEF_INDEX, 0x07 },
1683 { 0x1a, AC_VERB_SET_PROC_COEF, 0x3040 },
1687 [ALC260_FIXUP_GPIO1] = {
1688 .type = HDA_FIXUP_FUNC,
1689 .v.func = alc_fixup_gpio1,
1691 [ALC260_FIXUP_GPIO1_TOGGLE] = {
1692 .type = HDA_FIXUP_FUNC,
1693 .v.func = alc260_fixup_gpio1_toggle,
1695 .chain_id = ALC260_FIXUP_HP_PIN_0F,
1697 [ALC260_FIXUP_REPLACER] = {
1698 .type = HDA_FIXUP_VERBS,
1699 .v.verbs = (const struct hda_verb[]) {
1700 { 0x1a, AC_VERB_SET_COEF_INDEX, 0x07 },
1701 { 0x1a, AC_VERB_SET_PROC_COEF, 0x3050 },
1705 .chain_id = ALC260_FIXUP_GPIO1_TOGGLE,
1707 [ALC260_FIXUP_HP_B1900] = {
1708 .type = HDA_FIXUP_FUNC,
1709 .v.func = alc260_fixup_gpio1_toggle,
1711 .chain_id = ALC260_FIXUP_COEF,
1713 [ALC260_FIXUP_KN1] = {
1714 .type = HDA_FIXUP_FUNC,
1715 .v.func = alc260_fixup_kn1,
1717 [ALC260_FIXUP_FSC_S7020] = {
1718 .type = HDA_FIXUP_FUNC,
1719 .v.func = alc260_fixup_fsc_s7020,
1721 [ALC260_FIXUP_FSC_S7020_JWSE] = {
1722 .type = HDA_FIXUP_FUNC,
1723 .v.func = alc260_fixup_fsc_s7020_jwse,
1725 .chain_id = ALC260_FIXUP_FSC_S7020,
1727 [ALC260_FIXUP_VAIO_PINS] = {
1728 .type = HDA_FIXUP_PINS,
1729 .v.pins = (const struct hda_pintbl[]) {
1730 /* Pin configs are missing completely on some VAIOs */
1731 { 0x0f, 0x01211020 },
1732 { 0x10, 0x0001003f },
1733 { 0x11, 0x411111f0 },
1734 { 0x12, 0x01a15930 },
1735 { 0x13, 0x411111f0 },
1736 { 0x14, 0x411111f0 },
1737 { 0x15, 0x411111f0 },
1738 { 0x16, 0x411111f0 },
1739 { 0x17, 0x411111f0 },
1740 { 0x18, 0x411111f0 },
1741 { 0x19, 0x411111f0 },
1747 static const struct snd_pci_quirk alc260_fixup_tbl[] = {
1748 SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_FIXUP_GPIO1),
1749 SND_PCI_QUIRK(0x1025, 0x007f, "Acer Aspire 9500", ALC260_FIXUP_COEF),
1750 SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_FIXUP_GPIO1),
1751 SND_PCI_QUIRK(0x103c, 0x280a, "HP dc5750", ALC260_FIXUP_HP_DC5750),
1752 SND_PCI_QUIRK(0x103c, 0x30ba, "HP Presario B1900", ALC260_FIXUP_HP_B1900),
1753 SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_FIXUP_VAIO_PINS),
1754 SND_PCI_QUIRK(0x104d, 0x81e2, "Sony VAIO TX", ALC260_FIXUP_HP_PIN_0F),
1755 SND_PCI_QUIRK(0x10cf, 0x1326, "FSC LifeBook S7020", ALC260_FIXUP_FSC_S7020),
1756 SND_PCI_QUIRK(0x1509, 0x4540, "Favorit 100XS", ALC260_FIXUP_GPIO1),
1757 SND_PCI_QUIRK(0x152d, 0x0729, "Quanta KN1", ALC260_FIXUP_KN1),
1758 SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_FIXUP_REPLACER),
1759 SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_FIXUP_COEF),
1763 static const struct hda_model_fixup alc260_fixup_models[] = {
1764 {.id = ALC260_FIXUP_GPIO1, .name = "gpio1"},
1765 {.id = ALC260_FIXUP_COEF, .name = "coef"},
1766 {.id = ALC260_FIXUP_FSC_S7020, .name = "fujitsu"},
1767 {.id = ALC260_FIXUP_FSC_S7020_JWSE, .name = "fujitsu-jwse"},
1773 static int patch_alc260(struct hda_codec *codec)
1775 struct alc_spec *spec;
1778 err = alc_alloc_spec(codec, 0x07);
1783 /* as quite a few machines require HP amp for speaker outputs,
1784 * it's easier to enable it unconditionally; even if it's unneeded,
1785 * it's almost harmless.
1787 spec->gen.prefer_hp_amp = 1;
1788 spec->gen.beep_nid = 0x01;
1790 spec->shutup = alc_eapd_shutup;
1792 snd_hda_pick_fixup(codec, alc260_fixup_models, alc260_fixup_tbl,
1794 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
1796 /* automatic parse from the BIOS config */
1797 err = alc260_parse_auto_config(codec);
1801 if (!spec->gen.no_analog) {
1802 err = set_beep_amp(spec, 0x07, 0x05, HDA_INPUT);
1807 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
1818 * ALC882/883/885/888/889 support
1820 * ALC882 is almost identical with ALC880 but has cleaner and more flexible
1821 * configuration. Each pin widget can choose any input DACs and a mixer.
1822 * Each ADC is connected from a mixer of all inputs. This makes possible
1823 * 6-channel independent captures.
1825 * In addition, an independent DAC for the multi-playback (not used in this
1833 ALC882_FIXUP_ABIT_AW9D_MAX,
1834 ALC882_FIXUP_LENOVO_Y530,
1835 ALC882_FIXUP_PB_M5210,
1836 ALC882_FIXUP_ACER_ASPIRE_7736,
1837 ALC882_FIXUP_ASUS_W90V,
1839 ALC889_FIXUP_FRONT_HP_NO_PRESENCE,
1840 ALC889_FIXUP_VAIO_TT,
1841 ALC888_FIXUP_EEE1601,
1844 ALC883_FIXUP_ACER_EAPD,
1849 ALC882_FIXUP_ASUS_W2JC,
1850 ALC882_FIXUP_ACER_ASPIRE_4930G,
1851 ALC882_FIXUP_ACER_ASPIRE_8930G,
1852 ALC882_FIXUP_ASPIRE_8930G_VERBS,
1853 ALC885_FIXUP_MACPRO_GPIO,
1854 ALC889_FIXUP_DAC_ROUTE,
1855 ALC889_FIXUP_MBP_VREF,
1856 ALC889_FIXUP_IMAC91_VREF,
1857 ALC889_FIXUP_MBA11_VREF,
1858 ALC889_FIXUP_MBA21_VREF,
1859 ALC889_FIXUP_MP11_VREF,
1860 ALC889_FIXUP_MP41_VREF,
1861 ALC882_FIXUP_INV_DMIC,
1862 ALC882_FIXUP_NO_PRIMARY_HP,
1863 ALC887_FIXUP_ASUS_BASS,
1864 ALC887_FIXUP_BASS_CHMAP,
1865 ALC1220_FIXUP_GB_DUAL_CODECS,
1866 ALC1220_FIXUP_CLEVO_P950,
1867 ALC1220_FIXUP_SYSTEM76_ORYP5,
1868 ALC1220_FIXUP_SYSTEM76_ORYP5_PINS,
1871 static void alc889_fixup_coef(struct hda_codec *codec,
1872 const struct hda_fixup *fix, int action)
1874 if (action != HDA_FIXUP_ACT_INIT)
1876 alc_update_coef_idx(codec, 7, 0, 0x2030);
1879 /* set up GPIO at initialization */
1880 static void alc885_fixup_macpro_gpio(struct hda_codec *codec,
1881 const struct hda_fixup *fix, int action)
1883 struct alc_spec *spec = codec->spec;
1885 spec->gpio_write_delay = true;
1886 alc_fixup_gpio3(codec, fix, action);
1889 /* Fix the connection of some pins for ALC889:
1890 * At least, Acer Aspire 5935 shows the connections to DAC3/4 don't
1891 * work correctly (bko#42740)
1893 static void alc889_fixup_dac_route(struct hda_codec *codec,
1894 const struct hda_fixup *fix, int action)
1896 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
1897 /* fake the connections during parsing the tree */
1898 hda_nid_t conn1[2] = { 0x0c, 0x0d };
1899 hda_nid_t conn2[2] = { 0x0e, 0x0f };
1900 snd_hda_override_conn_list(codec, 0x14, 2, conn1);
1901 snd_hda_override_conn_list(codec, 0x15, 2, conn1);
1902 snd_hda_override_conn_list(codec, 0x18, 2, conn2);
1903 snd_hda_override_conn_list(codec, 0x1a, 2, conn2);
1904 } else if (action == HDA_FIXUP_ACT_PROBE) {
1905 /* restore the connections */
1906 hda_nid_t conn[5] = { 0x0c, 0x0d, 0x0e, 0x0f, 0x26 };
1907 snd_hda_override_conn_list(codec, 0x14, 5, conn);
1908 snd_hda_override_conn_list(codec, 0x15, 5, conn);
1909 snd_hda_override_conn_list(codec, 0x18, 5, conn);
1910 snd_hda_override_conn_list(codec, 0x1a, 5, conn);
1914 /* Set VREF on HP pin */
1915 static void alc889_fixup_mbp_vref(struct hda_codec *codec,
1916 const struct hda_fixup *fix, int action)
1918 struct alc_spec *spec = codec->spec;
1919 static hda_nid_t nids[3] = { 0x14, 0x15, 0x19 };
1922 if (action != HDA_FIXUP_ACT_INIT)
1924 for (i = 0; i < ARRAY_SIZE(nids); i++) {
1925 unsigned int val = snd_hda_codec_get_pincfg(codec, nids[i]);
1926 if (get_defcfg_device(val) != AC_JACK_HP_OUT)
1928 val = snd_hda_codec_get_pin_target(codec, nids[i]);
1929 val |= AC_PINCTL_VREF_80;
1930 snd_hda_set_pin_ctl(codec, nids[i], val);
1931 spec->gen.keep_vref_in_automute = 1;
1936 static void alc889_fixup_mac_pins(struct hda_codec *codec,
1937 const hda_nid_t *nids, int num_nids)
1939 struct alc_spec *spec = codec->spec;
1942 for (i = 0; i < num_nids; i++) {
1944 val = snd_hda_codec_get_pin_target(codec, nids[i]);
1945 val |= AC_PINCTL_VREF_50;
1946 snd_hda_set_pin_ctl(codec, nids[i], val);
1948 spec->gen.keep_vref_in_automute = 1;
1951 /* Set VREF on speaker pins on imac91 */
1952 static void alc889_fixup_imac91_vref(struct hda_codec *codec,
1953 const struct hda_fixup *fix, int action)
1955 static hda_nid_t nids[2] = { 0x18, 0x1a };
1957 if (action == HDA_FIXUP_ACT_INIT)
1958 alc889_fixup_mac_pins(codec, nids, ARRAY_SIZE(nids));
1961 /* Set VREF on speaker pins on mba11 */
1962 static void alc889_fixup_mba11_vref(struct hda_codec *codec,
1963 const struct hda_fixup *fix, int action)
1965 static hda_nid_t nids[1] = { 0x18 };
1967 if (action == HDA_FIXUP_ACT_INIT)
1968 alc889_fixup_mac_pins(codec, nids, ARRAY_SIZE(nids));
1971 /* Set VREF on speaker pins on mba21 */
1972 static void alc889_fixup_mba21_vref(struct hda_codec *codec,
1973 const struct hda_fixup *fix, int action)
1975 static hda_nid_t nids[2] = { 0x18, 0x19 };
1977 if (action == HDA_FIXUP_ACT_INIT)
1978 alc889_fixup_mac_pins(codec, nids, ARRAY_SIZE(nids));
1981 /* Don't take HP output as primary
1982 * Strangely, the speaker output doesn't work on Vaio Z and some Vaio
1983 * all-in-one desktop PCs (for example VGC-LN51JGB) through DAC 0x05
1985 static void alc882_fixup_no_primary_hp(struct hda_codec *codec,
1986 const struct hda_fixup *fix, int action)
1988 struct alc_spec *spec = codec->spec;
1989 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
1990 spec->gen.no_primary_hp = 1;
1991 spec->gen.no_multi_io = 1;
1995 static void alc_fixup_bass_chmap(struct hda_codec *codec,
1996 const struct hda_fixup *fix, int action);
1998 /* For dual-codec configuration, we need to disable some features to avoid
1999 * conflicts of kctls and PCM streams
2001 static void alc_fixup_dual_codecs(struct hda_codec *codec,
2002 const struct hda_fixup *fix, int action)
2004 struct alc_spec *spec = codec->spec;
2006 if (action != HDA_FIXUP_ACT_PRE_PROBE)
2008 /* disable vmaster */
2009 spec->gen.suppress_vmaster = 1;
2010 /* auto-mute and auto-mic switch don't work with multiple codecs */
2011 spec->gen.suppress_auto_mute = 1;
2012 spec->gen.suppress_auto_mic = 1;
2013 /* disable aamix as well */
2014 spec->gen.mixer_nid = 0;
2015 /* add location prefix to avoid conflicts */
2016 codec->force_pin_prefix = 1;
2019 static void rename_ctl(struct hda_codec *codec, const char *oldname,
2020 const char *newname)
2022 struct snd_kcontrol *kctl;
2024 kctl = snd_hda_find_mixer_ctl(codec, oldname);
2026 strcpy(kctl->id.name, newname);
2029 static void alc1220_fixup_gb_dual_codecs(struct hda_codec *codec,
2030 const struct hda_fixup *fix,
2033 alc_fixup_dual_codecs(codec, fix, action);
2035 case HDA_FIXUP_ACT_PRE_PROBE:
2036 /* override card longname to provide a unique UCM profile */
2037 strcpy(codec->card->longname, "HDAudio-Gigabyte-ALC1220DualCodecs");
2039 case HDA_FIXUP_ACT_BUILD:
2040 /* rename Capture controls depending on the codec */
2041 rename_ctl(codec, "Capture Volume",
2043 "Rear-Panel Capture Volume" :
2044 "Front-Panel Capture Volume");
2045 rename_ctl(codec, "Capture Switch",
2047 "Rear-Panel Capture Switch" :
2048 "Front-Panel Capture Switch");
2053 static void alc1220_fixup_clevo_p950(struct hda_codec *codec,
2054 const struct hda_fixup *fix,
2057 hda_nid_t conn1[1] = { 0x0c };
2059 if (action != HDA_FIXUP_ACT_PRE_PROBE)
2062 alc_update_coef_idx(codec, 0x7, 0, 0x3c3);
2063 /* We therefore want to make sure 0x14 (front headphone) and
2064 * 0x1b (speakers) use the stereo DAC 0x02
2066 snd_hda_override_conn_list(codec, 0x14, 1, conn1);
2067 snd_hda_override_conn_list(codec, 0x1b, 1, conn1);
2070 static void alc_fixup_headset_mode_no_hp_mic(struct hda_codec *codec,
2071 const struct hda_fixup *fix, int action);
2073 static void alc1220_fixup_system76_oryp5(struct hda_codec *codec,
2074 const struct hda_fixup *fix,
2077 alc1220_fixup_clevo_p950(codec, fix, action);
2078 alc_fixup_headset_mode_no_hp_mic(codec, fix, action);
2081 static const struct hda_fixup alc882_fixups[] = {
2082 [ALC882_FIXUP_ABIT_AW9D_MAX] = {
2083 .type = HDA_FIXUP_PINS,
2084 .v.pins = (const struct hda_pintbl[]) {
2085 { 0x15, 0x01080104 }, /* side */
2086 { 0x16, 0x01011012 }, /* rear */
2087 { 0x17, 0x01016011 }, /* clfe */
2091 [ALC882_FIXUP_LENOVO_Y530] = {
2092 .type = HDA_FIXUP_PINS,
2093 .v.pins = (const struct hda_pintbl[]) {
2094 { 0x15, 0x99130112 }, /* rear int speakers */
2095 { 0x16, 0x99130111 }, /* subwoofer */
2099 [ALC882_FIXUP_PB_M5210] = {
2100 .type = HDA_FIXUP_PINCTLS,
2101 .v.pins = (const struct hda_pintbl[]) {
2102 { 0x19, PIN_VREF50 },
2106 [ALC882_FIXUP_ACER_ASPIRE_7736] = {
2107 .type = HDA_FIXUP_FUNC,
2108 .v.func = alc_fixup_sku_ignore,
2110 [ALC882_FIXUP_ASUS_W90V] = {
2111 .type = HDA_FIXUP_PINS,
2112 .v.pins = (const struct hda_pintbl[]) {
2113 { 0x16, 0x99130110 }, /* fix sequence for CLFE */
2117 [ALC889_FIXUP_CD] = {
2118 .type = HDA_FIXUP_PINS,
2119 .v.pins = (const struct hda_pintbl[]) {
2120 { 0x1c, 0x993301f0 }, /* CD */
2124 [ALC889_FIXUP_FRONT_HP_NO_PRESENCE] = {
2125 .type = HDA_FIXUP_PINS,
2126 .v.pins = (const struct hda_pintbl[]) {
2127 { 0x1b, 0x02214120 }, /* Front HP jack is flaky, disable jack detect */
2131 .chain_id = ALC889_FIXUP_CD,
2133 [ALC889_FIXUP_VAIO_TT] = {
2134 .type = HDA_FIXUP_PINS,
2135 .v.pins = (const struct hda_pintbl[]) {
2136 { 0x17, 0x90170111 }, /* hidden surround speaker */
2140 [ALC888_FIXUP_EEE1601] = {
2141 .type = HDA_FIXUP_VERBS,
2142 .v.verbs = (const struct hda_verb[]) {
2143 { 0x20, AC_VERB_SET_COEF_INDEX, 0x0b },
2144 { 0x20, AC_VERB_SET_PROC_COEF, 0x0838 },
2148 [ALC882_FIXUP_EAPD] = {
2149 .type = HDA_FIXUP_VERBS,
2150 .v.verbs = (const struct hda_verb[]) {
2151 /* change to EAPD mode */
2152 { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
2153 { 0x20, AC_VERB_SET_PROC_COEF, 0x3060 },
2157 [ALC883_FIXUP_EAPD] = {
2158 .type = HDA_FIXUP_VERBS,
2159 .v.verbs = (const struct hda_verb[]) {
2160 /* change to EAPD mode */
2161 { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
2162 { 0x20, AC_VERB_SET_PROC_COEF, 0x3070 },
2166 [ALC883_FIXUP_ACER_EAPD] = {
2167 .type = HDA_FIXUP_VERBS,
2168 .v.verbs = (const struct hda_verb[]) {
2169 /* eanable EAPD on Acer laptops */
2170 { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
2171 { 0x20, AC_VERB_SET_PROC_COEF, 0x3050 },
2175 [ALC882_FIXUP_GPIO1] = {
2176 .type = HDA_FIXUP_FUNC,
2177 .v.func = alc_fixup_gpio1,
2179 [ALC882_FIXUP_GPIO2] = {
2180 .type = HDA_FIXUP_FUNC,
2181 .v.func = alc_fixup_gpio2,
2183 [ALC882_FIXUP_GPIO3] = {
2184 .type = HDA_FIXUP_FUNC,
2185 .v.func = alc_fixup_gpio3,
2187 [ALC882_FIXUP_ASUS_W2JC] = {
2188 .type = HDA_FIXUP_FUNC,
2189 .v.func = alc_fixup_gpio1,
2191 .chain_id = ALC882_FIXUP_EAPD,
2193 [ALC889_FIXUP_COEF] = {
2194 .type = HDA_FIXUP_FUNC,
2195 .v.func = alc889_fixup_coef,
2197 [ALC882_FIXUP_ACER_ASPIRE_4930G] = {
2198 .type = HDA_FIXUP_PINS,
2199 .v.pins = (const struct hda_pintbl[]) {
2200 { 0x16, 0x99130111 }, /* CLFE speaker */
2201 { 0x17, 0x99130112 }, /* surround speaker */
2205 .chain_id = ALC882_FIXUP_GPIO1,
2207 [ALC882_FIXUP_ACER_ASPIRE_8930G] = {
2208 .type = HDA_FIXUP_PINS,
2209 .v.pins = (const struct hda_pintbl[]) {
2210 { 0x16, 0x99130111 }, /* CLFE speaker */
2211 { 0x1b, 0x99130112 }, /* surround speaker */
2215 .chain_id = ALC882_FIXUP_ASPIRE_8930G_VERBS,
2217 [ALC882_FIXUP_ASPIRE_8930G_VERBS] = {
2218 /* additional init verbs for Acer Aspire 8930G */
2219 .type = HDA_FIXUP_VERBS,
2220 .v.verbs = (const struct hda_verb[]) {
2221 /* Enable all DACs */
2222 /* DAC DISABLE/MUTE 1? */
2223 /* setting bits 1-5 disables DAC nids 0x02-0x06
2224 * apparently. Init=0x38 */
2225 { 0x20, AC_VERB_SET_COEF_INDEX, 0x03 },
2226 { 0x20, AC_VERB_SET_PROC_COEF, 0x0000 },
2227 /* DAC DISABLE/MUTE 2? */
2228 /* some bit here disables the other DACs.
2230 { 0x20, AC_VERB_SET_COEF_INDEX, 0x08 },
2231 { 0x20, AC_VERB_SET_PROC_COEF, 0x0000 },
2233 * This laptop has a stereo digital microphone.
2234 * The mics are only 1cm apart which makes the stereo
2235 * useless. However, either the mic or the ALC889
2236 * makes the signal become a difference/sum signal
2237 * instead of standard stereo, which is annoying.
2238 * So instead we flip this bit which makes the
2239 * codec replicate the sum signal to both channels,
2240 * turning it into a normal mono mic.
2242 /* DMIC_CONTROL? Init value = 0x0001 */
2243 { 0x20, AC_VERB_SET_COEF_INDEX, 0x0b },
2244 { 0x20, AC_VERB_SET_PROC_COEF, 0x0003 },
2245 { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
2246 { 0x20, AC_VERB_SET_PROC_COEF, 0x3050 },
2250 .chain_id = ALC882_FIXUP_GPIO1,
2252 [ALC885_FIXUP_MACPRO_GPIO] = {
2253 .type = HDA_FIXUP_FUNC,
2254 .v.func = alc885_fixup_macpro_gpio,
2256 [ALC889_FIXUP_DAC_ROUTE] = {
2257 .type = HDA_FIXUP_FUNC,
2258 .v.func = alc889_fixup_dac_route,
2260 [ALC889_FIXUP_MBP_VREF] = {
2261 .type = HDA_FIXUP_FUNC,
2262 .v.func = alc889_fixup_mbp_vref,
2264 .chain_id = ALC882_FIXUP_GPIO1,
2266 [ALC889_FIXUP_IMAC91_VREF] = {
2267 .type = HDA_FIXUP_FUNC,
2268 .v.func = alc889_fixup_imac91_vref,
2270 .chain_id = ALC882_FIXUP_GPIO1,
2272 [ALC889_FIXUP_MBA11_VREF] = {
2273 .type = HDA_FIXUP_FUNC,
2274 .v.func = alc889_fixup_mba11_vref,
2276 .chain_id = ALC889_FIXUP_MBP_VREF,
2278 [ALC889_FIXUP_MBA21_VREF] = {
2279 .type = HDA_FIXUP_FUNC,
2280 .v.func = alc889_fixup_mba21_vref,
2282 .chain_id = ALC889_FIXUP_MBP_VREF,
2284 [ALC889_FIXUP_MP11_VREF] = {
2285 .type = HDA_FIXUP_FUNC,
2286 .v.func = alc889_fixup_mba11_vref,
2288 .chain_id = ALC885_FIXUP_MACPRO_GPIO,
2290 [ALC889_FIXUP_MP41_VREF] = {
2291 .type = HDA_FIXUP_FUNC,
2292 .v.func = alc889_fixup_mbp_vref,
2294 .chain_id = ALC885_FIXUP_MACPRO_GPIO,
2296 [ALC882_FIXUP_INV_DMIC] = {
2297 .type = HDA_FIXUP_FUNC,
2298 .v.func = alc_fixup_inv_dmic,
2300 [ALC882_FIXUP_NO_PRIMARY_HP] = {
2301 .type = HDA_FIXUP_FUNC,
2302 .v.func = alc882_fixup_no_primary_hp,
2304 [ALC887_FIXUP_ASUS_BASS] = {
2305 .type = HDA_FIXUP_PINS,
2306 .v.pins = (const struct hda_pintbl[]) {
2307 {0x16, 0x99130130}, /* bass speaker */
2311 .chain_id = ALC887_FIXUP_BASS_CHMAP,
2313 [ALC887_FIXUP_BASS_CHMAP] = {
2314 .type = HDA_FIXUP_FUNC,
2315 .v.func = alc_fixup_bass_chmap,
2317 [ALC1220_FIXUP_GB_DUAL_CODECS] = {
2318 .type = HDA_FIXUP_FUNC,
2319 .v.func = alc1220_fixup_gb_dual_codecs,
2321 [ALC1220_FIXUP_CLEVO_P950] = {
2322 .type = HDA_FIXUP_FUNC,
2323 .v.func = alc1220_fixup_clevo_p950,
2325 [ALC1220_FIXUP_SYSTEM76_ORYP5] = {
2326 .type = HDA_FIXUP_FUNC,
2327 .v.func = alc1220_fixup_system76_oryp5,
2329 [ALC1220_FIXUP_SYSTEM76_ORYP5_PINS] = {
2330 .type = HDA_FIXUP_PINS,
2331 .v.pins = (const struct hda_pintbl[]) {
2332 { 0x19, 0x01a1913c }, /* use as headset mic, without its own jack detect */
2336 .chain_id = ALC1220_FIXUP_SYSTEM76_ORYP5,
2340 static const struct snd_pci_quirk alc882_fixup_tbl[] = {
2341 SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_FIXUP_ACER_EAPD),
2342 SND_PCI_QUIRK(0x1025, 0x0090, "Acer Aspire", ALC883_FIXUP_ACER_EAPD),
2343 SND_PCI_QUIRK(0x1025, 0x0107, "Acer Aspire", ALC883_FIXUP_ACER_EAPD),
2344 SND_PCI_QUIRK(0x1025, 0x010a, "Acer Ferrari 5000", ALC883_FIXUP_ACER_EAPD),
2345 SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_FIXUP_ACER_EAPD),
2346 SND_PCI_QUIRK(0x1025, 0x0112, "Acer Aspire 9303", ALC883_FIXUP_ACER_EAPD),
2347 SND_PCI_QUIRK(0x1025, 0x0121, "Acer Aspire 5920G", ALC883_FIXUP_ACER_EAPD),
2348 SND_PCI_QUIRK(0x1025, 0x013e, "Acer Aspire 4930G",
2349 ALC882_FIXUP_ACER_ASPIRE_4930G),
2350 SND_PCI_QUIRK(0x1025, 0x013f, "Acer Aspire 5930G",
2351 ALC882_FIXUP_ACER_ASPIRE_4930G),
2352 SND_PCI_QUIRK(0x1025, 0x0145, "Acer Aspire 8930G",
2353 ALC882_FIXUP_ACER_ASPIRE_8930G),
2354 SND_PCI_QUIRK(0x1025, 0x0146, "Acer Aspire 6935G",
2355 ALC882_FIXUP_ACER_ASPIRE_8930G),
2356 SND_PCI_QUIRK(0x1025, 0x015e, "Acer Aspire 6930G",
2357 ALC882_FIXUP_ACER_ASPIRE_4930G),
2358 SND_PCI_QUIRK(0x1025, 0x0166, "Acer Aspire 6530G",
2359 ALC882_FIXUP_ACER_ASPIRE_4930G),
2360 SND_PCI_QUIRK(0x1025, 0x0142, "Acer Aspire 7730G",
2361 ALC882_FIXUP_ACER_ASPIRE_4930G),
2362 SND_PCI_QUIRK(0x1025, 0x0155, "Packard-Bell M5120", ALC882_FIXUP_PB_M5210),
2363 SND_PCI_QUIRK(0x1025, 0x021e, "Acer Aspire 5739G",
2364 ALC882_FIXUP_ACER_ASPIRE_4930G),
2365 SND_PCI_QUIRK(0x1025, 0x0259, "Acer Aspire 5935", ALC889_FIXUP_DAC_ROUTE),
2366 SND_PCI_QUIRK(0x1025, 0x026b, "Acer Aspire 8940G", ALC882_FIXUP_ACER_ASPIRE_8930G),
2367 SND_PCI_QUIRK(0x1025, 0x0296, "Acer Aspire 7736z", ALC882_FIXUP_ACER_ASPIRE_7736),
2368 SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_FIXUP_EAPD),
2369 SND_PCI_QUIRK(0x1043, 0x1873, "ASUS W90V", ALC882_FIXUP_ASUS_W90V),
2370 SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_FIXUP_ASUS_W2JC),
2371 SND_PCI_QUIRK(0x1043, 0x835f, "Asus Eee 1601", ALC888_FIXUP_EEE1601),
2372 SND_PCI_QUIRK(0x1043, 0x84bc, "ASUS ET2700", ALC887_FIXUP_ASUS_BASS),
2373 SND_PCI_QUIRK(0x1043, 0x8691, "ASUS ROG Ranger VIII", ALC882_FIXUP_GPIO3),
2374 SND_PCI_QUIRK(0x104d, 0x9047, "Sony Vaio TT", ALC889_FIXUP_VAIO_TT),
2375 SND_PCI_QUIRK(0x104d, 0x905a, "Sony Vaio Z", ALC882_FIXUP_NO_PRIMARY_HP),
2376 SND_PCI_QUIRK(0x104d, 0x9060, "Sony Vaio VPCL14M1R", ALC882_FIXUP_NO_PRIMARY_HP),
2377 SND_PCI_QUIRK(0x104d, 0x9043, "Sony Vaio VGC-LN51JGB", ALC882_FIXUP_NO_PRIMARY_HP),
2378 SND_PCI_QUIRK(0x104d, 0x9044, "Sony VAIO AiO", ALC882_FIXUP_NO_PRIMARY_HP),
2380 /* All Apple entries are in codec SSIDs */
2381 SND_PCI_QUIRK(0x106b, 0x00a0, "MacBookPro 3,1", ALC889_FIXUP_MBP_VREF),
2382 SND_PCI_QUIRK(0x106b, 0x00a1, "Macbook", ALC889_FIXUP_MBP_VREF),
2383 SND_PCI_QUIRK(0x106b, 0x00a4, "MacbookPro 4,1", ALC889_FIXUP_MBP_VREF),
2384 SND_PCI_QUIRK(0x106b, 0x0c00, "Mac Pro", ALC889_FIXUP_MP11_VREF),
2385 SND_PCI_QUIRK(0x106b, 0x1000, "iMac 24", ALC885_FIXUP_MACPRO_GPIO),
2386 SND_PCI_QUIRK(0x106b, 0x2800, "AppleTV", ALC885_FIXUP_MACPRO_GPIO),
2387 SND_PCI_QUIRK(0x106b, 0x2c00, "MacbookPro rev3", ALC889_FIXUP_MBP_VREF),
2388 SND_PCI_QUIRK(0x106b, 0x3000, "iMac", ALC889_FIXUP_MBP_VREF),
2389 SND_PCI_QUIRK(0x106b, 0x3200, "iMac 7,1 Aluminum", ALC882_FIXUP_EAPD),
2390 SND_PCI_QUIRK(0x106b, 0x3400, "MacBookAir 1,1", ALC889_FIXUP_MBA11_VREF),
2391 SND_PCI_QUIRK(0x106b, 0x3500, "MacBookAir 2,1", ALC889_FIXUP_MBA21_VREF),
2392 SND_PCI_QUIRK(0x106b, 0x3600, "Macbook 3,1", ALC889_FIXUP_MBP_VREF),
2393 SND_PCI_QUIRK(0x106b, 0x3800, "MacbookPro 4,1", ALC889_FIXUP_MBP_VREF),
2394 SND_PCI_QUIRK(0x106b, 0x3e00, "iMac 24 Aluminum", ALC885_FIXUP_MACPRO_GPIO),
2395 SND_PCI_QUIRK(0x106b, 0x3f00, "Macbook 5,1", ALC889_FIXUP_IMAC91_VREF),
2396 SND_PCI_QUIRK(0x106b, 0x4000, "MacbookPro 5,1", ALC889_FIXUP_IMAC91_VREF),
2397 SND_PCI_QUIRK(0x106b, 0x4100, "Macmini 3,1", ALC889_FIXUP_IMAC91_VREF),
2398 SND_PCI_QUIRK(0x106b, 0x4200, "Mac Pro 4,1/5,1", ALC889_FIXUP_MP41_VREF),
2399 SND_PCI_QUIRK(0x106b, 0x4300, "iMac 9,1", ALC889_FIXUP_IMAC91_VREF),
2400 SND_PCI_QUIRK(0x106b, 0x4600, "MacbookPro 5,2", ALC889_FIXUP_IMAC91_VREF),
2401 SND_PCI_QUIRK(0x106b, 0x4900, "iMac 9,1 Aluminum", ALC889_FIXUP_IMAC91_VREF),
2402 SND_PCI_QUIRK(0x106b, 0x4a00, "Macbook 5,2", ALC889_FIXUP_MBA11_VREF),
2404 SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC882_FIXUP_EAPD),
2405 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte EP45-DS3/Z87X-UD3H", ALC889_FIXUP_FRONT_HP_NO_PRESENCE),
2406 SND_PCI_QUIRK(0x1458, 0xa0b8, "Gigabyte AZ370-Gaming", ALC1220_FIXUP_GB_DUAL_CODECS),
2407 SND_PCI_QUIRK(0x1462, 0x7350, "MSI-7350", ALC889_FIXUP_CD),
2408 SND_PCI_QUIRK(0x1462, 0xda57, "MSI Z270-Gaming", ALC1220_FIXUP_GB_DUAL_CODECS),
2409 SND_PCI_QUIRK_VENDOR(0x1462, "MSI", ALC882_FIXUP_GPIO3),
2410 SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", ALC882_FIXUP_ABIT_AW9D_MAX),
2411 SND_PCI_QUIRK(0x1558, 0x9501, "Clevo P950HR", ALC1220_FIXUP_CLEVO_P950),
2412 SND_PCI_QUIRK(0x1558, 0x95e1, "Clevo P95xER", ALC1220_FIXUP_CLEVO_P950),
2413 SND_PCI_QUIRK(0x1558, 0x95e2, "Clevo P950ER", ALC1220_FIXUP_CLEVO_P950),
2414 SND_PCI_QUIRK(0x1558, 0x96e1, "System76 Oryx Pro (oryp5)", ALC1220_FIXUP_SYSTEM76_ORYP5_PINS),
2415 SND_PCI_QUIRK(0x1558, 0x97e1, "System76 Oryx Pro (oryp5)", ALC1220_FIXUP_SYSTEM76_ORYP5_PINS),
2416 SND_PCI_QUIRK_VENDOR(0x1558, "Clevo laptop", ALC882_FIXUP_EAPD),
2417 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_FIXUP_EAPD),
2418 SND_PCI_QUIRK(0x17aa, 0x3a0d, "Lenovo Y530", ALC882_FIXUP_LENOVO_Y530),
2419 SND_PCI_QUIRK(0x8086, 0x0022, "DX58SO", ALC889_FIXUP_COEF),
2423 static const struct hda_model_fixup alc882_fixup_models[] = {
2424 {.id = ALC882_FIXUP_ABIT_AW9D_MAX, .name = "abit-aw9d"},
2425 {.id = ALC882_FIXUP_LENOVO_Y530, .name = "lenovo-y530"},
2426 {.id = ALC882_FIXUP_ACER_ASPIRE_7736, .name = "acer-aspire-7736"},
2427 {.id = ALC882_FIXUP_ASUS_W90V, .name = "asus-w90v"},
2428 {.id = ALC889_FIXUP_CD, .name = "cd"},
2429 {.id = ALC889_FIXUP_FRONT_HP_NO_PRESENCE, .name = "no-front-hp"},
2430 {.id = ALC889_FIXUP_VAIO_TT, .name = "vaio-tt"},
2431 {.id = ALC888_FIXUP_EEE1601, .name = "eee1601"},
2432 {.id = ALC882_FIXUP_EAPD, .name = "alc882-eapd"},
2433 {.id = ALC883_FIXUP_EAPD, .name = "alc883-eapd"},
2434 {.id = ALC882_FIXUP_GPIO1, .name = "gpio1"},
2435 {.id = ALC882_FIXUP_GPIO2, .name = "gpio2"},
2436 {.id = ALC882_FIXUP_GPIO3, .name = "gpio3"},
2437 {.id = ALC889_FIXUP_COEF, .name = "alc889-coef"},
2438 {.id = ALC882_FIXUP_ASUS_W2JC, .name = "asus-w2jc"},
2439 {.id = ALC882_FIXUP_ACER_ASPIRE_4930G, .name = "acer-aspire-4930g"},
2440 {.id = ALC882_FIXUP_ACER_ASPIRE_8930G, .name = "acer-aspire-8930g"},
2441 {.id = ALC883_FIXUP_ACER_EAPD, .name = "acer-aspire"},
2442 {.id = ALC885_FIXUP_MACPRO_GPIO, .name = "macpro-gpio"},
2443 {.id = ALC889_FIXUP_DAC_ROUTE, .name = "dac-route"},
2444 {.id = ALC889_FIXUP_MBP_VREF, .name = "mbp-vref"},
2445 {.id = ALC889_FIXUP_IMAC91_VREF, .name = "imac91-vref"},
2446 {.id = ALC889_FIXUP_MBA11_VREF, .name = "mba11-vref"},
2447 {.id = ALC889_FIXUP_MBA21_VREF, .name = "mba21-vref"},
2448 {.id = ALC889_FIXUP_MP11_VREF, .name = "mp11-vref"},
2449 {.id = ALC889_FIXUP_MP41_VREF, .name = "mp41-vref"},
2450 {.id = ALC882_FIXUP_INV_DMIC, .name = "inv-dmic"},
2451 {.id = ALC882_FIXUP_NO_PRIMARY_HP, .name = "no-primary-hp"},
2452 {.id = ALC887_FIXUP_ASUS_BASS, .name = "asus-bass"},
2453 {.id = ALC1220_FIXUP_GB_DUAL_CODECS, .name = "dual-codecs"},
2454 {.id = ALC1220_FIXUP_CLEVO_P950, .name = "clevo-p950"},
2459 * BIOS auto configuration
2461 /* almost identical with ALC880 parser... */
2462 static int alc882_parse_auto_config(struct hda_codec *codec)
2464 static const hda_nid_t alc882_ignore[] = { 0x1d, 0 };
2465 static const hda_nid_t alc882_ssids[] = { 0x15, 0x1b, 0x14, 0 };
2466 return alc_parse_auto_config(codec, alc882_ignore, alc882_ssids);
2471 static int patch_alc882(struct hda_codec *codec)
2473 struct alc_spec *spec;
2476 err = alc_alloc_spec(codec, 0x0b);
2482 switch (codec->core.vendor_id) {
2489 /* ALC883 and variants */
2490 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
2494 snd_hda_pick_fixup(codec, alc882_fixup_models, alc882_fixup_tbl,
2496 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
2498 alc_auto_parse_customize_define(codec);
2500 if (has_cdefine_beep(codec))
2501 spec->gen.beep_nid = 0x01;
2503 /* automatic parse from the BIOS config */
2504 err = alc882_parse_auto_config(codec);
2508 if (!spec->gen.no_analog && spec->gen.beep_nid) {
2509 err = set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
2514 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
2527 static int alc262_parse_auto_config(struct hda_codec *codec)
2529 static const hda_nid_t alc262_ignore[] = { 0x1d, 0 };
2530 static const hda_nid_t alc262_ssids[] = { 0x15, 0x1b, 0x14, 0 };
2531 return alc_parse_auto_config(codec, alc262_ignore, alc262_ssids);
2538 ALC262_FIXUP_FSC_H270,
2539 ALC262_FIXUP_FSC_S7110,
2540 ALC262_FIXUP_HP_Z200,
2542 ALC262_FIXUP_LENOVO_3000,
2544 ALC262_FIXUP_BENQ_T31,
2545 ALC262_FIXUP_INV_DMIC,
2546 ALC262_FIXUP_INTEL_BAYLEYBAY,
2549 static const struct hda_fixup alc262_fixups[] = {
2550 [ALC262_FIXUP_FSC_H270] = {
2551 .type = HDA_FIXUP_PINS,
2552 .v.pins = (const struct hda_pintbl[]) {
2553 { 0x14, 0x99130110 }, /* speaker */
2554 { 0x15, 0x0221142f }, /* front HP */
2555 { 0x1b, 0x0121141f }, /* rear HP */
2559 [ALC262_FIXUP_FSC_S7110] = {
2560 .type = HDA_FIXUP_PINS,
2561 .v.pins = (const struct hda_pintbl[]) {
2562 { 0x15, 0x90170110 }, /* speaker */
2566 .chain_id = ALC262_FIXUP_BENQ,
2568 [ALC262_FIXUP_HP_Z200] = {
2569 .type = HDA_FIXUP_PINS,
2570 .v.pins = (const struct hda_pintbl[]) {
2571 { 0x16, 0x99130120 }, /* internal speaker */
2575 [ALC262_FIXUP_TYAN] = {
2576 .type = HDA_FIXUP_PINS,
2577 .v.pins = (const struct hda_pintbl[]) {
2578 { 0x14, 0x1993e1f0 }, /* int AUX */
2582 [ALC262_FIXUP_LENOVO_3000] = {
2583 .type = HDA_FIXUP_PINCTLS,
2584 .v.pins = (const struct hda_pintbl[]) {
2585 { 0x19, PIN_VREF50 },
2589 .chain_id = ALC262_FIXUP_BENQ,
2591 [ALC262_FIXUP_BENQ] = {
2592 .type = HDA_FIXUP_VERBS,
2593 .v.verbs = (const struct hda_verb[]) {
2594 { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
2595 { 0x20, AC_VERB_SET_PROC_COEF, 0x3070 },
2599 [ALC262_FIXUP_BENQ_T31] = {
2600 .type = HDA_FIXUP_VERBS,
2601 .v.verbs = (const struct hda_verb[]) {
2602 { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
2603 { 0x20, AC_VERB_SET_PROC_COEF, 0x3050 },
2607 [ALC262_FIXUP_INV_DMIC] = {
2608 .type = HDA_FIXUP_FUNC,
2609 .v.func = alc_fixup_inv_dmic,
2611 [ALC262_FIXUP_INTEL_BAYLEYBAY] = {
2612 .type = HDA_FIXUP_FUNC,
2613 .v.func = alc_fixup_no_depop_delay,
2617 static const struct snd_pci_quirk alc262_fixup_tbl[] = {
2618 SND_PCI_QUIRK(0x103c, 0x170b, "HP Z200", ALC262_FIXUP_HP_Z200),
2619 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu Lifebook S7110", ALC262_FIXUP_FSC_S7110),
2620 SND_PCI_QUIRK(0x10cf, 0x142d, "Fujitsu Lifebook E8410", ALC262_FIXUP_BENQ),
2621 SND_PCI_QUIRK(0x10f1, 0x2915, "Tyan Thunder n6650W", ALC262_FIXUP_TYAN),
2622 SND_PCI_QUIRK(0x1734, 0x1141, "FSC ESPRIMO U9210", ALC262_FIXUP_FSC_H270),
2623 SND_PCI_QUIRK(0x1734, 0x1147, "FSC Celsius H270", ALC262_FIXUP_FSC_H270),
2624 SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000", ALC262_FIXUP_LENOVO_3000),
2625 SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_FIXUP_BENQ),
2626 SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_FIXUP_BENQ_T31),
2627 SND_PCI_QUIRK(0x8086, 0x7270, "BayleyBay", ALC262_FIXUP_INTEL_BAYLEYBAY),
2631 static const struct hda_model_fixup alc262_fixup_models[] = {
2632 {.id = ALC262_FIXUP_INV_DMIC, .name = "inv-dmic"},
2633 {.id = ALC262_FIXUP_FSC_H270, .name = "fsc-h270"},
2634 {.id = ALC262_FIXUP_FSC_S7110, .name = "fsc-s7110"},
2635 {.id = ALC262_FIXUP_HP_Z200, .name = "hp-z200"},
2636 {.id = ALC262_FIXUP_TYAN, .name = "tyan"},
2637 {.id = ALC262_FIXUP_LENOVO_3000, .name = "lenovo-3000"},
2638 {.id = ALC262_FIXUP_BENQ, .name = "benq"},
2639 {.id = ALC262_FIXUP_BENQ_T31, .name = "benq-t31"},
2640 {.id = ALC262_FIXUP_INTEL_BAYLEYBAY, .name = "bayleybay"},
2646 static int patch_alc262(struct hda_codec *codec)
2648 struct alc_spec *spec;
2651 err = alc_alloc_spec(codec, 0x0b);
2656 spec->gen.shared_mic_vref_pin = 0x18;
2658 spec->shutup = alc_eapd_shutup;
2661 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
2664 alc_update_coefex_idx(codec, 0x1a, 7, 0, 0x80);
2666 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
2668 snd_hda_pick_fixup(codec, alc262_fixup_models, alc262_fixup_tbl,
2670 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
2672 alc_auto_parse_customize_define(codec);
2674 if (has_cdefine_beep(codec))
2675 spec->gen.beep_nid = 0x01;
2677 /* automatic parse from the BIOS config */
2678 err = alc262_parse_auto_config(codec);
2682 if (!spec->gen.no_analog && spec->gen.beep_nid) {
2683 err = set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
2688 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
2700 /* bind Beep switches of both NID 0x0f and 0x10 */
2701 static int alc268_beep_switch_put(struct snd_kcontrol *kcontrol,
2702 struct snd_ctl_elem_value *ucontrol)
2704 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2708 mutex_lock(&codec->control_mutex);
2709 pval = kcontrol->private_value;
2710 kcontrol->private_value = (pval & ~0xff) | 0x0f;
2711 err = snd_hda_mixer_amp_switch_put(kcontrol, ucontrol);
2713 kcontrol->private_value = (pval & ~0xff) | 0x10;
2714 err = snd_hda_mixer_amp_switch_put(kcontrol, ucontrol);
2716 kcontrol->private_value = pval;
2717 mutex_unlock(&codec->control_mutex);
2721 static const struct snd_kcontrol_new alc268_beep_mixer[] = {
2722 HDA_CODEC_VOLUME("Beep Playback Volume", 0x1d, 0x0, HDA_INPUT),
2724 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2725 .name = "Beep Playback Switch",
2726 .subdevice = HDA_SUBDEV_AMP_FLAG,
2727 .info = snd_hda_mixer_amp_switch_info,
2728 .get = snd_hda_mixer_amp_switch_get,
2729 .put = alc268_beep_switch_put,
2730 .private_value = HDA_COMPOSE_AMP_VAL(0x0f, 3, 1, HDA_INPUT)
2734 /* set PCBEEP vol = 0, mute connections */
2735 static const struct hda_verb alc268_beep_init_verbs[] = {
2736 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2737 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2738 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2743 ALC268_FIXUP_INV_DMIC,
2744 ALC268_FIXUP_HP_EAPD,
2748 static const struct hda_fixup alc268_fixups[] = {
2749 [ALC268_FIXUP_INV_DMIC] = {
2750 .type = HDA_FIXUP_FUNC,
2751 .v.func = alc_fixup_inv_dmic,
2753 [ALC268_FIXUP_HP_EAPD] = {
2754 .type = HDA_FIXUP_VERBS,
2755 .v.verbs = (const struct hda_verb[]) {
2756 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 0},
2760 [ALC268_FIXUP_SPDIF] = {
2761 .type = HDA_FIXUP_PINS,
2762 .v.pins = (const struct hda_pintbl[]) {
2763 { 0x1e, 0x014b1180 }, /* enable SPDIF out */
2769 static const struct hda_model_fixup alc268_fixup_models[] = {
2770 {.id = ALC268_FIXUP_INV_DMIC, .name = "inv-dmic"},
2771 {.id = ALC268_FIXUP_HP_EAPD, .name = "hp-eapd"},
2772 {.id = ALC268_FIXUP_SPDIF, .name = "spdif"},
2776 static const struct snd_pci_quirk alc268_fixup_tbl[] = {
2777 SND_PCI_QUIRK(0x1025, 0x0139, "Acer TravelMate 6293", ALC268_FIXUP_SPDIF),
2778 SND_PCI_QUIRK(0x1025, 0x015b, "Acer AOA 150 (ZG5)", ALC268_FIXUP_INV_DMIC),
2779 /* below is codec SSID since multiple Toshiba laptops have the
2780 * same PCI SSID 1179:ff00
2782 SND_PCI_QUIRK(0x1179, 0xff06, "Toshiba P200", ALC268_FIXUP_HP_EAPD),
2787 * BIOS auto configuration
2789 static int alc268_parse_auto_config(struct hda_codec *codec)
2791 static const hda_nid_t alc268_ssids[] = { 0x15, 0x1b, 0x14, 0 };
2792 return alc_parse_auto_config(codec, NULL, alc268_ssids);
2797 static int patch_alc268(struct hda_codec *codec)
2799 struct alc_spec *spec;
2802 /* ALC268 has no aa-loopback mixer */
2803 err = alc_alloc_spec(codec, 0);
2808 spec->gen.beep_nid = 0x01;
2810 spec->shutup = alc_eapd_shutup;
2812 snd_hda_pick_fixup(codec, alc268_fixup_models, alc268_fixup_tbl, alc268_fixups);
2813 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
2815 /* automatic parse from the BIOS config */
2816 err = alc268_parse_auto_config(codec);
2820 if (err > 0 && !spec->gen.no_analog &&
2821 spec->gen.autocfg.speaker_pins[0] != 0x1d) {
2822 for (i = 0; i < ARRAY_SIZE(alc268_beep_mixer); i++) {
2823 if (!snd_hda_gen_add_kctl(&spec->gen, NULL,
2824 &alc268_beep_mixer[i])) {
2829 snd_hda_add_verbs(codec, alc268_beep_init_verbs);
2830 if (!query_amp_caps(codec, 0x1d, HDA_INPUT))
2831 /* override the amp caps for beep generator */
2832 snd_hda_override_amp_caps(codec, 0x1d, HDA_INPUT,
2833 (0x0c << AC_AMPCAP_OFFSET_SHIFT) |
2834 (0x0c << AC_AMPCAP_NUM_STEPS_SHIFT) |
2835 (0x07 << AC_AMPCAP_STEP_SIZE_SHIFT) |
2836 (0 << AC_AMPCAP_MUTE_SHIFT));
2839 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
2852 static const struct hda_pcm_stream alc269_44k_pcm_analog_playback = {
2853 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
2856 static const struct hda_pcm_stream alc269_44k_pcm_analog_capture = {
2857 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
2860 /* different alc269-variants */
2862 ALC269_TYPE_ALC269VA,
2863 ALC269_TYPE_ALC269VB,
2864 ALC269_TYPE_ALC269VC,
2865 ALC269_TYPE_ALC269VD,
2884 * BIOS auto configuration
2886 static int alc269_parse_auto_config(struct hda_codec *codec)
2888 static const hda_nid_t alc269_ignore[] = { 0x1d, 0 };
2889 static const hda_nid_t alc269_ssids[] = { 0, 0x1b, 0x14, 0x21 };
2890 static const hda_nid_t alc269va_ssids[] = { 0x15, 0x1b, 0x14, 0 };
2891 struct alc_spec *spec = codec->spec;
2892 const hda_nid_t *ssids;
2894 switch (spec->codec_variant) {
2895 case ALC269_TYPE_ALC269VA:
2896 case ALC269_TYPE_ALC269VC:
2897 case ALC269_TYPE_ALC280:
2898 case ALC269_TYPE_ALC284:
2899 case ALC269_TYPE_ALC293:
2900 ssids = alc269va_ssids;
2902 case ALC269_TYPE_ALC269VB:
2903 case ALC269_TYPE_ALC269VD:
2904 case ALC269_TYPE_ALC282:
2905 case ALC269_TYPE_ALC283:
2906 case ALC269_TYPE_ALC286:
2907 case ALC269_TYPE_ALC298:
2908 case ALC269_TYPE_ALC255:
2909 case ALC269_TYPE_ALC256:
2910 case ALC269_TYPE_ALC257:
2911 case ALC269_TYPE_ALC215:
2912 case ALC269_TYPE_ALC225:
2913 case ALC269_TYPE_ALC294:
2914 case ALC269_TYPE_ALC300:
2915 case ALC269_TYPE_ALC700:
2916 ssids = alc269_ssids;
2919 ssids = alc269_ssids;
2923 return alc_parse_auto_config(codec, alc269_ignore, ssids);
2926 static int find_ext_mic_pin(struct hda_codec *codec);
2928 static void alc286_shutup(struct hda_codec *codec)
2930 const struct hda_pincfg *pin;
2932 int mic_pin = find_ext_mic_pin(codec);
2933 /* don't shut up pins when unloading the driver; otherwise it breaks
2934 * the default pin setup at the next load of the driver
2936 if (codec->bus->shutdown)
2938 snd_array_for_each(&codec->init_pins, i, pin) {
2939 /* use read here for syncing after issuing each verb */
2940 if (pin->nid != mic_pin)
2941 snd_hda_codec_read(codec, pin->nid, 0,
2942 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
2944 codec->pins_shutup = 1;
2947 static void alc269vb_toggle_power_output(struct hda_codec *codec, int power_up)
2949 alc_update_coef_idx(codec, 0x04, 1 << 11, power_up ? (1 << 11) : 0);
2952 static void alc269_shutup(struct hda_codec *codec)
2954 struct alc_spec *spec = codec->spec;
2956 if (spec->codec_variant == ALC269_TYPE_ALC269VB)
2957 alc269vb_toggle_power_output(codec, 0);
2958 if (spec->codec_variant == ALC269_TYPE_ALC269VB &&
2959 (alc_get_coef0(codec) & 0x00ff) == 0x018) {
2962 alc_shutup_pins(codec);
2965 static struct coef_fw alc282_coefs[] = {
2966 WRITE_COEF(0x03, 0x0002), /* Power Down Control */
2967 UPDATE_COEF(0x05, 0xff3f, 0x0700), /* FIFO and filter clock */
2968 WRITE_COEF(0x07, 0x0200), /* DMIC control */
2969 UPDATE_COEF(0x06, 0x00f0, 0), /* Analog clock */
2970 UPDATE_COEF(0x08, 0xfffc, 0x0c2c), /* JD */
2971 WRITE_COEF(0x0a, 0xcccc), /* JD offset1 */
2972 WRITE_COEF(0x0b, 0xcccc), /* JD offset2 */
2973 WRITE_COEF(0x0e, 0x6e00), /* LDO1/2/3, DAC/ADC */
2974 UPDATE_COEF(0x0f, 0xf800, 0x1000), /* JD */
2975 UPDATE_COEF(0x10, 0xfc00, 0x0c00), /* Capless */
2976 WRITE_COEF(0x6f, 0x0), /* Class D test 4 */
2977 UPDATE_COEF(0x0c, 0xfe00, 0), /* IO power down directly */
2978 WRITE_COEF(0x34, 0xa0c0), /* ANC */
2979 UPDATE_COEF(0x16, 0x0008, 0), /* AGC MUX */
2980 UPDATE_COEF(0x1d, 0x00e0, 0), /* DAC simple content protection */
2981 UPDATE_COEF(0x1f, 0x00e0, 0), /* ADC simple content protection */
2982 WRITE_COEF(0x21, 0x8804), /* DAC ADC Zero Detection */
2983 WRITE_COEF(0x63, 0x2902), /* PLL */
2984 WRITE_COEF(0x68, 0xa080), /* capless control 2 */
2985 WRITE_COEF(0x69, 0x3400), /* capless control 3 */
2986 WRITE_COEF(0x6a, 0x2f3e), /* capless control 4 */
2987 WRITE_COEF(0x6b, 0x0), /* capless control 5 */
2988 UPDATE_COEF(0x6d, 0x0fff, 0x0900), /* class D test 2 */
2989 WRITE_COEF(0x6e, 0x110a), /* class D test 3 */
2990 UPDATE_COEF(0x70, 0x00f8, 0x00d8), /* class D test 5 */
2991 WRITE_COEF(0x71, 0x0014), /* class D test 6 */
2992 WRITE_COEF(0x72, 0xc2ba), /* classD OCP */
2993 UPDATE_COEF(0x77, 0x0f80, 0), /* classD pure DC test */
2994 WRITE_COEF(0x6c, 0xfc06), /* Class D amp control */
2998 static void alc282_restore_default_value(struct hda_codec *codec)
3000 alc_process_coef_fw(codec, alc282_coefs);
3003 static void alc282_init(struct hda_codec *codec)
3005 struct alc_spec *spec = codec->spec;
3006 hda_nid_t hp_pin = alc_get_hp_pin(spec);
3010 alc282_restore_default_value(codec);
3014 hp_pin_sense = snd_hda_jack_detect(codec, hp_pin);
3015 coef78 = alc_read_coef_idx(codec, 0x78);
3017 /* Index 0x78 Direct Drive HP AMP LPM Control 1 */
3018 /* Headphone capless set to high power mode */
3019 alc_write_coef_idx(codec, 0x78, 0x9004);
3024 snd_hda_codec_write(codec, hp_pin, 0,
3025 AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
3030 snd_hda_codec_write(codec, hp_pin, 0,
3031 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
3036 /* Headphone capless set to normal mode */
3037 alc_write_coef_idx(codec, 0x78, coef78);
3040 static void alc282_shutup(struct hda_codec *codec)
3042 struct alc_spec *spec = codec->spec;
3043 hda_nid_t hp_pin = alc_get_hp_pin(spec);
3048 alc269_shutup(codec);
3052 hp_pin_sense = snd_hda_jack_detect(codec, hp_pin);
3053 coef78 = alc_read_coef_idx(codec, 0x78);
3054 alc_write_coef_idx(codec, 0x78, 0x9004);
3059 snd_hda_codec_write(codec, hp_pin, 0,
3060 AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
3065 if (!spec->no_shutup_pins)
3066 snd_hda_codec_write(codec, hp_pin, 0,
3067 AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0);
3072 alc_auto_setup_eapd(codec, false);
3073 alc_shutup_pins(codec);
3074 alc_write_coef_idx(codec, 0x78, coef78);
3077 static struct coef_fw alc283_coefs[] = {
3078 WRITE_COEF(0x03, 0x0002), /* Power Down Control */
3079 UPDATE_COEF(0x05, 0xff3f, 0x0700), /* FIFO and filter clock */
3080 WRITE_COEF(0x07, 0x0200), /* DMIC control */
3081 UPDATE_COEF(0x06, 0x00f0, 0), /* Analog clock */
3082 UPDATE_COEF(0x08, 0xfffc, 0x0c2c), /* JD */
3083 WRITE_COEF(0x0a, 0xcccc), /* JD offset1 */
3084 WRITE_COEF(0x0b, 0xcccc), /* JD offset2 */
3085 WRITE_COEF(0x0e, 0x6fc0), /* LDO1/2/3, DAC/ADC */
3086 UPDATE_COEF(0x0f, 0xf800, 0x1000), /* JD */
3087 UPDATE_COEF(0x10, 0xfc00, 0x0c00), /* Capless */
3088 WRITE_COEF(0x3a, 0x0), /* Class D test 4 */
3089 UPDATE_COEF(0x0c, 0xfe00, 0x0), /* IO power down directly */
3090 WRITE_COEF(0x22, 0xa0c0), /* ANC */
3091 UPDATE_COEFEX(0x53, 0x01, 0x000f, 0x0008), /* AGC MUX */
3092 UPDATE_COEF(0x1d, 0x00e0, 0), /* DAC simple content protection */
3093 UPDATE_COEF(0x1f, 0x00e0, 0), /* ADC simple content protection */
3094 WRITE_COEF(0x21, 0x8804), /* DAC ADC Zero Detection */
3095 WRITE_COEF(0x2e, 0x2902), /* PLL */
3096 WRITE_COEF(0x33, 0xa080), /* capless control 2 */
3097 WRITE_COEF(0x34, 0x3400), /* capless control 3 */
3098 WRITE_COEF(0x35, 0x2f3e), /* capless control 4 */
3099 WRITE_COEF(0x36, 0x0), /* capless control 5 */
3100 UPDATE_COEF(0x38, 0x0fff, 0x0900), /* class D test 2 */
3101 WRITE_COEF(0x39, 0x110a), /* class D test 3 */
3102 UPDATE_COEF(0x3b, 0x00f8, 0x00d8), /* class D test 5 */
3103 WRITE_COEF(0x3c, 0x0014), /* class D test 6 */
3104 WRITE_COEF(0x3d, 0xc2ba), /* classD OCP */
3105 UPDATE_COEF(0x42, 0x0f80, 0x0), /* classD pure DC test */
3106 WRITE_COEF(0x49, 0x0), /* test mode */
3107 UPDATE_COEF(0x40, 0xf800, 0x9800), /* Class D DC enable */
3108 UPDATE_COEF(0x42, 0xf000, 0x2000), /* DC offset */
3109 WRITE_COEF(0x37, 0xfc06), /* Class D amp control */
3110 UPDATE_COEF(0x1b, 0x8000, 0), /* HP JD control */
3114 static void alc283_restore_default_value(struct hda_codec *codec)
3116 alc_process_coef_fw(codec, alc283_coefs);
3119 static void alc283_init(struct hda_codec *codec)
3121 struct alc_spec *spec = codec->spec;
3122 hda_nid_t hp_pin = alc_get_hp_pin(spec);
3125 alc283_restore_default_value(codec);
3131 hp_pin_sense = snd_hda_jack_detect(codec, hp_pin);
3133 /* Index 0x43 Direct Drive HP AMP LPM Control 1 */
3134 /* Headphone capless set to high power mode */
3135 alc_write_coef_idx(codec, 0x43, 0x9004);
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, PIN_OUT);
3148 /* Index 0x46 Combo jack auto switch control 2 */
3149 /* 3k pull low control for Headset jack. */
3150 alc_update_coef_idx(codec, 0x46, 3 << 12, 0);
3151 /* Headphone capless set to normal mode */
3152 alc_write_coef_idx(codec, 0x43, 0x9614);
3155 static void alc283_shutup(struct hda_codec *codec)
3157 struct alc_spec *spec = codec->spec;
3158 hda_nid_t hp_pin = alc_get_hp_pin(spec);
3162 alc269_shutup(codec);
3166 hp_pin_sense = snd_hda_jack_detect(codec, hp_pin);
3168 alc_write_coef_idx(codec, 0x43, 0x9004);
3170 /*depop hp during suspend*/
3171 alc_write_coef_idx(codec, 0x06, 0x2100);
3173 snd_hda_codec_write(codec, hp_pin, 0,
3174 AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
3179 if (!spec->no_shutup_pins)
3180 snd_hda_codec_write(codec, hp_pin, 0,
3181 AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0);
3183 alc_update_coef_idx(codec, 0x46, 0, 3 << 12);
3187 alc_auto_setup_eapd(codec, false);
3188 alc_shutup_pins(codec);
3189 alc_write_coef_idx(codec, 0x43, 0x9614);
3192 static void alc256_init(struct hda_codec *codec)
3194 struct alc_spec *spec = codec->spec;
3195 hda_nid_t hp_pin = alc_get_hp_pin(spec);
3203 hp_pin_sense = snd_hda_jack_detect(codec, hp_pin);
3208 alc_update_coefex_idx(codec, 0x57, 0x04, 0x0007, 0x1); /* Low power */
3210 snd_hda_codec_write(codec, hp_pin, 0,
3211 AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
3216 snd_hda_codec_write(codec, hp_pin, 0,
3217 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
3222 alc_update_coef_idx(codec, 0x46, 3 << 12, 0);
3223 alc_update_coefex_idx(codec, 0x57, 0x04, 0x0007, 0x4); /* Hight power */
3224 alc_update_coefex_idx(codec, 0x53, 0x02, 0x8000, 1 << 15); /* Clear bit */
3225 alc_update_coefex_idx(codec, 0x53, 0x02, 0x8000, 0 << 15);
3228 static void alc256_shutup(struct hda_codec *codec)
3230 struct alc_spec *spec = codec->spec;
3231 hda_nid_t hp_pin = alc_get_hp_pin(spec);
3235 alc269_shutup(codec);
3239 hp_pin_sense = snd_hda_jack_detect(codec, hp_pin);
3244 snd_hda_codec_write(codec, hp_pin, 0,
3245 AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
3250 /* 3k pull low control for Headset jack. */
3251 /* NOTE: call this before clearing the pin, otherwise codec stalls */
3252 alc_update_coef_idx(codec, 0x46, 0, 3 << 12);
3254 if (!spec->no_shutup_pins)
3255 snd_hda_codec_write(codec, hp_pin, 0,
3256 AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0);
3261 alc_auto_setup_eapd(codec, false);
3262 alc_shutup_pins(codec);
3265 static void alc225_init(struct hda_codec *codec)
3267 struct alc_spec *spec = codec->spec;
3268 hda_nid_t hp_pin = alc_get_hp_pin(spec);
3269 bool hp1_pin_sense, hp2_pin_sense;
3276 hp1_pin_sense = snd_hda_jack_detect(codec, hp_pin);
3277 hp2_pin_sense = snd_hda_jack_detect(codec, 0x16);
3279 if (hp1_pin_sense || hp2_pin_sense)
3282 alc_update_coefex_idx(codec, 0x57, 0x04, 0x0007, 0x1); /* Low power */
3285 snd_hda_codec_write(codec, hp_pin, 0,
3286 AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
3288 snd_hda_codec_write(codec, 0x16, 0,
3289 AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
3291 if (hp1_pin_sense || hp2_pin_sense)
3295 snd_hda_codec_write(codec, hp_pin, 0,
3296 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
3298 snd_hda_codec_write(codec, 0x16, 0,
3299 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
3301 if (hp1_pin_sense || hp2_pin_sense)
3304 alc_update_coef_idx(codec, 0x4a, 3 << 10, 0);
3305 alc_update_coefex_idx(codec, 0x57, 0x04, 0x0007, 0x4); /* Hight power */
3308 static void alc225_shutup(struct hda_codec *codec)
3310 struct alc_spec *spec = codec->spec;
3311 hda_nid_t hp_pin = alc_get_hp_pin(spec);
3312 bool hp1_pin_sense, hp2_pin_sense;
<