51 #include <linux/slab.h>
52 #include <linux/module.h>
61 #define VT1708_HP_PIN_NID 0x20
62 #define VT1708_CD_PIN_NID 0x24
82 #define VT2002P_COMPATIBLE(spec) \
83 ((spec)->codec_type == VT2002P ||\
84 (spec)->codec_type == VT1812 ||\
85 (spec)->codec_type == VT1802)
87 #define MAX_NID_PATH_DEPTH 5
113 #define VIA_MAX_ADCS 3
251 snd_hda_gen_init(&spec->
gen);
258 u16 ven_id = vendor_id >> 16;
263 if (ven_id != 0x1106)
265 else if (dev_id >= 0x1708 && dev_id <= 0x170b)
267 else if (dev_id >= 0xe710 && dev_id <= 0xe713)
269 else if (dev_id >= 0xe714 && dev_id <= 0xe717)
271 else if (dev_id >= 0xe720 && dev_id <= 0xe723) {
275 }
else if (dev_id >= 0xe724 && dev_id <= 0xe727)
277 else if ((dev_id & 0xfff) == 0x397
278 && (dev_id >> 12) < 8)
280 else if ((dev_id & 0xfff) == 0x398
281 && (dev_id >> 12) < 8)
283 else if ((dev_id & 0xfff) == 0x428
284 && (dev_id >> 12) < 8)
286 else if (dev_id == 0x0433 || dev_id == 0xa721)
288 else if (dev_id == 0x0441 || dev_id == 0x4441)
290 else if (dev_id == 0x0438 || dev_id == 0x4438)
292 else if (dev_id == 0x0448)
294 else if (dev_id == 0x0440)
296 else if ((dev_id & 0xfff) == 0x446)
303 #define VIA_JACK_EVENT 0x20
304 #define VIA_HP_EVENT 0x01
305 #define VIA_LINE_EVENT 0x03
313 static void analog_low_current_mode(
struct hda_codec *codec);
314 static bool is_aa_path_mute(
struct hda_codec *codec);
316 #define hp_detect_with_aa(codec) \
317 (snd_hda_get_bool_hint(codec, "analog_loopback_hp_detect") == 1 && \
318 !is_aa_path_mute(codec))
320 static void vt1708_stop_hp_work(
struct via_spec *spec)
331 static void vt1708_update_hp_work(
struct via_spec *spec)
344 vt1708_stop_hp_work(spec);
354 static int analog_input_switch_put(
struct snd_kcontrol *kcontrol,
360 set_widgets_power_state(codec);
362 vt1708_update_hp_work(codec->
spec);
367 #define ANALOG_INPUT_MUTE \
368 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
371 .info = snd_hda_mixer_amp_switch_info, \
372 .get = snd_hda_mixer_amp_switch_get, \
373 .put = analog_input_switch_put, \
374 .private_value = HDA_COMPOSE_AMP_VAL(0, 3, 0, 0) }
390 snd_array_init(&spec->
kctls,
sizeof(*knew), 32);
405 static int __via_add_control(
struct via_spec *spec,
int type,
const char *name,
406 int idx,
unsigned long val)
410 knew = __via_clone_ctl(spec, &via_control_templates[type], name);
420 #define via_add_control(spec, type, name, val) \
421 __via_add_control(spec, type, name, 0, val)
423 #define via_clone_control(spec, tmpl) __via_clone_ctl(spec, tmpl, NULL)
425 static void via_free_kctls(
struct hda_codec *codec)
429 if (spec->
kctls.list) {
432 for (i = 0; i < spec->
kctls.used; i++)
439 static int via_new_analog_input(
struct via_spec *spec,
const char *ctlname,
440 int type_idx,
int idx,
int mix_nid)
445 sprintf(name,
"%s Playback Volume", ctlname);
450 sprintf(name,
"%s Playback Switch", ctlname);
458 #define get_connection_index(codec, mux, nid) \
459 snd_hda_get_conn_index(codec, mux, nid, 0)
467 caps = get_wcaps(codec, nid);
479 #define have_mute(codec, nid, dir) \
480 check_amp_caps(codec, nid, dir, AC_AMPCAP_MUTE)
490 num = snd_hda_get_num_conns(codec, mix_nid);
491 for (i = 0; i < num; i++) {
507 for (i = 0; i < path->
depth; i++) {
509 int idx = path->
idx[
i];
511 if (i < path->
depth - 1)
512 dst = path->
path[i + 1];
515 if (enable && path->
multi[i])
521 activate_output_mix(codec, path, dst, idx, enable);
538 snd_hda_set_pin_ctl(codec, pin, pin_type);
544 static void via_auto_init_output(
struct hda_codec *codec,
545 struct nid_path *path,
int pin_type)
554 init_output_pin(codec, pin, pin_type);
565 activate_output_path(codec, path,
true,
true);
568 static void via_auto_init_multi_out(
struct hda_codec *codec)
578 via_auto_init_output(codec, path,
PIN_OUT);
583 static void deactivate_hp_paths(
struct hda_codec *codec)
589 activate_output_path(codec, &spec->
hp_path,
false,
false);
590 activate_output_path(codec, &spec->
hp_mix_path,
false,
false);
592 activate_output_path(codec, &spec->
out_path[shared],
595 activate_output_path(codec, &spec->
hp_indep_path,
false,
false);
596 activate_output_path(codec, &spec->
hp_path,
false,
false);
598 activate_output_path(codec, &spec->
hp_indep_path,
false,
false);
599 activate_output_path(codec, &spec->
hp_mix_path,
false,
false);
603 static void via_auto_init_hp_out(
struct hda_codec *codec)
611 deactivate_hp_paths(codec);
620 static void via_auto_init_speaker_out(
struct hda_codec *codec)
624 if (!spec->
autocfg.speaker_outs)
635 activate_output_path(codec, &spec->
speaker_path,
false,
false);
641 static void via_hp_automute(
struct hda_codec *codec);
643 static void via_auto_init_analog_input(
struct hda_codec *codec)
672 snd_hda_set_pin_ctl(codec, nid, ctl);
696 for (i = 0; i < num_conns; i++) {
697 unsigned int caps = get_wcaps(codec, conn[i]);
715 unsigned int *affected_parm)
723 unsigned present = 0;
729 || ((no_presence || present)
736 update_power_state(codec, nid, parm);
739 static int via_pin_power_ctl_info(
struct snd_kcontrol *kcontrol,
742 static const char *
const texts[] = {
743 "Disabled",
"Enabled"
756 static int via_pin_power_ctl_get(
struct snd_kcontrol *kcontrol,
765 static int via_pin_power_ctl_put(
struct snd_kcontrol *kcontrol,
770 unsigned int val = !ucontrol->
value.enumerated.item[0];
776 analog_low_current_mode(codec);
782 .name =
"Dynamic Power-Control",
783 .info = via_pin_power_ctl_info,
784 .get = via_pin_power_ctl_get,
785 .put = via_pin_power_ctl_put,
789 static int via_independent_hp_info(
struct snd_kcontrol *kcontrol,
792 static const char *
const texts[] = {
"OFF",
"ON" };
804 static int via_independent_hp_get(
struct snd_kcontrol *kcontrol,
815 static void setup_playback_multi_pcm(
struct via_spec *spec)
832 static void switch_indep_hp_dacs(
struct hda_codec *codec)
872 setup_playback_multi_pcm(spec);
875 static int via_independent_hp_put(
struct snd_kcontrol *kcontrol,
883 cur = !!ucontrol->
value.enumerated.item[0];
890 deactivate_hp_paths(codec);
892 activate_output_path(codec, &spec->
hp_indep_path,
true,
false);
895 activate_output_path(codec, &spec->
out_path[shared],
901 activate_output_path(codec, &spec->
hp_path,
905 switch_indep_hp_dacs(codec);
910 via_hp_automute(codec);
916 .name =
"Independent HP",
917 .info = via_independent_hp_info,
918 .get = via_independent_hp_get,
919 .put = via_independent_hp_put,
922 static int via_hp_build(
struct hda_codec *codec)
928 nid = spec->
autocfg.hp_pins[0];
938 static void notify_aa_path_ctls(
struct hda_codec *codec)
946 memset(&
id, 0,
sizeof(
id));
984 static int via_smart51_get(
struct snd_kcontrol *kcontrol,
994 static int via_smart51_put(
struct snd_kcontrol *kcontrol,
999 int out_in = *ucontrol->
value.integer.value
1011 snd_hda_set_pin_ctl(codec, nid, parm);
1013 mute_aa_path(codec, 1);
1014 notify_aa_path_ctls(codec);
1024 .name =
"Smart 5.1",
1027 .get = via_smart51_get,
1028 .put = via_smart51_put,
1031 static int via_smart51_build(
struct hda_codec *codec)
1043 static bool is_aa_path_mute(
struct hda_codec *codec)
1051 for (ch = 0; ch < 2; ch++) {
1062 static void __analog_low_current_mode(
struct hda_codec *codec,
bool force)
1072 if (enable == spec->
alc_mode && !force)
1081 parm = enable ? 0x02 : 0x00;
1087 parm = enable ? 0x51 : 0xe1;
1091 parm = enable ? 0x01 : 0x1d;
1097 parm = enable ? 0x00 : 0xe0;
1106 static void analog_low_current_mode(
struct hda_codec *codec)
1108 return __analog_low_current_mode(codec,
false);
1114 static const struct hda_verb vt1708_init_verbs[] = {
1128 analog_low_current_mode(codec);
1131 static int via_playback_multi_pcm_open(
struct hda_pcm_stream *hinfo,
1151 static int via_playback_multi_pcm_close(
struct hda_pcm_stream *hinfo,
1159 static int via_playback_hp_pcm_open(
struct hda_pcm_stream *hinfo,
1171 static int via_playback_hp_pcm_close(
struct hda_pcm_stream *hinfo,
1179 static int via_playback_multi_pcm_prepare(
struct hda_pcm_stream *hinfo,
1181 unsigned int stream_tag,
1188 setup_playback_multi_pcm(spec);
1196 vt1708_update_hp_work(spec);
1200 static int via_playback_hp_pcm_prepare(
struct hda_pcm_stream *hinfo,
1202 unsigned int stream_tag,
1211 stream_tag, 0, format);
1216 vt1708_update_hp_work(spec);
1220 static int via_playback_multi_pcm_cleanup(
struct hda_pcm_stream *hinfo,
1230 vt1708_update_hp_work(spec);
1234 static int via_playback_hp_pcm_cleanup(
struct hda_pcm_stream *hinfo,
1245 vt1708_update_hp_work(spec);
1252 static int via_dig_playback_pcm_open(
struct hda_pcm_stream *hinfo,
1260 static int via_dig_playback_pcm_close(
struct hda_pcm_stream *hinfo,
1268 static int via_dig_playback_pcm_prepare(
struct hda_pcm_stream *hinfo,
1270 unsigned int stream_tag,
1271 unsigned int format,
1276 stream_tag, format, substream);
1279 static int via_dig_playback_pcm_cleanup(
struct hda_pcm_stream *hinfo,
1293 unsigned int stream_tag,
1294 unsigned int format,
1300 stream_tag, 0, format);
1314 static int via_dyn_adc_capture_pcm_prepare(
struct hda_pcm_stream *hinfo,
1316 unsigned int stream_tag,
1317 unsigned int format,
1332 static int via_dyn_adc_capture_pcm_cleanup(
struct hda_pcm_stream *hinfo,
1346 static bool via_dyn_adc_pcm_resetup(
struct hda_codec *codec,
int cur)
1349 int adc_idx = spec->
inputs[
cur].adc_idx;
1373 .open = via_playback_multi_pcm_open,
1374 .close = via_playback_multi_pcm_close,
1375 .prepare = via_playback_multi_pcm_prepare,
1376 .cleanup = via_playback_multi_pcm_cleanup
1386 .open = via_playback_hp_pcm_open,
1387 .close = via_playback_hp_pcm_close,
1388 .prepare = via_playback_hp_pcm_prepare,
1389 .cleanup = via_playback_hp_pcm_cleanup
1393 static const struct hda_pcm_stream vt1708_pcm_analog_s16_playback = {
1404 .open = via_playback_multi_pcm_open,
1405 .close = via_playback_multi_pcm_close,
1406 .prepare = via_playback_multi_pcm_prepare,
1407 .cleanup = via_playback_multi_pcm_cleanup
1417 .prepare = via_capture_pcm_prepare,
1418 .cleanup = via_capture_pcm_cleanup
1422 static const struct hda_pcm_stream via_pcm_dyn_adc_analog_capture = {
1428 .prepare = via_dyn_adc_capture_pcm_prepare,
1429 .cleanup = via_dyn_adc_capture_pcm_cleanup,
1439 .open = via_dig_playback_pcm_open,
1440 .close = via_dig_playback_pcm_close,
1441 .prepare = via_dig_playback_pcm_prepare,
1442 .cleanup = via_dig_playback_pcm_cleanup
1455 static const char *
const via_slave_pfxs[] = {
1456 "Front",
"Surround",
"Center",
"LFE",
"Side",
1457 "Headphone",
"Speaker",
1461 static int via_build_controls(
struct hda_codec *codec)
1498 unsigned int vmaster_tlv[4];
1502 vmaster_tlv, via_slave_pfxs,
1509 NULL, via_slave_pfxs,
1517 for (i = 0; kctl && i < kctl->
count; i++) {
1525 via_free_kctls(codec);
1534 static int via_build_pcms(
struct hda_codec *codec)
1551 &via_pcm_analog_playback;
1563 &via_pcm_dyn_adc_analog_capture;
1566 &via_pcm_analog_capture;
1590 &via_pcm_digital_playback;
1599 &via_pcm_digital_capture;
1622 static void via_free(
struct hda_codec *codec)
1629 via_free_kctls(codec);
1630 vt1708_stop_hp_work(spec);
1633 snd_hda_gen_free(&spec->
gen);
1638 static void toggle_output_mutes(
struct hda_codec *codec,
int num_pins,
1642 for (i = 0; i < num_pins; i++) {
1651 snd_hda_set_pin_ctl(codec, pins[i], parm);
1656 static void via_line_automute(
struct hda_codec *codec,
int present)
1660 if (!spec->
autocfg.speaker_outs)
1664 spec->
autocfg.line_out_pins[0]);
1665 toggle_output_mutes(codec, spec->
autocfg.speaker_outs,
1671 static void via_hp_automute(
struct hda_codec *codec)
1685 nums = spec->
autocfg.line_outs;
1686 toggle_output_mutes(codec, nums, spec->
autocfg.line_out_pins, present);
1688 via_line_automute(codec, present);
1692 static int via_suspend(
struct hda_codec *codec)
1695 vt1708_stop_hp_work(spec);
1700 for (i = 0; i < spec->
autocfg.hp_outs; i++)
1701 snd_hda_set_pin_ctl(codec, spec->
autocfg.hp_pins[i], 0);
1722 .build_controls = via_build_controls,
1723 .build_pcms = via_build_pcms,
1728 .suspend = via_suspend,
1729 .check_power_status = via_check_power_status,
1738 for (i = 0; i < spec->
multiout.num_dacs; i++) {
1739 if (spec->
multiout.dac_nids[i] == dac)
1762 for (i = 0; i < nums; i++) {
1765 if (conn[i] == target_dac || is_empty_dac(codec, conn[i])) {
1773 for (i = 0; i < nums; i++) {
1775 type = get_wcaps_type(get_wcaps(codec, conn[i]));
1778 if (__parse_output_path(codec, conn[i], target_dac,
1779 with_aa_mix, path, depth + 1))
1787 if (nums > 1 && get_wcaps_type(get_wcaps(codec, nid)) !=
AC_WID_AUD_MIX)
1797 if (__parse_output_path(codec, nid, target_dac, with_aa_mix, path, 1)) {
1800 snd_printdd(
"output-path: depth=%d, %02x/%02x/%02x/%02x/%02x\n",
1808 static int via_auto_fill_dac_nids(
struct hda_codec *codec)
1822 if (parse_output_path(codec, nid, 0, 0, &spec->
out_path[i]))
1824 if (!i && parse_output_path(codec, nid, dac, 1,
1837 static int create_ch_ctls(
struct hda_codec *codec,
const char *pfx,
1838 int chs,
bool check_dac,
struct nid_path *path)
1845 dac = check_dac ? path->
path[0] : 0;
1847 sel = path->
depth > 1 ? path->
path[1] : 0;
1858 sprintf(name,
"%s Playback Volume", pfx);
1866 if (dac && check_amp_caps(codec, dac,
HDA_OUTPUT, AC_AMPCAP_MUTE))
1868 else if (check_amp_caps(codec, pin,
HDA_OUTPUT, AC_AMPCAP_MUTE))
1870 else if (check_amp_caps(codec, sel,
HDA_OUTPUT, AC_AMPCAP_MUTE))
1875 sprintf(name,
"%s Playback Switch", pfx);
1885 static void mangle_smart51(
struct hda_codec *codec)
1902 for (j = 0; j < nums; j++)
1903 if (ins[pins[j]].type < ins[i].type) {
1904 memmove(pins + j + 1, pins + j,
1905 (nums - j) *
sizeof(
int));
1913 for (i = 0; i < nums; i++) {
1924 static void copy_path_mixer_ctls(
struct nid_path *dst,
struct nid_path *src)
1931 static int via_auto_create_multi_out_ctls(
struct hda_codec *codec)
1936 static const char *
const chname[4] = {
1937 "Front",
"Surround",
"C/LFE",
"Side"
1945 mangle_smart51(codec);
1947 err = via_auto_fill_dac_nids(codec);
1963 err = create_ch_ctls(codec,
"Center", 1,
true, path);
1966 err = create_ch_ctls(codec,
"LFE", 2,
true, path);
1970 const char *pfx = chname[
i];
1974 err = create_ch_ctls(codec, pfx, 3,
true, path);
1979 copy_path_mixer_ctls(&spec->
out_path[i], path);
1990 "PCM Loopback Playback Volume" :
"PCM Playback Volume";
1997 "PCM Loopback Playback Switch" :
"PCM Playback Switch";
2020 if (!parse_output_path(codec, pin, 0, 0, &spec->
hp_indep_path)) {
2022 if (i < spec->multiout.num_dacs &&
2023 parse_output_path(codec, pin,
2038 parse_output_path(codec, pin,
2053 err = create_ch_ctls(codec,
"Headphone", 3, check_dac, path);
2059 copy_path_mixer_ctls(&spec->
hp_path, path);
2065 static int via_auto_create_speaker_ctls(
struct hda_codec *codec)
2073 pin = spec->
autocfg.speaker_pins[0];
2074 if (!spec->
autocfg.speaker_outs || !pin)
2077 if (parse_output_path(codec, pin, 0, 0, &spec->
speaker_path))
2080 parse_output_path(codec, pin,
2092 spec->
multiout.extra_out_nid[0] = dac;
2100 err = create_ch_ctls(codec,
"Speaker", 3, check_dac, path);
2110 #define via_aamix_ctl_info via_pin_power_ctl_info
2112 static int via_aamix_ctl_get(
struct snd_kcontrol *kcontrol,
2121 static void update_aamix_paths(
struct hda_codec *codec,
int do_mix,
2125 activate_output_path(codec, nomix,
false,
false);
2126 activate_output_path(codec, mix,
true,
false);
2128 activate_output_path(codec, mix,
false,
false);
2129 activate_output_path(codec, nomix,
true,
false);
2133 static int via_aamix_ctl_put(
struct snd_kcontrol *kcontrol,
2138 unsigned int val = ucontrol->
value.enumerated.item[0];
2147 update_aamix_paths(codec, val, &spec->
hp_path,
2158 .name =
"Loopback Mixing",
2160 .get = via_aamix_ctl_get,
2161 .put = via_aamix_ctl_put,
2164 static int via_auto_create_loopback_switch(
struct hda_codec *codec)
2179 static int via_fill_adcs(
struct hda_codec *codec)
2185 for (i = 0; i < codec->
num_nodes; i++, nid++) {
2186 unsigned int wcaps = get_wcaps(codec, nid);
2201 static int via_mux_enum_info(
struct snd_kcontrol *kcontrol,
2217 static int via_mux_enum_get(
struct snd_kcontrol *kcontrol,
2222 unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->
id);
2228 static int via_mux_enum_put(
struct snd_kcontrol *kcontrol,
2233 unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->
id);
2237 cur = ucontrol->
value.enumerated.item[0];
2240 if (spec->
cur_mux[idx] == cur)
2244 int adc_idx = spec->
inputs[
cur].adc_idx;
2246 via_dyn_adc_pcm_resetup(codec, cur);
2258 spec->
inputs[cur].mux_idx);
2272 .name =
"Input Source",
2273 .info = via_mux_enum_info,
2274 .get = via_mux_enum_get,
2275 .put = via_mux_enum_put,
2278 static int create_input_src_ctls(
struct hda_codec *codec,
int count)
2330 if (!is_reachable_nid(codec, spec->
adc_nids[c], pin))
2338 "via: dynamic ADC switching enabled\n");
2346 static int get_mux_nids(
struct hda_codec *codec);
2349 static int parse_analog_inputs(
struct hda_codec *codec)
2355 err = via_fill_adcs(codec);
2358 err = get_mux_nids(codec);
2364 if (add_input_route(codec, cfg->
inputs[i].pin))
2378 static int create_loopback_ctls(
struct hda_codec *codec)
2382 const char *prev_label =
NULL;
2393 if (prev_label && !
strcmp(label, prev_label))
2400 err = via_new_analog_input(spec, label, type_idx,
2420 static int create_mic_boost_ctls(
struct hda_codec *codec)
2424 const char *prev_label =
NULL;
2440 if (prev_label && !
strcmp(label, prev_label))
2445 snprintf(name,
sizeof(name),
"%s Boost Volume", label);
2455 static int create_multi_adc_ctls(
struct hda_codec *codec)
2464 "Capture Volume", i,
2470 "Capture Switch", i,
2481 err = create_input_src_ctls(codec, i);
2499 ctl = kzalloc(
sizeof(*ctl) +
sizeof(
long) * 4,
GFP_KERNEL);
2511 static int create_dyn_adc_ctls(
struct hda_codec *codec)
2537 err = create_input_src_ctls(codec, 1);
2544 static int via_auto_create_analog_input_ctls(
struct hda_codec *codec)
2549 err = parse_analog_inputs(codec);
2553 err = create_dyn_adc_ctls(codec);
2555 err = create_multi_adc_ctls(codec);
2558 err = create_loopback_ctls(codec);
2561 err = create_mic_boost_ctls(codec);
2569 unsigned int def_conf;
2570 unsigned char seqassoc;
2576 && (seqassoc == 0xf0 || seqassoc == 0xff)) {
2584 static int vt1708_jack_detect_get(
struct snd_kcontrol *kcontrol,
2596 static int vt1708_jack_detect_put(
struct snd_kcontrol *kcontrol,
2605 val = !!ucontrol->
value.integer.value[0];
2610 snd_hda_get_bool_hint(codec,
"analog_loopback_hp_detect") != 1) {
2611 mute_aa_path(codec, 1);
2612 notify_aa_path_ctls(codec);
2614 via_hp_automute(codec);
2615 vt1708_update_hp_work(spec);
2621 .name =
"Jack Detect",
2624 .get = vt1708_jack_detect_get,
2625 .put = vt1708_jack_detect_put,
2628 static void fill_dig_outs(
struct hda_codec *codec);
2629 static void fill_dig_in(
struct hda_codec *codec);
2631 static int via_parse_auto_config(
struct hda_codec *codec)
2642 err = via_auto_create_multi_out_ctls(codec);
2645 err = via_auto_create_hp_ctls(codec, spec->
autocfg.hp_pins[0]);
2648 err = via_auto_create_speaker_ctls(codec);
2651 err = via_auto_create_loopback_switch(codec);
2654 err = via_auto_create_analog_input_ctls(codec);
2660 fill_dig_outs(codec);
2663 if (spec->
kctls.list)
2668 err = via_hp_build(codec);
2673 err = via_smart51_build(codec);
2684 static void via_auto_init_dig_outs(
struct hda_codec *codec)
2693 static void via_auto_init_dig_in(
struct hda_codec *codec)
2698 snd_hda_set_pin_ctl(codec, spec->
autocfg.dig_in_pin,
PIN_IN);
2704 via_hp_automute(codec);
2713 static void via_auto_init_unsol_event(
struct hda_codec *codec)
2724 via_jack_output_event);
2730 cb = ev ? via_jack_output_event : via_jack_powerstate_event;
2743 via_jack_powerstate_event);
2757 __analog_low_current_mode(codec,
true);
2759 via_auto_init_multi_out(codec);
2760 via_auto_init_hp_out(codec);
2761 via_auto_init_speaker_out(codec);
2762 via_auto_init_analog_input(codec);
2763 via_auto_init_dig_outs(codec);
2764 via_auto_init_dig_in(codec);
2766 via_auto_init_unsol_event(codec);
2768 via_hp_automute(codec);
2769 vt1708_update_hp_work(spec);
2785 via_hp_automute(spec->
codec);
2792 static int get_mux_nids(
struct hda_codec *codec)
2802 type = get_wcaps_type(get_wcaps(codec, nid));
2819 static int patch_vt1708(
struct hda_codec *codec)
2825 spec = via_new_spec(codec);
2836 err = via_parse_auto_config(codec);
2858 static int patch_vt1709(
struct hda_codec *codec)
2864 spec = via_new_spec(codec);
2870 err = via_parse_auto_config(codec);
2881 static void set_widgets_power_state_vt1708B(
struct hda_codec *codec)
2898 set_pin_power_state(codec, 0x1a, &parm);
2899 set_pin_power_state(codec, 0x1b, &parm);
2900 set_pin_power_state(codec, 0x1e, &parm);
2904 update_power_state(codec, 0x17, parm);
2905 update_power_state(codec, 0x13, parm);
2906 update_power_state(codec, 0x14, parm);
2911 set_pin_power_state(codec, 0x19, &parm);
2913 set_pin_power_state(codec, 0x1b, &parm);
2914 update_power_state(codec, 0x18, parm);
2915 update_power_state(codec, 0x11, parm);
2920 set_pin_power_state(codec, 0x22, &parm);
2922 set_pin_power_state(codec, 0x1a, &parm);
2923 update_power_state(codec, 0x26, parm);
2924 update_power_state(codec, 0x24, parm);
2925 }
else if (codec->
vendor_id == 0x11064397) {
2928 set_pin_power_state(codec, 0x23, &parm);
2930 set_pin_power_state(codec, 0x1a, &parm);
2931 update_power_state(codec, 0x27, parm);
2932 update_power_state(codec, 0x25, parm);
2938 set_pin_power_state(codec, 0x1c, &parm);
2939 set_pin_power_state(codec, 0x1d, &parm);
2941 set_pin_power_state(codec, 0x23, &parm);
2944 update_power_state(codec, 0x16, imux_is_smixer ?
AC_PWRST_D0 : parm);
2945 update_power_state(codec, 0x10, parm);
2947 update_power_state(codec, 0x25, parm);
2948 update_power_state(codec, 0x27, parm);
2950 update_power_state(codec, 0x25, parm);
2953 static int patch_vt1708S(
struct hda_codec *codec);
2954 static int patch_vt1708B(
struct hda_codec *codec)
2960 return patch_vt1708S(codec);
2963 spec = via_new_spec(codec);
2970 err = via_parse_auto_config(codec);
2984 static const struct hda_verb vt1708S_init_verbs[] = {
2993 static void fill_dig_outs(
struct hda_codec *codec)
2998 for (i = 0; i < spec->
autocfg.dig_outs; i++) {
3002 nid = spec->
autocfg.dig_out_pins[
i];
3017 static void fill_dig_in(
struct hda_codec *codec)
3023 if (!spec->
autocfg.dig_in_pin)
3027 for (i = 0; i < codec->
num_nodes; i++, dig_nid++) {
3028 unsigned int wcaps = get_wcaps(codec, dig_nid);
3031 if (!(wcaps & AC_WCAP_DIGITAL))
3033 if (!(wcaps & AC_WCAP_CONN_LIST))
3054 static int patch_vt1708S(
struct hda_codec *codec)
3060 spec = via_new_spec(codec);
3065 override_mic_boost(codec, 0x1a, 0, 3, 40);
3066 override_mic_boost(codec, 0x1e, 0, 3, 40);
3069 err = via_parse_auto_config(codec);
3080 if (get_codec_type(codec) ==
VT1708BCE) {
3084 sizeof(codec->
bus->card->mixername),
3092 sizeof(codec->
bus->card->mixername),
3101 static const struct hda_verb vt1702_init_verbs[] = {
3109 static void set_widgets_power_state_vt1702(
struct hda_codec *codec)
3111 int imux_is_smixer =
3117 set_pin_power_state(codec, 0x14, &parm);
3118 set_pin_power_state(codec, 0x15, &parm);
3119 set_pin_power_state(codec, 0x18, &parm);
3123 update_power_state(codec, 0x13, parm);
3124 update_power_state(codec, 0x12, parm);
3125 update_power_state(codec, 0x1f, parm);
3126 update_power_state(codec, 0x20, parm);
3131 set_pin_power_state(codec, 0x17, &parm);
3132 set_pin_power_state(codec, 0x16, &parm);
3134 update_power_state(codec, 0x1a, imux_is_smixer ?
AC_PWRST_D0 : parm);
3135 update_power_state(codec, 0x10, parm);
3136 update_power_state(codec, 0x1d, parm);
3139 static int patch_vt1702(
struct hda_codec *codec)
3145 spec = via_new_spec(codec);
3159 err = via_parse_auto_config(codec);
3175 static const struct hda_verb vt1718S_init_verbs[] = {
3184 static void set_widgets_power_state_vt1718S(
struct hda_codec *codec)
3188 unsigned int parm, parm2;
3195 set_pin_power_state(codec, 0x29, &parm);
3196 set_pin_power_state(codec, 0x2a, &parm);
3197 set_pin_power_state(codec, 0x2b, &parm);
3201 update_power_state(codec, 0x1e, parm);
3202 update_power_state(codec, 0x1f, parm);
3203 update_power_state(codec, 0x10, parm);
3204 update_power_state(codec, 0x11, parm);
3209 set_pin_power_state(codec, 0x27, &parm);
3210 update_power_state(codec, 0x1a, parm);
3215 set_pin_power_state(codec, 0x26, &parm);
3217 set_pin_power_state(codec, 0x2b, &parm);
3218 update_power_state(codec, 0xa, parm);
3222 set_pin_power_state(codec, 0x24, &parm);
3224 set_pin_power_state(codec, 0x28, &parm);
3225 update_power_state(codec, 0x8, parm);
3228 update_power_state(codec, 0
xb, parm);
3230 update_power_state(codec, 0x21, imux_is_smixer ?
AC_PWRST_D0 : parm);
3234 set_pin_power_state(codec, 0x25, &parm);
3236 set_pin_power_state(codec, 0x2a, &parm);
3237 update_power_state(codec, 0x9, parm);
3242 set_pin_power_state(codec, 0x28, &parm);
3243 update_power_state(codec, 0x1b, parm);
3244 update_power_state(codec, 0x34, parm);
3245 update_power_state(codec, 0
xc, parm);
3252 static int add_secret_dac_path(
struct hda_codec *codec)
3263 for (i = 0; i < nums; i++) {
3270 for (i = 0; i < codec->
num_nodes; i++, nid++) {
3271 unsigned int caps = get_wcaps(codec, nid);
3273 !(caps & AC_WCAP_DIGITAL)) {
3284 static int patch_vt1718S(
struct hda_codec *codec)
3290 spec = via_new_spec(codec);
3295 override_mic_boost(codec, 0x2b, 0, 3, 40);
3296 override_mic_boost(codec, 0x29, 0, 3, 40);
3297 add_secret_dac_path(codec);
3300 err = via_parse_auto_config(codec);
3317 static int vt1716s_dmic_info(
struct snd_kcontrol *kcontrol,
3327 static int vt1716s_dmic_get(
struct snd_kcontrol *kcontrol,
3341 static int vt1716s_dmic_put(
struct snd_kcontrol *kcontrol,
3346 int index = *ucontrol->
value.integer.value;
3359 .name =
"Digital Mic Capture Switch",
3362 .info = vt1716s_dmic_info,
3363 .get = vt1716s_dmic_get,
3364 .put = vt1716s_dmic_put,
3376 static const struct hda_verb vt1716S_init_verbs[] = {
3386 static void set_widgets_power_state_vt1716S(
struct hda_codec *codec)
3391 unsigned int mono_out, present;
3399 set_pin_power_state(codec, 0x1a, &parm);
3400 set_pin_power_state(codec, 0x1b, &parm);
3401 set_pin_power_state(codec, 0x1e, &parm);
3405 update_power_state(codec, 0x17, parm);
3406 update_power_state(codec, 0x13, parm);
3409 set_pin_power_state(codec, 0x1e, &parm);
3412 set_pin_power_state(codec, 0x22, &parm);
3417 update_power_state(codec, 0x26, parm);
3418 update_power_state(codec, 0x14, parm);
3423 set_pin_power_state(codec, 0x19, &parm);
3426 set_pin_power_state(codec, 0x1b, &parm);
3427 update_power_state(codec, 0x18, parm);
3428 update_power_state(codec, 0x11, parm);
3432 set_pin_power_state(codec, 0x23, &parm);
3435 set_pin_power_state(codec, 0x1a, &parm);
3436 update_power_state(codec, 0x27, parm);
3440 set_pin_power_state(codec, 0x1e, &parm);
3441 update_power_state(codec, 0x25, parm);
3457 update_power_state(codec, 0x28, parm);
3458 update_power_state(codec, 0x29, parm);
3459 update_power_state(codec, 0x2a, parm);
3463 set_pin_power_state(codec, 0x1c, &parm);
3464 set_pin_power_state(codec, 0x1d, &parm);
3467 update_power_state(codec, 0x25, parm);
3471 update_power_state(codec, 0x16, imux_is_smixer ?
AC_PWRST_D0 : parm);
3472 update_power_state(codec, 0x10, mono_out ?
AC_PWRST_D0 : parm);
3475 static int patch_vt1716S(
struct hda_codec *codec)
3481 spec = via_new_spec(codec);
3486 override_mic_boost(codec, 0x1a, 0, 3, 40);
3487 override_mic_boost(codec, 0x1e, 0, 3, 40);
3490 err = via_parse_auto_config(codec);
3511 static const struct hda_verb vt2002P_init_verbs[] = {
3523 static const struct hda_verb vt1802_init_verbs[] = {
3531 static void set_widgets_power_state_vt2002P(
struct hda_codec *codec)
3536 unsigned int present;
3543 set_pin_power_state(codec, 0x29, &parm);
3544 set_pin_power_state(codec, 0x2a, &parm);
3545 set_pin_power_state(codec, 0x2b, &parm);
3548 update_power_state(codec, 0x1e, parm);
3549 update_power_state(codec, 0x1f, parm);
3550 update_power_state(codec, 0x10, parm);
3551 update_power_state(codec, 0x11, parm);
3555 update_power_state(codec, 0x8, parm);
3560 set_pin_power_state(codec, 0x28, &parm);
3561 update_power_state(codec, 0x18, parm);
3562 update_power_state(codec, 0x38, parm);
3566 set_pin_power_state(codec, 0x26, &parm);
3567 update_power_state(codec, 0x1c, parm);
3568 update_power_state(codec, 0x37, parm);
3574 set_pin_power_state(codec, 0x25, &parm);
3575 update_power_state(codec, 0x15, parm);
3576 update_power_state(codec, 0x35, parm);
3580 set_pin_power_state(codec, 0x25, &parm);
3581 update_power_state(codec, 0x19, parm);
3582 update_power_state(codec, 0x35, parm);
3593 set_pin_power_state(codec, 0x24, &parm);
3596 update_power_state(codec, 0x14, parm);
3598 update_power_state(codec, 0x18, parm);
3599 update_power_state(codec, 0x34, parm);
3607 update_power_state(codec, 0x33, parm);
3608 update_power_state(codec, 0x1c, parm);
3609 update_power_state(codec, 0x3c, parm);
3612 update_power_state(codec, 0x31, parm);
3613 update_power_state(codec, 0x17, parm);
3614 update_power_state(codec, 0x3b, parm);
3617 if (imux_is_smixer || !is_aa_path_mute(codec))
3631 static void via_fixup_intmic_boost(
struct hda_codec *codec,
3635 override_mic_boost(codec, 0x30, 0, 2, 40);
3638 static const struct hda_fixup via_fixups[] = {
3641 .v.func = via_fixup_intmic_boost,
3647 { 0x24, 0x991301f0 },
3648 { 0x33, 0x991301f1 },
3654 static const struct snd_pci_quirk vt2002p_fixups[] = {
3663 static void fix_vt1802_connections(
struct hda_codec *codec)
3665 static hda_nid_t conn_24[] = { 0x14, 0x1c };
3673 static int patch_vt2002P(
struct hda_codec *codec)
3679 spec = via_new_spec(codec);
3684 override_mic_boost(codec, 0x2b, 0, 3, 40);
3685 override_mic_boost(codec, 0x29, 0, 3, 40);
3687 fix_vt1802_connections(codec);
3688 add_secret_dac_path(codec);
3694 err = via_parse_auto_config(codec);
3713 static const struct hda_verb vt1812_init_verbs[] = {
3721 static void set_widgets_power_state_vt1812(
struct hda_codec *codec)
3725 unsigned int present;
3729 set_pin_power_state(codec, 0x29, &parm);
3730 set_pin_power_state(codec, 0x2a, &parm);
3731 set_pin_power_state(codec, 0x2b, &parm);
3734 update_power_state(codec, 0x1e, parm);
3735 update_power_state(codec, 0x1f, parm);
3736 update_power_state(codec, 0x10, parm);
3737 update_power_state(codec, 0x11, parm);
3745 set_pin_power_state(codec, 0x28, &parm);
3746 update_power_state(codec, 0x18, parm);
3747 update_power_state(codec, 0x38, parm);
3751 set_pin_power_state(codec, 0x25, &parm);
3752 update_power_state(codec, 0x15, parm);
3753 update_power_state(codec, 0x35, parm);
3762 set_pin_power_state(codec, 0x24, &parm);
3777 set_pin_power_state(codec, 0x31, &parm);
3790 set_pin_power_state(codec, 0x33, &parm);
3791 update_power_state(codec, 0x1d, parm);
3792 update_power_state(codec, 0x3d, parm);
3797 static int patch_vt1812(
struct hda_codec *codec)
3803 spec = via_new_spec(codec);
3808 override_mic_boost(codec, 0x2b, 0, 3, 40);
3809 override_mic_boost(codec, 0x29, 0, 3, 40);
3810 add_secret_dac_path(codec);
3813 err = via_parse_auto_config(codec);
3831 { .id = 0x11061708, .name =
"VT1708", .patch = patch_vt1708},
3832 { .id = 0x11061709, .name =
"VT1708", .patch = patch_vt1708},
3833 { .id = 0x1106170a, .name =
"VT1708", .patch = patch_vt1708},
3834 { .id = 0x1106170b, .name =
"VT1708", .patch = patch_vt1708},
3835 { .id = 0x1106e710, .name =
"VT1709 10-Ch",
3836 .patch = patch_vt1709},
3837 { .id = 0x1106e711, .name =
"VT1709 10-Ch",
3838 .patch = patch_vt1709},
3839 { .id = 0x1106e712, .name =
"VT1709 10-Ch",
3840 .patch = patch_vt1709},
3841 { .id = 0x1106e713, .name =
"VT1709 10-Ch",
3842 .patch = patch_vt1709},
3843 { .id = 0x1106e714, .name =
"VT1709 6-Ch",
3844 .patch = patch_vt1709},
3845 { .id = 0x1106e715, .name =
"VT1709 6-Ch",
3846 .patch = patch_vt1709},
3847 { .id = 0x1106e716, .name =
"VT1709 6-Ch",
3848 .patch = patch_vt1709},
3849 { .id = 0x1106e717, .name =
"VT1709 6-Ch",
3850 .patch = patch_vt1709},
3851 { .id = 0x1106e720, .name =
"VT1708B 8-Ch",
3852 .patch = patch_vt1708B},
3853 { .id = 0x1106e721, .name =
"VT1708B 8-Ch",
3854 .patch = patch_vt1708B},
3855 { .id = 0x1106e722, .name =
"VT1708B 8-Ch",
3856 .patch = patch_vt1708B},
3857 { .id = 0x1106e723, .name =
"VT1708B 8-Ch",
3858 .patch = patch_vt1708B},
3859 { .id = 0x1106e724, .name =
"VT1708B 4-Ch",
3860 .patch = patch_vt1708B},
3861 { .id = 0x1106e725, .name =
"VT1708B 4-Ch",
3862 .patch = patch_vt1708B},
3863 { .id = 0x1106e726, .name =
"VT1708B 4-Ch",
3864 .patch = patch_vt1708B},
3865 { .id = 0x1106e727, .name =
"VT1708B 4-Ch",
3866 .patch = patch_vt1708B},
3867 { .id = 0x11060397, .name =
"VT1708S",
3868 .patch = patch_vt1708S},
3869 { .id = 0x11061397, .name =
"VT1708S",
3870 .patch = patch_vt1708S},
3871 { .id = 0x11062397, .name =
"VT1708S",
3872 .patch = patch_vt1708S},
3873 { .id = 0x11063397, .name =
"VT1708S",
3874 .patch = patch_vt1708S},
3875 { .id = 0x11064397, .name =
"VT1705",
3876 .patch = patch_vt1708S},
3877 { .id = 0x11065397, .name =
"VT1708S",
3878 .patch = patch_vt1708S},
3879 { .id = 0x11066397, .name =
"VT1708S",
3880 .patch = patch_vt1708S},
3881 { .id = 0x11067397, .name =
"VT1708S",
3882 .patch = patch_vt1708S},
3883 { .id = 0x11060398, .name =
"VT1702",
3884 .patch = patch_vt1702},
3885 { .id = 0x11061398, .name =
"VT1702",
3886 .patch = patch_vt1702},
3887 { .id = 0x11062398, .name =
"VT1702",
3888 .patch = patch_vt1702},
3889 { .id = 0x11063398, .name =
"VT1702",
3890 .patch = patch_vt1702},
3891 { .id = 0x11064398, .name =
"VT1702",
3892 .patch = patch_vt1702},
3893 { .id = 0x11065398, .name =
"VT1702",
3894 .patch = patch_vt1702},
3895 { .id = 0x11066398, .name =
"VT1702",
3896 .patch = patch_vt1702},
3897 { .id = 0x11067398, .name =
"VT1702",
3898 .patch = patch_vt1702},
3899 { .id = 0x11060428, .name =
"VT1718S",
3900 .patch = patch_vt1718S},
3901 { .id = 0x11064428, .name =
"VT1718S",
3902 .patch = patch_vt1718S},
3903 { .id = 0x11060441, .name =
"VT2020",
3904 .patch = patch_vt1718S},
3905 { .id = 0x11064441, .name =
"VT1828S",
3906 .patch = patch_vt1718S},
3907 { .id = 0x11060433, .name =
"VT1716S",
3908 .patch = patch_vt1716S},
3909 { .id = 0x1106a721, .name =
"VT1716S",
3910 .patch = patch_vt1716S},
3911 { .id = 0x11060438, .name =
"VT2002P", .patch = patch_vt2002P},
3912 { .id = 0x11064438, .name =
"VT2002P", .patch = patch_vt2002P},
3913 { .id = 0x11060448, .name =
"VT1812", .patch = patch_vt1812},
3914 { .id = 0x11060440, .name =
"VT1818S",
3915 .patch = patch_vt1708S},
3916 { .id = 0x11060446, .name =
"VT1802",
3917 .patch = patch_vt2002P},
3918 { .id = 0x11068446, .name =
"VT1802",
3919 .patch = patch_vt2002P},
3926 .preset = snd_hda_preset_via,
3933 static int __init patch_via_init(
void)
3938 static void __exit patch_via_exit(
void)