Commit 1b5d514a authored by Jason Gerecke's avatar Jason Gerecke Committed by Jiri Kosina

HID: wacom: Ignore contacts in excess of declared contact count

The reports sent from some touch devices (e.g. the Cintiq 24HDT) contain
junk data in the contact slots which follow the final "valid" contact.
To avoid forwarding it to usrspace, we store the reported contact count
during the pre-process phase and then only process that many contacts.
If a device sends its contacts across multiple reports (what Microsoft
refers to as "hybrid" mode) then the contact count will be zero for
reports other than the first.
Signed-off-by: default avatarJason Gerecke <jason.gerecke@wacom.com>
Signed-off-by: default avatarJiri Kosina <jkosina@suse.com>
parent 06324e0c
...@@ -1510,6 +1510,10 @@ static void wacom_wac_finger_usage_mapping(struct hid_device *hdev, ...@@ -1510,6 +1510,10 @@ static void wacom_wac_finger_usage_mapping(struct hid_device *hdev,
features->last_slot_field = usage->hid; features->last_slot_field = usage->hid;
wacom_map_usage(input, usage, field, EV_KEY, BTN_TOUCH, 0); wacom_map_usage(input, usage, field, EV_KEY, BTN_TOUCH, 0);
break; break;
case HID_DG_CONTACTCOUNT:
wacom_wac->hid_data.cc_index = field->index;
wacom_wac->hid_data.cc_value_index = usage->usage_index;
break;
} }
} }
...@@ -1521,6 +1525,10 @@ static void wacom_wac_finger_slot(struct wacom_wac *wacom_wac, ...@@ -1521,6 +1525,10 @@ static void wacom_wac_finger_slot(struct wacom_wac *wacom_wac,
bool prox = hid_data->tipswitch && bool prox = hid_data->tipswitch &&
!wacom_wac->shared->stylus_in_proximity; !wacom_wac->shared->stylus_in_proximity;
wacom_wac->hid_data.num_received++;
if (wacom_wac->hid_data.num_received > wacom_wac->hid_data.num_expected)
return;
if (mt) { if (mt) {
int slot; int slot;
...@@ -1573,7 +1581,19 @@ static int wacom_wac_finger_event(struct hid_device *hdev, ...@@ -1573,7 +1581,19 @@ static int wacom_wac_finger_event(struct hid_device *hdev,
static void wacom_wac_finger_pre_report(struct hid_device *hdev, static void wacom_wac_finger_pre_report(struct hid_device *hdev,
struct hid_report *report) struct hid_report *report)
{ {
return; struct wacom *wacom = hid_get_drvdata(hdev);
struct wacom_wac *wacom_wac = &wacom->wacom_wac;
struct hid_data* hid_data = &wacom_wac->hid_data;
if (hid_data->cc_index >= 0) {
struct hid_field *field = report->field[hid_data->cc_index];
int value = field->value[hid_data->cc_value_index];
if (value)
hid_data->num_expected = value;
}
else {
hid_data->num_expected = wacom_wac->features.touch_max;
}
} }
static void wacom_wac_finger_report(struct hid_device *hdev, static void wacom_wac_finger_report(struct hid_device *hdev,
...@@ -1584,10 +1604,18 @@ static void wacom_wac_finger_report(struct hid_device *hdev, ...@@ -1584,10 +1604,18 @@ static void wacom_wac_finger_report(struct hid_device *hdev,
struct input_dev *input = wacom_wac->touch_input; struct input_dev *input = wacom_wac->touch_input;
unsigned touch_max = wacom_wac->features.touch_max; unsigned touch_max = wacom_wac->features.touch_max;
/* If more packets of data are expected, give us a chance to
* process them rather than immediately syncing a partial
* update.
*/
if (wacom_wac->hid_data.num_received < wacom_wac->hid_data.num_expected)
return;
if (touch_max > 1) if (touch_max > 1)
input_mt_sync_frame(input); input_mt_sync_frame(input);
input_sync(input); input_sync(input);
wacom_wac->hid_data.num_received = 0;
/* keep touch state for pen event */ /* keep touch state for pen event */
wacom_wac->shared->touch_down = wacom_wac_finger_count_touches(wacom_wac); wacom_wac->shared->touch_down = wacom_wac_finger_count_touches(wacom_wac);
......
...@@ -193,6 +193,10 @@ struct hid_data { ...@@ -193,6 +193,10 @@ struct hid_data {
int width; int width;
int height; int height;
int id; int id;
int cc_index;
int cc_value_index;
int num_expected;
int num_received;
}; };
struct wacom_wac { struct wacom_wac {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment