]> git.baikalelectronics.ru Git - kernel.git/commit
HID: clamp input to logical range if no null state
authorTomasz Kramkowski <tk@the-tk.com>
Tue, 14 Mar 2017 13:29:13 +0000 (13:29 +0000)
committerJiri Kosina <jkosina@suse.cz>
Tue, 21 Mar 2017 13:54:00 +0000 (14:54 +0100)
commit8d5499e24a8678e43550d1601fc45302ac8a07e3
tree652d30107b1eddb863987d5e9d59b29ef64b0050
parentac90a4d902045a02c321b746fcd4ecc81c577464
HID: clamp input to logical range if no null state

This patch fixes an issue in drivers/hid/hid-input.c where values
outside of the logical range are not clamped when "null state" bit of
the input control is not set.

This was discussed on the lists [1] and this change stems from the fact
due to the ambiguity of the HID specification it might be appropriate to
follow Microsoft's own interpretation of the specification. As noted in
Microsoft's documentation [2] in the section titled "Required HID usages
for digitizers" it is noted that values reported outside the logical
range "will be considered as invalid data and the value will be changed
to the nearest boundary value (logical min/max)."

This patch fixes an issue where the (1292:4745) Innomedia INNEX
GENESIS/ATARI reports out of range values for its X and Y axis of the
DPad which, due to the null state bit being unset, are forwarded to
userspace as is. Now these values will get clamped to the logical range
before being forwarded to userspace. This device was also used to test
this patch.

This patch expands on commit ac90a4d90204 ("HID: reject input outside
logical range only if null state is set").

[1]: http://lkml.kernel.org/r/20170307131036.GA853@gaia.local
[2]: https://msdn.microsoft.com/en-us/library/windows/hardware/dn672278(v=vs.85).asp

Signed-off-by: Tomasz Kramkowski <tk@the-tk.com>
Acked-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
drivers/hid/hid-input.c