1. 08 1月, 2012 1 次提交
    • D
      hid-input: add support for HID devices reporting Battery Strength · c5a92aa3
      Daniel Nicoletti 提交于
      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: NDaniel Nicoletti <dantti12@gmail.com>
      c5a92aa3
  2. 28 11月, 2011 1 次提交
    • J
      HID: hid-input: add support for HID devices reporting Battery Strength · 4f5ca836
      Jeremy Fitzhardinge 提交于
      Some HID devices, such as my Bluetooth mouse, report their battery
      strength as an event.  Rather than passing it through as a strange
      absolute input event, this patch registers it with the power_supply
      subsystem as a battery, so that the device's Battery Strength can be
      reported to usermode.
      
      The battery appears in sysfs names
      /sys/class/power_supply/hid-<UNIQ>-battery, and it is a child of the
      battery-containing device, so it should be clear what it's the battery of.
      
      Unfortunately on my current Fedora 16 system, while the battery does
      appear in the UI, it is listed as a Laptop Battery with 0% charge (since
      it ignores the "capacity" property of the battery and instead computes
      it from the "energy*" fields, which we can't supply given the limited
      information contained within the HID Report).
      
      Still, this patch is the first step.
      Signed-off-by: NJeremy Fitzhardinge <jeremy@goop.org>
      Signed-off-by: NJiri Kosina <jkosina@suse.cz>
      4f5ca836
  3. 03 11月, 2011 13 次提交
  4. 02 11月, 2011 8 次提交
  5. 01 11月, 2011 17 次提交