Lines Matching full:codec

3  * Universal Interface for Intel High Definition Audio Codec
5 * HD audio codec driver for VIA VT17xx/VT18xx/VT20xx codec
13 /* 2006-03-03 Lydia Wang Create the basic patch to support VT1708 codec */
15 /* 2006-08-02 Lydia Wang Add support to VT1709 codec */
18 /* 2007-09-17 Lydia Wang Add VT1708B codec support */
19 /* 2007-11-14 Lydia Wang Add VT1708A codec HP and CD pin connect config */
21 /* 2008-03-06 Lydia Wang Add VT1702 codec and VT1708S codec support */
95 static enum VIA_HDA_CODEC get_codec_type(struct hda_codec *codec);
97 struct hda_codec *codec,
101 static struct via_spec *via_new_spec(struct hda_codec *codec) in via_new_spec() argument
109 codec->spec = spec; in via_new_spec()
111 spec->codec_type = get_codec_type(codec); in via_new_spec()
120 codec->power_save_node = 1; in via_new_spec()
125 static enum VIA_HDA_CODEC get_codec_type(struct hda_codec *codec) in get_codec_type() argument
127 u32 vendor_id = codec->core.vendor_id; in get_codec_type()
132 /* get codec type */ in get_codec_type()
143 if (snd_hda_param_read(codec, 0x16, AC_PAR_CONNLIST_LEN) == 0x7) in get_codec_type()
177 static void analog_low_current_mode(struct hda_codec *codec);
178 static bool is_aa_path_mute(struct hda_codec *codec);
180 #define hp_detect_with_aa(codec) \ argument
181 (snd_hda_get_bool_hint(codec, "analog_loopback_hp_detect") == 1 && \
182 !is_aa_path_mute(codec))
184 static void vt1708_stop_hp_work(struct hda_codec *codec) in vt1708_stop_hp_work() argument
186 struct via_spec *spec = codec->spec; in vt1708_stop_hp_work()
190 snd_hda_codec_write(codec, 0x1, 0, 0xf81, 1); in vt1708_stop_hp_work()
191 codec->jackpoll_interval = 0; in vt1708_stop_hp_work()
192 cancel_delayed_work_sync(&codec->jackpoll_work); in vt1708_stop_hp_work()
197 static void vt1708_update_hp_work(struct hda_codec *codec) in vt1708_update_hp_work() argument
199 struct via_spec *spec = codec->spec; in vt1708_update_hp_work()
204 codec->jackpoll_interval = msecs_to_jiffies(100); in vt1708_update_hp_work()
205 snd_hda_codec_write(codec, 0x1, 0, 0xf81, 0); in vt1708_update_hp_work()
206 schedule_delayed_work(&codec->jackpoll_work, 0); in vt1708_update_hp_work()
209 } else if (!hp_detect_with_aa(codec)) in vt1708_update_hp_work()
210 vt1708_stop_hp_work(codec); in vt1708_update_hp_work()
222 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); in via_pin_power_ctl_get() local
223 struct via_spec *spec = codec->spec; in via_pin_power_ctl_get()
232 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); in via_pin_power_ctl_put() local
233 struct via_spec *spec = codec->spec; in via_pin_power_ctl_put()
238 /* codec->power_save_node = val; */ /* widget PM seems yet broken */ in via_pin_power_ctl_put()
240 analog_low_current_mode(codec); in via_pin_power_ctl_put()
277 static int auto_parse_beep(struct hda_codec *codec) in auto_parse_beep() argument
279 struct via_spec *spec = codec->spec; in auto_parse_beep()
282 for_each_hda_codec_node(nid, codec) in auto_parse_beep()
283 if (get_wcaps_type(get_wcaps(codec, nid)) == AC_WID_BEEP) in auto_parse_beep()
288 #define auto_parse_beep(codec) 0 argument
292 static bool is_aa_path_mute(struct hda_codec *codec) in is_aa_path_mute() argument
294 struct via_spec *spec = codec->spec; in is_aa_path_mute()
303 v = snd_hda_codec_amp_read(codec, p->nid, ch, p->dir, in is_aa_path_mute()
313 static void __analog_low_current_mode(struct hda_codec *codec, bool force) in __analog_low_current_mode() argument
315 struct via_spec *spec = codec->spec; in __analog_low_current_mode()
319 if (!codec->power_save_node) in __analog_low_current_mode()
322 enable = is_aa_path_mute(codec) && !spec->gen.active_streams; in __analog_low_current_mode()
359 snd_hda_codec_write(codec, codec->core.afg, 0, verb, parm); in __analog_low_current_mode()
362 static void analog_low_current_mode(struct hda_codec *codec) in analog_low_current_mode() argument
364 return __analog_low_current_mode(codec, false); in analog_low_current_mode()
368 struct hda_codec *codec, in via_playback_pcm_hook() argument
372 analog_low_current_mode(codec); in via_playback_pcm_hook()
373 vt1708_update_hp_work(codec); in via_playback_pcm_hook()
376 static void via_remove(struct hda_codec *codec) in via_remove() argument
378 vt1708_stop_hp_work(codec); in via_remove()
379 snd_hda_gen_remove(codec); in via_remove()
382 static int via_suspend(struct hda_codec *codec) in via_suspend() argument
384 struct via_spec *spec = codec->spec; in via_suspend()
385 vt1708_stop_hp_work(codec); in via_suspend()
389 snd_hda_shutup_pins(codec); in via_suspend()
394 static int via_resume(struct hda_codec *codec) in via_resume() argument
398 snd_hda_codec_init(codec); in via_resume()
399 snd_hda_regmap_sync(codec); in via_resume()
403 static int via_check_power_status(struct hda_codec *codec, hda_nid_t nid) in via_check_power_status() argument
405 struct via_spec *spec = codec->spec; in via_check_power_status()
406 analog_low_current_mode(codec); in via_check_power_status()
407 vt1708_update_hp_work(codec); in via_check_power_status()
408 return snd_hda_check_amp_list_power(codec, &spec->gen.loopback, nid); in via_check_power_status()
419 static void vt1708_set_pinconfig_connect(struct hda_codec *codec, hda_nid_t nid) in vt1708_set_pinconfig_connect() argument
424 def_conf = snd_hda_codec_get_pincfg(codec, nid); in vt1708_set_pinconfig_connect()
430 snd_hda_codec_set_pincfg(codec, nid, def_conf); in vt1708_set_pinconfig_connect()
437 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); in vt1708_jack_detect_get() local
438 struct via_spec *spec = codec->spec; in vt1708_jack_detect_get()
449 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); in vt1708_jack_detect_put() local
450 struct via_spec *spec = codec->spec; in vt1708_jack_detect_put()
459 vt1708_update_hp_work(codec); in vt1708_jack_detect_put()
489 static int via_parse_auto_config(struct hda_codec *codec) in via_parse_auto_config() argument
491 struct via_spec *spec = codec->spec; in via_parse_auto_config()
497 err = snd_hda_parse_pin_defcfg(codec, &spec->gen.autocfg, NULL, 0); in via_parse_auto_config()
501 err = auto_parse_beep(codec); in via_parse_auto_config()
505 err = snd_hda_gen_parse_auto_config(codec, &spec->gen.autocfg); in via_parse_auto_config()
513 codec->power_save_node = 0; in via_parse_auto_config()
518 static int via_init(struct hda_codec *codec) in via_init() argument
521 __analog_low_current_mode(codec, true); in via_init()
523 snd_hda_gen_init(codec); in via_init()
525 vt1708_update_hp_work(codec); in via_init()
530 static int via_build_controls(struct hda_codec *codec) in via_build_controls() argument
535 int old_interval = codec->jackpoll_interval; in via_build_controls()
537 codec->jackpoll_interval = msecs_to_jiffies(100); in via_build_controls()
538 err = snd_hda_gen_build_controls(codec); in via_build_controls()
540 codec->jackpoll_interval = old_interval; in via_build_controls()
544 static int via_build_pcms(struct hda_codec *codec) in via_build_pcms() argument
546 struct via_spec *spec = codec->spec; in via_build_pcms()
549 err = snd_hda_gen_build_pcms(codec); in via_build_pcms()
550 if (err < 0 || codec->core.vendor_id != 0x11061708) in via_build_pcms()
571 static int probe_vt1708(struct hda_codec *codec) in probe_vt1708() argument
573 struct via_spec *spec = codec->spec; in probe_vt1708()
578 /* set jackpoll_interval while parsing the codec */ in probe_vt1708()
579 codec->jackpoll_interval = msecs_to_jiffies(100); in probe_vt1708()
589 vt1708_set_pinconfig_connect(codec, VT1708_HP_PIN_NID); in probe_vt1708()
590 vt1708_set_pinconfig_connect(codec, VT1708_CD_PIN_NID); in probe_vt1708()
592 err = snd_hda_add_verbs(codec, vt1708_init_verbs); in probe_vt1708()
597 err = via_parse_auto_config(codec); in probe_vt1708()
606 codec->jackpoll_interval = 0; in probe_vt1708()
611 static int probe_vt1709(struct hda_codec *codec) in probe_vt1709() argument
613 struct via_spec *spec = codec->spec; in probe_vt1709()
617 return via_parse_auto_config(codec); in probe_vt1709()
620 static int probe_vt1708S(struct hda_codec *codec);
621 static int probe_vt1708B(struct hda_codec *codec) in probe_vt1708B() argument
623 struct via_spec *spec = codec->spec; in probe_vt1708B()
625 if (get_codec_type(codec) == VT1708BCE) in probe_vt1708B()
626 return probe_vt1708S(codec); in probe_vt1708B()
631 return via_parse_auto_config(codec); in probe_vt1708B()
643 static void override_mic_boost(struct hda_codec *codec, hda_nid_t pin, in override_mic_boost() argument
646 snd_hda_override_wcaps(codec, pin, in override_mic_boost()
647 get_wcaps(codec, pin) | AC_WCAP_IN_AMP); in override_mic_boost()
648 snd_hda_override_amp_caps(codec, pin, HDA_INPUT, in override_mic_boost()
655 static int probe_vt1708S(struct hda_codec *codec) in probe_vt1708S() argument
657 struct via_spec *spec = codec->spec; in probe_vt1708S()
661 override_mic_boost(codec, 0x1a, 0, 3, 40); in probe_vt1708S()
662 override_mic_boost(codec, 0x1e, 0, 3, 40); in probe_vt1708S()
665 if (get_codec_type(codec) == VT1708BCE) in probe_vt1708S()
666 snd_hda_codec_set_name(codec, "VT1708BCE"); in probe_vt1708S()
668 if (codec->core.vendor_id == 0x11064397) in probe_vt1708S()
669 snd_hda_codec_set_name(codec, "VT1705"); in probe_vt1708S()
671 err = snd_hda_add_verbs(codec, vt1708S_init_verbs); in probe_vt1708S()
675 return via_parse_auto_config(codec); in probe_vt1708S()
688 static int probe_vt1702(struct hda_codec *codec) in probe_vt1702() argument
690 struct via_spec *spec = codec->spec; in probe_vt1702()
696 snd_hda_override_amp_caps(codec, 0x1A, HDA_INPUT, in probe_vt1702()
702 err = snd_hda_add_verbs(codec, vt1702_init_verbs); in probe_vt1702()
707 return via_parse_auto_config(codec); in probe_vt1702()
724 static int add_secret_dac_path(struct hda_codec *codec) in add_secret_dac_path() argument
726 struct via_spec *spec = codec->spec; in add_secret_dac_path()
733 nums = snd_hda_get_connections(codec, spec->gen.mixer_nid, conn, in add_secret_dac_path()
739 if (get_wcaps_type(get_wcaps(codec, conn[i])) == AC_WID_AUD_OUT) in add_secret_dac_path()
744 for_each_hda_codec_node(nid, codec) { in add_secret_dac_path()
745 unsigned int caps = get_wcaps(codec, nid); in add_secret_dac_path()
749 return snd_hda_override_conn_list(codec, in add_secret_dac_path()
758 static int probe_vt1718S(struct hda_codec *codec) in probe_vt1718S() argument
760 struct via_spec *spec = codec->spec; in probe_vt1718S()
764 override_mic_boost(codec, 0x2b, 0, 3, 40); in probe_vt1718S()
765 override_mic_boost(codec, 0x29, 0, 3, 40); in probe_vt1718S()
766 add_secret_dac_path(codec); in probe_vt1718S()
768 err = snd_hda_add_verbs(codec, vt1718S_init_verbs); in probe_vt1718S()
773 return via_parse_auto_config(codec); in probe_vt1718S()
791 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); in vt1716s_dmic_get() local
794 index = snd_hda_codec_read(codec, 0x26, 0, in vt1716s_dmic_get()
805 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); in vt1716s_dmic_put() local
806 struct via_spec *spec = codec->spec; in vt1716s_dmic_put()
809 snd_hda_codec_write(codec, 0x26, 0, in vt1716s_dmic_put()
842 static int probe_vt1716S(struct hda_codec *codec) in probe_vt1716S() argument
844 struct via_spec *spec = codec->spec; in probe_vt1716S()
848 override_mic_boost(codec, 0x1a, 0, 3, 40); in probe_vt1716S()
849 override_mic_boost(codec, 0x1e, 0, 3, 40); in probe_vt1716S()
851 err = snd_hda_add_verbs(codec, vt1716S_init_verbs); in probe_vt1716S()
856 err = via_parse_auto_config(codec); in probe_vt1716S()
899 static void via_fixup_intmic_boost(struct hda_codec *codec, in via_fixup_intmic_boost() argument
903 override_mic_boost(codec, 0x30, 0, 2, 40); in via_fixup_intmic_boost()
906 static void via_fixup_power_save(struct hda_codec *codec, in via_fixup_power_save() argument
910 codec->power_save_node = 0; in via_fixup_power_save()
944 static void fix_vt1802_connections(struct hda_codec *codec) in fix_vt1802_connections() argument
949 snd_hda_override_conn_list(codec, 0x24, ARRAY_SIZE(conn_24), conn_24); in fix_vt1802_connections()
950 snd_hda_override_conn_list(codec, 0x33, ARRAY_SIZE(conn_33), conn_33); in fix_vt1802_connections()
954 static int probe_vt2002P(struct hda_codec *codec) in probe_vt2002P() argument
956 struct via_spec *spec = codec->spec; in probe_vt2002P()
960 override_mic_boost(codec, 0x2b, 0, 3, 40); in probe_vt2002P()
961 override_mic_boost(codec, 0x29, 0, 3, 40); in probe_vt2002P()
963 fix_vt1802_connections(codec); in probe_vt2002P()
964 add_secret_dac_path(codec); in probe_vt2002P()
966 snd_hda_pick_fixup(codec, NULL, vt2002p_fixups, via_fixups); in probe_vt2002P()
967 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE); in probe_vt2002P()
970 err = snd_hda_add_verbs(codec, vt1802_init_verbs); in probe_vt2002P()
972 err = snd_hda_add_verbs(codec, vt2002P_init_verbs); in probe_vt2002P()
977 return via_parse_auto_config(codec); in probe_vt2002P()
990 static int probe_vt1812(struct hda_codec *codec) in probe_vt1812() argument
992 struct via_spec *spec = codec->spec; in probe_vt1812()
996 override_mic_boost(codec, 0x2b, 0, 3, 40); in probe_vt1812()
997 override_mic_boost(codec, 0x29, 0, 3, 40); in probe_vt1812()
998 add_secret_dac_path(codec); in probe_vt1812()
1000 err = snd_hda_add_verbs(codec, vt1812_init_verbs); in probe_vt1812()
1005 return via_parse_auto_config(codec); in probe_vt1812()
1020 static int probe_vt3476(struct hda_codec *codec) in probe_vt3476() argument
1022 struct via_spec *spec = codec->spec; in probe_vt3476()
1026 add_secret_dac_path(codec); in probe_vt3476()
1028 err = snd_hda_add_verbs(codec, vt3476_init_verbs); in probe_vt3476()
1033 return via_parse_auto_config(codec); in probe_vt3476()
1040 static int via_probe(struct hda_codec *codec, const struct hda_device_id *id) in via_probe() argument
1045 /* create a codec specific record */ in via_probe()
1046 spec = via_new_spec(codec); in via_probe()
1052 err = probe_vt1708(codec); in via_probe()
1055 err = probe_vt1709(codec); in via_probe()
1058 err = probe_vt1708B(codec); in via_probe()
1061 err = probe_vt1708S(codec); in via_probe()
1064 err = probe_vt1702(codec); in via_probe()
1067 err = probe_vt1718S(codec); in via_probe()
1070 err = probe_vt1716S(codec); in via_probe()
1073 err = probe_vt2002P(codec); in via_probe()
1076 err = probe_vt1812(codec); in via_probe()
1079 err = probe_vt3476(codec); in via_probe()
1087 via_remove(codec); in via_probe()
1172 MODULE_DESCRIPTION("VIA HD-audio codec");