18 #include <linux/hid.h>
21 #define WACOM_PL_RES 20
22 #define WACOM_PENPRTN_RES 40
23 #define WACOM_VOLITO_RES 50
24 #define WACOM_GRAPHIRE_RES 80
25 #define WACOM_INTUOS_RES 100
26 #define WACOM_INTUOS3_RES 200
31 #define WACOM_CONTACT_AREA_SCALE 2607
43 input_report_key(input, wacom->
tool[0], 1);
44 input_report_abs(input,
ABS_MISC, wacom->
id[0]);
45 input_report_abs(input,
ABS_X, get_unaligned_le16(&data[1]));
46 input_report_abs(input,
ABS_Y, get_unaligned_le16(&data[3]));
47 input_report_abs(input,
ABS_PRESSURE, (
signed char)data[6] + 127);
48 input_report_key(input,
BTN_TOUCH, ((
signed char)data[6] > -127));
49 input_report_key(input,
BTN_STYLUS, (data[5] & 0x40));
51 input_report_key(input, wacom->
tool[0], 0);
52 input_report_abs(input,
ABS_MISC, 0);
61 input_report_abs(input,
ABS_X, get_unaligned_le16(&data[1]));
62 input_report_abs(input,
ABS_Y, get_unaligned_le16(&data[3]));
63 input_report_abs(input,
ABS_PRESSURE, (
signed char)data[6] + 127);
64 input_report_key(input,
BTN_TOUCH, ((
signed char)data[6] > -80) && !(data[5] & 0x20));
65 input_report_key(input,
BTN_STYLUS, (data[5] & 0x40));
70 "%s: received unknown report #%d\n", __func__, data[0]);
86 "%s: received unknown report #%d\n", __func__, data[0]);
90 prox = data[1] & 0x40;
94 pressure = (
signed char)((data[7] << 1) | ((data[4] >> 2) & 1));
96 pressure = (pressure << 1) | ((data[4] >> 6) & 1);
105 if (!wacom->
tool[0]) {
116 input_report_key(input, wacom->
tool[1], 0);
127 input_report_key(input, wacom->
tool[1], prox);
128 input_report_abs(input,
ABS_MISC, wacom->
id[0]);
129 input_report_abs(input,
ABS_X, data[3] | (data[2] << 7) | ((data[1] & 0x03) << 14));
130 input_report_abs(input,
ABS_Y, data[6] | (data[5] << 7) | ((data[4] & 0x03) << 14));
133 input_report_key(input,
BTN_TOUCH, data[4] & 0x08);
134 input_report_key(input,
BTN_STYLUS, data[4] & 0x10);
143 input_report_key(input, wacom->
tool[1], prox);
146 wacom->
tool[0] = prox;
150 static int wacom_ptu_irq(
struct wacom_wac *wacom)
152 unsigned char *data = wacom->
data;
153 struct input_dev *input = wacom->
input;
157 "%s: received unknown report #%d\n", __func__, data[0]);
161 if (data[1] & 0x04) {
163 input_report_key(input,
BTN_TOUCH, data[1] & 0x08);
167 input_report_key(input,
BTN_TOUCH, data[1] & 0x01);
170 input_report_abs(input,
ABS_MISC, wacom->
id[0]);
174 input_report_key(input,
BTN_STYLUS, data[1] & 0x02);
175 input_report_key(input,
BTN_STYLUS2, data[1] & 0x10);
179 static int wacom_dtu_irq(
struct wacom_wac *wacom)
182 char *data = wacom->
data;
183 struct input_dev *input = wacom->
input;
184 int prox = data[1] & 0x20, pressure;
187 "%s: received report #%d", __func__, data[0]);
197 input_report_key(input,
BTN_STYLUS, data[1] & 0x02);
198 input_report_key(input,
BTN_STYLUS2, data[1] & 0x10);
201 pressure = ((data[7] & 0x01) << 8) | data[6];
205 input_report_key(input,
BTN_TOUCH, data[1] & 0x05);
208 input_report_key(input, wacom->
tool[0], prox);
209 input_report_abs(input,
ABS_MISC, wacom->
id[0]);
213 static int wacom_graphire_irq(
struct wacom_wac *wacom)
216 unsigned char *data = wacom->
data;
217 struct input_dev *input = wacom->
input;
224 "%s: received unknown report #%d\n", __func__, data[0]);
228 prox = data[1] & 0x80;
229 if (prox || wacom->
id[0]) {
231 switch ((data[1] >> 5) & 3) {
244 input_report_key(input,
BTN_MIDDLE, data[1] & 0x04);
256 input_report_abs(input,
ABS_PRESSURE, data[6] | ((data[7] & 0x03) << 8));
257 input_report_key(input,
BTN_TOUCH, data[1] & 0x01);
258 input_report_key(input,
BTN_STYLUS, data[1] & 0x02);
259 input_report_key(input,
BTN_STYLUS2, data[1] & 0x04);
261 input_report_key(input,
BTN_LEFT, data[1] & 0x01);
262 input_report_key(input,
BTN_RIGHT, data[1] & 0x02);
266 rw = (data[7] & 0x04) - (data[7] & 0x03);
269 rw = -(
signed char)data[6];
276 input_report_abs(input,
ABS_MISC, wacom->
id[0]);
277 input_report_key(input, wacom->
tool[0], prox);
283 switch (features->
type) {
285 prox = data[7] & 0xf8;
286 if (prox || wacom->
id[1]) {
288 input_report_key(input,
BTN_BACK, (data[7] & 0x40));
289 input_report_key(input,
BTN_FORWARD, (data[7] & 0x80));
290 rw = ((data[7] & 0x18) >> 3) - ((data[7] & 0x20) >> 3);
294 input_report_abs(input,
ABS_MISC, wacom->
id[1]);
301 prox = (data[7] & 0xf8) || data[8];
302 if (prox || wacom->
id[1]) {
304 input_report_key(input,
BTN_BACK, (data[7] & 0x08));
305 input_report_key(input,
BTN_LEFT, (data[7] & 0x20));
306 input_report_key(input,
BTN_FORWARD, (data[7] & 0x10));
307 input_report_key(input,
BTN_RIGHT, (data[7] & 0x40));
308 input_report_abs(input,
ABS_WHEEL, (data[8] & 0x7f));
311 input_report_abs(input,
ABS_MISC, wacom->
id[1]);
321 static int wacom_intuos_inout(
struct wacom_wac *wacom)
324 unsigned char *data = wacom->
data;
325 struct input_dev *input = wacom->
input;
330 idx = data[1] & 0x01;
333 if ((data[1] & 0xfc) == 0xc0) {
335 wacom->
shared->stylus_in_proximity =
true;
338 wacom->
serial[
idx] = ((data[3] & 0x0f) << 28) +
339 (data[4] << 20) + (data[5] << 12) +
340 (data[6] << 4) + (data[7] >> 4);
342 wacom->
id[
idx] = (data[2] << 4) | (data[3] >> 4) |
343 ((data[7] & 0x0f) << 20) | ((data[8] & 0xf0) << 12);
345 switch (wacom->
id[idx] & 0xfffff) {
416 if (!((wacom->
id[idx] >> 20) & 0x01) &&
421 if ((data[1] & 0xfe) == 0x80) {
423 wacom->
shared->stylus_in_proximity =
false;
429 input_report_abs(input,
ABS_X, 0);
430 input_report_abs(input,
ABS_Y, 0);
435 input_report_key(input,
BTN_LEFT, 0);
438 input_report_key(input,
BTN_SIDE, 0);
441 input_report_abs(input,
ABS_RZ, 0);
449 input_report_abs(input,
ABS_Z, 0);
451 input_report_key(input, wacom->
tool[idx], 0);
452 input_report_abs(input,
ABS_MISC, 0);
460 static void wacom_intuos_general(
struct wacom_wac *wacom)
463 unsigned char *data = wacom->
data;
464 struct input_dev *input = wacom->
input;
468 if ((data[1] & 0xb8) == 0xa0) {
469 t = (data[6] << 2) | ((data[7] >> 6) & 3);
473 t = (t << 1) | (data[1] & 1);
477 ((data[7] << 1) & 0x7e) | (data[8] >> 7));
478 input_report_abs(input,
ABS_TILT_Y, data[8] & 0x7f);
479 input_report_key(input,
BTN_STYLUS, data[1] & 2);
481 input_report_key(input,
BTN_TOUCH, t > 10);
485 if ((data[1] & 0xbc) == 0xb4) {
487 (data[6] << 2) | ((data[7] >> 6) & 3));
489 ((data[7] << 1) & 0x7e) | (data[8] >> 7));
490 input_report_abs(input,
ABS_TILT_Y, data[8] & 0x7f);
494 static int wacom_intuos_irq(
struct wacom_wac *wacom)
497 unsigned char *data = wacom->
data;
498 struct input_dev *input = wacom->
input;
508 "%s: received unknown report #%d\n", __func__, data[0]);
514 idx = data[1] & 0x01;
519 input_report_key(input,
BTN_0, (data[2] & 0x01));
520 input_report_key(input,
BTN_1, (data[3] & 0x01));
521 input_report_key(input,
BTN_2, (data[3] & 0x02));
522 input_report_key(input,
BTN_3, (data[3] & 0x04));
523 input_report_key(input,
BTN_4, (data[3] & 0x08));
524 input_report_key(input,
BTN_5, (data[3] & 0x10));
525 input_report_key(input,
BTN_6, (data[3] & 0x20));
526 if (data[1] & 0x80) {
527 input_report_abs(input,
ABS_WHEEL, (data[1] & 0x7f));
533 input_report_key(input,
BTN_7, (data[3] & 0x40));
534 input_report_key(input,
BTN_8, (data[3] & 0x80));
536 if (data[1] | (data[2] & 0x01) | data[3]) {
537 input_report_key(input, wacom->
tool[1], 1);
540 input_report_key(input, wacom->
tool[1], 0);
541 input_report_abs(input,
ABS_MISC, 0);
544 input_report_key(input,
BTN_0, (data[6] & 0x01));
545 input_report_key(input,
BTN_1, (data[6] & 0x02));
546 input_report_key(input,
BTN_2, (data[6] & 0x04));
547 input_report_key(input,
BTN_3, (data[6] & 0x08));
548 input_report_key(input,
BTN_4, (data[6] & 0x10));
549 input_report_key(input,
BTN_5, (data[6] & 0x20));
550 input_report_key(input,
BTN_6, (data[6] & 0x40));
551 input_report_key(input,
BTN_7, (data[6] & 0x80));
552 input_report_key(input,
BTN_8, (data[8] & 0x01));
553 input_report_key(input,
BTN_9, (data[8] & 0x02));
554 input_report_key(input,
BTN_A, (data[8] & 0x04));
555 input_report_key(input,
BTN_B, (data[8] & 0x08));
556 input_report_key(input,
BTN_C, (data[8] & 0x10));
557 input_report_key(input,
BTN_X, (data[8] & 0x20));
558 input_report_key(input,
BTN_Y, (data[8] & 0x40));
559 input_report_key(input,
BTN_Z, (data[8] & 0x80));
568 input_report_key(input,
KEY_PROG1, data[4] & 0x07);
569 input_report_key(input,
KEY_PROG2, data[4] & 0xE0);
570 input_report_key(input,
KEY_PROG3, data[3] & 0x1C);
572 if (data[1] & 0x80) {
573 input_report_abs(input,
ABS_WHEEL, (data[1] & 0x7f));
579 if (data[2] & 0x80) {
580 input_report_abs(input,
ABS_THROTTLE, (data[2] & 0x7f));
586 if (data[1] | data[2] | (data[3] & 0x1f) | data[4] | data[6] | data[8]) {
587 input_report_key(input, wacom->
tool[1], 1);
590 input_report_key(input, wacom->
tool[1], 0);
591 input_report_abs(input,
ABS_MISC, 0);
597 input_report_key(input,
BTN_0, (data[3] & 0x01));
604 for (i = 0; i < 8; i++)
605 input_report_key(input,
BTN_1 + i, data[4] & (1 << i));
607 if (data[2] & 0x80) {
608 input_report_abs(input,
ABS_WHEEL, (data[2] & 0x7f));
614 if (data[2] | (data[3] & 0x01) | data[4] | data[5]) {
615 input_report_key(input, wacom->
tool[1], 1);
618 input_report_key(input, wacom->
tool[1], 0);
619 input_report_abs(input,
ABS_MISC, 0);
623 input_report_key(input,
BTN_0, (data[5] & 0x01));
624 input_report_key(input,
BTN_1, (data[6] & 0x01));
625 input_report_key(input,
BTN_2, (data[6] & 0x02));
626 input_report_key(input,
BTN_3, (data[6] & 0x04));
627 input_report_key(input,
BTN_4, (data[6] & 0x08));
628 input_report_key(input,
BTN_5, (data[6] & 0x10));
629 input_report_key(input,
BTN_6, (data[6] & 0x20));
630 input_report_key(input,
BTN_7, (data[6] & 0x40));
631 input_report_key(input,
BTN_8, (data[6] & 0x80));
632 input_report_key(input,
BTN_9, (data[7] & 0x01));
633 input_report_key(input,
BTN_A, (data[8] & 0x01));
634 input_report_key(input,
BTN_B, (data[8] & 0x02));
635 input_report_key(input,
BTN_C, (data[8] & 0x04));
636 input_report_key(input,
BTN_X, (data[8] & 0x08));
637 input_report_key(input,
BTN_Y, (data[8] & 0x10));
638 input_report_key(input,
BTN_Z, (data[8] & 0x20));
639 input_report_key(input,
BTN_BASE, (data[8] & 0x40));
640 input_report_key(input,
BTN_BASE2, (data[8] & 0x80));
643 input_report_key(input,
KEY_PROG1, data[9] & 0x01);
644 input_report_key(input,
KEY_PROG2, data[9] & 0x02);
645 input_report_key(input,
KEY_PROG3, data[9] & 0x04);
648 input_report_key(input,
BTN_0, (data[5] & 0x01));
649 input_report_key(input,
BTN_1, (data[5] & 0x02));
650 input_report_key(input,
BTN_2, (data[5] & 0x04));
651 input_report_key(input,
BTN_3, (data[5] & 0x08));
652 input_report_key(input,
BTN_4, (data[6] & 0x01));
653 input_report_key(input,
BTN_5, (data[6] & 0x02));
654 input_report_key(input,
BTN_6, (data[6] & 0x04));
655 input_report_key(input,
BTN_7, (data[6] & 0x08));
656 input_report_key(input,
BTN_8, (data[5] & 0x10));
657 input_report_key(input,
BTN_9, (data[6] & 0x10));
659 input_report_abs(input,
ABS_RX, ((data[1] & 0x1f) << 8) | data[2]);
660 input_report_abs(input,
ABS_RY, ((data[3] & 0x1f) << 8) | data[4]);
662 if ((data[5] & 0x1f) | data[6] | (data[1] & 0x1f) |
663 data[2] | (data[3] & 0x1f) | data[4] | data[8] |
665 input_report_key(input, wacom->
tool[1], 1);
668 input_report_key(input, wacom->
tool[1], 0);
669 input_report_abs(input,
ABS_MISC, 0);
677 result = wacom_intuos_inout(wacom);
698 if (features->
type ==
CINTIQ && !(data[1] & 0x40))
702 input_report_abs(input,
ABS_X, (data[2] << 9) | (data[3] << 1) | ((data[9] >> 1) & 1));
703 input_report_abs(input,
ABS_Y, (data[4] << 9) | (data[5] << 1) | (data[9] & 1));
704 input_report_abs(input,
ABS_DISTANCE, ((data[9] >> 2) & 0x3f));
708 input_report_abs(input,
ABS_DISTANCE, ((data[9] >> 3) & 0x1f));
712 wacom_intuos_general(wacom);
715 if ((data[1] & 0xbc) == 0xa8 || (data[1] & 0xbe) == 0xb0 || (data[1] & 0xbc) == 0xac) {
717 if (data[1] & 0x02) {
721 t = (data[6] << 3) | ((data[7] >> 5) & 7);
722 t = (data[7] & 0x20) ? ((t > 900) ? ((t-1) / 2 - 1350) :
723 ((t-1) / 2 + 450)) : (450 - t / 2) ;
724 input_report_abs(input,
ABS_Z, t);
727 t = (data[6] << 3) | ((data[7] >> 5) & 7);
728 input_report_abs(input,
ABS_RZ, (data[7] & 0x20) ?
729 ((t - 1) / 2) : -t / 2);
732 }
else if (!(data[1] & 0x10) && features->
type <
INTUOS3S) {
734 input_report_key(input,
BTN_LEFT, data[8] & 0x01);
735 input_report_key(input,
BTN_MIDDLE, data[8] & 0x02);
736 input_report_key(input,
BTN_RIGHT, data[8] & 0x04);
738 input_report_key(input,
BTN_SIDE, data[8] & 0x20);
739 input_report_key(input,
BTN_EXTRA, data[8] & 0x10);
740 t = (data[6] << 2) | ((data[7] >> 6) & 3);
741 input_report_abs(input,
ABS_THROTTLE, (data[8] & 0x08) ? -t : t);
747 input_report_key(input,
BTN_LEFT, data[6] & 0x01);
748 input_report_key(input,
BTN_MIDDLE, data[6] & 0x02);
749 input_report_key(input,
BTN_RIGHT, data[6] & 0x04);
750 input_report_rel(input,
REL_WHEEL, ((data[7] & 0x80) >> 7)
751 - ((data[7] & 0x40) >> 6));
752 input_report_key(input,
BTN_SIDE, data[6] & 0x08);
753 input_report_key(input,
BTN_EXTRA, data[6] & 0x10);
756 ((data[7] << 1) & 0x7e) | (data[8] >> 7));
757 input_report_abs(input,
ABS_TILT_Y, data[8] & 0x7f);
760 input_report_key(input,
BTN_LEFT, data[8] & 0x04);
761 input_report_key(input,
BTN_MIDDLE, data[8] & 0x08);
762 input_report_key(input,
BTN_RIGHT, data[8] & 0x10);
763 input_report_rel(input,
REL_WHEEL, (data[8] & 0x01)
764 - ((data[8] & 0x02) >> 1));
768 input_report_key(input,
BTN_SIDE, data[8] & 0x40);
769 input_report_key(input,
BTN_EXTRA, data[8] & 0x20);
776 input_report_key(input,
BTN_LEFT, data[8] & 0x01);
777 input_report_key(input,
BTN_MIDDLE, data[8] & 0x02);
778 input_report_key(input,
BTN_RIGHT, data[8] & 0x04);
779 input_report_key(input,
BTN_SIDE, data[8] & 0x10);
780 input_report_key(input,
BTN_EXTRA, data[8] & 0x08);
784 input_report_abs(input,
ABS_MISC, wacom->
id[idx]);
785 input_report_key(input, wacom->
tool[idx], 1);
790 static int find_slot_from_contactid(
struct wacom_wac *wacom,
int contactid)
792 int touch_max = wacom->
features.touch_max;
798 for (i = 0; i < touch_max; ++
i) {
799 if (wacom->
slots[i] == contactid)
802 for (i = 0; i < touch_max; ++
i) {
803 if (wacom->
slots[i] == -1)
809 static int int_dist(
int x1,
int y1,
int x2,
int y2)
817 static int wacom_24hdt_irq(
struct wacom_wac *wacom)
819 struct input_dev *input = wacom->
input;
820 char *data = wacom->
data;
822 int current_num_contacts = data[61];
823 int contacts_to_send = 0;
829 if (current_num_contacts)
835 for (i = 0; i < contacts_to_send; i++) {
837 bool touch = data[
offset] & 0x1 && !wacom->
shared->stylus_in_proximity;
838 int id = data[offset + 1];
839 int slot = find_slot_from_contactid(wacom,
id);
873 static int wacom_mt_touch(
struct wacom_wac *wacom)
875 struct input_dev *input = wacom->
input;
876 char *data = wacom->
data;
878 int current_num_contacts = data[2];
879 int contacts_to_send = 0;
885 if (current_num_contacts)
891 for (i = 0; i < contacts_to_send; i++) {
893 bool touch = data[
offset] & 0x1;
895 int slot = find_slot_from_contactid(wacom,
id);
920 static int wacom_tpc_mt_touch(
struct wacom_wac *wacom)
922 struct input_dev *input = wacom->
input;
923 unsigned char *data = wacom->
data;
924 int contact_with_no_pen_down_count = 0;
927 for (i = 0; i < 2; i++) {
928 int p = data[1] & (1 <<
i);
929 bool touch = p && !wacom->
shared->stylus_in_proximity;
939 contact_with_no_pen_down_count++;
944 wacom->
shared->touch_down = (contact_with_no_pen_down_count > 0);
951 static int wacom_tpc_single_touch(
struct wacom_wac *wacom,
size_t len)
953 char *data = wacom->
data;
954 struct input_dev *input = wacom->
input;
961 if (!wacom->
shared->stylus_in_proximity) {
963 prox = data[0] & 0x01;
964 x = get_unaligned_le16(&data[1]);
965 y = get_unaligned_le16(&data[3]);
967 prox = data[1] & 0x01;
976 input_report_abs(input,
ABS_X, x);
977 input_report_abs(input,
ABS_Y,
y);
979 input_report_key(input,
BTN_TOUCH, prox);
982 wacom->
shared->touch_down = prox;
987 static int wacom_tpc_pen(
struct wacom_wac *wacom)
990 char *data = wacom->
data;
991 struct input_dev *input = wacom->
input;
993 bool prox = data[1] & 0x20;
995 if (!wacom->
shared->stylus_in_proximity)
1000 wacom->
shared->stylus_in_proximity = prox;
1003 if (!wacom->
shared->touch_down) {
1004 input_report_key(input,
BTN_STYLUS, data[1] & 0x02);
1005 input_report_key(input,
BTN_STYLUS2, data[1] & 0x10);
1008 pressure = ((data[7] & 0x01) << 8) | data[6];
1012 input_report_key(input,
BTN_TOUCH, data[1] & 0x05);
1013 input_report_key(input, wacom->
tool[0], prox);
1020 static int wacom_tpc_irq(
struct wacom_wac *wacom,
size_t len)
1022 char *data = wacom->
data;
1025 "%s: received report #%d\n", __func__, data[0]);
1029 return wacom_tpc_single_touch(wacom, len);
1032 return wacom_tpc_mt_touch(wacom);
1040 return wacom_tpc_single_touch(wacom, len);
1043 return wacom_mt_touch(wacom);
1046 return wacom_tpc_pen(wacom);
1053 static int wacom_bpt_touch(
struct wacom_wac *wacom)
1056 struct input_dev *input = wacom->
input;
1057 unsigned char *data = wacom->
data;
1060 if (data[0] != 0x02)
1063 for (i = 0; i < 2; i++) {
1064 int offset = (data[1] & 0x80) ? (8 * i) : (9 *
i);
1065 bool touch = data[offset + 3] & 0x80;
1073 touch = touch && !wacom->
shared->stylus_in_proximity;
1078 int x = get_unaligned_be16(&data[offset + 3]) & 0x7ff;
1079 int y = get_unaligned_be16(&data[offset + 5]) & 0x7ff;
1091 input_report_key(input,
BTN_LEFT, (data[1] & 0x08) != 0);
1092 input_report_key(input,
BTN_FORWARD, (data[1] & 0x04) != 0);
1093 input_report_key(input,
BTN_BACK, (data[1] & 0x02) != 0);
1094 input_report_key(input,
BTN_RIGHT, (data[1] & 0x01) != 0);
1101 static void wacom_bpt3_touch_msg(
struct wacom_wac *wacom,
unsigned char *data)
1103 struct input_dev *input = wacom->
input;
1104 int slot_id = data[0] - 2;
1105 bool touch = data[1] & 0x80;
1107 touch = touch && !wacom->
shared->stylus_in_proximity;
1113 int x = (data[2] << 4) | (data[4] >> 4);
1114 int y = (data[3] << 4) | (data[4] & 0x0f);
1131 static void wacom_bpt3_button_msg(
struct wacom_wac *wacom,
unsigned char *data)
1133 struct input_dev *input = wacom->
input;
1135 input_report_key(input,
BTN_LEFT, (data[1] & 0x08) != 0);
1136 input_report_key(input,
BTN_FORWARD, (data[1] & 0x04) != 0);
1137 input_report_key(input,
BTN_BACK, (data[1] & 0x02) != 0);
1138 input_report_key(input,
BTN_RIGHT, (data[1] & 0x01) != 0);
1141 static int wacom_bpt3_touch(
struct wacom_wac *wacom)
1143 struct input_dev *input = wacom->
input;
1144 unsigned char *data = wacom->
data;
1145 int count = data[1] & 0x07;
1148 if (data[0] != 0x02)
1152 for (i = 0; i <
count; i++) {
1153 int offset = (8 *
i) + 2;
1154 int msg_id = data[
offset];
1156 if (msg_id >= 2 && msg_id <= 17)
1157 wacom_bpt3_touch_msg(wacom, data + offset);
1158 else if (msg_id == 128)
1159 wacom_bpt3_button_msg(wacom, data + offset);
1170 static int wacom_bpt_pen(
struct wacom_wac *wacom)
1172 struct input_dev *input = wacom->
input;
1173 unsigned char *data = wacom->
data;
1174 int prox = 0, x = 0,
y = 0, p = 0,
d = 0, pen = 0, btn1 = 0, btn2 = 0;
1176 if (data[0] != 0x02)
1179 prox = (data[1] & 0x20) == 0x20;
1192 if (!wacom->
shared->stylus_in_proximity) {
1193 if (data[1] & 0x08) {
1200 wacom->
shared->stylus_in_proximity =
true;
1211 if (data[8] <= wacom->
features.distance_max)
1212 d = wacom->
features.distance_max - data[8];
1214 pen = data[1] & 0x01;
1215 btn1 = data[1] & 0x02;
1216 btn2 = data[1] & 0x04;
1219 input_report_key(input,
BTN_TOUCH, pen);
1223 input_report_abs(input,
ABS_X, x);
1224 input_report_abs(input,
ABS_Y,
y);
1230 wacom->
shared->stylus_in_proximity =
false;
1233 input_report_key(input, wacom->
tool[0], prox);
1234 input_report_abs(input,
ABS_MISC, wacom->
id[0]);
1239 static int wacom_bpt_irq(
struct wacom_wac *wacom,
size_t len)
1242 return wacom_bpt_touch(wacom);
1244 return wacom_bpt3_touch(wacom);
1246 return wacom_bpt_pen(wacom);
1251 static int wacom_wireless_irq(
struct wacom_wac *wacom,
size_t len)
1253 unsigned char *data = wacom->
data;
1259 connected = data[1] & 0x01;
1263 pid = get_unaligned_be16(&data[6]);
1264 battery = data[5] & 0x3f;
1265 if (wacom->
pid != pid) {
1267 wacom_schedule_work(wacom);
1270 }
else if (wacom->
pid != 0) {
1273 wacom_schedule_work(wacom);
1284 switch (wacom_wac->
features.type) {
1286 sync = wacom_penpartner_irq(wacom_wac);
1290 sync = wacom_pl_irq(wacom_wac);
1296 sync = wacom_graphire_irq(wacom_wac);
1300 sync = wacom_ptu_irq(wacom_wac);
1304 sync = wacom_dtu_irq(wacom_wac);
1319 sync = wacom_intuos_irq(wacom_wac);
1323 sync = wacom_24hdt_irq(wacom_wac);
1330 sync = wacom_bpt3_touch(wacom_wac);
1332 sync = wacom_intuos_irq(wacom_wac);
1339 sync = wacom_tpc_irq(wacom_wac, len);
1343 sync = wacom_bpt_irq(wacom_wac, len);
1347 sync = wacom_wireless_irq(wacom_wac, len);
1356 input_sync(wacom_wac->
input);
1361 struct input_dev *input_dev = wacom_wac->
input;
1374 0, wacom_wac->
features.distance_max, 0, 0);
1375 input_set_abs_params(input_dev,
ABS_WHEEL, 0, 1023, 0, 0);
1376 input_set_abs_params(input_dev,
ABS_TILT_X, 0, 127, 0, 0);
1377 input_set_abs_params(input_dev,
ABS_TILT_Y, 0, 127, 0, 0);
1382 struct input_dev *input_dev = wacom_wac->
input;
1386 wacom_setup_cintiq(wacom_wac);
1396 input_set_abs_params(input_dev,
ABS_RZ, -900, 899, 0, 0);
1397 input_set_abs_params(input_dev,
ABS_THROTTLE, -1023, 1023, 0, 0);
1405 features->
x_max = 1023;
1406 features->
y_max = 1023;
1412 (features->
oVid && features->
oPid))
1418 features->
x_max <<= 5;
1419 features->
y_max <<= 5;
1436 static unsigned int wacom_calculate_touch_res(
unsigned int logical_max,
1437 unsigned int physical_max)
1440 return (logical_max * 100) / physical_max;
1453 input_set_abs_params(input_dev,
ABS_X, 0, features->
x_max,
1455 input_set_abs_params(input_dev,
ABS_Y, 0, features->
y_max,
1466 input_abs_set_res(input_dev,
ABS_X,
1467 wacom_calculate_touch_res(features->
x_max,
1469 input_abs_set_res(input_dev,
ABS_Y,
1470 wacom_calculate_touch_res(features->
y_max,
1476 switch (wacom_wac->
features.type) {
1478 input_set_abs_params(input_dev,
ABS_WHEEL, 0, 71, 0, 0);
1512 for (i = 0; i < 10; i++)
1519 input_set_abs_params(input_dev,
ABS_Z, -900, 899, 0, 0);
1520 input_set_abs_params(input_dev,
ABS_THROTTLE, 0, 71, 0, 0);
1524 wacom_setup_cintiq(wacom_wac);
1550 for (i = 0; i < 8; i++)
1553 input_set_abs_params(input_dev,
ABS_RX, 0, 4096, 0, 0);
1554 input_set_abs_params(input_dev,
ABS_RY, 0, 4096, 0, 0);
1555 input_set_abs_params(input_dev,
ABS_Z, -900, 899, 0, 0);
1559 wacom_setup_cintiq(wacom_wac);
1569 input_set_abs_params(input_dev,
ABS_RY, 0, 4096, 0, 0);
1578 input_set_abs_params(input_dev,
ABS_RX, 0, 4096, 0, 0);
1579 input_set_abs_params(input_dev,
ABS_Z, -900, 899, 0, 0);
1585 wacom_setup_intuos(wacom_wac);
1600 for (i = 0; i < 7; i++)
1607 input_set_abs_params(input_dev,
ABS_Z, -900, 899, 0, 0);
1609 wacom_setup_intuos(wacom_wac);
1621 0, features->
x_max, 0, 0);
1623 0, features->
y_max, 0, 0);
1641 for (i = 0; i < 7; i++)
1644 input_set_abs_params(input_dev,
ABS_Z, -900, 899, 0, 0);
1645 wacom_setup_intuos(wacom_wac);
1664 if (!wacom_wac->
slots)
1667 for (i = 0; i < features->
touch_max; i++)
1668 wacom_wac->
slots[i] = -1;
1678 0, features->
x_max, 0, 0);
1680 0, features->
y_max, 0, 0);
1738 input_set_abs_params(input_dev,
1740 0, features->
x_max, 0, 0);
1741 input_set_abs_params(input_dev,
1743 0, features->
y_max, 0, 0);
2026 0,
WIRELESS, 0, 0, .touch_max = 16 };
2083 #define USB_DEVICE_WACOM(prod) \
2084 USB_DEVICE(USB_VENDOR_ID_WACOM, prod), \
2085 .driver_info = (kernel_ulong_t)&wacom_features_##prod
2087 #define USB_DEVICE_DETAILED(prod, class, sub, proto) \
2088 USB_DEVICE_AND_INTERFACE_INFO(USB_VENDOR_ID_WACOM, prod, class, \
2090 .driver_info = (kernel_ulong_t)&wacom_features_##prod
2092 #define USB_DEVICE_LENOVO(prod) \
2093 USB_DEVICE(USB_VENDOR_ID_LENOVO, prod), \
2094 .driver_info = (kernel_ulong_t)&wacom_features_##prod