From: Matthew Garrett <mjg@redhat.com>
To: linux-acpi@vger.kernel.org
Cc: ibm-acpi@hmh.eng.br, ibm-acpi-devel@lists.sourceforge.net,
platform-driver-x86@vger.kernel.org,
Matthew Garrett <mjg@redhat.com>
Subject: [PATCH 2/2] thinkpad_acpi: Hook volume events
Date: Mon, 3 May 2010 16:03:00 -0400 [thread overview]
Message-ID: <1272916980-11835-2-git-send-email-mjg@redhat.com> (raw)
In-Reply-To: <1272916980-11835-1-git-send-email-mjg@redhat.com>
Not all Thinkpads generate events for volume hotkeys, so hook into the
CMOS update and generate events from there without polling. This should
let Pulseaudio do something sensible with the mute state.
Signed-off-by: Matthew Garrett <mjg@redhat.com>
---
drivers/platform/x86/thinkpad_acpi.c | 32 ++++++++++++++++++++++++++++++++
1 files changed, 32 insertions(+), 0 deletions(-)
diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c
index 63290b3..c8c4f2b 100644
--- a/drivers/platform/x86/thinkpad_acpi.c
+++ b/drivers/platform/x86/thinkpad_acpi.c
@@ -3083,6 +3083,15 @@ static const struct tpacpi_quirk tpacpi_hotkey_qtable[] __initconst = {
TPACPI_Q_IBM('1', 'D', TPACPI_HK_Q_INIMASK), /* X22, X23, X24 */
};
+static void volume_alsa_notify_change(void);
+static int volume_check_status(void);
+
+static void cmos_notifier(void *context)
+{
+ if (volume_check_status())
+ volume_alsa_notify_change();
+}
+
static int __init hotkey_init(struct ibm_init_struct *iibm)
{
/* Requirements for changing the default keymaps:
@@ -4939,11 +4948,16 @@ static int __init cmos_init(struct ibm_init_struct *iibm)
if (res)
return res;
+ if (cmos_handle)
+ acpi_install_method_handler(cmos_handle, cmos_notifier,
+ iibm->data);
+
return (cmos_handle)? 0 : 1;
}
static void cmos_exit(void)
{
+ acpi_remove_method_handler(cmos_handle, cmos_notifier);
device_remove_file(&tpacpi_pdev->dev, &dev_attr_cmos_command);
}
@@ -6458,6 +6472,7 @@ static enum tpacpi_volume_access_mode volume_mode =
static enum tpacpi_volume_capabilities volume_capabilities;
static int volume_control_allowed;
+static u8 volume_state;
/*
* Used to syncronize writers to TP_EC_AUDIO and
@@ -6544,6 +6559,21 @@ static int volume_set_status(const u8 status)
return volume_set_status_ec(status);
}
+static int volume_check_status()
+{
+ u8 new_state;
+ int ret = 0;
+
+ volume_get_status(&new_state);
+
+ if (new_state != volume_state) {
+ ret = 1;
+ volume_state = new_state;
+ }
+
+ return ret;
+}
+
/* returns < 0 on error, 0 on no change, 1 on change */
static int __volume_set_mute_ec(const bool mute)
{
@@ -6931,6 +6961,8 @@ static int __init volume_init(struct ibm_init_struct *iibm)
return rc;
}
+ volume_get_status(&volume_state);
+
printk(TPACPI_INFO
"Console audio control enabled, mode: %s\n",
(volume_control_allowed) ?
--
1.7.0.1
next prev parent reply other threads:[~2010-05-03 20:03 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-05-03 20:02 [PATCH 1/2] acpi: Provide interface for driver notification on method call Matthew Garrett
2010-05-03 20:03 ` Matthew Garrett [this message]
2010-05-05 11:30 ` [PATCH 2/2] thinkpad_acpi: Hook volume events Henrique de Moraes Holschuh
2010-05-05 13:20 ` Matthew Garrett
2010-05-06 3:02 ` Henrique de Moraes Holschuh
[not found] ` <20100506030239.GB19265-ZGHd14iZgfaRjzvQDGKj+xxZW9W5cXbT@public.gmane.org>
2010-05-06 12:47 ` Matthew Garrett
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=1272916980-11835-2-git-send-email-mjg@redhat.com \
--to=mjg@redhat.com \
--cc=ibm-acpi-devel@lists.sourceforge.net \
--cc=ibm-acpi@hmh.eng.br \
--cc=linux-acpi@vger.kernel.org \
--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;
as well as URLs for NNTP newsgroup(s).