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);
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);
457 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
458 struct via_spec *spec = codec->spec;
469 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
470 struct via_spec *spec = codec->spec;
479 vt1708_update_hp_work(codec);
509 static int via_parse_auto_config(struct hda_codec *codec)
511 struct via_spec *spec = codec->spec;
517 err = snd_hda_parse_pin_defcfg(codec, &spec->gen.autocfg, NULL, 0);
521 err = auto_parse_beep(codec);
525 err = snd_hda_gen_parse_auto_config(codec, &spec->gen.autocfg);
533 codec->power_save_node = 0;
538 static int via_init(struct hda_codec *codec)
541 __analog_low_current_mode(codec, true);
543 snd_hda_gen_init(codec);
545 vt1708_update_hp_work(codec);
550 static int vt1708_build_controls(struct hda_codec *codec)
555 int old_interval = codec->jackpoll_interval;
556 codec->jackpoll_interval = msecs_to_jiffies(100);
557 err = snd_hda_gen_build_controls(codec);
558 codec->jackpoll_interval = old_interval;
562 static int vt1708_build_pcms(struct hda_codec *codec)
564 struct via_spec *spec = codec->spec;
567 err = snd_hda_gen_build_pcms(codec);
568 if (err < 0 || codec->core.vendor_id != 0x11061708)
589 static int patch_vt1708(struct hda_codec *codec)
594 /* create a codec specific record */
595 spec = via_new_spec(codec);
600 codec->patch_ops.build_controls = vt1708_build_controls;
601 codec->patch_ops.build_pcms = vt1708_build_pcms;
604 /* set jackpoll_interval while parsing the codec */
605 codec->jackpoll_interval = msecs_to_jiffies(100);
615 vt1708_set_pinconfig_connect(codec, VT1708_HP_PIN_NID);
616 vt1708_set_pinconfig_connect(codec, VT1708_CD_PIN_NID);
618 err = snd_hda_add_verbs(codec, vt1708_init_verbs);
623 err = via_parse_auto_config(codec);
634 codec->jackpoll_interval = 0;
639 via_free(codec);
643 static int patch_vt1709(struct hda_codec *codec)
648 /* create a codec specific record */
649 spec = via_new_spec(codec);
655 err = via_parse_auto_config(codec);
662 via_free(codec);
666 static int patch_vt1708S(struct hda_codec *codec);
667 static int patch_vt1708B(struct hda_codec *codec)
672 if (get_codec_type(codec) == VT1708BCE)
673 return patch_vt1708S(codec);
675 /* create a codec specific record */
676 spec = via_new_spec(codec);
683 err = via_parse_auto_config(codec);
690 via_free(codec);
703 static void override_mic_boost(struct hda_codec *codec, hda_nid_t pin,
706 snd_hda_override_wcaps(codec, pin,
707 get_wcaps(codec, pin) | AC_WCAP_IN_AMP);
708 snd_hda_override_amp_caps(codec, pin, HDA_INPUT,
715 static int patch_vt1708S(struct hda_codec *codec)
720 /* create a codec specific record */
721 spec = via_new_spec(codec);
726 override_mic_boost(codec, 0x1a, 0, 3, 40);
727 override_mic_boost(codec, 0x1e, 0, 3, 40);
730 if (get_codec_type(codec) == VT1708BCE)
731 snd_hda_codec_set_name(codec, "VT1708BCE");
733 if (codec->core.vendor_id == 0x11064397)
734 snd_hda_codec_set_name(codec, "VT1705");
736 err = snd_hda_add_verbs(codec, vt1708S_init_verbs);
741 err = via_parse_auto_config(codec);
748 via_free(codec);
762 static int patch_vt1702(struct hda_codec *codec)
767 /* create a codec specific record */
768 spec = via_new_spec(codec);
775 snd_hda_override_amp_caps(codec, 0x1A, HDA_INPUT,
781 err = snd_hda_add_verbs(codec, vt1702_init_verbs);
786 err = via_parse_auto_config(codec);
793 via_free(codec);
811 static int add_secret_dac_path(struct hda_codec *codec)
813 struct via_spec *spec = codec->spec;
820 nums = snd_hda_get_connections(codec, spec->gen.mixer_nid, conn,
826 if (get_wcaps_type(get_wcaps(codec, conn[i])) == AC_WID_AUD_OUT)
831 for_each_hda_codec_node(nid, codec) {
832 unsigned int caps = get_wcaps(codec, nid);
836 return snd_hda_override_conn_list(codec,
845 static int patch_vt1718S(struct hda_codec *codec)
850 /* create a codec specific record */
851 spec = via_new_spec(codec);
856 override_mic_boost(codec, 0x2b, 0, 3, 40);
857 override_mic_boost(codec, 0x29, 0, 3, 40);
858 add_secret_dac_path(codec);
860 err = snd_hda_add_verbs(codec, vt1718S_init_verbs);
865 err = via_parse_auto_config(codec);
872 via_free(codec);
891 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
894 index = snd_hda_codec_read(codec, 0x26, 0,
905 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
906 struct via_spec *spec = codec->spec;
909 snd_hda_codec_write(codec, 0x26, 0,
942 static int patch_vt1716S(struct hda_codec *codec)
947 /* create a codec specific record */
948 spec = via_new_spec(codec);
953 override_mic_boost(codec, 0x1a, 0, 3, 40);
954 override_mic_boost(codec, 0x1e, 0, 3, 40);
956 err = snd_hda_add_verbs(codec, vt1716S_init_verbs);
961 err = via_parse_auto_config(codec);
975 via_free(codec);
1010 static void via_fixup_intmic_boost(struct hda_codec *codec,
1014 override_mic_boost(codec, 0x30, 0, 2, 40);
1017 static void via_fixup_power_save(struct hda_codec *codec,
1021 codec->power_save_node = 0;
1055 static void fix_vt1802_connections(struct hda_codec *codec)
1060 snd_hda_override_conn_list(codec, 0x24, ARRAY_SIZE(conn_24), conn_24);
1061 snd_hda_override_conn_list(codec, 0x33, ARRAY_SIZE(conn_33), conn_33);
1065 static int patch_vt2002P(struct hda_codec *codec)
1070 /* create a codec specific record */
1071 spec = via_new_spec(codec);
1076 override_mic_boost(codec, 0x2b, 0, 3, 40);
1077 override_mic_boost(codec, 0x29, 0, 3, 40);
1079 fix_vt1802_connections(codec);
1080 add_secret_dac_path(codec);
1082 snd_hda_pick_fixup(codec, NULL, vt2002p_fixups, via_fixups);
1083 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
1086 err = snd_hda_add_verbs(codec, vt1802_init_verbs);
1088 err = snd_hda_add_verbs(codec, vt2002P_init_verbs);
1093 err = via_parse_auto_config(codec);
1100 via_free(codec);
1115 static int patch_vt1812(struct hda_codec *codec)
1120 /* create a codec specific record */
1121 spec = via_new_spec(codec);
1126 override_mic_boost(codec, 0x2b, 0, 3, 40);
1127 override_mic_boost(codec, 0x29, 0, 3, 40);
1128 add_secret_dac_path(codec);
1130 err = snd_hda_add_verbs(codec, vt1812_init_verbs);
1135 err = via_parse_auto_config(codec);
1142 via_free(codec);
1158 static int patch_vt3476(struct hda_codec *codec)
1163 /* create a codec specific record */
1164 spec = via_new_spec(codec);
1169 add_secret_dac_path(codec);
1171 err = snd_hda_add_verbs(codec, vt3476_init_verbs);
1176 err = via_parse_auto_config(codec);
1183 via_free(codec);
1251 MODULE_DESCRIPTION("VIA HD-audio codec");