Lines Matching refs:codec
114 static enum VIA_HDA_CODEC get_codec_type(struct hda_codec *codec);
116 struct hda_codec *codec,
120 static struct via_spec *via_new_spec(struct hda_codec *codec) in via_new_spec() argument
128 codec->spec = spec; in via_new_spec()
130 spec->codec_type = get_codec_type(codec); in via_new_spec()
138 codec->power_save_node = 1; in via_new_spec()
143 static enum VIA_HDA_CODEC get_codec_type(struct hda_codec *codec) in get_codec_type() argument
145 u32 vendor_id = codec->core.vendor_id; in get_codec_type()
161 if (snd_hda_param_read(codec, 0x16, AC_PAR_CONNLIST_LEN) == 0x7) in get_codec_type()
195 static void analog_low_current_mode(struct hda_codec *codec);
196 static bool is_aa_path_mute(struct hda_codec *codec);
198 #define hp_detect_with_aa(codec) \ argument
199 (snd_hda_get_bool_hint(codec, "analog_loopback_hp_detect") == 1 && \
200 !is_aa_path_mute(codec))
202 static void vt1708_stop_hp_work(struct hda_codec *codec) in vt1708_stop_hp_work() argument
204 struct via_spec *spec = codec->spec; in vt1708_stop_hp_work()
208 snd_hda_codec_write(codec, 0x1, 0, 0xf81, 1); in vt1708_stop_hp_work()
209 codec->jackpoll_interval = 0; in vt1708_stop_hp_work()
210 cancel_delayed_work_sync(&codec->jackpoll_work); in vt1708_stop_hp_work()
215 static void vt1708_update_hp_work(struct hda_codec *codec) in vt1708_update_hp_work() argument
217 struct via_spec *spec = codec->spec; in vt1708_update_hp_work()
222 codec->jackpoll_interval = msecs_to_jiffies(100); in vt1708_update_hp_work()
223 snd_hda_codec_write(codec, 0x1, 0, 0xf81, 0); in vt1708_update_hp_work()
224 schedule_delayed_work(&codec->jackpoll_work, 0); in vt1708_update_hp_work()
227 } else if (!hp_detect_with_aa(codec)) in vt1708_update_hp_work()
228 vt1708_stop_hp_work(codec); in vt1708_update_hp_work()
240 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); in via_pin_power_ctl_get() local
241 struct via_spec *spec = codec->spec; in via_pin_power_ctl_get()
250 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); in via_pin_power_ctl_put() local
251 struct via_spec *spec = codec->spec; in via_pin_power_ctl_put()
258 analog_low_current_mode(codec); in via_pin_power_ctl_put()
289 static int add_beep_ctls(struct hda_codec *codec) in add_beep_ctls() argument
291 struct via_spec *spec = codec->spec; in add_beep_ctls()
298 kctl = snd_ctl_new1(knew, codec); in add_beep_ctls()
302 err = snd_hda_ctl_add(codec, 0, kctl); in add_beep_ctls()
310 static void auto_parse_beep(struct hda_codec *codec) in auto_parse_beep() argument
312 struct via_spec *spec = codec->spec; in auto_parse_beep()
315 for_each_hda_codec_node(nid, codec) in auto_parse_beep()
316 if (get_wcaps_type(get_wcaps(codec, nid)) == AC_WID_BEEP) { in auto_parse_beep()
323 #define add_beep_ctls(codec) 0 argument
324 #define auto_parse_beep(codec) argument
328 static bool is_aa_path_mute(struct hda_codec *codec) in is_aa_path_mute() argument
330 struct via_spec *spec = codec->spec; in is_aa_path_mute()
339 v = snd_hda_codec_amp_read(codec, p->nid, ch, p->dir, in is_aa_path_mute()
349 static void __analog_low_current_mode(struct hda_codec *codec, bool force) in __analog_low_current_mode() argument
351 struct via_spec *spec = codec->spec; in __analog_low_current_mode()
355 if (!codec->power_save_node) in __analog_low_current_mode()
358 enable = is_aa_path_mute(codec) && !spec->gen.active_streams; in __analog_low_current_mode()
395 snd_hda_codec_write(codec, codec->core.afg, 0, verb, parm); in __analog_low_current_mode()
398 static void analog_low_current_mode(struct hda_codec *codec) in analog_low_current_mode() argument
400 return __analog_low_current_mode(codec, false); in analog_low_current_mode()
403 static int via_build_controls(struct hda_codec *codec) in via_build_controls() argument
405 struct via_spec *spec = codec->spec; in via_build_controls()
408 err = snd_hda_gen_build_controls(codec); in via_build_controls()
412 err = add_beep_ctls(codec); in via_build_controls()
419 err = snd_hda_add_new_ctls(codec, spec->mixers[i]); in via_build_controls()
428 struct hda_codec *codec, in via_playback_pcm_hook() argument
432 analog_low_current_mode(codec); in via_playback_pcm_hook()
433 vt1708_update_hp_work(codec); in via_playback_pcm_hook()
436 static void via_free(struct hda_codec *codec) in via_free() argument
438 vt1708_stop_hp_work(codec); in via_free()
439 snd_hda_gen_free(codec); in via_free()
443 static int via_suspend(struct hda_codec *codec) in via_suspend() argument
445 struct via_spec *spec = codec->spec; in via_suspend()
446 vt1708_stop_hp_work(codec); in via_suspend()
450 snd_hda_shutup_pins(codec); in via_suspend()
455 static int via_resume(struct hda_codec *codec) in via_resume() argument
459 codec->patch_ops.init(codec); in via_resume()
460 regcache_sync(codec->core.regmap); in via_resume()
466 static int via_check_power_status(struct hda_codec *codec, hda_nid_t nid) in via_check_power_status() argument
468 struct via_spec *spec = codec->spec; in via_check_power_status()
469 analog_low_current_mode(codec); in via_check_power_status()
470 vt1708_update_hp_work(codec); in via_check_power_status()
471 return snd_hda_check_amp_list_power(codec, &spec->gen.loopback, nid); in via_check_power_status()
478 static int via_init(struct hda_codec *codec);
500 static void vt1708_set_pinconfig_connect(struct hda_codec *codec, hda_nid_t nid) in vt1708_set_pinconfig_connect() argument
505 def_conf = snd_hda_codec_get_pincfg(codec, nid); in vt1708_set_pinconfig_connect()
511 snd_hda_codec_set_pincfg(codec, nid, def_conf); in vt1708_set_pinconfig_connect()
520 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); in vt1708_jack_detect_get() local
521 struct via_spec *spec = codec->spec; in vt1708_jack_detect_get()
532 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); in vt1708_jack_detect_put() local
533 struct via_spec *spec = codec->spec; in vt1708_jack_detect_put()
542 vt1708_update_hp_work(codec); in vt1708_jack_detect_put()
575 static int via_parse_auto_config(struct hda_codec *codec) in via_parse_auto_config() argument
577 struct via_spec *spec = codec->spec; in via_parse_auto_config()
583 err = snd_hda_parse_pin_defcfg(codec, &spec->gen.autocfg, NULL, 0); in via_parse_auto_config()
587 auto_parse_beep(codec); in via_parse_auto_config()
589 err = snd_hda_gen_parse_auto_config(codec, &spec->gen.autocfg); in via_parse_auto_config()
594 codec->power_save_node = 0; in via_parse_auto_config()
599 static int via_init(struct hda_codec *codec) in via_init() argument
601 struct via_spec *spec = codec->spec; in via_init()
605 snd_hda_sequence_write(codec, spec->init_verbs[i]); in via_init()
608 __analog_low_current_mode(codec, true); in via_init()
610 snd_hda_gen_init(codec); in via_init()
612 vt1708_update_hp_work(codec); in via_init()
617 static int vt1708_build_controls(struct hda_codec *codec) in vt1708_build_controls() argument
622 int old_interval = codec->jackpoll_interval; in vt1708_build_controls()
623 codec->jackpoll_interval = msecs_to_jiffies(100); in vt1708_build_controls()
624 err = via_build_controls(codec); in vt1708_build_controls()
625 codec->jackpoll_interval = old_interval; in vt1708_build_controls()
629 static int vt1708_build_pcms(struct hda_codec *codec) in vt1708_build_pcms() argument
631 struct via_spec *spec = codec->spec; in vt1708_build_pcms()
634 err = snd_hda_gen_build_pcms(codec); in vt1708_build_pcms()
635 if (err < 0 || codec->core.vendor_id != 0x11061708) in vt1708_build_pcms()
656 static int patch_vt1708(struct hda_codec *codec) in patch_vt1708() argument
662 spec = via_new_spec(codec); in patch_vt1708()
669 codec->jackpoll_interval = msecs_to_jiffies(100); in patch_vt1708()
679 vt1708_set_pinconfig_connect(codec, VT1708_HP_PIN_NID); in patch_vt1708()
680 vt1708_set_pinconfig_connect(codec, VT1708_CD_PIN_NID); in patch_vt1708()
683 err = via_parse_auto_config(codec); in patch_vt1708()
685 via_free(codec); in patch_vt1708()
694 codec->patch_ops = via_patch_ops; in patch_vt1708()
695 codec->patch_ops.build_controls = vt1708_build_controls; in patch_vt1708()
696 codec->patch_ops.build_pcms = vt1708_build_pcms; in patch_vt1708()
699 codec->jackpoll_interval = 0; in patch_vt1708()
704 static int patch_vt1709(struct hda_codec *codec) in patch_vt1709() argument
710 spec = via_new_spec(codec); in patch_vt1709()
716 err = via_parse_auto_config(codec); in patch_vt1709()
718 via_free(codec); in patch_vt1709()
722 codec->patch_ops = via_patch_ops; in patch_vt1709()
727 static int patch_vt1708S(struct hda_codec *codec);
728 static int patch_vt1708B(struct hda_codec *codec) in patch_vt1708B() argument
733 if (get_codec_type(codec) == VT1708BCE) in patch_vt1708B()
734 return patch_vt1708S(codec); in patch_vt1708B()
737 spec = via_new_spec(codec); in patch_vt1708B()
744 err = via_parse_auto_config(codec); in patch_vt1708B()
746 via_free(codec); in patch_vt1708B()
750 codec->patch_ops = via_patch_ops; in patch_vt1708B()
763 static void override_mic_boost(struct hda_codec *codec, hda_nid_t pin, in override_mic_boost() argument
766 snd_hda_override_wcaps(codec, pin, in override_mic_boost()
767 get_wcaps(codec, pin) | AC_WCAP_IN_AMP); in override_mic_boost()
768 snd_hda_override_amp_caps(codec, pin, HDA_INPUT, in override_mic_boost()
775 static int patch_vt1708S(struct hda_codec *codec) in patch_vt1708S() argument
781 spec = via_new_spec(codec); in patch_vt1708S()
786 override_mic_boost(codec, 0x1a, 0, 3, 40); in patch_vt1708S()
787 override_mic_boost(codec, 0x1e, 0, 3, 40); in patch_vt1708S()
790 if (get_codec_type(codec) == VT1708BCE) { in patch_vt1708S()
791 kfree(codec->core.chip_name); in patch_vt1708S()
792 codec->core.chip_name = kstrdup("VT1708BCE", GFP_KERNEL); in patch_vt1708S()
793 snprintf(codec->card->mixername, in patch_vt1708S()
794 sizeof(codec->card->mixername), in patch_vt1708S()
795 "%s %s", codec->core.vendor_name, codec->core.chip_name); in patch_vt1708S()
798 if (codec->core.vendor_id == 0x11064397) { in patch_vt1708S()
799 kfree(codec->core.chip_name); in patch_vt1708S()
800 codec->core.chip_name = kstrdup("VT1705", GFP_KERNEL); in patch_vt1708S()
801 snprintf(codec->card->mixername, in patch_vt1708S()
802 sizeof(codec->card->mixername), in patch_vt1708S()
803 "%s %s", codec->core.vendor_name, codec->core.chip_name); in patch_vt1708S()
807 err = via_parse_auto_config(codec); in patch_vt1708S()
809 via_free(codec); in patch_vt1708S()
815 codec->patch_ops = via_patch_ops; in patch_vt1708S()
829 static int patch_vt1702(struct hda_codec *codec) in patch_vt1702() argument
835 spec = via_new_spec(codec); in patch_vt1702()
842 snd_hda_override_amp_caps(codec, 0x1A, HDA_INPUT, in patch_vt1702()
849 err = via_parse_auto_config(codec); in patch_vt1702()
851 via_free(codec); in patch_vt1702()
857 codec->patch_ops = via_patch_ops; in patch_vt1702()
875 static int add_secret_dac_path(struct hda_codec *codec) in add_secret_dac_path() argument
877 struct via_spec *spec = codec->spec; in add_secret_dac_path()
884 nums = snd_hda_get_connections(codec, spec->gen.mixer_nid, conn, in add_secret_dac_path()
887 if (get_wcaps_type(get_wcaps(codec, conn[i])) == AC_WID_AUD_OUT) in add_secret_dac_path()
892 for_each_hda_codec_node(nid, codec) { in add_secret_dac_path()
893 unsigned int caps = get_wcaps(codec, nid); in add_secret_dac_path()
897 return snd_hda_override_conn_list(codec, in add_secret_dac_path()
906 static int patch_vt1718S(struct hda_codec *codec) in patch_vt1718S() argument
912 spec = via_new_spec(codec); in patch_vt1718S()
917 override_mic_boost(codec, 0x2b, 0, 3, 40); in patch_vt1718S()
918 override_mic_boost(codec, 0x29, 0, 3, 40); in patch_vt1718S()
919 add_secret_dac_path(codec); in patch_vt1718S()
922 err = via_parse_auto_config(codec); in patch_vt1718S()
924 via_free(codec); in patch_vt1718S()
930 codec->patch_ops = via_patch_ops; in patch_vt1718S()
949 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); in vt1716s_dmic_get() local
952 index = snd_hda_codec_read(codec, 0x26, 0, in vt1716s_dmic_get()
963 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); in vt1716s_dmic_put() local
964 struct via_spec *spec = codec->spec; in vt1716s_dmic_put()
967 snd_hda_codec_write(codec, 0x26, 0, in vt1716s_dmic_put()
1004 static int patch_vt1716S(struct hda_codec *codec) in patch_vt1716S() argument
1010 spec = via_new_spec(codec); in patch_vt1716S()
1015 override_mic_boost(codec, 0x1a, 0, 3, 40); in patch_vt1716S()
1016 override_mic_boost(codec, 0x1e, 0, 3, 40); in patch_vt1716S()
1019 err = via_parse_auto_config(codec); in patch_vt1716S()
1021 via_free(codec); in patch_vt1716S()
1030 codec->patch_ops = via_patch_ops; in patch_vt1716S()
1064 static void via_fixup_intmic_boost(struct hda_codec *codec, in via_fixup_intmic_boost() argument
1068 override_mic_boost(codec, 0x30, 0, 2, 40); in via_fixup_intmic_boost()
1096 static void fix_vt1802_connections(struct hda_codec *codec) in fix_vt1802_connections() argument
1101 snd_hda_override_conn_list(codec, 0x24, ARRAY_SIZE(conn_24), conn_24); in fix_vt1802_connections()
1102 snd_hda_override_conn_list(codec, 0x33, ARRAY_SIZE(conn_33), conn_33); in fix_vt1802_connections()
1106 static int patch_vt2002P(struct hda_codec *codec) in patch_vt2002P() argument
1112 spec = via_new_spec(codec); in patch_vt2002P()
1117 override_mic_boost(codec, 0x2b, 0, 3, 40); in patch_vt2002P()
1118 override_mic_boost(codec, 0x29, 0, 3, 40); in patch_vt2002P()
1120 fix_vt1802_connections(codec); in patch_vt2002P()
1121 add_secret_dac_path(codec); in patch_vt2002P()
1123 snd_hda_pick_fixup(codec, NULL, vt2002p_fixups, via_fixups); in patch_vt2002P()
1124 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE); in patch_vt2002P()
1127 err = via_parse_auto_config(codec); in patch_vt2002P()
1129 via_free(codec); in patch_vt2002P()
1138 codec->patch_ops = via_patch_ops; in patch_vt2002P()
1153 static int patch_vt1812(struct hda_codec *codec) in patch_vt1812() argument
1159 spec = via_new_spec(codec); in patch_vt1812()
1164 override_mic_boost(codec, 0x2b, 0, 3, 40); in patch_vt1812()
1165 override_mic_boost(codec, 0x29, 0, 3, 40); in patch_vt1812()
1166 add_secret_dac_path(codec); in patch_vt1812()
1169 err = via_parse_auto_config(codec); in patch_vt1812()
1171 via_free(codec); in patch_vt1812()
1177 codec->patch_ops = via_patch_ops; in patch_vt1812()
1193 static int patch_vt3476(struct hda_codec *codec) in patch_vt3476() argument
1199 spec = via_new_spec(codec); in patch_vt3476()
1204 add_secret_dac_path(codec); in patch_vt3476()
1207 err = via_parse_auto_config(codec); in patch_vt3476()
1209 via_free(codec); in patch_vt3476()
1215 codec->patch_ops = via_patch_ops; in patch_vt3476()