Lines Matching +full:codec +full:- +full:2
1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * HD audio codec driver for AD1882, AD1884, AD1981HD, AD1983, AD1984,
6 * Copyright (c) 2005-2007 Takashi Iwai <tiwai@suse.de>
53 ((spec)->beep_amp = HDA_COMPOSE_AMP_VAL(nid, 1, idx, dir)) /* mono */
59 static int create_beep_ctls(struct hda_codec *codec)
61 struct ad198x_spec *spec = codec->spec;
64 if (!spec->beep_amp)
67 for (knew = ad_beep_mixer ; knew->name; knew++) {
70 kctl = snd_ctl_new1(knew, codec);
72 return -ENOMEM;
73 kctl->private_value = spec->beep_amp;
74 err = snd_hda_ctl_add(codec, 0, kctl);
81 #define create_beep_ctls(codec) 0
84 static void ad198x_power_eapd_write(struct hda_codec *codec, hda_nid_t front,
87 if (snd_hda_query_pin_caps(codec, front) & AC_PINCAP_EAPD)
88 snd_hda_codec_write(codec, front, 0, AC_VERB_SET_EAPD_BTLENABLE,
89 !codec->inv_eapd ? 0x00 : 0x02);
90 if (snd_hda_query_pin_caps(codec, hp) & AC_PINCAP_EAPD)
91 snd_hda_codec_write(codec, hp, 0, AC_VERB_SET_EAPD_BTLENABLE,
92 !codec->inv_eapd ? 0x00 : 0x02);
95 static void ad198x_power_eapd(struct hda_codec *codec)
98 switch (codec->core.vendor_id) {
111 ad198x_power_eapd_write(codec, 0x12, 0x11);
115 ad198x_power_eapd_write(codec, 0x05, 0x06);
118 ad198x_power_eapd_write(codec, 0x1b, 0x1a);
123 static int ad_codec_suspend(struct hda_codec *codec)
125 snd_hda_shutup_pins(codec);
126 ad198x_power_eapd(codec);
133 struct hda_codec *codec = private_data;
134 struct ad198x_spec *spec = codec->spec;
136 if (!spec->eapd_nid)
138 if (codec->inv_eapd)
140 snd_hda_codec_write_cache(codec, spec->eapd_nid, 0,
149 static int ad_codec_build_controls(struct hda_codec *codec)
153 err = snd_hda_gen_build_controls(codec);
156 err = create_beep_ctls(codec);
162 static int ad198x_parse_auto_config(struct hda_codec *codec, bool indep_hp)
164 struct ad198x_spec *spec = codec->spec;
165 struct auto_pin_cfg *cfg = &spec->gen.autocfg;
168 codec->spdif_status_reset = 1;
169 codec->no_trigger_sense = 1;
170 codec->no_sticky_stream = 1;
172 spec->gen.indep_hp = indep_hp;
173 if (!spec->gen.add_stereo_mix_input)
174 spec->gen.add_stereo_mix_input = HDA_HINT_STEREO_MIX_AUTO;
176 err = snd_hda_parse_pin_defcfg(codec, cfg, NULL, 0);
179 err = snd_hda_gen_parse_auto_config(codec, cfg);
190 static int alloc_ad_spec(struct hda_codec *codec)
196 return -ENOMEM;
197 codec->spec = spec;
198 snd_hda_gen_spec_init(&spec->gen);
206 /* Lenovo N100 seems to report the reversed bit for HP jack-sensing */
207 static void ad_fixup_inv_jack_detect(struct hda_codec *codec,
210 struct ad198x_spec *spec = codec->spec;
213 codec->inv_jack_detect = 1;
214 spec->gen.keep_eapd_on = 1;
215 spec->gen.vmaster_mute.hook = ad_vmaster_eapd_hook;
216 spec->eapd_nid = 0x1b;
221 static void ad1986a_fixup_eapd(struct hda_codec *codec,
224 struct ad198x_spec *spec = codec->spec;
227 codec->inv_eapd = 0;
228 spec->gen.keep_eapd_on = 1;
229 spec->eapd_nid = 0x1b;
233 /* enable stereo-mix input for avoiding regression on KDE (bko#88251) */
234 static void ad1986a_fixup_eapd_mix_in(struct hda_codec *codec,
237 struct ad198x_spec *spec = codec->spec;
240 ad1986a_fixup_eapd(codec, fix, action);
241 spec->gen.add_stereo_mix_input = HDA_HINT_STEREO_MIX_ENABLE;
285 { 0x1c, 0x01813030 }, /* line-in */
352 SND_PCI_QUIRK(0x10de, 0xcb84, "ASUS A8N-VM", AD1986A_FIXUP_3STACK),
367 { .id = AD1986A_FIXUP_LAPTOP_IMIC, .name = "laptop-imic" },
368 { .id = AD1986A_FIXUP_LAPTOP_IMIC, .name = "laptop-eapd" }, /* alias */
375 static int ad1986a_probe(struct hda_codec *codec)
378 struct ad198x_spec *spec = codec->spec;
389 codec->inv_eapd = 1;
391 spec->gen.mixer_nid = 0x07;
392 spec->gen.beep_nid = 0x19;
401 spec->gen.multiout.no_share_stream = 1;
403 spec->gen.preferred_dacs = preferred_pairs;
406 spec->gen.auto_mute_via_amp = 1;
408 snd_hda_pick_fixup(codec, ad1986a_fixup_models, ad1986a_fixup_tbl,
410 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
412 err = ad198x_parse_auto_config(codec, false);
416 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
427 * SPDIF mux control for AD1983 auto-parser
432 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
433 struct ad198x_spec *spec = codec->spec;
436 int num_conns = spec->num_smux_conns;
438 if (num_conns == 2)
439 return snd_hda_enum_helper_info(kcontrol, uinfo, 2, texts2);
443 return -EINVAL;
449 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
450 struct ad198x_spec *spec = codec->spec;
452 ucontrol->value.enumerated.item[0] = spec->cur_smux;
459 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
460 struct ad198x_spec *spec = codec->spec;
461 unsigned int val = ucontrol->value.enumerated.item[0];
462 hda_nid_t dig_out = spec->gen.multiout.dig_out_nid;
463 int num_conns = spec->num_smux_conns;
466 return -EINVAL;
467 if (spec->cur_smux == val)
469 spec->cur_smux = val;
470 snd_hda_codec_write_cache(codec, dig_out, 0,
483 static int ad1983_add_spdif_mux_ctl(struct hda_codec *codec)
485 struct ad198x_spec *spec = codec->spec;
486 hda_nid_t dig_out = spec->gen.multiout.dig_out_nid;
491 num_conns = snd_hda_get_num_conns(codec, dig_out);
492 if (num_conns != 2 && num_conns != 3)
494 spec->num_smux_conns = num_conns;
495 if (!snd_hda_gen_add_kctl(&spec->gen, NULL, &ad1983_auto_smux_mixer))
496 return -ENOMEM;
500 static int ad1983_probe(struct hda_codec *codec)
504 struct ad198x_spec *spec = codec->spec;
507 spec->gen.mixer_nid = 0x0e;
508 spec->gen.beep_nid = 0x10;
512 snd_hda_override_conn_list(codec, 0x0c, ARRAY_SIZE(conn_0c), conn_0c);
513 snd_hda_override_conn_list(codec, 0x0d, ARRAY_SIZE(conn_0d), conn_0d);
515 err = ad198x_parse_auto_config(codec, false);
518 err = ad1983_add_spdif_mux_ctl(codec);
529 static void ad1981_fixup_hp_eapd(struct hda_codec *codec,
532 struct ad198x_spec *spec = codec->spec;
535 spec->gen.vmaster_mute.hook = ad_vmaster_eapd_hook;
536 spec->eapd_nid = 0x05;
540 /* set the upper-limit for mixer amp to 0dB for avoiding the possible
543 static void ad1981_fixup_amp_override(struct hda_codec *codec,
547 snd_hda_override_amp_caps(codec, 0x11, HDA_INPUT,
581 static int ad1981_probe(struct hda_codec *codec)
583 struct ad198x_spec *spec = codec->spec;
586 spec->gen.mixer_nid = 0x0e;
587 spec->gen.beep_nid = 0x10;
590 snd_hda_pick_fixup(codec, NULL, ad1981_fixup_tbl, ad1981_fixups);
591 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
593 err = ad198x_parse_auto_config(codec, false);
596 err = ad1983_add_spdif_mux_ctl(codec);
600 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
612 * port-A 0x11 (mute/hp) <- 0x22 <- 0x37 <- 03/04/06
613 * port-B 0x14 (mute/hp) <- 0x2b <- 0x30 <- 03/04/06
614 * port-C 0x15 (mute) <- 0x2c <- 0x31 <- 05/0a
615 * port-D 0x12 (mute/hp) <- 0x29 <- 04
616 * port-E 0x17 (mute/hp) <- 0x26 <- 0x32 <- 05/0a
617 * port-F 0x16 (mute) <- 0x2a <- 06
618 * port-G 0x24 (mute) <- 0x27 <- 05
619 * port-H 0x25 (mute) <- 0x28 <- 0a
620 * mono 0x13 (mute/amp)<- 0x1e <- 0x36 <- 03/04/06
623 * (*) DAC2/3/4 are swapped to DAC3/4/2 on AD198A rev.2 due to a h/w bug.
628 * port-A 0x11 -> 0x38 -> mix 2, ADC 0
629 * port-B 0x14 -> 0x39 -> mix 0, ADC 1
630 * port-C 0x15 -> 0x3a -> 33:0 - mix 1, ADC 2
631 * port-D 0x12 -> 0x3d -> mix 3, ADC 8
632 * port-E 0x17 -> 0x3c -> 34:0 - mix 4, ADC 4
633 * port-F 0x16 -> 0x3b -> mix 5, ADC 3
634 * port-G 0x24 -> N/A -> 33:1 - mix 1, 34:1 - mix 4, ADC 6
635 * port-H 0x25 -> N/A -> 33:2 - mix 1, 34:2 - mix 4, ADC 7
639 * 6stack - front/surr/CLFE/side/opt DACs - 04/06/05/0a/03
640 * 3stack - front/surr/CLFE/opt DACs - 04/05/0a/03
643 * 0:Port-B (front mic)
644 * 1:Port-C/G/H (line-in)
645 * 2:Port-A
646 * 3:Port-D (line-in/2)
647 * 4:Port-E/G/H (mic-in)
648 * 5:Port-F (mic2-in)
653 * 0:Port-A
654 * 1:Port-B (front mic-in)
655 * 2:Port-C (line-in)
656 * 3:Port-F (mic2-in)
657 * 4:Port-E (mic-in)
659 * 6:Port-G
660 * 7:Port-H
661 * 8:Port-D (line-in/2)
666 * 6-stack
667 * Port-A front headphone
668 * B front mic-in
669 * C rear line-in
670 * D rear front-out
671 * E rear mic-in
676 * 3-stack
677 * Port-A front headphone
679 * C rear line-in/surround
680 * D rear front-out
681 * E rear mic-in/CLFE
684 * Port-A headphone
685 * B mic-in
694 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
695 struct ad198x_spec *spec = codec->spec;
699 int num_conns = spec->num_smux_conns;
709 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
710 struct ad198x_spec *spec = codec->spec;
712 ucontrol->value.enumerated.item[0] = spec->cur_smux;
719 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
720 struct ad198x_spec *spec = codec->spec;
721 unsigned int val = ucontrol->value.enumerated.item[0];
723 int num_conns = spec->num_smux_conns;
726 return -EINVAL;
727 if (spec->cur_smux == val)
730 guard(mutex)(&codec->control_mutex);
731 path = snd_hda_get_path_from_idx(codec,
732 spec->smux_paths[spec->cur_smux]);
734 snd_hda_activate_path(codec, path, false, true);
735 path = snd_hda_get_path_from_idx(codec, spec->smux_paths[val]);
737 snd_hda_activate_path(codec, path, true, true);
738 spec->cur_smux = val;
750 static int ad_codec_init(struct hda_codec *codec)
752 struct ad198x_spec *spec = codec->spec;
755 err = snd_hda_gen_init(codec);
758 if (spec->model != MODEL_AD1988)
760 if (!spec->gen.autocfg.dig_outs)
765 path = snd_hda_get_path_from_idx(codec, spec->smux_paths[i]);
767 snd_hda_activate_path(codec, path, path->active, false);
773 static int ad1988_add_spdif_mux_ctl(struct hda_codec *codec)
775 struct ad198x_spec *spec = codec->spec;
802 .idx = { 0, 2, 1, 0 },
808 if (!spec->gen.autocfg.dig_outs ||
809 get_wcaps_type(get_wcaps(codec, 0x1d)) != AC_WID_AUD_MIX)
812 num_conns = snd_hda_get_num_conns(codec, 0x0b) + 1;
815 spec->num_smux_conns = num_conns;
818 struct nid_path *path = snd_array_new(&spec->gen.paths);
820 return -ENOMEM;
823 path->active = 1;
824 spec->smux_paths[i] = snd_hda_get_path_idx(codec, path);
827 if (!snd_hda_gen_add_kctl(&spec->gen, NULL, &ad1988_auto_smux_mixer))
828 return -ENOMEM;
844 { 0x11, 0x02214130 }, /* front-hp */
845 { 0x12, 0x01014010 }, /* line-out */
846 { 0x14, 0x02a19122 }, /* front-mic */
847 { 0x15, 0x01813021 }, /* line-in */
848 { 0x16, 0x01011012 }, /* line-out */
851 { 0x24, 0x01016011 }, /* line-out */
852 { 0x25, 0x01012013 }, /* line-out */
859 { .id = AD1988_FIXUP_6STACK_DIG, .name = "6stack-dig" },
863 static int ad1988_probe(struct hda_codec *codec)
865 struct ad198x_spec *spec = codec->spec;
868 spec->gen.mixer_nid = 0x20;
869 spec->gen.mixer_merge_nid = 0x21;
870 spec->gen.beep_nid = 0x10;
873 snd_hda_pick_fixup(codec, ad1988_fixup_models, NULL, ad1988_fixups);
874 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
876 err = ad198x_parse_auto_config(codec, true);
879 err = ad1988_add_spdif_mux_ctl(codec);
883 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
892 * port-B - front line/mic-in
893 * port-E - aux in/out
894 * port-F - aux in/out
895 * port-C - rear line/mic-in
896 * port-D - rear line/hp-out
897 * port-A - front line/hp-out
899 * AD1984 = AD1884 + two digital mic-ins
903 * port-B (0x14) - front mic-in
904 * port-E (0x1c) - rear mic-in
905 * port-F (0x16) - CD / ext out
906 * port-C (0x15) - rear line-in
907 * port-D (0x12) - rear line-out
908 * port-A (0x11) - front hp-out
910 * AD1984A = AD1884A + digital-mic
912 * AD1984B = AD1984A + extra SPDIF-out
915 /* set the upper-limit for mixer amp to 0dB for avoiding the possible
918 static void ad1884_fixup_amp_override(struct hda_codec *codec,
922 snd_hda_override_amp_caps(codec, 0x20, HDA_INPUT,
932 struct hda_codec *codec = private_data;
933 struct ad198x_spec *spec = codec->spec;
935 if (spec->eapd_nid)
937 snd_hda_codec_write_cache(codec, 0x01, 0,
942 static void ad1884_fixup_hp_eapd(struct hda_codec *codec,
945 struct ad198x_spec *spec = codec->spec;
949 spec->gen.vmaster_mute.hook = ad1884_vmaster_hp_gpio_hook;
950 spec->gen.own_eapd_ctl = 1;
951 snd_hda_codec_write_cache(codec, 0x01, 0,
953 snd_hda_codec_write_cache(codec, 0x01, 0,
955 snd_hda_codec_write_cache(codec, 0x01, 0,
959 if (spec->gen.autocfg.line_out_type == AUTO_PIN_SPEAKER_OUT)
960 spec->eapd_nid = spec->gen.autocfg.line_out_pins[0];
962 spec->eapd_nid = spec->gen.autocfg.speaker_pins[0];
967 static void ad1884_fixup_thinkpad(struct hda_codec *codec,
970 struct ad198x_spec *spec = codec->spec;
973 spec->gen.keep_eapd_on = 1;
974 spec->gen.vmaster_mute.hook = ad_vmaster_eapd_hook;
975 spec->eapd_nid = 0x12;
976 /* Analog PC Beeper - allow firmware/ACPI beeps */
977 spec->beep_amp = HDA_COMPOSE_AMP_VAL(0x20, 3, 3, HDA_INPUT);
978 spec->gen.beep_nid = 0; /* no digital beep */
1034 static int ad1884_probe(struct hda_codec *codec)
1036 struct ad198x_spec *spec = codec->spec;
1039 spec->gen.mixer_nid = 0x20;
1040 spec->gen.mixer_merge_nid = 0x21;
1041 spec->gen.beep_nid = 0x10;
1044 snd_hda_pick_fixup(codec, NULL, ad1884_fixup_tbl, ad1884_fixups);
1045 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
1047 err = ad198x_parse_auto_config(codec, true);
1050 err = ad1983_add_spdif_mux_ctl(codec);
1054 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
1062 * port-A - front hp-out
1063 * port-B - front mic-in
1064 * port-C - rear line-in, shared surr-out (3stack)
1065 * port-D - rear line-out
1066 * port-E - rear mic-in, shared clfe-out (3stack)
1067 * port-F - rear surr-out (6stack)
1068 * port-G - rear clfe-out (6stack)
1071 static int ad1882_probe(struct hda_codec *codec)
1073 struct ad198x_spec *spec = codec->spec;
1076 spec->gen.mixer_nid = 0x20;
1077 spec->gen.mixer_merge_nid = 0x21;
1078 spec->gen.beep_nid = 0x10;
1080 err = ad198x_parse_auto_config(codec, true);
1083 err = ad1988_add_spdif_mux_ctl(codec);
1092 static int ad_codec_probe(struct hda_codec *codec,
1098 err = alloc_ad_spec(codec);
1100 return -ENOMEM;
1101 spec = codec->spec;
1102 spec->model = id->driver_data;
1104 switch (spec->model) {
1106 err = ad1882_probe(codec);
1109 err = ad1884_probe(codec);
1112 err = ad1981_probe(codec);
1115 err = ad1983_probe(codec);
1118 err = ad1986a_probe(codec);
1121 err = ad1988_probe(codec);
1124 err = -EINVAL;
1129 snd_hda_gen_remove(codec);
1169 MODULE_DESCRIPTION("Analog Devices HD-audio codec");