Lines Matching defs:codec

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);
143 static void coef_mutex_lock(struct hda_codec *codec)
145 struct alc_spec *spec = codec->spec;
147 snd_hda_power_up_pm(codec);
151 static void coef_mutex_unlock(struct hda_codec *codec)
153 struct alc_spec *spec = codec->spec;
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);
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;
230 spec->coef0 = alc_read_coef_idx(codec, 0);
248 static void alc_process_coef_fw(struct hda_codec *codec,
251 coef_mutex_lock(codec);
254 __alc_write_coefex_idx(codec, fw->nid, fw->idx, fw->val);
256 __alc_update_coefex_idx(codec, fw->nid, fw->idx,
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;
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,
284 static void alc_update_gpio_data(struct hda_codec *codec, unsigned int mask,
287 struct alc_spec *spec = codec->spec;
295 alc_write_gpio_data(codec);
298 static void alc_write_gpio(struct hda_codec *codec)
300 struct alc_spec *spec = codec->spec;
305 snd_hda_codec_write(codec, codec->core.afg, 0,
307 snd_hda_codec_write(codec, codec->core.afg, 0,
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);
357 static void alc_fix_pll(struct hda_codec *codec)
359 struct alc_spec *spec = codec->spec;
362 alc_update_coefex_idx(codec, spec->pll_nid, spec->pll_coef_idx,
366 static void alc_fix_pll_init(struct hda_codec *codec, hda_nid_t nid,
369 struct alc_spec *spec = codec->spec;
373 alc_fix_pll(codec);
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,
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);
479 alc_update_coef_idx(codec, 0x10, 1<<15, 0);
483 alc_update_coef_idx(codec, 0x4, 1<<10, 0); /* EAPD Ctrl */
492 alc_update_coef_idx(codec, 0xd, 0, 1<<14); /* EAPD Ctrl */
496 alc_update_coef_idx(codec, 0x19, 1<<13, 0);
499 alc_update_coef_idx(codec, 0x7, 3<<13, 0);
502 alc_update_coef_idx(codec, 0x4, 1<<10, 0);
506 alc_update_coef_idx(codec, 0x7, 1<<5, 0);
510 alc_update_coef_idx(codec, 0x7, 1<<5, 0);
517 alc_update_coef_idx(codec, 0x7, 1<<1, 0);
523 static void alc888_coef_init(struct hda_codec *codec)
525 switch (alc_get_coef0(codec) & 0x00f0) {
530 alc_update_coef_idx(codec, 7, 0, 0x2030); /* Turn EAPD to High */
536 static void set_eapd(struct hda_codec *codec, hda_nid_t nid, int on)
538 if (get_wcaps_type(get_wcaps(codec, nid)) != AC_WID_PIN)
540 if (snd_hda_query_pin_caps(codec, nid) & AC_PINCAP_EAPD)
541 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
545 /* turn on/off EAPD controls of the codec */
546 static void alc_auto_setup_eapd(struct hda_codec *codec, bool on)
554 set_eapd(codec, *p, on);
557 static int find_ext_mic_pin(struct hda_codec *codec);
559 static void alc_headset_mic_no_shutup(struct hda_codec *codec)
562 int mic_pin = find_ext_mic_pin(codec);
568 if (codec->bus->shutdown)
571 snd_array_for_each(&codec->init_pins, i, pin) {
574 snd_hda_codec_read(codec, pin->nid, 0,
578 codec->pins_shutup = 1;
581 static void alc_shutup_pins(struct hda_codec *codec)
583 struct alc_spec *spec = codec->spec;
585 switch (codec->core.vendor_id) {
593 alc_headset_mic_no_shutup(codec);
597 snd_hda_shutup_pins(codec);
605 static void alc_eapd_shutup(struct hda_codec *codec)
607 struct alc_spec *spec = codec->spec;
609 alc_auto_setup_eapd(codec, false);
612 alc_shutup_pins(codec);
616 static void alc_auto_init_amp(struct hda_codec *codec, int type)
618 alc_auto_setup_eapd(codec, true);
619 alc_write_gpio(codec);
622 switch (codec->core.vendor_id) {
624 alc_update_coefex_idx(codec, 0x1a, 7, 0, 0x2010);
630 alc_update_coef_idx(codec, 7, 0, 0x2030);
633 alc888_coef_init(codec);
659 static void alc_fixup_sku_ignore(struct hda_codec *codec,
662 struct alc_spec *spec = codec->spec;
669 static void alc_fixup_no_depop_delay(struct hda_codec *codec,
672 struct alc_spec *spec = codec->spec;
676 codec->depop_delay = 0;
680 static int alc_auto_parse_customize_define(struct hda_codec *codec)
684 struct alc_spec *spec = codec->spec;
695 if (!codec->bus->pci)
697 ass = codec->core.subsystem_id & 0xffff;
698 if (ass != codec->bus->pci->subsystem_device && (ass & 1))
702 if (codec->core.vendor_id == 0x10ec0260)
704 ass = snd_hda_codec_get_pincfg(codec, nid);
707 codec_info(codec, "%s: SKU not ready 0x%08x\n",
708 codec->core.chip_name, ass);
732 codec_dbg(codec, "SKU: Nid=0x%x sku_cfg=0x%08x\n",
734 codec_dbg(codec, "SKU: port_connectivity=0x%x\n",
736 codec_dbg(codec, "SKU: enable_pcbeep=0x%x\n", spec->cdefine.enable_pcbeep);
737 codec_dbg(codec, "SKU: check_sum=0x%08x\n", spec->cdefine.check_sum);
738 codec_dbg(codec, "SKU: customization=0x%08x\n", spec->cdefine.customization);
739 codec_dbg(codec, "SKU: external_amp=0x%x\n", spec->cdefine.external_amp);
740 codec_dbg(codec, "SKU: platform_type=0x%x\n", spec->cdefine.platform_type);
741 codec_dbg(codec, "SKU: swap=0x%x\n", spec->cdefine.swap);
742 codec_dbg(codec, "SKU: override=0x%x\n", spec->cdefine.override);
765 /* 32-bit subsystem ID for BIOS loading in HD Audio codec.
771 static int alc_subsystem_id(struct hda_codec *codec, const hda_nid_t *ports)
775 struct alc_spec *spec = codec->spec;
784 ass = codec->core.subsystem_id & 0xffff;
785 if (codec->bus->pci &&
786 ass != codec->bus->pci->subsystem_device && (ass & 1))
799 if (codec->core.vendor_id == 0x10ec0260)
801 ass = snd_hda_codec_get_pincfg(codec, nid);
802 codec_dbg(codec,
819 codec_dbg(codec, "realtek: Enabling init ASM_ID=0x%04x CODEC_ID=%08x\n",
820 ass & 0xffff, codec->core.vendor_id);
832 alc_setup_gpio(codec, 0x01);
835 alc_setup_gpio(codec, 0x02);
838 alc_setup_gpio(codec, 0x04);
873 static void alc_ssid_check(struct hda_codec *codec, const hda_nid_t *ports)
875 if (!alc_subsystem_id(codec, ports)) {
876 struct alc_spec *spec = codec->spec;
878 codec_dbg(codec,
888 static void alc_fixup_inv_dmic(struct hda_codec *codec,
891 struct alc_spec *spec = codec->spec;
897 static int alc_build_controls(struct hda_codec *codec)
901 err = snd_hda_gen_build_controls(codec);
905 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_BUILD);
914 static void alc_pre_init(struct hda_codec *codec)
916 alc_fill_eapd_coef(codec);
919 #define is_s3_resume(codec) \
920 ((codec)->core.dev.power.power_state.event == PM_EVENT_RESUME)
921 #define is_s4_resume(codec) \
922 ((codec)->core.dev.power.power_state.event == PM_EVENT_RESTORE)
924 static int alc_init(struct hda_codec *codec)
926 struct alc_spec *spec = codec->spec;
929 if (is_s4_resume(codec))
930 alc_pre_init(codec);
933 spec->init_hook(codec);
936 snd_hda_gen_init(codec);
937 alc_fix_pll(codec);
938 alc_auto_init_amp(codec, spec->init_amp);
939 snd_hda_apply_verbs(codec); /* apply verbs here after own init */
941 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_INIT);
949 static inline void alc_shutup(struct hda_codec *codec)
951 struct alc_spec *spec = codec->spec;
953 if (!snd_hda_get_bool_hint(codec, "shutup"))
957 spec->shutup(codec);
959 alc_shutup_pins(codec);
962 static void alc_power_eapd(struct hda_codec *codec)
964 alc_auto_setup_eapd(codec, false);
967 static int alc_suspend(struct hda_codec *codec)
969 struct alc_spec *spec = codec->spec;
970 alc_shutup(codec);
972 spec->power_hook(codec);
976 static int alc_resume(struct hda_codec *codec)
978 struct alc_spec *spec = codec->spec;
982 codec->patch_ops.init(codec);
983 snd_hda_regmap_sync(codec);
984 hda_call_check_power_status(codec, 0x01);
1005 #define alc_codec_rename(codec, name) snd_hda_codec_set_name(codec, name)
1076 static int alc_codec_rename_from_preset(struct hda_codec *codec)
1082 if (p->vendor_id != codec->core.vendor_id)
1084 if ((alc_get_coef0(codec) & p->coef_mask) == p->coef_bits)
1085 return alc_codec_rename(codec, p->name);
1088 if (!codec->bus->pci)
1091 if (q->codec_vendor_id != codec->core.vendor_id)
1093 if (q->pci_subvendor != codec->bus->pci->subsystem_vendor)
1096 q->pci_subdevice == codec->bus->pci->subsystem_device)
1097 return alc_codec_rename(codec, q->name);
1149 static inline int has_cdefine_beep(struct hda_codec *codec)
1151 struct alc_spec *spec = codec->spec;
1153 q = snd_pci_quirk_lookup(codec->bus->pci, beep_allow_list);
1160 #define has_cdefine_beep(codec) 0
1167 static int alc_parse_auto_config(struct hda_codec *codec,
1171 struct alc_spec *spec = codec->spec;
1175 err = snd_hda_parse_pin_defcfg(codec, cfg, ignore_nids,
1181 alc_ssid_check(codec, ssid_nids);
1183 err = snd_hda_gen_parse_auto_config(codec, cfg);
1191 static int alc_alloc_spec(struct hda_codec *codec, hda_nid_t mixer_nid)
1198 codec->spec = spec;
1202 codec->single_adc_amp = 1;
1203 /* FIXME: do we need this for all Realtek codec models? */
1204 codec->spdif_status_reset = 1;
1205 codec->forced_resume = 1;
1206 codec->patch_ops = alc_patch_ops;
1209 err = alc_codec_rename_from_preset(codec);
1217 static int alc880_parse_auto_config(struct hda_codec *codec)
1221 return alc_parse_auto_config(codec, alc880_ignore, alc880_ssids);
1256 static void alc880_fixup_vol_knob(struct hda_codec *codec,
1260 snd_hda_jack_detect_enable_callback(codec, 0x21,
1639 static int patch_alc880(struct hda_codec *codec)
1644 err = alc_alloc_spec(codec, 0x0b);
1648 spec = codec->spec;
1652 codec->patch_ops.unsol_event = alc880_unsol_event;
1654 alc_pre_init(codec);
1656 snd_hda_pick_fixup(codec, alc880_fixup_models, alc880_fixup_tbl,
1658 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
1661 err = alc880_parse_auto_config(codec);
1671 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
1676 alc_free(codec);
1684 static int alc260_parse_auto_config(struct hda_codec *codec)
1688 return alc_parse_auto_config(codec, alc260_ignore, alc260_ssids);
1708 static void alc260_gpio1_automute(struct hda_codec *codec)
1710 struct alc_spec *spec = codec->spec;
1712 alc_update_gpio_data(codec, 0x01, spec->gen.hp_jack_present);
1715 static void alc260_fixup_gpio1_toggle(struct hda_codec *codec,
1718 struct alc_spec *spec = codec->spec;
1727 snd_hda_jack_detect_enable_callback(codec, 0x0f,
1729 alc_setup_gpio(codec, 0x01);
1733 static void alc260_fixup_kn1(struct hda_codec *codec,
1736 struct alc_spec *spec = codec->spec;
1755 snd_hda_apply_pincfgs(codec, pincfgs);
1761 static void alc260_fixup_fsc_s7020(struct hda_codec *codec,
1764 struct alc_spec *spec = codec->spec;
1769 static void alc260_fixup_fsc_s7020_jwse(struct hda_codec *codec,
1772 struct alc_spec *spec = codec->spec;
1888 static int patch_alc260(struct hda_codec *codec)
1893 err = alc_alloc_spec(codec, 0x07);
1897 spec = codec->spec;
1907 alc_pre_init(codec);
1909 snd_hda_pick_fixup(codec, alc260_fixup_models, alc260_fixup_tbl,
1911 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
1914 err = alc260_parse_auto_config(codec);
1924 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
1929 alc_free(codec);
1994 static void alc889_fixup_coef(struct hda_codec *codec,
1999 alc_update_coef_idx(codec, 7, 0, 0x2030);
2003 static void alc885_fixup_macpro_gpio(struct hda_codec *codec,
2006 struct alc_spec *spec = codec->spec;
2009 alc_fixup_gpio3(codec, fix, action);
2016 static void alc889_fixup_dac_route(struct hda_codec *codec,
2023 snd_hda_override_conn_list(codec, 0x14, ARRAY_SIZE(conn1), conn1);
2024 snd_hda_override_conn_list(codec, 0x15, ARRAY_SIZE(conn1), conn1);
2025 snd_hda_override_conn_list(codec, 0x18, ARRAY_SIZE(conn2), conn2);
2026 snd_hda_override_conn_list(codec, 0x1a, ARRAY_SIZE(conn2), conn2);
2030 snd_hda_override_conn_list(codec, 0x14, ARRAY_SIZE(conn), conn);
2031 snd_hda_override_conn_list(codec, 0x15, ARRAY_SIZE(conn), conn);
2032 snd_hda_override_conn_list(codec, 0x18, ARRAY_SIZE(conn), conn);
2033 snd_hda_override_conn_list(codec, 0x1a, ARRAY_SIZE(conn), conn);
2038 static void alc889_fixup_mbp_vref(struct hda_codec *codec,
2042 struct alc_spec *spec = codec->spec;
2048 unsigned int val = snd_hda_codec_get_pincfg(codec, nids[i]);
2051 val = snd_hda_codec_get_pin_target(codec, nids[i]);
2053 snd_hda_set_pin_ctl(codec, nids[i], val);
2059 static void alc889_fixup_mac_pins(struct hda_codec *codec,
2062 struct alc_spec *spec = codec->spec;
2067 val = snd_hda_codec_get_pin_target(codec, nids[i]);
2069 snd_hda_set_pin_ctl(codec, nids[i], val);
2075 static void alc889_fixup_imac91_vref(struct hda_codec *codec,
2081 alc889_fixup_mac_pins(codec, nids, ARRAY_SIZE(nids));
2085 static void alc889_fixup_mba11_vref(struct hda_codec *codec,
2091 alc889_fixup_mac_pins(codec, nids, ARRAY_SIZE(nids));
2095 static void alc889_fixup_mba21_vref(struct hda_codec *codec,
2101 alc889_fixup_mac_pins(codec, nids, ARRAY_SIZE(nids));
2108 static void alc882_fixup_no_primary_hp(struct hda_codec *codec,
2111 struct alc_spec *spec = codec->spec;
2118 static void alc_fixup_bass_chmap(struct hda_codec *codec,
2121 /* For dual-codec configuration, we need to disable some features to avoid
2124 static void alc_fixup_dual_codecs(struct hda_codec *codec,
2127 struct alc_spec *spec = codec->spec;
2139 codec->force_pin_prefix = 1;
2142 static void rename_ctl(struct hda_codec *codec, const char *oldname,
2147 kctl = snd_hda_find_mixer_ctl(codec, oldname);
2149 snd_ctl_rename(codec->card, kctl, newname);
2152 static void alc1220_fixup_gb_dual_codecs(struct hda_codec *codec,
2156 alc_fixup_dual_codecs(codec, fix, action);
2160 strcpy(codec->card->longname, "HDAudio-Gigabyte-ALC1220DualCodecs");
2163 /* rename Capture controls depending on the codec */
2164 rename_ctl(codec, "Capture Volume",
2165 codec->addr == 0 ?
2168 rename_ctl(codec, "Capture Switch",
2169 codec->addr == 0 ?
2176 static void alc1220_fixup_gb_x570(struct hda_codec *codec,
2191 snd_hda_override_conn_list(codec, 0x14, ARRAY_SIZE(conn1), conn1);
2192 snd_hda_override_conn_list(codec, 0x1b, ARRAY_SIZE(conn1), conn1);
2195 alc_process_coef_fw(codec, gb_x570_coefs);
2200 static void alc1220_fixup_clevo_p950(struct hda_codec *codec,
2209 alc_update_coef_idx(codec, 0x7, 0, 0x3c3);
2213 snd_hda_override_conn_list(codec, 0x14, ARRAY_SIZE(conn1), conn1);
2214 snd_hda_override_conn_list(codec, 0x1b, ARRAY_SIZE(conn1), conn1);
2217 static void alc_fixup_headset_mode_no_hp_mic(struct hda_codec *codec,
2220 static void alc1220_fixup_clevo_pb51ed(struct hda_codec *codec,
2224 alc1220_fixup_clevo_p950(codec, fix, action);
2225 alc_fixup_headset_mode_no_hp_mic(codec, fix, action);
2228 static void alc887_asus_hp_automute_hook(struct hda_codec *codec,
2231 struct alc_spec *spec = codec->spec;
2234 snd_hda_gen_hp_automute(codec, jack);
2240 snd_hda_set_pin_ctl(codec, 0x19, PIN_HP | vref);
2243 static void alc887_fixup_asus_jack(struct hda_codec *codec,
2246 struct alc_spec *spec = codec->spec;
2249 snd_hda_set_pin_ctl_cache(codec, 0x1b, PIN_HP);
2420 * codec replicate the sum signal to both channels,
2596 /* All Apple entries are in codec SSIDs */
2738 static int alc882_parse_auto_config(struct hda_codec *codec)
2742 return alc_parse_auto_config(codec, alc882_ignore, alc882_ssids);
2747 static int patch_alc882(struct hda_codec *codec)
2752 err = alc_alloc_spec(codec, 0x0b);
2756 spec = codec->spec;
2758 switch (codec->core.vendor_id) {
2767 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
2771 alc_pre_init(codec);
2773 snd_hda_pick_fixup(codec, alc882_fixup_models, alc882_fixup_tbl,
2775 snd_hda_pick_pin_fixup(codec, alc882_pin_fixup_tbl, alc882_fixups, true);
2776 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
2778 alc_auto_parse_customize_define(codec);
2780 if (has_cdefine_beep(codec))
2784 err = alc882_parse_auto_config(codec);
2794 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
2799 alc_free(codec);
2807 static int alc262_parse_auto_config(struct hda_codec *codec)
2811 return alc_parse_auto_config(codec, alc262_ignore, alc262_ssids);
2926 static int patch_alc262(struct hda_codec *codec)
2931 err = alc_alloc_spec(codec, 0x0b);
2935 spec = codec->spec;
2944 alc_update_coefex_idx(codec, 0x1a, 7, 0, 0x80);
2946 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
2948 alc_pre_init(codec);
2950 snd_hda_pick_fixup(codec, alc262_fixup_models, alc262_fixup_tbl,
2952 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
2954 alc_auto_parse_customize_define(codec);
2956 if (has_cdefine_beep(codec))
2960 err = alc262_parse_auto_config(codec);
2970 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
2975 alc_free(codec);
2986 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2990 mutex_lock(&codec->control_mutex);
2999 mutex_unlock(&codec->control_mutex);
3061 /* below is codec SSID since multiple Toshiba laptops have the
3071 static int alc268_parse_auto_config(struct hda_codec *codec)
3074 return alc_parse_auto_config(codec, NULL, alc268_ssids);
3079 static int patch_alc268(struct hda_codec *codec)
3085 err = alc_alloc_spec(codec, 0);
3089 spec = codec->spec;
3090 if (has_cdefine_beep(codec))
3095 alc_pre_init(codec);
3097 snd_hda_pick_fixup(codec, alc268_fixup_models, alc268_fixup_tbl, alc268_fixups);
3098 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
3101 err = alc268_parse_auto_config(codec);
3114 snd_hda_add_verbs(codec, alc268_beep_init_verbs);
3115 if (!query_amp_caps(codec, 0x1d, HDA_INPUT))
3117 snd_hda_override_amp_caps(codec, 0x1d, HDA_INPUT,
3124 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
3129 alc_free(codec);
3174 static int alc269_parse_auto_config(struct hda_codec *codec)
3179 struct alc_spec *spec = codec->spec;
3214 return alc_parse_auto_config(codec, alc269_ignore, ssids);
3225 static void alc_headset_btn_callback(struct hda_codec *codec,
3244 snd_hda_jack_set_button_state(codec, jack->nid, report);
3247 static void alc_disable_headset_jack_key(struct hda_codec *codec)
3249 struct alc_spec *spec = codec->spec;
3254 switch (codec->core.vendor_id) {
3262 alc_write_coef_idx(codec, 0x48, 0x0);
3263 alc_update_coef_idx(codec, 0x49, 0x0045, 0x0);
3264 alc_update_coef_idx(codec, 0x44, 0x0045 << 8, 0x0);
3271 alc_write_coef_idx(codec, 0x48, 0x0);
3272 alc_update_coef_idx(codec, 0x49, 0x0045, 0x0);
3277 static void alc_enable_headset_jack_key(struct hda_codec *codec)
3279 struct alc_spec *spec = codec->spec;
3284 switch (codec->core.vendor_id) {
3292 alc_write_coef_idx(codec, 0x48, 0xd011);
3293 alc_update_coef_idx(codec, 0x49, 0x007f, 0x0045);
3294 alc_update_coef_idx(codec, 0x44, 0x007f << 8, 0x0045 << 8);
3301 alc_write_coef_idx(codec, 0x48, 0xd011);
3302 alc_update_coef_idx(codec, 0x49, 0x007f, 0x0045);
3307 static void alc_fixup_headset_jack(struct hda_codec *codec,
3310 struct alc_spec *spec = codec->spec;
3316 snd_hda_jack_detect_enable_callback(codec, 0x55,
3321 if (!hp_pin || snd_hda_jack_bind_keymap(codec, 0x55,
3324 snd_hda_jack_add_kctl(codec, 0x55, "Headset Jack",
3328 alc_enable_headset_jack_key(codec);
3333 static void alc269vb_toggle_power_output(struct hda_codec *codec, int power_up)
3335 alc_update_coef_idx(codec, 0x04, 1 << 11, power_up ? (1 << 11) : 0);
3338 static void alc269_shutup(struct hda_codec *codec)
3340 struct alc_spec *spec = codec->spec;
3343 alc269vb_toggle_power_output(codec, 0);
3345 (alc_get_coef0(codec) & 0x00ff) == 0x018) {
3348 alc_shutup_pins(codec);
3384 static void alc282_restore_default_value(struct hda_codec *codec)
3386 alc_process_coef_fw(codec, alc282_coefs);
3389 static void alc282_init(struct hda_codec *codec)
3391 struct alc_spec *spec = codec->spec;
3396 alc282_restore_default_value(codec);
3400 hp_pin_sense = snd_hda_jack_detect(codec, hp_pin);
3401 coef78 = alc_read_coef_idx(codec, 0x78);
3405 alc_write_coef_idx(codec, 0x78, 0x9004);
3410 snd_hda_codec_write(codec, hp_pin, 0,
3416 snd_hda_codec_write(codec, hp_pin, 0,
3423 alc_write_coef_idx(codec, 0x78, coef78);
3426 static void alc282_shutup(struct hda_codec *codec)
3428 struct alc_spec *spec = codec->spec;
3434 alc269_shutup(codec);
3438 hp_pin_sense = snd_hda_jack_detect(codec, hp_pin);
3439 coef78 = alc_read_coef_idx(codec, 0x78);
3440 alc_write_coef_idx(codec, 0x78, 0x9004);
3445 snd_hda_codec_write(codec, hp_pin, 0,
3452 snd_hda_codec_write(codec, hp_pin, 0,
3458 alc_auto_setup_eapd(codec, false);
3459 alc_shutup_pins(codec);
3460 alc_write_coef_idx(codec, 0x78, coef78);
3500 static void alc283_restore_default_value(struct hda_codec *codec)
3502 alc_process_coef_fw(codec, alc283_coefs);
3505 static void alc283_init(struct hda_codec *codec)
3507 struct alc_spec *spec = codec->spec;
3511 alc283_restore_default_value(codec);
3517 hp_pin_sense = snd_hda_jack_detect(codec, hp_pin);
3521 alc_write_coef_idx(codec, 0x43, 0x9004);
3523 snd_hda_codec_write(codec, hp_pin, 0,
3529 snd_hda_codec_write(codec, hp_pin, 0,
3536 alc_update_coef_idx(codec, 0x46, 3 << 12, 0);
3538 alc_write_coef_idx(codec, 0x43, 0x9614);
3541 static void alc283_shutup(struct hda_codec *codec)
3543 struct alc_spec *spec = codec->spec;
3548 alc269_shutup(codec);
3552 hp_pin_sense = snd_hda_jack_detect(codec, hp_pin);
3554 alc_write_coef_idx(codec, 0x43, 0x9004);
3557 alc_write_coef_idx(codec, 0x06, 0x2100);
3559 snd_hda_codec_write(codec, hp_pin, 0,
3566 snd_hda_codec_write(codec, hp_pin, 0,
3569 alc_update_coef_idx(codec, 0x46, 0, 3 << 12);
3573 alc_auto_setup_eapd(codec, false);
3574 alc_shutup_pins(codec);
3575 alc_write_coef_idx(codec, 0x43, 0x9614);
3578 static void alc256_init(struct hda_codec *codec)
3580 struct alc_spec *spec = codec->spec;
3585 alc_update_coef_idx(codec, 0x03, 1<<1, 1<<1);
3586 alc_update_coef_idx(codec, 0x08, 3<<2, 3<<2);
3587 alc_update_coef_idx(codec, 0x08, 7<<4, 0);
3588 alc_update_coef_idx(codec, 0x3b, 1<<15, 0);
3589 alc_update_coef_idx(codec, 0x0e, 7<<6, 7<<6);
3598 hp_pin_sense = snd_hda_jack_detect(codec, hp_pin);
3603 alc_update_coefex_idx(codec, 0x57, 0x04, 0x0007, 0x1); /* Low power */
3605 snd_hda_codec_write(codec, hp_pin, 0,
3611 snd_hda_codec_write(codec, hp_pin, 0,
3617 alc_update_coef_idx(codec, 0x46, 3 << 12, 0);
3618 alc_update_coefex_idx(codec, 0x57, 0x04, 0x0007, 0x4); /* Hight power */
3619 alc_update_coefex_idx(codec, 0x53, 0x02, 0x8000, 1 << 15); /* Clear bit */
3620 alc_update_coefex_idx(codec, 0x53, 0x02, 0x8000, 0 << 15);
3627 alc_write_coef_idx(codec, 0x36, 0x5757);
3630 static void alc256_shutup(struct hda_codec *codec)
3632 struct alc_spec *spec = codec->spec;
3639 alc_update_coefex_idx(codec, 0x57, 0x04, 0x0007, 0x1); /* Low power */
3640 hp_pin_sense = snd_hda_jack_detect(codec, hp_pin);
3645 snd_hda_codec_write(codec, hp_pin, 0,
3652 /* NOTE: call this before clearing the pin, otherwise codec stalls */
3654 * when booting with headset plugged. So skip setting it for the codec alc257
3657 alc_update_coef_idx(codec, 0x46, 0, 3 << 12);
3660 snd_hda_codec_write(codec, hp_pin, 0,
3666 alc_auto_setup_eapd(codec, false);
3667 alc_shutup_pins(codec);
3670 alc_update_coef_idx(codec, 0x03, 1<<1, 0);
3671 alc_update_coef_idx(codec, 0x08, 7<<4, 7<<4);
3672 alc_update_coef_idx(codec, 0x08, 3<<2, 0);
3673 alc_update_coef_idx(codec, 0x3b, 1<<15, 1<<15);
3674 alc_update_coef_idx(codec, 0x0e, 7<<6, 0);
3679 static void alc285_hp_init(struct hda_codec *codec)
3681 struct alc_spec *spec = codec->spec;
3686 alc_write_coefex_idx(codec, 0x58, 0x00, 0x1888); /* write default value */
3687 alc_update_coef_idx(codec, 0x4a, 1<<15, 1<<15); /* Reset HP JD */
3688 coef38 = alc_read_coef_idx(codec, 0x38); /* Amp control */
3689 coef0d = alc_read_coef_idx(codec, 0x0d); /* Digital Misc control */
3690 coef36 = alc_read_coef_idx(codec, 0x36); /* Passthrough Control */
3691 alc_update_coef_idx(codec, 0x38, 1<<4, 0x0);
3692 alc_update_coef_idx(codec, 0x0d, 0x110, 0x0);
3694 alc_update_coef_idx(codec, 0x67, 0xf000, 0x3000);
3697 snd_hda_codec_write(codec, hp_pin, 0,
3701 alc_update_coef_idx(codec, 0x36, 1<<14, 1<<14);
3702 alc_update_coef_idx(codec, 0x36, 1<<13, 0x0);
3705 snd_hda_codec_write(codec, hp_pin, 0,
3708 alc_write_coef_idx(codec, 0x67, 0x0); /* Set HP depop to manual mode */
3709 alc_write_coefex_idx(codec, 0x58, 0x00, 0x7880);
3710 alc_write_coefex_idx(codec, 0x58, 0x0f, 0xf049);
3711 alc_update_coefex_idx(codec, 0x58, 0x03, 0x00f0, 0x00c0);
3713 alc_write_coefex_idx(codec, 0x58, 0x00, 0xf888); /* HP depop procedure start */
3714 val = alc_read_coefex_idx(codec, 0x58, 0x00);
3717 val = alc_read_coefex_idx(codec, 0x58, 0x00);
3720 alc_write_coefex_idx(codec, 0x58, 0x00, val); /* write back the result */
3721 alc_update_coef_idx(codec, 0x38, 1<<4, coef38);
3722 alc_update_coef_idx(codec, 0x0d, 0x110, coef0d);
3723 alc_update_coef_idx(codec, 0x36, 3<<13, coef36);
3726 alc_update_coef_idx(codec, 0x4a, 1<<15, 0);
3729 static void alc225_init(struct hda_codec *codec)
3731 struct alc_spec *spec = codec->spec;
3736 alc_update_coef_idx(codec, 0x08, 0x0f << 2, 3<<2);
3737 alc_update_coef_idx(codec, 0x0e, 7<<6, 7<<6);
3738 alc_update_coef_idx(codec, 0x33, 1<<11, 0);
3746 is_s3_resume(codec) ||
3747 is_s4_resume(codec)) {
3748 alc285_hp_init(codec);
3756 hp1_pin_sense = snd_hda_jack_detect(codec, hp_pin);
3757 hp2_pin_sense = snd_hda_jack_detect(codec, 0x16);
3762 alc_update_coefex_idx(codec, 0x57, 0x04, 0x0007, 0x1); /* Low power */
3765 snd_hda_codec_write(codec, hp_pin, 0,
3768 snd_hda_codec_write(codec, 0x16, 0,
3775 snd_hda_codec_write(codec, hp_pin, 0,
3778 snd_hda_codec_write(codec, 0x16, 0,
3784 alc_update_coef_idx(codec, 0x4a, 3 << 10, 0);
3785 alc_update_coefex_idx(codec, 0x57, 0x04, 0x0007, 0x4); /* Hight power */
3788 static void alc225_shutup(struct hda_codec *codec)
3790 struct alc_spec *spec = codec->spec;
3797 alc_disable_headset_jack_key(codec);
3799 alc_update_coef_idx(codec, 0x4a, 0, 3 << 10);
3801 hp1_pin_sense = snd_hda_jack_detect(codec, hp_pin);
3802 hp2_pin_sense = snd_hda_jack_detect(codec, 0x16);
3808 snd_hda_codec_write(codec, hp_pin, 0,
3811 snd_hda_codec_write(codec, 0x16, 0,
3818 snd_hda_codec_write(codec, hp_pin, 0,
3821 snd_hda_codec_write(codec, 0x16, 0,
3827 alc_auto_setup_eapd(codec, false);
3828 alc_shutup_pins(codec);
3831 alc_update_coef_idx(codec, 0x08, 0x0f << 2, 0x0c << 2);
3832 alc_update_coef_idx(codec, 0x0e, 7<<6, 0);
3833 alc_update_coef_idx(codec, 0x33, 1<<11, 1<<11);
3834 alc_update_coef_idx(codec, 0x4a, 3<<4, 2<<4);
3838 alc_update_coef_idx(codec, 0x4a, 3 << 10, 0);
3839 alc_enable_headset_jack_key(codec);
3842 static void alc_default_init(struct hda_codec *codec)
3844 struct alc_spec *spec = codec->spec;
3853 hp_pin_sense = snd_hda_jack_detect(codec, hp_pin);
3858 snd_hda_codec_write(codec, hp_pin, 0,
3864 snd_hda_codec_write(codec, hp_pin, 0,
3871 static void alc_default_shutup(struct hda_codec *codec)
3873 struct alc_spec *spec = codec->spec;
3878 alc269_shutup(codec);
3882 hp_pin_sense = snd_hda_jack_detect(codec, hp_pin);
3887 snd_hda_codec_write(codec, hp_pin, 0,
3894 snd_hda_codec_write(codec, hp_pin, 0,
3900 alc_auto_setup_eapd(codec, false);
3901 alc_shutup_pins(codec);
3904 static void alc294_hp_init(struct hda_codec *codec)
3906 struct alc_spec *spec = codec->spec;
3913 snd_hda_codec_write(codec, hp_pin, 0,
3919 snd_hda_codec_write(codec, hp_pin, 0,
3922 alc_update_coef_idx(codec, 0x6f, 0x000f, 0);/* Set HP depop to manual mode */
3923 alc_update_coefex_idx(codec, 0x58, 0x00, 0x8000, 0x8000); /* HP depop procedure start */
3926 val = alc_read_coefex_idx(codec, 0x58, 0x01);
3929 val = alc_read_coefex_idx(codec, 0x58, 0x01);
3932 alc_update_coef_idx(codec, 0x6f, 0x000f, 0x000b);
3936 static void alc294_init(struct hda_codec *codec)
3938 struct alc_spec *spec = codec->spec;
3942 codec->core.dev.power.power_state.event == PM_EVENT_RESTORE) {
3943 alc294_hp_init(codec);
3946 alc_default_init(codec);
3949 static void alc5505_coef_set(struct hda_codec *codec, unsigned int index_reg,
3952 snd_hda_codec_write(codec, 0x51, 0, AC_VERB_SET_COEF_INDEX, index_reg >> 1);
3953 snd_hda_codec_write(codec, 0x51, 0, AC_VERB_SET_PROC_COEF, val & 0xffff); /* LSB */
3954 snd_hda_codec_write(codec, 0x51, 0, AC_VERB_SET_PROC_COEF, val >> 16); /* MSB */
3957 static int alc5505_coef_get(struct hda_codec *codec, unsigned int index_reg)
3961 snd_hda_codec_write(codec, 0x51, 0, AC_VERB_SET_COEF_INDEX, index_reg >> 1);
3962 val = snd_hda_codec_read(codec, 0x51, 0, AC_VERB_GET_PROC_COEF, 0)
3964 val |= snd_hda_codec_read(codec, 0x51, 0, AC_VERB_GET_PROC_COEF, 0)
3969 static void alc5505_dsp_halt(struct hda_codec *codec)
3973 alc5505_coef_set(codec, 0x3000, 0x000c); /* DSP CPU stop */
3974 alc5505_coef_set(codec, 0x880c, 0x0008); /* DDR enter self refresh */
3975 alc5505_coef_set(codec, 0x61c0, 0x11110080); /* Clock control for PLL and CPU */
3976 alc5505_coef_set(codec, 0x6230, 0xfc0d4011); /* Disable Input OP */
3977 alc5505_coef_set(codec, 0x61b4, 0x040a2b03); /* Stop PLL2 */
3978 alc5505_coef_set(codec, 0x61b0, 0x00005b17); /* Stop PLL1 */
3979 alc5505_coef_set(codec, 0x61b8, 0x04133303); /* Stop PLL3 */
3980 val = alc5505_coef_get(codec, 0x6220);
3981 alc5505_coef_set(codec, 0x6220, (val | 0x3000)); /* switch Ringbuffer clock to DBUS clock */
3984 static void alc5505_dsp_back_from_halt(struct hda_codec *codec)
3986 alc5505_coef_set(codec, 0x61b8, 0x04133302);
3987 alc5505_coef_set(codec, 0x61b0, 0x00005b16);
3988 alc5505_coef_set(codec, 0x61b4, 0x040a2b02);
3989 alc5505_coef_set(codec, 0x6230, 0xf80d4011);
3990 alc5505_coef_set(codec, 0x6220, 0x2002010f);
3991 alc5505_coef_set(codec, 0x880c, 0x00000004);
3994 static void alc5505_dsp_init(struct hda_codec *codec)
3998 alc5505_dsp_halt(codec);
3999 alc5505_dsp_back_from_halt(codec);
4000 alc5505_coef_set(codec, 0x61b0, 0x5b14); /* PLL1 control */
4001 alc5505_coef_set(codec, 0x61b0, 0x5b16);
4002 alc5505_coef_set(codec, 0x61b4, 0x04132b00); /* PLL2 control */
4003 alc5505_coef_set(codec, 0x61b4, 0x04132b02);
4004 alc5505_coef_set(codec, 0x61b8, 0x041f3300); /* PLL3 control*/
4005 alc5505_coef_set(codec, 0x61b8, 0x041f3302);
4006 snd_hda_codec_write(codec, 0x51, 0, AC_VERB_SET_CODEC_RESET, 0); /* Function reset */
4007 alc5505_coef_set(codec, 0x61b8, 0x041b3302);
4008 alc5505_coef_set(codec, 0x61b8, 0x04173302);
4009 alc5505_coef_set(codec, 0x61b8, 0x04163302);
4010 alc5505_coef_set(codec, 0x8800, 0x348b328b); /* DRAM control */
4011 alc5505_coef_set(codec, 0x8808, 0x00020022); /* DRAM control */
4012 alc5505_coef_set(codec, 0x8818, 0x00000400); /* DRAM control */
4014 val = alc5505_coef_get(codec, 0x6200) >> 16; /* Read revision ID */
4016 alc5505_coef_set(codec, 0x6220, 0x2002010f); /* I/O PAD Configuration */
4018 alc5505_coef_set(codec, 0x6220, 0x6002018f);
4020 alc5505_coef_set(codec, 0x61ac, 0x055525f0); /**/
4021 alc5505_coef_set(codec, 0x61c0, 0x12230080); /* Clock control */
4022 alc5505_coef_set(codec, 0x61b4, 0x040e2b02); /* PLL2 control */
4023 alc5505_coef_set(codec, 0x61bc, 0x010234f8); /* OSC Control */
4024 alc5505_coef_set(codec, 0x880c, 0x00000004); /* DRAM Function control */
4025 alc5505_coef_set(codec, 0x880c, 0x00000003);
4026 alc5505_coef_set(codec, 0x880c, 0x00000010);
4029 alc5505_dsp_halt(codec);
4034 #define alc5505_dsp_suspend(codec) do { } while (0) /* NOP */
4035 #define alc5505_dsp_resume(codec) do { } while (0) /* NOP */
4037 #define alc5505_dsp_suspend(codec) alc5505_dsp_halt(codec)
4038 #define alc5505_dsp_resume(codec) alc5505_dsp_back_from_halt(codec)
4042 static int alc269_suspend(struct hda_codec *codec)
4044 struct alc_spec *spec = codec->spec;
4047 alc5505_dsp_suspend(codec);
4049 return alc_suspend(codec);
4052 static int alc269_resume(struct hda_codec *codec)
4054 struct alc_spec *spec = codec->spec;
4057 alc269vb_toggle_power_output(codec, 0);
4059 (alc_get_coef0(codec) & 0x00ff) == 0x018) {
4063 codec->patch_ops.init(codec);
4066 alc269vb_toggle_power_output(codec, 1);
4068 (alc_get_coef0(codec) & 0x00ff) == 0x017) {
4072 snd_hda_regmap_sync(codec);
4073 hda_call_check_power_status(codec, 0x01);
4075 /* on some machine, the BIOS will clear the codec gpio data when enter
4080 alc_write_gpio_data(codec);
4083 alc5505_dsp_resume(codec);
4089 static void alc269_fixup_pincfg_no_hp_to_lineout(struct hda_codec *codec,
4092 struct alc_spec *spec = codec->spec;
4098 static void alc269_fixup_pincfg_U7x7_headset_mic(struct hda_codec *codec,
4102 unsigned int cfg_headphone = snd_hda_codec_get_pincfg(codec, 0x21);
4103 unsigned int cfg_headset_mic = snd_hda_codec_get_pincfg(codec, 0x19);
4106 snd_hda_codec_set_pincfg(codec, 0x19,
4111 static void alc269_fixup_hweq(struct hda_codec *codec,
4115 alc_update_coef_idx(codec, 0x1e, 0, 0x80);
4118 static void alc269_fixup_headset_mic(struct hda_codec *codec,
4121 struct alc_spec *spec = codec->spec;
4127 static void alc271_fixup_dmic(struct hda_codec *codec,
4137 if (strcmp(codec->core.chip_name, "ALC271X") &&
4138 strcmp(codec->core.chip_name, "ALC269VB"))
4140 cfg = snd_hda_codec_get_pincfg(codec, 0x12);
4142 snd_hda_sequence_write(codec, verbs);
4146 static void alc269vb_fixup_aspire_e1_coef(struct hda_codec *codec,
4151 alc_update_coef_idx(codec, 0x0d, 0x6000, 0x6000);
4154 static void alc269_fixup_pcm_44k(struct hda_codec *codec,
4157 struct alc_spec *spec = codec->spec;
4169 static void alc269_fixup_stereo_dmic(struct hda_codec *codec,
4178 alc_update_coef_idx(codec, 0x07, 0, 0x80);
4181 static void alc269_quanta_automute(struct hda_codec *codec)
4183 snd_hda_gen_update_outputs(codec);
4185 alc_write_coef_idx(codec, 0x0c, 0x680);
4186 alc_write_coef_idx(codec, 0x0c, 0x480);
4189 static void alc269_fixup_quanta_mute(struct hda_codec *codec,
4192 struct alc_spec *spec = codec->spec;
4198 static void alc269_x101_hp_automute_hook(struct hda_codec *codec,
4201 struct alc_spec *spec = codec->spec;
4204 snd_hda_gen_hp_automute(codec, jack);
4208 snd_hda_codec_write(codec, 0x18, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4211 snd_hda_codec_write(codec, 0x18, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4223 static void alc298_huawei_mbx_stereo_seq(struct hda_codec *codec,
4227 snd_hda_codec_write(codec, 0x06, 0, AC_VERB_SET_DIGI_CONVERT_3, 0x0);
4228 alc_write_coef_idx(codec, 0x26, 0xb000);
4231 snd_hda_codec_write(codec, 0x21, 0, AC_VERB_GET_PIN_SENSE, 0x0);
4233 snd_hda_codec_write(codec, 0x6, 0, AC_VERB_SET_DIGI_CONVERT_3, 0x80);
4234 alc_write_coef_idx(codec, 0x26, 0xf000);
4235 alc_write_coef_idx(codec, 0x23, initval->value_0x23);
4238 alc_write_coef_idx(codec, 0x25, initval->value_0x25);
4240 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 0x26);
4241 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_PROC_COEF, 0xb010);
4244 static void alc298_fixup_huawei_mbx_stereo(struct hda_codec *codec,
4268 snd_hda_codec_write(codec, 0x06, 0, AC_VERB_SET_DIGI_CONVERT_3, 0x00);
4269 snd_hda_codec_write(codec, 0x06, 0, AC_VERB_SET_DIGI_CONVERT_3, 0x80);
4270 alc_write_coef_idx(codec, 0x26, 0xf000);
4271 alc_write_coef_idx(codec, 0x22, 0x31);
4272 alc_write_coef_idx(codec, 0x23, 0x0b);
4273 alc_write_coef_idx(codec, 0x25, 0x00);
4274 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 0x26);
4275 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_PROC_COEF, 0xb010);
4278 alc298_huawei_mbx_stereo_seq(codec, seq, seq == dac_init);
4281 static void alc269_fixup_x101_headset_mic(struct hda_codec *codec,
4284 struct alc_spec *spec = codec->spec;
4291 static void alc_update_vref_led(struct hda_codec *codec, hda_nid_t pin,
4300 pinval = snd_hda_codec_get_pin_target(codec, pin);
4304 snd_hda_power_up_pm(codec);
4305 snd_hda_set_pin_ctl_cache(codec, pin, pinval);
4306 snd_hda_power_down_pm(codec);
4313 struct hda_codec *codec = dev_to_hda_codec(led_cdev->dev->parent);
4314 struct alc_spec *spec = codec->spec;
4316 alc_update_vref_led(codec, spec->mute_led_nid,
4322 static unsigned int led_power_filter(struct hda_codec *codec,
4326 struct alc_spec *spec = codec->spec;
4333 snd_hda_set_pin_ctl(codec, nid,
4334 snd_hda_codec_get_pin_target(codec, nid));
4336 return snd_hda_gen_path_power_filter(codec, nid, power_state);
4339 static void alc269_fixup_hp_mute_led(struct hda_codec *codec,
4342 struct alc_spec *spec = codec->spec;
4356 snd_hda_gen_add_mute_led_cdev(codec, vref_mute_led_set);
4357 codec->power_filter = led_power_filter;
4358 codec_dbg(codec,
4365 static void alc269_fixup_hp_mute_led_micx(struct hda_codec *codec,
4369 struct alc_spec *spec = codec->spec;
4374 snd_hda_gen_add_mute_led_cdev(codec, vref_mute_led_set);
4375 codec->power_filter = led_power_filter;
4379 static void alc269_fixup_hp_mute_led_mic1(struct hda_codec *codec,
4382 alc269_fixup_hp_mute_led_micx(codec, fix, action, 0x18);
4385 static void alc269_fixup_hp_mute_led_mic2(struct hda_codec *codec,
4388 alc269_fixup_hp_mute_led_micx(codec, fix, action, 0x19);
4391 static void alc269_fixup_hp_mute_led_mic3(struct hda_codec *codec,
4394 alc269_fixup_hp_mute_led_micx(codec, fix, action, 0x1b);
4398 static void alc_update_gpio_led(struct hda_codec *codec, unsigned int mask,
4403 alc_update_gpio_data(codec, mask, !enabled); /* muted -> LED on */
4410 struct hda_codec *codec = dev_to_hda_codec(led_cdev->dev->parent);
4411 struct alc_spec *spec = codec->spec;
4413 alc_update_gpio_led(codec, spec->gpio_mute_led_mask,
4422 struct hda_codec *codec = dev_to_hda_codec(led_cdev->dev->parent);
4423 struct alc_spec *spec = codec->spec;
4425 alc_update_gpio_led(codec, spec->gpio_mic_led_mask,
4431 static void alc_fixup_hp_gpio_led(struct hda_codec *codec,
4436 struct alc_spec *spec = codec->spec;
4438 alc_fixup_gpio(codec, action, mute_mask | micmute_mask);
4444 snd_hda_gen_add_mute_led_cdev(codec, gpio_mute_led_set);
4448 snd_hda_gen_add_micmute_led_cdev(codec, micmute_led_set);
4452 static void alc236_fixup_hp_gpio_led(struct hda_codec *codec,
4455 alc_fixup_hp_gpio_led(codec, action, 0x02, 0x01);
4458 static void alc269_fixup_hp_gpio_led(struct hda_codec *codec,
4461 alc_fixup_hp_gpio_led(codec, action, 0x08, 0x10);
4464 static void alc285_fixup_hp_gpio_led(struct hda_codec *codec,
4467 alc_fixup_hp_gpio_led(codec, action, 0x04, 0x01);
4470 static void alc286_fixup_hp_gpio_led(struct hda_codec *codec,
4473 alc_fixup_hp_gpio_led(codec, action, 0x02, 0x20);
4476 static void alc287_fixup_hp_gpio_led(struct hda_codec *codec,
4479 alc_fixup_hp_gpio_led(codec, action, 0x10, 0);
4482 static void alc245_fixup_hp_gpio_led(struct hda_codec *codec,
4485 struct alc_spec *spec = codec->spec;
4489 alc_fixup_hp_gpio_led(codec, action, 0, 0x04);
4496 struct hda_codec *codec = dev_to_hda_codec(led_cdev->dev->parent);
4497 struct alc_spec *spec = codec->spec;
4499 alc_update_vref_led(codec, spec->cap_mute_led_nid,
4504 static void alc269_fixup_hp_gpio_mic1_led(struct hda_codec *codec,
4507 struct alc_spec *spec = codec->spec;
4509 alc_fixup_hp_gpio_led(codec, action, 0x08, 0);
4517 snd_hda_gen_add_micmute_led_cdev(codec, vref_micmute_led_set);
4518 codec->power_filter = led_power_filter;
4522 static void alc280_fixup_hp_gpio4(struct hda_codec *codec,
4525 struct alc_spec *spec = codec->spec;
4527 alc_fixup_hp_gpio_led(codec, action, 0x08, 0);
4530 snd_hda_gen_add_micmute_led_cdev(codec, vref_micmute_led_set);
4531 codec->power_filter = led_power_filter;
4538 static void alc245_fixup_hp_x360_amp(struct hda_codec *codec,
4541 struct alc_spec *spec = codec->spec;
4550 alc_update_gpio_data(codec, 0x01, true);
4552 alc_update_gpio_data(codec, 0x01, false);
4559 struct hda_codec *codec,
4565 alc_update_gpio_data(codec, 0x04, true);
4568 alc_update_gpio_data(codec, 0x04, false);
4573 static void alc274_fixup_hp_envy_gpio(struct hda_codec *codec,
4577 struct alc_spec *spec = codec->spec;
4586 static void alc_update_coef_led(struct hda_codec *codec,
4593 alc_update_coef_idx(codec, led->idx, led->mask,
4601 struct hda_codec *codec = dev_to_hda_codec(led_cdev->dev->parent);
4602 struct alc_spec *spec = codec->spec;
4604 alc_update_coef_led(codec, &spec->mute_led_coef,
4609 static void alc285_fixup_hp_mute_led_coefbit(struct hda_codec *codec,
4613 struct alc_spec *spec = codec->spec;
4621 snd_hda_gen_add_mute_led_cdev(codec, coef_mute_led_set);
4625 static void alc236_fixup_hp_mute_led_coefbit(struct hda_codec *codec,
4629 struct alc_spec *spec = codec->spec;
4637 snd_hda_gen_add_mute_led_cdev(codec, coef_mute_led_set);
4641 static void alc236_fixup_hp_mute_led_coefbit2(struct hda_codec *codec,
4644 struct alc_spec *spec = codec->spec;
4652 snd_hda_gen_add_mute_led_cdev(codec, coef_mute_led_set);
4656 static void alc245_fixup_hp_mute_led_coefbit(struct hda_codec *codec,
4660 struct alc_spec *spec = codec->spec;
4668 snd_hda_gen_add_mute_led_cdev(codec, coef_mute_led_set);
4676 struct hda_codec *codec = dev_to_hda_codec(led_cdev->dev->parent);
4677 struct alc_spec *spec = codec->spec;
4679 alc_update_coef_led(codec, &spec->mic_led_coef,
4684 static void alc285_fixup_hp_coef_micmute_led(struct hda_codec *codec,
4687 struct alc_spec *spec = codec->spec;
4694 snd_hda_gen_add_micmute_led_cdev(codec, coef_micmute_led_set);
4698 static void alc285_fixup_hp_gpio_micmute_led(struct hda_codec *codec,
4701 struct alc_spec *spec = codec->spec;
4705 alc_fixup_hp_gpio_led(codec, action, 0, 0x04);
4708 static void alc236_fixup_hp_coef_micmute_led(struct hda_codec *codec,
4711 struct alc_spec *spec = codec->spec;
4718 snd_hda_gen_add_micmute_led_cdev(codec, coef_micmute_led_set);
4722 static void alc285_fixup_hp_mute_led(struct hda_codec *codec,
4725 alc285_fixup_hp_mute_led_coefbit(codec, fix, action);
4726 alc285_fixup_hp_coef_micmute_led(codec, fix, action);
4729 static void alc285_fixup_hp_spectre_x360_mute_led(struct hda_codec *codec,
4732 alc285_fixup_hp_mute_led_coefbit(codec, fix, action);
4733 alc285_fixup_hp_gpio_micmute_led(codec, fix, action);
4736 static void alc236_fixup_hp_mute_led(struct hda_codec *codec,
4739 alc236_fixup_hp_mute_led_coefbit(codec, fix, action);
4740 alc236_fixup_hp_coef_micmute_led(codec, fix, action);
4743 static void alc236_fixup_hp_micmute_led_vref(struct hda_codec *codec,
4746 struct alc_spec *spec = codec->spec;
4750 snd_hda_gen_add_micmute_led_cdev(codec, vref_micmute_led_set);
4751 codec->power_filter = led_power_filter;
4755 static void alc236_fixup_hp_mute_led_micmute_vref(struct hda_codec *codec,
4758 alc236_fixup_hp_mute_led_coefbit(codec, fix, action);
4759 alc236_fixup_hp_micmute_led_vref(codec, fix, action);
4762 static inline void alc298_samsung_write_coef_pack(struct hda_codec *codec,
4765 alc_write_coef_idx(codec, 0x23, coefs[0]);
4766 alc_write_coef_idx(codec, 0x25, coefs[1]);
4767 alc_write_coef_idx(codec, 0x26, 0xb011);
4775 static void alc298_fixup_samsung_amp(struct hda_codec *codec,
4794 alc_write_coef_idx(codec, 0x22, amps[i].nid);
4797 alc298_samsung_write_coef_pack(codec, amps[i].init_seq[j]);
4800 alc298_samsung_write_coef_pack(codec, init_seq[j]);
4805 static void gpio2_mic_hotkey_event(struct hda_codec *codec,
4808 struct alc_spec *spec = codec->spec;
4818 static int alc_register_micmute_input_device(struct hda_codec *codec)
4820 struct alc_spec *spec = codec->spec;
4825 codec_err(codec, "Out of memory (input_allocate_device)\n");
4840 codec_err(codec, "input_register_device failed\n");
4854 static void alc280_fixup_hp_gpio2_mic_hotkey(struct hda_codec *codec,
4857 struct alc_spec *spec = codec->spec;
4859 alc_fixup_hp_gpio_led(codec, action, 0x08, 0x10);
4862 if (alc_register_micmute_input_device(codec) != 0)
4868 snd_hda_codec_write_cache(codec, codec->core.afg, 0,
4870 snd_hda_jack_detect_enable_callback(codec, codec->core.afg,
4888 static void alc233_fixup_lenovo_line2_mic_hotkey(struct hda_codec *codec,
4891 struct alc_spec *spec = codec->spec;
4893 alc_fixup_hp_gpio_led(codec, action, 0, 0x04);
4896 if (alc_register_micmute_input_device(codec) != 0)
4899 snd_hda_jack_detect_enable_callback(codec, 0x1b,
4918 static void alc269_fixup_hp_line1_mic1_led(struct hda_codec *codec,
4921 struct alc_spec *spec = codec->spec;
4923 alc269_fixup_hp_mute_led_micx(codec, fix, action, 0x1a);
4926 snd_hda_gen_add_micmute_led_cdev(codec, vref_micmute_led_set);
4941 static void alc_headset_mode_unplugged(struct hda_codec *codec)
4943 struct alc_spec *spec = codec->spec;
5019 alc_update_coef_idx(codec, 0x45, 0xf<<12 | 1<<10, 5<<12);
5023 switch (codec->core.vendor_id) {
5025 alc_process_coef_fw(codec, coef0255);
5031 alc_process_coef_fw(codec, coef0256);
5036 alc_process_coef_fw(codec, coef0274);
5040 alc_process_coef_fw(codec, coef0233);
5044 alc_process_coef_fw(codec, coef0288);
5047 alc_process_coef_fw(codec, coef0298);
5048 alc_process_coef_fw(codec, coef0288);
5051 alc_process_coef_fw(codec, coef0292);
5054 alc_process_coef_fw(codec, coef0293);
5057 alc_process_coef_fw(codec, coef0668);
5065 alc_process_coef_fw(codec, alc225_pre_hsmode);
5066 alc_process_coef_fw(codec, coef0225);
5069 alc_update_coefex_idx(codec, 0x57, 0x5, 1<<14, 0);
5072 codec_dbg(codec, "Headset jack set to unplugged mode.\n");
5076 static void alc_headset_mode_mic_in(struct hda_codec *codec, hda_nid_t hp_pin,
5136 switch (codec->core.vendor_id) {
5138 alc_write_coef_idx(codec, 0x45, 0xc489);
5139 snd_hda_set_pin_ctl_cache(codec, hp_pin, 0);
5140 alc_process_coef_fw(codec, coef0255);
5141 snd_hda_set_pin_ctl_cache(codec, mic_pin, PIN_VREF50);
5147 alc_write_coef_idx(codec, 0x45, 0xc489);
5148 snd_hda_set_pin_ctl_cache(codec, hp_pin, 0);
5149 alc_process_coef_fw(codec, coef0256);
5150 snd_hda_set_pin_ctl_cache(codec, mic_pin, PIN_VREF50);
5155 alc_write_coef_idx(codec, 0x45, 0x4689);
5156 snd_hda_set_pin_ctl_cache(codec, hp_pin, 0);
5157 alc_process_coef_fw(codec, coef0274);
5158 snd_hda_set_pin_ctl_cache(codec, mic_pin, PIN_VREF50);
5162 alc_write_coef_idx(codec, 0x45, 0xc429);
5163 snd_hda_set_pin_ctl_cache(codec, hp_pin, 0);
5164 alc_process_coef_fw(codec, coef0233);
5165 snd_hda_set_pin_ctl_cache(codec, mic_pin, PIN_VREF50);
5170 snd_hda_set_pin_ctl_cache(codec, hp_pin, 0);
5171 alc_process_coef_fw(codec, coef0288);
5172 snd_hda_set_pin_ctl_cache(codec, mic_pin, PIN_VREF50);
5175 snd_hda_set_pin_ctl_cache(codec, hp_pin, 0);
5176 alc_process_coef_fw(codec, coef0292);
5180 alc_write_coef_idx(codec, 0x45, 0xc429);
5181 snd_hda_set_pin_ctl_cache(codec, hp_pin, 0);
5182 alc_process_coef_fw(codec, coef0293);
5183 snd_hda_set_pin_ctl_cache(codec, mic_pin, PIN_VREF50);
5186 alc_update_coefex_idx(codec, 0x57, 0x5, 0, 1<<14);
5190 snd_hda_set_pin_ctl_cache(codec, hp_pin, 0);
5191 snd_hda_set_pin_ctl_cache(codec, mic_pin, PIN_VREF50);
5194 alc_write_coef_idx(codec, 0x11, 0x0001);
5195 snd_hda_set_pin_ctl_cache(codec, hp_pin, 0);
5196 alc_process_coef_fw(codec, coef0688);
5197 snd_hda_set_pin_ctl_cache(codec, mic_pin, PIN_VREF50);
5205 alc_process_coef_fw(codec, alc225_pre_hsmode);
5206 alc_update_coef_idx(codec, 0x45, 0x3f<<10, 0x31<<10);
5207 snd_hda_set_pin_ctl_cache(codec, hp_pin, 0);
5208 alc_process_coef_fw(codec, coef0225);
5209 snd_hda_set_pin_ctl_cache(codec, mic_pin, PIN_VREF50);
5212 codec_dbg(codec, "Headset jack set to mic-in mode.\n");
5215 static void alc_headset_mode_default(struct hda_codec *codec)
5281 switch (codec->core.vendor_id) {
5288 alc_process_coef_fw(codec, alc225_pre_hsmode);
5289 alc_process_coef_fw(codec, coef0225);
5292 alc_process_coef_fw(codec, coef0255);
5298 alc_write_coef_idx(codec, 0x1b, 0x0e4b);
5299 alc_write_coef_idx(codec, 0x45, 0xc089);
5301 alc_process_coef_fw(codec, coef0256);
5306 alc_process_coef_fw(codec, coef0274);
5310 alc_process_coef_fw(codec, coef0233);
5315 alc_process_coef_fw(codec, coef0288);
5318 alc_process_coef_fw(codec, coef0292);
5321 alc_process_coef_fw(codec, coef0293);
5324 alc_process_coef_fw(codec, coef0688);
5327 alc_update_coefex_idx(codec, 0x57, 0x5, 1<<14, 0);
5330 codec_dbg(codec, "Headset jack set to headphone (default) mode.\n");
5334 static void alc_headset_mode_ctia(struct hda_codec *codec)
5390 switch (codec->core.vendor_id) {
5392 alc_process_coef_fw(codec, coef0255);
5398 alc_process_coef_fw(codec, coef0256);
5403 alc_write_coef_idx(codec, 0x45, 0xd689);
5407 alc_process_coef_fw(codec, coef0233);
5410 val = alc_read_coef_idx(codec, 0x50);
5412 alc_update_coef_idx(codec, 0x8e, 0x0070, 0x0020);
5413 alc_update_coef_idx(codec, 0x4f, 0xfcc0, 0xd400);
5416 alc_update_coef_idx(codec, 0x8e, 0x0070, 0x0010);
5417 alc_update_coef_idx(codec, 0x4f, 0xfcc0, 0xd400);
5423 alc_update_coef_idx(codec, 0x4f, 0xfcc0, 0xd400);
5425 alc_process_coef_fw(codec, coef0288);
5428 alc_process_coef_fw(codec, coef0292);
5431 alc_process_coef_fw(codec, coef0293);
5434 alc_process_coef_fw(codec, coef0688);
5442 val = alc_read_coef_idx(codec, 0x45);
5444 alc_process_coef_fw(codec, coef0225_2);
5446 alc_process_coef_fw(codec, coef0225_1);
5449 alc_update_coefex_idx(codec, 0x57, 0x5, 1<<14, 0);
5452 codec_dbg(codec, "Headset jack set to iPhone-style headset mode.\n");
5456 static void alc_headset_mode_omtp(struct hda_codec *codec)
5505 switch (codec->core.vendor_id) {
5507 alc_process_coef_fw(codec, coef0255);
5513 alc_process_coef_fw(codec, coef0256);
5518 alc_write_coef_idx(codec, 0x45, 0xe689);
5522 alc_process_coef_fw(codec, coef0233);
5525 alc_update_coef_idx(codec, 0x8e, 0x0070, 0x0010);/* Headset output enable */
5526 alc_update_coef_idx(codec, 0x4f, 0xfcc0, 0xe400);
5531 alc_update_coef_idx(codec, 0x4f, 0xfcc0, 0xe400);
5533 alc_process_coef_fw(codec, coef0288);
5536 alc_process_coef_fw(codec, coef0292);
5539 alc_process_coef_fw(codec, coef0293);
5542 alc_process_coef_fw(codec, coef0688);
5550 alc_process_coef_fw(codec, coef0225);
5553 codec_dbg(codec, "Headset jack set to Nokia-style headset mode.\n");
5556 static void alc_determine_headset_type(struct hda_codec *codec)
5560 struct alc_spec *spec = codec->spec;
5600 alc_update_coef_idx(codec, 0x45, 0xf<<12 | 1<<10, 5<<12);
5604 switch (codec->core.vendor_id) {
5606 alc_process_coef_fw(codec, coef0255);
5608 val = alc_read_coef_idx(codec, 0x46);
5615 alc_write_coef_idx(codec, 0x1b, 0x0e4b);
5616 alc_write_coef_idx(codec, 0x06, 0x6104);
5617 alc_write_coefex_idx(codec, 0x57, 0x3, 0x09a3);
5619 snd_hda_codec_write(codec, 0x21, 0,
5622 snd_hda_codec_write(codec, 0x21, 0,
5625 alc_process_coef_fw(codec, coef0255);
5627 val = alc_read_coef_idx(codec, 0x46);
5630 alc_write_coefex_idx(codec, 0x57, 0x3, 0x0da3);
5631 alc_update_coefex_idx(codec, 0x57, 0x5, 1<<14, 0);
5633 snd_hda_codec_write(codec, 0x21, 0,
5636 snd_hda_codec_write(codec, 0x21, 0,
5642 alc_process_coef_fw(codec, coef0274);
5644 val = alc_read_coef_idx(codec, 0x46);
5649 alc_write_coef_idx(codec, 0x45, 0xd029);
5651 val = alc_read_coef_idx(codec, 0x46);
5655 snd_hda_codec_write(codec, 0x21, 0,
5658 snd_hda_codec_write(codec, 0x21, 0,
5662 val = alc_read_coef_idx(codec, 0x50);
5664 alc_update_coef_idx(codec, 0x8e, 0x0070, 0x0020);
5665 alc_process_coef_fw(codec, coef0288);
5667 val = alc_read_coef_idx(codec, 0x50);
5670 alc_update_coef_idx(codec, 0x8e, 0x0070, 0x0010);
5671 alc_process_coef_fw(codec, coef0288);
5673 val = alc_read_coef_idx(codec, 0x50);
5676 alc_process_coef_fw(codec, coef0298);
5677 snd_hda_codec_write(codec, 0x21, 0,
5680 snd_hda_codec_write(codec, 0x21, 0,
5685 alc_process_coef_fw(codec, coef0288);
5687 val = alc_read_coef_idx(codec, 0x50);
5691 alc_write_coef_idx(codec, 0x6b, 0xd429);
5693 val = alc_read_coef_idx(codec, 0x6c);
5697 alc_process_coef_fw(codec, coef0293);
5699 val = alc_read_coef_idx(codec, 0x46);
5703 alc_process_coef_fw(codec, coef0688);
5705 val = alc_read_coef_idx(codec, 0xbe);
5714 snd_hda_codec_write(codec, 0x21, 0,
5717 snd_hda_codec_write(codec, 0x21, 0,
5720 alc_process_coef_fw(codec, alc225_pre_hsmode);
5721 alc_update_coef_idx(codec, 0x67, 0xf000, 0x1000);
5722 val = alc_read_coef_idx(codec, 0x45);
5724 alc_update_coef_idx(codec, 0x45, 0x3f<<10, 0x34<<10);
5725 alc_update_coef_idx(codec, 0x49, 3<<8, 2<<8);
5727 val = alc_read_coef_idx(codec, 0x46);
5730 alc_update_coef_idx(codec, 0x45, 0x3f<<10, 0x34<<10);
5731 alc_update_coef_idx(codec, 0x49, 3<<8, 1<<8);
5733 val = alc_read_coef_idx(codec, 0x46);
5736 alc_update_coef_idx(codec, 0x4a, 7<<6, 7<<6);
5737 alc_update_coef_idx(codec, 0x4a, 3<<4, 3<<4);
5738 alc_update_coef_idx(codec, 0x67, 0xf000, 0x3000);
5740 snd_hda_codec_write(codec, 0x21, 0,
5743 snd_hda_codec_write(codec, 0x21, 0,
5751 codec_dbg(codec, "Headset jack detected iPhone-style headset: %s\n",
5756 static void alc_update_headset_mode(struct hda_codec *codec)
5758 struct alc_spec *spec = codec->spec;
5765 if (!snd_hda_jack_detect(codec, hp_pin))
5775 snd_hda_gen_update_outputs(codec);
5781 alc_headset_mode_unplugged(codec);
5788 alc_determine_headset_type(codec);
5790 alc_headset_mode_ctia(codec);
5792 alc_headset_mode_omtp(codec);
5796 alc_headset_mode_mic_in(codec, hp_pin, spec->headphone_mic_pin);
5800 alc_headset_mode_default(codec);
5805 snd_hda_set_pin_ctl_cache(codec, hp_pin,
5808 snd_hda_set_pin_ctl_cache(codec, spec->headphone_mic_pin,
5813 snd_hda_gen_update_outputs(codec);
5816 static void alc_update_headset_mode_hook(struct hda_codec *codec,
5820 alc_update_headset_mode(codec);
5823 static void alc_update_headset_jack_cb(struct hda_codec *codec,
5826 snd_hda_gen_hp_automute(codec, jack);
5827 alc_update_headset_mode(codec);
5830 static void alc_probe_headset_mode(struct hda_codec *codec)
5833 struct alc_spec *spec = codec->spec;
5850 static void alc_fixup_headset_mode(struct hda_codec *codec,
5853 struct alc_spec *spec = codec->spec;
5860 alc_probe_headset_mode(codec);
5863 if (is_s3_resume(codec) || is_s4_resume(codec)) {
5867 alc_update_headset_mode(codec);
5872 static void alc_fixup_headset_mode_no_hp_mic(struct hda_codec *codec,
5876 struct alc_spec *spec = codec->spec;
5880 alc_fixup_headset_mode(codec, fix, action);
5883 static void alc255_set_default_jack_type(struct hda_codec *codec)
5902 switch (codec->core.vendor_id) {
5904 alc_process_coef_fw(codec, alc255fw);
5910 alc_process_coef_fw(codec, alc256fw);
5916 static void alc_fixup_headset_mode_alc255(struct hda_codec *codec,
5920 alc255_set_default_jack_type(codec);
5922 alc_fixup_headset_mode(codec, fix, action);
5925 static void alc_fixup_headset_mode_alc255_no_hp_mic(struct hda_codec *codec,
5929 struct alc_spec *spec = codec->spec;
5931 alc255_set_default_jack_type(codec);
5934 alc_fixup_headset_mode(codec, fix, action);
5937 static void alc288_update_headset_jack_cb(struct hda_codec *codec,
5940 struct alc_spec *spec = codec->spec;
5942 alc_update_headset_jack_cb(codec, jack);
5944 alc_update_gpio_data(codec, 0x40, spec->gen.hp_jack_present);
5947 static void alc_fixup_headset_mode_dell_alc288(struct hda_codec *codec,
5950 alc_fixup_headset_mode(codec, fix, action);
5952 struct alc_spec *spec = codec->spec;
5960 static void alc_fixup_auto_mute_via_amp(struct hda_codec *codec,
5964 struct alc_spec *spec = codec->spec;
5969 static void alc_fixup_no_shutup(struct hda_codec *codec,
5973 struct alc_spec *spec = codec->spec;
5978 static void alc_fixup_disable_aamix(struct hda_codec *codec,
5982 struct alc_spec *spec = codec->spec;
5989 static void alc_fixup_tpt440_dock(struct hda_codec *codec,
5997 struct alc_spec *spec = codec->spec;
6001 codec->power_save_node = 0; /* avoid click noises */
6002 snd_hda_apply_pincfgs(codec, pincfgs);
6006 static void alc_fixup_tpt470_dock(struct hda_codec *codec,
6014 struct alc_spec *spec = codec->spec;
6018 snd_hda_apply_pincfgs(codec, pincfgs);
6021 snd_hda_codec_write(codec, 0x17, 0,
6024 snd_hda_codec_write(codec, 0x19, 0,
6029 static void alc_fixup_tpt470_dacs(struct hda_codec *codec,
6034 * ALC298 codec
6040 struct alc_spec *spec = codec->spec;
6046 static void alc295_fixup_asus_dacs(struct hda_codec *codec,
6052 struct alc_spec *spec = codec->spec;
6058 static void alc_shutup_dell_xps13(struct hda_codec *codec)
6060 struct alc_spec *spec = codec->spec;
6064 snd_hda_codec_write(codec, hp_pin, 0,
6069 static void alc_fixup_dell_xps13(struct hda_codec *codec,
6072 struct alc_spec *spec = codec->spec;
6081 snd_hda_codec_set_pin_target(codec, 0x19, PIN_VREFHIZ);
6096 static void alc_fixup_headset_mode_alc662(struct hda_codec *codec,
6099 struct alc_spec *spec = codec->spec;
6107 snd_hda_codec_write(codec, 0x1b, 0, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000);
6108 snd_hda_override_wcaps(codec, 0x1b, get_wcaps(codec, 0x1b) & ~AC_WCAP_IN_AMP);
6110 alc_fixup_headset_mode(codec, fix, action);
6113 static void alc_fixup_headset_mode_alc668(struct hda_codec *codec,
6117 alc_write_coef_idx(codec, 0xc4, 0x8000);
6118 alc_update_coef_idx(codec, 0xc2, ~0xfe, 0);
6119 snd_hda_set_pin_ctl_cache(codec, 0x18, 0);
6121 alc_fixup_headset_mode(codec, fix, action);
6125 static int find_ext_mic_pin(struct hda_codec *codec)
6127 struct alc_spec *spec = codec->spec;
6137 defcfg = snd_hda_codec_get_pincfg(codec, nid);
6146 static void alc271_hp_gate_mic_jack(struct hda_codec *codec,
6150 struct alc_spec *spec = codec->spec;
6153 int mic_pin = find_ext_mic_pin(codec);
6158 snd_hda_jack_set_gating_jack(codec, mic_pin, hp_pin);
6162 static void alc269_fixup_limit_int_mic_boost(struct hda_codec *codec,
6166 struct alc_spec *spec = codec->spec;
6182 defcfg = snd_hda_codec_get_pincfg(codec, nid);
6186 snd_hda_override_amp_caps(codec, nid, HDA_INPUT,
6194 static void alc283_hp_automute_hook(struct hda_codec *codec,
6197 struct alc_spec *spec = codec->spec;
6201 snd_hda_gen_hp_automute(codec, jack);
6206 snd_hda_codec_write(codec, 0x19, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
6210 static void alc283_fixup_chromebook(struct hda_codec *codec,
6213 struct alc_spec *spec = codec->spec;
6217 snd_hda_override_wcaps(codec, 0x03, 0);
6224 alc_update_coef_idx(codec, 0x06, 0x000c, 0);
6226 alc_update_coef_idx(codec, 0x1a, 0, 1 << 4);
6231 static void alc283_fixup_sense_combo_jack(struct hda_codec *codec,
6234 struct alc_spec *spec = codec->spec;
6243 alc_update_coef_idx(codec, 0x06, 0x000c, 0);
6249 static void asus_tx300_automute(struct hda_codec *codec)
6251 struct alc_spec *spec = codec->spec;
6252 snd_hda_gen_update_outputs(codec);
6253 if (snd_hda_jack_detect(codec, 0x1b))
6257 static void alc282_fixup_asus_tx300(struct hda_codec *codec,
6260 struct alc_spec *spec = codec->spec;
6270 alc_setup_gpio(codec, 0x04);
6271 snd_hda_apply_pincfgs(codec, dock_pins);
6274 snd_hda_jack_detect_enable_callback(codec, 0x1b,
6284 rename_ctl(codec, "Speaker Playback Switch",
6286 rename_ctl(codec, "Bass Speaker Playback Switch",
6292 static void alc290_fixup_mono_speakers(struct hda_codec *codec,
6300 snd_hda_override_conn_list(codec, 0x14, ARRAY_SIZE(conn1), conn1);
6301 snd_hda_override_conn_list(codec, 0x15, ARRAY_SIZE(conn1), conn1);
6305 static void alc298_fixup_speaker_volume(struct hda_codec *codec,
6317 snd_hda_override_conn_list(codec, 0x17, ARRAY_SIZE(conn1), conn1);
6322 static void alc295_fixup_disable_dac3(struct hda_codec *codec,
6327 snd_hda_override_conn_list(codec, 0x17, ARRAY_SIZE(conn), conn);
6332 static void alc285_fixup_speaker2_to_dac1(struct hda_codec *codec,
6337 snd_hda_override_conn_list(codec, 0x17, ARRAY_SIZE(conn), conn);
6342 static void alc280_hp_gpio4_automute_hook(struct hda_codec *codec,
6345 struct alc_spec *spec = codec->spec;
6347 snd_hda_gen_hp_automute(codec, jack);
6349 alc_update_gpio_led(codec, 0x10, spec->mute_led_polarity,
6359 static void alc280_fixup_hp_9480m(struct hda_codec *codec,
6363 struct alc_spec *spec = codec->spec;
6365 alc_fixup_hp_gpio_led(codec, action, 0x08, 0);
6374 static void alc275_fixup_gpio4_off(struct hda_codec *codec,
6378 struct alc_spec *spec = codec->spec;
6393 static void alc285_fixup_thinkpad_x1_gen7(struct hda_codec *codec,
6400 struct alc_spec *spec = codec->spec;
6404 snd_hda_override_conn_list(codec, 0x17, ARRAY_SIZE(conn), conn);
6414 rename_ctl(codec, "Front Playback Volume", "DAC1 Playback Volume");
6415 rename_ctl(codec, "Bass Speaker Playback Volume", "DAC2 Playback Volume");
6420 static void alc233_alc662_fixup_lenovo_dual_codecs(struct hda_codec *codec,
6424 alc_fixup_dual_codecs(codec, fix, action);
6428 strcpy(codec->card->longname, "HDAudio-Lenovo-DualCodecs");
6431 /* rename Capture controls depending on the codec */
6432 rename_ctl(codec, "Capture Volume",
6433 codec->addr == 0 ?
6436 rename_ctl(codec, "Capture Switch",
6437 codec->addr == 0 ?
6444 static void alc225_fixup_s3_pop_noise(struct hda_codec *codec,
6450 codec->power_save_node = 1;
6454 static void alc274_fixup_bind_dacs(struct hda_codec *codec,
6457 struct alc_spec *spec = codec->spec;
6468 codec->power_save_node = 0;
6472 static void alc289_fixup_asus_ga401(struct hda_codec *codec,
6478 struct alc_spec *spec = codec->spec;
6487 static void alc285_fixup_invalidate_dacs(struct hda_codec *codec,
6493 snd_hda_override_wcaps(codec, 0x03, 0);
6496 static void alc_combo_jack_hp_jd_restart(struct hda_codec *codec)
6498 switch (codec->core.vendor_id) {
6504 alc_update_coef_idx(codec, 0x4a, 0x8000, 1 << 15); /* Reset HP JD */
6505 alc_update_coef_idx(codec, 0x4a, 0x8000, 0 << 15);
6514 alc_update_coef_idx(codec, 0x1b, 0x8000, 1 << 15); /* Reset HP JD */
6515 alc_update_coef_idx(codec, 0x1b, 0x8000, 0 << 15);
6520 static void alc295_fixup_chromebook(struct hda_codec *codec,
6523 struct alc_spec *spec = codec->spec;
6530 alc_combo_jack_hp_jd_restart(codec);
6535 static void alc_fixup_disable_mic_vref(struct hda_codec *codec,
6539 snd_hda_codec_set_pin_target(codec, 0x19, PIN_VREFHIZ);
6543 static void alc294_gx502_toggle_output(struct hda_codec *codec,
6546 /* The Windows driver sets the codec up in a very different way where
6549 if (snd_hda_jack_detect_state(codec, 0x21) == HDA_JACK_PRESENT)
6550 alc_write_coef_idx(codec, 0x10, 0x8a20);
6552 alc_write_coef_idx(codec, 0x10, 0x0a20);
6555 static void alc294_fixup_gx502_hp(struct hda_codec *codec,
6559 if (!is_jack_detectable(codec, 0x21))
6564 snd_hda_jack_detect_enable_callback(codec, 0x21,
6571 alc294_gx502_toggle_output(codec, NULL);
6576 static void alc294_gu502_toggle_output(struct hda_codec *codec,
6582 if (snd_hda_jack_detect_state(codec, 0x21) == HDA_JACK_PRESENT)
6583 alc_write_coef_idx(codec, 0x10, 0x8420);
6585 alc_write_coef_idx(codec, 0x10, 0x0a20);
6588 static void alc294_fixup_gu502_hp(struct hda_codec *codec,
6591 if (!is_jack_detectable(codec, 0x21))
6596 snd_hda_jack_detect_enable_callback(codec, 0x21,
6600 alc294_gu502_toggle_output(codec, NULL);
6605 static void alc285_fixup_hp_gpio_amp_init(struct hda_codec *codec,
6612 alc_write_coef_idx(codec, 0x65, 0x0);
6615 static void alc274_fixup_hp_headset_mic(struct hda_codec *codec,
6620 alc_combo_jack_hp_jd_restart(codec);
6625 static void alc_fixup_no_int_mic(struct hda_codec *codec,
6628 struct alc_spec *spec = codec->spec;
6633 alc_update_coef_idx(codec, 0x45, 0xf<<12 | 1<<10, 5<<12);
6637 alc_combo_jack_hp_jd_restart(codec);
6645 static void alc285_fixup_hp_spectre_x360_eb1(struct hda_codec *codec,
6650 struct alc_spec *spec = codec->spec;
6658 alc_fixup_hp_gpio_led(codec, action, 0x00, 0x04);
6666 snd_hda_apply_pincfgs(codec, pincfgs);
6668 snd_hda_override_conn_list(codec, 0x14, ARRAY_SIZE(conn), conn);
6669 snd_hda_override_conn_list(codec, 0x17, ARRAY_SIZE(conn), conn);
6673 alc_update_gpio_data(codec, 0x01, true);
6675 alc_update_gpio_data(codec, 0x01, false);
6680 static void alc285_fixup_hp_spectre_x360(struct hda_codec *codec,
6691 snd_hda_apply_pincfgs(codec, pincfgs);
6693 snd_hda_override_conn_list(codec, 0x17, ARRAY_SIZE(conn), conn);
6698 static void alc285_fixup_hp_envy_x360(struct hda_codec *codec,
6724 snd_hda_apply_pincfgs(codec, pincfgs);
6727 alc295_fixup_disable_dac3(codec, fix, action);
6730 snd_hda_codec_amp_stereo(codec, 0x21, HDA_OUTPUT, 0, -1, 0);
6733 snd_hda_jack_set_gating_jack(codec, 0x19, 0x21);
6736 snd_hda_codec_set_pin_target(codec, 0x19, PIN_VREF50);
6739 alc_process_coef_fw(codec, coefs);
6742 rename_ctl(codec, "Bass Speaker Playback Volume",
6744 rename_ctl(codec, "Front Playback Switch",
6746 rename_ctl(codec, "Bass Speaker Playback Switch",
6755 static void alc_fixup_thinkpad_acpi(struct hda_codec *codec,
6758 alc_fixup_no_shutup(codec, fix, action); /* reduce click noise */
6759 hda_fixup_thinkpad_acpi(codec, fix, action);
6763 static void alc287_fixup_legion_15imhg05_speakers(struct hda_codec *codec,
6767 struct alc_spec *spec = codec->spec;
6879 spec->comps[i].codec = cdc;
6911 spec->comps[0].codec = cdc;
6935 static void cs35l41_fixup_spi_two(struct hda_codec *codec, const struct hda_fixup *fix, int action)
6937 cs35l41_generic_fixup(codec, action, "spi", "CSC3551", 2);
6940 static void cs35l41_fixup_spi_four(struct hda_codec *codec, const struct hda_fixup *fix, int action)
6942 cs35l41_generic_fixup(codec, action, "spi", "CSC3551", 4);
6976 static void alc256_fixup_set_coef_defaults(struct hda_codec *codec,
6988 alc_process_coef_fw(codec, alc256_fixup_set_coef_defaults_coefs);
6998 static void alc233_fixup_no_audio_jack(struct hda_codec *codec,
7009 alc_process_coef_fw(codec, alc233_fixup_no_audio_jack_coefs);
7012 static void alc256_fixup_mic_no_presence_and_resume(struct hda_codec *codec,
7017 * The Clevo NJ51CU comes either with the ALC293 or the ALC256 codec,
7018 * but uses the 0x8686 subproduct id in both cases. The ALC256 codec
7021 if (codec->core.vendor_id == 0x10ec0256) {
7022 alc_update_coef_idx(codec, 0x10, 1<<9, 0);
7023 snd_hda_codec_set_pincfg(codec, 0x19, 0x04a11120);
7025 snd_hda_codec_set_pincfg(codec, 0x1a, 0x04a1113c);
7029 static void alc_fixup_dell4_mic_no_presence_quiet(struct hda_codec *codec,
7033 struct alc_spec *spec = codec->spec;
7037 alc269_fixup_limit_int_mic_boost(codec, fix, action);
7046 snd_hda_codec_set_pin_target(codec, 0x19, PIN_VREFHIZ);
7047 snd_hda_codec_set_pin_target(codec, 0x1b, PIN_VREFHIZ);
7064 static void alc287_fixup_yoga9_14iap7_bass_spk_pin(struct hda_codec *codec,
7090 struct alc_spec *spec = codec->spec;
7094 snd_hda_apply_pincfgs(codec, pincfgs);
7095 snd_hda_override_conn_list(codec, 0x17, ARRAY_SIZE(conn), conn);
7101 static void alc295_fixup_dell_inspiron_top_speakers(struct hda_codec *codec,
7116 struct alc_spec *spec = codec->spec;
7118 alc_fixup_no_shutup(codec, fix, action);
7122 snd_hda_apply_pincfgs(codec, pincfgs);
7123 snd_hda_override_conn_list(codec, 0x17, ARRAY_SIZE(conn), conn);
7130 static void alc287_fixup_bind_dacs(struct hda_codec *codec,
7133 struct alc_spec *spec = codec->spec;
7142 snd_hda_override_conn_list(codec, 0x17, ARRAY_SIZE(conn), conn);
7146 snd_hda_codec_write_cache(codec, 0x14, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
7151 static void alc_fixup_headset_mic(struct hda_codec *codec,
7154 struct alc_spec *spec = codec->spec;
7162 snd_hda_apply_pincfgs(codec, pincfgs);
7163 alc_update_coef_idx(codec, 0x45, 0xf<<12 | 1<<10, 5<<12);
7446 * depending on the codec ID
7448 static void alc298_fixup_lenovo_c940_duet7(struct hda_codec *codec,
7454 if (codec->core.vendor_id == 0x10ec0298)
7458 __snd_hda_apply_fixup(codec, id, action, 0);
7462 * 14IRP8 PCI SSID will mistakenly be matched with the DuetITL codec SSID,
7463 * so we need to apply a different fixup in this case. The only DuetITL codec
7468 static void alc287_fixup_lenovo_14irp8_duetitl(struct hda_codec *codec,
7474 if (codec->core.subsystem_id == 0x17aa3802)
7478 __snd_hda_apply_fixup(codec, id, action, 0);
10935 * at most one tbl is allowed to define for the same vendor and same codec
10958 static void alc269_fill_coef(struct hda_codec *codec)
10960 struct alc_spec *spec = codec->spec;
10966 if ((alc_get_coef0(codec) & 0x00ff) < 0x015) {
10967 alc_write_coef_idx(codec, 0xf, 0x960b);
10968 alc_write_coef_idx(codec, 0xe, 0x8817);
10971 if ((alc_get_coef0(codec) & 0x00ff) == 0x016) {
10972 alc_write_coef_idx(codec, 0xf, 0x960b);
10973 alc_write_coef_idx(codec, 0xe, 0x8814);
10976 if ((alc_get_coef0(codec) & 0x00ff) == 0x017) {
10978 alc_update_coef_idx(codec, 0x04, 0, 1<<11);
10981 if ((alc_get_coef0(codec) & 0x00ff) == 0x018) {
10982 val = alc_read_coef_idx(codec, 0xd);
10985 alc_write_coef_idx(codec, 0xd, val | (1<<10));
10987 val = alc_read_coef_idx(codec, 0x17);
10990 alc_write_coef_idx(codec, 0x17, val | (1<<7));
10995 alc_update_coef_idx(codec, 0x4, 0, 1<<11);
11000 static int patch_alc269(struct hda_codec *codec)
11005 err = alc_alloc_spec(codec, 0x0b);
11009 spec = codec->spec;
11011 codec->power_save_node = 0;
11015 codec->patch_ops.suspend = alc269_suspend;
11016 codec->patch_ops.resume = alc269_resume;
11021 switch (codec->core.vendor_id) {
11024 switch (alc_get_coef0(codec) & 0x00f0) {
11026 if (codec->bus->pci &&
11027 codec->bus->pci->subsystem_vendor == 0x1025 &&
11029 err = alc_codec_rename(codec, "ALC271X");
11033 if (codec->bus->pci &&
11034 codec->bus->pci->subsystem_vendor == 0x17aa &&
11035 codec->bus->pci->subsystem_device == 0x21f3)
11036 err = alc_codec_rename(codec, "ALC3202");
11043 alc_fix_pll_init(codec, 0x20, 0x04, 15);
11049 alc269_fill_coef(codec);
11095 if (codec->core.vendor_id == 0x10ec0236 &&
11096 codec->bus->pci->vendor != PCI_VENDOR_ID_AMD)
11110 if (alc_get_coef0(codec) & 0x0010)
11137 alc_update_coef_idx(codec, 0x6b, 0x0018, (1<<4) | (1<<3)); /* UAJ MIC Vref control by verb */
11153 alc_update_coef_idx(codec, 0x4a, 1 << 15, 0); /* Combo jack auto trigger control */
11159 if (snd_hda_codec_read(codec, 0x51, 0, AC_VERB_PARAMETERS, 0) == 0x10ec5505) {
11164 alc_pre_init(codec);
11166 snd_hda_pick_fixup(codec, alc269_fixup_models,
11172 if (codec->fixup_id == ALC282_FIXUP_ASUS_TX300 &&
11173 codec->core.vendor_id == 0x10ec0294) {
11174 codec_dbg(codec, "Clear wrong fixup for ASUS ROG Strix G17\n");
11175 codec->fixup_id = HDA_FIXUP_ID_NOT_SET;
11178 snd_hda_pick_pin_fixup(codec, alc269_pin_fixup_tbl, alc269_fixups, true);
11179 snd_hda_pick_pin_fixup(codec, alc269_fallback_pin_fixup_tbl, alc269_fixups, false);
11180 snd_hda_pick_fixup(codec, NULL, alc269_fixup_vendor_tbl,
11182 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
11184 alc_auto_parse_customize_define(codec);
11186 if (has_cdefine_beep(codec))
11190 err = alc269_parse_auto_config(codec);
11200 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
11205 alc_free(codec);
11213 static int alc861_parse_auto_config(struct hda_codec *codec)
11217 return alc_parse_auto_config(codec, alc861_ignore, alc861_ssids);
11230 static void alc861_fixup_asus_amp_vref_0f(struct hda_codec *codec,
11233 struct alc_spec *spec = codec->spec;
11238 val = snd_hda_codec_get_pin_target(codec, 0x0f);
11242 snd_hda_set_pin_ctl(codec, 0x0f, val);
11247 static void alc_fixup_no_jack_detect(struct hda_codec *codec,
11251 codec->no_jack_detect = 1;
11302 static int patch_alc861(struct hda_codec *codec)
11307 err = alc_alloc_spec(codec, 0x15);
11311 spec = codec->spec;
11312 if (has_cdefine_beep(codec))
11319 alc_pre_init(codec);
11321 snd_hda_pick_fixup(codec, NULL, alc861_fixup_tbl, alc861_fixups);
11322 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
11325 err = alc861_parse_auto_config(codec);
11335 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
11340 alc_free(codec);
11351 static int alc861vd_parse_auto_config(struct hda_codec *codec)
11355 return alc_parse_auto_config(codec, alc861vd_ignore, alc861vd_ssids);
11364 static void alc861vd_fixup_dallas(struct hda_codec *codec,
11368 snd_hda_override_pin_caps(codec, 0x18, 0x00000734);
11369 snd_hda_override_pin_caps(codec, 0x19, 0x0000073c);
11374 static void alc660vd_fixup_asus_gpio1(struct hda_codec *codec,
11377 struct alc_spec *spec = codec->spec;
11381 alc_fixup_gpio(codec, action, 0x01);
11404 static int patch_alc861vd(struct hda_codec *codec)
11409 err = alc_alloc_spec(codec, 0x0b);
11413 spec = codec->spec;
11414 if (has_cdefine_beep(codec))
11419 alc_pre_init(codec);
11421 snd_hda_pick_fixup(codec, NULL, alc861vd_fixup_tbl, alc861vd_fixups);
11422 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
11425 err = alc861vd_parse_auto_config(codec);
11435 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
11440 alc_free(codec);
11460 static int alc662_parse_auto_config(struct hda_codec *codec)
11467 if (codec->core.vendor_id == 0x10ec0272 || codec->core.vendor_id == 0x10ec0663 ||
11468 codec->core.vendor_id == 0x10ec0665 || codec->core.vendor_id == 0x10ec0670 ||
11469 codec->core.vendor_id == 0x10ec0671)
11473 return alc_parse_auto_config(codec, alc662_ignore, ssids);
11476 static void alc272_fixup_mario(struct hda_codec *codec,
11481 if (snd_hda_override_amp_caps(codec, 0x2, HDA_OUTPUT,
11486 codec_warn(codec, "failed to override amp caps for NID 0x2\n");
11499 static void alc_fixup_bass_chmap(struct hda_codec *codec,
11503 struct alc_spec *spec = codec->spec;
11509 static unsigned int gpio_led_power_filter(struct hda_codec *codec,
11513 struct alc_spec *spec = codec->spec;
11514 if (nid == codec->core.afg && power_state == AC_PWRST_D3 && spec->gpio_data)
11519 static void alc662_fixup_led_gpio1(struct hda_codec *codec,
11522 struct alc_spec *spec = codec->spec;
11524 alc_fixup_hp_gpio_led(codec, action, 0x01, 0);
11527 codec->power_filter = gpio_led_power_filter;
11531 static void alc662_usi_automute_hook(struct hda_codec *codec,
11534 struct alc_spec *spec = codec->spec;
11537 snd_hda_gen_hp_automute(codec, jack);
11541 snd_hda_codec_write(codec, 0x19, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
11545 static void alc662_fixup_usi_headset_mic(struct hda_codec *codec,
11548 struct alc_spec *spec = codec->spec;
11555 static void alc662_aspire_ethos_mute_speakers(struct hda_codec *codec,
11564 if (snd_hda_jack_detect_state(codec, 0x1b) == HDA_JACK_PRESENT) {
11565 snd_hda_set_pin_ctl_cache(codec, 0x15, 0);
11566 snd_hda_set_pin_ctl_cache(codec, 0x18, 0);
11568 snd_hda_set_pin_ctl_cache(codec, 0x15, PIN_OUT);
11569 snd_hda_set_pin_ctl_cache(codec, 0x18, PIN_OUT);
11573 static void alc662_fixup_aspire_ethos_hp(struct hda_codec *codec,
11577 if (!is_jack_detectable(codec, 0x1b))
11582 snd_hda_jack_detect_enable_callback(codec, 0x1b,
11585 alc_setup_gpio(codec, 0x02);
11591 alc662_aspire_ethos_mute_speakers(codec, NULL);
11596 static void alc671_fixup_hp_headset_mic2(struct hda_codec *codec,
11599 struct alc_spec *spec = codec->spec;
11611 snd_hda_apply_pincfgs(codec, pincfgs);
11614 alc_write_coef_idx(codec, 0x19, 0xa054);
11619 static void alc897_hp_automute_hook(struct hda_codec *codec,
11622 struct alc_spec *spec = codec->spec;
11625 snd_hda_gen_hp_automute(codec, jack);
11627 snd_hda_codec_write(codec, 0x1b, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
11631 static void alc897_fixup_lenovo_headset_mic(struct hda_codec *codec,
11634 struct alc_spec *spec = codec->spec;
11640 static void alc897_fixup_lenovo_headset_mode(struct hda_codec *codec,
11643 struct alc_spec *spec = codec->spec;
11675 static void alc668_restore_default_value(struct hda_codec *codec)
11677 alc_process_coef_fw(codec, alc668_coefs);
12410 static int patch_alc662(struct hda_codec *codec)
12415 err = alc_alloc_spec(codec, 0x0b);
12419 spec = codec->spec;
12426 alc_fix_pll_init(codec, 0x20, 0x04, 15);
12428 switch (codec->core.vendor_id) {
12434 alc_pre_init(codec);
12436 snd_hda_pick_fixup(codec, alc662_fixup_models,
12438 snd_hda_pick_pin_fixup(codec, alc662_pin_fixup_tbl, alc662_fixups, true);
12439 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
12441 alc_auto_parse_customize_define(codec);
12443 if (has_cdefine_beep(codec))
12446 if ((alc_get_coef0(codec) & (1 << 14)) &&
12447 codec->bus->pci && codec->bus->pci->subsystem_vendor == 0x1025 &&
12449 err = alc_codec_rename(codec, "ALC272X");
12455 err = alc662_parse_auto_config(codec);
12460 switch (codec->core.vendor_id) {
12478 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
12483 alc_free(codec);
12491 static int alc680_parse_auto_config(struct hda_codec *codec)
12493 return alc_parse_auto_config(codec, NULL, NULL);
12498 static int patch_alc680(struct hda_codec *codec)
12503 err = alc_alloc_spec(codec, 0);
12508 err = alc680_parse_auto_config(codec);
12510 alc_free(codec);
12605 MODULE_DESCRIPTION("Realtek HD-audio codec");