2023-07-22 15:29:40 +00:00
|
|
|
From 41eb4275f7868b68ac9868b44dd2b29fb97f091e Mon Sep 17 00:00:00 2001
|
2023-05-11 12:10:25 +00:00
|
|
|
From: Maximilian Luz <luzmaximilian@gmail.com>
|
|
|
|
Date: Sat, 4 Mar 2023 20:09:36 +0100
|
|
|
|
Subject: [PATCH] platform/surface: aggregator_tabletsw: Properly handle
|
|
|
|
different posture source IDs
|
|
|
|
|
|
|
|
The device posture subsystem (POS) can provide different posture
|
|
|
|
sources. Different sources can provide different posture states and
|
|
|
|
sources can be identified by their ID.
|
|
|
|
|
|
|
|
For example, screen posture of the Surface Laptop Studio (SLS), which is
|
|
|
|
currently the only supported source, uses a source ID of 0x03. The
|
|
|
|
Surface Pro 9 uses the same subsystem for its Type-Cover, however,
|
|
|
|
provides different states for that under the ID 0x00.
|
|
|
|
|
|
|
|
To eventually support the Surface Pro 9 and potential future devices, we
|
|
|
|
need to properly disambiguate between source IDs. Therefore, add the
|
|
|
|
source ID to the state we carry and determine the tablet-mode state (as
|
|
|
|
well as state names) based on that.
|
|
|
|
|
|
|
|
Signed-off-by: Maximilian Luz <luzmaximilian@gmail.com>
|
|
|
|
Patchset: surface-sam
|
|
|
|
---
|
|
|
|
.../surface/surface_aggregator_tabletsw.c | 123 ++++++++++++------
|
|
|
|
1 file changed, 84 insertions(+), 39 deletions(-)
|
|
|
|
|
|
|
|
diff --git a/drivers/platform/surface/surface_aggregator_tabletsw.c b/drivers/platform/surface/surface_aggregator_tabletsw.c
|
2023-06-17 22:08:32 +00:00
|
|
|
index a18e9fc7896b..f9a58db6afde 100644
|
2023-05-11 12:10:25 +00:00
|
|
|
--- a/drivers/platform/surface/surface_aggregator_tabletsw.c
|
|
|
|
+++ b/drivers/platform/surface/surface_aggregator_tabletsw.c
|
|
|
|
@@ -20,16 +20,23 @@
|
|
|
|
|
|
|
|
struct ssam_tablet_sw;
|
|
|
|
|
|
|
|
+struct ssam_tablet_sw_state {
|
|
|
|
+ u32 source;
|
|
|
|
+ u32 state;
|
|
|
|
+};
|
|
|
|
+
|
|
|
|
struct ssam_tablet_sw_ops {
|
|
|
|
- int (*get_state)(struct ssam_tablet_sw *sw, u32 *state);
|
|
|
|
- const char *(*state_name)(struct ssam_tablet_sw *sw, u32 state);
|
|
|
|
- bool (*state_is_tablet_mode)(struct ssam_tablet_sw *sw, u32 state);
|
|
|
|
+ int (*get_state)(struct ssam_tablet_sw *sw, struct ssam_tablet_sw_state *state);
|
|
|
|
+ const char *(*state_name)(struct ssam_tablet_sw *sw,
|
|
|
|
+ const struct ssam_tablet_sw_state *state);
|
|
|
|
+ bool (*state_is_tablet_mode)(struct ssam_tablet_sw *sw,
|
|
|
|
+ const struct ssam_tablet_sw_state *state);
|
|
|
|
};
|
|
|
|
|
|
|
|
struct ssam_tablet_sw {
|
|
|
|
struct ssam_device *sdev;
|
|
|
|
|
|
|
|
- u32 state;
|
|
|
|
+ struct ssam_tablet_sw_state state;
|
|
|
|
struct work_struct update_work;
|
|
|
|
struct input_dev *mode_switch;
|
|
|
|
|
|
|
|
@@ -45,9 +52,11 @@ struct ssam_tablet_sw_desc {
|
|
|
|
|
|
|
|
struct {
|
|
|
|
u32 (*notify)(struct ssam_event_notifier *nf, const struct ssam_event *event);
|
|
|
|
- int (*get_state)(struct ssam_tablet_sw *sw, u32 *state);
|
|
|
|
- const char *(*state_name)(struct ssam_tablet_sw *sw, u32 state);
|
|
|
|
- bool (*state_is_tablet_mode)(struct ssam_tablet_sw *sw, u32 state);
|
|
|
|
+ int (*get_state)(struct ssam_tablet_sw *sw, struct ssam_tablet_sw_state *state);
|
|
|
|
+ const char *(*state_name)(struct ssam_tablet_sw *sw,
|
|
|
|
+ const struct ssam_tablet_sw_state *state);
|
|
|
|
+ bool (*state_is_tablet_mode)(struct ssam_tablet_sw *sw,
|
|
|
|
+ const struct ssam_tablet_sw_state *state);
|
|
|
|
} ops;
|
|
|
|
|
|
|
|
struct {
|
|
|
|
@@ -61,7 +70,7 @@ struct ssam_tablet_sw_desc {
|
|
|
|
static ssize_t state_show(struct device *dev, struct device_attribute *attr, char *buf)
|
|
|
|
{
|
|
|
|
struct ssam_tablet_sw *sw = dev_get_drvdata(dev);
|
|
|
|
- const char *state = sw->ops.state_name(sw, sw->state);
|
|
|
|
+ const char *state = sw->ops.state_name(sw, &sw->state);
|
|
|
|
|
|
|
|
return sysfs_emit(buf, "%s\n", state);
|
|
|
|
}
|
|
|
|
@@ -79,19 +88,19 @@ static const struct attribute_group ssam_tablet_sw_group = {
|
|
|
|
static void ssam_tablet_sw_update_workfn(struct work_struct *work)
|
|
|
|
{
|
|
|
|
struct ssam_tablet_sw *sw = container_of(work, struct ssam_tablet_sw, update_work);
|
|
|
|
+ struct ssam_tablet_sw_state state;
|
|
|
|
int tablet, status;
|
|
|
|
- u32 state;
|
|
|
|
|
|
|
|
status = sw->ops.get_state(sw, &state);
|
|
|
|
if (status)
|
|
|
|
return;
|
|
|
|
|
|
|
|
- if (sw->state == state)
|
|
|
|
+ if (sw->state.source == state.source && sw->state.state == state.state)
|
|
|
|
return;
|
|
|
|
sw->state = state;
|
|
|
|
|
|
|
|
/* Send SW_TABLET_MODE event. */
|
|
|
|
- tablet = sw->ops.state_is_tablet_mode(sw, state);
|
|
|
|
+ tablet = sw->ops.state_is_tablet_mode(sw, &state);
|
|
|
|
input_report_switch(sw->mode_switch, SW_TABLET_MODE, tablet);
|
|
|
|
input_sync(sw->mode_switch);
|
|
|
|
}
|
|
|
|
@@ -146,7 +155,7 @@ static int ssam_tablet_sw_probe(struct ssam_device *sdev)
|
|
|
|
sw->mode_switch->id.bustype = BUS_HOST;
|
|
|
|
sw->mode_switch->dev.parent = &sdev->dev;
|
|
|
|
|
|
|
|
- tablet = sw->ops.state_is_tablet_mode(sw, sw->state);
|
|
|
|
+ tablet = sw->ops.state_is_tablet_mode(sw, &sw->state);
|
|
|
|
input_set_capability(sw->mode_switch, EV_SW, SW_TABLET_MODE);
|
|
|
|
input_report_switch(sw->mode_switch, SW_TABLET_MODE, tablet);
|
|
|
|
|
2023-06-17 22:08:32 +00:00
|
|
|
@@ -204,9 +213,10 @@ enum ssam_kip_cover_state {
|
|
|
|
SSAM_KIP_COVER_STATE_BOOK = 0x06,
|
2023-05-11 12:10:25 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
-static const char *ssam_kip_cover_state_name(struct ssam_tablet_sw *sw, u32 state)
|
|
|
|
+static const char *ssam_kip_cover_state_name(struct ssam_tablet_sw *sw,
|
|
|
|
+ const struct ssam_tablet_sw_state *state)
|
|
|
|
{
|
|
|
|
- switch (state) {
|
|
|
|
+ switch (state->state) {
|
|
|
|
case SSAM_KIP_COVER_STATE_DISCONNECTED:
|
|
|
|
return "disconnected";
|
|
|
|
|
2023-06-17 22:08:32 +00:00
|
|
|
@@ -226,14 +236,15 @@ static const char *ssam_kip_cover_state_name(struct ssam_tablet_sw *sw, u32 stat
|
|
|
|
return "book";
|
2023-05-11 12:10:25 +00:00
|
|
|
|
|
|
|
default:
|
|
|
|
- dev_warn(&sw->sdev->dev, "unknown KIP cover state: %u\n", state);
|
|
|
|
+ dev_warn(&sw->sdev->dev, "unknown KIP cover state: %u\n", state->state);
|
|
|
|
return "<unknown>";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
-static bool ssam_kip_cover_state_is_tablet_mode(struct ssam_tablet_sw *sw, u32 state)
|
|
|
|
+static bool ssam_kip_cover_state_is_tablet_mode(struct ssam_tablet_sw *sw,
|
|
|
|
+ const struct ssam_tablet_sw_state *state)
|
|
|
|
{
|
|
|
|
- switch (state) {
|
|
|
|
+ switch (state->state) {
|
|
|
|
case SSAM_KIP_COVER_STATE_DISCONNECTED:
|
|
|
|
case SSAM_KIP_COVER_STATE_FOLDED_CANVAS:
|
|
|
|
case SSAM_KIP_COVER_STATE_FOLDED_BACK:
|
2023-06-17 22:08:32 +00:00
|
|
|
@@ -245,7 +256,7 @@ static bool ssam_kip_cover_state_is_tablet_mode(struct ssam_tablet_sw *sw, u32 s
|
2023-05-11 12:10:25 +00:00
|
|
|
return false;
|
|
|
|
|
|
|
|
default:
|
|
|
|
- dev_warn(&sw->sdev->dev, "unknown KIP cover state: %d\n", sw->state);
|
|
|
|
+ dev_warn(&sw->sdev->dev, "unknown KIP cover state: %d\n", state->state);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
2023-06-17 22:08:32 +00:00
|
|
|
@@ -257,7 +268,7 @@ SSAM_DEFINE_SYNC_REQUEST_R(__ssam_kip_get_cover_state, u8, {
|
2023-05-11 12:10:25 +00:00
|
|
|
.instance_id = 0x00,
|
|
|
|
});
|
|
|
|
|
|
|
|
-static int ssam_kip_get_cover_state(struct ssam_tablet_sw *sw, u32 *state)
|
|
|
|
+static int ssam_kip_get_cover_state(struct ssam_tablet_sw *sw, struct ssam_tablet_sw_state *state)
|
|
|
|
{
|
|
|
|
int status;
|
|
|
|
u8 raw;
|
2023-06-17 22:08:32 +00:00
|
|
|
@@ -268,7 +279,8 @@ static int ssam_kip_get_cover_state(struct ssam_tablet_sw *sw, u32 *state)
|
2023-05-11 12:10:25 +00:00
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
|
|
|
- *state = raw;
|
|
|
|
+ state->source = 0; /* Unused for KIP switch. */
|
|
|
|
+ state->state = raw;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2023-06-17 22:08:32 +00:00
|
|
|
@@ -317,11 +329,15 @@ MODULE_PARM_DESC(tablet_mode_in_slate_state, "Enable tablet mode in slate device
|
2023-05-11 12:10:25 +00:00
|
|
|
#define SSAM_EVENT_POS_CID_POSTURE_CHANGED 0x03
|
|
|
|
#define SSAM_POS_MAX_SOURCES 4
|
|
|
|
|
|
|
|
-enum ssam_pos_state {
|
|
|
|
- SSAM_POS_POSTURE_LID_CLOSED = 0x00,
|
|
|
|
- SSAM_POS_POSTURE_LAPTOP = 0x01,
|
|
|
|
- SSAM_POS_POSTURE_SLATE = 0x02,
|
|
|
|
- SSAM_POS_POSTURE_TABLET = 0x03,
|
|
|
|
+enum ssam_pos_source_id {
|
|
|
|
+ SSAM_POS_SOURCE_SLS = 0x03,
|
|
|
|
+};
|
|
|
|
+
|
|
|
|
+enum ssam_pos_state_sls {
|
|
|
|
+ SSAM_POS_SLS_LID_CLOSED = 0x00,
|
|
|
|
+ SSAM_POS_SLS_LAPTOP = 0x01,
|
|
|
|
+ SSAM_POS_SLS_SLATE = 0x02,
|
|
|
|
+ SSAM_POS_SLS_TABLET = 0x03,
|
|
|
|
};
|
|
|
|
|
|
|
|
struct ssam_sources_list {
|
2023-06-17 22:08:32 +00:00
|
|
|
@@ -329,42 +345,68 @@ struct ssam_sources_list {
|
2023-05-11 12:10:25 +00:00
|
|
|
__le32 id[SSAM_POS_MAX_SOURCES];
|
|
|
|
} __packed;
|
|
|
|
|
|
|
|
-static const char *ssam_pos_state_name(struct ssam_tablet_sw *sw, u32 state)
|
|
|
|
+static const char *ssam_pos_state_name_sls(struct ssam_tablet_sw *sw, u32 state)
|
|
|
|
{
|
|
|
|
switch (state) {
|
|
|
|
- case SSAM_POS_POSTURE_LID_CLOSED:
|
|
|
|
+ case SSAM_POS_SLS_LID_CLOSED:
|
|
|
|
return "closed";
|
|
|
|
|
|
|
|
- case SSAM_POS_POSTURE_LAPTOP:
|
|
|
|
+ case SSAM_POS_SLS_LAPTOP:
|
|
|
|
return "laptop";
|
|
|
|
|
|
|
|
- case SSAM_POS_POSTURE_SLATE:
|
|
|
|
+ case SSAM_POS_SLS_SLATE:
|
|
|
|
return "slate";
|
|
|
|
|
|
|
|
- case SSAM_POS_POSTURE_TABLET:
|
|
|
|
+ case SSAM_POS_SLS_TABLET:
|
|
|
|
return "tablet";
|
|
|
|
|
|
|
|
default:
|
|
|
|
- dev_warn(&sw->sdev->dev, "unknown device posture: %u\n", state);
|
|
|
|
+ dev_warn(&sw->sdev->dev, "unknown device posture for SLS: %u\n", state);
|
|
|
|
return "<unknown>";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
-static bool ssam_pos_state_is_tablet_mode(struct ssam_tablet_sw *sw, u32 state)
|
|
|
|
+static const char *ssam_pos_state_name(struct ssam_tablet_sw *sw,
|
|
|
|
+ const struct ssam_tablet_sw_state *state)
|
|
|
|
+{
|
|
|
|
+ switch (state->source) {
|
|
|
|
+ case SSAM_POS_SOURCE_SLS:
|
|
|
|
+ return ssam_pos_state_name_sls(sw, state->state);
|
|
|
|
+
|
|
|
|
+ default:
|
|
|
|
+ dev_warn(&sw->sdev->dev, "unknown device posture source: %u\n", state->source);
|
|
|
|
+ return "<unknown>";
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+static bool ssam_pos_state_is_tablet_mode_sls(struct ssam_tablet_sw *sw, u32 state)
|
|
|
|
{
|
|
|
|
switch (state) {
|
|
|
|
- case SSAM_POS_POSTURE_LAPTOP:
|
|
|
|
- case SSAM_POS_POSTURE_LID_CLOSED:
|
|
|
|
+ case SSAM_POS_SLS_LAPTOP:
|
|
|
|
+ case SSAM_POS_SLS_LID_CLOSED:
|
|
|
|
return false;
|
|
|
|
|
|
|
|
- case SSAM_POS_POSTURE_SLATE:
|
|
|
|
+ case SSAM_POS_SLS_SLATE:
|
|
|
|
return tablet_mode_in_slate_state;
|
|
|
|
|
|
|
|
- case SSAM_POS_POSTURE_TABLET:
|
|
|
|
+ case SSAM_POS_SLS_TABLET:
|
|
|
|
return true;
|
|
|
|
|
|
|
|
default:
|
|
|
|
- dev_warn(&sw->sdev->dev, "unknown device posture: %u\n", state);
|
|
|
|
+ dev_warn(&sw->sdev->dev, "unknown device posture for SLS: %u\n", state);
|
|
|
|
+ return true;
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+static bool ssam_pos_state_is_tablet_mode(struct ssam_tablet_sw *sw,
|
|
|
|
+ const struct ssam_tablet_sw_state *state)
|
|
|
|
+{
|
|
|
|
+ switch (state->source) {
|
|
|
|
+ case SSAM_POS_SOURCE_SLS:
|
|
|
|
+ return ssam_pos_state_is_tablet_mode_sls(sw, state->state);
|
|
|
|
+
|
|
|
|
+ default:
|
|
|
|
+ dev_warn(&sw->sdev->dev, "unknown device posture source: %u\n", state->source);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
2023-06-17 22:08:32 +00:00
|
|
|
@@ -455,9 +497,10 @@ static int ssam_pos_get_posture_for_source(struct ssam_tablet_sw *sw, u32 source
|
2023-05-11 12:10:25 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
-static int ssam_pos_get_posture(struct ssam_tablet_sw *sw, u32 *state)
|
|
|
|
+static int ssam_pos_get_posture(struct ssam_tablet_sw *sw, struct ssam_tablet_sw_state *state)
|
|
|
|
{
|
|
|
|
u32 source_id;
|
|
|
|
+ u32 source_state;
|
|
|
|
int status;
|
|
|
|
|
|
|
|
status = ssam_pos_get_source(sw, &source_id);
|
2023-06-17 22:08:32 +00:00
|
|
|
@@ -466,13 +509,15 @@ static int ssam_pos_get_posture(struct ssam_tablet_sw *sw, u32 *state)
|
2023-05-11 12:10:25 +00:00
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
|
|
|
- status = ssam_pos_get_posture_for_source(sw, source_id, state);
|
|
|
|
+ status = ssam_pos_get_posture_for_source(sw, source_id, &source_state);
|
|
|
|
if (status) {
|
|
|
|
dev_err(&sw->sdev->dev, "failed to get posture value for source %u: %d\n",
|
|
|
|
source_id, status);
|
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
|
|
|
+ state->source = source_id;
|
|
|
|
+ state->state = source_state;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
--
|
2023-06-14 10:39:33 +00:00
|
|
|
2.41.0
|
2023-05-11 12:10:25 +00:00
|
|
|
|
2023-07-22 15:29:40 +00:00
|
|
|
From 742a68a8e0ec261cbe4ae08e6e101887cf8a3b72 Mon Sep 17 00:00:00 2001
|
2023-05-11 12:10:25 +00:00
|
|
|
From: Maximilian Luz <luzmaximilian@gmail.com>
|
|
|
|
Date: Sun, 19 Feb 2023 23:33:43 +0100
|
|
|
|
Subject: [PATCH] platform/surface: aggregator_tabletsw: Add support for
|
|
|
|
Type-Cover posture source
|
|
|
|
|
|
|
|
Implement support for the Type-Cover posture source (ID 0x00), found on
|
|
|
|
the Surface Pro 9.
|
|
|
|
|
|
|
|
Signed-off-by: Maximilian Luz <luzmaximilian@gmail.com>
|
|
|
|
Patchset: surface-sam
|
|
|
|
---
|
|
|
|
.../surface/surface_aggregator_tabletsw.c | 57 +++++++++++++++++++
|
|
|
|
1 file changed, 57 insertions(+)
|
|
|
|
|
|
|
|
diff --git a/drivers/platform/surface/surface_aggregator_tabletsw.c b/drivers/platform/surface/surface_aggregator_tabletsw.c
|
2023-06-17 22:08:32 +00:00
|
|
|
index f9a58db6afde..4a029f5db20a 100644
|
2023-05-11 12:10:25 +00:00
|
|
|
--- a/drivers/platform/surface/surface_aggregator_tabletsw.c
|
|
|
|
+++ b/drivers/platform/surface/surface_aggregator_tabletsw.c
|
2023-06-17 22:08:32 +00:00
|
|
|
@@ -330,9 +330,18 @@ MODULE_PARM_DESC(tablet_mode_in_slate_state, "Enable tablet mode in slate device
|
2023-05-11 12:10:25 +00:00
|
|
|
#define SSAM_POS_MAX_SOURCES 4
|
|
|
|
|
|
|
|
enum ssam_pos_source_id {
|
|
|
|
+ SSAM_POS_SOURCE_COVER = 0x00,
|
|
|
|
SSAM_POS_SOURCE_SLS = 0x03,
|
|
|
|
};
|
|
|
|
|
|
|
|
+enum ssam_pos_state_cover {
|
|
|
|
+ SSAM_POS_COVER_DISCONNECTED = 0x01,
|
|
|
|
+ SSAM_POS_COVER_CLOSED = 0x02,
|
|
|
|
+ SSAM_POS_COVER_LAPTOP = 0x03,
|
|
|
|
+ SSAM_POS_COVER_FOLDED_CANVAS = 0x04,
|
|
|
|
+ SSAM_POS_COVER_FOLDED_BACK = 0x05,
|
|
|
|
+};
|
|
|
|
+
|
|
|
|
enum ssam_pos_state_sls {
|
|
|
|
SSAM_POS_SLS_LID_CLOSED = 0x00,
|
|
|
|
SSAM_POS_SLS_LAPTOP = 0x01,
|
2023-06-17 22:08:32 +00:00
|
|
|
@@ -345,6 +354,30 @@ struct ssam_sources_list {
|
2023-05-11 12:10:25 +00:00
|
|
|
__le32 id[SSAM_POS_MAX_SOURCES];
|
|
|
|
} __packed;
|
|
|
|
|
|
|
|
+static const char *ssam_pos_state_name_cover(struct ssam_tablet_sw *sw, u32 state)
|
|
|
|
+{
|
|
|
|
+ switch (state) {
|
|
|
|
+ case SSAM_POS_COVER_DISCONNECTED:
|
|
|
|
+ return "disconnected";
|
|
|
|
+
|
|
|
|
+ case SSAM_POS_COVER_CLOSED:
|
|
|
|
+ return "closed";
|
|
|
|
+
|
|
|
|
+ case SSAM_POS_COVER_LAPTOP:
|
|
|
|
+ return "laptop";
|
|
|
|
+
|
|
|
|
+ case SSAM_POS_COVER_FOLDED_CANVAS:
|
|
|
|
+ return "folded-canvas";
|
|
|
|
+
|
|
|
|
+ case SSAM_POS_COVER_FOLDED_BACK:
|
|
|
|
+ return "folded-back";
|
|
|
|
+
|
|
|
|
+ default:
|
|
|
|
+ dev_warn(&sw->sdev->dev, "unknown device posture for type-cover: %u\n", state);
|
|
|
|
+ return "<unknown>";
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
static const char *ssam_pos_state_name_sls(struct ssam_tablet_sw *sw, u32 state)
|
|
|
|
{
|
|
|
|
switch (state) {
|
2023-06-17 22:08:32 +00:00
|
|
|
@@ -370,6 +403,9 @@ static const char *ssam_pos_state_name(struct ssam_tablet_sw *sw,
|
2023-05-11 12:10:25 +00:00
|
|
|
const struct ssam_tablet_sw_state *state)
|
|
|
|
{
|
|
|
|
switch (state->source) {
|
|
|
|
+ case SSAM_POS_SOURCE_COVER:
|
|
|
|
+ return ssam_pos_state_name_cover(sw, state->state);
|
|
|
|
+
|
|
|
|
case SSAM_POS_SOURCE_SLS:
|
|
|
|
return ssam_pos_state_name_sls(sw, state->state);
|
|
|
|
|
2023-06-17 22:08:32 +00:00
|
|
|
@@ -379,6 +415,24 @@ static const char *ssam_pos_state_name(struct ssam_tablet_sw *sw,
|
2023-05-11 12:10:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
+static bool ssam_pos_state_is_tablet_mode_cover(struct ssam_tablet_sw *sw, u32 state)
|
|
|
|
+{
|
|
|
|
+ switch (state) {
|
|
|
|
+ case SSAM_POS_COVER_DISCONNECTED:
|
|
|
|
+ case SSAM_POS_COVER_FOLDED_CANVAS:
|
|
|
|
+ case SSAM_POS_COVER_FOLDED_BACK:
|
|
|
|
+ return true;
|
|
|
|
+
|
|
|
|
+ case SSAM_POS_COVER_CLOSED:
|
|
|
|
+ case SSAM_POS_COVER_LAPTOP:
|
|
|
|
+ return false;
|
|
|
|
+
|
|
|
|
+ default:
|
|
|
|
+ dev_warn(&sw->sdev->dev, "unknown device posture for type-cover: %u\n", state);
|
|
|
|
+ return true;
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
static bool ssam_pos_state_is_tablet_mode_sls(struct ssam_tablet_sw *sw, u32 state)
|
|
|
|
{
|
|
|
|
switch (state) {
|
2023-06-17 22:08:32 +00:00
|
|
|
@@ -402,6 +456,9 @@ static bool ssam_pos_state_is_tablet_mode(struct ssam_tablet_sw *sw,
|
2023-05-11 12:10:25 +00:00
|
|
|
const struct ssam_tablet_sw_state *state)
|
|
|
|
{
|
|
|
|
switch (state->source) {
|
|
|
|
+ case SSAM_POS_SOURCE_COVER:
|
|
|
|
+ return ssam_pos_state_is_tablet_mode_cover(sw, state->state);
|
|
|
|
+
|
|
|
|
case SSAM_POS_SOURCE_SLS:
|
|
|
|
return ssam_pos_state_is_tablet_mode_sls(sw, state->state);
|
|
|
|
|
|
|
|
--
|
2023-06-14 10:39:33 +00:00
|
|
|
2.41.0
|
2023-05-11 12:10:25 +00:00
|
|
|
|
2023-07-22 15:29:40 +00:00
|
|
|
From 8d9dcc4d8219d5144be7af8e79f05e16fcb2d53f Mon Sep 17 00:00:00 2001
|
2023-05-11 12:10:25 +00:00
|
|
|
From: Maximilian Luz <luzmaximilian@gmail.com>
|
|
|
|
Date: Sun, 19 Feb 2023 23:41:18 +0100
|
|
|
|
Subject: [PATCH] platform/surface: aggregator_registry: Add support for
|
|
|
|
tablet-mode switch on Surface Pro 9
|
|
|
|
|
|
|
|
Add support for the POS-subsystem tablet-mode switch used on the Surface
|
|
|
|
Pro 9.
|
|
|
|
|
|
|
|
Signed-off-by: Maximilian Luz <luzmaximilian@gmail.com>
|
|
|
|
Patchset: surface-sam
|
|
|
|
---
|
|
|
|
drivers/platform/surface/surface_aggregator_registry.c | 2 +-
|
|
|
|
1 file changed, 1 insertion(+), 1 deletion(-)
|
|
|
|
|
|
|
|
diff --git a/drivers/platform/surface/surface_aggregator_registry.c b/drivers/platform/surface/surface_aggregator_registry.c
|
2023-06-02 09:43:07 +00:00
|
|
|
index 296f72d52e6a..0fe5be539652 100644
|
2023-05-11 12:10:25 +00:00
|
|
|
--- a/drivers/platform/surface/surface_aggregator_registry.c
|
|
|
|
+++ b/drivers/platform/surface/surface_aggregator_registry.c
|
|
|
|
@@ -305,7 +305,7 @@ static const struct software_node *ssam_node_group_sp9[] = {
|
|
|
|
&ssam_node_bat_ac,
|
|
|
|
&ssam_node_bat_main,
|
|
|
|
&ssam_node_tmp_pprof,
|
|
|
|
- /* TODO: Tablet mode switch (via POS subsystem) */
|
|
|
|
+ &ssam_node_pos_tablet_switch,
|
|
|
|
&ssam_node_hid_kip_keyboard,
|
|
|
|
&ssam_node_hid_kip_penstash,
|
|
|
|
&ssam_node_hid_kip_touchpad,
|
|
|
|
--
|
2023-06-14 10:39:33 +00:00
|
|
|
2.41.0
|
2023-05-11 12:10:25 +00:00
|
|
|
|
2023-07-22 15:29:40 +00:00
|
|
|
From fc78bd85c12b325e5635e9b9e66e9ec04784f2c6 Mon Sep 17 00:00:00 2001
|
2023-05-25 23:11:56 +00:00
|
|
|
From: Maximilian Luz <luzmaximilian@gmail.com>
|
|
|
|
Date: Thu, 18 May 2023 22:33:55 +0200
|
|
|
|
Subject: [PATCH] platform/surface: aggregator: Make to_ssam_device_driver()
|
|
|
|
respect const-ness
|
|
|
|
|
|
|
|
Make to_ssam_device_driver() a bit safer by replacing container_of()
|
|
|
|
with container_of_const() to respect the const-ness of the passed in
|
|
|
|
pointer, instead of silently discarding any const specifications.
|
|
|
|
|
|
|
|
Signed-off-by: Maximilian Luz <luzmaximilian@gmail.com>
|
|
|
|
Patchset: surface-sam
|
|
|
|
---
|
|
|
|
include/linux/surface_aggregator/device.h | 6 +-----
|
|
|
|
1 file changed, 1 insertion(+), 5 deletions(-)
|
|
|
|
|
|
|
|
diff --git a/include/linux/surface_aggregator/device.h b/include/linux/surface_aggregator/device.h
|
2023-06-02 09:43:07 +00:00
|
|
|
index df81043b9e71..42b249b4c24b 100644
|
2023-05-25 23:11:56 +00:00
|
|
|
--- a/include/linux/surface_aggregator/device.h
|
|
|
|
+++ b/include/linux/surface_aggregator/device.h
|
|
|
|
@@ -243,11 +243,7 @@ static inline bool is_ssam_device(struct device *d)
|
|
|
|
* Return: Returns the pointer to the &struct ssam_device_driver wrapping the
|
|
|
|
* given device driver @d.
|
|
|
|
*/
|
|
|
|
-static inline
|
|
|
|
-struct ssam_device_driver *to_ssam_device_driver(struct device_driver *d)
|
|
|
|
-{
|
|
|
|
- return container_of(d, struct ssam_device_driver, driver);
|
|
|
|
-}
|
|
|
|
+#define to_ssam_device_driver(d) container_of_const(d, struct ssam_device_driver, driver)
|
|
|
|
|
|
|
|
const struct ssam_device_id *ssam_device_id_match(const struct ssam_device_id *table,
|
|
|
|
const struct ssam_device_uid uid);
|
|
|
|
--
|
2023-06-14 10:39:33 +00:00
|
|
|
2.41.0
|
2023-05-25 23:11:56 +00:00
|
|
|
|
2023-07-22 15:29:40 +00:00
|
|
|
From 688b03f6428d89459d1281da26665a2da7efb817 Mon Sep 17 00:00:00 2001
|
2023-05-25 23:11:56 +00:00
|
|
|
From: Maximilian Luz <luzmaximilian@gmail.com>
|
|
|
|
Date: Thu, 18 May 2023 22:57:17 +0200
|
|
|
|
Subject: [PATCH] platform/surface: aggregator_tabletsw: Add support for book
|
|
|
|
mode in POS subsystem
|
|
|
|
|
|
|
|
Devices with a type-cover have an additional "book" mode, deactivating
|
|
|
|
type-cover input and turning off its backlight. This is currently
|
|
|
|
unsupported, leading to the warning
|
|
|
|
|
|
|
|
surface_aggregator_tablet_mode_switch 01:26:01:00:01: unknown device posture for type-cover: 6
|
|
|
|
|
|
|
|
Therefore, add support for this state and map it to enable tablet-mode.
|
|
|
|
|
|
|
|
Fixes: 37ff64cd81ff ("platform/surface: aggregator_tabletsw: Add support for Type-Cover posture source")
|
|
|
|
Signed-off-by: Maximilian Luz <luzmaximilian@gmail.com>
|
|
|
|
Patchset: surface-sam
|
|
|
|
---
|
|
|
|
drivers/platform/surface/surface_aggregator_tabletsw.c | 5 +++++
|
|
|
|
1 file changed, 5 insertions(+)
|
|
|
|
|
|
|
|
diff --git a/drivers/platform/surface/surface_aggregator_tabletsw.c b/drivers/platform/surface/surface_aggregator_tabletsw.c
|
2023-06-02 09:43:07 +00:00
|
|
|
index 4a029f5db20a..c0a1a5869246 100644
|
2023-05-25 23:11:56 +00:00
|
|
|
--- a/drivers/platform/surface/surface_aggregator_tabletsw.c
|
|
|
|
+++ b/drivers/platform/surface/surface_aggregator_tabletsw.c
|
|
|
|
@@ -340,6 +340,7 @@ enum ssam_pos_state_cover {
|
|
|
|
SSAM_POS_COVER_LAPTOP = 0x03,
|
|
|
|
SSAM_POS_COVER_FOLDED_CANVAS = 0x04,
|
|
|
|
SSAM_POS_COVER_FOLDED_BACK = 0x05,
|
|
|
|
+ SSAM_POS_COVER_BOOK = 0x06,
|
|
|
|
};
|
|
|
|
|
|
|
|
enum ssam_pos_state_sls {
|
|
|
|
@@ -372,6 +373,9 @@ static const char *ssam_pos_state_name_cover(struct ssam_tablet_sw *sw, u32 stat
|
|
|
|
case SSAM_POS_COVER_FOLDED_BACK:
|
|
|
|
return "folded-back";
|
|
|
|
|
|
|
|
+ case SSAM_POS_COVER_BOOK:
|
|
|
|
+ return "book";
|
|
|
|
+
|
|
|
|
default:
|
|
|
|
dev_warn(&sw->sdev->dev, "unknown device posture for type-cover: %u\n", state);
|
|
|
|
return "<unknown>";
|
|
|
|
@@ -421,6 +425,7 @@ static bool ssam_pos_state_is_tablet_mode_cover(struct ssam_tablet_sw *sw, u32 s
|
|
|
|
case SSAM_POS_COVER_DISCONNECTED:
|
|
|
|
case SSAM_POS_COVER_FOLDED_CANVAS:
|
|
|
|
case SSAM_POS_COVER_FOLDED_BACK:
|
|
|
|
+ case SSAM_POS_COVER_BOOK:
|
|
|
|
return true;
|
|
|
|
|
|
|
|
case SSAM_POS_COVER_CLOSED:
|
|
|
|
--
|
2023-06-14 10:39:33 +00:00
|
|
|
2.41.0
|
2023-05-25 23:11:56 +00:00
|
|
|
|