summaryrefslogtreecommitdiffstats
path: root/include/linux/hid.h
diff options
context:
space:
mode:
authorDaniel Nicoletti <dantti12@gmail.com>2011-12-02 03:52:22 -0200
committerJeremy Fitzhardinge <jeremy@goop.org>2012-01-08 18:30:34 +1100
commitc5a92aa3eb7425da68797a820d208edad36551f7 (patch)
tree92d2e8304ce9729c8feb3eeb4689cc8cd0561df5 /include/linux/hid.h
parent672007957846c3d556165bab635a9c9b855261fa (diff)
downloadop-kernel-dev-c5a92aa3eb7425da68797a820d208edad36551f7.zip
op-kernel-dev-c5a92aa3eb7425da68797a820d208edad36551f7.tar.gz
hid-input: add support for HID devices reporting Battery Strength
I've sent an email earlier asking for help with a GetFeature code, and now I have a second patch on top of Jeremy's to provide the battery functionality for devices that support reporting it. If I understood correctly when talking to Jeremy he said his device never actually reported the status as an input event (sorry if I didn't understand it correctly), and after reading HID specs I believe it's really because it was meant to be probed, I have an Apple Keyboard and Magic Trackpad both bluetooth batteries operated, so using PacketLogger I saw that Mac OSX always ask the battery status using the so called GetFeature. What my patch does is basically: - store the report id that matches the battery_strength - setup the battery if 0x6.0x20 is found, even if that is reported as a feature (as it was meant to be but only the MagicTrackpad does) - when upower or someone access /sys/class/power_supply/hid-*/capacity it will probe the device and return it's status. It works great for both devices, but I have two concerns: - the report_features function has a duplicated code - it would be nice if it was possible for specific drivers to provide their own probe as there might be some strange devices... (but maybe it's already possible) I've talked to the upower dev and he fixed it to be able to show the right percentage. Here how the uevent file (in /sys/class/power_supply/hid-*/) looks like: POWER_SUPPLY_NAME=hid-00:22:41:D9:18:E7-battery POWER_SUPPLY_PRESENT=1 POWER_SUPPLY_ONLINE=1 POWER_SUPPLY_CAPACITY=66 POWER_SUPPLY_MODEL_NAME=MacAdmin’s keyboard POWER_SUPPLY_STATUS=Discharging POWER_SUPPLY_NAME=hid-70:CD:60:F5:FF:3F-battery POWER_SUPPLY_PRESENT=1 POWER_SUPPLY_ONLINE=1 POWER_SUPPLY_CAPACITY=62 POWER_SUPPLY_MODEL_NAME=nexx’s Trackpad POWER_SUPPLY_STATUS=Discharging Signed-off-by: Daniel Nicoletti <dantti12@gmail.com>
Diffstat (limited to 'include/linux/hid.h')
-rw-r--r--include/linux/hid.h1
1 files changed, 1 insertions, 0 deletions
diff --git a/include/linux/hid.h b/include/linux/hid.h
index 7f344c3..b5df198 100644
--- a/include/linux/hid.h
+++ b/include/linux/hid.h
@@ -496,6 +496,7 @@ struct hid_device { /* device report descriptor */
__s32 battery_min;
__s32 battery_max;
__s32 battery_val;
+ __s32 battery_report_id;
#endif
unsigned int status; /* see STAT flags above */
OpenPOWER on IntegriCloud