Lines Matching refs: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)
108 codec->spec = spec;
110 spec->codec_type = get_codec_type(codec);
119 codec->power_save_node = 1;
121 codec->patch_ops = via_patch_ops;
125 static enum VIA_HDA_CODEC get_codec_type(struct hda_codec *codec)
127 u32 vendor_id = codec->core.vendor_id;
132 /* get codec type */
143 if (snd_hda_param_read(codec, 0x16, AC_PAR_CONNLIST_LEN) == 0x7)
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) \
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)
186 struct via_spec *spec = codec->spec;
190 snd_hda_codec_write(codec, 0x1, 0, 0xf81, 1);
191 codec->jackpoll_interval = 0;
192 cancel_delayed_work_sync(&codec->jackpoll_work);
197 static void vt1708_update_hp_work(struct hda_codec *codec)
199 struct via_spec *spec = codec->spec;
204 codec->jackpoll_interval = msecs_to_jiffies(100);
205 snd_hda_codec_write(codec, 0x1, 0, 0xf81, 0);
206 schedule_delayed_work(&codec->jackpoll_work, 0);
209 } else if (!hp_detect_with_aa(codec))
210 vt1708_stop_hp_work(codec);
222 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
223 struct via_spec *spec = codec->spec;
232 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
233 struct via_spec *spec = codec->spec;
238 /* codec->power_save_node = val; */ /* widget PM seems yet broken */
240 analog_low_current_mode(codec);
277 static int auto_parse_beep(struct hda_codec *codec)
279 struct via_spec *spec = codec->spec;
282 for_each_hda_codec_node(nid, codec)
283 if (get_wcaps_type(get_wcaps(codec, nid)) == AC_WID_BEEP)
288 #define auto_parse_beep(codec) 0
292 static bool is_aa_path_mute(struct hda_codec *codec)
294 struct via_spec *spec = codec->spec;
303 v = snd_hda_codec_amp_read(codec, p->nid, ch, p->dir,
313 static void __analog_low_current_mode(struct hda_codec *codec, bool force)
315 struct via_spec *spec = codec->spec;
319 if (!codec->power_save_node)
322 enable = is_aa_path_mute(codec) && !spec->gen.active_streams;
359 snd_hda_codec_write(codec, codec->core.afg, 0, verb, parm);
362 static void analog_low_current_mode(struct hda_codec *codec)
364 return __analog_low_current_mode(codec, false);
368 struct hda_codec *codec,
372 analog_low_current_mode(codec);
373 vt1708_update_hp_work(codec);
376 static void via_free(struct hda_codec *codec)
378 vt1708_stop_hp_work(codec);
379 snd_hda_gen_free(codec);
383 static int via_suspend(struct hda_codec *codec)
385 struct via_spec *spec = codec->spec;
386 vt1708_stop_hp_work(codec);
390 snd_hda_shutup_pins(codec);
395 static int via_resume(struct hda_codec *codec)
399 codec->patch_ops.init(codec);
400 snd_hda_regmap_sync(codec);
406 static int via_check_power_status(struct hda_codec *codec, hda_nid_t nid)
408 struct via_spec *spec = codec->spec;
409 analog_low_current_mode(codec);
410 vt1708_update_hp_work(codec);
411 return snd_hda_check_amp_list_power(codec, &spec->gen.loopback, nid);
418 static int via_init(struct hda_codec *codec);
439 static void vt1708_set_pinconfig_connect(struct hda_codec *codec, hda_nid_t nid)
444 def_conf = snd_hda_codec_get_pincfg(codec, nid);
450 snd_hda_codec_set_pincfg(codec, nid, def_conf);
459 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
460 struct via_spec *spec = codec->spec;
471 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
472 struct via_spec *spec = codec->spec;
481 vt1708_update_hp_work(codec);
511 static int via_parse_auto_config(struct hda_codec *codec)
513 struct via_spec *spec = codec->spec;
519 err = snd_hda_parse_pin_defcfg(codec, &spec->gen.autocfg, NULL, 0);
523 err = auto_parse_beep(codec);
527 err = snd_hda_gen_parse_auto_config(codec, &spec->gen.autocfg);
535 codec->power_save_node = 0;
540 static int via_init(struct hda_codec *codec)
543 __analog_low_current_mode(codec, true);
545 snd_hda_gen_init(codec);
547 vt1708_update_hp_work(codec);
552 static int vt1708_build_controls(struct hda_codec *codec)
557 int old_interval = codec->jackpoll_interval;
558 codec->jackpoll_interval = msecs_to_jiffies(100);
559 err = snd_hda_gen_build_controls(codec);
560 codec->jackpoll_interval = old_interval;
564 static int vt1708_build_pcms(struct hda_codec *codec)
566 struct via_spec *spec = codec->spec;
569 err = snd_hda_gen_build_pcms(codec);
570 if (err < 0 || codec->core.vendor_id != 0x11061708)
591 static int patch_vt1708(struct hda_codec *codec)
596 /* create a codec specific record */
597 spec = via_new_spec(codec);
602 codec->patch_ops.build_controls = vt1708_build_controls;
603 codec->patch_ops.build_pcms = vt1708_build_pcms;
606 /* set jackpoll_interval while parsing the codec */
607 codec->jackpoll_interval = msecs_to_jiffies(100);
617 vt1708_set_pinconfig_connect(codec, VT1708_HP_PIN_NID);
618 vt1708_set_pinconfig_connect(codec, VT1708_CD_PIN_NID);
620 err = snd_hda_add_verbs(codec, vt1708_init_verbs);
625 err = via_parse_auto_config(codec);
636 codec->jackpoll_interval = 0;
641 via_free(codec);
645 static int patch_vt1709(struct hda_codec *codec)
650 /* create a codec specific record */
651 spec = via_new_spec(codec);
657 err = via_parse_auto_config(codec);
664 via_free(codec);
668 static int patch_vt1708S(struct hda_codec *codec);
669 static int patch_vt1708B(struct hda_codec *codec)
674 if (get_codec_type(codec) == VT1708BCE)
675 return patch_vt1708S(codec);
677 /* create a codec specific record */
678 spec = via_new_spec(codec);
685 err = via_parse_auto_config(codec);
692 via_free(codec);
705 static void override_mic_boost(struct hda_codec *codec, hda_nid_t pin,
708 snd_hda_override_wcaps(codec, pin,
709 get_wcaps(codec, pin) | AC_WCAP_IN_AMP);
710 snd_hda_override_amp_caps(codec, pin, HDA_INPUT,
717 static int patch_vt1708S(struct hda_codec *codec)
722 /* create a codec specific record */
723 spec = via_new_spec(codec);
728 override_mic_boost(codec, 0x1a, 0, 3, 40);
729 override_mic_boost(codec, 0x1e, 0, 3, 40);
732 if (get_codec_type(codec) == VT1708BCE)
733 snd_hda_codec_set_name(codec, "VT1708BCE");
735 if (codec->core.vendor_id == 0x11064397)
736 snd_hda_codec_set_name(codec, "VT1705");
738 err = snd_hda_add_verbs(codec, vt1708S_init_verbs);
743 err = via_parse_auto_config(codec);
750 via_free(codec);
764 static int patch_vt1702(struct hda_codec *codec)
769 /* create a codec specific record */
770 spec = via_new_spec(codec);
777 snd_hda_override_amp_caps(codec, 0x1A, HDA_INPUT,
783 err = snd_hda_add_verbs(codec, vt1702_init_verbs);
788 err = via_parse_auto_config(codec);
795 via_free(codec);
813 static int add_secret_dac_path(struct hda_codec *codec)
815 struct via_spec *spec = codec->spec;
822 nums = snd_hda_get_connections(codec, spec->gen.mixer_nid, conn,
828 if (get_wcaps_type(get_wcaps(codec, conn[i])) == AC_WID_AUD_OUT)
833 for_each_hda_codec_node(nid, codec) {
834 unsigned int caps = get_wcaps(codec, nid);
838 return snd_hda_override_conn_list(codec,
847 static int patch_vt1718S(struct hda_codec *codec)
852 /* create a codec specific record */
853 spec = via_new_spec(codec);
858 override_mic_boost(codec, 0x2b, 0, 3, 40);
859 override_mic_boost(codec, 0x29, 0, 3, 40);
860 add_secret_dac_path(codec);
862 err = snd_hda_add_verbs(codec, vt1718S_init_verbs);
867 err = via_parse_auto_config(codec);
874 via_free(codec);
893 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
896 index = snd_hda_codec_read(codec, 0x26, 0,
907 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
908 struct via_spec *spec = codec->spec;
911 snd_hda_codec_write(codec, 0x26, 0,
944 static int patch_vt1716S(struct hda_codec *codec)
949 /* create a codec specific record */
950 spec = via_new_spec(codec);
955 override_mic_boost(codec, 0x1a, 0, 3, 40);
956 override_mic_boost(codec, 0x1e, 0, 3, 40);
958 err = snd_hda_add_verbs(codec, vt1716S_init_verbs);
963 err = via_parse_auto_config(codec);
977 via_free(codec);
1012 static void via_fixup_intmic_boost(struct hda_codec *codec,
1016 override_mic_boost(codec, 0x30, 0, 2, 40);
1019 static void via_fixup_power_save(struct hda_codec *codec,
1023 codec->power_save_node = 0;
1057 static void fix_vt1802_connections(struct hda_codec *codec)
1062 snd_hda_override_conn_list(codec, 0x24, ARRAY_SIZE(conn_24), conn_24);
1063 snd_hda_override_conn_list(codec, 0x33, ARRAY_SIZE(conn_33), conn_33);
1067 static int patch_vt2002P(struct hda_codec *codec)
1072 /* create a codec specific record */
1073 spec = via_new_spec(codec);
1078 override_mic_boost(codec, 0x2b, 0, 3, 40);
1079 override_mic_boost(codec, 0x29, 0, 3, 40);
1081 fix_vt1802_connections(codec);
1082 add_secret_dac_path(codec);
1084 snd_hda_pick_fixup(codec, NULL, vt2002p_fixups, via_fixups);
1085 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
1088 err = snd_hda_add_verbs(codec, vt1802_init_verbs);
1090 err = snd_hda_add_verbs(codec, vt2002P_init_verbs);
1095 err = via_parse_auto_config(codec);
1102 via_free(codec);
1117 static int patch_vt1812(struct hda_codec *codec)
1122 /* create a codec specific record */
1123 spec = via_new_spec(codec);
1128 override_mic_boost(codec, 0x2b, 0, 3, 40);
1129 override_mic_boost(codec, 0x29, 0, 3, 40);
1130 add_secret_dac_path(codec);
1132 err = snd_hda_add_verbs(codec, vt1812_init_verbs);
1137 err = via_parse_auto_config(codec);
1144 via_free(codec);
1160 static int patch_vt3476(struct hda_codec *codec)
1165 /* create a codec specific record */
1166 spec = via_new_spec(codec);
1171 add_secret_dac_path(codec);
1173 err = snd_hda_add_verbs(codec, vt3476_init_verbs);
1178 err = via_parse_auto_config(codec);
1185 via_free(codec);
1253 MODULE_DESCRIPTION("VIA HD-audio codec");