* [PATCH] ALSA: hda - Enable Thinkpad mute/micmute LEDs for Realtek
@ 2013-11-05 12:11 David Henningsson
2013-11-05 12:47 ` Takashi Iwai
0 siblings, 1 reply; 2+ messages in thread
From: David Henningsson @ 2013-11-05 12:11 UTC (permalink / raw)
To: tiwai, alsa-devel; +Cc: hui.wang, David Henningsson
Same as we already have for Conexant. Right now it's only enabled
for one machine.
Tested-by: Hui Wang <hui.wang@canonical.com>
Signed-off-by: David Henningsson <david.henningsson@canonical.com>
---
sound/pci/hda/patch_realtek.c | 83 ++++++++++++++++++++++++++++++++++++++++-
1 file changed, 81 insertions(+), 2 deletions(-)
diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
index 01bf812..02071a5 100644
--- a/sound/pci/hda/patch_realtek.c
+++ b/sound/pci/hda/patch_realtek.c
@@ -829,7 +829,11 @@ static inline void alc_shutup(struct hda_codec *codec)
snd_hda_shutup_pins(codec);
}
-#define alc_free snd_hda_gen_free
+static void alc_free(struct hda_codec *codec)
+{
+ snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_FREE);
+ snd_hda_gen_free(codec);
+}
#ifdef CONFIG_PM
static void alc_power_eapd(struct hda_codec *codec)
@@ -3527,6 +3531,74 @@ static void alc290_fixup_mono_speakers(struct hda_codec *codec,
snd_hda_override_wcaps(codec, 0x03, 0);
}
+#if IS_ENABLED(CONFIG_THINKPAD_ACPI)
+
+#include <linux/thinkpad_acpi.h>
+
+static int (*led_set_func)(int, bool);
+
+static void update_tpacpi_mute_led(void *private_data, int enabled)
+{
+ if (led_set_func)
+ led_set_func(TPACPI_LED_MUTE, !enabled);
+}
+
+static void update_tpacpi_micmute_led(struct hda_codec *codec,
+ struct snd_ctl_elem_value *ucontrol)
+{
+ if (!ucontrol || !led_set_func)
+ return;
+ if (strcmp("Capture Switch", ucontrol->id.name) == 0 && ucontrol->id.index == 0) {
+ /* TODO: How do I verify if it's a mono or stereo here? */
+ bool val = ucontrol->value.integer.value[0] || ucontrol->value.integer.value[1];
+ led_set_func(TPACPI_LED_MICMUTE, !val);
+ }
+}
+
+static void alc_fixup_thinkpad_acpi(struct hda_codec *codec,
+ const struct hda_fixup *fix, int action)
+{
+ struct alc_spec *spec = codec->spec;
+ bool removefunc = false;
+
+ if (action == HDA_FIXUP_ACT_PROBE) {
+ if (!led_set_func)
+ led_set_func = symbol_request(tpacpi_led_set);
+ if (!led_set_func) {
+ snd_printk(KERN_WARNING "Failed to find thinkpad-acpi symbol tpacpi_led_set\n");
+ return;
+ }
+
+ removefunc = true;
+ if (led_set_func(TPACPI_LED_MUTE, false) >= 0) {
+ spec->gen.vmaster_mute.hook = update_tpacpi_mute_led;
+ removefunc = false;
+ }
+ if (led_set_func(TPACPI_LED_MICMUTE, false) >= 0) {
+ if (spec->gen.num_adc_nids > 1)
+ snd_printdd("Skipping micmute LED control due to several ADCs");
+ else {
+ spec->gen.cap_sync_hook = update_tpacpi_micmute_led;
+ removefunc = false;
+ }
+ }
+ }
+
+ if (led_set_func && (action == HDA_FIXUP_ACT_FREE || removefunc)) {
+ symbol_put(tpacpi_led_set);
+ led_set_func = NULL;
+ }
+}
+
+#else
+
+static void alc_fixup_thinkpad_acpi(struct hda_codec *codec,
+ const struct hda_fixup *fix, int action)
+{
+}
+
+#endif
+
enum {
ALC269_FIXUP_SONY_VAIO,
ALC275_FIXUP_SONY_VAIO_GPIO2,
@@ -3570,6 +3642,7 @@ enum {
ALC282_FIXUP_ASUS_TX300,
ALC283_FIXUP_INT_MIC,
ALC290_FIXUP_MONO_SPEAKERS,
+ ALC269_FIXUP_THINKPAD_ACPI,
};
static const struct hda_fixup alc269_fixups[] = {
@@ -3867,6 +3940,12 @@ static const struct hda_fixup alc269_fixups[] = {
.chained = true,
.chain_id = ALC269_FIXUP_DELL3_MIC_NO_PRESENCE,
},
+ [ALC269_FIXUP_THINKPAD_ACPI] = {
+ .type = HDA_FIXUP_FUNC,
+ .v.func = alc_fixup_thinkpad_acpi,
+ .chained = true,
+ .chain_id = ALC269_FIXUP_LIMIT_INT_MIC_BOOST
+ },
};
static const struct snd_pci_quirk alc269_fixup_tbl[] = {
@@ -3950,7 +4029,7 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = {
SND_PCI_QUIRK(0x17aa, 0x2208, "Thinkpad T431s", ALC269_FIXUP_LENOVO_DOCK),
SND_PCI_QUIRK(0x17aa, 0x220c, "Thinkpad", ALC269_FIXUP_LIMIT_INT_MIC_BOOST),
SND_PCI_QUIRK(0x17aa, 0x2212, "Thinkpad", ALC269_FIXUP_LIMIT_INT_MIC_BOOST),
- SND_PCI_QUIRK(0x17aa, 0x2214, "Thinkpad", ALC269_FIXUP_LIMIT_INT_MIC_BOOST),
+ SND_PCI_QUIRK(0x17aa, 0x2214, "Thinkpad", ALC269_FIXUP_THINKPAD_ACPI),
SND_PCI_QUIRK(0x17aa, 0x2215, "Thinkpad", ALC269_FIXUP_LIMIT_INT_MIC_BOOST),
SND_PCI_QUIRK(0x17aa, 0x5013, "Thinkpad", ALC269_FIXUP_LIMIT_INT_MIC_BOOST),
SND_PCI_QUIRK(0x17aa, 0x501a, "Thinkpad", ALC283_FIXUP_INT_MIC),
--
1.7.9.5
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] ALSA: hda - Enable Thinkpad mute/micmute LEDs for Realtek
2013-11-05 12:11 [PATCH] ALSA: hda - Enable Thinkpad mute/micmute LEDs for Realtek David Henningsson
@ 2013-11-05 12:47 ` Takashi Iwai
0 siblings, 0 replies; 2+ messages in thread
From: Takashi Iwai @ 2013-11-05 12:47 UTC (permalink / raw)
To: David Henningsson; +Cc: hui.wang, alsa-devel
At Tue, 5 Nov 2013 13:11:37 +0100,
David Henningsson wrote:
>
> Same as we already have for Conexant. Right now it's only enabled
> for one machine.
>
> Tested-by: Hui Wang <hui.wang@canonical.com>
> Signed-off-by: David Henningsson <david.henningsson@canonical.com>
Thanks, applied.
Takashi
> ---
> sound/pci/hda/patch_realtek.c | 83 ++++++++++++++++++++++++++++++++++++++++-
> 1 file changed, 81 insertions(+), 2 deletions(-)
>
> diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
> index 01bf812..02071a5 100644
> --- a/sound/pci/hda/patch_realtek.c
> +++ b/sound/pci/hda/patch_realtek.c
> @@ -829,7 +829,11 @@ static inline void alc_shutup(struct hda_codec *codec)
> snd_hda_shutup_pins(codec);
> }
>
> -#define alc_free snd_hda_gen_free
> +static void alc_free(struct hda_codec *codec)
> +{
> + snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_FREE);
> + snd_hda_gen_free(codec);
> +}
>
> #ifdef CONFIG_PM
> static void alc_power_eapd(struct hda_codec *codec)
> @@ -3527,6 +3531,74 @@ static void alc290_fixup_mono_speakers(struct hda_codec *codec,
> snd_hda_override_wcaps(codec, 0x03, 0);
> }
>
> +#if IS_ENABLED(CONFIG_THINKPAD_ACPI)
> +
> +#include <linux/thinkpad_acpi.h>
> +
> +static int (*led_set_func)(int, bool);
> +
> +static void update_tpacpi_mute_led(void *private_data, int enabled)
> +{
> + if (led_set_func)
> + led_set_func(TPACPI_LED_MUTE, !enabled);
> +}
> +
> +static void update_tpacpi_micmute_led(struct hda_codec *codec,
> + struct snd_ctl_elem_value *ucontrol)
> +{
> + if (!ucontrol || !led_set_func)
> + return;
> + if (strcmp("Capture Switch", ucontrol->id.name) == 0 && ucontrol->id.index == 0) {
> + /* TODO: How do I verify if it's a mono or stereo here? */
> + bool val = ucontrol->value.integer.value[0] || ucontrol->value.integer.value[1];
> + led_set_func(TPACPI_LED_MICMUTE, !val);
> + }
> +}
> +
> +static void alc_fixup_thinkpad_acpi(struct hda_codec *codec,
> + const struct hda_fixup *fix, int action)
> +{
> + struct alc_spec *spec = codec->spec;
> + bool removefunc = false;
> +
> + if (action == HDA_FIXUP_ACT_PROBE) {
> + if (!led_set_func)
> + led_set_func = symbol_request(tpacpi_led_set);
> + if (!led_set_func) {
> + snd_printk(KERN_WARNING "Failed to find thinkpad-acpi symbol tpacpi_led_set\n");
> + return;
> + }
> +
> + removefunc = true;
> + if (led_set_func(TPACPI_LED_MUTE, false) >= 0) {
> + spec->gen.vmaster_mute.hook = update_tpacpi_mute_led;
> + removefunc = false;
> + }
> + if (led_set_func(TPACPI_LED_MICMUTE, false) >= 0) {
> + if (spec->gen.num_adc_nids > 1)
> + snd_printdd("Skipping micmute LED control due to several ADCs");
> + else {
> + spec->gen.cap_sync_hook = update_tpacpi_micmute_led;
> + removefunc = false;
> + }
> + }
> + }
> +
> + if (led_set_func && (action == HDA_FIXUP_ACT_FREE || removefunc)) {
> + symbol_put(tpacpi_led_set);
> + led_set_func = NULL;
> + }
> +}
> +
> +#else
> +
> +static void alc_fixup_thinkpad_acpi(struct hda_codec *codec,
> + const struct hda_fixup *fix, int action)
> +{
> +}
> +
> +#endif
> +
> enum {
> ALC269_FIXUP_SONY_VAIO,
> ALC275_FIXUP_SONY_VAIO_GPIO2,
> @@ -3570,6 +3642,7 @@ enum {
> ALC282_FIXUP_ASUS_TX300,
> ALC283_FIXUP_INT_MIC,
> ALC290_FIXUP_MONO_SPEAKERS,
> + ALC269_FIXUP_THINKPAD_ACPI,
> };
>
> static const struct hda_fixup alc269_fixups[] = {
> @@ -3867,6 +3940,12 @@ static const struct hda_fixup alc269_fixups[] = {
> .chained = true,
> .chain_id = ALC269_FIXUP_DELL3_MIC_NO_PRESENCE,
> },
> + [ALC269_FIXUP_THINKPAD_ACPI] = {
> + .type = HDA_FIXUP_FUNC,
> + .v.func = alc_fixup_thinkpad_acpi,
> + .chained = true,
> + .chain_id = ALC269_FIXUP_LIMIT_INT_MIC_BOOST
> + },
> };
>
> static const struct snd_pci_quirk alc269_fixup_tbl[] = {
> @@ -3950,7 +4029,7 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = {
> SND_PCI_QUIRK(0x17aa, 0x2208, "Thinkpad T431s", ALC269_FIXUP_LENOVO_DOCK),
> SND_PCI_QUIRK(0x17aa, 0x220c, "Thinkpad", ALC269_FIXUP_LIMIT_INT_MIC_BOOST),
> SND_PCI_QUIRK(0x17aa, 0x2212, "Thinkpad", ALC269_FIXUP_LIMIT_INT_MIC_BOOST),
> - SND_PCI_QUIRK(0x17aa, 0x2214, "Thinkpad", ALC269_FIXUP_LIMIT_INT_MIC_BOOST),
> + SND_PCI_QUIRK(0x17aa, 0x2214, "Thinkpad", ALC269_FIXUP_THINKPAD_ACPI),
> SND_PCI_QUIRK(0x17aa, 0x2215, "Thinkpad", ALC269_FIXUP_LIMIT_INT_MIC_BOOST),
> SND_PCI_QUIRK(0x17aa, 0x5013, "Thinkpad", ALC269_FIXUP_LIMIT_INT_MIC_BOOST),
> SND_PCI_QUIRK(0x17aa, 0x501a, "Thinkpad", ALC283_FIXUP_INT_MIC),
> --
> 1.7.9.5
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2013-11-05 12:47 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-11-05 12:11 [PATCH] ALSA: hda - Enable Thinkpad mute/micmute LEDs for Realtek David Henningsson
2013-11-05 12:47 ` Takashi Iwai
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.