Skip to content

Commit

Permalink
HID: wacom: process invalid Cintiq and Intuos data in wacom_intuos_in…
Browse files Browse the repository at this point in the history
…out()

Users may use unsupported tools on Cintiq or Intuos. When invalid tools or data
are detected, they should be ignored. That is, no event from those tools should
be reported.

Consolidating that code in wacom_intuos_inout simplifies the logic and make it
easier for future code change.

Signed-off-by: Ping Cheng <pingc@wacom.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
  • Loading branch information
Pinglinux authored and Jiri Kosina committed Jan 12, 2015
1 parent 61e9e7e commit 373a535
Showing 1 changed file with 26 additions and 24 deletions.
50 changes: 26 additions & 24 deletions drivers/hid/wacom_wac.c
Original file line number Diff line number Diff line change
Expand Up @@ -534,9 +534,24 @@ static int wacom_intuos_inout(struct wacom_wac *wacom)
return 1;
}

/*
* don't report events for invalid data
*/
/* older I4 styli don't work with new Cintiqs */
if (!((wacom->id[idx] >> 20) & 0x01) &&
(features->type == WACOM_21UX2))
if ((!((wacom->id[idx] >> 20) & 0x01) &&
(features->type == WACOM_21UX2)) ||
/* Only large Intuos support Lense Cursor */
(wacom->tool[idx] == BTN_TOOL_LENS &&
(features->type == INTUOS3 ||
features->type == INTUOS3S ||
features->type == INTUOS4 ||
features->type == INTUOS4S ||
features->type == INTUOS5 ||
features->type == INTUOS5S ||
features->type == INTUOSPM ||
features->type == INTUOSPS)) ||
/* Cintiq doesn't send data when RDY bit isn't set */
(features->type == CINTIQ && !(data[1] & 0x40)))
return 1;

/* Range Report */
Expand All @@ -553,6 +568,10 @@ static int wacom_intuos_inout(struct wacom_wac *wacom)
if (features->quirks & WACOM_QUIRK_MULTI_INPUT)
wacom->shared->stylus_in_proximity = false;

/* don't report exit if we don't know the ID */
if (!wacom->id[idx])
return 1;

/*
* Reset all states otherwise we lose the initial states
* when in-prox next time
Expand Down Expand Up @@ -585,6 +604,11 @@ static int wacom_intuos_inout(struct wacom_wac *wacom)
wacom->id[idx] = 0;
return 2;
}

/* don't report other events if we don't know the ID */
if (!wacom->id[idx])
return 1;

return 0;
}

Expand Down Expand Up @@ -842,28 +866,6 @@ static int wacom_intuos_irq(struct wacom_wac *wacom)
if (result)
return result - 1;

/* don't proceed if we don't know the ID */
if (!wacom->id[idx])
return 0;

/* Only large Intuos support Lense Cursor */
if (wacom->tool[idx] == BTN_TOOL_LENS &&
(features->type == INTUOS3 ||
features->type == INTUOS3S ||
features->type == INTUOS4 ||
features->type == INTUOS4S ||
features->type == INTUOS5 ||
features->type == INTUOS5S ||
features->type == INTUOSPM ||
features->type == INTUOSPS)) {

return 0;
}

/* Cintiq doesn't send data when RDY bit isn't set */
if (features->type == CINTIQ && !(data[1] & 0x40))
return 0;

if (features->type >= INTUOS3S) {
input_report_abs(input, ABS_X, (data[2] << 9) | (data[3] << 1) | ((data[9] >> 1) & 1));
input_report_abs(input, ABS_Y, (data[4] << 9) | (data[5] << 1) | (data[9] & 1));
Expand Down

0 comments on commit 373a535

Please sign in to comment.