0005-surface-sam.patch 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  1. From 7075cd222eea9ec651ec36a05e41061f4fc5757b Mon Sep 17 00:00:00 2001
  2. From: Maximilian Luz <luzmaximilian@gmail.com>
  3. Date: Sun, 10 Oct 2021 01:27:17 +0200
  4. Subject: [PATCH] platform/surface: aggregator_registry: Add support for
  5. Surface Laptop Studio
  6. Add support for the Surface Laptop Studio.
  7. In contrast to previous Surface Laptop models, this one has its HID
  8. devices attached to target ID 1 (instead of 2). It also has a couple
  9. more of them, including a new notifier for when the pen is stashed /
  10. taken out of its place, a "Sys Control" device, and two other
  11. unidentified HID devices with unknown usages.
  12. Battery and performance profile interfaces remain the same.
  13. Signed-off-by: Maximilian Luz <luzmaximilian@gmail.com>
  14. Patchset: surface-sam
  15. ---
  16. .../surface/surface_aggregator_registry.c | 54 +++++++++++++++++++
  17. 1 file changed, 54 insertions(+)
  18. diff --git a/drivers/platform/surface/surface_aggregator_registry.c b/drivers/platform/surface/surface_aggregator_registry.c
  19. index 4428c4330229..1679811eff50 100644
  20. --- a/drivers/platform/surface/surface_aggregator_registry.c
  21. +++ b/drivers/platform/surface/surface_aggregator_registry.c
  22. @@ -77,6 +77,42 @@ static const struct software_node ssam_node_bas_dtx = {
  23. .parent = &ssam_node_root,
  24. };
  25. +/* HID keyboard (TID1). */
  26. +static const struct software_node ssam_node_hid_tid1_keyboard = {
  27. + .name = "ssam:01:15:01:01:00",
  28. + .parent = &ssam_node_root,
  29. +};
  30. +
  31. +/* HID pen stash (TID1; pen taken / stashed away evens). */
  32. +static const struct software_node ssam_node_hid_tid1_penstash = {
  33. + .name = "ssam:01:15:01:02:00",
  34. + .parent = &ssam_node_root,
  35. +};
  36. +
  37. +/* HID touchpad (TID1). */
  38. +static const struct software_node ssam_node_hid_tid1_touchpad = {
  39. + .name = "ssam:01:15:01:03:00",
  40. + .parent = &ssam_node_root,
  41. +};
  42. +
  43. +/* HID device instance 6 (TID1, unknown HID device). */
  44. +static const struct software_node ssam_node_hid_tid1_iid6 = {
  45. + .name = "ssam:01:15:01:06:00",
  46. + .parent = &ssam_node_root,
  47. +};
  48. +
  49. +/* HID device instance 7 (TID1, unknown HID device). */
  50. +static const struct software_node ssam_node_hid_tid1_iid7 = {
  51. + .name = "ssam:01:15:01:07:00",
  52. + .parent = &ssam_node_root,
  53. +};
  54. +
  55. +/* HID system controls (TID1). */
  56. +static const struct software_node ssam_node_hid_tid1_sysctrl = {
  57. + .name = "ssam:01:15:01:08:00",
  58. + .parent = &ssam_node_root,
  59. +};
  60. +
  61. /* HID keyboard. */
  62. static const struct software_node ssam_node_hid_main_keyboard = {
  63. .name = "ssam:01:15:02:01:00",
  64. @@ -159,6 +195,21 @@ static const struct software_node *ssam_node_group_sl3[] = {
  65. NULL,
  66. };
  67. +/* Devices for Surface Laptop Studio. */
  68. +static const struct software_node *ssam_node_group_sls[] = {
  69. + &ssam_node_root,
  70. + &ssam_node_bat_ac,
  71. + &ssam_node_bat_main,
  72. + &ssam_node_tmp_pprof,
  73. + &ssam_node_hid_tid1_keyboard,
  74. + &ssam_node_hid_tid1_penstash,
  75. + &ssam_node_hid_tid1_touchpad,
  76. + &ssam_node_hid_tid1_iid6,
  77. + &ssam_node_hid_tid1_iid7,
  78. + &ssam_node_hid_tid1_sysctrl,
  79. + NULL,
  80. +};
  81. +
  82. /* Devices for Surface Laptop Go. */
  83. static const struct software_node *ssam_node_group_slg1[] = {
  84. &ssam_node_root,
  85. @@ -507,6 +558,9 @@ static const struct acpi_device_id ssam_platform_hub_match[] = {
  86. /* Surface Laptop Go 1 */
  87. { "MSHW0118", (unsigned long)ssam_node_group_slg1 },
  88. + /* Surface Laptop Studio */
  89. + { "MSHW0123", (unsigned long)ssam_node_group_sls },
  90. +
  91. { },
  92. };
  93. MODULE_DEVICE_TABLE(acpi, ssam_platform_hub_match);
  94. --
  95. 2.33.0
  96. From 5e7bd7d6ce73a75e25aedd826dbe4ba8ef80028e Mon Sep 17 00:00:00 2001
  97. From: Maximilian Luz <luzmaximilian@gmail.com>
  98. Date: Sun, 10 Oct 2021 15:07:42 +0200
  99. Subject: [PATCH] HID: surface-hid: Use correct event registry for managing HID
  100. events
  101. Fix a timeout error caused by using the wrong registry for some devices,
  102. preventing the driver to probe and manage events correctly.
  103. Until now, we have only ever seen the REG-category registry being used
  104. on devices addressed with target ID 2. In fact, we have only ever seen
  105. Surface Aggregator Module (SAM) HID devices with target ID 2. For those
  106. devices, the registry also has to be addressed with target ID 2.
  107. Some devices, like the new Surface Laptop Studio, however, address their
  108. HID devices on target ID 1. As a result of this, any target ID 2
  109. commands time out. This includes event management commands addressed to
  110. the target ID 2 REG-category registry. For these devices, the registry
  111. has to be addressed via target ID 1 instead.
  112. We therefore assume that the target ID of the registry to be used
  113. depends on the target ID of the respective device. Implement this
  114. accordingly.
  115. Fixes: b05ff1002a5c1 ("HID: Add support for Surface Aggregator Module HID transport")
  116. Signed-off-by: Maximilian Luz <luzmaximilian@gmail.com>
  117. Patchset: surface-sam
  118. ---
  119. drivers/hid/surface-hid/surface_hid.c | 2 +-
  120. include/linux/surface_aggregator/controller.h | 4 ++--
  121. 2 files changed, 3 insertions(+), 3 deletions(-)
  122. diff --git a/drivers/hid/surface-hid/surface_hid.c b/drivers/hid/surface-hid/surface_hid.c
  123. index a3a70e4f3f6c..daa452367c0b 100644
  124. --- a/drivers/hid/surface-hid/surface_hid.c
  125. +++ b/drivers/hid/surface-hid/surface_hid.c
  126. @@ -209,7 +209,7 @@ static int surface_hid_probe(struct ssam_device *sdev)
  127. shid->notif.base.priority = 1;
  128. shid->notif.base.fn = ssam_hid_event_fn;
  129. - shid->notif.event.reg = SSAM_EVENT_REGISTRY_REG;
  130. + shid->notif.event.reg = SSAM_EVENT_REGISTRY_REG(sdev->uid.target);
  131. shid->notif.event.id.target_category = sdev->uid.category;
  132. shid->notif.event.id.instance = sdev->uid.instance;
  133. shid->notif.event.mask = SSAM_EVENT_MASK_STRICT;
  134. diff --git a/include/linux/surface_aggregator/controller.h b/include/linux/surface_aggregator/controller.h
  135. index 068e1982ad37..74bfdffaf7b0 100644
  136. --- a/include/linux/surface_aggregator/controller.h
  137. +++ b/include/linux/surface_aggregator/controller.h
  138. @@ -792,8 +792,8 @@ enum ssam_event_mask {
  139. #define SSAM_EVENT_REGISTRY_KIP \
  140. SSAM_EVENT_REGISTRY(SSAM_SSH_TC_KIP, 0x02, 0x27, 0x28)
  141. -#define SSAM_EVENT_REGISTRY_REG \
  142. - SSAM_EVENT_REGISTRY(SSAM_SSH_TC_REG, 0x02, 0x01, 0x02)
  143. +#define SSAM_EVENT_REGISTRY_REG(tid)\
  144. + SSAM_EVENT_REGISTRY(SSAM_SSH_TC_REG, tid, 0x01, 0x02)
  145. /**
  146. * enum ssam_event_notifier_flags - Flags for event notifiers.
  147. --
  148. 2.33.0
  149. From 8f79ffa11f64ee32c97642d4149f5b6e02ec8e68 Mon Sep 17 00:00:00 2001
  150. From: Maximilian Luz <luzmaximilian@gmail.com>
  151. Date: Sun, 10 Oct 2021 19:48:10 +0200
  152. Subject: [PATCH] HID: surface-hid: Allow driver matching for target ID 1
  153. devices
  154. Until now we have only ever seen HID devices with target ID 2. The new
  155. Surface Laptop Studio however uses HID devices with target ID 1. Allow
  156. matching this driver to those as well.
  157. Fixes: b05ff1002a5c1 ("HID: Add support for Surface Aggregator Module HID transport")
  158. Signed-off-by: Maximilian Luz <luzmaximilian@gmail.com>
  159. Patchset: surface-sam
  160. ---
  161. drivers/hid/surface-hid/surface_hid.c | 2 +-
  162. 1 file changed, 1 insertion(+), 1 deletion(-)
  163. diff --git a/drivers/hid/surface-hid/surface_hid.c b/drivers/hid/surface-hid/surface_hid.c
  164. index daa452367c0b..d4aa8c81903a 100644
  165. --- a/drivers/hid/surface-hid/surface_hid.c
  166. +++ b/drivers/hid/surface-hid/surface_hid.c
  167. @@ -230,7 +230,7 @@ static void surface_hid_remove(struct ssam_device *sdev)
  168. }
  169. static const struct ssam_device_id surface_hid_match[] = {
  170. - { SSAM_SDEV(HID, 0x02, SSAM_ANY_IID, 0x00) },
  171. + { SSAM_SDEV(HID, SSAM_ANY_TID, SSAM_ANY_IID, 0x00) },
  172. { },
  173. };
  174. MODULE_DEVICE_TABLE(ssam, surface_hid_match);
  175. --
  176. 2.33.0