Message ID | 20250526-dualsense-hid-jack-v1-9-a65fee4a60cc@collabora.com |
---|---|
State | New |
Headers | show |
Series | HID: playstation: Add support for audio jack handling on DualSense | expand |
Hi Christian, At the time I didn't document all parts of the HID report as not everything was needed. When adding in the audio stuff, let's call this one by its official name. There are officially 3 bytes of status, so the correct thing is to technically make it a 3 byte array of status. The official register names contain DS_STATUS0_.., DS_STATUS1_.., etcetera in the name, so I would like to keep things aligned with our datasheets. Thanks, Roderick On Mon, May 26, 2025 at 5:54 AM Cristian Ciocaltea <cristian.ciocaltea@collabora.com> wrote: > > The name of the 'status' member of struct dualsense_input_report is too > generic, since it is only used to provide battery data. > > In preparation to support handling additional (non-battery) status > information and avoid ambiguity, rename the field to status_battery. > For consistency, also rename the related DS_STATUS_* bitfield macros. > > Signed-off-by: Cristian Ciocaltea <cristian.ciocaltea@collabora.com> > --- > drivers/hid/hid-playstation.c | 15 ++++++++------- > 1 file changed, 8 insertions(+), 7 deletions(-) > > diff --git a/drivers/hid/hid-playstation.c b/drivers/hid/hid-playstation.c > index 937b14679c8b17c5d3d245eae1cc4e0e56dadb71..b7777d3230b2fe277a4a2217ef6b1eff9cfad182 100644 > --- a/drivers/hid/hid-playstation.c > +++ b/drivers/hid/hid-playstation.c > @@ -112,10 +112,10 @@ 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) > -#define DS_STATUS_CHARGING_SHIFT 4 > +/* Battery status field of DualSense input report. */ > +#define DS_STATUS_BATTERY_CAPACITY GENMASK(3, 0) > +#define DS_STATUS_BATTERY_CHARGING GENMASK(7, 4) > +#define DS_STATUS_BATTERY_CHARGING_SHIFT 4 > > /* Feature version from DualSense Firmware Info report. */ > #define DS_FEATURE_VERSION_MINOR GENMASK(7, 0) > @@ -236,7 +236,7 @@ struct dualsense_input_report { > struct dualsense_touch_point points[2]; > > u8 reserved3[12]; > - u8 status; > + u8 status_battery; > u8 reserved4[10]; > } __packed; > /* Common input report size shared equals the size of the USB report minus 1 byte for ReportID. */ > @@ -1462,8 +1462,9 @@ 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 = ds_report->status & DS_STATUS_BATTERY_CAPACITY; > - charging_status = (ds_report->status & DS_STATUS_CHARGING) >> DS_STATUS_CHARGING_SHIFT; > + battery_data = ds_report->status_battery & DS_STATUS_BATTERY_CAPACITY; > + charging_status = ds_report->status_battery & DS_STATUS_BATTERY_CHARGING; > + charging_status >>= DS_STATUS_BATTERY_CHARGING_SHIFT; > > switch (charging_status) { > case 0x0: > > -- > 2.49.0 > >
Hi Roderick, On 6/10/25 7:40 AM, Roderick Colenbrander wrote: > Hi Christian, > > At the time I didn't document all parts of the HID report as not > everything was needed. When adding in the audio stuff, let's call this > one by its official name. There are officially 3 bytes of status, so > the correct thing is to technically make it a 3 byte array of status. > The official register names contain DS_STATUS0_.., DS_STATUS1_.., > etcetera in the name, so I would like to keep things aligned with our > datasheets. I don't have access to the datasheet, so thanks for pointing this out! Will be handled v2. Thanks, Cristian
diff --git a/drivers/hid/hid-playstation.c b/drivers/hid/hid-playstation.c index 937b14679c8b17c5d3d245eae1cc4e0e56dadb71..b7777d3230b2fe277a4a2217ef6b1eff9cfad182 100644 --- a/drivers/hid/hid-playstation.c +++ b/drivers/hid/hid-playstation.c @@ -112,10 +112,10 @@ 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) -#define DS_STATUS_CHARGING_SHIFT 4 +/* Battery status field of DualSense input report. */ +#define DS_STATUS_BATTERY_CAPACITY GENMASK(3, 0) +#define DS_STATUS_BATTERY_CHARGING GENMASK(7, 4) +#define DS_STATUS_BATTERY_CHARGING_SHIFT 4 /* Feature version from DualSense Firmware Info report. */ #define DS_FEATURE_VERSION_MINOR GENMASK(7, 0) @@ -236,7 +236,7 @@ struct dualsense_input_report { struct dualsense_touch_point points[2]; u8 reserved3[12]; - u8 status; + u8 status_battery; u8 reserved4[10]; } __packed; /* Common input report size shared equals the size of the USB report minus 1 byte for ReportID. */ @@ -1462,8 +1462,9 @@ 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 = ds_report->status & DS_STATUS_BATTERY_CAPACITY; - charging_status = (ds_report->status & DS_STATUS_CHARGING) >> DS_STATUS_CHARGING_SHIFT; + battery_data = ds_report->status_battery & DS_STATUS_BATTERY_CAPACITY; + charging_status = ds_report->status_battery & DS_STATUS_BATTERY_CHARGING; + charging_status >>= DS_STATUS_BATTERY_CHARGING_SHIFT; switch (charging_status) { case 0x0:
The name of the 'status' member of struct dualsense_input_report is too generic, since it is only used to provide battery data. In preparation to support handling additional (non-battery) status information and avoid ambiguity, rename the field to status_battery. For consistency, also rename the related DS_STATUS_* bitfield macros. Signed-off-by: Cristian Ciocaltea <cristian.ciocaltea@collabora.com> --- drivers/hid/hid-playstation.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-)