blob: 4aa3de9f1163b30eb64b4304f285a4167aef0cf0 [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
Jason Gerecke282e4632017-01-26 09:06:22 -0800171 if (prox) {
172 pressure = (signed char)((data[7] << 1) | ((data[4] >> 2) & 1));
173 if (features->pressure_max > 255)
174 pressure = (pressure << 1) | ((data[4] >> 6) & 1);
175 pressure += (features->pressure_max + 1) / 2;
Jason Gerecke025bcc12015-08-03 10:18:10 -0700176
Jason Gerecke282e4632017-01-26 09:06:22 -0800177 input_report_abs(input, ABS_X, data[3] | (data[2] << 7) | ((data[1] & 0x03) << 14));
178 input_report_abs(input, ABS_Y, data[6] | (data[5] << 7) | ((data[4] & 0x03) << 14));
179 input_report_abs(input, ABS_PRESSURE, pressure);
Jason Gerecke025bcc12015-08-03 10:18:10 -0700180
Jason Gerecke282e4632017-01-26 09:06:22 -0800181 input_report_key(input, BTN_TOUCH, data[4] & 0x08);
182 input_report_key(input, BTN_STYLUS, data[4] & 0x10);
183 /* Only allow the stylus2 button to be reported for the pen tool. */
184 input_report_key(input, BTN_STYLUS2, (wacom->tool[0] == BTN_TOOL_PEN) && (data[4] & 0x20));
185 }
Jason Gerecke025bcc12015-08-03 10:18:10 -0700186
187 if (!prox)
188 wacom->id[0] = 0;
189 input_report_key(input, wacom->tool[0], prox);
190 input_report_abs(input, ABS_MISC, wacom->id[0]);
Ping Cheng3bea7332006-07-13 18:01:36 -0700191 return 1;
192}
193
Dmitry Torokhov95dd3b32010-03-19 22:18:15 -0700194static int wacom_ptu_irq(struct wacom_wac *wacom)
Ping Cheng3bea7332006-07-13 18:01:36 -0700195{
196 unsigned char *data = wacom->data;
Jason Gerecke2a6cdbd2015-06-15 18:01:45 -0700197 struct input_dev *input = wacom->pen_input;
Ping Cheng3bea7332006-07-13 18:01:36 -0700198
Ping Chengcad74702009-12-15 00:35:25 -0800199 if (data[0] != WACOM_REPORT_PENABLED) {
Dmitry Torokhoveb71d1b2012-05-02 00:13:38 -0700200 dev_dbg(input->dev.parent,
201 "%s: received unknown report #%d\n", __func__, data[0]);
Ping Cheng3bea7332006-07-13 18:01:36 -0700202 return 0;
203 }
204
Ping Cheng3bea7332006-07-13 18:01:36 -0700205 if (data[1] & 0x04) {
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700206 input_report_key(input, BTN_TOOL_RUBBER, data[1] & 0x20);
207 input_report_key(input, BTN_TOUCH, data[1] & 0x08);
Ping Chenge34b9d22008-05-05 11:36:41 -0400208 wacom->id[0] = ERASER_DEVICE_ID;
Ping Cheng3bea7332006-07-13 18:01:36 -0700209 } else {
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700210 input_report_key(input, BTN_TOOL_PEN, data[1] & 0x20);
211 input_report_key(input, BTN_TOUCH, data[1] & 0x01);
Ping Chenge34b9d22008-05-05 11:36:41 -0400212 wacom->id[0] = STYLUS_DEVICE_ID;
Ping Cheng3bea7332006-07-13 18:01:36 -0700213 }
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700214 input_report_abs(input, ABS_MISC, wacom->id[0]); /* report tool id */
Dmitry Torokhov252f7762010-03-19 22:33:38 -0700215 input_report_abs(input, ABS_X, le16_to_cpup((__le16 *)&data[2]));
216 input_report_abs(input, ABS_Y, le16_to_cpup((__le16 *)&data[4]));
217 input_report_abs(input, ABS_PRESSURE, le16_to_cpup((__le16 *)&data[6]));
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700218 input_report_key(input, BTN_STYLUS, data[1] & 0x02);
219 input_report_key(input, BTN_STYLUS2, data[1] & 0x10);
Ping Cheng3bea7332006-07-13 18:01:36 -0700220 return 1;
221}
222
Ping Chengc8f2edc2010-06-28 01:10:51 -0700223static int wacom_dtu_irq(struct wacom_wac *wacom)
224{
Jason Gerecke74b63412014-04-19 13:50:22 -0700225 unsigned char *data = wacom->data;
Jason Gerecke2a6cdbd2015-06-15 18:01:45 -0700226 struct input_dev *input = wacom->pen_input;
Jason Gerecke74b63412014-04-19 13:50:22 -0700227 int prox = data[1] & 0x20;
Ping Chengc8f2edc2010-06-28 01:10:51 -0700228
Dmitry Torokhoveb71d1b2012-05-02 00:13:38 -0700229 dev_dbg(input->dev.parent,
230 "%s: received report #%d", __func__, data[0]);
Ping Chengc8f2edc2010-06-28 01:10:51 -0700231
232 if (prox) {
233 /* Going into proximity select tool */
234 wacom->tool[0] = (data[1] & 0x0c) ? BTN_TOOL_RUBBER : BTN_TOOL_PEN;
235 if (wacom->tool[0] == BTN_TOOL_PEN)
236 wacom->id[0] = STYLUS_DEVICE_ID;
237 else
238 wacom->id[0] = ERASER_DEVICE_ID;
239 }
240 input_report_key(input, BTN_STYLUS, data[1] & 0x02);
241 input_report_key(input, BTN_STYLUS2, data[1] & 0x10);
242 input_report_abs(input, ABS_X, le16_to_cpup((__le16 *)&data[2]));
243 input_report_abs(input, ABS_Y, le16_to_cpup((__le16 *)&data[4]));
Jason Gerecke74b63412014-04-19 13:50:22 -0700244 input_report_abs(input, ABS_PRESSURE, ((data[7] & 0x01) << 8) | data[6]);
Ping Chengc8f2edc2010-06-28 01:10:51 -0700245 input_report_key(input, BTN_TOUCH, data[1] & 0x05);
246 if (!prox) /* out-prox */
247 wacom->id[0] = 0;
248 input_report_key(input, wacom->tool[0], prox);
249 input_report_abs(input, ABS_MISC, wacom->id[0]);
250 return 1;
251}
252
Ping Cheng497ab1f2014-01-20 20:18:04 -0800253static int wacom_dtus_irq(struct wacom_wac *wacom)
254{
255 char *data = wacom->data;
Jason Gerecke2a6cdbd2015-06-15 18:01:45 -0700256 struct input_dev *input = wacom->pen_input;
Ping Cheng497ab1f2014-01-20 20:18:04 -0800257 unsigned short prox, pressure = 0;
258
259 if (data[0] != WACOM_REPORT_DTUS && data[0] != WACOM_REPORT_DTUSPAD) {
260 dev_dbg(input->dev.parent,
261 "%s: received unknown report #%d", __func__, data[0]);
262 return 0;
263 } else if (data[0] == WACOM_REPORT_DTUSPAD) {
Benjamin Tissoires422b0312014-07-24 12:50:39 -0700264 input = wacom->pad_input;
Ping Cheng497ab1f2014-01-20 20:18:04 -0800265 input_report_key(input, BTN_0, (data[1] & 0x01));
266 input_report_key(input, BTN_1, (data[1] & 0x02));
267 input_report_key(input, BTN_2, (data[1] & 0x04));
268 input_report_key(input, BTN_3, (data[1] & 0x08));
269 input_report_abs(input, ABS_MISC,
270 data[1] & 0x0f ? PAD_DEVICE_ID : 0);
Ping Cheng497ab1f2014-01-20 20:18:04 -0800271 return 1;
272 } else {
273 prox = data[1] & 0x80;
274 if (prox) {
275 switch ((data[1] >> 3) & 3) {
276 case 1: /* Rubber */
277 wacom->tool[0] = BTN_TOOL_RUBBER;
278 wacom->id[0] = ERASER_DEVICE_ID;
279 break;
280
281 case 2: /* Pen */
282 wacom->tool[0] = BTN_TOOL_PEN;
283 wacom->id[0] = STYLUS_DEVICE_ID;
284 break;
285 }
286 }
287
288 input_report_key(input, BTN_STYLUS, data[1] & 0x20);
289 input_report_key(input, BTN_STYLUS2, data[1] & 0x40);
290 input_report_abs(input, ABS_X, get_unaligned_be16(&data[3]));
291 input_report_abs(input, ABS_Y, get_unaligned_be16(&data[5]));
292 pressure = ((data[1] & 0x03) << 8) | (data[2] & 0xff);
293 input_report_abs(input, ABS_PRESSURE, pressure);
294 input_report_key(input, BTN_TOUCH, pressure > 10);
295
296 if (!prox) /* out-prox */
297 wacom->id[0] = 0;
298 input_report_key(input, wacom->tool[0], prox);
299 input_report_abs(input, ABS_MISC, wacom->id[0]);
Ping Cheng497ab1f2014-01-20 20:18:04 -0800300 return 1;
301 }
302}
303
Dmitry Torokhov95dd3b32010-03-19 22:18:15 -0700304static int wacom_graphire_irq(struct wacom_wac *wacom)
Ping Cheng3bea7332006-07-13 18:01:36 -0700305{
Jason Childse33da8a2010-02-17 22:38:31 -0800306 struct wacom_features *features = &wacom->features;
Ping Cheng3bea7332006-07-13 18:01:36 -0700307 unsigned char *data = wacom->data;
Jason Gerecke2a6cdbd2015-06-15 18:01:45 -0700308 struct input_dev *input = wacom->pen_input;
Benjamin Tissoires38138102014-07-24 12:51:03 -0700309 struct input_dev *pad_input = wacom->pad_input;
Benjamin Tissoires387142b2014-08-06 13:52:56 -0700310 int battery_capacity, ps_connected;
Dmitry Torokhov252f7762010-03-19 22:33:38 -0700311 int prox;
Ping Cheng3b57ca02010-03-04 21:50:59 -0800312 int rw = 0;
313 int retval = 0;
Ping Cheng3bea7332006-07-13 18:01:36 -0700314
Benjamin Tissoires387142b2014-08-06 13:52:56 -0700315 if (features->type == GRAPHIRE_BT) {
316 if (data[0] != WACOM_REPORT_PENABLED_BT) {
317 dev_dbg(input->dev.parent,
318 "%s: received unknown report #%d\n", __func__,
319 data[0]);
320 goto exit;
321 }
322 } else if (data[0] != WACOM_REPORT_PENABLED) {
Dmitry Torokhoveb71d1b2012-05-02 00:13:38 -0700323 dev_dbg(input->dev.parent,
324 "%s: received unknown report #%d\n", __func__, data[0]);
Ping Cheng3b57ca02010-03-04 21:50:59 -0800325 goto exit;
Ping Cheng3bea7332006-07-13 18:01:36 -0700326 }
327
Ping Cheng3b57ca02010-03-04 21:50:59 -0800328 prox = data[1] & 0x80;
329 if (prox || wacom->id[0]) {
330 if (prox) {
331 switch ((data[1] >> 5) & 3) {
Ping Cheng3bea7332006-07-13 18:01:36 -0700332
333 case 0: /* Pen */
334 wacom->tool[0] = BTN_TOOL_PEN;
Ping Chenge34b9d22008-05-05 11:36:41 -0400335 wacom->id[0] = STYLUS_DEVICE_ID;
Ping Cheng3bea7332006-07-13 18:01:36 -0700336 break;
337
338 case 1: /* Rubber */
339 wacom->tool[0] = BTN_TOOL_RUBBER;
Ping Chenge34b9d22008-05-05 11:36:41 -0400340 wacom->id[0] = ERASER_DEVICE_ID;
Ping Cheng3bea7332006-07-13 18:01:36 -0700341 break;
342
343 case 2: /* Mouse with wheel */
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700344 input_report_key(input, BTN_MIDDLE, data[1] & 0x04);
Ping Cheng3bea7332006-07-13 18:01:36 -0700345 /* fall through */
346
347 case 3: /* Mouse without wheel */
348 wacom->tool[0] = BTN_TOOL_MOUSE;
Ping Chenge34b9d22008-05-05 11:36:41 -0400349 wacom->id[0] = CURSOR_DEVICE_ID;
Ping Cheng3bea7332006-07-13 18:01:36 -0700350 break;
Ping Cheng3b57ca02010-03-04 21:50:59 -0800351 }
Ping Cheng3bea7332006-07-13 18:01:36 -0700352 }
Dmitry Torokhov252f7762010-03-19 22:33:38 -0700353 input_report_abs(input, ABS_X, le16_to_cpup((__le16 *)&data[2]));
354 input_report_abs(input, ABS_Y, le16_to_cpup((__le16 *)&data[4]));
Ping Cheng3bea7332006-07-13 18:01:36 -0700355 if (wacom->tool[0] != BTN_TOOL_MOUSE) {
Benjamin Tissoires387142b2014-08-06 13:52:56 -0700356 if (features->type == GRAPHIRE_BT)
357 input_report_abs(input, ABS_PRESSURE, data[6] |
358 (((__u16) (data[1] & 0x08)) << 5));
359 else
360 input_report_abs(input, ABS_PRESSURE, data[6] |
361 ((data[7] & 0x03) << 8));
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700362 input_report_key(input, BTN_TOUCH, data[1] & 0x01);
363 input_report_key(input, BTN_STYLUS, data[1] & 0x02);
364 input_report_key(input, BTN_STYLUS2, data[1] & 0x04);
Dmitry Torokhovafb567e2010-04-13 23:08:58 -0700365 } else {
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700366 input_report_key(input, BTN_LEFT, data[1] & 0x01);
367 input_report_key(input, BTN_RIGHT, data[1] & 0x02);
Ping Cheng3b57ca02010-03-04 21:50:59 -0800368 if (features->type == WACOM_G4 ||
369 features->type == WACOM_MO) {
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700370 input_report_abs(input, ABS_DISTANCE, data[6] & 0x3f);
Mike Autyd9f66c12010-08-28 20:35:17 -0700371 rw = (data[7] & 0x04) - (data[7] & 0x03);
Benjamin Tissoires387142b2014-08-06 13:52:56 -0700372 } else if (features->type == GRAPHIRE_BT) {
373 /* Compute distance between mouse and tablet */
374 rw = 44 - (data[6] >> 2);
375 rw = clamp_val(rw, 0, 31);
376 input_report_abs(input, ABS_DISTANCE, rw);
377 if (((data[1] >> 5) & 3) == 2) {
378 /* Mouse with wheel */
379 input_report_key(input, BTN_MIDDLE,
380 data[1] & 0x04);
381 rw = (data[6] & 0x01) ? -1 :
382 (data[6] & 0x02) ? 1 : 0;
383 } else {
384 rw = 0;
385 }
Ping Cheng3b57ca02010-03-04 21:50:59 -0800386 } else {
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700387 input_report_abs(input, ABS_DISTANCE, data[7] & 0x3f);
Mike Autyd9f66c12010-08-28 20:35:17 -0700388 rw = -(signed char)data[6];
Ping Cheng3b57ca02010-03-04 21:50:59 -0800389 }
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700390 input_report_rel(input, REL_WHEEL, rw);
Dmitry Torokhovafb567e2010-04-13 23:08:58 -0700391 }
Ping Cheng3b57ca02010-03-04 21:50:59 -0800392
393 if (!prox)
394 wacom->id[0] = 0;
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700395 input_report_abs(input, ABS_MISC, wacom->id[0]); /* report tool id */
396 input_report_key(input, wacom->tool[0], prox);
397 input_sync(input); /* sync last event */
Ping Cheng80d4e8e2007-02-23 12:22:48 -0800398 }
Ping Cheng3bea7332006-07-13 18:01:36 -0700399
400 /* send pad data */
Jason Childse33da8a2010-02-17 22:38:31 -0800401 switch (features->type) {
Dmitry Torokhov73a97f42010-03-19 22:18:15 -0700402 case WACOM_G4:
Ping Cheng3b57ca02010-03-04 21:50:59 -0800403 prox = data[7] & 0xf8;
404 if (prox || wacom->id[1]) {
Ping Chenge34b9d22008-05-05 11:36:41 -0400405 wacom->id[1] = PAD_DEVICE_ID;
Benjamin Tissoires38138102014-07-24 12:51:03 -0700406 input_report_key(pad_input, BTN_BACK, (data[7] & 0x40));
407 input_report_key(pad_input, BTN_FORWARD, (data[7] & 0x80));
Ping Cheng3bea7332006-07-13 18:01:36 -0700408 rw = ((data[7] & 0x18) >> 3) - ((data[7] & 0x20) >> 3);
Benjamin Tissoires38138102014-07-24 12:51:03 -0700409 input_report_rel(pad_input, REL_WHEEL, rw);
Ping Cheng3b57ca02010-03-04 21:50:59 -0800410 if (!prox)
411 wacom->id[1] = 0;
Benjamin Tissoires38138102014-07-24 12:51:03 -0700412 input_report_abs(pad_input, ABS_MISC, wacom->id[1]);
Ping Chengab687b12010-04-05 23:07:41 -0700413 retval = 1;
Ping Cheng3bea7332006-07-13 18:01:36 -0700414 }
Ping Cheng7ecfbfd2007-06-14 23:32:48 -0400415 break;
Dmitry Torokhov73a97f42010-03-19 22:18:15 -0700416
417 case WACOM_MO:
Ping Cheng3b57ca02010-03-04 21:50:59 -0800418 prox = (data[7] & 0xf8) || data[8];
419 if (prox || wacom->id[1]) {
Ping Chenge34b9d22008-05-05 11:36:41 -0400420 wacom->id[1] = PAD_DEVICE_ID;
Benjamin Tissoires38138102014-07-24 12:51:03 -0700421 input_report_key(pad_input, BTN_BACK, (data[7] & 0x08));
422 input_report_key(pad_input, BTN_LEFT, (data[7] & 0x20));
423 input_report_key(pad_input, BTN_FORWARD, (data[7] & 0x10));
424 input_report_key(pad_input, BTN_RIGHT, (data[7] & 0x40));
425 input_report_abs(pad_input, ABS_WHEEL, (data[8] & 0x7f));
Ping Cheng3b57ca02010-03-04 21:50:59 -0800426 if (!prox)
427 wacom->id[1] = 0;
Benjamin Tissoires38138102014-07-24 12:51:03 -0700428 input_report_abs(pad_input, ABS_MISC, wacom->id[1]);
Ping Cheng84460012011-07-06 18:05:43 -0700429 retval = 1;
Ping Cheng7ecfbfd2007-06-14 23:32:48 -0400430 }
431 break;
Benjamin Tissoires387142b2014-08-06 13:52:56 -0700432 case GRAPHIRE_BT:
433 prox = data[7] & 0x03;
434 if (prox || wacom->id[1]) {
435 wacom->id[1] = PAD_DEVICE_ID;
436 input_report_key(pad_input, BTN_0, (data[7] & 0x02));
437 input_report_key(pad_input, BTN_1, (data[7] & 0x01));
438 if (!prox)
439 wacom->id[1] = 0;
440 input_report_abs(pad_input, ABS_MISC, wacom->id[1]);
441 retval = 1;
442 }
443 break;
444 }
445
446 /* Store current battery capacity and power supply state */
447 if (features->type == GRAPHIRE_BT) {
448 rw = (data[7] >> 2 & 0x07);
449 battery_capacity = batcap_gr[rw];
450 ps_connected = rw == 7;
Jason Gerecke953f2c52015-03-06 11:47:39 -0800451 wacom_notify_battery(wacom, battery_capacity, ps_connected,
Jason Gerecke71fa6412015-03-11 10:25:41 -0700452 1, ps_connected);
Ping Cheng3bea7332006-07-13 18:01:36 -0700453 }
Ping Cheng3b57ca02010-03-04 21:50:59 -0800454exit:
455 return retval;
Ping Cheng3bea7332006-07-13 18:01:36 -0700456}
457
Benjamin Tissoires5fcad162015-03-05 17:36:54 -0500458static void wacom_intuos_schedule_prox_event(struct wacom_wac *wacom_wac)
459{
460 struct wacom *wacom = container_of(wacom_wac, struct wacom, wacom_wac);
Jason Gerecke0bbfe282016-01-06 13:25:53 -0800461 struct wacom_features *features = &wacom_wac->features;
Benjamin Tissoires5fcad162015-03-05 17:36:54 -0500462 struct hid_report *r;
463 struct hid_report_enum *re;
464
465 re = &(wacom->hdev->report_enum[HID_FEATURE_REPORT]);
Jason Gerecke0bbfe282016-01-06 13:25:53 -0800466 if (features->type == INTUOSHT2)
467 r = re->report_id_hash[WACOM_REPORT_INTUOSHT2_ID];
468 else
469 r = re->report_id_hash[WACOM_REPORT_INTUOS_ID1];
Benjamin Tissoires5fcad162015-03-05 17:36:54 -0500470 if (r) {
471 hid_hw_request(wacom->hdev, r, HID_REQ_GET_REPORT);
472 }
473}
474
Jason Gereckefb013a02015-11-30 17:13:46 -0800475static int wacom_intuos_pad(struct wacom_wac *wacom)
476{
477 struct wacom_features *features = &wacom->features;
478 unsigned char *data = wacom->data;
479 struct input_dev *input = wacom->pad_input;
Jason Gereckec7f05222015-11-30 17:13:47 -0800480 int i;
481 int buttons = 0, nbuttons = features->numbered_buttons;
482 int keys = 0, nkeys = 0;
483 int ring1 = 0, ring2 = 0;
484 int strip1 = 0, strip2 = 0;
485 bool prox = false;
Jason Gereckefb013a02015-11-30 17:13:46 -0800486
487 /* pad packets. Works as a second tool and is always in prox */
488 if (!(data[0] == WACOM_REPORT_INTUOSPAD || data[0] == WACOM_REPORT_INTUOS5PAD ||
489 data[0] == WACOM_REPORT_CINTIQPAD))
490 return 0;
491
492 if (features->type >= INTUOS4S && features->type <= INTUOS4L) {
Jason Gereckec7f05222015-11-30 17:13:47 -0800493 buttons = (data[3] << 1) | (data[2] & 0x01);
494 ring1 = data[1];
Jason Gereckefb013a02015-11-30 17:13:46 -0800495 } else if (features->type == DTK) {
Jason Gereckec7f05222015-11-30 17:13:47 -0800496 buttons = data[6];
Jason Gereckefb013a02015-11-30 17:13:46 -0800497 } else if (features->type == WACOM_13HD) {
Jason Gereckec7f05222015-11-30 17:13:47 -0800498 buttons = (data[4] << 1) | (data[3] & 0x01);
Jason Gereckefb013a02015-11-30 17:13:46 -0800499 } else if (features->type == WACOM_24HD) {
Jason Gereckec7f05222015-11-30 17:13:47 -0800500 buttons = (data[8] << 8) | data[6];
501 ring1 = data[1];
502 ring2 = data[2];
Jason Gereckefb013a02015-11-30 17:13:46 -0800503
504 /*
505 * Three "buttons" are available on the 24HD which are
506 * physically implemented as a touchstrip. Each button
507 * is approximately 3 bits wide with a 2 bit spacing.
508 * The raw touchstrip bits are stored at:
509 * ((data[3] & 0x1f) << 8) | data[4])
510 */
Jason Gereckec7f05222015-11-30 17:13:47 -0800511 nkeys = 3;
512 keys = ((data[3] & 0x1C) ? 1<<2 : 0) |
513 ((data[4] & 0xE0) ? 1<<1 : 0) |
514 ((data[4] & 0x07) ? 1<<0 : 0);
Jason Gereckefb013a02015-11-30 17:13:46 -0800515 } else if (features->type == WACOM_27QHD) {
Jason Gereckec7f05222015-11-30 17:13:47 -0800516 nkeys = 3;
517 keys = data[2] & 0x07;
Jason Gereckefb013a02015-11-30 17:13:46 -0800518
519 input_report_abs(input, ABS_X, be16_to_cpup((__be16 *)&data[4]));
520 input_report_abs(input, ABS_Y, be16_to_cpup((__be16 *)&data[6]));
521 input_report_abs(input, ABS_Z, be16_to_cpup((__be16 *)&data[8]));
Jason Gereckefb013a02015-11-30 17:13:46 -0800522 } else if (features->type == CINTIQ_HYBRID) {
523 /*
524 * Do not send hardware buttons under Android. They
525 * are already sent to the system through GPIO (and
526 * have different meaning).
Jason Gereckec7f05222015-11-30 17:13:47 -0800527 *
528 * d-pad right -> data[4] & 0x10
529 * d-pad up -> data[4] & 0x20
530 * d-pad left -> data[4] & 0x40
531 * d-pad down -> data[4] & 0x80
532 * d-pad center -> data[3] & 0x01
Jason Gereckefb013a02015-11-30 17:13:46 -0800533 */
Jason Gereckec7f05222015-11-30 17:13:47 -0800534 buttons = (data[4] << 1) | (data[3] & 0x01);
Jason Gereckefb013a02015-11-30 17:13:46 -0800535 } else if (features->type == CINTIQ_COMPANION_2) {
Jason Gereckec7f05222015-11-30 17:13:47 -0800536 /* d-pad right -> data[4] & 0x10
537 * d-pad up -> data[4] & 0x20
538 * d-pad left -> data[4] & 0x40
539 * d-pad down -> data[4] & 0x80
540 * d-pad center -> data[3] & 0x01
541 */
Jason Gerecke0402b6b2015-12-16 13:37:36 -0800542 buttons = ((data[2] >> 4) << 7) |
Jason Gereckec7f05222015-11-30 17:13:47 -0800543 ((data[1] & 0x04) << 6) |
544 ((data[2] & 0x0F) << 2) |
545 (data[1] & 0x03);
Jason Gereckefb013a02015-11-30 17:13:46 -0800546 } else if (features->type >= INTUOS5S && features->type <= INTUOSPL) {
Jason Gereckefb013a02015-11-30 17:13:46 -0800547 /*
548 * ExpressKeys on Intuos5/Intuos Pro have a capacitive sensor in
549 * addition to the mechanical switch. Switch data is
550 * stored in data[4], capacitive data in data[5].
Jason Gereckec7f05222015-11-30 17:13:47 -0800551 *
552 * Touch ring mode switch (data[3]) has no capacitive sensor
Jason Gereckefb013a02015-11-30 17:13:46 -0800553 */
Jason Gereckec7f05222015-11-30 17:13:47 -0800554 buttons = (data[4] << 1) | (data[3] & 0x01);
555 ring1 = data[2];
Jason Gereckefb013a02015-11-30 17:13:46 -0800556 } else {
557 if (features->type == WACOM_21UX2 || features->type == WACOM_22HD) {
Jason Gereckec7f05222015-11-30 17:13:47 -0800558 buttons = (data[8] << 10) | ((data[7] & 0x01) << 9) |
559 (data[6] << 1) | (data[5] & 0x01);
Jason Gereckefb013a02015-11-30 17:13:46 -0800560
561 if (features->type == WACOM_22HD) {
Jason Gereckec7f05222015-11-30 17:13:47 -0800562 nkeys = 3;
563 keys = data[9] & 0x07;
Jason Gereckefb013a02015-11-30 17:13:46 -0800564 }
565 } else {
Jason Gereckec7f05222015-11-30 17:13:47 -0800566 buttons = ((data[6] & 0x10) << 10) |
567 ((data[5] & 0x10) << 9) |
568 ((data[6] & 0x0F) << 4) |
569 (data[5] & 0x0F);
Jason Gereckefb013a02015-11-30 17:13:46 -0800570 }
Jason Gereckef73d08d2015-12-16 13:37:33 -0800571 strip1 = ((data[1] & 0x1f) << 8) | data[2];
572 strip2 = ((data[3] & 0x1f) << 8) | data[4];
Jason Gereckefb013a02015-11-30 17:13:46 -0800573 }
Jason Gereckec7f05222015-11-30 17:13:47 -0800574
Dan Carpenter8f9cfdd2015-12-09 13:22:05 +0300575 prox = (buttons & ~(~0 << nbuttons)) | (keys & ~(~0 << nkeys)) |
576 (ring1 & 0x80) | (ring2 & 0x80) | strip1 | strip2;
Jason Gereckec7f05222015-11-30 17:13:47 -0800577
578 wacom_report_numbered_buttons(input, nbuttons, buttons);
579
580 for (i = 0; i < nkeys; i++)
581 input_report_key(input, KEY_PROG1 + i, keys & (1 << i));
582
583 input_report_abs(input, ABS_RX, strip1);
Jason Gerecke03a0dc52015-12-16 13:37:34 -0800584 input_report_abs(input, ABS_RY, strip2);
Jason Gereckec7f05222015-11-30 17:13:47 -0800585
Jason Gereckeaaae03e2015-12-16 13:37:35 -0800586 input_report_abs(input, ABS_WHEEL, (ring1 & 0x80) ? (ring1 & 0x7f) : 0);
587 input_report_abs(input, ABS_THROTTLE, (ring2 & 0x80) ? (ring2 & 0x7f) : 0);
Jason Gereckec7f05222015-11-30 17:13:47 -0800588
589 input_report_key(input, wacom->tool[1], prox ? 1 : 0);
590 input_report_abs(input, ABS_MISC, prox ? PAD_DEVICE_ID : 0);
591
592 input_event(input, EV_MSC, MSC_SERIAL, 0xffffffff);
593
Jason Gereckefb013a02015-11-30 17:13:46 -0800594 return 1;
595}
596
Jason Gerecke82527da2016-10-19 18:03:47 -0700597static int wacom_intuos_id_mangle(int tool_id)
598{
599 return (tool_id & ~0xFFF) << 4 | (tool_id & 0xFFF);
600}
601
Benjamin Tissoires7e129782016-02-12 17:27:40 +0100602static int wacom_intuos_get_tool_type(int tool_id)
603{
604 int tool_type;
605
606 switch (tool_id) {
607 case 0x812: /* Inking pen */
608 case 0x801: /* Intuos3 Inking pen */
Jason Gerecke82527da2016-10-19 18:03:47 -0700609 case 0x12802: /* Intuos4/5 Inking Pen */
Benjamin Tissoires7e129782016-02-12 17:27:40 +0100610 case 0x012:
611 tool_type = BTN_TOOL_PENCIL;
612 break;
613
614 case 0x822: /* Pen */
615 case 0x842:
616 case 0x852:
617 case 0x823: /* Intuos3 Grip Pen */
618 case 0x813: /* Intuos3 Classic Pen */
619 case 0x885: /* Intuos3 Marker Pen */
620 case 0x802: /* Intuos4/5 13HD/24HD General Pen */
621 case 0x804: /* Intuos4/5 13HD/24HD Marker Pen */
622 case 0x8e2: /* IntuosHT2 pen */
623 case 0x022:
Jason Gerecke82527da2016-10-19 18:03:47 -0700624 case 0x10804: /* Intuos4/5 13HD/24HD Art Pen */
625 case 0x14802: /* Intuos4/5 13HD/24HD Classic Pen */
626 case 0x16802: /* Cintiq 13HD Pro Pen */
627 case 0x18802: /* DTH2242 Pen */
628 case 0x10802: /* Intuos4/5 13HD/24HD General Pen */
Benjamin Tissoires7e129782016-02-12 17:27:40 +0100629 tool_type = BTN_TOOL_PEN;
630 break;
631
632 case 0x832: /* Stroke pen */
633 case 0x032:
634 tool_type = BTN_TOOL_BRUSH;
635 break;
636
637 case 0x007: /* Mouse 4D and 2D */
638 case 0x09c:
639 case 0x094:
640 case 0x017: /* Intuos3 2D Mouse */
641 case 0x806: /* Intuos4 Mouse */
642 tool_type = BTN_TOOL_MOUSE;
643 break;
644
645 case 0x096: /* Lens cursor */
646 case 0x097: /* Intuos3 Lens cursor */
647 case 0x006: /* Intuos4 Lens cursor */
648 tool_type = BTN_TOOL_LENS;
649 break;
650
651 case 0x82a: /* Eraser */
Jason Gerecke9ce9a122016-11-11 15:05:52 -0800652 case 0x84a:
Benjamin Tissoires7e129782016-02-12 17:27:40 +0100653 case 0x85a:
654 case 0x91a:
655 case 0xd1a:
656 case 0x0fa:
657 case 0x82b: /* Intuos3 Grip Pen Eraser */
658 case 0x81b: /* Intuos3 Classic Pen Eraser */
659 case 0x91b: /* Intuos3 Airbrush Eraser */
660 case 0x80c: /* Intuos4/5 13HD/24HD Marker Pen Eraser */
661 case 0x80a: /* Intuos4/5 13HD/24HD General Pen Eraser */
662 case 0x90a: /* Intuos4/5 13HD/24HD Airbrush Eraser */
Jason Gerecke82527da2016-10-19 18:03:47 -0700663 case 0x1480a: /* Intuos4/5 13HD/24HD Classic Pen Eraser */
664 case 0x1090a: /* Intuos4/5 13HD/24HD Airbrush Eraser */
665 case 0x1080c: /* Intuos4/5 13HD/24HD Art Pen Eraser */
666 case 0x1680a: /* Cintiq 13HD Pro Pen Eraser */
667 case 0x1880a: /* DTH2242 Eraser */
668 case 0x1080a: /* Intuos4/5 13HD/24HD General Pen Eraser */
Benjamin Tissoires7e129782016-02-12 17:27:40 +0100669 tool_type = BTN_TOOL_RUBBER;
670 break;
671
672 case 0xd12:
673 case 0x912:
674 case 0x112:
675 case 0x913: /* Intuos3 Airbrush */
676 case 0x902: /* Intuos4/5 13HD/24HD Airbrush */
Jason Gerecke82527da2016-10-19 18:03:47 -0700677 case 0x10902: /* Intuos4/5 13HD/24HD Airbrush */
Benjamin Tissoires7e129782016-02-12 17:27:40 +0100678 tool_type = BTN_TOOL_AIRBRUSH;
679 break;
680
681 default: /* Unknown tool */
682 tool_type = BTN_TOOL_PEN;
683 break;
684 }
685 return tool_type;
686}
687
Dmitry Torokhov95dd3b32010-03-19 22:18:15 -0700688static int wacom_intuos_inout(struct wacom_wac *wacom)
Ping Cheng3bea7332006-07-13 18:01:36 -0700689{
Jason Childse33da8a2010-02-17 22:38:31 -0800690 struct wacom_features *features = &wacom->features;
Ping Cheng3bea7332006-07-13 18:01:36 -0700691 unsigned char *data = wacom->data;
Jason Gerecke2a6cdbd2015-06-15 18:01:45 -0700692 struct input_dev *input = wacom->pen_input;
Ping Cheng4750f5f2016-01-08 17:15:48 -0800693 int idx = (features->type == INTUOS) ? (data[1] & 0x01) : 0;
Ping Cheng3bea7332006-07-13 18:01:36 -0700694
Ping Cheng4750f5f2016-01-08 17:15:48 -0800695 if (!(((data[1] & 0xfc) == 0xc0) || /* in prox */
696 ((data[1] & 0xfe) == 0x20) || /* in range */
697 ((data[1] & 0xfe) == 0x80))) /* out prox */
698 return 0;
Ping Cheng3bea7332006-07-13 18:01:36 -0700699
700 /* Enter report */
701 if ((data[1] & 0xfc) == 0xc0) {
702 /* serial number of the tool */
703 wacom->serial[idx] = ((data[3] & 0x0f) << 28) +
704 (data[4] << 20) + (data[5] << 12) +
705 (data[6] << 4) + (data[7] >> 4);
706
Ping Cheng493630b2010-06-22 11:21:34 -0700707 wacom->id[idx] = (data[2] << 4) | (data[3] >> 4) |
Jason Gerecke82527da2016-10-19 18:03:47 -0700708 ((data[7] & 0x0f) << 16) | ((data[8] & 0xf0) << 8);
Dmitry Torokhov73a97f42010-03-19 22:18:15 -0700709
Benjamin Tissoires7e129782016-02-12 17:27:40 +0100710 wacom->tool[idx] = wacom_intuos_get_tool_type(wacom->id[idx]);
Dmitry Torokhov73a97f42010-03-19 22:18:15 -0700711
Ping Chengeff6ca92016-05-02 21:17:34 -0700712 wacom->shared->stylus_in_proximity = true;
Ping Cheng3bea7332006-07-13 18:01:36 -0700713 return 1;
714 }
715
Ping Chengc1b03f52016-01-08 17:16:06 -0800716 /* in Range */
717 if ((data[1] & 0xfe) == 0x20) {
Ping Cheng526d6e72016-01-08 17:16:25 -0800718 if (features->type != INTUOSHT2)
719 wacom->shared->stylus_in_proximity = true;
Ping Cheng486b9082015-02-20 14:25:58 -0800720
Ping Chengc1b03f52016-01-08 17:16:06 -0800721 /* in Range while exiting */
722 if (wacom->reporting_data) {
723 input_report_key(input, BTN_TOUCH, 0);
724 input_report_abs(input, ABS_PRESSURE, 0);
725 input_report_abs(input, ABS_DISTANCE, wacom->features.distance_max);
726 return 2;
727 }
728 return 1;
Jason Gerecke4eb18302013-09-20 09:48:46 -0700729 }
730
Ping Cheng3bea7332006-07-13 18:01:36 -0700731 /* Exit report */
732 if ((data[1] & 0xfe) == 0x80) {
Ping Chengf3586d22015-03-20 14:57:00 -0700733 wacom->shared->stylus_in_proximity = false;
Ping Chengb3bd7ef2015-01-09 11:05:13 -0800734 wacom->reporting_data = false;
Jason Gereckeae584ca2012-04-03 15:50:40 -0700735
Ping Cheng373a5352015-01-09 11:04:50 -0800736 /* don't report exit if we don't know the ID */
737 if (!wacom->id[idx])
738 return 1;
739
Ping Cheng6f660f12009-05-08 18:30:33 -0700740 /*
741 * Reset all states otherwise we lose the initial states
742 * when in-prox next time
743 */
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700744 input_report_abs(input, ABS_X, 0);
745 input_report_abs(input, ABS_Y, 0);
746 input_report_abs(input, ABS_DISTANCE, 0);
747 input_report_abs(input, ABS_TILT_X, 0);
748 input_report_abs(input, ABS_TILT_Y, 0);
Ping Cheng80d4e8e2007-02-23 12:22:48 -0800749 if (wacom->tool[idx] >= BTN_TOOL_MOUSE) {
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700750 input_report_key(input, BTN_LEFT, 0);
751 input_report_key(input, BTN_MIDDLE, 0);
752 input_report_key(input, BTN_RIGHT, 0);
753 input_report_key(input, BTN_SIDE, 0);
754 input_report_key(input, BTN_EXTRA, 0);
755 input_report_abs(input, ABS_THROTTLE, 0);
756 input_report_abs(input, ABS_RZ, 0);
Ping Cheng7ecfbfd2007-06-14 23:32:48 -0400757 } else {
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700758 input_report_abs(input, ABS_PRESSURE, 0);
759 input_report_key(input, BTN_STYLUS, 0);
760 input_report_key(input, BTN_STYLUS2, 0);
761 input_report_key(input, BTN_TOUCH, 0);
762 input_report_abs(input, ABS_WHEEL, 0);
Jason Childse33da8a2010-02-17 22:38:31 -0800763 if (features->type >= INTUOS3S)
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700764 input_report_abs(input, ABS_Z, 0);
Ping Cheng8d32e3a2006-09-26 13:34:47 -0700765 }
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700766 input_report_key(input, wacom->tool[idx], 0);
767 input_report_abs(input, ABS_MISC, 0); /* reset tool id */
768 input_event(input, EV_MSC, MSC_SERIAL, wacom->serial[idx]);
Ping Cheng6f660f12009-05-08 18:30:33 -0700769 wacom->id[idx] = 0;
Ping Cheng80d4e8e2007-02-23 12:22:48 -0800770 return 2;
Ping Cheng3bea7332006-07-13 18:01:36 -0700771 }
Ping Cheng373a5352015-01-09 11:04:50 -0800772
Ping Cheng3bea7332006-07-13 18:01:36 -0700773 return 0;
774}
775
Aaron Skomra72b236d2015-08-20 16:05:17 -0700776static int wacom_remote_irq(struct wacom_wac *wacom_wac, size_t len)
777{
778 unsigned char *data = wacom_wac->data;
Benjamin Tissoires7c35dc32016-07-13 18:06:07 +0200779 struct input_dev *input;
Aaron Skomra72b236d2015-08-20 16:05:17 -0700780 struct wacom *wacom = container_of(wacom_wac, struct wacom, wacom_wac);
Benjamin Tissoires83e6b402016-07-13 18:06:02 +0200781 struct wacom_remote *remote = wacom->remote;
Aaron Skomra72b236d2015-08-20 16:05:17 -0700782 int bat_charging, bat_percent, touch_ring_mode;
783 __u32 serial;
Benjamin Tissoires7c35dc32016-07-13 18:06:07 +0200784 int i, index = -1;
785 unsigned long flags;
Aaron Skomra72b236d2015-08-20 16:05:17 -0700786
787 if (data[0] != WACOM_REPORT_REMOTE) {
Benjamin Tissoires7c35dc32016-07-13 18:06:07 +0200788 hid_dbg(wacom->hdev, "%s: received unknown report #%d",
789 __func__, data[0]);
Aaron Skomra72b236d2015-08-20 16:05:17 -0700790 return 0;
791 }
792
793 serial = data[3] + (data[4] << 8) + (data[5] << 16);
794 wacom_wac->id[0] = PAD_DEVICE_ID;
795
Benjamin Tissoires7c35dc32016-07-13 18:06:07 +0200796 spin_lock_irqsave(&remote->remote_lock, flags);
797
798 for (i = 0; i < WACOM_MAX_REMOTES; i++) {
799 if (remote->remotes[i].serial == serial) {
800 index = i;
801 break;
802 }
803 }
804
805 if (index < 0 || !remote->remotes[index].registered)
806 goto out;
807
808 input = remote->remotes[index].input;
809
Aaron Skomra72b236d2015-08-20 16:05:17 -0700810 input_report_key(input, BTN_0, (data[9] & 0x01));
811 input_report_key(input, BTN_1, (data[9] & 0x02));
812 input_report_key(input, BTN_2, (data[9] & 0x04));
813 input_report_key(input, BTN_3, (data[9] & 0x08));
814 input_report_key(input, BTN_4, (data[9] & 0x10));
815 input_report_key(input, BTN_5, (data[9] & 0x20));
816 input_report_key(input, BTN_6, (data[9] & 0x40));
817 input_report_key(input, BTN_7, (data[9] & 0x80));
818
819 input_report_key(input, BTN_8, (data[10] & 0x01));
820 input_report_key(input, BTN_9, (data[10] & 0x02));
821 input_report_key(input, BTN_A, (data[10] & 0x04));
822 input_report_key(input, BTN_B, (data[10] & 0x08));
823 input_report_key(input, BTN_C, (data[10] & 0x10));
824 input_report_key(input, BTN_X, (data[10] & 0x20));
825 input_report_key(input, BTN_Y, (data[10] & 0x40));
826 input_report_key(input, BTN_Z, (data[10] & 0x80));
827
828 input_report_key(input, BTN_BASE, (data[11] & 0x01));
829 input_report_key(input, BTN_BASE2, (data[11] & 0x02));
830
831 if (data[12] & 0x80)
832 input_report_abs(input, ABS_WHEEL, (data[12] & 0x7f));
833 else
834 input_report_abs(input, ABS_WHEEL, 0);
835
836 bat_percent = data[7] & 0x7f;
837 bat_charging = !!(data[7] & 0x80);
838
839 if (data[9] | data[10] | (data[11] & 0x03) | data[12])
840 input_report_abs(input, ABS_MISC, PAD_DEVICE_ID);
841 else
842 input_report_abs(input, ABS_MISC, 0);
843
844 input_event(input, EV_MSC, MSC_SERIAL, serial);
845
Benjamin Tissoires7c35dc32016-07-13 18:06:07 +0200846 input_sync(input);
847
Aaron Skomra72b236d2015-08-20 16:05:17 -0700848 /*Which mode select (LED light) is currently on?*/
849 touch_ring_mode = (data[11] & 0xC0) >> 6;
850
851 for (i = 0; i < WACOM_MAX_REMOTES; i++) {
Benjamin Tissoirese7749f62016-07-13 18:06:06 +0200852 if (remote->remotes[i].serial == serial)
Benjamin Tissoiresa50aac72016-07-13 18:06:00 +0200853 wacom->led.groups[i].select = touch_ring_mode;
Aaron Skomra72b236d2015-08-20 16:05:17 -0700854 }
855
Benjamin Tissoires59d69bc2016-07-13 18:06:08 +0200856 __wacom_notify_battery(&remote->remotes[index].battery, bat_percent,
857 bat_charging, 1, bat_charging);
Aaron Skomra72b236d2015-08-20 16:05:17 -0700858
Benjamin Tissoires7c35dc32016-07-13 18:06:07 +0200859out:
860 spin_unlock_irqrestore(&remote->remote_lock, flags);
861 return 0;
Aaron Skomra72b236d2015-08-20 16:05:17 -0700862}
863
Benjamin Tissoirese6f28132016-07-13 18:06:01 +0200864static void wacom_remote_status_irq(struct wacom_wac *wacom_wac, size_t len)
Aaron Skomra72b236d2015-08-20 16:05:17 -0700865{
866 struct wacom *wacom = container_of(wacom_wac, struct wacom, wacom_wac);
867 unsigned char *data = wacom_wac->data;
Benjamin Tissoires83e6b402016-07-13 18:06:02 +0200868 struct wacom_remote *remote = wacom->remote;
Benjamin Tissoirese6f28132016-07-13 18:06:01 +0200869 struct wacom_remote_data remote_data;
870 unsigned long flags;
871 int i, ret;
Aaron Skomra72b236d2015-08-20 16:05:17 -0700872
873 if (data[0] != WACOM_REPORT_DEVICE_LIST)
Benjamin Tissoirese6f28132016-07-13 18:06:01 +0200874 return;
875
876 memset(&remote_data, 0, sizeof(struct wacom_remote_data));
Aaron Skomra72b236d2015-08-20 16:05:17 -0700877
878 for (i = 0; i < WACOM_MAX_REMOTES; i++) {
879 int j = i * 6;
880 int serial = (data[j+6] << 16) + (data[j+5] << 8) + data[j+4];
881 bool connected = data[j+2];
882
Benjamin Tissoirese6f28132016-07-13 18:06:01 +0200883 remote_data.remote[i].serial = serial;
884 remote_data.remote[i].connected = connected;
Aaron Skomra72b236d2015-08-20 16:05:17 -0700885 }
886
Benjamin Tissoires83e6b402016-07-13 18:06:02 +0200887 spin_lock_irqsave(&remote->remote_lock, flags);
Benjamin Tissoirese6f28132016-07-13 18:06:01 +0200888
Benjamin Tissoires83e6b402016-07-13 18:06:02 +0200889 ret = kfifo_in(&remote->remote_fifo, &remote_data, sizeof(remote_data));
Benjamin Tissoirese6f28132016-07-13 18:06:01 +0200890 if (ret != sizeof(remote_data)) {
Benjamin Tissoires83e6b402016-07-13 18:06:02 +0200891 spin_unlock_irqrestore(&remote->remote_lock, flags);
Benjamin Tissoirese6f28132016-07-13 18:06:01 +0200892 hid_err(wacom->hdev, "Can't queue Remote status event.\n");
893 return;
894 }
895
Benjamin Tissoires83e6b402016-07-13 18:06:02 +0200896 spin_unlock_irqrestore(&remote->remote_lock, flags);
Benjamin Tissoirese6f28132016-07-13 18:06:01 +0200897
898 wacom_schedule_work(wacom_wac, WACOM_WORKER_REMOTE);
Aaron Skomra72b236d2015-08-20 16:05:17 -0700899}
900
Ping Cheng1924e052016-08-09 14:38:56 -0700901static inline bool report_touch_events(struct wacom_wac *wacom)
902{
903 return (touch_arbitration ? !wacom->shared->stylus_in_proximity : 1);
904}
905
906static inline bool delay_pen_events(struct wacom_wac *wacom)
907{
908 return (wacom->shared->touch_down && touch_arbitration);
Ping Cheng3bea7332006-07-13 18:01:36 -0700909}
910
Jason Gerecke16e0a6a2015-11-30 17:13:48 -0800911static int wacom_intuos_general(struct wacom_wac *wacom)
Ping Cheng3bea7332006-07-13 18:01:36 -0700912{
Jason Childse33da8a2010-02-17 22:38:31 -0800913 struct wacom_features *features = &wacom->features;
Ping Cheng3bea7332006-07-13 18:01:36 -0700914 unsigned char *data = wacom->data;
Jason Gerecke2a6cdbd2015-06-15 18:01:45 -0700915 struct input_dev *input = wacom->pen_input;
Jason Gerecke16e0a6a2015-11-30 17:13:48 -0800916 int idx = (features->type == INTUOS) ? (data[1] & 0x01) : 0;
Jason Gereckea8a09c82015-11-30 17:13:49 -0800917 unsigned char type = (data[1] >> 1) & 0x0F;
Jason Gerecke5f33f432015-11-30 17:13:51 -0800918 unsigned int x, y, distance, t;
Ping Cheng3bea7332006-07-13 18:01:36 -0700919
Jason Gerecke16e0a6a2015-11-30 17:13:48 -0800920 if (data[0] != WACOM_REPORT_PENABLED && data[0] != WACOM_REPORT_CINTIQ &&
921 data[0] != WACOM_REPORT_INTUOS_PEN)
922 return 0;
923
Ping Cheng1924e052016-08-09 14:38:56 -0700924 if (delay_pen_events(wacom))
Ping Chengc1b03f52016-01-08 17:16:06 -0800925 return 1;
926
Ping Cheng599b0822016-01-08 17:14:54 -0800927 /* don't report events if we don't know the tool ID */
928 if (!wacom->id[idx]) {
929 /* but reschedule a read of the current tool */
930 wacom_intuos_schedule_prox_event(wacom);
931 return 1;
932 }
933
Ping Cheng4750f5f2016-01-08 17:15:48 -0800934 /*
935 * don't report events for invalid data
936 */
937 /* older I4 styli don't work with new Cintiqs */
Jason Gerecke82527da2016-10-19 18:03:47 -0700938 if ((!((wacom->id[idx] >> 16) & 0x01) &&
Ping Cheng4750f5f2016-01-08 17:15:48 -0800939 (features->type == WACOM_21UX2)) ||
940 /* Only large Intuos support Lense Cursor */
941 (wacom->tool[idx] == BTN_TOOL_LENS &&
942 (features->type == INTUOS3 ||
943 features->type == INTUOS3S ||
944 features->type == INTUOS4 ||
945 features->type == INTUOS4S ||
946 features->type == INTUOS5 ||
947 features->type == INTUOS5S ||
948 features->type == INTUOSPM ||
949 features->type == INTUOSPS)) ||
950 /* Cintiq doesn't send data when RDY bit isn't set */
951 (features->type == CINTIQ && !(data[1] & 0x40)))
952 return 1;
953
Jason Gerecke5f33f432015-11-30 17:13:51 -0800954 x = (be16_to_cpup((__be16 *)&data[2]) << 1) | ((data[9] >> 1) & 1);
955 y = (be16_to_cpup((__be16 *)&data[4]) << 1) | (data[9] & 1);
956 distance = data[9] >> 2;
957 if (features->type < INTUOS3S) {
958 x >>= 1;
959 y >>= 1;
960 distance >>= 1;
Jason Gerecke16e0a6a2015-11-30 17:13:48 -0800961 }
Jason Gerecke5f33f432015-11-30 17:13:51 -0800962 input_report_abs(input, ABS_X, x);
963 input_report_abs(input, ABS_Y, y);
964 input_report_abs(input, ABS_DISTANCE, distance);
Jason Gerecke16e0a6a2015-11-30 17:13:48 -0800965
Jason Gereckea8a09c82015-11-30 17:13:49 -0800966 switch (type) {
967 case 0x00:
968 case 0x01:
969 case 0x02:
970 case 0x03:
971 /* general pen packet */
Jason Gerecke5f33f432015-11-30 17:13:51 -0800972 t = (data[6] << 3) | ((data[7] & 0xC0) >> 5) | (data[1] & 1);
973 if (features->pressure_max < 2047)
974 t >>= 1;
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700975 input_report_abs(input, ABS_PRESSURE, t);
Ping Chengeda01da2015-09-23 13:51:15 -0700976 if (features->type != INTUOSHT2) {
977 input_report_abs(input, ABS_TILT_X,
Jason Gereckeec5fc1c2014-11-18 16:50:08 -0800978 (((data[7] << 1) & 0x7e) | (data[8] >> 7)) - 64);
Ping Chengeda01da2015-09-23 13:51:15 -0700979 input_report_abs(input, ABS_TILT_Y, (data[8] & 0x7f) - 64);
980 }
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700981 input_report_key(input, BTN_STYLUS, data[1] & 2);
982 input_report_key(input, BTN_STYLUS2, data[1] & 4);
983 input_report_key(input, BTN_TOUCH, t > 10);
Jason Gereckea8a09c82015-11-30 17:13:49 -0800984 break;
Ping Cheng3bea7332006-07-13 18:01:36 -0700985
Jason Gereckea8a09c82015-11-30 17:13:49 -0800986 case 0x0a:
Jason Gereckea8a09c82015-11-30 17:13:49 -0800987 /* airbrush second packet */
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700988 input_report_abs(input, ABS_WHEEL,
Ping Cheng3bea7332006-07-13 18:01:36 -0700989 (data[6] << 2) | ((data[7] >> 6) & 3));
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700990 input_report_abs(input, ABS_TILT_X,
Jason Gereckeec5fc1c2014-11-18 16:50:08 -0800991 (((data[7] << 1) & 0x7e) | (data[8] >> 7)) - 64);
992 input_report_abs(input, ABS_TILT_Y, (data[8] & 0x7f) - 64);
Jason Gereckea8a09c82015-11-30 17:13:49 -0800993 break;
994
995 case 0x05:
Jason Gereckea8a09c82015-11-30 17:13:49 -0800996 /* Rotation packet */
997 if (features->type >= INTUOS3S) {
998 /* I3 marker pen rotation */
999 t = (data[6] << 3) | ((data[7] >> 5) & 7);
1000 t = (data[7] & 0x20) ? ((t > 900) ? ((t-1) / 2 - 1350) :
1001 ((t-1) / 2 + 450)) : (450 - t / 2) ;
1002 input_report_abs(input, ABS_Z, t);
1003 } else {
Jason Gerecke571f5722015-11-30 17:13:50 -08001004 /* 4D mouse 2nd packet */
Jason Gereckea8a09c82015-11-30 17:13:49 -08001005 t = (data[6] << 3) | ((data[7] >> 5) & 7);
1006 input_report_abs(input, ABS_RZ, (data[7] & 0x20) ?
1007 ((t - 1) / 2) : -t / 2);
1008 }
1009 break;
Ping Cheng3bea7332006-07-13 18:01:36 -07001010
Jason Gereckea8a09c82015-11-30 17:13:49 -08001011 case 0x04:
Jason Gerecke571f5722015-11-30 17:13:50 -08001012 /* 4D mouse 1st packet */
1013 input_report_key(input, BTN_LEFT, data[8] & 0x01);
1014 input_report_key(input, BTN_MIDDLE, data[8] & 0x02);
1015 input_report_key(input, BTN_RIGHT, data[8] & 0x04);
1016
1017 input_report_key(input, BTN_SIDE, data[8] & 0x20);
1018 input_report_key(input, BTN_EXTRA, data[8] & 0x10);
1019 t = (data[6] << 2) | ((data[7] >> 6) & 3);
1020 input_report_abs(input, ABS_THROTTLE, (data[8] & 0x08) ? -t : t);
1021 break;
1022
Jason Gereckea8a09c82015-11-30 17:13:49 -08001023 case 0x06:
Jason Gerecke571f5722015-11-30 17:13:50 -08001024 /* I4 mouse */
1025 input_report_key(input, BTN_LEFT, data[6] & 0x01);
1026 input_report_key(input, BTN_MIDDLE, data[6] & 0x02);
1027 input_report_key(input, BTN_RIGHT, data[6] & 0x04);
1028 input_report_rel(input, REL_WHEEL, ((data[7] & 0x80) >> 7)
1029 - ((data[7] & 0x40) >> 6));
1030 input_report_key(input, BTN_SIDE, data[6] & 0x08);
1031 input_report_key(input, BTN_EXTRA, data[6] & 0x10);
1032
1033 input_report_abs(input, ABS_TILT_X,
1034 (((data[7] << 1) & 0x7e) | (data[8] >> 7)) - 64);
1035 input_report_abs(input, ABS_TILT_Y, (data[8] & 0x7f) - 64);
1036 break;
1037
Jason Gereckea8a09c82015-11-30 17:13:49 -08001038 case 0x08:
Jason Gerecke571f5722015-11-30 17:13:50 -08001039 if (wacom->tool[idx] == BTN_TOOL_MOUSE) {
1040 /* 2D mouse packet */
1041 input_report_key(input, BTN_LEFT, data[8] & 0x04);
1042 input_report_key(input, BTN_MIDDLE, data[8] & 0x08);
1043 input_report_key(input, BTN_RIGHT, data[8] & 0x10);
1044 input_report_rel(input, REL_WHEEL, (data[8] & 0x01)
1045 - ((data[8] & 0x02) >> 1));
Ping Cheng3bea7332006-07-13 18:01:36 -07001046
Jason Gerecke571f5722015-11-30 17:13:50 -08001047 /* I3 2D mouse side buttons */
1048 if (features->type >= INTUOS3S && features->type <= INTUOS3L) {
1049 input_report_key(input, BTN_SIDE, data[8] & 0x40);
1050 input_report_key(input, BTN_EXTRA, data[8] & 0x20);
Ping Cheng3bea7332006-07-13 18:01:36 -07001051 }
Jason Gereckea8a09c82015-11-30 17:13:49 -08001052 }
Jason Gerecke571f5722015-11-30 17:13:50 -08001053 else if (wacom->tool[idx] == BTN_TOOL_LENS) {
Ping Cheng3bea7332006-07-13 18:01:36 -07001054 /* Lens cursor packets */
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -07001055 input_report_key(input, BTN_LEFT, data[8] & 0x01);
1056 input_report_key(input, BTN_MIDDLE, data[8] & 0x02);
1057 input_report_key(input, BTN_RIGHT, data[8] & 0x04);
1058 input_report_key(input, BTN_SIDE, data[8] & 0x10);
1059 input_report_key(input, BTN_EXTRA, data[8] & 0x08);
Ping Cheng3bea7332006-07-13 18:01:36 -07001060 }
Jason Gereckea8a09c82015-11-30 17:13:49 -08001061 break;
1062
Jason Gerecke571f5722015-11-30 17:13:50 -08001063 case 0x07:
Jason Gereckea8a09c82015-11-30 17:13:49 -08001064 case 0x09:
Jason Gerecke571f5722015-11-30 17:13:50 -08001065 case 0x0b:
Jason Gereckea8a09c82015-11-30 17:13:49 -08001066 case 0x0c:
1067 case 0x0d:
1068 case 0x0e:
1069 case 0x0f:
1070 /* unhandled */
1071 break;
Ping Cheng3bea7332006-07-13 18:01:36 -07001072 }
Ping Cheng3bea7332006-07-13 18:01:36 -07001073
Jason Gerecke82527da2016-10-19 18:03:47 -07001074 input_report_abs(input, ABS_MISC,
1075 wacom_intuos_id_mangle(wacom->id[idx])); /* report tool id */
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -07001076 input_report_key(input, wacom->tool[idx], 1);
1077 input_event(input, EV_MSC, MSC_SERIAL, wacom->serial[idx]);
Ping Chengb3bd7ef2015-01-09 11:05:13 -08001078 wacom->reporting_data = true;
Jason Gerecke16e0a6a2015-11-30 17:13:48 -08001079 return 2;
Ping Cheng3bea7332006-07-13 18:01:36 -07001080}
1081
1082static int wacom_intuos_irq(struct wacom_wac *wacom)
1083{
Ping Cheng3bea7332006-07-13 18:01:36 -07001084 unsigned char *data = wacom->data;
1085 struct input_dev *input = wacom->pen_input;
Jason Gerecke16e0a6a2015-11-30 17:13:48 -08001086 int result;
Ping Cheng3bea7332006-07-13 18:01:36 -07001087
1088 if (data[0] != WACOM_REPORT_PENABLED &&
Jason Gerecke06109992015-11-30 17:13:52 -08001089 data[0] != WACOM_REPORT_INTUOS_ID1 &&
1090 data[0] != WACOM_REPORT_INTUOS_ID2 &&
Ping Cheng3bea7332006-07-13 18:01:36 -07001091 data[0] != WACOM_REPORT_INTUOSPAD &&
1092 data[0] != WACOM_REPORT_INTUOS_PEN &&
1093 data[0] != WACOM_REPORT_CINTIQ &&
1094 data[0] != WACOM_REPORT_CINTIQPAD &&
1095 data[0] != WACOM_REPORT_INTUOS5PAD) {
1096 dev_dbg(input->dev.parent,
1097 "%s: received unknown report #%d\n", __func__, data[0]);
1098 return 0;
1099 }
1100
Jason Gerecke16e0a6a2015-11-30 17:13:48 -08001101 /* process pad events */
1102 result = wacom_intuos_pad(wacom);
1103 if (result)
1104 return result;
Ping Cheng3bea7332006-07-13 18:01:36 -07001105
1106 /* process in/out prox events */
1107 result = wacom_intuos_inout(wacom);
1108 if (result)
Jason Gerecke16e0a6a2015-11-30 17:13:48 -08001109 return result - 1;
Ping Cheng3bea7332006-07-13 18:01:36 -07001110
1111 /* process general packets */
Jason Gerecke16e0a6a2015-11-30 17:13:48 -08001112 result = wacom_intuos_general(wacom);
1113 if (result)
1114 return result - 1;
Ping Cheng3bea7332006-07-13 18:01:36 -07001115
Jason Gerecke16e0a6a2015-11-30 17:13:48 -08001116 return 0;
Ping Cheng3bea7332006-07-13 18:01:36 -07001117}
1118
Jason Gereckeb1e42792012-10-21 00:38:04 -07001119static int int_dist(int x1, int y1, int x2, int y2)
1120{
1121 int x = x2 - x1;
1122 int y = y2 - y1;
1123
1124 return int_sqrt(x*x + y*y);
1125}
1126
Benjamin Tissoires81af7e62014-08-06 13:55:56 -07001127static void wacom_intuos_bt_process_data(struct wacom_wac *wacom,
1128 unsigned char *data)
1129{
1130 memcpy(wacom->data, data, 10);
1131 wacom_intuos_irq(wacom);
1132
Jason Gerecke2a6cdbd2015-06-15 18:01:45 -07001133 input_sync(wacom->pen_input);
Benjamin Tissoires81af7e62014-08-06 13:55:56 -07001134 if (wacom->pad_input)
1135 input_sync(wacom->pad_input);
1136}
1137
1138static int wacom_intuos_bt_irq(struct wacom_wac *wacom, size_t len)
1139{
1140 unsigned char data[WACOM_PKGLEN_MAX];
1141 int i = 1;
1142 unsigned power_raw, battery_capacity, bat_charging, ps_connected;
1143
1144 memcpy(data, wacom->data, len);
1145
1146 switch (data[0]) {
1147 case 0x04:
1148 wacom_intuos_bt_process_data(wacom, data + i);
1149 i += 10;
1150 /* fall through */
1151 case 0x03:
1152 wacom_intuos_bt_process_data(wacom, data + i);
1153 i += 10;
1154 wacom_intuos_bt_process_data(wacom, data + i);
1155 i += 10;
1156 power_raw = data[i];
1157 bat_charging = (power_raw & 0x08) ? 1 : 0;
1158 ps_connected = (power_raw & 0x10) ? 1 : 0;
1159 battery_capacity = batcap_i4[power_raw & 0x07];
Jason Gerecke953f2c52015-03-06 11:47:39 -08001160 wacom_notify_battery(wacom, battery_capacity, bat_charging,
Jason Gerecke71fa6412015-03-11 10:25:41 -07001161 battery_capacity || bat_charging,
Jason Gerecke953f2c52015-03-06 11:47:39 -08001162 ps_connected);
Benjamin Tissoires81af7e62014-08-06 13:55:56 -07001163 break;
1164 default:
Jason Gerecke2a6cdbd2015-06-15 18:01:45 -07001165 dev_dbg(wacom->pen_input->dev.parent,
Benjamin Tissoires81af7e62014-08-06 13:55:56 -07001166 "Unknown report: %d,%d size:%zu\n",
1167 data[0], data[1], len);
1168 return 0;
1169 }
1170 return 0;
1171}
1172
Ping Cheng7d059ed2015-03-20 14:57:21 -07001173static int wacom_wac_finger_count_touches(struct wacom_wac *wacom)
1174{
Jason Gerecke2a6cdbd2015-06-15 18:01:45 -07001175 struct input_dev *input = wacom->touch_input;
Ping Cheng7d059ed2015-03-20 14:57:21 -07001176 unsigned touch_max = wacom->features.touch_max;
1177 int count = 0;
1178 int i;
1179
Ping Cheng26ba61f2015-05-19 17:42:02 -07001180 if (!touch_max)
1181 return 0;
1182
Jason Gerecke71b5c472015-04-15 17:22:32 -07001183 if (touch_max == 1)
1184 return test_bit(BTN_TOUCH, input->key) &&
Ping Cheng1924e052016-08-09 14:38:56 -07001185 report_touch_events(wacom);
Ping Cheng7d059ed2015-03-20 14:57:21 -07001186
1187 for (i = 0; i < input->mt->num_slots; i++) {
1188 struct input_mt_slot *ps = &input->mt->slots[i];
1189 int id = input_mt_get_value(ps, ABS_MT_TRACKING_ID);
1190 if (id >= 0)
1191 count++;
1192 }
1193
1194 return count;
1195}
1196
Jason Gerecke4922cd22017-01-25 12:08:37 -08001197static void wacom_intuos_pro2_bt_pen(struct wacom_wac *wacom)
1198{
1199 const int pen_frame_len = 14;
1200 const int pen_frames = 7;
1201
1202 struct input_dev *pen_input = wacom->pen_input;
1203 unsigned char *data = wacom->data;
1204 int i;
1205
1206 wacom->serial[0] = get_unaligned_le64(&data[99]);
1207 wacom->id[0] = get_unaligned_le16(&data[107]);
1208 if (wacom->serial[0] >> 52 == 1) {
1209 /* Add back in missing bits of ID for non-USI pens */
1210 wacom->id[0] |= (wacom->serial[0] >> 32) & 0xFFFFF;
1211 }
1212 wacom->tool[0] = wacom_intuos_get_tool_type(wacom_intuos_id_mangle(wacom->id[0]));
1213
1214 for (i = 0; i < pen_frames; i++) {
1215 unsigned char *frame = &data[i*pen_frame_len + 1];
Jason Gereckea48324d2017-02-10 16:14:07 -08001216 bool valid = frame[0] & 0x80;
1217 bool prox = frame[0] & 0x40;
1218 bool range = frame[0] & 0x20;
Jason Gerecke4922cd22017-01-25 12:08:37 -08001219
Jason Gereckea48324d2017-02-10 16:14:07 -08001220 if (!valid)
Jason Gerecke4922cd22017-01-25 12:08:37 -08001221 continue;
1222
Jason Gereckea48324d2017-02-10 16:14:07 -08001223 if (range) {
1224 input_report_abs(pen_input, ABS_X, get_unaligned_le16(&frame[1]));
1225 input_report_abs(pen_input, ABS_Y, get_unaligned_le16(&frame[3]));
1226 input_report_abs(pen_input, ABS_TILT_X, frame[7]);
1227 input_report_abs(pen_input, ABS_TILT_Y, frame[8]);
1228 input_report_abs(pen_input, ABS_Z, get_unaligned_le16(&frame[9]));
1229 input_report_abs(pen_input, ABS_WHEEL, get_unaligned_le16(&frame[11]));
1230 }
Jason Gerecke4922cd22017-01-25 12:08:37 -08001231 input_report_abs(pen_input, ABS_PRESSURE, get_unaligned_le16(&frame[5]));
Jason Gereckea48324d2017-02-10 16:14:07 -08001232 input_report_abs(pen_input, ABS_DISTANCE, range ? frame[13] : wacom->features.distance_max);
Jason Gerecke4922cd22017-01-25 12:08:37 -08001233
1234 input_report_key(pen_input, BTN_TOUCH, frame[0] & 0x01);
1235 input_report_key(pen_input, BTN_STYLUS, frame[0] & 0x02);
1236 input_report_key(pen_input, BTN_STYLUS2, frame[0] & 0x04);
1237
Jason Gereckea48324d2017-02-10 16:14:07 -08001238 input_report_key(pen_input, wacom->tool[0], prox);
Jason Gerecke4922cd22017-01-25 12:08:37 -08001239 input_event(pen_input, EV_MSC, MSC_SERIAL, wacom->serial[0]);
1240 input_report_abs(pen_input, ABS_MISC,
1241 wacom_intuos_id_mangle(wacom->id[0])); /* report tool id */
1242
Jason Gereckea48324d2017-02-10 16:14:07 -08001243 wacom->shared->stylus_in_proximity = prox;
Jason Gerecke4922cd22017-01-25 12:08:37 -08001244
1245 input_sync(pen_input);
1246 }
1247}
1248
1249static void wacom_intuos_pro2_bt_touch(struct wacom_wac *wacom)
1250{
1251 const int finger_touch_len = 8;
1252 const int finger_frames = 4;
1253 const int finger_frame_len = 43;
1254
1255 struct input_dev *touch_input = wacom->touch_input;
1256 unsigned char *data = wacom->data;
1257 int num_contacts_left = 5;
1258 int i, j;
1259
1260 for (i = 0; i < finger_frames; i++) {
1261 unsigned char *frame = &data[i*finger_frame_len + 109];
1262 int current_num_contacts = frame[0] & 0x7F;
1263 int contacts_to_send;
1264
1265 if (!(frame[0] & 0x80))
1266 continue;
1267
1268 /*
1269 * First packet resets the counter since only the first
1270 * packet in series will have non-zero current_num_contacts.
1271 */
1272 if (current_num_contacts)
1273 wacom->num_contacts_left = current_num_contacts;
1274
1275 contacts_to_send = min(num_contacts_left, wacom->num_contacts_left);
1276
1277 for (j = 0; j < contacts_to_send; j++) {
1278 unsigned char *touch = &frame[j*finger_touch_len + 1];
1279 int slot = input_mt_get_slot_by_key(touch_input, touch[0]);
1280 int x = get_unaligned_le16(&touch[2]);
1281 int y = get_unaligned_le16(&touch[4]);
1282 int w = touch[6] * input_abs_get_res(touch_input, ABS_MT_POSITION_X);
1283 int h = touch[7] * input_abs_get_res(touch_input, ABS_MT_POSITION_Y);
1284
1285 if (slot < 0)
1286 continue;
1287
1288 input_mt_slot(touch_input, slot);
1289 input_mt_report_slot_state(touch_input, MT_TOOL_FINGER, touch[1] & 0x01);
1290 input_report_abs(touch_input, ABS_MT_POSITION_X, x);
1291 input_report_abs(touch_input, ABS_MT_POSITION_Y, y);
1292 input_report_abs(touch_input, ABS_MT_TOUCH_MAJOR, max(w, h));
1293 input_report_abs(touch_input, ABS_MT_TOUCH_MINOR, min(w, h));
1294 input_report_abs(touch_input, ABS_MT_ORIENTATION, w > h);
1295 }
1296
1297 input_mt_sync_frame(touch_input);
1298
1299 wacom->num_contacts_left -= contacts_to_send;
1300 if (wacom->num_contacts_left <= 0) {
1301 wacom->num_contacts_left = 0;
1302 wacom->shared->touch_down = wacom_wac_finger_count_touches(wacom);
1303 }
1304 }
1305
1306 input_report_switch(touch_input, SW_MUTE_DEVICE, !(data[281] >> 7));
1307 input_sync(touch_input);
1308}
1309
1310static void wacom_intuos_pro2_bt_pad(struct wacom_wac *wacom)
1311{
1312 struct input_dev *pad_input = wacom->pad_input;
1313 unsigned char *data = wacom->data;
1314
1315 int buttons = (data[282] << 1) | ((data[281] >> 6) & 0x01);
1316 int ring = data[285];
1317 int prox = buttons | (ring & 0x80);
1318
1319 wacom_report_numbered_buttons(pad_input, 9, buttons);
1320
1321 input_report_abs(pad_input, ABS_WHEEL, (ring & 0x80) ? (ring & 0x7f) : 0);
1322
1323 input_report_key(pad_input, wacom->tool[1], prox ? 1 : 0);
1324 input_report_abs(pad_input, ABS_MISC, prox ? PAD_DEVICE_ID : 0);
1325 input_event(pad_input, EV_MSC, MSC_SERIAL, 0xffffffff);
1326
1327 input_sync(pad_input);
1328}
1329
1330static void wacom_intuos_pro2_bt_battery(struct wacom_wac *wacom)
1331{
1332 unsigned char *data = wacom->data;
1333
1334 bool chg = data[284] & 0x80;
1335 int battery_status = data[284] & 0x7F;
1336
1337 wacom_notify_battery(wacom, battery_status, chg, 1, chg);
1338}
1339
1340static int wacom_intuos_pro2_bt_irq(struct wacom_wac *wacom, size_t len)
1341{
1342 unsigned char *data = wacom->data;
1343
1344 if (data[0] != 0x80) {
1345 dev_dbg(wacom->pen_input->dev.parent,
1346 "%s: received unknown report #%d\n", __func__, data[0]);
1347 return 0;
1348 }
1349
1350 wacom_intuos_pro2_bt_pen(wacom);
1351 wacom_intuos_pro2_bt_touch(wacom);
1352 wacom_intuos_pro2_bt_pad(wacom);
1353 wacom_intuos_pro2_bt_battery(wacom);
1354 return 0;
1355}
1356
Jason Gereckeb1e42792012-10-21 00:38:04 -07001357static int wacom_24hdt_irq(struct wacom_wac *wacom)
1358{
Jason Gerecke2a6cdbd2015-06-15 18:01:45 -07001359 struct input_dev *input = wacom->touch_input;
Jason Gerecke74b63412014-04-19 13:50:22 -07001360 unsigned char *data = wacom->data;
Jason Gereckeb1e42792012-10-21 00:38:04 -07001361 int i;
Ping Chenge0d41fd2015-02-20 14:27:30 -08001362 int current_num_contacts = data[61];
Jason Gereckeb1e42792012-10-21 00:38:04 -07001363 int contacts_to_send = 0;
Ping Cheng500d4162015-01-27 13:30:03 -08001364 int num_contacts_left = 4; /* maximum contacts per packet */
1365 int byte_per_packet = WACOM_BYTES_PER_24HDT_PACKET;
1366 int y_offset = 2;
1367
1368 if (wacom->features.type == WACOM_27QHDT) {
1369 current_num_contacts = data[63];
1370 num_contacts_left = 10;
1371 byte_per_packet = WACOM_BYTES_PER_QHDTHID_PACKET;
1372 y_offset = 0;
Ping Cheng500d4162015-01-27 13:30:03 -08001373 }
Jason Gereckeb1e42792012-10-21 00:38:04 -07001374
1375 /*
1376 * First packet resets the counter since only the first
1377 * packet in series will have non-zero current_num_contacts.
1378 */
Ping Cheng7d059ed2015-03-20 14:57:21 -07001379 if (current_num_contacts)
Jason Gereckeb1e42792012-10-21 00:38:04 -07001380 wacom->num_contacts_left = current_num_contacts;
1381
Ping Cheng500d4162015-01-27 13:30:03 -08001382 contacts_to_send = min(num_contacts_left, wacom->num_contacts_left);
Jason Gereckeb1e42792012-10-21 00:38:04 -07001383
1384 for (i = 0; i < contacts_to_send; i++) {
Ping Cheng500d4162015-01-27 13:30:03 -08001385 int offset = (byte_per_packet * i) + 1;
Ping Cheng1924e052016-08-09 14:38:56 -07001386 bool touch = (data[offset] & 0x1) && report_touch_events(wacom);
Ping Cheng02295e62013-01-04 23:56:00 -08001387 int slot = input_mt_get_slot_by_key(input, data[offset + 1]);
Jason Gereckeb1e42792012-10-21 00:38:04 -07001388
1389 if (slot < 0)
1390 continue;
1391 input_mt_slot(input, slot);
1392 input_mt_report_slot_state(input, MT_TOOL_FINGER, touch);
1393
1394 if (touch) {
Jason Gereckeedc8e20a2014-05-14 16:53:30 -07001395 int t_x = get_unaligned_le16(&data[offset + 2]);
Ping Cheng500d4162015-01-27 13:30:03 -08001396 int t_y = get_unaligned_le16(&data[offset + 4 + y_offset]);
Jason Gereckeb1e42792012-10-21 00:38:04 -07001397
1398 input_report_abs(input, ABS_MT_POSITION_X, t_x);
1399 input_report_abs(input, ABS_MT_POSITION_Y, t_y);
Ping Cheng500d4162015-01-27 13:30:03 -08001400
1401 if (wacom->features.type != WACOM_27QHDT) {
1402 int c_x = get_unaligned_le16(&data[offset + 4]);
1403 int c_y = get_unaligned_le16(&data[offset + 8]);
1404 int w = get_unaligned_le16(&data[offset + 10]);
1405 int h = get_unaligned_le16(&data[offset + 12]);
1406
1407 input_report_abs(input, ABS_MT_TOUCH_MAJOR, min(w,h));
1408 input_report_abs(input, ABS_MT_WIDTH_MAJOR,
1409 min(w, h) + int_dist(t_x, t_y, c_x, c_y));
1410 input_report_abs(input, ABS_MT_WIDTH_MINOR, min(w, h));
1411 input_report_abs(input, ABS_MT_ORIENTATION, w > h);
1412 }
Jason Gereckeb1e42792012-10-21 00:38:04 -07001413 }
Jason Gereckeb1e42792012-10-21 00:38:04 -07001414 }
Benjamin Tissoires9a1c0012015-02-17 14:19:46 -05001415 input_mt_sync_frame(input);
Jason Gereckeb1e42792012-10-21 00:38:04 -07001416
1417 wacom->num_contacts_left -= contacts_to_send;
Ping Chenge0d41fd2015-02-20 14:27:30 -08001418 if (wacom->num_contacts_left <= 0) {
Jason Gereckeb1e42792012-10-21 00:38:04 -07001419 wacom->num_contacts_left = 0;
Ping Cheng7d059ed2015-03-20 14:57:21 -07001420 wacom->shared->touch_down = wacom_wac_finger_count_touches(wacom);
Ping Chenge0d41fd2015-02-20 14:27:30 -08001421 }
Jason Gereckeb1e42792012-10-21 00:38:04 -07001422 return 1;
1423}
1424
Ping Cheng19635182012-04-29 21:09:18 -07001425static int wacom_mt_touch(struct wacom_wac *wacom)
1426{
Jason Gerecke2a6cdbd2015-06-15 18:01:45 -07001427 struct input_dev *input = wacom->touch_input;
Jason Gerecke74b63412014-04-19 13:50:22 -07001428 unsigned char *data = wacom->data;
Ping Cheng19635182012-04-29 21:09:18 -07001429 int i;
1430 int current_num_contacts = data[2];
1431 int contacts_to_send = 0;
Ping Cheng6afdc282012-11-03 12:16:15 -07001432 int x_offset = 0;
1433
1434 /* MTTPC does not support Height and Width */
Jason Gerecked51ddb22014-05-14 17:14:29 -07001435 if (wacom->features.type == MTTPC || wacom->features.type == MTTPC_B)
Ping Cheng6afdc282012-11-03 12:16:15 -07001436 x_offset = -4;
Ping Cheng19635182012-04-29 21:09:18 -07001437
1438 /*
1439 * First packet resets the counter since only the first
1440 * packet in series will have non-zero current_num_contacts.
1441 */
Ping Cheng7d059ed2015-03-20 14:57:21 -07001442 if (current_num_contacts)
Ping Cheng19635182012-04-29 21:09:18 -07001443 wacom->num_contacts_left = current_num_contacts;
1444
1445 /* There are at most 5 contacts per packet */
1446 contacts_to_send = min(5, wacom->num_contacts_left);
1447
1448 for (i = 0; i < contacts_to_send; i++) {
Ping Cheng6afdc282012-11-03 12:16:15 -07001449 int offset = (WACOM_BYTES_PER_MT_PACKET + x_offset) * i + 3;
Ping Cheng1924e052016-08-09 14:38:56 -07001450 bool touch = (data[offset] & 0x1) && report_touch_events(wacom);
Jason Gereckeedc8e20a2014-05-14 16:53:30 -07001451 int id = get_unaligned_le16(&data[offset + 1]);
Ping Cheng02295e62013-01-04 23:56:00 -08001452 int slot = input_mt_get_slot_by_key(input, id);
Ping Cheng19635182012-04-29 21:09:18 -07001453
1454 if (slot < 0)
1455 continue;
1456
1457 input_mt_slot(input, slot);
1458 input_mt_report_slot_state(input, MT_TOOL_FINGER, touch);
1459 if (touch) {
Jason Gereckeedc8e20a2014-05-14 16:53:30 -07001460 int x = get_unaligned_le16(&data[offset + x_offset + 7]);
1461 int y = get_unaligned_le16(&data[offset + x_offset + 9]);
Ping Cheng19635182012-04-29 21:09:18 -07001462 input_report_abs(input, ABS_MT_POSITION_X, x);
1463 input_report_abs(input, ABS_MT_POSITION_Y, y);
1464 }
Ping Cheng19635182012-04-29 21:09:18 -07001465 }
Benjamin Tissoires9a1c0012015-02-17 14:19:46 -05001466 input_mt_sync_frame(input);
Ping Cheng19635182012-04-29 21:09:18 -07001467
1468 wacom->num_contacts_left -= contacts_to_send;
Ping Chenge0d41fd2015-02-20 14:27:30 -08001469 if (wacom->num_contacts_left <= 0) {
Ping Cheng19635182012-04-29 21:09:18 -07001470 wacom->num_contacts_left = 0;
Ping Cheng7d059ed2015-03-20 14:57:21 -07001471 wacom->shared->touch_down = wacom_wac_finger_count_touches(wacom);
Ping Chenge0d41fd2015-02-20 14:27:30 -08001472 }
Ping Cheng19635182012-04-29 21:09:18 -07001473 return 1;
1474}
1475
Ping Cheng84eb5aa2011-03-12 20:35:18 -08001476static int wacom_tpc_mt_touch(struct wacom_wac *wacom)
1477{
Jason Gerecke2a6cdbd2015-06-15 18:01:45 -07001478 struct input_dev *input = wacom->touch_input;
Ping Cheng84eb5aa2011-03-12 20:35:18 -08001479 unsigned char *data = wacom->data;
Ping Cheng84eb5aa2011-03-12 20:35:18 -08001480 int i;
1481
1482 for (i = 0; i < 2; i++) {
1483 int p = data[1] & (1 << i);
Ping Cheng1924e052016-08-09 14:38:56 -07001484 bool touch = p && report_touch_events(wacom);
Ping Cheng84eb5aa2011-03-12 20:35:18 -08001485
1486 input_mt_slot(input, i);
1487 input_mt_report_slot_state(input, MT_TOOL_FINGER, touch);
1488 if (touch) {
1489 int x = le16_to_cpup((__le16 *)&data[i * 2 + 2]) & 0x7fff;
1490 int y = le16_to_cpup((__le16 *)&data[i * 2 + 6]) & 0x7fff;
1491
1492 input_report_abs(input, ABS_MT_POSITION_X, x);
1493 input_report_abs(input, ABS_MT_POSITION_Y, y);
Ping Cheng84eb5aa2011-03-12 20:35:18 -08001494 }
1495 }
Benjamin Tissoires9a1c0012015-02-17 14:19:46 -05001496 input_mt_sync_frame(input);
Ping Cheng84eb5aa2011-03-12 20:35:18 -08001497
1498 /* keep touch state for pen event */
Ping Cheng7d059ed2015-03-20 14:57:21 -07001499 wacom->shared->touch_down = wacom_wac_finger_count_touches(wacom);
Ping Cheng84eb5aa2011-03-12 20:35:18 -08001500
Ping Cheng84eb5aa2011-03-12 20:35:18 -08001501 return 1;
1502}
1503
Ping Chenga43c7c52011-03-12 20:34:42 -08001504static int wacom_tpc_single_touch(struct wacom_wac *wacom, size_t len)
Ping Chengec67bbe2009-12-15 00:35:24 -08001505{
Jason Gerecke74b63412014-04-19 13:50:22 -07001506 unsigned char *data = wacom->data;
Jason Gerecke2a6cdbd2015-06-15 18:01:45 -07001507 struct input_dev *input = wacom->touch_input;
Ping Cheng1924e052016-08-09 14:38:56 -07001508 bool prox = report_touch_events(wacom);
Ping Chenga43c7c52011-03-12 20:34:42 -08001509 int x = 0, y = 0;
Ping Chengec67bbe2009-12-15 00:35:24 -08001510
Ping Cheng19635182012-04-29 21:09:18 -07001511 if (wacom->features.touch_max > 1 || len > WACOM_PKGLEN_TPC2FG)
1512 return 0;
1513
Ping Chenge0d41fd2015-02-20 14:27:30 -08001514 if (len == WACOM_PKGLEN_TPC1FG) {
1515 prox = prox && (data[0] & 0x01);
1516 x = get_unaligned_le16(&data[1]);
1517 y = get_unaligned_le16(&data[3]);
1518 } else if (len == WACOM_PKGLEN_TPC1FG_B) {
1519 prox = prox && (data[2] & 0x01);
1520 x = get_unaligned_le16(&data[3]);
1521 y = get_unaligned_le16(&data[5]);
1522 } else {
1523 prox = prox && (data[1] & 0x01);
1524 x = le16_to_cpup((__le16 *)&data[2]);
1525 y = le16_to_cpup((__le16 *)&data[4]);
1526 }
Ping Chenga43c7c52011-03-12 20:34:42 -08001527
1528 if (prox) {
1529 input_report_abs(input, ABS_X, x);
1530 input_report_abs(input, ABS_Y, y);
Ping Chengec67bbe2009-12-15 00:35:24 -08001531 }
Ping Chenga43c7c52011-03-12 20:34:42 -08001532 input_report_key(input, BTN_TOUCH, prox);
1533
1534 /* keep touch state for pen events */
1535 wacom->shared->touch_down = prox;
1536
1537 return 1;
Ping Chengec67bbe2009-12-15 00:35:24 -08001538}
1539
Ping Cheng8aa9a9a2011-03-12 20:34:11 -08001540static int wacom_tpc_pen(struct wacom_wac *wacom)
Ping Cheng545f4e92008-11-24 11:44:27 -05001541{
Jason Gerecke74b63412014-04-19 13:50:22 -07001542 unsigned char *data = wacom->data;
Jason Gerecke2a6cdbd2015-06-15 18:01:45 -07001543 struct input_dev *input = wacom->pen_input;
Ping Chenga43c7c52011-03-12 20:34:42 -08001544 bool prox = data[1] & 0x20;
Ping Cheng8aa9a9a2011-03-12 20:34:11 -08001545
Ping Chenga43c7c52011-03-12 20:34:42 -08001546 if (!wacom->shared->stylus_in_proximity) /* first in prox */
Ping Cheng8aa9a9a2011-03-12 20:34:11 -08001547 /* Going into proximity select tool */
1548 wacom->tool[0] = (data[1] & 0x0c) ? BTN_TOOL_RUBBER : BTN_TOOL_PEN;
Ping Cheng8aa9a9a2011-03-12 20:34:11 -08001549
Ping Chenga43c7c52011-03-12 20:34:42 -08001550 /* keep pen state for touch events */
1551 wacom->shared->stylus_in_proximity = prox;
Ping Cheng8aa9a9a2011-03-12 20:34:11 -08001552
Ping Cheng1924e052016-08-09 14:38:56 -07001553 /* send pen events only when touch is up or forced out
1554 * or touch arbitration is off
1555 */
1556 if (!delay_pen_events(wacom)) {
Ping Chenga43c7c52011-03-12 20:34:42 -08001557 input_report_key(input, BTN_STYLUS, data[1] & 0x02);
1558 input_report_key(input, BTN_STYLUS2, data[1] & 0x10);
1559 input_report_abs(input, ABS_X, le16_to_cpup((__le16 *)&data[2]));
1560 input_report_abs(input, ABS_Y, le16_to_cpup((__le16 *)&data[4]));
Jason Gerecke0b335ca2014-07-24 13:15:31 -07001561 input_report_abs(input, ABS_PRESSURE, ((data[7] & 0x07) << 8) | data[6]);
Ping Chenga43c7c52011-03-12 20:34:42 -08001562 input_report_key(input, BTN_TOUCH, data[1] & 0x05);
1563 input_report_key(input, wacom->tool[0], prox);
1564 return 1;
1565 }
1566
1567 return 0;
Ping Cheng8aa9a9a2011-03-12 20:34:11 -08001568}
1569
1570static int wacom_tpc_irq(struct wacom_wac *wacom, size_t len)
1571{
Jason Gerecke74b63412014-04-19 13:50:22 -07001572 unsigned char *data = wacom->data;
Ping Cheng545f4e92008-11-24 11:44:27 -05001573
Jason Gerecke2a6cdbd2015-06-15 18:01:45 -07001574 if (wacom->pen_input)
1575 dev_dbg(wacom->pen_input->dev.parent,
1576 "%s: received report #%d\n", __func__, data[0]);
1577 else if (wacom->touch_input)
1578 dev_dbg(wacom->touch_input->dev.parent,
1579 "%s: received report #%d\n", __func__, data[0]);
Ping Cheng545f4e92008-11-24 11:44:27 -05001580
Ping Cheng31175a82012-01-31 00:07:33 -08001581 switch (len) {
1582 case WACOM_PKGLEN_TPC1FG:
Ping Cheng19635182012-04-29 21:09:18 -07001583 return wacom_tpc_single_touch(wacom, len);
Ping Cheng31175a82012-01-31 00:07:33 -08001584
1585 case WACOM_PKGLEN_TPC2FG:
Ping Cheng19635182012-04-29 21:09:18 -07001586 return wacom_tpc_mt_touch(wacom);
Ping Cheng31175a82012-01-31 00:07:33 -08001587
Jason Gerecked51ddb22014-05-14 17:14:29 -07001588 case WACOM_PKGLEN_PENABLED:
1589 return wacom_tpc_pen(wacom);
1590
Ping Cheng31175a82012-01-31 00:07:33 -08001591 default:
1592 switch (data[0]) {
1593 case WACOM_REPORT_TPC1FG:
1594 case WACOM_REPORT_TPCHID:
1595 case WACOM_REPORT_TPCST:
Ping Chengac173832012-06-12 00:15:06 -07001596 case WACOM_REPORT_TPC1FGE:
Ping Cheng31175a82012-01-31 00:07:33 -08001597 return wacom_tpc_single_touch(wacom, len);
1598
Ping Cheng19635182012-04-29 21:09:18 -07001599 case WACOM_REPORT_TPCMT:
Jason Gerecked51ddb22014-05-14 17:14:29 -07001600 case WACOM_REPORT_TPCMT2:
Ping Cheng19635182012-04-29 21:09:18 -07001601 return wacom_mt_touch(wacom);
1602
Ping Cheng31175a82012-01-31 00:07:33 -08001603 case WACOM_REPORT_PENABLED:
1604 return wacom_tpc_pen(wacom);
1605 }
1606 }
Ping Cheng545f4e92008-11-24 11:44:27 -05001607
Ping Cheng8aa9a9a2011-03-12 20:34:11 -08001608 return 0;
Ping Cheng545f4e92008-11-24 11:44:27 -05001609}
1610
Aaron Armstrong Skomraac2423c2017-01-25 12:08:40 -08001611int wacom_equivalent_usage(int usage)
Jason Gereckec9c09582016-10-19 18:03:43 -07001612{
1613 if ((usage & HID_USAGE_PAGE) == WACOM_HID_UP_WACOMDIGITIZER) {
1614 int subpage = (usage & 0xFF00) << 8;
1615 int subusage = (usage & 0xFF);
1616
Jason Gerecke5922e612016-10-19 18:03:51 -07001617 if (subpage == WACOM_HID_SP_PAD ||
1618 subpage == WACOM_HID_SP_BUTTON ||
1619 subpage == WACOM_HID_SP_DIGITIZER ||
Jason Gereckeb5c921e2016-10-19 18:03:44 -07001620 subpage == WACOM_HID_SP_DIGITIZERINFO ||
Jason Gerecke61ce3462016-10-19 18:03:46 -07001621 usage == WACOM_HID_WD_SENSE ||
Jason Gereckef85c9dc2016-10-19 18:03:48 -07001622 usage == WACOM_HID_WD_SERIALHI ||
1623 usage == WACOM_HID_WD_TOOLTYPE ||
Jason Gerecke5922e612016-10-19 18:03:51 -07001624 usage == WACOM_HID_WD_DISTANCE ||
Jason Gereckebf78adc2016-10-19 18:03:53 -07001625 usage == WACOM_HID_WD_TOUCHSTRIP ||
1626 usage == WACOM_HID_WD_TOUCHSTRIP2 ||
Jason Gerecke5922e612016-10-19 18:03:51 -07001627 usage == WACOM_HID_WD_TOUCHRING ||
1628 usage == WACOM_HID_WD_TOUCHRINGSTATUS) {
Jason Gereckec9c09582016-10-19 18:03:43 -07001629 return usage;
1630 }
1631
1632 if (subpage == HID_UP_UNDEFINED)
1633 subpage = HID_UP_DIGITIZER;
1634
1635 return subpage | subusage;
1636 }
1637
Aaron Armstrong Skomraac2423c2017-01-25 12:08:40 -08001638 if ((usage & HID_USAGE_PAGE) == WACOM_HID_UP_WACOMTOUCH) {
1639 int subpage = (usage & 0xFF00) << 8;
1640 int subusage = (usage & 0xFF);
1641
1642 if (subpage == HID_UP_UNDEFINED)
1643 subpage = WACOM_HID_SP_DIGITIZER;
1644
1645 return subpage | subusage;
1646 }
1647
Jason Gereckec9c09582016-10-19 18:03:43 -07001648 return usage;
1649}
1650
Jason Gerecke2a6cdbd2015-06-15 18:01:45 -07001651static void wacom_map_usage(struct input_dev *input, struct hid_usage *usage,
Benjamin Tissoires7704ac92014-09-23 12:08:08 -04001652 struct hid_field *field, __u8 type, __u16 code, int fuzz)
1653{
Jason Gerecke345857b2016-10-19 18:03:50 -07001654 struct wacom *wacom = input_get_drvdata(input);
1655 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
1656 struct wacom_features *features = &wacom_wac->features;
Benjamin Tissoires7704ac92014-09-23 12:08:08 -04001657 int fmin = field->logical_minimum;
1658 int fmax = field->logical_maximum;
Jason Gereckec9c09582016-10-19 18:03:43 -07001659 unsigned int equivalent_usage = wacom_equivalent_usage(usage->hid);
Jason Gerecke50066a02016-10-19 18:03:42 -07001660 int resolution_code = code;
1661
Jason Gereckec9c09582016-10-19 18:03:43 -07001662 if (equivalent_usage == HID_DG_TWIST) {
Jason Gerecke50066a02016-10-19 18:03:42 -07001663 resolution_code = ABS_RZ;
1664 }
Benjamin Tissoires7704ac92014-09-23 12:08:08 -04001665
Jason Gerecke345857b2016-10-19 18:03:50 -07001666 if (equivalent_usage == HID_GD_X) {
1667 fmin += features->offset_left;
1668 fmax -= features->offset_right;
1669 }
1670 if (equivalent_usage == HID_GD_Y) {
1671 fmin += features->offset_top;
1672 fmax -= features->offset_bottom;
1673 }
1674
Benjamin Tissoires7704ac92014-09-23 12:08:08 -04001675 usage->type = type;
1676 usage->code = code;
1677
1678 set_bit(type, input->evbit);
1679
1680 switch (type) {
1681 case EV_ABS:
1682 input_set_abs_params(input, code, fmin, fmax, fuzz, 0);
1683 input_abs_set_res(input, code,
Jason Gerecke50066a02016-10-19 18:03:42 -07001684 hidinput_calc_abs_res(field, resolution_code));
Benjamin Tissoires7704ac92014-09-23 12:08:08 -04001685 break;
1686 case EV_KEY:
1687 input_set_capability(input, EV_KEY, code);
1688 break;
1689 case EV_MSC:
1690 input_set_capability(input, EV_MSC, code);
1691 break;
Jason Gereckebf78adc2016-10-19 18:03:53 -07001692 case EV_SW:
1693 input_set_capability(input, EV_SW, code);
1694 break;
Benjamin Tissoires7704ac92014-09-23 12:08:08 -04001695 }
1696}
1697
Jason Gerecke5922e612016-10-19 18:03:51 -07001698static void wacom_wac_pad_usage_mapping(struct hid_device *hdev,
1699 struct hid_field *field, struct hid_usage *usage)
1700{
1701 struct wacom *wacom = hid_get_drvdata(hdev);
1702 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
1703 struct wacom_features *features = &wacom_wac->features;
1704 struct input_dev *input = wacom_wac->pad_input;
1705 unsigned equivalent_usage = wacom_equivalent_usage(usage->hid);
1706
1707 switch (equivalent_usage) {
Jason Gerecke93aab7f2016-10-19 18:03:52 -07001708 case WACOM_HID_WD_BATTERY_LEVEL:
1709 case WACOM_HID_WD_BATTERY_CHARGING:
1710 features->quirks |= WACOM_QUIRK_BATTERY;
1711 break;
Jason Gerecke5922e612016-10-19 18:03:51 -07001712 case WACOM_HID_WD_ACCELEROMETER_X:
1713 __set_bit(INPUT_PROP_ACCELEROMETER, input->propbit);
1714 wacom_map_usage(input, usage, field, EV_ABS, ABS_X, 0);
Ping Chengf3f24e72016-12-08 22:05:44 -08001715 features->device_type |= WACOM_DEVICETYPE_PAD;
Jason Gerecke5922e612016-10-19 18:03:51 -07001716 break;
1717 case WACOM_HID_WD_ACCELEROMETER_Y:
1718 __set_bit(INPUT_PROP_ACCELEROMETER, input->propbit);
1719 wacom_map_usage(input, usage, field, EV_ABS, ABS_Y, 0);
Ping Chengf3f24e72016-12-08 22:05:44 -08001720 features->device_type |= WACOM_DEVICETYPE_PAD;
Jason Gerecke5922e612016-10-19 18:03:51 -07001721 break;
1722 case WACOM_HID_WD_ACCELEROMETER_Z:
1723 __set_bit(INPUT_PROP_ACCELEROMETER, input->propbit);
1724 wacom_map_usage(input, usage, field, EV_ABS, ABS_Z, 0);
Ping Chengf3f24e72016-12-08 22:05:44 -08001725 features->device_type |= WACOM_DEVICETYPE_PAD;
Jason Gerecke5922e612016-10-19 18:03:51 -07001726 break;
Aaron Armstrong Skomra10c55ca2017-01-25 12:08:42 -08001727 case WACOM_HID_WD_BUTTONCENTER:
1728 wacom->generic_has_leds = true;
1729 /* fall through */
Jason Gerecke5922e612016-10-19 18:03:51 -07001730 case WACOM_HID_WD_BUTTONHOME:
1731 case WACOM_HID_WD_BUTTONUP:
1732 case WACOM_HID_WD_BUTTONDOWN:
1733 case WACOM_HID_WD_BUTTONLEFT:
1734 case WACOM_HID_WD_BUTTONRIGHT:
1735 wacom_map_usage(input, usage, field, EV_KEY,
1736 wacom_numbered_button_to_key(features->numbered_buttons),
1737 0);
1738 features->numbered_buttons++;
Ping Chengf3f24e72016-12-08 22:05:44 -08001739 features->device_type |= WACOM_DEVICETYPE_PAD;
Jason Gerecke5922e612016-10-19 18:03:51 -07001740 break;
Jason Gereckebf78adc2016-10-19 18:03:53 -07001741 case WACOM_HID_WD_TOUCHONOFF:
Aaron Armstrong Skomrad2ec58a2017-01-25 12:08:41 -08001742 /*
1743 * This usage, which is used to mute touch events, comes
1744 * from the pad packet, but is reported on the touch
1745 * interface. Because the touch interface may not have
1746 * been created yet, we cannot call wacom_map_usage(). In
1747 * order to process this usage when we receive it, we set
1748 * the usage type and code directly.
1749 */
1750 wacom_wac->has_mute_touch_switch = true;
1751 usage->type = EV_SW;
1752 usage->code = SW_MUTE_DEVICE;
Ping Chengf3f24e72016-12-08 22:05:44 -08001753 features->device_type |= WACOM_DEVICETYPE_PAD;
Jason Gereckebf78adc2016-10-19 18:03:53 -07001754 break;
1755 case WACOM_HID_WD_TOUCHSTRIP:
1756 wacom_map_usage(input, usage, field, EV_ABS, ABS_RX, 0);
Ping Chengf3f24e72016-12-08 22:05:44 -08001757 features->device_type |= WACOM_DEVICETYPE_PAD;
Jason Gereckebf78adc2016-10-19 18:03:53 -07001758 break;
1759 case WACOM_HID_WD_TOUCHSTRIP2:
1760 wacom_map_usage(input, usage, field, EV_ABS, ABS_RY, 0);
Ping Chengf3f24e72016-12-08 22:05:44 -08001761 features->device_type |= WACOM_DEVICETYPE_PAD;
Jason Gereckebf78adc2016-10-19 18:03:53 -07001762 break;
Jason Gerecke5922e612016-10-19 18:03:51 -07001763 case WACOM_HID_WD_TOUCHRING:
1764 wacom_map_usage(input, usage, field, EV_ABS, ABS_WHEEL, 0);
Ping Chengf3f24e72016-12-08 22:05:44 -08001765 features->device_type |= WACOM_DEVICETYPE_PAD;
Jason Gerecke5922e612016-10-19 18:03:51 -07001766 break;
Aaron Armstrong Skomra60a22182017-01-25 12:08:39 -08001767 case WACOM_HID_WD_TOUCHRINGSTATUS:
1768 wacom_map_usage(input, usage, field, EV_ABS, ABS_WHEEL, 0);
1769 features->device_type |= WACOM_DEVICETYPE_PAD;
1770 break;
Jason Gerecke5922e612016-10-19 18:03:51 -07001771 }
1772
1773 switch (equivalent_usage & 0xfffffff0) {
1774 case WACOM_HID_WD_EXPRESSKEY00:
1775 wacom_map_usage(input, usage, field, EV_KEY,
1776 wacom_numbered_button_to_key(features->numbered_buttons),
1777 0);
1778 features->numbered_buttons++;
Ping Chengf3f24e72016-12-08 22:05:44 -08001779 features->device_type |= WACOM_DEVICETYPE_PAD;
Jason Gerecke5922e612016-10-19 18:03:51 -07001780 break;
1781 }
1782}
1783
Ping Chengc9cfb2a2016-12-08 22:06:15 -08001784static void wacom_wac_pad_battery_event(struct hid_device *hdev, struct hid_field *field,
Jason Gerecke5922e612016-10-19 18:03:51 -07001785 struct hid_usage *usage, __s32 value)
1786{
1787 struct wacom *wacom = hid_get_drvdata(hdev);
1788 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
Jason Gerecke5922e612016-10-19 18:03:51 -07001789 unsigned equivalent_usage = wacom_equivalent_usage(usage->hid);
1790
Jason Gerecke93aab7f2016-10-19 18:03:52 -07001791 switch (equivalent_usage) {
1792 case WACOM_HID_WD_BATTERY_LEVEL:
1793 wacom_wac->hid_data.battery_capacity = value;
1794 wacom_wac->hid_data.bat_connected = 1;
Ping Cheng354a3292016-12-08 22:03:27 -08001795 break;
Jason Gerecke93aab7f2016-10-19 18:03:52 -07001796
1797 case WACOM_HID_WD_BATTERY_CHARGING:
1798 wacom_wac->hid_data.bat_charging = value;
1799 wacom_wac->hid_data.ps_connected = value;
1800 wacom_wac->hid_data.bat_connected = 1;
Ping Cheng354a3292016-12-08 22:03:27 -08001801 break;
Ping Chengc9cfb2a2016-12-08 22:06:15 -08001802 }
1803}
Jason Gerecke93aab7f2016-10-19 18:03:52 -07001804
Ping Chengc9cfb2a2016-12-08 22:06:15 -08001805static void wacom_wac_pad_event(struct hid_device *hdev, struct hid_field *field,
1806 struct hid_usage *usage, __s32 value)
1807{
1808 struct wacom *wacom = hid_get_drvdata(hdev);
1809 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
1810 struct input_dev *input = wacom_wac->pad_input;
1811 struct wacom_features *features = &wacom_wac->features;
1812 unsigned equivalent_usage = wacom_equivalent_usage(usage->hid);
Aaron Armstrong Skomra10c55ca2017-01-25 12:08:42 -08001813 int i;
Ping Chengc9cfb2a2016-12-08 22:06:15 -08001814
Aaron Armstrong Skomra60a22182017-01-25 12:08:39 -08001815 /*
1816 * Avoid reporting this event and setting inrange_state if this usage
1817 * hasn't been mapped.
1818 */
1819 if (!usage->type)
1820 return;
Ping Chengc9cfb2a2016-12-08 22:06:15 -08001821
1822 if (wacom_equivalent_usage(field->physical) == HID_DG_TABLETFUNCTIONKEY) {
Aaron Armstrong Skomra60a22182017-01-25 12:08:39 -08001823 if (usage->hid != WACOM_HID_WD_TOUCHRING)
1824 wacom_wac->hid_data.inrange_state |= value;
Ping Chengc9cfb2a2016-12-08 22:06:15 -08001825 }
1826
1827 switch (equivalent_usage) {
Jason Gerecke93aab7f2016-10-19 18:03:52 -07001828 case WACOM_HID_WD_TOUCHRINGSTATUS:
Aaron Armstrong Skomra60a22182017-01-25 12:08:39 -08001829 if (!value)
1830 input_event(input, usage->type, usage->code, 0);
Ping Cheng354a3292016-12-08 22:03:27 -08001831 break;
Jason Gerecke93aab7f2016-10-19 18:03:52 -07001832
Aaron Armstrong Skomrad2ec58a2017-01-25 12:08:41 -08001833 case WACOM_HID_WD_TOUCHONOFF:
1834 if (wacom_wac->shared->touch_input) {
1835 input_report_switch(wacom_wac->shared->touch_input,
1836 SW_MUTE_DEVICE, !value);
1837 input_sync(wacom_wac->shared->touch_input);
1838 }
1839 break;
Aaron Armstrong Skomra10c55ca2017-01-25 12:08:42 -08001840
1841 case WACOM_HID_WD_BUTTONCENTER:
1842 for (i = 0; i < wacom->led.count; i++)
1843 wacom_update_led(wacom, features->numbered_buttons,
1844 value, i);
1845 /* fall through*/
Jason Gerecke93aab7f2016-10-19 18:03:52 -07001846 default:
Jason Gerecke5922e612016-10-19 18:03:51 -07001847 input_event(input, usage->type, usage->code, value);
Jason Gerecke93aab7f2016-10-19 18:03:52 -07001848 break;
1849 }
Jason Gerecke5922e612016-10-19 18:03:51 -07001850}
1851
1852static void wacom_wac_pad_pre_report(struct hid_device *hdev,
1853 struct hid_report *report)
1854{
1855 struct wacom *wacom = hid_get_drvdata(hdev);
1856 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
1857
1858 wacom_wac->hid_data.inrange_state = 0;
1859}
1860
Ping Chengc9cfb2a2016-12-08 22:06:15 -08001861static void wacom_wac_pad_battery_report(struct hid_device *hdev,
Jason Gerecke5922e612016-10-19 18:03:51 -07001862 struct hid_report *report)
1863{
1864 struct wacom *wacom = hid_get_drvdata(hdev);
1865 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
Jason Gerecke93aab7f2016-10-19 18:03:52 -07001866 struct wacom_features *features = &wacom_wac->features;
Jason Gerecke5922e612016-10-19 18:03:51 -07001867
Jason Gerecke93aab7f2016-10-19 18:03:52 -07001868 if (features->quirks & WACOM_QUIRK_BATTERY) {
1869 int capacity = wacom_wac->hid_data.battery_capacity;
1870 bool charging = wacom_wac->hid_data.bat_charging;
1871 bool connected = wacom_wac->hid_data.bat_connected;
1872 bool powered = wacom_wac->hid_data.ps_connected;
1873
1874 wacom_notify_battery(wacom_wac, capacity, charging,
1875 connected, powered);
1876 }
Ping Chengc9cfb2a2016-12-08 22:06:15 -08001877}
Jason Gerecke93aab7f2016-10-19 18:03:52 -07001878
Ping Chengc9cfb2a2016-12-08 22:06:15 -08001879static void wacom_wac_pad_report(struct hid_device *hdev,
1880 struct hid_report *report)
1881{
1882 struct wacom *wacom = hid_get_drvdata(hdev);
1883 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
Ping Chengc9cfb2a2016-12-08 22:06:15 -08001884 struct input_dev *input = wacom_wac->pad_input;
1885 bool active = wacom_wac->hid_data.inrange_state != 0;
1886
1887 /* report prox for expresskey events */
1888 if (wacom_equivalent_usage(report->field[0]->physical) == HID_DG_TABLETFUNCTIONKEY) {
Ping Chengc9cfb2a2016-12-08 22:06:15 -08001889 input_event(input, EV_ABS, ABS_MISC, active ? PAD_DEVICE_ID : 0);
Ping Chengc9cfb2a2016-12-08 22:06:15 -08001890 input_sync(input);
1891 }
Aaron Armstrong Skomra65ef4c12017-01-25 12:08:38 -08001892
Jason Gerecke5922e612016-10-19 18:03:51 -07001893}
1894
Benjamin Tissoires7704ac92014-09-23 12:08:08 -04001895static void wacom_wac_pen_usage_mapping(struct hid_device *hdev,
1896 struct hid_field *field, struct hid_usage *usage)
1897{
1898 struct wacom *wacom = hid_get_drvdata(hdev);
Jason Gerecke2a6cdbd2015-06-15 18:01:45 -07001899 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
Jason Gerecke61ce3462016-10-19 18:03:46 -07001900 struct wacom_features *features = &wacom_wac->features;
Jason Gerecke2a6cdbd2015-06-15 18:01:45 -07001901 struct input_dev *input = wacom_wac->pen_input;
Jason Gereckec9c09582016-10-19 18:03:43 -07001902 unsigned equivalent_usage = wacom_equivalent_usage(usage->hid);
Benjamin Tissoires7704ac92014-09-23 12:08:08 -04001903
Jason Gereckec9c09582016-10-19 18:03:43 -07001904 switch (equivalent_usage) {
Benjamin Tissoires7704ac92014-09-23 12:08:08 -04001905 case HID_GD_X:
Jason Gerecke2a6cdbd2015-06-15 18:01:45 -07001906 wacom_map_usage(input, usage, field, EV_ABS, ABS_X, 4);
Benjamin Tissoires7704ac92014-09-23 12:08:08 -04001907 break;
1908 case HID_GD_Y:
Jason Gerecke2a6cdbd2015-06-15 18:01:45 -07001909 wacom_map_usage(input, usage, field, EV_ABS, ABS_Y, 4);
Benjamin Tissoires7704ac92014-09-23 12:08:08 -04001910 break;
Jason Gereckeb5c921e2016-10-19 18:03:44 -07001911 case WACOM_HID_WD_DISTANCE:
Jason Gerecke50066a02016-10-19 18:03:42 -07001912 case HID_GD_Z:
1913 wacom_map_usage(input, usage, field, EV_ABS, ABS_DISTANCE, 0);
1914 break;
Benjamin Tissoires7704ac92014-09-23 12:08:08 -04001915 case HID_DG_TIPPRESSURE:
Jason Gerecke2a6cdbd2015-06-15 18:01:45 -07001916 wacom_map_usage(input, usage, field, EV_ABS, ABS_PRESSURE, 0);
Benjamin Tissoires7704ac92014-09-23 12:08:08 -04001917 break;
1918 case HID_DG_INRANGE:
Jason Gerecke2a6cdbd2015-06-15 18:01:45 -07001919 wacom_map_usage(input, usage, field, EV_KEY, BTN_TOOL_PEN, 0);
Benjamin Tissoires7704ac92014-09-23 12:08:08 -04001920 break;
Jason Gerecke93aab7f2016-10-19 18:03:52 -07001921 case HID_DG_BATTERYSTRENGTH:
1922 features->quirks |= WACOM_QUIRK_BATTERY;
1923 break;
Benjamin Tissoires7704ac92014-09-23 12:08:08 -04001924 case HID_DG_INVERT:
Jason Gerecke2a6cdbd2015-06-15 18:01:45 -07001925 wacom_map_usage(input, usage, field, EV_KEY,
Benjamin Tissoires7704ac92014-09-23 12:08:08 -04001926 BTN_TOOL_RUBBER, 0);
1927 break;
Jason Gerecke50066a02016-10-19 18:03:42 -07001928 case HID_DG_TILT_X:
1929 wacom_map_usage(input, usage, field, EV_ABS, ABS_TILT_X, 0);
1930 break;
1931 case HID_DG_TILT_Y:
1932 wacom_map_usage(input, usage, field, EV_ABS, ABS_TILT_Y, 0);
1933 break;
1934 case HID_DG_TWIST:
1935 wacom_map_usage(input, usage, field, EV_ABS, ABS_Z, 0);
1936 break;
Benjamin Tissoires7704ac92014-09-23 12:08:08 -04001937 case HID_DG_ERASER:
1938 case HID_DG_TIPSWITCH:
Jason Gerecke2a6cdbd2015-06-15 18:01:45 -07001939 wacom_map_usage(input, usage, field, EV_KEY, BTN_TOUCH, 0);
Benjamin Tissoires7704ac92014-09-23 12:08:08 -04001940 break;
1941 case HID_DG_BARRELSWITCH:
Jason Gerecke2a6cdbd2015-06-15 18:01:45 -07001942 wacom_map_usage(input, usage, field, EV_KEY, BTN_STYLUS, 0);
Benjamin Tissoires7704ac92014-09-23 12:08:08 -04001943 break;
1944 case HID_DG_BARRELSWITCH2:
Jason Gerecke2a6cdbd2015-06-15 18:01:45 -07001945 wacom_map_usage(input, usage, field, EV_KEY, BTN_STYLUS2, 0);
Benjamin Tissoires7704ac92014-09-23 12:08:08 -04001946 break;
1947 case HID_DG_TOOLSERIALNUMBER:
Jason Gerecke2a6cdbd2015-06-15 18:01:45 -07001948 wacom_map_usage(input, usage, field, EV_MSC, MSC_SERIAL, 0);
Benjamin Tissoires7704ac92014-09-23 12:08:08 -04001949 break;
Jason Gerecke61ce3462016-10-19 18:03:46 -07001950 case WACOM_HID_WD_SENSE:
1951 features->quirks |= WACOM_QUIRK_SENSE;
1952 wacom_map_usage(input, usage, field, EV_KEY, BTN_TOOL_PEN, 0);
1953 break;
Jason Gereckef85c9dc2016-10-19 18:03:48 -07001954 case WACOM_HID_WD_SERIALHI:
1955 wacom_map_usage(input, usage, field, EV_ABS, ABS_MISC, 0);
1956 set_bit(EV_KEY, input->evbit);
1957 input_set_capability(input, EV_KEY, BTN_TOOL_PEN);
1958 input_set_capability(input, EV_KEY, BTN_TOOL_RUBBER);
1959 input_set_capability(input, EV_KEY, BTN_TOOL_BRUSH);
1960 input_set_capability(input, EV_KEY, BTN_TOOL_PENCIL);
1961 input_set_capability(input, EV_KEY, BTN_TOOL_AIRBRUSH);
1962 input_set_capability(input, EV_KEY, BTN_TOOL_MOUSE);
1963 input_set_capability(input, EV_KEY, BTN_TOOL_LENS);
1964 break;
Jason Gerecke929d6d52016-10-19 18:03:45 -07001965 case WACOM_HID_WD_FINGERWHEEL:
1966 wacom_map_usage(input, usage, field, EV_ABS, ABS_WHEEL, 0);
1967 break;
Benjamin Tissoires7704ac92014-09-23 12:08:08 -04001968 }
1969}
1970
Ping Cheng354a3292016-12-08 22:03:27 -08001971static void wacom_wac_pen_event(struct hid_device *hdev, struct hid_field *field,
Benjamin Tissoires7704ac92014-09-23 12:08:08 -04001972 struct hid_usage *usage, __s32 value)
1973{
1974 struct wacom *wacom = hid_get_drvdata(hdev);
1975 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
Jason Gerecke61ce3462016-10-19 18:03:46 -07001976 struct wacom_features *features = &wacom_wac->features;
Jason Gerecke2a6cdbd2015-06-15 18:01:45 -07001977 struct input_dev *input = wacom_wac->pen_input;
Jason Gereckec9c09582016-10-19 18:03:43 -07001978 unsigned equivalent_usage = wacom_equivalent_usage(usage->hid);
Benjamin Tissoires7704ac92014-09-23 12:08:08 -04001979
Jason Gereckec9c09582016-10-19 18:03:43 -07001980 switch (equivalent_usage) {
Jason Gerecke50066a02016-10-19 18:03:42 -07001981 case HID_GD_Z:
1982 /*
1983 * HID_GD_Z "should increase as the control's position is
1984 * moved from high to low", while ABS_DISTANCE instead
1985 * increases in value as the tool moves from low to high.
1986 */
1987 value = field->logical_maximum - value;
1988 break;
Benjamin Tissoires7704ac92014-09-23 12:08:08 -04001989 case HID_DG_INRANGE:
1990 wacom_wac->hid_data.inrange_state = value;
Jason Gerecke61ce3462016-10-19 18:03:46 -07001991 if (!(features->quirks & WACOM_QUIRK_SENSE))
1992 wacom_wac->hid_data.sense_state = value;
Ping Cheng354a3292016-12-08 22:03:27 -08001993 return;
Jason Gerecke93aab7f2016-10-19 18:03:52 -07001994 case HID_DG_BATTERYSTRENGTH:
1995 wacom_wac->hid_data.battery_capacity = value;
1996 wacom_wac->hid_data.bat_connected = 1;
1997 break;
Benjamin Tissoires7704ac92014-09-23 12:08:08 -04001998 case HID_DG_INVERT:
1999 wacom_wac->hid_data.invert_state = value;
Ping Cheng354a3292016-12-08 22:03:27 -08002000 return;
Benjamin Tissoires7704ac92014-09-23 12:08:08 -04002001 case HID_DG_ERASER:
2002 case HID_DG_TIPSWITCH:
2003 wacom_wac->hid_data.tipswitch |= value;
Ping Cheng354a3292016-12-08 22:03:27 -08002004 return;
Jason Gereckef85c9dc2016-10-19 18:03:48 -07002005 case HID_DG_TOOLSERIALNUMBER:
Dan Carpentera35f09b2016-11-10 22:25:39 +03002006 wacom_wac->serial[0] = (wacom_wac->serial[0] & ~0xFFFFFFFFULL);
Jason Gereckef85c9dc2016-10-19 18:03:48 -07002007 wacom_wac->serial[0] |= value;
Ping Cheng354a3292016-12-08 22:03:27 -08002008 return;
Jason Gerecke61ce3462016-10-19 18:03:46 -07002009 case WACOM_HID_WD_SENSE:
2010 wacom_wac->hid_data.sense_state = value;
Ping Cheng354a3292016-12-08 22:03:27 -08002011 return;
Jason Gereckef85c9dc2016-10-19 18:03:48 -07002012 case WACOM_HID_WD_SERIALHI:
2013 wacom_wac->serial[0] = (wacom_wac->serial[0] & 0xFFFFFFFF);
2014 wacom_wac->serial[0] |= ((__u64)value) << 32;
2015 /*
2016 * Non-USI EMR devices may contain additional tool type
2017 * information here. See WACOM_HID_WD_TOOLTYPE case for
2018 * more details.
2019 */
2020 if (value >> 20 == 1) {
2021 wacom_wac->id[0] |= value & 0xFFFFF;
2022 }
Ping Cheng354a3292016-12-08 22:03:27 -08002023 return;
Jason Gereckef85c9dc2016-10-19 18:03:48 -07002024 case WACOM_HID_WD_TOOLTYPE:
2025 /*
2026 * Some devices (MobileStudio Pro, and possibly later
2027 * devices as well) do not return the complete tool
2028 * type in their WACOM_HID_WD_TOOLTYPE usage. Use a
2029 * bitwise OR so the complete value can be built
2030 * up over time :(
2031 */
2032 wacom_wac->id[0] |= value;
Ping Cheng354a3292016-12-08 22:03:27 -08002033 return;
Jason Gerecke345857b2016-10-19 18:03:50 -07002034 case WACOM_HID_WD_OFFSETLEFT:
2035 if (features->offset_left && value != features->offset_left)
2036 hid_warn(hdev, "%s: overriding exising left offset "
2037 "%d -> %d\n", __func__, value,
2038 features->offset_left);
2039 features->offset_left = value;
Ping Cheng354a3292016-12-08 22:03:27 -08002040 return;
Jason Gerecke345857b2016-10-19 18:03:50 -07002041 case WACOM_HID_WD_OFFSETRIGHT:
2042 if (features->offset_right && value != features->offset_right)
2043 hid_warn(hdev, "%s: overriding exising right offset "
2044 "%d -> %d\n", __func__, value,
2045 features->offset_right);
2046 features->offset_right = value;
Ping Cheng354a3292016-12-08 22:03:27 -08002047 return;
Jason Gerecke345857b2016-10-19 18:03:50 -07002048 case WACOM_HID_WD_OFFSETTOP:
2049 if (features->offset_top && value != features->offset_top)
2050 hid_warn(hdev, "%s: overriding exising top offset "
2051 "%d -> %d\n", __func__, value,
2052 features->offset_top);
2053 features->offset_top = value;
Ping Cheng354a3292016-12-08 22:03:27 -08002054 return;
Jason Gerecke345857b2016-10-19 18:03:50 -07002055 case WACOM_HID_WD_OFFSETBOTTOM:
2056 if (features->offset_bottom && value != features->offset_bottom)
2057 hid_warn(hdev, "%s: overriding exising bottom offset "
2058 "%d -> %d\n", __func__, value,
2059 features->offset_bottom);
2060 features->offset_bottom = value;
Ping Cheng354a3292016-12-08 22:03:27 -08002061 return;
Benjamin Tissoires7704ac92014-09-23 12:08:08 -04002062 }
2063
Ping Cheng1924e052016-08-09 14:38:56 -07002064 /* send pen events only when touch is up or forced out
2065 * or touch arbitration is off
2066 */
2067 if (!usage->type || delay_pen_events(wacom_wac))
Ping Cheng354a3292016-12-08 22:03:27 -08002068 return;
Benjamin Tissoires7704ac92014-09-23 12:08:08 -04002069
Jason Gerecke61ce3462016-10-19 18:03:46 -07002070 /* send pen events only when the pen is in/entering/leaving proximity */
2071 if (!wacom_wac->hid_data.inrange_state && !wacom_wac->tool[0])
Ping Cheng354a3292016-12-08 22:03:27 -08002072 return;
Jason Gerecke61ce3462016-10-19 18:03:46 -07002073
Benjamin Tissoires7704ac92014-09-23 12:08:08 -04002074 input_event(input, usage->type, usage->code, value);
Benjamin Tissoires7704ac92014-09-23 12:08:08 -04002075}
2076
Jason Gerecke06324e02015-07-21 11:07:23 -07002077static void wacom_wac_pen_pre_report(struct hid_device *hdev,
2078 struct hid_report *report)
2079{
2080 return;
2081}
2082
Benjamin Tissoires7704ac92014-09-23 12:08:08 -04002083static void wacom_wac_pen_report(struct hid_device *hdev,
2084 struct hid_report *report)
2085{
2086 struct wacom *wacom = hid_get_drvdata(hdev);
2087 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
Jason Gerecke2a6cdbd2015-06-15 18:01:45 -07002088 struct input_dev *input = wacom_wac->pen_input;
Benjamin Tissoires7704ac92014-09-23 12:08:08 -04002089 bool prox = wacom_wac->hid_data.inrange_state;
Jason Gerecke61ce3462016-10-19 18:03:46 -07002090 bool range = wacom_wac->hid_data.sense_state;
Benjamin Tissoires7704ac92014-09-23 12:08:08 -04002091
Jason Gereckef85c9dc2016-10-19 18:03:48 -07002092 if (!wacom_wac->tool[0] && prox) { /* first in prox */
Benjamin Tissoires7704ac92014-09-23 12:08:08 -04002093 /* Going into proximity select tool */
Jason Gereckef85c9dc2016-10-19 18:03:48 -07002094 if (wacom_wac->hid_data.invert_state)
2095 wacom_wac->tool[0] = BTN_TOOL_RUBBER;
2096 else if (wacom_wac->id[0])
2097 wacom_wac->tool[0] = wacom_intuos_get_tool_type(wacom_wac->id[0]);
2098 else
2099 wacom_wac->tool[0] = BTN_TOOL_PEN;
2100 }
Benjamin Tissoires7704ac92014-09-23 12:08:08 -04002101
2102 /* keep pen state for touch events */
Jason Gerecke61ce3462016-10-19 18:03:46 -07002103 wacom_wac->shared->stylus_in_proximity = range;
Benjamin Tissoires7704ac92014-09-23 12:08:08 -04002104
Jason Gerecke61ce3462016-10-19 18:03:46 -07002105 if (!delay_pen_events(wacom_wac) && wacom_wac->tool[0]) {
Jason Gereckef85c9dc2016-10-19 18:03:48 -07002106 int id = wacom_wac->id[0];
2107
2108 /*
2109 * Non-USI EMR tools should have their IDs mangled to
2110 * match the legacy behavior of wacom_intuos_general
2111 */
2112 if (wacom_wac->serial[0] >> 52 == 1)
2113 id = wacom_intuos_id_mangle(id);
2114
2115 /*
2116 * To ensure compatibility with xf86-input-wacom, we should
2117 * report the BTN_TOOL_* event prior to the ABS_MISC or
2118 * MSC_SERIAL events.
2119 */
Benjamin Tissoires7704ac92014-09-23 12:08:08 -04002120 input_report_key(input, BTN_TOUCH,
2121 wacom_wac->hid_data.tipswitch);
2122 input_report_key(input, wacom_wac->tool[0], prox);
Jason Gereckef85c9dc2016-10-19 18:03:48 -07002123 if (wacom_wac->serial[0]) {
2124 input_event(input, EV_MSC, MSC_SERIAL, wacom_wac->serial[0]);
2125 input_report_abs(input, ABS_MISC, id);
2126 }
Benjamin Tissoires7704ac92014-09-23 12:08:08 -04002127
2128 wacom_wac->hid_data.tipswitch = false;
2129
2130 input_sync(input);
2131 }
Jason Gerecke61ce3462016-10-19 18:03:46 -07002132
Jason Gereckef85c9dc2016-10-19 18:03:48 -07002133 if (!prox) {
Jason Gerecke61ce3462016-10-19 18:03:46 -07002134 wacom_wac->tool[0] = 0;
Jason Gereckef85c9dc2016-10-19 18:03:48 -07002135 wacom_wac->id[0] = 0;
2136 }
Benjamin Tissoires7704ac92014-09-23 12:08:08 -04002137}
2138
Benjamin Tissoires5ae6e892014-09-23 12:08:09 -04002139static void wacom_wac_finger_usage_mapping(struct hid_device *hdev,
2140 struct hid_field *field, struct hid_usage *usage)
2141{
2142 struct wacom *wacom = hid_get_drvdata(hdev);
2143 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
Jason Gerecke2a6cdbd2015-06-15 18:01:45 -07002144 struct input_dev *input = wacom_wac->touch_input;
Benjamin Tissoires5ae6e892014-09-23 12:08:09 -04002145 unsigned touch_max = wacom_wac->features.touch_max;
Jason Gereckec9c09582016-10-19 18:03:43 -07002146 unsigned equivalent_usage = wacom_equivalent_usage(usage->hid);
Benjamin Tissoires5ae6e892014-09-23 12:08:09 -04002147
Jason Gereckec9c09582016-10-19 18:03:43 -07002148 switch (equivalent_usage) {
Benjamin Tissoires5ae6e892014-09-23 12:08:09 -04002149 case HID_GD_X:
2150 if (touch_max == 1)
Jason Gerecke2a6cdbd2015-06-15 18:01:45 -07002151 wacom_map_usage(input, usage, field, EV_ABS, ABS_X, 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_X, 4);
2155 break;
2156 case HID_GD_Y:
2157 if (touch_max == 1)
Jason Gerecke2a6cdbd2015-06-15 18:01:45 -07002158 wacom_map_usage(input, usage, field, EV_ABS, ABS_Y, 4);
Benjamin Tissoires5ae6e892014-09-23 12:08:09 -04002159 else
Jason Gerecke2a6cdbd2015-06-15 18:01:45 -07002160 wacom_map_usage(input, usage, field, EV_ABS,
Benjamin Tissoires5ae6e892014-09-23 12:08:09 -04002161 ABS_MT_POSITION_Y, 4);
2162 break;
Jason Gerecke488abb52015-07-21 11:07:25 -07002163 case HID_DG_WIDTH:
2164 case HID_DG_HEIGHT:
Jason Gerecke488abb52015-07-21 11:07:25 -07002165 wacom_map_usage(input, usage, field, EV_ABS, ABS_MT_TOUCH_MAJOR, 0);
2166 wacom_map_usage(input, usage, field, EV_ABS, ABS_MT_TOUCH_MINOR, 0);
2167 input_set_abs_params(input, ABS_MT_ORIENTATION, 0, 1, 0, 0);
2168 break;
Benjamin Tissoires5ae6e892014-09-23 12:08:09 -04002169 case HID_DG_TIPSWITCH:
Jason Gerecke2a6cdbd2015-06-15 18:01:45 -07002170 wacom_map_usage(input, usage, field, EV_KEY, BTN_TOUCH, 0);
Benjamin Tissoires5ae6e892014-09-23 12:08:09 -04002171 break;
Jason Gerecke1b5d514a2015-07-21 11:07:24 -07002172 case HID_DG_CONTACTCOUNT:
Jason Gerecke499522c2015-10-07 16:54:21 -07002173 wacom_wac->hid_data.cc_report = field->report->id;
Jason Gerecke1b5d514a2015-07-21 11:07:24 -07002174 wacom_wac->hid_data.cc_index = field->index;
2175 wacom_wac->hid_data.cc_value_index = usage->usage_index;
2176 break;
Benjamin Tissoires5ae6e892014-09-23 12:08:09 -04002177 }
2178}
2179
Jason Gerecke601a22f2014-12-10 16:26:04 -08002180static void wacom_wac_finger_slot(struct wacom_wac *wacom_wac,
2181 struct input_dev *input)
2182{
2183 struct hid_data *hid_data = &wacom_wac->hid_data;
2184 bool mt = wacom_wac->features.touch_max > 1;
2185 bool prox = hid_data->tipswitch &&
Ping Cheng1924e052016-08-09 14:38:56 -07002186 report_touch_events(wacom_wac);
Jason Gerecke601a22f2014-12-10 16:26:04 -08002187
Jason Gerecke1b5d514a2015-07-21 11:07:24 -07002188 wacom_wac->hid_data.num_received++;
2189 if (wacom_wac->hid_data.num_received > wacom_wac->hid_data.num_expected)
2190 return;
2191
Jason Gerecke601a22f2014-12-10 16:26:04 -08002192 if (mt) {
2193 int slot;
2194
2195 slot = input_mt_get_slot_by_key(input, hid_data->id);
2196 input_mt_slot(input, slot);
2197 input_mt_report_slot_state(input, MT_TOOL_FINGER, prox);
2198 }
2199 else {
2200 input_report_key(input, BTN_TOUCH, prox);
2201 }
2202
2203 if (prox) {
2204 input_report_abs(input, mt ? ABS_MT_POSITION_X : ABS_X,
2205 hid_data->x);
2206 input_report_abs(input, mt ? ABS_MT_POSITION_Y : ABS_Y,
2207 hid_data->y);
Jason Gerecke488abb52015-07-21 11:07:25 -07002208
2209 if (test_bit(ABS_MT_TOUCH_MAJOR, input->absbit)) {
2210 input_report_abs(input, ABS_MT_TOUCH_MAJOR, max(hid_data->width, hid_data->height));
2211 input_report_abs(input, ABS_MT_TOUCH_MINOR, min(hid_data->width, hid_data->height));
2212 if (hid_data->width != hid_data->height)
2213 input_report_abs(input, ABS_MT_ORIENTATION, hid_data->width <= hid_data->height ? 0 : 1);
2214 }
Jason Gerecke601a22f2014-12-10 16:26:04 -08002215 }
2216}
2217
Ping Cheng354a3292016-12-08 22:03:27 -08002218static void wacom_wac_finger_event(struct hid_device *hdev,
Benjamin Tissoires5ae6e892014-09-23 12:08:09 -04002219 struct hid_field *field, struct hid_usage *usage, __s32 value)
2220{
2221 struct wacom *wacom = hid_get_drvdata(hdev);
2222 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
Jason Gereckec9c09582016-10-19 18:03:43 -07002223 unsigned equivalent_usage = wacom_equivalent_usage(usage->hid);
Benjamin Tissoires5ae6e892014-09-23 12:08:09 -04002224
Jason Gereckec9c09582016-10-19 18:03:43 -07002225 switch (equivalent_usage) {
Benjamin Tissoires5ae6e892014-09-23 12:08:09 -04002226 case HID_GD_X:
2227 wacom_wac->hid_data.x = value;
2228 break;
2229 case HID_GD_Y:
2230 wacom_wac->hid_data.y = value;
2231 break;
Jason Gerecke488abb52015-07-21 11:07:25 -07002232 case HID_DG_WIDTH:
2233 wacom_wac->hid_data.width = value;
2234 break;
2235 case HID_DG_HEIGHT:
2236 wacom_wac->hid_data.height = value;
2237 break;
Benjamin Tissoires5ae6e892014-09-23 12:08:09 -04002238 case HID_DG_CONTACTID:
2239 wacom_wac->hid_data.id = value;
2240 break;
2241 case HID_DG_TIPSWITCH:
2242 wacom_wac->hid_data.tipswitch = value;
2243 break;
2244 }
2245
2246
Jason Gerecke601a22f2014-12-10 16:26:04 -08002247 if (usage->usage_index + 1 == field->report_count) {
Jason Gereckec9c09582016-10-19 18:03:43 -07002248 if (equivalent_usage == wacom_wac->hid_data.last_slot_field)
Jason Gerecke2a6cdbd2015-06-15 18:01:45 -07002249 wacom_wac_finger_slot(wacom_wac, wacom_wac->touch_input);
Jason Gerecke601a22f2014-12-10 16:26:04 -08002250 }
Benjamin Tissoires5ae6e892014-09-23 12:08:09 -04002251}
2252
Jason Gerecke06324e02015-07-21 11:07:23 -07002253static void wacom_wac_finger_pre_report(struct hid_device *hdev,
2254 struct hid_report *report)
2255{
Jason Gerecke1b5d514a2015-07-21 11:07:24 -07002256 struct wacom *wacom = hid_get_drvdata(hdev);
2257 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
2258 struct hid_data* hid_data = &wacom_wac->hid_data;
Jason Gerecke003f50a2016-07-21 09:10:46 -07002259 int i;
Jason Gerecke1b5d514a2015-07-21 11:07:24 -07002260
Jason Gerecke003f50a2016-07-21 09:10:46 -07002261 for (i = 0; i < report->maxfield; i++) {
2262 struct hid_field *field = report->field[i];
2263 int j;
Jason Gerecke499522c2015-10-07 16:54:21 -07002264
Jason Gerecke003f50a2016-07-21 09:10:46 -07002265 for (j = 0; j < field->maxusage; j++) {
2266 struct hid_usage *usage = &field->usage[j];
Aaron Armstrong Skomraac2423c2017-01-25 12:08:40 -08002267 unsigned int equivalent_usage =
2268 wacom_equivalent_usage(usage->hid);
Jason Gerecke499522c2015-10-07 16:54:21 -07002269
Aaron Armstrong Skomraac2423c2017-01-25 12:08:40 -08002270 switch (equivalent_usage) {
Jason Gerecke003f50a2016-07-21 09:10:46 -07002271 case HID_GD_X:
2272 case HID_GD_Y:
2273 case HID_DG_WIDTH:
2274 case HID_DG_HEIGHT:
2275 case HID_DG_CONTACTID:
2276 case HID_DG_INRANGE:
2277 case HID_DG_INVERT:
2278 case HID_DG_TIPSWITCH:
Aaron Armstrong Skomraac2423c2017-01-25 12:08:40 -08002279 hid_data->last_slot_field = equivalent_usage;
Jason Gerecke003f50a2016-07-21 09:10:46 -07002280 break;
2281 case HID_DG_CONTACTCOUNT:
2282 hid_data->cc_report = report->id;
2283 hid_data->cc_index = i;
2284 hid_data->cc_value_index = j;
2285 break;
Jason Gerecke499522c2015-10-07 16:54:21 -07002286 }
2287 }
2288 }
Jason Gerecke003f50a2016-07-21 09:10:46 -07002289
Jason Gereckedf707932015-10-07 16:54:22 -07002290 if (hid_data->cc_report != 0 &&
2291 hid_data->cc_index >= 0) {
Jason Gerecke1b5d514a2015-07-21 11:07:24 -07002292 struct hid_field *field = report->field[hid_data->cc_index];
2293 int value = field->value[hid_data->cc_value_index];
2294 if (value)
2295 hid_data->num_expected = value;
2296 }
2297 else {
2298 hid_data->num_expected = wacom_wac->features.touch_max;
2299 }
Jason Gerecke06324e02015-07-21 11:07:23 -07002300}
2301
Benjamin Tissoires5ae6e892014-09-23 12:08:09 -04002302static void wacom_wac_finger_report(struct hid_device *hdev,
2303 struct hid_report *report)
2304{
2305 struct wacom *wacom = hid_get_drvdata(hdev);
2306 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
Jason Gerecke2a6cdbd2015-06-15 18:01:45 -07002307 struct input_dev *input = wacom_wac->touch_input;
Benjamin Tissoires5ae6e892014-09-23 12:08:09 -04002308 unsigned touch_max = wacom_wac->features.touch_max;
2309
Jason Gerecke1b5d514a2015-07-21 11:07:24 -07002310 /* If more packets of data are expected, give us a chance to
2311 * process them rather than immediately syncing a partial
2312 * update.
2313 */
2314 if (wacom_wac->hid_data.num_received < wacom_wac->hid_data.num_expected)
2315 return;
2316
Benjamin Tissoires5ae6e892014-09-23 12:08:09 -04002317 if (touch_max > 1)
Jason Gerecke601a22f2014-12-10 16:26:04 -08002318 input_mt_sync_frame(input);
2319
Benjamin Tissoires5ae6e892014-09-23 12:08:09 -04002320 input_sync(input);
Jason Gerecke1b5d514a2015-07-21 11:07:24 -07002321 wacom_wac->hid_data.num_received = 0;
Benjamin Tissoires5ae6e892014-09-23 12:08:09 -04002322
2323 /* keep touch state for pen event */
Ping Cheng7d059ed2015-03-20 14:57:21 -07002324 wacom_wac->shared->touch_down = wacom_wac_finger_count_touches(wacom_wac);
Benjamin Tissoires5ae6e892014-09-23 12:08:09 -04002325}
2326
Benjamin Tissoires7704ac92014-09-23 12:08:08 -04002327void wacom_wac_usage_mapping(struct hid_device *hdev,
2328 struct hid_field *field, struct hid_usage *usage)
2329{
2330 struct wacom *wacom = hid_get_drvdata(hdev);
2331 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
Jason Gereckee5bc8eb2016-08-08 12:06:29 -07002332 struct wacom_features *features = &wacom_wac->features;
Benjamin Tissoires7704ac92014-09-23 12:08:08 -04002333
Aaron Armstrong Skomraac2423c2017-01-25 12:08:40 -08002334 if (WACOM_DIRECT_DEVICE(field))
2335 features->device_type |= WACOM_DEVICETYPE_DIRECT;
Benjamin Tissoires7704ac92014-09-23 12:08:08 -04002336
Jason Gerecke5922e612016-10-19 18:03:51 -07002337 if (WACOM_PAD_FIELD(field))
Ping Cheng354a3292016-12-08 22:03:27 -08002338 wacom_wac_pad_usage_mapping(hdev, field, usage);
Jason Gerecke5922e612016-10-19 18:03:51 -07002339 else if (WACOM_PEN_FIELD(field))
Ping Cheng354a3292016-12-08 22:03:27 -08002340 wacom_wac_pen_usage_mapping(hdev, field, usage);
Jason Gerecke5922e612016-10-19 18:03:51 -07002341 else if (WACOM_FINGER_FIELD(field))
Ping Cheng354a3292016-12-08 22:03:27 -08002342 wacom_wac_finger_usage_mapping(hdev, field, usage);
Benjamin Tissoires7704ac92014-09-23 12:08:08 -04002343}
2344
Ping Cheng354a3292016-12-08 22:03:27 -08002345void wacom_wac_event(struct hid_device *hdev, struct hid_field *field,
Benjamin Tissoires7704ac92014-09-23 12:08:08 -04002346 struct hid_usage *usage, __s32 value)
2347{
2348 struct wacom *wacom = hid_get_drvdata(hdev);
2349
2350 if (wacom->wacom_wac.features.type != HID_GENERIC)
Ping Cheng354a3292016-12-08 22:03:27 -08002351 return;
Benjamin Tissoires7704ac92014-09-23 12:08:08 -04002352
Aaron Armstrong Skomra60a22182017-01-25 12:08:39 -08002353 if (value > field->logical_maximum || value < field->logical_minimum)
2354 return;
2355
Ping Chengc9cfb2a2016-12-08 22:06:15 -08002356 if (WACOM_PAD_FIELD(field)) {
2357 wacom_wac_pad_battery_event(hdev, field, usage, value);
2358 if (wacom->wacom_wac.pad_input)
2359 wacom_wac_pad_event(hdev, field, usage, value);
2360 } else if (WACOM_PEN_FIELD(field) && wacom->wacom_wac.pen_input)
Ping Cheng354a3292016-12-08 22:03:27 -08002361 wacom_wac_pen_event(hdev, field, usage, value);
Ping Cheng6f46cf92016-12-08 22:04:52 -08002362 else if (WACOM_FINGER_FIELD(field) && wacom->wacom_wac.touch_input)
Ping Cheng354a3292016-12-08 22:03:27 -08002363 wacom_wac_finger_event(hdev, field, usage, value);
Benjamin Tissoires7704ac92014-09-23 12:08:08 -04002364}
2365
Jason Gerecke06324e02015-07-21 11:07:23 -07002366static void wacom_report_events(struct hid_device *hdev, struct hid_report *report)
2367{
2368 int r;
2369
2370 for (r = 0; r < report->maxfield; r++) {
2371 struct hid_field *field;
2372 unsigned count, n;
2373
2374 field = report->field[r];
2375 count = field->report_count;
2376
2377 if (!(HID_MAIN_ITEM_VARIABLE & field->flags))
2378 continue;
2379
2380 for (n = 0; n < count; n++)
2381 wacom_wac_event(hdev, field, &field->usage[n], field->value[n]);
2382 }
2383}
2384
Benjamin Tissoires7704ac92014-09-23 12:08:08 -04002385void wacom_wac_report(struct hid_device *hdev, struct hid_report *report)
2386{
2387 struct wacom *wacom = hid_get_drvdata(hdev);
2388 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
2389 struct hid_field *field = report->field[0];
2390
2391 if (wacom_wac->features.type != HID_GENERIC)
2392 return;
2393
Ping Cheng6f46cf92016-12-08 22:04:52 -08002394 if (WACOM_PAD_FIELD(field) && wacom->wacom_wac.pad_input)
Jason Gerecke5922e612016-10-19 18:03:51 -07002395 wacom_wac_pad_pre_report(hdev, report);
Ping Cheng6f46cf92016-12-08 22:04:52 -08002396 else if (WACOM_PEN_FIELD(field) && wacom->wacom_wac.pen_input)
Jason Gerecke06324e02015-07-21 11:07:23 -07002397 wacom_wac_pen_pre_report(hdev, report);
Ping Cheng6f46cf92016-12-08 22:04:52 -08002398 else if (WACOM_FINGER_FIELD(field) && wacom->wacom_wac.touch_input)
Jason Gerecke06324e02015-07-21 11:07:23 -07002399 wacom_wac_finger_pre_report(hdev, report);
2400
2401 wacom_report_events(hdev, report);
2402
Jason Gereckea9ce7852017-01-17 15:38:58 -08002403 /*
2404 * Non-input reports may be sent prior to the device being
2405 * completely initialized. Since only their events need
2406 * to be processed, exit after 'wacom_report_events' has
2407 * been called to prevent potential crashes in the report-
2408 * processing functions.
2409 */
2410 if (report->type != HID_INPUT_REPORT)
2411 return;
2412
Ping Chengc9cfb2a2016-12-08 22:06:15 -08002413 if (WACOM_PAD_FIELD(field)) {
2414 wacom_wac_pad_battery_report(hdev, report);
2415 if (wacom->wacom_wac.pad_input)
2416 wacom_wac_pad_report(hdev, report);
2417 } else if (WACOM_PEN_FIELD(field) && wacom->wacom_wac.pen_input)
2418 wacom_wac_pen_report(hdev, report);
Ping Cheng6f46cf92016-12-08 22:04:52 -08002419 else if (WACOM_FINGER_FIELD(field) && wacom->wacom_wac.touch_input)
Ping Chengc9cfb2a2016-12-08 22:06:15 -08002420 wacom_wac_finger_report(hdev, report);
Benjamin Tissoires7704ac92014-09-23 12:08:08 -04002421}
2422
Chris Bagwelle1d38e42010-09-12 00:09:27 -07002423static int wacom_bpt_touch(struct wacom_wac *wacom)
Henrik Rydbergcb734c02010-09-05 12:53:16 -07002424{
Henrik Rydbergf4ccbef2010-09-05 12:57:13 -07002425 struct wacom_features *features = &wacom->features;
Jason Gerecke2a6cdbd2015-06-15 18:01:45 -07002426 struct input_dev *input = wacom->touch_input;
Benjamin Tissoires31168712014-07-24 12:50:10 -07002427 struct input_dev *pad_input = wacom->pad_input;
Henrik Rydbergcb734c02010-09-05 12:53:16 -07002428 unsigned char *data = wacom->data;
Henrik Rydbergcb734c02010-09-05 12:53:16 -07002429 int i;
2430
Chris Bagwell5a6c8652011-11-07 19:52:42 -08002431 if (data[0] != 0x02)
2432 return 0;
2433
Henrik Rydbergcb734c02010-09-05 12:53:16 -07002434 for (i = 0; i < 2; i++) {
Chris Bagwell8f906862011-09-09 13:38:10 -07002435 int offset = (data[1] & 0x80) ? (8 * i) : (9 * i);
Ping Cheng1924e052016-08-09 14:38:56 -07002436 bool touch = report_touch_events(wacom)
2437 && (data[offset + 3] & 0x80);
Chris Bagwell8f906862011-09-09 13:38:10 -07002438
2439 input_mt_slot(input, i);
2440 input_mt_report_slot_state(input, MT_TOOL_FINGER, touch);
Henrik Rydbergc5f4dec2010-12-15 13:50:34 +01002441 if (touch) {
Chris Bagwell8f906862011-09-09 13:38:10 -07002442 int x = get_unaligned_be16(&data[offset + 3]) & 0x7ff;
2443 int y = get_unaligned_be16(&data[offset + 5]) & 0x7ff;
Henrik Rydbergf4ccbef2010-09-05 12:57:13 -07002444 if (features->quirks & WACOM_QUIRK_BBTOUCH_LOWRES) {
2445 x <<= 5;
2446 y <<= 5;
2447 }
Henrik Rydbergcb734c02010-09-05 12:53:16 -07002448 input_report_abs(input, ABS_MT_POSITION_X, x);
2449 input_report_abs(input, ABS_MT_POSITION_Y, y);
Henrik Rydbergcb734c02010-09-05 12:53:16 -07002450 }
Henrik Rydbergcb734c02010-09-05 12:53:16 -07002451 }
2452
Benjamin Tissoires9a1c0012015-02-17 14:19:46 -05002453 input_mt_sync_frame(input);
Henrik Rydbergcb734c02010-09-05 12:53:16 -07002454
Benjamin Tissoires31168712014-07-24 12:50:10 -07002455 input_report_key(pad_input, BTN_LEFT, (data[1] & 0x08) != 0);
2456 input_report_key(pad_input, BTN_FORWARD, (data[1] & 0x04) != 0);
2457 input_report_key(pad_input, BTN_BACK, (data[1] & 0x02) != 0);
2458 input_report_key(pad_input, BTN_RIGHT, (data[1] & 0x01) != 0);
Ping Cheng7d059ed2015-03-20 14:57:21 -07002459 wacom->shared->touch_down = wacom_wac_finger_count_touches(wacom);
Henrik Rydbergcb734c02010-09-05 12:53:16 -07002460
Benjamin Tissoires31168712014-07-24 12:50:10 -07002461 return 1;
Henrik Rydbergcb734c02010-09-05 12:53:16 -07002462}
2463
Ping Cheng7d059ed2015-03-20 14:57:21 -07002464static void wacom_bpt3_touch_msg(struct wacom_wac *wacom, unsigned char *data)
Chris Bagwell73149ab2011-10-26 22:34:21 -07002465{
Ping Cheng9a35c412013-09-20 09:51:56 -07002466 struct wacom_features *features = &wacom->features;
Jason Gerecke2a6cdbd2015-06-15 18:01:45 -07002467 struct input_dev *input = wacom->touch_input;
Chris Bagwell73149ab2011-10-26 22:34:21 -07002468 bool touch = data[1] & 0x80;
Ping Cheng02295e62013-01-04 23:56:00 -08002469 int slot = input_mt_get_slot_by_key(input, data[0]);
2470
2471 if (slot < 0)
Ping Cheng7d059ed2015-03-20 14:57:21 -07002472 return;
Chris Bagwell73149ab2011-10-26 22:34:21 -07002473
Ping Cheng1924e052016-08-09 14:38:56 -07002474 touch = touch && report_touch_events(wacom);
Chris Bagwell73149ab2011-10-26 22:34:21 -07002475
Ping Cheng02295e62013-01-04 23:56:00 -08002476 input_mt_slot(input, slot);
Chris Bagwell73149ab2011-10-26 22:34:21 -07002477 input_mt_report_slot_state(input, MT_TOOL_FINGER, touch);
2478
2479 if (touch) {
2480 int x = (data[2] << 4) | (data[4] >> 4);
2481 int y = (data[3] << 4) | (data[4] & 0x0f);
Ping Cheng9a35c412013-09-20 09:51:56 -07002482 int width, height;
Jason Gerecke4e904952012-10-03 17:19:11 -07002483
Ping Chengeda01da2015-09-23 13:51:15 -07002484 if (features->type >= INTUOSPS && features->type <= INTUOSHT2) {
Jason Gerecke0b279da2013-11-25 18:43:16 -08002485 width = data[5] * 100;
2486 height = data[6] * 100;
Ping Cheng9a35c412013-09-20 09:51:56 -07002487 } else {
2488 /*
2489 * "a" is a scaled-down area which we assume is
2490 * roughly circular and which can be described as:
2491 * a=(pi*r^2)/C.
2492 */
2493 int a = data[5];
Ping Chengd7da3a32014-06-13 13:37:33 -07002494 int x_res = input_abs_get_res(input, ABS_MT_POSITION_X);
2495 int y_res = input_abs_get_res(input, ABS_MT_POSITION_Y);
2496 width = 2 * int_sqrt(a * WACOM_CONTACT_AREA_SCALE);
Ping Cheng9a35c412013-09-20 09:51:56 -07002497 height = width * y_res / x_res;
2498 }
Chris Bagwell73149ab2011-10-26 22:34:21 -07002499
2500 input_report_abs(input, ABS_MT_POSITION_X, x);
2501 input_report_abs(input, ABS_MT_POSITION_Y, y);
Jason Gerecke4e904952012-10-03 17:19:11 -07002502 input_report_abs(input, ABS_MT_TOUCH_MAJOR, width);
2503 input_report_abs(input, ABS_MT_TOUCH_MINOR, height);
Chris Bagwell73149ab2011-10-26 22:34:21 -07002504 }
2505}
2506
2507static void wacom_bpt3_button_msg(struct wacom_wac *wacom, unsigned char *data)
2508{
Benjamin Tissoires31168712014-07-24 12:50:10 -07002509 struct input_dev *input = wacom->pad_input;
Ping Chengb5fd2a32013-11-25 18:44:55 -08002510 struct wacom_features *features = &wacom->features;
Chris Bagwell73149ab2011-10-26 22:34:21 -07002511
Ping Chengeda01da2015-09-23 13:51:15 -07002512 if (features->type == INTUOSHT || features->type == INTUOSHT2) {
Ping Chengb5fd2a32013-11-25 18:44:55 -08002513 input_report_key(input, BTN_LEFT, (data[1] & 0x02) != 0);
2514 input_report_key(input, BTN_BACK, (data[1] & 0x08) != 0);
2515 } else {
2516 input_report_key(input, BTN_BACK, (data[1] & 0x02) != 0);
2517 input_report_key(input, BTN_LEFT, (data[1] & 0x08) != 0);
2518 }
Chris Bagwell73149ab2011-10-26 22:34:21 -07002519 input_report_key(input, BTN_FORWARD, (data[1] & 0x04) != 0);
Chris Bagwell73149ab2011-10-26 22:34:21 -07002520 input_report_key(input, BTN_RIGHT, (data[1] & 0x01) != 0);
2521}
2522
2523static int wacom_bpt3_touch(struct wacom_wac *wacom)
2524{
Chris Bagwell73149ab2011-10-26 22:34:21 -07002525 unsigned char *data = wacom->data;
Jason Gerecke19d57d32012-03-06 10:19:19 -08002526 int count = data[1] & 0x07;
Ping Chengeda01da2015-09-23 13:51:15 -07002527 int touch_changed = 0, i;
Chris Bagwell73149ab2011-10-26 22:34:21 -07002528
Chris Bagwell5a6c8652011-11-07 19:52:42 -08002529 if (data[0] != 0x02)
2530 return 0;
2531
Chris Bagwell73149ab2011-10-26 22:34:21 -07002532 /* data has up to 7 fixed sized 8-byte messages starting at data[2] */
2533 for (i = 0; i < count; i++) {
2534 int offset = (8 * i) + 2;
2535 int msg_id = data[offset];
2536
Ping Chengeda01da2015-09-23 13:51:15 -07002537 if (msg_id >= 2 && msg_id <= 17) {
Ping Cheng7d059ed2015-03-20 14:57:21 -07002538 wacom_bpt3_touch_msg(wacom, data + offset);
Ping Chengeda01da2015-09-23 13:51:15 -07002539 touch_changed++;
2540 } else if (msg_id == 128)
Chris Bagwell73149ab2011-10-26 22:34:21 -07002541 wacom_bpt3_button_msg(wacom, data + offset);
2542
2543 }
Jason Gerecke2a6cdbd2015-06-15 18:01:45 -07002544
Ping Chengeda01da2015-09-23 13:51:15 -07002545 /* only update touch if we actually have a touchpad and touch data changed */
Benjamin Tissoires84dfbd72016-07-13 18:05:55 +02002546 if (wacom->touch_input && touch_changed) {
Jason Gerecke2a6cdbd2015-06-15 18:01:45 -07002547 input_mt_sync_frame(wacom->touch_input);
2548 wacom->shared->touch_down = wacom_wac_finger_count_touches(wacom);
2549 }
Chris Bagwell73149ab2011-10-26 22:34:21 -07002550
Benjamin Tissoires31168712014-07-24 12:50:10 -07002551 return 1;
Chris Bagwell73149ab2011-10-26 22:34:21 -07002552}
2553
Chris Bagwell2aaacb12010-09-12 00:11:35 -07002554static int wacom_bpt_pen(struct wacom_wac *wacom)
2555{
Ping Cheng961794a2013-12-05 12:54:53 -08002556 struct wacom_features *features = &wacom->features;
Jason Gerecke2a6cdbd2015-06-15 18:01:45 -07002557 struct input_dev *input = wacom->pen_input;
Chris Bagwell2aaacb12010-09-12 00:11:35 -07002558 unsigned char *data = wacom->data;
2559 int prox = 0, x = 0, y = 0, p = 0, d = 0, pen = 0, btn1 = 0, btn2 = 0;
2560
Jason Gerecke4ca4ec72015-03-06 11:47:38 -08002561 if (data[0] != WACOM_REPORT_PENABLED)
Chris Bagwell5a6c8652011-11-07 19:52:42 -08002562 return 0;
2563
Chris Bagwellc5981412011-10-26 22:28:34 -07002564 prox = (data[1] & 0x20) == 0x20;
Chris Bagwell2aaacb12010-09-12 00:11:35 -07002565
2566 /*
2567 * All reports shared between PEN and RUBBER tool must be
2568 * forced to a known starting value (zero) when transitioning to
2569 * out-of-prox.
2570 *
2571 * If not reset then, to userspace, it will look like lost events
2572 * if new tool comes in-prox with same values as previous tool sent.
2573 *
2574 * Hardware does report zero in most out-of-prox cases but not all.
2575 */
Ping Cheng01499312015-03-20 14:58:01 -07002576 if (!wacom->shared->stylus_in_proximity) {
2577 if (data[1] & 0x08) {
2578 wacom->tool[0] = BTN_TOOL_RUBBER;
2579 wacom->id[0] = ERASER_DEVICE_ID;
2580 } else {
2581 wacom->tool[0] = BTN_TOOL_PEN;
2582 wacom->id[0] = STYLUS_DEVICE_ID;
Chris Bagwell2aaacb12010-09-12 00:11:35 -07002583 }
Ping Cheng01499312015-03-20 14:58:01 -07002584 }
2585
2586 wacom->shared->stylus_in_proximity = prox;
Ping Cheng1924e052016-08-09 14:38:56 -07002587 if (delay_pen_events(wacom))
Ping Cheng01499312015-03-20 14:58:01 -07002588 return 0;
2589
2590 if (prox) {
Chris Bagwell2aaacb12010-09-12 00:11:35 -07002591 x = le16_to_cpup((__le16 *)&data[2]);
2592 y = le16_to_cpup((__le16 *)&data[4]);
2593 p = le16_to_cpup((__le16 *)&data[6]);
Chris Bagwellc18c2ce2011-10-10 08:52:13 -07002594 /*
2595 * Convert distance from out prox to distance from tablet.
2596 * distance will be greater than distance_max once
2597 * touching and applying pressure; do not report negative
2598 * distance.
2599 */
Ping Cheng961794a2013-12-05 12:54:53 -08002600 if (data[8] <= features->distance_max)
2601 d = features->distance_max - data[8];
Chris Bagwellc18c2ce2011-10-10 08:52:13 -07002602
Chris Bagwell2aaacb12010-09-12 00:11:35 -07002603 pen = data[1] & 0x01;
2604 btn1 = data[1] & 0x02;
2605 btn2 = data[1] & 0x04;
Ping Cheng01499312015-03-20 14:58:01 -07002606 } else {
2607 wacom->id[0] = 0;
Chris Bagwell2aaacb12010-09-12 00:11:35 -07002608 }
2609
2610 input_report_key(input, BTN_TOUCH, pen);
2611 input_report_key(input, BTN_STYLUS, btn1);
2612 input_report_key(input, BTN_STYLUS2, btn2);
2613
2614 input_report_abs(input, ABS_X, x);
2615 input_report_abs(input, ABS_Y, y);
2616 input_report_abs(input, ABS_PRESSURE, p);
2617 input_report_abs(input, ABS_DISTANCE, d);
2618
Chris Bagwell2aaacb12010-09-12 00:11:35 -07002619 input_report_key(input, wacom->tool[0], prox); /* PEN or RUBBER */
2620 input_report_abs(input, ABS_MISC, wacom->id[0]); /* TOOL ID */
2621
2622 return 1;
2623}
2624
Chris Bagwelle1d38e42010-09-12 00:09:27 -07002625static int wacom_bpt_irq(struct wacom_wac *wacom, size_t len)
2626{
Ping Chengeda01da2015-09-23 13:51:15 -07002627 struct wacom_features *features = &wacom->features;
2628
2629 if ((features->type == INTUOSHT2) &&
Ping Chengeda01da2015-09-23 13:51:15 -07002630 (features->device_type & WACOM_DEVICETYPE_PEN))
2631 return wacom_intuos_irq(wacom);
2632 else if (len == WACOM_PKGLEN_BBTOUCH)
Chris Bagwelle1d38e42010-09-12 00:09:27 -07002633 return wacom_bpt_touch(wacom);
Chris Bagwell73149ab2011-10-26 22:34:21 -07002634 else if (len == WACOM_PKGLEN_BBTOUCH3)
2635 return wacom_bpt3_touch(wacom);
2636 else if (len == WACOM_PKGLEN_BBFUN || len == WACOM_PKGLEN_BBPEN)
Chris Bagwell2aaacb12010-09-12 00:11:35 -07002637 return wacom_bpt_pen(wacom);
Chris Bagwelle1d38e42010-09-12 00:09:27 -07002638
2639 return 0;
2640}
2641
Benjamin Tissoires8c97a762015-02-26 11:28:50 -05002642static void wacom_bamboo_pad_pen_event(struct wacom_wac *wacom,
2643 unsigned char *data)
2644{
2645 unsigned char prefix;
2646
2647 /*
2648 * We need to reroute the event from the debug interface to the
2649 * pen interface.
2650 * We need to add the report ID to the actual pen report, so we
2651 * temporary overwrite the first byte to prevent having to kzalloc/kfree
2652 * and memcpy the report.
2653 */
2654 prefix = data[0];
2655 data[0] = WACOM_REPORT_BPAD_PEN;
2656
2657 /*
2658 * actually reroute the event.
2659 * No need to check if wacom->shared->pen is valid, hid_input_report()
2660 * will check for us.
2661 */
2662 hid_input_report(wacom->shared->pen, HID_INPUT_REPORT, data,
2663 WACOM_PKGLEN_PENABLED, 1);
2664
2665 data[0] = prefix;
2666}
2667
2668static int wacom_bamboo_pad_touch_event(struct wacom_wac *wacom,
2669 unsigned char *data)
2670{
Jason Gerecke2a6cdbd2015-06-15 18:01:45 -07002671 struct input_dev *input = wacom->touch_input;
Benjamin Tissoires8c97a762015-02-26 11:28:50 -05002672 unsigned char *finger_data, prefix;
2673 unsigned id;
2674 int x, y;
2675 bool valid;
2676
2677 prefix = data[0];
2678
2679 for (id = 0; id < wacom->features.touch_max; id++) {
2680 valid = !!(prefix & BIT(id)) &&
Ping Cheng1924e052016-08-09 14:38:56 -07002681 report_touch_events(wacom);
Benjamin Tissoires8c97a762015-02-26 11:28:50 -05002682
2683 input_mt_slot(input, id);
2684 input_mt_report_slot_state(input, MT_TOOL_FINGER, valid);
2685
2686 if (!valid)
2687 continue;
2688
2689 finger_data = data + 1 + id * 3;
2690 x = finger_data[0] | ((finger_data[1] & 0x0f) << 8);
2691 y = (finger_data[2] << 4) | (finger_data[1] >> 4);
2692
2693 input_report_abs(input, ABS_MT_POSITION_X, x);
2694 input_report_abs(input, ABS_MT_POSITION_Y, y);
2695 }
2696
2697 input_mt_sync_frame(input);
2698
2699 input_report_key(input, BTN_LEFT, prefix & 0x40);
2700 input_report_key(input, BTN_RIGHT, prefix & 0x80);
2701
2702 /* keep touch state for pen event */
Ping Cheng1924e052016-08-09 14:38:56 -07002703 wacom->shared->touch_down = !!prefix && report_touch_events(wacom);
Benjamin Tissoires8c97a762015-02-26 11:28:50 -05002704
2705 return 1;
2706}
2707
2708static int wacom_bamboo_pad_irq(struct wacom_wac *wacom, size_t len)
2709{
2710 unsigned char *data = wacom->data;
2711
2712 if (!((len == WACOM_PKGLEN_BPAD_TOUCH) ||
2713 (len == WACOM_PKGLEN_BPAD_TOUCH_USB)) ||
2714 (data[0] != WACOM_REPORT_BPAD_TOUCH))
2715 return 0;
2716
2717 if (data[1] & 0x01)
2718 wacom_bamboo_pad_pen_event(wacom, &data[1]);
2719
2720 if (data[1] & 0x02)
2721 return wacom_bamboo_pad_touch_event(wacom, &data[9]);
2722
2723 return 0;
2724}
2725
Chris Bagwelld3825d52012-03-25 23:26:11 -07002726static int wacom_wireless_irq(struct wacom_wac *wacom, size_t len)
2727{
Chris Bagwell16bf2882012-03-25 23:26:20 -07002728 unsigned char *data = wacom->data;
2729 int connected;
2730
Ping Chengb5fd2a32013-11-25 18:44:55 -08002731 if (len != WACOM_PKGLEN_WIRELESS || data[0] != WACOM_REPORT_WL)
Chris Bagwelld3825d52012-03-25 23:26:11 -07002732 return 0;
2733
Chris Bagwell16bf2882012-03-25 23:26:20 -07002734 connected = data[1] & 0x01;
2735 if (connected) {
Jason Gereckeb0882cb2015-03-06 11:47:43 -08002736 int pid, battery, charging;
Chris Bagwell16bf2882012-03-25 23:26:20 -07002737
Ping Chengeda01da2015-09-23 13:51:15 -07002738 if ((wacom->shared->type == INTUOSHT ||
2739 wacom->shared->type == INTUOSHT2) &&
Ping Cheng44b96832014-11-06 17:30:51 -08002740 wacom->shared->touch_input &&
2741 wacom->shared->touch_max) {
Ping Cheng961794a2013-12-05 12:54:53 -08002742 input_report_switch(wacom->shared->touch_input,
2743 SW_MUTE_DEVICE, data[5] & 0x40);
2744 input_sync(wacom->shared->touch_input);
2745 }
2746
Chris Bagwell16bf2882012-03-25 23:26:20 -07002747 pid = get_unaligned_be16(&data[6]);
Benjamin Tissoiresac8d1012014-07-25 17:29:48 -07002748 battery = (data[5] & 0x3f) * 100 / 31;
Jason Gereckeb0882cb2015-03-06 11:47:43 -08002749 charging = !!(data[5] & 0x80);
Chris Bagwell16bf2882012-03-25 23:26:20 -07002750 if (wacom->pid != pid) {
2751 wacom->pid = pid;
Benjamin Tissoiresd17d1f12016-07-13 18:05:52 +02002752 wacom_schedule_work(wacom, WACOM_WORKER_WIRELESS);
Chris Bagwell16bf2882012-03-25 23:26:20 -07002753 }
Benjamin Tissoiresac8d1012014-07-25 17:29:48 -07002754
Benjamin Tissoires59d69bc2016-07-13 18:06:08 +02002755 wacom_notify_battery(wacom, battery, charging, 1, 0);
Jason Gerecke953f2c52015-03-06 11:47:39 -08002756
Chris Bagwell16bf2882012-03-25 23:26:20 -07002757 } else if (wacom->pid != 0) {
2758 /* disconnected while previously connected */
2759 wacom->pid = 0;
Benjamin Tissoiresd17d1f12016-07-13 18:05:52 +02002760 wacom_schedule_work(wacom, WACOM_WORKER_WIRELESS);
Jason Gerecke71fa6412015-03-11 10:25:41 -07002761 wacom_notify_battery(wacom, 0, 0, 0, 0);
Chris Bagwell16bf2882012-03-25 23:26:20 -07002762 }
2763
Chris Bagwelld3825d52012-03-25 23:26:11 -07002764 return 0;
2765}
2766
Jason Gerecke4ca4ec72015-03-06 11:47:38 -08002767static int wacom_status_irq(struct wacom_wac *wacom_wac, size_t len)
2768{
Jason Gerecke8f93b0b2015-03-06 11:47:41 -08002769 struct wacom *wacom = container_of(wacom_wac, struct wacom, wacom_wac);
Jason Gerecke4ca4ec72015-03-06 11:47:38 -08002770 struct wacom_features *features = &wacom_wac->features;
2771 unsigned char *data = wacom_wac->data;
2772
2773 if (data[0] != WACOM_REPORT_USB)
2774 return 0;
2775
Ping Chengeda01da2015-09-23 13:51:15 -07002776 if ((features->type == INTUOSHT ||
2777 features->type == INTUOSHT2) &&
Jason Gerecke4ca4ec72015-03-06 11:47:38 -08002778 wacom_wac->shared->touch_input &&
2779 features->touch_max) {
2780 input_report_switch(wacom_wac->shared->touch_input,
2781 SW_MUTE_DEVICE, data[8] & 0x40);
2782 input_sync(wacom_wac->shared->touch_input);
2783 }
Jason Gerecke8f93b0b2015-03-06 11:47:41 -08002784
2785 if (data[9] & 0x02) { /* wireless module is attached */
2786 int battery = (data[8] & 0x3f) * 100 / 31;
Jason Gereckeb0882cb2015-03-06 11:47:43 -08002787 bool charging = !!(data[8] & 0x80);
Jason Gerecke8f93b0b2015-03-06 11:47:41 -08002788
2789 wacom_notify_battery(wacom_wac, battery, charging,
Jason Gerecke71fa6412015-03-11 10:25:41 -07002790 battery || charging, 1);
Jason Gerecke8f93b0b2015-03-06 11:47:41 -08002791
Benjamin Tissoires59d69bc2016-07-13 18:06:08 +02002792 if (!wacom->battery.battery &&
Jason Gerecke8f93b0b2015-03-06 11:47:41 -08002793 !(features->quirks & WACOM_QUIRK_BATTERY)) {
2794 features->quirks |= WACOM_QUIRK_BATTERY;
Benjamin Tissoiresd17d1f12016-07-13 18:05:52 +02002795 wacom_schedule_work(wacom_wac, WACOM_WORKER_BATTERY);
Jason Gerecke8f93b0b2015-03-06 11:47:41 -08002796 }
2797 }
2798 else if ((features->quirks & WACOM_QUIRK_BATTERY) &&
Benjamin Tissoires59d69bc2016-07-13 18:06:08 +02002799 wacom->battery.battery) {
Jason Gerecke8f93b0b2015-03-06 11:47:41 -08002800 features->quirks &= ~WACOM_QUIRK_BATTERY;
Benjamin Tissoiresd17d1f12016-07-13 18:05:52 +02002801 wacom_schedule_work(wacom_wac, WACOM_WORKER_BATTERY);
Jason Gerecke71fa6412015-03-11 10:25:41 -07002802 wacom_notify_battery(wacom_wac, 0, 0, 0, 0);
Jason Gerecke8f93b0b2015-03-06 11:47:41 -08002803 }
Jason Gerecke4ca4ec72015-03-06 11:47:38 -08002804 return 0;
2805}
2806
Dmitry Torokhov95dd3b32010-03-19 22:18:15 -07002807void wacom_wac_irq(struct wacom_wac *wacom_wac, size_t len)
Ping Cheng3bea7332006-07-13 18:01:36 -07002808{
Dmitry Torokhov95dd3b32010-03-19 22:18:15 -07002809 bool sync;
2810
Jason Childse33da8a2010-02-17 22:38:31 -08002811 switch (wacom_wac->features.type) {
Dmitry Torokhov73a97f42010-03-19 22:18:15 -07002812 case PENPARTNER:
Dmitry Torokhov95dd3b32010-03-19 22:18:15 -07002813 sync = wacom_penpartner_irq(wacom_wac);
2814 break;
Ping Cheng545f4e92008-11-24 11:44:27 -05002815
Dmitry Torokhov73a97f42010-03-19 22:18:15 -07002816 case PL:
Dmitry Torokhov95dd3b32010-03-19 22:18:15 -07002817 sync = wacom_pl_irq(wacom_wac);
2818 break;
Ping Cheng545f4e92008-11-24 11:44:27 -05002819
Dmitry Torokhov73a97f42010-03-19 22:18:15 -07002820 case WACOM_G4:
2821 case GRAPHIRE:
Benjamin Tissoires387142b2014-08-06 13:52:56 -07002822 case GRAPHIRE_BT:
Dmitry Torokhov73a97f42010-03-19 22:18:15 -07002823 case WACOM_MO:
Dmitry Torokhov95dd3b32010-03-19 22:18:15 -07002824 sync = wacom_graphire_irq(wacom_wac);
2825 break;
Ping Cheng545f4e92008-11-24 11:44:27 -05002826
Dmitry Torokhov73a97f42010-03-19 22:18:15 -07002827 case PTU:
Dmitry Torokhov95dd3b32010-03-19 22:18:15 -07002828 sync = wacom_ptu_irq(wacom_wac);
2829 break;
Ping Cheng545f4e92008-11-24 11:44:27 -05002830
Ping Chengc8f2edc2010-06-28 01:10:51 -07002831 case DTU:
2832 sync = wacom_dtu_irq(wacom_wac);
2833 break;
2834
Ping Cheng497ab1f2014-01-20 20:18:04 -08002835 case DTUS:
Ping Chengfff00bf2014-12-04 18:23:04 -08002836 case DTUSX:
Ping Cheng497ab1f2014-01-20 20:18:04 -08002837 sync = wacom_dtus_irq(wacom_wac);
2838 break;
2839
Dmitry Torokhov73a97f42010-03-19 22:18:15 -07002840 case INTUOS:
2841 case INTUOS3S:
2842 case INTUOS3:
2843 case INTUOS3L:
2844 case INTUOS4S:
2845 case INTUOS4:
2846 case INTUOS4L:
2847 case CINTIQ:
2848 case WACOM_BEE:
Ping Cheng56218562013-05-05 19:56:18 -07002849 case WACOM_13HD:
Ping Cheng3a4b4aa2010-06-03 22:10:21 -07002850 case WACOM_21UX2:
Ping Chengd838c642012-07-24 23:54:11 -07002851 case WACOM_22HD:
Jason Gerecke803296b2011-12-12 00:11:45 -08002852 case WACOM_24HD:
Ping Cheng500d4162015-01-27 13:30:03 -08002853 case WACOM_27QHD:
Ping Chenga112e9f2013-02-13 20:20:01 -08002854 case DTK:
Jason Gerecke36d3c512013-09-20 09:47:35 -07002855 case CINTIQ_HYBRID:
Jason Gereckef7acb552015-10-13 10:03:49 -07002856 case CINTIQ_COMPANION_2:
Dmitry Torokhov95dd3b32010-03-19 22:18:15 -07002857 sync = wacom_intuos_irq(wacom_wac);
2858 break;
Ping Cheng545f4e92008-11-24 11:44:27 -05002859
Benjamin Tissoires81af7e62014-08-06 13:55:56 -07002860 case INTUOS4WL:
2861 sync = wacom_intuos_bt_irq(wacom_wac, len);
2862 break;
2863
Jason Gereckeb1e42792012-10-21 00:38:04 -07002864 case WACOM_24HDT:
Ping Cheng500d4162015-01-27 13:30:03 -08002865 case WACOM_27QHDT:
Jason Gereckeb1e42792012-10-21 00:38:04 -07002866 sync = wacom_24hdt_irq(wacom_wac);
2867 break;
2868
Jason Gereckeae584ca2012-04-03 15:50:40 -07002869 case INTUOS5S:
2870 case INTUOS5:
2871 case INTUOS5L:
Ping Cheng9a35c412013-09-20 09:51:56 -07002872 case INTUOSPS:
2873 case INTUOSPM:
2874 case INTUOSPL:
Jason Gereckeae584ca2012-04-03 15:50:40 -07002875 if (len == WACOM_PKGLEN_BBTOUCH3)
2876 sync = wacom_bpt3_touch(wacom_wac);
Jason Gerecke2d13a432015-03-06 11:47:42 -08002877 else if (wacom_wac->data[0] == WACOM_REPORT_USB)
2878 sync = wacom_status_irq(wacom_wac, len);
Jason Gereckeae584ca2012-04-03 15:50:40 -07002879 else
2880 sync = wacom_intuos_irq(wacom_wac);
2881 break;
2882
Jason Gerecke4922cd22017-01-25 12:08:37 -08002883 case INTUOSP2_BT:
2884 sync = wacom_intuos_pro2_bt_irq(wacom_wac, len);
2885 break;
2886
Dmitry Torokhov73a97f42010-03-19 22:18:15 -07002887 case TABLETPC:
Ping Chengac173832012-06-12 00:15:06 -07002888 case TABLETPCE:
Dmitry Torokhov73a97f42010-03-19 22:18:15 -07002889 case TABLETPC2FG:
Ping Cheng19635182012-04-29 21:09:18 -07002890 case MTSCREEN:
Ping Cheng6afdc282012-11-03 12:16:15 -07002891 case MTTPC:
Jason Gerecked51ddb22014-05-14 17:14:29 -07002892 case MTTPC_B:
Dmitry Torokhov95dd3b32010-03-19 22:18:15 -07002893 sync = wacom_tpc_irq(wacom_wac, len);
2894 break;
Ping Cheng545f4e92008-11-24 11:44:27 -05002895
Henrik Rydbergcb734c02010-09-05 12:53:16 -07002896 case BAMBOO_PT:
Ping Cheng3b164a02015-09-23 09:59:10 -07002897 case BAMBOO_PEN:
2898 case BAMBOO_TOUCH:
Ping Chengb5fd2a32013-11-25 18:44:55 -08002899 case INTUOSHT:
Ping Chengeda01da2015-09-23 13:51:15 -07002900 case INTUOSHT2:
Jason Gerecke4ca4ec72015-03-06 11:47:38 -08002901 if (wacom_wac->data[0] == WACOM_REPORT_USB)
2902 sync = wacom_status_irq(wacom_wac, len);
2903 else
2904 sync = wacom_bpt_irq(wacom_wac, len);
Henrik Rydbergcb734c02010-09-05 12:53:16 -07002905 break;
2906
Benjamin Tissoires8c97a762015-02-26 11:28:50 -05002907 case BAMBOO_PAD:
2908 sync = wacom_bamboo_pad_irq(wacom_wac, len);
Ping Cheng3bea7332006-07-13 18:01:36 -07002909 break;
2910
Chris Bagwelld3825d52012-03-25 23:26:11 -07002911 case WIRELESS:
2912 sync = wacom_wireless_irq(wacom_wac, len);
2913 break;
2914
Aaron Skomra72b236d2015-08-20 16:05:17 -07002915 case REMOTE:
Benjamin Tissoirese6f28132016-07-13 18:06:01 +02002916 sync = false;
Aaron Skomra72b236d2015-08-20 16:05:17 -07002917 if (wacom_wac->data[0] == WACOM_REPORT_DEVICE_LIST)
Benjamin Tissoirese6f28132016-07-13 18:06:01 +02002918 wacom_remote_status_irq(wacom_wac, len);
Aaron Skomra72b236d2015-08-20 16:05:17 -07002919 else
2920 sync = wacom_remote_irq(wacom_wac, len);
2921 break;
2922
Dmitry Torokhov73a97f42010-03-19 22:18:15 -07002923 default:
Dmitry Torokhov95dd3b32010-03-19 22:18:15 -07002924 sync = false;
2925 break;
Ping Cheng3bea7332006-07-13 18:01:36 -07002926 }
Dmitry Torokhov95dd3b32010-03-19 22:18:15 -07002927
Benjamin Tissoiresd2d13f12014-07-24 12:48:28 -07002928 if (sync) {
Jason Gerecke2a6cdbd2015-06-15 18:01:45 -07002929 if (wacom_wac->pen_input)
2930 input_sync(wacom_wac->pen_input);
2931 if (wacom_wac->touch_input)
2932 input_sync(wacom_wac->touch_input);
Benjamin Tissoiresd2d13f12014-07-24 12:48:28 -07002933 if (wacom_wac->pad_input)
2934 input_sync(wacom_wac->pad_input);
2935 }
Ping Cheng3bea7332006-07-13 18:01:36 -07002936}
2937
Ping Chengeda01da2015-09-23 13:51:15 -07002938static void wacom_setup_basic_pro_pen(struct wacom_wac *wacom_wac)
Ping Cheng3bea7332006-07-13 18:01:36 -07002939{
Jason Gerecke2a6cdbd2015-06-15 18:01:45 -07002940 struct input_dev *input_dev = wacom_wac->pen_input;
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -07002941
2942 input_set_capability(input_dev, EV_MSC, MSC_SERIAL);
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -07002943
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -07002944 __set_bit(BTN_TOOL_PEN, input_dev->keybit);
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -07002945 __set_bit(BTN_STYLUS, input_dev->keybit);
2946 __set_bit(BTN_STYLUS2, input_dev->keybit);
2947
2948 input_set_abs_params(input_dev, ABS_DISTANCE,
Jason Gereckebef7e202016-04-22 14:30:53 -07002949 0, wacom_wac->features.distance_max, wacom_wac->features.distance_fuzz, 0);
Ping Chengeda01da2015-09-23 13:51:15 -07002950}
2951
2952static void wacom_setup_cintiq(struct wacom_wac *wacom_wac)
2953{
2954 struct input_dev *input_dev = wacom_wac->pen_input;
Jason Gereckebef7e202016-04-22 14:30:53 -07002955 struct wacom_features *features = &wacom_wac->features;
Ping Chengeda01da2015-09-23 13:51:15 -07002956
2957 wacom_setup_basic_pro_pen(wacom_wac);
2958
2959 __set_bit(BTN_TOOL_RUBBER, input_dev->keybit);
2960 __set_bit(BTN_TOOL_BRUSH, input_dev->keybit);
2961 __set_bit(BTN_TOOL_PENCIL, input_dev->keybit);
2962 __set_bit(BTN_TOOL_AIRBRUSH, input_dev->keybit);
2963
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -07002964 input_set_abs_params(input_dev, ABS_WHEEL, 0, 1023, 0, 0);
Jason Gereckebef7e202016-04-22 14:30:53 -07002965 input_set_abs_params(input_dev, ABS_TILT_X, -64, 63, features->tilt_fuzz, 0);
Jason Gerecke26fe4122014-11-18 16:50:09 -08002966 input_abs_set_res(input_dev, ABS_TILT_X, 57);
Jason Gereckebef7e202016-04-22 14:30:53 -07002967 input_set_abs_params(input_dev, ABS_TILT_Y, -64, 63, features->tilt_fuzz, 0);
Jason Gerecke26fe4122014-11-18 16:50:09 -08002968 input_abs_set_res(input_dev, ABS_TILT_Y, 57);
Ping Cheng6521d0b2010-10-24 21:53:40 -07002969}
2970
2971static void wacom_setup_intuos(struct wacom_wac *wacom_wac)
2972{
Jason Gerecke2a6cdbd2015-06-15 18:01:45 -07002973 struct input_dev *input_dev = wacom_wac->pen_input;
Ping Cheng6521d0b2010-10-24 21:53:40 -07002974
2975 input_set_capability(input_dev, EV_REL, REL_WHEEL);
2976
2977 wacom_setup_cintiq(wacom_wac);
2978
2979 __set_bit(BTN_LEFT, input_dev->keybit);
2980 __set_bit(BTN_RIGHT, input_dev->keybit);
2981 __set_bit(BTN_MIDDLE, input_dev->keybit);
2982 __set_bit(BTN_SIDE, input_dev->keybit);
2983 __set_bit(BTN_EXTRA, input_dev->keybit);
2984 __set_bit(BTN_TOOL_MOUSE, input_dev->keybit);
2985 __set_bit(BTN_TOOL_LENS, input_dev->keybit);
2986
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -07002987 input_set_abs_params(input_dev, ABS_RZ, -900, 899, 0, 0);
Jason Gerecke26fe4122014-11-18 16:50:09 -08002988 input_abs_set_res(input_dev, ABS_RZ, 287);
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -07002989 input_set_abs_params(input_dev, ABS_THROTTLE, -1023, 1023, 0, 0);
2990}
2991
Ping Cheng42f4f272015-04-15 16:53:54 -07002992void wacom_setup_device_quirks(struct wacom *wacom)
Henrik Rydbergbc73dd32010-09-05 12:26:16 -07002993{
Ping Cheng42f4f272015-04-15 16:53:54 -07002994 struct wacom_features *features = &wacom->wacom_wac.features;
Henrik Rydbergbc73dd32010-09-05 12:26:16 -07002995
Jason Gerecke862cf552015-06-15 18:01:43 -07002996 /* The pen and pad share the same interface on most devices */
2997 if (features->type == GRAPHIRE_BT || features->type == WACOM_G4 ||
Ping Cheng3b164a02015-09-23 09:59:10 -07002998 features->type == DTUS ||
2999 (features->type >= INTUOS3S && features->type <= WACOM_MO)) {
Jason Gerecke862cf552015-06-15 18:01:43 -07003000 if (features->device_type & WACOM_DEVICETYPE_PEN)
3001 features->device_type |= WACOM_DEVICETYPE_PAD;
3002 }
Henrik Rydbergbc73dd32010-09-05 12:26:16 -07003003
3004 /* touch device found but size is not defined. use default */
Jason Gereckeaa86b182015-06-15 18:01:42 -07003005 if (features->device_type & WACOM_DEVICETYPE_TOUCH && !features->x_max) {
Henrik Rydbergbc73dd32010-09-05 12:26:16 -07003006 features->x_max = 1023;
3007 features->y_max = 1023;
3008 }
3009
Ping Cheng42f4f272015-04-15 16:53:54 -07003010 /*
3011 * Intuos5/Pro and Bamboo 3rd gen have no useful data about its
3012 * touch interface in its HID descriptor. If this is the touch
3013 * interface (PacketSize of WACOM_PKGLEN_BBTOUCH3), override the
3014 * tablet values.
3015 */
Ping Cheng3b164a02015-09-23 09:59:10 -07003016 if ((features->type >= INTUOS5S && features->type <= INTUOSPL) ||
3017 (features->type >= INTUOSHT && features->type <= BAMBOO_PT)) {
Ping Cheng42f4f272015-04-15 16:53:54 -07003018 if (features->pktlen == WACOM_PKGLEN_BBTOUCH3) {
Jason Gerecke862cf552015-06-15 18:01:43 -07003019 if (features->touch_max)
3020 features->device_type |= WACOM_DEVICETYPE_TOUCH;
Jiri Kosinaa3088ab2015-11-17 00:24:14 +01003021 if (features->type >= INTUOSHT && features->type <= BAMBOO_PT)
Jason Gerecke862cf552015-06-15 18:01:43 -07003022 features->device_type |= WACOM_DEVICETYPE_PAD;
Ping Cheng42f4f272015-04-15 16:53:54 -07003023
3024 features->x_max = 4096;
3025 features->y_max = 4096;
Ping Cheng42f4f272015-04-15 16:53:54 -07003026 }
Jason Gerecke96339202015-07-01 13:01:00 -07003027 else if (features->pktlen == WACOM_PKGLEN_BBTOUCH) {
3028 features->device_type |= WACOM_DEVICETYPE_PAD;
3029 }
Ping Cheng42f4f272015-04-15 16:53:54 -07003030 }
3031
3032 /*
Benjamin Tissoires580549e2016-03-25 15:26:55 +01003033 * Hack for the Bamboo One:
3034 * the device presents a PAD/Touch interface as most Bamboos and even
3035 * sends ghosts PAD data on it. However, later, we must disable this
3036 * ghost interface, and we can not detect it unless we set it here
3037 * to WACOM_DEVICETYPE_PAD or WACOM_DEVICETYPE_TOUCH.
3038 */
3039 if (features->type == BAMBOO_PEN &&
3040 features->pktlen == WACOM_PKGLEN_BBTOUCH3)
3041 features->device_type |= WACOM_DEVICETYPE_PAD;
3042
3043 /*
Jason Gerecke042628a2015-04-30 17:51:54 -07003044 * Raw Wacom-mode pen and touch events both come from interface
3045 * 0, whose HID descriptor has an application usage of 0xFF0D
Jason Gerecke8de82282016-10-19 18:03:37 -07003046 * (i.e., WACOM_HID_WD_DIGITIZER). We route pen packets back
Jason Gerecke042628a2015-04-30 17:51:54 -07003047 * out through the HID_GENERIC device created for interface 1,
Benjamin Tissoires70caee0a2015-07-09 14:11:51 -04003048 * so rewrite this one to be of type WACOM_DEVICETYPE_TOUCH.
Ping Cheng42f4f272015-04-15 16:53:54 -07003049 */
3050 if (features->type == BAMBOO_PAD)
Benjamin Tissoires70caee0a2015-07-09 14:11:51 -04003051 features->device_type = WACOM_DEVICETYPE_TOUCH;
Ping Cheng42f4f272015-04-15 16:53:54 -07003052
Aaron Skomra72b236d2015-08-20 16:05:17 -07003053 if (features->type == REMOTE)
3054 features->device_type = WACOM_DEVICETYPE_PAD;
Ping Cheng42f4f272015-04-15 16:53:54 -07003055
Jason Gerecke4922cd22017-01-25 12:08:37 -08003056 if (features->type == INTUOSP2_BT) {
3057 features->device_type |= WACOM_DEVICETYPE_PEN |
3058 WACOM_DEVICETYPE_PAD |
3059 WACOM_DEVICETYPE_TOUCH;
3060 features->quirks |= WACOM_QUIRK_BATTERY;
3061 }
3062
Jason Gereckee5bc8eb2016-08-08 12:06:29 -07003063 switch (features->type) {
3064 case PL:
3065 case DTU:
3066 case DTUS:
3067 case DTUSX:
3068 case WACOM_21UX2:
3069 case WACOM_22HD:
3070 case DTK:
3071 case WACOM_24HD:
3072 case WACOM_27QHD:
3073 case CINTIQ_HYBRID:
3074 case CINTIQ_COMPANION_2:
3075 case CINTIQ:
3076 case WACOM_BEE:
3077 case WACOM_13HD:
3078 case WACOM_24HDT:
3079 case WACOM_27QHDT:
3080 case TABLETPC:
3081 case TABLETPCE:
3082 case TABLETPC2FG:
3083 case MTSCREEN:
3084 case MTTPC:
3085 case MTTPC_B:
3086 features->device_type |= WACOM_DEVICETYPE_DIRECT;
3087 break;
3088 }
3089
Ping Cheng42f4f272015-04-15 16:53:54 -07003090 if (wacom->hdev->bus == BUS_BLUETOOTH)
3091 features->quirks |= WACOM_QUIRK_BATTERY;
3092
Chris Bagwell73149ab2011-10-26 22:34:21 -07003093 /* quirk for bamboo touch with 2 low res touches */
Jason Gereckebe853fd2015-12-04 14:45:27 -08003094 if ((features->type == BAMBOO_PT || features->type == BAMBOO_TOUCH) &&
Chris Bagwell73149ab2011-10-26 22:34:21 -07003095 features->pktlen == WACOM_PKGLEN_BBTOUCH) {
Henrik Rydbergf4ccbef2010-09-05 12:57:13 -07003096 features->x_max <<= 5;
3097 features->y_max <<= 5;
3098 features->x_fuzz <<= 5;
3099 features->y_fuzz <<= 5;
Henrik Rydbergf4ccbef2010-09-05 12:57:13 -07003100 features->quirks |= WACOM_QUIRK_BBTOUCH_LOWRES;
Henrik Rydbergcb734c02010-09-05 12:53:16 -07003101 }
Chris Bagwelld3825d52012-03-25 23:26:11 -07003102
3103 if (features->type == WIRELESS) {
Jason Gereckeccad85c2015-08-03 10:17:04 -07003104 if (features->device_type == WACOM_DEVICETYPE_WL_MONITOR) {
Benjamin Tissoiresac8d1012014-07-25 17:29:48 -07003105 features->quirks |= WACOM_QUIRK_BATTERY;
3106 }
Chris Bagwelld3825d52012-03-25 23:26:11 -07003107 }
Benjamin Tissoires7c35dc32016-07-13 18:06:07 +02003108
3109 if (features->type == REMOTE)
3110 features->device_type |= WACOM_DEVICETYPE_WL_MONITOR;
Henrik Rydbergbc73dd32010-09-05 12:26:16 -07003111}
3112
Jason Gerecke2636a3f2015-06-15 18:01:44 -07003113int wacom_setup_pen_input_capabilities(struct input_dev *input_dev,
Ping Cheng19635182012-04-29 21:09:18 -07003114 struct wacom_wac *wacom_wac)
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -07003115{
3116 struct wacom_features *features = &wacom_wac->features;
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -07003117
3118 input_dev->evbit[0] |= BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS);
3119
Jason Gerecke2636a3f2015-06-15 18:01:44 -07003120 if (!(features->device_type & WACOM_DEVICETYPE_PEN))
3121 return -ENODEV;
3122
Jason Gereckee5bc8eb2016-08-08 12:06:29 -07003123 if (features->device_type & WACOM_DEVICETYPE_DIRECT)
3124 __set_bit(INPUT_PROP_DIRECT, input_dev->propbit);
3125 else
3126 __set_bit(INPUT_PROP_POINTER, input_dev->propbit);
3127
Benjamin Tissoires7704ac92014-09-23 12:08:08 -04003128 if (features->type == HID_GENERIC)
3129 /* setup has already been done */
3130 return 0;
3131
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -07003132 __set_bit(BTN_TOUCH, input_dev->keybit);
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -07003133 __set_bit(ABS_MISC, input_dev->absbit);
3134
Jason Gereckee779ef22016-10-19 18:03:49 -07003135 input_set_abs_params(input_dev, ABS_X, 0 + features->offset_left,
3136 features->x_max - features->offset_right,
3137 features->x_fuzz, 0);
3138 input_set_abs_params(input_dev, ABS_Y, 0 + features->offset_top,
3139 features->y_max - features->offset_bottom,
3140 features->y_fuzz, 0);
Jason Gerecke2636a3f2015-06-15 18:01:44 -07003141 input_set_abs_params(input_dev, ABS_PRESSURE, 0,
3142 features->pressure_max, features->pressure_fuzz, 0);
3143
3144 /* penabled devices have fixed resolution for each model */
3145 input_abs_set_res(input_dev, ABS_X, features->x_resolution);
3146 input_abs_set_res(input_dev, ABS_Y, features->y_resolution);
3147
Ping Cheng497ab1f2014-01-20 20:18:04 -08003148 switch (features->type) {
Ping Chenga2f71c62015-01-27 13:29:36 -08003149 case GRAPHIRE_BT:
3150 __clear_bit(ABS_MISC, input_dev->absbit);
3151
Dmitry Torokhov73a97f42010-03-19 22:18:15 -07003152 case WACOM_MO:
Dmitry Torokhov73a97f42010-03-19 22:18:15 -07003153 case WACOM_G4:
Ping Chenga2f71c62015-01-27 13:29:36 -08003154 input_set_abs_params(input_dev, ABS_DISTANCE, 0,
3155 features->distance_max,
Jason Gereckebef7e202016-04-22 14:30:53 -07003156 features->distance_fuzz, 0);
Dmitry Torokhov73a97f42010-03-19 22:18:15 -07003157 /* fall through */
3158
3159 case GRAPHIRE:
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -07003160 input_set_capability(input_dev, EV_REL, REL_WHEEL);
3161
3162 __set_bit(BTN_LEFT, input_dev->keybit);
3163 __set_bit(BTN_RIGHT, input_dev->keybit);
3164 __set_bit(BTN_MIDDLE, input_dev->keybit);
3165
3166 __set_bit(BTN_TOOL_RUBBER, input_dev->keybit);
3167 __set_bit(BTN_TOOL_PEN, input_dev->keybit);
3168 __set_bit(BTN_TOOL_MOUSE, input_dev->keybit);
3169 __set_bit(BTN_STYLUS, input_dev->keybit);
3170 __set_bit(BTN_STYLUS2, input_dev->keybit);
Dmitry Torokhov73a97f42010-03-19 22:18:15 -07003171 break;
3172
Ping Cheng500d4162015-01-27 13:30:03 -08003173 case WACOM_27QHD:
Jason Gerecke803296b2011-12-12 00:11:45 -08003174 case WACOM_24HD:
Ping Chenga112e9f2013-02-13 20:20:01 -08003175 case DTK:
Ping Chengd838c642012-07-24 23:54:11 -07003176 case WACOM_22HD:
Ping Cheng3a4b4aa2010-06-03 22:10:21 -07003177 case WACOM_21UX2:
Dmitry Torokhov73a97f42010-03-19 22:18:15 -07003178 case WACOM_BEE:
Ping Cheng6521d0b2010-10-24 21:53:40 -07003179 case CINTIQ:
Ping Cheng56218562013-05-05 19:56:18 -07003180 case WACOM_13HD:
Ping Chenga2f71c62015-01-27 13:29:36 -08003181 case CINTIQ_HYBRID:
Jason Gereckef7acb552015-10-13 10:03:49 -07003182 case CINTIQ_COMPANION_2:
Ping Cheng56218562013-05-05 19:56:18 -07003183 input_set_abs_params(input_dev, ABS_Z, -900, 899, 0, 0);
Jason Gerecke26fe4122014-11-18 16:50:09 -08003184 input_abs_set_res(input_dev, ABS_Z, 287);
Ping Cheng56218562013-05-05 19:56:18 -07003185 wacom_setup_cintiq(wacom_wac);
3186 break;
3187
Dmitry Torokhov73a97f42010-03-19 22:18:15 -07003188 case INTUOS3:
3189 case INTUOS3L:
Dmitry Torokhov73a97f42010-03-19 22:18:15 -07003190 case INTUOS3S:
Ping Chenga2f71c62015-01-27 13:29:36 -08003191 case INTUOS4:
3192 case INTUOS4WL:
3193 case INTUOS4L:
3194 case INTUOS4S:
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -07003195 input_set_abs_params(input_dev, ABS_Z, -900, 899, 0, 0);
Jason Gerecke26fe4122014-11-18 16:50:09 -08003196 input_abs_set_res(input_dev, ABS_Z, 287);
Dmitry Torokhov73a97f42010-03-19 22:18:15 -07003197 /* fall through */
3198
3199 case INTUOS:
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -07003200 wacom_setup_intuos(wacom_wac);
Dmitry Torokhov73a97f42010-03-19 22:18:15 -07003201 break;
3202
Jason Gerecke9fee6192012-04-03 15:47:22 -07003203 case INTUOS5:
3204 case INTUOS5L:
Ping Cheng9a35c412013-09-20 09:51:56 -07003205 case INTUOSPM:
3206 case INTUOSPL:
Jason Gereckeae584ca2012-04-03 15:50:40 -07003207 case INTUOS5S:
Ping Cheng9a35c412013-09-20 09:51:56 -07003208 case INTUOSPS:
Jason Gerecke4922cd22017-01-25 12:08:37 -08003209 case INTUOSP2_BT:
Jason Gerecke2636a3f2015-06-15 18:01:44 -07003210 input_set_abs_params(input_dev, ABS_DISTANCE, 0,
3211 features->distance_max,
Jason Gereckebef7e202016-04-22 14:30:53 -07003212 features->distance_fuzz, 0);
Jason Gereckeae584ca2012-04-03 15:50:40 -07003213
Jason Gerecke2636a3f2015-06-15 18:01:44 -07003214 input_set_abs_params(input_dev, ABS_Z, -900, 899, 0, 0);
3215 input_abs_set_res(input_dev, ABS_Z, 287);
Jason Gereckeae584ca2012-04-03 15:50:40 -07003216
Jason Gerecke2636a3f2015-06-15 18:01:44 -07003217 wacom_setup_intuos(wacom_wac);
Jason Gereckeae584ca2012-04-03 15:50:40 -07003218 break;
3219
Jason Gereckeb1e42792012-10-21 00:38:04 -07003220 case WACOM_24HDT:
Ping Cheng500d4162015-01-27 13:30:03 -08003221 case WACOM_27QHDT:
Ping Cheng19635182012-04-29 21:09:18 -07003222 case MTSCREEN:
Ping Cheng6afdc282012-11-03 12:16:15 -07003223 case MTTPC:
Jason Gerecked51ddb22014-05-14 17:14:29 -07003224 case MTTPC_B:
Ping Cheng6795a522012-06-28 16:49:00 -07003225 case TABLETPC2FG:
Dmitry Torokhov73a97f42010-03-19 22:18:15 -07003226 case TABLETPC:
Ping Chengac173832012-06-12 00:15:06 -07003227 case TABLETPCE:
Ping Chenga43c7c52011-03-12 20:34:42 -08003228 __clear_bit(ABS_MISC, input_dev->absbit);
Dmitry Torokhov73a97f42010-03-19 22:18:15 -07003229 /* fall through */
3230
Ping Cheng497ab1f2014-01-20 20:18:04 -08003231 case DTUS:
Ping Chengfff00bf2014-12-04 18:23:04 -08003232 case DTUSX:
Dmitry Torokhov73a97f42010-03-19 22:18:15 -07003233 case PL:
Ping Chengc8f2edc2010-06-28 01:10:51 -07003234 case DTU:
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -07003235 __set_bit(BTN_TOOL_PEN, input_dev->keybit);
Jason Gerecke35120692011-09-08 09:38:14 -07003236 __set_bit(BTN_TOOL_RUBBER, input_dev->keybit);
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -07003237 __set_bit(BTN_STYLUS, input_dev->keybit);
3238 __set_bit(BTN_STYLUS2, input_dev->keybit);
Jason Gerecke35120692011-09-08 09:38:14 -07003239 break;
3240
3241 case PTU:
Dmitry Torokhov73a97f42010-03-19 22:18:15 -07003242 __set_bit(BTN_STYLUS2, input_dev->keybit);
3243 /* fall through */
3244
3245 case PENPARTNER:
Jason Gerecke1fab84a2011-08-26 23:18:22 -07003246 __set_bit(BTN_TOOL_PEN, input_dev->keybit);
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -07003247 __set_bit(BTN_TOOL_RUBBER, input_dev->keybit);
Jason Gerecke1fab84a2011-08-26 23:18:22 -07003248 __set_bit(BTN_STYLUS, input_dev->keybit);
Dmitry Torokhov73a97f42010-03-19 22:18:15 -07003249 break;
Henrik Rydbergcb734c02010-09-05 12:53:16 -07003250
Ping Chengb5fd2a32013-11-25 18:44:55 -08003251 case INTUOSHT:
Henrik Rydbergcb734c02010-09-05 12:53:16 -07003252 case BAMBOO_PT:
Ping Cheng3b164a02015-09-23 09:59:10 -07003253 case BAMBOO_PEN:
Ping Chengeda01da2015-09-23 13:51:15 -07003254 case INTUOSHT2:
Ping Chengeda01da2015-09-23 13:51:15 -07003255 if (features->type == INTUOSHT2) {
3256 wacom_setup_basic_pro_pen(wacom_wac);
3257 } else {
3258 __clear_bit(ABS_MISC, input_dev->absbit);
3259 __set_bit(BTN_TOOL_PEN, input_dev->keybit);
3260 __set_bit(BTN_TOOL_RUBBER, input_dev->keybit);
3261 __set_bit(BTN_STYLUS, input_dev->keybit);
3262 __set_bit(BTN_STYLUS2, input_dev->keybit);
3263 input_set_abs_params(input_dev, ABS_DISTANCE, 0,
Jason Gerecke2636a3f2015-06-15 18:01:44 -07003264 features->distance_max,
Jason Gereckebef7e202016-04-22 14:30:53 -07003265 features->distance_fuzz, 0);
Ping Chengeda01da2015-09-23 13:51:15 -07003266 }
Henrik Rydbergcb734c02010-09-05 12:53:16 -07003267 break;
Benjamin Tissoires8c97a762015-02-26 11:28:50 -05003268 case BAMBOO_PAD:
3269 __clear_bit(ABS_MISC, input_dev->absbit);
Jason Gerecke2636a3f2015-06-15 18:01:44 -07003270 break;
3271 }
3272 return 0;
3273}
3274
3275int wacom_setup_touch_input_capabilities(struct input_dev *input_dev,
3276 struct wacom_wac *wacom_wac)
3277{
3278 struct wacom_features *features = &wacom_wac->features;
3279
3280 input_dev->evbit[0] |= BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS);
3281
3282 if (!(features->device_type & WACOM_DEVICETYPE_TOUCH))
3283 return -ENODEV;
3284
Jason Gereckee5bc8eb2016-08-08 12:06:29 -07003285 if (features->device_type & WACOM_DEVICETYPE_DIRECT)
3286 __set_bit(INPUT_PROP_DIRECT, input_dev->propbit);
3287 else
3288 __set_bit(INPUT_PROP_POINTER, input_dev->propbit);
3289
Jason Gerecke2636a3f2015-06-15 18:01:44 -07003290 if (features->type == HID_GENERIC)
3291 /* setup has already been done */
3292 return 0;
3293
3294 __set_bit(BTN_TOUCH, input_dev->keybit);
3295
3296 if (features->touch_max == 1) {
3297 input_set_abs_params(input_dev, ABS_X, 0,
3298 features->x_max, features->x_fuzz, 0);
3299 input_set_abs_params(input_dev, ABS_Y, 0,
3300 features->y_max, features->y_fuzz, 0);
3301 input_abs_set_res(input_dev, ABS_X,
3302 features->x_resolution);
3303 input_abs_set_res(input_dev, ABS_Y,
3304 features->y_resolution);
3305 }
3306 else if (features->touch_max > 1) {
3307 input_set_abs_params(input_dev, ABS_MT_POSITION_X, 0,
3308 features->x_max, features->x_fuzz, 0);
3309 input_set_abs_params(input_dev, ABS_MT_POSITION_Y, 0,
3310 features->y_max, features->y_fuzz, 0);
3311 input_abs_set_res(input_dev, ABS_MT_POSITION_X,
3312 features->x_resolution);
3313 input_abs_set_res(input_dev, ABS_MT_POSITION_Y,
3314 features->y_resolution);
3315 }
3316
3317 switch (features->type) {
Jason Gerecke4922cd22017-01-25 12:08:37 -08003318 case INTUOSP2_BT:
3319 input_dev->evbit[0] |= BIT_MASK(EV_SW);
3320 __set_bit(SW_MUTE_DEVICE, input_dev->swbit);
3321
3322 if (wacom_wac->shared->touch->product == 0x361) {
3323 input_set_abs_params(input_dev, ABS_MT_POSITION_X,
3324 0, 12440, 4, 0);
3325 input_set_abs_params(input_dev, ABS_MT_POSITION_Y,
3326 0, 8640, 4, 0);
3327 }
3328 else if (wacom_wac->shared->touch->product == 0x360) {
3329 input_set_abs_params(input_dev, ABS_MT_POSITION_X,
3330 0, 8960, 4, 0);
3331 input_set_abs_params(input_dev, ABS_MT_POSITION_Y,
3332 0, 5920, 4, 0);
3333 }
3334 input_abs_set_res(input_dev, ABS_MT_POSITION_X, 40);
3335 input_abs_set_res(input_dev, ABS_MT_POSITION_X, 40);
3336
3337 /* fall through */
3338
Jason Gerecke2636a3f2015-06-15 18:01:44 -07003339 case INTUOS5:
3340 case INTUOS5L:
3341 case INTUOSPM:
3342 case INTUOSPL:
3343 case INTUOS5S:
3344 case INTUOSPS:
Jason Gerecke2636a3f2015-06-15 18:01:44 -07003345 input_set_abs_params(input_dev, ABS_MT_TOUCH_MAJOR, 0, features->x_max, 0, 0);
3346 input_set_abs_params(input_dev, ABS_MT_TOUCH_MINOR, 0, features->y_max, 0, 0);
3347 input_mt_init_slots(input_dev, features->touch_max, INPUT_MT_POINTER);
3348 break;
3349
3350 case WACOM_24HDT:
3351 input_set_abs_params(input_dev, ABS_MT_TOUCH_MAJOR, 0, features->x_max, 0, 0);
3352 input_set_abs_params(input_dev, ABS_MT_WIDTH_MAJOR, 0, features->x_max, 0, 0);
3353 input_set_abs_params(input_dev, ABS_MT_WIDTH_MINOR, 0, features->y_max, 0, 0);
3354 input_set_abs_params(input_dev, ABS_MT_ORIENTATION, 0, 1, 0, 0);
3355 /* fall through */
3356
3357 case WACOM_27QHDT:
3358 case MTSCREEN:
3359 case MTTPC:
3360 case MTTPC_B:
3361 case TABLETPC2FG:
3362 input_mt_init_slots(input_dev, features->touch_max, INPUT_MT_DIRECT);
3363 /*fall through */
3364
3365 case TABLETPC:
3366 case TABLETPCE:
Jason Gerecke2636a3f2015-06-15 18:01:44 -07003367 break;
3368
3369 case INTUOSHT:
Ping Chengeda01da2015-09-23 13:51:15 -07003370 case INTUOSHT2:
Jason Gerecke2636a3f2015-06-15 18:01:44 -07003371 input_dev->evbit[0] |= BIT_MASK(EV_SW);
3372 __set_bit(SW_MUTE_DEVICE, input_dev->swbit);
3373 /* fall through */
3374
3375 case BAMBOO_PT:
Ping Cheng3b164a02015-09-23 09:59:10 -07003376 case BAMBOO_TOUCH:
Jason Gerecke2636a3f2015-06-15 18:01:44 -07003377 if (features->pktlen == WACOM_PKGLEN_BBTOUCH3) {
3378 input_set_abs_params(input_dev,
3379 ABS_MT_TOUCH_MAJOR,
3380 0, features->x_max, 0, 0);
3381 input_set_abs_params(input_dev,
3382 ABS_MT_TOUCH_MINOR,
3383 0, features->y_max, 0, 0);
3384 }
3385 input_mt_init_slots(input_dev, features->touch_max, INPUT_MT_POINTER);
3386 break;
3387
3388 case BAMBOO_PAD:
Benjamin Tissoires8c97a762015-02-26 11:28:50 -05003389 input_mt_init_slots(input_dev, features->touch_max,
3390 INPUT_MT_POINTER);
3391 __set_bit(BTN_LEFT, input_dev->keybit);
3392 __set_bit(BTN_RIGHT, input_dev->keybit);
3393 break;
Ping Cheng3bea7332006-07-13 18:01:36 -07003394 }
Ping Cheng19635182012-04-29 21:09:18 -07003395 return 0;
Ping Cheng3bea7332006-07-13 18:01:36 -07003396}
3397
Jason Gerecke49005b92016-10-19 18:03:39 -07003398static int wacom_numbered_button_to_key(int n)
3399{
3400 if (n < 10)
3401 return BTN_0 + n;
3402 else if (n < 16)
3403 return BTN_A + (n-10);
3404 else if (n < 18)
3405 return BTN_BASE + (n-16);
3406 else
3407 return 0;
3408}
3409
Jiri Kosina5397df12015-08-28 20:46:42 +02003410static void wacom_setup_numbered_buttons(struct input_dev *input_dev,
Aaron Skomra70ee06c2015-08-20 16:05:16 -07003411 int button_count)
3412{
3413 int i;
3414
Jason Gerecke49005b92016-10-19 18:03:39 -07003415 for (i = 0; i < button_count; i++) {
3416 int key = wacom_numbered_button_to_key(i);
3417
3418 if (key)
3419 __set_bit(key, input_dev->keybit);
3420 }
Aaron Skomra70ee06c2015-08-20 16:05:16 -07003421}
3422
Benjamin Tissoires6a062812016-07-13 18:06:14 +02003423static void wacom_24hd_update_leds(struct wacom *wacom, int mask, int group)
3424{
3425 struct wacom_led *led;
3426 int i;
3427 bool updated = false;
3428
3429 /*
3430 * 24HD has LED group 1 to the left and LED group 0 to the right.
3431 * So group 0 matches the second half of the buttons and thus the mask
3432 * needs to be shifted.
3433 */
3434 if (group == 0)
3435 mask >>= 8;
3436
3437 for (i = 0; i < 3; i++) {
3438 led = wacom_led_find(wacom, group, i);
3439 if (!led) {
3440 hid_err(wacom->hdev, "can't find LED %d in group %d\n",
3441 i, group);
3442 continue;
3443 }
3444 if (!updated && mask & BIT(i)) {
3445 led->held = true;
3446 led_trigger_event(&led->trigger, LED_FULL);
3447 } else {
3448 led->held = false;
3449 }
3450 }
3451}
3452
Benjamin Tissoires34736aa2016-07-13 18:06:12 +02003453static bool wacom_is_led_toggled(struct wacom *wacom, int button_count,
3454 int mask, int group)
3455{
3456 int button_per_group;
3457
Benjamin Tissoires5a0fe8ab2016-07-13 18:06:13 +02003458 /*
Benjamin Tissoires6a062812016-07-13 18:06:14 +02003459 * 21UX2 has LED group 1 to the left and LED group 0
Benjamin Tissoires5a0fe8ab2016-07-13 18:06:13 +02003460 * to the right. We need to reverse the group to match this
3461 * historical behavior.
3462 */
Benjamin Tissoires6a062812016-07-13 18:06:14 +02003463 if (wacom->wacom_wac.features.type == WACOM_21UX2)
Benjamin Tissoires5a0fe8ab2016-07-13 18:06:13 +02003464 group = 1 - group;
3465
Benjamin Tissoires34736aa2016-07-13 18:06:12 +02003466 button_per_group = button_count/wacom->led.count;
3467
3468 return mask & (1 << (group * button_per_group));
3469}
3470
3471static void wacom_update_led(struct wacom *wacom, int button_count, int mask,
3472 int group)
3473{
3474 struct wacom_led *led, *next_led;
3475 int cur;
3476 bool pressed;
3477
Benjamin Tissoires6a062812016-07-13 18:06:14 +02003478 if (wacom->wacom_wac.features.type == WACOM_24HD)
3479 return wacom_24hd_update_leds(wacom, mask, group);
3480
Benjamin Tissoires34736aa2016-07-13 18:06:12 +02003481 pressed = wacom_is_led_toggled(wacom, button_count, mask, group);
3482 cur = wacom->led.groups[group].select;
3483
3484 led = wacom_led_find(wacom, group, cur);
3485 if (!led) {
3486 hid_err(wacom->hdev, "can't find current LED %d in group %d\n",
3487 cur, group);
3488 return;
3489 }
3490
3491 if (!pressed) {
3492 led->held = false;
3493 return;
3494 }
3495
3496 if (led->held && pressed)
3497 return;
3498
3499 next_led = wacom_led_next(wacom, led);
3500 if (!next_led) {
3501 hid_err(wacom->hdev, "can't find next LED in group %d\n",
3502 group);
3503 return;
3504 }
3505 if (next_led == led)
3506 return;
3507
3508 next_led->held = true;
3509 led_trigger_event(&next_led->trigger,
3510 wacom_leds_brightness_get(next_led));
3511}
3512
Jason Gereckec7f05222015-11-30 17:13:47 -08003513static void wacom_report_numbered_buttons(struct input_dev *input_dev,
3514 int button_count, int mask)
3515{
Benjamin Tissoires34736aa2016-07-13 18:06:12 +02003516 struct wacom *wacom = input_get_drvdata(input_dev);
Jason Gereckec7f05222015-11-30 17:13:47 -08003517 int i;
3518
Benjamin Tissoires34736aa2016-07-13 18:06:12 +02003519 for (i = 0; i < wacom->led.count; i++)
3520 wacom_update_led(wacom, button_count, mask, i);
3521
Jason Gerecke49005b92016-10-19 18:03:39 -07003522 for (i = 0; i < button_count; i++) {
3523 int key = wacom_numbered_button_to_key(i);
3524
3525 if (key)
3526 input_report_key(input_dev, key, mask & (1 << i));
3527 }
Jason Gereckec7f05222015-11-30 17:13:47 -08003528}
3529
Benjamin Tissoiresd2d13f12014-07-24 12:48:28 -07003530int wacom_setup_pad_input_capabilities(struct input_dev *input_dev,
3531 struct wacom_wac *wacom_wac)
3532{
3533 struct wacom_features *features = &wacom_wac->features;
3534
Ping Chenge7deb152017-01-30 15:40:49 -08003535 if ((features->type == HID_GENERIC) && features->numbered_buttons > 0)
3536 features->device_type |= WACOM_DEVICETYPE_PAD;
3537
Jason Gerecke862cf552015-06-15 18:01:43 -07003538 if (!(features->device_type & WACOM_DEVICETYPE_PAD))
3539 return -ENODEV;
3540
Benjamin Tissoires7c35dc32016-07-13 18:06:07 +02003541 if (features->type == REMOTE && input_dev == wacom_wac->pad_input)
3542 return -ENODEV;
3543
Benjamin Tissoiresd2d13f12014-07-24 12:48:28 -07003544 input_dev->evbit[0] |= BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS);
3545
3546 /* kept for making legacy xf86-input-wacom working with the wheels */
3547 __set_bit(ABS_MISC, input_dev->absbit);
3548
3549 /* kept for making legacy xf86-input-wacom accepting the pad */
Jason Gerecke5922e612016-10-19 18:03:51 -07003550 if (!(input_dev->absinfo && (input_dev->absinfo[ABS_X].minimum ||
3551 input_dev->absinfo[ABS_X].maximum)))
3552 input_set_abs_params(input_dev, ABS_X, 0, 1, 0, 0);
3553 if (!(input_dev->absinfo && (input_dev->absinfo[ABS_Y].minimum ||
3554 input_dev->absinfo[ABS_Y].maximum)))
3555 input_set_abs_params(input_dev, ABS_Y, 0, 1, 0, 0);
Benjamin Tissoiresd2d13f12014-07-24 12:48:28 -07003556
Benjamin Tissoires12969e32014-09-11 13:14:04 -04003557 /* kept for making udev and libwacom accepting the pad */
3558 __set_bit(BTN_STYLUS, input_dev->keybit);
3559
Aaron Skomra70ee06c2015-08-20 16:05:16 -07003560 wacom_setup_numbered_buttons(input_dev, features->numbered_buttons);
3561
Benjamin Tissoiresd2d13f12014-07-24 12:48:28 -07003562 switch (features->type) {
Aaron Skomra70ee06c2015-08-20 16:05:16 -07003563
3564 case CINTIQ_HYBRID:
Jason Gereckef7acb552015-10-13 10:03:49 -07003565 case CINTIQ_COMPANION_2:
Aaron Skomra70ee06c2015-08-20 16:05:16 -07003566 case DTK:
3567 case DTUS:
Benjamin Tissoires387142b2014-08-06 13:52:56 -07003568 case GRAPHIRE_BT:
Benjamin Tissoires387142b2014-08-06 13:52:56 -07003569 break;
3570
Benjamin Tissoires38138102014-07-24 12:51:03 -07003571 case WACOM_MO:
3572 __set_bit(BTN_BACK, input_dev->keybit);
3573 __set_bit(BTN_LEFT, input_dev->keybit);
3574 __set_bit(BTN_FORWARD, input_dev->keybit);
3575 __set_bit(BTN_RIGHT, input_dev->keybit);
3576 input_set_abs_params(input_dev, ABS_WHEEL, 0, 71, 0, 0);
3577 break;
3578
3579 case WACOM_G4:
3580 __set_bit(BTN_BACK, input_dev->keybit);
Benjamin Tissoires38138102014-07-24 12:51:03 -07003581 __set_bit(BTN_FORWARD, input_dev->keybit);
Benjamin Tissoires38138102014-07-24 12:51:03 -07003582 input_set_capability(input_dev, EV_REL, REL_WHEEL);
3583 break;
3584
Benjamin Tissoires10059cdc2014-07-24 12:49:08 -07003585 case WACOM_24HD:
Benjamin Tissoires10059cdc2014-07-24 12:49:08 -07003586 __set_bit(KEY_PROG1, input_dev->keybit);
3587 __set_bit(KEY_PROG2, input_dev->keybit);
3588 __set_bit(KEY_PROG3, input_dev->keybit);
3589
3590 input_set_abs_params(input_dev, ABS_WHEEL, 0, 71, 0, 0);
3591 input_set_abs_params(input_dev, ABS_THROTTLE, 0, 71, 0, 0);
3592 break;
3593
Ping Cheng500d4162015-01-27 13:30:03 -08003594 case WACOM_27QHD:
3595 __set_bit(KEY_PROG1, input_dev->keybit);
3596 __set_bit(KEY_PROG2, input_dev->keybit);
3597 __set_bit(KEY_PROG3, input_dev->keybit);
3598 input_set_abs_params(input_dev, ABS_X, -2048, 2048, 0, 0);
3599 input_abs_set_res(input_dev, ABS_X, 1024); /* points/g */
3600 input_set_abs_params(input_dev, ABS_Y, -2048, 2048, 0, 0);
3601 input_abs_set_res(input_dev, ABS_Y, 1024);
3602 input_set_abs_params(input_dev, ABS_Z, -2048, 2048, 0, 0);
3603 input_abs_set_res(input_dev, ABS_Z, 1024);
3604 __set_bit(INPUT_PROP_ACCELEROMETER, input_dev->propbit);
3605 break;
3606
Benjamin Tissoires10059cdc2014-07-24 12:49:08 -07003607 case WACOM_22HD:
3608 __set_bit(KEY_PROG1, input_dev->keybit);
3609 __set_bit(KEY_PROG2, input_dev->keybit);
3610 __set_bit(KEY_PROG3, input_dev->keybit);
3611 /* fall through */
3612
3613 case WACOM_21UX2:
Benjamin Tissoires10059cdc2014-07-24 12:49:08 -07003614 case WACOM_BEE:
Benjamin Tissoires10059cdc2014-07-24 12:49:08 -07003615 case CINTIQ:
Benjamin Tissoires10059cdc2014-07-24 12:49:08 -07003616 input_set_abs_params(input_dev, ABS_RX, 0, 4096, 0, 0);
3617 input_set_abs_params(input_dev, ABS_RY, 0, 4096, 0, 0);
3618 break;
3619
3620 case WACOM_13HD:
Benjamin Tissoires10059cdc2014-07-24 12:49:08 -07003621 input_set_abs_params(input_dev, ABS_WHEEL, 0, 71, 0, 0);
3622 break;
3623
3624 case INTUOS3:
3625 case INTUOS3L:
Benjamin Tissoires10059cdc2014-07-24 12:49:08 -07003626 input_set_abs_params(input_dev, ABS_RY, 0, 4096, 0, 0);
3627 /* fall through */
3628
3629 case INTUOS3S:
Benjamin Tissoires10059cdc2014-07-24 12:49:08 -07003630 input_set_abs_params(input_dev, ABS_RX, 0, 4096, 0, 0);
3631 break;
3632
3633 case INTUOS5:
3634 case INTUOS5L:
3635 case INTUOSPM:
3636 case INTUOSPL:
Benjamin Tissoires10059cdc2014-07-24 12:49:08 -07003637 case INTUOS5S:
3638 case INTUOSPS:
Jason Gerecke4922cd22017-01-25 12:08:37 -08003639 case INTUOSP2_BT:
Benjamin Tissoires10059cdc2014-07-24 12:49:08 -07003640 input_set_abs_params(input_dev, ABS_WHEEL, 0, 71, 0, 0);
3641 break;
3642
Benjamin Tissoires81af7e62014-08-06 13:55:56 -07003643 case INTUOS4WL:
3644 /*
3645 * For Bluetooth devices, the udev rule does not work correctly
3646 * for pads unless we add a stylus capability, which forces
3647 * ID_INPUT_TABLET to be set.
3648 */
3649 __set_bit(BTN_STYLUS, input_dev->keybit);
3650 /* fall through */
3651
Benjamin Tissoires10059cdc2014-07-24 12:49:08 -07003652 case INTUOS4:
3653 case INTUOS4L:
Benjamin Tissoires10059cdc2014-07-24 12:49:08 -07003654 case INTUOS4S:
Benjamin Tissoires10059cdc2014-07-24 12:49:08 -07003655 input_set_abs_params(input_dev, ABS_WHEEL, 0, 71, 0, 0);
3656 break;
3657
Benjamin Tissoires31168712014-07-24 12:50:10 -07003658 case INTUOSHT:
3659 case BAMBOO_PT:
Ping Cheng3b164a02015-09-23 09:59:10 -07003660 case BAMBOO_TOUCH:
Ping Chengeda01da2015-09-23 13:51:15 -07003661 case INTUOSHT2:
Benjamin Tissoires31168712014-07-24 12:50:10 -07003662 __clear_bit(ABS_MISC, input_dev->absbit);
3663
3664 __set_bit(BTN_LEFT, input_dev->keybit);
3665 __set_bit(BTN_FORWARD, input_dev->keybit);
3666 __set_bit(BTN_BACK, input_dev->keybit);
3667 __set_bit(BTN_RIGHT, input_dev->keybit);
3668
3669 break;
3670
Aaron Skomra72b236d2015-08-20 16:05:17 -07003671 case REMOTE:
3672 input_set_capability(input_dev, EV_MSC, MSC_SERIAL);
3673 input_set_abs_params(input_dev, ABS_WHEEL, 0, 71, 0, 0);
3674 break;
3675
Jason Gerecke5922e612016-10-19 18:03:51 -07003676 case HID_GENERIC:
3677 break;
3678
Benjamin Tissoiresd2d13f12014-07-24 12:48:28 -07003679 default:
3680 /* no pad supported */
Ping Chengb3c8e932014-11-18 13:27:48 -08003681 return -ENODEV;
Benjamin Tissoiresd2d13f12014-07-24 12:48:28 -07003682 }
3683 return 0;
3684}
3685
Dmitry Torokhove87a3442010-02-18 01:51:47 -08003686static const struct wacom_features wacom_features_0x00 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003687 { "Wacom Penpartner", 5040, 3780, 255, 0,
3688 PENPARTNER, WACOM_PENPRTN_RES, WACOM_PENPRTN_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08003689static const struct wacom_features wacom_features_0x10 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003690 { "Wacom Graphire", 10206, 7422, 511, 63,
3691 GRAPHIRE, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
Benjamin Tissoires387142b2014-08-06 13:52:56 -07003692static const struct wacom_features wacom_features_0x81 =
3693 { "Wacom Graphire BT", 16704, 12064, 511, 32,
Aaron Skomra70ee06c2015-08-20 16:05:16 -07003694 GRAPHIRE_BT, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES, 2 };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08003695static const struct wacom_features wacom_features_0x11 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003696 { "Wacom Graphire2 4x5", 10206, 7422, 511, 63,
3697 GRAPHIRE, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08003698static const struct wacom_features wacom_features_0x12 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003699 { "Wacom Graphire2 5x7", 13918, 10206, 511, 63,
3700 GRAPHIRE, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08003701static const struct wacom_features wacom_features_0x13 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003702 { "Wacom Graphire3", 10208, 7424, 511, 63,
3703 GRAPHIRE, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08003704static const struct wacom_features wacom_features_0x14 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003705 { "Wacom Graphire3 6x8", 16704, 12064, 511, 63,
3706 GRAPHIRE, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08003707static const struct wacom_features wacom_features_0x15 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003708 { "Wacom Graphire4 4x5", 10208, 7424, 511, 63,
3709 WACOM_G4, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08003710static const struct wacom_features wacom_features_0x16 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003711 { "Wacom Graphire4 6x8", 16704, 12064, 511, 63,
3712 WACOM_G4, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08003713static const struct wacom_features wacom_features_0x17 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003714 { "Wacom BambooFun 4x5", 14760, 9225, 511, 63,
3715 WACOM_MO, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08003716static const struct wacom_features wacom_features_0x18 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003717 { "Wacom BambooFun 6x8", 21648, 13530, 511, 63,
3718 WACOM_MO, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08003719static const struct wacom_features wacom_features_0x19 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003720 { "Wacom Bamboo1 Medium", 16704, 12064, 511, 63,
3721 GRAPHIRE, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08003722static const struct wacom_features wacom_features_0x60 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003723 { "Wacom Volito", 5104, 3712, 511, 63,
3724 GRAPHIRE, WACOM_VOLITO_RES, WACOM_VOLITO_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08003725static const struct wacom_features wacom_features_0x61 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003726 { "Wacom PenStation2", 3250, 2320, 255, 63,
3727 GRAPHIRE, WACOM_VOLITO_RES, WACOM_VOLITO_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08003728static const struct wacom_features wacom_features_0x62 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003729 { "Wacom Volito2 4x5", 5104, 3712, 511, 63,
3730 GRAPHIRE, WACOM_VOLITO_RES, WACOM_VOLITO_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08003731static const struct wacom_features wacom_features_0x63 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003732 { "Wacom Volito2 2x3", 3248, 2320, 511, 63,
3733 GRAPHIRE, WACOM_VOLITO_RES, WACOM_VOLITO_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08003734static const struct wacom_features wacom_features_0x64 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003735 { "Wacom PenPartner2", 3250, 2320, 511, 63,
3736 GRAPHIRE, WACOM_VOLITO_RES, WACOM_VOLITO_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08003737static const struct wacom_features wacom_features_0x65 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003738 { "Wacom Bamboo", 14760, 9225, 511, 63,
3739 WACOM_MO, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08003740static const struct wacom_features wacom_features_0x69 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003741 { "Wacom Bamboo1", 5104, 3712, 511, 63,
3742 GRAPHIRE, WACOM_PENPRTN_RES, WACOM_PENPRTN_RES };
Ping Cheng11d0cf82011-06-27 12:57:58 -07003743static const struct wacom_features wacom_features_0x6A =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003744 { "Wacom Bamboo1 4x6", 14760, 9225, 1023, 63,
3745 GRAPHIRE, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Ping Cheng11d0cf82011-06-27 12:57:58 -07003746static const struct wacom_features wacom_features_0x6B =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003747 { "Wacom Bamboo1 5x8", 21648, 13530, 1023, 63,
3748 GRAPHIRE, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08003749static const struct wacom_features wacom_features_0x20 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003750 { "Wacom Intuos 4x5", 12700, 10600, 1023, 31,
3751 INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08003752static const struct wacom_features wacom_features_0x21 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003753 { "Wacom Intuos 6x8", 20320, 16240, 1023, 31,
3754 INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08003755static const struct wacom_features wacom_features_0x22 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003756 { "Wacom Intuos 9x12", 30480, 24060, 1023, 31,
3757 INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08003758static const struct wacom_features wacom_features_0x23 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003759 { "Wacom Intuos 12x12", 30480, 31680, 1023, 31,
3760 INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08003761static const struct wacom_features wacom_features_0x24 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003762 { "Wacom Intuos 12x18", 45720, 31680, 1023, 31,
3763 INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08003764static const struct wacom_features wacom_features_0x30 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003765 { "Wacom PL400", 5408, 4056, 255, 0,
3766 PL, WACOM_PL_RES, WACOM_PL_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08003767static const struct wacom_features wacom_features_0x31 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003768 { "Wacom PL500", 6144, 4608, 255, 0,
3769 PL, WACOM_PL_RES, WACOM_PL_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08003770static const struct wacom_features wacom_features_0x32 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003771 { "Wacom PL600", 6126, 4604, 255, 0,
3772 PL, WACOM_PL_RES, WACOM_PL_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08003773static const struct wacom_features wacom_features_0x33 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003774 { "Wacom PL600SX", 6260, 5016, 255, 0,
3775 PL, WACOM_PL_RES, WACOM_PL_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08003776static const struct wacom_features wacom_features_0x34 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003777 { "Wacom PL550", 6144, 4608, 511, 0,
3778 PL, WACOM_PL_RES, WACOM_PL_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08003779static const struct wacom_features wacom_features_0x35 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003780 { "Wacom PL800", 7220, 5780, 511, 0,
3781 PL, WACOM_PL_RES, WACOM_PL_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08003782static const struct wacom_features wacom_features_0x37 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003783 { "Wacom PL700", 6758, 5406, 511, 0,
3784 PL, WACOM_PL_RES, WACOM_PL_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08003785static const struct wacom_features wacom_features_0x38 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003786 { "Wacom PL510", 6282, 4762, 511, 0,
3787 PL, WACOM_PL_RES, WACOM_PL_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08003788static const struct wacom_features wacom_features_0x39 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003789 { "Wacom DTU710", 34080, 27660, 511, 0,
3790 PL, WACOM_PL_RES, WACOM_PL_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08003791static const struct wacom_features wacom_features_0xC4 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003792 { "Wacom DTF521", 6282, 4762, 511, 0,
3793 PL, WACOM_PL_RES, WACOM_PL_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08003794static const struct wacom_features wacom_features_0xC0 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003795 { "Wacom DTF720", 6858, 5506, 511, 0,
3796 PL, WACOM_PL_RES, WACOM_PL_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08003797static const struct wacom_features wacom_features_0xC2 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003798 { "Wacom DTF720a", 6858, 5506, 511, 0,
3799 PL, WACOM_PL_RES, WACOM_PL_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08003800static const struct wacom_features wacom_features_0x03 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003801 { "Wacom Cintiq Partner", 20480, 15360, 511, 0,
3802 PTU, WACOM_PL_RES, WACOM_PL_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08003803static const struct wacom_features wacom_features_0x41 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003804 { "Wacom Intuos2 4x5", 12700, 10600, 1023, 31,
3805 INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08003806static const struct wacom_features wacom_features_0x42 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003807 { "Wacom Intuos2 6x8", 20320, 16240, 1023, 31,
3808 INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08003809static const struct wacom_features wacom_features_0x43 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003810 { "Wacom Intuos2 9x12", 30480, 24060, 1023, 31,
3811 INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08003812static const struct wacom_features wacom_features_0x44 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003813 { "Wacom Intuos2 12x12", 30480, 31680, 1023, 31,
3814 INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08003815static const struct wacom_features wacom_features_0x45 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003816 { "Wacom Intuos2 12x18", 45720, 31680, 1023, 31,
3817 INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08003818static const struct wacom_features wacom_features_0xB0 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003819 { "Wacom Intuos3 4x5", 25400, 20320, 1023, 63,
Aaron Skomra70ee06c2015-08-20 16:05:16 -07003820 INTUOS3S, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 4 };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08003821static const struct wacom_features wacom_features_0xB1 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003822 { "Wacom Intuos3 6x8", 40640, 30480, 1023, 63,
Aaron Skomra70ee06c2015-08-20 16:05:16 -07003823 INTUOS3, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 8 };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08003824static const struct wacom_features wacom_features_0xB2 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003825 { "Wacom Intuos3 9x12", 60960, 45720, 1023, 63,
Aaron Skomra70ee06c2015-08-20 16:05:16 -07003826 INTUOS3, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 8 };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08003827static const struct wacom_features wacom_features_0xB3 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003828 { "Wacom Intuos3 12x12", 60960, 60960, 1023, 63,
Aaron Skomra70ee06c2015-08-20 16:05:16 -07003829 INTUOS3L, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 8 };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08003830static const struct wacom_features wacom_features_0xB4 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003831 { "Wacom Intuos3 12x19", 97536, 60960, 1023, 63,
Aaron Skomra70ee06c2015-08-20 16:05:16 -07003832 INTUOS3L, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 8 };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08003833static const struct wacom_features wacom_features_0xB5 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003834 { "Wacom Intuos3 6x11", 54204, 31750, 1023, 63,
Aaron Skomra70ee06c2015-08-20 16:05:16 -07003835 INTUOS3, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 8 };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08003836static const struct wacom_features wacom_features_0xB7 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003837 { "Wacom Intuos3 4x6", 31496, 19685, 1023, 63,
Aaron Skomra70ee06c2015-08-20 16:05:16 -07003838 INTUOS3S, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 4 };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08003839static const struct wacom_features wacom_features_0xB8 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003840 { "Wacom Intuos4 4x6", 31496, 19685, 2047, 63,
Aaron Skomra70ee06c2015-08-20 16:05:16 -07003841 INTUOS4S, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 7 };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08003842static const struct wacom_features wacom_features_0xB9 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003843 { "Wacom Intuos4 6x9", 44704, 27940, 2047, 63,
Aaron Skomra70ee06c2015-08-20 16:05:16 -07003844 INTUOS4, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9 };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08003845static const struct wacom_features wacom_features_0xBA =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003846 { "Wacom Intuos4 8x13", 65024, 40640, 2047, 63,
Aaron Skomra70ee06c2015-08-20 16:05:16 -07003847 INTUOS4L, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9 };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08003848static const struct wacom_features wacom_features_0xBB =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003849 { "Wacom Intuos4 12x19", 97536, 60960, 2047, 63,
Aaron Skomra70ee06c2015-08-20 16:05:16 -07003850 INTUOS4L, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9 };
Ping Cheng3a4b4aa2010-06-03 22:10:21 -07003851static const struct wacom_features wacom_features_0xBC =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003852 { "Wacom Intuos4 WL", 40640, 25400, 2047, 63,
Aaron Skomra70ee06c2015-08-20 16:05:16 -07003853 INTUOS4, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9 };
Benjamin Tissoires81af7e62014-08-06 13:55:56 -07003854static const struct wacom_features wacom_features_0xBD =
3855 { "Wacom Intuos4 WL", 40640, 25400, 2047, 63,
Aaron Skomra70ee06c2015-08-20 16:05:16 -07003856 INTUOS4WL, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9 };
Jason Gerecke9fee6192012-04-03 15:47:22 -07003857static const struct wacom_features wacom_features_0x26 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003858 { "Wacom Intuos5 touch S", 31496, 19685, 2047, 63,
Aaron Skomra70ee06c2015-08-20 16:05:16 -07003859 INTUOS5S, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 7, .touch_max = 16 };
Jason Gerecke9fee6192012-04-03 15:47:22 -07003860static const struct wacom_features wacom_features_0x27 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003861 { "Wacom Intuos5 touch M", 44704, 27940, 2047, 63,
Aaron Skomra70ee06c2015-08-20 16:05:16 -07003862 INTUOS5, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9, .touch_max = 16 };
Jason Gerecke9fee6192012-04-03 15:47:22 -07003863static const struct wacom_features wacom_features_0x28 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003864 { "Wacom Intuos5 touch L", 65024, 40640, 2047, 63,
Aaron Skomra70ee06c2015-08-20 16:05:16 -07003865 INTUOS5L, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9, .touch_max = 16 };
Jason Gerecke9fee6192012-04-03 15:47:22 -07003866static const struct wacom_features wacom_features_0x29 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003867 { "Wacom Intuos5 S", 31496, 19685, 2047, 63,
Aaron Skomra70ee06c2015-08-20 16:05:16 -07003868 INTUOS5S, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 7 };
Jason Gerecke9fee6192012-04-03 15:47:22 -07003869static const struct wacom_features wacom_features_0x2A =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003870 { "Wacom Intuos5 M", 44704, 27940, 2047, 63,
Aaron Skomra70ee06c2015-08-20 16:05:16 -07003871 INTUOS5, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9 };
Ping Cheng9a35c412013-09-20 09:51:56 -07003872static const struct wacom_features wacom_features_0x314 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003873 { "Wacom Intuos Pro S", 31496, 19685, 2047, 63,
Aaron Skomra70ee06c2015-08-20 16:05:16 -07003874 INTUOSPS, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 7, .touch_max = 16,
Benjamin Tissoires29b47392014-07-24 12:52:23 -07003875 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
Ping Cheng9a35c412013-09-20 09:51:56 -07003876static const struct wacom_features wacom_features_0x315 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003877 { "Wacom Intuos Pro M", 44704, 27940, 2047, 63,
Aaron Skomra70ee06c2015-08-20 16:05:16 -07003878 INTUOSPM, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9, .touch_max = 16,
Benjamin Tissoires29b47392014-07-24 12:52:23 -07003879 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
Ping Cheng9a35c412013-09-20 09:51:56 -07003880static const struct wacom_features wacom_features_0x317 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003881 { "Wacom Intuos Pro L", 65024, 40640, 2047, 63,
Aaron Skomra70ee06c2015-08-20 16:05:16 -07003882 INTUOSPL, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9, .touch_max = 16,
Benjamin Tissoires29b47392014-07-24 12:52:23 -07003883 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
Jason Gerecke803296b2011-12-12 00:11:45 -08003884static const struct wacom_features wacom_features_0xF4 =
Jason Gereckee779ef22016-10-19 18:03:49 -07003885 { "Wacom Cintiq 24HD", 104480, 65600, 2047, 63,
Aaron Skomra70ee06c2015-08-20 16:05:16 -07003886 WACOM_24HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 16,
Jason Gereckee779ef22016-10-19 18:03:49 -07003887 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
Ping Chengfa770342014-12-01 13:44:28 -08003888 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET };
Jason Gerecke6f4d0382012-08-21 22:11:59 -07003889static const struct wacom_features wacom_features_0xF8 =
Jason Gereckee779ef22016-10-19 18:03:49 -07003890 { "Wacom Cintiq 24HD touch", 104480, 65600, 2047, 63, /* Pen */
Aaron Skomra70ee06c2015-08-20 16:05:16 -07003891 WACOM_24HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 16,
Ping Chengfa770342014-12-01 13:44:28 -08003892 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
Jason Gereckee779ef22016-10-19 18:03:49 -07003893 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
Ping Cheng3bd1f7e2013-05-23 10:22:33 -07003894 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0xf6 };
Jason Gereckeb1e42792012-10-21 00:38:04 -07003895static const struct wacom_features wacom_features_0xF6 =
3896 { "Wacom Cintiq 24HD touch", .type = WACOM_24HDT, /* Touch */
Benjamin Tissoires29b47392014-07-24 12:52:23 -07003897 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0xf8, .touch_max = 10,
3898 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
Ping Cheng500d4162015-01-27 13:30:03 -08003899static const struct wacom_features wacom_features_0x32A =
Jason Gereckee779ef22016-10-19 18:03:49 -07003900 { "Wacom Cintiq 27QHD", 120140, 67920, 2047, 63,
Aaron Skomra70ee06c2015-08-20 16:05:16 -07003901 WACOM_27QHD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 0,
Jason Gereckee779ef22016-10-19 18:03:49 -07003902 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
Ping Chenga7e66452015-02-04 16:01:54 -08003903 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET };
Ping Cheng500d4162015-01-27 13:30:03 -08003904static const struct wacom_features wacom_features_0x32B =
Jason Gereckee779ef22016-10-19 18:03:49 -07003905 { "Wacom Cintiq 27QHD touch", 120140, 67920, 2047, 63,
Aaron Skomra70ee06c2015-08-20 16:05:16 -07003906 WACOM_27QHD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 0,
Ping Cheng500d4162015-01-27 13:30:03 -08003907 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
Jason Gereckee779ef22016-10-19 18:03:49 -07003908 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
Ping Cheng500d4162015-01-27 13:30:03 -08003909 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x32C };
3910static const struct wacom_features wacom_features_0x32C =
3911 { "Wacom Cintiq 27QHD touch", .type = WACOM_27QHDT,
3912 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x32B, .touch_max = 10 };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08003913static const struct wacom_features wacom_features_0x3F =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003914 { "Wacom Cintiq 21UX", 87200, 65600, 1023, 63,
Aaron Skomra70ee06c2015-08-20 16:05:16 -07003915 CINTIQ, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 8 };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08003916static const struct wacom_features wacom_features_0xC5 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003917 { "Wacom Cintiq 20WSX", 86680, 54180, 1023, 63,
Aaron Skomra70ee06c2015-08-20 16:05:16 -07003918 WACOM_BEE, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 10 };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08003919static const struct wacom_features wacom_features_0xC6 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003920 { "Wacom Cintiq 12WX", 53020, 33440, 1023, 63,
Aaron Skomra70ee06c2015-08-20 16:05:16 -07003921 WACOM_BEE, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 10 };
Ping Cheng56218562013-05-05 19:56:18 -07003922static const struct wacom_features wacom_features_0x304 =
Jason Gereckee779ef22016-10-19 18:03:49 -07003923 { "Wacom Cintiq 13HD", 59552, 33848, 1023, 63,
Aaron Skomra70ee06c2015-08-20 16:05:16 -07003924 WACOM_13HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9,
Jason Gereckee779ef22016-10-19 18:03:49 -07003925 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
Ping Chengfa770342014-12-01 13:44:28 -08003926 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET };
Ping Chengb4bf2122015-03-25 17:08:13 -07003927static const struct wacom_features wacom_features_0x333 =
Jason Gereckee779ef22016-10-19 18:03:49 -07003928 { "Wacom Cintiq 13HD touch", 59552, 33848, 2047, 63,
Aaron Skomra70ee06c2015-08-20 16:05:16 -07003929 WACOM_13HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9,
Ping Chengb4bf2122015-03-25 17:08:13 -07003930 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
Jason Gereckee779ef22016-10-19 18:03:49 -07003931 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
Ping Chengb4bf2122015-03-25 17:08:13 -07003932 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x335 };
3933static const struct wacom_features wacom_features_0x335 =
3934 { "Wacom Cintiq 13HD touch", .type = WACOM_24HDT, /* Touch */
3935 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x333, .touch_max = 10,
3936 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08003937static const struct wacom_features wacom_features_0xC7 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003938 { "Wacom DTU1931", 37832, 30305, 511, 0,
3939 PL, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Ping Chengc8f2edc2010-06-28 01:10:51 -07003940static const struct wacom_features wacom_features_0xCE =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003941 { "Wacom DTU2231", 47864, 27011, 511, 0,
3942 DTU, WACOM_INTUOS_RES, WACOM_INTUOS_RES,
Benjamin Tissoires29b47392014-07-24 12:52:23 -07003943 .check_for_hid_type = true, .hid_type = HID_TYPE_USBMOUSE };
Ping Chengc8f2edc2010-06-28 01:10:51 -07003944static const struct wacom_features wacom_features_0xF0 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003945 { "Wacom DTU1631", 34623, 19553, 511, 0,
3946 DTU, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Ping Cheng497ab1f2014-01-20 20:18:04 -08003947static const struct wacom_features wacom_features_0xFB =
Jason Gereckee779ef22016-10-19 18:03:49 -07003948 { "Wacom DTU1031", 22096, 13960, 511, 0,
Aaron Skomra70ee06c2015-08-20 16:05:16 -07003949 DTUS, WACOM_INTUOS_RES, WACOM_INTUOS_RES, 4,
Jason Gereckee779ef22016-10-19 18:03:49 -07003950 WACOM_DTU_OFFSET, WACOM_DTU_OFFSET,
Ping Chengfa770342014-12-01 13:44:28 -08003951 WACOM_DTU_OFFSET, WACOM_DTU_OFFSET };
Ping Chengfff00bf2014-12-04 18:23:04 -08003952static const struct wacom_features wacom_features_0x32F =
Jason Gereckee779ef22016-10-19 18:03:49 -07003953 { "Wacom DTU1031X", 22672, 12928, 511, 0,
Aaron Skomra70ee06c2015-08-20 16:05:16 -07003954 DTUSX, WACOM_INTUOS_RES, WACOM_INTUOS_RES, 0,
Jason Gereckee779ef22016-10-19 18:03:49 -07003955 WACOM_DTU_OFFSET, WACOM_DTU_OFFSET,
Ping Chengfff00bf2014-12-04 18:23:04 -08003956 WACOM_DTU_OFFSET, WACOM_DTU_OFFSET };
Aaron Skomra007760c2015-04-16 15:01:14 -07003957static const struct wacom_features wacom_features_0x336 =
Jason Gereckee779ef22016-10-19 18:03:49 -07003958 { "Wacom DTU1141", 23672, 13403, 1023, 0,
Ping Chengff38e822015-11-12 17:21:14 -08003959 DTUS, WACOM_INTUOS_RES, WACOM_INTUOS_RES, 4,
Jason Gereckee779ef22016-10-19 18:03:49 -07003960 WACOM_DTU_OFFSET, WACOM_DTU_OFFSET,
Ping Chengff38e822015-11-12 17:21:14 -08003961 WACOM_DTU_OFFSET, WACOM_DTU_OFFSET };
Ping Cheng56218562013-05-05 19:56:18 -07003962static const struct wacom_features wacom_features_0x57 =
Jason Gereckee779ef22016-10-19 18:03:49 -07003963 { "Wacom DTK2241", 95840, 54260, 2047, 63,
Aaron Skomra70ee06c2015-08-20 16:05:16 -07003964 DTK, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 6,
Jason Gereckee779ef22016-10-19 18:03:49 -07003965 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
Ping Chengfa770342014-12-01 13:44:28 -08003966 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET };
Ping Chenga112e9f2013-02-13 20:20:01 -08003967static const struct wacom_features wacom_features_0x59 = /* Pen */
Jason Gereckee779ef22016-10-19 18:03:49 -07003968 { "Wacom DTH2242", 95840, 54260, 2047, 63,
Aaron Skomra70ee06c2015-08-20 16:05:16 -07003969 DTK, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 6,
Ping Chengfa770342014-12-01 13:44:28 -08003970 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
Jason Gereckee779ef22016-10-19 18:03:49 -07003971 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
Ping Chenga112e9f2013-02-13 20:20:01 -08003972 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x5D };
3973static const struct wacom_features wacom_features_0x5D = /* Touch */
3974 { "Wacom DTH2242", .type = WACOM_24HDT,
Benjamin Tissoires29b47392014-07-24 12:52:23 -07003975 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x59, .touch_max = 10,
3976 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
Ping Cheng3a4b4aa2010-06-03 22:10:21 -07003977static const struct wacom_features wacom_features_0xCC =
Jason Gereckee779ef22016-10-19 18:03:49 -07003978 { "Wacom Cintiq 21UX2", 87200, 65600, 2047, 63,
Aaron Skomra70ee06c2015-08-20 16:05:16 -07003979 WACOM_21UX2, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 18,
Jason Gereckee779ef22016-10-19 18:03:49 -07003980 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
Ping Chengfa770342014-12-01 13:44:28 -08003981 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET };
Ping Chengd838c642012-07-24 23:54:11 -07003982static const struct wacom_features wacom_features_0xFA =
Jason Gereckee779ef22016-10-19 18:03:49 -07003983 { "Wacom Cintiq 22HD", 95840, 54260, 2047, 63,
Aaron Skomra70ee06c2015-08-20 16:05:16 -07003984 WACOM_22HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 18,
Jason Gereckee779ef22016-10-19 18:03:49 -07003985 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
Ping Chengfa770342014-12-01 13:44:28 -08003986 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET };
Ping Cheng56218562013-05-05 19:56:18 -07003987static const struct wacom_features wacom_features_0x5B =
Jason Gereckee779ef22016-10-19 18:03:49 -07003988 { "Wacom Cintiq 22HDT", 95840, 54260, 2047, 63,
Aaron Skomra70ee06c2015-08-20 16:05:16 -07003989 WACOM_22HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 18,
Ping Chengfa770342014-12-01 13:44:28 -08003990 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
Jason Gereckee779ef22016-10-19 18:03:49 -07003991 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
Ping Cheng3bd1f7e2013-05-23 10:22:33 -07003992 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x5e };
Ping Cheng56218562013-05-05 19:56:18 -07003993static const struct wacom_features wacom_features_0x5E =
3994 { "Wacom Cintiq 22HDT", .type = WACOM_24HDT,
Benjamin Tissoires29b47392014-07-24 12:52:23 -07003995 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x5b, .touch_max = 10,
3996 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08003997static const struct wacom_features wacom_features_0x90 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003998 { "Wacom ISDv4 90", 26202, 16325, 255, 0,
3999 TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08004000static const struct wacom_features wacom_features_0x93 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07004001 { "Wacom ISDv4 93", 26202, 16325, 255, 0,
4002 TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Ping Cheng11d0cf82011-06-27 12:57:58 -07004003static const struct wacom_features wacom_features_0x97 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07004004 { "Wacom ISDv4 97", 26202, 16325, 511, 0,
4005 TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08004006static const struct wacom_features wacom_features_0x9A =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07004007 { "Wacom ISDv4 9A", 26202, 16325, 255, 0,
4008 TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08004009static const struct wacom_features wacom_features_0x9F =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07004010 { "Wacom ISDv4 9F", 26202, 16325, 255, 0,
4011 TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08004012static const struct wacom_features wacom_features_0xE2 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07004013 { "Wacom ISDv4 E2", 26202, 16325, 255, 0,
4014 TABLETPC2FG, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08004015static const struct wacom_features wacom_features_0xE3 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07004016 { "Wacom ISDv4 E3", 26202, 16325, 255, 0,
4017 TABLETPC2FG, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
Ping Cheng19635182012-04-29 21:09:18 -07004018static const struct wacom_features wacom_features_0xE5 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07004019 { "Wacom ISDv4 E5", 26202, 16325, 255, 0,
4020 MTSCREEN, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Manoj Iyer26fcd2a2011-03-31 22:39:43 -07004021static const struct wacom_features wacom_features_0xE6 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07004022 { "Wacom ISDv4 E6", 27760, 15694, 255, 0,
4023 TABLETPC2FG, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
Chris Bagwell0d0e3062011-12-11 23:50:59 -08004024static const struct wacom_features wacom_features_0xEC =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07004025 { "Wacom ISDv4 EC", 25710, 14500, 255, 0,
4026 TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Ping Chengac173832012-06-12 00:15:06 -07004027static const struct wacom_features wacom_features_0xED =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07004028 { "Wacom ISDv4 ED", 26202, 16325, 255, 0,
4029 TABLETPCE, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Ping Chengac173832012-06-12 00:15:06 -07004030static const struct wacom_features wacom_features_0xEF =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07004031 { "Wacom ISDv4 EF", 26202, 16325, 255, 0,
4032 TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Ping Cheng6afdc282012-11-03 12:16:15 -07004033static const struct wacom_features wacom_features_0x100 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07004034 { "Wacom ISDv4 100", 26202, 16325, 255, 0,
4035 MTTPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Ping Cheng6afdc282012-11-03 12:16:15 -07004036static const struct wacom_features wacom_features_0x101 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07004037 { "Wacom ISDv4 101", 26202, 16325, 255, 0,
4038 MTTPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Stephan Frank58694832013-03-07 14:08:50 -08004039static const struct wacom_features wacom_features_0x10D =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07004040 { "Wacom ISDv4 10D", 26202, 16325, 255, 0,
4041 MTTPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Jason Gerecke2d3163f2013-10-22 15:35:30 -07004042static const struct wacom_features wacom_features_0x10E =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07004043 { "Wacom ISDv4 10E", 27760, 15694, 255, 0,
4044 MTTPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Jason Gerecke9b4f60e2013-10-15 23:46:34 -07004045static const struct wacom_features wacom_features_0x10F =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07004046 { "Wacom ISDv4 10F", 27760, 15694, 255, 0,
4047 MTTPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Jason Gerecke61616ed2014-05-14 11:42:22 -07004048static const struct wacom_features wacom_features_0x116 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07004049 { "Wacom ISDv4 116", 26202, 16325, 255, 0,
4050 TABLETPCE, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Jason Gereckeaeaf50d2014-07-28 10:53:16 -07004051static const struct wacom_features wacom_features_0x12C =
4052 { "Wacom ISDv4 12C", 27848, 15752, 2047, 0,
4053 TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Ping Chengedbe2652012-11-21 13:12:50 -08004054static const struct wacom_features wacom_features_0x4001 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07004055 { "Wacom ISDv4 4001", 26202, 16325, 255, 0,
4056 MTTPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Jason Gerecked51ddb22014-05-14 17:14:29 -07004057static const struct wacom_features wacom_features_0x4004 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07004058 { "Wacom ISDv4 4004", 11060, 6220, 255, 0,
4059 MTTPC_B, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Jason Gerecked51ddb22014-05-14 17:14:29 -07004060static const struct wacom_features wacom_features_0x5000 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07004061 { "Wacom ISDv4 5000", 27848, 15752, 1023, 0,
4062 MTTPC_B, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Jason Gerecked51ddb22014-05-14 17:14:29 -07004063static const struct wacom_features wacom_features_0x5002 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07004064 { "Wacom ISDv4 5002", 29576, 16724, 1023, 0,
4065 MTTPC_B, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08004066static const struct wacom_features wacom_features_0x47 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07004067 { "Wacom Intuos2 6x8", 20320, 16240, 1023, 31,
4068 INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Chris Bagwelld3825d52012-03-25 23:26:11 -07004069static const struct wacom_features wacom_features_0x84 =
Ping Cheng3b164a02015-09-23 09:59:10 -07004070 { "Wacom Wireless Receiver", .type = WIRELESS, .touch_max = 16 };
Ping Cheng7b824bb2011-03-26 21:16:04 -07004071static const struct wacom_features wacom_features_0xD0 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07004072 { "Wacom Bamboo 2FG", 14720, 9200, 1023, 31,
Ping Cheng3b164a02015-09-23 09:59:10 -07004073 BAMBOO_TOUCH, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
Ping Cheng7b824bb2011-03-26 21:16:04 -07004074static const struct wacom_features wacom_features_0xD1 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07004075 { "Wacom Bamboo 2FG 4x5", 14720, 9200, 1023, 31,
4076 BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
Ping Cheng7b824bb2011-03-26 21:16:04 -07004077static const struct wacom_features wacom_features_0xD2 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07004078 { "Wacom Bamboo Craft", 14720, 9200, 1023, 31,
4079 BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
Ping Cheng7b824bb2011-03-26 21:16:04 -07004080static const struct wacom_features wacom_features_0xD3 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07004081 { "Wacom Bamboo 2FG 6x8", 21648, 13700, 1023, 31,
4082 BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
Kevin Granade57a78722010-12-10 23:04:02 -08004083static const struct wacom_features wacom_features_0xD4 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07004084 { "Wacom Bamboo Pen", 14720, 9200, 1023, 31,
Ping Cheng3b164a02015-09-23 09:59:10 -07004085 BAMBOO_PEN, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Gerard Braad18adad12011-08-16 00:17:56 -07004086static const struct wacom_features wacom_features_0xD5 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07004087 { "Wacom Bamboo Pen 6x8", 21648, 13700, 1023, 31,
Ping Cheng3b164a02015-09-23 09:59:10 -07004088 BAMBOO_PEN, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Ping Cheng7b824bb2011-03-26 21:16:04 -07004089static const struct wacom_features wacom_features_0xD6 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07004090 { "Wacom BambooPT 2FG 4x5", 14720, 9200, 1023, 31,
4091 BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
Ping Cheng7b824bb2011-03-26 21:16:04 -07004092static const struct wacom_features wacom_features_0xD7 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07004093 { "Wacom BambooPT 2FG Small", 14720, 9200, 1023, 31,
4094 BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
Ping Cheng7b824bb2011-03-26 21:16:04 -07004095static const struct wacom_features wacom_features_0xD8 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07004096 { "Wacom Bamboo Comic 2FG", 21648, 13700, 1023, 31,
4097 BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
Ping Cheng7b824bb2011-03-26 21:16:04 -07004098static const struct wacom_features wacom_features_0xDA =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07004099 { "Wacom Bamboo 2FG 4x5 SE", 14720, 9200, 1023, 31,
4100 BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
Ping Chengf41a64e2013-08-21 09:14:49 -07004101static const struct wacom_features wacom_features_0xDB =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07004102 { "Wacom Bamboo 2FG 6x8 SE", 21648, 13700, 1023, 31,
4103 BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
Chris Bagwell73149ab2011-10-26 22:34:21 -07004104static const struct wacom_features wacom_features_0xDD =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07004105 { "Wacom Bamboo Connect", 14720, 9200, 1023, 31,
4106 BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Chris Bagwell73149ab2011-10-26 22:34:21 -07004107static const struct wacom_features wacom_features_0xDE =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07004108 { "Wacom Bamboo 16FG 4x5", 14720, 9200, 1023, 31,
4109 BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 16 };
Chris Bagwell73149ab2011-10-26 22:34:21 -07004110static const struct wacom_features wacom_features_0xDF =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07004111 { "Wacom Bamboo 16FG 6x8", 21648, 13700, 1023, 31,
4112 BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 16 };
Ping Chengf41a64e2013-08-21 09:14:49 -07004113static const struct wacom_features wacom_features_0x300 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07004114 { "Wacom Bamboo One S", 14720, 9225, 1023, 31,
Ping Cheng3b164a02015-09-23 09:59:10 -07004115 BAMBOO_PEN, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Ping Chengf41a64e2013-08-21 09:14:49 -07004116static const struct wacom_features wacom_features_0x301 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07004117 { "Wacom Bamboo One M", 21648, 13530, 1023, 31,
4118 BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Ping Chengb5fd2a32013-11-25 18:44:55 -08004119static const struct wacom_features wacom_features_0x302 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07004120 { "Wacom Intuos PT S", 15200, 9500, 1023, 31,
4121 INTUOSHT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 16,
Benjamin Tissoires29b47392014-07-24 12:52:23 -07004122 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
Ping Chengb5fd2a32013-11-25 18:44:55 -08004123static const struct wacom_features wacom_features_0x303 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07004124 { "Wacom Intuos PT M", 21600, 13500, 1023, 31,
4125 INTUOSHT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 16,
Benjamin Tissoires29b47392014-07-24 12:52:23 -07004126 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
Ping Chengb5fd2a32013-11-25 18:44:55 -08004127static const struct wacom_features wacom_features_0x30E =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07004128 { "Wacom Intuos S", 15200, 9500, 1023, 31,
4129 INTUOSHT, WACOM_INTUOS_RES, WACOM_INTUOS_RES,
Benjamin Tissoires29b47392014-07-24 12:52:23 -07004130 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
Ajay Ramaswamy7b4b3062010-12-23 01:19:39 -08004131static const struct wacom_features wacom_features_0x6004 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07004132 { "ISD-V4", 12800, 8000, 255, 0,
4133 TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Benjamin Tissoiresa3e6f652014-07-24 13:05:49 -07004134static const struct wacom_features wacom_features_0x307 =
Jason Gereckee779ef22016-10-19 18:03:49 -07004135 { "Wacom ISDv5 307", 59552, 33848, 2047, 63,
Aaron Skomra70ee06c2015-08-20 16:05:16 -07004136 CINTIQ_HYBRID, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9,
Ping Chengfa770342014-12-01 13:44:28 -08004137 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
Jason Gereckee779ef22016-10-19 18:03:49 -07004138 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
Jason Gerecke36d3c512013-09-20 09:47:35 -07004139 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x309 };
Benjamin Tissoiresa3e6f652014-07-24 13:05:49 -07004140static const struct wacom_features wacom_features_0x309 =
Jason Gerecke36d3c512013-09-20 09:47:35 -07004141 { "Wacom ISDv5 309", .type = WACOM_24HDT, /* Touch */
Benjamin Tissoires29b47392014-07-24 12:52:23 -07004142 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x0307, .touch_max = 10,
4143 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
Benjamin Tissoires89f2ab52014-09-03 15:43:25 -04004144static const struct wacom_features wacom_features_0x30A =
Jason Gereckee779ef22016-10-19 18:03:49 -07004145 { "Wacom ISDv5 30A", 59552, 33848, 2047, 63,
Aaron Skomra70ee06c2015-08-20 16:05:16 -07004146 CINTIQ_HYBRID, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9,
Ping Chengfa770342014-12-01 13:44:28 -08004147 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
Jason Gereckee779ef22016-10-19 18:03:49 -07004148 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
Benjamin Tissoires89f2ab52014-09-03 15:43:25 -04004149 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x30C };
4150static const struct wacom_features wacom_features_0x30C =
4151 { "Wacom ISDv5 30C", .type = WACOM_24HDT, /* Touch */
4152 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x30A, .touch_max = 10,
4153 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
Benjamin Tissoires8c97a762015-02-26 11:28:50 -05004154static const struct wacom_features wacom_features_0x318 =
4155 { "Wacom USB Bamboo PAD", 4095, 4095, /* Touch */
4156 .type = BAMBOO_PAD, 35, 48, .touch_max = 4 };
4157static const struct wacom_features wacom_features_0x319 =
4158 { "Wacom Wireless Bamboo PAD", 4095, 4095, /* Touch */
4159 .type = BAMBOO_PAD, 35, 48, .touch_max = 4 };
Jason Gereckef7acb552015-10-13 10:03:49 -07004160static const struct wacom_features wacom_features_0x325 =
4161 { "Wacom ISDv5 325", 59552, 33848, 2047, 63,
4162 CINTIQ_COMPANION_2, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 11,
4163 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
Jason Gereckee779ef22016-10-19 18:03:49 -07004164 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
Jason Gereckef7acb552015-10-13 10:03:49 -07004165 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x326 };
4166static const struct wacom_features wacom_features_0x326 = /* Touch */
4167 { "Wacom ISDv5 326", .type = HID_GENERIC, .oVid = USB_VENDOR_ID_WACOM,
4168 .oPid = 0x325 };
Ping Chengfefb3912014-11-11 12:52:08 -08004169static const struct wacom_features wacom_features_0x323 =
4170 { "Wacom Intuos P M", 21600, 13500, 1023, 31,
4171 INTUOSHT, WACOM_INTUOS_RES, WACOM_INTUOS_RES,
4172 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
Aaron Skomra72b236d2015-08-20 16:05:17 -07004173static const struct wacom_features wacom_features_0x331 =
Ping Cheng3b164a02015-09-23 09:59:10 -07004174 { "Wacom Express Key Remote", .type = REMOTE,
4175 .numbered_buttons = 18, .check_for_hid_type = true,
Aaron Skomra72b236d2015-08-20 16:05:17 -07004176 .hid_type = HID_TYPE_USBNONE };
Ping Chengeda01da2015-09-23 13:51:15 -07004177static const struct wacom_features wacom_features_0x33B =
4178 { "Wacom Intuos S 2", 15200, 9500, 2047, 63,
4179 INTUOSHT2, WACOM_INTUOS_RES, WACOM_INTUOS_RES,
4180 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
4181static const struct wacom_features wacom_features_0x33C =
4182 { "Wacom Intuos PT S 2", 15200, 9500, 2047, 63,
4183 INTUOSHT2, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 16,
4184 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
4185static const struct wacom_features wacom_features_0x33D =
4186 { "Wacom Intuos P M 2", 21600, 13500, 2047, 63,
4187 INTUOSHT2, WACOM_INTUOS_RES, WACOM_INTUOS_RES,
4188 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
4189static const struct wacom_features wacom_features_0x33E =
4190 { "Wacom Intuos PT M 2", 21600, 13500, 2047, 63,
4191 INTUOSHT2, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 16,
4192 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
Ping Chenge1123fe2016-04-12 13:37:45 -07004193static const struct wacom_features wacom_features_0x343 =
Jason Gereckee779ef22016-10-19 18:03:49 -07004194 { "Wacom DTK1651", 34816, 19759, 1023, 0,
Ping Chenge1123fe2016-04-12 13:37:45 -07004195 DTUS, WACOM_INTUOS_RES, WACOM_INTUOS_RES, 4,
Jason Gereckee779ef22016-10-19 18:03:49 -07004196 WACOM_DTU_OFFSET, WACOM_DTU_OFFSET,
Ping Chenge1123fe2016-04-12 13:37:45 -07004197 WACOM_DTU_OFFSET, WACOM_DTU_OFFSET };
Jason Gerecke4922cd22017-01-25 12:08:37 -08004198static const struct wacom_features wacom_features_0x360 =
4199 { "Wacom Intuos Pro M", 44800, 29600, 8191, 63,
4200 INTUOSP2_BT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, 9, .touch_max = 10 };
4201static const struct wacom_features wacom_features_0x361 =
4202 { "Wacom Intuos Pro L", 62200, 43200, 8191, 63,
4203 INTUOSP2_BT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, 9, .touch_max = 10 };
Bastian Blankb036f6f2010-02-10 23:06:23 -08004204
Benjamin Tissoires7704ac92014-09-23 12:08:08 -04004205static const struct wacom_features wacom_features_HID_ANY_ID =
Jason Gerecke41372d52016-08-08 12:06:30 -07004206 { "Wacom HID", .type = HID_GENERIC, .oVid = HID_ANY_ID, .oPid = HID_ANY_ID };
Benjamin Tissoires7704ac92014-09-23 12:08:08 -04004207
Benjamin Tissoires29b47392014-07-24 12:52:23 -07004208#define USB_DEVICE_WACOM(prod) \
4209 HID_DEVICE(BUS_USB, HID_GROUP_WACOM, USB_VENDOR_ID_WACOM, prod),\
4210 .driver_data = (kernel_ulong_t)&wacom_features_##prod
Bastian Blankb036f6f2010-02-10 23:06:23 -08004211
Benjamin Tissoires387142b2014-08-06 13:52:56 -07004212#define BT_DEVICE_WACOM(prod) \
4213 HID_DEVICE(BUS_BLUETOOTH, HID_GROUP_WACOM, USB_VENDOR_ID_WACOM, prod),\
4214 .driver_data = (kernel_ulong_t)&wacom_features_##prod
Aristeu Rozanski1483f552011-06-22 01:17:17 -07004215
Mika Westerbergeef23a82015-02-23 15:52:43 +02004216#define I2C_DEVICE_WACOM(prod) \
4217 HID_DEVICE(BUS_I2C, HID_GROUP_WACOM, USB_VENDOR_ID_WACOM, prod),\
4218 .driver_data = (kernel_ulong_t)&wacom_features_##prod
4219
Ajay Ramaswamy7b4b3062010-12-23 01:19:39 -08004220#define USB_DEVICE_LENOVO(prod) \
Benjamin Tissoires29b47392014-07-24 12:52:23 -07004221 HID_USB_DEVICE(USB_VENDOR_ID_LENOVO, prod), \
4222 .driver_data = (kernel_ulong_t)&wacom_features_##prod
Ajay Ramaswamy7b4b3062010-12-23 01:19:39 -08004223
Benjamin Tissoires29b47392014-07-24 12:52:23 -07004224const struct hid_device_id wacom_ids[] = {
Bastian Blankb036f6f2010-02-10 23:06:23 -08004225 { USB_DEVICE_WACOM(0x00) },
Benjamin Tissoiresa3e6f652014-07-24 13:05:49 -07004226 { USB_DEVICE_WACOM(0x03) },
Bastian Blankb036f6f2010-02-10 23:06:23 -08004227 { USB_DEVICE_WACOM(0x10) },
4228 { USB_DEVICE_WACOM(0x11) },
4229 { USB_DEVICE_WACOM(0x12) },
4230 { USB_DEVICE_WACOM(0x13) },
4231 { USB_DEVICE_WACOM(0x14) },
4232 { USB_DEVICE_WACOM(0x15) },
4233 { USB_DEVICE_WACOM(0x16) },
4234 { USB_DEVICE_WACOM(0x17) },
4235 { USB_DEVICE_WACOM(0x18) },
4236 { USB_DEVICE_WACOM(0x19) },
Bastian Blankb036f6f2010-02-10 23:06:23 -08004237 { USB_DEVICE_WACOM(0x20) },
4238 { USB_DEVICE_WACOM(0x21) },
4239 { USB_DEVICE_WACOM(0x22) },
4240 { USB_DEVICE_WACOM(0x23) },
4241 { USB_DEVICE_WACOM(0x24) },
Benjamin Tissoiresa3e6f652014-07-24 13:05:49 -07004242 { USB_DEVICE_WACOM(0x26) },
4243 { USB_DEVICE_WACOM(0x27) },
4244 { USB_DEVICE_WACOM(0x28) },
4245 { USB_DEVICE_WACOM(0x29) },
4246 { USB_DEVICE_WACOM(0x2A) },
Bastian Blankb036f6f2010-02-10 23:06:23 -08004247 { USB_DEVICE_WACOM(0x30) },
4248 { USB_DEVICE_WACOM(0x31) },
4249 { USB_DEVICE_WACOM(0x32) },
4250 { USB_DEVICE_WACOM(0x33) },
4251 { USB_DEVICE_WACOM(0x34) },
4252 { USB_DEVICE_WACOM(0x35) },
4253 { USB_DEVICE_WACOM(0x37) },
4254 { USB_DEVICE_WACOM(0x38) },
4255 { USB_DEVICE_WACOM(0x39) },
Benjamin Tissoiresa3e6f652014-07-24 13:05:49 -07004256 { USB_DEVICE_WACOM(0x3F) },
Bastian Blankb036f6f2010-02-10 23:06:23 -08004257 { USB_DEVICE_WACOM(0x41) },
4258 { USB_DEVICE_WACOM(0x42) },
4259 { USB_DEVICE_WACOM(0x43) },
4260 { USB_DEVICE_WACOM(0x44) },
4261 { USB_DEVICE_WACOM(0x45) },
Benjamin Tissoiresa3e6f652014-07-24 13:05:49 -07004262 { USB_DEVICE_WACOM(0x47) },
Ping Cheng56218562013-05-05 19:56:18 -07004263 { USB_DEVICE_WACOM(0x57) },
Ping Chenga112e9f2013-02-13 20:20:01 -08004264 { USB_DEVICE_WACOM(0x59) },
Ping Cheng56218562013-05-05 19:56:18 -07004265 { USB_DEVICE_WACOM(0x5B) },
Benjamin Tissoiresa3e6f652014-07-24 13:05:49 -07004266 { USB_DEVICE_WACOM(0x5D) },
Benjamin Tissoires29b47392014-07-24 12:52:23 -07004267 { USB_DEVICE_WACOM(0x5E) },
Benjamin Tissoiresa3e6f652014-07-24 13:05:49 -07004268 { USB_DEVICE_WACOM(0x60) },
4269 { USB_DEVICE_WACOM(0x61) },
4270 { USB_DEVICE_WACOM(0x62) },
4271 { USB_DEVICE_WACOM(0x63) },
4272 { USB_DEVICE_WACOM(0x64) },
4273 { USB_DEVICE_WACOM(0x65) },
4274 { USB_DEVICE_WACOM(0x69) },
4275 { USB_DEVICE_WACOM(0x6A) },
4276 { USB_DEVICE_WACOM(0x6B) },
Benjamin Tissoires387142b2014-08-06 13:52:56 -07004277 { BT_DEVICE_WACOM(0x81) },
Benjamin Tissoiresa3e6f652014-07-24 13:05:49 -07004278 { USB_DEVICE_WACOM(0x84) },
4279 { USB_DEVICE_WACOM(0x90) },
4280 { USB_DEVICE_WACOM(0x93) },
4281 { USB_DEVICE_WACOM(0x97) },
4282 { USB_DEVICE_WACOM(0x9A) },
4283 { USB_DEVICE_WACOM(0x9F) },
Bastian Blankb036f6f2010-02-10 23:06:23 -08004284 { USB_DEVICE_WACOM(0xB0) },
4285 { USB_DEVICE_WACOM(0xB1) },
4286 { USB_DEVICE_WACOM(0xB2) },
4287 { USB_DEVICE_WACOM(0xB3) },
4288 { USB_DEVICE_WACOM(0xB4) },
4289 { USB_DEVICE_WACOM(0xB5) },
4290 { USB_DEVICE_WACOM(0xB7) },
4291 { USB_DEVICE_WACOM(0xB8) },
4292 { USB_DEVICE_WACOM(0xB9) },
4293 { USB_DEVICE_WACOM(0xBA) },
4294 { USB_DEVICE_WACOM(0xBB) },
Ping Cheng3a4b4aa2010-06-03 22:10:21 -07004295 { USB_DEVICE_WACOM(0xBC) },
Benjamin Tissoires81af7e62014-08-06 13:55:56 -07004296 { BT_DEVICE_WACOM(0xBD) },
Benjamin Tissoiresa3e6f652014-07-24 13:05:49 -07004297 { USB_DEVICE_WACOM(0xC0) },
4298 { USB_DEVICE_WACOM(0xC2) },
4299 { USB_DEVICE_WACOM(0xC4) },
Bastian Blankb036f6f2010-02-10 23:06:23 -08004300 { USB_DEVICE_WACOM(0xC5) },
4301 { USB_DEVICE_WACOM(0xC6) },
4302 { USB_DEVICE_WACOM(0xC7) },
Benjamin Tissoiresa3e6f652014-07-24 13:05:49 -07004303 { USB_DEVICE_WACOM(0xCC) },
Benjamin Tissoires29b47392014-07-24 12:52:23 -07004304 { USB_DEVICE_WACOM(0xCE) },
Henrik Rydbergcb734c02010-09-05 12:53:16 -07004305 { USB_DEVICE_WACOM(0xD0) },
Chris Bagwell2aaacb12010-09-12 00:11:35 -07004306 { USB_DEVICE_WACOM(0xD1) },
4307 { USB_DEVICE_WACOM(0xD2) },
4308 { USB_DEVICE_WACOM(0xD3) },
Kevin Granade57a78722010-12-10 23:04:02 -08004309 { USB_DEVICE_WACOM(0xD4) },
Gerard Braad18adad12011-08-16 00:17:56 -07004310 { USB_DEVICE_WACOM(0xD5) },
Ping Chengd38acb42011-01-24 09:32:50 -08004311 { USB_DEVICE_WACOM(0xD6) },
4312 { USB_DEVICE_WACOM(0xD7) },
David Foleya318e6b2010-11-30 23:45:46 -08004313 { USB_DEVICE_WACOM(0xD8) },
4314 { USB_DEVICE_WACOM(0xDA) },
David Foley47d09232010-12-07 21:05:59 -08004315 { USB_DEVICE_WACOM(0xDB) },
Chris Bagwell73149ab2011-10-26 22:34:21 -07004316 { USB_DEVICE_WACOM(0xDD) },
4317 { USB_DEVICE_WACOM(0xDE) },
4318 { USB_DEVICE_WACOM(0xDF) },
Bastian Blankb036f6f2010-02-10 23:06:23 -08004319 { USB_DEVICE_WACOM(0xE2) },
4320 { USB_DEVICE_WACOM(0xE3) },
Ping Cheng19635182012-04-29 21:09:18 -07004321 { USB_DEVICE_WACOM(0xE5) },
Manoj Iyer26fcd2a2011-03-31 22:39:43 -07004322 { USB_DEVICE_WACOM(0xE6) },
Chris Bagwell0d0e3062011-12-11 23:50:59 -08004323 { USB_DEVICE_WACOM(0xEC) },
Ping Chengac173832012-06-12 00:15:06 -07004324 { USB_DEVICE_WACOM(0xED) },
4325 { USB_DEVICE_WACOM(0xEF) },
Benjamin Tissoiresa3e6f652014-07-24 13:05:49 -07004326 { USB_DEVICE_WACOM(0xF0) },
4327 { USB_DEVICE_WACOM(0xF4) },
4328 { USB_DEVICE_WACOM(0xF6) },
4329 { USB_DEVICE_WACOM(0xF8) },
4330 { USB_DEVICE_WACOM(0xFA) },
4331 { USB_DEVICE_WACOM(0xFB) },
Ping Cheng6afdc282012-11-03 12:16:15 -07004332 { USB_DEVICE_WACOM(0x100) },
4333 { USB_DEVICE_WACOM(0x101) },
Stephan Frank58694832013-03-07 14:08:50 -08004334 { USB_DEVICE_WACOM(0x10D) },
Jason Gerecke2d3163f2013-10-22 15:35:30 -07004335 { USB_DEVICE_WACOM(0x10E) },
Jason Gerecke9b4f60e2013-10-15 23:46:34 -07004336 { USB_DEVICE_WACOM(0x10F) },
Jason Gerecke61616ed2014-05-14 11:42:22 -07004337 { USB_DEVICE_WACOM(0x116) },
Jason Gereckeaeaf50d2014-07-28 10:53:16 -07004338 { USB_DEVICE_WACOM(0x12C) },
Ping Chengf41a64e2013-08-21 09:14:49 -07004339 { USB_DEVICE_WACOM(0x300) },
4340 { USB_DEVICE_WACOM(0x301) },
Benjamin Tissoires29b47392014-07-24 12:52:23 -07004341 { USB_DEVICE_WACOM(0x302) },
4342 { USB_DEVICE_WACOM(0x303) },
Ping Cheng56218562013-05-05 19:56:18 -07004343 { USB_DEVICE_WACOM(0x304) },
Benjamin Tissoiresa3e6f652014-07-24 13:05:49 -07004344 { USB_DEVICE_WACOM(0x307) },
4345 { USB_DEVICE_WACOM(0x309) },
Benjamin Tissoires89f2ab52014-09-03 15:43:25 -04004346 { USB_DEVICE_WACOM(0x30A) },
4347 { USB_DEVICE_WACOM(0x30C) },
Benjamin Tissoiresa3e6f652014-07-24 13:05:49 -07004348 { USB_DEVICE_WACOM(0x30E) },
Benjamin Tissoires29b47392014-07-24 12:52:23 -07004349 { USB_DEVICE_WACOM(0x314) },
4350 { USB_DEVICE_WACOM(0x315) },
4351 { USB_DEVICE_WACOM(0x317) },
Benjamin Tissoires8c97a762015-02-26 11:28:50 -05004352 { USB_DEVICE_WACOM(0x318) },
4353 { USB_DEVICE_WACOM(0x319) },
Ping Chengfefb3912014-11-11 12:52:08 -08004354 { USB_DEVICE_WACOM(0x323) },
Jason Gereckef7acb552015-10-13 10:03:49 -07004355 { USB_DEVICE_WACOM(0x325) },
4356 { USB_DEVICE_WACOM(0x326) },
Ping Cheng500d4162015-01-27 13:30:03 -08004357 { USB_DEVICE_WACOM(0x32A) },
4358 { USB_DEVICE_WACOM(0x32B) },
4359 { USB_DEVICE_WACOM(0x32C) },
Ping Chengfff00bf2014-12-04 18:23:04 -08004360 { USB_DEVICE_WACOM(0x32F) },
Aaron Skomra72b236d2015-08-20 16:05:17 -07004361 { USB_DEVICE_WACOM(0x331) },
Ping Chengb4bf2122015-03-25 17:08:13 -07004362 { USB_DEVICE_WACOM(0x333) },
4363 { USB_DEVICE_WACOM(0x335) },
Aaron Skomra007760c2015-04-16 15:01:14 -07004364 { USB_DEVICE_WACOM(0x336) },
Ping Chengeda01da2015-09-23 13:51:15 -07004365 { USB_DEVICE_WACOM(0x33B) },
4366 { USB_DEVICE_WACOM(0x33C) },
4367 { USB_DEVICE_WACOM(0x33D) },
4368 { USB_DEVICE_WACOM(0x33E) },
Ping Chenge1123fe2016-04-12 13:37:45 -07004369 { USB_DEVICE_WACOM(0x343) },
Jason Gerecke4922cd22017-01-25 12:08:37 -08004370 { BT_DEVICE_WACOM(0x360) },
4371 { BT_DEVICE_WACOM(0x361) },
Ping Chengedbe2652012-11-21 13:12:50 -08004372 { USB_DEVICE_WACOM(0x4001) },
Jason Gerecked51ddb22014-05-14 17:14:29 -07004373 { USB_DEVICE_WACOM(0x4004) },
4374 { USB_DEVICE_WACOM(0x5000) },
4375 { USB_DEVICE_WACOM(0x5002) },
Benjamin Tissoires00d6f2272014-12-01 11:52:39 -05004376 { USB_DEVICE_LENOVO(0x6004) },
Benjamin Tissoires7704ac92014-09-23 12:08:08 -04004377
4378 { USB_DEVICE_WACOM(HID_ANY_ID) },
Mika Westerbergeef23a82015-02-23 15:52:43 +02004379 { I2C_DEVICE_WACOM(HID_ANY_ID) },
Jason Gereckeb9e06252017-01-25 12:08:35 -08004380 { BT_DEVICE_WACOM(HID_ANY_ID) },
Ping Cheng3bea7332006-07-13 18:01:36 -07004381 { }
4382};
Benjamin Tissoires29b47392014-07-24 12:52:23 -07004383MODULE_DEVICE_TABLE(hid, wacom_ids);