From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.215.172 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796091002; b=kTwQlV4TA1OlJxxl1lwqOkdpD1O/S9ekDcABPRRtREOlbg0NOBtLEhoL8++yxIVNd0y6 r2wzLLzHx6y2udyZH5jH3YstfPdRENmTMQBvPK/GhfonVQAtKAFm0ClxZZca6pSuVYSRr i1pPf8VT1ZCBPgmj5oLBRqUzE/21U1P78057AVIXD6lazgDUZCqZRevkg7CilkNDBxZt4 +gp3u0Qkzh4AUXW9XqSsRz5BIIA+jwMP/xnOvj1kf+MfpMr1StRn5yrinxXDp+I4rVgO7 Ow6Su5iT5HbMZP/MH1cyBzpDQgX98kTkLPbCB9879+OR5Qm1L2/XTyxl04qGBhJwn1A== 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-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=PH9yQzrmFOF5ec/yDr2+Qb/WW6nXL1H1BI6WHj+TtZYdg8x0UdUPDtO/VT5lbm2Yt6Ca i7NWkRP4MSDAUenVLKXw0No3TcajwH5BYyB6GTxWNfc5eQzHCPgcnC6uK47m+PCvUJlPg aP3d3gOHfKOA5ntiVerFosaScTZCS716o+amgfcmfe65GedsjT9Kta2mG7k3egokOQGBN DiXslYM5iER7RHcpOndofIj80aR8kOlENeS+l11mO0Ey7sa5l1o6mMTBd3LLwhw+WEQqd HgZvoPBcdlF9+pxxh5mBgfdCVIMgcHNOludddRPGdutOXqQy1jTlfW/lUAI/npAdDug== 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.215.172 Received: from mail-pg1-f172.google.com (mail-pg1-f172.google.com [209.85.215.172]) (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 BFD04606A332 for ; Tue, 1 Dec 2026 02:10:01 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org BFD04606A332 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-pg1-f172.google.com with SMTP id 41be03b00d2f7-cd6acc50b8dso5608689a12.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=oIGGUyaXgilmbKjLock/2NZkQVnoUde0xFnrMn4HFjnqYxeEfVUH8gF/uwNOIDHcfn YiH3bhGzgCF5c83WygqhofzzEdMrxm8zfm5rNSfIx6k9yUx/qrCv49zVWBM6Wu4MKyeY nbEuxtWS3JX2SRXMtG77XvhwtVMPPSJ4615rFz/aEhHwx6wsFSWtBoSwU9CzysEVicfW 8IdwEcZoxqZOZ8ZyKYsn7B5K/axwgZthRySGknXjVfAZROM4wPgYNqLPUoR6h06Q2Ht3 2pUpO3CxvkPFeoF+9Wjhbyw8lxzREekGCzhNenCD44Xz4irXnDFXlbcCby4bSUgx+Srp TwNg== X-Gm-Message-State: APuU4Z8WI0weKT9uqJJiyUtrJ1US3NUss/WVOm7ztby1U2Adz/RosNMR CLKYN1xU+n44xWPMNs8tTvB94KSpr2T2eGlFetArNze/vKIO7+QK3jVEKfS3Cs81MOw= X-Gm-Gg: AZFdTZdeTwjU/n0GCrYnHIpMkfW1qy+lDvb4RguN83IpnlzYL7tr8rcwLYlud/858F6 f/taUVjODIpj/JLWTEJfMtS22pogxhQafN3eZHESqY90D64MUiq4uHhaBrlA8bGI5mEhfnE4fmG TLluGn6ZJKVE0SSe3pI693AR9y25s4e2JWRbsiOP5GCZFzQgjk6bUkPgkaXXg7oSd0BWnPhLAAR 08SFLG7ABCVTdhhTQ4U290y0BCyIxrUeVXYMNaHlnnFKiNunGe7XKY6etJS1eddPLmDHlLT436k A0Vs4jfrTI/1bPkHOE9fj+sqtUisYqHcL9BnnIUZuBBJ4ccupkv+KdjYz0CGuAyCV5GA5uXhuPs nWZLj2owo6qdteFkCRXOMkPl7dBnGvMJQAR3BbVQ1t6QTR1YqYu+g2ZtAxb65UtXWd9c1Z996L0 92Lz8a+yKbc2DtjZoQBYQikgnOSokW51UV84beZgkt8STdft1VW84s30GZ/d6eDet5ca67Lx6bi kDXq46XWsxrwsqKuhxDKXTuvuYm4IbneF/LynJDpa+J32oHHTh5iOrGyk2g6FS3421LZ+xHpUqM uFa9ZhAkUZr7eGrt/pTp6lLwVKgctcGPWLoZTGAg/Q8EDxDMaLAD64pYnclxGz2EWYaSpjaUBbd ghaTnruYeODtgg9uFeBAGTJcgdjKQz6MCOA/ktmBwxoSEf5yGY4RLlyuYLhhRnOfDpy/ZFrATTr 4cyCEMdWbfGUw= 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-kernel@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