1. 01 10月, 2020 1 次提交
  2. 01 9月, 2020 1 次提交
    • M
      HID: core: Sanitize event code and type when mapping input · 35556bed
      Marc Zyngier 提交于
      When calling into hid_map_usage(), the passed event code is
      blindly stored as is, even if it doesn't fit in the associated bitmap.
      
      This event code can come from a variety of sources, including devices
      masquerading as input devices, only a bit more "programmable".
      
      Instead of taking the event code at face value, check that it actually
      fits the corresponding bitmap, and if it doesn't:
      - spit out a warning so that we know which device is acting up
      - NULLify the bitmap pointer so that we catch unexpected uses
      
      Code paths that can make use of untrusted inputs can now check
      that the mapping was indeed correct and bail out if not.
      
      Cc: stable@vger.kernel.org
      Signed-off-by: NMarc Zyngier <maz@kernel.org>
      Signed-off-by: NBenjamin Tissoires <benjamin.tissoires@gmail.com>
      35556bed
  3. 12 2月, 2020 1 次提交
    • J
      HID: core: increase HID report buffer size to 8KiB · 84a40626
      Johan Korsnes 提交于
      We have a HID touch device that reports its opens and shorts test
      results in HID buffers of size 8184 bytes. The maximum size of the HID
      buffer is currently set to 4096 bytes, causing probe of this device to
      fail. With this patch we increase the maximum size of the HID buffer to
      8192 bytes, making device probe and acquisition of said buffers succeed.
      Signed-off-by: NJohan Korsnes <jkorsnes@cisco.com>
      Cc: Alan Stern <stern@rowland.harvard.edu>
      Cc: Armando Visconti <armando.visconti@st.com>
      Cc: Jiri Kosina <jkosina@suse.cz>
      Signed-off-by: NJiri Kosina <jkosina@suse.cz>
      84a40626
  4. 18 9月, 2019 2 次提交
  5. 31 5月, 2019 1 次提交
  6. 24 4月, 2019 2 次提交
  7. 02 4月, 2019 1 次提交
    • N
      HID: core: move Usage Page concatenation to Main item · 58e75155
      Nicolas Saenz Julienne 提交于
      As seen on some USB wireless keyboards manufactured by Primax, the HID
      parser was using some assumptions that are not always true. In this case
      it's s the fact that, inside the scope of a main item, an Usage Page
      will always precede an Usage.
      
      The spec is not pretty clear as 6.2.2.7 states "Any usage that follows
      is interpreted as a Usage ID and concatenated with the Usage Page".
      While 6.2.2.8 states "When the parser encounters a main item it
      concatenates the last declared Usage Page with a Usage to form a
      complete usage value." Being somewhat contradictory it was decided to
      match Window's implementation, which follows 6.2.2.8.
      
      In summary, the patch moves the Usage Page concatenation from the local
      item parsing function to the main item parsing function.
      Signed-off-by: NNicolas Saenz Julienne <nsaenzjulienne@suse.de>
      Reviewed-by: NTerry Junge <terry.junge@poly.com>
      Signed-off-by: NBenjamin Tissoires <benjamin.tissoires@redhat.com>
      58e75155
  8. 16 1月, 2019 1 次提交
  9. 10 1月, 2019 1 次提交
  10. 07 12月, 2018 3 次提交
    • P
      HID: input: use the Resolution Multiplier for high-resolution scrolling · 2dc702c9
      Peter Hutterer 提交于
      Windows uses a magic number of 120 for a wheel click. High-resolution
      scroll wheels are supposed to use a fraction of 120 to signal smaller
      scroll steps. This is implemented by the Resolution Multiplier in the
      device itself.
      
      If the multiplier is present in the report descriptor, set it to the
      logical max and then use the resolution multiplier to calculate the
      high-resolution events. This is the recommendation by Microsoft, see
      http://msdn.microsoft.com/en-us/windows/hardware/gg487477.aspx
      
      Note that all mice encountered so far have a logical min/max of 0/1, so
      it's a binary "yes or no" to high-res scrolling anyway.
      
      To make userspace simpler, always enable the REL_WHEEL_HI_RES bit. Where
      the device doesn't support high-resolution scrolling, the value for the
      high-res data will simply be a multiple of 120 every time. For userspace,
      if REL_WHEEL_HI_RES is available that is the one to be used.
      
      Potential side-effect: a device with a Resolution Multiplier applying to
      other Input items will have those items set to the logical max as well.
      This cannot easily be worked around but it is doubtful such devices exist.
      Signed-off-by: NPeter Hutterer <peter.hutterer@who-t.net>
      Verified-by: NHarry Cutts <hcutts@chromium.org>
      Signed-off-by: NBenjamin Tissoires <benjamin.tissoires@redhat.com>
      2dc702c9
    • P
      HID: core: process the Resolution Multiplier · 5a4abb36
      Peter Hutterer 提交于
      The Resolution Multiplier is a feature report that modifies the value of
      Usages within the same Logical Collection. If the multiplier is set to
      anything but 1, the hardware reports (value * multiplier) for the same amount
      of physical movement, i.e. the value we receive in the kernel is
      pre-multiplied.
      
      The hardware may either send a single (value * multiplier), or by sending
      multiplier as many reports with the same value, or a combination of these two
      options. For example, when the Microsoft Sculpt Ergonomic mouse Resolution
      Multiplier is set to 12, the Wheel sends out 12 for every detent but AC Pan
      sends out a value of 3 at 4 times the frequency.
      
      The effective multiplier is based on the physical min/max of the multiplier
      field, a logical min/max of [0,1] with a physical min/max of [1,8] means the
      multiplier is either 1 or 8.
      
      The Resolution Multiplier was introduced for high-resolution scrolling in
      Windows Vista and is commonly used on Microsoft mice.
      
      The recommendation for the Resolution Multiplier is to default to 1 for
      backwards compatibility. This patch adds an arbitrary upper limit at 255. The
      only known use case for the Resolution Multiplier is for scroll wheels where the
      multiplier has to be a fraction of 120 to work with Windows.
      Signed-off-by: NPeter Hutterer <peter.hutterer@who-t.net>
      Verified-by: NHarry Cutts <hcutts@chromium.org>
      Signed-off-by: NBenjamin Tissoires <benjamin.tissoires@redhat.com>
      5a4abb36
    • P
      HID: core: store the collections as a basic tree · c53431eb
      Peter Hutterer 提交于
      For each collection parsed, store a pointer to the parent collection
      (if any). This makes it a lot easier to look up which collection(s)
      any given item is part of
      Signed-off-by: NPeter Hutterer <peter.hutterer@who-t.net>
      Verified-by: NHarry Cutts <hcutts@chromium.org>
      Signed-off-by: NBenjamin Tissoires <benjamin.tissoires@redhat.com>
      c53431eb
  11. 05 12月, 2018 2 次提交
  12. 22 11月, 2018 1 次提交
  13. 06 11月, 2018 1 次提交
    • L
      HID: fix up .raw_event() documentation · aa9b760c
      Linus Walleij 提交于
      The documentation for the .raw_event() callback says that if the
      driver return 1, there will be no further processing of the event,
      but this is not true, the actual code in hid-core.c looks like this:
      
        if (hdrv && hdrv->raw_event && hid_match_report(hid, report)) {
                 ret = hdrv->raw_event(hid, report, data, size);
                 if (ret < 0)
                         goto unlock;
         }
      
         ret = hid_report_raw_event(hid, type, data, size, interrupt);
      
      The only return value that has any effect on the processing is
      a negative error.
      
      Correct this as it seems to confuse people: I found bogus code in
      the Razer out-of-tree driver attempting to return 1 here.
      Signed-off-by: NLinus Walleij <linus.walleij@linaro.org>
      Signed-off-by: NJiri Kosina <jkosina@suse.cz>
      aa9b760c
  14. 05 9月, 2018 2 次提交
  15. 23 7月, 2018 1 次提交
  16. 17 7月, 2018 2 次提交
  17. 25 6月, 2018 1 次提交
  18. 15 5月, 2018 1 次提交
    • R
      HID: add driver for Valve Steam Controller · c164d6ab
      Rodrigo Rivas Costa 提交于
      There are two ways to connect the Steam Controller: directly to the USB
      or with the USB wireless adapter.  Both methods are similar, but the
      wireless adapter can connect up to 4 devices at the same time.
      
      The wired device will appear as 3 interfaces: a virtual mouse, a virtual
      keyboard and a custom HID device.
      
      The wireless device will appear as 5 interfaces: a virtual keyboard and
      4 custom HID devices, that will remain silent until a device is actually
      connected.
      
      The custom HID device has a report descriptor with all vendor specific
      usages, so the hid-generic is not very useful. In a PC/SteamBox Valve
      Steam Client provices a software translation by using hidraw and a
      creates a uinput virtual gamepad and XTest keyboard/mouse.
      
      This driver intercepts the hidraw usage, so it can get out of the way
      when the Steam Client is in use.
      Signed-off-by: NRodrigo Rivas Costa <rodrigorivascosta@gmail.com>
      Signed-off-by: NJiri Kosina <jkosina@suse.cz>
      c164d6ab
  19. 26 4月, 2018 4 次提交
  20. 17 4月, 2018 1 次提交
    • B
      HID: input: do not increment usages when a duplicate is found · 190d7f02
      Benjamin Tissoires 提交于
      This is something that bothered us from a long time. When hid-input
      doesn't know how to map a usage, it uses *_MISC. But there is something
      else which increments the usage if the evdev code is already used.
      
      This leads to few issues:
      - some devices may have their ABS_X mapped to ABS_Y if they export a bad
        set of usages (see the DragonRise joysticks IIRC -> fixed in a specific
        HID driver)
      - *_MISC + N might (will) conflict with other defined axes (my Logitech
        H800 exports some multitouch axes because of that)
      - this prevents to freely add some new evdev usages, because "hey, my
        headset will now report ABS_COFFEE, and it's not coffee capable".
      
      So let's try to kill this nonsense, and hope we won't break too many
      devices.
      
      I my headset case, the ABS_MISC axes are created because of some
      proprietary usages, so we might not break that many devices.
      
      For backward compatibility, a quirk HID_QUIRK_INCREMENT_USAGE_ON_DUPLICATE
      is created and can be applied to any device that needs this behavior.
      Signed-off-by: NBenjamin Tissoires <benjamin.tissoires@redhat.com>
      Acked-by: NPeter Hutterer <peter.hutterer@who-t.net>
      Acked-by: NDmitry Torokhov <dmitry.torokhov@gmail.com>
      Signed-off-by: NJiri Kosina <jkosina@suse.cz>
      190d7f02
  21. 09 4月, 2018 1 次提交
    • D
      HID: input: fix battery level reporting on BT mice · 2e210bbb
      Dmitry Torokhov 提交于
      The commit 581c4484 ("HID: input: map digitizer battery usage")
      assumed that devices having input (qas opposed to feature) report for
      battery strength would report the data on their own, without the need to
      be polled by the kernel; unfortunately it is not so. Many wireless mice
      do not send unsolicited reports with battery strength data and have to
      be polled explicitly. As a complication, stylus devices on digitizers
      are not normally connected to the base and thus can not be polled - the
      base can only determine battery strength in the stylus when it is in
      proximity.
      
      To solve this issue, we add a special flag that tells the kernel
      to avoid polling the device (and expect unsolicited reports) and set it
      when report field with physical usage of digitizer stylus (HID_DG_STYLUS).
      Unless this flag is set, and we have not seen the unsolicited reports,
      the kernel will attempt to poll the device when userspace attempts to
      read "capacity" and "state" attributes of power_supply object
      corresponding to the devices battery.
      
      Fixes: 581c4484 ("HID: input: map digitizer battery usage")
      Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=198095
      Cc: stable@vger.kernel.org
      Reported-and-tested-by: NMartin van Es <martin@mrvanes.com>
      Signed-off-by: NDmitry Torokhov <dmitry.torokhov@gmail.com>
      Signed-off-by: NJiri Kosina <jkosina@suse.cz>
      2e210bbb
  22. 23 3月, 2018 3 次提交
  23. 06 3月, 2018 1 次提交
  24. 16 2月, 2018 1 次提交
  25. 01 12月, 2017 1 次提交
  26. 21 11月, 2017 3 次提交
    • B
      HID: core: remove the absolute need of hid_have_special_driver[] · e04a0442
      Benjamin Tissoires 提交于
      Most HID devices behave properly when they are used with hid-generic.
      Since kernel v4.12, we do not poll for input reports at plug in, so
      hid-generic should behave properly with all HID devices.
      
      There has been a long standing list of HID devices that have a special
      driver. It used to be just a few, but with time, this list went too big,
      and we can not ask users to know which HID special driver will pick up
      their device.
      
      We can teach hid-generic to be nice with others. If a device is not
      explicitly marked with HID_QUIRK_HAVE_SPECIAL_DRIVER, we can allow
      hid-generic to pick up the device as long as no other loaded HID driver
      will match the device.
      
      When the special driver appears, hid-generic can step back and let
      the special driver handling the device. In case this special driver
      is removed, this good old pal of hid-generic will rebind to the device.
      
      This basically makes the list hid_have_special_driver[] useless. It
      still allows to not see a hid-generic driver bound and removed during
      boot, so we can keep it around.
      
      This will also help other people to have a special HID driver without
      the need of recompiling hid-core.
      Signed-off-by: NBenjamin Tissoires <benjamin.tissoires@redhat.com>
      Signed-off-by: NJiri Kosina <jkosina@suse.cz>
      e04a0442
    • B
      HID: quirks: move the list of special devices into a quirk · 6e65d9d5
      Benjamin Tissoires 提交于
      It is better to centralize the information of special devices in one
      single file. Instead of manually parsing the list of devices that
      have a special driver or those that need to be ignored, introduce
      HID_QUIRK_HAVE_SPECIAL_DRIVER and set the correct quirks while fetching
      those quirks.
      Signed-off-by: NBenjamin Tissoires <benjamin.tissoires@redhat.com>
      Signed-off-by: NJiri Kosina <jkosina@suse.cz>
      6e65d9d5
    • B
      HID: core: move the dynamic quirks handling in core · d5d3e202
      Benjamin Tissoires 提交于
      usbhid has a list of dynamic quirks in addition to a list of static quirks.
      There is not much USB specific in that, so move this part of the module
      in core so we can have one central place for quirks.
      Signed-off-by: NBenjamin Tissoires <benjamin.tissoires@redhat.com>
      Signed-off-by: NJiri Kosina <jkosina@suse.cz>
      d5d3e202