[PATCH 0/3] HID: Apple Magic Keyboard/Trackpad battery over Bluetooth

Alec Hall posted 3 patches 1 week, 4 days ago
drivers/hid/hid-apple.c      | 36 ++++++-------
drivers/hid/hid-magicmouse.c | 99 ++++++++++++++++++++++++++----------
2 files changed, 92 insertions(+), 43 deletions(-)
[PATCH 0/3] HID: Apple Magic Keyboard/Trackpad battery over Bluetooth
Posted by Alec Hall 1 week, 4 days ago
Apple's Magic Keyboard and Magic Trackpad 2 / Magic Mouse 2 report their
battery to the host, but the kernel only surfaces it over USB; over
Bluetooth the power_supply is stuck at 0%, even though these devices are
used over Bluetooth nearly all the time.

Both drivers already fetch the battery (a GET_REPORT for input report
0x90) but only over USB. Enabling it over Bluetooth naively hard-locks the
machine: the fetch runs from a timer callback (atomic context) and the
uhid transport sleeps inside hid_hw_request(). Each driver's patch
therefore moves the fetch to a workqueue before enabling it over
Bluetooth. The last patch teaches hid-magicmouse to report charge status
from the device's status byte.

Patch 3 interprets a vendor status byte whose bit meanings were determined
empirically; I can rework it as a report-descriptor fixup exposing
HID_BAT_CHARGING instead if reviewers prefer.

Tested on a Magic Keyboard 2021 and a Magic Trackpad 2 over BlueZ (uhid).

Alec Hall (3):
  HID: apple: report Magic Keyboard battery over Bluetooth
  HID: magicmouse: report battery over Bluetooth
  HID: magicmouse: report charge status over Bluetooth

 drivers/hid/hid-apple.c      | 36 ++++++-------
 drivers/hid/hid-magicmouse.c | 99 ++++++++++++++++++++++++++----------
 2 files changed, 92 insertions(+), 43 deletions(-)


base-commit: b7556c8e713c88596046a906c7c4385218d44736
-- 
2.55.0