Lines Matching refs:codec

14 static void coef_mutex_lock(struct hda_codec *codec)  in coef_mutex_lock()  argument
16 struct alc_spec *spec = codec->spec; in coef_mutex_lock()
18 snd_hda_power_up_pm(codec); in coef_mutex_lock()
22 static void coef_mutex_unlock(struct hda_codec *codec) in coef_mutex_unlock() argument
24 struct alc_spec *spec = codec->spec; in coef_mutex_unlock()
27 snd_hda_power_down_pm(codec); in coef_mutex_unlock()
30 static int __alc_read_coefex_idx(struct hda_codec *codec, hda_nid_t nid, in __alc_read_coefex_idx() argument
35 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_COEF_INDEX, coef_idx); in __alc_read_coefex_idx()
36 val = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_PROC_COEF, 0); in __alc_read_coefex_idx()
40 int alc_read_coefex_idx(struct hda_codec *codec, hda_nid_t nid, in alc_read_coefex_idx() argument
45 coef_mutex_lock(codec); in alc_read_coefex_idx()
46 val = __alc_read_coefex_idx(codec, nid, coef_idx); in alc_read_coefex_idx()
47 coef_mutex_unlock(codec); in alc_read_coefex_idx()
52 static void __alc_write_coefex_idx(struct hda_codec *codec, hda_nid_t nid, in __alc_write_coefex_idx() argument
55 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_COEF_INDEX, coef_idx); in __alc_write_coefex_idx()
56 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PROC_COEF, coef_val); in __alc_write_coefex_idx()
59 void alc_write_coefex_idx(struct hda_codec *codec, hda_nid_t nid, in alc_write_coefex_idx() argument
62 coef_mutex_lock(codec); in alc_write_coefex_idx()
63 __alc_write_coefex_idx(codec, nid, coef_idx, coef_val); in alc_write_coefex_idx()
64 coef_mutex_unlock(codec); in alc_write_coefex_idx()
68 static void __alc_update_coefex_idx(struct hda_codec *codec, hda_nid_t nid, in __alc_update_coefex_idx() argument
72 unsigned int val = __alc_read_coefex_idx(codec, nid, coef_idx); in __alc_update_coefex_idx()
75 __alc_write_coefex_idx(codec, nid, coef_idx, in __alc_update_coefex_idx()
79 void alc_update_coefex_idx(struct hda_codec *codec, hda_nid_t nid, in alc_update_coefex_idx() argument
83 coef_mutex_lock(codec); in alc_update_coefex_idx()
84 __alc_update_coefex_idx(codec, nid, coef_idx, mask, bits_set); in alc_update_coefex_idx()
85 coef_mutex_unlock(codec); in alc_update_coefex_idx()
90 unsigned int alc_get_coef0(struct hda_codec *codec) in alc_get_coef0() argument
92 struct alc_spec *spec = codec->spec; in alc_get_coef0()
95 spec->coef0 = alc_read_coef_idx(codec, 0); in alc_get_coef0()
100 void alc_process_coef_fw(struct hda_codec *codec, const struct coef_fw *fw) in alc_process_coef_fw() argument
102 coef_mutex_lock(codec); in alc_process_coef_fw()
105 __alc_write_coefex_idx(codec, fw->nid, fw->idx, fw->val); in alc_process_coef_fw()
107 __alc_update_coefex_idx(codec, fw->nid, fw->idx, in alc_process_coef_fw()
110 coef_mutex_unlock(codec); in alc_process_coef_fw()
119 void alc_setup_gpio(struct hda_codec *codec, unsigned int mask) in alc_setup_gpio() argument
121 struct alc_spec *spec = codec->spec; in alc_setup_gpio()
129 void alc_write_gpio_data(struct hda_codec *codec) in alc_write_gpio_data() argument
131 struct alc_spec *spec = codec->spec; in alc_write_gpio_data()
133 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, in alc_write_gpio_data()
138 void alc_update_gpio_data(struct hda_codec *codec, unsigned int mask, in alc_update_gpio_data() argument
141 struct alc_spec *spec = codec->spec; in alc_update_gpio_data()
149 alc_write_gpio_data(codec); in alc_update_gpio_data()
153 void alc_write_gpio(struct hda_codec *codec) in alc_write_gpio() argument
155 struct alc_spec *spec = codec->spec; in alc_write_gpio()
160 snd_hda_codec_write(codec, codec->core.afg, 0, in alc_write_gpio()
162 snd_hda_codec_write(codec, codec->core.afg, 0, in alc_write_gpio()
166 alc_write_gpio_data(codec); in alc_write_gpio()
170 void alc_fixup_gpio(struct hda_codec *codec, int action, unsigned int mask) in alc_fixup_gpio() argument
173 alc_setup_gpio(codec, mask); in alc_fixup_gpio()
177 void alc_fixup_gpio1(struct hda_codec *codec, in alc_fixup_gpio1() argument
180 alc_fixup_gpio(codec, action, 0x01); in alc_fixup_gpio1()
184 void alc_fixup_gpio2(struct hda_codec *codec, in alc_fixup_gpio2() argument
187 alc_fixup_gpio(codec, action, 0x02); in alc_fixup_gpio2()
191 void alc_fixup_gpio3(struct hda_codec *codec, in alc_fixup_gpio3() argument
194 alc_fixup_gpio(codec, action, 0x03); in alc_fixup_gpio3()
198 void alc_fixup_gpio4(struct hda_codec *codec, in alc_fixup_gpio4() argument
201 alc_fixup_gpio(codec, action, 0x04); in alc_fixup_gpio4()
205 void alc_fixup_micmute_led(struct hda_codec *codec, in alc_fixup_micmute_led() argument
209 snd_hda_gen_add_micmute_led_cdev(codec, NULL); in alc_fixup_micmute_led()
218 void alc_fix_pll(struct hda_codec *codec) in alc_fix_pll() argument
220 struct alc_spec *spec = codec->spec; in alc_fix_pll()
223 alc_update_coefex_idx(codec, spec->pll_nid, spec->pll_coef_idx, in alc_fix_pll()
228 void alc_fix_pll_init(struct hda_codec *codec, hda_nid_t nid, in alc_fix_pll_init() argument
231 struct alc_spec *spec = codec->spec; in alc_fix_pll_init()
235 alc_fix_pll(codec); in alc_fix_pll_init()
240 void alc_update_knob_master(struct hda_codec *codec, in alc_update_knob_master() argument
247 kctl = snd_hda_find_mixer_ctl(codec, "Master Playback Volume"); in alc_update_knob_master()
253 val = snd_hda_codec_read(codec, jack->nid, 0, in alc_update_knob_master()
264 void alc_fill_eapd_coef(struct hda_codec *codec) in alc_fill_eapd_coef() argument
268 coef = alc_get_coef0(codec); in alc_fill_eapd_coef()
270 switch (codec->core.vendor_id) { in alc_fill_eapd_coef()
272 alc_update_coef_idx(codec, 0x7, 0, 1<<5); in alc_fill_eapd_coef()
276 alc_update_coef_idx(codec, 0x7, 0, 1<<13); in alc_fill_eapd_coef()
280 alc_update_coef_idx(codec, 0xd, 0, 1<<14); in alc_fill_eapd_coef()
282 alc_update_coef_idx(codec, 0x4, 1<<15, 0); in alc_fill_eapd_coef()
284 alc_update_coef_idx(codec, 0x10, 1<<9, 0); in alc_fill_eapd_coef()
290 alc_update_coef_idx(codec, 0x4, 1<<15, 0); in alc_fill_eapd_coef()
295 alc_update_coef_idx(codec, 0x67, 0xf000, 0x3000); in alc_fill_eapd_coef()
304 alc_update_coef_idx(codec, 0x36, 1<<13, 0); in alc_fill_eapd_coef()
317 alc_update_coef_idx(codec, 0x10, 1<<9, 0); in alc_fill_eapd_coef()
320 alc_update_coef_idx(codec, 0xe, 0, 1<<0); in alc_fill_eapd_coef()
323 alc_update_coef_idx(codec, 0x10, 1<<9, 0); in alc_fill_eapd_coef()
324 alc_write_coef_idx(codec, 0x8, 0x4ab7); in alc_fill_eapd_coef()
327 alc_update_coef_idx(codec, 0xa, 1<<13, 0); in alc_fill_eapd_coef()
331 alc_write_coef_idx(codec, 0x6e, 0x0c25); in alc_fill_eapd_coef()
338 alc_update_coef_idx(codec, 0x10, 1<<15, 0); in alc_fill_eapd_coef()
342 alc_update_coef_idx(codec, 0x4, 1<<10, 0); /* EAPD Ctrl */ in alc_fill_eapd_coef()
351 alc_update_coef_idx(codec, 0xd, 0, 1<<14); /* EAPD Ctrl */ in alc_fill_eapd_coef()
355 alc_update_coef_idx(codec, 0x19, 1<<13, 0); in alc_fill_eapd_coef()
358 alc_update_coef_idx(codec, 0x7, 3<<13, 0); in alc_fill_eapd_coef()
361 alc_update_coef_idx(codec, 0x4, 1<<10, 0); in alc_fill_eapd_coef()
365 alc_update_coef_idx(codec, 0x7, 1<<5, 0); in alc_fill_eapd_coef()
369 alc_update_coef_idx(codec, 0x7, 1<<5, 0); in alc_fill_eapd_coef()
376 alc_update_coef_idx(codec, 0x7, 1<<1, 0); in alc_fill_eapd_coef()
383 static void set_eapd(struct hda_codec *codec, hda_nid_t nid, int on) in set_eapd() argument
385 if (get_wcaps_type(get_wcaps(codec, nid)) != AC_WID_PIN) in set_eapd()
387 if (snd_hda_query_pin_caps(codec, nid) & AC_PINCAP_EAPD) in set_eapd()
388 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE, in set_eapd()
393 void alc_auto_setup_eapd(struct hda_codec *codec, bool on) in alc_auto_setup_eapd() argument
401 set_eapd(codec, *p, on); in alc_auto_setup_eapd()
406 int alc_find_ext_mic_pin(struct hda_codec *codec) in alc_find_ext_mic_pin() argument
408 struct alc_spec *spec = codec->spec; in alc_find_ext_mic_pin()
418 defcfg = snd_hda_codec_get_pincfg(codec, nid); in alc_find_ext_mic_pin()
428 void alc_headset_mic_no_shutup(struct hda_codec *codec) in alc_headset_mic_no_shutup() argument
431 int mic_pin = alc_find_ext_mic_pin(codec); in alc_headset_mic_no_shutup()
437 if (codec->bus->shutdown) in alc_headset_mic_no_shutup()
440 snd_array_for_each(&codec->init_pins, i, pin) { in alc_headset_mic_no_shutup()
443 snd_hda_codec_read(codec, pin->nid, 0, in alc_headset_mic_no_shutup()
447 codec->pins_shutup = 1; in alc_headset_mic_no_shutup()
451 void alc_shutup_pins(struct hda_codec *codec) in alc_shutup_pins() argument
453 struct alc_spec *spec = codec->spec; in alc_shutup_pins()
458 switch (codec->core.vendor_id) { in alc_shutup_pins()
470 alc_headset_mic_no_shutup(codec); in alc_shutup_pins()
473 snd_hda_shutup_pins(codec); in alc_shutup_pins()
482 void alc_eapd_shutup(struct hda_codec *codec) in alc_eapd_shutup() argument
484 struct alc_spec *spec = codec->spec; in alc_eapd_shutup()
486 alc_auto_setup_eapd(codec, false); in alc_eapd_shutup()
489 alc_shutup_pins(codec); in alc_eapd_shutup()
494 static void alc888_coef_init(struct hda_codec *codec) in alc888_coef_init() argument
496 switch (alc_get_coef0(codec) & 0x00f0) { in alc888_coef_init()
501 alc_update_coef_idx(codec, 7, 0, 0x2030); /* Turn EAPD to High */ in alc888_coef_init()
507 void alc_auto_init_amp(struct hda_codec *codec, int type) in alc_auto_init_amp() argument
509 alc_auto_setup_eapd(codec, true); in alc_auto_init_amp()
510 alc_write_gpio(codec); in alc_auto_init_amp()
513 switch (codec->core.vendor_id) { in alc_auto_init_amp()
515 alc_update_coefex_idx(codec, 0x1a, 7, 0, 0x2010); in alc_auto_init_amp()
521 alc_update_coef_idx(codec, 7, 0, 0x2030); in alc_auto_init_amp()
524 alc888_coef_init(codec); in alc_auto_init_amp()
552 void alc_fixup_sku_ignore(struct hda_codec *codec, in alc_fixup_sku_ignore() argument
555 struct alc_spec *spec = codec->spec; in alc_fixup_sku_ignore()
563 void alc_fixup_no_depop_delay(struct hda_codec *codec, in alc_fixup_no_depop_delay() argument
566 struct alc_spec *spec = codec->spec; in alc_fixup_no_depop_delay()
570 codec->depop_delay = 0; in alc_fixup_no_depop_delay()
575 int alc_auto_parse_customize_define(struct hda_codec *codec) in alc_auto_parse_customize_define() argument
579 struct alc_spec *spec = codec->spec; in alc_auto_parse_customize_define()
590 if (!codec->bus->pci) in alc_auto_parse_customize_define()
592 ass = codec->core.subsystem_id & 0xffff; in alc_auto_parse_customize_define()
593 if (ass != codec->bus->pci->subsystem_device && (ass & 1)) in alc_auto_parse_customize_define()
597 if (codec->core.vendor_id == 0x10ec0260) in alc_auto_parse_customize_define()
599 ass = snd_hda_codec_get_pincfg(codec, nid); in alc_auto_parse_customize_define()
602 codec_info(codec, "%s: SKU not ready 0x%08x\n", in alc_auto_parse_customize_define()
603 codec->core.chip_name, ass); in alc_auto_parse_customize_define()
627 codec_dbg(codec, "SKU: Nid=0x%x sku_cfg=0x%08x\n", in alc_auto_parse_customize_define()
629 codec_dbg(codec, "SKU: port_connectivity=0x%x\n", in alc_auto_parse_customize_define()
631 codec_dbg(codec, "SKU: enable_pcbeep=0x%x\n", spec->cdefine.enable_pcbeep); in alc_auto_parse_customize_define()
632 codec_dbg(codec, "SKU: check_sum=0x%08x\n", spec->cdefine.check_sum); in alc_auto_parse_customize_define()
633 codec_dbg(codec, "SKU: customization=0x%08x\n", spec->cdefine.customization); in alc_auto_parse_customize_define()
634 codec_dbg(codec, "SKU: external_amp=0x%x\n", spec->cdefine.external_amp); in alc_auto_parse_customize_define()
635 codec_dbg(codec, "SKU: platform_type=0x%x\n", spec->cdefine.platform_type); in alc_auto_parse_customize_define()
636 codec_dbg(codec, "SKU: swap=0x%x\n", spec->cdefine.swap); in alc_auto_parse_customize_define()
637 codec_dbg(codec, "SKU: override=0x%x\n", spec->cdefine.override); in alc_auto_parse_customize_define()
667 int alc_subsystem_id(struct hda_codec *codec, const hda_nid_t *ports) in alc_subsystem_id() argument
671 struct alc_spec *spec = codec->spec; in alc_subsystem_id()
680 ass = codec->core.subsystem_id & 0xffff; in alc_subsystem_id()
681 if (codec->bus->pci && in alc_subsystem_id()
682 ass != codec->bus->pci->subsystem_device && (ass & 1)) in alc_subsystem_id()
695 if (codec->core.vendor_id == 0x10ec0260) in alc_subsystem_id()
697 ass = snd_hda_codec_get_pincfg(codec, nid); in alc_subsystem_id()
698 codec_dbg(codec, in alc_subsystem_id()
715 codec_dbg(codec, "realtek: Enabling init ASM_ID=0x%04x CODEC_ID=%08x\n", in alc_subsystem_id()
716 ass & 0xffff, codec->core.vendor_id); in alc_subsystem_id()
728 alc_setup_gpio(codec, 0x01); in alc_subsystem_id()
731 alc_setup_gpio(codec, 0x02); in alc_subsystem_id()
734 alc_setup_gpio(codec, 0x04); in alc_subsystem_id()
770 void alc_ssid_check(struct hda_codec *codec, const hda_nid_t *ports) in alc_ssid_check() argument
772 if (!alc_subsystem_id(codec, ports)) { in alc_ssid_check()
773 struct alc_spec *spec = codec->spec; in alc_ssid_check()
775 codec_dbg(codec, in alc_ssid_check()
784 void alc_fixup_inv_dmic(struct hda_codec *codec, in alc_fixup_inv_dmic() argument
787 struct alc_spec *spec = codec->spec; in alc_fixup_inv_dmic()
793 int alc_build_controls(struct hda_codec *codec) in alc_build_controls() argument
797 err = snd_hda_gen_build_controls(codec); in alc_build_controls()
801 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_BUILD); in alc_build_controls()
806 int alc_init(struct hda_codec *codec) in alc_init() argument
808 struct alc_spec *spec = codec->spec; in alc_init()
811 if (is_s4_resume(codec)) in alc_init()
812 alc_pre_init(codec); in alc_init()
815 spec->init_hook(codec); in alc_init()
818 snd_hda_gen_init(codec); in alc_init()
819 alc_fix_pll(codec); in alc_init()
820 alc_auto_init_amp(codec, spec->init_amp); in alc_init()
821 snd_hda_apply_verbs(codec); /* apply verbs here after own init */ in alc_init()
823 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_INIT); in alc_init()
829 void alc_shutup(struct hda_codec *codec) in alc_shutup() argument
831 struct alc_spec *spec = codec->spec; in alc_shutup()
833 if (!snd_hda_get_bool_hint(codec, "shutup")) in alc_shutup()
837 spec->shutup(codec); in alc_shutup()
839 alc_shutup_pins(codec); in alc_shutup()
843 void alc_power_eapd(struct hda_codec *codec) in alc_power_eapd() argument
845 alc_auto_setup_eapd(codec, false); in alc_power_eapd()
849 int alc_suspend(struct hda_codec *codec) in alc_suspend() argument
851 struct alc_spec *spec = codec->spec; in alc_suspend()
852 alc_shutup(codec); in alc_suspend()
854 spec->power_hook(codec); in alc_suspend()
859 int alc_resume(struct hda_codec *codec) in alc_resume() argument
861 struct alc_spec *spec = codec->spec; in alc_resume()
865 snd_hda_codec_init(codec); in alc_resume()
866 snd_hda_regmap_sync(codec); in alc_resume()
867 hda_call_check_power_status(codec, 0x01); in alc_resume()
942 static int alc_codec_rename_from_preset(struct hda_codec *codec) in alc_codec_rename_from_preset() argument
948 if (p->vendor_id != codec->core.vendor_id) in alc_codec_rename_from_preset()
950 if ((alc_get_coef0(codec) & p->coef_mask) == p->coef_bits) in alc_codec_rename_from_preset()
951 return alc_codec_rename(codec, p->name); in alc_codec_rename_from_preset()
954 if (!codec->bus->pci) in alc_codec_rename_from_preset()
957 if (q->codec_vendor_id != codec->core.vendor_id) in alc_codec_rename_from_preset()
959 if (q->pci_subvendor != codec->bus->pci->subsystem_vendor) in alc_codec_rename_from_preset()
962 q->pci_subdevice == codec->bus->pci->subsystem_device) in alc_codec_rename_from_preset()
963 return alc_codec_rename(codec, q->name); in alc_codec_rename_from_preset()
1014 int alc_has_cdefine_beep(struct hda_codec *codec) in alc_has_cdefine_beep() argument
1016 struct alc_spec *spec = codec->spec; in alc_has_cdefine_beep()
1018 q = snd_pci_quirk_lookup(codec->bus->pci, beep_allow_list); in alc_has_cdefine_beep()
1031 int alc_parse_auto_config(struct hda_codec *codec, in alc_parse_auto_config() argument
1035 struct alc_spec *spec = codec->spec; in alc_parse_auto_config()
1039 err = snd_hda_parse_pin_defcfg(codec, cfg, ignore_nids, in alc_parse_auto_config()
1045 alc_ssid_check(codec, ssid_nids); in alc_parse_auto_config()
1047 err = snd_hda_gen_parse_auto_config(codec, cfg); in alc_parse_auto_config()
1056 int alc_alloc_spec(struct hda_codec *codec, hda_nid_t mixer_nid) in alc_alloc_spec() argument
1063 codec->spec = spec; in alc_alloc_spec()
1067 codec->single_adc_amp = 1; in alc_alloc_spec()
1069 codec->spdif_status_reset = 1; in alc_alloc_spec()
1070 codec->forced_resume = 1; in alc_alloc_spec()
1073 err = alc_codec_rename_from_preset(codec); in alc_alloc_spec()
1085 void alc_fixup_dual_codecs(struct hda_codec *codec, in alc_fixup_dual_codecs() argument
1088 struct alc_spec *spec = codec->spec; in alc_fixup_dual_codecs()
1100 codec->force_pin_prefix = 1; in alc_fixup_dual_codecs()
1114 void alc_fixup_bass_chmap(struct hda_codec *codec, in alc_fixup_bass_chmap() argument
1118 struct alc_spec *spec = codec->spec; in alc_fixup_bass_chmap()
1125 void alc1220_fixup_gb_dual_codecs(struct hda_codec *codec, in alc1220_fixup_gb_dual_codecs() argument
1129 alc_fixup_dual_codecs(codec, fix, action); in alc1220_fixup_gb_dual_codecs()
1133 strscpy(codec->card->longname, "HDAudio-Gigabyte-ALC1220DualCodecs"); in alc1220_fixup_gb_dual_codecs()
1137 rename_ctl(codec, "Capture Volume", in alc1220_fixup_gb_dual_codecs()
1138 codec->addr == 0 ? in alc1220_fixup_gb_dual_codecs()
1141 rename_ctl(codec, "Capture Switch", in alc1220_fixup_gb_dual_codecs()
1142 codec->addr == 0 ? in alc1220_fixup_gb_dual_codecs()
1150 void alc233_alc662_fixup_lenovo_dual_codecs(struct hda_codec *codec, in alc233_alc662_fixup_lenovo_dual_codecs() argument
1154 alc_fixup_dual_codecs(codec, fix, action); in alc233_alc662_fixup_lenovo_dual_codecs()
1158 strscpy(codec->card->longname, "HDAudio-Lenovo-DualCodecs"); in alc233_alc662_fixup_lenovo_dual_codecs()
1162 rename_ctl(codec, "Capture Volume", in alc233_alc662_fixup_lenovo_dual_codecs()
1163 codec->addr == 0 ? in alc233_alc662_fixup_lenovo_dual_codecs()
1166 rename_ctl(codec, "Capture Switch", in alc233_alc662_fixup_lenovo_dual_codecs()
1167 codec->addr == 0 ? in alc233_alc662_fixup_lenovo_dual_codecs()
1175 static void alc_shutup_dell_xps13(struct hda_codec *codec) in alc_shutup_dell_xps13() argument
1177 struct alc_spec *spec = codec->spec; in alc_shutup_dell_xps13()
1181 snd_hda_codec_write(codec, hp_pin, 0, in alc_shutup_dell_xps13()
1186 void alc_fixup_dell_xps13(struct hda_codec *codec, in alc_fixup_dell_xps13() argument
1189 struct alc_spec *spec = codec->spec; in alc_fixup_dell_xps13()
1198 snd_hda_codec_set_pin_target(codec, 0x19, PIN_VREFHIZ); in alc_fixup_dell_xps13()
1218 static void alc_hp_mute_disable(struct hda_codec *codec, unsigned int delay) in alc_hp_mute_disable() argument
1222 snd_hda_codec_write(codec, 0x21, 0, in alc_hp_mute_disable()
1225 snd_hda_codec_write(codec, 0x21, 0, in alc_hp_mute_disable()
1230 static void alc_hp_enable_unmute(struct hda_codec *codec, unsigned int delay) in alc_hp_enable_unmute() argument
1234 snd_hda_codec_write(codec, 0x21, 0, in alc_hp_enable_unmute()
1237 snd_hda_codec_write(codec, 0x21, 0, in alc_hp_enable_unmute()
1253 static void alc_headset_mode_unplugged(struct hda_codec *codec) in alc_headset_mode_unplugged() argument
1255 struct alc_spec *spec = codec->spec; in alc_headset_mode_unplugged()
1331 alc_update_coef_idx(codec, 0x45, 0xf<<12 | 1<<10, 5<<12); in alc_headset_mode_unplugged()
1335 switch (codec->core.vendor_id) { in alc_headset_mode_unplugged()
1337 alc_process_coef_fw(codec, coef0255); in alc_headset_mode_unplugged()
1343 alc_hp_mute_disable(codec, 75); in alc_headset_mode_unplugged()
1344 alc_process_coef_fw(codec, coef0256); in alc_headset_mode_unplugged()
1349 alc_process_coef_fw(codec, coef0274); in alc_headset_mode_unplugged()
1353 alc_process_coef_fw(codec, coef0233); in alc_headset_mode_unplugged()
1357 alc_process_coef_fw(codec, coef0288); in alc_headset_mode_unplugged()
1360 alc_process_coef_fw(codec, coef0298); in alc_headset_mode_unplugged()
1361 alc_process_coef_fw(codec, coef0288); in alc_headset_mode_unplugged()
1364 alc_process_coef_fw(codec, coef0292); in alc_headset_mode_unplugged()
1367 alc_process_coef_fw(codec, coef0293); in alc_headset_mode_unplugged()
1370 alc_process_coef_fw(codec, coef0668); in alc_headset_mode_unplugged()
1378 alc_hp_mute_disable(codec, 75); in alc_headset_mode_unplugged()
1379 alc_process_coef_fw(codec, alc225_pre_hsmode); in alc_headset_mode_unplugged()
1380 alc_process_coef_fw(codec, coef0225); in alc_headset_mode_unplugged()
1383 alc_update_coefex_idx(codec, 0x57, 0x5, 1<<14, 0); in alc_headset_mode_unplugged()
1386 codec_dbg(codec, "Headset jack set to unplugged mode.\n"); in alc_headset_mode_unplugged()
1390 static void alc_headset_mode_mic_in(struct hda_codec *codec, hda_nid_t hp_pin, in alc_headset_mode_mic_in() argument
1450 switch (codec->core.vendor_id) { in alc_headset_mode_mic_in()
1452 alc_write_coef_idx(codec, 0x45, 0xc489); in alc_headset_mode_mic_in()
1453 snd_hda_set_pin_ctl_cache(codec, hp_pin, 0); in alc_headset_mode_mic_in()
1454 alc_process_coef_fw(codec, coef0255); in alc_headset_mode_mic_in()
1455 snd_hda_set_pin_ctl_cache(codec, mic_pin, PIN_VREF50); in alc_headset_mode_mic_in()
1461 alc_write_coef_idx(codec, 0x45, 0xc489); in alc_headset_mode_mic_in()
1462 snd_hda_set_pin_ctl_cache(codec, hp_pin, 0); in alc_headset_mode_mic_in()
1463 alc_process_coef_fw(codec, coef0256); in alc_headset_mode_mic_in()
1464 snd_hda_set_pin_ctl_cache(codec, mic_pin, PIN_VREF50); in alc_headset_mode_mic_in()
1469 alc_write_coef_idx(codec, 0x45, 0x4689); in alc_headset_mode_mic_in()
1470 snd_hda_set_pin_ctl_cache(codec, hp_pin, 0); in alc_headset_mode_mic_in()
1471 alc_process_coef_fw(codec, coef0274); in alc_headset_mode_mic_in()
1472 snd_hda_set_pin_ctl_cache(codec, mic_pin, PIN_VREF50); in alc_headset_mode_mic_in()
1476 alc_write_coef_idx(codec, 0x45, 0xc429); in alc_headset_mode_mic_in()
1477 snd_hda_set_pin_ctl_cache(codec, hp_pin, 0); in alc_headset_mode_mic_in()
1478 alc_process_coef_fw(codec, coef0233); in alc_headset_mode_mic_in()
1479 snd_hda_set_pin_ctl_cache(codec, mic_pin, PIN_VREF50); in alc_headset_mode_mic_in()
1484 snd_hda_set_pin_ctl_cache(codec, hp_pin, 0); in alc_headset_mode_mic_in()
1485 alc_process_coef_fw(codec, coef0288); in alc_headset_mode_mic_in()
1486 snd_hda_set_pin_ctl_cache(codec, mic_pin, PIN_VREF50); in alc_headset_mode_mic_in()
1489 snd_hda_set_pin_ctl_cache(codec, hp_pin, 0); in alc_headset_mode_mic_in()
1490 alc_process_coef_fw(codec, coef0292); in alc_headset_mode_mic_in()
1494 alc_write_coef_idx(codec, 0x45, 0xc429); in alc_headset_mode_mic_in()
1495 snd_hda_set_pin_ctl_cache(codec, hp_pin, 0); in alc_headset_mode_mic_in()
1496 alc_process_coef_fw(codec, coef0293); in alc_headset_mode_mic_in()
1497 snd_hda_set_pin_ctl_cache(codec, mic_pin, PIN_VREF50); in alc_headset_mode_mic_in()
1500 alc_update_coefex_idx(codec, 0x57, 0x5, 0, 1<<14); in alc_headset_mode_mic_in()
1504 snd_hda_set_pin_ctl_cache(codec, hp_pin, 0); in alc_headset_mode_mic_in()
1505 snd_hda_set_pin_ctl_cache(codec, mic_pin, PIN_VREF50); in alc_headset_mode_mic_in()
1508 alc_write_coef_idx(codec, 0x11, 0x0001); in alc_headset_mode_mic_in()
1509 snd_hda_set_pin_ctl_cache(codec, hp_pin, 0); in alc_headset_mode_mic_in()
1510 alc_process_coef_fw(codec, coef0688); in alc_headset_mode_mic_in()
1511 snd_hda_set_pin_ctl_cache(codec, mic_pin, PIN_VREF50); in alc_headset_mode_mic_in()
1519 alc_process_coef_fw(codec, alc225_pre_hsmode); in alc_headset_mode_mic_in()
1520 alc_update_coef_idx(codec, 0x45, 0x3f<<10, 0x31<<10); in alc_headset_mode_mic_in()
1521 snd_hda_set_pin_ctl_cache(codec, hp_pin, 0); in alc_headset_mode_mic_in()
1522 alc_process_coef_fw(codec, coef0225); in alc_headset_mode_mic_in()
1523 snd_hda_set_pin_ctl_cache(codec, mic_pin, PIN_VREF50); in alc_headset_mode_mic_in()
1526 codec_dbg(codec, "Headset jack set to mic-in mode.\n"); in alc_headset_mode_mic_in()
1529 static void alc_headset_mode_default(struct hda_codec *codec) in alc_headset_mode_default() argument
1595 switch (codec->core.vendor_id) { in alc_headset_mode_default()
1602 alc_process_coef_fw(codec, alc225_pre_hsmode); in alc_headset_mode_default()
1603 alc_process_coef_fw(codec, coef0225); in alc_headset_mode_default()
1604 alc_hp_enable_unmute(codec, 75); in alc_headset_mode_default()
1607 alc_process_coef_fw(codec, coef0255); in alc_headset_mode_default()
1613 alc_write_coef_idx(codec, 0x1b, 0x0e4b); in alc_headset_mode_default()
1614 alc_write_coef_idx(codec, 0x45, 0xc089); in alc_headset_mode_default()
1616 alc_process_coef_fw(codec, coef0256); in alc_headset_mode_default()
1617 alc_hp_enable_unmute(codec, 75); in alc_headset_mode_default()
1622 alc_process_coef_fw(codec, coef0274); in alc_headset_mode_default()
1626 alc_process_coef_fw(codec, coef0233); in alc_headset_mode_default()
1631 alc_process_coef_fw(codec, coef0288); in alc_headset_mode_default()
1634 alc_process_coef_fw(codec, coef0292); in alc_headset_mode_default()
1637 alc_process_coef_fw(codec, coef0293); in alc_headset_mode_default()
1640 alc_process_coef_fw(codec, coef0688); in alc_headset_mode_default()
1643 alc_update_coefex_idx(codec, 0x57, 0x5, 1<<14, 0); in alc_headset_mode_default()
1646 codec_dbg(codec, "Headset jack set to headphone (default) mode.\n"); in alc_headset_mode_default()
1650 static void alc_headset_mode_ctia(struct hda_codec *codec) in alc_headset_mode_ctia() argument
1706 switch (codec->core.vendor_id) { in alc_headset_mode_ctia()
1708 alc_process_coef_fw(codec, coef0255); in alc_headset_mode_ctia()
1714 alc_process_coef_fw(codec, coef0256); in alc_headset_mode_ctia()
1715 alc_hp_enable_unmute(codec, 75); in alc_headset_mode_ctia()
1720 alc_write_coef_idx(codec, 0x45, 0xd689); in alc_headset_mode_ctia()
1724 alc_process_coef_fw(codec, coef0233); in alc_headset_mode_ctia()
1727 val = alc_read_coef_idx(codec, 0x50); in alc_headset_mode_ctia()
1729 alc_update_coef_idx(codec, 0x8e, 0x0070, 0x0020); in alc_headset_mode_ctia()
1730 alc_update_coef_idx(codec, 0x4f, 0xfcc0, 0xd400); in alc_headset_mode_ctia()
1733 alc_update_coef_idx(codec, 0x8e, 0x0070, 0x0010); in alc_headset_mode_ctia()
1734 alc_update_coef_idx(codec, 0x4f, 0xfcc0, 0xd400); in alc_headset_mode_ctia()
1740 alc_update_coef_idx(codec, 0x4f, 0xfcc0, 0xd400); in alc_headset_mode_ctia()
1742 alc_process_coef_fw(codec, coef0288); in alc_headset_mode_ctia()
1745 alc_process_coef_fw(codec, coef0292); in alc_headset_mode_ctia()
1748 alc_process_coef_fw(codec, coef0293); in alc_headset_mode_ctia()
1751 alc_process_coef_fw(codec, coef0688); in alc_headset_mode_ctia()
1759 val = alc_read_coef_idx(codec, 0x45); in alc_headset_mode_ctia()
1761 alc_process_coef_fw(codec, coef0225_2); in alc_headset_mode_ctia()
1763 alc_process_coef_fw(codec, coef0225_1); in alc_headset_mode_ctia()
1764 alc_hp_enable_unmute(codec, 75); in alc_headset_mode_ctia()
1767 alc_update_coefex_idx(codec, 0x57, 0x5, 1<<14, 0); in alc_headset_mode_ctia()
1770 codec_dbg(codec, "Headset jack set to iPhone-style headset mode.\n"); in alc_headset_mode_ctia()
1774 static void alc_headset_mode_omtp(struct hda_codec *codec) in alc_headset_mode_omtp() argument
1823 switch (codec->core.vendor_id) { in alc_headset_mode_omtp()
1825 alc_process_coef_fw(codec, coef0255); in alc_headset_mode_omtp()
1831 alc_process_coef_fw(codec, coef0256); in alc_headset_mode_omtp()
1832 alc_hp_enable_unmute(codec, 75); in alc_headset_mode_omtp()
1837 alc_write_coef_idx(codec, 0x45, 0xe689); in alc_headset_mode_omtp()
1841 alc_process_coef_fw(codec, coef0233); in alc_headset_mode_omtp()
1844 alc_update_coef_idx(codec, 0x8e, 0x0070, 0x0010);/* Headset output enable */ in alc_headset_mode_omtp()
1845 alc_update_coef_idx(codec, 0x4f, 0xfcc0, 0xe400); in alc_headset_mode_omtp()
1850 alc_update_coef_idx(codec, 0x4f, 0xfcc0, 0xe400); in alc_headset_mode_omtp()
1852 alc_process_coef_fw(codec, coef0288); in alc_headset_mode_omtp()
1855 alc_process_coef_fw(codec, coef0292); in alc_headset_mode_omtp()
1858 alc_process_coef_fw(codec, coef0293); in alc_headset_mode_omtp()
1861 alc_process_coef_fw(codec, coef0688); in alc_headset_mode_omtp()
1869 alc_process_coef_fw(codec, coef0225); in alc_headset_mode_omtp()
1870 alc_hp_enable_unmute(codec, 75); in alc_headset_mode_omtp()
1873 codec_dbg(codec, "Headset jack set to Nokia-style headset mode.\n"); in alc_headset_mode_omtp()
1876 static void alc_determine_headset_type(struct hda_codec *codec) in alc_determine_headset_type() argument
1880 struct alc_spec *spec = codec->spec; in alc_determine_headset_type()
1920 alc_update_coef_idx(codec, 0x45, 0xf<<12 | 1<<10, 5<<12); in alc_determine_headset_type()
1924 switch (codec->core.vendor_id) { in alc_determine_headset_type()
1926 alc_process_coef_fw(codec, coef0255); in alc_determine_headset_type()
1928 val = alc_read_coef_idx(codec, 0x46); in alc_determine_headset_type()
1935 alc_write_coef_idx(codec, 0x1b, 0x0e4b); in alc_determine_headset_type()
1936 alc_write_coef_idx(codec, 0x06, 0x6104); in alc_determine_headset_type()
1937 alc_write_coefex_idx(codec, 0x57, 0x3, 0x09a3); in alc_determine_headset_type()
1939 alc_process_coef_fw(codec, coef0255); in alc_determine_headset_type()
1941 val = alc_read_coef_idx(codec, 0x46); in alc_determine_headset_type()
1944 alc_write_coef_idx(codec, 0x45, 0xe089); in alc_determine_headset_type()
1946 val = alc_read_coef_idx(codec, 0x46); in alc_determine_headset_type()
1952 alc_write_coefex_idx(codec, 0x57, 0x3, 0x0da3); in alc_determine_headset_type()
1953 alc_update_coefex_idx(codec, 0x57, 0x5, 1<<14, 0); in alc_determine_headset_type()
1958 alc_process_coef_fw(codec, coef0274); in alc_determine_headset_type()
1960 val = alc_read_coef_idx(codec, 0x46); in alc_determine_headset_type()
1965 alc_write_coef_idx(codec, 0x45, 0xd029); in alc_determine_headset_type()
1967 val = alc_read_coef_idx(codec, 0x46); in alc_determine_headset_type()
1971 snd_hda_codec_write(codec, 0x21, 0, in alc_determine_headset_type()
1974 snd_hda_codec_write(codec, 0x21, 0, in alc_determine_headset_type()
1978 val = alc_read_coef_idx(codec, 0x50); in alc_determine_headset_type()
1980 alc_update_coef_idx(codec, 0x8e, 0x0070, 0x0020); in alc_determine_headset_type()
1981 alc_process_coef_fw(codec, coef0288); in alc_determine_headset_type()
1983 val = alc_read_coef_idx(codec, 0x50); in alc_determine_headset_type()
1986 alc_update_coef_idx(codec, 0x8e, 0x0070, 0x0010); in alc_determine_headset_type()
1987 alc_process_coef_fw(codec, coef0288); in alc_determine_headset_type()
1989 val = alc_read_coef_idx(codec, 0x50); in alc_determine_headset_type()
1992 alc_process_coef_fw(codec, coef0298); in alc_determine_headset_type()
1993 snd_hda_codec_write(codec, 0x21, 0, in alc_determine_headset_type()
1996 snd_hda_codec_write(codec, 0x21, 0, in alc_determine_headset_type()
2001 alc_process_coef_fw(codec, coef0288); in alc_determine_headset_type()
2003 val = alc_read_coef_idx(codec, 0x50); in alc_determine_headset_type()
2007 alc_write_coef_idx(codec, 0x6b, 0xd429); in alc_determine_headset_type()
2009 val = alc_read_coef_idx(codec, 0x6c); in alc_determine_headset_type()
2013 alc_process_coef_fw(codec, coef0293); in alc_determine_headset_type()
2015 val = alc_read_coef_idx(codec, 0x46); in alc_determine_headset_type()
2019 alc_process_coef_fw(codec, coef0688); in alc_determine_headset_type()
2021 val = alc_read_coef_idx(codec, 0xbe); in alc_determine_headset_type()
2030 alc_process_coef_fw(codec, alc225_pre_hsmode); in alc_determine_headset_type()
2031 alc_update_coef_idx(codec, 0x67, 0xf000, 0x1000); in alc_determine_headset_type()
2032 val = alc_read_coef_idx(codec, 0x45); in alc_determine_headset_type()
2034 alc_update_coef_idx(codec, 0x45, 0x3f<<10, 0x34<<10); in alc_determine_headset_type()
2035 alc_update_coef_idx(codec, 0x49, 3<<8, 2<<8); in alc_determine_headset_type()
2037 val = alc_read_coef_idx(codec, 0x46); in alc_determine_headset_type()
2040 alc_update_coef_idx(codec, 0x45, 0x3f<<10, 0x34<<10); in alc_determine_headset_type()
2041 alc_update_coef_idx(codec, 0x49, 3<<8, 1<<8); in alc_determine_headset_type()
2043 val = alc_read_coef_idx(codec, 0x46); in alc_determine_headset_type()
2047 alc_update_coef_idx(codec, 0x45, 0x3f<<10, 0x38<<10); in alc_determine_headset_type()
2048 alc_update_coef_idx(codec, 0x49, 3<<8, 1<<8); in alc_determine_headset_type()
2050 val = alc_read_coef_idx(codec, 0x46); in alc_determine_headset_type()
2056 alc_update_coef_idx(codec, 0x4a, 7<<6, 7<<6); in alc_determine_headset_type()
2057 alc_update_coef_idx(codec, 0x4a, 3<<4, 3<<4); in alc_determine_headset_type()
2058 alc_update_coef_idx(codec, 0x67, 0xf000, 0x3000); in alc_determine_headset_type()
2065 codec_dbg(codec, "Headset jack detected iPhone-style headset: %s\n", in alc_determine_headset_type()
2070 static void alc_update_headset_mode(struct hda_codec *codec) in alc_update_headset_mode() argument
2072 struct alc_spec *spec = codec->spec; in alc_update_headset_mode()
2079 if (!snd_hda_jack_detect(codec, hp_pin)) in alc_update_headset_mode()
2089 snd_hda_gen_update_outputs(codec); in alc_update_headset_mode()
2095 alc_headset_mode_unplugged(codec); in alc_update_headset_mode()
2102 alc_determine_headset_type(codec); in alc_update_headset_mode()
2104 alc_headset_mode_ctia(codec); in alc_update_headset_mode()
2106 alc_headset_mode_omtp(codec); in alc_update_headset_mode()
2110 alc_headset_mode_mic_in(codec, hp_pin, spec->headphone_mic_pin); in alc_update_headset_mode()
2114 alc_headset_mode_default(codec); in alc_update_headset_mode()
2119 snd_hda_set_pin_ctl_cache(codec, hp_pin, in alc_update_headset_mode()
2122 snd_hda_set_pin_ctl_cache(codec, spec->headphone_mic_pin, in alc_update_headset_mode()
2127 snd_hda_gen_update_outputs(codec); in alc_update_headset_mode()
2130 static void alc_update_headset_mode_hook(struct hda_codec *codec, in alc_update_headset_mode_hook() argument
2134 alc_update_headset_mode(codec); in alc_update_headset_mode_hook()
2137 void alc_update_headset_jack_cb(struct hda_codec *codec, in alc_update_headset_jack_cb() argument
2140 snd_hda_gen_hp_automute(codec, jack); in alc_update_headset_jack_cb()
2141 alc_update_headset_mode(codec); in alc_update_headset_jack_cb()
2145 static void alc_probe_headset_mode(struct hda_codec *codec) in alc_probe_headset_mode() argument
2148 struct alc_spec *spec = codec->spec; in alc_probe_headset_mode()
2165 void alc_fixup_headset_mode(struct hda_codec *codec, in alc_fixup_headset_mode() argument
2168 struct alc_spec *spec = codec->spec; in alc_fixup_headset_mode()
2175 alc_probe_headset_mode(codec); in alc_fixup_headset_mode()
2178 if (is_s3_resume(codec) || is_s4_resume(codec)) { in alc_fixup_headset_mode()
2182 alc_update_headset_mode(codec); in alc_fixup_headset_mode()
2188 void alc_fixup_headset_mode_no_hp_mic(struct hda_codec *codec, in alc_fixup_headset_mode_no_hp_mic() argument
2192 struct alc_spec *spec = codec->spec; in alc_fixup_headset_mode_no_hp_mic()
2196 alc_fixup_headset_mode(codec, fix, action); in alc_fixup_headset_mode_no_hp_mic()
2200 void alc_fixup_headset_mic(struct hda_codec *codec, in alc_fixup_headset_mic() argument
2203 struct alc_spec *spec = codec->spec; in alc_fixup_headset_mic()
2211 void alc_update_gpio_led(struct hda_codec *codec, unsigned int mask, in alc_update_gpio_led() argument
2216 alc_update_gpio_data(codec, mask, !enabled); /* muted -> LED on */ in alc_update_gpio_led()
2224 struct hda_codec *codec = dev_to_hda_codec(led_cdev->dev->parent); in micmute_led_set() local
2225 struct alc_spec *spec = codec->spec; in micmute_led_set()
2227 alc_update_gpio_led(codec, spec->gpio_mic_led_mask, in micmute_led_set()
2236 struct hda_codec *codec = dev_to_hda_codec(led_cdev->dev->parent); in gpio_mute_led_set() local
2237 struct alc_spec *spec = codec->spec; in gpio_mute_led_set()
2239 alc_update_gpio_led(codec, spec->gpio_mute_led_mask, in gpio_mute_led_set()
2245 void alc_fixup_hp_gpio_led(struct hda_codec *codec, in alc_fixup_hp_gpio_led() argument
2250 struct alc_spec *spec = codec->spec; in alc_fixup_hp_gpio_led()
2252 alc_fixup_gpio(codec, action, mute_mask | micmute_mask); in alc_fixup_hp_gpio_led()
2258 snd_hda_gen_add_mute_led_cdev(codec, gpio_mute_led_set); in alc_fixup_hp_gpio_led()
2262 snd_hda_gen_add_micmute_led_cdev(codec, micmute_led_set); in alc_fixup_hp_gpio_led()
2268 void alc_fixup_no_jack_detect(struct hda_codec *codec, in alc_fixup_no_jack_detect() argument
2272 codec->no_jack_detect = 1; in alc_fixup_no_jack_detect()
2276 void alc_fixup_disable_aamix(struct hda_codec *codec, in alc_fixup_disable_aamix() argument
2280 struct alc_spec *spec = codec->spec; in alc_fixup_disable_aamix()
2287 void alc_fixup_auto_mute_via_amp(struct hda_codec *codec, in alc_fixup_auto_mute_via_amp() argument
2291 struct alc_spec *spec = codec->spec; in alc_fixup_auto_mute_via_amp()