Lines Matching full:codec

3  * Universal Interface for Intel High Definition Audio Codec
5 * HD audio interface patch 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 */
92 static enum VIA_HDA_CODEC get_codec_type(struct hda_codec *codec);
94 struct hda_codec *codec,
100 static struct via_spec *via_new_spec(struct hda_codec *codec) in via_new_spec() argument
108 codec->spec = spec; in via_new_spec()
110 spec->codec_type = get_codec_type(codec); in via_new_spec()
119 codec->power_save_node = 1; in via_new_spec()
121 codec->patch_ops = via_patch_ops; 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_free(struct hda_codec *codec) in via_free() argument
378 vt1708_stop_hp_work(codec); in via_free()
379 snd_hda_gen_free(codec); in via_free()
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 codec->patch_ops.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()
414 static int via_init(struct hda_codec *codec);
433 static void vt1708_set_pinconfig_connect(struct hda_codec *codec, hda_nid_t nid) in vt1708_set_pinconfig_connect() argument
438 def_conf = snd_hda_codec_get_pincfg(codec, nid); in vt1708_set_pinconfig_connect()
444 snd_hda_codec_set_pincfg(codec, nid, def_conf); in vt1708_set_pinconfig_connect()
451 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); in vt1708_jack_detect_get() local
452 struct via_spec *spec = codec->spec; in vt1708_jack_detect_get()
463 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); in vt1708_jack_detect_put() local
464 struct via_spec *spec = codec->spec; in vt1708_jack_detect_put()
473 vt1708_update_hp_work(codec); in vt1708_jack_detect_put()
503 static int via_parse_auto_config(struct hda_codec *codec) in via_parse_auto_config() argument
505 struct via_spec *spec = codec->spec; in via_parse_auto_config()
511 err = snd_hda_parse_pin_defcfg(codec, &spec->gen.autocfg, NULL, 0); in via_parse_auto_config()
515 err = auto_parse_beep(codec); in via_parse_auto_config()
519 err = snd_hda_gen_parse_auto_config(codec, &spec->gen.autocfg); in via_parse_auto_config()
527 codec->power_save_node = 0; in via_parse_auto_config()
532 static int via_init(struct hda_codec *codec) in via_init() argument
535 __analog_low_current_mode(codec, true); in via_init()
537 snd_hda_gen_init(codec); in via_init()
539 vt1708_update_hp_work(codec); in via_init()
544 static int vt1708_build_controls(struct hda_codec *codec) in vt1708_build_controls() argument
549 int old_interval = codec->jackpoll_interval; in vt1708_build_controls()
550 codec->jackpoll_interval = msecs_to_jiffies(100); in vt1708_build_controls()
551 err = snd_hda_gen_build_controls(codec); in vt1708_build_controls()
552 codec->jackpoll_interval = old_interval; in vt1708_build_controls()
556 static int vt1708_build_pcms(struct hda_codec *codec) in vt1708_build_pcms() argument
558 struct via_spec *spec = codec->spec; in vt1708_build_pcms()
561 err = snd_hda_gen_build_pcms(codec); in vt1708_build_pcms()
562 if (err < 0 || codec->core.vendor_id != 0x11061708) in vt1708_build_pcms()
583 static int patch_vt1708(struct hda_codec *codec) in patch_vt1708() argument
588 /* create a codec specific record */ in patch_vt1708()
589 spec = via_new_spec(codec); in patch_vt1708()
594 codec->patch_ops.build_controls = vt1708_build_controls; in patch_vt1708()
595 codec->patch_ops.build_pcms = vt1708_build_pcms; in patch_vt1708()
598 /* set jackpoll_interval while parsing the codec */ in patch_vt1708()
599 codec->jackpoll_interval = msecs_to_jiffies(100); in patch_vt1708()
609 vt1708_set_pinconfig_connect(codec, VT1708_HP_PIN_NID); in patch_vt1708()
610 vt1708_set_pinconfig_connect(codec, VT1708_CD_PIN_NID); in patch_vt1708()
612 err = snd_hda_add_verbs(codec, vt1708_init_verbs); in patch_vt1708()
617 err = via_parse_auto_config(codec); in patch_vt1708()
628 codec->jackpoll_interval = 0; in patch_vt1708()
633 via_free(codec); in patch_vt1708()
637 static int patch_vt1709(struct hda_codec *codec) in patch_vt1709() argument
642 /* create a codec specific record */ in patch_vt1709()
643 spec = via_new_spec(codec); in patch_vt1709()
649 err = via_parse_auto_config(codec); in patch_vt1709()
656 via_free(codec); in patch_vt1709()
660 static int patch_vt1708S(struct hda_codec *codec);
661 static int patch_vt1708B(struct hda_codec *codec) in patch_vt1708B() argument
666 if (get_codec_type(codec) == VT1708BCE) in patch_vt1708B()
667 return patch_vt1708S(codec); in patch_vt1708B()
669 /* create a codec specific record */ in patch_vt1708B()
670 spec = via_new_spec(codec); in patch_vt1708B()
677 err = via_parse_auto_config(codec); in patch_vt1708B()
684 via_free(codec); in patch_vt1708B()
697 static void override_mic_boost(struct hda_codec *codec, hda_nid_t pin, in override_mic_boost() argument
700 snd_hda_override_wcaps(codec, pin, in override_mic_boost()
701 get_wcaps(codec, pin) | AC_WCAP_IN_AMP); in override_mic_boost()
702 snd_hda_override_amp_caps(codec, pin, HDA_INPUT, in override_mic_boost()
709 static int patch_vt1708S(struct hda_codec *codec) in patch_vt1708S() argument
714 /* create a codec specific record */ in patch_vt1708S()
715 spec = via_new_spec(codec); in patch_vt1708S()
720 override_mic_boost(codec, 0x1a, 0, 3, 40); in patch_vt1708S()
721 override_mic_boost(codec, 0x1e, 0, 3, 40); in patch_vt1708S()
724 if (get_codec_type(codec) == VT1708BCE) in patch_vt1708S()
725 snd_hda_codec_set_name(codec, "VT1708BCE"); in patch_vt1708S()
727 if (codec->core.vendor_id == 0x11064397) in patch_vt1708S()
728 snd_hda_codec_set_name(codec, "VT1705"); in patch_vt1708S()
730 err = snd_hda_add_verbs(codec, vt1708S_init_verbs); in patch_vt1708S()
735 err = via_parse_auto_config(codec); in patch_vt1708S()
742 via_free(codec); in patch_vt1708S()
756 static int patch_vt1702(struct hda_codec *codec) in patch_vt1702() argument
761 /* create a codec specific record */ in patch_vt1702()
762 spec = via_new_spec(codec); in patch_vt1702()
769 snd_hda_override_amp_caps(codec, 0x1A, HDA_INPUT, in patch_vt1702()
775 err = snd_hda_add_verbs(codec, vt1702_init_verbs); in patch_vt1702()
780 err = via_parse_auto_config(codec); in patch_vt1702()
787 via_free(codec); in patch_vt1702()
805 static int add_secret_dac_path(struct hda_codec *codec) in add_secret_dac_path() argument
807 struct via_spec *spec = codec->spec; in add_secret_dac_path()
814 nums = snd_hda_get_connections(codec, spec->gen.mixer_nid, conn, in add_secret_dac_path()
820 if (get_wcaps_type(get_wcaps(codec, conn[i])) == AC_WID_AUD_OUT) in add_secret_dac_path()
825 for_each_hda_codec_node(nid, codec) { in add_secret_dac_path()
826 unsigned int caps = get_wcaps(codec, nid); in add_secret_dac_path()
830 return snd_hda_override_conn_list(codec, in add_secret_dac_path()
839 static int patch_vt1718S(struct hda_codec *codec) in patch_vt1718S() argument
844 /* create a codec specific record */ in patch_vt1718S()
845 spec = via_new_spec(codec); in patch_vt1718S()
850 override_mic_boost(codec, 0x2b, 0, 3, 40); in patch_vt1718S()
851 override_mic_boost(codec, 0x29, 0, 3, 40); in patch_vt1718S()
852 add_secret_dac_path(codec); in patch_vt1718S()
854 err = snd_hda_add_verbs(codec, vt1718S_init_verbs); in patch_vt1718S()
859 err = via_parse_auto_config(codec); in patch_vt1718S()
866 via_free(codec); in patch_vt1718S()
885 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); in vt1716s_dmic_get() local
888 index = snd_hda_codec_read(codec, 0x26, 0, in vt1716s_dmic_get()
899 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); in vt1716s_dmic_put() local
900 struct via_spec *spec = codec->spec; in vt1716s_dmic_put()
903 snd_hda_codec_write(codec, 0x26, 0, in vt1716s_dmic_put()
936 static int patch_vt1716S(struct hda_codec *codec) in patch_vt1716S() argument
941 /* create a codec specific record */ in patch_vt1716S()
942 spec = via_new_spec(codec); in patch_vt1716S()
947 override_mic_boost(codec, 0x1a, 0, 3, 40); in patch_vt1716S()
948 override_mic_boost(codec, 0x1e, 0, 3, 40); in patch_vt1716S()
950 err = snd_hda_add_verbs(codec, vt1716S_init_verbs); in patch_vt1716S()
955 err = via_parse_auto_config(codec); in patch_vt1716S()
969 via_free(codec); in patch_vt1716S()
1004 static void via_fixup_intmic_boost(struct hda_codec *codec, in via_fixup_intmic_boost() argument
1008 override_mic_boost(codec, 0x30, 0, 2, 40); in via_fixup_intmic_boost()
1011 static void via_fixup_power_save(struct hda_codec *codec, in via_fixup_power_save() argument
1015 codec->power_save_node = 0; in via_fixup_power_save()
1049 static void fix_vt1802_connections(struct hda_codec *codec) in fix_vt1802_connections() argument
1054 snd_hda_override_conn_list(codec, 0x24, ARRAY_SIZE(conn_24), conn_24); in fix_vt1802_connections()
1055 snd_hda_override_conn_list(codec, 0x33, ARRAY_SIZE(conn_33), conn_33); in fix_vt1802_connections()
1059 static int patch_vt2002P(struct hda_codec *codec) in patch_vt2002P() argument
1064 /* create a codec specific record */ in patch_vt2002P()
1065 spec = via_new_spec(codec); in patch_vt2002P()
1070 override_mic_boost(codec, 0x2b, 0, 3, 40); in patch_vt2002P()
1071 override_mic_boost(codec, 0x29, 0, 3, 40); in patch_vt2002P()
1073 fix_vt1802_connections(codec); in patch_vt2002P()
1074 add_secret_dac_path(codec); in patch_vt2002P()
1076 snd_hda_pick_fixup(codec, NULL, vt2002p_fixups, via_fixups); in patch_vt2002P()
1077 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE); in patch_vt2002P()
1080 err = snd_hda_add_verbs(codec, vt1802_init_verbs); in patch_vt2002P()
1082 err = snd_hda_add_verbs(codec, vt2002P_init_verbs); in patch_vt2002P()
1087 err = via_parse_auto_config(codec); in patch_vt2002P()
1094 via_free(codec); in patch_vt2002P()
1109 static int patch_vt1812(struct hda_codec *codec) in patch_vt1812() argument
1114 /* create a codec specific record */ in patch_vt1812()
1115 spec = via_new_spec(codec); in patch_vt1812()
1120 override_mic_boost(codec, 0x2b, 0, 3, 40); in patch_vt1812()
1121 override_mic_boost(codec, 0x29, 0, 3, 40); in patch_vt1812()
1122 add_secret_dac_path(codec); in patch_vt1812()
1124 err = snd_hda_add_verbs(codec, vt1812_init_verbs); in patch_vt1812()
1129 err = via_parse_auto_config(codec); in patch_vt1812()
1136 via_free(codec); in patch_vt1812()
1152 static int patch_vt3476(struct hda_codec *codec) in patch_vt3476() argument
1157 /* create a codec specific record */ in patch_vt3476()
1158 spec = via_new_spec(codec); in patch_vt3476()
1163 add_secret_dac_path(codec); in patch_vt3476()
1165 err = snd_hda_add_verbs(codec, vt3476_init_verbs); in patch_vt3476()
1170 err = via_parse_auto_config(codec); in patch_vt3476()
1177 via_free(codec); in patch_vt3476()
1245 MODULE_DESCRIPTION("VIA HD-audio codec");