Skip to content

Commit 4750f5f

Browse files
PinglinuxJiri Kosina
authored andcommitted
HID: wacom - make sure wacom_intuos_inout only process in/out events
Move general events related data validation to wacom_intuos_general. Signed-off-by: Ping Cheng <[email protected]> Reviewed-by: Jason Gerecke <[email protected]> Signed-off-by: Jiri Kosina <[email protected]>
1 parent 599b082 commit 4750f5f

File tree

1 file changed

+25
-24
lines changed

1 file changed

+25
-24
lines changed

drivers/hid/wacom_wac.c

Lines changed: 25 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -580,11 +580,12 @@ static int wacom_intuos_inout(struct wacom_wac *wacom)
580580
struct wacom_features *features = &wacom->features;
581581
unsigned char *data = wacom->data;
582582
struct input_dev *input = wacom->pen_input;
583-
int idx = 0;
583+
int idx = (features->type == INTUOS) ? (data[1] & 0x01) : 0;
584584

585-
/* tool number */
586-
if (features->type == INTUOS)
587-
idx = data[1] & 0x01;
585+
if (!(((data[1] & 0xfc) == 0xc0) || /* in prox */
586+
((data[1] & 0xfe) == 0x20) || /* in range */
587+
((data[1] & 0xfe) == 0x80))) /* out prox */
588+
return 0;
588589

589590
/* Enter report */
590591
if ((data[1] & 0xfc) == 0xc0) {
@@ -676,26 +677,6 @@ static int wacom_intuos_inout(struct wacom_wac *wacom)
676677
return 1;
677678
}
678679

679-
/*
680-
* don't report events for invalid data
681-
*/
682-
/* older I4 styli don't work with new Cintiqs */
683-
if ((!((wacom->id[idx] >> 20) & 0x01) &&
684-
(features->type == WACOM_21UX2)) ||
685-
/* Only large Intuos support Lense Cursor */
686-
(wacom->tool[idx] == BTN_TOOL_LENS &&
687-
(features->type == INTUOS3 ||
688-
features->type == INTUOS3S ||
689-
features->type == INTUOS4 ||
690-
features->type == INTUOS4S ||
691-
features->type == INTUOS5 ||
692-
features->type == INTUOS5S ||
693-
features->type == INTUOSPM ||
694-
features->type == INTUOSPS)) ||
695-
/* Cintiq doesn't send data when RDY bit isn't set */
696-
(features->type == CINTIQ && !(data[1] & 0x40)))
697-
return 1;
698-
699680
wacom->shared->stylus_in_proximity = true;
700681
if (wacom->shared->touch_down)
701682
return 1;
@@ -897,6 +878,26 @@ static int wacom_intuos_general(struct wacom_wac *wacom)
897878
return 1;
898879
}
899880

881+
/*
882+
* don't report events for invalid data
883+
*/
884+
/* older I4 styli don't work with new Cintiqs */
885+
if ((!((wacom->id[idx] >> 20) & 0x01) &&
886+
(features->type == WACOM_21UX2)) ||
887+
/* Only large Intuos support Lense Cursor */
888+
(wacom->tool[idx] == BTN_TOOL_LENS &&
889+
(features->type == INTUOS3 ||
890+
features->type == INTUOS3S ||
891+
features->type == INTUOS4 ||
892+
features->type == INTUOS4S ||
893+
features->type == INTUOS5 ||
894+
features->type == INTUOS5S ||
895+
features->type == INTUOSPM ||
896+
features->type == INTUOSPS)) ||
897+
/* Cintiq doesn't send data when RDY bit isn't set */
898+
(features->type == CINTIQ && !(data[1] & 0x40)))
899+
return 1;
900+
900901
x = (be16_to_cpup((__be16 *)&data[2]) << 1) | ((data[9] >> 1) & 1);
901902
y = (be16_to_cpup((__be16 *)&data[4]) << 1) | (data[9] & 1);
902903
distance = data[9] >> 2;

0 commit comments

Comments
 (0)