Skip to contentSkip to conversation

surface pro 3: Add support driver for Surface Pro 3 buttons

PATCH In review Chen Yu 4 participants 6 messages Aug 18, 2015 – Sep 3, 2015 x86 platform drivers

lore
Share & tools
lore

Chen Yu

author
#0 lore raw

PATCH v4 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

---
v4:
- Add following code in driver's probe callback:

	if (strncmp(acpi_device_bid(device), SURFACE_BUTTON_OBJ_NAME,
	    strlen(SURFACE_BUTTON_OBJ_NAME)))
		return -ENODEV;

to make sure only device object name of 'VGBI' will load this driver. Because it is reported that, Surface 3(no Pro) also has a device with hid MSHW0028, but it is not a button device.

v3:
- Revert handle_surface_button_notify and keep original 'switch/case' in surface_button_notify. Add/fix some comments for surface_button_notify.

v2:
- Introduce MACRO handle_surface_button_notify to make it pairing the PRESS and RELEASE cases, convert dev_info to dev_info_ratelimited when in error condition.

---
 MAINTAINERS                               |   5 +
 drivers/platform/x86/Kconfig              |   5 +
 drivers/platform/x86/Makefile             |   1 +
 drivers/platform/x86/surfacepro3_button.c | 215 ++++++++++++++++++++++++++++++
 4 files changed, 226 insertions(+)
 create mode 100644 drivers/platform/x86/surfacepro3_button.c
MAINTAINERS +5 -0
index 569568f..eacaa41 100644
@@ -6721,6 +6721,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
index 6dc13e4..c69bb70 100644
@@ -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
index dda95a9..ada5128 100644
@@ -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 +215 -0

215 lines not on this page · raw message

Signature · 1 line
1.8.4.2
#1 lore raw
Quoted 14 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.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.

Quoted 6 lines

Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=84651

Joe, you provided a lot of review, are you happy with this version?

Rafael, any concerns over the justification to use ACPI instead of platform_driver/i2c_driver as described in the comment block below?

Chen, a couple more nitpics below. No need to resend if Joe and Rafael have no objections. I'll correct and queue. For now, queued to testing. Thanks!

Quoted 33 lines

---
v4:
- Add following code in driver's probe callback:

	if (strncmp(acpi_device_bid(device), SURFACE_BUTTON_OBJ_NAME,
	    strlen(SURFACE_BUTTON_OBJ_NAME)))
		return -ENODEV;

to make sure only device object name of 'VGBI' will load this driver. Because it is reported that, Surface 3(no Pro) also has a device with hid MSHW0028, but it is not a button device.

v3:
- Revert handle_surface_button_notify and keep original 'switch/case' in surface_button_notify. Add/fix some comments for surface_button_notify.

v2:
- Introduce MACRO handle_surface_button_notify to make it pairing the PRESS and RELEASE cases, convert dev_info to dev_info_ratelimited when in error condition.

---
 MAINTAINERS                               |   5 +
 drivers/platform/x86/Kconfig              |   5 +
 drivers/platform/x86/Makefile             |   1 +
 drivers/platform/x86/surfacepro3_button.c | 215 ++++++++++++++++++++++++++++++
 4 files changed, 226 insertions(+)
 create mode 100644 drivers/platform/x86/surfacepro3_button.c
MAINTAINERS +0 -0
index 569568f..eacaa41 100644

MAINTAINERS T: git git://git.monstr.eu/linux-2.6-microblaze.git · line 6725

Quoted 5 lines
MAINTAINERS +2 -0
@@ -6721,6 +6721,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]>

It's typical to include the list here as well:

L: [email protected]

MAINTAINERS T: git git://git.monstr.eu/linux-2.6-microblaze.git · line 6727

Quoted 2 lines
MAINTAINERS +2 -0
+S:    Supported
+F:    drivers/platform/x86/surfacepro3_button.c

Also, spaces should have been tabs to be consistent with existing whitespace usage in MAINTAINERS. Consider displaying whitespace in your editor if you don't already.

Quoted 33 lines
MAINTAINERS +1 -0
+
 MICROTEK X6 SCANNER
 M:	Oliver Neukum <[email protected]>
 S:	Maintained
drivers/platform/x86/Kconfig +5 -0
index 6dc13e4..c69bb70 100644
@@ -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
index dda95a9..ada5128 100644
@@ -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 +0 -0
new file mode 100644
index 0000000..6c6f11c

drivers/platform/x86/surfacepro3_button.c line 5

Quoted 5 lines
drivers/platform/x86/surfacepro3_button.c new file +5 -0
@@ -0,0 +1,215 @@
+/*
+ * power/home/volume button support for
+ * Microsoft Surface Pro 3 tablet.
+ *
+ * (C) Copyright 2015 Intel Corporation

Intel standard copyright notice:

Copyright (c) 2015, Intel Corporation.
All rights reserved.

But the (c) generally always goes after Copyright

Signature · 2 lines
Darren Hart
Intel Open Source Technology Center
#2 lore raw
Quoted 9 lines · Darren Hart
Quoted 8 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.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).

[]

Quoted 1 line

Joe, you provided a lot of review, are you happy with this version?

It looks fine.

Thanks for picking the other little nits too Darren.

#3 lore raw
Quoted 10 lines · Joe Perches
Quoted 9 lines · Darren Hart
Quoted 8 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.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).

Quoted 6 lines

[]

Quoted 1 line

Joe, you provided a lot of review, are you happy with this version?

It looks fine.

Thanks for picking the other little nits too Darren.

This is not queued for next.

Signature · 2 lines
Darren Hart
Intel Open Source Technology Center
#4 lore raw
Quoted 11 lines · Darren Hart
Quoted 10 lines · Joe Perches
Quoted 9 lines · Darren Hart
Quoted 8 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.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).

Quoted 8 lines
Quoted 6 lines

[]

Quoted 1 line

Joe, you provided a lot of review, are you happy with this version?

It looks fine.

Thanks for picking the other little nits too Darren.

This is not queued for next.

Not or now? If not, why not?

josh

#5 lore raw
Quoted 15 lines · Josh Boyer
Quoted 14 lines · Darren Hart
Quoted 13 lines · Joe Perches
Quoted 9 lines · Darren Hart
Quoted 8 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.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).

[]

Quoted 1 line

Joe, you provided a lot of review, are you happy with this version?

Quoted 7 lines
Quoted 5 lines
Quoted 3 lines

It looks fine.

Thanks for picking the other little nits too Darren.

This is not queued for next.

Not or now? If not, why not?

Sorry, typo :-)

It is queued for next, you'll find it in my "for-next" branch as well as in linux-next currently.

Signature · 2 lines
Darren Hart
Intel Open Source Technology Center