Skip to content

Commit 373a535

Browse files
PinglinuxJiri Kosina
authored andcommitted
HID: wacom: process invalid Cintiq and Intuos data in wacom_intuos_inout()
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 <[email protected]> Signed-off-by: Jiri Kosina <[email protected]>
1 parent 61e9e7e commit 373a535

File tree

1 file changed

+26
-24
lines changed

1 file changed

+26
-24
lines changed

drivers/hid/wacom_wac.c

Lines changed: 26 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -534,9 +534,24 @@ static int wacom_intuos_inout(struct wacom_wac *wacom)
534534
return 1;
535535
}
536536

537+
/*
538+
* don't report events for invalid data
539+
*/
537540
/* older I4 styli don't work with new Cintiqs */
538-
if (!((wacom->id[idx] >> 20) & 0x01) &&
539-
(features->type == WACOM_21UX2))
541+
if ((!((wacom->id[idx] >> 20) & 0x01) &&
542+
(features->type == WACOM_21UX2)) ||
543+
/* Only large Intuos support Lense Cursor */
544+
(wacom->tool[idx] == BTN_TOOL_LENS &&
545+
(features->type == INTUOS3 ||
546+
features->type == INTUOS3S ||
547+
features->type == INTUOS4 ||
548+
features->type == INTUOS4S ||
549+
features->type == INTUOS5 ||
550+
features->type == INTUOS5S ||
551+
features->type == INTUOSPM ||
552+
features->type == INTUOSPS)) ||
553+
/* Cintiq doesn't send data when RDY bit isn't set */
554+
(features->type == CINTIQ && !(data[1] & 0x40)))
540555
return 1;
541556

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

571+
/* don't report exit if we don't know the ID */
572+
if (!wacom->id[idx])
573+
return 1;
574+
556575
/*
557576
* Reset all states otherwise we lose the initial states
558577
* when in-prox next time
@@ -585,6 +604,11 @@ static int wacom_intuos_inout(struct wacom_wac *wacom)
585604
wacom->id[idx] = 0;
586605
return 2;
587606
}
607+
608+
/* don't report other events if we don't know the ID */
609+
if (!wacom->id[idx])
610+
return 1;
611+
588612
return 0;
589613
}
590614

@@ -842,28 +866,6 @@ static int wacom_intuos_irq(struct wacom_wac *wacom)
842866
if (result)
843867
return result - 1;
844868

845-
/* don't proceed if we don't know the ID */
846-
if (!wacom->id[idx])
847-
return 0;
848-
849-
/* Only large Intuos support Lense Cursor */
850-
if (wacom->tool[idx] == BTN_TOOL_LENS &&
851-
(features->type == INTUOS3 ||
852-
features->type == INTUOS3S ||
853-
features->type == INTUOS4 ||
854-
features->type == INTUOS4S ||
855-
features->type == INTUOS5 ||
856-
features->type == INTUOS5S ||
857-
features->type == INTUOSPM ||
858-
features->type == INTUOSPS)) {
859-
860-
return 0;
861-
}
862-
863-
/* Cintiq doesn't send data when RDY bit isn't set */
864-
if (features->type == CINTIQ && !(data[1] & 0x40))
865-
return 0;
866-
867869
if (features->type >= INTUOS3S) {
868870
input_report_abs(input, ABS_X, (data[2] << 9) | (data[3] << 1) | ((data[9] >> 1) & 1));
869871
input_report_abs(input, ABS_Y, (data[4] << 9) | (data[5] << 1) | (data[9] & 1));

0 commit comments

Comments
 (0)