From: Seth Forshee <seth.forshee@canonical.com>
To: Corentin Chary <corentin.chary@gmail.com>
Cc: Chris Bagwell <chris@cnpbagwell.com>,
Matthew Garrett <mjg@redhat.com>,
acpi4asus-user@lists.sourceforge.net,
platform-driver-x86@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: [PATCH 2/2] eeepc-wmi: Add support for T101MT Home/Express Gate key
Date: Thu, 24 Mar 2011 15:03:55 -0500 [thread overview]
Message-ID: <1300997035-14104-2-git-send-email-seth.forshee@canonical.com> (raw)
In-Reply-To: <20110324195720.GB31713@thinkpad-t410>
This key is different than other hotkeys, having seperate scan
codes for press, release, and hold, so it requires some special
handling.
Note that "Home" in the context of this button doesn't mean the
same thing as the usual Home key, and it really isn't clear at
all what is meant by "Home". The manufacurer's description of the
button indicates that it should launch some sort of touch screen
settings interface on short press and apply a desktop rotation on
long press.
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
---
drivers/platform/x86/eeepc-wmi.c | 87 +++++++++++++++++++++++++++++++++-----
1 files changed, 76 insertions(+), 11 deletions(-)
diff --git a/drivers/platform/x86/eeepc-wmi.c b/drivers/platform/x86/eeepc-wmi.c
index 0ddc434..f9b0ee4 100644
--- a/drivers/platform/x86/eeepc-wmi.c
+++ b/drivers/platform/x86/eeepc-wmi.c
@@ -56,6 +56,19 @@ MODULE_PARM_DESC(hotplug_wireless,
"If your laptop needs that, please report to "
"acpi4asus-user@lists.sourceforge.net.");
+struct eeepc_wmi_driver {
+ struct asus_wmi_driver asus_wmi_driver;
+ int home_key_state;
+};
+
+#define to_eeepc_wmi_driver(asus_drv) \
+ container_of((asus_drv), struct eeepc_wmi_driver, asus_wmi_driver)
+
+/* Values for T101MT "Home" key */
+#define HOME_PRESS 0xe4
+#define HOME_HOLD 0xea
+#define HOME_RELEASE 0xe5
+
static const struct key_entry eeepc_wmi_keymap[] = {
/* Sleep already handled via generic ACPI code */
{ KE_KEY, 0x30, { KEY_VOLUMEUP } },
@@ -70,7 +83,9 @@ static const struct key_entry eeepc_wmi_keymap[] = {
{ KE_KEY, 0xcc, { KEY_SWITCHVIDEOMODE } },
{ KE_KEY, 0xe0, { KEY_PROG1 } }, /* Task Manager */
{ KE_KEY, 0xe1, { KEY_F14 } }, /* Change Resolution */
+ { KE_KEY, HOME_PRESS, { BTN_TASK } },
{ KE_KEY, 0xe9, { KEY_BRIGHTNESS_ZERO } },
+ { KE_KEY, HOME_HOLD, { KEY_PROG2 } },
{ KE_KEY, 0xeb, { KEY_CAMERA_ZOOMOUT } },
{ KE_KEY, 0xec, { KEY_CAMERA_UP } },
{ KE_KEY, 0xed, { KEY_CAMERA_DOWN } },
@@ -79,6 +94,52 @@ static const struct key_entry eeepc_wmi_keymap[] = {
{ KE_END, 0},
};
+static void eeepc_wmi_key_filter(struct asus_wmi_driver *asus_wmi, int *code,
+ int *value, int *autorelease)
+{
+ struct eeepc_wmi_driver *eeepc = to_eeepc_wmi_driver(asus_wmi);
+ int is_press;
+
+ /*
+ * The following behavior is used for T101MT "Home" key:
+ *
+ * On press: No event set
+ * On hold: KEY_PROG2 press sent once w/o autorelease
+ * On release: If key was held, KEY_PROG2 release sent.
+ * Otherwise KEY_HOME press sent w/ autorelease.
+ *
+ * The simple state machine below implements this behavior.
+ */
+ switch (*code) {
+ case HOME_PRESS:
+ eeepc->home_key_state = HOME_PRESS;
+ *code = ASUS_WMI_KEY_IGNORE;
+ break;
+ case HOME_HOLD:
+ if (eeepc->home_key_state == HOME_HOLD) {
+ *code = ASUS_WMI_KEY_IGNORE;
+ } else {
+ eeepc->home_key_state = HOME_HOLD;
+ *value = 1;
+ *autorelease = 0;
+ }
+ break;
+ case HOME_RELEASE:
+ if (eeepc->home_key_state == HOME_RELEASE) {
+ dev_warn(&asus_wmi->platform_device->dev,
+ "Unexpected home key release event\n");
+ *code = ASUS_WMI_KEY_IGNORE;
+ } else {
+ *code = eeepc->home_key_state;
+ eeepc->home_key_state = HOME_RELEASE;
+ is_press = (*code == HOME_PRESS);
+ *value = is_press;
+ *autorelease = is_press;
+ }
+ break;
+ }
+}
+
static acpi_status eeepc_wmi_parse_device(acpi_handle handle, u32 level,
void *context, void **retval)
{
@@ -142,26 +203,30 @@ static void eeepc_wmi_quirks(struct asus_wmi_driver *driver)
eeepc_dmi_check(driver);
}
-static struct asus_wmi_driver asus_wmi_driver = {
- .name = EEEPC_WMI_FILE,
- .owner = THIS_MODULE,
- .event_guid = EEEPC_WMI_EVENT_GUID,
- .keymap = eeepc_wmi_keymap,
- .input_name = "Eee PC WMI hotkeys",
- .input_phys = EEEPC_WMI_FILE "/input0",
- .probe = eeepc_wmi_probe,
- .quirks = eeepc_wmi_quirks,
+static struct eeepc_wmi_driver eeepc_wmi_driver = {
+ .asus_wmi_driver = {
+ .name = EEEPC_WMI_FILE,
+ .owner = THIS_MODULE,
+ .event_guid = EEEPC_WMI_EVENT_GUID,
+ .keymap = eeepc_wmi_keymap,
+ .input_name = "Eee PC WMI hotkeys",
+ .input_phys = EEEPC_WMI_FILE "/input0",
+ .key_filter = eeepc_wmi_key_filter,
+ .probe = eeepc_wmi_probe,
+ .quirks = eeepc_wmi_quirks,
+ },
+ .home_key_state = HOME_RELEASE,
};
static int __init eeepc_wmi_init(void)
{
- return asus_wmi_register_driver(&asus_wmi_driver);
+ return asus_wmi_register_driver(&eeepc_wmi_driver.asus_wmi_driver);
}
static void __exit eeepc_wmi_exit(void)
{
- asus_wmi_unregister_driver(&asus_wmi_driver);
+ asus_wmi_unregister_driver(&eeepc_wmi_driver.asus_wmi_driver);
}
module_init(eeepc_wmi_init);
--
1.7.4.1
next prev parent reply other threads:[~2011-03-24 20:04 UTC|newest]
Thread overview: 41+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-03-23 19:39 [PATCH] eeepc-wmi: Add support for T101MT "Express Gate" key Seth Forshee
2011-03-24 7:33 ` Corentin Chary
2011-03-24 13:14 ` Seth Forshee
2011-03-24 13:26 ` Corentin Chary
2011-03-24 13:27 ` Chris Bagwell
2011-03-24 13:32 ` Chris Bagwell
2011-03-24 13:37 ` Seth Forshee
2011-03-24 13:40 ` Corentin Chary
2011-03-24 14:00 ` Chris Bagwell
2011-03-24 19:57 ` Seth Forshee
2011-03-24 20:03 ` [PATCH 1/2] asus-wmi: Add callback for hotkey filtering Seth Forshee
2011-03-24 20:03 ` Seth Forshee [this message]
2011-03-24 20:09 ` [PATCH 2/2] eeepc-wmi: Add support for T101MT Home/Express Gate key Seth Forshee
2011-03-25 13:28 ` Corentin Chary
2011-03-25 13:53 ` Seth Forshee
2011-03-25 14:05 ` Corentin Chary
2011-03-25 14:53 ` Chris Bagwell
2011-03-25 15:13 ` Seth Forshee
2011-03-25 15:43 ` Corentin Chary
2011-03-25 16:17 ` Seth Forshee
2011-03-25 16:14 ` Dmitry Torokhov
2011-03-25 16:28 ` Seth Forshee
2011-03-25 17:03 ` Dmitry Torokhov
2011-03-25 18:58 ` Seth Forshee
2011-03-27 17:13 ` Dmitry Torokhov
2011-03-27 18:32 ` Chris Bagwell
2011-03-27 19:11 ` Dmitry Torokhov
2011-03-28 13:46 ` Seth Forshee
2011-03-28 14:14 ` Corentin Chary
2011-03-28 18:33 ` Seth Forshee
2011-03-28 18:33 ` [PATCH v3 1/3] asus-wmi: Add callback for hotkey filtering Seth Forshee
2011-03-28 18:33 ` [PATCH v3 2/3] eeepc-wmi: Add support for T101MT Home/Express Gate key Seth Forshee
2011-03-29 12:29 ` Corentin Chary
2011-03-29 13:42 ` Seth Forshee
2011-03-29 13:47 ` Matthew Garrett
2011-03-30 7:46 ` Corentin Chary
2011-03-28 18:33 ` [PATCH v3 3/3] asus-wmi: Enable autorepeat for hotkey input device Seth Forshee
2011-03-29 6:33 ` [PATCH 2/2] eeepc-wmi: Add support for T101MT Home/Express Gate key Dmitry Torokhov
2011-03-25 16:07 ` [PATCH] eeepc-wmi: Add support for T101MT "Express Gate" key Dmitry Torokhov
2011-03-25 16:08 ` Corentin Chary
2011-03-25 16:05 ` Dmitry Torokhov
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=1300997035-14104-2-git-send-email-seth.forshee@canonical.com \
--to=seth.forshee@canonical.com \
--cc=acpi4asus-user@lists.sourceforge.net \
--cc=chris@cnpbagwell.com \
--cc=corentin.chary@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mjg@redhat.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
all inboxes | Powered by JetHome®