Skip to contentSkip to conversation

platform/surface: aggregator: Add support for Surface Laptop Studio

PATCH In review Maximilian Luz 3 participants 7 messages Oct 21, 2021 – Oct 22, 2021

Subsystems (6)
lore
Share & tools
lore

Maximilian Luz

author maintainer
#0 lore raw

cover platform/surface: aggregator: Add support for Surface Laptop Studio

This series adds Surface Aggregator Module (SAM) support for the new Surface Laptop Studio (SLS).

This is mostly straight-forward addition of devices to the Surface Aggregator registry, but the Surface HID driver needs a couple of small changes. Specifically, we need to allow it to probe against SAM devices with target ID 1 and also need to use the corresponding registry for those.

I hope it's okay that I've CCed stable to get these included in v5.14+ stable kernels. The changes are fairly small and enable keyboard and touchpad on the SLS. Most other things (except touch) should already work well on the latest stable kernels, so back-porting this series would make the SLS a usable device on those.

Maximilian Luz (3):
platform/surface: aggregator_registry: Add support for Surface Laptop
Studio
HID: surface-hid: Use correct event registry for managing HID events
HID: surface-hid: Allow driver matching for target ID 1 devices

 drivers/hid/surface-hid/surface_hid.c         |  4 +-
 .../surface/surface_aggregator_registry.c     | 54 +++++++++++++++++++
 include/linux/surface_aggregator/controller.h |  4 +-
 3 files changed, 58 insertions(+), 4 deletions(-)
Signature · 1 line
2.33.1
author maintainer
#1 lore raw

PATCH 1/3 platform/surface: aggregator_registry: Add support for Surface Laptop Studio

Add support for the Surface Laptop Studio.

In contrast to previous Surface Laptop models, this one has its HID devices attached to target ID 1 (instead of 2). It also has a couple more of them, including a new notifier for when the pen is stashed / taken out of its place, a "Sys Control" device, and two other unidentified HID devices with unknown usages.

Battery and performance profile interfaces remain the same.

---
 .../surface/surface_aggregator_registry.c     | 54 +++++++++++++++++++
 1 file changed, 54 insertions(+)
drivers/platform/surface/surface_aggregator_registry.c +54 -0
index 4428c4330229..1679811eff50 100644
@@ -77,6 +77,42 @@ static const struct software_node ssam_node_bas_dtx = {
 	.parent = &ssam_node_root,
 };
 
+/* HID keyboard (TID1). */
+static const struct software_node ssam_node_hid_tid1_keyboard = {
+	.name = "ssam:01:15:01:01:00",
+	.parent = &ssam_node_root,
+};
+
+/* HID pen stash (TID1; pen taken / stashed away evens). */
+static const struct software_node ssam_node_hid_tid1_penstash = {
+	.name = "ssam:01:15:01:02:00",
+	.parent = &ssam_node_root,
+};
+
+/* HID touchpad (TID1). */
+static const struct software_node ssam_node_hid_tid1_touchpad = {
+	.name = "ssam:01:15:01:03:00",
+	.parent = &ssam_node_root,
+};
+
+/* HID device instance 6 (TID1, unknown HID device). */
+static const struct software_node ssam_node_hid_tid1_iid6 = {
+	.name = "ssam:01:15:01:06:00",
+	.parent = &ssam_node_root,
+};
+
+/* HID device instance 7 (TID1, unknown HID device). */
+static const struct software_node ssam_node_hid_tid1_iid7 = {
+	.name = "ssam:01:15:01:07:00",
+	.parent = &ssam_node_root,
+};
+
+/* HID system controls (TID1). */
+static const struct software_node ssam_node_hid_tid1_sysctrl = {
+	.name = "ssam:01:15:01:08:00",
+	.parent = &ssam_node_root,
+};
+
 /* HID keyboard. */
 static const struct software_node ssam_node_hid_main_keyboard = {
 	.name = "ssam:01:15:02:01:00",
@@ -159,6 +195,21 @@ static const struct software_node *ssam_node_group_sl3[] = {
 	NULL,
 };
 
+/* Devices for Surface Laptop Studio. */
+static const struct software_node *ssam_node_group_sls[] = {
+	&ssam_node_root,
+	&ssam_node_bat_ac,
+	&ssam_node_bat_main,
+	&ssam_node_tmp_pprof,
+	&ssam_node_hid_tid1_keyboard,
+	&ssam_node_hid_tid1_penstash,
+	&ssam_node_hid_tid1_touchpad,
+	&ssam_node_hid_tid1_iid6,
+	&ssam_node_hid_tid1_iid7,
+	&ssam_node_hid_tid1_sysctrl,
+	NULL,
+};
+
 /* Devices for Surface Laptop Go. */
 static const struct software_node *ssam_node_group_slg1[] = {
 	&ssam_node_root,
@@ -507,6 +558,9 @@ static const struct acpi_device_id ssam_platform_hub_match[] = {
 	/* Surface Laptop Go 1 */
 	{ "MSHW0118", (unsigned long)ssam_node_group_slg1 },
 
+	/* Surface Laptop Studio */
+	{ "MSHW0123", (unsigned long)ssam_node_group_sls },
+
 	{ },
 };
 MODULE_DEVICE_TABLE(acpi, ssam_platform_hub_match);
Signature · 1 line
2.33.1
author maintainer
#2 lore raw

PATCH 2/3 HID: surface-hid: Use correct event registry for managing HID events

In reply to Maximilian Luz

Until now, we have only ever seen the REG-category registry being used on devices addressed with target ID 2. In fact, we have only ever seen Surface Aggregator Module (SAM) HID devices with target ID 2. For those devices, the registry also has to be addressed with target ID 2.

Some devices, like the new Surface Laptop Studio, however, address their HID devices on target ID 1. As a result of this, any target ID 2 commands time out. This includes event management commands addressed to the target ID 2 REG-category registry. For these devices, the registry has to be addressed via target ID 1 instead.

We therefore assume that the target ID of the registry to be used depends on the target ID of the respective device. Implement this accordingly.

Note that we currently allow the surface HID driver to only load against devices with target ID 2, so these timeouts are not happening (yet). This is just a preparation step before we allow the driver to load against all target IDs.

---
 drivers/hid/surface-hid/surface_hid.c         | 2 +-
 include/linux/surface_aggregator/controller.h | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)
drivers/hid/surface-hid/surface_hid.c +1 -1
index a3a70e4f3f6c..daa452367c0b 100644
@@ -209,7 +209,7 @@ static int surface_hid_probe(struct ssam_device *sdev)
 
 	shid->notif.base.priority = 1;
 	shid->notif.base.fn = ssam_hid_event_fn;
-	shid->notif.event.reg = SSAM_EVENT_REGISTRY_REG;
+	shid->notif.event.reg = SSAM_EVENT_REGISTRY_REG(sdev->uid.target);
 	shid->notif.event.id.target_category = sdev->uid.category;
 	shid->notif.event.id.instance = sdev->uid.instance;
 	shid->notif.event.mask = SSAM_EVENT_MASK_STRICT;
include/linux/surface_aggregator/controller.h +2 -2
index 068e1982ad37..74bfdffaf7b0 100644
@@ -792,8 +792,8 @@ enum ssam_event_mask {
 #define SSAM_EVENT_REGISTRY_KIP	\
 	SSAM_EVENT_REGISTRY(SSAM_SSH_TC_KIP, 0x02, 0x27, 0x28)
 
-#define SSAM_EVENT_REGISTRY_REG \
-	SSAM_EVENT_REGISTRY(SSAM_SSH_TC_REG, 0x02, 0x01, 0x02)
+#define SSAM_EVENT_REGISTRY_REG(tid)\
+	SSAM_EVENT_REGISTRY(SSAM_SSH_TC_REG, tid, 0x01, 0x02)
 
 /**
  * enum ssam_event_notifier_flags - Flags for event notifiers.
Signature · 1 line
2.33.1
author maintainer
#3 lore raw

PATCH 3/3 HID: surface-hid: Allow driver matching for target ID 1 devices

In reply to Maximilian Luz

Until now we have only ever seen HID devices with target ID 2. The new Surface Laptop Studio however uses HID devices with target ID 1. Allow matching this driver to those as well.

---
 drivers/hid/surface-hid/surface_hid.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/hid/surface-hid/surface_hid.c +1 -1
index daa452367c0b..d4aa8c81903a 100644
@@ -230,7 +230,7 @@ static void surface_hid_remove(struct ssam_device *sdev)
 }
 
 static const struct ssam_device_id surface_hid_match[] = {
-	{ SSAM_SDEV(HID, 0x02, SSAM_ANY_IID, 0x00) },
+	{ SSAM_SDEV(HID, SSAM_ANY_TID, SSAM_ANY_IID, 0x00) },
 	{ },
 };
 MODULE_DEVICE_TABLE(ssam, surface_hid_match);
Signature · 1 line
2.33.1
#4 lore raw
In reply to Maximilian Luz

Hi,

Quoted 9 lines · Maximilian Luz

This series adds Surface Aggregator Module (SAM) support for the new Surface Laptop Studio (SLS).

This is mostly straight-forward addition of devices to the Surface Aggregator registry, but the Surface HID driver needs a couple of small changes. Specifically, we need to allow it to probe against SAM devices with target ID 1 and also need to use the corresponding registry for those.

Quoted 5 lines

I hope it's okay that I've CCed stable to get these included in v5.14+ stable kernels. The changes are fairly small and enable keyboard and touchpad on the SLS. Most other things (except touch) should already work well on the latest stable kernels, so back-porting this series would make the SLS a usable device on those.

Thank you for your patch-series, I've applied the series to my review-hans branch:
https://git.kernel.org/pub/scm/linux/kernel/git/pdx86/platform-drivers-x86.git/log/?h=review-hans

Note it will show up in my review-hans branch once I've pushed my local branch there, which might take a while.

Once I've run some tests on this branch the patches there will be added to the platform-drivers-x86/for-next branch and eventually will be included in the pdx86 pull-request to Linus for the next merge-window.

Regards,

Hans

Quoted 12 lines

Maximilian Luz (3):
platform/surface: aggregator_registry: Add support for Surface Laptop
Studio
HID: surface-hid: Use correct event registry for managing HID events
HID: surface-hid: Allow driver matching for target ID 1 devices

 drivers/hid/surface-hid/surface_hid.c         |  4 +-
 .../surface/surface_aggregator_registry.c     | 54 +++++++++++++++++++
 include/linux/surface_aggregator/controller.h |  4 +-
 3 files changed, 58 insertions(+), 4 deletions(-)
#5 lore raw
Quoted 19 lines · Hans de Goede

Hi,

Quoted 9 lines · Maximilian Luz

This series adds Surface Aggregator Module (SAM) support for the new Surface Laptop Studio (SLS).

This is mostly straight-forward addition of devices to the Surface Aggregator registry, but the Surface HID driver needs a couple of small changes. Specifically, we need to allow it to probe against SAM devices with target ID 1 and also need to use the corresponding registry for those.

Quoted 5 lines

I hope it's okay that I've CCed stable to get these included in v5.14+ stable kernels. The changes are fairly small and enable keyboard and touchpad on the SLS. Most other things (except touch) should already work well on the latest stable kernels, so back-porting this series would make the SLS a usable device on those.

Quoted 6 lines

Thank you for your patch-series, I've applied the series to my review-hans branch:
https://git.kernel.org/pub/scm/linux/kernel/git/pdx86/platform-drivers-x86.git/log/?h=review-hans

Note it will show up in my review-hans branch once I've pushed my local branch there, which might take a while.

I was surprised to see you taking this series when the 2 patches I received are HID only.
But it turns out that the patch 1/3 (which I am missing) is actually about platform, so it makes sense to have you take the full series. The HID changes are relatively small and are not conflicting with anything in the HID tree.

For the HID part:

Cheers,
Benjamin

Quoted 25 lines

Once I've run some tests on this branch the patches there will be added to the platform-drivers-x86/for-next branch and eventually will be included in the pdx86 pull-request to Linus for the next merge-window.

Regards,

Hans

Quoted 12 lines

Maximilian Luz (3):
platform/surface: aggregator_registry: Add support for Surface Laptop
Studio
HID: surface-hid: Use correct event registry for managing HID events
HID: surface-hid: Allow driver matching for target ID 1 devices

 drivers/hid/surface-hid/surface_hid.c         |  4 +-
 .../surface/surface_aggregator_registry.c     | 54 +++++++++++++++++++
 include/linux/surface_aggregator/controller.h |  4 +-
 3 files changed, 58 insertions(+), 4 deletions(-)
#6 lore raw

Hi,

Quoted 34 lines · Benjamin Tissoires
Quoted 19 lines · Hans de Goede

Hi,

Quoted 9 lines · Maximilian Luz

This series adds Surface Aggregator Module (SAM) support for the new Surface Laptop Studio (SLS).

This is mostly straight-forward addition of devices to the Surface Aggregator registry, but the Surface HID driver needs a couple of small changes. Specifically, we need to allow it to probe against SAM devices with target ID 1 and also need to use the corresponding registry for those.

Quoted 5 lines

I hope it's okay that I've CCed stable to get these included in v5.14+ stable kernels. The changes are fairly small and enable keyboard and touchpad on the SLS. Most other things (except touch) should already work well on the latest stable kernels, so back-porting this series would make the SLS a usable device on those.

Quoted 6 lines

Thank you for your patch-series, I've applied the series to my review-hans branch:
https://git.kernel.org/pub/scm/linux/kernel/git/pdx86/platform-drivers-x86.git/log/?h=review-hans

Note it will show up in my review-hans branch once I've pushed my local branch there, which might take a while.

I was surprised to see you taking this series when the 2 patches I received are HID only.
But it turns out that the patch 1/3 (which I am missing) is actually about platform, so it makes sense to have you take the full series. The HID changes are relatively small and are not conflicting with anything in the HID tree.

Quoted 2 lines

For the HID part:

Thanks I'll add your Ack before moving this for-next and sorry for not coordinating this before hand.

TBH I completely missed that the 2 other patches where under drivers/hid since 90% or so of all surface stuff is under drivers/platform/surface I sorta assumed all patches where for there. My bad, sorry.

(Note to self: Next time not only review the contents of the diff but also look at the file-paths).

Regards,

Hans

Quoted 30 lines

Cheers,
Benjamin

Quoted 25 lines

Once I've run some tests on this branch the patches there will be added to the platform-drivers-x86/for-next branch and eventually will be included in the pdx86 pull-request to Linus for the next merge-window.

Regards,

Hans

Quoted 12 lines

Maximilian Luz (3):
platform/surface: aggregator_registry: Add support for Surface Laptop
Studio
HID: surface-hid: Use correct event registry for managing HID events
HID: surface-hid: Allow driver matching for target ID 1 devices

 drivers/hid/surface-hid/surface_hid.c         |  4 +-
 .../surface/surface_aggregator_registry.c     | 54 +++++++++++++++++++
 include/linux/surface_aggregator/controller.h |  4 +-
 3 files changed, 58 insertions(+), 4 deletions(-)