[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <pr3w6zp5hoza27fncktfj3qx3wp2nhdglbx46fbfx6swm4772d@7hg7a6dxom7p>
Date: Thu, 20 Nov 2025 12:05:08 +0100
From: Benjamin Tissoires <bentiss@...nel.org>
To: Lucas Zampieri <lzampier@...hat.com>
Cc: linux-input@...r.kernel.org, linux-kernel@...r.kernel.org,
Jiri Kosina <jikos@...nel.org>, Sebastian Reichel <sre@...nel.org>,
Bastien Nocera <hadess@...ess.net>, linux-pm@...r.kernel.org
Subject: Re: [PATCH v4 0/1] HID: Add support for multiple batteries per device
On Nov 20 2025, Lucas Zampieri wrote:
> This series adds support for HID devices with multiple batteries.
>
> Currently, the HID battery reporting subsystem only supports one battery per
> device. There are several devices with multiple batteries that would benefit
> from this support:
> - Gaming headsets with batteries in both the headset and charging dock
> - Wireless earbuds with per-earbud batteries plus charging case
> - Split keyboards with per-side batteries
>
> ## Proposed Solution
>
> This series introduces struct hid_battery to encapsulate individual battery
> state, replaces the old battery fields with a list-based approach, and adds
> support for multiple batteries tracked within struct hid_device. Batteries
> are identified by report ID. The implementation is fully backwards compatible
> with single-battery devices through a helper function.
>
> ## Testing
>
> Tested with split keyboard hardware (Dactyl 5x6) using custom ZMK firmware
> that implements per-side HID battery reporting. Each battery (left and right
> keyboard halves) reports independently through the power supply interface with
> distinct report IDs (0x05 and 0x06).
>
> Test firmware available on my personal fork at:
> https://github.com/zampierilucas/zmk/tree/feat/individual-hid-battery-reporting
> If this series gets merged, these changes will be proposed to upstream ZMK.
>
> HID descriptor and recording captured with hid-recorder:
>
> D: 0
> R: 162 05 01 09 06 a1 01 85 01 05 07 19 e0 29 e7 15 00 25 01 75 01 95 08 81 02 05 07 75 08 95 01 81 03 05 07 15 00 25 01 19 00 29 67 75 01 95 68 81 02 c0 05 0c 09 01 a1 01 85 02 05 0c 15 00 26 ff 0f 19 00 2a ff 0f 75 10 95 06 81 00 c0 05 84 09 05 a1 01 05 85 85 05 09 44 15 00 25 01 35 00 45 01 75 08 95 01 81 02 09 65 15 00 25 64 35 00 45 64 75 08 95 01 81 02 c0 05 84 09 05 a1 01 05 85 85 06 09 44 15 00 25 01 35 00 45 01 75 08 95 01 81 02 09 65 15 00 25 64 35 00 45 64 75 08 95 01 81 02 c0
> N: ZMK Project Dactyl 5x6
> P: usb-0000:2d:00.3-4.2/input2
> I: 3 1d50 615e
> D: 0
> E: 0.000000 3 05 00 56
> E: 0.000977 3 05 00 56
> E: 1.490974 3 06 00 52
> E: 1.491958 3 06 00 52
> E: 6.492979 3 06 00 53
> E: 6.493962 3 06 00 53
>
> The recording shows both batteries reporting with different charge levels
> (Report ID 05: 86%, Report ID 06: 82%-83%), demonstrating the multi-battery
> functionality. This can be used to verify UPower compatibility.
>
> ## Future Work: Userspace Integration
>
> As suggested by Bastien, semantic battery differentiation (e.g., "left
> earbud" vs "right earbud") requires userspace coordination, as HID
> reports typically lack role metadata.
>
> This will require:
> 1. systemd/hwdb entries for device-specific battery role mappings
> 2. UPower updates to enumerate and group multi-battery devices
> 3. Desktop environment changes to display batteries with meaningful labels
>
> This kernel infrastructure is a prerequisite for that userspace work.
>
> Lucas Zampieri (1):
> HID: input: Add support for multiple batteries per device
>
> Signed-off-by: Lucas Zampieri <lzampier@...hat.com>
>
> Changes in v4:
> - Added missing hidinput_update_battery() stub in #else block for
> CONFIG_HID_BATTERY_STRENGTH=n builds
> - Reported-by: kernel test robot <lkp@...el.com>
> - Closes: https://lore.kernel.org/oe-kbuild-all/202511201624.yUv4VtBv-lkp@intel.com/
I don't think you need to keep the formal tags here in changlogs of the
cover letter. A simple "as reported by kernel test robot
<lkp@...el.com>" should be sufficient (given that usually we end up
dropping the cover letter as we apply the patches only).
>
> Changes in v3:
> - Squashed the three v2 patches into a single patch as suggested by
> Benjamin
Sorry we didn't understood each other: I was asking you to squash
patches 1 and 2 only, and keep 3 separated. I was just complaining about
a blank header change. Separating the non functional changes from the
functional ones is important.
> - Removed all legacy dev->battery_* fields, using list-based storage only
> - Changed battery naming to include report ID: hid-{uniq}-battery-{report_id}
> - Converted battery memory management to devm_* for automatic cleanup
Haven't checked the code yet but that would require probably a separate
patch so we can bisect to it if anything breaks.
> - Updated hidinput_update_battery() to take struct hid_battery directly
> - Added hid_get_first_battery() helper for external driver compatibility
> - Updated hid-apple.c and hid-magicmouse.c to use new battery API
> - Simplified cover letter based on feedback
Heh, thanks :)
Cheers,
Benjamin
>
> Changes in v2:
> - Split the monolithic v1 patch into three logical patches for easier review:
> 1. Introduce struct hid_battery (pure structure addition)
> 2. Refactor existing code to use the new structure (internal changes)
> 3. Add multi-battery support (new functionality)
> - Added detailed testing section with hardware specifics
> - Added hid-recorder output (dactyl-hid-recording.txt) demonstrating two-battery
> HID descriptor for UPower validation
> - Added "Future Work: Userspace Integration" section addressing Bastien's feedback
> about semantic battery differentiation
> - Added hardware examples with product links to commit messages (per Bastien's
> suggestion)
> - No functional changes from v1, only improved patch organization and documentation
>
> drivers/hid/hid-apple.c | 10 +-
> drivers/hid/hid-core.c | 4 +
> drivers/hid/hid-input-test.c | 39 ++++---
> drivers/hid/hid-input.c | 196 +++++++++++++++++++----------------
> drivers/hid/hid-magicmouse.c | 10 +-
> include/linux/hid.h | 54 +++++++---
> 6 files changed, 187 insertions(+), 126 deletions(-)
>
>
> base-commit: 0678f5630429a5049d7663703b897e1bf8d13cd1
> --
> 2.51.0
>
Powered by blists - more mailing lists