-
Notifications
You must be signed in to change notification settings - Fork 1
/
0019-HID-amd_sfh-Add-keyguard-for-ASUS-ROG-X13-tablet.patch
174 lines (160 loc) · 6.26 KB
/
0019-HID-amd_sfh-Add-keyguard-for-ASUS-ROG-X13-tablet.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
From 802dfc514194e5459397f513b202031228b3315a Mon Sep 17 00:00:00 2001
From: "Luke D. Jones" <[email protected]>
Date: Fri, 26 Aug 2022 12:25:12 +1200
Subject: [PATCH 19/19] HID: amd_sfh: Add keyguard for ASUS ROG X13 tablet
Add support for ROG X13 Flow 2-in-1 to disable the keyboard when
the lid is flipped.
Signed-off-by: Luke D. Jones <[email protected]>
---
drivers/hid/amd-sfh-hid/amd_sfh_pcie.c | 4 +++
drivers/hid/amd-sfh-hid/amd_sfh_pcie.h | 1 +
.../hid_descriptor/amd_sfh_hid_desc.c | 27 +++++++++++++++++++
.../hid_descriptor/amd_sfh_hid_desc.h | 8 ++++++
.../hid_descriptor/amd_sfh_hid_report_desc.h | 19 +++++++++++++
5 files changed, 59 insertions(+)
diff --git a/drivers/hid/amd-sfh-hid/amd_sfh_pcie.c b/drivers/hid/amd-sfh-hid/amd_sfh_pcie.c
index 4b90c86ee5f8..0f4db2ce076e 100644
--- a/drivers/hid/amd-sfh-hid/amd_sfh_pcie.c
+++ b/drivers/hid/amd-sfh-hid/amd_sfh_pcie.c
@@ -27,6 +27,7 @@
#define ACEL_EN BIT(0)
#define GYRO_EN BIT(1)
#define MAGNO_EN BIT(2)
+#define KBGUARD_EN BIT(15)
#define HPD_EN BIT(16)
#define ALS_EN BIT(19)
@@ -233,6 +234,9 @@ int amd_mp2_get_sensor_num(struct amd_mp2_dev *privdata, u8 *sensor_id)
if (HPD_EN & activestatus)
sensor_id[num_of_sensors++] = HPD_IDX;
+ if (KBGUARD_EN & activestatus)
+ sensor_id[num_of_sensors++] = KBGUARD_IDX;
+
return num_of_sensors;
}
diff --git a/drivers/hid/amd-sfh-hid/amd_sfh_pcie.h b/drivers/hid/amd-sfh-hid/amd_sfh_pcie.h
index dfb7cabd82ef..5fa15eed43f3 100644
--- a/drivers/hid/amd-sfh-hid/amd_sfh_pcie.h
+++ b/drivers/hid/amd-sfh-hid/amd_sfh_pcie.h
@@ -23,6 +23,7 @@
#define V2_STATUS 0x2
#define HPD_IDX 16
+#define KBGUARD_IDX 15
#define SENSOR_DISCOVERY_STATUS_MASK GENMASK(5, 3)
#define SENSOR_DISCOVERY_STATUS_SHIFT 3
diff --git a/drivers/hid/amd-sfh-hid/hid_descriptor/amd_sfh_hid_desc.c b/drivers/hid/amd-sfh-hid/hid_descriptor/amd_sfh_hid_desc.c
index f9a8c02d5a7b..06487eb75dc8 100644
--- a/drivers/hid/amd-sfh-hid/hid_descriptor/amd_sfh_hid_desc.c
+++ b/drivers/hid/amd-sfh-hid/hid_descriptor/amd_sfh_hid_desc.c
@@ -57,6 +57,11 @@ static int get_report_descriptor(int sensor_idx, u8 *rep_desc)
memcpy(rep_desc, hpd_report_descriptor,
sizeof(hpd_report_descriptor));
break;
+ case KBGUARD_IDX: /* kbguard ? */
+ memset(rep_desc, 0, sizeof(kbguard_report_descriptor));
+ memcpy(rep_desc, kbguard_report_descriptor,
+ sizeof(kbguard_report_descriptor));
+ break;
default:
break;
}
@@ -116,6 +121,16 @@ static u32 get_descr_sz(int sensor_idx, int descriptor_name)
return sizeof(struct hpd_feature_report);
}
break;
+ case KBGUARD_IDX:
+ switch (descriptor_name) {
+ case descr_size:
+ return sizeof(kbguard_report_descriptor);
+ case input_size:
+ return sizeof(struct kbguard_input_report);
+ case feature_size:
+ return sizeof(struct kbguard_feature_report);
+ }
+ break;
default:
break;
@@ -139,6 +154,7 @@ static u8 get_feature_report(int sensor_idx, int report_id, u8 *feature_report)
struct gyro_feature_report gyro_feature;
struct magno_feature_report magno_feature;
struct hpd_feature_report hpd_feature;
+ struct kbguard_feature_report kbguard_feature;
struct als_feature_report als_feature;
u8 report_size = 0;
@@ -186,6 +202,11 @@ static u8 get_feature_report(int sensor_idx, int report_id, u8 *feature_report)
memcpy(feature_report, &hpd_feature, sizeof(hpd_feature));
report_size = sizeof(hpd_feature);
break;
+ case KBGUARD_IDX: /* auto disable keyboard when flip out */
+ get_common_features(&kbguard_feature.common_property, report_id);
+ memcpy(feature_report, &kbguard_feature, sizeof(kbguard_feature));
+ report_size = sizeof(kbguard_feature);
+ break;
default:
break;
@@ -211,6 +232,7 @@ static u8 get_input_report(u8 current_index, int sensor_idx, int report_id,
struct accel3_input_report acc_input;
struct gyro_input_report gyro_input;
struct hpd_input_report hpd_input;
+ struct kbguard_input_report kbguard_input;
struct als_input_report als_input;
struct hpd_status hpdstatus;
u8 report_size = 0;
@@ -263,6 +285,11 @@ static u8 get_input_report(u8 current_index, int sensor_idx, int report_id,
report_size = sizeof(hpd_input);
memcpy(input_report, &hpd_input, sizeof(hpd_input));
break;
+ case KBGUARD_IDX: /* kb guard */
+ get_common_inputs(&kbguard_input.common_property, report_id);
+ report_size = sizeof(kbguard_input);
+ memcpy(input_report, &kbguard_input, sizeof(kbguard_input));
+break;
default:
break;
}
diff --git a/drivers/hid/amd-sfh-hid/hid_descriptor/amd_sfh_hid_desc.h b/drivers/hid/amd-sfh-hid/hid_descriptor/amd_sfh_hid_desc.h
index ebd55675eb62..2f2ba9a0cfbc 100644
--- a/drivers/hid/amd-sfh-hid/hid_descriptor/amd_sfh_hid_desc.h
+++ b/drivers/hid/amd-sfh-hid/hid_descriptor/amd_sfh_hid_desc.h
@@ -111,4 +111,12 @@ struct hpd_input_report {
u8 human_presence;
} __packed;
+struct kbguard_feature_report {
+ struct common_feature_property common_property;
+} __packed;
+
+struct kbguard_input_report {
+ struct common_input_property common_property;
+} __packed;
+
#endif
diff --git a/drivers/hid/amd-sfh-hid/hid_descriptor/amd_sfh_hid_report_desc.h b/drivers/hid/amd-sfh-hid/hid_descriptor/amd_sfh_hid_report_desc.h
index 697f2791ea9c..7a62fcec2c73 100644
--- a/drivers/hid/amd-sfh-hid/hid_descriptor/amd_sfh_hid_report_desc.h
+++ b/drivers/hid/amd-sfh-hid/hid_descriptor/amd_sfh_hid_report_desc.h
@@ -644,6 +644,25 @@ static const u8 als_report_descriptor[] = {
0xC0 /* HID end collection */
};
+
+static const u8 kbguard_report_descriptor[] = {
+0x06, 0x43, 0xFF, // Usage Page (Vendor Defined 0xFF43)
+0x0A, 0x02, 0x02, // Usage (0x0202)
+0xA1, 0x01, // Collection (Application)
+0x85, 0x11, // Report ID (17)
+0x15, 0x00, // Logical Minimum (0)
+0x25, 0x01, // Logical Maximum (1)
+0x35, 0x00, // Physical Minimum (0)
+0x45, 0x01, // Physical Maximum (1)
+0x65, 0x00, // Unit (None)
+0x55, 0x00, // Unit Exponent (0)
+0x75, 0x01, // Report Size (1)
+0x95, 0x98, // Report Count (-104)
+0x81, 0x03, // Input (Const,Var,Abs,No Wrap,Linear,Preferred State,No Null Position)
+0x91, 0x03, // Output (Const,Var,Abs,No Wrap,Linear,Preferred State,No Null Position,Non-volatile)
+0xC1, 0x00, // End Collection
+};
+
/* BIOMETRIC PRESENCE*/
static const u8 hpd_report_descriptor[] = {
0x05, 0x20, /* Usage page */
--
2.37.2