Lines Matching +full:dac +full:- +full:current +full:- +full:limit +full:- +full:low

1 // SPDX-License-Identifier: GPL-2.0-or-later
7 * (C) 2006-2009 VIA Technology, Inc.
8 * (C) 2006-2008 Takashi Iwai <tiwai@suse.de>
13 /* 2006-03-03 Lydia Wang Create the basic patch to support VT1708 codec */
14 /* 2006-03-14 Lydia Wang Modify hard code for some pin widget nid */
15 /* 2006-08-02 Lydia Wang Add support to VT1709 codec */
16 /* 2006-09-08 Lydia Wang Fix internal loopback recording source select bug */
17 /* 2007-09-12 Lydia Wang Add EAPD enable during driver initialization */
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 */
20 /* 2008-02-03 Lydia Wang Fix Rear channels and Back channels inverse issue */
21 /* 2008-03-06 Lydia Wang Add VT1702 codec and VT1708S codec support */
22 /* 2008-04-09 Lydia Wang Add mute front speaker when HP plugin */
23 /* 2008-04-09 Lydia Wang Add Independent HP feature */
24 /* 2008-05-28 Lydia Wang Add second S/PDIF Out support for VT1702 */
25 /* 2008-09-15 Logan Li Add VT1708S Mic Boost workaround/backdoor */
26 /* 2009-02-16 Logan Li Add support for VT1718S */
27 /* 2009-03-13 Logan Li Add support for VT1716S */
28 /* 2009-04-14 Lydai Wang Add support for VT1828S and VT2020 */
29 /* 2009-07-08 Lydia Wang Add support for VT2002P */
30 /* 2009-07-21 Lydia Wang Add support for VT1812 */
31 /* 2009-09-19 Lydia Wang Add support for VT1818S */
53 UNKNOWN = -1,
73 ((spec)->codec_type == VT2002P ||\
74 (spec)->codec_type == VT1812 ||\
75 (spec)->codec_type == VT1802)
84 /* analog low-power control */
108 codec->spec = spec; in via_new_spec()
109 snd_hda_gen_spec_init(&spec->gen); in via_new_spec()
110 spec->codec_type = get_codec_type(codec); in via_new_spec()
112 if (spec->codec_type == VT1708BCE) in via_new_spec()
113 spec->codec_type = VT1708S; in via_new_spec()
114 spec->gen.indep_hp = 1; in via_new_spec()
115 spec->gen.keep_eapd_on = 1; in via_new_spec()
116 spec->gen.dac_min_mute = 1; in via_new_spec()
117 spec->gen.pcm_playback_hook = via_playback_pcm_hook; in via_new_spec()
118 spec->gen.add_stereo_mix_input = HDA_HINT_STEREO_MIX_AUTO; in via_new_spec()
119 codec->power_save_node = 1; in via_new_spec()
120 spec->gen.power_down_unused = 1; in via_new_spec()
121 codec->patch_ops = via_patch_ops; in via_new_spec()
127 u32 vendor_id = codec->core.vendor_id; in get_codec_type()
186 struct via_spec *spec = codec->spec; in vt1708_stop_hp_work()
187 if (spec->codec_type != VT1708 || !spec->gen.autocfg.hp_outs) in vt1708_stop_hp_work()
189 if (spec->hp_work_active) { 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()
193 spec->hp_work_active = false; in vt1708_stop_hp_work()
199 struct via_spec *spec = codec->spec; in vt1708_update_hp_work()
200 if (spec->codec_type != VT1708 || !spec->gen.autocfg.hp_outs) in vt1708_update_hp_work()
202 if (spec->vt1708_jack_detect) { in vt1708_update_hp_work()
203 if (!spec->hp_work_active) { in vt1708_update_hp_work()
204 codec->jackpoll_interval = msecs_to_jiffies(100); in vt1708_update_hp_work()
206 schedule_delayed_work(&codec->jackpoll_work, 0); in vt1708_update_hp_work()
207 spec->hp_work_active = true; in vt1708_update_hp_work()
223 struct via_spec *spec = codec->spec; in via_pin_power_ctl_get()
225 ucontrol->value.enumerated.item[0] = spec->gen.power_down_unused; in via_pin_power_ctl_get()
233 struct via_spec *spec = codec->spec; in via_pin_power_ctl_put()
234 bool val = !!ucontrol->value.enumerated.item[0]; in via_pin_power_ctl_put()
236 if (val == spec->gen.power_down_unused) in via_pin_power_ctl_put()
238 /* codec->power_save_node = val; */ /* widget PM seems yet broken */ in via_pin_power_ctl_put()
239 spec->gen.power_down_unused = val; in via_pin_power_ctl_put()
246 .name = "Dynamic Power-Control",
266 spec->gen.beep_nid = nid; in set_beep_amp()
268 knew = snd_hda_gen_add_kctl(&spec->gen, NULL, in set_beep_amp()
271 return -ENOMEM; in set_beep_amp()
272 knew->private_value = beep_amp; in set_beep_amp()
279 struct via_spec *spec = codec->spec; in auto_parse_beep()
294 struct via_spec *spec = codec->spec; in is_aa_path_mute()
298 p = spec->gen.loopback.amplist; in is_aa_path_mute()
301 for (; p->nid; p++) { in is_aa_path_mute()
303 v = snd_hda_codec_amp_read(codec, p->nid, ch, p->dir, in is_aa_path_mute()
304 p->idx); in is_aa_path_mute()
312 /* enter/exit analog low-current mode */
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()
323 if (enable == spec->alc_mode && !force) in __analog_low_current_mode()
325 spec->alc_mode = enable; in __analog_low_current_mode()
327 /* decide low current mode's verb & parameter */ in __analog_low_current_mode()
328 switch (spec->codec_type) { in __analog_low_current_mode()
359 snd_hda_codec_write(codec, codec->core.afg, 0, verb, parm); in __analog_low_current_mode()
385 struct via_spec *spec = codec->spec; in via_suspend()
389 if (spec->codec_type == VT1802) in via_suspend()
399 codec->patch_ops.init(codec); in via_resume()
408 struct via_spec *spec = codec->spec; in via_check_power_status()
411 return snd_hda_check_amp_list_power(codec, &spec->gen.loopback, nid); in via_check_power_status()
458 struct via_spec *spec = codec->spec; in vt1708_jack_detect_get()
460 if (spec->codec_type != VT1708) in vt1708_jack_detect_get()
462 ucontrol->value.integer.value[0] = spec->vt1708_jack_detect; in vt1708_jack_detect_get()
470 struct via_spec *spec = codec->spec; in vt1708_jack_detect_put()
473 if (spec->codec_type != VT1708) in vt1708_jack_detect_put()
475 val = !!ucontrol->value.integer.value[0]; in vt1708_jack_detect_put()
476 if (spec->vt1708_jack_detect == val) in vt1708_jack_detect_put()
478 spec->vt1708_jack_detect = val; in vt1708_jack_detect_put()
511 struct via_spec *spec = codec->spec; in via_parse_auto_config()
514 spec->gen.main_out_badness = &via_main_out_badness; in via_parse_auto_config()
515 spec->gen.extra_out_badness = &via_extra_out_badness; in via_parse_auto_config()
517 err = snd_hda_parse_pin_defcfg(codec, &spec->gen.autocfg, NULL, 0); in via_parse_auto_config()
525 err = snd_hda_gen_parse_auto_config(codec, &spec->gen.autocfg); in via_parse_auto_config()
529 if (!snd_hda_gen_add_kctl(&spec->gen, NULL, &via_pin_power_ctl_enum)) in via_parse_auto_config()
530 return -ENOMEM; in via_parse_auto_config()
533 codec->power_save_node = 0; in via_parse_auto_config()
534 spec->gen.power_down_unused = 0; in via_parse_auto_config()
555 int old_interval = codec->jackpoll_interval; in vt1708_build_controls()
556 codec->jackpoll_interval = msecs_to_jiffies(100); in vt1708_build_controls()
558 codec->jackpoll_interval = old_interval; in vt1708_build_controls()
564 struct via_spec *spec = codec->spec; in vt1708_build_pcms()
568 if (err < 0 || codec->core.vendor_id != 0x11061708) in vt1708_build_pcms()
575 for (i = 0; i < ARRAY_SIZE(spec->gen.pcm_rec); i++) { in vt1708_build_pcms()
576 struct hda_pcm *info = spec->gen.pcm_rec[i]; in vt1708_build_pcms()
579 if (!info->stream[SNDRV_PCM_STREAM_PLAYBACK].substreams || in vt1708_build_pcms()
580 info->pcm_type != HDA_PCM_TYPE_AUDIO) in vt1708_build_pcms()
582 info->stream[SNDRV_PCM_STREAM_PLAYBACK].formats = in vt1708_build_pcms()
597 return -ENOMEM; in patch_vt1708()
600 codec->patch_ops.build_controls = vt1708_build_controls; in patch_vt1708()
601 codec->patch_ops.build_pcms = vt1708_build_pcms; in patch_vt1708()
602 spec->gen.mixer_nid = 0x17; in patch_vt1708()
605 codec->jackpoll_interval = msecs_to_jiffies(100); in patch_vt1708()
606 spec->vt1708_jack_detect = 1; in patch_vt1708()
610 spec->gen.suppress_auto_mic = 1; in patch_vt1708()
612 spec->gen.auto_mute_via_amp = 1; in patch_vt1708()
614 /* Add HP and CD pin config connect bit re-config action */ in patch_vt1708()
628 if (!snd_hda_gen_add_kctl(&spec->gen, NULL, &vt1708_jack_detect_ctl)) { in patch_vt1708()
629 err = -ENOMEM; in patch_vt1708()
634 codec->jackpoll_interval = 0; in patch_vt1708()
651 return -ENOMEM; in patch_vt1709()
653 spec->gen.mixer_nid = 0x18; in patch_vt1709()
678 return -ENOMEM; in patch_vt1708B()
680 spec->gen.mixer_nid = 0x16; in patch_vt1708B()
723 return -ENOMEM; in patch_vt1708S()
725 spec->gen.mixer_nid = 0x16; in patch_vt1708S()
733 if (codec->core.vendor_id == 0x11064397) in patch_vt1708S()
770 return -ENOMEM; in patch_vt1702()
772 spec->gen.mixer_nid = 0x1a; in patch_vt1702()
774 /* limit AA path volume to 0 dB */ in patch_vt1702()
808 /* Add a connection to the primary DAC from AA-mixer for some codecs
813 struct via_spec *spec = codec->spec; in add_secret_dac_path()
818 if (!spec->gen.mixer_nid) in add_secret_dac_path()
820 nums = snd_hda_get_connections(codec, spec->gen.mixer_nid, conn, in add_secret_dac_path()
821 ARRAY_SIZE(conn) - 1); in add_secret_dac_path()
830 /* find the primary DAC and add to the connection list */ in add_secret_dac_path()
837 spec->gen.mixer_nid, in add_secret_dac_path()
853 return -ENOMEM; in patch_vt1718S()
855 spec->gen.mixer_nid = 0x21; in patch_vt1718S()
881 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; in vt1716s_dmic_info()
882 uinfo->count = 1; in vt1716s_dmic_info()
883 uinfo->value.integer.min = 0; in vt1716s_dmic_info()
884 uinfo->value.integer.max = 1; in vt1716s_dmic_info()
896 if (index != -1) in vt1716s_dmic_get()
897 *ucontrol->value.integer.value = index; in vt1716s_dmic_get()
906 struct via_spec *spec = codec->spec; in vt1716s_dmic_put()
907 int index = *ucontrol->value.integer.value; in vt1716s_dmic_put()
911 spec->dmic_enabled = index; in vt1716s_dmic_put()
928 /* mono-out mixer elements */
950 return -ENOMEM; in patch_vt1716S()
952 spec->gen.mixer_nid = 0x16; in patch_vt1716S()
965 if (!snd_hda_gen_add_kctl(&spec->gen, NULL, &vt1716s_dmic_mixer_vol) || in patch_vt1716S()
966 !snd_hda_gen_add_kctl(&spec->gen, NULL, &vt1716s_dmic_mixer_sw) || in patch_vt1716S()
967 !snd_hda_gen_add_kctl(&spec->gen, NULL, &vt1716S_mono_out_mixer)) { in patch_vt1716S()
968 err = -ENOMEM; in patch_vt1716S()
982 /* Class-D speaker related verbs */
1002 * pin fix-up
1021 codec->power_save_node = 0; in via_fixup_power_save()
1052 /* NIDs 0x24 and 0x33 on VT1802 have connections to non-existing NID 0x3e
1073 return -ENOMEM; in patch_vt2002P()
1075 spec->gen.mixer_nid = 0x21; in patch_vt2002P()
1078 if (spec->codec_type == VT1802) in patch_vt2002P()
1085 if (spec->codec_type == VT1802) in patch_vt2002P()
1123 return -ENOMEM; in patch_vt1812()
1125 spec->gen.mixer_nid = 0x21; in patch_vt1812()
1153 /* Enable AOW-MW9 path */
1166 return -ENOMEM; in patch_vt3476()
1168 spec->gen.mixer_nid = 0x3f; in patch_vt3476()
1195 HDA_CODEC_ENTRY(0x1106e710, "VT1709 10-Ch", patch_vt1709),
1196 HDA_CODEC_ENTRY(0x1106e711, "VT1709 10-Ch", patch_vt1709),
1197 HDA_CODEC_ENTRY(0x1106e712, "VT1709 10-Ch", patch_vt1709),
1198 HDA_CODEC_ENTRY(0x1106e713, "VT1709 10-Ch", patch_vt1709),
1199 HDA_CODEC_ENTRY(0x1106e714, "VT1709 6-Ch", patch_vt1709),
1200 HDA_CODEC_ENTRY(0x1106e715, "VT1709 6-Ch", patch_vt1709),
1201 HDA_CODEC_ENTRY(0x1106e716, "VT1709 6-Ch", patch_vt1709),
1202 HDA_CODEC_ENTRY(0x1106e717, "VT1709 6-Ch", patch_vt1709),
1203 HDA_CODEC_ENTRY(0x1106e720, "VT1708B 8-Ch", patch_vt1708B),
1204 HDA_CODEC_ENTRY(0x1106e721, "VT1708B 8-Ch", patch_vt1708B),
1205 HDA_CODEC_ENTRY(0x1106e722, "VT1708B 8-Ch", patch_vt1708B),
1206 HDA_CODEC_ENTRY(0x1106e723, "VT1708B 8-Ch", patch_vt1708B),
1207 HDA_CODEC_ENTRY(0x1106e724, "VT1708B 4-Ch", patch_vt1708B),
1208 HDA_CODEC_ENTRY(0x1106e725, "VT1708B 4-Ch", patch_vt1708B),
1209 HDA_CODEC_ENTRY(0x1106e726, "VT1708B 4-Ch", patch_vt1708B),
1210 HDA_CODEC_ENTRY(0x1106e727, "VT1708B 4-Ch", patch_vt1708B),
1251 MODULE_DESCRIPTION("VIA HD-audio codec");