0006-surface-sam.patch 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660
  1. From 28a501ccd9cc4e7fd424b79b32ecab9e79dea137 Mon Sep 17 00:00:00 2001
  2. From: Maximilian Luz <luzmaximilian@gmail.com>
  3. Date: Sat, 4 Mar 2023 20:09:36 +0100
  4. Subject: [PATCH] platform/surface: aggregator_tabletsw: Properly handle
  5. different posture source IDs
  6. The device posture subsystem (POS) can provide different posture
  7. sources. Different sources can provide different posture states and
  8. sources can be identified by their ID.
  9. For example, screen posture of the Surface Laptop Studio (SLS), which is
  10. currently the only supported source, uses a source ID of 0x03. The
  11. Surface Pro 9 uses the same subsystem for its Type-Cover, however,
  12. provides different states for that under the ID 0x00.
  13. To eventually support the Surface Pro 9 and potential future devices, we
  14. need to properly disambiguate between source IDs. Therefore, add the
  15. source ID to the state we carry and determine the tablet-mode state (as
  16. well as state names) based on that.
  17. Signed-off-by: Maximilian Luz <luzmaximilian@gmail.com>
  18. Patchset: surface-sam
  19. ---
  20. .../surface/surface_aggregator_tabletsw.c | 123 ++++++++++++------
  21. 1 file changed, 84 insertions(+), 39 deletions(-)
  22. diff --git a/drivers/platform/surface/surface_aggregator_tabletsw.c b/drivers/platform/surface/surface_aggregator_tabletsw.c
  23. index 9fed800c7cc09..e8682f52558f3 100644
  24. --- a/drivers/platform/surface/surface_aggregator_tabletsw.c
  25. +++ b/drivers/platform/surface/surface_aggregator_tabletsw.c
  26. @@ -20,16 +20,23 @@
  27. struct ssam_tablet_sw;
  28. +struct ssam_tablet_sw_state {
  29. + u32 source;
  30. + u32 state;
  31. +};
  32. +
  33. struct ssam_tablet_sw_ops {
  34. - int (*get_state)(struct ssam_tablet_sw *sw, u32 *state);
  35. - const char *(*state_name)(struct ssam_tablet_sw *sw, u32 state);
  36. - bool (*state_is_tablet_mode)(struct ssam_tablet_sw *sw, u32 state);
  37. + int (*get_state)(struct ssam_tablet_sw *sw, struct ssam_tablet_sw_state *state);
  38. + const char *(*state_name)(struct ssam_tablet_sw *sw,
  39. + const struct ssam_tablet_sw_state *state);
  40. + bool (*state_is_tablet_mode)(struct ssam_tablet_sw *sw,
  41. + const struct ssam_tablet_sw_state *state);
  42. };
  43. struct ssam_tablet_sw {
  44. struct ssam_device *sdev;
  45. - u32 state;
  46. + struct ssam_tablet_sw_state state;
  47. struct work_struct update_work;
  48. struct input_dev *mode_switch;
  49. @@ -45,9 +52,11 @@ struct ssam_tablet_sw_desc {
  50. struct {
  51. u32 (*notify)(struct ssam_event_notifier *nf, const struct ssam_event *event);
  52. - int (*get_state)(struct ssam_tablet_sw *sw, u32 *state);
  53. - const char *(*state_name)(struct ssam_tablet_sw *sw, u32 state);
  54. - bool (*state_is_tablet_mode)(struct ssam_tablet_sw *sw, u32 state);
  55. + int (*get_state)(struct ssam_tablet_sw *sw, struct ssam_tablet_sw_state *state);
  56. + const char *(*state_name)(struct ssam_tablet_sw *sw,
  57. + const struct ssam_tablet_sw_state *state);
  58. + bool (*state_is_tablet_mode)(struct ssam_tablet_sw *sw,
  59. + const struct ssam_tablet_sw_state *state);
  60. } ops;
  61. struct {
  62. @@ -61,7 +70,7 @@ struct ssam_tablet_sw_desc {
  63. static ssize_t state_show(struct device *dev, struct device_attribute *attr, char *buf)
  64. {
  65. struct ssam_tablet_sw *sw = dev_get_drvdata(dev);
  66. - const char *state = sw->ops.state_name(sw, sw->state);
  67. + const char *state = sw->ops.state_name(sw, &sw->state);
  68. return sysfs_emit(buf, "%s\n", state);
  69. }
  70. @@ -79,19 +88,19 @@ static const struct attribute_group ssam_tablet_sw_group = {
  71. static void ssam_tablet_sw_update_workfn(struct work_struct *work)
  72. {
  73. struct ssam_tablet_sw *sw = container_of(work, struct ssam_tablet_sw, update_work);
  74. + struct ssam_tablet_sw_state state;
  75. int tablet, status;
  76. - u32 state;
  77. status = sw->ops.get_state(sw, &state);
  78. if (status)
  79. return;
  80. - if (sw->state == state)
  81. + if (sw->state.source == state.source && sw->state.state == state.state)
  82. return;
  83. sw->state = state;
  84. /* Send SW_TABLET_MODE event. */
  85. - tablet = sw->ops.state_is_tablet_mode(sw, state);
  86. + tablet = sw->ops.state_is_tablet_mode(sw, &state);
  87. input_report_switch(sw->mode_switch, SW_TABLET_MODE, tablet);
  88. input_sync(sw->mode_switch);
  89. }
  90. @@ -146,7 +155,7 @@ static int ssam_tablet_sw_probe(struct ssam_device *sdev)
  91. sw->mode_switch->id.bustype = BUS_HOST;
  92. sw->mode_switch->dev.parent = &sdev->dev;
  93. - tablet = sw->ops.state_is_tablet_mode(sw, sw->state);
  94. + tablet = sw->ops.state_is_tablet_mode(sw, &sw->state);
  95. input_set_capability(sw->mode_switch, EV_SW, SW_TABLET_MODE);
  96. input_report_switch(sw->mode_switch, SW_TABLET_MODE, tablet);
  97. @@ -203,9 +212,10 @@ enum ssam_kip_cover_state {
  98. SSAM_KIP_COVER_STATE_FOLDED_BACK = 0x05,
  99. };
  100. -static const char *ssam_kip_cover_state_name(struct ssam_tablet_sw *sw, u32 state)
  101. +static const char *ssam_kip_cover_state_name(struct ssam_tablet_sw *sw,
  102. + const struct ssam_tablet_sw_state *state)
  103. {
  104. - switch (state) {
  105. + switch (state->state) {
  106. case SSAM_KIP_COVER_STATE_DISCONNECTED:
  107. return "disconnected";
  108. @@ -222,14 +232,15 @@ static const char *ssam_kip_cover_state_name(struct ssam_tablet_sw *sw, u32 stat
  109. return "folded-back";
  110. default:
  111. - dev_warn(&sw->sdev->dev, "unknown KIP cover state: %u\n", state);
  112. + dev_warn(&sw->sdev->dev, "unknown KIP cover state: %u\n", state->state);
  113. return "<unknown>";
  114. }
  115. }
  116. -static bool ssam_kip_cover_state_is_tablet_mode(struct ssam_tablet_sw *sw, u32 state)
  117. +static bool ssam_kip_cover_state_is_tablet_mode(struct ssam_tablet_sw *sw,
  118. + const struct ssam_tablet_sw_state *state)
  119. {
  120. - switch (state) {
  121. + switch (state->state) {
  122. case SSAM_KIP_COVER_STATE_DISCONNECTED:
  123. case SSAM_KIP_COVER_STATE_FOLDED_CANVAS:
  124. case SSAM_KIP_COVER_STATE_FOLDED_BACK:
  125. @@ -240,7 +251,7 @@ static bool ssam_kip_cover_state_is_tablet_mode(struct ssam_tablet_sw *sw, u32 s
  126. return false;
  127. default:
  128. - dev_warn(&sw->sdev->dev, "unknown KIP cover state: %d\n", sw->state);
  129. + dev_warn(&sw->sdev->dev, "unknown KIP cover state: %d\n", state->state);
  130. return true;
  131. }
  132. }
  133. @@ -252,7 +263,7 @@ SSAM_DEFINE_SYNC_REQUEST_R(__ssam_kip_get_cover_state, u8, {
  134. .instance_id = 0x00,
  135. });
  136. -static int ssam_kip_get_cover_state(struct ssam_tablet_sw *sw, u32 *state)
  137. +static int ssam_kip_get_cover_state(struct ssam_tablet_sw *sw, struct ssam_tablet_sw_state *state)
  138. {
  139. int status;
  140. u8 raw;
  141. @@ -263,7 +274,8 @@ static int ssam_kip_get_cover_state(struct ssam_tablet_sw *sw, u32 *state)
  142. return status;
  143. }
  144. - *state = raw;
  145. + state->source = 0; /* Unused for KIP switch. */
  146. + state->state = raw;
  147. return 0;
  148. }
  149. @@ -312,11 +324,15 @@ MODULE_PARM_DESC(tablet_mode_in_slate_state, "Enable tablet mode in slate device
  150. #define SSAM_EVENT_POS_CID_POSTURE_CHANGED 0x03
  151. #define SSAM_POS_MAX_SOURCES 4
  152. -enum ssam_pos_state {
  153. - SSAM_POS_POSTURE_LID_CLOSED = 0x00,
  154. - SSAM_POS_POSTURE_LAPTOP = 0x01,
  155. - SSAM_POS_POSTURE_SLATE = 0x02,
  156. - SSAM_POS_POSTURE_TABLET = 0x03,
  157. +enum ssam_pos_source_id {
  158. + SSAM_POS_SOURCE_SLS = 0x03,
  159. +};
  160. +
  161. +enum ssam_pos_state_sls {
  162. + SSAM_POS_SLS_LID_CLOSED = 0x00,
  163. + SSAM_POS_SLS_LAPTOP = 0x01,
  164. + SSAM_POS_SLS_SLATE = 0x02,
  165. + SSAM_POS_SLS_TABLET = 0x03,
  166. };
  167. struct ssam_sources_list {
  168. @@ -324,42 +340,68 @@ struct ssam_sources_list {
  169. __le32 id[SSAM_POS_MAX_SOURCES];
  170. } __packed;
  171. -static const char *ssam_pos_state_name(struct ssam_tablet_sw *sw, u32 state)
  172. +static const char *ssam_pos_state_name_sls(struct ssam_tablet_sw *sw, u32 state)
  173. {
  174. switch (state) {
  175. - case SSAM_POS_POSTURE_LID_CLOSED:
  176. + case SSAM_POS_SLS_LID_CLOSED:
  177. return "closed";
  178. - case SSAM_POS_POSTURE_LAPTOP:
  179. + case SSAM_POS_SLS_LAPTOP:
  180. return "laptop";
  181. - case SSAM_POS_POSTURE_SLATE:
  182. + case SSAM_POS_SLS_SLATE:
  183. return "slate";
  184. - case SSAM_POS_POSTURE_TABLET:
  185. + case SSAM_POS_SLS_TABLET:
  186. return "tablet";
  187. default:
  188. - dev_warn(&sw->sdev->dev, "unknown device posture: %u\n", state);
  189. + dev_warn(&sw->sdev->dev, "unknown device posture for SLS: %u\n", state);
  190. return "<unknown>";
  191. }
  192. }
  193. -static bool ssam_pos_state_is_tablet_mode(struct ssam_tablet_sw *sw, u32 state)
  194. +static const char *ssam_pos_state_name(struct ssam_tablet_sw *sw,
  195. + const struct ssam_tablet_sw_state *state)
  196. +{
  197. + switch (state->source) {
  198. + case SSAM_POS_SOURCE_SLS:
  199. + return ssam_pos_state_name_sls(sw, state->state);
  200. +
  201. + default:
  202. + dev_warn(&sw->sdev->dev, "unknown device posture source: %u\n", state->source);
  203. + return "<unknown>";
  204. + }
  205. +}
  206. +
  207. +static bool ssam_pos_state_is_tablet_mode_sls(struct ssam_tablet_sw *sw, u32 state)
  208. {
  209. switch (state) {
  210. - case SSAM_POS_POSTURE_LAPTOP:
  211. - case SSAM_POS_POSTURE_LID_CLOSED:
  212. + case SSAM_POS_SLS_LAPTOP:
  213. + case SSAM_POS_SLS_LID_CLOSED:
  214. return false;
  215. - case SSAM_POS_POSTURE_SLATE:
  216. + case SSAM_POS_SLS_SLATE:
  217. return tablet_mode_in_slate_state;
  218. - case SSAM_POS_POSTURE_TABLET:
  219. + case SSAM_POS_SLS_TABLET:
  220. return true;
  221. default:
  222. - dev_warn(&sw->sdev->dev, "unknown device posture: %u\n", state);
  223. + dev_warn(&sw->sdev->dev, "unknown device posture for SLS: %u\n", state);
  224. + return true;
  225. + }
  226. +}
  227. +
  228. +static bool ssam_pos_state_is_tablet_mode(struct ssam_tablet_sw *sw,
  229. + const struct ssam_tablet_sw_state *state)
  230. +{
  231. + switch (state->source) {
  232. + case SSAM_POS_SOURCE_SLS:
  233. + return ssam_pos_state_is_tablet_mode_sls(sw, state->state);
  234. +
  235. + default:
  236. + dev_warn(&sw->sdev->dev, "unknown device posture source: %u\n", state->source);
  237. return true;
  238. }
  239. }
  240. @@ -450,9 +492,10 @@ static int ssam_pos_get_posture_for_source(struct ssam_tablet_sw *sw, u32 source
  241. return 0;
  242. }
  243. -static int ssam_pos_get_posture(struct ssam_tablet_sw *sw, u32 *state)
  244. +static int ssam_pos_get_posture(struct ssam_tablet_sw *sw, struct ssam_tablet_sw_state *state)
  245. {
  246. u32 source_id;
  247. + u32 source_state;
  248. int status;
  249. status = ssam_pos_get_source(sw, &source_id);
  250. @@ -461,13 +504,15 @@ static int ssam_pos_get_posture(struct ssam_tablet_sw *sw, u32 *state)
  251. return status;
  252. }
  253. - status = ssam_pos_get_posture_for_source(sw, source_id, state);
  254. + status = ssam_pos_get_posture_for_source(sw, source_id, &source_state);
  255. if (status) {
  256. dev_err(&sw->sdev->dev, "failed to get posture value for source %u: %d\n",
  257. source_id, status);
  258. return status;
  259. }
  260. + state->source = source_id;
  261. + state->state = source_state;
  262. return 0;
  263. }
  264. --
  265. 2.40.1
  266. From 254309b7f226893d432dec3f247185fd182c5192 Mon Sep 17 00:00:00 2001
  267. From: Maximilian Luz <luzmaximilian@gmail.com>
  268. Date: Sun, 19 Feb 2023 23:33:43 +0100
  269. Subject: [PATCH] platform/surface: aggregator_tabletsw: Add support for
  270. Type-Cover posture source
  271. Implement support for the Type-Cover posture source (ID 0x00), found on
  272. the Surface Pro 9.
  273. Signed-off-by: Maximilian Luz <luzmaximilian@gmail.com>
  274. Patchset: surface-sam
  275. ---
  276. .../surface/surface_aggregator_tabletsw.c | 57 +++++++++++++++++++
  277. 1 file changed, 57 insertions(+)
  278. diff --git a/drivers/platform/surface/surface_aggregator_tabletsw.c b/drivers/platform/surface/surface_aggregator_tabletsw.c
  279. index e8682f52558f3..8f52b62d1c195 100644
  280. --- a/drivers/platform/surface/surface_aggregator_tabletsw.c
  281. +++ b/drivers/platform/surface/surface_aggregator_tabletsw.c
  282. @@ -325,9 +325,18 @@ MODULE_PARM_DESC(tablet_mode_in_slate_state, "Enable tablet mode in slate device
  283. #define SSAM_POS_MAX_SOURCES 4
  284. enum ssam_pos_source_id {
  285. + SSAM_POS_SOURCE_COVER = 0x00,
  286. SSAM_POS_SOURCE_SLS = 0x03,
  287. };
  288. +enum ssam_pos_state_cover {
  289. + SSAM_POS_COVER_DISCONNECTED = 0x01,
  290. + SSAM_POS_COVER_CLOSED = 0x02,
  291. + SSAM_POS_COVER_LAPTOP = 0x03,
  292. + SSAM_POS_COVER_FOLDED_CANVAS = 0x04,
  293. + SSAM_POS_COVER_FOLDED_BACK = 0x05,
  294. +};
  295. +
  296. enum ssam_pos_state_sls {
  297. SSAM_POS_SLS_LID_CLOSED = 0x00,
  298. SSAM_POS_SLS_LAPTOP = 0x01,
  299. @@ -340,6 +349,30 @@ struct ssam_sources_list {
  300. __le32 id[SSAM_POS_MAX_SOURCES];
  301. } __packed;
  302. +static const char *ssam_pos_state_name_cover(struct ssam_tablet_sw *sw, u32 state)
  303. +{
  304. + switch (state) {
  305. + case SSAM_POS_COVER_DISCONNECTED:
  306. + return "disconnected";
  307. +
  308. + case SSAM_POS_COVER_CLOSED:
  309. + return "closed";
  310. +
  311. + case SSAM_POS_COVER_LAPTOP:
  312. + return "laptop";
  313. +
  314. + case SSAM_POS_COVER_FOLDED_CANVAS:
  315. + return "folded-canvas";
  316. +
  317. + case SSAM_POS_COVER_FOLDED_BACK:
  318. + return "folded-back";
  319. +
  320. + default:
  321. + dev_warn(&sw->sdev->dev, "unknown device posture for type-cover: %u\n", state);
  322. + return "<unknown>";
  323. + }
  324. +}
  325. +
  326. static const char *ssam_pos_state_name_sls(struct ssam_tablet_sw *sw, u32 state)
  327. {
  328. switch (state) {
  329. @@ -365,6 +398,9 @@ static const char *ssam_pos_state_name(struct ssam_tablet_sw *sw,
  330. const struct ssam_tablet_sw_state *state)
  331. {
  332. switch (state->source) {
  333. + case SSAM_POS_SOURCE_COVER:
  334. + return ssam_pos_state_name_cover(sw, state->state);
  335. +
  336. case SSAM_POS_SOURCE_SLS:
  337. return ssam_pos_state_name_sls(sw, state->state);
  338. @@ -374,6 +410,24 @@ static const char *ssam_pos_state_name(struct ssam_tablet_sw *sw,
  339. }
  340. }
  341. +static bool ssam_pos_state_is_tablet_mode_cover(struct ssam_tablet_sw *sw, u32 state)
  342. +{
  343. + switch (state) {
  344. + case SSAM_POS_COVER_DISCONNECTED:
  345. + case SSAM_POS_COVER_FOLDED_CANVAS:
  346. + case SSAM_POS_COVER_FOLDED_BACK:
  347. + return true;
  348. +
  349. + case SSAM_POS_COVER_CLOSED:
  350. + case SSAM_POS_COVER_LAPTOP:
  351. + return false;
  352. +
  353. + default:
  354. + dev_warn(&sw->sdev->dev, "unknown device posture for type-cover: %u\n", state);
  355. + return true;
  356. + }
  357. +}
  358. +
  359. static bool ssam_pos_state_is_tablet_mode_sls(struct ssam_tablet_sw *sw, u32 state)
  360. {
  361. switch (state) {
  362. @@ -397,6 +451,9 @@ static bool ssam_pos_state_is_tablet_mode(struct ssam_tablet_sw *sw,
  363. const struct ssam_tablet_sw_state *state)
  364. {
  365. switch (state->source) {
  366. + case SSAM_POS_SOURCE_COVER:
  367. + return ssam_pos_state_is_tablet_mode_cover(sw, state->state);
  368. +
  369. case SSAM_POS_SOURCE_SLS:
  370. return ssam_pos_state_is_tablet_mode_sls(sw, state->state);
  371. --
  372. 2.40.1
  373. From 7b641bef1a47526a82353571a0694a41881ff69d Mon Sep 17 00:00:00 2001
  374. From: Maximilian Luz <luzmaximilian@gmail.com>
  375. Date: Sun, 19 Feb 2023 23:41:18 +0100
  376. Subject: [PATCH] platform/surface: aggregator_registry: Add support for
  377. tablet-mode switch on Surface Pro 9
  378. Add support for the POS-subsystem tablet-mode switch used on the Surface
  379. Pro 9.
  380. Signed-off-by: Maximilian Luz <luzmaximilian@gmail.com>
  381. Patchset: surface-sam
  382. ---
  383. drivers/platform/surface/surface_aggregator_registry.c | 2 +-
  384. 1 file changed, 1 insertion(+), 1 deletion(-)
  385. diff --git a/drivers/platform/surface/surface_aggregator_registry.c b/drivers/platform/surface/surface_aggregator_registry.c
  386. index 296f72d52e6a6..0fe5be5396525 100644
  387. --- a/drivers/platform/surface/surface_aggregator_registry.c
  388. +++ b/drivers/platform/surface/surface_aggregator_registry.c
  389. @@ -305,7 +305,7 @@ static const struct software_node *ssam_node_group_sp9[] = {
  390. &ssam_node_bat_ac,
  391. &ssam_node_bat_main,
  392. &ssam_node_tmp_pprof,
  393. - /* TODO: Tablet mode switch (via POS subsystem) */
  394. + &ssam_node_pos_tablet_switch,
  395. &ssam_node_hid_kip_keyboard,
  396. &ssam_node_hid_kip_penstash,
  397. &ssam_node_hid_kip_touchpad,
  398. --
  399. 2.40.1
  400. From 980183aeae06a1b46c4dee929d642854b3c24c89 Mon Sep 17 00:00:00 2001
  401. From: Maximilian Luz <luzmaximilian@gmail.com>
  402. Date: Wed, 3 May 2023 02:02:21 +0200
  403. Subject: [PATCH] platform/surface: aggregator: Allow completion work-items to
  404. be executed in parallel
  405. Currently, event completion work-items are restricted to be run strictly
  406. in non-parallel fashion by the respective workqueue. However, this has
  407. lead to some problems:
  408. In some instances, the event notifier function called inside this
  409. completion workqueue takes a non-negligible amount of time to execute.
  410. One such example is the battery event handling code (surface_battery.c),
  411. which can result in a full battery information refresh, involving
  412. further synchronous communication with the EC inside the event handler.
  413. This is made worse if the communication fails spuriously, generally
  414. incurring a multi-second timeout.
  415. Since the event completions are run strictly non-parallel, this blocks
  416. other events from being propagated to the respective subsystems. This
  417. becomes especially noticeable for keyboard and touchpad input, which
  418. also funnel their events through this system. Here, users have reported
  419. occasional multi-second "freezes".
  420. Note, however, that the event handling system was never intended to run
  421. purely sequentially. Instead, we have one work struct per EC/SAM
  422. subsystem, processing the event queue for that subsystem. These work
  423. structs were intended to run in parallel, allowing sequential processing
  424. of work items for each subsystem but parallel processing of work items
  425. across subsystems.
  426. The only restriction to this is the way the workqueue is created.
  427. Therefore, replace create_workqueue() with alloc_workqueue() and do not
  428. restrict the maximum number of parallel work items to be executed on
  429. that queue, resolving any cross-subsystem blockage.
  430. Fixes: c167b9c7e3d6 ("platform/surface: Add Surface Aggregator subsystem")
  431. Link: https://github.com/linux-surface/linux-surface/issues/1026
  432. Signed-off-by: Maximilian Luz <luzmaximilian@gmail.com>
  433. Patchset: surface-sam
  434. ---
  435. drivers/platform/surface/aggregator/controller.c | 2 +-
  436. 1 file changed, 1 insertion(+), 1 deletion(-)
  437. diff --git a/drivers/platform/surface/aggregator/controller.c b/drivers/platform/surface/aggregator/controller.c
  438. index 535581c0471c5..7fc602e01487d 100644
  439. --- a/drivers/platform/surface/aggregator/controller.c
  440. +++ b/drivers/platform/surface/aggregator/controller.c
  441. @@ -825,7 +825,7 @@ static int ssam_cplt_init(struct ssam_cplt *cplt, struct device *dev)
  442. cplt->dev = dev;
  443. - cplt->wq = create_workqueue(SSAM_CPLT_WQ_NAME);
  444. + cplt->wq = alloc_workqueue(SSAM_CPLT_WQ_NAME, WQ_UNBOUND | WQ_MEM_RECLAIM, 0);
  445. if (!cplt->wq)
  446. return -ENOMEM;
  447. --
  448. 2.40.1
  449. From 54c72fc01264aface4345f5d70eb7d194d471210 Mon Sep 17 00:00:00 2001
  450. From: Maximilian Luz <luzmaximilian@gmail.com>
  451. Date: Thu, 18 May 2023 22:33:55 +0200
  452. Subject: [PATCH] platform/surface: aggregator: Make to_ssam_device_driver()
  453. respect const-ness
  454. Make to_ssam_device_driver() a bit safer by replacing container_of()
  455. with container_of_const() to respect the const-ness of the passed in
  456. pointer, instead of silently discarding any const specifications.
  457. Signed-off-by: Maximilian Luz <luzmaximilian@gmail.com>
  458. Patchset: surface-sam
  459. ---
  460. include/linux/surface_aggregator/device.h | 6 +-----
  461. 1 file changed, 1 insertion(+), 5 deletions(-)
  462. diff --git a/include/linux/surface_aggregator/device.h b/include/linux/surface_aggregator/device.h
  463. index df81043b9e718..42b249b4c24b1 100644
  464. --- a/include/linux/surface_aggregator/device.h
  465. +++ b/include/linux/surface_aggregator/device.h
  466. @@ -243,11 +243,7 @@ static inline bool is_ssam_device(struct device *d)
  467. * Return: Returns the pointer to the &struct ssam_device_driver wrapping the
  468. * given device driver @d.
  469. */
  470. -static inline
  471. -struct ssam_device_driver *to_ssam_device_driver(struct device_driver *d)
  472. -{
  473. - return container_of(d, struct ssam_device_driver, driver);
  474. -}
  475. +#define to_ssam_device_driver(d) container_of_const(d, struct ssam_device_driver, driver)
  476. const struct ssam_device_id *ssam_device_id_match(const struct ssam_device_id *table,
  477. const struct ssam_device_uid uid);
  478. --
  479. 2.40.1
  480. From 61df3fe89021926391458b9e2b334c4ca0263449 Mon Sep 17 00:00:00 2001
  481. From: Maximilian Luz <luzmaximilian@gmail.com>
  482. Date: Thu, 18 May 2023 22:53:12 +0200
  483. Subject: [PATCH] platform/surface: aggregator_tabletsw: Add support for book
  484. mode in KIP subsystem
  485. Devices with a type-cover have an additional "book" mode, deactivating
  486. type-cover input and turning off its backlight. This is currently
  487. unsupported, leading to the warning
  488. surface_aggregator_tablet_mode_switch 01:03:01:00:01: unknown KIP cover state: 6
  489. Therefore, add support for this state and map it to enable tablet-mode.
  490. Fixes: 9f794056db5b ("platform/surface: Add KIP/POS tablet-mode switch driver")
  491. Signed-off-by: Maximilian Luz <luzmaximilian@gmail.com>
  492. Patchset: surface-sam
  493. ---
  494. drivers/platform/surface/surface_aggregator_tabletsw.c | 5 +++++
  495. 1 file changed, 5 insertions(+)
  496. diff --git a/drivers/platform/surface/surface_aggregator_tabletsw.c b/drivers/platform/surface/surface_aggregator_tabletsw.c
  497. index 8f52b62d1c195..4a029f5db20a9 100644
  498. --- a/drivers/platform/surface/surface_aggregator_tabletsw.c
  499. +++ b/drivers/platform/surface/surface_aggregator_tabletsw.c
  500. @@ -210,6 +210,7 @@ enum ssam_kip_cover_state {
  501. SSAM_KIP_COVER_STATE_LAPTOP = 0x03,
  502. SSAM_KIP_COVER_STATE_FOLDED_CANVAS = 0x04,
  503. SSAM_KIP_COVER_STATE_FOLDED_BACK = 0x05,
  504. + SSAM_KIP_COVER_STATE_BOOK = 0x06,
  505. };
  506. static const char *ssam_kip_cover_state_name(struct ssam_tablet_sw *sw,
  507. @@ -231,6 +232,9 @@ static const char *ssam_kip_cover_state_name(struct ssam_tablet_sw *sw,
  508. case SSAM_KIP_COVER_STATE_FOLDED_BACK:
  509. return "folded-back";
  510. + case SSAM_KIP_COVER_STATE_BOOK:
  511. + return "book";
  512. +
  513. default:
  514. dev_warn(&sw->sdev->dev, "unknown KIP cover state: %u\n", state->state);
  515. return "<unknown>";
  516. @@ -244,6 +248,7 @@ static bool ssam_kip_cover_state_is_tablet_mode(struct ssam_tablet_sw *sw,
  517. case SSAM_KIP_COVER_STATE_DISCONNECTED:
  518. case SSAM_KIP_COVER_STATE_FOLDED_CANVAS:
  519. case SSAM_KIP_COVER_STATE_FOLDED_BACK:
  520. + case SSAM_KIP_COVER_STATE_BOOK:
  521. return true;
  522. case SSAM_KIP_COVER_STATE_CLOSED:
  523. --
  524. 2.40.1
  525. From bac3a83ede3421c7d625c5b901be2f37fcde9af2 Mon Sep 17 00:00:00 2001
  526. From: Maximilian Luz <luzmaximilian@gmail.com>
  527. Date: Thu, 18 May 2023 22:57:17 +0200
  528. Subject: [PATCH] platform/surface: aggregator_tabletsw: Add support for book
  529. mode in POS subsystem
  530. Devices with a type-cover have an additional "book" mode, deactivating
  531. type-cover input and turning off its backlight. This is currently
  532. unsupported, leading to the warning
  533. surface_aggregator_tablet_mode_switch 01:26:01:00:01: unknown device posture for type-cover: 6
  534. Therefore, add support for this state and map it to enable tablet-mode.
  535. Fixes: 37ff64cd81ff ("platform/surface: aggregator_tabletsw: Add support for Type-Cover posture source")
  536. Signed-off-by: Maximilian Luz <luzmaximilian@gmail.com>
  537. Patchset: surface-sam
  538. ---
  539. drivers/platform/surface/surface_aggregator_tabletsw.c | 5 +++++
  540. 1 file changed, 5 insertions(+)
  541. diff --git a/drivers/platform/surface/surface_aggregator_tabletsw.c b/drivers/platform/surface/surface_aggregator_tabletsw.c
  542. index 4a029f5db20a9..c0a1a5869246e 100644
  543. --- a/drivers/platform/surface/surface_aggregator_tabletsw.c
  544. +++ b/drivers/platform/surface/surface_aggregator_tabletsw.c
  545. @@ -340,6 +340,7 @@ enum ssam_pos_state_cover {
  546. SSAM_POS_COVER_LAPTOP = 0x03,
  547. SSAM_POS_COVER_FOLDED_CANVAS = 0x04,
  548. SSAM_POS_COVER_FOLDED_BACK = 0x05,
  549. + SSAM_POS_COVER_BOOK = 0x06,
  550. };
  551. enum ssam_pos_state_sls {
  552. @@ -372,6 +373,9 @@ static const char *ssam_pos_state_name_cover(struct ssam_tablet_sw *sw, u32 stat
  553. case SSAM_POS_COVER_FOLDED_BACK:
  554. return "folded-back";
  555. + case SSAM_POS_COVER_BOOK:
  556. + return "book";
  557. +
  558. default:
  559. dev_warn(&sw->sdev->dev, "unknown device posture for type-cover: %u\n", state);
  560. return "<unknown>";
  561. @@ -421,6 +425,7 @@ static bool ssam_pos_state_is_tablet_mode_cover(struct ssam_tablet_sw *sw, u32 s
  562. case SSAM_POS_COVER_DISCONNECTED:
  563. case SSAM_POS_COVER_FOLDED_CANVAS:
  564. case SSAM_POS_COVER_FOLDED_BACK:
  565. + case SSAM_POS_COVER_BOOK:
  566. return true;
  567. case SSAM_POS_COVER_CLOSED:
  568. --
  569. 2.40.1