blob: d51daf5814888044019546fbb6d019eeab78c341 [file] [log] [blame]
Ping Cheng3bea7332006-07-13 18:01:36 -07001/*
Dmitry Torokhov4104d132007-05-07 16:16:29 -04002 * drivers/input/tablet/wacom_wac.c
Ping Cheng3bea7332006-07-13 18:01:36 -07003 *
Ping Chengee545002009-12-15 00:35:24 -08004 * USB Wacom tablet support - Wacom specific code
Ping Cheng3bea7332006-07-13 18:01:36 -07005 *
6 */
7
8/*
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.
13 */
Dmitry Torokhov51269fe2010-03-19 22:18:15 -070014
Ping Cheng3bea7332006-07-13 18:01:36 -070015#include "wacom_wac.h"
Dmitry Torokhov51269fe2010-03-19 22:18:15 -070016#include "wacom.h"
Henrik Rydberg47c78e82010-11-27 09:16:48 +010017#include <linux/input/mt.h>
Ping Cheng3bea7332006-07-13 18:01:36 -070018
Ping Chenge35fb8c2011-03-26 21:16:05 -070019/* resolution for penabled devices */
20#define WACOM_PL_RES 20
21#define WACOM_PENPRTN_RES 40
22#define WACOM_VOLITO_RES 50
23#define WACOM_GRAPHIRE_RES 80
24#define WACOM_INTUOS_RES 100
25#define WACOM_INTUOS3_RES 200
26
Ping Chengfa770342014-12-01 13:44:28 -080027/* Newer Cintiq and DTU have an offset between tablet and screen areas */
28#define WACOM_DTU_OFFSET 200
29#define WACOM_CINTIQ_OFFSET 400
30
Benjamin Tissoires387142b2014-08-06 13:52:56 -070031/*
32 * Scale factor relating reported contact size to logical contact area.
Jason Gerecke4e904952012-10-03 17:19:11 -070033 * 2^14/pi is a good approximation on Intuos5 and 3rd-gen Bamboo
34 */
35#define WACOM_CONTACT_AREA_SCALE 2607
36
Ping Cheng1924e052016-08-09 14:38:56 -070037static bool touch_arbitration = 1;
38module_param(touch_arbitration, bool, 0644);
39MODULE_PARM_DESC(touch_arbitration, " on (Y) off (N)");
40
Jason Gereckec7f05222015-11-30 17:13:47 -080041static void wacom_report_numbered_buttons(struct input_dev *input_dev,
42 int button_count, int mask);
43
Jason Gerecke5922e612016-10-19 18:03:51 -070044static int wacom_numbered_button_to_key(int n);
45
Aaron Armstrong Skomra10c55ca2017-01-25 12:08:42 -080046static void wacom_update_led(struct wacom *wacom, int button_count, int mask,
47 int group);
Benjamin Tissoires387142b2014-08-06 13:52:56 -070048/*
49 * Percent of battery capacity for Graphire.
50 * 8th value means AC online and show 100% capacity.
51 */
52static unsigned short batcap_gr[8] = { 1, 15, 25, 35, 50, 70, 100, 100 };
53
Benjamin Tissoires81af7e62014-08-06 13:55:56 -070054/*
55 * Percent of battery capacity for Intuos4 WL, AC has a separate bit.
56 */
57static unsigned short batcap_i4[8] = { 1, 15, 30, 45, 60, 70, 85, 100 };
58
Benjamin Tissoires59d69bc2016-07-13 18:06:08 +020059static void __wacom_notify_battery(struct wacom_battery *battery,
60 int bat_capacity, bool bat_charging,
61 bool bat_connected, bool ps_connected)
62{
63 bool changed = battery->battery_capacity != bat_capacity ||
64 battery->bat_charging != bat_charging ||
65 battery->bat_connected != bat_connected ||
66 battery->ps_connected != ps_connected;
67
68 if (changed) {
69 battery->battery_capacity = bat_capacity;
70 battery->bat_charging = bat_charging;
71 battery->bat_connected = bat_connected;
72 battery->ps_connected = ps_connected;
73
74 if (battery->battery)
75 power_supply_changed(battery->battery);
76 }
77}
78
Jason Gerecke953f2c52015-03-06 11:47:39 -080079static void wacom_notify_battery(struct wacom_wac *wacom_wac,
Jason Gerecke71fa6412015-03-11 10:25:41 -070080 int bat_capacity, bool bat_charging, bool bat_connected,
81 bool ps_connected)
Jason Gerecke953f2c52015-03-06 11:47:39 -080082{
83 struct wacom *wacom = container_of(wacom_wac, struct wacom, wacom_wac);
Jason Gerecke953f2c52015-03-06 11:47:39 -080084
Benjamin Tissoires59d69bc2016-07-13 18:06:08 +020085 __wacom_notify_battery(&wacom->battery, bat_capacity, bat_charging,
86 bat_connected, ps_connected);
Jason Gerecke953f2c52015-03-06 11:47:39 -080087}
88
Dmitry Torokhov95dd3b32010-03-19 22:18:15 -070089static int wacom_penpartner_irq(struct wacom_wac *wacom)
Ping Cheng3bea7332006-07-13 18:01:36 -070090{
91 unsigned char *data = wacom->data;
Jason Gerecke2a6cdbd2015-06-15 18:01:45 -070092 struct input_dev *input = wacom->pen_input;
Ping Cheng3bea7332006-07-13 18:01:36 -070093
94 switch (data[0]) {
Dmitry Torokhov73a97f42010-03-19 22:18:15 -070095 case 1:
96 if (data[5] & 0x80) {
97 wacom->tool[0] = (data[5] & 0x20) ? BTN_TOOL_RUBBER : BTN_TOOL_PEN;
98 wacom->id[0] = (data[5] & 0x20) ? ERASER_DEVICE_ID : STYLUS_DEVICE_ID;
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -070099 input_report_key(input, wacom->tool[0], 1);
100 input_report_abs(input, ABS_MISC, wacom->id[0]); /* report tool id */
Dmitry Torokhov252f7762010-03-19 22:33:38 -0700101 input_report_abs(input, ABS_X, get_unaligned_le16(&data[1]));
102 input_report_abs(input, ABS_Y, get_unaligned_le16(&data[3]));
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700103 input_report_abs(input, ABS_PRESSURE, (signed char)data[6] + 127);
104 input_report_key(input, BTN_TOUCH, ((signed char)data[6] > -127));
105 input_report_key(input, BTN_STYLUS, (data[5] & 0x40));
Dmitry Torokhov73a97f42010-03-19 22:18:15 -0700106 } else {
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700107 input_report_key(input, wacom->tool[0], 0);
108 input_report_abs(input, ABS_MISC, 0); /* report tool id */
109 input_report_abs(input, ABS_PRESSURE, -1);
110 input_report_key(input, BTN_TOUCH, 0);
Dmitry Torokhov73a97f42010-03-19 22:18:15 -0700111 }
112 break;
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700113
Dmitry Torokhov73a97f42010-03-19 22:18:15 -0700114 case 2:
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700115 input_report_key(input, BTN_TOOL_PEN, 1);
116 input_report_abs(input, ABS_MISC, STYLUS_DEVICE_ID); /* report tool id */
Dmitry Torokhov252f7762010-03-19 22:33:38 -0700117 input_report_abs(input, ABS_X, get_unaligned_le16(&data[1]));
118 input_report_abs(input, ABS_Y, get_unaligned_le16(&data[3]));
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700119 input_report_abs(input, ABS_PRESSURE, (signed char)data[6] + 127);
120 input_report_key(input, BTN_TOUCH, ((signed char)data[6] > -80) && !(data[5] & 0x20));
121 input_report_key(input, BTN_STYLUS, (data[5] & 0x40));
Dmitry Torokhov73a97f42010-03-19 22:18:15 -0700122 break;
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700123
Dmitry Torokhov73a97f42010-03-19 22:18:15 -0700124 default:
Dmitry Torokhoveb71d1b2012-05-02 00:13:38 -0700125 dev_dbg(input->dev.parent,
126 "%s: received unknown report #%d\n", __func__, data[0]);
Dmitry Torokhov73a97f42010-03-19 22:18:15 -0700127 return 0;
Ping Cheng3bea7332006-07-13 18:01:36 -0700128 }
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700129
Ping Cheng3bea7332006-07-13 18:01:36 -0700130 return 1;
131}
132
Dmitry Torokhov95dd3b32010-03-19 22:18:15 -0700133static int wacom_pl_irq(struct wacom_wac *wacom)
Ping Cheng3bea7332006-07-13 18:01:36 -0700134{
Jason Childse33da8a2010-02-17 22:38:31 -0800135 struct wacom_features *features = &wacom->features;
Ping Cheng3bea7332006-07-13 18:01:36 -0700136 unsigned char *data = wacom->data;
Jason Gerecke2a6cdbd2015-06-15 18:01:45 -0700137 struct input_dev *input = wacom->pen_input;
Ping Chenge34b9d22008-05-05 11:36:41 -0400138 int prox, pressure;
Ping Cheng3bea7332006-07-13 18:01:36 -0700139
Ping Chengcad74702009-12-15 00:35:25 -0800140 if (data[0] != WACOM_REPORT_PENABLED) {
Dmitry Torokhoveb71d1b2012-05-02 00:13:38 -0700141 dev_dbg(input->dev.parent,
142 "%s: received unknown report #%d\n", __func__, data[0]);
Ping Cheng3bea7332006-07-13 18:01:36 -0700143 return 0;
144 }
145
146 prox = data[1] & 0x40;
147
Jason Gerecke025bcc12015-08-03 10:18:10 -0700148 if (!wacom->id[0]) {
149 if ((data[0] & 0x10) || (data[4] & 0x20)) {
150 wacom->tool[0] = BTN_TOOL_RUBBER;
151 wacom->id[0] = ERASER_DEVICE_ID;
Ping Cheng3bea7332006-07-13 18:01:36 -0700152 }
Jason Gerecke025bcc12015-08-03 10:18:10 -0700153 else {
154 wacom->tool[0] = BTN_TOOL_PEN;
Ping Chenge34b9d22008-05-05 11:36:41 -0400155 wacom->id[0] = STYLUS_DEVICE_ID;
Ping Cheng3bea7332006-07-13 18:01:36 -0700156 }
Ping Cheng3bea7332006-07-13 18:01:36 -0700157 }
158
Jason Gerecke025bcc12015-08-03 10:18:10 -0700159 /* If the eraser is in prox, STYLUS2 is always set. If we
160 * mis-detected the type and notice that STYLUS2 isn't set
161 * then force the eraser out of prox and let the pen in.
162 */
163 if (wacom->tool[0] == BTN_TOOL_RUBBER && !(data[4] & 0x20)) {
164 input_report_key(input, BTN_TOOL_RUBBER, 0);
165 input_report_abs(input, ABS_MISC, 0);
166 input_sync(input);
167 wacom->tool[0] = BTN_TOOL_PEN;
168 wacom->id[0] = STYLUS_DEVICE_ID;
169 }
170
171 pressure = (signed char)((data[7] << 1) | ((data[4] >> 2) & 1));
172 if (features->pressure_max > 255)
173 pressure = (pressure << 1) | ((data[4] >> 6) & 1);
174 pressure += (features->pressure_max + 1) / 2;
175
176 input_report_abs(input, ABS_X, data[3] | (data[2] << 7) | ((data[1] & 0x03) << 14));
177 input_report_abs(input, ABS_Y, data[6] | (data[5] << 7) | ((data[4] & 0x03) << 14));
178 input_report_abs(input, ABS_PRESSURE, pressure);
179
180 input_report_key(input, BTN_TOUCH, data[4] & 0x08);
181 input_report_key(input, BTN_STYLUS, data[4] & 0x10);
182 /* Only allow the stylus2 button to be reported for the pen tool. */
183 input_report_key(input, BTN_STYLUS2, (wacom->tool[0] == BTN_TOOL_PEN) && (data[4] & 0x20));
184
185 if (!prox)
186 wacom->id[0] = 0;
187 input_report_key(input, wacom->tool[0], prox);
188 input_report_abs(input, ABS_MISC, wacom->id[0]);
Ping Cheng3bea7332006-07-13 18:01:36 -0700189 return 1;
190}
191
Dmitry Torokhov95dd3b32010-03-19 22:18:15 -0700192static int wacom_ptu_irq(struct wacom_wac *wacom)
Ping Cheng3bea7332006-07-13 18:01:36 -0700193{
194 unsigned char *data = wacom->data;
Jason Gerecke2a6cdbd2015-06-15 18:01:45 -0700195 struct input_dev *input = wacom->pen_input;
Ping Cheng3bea7332006-07-13 18:01:36 -0700196
Ping Chengcad74702009-12-15 00:35:25 -0800197 if (data[0] != WACOM_REPORT_PENABLED) {
Dmitry Torokhoveb71d1b2012-05-02 00:13:38 -0700198 dev_dbg(input->dev.parent,
199 "%s: received unknown report #%d\n", __func__, data[0]);
Ping Cheng3bea7332006-07-13 18:01:36 -0700200 return 0;
201 }
202
Ping Cheng3bea7332006-07-13 18:01:36 -0700203 if (data[1] & 0x04) {
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700204 input_report_key(input, BTN_TOOL_RUBBER, data[1] & 0x20);
205 input_report_key(input, BTN_TOUCH, data[1] & 0x08);
Ping Chenge34b9d22008-05-05 11:36:41 -0400206 wacom->id[0] = ERASER_DEVICE_ID;
Ping Cheng3bea7332006-07-13 18:01:36 -0700207 } else {
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700208 input_report_key(input, BTN_TOOL_PEN, data[1] & 0x20);
209 input_report_key(input, BTN_TOUCH, data[1] & 0x01);
Ping Chenge34b9d22008-05-05 11:36:41 -0400210 wacom->id[0] = STYLUS_DEVICE_ID;
Ping Cheng3bea7332006-07-13 18:01:36 -0700211 }
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700212 input_report_abs(input, ABS_MISC, wacom->id[0]); /* report tool id */
Dmitry Torokhov252f7762010-03-19 22:33:38 -0700213 input_report_abs(input, ABS_X, le16_to_cpup((__le16 *)&data[2]));
214 input_report_abs(input, ABS_Y, le16_to_cpup((__le16 *)&data[4]));
215 input_report_abs(input, ABS_PRESSURE, le16_to_cpup((__le16 *)&data[6]));
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700216 input_report_key(input, BTN_STYLUS, data[1] & 0x02);
217 input_report_key(input, BTN_STYLUS2, data[1] & 0x10);
Ping Cheng3bea7332006-07-13 18:01:36 -0700218 return 1;
219}
220
Ping Chengc8f2edc2010-06-28 01:10:51 -0700221static int wacom_dtu_irq(struct wacom_wac *wacom)
222{
Jason Gerecke74b63412014-04-19 13:50:22 -0700223 unsigned char *data = wacom->data;
Jason Gerecke2a6cdbd2015-06-15 18:01:45 -0700224 struct input_dev *input = wacom->pen_input;
Jason Gerecke74b63412014-04-19 13:50:22 -0700225 int prox = data[1] & 0x20;
Ping Chengc8f2edc2010-06-28 01:10:51 -0700226
Dmitry Torokhoveb71d1b2012-05-02 00:13:38 -0700227 dev_dbg(input->dev.parent,
228 "%s: received report #%d", __func__, data[0]);
Ping Chengc8f2edc2010-06-28 01:10:51 -0700229
230 if (prox) {
231 /* Going into proximity select tool */
232 wacom->tool[0] = (data[1] & 0x0c) ? BTN_TOOL_RUBBER : BTN_TOOL_PEN;
233 if (wacom->tool[0] == BTN_TOOL_PEN)
234 wacom->id[0] = STYLUS_DEVICE_ID;
235 else
236 wacom->id[0] = ERASER_DEVICE_ID;
237 }
238 input_report_key(input, BTN_STYLUS, data[1] & 0x02);
239 input_report_key(input, BTN_STYLUS2, data[1] & 0x10);
240 input_report_abs(input, ABS_X, le16_to_cpup((__le16 *)&data[2]));
241 input_report_abs(input, ABS_Y, le16_to_cpup((__le16 *)&data[4]));
Jason Gerecke74b63412014-04-19 13:50:22 -0700242 input_report_abs(input, ABS_PRESSURE, ((data[7] & 0x01) << 8) | data[6]);
Ping Chengc8f2edc2010-06-28 01:10:51 -0700243 input_report_key(input, BTN_TOUCH, data[1] & 0x05);
244 if (!prox) /* out-prox */
245 wacom->id[0] = 0;
246 input_report_key(input, wacom->tool[0], prox);
247 input_report_abs(input, ABS_MISC, wacom->id[0]);
248 return 1;
249}
250
Ping Cheng497ab1f2014-01-20 20:18:04 -0800251static int wacom_dtus_irq(struct wacom_wac *wacom)
252{
253 char *data = wacom->data;
Jason Gerecke2a6cdbd2015-06-15 18:01:45 -0700254 struct input_dev *input = wacom->pen_input;
Ping Cheng497ab1f2014-01-20 20:18:04 -0800255 unsigned short prox, pressure = 0;
256
257 if (data[0] != WACOM_REPORT_DTUS && data[0] != WACOM_REPORT_DTUSPAD) {
258 dev_dbg(input->dev.parent,
259 "%s: received unknown report #%d", __func__, data[0]);
260 return 0;
261 } else if (data[0] == WACOM_REPORT_DTUSPAD) {
Benjamin Tissoires422b0312014-07-24 12:50:39 -0700262 input = wacom->pad_input;
Ping Cheng497ab1f2014-01-20 20:18:04 -0800263 input_report_key(input, BTN_0, (data[1] & 0x01));
264 input_report_key(input, BTN_1, (data[1] & 0x02));
265 input_report_key(input, BTN_2, (data[1] & 0x04));
266 input_report_key(input, BTN_3, (data[1] & 0x08));
267 input_report_abs(input, ABS_MISC,
268 data[1] & 0x0f ? PAD_DEVICE_ID : 0);
Ping Cheng497ab1f2014-01-20 20:18:04 -0800269 return 1;
270 } else {
271 prox = data[1] & 0x80;
272 if (prox) {
273 switch ((data[1] >> 3) & 3) {
274 case 1: /* Rubber */
275 wacom->tool[0] = BTN_TOOL_RUBBER;
276 wacom->id[0] = ERASER_DEVICE_ID;
277 break;
278
279 case 2: /* Pen */
280 wacom->tool[0] = BTN_TOOL_PEN;
281 wacom->id[0] = STYLUS_DEVICE_ID;
282 break;
283 }
284 }
285
286 input_report_key(input, BTN_STYLUS, data[1] & 0x20);
287 input_report_key(input, BTN_STYLUS2, data[1] & 0x40);
288 input_report_abs(input, ABS_X, get_unaligned_be16(&data[3]));
289 input_report_abs(input, ABS_Y, get_unaligned_be16(&data[5]));
290 pressure = ((data[1] & 0x03) << 8) | (data[2] & 0xff);
291 input_report_abs(input, ABS_PRESSURE, pressure);
292 input_report_key(input, BTN_TOUCH, pressure > 10);
293
294 if (!prox) /* out-prox */
295 wacom->id[0] = 0;
296 input_report_key(input, wacom->tool[0], prox);
297 input_report_abs(input, ABS_MISC, wacom->id[0]);
Ping Cheng497ab1f2014-01-20 20:18:04 -0800298 return 1;
299 }
300}
301
Dmitry Torokhov95dd3b32010-03-19 22:18:15 -0700302static int wacom_graphire_irq(struct wacom_wac *wacom)
Ping Cheng3bea7332006-07-13 18:01:36 -0700303{
Jason Childse33da8a2010-02-17 22:38:31 -0800304 struct wacom_features *features = &wacom->features;
Ping Cheng3bea7332006-07-13 18:01:36 -0700305 unsigned char *data = wacom->data;
Jason Gerecke2a6cdbd2015-06-15 18:01:45 -0700306 struct input_dev *input = wacom->pen_input;
Benjamin Tissoires38138102014-07-24 12:51:03 -0700307 struct input_dev *pad_input = wacom->pad_input;
Benjamin Tissoires387142b2014-08-06 13:52:56 -0700308 int battery_capacity, ps_connected;
Dmitry Torokhov252f7762010-03-19 22:33:38 -0700309 int prox;
Ping Cheng3b57ca02010-03-04 21:50:59 -0800310 int rw = 0;
311 int retval = 0;
Ping Cheng3bea7332006-07-13 18:01:36 -0700312
Benjamin Tissoires387142b2014-08-06 13:52:56 -0700313 if (features->type == GRAPHIRE_BT) {
314 if (data[0] != WACOM_REPORT_PENABLED_BT) {
315 dev_dbg(input->dev.parent,
316 "%s: received unknown report #%d\n", __func__,
317 data[0]);
318 goto exit;
319 }
320 } else if (data[0] != WACOM_REPORT_PENABLED) {
Dmitry Torokhoveb71d1b2012-05-02 00:13:38 -0700321 dev_dbg(input->dev.parent,
322 "%s: received unknown report #%d\n", __func__, data[0]);
Ping Cheng3b57ca02010-03-04 21:50:59 -0800323 goto exit;
Ping Cheng3bea7332006-07-13 18:01:36 -0700324 }
325
Ping Cheng3b57ca02010-03-04 21:50:59 -0800326 prox = data[1] & 0x80;
327 if (prox || wacom->id[0]) {
328 if (prox) {
329 switch ((data[1] >> 5) & 3) {
Ping Cheng3bea7332006-07-13 18:01:36 -0700330
331 case 0: /* Pen */
332 wacom->tool[0] = BTN_TOOL_PEN;
Ping Chenge34b9d22008-05-05 11:36:41 -0400333 wacom->id[0] = STYLUS_DEVICE_ID;
Ping Cheng3bea7332006-07-13 18:01:36 -0700334 break;
335
336 case 1: /* Rubber */
337 wacom->tool[0] = BTN_TOOL_RUBBER;
Ping Chenge34b9d22008-05-05 11:36:41 -0400338 wacom->id[0] = ERASER_DEVICE_ID;
Ping Cheng3bea7332006-07-13 18:01:36 -0700339 break;
340
341 case 2: /* Mouse with wheel */
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700342 input_report_key(input, BTN_MIDDLE, data[1] & 0x04);
Ping Cheng3bea7332006-07-13 18:01:36 -0700343 /* fall through */
344
345 case 3: /* Mouse without wheel */
346 wacom->tool[0] = BTN_TOOL_MOUSE;
Ping Chenge34b9d22008-05-05 11:36:41 -0400347 wacom->id[0] = CURSOR_DEVICE_ID;
Ping Cheng3bea7332006-07-13 18:01:36 -0700348 break;
Ping Cheng3b57ca02010-03-04 21:50:59 -0800349 }
Ping Cheng3bea7332006-07-13 18:01:36 -0700350 }
Dmitry Torokhov252f7762010-03-19 22:33:38 -0700351 input_report_abs(input, ABS_X, le16_to_cpup((__le16 *)&data[2]));
352 input_report_abs(input, ABS_Y, le16_to_cpup((__le16 *)&data[4]));
Ping Cheng3bea7332006-07-13 18:01:36 -0700353 if (wacom->tool[0] != BTN_TOOL_MOUSE) {
Benjamin Tissoires387142b2014-08-06 13:52:56 -0700354 if (features->type == GRAPHIRE_BT)
355 input_report_abs(input, ABS_PRESSURE, data[6] |
356 (((__u16) (data[1] & 0x08)) << 5));
357 else
358 input_report_abs(input, ABS_PRESSURE, data[6] |
359 ((data[7] & 0x03) << 8));
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700360 input_report_key(input, BTN_TOUCH, data[1] & 0x01);
361 input_report_key(input, BTN_STYLUS, data[1] & 0x02);
362 input_report_key(input, BTN_STYLUS2, data[1] & 0x04);
Dmitry Torokhovafb567e2010-04-13 23:08:58 -0700363 } else {
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700364 input_report_key(input, BTN_LEFT, data[1] & 0x01);
365 input_report_key(input, BTN_RIGHT, data[1] & 0x02);
Ping Cheng3b57ca02010-03-04 21:50:59 -0800366 if (features->type == WACOM_G4 ||
367 features->type == WACOM_MO) {
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700368 input_report_abs(input, ABS_DISTANCE, data[6] & 0x3f);
Mike Autyd9f66c12010-08-28 20:35:17 -0700369 rw = (data[7] & 0x04) - (data[7] & 0x03);
Benjamin Tissoires387142b2014-08-06 13:52:56 -0700370 } else if (features->type == GRAPHIRE_BT) {
371 /* Compute distance between mouse and tablet */
372 rw = 44 - (data[6] >> 2);
373 rw = clamp_val(rw, 0, 31);
374 input_report_abs(input, ABS_DISTANCE, rw);
375 if (((data[1] >> 5) & 3) == 2) {
376 /* Mouse with wheel */
377 input_report_key(input, BTN_MIDDLE,
378 data[1] & 0x04);
379 rw = (data[6] & 0x01) ? -1 :
380 (data[6] & 0x02) ? 1 : 0;
381 } else {
382 rw = 0;
383 }
Ping Cheng3b57ca02010-03-04 21:50:59 -0800384 } else {
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700385 input_report_abs(input, ABS_DISTANCE, data[7] & 0x3f);
Mike Autyd9f66c12010-08-28 20:35:17 -0700386 rw = -(signed char)data[6];
Ping Cheng3b57ca02010-03-04 21:50:59 -0800387 }
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700388 input_report_rel(input, REL_WHEEL, rw);
Dmitry Torokhovafb567e2010-04-13 23:08:58 -0700389 }
Ping Cheng3b57ca02010-03-04 21:50:59 -0800390
391 if (!prox)
392 wacom->id[0] = 0;
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700393 input_report_abs(input, ABS_MISC, wacom->id[0]); /* report tool id */
394 input_report_key(input, wacom->tool[0], prox);
395 input_sync(input); /* sync last event */
Ping Cheng80d4e8e2007-02-23 12:22:48 -0800396 }
Ping Cheng3bea7332006-07-13 18:01:36 -0700397
398 /* send pad data */
Jason Childse33da8a2010-02-17 22:38:31 -0800399 switch (features->type) {
Dmitry Torokhov73a97f42010-03-19 22:18:15 -0700400 case WACOM_G4:
Ping Cheng3b57ca02010-03-04 21:50:59 -0800401 prox = data[7] & 0xf8;
402 if (prox || wacom->id[1]) {
Ping Chenge34b9d22008-05-05 11:36:41 -0400403 wacom->id[1] = PAD_DEVICE_ID;
Benjamin Tissoires38138102014-07-24 12:51:03 -0700404 input_report_key(pad_input, BTN_BACK, (data[7] & 0x40));
405 input_report_key(pad_input, BTN_FORWARD, (data[7] & 0x80));
Ping Cheng3bea7332006-07-13 18:01:36 -0700406 rw = ((data[7] & 0x18) >> 3) - ((data[7] & 0x20) >> 3);
Benjamin Tissoires38138102014-07-24 12:51:03 -0700407 input_report_rel(pad_input, REL_WHEEL, rw);
Ping Cheng3b57ca02010-03-04 21:50:59 -0800408 if (!prox)
409 wacom->id[1] = 0;
Benjamin Tissoires38138102014-07-24 12:51:03 -0700410 input_report_abs(pad_input, ABS_MISC, wacom->id[1]);
Ping Chengab687b12010-04-05 23:07:41 -0700411 retval = 1;
Ping Cheng3bea7332006-07-13 18:01:36 -0700412 }
Ping Cheng7ecfbfd2007-06-14 23:32:48 -0400413 break;
Dmitry Torokhov73a97f42010-03-19 22:18:15 -0700414
415 case WACOM_MO:
Ping Cheng3b57ca02010-03-04 21:50:59 -0800416 prox = (data[7] & 0xf8) || data[8];
417 if (prox || wacom->id[1]) {
Ping Chenge34b9d22008-05-05 11:36:41 -0400418 wacom->id[1] = PAD_DEVICE_ID;
Benjamin Tissoires38138102014-07-24 12:51:03 -0700419 input_report_key(pad_input, BTN_BACK, (data[7] & 0x08));
420 input_report_key(pad_input, BTN_LEFT, (data[7] & 0x20));
421 input_report_key(pad_input, BTN_FORWARD, (data[7] & 0x10));
422 input_report_key(pad_input, BTN_RIGHT, (data[7] & 0x40));
423 input_report_abs(pad_input, ABS_WHEEL, (data[8] & 0x7f));
Ping Cheng3b57ca02010-03-04 21:50:59 -0800424 if (!prox)
425 wacom->id[1] = 0;
Benjamin Tissoires38138102014-07-24 12:51:03 -0700426 input_report_abs(pad_input, ABS_MISC, wacom->id[1]);
Ping Cheng84460012011-07-06 18:05:43 -0700427 retval = 1;
Ping Cheng7ecfbfd2007-06-14 23:32:48 -0400428 }
429 break;
Benjamin Tissoires387142b2014-08-06 13:52:56 -0700430 case GRAPHIRE_BT:
431 prox = data[7] & 0x03;
432 if (prox || wacom->id[1]) {
433 wacom->id[1] = PAD_DEVICE_ID;
434 input_report_key(pad_input, BTN_0, (data[7] & 0x02));
435 input_report_key(pad_input, BTN_1, (data[7] & 0x01));
436 if (!prox)
437 wacom->id[1] = 0;
438 input_report_abs(pad_input, ABS_MISC, wacom->id[1]);
439 retval = 1;
440 }
441 break;
442 }
443
444 /* Store current battery capacity and power supply state */
445 if (features->type == GRAPHIRE_BT) {
446 rw = (data[7] >> 2 & 0x07);
447 battery_capacity = batcap_gr[rw];
448 ps_connected = rw == 7;
Jason Gerecke953f2c52015-03-06 11:47:39 -0800449 wacom_notify_battery(wacom, battery_capacity, ps_connected,
Jason Gerecke71fa6412015-03-11 10:25:41 -0700450 1, ps_connected);
Ping Cheng3bea7332006-07-13 18:01:36 -0700451 }
Ping Cheng3b57ca02010-03-04 21:50:59 -0800452exit:
453 return retval;
Ping Cheng3bea7332006-07-13 18:01:36 -0700454}
455
Benjamin Tissoires5fcad162015-03-05 17:36:54 -0500456static void wacom_intuos_schedule_prox_event(struct wacom_wac *wacom_wac)
457{
458 struct wacom *wacom = container_of(wacom_wac, struct wacom, wacom_wac);
Jason Gerecke0bbfe282016-01-06 13:25:53 -0800459 struct wacom_features *features = &wacom_wac->features;
Benjamin Tissoires5fcad162015-03-05 17:36:54 -0500460 struct hid_report *r;
461 struct hid_report_enum *re;
462
463 re = &(wacom->hdev->report_enum[HID_FEATURE_REPORT]);
Jason Gerecke0bbfe282016-01-06 13:25:53 -0800464 if (features->type == INTUOSHT2)
465 r = re->report_id_hash[WACOM_REPORT_INTUOSHT2_ID];
466 else
467 r = re->report_id_hash[WACOM_REPORT_INTUOS_ID1];
Benjamin Tissoires5fcad162015-03-05 17:36:54 -0500468 if (r) {
469 hid_hw_request(wacom->hdev, r, HID_REQ_GET_REPORT);
470 }
471}
472
Jason Gereckefb013a02015-11-30 17:13:46 -0800473static int wacom_intuos_pad(struct wacom_wac *wacom)
474{
475 struct wacom_features *features = &wacom->features;
476 unsigned char *data = wacom->data;
477 struct input_dev *input = wacom->pad_input;
Jason Gereckec7f05222015-11-30 17:13:47 -0800478 int i;
479 int buttons = 0, nbuttons = features->numbered_buttons;
480 int keys = 0, nkeys = 0;
481 int ring1 = 0, ring2 = 0;
482 int strip1 = 0, strip2 = 0;
483 bool prox = false;
Jason Gereckefb013a02015-11-30 17:13:46 -0800484
485 /* pad packets. Works as a second tool and is always in prox */
486 if (!(data[0] == WACOM_REPORT_INTUOSPAD || data[0] == WACOM_REPORT_INTUOS5PAD ||
487 data[0] == WACOM_REPORT_CINTIQPAD))
488 return 0;
489
490 if (features->type >= INTUOS4S && features->type <= INTUOS4L) {
Jason Gereckec7f05222015-11-30 17:13:47 -0800491 buttons = (data[3] << 1) | (data[2] & 0x01);
492 ring1 = data[1];
Jason Gereckefb013a02015-11-30 17:13:46 -0800493 } else if (features->type == DTK) {
Jason Gereckec7f05222015-11-30 17:13:47 -0800494 buttons = data[6];
Jason Gereckefb013a02015-11-30 17:13:46 -0800495 } else if (features->type == WACOM_13HD) {
Jason Gereckec7f05222015-11-30 17:13:47 -0800496 buttons = (data[4] << 1) | (data[3] & 0x01);
Jason Gereckefb013a02015-11-30 17:13:46 -0800497 } else if (features->type == WACOM_24HD) {
Jason Gereckec7f05222015-11-30 17:13:47 -0800498 buttons = (data[8] << 8) | data[6];
499 ring1 = data[1];
500 ring2 = data[2];
Jason Gereckefb013a02015-11-30 17:13:46 -0800501
502 /*
503 * Three "buttons" are available on the 24HD which are
504 * physically implemented as a touchstrip. Each button
505 * is approximately 3 bits wide with a 2 bit spacing.
506 * The raw touchstrip bits are stored at:
507 * ((data[3] & 0x1f) << 8) | data[4])
508 */
Jason Gereckec7f05222015-11-30 17:13:47 -0800509 nkeys = 3;
510 keys = ((data[3] & 0x1C) ? 1<<2 : 0) |
511 ((data[4] & 0xE0) ? 1<<1 : 0) |
512 ((data[4] & 0x07) ? 1<<0 : 0);
Jason Gereckefb013a02015-11-30 17:13:46 -0800513 } else if (features->type == WACOM_27QHD) {
Jason Gereckec7f05222015-11-30 17:13:47 -0800514 nkeys = 3;
515 keys = data[2] & 0x07;
Jason Gereckefb013a02015-11-30 17:13:46 -0800516
517 input_report_abs(input, ABS_X, be16_to_cpup((__be16 *)&data[4]));
518 input_report_abs(input, ABS_Y, be16_to_cpup((__be16 *)&data[6]));
519 input_report_abs(input, ABS_Z, be16_to_cpup((__be16 *)&data[8]));
Jason Gereckefb013a02015-11-30 17:13:46 -0800520 } else if (features->type == CINTIQ_HYBRID) {
521 /*
522 * Do not send hardware buttons under Android. They
523 * are already sent to the system through GPIO (and
524 * have different meaning).
Jason Gereckec7f05222015-11-30 17:13:47 -0800525 *
526 * d-pad right -> data[4] & 0x10
527 * d-pad up -> data[4] & 0x20
528 * d-pad left -> data[4] & 0x40
529 * d-pad down -> data[4] & 0x80
530 * d-pad center -> data[3] & 0x01
Jason Gereckefb013a02015-11-30 17:13:46 -0800531 */
Jason Gereckec7f05222015-11-30 17:13:47 -0800532 buttons = (data[4] << 1) | (data[3] & 0x01);
Jason Gereckefb013a02015-11-30 17:13:46 -0800533 } else if (features->type == CINTIQ_COMPANION_2) {
Jason Gereckec7f05222015-11-30 17:13:47 -0800534 /* d-pad right -> data[4] & 0x10
535 * d-pad up -> data[4] & 0x20
536 * d-pad left -> data[4] & 0x40
537 * d-pad down -> data[4] & 0x80
538 * d-pad center -> data[3] & 0x01
539 */
Jason Gerecke0402b6b2015-12-16 13:37:36 -0800540 buttons = ((data[2] >> 4) << 7) |
Jason Gereckec7f05222015-11-30 17:13:47 -0800541 ((data[1] & 0x04) << 6) |
542 ((data[2] & 0x0F) << 2) |
543 (data[1] & 0x03);
Jason Gereckefb013a02015-11-30 17:13:46 -0800544 } else if (features->type >= INTUOS5S && features->type <= INTUOSPL) {
Jason Gereckefb013a02015-11-30 17:13:46 -0800545 /*
546 * ExpressKeys on Intuos5/Intuos Pro have a capacitive sensor in
547 * addition to the mechanical switch. Switch data is
548 * stored in data[4], capacitive data in data[5].
Jason Gereckec7f05222015-11-30 17:13:47 -0800549 *
550 * Touch ring mode switch (data[3]) has no capacitive sensor
Jason Gereckefb013a02015-11-30 17:13:46 -0800551 */
Jason Gereckec7f05222015-11-30 17:13:47 -0800552 buttons = (data[4] << 1) | (data[3] & 0x01);
553 ring1 = data[2];
Jason Gereckefb013a02015-11-30 17:13:46 -0800554 } else {
555 if (features->type == WACOM_21UX2 || features->type == WACOM_22HD) {
Jason Gereckec7f05222015-11-30 17:13:47 -0800556 buttons = (data[8] << 10) | ((data[7] & 0x01) << 9) |
557 (data[6] << 1) | (data[5] & 0x01);
Jason Gereckefb013a02015-11-30 17:13:46 -0800558
559 if (features->type == WACOM_22HD) {
Jason Gereckec7f05222015-11-30 17:13:47 -0800560 nkeys = 3;
561 keys = data[9] & 0x07;
Jason Gereckefb013a02015-11-30 17:13:46 -0800562 }
563 } else {
Jason Gereckec7f05222015-11-30 17:13:47 -0800564 buttons = ((data[6] & 0x10) << 10) |
565 ((data[5] & 0x10) << 9) |
566 ((data[6] & 0x0F) << 4) |
567 (data[5] & 0x0F);
Jason Gereckefb013a02015-11-30 17:13:46 -0800568 }
Jason Gereckef73d08d2015-12-16 13:37:33 -0800569 strip1 = ((data[1] & 0x1f) << 8) | data[2];
570 strip2 = ((data[3] & 0x1f) << 8) | data[4];
Jason Gereckefb013a02015-11-30 17:13:46 -0800571 }
Jason Gereckec7f05222015-11-30 17:13:47 -0800572
Dan Carpenter8f9cfdd2015-12-09 13:22:05 +0300573 prox = (buttons & ~(~0 << nbuttons)) | (keys & ~(~0 << nkeys)) |
574 (ring1 & 0x80) | (ring2 & 0x80) | strip1 | strip2;
Jason Gereckec7f05222015-11-30 17:13:47 -0800575
576 wacom_report_numbered_buttons(input, nbuttons, buttons);
577
578 for (i = 0; i < nkeys; i++)
579 input_report_key(input, KEY_PROG1 + i, keys & (1 << i));
580
581 input_report_abs(input, ABS_RX, strip1);
Jason Gerecke03a0dc52015-12-16 13:37:34 -0800582 input_report_abs(input, ABS_RY, strip2);
Jason Gereckec7f05222015-11-30 17:13:47 -0800583
Jason Gereckeaaae03e2015-12-16 13:37:35 -0800584 input_report_abs(input, ABS_WHEEL, (ring1 & 0x80) ? (ring1 & 0x7f) : 0);
585 input_report_abs(input, ABS_THROTTLE, (ring2 & 0x80) ? (ring2 & 0x7f) : 0);
Jason Gereckec7f05222015-11-30 17:13:47 -0800586
587 input_report_key(input, wacom->tool[1], prox ? 1 : 0);
588 input_report_abs(input, ABS_MISC, prox ? PAD_DEVICE_ID : 0);
589
590 input_event(input, EV_MSC, MSC_SERIAL, 0xffffffff);
591
Jason Gereckefb013a02015-11-30 17:13:46 -0800592 return 1;
593}
594
Jason Gerecke82527da2016-10-19 18:03:47 -0700595static int wacom_intuos_id_mangle(int tool_id)
596{
597 return (tool_id & ~0xFFF) << 4 | (tool_id & 0xFFF);
598}
599
Benjamin Tissoires7e129782016-02-12 17:27:40 +0100600static int wacom_intuos_get_tool_type(int tool_id)
601{
602 int tool_type;
603
604 switch (tool_id) {
605 case 0x812: /* Inking pen */
606 case 0x801: /* Intuos3 Inking pen */
Jason Gerecke82527da2016-10-19 18:03:47 -0700607 case 0x12802: /* Intuos4/5 Inking Pen */
Benjamin Tissoires7e129782016-02-12 17:27:40 +0100608 case 0x012:
609 tool_type = BTN_TOOL_PENCIL;
610 break;
611
612 case 0x822: /* Pen */
613 case 0x842:
614 case 0x852:
615 case 0x823: /* Intuos3 Grip Pen */
616 case 0x813: /* Intuos3 Classic Pen */
617 case 0x885: /* Intuos3 Marker Pen */
618 case 0x802: /* Intuos4/5 13HD/24HD General Pen */
619 case 0x804: /* Intuos4/5 13HD/24HD Marker Pen */
620 case 0x8e2: /* IntuosHT2 pen */
621 case 0x022:
Jason Gerecke82527da2016-10-19 18:03:47 -0700622 case 0x10804: /* Intuos4/5 13HD/24HD Art Pen */
623 case 0x14802: /* Intuos4/5 13HD/24HD Classic Pen */
624 case 0x16802: /* Cintiq 13HD Pro Pen */
625 case 0x18802: /* DTH2242 Pen */
626 case 0x10802: /* Intuos4/5 13HD/24HD General Pen */
Benjamin Tissoires7e129782016-02-12 17:27:40 +0100627 tool_type = BTN_TOOL_PEN;
628 break;
629
630 case 0x832: /* Stroke pen */
631 case 0x032:
632 tool_type = BTN_TOOL_BRUSH;
633 break;
634
635 case 0x007: /* Mouse 4D and 2D */
636 case 0x09c:
637 case 0x094:
638 case 0x017: /* Intuos3 2D Mouse */
639 case 0x806: /* Intuos4 Mouse */
640 tool_type = BTN_TOOL_MOUSE;
641 break;
642
643 case 0x096: /* Lens cursor */
644 case 0x097: /* Intuos3 Lens cursor */
645 case 0x006: /* Intuos4 Lens cursor */
646 tool_type = BTN_TOOL_LENS;
647 break;
648
649 case 0x82a: /* Eraser */
Jason Gerecke9ce9a122016-11-11 15:05:52 -0800650 case 0x84a:
Benjamin Tissoires7e129782016-02-12 17:27:40 +0100651 case 0x85a:
652 case 0x91a:
653 case 0xd1a:
654 case 0x0fa:
655 case 0x82b: /* Intuos3 Grip Pen Eraser */
656 case 0x81b: /* Intuos3 Classic Pen Eraser */
657 case 0x91b: /* Intuos3 Airbrush Eraser */
658 case 0x80c: /* Intuos4/5 13HD/24HD Marker Pen Eraser */
659 case 0x80a: /* Intuos4/5 13HD/24HD General Pen Eraser */
660 case 0x90a: /* Intuos4/5 13HD/24HD Airbrush Eraser */
Jason Gerecke82527da2016-10-19 18:03:47 -0700661 case 0x1480a: /* Intuos4/5 13HD/24HD Classic Pen Eraser */
662 case 0x1090a: /* Intuos4/5 13HD/24HD Airbrush Eraser */
663 case 0x1080c: /* Intuos4/5 13HD/24HD Art Pen Eraser */
664 case 0x1680a: /* Cintiq 13HD Pro Pen Eraser */
665 case 0x1880a: /* DTH2242 Eraser */
666 case 0x1080a: /* Intuos4/5 13HD/24HD General Pen Eraser */
Benjamin Tissoires7e129782016-02-12 17:27:40 +0100667 tool_type = BTN_TOOL_RUBBER;
668 break;
669
670 case 0xd12:
671 case 0x912:
672 case 0x112:
673 case 0x913: /* Intuos3 Airbrush */
674 case 0x902: /* Intuos4/5 13HD/24HD Airbrush */
Jason Gerecke82527da2016-10-19 18:03:47 -0700675 case 0x10902: /* Intuos4/5 13HD/24HD Airbrush */
Benjamin Tissoires7e129782016-02-12 17:27:40 +0100676 tool_type = BTN_TOOL_AIRBRUSH;
677 break;
678
679 default: /* Unknown tool */
680 tool_type = BTN_TOOL_PEN;
681 break;
682 }
683 return tool_type;
684}
685
Dmitry Torokhov95dd3b32010-03-19 22:18:15 -0700686static int wacom_intuos_inout(struct wacom_wac *wacom)
Ping Cheng3bea7332006-07-13 18:01:36 -0700687{
Jason Childse33da8a2010-02-17 22:38:31 -0800688 struct wacom_features *features = &wacom->features;
Ping Cheng3bea7332006-07-13 18:01:36 -0700689 unsigned char *data = wacom->data;
Jason Gerecke2a6cdbd2015-06-15 18:01:45 -0700690 struct input_dev *input = wacom->pen_input;
Ping Cheng4750f5f2016-01-08 17:15:48 -0800691 int idx = (features->type == INTUOS) ? (data[1] & 0x01) : 0;
Ping Cheng3bea7332006-07-13 18:01:36 -0700692
Ping Cheng4750f5f2016-01-08 17:15:48 -0800693 if (!(((data[1] & 0xfc) == 0xc0) || /* in prox */
694 ((data[1] & 0xfe) == 0x20) || /* in range */
695 ((data[1] & 0xfe) == 0x80))) /* out prox */
696 return 0;
Ping Cheng3bea7332006-07-13 18:01:36 -0700697
698 /* Enter report */
699 if ((data[1] & 0xfc) == 0xc0) {
700 /* serial number of the tool */
701 wacom->serial[idx] = ((data[3] & 0x0f) << 28) +
702 (data[4] << 20) + (data[5] << 12) +
703 (data[6] << 4) + (data[7] >> 4);
704
Ping Cheng493630b2010-06-22 11:21:34 -0700705 wacom->id[idx] = (data[2] << 4) | (data[3] >> 4) |
Jason Gerecke82527da2016-10-19 18:03:47 -0700706 ((data[7] & 0x0f) << 16) | ((data[8] & 0xf0) << 8);
Dmitry Torokhov73a97f42010-03-19 22:18:15 -0700707
Benjamin Tissoires7e129782016-02-12 17:27:40 +0100708 wacom->tool[idx] = wacom_intuos_get_tool_type(wacom->id[idx]);
Dmitry Torokhov73a97f42010-03-19 22:18:15 -0700709
Ping Chengeff6ca92016-05-02 21:17:34 -0700710 wacom->shared->stylus_in_proximity = true;
Ping Cheng3bea7332006-07-13 18:01:36 -0700711 return 1;
712 }
713
Ping Chengc1b03f52016-01-08 17:16:06 -0800714 /* in Range */
715 if ((data[1] & 0xfe) == 0x20) {
Ping Cheng526d6e72016-01-08 17:16:25 -0800716 if (features->type != INTUOSHT2)
717 wacom->shared->stylus_in_proximity = true;
Ping Cheng486b9082015-02-20 14:25:58 -0800718
Ping Chengc1b03f52016-01-08 17:16:06 -0800719 /* in Range while exiting */
720 if (wacom->reporting_data) {
721 input_report_key(input, BTN_TOUCH, 0);
722 input_report_abs(input, ABS_PRESSURE, 0);
723 input_report_abs(input, ABS_DISTANCE, wacom->features.distance_max);
724 return 2;
725 }
726 return 1;
Jason Gerecke4eb18302013-09-20 09:48:46 -0700727 }
728
Ping Cheng3bea7332006-07-13 18:01:36 -0700729 /* Exit report */
730 if ((data[1] & 0xfe) == 0x80) {
Ping Chengf3586d22015-03-20 14:57:00 -0700731 wacom->shared->stylus_in_proximity = false;
Ping Chengb3bd7ef2015-01-09 11:05:13 -0800732 wacom->reporting_data = false;
Jason Gereckeae584ca2012-04-03 15:50:40 -0700733
Ping Cheng373a5352015-01-09 11:04:50 -0800734 /* don't report exit if we don't know the ID */
735 if (!wacom->id[idx])
736 return 1;
737
Ping Cheng6f660f12009-05-08 18:30:33 -0700738 /*
739 * Reset all states otherwise we lose the initial states
740 * when in-prox next time
741 */
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700742 input_report_abs(input, ABS_X, 0);
743 input_report_abs(input, ABS_Y, 0);
744 input_report_abs(input, ABS_DISTANCE, 0);
745 input_report_abs(input, ABS_TILT_X, 0);
746 input_report_abs(input, ABS_TILT_Y, 0);
Ping Cheng80d4e8e2007-02-23 12:22:48 -0800747 if (wacom->tool[idx] >= BTN_TOOL_MOUSE) {
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700748 input_report_key(input, BTN_LEFT, 0);
749 input_report_key(input, BTN_MIDDLE, 0);
750 input_report_key(input, BTN_RIGHT, 0);
751 input_report_key(input, BTN_SIDE, 0);
752 input_report_key(input, BTN_EXTRA, 0);
753 input_report_abs(input, ABS_THROTTLE, 0);
754 input_report_abs(input, ABS_RZ, 0);
Ping Cheng7ecfbfd2007-06-14 23:32:48 -0400755 } else {
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700756 input_report_abs(input, ABS_PRESSURE, 0);
757 input_report_key(input, BTN_STYLUS, 0);
758 input_report_key(input, BTN_STYLUS2, 0);
759 input_report_key(input, BTN_TOUCH, 0);
760 input_report_abs(input, ABS_WHEEL, 0);
Jason Childse33da8a2010-02-17 22:38:31 -0800761 if (features->type >= INTUOS3S)
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700762 input_report_abs(input, ABS_Z, 0);
Ping Cheng8d32e3a2006-09-26 13:34:47 -0700763 }
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700764 input_report_key(input, wacom->tool[idx], 0);
765 input_report_abs(input, ABS_MISC, 0); /* reset tool id */
766 input_event(input, EV_MSC, MSC_SERIAL, wacom->serial[idx]);
Ping Cheng6f660f12009-05-08 18:30:33 -0700767 wacom->id[idx] = 0;
Ping Cheng80d4e8e2007-02-23 12:22:48 -0800768 return 2;
Ping Cheng3bea7332006-07-13 18:01:36 -0700769 }
Ping Cheng373a5352015-01-09 11:04:50 -0800770
Ping Cheng3bea7332006-07-13 18:01:36 -0700771 return 0;
772}
773
Aaron Skomra72b236d2015-08-20 16:05:17 -0700774static int wacom_remote_irq(struct wacom_wac *wacom_wac, size_t len)
775{
776 unsigned char *data = wacom_wac->data;
Benjamin Tissoires7c35dc32016-07-13 18:06:07 +0200777 struct input_dev *input;
Aaron Skomra72b236d2015-08-20 16:05:17 -0700778 struct wacom *wacom = container_of(wacom_wac, struct wacom, wacom_wac);
Benjamin Tissoires83e6b402016-07-13 18:06:02 +0200779 struct wacom_remote *remote = wacom->remote;
Aaron Skomra72b236d2015-08-20 16:05:17 -0700780 int bat_charging, bat_percent, touch_ring_mode;
781 __u32 serial;
Benjamin Tissoires7c35dc32016-07-13 18:06:07 +0200782 int i, index = -1;
783 unsigned long flags;
Aaron Skomra72b236d2015-08-20 16:05:17 -0700784
785 if (data[0] != WACOM_REPORT_REMOTE) {
Benjamin Tissoires7c35dc32016-07-13 18:06:07 +0200786 hid_dbg(wacom->hdev, "%s: received unknown report #%d",
787 __func__, data[0]);
Aaron Skomra72b236d2015-08-20 16:05:17 -0700788 return 0;
789 }
790
791 serial = data[3] + (data[4] << 8) + (data[5] << 16);
792 wacom_wac->id[0] = PAD_DEVICE_ID;
793
Benjamin Tissoires7c35dc32016-07-13 18:06:07 +0200794 spin_lock_irqsave(&remote->remote_lock, flags);
795
796 for (i = 0; i < WACOM_MAX_REMOTES; i++) {
797 if (remote->remotes[i].serial == serial) {
798 index = i;
799 break;
800 }
801 }
802
803 if (index < 0 || !remote->remotes[index].registered)
804 goto out;
805
806 input = remote->remotes[index].input;
807
Aaron Skomra72b236d2015-08-20 16:05:17 -0700808 input_report_key(input, BTN_0, (data[9] & 0x01));
809 input_report_key(input, BTN_1, (data[9] & 0x02));
810 input_report_key(input, BTN_2, (data[9] & 0x04));
811 input_report_key(input, BTN_3, (data[9] & 0x08));
812 input_report_key(input, BTN_4, (data[9] & 0x10));
813 input_report_key(input, BTN_5, (data[9] & 0x20));
814 input_report_key(input, BTN_6, (data[9] & 0x40));
815 input_report_key(input, BTN_7, (data[9] & 0x80));
816
817 input_report_key(input, BTN_8, (data[10] & 0x01));
818 input_report_key(input, BTN_9, (data[10] & 0x02));
819 input_report_key(input, BTN_A, (data[10] & 0x04));
820 input_report_key(input, BTN_B, (data[10] & 0x08));
821 input_report_key(input, BTN_C, (data[10] & 0x10));
822 input_report_key(input, BTN_X, (data[10] & 0x20));
823 input_report_key(input, BTN_Y, (data[10] & 0x40));
824 input_report_key(input, BTN_Z, (data[10] & 0x80));
825
826 input_report_key(input, BTN_BASE, (data[11] & 0x01));
827 input_report_key(input, BTN_BASE2, (data[11] & 0x02));
828
829 if (data[12] & 0x80)
830 input_report_abs(input, ABS_WHEEL, (data[12] & 0x7f));
831 else
832 input_report_abs(input, ABS_WHEEL, 0);
833
834 bat_percent = data[7] & 0x7f;
835 bat_charging = !!(data[7] & 0x80);
836
837 if (data[9] | data[10] | (data[11] & 0x03) | data[12])
838 input_report_abs(input, ABS_MISC, PAD_DEVICE_ID);
839 else
840 input_report_abs(input, ABS_MISC, 0);
841
842 input_event(input, EV_MSC, MSC_SERIAL, serial);
843
Benjamin Tissoires7c35dc32016-07-13 18:06:07 +0200844 input_sync(input);
845
Aaron Skomra72b236d2015-08-20 16:05:17 -0700846 /*Which mode select (LED light) is currently on?*/
847 touch_ring_mode = (data[11] & 0xC0) >> 6;
848
849 for (i = 0; i < WACOM_MAX_REMOTES; i++) {
Benjamin Tissoirese7749f62016-07-13 18:06:06 +0200850 if (remote->remotes[i].serial == serial)
Benjamin Tissoiresa50aac72016-07-13 18:06:00 +0200851 wacom->led.groups[i].select = touch_ring_mode;
Aaron Skomra72b236d2015-08-20 16:05:17 -0700852 }
853
Benjamin Tissoires59d69bc2016-07-13 18:06:08 +0200854 __wacom_notify_battery(&remote->remotes[index].battery, bat_percent,
855 bat_charging, 1, bat_charging);
Aaron Skomra72b236d2015-08-20 16:05:17 -0700856
Benjamin Tissoires7c35dc32016-07-13 18:06:07 +0200857out:
858 spin_unlock_irqrestore(&remote->remote_lock, flags);
859 return 0;
Aaron Skomra72b236d2015-08-20 16:05:17 -0700860}
861
Benjamin Tissoirese6f28132016-07-13 18:06:01 +0200862static void wacom_remote_status_irq(struct wacom_wac *wacom_wac, size_t len)
Aaron Skomra72b236d2015-08-20 16:05:17 -0700863{
864 struct wacom *wacom = container_of(wacom_wac, struct wacom, wacom_wac);
865 unsigned char *data = wacom_wac->data;
Benjamin Tissoires83e6b402016-07-13 18:06:02 +0200866 struct wacom_remote *remote = wacom->remote;
Benjamin Tissoirese6f28132016-07-13 18:06:01 +0200867 struct wacom_remote_data remote_data;
868 unsigned long flags;
869 int i, ret;
Aaron Skomra72b236d2015-08-20 16:05:17 -0700870
871 if (data[0] != WACOM_REPORT_DEVICE_LIST)
Benjamin Tissoirese6f28132016-07-13 18:06:01 +0200872 return;
873
874 memset(&remote_data, 0, sizeof(struct wacom_remote_data));
Aaron Skomra72b236d2015-08-20 16:05:17 -0700875
876 for (i = 0; i < WACOM_MAX_REMOTES; i++) {
877 int j = i * 6;
878 int serial = (data[j+6] << 16) + (data[j+5] << 8) + data[j+4];
879 bool connected = data[j+2];
880
Benjamin Tissoirese6f28132016-07-13 18:06:01 +0200881 remote_data.remote[i].serial = serial;
882 remote_data.remote[i].connected = connected;
Aaron Skomra72b236d2015-08-20 16:05:17 -0700883 }
884
Benjamin Tissoires83e6b402016-07-13 18:06:02 +0200885 spin_lock_irqsave(&remote->remote_lock, flags);
Benjamin Tissoirese6f28132016-07-13 18:06:01 +0200886
Benjamin Tissoires83e6b402016-07-13 18:06:02 +0200887 ret = kfifo_in(&remote->remote_fifo, &remote_data, sizeof(remote_data));
Benjamin Tissoirese6f28132016-07-13 18:06:01 +0200888 if (ret != sizeof(remote_data)) {
Benjamin Tissoires83e6b402016-07-13 18:06:02 +0200889 spin_unlock_irqrestore(&remote->remote_lock, flags);
Benjamin Tissoirese6f28132016-07-13 18:06:01 +0200890 hid_err(wacom->hdev, "Can't queue Remote status event.\n");
891 return;
892 }
893
Benjamin Tissoires83e6b402016-07-13 18:06:02 +0200894 spin_unlock_irqrestore(&remote->remote_lock, flags);
Benjamin Tissoirese6f28132016-07-13 18:06:01 +0200895
896 wacom_schedule_work(wacom_wac, WACOM_WORKER_REMOTE);
Aaron Skomra72b236d2015-08-20 16:05:17 -0700897}
898
Ping Cheng1924e052016-08-09 14:38:56 -0700899static inline bool report_touch_events(struct wacom_wac *wacom)
900{
901 return (touch_arbitration ? !wacom->shared->stylus_in_proximity : 1);
902}
903
904static inline bool delay_pen_events(struct wacom_wac *wacom)
905{
906 return (wacom->shared->touch_down && touch_arbitration);
Ping Cheng3bea7332006-07-13 18:01:36 -0700907}
908
Jason Gerecke16e0a6a2015-11-30 17:13:48 -0800909static int wacom_intuos_general(struct wacom_wac *wacom)
Ping Cheng3bea7332006-07-13 18:01:36 -0700910{
Jason Childse33da8a2010-02-17 22:38:31 -0800911 struct wacom_features *features = &wacom->features;
Ping Cheng3bea7332006-07-13 18:01:36 -0700912 unsigned char *data = wacom->data;
Jason Gerecke2a6cdbd2015-06-15 18:01:45 -0700913 struct input_dev *input = wacom->pen_input;
Jason Gerecke16e0a6a2015-11-30 17:13:48 -0800914 int idx = (features->type == INTUOS) ? (data[1] & 0x01) : 0;
Jason Gereckea8a09c82015-11-30 17:13:49 -0800915 unsigned char type = (data[1] >> 1) & 0x0F;
Jason Gerecke5f33f432015-11-30 17:13:51 -0800916 unsigned int x, y, distance, t;
Ping Cheng3bea7332006-07-13 18:01:36 -0700917
Jason Gerecke16e0a6a2015-11-30 17:13:48 -0800918 if (data[0] != WACOM_REPORT_PENABLED && data[0] != WACOM_REPORT_CINTIQ &&
919 data[0] != WACOM_REPORT_INTUOS_PEN)
920 return 0;
921
Ping Cheng1924e052016-08-09 14:38:56 -0700922 if (delay_pen_events(wacom))
Ping Chengc1b03f52016-01-08 17:16:06 -0800923 return 1;
924
Ping Cheng599b0822016-01-08 17:14:54 -0800925 /* don't report events if we don't know the tool ID */
926 if (!wacom->id[idx]) {
927 /* but reschedule a read of the current tool */
928 wacom_intuos_schedule_prox_event(wacom);
929 return 1;
930 }
931
Ping Cheng4750f5f2016-01-08 17:15:48 -0800932 /*
933 * don't report events for invalid data
934 */
935 /* older I4 styli don't work with new Cintiqs */
Jason Gerecke82527da2016-10-19 18:03:47 -0700936 if ((!((wacom->id[idx] >> 16) & 0x01) &&
Ping Cheng4750f5f2016-01-08 17:15:48 -0800937 (features->type == WACOM_21UX2)) ||
938 /* Only large Intuos support Lense Cursor */
939 (wacom->tool[idx] == BTN_TOOL_LENS &&
940 (features->type == INTUOS3 ||
941 features->type == INTUOS3S ||
942 features->type == INTUOS4 ||
943 features->type == INTUOS4S ||
944 features->type == INTUOS5 ||
945 features->type == INTUOS5S ||
946 features->type == INTUOSPM ||
947 features->type == INTUOSPS)) ||
948 /* Cintiq doesn't send data when RDY bit isn't set */
949 (features->type == CINTIQ && !(data[1] & 0x40)))
950 return 1;
951
Jason Gerecke5f33f432015-11-30 17:13:51 -0800952 x = (be16_to_cpup((__be16 *)&data[2]) << 1) | ((data[9] >> 1) & 1);
953 y = (be16_to_cpup((__be16 *)&data[4]) << 1) | (data[9] & 1);
954 distance = data[9] >> 2;
955 if (features->type < INTUOS3S) {
956 x >>= 1;
957 y >>= 1;
958 distance >>= 1;
Jason Gerecke16e0a6a2015-11-30 17:13:48 -0800959 }
Jason Gerecke5f33f432015-11-30 17:13:51 -0800960 input_report_abs(input, ABS_X, x);
961 input_report_abs(input, ABS_Y, y);
962 input_report_abs(input, ABS_DISTANCE, distance);
Jason Gerecke16e0a6a2015-11-30 17:13:48 -0800963
Jason Gereckea8a09c82015-11-30 17:13:49 -0800964 switch (type) {
965 case 0x00:
966 case 0x01:
967 case 0x02:
968 case 0x03:
969 /* general pen packet */
Jason Gerecke5f33f432015-11-30 17:13:51 -0800970 t = (data[6] << 3) | ((data[7] & 0xC0) >> 5) | (data[1] & 1);
971 if (features->pressure_max < 2047)
972 t >>= 1;
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700973 input_report_abs(input, ABS_PRESSURE, t);
Ping Chengeda01da2015-09-23 13:51:15 -0700974 if (features->type != INTUOSHT2) {
975 input_report_abs(input, ABS_TILT_X,
Jason Gereckeec5fc1c2014-11-18 16:50:08 -0800976 (((data[7] << 1) & 0x7e) | (data[8] >> 7)) - 64);
Ping Chengeda01da2015-09-23 13:51:15 -0700977 input_report_abs(input, ABS_TILT_Y, (data[8] & 0x7f) - 64);
978 }
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700979 input_report_key(input, BTN_STYLUS, data[1] & 2);
980 input_report_key(input, BTN_STYLUS2, data[1] & 4);
981 input_report_key(input, BTN_TOUCH, t > 10);
Jason Gereckea8a09c82015-11-30 17:13:49 -0800982 break;
Ping Cheng3bea7332006-07-13 18:01:36 -0700983
Jason Gereckea8a09c82015-11-30 17:13:49 -0800984 case 0x0a:
Jason Gereckea8a09c82015-11-30 17:13:49 -0800985 /* airbrush second packet */
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700986 input_report_abs(input, ABS_WHEEL,
Ping Cheng3bea7332006-07-13 18:01:36 -0700987 (data[6] << 2) | ((data[7] >> 6) & 3));
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700988 input_report_abs(input, ABS_TILT_X,
Jason Gereckeec5fc1c2014-11-18 16:50:08 -0800989 (((data[7] << 1) & 0x7e) | (data[8] >> 7)) - 64);
990 input_report_abs(input, ABS_TILT_Y, (data[8] & 0x7f) - 64);
Jason Gereckea8a09c82015-11-30 17:13:49 -0800991 break;
992
993 case 0x05:
Jason Gereckea8a09c82015-11-30 17:13:49 -0800994 /* Rotation packet */
995 if (features->type >= INTUOS3S) {
996 /* I3 marker pen rotation */
997 t = (data[6] << 3) | ((data[7] >> 5) & 7);
998 t = (data[7] & 0x20) ? ((t > 900) ? ((t-1) / 2 - 1350) :
999 ((t-1) / 2 + 450)) : (450 - t / 2) ;
1000 input_report_abs(input, ABS_Z, t);
1001 } else {
Jason Gerecke571f5722015-11-30 17:13:50 -08001002 /* 4D mouse 2nd packet */
Jason Gereckea8a09c82015-11-30 17:13:49 -08001003 t = (data[6] << 3) | ((data[7] >> 5) & 7);
1004 input_report_abs(input, ABS_RZ, (data[7] & 0x20) ?
1005 ((t - 1) / 2) : -t / 2);
1006 }
1007 break;
Ping Cheng3bea7332006-07-13 18:01:36 -07001008
Jason Gereckea8a09c82015-11-30 17:13:49 -08001009 case 0x04:
Jason Gerecke571f5722015-11-30 17:13:50 -08001010 /* 4D mouse 1st packet */
1011 input_report_key(input, BTN_LEFT, data[8] & 0x01);
1012 input_report_key(input, BTN_MIDDLE, data[8] & 0x02);
1013 input_report_key(input, BTN_RIGHT, data[8] & 0x04);
1014
1015 input_report_key(input, BTN_SIDE, data[8] & 0x20);
1016 input_report_key(input, BTN_EXTRA, data[8] & 0x10);
1017 t = (data[6] << 2) | ((data[7] >> 6) & 3);
1018 input_report_abs(input, ABS_THROTTLE, (data[8] & 0x08) ? -t : t);
1019 break;
1020
Jason Gereckea8a09c82015-11-30 17:13:49 -08001021 case 0x06:
Jason Gerecke571f5722015-11-30 17:13:50 -08001022 /* I4 mouse */
1023 input_report_key(input, BTN_LEFT, data[6] & 0x01);
1024 input_report_key(input, BTN_MIDDLE, data[6] & 0x02);
1025 input_report_key(input, BTN_RIGHT, data[6] & 0x04);
1026 input_report_rel(input, REL_WHEEL, ((data[7] & 0x80) >> 7)
1027 - ((data[7] & 0x40) >> 6));
1028 input_report_key(input, BTN_SIDE, data[6] & 0x08);
1029 input_report_key(input, BTN_EXTRA, data[6] & 0x10);
1030
1031 input_report_abs(input, ABS_TILT_X,
1032 (((data[7] << 1) & 0x7e) | (data[8] >> 7)) - 64);
1033 input_report_abs(input, ABS_TILT_Y, (data[8] & 0x7f) - 64);
1034 break;
1035
Jason Gereckea8a09c82015-11-30 17:13:49 -08001036 case 0x08:
Jason Gerecke571f5722015-11-30 17:13:50 -08001037 if (wacom->tool[idx] == BTN_TOOL_MOUSE) {
1038 /* 2D mouse packet */
1039 input_report_key(input, BTN_LEFT, data[8] & 0x04);
1040 input_report_key(input, BTN_MIDDLE, data[8] & 0x08);
1041 input_report_key(input, BTN_RIGHT, data[8] & 0x10);
1042 input_report_rel(input, REL_WHEEL, (data[8] & 0x01)
1043 - ((data[8] & 0x02) >> 1));
Ping Cheng3bea7332006-07-13 18:01:36 -07001044
Jason Gerecke571f5722015-11-30 17:13:50 -08001045 /* I3 2D mouse side buttons */
1046 if (features->type >= INTUOS3S && features->type <= INTUOS3L) {
1047 input_report_key(input, BTN_SIDE, data[8] & 0x40);
1048 input_report_key(input, BTN_EXTRA, data[8] & 0x20);
Ping Cheng3bea7332006-07-13 18:01:36 -07001049 }
Jason Gereckea8a09c82015-11-30 17:13:49 -08001050 }
Jason Gerecke571f5722015-11-30 17:13:50 -08001051 else if (wacom->tool[idx] == BTN_TOOL_LENS) {
Ping Cheng3bea7332006-07-13 18:01:36 -07001052 /* Lens cursor packets */
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -07001053 input_report_key(input, BTN_LEFT, data[8] & 0x01);
1054 input_report_key(input, BTN_MIDDLE, data[8] & 0x02);
1055 input_report_key(input, BTN_RIGHT, data[8] & 0x04);
1056 input_report_key(input, BTN_SIDE, data[8] & 0x10);
1057 input_report_key(input, BTN_EXTRA, data[8] & 0x08);
Ping Cheng3bea7332006-07-13 18:01:36 -07001058 }
Jason Gereckea8a09c82015-11-30 17:13:49 -08001059 break;
1060
Jason Gerecke571f5722015-11-30 17:13:50 -08001061 case 0x07:
Jason Gereckea8a09c82015-11-30 17:13:49 -08001062 case 0x09:
Jason Gerecke571f5722015-11-30 17:13:50 -08001063 case 0x0b:
Jason Gereckea8a09c82015-11-30 17:13:49 -08001064 case 0x0c:
1065 case 0x0d:
1066 case 0x0e:
1067 case 0x0f:
1068 /* unhandled */
1069 break;
Ping Cheng3bea7332006-07-13 18:01:36 -07001070 }
Ping Cheng3bea7332006-07-13 18:01:36 -07001071
Jason Gerecke82527da2016-10-19 18:03:47 -07001072 input_report_abs(input, ABS_MISC,
1073 wacom_intuos_id_mangle(wacom->id[idx])); /* report tool id */
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -07001074 input_report_key(input, wacom->tool[idx], 1);
1075 input_event(input, EV_MSC, MSC_SERIAL, wacom->serial[idx]);
Ping Chengb3bd7ef2015-01-09 11:05:13 -08001076 wacom->reporting_data = true;
Jason Gerecke16e0a6a2015-11-30 17:13:48 -08001077 return 2;
Ping Cheng3bea7332006-07-13 18:01:36 -07001078}
1079
1080static int wacom_intuos_irq(struct wacom_wac *wacom)
1081{
Ping Cheng3bea7332006-07-13 18:01:36 -07001082 unsigned char *data = wacom->data;
1083 struct input_dev *input = wacom->pen_input;
Jason Gerecke16e0a6a2015-11-30 17:13:48 -08001084 int result;
Ping Cheng3bea7332006-07-13 18:01:36 -07001085
1086 if (data[0] != WACOM_REPORT_PENABLED &&
Jason Gerecke06109992015-11-30 17:13:52 -08001087 data[0] != WACOM_REPORT_INTUOS_ID1 &&
1088 data[0] != WACOM_REPORT_INTUOS_ID2 &&
Ping Cheng3bea7332006-07-13 18:01:36 -07001089 data[0] != WACOM_REPORT_INTUOSPAD &&
1090 data[0] != WACOM_REPORT_INTUOS_PEN &&
1091 data[0] != WACOM_REPORT_CINTIQ &&
1092 data[0] != WACOM_REPORT_CINTIQPAD &&
1093 data[0] != WACOM_REPORT_INTUOS5PAD) {
1094 dev_dbg(input->dev.parent,
1095 "%s: received unknown report #%d\n", __func__, data[0]);
1096 return 0;
1097 }
1098
Jason Gerecke16e0a6a2015-11-30 17:13:48 -08001099 /* process pad events */
1100 result = wacom_intuos_pad(wacom);
1101 if (result)
1102 return result;
Ping Cheng3bea7332006-07-13 18:01:36 -07001103
1104 /* process in/out prox events */
1105 result = wacom_intuos_inout(wacom);
1106 if (result)
Jason Gerecke16e0a6a2015-11-30 17:13:48 -08001107 return result - 1;
Ping Cheng3bea7332006-07-13 18:01:36 -07001108
1109 /* process general packets */
Jason Gerecke16e0a6a2015-11-30 17:13:48 -08001110 result = wacom_intuos_general(wacom);
1111 if (result)
1112 return result - 1;
Ping Cheng3bea7332006-07-13 18:01:36 -07001113
Jason Gerecke16e0a6a2015-11-30 17:13:48 -08001114 return 0;
Ping Cheng3bea7332006-07-13 18:01:36 -07001115}
1116
Jason Gereckeb1e42792012-10-21 00:38:04 -07001117static int int_dist(int x1, int y1, int x2, int y2)
1118{
1119 int x = x2 - x1;
1120 int y = y2 - y1;
1121
1122 return int_sqrt(x*x + y*y);
1123}
1124
Benjamin Tissoires81af7e62014-08-06 13:55:56 -07001125static void wacom_intuos_bt_process_data(struct wacom_wac *wacom,
1126 unsigned char *data)
1127{
1128 memcpy(wacom->data, data, 10);
1129 wacom_intuos_irq(wacom);
1130
Jason Gerecke2a6cdbd2015-06-15 18:01:45 -07001131 input_sync(wacom->pen_input);
Benjamin Tissoires81af7e62014-08-06 13:55:56 -07001132 if (wacom->pad_input)
1133 input_sync(wacom->pad_input);
1134}
1135
1136static int wacom_intuos_bt_irq(struct wacom_wac *wacom, size_t len)
1137{
1138 unsigned char data[WACOM_PKGLEN_MAX];
1139 int i = 1;
1140 unsigned power_raw, battery_capacity, bat_charging, ps_connected;
1141
1142 memcpy(data, wacom->data, len);
1143
1144 switch (data[0]) {
1145 case 0x04:
1146 wacom_intuos_bt_process_data(wacom, data + i);
1147 i += 10;
1148 /* fall through */
1149 case 0x03:
1150 wacom_intuos_bt_process_data(wacom, data + i);
1151 i += 10;
1152 wacom_intuos_bt_process_data(wacom, data + i);
1153 i += 10;
1154 power_raw = data[i];
1155 bat_charging = (power_raw & 0x08) ? 1 : 0;
1156 ps_connected = (power_raw & 0x10) ? 1 : 0;
1157 battery_capacity = batcap_i4[power_raw & 0x07];
Jason Gerecke953f2c52015-03-06 11:47:39 -08001158 wacom_notify_battery(wacom, battery_capacity, bat_charging,
Jason Gerecke71fa6412015-03-11 10:25:41 -07001159 battery_capacity || bat_charging,
Jason Gerecke953f2c52015-03-06 11:47:39 -08001160 ps_connected);
Benjamin Tissoires81af7e62014-08-06 13:55:56 -07001161 break;
1162 default:
Jason Gerecke2a6cdbd2015-06-15 18:01:45 -07001163 dev_dbg(wacom->pen_input->dev.parent,
Benjamin Tissoires81af7e62014-08-06 13:55:56 -07001164 "Unknown report: %d,%d size:%zu\n",
1165 data[0], data[1], len);
1166 return 0;
1167 }
1168 return 0;
1169}
1170
Ping Cheng7d059ed2015-03-20 14:57:21 -07001171static int wacom_wac_finger_count_touches(struct wacom_wac *wacom)
1172{
Jason Gerecke2a6cdbd2015-06-15 18:01:45 -07001173 struct input_dev *input = wacom->touch_input;
Ping Cheng7d059ed2015-03-20 14:57:21 -07001174 unsigned touch_max = wacom->features.touch_max;
1175 int count = 0;
1176 int i;
1177
Ping Cheng26ba61f2015-05-19 17:42:02 -07001178 if (!touch_max)
1179 return 0;
1180
Jason Gerecke71b5c472015-04-15 17:22:32 -07001181 if (touch_max == 1)
1182 return test_bit(BTN_TOUCH, input->key) &&
Ping Cheng1924e052016-08-09 14:38:56 -07001183 report_touch_events(wacom);
Ping Cheng7d059ed2015-03-20 14:57:21 -07001184
1185 for (i = 0; i < input->mt->num_slots; i++) {
1186 struct input_mt_slot *ps = &input->mt->slots[i];
1187 int id = input_mt_get_value(ps, ABS_MT_TRACKING_ID);
1188 if (id >= 0)
1189 count++;
1190 }
1191
1192 return count;
1193}
1194
Jason Gerecke4922cd22017-01-25 12:08:37 -08001195static void wacom_intuos_pro2_bt_pen(struct wacom_wac *wacom)
1196{
1197 const int pen_frame_len = 14;
1198 const int pen_frames = 7;
1199
1200 struct input_dev *pen_input = wacom->pen_input;
1201 unsigned char *data = wacom->data;
1202 int i;
1203
1204 wacom->serial[0] = get_unaligned_le64(&data[99]);
1205 wacom->id[0] = get_unaligned_le16(&data[107]);
1206 if (wacom->serial[0] >> 52 == 1) {
1207 /* Add back in missing bits of ID for non-USI pens */
1208 wacom->id[0] |= (wacom->serial[0] >> 32) & 0xFFFFF;
1209 }
1210 wacom->tool[0] = wacom_intuos_get_tool_type(wacom_intuos_id_mangle(wacom->id[0]));
1211
1212 for (i = 0; i < pen_frames; i++) {
1213 unsigned char *frame = &data[i*pen_frame_len + 1];
1214
1215 if (!(frame[0] & 0x80))
1216 continue;
1217
1218 input_report_abs(pen_input, ABS_X, get_unaligned_le16(&frame[1]));
1219 input_report_abs(pen_input, ABS_Y, get_unaligned_le16(&frame[3]));
1220 input_report_abs(pen_input, ABS_PRESSURE, get_unaligned_le16(&frame[5]));
1221 input_report_abs(pen_input, ABS_TILT_X, frame[7]);
1222 input_report_abs(pen_input, ABS_TILT_Y, frame[8]);
1223 input_report_abs(pen_input, ABS_Z, get_unaligned_le16(&frame[9]));
1224 input_report_abs(pen_input, ABS_WHEEL, get_unaligned_le16(&frame[11]));
1225 input_report_abs(pen_input, ABS_DISTANCE, frame[13]);
1226
1227 input_report_key(pen_input, BTN_TOUCH, frame[0] & 0x01);
1228 input_report_key(pen_input, BTN_STYLUS, frame[0] & 0x02);
1229 input_report_key(pen_input, BTN_STYLUS2, frame[0] & 0x04);
1230
1231 input_report_key(pen_input, wacom->tool[0], 1);
1232 input_event(pen_input, EV_MSC, MSC_SERIAL, wacom->serial[0]);
1233 input_report_abs(pen_input, ABS_MISC,
1234 wacom_intuos_id_mangle(wacom->id[0])); /* report tool id */
1235
1236 wacom->shared->stylus_in_proximity = frame[0] & 0x40;
1237
1238 input_sync(pen_input);
1239 }
1240}
1241
1242static void wacom_intuos_pro2_bt_touch(struct wacom_wac *wacom)
1243{
1244 const int finger_touch_len = 8;
1245 const int finger_frames = 4;
1246 const int finger_frame_len = 43;
1247
1248 struct input_dev *touch_input = wacom->touch_input;
1249 unsigned char *data = wacom->data;
1250 int num_contacts_left = 5;
1251 int i, j;
1252
1253 for (i = 0; i < finger_frames; i++) {
1254 unsigned char *frame = &data[i*finger_frame_len + 109];
1255 int current_num_contacts = frame[0] & 0x7F;
1256 int contacts_to_send;
1257
1258 if (!(frame[0] & 0x80))
1259 continue;
1260
1261 /*
1262 * First packet resets the counter since only the first
1263 * packet in series will have non-zero current_num_contacts.
1264 */
1265 if (current_num_contacts)
1266 wacom->num_contacts_left = current_num_contacts;
1267
1268 contacts_to_send = min(num_contacts_left, wacom->num_contacts_left);
1269
1270 for (j = 0; j < contacts_to_send; j++) {
1271 unsigned char *touch = &frame[j*finger_touch_len + 1];
1272 int slot = input_mt_get_slot_by_key(touch_input, touch[0]);
1273 int x = get_unaligned_le16(&touch[2]);
1274 int y = get_unaligned_le16(&touch[4]);
1275 int w = touch[6] * input_abs_get_res(touch_input, ABS_MT_POSITION_X);
1276 int h = touch[7] * input_abs_get_res(touch_input, ABS_MT_POSITION_Y);
1277
1278 if (slot < 0)
1279 continue;
1280
1281 input_mt_slot(touch_input, slot);
1282 input_mt_report_slot_state(touch_input, MT_TOOL_FINGER, touch[1] & 0x01);
1283 input_report_abs(touch_input, ABS_MT_POSITION_X, x);
1284 input_report_abs(touch_input, ABS_MT_POSITION_Y, y);
1285 input_report_abs(touch_input, ABS_MT_TOUCH_MAJOR, max(w, h));
1286 input_report_abs(touch_input, ABS_MT_TOUCH_MINOR, min(w, h));
1287 input_report_abs(touch_input, ABS_MT_ORIENTATION, w > h);
1288 }
1289
1290 input_mt_sync_frame(touch_input);
1291
1292 wacom->num_contacts_left -= contacts_to_send;
1293 if (wacom->num_contacts_left <= 0) {
1294 wacom->num_contacts_left = 0;
1295 wacom->shared->touch_down = wacom_wac_finger_count_touches(wacom);
1296 }
1297 }
1298
1299 input_report_switch(touch_input, SW_MUTE_DEVICE, !(data[281] >> 7));
1300 input_sync(touch_input);
1301}
1302
1303static void wacom_intuos_pro2_bt_pad(struct wacom_wac *wacom)
1304{
1305 struct input_dev *pad_input = wacom->pad_input;
1306 unsigned char *data = wacom->data;
1307
1308 int buttons = (data[282] << 1) | ((data[281] >> 6) & 0x01);
1309 int ring = data[285];
1310 int prox = buttons | (ring & 0x80);
1311
1312 wacom_report_numbered_buttons(pad_input, 9, buttons);
1313
1314 input_report_abs(pad_input, ABS_WHEEL, (ring & 0x80) ? (ring & 0x7f) : 0);
1315
1316 input_report_key(pad_input, wacom->tool[1], prox ? 1 : 0);
1317 input_report_abs(pad_input, ABS_MISC, prox ? PAD_DEVICE_ID : 0);
1318 input_event(pad_input, EV_MSC, MSC_SERIAL, 0xffffffff);
1319
1320 input_sync(pad_input);
1321}
1322
1323static void wacom_intuos_pro2_bt_battery(struct wacom_wac *wacom)
1324{
1325 unsigned char *data = wacom->data;
1326
1327 bool chg = data[284] & 0x80;
1328 int battery_status = data[284] & 0x7F;
1329
1330 wacom_notify_battery(wacom, battery_status, chg, 1, chg);
1331}
1332
1333static int wacom_intuos_pro2_bt_irq(struct wacom_wac *wacom, size_t len)
1334{
1335 unsigned char *data = wacom->data;
1336
1337 if (data[0] != 0x80) {
1338 dev_dbg(wacom->pen_input->dev.parent,
1339 "%s: received unknown report #%d\n", __func__, data[0]);
1340 return 0;
1341 }
1342
1343 wacom_intuos_pro2_bt_pen(wacom);
1344 wacom_intuos_pro2_bt_touch(wacom);
1345 wacom_intuos_pro2_bt_pad(wacom);
1346 wacom_intuos_pro2_bt_battery(wacom);
1347 return 0;
1348}
1349
Jason Gereckeb1e42792012-10-21 00:38:04 -07001350static int wacom_24hdt_irq(struct wacom_wac *wacom)
1351{
Jason Gerecke2a6cdbd2015-06-15 18:01:45 -07001352 struct input_dev *input = wacom->touch_input;
Jason Gerecke74b63412014-04-19 13:50:22 -07001353 unsigned char *data = wacom->data;
Jason Gereckeb1e42792012-10-21 00:38:04 -07001354 int i;
Ping Chenge0d41fd2015-02-20 14:27:30 -08001355 int current_num_contacts = data[61];
Jason Gereckeb1e42792012-10-21 00:38:04 -07001356 int contacts_to_send = 0;
Ping Cheng500d4162015-01-27 13:30:03 -08001357 int num_contacts_left = 4; /* maximum contacts per packet */
1358 int byte_per_packet = WACOM_BYTES_PER_24HDT_PACKET;
1359 int y_offset = 2;
1360
1361 if (wacom->features.type == WACOM_27QHDT) {
1362 current_num_contacts = data[63];
1363 num_contacts_left = 10;
1364 byte_per_packet = WACOM_BYTES_PER_QHDTHID_PACKET;
1365 y_offset = 0;
Ping Cheng500d4162015-01-27 13:30:03 -08001366 }
Jason Gereckeb1e42792012-10-21 00:38:04 -07001367
1368 /*
1369 * First packet resets the counter since only the first
1370 * packet in series will have non-zero current_num_contacts.
1371 */
Ping Cheng7d059ed2015-03-20 14:57:21 -07001372 if (current_num_contacts)
Jason Gereckeb1e42792012-10-21 00:38:04 -07001373 wacom->num_contacts_left = current_num_contacts;
1374
Ping Cheng500d4162015-01-27 13:30:03 -08001375 contacts_to_send = min(num_contacts_left, wacom->num_contacts_left);
Jason Gereckeb1e42792012-10-21 00:38:04 -07001376
1377 for (i = 0; i < contacts_to_send; i++) {
Ping Cheng500d4162015-01-27 13:30:03 -08001378 int offset = (byte_per_packet * i) + 1;
Ping Cheng1924e052016-08-09 14:38:56 -07001379 bool touch = (data[offset] & 0x1) && report_touch_events(wacom);
Ping Cheng02295e62013-01-04 23:56:00 -08001380 int slot = input_mt_get_slot_by_key(input, data[offset + 1]);
Jason Gereckeb1e42792012-10-21 00:38:04 -07001381
1382 if (slot < 0)
1383 continue;
1384 input_mt_slot(input, slot);
1385 input_mt_report_slot_state(input, MT_TOOL_FINGER, touch);
1386
1387 if (touch) {
Jason Gereckeedc8e20a2014-05-14 16:53:30 -07001388 int t_x = get_unaligned_le16(&data[offset + 2]);
Ping Cheng500d4162015-01-27 13:30:03 -08001389 int t_y = get_unaligned_le16(&data[offset + 4 + y_offset]);
Jason Gereckeb1e42792012-10-21 00:38:04 -07001390
1391 input_report_abs(input, ABS_MT_POSITION_X, t_x);
1392 input_report_abs(input, ABS_MT_POSITION_Y, t_y);
Ping Cheng500d4162015-01-27 13:30:03 -08001393
1394 if (wacom->features.type != WACOM_27QHDT) {
1395 int c_x = get_unaligned_le16(&data[offset + 4]);
1396 int c_y = get_unaligned_le16(&data[offset + 8]);
1397 int w = get_unaligned_le16(&data[offset + 10]);
1398 int h = get_unaligned_le16(&data[offset + 12]);
1399
1400 input_report_abs(input, ABS_MT_TOUCH_MAJOR, min(w,h));
1401 input_report_abs(input, ABS_MT_WIDTH_MAJOR,
1402 min(w, h) + int_dist(t_x, t_y, c_x, c_y));
1403 input_report_abs(input, ABS_MT_WIDTH_MINOR, min(w, h));
1404 input_report_abs(input, ABS_MT_ORIENTATION, w > h);
1405 }
Jason Gereckeb1e42792012-10-21 00:38:04 -07001406 }
Jason Gereckeb1e42792012-10-21 00:38:04 -07001407 }
Benjamin Tissoires9a1c0012015-02-17 14:19:46 -05001408 input_mt_sync_frame(input);
Jason Gereckeb1e42792012-10-21 00:38:04 -07001409
1410 wacom->num_contacts_left -= contacts_to_send;
Ping Chenge0d41fd2015-02-20 14:27:30 -08001411 if (wacom->num_contacts_left <= 0) {
Jason Gereckeb1e42792012-10-21 00:38:04 -07001412 wacom->num_contacts_left = 0;
Ping Cheng7d059ed2015-03-20 14:57:21 -07001413 wacom->shared->touch_down = wacom_wac_finger_count_touches(wacom);
Ping Chenge0d41fd2015-02-20 14:27:30 -08001414 }
Jason Gereckeb1e42792012-10-21 00:38:04 -07001415 return 1;
1416}
1417
Ping Cheng19635182012-04-29 21:09:18 -07001418static int wacom_mt_touch(struct wacom_wac *wacom)
1419{
Jason Gerecke2a6cdbd2015-06-15 18:01:45 -07001420 struct input_dev *input = wacom->touch_input;
Jason Gerecke74b63412014-04-19 13:50:22 -07001421 unsigned char *data = wacom->data;
Ping Cheng19635182012-04-29 21:09:18 -07001422 int i;
1423 int current_num_contacts = data[2];
1424 int contacts_to_send = 0;
Ping Cheng6afdc282012-11-03 12:16:15 -07001425 int x_offset = 0;
1426
1427 /* MTTPC does not support Height and Width */
Jason Gerecked51ddb22014-05-14 17:14:29 -07001428 if (wacom->features.type == MTTPC || wacom->features.type == MTTPC_B)
Ping Cheng6afdc282012-11-03 12:16:15 -07001429 x_offset = -4;
Ping Cheng19635182012-04-29 21:09:18 -07001430
1431 /*
1432 * First packet resets the counter since only the first
1433 * packet in series will have non-zero current_num_contacts.
1434 */
Ping Cheng7d059ed2015-03-20 14:57:21 -07001435 if (current_num_contacts)
Ping Cheng19635182012-04-29 21:09:18 -07001436 wacom->num_contacts_left = current_num_contacts;
1437
1438 /* There are at most 5 contacts per packet */
1439 contacts_to_send = min(5, wacom->num_contacts_left);
1440
1441 for (i = 0; i < contacts_to_send; i++) {
Ping Cheng6afdc282012-11-03 12:16:15 -07001442 int offset = (WACOM_BYTES_PER_MT_PACKET + x_offset) * i + 3;
Ping Cheng1924e052016-08-09 14:38:56 -07001443 bool touch = (data[offset] & 0x1) && report_touch_events(wacom);
Jason Gereckeedc8e20a2014-05-14 16:53:30 -07001444 int id = get_unaligned_le16(&data[offset + 1]);
Ping Cheng02295e62013-01-04 23:56:00 -08001445 int slot = input_mt_get_slot_by_key(input, id);
Ping Cheng19635182012-04-29 21:09:18 -07001446
1447 if (slot < 0)
1448 continue;
1449
1450 input_mt_slot(input, slot);
1451 input_mt_report_slot_state(input, MT_TOOL_FINGER, touch);
1452 if (touch) {
Jason Gereckeedc8e20a2014-05-14 16:53:30 -07001453 int x = get_unaligned_le16(&data[offset + x_offset + 7]);
1454 int y = get_unaligned_le16(&data[offset + x_offset + 9]);
Ping Cheng19635182012-04-29 21:09:18 -07001455 input_report_abs(input, ABS_MT_POSITION_X, x);
1456 input_report_abs(input, ABS_MT_POSITION_Y, y);
1457 }
Ping Cheng19635182012-04-29 21:09:18 -07001458 }
Benjamin Tissoires9a1c0012015-02-17 14:19:46 -05001459 input_mt_sync_frame(input);
Ping Cheng19635182012-04-29 21:09:18 -07001460
1461 wacom->num_contacts_left -= contacts_to_send;
Ping Chenge0d41fd2015-02-20 14:27:30 -08001462 if (wacom->num_contacts_left <= 0) {
Ping Cheng19635182012-04-29 21:09:18 -07001463 wacom->num_contacts_left = 0;
Ping Cheng7d059ed2015-03-20 14:57:21 -07001464 wacom->shared->touch_down = wacom_wac_finger_count_touches(wacom);
Ping Chenge0d41fd2015-02-20 14:27:30 -08001465 }
Ping Cheng19635182012-04-29 21:09:18 -07001466 return 1;
1467}
1468
Ping Cheng84eb5aa2011-03-12 20:35:18 -08001469static int wacom_tpc_mt_touch(struct wacom_wac *wacom)
1470{
Jason Gerecke2a6cdbd2015-06-15 18:01:45 -07001471 struct input_dev *input = wacom->touch_input;
Ping Cheng84eb5aa2011-03-12 20:35:18 -08001472 unsigned char *data = wacom->data;
Ping Cheng84eb5aa2011-03-12 20:35:18 -08001473 int i;
1474
1475 for (i = 0; i < 2; i++) {
1476 int p = data[1] & (1 << i);
Ping Cheng1924e052016-08-09 14:38:56 -07001477 bool touch = p && report_touch_events(wacom);
Ping Cheng84eb5aa2011-03-12 20:35:18 -08001478
1479 input_mt_slot(input, i);
1480 input_mt_report_slot_state(input, MT_TOOL_FINGER, touch);
1481 if (touch) {
1482 int x = le16_to_cpup((__le16 *)&data[i * 2 + 2]) & 0x7fff;
1483 int y = le16_to_cpup((__le16 *)&data[i * 2 + 6]) & 0x7fff;
1484
1485 input_report_abs(input, ABS_MT_POSITION_X, x);
1486 input_report_abs(input, ABS_MT_POSITION_Y, y);
Ping Cheng84eb5aa2011-03-12 20:35:18 -08001487 }
1488 }
Benjamin Tissoires9a1c0012015-02-17 14:19:46 -05001489 input_mt_sync_frame(input);
Ping Cheng84eb5aa2011-03-12 20:35:18 -08001490
1491 /* keep touch state for pen event */
Ping Cheng7d059ed2015-03-20 14:57:21 -07001492 wacom->shared->touch_down = wacom_wac_finger_count_touches(wacom);
Ping Cheng84eb5aa2011-03-12 20:35:18 -08001493
Ping Cheng84eb5aa2011-03-12 20:35:18 -08001494 return 1;
1495}
1496
Ping Chenga43c7c52011-03-12 20:34:42 -08001497static int wacom_tpc_single_touch(struct wacom_wac *wacom, size_t len)
Ping Chengec67bbe2009-12-15 00:35:24 -08001498{
Jason Gerecke74b63412014-04-19 13:50:22 -07001499 unsigned char *data = wacom->data;
Jason Gerecke2a6cdbd2015-06-15 18:01:45 -07001500 struct input_dev *input = wacom->touch_input;
Ping Cheng1924e052016-08-09 14:38:56 -07001501 bool prox = report_touch_events(wacom);
Ping Chenga43c7c52011-03-12 20:34:42 -08001502 int x = 0, y = 0;
Ping Chengec67bbe2009-12-15 00:35:24 -08001503
Ping Cheng19635182012-04-29 21:09:18 -07001504 if (wacom->features.touch_max > 1 || len > WACOM_PKGLEN_TPC2FG)
1505 return 0;
1506
Ping Chenge0d41fd2015-02-20 14:27:30 -08001507 if (len == WACOM_PKGLEN_TPC1FG) {
1508 prox = prox && (data[0] & 0x01);
1509 x = get_unaligned_le16(&data[1]);
1510 y = get_unaligned_le16(&data[3]);
1511 } else if (len == WACOM_PKGLEN_TPC1FG_B) {
1512 prox = prox && (data[2] & 0x01);
1513 x = get_unaligned_le16(&data[3]);
1514 y = get_unaligned_le16(&data[5]);
1515 } else {
1516 prox = prox && (data[1] & 0x01);
1517 x = le16_to_cpup((__le16 *)&data[2]);
1518 y = le16_to_cpup((__le16 *)&data[4]);
1519 }
Ping Chenga43c7c52011-03-12 20:34:42 -08001520
1521 if (prox) {
1522 input_report_abs(input, ABS_X, x);
1523 input_report_abs(input, ABS_Y, y);
Ping Chengec67bbe2009-12-15 00:35:24 -08001524 }
Ping Chenga43c7c52011-03-12 20:34:42 -08001525 input_report_key(input, BTN_TOUCH, prox);
1526
1527 /* keep touch state for pen events */
1528 wacom->shared->touch_down = prox;
1529
1530 return 1;
Ping Chengec67bbe2009-12-15 00:35:24 -08001531}
1532
Ping Cheng8aa9a9a2011-03-12 20:34:11 -08001533static int wacom_tpc_pen(struct wacom_wac *wacom)
Ping Cheng545f4e92008-11-24 11:44:27 -05001534{
Jason Gerecke74b63412014-04-19 13:50:22 -07001535 unsigned char *data = wacom->data;
Jason Gerecke2a6cdbd2015-06-15 18:01:45 -07001536 struct input_dev *input = wacom->pen_input;
Ping Chenga43c7c52011-03-12 20:34:42 -08001537 bool prox = data[1] & 0x20;
Ping Cheng8aa9a9a2011-03-12 20:34:11 -08001538
Ping Chenga43c7c52011-03-12 20:34:42 -08001539 if (!wacom->shared->stylus_in_proximity) /* first in prox */
Ping Cheng8aa9a9a2011-03-12 20:34:11 -08001540 /* Going into proximity select tool */
1541 wacom->tool[0] = (data[1] & 0x0c) ? BTN_TOOL_RUBBER : BTN_TOOL_PEN;
Ping Cheng8aa9a9a2011-03-12 20:34:11 -08001542
Ping Chenga43c7c52011-03-12 20:34:42 -08001543 /* keep pen state for touch events */
1544 wacom->shared->stylus_in_proximity = prox;
Ping Cheng8aa9a9a2011-03-12 20:34:11 -08001545
Ping Cheng1924e052016-08-09 14:38:56 -07001546 /* send pen events only when touch is up or forced out
1547 * or touch arbitration is off
1548 */
1549 if (!delay_pen_events(wacom)) {
Ping Chenga43c7c52011-03-12 20:34:42 -08001550 input_report_key(input, BTN_STYLUS, data[1] & 0x02);
1551 input_report_key(input, BTN_STYLUS2, data[1] & 0x10);
1552 input_report_abs(input, ABS_X, le16_to_cpup((__le16 *)&data[2]));
1553 input_report_abs(input, ABS_Y, le16_to_cpup((__le16 *)&data[4]));
Jason Gerecke0b335ca2014-07-24 13:15:31 -07001554 input_report_abs(input, ABS_PRESSURE, ((data[7] & 0x07) << 8) | data[6]);
Ping Chenga43c7c52011-03-12 20:34:42 -08001555 input_report_key(input, BTN_TOUCH, data[1] & 0x05);
1556 input_report_key(input, wacom->tool[0], prox);
1557 return 1;
1558 }
1559
1560 return 0;
Ping Cheng8aa9a9a2011-03-12 20:34:11 -08001561}
1562
1563static int wacom_tpc_irq(struct wacom_wac *wacom, size_t len)
1564{
Jason Gerecke74b63412014-04-19 13:50:22 -07001565 unsigned char *data = wacom->data;
Ping Cheng545f4e92008-11-24 11:44:27 -05001566
Jason Gerecke2a6cdbd2015-06-15 18:01:45 -07001567 if (wacom->pen_input)
1568 dev_dbg(wacom->pen_input->dev.parent,
1569 "%s: received report #%d\n", __func__, data[0]);
1570 else if (wacom->touch_input)
1571 dev_dbg(wacom->touch_input->dev.parent,
1572 "%s: received report #%d\n", __func__, data[0]);
Ping Cheng545f4e92008-11-24 11:44:27 -05001573
Ping Cheng31175a82012-01-31 00:07:33 -08001574 switch (len) {
1575 case WACOM_PKGLEN_TPC1FG:
Ping Cheng19635182012-04-29 21:09:18 -07001576 return wacom_tpc_single_touch(wacom, len);
Ping Cheng31175a82012-01-31 00:07:33 -08001577
1578 case WACOM_PKGLEN_TPC2FG:
Ping Cheng19635182012-04-29 21:09:18 -07001579 return wacom_tpc_mt_touch(wacom);
Ping Cheng31175a82012-01-31 00:07:33 -08001580
Jason Gerecked51ddb22014-05-14 17:14:29 -07001581 case WACOM_PKGLEN_PENABLED:
1582 return wacom_tpc_pen(wacom);
1583
Ping Cheng31175a82012-01-31 00:07:33 -08001584 default:
1585 switch (data[0]) {
1586 case WACOM_REPORT_TPC1FG:
1587 case WACOM_REPORT_TPCHID:
1588 case WACOM_REPORT_TPCST:
Ping Chengac173832012-06-12 00:15:06 -07001589 case WACOM_REPORT_TPC1FGE:
Ping Cheng31175a82012-01-31 00:07:33 -08001590 return wacom_tpc_single_touch(wacom, len);
1591
Ping Cheng19635182012-04-29 21:09:18 -07001592 case WACOM_REPORT_TPCMT:
Jason Gerecked51ddb22014-05-14 17:14:29 -07001593 case WACOM_REPORT_TPCMT2:
Ping Cheng19635182012-04-29 21:09:18 -07001594 return wacom_mt_touch(wacom);
1595
Ping Cheng31175a82012-01-31 00:07:33 -08001596 case WACOM_REPORT_PENABLED:
1597 return wacom_tpc_pen(wacom);
1598 }
1599 }
Ping Cheng545f4e92008-11-24 11:44:27 -05001600
Ping Cheng8aa9a9a2011-03-12 20:34:11 -08001601 return 0;
Ping Cheng545f4e92008-11-24 11:44:27 -05001602}
1603
Aaron Armstrong Skomraac2423c2017-01-25 12:08:40 -08001604int wacom_equivalent_usage(int usage)
Jason Gereckec9c09582016-10-19 18:03:43 -07001605{
1606 if ((usage & HID_USAGE_PAGE) == WACOM_HID_UP_WACOMDIGITIZER) {
1607 int subpage = (usage & 0xFF00) << 8;
1608 int subusage = (usage & 0xFF);
1609
Jason Gerecke5922e612016-10-19 18:03:51 -07001610 if (subpage == WACOM_HID_SP_PAD ||
1611 subpage == WACOM_HID_SP_BUTTON ||
1612 subpage == WACOM_HID_SP_DIGITIZER ||
Jason Gereckeb5c921e2016-10-19 18:03:44 -07001613 subpage == WACOM_HID_SP_DIGITIZERINFO ||
Jason Gerecke61ce3462016-10-19 18:03:46 -07001614 usage == WACOM_HID_WD_SENSE ||
Jason Gereckef85c9dc2016-10-19 18:03:48 -07001615 usage == WACOM_HID_WD_SERIALHI ||
1616 usage == WACOM_HID_WD_TOOLTYPE ||
Jason Gerecke5922e612016-10-19 18:03:51 -07001617 usage == WACOM_HID_WD_DISTANCE ||
Jason Gereckebf78adc2016-10-19 18:03:53 -07001618 usage == WACOM_HID_WD_TOUCHSTRIP ||
1619 usage == WACOM_HID_WD_TOUCHSTRIP2 ||
Jason Gerecke5922e612016-10-19 18:03:51 -07001620 usage == WACOM_HID_WD_TOUCHRING ||
1621 usage == WACOM_HID_WD_TOUCHRINGSTATUS) {
Jason Gereckec9c09582016-10-19 18:03:43 -07001622 return usage;
1623 }
1624
1625 if (subpage == HID_UP_UNDEFINED)
1626 subpage = HID_UP_DIGITIZER;
1627
1628 return subpage | subusage;
1629 }
1630
Aaron Armstrong Skomraac2423c2017-01-25 12:08:40 -08001631 if ((usage & HID_USAGE_PAGE) == WACOM_HID_UP_WACOMTOUCH) {
1632 int subpage = (usage & 0xFF00) << 8;
1633 int subusage = (usage & 0xFF);
1634
1635 if (subpage == HID_UP_UNDEFINED)
1636 subpage = WACOM_HID_SP_DIGITIZER;
1637
1638 return subpage | subusage;
1639 }
1640
Jason Gereckec9c09582016-10-19 18:03:43 -07001641 return usage;
1642}
1643
Jason Gerecke2a6cdbd2015-06-15 18:01:45 -07001644static void wacom_map_usage(struct input_dev *input, struct hid_usage *usage,
Benjamin Tissoires7704ac92014-09-23 12:08:08 -04001645 struct hid_field *field, __u8 type, __u16 code, int fuzz)
1646{
Jason Gerecke345857b2016-10-19 18:03:50 -07001647 struct wacom *wacom = input_get_drvdata(input);
1648 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
1649 struct wacom_features *features = &wacom_wac->features;
Benjamin Tissoires7704ac92014-09-23 12:08:08 -04001650 int fmin = field->logical_minimum;
1651 int fmax = field->logical_maximum;
Jason Gereckec9c09582016-10-19 18:03:43 -07001652 unsigned int equivalent_usage = wacom_equivalent_usage(usage->hid);
Jason Gerecke50066a02016-10-19 18:03:42 -07001653 int resolution_code = code;
1654
Jason Gereckec9c09582016-10-19 18:03:43 -07001655 if (equivalent_usage == HID_DG_TWIST) {
Jason Gerecke50066a02016-10-19 18:03:42 -07001656 resolution_code = ABS_RZ;
1657 }
Benjamin Tissoires7704ac92014-09-23 12:08:08 -04001658
Jason Gerecke345857b2016-10-19 18:03:50 -07001659 if (equivalent_usage == HID_GD_X) {
1660 fmin += features->offset_left;
1661 fmax -= features->offset_right;
1662 }
1663 if (equivalent_usage == HID_GD_Y) {
1664 fmin += features->offset_top;
1665 fmax -= features->offset_bottom;
1666 }
1667
Benjamin Tissoires7704ac92014-09-23 12:08:08 -04001668 usage->type = type;
1669 usage->code = code;
1670
1671 set_bit(type, input->evbit);
1672
1673 switch (type) {
1674 case EV_ABS:
1675 input_set_abs_params(input, code, fmin, fmax, fuzz, 0);
1676 input_abs_set_res(input, code,
Jason Gerecke50066a02016-10-19 18:03:42 -07001677 hidinput_calc_abs_res(field, resolution_code));
Benjamin Tissoires7704ac92014-09-23 12:08:08 -04001678 break;
1679 case EV_KEY:
1680 input_set_capability(input, EV_KEY, code);
1681 break;
1682 case EV_MSC:
1683 input_set_capability(input, EV_MSC, code);
1684 break;
Jason Gereckebf78adc2016-10-19 18:03:53 -07001685 case EV_SW:
1686 input_set_capability(input, EV_SW, code);
1687 break;
Benjamin Tissoires7704ac92014-09-23 12:08:08 -04001688 }
1689}
1690
Jason Gerecke5922e612016-10-19 18:03:51 -07001691static void wacom_wac_pad_usage_mapping(struct hid_device *hdev,
1692 struct hid_field *field, struct hid_usage *usage)
1693{
1694 struct wacom *wacom = hid_get_drvdata(hdev);
1695 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
1696 struct wacom_features *features = &wacom_wac->features;
1697 struct input_dev *input = wacom_wac->pad_input;
1698 unsigned equivalent_usage = wacom_equivalent_usage(usage->hid);
1699
1700 switch (equivalent_usage) {
Jason Gerecke93aab7f2016-10-19 18:03:52 -07001701 case WACOM_HID_WD_BATTERY_LEVEL:
1702 case WACOM_HID_WD_BATTERY_CHARGING:
1703 features->quirks |= WACOM_QUIRK_BATTERY;
1704 break;
Jason Gerecke5922e612016-10-19 18:03:51 -07001705 case WACOM_HID_WD_ACCELEROMETER_X:
1706 __set_bit(INPUT_PROP_ACCELEROMETER, input->propbit);
1707 wacom_map_usage(input, usage, field, EV_ABS, ABS_X, 0);
Ping Chengf3f24e72016-12-08 22:05:44 -08001708 features->device_type |= WACOM_DEVICETYPE_PAD;
Jason Gerecke5922e612016-10-19 18:03:51 -07001709 break;
1710 case WACOM_HID_WD_ACCELEROMETER_Y:
1711 __set_bit(INPUT_PROP_ACCELEROMETER, input->propbit);
1712 wacom_map_usage(input, usage, field, EV_ABS, ABS_Y, 0);
Ping Chengf3f24e72016-12-08 22:05:44 -08001713 features->device_type |= WACOM_DEVICETYPE_PAD;
Jason Gerecke5922e612016-10-19 18:03:51 -07001714 break;
1715 case WACOM_HID_WD_ACCELEROMETER_Z:
1716 __set_bit(INPUT_PROP_ACCELEROMETER, input->propbit);
1717 wacom_map_usage(input, usage, field, EV_ABS, ABS_Z, 0);
Ping Chengf3f24e72016-12-08 22:05:44 -08001718 features->device_type |= WACOM_DEVICETYPE_PAD;
Jason Gerecke5922e612016-10-19 18:03:51 -07001719 break;
Aaron Armstrong Skomra10c55ca2017-01-25 12:08:42 -08001720 case WACOM_HID_WD_BUTTONCENTER:
1721 wacom->generic_has_leds = true;
1722 /* fall through */
Jason Gerecke5922e612016-10-19 18:03:51 -07001723 case WACOM_HID_WD_BUTTONHOME:
1724 case WACOM_HID_WD_BUTTONUP:
1725 case WACOM_HID_WD_BUTTONDOWN:
1726 case WACOM_HID_WD_BUTTONLEFT:
1727 case WACOM_HID_WD_BUTTONRIGHT:
1728 wacom_map_usage(input, usage, field, EV_KEY,
1729 wacom_numbered_button_to_key(features->numbered_buttons),
1730 0);
1731 features->numbered_buttons++;
Ping Chengf3f24e72016-12-08 22:05:44 -08001732 features->device_type |= WACOM_DEVICETYPE_PAD;
Jason Gerecke5922e612016-10-19 18:03:51 -07001733 break;
Jason Gereckebf78adc2016-10-19 18:03:53 -07001734 case WACOM_HID_WD_TOUCHONOFF:
Aaron Armstrong Skomrad2ec58a2017-01-25 12:08:41 -08001735 /*
1736 * This usage, which is used to mute touch events, comes
1737 * from the pad packet, but is reported on the touch
1738 * interface. Because the touch interface may not have
1739 * been created yet, we cannot call wacom_map_usage(). In
1740 * order to process this usage when we receive it, we set
1741 * the usage type and code directly.
1742 */
1743 wacom_wac->has_mute_touch_switch = true;
1744 usage->type = EV_SW;
1745 usage->code = SW_MUTE_DEVICE;
Ping Chengf3f24e72016-12-08 22:05:44 -08001746 features->device_type |= WACOM_DEVICETYPE_PAD;
Jason Gereckebf78adc2016-10-19 18:03:53 -07001747 break;
1748 case WACOM_HID_WD_TOUCHSTRIP:
1749 wacom_map_usage(input, usage, field, EV_ABS, ABS_RX, 0);
Ping Chengf3f24e72016-12-08 22:05:44 -08001750 features->device_type |= WACOM_DEVICETYPE_PAD;
Jason Gereckebf78adc2016-10-19 18:03:53 -07001751 break;
1752 case WACOM_HID_WD_TOUCHSTRIP2:
1753 wacom_map_usage(input, usage, field, EV_ABS, ABS_RY, 0);
Ping Chengf3f24e72016-12-08 22:05:44 -08001754 features->device_type |= WACOM_DEVICETYPE_PAD;
Jason Gereckebf78adc2016-10-19 18:03:53 -07001755 break;
Jason Gerecke5922e612016-10-19 18:03:51 -07001756 case WACOM_HID_WD_TOUCHRING:
1757 wacom_map_usage(input, usage, field, EV_ABS, ABS_WHEEL, 0);
Ping Chengf3f24e72016-12-08 22:05:44 -08001758 features->device_type |= WACOM_DEVICETYPE_PAD;
Jason Gerecke5922e612016-10-19 18:03:51 -07001759 break;
Aaron Armstrong Skomra60a22182017-01-25 12:08:39 -08001760 case WACOM_HID_WD_TOUCHRINGSTATUS:
1761 wacom_map_usage(input, usage, field, EV_ABS, ABS_WHEEL, 0);
1762 features->device_type |= WACOM_DEVICETYPE_PAD;
1763 break;
Jason Gerecke5922e612016-10-19 18:03:51 -07001764 }
1765
1766 switch (equivalent_usage & 0xfffffff0) {
1767 case WACOM_HID_WD_EXPRESSKEY00:
1768 wacom_map_usage(input, usage, field, EV_KEY,
1769 wacom_numbered_button_to_key(features->numbered_buttons),
1770 0);
1771 features->numbered_buttons++;
Ping Chengf3f24e72016-12-08 22:05:44 -08001772 features->device_type |= WACOM_DEVICETYPE_PAD;
Jason Gerecke5922e612016-10-19 18:03:51 -07001773 break;
1774 }
1775}
1776
Ping Chengc9cfb2a2016-12-08 22:06:15 -08001777static void wacom_wac_pad_battery_event(struct hid_device *hdev, struct hid_field *field,
Jason Gerecke5922e612016-10-19 18:03:51 -07001778 struct hid_usage *usage, __s32 value)
1779{
1780 struct wacom *wacom = hid_get_drvdata(hdev);
1781 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
Jason Gerecke5922e612016-10-19 18:03:51 -07001782 unsigned equivalent_usage = wacom_equivalent_usage(usage->hid);
1783
Jason Gerecke93aab7f2016-10-19 18:03:52 -07001784 switch (equivalent_usage) {
1785 case WACOM_HID_WD_BATTERY_LEVEL:
1786 wacom_wac->hid_data.battery_capacity = value;
1787 wacom_wac->hid_data.bat_connected = 1;
Ping Cheng354a3292016-12-08 22:03:27 -08001788 break;
Jason Gerecke93aab7f2016-10-19 18:03:52 -07001789
1790 case WACOM_HID_WD_BATTERY_CHARGING:
1791 wacom_wac->hid_data.bat_charging = value;
1792 wacom_wac->hid_data.ps_connected = value;
1793 wacom_wac->hid_data.bat_connected = 1;
Ping Cheng354a3292016-12-08 22:03:27 -08001794 break;
Ping Chengc9cfb2a2016-12-08 22:06:15 -08001795 }
1796}
Jason Gerecke93aab7f2016-10-19 18:03:52 -07001797
Ping Chengc9cfb2a2016-12-08 22:06:15 -08001798static void wacom_wac_pad_event(struct hid_device *hdev, struct hid_field *field,
1799 struct hid_usage *usage, __s32 value)
1800{
1801 struct wacom *wacom = hid_get_drvdata(hdev);
1802 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
1803 struct input_dev *input = wacom_wac->pad_input;
Aaron Armstrong Skomra10c55ca2017-01-25 12:08:42 -08001804 struct wacom_features *features = &wacom_wac->features;
Ping Chengc9cfb2a2016-12-08 22:06:15 -08001805 unsigned equivalent_usage = wacom_equivalent_usage(usage->hid);
Aaron Armstrong Skomra10c55ca2017-01-25 12:08:42 -08001806 int i;
Ping Chengc9cfb2a2016-12-08 22:06:15 -08001807
Aaron Armstrong Skomra60a22182017-01-25 12:08:39 -08001808 /*
1809 * Avoid reporting this event and setting inrange_state if this usage
1810 * hasn't been mapped.
1811 */
1812 if (!usage->type)
1813 return;
1814
Ping Chengc9cfb2a2016-12-08 22:06:15 -08001815 if (wacom_equivalent_usage(field->physical) == HID_DG_TABLETFUNCTIONKEY) {
Aaron Armstrong Skomra60a22182017-01-25 12:08:39 -08001816 if (usage->hid != WACOM_HID_WD_TOUCHRING)
1817 wacom_wac->hid_data.inrange_state |= value;
Ping Chengc9cfb2a2016-12-08 22:06:15 -08001818 }
1819
1820 switch (equivalent_usage) {
Jason Gerecke93aab7f2016-10-19 18:03:52 -07001821 case WACOM_HID_WD_TOUCHRINGSTATUS:
Aaron Armstrong Skomra60a22182017-01-25 12:08:39 -08001822 if (!value)
1823 input_event(input, usage->type, usage->code, 0);
Ping Cheng354a3292016-12-08 22:03:27 -08001824 break;
Jason Gerecke93aab7f2016-10-19 18:03:52 -07001825
Aaron Armstrong Skomrad2ec58a2017-01-25 12:08:41 -08001826 case WACOM_HID_WD_TOUCHONOFF:
1827 if (wacom_wac->shared->touch_input) {
1828 input_report_switch(wacom_wac->shared->touch_input,
1829 SW_MUTE_DEVICE, !value);
1830 input_sync(wacom_wac->shared->touch_input);
1831 }
1832 break;
Aaron Armstrong Skomra10c55ca2017-01-25 12:08:42 -08001833
1834 case WACOM_HID_WD_BUTTONCENTER:
1835 for (i = 0; i < wacom->led.count; i++)
1836 wacom_update_led(wacom, features->numbered_buttons,
1837 value, i);
1838 /* fall through*/
Jason Gerecke93aab7f2016-10-19 18:03:52 -07001839 default:
Jason Gerecke5922e612016-10-19 18:03:51 -07001840 input_event(input, usage->type, usage->code, value);
Jason Gerecke93aab7f2016-10-19 18:03:52 -07001841 break;
1842 }
Jason Gerecke5922e612016-10-19 18:03:51 -07001843}
1844
1845static void wacom_wac_pad_pre_report(struct hid_device *hdev,
1846 struct hid_report *report)
1847{
1848 struct wacom *wacom = hid_get_drvdata(hdev);
1849 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
1850
1851 wacom_wac->hid_data.inrange_state = 0;
1852}
1853
Ping Chengc9cfb2a2016-12-08 22:06:15 -08001854static void wacom_wac_pad_battery_report(struct hid_device *hdev,
Jason Gerecke5922e612016-10-19 18:03:51 -07001855 struct hid_report *report)
1856{
1857 struct wacom *wacom = hid_get_drvdata(hdev);
1858 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
Jason Gerecke93aab7f2016-10-19 18:03:52 -07001859 struct wacom_features *features = &wacom_wac->features;
Jason Gerecke5922e612016-10-19 18:03:51 -07001860
Jason Gerecke93aab7f2016-10-19 18:03:52 -07001861 if (features->quirks & WACOM_QUIRK_BATTERY) {
1862 int capacity = wacom_wac->hid_data.battery_capacity;
1863 bool charging = wacom_wac->hid_data.bat_charging;
1864 bool connected = wacom_wac->hid_data.bat_connected;
1865 bool powered = wacom_wac->hid_data.ps_connected;
1866
1867 wacom_notify_battery(wacom_wac, capacity, charging,
1868 connected, powered);
1869 }
Ping Chengc9cfb2a2016-12-08 22:06:15 -08001870}
Jason Gerecke93aab7f2016-10-19 18:03:52 -07001871
Ping Chengc9cfb2a2016-12-08 22:06:15 -08001872static void wacom_wac_pad_report(struct hid_device *hdev,
1873 struct hid_report *report)
1874{
1875 struct wacom *wacom = hid_get_drvdata(hdev);
1876 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
Ping Chengc9cfb2a2016-12-08 22:06:15 -08001877 struct input_dev *input = wacom_wac->pad_input;
1878 bool active = wacom_wac->hid_data.inrange_state != 0;
1879
1880 /* report prox for expresskey events */
1881 if (wacom_equivalent_usage(report->field[0]->physical) == HID_DG_TABLETFUNCTIONKEY) {
Ping Chengc9cfb2a2016-12-08 22:06:15 -08001882 input_event(input, EV_ABS, ABS_MISC, active ? PAD_DEVICE_ID : 0);
Ping Chengc9cfb2a2016-12-08 22:06:15 -08001883 input_sync(input);
1884 }
Aaron Armstrong Skomra65ef4c12017-01-25 12:08:38 -08001885
Jason Gerecke5922e612016-10-19 18:03:51 -07001886}
1887
Benjamin Tissoires7704ac92014-09-23 12:08:08 -04001888static void wacom_wac_pen_usage_mapping(struct hid_device *hdev,
1889 struct hid_field *field, struct hid_usage *usage)
1890{
1891 struct wacom *wacom = hid_get_drvdata(hdev);
Jason Gerecke2a6cdbd2015-06-15 18:01:45 -07001892 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
Jason Gerecke61ce3462016-10-19 18:03:46 -07001893 struct wacom_features *features = &wacom_wac->features;
Jason Gerecke2a6cdbd2015-06-15 18:01:45 -07001894 struct input_dev *input = wacom_wac->pen_input;
Jason Gereckec9c09582016-10-19 18:03:43 -07001895 unsigned equivalent_usage = wacom_equivalent_usage(usage->hid);
Benjamin Tissoires7704ac92014-09-23 12:08:08 -04001896
Jason Gereckec9c09582016-10-19 18:03:43 -07001897 switch (equivalent_usage) {
Benjamin Tissoires7704ac92014-09-23 12:08:08 -04001898 case HID_GD_X:
Jason Gerecke2a6cdbd2015-06-15 18:01:45 -07001899 wacom_map_usage(input, usage, field, EV_ABS, ABS_X, 4);
Benjamin Tissoires7704ac92014-09-23 12:08:08 -04001900 break;
1901 case HID_GD_Y:
Jason Gerecke2a6cdbd2015-06-15 18:01:45 -07001902 wacom_map_usage(input, usage, field, EV_ABS, ABS_Y, 4);
Benjamin Tissoires7704ac92014-09-23 12:08:08 -04001903 break;
Jason Gereckeb5c921e2016-10-19 18:03:44 -07001904 case WACOM_HID_WD_DISTANCE:
Jason Gerecke50066a02016-10-19 18:03:42 -07001905 case HID_GD_Z:
1906 wacom_map_usage(input, usage, field, EV_ABS, ABS_DISTANCE, 0);
1907 break;
Benjamin Tissoires7704ac92014-09-23 12:08:08 -04001908 case HID_DG_TIPPRESSURE:
Jason Gerecke2a6cdbd2015-06-15 18:01:45 -07001909 wacom_map_usage(input, usage, field, EV_ABS, ABS_PRESSURE, 0);
Benjamin Tissoires7704ac92014-09-23 12:08:08 -04001910 break;
1911 case HID_DG_INRANGE:
Jason Gerecke2a6cdbd2015-06-15 18:01:45 -07001912 wacom_map_usage(input, usage, field, EV_KEY, BTN_TOOL_PEN, 0);
Benjamin Tissoires7704ac92014-09-23 12:08:08 -04001913 break;
Jason Gerecke93aab7f2016-10-19 18:03:52 -07001914 case HID_DG_BATTERYSTRENGTH:
1915 features->quirks |= WACOM_QUIRK_BATTERY;
1916 break;
Benjamin Tissoires7704ac92014-09-23 12:08:08 -04001917 case HID_DG_INVERT:
Jason Gerecke2a6cdbd2015-06-15 18:01:45 -07001918 wacom_map_usage(input, usage, field, EV_KEY,
Benjamin Tissoires7704ac92014-09-23 12:08:08 -04001919 BTN_TOOL_RUBBER, 0);
1920 break;
Jason Gerecke50066a02016-10-19 18:03:42 -07001921 case HID_DG_TILT_X:
1922 wacom_map_usage(input, usage, field, EV_ABS, ABS_TILT_X, 0);
1923 break;
1924 case HID_DG_TILT_Y:
1925 wacom_map_usage(input, usage, field, EV_ABS, ABS_TILT_Y, 0);
1926 break;
1927 case HID_DG_TWIST:
1928 wacom_map_usage(input, usage, field, EV_ABS, ABS_Z, 0);
1929 break;
Benjamin Tissoires7704ac92014-09-23 12:08:08 -04001930 case HID_DG_ERASER:
1931 case HID_DG_TIPSWITCH:
Jason Gerecke2a6cdbd2015-06-15 18:01:45 -07001932 wacom_map_usage(input, usage, field, EV_KEY, BTN_TOUCH, 0);
Benjamin Tissoires7704ac92014-09-23 12:08:08 -04001933 break;
1934 case HID_DG_BARRELSWITCH:
Jason Gerecke2a6cdbd2015-06-15 18:01:45 -07001935 wacom_map_usage(input, usage, field, EV_KEY, BTN_STYLUS, 0);
Benjamin Tissoires7704ac92014-09-23 12:08:08 -04001936 break;
1937 case HID_DG_BARRELSWITCH2:
Jason Gerecke2a6cdbd2015-06-15 18:01:45 -07001938 wacom_map_usage(input, usage, field, EV_KEY, BTN_STYLUS2, 0);
Benjamin Tissoires7704ac92014-09-23 12:08:08 -04001939 break;
1940 case HID_DG_TOOLSERIALNUMBER:
Jason Gerecke2a6cdbd2015-06-15 18:01:45 -07001941 wacom_map_usage(input, usage, field, EV_MSC, MSC_SERIAL, 0);
Benjamin Tissoires7704ac92014-09-23 12:08:08 -04001942 break;
Jason Gerecke61ce3462016-10-19 18:03:46 -07001943 case WACOM_HID_WD_SENSE:
1944 features->quirks |= WACOM_QUIRK_SENSE;
1945 wacom_map_usage(input, usage, field, EV_KEY, BTN_TOOL_PEN, 0);
1946 break;
Jason Gereckef85c9dc2016-10-19 18:03:48 -07001947 case WACOM_HID_WD_SERIALHI:
1948 wacom_map_usage(input, usage, field, EV_ABS, ABS_MISC, 0);
1949 set_bit(EV_KEY, input->evbit);
1950 input_set_capability(input, EV_KEY, BTN_TOOL_PEN);
1951 input_set_capability(input, EV_KEY, BTN_TOOL_RUBBER);
1952 input_set_capability(input, EV_KEY, BTN_TOOL_BRUSH);
1953 input_set_capability(input, EV_KEY, BTN_TOOL_PENCIL);
1954 input_set_capability(input, EV_KEY, BTN_TOOL_AIRBRUSH);
1955 input_set_capability(input, EV_KEY, BTN_TOOL_MOUSE);
1956 input_set_capability(input, EV_KEY, BTN_TOOL_LENS);
1957 break;
Jason Gerecke929d6d52016-10-19 18:03:45 -07001958 case WACOM_HID_WD_FINGERWHEEL:
1959 wacom_map_usage(input, usage, field, EV_ABS, ABS_WHEEL, 0);
1960 break;
Benjamin Tissoires7704ac92014-09-23 12:08:08 -04001961 }
1962}
1963
Ping Cheng354a3292016-12-08 22:03:27 -08001964static void wacom_wac_pen_event(struct hid_device *hdev, struct hid_field *field,
Benjamin Tissoires7704ac92014-09-23 12:08:08 -04001965 struct hid_usage *usage, __s32 value)
1966{
1967 struct wacom *wacom = hid_get_drvdata(hdev);
1968 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
Jason Gerecke61ce3462016-10-19 18:03:46 -07001969 struct wacom_features *features = &wacom_wac->features;
Jason Gerecke2a6cdbd2015-06-15 18:01:45 -07001970 struct input_dev *input = wacom_wac->pen_input;
Jason Gereckec9c09582016-10-19 18:03:43 -07001971 unsigned equivalent_usage = wacom_equivalent_usage(usage->hid);
Benjamin Tissoires7704ac92014-09-23 12:08:08 -04001972
Jason Gereckec9c09582016-10-19 18:03:43 -07001973 switch (equivalent_usage) {
Jason Gerecke50066a02016-10-19 18:03:42 -07001974 case HID_GD_Z:
1975 /*
1976 * HID_GD_Z "should increase as the control's position is
1977 * moved from high to low", while ABS_DISTANCE instead
1978 * increases in value as the tool moves from low to high.
1979 */
1980 value = field->logical_maximum - value;
1981 break;
Benjamin Tissoires7704ac92014-09-23 12:08:08 -04001982 case HID_DG_INRANGE:
1983 wacom_wac->hid_data.inrange_state = value;
Jason Gerecke61ce3462016-10-19 18:03:46 -07001984 if (!(features->quirks & WACOM_QUIRK_SENSE))
1985 wacom_wac->hid_data.sense_state = value;
Ping Cheng354a3292016-12-08 22:03:27 -08001986 return;
Jason Gerecke93aab7f2016-10-19 18:03:52 -07001987 case HID_DG_BATTERYSTRENGTH:
1988 wacom_wac->hid_data.battery_capacity = value;
1989 wacom_wac->hid_data.bat_connected = 1;
1990 break;
Benjamin Tissoires7704ac92014-09-23 12:08:08 -04001991 case HID_DG_INVERT:
1992 wacom_wac->hid_data.invert_state = value;
Ping Cheng354a3292016-12-08 22:03:27 -08001993 return;
Benjamin Tissoires7704ac92014-09-23 12:08:08 -04001994 case HID_DG_ERASER:
1995 case HID_DG_TIPSWITCH:
1996 wacom_wac->hid_data.tipswitch |= value;
Ping Cheng354a3292016-12-08 22:03:27 -08001997 return;
Jason Gereckef85c9dc2016-10-19 18:03:48 -07001998 case HID_DG_TOOLSERIALNUMBER:
Dan Carpentera35f09b2016-11-10 22:25:39 +03001999 wacom_wac->serial[0] = (wacom_wac->serial[0] & ~0xFFFFFFFFULL);
Jason Gereckef85c9dc2016-10-19 18:03:48 -07002000 wacom_wac->serial[0] |= value;
Ping Cheng354a3292016-12-08 22:03:27 -08002001 return;
Jason Gerecke61ce3462016-10-19 18:03:46 -07002002 case WACOM_HID_WD_SENSE:
2003 wacom_wac->hid_data.sense_state = value;
Ping Cheng354a3292016-12-08 22:03:27 -08002004 return;
Jason Gereckef85c9dc2016-10-19 18:03:48 -07002005 case WACOM_HID_WD_SERIALHI:
2006 wacom_wac->serial[0] = (wacom_wac->serial[0] & 0xFFFFFFFF);
2007 wacom_wac->serial[0] |= ((__u64)value) << 32;
2008 /*
2009 * Non-USI EMR devices may contain additional tool type
2010 * information here. See WACOM_HID_WD_TOOLTYPE case for
2011 * more details.
2012 */
2013 if (value >> 20 == 1) {
2014 wacom_wac->id[0] |= value & 0xFFFFF;
2015 }
Ping Cheng354a3292016-12-08 22:03:27 -08002016 return;
Jason Gereckef85c9dc2016-10-19 18:03:48 -07002017 case WACOM_HID_WD_TOOLTYPE:
2018 /*
2019 * Some devices (MobileStudio Pro, and possibly later
2020 * devices as well) do not return the complete tool
2021 * type in their WACOM_HID_WD_TOOLTYPE usage. Use a
2022 * bitwise OR so the complete value can be built
2023 * up over time :(
2024 */
2025 wacom_wac->id[0] |= value;
Ping Cheng354a3292016-12-08 22:03:27 -08002026 return;
Jason Gerecke345857b2016-10-19 18:03:50 -07002027 case WACOM_HID_WD_OFFSETLEFT:
2028 if (features->offset_left && value != features->offset_left)
2029 hid_warn(hdev, "%s: overriding exising left offset "
2030 "%d -> %d\n", __func__, value,
2031 features->offset_left);
2032 features->offset_left = value;
Ping Cheng354a3292016-12-08 22:03:27 -08002033 return;
Jason Gerecke345857b2016-10-19 18:03:50 -07002034 case WACOM_HID_WD_OFFSETRIGHT:
2035 if (features->offset_right && value != features->offset_right)
2036 hid_warn(hdev, "%s: overriding exising right offset "
2037 "%d -> %d\n", __func__, value,
2038 features->offset_right);
2039 features->offset_right = value;
Ping Cheng354a3292016-12-08 22:03:27 -08002040 return;
Jason Gerecke345857b2016-10-19 18:03:50 -07002041 case WACOM_HID_WD_OFFSETTOP:
2042 if (features->offset_top && value != features->offset_top)
2043 hid_warn(hdev, "%s: overriding exising top offset "
2044 "%d -> %d\n", __func__, value,
2045 features->offset_top);
2046 features->offset_top = value;
Ping Cheng354a3292016-12-08 22:03:27 -08002047 return;
Jason Gerecke345857b2016-10-19 18:03:50 -07002048 case WACOM_HID_WD_OFFSETBOTTOM:
2049 if (features->offset_bottom && value != features->offset_bottom)
2050 hid_warn(hdev, "%s: overriding exising bottom offset "
2051 "%d -> %d\n", __func__, value,
2052 features->offset_bottom);
2053 features->offset_bottom = value;
Ping Cheng354a3292016-12-08 22:03:27 -08002054 return;
Benjamin Tissoires7704ac92014-09-23 12:08:08 -04002055 }
2056
Ping Cheng1924e052016-08-09 14:38:56 -07002057 /* send pen events only when touch is up or forced out
2058 * or touch arbitration is off
2059 */
2060 if (!usage->type || delay_pen_events(wacom_wac))
Ping Cheng354a3292016-12-08 22:03:27 -08002061 return;
Benjamin Tissoires7704ac92014-09-23 12:08:08 -04002062
Jason Gerecke61ce3462016-10-19 18:03:46 -07002063 /* send pen events only when the pen is in/entering/leaving proximity */
2064 if (!wacom_wac->hid_data.inrange_state && !wacom_wac->tool[0])
Ping Cheng354a3292016-12-08 22:03:27 -08002065 return;
Jason Gerecke61ce3462016-10-19 18:03:46 -07002066
Benjamin Tissoires7704ac92014-09-23 12:08:08 -04002067 input_event(input, usage->type, usage->code, value);
Benjamin Tissoires7704ac92014-09-23 12:08:08 -04002068}
2069
Jason Gerecke06324e02015-07-21 11:07:23 -07002070static void wacom_wac_pen_pre_report(struct hid_device *hdev,
2071 struct hid_report *report)
2072{
2073 return;
2074}
2075
Benjamin Tissoires7704ac92014-09-23 12:08:08 -04002076static void wacom_wac_pen_report(struct hid_device *hdev,
2077 struct hid_report *report)
2078{
2079 struct wacom *wacom = hid_get_drvdata(hdev);
2080 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
Jason Gerecke2a6cdbd2015-06-15 18:01:45 -07002081 struct input_dev *input = wacom_wac->pen_input;
Benjamin Tissoires7704ac92014-09-23 12:08:08 -04002082 bool prox = wacom_wac->hid_data.inrange_state;
Jason Gerecke61ce3462016-10-19 18:03:46 -07002083 bool range = wacom_wac->hid_data.sense_state;
Benjamin Tissoires7704ac92014-09-23 12:08:08 -04002084
Jason Gereckef85c9dc2016-10-19 18:03:48 -07002085 if (!wacom_wac->tool[0] && prox) { /* first in prox */
Benjamin Tissoires7704ac92014-09-23 12:08:08 -04002086 /* Going into proximity select tool */
Jason Gereckef85c9dc2016-10-19 18:03:48 -07002087 if (wacom_wac->hid_data.invert_state)
2088 wacom_wac->tool[0] = BTN_TOOL_RUBBER;
2089 else if (wacom_wac->id[0])
2090 wacom_wac->tool[0] = wacom_intuos_get_tool_type(wacom_wac->id[0]);
2091 else
2092 wacom_wac->tool[0] = BTN_TOOL_PEN;
2093 }
Benjamin Tissoires7704ac92014-09-23 12:08:08 -04002094
2095 /* keep pen state for touch events */
Jason Gerecke61ce3462016-10-19 18:03:46 -07002096 wacom_wac->shared->stylus_in_proximity = range;
Benjamin Tissoires7704ac92014-09-23 12:08:08 -04002097
Jason Gerecke61ce3462016-10-19 18:03:46 -07002098 if (!delay_pen_events(wacom_wac) && wacom_wac->tool[0]) {
Jason Gereckef85c9dc2016-10-19 18:03:48 -07002099 int id = wacom_wac->id[0];
2100
2101 /*
2102 * Non-USI EMR tools should have their IDs mangled to
2103 * match the legacy behavior of wacom_intuos_general
2104 */
2105 if (wacom_wac->serial[0] >> 52 == 1)
2106 id = wacom_intuos_id_mangle(id);
2107
2108 /*
2109 * To ensure compatibility with xf86-input-wacom, we should
2110 * report the BTN_TOOL_* event prior to the ABS_MISC or
2111 * MSC_SERIAL events.
2112 */
Benjamin Tissoires7704ac92014-09-23 12:08:08 -04002113 input_report_key(input, BTN_TOUCH,
2114 wacom_wac->hid_data.tipswitch);
2115 input_report_key(input, wacom_wac->tool[0], prox);
Jason Gereckef85c9dc2016-10-19 18:03:48 -07002116 if (wacom_wac->serial[0]) {
2117 input_event(input, EV_MSC, MSC_SERIAL, wacom_wac->serial[0]);
2118 input_report_abs(input, ABS_MISC, id);
2119 }
Benjamin Tissoires7704ac92014-09-23 12:08:08 -04002120
2121 wacom_wac->hid_data.tipswitch = false;
2122
2123 input_sync(input);
2124 }
Jason Gerecke61ce3462016-10-19 18:03:46 -07002125
Jason Gereckef85c9dc2016-10-19 18:03:48 -07002126 if (!prox) {
Jason Gerecke61ce3462016-10-19 18:03:46 -07002127 wacom_wac->tool[0] = 0;
Jason Gereckef85c9dc2016-10-19 18:03:48 -07002128 wacom_wac->id[0] = 0;
2129 }
Benjamin Tissoires7704ac92014-09-23 12:08:08 -04002130}
2131
Benjamin Tissoires5ae6e892014-09-23 12:08:09 -04002132static void wacom_wac_finger_usage_mapping(struct hid_device *hdev,
2133 struct hid_field *field, struct hid_usage *usage)
2134{
2135 struct wacom *wacom = hid_get_drvdata(hdev);
2136 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
Jason Gerecke2a6cdbd2015-06-15 18:01:45 -07002137 struct input_dev *input = wacom_wac->touch_input;
Benjamin Tissoires5ae6e892014-09-23 12:08:09 -04002138 unsigned touch_max = wacom_wac->features.touch_max;
Jason Gereckec9c09582016-10-19 18:03:43 -07002139 unsigned equivalent_usage = wacom_equivalent_usage(usage->hid);
Benjamin Tissoires5ae6e892014-09-23 12:08:09 -04002140
Jason Gereckec9c09582016-10-19 18:03:43 -07002141 switch (equivalent_usage) {
Benjamin Tissoires5ae6e892014-09-23 12:08:09 -04002142 case HID_GD_X:
2143 if (touch_max == 1)
Jason Gerecke2a6cdbd2015-06-15 18:01:45 -07002144 wacom_map_usage(input, usage, field, EV_ABS, ABS_X, 4);
Benjamin Tissoires5ae6e892014-09-23 12:08:09 -04002145 else
Jason Gerecke2a6cdbd2015-06-15 18:01:45 -07002146 wacom_map_usage(input, usage, field, EV_ABS,
Benjamin Tissoires5ae6e892014-09-23 12:08:09 -04002147 ABS_MT_POSITION_X, 4);
2148 break;
2149 case HID_GD_Y:
2150 if (touch_max == 1)
Jason Gerecke2a6cdbd2015-06-15 18:01:45 -07002151 wacom_map_usage(input, usage, field, EV_ABS, ABS_Y, 4);
Benjamin Tissoires5ae6e892014-09-23 12:08:09 -04002152 else
Jason Gerecke2a6cdbd2015-06-15 18:01:45 -07002153 wacom_map_usage(input, usage, field, EV_ABS,
Benjamin Tissoires5ae6e892014-09-23 12:08:09 -04002154 ABS_MT_POSITION_Y, 4);
2155 break;
Jason Gerecke488abb52015-07-21 11:07:25 -07002156 case HID_DG_WIDTH:
2157 case HID_DG_HEIGHT:
Jason Gerecke488abb52015-07-21 11:07:25 -07002158 wacom_map_usage(input, usage, field, EV_ABS, ABS_MT_TOUCH_MAJOR, 0);
2159 wacom_map_usage(input, usage, field, EV_ABS, ABS_MT_TOUCH_MINOR, 0);
2160 input_set_abs_params(input, ABS_MT_ORIENTATION, 0, 1, 0, 0);
2161 break;
Benjamin Tissoires5ae6e892014-09-23 12:08:09 -04002162 case HID_DG_TIPSWITCH:
Jason Gerecke2a6cdbd2015-06-15 18:01:45 -07002163 wacom_map_usage(input, usage, field, EV_KEY, BTN_TOUCH, 0);
Benjamin Tissoires5ae6e892014-09-23 12:08:09 -04002164 break;
Jason Gerecke1b5d514a2015-07-21 11:07:24 -07002165 case HID_DG_CONTACTCOUNT:
Jason Gerecke499522c2015-10-07 16:54:21 -07002166 wacom_wac->hid_data.cc_report = field->report->id;
Jason Gerecke1b5d514a2015-07-21 11:07:24 -07002167 wacom_wac->hid_data.cc_index = field->index;
2168 wacom_wac->hid_data.cc_value_index = usage->usage_index;
2169 break;
Benjamin Tissoires5ae6e892014-09-23 12:08:09 -04002170 }
2171}
2172
Jason Gerecke601a22f2014-12-10 16:26:04 -08002173static void wacom_wac_finger_slot(struct wacom_wac *wacom_wac,
2174 struct input_dev *input)
2175{
2176 struct hid_data *hid_data = &wacom_wac->hid_data;
2177 bool mt = wacom_wac->features.touch_max > 1;
2178 bool prox = hid_data->tipswitch &&
Ping Cheng1924e052016-08-09 14:38:56 -07002179 report_touch_events(wacom_wac);
Jason Gerecke601a22f2014-12-10 16:26:04 -08002180
Jason Gerecke1b5d514a2015-07-21 11:07:24 -07002181 wacom_wac->hid_data.num_received++;
2182 if (wacom_wac->hid_data.num_received > wacom_wac->hid_data.num_expected)
2183 return;
2184
Jason Gerecke601a22f2014-12-10 16:26:04 -08002185 if (mt) {
2186 int slot;
2187
2188 slot = input_mt_get_slot_by_key(input, hid_data->id);
2189 input_mt_slot(input, slot);
2190 input_mt_report_slot_state(input, MT_TOOL_FINGER, prox);
2191 }
2192 else {
2193 input_report_key(input, BTN_TOUCH, prox);
2194 }
2195
2196 if (prox) {
2197 input_report_abs(input, mt ? ABS_MT_POSITION_X : ABS_X,
2198 hid_data->x);
2199 input_report_abs(input, mt ? ABS_MT_POSITION_Y : ABS_Y,
2200 hid_data->y);
Jason Gerecke488abb52015-07-21 11:07:25 -07002201
2202 if (test_bit(ABS_MT_TOUCH_MAJOR, input->absbit)) {
2203 input_report_abs(input, ABS_MT_TOUCH_MAJOR, max(hid_data->width, hid_data->height));
2204 input_report_abs(input, ABS_MT_TOUCH_MINOR, min(hid_data->width, hid_data->height));
2205 if (hid_data->width != hid_data->height)
2206 input_report_abs(input, ABS_MT_ORIENTATION, hid_data->width <= hid_data->height ? 0 : 1);
2207 }
Jason Gerecke601a22f2014-12-10 16:26:04 -08002208 }
2209}
2210
Ping Cheng354a3292016-12-08 22:03:27 -08002211static void wacom_wac_finger_event(struct hid_device *hdev,
Benjamin Tissoires5ae6e892014-09-23 12:08:09 -04002212 struct hid_field *field, struct hid_usage *usage, __s32 value)
2213{
2214 struct wacom *wacom = hid_get_drvdata(hdev);
2215 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
Jason Gereckec9c09582016-10-19 18:03:43 -07002216 unsigned equivalent_usage = wacom_equivalent_usage(usage->hid);
Benjamin Tissoires5ae6e892014-09-23 12:08:09 -04002217
Jason Gereckec9c09582016-10-19 18:03:43 -07002218 switch (equivalent_usage) {
Benjamin Tissoires5ae6e892014-09-23 12:08:09 -04002219 case HID_GD_X:
2220 wacom_wac->hid_data.x = value;
2221 break;
2222 case HID_GD_Y:
2223 wacom_wac->hid_data.y = value;
2224 break;
Jason Gerecke488abb52015-07-21 11:07:25 -07002225 case HID_DG_WIDTH:
2226 wacom_wac->hid_data.width = value;
2227 break;
2228 case HID_DG_HEIGHT:
2229 wacom_wac->hid_data.height = value;
2230 break;
Benjamin Tissoires5ae6e892014-09-23 12:08:09 -04002231 case HID_DG_CONTACTID:
2232 wacom_wac->hid_data.id = value;
2233 break;
2234 case HID_DG_TIPSWITCH:
2235 wacom_wac->hid_data.tipswitch = value;
2236 break;
2237 }
2238
2239
Jason Gerecke601a22f2014-12-10 16:26:04 -08002240 if (usage->usage_index + 1 == field->report_count) {
Jason Gereckec9c09582016-10-19 18:03:43 -07002241 if (equivalent_usage == wacom_wac->hid_data.last_slot_field)
Jason Gerecke2a6cdbd2015-06-15 18:01:45 -07002242 wacom_wac_finger_slot(wacom_wac, wacom_wac->touch_input);
Jason Gerecke601a22f2014-12-10 16:26:04 -08002243 }
Benjamin Tissoires5ae6e892014-09-23 12:08:09 -04002244}
2245
Jason Gerecke06324e02015-07-21 11:07:23 -07002246static void wacom_wac_finger_pre_report(struct hid_device *hdev,
2247 struct hid_report *report)
2248{
Jason Gerecke1b5d514a2015-07-21 11:07:24 -07002249 struct wacom *wacom = hid_get_drvdata(hdev);
2250 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
2251 struct hid_data* hid_data = &wacom_wac->hid_data;
Jason Gerecke003f50a2016-07-21 09:10:46 -07002252 int i;
Jason Gerecke1b5d514a2015-07-21 11:07:24 -07002253
Jason Gerecke003f50a2016-07-21 09:10:46 -07002254 for (i = 0; i < report->maxfield; i++) {
2255 struct hid_field *field = report->field[i];
2256 int j;
Jason Gerecke499522c2015-10-07 16:54:21 -07002257
Jason Gerecke003f50a2016-07-21 09:10:46 -07002258 for (j = 0; j < field->maxusage; j++) {
2259 struct hid_usage *usage = &field->usage[j];
Aaron Armstrong Skomraac2423c2017-01-25 12:08:40 -08002260 unsigned int equivalent_usage =
2261 wacom_equivalent_usage(usage->hid);
Jason Gerecke499522c2015-10-07 16:54:21 -07002262
Aaron Armstrong Skomraac2423c2017-01-25 12:08:40 -08002263 switch (equivalent_usage) {
Jason Gerecke003f50a2016-07-21 09:10:46 -07002264 case HID_GD_X:
2265 case HID_GD_Y:
2266 case HID_DG_WIDTH:
2267 case HID_DG_HEIGHT:
2268 case HID_DG_CONTACTID:
2269 case HID_DG_INRANGE:
2270 case HID_DG_INVERT:
2271 case HID_DG_TIPSWITCH:
Aaron Armstrong Skomraac2423c2017-01-25 12:08:40 -08002272 hid_data->last_slot_field = equivalent_usage;
Jason Gerecke003f50a2016-07-21 09:10:46 -07002273 break;
2274 case HID_DG_CONTACTCOUNT:
2275 hid_data->cc_report = report->id;
2276 hid_data->cc_index = i;
2277 hid_data->cc_value_index = j;
2278 break;
Jason Gerecke499522c2015-10-07 16:54:21 -07002279 }
2280 }
2281 }
Jason Gerecke003f50a2016-07-21 09:10:46 -07002282
Jason Gereckedf707932015-10-07 16:54:22 -07002283 if (hid_data->cc_report != 0 &&
2284 hid_data->cc_index >= 0) {
Jason Gerecke1b5d514a2015-07-21 11:07:24 -07002285 struct hid_field *field = report->field[hid_data->cc_index];
2286 int value = field->value[hid_data->cc_value_index];
2287 if (value)
2288 hid_data->num_expected = value;
2289 }
2290 else {
2291 hid_data->num_expected = wacom_wac->features.touch_max;
2292 }
Jason Gerecke06324e02015-07-21 11:07:23 -07002293}
2294
Benjamin Tissoires5ae6e892014-09-23 12:08:09 -04002295static void wacom_wac_finger_report(struct hid_device *hdev,
2296 struct hid_report *report)
2297{
2298 struct wacom *wacom = hid_get_drvdata(hdev);
2299 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
Jason Gerecke2a6cdbd2015-06-15 18:01:45 -07002300 struct input_dev *input = wacom_wac->touch_input;
Benjamin Tissoires5ae6e892014-09-23 12:08:09 -04002301 unsigned touch_max = wacom_wac->features.touch_max;
2302
Jason Gerecke1b5d514a2015-07-21 11:07:24 -07002303 /* If more packets of data are expected, give us a chance to
2304 * process them rather than immediately syncing a partial
2305 * update.
2306 */
2307 if (wacom_wac->hid_data.num_received < wacom_wac->hid_data.num_expected)
2308 return;
2309
Benjamin Tissoires5ae6e892014-09-23 12:08:09 -04002310 if (touch_max > 1)
Jason Gerecke601a22f2014-12-10 16:26:04 -08002311 input_mt_sync_frame(input);
2312
Benjamin Tissoires5ae6e892014-09-23 12:08:09 -04002313 input_sync(input);
Jason Gerecke1b5d514a2015-07-21 11:07:24 -07002314 wacom_wac->hid_data.num_received = 0;
Benjamin Tissoires5ae6e892014-09-23 12:08:09 -04002315
2316 /* keep touch state for pen event */
Ping Cheng7d059ed2015-03-20 14:57:21 -07002317 wacom_wac->shared->touch_down = wacom_wac_finger_count_touches(wacom_wac);
Benjamin Tissoires5ae6e892014-09-23 12:08:09 -04002318}
2319
Benjamin Tissoires7704ac92014-09-23 12:08:08 -04002320void wacom_wac_usage_mapping(struct hid_device *hdev,
2321 struct hid_field *field, struct hid_usage *usage)
2322{
2323 struct wacom *wacom = hid_get_drvdata(hdev);
2324 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
Jason Gereckee5bc8eb2016-08-08 12:06:29 -07002325 struct wacom_features *features = &wacom_wac->features;
Benjamin Tissoires7704ac92014-09-23 12:08:08 -04002326
Aaron Armstrong Skomraac2423c2017-01-25 12:08:40 -08002327 if (WACOM_DIRECT_DEVICE(field))
2328 features->device_type |= WACOM_DEVICETYPE_DIRECT;
Benjamin Tissoires7704ac92014-09-23 12:08:08 -04002329
Jason Gerecke5922e612016-10-19 18:03:51 -07002330 if (WACOM_PAD_FIELD(field))
Ping Cheng354a3292016-12-08 22:03:27 -08002331 wacom_wac_pad_usage_mapping(hdev, field, usage);
Jason Gerecke5922e612016-10-19 18:03:51 -07002332 else if (WACOM_PEN_FIELD(field))
Ping Cheng354a3292016-12-08 22:03:27 -08002333 wacom_wac_pen_usage_mapping(hdev, field, usage);
Jason Gerecke5922e612016-10-19 18:03:51 -07002334 else if (WACOM_FINGER_FIELD(field))
Ping Cheng354a3292016-12-08 22:03:27 -08002335 wacom_wac_finger_usage_mapping(hdev, field, usage);
Benjamin Tissoires7704ac92014-09-23 12:08:08 -04002336}
2337
Ping Cheng354a3292016-12-08 22:03:27 -08002338void wacom_wac_event(struct hid_device *hdev, struct hid_field *field,
Benjamin Tissoires7704ac92014-09-23 12:08:08 -04002339 struct hid_usage *usage, __s32 value)
2340{
2341 struct wacom *wacom = hid_get_drvdata(hdev);
2342
2343 if (wacom->wacom_wac.features.type != HID_GENERIC)
Ping Cheng354a3292016-12-08 22:03:27 -08002344 return;
Benjamin Tissoires7704ac92014-09-23 12:08:08 -04002345
Aaron Armstrong Skomra60a22182017-01-25 12:08:39 -08002346 if (value > field->logical_maximum || value < field->logical_minimum)
2347 return;
2348
Ping Chengc9cfb2a2016-12-08 22:06:15 -08002349 if (WACOM_PAD_FIELD(field)) {
2350 wacom_wac_pad_battery_event(hdev, field, usage, value);
2351 if (wacom->wacom_wac.pad_input)
2352 wacom_wac_pad_event(hdev, field, usage, value);
2353 } else if (WACOM_PEN_FIELD(field) && wacom->wacom_wac.pen_input)
Ping Cheng354a3292016-12-08 22:03:27 -08002354 wacom_wac_pen_event(hdev, field, usage, value);
Ping Cheng6f46cf92016-12-08 22:04:52 -08002355 else if (WACOM_FINGER_FIELD(field) && wacom->wacom_wac.touch_input)
Ping Cheng354a3292016-12-08 22:03:27 -08002356 wacom_wac_finger_event(hdev, field, usage, value);
Benjamin Tissoires7704ac92014-09-23 12:08:08 -04002357}
2358
Jason Gerecke06324e02015-07-21 11:07:23 -07002359static void wacom_report_events(struct hid_device *hdev, struct hid_report *report)
2360{
2361 int r;
2362
2363 for (r = 0; r < report->maxfield; r++) {
2364 struct hid_field *field;
2365 unsigned count, n;
2366
2367 field = report->field[r];
2368 count = field->report_count;
2369
2370 if (!(HID_MAIN_ITEM_VARIABLE & field->flags))
2371 continue;
2372
2373 for (n = 0; n < count; n++)
2374 wacom_wac_event(hdev, field, &field->usage[n], field->value[n]);
2375 }
2376}
2377
Benjamin Tissoires7704ac92014-09-23 12:08:08 -04002378void wacom_wac_report(struct hid_device *hdev, struct hid_report *report)
2379{
2380 struct wacom *wacom = hid_get_drvdata(hdev);
2381 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
2382 struct hid_field *field = report->field[0];
2383
2384 if (wacom_wac->features.type != HID_GENERIC)
2385 return;
2386
Ping Cheng6f46cf92016-12-08 22:04:52 -08002387 if (WACOM_PAD_FIELD(field) && wacom->wacom_wac.pad_input)
Jason Gerecke5922e612016-10-19 18:03:51 -07002388 wacom_wac_pad_pre_report(hdev, report);
Ping Cheng6f46cf92016-12-08 22:04:52 -08002389 else if (WACOM_PEN_FIELD(field) && wacom->wacom_wac.pen_input)
Jason Gerecke06324e02015-07-21 11:07:23 -07002390 wacom_wac_pen_pre_report(hdev, report);
Ping Cheng6f46cf92016-12-08 22:04:52 -08002391 else if (WACOM_FINGER_FIELD(field) && wacom->wacom_wac.touch_input)
Jason Gerecke06324e02015-07-21 11:07:23 -07002392 wacom_wac_finger_pre_report(hdev, report);
2393
2394 wacom_report_events(hdev, report);
2395
Jason Gereckea9ce7852017-01-17 15:38:58 -08002396 /*
2397 * Non-input reports may be sent prior to the device being
2398 * completely initialized. Since only their events need
2399 * to be processed, exit after 'wacom_report_events' has
2400 * been called to prevent potential crashes in the report-
2401 * processing functions.
2402 */
2403 if (report->type != HID_INPUT_REPORT)
2404 return;
2405
Ping Chengc9cfb2a2016-12-08 22:06:15 -08002406 if (WACOM_PAD_FIELD(field)) {
2407 wacom_wac_pad_battery_report(hdev, report);
2408 if (wacom->wacom_wac.pad_input)
2409 wacom_wac_pad_report(hdev, report);
2410 } else if (WACOM_PEN_FIELD(field) && wacom->wacom_wac.pen_input)
2411 wacom_wac_pen_report(hdev, report);
Ping Cheng6f46cf92016-12-08 22:04:52 -08002412 else if (WACOM_FINGER_FIELD(field) && wacom->wacom_wac.touch_input)
Ping Chengc9cfb2a2016-12-08 22:06:15 -08002413 wacom_wac_finger_report(hdev, report);
Benjamin Tissoires7704ac92014-09-23 12:08:08 -04002414}
2415
Chris Bagwelle1d38e42010-09-12 00:09:27 -07002416static int wacom_bpt_touch(struct wacom_wac *wacom)
Henrik Rydbergcb734c02010-09-05 12:53:16 -07002417{
Henrik Rydbergf4ccbef2010-09-05 12:57:13 -07002418 struct wacom_features *features = &wacom->features;
Jason Gerecke2a6cdbd2015-06-15 18:01:45 -07002419 struct input_dev *input = wacom->touch_input;
Benjamin Tissoires31168712014-07-24 12:50:10 -07002420 struct input_dev *pad_input = wacom->pad_input;
Henrik Rydbergcb734c02010-09-05 12:53:16 -07002421 unsigned char *data = wacom->data;
Henrik Rydbergcb734c02010-09-05 12:53:16 -07002422 int i;
2423
Chris Bagwell5a6c8652011-11-07 19:52:42 -08002424 if (data[0] != 0x02)
2425 return 0;
2426
Henrik Rydbergcb734c02010-09-05 12:53:16 -07002427 for (i = 0; i < 2; i++) {
Chris Bagwell8f906862011-09-09 13:38:10 -07002428 int offset = (data[1] & 0x80) ? (8 * i) : (9 * i);
Ping Cheng1924e052016-08-09 14:38:56 -07002429 bool touch = report_touch_events(wacom)
2430 && (data[offset + 3] & 0x80);
Chris Bagwell8f906862011-09-09 13:38:10 -07002431
2432 input_mt_slot(input, i);
2433 input_mt_report_slot_state(input, MT_TOOL_FINGER, touch);
Henrik Rydbergc5f4dec2010-12-15 13:50:34 +01002434 if (touch) {
Chris Bagwell8f906862011-09-09 13:38:10 -07002435 int x = get_unaligned_be16(&data[offset + 3]) & 0x7ff;
2436 int y = get_unaligned_be16(&data[offset + 5]) & 0x7ff;
Henrik Rydbergf4ccbef2010-09-05 12:57:13 -07002437 if (features->quirks & WACOM_QUIRK_BBTOUCH_LOWRES) {
2438 x <<= 5;
2439 y <<= 5;
2440 }
Henrik Rydbergcb734c02010-09-05 12:53:16 -07002441 input_report_abs(input, ABS_MT_POSITION_X, x);
2442 input_report_abs(input, ABS_MT_POSITION_Y, y);
Henrik Rydbergcb734c02010-09-05 12:53:16 -07002443 }
Henrik Rydbergcb734c02010-09-05 12:53:16 -07002444 }
2445
Benjamin Tissoires9a1c0012015-02-17 14:19:46 -05002446 input_mt_sync_frame(input);
Henrik Rydbergcb734c02010-09-05 12:53:16 -07002447
Benjamin Tissoires31168712014-07-24 12:50:10 -07002448 input_report_key(pad_input, BTN_LEFT, (data[1] & 0x08) != 0);
2449 input_report_key(pad_input, BTN_FORWARD, (data[1] & 0x04) != 0);
2450 input_report_key(pad_input, BTN_BACK, (data[1] & 0x02) != 0);
2451 input_report_key(pad_input, BTN_RIGHT, (data[1] & 0x01) != 0);
Ping Cheng7d059ed2015-03-20 14:57:21 -07002452 wacom->shared->touch_down = wacom_wac_finger_count_touches(wacom);
Henrik Rydbergcb734c02010-09-05 12:53:16 -07002453
Benjamin Tissoires31168712014-07-24 12:50:10 -07002454 return 1;
Henrik Rydbergcb734c02010-09-05 12:53:16 -07002455}
2456
Ping Cheng7d059ed2015-03-20 14:57:21 -07002457static void wacom_bpt3_touch_msg(struct wacom_wac *wacom, unsigned char *data)
Chris Bagwell73149ab2011-10-26 22:34:21 -07002458{
Ping Cheng9a35c412013-09-20 09:51:56 -07002459 struct wacom_features *features = &wacom->features;
Jason Gerecke2a6cdbd2015-06-15 18:01:45 -07002460 struct input_dev *input = wacom->touch_input;
Chris Bagwell73149ab2011-10-26 22:34:21 -07002461 bool touch = data[1] & 0x80;
Ping Cheng02295e62013-01-04 23:56:00 -08002462 int slot = input_mt_get_slot_by_key(input, data[0]);
2463
2464 if (slot < 0)
Ping Cheng7d059ed2015-03-20 14:57:21 -07002465 return;
Chris Bagwell73149ab2011-10-26 22:34:21 -07002466
Ping Cheng1924e052016-08-09 14:38:56 -07002467 touch = touch && report_touch_events(wacom);
Chris Bagwell73149ab2011-10-26 22:34:21 -07002468
Ping Cheng02295e62013-01-04 23:56:00 -08002469 input_mt_slot(input, slot);
Chris Bagwell73149ab2011-10-26 22:34:21 -07002470 input_mt_report_slot_state(input, MT_TOOL_FINGER, touch);
2471
2472 if (touch) {
2473 int x = (data[2] << 4) | (data[4] >> 4);
2474 int y = (data[3] << 4) | (data[4] & 0x0f);
Ping Cheng9a35c412013-09-20 09:51:56 -07002475 int width, height;
Jason Gerecke4e904952012-10-03 17:19:11 -07002476
Ping Chengeda01da2015-09-23 13:51:15 -07002477 if (features->type >= INTUOSPS && features->type <= INTUOSHT2) {
Jason Gerecke0b279da2013-11-25 18:43:16 -08002478 width = data[5] * 100;
2479 height = data[6] * 100;
Ping Cheng9a35c412013-09-20 09:51:56 -07002480 } else {
2481 /*
2482 * "a" is a scaled-down area which we assume is
2483 * roughly circular and which can be described as:
2484 * a=(pi*r^2)/C.
2485 */
2486 int a = data[5];
Ping Chengd7da3a32014-06-13 13:37:33 -07002487 int x_res = input_abs_get_res(input, ABS_MT_POSITION_X);
2488 int y_res = input_abs_get_res(input, ABS_MT_POSITION_Y);
2489 width = 2 * int_sqrt(a * WACOM_CONTACT_AREA_SCALE);
Ping Cheng9a35c412013-09-20 09:51:56 -07002490 height = width * y_res / x_res;
2491 }
Chris Bagwell73149ab2011-10-26 22:34:21 -07002492
2493 input_report_abs(input, ABS_MT_POSITION_X, x);
2494 input_report_abs(input, ABS_MT_POSITION_Y, y);
Jason Gerecke4e904952012-10-03 17:19:11 -07002495 input_report_abs(input, ABS_MT_TOUCH_MAJOR, width);
2496 input_report_abs(input, ABS_MT_TOUCH_MINOR, height);
Chris Bagwell73149ab2011-10-26 22:34:21 -07002497 }
2498}
2499
2500static void wacom_bpt3_button_msg(struct wacom_wac *wacom, unsigned char *data)
2501{
Benjamin Tissoires31168712014-07-24 12:50:10 -07002502 struct input_dev *input = wacom->pad_input;
Ping Chengb5fd2a32013-11-25 18:44:55 -08002503 struct wacom_features *features = &wacom->features;
Chris Bagwell73149ab2011-10-26 22:34:21 -07002504
Ping Chengeda01da2015-09-23 13:51:15 -07002505 if (features->type == INTUOSHT || features->type == INTUOSHT2) {
Ping Chengb5fd2a32013-11-25 18:44:55 -08002506 input_report_key(input, BTN_LEFT, (data[1] & 0x02) != 0);
2507 input_report_key(input, BTN_BACK, (data[1] & 0x08) != 0);
2508 } else {
2509 input_report_key(input, BTN_BACK, (data[1] & 0x02) != 0);
2510 input_report_key(input, BTN_LEFT, (data[1] & 0x08) != 0);
2511 }
Chris Bagwell73149ab2011-10-26 22:34:21 -07002512 input_report_key(input, BTN_FORWARD, (data[1] & 0x04) != 0);
Chris Bagwell73149ab2011-10-26 22:34:21 -07002513 input_report_key(input, BTN_RIGHT, (data[1] & 0x01) != 0);
2514}
2515
2516static int wacom_bpt3_touch(struct wacom_wac *wacom)
2517{
Chris Bagwell73149ab2011-10-26 22:34:21 -07002518 unsigned char *data = wacom->data;
Jason Gerecke19d57d32012-03-06 10:19:19 -08002519 int count = data[1] & 0x07;
Ping Chengeda01da2015-09-23 13:51:15 -07002520 int touch_changed = 0, i;
Chris Bagwell73149ab2011-10-26 22:34:21 -07002521
Chris Bagwell5a6c8652011-11-07 19:52:42 -08002522 if (data[0] != 0x02)
2523 return 0;
2524
Chris Bagwell73149ab2011-10-26 22:34:21 -07002525 /* data has up to 7 fixed sized 8-byte messages starting at data[2] */
2526 for (i = 0; i < count; i++) {
2527 int offset = (8 * i) + 2;
2528 int msg_id = data[offset];
2529
Ping Chengeda01da2015-09-23 13:51:15 -07002530 if (msg_id >= 2 && msg_id <= 17) {
Ping Cheng7d059ed2015-03-20 14:57:21 -07002531 wacom_bpt3_touch_msg(wacom, data + offset);
Ping Chengeda01da2015-09-23 13:51:15 -07002532 touch_changed++;
2533 } else if (msg_id == 128)
Chris Bagwell73149ab2011-10-26 22:34:21 -07002534 wacom_bpt3_button_msg(wacom, data + offset);
2535
2536 }
Jason Gerecke2a6cdbd2015-06-15 18:01:45 -07002537
Ping Chengeda01da2015-09-23 13:51:15 -07002538 /* only update touch if we actually have a touchpad and touch data changed */
Benjamin Tissoires84dfbd72016-07-13 18:05:55 +02002539 if (wacom->touch_input && touch_changed) {
Jason Gerecke2a6cdbd2015-06-15 18:01:45 -07002540 input_mt_sync_frame(wacom->touch_input);
2541 wacom->shared->touch_down = wacom_wac_finger_count_touches(wacom);
2542 }
Chris Bagwell73149ab2011-10-26 22:34:21 -07002543
Benjamin Tissoires31168712014-07-24 12:50:10 -07002544 return 1;
Chris Bagwell73149ab2011-10-26 22:34:21 -07002545}
2546
Chris Bagwell2aaacb12010-09-12 00:11:35 -07002547static int wacom_bpt_pen(struct wacom_wac *wacom)
2548{
Ping Cheng961794a2013-12-05 12:54:53 -08002549 struct wacom_features *features = &wacom->features;
Jason Gerecke2a6cdbd2015-06-15 18:01:45 -07002550 struct input_dev *input = wacom->pen_input;
Chris Bagwell2aaacb12010-09-12 00:11:35 -07002551 unsigned char *data = wacom->data;
2552 int prox = 0, x = 0, y = 0, p = 0, d = 0, pen = 0, btn1 = 0, btn2 = 0;
2553
Jason Gerecke4ca4ec72015-03-06 11:47:38 -08002554 if (data[0] != WACOM_REPORT_PENABLED)
Chris Bagwell5a6c8652011-11-07 19:52:42 -08002555 return 0;
2556
Chris Bagwellc5981412011-10-26 22:28:34 -07002557 prox = (data[1] & 0x20) == 0x20;
Chris Bagwell2aaacb12010-09-12 00:11:35 -07002558
2559 /*
2560 * All reports shared between PEN and RUBBER tool must be
2561 * forced to a known starting value (zero) when transitioning to
2562 * out-of-prox.
2563 *
2564 * If not reset then, to userspace, it will look like lost events
2565 * if new tool comes in-prox with same values as previous tool sent.
2566 *
2567 * Hardware does report zero in most out-of-prox cases but not all.
2568 */
Ping Cheng01499312015-03-20 14:58:01 -07002569 if (!wacom->shared->stylus_in_proximity) {
2570 if (data[1] & 0x08) {
2571 wacom->tool[0] = BTN_TOOL_RUBBER;
2572 wacom->id[0] = ERASER_DEVICE_ID;
2573 } else {
2574 wacom->tool[0] = BTN_TOOL_PEN;
2575 wacom->id[0] = STYLUS_DEVICE_ID;
Chris Bagwell2aaacb12010-09-12 00:11:35 -07002576 }
Ping Cheng01499312015-03-20 14:58:01 -07002577 }
2578
2579 wacom->shared->stylus_in_proximity = prox;
Ping Cheng1924e052016-08-09 14:38:56 -07002580 if (delay_pen_events(wacom))
Ping Cheng01499312015-03-20 14:58:01 -07002581 return 0;
2582
2583 if (prox) {
Chris Bagwell2aaacb12010-09-12 00:11:35 -07002584 x = le16_to_cpup((__le16 *)&data[2]);
2585 y = le16_to_cpup((__le16 *)&data[4]);
2586 p = le16_to_cpup((__le16 *)&data[6]);
Chris Bagwellc18c2ce2011-10-10 08:52:13 -07002587 /*
2588 * Convert distance from out prox to distance from tablet.
2589 * distance will be greater than distance_max once
2590 * touching and applying pressure; do not report negative
2591 * distance.
2592 */
Ping Cheng961794a2013-12-05 12:54:53 -08002593 if (data[8] <= features->distance_max)
2594 d = features->distance_max - data[8];
Chris Bagwellc18c2ce2011-10-10 08:52:13 -07002595
Chris Bagwell2aaacb12010-09-12 00:11:35 -07002596 pen = data[1] & 0x01;
2597 btn1 = data[1] & 0x02;
2598 btn2 = data[1] & 0x04;
Ping Cheng01499312015-03-20 14:58:01 -07002599 } else {
2600 wacom->id[0] = 0;
Chris Bagwell2aaacb12010-09-12 00:11:35 -07002601 }
2602
2603 input_report_key(input, BTN_TOUCH, pen);
2604 input_report_key(input, BTN_STYLUS, btn1);
2605 input_report_key(input, BTN_STYLUS2, btn2);
2606
2607 input_report_abs(input, ABS_X, x);
2608 input_report_abs(input, ABS_Y, y);
2609 input_report_abs(input, ABS_PRESSURE, p);
2610 input_report_abs(input, ABS_DISTANCE, d);
2611
Chris Bagwell2aaacb12010-09-12 00:11:35 -07002612 input_report_key(input, wacom->tool[0], prox); /* PEN or RUBBER */
2613 input_report_abs(input, ABS_MISC, wacom->id[0]); /* TOOL ID */
2614
2615 return 1;
2616}
2617
Chris Bagwelle1d38e42010-09-12 00:09:27 -07002618static int wacom_bpt_irq(struct wacom_wac *wacom, size_t len)
2619{
Ping Chengeda01da2015-09-23 13:51:15 -07002620 struct wacom_features *features = &wacom->features;
2621
2622 if ((features->type == INTUOSHT2) &&
Ping Chengeda01da2015-09-23 13:51:15 -07002623 (features->device_type & WACOM_DEVICETYPE_PEN))
2624 return wacom_intuos_irq(wacom);
2625 else if (len == WACOM_PKGLEN_BBTOUCH)
Chris Bagwelle1d38e42010-09-12 00:09:27 -07002626 return wacom_bpt_touch(wacom);
Chris Bagwell73149ab2011-10-26 22:34:21 -07002627 else if (len == WACOM_PKGLEN_BBTOUCH3)
2628 return wacom_bpt3_touch(wacom);
2629 else if (len == WACOM_PKGLEN_BBFUN || len == WACOM_PKGLEN_BBPEN)
Chris Bagwell2aaacb12010-09-12 00:11:35 -07002630 return wacom_bpt_pen(wacom);
Chris Bagwelle1d38e42010-09-12 00:09:27 -07002631
2632 return 0;
2633}
2634
Benjamin Tissoires8c97a762015-02-26 11:28:50 -05002635static void wacom_bamboo_pad_pen_event(struct wacom_wac *wacom,
2636 unsigned char *data)
2637{
2638 unsigned char prefix;
2639
2640 /*
2641 * We need to reroute the event from the debug interface to the
2642 * pen interface.
2643 * We need to add the report ID to the actual pen report, so we
2644 * temporary overwrite the first byte to prevent having to kzalloc/kfree
2645 * and memcpy the report.
2646 */
2647 prefix = data[0];
2648 data[0] = WACOM_REPORT_BPAD_PEN;
2649
2650 /*
2651 * actually reroute the event.
2652 * No need to check if wacom->shared->pen is valid, hid_input_report()
2653 * will check for us.
2654 */
2655 hid_input_report(wacom->shared->pen, HID_INPUT_REPORT, data,
2656 WACOM_PKGLEN_PENABLED, 1);
2657
2658 data[0] = prefix;
2659}
2660
2661static int wacom_bamboo_pad_touch_event(struct wacom_wac *wacom,
2662 unsigned char *data)
2663{
Jason Gerecke2a6cdbd2015-06-15 18:01:45 -07002664 struct input_dev *input = wacom->touch_input;
Benjamin Tissoires8c97a762015-02-26 11:28:50 -05002665 unsigned char *finger_data, prefix;
2666 unsigned id;
2667 int x, y;
2668 bool valid;
2669
2670 prefix = data[0];
2671
2672 for (id = 0; id < wacom->features.touch_max; id++) {
2673 valid = !!(prefix & BIT(id)) &&
Ping Cheng1924e052016-08-09 14:38:56 -07002674 report_touch_events(wacom);
Benjamin Tissoires8c97a762015-02-26 11:28:50 -05002675
2676 input_mt_slot(input, id);
2677 input_mt_report_slot_state(input, MT_TOOL_FINGER, valid);
2678
2679 if (!valid)
2680 continue;
2681
2682 finger_data = data + 1 + id * 3;
2683 x = finger_data[0] | ((finger_data[1] & 0x0f) << 8);
2684 y = (finger_data[2] << 4) | (finger_data[1] >> 4);
2685
2686 input_report_abs(input, ABS_MT_POSITION_X, x);
2687 input_report_abs(input, ABS_MT_POSITION_Y, y);
2688 }
2689
2690 input_mt_sync_frame(input);
2691
2692 input_report_key(input, BTN_LEFT, prefix & 0x40);
2693 input_report_key(input, BTN_RIGHT, prefix & 0x80);
2694
2695 /* keep touch state for pen event */
Ping Cheng1924e052016-08-09 14:38:56 -07002696 wacom->shared->touch_down = !!prefix && report_touch_events(wacom);
Benjamin Tissoires8c97a762015-02-26 11:28:50 -05002697
2698 return 1;
2699}
2700
2701static int wacom_bamboo_pad_irq(struct wacom_wac *wacom, size_t len)
2702{
2703 unsigned char *data = wacom->data;
2704
2705 if (!((len == WACOM_PKGLEN_BPAD_TOUCH) ||
2706 (len == WACOM_PKGLEN_BPAD_TOUCH_USB)) ||
2707 (data[0] != WACOM_REPORT_BPAD_TOUCH))
2708 return 0;
2709
2710 if (data[1] & 0x01)
2711 wacom_bamboo_pad_pen_event(wacom, &data[1]);
2712
2713 if (data[1] & 0x02)
2714 return wacom_bamboo_pad_touch_event(wacom, &data[9]);
2715
2716 return 0;
2717}
2718
Chris Bagwelld3825d52012-03-25 23:26:11 -07002719static int wacom_wireless_irq(struct wacom_wac *wacom, size_t len)
2720{
Chris Bagwell16bf2882012-03-25 23:26:20 -07002721 unsigned char *data = wacom->data;
2722 int connected;
2723
Ping Chengb5fd2a32013-11-25 18:44:55 -08002724 if (len != WACOM_PKGLEN_WIRELESS || data[0] != WACOM_REPORT_WL)
Chris Bagwelld3825d52012-03-25 23:26:11 -07002725 return 0;
2726
Chris Bagwell16bf2882012-03-25 23:26:20 -07002727 connected = data[1] & 0x01;
2728 if (connected) {
Jason Gereckeb0882cb2015-03-06 11:47:43 -08002729 int pid, battery, charging;
Chris Bagwell16bf2882012-03-25 23:26:20 -07002730
Ping Chengeda01da2015-09-23 13:51:15 -07002731 if ((wacom->shared->type == INTUOSHT ||
2732 wacom->shared->type == INTUOSHT2) &&
Ping Cheng44b96832014-11-06 17:30:51 -08002733 wacom->shared->touch_input &&
2734 wacom->shared->touch_max) {
Ping Cheng961794a2013-12-05 12:54:53 -08002735 input_report_switch(wacom->shared->touch_input,
2736 SW_MUTE_DEVICE, data[5] & 0x40);
2737 input_sync(wacom->shared->touch_input);
2738 }
2739
Chris Bagwell16bf2882012-03-25 23:26:20 -07002740 pid = get_unaligned_be16(&data[6]);
Benjamin Tissoiresac8d1012014-07-25 17:29:48 -07002741 battery = (data[5] & 0x3f) * 100 / 31;
Jason Gereckeb0882cb2015-03-06 11:47:43 -08002742 charging = !!(data[5] & 0x80);
Chris Bagwell16bf2882012-03-25 23:26:20 -07002743 if (wacom->pid != pid) {
2744 wacom->pid = pid;
Benjamin Tissoiresd17d1f12016-07-13 18:05:52 +02002745 wacom_schedule_work(wacom, WACOM_WORKER_WIRELESS);
Chris Bagwell16bf2882012-03-25 23:26:20 -07002746 }
Benjamin Tissoiresac8d1012014-07-25 17:29:48 -07002747
Benjamin Tissoires59d69bc2016-07-13 18:06:08 +02002748 wacom_notify_battery(wacom, battery, charging, 1, 0);
Jason Gerecke953f2c52015-03-06 11:47:39 -08002749
Chris Bagwell16bf2882012-03-25 23:26:20 -07002750 } else if (wacom->pid != 0) {
2751 /* disconnected while previously connected */
2752 wacom->pid = 0;
Benjamin Tissoiresd17d1f12016-07-13 18:05:52 +02002753 wacom_schedule_work(wacom, WACOM_WORKER_WIRELESS);
Jason Gerecke71fa6412015-03-11 10:25:41 -07002754 wacom_notify_battery(wacom, 0, 0, 0, 0);
Chris Bagwell16bf2882012-03-25 23:26:20 -07002755 }
2756
Chris Bagwelld3825d52012-03-25 23:26:11 -07002757 return 0;
2758}
2759
Jason Gerecke4ca4ec72015-03-06 11:47:38 -08002760static int wacom_status_irq(struct wacom_wac *wacom_wac, size_t len)
2761{
Jason Gerecke8f93b0b2015-03-06 11:47:41 -08002762 struct wacom *wacom = container_of(wacom_wac, struct wacom, wacom_wac);
Jason Gerecke4ca4ec72015-03-06 11:47:38 -08002763 struct wacom_features *features = &wacom_wac->features;
2764 unsigned char *data = wacom_wac->data;
2765
2766 if (data[0] != WACOM_REPORT_USB)
2767 return 0;
2768
Ping Chengeda01da2015-09-23 13:51:15 -07002769 if ((features->type == INTUOSHT ||
2770 features->type == INTUOSHT2) &&
Jason Gerecke4ca4ec72015-03-06 11:47:38 -08002771 wacom_wac->shared->touch_input &&
2772 features->touch_max) {
2773 input_report_switch(wacom_wac->shared->touch_input,
2774 SW_MUTE_DEVICE, data[8] & 0x40);
2775 input_sync(wacom_wac->shared->touch_input);
2776 }
Jason Gerecke8f93b0b2015-03-06 11:47:41 -08002777
2778 if (data[9] & 0x02) { /* wireless module is attached */
2779 int battery = (data[8] & 0x3f) * 100 / 31;
Jason Gereckeb0882cb2015-03-06 11:47:43 -08002780 bool charging = !!(data[8] & 0x80);
Jason Gerecke8f93b0b2015-03-06 11:47:41 -08002781
2782 wacom_notify_battery(wacom_wac, battery, charging,
Jason Gerecke71fa6412015-03-11 10:25:41 -07002783 battery || charging, 1);
Jason Gerecke8f93b0b2015-03-06 11:47:41 -08002784
Benjamin Tissoires59d69bc2016-07-13 18:06:08 +02002785 if (!wacom->battery.battery &&
Jason Gerecke8f93b0b2015-03-06 11:47:41 -08002786 !(features->quirks & WACOM_QUIRK_BATTERY)) {
2787 features->quirks |= WACOM_QUIRK_BATTERY;
Benjamin Tissoiresd17d1f12016-07-13 18:05:52 +02002788 wacom_schedule_work(wacom_wac, WACOM_WORKER_BATTERY);
Jason Gerecke8f93b0b2015-03-06 11:47:41 -08002789 }
2790 }
2791 else if ((features->quirks & WACOM_QUIRK_BATTERY) &&
Benjamin Tissoires59d69bc2016-07-13 18:06:08 +02002792 wacom->battery.battery) {
Jason Gerecke8f93b0b2015-03-06 11:47:41 -08002793 features->quirks &= ~WACOM_QUIRK_BATTERY;
Benjamin Tissoiresd17d1f12016-07-13 18:05:52 +02002794 wacom_schedule_work(wacom_wac, WACOM_WORKER_BATTERY);
Jason Gerecke71fa6412015-03-11 10:25:41 -07002795 wacom_notify_battery(wacom_wac, 0, 0, 0, 0);
Jason Gerecke8f93b0b2015-03-06 11:47:41 -08002796 }
Jason Gerecke4ca4ec72015-03-06 11:47:38 -08002797 return 0;
2798}
2799
Dmitry Torokhov95dd3b32010-03-19 22:18:15 -07002800void wacom_wac_irq(struct wacom_wac *wacom_wac, size_t len)
Ping Cheng3bea7332006-07-13 18:01:36 -07002801{
Dmitry Torokhov95dd3b32010-03-19 22:18:15 -07002802 bool sync;
2803
Jason Childse33da8a2010-02-17 22:38:31 -08002804 switch (wacom_wac->features.type) {
Dmitry Torokhov73a97f42010-03-19 22:18:15 -07002805 case PENPARTNER:
Dmitry Torokhov95dd3b32010-03-19 22:18:15 -07002806 sync = wacom_penpartner_irq(wacom_wac);
2807 break;
Ping Cheng545f4e92008-11-24 11:44:27 -05002808
Dmitry Torokhov73a97f42010-03-19 22:18:15 -07002809 case PL:
Dmitry Torokhov95dd3b32010-03-19 22:18:15 -07002810 sync = wacom_pl_irq(wacom_wac);
2811 break;
Ping Cheng545f4e92008-11-24 11:44:27 -05002812
Dmitry Torokhov73a97f42010-03-19 22:18:15 -07002813 case WACOM_G4:
2814 case GRAPHIRE:
Benjamin Tissoires387142b2014-08-06 13:52:56 -07002815 case GRAPHIRE_BT:
Dmitry Torokhov73a97f42010-03-19 22:18:15 -07002816 case WACOM_MO:
Dmitry Torokhov95dd3b32010-03-19 22:18:15 -07002817 sync = wacom_graphire_irq(wacom_wac);
2818 break;
Ping Cheng545f4e92008-11-24 11:44:27 -05002819
Dmitry Torokhov73a97f42010-03-19 22:18:15 -07002820 case PTU:
Dmitry Torokhov95dd3b32010-03-19 22:18:15 -07002821 sync = wacom_ptu_irq(wacom_wac);
2822 break;
Ping Cheng545f4e92008-11-24 11:44:27 -05002823
Ping Chengc8f2edc2010-06-28 01:10:51 -07002824 case DTU:
2825 sync = wacom_dtu_irq(wacom_wac);
2826 break;
2827
Ping Cheng497ab1f2014-01-20 20:18:04 -08002828 case DTUS:
Ping Chengfff00bf2014-12-04 18:23:04 -08002829 case DTUSX:
Ping Cheng497ab1f2014-01-20 20:18:04 -08002830 sync = wacom_dtus_irq(wacom_wac);
2831 break;
2832
Dmitry Torokhov73a97f42010-03-19 22:18:15 -07002833 case INTUOS:
2834 case INTUOS3S:
2835 case INTUOS3:
2836 case INTUOS3L:
2837 case INTUOS4S:
2838 case INTUOS4:
2839 case INTUOS4L:
2840 case CINTIQ:
2841 case WACOM_BEE:
Ping Cheng56218562013-05-05 19:56:18 -07002842 case WACOM_13HD:
Ping Cheng3a4b4aa2010-06-03 22:10:21 -07002843 case WACOM_21UX2:
Ping Chengd838c642012-07-24 23:54:11 -07002844 case WACOM_22HD:
Jason Gerecke803296b2011-12-12 00:11:45 -08002845 case WACOM_24HD:
Ping Cheng500d4162015-01-27 13:30:03 -08002846 case WACOM_27QHD:
Ping Chenga112e9f2013-02-13 20:20:01 -08002847 case DTK:
Jason Gerecke36d3c512013-09-20 09:47:35 -07002848 case CINTIQ_HYBRID:
Jason Gereckef7acb552015-10-13 10:03:49 -07002849 case CINTIQ_COMPANION_2:
Dmitry Torokhov95dd3b32010-03-19 22:18:15 -07002850 sync = wacom_intuos_irq(wacom_wac);
2851 break;
Ping Cheng545f4e92008-11-24 11:44:27 -05002852
Benjamin Tissoires81af7e62014-08-06 13:55:56 -07002853 case INTUOS4WL:
2854 sync = wacom_intuos_bt_irq(wacom_wac, len);
2855 break;
2856
Jason Gereckeb1e42792012-10-21 00:38:04 -07002857 case WACOM_24HDT:
Ping Cheng500d4162015-01-27 13:30:03 -08002858 case WACOM_27QHDT:
Jason Gereckeb1e42792012-10-21 00:38:04 -07002859 sync = wacom_24hdt_irq(wacom_wac);
2860 break;
2861
Jason Gereckeae584ca2012-04-03 15:50:40 -07002862 case INTUOS5S:
2863 case INTUOS5:
2864 case INTUOS5L:
Ping Cheng9a35c412013-09-20 09:51:56 -07002865 case INTUOSPS:
2866 case INTUOSPM:
2867 case INTUOSPL:
Jason Gereckeae584ca2012-04-03 15:50:40 -07002868 if (len == WACOM_PKGLEN_BBTOUCH3)
2869 sync = wacom_bpt3_touch(wacom_wac);
Jason Gerecke2d13a432015-03-06 11:47:42 -08002870 else if (wacom_wac->data[0] == WACOM_REPORT_USB)
2871 sync = wacom_status_irq(wacom_wac, len);
Jason Gereckeae584ca2012-04-03 15:50:40 -07002872 else
2873 sync = wacom_intuos_irq(wacom_wac);
2874 break;
2875
Jason Gerecke4922cd22017-01-25 12:08:37 -08002876 case INTUOSP2_BT:
2877 sync = wacom_intuos_pro2_bt_irq(wacom_wac, len);
2878 break;
2879
Dmitry Torokhov73a97f42010-03-19 22:18:15 -07002880 case TABLETPC:
Ping Chengac173832012-06-12 00:15:06 -07002881 case TABLETPCE:
Dmitry Torokhov73a97f42010-03-19 22:18:15 -07002882 case TABLETPC2FG:
Ping Cheng19635182012-04-29 21:09:18 -07002883 case MTSCREEN:
Ping Cheng6afdc282012-11-03 12:16:15 -07002884 case MTTPC:
Jason Gerecked51ddb22014-05-14 17:14:29 -07002885 case MTTPC_B:
Dmitry Torokhov95dd3b32010-03-19 22:18:15 -07002886 sync = wacom_tpc_irq(wacom_wac, len);
2887 break;
Ping Cheng545f4e92008-11-24 11:44:27 -05002888
Henrik Rydbergcb734c02010-09-05 12:53:16 -07002889 case BAMBOO_PT:
Ping Cheng3b164a02015-09-23 09:59:10 -07002890 case BAMBOO_PEN:
2891 case BAMBOO_TOUCH:
Ping Chengb5fd2a32013-11-25 18:44:55 -08002892 case INTUOSHT:
Ping Chengeda01da2015-09-23 13:51:15 -07002893 case INTUOSHT2:
Jason Gerecke4ca4ec72015-03-06 11:47:38 -08002894 if (wacom_wac->data[0] == WACOM_REPORT_USB)
2895 sync = wacom_status_irq(wacom_wac, len);
2896 else
2897 sync = wacom_bpt_irq(wacom_wac, len);
Henrik Rydbergcb734c02010-09-05 12:53:16 -07002898 break;
2899
Benjamin Tissoires8c97a762015-02-26 11:28:50 -05002900 case BAMBOO_PAD:
2901 sync = wacom_bamboo_pad_irq(wacom_wac, len);
Ping Cheng3bea7332006-07-13 18:01:36 -07002902 break;
2903
Chris Bagwelld3825d52012-03-25 23:26:11 -07002904 case WIRELESS:
2905 sync = wacom_wireless_irq(wacom_wac, len);
2906 break;
2907
Aaron Skomra72b236d2015-08-20 16:05:17 -07002908 case REMOTE:
Benjamin Tissoirese6f28132016-07-13 18:06:01 +02002909 sync = false;
Aaron Skomra72b236d2015-08-20 16:05:17 -07002910 if (wacom_wac->data[0] == WACOM_REPORT_DEVICE_LIST)
Benjamin Tissoirese6f28132016-07-13 18:06:01 +02002911 wacom_remote_status_irq(wacom_wac, len);
Aaron Skomra72b236d2015-08-20 16:05:17 -07002912 else
2913 sync = wacom_remote_irq(wacom_wac, len);
2914 break;
2915
Dmitry Torokhov73a97f42010-03-19 22:18:15 -07002916 default:
Dmitry Torokhov95dd3b32010-03-19 22:18:15 -07002917 sync = false;
2918 break;
Ping Cheng3bea7332006-07-13 18:01:36 -07002919 }
Dmitry Torokhov95dd3b32010-03-19 22:18:15 -07002920
Benjamin Tissoiresd2d13f12014-07-24 12:48:28 -07002921 if (sync) {
Jason Gerecke2a6cdbd2015-06-15 18:01:45 -07002922 if (wacom_wac->pen_input)
2923 input_sync(wacom_wac->pen_input);
2924 if (wacom_wac->touch_input)
2925 input_sync(wacom_wac->touch_input);
Benjamin Tissoiresd2d13f12014-07-24 12:48:28 -07002926 if (wacom_wac->pad_input)
2927 input_sync(wacom_wac->pad_input);
2928 }
Ping Cheng3bea7332006-07-13 18:01:36 -07002929}
2930
Ping Chengeda01da2015-09-23 13:51:15 -07002931static void wacom_setup_basic_pro_pen(struct wacom_wac *wacom_wac)
Ping Cheng3bea7332006-07-13 18:01:36 -07002932{
Jason Gerecke2a6cdbd2015-06-15 18:01:45 -07002933 struct input_dev *input_dev = wacom_wac->pen_input;
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -07002934
2935 input_set_capability(input_dev, EV_MSC, MSC_SERIAL);
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -07002936
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -07002937 __set_bit(BTN_TOOL_PEN, input_dev->keybit);
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -07002938 __set_bit(BTN_STYLUS, input_dev->keybit);
2939 __set_bit(BTN_STYLUS2, input_dev->keybit);
2940
2941 input_set_abs_params(input_dev, ABS_DISTANCE,
Jason Gereckebef7e202016-04-22 14:30:53 -07002942 0, wacom_wac->features.distance_max, wacom_wac->features.distance_fuzz, 0);
Ping Chengeda01da2015-09-23 13:51:15 -07002943}
2944
2945static void wacom_setup_cintiq(struct wacom_wac *wacom_wac)
2946{
2947 struct input_dev *input_dev = wacom_wac->pen_input;
Jason Gereckebef7e202016-04-22 14:30:53 -07002948 struct wacom_features *features = &wacom_wac->features;
Ping Chengeda01da2015-09-23 13:51:15 -07002949
2950 wacom_setup_basic_pro_pen(wacom_wac);
2951
2952 __set_bit(BTN_TOOL_RUBBER, input_dev->keybit);
2953 __set_bit(BTN_TOOL_BRUSH, input_dev->keybit);
2954 __set_bit(BTN_TOOL_PENCIL, input_dev->keybit);
2955 __set_bit(BTN_TOOL_AIRBRUSH, input_dev->keybit);
2956
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -07002957 input_set_abs_params(input_dev, ABS_WHEEL, 0, 1023, 0, 0);
Jason Gereckebef7e202016-04-22 14:30:53 -07002958 input_set_abs_params(input_dev, ABS_TILT_X, -64, 63, features->tilt_fuzz, 0);
Jason Gerecke26fe4122014-11-18 16:50:09 -08002959 input_abs_set_res(input_dev, ABS_TILT_X, 57);
Jason Gereckebef7e202016-04-22 14:30:53 -07002960 input_set_abs_params(input_dev, ABS_TILT_Y, -64, 63, features->tilt_fuzz, 0);
Jason Gerecke26fe4122014-11-18 16:50:09 -08002961 input_abs_set_res(input_dev, ABS_TILT_Y, 57);
Ping Cheng6521d0b2010-10-24 21:53:40 -07002962}
2963
2964static void wacom_setup_intuos(struct wacom_wac *wacom_wac)
2965{
Jason Gerecke2a6cdbd2015-06-15 18:01:45 -07002966 struct input_dev *input_dev = wacom_wac->pen_input;
Ping Cheng6521d0b2010-10-24 21:53:40 -07002967
2968 input_set_capability(input_dev, EV_REL, REL_WHEEL);
2969
2970 wacom_setup_cintiq(wacom_wac);
2971
2972 __set_bit(BTN_LEFT, input_dev->keybit);
2973 __set_bit(BTN_RIGHT, input_dev->keybit);
2974 __set_bit(BTN_MIDDLE, input_dev->keybit);
2975 __set_bit(BTN_SIDE, input_dev->keybit);
2976 __set_bit(BTN_EXTRA, input_dev->keybit);
2977 __set_bit(BTN_TOOL_MOUSE, input_dev->keybit);
2978 __set_bit(BTN_TOOL_LENS, input_dev->keybit);
2979
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -07002980 input_set_abs_params(input_dev, ABS_RZ, -900, 899, 0, 0);
Jason Gerecke26fe4122014-11-18 16:50:09 -08002981 input_abs_set_res(input_dev, ABS_RZ, 287);
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -07002982 input_set_abs_params(input_dev, ABS_THROTTLE, -1023, 1023, 0, 0);
2983}
2984
Ping Cheng42f4f272015-04-15 16:53:54 -07002985void wacom_setup_device_quirks(struct wacom *wacom)
Henrik Rydbergbc73dd32010-09-05 12:26:16 -07002986{
Ping Cheng42f4f272015-04-15 16:53:54 -07002987 struct wacom_features *features = &wacom->wacom_wac.features;
Henrik Rydbergbc73dd32010-09-05 12:26:16 -07002988
Jason Gerecke862cf552015-06-15 18:01:43 -07002989 /* The pen and pad share the same interface on most devices */
2990 if (features->type == GRAPHIRE_BT || features->type == WACOM_G4 ||
Ping Cheng3b164a02015-09-23 09:59:10 -07002991 features->type == DTUS ||
2992 (features->type >= INTUOS3S && features->type <= WACOM_MO)) {
Jason Gerecke862cf552015-06-15 18:01:43 -07002993 if (features->device_type & WACOM_DEVICETYPE_PEN)
2994 features->device_type |= WACOM_DEVICETYPE_PAD;
2995 }
Henrik Rydbergbc73dd32010-09-05 12:26:16 -07002996
2997 /* touch device found but size is not defined. use default */
Jason Gereckeaa86b182015-06-15 18:01:42 -07002998 if (features->device_type & WACOM_DEVICETYPE_TOUCH && !features->x_max) {
Henrik Rydbergbc73dd32010-09-05 12:26:16 -07002999 features->x_max = 1023;
3000 features->y_max = 1023;
3001 }
3002
Ping Cheng42f4f272015-04-15 16:53:54 -07003003 /*
3004 * Intuos5/Pro and Bamboo 3rd gen have no useful data about its
3005 * touch interface in its HID descriptor. If this is the touch
3006 * interface (PacketSize of WACOM_PKGLEN_BBTOUCH3), override the
3007 * tablet values.
3008 */
Ping Cheng3b164a02015-09-23 09:59:10 -07003009 if ((features->type >= INTUOS5S && features->type <= INTUOSPL) ||
3010 (features->type >= INTUOSHT && features->type <= BAMBOO_PT)) {
Ping Cheng42f4f272015-04-15 16:53:54 -07003011 if (features->pktlen == WACOM_PKGLEN_BBTOUCH3) {
Jason Gerecke862cf552015-06-15 18:01:43 -07003012 if (features->touch_max)
3013 features->device_type |= WACOM_DEVICETYPE_TOUCH;
Jiri Kosinaa3088ab2015-11-17 00:24:14 +01003014 if (features->type >= INTUOSHT && features->type <= BAMBOO_PT)
Jason Gerecke862cf552015-06-15 18:01:43 -07003015 features->device_type |= WACOM_DEVICETYPE_PAD;
Ping Cheng42f4f272015-04-15 16:53:54 -07003016
3017 features->x_max = 4096;
3018 features->y_max = 4096;
Ping Cheng42f4f272015-04-15 16:53:54 -07003019 }
Jason Gerecke96339202015-07-01 13:01:00 -07003020 else if (features->pktlen == WACOM_PKGLEN_BBTOUCH) {
3021 features->device_type |= WACOM_DEVICETYPE_PAD;
3022 }
Ping Cheng42f4f272015-04-15 16:53:54 -07003023 }
3024
3025 /*
Benjamin Tissoires580549e2016-03-25 15:26:55 +01003026 * Hack for the Bamboo One:
3027 * the device presents a PAD/Touch interface as most Bamboos and even
3028 * sends ghosts PAD data on it. However, later, we must disable this
3029 * ghost interface, and we can not detect it unless we set it here
3030 * to WACOM_DEVICETYPE_PAD or WACOM_DEVICETYPE_TOUCH.
3031 */
3032 if (features->type == BAMBOO_PEN &&
3033 features->pktlen == WACOM_PKGLEN_BBTOUCH3)
3034 features->device_type |= WACOM_DEVICETYPE_PAD;
3035
3036 /*
Jason Gerecke042628a2015-04-30 17:51:54 -07003037 * Raw Wacom-mode pen and touch events both come from interface
3038 * 0, whose HID descriptor has an application usage of 0xFF0D
Jason Gerecke8de82282016-10-19 18:03:37 -07003039 * (i.e., WACOM_HID_WD_DIGITIZER). We route pen packets back
Jason Gerecke042628a2015-04-30 17:51:54 -07003040 * out through the HID_GENERIC device created for interface 1,
Benjamin Tissoires70caee02015-07-09 14:11:51 -04003041 * so rewrite this one to be of type WACOM_DEVICETYPE_TOUCH.
Ping Cheng42f4f272015-04-15 16:53:54 -07003042 */
3043 if (features->type == BAMBOO_PAD)
Benjamin Tissoires70caee02015-07-09 14:11:51 -04003044 features->device_type = WACOM_DEVICETYPE_TOUCH;
Ping Cheng42f4f272015-04-15 16:53:54 -07003045
Aaron Skomra72b236d2015-08-20 16:05:17 -07003046 if (features->type == REMOTE)
3047 features->device_type = WACOM_DEVICETYPE_PAD;
Ping Cheng42f4f272015-04-15 16:53:54 -07003048
Jason Gerecke4922cd22017-01-25 12:08:37 -08003049 if (features->type == INTUOSP2_BT) {
3050 features->device_type |= WACOM_DEVICETYPE_PEN |
3051 WACOM_DEVICETYPE_PAD |
3052 WACOM_DEVICETYPE_TOUCH;
3053 features->quirks |= WACOM_QUIRK_BATTERY;
3054 }
3055
Jason Gereckee5bc8eb2016-08-08 12:06:29 -07003056 switch (features->type) {
3057 case PL:
3058 case DTU:
3059 case DTUS:
3060 case DTUSX:
3061 case WACOM_21UX2:
3062 case WACOM_22HD:
3063 case DTK:
3064 case WACOM_24HD:
3065 case WACOM_27QHD:
3066 case CINTIQ_HYBRID:
3067 case CINTIQ_COMPANION_2:
3068 case CINTIQ:
3069 case WACOM_BEE:
3070 case WACOM_13HD:
3071 case WACOM_24HDT:
3072 case WACOM_27QHDT:
3073 case TABLETPC:
3074 case TABLETPCE:
3075 case TABLETPC2FG:
3076 case MTSCREEN:
3077 case MTTPC:
3078 case MTTPC_B:
3079 features->device_type |= WACOM_DEVICETYPE_DIRECT;
3080 break;
3081 }
3082
Ping Cheng42f4f272015-04-15 16:53:54 -07003083 if (wacom->hdev->bus == BUS_BLUETOOTH)
3084 features->quirks |= WACOM_QUIRK_BATTERY;
3085
Chris Bagwell73149ab2011-10-26 22:34:21 -07003086 /* quirk for bamboo touch with 2 low res touches */
Jason Gereckebe853fd2015-12-04 14:45:27 -08003087 if ((features->type == BAMBOO_PT || features->type == BAMBOO_TOUCH) &&
Chris Bagwell73149ab2011-10-26 22:34:21 -07003088 features->pktlen == WACOM_PKGLEN_BBTOUCH) {
Henrik Rydbergf4ccbef2010-09-05 12:57:13 -07003089 features->x_max <<= 5;
3090 features->y_max <<= 5;
3091 features->x_fuzz <<= 5;
3092 features->y_fuzz <<= 5;
Henrik Rydbergf4ccbef2010-09-05 12:57:13 -07003093 features->quirks |= WACOM_QUIRK_BBTOUCH_LOWRES;
Henrik Rydbergcb734c02010-09-05 12:53:16 -07003094 }
Chris Bagwelld3825d52012-03-25 23:26:11 -07003095
3096 if (features->type == WIRELESS) {
Jason Gereckeccad85c2015-08-03 10:17:04 -07003097 if (features->device_type == WACOM_DEVICETYPE_WL_MONITOR) {
Benjamin Tissoiresac8d1012014-07-25 17:29:48 -07003098 features->quirks |= WACOM_QUIRK_BATTERY;
3099 }
Chris Bagwelld3825d52012-03-25 23:26:11 -07003100 }
Benjamin Tissoires7c35dc32016-07-13 18:06:07 +02003101
3102 if (features->type == REMOTE)
3103 features->device_type |= WACOM_DEVICETYPE_WL_MONITOR;
Henrik Rydbergbc73dd32010-09-05 12:26:16 -07003104}
3105
Jason Gerecke2636a3f2015-06-15 18:01:44 -07003106int wacom_setup_pen_input_capabilities(struct input_dev *input_dev,
Ping Cheng19635182012-04-29 21:09:18 -07003107 struct wacom_wac *wacom_wac)
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -07003108{
3109 struct wacom_features *features = &wacom_wac->features;
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -07003110
3111 input_dev->evbit[0] |= BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS);
3112
Jason Gerecke2636a3f2015-06-15 18:01:44 -07003113 if (!(features->device_type & WACOM_DEVICETYPE_PEN))
3114 return -ENODEV;
3115
Jason Gereckee5bc8eb2016-08-08 12:06:29 -07003116 if (features->device_type & WACOM_DEVICETYPE_DIRECT)
3117 __set_bit(INPUT_PROP_DIRECT, input_dev->propbit);
3118 else
3119 __set_bit(INPUT_PROP_POINTER, input_dev->propbit);
3120
Benjamin Tissoires7704ac92014-09-23 12:08:08 -04003121 if (features->type == HID_GENERIC)
3122 /* setup has already been done */
3123 return 0;
3124
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -07003125 __set_bit(BTN_TOUCH, input_dev->keybit);
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -07003126 __set_bit(ABS_MISC, input_dev->absbit);
3127
Jason Gereckee779ef22016-10-19 18:03:49 -07003128 input_set_abs_params(input_dev, ABS_X, 0 + features->offset_left,
3129 features->x_max - features->offset_right,
3130 features->x_fuzz, 0);
3131 input_set_abs_params(input_dev, ABS_Y, 0 + features->offset_top,
3132 features->y_max - features->offset_bottom,
3133 features->y_fuzz, 0);
Jason Gerecke2636a3f2015-06-15 18:01:44 -07003134 input_set_abs_params(input_dev, ABS_PRESSURE, 0,
3135 features->pressure_max, features->pressure_fuzz, 0);
3136
3137 /* penabled devices have fixed resolution for each model */
3138 input_abs_set_res(input_dev, ABS_X, features->x_resolution);
3139 input_abs_set_res(input_dev, ABS_Y, features->y_resolution);
3140
Ping Cheng497ab1f2014-01-20 20:18:04 -08003141 switch (features->type) {
Ping Chenga2f71c62015-01-27 13:29:36 -08003142 case GRAPHIRE_BT:
3143 __clear_bit(ABS_MISC, input_dev->absbit);
3144
Dmitry Torokhov73a97f42010-03-19 22:18:15 -07003145 case WACOM_MO:
Dmitry Torokhov73a97f42010-03-19 22:18:15 -07003146 case WACOM_G4:
Ping Chenga2f71c62015-01-27 13:29:36 -08003147 input_set_abs_params(input_dev, ABS_DISTANCE, 0,
3148 features->distance_max,
Jason Gereckebef7e202016-04-22 14:30:53 -07003149 features->distance_fuzz, 0);
Dmitry Torokhov73a97f42010-03-19 22:18:15 -07003150 /* fall through */
3151
3152 case GRAPHIRE:
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -07003153 input_set_capability(input_dev, EV_REL, REL_WHEEL);
3154
3155 __set_bit(BTN_LEFT, input_dev->keybit);
3156 __set_bit(BTN_RIGHT, input_dev->keybit);
3157 __set_bit(BTN_MIDDLE, input_dev->keybit);
3158
3159 __set_bit(BTN_TOOL_RUBBER, input_dev->keybit);
3160 __set_bit(BTN_TOOL_PEN, input_dev->keybit);
3161 __set_bit(BTN_TOOL_MOUSE, input_dev->keybit);
3162 __set_bit(BTN_STYLUS, input_dev->keybit);
3163 __set_bit(BTN_STYLUS2, input_dev->keybit);
Dmitry Torokhov73a97f42010-03-19 22:18:15 -07003164 break;
3165
Ping Cheng500d4162015-01-27 13:30:03 -08003166 case WACOM_27QHD:
Jason Gerecke803296b2011-12-12 00:11:45 -08003167 case WACOM_24HD:
Ping Chenga112e9f2013-02-13 20:20:01 -08003168 case DTK:
Ping Chengd838c642012-07-24 23:54:11 -07003169 case WACOM_22HD:
Ping Cheng3a4b4aa2010-06-03 22:10:21 -07003170 case WACOM_21UX2:
Dmitry Torokhov73a97f42010-03-19 22:18:15 -07003171 case WACOM_BEE:
Ping Cheng6521d0b2010-10-24 21:53:40 -07003172 case CINTIQ:
Ping Cheng56218562013-05-05 19:56:18 -07003173 case WACOM_13HD:
Ping Chenga2f71c62015-01-27 13:29:36 -08003174 case CINTIQ_HYBRID:
Jason Gereckef7acb552015-10-13 10:03:49 -07003175 case CINTIQ_COMPANION_2:
Ping Cheng56218562013-05-05 19:56:18 -07003176 input_set_abs_params(input_dev, ABS_Z, -900, 899, 0, 0);
Jason Gerecke26fe4122014-11-18 16:50:09 -08003177 input_abs_set_res(input_dev, ABS_Z, 287);
Ping Cheng56218562013-05-05 19:56:18 -07003178 wacom_setup_cintiq(wacom_wac);
3179 break;
3180
Dmitry Torokhov73a97f42010-03-19 22:18:15 -07003181 case INTUOS3:
3182 case INTUOS3L:
Dmitry Torokhov73a97f42010-03-19 22:18:15 -07003183 case INTUOS3S:
Ping Chenga2f71c62015-01-27 13:29:36 -08003184 case INTUOS4:
3185 case INTUOS4WL:
3186 case INTUOS4L:
3187 case INTUOS4S:
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -07003188 input_set_abs_params(input_dev, ABS_Z, -900, 899, 0, 0);
Jason Gerecke26fe4122014-11-18 16:50:09 -08003189 input_abs_set_res(input_dev, ABS_Z, 287);
Dmitry Torokhov73a97f42010-03-19 22:18:15 -07003190 /* fall through */
3191
3192 case INTUOS:
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -07003193 wacom_setup_intuos(wacom_wac);
Dmitry Torokhov73a97f42010-03-19 22:18:15 -07003194 break;
3195
Jason Gerecke9fee6192012-04-03 15:47:22 -07003196 case INTUOS5:
3197 case INTUOS5L:
Ping Cheng9a35c412013-09-20 09:51:56 -07003198 case INTUOSPM:
3199 case INTUOSPL:
Jason Gereckeae584ca2012-04-03 15:50:40 -07003200 case INTUOS5S:
Ping Cheng9a35c412013-09-20 09:51:56 -07003201 case INTUOSPS:
Jason Gerecke4922cd22017-01-25 12:08:37 -08003202 case INTUOSP2_BT:
Jason Gerecke2636a3f2015-06-15 18:01:44 -07003203 input_set_abs_params(input_dev, ABS_DISTANCE, 0,
3204 features->distance_max,
Jason Gereckebef7e202016-04-22 14:30:53 -07003205 features->distance_fuzz, 0);
Jason Gereckeae584ca2012-04-03 15:50:40 -07003206
Jason Gerecke2636a3f2015-06-15 18:01:44 -07003207 input_set_abs_params(input_dev, ABS_Z, -900, 899, 0, 0);
3208 input_abs_set_res(input_dev, ABS_Z, 287);
Jason Gereckeae584ca2012-04-03 15:50:40 -07003209
Jason Gerecke2636a3f2015-06-15 18:01:44 -07003210 wacom_setup_intuos(wacom_wac);
Jason Gereckeae584ca2012-04-03 15:50:40 -07003211 break;
3212
Jason Gereckeb1e42792012-10-21 00:38:04 -07003213 case WACOM_24HDT:
Ping Cheng500d4162015-01-27 13:30:03 -08003214 case WACOM_27QHDT:
Ping Cheng19635182012-04-29 21:09:18 -07003215 case MTSCREEN:
Ping Cheng6afdc282012-11-03 12:16:15 -07003216 case MTTPC:
Jason Gerecked51ddb22014-05-14 17:14:29 -07003217 case MTTPC_B:
Ping Cheng6795a522012-06-28 16:49:00 -07003218 case TABLETPC2FG:
Dmitry Torokhov73a97f42010-03-19 22:18:15 -07003219 case TABLETPC:
Ping Chengac173832012-06-12 00:15:06 -07003220 case TABLETPCE:
Ping Chenga43c7c52011-03-12 20:34:42 -08003221 __clear_bit(ABS_MISC, input_dev->absbit);
Dmitry Torokhov73a97f42010-03-19 22:18:15 -07003222 /* fall through */
3223
Ping Cheng497ab1f2014-01-20 20:18:04 -08003224 case DTUS:
Ping Chengfff00bf2014-12-04 18:23:04 -08003225 case DTUSX:
Dmitry Torokhov73a97f42010-03-19 22:18:15 -07003226 case PL:
Ping Chengc8f2edc2010-06-28 01:10:51 -07003227 case DTU:
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -07003228 __set_bit(BTN_TOOL_PEN, input_dev->keybit);
Jason Gerecke35120692011-09-08 09:38:14 -07003229 __set_bit(BTN_TOOL_RUBBER, input_dev->keybit);
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -07003230 __set_bit(BTN_STYLUS, input_dev->keybit);
3231 __set_bit(BTN_STYLUS2, input_dev->keybit);
Jason Gerecke35120692011-09-08 09:38:14 -07003232 break;
3233
3234 case PTU:
Dmitry Torokhov73a97f42010-03-19 22:18:15 -07003235 __set_bit(BTN_STYLUS2, input_dev->keybit);
3236 /* fall through */
3237
3238 case PENPARTNER:
Jason Gerecke1fab84a2011-08-26 23:18:22 -07003239 __set_bit(BTN_TOOL_PEN, input_dev->keybit);
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -07003240 __set_bit(BTN_TOOL_RUBBER, input_dev->keybit);
Jason Gerecke1fab84a2011-08-26 23:18:22 -07003241 __set_bit(BTN_STYLUS, input_dev->keybit);
Dmitry Torokhov73a97f42010-03-19 22:18:15 -07003242 break;
Henrik Rydbergcb734c02010-09-05 12:53:16 -07003243
Ping Chengb5fd2a32013-11-25 18:44:55 -08003244 case INTUOSHT:
Henrik Rydbergcb734c02010-09-05 12:53:16 -07003245 case BAMBOO_PT:
Ping Cheng3b164a02015-09-23 09:59:10 -07003246 case BAMBOO_PEN:
Ping Chengeda01da2015-09-23 13:51:15 -07003247 case INTUOSHT2:
Ping Chengeda01da2015-09-23 13:51:15 -07003248 if (features->type == INTUOSHT2) {
3249 wacom_setup_basic_pro_pen(wacom_wac);
3250 } else {
3251 __clear_bit(ABS_MISC, input_dev->absbit);
3252 __set_bit(BTN_TOOL_PEN, input_dev->keybit);
3253 __set_bit(BTN_TOOL_RUBBER, input_dev->keybit);
3254 __set_bit(BTN_STYLUS, input_dev->keybit);
3255 __set_bit(BTN_STYLUS2, input_dev->keybit);
3256 input_set_abs_params(input_dev, ABS_DISTANCE, 0,
Jason Gerecke2636a3f2015-06-15 18:01:44 -07003257 features->distance_max,
Jason Gereckebef7e202016-04-22 14:30:53 -07003258 features->distance_fuzz, 0);
Ping Chengeda01da2015-09-23 13:51:15 -07003259 }
Henrik Rydbergcb734c02010-09-05 12:53:16 -07003260 break;
Benjamin Tissoires8c97a762015-02-26 11:28:50 -05003261 case BAMBOO_PAD:
3262 __clear_bit(ABS_MISC, input_dev->absbit);
Jason Gerecke2636a3f2015-06-15 18:01:44 -07003263 break;
3264 }
3265 return 0;
3266}
3267
3268int wacom_setup_touch_input_capabilities(struct input_dev *input_dev,
3269 struct wacom_wac *wacom_wac)
3270{
3271 struct wacom_features *features = &wacom_wac->features;
3272
3273 input_dev->evbit[0] |= BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS);
3274
3275 if (!(features->device_type & WACOM_DEVICETYPE_TOUCH))
3276 return -ENODEV;
3277
Jason Gereckee5bc8eb2016-08-08 12:06:29 -07003278 if (features->device_type & WACOM_DEVICETYPE_DIRECT)
3279 __set_bit(INPUT_PROP_DIRECT, input_dev->propbit);
3280 else
3281 __set_bit(INPUT_PROP_POINTER, input_dev->propbit);
3282
Jason Gerecke2636a3f2015-06-15 18:01:44 -07003283 if (features->type == HID_GENERIC)
3284 /* setup has already been done */
3285 return 0;
3286
3287 __set_bit(BTN_TOUCH, input_dev->keybit);
3288
3289 if (features->touch_max == 1) {
3290 input_set_abs_params(input_dev, ABS_X, 0,
3291 features->x_max, features->x_fuzz, 0);
3292 input_set_abs_params(input_dev, ABS_Y, 0,
3293 features->y_max, features->y_fuzz, 0);
3294 input_abs_set_res(input_dev, ABS_X,
3295 features->x_resolution);
3296 input_abs_set_res(input_dev, ABS_Y,
3297 features->y_resolution);
3298 }
3299 else if (features->touch_max > 1) {
3300 input_set_abs_params(input_dev, ABS_MT_POSITION_X, 0,
3301 features->x_max, features->x_fuzz, 0);
3302 input_set_abs_params(input_dev, ABS_MT_POSITION_Y, 0,
3303 features->y_max, features->y_fuzz, 0);
3304 input_abs_set_res(input_dev, ABS_MT_POSITION_X,
3305 features->x_resolution);
3306 input_abs_set_res(input_dev, ABS_MT_POSITION_Y,
3307 features->y_resolution);
3308 }
3309
3310 switch (features->type) {
Jason Gerecke4922cd22017-01-25 12:08:37 -08003311 case INTUOSP2_BT:
3312 input_dev->evbit[0] |= BIT_MASK(EV_SW);
3313 __set_bit(SW_MUTE_DEVICE, input_dev->swbit);
3314
3315 if (wacom_wac->shared->touch->product == 0x361) {
3316 input_set_abs_params(input_dev, ABS_MT_POSITION_X,
3317 0, 12440, 4, 0);
3318 input_set_abs_params(input_dev, ABS_MT_POSITION_Y,
3319 0, 8640, 4, 0);
3320 }
3321 else if (wacom_wac->shared->touch->product == 0x360) {
3322 input_set_abs_params(input_dev, ABS_MT_POSITION_X,
3323 0, 8960, 4, 0);
3324 input_set_abs_params(input_dev, ABS_MT_POSITION_Y,
3325 0, 5920, 4, 0);
3326 }
3327 input_abs_set_res(input_dev, ABS_MT_POSITION_X, 40);
3328 input_abs_set_res(input_dev, ABS_MT_POSITION_X, 40);
3329
3330 /* fall through */
3331
Jason Gerecke2636a3f2015-06-15 18:01:44 -07003332 case INTUOS5:
3333 case INTUOS5L:
3334 case INTUOSPM:
3335 case INTUOSPL:
3336 case INTUOS5S:
3337 case INTUOSPS:
Jason Gerecke2636a3f2015-06-15 18:01:44 -07003338 input_set_abs_params(input_dev, ABS_MT_TOUCH_MAJOR, 0, features->x_max, 0, 0);
3339 input_set_abs_params(input_dev, ABS_MT_TOUCH_MINOR, 0, features->y_max, 0, 0);
3340 input_mt_init_slots(input_dev, features->touch_max, INPUT_MT_POINTER);
3341 break;
3342
3343 case WACOM_24HDT:
3344 input_set_abs_params(input_dev, ABS_MT_TOUCH_MAJOR, 0, features->x_max, 0, 0);
3345 input_set_abs_params(input_dev, ABS_MT_WIDTH_MAJOR, 0, features->x_max, 0, 0);
3346 input_set_abs_params(input_dev, ABS_MT_WIDTH_MINOR, 0, features->y_max, 0, 0);
3347 input_set_abs_params(input_dev, ABS_MT_ORIENTATION, 0, 1, 0, 0);
3348 /* fall through */
3349
3350 case WACOM_27QHDT:
3351 case MTSCREEN:
3352 case MTTPC:
3353 case MTTPC_B:
3354 case TABLETPC2FG:
3355 input_mt_init_slots(input_dev, features->touch_max, INPUT_MT_DIRECT);
3356 /*fall through */
3357
3358 case TABLETPC:
3359 case TABLETPCE:
Jason Gerecke2636a3f2015-06-15 18:01:44 -07003360 break;
3361
3362 case INTUOSHT:
Ping Chengeda01da2015-09-23 13:51:15 -07003363 case INTUOSHT2:
Jason Gerecke2636a3f2015-06-15 18:01:44 -07003364 input_dev->evbit[0] |= BIT_MASK(EV_SW);
3365 __set_bit(SW_MUTE_DEVICE, input_dev->swbit);
3366 /* fall through */
3367
3368 case BAMBOO_PT:
Ping Cheng3b164a02015-09-23 09:59:10 -07003369 case BAMBOO_TOUCH:
Jason Gerecke2636a3f2015-06-15 18:01:44 -07003370 if (features->pktlen == WACOM_PKGLEN_BBTOUCH3) {
3371 input_set_abs_params(input_dev,
3372 ABS_MT_TOUCH_MAJOR,
3373 0, features->x_max, 0, 0);
3374 input_set_abs_params(input_dev,
3375 ABS_MT_TOUCH_MINOR,
3376 0, features->y_max, 0, 0);
3377 }
3378 input_mt_init_slots(input_dev, features->touch_max, INPUT_MT_POINTER);
3379 break;
3380
3381 case BAMBOO_PAD:
Benjamin Tissoires8c97a762015-02-26 11:28:50 -05003382 input_mt_init_slots(input_dev, features->touch_max,
3383 INPUT_MT_POINTER);
3384 __set_bit(BTN_LEFT, input_dev->keybit);
3385 __set_bit(BTN_RIGHT, input_dev->keybit);
3386 break;
Ping Cheng3bea7332006-07-13 18:01:36 -07003387 }
Ping Cheng19635182012-04-29 21:09:18 -07003388 return 0;
Ping Cheng3bea7332006-07-13 18:01:36 -07003389}
3390
Jason Gerecke49005b92016-10-19 18:03:39 -07003391static int wacom_numbered_button_to_key(int n)
3392{
3393 if (n < 10)
3394 return BTN_0 + n;
3395 else if (n < 16)
3396 return BTN_A + (n-10);
3397 else if (n < 18)
3398 return BTN_BASE + (n-16);
3399 else
3400 return 0;
3401}
3402
Jiri Kosina5397df12015-08-28 20:46:42 +02003403static void wacom_setup_numbered_buttons(struct input_dev *input_dev,
Aaron Skomra70ee06c2015-08-20 16:05:16 -07003404 int button_count)
3405{
3406 int i;
3407
Jason Gerecke49005b92016-10-19 18:03:39 -07003408 for (i = 0; i < button_count; i++) {
3409 int key = wacom_numbered_button_to_key(i);
3410
3411 if (key)
3412 __set_bit(key, input_dev->keybit);
3413 }
Aaron Skomra70ee06c2015-08-20 16:05:16 -07003414}
3415
Benjamin Tissoires6a062812016-07-13 18:06:14 +02003416static void wacom_24hd_update_leds(struct wacom *wacom, int mask, int group)
3417{
3418 struct wacom_led *led;
3419 int i;
3420 bool updated = false;
3421
3422 /*
3423 * 24HD has LED group 1 to the left and LED group 0 to the right.
3424 * So group 0 matches the second half of the buttons and thus the mask
3425 * needs to be shifted.
3426 */
3427 if (group == 0)
3428 mask >>= 8;
3429
3430 for (i = 0; i < 3; i++) {
3431 led = wacom_led_find(wacom, group, i);
3432 if (!led) {
3433 hid_err(wacom->hdev, "can't find LED %d in group %d\n",
3434 i, group);
3435 continue;
3436 }
3437 if (!updated && mask & BIT(i)) {
3438 led->held = true;
3439 led_trigger_event(&led->trigger, LED_FULL);
3440 } else {
3441 led->held = false;
3442 }
3443 }
3444}
3445
Benjamin Tissoires34736aa2016-07-13 18:06:12 +02003446static bool wacom_is_led_toggled(struct wacom *wacom, int button_count,
3447 int mask, int group)
3448{
3449 int button_per_group;
3450
Benjamin Tissoires5a0fe8ab2016-07-13 18:06:13 +02003451 /*
Benjamin Tissoires6a062812016-07-13 18:06:14 +02003452 * 21UX2 has LED group 1 to the left and LED group 0
Benjamin Tissoires5a0fe8ab2016-07-13 18:06:13 +02003453 * to the right. We need to reverse the group to match this
3454 * historical behavior.
3455 */
Benjamin Tissoires6a062812016-07-13 18:06:14 +02003456 if (wacom->wacom_wac.features.type == WACOM_21UX2)
Benjamin Tissoires5a0fe8ab2016-07-13 18:06:13 +02003457 group = 1 - group;
3458
Benjamin Tissoires34736aa2016-07-13 18:06:12 +02003459 button_per_group = button_count/wacom->led.count;
3460
3461 return mask & (1 << (group * button_per_group));
3462}
3463
3464static void wacom_update_led(struct wacom *wacom, int button_count, int mask,
3465 int group)
3466{
3467 struct wacom_led *led, *next_led;
3468 int cur;
3469 bool pressed;
3470
Benjamin Tissoires6a062812016-07-13 18:06:14 +02003471 if (wacom->wacom_wac.features.type == WACOM_24HD)
3472 return wacom_24hd_update_leds(wacom, mask, group);
3473
Benjamin Tissoires34736aa2016-07-13 18:06:12 +02003474 pressed = wacom_is_led_toggled(wacom, button_count, mask, group);
3475 cur = wacom->led.groups[group].select;
3476
3477 led = wacom_led_find(wacom, group, cur);
3478 if (!led) {
3479 hid_err(wacom->hdev, "can't find current LED %d in group %d\n",
3480 cur, group);
3481 return;
3482 }
3483
3484 if (!pressed) {
3485 led->held = false;
3486 return;
3487 }
3488
3489 if (led->held && pressed)
3490 return;
3491
3492 next_led = wacom_led_next(wacom, led);
3493 if (!next_led) {
3494 hid_err(wacom->hdev, "can't find next LED in group %d\n",
3495 group);
3496 return;
3497 }
3498 if (next_led == led)
3499 return;
3500
3501 next_led->held = true;
3502 led_trigger_event(&next_led->trigger,
3503 wacom_leds_brightness_get(next_led));
3504}
3505
Jason Gereckec7f05222015-11-30 17:13:47 -08003506static void wacom_report_numbered_buttons(struct input_dev *input_dev,
3507 int button_count, int mask)
3508{
Benjamin Tissoires34736aa2016-07-13 18:06:12 +02003509 struct wacom *wacom = input_get_drvdata(input_dev);
Jason Gereckec7f05222015-11-30 17:13:47 -08003510 int i;
3511
Benjamin Tissoires34736aa2016-07-13 18:06:12 +02003512 for (i = 0; i < wacom->led.count; i++)
3513 wacom_update_led(wacom, button_count, mask, i);
3514
Jason Gerecke49005b92016-10-19 18:03:39 -07003515 for (i = 0; i < button_count; i++) {
3516 int key = wacom_numbered_button_to_key(i);
3517
3518 if (key)
3519 input_report_key(input_dev, key, mask & (1 << i));
3520 }
Jason Gereckec7f05222015-11-30 17:13:47 -08003521}
3522
Benjamin Tissoiresd2d13f12014-07-24 12:48:28 -07003523int wacom_setup_pad_input_capabilities(struct input_dev *input_dev,
3524 struct wacom_wac *wacom_wac)
3525{
3526 struct wacom_features *features = &wacom_wac->features;
3527
Ping Chenge7deb152017-01-30 15:40:49 -08003528 if ((features->type == HID_GENERIC) && features->numbered_buttons > 0)
3529 features->device_type |= WACOM_DEVICETYPE_PAD;
3530
Jason Gerecke862cf552015-06-15 18:01:43 -07003531 if (!(features->device_type & WACOM_DEVICETYPE_PAD))
3532 return -ENODEV;
3533
Benjamin Tissoires7c35dc32016-07-13 18:06:07 +02003534 if (features->type == REMOTE && input_dev == wacom_wac->pad_input)
3535 return -ENODEV;
3536
Benjamin Tissoiresd2d13f12014-07-24 12:48:28 -07003537 input_dev->evbit[0] |= BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS);
3538
3539 /* kept for making legacy xf86-input-wacom working with the wheels */
3540 __set_bit(ABS_MISC, input_dev->absbit);
3541
3542 /* kept for making legacy xf86-input-wacom accepting the pad */
Jason Gerecke5922e612016-10-19 18:03:51 -07003543 if (!(input_dev->absinfo && (input_dev->absinfo[ABS_X].minimum ||
3544 input_dev->absinfo[ABS_X].maximum)))
3545 input_set_abs_params(input_dev, ABS_X, 0, 1, 0, 0);
3546 if (!(input_dev->absinfo && (input_dev->absinfo[ABS_Y].minimum ||
3547 input_dev->absinfo[ABS_Y].maximum)))
3548 input_set_abs_params(input_dev, ABS_Y, 0, 1, 0, 0);
Benjamin Tissoiresd2d13f12014-07-24 12:48:28 -07003549
Benjamin Tissoires12969e32014-09-11 13:14:04 -04003550 /* kept for making udev and libwacom accepting the pad */
3551 __set_bit(BTN_STYLUS, input_dev->keybit);
3552
Aaron Skomra70ee06c2015-08-20 16:05:16 -07003553 wacom_setup_numbered_buttons(input_dev, features->numbered_buttons);
3554
Benjamin Tissoiresd2d13f12014-07-24 12:48:28 -07003555 switch (features->type) {
Aaron Skomra70ee06c2015-08-20 16:05:16 -07003556
3557 case CINTIQ_HYBRID:
Jason Gereckef7acb552015-10-13 10:03:49 -07003558 case CINTIQ_COMPANION_2:
Aaron Skomra70ee06c2015-08-20 16:05:16 -07003559 case DTK:
3560 case DTUS:
Benjamin Tissoires387142b2014-08-06 13:52:56 -07003561 case GRAPHIRE_BT:
Benjamin Tissoires387142b2014-08-06 13:52:56 -07003562 break;
3563
Benjamin Tissoires38138102014-07-24 12:51:03 -07003564 case WACOM_MO:
3565 __set_bit(BTN_BACK, input_dev->keybit);
3566 __set_bit(BTN_LEFT, input_dev->keybit);
3567 __set_bit(BTN_FORWARD, input_dev->keybit);
3568 __set_bit(BTN_RIGHT, input_dev->keybit);
3569 input_set_abs_params(input_dev, ABS_WHEEL, 0, 71, 0, 0);
3570 break;
3571
3572 case WACOM_G4:
3573 __set_bit(BTN_BACK, input_dev->keybit);
Benjamin Tissoires38138102014-07-24 12:51:03 -07003574 __set_bit(BTN_FORWARD, input_dev->keybit);
Benjamin Tissoires38138102014-07-24 12:51:03 -07003575 input_set_capability(input_dev, EV_REL, REL_WHEEL);
3576 break;
3577
Benjamin Tissoires10059cdc2014-07-24 12:49:08 -07003578 case WACOM_24HD:
Benjamin Tissoires10059cdc2014-07-24 12:49:08 -07003579 __set_bit(KEY_PROG1, input_dev->keybit);
3580 __set_bit(KEY_PROG2, input_dev->keybit);
3581 __set_bit(KEY_PROG3, input_dev->keybit);
3582
3583 input_set_abs_params(input_dev, ABS_WHEEL, 0, 71, 0, 0);
3584 input_set_abs_params(input_dev, ABS_THROTTLE, 0, 71, 0, 0);
3585 break;
3586
Ping Cheng500d4162015-01-27 13:30:03 -08003587 case WACOM_27QHD:
3588 __set_bit(KEY_PROG1, input_dev->keybit);
3589 __set_bit(KEY_PROG2, input_dev->keybit);
3590 __set_bit(KEY_PROG3, input_dev->keybit);
3591 input_set_abs_params(input_dev, ABS_X, -2048, 2048, 0, 0);
3592 input_abs_set_res(input_dev, ABS_X, 1024); /* points/g */
3593 input_set_abs_params(input_dev, ABS_Y, -2048, 2048, 0, 0);
3594 input_abs_set_res(input_dev, ABS_Y, 1024);
3595 input_set_abs_params(input_dev, ABS_Z, -2048, 2048, 0, 0);
3596 input_abs_set_res(input_dev, ABS_Z, 1024);
3597 __set_bit(INPUT_PROP_ACCELEROMETER, input_dev->propbit);
3598 break;
3599
Benjamin Tissoires10059cdc2014-07-24 12:49:08 -07003600 case WACOM_22HD:
3601 __set_bit(KEY_PROG1, input_dev->keybit);
3602 __set_bit(KEY_PROG2, input_dev->keybit);
3603 __set_bit(KEY_PROG3, input_dev->keybit);
3604 /* fall through */
3605
3606 case WACOM_21UX2:
Benjamin Tissoires10059cdc2014-07-24 12:49:08 -07003607 case WACOM_BEE:
Benjamin Tissoires10059cdc2014-07-24 12:49:08 -07003608 case CINTIQ:
Benjamin Tissoires10059cdc2014-07-24 12:49:08 -07003609 input_set_abs_params(input_dev, ABS_RX, 0, 4096, 0, 0);
3610 input_set_abs_params(input_dev, ABS_RY, 0, 4096, 0, 0);
3611 break;
3612
3613 case WACOM_13HD:
Benjamin Tissoires10059cdc2014-07-24 12:49:08 -07003614 input_set_abs_params(input_dev, ABS_WHEEL, 0, 71, 0, 0);
3615 break;
3616
3617 case INTUOS3:
3618 case INTUOS3L:
Benjamin Tissoires10059cdc2014-07-24 12:49:08 -07003619 input_set_abs_params(input_dev, ABS_RY, 0, 4096, 0, 0);
3620 /* fall through */
3621
3622 case INTUOS3S:
Benjamin Tissoires10059cdc2014-07-24 12:49:08 -07003623 input_set_abs_params(input_dev, ABS_RX, 0, 4096, 0, 0);
3624 break;
3625
3626 case INTUOS5:
3627 case INTUOS5L:
3628 case INTUOSPM:
3629 case INTUOSPL:
Benjamin Tissoires10059cdc2014-07-24 12:49:08 -07003630 case INTUOS5S:
3631 case INTUOSPS:
Jason Gerecke4922cd22017-01-25 12:08:37 -08003632 case INTUOSP2_BT:
Benjamin Tissoires10059cdc2014-07-24 12:49:08 -07003633 input_set_abs_params(input_dev, ABS_WHEEL, 0, 71, 0, 0);
3634 break;
3635
Benjamin Tissoires81af7e62014-08-06 13:55:56 -07003636 case INTUOS4WL:
3637 /*
3638 * For Bluetooth devices, the udev rule does not work correctly
3639 * for pads unless we add a stylus capability, which forces
3640 * ID_INPUT_TABLET to be set.
3641 */
3642 __set_bit(BTN_STYLUS, input_dev->keybit);
3643 /* fall through */
3644
Benjamin Tissoires10059cdc2014-07-24 12:49:08 -07003645 case INTUOS4:
3646 case INTUOS4L:
Benjamin Tissoires10059cdc2014-07-24 12:49:08 -07003647 case INTUOS4S:
Benjamin Tissoires10059cdc2014-07-24 12:49:08 -07003648 input_set_abs_params(input_dev, ABS_WHEEL, 0, 71, 0, 0);
3649 break;
3650
Benjamin Tissoires31168712014-07-24 12:50:10 -07003651 case INTUOSHT:
3652 case BAMBOO_PT:
Ping Cheng3b164a02015-09-23 09:59:10 -07003653 case BAMBOO_TOUCH:
Ping Chengeda01da2015-09-23 13:51:15 -07003654 case INTUOSHT2:
Benjamin Tissoires31168712014-07-24 12:50:10 -07003655 __clear_bit(ABS_MISC, input_dev->absbit);
3656
3657 __set_bit(BTN_LEFT, input_dev->keybit);
3658 __set_bit(BTN_FORWARD, input_dev->keybit);
3659 __set_bit(BTN_BACK, input_dev->keybit);
3660 __set_bit(BTN_RIGHT, input_dev->keybit);
3661
3662 break;
3663
Aaron Skomra72b236d2015-08-20 16:05:17 -07003664 case REMOTE:
3665 input_set_capability(input_dev, EV_MSC, MSC_SERIAL);
3666 input_set_abs_params(input_dev, ABS_WHEEL, 0, 71, 0, 0);
3667 break;
3668
Jason Gerecke5922e612016-10-19 18:03:51 -07003669 case HID_GENERIC:
3670 break;
3671
Benjamin Tissoiresd2d13f12014-07-24 12:48:28 -07003672 default:
3673 /* no pad supported */
Ping Chengb3c8e932014-11-18 13:27:48 -08003674 return -ENODEV;
Benjamin Tissoiresd2d13f12014-07-24 12:48:28 -07003675 }
3676 return 0;
3677}
3678
Dmitry Torokhove87a3442010-02-18 01:51:47 -08003679static const struct wacom_features wacom_features_0x00 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003680 { "Wacom Penpartner", 5040, 3780, 255, 0,
3681 PENPARTNER, WACOM_PENPRTN_RES, WACOM_PENPRTN_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08003682static const struct wacom_features wacom_features_0x10 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003683 { "Wacom Graphire", 10206, 7422, 511, 63,
3684 GRAPHIRE, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
Benjamin Tissoires387142b2014-08-06 13:52:56 -07003685static const struct wacom_features wacom_features_0x81 =
3686 { "Wacom Graphire BT", 16704, 12064, 511, 32,
Aaron Skomra70ee06c2015-08-20 16:05:16 -07003687 GRAPHIRE_BT, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES, 2 };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08003688static const struct wacom_features wacom_features_0x11 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003689 { "Wacom Graphire2 4x5", 10206, 7422, 511, 63,
3690 GRAPHIRE, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08003691static const struct wacom_features wacom_features_0x12 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003692 { "Wacom Graphire2 5x7", 13918, 10206, 511, 63,
3693 GRAPHIRE, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08003694static const struct wacom_features wacom_features_0x13 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003695 { "Wacom Graphire3", 10208, 7424, 511, 63,
3696 GRAPHIRE, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08003697static const struct wacom_features wacom_features_0x14 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003698 { "Wacom Graphire3 6x8", 16704, 12064, 511, 63,
3699 GRAPHIRE, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08003700static const struct wacom_features wacom_features_0x15 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003701 { "Wacom Graphire4 4x5", 10208, 7424, 511, 63,
3702 WACOM_G4, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08003703static const struct wacom_features wacom_features_0x16 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003704 { "Wacom Graphire4 6x8", 16704, 12064, 511, 63,
3705 WACOM_G4, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08003706static const struct wacom_features wacom_features_0x17 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003707 { "Wacom BambooFun 4x5", 14760, 9225, 511, 63,
3708 WACOM_MO, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08003709static const struct wacom_features wacom_features_0x18 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003710 { "Wacom BambooFun 6x8", 21648, 13530, 511, 63,
3711 WACOM_MO, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08003712static const struct wacom_features wacom_features_0x19 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003713 { "Wacom Bamboo1 Medium", 16704, 12064, 511, 63,
3714 GRAPHIRE, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08003715static const struct wacom_features wacom_features_0x60 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003716 { "Wacom Volito", 5104, 3712, 511, 63,
3717 GRAPHIRE, WACOM_VOLITO_RES, WACOM_VOLITO_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08003718static const struct wacom_features wacom_features_0x61 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003719 { "Wacom PenStation2", 3250, 2320, 255, 63,
3720 GRAPHIRE, WACOM_VOLITO_RES, WACOM_VOLITO_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08003721static const struct wacom_features wacom_features_0x62 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003722 { "Wacom Volito2 4x5", 5104, 3712, 511, 63,
3723 GRAPHIRE, WACOM_VOLITO_RES, WACOM_VOLITO_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08003724static const struct wacom_features wacom_features_0x63 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003725 { "Wacom Volito2 2x3", 3248, 2320, 511, 63,
3726 GRAPHIRE, WACOM_VOLITO_RES, WACOM_VOLITO_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08003727static const struct wacom_features wacom_features_0x64 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003728 { "Wacom PenPartner2", 3250, 2320, 511, 63,
3729 GRAPHIRE, WACOM_VOLITO_RES, WACOM_VOLITO_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08003730static const struct wacom_features wacom_features_0x65 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003731 { "Wacom Bamboo", 14760, 9225, 511, 63,
3732 WACOM_MO, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08003733static const struct wacom_features wacom_features_0x69 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003734 { "Wacom Bamboo1", 5104, 3712, 511, 63,
3735 GRAPHIRE, WACOM_PENPRTN_RES, WACOM_PENPRTN_RES };
Ping Cheng11d0cf82011-06-27 12:57:58 -07003736static const struct wacom_features wacom_features_0x6A =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003737 { "Wacom Bamboo1 4x6", 14760, 9225, 1023, 63,
3738 GRAPHIRE, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Ping Cheng11d0cf82011-06-27 12:57:58 -07003739static const struct wacom_features wacom_features_0x6B =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003740 { "Wacom Bamboo1 5x8", 21648, 13530, 1023, 63,
3741 GRAPHIRE, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08003742static const struct wacom_features wacom_features_0x20 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003743 { "Wacom Intuos 4x5", 12700, 10600, 1023, 31,
3744 INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08003745static const struct wacom_features wacom_features_0x21 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003746 { "Wacom Intuos 6x8", 20320, 16240, 1023, 31,
3747 INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08003748static const struct wacom_features wacom_features_0x22 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003749 { "Wacom Intuos 9x12", 30480, 24060, 1023, 31,
3750 INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08003751static const struct wacom_features wacom_features_0x23 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003752 { "Wacom Intuos 12x12", 30480, 31680, 1023, 31,
3753 INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08003754static const struct wacom_features wacom_features_0x24 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003755 { "Wacom Intuos 12x18", 45720, 31680, 1023, 31,
3756 INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08003757static const struct wacom_features wacom_features_0x30 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003758 { "Wacom PL400", 5408, 4056, 255, 0,
3759 PL, WACOM_PL_RES, WACOM_PL_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08003760static const struct wacom_features wacom_features_0x31 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003761 { "Wacom PL500", 6144, 4608, 255, 0,
3762 PL, WACOM_PL_RES, WACOM_PL_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08003763static const struct wacom_features wacom_features_0x32 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003764 { "Wacom PL600", 6126, 4604, 255, 0,
3765 PL, WACOM_PL_RES, WACOM_PL_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08003766static const struct wacom_features wacom_features_0x33 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003767 { "Wacom PL600SX", 6260, 5016, 255, 0,
3768 PL, WACOM_PL_RES, WACOM_PL_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08003769static const struct wacom_features wacom_features_0x34 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003770 { "Wacom PL550", 6144, 4608, 511, 0,
3771 PL, WACOM_PL_RES, WACOM_PL_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08003772static const struct wacom_features wacom_features_0x35 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003773 { "Wacom PL800", 7220, 5780, 511, 0,
3774 PL, WACOM_PL_RES, WACOM_PL_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08003775static const struct wacom_features wacom_features_0x37 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003776 { "Wacom PL700", 6758, 5406, 511, 0,
3777 PL, WACOM_PL_RES, WACOM_PL_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08003778static const struct wacom_features wacom_features_0x38 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003779 { "Wacom PL510", 6282, 4762, 511, 0,
3780 PL, WACOM_PL_RES, WACOM_PL_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08003781static const struct wacom_features wacom_features_0x39 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003782 { "Wacom DTU710", 34080, 27660, 511, 0,
3783 PL, WACOM_PL_RES, WACOM_PL_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08003784static const struct wacom_features wacom_features_0xC4 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003785 { "Wacom DTF521", 6282, 4762, 511, 0,
3786 PL, WACOM_PL_RES, WACOM_PL_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08003787static const struct wacom_features wacom_features_0xC0 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003788 { "Wacom DTF720", 6858, 5506, 511, 0,
3789 PL, WACOM_PL_RES, WACOM_PL_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08003790static const struct wacom_features wacom_features_0xC2 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003791 { "Wacom DTF720a", 6858, 5506, 511, 0,
3792 PL, WACOM_PL_RES, WACOM_PL_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08003793static const struct wacom_features wacom_features_0x03 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003794 { "Wacom Cintiq Partner", 20480, 15360, 511, 0,
3795 PTU, WACOM_PL_RES, WACOM_PL_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08003796static const struct wacom_features wacom_features_0x41 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003797 { "Wacom Intuos2 4x5", 12700, 10600, 1023, 31,
3798 INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08003799static const struct wacom_features wacom_features_0x42 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003800 { "Wacom Intuos2 6x8", 20320, 16240, 1023, 31,
3801 INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08003802static const struct wacom_features wacom_features_0x43 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003803 { "Wacom Intuos2 9x12", 30480, 24060, 1023, 31,
3804 INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08003805static const struct wacom_features wacom_features_0x44 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003806 { "Wacom Intuos2 12x12", 30480, 31680, 1023, 31,
3807 INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08003808static const struct wacom_features wacom_features_0x45 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003809 { "Wacom Intuos2 12x18", 45720, 31680, 1023, 31,
3810 INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08003811static const struct wacom_features wacom_features_0xB0 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003812 { "Wacom Intuos3 4x5", 25400, 20320, 1023, 63,
Aaron Skomra70ee06c2015-08-20 16:05:16 -07003813 INTUOS3S, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 4 };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08003814static const struct wacom_features wacom_features_0xB1 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003815 { "Wacom Intuos3 6x8", 40640, 30480, 1023, 63,
Aaron Skomra70ee06c2015-08-20 16:05:16 -07003816 INTUOS3, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 8 };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08003817static const struct wacom_features wacom_features_0xB2 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003818 { "Wacom Intuos3 9x12", 60960, 45720, 1023, 63,
Aaron Skomra70ee06c2015-08-20 16:05:16 -07003819 INTUOS3, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 8 };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08003820static const struct wacom_features wacom_features_0xB3 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003821 { "Wacom Intuos3 12x12", 60960, 60960, 1023, 63,
Aaron Skomra70ee06c2015-08-20 16:05:16 -07003822 INTUOS3L, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 8 };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08003823static const struct wacom_features wacom_features_0xB4 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003824 { "Wacom Intuos3 12x19", 97536, 60960, 1023, 63,
Aaron Skomra70ee06c2015-08-20 16:05:16 -07003825 INTUOS3L, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 8 };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08003826static const struct wacom_features wacom_features_0xB5 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003827 { "Wacom Intuos3 6x11", 54204, 31750, 1023, 63,
Aaron Skomra70ee06c2015-08-20 16:05:16 -07003828 INTUOS3, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 8 };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08003829static const struct wacom_features wacom_features_0xB7 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003830 { "Wacom Intuos3 4x6", 31496, 19685, 1023, 63,
Aaron Skomra70ee06c2015-08-20 16:05:16 -07003831 INTUOS3S, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 4 };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08003832static const struct wacom_features wacom_features_0xB8 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003833 { "Wacom Intuos4 4x6", 31496, 19685, 2047, 63,
Aaron Skomra70ee06c2015-08-20 16:05:16 -07003834 INTUOS4S, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 7 };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08003835static const struct wacom_features wacom_features_0xB9 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003836 { "Wacom Intuos4 6x9", 44704, 27940, 2047, 63,
Aaron Skomra70ee06c2015-08-20 16:05:16 -07003837 INTUOS4, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9 };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08003838static const struct wacom_features wacom_features_0xBA =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003839 { "Wacom Intuos4 8x13", 65024, 40640, 2047, 63,
Aaron Skomra70ee06c2015-08-20 16:05:16 -07003840 INTUOS4L, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9 };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08003841static const struct wacom_features wacom_features_0xBB =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003842 { "Wacom Intuos4 12x19", 97536, 60960, 2047, 63,
Aaron Skomra70ee06c2015-08-20 16:05:16 -07003843 INTUOS4L, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9 };
Ping Cheng3a4b4aa2010-06-03 22:10:21 -07003844static const struct wacom_features wacom_features_0xBC =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003845 { "Wacom Intuos4 WL", 40640, 25400, 2047, 63,
Aaron Skomra70ee06c2015-08-20 16:05:16 -07003846 INTUOS4, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9 };
Benjamin Tissoires81af7e62014-08-06 13:55:56 -07003847static const struct wacom_features wacom_features_0xBD =
3848 { "Wacom Intuos4 WL", 40640, 25400, 2047, 63,
Aaron Skomra70ee06c2015-08-20 16:05:16 -07003849 INTUOS4WL, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9 };
Jason Gerecke9fee6192012-04-03 15:47:22 -07003850static const struct wacom_features wacom_features_0x26 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003851 { "Wacom Intuos5 touch S", 31496, 19685, 2047, 63,
Aaron Skomra70ee06c2015-08-20 16:05:16 -07003852 INTUOS5S, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 7, .touch_max = 16 };
Jason Gerecke9fee6192012-04-03 15:47:22 -07003853static const struct wacom_features wacom_features_0x27 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003854 { "Wacom Intuos5 touch M", 44704, 27940, 2047, 63,
Aaron Skomra70ee06c2015-08-20 16:05:16 -07003855 INTUOS5, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9, .touch_max = 16 };
Jason Gerecke9fee6192012-04-03 15:47:22 -07003856static const struct wacom_features wacom_features_0x28 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003857 { "Wacom Intuos5 touch L", 65024, 40640, 2047, 63,
Aaron Skomra70ee06c2015-08-20 16:05:16 -07003858 INTUOS5L, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9, .touch_max = 16 };
Jason Gerecke9fee6192012-04-03 15:47:22 -07003859static const struct wacom_features wacom_features_0x29 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003860 { "Wacom Intuos5 S", 31496, 19685, 2047, 63,
Aaron Skomra70ee06c2015-08-20 16:05:16 -07003861 INTUOS5S, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 7 };
Jason Gerecke9fee6192012-04-03 15:47:22 -07003862static const struct wacom_features wacom_features_0x2A =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003863 { "Wacom Intuos5 M", 44704, 27940, 2047, 63,
Aaron Skomra70ee06c2015-08-20 16:05:16 -07003864 INTUOS5, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9 };
Ping Cheng9a35c412013-09-20 09:51:56 -07003865static const struct wacom_features wacom_features_0x314 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003866 { "Wacom Intuos Pro S", 31496, 19685, 2047, 63,
Aaron Skomra70ee06c2015-08-20 16:05:16 -07003867 INTUOSPS, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 7, .touch_max = 16,
Benjamin Tissoires29b47392014-07-24 12:52:23 -07003868 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
Ping Cheng9a35c412013-09-20 09:51:56 -07003869static const struct wacom_features wacom_features_0x315 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003870 { "Wacom Intuos Pro M", 44704, 27940, 2047, 63,
Aaron Skomra70ee06c2015-08-20 16:05:16 -07003871 INTUOSPM, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9, .touch_max = 16,
Benjamin Tissoires29b47392014-07-24 12:52:23 -07003872 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
Ping Cheng9a35c412013-09-20 09:51:56 -07003873static const struct wacom_features wacom_features_0x317 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003874 { "Wacom Intuos Pro L", 65024, 40640, 2047, 63,
Aaron Skomra70ee06c2015-08-20 16:05:16 -07003875 INTUOSPL, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9, .touch_max = 16,
Benjamin Tissoires29b47392014-07-24 12:52:23 -07003876 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
Jason Gerecke803296b2011-12-12 00:11:45 -08003877static const struct wacom_features wacom_features_0xF4 =
Jason Gereckee779ef22016-10-19 18:03:49 -07003878 { "Wacom Cintiq 24HD", 104480, 65600, 2047, 63,
Aaron Skomra70ee06c2015-08-20 16:05:16 -07003879 WACOM_24HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 16,
Jason Gereckee779ef22016-10-19 18:03:49 -07003880 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
Ping Chengfa770342014-12-01 13:44:28 -08003881 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET };
Jason Gerecke6f4d0382012-08-21 22:11:59 -07003882static const struct wacom_features wacom_features_0xF8 =
Jason Gereckee779ef22016-10-19 18:03:49 -07003883 { "Wacom Cintiq 24HD touch", 104480, 65600, 2047, 63, /* Pen */
Aaron Skomra70ee06c2015-08-20 16:05:16 -07003884 WACOM_24HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 16,
Ping Chengfa770342014-12-01 13:44:28 -08003885 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
Jason Gereckee779ef22016-10-19 18:03:49 -07003886 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
Ping Cheng3bd1f7e2013-05-23 10:22:33 -07003887 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0xf6 };
Jason Gereckeb1e42792012-10-21 00:38:04 -07003888static const struct wacom_features wacom_features_0xF6 =
3889 { "Wacom Cintiq 24HD touch", .type = WACOM_24HDT, /* Touch */
Benjamin Tissoires29b47392014-07-24 12:52:23 -07003890 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0xf8, .touch_max = 10,
3891 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
Ping Cheng500d4162015-01-27 13:30:03 -08003892static const struct wacom_features wacom_features_0x32A =
Jason Gereckee779ef22016-10-19 18:03:49 -07003893 { "Wacom Cintiq 27QHD", 120140, 67920, 2047, 63,
Aaron Skomra70ee06c2015-08-20 16:05:16 -07003894 WACOM_27QHD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 0,
Jason Gereckee779ef22016-10-19 18:03:49 -07003895 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
Ping Chenga7e66452015-02-04 16:01:54 -08003896 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET };
Ping Cheng500d4162015-01-27 13:30:03 -08003897static const struct wacom_features wacom_features_0x32B =
Jason Gereckee779ef22016-10-19 18:03:49 -07003898 { "Wacom Cintiq 27QHD touch", 120140, 67920, 2047, 63,
Aaron Skomra70ee06c2015-08-20 16:05:16 -07003899 WACOM_27QHD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 0,
Ping Cheng500d4162015-01-27 13:30:03 -08003900 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
Jason Gereckee779ef22016-10-19 18:03:49 -07003901 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
Ping Cheng500d4162015-01-27 13:30:03 -08003902 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x32C };
3903static const struct wacom_features wacom_features_0x32C =
3904 { "Wacom Cintiq 27QHD touch", .type = WACOM_27QHDT,
3905 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x32B, .touch_max = 10 };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08003906static const struct wacom_features wacom_features_0x3F =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003907 { "Wacom Cintiq 21UX", 87200, 65600, 1023, 63,
Aaron Skomra70ee06c2015-08-20 16:05:16 -07003908 CINTIQ, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 8 };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08003909static const struct wacom_features wacom_features_0xC5 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003910 { "Wacom Cintiq 20WSX", 86680, 54180, 1023, 63,
Aaron Skomra70ee06c2015-08-20 16:05:16 -07003911 WACOM_BEE, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 10 };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08003912static const struct wacom_features wacom_features_0xC6 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003913 { "Wacom Cintiq 12WX", 53020, 33440, 1023, 63,
Aaron Skomra70ee06c2015-08-20 16:05:16 -07003914 WACOM_BEE, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 10 };
Ping Cheng56218562013-05-05 19:56:18 -07003915static const struct wacom_features wacom_features_0x304 =
Jason Gereckee779ef22016-10-19 18:03:49 -07003916 { "Wacom Cintiq 13HD", 59552, 33848, 1023, 63,
Aaron Skomra70ee06c2015-08-20 16:05:16 -07003917 WACOM_13HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9,
Jason Gereckee779ef22016-10-19 18:03:49 -07003918 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
Ping Chengfa770342014-12-01 13:44:28 -08003919 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET };
Ping Chengb4bf2122015-03-25 17:08:13 -07003920static const struct wacom_features wacom_features_0x333 =
Jason Gereckee779ef22016-10-19 18:03:49 -07003921 { "Wacom Cintiq 13HD touch", 59552, 33848, 2047, 63,
Aaron Skomra70ee06c2015-08-20 16:05:16 -07003922 WACOM_13HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9,
Ping Chengb4bf2122015-03-25 17:08:13 -07003923 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
Jason Gereckee779ef22016-10-19 18:03:49 -07003924 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
Ping Chengb4bf2122015-03-25 17:08:13 -07003925 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x335 };
3926static const struct wacom_features wacom_features_0x335 =
3927 { "Wacom Cintiq 13HD touch", .type = WACOM_24HDT, /* Touch */
3928 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x333, .touch_max = 10,
3929 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08003930static const struct wacom_features wacom_features_0xC7 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003931 { "Wacom DTU1931", 37832, 30305, 511, 0,
3932 PL, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Ping Chengc8f2edc2010-06-28 01:10:51 -07003933static const struct wacom_features wacom_features_0xCE =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003934 { "Wacom DTU2231", 47864, 27011, 511, 0,
3935 DTU, WACOM_INTUOS_RES, WACOM_INTUOS_RES,
Benjamin Tissoires29b47392014-07-24 12:52:23 -07003936 .check_for_hid_type = true, .hid_type = HID_TYPE_USBMOUSE };
Ping Chengc8f2edc2010-06-28 01:10:51 -07003937static const struct wacom_features wacom_features_0xF0 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003938 { "Wacom DTU1631", 34623, 19553, 511, 0,
3939 DTU, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Ping Cheng497ab1f2014-01-20 20:18:04 -08003940static const struct wacom_features wacom_features_0xFB =
Jason Gereckee779ef22016-10-19 18:03:49 -07003941 { "Wacom DTU1031", 22096, 13960, 511, 0,
Aaron Skomra70ee06c2015-08-20 16:05:16 -07003942 DTUS, WACOM_INTUOS_RES, WACOM_INTUOS_RES, 4,
Jason Gereckee779ef22016-10-19 18:03:49 -07003943 WACOM_DTU_OFFSET, WACOM_DTU_OFFSET,
Ping Chengfa770342014-12-01 13:44:28 -08003944 WACOM_DTU_OFFSET, WACOM_DTU_OFFSET };
Ping Chengfff00bf2014-12-04 18:23:04 -08003945static const struct wacom_features wacom_features_0x32F =
Jason Gereckee779ef22016-10-19 18:03:49 -07003946 { "Wacom DTU1031X", 22672, 12928, 511, 0,
Aaron Skomra70ee06c2015-08-20 16:05:16 -07003947 DTUSX, WACOM_INTUOS_RES, WACOM_INTUOS_RES, 0,
Jason Gereckee779ef22016-10-19 18:03:49 -07003948 WACOM_DTU_OFFSET, WACOM_DTU_OFFSET,
Ping Chengfff00bf2014-12-04 18:23:04 -08003949 WACOM_DTU_OFFSET, WACOM_DTU_OFFSET };
Aaron Skomra007760c2015-04-16 15:01:14 -07003950static const struct wacom_features wacom_features_0x336 =
Jason Gereckee779ef22016-10-19 18:03:49 -07003951 { "Wacom DTU1141", 23672, 13403, 1023, 0,
Ping Chengff38e822015-11-12 17:21:14 -08003952 DTUS, WACOM_INTUOS_RES, WACOM_INTUOS_RES, 4,
Jason Gereckee779ef22016-10-19 18:03:49 -07003953 WACOM_DTU_OFFSET, WACOM_DTU_OFFSET,
Ping Chengff38e822015-11-12 17:21:14 -08003954 WACOM_DTU_OFFSET, WACOM_DTU_OFFSET };
Ping Cheng56218562013-05-05 19:56:18 -07003955static const struct wacom_features wacom_features_0x57 =
Jason Gereckee779ef22016-10-19 18:03:49 -07003956 { "Wacom DTK2241", 95840, 54260, 2047, 63,
Aaron Skomra70ee06c2015-08-20 16:05:16 -07003957 DTK, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 6,
Jason Gereckee779ef22016-10-19 18:03:49 -07003958 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
Ping Chengfa770342014-12-01 13:44:28 -08003959 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET };
Ping Chenga112e9f2013-02-13 20:20:01 -08003960static const struct wacom_features wacom_features_0x59 = /* Pen */
Jason Gereckee779ef22016-10-19 18:03:49 -07003961 { "Wacom DTH2242", 95840, 54260, 2047, 63,
Aaron Skomra70ee06c2015-08-20 16:05:16 -07003962 DTK, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 6,
Ping Chengfa770342014-12-01 13:44:28 -08003963 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
Jason Gereckee779ef22016-10-19 18:03:49 -07003964 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
Ping Chenga112e9f2013-02-13 20:20:01 -08003965 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x5D };
3966static const struct wacom_features wacom_features_0x5D = /* Touch */
3967 { "Wacom DTH2242", .type = WACOM_24HDT,
Benjamin Tissoires29b47392014-07-24 12:52:23 -07003968 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x59, .touch_max = 10,
3969 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
Ping Cheng3a4b4aa2010-06-03 22:10:21 -07003970static const struct wacom_features wacom_features_0xCC =
Jason Gereckee779ef22016-10-19 18:03:49 -07003971 { "Wacom Cintiq 21UX2", 87200, 65600, 2047, 63,
Aaron Skomra70ee06c2015-08-20 16:05:16 -07003972 WACOM_21UX2, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 18,
Jason Gereckee779ef22016-10-19 18:03:49 -07003973 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
Ping Chengfa770342014-12-01 13:44:28 -08003974 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET };
Ping Chengd838c642012-07-24 23:54:11 -07003975static const struct wacom_features wacom_features_0xFA =
Jason Gereckee779ef22016-10-19 18:03:49 -07003976 { "Wacom Cintiq 22HD", 95840, 54260, 2047, 63,
Aaron Skomra70ee06c2015-08-20 16:05:16 -07003977 WACOM_22HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 18,
Jason Gereckee779ef22016-10-19 18:03:49 -07003978 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
Ping Chengfa770342014-12-01 13:44:28 -08003979 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET };
Ping Cheng56218562013-05-05 19:56:18 -07003980static const struct wacom_features wacom_features_0x5B =
Jason Gereckee779ef22016-10-19 18:03:49 -07003981 { "Wacom Cintiq 22HDT", 95840, 54260, 2047, 63,
Aaron Skomra70ee06c2015-08-20 16:05:16 -07003982 WACOM_22HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 18,
Ping Chengfa770342014-12-01 13:44:28 -08003983 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
Jason Gereckee779ef22016-10-19 18:03:49 -07003984 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
Ping Cheng3bd1f7e2013-05-23 10:22:33 -07003985 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x5e };
Ping Cheng56218562013-05-05 19:56:18 -07003986static const struct wacom_features wacom_features_0x5E =
3987 { "Wacom Cintiq 22HDT", .type = WACOM_24HDT,
Benjamin Tissoires29b47392014-07-24 12:52:23 -07003988 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x5b, .touch_max = 10,
3989 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08003990static const struct wacom_features wacom_features_0x90 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003991 { "Wacom ISDv4 90", 26202, 16325, 255, 0,
3992 TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08003993static const struct wacom_features wacom_features_0x93 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003994 { "Wacom ISDv4 93", 26202, 16325, 255, 0,
3995 TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Ping Cheng11d0cf82011-06-27 12:57:58 -07003996static const struct wacom_features wacom_features_0x97 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003997 { "Wacom ISDv4 97", 26202, 16325, 511, 0,
3998 TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08003999static const struct wacom_features wacom_features_0x9A =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07004000 { "Wacom ISDv4 9A", 26202, 16325, 255, 0,
4001 TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08004002static const struct wacom_features wacom_features_0x9F =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07004003 { "Wacom ISDv4 9F", 26202, 16325, 255, 0,
4004 TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08004005static const struct wacom_features wacom_features_0xE2 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07004006 { "Wacom ISDv4 E2", 26202, 16325, 255, 0,
4007 TABLETPC2FG, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08004008static const struct wacom_features wacom_features_0xE3 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07004009 { "Wacom ISDv4 E3", 26202, 16325, 255, 0,
4010 TABLETPC2FG, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
Ping Cheng19635182012-04-29 21:09:18 -07004011static const struct wacom_features wacom_features_0xE5 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07004012 { "Wacom ISDv4 E5", 26202, 16325, 255, 0,
4013 MTSCREEN, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Manoj Iyer26fcd2a2011-03-31 22:39:43 -07004014static const struct wacom_features wacom_features_0xE6 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07004015 { "Wacom ISDv4 E6", 27760, 15694, 255, 0,
4016 TABLETPC2FG, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
Chris Bagwell0d0e3062011-12-11 23:50:59 -08004017static const struct wacom_features wacom_features_0xEC =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07004018 { "Wacom ISDv4 EC", 25710, 14500, 255, 0,
4019 TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Ping Chengac173832012-06-12 00:15:06 -07004020static const struct wacom_features wacom_features_0xED =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07004021 { "Wacom ISDv4 ED", 26202, 16325, 255, 0,
4022 TABLETPCE, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Ping Chengac173832012-06-12 00:15:06 -07004023static const struct wacom_features wacom_features_0xEF =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07004024 { "Wacom ISDv4 EF", 26202, 16325, 255, 0,
4025 TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Ping Cheng6afdc282012-11-03 12:16:15 -07004026static const struct wacom_features wacom_features_0x100 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07004027 { "Wacom ISDv4 100", 26202, 16325, 255, 0,
4028 MTTPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Ping Cheng6afdc282012-11-03 12:16:15 -07004029static const struct wacom_features wacom_features_0x101 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07004030 { "Wacom ISDv4 101", 26202, 16325, 255, 0,
4031 MTTPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Stephan Frank58694832013-03-07 14:08:50 -08004032static const struct wacom_features wacom_features_0x10D =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07004033 { "Wacom ISDv4 10D", 26202, 16325, 255, 0,
4034 MTTPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Jason Gerecke2d3163f2013-10-22 15:35:30 -07004035static const struct wacom_features wacom_features_0x10E =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07004036 { "Wacom ISDv4 10E", 27760, 15694, 255, 0,
4037 MTTPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Jason Gerecke9b4f60e2013-10-15 23:46:34 -07004038static const struct wacom_features wacom_features_0x10F =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07004039 { "Wacom ISDv4 10F", 27760, 15694, 255, 0,
4040 MTTPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Jason Gerecke61616ed2014-05-14 11:42:22 -07004041static const struct wacom_features wacom_features_0x116 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07004042 { "Wacom ISDv4 116", 26202, 16325, 255, 0,
4043 TABLETPCE, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Jason Gereckeaeaf50d2014-07-28 10:53:16 -07004044static const struct wacom_features wacom_features_0x12C =
4045 { "Wacom ISDv4 12C", 27848, 15752, 2047, 0,
4046 TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Ping Chengedbe2652012-11-21 13:12:50 -08004047static const struct wacom_features wacom_features_0x4001 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07004048 { "Wacom ISDv4 4001", 26202, 16325, 255, 0,
4049 MTTPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Jason Gerecked51ddb22014-05-14 17:14:29 -07004050static const struct wacom_features wacom_features_0x4004 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07004051 { "Wacom ISDv4 4004", 11060, 6220, 255, 0,
4052 MTTPC_B, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Jason Gerecked51ddb22014-05-14 17:14:29 -07004053static const struct wacom_features wacom_features_0x5000 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07004054 { "Wacom ISDv4 5000", 27848, 15752, 1023, 0,
4055 MTTPC_B, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Jason Gerecked51ddb22014-05-14 17:14:29 -07004056static const struct wacom_features wacom_features_0x5002 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07004057 { "Wacom ISDv4 5002", 29576, 16724, 1023, 0,
4058 MTTPC_B, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08004059static const struct wacom_features wacom_features_0x47 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07004060 { "Wacom Intuos2 6x8", 20320, 16240, 1023, 31,
4061 INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Chris Bagwelld3825d52012-03-25 23:26:11 -07004062static const struct wacom_features wacom_features_0x84 =
Ping Cheng3b164a02015-09-23 09:59:10 -07004063 { "Wacom Wireless Receiver", .type = WIRELESS, .touch_max = 16 };
Ping Cheng7b824bb2011-03-26 21:16:04 -07004064static const struct wacom_features wacom_features_0xD0 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07004065 { "Wacom Bamboo 2FG", 14720, 9200, 1023, 31,
Ping Cheng3b164a02015-09-23 09:59:10 -07004066 BAMBOO_TOUCH, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
Ping Cheng7b824bb2011-03-26 21:16:04 -07004067static const struct wacom_features wacom_features_0xD1 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07004068 { "Wacom Bamboo 2FG 4x5", 14720, 9200, 1023, 31,
4069 BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
Ping Cheng7b824bb2011-03-26 21:16:04 -07004070static const struct wacom_features wacom_features_0xD2 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07004071 { "Wacom Bamboo Craft", 14720, 9200, 1023, 31,
4072 BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
Ping Cheng7b824bb2011-03-26 21:16:04 -07004073static const struct wacom_features wacom_features_0xD3 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07004074 { "Wacom Bamboo 2FG 6x8", 21648, 13700, 1023, 31,
4075 BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
Kevin Granade57a78722010-12-10 23:04:02 -08004076static const struct wacom_features wacom_features_0xD4 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07004077 { "Wacom Bamboo Pen", 14720, 9200, 1023, 31,
Ping Cheng3b164a02015-09-23 09:59:10 -07004078 BAMBOO_PEN, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Gerard Braad18adad12011-08-16 00:17:56 -07004079static const struct wacom_features wacom_features_0xD5 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07004080 { "Wacom Bamboo Pen 6x8", 21648, 13700, 1023, 31,
Ping Cheng3b164a02015-09-23 09:59:10 -07004081 BAMBOO_PEN, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Ping Cheng7b824bb2011-03-26 21:16:04 -07004082static const struct wacom_features wacom_features_0xD6 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07004083 { "Wacom BambooPT 2FG 4x5", 14720, 9200, 1023, 31,
4084 BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
Ping Cheng7b824bb2011-03-26 21:16:04 -07004085static const struct wacom_features wacom_features_0xD7 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07004086 { "Wacom BambooPT 2FG Small", 14720, 9200, 1023, 31,
4087 BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
Ping Cheng7b824bb2011-03-26 21:16:04 -07004088static const struct wacom_features wacom_features_0xD8 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07004089 { "Wacom Bamboo Comic 2FG", 21648, 13700, 1023, 31,
4090 BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
Ping Cheng7b824bb2011-03-26 21:16:04 -07004091static const struct wacom_features wacom_features_0xDA =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07004092 { "Wacom Bamboo 2FG 4x5 SE", 14720, 9200, 1023, 31,
4093 BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
Ping Chengf41a64e2013-08-21 09:14:49 -07004094static const struct wacom_features wacom_features_0xDB =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07004095 { "Wacom Bamboo 2FG 6x8 SE", 21648, 13700, 1023, 31,
4096 BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
Chris Bagwell73149ab2011-10-26 22:34:21 -07004097static const struct wacom_features wacom_features_0xDD =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07004098 { "Wacom Bamboo Connect", 14720, 9200, 1023, 31,
4099 BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Chris Bagwell73149ab2011-10-26 22:34:21 -07004100static const struct wacom_features wacom_features_0xDE =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07004101 { "Wacom Bamboo 16FG 4x5", 14720, 9200, 1023, 31,
4102 BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 16 };
Chris Bagwell73149ab2011-10-26 22:34:21 -07004103static const struct wacom_features wacom_features_0xDF =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07004104 { "Wacom Bamboo 16FG 6x8", 21648, 13700, 1023, 31,
4105 BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 16 };
Ping Chengf41a64e2013-08-21 09:14:49 -07004106static const struct wacom_features wacom_features_0x300 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07004107 { "Wacom Bamboo One S", 14720, 9225, 1023, 31,
Ping Cheng3b164a02015-09-23 09:59:10 -07004108 BAMBOO_PEN, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Ping Chengf41a64e2013-08-21 09:14:49 -07004109static const struct wacom_features wacom_features_0x301 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07004110 { "Wacom Bamboo One M", 21648, 13530, 1023, 31,
4111 BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Ping Chengb5fd2a32013-11-25 18:44:55 -08004112static const struct wacom_features wacom_features_0x302 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07004113 { "Wacom Intuos PT S", 15200, 9500, 1023, 31,
4114 INTUOSHT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 16,
Benjamin Tissoires29b47392014-07-24 12:52:23 -07004115 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
Ping Chengb5fd2a32013-11-25 18:44:55 -08004116static const struct wacom_features wacom_features_0x303 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07004117 { "Wacom Intuos PT M", 21600, 13500, 1023, 31,
4118 INTUOSHT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 16,
Benjamin Tissoires29b47392014-07-24 12:52:23 -07004119 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
Ping Chengb5fd2a32013-11-25 18:44:55 -08004120static const struct wacom_features wacom_features_0x30E =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07004121 { "Wacom Intuos S", 15200, 9500, 1023, 31,
4122 INTUOSHT, WACOM_INTUOS_RES, WACOM_INTUOS_RES,
Benjamin Tissoires29b47392014-07-24 12:52:23 -07004123 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
Ajay Ramaswamy7b4b3062010-12-23 01:19:39 -08004124static const struct wacom_features wacom_features_0x6004 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07004125 { "ISD-V4", 12800, 8000, 255, 0,
4126 TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Benjamin Tissoiresa3e6f652014-07-24 13:05:49 -07004127static const struct wacom_features wacom_features_0x307 =
Jason Gereckee779ef22016-10-19 18:03:49 -07004128 { "Wacom ISDv5 307", 59552, 33848, 2047, 63,
Aaron Skomra70ee06c2015-08-20 16:05:16 -07004129 CINTIQ_HYBRID, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9,
Ping Chengfa770342014-12-01 13:44:28 -08004130 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
Jason Gereckee779ef22016-10-19 18:03:49 -07004131 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
Jason Gerecke36d3c512013-09-20 09:47:35 -07004132 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x309 };
Benjamin Tissoiresa3e6f652014-07-24 13:05:49 -07004133static const struct wacom_features wacom_features_0x309 =
Jason Gerecke36d3c512013-09-20 09:47:35 -07004134 { "Wacom ISDv5 309", .type = WACOM_24HDT, /* Touch */
Benjamin Tissoires29b47392014-07-24 12:52:23 -07004135 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x0307, .touch_max = 10,
4136 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
Benjamin Tissoires89f2ab52014-09-03 15:43:25 -04004137static const struct wacom_features wacom_features_0x30A =
Jason Gereckee779ef22016-10-19 18:03:49 -07004138 { "Wacom ISDv5 30A", 59552, 33848, 2047, 63,
Aaron Skomra70ee06c2015-08-20 16:05:16 -07004139 CINTIQ_HYBRID, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9,
Ping Chengfa770342014-12-01 13:44:28 -08004140 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
Jason Gereckee779ef22016-10-19 18:03:49 -07004141 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
Benjamin Tissoires89f2ab52014-09-03 15:43:25 -04004142 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x30C };
4143static const struct wacom_features wacom_features_0x30C =
4144 { "Wacom ISDv5 30C", .type = WACOM_24HDT, /* Touch */
4145 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x30A, .touch_max = 10,
4146 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
Benjamin Tissoires8c97a762015-02-26 11:28:50 -05004147static const struct wacom_features wacom_features_0x318 =
4148 { "Wacom USB Bamboo PAD", 4095, 4095, /* Touch */
4149 .type = BAMBOO_PAD, 35, 48, .touch_max = 4 };
4150static const struct wacom_features wacom_features_0x319 =
4151 { "Wacom Wireless Bamboo PAD", 4095, 4095, /* Touch */
4152 .type = BAMBOO_PAD, 35, 48, .touch_max = 4 };
Jason Gereckef7acb552015-10-13 10:03:49 -07004153static const struct wacom_features wacom_features_0x325 =
4154 { "Wacom ISDv5 325", 59552, 33848, 2047, 63,
4155 CINTIQ_COMPANION_2, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 11,
4156 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
Jason Gereckee779ef22016-10-19 18:03:49 -07004157 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
Jason Gereckef7acb552015-10-13 10:03:49 -07004158 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x326 };
4159static const struct wacom_features wacom_features_0x326 = /* Touch */
4160 { "Wacom ISDv5 326", .type = HID_GENERIC, .oVid = USB_VENDOR_ID_WACOM,
4161 .oPid = 0x325 };
Ping Chengfefb3912014-11-11 12:52:08 -08004162static const struct wacom_features wacom_features_0x323 =
4163 { "Wacom Intuos P M", 21600, 13500, 1023, 31,
4164 INTUOSHT, WACOM_INTUOS_RES, WACOM_INTUOS_RES,
4165 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
Aaron Skomra72b236d2015-08-20 16:05:17 -07004166static const struct wacom_features wacom_features_0x331 =
Ping Cheng3b164a02015-09-23 09:59:10 -07004167 { "Wacom Express Key Remote", .type = REMOTE,
4168 .numbered_buttons = 18, .check_for_hid_type = true,
Aaron Skomra72b236d2015-08-20 16:05:17 -07004169 .hid_type = HID_TYPE_USBNONE };
Ping Chengeda01da2015-09-23 13:51:15 -07004170static const struct wacom_features wacom_features_0x33B =
4171 { "Wacom Intuos S 2", 15200, 9500, 2047, 63,
4172 INTUOSHT2, WACOM_INTUOS_RES, WACOM_INTUOS_RES,
4173 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
4174static const struct wacom_features wacom_features_0x33C =
4175 { "Wacom Intuos PT S 2", 15200, 9500, 2047, 63,
4176 INTUOSHT2, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 16,
4177 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
4178static const struct wacom_features wacom_features_0x33D =
4179 { "Wacom Intuos P M 2", 21600, 13500, 2047, 63,
4180 INTUOSHT2, WACOM_INTUOS_RES, WACOM_INTUOS_RES,
4181 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
4182static const struct wacom_features wacom_features_0x33E =
4183 { "Wacom Intuos PT M 2", 21600, 13500, 2047, 63,
4184 INTUOSHT2, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 16,
4185 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
Ping Chenge1123fe2016-04-12 13:37:45 -07004186static const struct wacom_features wacom_features_0x343 =
Jason Gereckee779ef22016-10-19 18:03:49 -07004187 { "Wacom DTK1651", 34816, 19759, 1023, 0,
Ping Chenge1123fe2016-04-12 13:37:45 -07004188 DTUS, WACOM_INTUOS_RES, WACOM_INTUOS_RES, 4,
Jason Gereckee779ef22016-10-19 18:03:49 -07004189 WACOM_DTU_OFFSET, WACOM_DTU_OFFSET,
Ping Chenge1123fe2016-04-12 13:37:45 -07004190 WACOM_DTU_OFFSET, WACOM_DTU_OFFSET };
Jason Gerecke4922cd22017-01-25 12:08:37 -08004191static const struct wacom_features wacom_features_0x360 =
4192 { "Wacom Intuos Pro M", 44800, 29600, 8191, 63,
4193 INTUOSP2_BT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, 9, .touch_max = 10 };
4194static const struct wacom_features wacom_features_0x361 =
4195 { "Wacom Intuos Pro L", 62200, 43200, 8191, 63,
4196 INTUOSP2_BT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, 9, .touch_max = 10 };
Bastian Blankb036f6f2010-02-10 23:06:23 -08004197
Benjamin Tissoires7704ac92014-09-23 12:08:08 -04004198static const struct wacom_features wacom_features_HID_ANY_ID =
Jason Gerecke41372d52016-08-08 12:06:30 -07004199 { "Wacom HID", .type = HID_GENERIC, .oVid = HID_ANY_ID, .oPid = HID_ANY_ID };
Benjamin Tissoires7704ac92014-09-23 12:08:08 -04004200
Benjamin Tissoires29b47392014-07-24 12:52:23 -07004201#define USB_DEVICE_WACOM(prod) \
4202 HID_DEVICE(BUS_USB, HID_GROUP_WACOM, USB_VENDOR_ID_WACOM, prod),\
4203 .driver_data = (kernel_ulong_t)&wacom_features_##prod
Bastian Blankb036f6f2010-02-10 23:06:23 -08004204
Benjamin Tissoires387142b2014-08-06 13:52:56 -07004205#define BT_DEVICE_WACOM(prod) \
4206 HID_DEVICE(BUS_BLUETOOTH, HID_GROUP_WACOM, USB_VENDOR_ID_WACOM, prod),\
4207 .driver_data = (kernel_ulong_t)&wacom_features_##prod
Aristeu Rozanski1483f552011-06-22 01:17:17 -07004208
Mika Westerbergeef23a82015-02-23 15:52:43 +02004209#define I2C_DEVICE_WACOM(prod) \
4210 HID_DEVICE(BUS_I2C, HID_GROUP_WACOM, USB_VENDOR_ID_WACOM, prod),\
4211 .driver_data = (kernel_ulong_t)&wacom_features_##prod
4212
Ajay Ramaswamy7b4b3062010-12-23 01:19:39 -08004213#define USB_DEVICE_LENOVO(prod) \
Benjamin Tissoires29b47392014-07-24 12:52:23 -07004214 HID_USB_DEVICE(USB_VENDOR_ID_LENOVO, prod), \
4215 .driver_data = (kernel_ulong_t)&wacom_features_##prod
Ajay Ramaswamy7b4b3062010-12-23 01:19:39 -08004216
Benjamin Tissoires29b47392014-07-24 12:52:23 -07004217const struct hid_device_id wacom_ids[] = {
Bastian Blankb036f6f2010-02-10 23:06:23 -08004218 { USB_DEVICE_WACOM(0x00) },
Benjamin Tissoiresa3e6f652014-07-24 13:05:49 -07004219 { USB_DEVICE_WACOM(0x03) },
Bastian Blankb036f6f2010-02-10 23:06:23 -08004220 { USB_DEVICE_WACOM(0x10) },
4221 { USB_DEVICE_WACOM(0x11) },
4222 { USB_DEVICE_WACOM(0x12) },
4223 { USB_DEVICE_WACOM(0x13) },
4224 { USB_DEVICE_WACOM(0x14) },
4225 { USB_DEVICE_WACOM(0x15) },
4226 { USB_DEVICE_WACOM(0x16) },
4227 { USB_DEVICE_WACOM(0x17) },
4228 { USB_DEVICE_WACOM(0x18) },
4229 { USB_DEVICE_WACOM(0x19) },
Bastian Blankb036f6f2010-02-10 23:06:23 -08004230 { USB_DEVICE_WACOM(0x20) },
4231 { USB_DEVICE_WACOM(0x21) },
4232 { USB_DEVICE_WACOM(0x22) },
4233 { USB_DEVICE_WACOM(0x23) },
4234 { USB_DEVICE_WACOM(0x24) },
Benjamin Tissoiresa3e6f652014-07-24 13:05:49 -07004235 { USB_DEVICE_WACOM(0x26) },
4236 { USB_DEVICE_WACOM(0x27) },
4237 { USB_DEVICE_WACOM(0x28) },
4238 { USB_DEVICE_WACOM(0x29) },
4239 { USB_DEVICE_WACOM(0x2A) },
Bastian Blankb036f6f2010-02-10 23:06:23 -08004240 { USB_DEVICE_WACOM(0x30) },
4241 { USB_DEVICE_WACOM(0x31) },
4242 { USB_DEVICE_WACOM(0x32) },
4243 { USB_DEVICE_WACOM(0x33) },
4244 { USB_DEVICE_WACOM(0x34) },
4245 { USB_DEVICE_WACOM(0x35) },
4246 { USB_DEVICE_WACOM(0x37) },
4247 { USB_DEVICE_WACOM(0x38) },
4248 { USB_DEVICE_WACOM(0x39) },
Benjamin Tissoiresa3e6f652014-07-24 13:05:49 -07004249 { USB_DEVICE_WACOM(0x3F) },
Bastian Blankb036f6f2010-02-10 23:06:23 -08004250 { USB_DEVICE_WACOM(0x41) },
4251 { USB_DEVICE_WACOM(0x42) },
4252 { USB_DEVICE_WACOM(0x43) },
4253 { USB_DEVICE_WACOM(0x44) },
4254 { USB_DEVICE_WACOM(0x45) },
Benjamin Tissoiresa3e6f652014-07-24 13:05:49 -07004255 { USB_DEVICE_WACOM(0x47) },
Ping Cheng56218562013-05-05 19:56:18 -07004256 { USB_DEVICE_WACOM(0x57) },
Ping Chenga112e9f2013-02-13 20:20:01 -08004257 { USB_DEVICE_WACOM(0x59) },
Ping Cheng56218562013-05-05 19:56:18 -07004258 { USB_DEVICE_WACOM(0x5B) },
Benjamin Tissoiresa3e6f652014-07-24 13:05:49 -07004259 { USB_DEVICE_WACOM(0x5D) },
Benjamin Tissoires29b47392014-07-24 12:52:23 -07004260 { USB_DEVICE_WACOM(0x5E) },
Benjamin Tissoiresa3e6f652014-07-24 13:05:49 -07004261 { USB_DEVICE_WACOM(0x60) },
4262 { USB_DEVICE_WACOM(0x61) },
4263 { USB_DEVICE_WACOM(0x62) },
4264 { USB_DEVICE_WACOM(0x63) },
4265 { USB_DEVICE_WACOM(0x64) },
4266 { USB_DEVICE_WACOM(0x65) },
4267 { USB_DEVICE_WACOM(0x69) },
4268 { USB_DEVICE_WACOM(0x6A) },
4269 { USB_DEVICE_WACOM(0x6B) },
Benjamin Tissoires387142b2014-08-06 13:52:56 -07004270 { BT_DEVICE_WACOM(0x81) },
Benjamin Tissoiresa3e6f652014-07-24 13:05:49 -07004271 { USB_DEVICE_WACOM(0x84) },
4272 { USB_DEVICE_WACOM(0x90) },
4273 { USB_DEVICE_WACOM(0x93) },
4274 { USB_DEVICE_WACOM(0x97) },
4275 { USB_DEVICE_WACOM(0x9A) },
4276 { USB_DEVICE_WACOM(0x9F) },
Bastian Blankb036f6f2010-02-10 23:06:23 -08004277 { USB_DEVICE_WACOM(0xB0) },
4278 { USB_DEVICE_WACOM(0xB1) },
4279 { USB_DEVICE_WACOM(0xB2) },
4280 { USB_DEVICE_WACOM(0xB3) },
4281 { USB_DEVICE_WACOM(0xB4) },
4282 { USB_DEVICE_WACOM(0xB5) },
4283 { USB_DEVICE_WACOM(0xB7) },
4284 { USB_DEVICE_WACOM(0xB8) },
4285 { USB_DEVICE_WACOM(0xB9) },
4286 { USB_DEVICE_WACOM(0xBA) },
4287 { USB_DEVICE_WACOM(0xBB) },
Ping Cheng3a4b4aa2010-06-03 22:10:21 -07004288 { USB_DEVICE_WACOM(0xBC) },
Benjamin Tissoires81af7e62014-08-06 13:55:56 -07004289 { BT_DEVICE_WACOM(0xBD) },
Benjamin Tissoiresa3e6f652014-07-24 13:05:49 -07004290 { USB_DEVICE_WACOM(0xC0) },
4291 { USB_DEVICE_WACOM(0xC2) },
4292 { USB_DEVICE_WACOM(0xC4) },
Bastian Blankb036f6f2010-02-10 23:06:23 -08004293 { USB_DEVICE_WACOM(0xC5) },
4294 { USB_DEVICE_WACOM(0xC6) },
4295 { USB_DEVICE_WACOM(0xC7) },
Benjamin Tissoiresa3e6f652014-07-24 13:05:49 -07004296 { USB_DEVICE_WACOM(0xCC) },
Benjamin Tissoires29b47392014-07-24 12:52:23 -07004297 { USB_DEVICE_WACOM(0xCE) },
Henrik Rydbergcb734c02010-09-05 12:53:16 -07004298 { USB_DEVICE_WACOM(0xD0) },
Chris Bagwell2aaacb12010-09-12 00:11:35 -07004299 { USB_DEVICE_WACOM(0xD1) },
4300 { USB_DEVICE_WACOM(0xD2) },
4301 { USB_DEVICE_WACOM(0xD3) },
Kevin Granade57a78722010-12-10 23:04:02 -08004302 { USB_DEVICE_WACOM(0xD4) },
Gerard Braad18adad12011-08-16 00:17:56 -07004303 { USB_DEVICE_WACOM(0xD5) },
Ping Chengd38acb42011-01-24 09:32:50 -08004304 { USB_DEVICE_WACOM(0xD6) },
4305 { USB_DEVICE_WACOM(0xD7) },
David Foleya318e6b2010-11-30 23:45:46 -08004306 { USB_DEVICE_WACOM(0xD8) },
4307 { USB_DEVICE_WACOM(0xDA) },
David Foley47d09232010-12-07 21:05:59 -08004308 { USB_DEVICE_WACOM(0xDB) },
Chris Bagwell73149ab2011-10-26 22:34:21 -07004309 { USB_DEVICE_WACOM(0xDD) },
4310 { USB_DEVICE_WACOM(0xDE) },
4311 { USB_DEVICE_WACOM(0xDF) },
Bastian Blankb036f6f2010-02-10 23:06:23 -08004312 { USB_DEVICE_WACOM(0xE2) },
4313 { USB_DEVICE_WACOM(0xE3) },
Ping Cheng19635182012-04-29 21:09:18 -07004314 { USB_DEVICE_WACOM(0xE5) },
Manoj Iyer26fcd2a2011-03-31 22:39:43 -07004315 { USB_DEVICE_WACOM(0xE6) },
Chris Bagwell0d0e3062011-12-11 23:50:59 -08004316 { USB_DEVICE_WACOM(0xEC) },
Ping Chengac173832012-06-12 00:15:06 -07004317 { USB_DEVICE_WACOM(0xED) },
4318 { USB_DEVICE_WACOM(0xEF) },
Benjamin Tissoiresa3e6f652014-07-24 13:05:49 -07004319 { USB_DEVICE_WACOM(0xF0) },
4320 { USB_DEVICE_WACOM(0xF4) },
4321 { USB_DEVICE_WACOM(0xF6) },
4322 { USB_DEVICE_WACOM(0xF8) },
4323 { USB_DEVICE_WACOM(0xFA) },
4324 { USB_DEVICE_WACOM(0xFB) },
Ping Cheng6afdc282012-11-03 12:16:15 -07004325 { USB_DEVICE_WACOM(0x100) },
4326 { USB_DEVICE_WACOM(0x101) },
Stephan Frank58694832013-03-07 14:08:50 -08004327 { USB_DEVICE_WACOM(0x10D) },
Jason Gerecke2d3163f2013-10-22 15:35:30 -07004328 { USB_DEVICE_WACOM(0x10E) },
Jason Gerecke9b4f60e2013-10-15 23:46:34 -07004329 { USB_DEVICE_WACOM(0x10F) },
Jason Gerecke61616ed2014-05-14 11:42:22 -07004330 { USB_DEVICE_WACOM(0x116) },
Jason Gereckeaeaf50d2014-07-28 10:53:16 -07004331 { USB_DEVICE_WACOM(0x12C) },
Ping Chengf41a64e2013-08-21 09:14:49 -07004332 { USB_DEVICE_WACOM(0x300) },
4333 { USB_DEVICE_WACOM(0x301) },
Benjamin Tissoires29b47392014-07-24 12:52:23 -07004334 { USB_DEVICE_WACOM(0x302) },
4335 { USB_DEVICE_WACOM(0x303) },
Ping Cheng56218562013-05-05 19:56:18 -07004336 { USB_DEVICE_WACOM(0x304) },
Benjamin Tissoiresa3e6f652014-07-24 13:05:49 -07004337 { USB_DEVICE_WACOM(0x307) },
4338 { USB_DEVICE_WACOM(0x309) },
Benjamin Tissoires89f2ab52014-09-03 15:43:25 -04004339 { USB_DEVICE_WACOM(0x30A) },
4340 { USB_DEVICE_WACOM(0x30C) },
Benjamin Tissoiresa3e6f652014-07-24 13:05:49 -07004341 { USB_DEVICE_WACOM(0x30E) },
Benjamin Tissoires29b47392014-07-24 12:52:23 -07004342 { USB_DEVICE_WACOM(0x314) },
4343 { USB_DEVICE_WACOM(0x315) },
4344 { USB_DEVICE_WACOM(0x317) },
Benjamin Tissoires8c97a762015-02-26 11:28:50 -05004345 { USB_DEVICE_WACOM(0x318) },
4346 { USB_DEVICE_WACOM(0x319) },
Ping Chengfefb3912014-11-11 12:52:08 -08004347 { USB_DEVICE_WACOM(0x323) },
Jason Gereckef7acb552015-10-13 10:03:49 -07004348 { USB_DEVICE_WACOM(0x325) },
4349 { USB_DEVICE_WACOM(0x326) },
Ping Cheng500d4162015-01-27 13:30:03 -08004350 { USB_DEVICE_WACOM(0x32A) },
4351 { USB_DEVICE_WACOM(0x32B) },
4352 { USB_DEVICE_WACOM(0x32C) },
Ping Chengfff00bf2014-12-04 18:23:04 -08004353 { USB_DEVICE_WACOM(0x32F) },
Aaron Skomra72b236d2015-08-20 16:05:17 -07004354 { USB_DEVICE_WACOM(0x331) },
Ping Chengb4bf2122015-03-25 17:08:13 -07004355 { USB_DEVICE_WACOM(0x333) },
4356 { USB_DEVICE_WACOM(0x335) },
Aaron Skomra007760c2015-04-16 15:01:14 -07004357 { USB_DEVICE_WACOM(0x336) },
Ping Chengeda01da2015-09-23 13:51:15 -07004358 { USB_DEVICE_WACOM(0x33B) },
4359 { USB_DEVICE_WACOM(0x33C) },
4360 { USB_DEVICE_WACOM(0x33D) },
4361 { USB_DEVICE_WACOM(0x33E) },
Ping Chenge1123fe2016-04-12 13:37:45 -07004362 { USB_DEVICE_WACOM(0x343) },
Jason Gerecke4922cd22017-01-25 12:08:37 -08004363 { BT_DEVICE_WACOM(0x360) },
4364 { BT_DEVICE_WACOM(0x361) },
Ping Chengedbe2652012-11-21 13:12:50 -08004365 { USB_DEVICE_WACOM(0x4001) },
Jason Gerecked51ddb22014-05-14 17:14:29 -07004366 { USB_DEVICE_WACOM(0x4004) },
4367 { USB_DEVICE_WACOM(0x5000) },
4368 { USB_DEVICE_WACOM(0x5002) },
Benjamin Tissoires00d6f2272014-12-01 11:52:39 -05004369 { USB_DEVICE_LENOVO(0x6004) },
Benjamin Tissoires7704ac92014-09-23 12:08:08 -04004370
4371 { USB_DEVICE_WACOM(HID_ANY_ID) },
Mika Westerbergeef23a82015-02-23 15:52:43 +02004372 { I2C_DEVICE_WACOM(HID_ANY_ID) },
Jason Gereckeb9e06252017-01-25 12:08:35 -08004373 { BT_DEVICE_WACOM(HID_ANY_ID) },
Ping Cheng3bea7332006-07-13 18:01:36 -07004374 { }
4375};
Benjamin Tissoires29b47392014-07-24 12:52:23 -07004376MODULE_DEVICE_TABLE(hid, wacom_ids);