Lines Matching +full:codec +full:- +full:1
1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * Universal Interface for Intel High Definition Audio Codec
34 /* extra amp-initialization sequence types */
65 unsigned int enable_pcbeep:1;
66 unsigned int platform_type:1;
67 unsigned int swap:1;
68 unsigned int override:1;
69 unsigned int fixup:1; /* Means that this sku is set by driver, not read from hw */
82 /* codec parameterization */
110 void (*init_hook)(struct hda_codec *codec);
112 void (*power_hook)(struct hda_codec *codec);
114 void (*shutup)(struct hda_codec *codec);
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;
122 unsigned int ultra_low_power:1;
123 unsigned int has_hs_key:1;
124 unsigned int no_internal_mic_pin:1;
125 unsigned int en_3kpull_low:1;
132 u8 alc_mute_keycode_map[1];
143 static void coef_mutex_lock(struct hda_codec *codec)
145 struct alc_spec *spec = codec->spec;
147 snd_hda_power_up_pm(codec);
148 mutex_lock(&spec->coef_mutex);
151 static void coef_mutex_unlock(struct hda_codec *codec)
153 struct alc_spec *spec = codec->spec;
155 mutex_unlock(&spec->coef_mutex);
156 snd_hda_power_down_pm(codec);
159 static int __alc_read_coefex_idx(struct hda_codec *codec, hda_nid_t nid,
164 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_COEF_INDEX, coef_idx);
165 val = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_PROC_COEF, 0);
169 static int alc_read_coefex_idx(struct hda_codec *codec, hda_nid_t nid,
174 coef_mutex_lock(codec);
175 val = __alc_read_coefex_idx(codec, nid, coef_idx);
176 coef_mutex_unlock(codec);
180 #define alc_read_coef_idx(codec, coef_idx) \
181 alc_read_coefex_idx(codec, 0x20, coef_idx)
183 static void __alc_write_coefex_idx(struct hda_codec *codec, hda_nid_t nid,
186 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_COEF_INDEX, coef_idx);
187 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PROC_COEF, coef_val);
190 static void alc_write_coefex_idx(struct hda_codec *codec, hda_nid_t nid,
193 coef_mutex_lock(codec);
194 __alc_write_coefex_idx(codec, nid, coef_idx, coef_val);
195 coef_mutex_unlock(codec);
198 #define alc_write_coef_idx(codec, coef_idx, coef_val) \
199 alc_write_coefex_idx(codec, 0x20, coef_idx, coef_val)
201 static void __alc_update_coefex_idx(struct hda_codec *codec, hda_nid_t nid,
205 unsigned int val = __alc_read_coefex_idx(codec, nid, coef_idx);
207 if (val != -1)
208 __alc_write_coefex_idx(codec, nid, coef_idx,
212 static void alc_update_coefex_idx(struct hda_codec *codec, hda_nid_t nid,
216 coef_mutex_lock(codec);
217 __alc_update_coefex_idx(codec, nid, coef_idx, mask, bits_set);
218 coef_mutex_unlock(codec);
221 #define alc_update_coef_idx(codec, coef_idx, mask, bits_set) \
222 alc_update_coefex_idx(codec, 0x20, coef_idx, mask, bits_set)
225 static unsigned int alc_get_coef0(struct hda_codec *codec)
227 struct alc_spec *spec = codec->spec;
229 if (!spec->coef0)
230 spec->coef0 = alc_read_coef_idx(codec, 0);
231 return spec->coef0;
244 #define WRITE_COEFEX(_nid, _idx, _val) UPDATE_COEFEX(_nid, _idx, -1, _val)
248 static void alc_process_coef_fw(struct hda_codec *codec,
251 coef_mutex_lock(codec);
252 for (; fw->nid; fw++) {
253 if (fw->mask == (unsigned short)-1)
254 __alc_write_coefex_idx(codec, fw->nid, fw->idx, fw->val);
256 __alc_update_coefex_idx(codec, fw->nid, fw->idx,
257 fw->mask, fw->val);
259 coef_mutex_unlock(codec);
267 static void alc_setup_gpio(struct hda_codec *codec, unsigned int mask)
269 struct alc_spec *spec = codec->spec;
271 spec->gpio_mask |= mask;
272 spec->gpio_dir |= mask;
273 spec->gpio_data |= mask;
276 static void alc_write_gpio_data(struct hda_codec *codec)
278 struct alc_spec *spec = codec->spec;
280 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA,
281 spec->gpio_data);
284 static void alc_update_gpio_data(struct hda_codec *codec, unsigned int mask,
287 struct alc_spec *spec = codec->spec;
288 unsigned int oldval = spec->gpio_data;
291 spec->gpio_data |= mask;
293 spec->gpio_data &= ~mask;
294 if (oldval != spec->gpio_data)
295 alc_write_gpio_data(codec);
298 static void alc_write_gpio(struct hda_codec *codec)
300 struct alc_spec *spec = codec->spec;
302 if (!spec->gpio_mask)
305 snd_hda_codec_write(codec, codec->core.afg, 0,
306 AC_VERB_SET_GPIO_MASK, spec->gpio_mask);
307 snd_hda_codec_write(codec, codec->core.afg, 0,
308 AC_VERB_SET_GPIO_DIRECTION, spec->gpio_dir);
309 if (spec->gpio_write_delay)
310 msleep(1);
311 alc_write_gpio_data(codec);
314 static void alc_fixup_gpio(struct hda_codec *codec, int action,
318 alc_setup_gpio(codec, mask);
321 static void alc_fixup_gpio1(struct hda_codec *codec,
324 alc_fixup_gpio(codec, action, 0x01);
327 static void alc_fixup_gpio2(struct hda_codec *codec,
330 alc_fixup_gpio(codec, action, 0x02);
333 static void alc_fixup_gpio3(struct hda_codec *codec,
336 alc_fixup_gpio(codec, action, 0x03);
339 static void alc_fixup_gpio4(struct hda_codec *codec,
342 alc_fixup_gpio(codec, action, 0x04);
345 static void alc_fixup_micmute_led(struct hda_codec *codec,
349 snd_hda_gen_add_micmute_led_cdev(codec, NULL);
355 * the default value is 1.
357 static void alc_fix_pll(struct hda_codec *codec)
359 struct alc_spec *spec = codec->spec;
361 if (spec->pll_nid)
362 alc_update_coefex_idx(codec, spec->pll_nid, spec->pll_coef_idx,
363 1 << spec->pll_coef_bit, 0);
366 static void alc_fix_pll_init(struct hda_codec *codec, hda_nid_t nid,
369 struct alc_spec *spec = codec->spec;
370 spec->pll_nid = nid;
371 spec->pll_coef_idx = coef_idx;
372 spec->pll_coef_bit = coef_bit;
373 alc_fix_pll(codec);
376 /* update the master volume per volume-knob's unsol event */
377 static void alc_update_knob_master(struct hda_codec *codec,
384 kctl = snd_hda_find_mixer_ctl(codec, "Master Playback Volume");
390 val = snd_hda_codec_read(codec, jack->nid, 0,
393 uctl->value.integer.value[0] = val;
394 uctl->value.integer.value[1] = val;
395 kctl->put(kctl, uctl);
399 static void alc880_unsol_event(struct hda_codec *codec, unsigned int res)
403 snd_hda_jack_unsol_event(codec, res >> 2);
407 static void alc_fill_eapd_coef(struct hda_codec *codec)
411 coef = alc_get_coef0(codec);
413 switch (codec->core.vendor_id) {
415 alc_update_coef_idx(codec, 0x7, 0, 1<<5);
419 alc_update_coef_idx(codec, 0x7, 0, 1<<13);
423 alc_update_coef_idx(codec, 0xd, 0, 1<<14);
425 alc_update_coef_idx(codec, 0x4, 1<<15, 0);
427 alc_update_coef_idx(codec, 0x10, 1<<9, 0);
433 alc_update_coef_idx(codec, 0x4, 1<<15, 0);
438 alc_update_coef_idx(codec, 0x67, 0xf000, 0x3000);
443 alc_update_coef_idx(codec, 0x36, 1<<13, 0);
460 alc_update_coef_idx(codec, 0x10, 1<<9, 0);
463 alc_update_coef_idx(codec, 0xe, 0, 1<<0);
466 alc_update_coef_idx(codec, 0x10, 1<<9, 0);
467 alc_write_coef_idx(codec, 0x8, 0x4ab7);
470 alc_update_coef_idx(codec, 0xa, 1<<13, 0);
474 alc_write_coef_idx(codec, 0x6e, 0x0c25);
481 alc_update_coef_idx(codec, 0x10, 1<<15, 0);
485 alc_update_coef_idx(codec, 0x4, 1<<10, 0); /* EAPD Ctrl */
494 alc_update_coef_idx(codec, 0xd, 0, 1<<14); /* EAPD Ctrl */
498 alc_update_coef_idx(codec, 0x19, 1<<13, 0);
501 alc_update_coef_idx(codec, 0x7, 3<<13, 0);
504 alc_update_coef_idx(codec, 0x4, 1<<10, 0);
508 alc_update_coef_idx(codec, 0x7, 1<<5, 0);
512 alc_update_coef_idx(codec, 0x7, 1<<5, 0);
519 alc_update_coef_idx(codec, 0x7, 1<<1, 0);
525 static void alc888_coef_init(struct hda_codec *codec)
527 switch (alc_get_coef0(codec) & 0x00f0) {
528 /* alc888-VA */
530 /* alc888-VB */
532 alc_update_coef_idx(codec, 7, 0, 0x2030); /* Turn EAPD to High */
538 static void set_eapd(struct hda_codec *codec, hda_nid_t nid, int on)
540 if (get_wcaps_type(get_wcaps(codec, nid)) != AC_WID_PIN)
542 if (snd_hda_query_pin_caps(codec, nid) & AC_PINCAP_EAPD)
543 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
547 /* turn on/off EAPD controls of the codec */
548 static void alc_auto_setup_eapd(struct hda_codec *codec, bool on)
556 set_eapd(codec, *p, on);
559 static int find_ext_mic_pin(struct hda_codec *codec);
561 static void alc_headset_mic_no_shutup(struct hda_codec *codec)
564 int mic_pin = find_ext_mic_pin(codec);
570 if (codec->bus->shutdown)
573 snd_array_for_each(&codec->init_pins, i, pin) {
575 if (pin->nid != mic_pin)
576 snd_hda_codec_read(codec, pin->nid, 0,
580 codec->pins_shutup = 1;
583 static void alc_shutup_pins(struct hda_codec *codec)
585 struct alc_spec *spec = codec->spec;
587 switch (codec->core.vendor_id) {
599 alc_headset_mic_no_shutup(codec);
602 if (!spec->no_shutup_pins)
603 snd_hda_shutup_pins(codec);
609 * just turning off EAPD and a little pause for avoiding pop-noise
611 static void alc_eapd_shutup(struct hda_codec *codec)
613 struct alc_spec *spec = codec->spec;
615 alc_auto_setup_eapd(codec, false);
616 if (!spec->no_depop_delay)
618 alc_shutup_pins(codec);
622 static void alc_auto_init_amp(struct hda_codec *codec, int type)
624 alc_auto_setup_eapd(codec, true);
625 alc_write_gpio(codec);
628 switch (codec->core.vendor_id) {
630 alc_update_coefex_idx(codec, 0x1a, 7, 0, 0x2010);
636 alc_update_coef_idx(codec, 7, 0, 0x2030);
639 alc888_coef_init(codec);
649 if (spec->gen.autocfg.hp_pins[0])
650 return spec->gen.autocfg.hp_pins[0];
651 if (spec->gen.autocfg.line_out_type == AC_JACK_HP_OUT)
652 return spec->gen.autocfg.line_out_pins[0];
660 /* Could be any non-zero and even value. When used as fixup, tells
665 static void alc_fixup_sku_ignore(struct hda_codec *codec,
668 struct alc_spec *spec = codec->spec;
670 spec->cdefine.fixup = 1;
671 spec->cdefine.sku_cfg = ALC_FIXUP_SKU_IGNORE;
675 static void alc_fixup_no_depop_delay(struct hda_codec *codec,
678 struct alc_spec *spec = codec->spec;
681 spec->no_depop_delay = 1;
682 codec->depop_delay = 0;
686 static int alc_auto_parse_customize_define(struct hda_codec *codec)
690 struct alc_spec *spec = codec->spec;
692 spec->cdefine.enable_pcbeep = 1; /* assume always enabled */
694 if (spec->cdefine.fixup) {
695 ass = spec->cdefine.sku_cfg;
697 return -1;
701 if (!codec->bus->pci)
702 return -1;
703 ass = codec->core.subsystem_id & 0xffff;
704 if (ass != codec->bus->pci->subsystem_device && (ass & 1))
708 if (codec->core.vendor_id == 0x10ec0260)
710 ass = snd_hda_codec_get_pincfg(codec, nid);
712 if (!(ass & 1)) {
713 codec_info(codec, "%s: SKU not ready 0x%08x\n",
714 codec->core.chip_name, ass);
715 return -1;
720 for (i = 1; i < 16; i++) {
721 if ((ass >> i) & 1)
725 return -1;
727 spec->cdefine.port_connectivity = ass >> 30;
728 spec->cdefine.enable_pcbeep = (ass & 0x100000) >> 20;
729 spec->cdefine.check_sum = (ass >> 16) & 0xf;
730 spec->cdefine.customization = ass >> 8;
732 spec->cdefine.sku_cfg = ass;
733 spec->cdefine.external_amp = (ass & 0x38) >> 3;
734 spec->cdefine.platform_type = (ass & 0x4) >> 2;
735 spec->cdefine.swap = (ass & 0x2) >> 1;
736 spec->cdefine.override = ass & 0x1;
738 codec_dbg(codec, "SKU: Nid=0x%x sku_cfg=0x%08x\n",
739 nid, spec->cdefine.sku_cfg);
740 codec_dbg(codec, "SKU: port_connectivity=0x%x\n",
741 spec->cdefine.port_connectivity);
742 codec_dbg(codec, "SKU: enable_pcbeep=0x%x\n", spec->cdefine.enable_pcbeep);
743 codec_dbg(codec, "SKU: check_sum=0x%08x\n", spec->cdefine.check_sum);
744 codec_dbg(codec, "SKU: customization=0x%08x\n", spec->cdefine.customization);
745 codec_dbg(codec, "SKU: external_amp=0x%x\n", spec->cdefine.external_amp);
746 codec_dbg(codec, "SKU: platform_type=0x%x\n", spec->cdefine.platform_type);
747 codec_dbg(codec, "SKU: swap=0x%x\n", spec->cdefine.swap);
748 codec_dbg(codec, "SKU: override=0x%x\n", spec->cdefine.override);
753 /* return the position of NID in the list, or -1 if not found */
760 return -1;
768 /* check subsystem ID and set up device-specific initialization;
769 * return 1 if initialized, 0 if invalid SSID
771 /* 32-bit subsystem ID for BIOS loading in HD Audio codec.
775 * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36
777 static int alc_subsystem_id(struct hda_codec *codec, const hda_nid_t *ports)
781 struct alc_spec *spec = codec->spec;
783 if (spec->cdefine.fixup) {
784 ass = spec->cdefine.sku_cfg;
790 ass = codec->core.subsystem_id & 0xffff;
791 if (codec->bus->pci &&
792 ass != codec->bus->pci->subsystem_device && (ass & 1))
800 * 19~16 : Check sum (15:1)
801 * 15~1 : Custom
805 if (codec->core.vendor_id == 0x10ec0260)
807 ass = snd_hda_codec_get_pincfg(codec, nid);
808 codec_dbg(codec,
811 if (!(ass & 1))
813 if ((ass >> 30) != 1) /* no physical connection */
818 for (i = 1; i < 16; i++) {
819 if ((ass >> i) & 1)
825 codec_dbg(codec, "realtek: Enabling init ASM_ID=0x%04x CODEC_ID=%08x\n",
826 ass & 0xffff, codec->core.vendor_id);
829 * 1 : Swap Jack
830 * 2 : 0 --> Desktop, 1 --> Laptop
835 if (spec->init_amp == ALC_INIT_UNDEFINED) {
837 case 1:
838 alc_setup_gpio(codec, 0x01);
841 alc_setup_gpio(codec, 0x02);
844 alc_setup_gpio(codec, 0x04);
848 spec->init_amp = ALC_INIT_DEFAULT;
857 return 1;
860 * 12~11: Headphone out -> 00: PortA, 01: PortE, 02: PortD, 03: Resvered
862 * 15 : 1 --> enable the function "Mute internal speaker
869 if (found_in_nid_list(nid, spec->gen.autocfg.line_out_pins,
870 spec->gen.autocfg.line_outs))
871 return 1;
872 spec->gen.autocfg.hp_pins[0] = nid;
874 return 1;
877 /* Check the validity of ALC subsystem-id
878 * ports contains an array of 4 pin NIDs for port-A, E, D and I */
879 static void alc_ssid_check(struct hda_codec *codec, const hda_nid_t *ports)
881 if (!alc_subsystem_id(codec, ports)) {
882 struct alc_spec *spec = codec->spec;
883 if (spec->init_amp == ALC_INIT_UNDEFINED) {
884 codec_dbg(codec,
886 spec->init_amp = ALC_INIT_DEFAULT;
894 static void alc_fixup_inv_dmic(struct hda_codec *codec,
897 struct alc_spec *spec = codec->spec;
899 spec->gen.inv_dmic_split = 1;
903 static int alc_build_controls(struct hda_codec *codec)
907 err = snd_hda_gen_build_controls(codec);
911 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_BUILD);
920 static void alc_pre_init(struct hda_codec *codec)
922 alc_fill_eapd_coef(codec);
925 #define is_s3_resume(codec) \
926 ((codec)->core.dev.power.power_state.event == PM_EVENT_RESUME)
927 #define is_s4_resume(codec) \
928 ((codec)->core.dev.power.power_state.event == PM_EVENT_RESTORE)
930 static int alc_init(struct hda_codec *codec)
932 struct alc_spec *spec = codec->spec;
935 if (is_s4_resume(codec))
936 alc_pre_init(codec);
938 if (spec->init_hook)
939 spec->init_hook(codec);
941 spec->gen.skip_verbs = 1; /* applied in below */
942 snd_hda_gen_init(codec);
943 alc_fix_pll(codec);
944 alc_auto_init_amp(codec, spec->init_amp);
945 snd_hda_apply_verbs(codec); /* apply verbs here after own init */
947 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_INIT);
955 static inline void alc_shutup(struct hda_codec *codec)
957 struct alc_spec *spec = codec->spec;
959 if (!snd_hda_get_bool_hint(codec, "shutup"))
962 if (spec && spec->shutup)
963 spec->shutup(codec);
965 alc_shutup_pins(codec);
968 static void alc_power_eapd(struct hda_codec *codec)
970 alc_auto_setup_eapd(codec, false);
973 static int alc_suspend(struct hda_codec *codec)
975 struct alc_spec *spec = codec->spec;
976 alc_shutup(codec);
977 if (spec && spec->power_hook)
978 spec->power_hook(codec);
982 static int alc_resume(struct hda_codec *codec)
984 struct alc_spec *spec = codec->spec;
986 if (!spec->no_depop_delay)
988 codec->patch_ops.init(codec);
989 snd_hda_regmap_sync(codec);
990 hda_call_check_power_status(codec, 0x01);
1011 #define alc_codec_rename(codec, name) snd_hda_codec_set_name(codec, name)
1041 { 0x10ec0887, 0x00f0, 0x0030, "ALC887-VD" },
1042 { 0x10ec0888, 0x00f0, 0x0030, "ALC888-VD" },
1082 static int alc_codec_rename_from_preset(struct hda_codec *codec)
1087 for (p = rename_tbl; p->vendor_id; p++) {
1088 if (p->vendor_id != codec->core.vendor_id)
1090 if ((alc_get_coef0(codec) & p->coef_mask) == p->coef_bits)
1091 return alc_codec_rename(codec, p->name);
1094 if (!codec->bus->pci)
1096 for (q = rename_pci_tbl; q->codec_vendor_id; q++) {
1097 if (q->codec_vendor_id != codec->core.vendor_id)
1099 if (q->pci_subvendor != codec->bus->pci->subsystem_vendor)
1101 if (!q->pci_subdevice ||
1102 q->pci_subdevice == codec->bus->pci->subsystem_device)
1103 return alc_codec_rename(codec, q->name);
1111 * Digital-beep handlers
1130 knew = snd_hda_gen_add_kctl(&spec->gen, NULL,
1133 return -ENOMEM;
1134 knew->private_value = beep_amp;
1140 SND_PCI_QUIRK(0x1043, 0x103c, "ASUS", 1),
1141 SND_PCI_QUIRK(0x1043, 0x115d, "ASUS", 1),
1142 SND_PCI_QUIRK(0x1043, 0x829f, "ASUS", 1),
1143 SND_PCI_QUIRK(0x1043, 0x8376, "EeePC", 1),
1144 SND_PCI_QUIRK(0x1043, 0x83ce, "EeePC", 1),
1145 SND_PCI_QUIRK(0x1043, 0x831a, "EeePC", 1),
1146 SND_PCI_QUIRK(0x1043, 0x834a, "EeePC", 1),
1147 SND_PCI_QUIRK(0x1458, 0xa002, "GA-MA790X", 1),
1148 SND_PCI_QUIRK(0x8086, 0xd613, "Intel", 1),
1149 /* denylist -- no beep available */
1155 static inline int has_cdefine_beep(struct hda_codec *codec)
1157 struct alc_spec *spec = codec->spec;
1159 q = snd_pci_quirk_lookup(codec->bus->pci, beep_allow_list);
1161 return q->value;
1162 return spec->cdefine.enable_pcbeep;
1166 #define has_cdefine_beep(codec) 0
1170 /* return 1 if successful, 0 if the proper config is not found,
1173 static int alc_parse_auto_config(struct hda_codec *codec,
1177 struct alc_spec *spec = codec->spec;
1178 struct auto_pin_cfg *cfg = &spec->gen.autocfg;
1181 err = snd_hda_parse_pin_defcfg(codec, cfg, ignore_nids,
1182 spec->parse_flags);
1187 alc_ssid_check(codec, ssid_nids);
1189 err = snd_hda_gen_parse_auto_config(codec, cfg);
1193 return 1;
1197 static int alc_alloc_spec(struct hda_codec *codec, hda_nid_t mixer_nid)
1203 return -ENOMEM;
1204 codec->spec = spec;
1205 snd_hda_gen_spec_init(&spec->gen);
1206 spec->gen.mixer_nid = mixer_nid;
1207 spec->gen.own_eapd_ctl = 1;
1208 codec->single_adc_amp = 1;
1209 /* FIXME: do we need this for all Realtek codec models? */
1210 codec->spdif_status_reset = 1;
1211 codec->forced_resume = 1;
1212 codec->patch_ops = alc_patch_ops;
1213 mutex_init(&spec->coef_mutex);
1215 err = alc_codec_rename_from_preset(codec);
1223 static int alc880_parse_auto_config(struct hda_codec *codec)
1227 return alc_parse_auto_config(codec, alc880_ignore, alc880_ssids);
1231 * ALC880 fix-ups
1261 /* enable the volume-knob widget support on NID 0x21 */
1262 static void alc880_fixup_vol_knob(struct hda_codec *codec,
1266 snd_hda_jack_detect_enable_callback(codec, 0x21,
1302 { 0x1a, 0x0181344f }, /* line-in */
1350 { 0x19, 0x01a19950 }, /* mic-in */
1370 { 0x19, 0x01a19950 }, /* mic-in */
1410 { 0x18, 0x01a19950 }, /* mic-in */
1412 { 0x1a, 0x01813031 }, /* line-in */
1443 { 0x14, 0x01014010 }, /* line-out */
1447 { 0x18, 0x01a19c30 }, /* mic-in */
1449 { 0x1a, 0x01813031 }, /* line-in */
1450 { 0x1b, 0x02a19c40 }, /* front-mic */
1483 { 0x18, 0x01a19c30 }, /* mic-in */
1485 { 0x1a, 0x01813031 }, /* line-in */
1486 { 0x1b, 0x02a19c40 }, /* front-mic */
1519 { 0x18, 0x01a19c30 }, /* mic-in */
1520 { 0x19, 0x02a19c40 }, /* front-mic */
1521 { 0x1a, 0x01813031 }, /* line-in */
1585 * It's not quite sure whether BIOS sets the correct pin-config table
1610 SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_FIXUP_5ST_DIG),
1625 SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_FIXUP_5ST_DIG),
1632 {.id = ALC880_FIXUP_3ST_DIG, .name = "3stack-digout"},
1634 {.id = ALC880_FIXUP_5ST_DIG, .name = "5stack-digout"},
1636 {.id = ALC880_FIXUP_6ST_DIG, .name = "6stack-digout"},
1637 {.id = ALC880_FIXUP_6ST_AUTOMUTE, .name = "6stack-automute"},
1645 static int patch_alc880(struct hda_codec *codec)
1650 err = alc_alloc_spec(codec, 0x0b);
1654 spec = codec->spec;
1655 spec->gen.need_dac_fix = 1;
1656 spec->gen.beep_nid = 0x01;
1658 codec->patch_ops.unsol_event = alc880_unsol_event;
1660 alc_pre_init(codec);
1662 snd_hda_pick_fixup(codec, alc880_fixup_models, alc880_fixup_tbl,
1664 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
1667 err = alc880_parse_auto_config(codec);
1671 if (!spec->gen.no_analog) {
1677 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
1682 alc_free(codec);
1690 static int alc260_parse_auto_config(struct hda_codec *codec)
1694 return alc_parse_auto_config(codec, alc260_ignore, alc260_ssids);
1714 static void alc260_gpio1_automute(struct hda_codec *codec)
1716 struct alc_spec *spec = codec->spec;
1718 alc_update_gpio_data(codec, 0x01, spec->gen.hp_jack_present);
1721 static void alc260_fixup_gpio1_toggle(struct hda_codec *codec,
1724 struct alc_spec *spec = codec->spec;
1729 spec->gen.automute_hook = alc260_gpio1_automute;
1730 spec->gen.detect_hp = 1;
1731 spec->gen.automute_speaker = 1;
1732 spec->gen.autocfg.hp_pins[0] = 0x0f; /* copy it for automute */
1733 snd_hda_jack_detect_enable_callback(codec, 0x0f,
1735 alc_setup_gpio(codec, 0x01);
1739 static void alc260_fixup_kn1(struct hda_codec *codec,
1742 struct alc_spec *spec = codec->spec;
1761 snd_hda_apply_pincfgs(codec, pincfgs);
1762 spec->init_amp = ALC_INIT_NONE;
1767 static void alc260_fixup_fsc_s7020(struct hda_codec *codec,
1770 struct alc_spec *spec = codec->spec;
1772 spec->init_amp = ALC_INIT_NONE;
1775 static void alc260_fixup_fsc_s7020_jwse(struct hda_codec *codec,
1778 struct alc_spec *spec = codec->spec;
1780 spec->gen.add_jack_modes = 1;
1781 spec->gen.hp_mic = 1;
1888 {.id = ALC260_FIXUP_FSC_S7020_JWSE, .name = "fujitsu-jwse"},
1894 static int patch_alc260(struct hda_codec *codec)
1899 err = alc_alloc_spec(codec, 0x07);
1903 spec = codec->spec;
1908 spec->gen.prefer_hp_amp = 1;
1909 spec->gen.beep_nid = 0x01;
1911 spec->shutup = alc_eapd_shutup;
1913 alc_pre_init(codec);
1915 snd_hda_pick_fixup(codec, alc260_fixup_models, alc260_fixup_tbl,
1917 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
1920 err = alc260_parse_auto_config(codec);
1924 if (!spec->gen.no_analog) {
1930 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
1935 alc_free(codec);
1946 * 6-channel independent captures.
1948 * In addition, an independent DAC for the multi-playback (not used in this
2000 static void alc889_fixup_coef(struct hda_codec *codec,
2005 alc_update_coef_idx(codec, 7, 0, 0x2030);
2009 static void alc885_fixup_macpro_gpio(struct hda_codec *codec,
2012 struct alc_spec *spec = codec->spec;
2014 spec->gpio_write_delay = true;
2015 alc_fixup_gpio3(codec, fix, action);
2022 static void alc889_fixup_dac_route(struct hda_codec *codec,
2029 snd_hda_override_conn_list(codec, 0x14, ARRAY_SIZE(conn1), conn1);
2030 snd_hda_override_conn_list(codec, 0x15, ARRAY_SIZE(conn1), conn1);
2031 snd_hda_override_conn_list(codec, 0x18, ARRAY_SIZE(conn2), conn2);
2032 snd_hda_override_conn_list(codec, 0x1a, ARRAY_SIZE(conn2), conn2);
2036 snd_hda_override_conn_list(codec, 0x14, ARRAY_SIZE(conn), conn);
2037 snd_hda_override_conn_list(codec, 0x15, ARRAY_SIZE(conn), conn);
2038 snd_hda_override_conn_list(codec, 0x18, ARRAY_SIZE(conn), conn);
2039 snd_hda_override_conn_list(codec, 0x1a, ARRAY_SIZE(conn), conn);
2044 static void alc889_fixup_mbp_vref(struct hda_codec *codec,
2048 struct alc_spec *spec = codec->spec;
2054 unsigned int val = snd_hda_codec_get_pincfg(codec, nids[i]);
2057 val = snd_hda_codec_get_pin_target(codec, nids[i]);
2059 snd_hda_set_pin_ctl(codec, nids[i], val);
2060 spec->gen.keep_vref_in_automute = 1;
2065 static void alc889_fixup_mac_pins(struct hda_codec *codec,
2068 struct alc_spec *spec = codec->spec;
2073 val = snd_hda_codec_get_pin_target(codec, nids[i]);
2075 snd_hda_set_pin_ctl(codec, nids[i], val);
2077 spec->gen.keep_vref_in_automute = 1;
2081 static void alc889_fixup_imac91_vref(struct hda_codec *codec,
2087 alc889_fixup_mac_pins(codec, nids, ARRAY_SIZE(nids));
2091 static void alc889_fixup_mba11_vref(struct hda_codec *codec,
2097 alc889_fixup_mac_pins(codec, nids, ARRAY_SIZE(nids));
2101 static void alc889_fixup_mba21_vref(struct hda_codec *codec,
2107 alc889_fixup_mac_pins(codec, nids, ARRAY_SIZE(nids));
2112 * all-in-one desktop PCs (for example VGC-LN51JGB) through DAC 0x05
2114 static void alc882_fixup_no_primary_hp(struct hda_codec *codec,
2117 struct alc_spec *spec = codec->spec;
2119 spec->gen.no_primary_hp = 1;
2120 spec->gen.no_multi_io = 1;
2124 static void alc_fixup_bass_chmap(struct hda_codec *codec,
2127 /* For dual-codec configuration, we need to disable some features to avoid
2130 static void alc_fixup_dual_codecs(struct hda_codec *codec,
2133 struct alc_spec *spec = codec->spec;
2138 spec->gen.suppress_vmaster = 1;
2139 /* auto-mute and auto-mic switch don't work with multiple codecs */
2140 spec->gen.suppress_auto_mute = 1;
2141 spec->gen.suppress_auto_mic = 1;
2143 spec->gen.mixer_nid = 0;
2145 codec->force_pin_prefix = 1;
2148 static void rename_ctl(struct hda_codec *codec, const char *oldname,
2153 kctl = snd_hda_find_mixer_ctl(codec, oldname);
2155 snd_ctl_rename(codec->card, kctl, newname);
2158 static void alc1220_fixup_gb_dual_codecs(struct hda_codec *codec,
2162 alc_fixup_dual_codecs(codec, fix, action);
2166 strcpy(codec->card->longname, "HDAudio-Gigabyte-ALC1220DualCodecs");
2169 /* rename Capture controls depending on the codec */
2170 rename_ctl(codec, "Capture Volume",
2171 codec->addr == 0 ?
2172 "Rear-Panel Capture Volume" :
2173 "Front-Panel Capture Volume");
2174 rename_ctl(codec, "Capture Switch",
2175 codec->addr == 0 ?
2176 "Rear-Panel Capture Switch" :
2177 "Front-Panel Capture Switch");
2182 static void alc1220_fixup_gb_x570(struct hda_codec *codec,
2197 snd_hda_override_conn_list(codec, 0x14, ARRAY_SIZE(conn1), conn1);
2198 snd_hda_override_conn_list(codec, 0x1b, ARRAY_SIZE(conn1), conn1);
2201 alc_process_coef_fw(codec, gb_x570_coefs);
2206 static void alc1220_fixup_clevo_p950(struct hda_codec *codec,
2215 alc_update_coef_idx(codec, 0x7, 0, 0x3c3);
2219 snd_hda_override_conn_list(codec, 0x14, ARRAY_SIZE(conn1), conn1);
2220 snd_hda_override_conn_list(codec, 0x1b, ARRAY_SIZE(conn1), conn1);
2223 static void alc_fixup_headset_mode_no_hp_mic(struct hda_codec *codec,
2226 static void alc1220_fixup_clevo_pb51ed(struct hda_codec *codec,
2230 alc1220_fixup_clevo_p950(codec, fix, action);
2231 alc_fixup_headset_mode_no_hp_mic(codec, fix, action);
2234 static void alc887_asus_hp_automute_hook(struct hda_codec *codec,
2237 struct alc_spec *spec = codec->spec;
2240 snd_hda_gen_hp_automute(codec, jack);
2242 if (spec->gen.hp_jack_present)
2246 snd_hda_set_pin_ctl(codec, 0x19, PIN_HP | vref);
2249 static void alc887_fixup_asus_jack(struct hda_codec *codec,
2252 struct alc_spec *spec = codec->spec;
2255 snd_hda_set_pin_ctl_cache(codec, 0x1b, PIN_HP);
2256 spec->gen.hp_automute_hook = alc887_asus_hp_automute_hook;
2409 /* DAC DISABLE/MUTE 1? */
2410 /* setting bits 1-5 disables DAC nids 0x02-0x06
2421 * The mics are only 1cm apart which makes the stereo
2426 * codec replicate the sum signal to both channels,
2578 SND_PCI_QUIRK(0x1025, 0x0155, "Packard-Bell M5120", ALC882_FIXUP_PB_M5210),
2595 SND_PCI_QUIRK(0x1043, 0x8797, "ASUS TUF B550M-PLUS", ALCS1200A_FIXUP_MIC_VREF),
2596 SND_PCI_QUIRK(0x104d, 0x9043, "Sony Vaio VGC-LN51JGB", ALC882_FIXUP_NO_PRIMARY_HP),
2602 /* All Apple entries are in codec SSIDs */
2603 SND_PCI_QUIRK(0x106b, 0x00a0, "MacBookPro 3,1", ALC889_FIXUP_MBP_VREF),
2605 SND_PCI_QUIRK(0x106b, 0x00a4, "MacbookPro 4,1", ALC889_FIXUP_MBP_VREF),
2611 SND_PCI_QUIRK(0x106b, 0x3200, "iMac 7,1 Aluminum", ALC882_FIXUP_EAPD),
2612 SND_PCI_QUIRK(0x106b, 0x3400, "MacBookAir 1,1", ALC889_FIXUP_MBA11_VREF),
2613 SND_PCI_QUIRK(0x106b, 0x3500, "MacBookAir 2,1", ALC889_FIXUP_MBA21_VREF),
2614 SND_PCI_QUIRK(0x106b, 0x3600, "Macbook 3,1", ALC889_FIXUP_MBP_VREF),
2615 SND_PCI_QUIRK(0x106b, 0x3800, "MacbookPro 4,1", ALC889_FIXUP_MBP_VREF),
2617 SND_PCI_QUIRK(0x106b, 0x3f00, "Macbook 5,1", ALC889_FIXUP_IMAC91_VREF),
2618 SND_PCI_QUIRK(0x106b, 0x4000, "MacbookPro 5,1", ALC889_FIXUP_IMAC91_VREF),
2619 SND_PCI_QUIRK(0x106b, 0x4100, "Macmini 3,1", ALC889_FIXUP_IMAC91_VREF),
2620 SND_PCI_QUIRK(0x106b, 0x4200, "Mac Pro 4,1/5,1", ALC889_FIXUP_MP41_VREF),
2621 SND_PCI_QUIRK(0x106b, 0x4300, "iMac 9,1", ALC889_FIXUP_IMAC91_VREF),
2623 SND_PCI_QUIRK(0x106b, 0x4900, "iMac 9,1 Aluminum", ALC889_FIXUP_IMAC91_VREF),
2628 SND_PCI_QUIRK(0x13fe, 0x1009, "Advantech MIT-W101", ALC886_FIXUP_EAPD),
2629 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte EP45-DS3/Z87X-UD3H", ALC889_FIXUP_FRONT_HP_NO_PRESENCE),
2630 SND_PCI_QUIRK(0x1458, 0xa0b8, "Gigabyte AZ370-Gaming", ALC1220_FIXUP_GB_DUAL_CODECS),
2634 SND_PCI_QUIRK(0x1462, 0x11f7, "MSI-GE63", ALC1220_FIXUP_CLEVO_P950),
2635 SND_PCI_QUIRK(0x1462, 0x1228, "MSI-GP63", ALC1220_FIXUP_CLEVO_P950),
2636 SND_PCI_QUIRK(0x1462, 0x1229, "MSI-GP73", ALC1220_FIXUP_CLEVO_P950),
2637 SND_PCI_QUIRK(0x1462, 0x1275, "MSI-GL63", ALC1220_FIXUP_CLEVO_P950),
2638 SND_PCI_QUIRK(0x1462, 0x1276, "MSI-GL73", ALC1220_FIXUP_CLEVO_P950),
2639 SND_PCI_QUIRK(0x1462, 0x1293, "MSI-GP65", ALC1220_FIXUP_CLEVO_P950),
2640 SND_PCI_QUIRK(0x1462, 0x7350, "MSI-7350", ALC889_FIXUP_CD),
2642 SND_PCI_QUIRK(0x1462, 0xda57, "MSI Z270-Gaming", ALC1220_FIXUP_GB_DUAL_CODECS),
2644 SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", ALC882_FIXUP_ABIT_AW9D_MAX),
2650 SND_PCI_QUIRK(0x1558, 0x65e5, "Clevo PC50D[PRS](?:-D|-G)?", ALC1220_FIXUP_CLEVO_PB51ED_PINS),
2654 SND_PCI_QUIRK(0x1558, 0x66a6, "Clevo PE60SN[CDE]-[GS]", ALC1220_FIXUP_CLEVO_PB51ED_PINS),
2657 SND_PCI_QUIRK(0x1558, 0x67e5, "Clevo PC70D[PRS](?:-D|-G)?", ALC1220_FIXUP_CLEVO_PB51ED_PINS),
2662 SND_PCI_QUIRK(0x1558, 0x7715, "Clevo X170KM-G", ALC1220_FIXUP_CLEVO_PB51ED),
2672 SND_PCI_QUIRK(0x1558, 0x96e1, "Clevo P960[ER][CDFN]-K", ALC1220_FIXUP_CLEVO_P950),
2674 SND_PCI_QUIRK(0x1558, 0x97e2, "Clevo P970RC-M", ALC1220_FIXUP_CLEVO_P950),
2684 {.id = ALC882_FIXUP_ABIT_AW9D_MAX, .name = "abit-aw9d"},
2685 {.id = ALC882_FIXUP_LENOVO_Y530, .name = "lenovo-y530"},
2686 {.id = ALC882_FIXUP_ACER_ASPIRE_7736, .name = "acer-aspire-7736"},
2687 {.id = ALC882_FIXUP_ASUS_W90V, .name = "asus-w90v"},
2689 {.id = ALC889_FIXUP_FRONT_HP_NO_PRESENCE, .name = "no-front-hp"},
2690 {.id = ALC889_FIXUP_VAIO_TT, .name = "vaio-tt"},
2692 {.id = ALC882_FIXUP_EAPD, .name = "alc882-eapd"},
2693 {.id = ALC883_FIXUP_EAPD, .name = "alc883-eapd"},
2697 {.id = ALC889_FIXUP_COEF, .name = "alc889-coef"},
2698 {.id = ALC882_FIXUP_ASUS_W2JC, .name = "asus-w2jc"},
2699 {.id = ALC882_FIXUP_ACER_ASPIRE_4930G, .name = "acer-aspire-4930g"},
2700 {.id = ALC882_FIXUP_ACER_ASPIRE_8930G, .name = "acer-aspire-8930g"},
2701 {.id = ALC883_FIXUP_ACER_EAPD, .name = "acer-aspire"},
2702 {.id = ALC885_FIXUP_MACPRO_GPIO, .name = "macpro-gpio"},
2703 {.id = ALC889_FIXUP_DAC_ROUTE, .name = "dac-route"},
2704 {.id = ALC889_FIXUP_MBP_VREF, .name = "mbp-vref"},
2705 {.id = ALC889_FIXUP_IMAC91_VREF, .name = "imac91-vref"},
2706 {.id = ALC889_FIXUP_MBA11_VREF, .name = "mba11-vref"},
2707 {.id = ALC889_FIXUP_MBA21_VREF, .name = "mba21-vref"},
2708 {.id = ALC889_FIXUP_MP11_VREF, .name = "mp11-vref"},
2709 {.id = ALC889_FIXUP_MP41_VREF, .name = "mp41-vref"},
2710 {.id = ALC882_FIXUP_INV_DMIC, .name = "inv-dmic"},
2711 {.id = ALC882_FIXUP_NO_PRIMARY_HP, .name = "no-primary-hp"},
2712 {.id = ALC887_FIXUP_ASUS_BASS, .name = "asus-bass"},
2713 {.id = ALC1220_FIXUP_GB_DUAL_CODECS, .name = "dual-codecs"},
2714 {.id = ALC1220_FIXUP_GB_X570, .name = "gb-x570"},
2715 {.id = ALC1220_FIXUP_CLEVO_P950, .name = "clevo-p950"},
2729 SND_HDA_PIN_QUIRK(0x10ec1220, 0x1462, "MS-7C35", ALC1220_FIXUP_CLEVO_P950,
2745 static int alc882_parse_auto_config(struct hda_codec *codec)
2749 return alc_parse_auto_config(codec, alc882_ignore, alc882_ssids);
2754 static int patch_alc882(struct hda_codec *codec)
2759 err = alc_alloc_spec(codec, 0x0b);
2763 spec = codec->spec;
2765 switch (codec->core.vendor_id) {
2774 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
2778 alc_pre_init(codec);
2780 snd_hda_pick_fixup(codec, alc882_fixup_models, alc882_fixup_tbl,
2782 snd_hda_pick_pin_fixup(codec, alc882_pin_fixup_tbl, alc882_fixups, true);
2783 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
2785 alc_auto_parse_customize_define(codec);
2787 if (has_cdefine_beep(codec))
2788 spec->gen.beep_nid = 0x01;
2791 err = alc882_parse_auto_config(codec);
2795 if (!spec->gen.no_analog && spec->gen.beep_nid) {
2801 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
2806 alc_free(codec);
2814 static int alc262_parse_auto_config(struct hda_codec *codec)
2818 return alc_parse_auto_config(codec, alc262_ignore, alc262_ssids);
2913 SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_FIXUP_BENQ_T31),
2919 {.id = ALC262_FIXUP_INV_DMIC, .name = "inv-dmic"},
2920 {.id = ALC262_FIXUP_FSC_H270, .name = "fsc-h270"},
2921 {.id = ALC262_FIXUP_FSC_S7110, .name = "fsc-s7110"},
2922 {.id = ALC262_FIXUP_HP_Z200, .name = "hp-z200"},
2924 {.id = ALC262_FIXUP_LENOVO_3000, .name = "lenovo-3000"},
2926 {.id = ALC262_FIXUP_BENQ_T31, .name = "benq-t31"},
2933 static int patch_alc262(struct hda_codec *codec)
2938 err = alc_alloc_spec(codec, 0x0b);
2942 spec = codec->spec;
2943 spec->gen.shared_mic_vref_pin = 0x18;
2945 spec->shutup = alc_eapd_shutup;
2949 * under-run
2951 alc_update_coefex_idx(codec, 0x1a, 7, 0, 0x80);
2953 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
2955 alc_pre_init(codec);
2957 snd_hda_pick_fixup(codec, alc262_fixup_models, alc262_fixup_tbl,
2959 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
2961 alc_auto_parse_customize_define(codec);
2963 if (has_cdefine_beep(codec))
2964 spec->gen.beep_nid = 0x01;
2967 err = alc262_parse_auto_config(codec);
2971 if (!spec->gen.no_analog && spec->gen.beep_nid) {
2977 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
2982 alc_free(codec);
2993 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2997 mutex_lock(&codec->control_mutex);
2998 pval = kcontrol->private_value;
2999 kcontrol->private_value = (pval & ~0xff) | 0x0f;
3002 kcontrol->private_value = (pval & ~0xff) | 0x10;
3005 kcontrol->private_value = pval;
3006 mutex_unlock(&codec->control_mutex);
3019 .private_value = HDA_COMPOSE_AMP_VAL(0x0f, 3, 1, HDA_INPUT)
3026 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3027 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3059 {.id = ALC268_FIXUP_INV_DMIC, .name = "inv-dmic"},
3060 {.id = ALC268_FIXUP_HP_EAPD, .name = "hp-eapd"},
3068 /* below is codec SSID since multiple Toshiba laptops have the
3078 static int alc268_parse_auto_config(struct hda_codec *codec)
3081 return alc_parse_auto_config(codec, NULL, alc268_ssids);
3086 static int patch_alc268(struct hda_codec *codec)
3091 /* ALC268 has no aa-loopback mixer */
3092 err = alc_alloc_spec(codec, 0);
3096 spec = codec->spec;
3097 if (has_cdefine_beep(codec))
3098 spec->gen.beep_nid = 0x01;
3100 spec->shutup = alc_eapd_shutup;
3102 alc_pre_init(codec);
3104 snd_hda_pick_fixup(codec, alc268_fixup_models, alc268_fixup_tbl, alc268_fixups);
3105 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
3108 err = alc268_parse_auto_config(codec);
3112 if (err > 0 && !spec->gen.no_analog &&
3113 spec->gen.autocfg.speaker_pins[0] != 0x1d) {
3115 if (!snd_hda_gen_add_kctl(&spec->gen, NULL,
3117 err = -ENOMEM;
3121 snd_hda_add_verbs(codec, alc268_beep_init_verbs);
3122 if (!query_amp_caps(codec, 0x1d, HDA_INPUT))
3124 snd_hda_override_amp_caps(codec, 0x1d, HDA_INPUT,
3131 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
3136 alc_free(codec);
3152 /* different alc269-variants */
3181 static int alc269_parse_auto_config(struct hda_codec *codec)
3186 struct alc_spec *spec = codec->spec;
3189 switch (spec->codec_variant) {
3221 return alc_parse_auto_config(codec, alc269_ignore, ssids);
3232 static void alc_headset_btn_callback(struct hda_codec *codec,
3237 if (jack->unsol_res & (7 << 13))
3240 if (jack->unsol_res & (1 << 16 | 3 << 8))
3244 if (jack->unsol_res & (7 << 23))
3248 if (jack->unsol_res & (7 << 10))
3251 snd_hda_jack_set_button_state(codec, jack->nid, report);
3254 static void alc_disable_headset_jack_key(struct hda_codec *codec)
3256 struct alc_spec *spec = codec->spec;
3258 if (!spec->has_hs_key)
3261 switch (codec->core.vendor_id) {
3269 alc_write_coef_idx(codec, 0x48, 0x0);
3270 alc_update_coef_idx(codec, 0x49, 0x0045, 0x0);
3271 alc_update_coef_idx(codec, 0x44, 0x0045 << 8, 0x0);
3278 alc_write_coef_idx(codec, 0x48, 0x0);
3279 alc_update_coef_idx(codec, 0x49, 0x0045, 0x0);
3284 static void alc_enable_headset_jack_key(struct hda_codec *codec)
3286 struct alc_spec *spec = codec->spec;
3288 if (!spec->has_hs_key)
3291 switch (codec->core.vendor_id) {
3299 alc_write_coef_idx(codec, 0x48, 0xd011);
3300 alc_update_coef_idx(codec, 0x49, 0x007f, 0x0045);
3301 alc_update_coef_idx(codec, 0x44, 0x007f << 8, 0x0045 << 8);
3308 alc_write_coef_idx(codec, 0x48, 0xd011);
3309 alc_update_coef_idx(codec, 0x49, 0x007f, 0x0045);
3314 static void alc_fixup_headset_jack(struct hda_codec *codec,
3317 struct alc_spec *spec = codec->spec;
3322 spec->has_hs_key = 1;
3323 snd_hda_jack_detect_enable_callback(codec, 0x55,
3328 if (!hp_pin || snd_hda_jack_bind_keymap(codec, 0x55,
3331 snd_hda_jack_add_kctl(codec, 0x55, "Headset Jack",
3335 alc_enable_headset_jack_key(codec);
3340 static void alc269vb_toggle_power_output(struct hda_codec *codec, int power_up)
3342 alc_update_coef_idx(codec, 0x04, 1 << 11, power_up ? (1 << 11) : 0);
3345 static void alc269_shutup(struct hda_codec *codec)
3347 struct alc_spec *spec = codec->spec;
3349 if (spec->codec_variant == ALC269_TYPE_ALC269VB)
3350 alc269vb_toggle_power_output(codec, 0);
3351 if (spec->codec_variant == ALC269_TYPE_ALC269VB &&
3352 (alc_get_coef0(codec) & 0x00ff) == 0x018) {
3355 alc_shutup_pins(codec);
3391 static void alc282_restore_default_value(struct hda_codec *codec)
3393 alc_process_coef_fw(codec, alc282_coefs);
3396 static void alc282_init(struct hda_codec *codec)
3398 struct alc_spec *spec = codec->spec;
3403 alc282_restore_default_value(codec);
3407 hp_pin_sense = snd_hda_jack_detect(codec, hp_pin);
3408 coef78 = alc_read_coef_idx(codec, 0x78);
3410 /* Index 0x78 Direct Drive HP AMP LPM Control 1 */
3412 alc_write_coef_idx(codec, 0x78, 0x9004);
3417 snd_hda_codec_write(codec, hp_pin, 0,
3423 snd_hda_codec_write(codec, hp_pin, 0,
3430 alc_write_coef_idx(codec, 0x78, coef78);
3433 static void alc282_shutup(struct hda_codec *codec)
3435 struct alc_spec *spec = codec->spec;
3441 alc269_shutup(codec);
3445 hp_pin_sense = snd_hda_jack_detect(codec, hp_pin);
3446 coef78 = alc_read_coef_idx(codec, 0x78);
3447 alc_write_coef_idx(codec, 0x78, 0x9004);
3452 snd_hda_codec_write(codec, hp_pin, 0,
3458 if (!spec->no_shutup_pins)
3459 snd_hda_codec_write(codec, hp_pin, 0,
3465 alc_auto_setup_eapd(codec, false);
3466 alc_shutup_pins(codec);
3467 alc_write_coef_idx(codec, 0x78, coef78);
3507 static void alc283_restore_default_value(struct hda_codec *codec)
3509 alc_process_coef_fw(codec, alc283_coefs);
3512 static void alc283_init(struct hda_codec *codec)
3514 struct alc_spec *spec = codec->spec;
3518 alc283_restore_default_value(codec);
3524 hp_pin_sense = snd_hda_jack_detect(codec, hp_pin);
3526 /* Index 0x43 Direct Drive HP AMP LPM Control 1 */
3528 alc_write_coef_idx(codec, 0x43, 0x9004);
3530 snd_hda_codec_write(codec, hp_pin, 0,
3536 snd_hda_codec_write(codec, hp_pin, 0,
3543 alc_update_coef_idx(codec, 0x46, 3 << 12, 0);
3545 alc_write_coef_idx(codec, 0x43, 0x9614);
3548 static void alc283_shutup(struct hda_codec *codec)
3550 struct alc_spec *spec = codec->spec;
3555 alc269_shutup(codec);
3559 hp_pin_sense = snd_hda_jack_detect(codec, hp_pin);
3561 alc_write_coef_idx(codec, 0x43, 0x9004);
3564 alc_write_coef_idx(codec, 0x06, 0x2100);
3566 snd_hda_codec_write(codec, hp_pin, 0,
3572 if (!spec->no_shutup_pins)
3573 snd_hda_codec_write(codec, hp_pin, 0,
3576 alc_update_coef_idx(codec, 0x46, 0, 3 << 12);
3580 alc_auto_setup_eapd(codec, false);
3581 alc_shutup_pins(codec);
3582 alc_write_coef_idx(codec, 0x43, 0x9614);
3585 static void alc256_init(struct hda_codec *codec)
3587 struct alc_spec *spec = codec->spec;
3591 if (spec->ultra_low_power) {
3592 alc_update_coef_idx(codec, 0x03, 1<<1, 1<<1);
3593 alc_update_coef_idx(codec, 0x08, 3<<2, 3<<2);
3594 alc_update_coef_idx(codec, 0x08, 7<<4, 0);
3595 alc_update_coef_idx(codec, 0x3b, 1<<15, 0);
3596 alc_update_coef_idx(codec, 0x0e, 7<<6, 7<<6);
3605 hp_pin_sense = snd_hda_jack_detect(codec, hp_pin);
3609 alc_update_coefex_idx(codec, 0x57, 0x04, 0x0007, 0x1); /* Low power */
3611 snd_hda_codec_write(codec, hp_pin, 0,
3616 snd_hda_codec_write(codec, hp_pin, 0,
3620 alc_update_coefex_idx(codec, 0x57, 0x04, 0x0007, 0x4); /* Hight power */
3622 alc_update_coef_idx(codec, 0x46, 3 << 12, 0);
3623 alc_update_coefex_idx(codec, 0x53, 0x02, 0x8000, 1 << 15); /* Clear bit */
3624 alc_update_coefex_idx(codec, 0x53, 0x02, 0x8000, 0 << 15);
3627 * of PC Beep on 1Ah, and disable 1Ah loopback for all outputs. See
3628 * Documentation/sound/hd-audio/realtek-pc-beep.rst for details of
3631 alc_write_coef_idx(codec, 0x36, 0x5757);
3634 static void alc256_shutup(struct hda_codec *codec)
3636 struct alc_spec *spec = codec->spec;
3643 alc_update_coefex_idx(codec, 0x57, 0x04, 0x0007, 0x1); /* Low power */
3644 hp_pin_sense = snd_hda_jack_detect(codec, hp_pin);
3649 snd_hda_codec_write(codec, hp_pin, 0,
3655 /* NOTE: call this before clearing the pin, otherwise codec stalls */
3657 * when booting with headset plugged. So skip setting it for the codec alc257
3659 if (spec->en_3kpull_low)
3660 alc_update_coef_idx(codec, 0x46, 0, 3 << 12);
3662 if (!spec->no_shutup_pins)
3663 snd_hda_codec_write(codec, hp_pin, 0,
3669 alc_auto_setup_eapd(codec, false);
3670 alc_shutup_pins(codec);
3671 if (spec->ultra_low_power) {
3673 alc_update_coef_idx(codec, 0x03, 1<<1, 0);
3674 alc_update_coef_idx(codec, 0x08, 7<<4, 7<<4);
3675 alc_update_coef_idx(codec, 0x08, 3<<2, 0);
3676 alc_update_coef_idx(codec, 0x3b, 1<<15, 1<<15);
3677 alc_update_coef_idx(codec, 0x0e, 7<<6, 0);
3682 static void alc285_hp_init(struct hda_codec *codec)
3684 struct alc_spec *spec = codec->spec;
3689 alc_write_coefex_idx(codec, 0x58, 0x00, 0x1888); /* write default value */
3690 alc_update_coef_idx(codec, 0x4a, 1<<15, 1<<15); /* Reset HP JD */
3691 coef38 = alc_read_coef_idx(codec, 0x38); /* Amp control */
3692 coef0d = alc_read_coef_idx(codec, 0x0d); /* Digital Misc control */
3693 coef36 = alc_read_coef_idx(codec, 0x36); /* Passthrough Control */
3694 alc_update_coef_idx(codec, 0x38, 1<<4, 0x0);
3695 alc_update_coef_idx(codec, 0x0d, 0x110, 0x0);
3697 alc_update_coef_idx(codec, 0x67, 0xf000, 0x3000);
3700 snd_hda_codec_write(codec, hp_pin, 0,
3704 alc_update_coef_idx(codec, 0x36, 1<<14, 1<<14);
3705 alc_update_coef_idx(codec, 0x36, 1<<13, 0x0);
3708 snd_hda_codec_write(codec, hp_pin, 0,
3711 alc_write_coef_idx(codec, 0x67, 0x0); /* Set HP depop to manual mode */
3712 alc_write_coefex_idx(codec, 0x58, 0x00, 0x7880);
3713 alc_write_coefex_idx(codec, 0x58, 0x0f, 0xf049);
3714 alc_update_coefex_idx(codec, 0x58, 0x03, 0x00f0, 0x00c0);
3716 alc_write_coefex_idx(codec, 0x58, 0x00, 0xf888); /* HP depop procedure start */
3717 val = alc_read_coefex_idx(codec, 0x58, 0x00);
3720 val = alc_read_coefex_idx(codec, 0x58, 0x00);
3723 alc_write_coefex_idx(codec, 0x58, 0x00, val); /* write back the result */
3724 alc_update_coef_idx(codec, 0x38, 1<<4, coef38);
3725 alc_update_coef_idx(codec, 0x0d, 0x110, coef0d);
3726 alc_update_coef_idx(codec, 0x36, 3<<13, coef36);
3729 alc_update_coef_idx(codec, 0x4a, 1<<15, 0);
3732 static void alc225_init(struct hda_codec *codec)
3734 struct alc_spec *spec = codec->spec;
3738 if (spec->ultra_low_power) {
3739 alc_update_coef_idx(codec, 0x08, 0x0f << 2, 3<<2);
3740 alc_update_coef_idx(codec, 0x0e, 7<<6, 7<<6);
3741 alc_update_coef_idx(codec, 0x33, 1<<11, 0);
3745 if (spec->codec_variant != ALC269_TYPE_ALC287 &&
3746 spec->codec_variant != ALC269_TYPE_ALC245)
3748 if (!spec->done_hp_init ||
3749 is_s3_resume(codec) ||
3750 is_s4_resume(codec)) {
3751 alc285_hp_init(codec);
3752 spec->done_hp_init = true;
3759 hp1_pin_sense = snd_hda_jack_detect(codec, hp_pin);
3760 hp2_pin_sense = snd_hda_jack_detect(codec, 0x16);
3764 alc_update_coefex_idx(codec, 0x57, 0x04, 0x0007, 0x1); /* Low power */
3767 snd_hda_codec_write(codec, hp_pin, 0,
3770 snd_hda_codec_write(codec, 0x16, 0,
3775 snd_hda_codec_write(codec, hp_pin, 0,
3778 snd_hda_codec_write(codec, 0x16, 0,
3782 alc_update_coefex_idx(codec, 0x57, 0x04, 0x0007, 0x4); /* Hight power */
3786 static void alc225_shutup(struct hda_codec *codec)
3788 struct alc_spec *spec = codec->spec;
3795 hp1_pin_sense = snd_hda_jack_detect(codec, hp_pin);
3796 hp2_pin_sense = snd_hda_jack_detect(codec, 0x16);
3799 alc_disable_headset_jack_key(codec);
3801 alc_update_coef_idx(codec, 0x4a, 0, 3 << 10);
3805 snd_hda_codec_write(codec, hp_pin, 0,
3808 snd_hda_codec_write(codec, 0x16, 0,
3814 snd_hda_codec_write(codec, hp_pin, 0,
3817 snd_hda_codec_write(codec, 0x16, 0,
3821 alc_update_coef_idx(codec, 0x4a, 3 << 10, 0);
3822 alc_enable_headset_jack_key(codec);
3824 alc_auto_setup_eapd(codec, false);
3825 alc_shutup_pins(codec);
3826 if (spec->ultra_low_power) {
3828 alc_update_coef_idx(codec, 0x08, 0x0f << 2, 0x0c << 2);
3829 alc_update_coef_idx(codec, 0x0e, 7<<6, 0);
3830 alc_update_coef_idx(codec, 0x33, 1<<11, 1<<11);
3831 alc_update_coef_idx(codec, 0x4a, 3<<4, 2<<4);
3836 static void alc_default_init(struct hda_codec *codec)
3838 struct alc_spec *spec = codec->spec;
3847 hp_pin_sense = snd_hda_jack_detect(codec, hp_pin);
3852 snd_hda_codec_write(codec, hp_pin, 0,
3857 snd_hda_codec_write(codec, hp_pin, 0,
3863 static void alc_default_shutup(struct hda_codec *codec)
3865 struct alc_spec *spec = codec->spec;
3870 alc269_shutup(codec);
3874 hp_pin_sense = snd_hda_jack_detect(codec, hp_pin);
3879 snd_hda_codec_write(codec, hp_pin, 0,
3884 if (!spec->no_shutup_pins)
3885 snd_hda_codec_write(codec, hp_pin, 0,
3890 alc_auto_setup_eapd(codec, false);
3891 alc_shutup_pins(codec);
3894 static void alc294_hp_init(struct hda_codec *codec)
3896 struct alc_spec *spec = codec->spec;
3903 snd_hda_codec_write(codec, hp_pin, 0,
3908 if (!spec->no_shutup_pins)
3909 snd_hda_codec_write(codec, hp_pin, 0,
3912 alc_update_coef_idx(codec, 0x6f, 0x000f, 0);/* Set HP depop to manual mode */
3913 alc_update_coefex_idx(codec, 0x58, 0x00, 0x8000, 0x8000); /* HP depop procedure start */
3916 val = alc_read_coefex_idx(codec, 0x58, 0x01);
3919 val = alc_read_coefex_idx(codec, 0x58, 0x01);
3922 alc_update_coef_idx(codec, 0x6f, 0x000f, 0x000b);
3926 static void alc294_init(struct hda_codec *codec)
3928 struct alc_spec *spec = codec->spec;
3931 if (!spec->done_hp_init ||
3932 codec->core.dev.power.power_state.event == PM_EVENT_RESTORE) {
3933 alc294_hp_init(codec);
3934 spec->done_hp_init = true;
3936 alc_default_init(codec);
3939 static void alc5505_coef_set(struct hda_codec *codec, unsigned int index_reg,
3942 snd_hda_codec_write(codec, 0x51, 0, AC_VERB_SET_COEF_INDEX, index_reg >> 1);
3943 snd_hda_codec_write(codec, 0x51, 0, AC_VERB_SET_PROC_COEF, val & 0xffff); /* LSB */
3944 snd_hda_codec_write(codec, 0x51, 0, AC_VERB_SET_PROC_COEF, val >> 16); /* MSB */
3947 static int alc5505_coef_get(struct hda_codec *codec, unsigned int index_reg)
3951 snd_hda_codec_write(codec, 0x51, 0, AC_VERB_SET_COEF_INDEX, index_reg >> 1);
3952 val = snd_hda_codec_read(codec, 0x51, 0, AC_VERB_GET_PROC_COEF, 0)
3954 val |= snd_hda_codec_read(codec, 0x51, 0, AC_VERB_GET_PROC_COEF, 0)
3959 static void alc5505_dsp_halt(struct hda_codec *codec)
3963 alc5505_coef_set(codec, 0x3000, 0x000c); /* DSP CPU stop */
3964 alc5505_coef_set(codec, 0x880c, 0x0008); /* DDR enter self refresh */
3965 alc5505_coef_set(codec, 0x61c0, 0x11110080); /* Clock control for PLL and CPU */
3966 alc5505_coef_set(codec, 0x6230, 0xfc0d4011); /* Disable Input OP */
3967 alc5505_coef_set(codec, 0x61b4, 0x040a2b03); /* Stop PLL2 */
3968 alc5505_coef_set(codec, 0x61b0, 0x00005b17); /* Stop PLL1 */
3969 alc5505_coef_set(codec, 0x61b8, 0x04133303); /* Stop PLL3 */
3970 val = alc5505_coef_get(codec, 0x6220);
3971 alc5505_coef_set(codec, 0x6220, (val | 0x3000)); /* switch Ringbuffer clock to DBUS clock */
3974 static void alc5505_dsp_back_from_halt(struct hda_codec *codec)
3976 alc5505_coef_set(codec, 0x61b8, 0x04133302);
3977 alc5505_coef_set(codec, 0x61b0, 0x00005b16);
3978 alc5505_coef_set(codec, 0x61b4, 0x040a2b02);
3979 alc5505_coef_set(codec, 0x6230, 0xf80d4011);
3980 alc5505_coef_set(codec, 0x6220, 0x2002010f);
3981 alc5505_coef_set(codec, 0x880c, 0x00000004);
3984 static void alc5505_dsp_init(struct hda_codec *codec)
3988 alc5505_dsp_halt(codec);
3989 alc5505_dsp_back_from_halt(codec);
3990 alc5505_coef_set(codec, 0x61b0, 0x5b14); /* PLL1 control */
3991 alc5505_coef_set(codec, 0x61b0, 0x5b16);
3992 alc5505_coef_set(codec, 0x61b4, 0x04132b00); /* PLL2 control */
3993 alc5505_coef_set(codec, 0x61b4, 0x04132b02);
3994 alc5505_coef_set(codec, 0x61b8, 0x041f3300); /* PLL3 control*/
3995 alc5505_coef_set(codec, 0x61b8, 0x041f3302);
3996 snd_hda_codec_write(codec, 0x51, 0, AC_VERB_SET_CODEC_RESET, 0); /* Function reset */
3997 alc5505_coef_set(codec, 0x61b8, 0x041b3302);
3998 alc5505_coef_set(codec, 0x61b8, 0x04173302);
3999 alc5505_coef_set(codec, 0x61b8, 0x04163302);
4000 alc5505_coef_set(codec, 0x8800, 0x348b328b); /* DRAM control */
4001 alc5505_coef_set(codec, 0x8808, 0x00020022); /* DRAM control */
4002 alc5505_coef_set(codec, 0x8818, 0x00000400); /* DRAM control */
4004 val = alc5505_coef_get(codec, 0x6200) >> 16; /* Read revision ID */
4006 alc5505_coef_set(codec, 0x6220, 0x2002010f); /* I/O PAD Configuration */
4008 alc5505_coef_set(codec, 0x6220, 0x6002018f);
4010 alc5505_coef_set(codec, 0x61ac, 0x055525f0); /**/
4011 alc5505_coef_set(codec, 0x61c0, 0x12230080); /* Clock control */
4012 alc5505_coef_set(codec, 0x61b4, 0x040e2b02); /* PLL2 control */
4013 alc5505_coef_set(codec, 0x61bc, 0x010234f8); /* OSC Control */
4014 alc5505_coef_set(codec, 0x880c, 0x00000004); /* DRAM Function control */
4015 alc5505_coef_set(codec, 0x880c, 0x00000003);
4016 alc5505_coef_set(codec, 0x880c, 0x00000010);
4019 alc5505_dsp_halt(codec);
4024 #define alc5505_dsp_suspend(codec) do { } while (0) /* NOP */
4025 #define alc5505_dsp_resume(codec) do { } while (0) /* NOP */
4027 #define alc5505_dsp_suspend(codec) alc5505_dsp_halt(codec)
4028 #define alc5505_dsp_resume(codec) alc5505_dsp_back_from_halt(codec)
4032 static int alc269_suspend(struct hda_codec *codec)
4034 struct alc_spec *spec = codec->spec;
4036 if (spec->has_alc5505_dsp)
4037 alc5505_dsp_suspend(codec);
4039 return alc_suspend(codec);
4042 static int alc269_resume(struct hda_codec *codec)
4044 struct alc_spec *spec = codec->spec;
4046 if (spec->codec_variant == ALC269_TYPE_ALC269VB)
4047 alc269vb_toggle_power_output(codec, 0);
4048 if (spec->codec_variant == ALC269_TYPE_ALC269VB &&
4049 (alc_get_coef0(codec) & 0x00ff) == 0x018) {
4053 codec->patch_ops.init(codec);
4055 if (spec->codec_variant == ALC269_TYPE_ALC269VB)
4056 alc269vb_toggle_power_output(codec, 1);
4057 if (spec->codec_variant == ALC269_TYPE_ALC269VB &&
4058 (alc_get_coef0(codec) & 0x00ff) == 0x017) {
4062 snd_hda_regmap_sync(codec);
4063 hda_call_check_power_status(codec, 0x01);
4065 /* on some machine, the BIOS will clear the codec gpio data when enter
4069 if (spec->gpio_data)
4070 alc_write_gpio_data(codec);
4072 if (spec->has_alc5505_dsp)
4073 alc5505_dsp_resume(codec);
4079 static void alc269_fixup_pincfg_no_hp_to_lineout(struct hda_codec *codec,
4082 struct alc_spec *spec = codec->spec;
4085 spec->parse_flags = HDA_PINCFG_NO_HP_FIXUP;
4088 static void alc269_fixup_pincfg_U7x7_headset_mic(struct hda_codec *codec,
4092 unsigned int cfg_headphone = snd_hda_codec_get_pincfg(codec, 0x21);
4093 unsigned int cfg_headset_mic = snd_hda_codec_get_pincfg(codec, 0x19);
4096 snd_hda_codec_set_pincfg(codec, 0x19,
4101 static void alc269_fixup_hweq(struct hda_codec *codec,
4105 alc_update_coef_idx(codec, 0x1e, 0, 0x80);
4108 static void alc269_fixup_headset_mic(struct hda_codec *codec,
4111 struct alc_spec *spec = codec->spec;
4114 spec->parse_flags |= HDA_PINCFG_HEADSET_MIC;
4117 static void alc271_fixup_dmic(struct hda_codec *codec,
4127 if (strcmp(codec->core.chip_name, "ALC271X") &&
4128 strcmp(codec->core.chip_name, "ALC269VB"))
4130 cfg = snd_hda_codec_get_pincfg(codec, 0x12);
4132 snd_hda_sequence_write(codec, verbs);
4136 static void alc269vb_fixup_aspire_e1_coef(struct hda_codec *codec,
4141 alc_update_coef_idx(codec, 0x0d, 0x6000, 0x6000);
4144 static void alc269_fixup_pcm_44k(struct hda_codec *codec,
4147 struct alc_spec *spec = codec->spec;
4155 spec->gen.stream_analog_playback = &alc269_44k_pcm_analog_playback;
4156 spec->gen.stream_analog_capture = &alc269_44k_pcm_analog_capture;
4159 static void alc269_fixup_stereo_dmic(struct hda_codec *codec,
4162 /* The digital-mic unit sends PDM (differential signal) instead of
4168 alc_update_coef_idx(codec, 0x07, 0, 0x80);
4171 static void alc269_quanta_automute(struct hda_codec *codec)
4173 snd_hda_gen_update_outputs(codec);
4175 alc_write_coef_idx(codec, 0x0c, 0x680);
4176 alc_write_coef_idx(codec, 0x0c, 0x480);
4179 static void alc269_fixup_quanta_mute(struct hda_codec *codec,
4182 struct alc_spec *spec = codec->spec;
4185 spec->gen.automute_hook = alc269_quanta_automute;
4188 static void alc269_x101_hp_automute_hook(struct hda_codec *codec,
4191 struct alc_spec *spec = codec->spec;
4194 snd_hda_gen_hp_automute(codec, jack);
4196 vref = spec->gen.hp_jack_present ? PIN_VREF80 : 0;
4198 snd_hda_codec_write(codec, 0x18, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4201 snd_hda_codec_write(codec, 0x18, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4213 static void alc298_huawei_mbx_stereo_seq(struct hda_codec *codec,
4217 snd_hda_codec_write(codec, 0x06, 0, AC_VERB_SET_DIGI_CONVERT_3, 0x0);
4218 alc_write_coef_idx(codec, 0x26, 0xb000);
4221 snd_hda_codec_write(codec, 0x21, 0, AC_VERB_GET_PIN_SENSE, 0x0);
4223 snd_hda_codec_write(codec, 0x6, 0, AC_VERB_SET_DIGI_CONVERT_3, 0x80);
4224 alc_write_coef_idx(codec, 0x26, 0xf000);
4225 alc_write_coef_idx(codec, 0x23, initval->value_0x23);
4227 if (initval->value_0x23 != 0x1e)
4228 alc_write_coef_idx(codec, 0x25, initval->value_0x25);
4230 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 0x26);
4231 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_PROC_COEF, 0xb010);
4234 static void alc298_fixup_huawei_mbx_stereo(struct hda_codec *codec,
4258 snd_hda_codec_write(codec, 0x06, 0, AC_VERB_SET_DIGI_CONVERT_3, 0x00);
4259 snd_hda_codec_write(codec, 0x06, 0, AC_VERB_SET_DIGI_CONVERT_3, 0x80);
4260 alc_write_coef_idx(codec, 0x26, 0xf000);
4261 alc_write_coef_idx(codec, 0x22, 0x31);
4262 alc_write_coef_idx(codec, 0x23, 0x0b);
4263 alc_write_coef_idx(codec, 0x25, 0x00);
4264 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 0x26);
4265 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_PROC_COEF, 0xb010);
4267 for (seq = dac_init; seq->value_0x23; seq++)
4268 alc298_huawei_mbx_stereo_seq(codec, seq, seq == dac_init);
4271 static void alc269_fixup_x101_headset_mic(struct hda_codec *codec,
4274 struct alc_spec *spec = codec->spec;
4276 spec->parse_flags |= HDA_PINCFG_HEADSET_MIC;
4277 spec->gen.hp_automute_hook = alc269_x101_hp_automute_hook;
4281 static void alc_update_vref_led(struct hda_codec *codec, hda_nid_t pin,
4290 pinval = snd_hda_codec_get_pin_target(codec, pin);
4294 snd_hda_power_up_pm(codec);
4295 snd_hda_set_pin_ctl_cache(codec, pin, pinval);
4296 snd_hda_power_down_pm(codec);
4299 /* update mute-LED according to the speaker mute state via mic VREF pin */
4303 struct hda_codec *codec = dev_to_hda_codec(led_cdev->dev->parent);
4304 struct alc_spec *spec = codec->spec;
4306 alc_update_vref_led(codec, spec->mute_led_nid,
4307 spec->mute_led_polarity, brightness);
4312 static unsigned int led_power_filter(struct hda_codec *codec,
4316 struct alc_spec *spec = codec->spec;
4319 (nid != spec->mute_led_nid && nid != spec->cap_mute_led_nid))
4323 snd_hda_set_pin_ctl(codec, nid,
4324 snd_hda_codec_get_pin_target(codec, nid));
4326 return snd_hda_gen_path_power_filter(codec, nid, power_state);
4329 static void alc269_fixup_hp_mute_led(struct hda_codec *codec,
4332 struct alc_spec *spec = codec->spec;
4340 if (sscanf(dev->name, "HP_Mute_LED_%d_%x", &pol, &pin) != 2)
4344 spec->mute_led_polarity = pol;
4345 spec->mute_led_nid = pin - 0x0a + 0x18;
4346 snd_hda_gen_add_mute_led_cdev(codec, vref_mute_led_set);
4347 codec->power_filter = led_power_filter;
4348 codec_dbg(codec,
4349 "Detected mute LED for %x:%d\n", spec->mute_led_nid,
4350 spec->mute_led_polarity);
4355 static void alc269_fixup_hp_mute_led_micx(struct hda_codec *codec,
4359 struct alc_spec *spec = codec->spec;
4362 spec->mute_led_polarity = 0;
4363 spec->mute_led_nid = pin;
4364 snd_hda_gen_add_mute_led_cdev(codec, vref_mute_led_set);
4365 codec->power_filter = led_power_filter;
4369 static void alc269_fixup_hp_mute_led_mic1(struct hda_codec *codec,
4372 alc269_fixup_hp_mute_led_micx(codec, fix, action, 0x18);
4375 static void alc269_fixup_hp_mute_led_mic2(struct hda_codec *codec,
4378 alc269_fixup_hp_mute_led_micx(codec, fix, action, 0x19);
4381 static void alc269_fixup_hp_mute_led_mic3(struct hda_codec *codec,
4384 alc269_fixup_hp_mute_led_micx(codec, fix, action, 0x1b);
4388 static void alc_update_gpio_led(struct hda_codec *codec, unsigned int mask,
4393 alc_update_gpio_data(codec, mask, !enabled); /* muted -> LED on */
4400 struct hda_codec *codec = dev_to_hda_codec(led_cdev->dev->parent);
4401 struct alc_spec *spec = codec->spec;
4403 alc_update_gpio_led(codec, spec->gpio_mute_led_mask,
4404 spec->mute_led_polarity, !brightness);
4408 /* turn on/off mic-mute LED via GPIO per capture hook */
4412 struct hda_codec *codec = dev_to_hda_codec(led_cdev->dev->parent);
4413 struct alc_spec *spec = codec->spec;
4415 alc_update_gpio_led(codec, spec->gpio_mic_led_mask,
4416 spec->micmute_led_polarity, !brightness);
4420 /* setup mute and mic-mute GPIO bits, add hooks appropriately */
4421 static void alc_fixup_hp_gpio_led(struct hda_codec *codec,
4426 struct alc_spec *spec = codec->spec;
4428 alc_fixup_gpio(codec, action, mute_mask | micmute_mask);
4433 spec->gpio_mute_led_mask = mute_mask;
4434 snd_hda_gen_add_mute_led_cdev(codec, gpio_mute_led_set);
4437 spec->gpio_mic_led_mask = micmute_mask;
4438 snd_hda_gen_add_micmute_led_cdev(codec, micmute_led_set);
4442 static void alc236_fixup_hp_gpio_led(struct hda_codec *codec,
4445 alc_fixup_hp_gpio_led(codec, action, 0x02, 0x01);
4448 static void alc269_fixup_hp_gpio_led(struct hda_codec *codec,
4451 alc_fixup_hp_gpio_led(codec, action, 0x08, 0x10);
4454 static void alc285_fixup_hp_gpio_led(struct hda_codec *codec,
4457 alc_fixup_hp_gpio_led(codec, action, 0x04, 0x01);
4460 static void alc286_fixup_hp_gpio_led(struct hda_codec *codec,
4463 alc_fixup_hp_gpio_led(codec, action, 0x02, 0x20);
4466 static void alc287_fixup_hp_gpio_led(struct hda_codec *codec,
4469 alc_fixup_hp_gpio_led(codec, action, 0x10, 0);
4472 static void alc245_fixup_hp_gpio_led(struct hda_codec *codec,
4475 struct alc_spec *spec = codec->spec;
4478 spec->micmute_led_polarity = 1;
4479 alc_fixup_hp_gpio_led(codec, action, 0, 0x04);
4482 /* turn on/off mic-mute LED per capture hook via VREF change */
4486 struct hda_codec *codec = dev_to_hda_codec(led_cdev->dev->parent);
4487 struct alc_spec *spec = codec->spec;
4489 alc_update_vref_led(codec, spec->cap_mute_led_nid,
4490 spec->micmute_led_polarity, brightness);
4494 static void alc269_fixup_hp_gpio_mic1_led(struct hda_codec *codec,
4497 struct alc_spec *spec = codec->spec;
4499 alc_fixup_hp_gpio_led(codec, action, 0x08, 0);
4504 spec->gpio_mask |= 0x10;
4505 spec->gpio_dir |= 0x10;
4506 spec->cap_mute_led_nid = 0x18;
4507 snd_hda_gen_add_micmute_led_cdev(codec, vref_micmute_led_set);
4508 codec->power_filter = led_power_filter;
4512 static void alc280_fixup_hp_gpio4(struct hda_codec *codec,
4515 struct alc_spec *spec = codec->spec;
4517 alc_fixup_hp_gpio_led(codec, action, 0x08, 0);
4519 spec->cap_mute_led_nid = 0x18;
4520 snd_hda_gen_add_micmute_led_cdev(codec, vref_micmute_led_set);
4521 codec->power_filter = led_power_filter;
4528 static void alc245_fixup_hp_x360_amp(struct hda_codec *codec,
4531 struct alc_spec *spec = codec->spec;
4535 spec->gpio_mask |= 0x01;
4536 spec->gpio_dir |= 0x01;
4540 alc_update_gpio_data(codec, 0x01, true);
4542 alc_update_gpio_data(codec, 0x01, false);
4549 struct hda_codec *codec,
4555 alc_update_gpio_data(codec, 0x04, true);
4558 alc_update_gpio_data(codec, 0x04, false);
4563 static void alc274_fixup_hp_envy_gpio(struct hda_codec *codec,
4567 struct alc_spec *spec = codec->spec;
4570 spec->gpio_mask |= 0x04;
4571 spec->gpio_dir |= 0x04;
4572 spec->gen.pcm_playback_hook = alc274_hp_envy_pcm_hook;
4576 static void alc_update_coef_led(struct hda_codec *codec,
4583 alc_update_coef_idx(codec, led->idx, led->mask,
4584 on ? led->on : led->off);
4587 /* update mute-LED according to the speaker mute state via COEF bit */
4591 struct hda_codec *codec = dev_to_hda_codec(led_cdev->dev->parent);
4592 struct alc_spec *spec = codec->spec;
4594 alc_update_coef_led(codec, &spec->mute_led_coef,
4595 spec->mute_led_polarity, brightness);
4599 static void alc285_fixup_hp_mute_led_coefbit(struct hda_codec *codec,
4603 struct alc_spec *spec = codec->spec;
4606 spec->mute_led_polarity = 0;
4607 spec->mute_led_coef.idx = 0x0b;
4608 spec->mute_led_coef.mask = 1 << 3;
4609 spec->mute_led_coef.on = 1 << 3;
4610 spec->mute_led_coef.off = 0;
4611 snd_hda_gen_add_mute_led_cdev(codec, coef_mute_led_set);
4615 static void alc236_fixup_hp_mute_led_coefbit(struct hda_codec *codec,
4619 struct alc_spec *spec = codec->spec;
4622 spec->mute_led_polarity = 0;
4623 spec->mute_led_coef.idx = 0x34;
4624 spec->mute_led_coef.mask = 1 << 5;
4625 spec->mute_led_coef.on = 0;
4626 spec->mute_led_coef.off = 1 << 5;
4627 snd_hda_gen_add_mute_led_cdev(codec, coef_mute_led_set);
4631 static void alc236_fixup_hp_mute_led_coefbit2(struct hda_codec *codec,
4634 struct alc_spec *spec = codec->spec;
4637 spec->mute_led_polarity = 0;
4638 spec->mute_led_coef.idx = 0x07;
4639 spec->mute_led_coef.mask = 1;
4640 spec->mute_led_coef.on = 1;
4641 spec->mute_led_coef.off = 0;
4642 snd_hda_gen_add_mute_led_cdev(codec, coef_mute_led_set);
4646 static void alc245_fixup_hp_mute_led_coefbit(struct hda_codec *codec,
4650 struct alc_spec *spec = codec->spec;
4653 spec->mute_led_polarity = 0;
4654 spec->mute_led_coef.idx = 0x0b;
4655 spec->mute_led_coef.mask = 3 << 2;
4656 spec->mute_led_coef.on = 2 << 2;
4657 spec->mute_led_coef.off = 1 << 2;
4658 snd_hda_gen_add_mute_led_cdev(codec, coef_mute_led_set);
4662 /* turn on/off mic-mute LED per capture hook by coef bit */
4666 struct hda_codec *codec = dev_to_hda_codec(led_cdev->dev->parent);
4667 struct alc_spec *spec = codec->spec;
4669 alc_update_coef_led(codec, &spec->mic_led_coef,
4670 spec->micmute_led_polarity, brightness);
4674 static void alc285_fixup_hp_coef_micmute_led(struct hda_codec *codec,
4677 struct alc_spec *spec = codec->spec;
4680 spec->mic_led_coef.idx = 0x19;
4681 spec->mic_led_coef.mask = 1 << 13;
4682 spec->mic_led_coef.on = 1 << 13;
4683 spec->mic_led_coef.off = 0;
4684 snd_hda_gen_add_micmute_led_cdev(codec, coef_micmute_led_set);
4688 static void alc285_fixup_hp_gpio_micmute_led(struct hda_codec *codec,
4691 struct alc_spec *spec = codec->spec;
4694 spec->micmute_led_polarity = 1;
4695 alc_fixup_hp_gpio_led(codec, action, 0, 0x04);
4698 static void alc236_fixup_hp_coef_micmute_led(struct hda_codec *codec,
4701 struct alc_spec *spec = codec->spec;
4704 spec->mic_led_coef.idx = 0x35;
4705 spec->mic_led_coef.mask = 3 << 2;
4706 spec->mic_led_coef.on = 2 << 2;
4707 spec->mic_led_coef.off = 1 << 2;
4708 snd_hda_gen_add_micmute_led_cdev(codec, coef_micmute_led_set);
4712 static void alc285_fixup_hp_mute_led(struct hda_codec *codec,
4715 alc285_fixup_hp_mute_led_coefbit(codec, fix, action);
4716 alc285_fixup_hp_coef_micmute_led(codec, fix, action);
4719 static void alc285_fixup_hp_spectre_x360_mute_led(struct hda_codec *codec,
4722 alc285_fixup_hp_mute_led_coefbit(codec, fix, action);
4723 alc285_fixup_hp_gpio_micmute_led(codec, fix, action);
4726 static void alc236_fixup_hp_mute_led(struct hda_codec *codec,
4729 alc236_fixup_hp_mute_led_coefbit(codec, fix, action);
4730 alc236_fixup_hp_coef_micmute_led(codec, fix, action);
4733 static void alc236_fixup_hp_micmute_led_vref(struct hda_codec *codec,
4736 struct alc_spec *spec = codec->spec;
4739 spec->cap_mute_led_nid = 0x1a;
4740 snd_hda_gen_add_micmute_led_cdev(codec, vref_micmute_led_set);
4741 codec->power_filter = led_power_filter;
4745 static void alc236_fixup_hp_mute_led_micmute_vref(struct hda_codec *codec,
4748 alc236_fixup_hp_mute_led_coefbit(codec, fix, action);
4749 alc236_fixup_hp_micmute_led_vref(codec, fix, action);
4752 static inline void alc298_samsung_write_coef_pack(struct hda_codec *codec,
4755 alc_write_coef_idx(codec, 0x23, coefs[0]);
4756 alc_write_coef_idx(codec, 0x25, coefs[1]);
4757 alc_write_coef_idx(codec, 0x26, 0xb011);
4765 static void alc298_fixup_samsung_amp(struct hda_codec *codec,
4784 alc_write_coef_idx(codec, 0x22, amps[i].nid);
4787 alc298_samsung_write_coef_pack(codec, amps[i].init_seq[j]);
4790 alc298_samsung_write_coef_pack(codec, init_seq[j]);
4795 static void gpio2_mic_hotkey_event(struct hda_codec *codec,
4798 struct alc_spec *spec = codec->spec;
4802 input_report_key(spec->kb_dev, spec->alc_mute_keycode_map[ALC_KEY_MICMUTE_INDEX], 1);
4803 input_sync(spec->kb_dev);
4804 input_report_key(spec->kb_dev, spec->alc_mute_keycode_map[ALC_KEY_MICMUTE_INDEX], 0);
4805 input_sync(spec->kb_dev);
4808 static int alc_register_micmute_input_device(struct hda_codec *codec)
4810 struct alc_spec *spec = codec->spec;
4813 spec->kb_dev = input_allocate_device();
4814 if (!spec->kb_dev) {
4815 codec_err(codec, "Out of memory (input_allocate_device)\n");
4816 return -ENOMEM;
4819 spec->alc_mute_keycode_map[ALC_KEY_MICMUTE_INDEX] = KEY_MICMUTE;
4821 spec->kb_dev->name = "Microphone Mute Button";
4822 spec->kb_dev->evbit[0] = BIT_MASK(EV_KEY);
4823 spec->kb_dev->keycodesize = sizeof(spec->alc_mute_keycode_map[0]);
4824 spec->kb_dev->keycodemax = ARRAY_SIZE(spec->alc_mute_keycode_map);
4825 spec->kb_dev->keycode = spec->alc_mute_keycode_map;
4826 for (i = 0; i < ARRAY_SIZE(spec->alc_mute_keycode_map); i++)
4827 set_bit(spec->alc_mute_keycode_map[i], spec->kb_dev->keybit);
4829 if (input_register_device(spec->kb_dev)) {
4830 codec_err(codec, "input_register_device failed\n");
4831 input_free_device(spec->kb_dev);
4832 spec->kb_dev = NULL;
4833 return -ENOMEM;
4844 static void alc280_fixup_hp_gpio2_mic_hotkey(struct hda_codec *codec,
4847 struct alc_spec *spec = codec->spec;
4849 alc_fixup_hp_gpio_led(codec, action, 0x08, 0x10);
4851 spec->init_amp = ALC_INIT_DEFAULT;
4852 if (alc_register_micmute_input_device(codec) != 0)
4855 spec->gpio_mask |= 0x06;
4856 spec->gpio_dir |= 0x02;
4857 spec->gpio_data |= 0x02;
4858 snd_hda_codec_write_cache(codec, codec->core.afg, 0,
4860 snd_hda_jack_detect_enable_callback(codec, codec->core.afg,
4865 if (!spec->kb_dev)
4870 input_unregister_device(spec->kb_dev);
4871 spec->kb_dev = NULL;
4878 static void alc233_fixup_lenovo_line2_mic_hotkey(struct hda_codec *codec,
4881 struct alc_spec *spec = codec->spec;
4883 alc_fixup_hp_gpio_led(codec, action, 0, 0x04);
4885 spec->init_amp = ALC_INIT_DEFAULT;
4886 if (alc_register_micmute_input_device(codec) != 0)
4889 snd_hda_jack_detect_enable_callback(codec, 0x1b,
4894 if (!spec->kb_dev)
4899 input_unregister_device(spec->kb_dev);
4900 spec->kb_dev = NULL;
4908 static void alc269_fixup_hp_line1_mic1_led(struct hda_codec *codec,
4911 struct alc_spec *spec = codec->spec;
4913 alc269_fixup_hp_mute_led_micx(codec, fix, action, 0x1a);
4915 spec->cap_mute_led_nid = 0x18;
4916 snd_hda_gen_add_micmute_led_cdev(codec, vref_micmute_led_set);
4920 static void alc_hp_mute_disable(struct hda_codec *codec, unsigned int delay)
4924 snd_hda_codec_write(codec, 0x21, 0,
4927 snd_hda_codec_write(codec, 0x21, 0,
4932 static void alc_hp_enable_unmute(struct hda_codec *codec, unsigned int delay)
4936 snd_hda_codec_write(codec, 0x21, 0,
4939 snd_hda_codec_write(codec, 0x21, 0,
4945 UPDATE_COEF(0x4a, 1<<8, 0),
4946 UPDATE_COEFEX(0x57, 0x05, 1<<14, 0),
4955 static void alc_headset_mode_unplugged(struct hda_codec *codec)
4957 struct alc_spec *spec = codec->spec;
4961 UPDATE_COEFEX(0x57, 0x05, 1<<14, 0), /* Direct Drive HP Amp control(Set to verb control)*/
4971 UPDATE_COEFEX(0x57, 0x05, 1<<14, 0), /* Direct Drive HP Amp control(Set to verb control)*/
5005 UPDATE_COEFEX(0x57, 0x05, 1<<15|1<<13, 0x0), /* SET charge pump by verb */
5006 UPDATE_COEFEX(0x57, 0x03, 1<<10, 1<<10), /* SET EN_OSW to 1 */
5007 UPDATE_COEF(0x1a, 1<<3, 1<<3), /* Combo JD gating with LINE1-VREFO */
5032 if (spec->no_internal_mic_pin) {
5033 alc_update_coef_idx(codec, 0x45, 0xf<<12 | 1<<10, 5<<12);
5037 switch (codec->core.vendor_id) {
5039 alc_process_coef_fw(codec, coef0255);
5045 alc_hp_mute_disable(codec, 75);
5046 alc_process_coef_fw(codec, coef0256);
5051 alc_process_coef_fw(codec, coef0274);
5055 alc_process_coef_fw(codec, coef0233);
5059 alc_process_coef_fw(codec, coef0288);
5062 alc_process_coef_fw(codec, coef0298);
5063 alc_process_coef_fw(codec, coef0288);
5066 alc_process_coef_fw(codec, coef0292);
5069 alc_process_coef_fw(codec, coef0293);
5072 alc_process_coef_fw(codec, coef0668);
5080 alc_hp_mute_disable(codec, 75);
5081 alc_process_coef_fw(codec, alc225_pre_hsmode);
5082 alc_process_coef_fw(codec, coef0225);
5085 alc_update_coefex_idx(codec, 0x57, 0x5, 1<<14, 0);
5088 codec_dbg(codec, "Headset jack set to unplugged mode.\n");
5092 static void alc_headset_mode_mic_in(struct hda_codec *codec, hda_nid_t hp_pin,
5101 UPDATE_COEFEX(0x57, 0x05, 1<<14, 1<<14), /* Direct Drive HP Amp control(Set to verb control)*/
5107 UPDATE_COEF(0x35, 0, 1<<14),
5128 UPDATE_COEFEX(0x57, 0x05, 0, 1<<15|1<<13), /* SET charge pump by verb */
5129 UPDATE_COEFEX(0x57, 0x03, 1<<10, 0), /* SET EN_OSW to 0 */
5130 UPDATE_COEF(0x1a, 1<<3, 0), /* Combo JD gating without LINE1-VREFO */
5136 UPDATE_COEF(0xc3, 0, 1<<12),
5140 UPDATE_COEFEX(0x57, 0x05, 1<<14, 1<<14),
5152 switch (codec->core.vendor_id) {
5154 alc_write_coef_idx(codec, 0x45, 0xc489);
5155 snd_hda_set_pin_ctl_cache(codec, hp_pin, 0);
5156 alc_process_coef_fw(codec, coef0255);
5157 snd_hda_set_pin_ctl_cache(codec, mic_pin, PIN_VREF50);
5163 alc_write_coef_idx(codec, 0x45, 0xc489);
5164 snd_hda_set_pin_ctl_cache(codec, hp_pin, 0);
5165 alc_process_coef_fw(codec, coef0256);
5166 snd_hda_set_pin_ctl_cache(codec, mic_pin, PIN_VREF50);
5171 alc_write_coef_idx(codec, 0x45, 0x4689);
5172 snd_hda_set_pin_ctl_cache(codec, hp_pin, 0);
5173 alc_process_coef_fw(codec, coef0274);
5174 snd_hda_set_pin_ctl_cache(codec, mic_pin, PIN_VREF50);
5178 alc_write_coef_idx(codec, 0x45, 0xc429);
5179 snd_hda_set_pin_ctl_cache(codec, hp_pin, 0);
5180 alc_process_coef_fw(codec, coef0233);
5181 snd_hda_set_pin_ctl_cache(codec, mic_pin, PIN_VREF50);
5186 snd_hda_set_pin_ctl_cache(codec, hp_pin, 0);
5187 alc_process_coef_fw(codec, coef0288);
5188 snd_hda_set_pin_ctl_cache(codec, mic_pin, PIN_VREF50);
5191 snd_hda_set_pin_ctl_cache(codec, hp_pin, 0);
5192 alc_process_coef_fw(codec, coef0292);
5196 alc_write_coef_idx(codec, 0x45, 0xc429);
5197 snd_hda_set_pin_ctl_cache(codec, hp_pin, 0);
5198 alc_process_coef_fw(codec, coef0293);
5199 snd_hda_set_pin_ctl_cache(codec, mic_pin, PIN_VREF50);
5202 alc_update_coefex_idx(codec, 0x57, 0x5, 0, 1<<14);
5206 snd_hda_set_pin_ctl_cache(codec, hp_pin, 0);
5207 snd_hda_set_pin_ctl_cache(codec, mic_pin, PIN_VREF50);
5210 alc_write_coef_idx(codec, 0x11, 0x0001);
5211 snd_hda_set_pin_ctl_cache(codec, hp_pin, 0);
5212 alc_process_coef_fw(codec, coef0688);
5213 snd_hda_set_pin_ctl_cache(codec, mic_pin, PIN_VREF50);
5221 alc_process_coef_fw(codec, alc225_pre_hsmode);
5222 alc_update_coef_idx(codec, 0x45, 0x3f<<10, 0x31<<10);
5223 snd_hda_set_pin_ctl_cache(codec, hp_pin, 0);
5224 alc_process_coef_fw(codec, coef0225);
5225 snd_hda_set_pin_ctl_cache(codec, mic_pin, PIN_VREF50);
5228 codec_dbg(codec, "Headset jack set to mic-in mode.\n");
5231 static void alc_headset_mode_default(struct hda_codec *codec)
5253 UPDATE_COEFEX(0x57, 0x05, 1<<14, 0), /* Direct Drive HP Amp control(Set to verb control)*/
5280 UPDATE_COEF(0x1a, 1<<3, 0), /* Combo JD gating without LINE1-VREFO */
5297 switch (codec->core.vendor_id) {
5304 alc_process_coef_fw(codec, alc225_pre_hsmode);
5305 alc_process_coef_fw(codec, coef0225);
5306 alc_hp_enable_unmute(codec, 75);
5309 alc_process_coef_fw(codec, coef0255);
5315 alc_write_coef_idx(codec, 0x1b, 0x0e4b);
5316 alc_write_coef_idx(codec, 0x45, 0xc089);
5318 alc_process_coef_fw(codec, coef0256);
5319 alc_hp_enable_unmute(codec, 75);
5324 alc_process_coef_fw(codec, coef0274);
5328 alc_process_coef_fw(codec, coef0233);
5333 alc_process_coef_fw(codec, coef0288);
5336 alc_process_coef_fw(codec, coef0292);
5339 alc_process_coef_fw(codec, coef0293);
5342 alc_process_coef_fw(codec, coef0688);
5345 alc_update_coefex_idx(codec, 0x57, 0x5, 1<<14, 0);
5348 codec_dbg(codec, "Headset jack set to headphone (default) mode.\n");
5352 static void alc_headset_mode_ctia(struct hda_codec *codec)
5388 UPDATE_COEF(0x10, 7<<8, 7<<8), /* SET Line1 JD to 1 */
5404 UPDATE_COEF(0x63, 3<<14, 1<<14),
5408 switch (codec->core.vendor_id) {
5410 alc_process_coef_fw(codec, coef0255);
5416 alc_process_coef_fw(codec, coef0256);
5417 alc_hp_enable_unmute(codec, 75);
5422 alc_write_coef_idx(codec, 0x45, 0xd689);
5426 alc_process_coef_fw(codec, coef0233);
5429 val = alc_read_coef_idx(codec, 0x50);
5430 if (val & (1 << 12)) {
5431 alc_update_coef_idx(codec, 0x8e, 0x0070, 0x0020);
5432 alc_update_coef_idx(codec, 0x4f, 0xfcc0, 0xd400);
5435 alc_update_coef_idx(codec, 0x8e, 0x0070, 0x0010);
5436 alc_update_coef_idx(codec, 0x4f, 0xfcc0, 0xd400);
5442 alc_update_coef_idx(codec, 0x4f, 0xfcc0, 0xd400);
5444 alc_process_coef_fw(codec, coef0288);
5447 alc_process_coef_fw(codec, coef0292);
5450 alc_process_coef_fw(codec, coef0293);
5453 alc_process_coef_fw(codec, coef0688);
5461 val = alc_read_coef_idx(codec, 0x45);
5462 if (val & (1 << 9))
5463 alc_process_coef_fw(codec, coef0225_2);
5465 alc_process_coef_fw(codec, coef0225_1);
5466 alc_hp_enable_unmute(codec, 75);
5469 alc_update_coefex_idx(codec, 0x57, 0x5, 1<<14, 0);
5472 codec_dbg(codec, "Headset jack set to iPhone-style headset mode.\n");
5476 static void alc_headset_mode_omtp(struct hda_codec *codec)
5510 UPDATE_COEF(0x10, 7<<8, 7<<8), /* SET Line1 JD to 1 */
5525 switch (codec->core.vendor_id) {
5527 alc_process_coef_fw(codec, coef0255);
5533 alc_process_coef_fw(codec, coef0256);
5534 alc_hp_enable_unmute(codec, 75);
5539 alc_write_coef_idx(codec, 0x45, 0xe689);
5543 alc_process_coef_fw(codec, coef0233);
5546 alc_update_coef_idx(codec, 0x8e, 0x0070, 0x0010);/* Headset output enable */
5547 alc_update_coef_idx(codec, 0x4f, 0xfcc0, 0xe400);
5552 alc_update_coef_idx(codec, 0x4f, 0xfcc0, 0xe400);
5554 alc_process_coef_fw(codec, coef0288);
5557 alc_process_coef_fw(codec, coef0292);
5560 alc_process_coef_fw(codec, coef0293);
5563 alc_process_coef_fw(codec, coef0688);
5571 alc_process_coef_fw(codec, coef0225);
5572 alc_hp_enable_unmute(codec, 75);
5575 codec_dbg(codec, "Headset jack set to Nokia-style headset mode.\n");
5578 static void alc_determine_headset_type(struct hda_codec *codec)
5582 struct alc_spec *spec = codec->spec;
5621 if (spec->no_internal_mic_pin) {
5622 alc_update_coef_idx(codec, 0x45, 0xf<<12 | 1<<10, 5<<12);
5626 switch (codec->core.vendor_id) {
5628 alc_process_coef_fw(codec, coef0255);
5630 val = alc_read_coef_idx(codec, 0x46);
5637 alc_write_coef_idx(codec, 0x1b, 0x0e4b);
5638 alc_write_coef_idx(codec, 0x06, 0x6104);
5639 alc_write_coefex_idx(codec, 0x57, 0x3, 0x09a3);
5641 alc_process_coef_fw(codec, coef0255);
5643 val = alc_read_coef_idx(codec, 0x46);
5646 alc_write_coef_idx(codec, 0x45, 0xe089);
5648 val = alc_read_coef_idx(codec, 0x46);
5654 alc_write_coefex_idx(codec, 0x57, 0x3, 0x0da3);
5655 alc_update_coefex_idx(codec, 0x57, 0x5, 1<<14, 0);
5660 alc_process_coef_fw(codec, coef0274);
5662 val = alc_read_coef_idx(codec, 0x46);
5667 alc_write_coef_idx(codec, 0x45, 0xd029);
5669 val = alc_read_coef_idx(codec, 0x46);
5673 snd_hda_codec_write(codec, 0x21, 0,
5676 snd_hda_codec_write(codec, 0x21, 0,
5680 val = alc_read_coef_idx(codec, 0x50);
5681 if (val & (1 << 12)) {
5682 alc_update_coef_idx(codec, 0x8e, 0x0070, 0x0020);
5683 alc_process_coef_fw(codec, coef0288);
5685 val = alc_read_coef_idx(codec, 0x50);
5688 alc_update_coef_idx(codec, 0x8e, 0x0070, 0x0010);
5689 alc_process_coef_fw(codec, coef0288);
5691 val = alc_read_coef_idx(codec, 0x50);
5694 alc_process_coef_fw(codec, coef0298);
5695 snd_hda_codec_write(codec, 0x21, 0,
5698 snd_hda_codec_write(codec, 0x21, 0,
5703 alc_process_coef_fw(codec, coef0288);
5705 val = alc_read_coef_idx(codec, 0x50);
5709 alc_write_coef_idx(codec, 0x6b, 0xd429);
5711 val = alc_read_coef_idx(codec, 0x6c);
5715 alc_process_coef_fw(codec, coef0293);
5717 val = alc_read_coef_idx(codec, 0x46);
5721 alc_process_coef_fw(codec, coef0688);
5723 val = alc_read_coef_idx(codec, 0xbe);
5732 alc_process_coef_fw(codec, alc225_pre_hsmode);
5733 alc_update_coef_idx(codec, 0x67, 0xf000, 0x1000);
5734 val = alc_read_coef_idx(codec, 0x45);
5735 if (val & (1 << 9)) {
5736 alc_update_coef_idx(codec, 0x45, 0x3f<<10, 0x34<<10);
5737 alc_update_coef_idx(codec, 0x49, 3<<8, 2<<8);
5739 val = alc_read_coef_idx(codec, 0x46);
5742 alc_update_coef_idx(codec, 0x45, 0x3f<<10, 0x34<<10);
5743 alc_update_coef_idx(codec, 0x49, 3<<8, 1<<8);
5745 val = alc_read_coef_idx(codec, 0x46);
5749 alc_update_coef_idx(codec, 0x45, 0x3f<<10, 0x38<<10);
5750 alc_update_coef_idx(codec, 0x49, 3<<8, 1<<8);
5752 val = alc_read_coef_idx(codec, 0x46);
5758 alc_update_coef_idx(codec, 0x4a, 7<<6, 7<<6);
5759 alc_update_coef_idx(codec, 0x4a, 3<<4, 3<<4);
5760 alc_update_coef_idx(codec, 0x67, 0xf000, 0x3000);
5767 codec_dbg(codec, "Headset jack detected iPhone-style headset: %s\n",
5769 spec->current_headset_type = is_ctia ? ALC_HEADSET_TYPE_CTIA : ALC_HEADSET_TYPE_OMTP;
5772 static void alc_update_headset_mode(struct hda_codec *codec)
5774 struct alc_spec *spec = codec->spec;
5776 hda_nid_t mux_pin = spec->gen.imux_pins[spec->gen.cur_mux[0]];
5781 if (!snd_hda_jack_detect(codec, hp_pin))
5783 else if (mux_pin == spec->headset_mic_pin)
5785 else if (mux_pin == spec->headphone_mic_pin)
5790 if (new_headset_mode == spec->current_headset_mode) {
5791 snd_hda_gen_update_outputs(codec);
5797 alc_headset_mode_unplugged(codec);
5798 spec->current_headset_mode = ALC_HEADSET_MODE_UNKNOWN;
5799 spec->current_headset_type = ALC_HEADSET_TYPE_UNKNOWN;
5800 spec->gen.hp_jack_present = false;
5803 if (spec->current_headset_type == ALC_HEADSET_TYPE_UNKNOWN)
5804 alc_determine_headset_type(codec);
5805 if (spec->current_headset_type == ALC_HEADSET_TYPE_CTIA)
5806 alc_headset_mode_ctia(codec);
5807 else if (spec->current_headset_type == ALC_HEADSET_TYPE_OMTP)
5808 alc_headset_mode_omtp(codec);
5809 spec->gen.hp_jack_present = true;
5812 alc_headset_mode_mic_in(codec, hp_pin, spec->headphone_mic_pin);
5813 spec->gen.hp_jack_present = false;
5816 alc_headset_mode_default(codec);
5817 spec->gen.hp_jack_present = true;
5821 snd_hda_set_pin_ctl_cache(codec, hp_pin,
5823 if (spec->headphone_mic_pin && spec->headphone_mic_pin != hp_pin)
5824 snd_hda_set_pin_ctl_cache(codec, spec->headphone_mic_pin,
5827 spec->current_headset_mode = new_headset_mode;
5829 snd_hda_gen_update_outputs(codec);
5832 static void alc_update_headset_mode_hook(struct hda_codec *codec,
5836 alc_update_headset_mode(codec);
5839 static void alc_update_headset_jack_cb(struct hda_codec *codec,
5842 snd_hda_gen_hp_automute(codec, jack);
5843 alc_update_headset_mode(codec);
5846 static void alc_probe_headset_mode(struct hda_codec *codec)
5849 struct alc_spec *spec = codec->spec;
5850 struct auto_pin_cfg *cfg = &spec->gen.autocfg;
5853 for (i = 0; i < cfg->num_inputs; i++) {
5854 if (cfg->inputs[i].is_headset_mic && !spec->headset_mic_pin)
5855 spec->headset_mic_pin = cfg->inputs[i].pin;
5856 if (cfg->inputs[i].is_headphone_mic && !spec->headphone_mic_pin)
5857 spec->headphone_mic_pin = cfg->inputs[i].pin;
5860 WARN_ON(spec->gen.cap_sync_hook);
5861 spec->gen.cap_sync_hook = alc_update_headset_mode_hook;
5862 spec->gen.automute_hook = alc_update_headset_mode;
5863 spec->gen.hp_automute_hook = alc_update_headset_jack_cb;
5866 static void alc_fixup_headset_mode(struct hda_codec *codec,
5869 struct alc_spec *spec = codec->spec;
5873 spec->parse_flags |= HDA_PINCFG_HEADSET_MIC | HDA_PINCFG_HEADPHONE_MIC;
5876 alc_probe_headset_mode(codec);
5879 if (is_s3_resume(codec) || is_s4_resume(codec)) {
5880 spec->current_headset_mode = ALC_HEADSET_MODE_UNKNOWN;
5881 spec->current_headset_type = ALC_HEADSET_TYPE_UNKNOWN;
5883 alc_update_headset_mode(codec);
5888 static void alc_fixup_headset_mode_no_hp_mic(struct hda_codec *codec,
5892 struct alc_spec *spec = codec->spec;
5893 spec->parse_flags |= HDA_PINCFG_HEADSET_MIC;
5896 alc_fixup_headset_mode(codec, fix, action);
5899 static void alc255_set_default_jack_type(struct hda_codec *codec)
5918 switch (codec->core.vendor_id) {
5920 alc_process_coef_fw(codec, alc255fw);
5926 alc_process_coef_fw(codec, alc256fw);
5932 static void alc_fixup_headset_mode_alc255(struct hda_codec *codec,
5936 alc255_set_default_jack_type(codec);
5938 alc_fixup_headset_mode(codec, fix, action);
5941 static void alc_fixup_headset_mode_alc255_no_hp_mic(struct hda_codec *codec,
5945 struct alc_spec *spec = codec->spec;
5946 spec->parse_flags |= HDA_PINCFG_HEADSET_MIC;
5947 alc255_set_default_jack_type(codec);
5950 alc_fixup_headset_mode(codec, fix, action);
5953 static void alc288_update_headset_jack_cb(struct hda_codec *codec,
5956 struct alc_spec *spec = codec->spec;
5958 alc_update_headset_jack_cb(codec, jack);
5960 alc_update_gpio_data(codec, 0x40, spec->gen.hp_jack_present);
5963 static void alc_fixup_headset_mode_dell_alc288(struct hda_codec *codec,
5966 alc_fixup_headset_mode(codec, fix, action);
5968 struct alc_spec *spec = codec->spec;
5970 spec->gpio_mask |= 0x40;
5971 spec->gpio_dir |= 0x40;
5972 spec->gen.hp_automute_hook = alc288_update_headset_jack_cb;
5976 static void alc_fixup_auto_mute_via_amp(struct hda_codec *codec,
5980 struct alc_spec *spec = codec->spec;
5981 spec->gen.auto_mute_via_amp = 1;
5985 static void alc_fixup_no_shutup(struct hda_codec *codec,
5989 struct alc_spec *spec = codec->spec;
5990 spec->no_shutup_pins = 1;
5994 static void alc_fixup_disable_aamix(struct hda_codec *codec,
5998 struct alc_spec *spec = codec->spec;
5999 /* Disable AA-loopback as it causes white noise */
6000 spec->gen.mixer_nid = 0;
6005 static void alc_fixup_tpt440_dock(struct hda_codec *codec,
6013 struct alc_spec *spec = codec->spec;
6016 spec->parse_flags = HDA_PINCFG_NO_HP_FIXUP;
6017 codec->power_save_node = 0; /* avoid click noises */
6018 snd_hda_apply_pincfgs(codec, pincfgs);
6022 static void alc_fixup_tpt470_dock(struct hda_codec *codec,
6030 struct alc_spec *spec = codec->spec;
6033 spec->parse_flags = HDA_PINCFG_NO_HP_FIXUP;
6034 snd_hda_apply_pincfgs(codec, pincfgs);
6037 snd_hda_codec_write(codec, 0x17, 0,
6040 snd_hda_codec_write(codec, 0x19, 0,
6045 static void alc_fixup_tpt470_dacs(struct hda_codec *codec,
6050 * ALC298 codec
6056 struct alc_spec *spec = codec->spec;
6059 spec->gen.preferred_dacs = preferred_pairs;
6062 static void alc295_fixup_asus_dacs(struct hda_codec *codec,
6068 struct alc_spec *spec = codec->spec;
6071 spec->gen.preferred_dacs = preferred_pairs;
6074 static void alc_shutup_dell_xps13(struct hda_codec *codec)
6076 struct alc_spec *spec = codec->spec;
6080 snd_hda_codec_write(codec, hp_pin, 0,
6085 static void alc_fixup_dell_xps13(struct hda_codec *codec,
6088 struct alc_spec *spec = codec->spec;
6089 struct hda_input_mux *imux = &spec->gen.input_mux;
6094 /* mic pin 0x19 must be initialized with Vref Hi-Z, otherwise
6097 snd_hda_codec_set_pin_target(codec, 0x19, PIN_VREFHIZ);
6098 spec->shutup = alc_shutup_dell_xps13;
6102 for (i = 0; i < imux->num_items; i++) {
6103 if (spec->gen.imux_pins[i] == 0x12) {
6104 spec->gen.cur_mux[0] = i;
6112 static void alc_fixup_headset_mode_alc662(struct hda_codec *codec,
6115 struct alc_spec *spec = codec->spec;
6118 spec->parse_flags |= HDA_PINCFG_HEADSET_MIC;
6119 spec->gen.hp_mic = 1; /* Mic-in is same pin as headphone */
6121 /* Disable boost for mic-in permanently. (This code is only called
6123 snd_hda_codec_write(codec, 0x1b, 0, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000);
6124 snd_hda_override_wcaps(codec, 0x1b, get_wcaps(codec, 0x1b) & ~AC_WCAP_IN_AMP);
6126 alc_fixup_headset_mode(codec, fix, action);
6129 static void alc_fixup_headset_mode_alc668(struct hda_codec *codec,
6133 alc_write_coef_idx(codec, 0xc4, 0x8000);
6134 alc_update_coef_idx(codec, 0xc2, ~0xfe, 0);
6135 snd_hda_set_pin_ctl_cache(codec, 0x18, 0);
6137 alc_fixup_headset_mode(codec, fix, action);
6141 static int find_ext_mic_pin(struct hda_codec *codec)
6143 struct alc_spec *spec = codec->spec;
6144 struct auto_pin_cfg *cfg = &spec->gen.autocfg;
6149 for (i = 0; i < cfg->num_inputs; i++) {
6150 if (cfg->inputs[i].type != AUTO_PIN_MIC)
6152 nid = cfg->inputs[i].pin;
6153 defcfg = snd_hda_codec_get_pincfg(codec, nid);
6162 static void alc271_hp_gate_mic_jack(struct hda_codec *codec,
6166 struct alc_spec *spec = codec->spec;
6169 int mic_pin = find_ext_mic_pin(codec);
6174 snd_hda_jack_set_gating_jack(codec, mic_pin, hp_pin);
6178 static void alc269_fixup_limit_int_mic_boost(struct hda_codec *codec,
6182 struct alc_spec *spec = codec->spec;
6183 struct auto_pin_cfg *cfg = &spec->gen.autocfg;
6188 Therefore limit the boost to 0 or 1. */
6193 for (i = 0; i < cfg->num_inputs; i++) {
6194 hda_nid_t nid = cfg->inputs[i].pin;
6196 if (cfg->inputs[i].type != AUTO_PIN_MIC)
6198 defcfg = snd_hda_codec_get_pincfg(codec, nid);
6202 snd_hda_override_amp_caps(codec, nid, HDA_INPUT,
6210 static void alc283_hp_automute_hook(struct hda_codec *codec,
6213 struct alc_spec *spec = codec->spec;
6217 snd_hda_gen_hp_automute(codec, jack);
6219 vref = spec->gen.hp_jack_present ? PIN_VREF80 : 0;
6222 snd_hda_codec_write(codec, 0x19, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
6226 static void alc283_fixup_chromebook(struct hda_codec *codec,
6229 struct alc_spec *spec = codec->spec;
6233 snd_hda_override_wcaps(codec, 0x03, 0);
6234 /* Disable AA-loopback as it causes white noise */
6235 spec->gen.mixer_nid = 0;
6238 /* MIC2-VREF control */
6240 alc_update_coef_idx(codec, 0x06, 0x000c, 0);
6242 alc_update_coef_idx(codec, 0x1a, 0, 1 << 4);
6247 static void alc283_fixup_sense_combo_jack(struct hda_codec *codec,
6250 struct alc_spec *spec = codec->spec;
6254 spec->gen.hp_automute_hook = alc283_hp_automute_hook;
6257 /* MIC2-VREF control */
6259 alc_update_coef_idx(codec, 0x06, 0x000c, 0);
6265 static void asus_tx300_automute(struct hda_codec *codec)
6267 struct alc_spec *spec = codec->spec;
6268 snd_hda_gen_update_outputs(codec);
6269 if (snd_hda_jack_detect(codec, 0x1b))
6270 spec->gen.mute_bits |= (1ULL << 0x14);
6273 static void alc282_fixup_asus_tx300(struct hda_codec *codec,
6276 struct alc_spec *spec = codec->spec;
6284 spec->init_amp = ALC_INIT_DEFAULT;
6286 alc_setup_gpio(codec, 0x04);
6287 snd_hda_apply_pincfgs(codec, dock_pins);
6288 spec->gen.auto_mute_via_amp = 1;
6289 spec->gen.automute_hook = asus_tx300_automute;
6290 snd_hda_jack_detect_enable_callback(codec, 0x1b,
6294 spec->init_amp = ALC_INIT_DEFAULT;
6300 rename_ctl(codec, "Speaker Playback Switch",
6302 rename_ctl(codec, "Bass Speaker Playback Switch",
6308 static void alc290_fixup_mono_speakers(struct hda_codec *codec,
6316 snd_hda_override_conn_list(codec, 0x14, ARRAY_SIZE(conn1), conn1);
6317 snd_hda_override_conn_list(codec, 0x15, ARRAY_SIZE(conn1), conn1);
6321 static void alc298_fixup_speaker_volume(struct hda_codec *codec,
6327 Amp-out capability. we change the speaker's route to:
6328 Node 0x02 (Audio Output) -> Node 0x0c (Audio Mixer) -> Node 0x17 (
6329 Pin Complex), since Node 0x02 has Amp-out caps, we can adjust
6333 snd_hda_override_conn_list(codec, 0x17, ARRAY_SIZE(conn1), conn1);
6338 static void alc295_fixup_disable_dac3(struct hda_codec *codec,
6343 snd_hda_override_conn_list(codec, 0x17, ARRAY_SIZE(conn), conn);
6348 static void alc285_fixup_speaker2_to_dac1(struct hda_codec *codec,
6353 snd_hda_override_conn_list(codec, 0x17, ARRAY_SIZE(conn), conn);
6358 static void alc280_hp_gpio4_automute_hook(struct hda_codec *codec,
6361 struct alc_spec *spec = codec->spec;
6363 snd_hda_gen_hp_automute(codec, jack);
6365 alc_update_gpio_led(codec, 0x10, spec->mute_led_polarity,
6366 !spec->gen.hp_jack_present);
6375 static void alc280_fixup_hp_9480m(struct hda_codec *codec,
6379 struct alc_spec *spec = codec->spec;
6381 alc_fixup_hp_gpio_led(codec, action, 0x08, 0);
6384 spec->gpio_mask |= 0x10;
6385 spec->gpio_dir |= 0x10;
6386 spec->gen.hp_automute_hook = alc280_hp_gpio4_automute_hook;
6390 static void alc275_fixup_gpio4_off(struct hda_codec *codec,
6394 struct alc_spec *spec = codec->spec;
6397 spec->gpio_mask |= 0x04;
6398 spec->gpio_dir |= 0x04;
6405 * DAC1 (NID 0x02) -> Speaker (NID 0x14); some eq applied secretly
6406 * DAC2 (NID 0x03) -> Bass (NID 0x17) & Headphone (NID 0x21); sharing a DAC
6407 * DAC3 (NID 0x06) -> Unused, due to the lack of volume amp
6409 static void alc285_fixup_thinkpad_x1_gen7(struct hda_codec *codec,
6416 struct alc_spec *spec = codec->spec;
6420 snd_hda_override_conn_list(codec, 0x17, ARRAY_SIZE(conn), conn);
6421 spec->gen.preferred_dacs = preferred_pairs;
6430 rename_ctl(codec, "Front Playback Volume", "DAC1 Playback Volume");
6431 rename_ctl(codec, "Bass Speaker Playback Volume", "DAC2 Playback Volume");
6436 static void alc233_alc662_fixup_lenovo_dual_codecs(struct hda_codec *codec,
6440 alc_fixup_dual_codecs(codec, fix, action);
6444 strcpy(codec->card->longname, "HDAudio-Lenovo-DualCodecs");
6447 /* rename Capture controls depending on the codec */
6448 rename_ctl(codec, "Capture Volume",
6449 codec->addr == 0 ?
6450 "Rear-Panel Capture Volume" :
6451 "Front-Panel Capture Volume");
6452 rename_ctl(codec, "Capture Switch",
6453 codec->addr == 0 ?
6454 "Rear-Panel Capture Switch" :
6455 "Front-Panel Capture Switch");
6460 static void alc225_fixup_s3_pop_noise(struct hda_codec *codec,
6466 codec->power_save_node = 1;
6470 static void alc274_fixup_bind_dacs(struct hda_codec *codec,
6473 struct alc_spec *spec = codec->spec;
6482 spec->gen.preferred_dacs = preferred_pairs;
6483 spec->gen.auto_mute_via_amp = 1;
6484 codec->power_save_node = 0;
6488 static void alc289_fixup_asus_ga401(struct hda_codec *codec,
6494 struct alc_spec *spec = codec->spec;
6497 spec->gen.preferred_dacs = preferred_pairs;
6498 spec->gen.obey_preferred_dacs = 1;
6503 static void alc285_fixup_invalidate_dacs(struct hda_codec *codec,
6509 snd_hda_override_wcaps(codec, 0x03, 0);
6512 static void alc_combo_jack_hp_jd_restart(struct hda_codec *codec)
6514 switch (codec->core.vendor_id) {
6520 alc_update_coef_idx(codec, 0x4a, 0x8000, 1 << 15); /* Reset HP JD */
6521 alc_update_coef_idx(codec, 0x4a, 0x8000, 0 << 15);
6530 alc_update_coef_idx(codec, 0x1b, 0x8000, 1 << 15); /* Reset HP JD */
6531 alc_update_coef_idx(codec, 0x1b, 0x8000, 0 << 15);
6536 static void alc295_fixup_chromebook(struct hda_codec *codec,
6539 struct alc_spec *spec = codec->spec;
6543 spec->ultra_low_power = true;
6546 alc_combo_jack_hp_jd_restart(codec);
6551 static void alc_fixup_disable_mic_vref(struct hda_codec *codec,
6555 snd_hda_codec_set_pin_target(codec, 0x19, PIN_VREFHIZ);
6559 static void alc294_gx502_toggle_output(struct hda_codec *codec,
6562 /* The Windows driver sets the codec up in a very different way where
6565 if (snd_hda_jack_detect_state(codec, 0x21) == HDA_JACK_PRESENT)
6566 alc_write_coef_idx(codec, 0x10, 0x8a20);
6568 alc_write_coef_idx(codec, 0x10, 0x0a20);
6571 static void alc294_fixup_gx502_hp(struct hda_codec *codec,
6575 if (!is_jack_detectable(codec, 0x21))
6580 snd_hda_jack_detect_enable_callback(codec, 0x21,
6587 alc294_gx502_toggle_output(codec, NULL);
6592 static void alc294_gu502_toggle_output(struct hda_codec *codec,
6598 if (snd_hda_jack_detect_state(codec, 0x21) == HDA_JACK_PRESENT)
6599 alc_write_coef_idx(codec, 0x10, 0x8420);
6601 alc_write_coef_idx(codec, 0x10, 0x0a20);
6604 static void alc294_fixup_gu502_hp(struct hda_codec *codec,
6607 if (!is_jack_detectable(codec, 0x21))
6612 snd_hda_jack_detect_enable_callback(codec, 0x21,
6616 alc294_gu502_toggle_output(codec, NULL);
6621 static void alc285_fixup_hp_gpio_amp_init(struct hda_codec *codec,
6628 alc_write_coef_idx(codec, 0x65, 0x0);
6631 static void alc274_fixup_hp_headset_mic(struct hda_codec *codec,
6636 alc_combo_jack_hp_jd_restart(codec);
6641 static void alc_fixup_no_int_mic(struct hda_codec *codec,
6644 struct alc_spec *spec = codec->spec;
6649 alc_update_coef_idx(codec, 0x45, 0xf<<12 | 1<<10, 5<<12);
6650 spec->no_internal_mic_pin = true;
6653 alc_combo_jack_hp_jd_restart(codec);
6661 static void alc285_fixup_hp_spectre_x360_eb1(struct hda_codec *codec,
6666 struct alc_spec *spec = codec->spec;
6674 alc_fixup_hp_gpio_led(codec, action, 0x00, 0x04);
6678 spec->micmute_led_polarity = 1;
6680 spec->gpio_mask |= 0x01;
6681 spec->gpio_dir |= 0x01;
6682 snd_hda_apply_pincfgs(codec, pincfgs);
6684 snd_hda_override_conn_list(codec, 0x14, ARRAY_SIZE(conn), conn);
6685 snd_hda_override_conn_list(codec, 0x17, ARRAY_SIZE(conn), conn);
6689 alc_update_gpio_data(codec, 0x01, true);
6691 alc_update_gpio_data(codec, 0x01, false);
6696 static void alc285_fixup_hp_spectre_x360(struct hda_codec *codec,
6707 snd_hda_apply_pincfgs(codec, pincfgs);
6709 snd_hda_override_conn_list(codec, 0x17, ARRAY_SIZE(conn), conn);
6714 static void alc285_fixup_hp_envy_x360(struct hda_codec *codec,
6740 snd_hda_apply_pincfgs(codec, pincfgs);
6743 alc295_fixup_disable_dac3(codec, fix, action);
6746 snd_hda_codec_amp_stereo(codec, 0x21, HDA_OUTPUT, 0, -1, 0);
6748 /* Auto-enable headset mic when plugged */
6749 snd_hda_jack_set_gating_jack(codec, 0x19, 0x21);
6752 snd_hda_codec_set_pin_target(codec, 0x19, PIN_VREF50);
6755 alc_process_coef_fw(codec, coefs);
6758 rename_ctl(codec, "Bass Speaker Playback Volume",
6759 "B&O-Tuned Playback Volume");
6760 rename_ctl(codec, "Front Playback Switch",
6762 rename_ctl(codec, "Bass Speaker Playback Switch",
6771 static void alc_fixup_thinkpad_acpi(struct hda_codec *codec,
6774 alc_fixup_no_shutup(codec, fix, action); /* reduce click noise */
6775 hda_fixup_thinkpad_acpi(codec, fix, action);
6779 static void alc287_fixup_legion_15imhg05_speakers(struct hda_codec *codec,
6783 struct alc_spec *spec = codec->spec;
6787 spec->gen.suppress_auto_mute = 1;
6795 struct alc_spec *spec = cdc->spec;
6797 return component_bind_all(dev, spec->comps);
6803 struct alc_spec *spec = cdc->spec;
6805 component_unbind_all(dev, spec->comps);
6816 struct alc_spec *spec = cdc->spec;
6820 if (spec->comps[i].dev && spec->comps[i].pre_playback_hook)
6821 spec->comps[i].pre_playback_hook(spec->comps[i].dev, action);
6824 if (spec->comps[i].dev && spec->comps[i].playback_hook)
6825 spec->comps[i].playback_hook(spec->comps[i].dev, action);
6828 if (spec->comps[i].dev && spec->comps[i].post_playback_hook)
6829 spec->comps[i].post_playback_hook(spec->comps[i].dev, action);
6844 int n = strlen(p->bus);
6848 if (strncmp(d, p->bus, n))
6854 snprintf(tmp, sizeof(tmp), "-%s:00-cs35l41-hda.%d", p->hid, p->index);
6863 int n = strlen(p->bus);
6867 if (strncmp(d, p->bus, n))
6873 snprintf(tmp, sizeof(tmp), "-%s:00", p->hid);
6882 struct alc_spec *spec = cdc->spec;
6892 rec->bus = bus;
6893 rec->hid = hid;
6894 rec->index = i;
6895 spec->comps[i].codec = cdc;
6896 component_match_add(dev, &spec->match,
6899 ret = component_master_add_with_match(dev, &comp_master_ops, spec->match);
6903 spec->gen.pcm_playback_hook = comp_generic_playback_hook;
6915 struct alc_spec *spec = cdc->spec;
6924 rec->bus = bus;
6925 rec->hid = hid;
6926 rec->index = 0;
6927 spec->comps[0].codec = cdc;
6928 component_match_add(dev, &spec->match,
6931 spec->match);
6937 spec->gen.pcm_playback_hook =
6951 static void cs35l41_fixup_spi_two(struct hda_codec *codec, const struct hda_fixup *fix, int action)
6953 cs35l41_generic_fixup(codec, action, "spi", "CSC3551", 2);
6956 static void cs35l41_fixup_spi_four(struct hda_codec *codec, const struct hda_fixup *fix, int action)
6958 cs35l41_generic_fixup(codec, action, "spi", "CSC3551", 4);
6992 static void alc256_fixup_set_coef_defaults(struct hda_codec *codec,
7001 * plugged-in state, while the internal microphone is always in an
7004 alc_process_coef_fw(codec, alc256_fixup_set_coef_defaults_coefs);
7014 static void alc233_fixup_no_audio_jack(struct hda_codec *codec,
7025 alc_process_coef_fw(codec, alc233_fixup_no_audio_jack_coefs);
7028 static void alc256_fixup_mic_no_presence_and_resume(struct hda_codec *codec,
7033 * The Clevo NJ51CU comes either with the ALC293 or the ALC256 codec,
7034 * but uses the 0x8686 subproduct id in both cases. The ALC256 codec
7037 if (codec->core.vendor_id == 0x10ec0256) {
7038 alc_update_coef_idx(codec, 0x10, 1<<9, 0);
7039 snd_hda_codec_set_pincfg(codec, 0x19, 0x04a11120);
7041 snd_hda_codec_set_pincfg(codec, 0x1a, 0x04a1113c);
7045 static void alc_fixup_dell4_mic_no_presence_quiet(struct hda_codec *codec,
7049 struct alc_spec *spec = codec->spec;
7050 struct hda_input_mux *imux = &spec->gen.input_mux;
7053 alc269_fixup_limit_int_mic_boost(codec, fix, action);
7059 * to Hi-Z to avoid pop noises at startup and when plugging and
7062 snd_hda_codec_set_pin_target(codec, 0x19, PIN_VREFHIZ);
7063 snd_hda_codec_set_pin_target(codec, 0x1b, PIN_VREFHIZ);
7070 for (i = 0; i < imux->num_items; i++) {
7071 if (spec->gen.imux_pins[i] == 0x12) {
7072 spec->gen.cur_mux[0] = i;
7080 static void alc287_fixup_yoga9_14iap7_bass_spk_pin(struct hda_codec *codec,
7106 struct alc_spec *spec = codec->spec;
7110 snd_hda_apply_pincfgs(codec, pincfgs);
7111 snd_hda_override_conn_list(codec, 0x17, ARRAY_SIZE(conn), conn);
7112 spec->gen.preferred_dacs = preferred_pairs;
7117 static void alc295_fixup_dell_inspiron_top_speakers(struct hda_codec *codec,
7132 struct alc_spec *spec = codec->spec;
7134 alc_fixup_no_shutup(codec, fix, action);
7138 snd_hda_apply_pincfgs(codec, pincfgs);
7139 snd_hda_override_conn_list(codec, 0x17, ARRAY_SIZE(conn), conn);
7140 spec->gen.preferred_dacs = preferred_pairs;
7146 static void alc287_fixup_bind_dacs(struct hda_codec *codec,
7149 struct alc_spec *spec = codec->spec;
7158 snd_hda_override_conn_list(codec, 0x17, ARRAY_SIZE(conn), conn);
7159 spec->gen.preferred_dacs = preferred_pairs;
7160 spec->gen.auto_mute_via_amp = 1;
7161 if (spec->gen.autocfg.speaker_pins[0] != 0x14) {
7162 snd_hda_codec_write_cache(codec, 0x14, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
7167 static void alc_fixup_headset_mic(struct hda_codec *codec,
7170 struct alc_spec *spec = codec->spec;
7178 snd_hda_apply_pincfgs(codec, pincfgs);
7179 alc_update_coef_idx(codec, 0x45, 0xf<<12 | 1<<10, 5<<12);
7180 spec->parse_flags |= HDA_PINCFG_HEADSET_MIC;
7469 * depending on the codec ID
7471 static void alc298_fixup_lenovo_c940_duet7(struct hda_codec *codec,
7477 if (codec->core.vendor_id == 0x10ec0298)
7481 __snd_hda_apply_fixup(codec, id, action, 0);
7485 * 14IRP8 PCI SSID will mistakenly be matched with the DuetITL codec SSID,
7486 * so we need to apply a different fixup in this case. The only DuetITL codec
7491 static void alc287_fixup_lenovo_14irp8_duetitl(struct hda_codec *codec,
7497 if (codec->core.subsystem_id == 0x17aa3802)
7501 __snd_hda_apply_fixup(codec, id, action, 0);
7609 { 0x1a, 0x2101103f }, /* dock line-out */
7610 { 0x1b, 0x23a11040 }, /* dock mic-in */
7671 { 0x19, 0x99a3092f }, /* int-mic */
7678 { 0x12, 0x99a3092f }, /* int-mic */
7690 { 0x19, 0x99a3092f }, /* int-mic */
7698 { 0x12, 0x99a3092f }, /* int-mic */
7892 { 0x1b, 0x99a7012f }, /* int-mic */
7912 { 0x12, 0x99a3092f }, /* int-mic */
7937 /* class-D output amp +5dB */
7963 { 0x12, 0x99a3092f }, /* int-mic */
8154 { 0x1b, 0x21011020 }, /* line-out */
8156 { 0x18, 0x2181103f }, /* line-in */
8165 { 0x1b, 0x21011020 }, /* line-out */
8166 { 0x18, 0x2181103f }, /* line-in */
8309 /* Disable pass-through path for FRONT 14h */
8665 /* Disable PCBEEP-IN passthrough */
8878 /* set 0x15 to HP-OUT ctrl */
8905 /* set 0x15 to HP-OUT ctrl */
8909 /* set 0x1b to HP-OUT */
9695 SND_PCI_QUIRK(0x1025, 0x072d, "Acer Aspire V5-571G", ALC269_FIXUP_ASPIRE_HEADSET_MIC),
9698 SND_PCI_QUIRK(0x1025, 0x0762, "Acer Aspire E1-472", ALC271_FIXUP_HP_GATE_MIC_JACK_E1_572),
9699 SND_PCI_QUIRK(0x1025, 0x0775, "Acer Aspire E1-572", ALC271_FIXUP_HP_GATE_MIC_JACK_E1_572),
9700 SND_PCI_QUIRK(0x1025, 0x079b, "Acer Aspire V5-573G", ALC282_FIXUP_ASPIRE_V5_PINS),
9701 SND_PCI_QUIRK(0x1025, 0x080d, "Acer Aspire V5-122P", ALC269_FIXUP_ASPIRE_HEADSET_MIC),
9703 SND_PCI_QUIRK(0x1025, 0x100c, "Acer Aspire E5-574G", ALC255_FIXUP_ACER_LIMIT_INT_MIC_BOOST),
9705 SND_PCI_QUIRK(0x1025, 0x102b, "Acer Aspire C24-860", ALC286_FIXUP_ACER_AIO_MIC_NO_PRESENCE),
9706 SND_PCI_QUIRK(0x1025, 0x1065, "Acer Aspire C20-820", ALC269VC_FIXUP_ACER_HEADSET_MIC),
9708 SND_PCI_QUIRK(0x1025, 0x1094, "Acer Aspire E5-575T", ALC255_FIXUP_ACER_LIMIT_INT_MIC_BOOST),
9709 SND_PCI_QUIRK(0x1025, 0x1099, "Acer Aspire E5-523G", ALC255_FIXUP_ACER_MIC_NO_PRESENCE),
9710 SND_PCI_QUIRK(0x1025, 0x110e, "Acer Aspire ES1-432", ALC255_FIXUP_ACER_MIC_NO_PRESENCE),
9713 SND_PCI_QUIRK(0x1025, 0x1177, "Acer Predator G9-593", ALC255_FIXUP_PREDATOR_SUBWOOFER),
9714 SND_PCI_QUIRK(0x1025, 0x1178, "Acer Predator G9-593", ALC255_FIXUP_PREDATOR_SUBWOOFER),
9718 SND_PCI_QUIRK(0x1025, 0x1269, "Acer SWIFT SF314-54", ALC256_FIXUP_ACER_HEADSET_MIC),
9719 SND_PCI_QUIRK(0x1025, 0x126a, "Acer Swift SF114-32", ALC256_FIXUP_ACER_MIC_NO_PRESENCE),
9723 SND_PCI_QUIRK(0x1025, 0x129c, "Acer SWIFT SF314-55", ALC256_FIXUP_ACER_HEADSET_MIC),
9724 SND_PCI_QUIRK(0x1025, 0x129d, "Acer SWIFT SF313-51", ALC256_FIXUP_ACER_MIC_NO_PRESENCE),
9725 SND_PCI_QUIRK(0x1025, 0x1300, "Acer SWIFT SF314-56", ALC256_FIXUP_ACER_MIC_NO_PRESENCE),
9726 SND_PCI_QUIRK(0x1025, 0x1308, "Acer Aspire Z24-890", ALC286_FIXUP_ACER_AIO_HEADSET_MIC),
9727 SND_PCI_QUIRK(0x1025, 0x132a, "Acer TravelMate B114-21", ALC233_FIXUP_ACER_HEADSET_MIC),
9728 SND_PCI_QUIRK(0x1025, 0x1330, "Acer TravelMate X514-51T", ALC255_FIXUP_ACER_HEADSET_MIC),
9729 SND_PCI_QUIRK(0x1025, 0x141f, "Acer Spin SP513-54N", ALC255_FIXUP_ACER_MIC_NO_PRESENCE),
9730 SND_PCI_QUIRK(0x1025, 0x142b, "Acer Swift SF314-42", ALC255_FIXUP_ACER_MIC_NO_PRESENCE),
9731 SND_PCI_QUIRK(0x1025, 0x1430, "Acer TravelMate B311R-31", ALC256_FIXUP_ACER_MIC_NO_PRESENCE),
9732 SND_PCI_QUIRK(0x1025, 0x1466, "Acer Aspire A515-56", ALC255_FIXUP_ACER_HEADPHONE_AND_MIC),
9733 SND_PCI_QUIRK(0x1025, 0x1534, "Acer Predator PH315-54", ALC255_FIXUP_ACER_MIC_NO_PRESENCE),
9793 SND_PCI_QUIRK(0x1028, 0x0b37, "Dell Inspiron 16 Plus 7620 2-in-1", ALC295_FIXUP_DELL_INSPIRON_TOP_SPEAKERS),
9797 SND_PCI_QUIRK(0x1028, 0x0c0b, "Dell Oasis 14 RPL-P", ALC289_FIXUP_RTK_AMP_DUAL_SPK),
9806 SND_PCI_QUIRK(0x1028, 0x0cbd, "Dell Oasis 13 CS MTL-U", ALC289_FIXUP_DELL_CS35L41_SPI_2),
9807 SND_PCI_QUIRK(0x1028, 0x0cbe, "Dell Oasis 13 2-IN-1 MTL-U", ALC289_FIXUP_DELL_CS35L41_SPI_2),
9808 SND_PCI_QUIRK(0x1028, 0x0cbf, "Dell Oasis 13 Low Weight MTU-L", ALC289_FIXUP_DELL_CS35L41_SPI_2),
9810 SND_PCI_QUIRK(0x1028, 0x0cc1, "Dell Oasis 14 MTL-H/U", ALC289_FIXUP_DELL_CS35L41_SPI_2),
9811 SND_PCI_QUIRK(0x1028, 0x0cc2, "Dell Oasis 14 2-in-1 MTL-H/U", ALC289_FIXUP_DELL_CS35L41_SPI_2),
9812 SND_PCI_QUIRK(0x1028, 0x0cc3, "Dell Oasis 14 Low Weight MTL-U", ALC289_FIXUP_DELL_CS35L41_SPI_2),
9813 SND_PCI_QUIRK(0x1028, 0x0cc4, "Dell Oasis 16 MTL-H/U", ALC289_FIXUP_DELL_CS35L41_SPI_2),
9886 SND_PCI_QUIRK(0x103c, 0x841c, "HP Pavilion 15-CK0xx", ALC269_FIXUP_HP_MUTE_LED_MIC3),
9889 SND_PCI_QUIRK(0x103c, 0x84ae, "HP 15-db0403ng", ALC236_FIXUP_HP_MUTE_LED_COEFBIT2),
9890 SND_PCI_QUIRK(0x103c, 0x84da, "HP OMEN dc0019-ur", ALC295_FIXUP_HP_OMEN),
9892 SND_PCI_QUIRK(0x103c, 0x8519, "HP Spectre x360 15-df0xxx", ALC285_FIXUP_HP_SPECTRE_X360),
9894 SND_PCI_QUIRK(0x103c, 0x85de, "HP Envy x360 13-ar0xxx", ALC285_FIXUP_HP_ENVY_X360),
9898 SND_PCI_QUIRK(0x103c, 0x86c1, "HP Laptop 15-da3001TU", ALC236_FIXUP_HP_MUTE_LED_COEFBIT2),
9900 SND_PCI_QUIRK(0x103c, 0x86e7, "HP Spectre x360 15-eb0xxx", ALC285_FIXUP_HP_SPECTRE_X360_EB1),
9901 SND_PCI_QUIRK(0x103c, 0x86e8, "HP Spectre x360 15-eb0xxx", ALC285_FIXUP_HP_SPECTRE_X360_EB1),
9902 SND_PCI_QUIRK(0x103c, 0x86f9, "HP Spectre x360 13-aw0xxx", ALC285_FIXUP_HP_SPECTRE_X360_MUTE_LED),
9912 SND_PCI_QUIRK(0x103c, 0x876e, "HP ENVY x360 Convertible 13-ay0xxx", ALC245_FIXUP_HP_X360_MUTE_LEDS),
9922 SND_PCI_QUIRK(0x103c, 0x87b7, "HP Laptop 14-fq0xxx", ALC236_FIXUP_HP_MUTE_LED_COEFBIT2),
9924 SND_PCI_QUIRK(0x103c, 0x87d3, "HP Laptop 15-gw0xxx", ALC236_FIXUP_HP_MUTE_LED_COEFBIT2),
9934 SND_PCI_QUIRK(0x103c, 0x87fd, "HP Laptop 14-dq2xxx", ALC236_FIXUP_HP_MUTE_LED_COEFBIT2),
9935 SND_PCI_QUIRK(0x103c, 0x87fe, "HP Laptop 15s-fq2xxx", ALC236_FIXUP_HP_MUTE_LED_COEFBIT2),
9938 SND_PCI_QUIRK(0x103c, 0x8811, "HP Spectre x360 15-eb1xxx", ALC285_FIXUP_HP_SPECTRE_X360_EB1),
9939 SND_PCI_QUIRK(0x103c, 0x8812, "HP Spectre x360 15-eb1xxx", ALC285_FIXUP_HP_SPECTRE_X360_EB1),
9950 SND_PCI_QUIRK(0x103c, 0x887a, "HP Laptop 15s-eq2xxx", ALC236_FIXUP_HP_MUTE_LED_COEFBIT2),
9951 SND_PCI_QUIRK(0x103c, 0x888a, "HP ENVY x360 Convertible 15-eu0xxx", ALC245_FIXUP_HP_X360_MUTE_LEDS),
9956 SND_PCI_QUIRK(0x103c, 0x88d0, "HP Pavilion 15-eh1xxx (mainboard 88D0)", ALC287_FIXUP_HP_GPIO_LED),
9957 SND_PCI_QUIRK(0x103c, 0x88dd, "HP Pavilion 15z-ec200", ALC285_FIXUP_HP_MUTE_LED),
9960 SND_PCI_QUIRK(0x103c, 0x8919, "HP Pavilion Aero Laptop 13-be0xxx", ALC287_FIXUP_HP_GPIO_LED),
9986 SND_PCI_QUIRK(0x103c, 0x8a0f, "HP Pavilion 14-ec1xxx", ALC287_FIXUP_HP_GPIO_LED),
9987 SND_PCI_QUIRK(0x103c, 0x8a20, "HP Laptop 15s-fq5xxx", ALC236_FIXUP_HP_MUTE_LED_COEFBIT2),
9988 SND_PCI_QUIRK(0x103c, 0x8a25, "HP Victus 16-d1xxx (MB 8A25)", ALC245_FIXUP_HP_MUTE_LED_COEFBIT),
10032 SND_PCI_QUIRK(0x103c, 0x8c49, "HP Elite x360 830 2-in-1 G11", ALC245_FIXUP_CS35L41_SPI_2_HP_GPIO_LED),
10170 SND_PCI_QUIRK(0x10ec, 0x11bc, "VAIO VJFE-IL", ALC269_FIXUP_LIMIT_INT_MIC_BOOST),
10176 SND_PCI_QUIRK(0x10f7, 0x8338, "Panasonic CF-SZ6", ALC269_FIXUP_ASPIRE_HEADSET_MIC),
10178 SND_PCI_QUIRK(0x144d, 0xc169, "Samsung Notebook 9 Pen (NP930SBE-K01US)", ALC298_FIXUP_SAMSUNG_AMP),
10179 SND_PCI_QUIRK(0x144d, 0xc176, "Samsung Notebook 9 Pro (NP930MBE-K04US)", ALC298_FIXUP_SAMSUNG_AMP),
10180 SND_PCI_QUIRK(0x144d, 0xc189, "Samsung Galaxy Flex Book (NT950QCG-X716)", ALC298_FIXUP_SAMSUNG_AMP),
10181 SND_PCI_QUIRK(0x144d, 0xc18a, "Samsung Galaxy Book Ion (NP930XCJ-K01US)", ALC298_FIXUP_SAMSUNG_AMP),
10182 SND_PCI_QUIRK(0x144d, 0xc1a3, "Samsung Galaxy Book Pro (NP935XDB-KC1SE)", ALC298_FIXUP_SAMSUNG_AMP),
10186 SND_PCI_QUIRK(0x144d, 0xc812, "Samsung Notebook Pen S (NT950SBE-X58)", ALC298_FIXUP_SAMSUNG_AMP),
10187 SND_PCI_QUIRK(0x144d, 0xc830, "Samsung Galaxy Book Ion (NT950XCJ-X716A)", ALC298_FIXUP_SAMSUNG_AMP),
10192 SND_PCI_QUIRK(0x1458, 0xfa53, "Gigabyte BXBT-2807", ALC283_FIXUP_HEADSET_MIC),
10193 SND_PCI_QUIRK(0x1462, 0xb120, "MSI Cubi MS-B120", ALC283_FIXUP_HEADSET_MIC),
10194 SND_PCI_QUIRK(0x1462, 0xb171, "Cubi N 8GL (MS-B171)", ALC283_FIXUP_HEADSET_MIC),
10196 SND_PCI_QUIRK(0x152d, 0x1262, "Huawei NBLB-WAX9N", ALC2XX_FIXUP_HEADSET_MIC),
10238 SND_PCI_QUIRK(0x1558, 0x70f6, "Clevo NH77DPQ-Y", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
10248 SND_PCI_QUIRK(0x1558, 0x8550, "Clevo NH[57][0-9][ER][ACDH]Q", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
10249 SND_PCI_QUIRK(0x1558, 0x8551, "Clevo NH[57][0-9][ER][ACDH]Q", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
10250 SND_PCI_QUIRK(0x1558, 0x8560, "Clevo NH[57][0-9][ER][ACDH]Q", ALC269_FIXUP_HEADSET_MIC),
10251 SND_PCI_QUIRK(0x1558, 0x8561, "Clevo NH[57][0-9][ER][ACDH]Q", ALC269_FIXUP_HEADSET_MIC),
10252 SND_PCI_QUIRK(0x1558, 0x8562, "Clevo NH[57][0-9]RZ[Q]", ALC269_FIXUP_DMIC),
10259 SND_PCI_QUIRK(0x1558, 0x8a20, "Clevo NH55DCQ-Y", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
10260 SND_PCI_QUIRK(0x1558, 0x8a51, "Clevo NH70RCQ-Y", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
10261 SND_PCI_QUIRK(0x1558, 0x8d50, "Clevo NH55RCQ-M", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
10304 SND_PCI_QUIRK(0x17aa, 0x2234, "Thinkpad ICE-1", ALC287_FIXUP_TAS2781_I2C),
10342 SND_PCI_QUIRK(0x17aa, 0x3820, "IdeaPad 330-17IKB 81DM", ALC269_FIXUP_ASPIRE_HEADSET_MIC),
10356 SND_PCI_QUIRK(0x17aa, 0x387d, "Yoga S780-16 pro Quad AAC", ALC287_FIXUP_TAS2781_I2C),
10357 SND_PCI_QUIRK(0x17aa, 0x387e, "Yoga S780-16 pro Quad YC", ALC287_FIXUP_TAS2781_I2C),
10365 SND_PCI_QUIRK(0x17aa, 0x38ba, "Yoga S780-14.5 Air AMD quad YC", ALC287_FIXUP_TAS2781_I2C),
10366 SND_PCI_QUIRK(0x17aa, 0x38bb, "Yoga S780-14.5 Air AMD quad AAC", ALC287_FIXUP_TAS2781_I2C),
10367 SND_PCI_QUIRK(0x17aa, 0x38be, "Yoga S980-14.5 proX YC Dual", ALC287_FIXUP_TAS2781_I2C),
10368 SND_PCI_QUIRK(0x17aa, 0x38bf, "Yoga S980-14.5 proX LX Dual", ALC287_FIXUP_TAS2781_I2C),
10377 SND_PCI_QUIRK(0x17aa, 0x3902, "Lenovo E50-80", ALC269_FIXUP_DMIC_THINKPAD_ACPI),
10380 SND_PCI_QUIRK(0x17aa, 0x3978, "Lenovo B50-70", ALC269_FIXUP_DMIC_THINKPAD_ACPI),
10397 SND_PCI_QUIRK(0x17aa, 0x508b, "Thinkpad X12 Gen 1", ALC287_FIXUP_LEGION_15IMHG05_SPEAKERS),
10405 SND_PCI_QUIRK(0x19e5, 0x3204, "Huawei MACH-WX9", ALC256_FIXUP_HUAWEI_MACH_WX9_PINS),
10406 SND_PCI_QUIRK(0x19e5, 0x320f, "Huawei WRT-WX9 ", ALC256_FIXUP_ASUS_MIC_NO_PRESENCE),
10407 SND_PCI_QUIRK(0x19e5, 0x3212, "Huawei KLV-WX9 ", ALC256_FIXUP_ACER_HEADSET_MIC),
10411 SND_PCI_QUIRK(0x1b7d, 0xa831, "Ordissimo EVE2 ", ALC269VB_FIXUP_ORDISSIMO_EVE2), /* Also known as Malata PC-B1303 */
10415 SND_PCI_QUIRK(0x1c6c, 0x1251, "Positivo N14KP6-TG", ALC288_FIXUP_DELL1_MIC_NO_PRESENCE),
10433 SND_PCI_QUIRK(0x2782, 0x0214, "VAIO VJFE-CL", ALC269_FIXUP_LIMIT_INT_MIC_BOOST),
10438 SND_PCI_QUIRK(0x2782, 0x1707, "Vaio VJFE-ADL", ALC298_FIXUP_SPK_VOLUME),
10508 {.id = ALC269_FIXUP_AMIC, .name = "laptop-amic"},
10509 {.id = ALC269_FIXUP_DMIC, .name = "laptop-dmic"},
10510 {.id = ALC269_FIXUP_STEREO_DMIC, .name = "alc269-dmic"},
10511 {.id = ALC271_FIXUP_DMIC, .name = "alc271-dmic"},
10512 {.id = ALC269_FIXUP_INV_DMIC, .name = "inv-dmic"},
10513 {.id = ALC269_FIXUP_HEADSET_MIC, .name = "headset-mic"},
10514 {.id = ALC269_FIXUP_HEADSET_MODE, .name = "headset-mode"},
10515 {.id = ALC269_FIXUP_HEADSET_MODE_NO_HP_MIC, .name = "headset-mode-no-hp-mic"},
10516 {.id = ALC269_FIXUP_LENOVO_DOCK, .name = "lenovo-dock"},
10517 {.id = ALC269_FIXUP_LENOVO_DOCK_LIMIT_BOOST, .name = "lenovo-dock-limit-boost"},
10518 {.id = ALC269_FIXUP_HP_GPIO_LED, .name = "hp-gpio-led"},
10519 {.id = ALC269_FIXUP_HP_DOCK_GPIO_MIC1_LED, .name = "hp-dock-gpio-mic1-led"},
10520 {.id = ALC269_FIXUP_DELL1_MIC_NO_PRESENCE, .name = "dell-headset-multi"},
10521 {.id = ALC269_FIXUP_DELL2_MIC_NO_PRESENCE, .name = "dell-headset-dock"},
10522 {.id = ALC269_FIXUP_DELL3_MIC_NO_PRESENCE, .name = "dell-headset3"},
10523 {.id = ALC269_FIXUP_DELL4_MIC_NO_PRESENCE, .name = "dell-headset4"},
10524 {.id = ALC269_FIXUP_DELL4_MIC_NO_PRESENCE_QUIET, .name = "dell-headset4-quiet"},
10525 {.id = ALC283_FIXUP_CHROME_BOOK, .name = "alc283-dac-wcaps"},
10526 {.id = ALC283_FIXUP_SENSE_COMBO_JACK, .name = "alc283-sense-combo"},
10527 {.id = ALC292_FIXUP_TPT440_DOCK, .name = "tpt440-dock"},
10530 {.id = ALC298_FIXUP_TPT470_DOCK_FIX, .name = "tpt470-dock-fix"},
10531 {.id = ALC298_FIXUP_TPT470_DOCK, .name = "tpt470-dock"},
10532 {.id = ALC233_FIXUP_LENOVO_MULTI_CODECS, .name = "dual-codecs"},
10533 {.id = ALC700_FIXUP_INTEL_REFERENCE, .name = "alc700-ref"},
10535 {.id = ALC269_FIXUP_DELL_M101Z, .name = "dell-m101z"},
10536 {.id = ALC269_FIXUP_ASUS_G73JW, .name = "asus-g73jw"},
10537 {.id = ALC269_FIXUP_LENOVO_EAPD, .name = "lenovo-eapd"},
10538 {.id = ALC275_FIXUP_SONY_HWEQ, .name = "sony-hweq"},
10541 {.id = ALC269_FIXUP_LIFEBOOK_EXTMIC, .name = "lifebook-extmic"},
10542 {.id = ALC269_FIXUP_LIFEBOOK_HP_PIN, .name = "lifebook-hp-pin"},
10543 {.id = ALC255_FIXUP_LIFEBOOK_U7x7_HEADSET_MIC, .name = "lifebook-u7x7"},
10544 {.id = ALC269VB_FIXUP_AMIC, .name = "alc269vb-amic"},
10545 {.id = ALC269VB_FIXUP_DMIC, .name = "alc269vb-dmic"},
10546 {.id = ALC269_FIXUP_HP_MUTE_LED_MIC1, .name = "hp-mute-led-mic1"},
10547 {.id = ALC269_FIXUP_HP_MUTE_LED_MIC2, .name = "hp-mute-led-mic2"},
10548 {.id = ALC269_FIXUP_HP_MUTE_LED_MIC3, .name = "hp-mute-led-mic3"},
10549 {.id = ALC269_FIXUP_HP_GPIO_MIC1_LED, .name = "hp-gpio-mic1"},
10550 {.id = ALC269_FIXUP_HP_LINE1_MIC1_LED, .name = "hp-line1-mic1"},
10552 {.id = ALC286_FIXUP_SONY_MIC_NO_PRESENCE, .name = "sony-nomic"},
10553 {.id = ALC269_FIXUP_ASPIRE_HEADSET_MIC, .name = "aspire-headset-mic"},
10554 {.id = ALC269_FIXUP_ASUS_X101, .name = "asus-x101"},
10555 {.id = ALC271_FIXUP_HP_GATE_MIC_JACK, .name = "acer-ao7xx"},
10556 {.id = ALC271_FIXUP_HP_GATE_MIC_JACK_E1_572, .name = "acer-aspire-e1"},
10557 {.id = ALC269_FIXUP_ACER_AC700, .name = "acer-ac700"},
10558 {.id = ALC269_FIXUP_LIMIT_INT_MIC_BOOST, .name = "limit-mic-boost"},
10559 {.id = ALC269VB_FIXUP_ASUS_ZENBOOK, .name = "asus-zenbook"},
10560 {.id = ALC269VB_FIXUP_ASUS_ZENBOOK_UX31A, .name = "asus-zenbook-ux31a"},
10562 {.id = ALC282_FIXUP_ASUS_TX300, .name = "asus-tx300"},
10563 {.id = ALC283_FIXUP_INT_MIC, .name = "alc283-int-mic"},
10564 {.id = ALC290_FIXUP_MONO_SPEAKERS_HSJACK, .name = "mono-speakers"},
10565 {.id = ALC290_FIXUP_SUBWOOFER_HSJACK, .name = "alc290-subwoofer"},
10567 {.id = ALC269_FIXUP_DMIC_THINKPAD_ACPI, .name = "dmic-thinkpad"},
10568 {.id = ALC255_FIXUP_ACER_MIC_NO_PRESENCE, .name = "alc255-acer"},
10569 {.id = ALC255_FIXUP_ASUS_MIC_NO_PRESENCE, .name = "alc255-asus"},
10570 {.id = ALC255_FIXUP_DELL1_MIC_NO_PRESENCE, .name = "alc255-dell1"},
10571 {.id = ALC255_FIXUP_DELL2_MIC_NO_PRESENCE, .name = "alc255-dell2"},
10572 {.id = ALC293_FIXUP_DELL1_MIC_NO_PRESENCE, .name = "alc293-dell1"},
10573 {.id = ALC283_FIXUP_HEADSET_MIC, .name = "alc283-headset"},
10574 {.id = ALC255_FIXUP_MIC_MUTE_LED, .name = "alc255-dell-mute"},
10575 {.id = ALC282_FIXUP_ASPIRE_V5_PINS, .name = "aspire-v5"},
10576 {.id = ALC269VB_FIXUP_ASPIRE_E1_COEF, .name = "aspire-e1-coef"},
10577 {.id = ALC280_FIXUP_HP_GPIO4, .name = "hp-gpio4"},
10578 {.id = ALC286_FIXUP_HP_GPIO_LED, .name = "hp-gpio-led"},
10579 {.id = ALC280_FIXUP_HP_GPIO2_MIC_HOTKEY, .name = "hp-gpio2-hotkey"},
10580 {.id = ALC280_FIXUP_HP_DOCK_PINS, .name = "hp-dock-pins"},
10581 {.id = ALC269_FIXUP_HP_DOCK_GPIO_MIC1_LED, .name = "hp-dock-gpio-mic"},
10582 {.id = ALC280_FIXUP_HP_9480M, .name = "hp-9480m"},
10583 {.id = ALC288_FIXUP_DELL_HEADSET_MODE, .name = "alc288-dell-headset"},
10584 {.id = ALC288_FIXUP_DELL1_MIC_NO_PRESENCE, .name = "alc288-dell1"},
10585 {.id = ALC288_FIXUP_DELL_XPS_13, .name = "alc288-dell-xps13"},
10586 {.id = ALC292_FIXUP_DELL_E7X, .name = "dell-e7x"},
10587 {.id = ALC293_FIXUP_DISABLE_AAMIX_MULTIJACK, .name = "alc293-dell"},
10588 {.id = ALC298_FIXUP_DELL1_MIC_NO_PRESENCE, .name = "alc298-dell1"},
10589 {.id = ALC298_FIXUP_DELL_AIO_MIC_NO_PRESENCE, .name = "alc298-dell-aio"},
10590 {.id = ALC275_FIXUP_DELL_XPS, .name = "alc275-dell-xps"},
10591 {.id = ALC293_FIXUP_LENOVO_SPK_NOISE, .name = "lenovo-spk-noise"},
10592 {.id = ALC233_FIXUP_LENOVO_LINE2_MIC_HOTKEY, .name = "lenovo-hotkey"},
10593 {.id = ALC255_FIXUP_DELL_SPK_NOISE, .name = "dell-spk-noise"},
10594 {.id = ALC225_FIXUP_DELL1_MIC_NO_PRESENCE, .name = "alc225-dell1"},
10595 {.id = ALC295_FIXUP_DISABLE_DAC3, .name = "alc295-disable-dac3"},
10596 {.id = ALC285_FIXUP_SPEAKER2_TO_DAC1, .name = "alc285-speaker2-to-dac1"},
10597 {.id = ALC280_FIXUP_HP_HEADSET_MIC, .name = "alc280-hp-headset"},
10598 {.id = ALC221_FIXUP_HP_FRONT_MIC, .name = "alc221-hp-mic"},
10599 {.id = ALC298_FIXUP_SPK_VOLUME, .name = "alc298-spk-volume"},
10600 {.id = ALC256_FIXUP_DELL_INSPIRON_7559_SUBWOOFER, .name = "dell-inspiron-7559"},
10601 {.id = ALC269_FIXUP_ATIV_BOOK_8, .name = "ativ-book"},
10602 {.id = ALC221_FIXUP_HP_MIC_NO_PRESENCE, .name = "alc221-hp-mic"},
10603 {.id = ALC256_FIXUP_ASUS_HEADSET_MODE, .name = "alc256-asus-headset"},
10604 {.id = ALC256_FIXUP_ASUS_MIC, .name = "alc256-asus-mic"},
10605 {.id = ALC256_FIXUP_ASUS_AIO_GPIO2, .name = "alc256-asus-aio"},
10606 {.id = ALC233_FIXUP_ASUS_MIC_NO_PRESENCE, .name = "alc233-asus"},
10607 {.id = ALC233_FIXUP_EAPD_COEF_AND_MIC_NO_PRESENCE, .name = "alc233-eapd"},
10608 {.id = ALC294_FIXUP_LENOVO_MIC_LOCATION, .name = "alc294-lenovo-mic"},
10609 {.id = ALC225_FIXUP_DELL_WYSE_MIC_NO_PRESENCE, .name = "alc225-wyse"},
10610 {.id = ALC274_FIXUP_DELL_AIO_LINEOUT_VERB, .name = "alc274-dell-aio"},
10611 {.id = ALC255_FIXUP_DUMMY_LINEOUT_VERB, .name = "alc255-dummy-lineout"},
10612 {.id = ALC255_FIXUP_DELL_HEADSET_MIC, .name = "alc255-dell-headset"},
10613 {.id = ALC295_FIXUP_HP_X360, .name = "alc295-hp-x360"},
10614 {.id = ALC225_FIXUP_HEADSET_JACK, .name = "alc-headset-jack"},
10615 {.id = ALC295_FIXUP_CHROME_BOOK, .name = "alc-chrome-book"},
10616 {.id = ALC299_FIXUP_PREDATOR_SPK, .name = "predator-spk"},
10617 {.id = ALC298_FIXUP_HUAWEI_MBX_STEREO, .name = "huawei-mbx-stereo"},
10618 {.id = ALC256_FIXUP_MEDION_HEADSET_NO_PRESENCE, .name = "alc256-medion-headset"},
10619 {.id = ALC298_FIXUP_SAMSUNG_AMP, .name = "alc298-samsung-amp"},
10620 {.id = ALC256_FIXUP_SAMSUNG_HEADPHONE_VERY_QUIET, .name = "alc256-samsung-headphone"},
10621 {.id = ALC255_FIXUP_XIAOMI_HEADSET_MIC, .name = "alc255-xiaomi-headset"},
10622 {.id = ALC274_FIXUP_HP_MIC, .name = "alc274-hp-mic-detect"},
10623 {.id = ALC245_FIXUP_HP_X360_AMP, .name = "alc245-hp-x360-amp"},
10624 {.id = ALC295_FIXUP_HP_OMEN, .name = "alc295-hp-omen"},
10625 {.id = ALC285_FIXUP_HP_SPECTRE_X360, .name = "alc285-hp-spectre-x360"},
10626 {.id = ALC285_FIXUP_HP_SPECTRE_X360_EB1, .name = "alc285-hp-spectre-x360-eb1"},
10627 {.id = ALC285_FIXUP_HP_ENVY_X360, .name = "alc285-hp-envy-x360"},
10628 {.id = ALC287_FIXUP_IDEAPAD_BASS_SPK_AMP, .name = "alc287-ideapad-bass-spk-amp"},
10629 {.id = ALC287_FIXUP_YOGA9_14IAP7_BASS_SPK_PIN, .name = "alc287-yoga9-bass-spk-pin"},
10630 {.id = ALC623_FIXUP_LENOVO_THINKSTATION_P340, .name = "alc623-lenovo-thinkstation-p340"},
10631 {.id = ALC255_FIXUP_ACER_HEADPHONE_AND_MIC, .name = "alc255-acer-headphone-and-mic"},
10632 {.id = ALC285_FIXUP_HP_GPIO_AMP_INIT, .name = "alc285-hp-amp-init"},
10633 {.id = ALC236_FIXUP_LENOVO_INV_DMIC, .name = "alc236-fixup-lenovo-inv-mic"},
11068 * at most one tbl is allowed to define for the same vendor and same codec
11095 static void alc269_fill_coef(struct hda_codec *codec)
11097 struct alc_spec *spec = codec->spec;
11100 if (spec->codec_variant != ALC269_TYPE_ALC269VB)
11103 if ((alc_get_coef0(codec) & 0x00ff) < 0x015) {
11104 alc_write_coef_idx(codec, 0xf, 0x960b);
11105 alc_write_coef_idx(codec, 0xe, 0x8817);
11108 if ((alc_get_coef0(codec) & 0x00ff) == 0x016) {
11109 alc_write_coef_idx(codec, 0xf, 0x960b);
11110 alc_write_coef_idx(codec, 0xe, 0x8814);
11113 if ((alc_get_coef0(codec) & 0x00ff) == 0x017) {
11115 alc_update_coef_idx(codec, 0x04, 0, 1<<11);
11118 if ((alc_get_coef0(codec) & 0x00ff) == 0x018) {
11119 val = alc_read_coef_idx(codec, 0xd);
11120 if (val != -1 && (val & 0x0c00) >> 10 != 0x1) {
11122 alc_write_coef_idx(codec, 0xd, val | (1<<10));
11124 val = alc_read_coef_idx(codec, 0x17);
11125 if (val != -1 && (val & 0x01c0) >> 6 != 0x4) {
11127 alc_write_coef_idx(codec, 0x17, val | (1<<7));
11132 alc_update_coef_idx(codec, 0x4, 0, 1<<11);
11137 static int patch_alc269(struct hda_codec *codec)
11142 err = alc_alloc_spec(codec, 0x0b);
11146 spec = codec->spec;
11147 spec->gen.shared_mic_vref_pin = 0x18;
11148 codec->power_save_node = 0;
11149 spec->en_3kpull_low = true;
11152 codec->patch_ops.suspend = alc269_suspend;
11153 codec->patch_ops.resume = alc269_resume;
11155 spec->shutup = alc_default_shutup;
11156 spec->init_hook = alc_default_init;
11158 switch (codec->core.vendor_id) {
11160 spec->codec_variant = ALC269_TYPE_ALC269VA;
11161 switch (alc_get_coef0(codec) & 0x00f0) {
11163 if (codec->bus->pci &&
11164 codec->bus->pci->subsystem_vendor == 0x1025 &&
11165 spec->cdefine.platform_type == 1)
11166 err = alc_codec_rename(codec, "ALC271X");
11167 spec->codec_variant = ALC269_TYPE_ALC269VB;
11170 if (codec->bus->pci &&
11171 codec->bus->pci->subsystem_vendor == 0x17aa &&
11172 codec->bus->pci->subsystem_device == 0x21f3)
11173 err = alc_codec_rename(codec, "ALC3202");
11174 spec->codec_variant = ALC269_TYPE_ALC269VC;
11177 spec->codec_variant = ALC269_TYPE_ALC269VD;
11180 alc_fix_pll_init(codec, 0x20, 0x04, 15);
11184 spec->shutup = alc269_shutup;
11185 spec->init_hook = alc269_fill_coef;
11186 alc269_fill_coef(codec);
11191 spec->codec_variant = ALC269_TYPE_ALC280;
11194 spec->codec_variant = ALC269_TYPE_ALC282;
11195 spec->shutup = alc282_shutup;
11196 spec->init_hook = alc282_init;
11200 spec->codec_variant = ALC269_TYPE_ALC283;
11201 spec->shutup = alc283_shutup;
11202 spec->init_hook = alc283_init;
11206 spec->codec_variant = ALC269_TYPE_ALC284;
11209 spec->codec_variant = ALC269_TYPE_ALC293;
11213 spec->codec_variant = ALC269_TYPE_ALC286;
11216 spec->codec_variant = ALC269_TYPE_ALC298;
11220 spec->codec_variant = ALC269_TYPE_ALC255;
11221 spec->shutup = alc256_shutup;
11222 spec->init_hook = alc256_init;
11228 spec->codec_variant = ALC269_TYPE_ALC256;
11229 spec->shutup = alc256_shutup;
11230 spec->init_hook = alc256_init;
11231 spec->gen.mixer_nid = 0; /* ALC256 does not have any loopback mixer path */
11232 if (codec->core.vendor_id == 0x10ec0236 &&
11233 codec->bus->pci->vendor != PCI_VENDOR_ID_AMD)
11234 spec->en_3kpull_low = false;
11237 spec->codec_variant = ALC269_TYPE_ALC257;
11238 spec->shutup = alc256_shutup;
11239 spec->init_hook = alc256_init;
11240 spec->gen.mixer_nid = 0;
11241 spec->en_3kpull_low = false;
11247 if (alc_get_coef0(codec) & 0x0010)
11248 spec->codec_variant = ALC269_TYPE_ALC245;
11250 spec->codec_variant = ALC269_TYPE_ALC215;
11251 spec->shutup = alc225_shutup;
11252 spec->init_hook = alc225_init;
11253 spec->gen.mixer_nid = 0;
11258 spec->codec_variant = ALC269_TYPE_ALC225;
11259 spec->shutup = alc225_shutup;
11260 spec->init_hook = alc225_init;
11261 spec->gen.mixer_nid = 0; /* no loopback on ALC225, ALC295 and ALC299 */
11264 spec->codec_variant = ALC269_TYPE_ALC287;
11265 spec->shutup = alc225_shutup;
11266 spec->init_hook = alc225_init;
11267 spec->gen.mixer_nid = 0; /* no loopback on ALC287 */
11272 spec->codec_variant = ALC269_TYPE_ALC294;
11273 spec->gen.mixer_nid = 0; /* ALC2x4 does not have any loopback mixer path */
11274 alc_update_coef_idx(codec, 0x6b, 0x0018, (1<<4) | (1<<3)); /* UAJ MIC Vref control by verb */
11275 spec->init_hook = alc294_init;
11278 spec->codec_variant = ALC269_TYPE_ALC300;
11279 spec->gen.mixer_nid = 0; /* no loopback on ALC300 */
11282 spec->codec_variant = ALC269_TYPE_ALC623;
11288 spec->codec_variant = ALC269_TYPE_ALC700;
11289 spec->gen.mixer_nid = 0; /* ALC700 does not have any loopback mixer path */
11290 alc_update_coef_idx(codec, 0x4a, 1 << 15, 0); /* Combo jack auto trigger control */
11291 spec->init_hook = alc294_init;
11296 if (snd_hda_codec_read(codec, 0x51, 0, AC_VERB_PARAMETERS, 0) == 0x10ec5505) {
11297 spec->has_alc5505_dsp = 1;
11298 spec->init_hook = alc5505_dsp_init;
11301 alc_pre_init(codec);
11303 snd_hda_pick_fixup(codec, alc269_fixup_models,
11309 if (codec->fixup_id == ALC282_FIXUP_ASUS_TX300 &&
11310 codec->core.vendor_id == 0x10ec0294) {
11311 codec_dbg(codec, "Clear wrong fixup for ASUS ROG Strix G17\n");
11312 codec->fixup_id = HDA_FIXUP_ID_NOT_SET;
11315 snd_hda_pick_pin_fixup(codec, alc269_pin_fixup_tbl, alc269_fixups, true);
11316 snd_hda_pick_pin_fixup(codec, alc269_fallback_pin_fixup_tbl, alc269_fixups, false);
11317 snd_hda_pick_fixup(codec, NULL, alc269_fixup_vendor_tbl,
11319 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
11321 alc_auto_parse_customize_define(codec);
11323 if (has_cdefine_beep(codec))
11324 spec->gen.beep_nid = 0x01;
11327 err = alc269_parse_auto_config(codec);
11331 if (!spec->gen.no_analog && spec->gen.beep_nid && spec->gen.mixer_nid) {
11332 err = set_beep_amp(spec, spec->gen.mixer_nid, 0x04, HDA_INPUT);
11337 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
11342 alc_free(codec);
11350 static int alc861_parse_auto_config(struct hda_codec *codec)
11354 return alc_parse_auto_config(codec, alc861_ignore, alc861_ssids);
11367 static void alc861_fixup_asus_amp_vref_0f(struct hda_codec *codec,
11370 struct alc_spec *spec = codec->spec;
11375 val = snd_hda_codec_get_pin_target(codec, 0x0f);
11379 snd_hda_set_pin_ctl(codec, 0x0f, val);
11380 spec->gen.keep_vref_in_automute = 1;
11383 /* suppress the jack-detection */
11384 static void alc_fixup_no_jack_detect(struct hda_codec *codec,
11388 codec->no_jack_detect = 1;
11439 static int patch_alc861(struct hda_codec *codec)
11444 err = alc_alloc_spec(codec, 0x15);
11448 spec = codec->spec;
11449 if (has_cdefine_beep(codec))
11450 spec->gen.beep_nid = 0x23;
11453 spec->power_hook = alc_power_eapd;
11456 alc_pre_init(codec);
11458 snd_hda_pick_fixup(codec, NULL, alc861_fixup_tbl, alc861_fixups);
11459 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
11462 err = alc861_parse_auto_config(codec);
11466 if (!spec->gen.no_analog) {
11472 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
11477 alc_free(codec);
11482 * ALC861-VD support
11488 static int alc861vd_parse_auto_config(struct hda_codec *codec)
11492 return alc_parse_auto_config(codec, alc861vd_ignore, alc861vd_ssids);
11501 static void alc861vd_fixup_dallas(struct hda_codec *codec,
11505 snd_hda_override_pin_caps(codec, 0x18, 0x00000734);
11506 snd_hda_override_pin_caps(codec, 0x19, 0x0000073c);
11511 static void alc660vd_fixup_asus_gpio1(struct hda_codec *codec,
11514 struct alc_spec *spec = codec->spec;
11517 spec->gpio_mask |= 0x02;
11518 alc_fixup_gpio(codec, action, 0x01);
11534 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS A7-K", ALC660VD_FIX_ASUS_GPIO1),
11535 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba L30-149", ALC861VD_FIX_DALLAS),
11541 static int patch_alc861vd(struct hda_codec *codec)
11546 err = alc_alloc_spec(codec, 0x0b);
11550 spec = codec->spec;
11551 if (has_cdefine_beep(codec))
11552 spec->gen.beep_nid = 0x23;
11554 spec->shutup = alc_eapd_shutup;
11556 alc_pre_init(codec);
11558 snd_hda_pick_fixup(codec, NULL, alc861vd_fixup_tbl, alc861vd_fixups);
11559 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
11562 err = alc861vd_parse_auto_config(codec);
11566 if (!spec->gen.no_analog) {
11572 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
11577 alc_free(codec);
11587 * 6-channel independent captures.
11589 * In addition, an independent DAC for the multi-playback (not used in this
11597 static int alc662_parse_auto_config(struct hda_codec *codec)
11604 if (codec->core.vendor_id == 0x10ec0272 || codec->core.vendor_id == 0x10ec0663 ||
11605 codec->core.vendor_id == 0x10ec0665 || codec->core.vendor_id == 0x10ec0670 ||
11606 codec->core.vendor_id == 0x10ec0671)
11610 return alc_parse_auto_config(codec, alc662_ignore, ssids);
11613 static void alc272_fixup_mario(struct hda_codec *codec,
11618 if (snd_hda_override_amp_caps(codec, 0x2, HDA_OUTPUT,
11623 codec_warn(codec, "failed to override amp caps for NID 0x2\n");
11636 static void alc_fixup_bass_chmap(struct hda_codec *codec,
11640 struct alc_spec *spec = codec->spec;
11641 spec->gen.pcm_rec[0]->stream[0].chmap = asus_pcm_2_1_chmaps;
11646 static unsigned int gpio_led_power_filter(struct hda_codec *codec,
11650 struct alc_spec *spec = codec->spec;
11651 if (nid == codec->core.afg && power_state == AC_PWRST_D3 && spec->gpio_data)
11656 static void alc662_fixup_led_gpio1(struct hda_codec *codec,
11659 struct alc_spec *spec = codec->spec;
11661 alc_fixup_hp_gpio_led(codec, action, 0x01, 0);
11663 spec->mute_led_polarity = 1;
11664 codec->power_filter = gpio_led_power_filter;
11668 static void alc662_usi_automute_hook(struct hda_codec *codec,
11671 struct alc_spec *spec = codec->spec;
11674 snd_hda_gen_hp_automute(codec, jack);
11676 vref = spec->gen.hp_jack_present ? PIN_VREF80 : 0;
11678 snd_hda_codec_write(codec, 0x19, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
11682 static void alc662_fixup_usi_headset_mic(struct hda_codec *codec,
11685 struct alc_spec *spec = codec->spec;
11687 spec->parse_flags |= HDA_PINCFG_HEADSET_MIC;
11688 spec->gen.hp_automute_hook = alc662_usi_automute_hook;
11692 static void alc662_aspire_ethos_mute_speakers(struct hda_codec *codec,
11698 * 0x15 - front left/front right
11699 * 0x18 - front center/ LFE
11701 if (snd_hda_jack_detect_state(codec, 0x1b) == HDA_JACK_PRESENT) {
11702 snd_hda_set_pin_ctl_cache(codec, 0x15, 0);
11703 snd_hda_set_pin_ctl_cache(codec, 0x18, 0);
11705 snd_hda_set_pin_ctl_cache(codec, 0x15, PIN_OUT);
11706 snd_hda_set_pin_ctl_cache(codec, 0x18, PIN_OUT);
11710 static void alc662_fixup_aspire_ethos_hp(struct hda_codec *codec,
11714 if (!is_jack_detectable(codec, 0x1b))
11719 snd_hda_jack_detect_enable_callback(codec, 0x1b,
11722 alc_setup_gpio(codec, 0x02);
11728 alc662_aspire_ethos_mute_speakers(codec, NULL);
11733 static void alc671_fixup_hp_headset_mic2(struct hda_codec *codec,
11736 struct alc_spec *spec = codec->spec;
11746 spec->gen.mixer_nid = 0;
11747 spec->parse_flags |= HDA_PINCFG_HEADSET_MIC;
11748 snd_hda_apply_pincfgs(codec, pincfgs);
11751 alc_write_coef_idx(codec, 0x19, 0xa054);
11756 static void alc897_hp_automute_hook(struct hda_codec *codec,
11759 struct alc_spec *spec = codec->spec;
11762 snd_hda_gen_hp_automute(codec, jack);
11763 vref = spec->gen.hp_jack_present ? (PIN_HP | AC_PINCTL_VREF_100) : PIN_HP;
11764 snd_hda_set_pin_ctl(codec, 0x1b, vref);
11767 static void alc897_fixup_lenovo_headset_mic(struct hda_codec *codec,
11770 struct alc_spec *spec = codec->spec;
11772 spec->gen.hp_automute_hook = alc897_hp_automute_hook;
11773 spec->no_shutup_pins = 1;
11776 snd_hda_set_pin_ctl_cache(codec, 0x1a, PIN_IN | AC_PINCTL_VREF_100);
11780 static void alc897_fixup_lenovo_headset_mode(struct hda_codec *codec,
11783 struct alc_spec *spec = codec->spec;
11786 spec->parse_flags |= HDA_PINCFG_HEADSET_MIC;
11787 spec->gen.hp_automute_hook = alc897_hp_automute_hook;
11815 static void alc668_restore_default_value(struct hda_codec *codec)
11817 alc_process_coef_fw(codec, alc668_coefs);
11913 {0x19, 0x90a7013f}, /* int-mic */
11949 { 0x19, 0x99a3092f }, /* int-mic */
11961 { 0x19, 0x99a3092f }, /* int-mic */
11974 { 0x19, 0x99a3094f }, /* int-mic */
11987 { 0x19, 0x99a3094f }, /* int-mic */
12001 { 0x19, 0x99a3094f }, /* int-mic */
12013 { 0x19, 0x99a3094f }, /* int-mic */
12026 { 0x19, 0x99a3094f }, /* int-mic */
12038 { 0x12, 0x99a30970 }, /* int-mic */
12335 SND_PCI_QUIRK(0x1019, 0x9859, "JP-IK LEAP W502", ALC897_FIXUP_HEADSET_MIC_PIN3),
12344 SND_PCI_QUIRK(0x1025, 0x123c, "Acer Nitro N50-600", ALC662_FIXUP_ACER_NITRO_HEADSET_MODE),
12391 SND_PCI_QUIRK(0x17aa, 0x3742, "Lenovo TianYi510Pro-14IOB", ALC897_FIXUP_HEADSET_MIC_PIN2),
12399 SND_PCI_QUIRK(0x1c6c, 0x1239, "Compaq N14JP6-V2", ALC897_FIXUP_HP_HSMIC_VERB),
12465 {.id = ALC662_FIXUP_HP_RP5800, .name = "hp-rp5800"},
12466 {.id = ALC662_FIXUP_ASUS_MODE1, .name = "asus-mode1"},
12467 {.id = ALC662_FIXUP_ASUS_MODE2, .name = "asus-mode2"},
12468 {.id = ALC662_FIXUP_ASUS_MODE3, .name = "asus-mode3"},
12469 {.id = ALC662_FIXUP_ASUS_MODE4, .name = "asus-mode4"},
12470 {.id = ALC662_FIXUP_ASUS_MODE5, .name = "asus-mode5"},
12471 {.id = ALC662_FIXUP_ASUS_MODE6, .name = "asus-mode6"},
12472 {.id = ALC662_FIXUP_ASUS_MODE7, .name = "asus-mode7"},
12473 {.id = ALC662_FIXUP_ASUS_MODE8, .name = "asus-mode8"},
12474 {.id = ALC662_FIXUP_ZOTAC_Z68, .name = "zotac-z68"},
12475 {.id = ALC662_FIXUP_INV_DMIC, .name = "inv-dmic"},
12476 {.id = ALC662_FIXUP_DELL_MIC_NO_PRESENCE, .name = "alc662-headset-multi"},
12477 {.id = ALC668_FIXUP_DELL_MIC_NO_PRESENCE, .name = "dell-headset-multi"},
12478 {.id = ALC662_FIXUP_HEADSET_MODE, .name = "alc662-headset"},
12479 {.id = ALC668_FIXUP_HEADSET_MODE, .name = "alc668-headset"},
12483 {.id = ALC668_FIXUP_DELL_XPS13, .name = "dell-xps13"},
12484 {.id = ALC662_FIXUP_ASUS_Nx50, .name = "asus-nx50"},
12485 {.id = ALC668_FIXUP_ASUS_Nx51, .name = "asus-nx51"},
12486 {.id = ALC668_FIXUP_ASUS_G751, .name = "asus-g751"},
12487 {.id = ALC891_FIXUP_HEADSET_MODE, .name = "alc891-headset"},
12488 {.id = ALC891_FIXUP_DELL_MIC_NO_PRESENCE, .name = "alc891-headset-multi"},
12489 {.id = ALC662_FIXUP_ACER_VERITON, .name = "acer-veriton"},
12490 {.id = ALC892_FIXUP_ASROCK_MOBO, .name = "asrock-mobo"},
12491 {.id = ALC662_FIXUP_USI_HEADSET_MODE, .name = "usi-headset"},
12492 {.id = ALC662_FIXUP_LENOVO_MULTI_CODECS, .name = "dual-codecs"},
12493 {.id = ALC669_FIXUP_ACER_ASPIRE_ETHOS, .name = "aspire-ethos"},
12494 {.id = ALC897_FIXUP_UNIS_H3C_X500S, .name = "unis-h3c-x500s"},
12559 static int patch_alc662(struct hda_codec *codec)
12564 err = alc_alloc_spec(codec, 0x0b);
12568 spec = codec->spec;
12570 spec->shutup = alc_eapd_shutup;
12573 spec->parse_flags = HDA_PINCFG_NO_HP_FIXUP;
12575 alc_fix_pll_init(codec, 0x20, 0x04, 15);
12577 switch (codec->core.vendor_id) {
12579 spec->init_hook = alc668_restore_default_value;
12583 alc_pre_init(codec);
12585 snd_hda_pick_fixup(codec, alc662_fixup_models,
12587 snd_hda_pick_pin_fixup(codec, alc662_pin_fixup_tbl, alc662_fixups, true);
12588 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
12590 alc_auto_parse_customize_define(codec);
12592 if (has_cdefine_beep(codec))
12593 spec->gen.beep_nid = 0x01;
12595 if ((alc_get_coef0(codec) & (1 << 14)) &&
12596 codec->bus->pci && codec->bus->pci->subsystem_vendor == 0x1025 &&
12597 spec->cdefine.platform_type == 1) {
12598 err = alc_codec_rename(codec, "ALC272X");
12604 err = alc662_parse_auto_config(codec);
12608 if (!spec->gen.no_analog && spec->gen.beep_nid) {
12609 switch (codec->core.vendor_id) {
12627 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
12632 alc_free(codec);
12640 static int alc680_parse_auto_config(struct hda_codec *codec)
12642 return alc_parse_auto_config(codec, NULL, NULL);
12647 static int patch_alc680(struct hda_codec *codec)
12651 /* ALC680 has no aa-loopback mixer */
12652 err = alc_alloc_spec(codec, 0);
12657 err = alc680_parse_auto_config(codec);
12659 alc_free(codec);
12713 HDA_CODEC_ENTRY(0x10ec0660, "ALC660-VD", patch_alc861vd),
12715 HDA_CODEC_ENTRY(0x10ec0862, "ALC861-VD", patch_alc861vd),
12754 MODULE_DESCRIPTION("Realtek HD-audio codec");