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()
118 codec->power_save_node = 1; in via_new_spec()
120 codec->patch_ops = via_patch_ops; in via_new_spec()
124 static enum VIA_HDA_CODEC get_codec_type(struct hda_codec *codec) in get_codec_type() argument
126 u32 vendor_id = codec->core.vendor_id; in get_codec_type()
131 /* get codec type */ in get_codec_type()
142 if (snd_hda_param_read(codec, 0x16, AC_PAR_CONNLIST_LEN) == 0x7) in get_codec_type()
176 static void analog_low_current_mode(struct hda_codec *codec);
177 static bool is_aa_path_mute(struct hda_codec *codec);
179 #define hp_detect_with_aa(codec) \ argument
180 (snd_hda_get_bool_hint(codec, "analog_loopback_hp_detect") == 1 && \
181 !is_aa_path_mute(codec))
183 static void vt1708_stop_hp_work(struct hda_codec *codec) in vt1708_stop_hp_work() argument
185 struct via_spec *spec = codec->spec; in vt1708_stop_hp_work()
189 snd_hda_codec_write(codec, 0x1, 0, 0xf81, 1); in vt1708_stop_hp_work()
190 codec->jackpoll_interval = 0; in vt1708_stop_hp_work()
191 cancel_delayed_work_sync(&codec->jackpoll_work); in vt1708_stop_hp_work()
196 static void vt1708_update_hp_work(struct hda_codec *codec) in vt1708_update_hp_work() argument
198 struct via_spec *spec = codec->spec; in vt1708_update_hp_work()
203 codec->jackpoll_interval = msecs_to_jiffies(100); in vt1708_update_hp_work()
204 snd_hda_codec_write(codec, 0x1, 0, 0xf81, 0); in vt1708_update_hp_work()
205 schedule_delayed_work(&codec->jackpoll_work, 0); in vt1708_update_hp_work()
208 } else if (!hp_detect_with_aa(codec)) in vt1708_update_hp_work()
209 vt1708_stop_hp_work(codec); in vt1708_update_hp_work()
221 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); in via_pin_power_ctl_get() local
222 struct via_spec *spec = codec->spec; in via_pin_power_ctl_get()
231 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); in via_pin_power_ctl_put() local
232 struct via_spec *spec = codec->spec; in via_pin_power_ctl_put()
237 /* codec->power_save_node = val; */ /* widget PM seems yet broken */ in via_pin_power_ctl_put()
239 analog_low_current_mode(codec); in via_pin_power_ctl_put()
276 static int auto_parse_beep(struct hda_codec *codec) in auto_parse_beep() argument
278 struct via_spec *spec = codec->spec; in auto_parse_beep()
281 for_each_hda_codec_node(nid, codec) in auto_parse_beep()
282 if (get_wcaps_type(get_wcaps(codec, nid)) == AC_WID_BEEP) in auto_parse_beep()
287 #define auto_parse_beep(codec) 0 argument
291 static bool is_aa_path_mute(struct hda_codec *codec) in is_aa_path_mute() argument
293 struct via_spec *spec = codec->spec; in is_aa_path_mute()
302 v = snd_hda_codec_amp_read(codec, p->nid, ch, p->dir, in is_aa_path_mute()
312 static void __analog_low_current_mode(struct hda_codec *codec, bool force) in __analog_low_current_mode() argument
314 struct via_spec *spec = codec->spec; in __analog_low_current_mode()
318 if (!codec->power_save_node) in __analog_low_current_mode()
321 enable = is_aa_path_mute(codec) && !spec->gen.active_streams; in __analog_low_current_mode()
358 snd_hda_codec_write(codec, codec->core.afg, 0, verb, parm); in __analog_low_current_mode()
361 static void analog_low_current_mode(struct hda_codec *codec) in analog_low_current_mode() argument
363 return __analog_low_current_mode(codec, false); in analog_low_current_mode()
367 struct hda_codec *codec, in via_playback_pcm_hook() argument
371 analog_low_current_mode(codec); in via_playback_pcm_hook()
372 vt1708_update_hp_work(codec); in via_playback_pcm_hook()
375 static void via_free(struct hda_codec *codec) in via_free() argument
377 vt1708_stop_hp_work(codec); in via_free()
378 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()
405 static int via_check_power_status(struct hda_codec *codec, hda_nid_t nid) in via_check_power_status() argument
407 struct via_spec *spec = codec->spec; in via_check_power_status()
408 analog_low_current_mode(codec); in via_check_power_status()
409 vt1708_update_hp_work(codec); in via_check_power_status()
410 return snd_hda_check_amp_list_power(codec, &spec->gen.loopback, nid); in via_check_power_status()
417 static int via_init(struct hda_codec *codec);
438 static void vt1708_set_pinconfig_connect(struct hda_codec *codec, hda_nid_t nid) in vt1708_set_pinconfig_connect() argument
443 def_conf = snd_hda_codec_get_pincfg(codec, nid); in vt1708_set_pinconfig_connect()
449 snd_hda_codec_set_pincfg(codec, nid, def_conf); in vt1708_set_pinconfig_connect()
458 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); in vt1708_jack_detect_get() local
459 struct via_spec *spec = codec->spec; in vt1708_jack_detect_get()
470 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); in vt1708_jack_detect_put() local
471 struct via_spec *spec = codec->spec; in vt1708_jack_detect_put()
480 vt1708_update_hp_work(codec); in vt1708_jack_detect_put()
510 static int via_parse_auto_config(struct hda_codec *codec) in via_parse_auto_config() argument
512 struct via_spec *spec = codec->spec; in via_parse_auto_config()
518 err = snd_hda_parse_pin_defcfg(codec, &spec->gen.autocfg, NULL, 0); in via_parse_auto_config()
522 err = snd_hda_gen_parse_auto_config(codec, &spec->gen.autocfg); in via_parse_auto_config()
526 err = auto_parse_beep(codec); in via_parse_auto_config()
534 codec->power_save_node = 0; in via_parse_auto_config()
539 static int via_init(struct hda_codec *codec) in via_init() argument
542 __analog_low_current_mode(codec, true); in via_init()
544 snd_hda_gen_init(codec); in via_init()
546 vt1708_update_hp_work(codec); in via_init()
551 static int vt1708_build_controls(struct hda_codec *codec) in vt1708_build_controls() argument
556 int old_interval = codec->jackpoll_interval; in vt1708_build_controls()
557 codec->jackpoll_interval = msecs_to_jiffies(100); in vt1708_build_controls()
558 err = snd_hda_gen_build_controls(codec); in vt1708_build_controls()
559 codec->jackpoll_interval = old_interval; in vt1708_build_controls()
563 static int vt1708_build_pcms(struct hda_codec *codec) in vt1708_build_pcms() argument
565 struct via_spec *spec = codec->spec; in vt1708_build_pcms()
568 err = snd_hda_gen_build_pcms(codec); in vt1708_build_pcms()
569 if (err < 0 || codec->core.vendor_id != 0x11061708) in vt1708_build_pcms()
590 static int patch_vt1708(struct hda_codec *codec) in patch_vt1708() argument
595 /* create a codec specific record */ in patch_vt1708()
596 spec = via_new_spec(codec); in patch_vt1708()
601 codec->patch_ops.build_controls = vt1708_build_controls; in patch_vt1708()
602 codec->patch_ops.build_pcms = vt1708_build_pcms; in patch_vt1708()
605 /* set jackpoll_interval while parsing the codec */ in patch_vt1708()
606 codec->jackpoll_interval = msecs_to_jiffies(100); in patch_vt1708()
616 vt1708_set_pinconfig_connect(codec, VT1708_HP_PIN_NID); in patch_vt1708()
617 vt1708_set_pinconfig_connect(codec, VT1708_CD_PIN_NID); in patch_vt1708()
619 err = snd_hda_add_verbs(codec, vt1708_init_verbs); in patch_vt1708()
624 err = via_parse_auto_config(codec); in patch_vt1708()
635 codec->jackpoll_interval = 0; in patch_vt1708()
640 via_free(codec); in patch_vt1708()
644 static int patch_vt1709(struct hda_codec *codec) in patch_vt1709() argument
649 /* create a codec specific record */ in patch_vt1709()
650 spec = via_new_spec(codec); in patch_vt1709()
656 err = via_parse_auto_config(codec); in patch_vt1709()
663 via_free(codec); in patch_vt1709()
667 static int patch_vt1708S(struct hda_codec *codec);
668 static int patch_vt1708B(struct hda_codec *codec) in patch_vt1708B() argument
673 if (get_codec_type(codec) == VT1708BCE) in patch_vt1708B()
674 return patch_vt1708S(codec); in patch_vt1708B()
676 /* create a codec specific record */ in patch_vt1708B()
677 spec = via_new_spec(codec); in patch_vt1708B()
684 err = via_parse_auto_config(codec); in patch_vt1708B()
691 via_free(codec); in patch_vt1708B()
704 static void override_mic_boost(struct hda_codec *codec, hda_nid_t pin, in override_mic_boost() argument
707 snd_hda_override_wcaps(codec, pin, in override_mic_boost()
708 get_wcaps(codec, pin) | AC_WCAP_IN_AMP); in override_mic_boost()
709 snd_hda_override_amp_caps(codec, pin, HDA_INPUT, in override_mic_boost()
716 static int patch_vt1708S(struct hda_codec *codec) in patch_vt1708S() argument
721 /* create a codec specific record */ in patch_vt1708S()
722 spec = via_new_spec(codec); in patch_vt1708S()
727 override_mic_boost(codec, 0x1a, 0, 3, 40); in patch_vt1708S()
728 override_mic_boost(codec, 0x1e, 0, 3, 40); in patch_vt1708S()
731 if (get_codec_type(codec) == VT1708BCE) in patch_vt1708S()
732 snd_hda_codec_set_name(codec, "VT1708BCE"); in patch_vt1708S()
734 if (codec->core.vendor_id == 0x11064397) in patch_vt1708S()
735 snd_hda_codec_set_name(codec, "VT1705"); in patch_vt1708S()
737 err = snd_hda_add_verbs(codec, vt1708S_init_verbs); in patch_vt1708S()
742 err = via_parse_auto_config(codec); in patch_vt1708S()
749 via_free(codec); in patch_vt1708S()
763 static int patch_vt1702(struct hda_codec *codec) in patch_vt1702() argument
768 /* create a codec specific record */ in patch_vt1702()
769 spec = via_new_spec(codec); in patch_vt1702()
776 snd_hda_override_amp_caps(codec, 0x1A, HDA_INPUT, in patch_vt1702()
782 err = snd_hda_add_verbs(codec, vt1702_init_verbs); in patch_vt1702()
787 err = via_parse_auto_config(codec); in patch_vt1702()
794 via_free(codec); in patch_vt1702()
812 static int add_secret_dac_path(struct hda_codec *codec) in add_secret_dac_path() argument
814 struct via_spec *spec = codec->spec; in add_secret_dac_path()
821 nums = snd_hda_get_connections(codec, spec->gen.mixer_nid, conn, in add_secret_dac_path()
824 if (get_wcaps_type(get_wcaps(codec, conn[i])) == AC_WID_AUD_OUT) in add_secret_dac_path()
829 for_each_hda_codec_node(nid, codec) { in add_secret_dac_path()
830 unsigned int caps = get_wcaps(codec, nid); in add_secret_dac_path()
834 return snd_hda_override_conn_list(codec, in add_secret_dac_path()
843 static int patch_vt1718S(struct hda_codec *codec) in patch_vt1718S() argument
848 /* create a codec specific record */ in patch_vt1718S()
849 spec = via_new_spec(codec); in patch_vt1718S()
854 override_mic_boost(codec, 0x2b, 0, 3, 40); in patch_vt1718S()
855 override_mic_boost(codec, 0x29, 0, 3, 40); in patch_vt1718S()
856 add_secret_dac_path(codec); in patch_vt1718S()
858 err = snd_hda_add_verbs(codec, vt1718S_init_verbs); in patch_vt1718S()
863 err = via_parse_auto_config(codec); in patch_vt1718S()
870 via_free(codec); in patch_vt1718S()
889 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); in vt1716s_dmic_get() local
892 index = snd_hda_codec_read(codec, 0x26, 0, in vt1716s_dmic_get()
903 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); in vt1716s_dmic_put() local
904 struct via_spec *spec = codec->spec; in vt1716s_dmic_put()
907 snd_hda_codec_write(codec, 0x26, 0, in vt1716s_dmic_put()
940 static int patch_vt1716S(struct hda_codec *codec) in patch_vt1716S() argument
945 /* create a codec specific record */ in patch_vt1716S()
946 spec = via_new_spec(codec); in patch_vt1716S()
951 override_mic_boost(codec, 0x1a, 0, 3, 40); in patch_vt1716S()
952 override_mic_boost(codec, 0x1e, 0, 3, 40); in patch_vt1716S()
954 err = snd_hda_add_verbs(codec, vt1716S_init_verbs); in patch_vt1716S()
959 err = via_parse_auto_config(codec); in patch_vt1716S()
973 via_free(codec); in patch_vt1716S()
1007 static void via_fixup_intmic_boost(struct hda_codec *codec, in via_fixup_intmic_boost() argument
1011 override_mic_boost(codec, 0x30, 0, 2, 40); in via_fixup_intmic_boost()
1039 static void fix_vt1802_connections(struct hda_codec *codec) in fix_vt1802_connections() argument
1044 snd_hda_override_conn_list(codec, 0x24, ARRAY_SIZE(conn_24), conn_24); in fix_vt1802_connections()
1045 snd_hda_override_conn_list(codec, 0x33, ARRAY_SIZE(conn_33), conn_33); in fix_vt1802_connections()
1049 static int patch_vt2002P(struct hda_codec *codec) in patch_vt2002P() argument
1054 /* create a codec specific record */ in patch_vt2002P()
1055 spec = via_new_spec(codec); in patch_vt2002P()
1060 override_mic_boost(codec, 0x2b, 0, 3, 40); in patch_vt2002P()
1061 override_mic_boost(codec, 0x29, 0, 3, 40); in patch_vt2002P()
1063 fix_vt1802_connections(codec); in patch_vt2002P()
1064 add_secret_dac_path(codec); in patch_vt2002P()
1066 snd_hda_pick_fixup(codec, NULL, vt2002p_fixups, via_fixups); in patch_vt2002P()
1067 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE); in patch_vt2002P()
1070 err = snd_hda_add_verbs(codec, vt1802_init_verbs); in patch_vt2002P()
1072 err = snd_hda_add_verbs(codec, vt2002P_init_verbs); in patch_vt2002P()
1077 err = via_parse_auto_config(codec); in patch_vt2002P()
1084 via_free(codec); in patch_vt2002P()
1099 static int patch_vt1812(struct hda_codec *codec) in patch_vt1812() argument
1104 /* create a codec specific record */ in patch_vt1812()
1105 spec = via_new_spec(codec); in patch_vt1812()
1110 override_mic_boost(codec, 0x2b, 0, 3, 40); in patch_vt1812()
1111 override_mic_boost(codec, 0x29, 0, 3, 40); in patch_vt1812()
1112 add_secret_dac_path(codec); in patch_vt1812()
1114 err = snd_hda_add_verbs(codec, vt1812_init_verbs); in patch_vt1812()
1119 err = via_parse_auto_config(codec); in patch_vt1812()
1126 via_free(codec); in patch_vt1812()
1142 static int patch_vt3476(struct hda_codec *codec) in patch_vt3476() argument
1147 /* create a codec specific record */ in patch_vt3476()
1148 spec = via_new_spec(codec); in patch_vt3476()
1153 add_secret_dac_path(codec); in patch_vt3476()
1155 err = snd_hda_add_verbs(codec, vt3476_init_verbs); in patch_vt3476()
1160 err = via_parse_auto_config(codec); in patch_vt3476()
1167 via_free(codec); in patch_vt3476()
1235 MODULE_DESCRIPTION("VIA HD-audio codec");