From: Mario Limonciello <mario_limonciello@dell.com>
To: "matthew.garrett@nebula.com" <matthew.garrett@nebula.com>
Cc: LKML <linux-kernel@vger.kernel.org>,
"platform-driver-x86@vger.kernel.org"
<platform-driver-x86@vger.kernel.org>
Subject: Re: [PATCH 3/3] Capture cable events created by Alienware GFX Amplifier.
Date: Wed, 27 May 2015 18:46:05 -0500 [thread overview]
Message-ID: <5566573D.4000300@dell.com> (raw)
In-Reply-To: <1432755422-26024-4-git-send-email-mario_limonciello@dell.com>
On 05/27/2015 02:37 PM, Limonciello, Mario wrote:
> These events are outputted via the keyboard controller.
> Right now the only actionable event is to restart the system
> if the cable is removed, but the others are documented in
> case they will be bubbled up to other parts of the kernel or
> userspace later on.
>
> Signed-off-by: Mario Limonciello <mario_limonciello@dell.com>
> ---
> drivers/platform/x86/Kconfig | 1 +
> drivers/platform/x86/alienware-wmi.c | 45 ++++++++++++++++++++++++++++++++++++
> 2 files changed, 46 insertions(+)
>
> diff --git a/drivers/platform/x86/Kconfig b/drivers/platform/x86/Kconfig
> index f9f205c..8a7bd7c 100644
> --- a/drivers/platform/x86/Kconfig
> +++ b/drivers/platform/x86/Kconfig
> @@ -60,6 +60,7 @@ config ALIENWARE_WMI
> depends on LEDS_CLASS
> depends on NEW_LEDS
> depends on ACPI_WMI
> + depends on SERIO_I8042
> ---help---
> This is a driver for controlling Alienware BIOS driven
> features. It exposes an interface for controlling the AlienFX
> diff --git a/drivers/platform/x86/alienware-wmi.c b/drivers/platform/x86/alienware-wmi.c
> index 5bd8faf..ffccbd9 100644
> --- a/drivers/platform/x86/alienware-wmi.c
> +++ b/drivers/platform/x86/alienware-wmi.c
> @@ -23,6 +23,8 @@
> #include <linux/dmi.h>
> #include <linux/acpi.h>
> #include <linux/leds.h>
> +#include <linux/i8042.h>
> +#include <linux/reboot.h>
>
> #define LEGACY_CONTROL_GUID "A90597CE-A997-11DA-B012-B622A1EF5492"
> #define LEGACY_POWER_CONTROL_GUID "A80593CE-A997-11DA-B012-B622A1EF5492"
> @@ -650,6 +652,44 @@ error_create_amplifier:
> return ret;
> }
>
> +static bool alienware_i8042_filter(unsigned char data, unsigned char str,
> + struct serio *port)
> +{
> + static bool extended;
> +
> + if (str & I8042_STR_AUXDATA)
> + return false;
> +
> + if (unlikely(data == 0xe0)) {
> + extended = true;
> + return false;
> + } else if (unlikely(extended)) {
> + switch (data) {
> + /*Connect */
> + case 0x3F:
> + pr_debug("Received connect event\n");
> + break;
> + /* Disconnect by hotkey */
> + case 0x40:
> + pr_debug("Received disconnect hotkey event\n");
> + break;
> + /*disconnect by cable undock button */
> + case 0x41:
> + pr_debug("Received disconnect button event\n");
> + break;
> + /* surprise disconnect */
> + case 0x42:
> + pr_crit("Graphics amplifier removed, initiating reboot.\n");
> + emergency_restart();
I had some discussion with someone in #systemd. Just to clarify why the
reboot is needed I wanted to mention it here.
X does continue to run and the kernel doesn't panic, but the GPU drivers
gets stuck in a hung state.
Restarting X or plugging the cable back in doesn't actually fix it.
Since you just pulled your U/I from under yourself you don't really have
a way to message what happened, or to fix this other than restarting the
system.
I also later discovered that this should probably be:
orderly_reboot();
I'll resubmit with that change after any other discussion around
iterating with this.
> + break;
> + }
> + extended = false;
> + }
> +
> + return false;
> +}
> +
> +
> static int __init alienware_wmi_init(void)
> {
> int ret;
> @@ -689,6 +729,9 @@ static int __init alienware_wmi_init(void)
> ret = create_amplifier(platform_device);
> if (ret)
> goto fail_prep_amplifier;
> + ret = i8042_install_filter(alienware_i8042_filter);
> + if (ret)
> + goto fail_prep_i8042;
> }
>
> ret = alienware_zone_init(platform_device);
> @@ -699,6 +742,7 @@ static int __init alienware_wmi_init(void)
>
> fail_prep_zones:
> alienware_zone_exit(platform_device);
> +fail_prep_i8042:
> fail_prep_amplifier:
> fail_prep_hdmi:
> platform_device_del(platform_device);
> @@ -715,6 +759,7 @@ module_init(alienware_wmi_init);
> static void __exit alienware_wmi_exit(void)
> {
> if (platform_device) {
> + i8042_remove_filter(alienware_i8042_filter);
> alienware_zone_exit(platform_device);
> remove_hdmi(platform_device);
> platform_device_unregister(platform_device);
next prev parent reply other threads:[~2015-05-27 23:46 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-05-27 19:36 [PATCH 0/3] Add support for X51-R3 to alienware-wmi Mario Limonciello
2015-05-27 19:37 ` [PATCH 1/3] Add support for X51-R3 Mario Limonciello
2015-05-27 19:37 ` [PATCH 2/3] Add support for Alienware graphics amplifier Mario Limonciello
2015-05-27 19:37 ` [PATCH 3/3] Capture cable events created by Alienware GFX Amplifier Mario Limonciello
2015-05-27 23:46 ` Mario Limonciello [this message]
2015-05-28 18:30 ` Greg KH
2015-05-28 18:50 ` Mario Limonciello
2015-05-28 20:34 ` Greg KH
2015-05-28 18:29 ` Greg KH
2015-06-03 23:17 ` [PATCH 0/3] Add support for X51-R3 to alienware-wmi Mario Limonciello
2015-06-16 5:25 ` Mario Limonciello
2015-06-30 19:02 ` Mario Limonciello
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=5566573D.4000300@dell.com \
--to=mario_limonciello@dell.com \
--cc=linux-kernel@vger.kernel.org \
--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;
as well as URLs for NNTP newsgroup(s).