* [PATCH 1/1] HID: hid-input: allow array fields out of range
@ 2012-03-02 20:13 Nikolai Kondrashov
2012-03-05 9:30 ` Jiri Kosina
0 siblings, 1 reply; 2+ messages in thread
From: Nikolai Kondrashov @ 2012-03-02 20:13 UTC (permalink / raw)
To: Jiri Kosina; +Cc: linux-input, Nikolai Kondrashov
Allow array field values out of range as per HID 1.11 specification,
section 6.2.25:
Rather than returning a single bit for each button in the group, an
array returns an index in each field that corresponds to the pressed
button (like keyboard scan codes). An out-of range value in and array
field is considered no controls asserted.
Apparently, "and" above is a typo and should be "an".
This fixes at least Waltop tablet pen clicks - otherwise BTN_TOUCH is never
released.
The relevant part of Waltop tablet report descriptors is this:
0x09, 0x42, /* Usage (Tip Switch), */
0x09, 0x44, /* Usage (Barrel Switch), */
0x09, 0x46, /* Usage (Tablet Pick), */
0x15, 0x01, /* Logical Minimum (1), */
0x25, 0x03, /* Logical Maximum (3), */
0x75, 0x04, /* Report Size (4), */
0x95, 0x01, /* Report Count (1), */
0x80, /* Input, */
Signed-off-by: Nikolai Kondrashov <spbnick@gmail.com>
---
I hope this could get into the 3.3 release, otherwise at least Waltop tablets
would be useless.
drivers/hid/hid-input.c | 9 +++++++--
1 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/drivers/hid/hid-input.c b/drivers/hid/hid-input.c
index 9333d69..627850a 100644
--- a/drivers/hid/hid-input.c
+++ b/drivers/hid/hid-input.c
@@ -986,8 +986,13 @@ void hidinput_hid_event(struct hid_device *hid, struct hid_field *field, struct
return;
}
- /* Ignore out-of-range values as per HID specification, section 5.10 */
- if (value < field->logical_minimum || value > field->logical_maximum) {
+ /*
+ * Ignore out-of-range values as per HID specification,
+ * section 5.10 and 6.2.25
+ */
+ if ((field->flags & HID_MAIN_ITEM_VARIABLE) &&
+ (value < field->logical_minimum ||
+ value > field->logical_maximum)) {
dbg_hid("Ignoring out-of-range value %x\n", value);
return;
}
--
1.7.9
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH 1/1] HID: hid-input: allow array fields out of range
2012-03-02 20:13 [PATCH 1/1] HID: hid-input: allow array fields out of range Nikolai Kondrashov
@ 2012-03-05 9:30 ` Jiri Kosina
0 siblings, 0 replies; 2+ messages in thread
From: Jiri Kosina @ 2012-03-05 9:30 UTC (permalink / raw)
To: Nikolai Kondrashov; +Cc: linux-input
On Fri, 2 Mar 2012, Nikolai Kondrashov wrote:
> Allow array field values out of range as per HID 1.11 specification,
> section 6.2.25:
>
> Rather than returning a single bit for each button in the group, an
> array returns an index in each field that corresponds to the pressed
> button (like keyboard scan codes). An out-of range value in and array
> field is considered no controls asserted.
>
> Apparently, "and" above is a typo and should be "an".
>
> This fixes at least Waltop tablet pen clicks - otherwise BTN_TOUCH is never
> released.
>
> The relevant part of Waltop tablet report descriptors is this:
>
> 0x09, 0x42, /* Usage (Tip Switch), */
> 0x09, 0x44, /* Usage (Barrel Switch), */
> 0x09, 0x46, /* Usage (Tablet Pick), */
> 0x15, 0x01, /* Logical Minimum (1), */
> 0x25, 0x03, /* Logical Maximum (3), */
> 0x75, 0x04, /* Report Size (4), */
> 0x95, 0x01, /* Report Count (1), */
> 0x80, /* Input, */
>
> Signed-off-by: Nikolai Kondrashov <spbnick@gmail.com>
> ---
>
> I hope this could get into the 3.3 release, otherwise at least Waltop tablets
> would be useless.
>
> drivers/hid/hid-input.c | 9 +++++++--
> 1 files changed, 7 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/hid/hid-input.c b/drivers/hid/hid-input.c
> index 9333d69..627850a 100644
> --- a/drivers/hid/hid-input.c
> +++ b/drivers/hid/hid-input.c
> @@ -986,8 +986,13 @@ void hidinput_hid_event(struct hid_device *hid, struct hid_field *field, struct
> return;
> }
>
> - /* Ignore out-of-range values as per HID specification, section 5.10 */
> - if (value < field->logical_minimum || value > field->logical_maximum) {
> + /*
> + * Ignore out-of-range values as per HID specification,
> + * section 5.10 and 6.2.25
> + */
> + if ((field->flags & HID_MAIN_ITEM_VARIABLE) &&
> + (value < field->logical_minimum ||
> + value > field->logical_maximum)) {
> dbg_hid("Ignoring out-of-range value %x\n", value);
> return;
> }
Nikolai, thanks a lot for the quick analysis and fix. I have now applied
it and will be sending it to Linus shortly.
--
Jiri Kosina
SUSE Labs
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2012-03-05 9:30 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-03-02 20:13 [PATCH 1/1] HID: hid-input: allow array fields out of range Nikolai Kondrashov
2012-03-05 9:30 ` Jiri Kosina
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.