ソースを参照

Update v5.9 patches

Changes:
 - SAM:
   - Fix typos in kernel doc.

 - GPE:
   - Add support for 15" Intel-based Surface Laptop 3

 - misc:
   - Turn-off typecover backlight when suspending.

Links:
 - SAM: https://github.com/linux-surface/surface-aggregator-module/commit/414658f8c247e94e5d3f3201dd188e46e078affa
 - GPE: https://github.com/linux-surface/surface-gpe/commit/35fc41f3f0801826143f9761b2b16fd82e8ebb0d
 - kernel: https://github.com/linux-surface/kernel/commit/cf69cdf4c1d1cd99c52b6642551b278fda03d91a
Maximilian Luz 4 年 前
コミット
e6fdaf8ddd

+ 1 - 1
patches/5.9/0001-surface3-oemb.patch

@@ -1,4 +1,4 @@
-From dadbf16bf0d1d1adb32690f7855301dbe8d7262e Mon Sep 17 00:00:00 2001
+From bcc470a5c0698f5706378ff82eedda63ccd35d1a Mon Sep 17 00:00:00 2001
 From: Tsuchiya Yuto <kitakar@gmail.com>
 Date: Sun, 18 Oct 2020 16:42:44 +0900
 Subject: [PATCH] (surface3-oemb) add DMI matches for Surface 3 with broken DMI

+ 12 - 12
patches/5.9/0002-wifi.patch

@@ -1,4 +1,4 @@
-From 42fe2b89d9670455d396f63e5dc6dbcdf98d07c5 Mon Sep 17 00:00:00 2001
+From 74c77b82a0a8af9fd8c87bc401fab7c06c5ec796 Mon Sep 17 00:00:00 2001
 From: Tsuchiya Yuto <kitakar@gmail.com>
 Date: Thu, 24 Sep 2020 18:02:06 +0900
 Subject: [PATCH] mwifiex: pcie: skip cancel_work_sync() on reset failure path
@@ -156,7 +156,7 @@ index fc59b522f670..048f4db6027a 100644
 -- 
 2.29.2
 
-From 958d23356668aba685e2b3f6d7035e616c167370 Mon Sep 17 00:00:00 2001
+From 17333080602c7f3054d13254737445325430f4a2 Mon Sep 17 00:00:00 2001
 From: Tsuchiya Yuto <kitakar@gmail.com>
 Date: Mon, 28 Sep 2020 17:46:49 +0900
 Subject: [PATCH] mwifiex: pcie: add DMI-based quirk impl for Surface devices
@@ -364,7 +364,7 @@ index 000000000000..5326ae7e5671
 -- 
 2.29.2
 
-From c0c0073a829e6e49ce3f338a21133d1035369cc8 Mon Sep 17 00:00:00 2001
+From 50f22e019a84229ef1a49485dc5d1e22da542fff Mon Sep 17 00:00:00 2001
 From: Tsuchiya Yuto <kitakar@gmail.com>
 Date: Tue, 29 Sep 2020 17:25:22 +0900
 Subject: [PATCH] mwifiex: pcie: add reset_d3cold quirk for Surface gen4+
@@ -565,7 +565,7 @@ index 5326ae7e5671..8b9dcb5070d8 100644
 -- 
 2.29.2
 
-From 55af2ed1ee7806cb323a0dd8665fab4b6f81f466 Mon Sep 17 00:00:00 2001
+From 43d1be085eae6527618151ea56eea4a0223be5f6 Mon Sep 17 00:00:00 2001
 From: Tsuchiya Yuto <kitakar@gmail.com>
 Date: Tue, 29 Sep 2020 17:32:22 +0900
 Subject: [PATCH] mwifiex: pcie: add reset_wsid quirk for Surface 3
@@ -744,7 +744,7 @@ index 8b9dcb5070d8..3ef7440418e3 100644
 -- 
 2.29.2
 
-From 3c71ca6ff0abd5f2e4944a261965fe99254da4e0 Mon Sep 17 00:00:00 2001
+From 757d1414fb52417e869dcdeff717439ce6b4b432 Mon Sep 17 00:00:00 2001
 From: Tsuchiya Yuto <kitakar@gmail.com>
 Date: Wed, 30 Sep 2020 18:08:24 +0900
 Subject: [PATCH] mwifiex: pcie: (OEMB) add quirk for Surface 3 with broken DMI
@@ -806,7 +806,7 @@ index f0a6fa0a7ae5..34dcd84f02a6 100644
 -- 
 2.29.2
 
-From 292528bfec67e63a9d53b784b324497ac9d23be5 Mon Sep 17 00:00:00 2001
+From 5ce9a0a3f4164ac8a374f439ae5cf2ee6b259238 Mon Sep 17 00:00:00 2001
 From: Tsuchiya Yuto <kitakar@gmail.com>
 Date: Thu, 24 Sep 2020 01:56:29 +0900
 Subject: [PATCH] mwifiex: fix mwifiex_shutdown_sw() causing sw reset failure
@@ -883,7 +883,7 @@ index 9ee5600351a7..5965999f1b9b 100644
 -- 
 2.29.2
 
-From 1199446441d2a1ec8a958f00597456a1b6677cde Mon Sep 17 00:00:00 2001
+From 3fb13d88addf81f89182c277a3465900eb955cdd Mon Sep 17 00:00:00 2001
 From: Tsuchiya Yuto <kitakar@gmail.com>
 Date: Thu, 24 Sep 2020 01:56:34 +0900
 Subject: [PATCH] mwifiex: pcie: use shutdown_sw()/reinit_sw() on
@@ -1025,7 +1025,7 @@ index daae572ce94e..b46d56389c3b 100644
 -- 
 2.29.2
 
-From 48633dc307a191cc6269c3a29606a5097f96ae1e Mon Sep 17 00:00:00 2001
+From 15266dbbcdfb49760b51416a83fb368e22d23385 Mon Sep 17 00:00:00 2001
 From: Tsuchiya Yuto <kitakar@gmail.com>
 Date: Mon, 24 Aug 2020 17:11:35 +0900
 Subject: [PATCH] mwifiex: pcie: add enable_device_dump module parameter
@@ -1074,7 +1074,7 @@ index b46d56389c3b..1847a0274991 100644
 -- 
 2.29.2
 
-From 754f78890391d95f50c71cccb59e50ac7bf6516a Mon Sep 17 00:00:00 2001
+From 06ae6b1caeacd400f1f351ac743648a9899ea7e7 Mon Sep 17 00:00:00 2001
 From: Tsuchiya Yuto <kitakar@gmail.com>
 Date: Sun, 4 Oct 2020 00:11:49 +0900
 Subject: [PATCH] mwifiex: pcie: disable bridge_d3 for Surface gen4+
@@ -1229,7 +1229,7 @@ index 3ef7440418e3..a95ebac06e13 100644
 -- 
 2.29.2
 
-From 1dbf4162d0c0f4cabadb29bf21fc16900f6c13d9 Mon Sep 17 00:00:00 2001
+From bd8188fb5deb2c7682ca1a1f2b985b8f8b8be5cf Mon Sep 17 00:00:00 2001
 From: Tsuchiya Yuto <kitakar@gmail.com>
 Date: Sun, 4 Oct 2020 00:25:48 +0900
 Subject: [PATCH] mwifiex: add allow_ps_mode module parameter
@@ -1291,7 +1291,7 @@ index 96848fa0e417..786f7a197613 100644
 -- 
 2.29.2
 
-From f0ca4ec775946c120540ef982443a07025d19e92 Mon Sep 17 00:00:00 2001
+From c84f1c874ea9ca6a2642f68722911cd8d9418b05 Mon Sep 17 00:00:00 2001
 From: Tsuchiya Yuto <kitakar@gmail.com>
 Date: Sun, 4 Oct 2020 00:38:48 +0900
 Subject: [PATCH] mwifiex: print message when changing ps_mode
@@ -1326,7 +1326,7 @@ index 786f7a197613..8f4b8bc5ff03 100644
 -- 
 2.29.2
 
-From 4239f69e8c25df6de066c20ca0731c4dbd508e17 Mon Sep 17 00:00:00 2001
+From 467aba47a776ffd89200bee48be4cc566d115bee Mon Sep 17 00:00:00 2001
 From: Tsuchiya Yuto <kitakar@gmail.com>
 Date: Sun, 4 Oct 2020 00:59:37 +0900
 Subject: [PATCH] mwifiex: disable ps_mode explicitly by default instead

+ 3 - 3
patches/5.9/0003-ipts.patch

@@ -1,4 +1,4 @@
-From ca997d3c72504065e84c1da0613fa85dded60f16 Mon Sep 17 00:00:00 2001
+From 0ea99c8b2b4a79c949f37715c2f79b0a8b944392 Mon Sep 17 00:00:00 2001
 From: Dorian Stoll <dorian.stoll@tmsp.io>
 Date: Fri, 25 Sep 2020 18:06:05 +0200
 Subject: [PATCH] mei: Remove client devices before shutting down
@@ -27,7 +27,7 @@ index bcee77768b91..21ed765003e1 100644
 -- 
 2.29.2
 
-From 9b2ccee8b3d6014e2a5299c46cb828352d9a2def Mon Sep 17 00:00:00 2001
+From 2ebe25b7fdc5a710021ba1c2e2f301faf9153014 Mon Sep 17 00:00:00 2001
 From: Dorian Stoll <dorian.stoll@tmsp.io>
 Date: Thu, 30 Jul 2020 13:21:53 +0200
 Subject: [PATCH] misc: mei: Add missing IPTS device IDs
@@ -65,7 +65,7 @@ index 1de9ef7a272b..e12484840f88 100644
 -- 
 2.29.2
 
-From 1b0d69cbca89b9b0611dc45b0dd2e03524d268c0 Mon Sep 17 00:00:00 2001
+From bbf5bba02ab30a66fc9f31ffe6a39558d6a6670a Mon Sep 17 00:00:00 2001
 From: Dorian Stoll <dorian.stoll@tmsp.io>
 Date: Thu, 6 Aug 2020 11:20:41 +0200
 Subject: [PATCH] misc: Add support for Intel Precise Touch & Stylus

+ 17 - 5
patches/5.9/0004-surface-gpe.patch

@@ -1,4 +1,4 @@
-From c48e6dbc46e67d74e563d4bb7a01c30d79cfa757 Mon Sep 17 00:00:00 2001
+From f8a8b8e8f6eee845f60e7d56e648fc4fe0ebfd31 Mon Sep 17 00:00:00 2001
 From: Maximilian Luz <luzmaximilian@gmail.com>
 Date: Sun, 16 Aug 2020 23:39:56 +0200
 Subject: [PATCH] platform/x86: Add Driver to set up lid GPEs on MS Surface
@@ -33,8 +33,8 @@ Patchset: surface-gpe
 ---
  drivers/platform/x86/Kconfig       |   9 +
  drivers/platform/x86/Makefile      |   1 +
- drivers/platform/x86/surface_gpe.c | 309 +++++++++++++++++++++++++++++
- 3 files changed, 319 insertions(+)
+ drivers/platform/x86/surface_gpe.c | 321 +++++++++++++++++++++++++++++
+ 3 files changed, 331 insertions(+)
  create mode 100644 drivers/platform/x86/surface_gpe.c
 
 diff --git a/drivers/platform/x86/Kconfig b/drivers/platform/x86/Kconfig
@@ -71,10 +71,10 @@ index 5f823f7eff45..c0d1c753eb3c 100644
  obj-$(CONFIG_MSI_LAPTOP)	+= msi-laptop.o
 diff --git a/drivers/platform/x86/surface_gpe.c b/drivers/platform/x86/surface_gpe.c
 new file mode 100644
-index 000000000000..88b952ee9b8b
+index 000000000000..573dc52f568f
 --- /dev/null
 +++ b/drivers/platform/x86/surface_gpe.c
-@@ -0,0 +1,309 @@
+@@ -0,0 +1,321 @@
 +// SPDX-License-Identifier: GPL-2.0-or-later
 +/*
 + * Surface GPE/Lid driver to enable wakeup from suspend via the lid by
@@ -223,6 +223,18 @@ index 000000000000..88b952ee9b8b
 +		},
 +		.driver_data = (void *)lid_device_props_l4D,
 +	},
++	{
++		.ident = "Surface Laptop 3 (Intel 15\")",
++		.matches = {
++			/*
++			 * We match for SKU here due to different vairants: The
++			 * AMD (15") version does not rely on GPEs.
++			 */
++			DMI_EXACT_MATCH(DMI_SYS_VENDOR, "Microsoft Corporation"),
++			DMI_EXACT_MATCH(DMI_PRODUCT_SKU, "Surface_Laptop_3_1872"),
++		},
++		.driver_data = (void *)lid_device_props_l4D,
++	},
 +	{ }
 +};
 +

+ 2 - 2
patches/5.9/0005-surface-sam-over-hid.patch

@@ -1,4 +1,4 @@
-From 4d30a710542ea9d1dc6ec9c04def69a9d55b2e69 Mon Sep 17 00:00:00 2001
+From 9c8705d7445eee3ade8598bdfe6cfd1e749f7f06 Mon Sep 17 00:00:00 2001
 From: Maximilian Luz <luzmaximilian@gmail.com>
 Date: Sat, 25 Jul 2020 17:19:53 +0200
 Subject: [PATCH] i2c: acpi: Implement RawBytes read access
@@ -109,7 +109,7 @@ index 37c510d9347a..aed579942436 100644
 -- 
 2.29.2
 
-From 88b355f62148d5363cc3b7f5d58770fa5d12ab40 Mon Sep 17 00:00:00 2001
+From 01ac18ee58fa541b8edaae9135e6763e35bb3ce3 Mon Sep 17 00:00:00 2001
 From: Maximilian Luz <luzmaximilian@gmail.com>
 Date: Sun, 6 Sep 2020 04:01:19 +0200
 Subject: [PATCH] platform/x86: Add driver for Surface Book 1 dGPU switch

+ 15 - 15
patches/5.9/0006-surface-sam.patch

@@ -1,4 +1,4 @@
-From 84fcc76b6ec6fb447d76e367695b35cce5fbea8e Mon Sep 17 00:00:00 2001
+From 0b304873e92c778debadaabbbe19b69420d8faa8 Mon Sep 17 00:00:00 2001
 From: Maximilian Luz <luzmaximilian@gmail.com>
 Date: Thu, 29 Oct 2020 22:04:38 +0100
 Subject: [PATCH] PCI: Allow D3cold for hot-plug ports on Surface Books
@@ -83,7 +83,7 @@ index e39c5499770f..31d8811ee5c5 100644
 -- 
 2.29.2
 
-From 989461594c2a167d8292a217a05563341c792dbf Mon Sep 17 00:00:00 2001
+From a5497a7cc5c0befecf73d65b6af83f45f08389f8 Mon Sep 17 00:00:00 2001
 From: Maximilian Luz <luzmaximilian@gmail.com>
 Date: Mon, 9 Nov 2020 14:23:00 +0100
 Subject: [PATCH] PCI: Run platform power transition on initial D0 entry
@@ -143,7 +143,7 @@ index 31d8811ee5c5..4d652c3abae8 100644
 -- 
 2.29.2
 
-From e2c51058cff0cf3d07661843a15985ca5fcaabe4 Mon Sep 17 00:00:00 2001
+From 69f385511d829a997aabfe92a44416af6d5f9ada Mon Sep 17 00:00:00 2001
 From: Maximilian Luz <luzmaximilian@gmail.com>
 Date: Sat, 31 Oct 2020 20:46:33 +0100
 Subject: [PATCH] PCI: Add sysfs attribute for PCI device power state
@@ -216,7 +216,7 @@ index 6d78df981d41..17f186ce8e87 100644
 -- 
 2.29.2
 
-From 7dfe04d75bc2e8384291feb37c2873c924aa4ea1 Mon Sep 17 00:00:00 2001
+From 4046882cdbccb918c844d260e8594b4e753d6354 Mon Sep 17 00:00:00 2001
 From: Maximilian Luz <luzmaximilian@gmail.com>
 Date: Mon, 17 Aug 2020 01:23:20 +0200
 Subject: [PATCH] misc: surface_sam: Add file2alias support for Surface SAM
@@ -318,7 +318,7 @@ index 2417dd1dee33..a6c583362b92 100644
 -- 
 2.29.2
 
-From 920c67f6103567f540fe84069833051429e12a45 Mon Sep 17 00:00:00 2001
+From 16d3d210570364fe10baf6dd740cb09817097fa9 Mon Sep 17 00:00:00 2001
 From: Maximilian Luz <luzmaximilian@gmail.com>
 Date: Mon, 17 Aug 2020 01:44:30 +0200
 Subject: [PATCH] misc: Add support for Surface System Aggregator Module
@@ -485,7 +485,7 @@ index 000000000000..a1117d57036a
 +    :export:
 diff --git a/Documentation/driver-api/surface_aggregator/client.rst b/Documentation/driver-api/surface_aggregator/client.rst
 new file mode 100644
-index 000000000000..41c17bb63bef
+index 000000000000..f1275bf53837
 --- /dev/null
 +++ b/Documentation/driver-api/surface_aggregator/client.rst
 @@ -0,0 +1,394 @@
@@ -548,7 +548,7 @@ index 000000000000..41c17bb63bef
 +|ssam_client_link|). It is important to do this, as it, first, guarantees
 +that the returned controller is valid for use in the client driver for as
 +long as this driver is bound to its device, i.e. that the driver gets
-+un-bound before the controller ever becomes invalid, and, second, as it
++unbound before the controller ever becomes invalid, and, second, as it
 +ensures correct suspend/resume ordering. This setup should be done in the
 +driver's probe function, and may be used to defer probing in case the SSAM
 +subsystem is not ready yet, for example:
@@ -573,7 +573,7 @@ index 000000000000..41c17bb63bef
 +lifetime be guaranteed via |ssam_controller_get| and |ssam_controller_put|.
 +Note that none of these functions, however, guarantee that the controller
 +will not be shut down or suspended. These functions essentially only operate
-+on the reference, i.e. only guarantee a bare minimum of accessability
++on the reference, i.e. only guarantee a bare minimum of accessibility
 +without any guarantees at all on practical operability.
 +
 +
@@ -709,7 +709,7 @@ index 000000000000..41c17bb63bef
 +            *   ssam_request_sync_onstack(ctrl, &rqst, &resp, sizeof(arg_le));
 +            *
 +            * to perform the request, allocating the message buffer directly
-+            * on the stack as opposed to via kzalloc(.
++            * on the stack as opposed to via kzalloc().
 +            */
 +
 +           /*
@@ -757,12 +757,12 @@ index 000000000000..41c17bb63bef
 +
 +- :c:func:`SSAM_DEFINE_SYNC_REQUEST_N` for requests without return value and
 +  without argument.
-+- :c:func:`SSAM_DEFINE_SYNC_REQUEST_R` for equests with return value but no
++- :c:func:`SSAM_DEFINE_SYNC_REQUEST_R` for requests with return value but no
 +  argument.
 +- :c:func:`SSAM_DEFINE_SYNC_REQUEST_W` for requests without return value but
 +  with argument.
 +
-+Refer to their respecitve documentation for more details. For each one of
++Refer to their respective documentation for more details. For each one of
 +these macros, a special variant is provided, which targets request types
 +applicable to multiple instances of the same device type:
 +
@@ -885,7 +885,7 @@ index 000000000000..41c17bb63bef
 +with the same flag and it is considered a bug to do otherwise.
 diff --git a/Documentation/driver-api/surface_aggregator/clients/cdev.rst b/Documentation/driver-api/surface_aggregator/clients/cdev.rst
 new file mode 100644
-index 000000000000..63b5afcb89b5
+index 000000000000..720c9c03aa0e
 --- /dev/null
 +++ b/Documentation/driver-api/surface_aggregator/clients/cdev.rst
 @@ -0,0 +1,85 @@
@@ -901,7 +901,7 @@ index 000000000000..63b5afcb89b5
 +==============================
 +
 +The ``surface_aggregator_cdev`` module provides a misc-device for the SSAM
-+controller to allow for a (more or less) direct connection from userspace to
++controller to allow for a (more or less) direct connection from user-space to
 +the SAM EC. It is intended to be used for development and debugging, and
 +therefore should not be used or relied upon in any other way. Note that this
 +module is not loaded automatically, but instead must be loaded manually.
@@ -1928,7 +1928,7 @@ index 000000000000..6c020b87ad62
 +API and interface options for other kernel drivers.
 diff --git a/Documentation/driver-api/surface_aggregator/overview.rst b/Documentation/driver-api/surface_aggregator/overview.rst
 new file mode 100644
-index 000000000000..06d49ce001e7
+index 000000000000..b4ef7e25748c
 --- /dev/null
 +++ b/Documentation/driver-api/surface_aggregator/overview.rst
 @@ -0,0 +1,76 @@
@@ -1999,7 +1999,7 @@ index 000000000000..06d49ce001e7
 +
 +As already elaborated above, the Surface Serial Hub (SSH) is the
 +communication interface for SAM on 5th- and all later-generation Surface
-+devices. On the highest level, communication can be sparated into two main
++devices. On the highest level, communication can be separated into two main
 +types: Requests, messages sent from host to EC that may trigger a direct
 +response from the EC (explicitly associated with the request), and events
 +(sometimes also referred to as notifications), sent from EC to host without

+ 233 - 0
patches/5.9/0007-surface-typecover.patch

@@ -0,0 +1,233 @@
+From 8e9d159daab6be4c65b79cde4824677d4510c85d Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Jonas=20Dre=C3=9Fler?= <verdre@v0yd.nl>
+Date: Thu, 5 Nov 2020 13:09:45 +0100
+Subject: [PATCH] hid/multitouch: Turn off Type Cover keyboard backlight when
+ suspending
+
+The Type Cover for Microsoft Surface devices supports a special usb
+control request to disable or enable the built-in keyboard backlight.
+On Windows, this request happens when putting the device into suspend or
+resuming it, without it the backlight of the Type Cover will remain
+enabled for some time even though the computer is suspended, which looks
+weird to the user.
+
+So add support for this special usb control request to hid-multitouch,
+which is the driver that's handling the Type Cover.
+
+The reason we have to use a pm_notifier for this instead of the usual
+suspend/resume methods is that those won't get called in case the usb
+device is already autosuspended.
+
+Also, if the device is autosuspended, we have to briefly autoresume it
+in order to send the request. Doing that should be fine, the usb-core
+driver does something similar during suspend inside choose_wakeup().
+
+To make sure we don't send that request to every device but only to
+devices which support it, add a new quirk
+MT_CLS_WIN_8_MS_SURFACE_TYPE_COVER to hid-multitouch. For now this quirk
+is only enabled for the usb id of the Surface Pro 2017 Type Cover, which
+is where I confirmed that it's working.
+
+Patchset: surface-typecover
+---
+ drivers/hid/hid-multitouch.c | 100 ++++++++++++++++++++++++++++++++++-
+ 1 file changed, 98 insertions(+), 2 deletions(-)
+
+diff --git a/drivers/hid/hid-multitouch.c b/drivers/hid/hid-multitouch.c
+index 99f041afd5c0..dbdd170c77c7 100644
+--- a/drivers/hid/hid-multitouch.c
++++ b/drivers/hid/hid-multitouch.c
+@@ -34,7 +34,10 @@
+ #include <linux/device.h>
+ #include <linux/hid.h>
+ #include <linux/module.h>
++#include <linux/pm_runtime.h>
+ #include <linux/slab.h>
++#include <linux/suspend.h>
++#include <linux/usb.h>
+ #include <linux/input/mt.h>
+ #include <linux/jiffies.h>
+ #include <linux/string.h>
+@@ -47,6 +50,7 @@ MODULE_DESCRIPTION("HID multitouch panels");
+ MODULE_LICENSE("GPL");
+ 
+ #include "hid-ids.h"
++#include "usbhid/usbhid.h"
+ 
+ /* quirks to control the device */
+ #define MT_QUIRK_NOT_SEEN_MEANS_UP	BIT(0)
+@@ -70,12 +74,15 @@ MODULE_LICENSE("GPL");
+ #define MT_QUIRK_WIN8_PTP_BUTTONS	BIT(18)
+ #define MT_QUIRK_SEPARATE_APP_REPORT	BIT(19)
+ #define MT_QUIRK_FORCE_MULTI_INPUT	BIT(20)
++#define MT_QUIRK_HAS_TYPE_COVER_BACKLIGHT	BIT(21)
+ 
+ #define MT_INPUTMODE_TOUCHSCREEN	0x02
+ #define MT_INPUTMODE_TOUCHPAD		0x03
+ 
+ #define MT_BUTTONTYPE_CLICKPAD		0
+ 
++#define MS_TYPE_COVER_FEATURE_REPORT_USAGE	0xff050086
++
+ enum latency_mode {
+ 	HID_LATENCY_NORMAL = 0,
+ 	HID_LATENCY_HIGH = 1,
+@@ -167,6 +174,8 @@ struct mt_device {
+ 
+ 	struct list_head applications;
+ 	struct list_head reports;
++
++	struct notifier_block pm_notifier;
+ };
+ 
+ static void mt_post_parse_default_settings(struct mt_device *td,
+@@ -208,6 +217,7 @@ static void mt_post_parse(struct mt_device *td, struct mt_application *app);
+ #define MT_CLS_GOOGLE				0x0111
+ #define MT_CLS_RAZER_BLADE_STEALTH		0x0112
+ #define MT_CLS_SMART_TECH			0x0113
++#define MT_CLS_WIN_8_MS_SURFACE_TYPE_COVER	0x0114
+ 
+ #define MT_DEFAULT_MAXCONTACT	10
+ #define MT_MAX_MAXCONTACT	250
+@@ -367,6 +377,16 @@ static const struct mt_class mt_classes[] = {
+ 			MT_QUIRK_CONTACT_CNT_ACCURATE |
+ 			MT_QUIRK_SEPARATE_APP_REPORT,
+ 	},
++	{ .name = MT_CLS_WIN_8_MS_SURFACE_TYPE_COVER,
++		.quirks = MT_QUIRK_HAS_TYPE_COVER_BACKLIGHT |
++			MT_QUIRK_ALWAYS_VALID |
++			MT_QUIRK_IGNORE_DUPLICATES |
++			MT_QUIRK_HOVERING |
++			MT_QUIRK_CONTACT_CNT_ACCURATE |
++			MT_QUIRK_STICKY_FINGERS |
++			MT_QUIRK_WIN8_PTP_BUTTONS,
++		.export_all_inputs = true
++	},
+ 	{ }
+ };
+ 
+@@ -1673,6 +1693,69 @@ static void mt_expired_timeout(struct timer_list *t)
+ 	clear_bit(MT_IO_FLAGS_RUNNING, &td->mt_io_flags);
+ }
+ 
++static void get_type_cover_backlight_field(struct hid_device *hdev,
++					   struct hid_field **field)
++{
++	struct hid_report_enum *rep_enum;
++	struct hid_report *rep;
++	struct hid_field *cur_field;
++	int i, j;
++
++	rep_enum = &hdev->report_enum[HID_FEATURE_REPORT];
++	list_for_each_entry(rep, &rep_enum->report_list, list) {
++		for (i = 0; i < rep->maxfield; i++) {
++			cur_field = rep->field[i];
++
++			for (j = 0; j < cur_field->maxusage; j++) {
++				if (cur_field->usage[j].hid
++				    == MS_TYPE_COVER_FEATURE_REPORT_USAGE) {
++					*field = cur_field;
++					return;
++				}
++			}
++		}
++	}
++}
++
++static void update_keyboard_backlight(struct hid_device *hdev, bool enabled)
++{
++	struct usb_device *udev = hid_to_usb_dev(hdev);
++	struct hid_field *field = NULL;
++
++	/* Wake up the device in case it's already suspended */
++	pm_runtime_get_sync(&udev->dev);
++
++	get_type_cover_backlight_field(hdev, &field);
++	if (!field) {
++		hid_err(hdev, "couldn't find backlight field\n");
++		goto out;
++	}
++
++	field->value[field->index] = enabled ? 0x01ff00ff : 0x00ff00ff;
++	hid_hw_request(hdev, field->report, HID_REQ_SET_REPORT);
++
++out:
++	pm_runtime_put_sync(&udev->dev);
++}
++
++static int mt_pm_notifier(struct notifier_block *notifier,
++			  unsigned long pm_event,
++			  void *unused)
++{
++	struct mt_device *td =
++		container_of(notifier, struct mt_device, pm_notifier);
++	struct hid_device *hdev = td->hdev;
++
++	if (td->mtclass.quirks & MT_QUIRK_HAS_TYPE_COVER_BACKLIGHT) {
++		if (pm_event == PM_SUSPEND_PREPARE)
++			update_keyboard_backlight(hdev, 0);
++		else if (pm_event == PM_POST_SUSPEND)
++			update_keyboard_backlight(hdev, 1);
++	}
++
++	return NOTIFY_DONE;
++}
++
+ static int mt_probe(struct hid_device *hdev, const struct hid_device_id *id)
+ {
+ 	int ret, i;
+@@ -1696,6 +1779,9 @@ static int mt_probe(struct hid_device *hdev, const struct hid_device_id *id)
+ 	td->inputmode_value = MT_INPUTMODE_TOUCHSCREEN;
+ 	hid_set_drvdata(hdev, td);
+ 
++	td->pm_notifier.notifier_call = mt_pm_notifier;
++	register_pm_notifier(&td->pm_notifier);
++
+ 	INIT_LIST_HEAD(&td->applications);
+ 	INIT_LIST_HEAD(&td->reports);
+ 
+@@ -1725,15 +1811,19 @@ static int mt_probe(struct hid_device *hdev, const struct hid_device_id *id)
+ 	timer_setup(&td->release_timer, mt_expired_timeout, 0);
+ 
+ 	ret = hid_parse(hdev);
+-	if (ret != 0)
++	if (ret != 0) {
++		unregister_pm_notifier(&td->pm_notifier);
+ 		return ret;
++	}
+ 
+ 	if (mtclass->quirks & MT_QUIRK_FIX_CONST_CONTACT_ID)
+ 		mt_fix_const_fields(hdev, HID_DG_CONTACTID);
+ 
+ 	ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT);
+-	if (ret)
++	if (ret) {
++		unregister_pm_notifier(&td->pm_notifier);
+ 		return ret;
++	}
+ 
+ 	ret = sysfs_create_group(&hdev->dev.kobj, &mt_attribute_group);
+ 	if (ret)
+@@ -1769,6 +1859,7 @@ static void mt_remove(struct hid_device *hdev)
+ {
+ 	struct mt_device *td = hid_get_drvdata(hdev);
+ 
++	unregister_pm_notifier(&td->pm_notifier);
+ 	del_timer_sync(&td->release_timer);
+ 
+ 	sysfs_remove_group(&hdev->dev.kobj, &mt_attribute_group);
+@@ -2110,6 +2201,11 @@ static const struct hid_device_id mt_devices[] = {
+ 		MT_USB_DEVICE(USB_VENDOR_ID_XIROKU,
+ 			USB_DEVICE_ID_XIROKU_CSR2) },
+ 
++	/* Microsoft Surface type cover */
++	{ .driver_data = MT_CLS_WIN_8_MS_SURFACE_TYPE_COVER,
++		HID_DEVICE(HID_BUS_ANY, HID_GROUP_ANY,
++			USB_VENDOR_ID_MICROSOFT, 0x09c0) },
++
+ 	/* Google MT devices */
+ 	{ .driver_data = MT_CLS_GOOGLE,
+ 		HID_DEVICE(HID_BUS_ANY, HID_GROUP_ANY, USB_VENDOR_ID_GOOGLE,
+-- 
+2.29.2
+

+ 1 - 0
pkg/arch/kernel/0007-surface-typecover.patch

@@ -0,0 +1 @@
+../../../patches/5.9/0007-surface-typecover.patch

+ 8 - 6
pkg/arch/kernel/PKGBUILD

@@ -31,6 +31,7 @@ source=(
   0004-surface-gpe.patch
   0005-surface-sam-over-hid.patch
   0006-surface-sam.patch
+  0007-surface-typecover.patch
 )
 validpgpkeys=(
   'ABAF11C65A2970B130ABE3C479BE3E4300411886'  # Linus Torvalds
@@ -41,12 +42,13 @@ sha256sums=('c04ac0d84db2dbd38a36d971e34648ff2de4494b4d9a766ab9c087d8e4ced754'
             '36439a90c9d2f860298d90e141f3bf9d897dd8ece9e21cd46508f4ed7b2151bb'
             'cad2f23b058938c27ccdeb1944dcc492cf8696651b1ca9c74a86eb73a039f8c1'
             '8cd2b019aac6d3807a5cdcbbbe0aad81e63193ff3e8dffd7a79d4a1421b858f6'
-            '77602c298f25d76a91c31ae37e6f4c9c77f3185e716092518f755a285eddb60b'
-            'c508a8998161668b6f836c391bb7d8fdcb1424669f92cd49bd865cdeadca95e9'
-            '05eed9ef5bfd29e66b72631d7ec46400fceca3f1ea02fb531c3162593f5a9b65'
-            'da4539a87bfd688f7e5fb7a52d6ac65b545861710f12e9e66863171e0704594e'
-            'e350b1f0ed4631102dd723af7466e0051462d5627325cae1b92476cf63f5c4f5'
-            '545a8dc1a8f0db38c1e7dadb616d1a037886d221137640957e552865a602a1fd')
+            '5cf4e8194c70ccbe7ab90b5c2885070e58961bba8d26d5c5ac70bd05bc60a3f6'
+            '845f5184d557d5d2e31d48a81a55927a051aba901e28c791cc39d21cf1bbbfd4'
+            'a3289844a8c9131448c6b1fd84612d711334d6e1b048843393102d136df6c092'
+            'b76affed4ab2b4cb343a5e78985eb436aecf49e23fcfcd8f1f3b73460e84e43a'
+            '85d1c0708cab487ebe413800c5a888aad98cb91ec2b4c486d51b38f87852258d'
+            '706fb5cf4e5aa5f96740e1a40098ba369d0db290473778e2e6118d3be0aef923'
+            '09c7a36c7f98aa373adbdef8d1883d98158a5d3864f6ac934dee14a55a64a96a')
 
 
 export KBUILD_BUILD_HOST=archlinux