aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sound/pci/hda/dell_wmi_helper.c76
-rw-r--r--sound/pci/hda/patch_realtek.c13
2 files changed, 89 insertions, 0 deletions
diff --git a/sound/pci/hda/dell_wmi_helper.c b/sound/pci/hda/dell_wmi_helper.c
new file mode 100644
index 000000000000..9c22f95838ef
--- /dev/null
+++ b/sound/pci/hda/dell_wmi_helper.c
@@ -0,0 +1,76 @@
1/* Helper functions for Dell Mic Mute LED control;
2 * to be included from codec driver
3 */
4
5#if IS_ENABLED(CONFIG_LEDS_DELL_NETBOOKS)
6#include <linux/dell-led.h>
7
8static int dell_led_value;
9static int (*dell_led_set_func)(int, int);
10static void (*dell_old_cap_hook)(struct hda_codec *,
11 struct snd_kcontrol *,
12 struct snd_ctl_elem_value *);
13
14static void update_dell_wmi_micmute_led(struct hda_codec *codec,
15 struct snd_kcontrol *kcontrol,
16 struct snd_ctl_elem_value *ucontrol)
17{
18 if (dell_old_cap_hook)
19 dell_old_cap_hook(codec, kcontrol, ucontrol);
20
21 if (!ucontrol || !dell_led_set_func)
22 return;
23 if (strcmp("Capture Switch", ucontrol->id.name) == 0 && ucontrol->id.index == 0) {
24 /* TODO: How do I verify if it's a mono or stereo here? */
25 int val = (ucontrol->value.integer.value[0] || ucontrol->value.integer.value[1]) ? 0 : 1;
26 if (val == dell_led_value)
27 return;
28 dell_led_value = val;
29 if (dell_led_set_func)
30 dell_led_set_func(DELL_LED_MICMUTE, dell_led_value);
31 }
32}
33
34
35static void alc_fixup_dell_wmi(struct hda_codec *codec,
36 const struct hda_fixup *fix, int action)
37{
38 struct alc_spec *spec = codec->spec;
39 bool removefunc = false;
40
41 if (action == HDA_FIXUP_ACT_PROBE) {
42 if (!dell_led_set_func)
43 dell_led_set_func = symbol_request(dell_app_wmi_led_set);
44 if (!dell_led_set_func) {
45 codec_warn(codec, "Failed to find dell wmi symbol dell_app_wmi_led_set\n");
46 return;
47 }
48
49 removefunc = true;
50 if (dell_led_set_func(DELL_LED_MICMUTE, false) >= 0) {
51 dell_led_value = 0;
52 if (spec->gen.num_adc_nids > 1)
53 codec_dbg(codec, "Skipping micmute LED control due to several ADCs");
54 else {
55 dell_old_cap_hook = spec->gen.cap_sync_hook;
56 spec->gen.cap_sync_hook = update_dell_wmi_micmute_led;
57 removefunc = false;
58 }
59 }
60
61 }
62
63 if (dell_led_set_func && (action == HDA_FIXUP_ACT_FREE || removefunc)) {
64 symbol_put(dell_app_wmi_led_set);
65 dell_led_set_func = NULL;
66 dell_old_cap_hook = NULL;
67 }
68}
69
70#else /* CONFIG_LEDS_DELL_NETBOOKS */
71static void alc_fixup_dell_wmi(struct hda_codec *codec,
72 const struct hda_fixup *fix, int action)
73{
74}
75
76#endif /* CONFIG_LEDS_DELL_NETBOOKS */
diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
index 2f755adfbe7c..654c8f16d150 100644
--- a/sound/pci/hda/patch_realtek.c
+++ b/sound/pci/hda/patch_realtek.c
@@ -4295,6 +4295,9 @@ static void alc290_fixup_mono_speakers(struct hda_codec *codec,
4295/* for hda_fixup_thinkpad_acpi() */ 4295/* for hda_fixup_thinkpad_acpi() */
4296#include "thinkpad_helper.c" 4296#include "thinkpad_helper.c"
4297 4297
4298/* for dell wmi mic mute led */
4299#include "dell_wmi_helper.c"
4300
4298enum { 4301enum {
4299 ALC269_FIXUP_SONY_VAIO, 4302 ALC269_FIXUP_SONY_VAIO,
4300 ALC275_FIXUP_SONY_VAIO_GPIO2, 4303 ALC275_FIXUP_SONY_VAIO_GPIO2,
@@ -4359,6 +4362,7 @@ enum {
4359 ALC293_FIXUP_DELL1_MIC_NO_PRESENCE, 4362 ALC293_FIXUP_DELL1_MIC_NO_PRESENCE,
4360 ALC292_FIXUP_TPT440_DOCK, 4363 ALC292_FIXUP_TPT440_DOCK,
4361 ALC283_FIXUP_BXBT2807_MIC, 4364 ALC283_FIXUP_BXBT2807_MIC,
4365 ALC255_FIXUP_DELL_WMI_MIC_MUTE_LED,
4362}; 4366};
4363 4367
4364static const struct hda_fixup alc269_fixups[] = { 4368static const struct hda_fixup alc269_fixups[] = {
@@ -4800,6 +4804,13 @@ static const struct hda_fixup alc269_fixups[] = {
4800 { }, 4804 { },
4801 }, 4805 },
4802 }, 4806 },
4807 [ALC255_FIXUP_DELL_WMI_MIC_MUTE_LED] = {
4808 .type = HDA_FIXUP_FUNC,
4809 .v.func = alc_fixup_dell_wmi,
4810 .chained_before = true,
4811 .chain_id = ALC255_FIXUP_DELL1_MIC_NO_PRESENCE
4812 },
4813
4803}; 4814};
4804 4815
4805static const struct snd_pci_quirk alc269_fixup_tbl[] = { 4816static const struct snd_pci_quirk alc269_fixup_tbl[] = {
@@ -4842,10 +4853,12 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = {
4842 SND_PCI_QUIRK(0x1028, 0x0606, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE), 4853 SND_PCI_QUIRK(0x1028, 0x0606, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE),
4843 SND_PCI_QUIRK(0x1028, 0x0608, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE), 4854 SND_PCI_QUIRK(0x1028, 0x0608, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE),
4844 SND_PCI_QUIRK(0x1028, 0x0609, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE), 4855 SND_PCI_QUIRK(0x1028, 0x0609, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE),
4856 SND_PCI_QUIRK(0x1028, 0x0610, "Dell", ALC255_FIXUP_DELL_WMI_MIC_MUTE_LED),
4845 SND_PCI_QUIRK(0x1028, 0x0613, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE), 4857 SND_PCI_QUIRK(0x1028, 0x0613, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE),
4846 SND_PCI_QUIRK(0x1028, 0x0614, "Dell Inspiron 3135", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE), 4858 SND_PCI_QUIRK(0x1028, 0x0614, "Dell Inspiron 3135", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE),
4847 SND_PCI_QUIRK(0x1028, 0x0615, "Dell Vostro 5470", ALC290_FIXUP_SUBWOOFER_HSJACK), 4859 SND_PCI_QUIRK(0x1028, 0x0615, "Dell Vostro 5470", ALC290_FIXUP_SUBWOOFER_HSJACK),
4848 SND_PCI_QUIRK(0x1028, 0x0616, "Dell Vostro 5470", ALC290_FIXUP_SUBWOOFER_HSJACK), 4860 SND_PCI_QUIRK(0x1028, 0x0616, "Dell Vostro 5470", ALC290_FIXUP_SUBWOOFER_HSJACK),
4861 SND_PCI_QUIRK(0x1028, 0x061f, "Dell", ALC255_FIXUP_DELL_WMI_MIC_MUTE_LED),
4849 SND_PCI_QUIRK(0x1028, 0x0638, "Dell Inspiron 5439", ALC290_FIXUP_MONO_SPEAKERS_HSJACK), 4862 SND_PCI_QUIRK(0x1028, 0x0638, "Dell Inspiron 5439", ALC290_FIXUP_MONO_SPEAKERS_HSJACK),
4850 SND_PCI_QUIRK(0x1028, 0x063f, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE), 4863 SND_PCI_QUIRK(0x1028, 0x063f, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE),
4851 SND_PCI_QUIRK(0x1028, 0x064a, "Dell", ALC293_FIXUP_DELL1_MIC_NO_PRESENCE), 4864 SND_PCI_QUIRK(0x1028, 0x064a, "Dell", ALC293_FIXUP_DELL1_MIC_NO_PRESENCE),