add support for acpi interfaces of thinkpad hardware mute
cover add support for acpi interfaces of thinkpad hardware mute
Newer Thinkpad models comes with a mute hotkey with a mute led. It also comes with ACPI AML functions to control hardware mute + led. The patches add supports to enable/disable and to change mute and its led via thinkpad-acpi.
Alex Hung (2):
thinkpad-acpi: add a kernel parameter to disable hardware mute and its
led
thinkpad-acpi: support hardware mute and led
drivers/platform/x86/thinkpad_acpi.c | 103 +++++++++++++++++++++++++++++++++++ 1 file changed, 103 insertions(+)
Signature · 1 line
1.8.1.2
PATCH 1/2 thinkpad-acpi: add a kernel parameter to disable hardware mute and its led
Some new Thinkpad has a mute button with led. This mute led can out-of-sync with mute in user interface. This kernel parameter disables the hardware mute and led to avoid confusion. The hotkey will only issue scancode to UI.
--- drivers/platform/x86/thinkpad_acpi.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
drivers/platform/x86/thinkpad_acpi.c +14 -0
@@ -253,6 +253,9 @@ enum tpacpi_hkey_event_t {#define strlencmp (a, b) (strncmp((a), (b), strlen(b))) +static bool use_hardware_mute =1 ; +module_param (use_hardware_mute, bool,0644 ); +/**************************************************************************** * Driver-wide structs and misc. variables */
@@ -3327,6 +3330,17 @@ static int __init hotkey_init(struct ibm_init_struct *iibm)if (res) goto err_exit; +if (!use_hardware_mute) { +acpi_handle temp; + +if (!ACPI_SUCCESS (acpi_get_handle (hkey_handle,"SHDA" , &temp))) +pr_info ("hardware mute interface is not supported\n" ); +else { +if (!acpi_evalf (hkey_handle, &status,"SHDA" ,"dd" ,1 )) +pr_info ("failed to disable hardware mute\n" ); + } + } +/* Set up key map */ hotkey_keycode_map =kmalloc (TPACPI_HOTKEY_MAP_SIZE ,GFP_KERNEL );
Signature · 1 line
1.8.1.2
PATCH 2/2 thinkpad-acpi: support hardware mute and led
In reply to Alex HungNewer thinkpad models have a mute hotkey with a led to indicate current mute states. Thinkpad BIOS provides ACPI interfaces for getting and changing the hardware mute along with the led.
--- drivers/platform/x86/thinkpad_acpi.c | 89 ++++++++++++++++++++++++++++++++++++ 1 file changed, 89 insertions(+)
drivers/platform/x86/thinkpad_acpi.c +89 -0
@@ -8364,6 +8364,91 @@ static struct ibm_struct fan_driver_data = { .resume = fan_resume, }; +/************************************************************************* +* Mute LED subdriver +*/ + +enum { +TPACPI_AML_MUTE_READ_MASK =0x01 , +}; + +static int mute_led_on_off (int state) +{ +int output; +acpi_handle temp; + +if (!ACPI_SUCCESS (acpi_get_handle (hkey_handle,"SSMS" , &temp))) { +pr_warn ("Thinkpad ACPI has no GSMS interface.\n" ); +return -EIO ; + } + +if (!acpi_evalf (hkey_handle, &output,"SSMS" ,"dd" , state)) +return -EIO ; + +return 0 ; +} + +static void mute_led_set (struct led_classdev *led_cdev, +enum led_brightness value) +{ +if (value >0 ) +mute_led_on_off (1 ); +else +mute_led_on_off (0 ); +} + +static enum led_brightness mute_led_get (struct led_classdev *led_cdev) +{ +int state =0 ; +acpi_handle temp; + +if (!ACPI_SUCCESS (acpi_get_handle (hkey_handle,"GSMS" , &temp))) { +pr_warn ("Thinkpad ACPI has no GSMS interface.\n" ); +return -EIO ; + } + +if (!acpi_evalf (hkey_handle, &state,"GSMS" ,"dd" )) +pr_warn ("failed to get hardware mute state.\n" ); + + state &=TPACPI_AML_MUTE_READ_MASK ; + +return state; +} + +static struct tpacpi_led_classdev tpacpi_led_mute = { + .led_classdev = { + .name ="tpacpi::mute" , + .brightness_set = mute_led_set, + .brightness_get = mute_led_get, + } +}; + +static int mute_led_init (struct ibm_init_struct *iibm) +{ +acpi_handle temp; + +if (!ACPI_SUCCESS (acpi_get_handle (hkey_handle,"GSMS" , &temp))) +return 0 ; + +return led_classdev_register (&tpacpi_pdev->dev, + &tpacpi_led_mute.led_classdev); +} + +static void mute_led_exit (void ) +{ +acpi_handle temp; + +if (!ACPI_SUCCESS (acpi_get_handle (hkey_handle,"GSMS" , &temp))) +return ; + +led_classdev_unregister (&tpacpi_led_mute.led_classdev); +} + +static struct ibm_struct mute_led_driver_data = { + .name ="mute_led" , + .exit = mute_led_exit, +}; +/**************************************************************************** **************************************************************************** *
@@ -8782,6 +8867,10 @@ static struct ibm_init_struct ibms_init[] __initdata = { .init = fan_init, .data = &fan_driver_data, }, + { + .init = mute_led_init, + .data = &mute_led_driver_data, + }, };static int __init set_ibm_param (const char *val,struct kernel_param *kp)
Signature · 1 line
1.8.1.2