Skip to content

Commit d7b744f

Browse files
cristiccJiri Kosina
authored andcommitted
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>
1 parent 400c6bb commit d7b744f

1 file changed

Lines changed: 7 additions & 7 deletions

File tree

drivers/hid/hid-playstation.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -112,9 +112,9 @@ struct ps_led_info {
112112
#define DS_BUTTONS2_TOUCHPAD BIT(1)
113113
#define DS_BUTTONS2_MIC_MUTE BIT(2)
114114

115-
/* Status field of DualSense input report. */
116-
#define DS_STATUS_BATTERY_CAPACITY GENMASK(3, 0)
117-
#define DS_STATUS_CHARGING GENMASK(7, 4)
115+
/* Battery status field of DualSense input report. */
116+
#define DS_STATUS0_BATTERY_CAPACITY GENMASK(3, 0)
117+
#define DS_STATUS0_CHARGING GENMASK(7, 4)
118118

119119
/* Feature version from DualSense Firmware Info report. */
120120
#define DS_FEATURE_VERSION_MINOR GENMASK(7, 0)
@@ -235,8 +235,8 @@ struct dualsense_input_report {
235235
struct dualsense_touch_point points[2];
236236

237237
u8 reserved3[12];
238-
u8 status;
239-
u8 reserved4[10];
238+
u8 status[3];
239+
u8 reserved4[8];
240240
} __packed;
241241
/* Common input report size shared equals the size of the USB report minus 1 byte for ReportID. */
242242
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
14611461
input_report_key(ds->touchpad, BTN_LEFT, ds_report->buttons[2] & DS_BUTTONS2_TOUCHPAD);
14621462
input_sync(ds->touchpad);
14631463

1464-
battery_data = FIELD_GET(DS_STATUS_BATTERY_CAPACITY, ds_report->status);
1465-
charging_status = FIELD_GET(DS_STATUS_CHARGING, ds_report->status);
1464+
battery_data = FIELD_GET(DS_STATUS0_BATTERY_CAPACITY, ds_report->status[0]);
1465+
charging_status = FIELD_GET(DS_STATUS0_CHARGING, ds_report->status[0]);
14661466

14671467
switch (charging_status) {
14681468
case 0x0:

0 commit comments

Comments
 (0)