[PATCH 2/2] thinkpad-acpi: add sysfs for enabling and disabling hardware mute

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Thinkpad BIOS provides an ACPI interface to disable hardware mute.
When enabled (as default), Thinkpad issues a scancode and toggles
hardware mute + led. Once disabled, Thinkpad will only issues the
scancode.

When hardware mute is enabled, hardware mute can be out-of-sync
with user-space if a user changes mute state by user application.
This patch gives a chance to disable hardware mute.

Signed-off-by: Alex Hung <alex.hung@xxxxxxxxxxxxx>
---
 drivers/platform/x86/thinkpad_acpi.c | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)

diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c
index 3b648c0..a901fac 100644
--- a/drivers/platform/x86/thinkpad_acpi.c
+++ b/drivers/platform/x86/thinkpad_acpi.c
@@ -2978,6 +2978,32 @@ static struct device_attribute dev_attr_hotkey_mute_state =
 	__ATTR(hotkey_mute_state, S_IWUSR | S_IRUGO,
 	hotkey_mute_state_show, hotkey_mute_state_store);
 
+/* sysfs hotkey_mute_enable -------------------------------------------- */
+static ssize_t hotkey_mute_enable_store(struct device *dev,
+			    struct device_attribute *attr,
+			    const char *buf, size_t count)
+{
+	unsigned long state;
+	int output;
+
+	if (parse_strtoul(buf, 25, &state))
+		return -EINVAL;
+
+	if (state != 1 && state != 0)
+		return -EINVAL;
+
+	if (!acpi_evalf(hkey_handle, &output, "SHDA", "dd", state))
+		return -EIO;
+
+	if (output & TPACPI_AML_MUTE_ERROR_STATE_MASK)
+		return -EIO;
+
+	return count;
+}
+
+static struct device_attribute dev_attr_hotkey_mute_enable =
+	__ATTR(hotkey_mute_enable, S_IWUSR, NULL, hotkey_mute_enable_store);
+
 /* --------------------------------------------------------------------- */
 
 static struct attribute *hotkey_attributes[] __initdata = {
@@ -2995,6 +3021,7 @@ static struct attribute *hotkey_attributes[] __initdata = {
 	&dev_attr_hotkey_poll_freq.attr,
 #endif
 	&dev_attr_hotkey_mute_state.attr,
+	&dev_attr_hotkey_mute_enable.attr,
 };
 
 /*
-- 
1.8.1.2


------------------------------------------------------------------------------
Get 100% visibility into Java/.NET code with AppDynamics Lite!
It's a free troubleshooting tool designed for production.
Get down to code-level detail for bottlenecks, with <2% overhead. 
Download for free and get started troubleshooting in minutes. 
http://pubads.g.doubleclick.net/gampad/clk?id=48897031&iu=/4140/ostg.clktrk
_______________________________________________
ibm-acpi-devel mailing list
ibm-acpi-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.sourceforge.net/lists/listinfo/ibm-acpi-devel



[Index of Archives]     [Linux ACPI]     [Linux Kernel]     [Linux Laptop]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Photo]     [Yosemite Photos]     [Yosemite Advice]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Device Mapper]

  Powered by Linux