aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hid/wacom_wac.c
diff options
context:
space:
mode:
authorPing Cheng <pinglinux@gmail.com>2015-01-09 14:04:50 -0500
committerJiri Kosina <jkosina@suse.cz>2015-01-12 04:16:32 -0500
commit373a5356dfb75ea7140f8d37cf26eb6a62910617 (patch)
tree464c3bc8511d6dce5327bcb8bde962ae3f6e0a65 /drivers/hid/wacom_wac.c
parent61e9e7e40a93cfb4a70180beefbbb5bd0c860aeb (diff)
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 <pingc@wacom.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Diffstat (limited to 'drivers/hid/wacom_wac.c')
-rw-r--r--drivers/hid/wacom_wac.c50
1 files changed, 26 insertions, 24 deletions
diff --git a/drivers/hid/wacom_wac.c b/drivers/hid/wacom_wac.c
index 596a6fb5b8b5..527668913a26 100644
--- a/drivers/hid/wacom_wac.c
+++ b/drivers/hid/wacom_wac.c
@@ -534,9 +534,24 @@ static int wacom_intuos_inout(struct wacom_wac *wacom)
534 return 1; 534 return 1;
535 } 535 }
536 536
537 /*
538 * don't report events for invalid data
539 */
537 /* older I4 styli don't work with new Cintiqs */ 540 /* older I4 styli don't work with new Cintiqs */
538 if (!((wacom->id[idx] >> 20) & 0x01) && 541 if ((!((wacom->id[idx] >> 20) & 0x01) &&
539 (features->type == WACOM_21UX2)) 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)))
540 return 1; 555 return 1;
541 556
542 /* Range Report */ 557 /* Range Report */
@@ -553,6 +568,10 @@ static int wacom_intuos_inout(struct wacom_wac *wacom)
553 if (features->quirks & WACOM_QUIRK_MULTI_INPUT) 568 if (features->quirks & WACOM_QUIRK_MULTI_INPUT)
554 wacom->shared->stylus_in_proximity = false; 569 wacom->shared->stylus_in_proximity = false;
555 570
571 /* don't report exit if we don't know the ID */
572 if (!wacom->id[idx])
573 return 1;
574
556 /* 575 /*
557 * Reset all states otherwise we lose the initial states 576 * Reset all states otherwise we lose the initial states
558 * when in-prox next time 577 * when in-prox next time
@@ -585,6 +604,11 @@ static int wacom_intuos_inout(struct wacom_wac *wacom)
585 wacom->id[idx] = 0; 604 wacom->id[idx] = 0;
586 return 2; 605 return 2;
587 } 606 }
607
608 /* don't report other events if we don't know the ID */
609 if (!wacom->id[idx])
610 return 1;
611
588 return 0; 612 return 0;
589} 613}
590 614
@@ -842,28 +866,6 @@ static int wacom_intuos_irq(struct wacom_wac *wacom)
842 if (result) 866 if (result)
843 return result - 1; 867 return result - 1;
844 868
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
867 if (features->type >= INTUOS3S) { 869 if (features->type >= INTUOS3S) {
868 input_report_abs(input, ABS_X, (data[2] << 9) | (data[3] << 1) | ((data[9] >> 1) & 1)); 870 input_report_abs(input, ABS_X, (data[2] << 9) | (data[3] << 1) | ((data[9] >> 1) & 1));
869 input_report_abs(input, ABS_Y, (data[4] << 9) | (data[5] << 1) | (data[9] & 1)); 871 input_report_abs(input, ABS_Y, (data[4] << 9) | (data[5] << 1) | (data[9] & 1));