summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCristian Ciocaltea <cristian.ciocaltea@collabora.com>2025-06-25 00:56:53 +0300
committerJiri Kosina <jkosina@suse.com>2025-09-17 11:33:43 +0200
commitd7b744fa977b4c402c25ba723b4981a8420ad15a (patch)
tree93e38e6c2e16c94e80887c08a673edcea395b40e
parent400c6bbc7b48a011c18c765cd1fbb396113e2f63 (diff)
HID: playstation: Redefine DualSense input report status field
The 'status' member of struct dualsense_input_report is currently used to store just the battery data, despite the fact that hardware is capable to report two extra bytes of status information. In preparation to make use of some of the additional data, redefine the field type as a 3-byte array. Moreover, to preserve consistency with the related DS_STATUS[0..2]_* registers in datasheet, rename DS_STATUS_* bitfield macros accordingly. Signed-off-by: Cristian Ciocaltea <cristian.ciocaltea@collabora.com> Reviewed-by: Benjamin Tissoires <bentiss@kernel.org> Tested-by: Benjamin Tissoires <bentiss@kernel.org> Signed-off-by: Jiri Kosina <jkosina@suse.com>
-rw-r--r--drivers/hid/hid-playstation.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/drivers/hid/hid-playstation.c b/drivers/hid/hid-playstation.c
index 6e3132418f2e..f523ca989a2f 100644
--- a/drivers/hid/hid-playstation.c
+++ b/drivers/hid/hid-playstation.c
@@ -112,9 +112,9 @@ struct ps_led_info {
#define DS_BUTTONS2_TOUCHPAD BIT(1)
#define DS_BUTTONS2_MIC_MUTE BIT(2)
-/* Status field of DualSense input report. */
-#define DS_STATUS_BATTERY_CAPACITY GENMASK(3, 0)
-#define DS_STATUS_CHARGING GENMASK(7, 4)
+/* Battery status field of DualSense input report. */
+#define DS_STATUS0_BATTERY_CAPACITY GENMASK(3, 0)
+#define DS_STATUS0_CHARGING GENMASK(7, 4)
/* Feature version from DualSense Firmware Info report. */
#define DS_FEATURE_VERSION_MINOR GENMASK(7, 0)
@@ -235,8 +235,8 @@ struct dualsense_input_report {
struct dualsense_touch_point points[2];
u8 reserved3[12];
- u8 status;
- u8 reserved4[10];
+ u8 status[3];
+ u8 reserved4[8];
} __packed;
/* Common input report size shared equals the size of the USB report minus 1 byte for ReportID. */
static_assert(sizeof(struct dualsense_input_report) == DS_INPUT_REPORT_USB_SIZE - 1);
@@ -1461,8 +1461,8 @@ static int dualsense_parse_report(struct ps_device *ps_dev, struct hid_report *r
input_report_key(ds->touchpad, BTN_LEFT, ds_report->buttons[2] & DS_BUTTONS2_TOUCHPAD);
input_sync(ds->touchpad);
- battery_data = FIELD_GET(DS_STATUS_BATTERY_CAPACITY, ds_report->status);
- charging_status = FIELD_GET(DS_STATUS_CHARGING, ds_report->status);
+ battery_data = FIELD_GET(DS_STATUS0_BATTERY_CAPACITY, ds_report->status[0]);
+ charging_status = FIELD_GET(DS_STATUS0_CHARGING, ds_report->status[0]);
switch (charging_status) {
case 0x0: