mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 0/2] HID: sony: fix RB4 PS5 guitar battery handling
@ 2026-12-01  2:07 Sanjay Govind
  2026-12-01  2:07 ` [PATCH 1/2] HID: sony: handle RB4 PS5 guitars that do not report a battery level Sanjay Govind
  2026-12-01  2:07 ` [PATCH 2/2] HID: sony: fix battery name clash between RB4 PS5 guitars Sanjay Govind
  0 siblings, 2 replies; 3+ messages in thread
From: Sanjay Govind @ 2026-12-01  2:07 UTC (permalink / raw)
  To: Jiri Kosina, Benjamin Tissoires, linux-input
  Cc: linux-kernel, Rosalie Wanders, Sanjay Govind

Fix two issues with the battery reporting of Rock Band 4 PS5 guitars:

- Guitars that do not report a battery level send a level of 0x0c,
  which is currently reported as a discharging battery at 100%. Report
  an unknown status instead, as SDL does.
- Every such guitar registers a battery with the same name, so with two
  of them connected, the second guitar fails to probe and is not usable.

Both were tested with a CRKD Gibson SG and a RedOctane Games Gibson
Kramer connected at the same time. Support for these guitars is added
in a separate series that is based on this one.

Sanjay Govind (2):
  HID: sony: handle RB4 PS5 guitars that do not report a battery level
  HID: sony: fix battery name clash between RB4 PS5 guitars

 drivers/hid/hid-sony.c | 32 ++++++++++++++++++++++++++------
 1 file changed, 26 insertions(+), 6 deletions(-)


base-commit: 720806515cb6921ab05caaa6f470f7054b56385e
-- 
2.56.1


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH 1/2] HID: sony: handle RB4 PS5 guitars that do not report a battery level
  2026-12-01  2:07 [PATCH 0/2] HID: sony: fix RB4 PS5 guitar battery handling Sanjay Govind
@ 2026-12-01  2:07 ` Sanjay Govind
  2026-12-01  2:07 ` [PATCH 2/2] HID: sony: fix battery name clash between RB4 PS5 guitars Sanjay Govind
  1 sibling, 0 replies; 3+ messages in thread
From: Sanjay Govind @ 2026-12-01  2:07 UTC (permalink / raw)
  To: Jiri Kosina, Benjamin Tissoires, linux-input
  Cc: linux-kernel, Rosalie Wanders, Sanjay Govind, stable

Rock Band 4 PS5 guitars report their battery state in byte 30 of the
input report, with the charging status in the high nibble and the
battery level, from 0 to 10, in the low nibble. A level of 0x0c means
that the guitar does not report its battery level, which is what the
CRKD Gibson SG and the RedOctane Games Gibson Kramer always send when
connected over USB. SDL handles this level the same way for PS5
controllers.

This is currently decoded as a discharging battery at 100%, as the
capacity is clamped. Report an unknown status instead whenever the
level is 0x0c. Keep the capacity at 100% so that this does not cause
low battery warnings.

Fixes: e4bdeaef0351 ("HID: sony: add battery status support for Rock Band 4 PS5 guitars")
Cc: stable@vger.kernel.org
Signed-off-by: Sanjay Govind <sanjay.govind9@gmail.com>
---

Notes:
    Tested with a Gibson SG (3651:8600) and a Gibson Kramer (3958:5600),
    both in PS5 mode over USB, which always report 0x0c in byte 30. Before
    this patch their batteries were reported as discharging at 100%; with
    it, they are reported as unknown at 100%.
    
    Built hid-sony.ko with W=1 against the 7.3.6 headers, no warnings;
    checkpatch clean.
    
    The patch and changelog were written with the help of an AI coding
    assistant (Claude Opus 5.5).

 drivers/hid/hid-sony.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/drivers/hid/hid-sony.c b/drivers/hid/hid-sony.c
index 50f5ad6bbeb4..7a25f5acce88 100644
--- a/drivers/hid/hid-sony.c
+++ b/drivers/hid/hid-sony.c
@@ -1159,6 +1159,16 @@ static int rb4_ps5_guitar_raw_event(struct sony_sc *sc, u8 *rd, int size)
 	charging_status = (rd[30] >> 4) & 0x0F;
 	battery_data = rd[30] & 0x0F;
 
+	/*
+	 * A level of 0x0c means that the guitar does not report its battery
+	 * level. Keep the capacity at 100% to avoid low battery warnings.
+	 */
+	if (battery_data == 0x0c) {
+		battery_capacity = 100;
+		battery_status = POWER_SUPPLY_STATUS_UNKNOWN;
+		goto out;
+	}
+
 	switch (charging_status) {
 	case 0x0:
 		battery_capacity = min(battery_data * 10 + 5, 100);
@@ -1178,6 +1188,7 @@ static int rb4_ps5_guitar_raw_event(struct sony_sc *sc, u8 *rd, int size)
 		break;
 	}
 
+out:
 	scoped_guard(spinlock_irqsave, &sc->lock) {
 		sc->battery_capacity = battery_capacity;
 		sc->battery_status = battery_status;
-- 
2.56.1


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH 2/2] HID: sony: fix battery name clash between RB4 PS5 guitars
  2026-12-01  2:07 [PATCH 0/2] HID: sony: fix RB4 PS5 guitar battery handling Sanjay Govind
  2026-12-01  2:07 ` [PATCH 1/2] HID: sony: handle RB4 PS5 guitars that do not report a battery level Sanjay Govind
@ 2026-12-01  2:07 ` Sanjay Govind
  1 sibling, 0 replies; 3+ messages in thread
From: Sanjay Govind @ 2026-12-01  2:07 UTC (permalink / raw)
  To: Jiri Kosina, Benjamin Tissoires, linux-input
  Cc: linux-kernel, Rosalie Wanders, Sanjay Govind, stable

Rock Band 4 PS5 guitars register a power supply named after their MAC
address, but the driver never reads a MAC address for them, so every
such guitar registers "sony_controller_battery_00:00:00:00:00:00".

With two of these guitars connected, registering the battery of the
second one fails, and as a battery registration failure aborts
sony_input_configured(), the second guitar is not usable at all:

  sysfs: cannot create duplicate filename '/class/power_supply/sony_controller_battery_00:00:00:00:00:00'
  ...
  sony 0003:3958:5600.0222: Unable to register battery device
  sony 0003:3958:5600.0222: failed to claim input

Allocate a device ID for these guitars, and append it to the battery
name when the MAC address is unknown.

Fixes: e4bdeaef0351 ("HID: sony: add battery status support for Rock Band 4 PS5 guitars")
Cc: stable@vger.kernel.org
Signed-off-by: Sanjay Govind <sanjay.govind9@gmail.com>
---

Notes:
    Tested with a Gibson SG (3651:8600) and a Gibson Kramer (3958:5600),
    both in PS5 mode over USB and connected at the same time. Without this
    patch, the guitar connected second fails to register its battery, with
    the sysfs warning above, and has no input device. With it, both guitars
    are usable and their batteries are registered as
    sony_controller_battery_00:00:00:00:00:00_0 and _1.
    
    Built hid-sony.ko with W=1 against the 7.3.6 headers, no warnings;
    checkpatch clean.
    
    The patch and changelog were written with the help of an AI coding
    assistant (Claude Opus 5.5).

 drivers/hid/hid-sony.c | 21 +++++++++++++++------
 1 file changed, 15 insertions(+), 6 deletions(-)

diff --git a/drivers/hid/hid-sony.c b/drivers/hid/hid-sony.c
index 7a25f5acce88..1f1152575ae4 100644
--- a/drivers/hid/hid-sony.c
+++ b/drivers/hid/hid-sony.c
@@ -31,6 +31,7 @@
 
 #include <linux/cleanup.h>
 #include <linux/device.h>
+#include <linux/etherdevice.h>
 #include <linux/hid.h>
 #include <linux/module.h>
 #include <linux/slab.h>
@@ -1906,13 +1907,21 @@ static int sony_battery_get_property(struct power_supply *psy,
 
 static int sony_battery_probe(struct sony_sc *sc, int append_dev_id)
 {
-	const char *battery_str_fmt = append_dev_id ?
-		"sony_controller_battery_%pMR_%i" :
-		"sony_controller_battery_%pMR";
 	struct power_supply_config psy_cfg = { .drv_data = sc, };
 	struct hid_device *hdev = sc->hdev;
+	const char *battery_str_fmt;
 	int ret;
 
+	/*
+	 * Devices without a MAC address, such as Rock Band 4 PS5 guitars,
+	 * would all get the same name, so use the device ID to tell them
+	 * apart.
+	 */
+	if (append_dev_id || is_zero_ether_addr(sc->mac_address))
+		battery_str_fmt = "sony_controller_battery_%pMR_%i";
+	else
+		battery_str_fmt = "sony_controller_battery_%pMR";
+
 	/*
 	 * Set the default battery level to 100% to avoid low battery warnings
 	 * if the battery is polled before the first device report is received.
@@ -2085,10 +2094,10 @@ static int sony_set_device_id(struct sony_sc *sc)
 	int ret;
 
 	/*
-	 * Only Sixaxis controllers get an id.
-	 * All others are set to -1.
+	 * Only Sixaxis controllers, and Rock Band 4 PS5 guitars which need it
+	 * to name their battery, get an id. All others are set to -1.
 	 */
-	if (sc->quirks & SIXAXIS_CONTROLLER) {
+	if (sc->quirks & (SIXAXIS_CONTROLLER | RB4_GUITAR_PS5)) {
 		ret = ida_alloc(&sony_device_id_allocator, GFP_KERNEL);
 		if (ret < 0) {
 			sc->device_id = -1;
-- 
2.56.1


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-12-01  2:08 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-12-01  2:07 [PATCH 0/2] HID: sony: fix RB4 PS5 guitar battery handling Sanjay Govind
2026-12-01  2:07 ` [PATCH 1/2] HID: sony: handle RB4 PS5 guitars that do not report a battery level Sanjay Govind
2026-12-01  2:07 ` [PATCH 2/2] HID: sony: fix battery name clash between RB4 PS5 guitars Sanjay Govind

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®