Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

HID: wacom: Use "Confidence" flag to prevent reporting invalid contacts

The HID descriptor of many of Wacom's touch input devices include a
"Confidence" usage that signals if a particular touch collection contains
useful data. The driver does not look at this flag, however, which causes
even invalid contacts to be reported to userspace. A lucky combination of
kernel event filtering and device behavior (specifically: contact ID 0 ==
invalid, contact ID >0 == valid; and order all data so that all valid
contacts are reported before any invalid contacts) spare most devices from
any visibly-bad behavior.

The DTH-2452 is one example of an unlucky device that misbehaves. It uses
ID 0 for both the first valid contact and all invalid contacts. Because
we report both the valid and invalid contacts, the kernel reports that
contact 0 first goes down (valid) and then goes up (invalid) in every
report. This causes ~100 clicks per second simply by touching the screen.

This patch inroduces new `confidence` flag in our `hid_data` structure.
The value is initially set to `true` at the start of a report and can be
set to `false` if an invalid touch usage is seen.

Link: https://github.com/linuxwacom/input-wacom/issues/270
Fixes: f8b6a74719b5 ("HID: wacom: generic: Support multiple tools per report")
Signed-off-by: Jason Gerecke <jason.gerecke@wacom.com>
Tested-by: Joshua Dickens <joshua.dickens@wacom.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>

authored by

Jason Gerecke and committed by
Jiri Kosina
7fb0413b 304dd368

+8 -1
+7 -1
drivers/hid/wacom_wac.c
··· 2603 2603 return; 2604 2604 2605 2605 switch (equivalent_usage) { 2606 + case HID_DG_CONFIDENCE: 2607 + wacom_wac->hid_data.confidence = value; 2608 + break; 2606 2609 case HID_GD_X: 2607 2610 wacom_wac->hid_data.x = value; 2608 2611 break; ··· 2638 2635 } 2639 2636 2640 2637 if (usage->usage_index + 1 == field->report_count) { 2641 - if (equivalent_usage == wacom_wac->hid_data.last_slot_field) 2638 + if (equivalent_usage == wacom_wac->hid_data.last_slot_field && 2639 + wacom_wac->hid_data.confidence) 2642 2640 wacom_wac_finger_slot(wacom_wac, wacom_wac->touch_input); 2643 2641 } 2644 2642 } ··· 2656 2652 return; 2657 2653 2658 2654 wacom_wac->is_invalid_bt_frame = false; 2655 + 2656 + hid_data->confidence = true; 2659 2657 2660 2658 for (i = 0; i < report->maxfield; i++) { 2661 2659 struct hid_field *field = report->field[i];
+1
drivers/hid/wacom_wac.h
··· 301 301 bool barrelswitch; 302 302 bool barrelswitch2; 303 303 bool serialhi; 304 + bool confidence; 304 305 int x; 305 306 int y; 306 307 int pressure;