linux/drivers
Daniel Nicoletti c5a92aa3eb 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>
2012-01-08 18:30:34 +11:00
..
accessibility
acpi Merge branch 'pstore' of git://git.kernel.org/pub/scm/linux/kernel/git/aegl/linux 2011-11-01 10:52:29 -07:00
amba
ata Merge branch 'depends/rmk/gpio' into next/devel 2011-10-31 23:46:42 +01:00
atm Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next 2011-10-25 13:25:22 +02:00
auxdisplay
base Merge branch 'pm-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm 2011-10-25 15:18:39 +02:00
bcma
block virtio-blk: use ida to allocate disk index 2011-11-02 11:41:02 +10:30
bluetooth Merge branch 'pm-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm 2011-10-25 15:18:39 +02:00
cdrom
char Merge branch 'misc-3.2' of git://git.kernel.org/pub/scm/linux/kernel/git/aegl/linux 2011-11-02 16:52:17 -07:00
clk
clocksource Merge branch 'next/timer' of git://git.linaro.org/people/arnd/arm-soc 2011-11-01 20:18:05 -07:00
connector
cpufreq Merge branch 'timers-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip 2011-10-26 17:15:03 +02:00
cpuidle
crypto crypto: talitos - handle descriptor not found in error path 2011-10-21 15:20:28 +02:00
dca
devfreq
dio
dma
edac Merge branch 'linux_next' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-edac 2011-11-02 16:55:15 -07:00
eisa
firewire firewire: ohci: fix isochronous DMA synchronization 2011-10-18 12:32:39 +02:00
firmware Merge branch 'pstore' of git://git.kernel.org/pub/scm/linux/kernel/git/aegl/linux 2011-11-01 10:52:29 -07:00
gpio Merge branch 'next/devel' of git://git.linaro.org/people/arnd/arm-soc 2011-11-01 20:31:25 -07:00
gpu Merge branch 'drm-core-next' of git://people.freedesktop.org/~airlied/linux 2011-10-28 05:54:23 -07:00
hid hid-input: add support for HID devices reporting Battery Strength 2012-01-08 18:30:34 +11:00
hv hv: remove struct hv_device_info from hyperv.h 2011-10-11 09:51:22 -06:00
hwmon drivers/hwmon/hwmon.c: convert idr to ida and use ida_simple_get() 2011-10-31 17:30:51 -07:00
hwspinlock
i2c Merge branch 'for-linus/i2c-3.2' of git://git.fluff.org/bjdooks/linux 2011-11-01 15:07:19 -07:00
ide Merge branch 'depends/rmk/gpio' into next/devel 2011-10-31 23:46:42 +01:00
idle
ieee802154
infiniband Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/roland/infiniband 2011-11-01 10:51:38 -07:00
input Merge branch 'for-linus' of git://github.com/richardweinberger/linux 2011-11-02 09:45:39 -07:00
iommu Merge branch 'next' of git://git.kernel.org/pub/scm/linux/kernel/git/joro/iommu 2011-10-30 15:46:19 -07:00
isdn Merge branch 'for-linus' of git://github.com/richardweinberger/linux 2011-11-02 09:45:39 -07:00
leds drivers/leds/leds-lp5521.c: check if reset is successful 2011-10-31 17:30:55 -07:00
lguest lguest: move process freezing before pending signals check 2011-10-27 10:56:18 +10:30
macintosh
mca
md Merge git://git.kernel.org/pub/scm/linux/kernel/git/steve/linux-dm 2011-11-02 17:02:37 -07:00
media Merge branch 'v4l_for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-media 2011-10-31 15:42:54 -07:00
memstick
message
mfd Merge branch 'depends/rmk/gpio' into next/devel 2011-10-31 23:46:42 +01:00
misc drivers/misc/vmw_balloon.c: fix typo in code comment 2011-11-02 16:07:03 -07:00
mmc Merge branch 'next/devel' of git://git.linaro.org/people/arnd/arm-soc 2011-11-01 20:31:25 -07:00
mtd filesystems: add missing nlink wrappers 2011-11-02 12:53:43 +01:00
net Merge branch 'akpm' (Andrew's incoming - part two) 2011-11-02 16:07:27 -07:00
nfc
nubus
of Merge branch 'next/dt' of git://git.linaro.org/people/arnd/arm-soc 2011-11-01 21:02:35 -07:00
oprofile
parisc
parport parport_pc: release IO region properly if unsupported ITE887x card is found 2011-10-18 14:17:40 -07:00
pci Merge branch 'next-rebase' of git://git.kernel.org/pub/scm/linux/kernel/git/jbarnes/pci 2011-10-28 14:20:44 -07:00
pcmcia Merge branch 'next/fixes' of git://git.linaro.org/people/arnd/arm-soc 2011-11-01 19:55:06 -07:00
pinctrl pinctrl/sirf: fix sirfsoc_get_group_pins prototype 2011-10-25 10:43:57 +02:00
platform Merge branch 'akpm' (Andrew's incoming) 2011-10-31 17:46:07 -07:00
pnp
power Merge branch 'akpm' (Andrew's incoming - part two) 2011-11-02 16:07:27 -07:00
pps pps gpio client: add missing dependency 2011-11-02 16:07:02 -07:00
ps3
ptp
rapidio RapidIO: fix potential null deref in rio_setup_device() 2011-11-02 16:07:01 -07:00
regulator Merge branch 'for-linus' of git://opensource.wolfsonmicro.com/regulator 2011-11-01 15:06:20 -07:00
rtc Merge branch 'akpm' (Andrew's incoming - part two) 2011-11-02 16:07:27 -07:00
s390 [S390] qdio: prevent dsci access without adapter interrupts 2011-10-30 15:16:47 +01:00
sbus
scsi Merge git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi-misc-2.6 2011-10-28 16:44:18 -07:00
sfi
sh
sn
spi Merge branch 'depends/rmk/gpio' into next/devel 2011-10-31 23:46:42 +01:00
ssb
staging filesystems: add set_nlink() 2011-11-02 12:53:43 +01:00
target Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jikos/trivial 2011-10-25 12:11:02 +02:00
tc
telephony
thermal
tty Merge branch 'for-linus' of git://github.com/richardweinberger/linux 2011-11-02 09:45:39 -07:00
uio uio: Support physical addresses >32 bits on 32-bit systems 2011-10-18 11:18:57 -07:00
usb HID/usbled: add support for Dream Cheeky DL100B Mailbox Friends Alert 2011-11-20 10:21:30 +01:00
uwb
vhost
video Merge branch 'next/fixes' of git://git.linaro.org/people/arnd/arm-soc 2011-11-01 19:55:06 -07:00
virt
virtio virtio: Add platform bus driver for memory mapped virtio device 2011-11-02 11:41:01 +10:30
vlynq
w1 w1: disable irqs in critical section 2011-11-02 16:07:03 -07:00
watchdog Merge branch 'for-linus' of git://github.com/richardweinberger/linux 2011-11-02 09:45:39 -07:00
xen Merge branch 'irq-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip 2011-10-26 16:44:09 +02:00
zorro zorro: Fix four checkpatch warnings 2011-10-24 21:00:34 +02:00
Kconfig Merge branch 'staging-next' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging 2011-10-26 15:39:02 +02:00
Makefile Merge branch 'staging-next' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging 2011-10-26 15:39:02 +02:00