Lines Matching +full:gen +full:- +full:2

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)
78 struct hda_gen_spec gen; member
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.pcm_playback_hook = via_playback_pcm_hook; in via_new_spec()
117 spec->gen.add_stereo_mix_input = HDA_HINT_STEREO_MIX_AUTO; in via_new_spec()
118 codec->power_save_node = 1; in via_new_spec()
119 spec->gen.power_down_unused = 1; in via_new_spec()
120 codec->patch_ops = via_patch_ops; in via_new_spec()
126 u32 vendor_id = codec->core.vendor_id; in get_codec_type()
185 struct via_spec *spec = codec->spec; in vt1708_stop_hp_work()
186 if (spec->codec_type != VT1708 || !spec->gen.autocfg.hp_outs) in vt1708_stop_hp_work()
188 if (spec->hp_work_active) { 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()
192 spec->hp_work_active = false; in vt1708_stop_hp_work()
198 struct via_spec *spec = codec->spec; in vt1708_update_hp_work()
199 if (spec->codec_type != VT1708 || !spec->gen.autocfg.hp_outs) in vt1708_update_hp_work()
201 if (spec->vt1708_jack_detect) { in vt1708_update_hp_work()
202 if (!spec->hp_work_active) { in vt1708_update_hp_work()
203 codec->jackpoll_interval = msecs_to_jiffies(100); in vt1708_update_hp_work()
205 schedule_delayed_work(&codec->jackpoll_work, 0); in vt1708_update_hp_work()
206 spec->hp_work_active = true; in vt1708_update_hp_work()
222 struct via_spec *spec = codec->spec; in via_pin_power_ctl_get()
224 ucontrol->value.enumerated.item[0] = spec->gen.power_down_unused; in via_pin_power_ctl_get()
232 struct via_spec *spec = codec->spec; in via_pin_power_ctl_put()
233 bool val = !!ucontrol->value.enumerated.item[0]; in via_pin_power_ctl_put()
235 if (val == spec->gen.power_down_unused) in via_pin_power_ctl_put()
237 /* codec->power_save_node = val; */ /* widget PM seems yet broken */ in via_pin_power_ctl_put()
238 spec->gen.power_down_unused = val; in via_pin_power_ctl_put()
245 .name = "Dynamic Power-Control",
265 spec->gen.beep_nid = nid; in set_beep_amp()
267 knew = snd_hda_gen_add_kctl(&spec->gen, NULL, in set_beep_amp()
270 return -ENOMEM; in set_beep_amp()
271 knew->private_value = beep_amp; in set_beep_amp()
278 struct via_spec *spec = codec->spec; in auto_parse_beep()
293 struct via_spec *spec = codec->spec; in is_aa_path_mute()
297 p = spec->gen.loopback.amplist; in is_aa_path_mute()
300 for (; p->nid; p++) { in is_aa_path_mute()
301 for (ch = 0; ch < 2; ch++) { in is_aa_path_mute()
302 v = snd_hda_codec_amp_read(codec, p->nid, ch, p->dir, in is_aa_path_mute()
303 p->idx); in is_aa_path_mute()
311 /* enter/exit analog low-current mode */
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()
322 if (enable == spec->alc_mode && !force) in __analog_low_current_mode()
324 spec->alc_mode = enable; in __analog_low_current_mode()
327 switch (spec->codec_type) { in __analog_low_current_mode()
331 parm = enable ? 0x02 : 0x00; /* 0x02: 2/3x, 0x00: 1x */ in __analog_low_current_mode()
358 snd_hda_codec_write(codec, codec->core.afg, 0, verb, parm); in __analog_low_current_mode()
384 struct via_spec *spec = codec->spec; in via_suspend()
388 if (spec->codec_type == VT1802) in via_suspend()
398 codec->patch_ops.init(codec); in via_resume()
407 struct via_spec *spec = codec->spec; in via_check_power_status()
410 return snd_hda_check_amp_list_power(codec, &spec->gen.loopback, nid); in via_check_power_status()
459 struct via_spec *spec = codec->spec; in vt1708_jack_detect_get()
461 if (spec->codec_type != VT1708) in vt1708_jack_detect_get()
463 ucontrol->value.integer.value[0] = spec->vt1708_jack_detect; in vt1708_jack_detect_get()
471 struct via_spec *spec = codec->spec; in vt1708_jack_detect_put()
474 if (spec->codec_type != VT1708) in vt1708_jack_detect_put()
476 val = !!ucontrol->value.integer.value[0]; in vt1708_jack_detect_put()
477 if (spec->vt1708_jack_detect == val) in vt1708_jack_detect_put()
479 spec->vt1708_jack_detect = val; in vt1708_jack_detect_put()
512 struct via_spec *spec = codec->spec; in via_parse_auto_config()
515 spec->gen.main_out_badness = &via_main_out_badness; in via_parse_auto_config()
516 spec->gen.extra_out_badness = &via_extra_out_badness; 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()
530 if (!snd_hda_gen_add_kctl(&spec->gen, NULL, &via_pin_power_ctl_enum)) in via_parse_auto_config()
531 return -ENOMEM; in via_parse_auto_config()
534 codec->power_save_node = 0; in via_parse_auto_config()
535 spec->gen.power_down_unused = 0; in via_parse_auto_config()
556 int old_interval = codec->jackpoll_interval; in vt1708_build_controls()
557 codec->jackpoll_interval = msecs_to_jiffies(100); in vt1708_build_controls()
559 codec->jackpoll_interval = old_interval; in vt1708_build_controls()
565 struct via_spec *spec = codec->spec; in vt1708_build_pcms()
569 if (err < 0 || codec->core.vendor_id != 0x11061708) in vt1708_build_pcms()
576 for (i = 0; i < ARRAY_SIZE(spec->gen.pcm_rec); i++) { in vt1708_build_pcms()
577 struct hda_pcm *info = spec->gen.pcm_rec[i]; in vt1708_build_pcms()
580 if (!info->stream[SNDRV_PCM_STREAM_PLAYBACK].substreams || in vt1708_build_pcms()
581 info->pcm_type != HDA_PCM_TYPE_AUDIO) in vt1708_build_pcms()
583 info->stream[SNDRV_PCM_STREAM_PLAYBACK].formats = in vt1708_build_pcms()
598 return -ENOMEM; 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()
603 spec->gen.mixer_nid = 0x17; in patch_vt1708()
606 codec->jackpoll_interval = msecs_to_jiffies(100); in patch_vt1708()
607 spec->vt1708_jack_detect = 1; in patch_vt1708()
611 spec->gen.suppress_auto_mic = 1; in patch_vt1708()
613 spec->gen.auto_mute_via_amp = 1; in patch_vt1708()
615 /* Add HP and CD pin config connect bit re-config action */ in patch_vt1708()
629 if (!snd_hda_gen_add_kctl(&spec->gen, NULL, &vt1708_jack_detect_ctl)) { in patch_vt1708()
630 err = -ENOMEM; in patch_vt1708()
635 codec->jackpoll_interval = 0; in patch_vt1708()
652 return -ENOMEM; in patch_vt1709()
654 spec->gen.mixer_nid = 0x18; in patch_vt1709()
679 return -ENOMEM; in patch_vt1708B()
681 spec->gen.mixer_nid = 0x16; in patch_vt1708B()
724 return -ENOMEM; in patch_vt1708S()
726 spec->gen.mixer_nid = 0x16; in patch_vt1708S()
734 if (codec->core.vendor_id == 0x11064397) in patch_vt1708S()
758 /* GPIO 0~2 */
771 return -ENOMEM; in patch_vt1702()
773 spec->gen.mixer_nid = 0x1a; in patch_vt1702()
809 /* Add a connection to the primary DAC from AA-mixer for some codecs
814 struct via_spec *spec = codec->spec; in add_secret_dac_path()
819 if (!spec->gen.mixer_nid) in add_secret_dac_path()
821 nums = snd_hda_get_connections(codec, spec->gen.mixer_nid, conn, in add_secret_dac_path()
822 ARRAY_SIZE(conn) - 1); in add_secret_dac_path()
835 spec->gen.mixer_nid, in add_secret_dac_path()
851 return -ENOMEM; in patch_vt1718S()
853 spec->gen.mixer_nid = 0x21; in patch_vt1718S()
879 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; in vt1716s_dmic_info()
880 uinfo->count = 1; in vt1716s_dmic_info()
881 uinfo->value.integer.min = 0; in vt1716s_dmic_info()
882 uinfo->value.integer.max = 1; in vt1716s_dmic_info()
894 if (index != -1) in vt1716s_dmic_get()
895 *ucontrol->value.integer.value = index; in vt1716s_dmic_get()
904 struct via_spec *spec = codec->spec; in vt1716s_dmic_put()
905 int index = *ucontrol->value.integer.value; in vt1716s_dmic_put()
909 spec->dmic_enabled = index; in vt1716s_dmic_put()
926 /* mono-out mixer elements */
948 return -ENOMEM; in patch_vt1716S()
950 spec->gen.mixer_nid = 0x16; in patch_vt1716S()
963 if (!snd_hda_gen_add_kctl(&spec->gen, NULL, &vt1716s_dmic_mixer_vol) || in patch_vt1716S()
964 !snd_hda_gen_add_kctl(&spec->gen, NULL, &vt1716s_dmic_mixer_sw) || in patch_vt1716S()
965 !snd_hda_gen_add_kctl(&spec->gen, NULL, &vt1716S_mono_out_mixer)) { in patch_vt1716S()
966 err = -ENOMEM; in patch_vt1716S()
980 /* Class-D speaker related verbs */
1000 * pin fix-up
1011 override_mic_boost(codec, 0x30, 0, 2, 40); in via_fixup_intmic_boost()
1036 /* NIDs 0x24 and 0x33 on VT1802 have connections to non-existing NID 0x3e
1057 return -ENOMEM; in patch_vt2002P()
1059 spec->gen.mixer_nid = 0x21; in patch_vt2002P()
1062 if (spec->codec_type == VT1802) in patch_vt2002P()
1069 if (spec->codec_type == VT1802) in patch_vt2002P()
1107 return -ENOMEM; in patch_vt1812()
1109 spec->gen.mixer_nid = 0x21; in patch_vt1812()
1137 /* Enable AOW-MW9 path */
1150 return -ENOMEM; in patch_vt3476()
1152 spec->gen.mixer_nid = 0x3f; in patch_vt3476()
1179 HDA_CODEC_ENTRY(0x1106e710, "VT1709 10-Ch", patch_vt1709),
1180 HDA_CODEC_ENTRY(0x1106e711, "VT1709 10-Ch", patch_vt1709),
1181 HDA_CODEC_ENTRY(0x1106e712, "VT1709 10-Ch", patch_vt1709),
1182 HDA_CODEC_ENTRY(0x1106e713, "VT1709 10-Ch", patch_vt1709),
1183 HDA_CODEC_ENTRY(0x1106e714, "VT1709 6-Ch", patch_vt1709),
1184 HDA_CODEC_ENTRY(0x1106e715, "VT1709 6-Ch", patch_vt1709),
1185 HDA_CODEC_ENTRY(0x1106e716, "VT1709 6-Ch", patch_vt1709),
1186 HDA_CODEC_ENTRY(0x1106e717, "VT1709 6-Ch", patch_vt1709),
1187 HDA_CODEC_ENTRY(0x1106e720, "VT1708B 8-Ch", patch_vt1708B),
1188 HDA_CODEC_ENTRY(0x1106e721, "VT1708B 8-Ch", patch_vt1708B),
1189 HDA_CODEC_ENTRY(0x1106e722, "VT1708B 8-Ch", patch_vt1708B),
1190 HDA_CODEC_ENTRY(0x1106e723, "VT1708B 8-Ch", patch_vt1708B),
1191 HDA_CODEC_ENTRY(0x1106e724, "VT1708B 4-Ch", patch_vt1708B),
1192 HDA_CODEC_ENTRY(0x1106e725, "VT1708B 4-Ch", patch_vt1708B),
1193 HDA_CODEC_ENTRY(0x1106e726, "VT1708B 4-Ch", patch_vt1708B),
1194 HDA_CODEC_ENTRY(0x1106e727, "VT1708B 4-Ch", patch_vt1708B),
1235 MODULE_DESCRIPTION("VIA HD-audio codec");