hc
2024-01-05 071106ecf68c401173c58808b1cf5f68cc50d390
kernel/drivers/hid/wacom_wac.c
....@@ -1,20 +1,17 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * drivers/input/tablet/wacom_wac.c
34 *
45 * USB Wacom tablet support - Wacom specific code
5
- *
66 */
77
88 /*
9
- * This program is free software; you can redistribute it and/or modify
10
- * it under the terms of the GNU General Public License as published by
11
- * the Free Software Foundation; either version 2 of the License, or
12
- * (at your option) any later version.
139 */
1410
1511 #include "wacom_wac.h"
1612 #include "wacom.h"
1713 #include <linux/input/mt.h>
14
+#include <linux/jiffies.h>
1815
1916 /* resolution for penabled devices */
2017 #define WACOM_PL_RES 20
....@@ -45,6 +42,43 @@
4542
4643 static void wacom_update_led(struct wacom *wacom, int button_count, int mask,
4744 int group);
45
+
46
+static void wacom_force_proxout(struct wacom_wac *wacom_wac)
47
+{
48
+ struct input_dev *input = wacom_wac->pen_input;
49
+
50
+ wacom_wac->shared->stylus_in_proximity = 0;
51
+
52
+ input_report_key(input, BTN_TOUCH, 0);
53
+ input_report_key(input, BTN_STYLUS, 0);
54
+ input_report_key(input, BTN_STYLUS2, 0);
55
+ input_report_key(input, BTN_STYLUS3, 0);
56
+ input_report_key(input, wacom_wac->tool[0], 0);
57
+ if (wacom_wac->serial[0]) {
58
+ input_report_abs(input, ABS_MISC, 0);
59
+ }
60
+ input_report_abs(input, ABS_PRESSURE, 0);
61
+
62
+ wacom_wac->tool[0] = 0;
63
+ wacom_wac->id[0] = 0;
64
+ wacom_wac->serial[0] = 0;
65
+
66
+ input_sync(input);
67
+}
68
+
69
+void wacom_idleprox_timeout(struct timer_list *list)
70
+{
71
+ struct wacom *wacom = from_timer(wacom, list, idleprox_timer);
72
+ struct wacom_wac *wacom_wac = &wacom->wacom_wac;
73
+
74
+ if (!wacom_wac->hid_data.sense_state) {
75
+ return;
76
+ }
77
+
78
+ hid_warn(wacom->hdev, "%s: tool appears to be hung in-prox. forcing it out.\n", __func__);
79
+ wacom_force_proxout(wacom_wac);
80
+}
81
+
4882 /*
4983 * Percent of battery capacity for Graphire.
5084 * 8th value means AC online and show 100% capacity.
....@@ -345,7 +379,7 @@
345379
346380 case 2: /* Mouse with wheel */
347381 input_report_key(input, BTN_MIDDLE, data[1] & 0x04);
348
- /* fall through */
382
+ fallthrough;
349383
350384 case 3: /* Mouse without wheel */
351385 wacom->tool[0] = BTN_TOOL_MOUSE;
....@@ -487,6 +521,8 @@
487521 int ring1 = 0, ring2 = 0;
488522 int strip1 = 0, strip2 = 0;
489523 bool prox = false;
524
+ bool wrench = false, keyboard = false, mute_touch = false, menu = false,
525
+ info = false;
490526
491527 /* pad packets. Works as a second tool and is always in prox */
492528 if (!(data[0] == WACOM_REPORT_INTUOSPAD || data[0] == WACOM_REPORT_INTUOS5PAD ||
....@@ -516,10 +552,32 @@
516552 keys = ((data[3] & 0x1C) ? 1<<2 : 0) |
517553 ((data[4] & 0xE0) ? 1<<1 : 0) |
518554 ((data[4] & 0x07) ? 1<<0 : 0);
555
+ keyboard = !!(data[4] & 0xE0);
556
+ info = !!(data[3] & 0x1C);
557
+
558
+ if (features->oPid) {
559
+ mute_touch = !!(data[4] & 0x07);
560
+ if (mute_touch)
561
+ wacom->shared->is_touch_on =
562
+ !wacom->shared->is_touch_on;
563
+ } else {
564
+ wrench = !!(data[4] & 0x07);
565
+ }
519566 } else if (features->type == WACOM_27QHD) {
520567 nkeys = 3;
521568 keys = data[2] & 0x07;
522569
570
+ wrench = !!(data[2] & 0x01);
571
+ keyboard = !!(data[2] & 0x02);
572
+
573
+ if (features->oPid) {
574
+ mute_touch = !!(data[2] & 0x04);
575
+ if (mute_touch)
576
+ wacom->shared->is_touch_on =
577
+ !wacom->shared->is_touch_on;
578
+ } else {
579
+ menu = !!(data[2] & 0x04);
580
+ }
523581 input_report_abs(input, ABS_X, be16_to_cpup((__be16 *)&data[4]));
524582 input_report_abs(input, ABS_Y, be16_to_cpup((__be16 *)&data[6]));
525583 input_report_abs(input, ABS_Z, be16_to_cpup((__be16 *)&data[8]));
....@@ -565,6 +623,9 @@
565623 if (features->type == WACOM_22HD) {
566624 nkeys = 3;
567625 keys = data[9] & 0x07;
626
+
627
+ info = !!(data[9] & 0x01);
628
+ wrench = !!(data[9] & 0x02);
568629 }
569630 } else {
570631 buttons = ((data[6] & 0x10) << 5) |
....@@ -583,6 +644,18 @@
583644
584645 for (i = 0; i < nkeys; i++)
585646 input_report_key(input, KEY_PROG1 + i, keys & (1 << i));
647
+
648
+ input_report_key(input, KEY_BUTTONCONFIG, wrench);
649
+ input_report_key(input, KEY_ONSCREEN_KEYBOARD, keyboard);
650
+ input_report_key(input, KEY_CONTROLPANEL, menu);
651
+ input_report_key(input, KEY_INFO, info);
652
+
653
+ if (wacom->shared && wacom->shared->touch_input) {
654
+ input_report_switch(wacom->shared->touch_input,
655
+ SW_MUTE_DEVICE,
656
+ !wacom->shared->is_touch_on);
657
+ input_sync(wacom->shared->touch_input);
658
+ }
586659
587660 input_report_abs(input, ABS_RX, strip1);
588661 input_report_abs(input, ABS_RY, strip2);
....@@ -603,9 +676,26 @@
603676 return (tool_id & ~0xFFF) << 4 | (tool_id & 0xFFF);
604677 }
605678
679
+static bool wacom_is_art_pen(int tool_id)
680
+{
681
+ bool is_art_pen = false;
682
+
683
+ switch (tool_id) {
684
+ case 0x885: /* Intuos3 Marker Pen */
685
+ case 0x804: /* Intuos4/5 13HD/24HD Marker Pen */
686
+ case 0x10804: /* Intuos4/5 13HD/24HD Art Pen */
687
+ is_art_pen = true;
688
+ break;
689
+ }
690
+ return is_art_pen;
691
+}
692
+
606693 static int wacom_intuos_get_tool_type(int tool_id)
607694 {
608
- int tool_type;
695
+ int tool_type = BTN_TOOL_PEN;
696
+
697
+ if (wacom_is_art_pen(tool_id))
698
+ return tool_type;
609699
610700 switch (tool_id) {
611701 case 0x812: /* Inking pen */
....@@ -620,16 +710,17 @@
620710 case 0x852:
621711 case 0x823: /* Intuos3 Grip Pen */
622712 case 0x813: /* Intuos3 Classic Pen */
623
- case 0x885: /* Intuos3 Marker Pen */
624713 case 0x802: /* Intuos4/5 13HD/24HD General Pen */
625
- case 0x804: /* Intuos4/5 13HD/24HD Marker Pen */
626714 case 0x8e2: /* IntuosHT2 pen */
627715 case 0x022:
628
- case 0x10804: /* Intuos4/5 13HD/24HD Art Pen */
716
+ case 0x200: /* Pro Pen 3 */
717
+ case 0x04200: /* Pro Pen 3 */
718
+ case 0x10842: /* MobileStudio Pro Pro Pen slim */
629719 case 0x14802: /* Intuos4/5 13HD/24HD Classic Pen */
630720 case 0x16802: /* Cintiq 13HD Pro Pen */
631721 case 0x18802: /* DTH2242 Pen */
632722 case 0x10802: /* Intuos4/5 13HD/24HD General Pen */
723
+ case 0x80842: /* Intuos Pro and Cintiq Pro 3D Pen */
633724 tool_type = BTN_TOOL_PEN;
634725 break;
635726
....@@ -667,6 +758,7 @@
667758 case 0x1480a: /* Intuos4/5 13HD/24HD Classic Pen Eraser */
668759 case 0x1090a: /* Intuos4/5 13HD/24HD Airbrush Eraser */
669760 case 0x1080c: /* Intuos4/5 13HD/24HD Art Pen Eraser */
761
+ case 0x1084a: /* MobileStudio Pro Pro Pen slim Eraser */
670762 case 0x1680a: /* Cintiq 13HD Pro Pen Eraser */
671763 case 0x1880a: /* DTH2242 Eraser */
672764 case 0x1080a: /* Intuos4/5 13HD/24HD General Pen Eraser */
....@@ -680,10 +772,6 @@
680772 case 0x902: /* Intuos4/5 13HD/24HD Airbrush */
681773 case 0x10902: /* Intuos4/5 13HD/24HD Airbrush */
682774 tool_type = BTN_TOOL_AIRBRUSH;
683
- break;
684
-
685
- default: /* Unknown tool */
686
- tool_type = BTN_TOOL_PEN;
687775 break;
688776 }
689777 return tool_type;
....@@ -743,7 +831,7 @@
743831 /* Enter report */
744832 if ((data[1] & 0xfc) == 0xc0) {
745833 /* serial number of the tool */
746
- wacom->serial[idx] = ((data[3] & 0x0f) << 28) +
834
+ wacom->serial[idx] = ((__u64)(data[3] & 0x0f) << 28) +
747835 (data[4] << 20) + (data[5] << 12) +
748836 (data[6] << 4) + (data[7] >> 4);
749837
....@@ -1039,6 +1127,7 @@
10391127 if (index < 0 || !remote->remotes[index].registered)
10401128 goto out;
10411129
1130
+ remote->remotes[i].active_time = ktime_get();
10421131 input = remote->remotes[index].input;
10431132
10441133 input_report_key(input, BTN_0, (data[9] & 0x01));
....@@ -1164,7 +1253,7 @@
11641253 case 0x04:
11651254 wacom_intuos_bt_process_data(wacom, data + i);
11661255 i += 10;
1167
- /* fall through */
1256
+ fallthrough;
11681257 case 0x03:
11691258 wacom_intuos_bt_process_data(wacom, data + i);
11701259 i += 10;
....@@ -1218,9 +1307,13 @@
12181307
12191308 struct input_dev *pen_input = wacom->pen_input;
12201309 unsigned char *data = wacom->data;
1310
+ int number_of_valid_frames = 0;
1311
+ ktime_t time_interval = 15000000;
1312
+ ktime_t time_packet_received = ktime_get();
12211313 int i;
12221314
1223
- if (wacom->features.type == INTUOSP2_BT) {
1315
+ if (wacom->features.type == INTUOSP2_BT ||
1316
+ wacom->features.type == INTUOSP2S_BT) {
12241317 wacom->serial[0] = get_unaligned_le64(&data[99]);
12251318 wacom->id[0] = get_unaligned_le16(&data[107]);
12261319 pen_frame_len = 14;
....@@ -1237,12 +1330,30 @@
12371330 wacom->id[0] |= (wacom->serial[0] >> 32) & 0xFFFFF;
12381331 }
12391332
1333
+ /* number of valid frames */
12401334 for (i = 0; i < pen_frames; i++) {
1335
+ unsigned char *frame = &data[i*pen_frame_len + 1];
1336
+ bool valid = frame[0] & 0x80;
1337
+
1338
+ if (valid)
1339
+ number_of_valid_frames++;
1340
+ }
1341
+
1342
+ if (number_of_valid_frames) {
1343
+ if (wacom->hid_data.time_delayed)
1344
+ time_interval = ktime_get() - wacom->hid_data.time_delayed;
1345
+ time_interval = div_u64(time_interval, number_of_valid_frames);
1346
+ wacom->hid_data.time_delayed = time_packet_received;
1347
+ }
1348
+
1349
+ for (i = 0; i < number_of_valid_frames; i++) {
12411350 unsigned char *frame = &data[i*pen_frame_len + 1];
12421351 bool valid = frame[0] & 0x80;
12431352 bool prox = frame[0] & 0x40;
12441353 bool range = frame[0] & 0x20;
12451354 bool invert = frame[0] & 0x10;
1355
+ int frames_number_reversed = number_of_valid_frames - i - 1;
1356
+ ktime_t event_timestamp = time_packet_received - frames_number_reversed * time_interval;
12461357
12471358 if (!valid)
12481359 continue;
....@@ -1255,6 +1366,7 @@
12551366 wacom->tool[0] = 0;
12561367 wacom->id[0] = 0;
12571368 wacom->serial[0] = 0;
1369
+ wacom->hid_data.time_delayed = 0;
12581370 return;
12591371 }
12601372
....@@ -1272,7 +1384,8 @@
12721384 input_report_abs(pen_input, ABS_X, get_unaligned_le16(&frame[1]));
12731385 input_report_abs(pen_input, ABS_Y, get_unaligned_le16(&frame[3]));
12741386
1275
- if (wacom->features.type == INTUOSP2_BT) {
1387
+ if (wacom->features.type == INTUOSP2_BT ||
1388
+ wacom->features.type == INTUOSP2S_BT) {
12761389 /* Fix rotation alignment: userspace expects zero at left */
12771390 int16_t rotation =
12781391 (int16_t)get_unaligned_le16(&frame[9]);
....@@ -1293,7 +1406,8 @@
12931406
12941407 if (wacom->tool[0]) {
12951408 input_report_abs(pen_input, ABS_PRESSURE, get_unaligned_le16(&frame[5]));
1296
- if (wacom->features.type == INTUOSP2_BT) {
1409
+ if (wacom->features.type == INTUOSP2_BT ||
1410
+ wacom->features.type == INTUOSP2S_BT) {
12971411 input_report_abs(pen_input, ABS_DISTANCE,
12981412 range ? frame[13] : wacom->features.distance_max);
12991413 } else {
....@@ -1312,6 +1426,9 @@
13121426 }
13131427
13141428 wacom->shared->stylus_in_proximity = prox;
1429
+
1430
+ /* add timestamp to unpack the frames */
1431
+ input_set_timestamp(pen_input, event_timestamp);
13151432
13161433 input_sync(pen_input);
13171434 }
....@@ -1388,11 +1505,13 @@
13881505 {
13891506 struct input_dev *pad_input = wacom->pad_input;
13901507 unsigned char *data = wacom->data;
1508
+ int nbuttons = wacom->features.numbered_buttons;
13911509
1392
- int buttons = data[282] | ((data[281] & 0x40) << 2);
1510
+ int expresskeys = data[282];
1511
+ int center = (data[281] & 0x40) >> 6;
13931512 int ring = data[285] & 0x7F;
13941513 bool ringstatus = data[285] & 0x80;
1395
- bool prox = buttons || ringstatus;
1514
+ bool prox = expresskeys || center || ringstatus;
13961515
13971516 /* Fix touchring data: userspace expects 0 at left and increasing clockwise */
13981517 ring = 71 - ring;
....@@ -1400,7 +1519,8 @@
14001519 if (ring > 71)
14011520 ring -= 72;
14021521
1403
- wacom_report_numbered_buttons(pad_input, 9, buttons);
1522
+ wacom_report_numbered_buttons(pad_input, nbuttons,
1523
+ expresskeys | (center << (nbuttons - 1)));
14041524
14051525 input_report_abs(pad_input, ABS_WHEEL, ringstatus ? ring : 0);
14061526
....@@ -1460,7 +1580,8 @@
14601580 }
14611581
14621582 wacom_intuos_pro2_bt_pen(wacom);
1463
- if (wacom->features.type == INTUOSP2_BT) {
1583
+ if (wacom->features.type == INTUOSP2_BT ||
1584
+ wacom->features.type == INTUOSP2S_BT) {
14641585 wacom_intuos_pro2_bt_touch(wacom);
14651586 wacom_intuos_pro2_bt_pad(wacom);
14661587 wacom_intuos_pro2_bt_battery(wacom);
....@@ -1481,6 +1602,12 @@
14811602 int num_contacts_left = 4; /* maximum contacts per packet */
14821603 int byte_per_packet = WACOM_BYTES_PER_24HDT_PACKET;
14831604 int y_offset = 2;
1605
+
1606
+ if (wacom->shared->has_mute_touch_switch &&
1607
+ !wacom->shared->is_touch_on) {
1608
+ if (!wacom->shared->touch_down)
1609
+ return 0;
1610
+ }
14841611
14851612 if (wacom->features.type == WACOM_27QHDT) {
14861613 current_num_contacts = data[63];
....@@ -1772,6 +1899,9 @@
17721899 int subpage = (usage & 0xFF00) << 8;
17731900 int subusage = (usage & 0xFF);
17741901
1902
+ if (usage == WACOM_HID_WT_REPORT_VALID)
1903
+ return usage;
1904
+
17751905 if (subpage == HID_UP_UNDEFINED)
17761906 subpage = WACOM_HID_SP_DIGITIZER;
17771907
....@@ -1791,6 +1921,7 @@
17911921 int fmax = field->logical_maximum;
17921922 unsigned int equivalent_usage = wacom_equivalent_usage(usage->hid);
17931923 int resolution_code = code;
1924
+ int resolution = hidinput_calc_abs_res(field, resolution_code);
17941925
17951926 if (equivalent_usage == HID_DG_TWIST) {
17961927 resolution_code = ABS_RZ;
....@@ -1813,8 +1944,15 @@
18131944 switch (type) {
18141945 case EV_ABS:
18151946 input_set_abs_params(input, code, fmin, fmax, fuzz, 0);
1816
- input_abs_set_res(input, code,
1817
- hidinput_calc_abs_res(field, resolution_code));
1947
+
1948
+ /* older tablet may miss physical usage */
1949
+ if ((code == ABS_X || code == ABS_Y) && !resolution) {
1950
+ resolution = WACOM_INTUOS_RES;
1951
+ hid_warn(input,
1952
+ "Wacom usage (%d) missing resolution \n",
1953
+ code);
1954
+ }
1955
+ input_abs_set_res(input, code, resolution);
18181956 break;
18191957 case EV_KEY:
18201958 input_set_capability(input, EV_KEY, code);
....@@ -1831,18 +1969,7 @@
18311969 static void wacom_wac_battery_usage_mapping(struct hid_device *hdev,
18321970 struct hid_field *field, struct hid_usage *usage)
18331971 {
1834
- struct wacom *wacom = hid_get_drvdata(hdev);
1835
- struct wacom_wac *wacom_wac = &wacom->wacom_wac;
1836
- struct wacom_features *features = &wacom_wac->features;
1837
- unsigned equivalent_usage = wacom_equivalent_usage(usage->hid);
1838
-
1839
- switch (equivalent_usage) {
1840
- case HID_DG_BATTERYSTRENGTH:
1841
- case WACOM_HID_WD_BATTERY_LEVEL:
1842
- case WACOM_HID_WD_BATTERY_CHARGING:
1843
- features->quirks |= WACOM_QUIRK_BATTERY;
1844
- break;
1845
- }
1972
+ return;
18461973 }
18471974
18481975 static void wacom_wac_battery_event(struct hid_device *hdev, struct hid_field *field,
....@@ -1863,18 +1990,21 @@
18631990 wacom_wac->hid_data.bat_connected = 1;
18641991 wacom_wac->hid_data.bat_status = WACOM_POWER_SUPPLY_STATUS_AUTO;
18651992 }
1993
+ wacom_wac->features.quirks |= WACOM_QUIRK_BATTERY;
18661994 break;
18671995 case WACOM_HID_WD_BATTERY_LEVEL:
18681996 value = value * 100 / (field->logical_maximum - field->logical_minimum);
18691997 wacom_wac->hid_data.battery_capacity = value;
18701998 wacom_wac->hid_data.bat_connected = 1;
18711999 wacom_wac->hid_data.bat_status = WACOM_POWER_SUPPLY_STATUS_AUTO;
2000
+ wacom_wac->features.quirks |= WACOM_QUIRK_BATTERY;
18722001 break;
18732002 case WACOM_HID_WD_BATTERY_CHARGING:
18742003 wacom_wac->hid_data.bat_charging = value;
18752004 wacom_wac->hid_data.ps_connected = value;
18762005 wacom_wac->hid_data.bat_connected = 1;
18772006 wacom_wac->hid_data.bat_status = WACOM_POWER_SUPPLY_STATUS_AUTO;
2007
+ wacom_wac->features.quirks |= WACOM_QUIRK_BATTERY;
18782008 break;
18792009 }
18802010 }
....@@ -1890,18 +2020,15 @@
18902020 {
18912021 struct wacom *wacom = hid_get_drvdata(hdev);
18922022 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
1893
- struct wacom_features *features = &wacom_wac->features;
18942023
1895
- if (features->quirks & WACOM_QUIRK_BATTERY) {
1896
- int status = wacom_wac->hid_data.bat_status;
1897
- int capacity = wacom_wac->hid_data.battery_capacity;
1898
- bool charging = wacom_wac->hid_data.bat_charging;
1899
- bool connected = wacom_wac->hid_data.bat_connected;
1900
- bool powered = wacom_wac->hid_data.ps_connected;
2024
+ int status = wacom_wac->hid_data.bat_status;
2025
+ int capacity = wacom_wac->hid_data.battery_capacity;
2026
+ bool charging = wacom_wac->hid_data.bat_charging;
2027
+ bool connected = wacom_wac->hid_data.bat_connected;
2028
+ bool powered = wacom_wac->hid_data.ps_connected;
19012029
1902
- wacom_notify_battery(wacom_wac, status, capacity, charging,
1903
- connected, powered);
1904
- }
2030
+ wacom_notify_battery(wacom_wac, status, capacity, charging,
2031
+ connected, powered);
19052032 }
19062033
19072034 static void wacom_wac_pad_usage_mapping(struct hid_device *hdev,
....@@ -1954,7 +2081,6 @@
19542081 wacom_wac->has_mute_touch_switch = true;
19552082 usage->type = EV_SW;
19562083 usage->code = SW_MUTE_DEVICE;
1957
- features->device_type |= WACOM_DEVICETYPE_PAD;
19582084 break;
19592085 case WACOM_HID_WD_TOUCHSTRIP:
19602086 wacom_map_usage(input, usage, field, EV_ABS, ABS_RX, 0);
....@@ -2034,37 +2160,12 @@
20342160 wacom_wac->hid_data.inrange_state |= value;
20352161 }
20362162
2037
- switch (equivalent_usage) {
2038
- case WACOM_HID_WD_TOUCHRING:
2039
- /*
2040
- * Userspace expects touchrings to increase in value with
2041
- * clockwise gestures and have their zero point at the
2042
- * tablet's left. HID events "should" be clockwise-
2043
- * increasing and zero at top, though the MobileStudio
2044
- * Pro and 2nd-gen Intuos Pro don't do this...
2045
- */
2046
- if (hdev->vendor == 0x56a &&
2047
- (hdev->product == 0x34d || hdev->product == 0x34e || /* MobileStudio Pro */
2048
- hdev->product == 0x357 || hdev->product == 0x358)) { /* Intuos Pro 2 */
2049
- value = (field->logical_maximum - value);
2050
-
2051
- if (hdev->product == 0x357 || hdev->product == 0x358)
2052
- value = wacom_offset_rotation(input, usage, value, 3, 16);
2053
- else if (hdev->product == 0x34d || hdev->product == 0x34e)
2054
- value = wacom_offset_rotation(input, usage, value, 1, 2);
2055
- }
2056
- else {
2057
- value = wacom_offset_rotation(input, usage, value, 1, 4);
2058
- }
2059
- do_report = true;
2060
- break;
2061
- case WACOM_HID_WD_TOUCHRINGSTATUS:
2062
- if (!value)
2063
- input_event(input, usage->type, usage->code, 0);
2064
- break;
2065
-
2066
- case WACOM_HID_WD_MUTE_DEVICE:
2067
- case WACOM_HID_WD_TOUCHONOFF:
2163
+ /* Process touch switch state first since it is reported through touch interface,
2164
+ * which is indepentent of pad interface. In the case when there are no other pad
2165
+ * events, the pad interface will not even be created.
2166
+ */
2167
+ if ((equivalent_usage == WACOM_HID_WD_MUTE_DEVICE) ||
2168
+ (equivalent_usage == WACOM_HID_WD_TOUCHONOFF)) {
20682169 if (wacom_wac->shared->touch_input) {
20692170 bool *is_touch_on = &wacom_wac->shared->is_touch_on;
20702171
....@@ -2077,6 +2178,45 @@
20772178 SW_MUTE_DEVICE, !(*is_touch_on));
20782179 input_sync(wacom_wac->shared->touch_input);
20792180 }
2181
+ return;
2182
+ }
2183
+
2184
+ if (!input)
2185
+ return;
2186
+
2187
+ switch (equivalent_usage) {
2188
+ case WACOM_HID_WD_TOUCHRING:
2189
+ /*
2190
+ * Userspace expects touchrings to increase in value with
2191
+ * clockwise gestures and have their zero point at the
2192
+ * tablet's left. HID events "should" be clockwise-
2193
+ * increasing and zero at top, though the MobileStudio
2194
+ * Pro and 2nd-gen Intuos Pro don't do this...
2195
+ */
2196
+ if (hdev->vendor == 0x56a &&
2197
+ (hdev->product == 0x34d || hdev->product == 0x34e || /* MobileStudio Pro */
2198
+ hdev->product == 0x357 || hdev->product == 0x358 || /* Intuos Pro 2 */
2199
+ hdev->product == 0x392 || /* Intuos Pro 2 */
2200
+ hdev->product == 0x398 || hdev->product == 0x399 || /* MobileStudio Pro */
2201
+ hdev->product == 0x3AA)) { /* MobileStudio Pro */
2202
+ value = (field->logical_maximum - value);
2203
+
2204
+ if (hdev->product == 0x357 || hdev->product == 0x358 ||
2205
+ hdev->product == 0x392)
2206
+ value = wacom_offset_rotation(input, usage, value, 3, 16);
2207
+ else if (hdev->product == 0x34d || hdev->product == 0x34e ||
2208
+ hdev->product == 0x398 || hdev->product == 0x399 ||
2209
+ hdev->product == 0x3AA)
2210
+ value = wacom_offset_rotation(input, usage, value, 1, 2);
2211
+ }
2212
+ else {
2213
+ value = wacom_offset_rotation(input, usage, value, 1, 4);
2214
+ }
2215
+ do_report = true;
2216
+ break;
2217
+ case WACOM_HID_WD_TOUCHRINGSTATUS:
2218
+ if (!value)
2219
+ input_event(input, usage->type, usage->code, 0);
20802220 break;
20812221
20822222 case WACOM_HID_WD_MODE_CHANGE:
....@@ -2090,7 +2230,7 @@
20902230 for (i = 0; i < wacom->led.count; i++)
20912231 wacom_update_led(wacom, features->numbered_buttons,
20922232 value, i);
2093
- /* fall through*/
2233
+ fallthrough;
20942234 default:
20952235 do_report = true;
20962236 break;
....@@ -2181,27 +2321,6 @@
21812321 case HID_DG_TOOLSERIALNUMBER:
21822322 features->quirks |= WACOM_QUIRK_TOOLSERIAL;
21832323 wacom_map_usage(input, usage, field, EV_MSC, MSC_SERIAL, 0);
2184
-
2185
- /* Adjust AES usages to match modern convention */
2186
- if (usage->hid == WACOM_HID_WT_SERIALNUMBER && field->report_size == 16) {
2187
- if (field->index + 2 < field->report->maxfield) {
2188
- struct hid_field *a = field->report->field[field->index + 1];
2189
- struct hid_field *b = field->report->field[field->index + 2];
2190
-
2191
- if (a->maxusage > 0 && a->usage[0].hid == HID_DG_TOOLSERIALNUMBER && a->report_size == 32 &&
2192
- b->maxusage > 0 && b->usage[0].hid == 0xFF000000 && b->report_size == 8) {
2193
- features->quirks |= WACOM_QUIRK_AESPEN;
2194
- usage->hid = WACOM_HID_WD_TOOLTYPE;
2195
- field->logical_minimum = S16_MIN;
2196
- field->logical_maximum = S16_MAX;
2197
- a->logical_minimum = S32_MIN;
2198
- a->logical_maximum = S32_MAX;
2199
- b->usage[0].hid = WACOM_HID_WD_SERIALHI;
2200
- b->logical_minimum = 0;
2201
- b->logical_maximum = U8_MAX;
2202
- }
2203
- }
2204
- }
22052324 break;
22062325 case WACOM_HID_WD_SENSE:
22072326 features->quirks |= WACOM_QUIRK_SENSE;
....@@ -2251,6 +2370,7 @@
22512370 value = field->logical_maximum - value;
22522371 break;
22532372 case HID_DG_INRANGE:
2373
+ mod_timer(&wacom->idleprox_timer, jiffies + msecs_to_jiffies(100));
22542374 wacom_wac->hid_data.inrange_state = value;
22552375 if (!(features->quirks & WACOM_QUIRK_SENSE))
22562376 wacom_wac->hid_data.sense_state = value;
....@@ -2275,6 +2395,9 @@
22752395 }
22762396 return;
22772397 case HID_DG_TWIST:
2398
+ /* don't modify the value if the pen doesn't support the feature */
2399
+ if (!wacom_is_art_pen(wacom_wac->id[0])) return;
2400
+
22782401 /*
22792402 * Userspace expects pen twist to have its zero point when
22802403 * the buttons/finger is on the tablet's left. HID values
....@@ -2555,6 +2678,9 @@
25552678 unsigned equivalent_usage = wacom_equivalent_usage(usage->hid);
25562679 struct wacom_features *features = &wacom->wacom_wac.features;
25572680
2681
+ if (wacom_wac->is_invalid_bt_frame)
2682
+ return;
2683
+
25582684 switch (equivalent_usage) {
25592685 case HID_DG_CONFIDENCE:
25602686 wacom_wac->hid_data.confidence = value;
....@@ -2577,6 +2703,9 @@
25772703 case HID_DG_TIPSWITCH:
25782704 wacom_wac->hid_data.tipswitch = value;
25792705 break;
2706
+ case WACOM_HID_WT_REPORT_VALID:
2707
+ wacom_wac->is_invalid_bt_frame = !value;
2708
+ return;
25802709 case HID_DG_CONTACTMAX:
25812710 if (!features->touch_max) {
25822711 features->touch_max = value;
....@@ -2586,7 +2715,6 @@
25862715 }
25872716 return;
25882717 }
2589
-
25902718
25912719 if (usage->usage_index + 1 == field->report_count) {
25922720 if (equivalent_usage == wacom_wac->hid_data.last_slot_field) {
....@@ -2607,6 +2735,8 @@
26072735 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
26082736 struct hid_data* hid_data = &wacom_wac->hid_data;
26092737 int i;
2738
+
2739
+ wacom_wac->is_invalid_bt_frame = false;
26102740
26112741 hid_data->confidence = true;
26122742
....@@ -2719,7 +2849,7 @@
27192849 /* usage tests must precede field tests */
27202850 if (WACOM_BATTERY_USAGE(usage))
27212851 wacom_wac_battery_event(hdev, field, usage, value);
2722
- else if (WACOM_PAD_FIELD(field) && wacom->wacom_wac.pad_input)
2852
+ else if (WACOM_PAD_FIELD(field))
27232853 wacom_wac_pad_event(hdev, field, usage, value);
27242854 else if (WACOM_PEN_FIELD(field) && wacom->wacom_wac.pen_input)
27252855 wacom_wac_pen_event(hdev, field, usage, value);
....@@ -3299,6 +3429,7 @@
32993429 break;
33003430
33013431 case INTUOSP2_BT:
3432
+ case INTUOSP2S_BT:
33023433 case INTUOSHT3_BT:
33033434 sync = wacom_intuos_pro2_bt_irq(wacom_wac, len);
33043435 break;
....@@ -3479,7 +3610,8 @@
34793610 if (features->type == REMOTE)
34803611 features->device_type = WACOM_DEVICETYPE_PAD;
34813612
3482
- if (features->type == INTUOSP2_BT) {
3613
+ if (features->type == INTUOSP2_BT ||
3614
+ features->type == INTUOSP2S_BT) {
34833615 features->device_type |= WACOM_DEVICETYPE_PEN |
34843616 WACOM_DEVICETYPE_PAD |
34853617 WACOM_DEVICETYPE_TOUCH;
....@@ -3599,13 +3731,14 @@
35993731 switch (features->type) {
36003732 case GRAPHIRE_BT:
36013733 __clear_bit(ABS_MISC, input_dev->absbit);
3734
+ fallthrough;
36023735
36033736 case WACOM_MO:
36043737 case WACOM_G4:
36053738 input_set_abs_params(input_dev, ABS_DISTANCE, 0,
36063739 features->distance_max,
36073740 features->distance_fuzz, 0);
3608
- /* fall through */
3741
+ fallthrough;
36093742
36103743 case GRAPHIRE:
36113744 input_set_capability(input_dev, EV_REL, REL_WHEEL);
....@@ -3645,7 +3778,7 @@
36453778 case INTUOS4S:
36463779 input_set_abs_params(input_dev, ABS_Z, -900, 899, 0, 0);
36473780 input_abs_set_res(input_dev, ABS_Z, 287);
3648
- /* fall through */
3781
+ fallthrough;
36493782
36503783 case INTUOS:
36513784 wacom_setup_intuos(wacom_wac);
....@@ -3658,6 +3791,7 @@
36583791 case INTUOS5S:
36593792 case INTUOSPS:
36603793 case INTUOSP2_BT:
3794
+ case INTUOSP2S_BT:
36613795 input_set_abs_params(input_dev, ABS_DISTANCE, 0,
36623796 features->distance_max,
36633797 features->distance_fuzz, 0);
....@@ -3677,7 +3811,7 @@
36773811 case TABLETPC:
36783812 case TABLETPCE:
36793813 __clear_bit(ABS_MISC, input_dev->absbit);
3680
- /* fall through */
3814
+ fallthrough;
36813815
36823816 case DTUS:
36833817 case DTUSX:
....@@ -3691,7 +3825,7 @@
36913825
36923826 case PTU:
36933827 __set_bit(BTN_STYLUS2, input_dev->keybit);
3694
- /* fall through */
3828
+ fallthrough;
36953829
36963830 case PENPARTNER:
36973831 __set_bit(BTN_TOOL_PEN, input_dev->keybit);
....@@ -3768,6 +3902,7 @@
37683902
37693903 switch (features->type) {
37703904 case INTUOSP2_BT:
3905
+ case INTUOSP2S_BT:
37713906 input_dev->evbit[0] |= BIT_MASK(EV_SW);
37723907 __set_bit(SW_MUTE_DEVICE, input_dev->swbit);
37733908
....@@ -3783,10 +3918,16 @@
37833918 input_set_abs_params(input_dev, ABS_MT_POSITION_Y,
37843919 0, 5920, 4, 0);
37853920 }
3921
+ else if (wacom_wac->shared->touch->product == 0x393) {
3922
+ input_set_abs_params(input_dev, ABS_MT_POSITION_X,
3923
+ 0, 6400, 4, 0);
3924
+ input_set_abs_params(input_dev, ABS_MT_POSITION_Y,
3925
+ 0, 4000, 4, 0);
3926
+ }
37863927 input_abs_set_res(input_dev, ABS_MT_POSITION_X, 40);
37873928 input_abs_set_res(input_dev, ABS_MT_POSITION_Y, 40);
37883929
3789
- /* fall through */
3930
+ fallthrough;
37903931
37913932 case INTUOS5:
37923933 case INTUOS5L:
....@@ -3804,15 +3945,23 @@
38043945 input_set_abs_params(input_dev, ABS_MT_WIDTH_MAJOR, 0, features->x_max, 0, 0);
38053946 input_set_abs_params(input_dev, ABS_MT_WIDTH_MINOR, 0, features->y_max, 0, 0);
38063947 input_set_abs_params(input_dev, ABS_MT_ORIENTATION, 0, 1, 0, 0);
3807
- /* fall through */
3948
+ fallthrough;
38083949
38093950 case WACOM_27QHDT:
3951
+ if (wacom_wac->shared->touch->product == 0x32C ||
3952
+ wacom_wac->shared->touch->product == 0xF6) {
3953
+ input_dev->evbit[0] |= BIT_MASK(EV_SW);
3954
+ __set_bit(SW_MUTE_DEVICE, input_dev->swbit);
3955
+ wacom_wac->has_mute_touch_switch = true;
3956
+ }
3957
+ fallthrough;
3958
+
38103959 case MTSCREEN:
38113960 case MTTPC:
38123961 case MTTPC_B:
38133962 case TABLETPC2FG:
38143963 input_mt_init_slots(input_dev, features->touch_max, INPUT_MT_DIRECT);
3815
- /*fall through */
3964
+ fallthrough;
38163965
38173966 case TABLETPC:
38183967 case TABLETPCE:
....@@ -3822,7 +3971,7 @@
38223971 case INTUOSHT2:
38233972 input_dev->evbit[0] |= BIT_MASK(EV_SW);
38243973 __set_bit(SW_MUTE_DEVICE, input_dev->swbit);
3825
- /* fall through */
3974
+ fallthrough;
38263975
38273976 case BAMBOO_PT:
38283977 case BAMBOO_TOUCH:
....@@ -4042,6 +4191,12 @@
40424191 __set_bit(KEY_PROG2, input_dev->keybit);
40434192 __set_bit(KEY_PROG3, input_dev->keybit);
40444193
4194
+ __set_bit(KEY_ONSCREEN_KEYBOARD, input_dev->keybit);
4195
+ __set_bit(KEY_INFO, input_dev->keybit);
4196
+
4197
+ if (!features->oPid)
4198
+ __set_bit(KEY_BUTTONCONFIG, input_dev->keybit);
4199
+
40454200 input_set_abs_params(input_dev, ABS_WHEEL, 0, 71, 0, 0);
40464201 input_set_abs_params(input_dev, ABS_THROTTLE, 0, 71, 0, 0);
40474202 break;
....@@ -4050,6 +4205,12 @@
40504205 __set_bit(KEY_PROG1, input_dev->keybit);
40514206 __set_bit(KEY_PROG2, input_dev->keybit);
40524207 __set_bit(KEY_PROG3, input_dev->keybit);
4208
+
4209
+ __set_bit(KEY_ONSCREEN_KEYBOARD, input_dev->keybit);
4210
+ __set_bit(KEY_BUTTONCONFIG, input_dev->keybit);
4211
+
4212
+ if (!features->oPid)
4213
+ __set_bit(KEY_CONTROLPANEL, input_dev->keybit);
40534214 input_set_abs_params(input_dev, ABS_X, -2048, 2048, 0, 0);
40544215 input_abs_set_res(input_dev, ABS_X, 1024); /* points/g */
40554216 input_set_abs_params(input_dev, ABS_Y, -2048, 2048, 0, 0);
....@@ -4063,7 +4224,10 @@
40634224 __set_bit(KEY_PROG1, input_dev->keybit);
40644225 __set_bit(KEY_PROG2, input_dev->keybit);
40654226 __set_bit(KEY_PROG3, input_dev->keybit);
4066
- /* fall through */
4227
+
4228
+ __set_bit(KEY_BUTTONCONFIG, input_dev->keybit);
4229
+ __set_bit(KEY_INFO, input_dev->keybit);
4230
+ fallthrough;
40674231
40684232 case WACOM_21UX2:
40694233 case WACOM_BEE:
....@@ -4079,7 +4243,7 @@
40794243 case INTUOS3:
40804244 case INTUOS3L:
40814245 input_set_abs_params(input_dev, ABS_RY, 0, 4096, 0, 0);
4082
- /* fall through */
4246
+ fallthrough;
40834247
40844248 case INTUOS3S:
40854249 input_set_abs_params(input_dev, ABS_RX, 0, 4096, 0, 0);
....@@ -4092,6 +4256,7 @@
40924256 case INTUOS5S:
40934257 case INTUOSPS:
40944258 case INTUOSP2_BT:
4259
+ case INTUOSP2S_BT:
40954260 input_set_abs_params(input_dev, ABS_WHEEL, 0, 71, 0, 0);
40964261 break;
40974262
....@@ -4102,7 +4267,7 @@
41024267 * ID_INPUT_TABLET to be set.
41034268 */
41044269 __set_bit(BTN_STYLUS, input_dev->keybit);
4105
- /* fall through */
4270
+ fallthrough;
41064271
41074272 case INTUOS4:
41084273 case INTUOS4L:
....@@ -4669,9 +4834,26 @@
46694834 static const struct wacom_features wacom_features_0x37B =
46704835 { "Wacom One by Wacom M", 21600, 13500, 2047, 63,
46714836 BAMBOO_PEN, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4837
+static const struct wacom_features wacom_features_0x393 =
4838
+ { "Wacom Intuos Pro S", 31920, 19950, 8191, 63,
4839
+ INTUOSP2S_BT, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 7,
4840
+ .touch_max = 10 };
4841
+static const struct wacom_features wacom_features_0x3c6 =
4842
+ { "Wacom Intuos BT S", 15200, 9500, 4095, 63,
4843
+ INTUOSHT3_BT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, 4 };
4844
+static const struct wacom_features wacom_features_0x3c8 =
4845
+ { "Wacom Intuos BT M", 21600, 13500, 4095, 63,
4846
+ INTUOSHT3_BT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, 4 };
4847
+static const struct wacom_features wacom_features_0x3dd =
4848
+ { "Wacom Intuos Pro S", 31920, 19950, 8191, 63,
4849
+ INTUOSP2S_BT, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 7,
4850
+ .touch_max = 10 };
46724851
46734852 static const struct wacom_features wacom_features_HID_ANY_ID =
46744853 { "Wacom HID", .type = HID_GENERIC, .oVid = HID_ANY_ID, .oPid = HID_ANY_ID };
4854
+
4855
+static const struct wacom_features wacom_features_0x94 =
4856
+ { "Wacom Bootloader", .type = BOOTLOADER };
46754857
46764858 #define USB_DEVICE_WACOM(prod) \
46774859 HID_DEVICE(BUS_USB, HID_GROUP_WACOM, USB_VENDOR_ID_WACOM, prod),\
....@@ -4746,6 +4928,7 @@
47464928 { USB_DEVICE_WACOM(0x84) },
47474929 { USB_DEVICE_WACOM(0x90) },
47484930 { USB_DEVICE_WACOM(0x93) },
4931
+ { USB_DEVICE_WACOM(0x94) },
47494932 { USB_DEVICE_WACOM(0x97) },
47504933 { USB_DEVICE_WACOM(0x9A) },
47514934 { USB_DEVICE_WACOM(0x9F) },
....@@ -4841,6 +5024,10 @@
48415024 { BT_DEVICE_WACOM(0x379) },
48425025 { USB_DEVICE_WACOM(0x37A) },
48435026 { USB_DEVICE_WACOM(0x37B) },
5027
+ { BT_DEVICE_WACOM(0x393) },
5028
+ { BT_DEVICE_WACOM(0x3c6) },
5029
+ { BT_DEVICE_WACOM(0x3c8) },
5030
+ { BT_DEVICE_WACOM(0x3dd) },
48445031 { USB_DEVICE_WACOM(0x4001) },
48455032 { USB_DEVICE_WACOM(0x4004) },
48465033 { USB_DEVICE_WACOM(0x5000) },