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