From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.216.45 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796091002; b=1Np6guLtBDNTqu1zdhDY1ZYP28/8jkodGbmMo6fJPdv5Ocs1y8VEtn/RLF6i9HjMg6TP 037W83Pygkx/0BWiN5++otsRKb3mZK0iPqA3g36lvfSIvdOPbwe17c2kWhnBuaqekTlbI X3iRKJROfPiPgEEpHs/eW0G5UPhTYFZGcjmT3O68Q2YVZT/71bEB0G9syLpEqMX7/fo2Q s1x1mIRsW5i9k0Qbz6xaqsIhyRWul/DVE2y7TN0vTCv2RkgciBCVvkVu3uYz85PWv+Okh BaOz76wSXe48EPCPNeWKs8MDBVTZbYrz0Sq70iAzNO878WBLOeWL8qXeBerOb6Ilx5Q== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796091002; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: From:To:Cc:Subject:Date:Message-ID:X-Mailer:In-Reply-To:References: MIME-Version:Content-Transfer-Encoding; bh=B+6vS2QT5HUH7tNeE3AcmqjF4JbzUgTx7x6M+jJ3a7I=; b=fhMdNOm125mKCr2T22LWTN994DlGuUoXF08DBkBzKyEyRBXi8F5xfTxHCY6S3g3K36kd Wflsi6Z6CwWm4GkOvVGGz1/zgFh90v+zV4eY14QIPC/dOODGljOWKGRxWnuX8lgqRiBBO G+rIi3t+XRXJ0f2a4zbi790ZsIaKWLsDCHg04Icg+8qQq/qDZavUR+5Td8FdkYo+4XtyS DZXRiQglfPxKeqY3haPgpbQ8YlcKrJa1GwXjPGRBD6AJw53uKMz9z4MxW1VmoUrLl1lVY oBLGJpBmje10rvh8fynAlSmtvLZnxHg9p7kxf3Wr4Ir5p8s7WZa6f0s61FyY1zg5BnQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b="TWP/1xIl"; arc=none smtp.remote-ip=209.85.216.45 Received: from mail-pj1-f45.google.com (mail-pj1-f45.google.com [209.85.216.45]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B90F2606A336 for ; Tue, 1 Dec 2026 02:10:01 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org B90F2606A336 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=TWP/1xIl Received: by mail-pj1-f45.google.com with SMTP id 98e67ed59e1d1-3b405d8f1cfso5454687a91.3 for ; Mon, 30 Nov 2026 18:10:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796091001; x=1796695801; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=B+6vS2QT5HUH7tNeE3AcmqjF4JbzUgTx7x6M+jJ3a7I=; b=TWP/1xIlECYUtZooAd2tHVUFNVg2RT9rfiFDv34YbNelcCwsLKtYmqXh75QbxcmZzA V2JgOGpTC18LO6wR3Hd7cbneVn4vFtbDugKT0Rc979eGv4HAogHO/xQGHagOHXIlymMq 5jEwD46XWSzGM0Ptt7BigGGgkr/COEhiKfarjQU+NDrr6OoZz6esPlSCmrhhjHWcWHdG ztpriUR4YHLPmudM81eaEGrrk/JlqYEFkmoHYgMAJb1qj0OmoLDD7vSdCzy7tj7h05zN QznTqZnwD5mVQItkmVKaNzy06OFI60CziUAsFDDeokIUcZGKgN9kq0e/JOik6WKAlQYR 9agw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796091001; x=1796695801; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=B+6vS2QT5HUH7tNeE3AcmqjF4JbzUgTx7x6M+jJ3a7I=; b=nzHypQZEKGNOBV1FT6tcY1s3EbSsYtDrsTh54anPSDvofwSgeTKDWl48r/TWEAXAsE B7Wri6N/kKSsnxhFmoiSu4wAIrGFpW0LE/RNljGgrdvvvUqjSC+oEAKnBeeDYULYjuVw zKbEzVastqhUDoqbJCkY6GIadvgBwYOW/MI5bYYDjNKt1Y8gAton7F0NDh+9FU5uRHd6 7Mhb0RROoYXPgQRU7BNXJ9Gt951+o3e08GxjqWxt1zufFvn2/BOZS90cqenZqbjQ9Qhb SVmGNVZAaPmWNw8P/4y1kjUjNtOuDSN4fpQ/v6X8n9zuyZi0LVdswjvobqC7sb4Cm+5r eOag== X-Forwarded-Encrypted: i=1; AL+hErEiu1XqEKk9iSOfWYTzEo+AnsRagnQ0bi18MK5yZ1f2akI2F0Rk+GA+1mmnOjcPYT58eiqd26P4UAVIFA==@vger.kernel.org X-Gm-Message-State: APuU4Z/nVOUHeLjA3tOYh9ieDSI8ukPuRMpBXSjrhpiJw0dxRnHeADI/ a//8N1HNyQ9T9lcS3HCtU8ZeBqWhwKLhK6DTGzTdHEO2xWsPySlenDIN X-Gm-Gg: AZFdTZdXKBOxYd9LGWlkEHGgSkxr6oIiooEWUfaLbOe3/CtzuVapmuHyrimHL3aQHra n+tTDdeDcDfyCXLdq5rn5XG5gadn/rs1L22obqlBsZm7HrF/dVfwTg5UQUZF84zG6eFW0hFV/xd 7ON2AvgMyuXSMtLVb0M5vunpn8sfjP1Rct1cfMmSNOI2OOE6lutpBO3KsnazZlaLIgG6DQMB2U0 XwJhWA3IJmW7q/wmZq1yUHXbrr6BOf71s2cS6SYJuFupSZ1bGGQWTP8xJT0rYqUjOQfA7GEP9ax TN3Y4dzOGz0uoLDRuqtvTlV96FCl4o18EHBdWbA4QI6HYIjg7/FzTbTgLIRX27KZxlVChsXnkMc wgQyyn2rqsVctPSQZtDJh8zmw7i92r1yYhIL+OvWGUoX6KlFVRhI9dputok1kvVBYrx6WHEskD3 2X2Pq/U1EtNEAcrN+zYLEvT863pIDsqSLOThuZ69ZAS+F95PJNUlUbbb9kS0oXRJ3JXW6FwWuIh 7mCSPF+DDZ6P6cynHU0tB1K6n0iRjzc3r1R4CCB4En8bDGopvyOOR3kM8H86/HVKyKz69FxKtUa dWUr11xSn01zcNSDBrcLR+dyh2GuKdL95/QEDTogRFQmVW11B/1kYviM07EIZgqVTLe2PRKo+6M UHIlf1t4oPNoMnJqxIZv7XkXVjHOMw9cNi4G7/VbLcUwolOLZRvXKZTnWTLWNmL9PQ8D+6IedZK lVX9AqCxcKoeg= X-Received: by 2002:a17:90b:50:b0:3b0:b35e:b373 with SMTP id 98e67ed59e1d1-3b41c7c2378mr35791437a91.4.1796091001038; Mon, 30 Nov 2026 18:10:01 -0800 (PST) Received: from sanjays-pc.govzhome.govindz.co.nz ([139.180.95.49]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3b41ad0a34asm54705463a91.3.2026.11.30.18.09.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Nov 2026 18:10:00 -0800 (PST) From: Sanjay Govind To: Jiri Kosina , Benjamin Tissoires , linux-input@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Sanjay Govind Subject: [PATCH 4/4] HID: sony: report the battery of Rock Band 4 PS5 drums Date: Tue, 1 Dec 2026 15:09:23 +1300 Message-ID: <20261201020922.3552247-6-sanjay.govind9@gmail.com> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261201020922.3552247-2-sanjay.govind9@gmail.com> References: <20261201020922.3552247-2-sanjay.govind9@gmail.com> X-Mailing-List: linux-input@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Rock Band 4 PS5 drum kits report their battery state in byte 30 of their input report, encoded the same way as on Rock Band 4 PS5 guitars. The Stage Tour drum kit reports its battery level there, for example 0x19 (charging, level 9) when connected over USB. Move the decoding of this byte out of the PS5 guitar handler into a helper, and use it for PS5 drum kits as well. Like the guitars, these kits have no MAC address, so give them a device ID to keep the name of their battery unique. Signed-off-by: Sanjay Govind --- Notes: Depends on the series fixing the RB4 PS5 guitar battery reporting ("HID: sony: handle RB4 PS5 guitars that do not report a battery level" and "HID: sony: fix battery name clash between RB4 PS5 guitars"). Tested on a Stage Tour drum kit in PS5 mode (3958:d600): - Over USB, it reports 0x19 in byte 30 and its battery is reported as charging at 95%. - Through its wireless dongle, which uses the same USB ID, it reports 0x08 and its battery is reported as discharging at 85%. 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 | 67 ++++++++++++++++++++++++------------------ 1 file changed, 38 insertions(+), 29 deletions(-) diff --git a/drivers/hid/hid-sony.c b/drivers/hid/hid-sony.c index 4e68eb11c418..55662d163f57 100644 --- a/drivers/hid/hid-sony.c +++ b/drivers/hid/hid-sony.c @@ -82,7 +82,7 @@ #define SONY_LED_SUPPORT (SIXAXIS_CONTROLLER | BUZZ_CONTROLLER |\ MOTION_CONTROLLER | NAVIGATION_CONTROLLER) #define SONY_BATTERY_SUPPORT (SIXAXIS_CONTROLLER | MOTION_CONTROLLER_BT | NAVIGATION_CONTROLLER |\ - RB4_GUITAR_PS5) + RB4_GUITAR_PS5 | RB4_DRUMS_PS5) #define SONY_FF_SUPPORT (SIXAXIS_CONTROLLER | MOTION_CONTROLLER) #define SONY_BT_DEVICE (SIXAXIS_CONTROLLER_BT | MOTION_CONTROLLER_BT | NAVIGATION_CONTROLLER_BT) #define NSG_MRXU_REMOTE (NSG_MR5U_REMOTE_BT | NSG_MR7U_REMOTE_BT) @@ -1165,38 +1165,24 @@ static int rb4_ps4_guitar_raw_event(struct sony_sc *sc, u8 *rd, int size) return 0; } -static int rb4_ps5_guitar_raw_event(struct sony_sc *sc, u8 *rd, int size) +/* + * Rock Band 4 PS5 instruments report the battery status and level at byte 30 + * of their input report. + */ +static void rb4_ps5_parse_battery(struct sony_sc *sc, u8 data) { u8 charging_status; u8 battery_data; u8 battery_capacity; u8 battery_status; - if (unlikely(size != 64 || rd[0] != 0x01)) - return 0; - - /* - * Rock Band 4 PS5 guitars have whammy and - * tilt functionality, they're located at - * byte 41 and 42 respectively. - * - * We will map these values to the triggers - * because the guitars don't have anything - * mapped there. - */ - input_report_abs(sc->input_dev, ABS_Z, rd[41]); - input_report_abs(sc->input_dev, ABS_RZ, rd[42]); - - /* - * Rock Band 4 PS5 guitars also report the - * battery status and level at byte 30. - */ - charging_status = (rd[30] >> 4) & 0x0F; - battery_data = rd[30] & 0x0F; + charging_status = (data >> 4) & 0x0F; + battery_data = data & 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. + * A level of 0x0c means that the instrument does not report its + * battery level. Keep the capacity at 100% to avoid low battery + * warnings. */ if (battery_data == 0x0c) { battery_capacity = 100; @@ -1228,6 +1214,26 @@ static int rb4_ps5_guitar_raw_event(struct sony_sc *sc, u8 *rd, int size) sc->battery_capacity = battery_capacity; sc->battery_status = battery_status; } +} + +static int rb4_ps5_guitar_raw_event(struct sony_sc *sc, u8 *rd, int size) +{ + if (unlikely(size != 64 || rd[0] != 0x01)) + return 0; + + /* + * Rock Band 4 PS5 guitars have whammy and + * tilt functionality, they're located at + * byte 41 and 42 respectively. + * + * We will map these values to the triggers + * because the guitars don't have anything + * mapped there. + */ + input_report_abs(sc->input_dev, ABS_Z, rd[41]); + input_report_abs(sc->input_dev, ABS_RZ, rd[42]); + + rb4_ps5_parse_battery(sc, rd[30]); input_sync(sc->input_dev); return 0; @@ -1267,6 +1273,9 @@ static int rb4_drums_raw_event(struct sony_sc *sc, u8 *rd, int size) input_report_abs(input, rb4_drums_velocity_absmap[i], rd[velocity_offset + i]); + if (sc->quirks & RB4_DRUMS_PS5) + rb4_ps5_parse_battery(sc, rd[30]); + /* * hid-input syncs these events together with the buttons of the same * report, so that each hit arrives as a single frame. @@ -2005,7 +2014,7 @@ static int sony_battery_probe(struct sony_sc *sc, int append_dev_id) int ret; /* - * Devices without a MAC address, such as Rock Band 4 PS5 guitars, + * Devices without a MAC address, such as Rock Band 4 PS5 instruments, * would all get the same name, so use the device ID to tell them * apart. */ @@ -2186,10 +2195,10 @@ static int sony_set_device_id(struct sony_sc *sc) int ret; /* - * 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. + * Only Sixaxis controllers, and Rock Band 4 PS5 instruments which need + * it to name their battery, get an id. All others are set to -1. */ - if (sc->quirks & (SIXAXIS_CONTROLLER | RB4_GUITAR_PS5)) { + if (sc->quirks & (SIXAXIS_CONTROLLER | RB4_GUITAR_PS5 | RB4_DRUMS_PS5)) { ret = ida_alloc(&sony_device_id_allocator, GFP_KERNEL); if (ret < 0) { sc->device_id = -1; -- 2.56.1