From: Alex Hung <alex.hung@canonical.com>
To: alex.hung@canonical.com, ibm-acpi@hmh.eng.br,
matthew.garrett@nebula.com, ibm-acpi-devel@lists.sourceforge.net,
platform-driver-x86@vger.kernel.org
Subject: [PATCH 1/2] thinkpad-acpi: add sysfs for getting and setting hardware mute
Date: Wed, 14 Aug 2013 13:40:01 +0800 [thread overview]
Message-ID: <1376458802-11923-2-git-send-email-alex.hung@canonical.com> (raw)
In-Reply-To: <1376458802-11923-1-git-send-email-alex.hung@canonical.com>
Newer 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.
Signed-off-by: Alex Hung <alex.hung@canonical.com>
---
drivers/platform/x86/thinkpad_acpi.c | 50 ++++++++++++++++++++++++++++++++++++
1 file changed, 50 insertions(+)
diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c
index 54d31c0..3b648c0 100644
--- a/drivers/platform/x86/thinkpad_acpi.c
+++ b/drivers/platform/x86/thinkpad_acpi.c
@@ -2929,6 +2929,55 @@ static void hotkey_wakeup_hotunplug_complete_notify_change(void)
"wakeup_hotunplug_complete");
}
+/* sysfs hotkey_mute_state --------------------------------------------- */
+enum {
+ TPACPI_AML_MUTE_READ_MASK = 0x01,
+ TPACPI_AML_MUTE_ERROR_STATE_MASK = 0x80000000,
+};
+
+static ssize_t hotkey_mute_state_show(struct device *dev,
+ struct device_attribute *attr,
+ char *buf)
+{
+ int state;
+
+ if (!acpi_evalf(hkey_handle, &state, "GSMS", "dd"))
+ return -EIO;
+
+ if (state & TPACPI_AML_MUTE_ERROR_STATE_MASK)
+ pr_warn("getting mute state failed.\n");
+
+ state &= TPACPI_AML_MUTE_READ_MASK;
+
+ return snprintf(buf, PAGE_SIZE, "%x\n", state);
+}
+
+static ssize_t hotkey_mute_state_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, "SSMS", "dd", state))
+ return -EIO;
+
+ if (output & TPACPI_AML_MUTE_ERROR_STATE_MASK)
+ return -EIO;
+
+ return count;
+}
+
+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);
+
/* --------------------------------------------------------------------- */
static struct attribute *hotkey_attributes[] __initdata = {
@@ -2945,6 +2994,7 @@ static struct attribute *hotkey_attributes[] __initdata = {
&dev_attr_hotkey_source_mask.attr,
&dev_attr_hotkey_poll_freq.attr,
#endif
+ &dev_attr_hotkey_mute_state.attr,
};
/*
--
1.8.1.2
next prev parent reply other threads:[~2013-08-14 5:40 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-08-14 5:40 [PATCH 0/2] add sysfs for acpi interfaces of thinkpad hardware mute Alex Hung
2013-08-14 5:40 ` Alex Hung [this message]
2013-08-14 5:40 ` [PATCH 2/2] thinkpad-acpi: add sysfs for enabling and disabling " Alex Hung
[not found] ` <1376458802-11923-1-git-send-email-alex.hung-Z7WLFzj8eWMS+FvcfC7Uqw@public.gmane.org>
2013-08-14 5:42 ` [PATCH 0/2] add sysfs for acpi interfaces of thinkpad " Matthew Garrett
2013-08-14 5:53 ` Alex Hung
2013-08-14 5:54 ` Matthew Garrett
2013-08-14 6:11 ` Alex Hung
2013-08-14 6:14 ` Matthew Garrett
2013-08-14 6:41 ` Alex Hung
2013-08-14 7:00 ` Matthew Garrett
2013-08-14 7:08 ` Alex Hung
[not found] ` <CAJ=jqubWWeWH+xsGrTVaNguNuw7gm2E=CZmXY_SxO+Bxg1Hxag-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2013-08-14 23:30 ` Henrique de Moraes Holschuh
2013-08-14 7:16 ` Alex Hung
2013-08-14 7:43 ` David Henningsson
2013-08-14 7:51 ` Matthew Garrett
2013-08-14 9:27 ` David Henningsson
2013-08-14 14:57 ` Matthew Garrett
2013-08-14 19:53 ` David Henningsson
2013-08-14 20:05 ` Matthew Garrett
2013-08-14 20:36 ` David Henningsson
2013-08-14 20:38 ` Matthew Garrett
2013-08-14 20:59 ` David Henningsson
2013-08-14 21:15 ` Matthew Garrett
2013-08-15 14:55 ` David Henningsson
2013-08-15 14:24 ` [alsa-devel] " Arun Raghavan
[not found] ` <CAJ=jqub1sRSzBRv_R6soDVAydRL+5nmA9-pMC4E+sgXhP6tbPw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2013-08-14 6:15 ` Alex Hung
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1376458802-11923-2-git-send-email-alex.hung@canonical.com \
--to=alex.hung@canonical.com \
--cc=ibm-acpi-devel@lists.sourceforge.net \
--cc=ibm-acpi@hmh.eng.br \
--cc=matthew.garrett@nebula.com \
--cc=platform-driver-x86@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox