ALSA: hda - Enable mute/mic-mute LEDs for more Thinkpads with Realtek codec
Subsystems (3)
PATCH 1/1 ALSA: hda - Enable mute/mic-mute LEDs for more Thinkpads with Realtek codec
We're using the ACPI interface to detect whether we're dealing with a Thinkpad or not. This way we're not loading the thinkpad_acpi module when we're not on a Thinkpad, but at the same time, we give the opportunity to check for, and potentially enable, both present and future Thinkpad with mute/micmute LEDs.
At least those running the ALC269 family (269 to 299) of Realtek codecs.
--- sound/pci/hda/patch_realtek.c | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-)
Hi Takashi,
Sorry I'm late with this one. I'm hoping that you can still merge it for 3.13, but if you can't, we'll just backport it into the Ubuntu 3.13 kernel instead, so not the end of the world I guess.
sound/pci/hda/patch_realtek.c +26 -3
@@ -3652,9 +3652,29 @@ static void alc290_fixup_mono_speakers(struct hda_codec *codec,#if IS_ENABLED (CONFIG_THINKPAD_ACPI )#include <linux/thinkpad_acpi.h> +#include <acpi/acpi.h> static int (*led_set_func)(int ,bool ); +static acpi_status acpi_check_cb (acpi_handle handle,u32 lvl,void *context, +void **rv) +{ +bool *found = context; + *found = true; +return AE_OK ; +} + +static bool is_thinkpad (struct hda_codec *codec) +{ +bool found = false; +if (codec->subsystem_id >>16 !=0x17aa ) +return false; +if (ACPI_SUCCESS (acpi_get_devices ("LEN0068" , acpi_check_cb, &found,NULL )) && found) +return true; + found = false; +return ACPI_SUCCESS (acpi_get_devices ("IBM0068" , acpi_check_cb, &found,NULL )) && found; +} +static void update_tpacpi_mute_led (void *private_data,int enabled) {if (led_set_func)
@@ -3680,6 +3700,8 @@ static void alc_fixup_thinkpad_acpi(struct hda_codec *codec,bool removefunc = false;if (action ==HDA_FIXUP_ACT_PROBE ) { +if (!is_thinkpad (codec)) +return ;if (!led_set_func) led_set_func =symbol_request (tpacpi_led_set);if (!led_set_func) {
@@ -4027,6 +4049,8 @@ static const struct hda_fixup alc269_fixups[] = { [ALC269_FIXUP_LIMIT_INT_MIC_BOOST] = { .type = HDA_FIXUP_FUNC, .v.func = alc269_fixup_limit_int_mic_boost, + .chained = true, + .chain_id = ALC269_FIXUP_THINKPAD_ACPI, }, [ALC269_FIXUP_LIMIT_INT_MIC_BOOST_MUTE_LED] = { .type = HDA_FIXUP_FUNC,
@@ -4070,8 +4094,6 @@ static const struct hda_fixup alc269_fixups[] = { [ALC269_FIXUP_THINKPAD_ACPI] = { .type = HDA_FIXUP_FUNC, .v.func = alc_fixup_thinkpad_acpi, - .chained = true, - .chain_id =ALC269_FIXUP_LIMIT_INT_MIC_BOOST }, [ALC255_FIXUP_DELL1_MIC_NO_PRESENCE] = { .type = HDA_FIXUP_PINS,
@@ -4173,7 +4195,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_THINKPAD_ACPI ), +SND_PCI_QUIRK (0x17aa ,0x2214 ,"Thinkpad" ,ALC269_FIXUP_LIMIT_INT_MIC_BOOST ),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),
@@ -4181,6 +4203,7 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = {SND_PCI_QUIRK (0x17aa ,0x5109 ,"Thinkpad" ,ALC269_FIXUP_LIMIT_INT_MIC_BOOST ),SND_PCI_QUIRK (0x17aa ,0x3bf8 ,"Quanta FL1" ,ALC269_FIXUP_PCM_44K ),SND_PCI_QUIRK (0x17aa ,0x9e54 ,"LENOVO NB" ,ALC269_FIXUP_LENOVO_EAPD ), +SND_PCI_QUIRK_VENDOR (0x17aa ,"Thinkpad" ,ALC269_FIXUP_THINKPAD_ACPI ),SND_PCI_QUIRK (0x1b7d ,0xa831 ,"Ordissimo EVE2 " ,ALC269VB_FIXUP_ORDISSIMO_EVE2 ),/* Also known as Malata PC-B1303 */ #if 0
Signature · 1 line
1.7.9.5
At Mon, 18 Nov 2013 11:51:47 +0100,
Quoted 15 lines · David Henningsson
We're using the ACPI interface to detect whether we're dealing with a Thinkpad or not. This way we're not loading the
thinkpad_acpimodule when we're not on a Thinkpad, but at the same time, we give the opportunity to check for, and potentially enable, both present and future Thinkpad with mute/micmute LEDs.At least those running the ALC269 family (269 to 299) of Realtek codecs.
Cc Alex Hung <[email protected]>Tested-by Hui Wang <[email protected]>Signed-off-by David Henningsson <[email protected]>--- sound/pci/hda/patch_realtek.c | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-)
Quoted 5 lines
Hi Takashi,
Sorry I'm late with this one. I'm hoping that you can still merge it for 3.13, but if you can't, we'll just backport it into the Ubuntu 3.13 kernel instead, so not the end of the world I guess.
OK, I merged it now, as it's not too intrusive, and the build test without CONFIG_ACPI passed.
thanks,
Takashi
Quoted 82 lines
sound/pci/hda/patch_realtek.c +26
-3@@ -3652,9 +3652,29 @@ static void alc290_fixup_mono_speakers(struct hda_codec *codec,#if IS_ENABLED (CONFIG_THINKPAD_ACPI )#include <linux/thinkpad_acpi.h> +#include <acpi/acpi.h> static int (*led_set_func)(int ,bool ); +static acpi_status acpi_check_cb (acpi_handle handle,u32 lvl,void *context, +void **rv) +{ +bool *found = context; + *found = true; +return AE_OK ; +} + +static bool is_thinkpad (struct hda_codec *codec) +{ +bool found = false; +if (codec->subsystem_id >>16 !=0x17aa ) +return false; +if (ACPI_SUCCESS (acpi_get_devices ("LEN0068" , acpi_check_cb, &found,NULL )) && found) +return true; + found = false; +return ACPI_SUCCESS (acpi_get_devices ("IBM0068" , acpi_check_cb, &found,NULL )) && found; +} +static void update_tpacpi_mute_led (void *private_data,int enabled) {if (led_set_func)@@ -3680,6 +3700,8 @@ static void alc_fixup_thinkpad_acpi(struct hda_codec *codec,bool removefunc = false;if (action ==HDA_FIXUP_ACT_PROBE ) { +if (!is_thinkpad (codec)) +return ;if (!led_set_func) led_set_func =symbol_request (tpacpi_led_set);if (!led_set_func) {@@ -4027,6 +4049,8 @@ static const struct hda_fixup alc269_fixups[] = { [ALC269_FIXUP_LIMIT_INT_MIC_BOOST] = { .type = HDA_FIXUP_FUNC, .v.func = alc269_fixup_limit_int_mic_boost, + .chained = true, + .chain_id = ALC269_FIXUP_THINKPAD_ACPI, }, [ALC269_FIXUP_LIMIT_INT_MIC_BOOST_MUTE_LED] = { .type = HDA_FIXUP_FUNC,@@ -4070,8 +4094,6 @@ static const struct hda_fixup alc269_fixups[] = { [ALC269_FIXUP_THINKPAD_ACPI] = { .type = HDA_FIXUP_FUNC, .v.func = alc_fixup_thinkpad_acpi, - .chained = true, - .chain_id =ALC269_FIXUP_LIMIT_INT_MIC_BOOST }, [ALC255_FIXUP_DELL1_MIC_NO_PRESENCE] = { .type = HDA_FIXUP_PINS,@@ -4173,7 +4195,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_THINKPAD_ACPI ), +SND_PCI_QUIRK (0x17aa ,0x2214 ,"Thinkpad" ,ALC269_FIXUP_LIMIT_INT_MIC_BOOST ),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),@@ -4181,6 +4203,7 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = {SND_PCI_QUIRK (0x17aa ,0x5109 ,"Thinkpad" ,ALC269_FIXUP_LIMIT_INT_MIC_BOOST ),SND_PCI_QUIRK (0x17aa ,0x3bf8 ,"Quanta FL1" ,ALC269_FIXUP_PCM_44K ),SND_PCI_QUIRK (0x17aa ,0x9e54 ,"LENOVO NB" ,ALC269_FIXUP_LENOVO_EAPD ), +SND_PCI_QUIRK_VENDOR (0x17aa ,"Thinkpad" ,ALC269_FIXUP_THINKPAD_ACPI ),SND_PCI_QUIRK (0x1b7d ,0xa831 ,"Ordissimo EVE2 " ,ALC269VB_FIXUP_ORDISSIMO_EVE2 ),/* Also known as Malata PC-B1303 */ #if 0Signature · 1 line
1.7.9.5
Quoted 17 lines · Takashi Iwai
At Mon, 18 Nov 2013 11:51:47 +0100,
Quoted 15 lines · David Henningsson
We're using the ACPI interface to detect whether we're dealing with a Thinkpad or not. This way we're not loading the
thinkpad_acpimodule when we're not on a Thinkpad, but at the same time, we give the opportunity to check for, and potentially enable, both present and future Thinkpad with mute/micmute LEDs.At least those running the ALC269 family (269 to 299) of Realtek codecs.
Cc Alex Hung <[email protected]>Tested-by Hui Wang <[email protected]>Signed-off-by David Henningsson <[email protected]>--- sound/pci/hda/patch_realtek.c | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-)
Quoted 7 lines
Quoted 5 lines
Hi Takashi,
Sorry I'm late with this one. I'm hoping that you can still merge it for 3.13, but if you can't, we'll just backport it into the Ubuntu 3.13 kernel instead, so not the end of the world I guess.
OK, I merged it now, as it's not too intrusive,
Ok, thanks a lot!
Quoted 2 lines
and the build test
withoutCONFIG_ACPIpassed.
Yeah, I don't think thinkpad_acpi will stop depend on acpi anytime soon... :-)
Anyway, I'm attaching two more patches - one for enabling thinkpad_acpi on the lenovo_dock fixup (I must have missed this in the previous patch), and one for hda-emu.
Quoted 90 lines
thanks,
Takashi
Quoted 82 lines
sound/pci/hda/patch_realtek.c +26
-3@@ -3652,9 +3652,29 @@ static void alc290_fixup_mono_speakers(struct hda_codec *codec,#if IS_ENABLED (CONFIG_THINKPAD_ACPI )#include <linux/thinkpad_acpi.h> +#include <acpi/acpi.h> static int (*led_set_func)(int ,bool ); +static acpi_status acpi_check_cb (acpi_handle handle,u32 lvl,void *context, +void **rv) +{ +bool *found = context; + *found = true; +return AE_OK ; +} + +static bool is_thinkpad (struct hda_codec *codec) +{ +bool found = false; +if (codec->subsystem_id >>16 !=0x17aa ) +return false; +if (ACPI_SUCCESS (acpi_get_devices ("LEN0068" , acpi_check_cb, &found,NULL )) && found) +return true; + found = false; +return ACPI_SUCCESS (acpi_get_devices ("IBM0068" , acpi_check_cb, &found,NULL )) && found; +} +static void update_tpacpi_mute_led (void *private_data,int enabled) {if (led_set_func)@@ -3680,6 +3700,8 @@ static void alc_fixup_thinkpad_acpi(struct hda_codec *codec,bool removefunc = false;if (action ==HDA_FIXUP_ACT_PROBE ) { +if (!is_thinkpad (codec)) +return ;if (!led_set_func) led_set_func =symbol_request (tpacpi_led_set);if (!led_set_func) {@@ -4027,6 +4049,8 @@ static const struct hda_fixup alc269_fixups[] = { [ALC269_FIXUP_LIMIT_INT_MIC_BOOST] = { .type = HDA_FIXUP_FUNC, .v.func = alc269_fixup_limit_int_mic_boost, + .chained = true, + .chain_id = ALC269_FIXUP_THINKPAD_ACPI, }, [ALC269_FIXUP_LIMIT_INT_MIC_BOOST_MUTE_LED] = { .type = HDA_FIXUP_FUNC,@@ -4070,8 +4094,6 @@ static const struct hda_fixup alc269_fixups[] = { [ALC269_FIXUP_THINKPAD_ACPI] = { .type = HDA_FIXUP_FUNC, .v.func = alc_fixup_thinkpad_acpi, - .chained = true, - .chain_id =ALC269_FIXUP_LIMIT_INT_MIC_BOOST }, [ALC255_FIXUP_DELL1_MIC_NO_PRESENCE] = { .type = HDA_FIXUP_PINS,@@ -4173,7 +4195,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_THINKPAD_ACPI ), +SND_PCI_QUIRK (0x17aa ,0x2214 ,"Thinkpad" ,ALC269_FIXUP_LIMIT_INT_MIC_BOOST ),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),@@ -4181,6 +4203,7 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = {SND_PCI_QUIRK (0x17aa ,0x5109 ,"Thinkpad" ,ALC269_FIXUP_LIMIT_INT_MIC_BOOST ),SND_PCI_QUIRK (0x17aa ,0x3bf8 ,"Quanta FL1" ,ALC269_FIXUP_PCM_44K ),SND_PCI_QUIRK (0x17aa ,0x9e54 ,"LENOVO NB" ,ALC269_FIXUP_LENOVO_EAPD ), +SND_PCI_QUIRK_VENDOR (0x17aa ,"Thinkpad" ,ALC269_FIXUP_THINKPAD_ACPI ),SND_PCI_QUIRK (0x1b7d ,0xa831 ,"Ordissimo EVE2 " ,ALC269VB_FIXUP_ORDISSIMO_EVE2 ),/* Also known as Malata PC-B1303 */ #if 0Signature · 1 line
1.7.9.5
Signature · 2 lines
David Henningsson, Canonical Ltd. https://launchpad.net/~diwic
Quoted 1 line
From
c4b634f2a7fb7a970907b89df99d2333201e8534Mon Sep 17 00:00:00 2001
From: David Henningsson <[email protected]>
Date: Tue, 19 Nov 2013 10:55:17 +0100
Subject: [PATCH] hda-emu: Add acpi.h header
This is needed for the new acpi functionality in patch_realtek.c.
--- include/acpi/acpi.h | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 include/acpi/acpi.h
include/acpi/acpi.h new file +36 -0
@@ -0,0 +1,36 @@ +#ifndef __ACPI_H__ +#define __ACPI_H__ + +/* Copy-pasted from acpixf.h, acexcep.h and actypes.h. */ + +/* +* Miscellaneous types +*/ +typedef u32 acpi_status ;/* All ACPI Exceptions */ +typedef u32 acpi_name ;/* 4-byte ACPI name */ +typedef char *acpi_string ;/* Null terminated ASCII string */ +typedef void *acpi_handle ;/* Actually a ptr to a NS Node */ + +typedef +acpi_status (*acpi_walk_callback ) (acpi_handle object, +u32 nesting_level, +void *context,void **return_value); + +/* +* Success is always zero, failure is non-zero +*/ +#define ACPI_SUCCESS (a) (!(a)) +#define ACPI_FAILURE (a) (a) + +#define ACPI_SKIP (a) (a == AE_CTRL_SKIP) +#define AE_OK (acpi_status) 0x0000 + +static inline acpi_status +acpi_get_devices (const char *HID , +acpi_walk_callback user_function, +void *context,void **return_value) +{ +return user_function (NULL ,0 , context,NULL ); +} + +#endif /* __ACPI_H__ */
Signature · 1 line
1.7.9.5
Quoted 1 line
From
026e9cb7c2527dc42448d9ae414eb8ab9661ee24Mon Sep 17 00:00:00 2001
From: David Henningsson <[email protected]>
Date: Tue, 19 Nov 2013 10:25:53 +0100
Subject: [PATCH] ALSA: hda - Also enable mute/micmute LED control for "Lenovo
dock" fixup
The docking station is a Thinkpad thing, so it makes sense to check for mute/micmute LEDs for that quirk type too.
--- sound/pci/hda/patch_realtek.c | 2 ++ 1 file changed, 2 insertions(+)
sound/pci/hda/patch_realtek.c +2 -0
@@ -3945,6 +3945,8 @@ static const struct hda_fixup alc269_fixups[] = { [ALC269_FIXUP_PINCFG_NO_HP_TO_LINEOUT] = { .type = HDA_FIXUP_FUNC, .v.func = alc269_fixup_pincfg_no_hp_to_lineout, + .chained = true, + .chain_id = ALC269_FIXUP_THINKPAD_ACPI, }, [ALC269_FIXUP_DELL1_MIC_NO_PRESENCE] = { .type = HDA_FIXUP_PINS,
Signature · 1 line
1.7.9.5
Takashi Iwai
AppliedAt Tue, 19 Nov 2013 11:09:19 +0100,
Quoted 32 lines · David Henningsson
Quoted 17 lines · Takashi Iwai
At Mon, 18 Nov 2013 11:51:47 +0100,
Quoted 15 lines · David Henningsson
We're using the ACPI interface to detect whether we're dealing with a Thinkpad or not. This way we're not loading the
thinkpad_acpimodule when we're not on a Thinkpad, but at the same time, we give the opportunity to check for, and potentially enable, both present and future Thinkpad with mute/micmute LEDs.At least those running the ALC269 family (269 to 299) of Realtek codecs.
Cc Alex Hung <[email protected]>Tested-by Hui Wang <[email protected]>Signed-off-by David Henningsson <[email protected]>--- sound/pci/hda/patch_realtek.c | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-)Quoted 7 lines
Quoted 5 lines
Hi Takashi,
Sorry I'm late with this one. I'm hoping that you can still merge it for 3.13, but if you can't, we'll just backport it into the Ubuntu 3.13 kernel instead, so not the end of the world I guess.
OK, I merged it now, as it's not too intrusive,
Ok, thanks a lot!
Quoted 2 lines
and the build test
withoutCONFIG_ACPIpassed.
Quoted 6 lines
Yeah, I don't think
thinkpad_acpiwill stop depend on acpi anytime soon... :-)Anyway, I'm attaching two more patches - one for enabling
thinkpad_acpion thelenovo_dockfixup (I must have missed this in the previous patch), and one for hda-emu.
Thanks, applied both patch.
Takashi