Update v5.4 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: 414658f8c2
 - GPE: 35fc41f3f0
 - kernel: 8b0a9c0caf
This commit is contained in:
Maximilian Luz 2020-11-13 22:32:11 +01:00
parent 2f40b23619
commit 89fc3c6ddc
No known key found for this signature in database
GPG key ID: 70EC0937F6C26F02
8 changed files with 286 additions and 41 deletions

View file

@ -1,4 +1,4 @@
From dbf8ee1341ecd608385453313b0b8152f9693dfa Mon Sep 17 00:00:00 2001
From 8ef63eac0d3ed42818a0b5e0e685b677e4bd52d6 Mon Sep 17 00:00:00 2001
From: qzed <qzed@users.noreply.github.com>
Date: Tue, 17 Sep 2019 17:17:56 +0200
Subject: [PATCH] platform/x86: Surface 3 battery platform operation region

View file

@ -1,4 +1,4 @@
From 4d815ded70ab8aae76493f3d09cf9deb66a9db89 Mon Sep 17 00:00:00 2001
From 9c0903552bf464dae2eef06b92442d7cb86884f6 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

View file

@ -1,4 +1,4 @@
From 0b87680b0c33a0aaa76a37daf9497aa7aa1e0027 Mon Sep 17 00:00:00 2001
From 053c27ba70b8813d1a1bddf637fc5db4c77dac6f 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 f7ce9b6db6b4..72d0c01ff359 100644
--
2.29.2
From 536562e35c51306f47a238942347db48c0f4885e Mon Sep 17 00:00:00 2001
From ef4402cd5492259d6abab5f51e44e6d3d6a6a421 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 4ceb625d1a47f305ed9a21ff46112efe0f9e7372 Mon Sep 17 00:00:00 2001
From 937a703f413f2ad65158bffbcab4191b4c60fb5d 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 37bcc6710b54af86232f898e2ac1c9001f00138c Mon Sep 17 00:00:00 2001
From c43a6258bda02743c691cd829887139035bbad65 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 b0e6eba5247ab5a40628e3f3680d52c91ecfb951 Mon Sep 17 00:00:00 2001
From 8bd03fe491826d5bf13afda34c77d43a6624f72b 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 94041b7af83160ab418fa9657969537921435566 Mon Sep 17 00:00:00 2001
From 266cba60bc52b6dd8bdc93ebd37e1b8ace483916 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 d14e55e3c9da..5894566ec480 100644
--
2.29.2
From 90bd2981ca5273f2409210788b290440fa7b6106 Mon Sep 17 00:00:00 2001
From cda4c5cb152481c5a48fec84af74716ca83179d4 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 263d918767bd..bd6791dc3a0f 100644
--
2.29.2
From 4628465f444ed13a728fd46d791892ac436b6541 Mon Sep 17 00:00:00 2001
From 03ab0463fd707097c48fb8510a101c1f0519c1bc 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 bd6791dc3a0f..d7ff898c1767 100644
--
2.29.2
From cd1ec33e59ff1202669c8f3624319dcedc345b95 Mon Sep 17 00:00:00 2001
From 40516e97ba27ba344d8bd9a3134b06dec45099ea 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 da5ac4ee8acf649ab495c662e3b1e86415f576ce Mon Sep 17 00:00:00 2001
From 17d0706226c1774a03107db9ea361042371c829b 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 9e6dc289ec3e..20f5ee3fe7e3 100644
--
2.29.2
From 02024fe7fa192bf5f5ba2e96d450067ea113c56e Mon Sep 17 00:00:00 2001
From 2857f54b783d6a3cbf4aaead8b75aa12eda9d627 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 20f5ee3fe7e3..8020a2929069 100644
--
2.29.2
From a41473e357bc9897c7b19faa5b1be5b8c839eb23 Mon Sep 17 00:00:00 2001
From 566932adf102e5b991460ac4d9cbc81ea8e6d1bf 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

View file

@ -1,4 +1,4 @@
From eed20d079f4b88b004987ef649df7fa792532acf Mon Sep 17 00:00:00 2001
From 8d86828719cf885feea11ee3794d7c16267f329d Mon Sep 17 00:00:00 2001
From: Dorian Stoll <dorian.stoll@tmsp.io>
Date: Mon, 27 Jan 2020 21:16:20 +0100
Subject: [PATCH] mei: Add IPTS device IDs
@ -53,7 +53,7 @@ index 75ab2ffbf235..78790904d77c 100644
--
2.29.2
From 753755e1044d9e1a04b50df64ee65be4bfb5ea5c Mon Sep 17 00:00:00 2001
From dc61fc8e0be6d436b9bf018dd8fc6e81ab1a897a Mon Sep 17 00:00:00 2001
From: Dorian Stoll <dorian.stoll@tmsp.io>
Date: Fri, 20 Dec 2019 23:15:58 +0100
Subject: [PATCH] uapi: Add MEI bus ID
@ -79,7 +79,7 @@ index 9a61c28ed3ae..47fc20975245 100644
--
2.29.2
From f7f03f4bb0e8f0adf2aaf23e1ab7a4da468a2b05 Mon Sep 17 00:00:00 2001
From b00afd8f41828902047231f04771dbd30faf3adc Mon Sep 17 00:00:00 2001
From: Dorian Stoll <dorian.stoll@tmsp.io>
Date: Mon, 27 Jan 2020 21:22:42 +0100
Subject: [PATCH] input: Add support for Intel Precise Touch & Stylus

View file

@ -1,4 +1,4 @@
From c54eb171bdb93dfdd188cfee34c363ab27ab04d0 Mon Sep 17 00:00:00 2001
From ab259e46a7863c840e88ef228375eda85a702316 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 6dd955ad9bf1..5db303f43bda 100644
obj-$(CONFIG_INTEL_TELEMETRY) += intel_telemetry_core.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,
+ },
+ { }
+};
+

View file

@ -1,4 +1,4 @@
From 1fc81386c040856a80d56f2cfbc03d656eef6642 Mon Sep 17 00:00:00 2001
From 6d7243f3c134fe901c08ebf94f704a7c459ea026 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 c70983780ae7..1c90651161a6 100644
--
2.29.2
From 3a3bd6bfb90b3e08b24c04baac718652d4d24b61 Mon Sep 17 00:00:00 2001
From 3f731b1b5dd36e99b26c567748e7fb568caff777 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

View file

@ -1,4 +1,4 @@
From 4d748f3baa99a037bcf82e0eeadb37f9f414725f Mon Sep 17 00:00:00 2001
From 52d7807ec1d317c003ae9bb80e57f214ae23b99f Mon Sep 17 00:00:00 2001
From: qzed <qzed@users.noreply.github.com>
Date: Mon, 26 Aug 2019 01:11:08 +0200
Subject: [PATCH] ACPI: Fix buffer/integer type mismatch
@ -60,7 +60,7 @@ index d3d2dbfba680..0b7f617a6e9b 100644
--
2.29.2
From d92ec71cdcfd601d5ca8b2b8606d45ee47b8f2e3 Mon Sep 17 00:00:00 2001
From 97d52ac0951b5385b4f5626a47f84ba0ffeefd06 Mon Sep 17 00:00:00 2001
From: Maximilian Luz <luzmaximilian@gmail.com>
Date: Tue, 24 Sep 2019 17:38:12 +0200
Subject: [PATCH] serdev: Add ACPI devices by ResourceSource field
@ -248,7 +248,7 @@ index a9719858c950..ce5309d00280 100644
--
2.29.2
From 6d87a01f7841f9c287607adec3604cbf16292453 Mon Sep 17 00:00:00 2001
From 3482f4182879466976c947d53cbddba057e839b9 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
@ -333,7 +333,7 @@ index b1b2c8ddbc92..15566ec8f75d 100644
--
2.29.2
From da5f35bad772a6854c80df04f6710a2842b3d040 Mon Sep 17 00:00:00 2001
From a8c97b33fa4b4598527a8ea64242ded201803f34 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
@ -395,7 +395,7 @@ index 15566ec8f75d..9b0a591fc60b 100644
--
2.29.2
From f8142da29f19db03995420b7f8e798c38ae03200 Mon Sep 17 00:00:00 2001
From e5b02da2335978b0e2e695338636c1ef3ad04fc3 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
@ -468,7 +468,7 @@ index e401f040f157..418927872ae6 100644
--
2.29.2
From 9f6c88bb06a99de23bf214f8d5b5bea49c164d09 Mon Sep 17 00:00:00 2001
From 5aeed170de734b7cc8e3a0a42bd712928ec6eeb2 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
@ -570,7 +570,7 @@ index c91eba751804..bc06f7631200 100644
--
2.29.2
From 9f94a0785a1171b88ccf73cffd472dd2fd973dae Mon Sep 17 00:00:00 2001
From ebc16a220daf1a4546989f1c5fcd56558b13d62b 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
@ -737,7 +737,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 @@
@ -800,7 +800,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:
@ -825,7 +825,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.
+
+
@ -961,7 +961,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().
+ */
+
+ /*
@ -1009,12 +1009,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:
+
@ -1137,7 +1137,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 @@
@ -1153,7 +1153,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.
@ -2180,7 +2180,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 @@
@ -2251,7 +2251,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

View file

@ -0,0 +1,233 @@
From 2bdd45aa65001314248488e4f7fc1a401e784ae4 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 128d8f4319b9..2c30f65056d9 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
@@ -374,6 +384,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
+ },
{ }
};
@@ -1683,6 +1703,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;
@@ -1706,6 +1789,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);
@@ -1735,15 +1821,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)
@@ -1779,6 +1869,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);
@@ -2146,6 +2237,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