surface pro 3: Add support driver for Surface Pro 3 buttons
PATCH 1/1 surface pro 3: Add support driver for Surface Pro 3 buttons
Since Surface Pro 3 does not follow the specs of "Windows ACPI Design Guide for SoC Platform", code in drivers/input/misc/soc_array.c can not detect these buttons on it. According to bios implementation, Surface Pro 3 encapsulates these buttons in a device named "VGBI", with _HID "MSHW0028". When any of the buttons is pressed, a specify ACPI notification code for this button will be delivered to "VGBI". For example, if power button is pressed down, ACPI notification code of 0xc6 will be sent by Notify(VGBI, 0xc6).
This patch leverages "VGBI" to distinguish different ACPI notification code from Power button, Home button, Volume button, then dispatches these code to input layer. Lid is already covered by acpi button driver, so there's no need to rewrite.
Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=84651
--- MAINTAINERS | 5 + drivers/platform/x86/Kconfig | 5 + drivers/platform/x86/Makefile | 1 + drivers/platform/x86/surfacepro3_button.c | 203 ++++++++++++++++++++++++++++++ 4 files changed, 214 insertions(+) create mode 100644 drivers/platform/x86/surfacepro3_button.c
MAINTAINERS +5 -0
@@ -6712,6 +6712,11 @@ T: git git://git.monstr.eu/linux-2.6-microblaze.git S: Supported F: arch/microblaze/ +MICROSOFT SURFACE PRO 3 BUTTON DRIVER +M: Chen Yu <[email protected]> +S: Supported +F: drivers/platform/x86/surfacepro3_button.c + MICROTEK X6 SCANNER M: Oliver Neukum <[email protected]> S: Maintained
drivers/platform/x86/Kconfig +5 -0
@@ -919,4 +919,9 @@ config INTEL_PMC_IPC The PMC is an ARC processor which defines IPC commands for communication with other entities in the CPU. +config SURFACE_PRO3_BUTTON + tristate "Power/home/volume buttons driver for Microsoft Surface Pro 3 tablet" + depends on ACPI && INPUT + ---help--- + This driver handles the power/home/volume buttons on the Microsoft Surface Pro 3 tablet. endif # X86_PLATFORM_DEVICES
drivers/platform/x86/Makefile +1 -0
@@ -60,3 +60,4 @@ obj-$(CONFIG_INTEL_SMARTCONNECT) += intel-smartconnect.o obj-$(CONFIG_PVPANIC) += pvpanic.o obj-$(CONFIG_ALIENWARE_WMI) += alienware-wmi.o obj-$(CONFIG_INTEL_PMC_IPC) += intel_pmc_ipc.o +obj-$(CONFIG_SURFACE_PRO3_BUTTON) += surfacepro3_button.o
drivers/platform/x86/surfacepro3_button.c new file +203 -0
203 lines not on this page · raw message
Signature · 1 line
1.8.4.2
Quoted 3 lines · Chen Yu
Since Surface Pro 3 does not follow the specs of "Windows ACPI Design Guide for SoC Platform", code in
drivers/input/misc/soc_array.ccan not detect these buttons on it.
style trivia:
drivers/platform/x86/surfacepro3_button.c
Quoted 1 line
drivers/platform/x86/surfacepro3_button.c +0
-0
[]
drivers/platform/x86/surfacepro3_button.c
Quoted 2 lines
drivers/platform/x86/surfacepro3_button.c +2
-0+static void surface_button_notify (struct acpi_device *device,u32 event) +{
[]
drivers/platform/x86/surfacepro3_button.c line 78
Quoted 4 lines
drivers/platform/x86/surfacepro3_button.c +4
-0+switch (event) { +case SURFACE_BUTTON_NOTIFY_PRESS_POWER : + pressed = true; +/*go through*/
/* fall through */ is more common
drivers/platform/x86/surfacepro3_button.c line 86
Quoted 5 lines
drivers/platform/x86/surfacepro3_button.c +5
-0+case SURFACE_BUTTON_NOTIFY_PRESS_HOME : + pressed = true; +case SURFACE_BUTTON_NOTIFY_RELEASE_HOME : + key_code =KEY_LEFTMETA ; +break ;
It may be better to add a comment about the style or maybe add a macro like
#define HANDLE_SURFACE_BUTTON_NOTIFY(type, code) \ case SURFACE_BUTTON_NOTIFY_PRESS_##type: \ pressed = true; /* and fall-through */ \ case SURFACE_BUTTON_NOTIFY_RELEASE_##type: \ key_code = code; \ break;
Quoted 4 lines
drivers/platform/x86/surfacepro3_button.c +4
-0+case SURFACE_BUTTON_NOTIFY_PRESS_VOLUME_UP : + pressed = true; +case SURFACE_BUTTON_NOTIFY_RELEASE_VOLUME_UP : + key_code =KEY_VOLUMEUP ;
drivers/platform/x86/surfacepro3_button.c line 99
Quoted 10 lines
drivers/platform/x86/surfacepro3_button.c +9
-0+break ; +case SURFACE_BUTTON_NOTIFY_PRESS_VOLUME_DOWN : + pressed = true; +case SURFACE_BUTTON_NOTIFY_RELEASE_VOLUME_DOWN : + key_code =KEY_VOLUMEDOWN ; +break ; +default : +dev_info (&device->dev, +"Unsupported event [0x%x]\n" , event);
It might be useful to ratelimit this
Thanks Joe,
Quoted 12 lines · Joe Perches
Quoted 3 lines · Chen Yu
Since Surface Pro 3 does not follow the specs of "Windows ACPI Design Guide for SoC Platform", code in
drivers/input/misc/soc_array.ccan not detect these buttons on it.style trivia:
drivers/platform/x86/surfacepro3_button.c
Quoted 1 line
drivers/platform/x86/surfacepro3_button.c +0
-0[]
drivers/platform/x86/surfacepro3_button.c
Quoted 2 lines
drivers/platform/x86/surfacepro3_button.c +2
-0+static void surface_button_notify (struct acpi_device *device,u32 event) +{[]
Quoted 7 lines
drivers/platform/x86/surfacepro3_button.c line 78
Quoted 4 lines
drivers/platform/x86/surfacepro3_button.c +4
-0+switch (event) { +case SURFACE_BUTTON_NOTIFY_PRESS_POWER : + pressed = true; +/*go through*/ /* fall through */ is more common
OK.
Quoted 9 lines
drivers/platform/x86/surfacepro3_button.c line 86
Quoted 5 lines
drivers/platform/x86/surfacepro3_button.c +5
-0+case SURFACE_BUTTON_NOTIFY_PRESS_HOME : + pressed = true; +case SURFACE_BUTTON_NOTIFY_RELEASE_HOME : + key_code =KEY_LEFTMETA ; +break ;It may be better to add a comment about the style or maybe add a macro like
Quoted 7 lines
#define HANDLE_SURFACE_BUTTON_NOTIFY(type, code) \ case SURFACE_BUTTON_NOTIFY_PRESS_##type: \ pressed = true; /* and fall-through */ \ case SURFACE_BUTTON_NOTIFY_RELEASE_##type: \ key_code = code; \ break;
WRT macro HANDLE_SURFACE_BUTTON_NOTIFY, the checkpatch.pl complains that multi lines of codes should be wrapped in 'do while'state, but doing like this might lead to incorrect semantic. Is it ok to keep these codes and add comments like:
/*
* When a button(power button/volume button/home button) is
* pressed down or released, different ACPI notification codes
* will be generated. We can distinguish different event code
* and value of buttons by these notification codes, then pass
* (EV_KEY, event code(key_code), value(pressed)) to input layer. */
Quoted 6 lines
Quoted 5 lines
drivers/platform/x86/surfacepro3_button.c +5
-0+case SURFACE_BUTTON_NOTIFY_PRESS_VOLUME_UP : + pressed = true; +case SURFACE_BUTTON_NOTIFY_RELEASE_VOLUME_UP : + key_code =KEY_VOLUMEUP ; +break ;
Quoted 11 lines
drivers/platform/x86/surfacepro3_button.c line 99
Quoted 8 lines
drivers/platform/x86/surfacepro3_button.c +8
-0+case SURFACE_BUTTON_NOTIFY_PRESS_VOLUME_DOWN : + pressed = true; +case SURFACE_BUTTON_NOTIFY_RELEASE_VOLUME_DOWN : + key_code =KEY_VOLUMEDOWN ; +break ; +default : +dev_info (&device->dev, +"Unsupported event [0x%x]\n" , event);It might be useful to ratelimit this
OK, changed to dev_info_ratelimited
Quoted 1 line
Best Regards,
Yu
Quoted 1 line · Yu C
On Wed, 2015-08-05 at 22:30 -0700, Joe Perches wrote:
[]
Quoted 16 lines
Quoted 9 lines
drivers/platform/x86/surfacepro3_button.c line 86
Quoted 5 lines
drivers/platform/x86/surfacepro3_button.c new file +5
-0+case SURFACE_BUTTON_NOTIFY_PRESS_HOME : + pressed = true; +case SURFACE_BUTTON_NOTIFY_RELEASE_HOME : + key_code =KEY_LEFTMETA ; +break ;It may be better to add a comment about the style or maybe add a macro like
Quoted 7 lines
#define HANDLE_SURFACE_BUTTON_NOTIFY(type, code) \ case SURFACE_BUTTON_NOTIFY_PRESS_##type: \ pressed = true; /* and fall-through */ \ case SURFACE_BUTTON_NOTIFY_RELEASE_##type: \ key_code = code; \ break;
Quoted 3 lines
WRT macro
HANDLE_SURFACE_BUTTON_NOTIFY, the checkpatch.pl complains that multi lines of codes should be wrapped in 'do while'state, but doing like this might lead to incorrect semantic.
checkpatch is a brainless tool that should be ignored whenever you want.
Quoted 1 line
Is it ok to keep these codes and add comments like:
Up to you. It'd OK to do nothing too.
Quoted 38 lines · Yu C
Thanks Joe,
Quoted 12 lines · Joe Perches
Quoted 3 lines · Chen Yu
Since Surface Pro 3 does not follow the specs of "Windows ACPI Design Guide for SoC Platform", code in
drivers/input/misc/soc_array.ccan not detect these buttons on it.style trivia:
drivers/platform/x86/surfacepro3_button.c
Quoted 1 line
drivers/platform/x86/surfacepro3_button.c +0
-0[]
drivers/platform/x86/surfacepro3_button.c
Quoted 2 lines
drivers/platform/x86/surfacepro3_button.c +2
-0+static void surface_button_notify (struct acpi_device *device,u32 event) +{[]
Quoted 7 lines
drivers/platform/x86/surfacepro3_button.c line 78
Quoted 4 lines
drivers/platform/x86/surfacepro3_button.c +4
-0+switch (event) { +case SURFACE_BUTTON_NOTIFY_PRESS_POWER : + pressed = true; +/*go through*/ /* fall through */ is more common
OK.
Quoted 9 lines
drivers/platform/x86/surfacepro3_button.c line 86
Quoted 5 lines
drivers/platform/x86/surfacepro3_button.c +5
-0+case SURFACE_BUTTON_NOTIFY_PRESS_HOME : + pressed = true; +case SURFACE_BUTTON_NOTIFY_RELEASE_HOME : + key_code =KEY_LEFTMETA ; +break ;It may be better to add a comment about the style or maybe add a macro like
Quoted 7 lines
#define HANDLE_SURFACE_BUTTON_NOTIFY(type, code) \ case SURFACE_BUTTON_NOTIFY_PRESS_##type: \ pressed = true; /* and fall-through */ \ case SURFACE_BUTTON_NOTIFY_RELEASE_##type: \ key_code = code; \ break;
Quoted 11 lines
WRT macro
HANDLE_SURFACE_BUTTON_NOTIFY, the checkpatch.pl complains that multi lines of codes should be wrapped in 'do while'state, but doing like this might lead to incorrect semantic. Is it ok to keep these codes and add comments like:
/*
* When a button(power button/volume button/home button) is
* pressed down or released, different ACPI notification codes
* will be generated. We can distinguish different event code
* and value of buttons by these notification codes, then pass
* (EV_KEY, eventcode(key_code), value(pressed)) to input layer. */
The commentary is useful regardless. However, I suspect Joe was referring to the approach pairing the PRESS and RELEASE cases?
Signature · 2 lines
Darren Hart Intel Open Source Technology Center
Quoted 1 line · Darren Hart
On Thu, Aug 06, 2015 at 11:20:44AM +0000, Chen, Yu C wrote:
[]
Quoted 1 line
Quoted 1 line
Is it ok to keep these codes and add comments like:
It's your code Yu, do whatever you think appropriate.
Quoted 11 lines
Quoted 7 lines
/*
* When a button(power button/volume button/home button) is
* pressed down or released, different ACPI notification codes
* will be generated. We can distinguish different event code
* and value of buttons by these notification codes, then pass
* (EV_KEY, eventcode(key_code), value(pressed)) to input layer. */The commentary is useful regardless. However, I suspect Joe was referring to the approach pairing the PRESS and RELEASE cases?
True.
btw Darren, your computer's email time setting seems off.
Quoted 15 lines · Joe Perches
Quoted 1 line · Darren Hart
On Thu, Aug 06, 2015 at 11:20:44AM +0000, Chen, Yu C wrote:
[]
Quoted 1 line
Quoted 1 line
Is it ok to keep these codes and add comments like:
It's your code Yu, do whatever you think appropriate.
Quoted 8 lines
Quoted 7 lines
/*
* When a button(power button/volume button/home button) is
* pressed down or released, different ACPI notification codes
* will be generated. We can distinguish different event code
* and value of buttons by these notification codes, then pass
* (EV_KEY, eventcode(key_code), value(pressed)) to input layer. */
Quoted 7 lines
Quoted 3 lines
The commentary is useful regardless. However, I suspect Joe was referring to the approach pairing the PRESS and RELEASE cases?
True.
btw Darren, your computer's email time setting seems off.
Nothing gets past kernel devs! Corporate firewall broke ntp for Linux VM from where I sent this, didn't notice until too late.
Signature · 2 lines
Darren Hart Intel Open Source Technology Center
Hi, Darren and Joe,
Quoted 5 lines · Darren Hart
On Thu, Aug 06, 2015 at 11:20:44AM +0000, Chen, Yu C wrote:
The commentary is useful regardless. However, I suspect Joe was referring to the approach pairing the PRESS and RELEASE cases?
I've wrote another piece of Macro to make it pairing the PRESS and RELEASE cases, would you please help check if it is suitable,thanks for your time.
PS: I resend another patch titled with v2.
Best Regards,
Yu