blob: c611ea5b83c82eeb61e3cfa6c9cc081140bc9be5 [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
Benjamin Tissoires387142b2014-08-06 13:52:56 -070037/*
38 * Percent of battery capacity for Graphire.
39 * 8th value means AC online and show 100% capacity.
40 */
41static unsigned short batcap_gr[8] = { 1, 15, 25, 35, 50, 70, 100, 100 };
42
Benjamin Tissoires81af7e62014-08-06 13:55:56 -070043/*
44 * Percent of battery capacity for Intuos4 WL, AC has a separate bit.
45 */
46static unsigned short batcap_i4[8] = { 1, 15, 30, 45, 60, 70, 85, 100 };
47
Jason Gerecke953f2c52015-03-06 11:47:39 -080048static void wacom_notify_battery(struct wacom_wac *wacom_wac,
Jason Gerecke71fa6412015-03-11 10:25:41 -070049 int bat_capacity, bool bat_charging, bool bat_connected,
50 bool ps_connected)
Jason Gerecke953f2c52015-03-06 11:47:39 -080051{
52 struct wacom *wacom = container_of(wacom_wac, struct wacom, wacom_wac);
53 bool changed = wacom_wac->battery_capacity != bat_capacity ||
54 wacom_wac->bat_charging != bat_charging ||
Jason Gerecke71fa6412015-03-11 10:25:41 -070055 wacom_wac->bat_connected != bat_connected ||
Jason Gerecke953f2c52015-03-06 11:47:39 -080056 wacom_wac->ps_connected != ps_connected;
57
58 if (changed) {
59 wacom_wac->battery_capacity = bat_capacity;
60 wacom_wac->bat_charging = bat_charging;
Jason Gerecke71fa6412015-03-11 10:25:41 -070061 wacom_wac->bat_connected = bat_connected;
Jason Gerecke953f2c52015-03-06 11:47:39 -080062 wacom_wac->ps_connected = ps_connected;
63
Linus Torvalds8de29a32015-04-14 08:25:26 -080064 if (wacom->battery)
65 power_supply_changed(wacom->battery);
Jason Gerecke953f2c52015-03-06 11:47:39 -080066 }
67}
68
Dmitry Torokhov95dd3b32010-03-19 22:18:15 -070069static int wacom_penpartner_irq(struct wacom_wac *wacom)
Ping Cheng3bea7332006-07-13 18:01:36 -070070{
71 unsigned char *data = wacom->data;
Jason Gerecke2a6cdbd2015-06-15 18:01:45 -070072 struct input_dev *input = wacom->pen_input;
Ping Cheng3bea7332006-07-13 18:01:36 -070073
74 switch (data[0]) {
Dmitry Torokhov73a97f42010-03-19 22:18:15 -070075 case 1:
76 if (data[5] & 0x80) {
77 wacom->tool[0] = (data[5] & 0x20) ? BTN_TOOL_RUBBER : BTN_TOOL_PEN;
78 wacom->id[0] = (data[5] & 0x20) ? ERASER_DEVICE_ID : STYLUS_DEVICE_ID;
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -070079 input_report_key(input, wacom->tool[0], 1);
80 input_report_abs(input, ABS_MISC, wacom->id[0]); /* report tool id */
Dmitry Torokhov252f7762010-03-19 22:33:38 -070081 input_report_abs(input, ABS_X, get_unaligned_le16(&data[1]));
82 input_report_abs(input, ABS_Y, get_unaligned_le16(&data[3]));
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -070083 input_report_abs(input, ABS_PRESSURE, (signed char)data[6] + 127);
84 input_report_key(input, BTN_TOUCH, ((signed char)data[6] > -127));
85 input_report_key(input, BTN_STYLUS, (data[5] & 0x40));
Dmitry Torokhov73a97f42010-03-19 22:18:15 -070086 } else {
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -070087 input_report_key(input, wacom->tool[0], 0);
88 input_report_abs(input, ABS_MISC, 0); /* report tool id */
89 input_report_abs(input, ABS_PRESSURE, -1);
90 input_report_key(input, BTN_TOUCH, 0);
Dmitry Torokhov73a97f42010-03-19 22:18:15 -070091 }
92 break;
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -070093
Dmitry Torokhov73a97f42010-03-19 22:18:15 -070094 case 2:
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -070095 input_report_key(input, BTN_TOOL_PEN, 1);
96 input_report_abs(input, ABS_MISC, STYLUS_DEVICE_ID); /* report tool id */
Dmitry Torokhov252f7762010-03-19 22:33:38 -070097 input_report_abs(input, ABS_X, get_unaligned_le16(&data[1]));
98 input_report_abs(input, ABS_Y, get_unaligned_le16(&data[3]));
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -070099 input_report_abs(input, ABS_PRESSURE, (signed char)data[6] + 127);
100 input_report_key(input, BTN_TOUCH, ((signed char)data[6] > -80) && !(data[5] & 0x20));
101 input_report_key(input, BTN_STYLUS, (data[5] & 0x40));
Dmitry Torokhov73a97f42010-03-19 22:18:15 -0700102 break;
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700103
Dmitry Torokhov73a97f42010-03-19 22:18:15 -0700104 default:
Dmitry Torokhoveb71d1b2012-05-02 00:13:38 -0700105 dev_dbg(input->dev.parent,
106 "%s: received unknown report #%d\n", __func__, data[0]);
Dmitry Torokhov73a97f42010-03-19 22:18:15 -0700107 return 0;
Ping Cheng3bea7332006-07-13 18:01:36 -0700108 }
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700109
Ping Cheng3bea7332006-07-13 18:01:36 -0700110 return 1;
111}
112
Dmitry Torokhov95dd3b32010-03-19 22:18:15 -0700113static int wacom_pl_irq(struct wacom_wac *wacom)
Ping Cheng3bea7332006-07-13 18:01:36 -0700114{
Jason Childse33da8a2010-02-17 22:38:31 -0800115 struct wacom_features *features = &wacom->features;
Ping Cheng3bea7332006-07-13 18:01:36 -0700116 unsigned char *data = wacom->data;
Jason Gerecke2a6cdbd2015-06-15 18:01:45 -0700117 struct input_dev *input = wacom->pen_input;
Ping Chenge34b9d22008-05-05 11:36:41 -0400118 int prox, pressure;
Ping Cheng3bea7332006-07-13 18:01:36 -0700119
Ping Chengcad74702009-12-15 00:35:25 -0800120 if (data[0] != WACOM_REPORT_PENABLED) {
Dmitry Torokhoveb71d1b2012-05-02 00:13:38 -0700121 dev_dbg(input->dev.parent,
122 "%s: received unknown report #%d\n", __func__, data[0]);
Ping Cheng3bea7332006-07-13 18:01:36 -0700123 return 0;
124 }
125
126 prox = data[1] & 0x40;
127
Jason Gerecke025bcc12015-08-03 10:18:10 -0700128 if (!wacom->id[0]) {
129 if ((data[0] & 0x10) || (data[4] & 0x20)) {
130 wacom->tool[0] = BTN_TOOL_RUBBER;
131 wacom->id[0] = ERASER_DEVICE_ID;
Ping Cheng3bea7332006-07-13 18:01:36 -0700132 }
Jason Gerecke025bcc12015-08-03 10:18:10 -0700133 else {
134 wacom->tool[0] = BTN_TOOL_PEN;
Ping Chenge34b9d22008-05-05 11:36:41 -0400135 wacom->id[0] = STYLUS_DEVICE_ID;
Ping Cheng3bea7332006-07-13 18:01:36 -0700136 }
Ping Cheng3bea7332006-07-13 18:01:36 -0700137 }
138
Jason Gerecke025bcc12015-08-03 10:18:10 -0700139 /* If the eraser is in prox, STYLUS2 is always set. If we
140 * mis-detected the type and notice that STYLUS2 isn't set
141 * then force the eraser out of prox and let the pen in.
142 */
143 if (wacom->tool[0] == BTN_TOOL_RUBBER && !(data[4] & 0x20)) {
144 input_report_key(input, BTN_TOOL_RUBBER, 0);
145 input_report_abs(input, ABS_MISC, 0);
146 input_sync(input);
147 wacom->tool[0] = BTN_TOOL_PEN;
148 wacom->id[0] = STYLUS_DEVICE_ID;
149 }
150
151 pressure = (signed char)((data[7] << 1) | ((data[4] >> 2) & 1));
152 if (features->pressure_max > 255)
153 pressure = (pressure << 1) | ((data[4] >> 6) & 1);
154 pressure += (features->pressure_max + 1) / 2;
155
156 input_report_abs(input, ABS_X, data[3] | (data[2] << 7) | ((data[1] & 0x03) << 14));
157 input_report_abs(input, ABS_Y, data[6] | (data[5] << 7) | ((data[4] & 0x03) << 14));
158 input_report_abs(input, ABS_PRESSURE, pressure);
159
160 input_report_key(input, BTN_TOUCH, data[4] & 0x08);
161 input_report_key(input, BTN_STYLUS, data[4] & 0x10);
162 /* Only allow the stylus2 button to be reported for the pen tool. */
163 input_report_key(input, BTN_STYLUS2, (wacom->tool[0] == BTN_TOOL_PEN) && (data[4] & 0x20));
164
165 if (!prox)
166 wacom->id[0] = 0;
167 input_report_key(input, wacom->tool[0], prox);
168 input_report_abs(input, ABS_MISC, wacom->id[0]);
Ping Cheng3bea7332006-07-13 18:01:36 -0700169 return 1;
170}
171
Dmitry Torokhov95dd3b32010-03-19 22:18:15 -0700172static int wacom_ptu_irq(struct wacom_wac *wacom)
Ping Cheng3bea7332006-07-13 18:01:36 -0700173{
174 unsigned char *data = wacom->data;
Jason Gerecke2a6cdbd2015-06-15 18:01:45 -0700175 struct input_dev *input = wacom->pen_input;
Ping Cheng3bea7332006-07-13 18:01:36 -0700176
Ping Chengcad74702009-12-15 00:35:25 -0800177 if (data[0] != WACOM_REPORT_PENABLED) {
Dmitry Torokhoveb71d1b2012-05-02 00:13:38 -0700178 dev_dbg(input->dev.parent,
179 "%s: received unknown report #%d\n", __func__, data[0]);
Ping Cheng3bea7332006-07-13 18:01:36 -0700180 return 0;
181 }
182
Ping Cheng3bea7332006-07-13 18:01:36 -0700183 if (data[1] & 0x04) {
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700184 input_report_key(input, BTN_TOOL_RUBBER, data[1] & 0x20);
185 input_report_key(input, BTN_TOUCH, data[1] & 0x08);
Ping Chenge34b9d22008-05-05 11:36:41 -0400186 wacom->id[0] = ERASER_DEVICE_ID;
Ping Cheng3bea7332006-07-13 18:01:36 -0700187 } else {
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700188 input_report_key(input, BTN_TOOL_PEN, data[1] & 0x20);
189 input_report_key(input, BTN_TOUCH, data[1] & 0x01);
Ping Chenge34b9d22008-05-05 11:36:41 -0400190 wacom->id[0] = STYLUS_DEVICE_ID;
Ping Cheng3bea7332006-07-13 18:01:36 -0700191 }
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700192 input_report_abs(input, ABS_MISC, wacom->id[0]); /* report tool id */
Dmitry Torokhov252f7762010-03-19 22:33:38 -0700193 input_report_abs(input, ABS_X, le16_to_cpup((__le16 *)&data[2]));
194 input_report_abs(input, ABS_Y, le16_to_cpup((__le16 *)&data[4]));
195 input_report_abs(input, ABS_PRESSURE, le16_to_cpup((__le16 *)&data[6]));
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700196 input_report_key(input, BTN_STYLUS, data[1] & 0x02);
197 input_report_key(input, BTN_STYLUS2, data[1] & 0x10);
Ping Cheng3bea7332006-07-13 18:01:36 -0700198 return 1;
199}
200
Ping Chengc8f2edc2010-06-28 01:10:51 -0700201static int wacom_dtu_irq(struct wacom_wac *wacom)
202{
Jason Gerecke74b63412014-04-19 13:50:22 -0700203 unsigned char *data = wacom->data;
Jason Gerecke2a6cdbd2015-06-15 18:01:45 -0700204 struct input_dev *input = wacom->pen_input;
Jason Gerecke74b63412014-04-19 13:50:22 -0700205 int prox = data[1] & 0x20;
Ping Chengc8f2edc2010-06-28 01:10:51 -0700206
Dmitry Torokhoveb71d1b2012-05-02 00:13:38 -0700207 dev_dbg(input->dev.parent,
208 "%s: received report #%d", __func__, data[0]);
Ping Chengc8f2edc2010-06-28 01:10:51 -0700209
210 if (prox) {
211 /* Going into proximity select tool */
212 wacom->tool[0] = (data[1] & 0x0c) ? BTN_TOOL_RUBBER : BTN_TOOL_PEN;
213 if (wacom->tool[0] == BTN_TOOL_PEN)
214 wacom->id[0] = STYLUS_DEVICE_ID;
215 else
216 wacom->id[0] = ERASER_DEVICE_ID;
217 }
218 input_report_key(input, BTN_STYLUS, data[1] & 0x02);
219 input_report_key(input, BTN_STYLUS2, data[1] & 0x10);
220 input_report_abs(input, ABS_X, le16_to_cpup((__le16 *)&data[2]));
221 input_report_abs(input, ABS_Y, le16_to_cpup((__le16 *)&data[4]));
Jason Gerecke74b63412014-04-19 13:50:22 -0700222 input_report_abs(input, ABS_PRESSURE, ((data[7] & 0x01) << 8) | data[6]);
Ping Chengc8f2edc2010-06-28 01:10:51 -0700223 input_report_key(input, BTN_TOUCH, data[1] & 0x05);
224 if (!prox) /* out-prox */
225 wacom->id[0] = 0;
226 input_report_key(input, wacom->tool[0], prox);
227 input_report_abs(input, ABS_MISC, wacom->id[0]);
228 return 1;
229}
230
Ping Cheng497ab1f2014-01-20 20:18:04 -0800231static int wacom_dtus_irq(struct wacom_wac *wacom)
232{
233 char *data = wacom->data;
Jason Gerecke2a6cdbd2015-06-15 18:01:45 -0700234 struct input_dev *input = wacom->pen_input;
Ping Cheng497ab1f2014-01-20 20:18:04 -0800235 unsigned short prox, pressure = 0;
236
237 if (data[0] != WACOM_REPORT_DTUS && data[0] != WACOM_REPORT_DTUSPAD) {
238 dev_dbg(input->dev.parent,
239 "%s: received unknown report #%d", __func__, data[0]);
240 return 0;
241 } else if (data[0] == WACOM_REPORT_DTUSPAD) {
Benjamin Tissoires422b0312014-07-24 12:50:39 -0700242 input = wacom->pad_input;
Ping Cheng497ab1f2014-01-20 20:18:04 -0800243 input_report_key(input, BTN_0, (data[1] & 0x01));
244 input_report_key(input, BTN_1, (data[1] & 0x02));
245 input_report_key(input, BTN_2, (data[1] & 0x04));
246 input_report_key(input, BTN_3, (data[1] & 0x08));
247 input_report_abs(input, ABS_MISC,
248 data[1] & 0x0f ? PAD_DEVICE_ID : 0);
Ping Cheng497ab1f2014-01-20 20:18:04 -0800249 return 1;
250 } else {
251 prox = data[1] & 0x80;
252 if (prox) {
253 switch ((data[1] >> 3) & 3) {
254 case 1: /* Rubber */
255 wacom->tool[0] = BTN_TOOL_RUBBER;
256 wacom->id[0] = ERASER_DEVICE_ID;
257 break;
258
259 case 2: /* Pen */
260 wacom->tool[0] = BTN_TOOL_PEN;
261 wacom->id[0] = STYLUS_DEVICE_ID;
262 break;
263 }
264 }
265
266 input_report_key(input, BTN_STYLUS, data[1] & 0x20);
267 input_report_key(input, BTN_STYLUS2, data[1] & 0x40);
268 input_report_abs(input, ABS_X, get_unaligned_be16(&data[3]));
269 input_report_abs(input, ABS_Y, get_unaligned_be16(&data[5]));
270 pressure = ((data[1] & 0x03) << 8) | (data[2] & 0xff);
271 input_report_abs(input, ABS_PRESSURE, pressure);
272 input_report_key(input, BTN_TOUCH, pressure > 10);
273
274 if (!prox) /* out-prox */
275 wacom->id[0] = 0;
276 input_report_key(input, wacom->tool[0], prox);
277 input_report_abs(input, ABS_MISC, wacom->id[0]);
Ping Cheng497ab1f2014-01-20 20:18:04 -0800278 return 1;
279 }
280}
281
Dmitry Torokhov95dd3b32010-03-19 22:18:15 -0700282static int wacom_graphire_irq(struct wacom_wac *wacom)
Ping Cheng3bea7332006-07-13 18:01:36 -0700283{
Jason Childse33da8a2010-02-17 22:38:31 -0800284 struct wacom_features *features = &wacom->features;
Ping Cheng3bea7332006-07-13 18:01:36 -0700285 unsigned char *data = wacom->data;
Jason Gerecke2a6cdbd2015-06-15 18:01:45 -0700286 struct input_dev *input = wacom->pen_input;
Benjamin Tissoires38138102014-07-24 12:51:03 -0700287 struct input_dev *pad_input = wacom->pad_input;
Benjamin Tissoires387142b2014-08-06 13:52:56 -0700288 int battery_capacity, ps_connected;
Dmitry Torokhov252f7762010-03-19 22:33:38 -0700289 int prox;
Ping Cheng3b57ca02010-03-04 21:50:59 -0800290 int rw = 0;
291 int retval = 0;
Ping Cheng3bea7332006-07-13 18:01:36 -0700292
Benjamin Tissoires387142b2014-08-06 13:52:56 -0700293 if (features->type == GRAPHIRE_BT) {
294 if (data[0] != WACOM_REPORT_PENABLED_BT) {
295 dev_dbg(input->dev.parent,
296 "%s: received unknown report #%d\n", __func__,
297 data[0]);
298 goto exit;
299 }
300 } else if (data[0] != WACOM_REPORT_PENABLED) {
Dmitry Torokhoveb71d1b2012-05-02 00:13:38 -0700301 dev_dbg(input->dev.parent,
302 "%s: received unknown report #%d\n", __func__, data[0]);
Ping Cheng3b57ca02010-03-04 21:50:59 -0800303 goto exit;
Ping Cheng3bea7332006-07-13 18:01:36 -0700304 }
305
Ping Cheng3b57ca02010-03-04 21:50:59 -0800306 prox = data[1] & 0x80;
307 if (prox || wacom->id[0]) {
308 if (prox) {
309 switch ((data[1] >> 5) & 3) {
Ping Cheng3bea7332006-07-13 18:01:36 -0700310
311 case 0: /* Pen */
312 wacom->tool[0] = BTN_TOOL_PEN;
Ping Chenge34b9d22008-05-05 11:36:41 -0400313 wacom->id[0] = STYLUS_DEVICE_ID;
Ping Cheng3bea7332006-07-13 18:01:36 -0700314 break;
315
316 case 1: /* Rubber */
317 wacom->tool[0] = BTN_TOOL_RUBBER;
Ping Chenge34b9d22008-05-05 11:36:41 -0400318 wacom->id[0] = ERASER_DEVICE_ID;
Ping Cheng3bea7332006-07-13 18:01:36 -0700319 break;
320
321 case 2: /* Mouse with wheel */
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700322 input_report_key(input, BTN_MIDDLE, data[1] & 0x04);
Ping Cheng3bea7332006-07-13 18:01:36 -0700323 /* fall through */
324
325 case 3: /* Mouse without wheel */
326 wacom->tool[0] = BTN_TOOL_MOUSE;
Ping Chenge34b9d22008-05-05 11:36:41 -0400327 wacom->id[0] = CURSOR_DEVICE_ID;
Ping Cheng3bea7332006-07-13 18:01:36 -0700328 break;
Ping Cheng3b57ca02010-03-04 21:50:59 -0800329 }
Ping Cheng3bea7332006-07-13 18:01:36 -0700330 }
Dmitry Torokhov252f7762010-03-19 22:33:38 -0700331 input_report_abs(input, ABS_X, le16_to_cpup((__le16 *)&data[2]));
332 input_report_abs(input, ABS_Y, le16_to_cpup((__le16 *)&data[4]));
Ping Cheng3bea7332006-07-13 18:01:36 -0700333 if (wacom->tool[0] != BTN_TOOL_MOUSE) {
Benjamin Tissoires387142b2014-08-06 13:52:56 -0700334 if (features->type == GRAPHIRE_BT)
335 input_report_abs(input, ABS_PRESSURE, data[6] |
336 (((__u16) (data[1] & 0x08)) << 5));
337 else
338 input_report_abs(input, ABS_PRESSURE, data[6] |
339 ((data[7] & 0x03) << 8));
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700340 input_report_key(input, BTN_TOUCH, data[1] & 0x01);
341 input_report_key(input, BTN_STYLUS, data[1] & 0x02);
342 input_report_key(input, BTN_STYLUS2, data[1] & 0x04);
Dmitry Torokhovafb567e2010-04-13 23:08:58 -0700343 } else {
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700344 input_report_key(input, BTN_LEFT, data[1] & 0x01);
345 input_report_key(input, BTN_RIGHT, data[1] & 0x02);
Ping Cheng3b57ca02010-03-04 21:50:59 -0800346 if (features->type == WACOM_G4 ||
347 features->type == WACOM_MO) {
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700348 input_report_abs(input, ABS_DISTANCE, data[6] & 0x3f);
Mike Autyd9f66c12010-08-28 20:35:17 -0700349 rw = (data[7] & 0x04) - (data[7] & 0x03);
Benjamin Tissoires387142b2014-08-06 13:52:56 -0700350 } else if (features->type == GRAPHIRE_BT) {
351 /* Compute distance between mouse and tablet */
352 rw = 44 - (data[6] >> 2);
353 rw = clamp_val(rw, 0, 31);
354 input_report_abs(input, ABS_DISTANCE, rw);
355 if (((data[1] >> 5) & 3) == 2) {
356 /* Mouse with wheel */
357 input_report_key(input, BTN_MIDDLE,
358 data[1] & 0x04);
359 rw = (data[6] & 0x01) ? -1 :
360 (data[6] & 0x02) ? 1 : 0;
361 } else {
362 rw = 0;
363 }
Ping Cheng3b57ca02010-03-04 21:50:59 -0800364 } else {
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700365 input_report_abs(input, ABS_DISTANCE, data[7] & 0x3f);
Mike Autyd9f66c12010-08-28 20:35:17 -0700366 rw = -(signed char)data[6];
Ping Cheng3b57ca02010-03-04 21:50:59 -0800367 }
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700368 input_report_rel(input, REL_WHEEL, rw);
Dmitry Torokhovafb567e2010-04-13 23:08:58 -0700369 }
Ping Cheng3b57ca02010-03-04 21:50:59 -0800370
371 if (!prox)
372 wacom->id[0] = 0;
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700373 input_report_abs(input, ABS_MISC, wacom->id[0]); /* report tool id */
374 input_report_key(input, wacom->tool[0], prox);
375 input_sync(input); /* sync last event */
Ping Cheng80d4e8e2007-02-23 12:22:48 -0800376 }
Ping Cheng3bea7332006-07-13 18:01:36 -0700377
378 /* send pad data */
Jason Childse33da8a2010-02-17 22:38:31 -0800379 switch (features->type) {
Dmitry Torokhov73a97f42010-03-19 22:18:15 -0700380 case WACOM_G4:
Ping Cheng3b57ca02010-03-04 21:50:59 -0800381 prox = data[7] & 0xf8;
382 if (prox || wacom->id[1]) {
Ping Chenge34b9d22008-05-05 11:36:41 -0400383 wacom->id[1] = PAD_DEVICE_ID;
Benjamin Tissoires38138102014-07-24 12:51:03 -0700384 input_report_key(pad_input, BTN_BACK, (data[7] & 0x40));
385 input_report_key(pad_input, BTN_FORWARD, (data[7] & 0x80));
Ping Cheng3bea7332006-07-13 18:01:36 -0700386 rw = ((data[7] & 0x18) >> 3) - ((data[7] & 0x20) >> 3);
Benjamin Tissoires38138102014-07-24 12:51:03 -0700387 input_report_rel(pad_input, REL_WHEEL, rw);
Ping Cheng3b57ca02010-03-04 21:50:59 -0800388 if (!prox)
389 wacom->id[1] = 0;
Benjamin Tissoires38138102014-07-24 12:51:03 -0700390 input_report_abs(pad_input, ABS_MISC, wacom->id[1]);
Ping Chengab687b12010-04-05 23:07:41 -0700391 retval = 1;
Ping Cheng3bea7332006-07-13 18:01:36 -0700392 }
Ping Cheng7ecfbfd2007-06-14 23:32:48 -0400393 break;
Dmitry Torokhov73a97f42010-03-19 22:18:15 -0700394
395 case WACOM_MO:
Ping Cheng3b57ca02010-03-04 21:50:59 -0800396 prox = (data[7] & 0xf8) || data[8];
397 if (prox || wacom->id[1]) {
Ping Chenge34b9d22008-05-05 11:36:41 -0400398 wacom->id[1] = PAD_DEVICE_ID;
Benjamin Tissoires38138102014-07-24 12:51:03 -0700399 input_report_key(pad_input, BTN_BACK, (data[7] & 0x08));
400 input_report_key(pad_input, BTN_LEFT, (data[7] & 0x20));
401 input_report_key(pad_input, BTN_FORWARD, (data[7] & 0x10));
402 input_report_key(pad_input, BTN_RIGHT, (data[7] & 0x40));
403 input_report_abs(pad_input, ABS_WHEEL, (data[8] & 0x7f));
Ping Cheng3b57ca02010-03-04 21:50:59 -0800404 if (!prox)
405 wacom->id[1] = 0;
Benjamin Tissoires38138102014-07-24 12:51:03 -0700406 input_report_abs(pad_input, ABS_MISC, wacom->id[1]);
Ping Cheng84460012011-07-06 18:05:43 -0700407 retval = 1;
Ping Cheng7ecfbfd2007-06-14 23:32:48 -0400408 }
409 break;
Benjamin Tissoires387142b2014-08-06 13:52:56 -0700410 case GRAPHIRE_BT:
411 prox = data[7] & 0x03;
412 if (prox || wacom->id[1]) {
413 wacom->id[1] = PAD_DEVICE_ID;
414 input_report_key(pad_input, BTN_0, (data[7] & 0x02));
415 input_report_key(pad_input, BTN_1, (data[7] & 0x01));
416 if (!prox)
417 wacom->id[1] = 0;
418 input_report_abs(pad_input, ABS_MISC, wacom->id[1]);
419 retval = 1;
420 }
421 break;
422 }
423
424 /* Store current battery capacity and power supply state */
425 if (features->type == GRAPHIRE_BT) {
426 rw = (data[7] >> 2 & 0x07);
427 battery_capacity = batcap_gr[rw];
428 ps_connected = rw == 7;
Jason Gerecke953f2c52015-03-06 11:47:39 -0800429 wacom_notify_battery(wacom, battery_capacity, ps_connected,
Jason Gerecke71fa6412015-03-11 10:25:41 -0700430 1, ps_connected);
Ping Cheng3bea7332006-07-13 18:01:36 -0700431 }
Ping Cheng3b57ca02010-03-04 21:50:59 -0800432exit:
433 return retval;
Ping Cheng3bea7332006-07-13 18:01:36 -0700434}
435
Benjamin Tissoires5fcad162015-03-05 17:36:54 -0500436static void wacom_intuos_schedule_prox_event(struct wacom_wac *wacom_wac)
437{
438 struct wacom *wacom = container_of(wacom_wac, struct wacom, wacom_wac);
439 struct hid_report *r;
440 struct hid_report_enum *re;
441
442 re = &(wacom->hdev->report_enum[HID_FEATURE_REPORT]);
443 r = re->report_id_hash[WACOM_REPORT_INTUOSREAD];
444 if (r) {
445 hid_hw_request(wacom->hdev, r, HID_REQ_GET_REPORT);
446 }
447}
448
Jason Gereckefb013a02015-11-30 17:13:46 -0800449static int wacom_intuos_pad(struct wacom_wac *wacom)
450{
451 struct wacom_features *features = &wacom->features;
452 unsigned char *data = wacom->data;
453 struct input_dev *input = wacom->pad_input;
454
455 /* pad packets. Works as a second tool and is always in prox */
456 if (!(data[0] == WACOM_REPORT_INTUOSPAD || data[0] == WACOM_REPORT_INTUOS5PAD ||
457 data[0] == WACOM_REPORT_CINTIQPAD))
458 return 0;
459
460 if (features->type >= INTUOS4S && features->type <= INTUOS4L) {
461 input_report_key(input, BTN_0, (data[2] & 0x01));
462 input_report_key(input, BTN_1, (data[3] & 0x01));
463 input_report_key(input, BTN_2, (data[3] & 0x02));
464 input_report_key(input, BTN_3, (data[3] & 0x04));
465 input_report_key(input, BTN_4, (data[3] & 0x08));
466 input_report_key(input, BTN_5, (data[3] & 0x10));
467 input_report_key(input, BTN_6, (data[3] & 0x20));
468 if (data[1] & 0x80) {
469 input_report_abs(input, ABS_WHEEL, (data[1] & 0x7f));
470 } else {
471 /* Out of proximity, clear wheel value. */
472 input_report_abs(input, ABS_WHEEL, 0);
473 }
474 if (features->type != INTUOS4S) {
475 input_report_key(input, BTN_7, (data[3] & 0x40));
476 input_report_key(input, BTN_8, (data[3] & 0x80));
477 }
478 if (data[1] | (data[2] & 0x01) | data[3]) {
479 input_report_abs(input, ABS_MISC, PAD_DEVICE_ID);
480 } else {
481 input_report_abs(input, ABS_MISC, 0);
482 }
483 } else if (features->type == DTK) {
484 input_report_key(input, BTN_0, (data[6] & 0x01));
485 input_report_key(input, BTN_1, (data[6] & 0x02));
486 input_report_key(input, BTN_2, (data[6] & 0x04));
487 input_report_key(input, BTN_3, (data[6] & 0x08));
488 input_report_key(input, BTN_4, (data[6] & 0x10));
489 input_report_key(input, BTN_5, (data[6] & 0x20));
490 if (data[6] & 0x3f) {
491 input_report_abs(input, ABS_MISC, PAD_DEVICE_ID);
492 } else {
493 input_report_abs(input, ABS_MISC, 0);
494 }
495 } else if (features->type == WACOM_13HD) {
496 input_report_key(input, BTN_0, (data[3] & 0x01));
497 input_report_key(input, BTN_1, (data[4] & 0x01));
498 input_report_key(input, BTN_2, (data[4] & 0x02));
499 input_report_key(input, BTN_3, (data[4] & 0x04));
500 input_report_key(input, BTN_4, (data[4] & 0x08));
501 input_report_key(input, BTN_5, (data[4] & 0x10));
502 input_report_key(input, BTN_6, (data[4] & 0x20));
503 input_report_key(input, BTN_7, (data[4] & 0x40));
504 input_report_key(input, BTN_8, (data[4] & 0x80));
505 if ((data[3] & 0x01) | data[4]) {
506 input_report_abs(input, ABS_MISC, PAD_DEVICE_ID);
507 } else {
508 input_report_abs(input, ABS_MISC, 0);
509 }
510 } else if (features->type == WACOM_24HD) {
511 input_report_key(input, BTN_0, (data[6] & 0x01));
512 input_report_key(input, BTN_1, (data[6] & 0x02));
513 input_report_key(input, BTN_2, (data[6] & 0x04));
514 input_report_key(input, BTN_3, (data[6] & 0x08));
515 input_report_key(input, BTN_4, (data[6] & 0x10));
516 input_report_key(input, BTN_5, (data[6] & 0x20));
517 input_report_key(input, BTN_6, (data[6] & 0x40));
518 input_report_key(input, BTN_7, (data[6] & 0x80));
519 input_report_key(input, BTN_8, (data[8] & 0x01));
520 input_report_key(input, BTN_9, (data[8] & 0x02));
521 input_report_key(input, BTN_A, (data[8] & 0x04));
522 input_report_key(input, BTN_B, (data[8] & 0x08));
523 input_report_key(input, BTN_C, (data[8] & 0x10));
524 input_report_key(input, BTN_X, (data[8] & 0x20));
525 input_report_key(input, BTN_Y, (data[8] & 0x40));
526 input_report_key(input, BTN_Z, (data[8] & 0x80));
527
528 /*
529 * Three "buttons" are available on the 24HD which are
530 * physically implemented as a touchstrip. Each button
531 * is approximately 3 bits wide with a 2 bit spacing.
532 * The raw touchstrip bits are stored at:
533 * ((data[3] & 0x1f) << 8) | data[4])
534 */
535 input_report_key(input, KEY_PROG1, data[4] & 0x07);
536 input_report_key(input, KEY_PROG2, data[4] & 0xE0);
537 input_report_key(input, KEY_PROG3, data[3] & 0x1C);
538
539 if (data[1] & 0x80) {
540 input_report_abs(input, ABS_WHEEL, (data[1] & 0x7f));
541 } else {
542 /* Out of proximity, clear wheel value. */
543 input_report_abs(input, ABS_WHEEL, 0);
544 }
545
546 if (data[2] & 0x80) {
547 input_report_abs(input, ABS_THROTTLE, (data[2] & 0x7f));
548 } else {
549 /* Out of proximity, clear second wheel value. */
550 input_report_abs(input, ABS_THROTTLE, 0);
551 }
552
553 if (data[1] | data[2] | (data[3] & 0x1f) | data[4] | data[6] | data[8]) {
554 input_report_abs(input, ABS_MISC, PAD_DEVICE_ID);
555 } else {
556 input_report_abs(input, ABS_MISC, 0);
557 }
558 } else if (features->type == WACOM_27QHD) {
559 input_report_key(input, KEY_PROG1, data[2] & 0x01);
560 input_report_key(input, KEY_PROG2, data[2] & 0x02);
561 input_report_key(input, KEY_PROG3, data[2] & 0x04);
562
563 input_report_abs(input, ABS_X, be16_to_cpup((__be16 *)&data[4]));
564 input_report_abs(input, ABS_Y, be16_to_cpup((__be16 *)&data[6]));
565 input_report_abs(input, ABS_Z, be16_to_cpup((__be16 *)&data[8]));
566 if ((data[2] & 0x07) | data[4] | data[5] | data[6] | data[7] | data[8] | data[9]) {
567 input_report_abs(input, ABS_MISC, PAD_DEVICE_ID);
568 } else {
569 input_report_abs(input, ABS_MISC, 0);
570 }
571 } else if (features->type == CINTIQ_HYBRID) {
572 /*
573 * Do not send hardware buttons under Android. They
574 * are already sent to the system through GPIO (and
575 * have different meaning).
576 */
577 input_report_key(input, BTN_1, (data[4] & 0x01));
578 input_report_key(input, BTN_2, (data[4] & 0x02));
579 input_report_key(input, BTN_3, (data[4] & 0x04));
580 input_report_key(input, BTN_4, (data[4] & 0x08));
581
582 input_report_key(input, BTN_5, (data[4] & 0x10)); /* Right */
583 input_report_key(input, BTN_6, (data[4] & 0x20)); /* Up */
584 input_report_key(input, BTN_7, (data[4] & 0x40)); /* Left */
585 input_report_key(input, BTN_8, (data[4] & 0x80)); /* Down */
586 input_report_key(input, BTN_0, (data[3] & 0x01)); /* Center */
587
588 if (data[4] | (data[3] & 0x01)) {
589 input_report_abs(input, ABS_MISC, PAD_DEVICE_ID);
590 } else {
591 input_report_abs(input, ABS_MISC, 0);
592 }
593
594 } else if (features->type == CINTIQ_COMPANION_2) {
595 input_report_key(input, BTN_1, (data[1] & 0x02));
596 input_report_key(input, BTN_2, (data[2] & 0x01));
597 input_report_key(input, BTN_3, (data[2] & 0x02));
598 input_report_key(input, BTN_4, (data[2] & 0x04));
599 input_report_key(input, BTN_5, (data[2] & 0x08));
600 input_report_key(input, BTN_6, (data[1] & 0x04));
601
602 input_report_key(input, BTN_7, (data[2] & 0x10)); /* Right */
603 input_report_key(input, BTN_8, (data[2] & 0x20)); /* Up */
604 input_report_key(input, BTN_9, (data[2] & 0x40)); /* Left */
605 input_report_key(input, BTN_A, (data[2] & 0x80)); /* Down */
606 input_report_key(input, BTN_0, (data[1] & 0x01)); /* Center */
607
608 if (data[2] | (data[1] & 0x07)) {
609 input_report_abs(input, ABS_MISC, PAD_DEVICE_ID);
610 } else {
611 input_report_abs(input, ABS_MISC, 0);
612 }
613
614 } else if (features->type >= INTUOS5S && features->type <= INTUOSPL) {
615 int i;
616
617 /* Touch ring mode switch has no capacitive sensor */
618 input_report_key(input, BTN_0, (data[3] & 0x01));
619
620 /*
621 * ExpressKeys on Intuos5/Intuos Pro have a capacitive sensor in
622 * addition to the mechanical switch. Switch data is
623 * stored in data[4], capacitive data in data[5].
624 */
625 for (i = 0; i < 8; i++)
626 input_report_key(input, BTN_1 + i, data[4] & (1 << i));
627
628 if (data[2] & 0x80) {
629 input_report_abs(input, ABS_WHEEL, (data[2] & 0x7f));
630 } else {
631 /* Out of proximity, clear wheel value. */
632 input_report_abs(input, ABS_WHEEL, 0);
633 }
634
635 if (data[2] | (data[3] & 0x01) | data[4] | data[5]) {
636 input_report_abs(input, ABS_MISC, PAD_DEVICE_ID);
637 } else {
638 input_report_abs(input, ABS_MISC, 0);
639 }
640 } else {
641 if (features->type == WACOM_21UX2 || features->type == WACOM_22HD) {
642 input_report_key(input, BTN_0, (data[5] & 0x01));
643 input_report_key(input, BTN_1, (data[6] & 0x01));
644 input_report_key(input, BTN_2, (data[6] & 0x02));
645 input_report_key(input, BTN_3, (data[6] & 0x04));
646 input_report_key(input, BTN_4, (data[6] & 0x08));
647 input_report_key(input, BTN_5, (data[6] & 0x10));
648 input_report_key(input, BTN_6, (data[6] & 0x20));
649 input_report_key(input, BTN_7, (data[6] & 0x40));
650 input_report_key(input, BTN_8, (data[6] & 0x80));
651 input_report_key(input, BTN_9, (data[7] & 0x01));
652 input_report_key(input, BTN_A, (data[8] & 0x01));
653 input_report_key(input, BTN_B, (data[8] & 0x02));
654 input_report_key(input, BTN_C, (data[8] & 0x04));
655 input_report_key(input, BTN_X, (data[8] & 0x08));
656 input_report_key(input, BTN_Y, (data[8] & 0x10));
657 input_report_key(input, BTN_Z, (data[8] & 0x20));
658 input_report_key(input, BTN_BASE, (data[8] & 0x40));
659 input_report_key(input, BTN_BASE2, (data[8] & 0x80));
660
661 if (features->type == WACOM_22HD) {
662 input_report_key(input, KEY_PROG1, data[9] & 0x01);
663 input_report_key(input, KEY_PROG2, data[9] & 0x02);
664 input_report_key(input, KEY_PROG3, data[9] & 0x04);
665 }
666 } else {
667 input_report_key(input, BTN_0, (data[5] & 0x01));
668 input_report_key(input, BTN_1, (data[5] & 0x02));
669 input_report_key(input, BTN_2, (data[5] & 0x04));
670 input_report_key(input, BTN_3, (data[5] & 0x08));
671 input_report_key(input, BTN_4, (data[6] & 0x01));
672 input_report_key(input, BTN_5, (data[6] & 0x02));
673 input_report_key(input, BTN_6, (data[6] & 0x04));
674 input_report_key(input, BTN_7, (data[6] & 0x08));
675 input_report_key(input, BTN_8, (data[5] & 0x10));
676 input_report_key(input, BTN_9, (data[6] & 0x10));
677 }
678 input_report_abs(input, ABS_RX, ((data[1] & 0x1f) << 8) | data[2]);
679 input_report_abs(input, ABS_RY, ((data[3] & 0x1f) << 8) | data[4]);
680
681 if ((data[5] & 0x1f) | data[6] | (data[1] & 0x1f) |
682 data[2] | (data[3] & 0x1f) | data[4] | data[8] |
683 (data[7] & 0x01)) {
684 input_report_abs(input, ABS_MISC, PAD_DEVICE_ID);
685 } else {
686 input_report_abs(input, ABS_MISC, 0);
687 }
688 }
689 return 1;
690}
691
Dmitry Torokhov95dd3b32010-03-19 22:18:15 -0700692static int wacom_intuos_inout(struct wacom_wac *wacom)
Ping Cheng3bea7332006-07-13 18:01:36 -0700693{
Jason Childse33da8a2010-02-17 22:38:31 -0800694 struct wacom_features *features = &wacom->features;
Ping Cheng3bea7332006-07-13 18:01:36 -0700695 unsigned char *data = wacom->data;
Jason Gerecke2a6cdbd2015-06-15 18:01:45 -0700696 struct input_dev *input = wacom->pen_input;
Ping Cheng6f660f12009-05-08 18:30:33 -0700697 int idx = 0;
Ping Cheng3bea7332006-07-13 18:01:36 -0700698
699 /* tool number */
Jason Childse33da8a2010-02-17 22:38:31 -0800700 if (features->type == INTUOS)
Ping Cheng6f660f12009-05-08 18:30:33 -0700701 idx = data[1] & 0x01;
Ping Cheng3bea7332006-07-13 18:01:36 -0700702
703 /* Enter report */
704 if ((data[1] & 0xfc) == 0xc0) {
705 /* serial number of the tool */
706 wacom->serial[idx] = ((data[3] & 0x0f) << 28) +
707 (data[4] << 20) + (data[5] << 12) +
708 (data[6] << 4) + (data[7] >> 4);
709
Ping Cheng493630b2010-06-22 11:21:34 -0700710 wacom->id[idx] = (data[2] << 4) | (data[3] >> 4) |
711 ((data[7] & 0x0f) << 20) | ((data[8] & 0xf0) << 12);
Dmitry Torokhov73a97f42010-03-19 22:18:15 -0700712
Ping Chengf0aacea2013-05-05 19:59:05 -0700713 switch (wacom->id[idx]) {
Dmitry Torokhov73a97f42010-03-19 22:18:15 -0700714 case 0x812: /* Inking pen */
715 case 0x801: /* Intuos3 Inking pen */
Ping Chengf0aacea2013-05-05 19:59:05 -0700716 case 0x120802: /* Intuos4/5 Inking Pen */
Dmitry Torokhov73a97f42010-03-19 22:18:15 -0700717 case 0x012:
718 wacom->tool[idx] = BTN_TOOL_PENCIL;
719 break;
720
721 case 0x822: /* Pen */
722 case 0x842:
723 case 0x852:
724 case 0x823: /* Intuos3 Grip Pen */
725 case 0x813: /* Intuos3 Classic Pen */
726 case 0x885: /* Intuos3 Marker Pen */
Ping Chengf0aacea2013-05-05 19:59:05 -0700727 case 0x802: /* Intuos4/5 13HD/24HD General Pen */
728 case 0x804: /* Intuos4/5 13HD/24HD Marker Pen */
Dmitry Torokhov73a97f42010-03-19 22:18:15 -0700729 case 0x022:
Ping Chengf0aacea2013-05-05 19:59:05 -0700730 case 0x100804: /* Intuos4/5 13HD/24HD Art Pen */
731 case 0x140802: /* Intuos4/5 13HD/24HD Classic Pen */
732 case 0x160802: /* Cintiq 13HD Pro Pen */
Ping Chengc73a1af2013-05-14 23:34:53 -0700733 case 0x180802: /* DTH2242 Pen */
Ping Cheng7d753b02013-06-18 23:14:25 -0700734 case 0x100802: /* Intuos4/5 13HD/24HD General Pen */
Dmitry Torokhov73a97f42010-03-19 22:18:15 -0700735 wacom->tool[idx] = BTN_TOOL_PEN;
736 break;
737
738 case 0x832: /* Stroke pen */
739 case 0x032:
740 wacom->tool[idx] = BTN_TOOL_BRUSH;
741 break;
742
743 case 0x007: /* Mouse 4D and 2D */
744 case 0x09c:
745 case 0x094:
746 case 0x017: /* Intuos3 2D Mouse */
747 case 0x806: /* Intuos4 Mouse */
748 wacom->tool[idx] = BTN_TOOL_MOUSE;
749 break;
750
751 case 0x096: /* Lens cursor */
752 case 0x097: /* Intuos3 Lens cursor */
753 case 0x006: /* Intuos4 Lens cursor */
754 wacom->tool[idx] = BTN_TOOL_LENS;
755 break;
756
757 case 0x82a: /* Eraser */
758 case 0x85a:
759 case 0x91a:
760 case 0xd1a:
761 case 0x0fa:
762 case 0x82b: /* Intuos3 Grip Pen Eraser */
763 case 0x81b: /* Intuos3 Classic Pen Eraser */
764 case 0x91b: /* Intuos3 Airbrush Eraser */
Ping Chengf0aacea2013-05-05 19:59:05 -0700765 case 0x80c: /* Intuos4/5 13HD/24HD Marker Pen Eraser */
766 case 0x80a: /* Intuos4/5 13HD/24HD General Pen Eraser */
767 case 0x90a: /* Intuos4/5 13HD/24HD Airbrush Eraser */
768 case 0x14080a: /* Intuos4/5 13HD/24HD Classic Pen Eraser */
769 case 0x10090a: /* Intuos4/5 13HD/24HD Airbrush Eraser */
770 case 0x10080c: /* Intuos4/5 13HD/24HD Art Pen Eraser */
771 case 0x16080a: /* Cintiq 13HD Pro Pen Eraser */
Ping Chengc73a1af2013-05-14 23:34:53 -0700772 case 0x18080a: /* DTH2242 Eraser */
Ping Cheng7d753b02013-06-18 23:14:25 -0700773 case 0x10080a: /* Intuos4/5 13HD/24HD General Pen Eraser */
Dmitry Torokhov73a97f42010-03-19 22:18:15 -0700774 wacom->tool[idx] = BTN_TOOL_RUBBER;
775 break;
776
777 case 0xd12:
778 case 0x912:
779 case 0x112:
780 case 0x913: /* Intuos3 Airbrush */
Ping Chengf0aacea2013-05-05 19:59:05 -0700781 case 0x902: /* Intuos4/5 13HD/24HD Airbrush */
782 case 0x100902: /* Intuos4/5 13HD/24HD Airbrush */
Dmitry Torokhov73a97f42010-03-19 22:18:15 -0700783 wacom->tool[idx] = BTN_TOOL_AIRBRUSH;
784 break;
785
786 default: /* Unknown tool */
787 wacom->tool[idx] = BTN_TOOL_PEN;
788 break;
Ping Cheng3bea7332006-07-13 18:01:36 -0700789 }
Ping Cheng3bea7332006-07-13 18:01:36 -0700790 return 1;
791 }
792
Ping Cheng373a5352015-01-09 11:04:50 -0800793 /*
794 * don't report events for invalid data
795 */
Ping Cheng3a4b4aa2010-06-03 22:10:21 -0700796 /* older I4 styli don't work with new Cintiqs */
Ping Cheng373a5352015-01-09 11:04:50 -0800797 if ((!((wacom->id[idx] >> 20) & 0x01) &&
798 (features->type == WACOM_21UX2)) ||
799 /* Only large Intuos support Lense Cursor */
800 (wacom->tool[idx] == BTN_TOOL_LENS &&
801 (features->type == INTUOS3 ||
802 features->type == INTUOS3S ||
803 features->type == INTUOS4 ||
804 features->type == INTUOS4S ||
805 features->type == INTUOS5 ||
806 features->type == INTUOS5S ||
807 features->type == INTUOSPM ||
808 features->type == INTUOSPS)) ||
809 /* Cintiq doesn't send data when RDY bit isn't set */
810 (features->type == CINTIQ && !(data[1] & 0x40)))
Ping Cheng3a4b4aa2010-06-03 22:10:21 -0700811 return 1;
812
Ping Chengf3586d22015-03-20 14:57:00 -0700813 wacom->shared->stylus_in_proximity = true;
814 if (wacom->shared->touch_down)
815 return 1;
Ping Cheng486b9082015-02-20 14:25:58 -0800816
Ping Chengb3bd7ef2015-01-09 11:05:13 -0800817 /* in Range while exiting */
818 if (((data[1] & 0xfe) == 0x20) && wacom->reporting_data) {
Jason Gerecke4eb18302013-09-20 09:48:46 -0700819 input_report_key(input, BTN_TOUCH, 0);
820 input_report_abs(input, ABS_PRESSURE, 0);
821 input_report_abs(input, ABS_DISTANCE, wacom->features.distance_max);
Ping Chengb3bd7ef2015-01-09 11:05:13 -0800822 return 2;
Jason Gerecke4eb18302013-09-20 09:48:46 -0700823 }
824
Ping Cheng3bea7332006-07-13 18:01:36 -0700825 /* Exit report */
826 if ((data[1] & 0xfe) == 0x80) {
Ping Chengf3586d22015-03-20 14:57:00 -0700827 wacom->shared->stylus_in_proximity = false;
Ping Chengb3bd7ef2015-01-09 11:05:13 -0800828 wacom->reporting_data = false;
Jason Gereckeae584ca2012-04-03 15:50:40 -0700829
Ping Cheng373a5352015-01-09 11:04:50 -0800830 /* don't report exit if we don't know the ID */
831 if (!wacom->id[idx])
832 return 1;
833
Ping Cheng6f660f12009-05-08 18:30:33 -0700834 /*
835 * Reset all states otherwise we lose the initial states
836 * when in-prox next time
837 */
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700838 input_report_abs(input, ABS_X, 0);
839 input_report_abs(input, ABS_Y, 0);
840 input_report_abs(input, ABS_DISTANCE, 0);
841 input_report_abs(input, ABS_TILT_X, 0);
842 input_report_abs(input, ABS_TILT_Y, 0);
Ping Cheng80d4e8e2007-02-23 12:22:48 -0800843 if (wacom->tool[idx] >= BTN_TOOL_MOUSE) {
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700844 input_report_key(input, BTN_LEFT, 0);
845 input_report_key(input, BTN_MIDDLE, 0);
846 input_report_key(input, BTN_RIGHT, 0);
847 input_report_key(input, BTN_SIDE, 0);
848 input_report_key(input, BTN_EXTRA, 0);
849 input_report_abs(input, ABS_THROTTLE, 0);
850 input_report_abs(input, ABS_RZ, 0);
Ping Cheng7ecfbfd2007-06-14 23:32:48 -0400851 } else {
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700852 input_report_abs(input, ABS_PRESSURE, 0);
853 input_report_key(input, BTN_STYLUS, 0);
854 input_report_key(input, BTN_STYLUS2, 0);
855 input_report_key(input, BTN_TOUCH, 0);
856 input_report_abs(input, ABS_WHEEL, 0);
Jason Childse33da8a2010-02-17 22:38:31 -0800857 if (features->type >= INTUOS3S)
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700858 input_report_abs(input, ABS_Z, 0);
Ping Cheng8d32e3a2006-09-26 13:34:47 -0700859 }
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700860 input_report_key(input, wacom->tool[idx], 0);
861 input_report_abs(input, ABS_MISC, 0); /* reset tool id */
862 input_event(input, EV_MSC, MSC_SERIAL, wacom->serial[idx]);
Ping Cheng6f660f12009-05-08 18:30:33 -0700863 wacom->id[idx] = 0;
Ping Cheng80d4e8e2007-02-23 12:22:48 -0800864 return 2;
Ping Cheng3bea7332006-07-13 18:01:36 -0700865 }
Ping Cheng373a5352015-01-09 11:04:50 -0800866
867 /* don't report other events if we don't know the ID */
Benjamin Tissoires5fcad162015-03-05 17:36:54 -0500868 if (!wacom->id[idx]) {
869 /* but reschedule a read of the current tool */
870 wacom_intuos_schedule_prox_event(wacom);
Ping Cheng373a5352015-01-09 11:04:50 -0800871 return 1;
Benjamin Tissoires5fcad162015-03-05 17:36:54 -0500872 }
Ping Cheng373a5352015-01-09 11:04:50 -0800873
Ping Cheng3bea7332006-07-13 18:01:36 -0700874 return 0;
875}
876
Aaron Skomra72b236d2015-08-20 16:05:17 -0700877static int wacom_remote_irq(struct wacom_wac *wacom_wac, size_t len)
878{
879 unsigned char *data = wacom_wac->data;
880 struct input_dev *input = wacom_wac->pad_input;
881 struct wacom *wacom = container_of(wacom_wac, struct wacom, wacom_wac);
882 struct wacom_features *features = &wacom_wac->features;
883 int bat_charging, bat_percent, touch_ring_mode;
884 __u32 serial;
885 int i;
886
887 if (data[0] != WACOM_REPORT_REMOTE) {
888 dev_dbg(input->dev.parent,
889 "%s: received unknown report #%d", __func__, data[0]);
890 return 0;
891 }
892
893 serial = data[3] + (data[4] << 8) + (data[5] << 16);
894 wacom_wac->id[0] = PAD_DEVICE_ID;
895
896 input_report_key(input, BTN_0, (data[9] & 0x01));
897 input_report_key(input, BTN_1, (data[9] & 0x02));
898 input_report_key(input, BTN_2, (data[9] & 0x04));
899 input_report_key(input, BTN_3, (data[9] & 0x08));
900 input_report_key(input, BTN_4, (data[9] & 0x10));
901 input_report_key(input, BTN_5, (data[9] & 0x20));
902 input_report_key(input, BTN_6, (data[9] & 0x40));
903 input_report_key(input, BTN_7, (data[9] & 0x80));
904
905 input_report_key(input, BTN_8, (data[10] & 0x01));
906 input_report_key(input, BTN_9, (data[10] & 0x02));
907 input_report_key(input, BTN_A, (data[10] & 0x04));
908 input_report_key(input, BTN_B, (data[10] & 0x08));
909 input_report_key(input, BTN_C, (data[10] & 0x10));
910 input_report_key(input, BTN_X, (data[10] & 0x20));
911 input_report_key(input, BTN_Y, (data[10] & 0x40));
912 input_report_key(input, BTN_Z, (data[10] & 0x80));
913
914 input_report_key(input, BTN_BASE, (data[11] & 0x01));
915 input_report_key(input, BTN_BASE2, (data[11] & 0x02));
916
917 if (data[12] & 0x80)
918 input_report_abs(input, ABS_WHEEL, (data[12] & 0x7f));
919 else
920 input_report_abs(input, ABS_WHEEL, 0);
921
922 bat_percent = data[7] & 0x7f;
923 bat_charging = !!(data[7] & 0x80);
924
925 if (data[9] | data[10] | (data[11] & 0x03) | data[12])
926 input_report_abs(input, ABS_MISC, PAD_DEVICE_ID);
927 else
928 input_report_abs(input, ABS_MISC, 0);
929
930 input_event(input, EV_MSC, MSC_SERIAL, serial);
931
932 /*Which mode select (LED light) is currently on?*/
933 touch_ring_mode = (data[11] & 0xC0) >> 6;
934
935 for (i = 0; i < WACOM_MAX_REMOTES; i++) {
936 if (wacom_wac->serial[i] == serial)
937 wacom->led.select[i] = touch_ring_mode;
938 }
939
940 if (!wacom->battery &&
941 !(features->quirks & WACOM_QUIRK_BATTERY)) {
942 features->quirks |= WACOM_QUIRK_BATTERY;
943 INIT_WORK(&wacom->work, wacom_battery_work);
944 wacom_schedule_work(wacom_wac);
945 }
946
947 wacom_notify_battery(wacom_wac, bat_percent, bat_charging, 1,
948 bat_charging);
949
950 return 1;
951}
952
953static int wacom_remote_status_irq(struct wacom_wac *wacom_wac, size_t len)
954{
955 struct wacom *wacom = container_of(wacom_wac, struct wacom, wacom_wac);
956 unsigned char *data = wacom_wac->data;
957 int i;
958
959 if (data[0] != WACOM_REPORT_DEVICE_LIST)
960 return 0;
961
962 for (i = 0; i < WACOM_MAX_REMOTES; i++) {
963 int j = i * 6;
964 int serial = (data[j+6] << 16) + (data[j+5] << 8) + data[j+4];
965 bool connected = data[j+2];
966
967 if (connected) {
968 int k;
969
970 if (wacom_wac->serial[i] == serial)
971 continue;
972
973 if (wacom_wac->serial[i]) {
974 wacom_remote_destroy_attr_group(wacom,
975 wacom_wac->serial[i]);
976 }
977
978 /* A remote can pair more than once with an EKR,
979 * check to make sure this serial isn't already paired.
980 */
981 for (k = 0; k < WACOM_MAX_REMOTES; k++) {
982 if (wacom_wac->serial[k] == serial)
983 break;
984 }
985
986 if (k < WACOM_MAX_REMOTES) {
987 wacom_wac->serial[i] = serial;
988 continue;
989 }
990 wacom_remote_create_attr_group(wacom, serial, i);
991
992 } else if (wacom_wac->serial[i]) {
993 wacom_remote_destroy_attr_group(wacom,
994 wacom_wac->serial[i]);
995 }
996 }
997
998 return 0;
999}
1000
Dmitry Torokhov95dd3b32010-03-19 22:18:15 -07001001static void wacom_intuos_general(struct wacom_wac *wacom)
Ping Cheng3bea7332006-07-13 18:01:36 -07001002{
Jason Childse33da8a2010-02-17 22:38:31 -08001003 struct wacom_features *features = &wacom->features;
Ping Cheng3bea7332006-07-13 18:01:36 -07001004 unsigned char *data = wacom->data;
Jason Gerecke2a6cdbd2015-06-15 18:01:45 -07001005 struct input_dev *input = wacom->pen_input;
Ping Cheng3bea7332006-07-13 18:01:36 -07001006 unsigned int t;
1007
1008 /* general pen packet */
1009 if ((data[1] & 0xb8) == 0xa0) {
1010 t = (data[6] << 2) | ((data[7] >> 6) & 3);
Jason Gerecke8d515fd2015-10-15 10:17:06 -07001011 if (features->pressure_max == 2047) {
Ping Cheng6f660f12009-05-08 18:30:33 -07001012 t = (t << 1) | (data[1] & 1);
Aristeu Rozanskica047fe2010-10-10 14:12:33 -07001013 }
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -07001014 input_report_abs(input, ABS_PRESSURE, t);
Ping Chengeda01da2015-09-23 13:51:15 -07001015 if (features->type != INTUOSHT2) {
1016 input_report_abs(input, ABS_TILT_X,
Jason Gereckeec5fc1c2014-11-18 16:50:08 -08001017 (((data[7] << 1) & 0x7e) | (data[8] >> 7)) - 64);
Ping Chengeda01da2015-09-23 13:51:15 -07001018 input_report_abs(input, ABS_TILT_Y, (data[8] & 0x7f) - 64);
1019 }
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -07001020 input_report_key(input, BTN_STYLUS, data[1] & 2);
1021 input_report_key(input, BTN_STYLUS2, data[1] & 4);
1022 input_report_key(input, BTN_TOUCH, t > 10);
Ping Cheng3bea7332006-07-13 18:01:36 -07001023 }
1024
1025 /* airbrush second packet */
1026 if ((data[1] & 0xbc) == 0xb4) {
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -07001027 input_report_abs(input, ABS_WHEEL,
Ping Cheng3bea7332006-07-13 18:01:36 -07001028 (data[6] << 2) | ((data[7] >> 6) & 3));
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -07001029 input_report_abs(input, ABS_TILT_X,
Jason Gereckeec5fc1c2014-11-18 16:50:08 -08001030 (((data[7] << 1) & 0x7e) | (data[8] >> 7)) - 64);
1031 input_report_abs(input, ABS_TILT_Y, (data[8] & 0x7f) - 64);
Ping Cheng3bea7332006-07-13 18:01:36 -07001032 }
Ping Cheng3bea7332006-07-13 18:01:36 -07001033}
1034
Dmitry Torokhov95dd3b32010-03-19 22:18:15 -07001035static int wacom_intuos_irq(struct wacom_wac *wacom)
Ping Cheng3bea7332006-07-13 18:01:36 -07001036{
Jason Childse33da8a2010-02-17 22:38:31 -08001037 struct wacom_features *features = &wacom->features;
Ping Cheng3bea7332006-07-13 18:01:36 -07001038 unsigned char *data = wacom->data;
Jason Gerecke2a6cdbd2015-06-15 18:01:45 -07001039 struct input_dev *input = wacom->pen_input;
Ping Cheng3bea7332006-07-13 18:01:36 -07001040 unsigned int t;
Ping Cheng6f660f12009-05-08 18:30:33 -07001041 int idx = 0, result;
Ping Cheng3bea7332006-07-13 18:01:36 -07001042
Dmitry Torokhoveb71d1b2012-05-02 00:13:38 -07001043 if (data[0] != WACOM_REPORT_PENABLED &&
1044 data[0] != WACOM_REPORT_INTUOSREAD &&
1045 data[0] != WACOM_REPORT_INTUOSWRITE &&
1046 data[0] != WACOM_REPORT_INTUOSPAD &&
Ping Chengeda01da2015-09-23 13:51:15 -07001047 data[0] != WACOM_REPORT_INTUOS_PEN &&
Ping Cheng500d4162015-01-27 13:30:03 -08001048 data[0] != WACOM_REPORT_CINTIQ &&
1049 data[0] != WACOM_REPORT_CINTIQPAD &&
Dmitry Torokhoveb71d1b2012-05-02 00:13:38 -07001050 data[0] != WACOM_REPORT_INTUOS5PAD) {
1051 dev_dbg(input->dev.parent,
1052 "%s: received unknown report #%d\n", __func__, data[0]);
Ping Cheng3bea7332006-07-13 18:01:36 -07001053 return 0;
1054 }
1055
Ping Cheng3bea7332006-07-13 18:01:36 -07001056 /* tool number */
Jason Childse33da8a2010-02-17 22:38:31 -08001057 if (features->type == INTUOS)
Ping Cheng6f660f12009-05-08 18:30:33 -07001058 idx = data[1] & 0x01;
Ping Cheng3bea7332006-07-13 18:01:36 -07001059
Jason Gereckefb013a02015-11-30 17:13:46 -08001060 /* process pad events */
1061 result = wacom_intuos_pad(wacom);
1062 if (result)
1063 return result;
Ping Cheng3bea7332006-07-13 18:01:36 -07001064
1065 /* process in/out prox events */
Dmitry Torokhov95dd3b32010-03-19 22:18:15 -07001066 result = wacom_intuos_inout(wacom);
Ping Cheng3bea7332006-07-13 18:01:36 -07001067 if (result)
Dmitry Torokhov73a97f42010-03-19 22:18:15 -07001068 return result - 1;
Ping Cheng3bea7332006-07-13 18:01:36 -07001069
Jason Childse33da8a2010-02-17 22:38:31 -08001070 if (features->type >= INTUOS3S) {
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -07001071 input_report_abs(input, ABS_X, (data[2] << 9) | (data[3] << 1) | ((data[9] >> 1) & 1));
1072 input_report_abs(input, ABS_Y, (data[4] << 9) | (data[5] << 1) | (data[9] & 1));
1073 input_report_abs(input, ABS_DISTANCE, ((data[9] >> 2) & 0x3f));
Ping Cheng3bea7332006-07-13 18:01:36 -07001074 } else {
Dmitry Torokhov252f7762010-03-19 22:33:38 -07001075 input_report_abs(input, ABS_X, be16_to_cpup((__be16 *)&data[2]));
1076 input_report_abs(input, ABS_Y, be16_to_cpup((__be16 *)&data[4]));
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -07001077 input_report_abs(input, ABS_DISTANCE, ((data[9] >> 3) & 0x1f));
Ping Cheng3bea7332006-07-13 18:01:36 -07001078 }
1079
1080 /* process general packets */
Dmitry Torokhov95dd3b32010-03-19 22:18:15 -07001081 wacom_intuos_general(wacom);
Ping Cheng3bea7332006-07-13 18:01:36 -07001082
Ping Cheng6f660f12009-05-08 18:30:33 -07001083 /* 4D mouse, 2D mouse, marker pen rotation, tilt mouse, or Lens cursor packets */
1084 if ((data[1] & 0xbc) == 0xa8 || (data[1] & 0xbe) == 0xb0 || (data[1] & 0xbc) == 0xac) {
Ping Cheng3bea7332006-07-13 18:01:36 -07001085
1086 if (data[1] & 0x02) {
1087 /* Rotation packet */
Jason Childse33da8a2010-02-17 22:38:31 -08001088 if (features->type >= INTUOS3S) {
Ping Cheng0e1763f2008-03-13 16:46:46 -04001089 /* I3 marker pen rotation */
Ping Cheng3bea7332006-07-13 18:01:36 -07001090 t = (data[6] << 3) | ((data[7] >> 5) & 7);
1091 t = (data[7] & 0x20) ? ((t > 900) ? ((t-1) / 2 - 1350) :
1092 ((t-1) / 2 + 450)) : (450 - t / 2) ;
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -07001093 input_report_abs(input, ABS_Z, t);
Ping Cheng3bea7332006-07-13 18:01:36 -07001094 } else {
1095 /* 4D mouse rotation packet */
1096 t = (data[6] << 3) | ((data[7] >> 5) & 7);
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -07001097 input_report_abs(input, ABS_RZ, (data[7] & 0x20) ?
Ping Cheng3bea7332006-07-13 18:01:36 -07001098 ((t - 1) / 2) : -t / 2);
1099 }
1100
Jason Childse33da8a2010-02-17 22:38:31 -08001101 } else if (!(data[1] & 0x10) && features->type < INTUOS3S) {
Ping Cheng3bea7332006-07-13 18:01:36 -07001102 /* 4D mouse packet */
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -07001103 input_report_key(input, BTN_LEFT, data[8] & 0x01);
1104 input_report_key(input, BTN_MIDDLE, data[8] & 0x02);
1105 input_report_key(input, BTN_RIGHT, data[8] & 0x04);
Ping Cheng3bea7332006-07-13 18:01:36 -07001106
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -07001107 input_report_key(input, BTN_SIDE, data[8] & 0x20);
1108 input_report_key(input, BTN_EXTRA, data[8] & 0x10);
Ping Cheng3bea7332006-07-13 18:01:36 -07001109 t = (data[6] << 2) | ((data[7] >> 6) & 3);
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -07001110 input_report_abs(input, ABS_THROTTLE, (data[8] & 0x08) ? -t : t);
Ping Cheng3bea7332006-07-13 18:01:36 -07001111
1112 } else if (wacom->tool[idx] == BTN_TOOL_MOUSE) {
Ping Cheng6f660f12009-05-08 18:30:33 -07001113 /* I4 mouse */
Ping Cheng9a35c412013-09-20 09:51:56 -07001114 if (features->type >= INTUOS4S && features->type <= INTUOSPL) {
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -07001115 input_report_key(input, BTN_LEFT, data[6] & 0x01);
1116 input_report_key(input, BTN_MIDDLE, data[6] & 0x02);
1117 input_report_key(input, BTN_RIGHT, data[6] & 0x04);
1118 input_report_rel(input, REL_WHEEL, ((data[7] & 0x80) >> 7)
Ping Cheng6f660f12009-05-08 18:30:33 -07001119 - ((data[7] & 0x40) >> 6));
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -07001120 input_report_key(input, BTN_SIDE, data[6] & 0x08);
1121 input_report_key(input, BTN_EXTRA, data[6] & 0x10);
Ping Cheng6f660f12009-05-08 18:30:33 -07001122
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -07001123 input_report_abs(input, ABS_TILT_X,
Jason Gereckeec5fc1c2014-11-18 16:50:08 -08001124 (((data[7] << 1) & 0x7e) | (data[8] >> 7)) - 64);
1125 input_report_abs(input, ABS_TILT_Y, (data[8] & 0x7f) - 64);
Ping Cheng6f660f12009-05-08 18:30:33 -07001126 } else {
1127 /* 2D mouse packet */
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -07001128 input_report_key(input, BTN_LEFT, data[8] & 0x04);
1129 input_report_key(input, BTN_MIDDLE, data[8] & 0x08);
1130 input_report_key(input, BTN_RIGHT, data[8] & 0x10);
1131 input_report_rel(input, REL_WHEEL, (data[8] & 0x01)
Ping Cheng3bea7332006-07-13 18:01:36 -07001132 - ((data[8] & 0x02) >> 1));
1133
Ping Cheng6f660f12009-05-08 18:30:33 -07001134 /* I3 2D mouse side buttons */
Jason Childse33da8a2010-02-17 22:38:31 -08001135 if (features->type >= INTUOS3S && features->type <= INTUOS3L) {
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -07001136 input_report_key(input, BTN_SIDE, data[8] & 0x40);
1137 input_report_key(input, BTN_EXTRA, data[8] & 0x20);
Ping Cheng6f660f12009-05-08 18:30:33 -07001138 }
Ping Cheng3bea7332006-07-13 18:01:36 -07001139 }
Jason Childse33da8a2010-02-17 22:38:31 -08001140 } else if ((features->type < INTUOS3S || features->type == INTUOS3L ||
Ping Cheng9a35c412013-09-20 09:51:56 -07001141 features->type == INTUOS4L || features->type == INTUOS5L ||
1142 features->type == INTUOSPL) &&
Ping Cheng6f660f12009-05-08 18:30:33 -07001143 wacom->tool[idx] == BTN_TOOL_LENS) {
Ping Cheng3bea7332006-07-13 18:01:36 -07001144 /* Lens cursor packets */
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -07001145 input_report_key(input, BTN_LEFT, data[8] & 0x01);
1146 input_report_key(input, BTN_MIDDLE, data[8] & 0x02);
1147 input_report_key(input, BTN_RIGHT, data[8] & 0x04);
1148 input_report_key(input, BTN_SIDE, data[8] & 0x10);
1149 input_report_key(input, BTN_EXTRA, data[8] & 0x08);
Ping Cheng3bea7332006-07-13 18:01:36 -07001150 }
1151 }
1152
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -07001153 input_report_abs(input, ABS_MISC, wacom->id[idx]); /* report tool id */
1154 input_report_key(input, wacom->tool[idx], 1);
1155 input_event(input, EV_MSC, MSC_SERIAL, wacom->serial[idx]);
Ping Chengb3bd7ef2015-01-09 11:05:13 -08001156 wacom->reporting_data = true;
Ping Cheng3bea7332006-07-13 18:01:36 -07001157 return 1;
1158}
1159
Jason Gereckeb1e42792012-10-21 00:38:04 -07001160static int int_dist(int x1, int y1, int x2, int y2)
1161{
1162 int x = x2 - x1;
1163 int y = y2 - y1;
1164
1165 return int_sqrt(x*x + y*y);
1166}
1167
Benjamin Tissoires81af7e62014-08-06 13:55:56 -07001168static void wacom_intuos_bt_process_data(struct wacom_wac *wacom,
1169 unsigned char *data)
1170{
1171 memcpy(wacom->data, data, 10);
1172 wacom_intuos_irq(wacom);
1173
Jason Gerecke2a6cdbd2015-06-15 18:01:45 -07001174 input_sync(wacom->pen_input);
Benjamin Tissoires81af7e62014-08-06 13:55:56 -07001175 if (wacom->pad_input)
1176 input_sync(wacom->pad_input);
1177}
1178
1179static int wacom_intuos_bt_irq(struct wacom_wac *wacom, size_t len)
1180{
1181 unsigned char data[WACOM_PKGLEN_MAX];
1182 int i = 1;
1183 unsigned power_raw, battery_capacity, bat_charging, ps_connected;
1184
1185 memcpy(data, wacom->data, len);
1186
1187 switch (data[0]) {
1188 case 0x04:
1189 wacom_intuos_bt_process_data(wacom, data + i);
1190 i += 10;
1191 /* fall through */
1192 case 0x03:
1193 wacom_intuos_bt_process_data(wacom, data + i);
1194 i += 10;
1195 wacom_intuos_bt_process_data(wacom, data + i);
1196 i += 10;
1197 power_raw = data[i];
1198 bat_charging = (power_raw & 0x08) ? 1 : 0;
1199 ps_connected = (power_raw & 0x10) ? 1 : 0;
1200 battery_capacity = batcap_i4[power_raw & 0x07];
Jason Gerecke953f2c52015-03-06 11:47:39 -08001201 wacom_notify_battery(wacom, battery_capacity, bat_charging,
Jason Gerecke71fa6412015-03-11 10:25:41 -07001202 battery_capacity || bat_charging,
Jason Gerecke953f2c52015-03-06 11:47:39 -08001203 ps_connected);
Benjamin Tissoires81af7e62014-08-06 13:55:56 -07001204 break;
1205 default:
Jason Gerecke2a6cdbd2015-06-15 18:01:45 -07001206 dev_dbg(wacom->pen_input->dev.parent,
Benjamin Tissoires81af7e62014-08-06 13:55:56 -07001207 "Unknown report: %d,%d size:%zu\n",
1208 data[0], data[1], len);
1209 return 0;
1210 }
1211 return 0;
1212}
1213
Ping Cheng7d059ed2015-03-20 14:57:21 -07001214static int wacom_wac_finger_count_touches(struct wacom_wac *wacom)
1215{
Jason Gerecke2a6cdbd2015-06-15 18:01:45 -07001216 struct input_dev *input = wacom->touch_input;
Ping Cheng7d059ed2015-03-20 14:57:21 -07001217 unsigned touch_max = wacom->features.touch_max;
1218 int count = 0;
1219 int i;
1220
Ping Cheng26ba61f2015-05-19 17:42:02 -07001221 if (!touch_max)
1222 return 0;
1223
Jason Gerecke71b5c472015-04-15 17:22:32 -07001224 if (touch_max == 1)
1225 return test_bit(BTN_TOUCH, input->key) &&
Ping Cheng7d059ed2015-03-20 14:57:21 -07001226 !wacom->shared->stylus_in_proximity;
1227
1228 for (i = 0; i < input->mt->num_slots; i++) {
1229 struct input_mt_slot *ps = &input->mt->slots[i];
1230 int id = input_mt_get_value(ps, ABS_MT_TRACKING_ID);
1231 if (id >= 0)
1232 count++;
1233 }
1234
1235 return count;
1236}
1237
Jason Gereckeb1e42792012-10-21 00:38:04 -07001238static int wacom_24hdt_irq(struct wacom_wac *wacom)
1239{
Jason Gerecke2a6cdbd2015-06-15 18:01:45 -07001240 struct input_dev *input = wacom->touch_input;
Jason Gerecke74b63412014-04-19 13:50:22 -07001241 unsigned char *data = wacom->data;
Jason Gereckeb1e42792012-10-21 00:38:04 -07001242 int i;
Ping Chenge0d41fd2015-02-20 14:27:30 -08001243 int current_num_contacts = data[61];
Jason Gereckeb1e42792012-10-21 00:38:04 -07001244 int contacts_to_send = 0;
Ping Cheng500d4162015-01-27 13:30:03 -08001245 int num_contacts_left = 4; /* maximum contacts per packet */
1246 int byte_per_packet = WACOM_BYTES_PER_24HDT_PACKET;
1247 int y_offset = 2;
1248
1249 if (wacom->features.type == WACOM_27QHDT) {
1250 current_num_contacts = data[63];
1251 num_contacts_left = 10;
1252 byte_per_packet = WACOM_BYTES_PER_QHDTHID_PACKET;
1253 y_offset = 0;
Ping Cheng500d4162015-01-27 13:30:03 -08001254 }
Jason Gereckeb1e42792012-10-21 00:38:04 -07001255
1256 /*
1257 * First packet resets the counter since only the first
1258 * packet in series will have non-zero current_num_contacts.
1259 */
Ping Cheng7d059ed2015-03-20 14:57:21 -07001260 if (current_num_contacts)
Jason Gereckeb1e42792012-10-21 00:38:04 -07001261 wacom->num_contacts_left = current_num_contacts;
1262
Ping Cheng500d4162015-01-27 13:30:03 -08001263 contacts_to_send = min(num_contacts_left, wacom->num_contacts_left);
Jason Gereckeb1e42792012-10-21 00:38:04 -07001264
1265 for (i = 0; i < contacts_to_send; i++) {
Ping Cheng500d4162015-01-27 13:30:03 -08001266 int offset = (byte_per_packet * i) + 1;
Ping Cheng9b61aa82015-01-28 09:42:59 -08001267 bool touch = (data[offset] & 0x1) && !wacom->shared->stylus_in_proximity;
Ping Cheng02295e62013-01-04 23:56:00 -08001268 int slot = input_mt_get_slot_by_key(input, data[offset + 1]);
Jason Gereckeb1e42792012-10-21 00:38:04 -07001269
1270 if (slot < 0)
1271 continue;
1272 input_mt_slot(input, slot);
1273 input_mt_report_slot_state(input, MT_TOOL_FINGER, touch);
1274
1275 if (touch) {
Jason Gereckeedc8e20a2014-05-14 16:53:30 -07001276 int t_x = get_unaligned_le16(&data[offset + 2]);
Ping Cheng500d4162015-01-27 13:30:03 -08001277 int t_y = get_unaligned_le16(&data[offset + 4 + y_offset]);
Jason Gereckeb1e42792012-10-21 00:38:04 -07001278
1279 input_report_abs(input, ABS_MT_POSITION_X, t_x);
1280 input_report_abs(input, ABS_MT_POSITION_Y, t_y);
Ping Cheng500d4162015-01-27 13:30:03 -08001281
1282 if (wacom->features.type != WACOM_27QHDT) {
1283 int c_x = get_unaligned_le16(&data[offset + 4]);
1284 int c_y = get_unaligned_le16(&data[offset + 8]);
1285 int w = get_unaligned_le16(&data[offset + 10]);
1286 int h = get_unaligned_le16(&data[offset + 12]);
1287
1288 input_report_abs(input, ABS_MT_TOUCH_MAJOR, min(w,h));
1289 input_report_abs(input, ABS_MT_WIDTH_MAJOR,
1290 min(w, h) + int_dist(t_x, t_y, c_x, c_y));
1291 input_report_abs(input, ABS_MT_WIDTH_MINOR, min(w, h));
1292 input_report_abs(input, ABS_MT_ORIENTATION, w > h);
1293 }
Jason Gereckeb1e42792012-10-21 00:38:04 -07001294 }
Jason Gereckeb1e42792012-10-21 00:38:04 -07001295 }
Benjamin Tissoires9a1c0012015-02-17 14:19:46 -05001296 input_mt_sync_frame(input);
Jason Gereckeb1e42792012-10-21 00:38:04 -07001297
1298 wacom->num_contacts_left -= contacts_to_send;
Ping Chenge0d41fd2015-02-20 14:27:30 -08001299 if (wacom->num_contacts_left <= 0) {
Jason Gereckeb1e42792012-10-21 00:38:04 -07001300 wacom->num_contacts_left = 0;
Ping Cheng7d059ed2015-03-20 14:57:21 -07001301 wacom->shared->touch_down = wacom_wac_finger_count_touches(wacom);
Ping Chenge0d41fd2015-02-20 14:27:30 -08001302 }
Jason Gereckeb1e42792012-10-21 00:38:04 -07001303 return 1;
1304}
1305
Ping Cheng19635182012-04-29 21:09:18 -07001306static int wacom_mt_touch(struct wacom_wac *wacom)
1307{
Jason Gerecke2a6cdbd2015-06-15 18:01:45 -07001308 struct input_dev *input = wacom->touch_input;
Jason Gerecke74b63412014-04-19 13:50:22 -07001309 unsigned char *data = wacom->data;
Ping Cheng19635182012-04-29 21:09:18 -07001310 int i;
1311 int current_num_contacts = data[2];
1312 int contacts_to_send = 0;
Ping Cheng6afdc282012-11-03 12:16:15 -07001313 int x_offset = 0;
1314
1315 /* MTTPC does not support Height and Width */
Jason Gerecked51ddb22014-05-14 17:14:29 -07001316 if (wacom->features.type == MTTPC || wacom->features.type == MTTPC_B)
Ping Cheng6afdc282012-11-03 12:16:15 -07001317 x_offset = -4;
Ping Cheng19635182012-04-29 21:09:18 -07001318
1319 /*
1320 * First packet resets the counter since only the first
1321 * packet in series will have non-zero current_num_contacts.
1322 */
Ping Cheng7d059ed2015-03-20 14:57:21 -07001323 if (current_num_contacts)
Ping Cheng19635182012-04-29 21:09:18 -07001324 wacom->num_contacts_left = current_num_contacts;
1325
1326 /* There are at most 5 contacts per packet */
1327 contacts_to_send = min(5, wacom->num_contacts_left);
1328
1329 for (i = 0; i < contacts_to_send; i++) {
Ping Cheng6afdc282012-11-03 12:16:15 -07001330 int offset = (WACOM_BYTES_PER_MT_PACKET + x_offset) * i + 3;
Ping Cheng9b61aa82015-01-28 09:42:59 -08001331 bool touch = (data[offset] & 0x1) && !wacom->shared->stylus_in_proximity;
Jason Gereckeedc8e20a2014-05-14 16:53:30 -07001332 int id = get_unaligned_le16(&data[offset + 1]);
Ping Cheng02295e62013-01-04 23:56:00 -08001333 int slot = input_mt_get_slot_by_key(input, id);
Ping Cheng19635182012-04-29 21:09:18 -07001334
1335 if (slot < 0)
1336 continue;
1337
1338 input_mt_slot(input, slot);
1339 input_mt_report_slot_state(input, MT_TOOL_FINGER, touch);
1340 if (touch) {
Jason Gereckeedc8e20a2014-05-14 16:53:30 -07001341 int x = get_unaligned_le16(&data[offset + x_offset + 7]);
1342 int y = get_unaligned_le16(&data[offset + x_offset + 9]);
Ping Cheng19635182012-04-29 21:09:18 -07001343 input_report_abs(input, ABS_MT_POSITION_X, x);
1344 input_report_abs(input, ABS_MT_POSITION_Y, y);
1345 }
Ping Cheng19635182012-04-29 21:09:18 -07001346 }
Benjamin Tissoires9a1c0012015-02-17 14:19:46 -05001347 input_mt_sync_frame(input);
Ping Cheng19635182012-04-29 21:09:18 -07001348
1349 wacom->num_contacts_left -= contacts_to_send;
Ping Chenge0d41fd2015-02-20 14:27:30 -08001350 if (wacom->num_contacts_left <= 0) {
Ping Cheng19635182012-04-29 21:09:18 -07001351 wacom->num_contacts_left = 0;
Ping Cheng7d059ed2015-03-20 14:57:21 -07001352 wacom->shared->touch_down = wacom_wac_finger_count_touches(wacom);
Ping Chenge0d41fd2015-02-20 14:27:30 -08001353 }
Ping Cheng19635182012-04-29 21:09:18 -07001354 return 1;
1355}
1356
Ping Cheng84eb5aa2011-03-12 20:35:18 -08001357static int wacom_tpc_mt_touch(struct wacom_wac *wacom)
1358{
Jason Gerecke2a6cdbd2015-06-15 18:01:45 -07001359 struct input_dev *input = wacom->touch_input;
Ping Cheng84eb5aa2011-03-12 20:35:18 -08001360 unsigned char *data = wacom->data;
Ping Cheng84eb5aa2011-03-12 20:35:18 -08001361 int i;
1362
1363 for (i = 0; i < 2; i++) {
1364 int p = data[1] & (1 << i);
1365 bool touch = p && !wacom->shared->stylus_in_proximity;
1366
1367 input_mt_slot(input, i);
1368 input_mt_report_slot_state(input, MT_TOOL_FINGER, touch);
1369 if (touch) {
1370 int x = le16_to_cpup((__le16 *)&data[i * 2 + 2]) & 0x7fff;
1371 int y = le16_to_cpup((__le16 *)&data[i * 2 + 6]) & 0x7fff;
1372
1373 input_report_abs(input, ABS_MT_POSITION_X, x);
1374 input_report_abs(input, ABS_MT_POSITION_Y, y);
Ping Cheng84eb5aa2011-03-12 20:35:18 -08001375 }
1376 }
Benjamin Tissoires9a1c0012015-02-17 14:19:46 -05001377 input_mt_sync_frame(input);
Ping Cheng84eb5aa2011-03-12 20:35:18 -08001378
1379 /* keep touch state for pen event */
Ping Cheng7d059ed2015-03-20 14:57:21 -07001380 wacom->shared->touch_down = wacom_wac_finger_count_touches(wacom);
Ping Cheng84eb5aa2011-03-12 20:35:18 -08001381
Ping Cheng84eb5aa2011-03-12 20:35:18 -08001382 return 1;
1383}
1384
Ping Chenga43c7c52011-03-12 20:34:42 -08001385static int wacom_tpc_single_touch(struct wacom_wac *wacom, size_t len)
Ping Chengec67bbe2009-12-15 00:35:24 -08001386{
Jason Gerecke74b63412014-04-19 13:50:22 -07001387 unsigned char *data = wacom->data;
Jason Gerecke2a6cdbd2015-06-15 18:01:45 -07001388 struct input_dev *input = wacom->touch_input;
Ping Chenge0d41fd2015-02-20 14:27:30 -08001389 bool prox = !wacom->shared->stylus_in_proximity;
Ping Chenga43c7c52011-03-12 20:34:42 -08001390 int x = 0, y = 0;
Ping Chengec67bbe2009-12-15 00:35:24 -08001391
Ping Cheng19635182012-04-29 21:09:18 -07001392 if (wacom->features.touch_max > 1 || len > WACOM_PKGLEN_TPC2FG)
1393 return 0;
1394
Ping Chenge0d41fd2015-02-20 14:27:30 -08001395 if (len == WACOM_PKGLEN_TPC1FG) {
1396 prox = prox && (data[0] & 0x01);
1397 x = get_unaligned_le16(&data[1]);
1398 y = get_unaligned_le16(&data[3]);
1399 } else if (len == WACOM_PKGLEN_TPC1FG_B) {
1400 prox = prox && (data[2] & 0x01);
1401 x = get_unaligned_le16(&data[3]);
1402 y = get_unaligned_le16(&data[5]);
1403 } else {
1404 prox = prox && (data[1] & 0x01);
1405 x = le16_to_cpup((__le16 *)&data[2]);
1406 y = le16_to_cpup((__le16 *)&data[4]);
1407 }
Ping Chenga43c7c52011-03-12 20:34:42 -08001408
1409 if (prox) {
1410 input_report_abs(input, ABS_X, x);
1411 input_report_abs(input, ABS_Y, y);
Ping Chengec67bbe2009-12-15 00:35:24 -08001412 }
Ping Chenga43c7c52011-03-12 20:34:42 -08001413 input_report_key(input, BTN_TOUCH, prox);
1414
1415 /* keep touch state for pen events */
1416 wacom->shared->touch_down = prox;
1417
1418 return 1;
Ping Chengec67bbe2009-12-15 00:35:24 -08001419}
1420
Ping Cheng8aa9a9a2011-03-12 20:34:11 -08001421static int wacom_tpc_pen(struct wacom_wac *wacom)
Ping Cheng545f4e92008-11-24 11:44:27 -05001422{
Jason Gerecke74b63412014-04-19 13:50:22 -07001423 unsigned char *data = wacom->data;
Jason Gerecke2a6cdbd2015-06-15 18:01:45 -07001424 struct input_dev *input = wacom->pen_input;
Ping Chenga43c7c52011-03-12 20:34:42 -08001425 bool prox = data[1] & 0x20;
Ping Cheng8aa9a9a2011-03-12 20:34:11 -08001426
Ping Chenga43c7c52011-03-12 20:34:42 -08001427 if (!wacom->shared->stylus_in_proximity) /* first in prox */
Ping Cheng8aa9a9a2011-03-12 20:34:11 -08001428 /* Going into proximity select tool */
1429 wacom->tool[0] = (data[1] & 0x0c) ? BTN_TOOL_RUBBER : BTN_TOOL_PEN;
Ping Cheng8aa9a9a2011-03-12 20:34:11 -08001430
Ping Chenga43c7c52011-03-12 20:34:42 -08001431 /* keep pen state for touch events */
1432 wacom->shared->stylus_in_proximity = prox;
Ping Cheng8aa9a9a2011-03-12 20:34:11 -08001433
Ping Chenga43c7c52011-03-12 20:34:42 -08001434 /* send pen events only when touch is up or forced out */
1435 if (!wacom->shared->touch_down) {
1436 input_report_key(input, BTN_STYLUS, data[1] & 0x02);
1437 input_report_key(input, BTN_STYLUS2, data[1] & 0x10);
1438 input_report_abs(input, ABS_X, le16_to_cpup((__le16 *)&data[2]));
1439 input_report_abs(input, ABS_Y, le16_to_cpup((__le16 *)&data[4]));
Jason Gerecke0b335ca2014-07-24 13:15:31 -07001440 input_report_abs(input, ABS_PRESSURE, ((data[7] & 0x07) << 8) | data[6]);
Ping Chenga43c7c52011-03-12 20:34:42 -08001441 input_report_key(input, BTN_TOUCH, data[1] & 0x05);
1442 input_report_key(input, wacom->tool[0], prox);
1443 return 1;
1444 }
1445
1446 return 0;
Ping Cheng8aa9a9a2011-03-12 20:34:11 -08001447}
1448
1449static int wacom_tpc_irq(struct wacom_wac *wacom, size_t len)
1450{
Jason Gerecke74b63412014-04-19 13:50:22 -07001451 unsigned char *data = wacom->data;
Ping Cheng545f4e92008-11-24 11:44:27 -05001452
Jason Gerecke2a6cdbd2015-06-15 18:01:45 -07001453 if (wacom->pen_input)
1454 dev_dbg(wacom->pen_input->dev.parent,
1455 "%s: received report #%d\n", __func__, data[0]);
1456 else if (wacom->touch_input)
1457 dev_dbg(wacom->touch_input->dev.parent,
1458 "%s: received report #%d\n", __func__, data[0]);
Ping Cheng545f4e92008-11-24 11:44:27 -05001459
Ping Cheng31175a82012-01-31 00:07:33 -08001460 switch (len) {
1461 case WACOM_PKGLEN_TPC1FG:
Ping Cheng19635182012-04-29 21:09:18 -07001462 return wacom_tpc_single_touch(wacom, len);
Ping Cheng31175a82012-01-31 00:07:33 -08001463
1464 case WACOM_PKGLEN_TPC2FG:
Ping Cheng19635182012-04-29 21:09:18 -07001465 return wacom_tpc_mt_touch(wacom);
Ping Cheng31175a82012-01-31 00:07:33 -08001466
Jason Gerecked51ddb22014-05-14 17:14:29 -07001467 case WACOM_PKGLEN_PENABLED:
1468 return wacom_tpc_pen(wacom);
1469
Ping Cheng31175a82012-01-31 00:07:33 -08001470 default:
1471 switch (data[0]) {
1472 case WACOM_REPORT_TPC1FG:
1473 case WACOM_REPORT_TPCHID:
1474 case WACOM_REPORT_TPCST:
Ping Chengac173832012-06-12 00:15:06 -07001475 case WACOM_REPORT_TPC1FGE:
Ping Cheng31175a82012-01-31 00:07:33 -08001476 return wacom_tpc_single_touch(wacom, len);
1477
Ping Cheng19635182012-04-29 21:09:18 -07001478 case WACOM_REPORT_TPCMT:
Jason Gerecked51ddb22014-05-14 17:14:29 -07001479 case WACOM_REPORT_TPCMT2:
Ping Cheng19635182012-04-29 21:09:18 -07001480 return wacom_mt_touch(wacom);
1481
Ping Cheng31175a82012-01-31 00:07:33 -08001482 case WACOM_REPORT_PENABLED:
1483 return wacom_tpc_pen(wacom);
1484 }
1485 }
Ping Cheng545f4e92008-11-24 11:44:27 -05001486
Ping Cheng8aa9a9a2011-03-12 20:34:11 -08001487 return 0;
Ping Cheng545f4e92008-11-24 11:44:27 -05001488}
1489
Jason Gerecke2a6cdbd2015-06-15 18:01:45 -07001490static void wacom_map_usage(struct input_dev *input, struct hid_usage *usage,
Benjamin Tissoires7704ac92014-09-23 12:08:08 -04001491 struct hid_field *field, __u8 type, __u16 code, int fuzz)
1492{
Benjamin Tissoires7704ac92014-09-23 12:08:08 -04001493 int fmin = field->logical_minimum;
1494 int fmax = field->logical_maximum;
1495
1496 usage->type = type;
1497 usage->code = code;
1498
1499 set_bit(type, input->evbit);
1500
1501 switch (type) {
1502 case EV_ABS:
1503 input_set_abs_params(input, code, fmin, fmax, fuzz, 0);
1504 input_abs_set_res(input, code,
1505 hidinput_calc_abs_res(field, code));
1506 break;
1507 case EV_KEY:
1508 input_set_capability(input, EV_KEY, code);
1509 break;
1510 case EV_MSC:
1511 input_set_capability(input, EV_MSC, code);
1512 break;
1513 }
1514}
1515
1516static void wacom_wac_pen_usage_mapping(struct hid_device *hdev,
1517 struct hid_field *field, struct hid_usage *usage)
1518{
1519 struct wacom *wacom = hid_get_drvdata(hdev);
Jason Gerecke2a6cdbd2015-06-15 18:01:45 -07001520 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
1521 struct input_dev *input = wacom_wac->pen_input;
Benjamin Tissoires7704ac92014-09-23 12:08:08 -04001522
1523 switch (usage->hid) {
1524 case HID_GD_X:
Jason Gerecke2a6cdbd2015-06-15 18:01:45 -07001525 wacom_map_usage(input, usage, field, EV_ABS, ABS_X, 4);
Benjamin Tissoires7704ac92014-09-23 12:08:08 -04001526 break;
1527 case HID_GD_Y:
Jason Gerecke2a6cdbd2015-06-15 18:01:45 -07001528 wacom_map_usage(input, usage, field, EV_ABS, ABS_Y, 4);
Benjamin Tissoires7704ac92014-09-23 12:08:08 -04001529 break;
1530 case HID_DG_TIPPRESSURE:
Jason Gerecke2a6cdbd2015-06-15 18:01:45 -07001531 wacom_map_usage(input, usage, field, EV_ABS, ABS_PRESSURE, 0);
Benjamin Tissoires7704ac92014-09-23 12:08:08 -04001532 break;
1533 case HID_DG_INRANGE:
Jason Gerecke2a6cdbd2015-06-15 18:01:45 -07001534 wacom_map_usage(input, usage, field, EV_KEY, BTN_TOOL_PEN, 0);
Benjamin Tissoires7704ac92014-09-23 12:08:08 -04001535 break;
1536 case HID_DG_INVERT:
Jason Gerecke2a6cdbd2015-06-15 18:01:45 -07001537 wacom_map_usage(input, usage, field, EV_KEY,
Benjamin Tissoires7704ac92014-09-23 12:08:08 -04001538 BTN_TOOL_RUBBER, 0);
1539 break;
1540 case HID_DG_ERASER:
1541 case HID_DG_TIPSWITCH:
Jason Gerecke2a6cdbd2015-06-15 18:01:45 -07001542 wacom_map_usage(input, usage, field, EV_KEY, BTN_TOUCH, 0);
Benjamin Tissoires7704ac92014-09-23 12:08:08 -04001543 break;
1544 case HID_DG_BARRELSWITCH:
Jason Gerecke2a6cdbd2015-06-15 18:01:45 -07001545 wacom_map_usage(input, usage, field, EV_KEY, BTN_STYLUS, 0);
Benjamin Tissoires7704ac92014-09-23 12:08:08 -04001546 break;
1547 case HID_DG_BARRELSWITCH2:
Jason Gerecke2a6cdbd2015-06-15 18:01:45 -07001548 wacom_map_usage(input, usage, field, EV_KEY, BTN_STYLUS2, 0);
Benjamin Tissoires7704ac92014-09-23 12:08:08 -04001549 break;
1550 case HID_DG_TOOLSERIALNUMBER:
Jason Gerecke2a6cdbd2015-06-15 18:01:45 -07001551 wacom_map_usage(input, usage, field, EV_MSC, MSC_SERIAL, 0);
Benjamin Tissoires7704ac92014-09-23 12:08:08 -04001552 break;
1553 }
1554}
1555
1556static int wacom_wac_pen_event(struct hid_device *hdev, struct hid_field *field,
1557 struct hid_usage *usage, __s32 value)
1558{
1559 struct wacom *wacom = hid_get_drvdata(hdev);
1560 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
Jason Gerecke2a6cdbd2015-06-15 18:01:45 -07001561 struct input_dev *input = wacom_wac->pen_input;
Benjamin Tissoires7704ac92014-09-23 12:08:08 -04001562
1563 /* checking which Tool / tip switch to send */
1564 switch (usage->hid) {
1565 case HID_DG_INRANGE:
1566 wacom_wac->hid_data.inrange_state = value;
1567 return 0;
1568 case HID_DG_INVERT:
1569 wacom_wac->hid_data.invert_state = value;
1570 return 0;
1571 case HID_DG_ERASER:
1572 case HID_DG_TIPSWITCH:
1573 wacom_wac->hid_data.tipswitch |= value;
1574 return 0;
1575 }
1576
1577 /* send pen events only when touch is up or forced out */
1578 if (!usage->type || wacom_wac->shared->touch_down)
1579 return 0;
1580
1581 input_event(input, usage->type, usage->code, value);
1582
1583 return 0;
1584}
1585
Jason Gerecke06324e02015-07-21 11:07:23 -07001586static void wacom_wac_pen_pre_report(struct hid_device *hdev,
1587 struct hid_report *report)
1588{
1589 return;
1590}
1591
Benjamin Tissoires7704ac92014-09-23 12:08:08 -04001592static void wacom_wac_pen_report(struct hid_device *hdev,
1593 struct hid_report *report)
1594{
1595 struct wacom *wacom = hid_get_drvdata(hdev);
1596 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
Jason Gerecke2a6cdbd2015-06-15 18:01:45 -07001597 struct input_dev *input = wacom_wac->pen_input;
Benjamin Tissoires7704ac92014-09-23 12:08:08 -04001598 bool prox = wacom_wac->hid_data.inrange_state;
1599
1600 if (!wacom_wac->shared->stylus_in_proximity) /* first in prox */
1601 /* Going into proximity select tool */
1602 wacom_wac->tool[0] = wacom_wac->hid_data.invert_state ?
1603 BTN_TOOL_RUBBER : BTN_TOOL_PEN;
1604
1605 /* keep pen state for touch events */
1606 wacom_wac->shared->stylus_in_proximity = prox;
1607
1608 /* send pen events only when touch is up or forced out */
1609 if (!wacom_wac->shared->touch_down) {
1610 input_report_key(input, BTN_TOUCH,
1611 wacom_wac->hid_data.tipswitch);
1612 input_report_key(input, wacom_wac->tool[0], prox);
1613
1614 wacom_wac->hid_data.tipswitch = false;
1615
1616 input_sync(input);
1617 }
1618}
1619
Benjamin Tissoires5ae6e892014-09-23 12:08:09 -04001620static void wacom_wac_finger_usage_mapping(struct hid_device *hdev,
1621 struct hid_field *field, struct hid_usage *usage)
1622{
1623 struct wacom *wacom = hid_get_drvdata(hdev);
1624 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
Jason Gerecke601a22f2014-12-10 16:26:04 -08001625 struct wacom_features *features = &wacom_wac->features;
Jason Gerecke2a6cdbd2015-06-15 18:01:45 -07001626 struct input_dev *input = wacom_wac->touch_input;
Benjamin Tissoires5ae6e892014-09-23 12:08:09 -04001627 unsigned touch_max = wacom_wac->features.touch_max;
1628
1629 switch (usage->hid) {
1630 case HID_GD_X:
Jason Gerecke601a22f2014-12-10 16:26:04 -08001631 features->last_slot_field = usage->hid;
Benjamin Tissoires5ae6e892014-09-23 12:08:09 -04001632 if (touch_max == 1)
Jason Gerecke2a6cdbd2015-06-15 18:01:45 -07001633 wacom_map_usage(input, usage, field, EV_ABS, ABS_X, 4);
Benjamin Tissoires5ae6e892014-09-23 12:08:09 -04001634 else
Jason Gerecke2a6cdbd2015-06-15 18:01:45 -07001635 wacom_map_usage(input, usage, field, EV_ABS,
Benjamin Tissoires5ae6e892014-09-23 12:08:09 -04001636 ABS_MT_POSITION_X, 4);
1637 break;
1638 case HID_GD_Y:
Jason Gerecke601a22f2014-12-10 16:26:04 -08001639 features->last_slot_field = usage->hid;
Benjamin Tissoires5ae6e892014-09-23 12:08:09 -04001640 if (touch_max == 1)
Jason Gerecke2a6cdbd2015-06-15 18:01:45 -07001641 wacom_map_usage(input, usage, field, EV_ABS, ABS_Y, 4);
Benjamin Tissoires5ae6e892014-09-23 12:08:09 -04001642 else
Jason Gerecke2a6cdbd2015-06-15 18:01:45 -07001643 wacom_map_usage(input, usage, field, EV_ABS,
Benjamin Tissoires5ae6e892014-09-23 12:08:09 -04001644 ABS_MT_POSITION_Y, 4);
1645 break;
Jason Gerecke488abb52015-07-21 11:07:25 -07001646 case HID_DG_WIDTH:
1647 case HID_DG_HEIGHT:
1648 features->last_slot_field = usage->hid;
1649 wacom_map_usage(input, usage, field, EV_ABS, ABS_MT_TOUCH_MAJOR, 0);
1650 wacom_map_usage(input, usage, field, EV_ABS, ABS_MT_TOUCH_MINOR, 0);
1651 input_set_abs_params(input, ABS_MT_ORIENTATION, 0, 1, 0, 0);
1652 break;
Benjamin Tissoires5ae6e892014-09-23 12:08:09 -04001653 case HID_DG_CONTACTID:
Jason Gerecke601a22f2014-12-10 16:26:04 -08001654 features->last_slot_field = usage->hid;
Benjamin Tissoires5ae6e892014-09-23 12:08:09 -04001655 break;
1656 case HID_DG_INRANGE:
Jason Gerecke601a22f2014-12-10 16:26:04 -08001657 features->last_slot_field = usage->hid;
Benjamin Tissoires5ae6e892014-09-23 12:08:09 -04001658 break;
1659 case HID_DG_INVERT:
Jason Gerecke601a22f2014-12-10 16:26:04 -08001660 features->last_slot_field = usage->hid;
Benjamin Tissoires5ae6e892014-09-23 12:08:09 -04001661 break;
1662 case HID_DG_TIPSWITCH:
Jason Gerecke601a22f2014-12-10 16:26:04 -08001663 features->last_slot_field = usage->hid;
Jason Gerecke2a6cdbd2015-06-15 18:01:45 -07001664 wacom_map_usage(input, usage, field, EV_KEY, BTN_TOUCH, 0);
Benjamin Tissoires5ae6e892014-09-23 12:08:09 -04001665 break;
Jason Gerecke1b5d514a2015-07-21 11:07:24 -07001666 case HID_DG_CONTACTCOUNT:
Jason Gerecke499522c2015-10-07 16:54:21 -07001667 wacom_wac->hid_data.cc_report = field->report->id;
Jason Gerecke1b5d514a2015-07-21 11:07:24 -07001668 wacom_wac->hid_data.cc_index = field->index;
1669 wacom_wac->hid_data.cc_value_index = usage->usage_index;
1670 break;
Benjamin Tissoires5ae6e892014-09-23 12:08:09 -04001671 }
1672}
1673
Jason Gerecke601a22f2014-12-10 16:26:04 -08001674static void wacom_wac_finger_slot(struct wacom_wac *wacom_wac,
1675 struct input_dev *input)
1676{
1677 struct hid_data *hid_data = &wacom_wac->hid_data;
1678 bool mt = wacom_wac->features.touch_max > 1;
1679 bool prox = hid_data->tipswitch &&
1680 !wacom_wac->shared->stylus_in_proximity;
1681
Jason Gerecke1b5d514a2015-07-21 11:07:24 -07001682 wacom_wac->hid_data.num_received++;
1683 if (wacom_wac->hid_data.num_received > wacom_wac->hid_data.num_expected)
1684 return;
1685
Jason Gerecke601a22f2014-12-10 16:26:04 -08001686 if (mt) {
1687 int slot;
1688
1689 slot = input_mt_get_slot_by_key(input, hid_data->id);
1690 input_mt_slot(input, slot);
1691 input_mt_report_slot_state(input, MT_TOOL_FINGER, prox);
1692 }
1693 else {
1694 input_report_key(input, BTN_TOUCH, prox);
1695 }
1696
1697 if (prox) {
1698 input_report_abs(input, mt ? ABS_MT_POSITION_X : ABS_X,
1699 hid_data->x);
1700 input_report_abs(input, mt ? ABS_MT_POSITION_Y : ABS_Y,
1701 hid_data->y);
Jason Gerecke488abb52015-07-21 11:07:25 -07001702
1703 if (test_bit(ABS_MT_TOUCH_MAJOR, input->absbit)) {
1704 input_report_abs(input, ABS_MT_TOUCH_MAJOR, max(hid_data->width, hid_data->height));
1705 input_report_abs(input, ABS_MT_TOUCH_MINOR, min(hid_data->width, hid_data->height));
1706 if (hid_data->width != hid_data->height)
1707 input_report_abs(input, ABS_MT_ORIENTATION, hid_data->width <= hid_data->height ? 0 : 1);
1708 }
Jason Gerecke601a22f2014-12-10 16:26:04 -08001709 }
1710}
1711
Benjamin Tissoires5ae6e892014-09-23 12:08:09 -04001712static int wacom_wac_finger_event(struct hid_device *hdev,
1713 struct hid_field *field, struct hid_usage *usage, __s32 value)
1714{
1715 struct wacom *wacom = hid_get_drvdata(hdev);
1716 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
1717
1718 switch (usage->hid) {
1719 case HID_GD_X:
1720 wacom_wac->hid_data.x = value;
1721 break;
1722 case HID_GD_Y:
1723 wacom_wac->hid_data.y = value;
1724 break;
Jason Gerecke488abb52015-07-21 11:07:25 -07001725 case HID_DG_WIDTH:
1726 wacom_wac->hid_data.width = value;
1727 break;
1728 case HID_DG_HEIGHT:
1729 wacom_wac->hid_data.height = value;
1730 break;
Benjamin Tissoires5ae6e892014-09-23 12:08:09 -04001731 case HID_DG_CONTACTID:
1732 wacom_wac->hid_data.id = value;
1733 break;
1734 case HID_DG_TIPSWITCH:
1735 wacom_wac->hid_data.tipswitch = value;
1736 break;
1737 }
1738
1739
Jason Gerecke601a22f2014-12-10 16:26:04 -08001740 if (usage->usage_index + 1 == field->report_count) {
1741 if (usage->hid == wacom_wac->features.last_slot_field)
Jason Gerecke2a6cdbd2015-06-15 18:01:45 -07001742 wacom_wac_finger_slot(wacom_wac, wacom_wac->touch_input);
Jason Gerecke601a22f2014-12-10 16:26:04 -08001743 }
1744
Benjamin Tissoires5ae6e892014-09-23 12:08:09 -04001745 return 0;
1746}
1747
Jason Gerecke06324e02015-07-21 11:07:23 -07001748static void wacom_wac_finger_pre_report(struct hid_device *hdev,
1749 struct hid_report *report)
1750{
Jason Gerecke1b5d514a2015-07-21 11:07:24 -07001751 struct wacom *wacom = hid_get_drvdata(hdev);
1752 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
1753 struct hid_data* hid_data = &wacom_wac->hid_data;
1754
Jason Gerecke499522c2015-10-07 16:54:21 -07001755 if (hid_data->cc_report != 0 &&
1756 hid_data->cc_report != report->id) {
1757 int i;
1758
1759 hid_data->cc_report = report->id;
1760 hid_data->cc_index = -1;
1761 hid_data->cc_value_index = -1;
1762
1763 for (i = 0; i < report->maxfield; i++) {
1764 struct hid_field *field = report->field[i];
1765 int j;
1766
1767 for (j = 0; j < field->maxusage; j++) {
1768 if (field->usage[j].hid == HID_DG_CONTACTCOUNT) {
1769 hid_data->cc_index = i;
1770 hid_data->cc_value_index = j;
1771
1772 /* break */
1773 i = report->maxfield;
1774 j = field->maxusage;
1775 }
1776 }
1777 }
1778 }
Jason Gereckedf707932015-10-07 16:54:22 -07001779 if (hid_data->cc_report != 0 &&
1780 hid_data->cc_index >= 0) {
Jason Gerecke1b5d514a2015-07-21 11:07:24 -07001781 struct hid_field *field = report->field[hid_data->cc_index];
1782 int value = field->value[hid_data->cc_value_index];
1783 if (value)
1784 hid_data->num_expected = value;
1785 }
1786 else {
1787 hid_data->num_expected = wacom_wac->features.touch_max;
1788 }
Jason Gerecke06324e02015-07-21 11:07:23 -07001789}
1790
Benjamin Tissoires5ae6e892014-09-23 12:08:09 -04001791static void wacom_wac_finger_report(struct hid_device *hdev,
1792 struct hid_report *report)
1793{
1794 struct wacom *wacom = hid_get_drvdata(hdev);
1795 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
Jason Gerecke2a6cdbd2015-06-15 18:01:45 -07001796 struct input_dev *input = wacom_wac->touch_input;
Benjamin Tissoires5ae6e892014-09-23 12:08:09 -04001797 unsigned touch_max = wacom_wac->features.touch_max;
1798
Jason Gerecke1b5d514a2015-07-21 11:07:24 -07001799 /* If more packets of data are expected, give us a chance to
1800 * process them rather than immediately syncing a partial
1801 * update.
1802 */
1803 if (wacom_wac->hid_data.num_received < wacom_wac->hid_data.num_expected)
1804 return;
1805
Benjamin Tissoires5ae6e892014-09-23 12:08:09 -04001806 if (touch_max > 1)
Jason Gerecke601a22f2014-12-10 16:26:04 -08001807 input_mt_sync_frame(input);
1808
Benjamin Tissoires5ae6e892014-09-23 12:08:09 -04001809 input_sync(input);
Jason Gerecke1b5d514a2015-07-21 11:07:24 -07001810 wacom_wac->hid_data.num_received = 0;
Benjamin Tissoires5ae6e892014-09-23 12:08:09 -04001811
1812 /* keep touch state for pen event */
Ping Cheng7d059ed2015-03-20 14:57:21 -07001813 wacom_wac->shared->touch_down = wacom_wac_finger_count_touches(wacom_wac);
Benjamin Tissoires5ae6e892014-09-23 12:08:09 -04001814}
1815
Benjamin Tissoires7704ac92014-09-23 12:08:08 -04001816void wacom_wac_usage_mapping(struct hid_device *hdev,
1817 struct hid_field *field, struct hid_usage *usage)
1818{
1819 struct wacom *wacom = hid_get_drvdata(hdev);
1820 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
Benjamin Tissoires7704ac92014-09-23 12:08:08 -04001821
1822 /* currently, only direct devices have proper hid report descriptors */
Jason Gerecke2a6cdbd2015-06-15 18:01:45 -07001823 __set_bit(INPUT_PROP_DIRECT, wacom_wac->pen_input->propbit);
1824 __set_bit(INPUT_PROP_DIRECT, wacom_wac->touch_input->propbit);
Benjamin Tissoires7704ac92014-09-23 12:08:08 -04001825
1826 if (WACOM_PEN_FIELD(field))
1827 return wacom_wac_pen_usage_mapping(hdev, field, usage);
Benjamin Tissoires5ae6e892014-09-23 12:08:09 -04001828
1829 if (WACOM_FINGER_FIELD(field))
1830 return wacom_wac_finger_usage_mapping(hdev, field, usage);
Benjamin Tissoires7704ac92014-09-23 12:08:08 -04001831}
1832
1833int wacom_wac_event(struct hid_device *hdev, struct hid_field *field,
1834 struct hid_usage *usage, __s32 value)
1835{
1836 struct wacom *wacom = hid_get_drvdata(hdev);
1837
1838 if (wacom->wacom_wac.features.type != HID_GENERIC)
1839 return 0;
1840
1841 if (WACOM_PEN_FIELD(field))
1842 return wacom_wac_pen_event(hdev, field, usage, value);
1843
Benjamin Tissoires5ae6e892014-09-23 12:08:09 -04001844 if (WACOM_FINGER_FIELD(field))
1845 return wacom_wac_finger_event(hdev, field, usage, value);
1846
Benjamin Tissoires7704ac92014-09-23 12:08:08 -04001847 return 0;
1848}
1849
Jason Gerecke06324e02015-07-21 11:07:23 -07001850static void wacom_report_events(struct hid_device *hdev, struct hid_report *report)
1851{
1852 int r;
1853
1854 for (r = 0; r < report->maxfield; r++) {
1855 struct hid_field *field;
1856 unsigned count, n;
1857
1858 field = report->field[r];
1859 count = field->report_count;
1860
1861 if (!(HID_MAIN_ITEM_VARIABLE & field->flags))
1862 continue;
1863
1864 for (n = 0; n < count; n++)
1865 wacom_wac_event(hdev, field, &field->usage[n], field->value[n]);
1866 }
1867}
1868
Benjamin Tissoires7704ac92014-09-23 12:08:08 -04001869void wacom_wac_report(struct hid_device *hdev, struct hid_report *report)
1870{
1871 struct wacom *wacom = hid_get_drvdata(hdev);
1872 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
1873 struct hid_field *field = report->field[0];
1874
1875 if (wacom_wac->features.type != HID_GENERIC)
1876 return;
1877
1878 if (WACOM_PEN_FIELD(field))
Jason Gerecke06324e02015-07-21 11:07:23 -07001879 wacom_wac_pen_pre_report(hdev, report);
1880
1881 if (WACOM_FINGER_FIELD(field))
1882 wacom_wac_finger_pre_report(hdev, report);
1883
1884 wacom_report_events(hdev, report);
1885
1886 if (WACOM_PEN_FIELD(field))
Benjamin Tissoires7704ac92014-09-23 12:08:08 -04001887 return wacom_wac_pen_report(hdev, report);
Benjamin Tissoires5ae6e892014-09-23 12:08:09 -04001888
1889 if (WACOM_FINGER_FIELD(field))
1890 return wacom_wac_finger_report(hdev, report);
Benjamin Tissoires7704ac92014-09-23 12:08:08 -04001891}
1892
Chris Bagwelle1d38e42010-09-12 00:09:27 -07001893static int wacom_bpt_touch(struct wacom_wac *wacom)
Henrik Rydbergcb734c02010-09-05 12:53:16 -07001894{
Henrik Rydbergf4ccbef2010-09-05 12:57:13 -07001895 struct wacom_features *features = &wacom->features;
Jason Gerecke2a6cdbd2015-06-15 18:01:45 -07001896 struct input_dev *input = wacom->touch_input;
Benjamin Tissoires31168712014-07-24 12:50:10 -07001897 struct input_dev *pad_input = wacom->pad_input;
Henrik Rydbergcb734c02010-09-05 12:53:16 -07001898 unsigned char *data = wacom->data;
Henrik Rydbergcb734c02010-09-05 12:53:16 -07001899 int i;
1900
Chris Bagwell5a6c8652011-11-07 19:52:42 -08001901 if (data[0] != 0x02)
1902 return 0;
1903
Henrik Rydbergcb734c02010-09-05 12:53:16 -07001904 for (i = 0; i < 2; i++) {
Chris Bagwell8f906862011-09-09 13:38:10 -07001905 int offset = (data[1] & 0x80) ? (8 * i) : (9 * i);
1906 bool touch = data[offset + 3] & 0x80;
Henrik Rydbergc5f4dec2010-12-15 13:50:34 +01001907
Chris Bagwell33d5f712010-09-12 00:12:28 -07001908 /*
1909 * Touch events need to be disabled while stylus is
1910 * in proximity because user's hand is resting on touchpad
1911 * and sending unwanted events. User expects tablet buttons
1912 * to continue working though.
1913 */
Chris Bagwell8f906862011-09-09 13:38:10 -07001914 touch = touch && !wacom->shared->stylus_in_proximity;
1915
1916 input_mt_slot(input, i);
1917 input_mt_report_slot_state(input, MT_TOOL_FINGER, touch);
Henrik Rydbergc5f4dec2010-12-15 13:50:34 +01001918 if (touch) {
Chris Bagwell8f906862011-09-09 13:38:10 -07001919 int x = get_unaligned_be16(&data[offset + 3]) & 0x7ff;
1920 int y = get_unaligned_be16(&data[offset + 5]) & 0x7ff;
Henrik Rydbergf4ccbef2010-09-05 12:57:13 -07001921 if (features->quirks & WACOM_QUIRK_BBTOUCH_LOWRES) {
1922 x <<= 5;
1923 y <<= 5;
1924 }
Henrik Rydbergcb734c02010-09-05 12:53:16 -07001925 input_report_abs(input, ABS_MT_POSITION_X, x);
1926 input_report_abs(input, ABS_MT_POSITION_Y, y);
Henrik Rydbergcb734c02010-09-05 12:53:16 -07001927 }
Henrik Rydbergcb734c02010-09-05 12:53:16 -07001928 }
1929
Benjamin Tissoires9a1c0012015-02-17 14:19:46 -05001930 input_mt_sync_frame(input);
Henrik Rydbergcb734c02010-09-05 12:53:16 -07001931
Benjamin Tissoires31168712014-07-24 12:50:10 -07001932 input_report_key(pad_input, BTN_LEFT, (data[1] & 0x08) != 0);
1933 input_report_key(pad_input, BTN_FORWARD, (data[1] & 0x04) != 0);
1934 input_report_key(pad_input, BTN_BACK, (data[1] & 0x02) != 0);
1935 input_report_key(pad_input, BTN_RIGHT, (data[1] & 0x01) != 0);
Ping Cheng7d059ed2015-03-20 14:57:21 -07001936 wacom->shared->touch_down = wacom_wac_finger_count_touches(wacom);
Henrik Rydbergcb734c02010-09-05 12:53:16 -07001937
Benjamin Tissoires31168712014-07-24 12:50:10 -07001938 return 1;
Henrik Rydbergcb734c02010-09-05 12:53:16 -07001939}
1940
Ping Cheng7d059ed2015-03-20 14:57:21 -07001941static void wacom_bpt3_touch_msg(struct wacom_wac *wacom, unsigned char *data)
Chris Bagwell73149ab2011-10-26 22:34:21 -07001942{
Ping Cheng9a35c412013-09-20 09:51:56 -07001943 struct wacom_features *features = &wacom->features;
Jason Gerecke2a6cdbd2015-06-15 18:01:45 -07001944 struct input_dev *input = wacom->touch_input;
Chris Bagwell73149ab2011-10-26 22:34:21 -07001945 bool touch = data[1] & 0x80;
Ping Cheng02295e62013-01-04 23:56:00 -08001946 int slot = input_mt_get_slot_by_key(input, data[0]);
1947
1948 if (slot < 0)
Ping Cheng7d059ed2015-03-20 14:57:21 -07001949 return;
Chris Bagwell73149ab2011-10-26 22:34:21 -07001950
1951 touch = touch && !wacom->shared->stylus_in_proximity;
1952
Ping Cheng02295e62013-01-04 23:56:00 -08001953 input_mt_slot(input, slot);
Chris Bagwell73149ab2011-10-26 22:34:21 -07001954 input_mt_report_slot_state(input, MT_TOOL_FINGER, touch);
1955
1956 if (touch) {
1957 int x = (data[2] << 4) | (data[4] >> 4);
1958 int y = (data[3] << 4) | (data[4] & 0x0f);
Ping Cheng9a35c412013-09-20 09:51:56 -07001959 int width, height;
Jason Gerecke4e904952012-10-03 17:19:11 -07001960
Ping Chengeda01da2015-09-23 13:51:15 -07001961 if (features->type >= INTUOSPS && features->type <= INTUOSHT2) {
Jason Gerecke0b279da2013-11-25 18:43:16 -08001962 width = data[5] * 100;
1963 height = data[6] * 100;
Ping Cheng9a35c412013-09-20 09:51:56 -07001964 } else {
1965 /*
1966 * "a" is a scaled-down area which we assume is
1967 * roughly circular and which can be described as:
1968 * a=(pi*r^2)/C.
1969 */
1970 int a = data[5];
Ping Chengd7da3a32014-06-13 13:37:33 -07001971 int x_res = input_abs_get_res(input, ABS_MT_POSITION_X);
1972 int y_res = input_abs_get_res(input, ABS_MT_POSITION_Y);
1973 width = 2 * int_sqrt(a * WACOM_CONTACT_AREA_SCALE);
Ping Cheng9a35c412013-09-20 09:51:56 -07001974 height = width * y_res / x_res;
1975 }
Chris Bagwell73149ab2011-10-26 22:34:21 -07001976
1977 input_report_abs(input, ABS_MT_POSITION_X, x);
1978 input_report_abs(input, ABS_MT_POSITION_Y, y);
Jason Gerecke4e904952012-10-03 17:19:11 -07001979 input_report_abs(input, ABS_MT_TOUCH_MAJOR, width);
1980 input_report_abs(input, ABS_MT_TOUCH_MINOR, height);
Chris Bagwell73149ab2011-10-26 22:34:21 -07001981 }
1982}
1983
1984static void wacom_bpt3_button_msg(struct wacom_wac *wacom, unsigned char *data)
1985{
Benjamin Tissoires31168712014-07-24 12:50:10 -07001986 struct input_dev *input = wacom->pad_input;
Ping Chengb5fd2a32013-11-25 18:44:55 -08001987 struct wacom_features *features = &wacom->features;
Chris Bagwell73149ab2011-10-26 22:34:21 -07001988
Ping Chengeda01da2015-09-23 13:51:15 -07001989 if (features->type == INTUOSHT || features->type == INTUOSHT2) {
Ping Chengb5fd2a32013-11-25 18:44:55 -08001990 input_report_key(input, BTN_LEFT, (data[1] & 0x02) != 0);
1991 input_report_key(input, BTN_BACK, (data[1] & 0x08) != 0);
1992 } else {
1993 input_report_key(input, BTN_BACK, (data[1] & 0x02) != 0);
1994 input_report_key(input, BTN_LEFT, (data[1] & 0x08) != 0);
1995 }
Chris Bagwell73149ab2011-10-26 22:34:21 -07001996 input_report_key(input, BTN_FORWARD, (data[1] & 0x04) != 0);
Chris Bagwell73149ab2011-10-26 22:34:21 -07001997 input_report_key(input, BTN_RIGHT, (data[1] & 0x01) != 0);
1998}
1999
2000static int wacom_bpt3_touch(struct wacom_wac *wacom)
2001{
Chris Bagwell73149ab2011-10-26 22:34:21 -07002002 unsigned char *data = wacom->data;
Jason Gerecke19d57d32012-03-06 10:19:19 -08002003 int count = data[1] & 0x07;
Ping Chengeda01da2015-09-23 13:51:15 -07002004 int touch_changed = 0, i;
Chris Bagwell73149ab2011-10-26 22:34:21 -07002005
Chris Bagwell5a6c8652011-11-07 19:52:42 -08002006 if (data[0] != 0x02)
2007 return 0;
2008
Chris Bagwell73149ab2011-10-26 22:34:21 -07002009 /* data has up to 7 fixed sized 8-byte messages starting at data[2] */
2010 for (i = 0; i < count; i++) {
2011 int offset = (8 * i) + 2;
2012 int msg_id = data[offset];
2013
Ping Chengeda01da2015-09-23 13:51:15 -07002014 if (msg_id >= 2 && msg_id <= 17) {
Ping Cheng7d059ed2015-03-20 14:57:21 -07002015 wacom_bpt3_touch_msg(wacom, data + offset);
Ping Chengeda01da2015-09-23 13:51:15 -07002016 touch_changed++;
2017 } else if (msg_id == 128)
Chris Bagwell73149ab2011-10-26 22:34:21 -07002018 wacom_bpt3_button_msg(wacom, data + offset);
2019
2020 }
Jason Gerecke2a6cdbd2015-06-15 18:01:45 -07002021
Ping Chengeda01da2015-09-23 13:51:15 -07002022 /* only update touch if we actually have a touchpad and touch data changed */
2023 if (wacom->touch_registered && touch_changed) {
Jason Gerecke2a6cdbd2015-06-15 18:01:45 -07002024 input_mt_sync_frame(wacom->touch_input);
2025 wacom->shared->touch_down = wacom_wac_finger_count_touches(wacom);
2026 }
Chris Bagwell73149ab2011-10-26 22:34:21 -07002027
Benjamin Tissoires31168712014-07-24 12:50:10 -07002028 return 1;
Chris Bagwell73149ab2011-10-26 22:34:21 -07002029}
2030
Chris Bagwell2aaacb12010-09-12 00:11:35 -07002031static int wacom_bpt_pen(struct wacom_wac *wacom)
2032{
Ping Cheng961794a2013-12-05 12:54:53 -08002033 struct wacom_features *features = &wacom->features;
Jason Gerecke2a6cdbd2015-06-15 18:01:45 -07002034 struct input_dev *input = wacom->pen_input;
Chris Bagwell2aaacb12010-09-12 00:11:35 -07002035 unsigned char *data = wacom->data;
2036 int prox = 0, x = 0, y = 0, p = 0, d = 0, pen = 0, btn1 = 0, btn2 = 0;
2037
Jason Gerecke4ca4ec72015-03-06 11:47:38 -08002038 if (data[0] != WACOM_REPORT_PENABLED)
Chris Bagwell5a6c8652011-11-07 19:52:42 -08002039 return 0;
2040
Chris Bagwellc5981412011-10-26 22:28:34 -07002041 prox = (data[1] & 0x20) == 0x20;
Chris Bagwell2aaacb12010-09-12 00:11:35 -07002042
2043 /*
2044 * All reports shared between PEN and RUBBER tool must be
2045 * forced to a known starting value (zero) when transitioning to
2046 * out-of-prox.
2047 *
2048 * If not reset then, to userspace, it will look like lost events
2049 * if new tool comes in-prox with same values as previous tool sent.
2050 *
2051 * Hardware does report zero in most out-of-prox cases but not all.
2052 */
Ping Cheng01499312015-03-20 14:58:01 -07002053 if (!wacom->shared->stylus_in_proximity) {
2054 if (data[1] & 0x08) {
2055 wacom->tool[0] = BTN_TOOL_RUBBER;
2056 wacom->id[0] = ERASER_DEVICE_ID;
2057 } else {
2058 wacom->tool[0] = BTN_TOOL_PEN;
2059 wacom->id[0] = STYLUS_DEVICE_ID;
Chris Bagwell2aaacb12010-09-12 00:11:35 -07002060 }
Ping Cheng01499312015-03-20 14:58:01 -07002061 }
2062
2063 wacom->shared->stylus_in_proximity = prox;
2064 if (wacom->shared->touch_down)
2065 return 0;
2066
2067 if (prox) {
Chris Bagwell2aaacb12010-09-12 00:11:35 -07002068 x = le16_to_cpup((__le16 *)&data[2]);
2069 y = le16_to_cpup((__le16 *)&data[4]);
2070 p = le16_to_cpup((__le16 *)&data[6]);
Chris Bagwellc18c2ce2011-10-10 08:52:13 -07002071 /*
2072 * Convert distance from out prox to distance from tablet.
2073 * distance will be greater than distance_max once
2074 * touching and applying pressure; do not report negative
2075 * distance.
2076 */
Ping Cheng961794a2013-12-05 12:54:53 -08002077 if (data[8] <= features->distance_max)
2078 d = features->distance_max - data[8];
Chris Bagwellc18c2ce2011-10-10 08:52:13 -07002079
Chris Bagwell2aaacb12010-09-12 00:11:35 -07002080 pen = data[1] & 0x01;
2081 btn1 = data[1] & 0x02;
2082 btn2 = data[1] & 0x04;
Ping Cheng01499312015-03-20 14:58:01 -07002083 } else {
2084 wacom->id[0] = 0;
Chris Bagwell2aaacb12010-09-12 00:11:35 -07002085 }
2086
2087 input_report_key(input, BTN_TOUCH, pen);
2088 input_report_key(input, BTN_STYLUS, btn1);
2089 input_report_key(input, BTN_STYLUS2, btn2);
2090
2091 input_report_abs(input, ABS_X, x);
2092 input_report_abs(input, ABS_Y, y);
2093 input_report_abs(input, ABS_PRESSURE, p);
2094 input_report_abs(input, ABS_DISTANCE, d);
2095
Chris Bagwell2aaacb12010-09-12 00:11:35 -07002096 input_report_key(input, wacom->tool[0], prox); /* PEN or RUBBER */
2097 input_report_abs(input, ABS_MISC, wacom->id[0]); /* TOOL ID */
2098
2099 return 1;
2100}
2101
Chris Bagwelle1d38e42010-09-12 00:09:27 -07002102static int wacom_bpt_irq(struct wacom_wac *wacom, size_t len)
2103{
Ping Chengeda01da2015-09-23 13:51:15 -07002104 struct wacom_features *features = &wacom->features;
2105
2106 if ((features->type == INTUOSHT2) &&
Ping Chengeda01da2015-09-23 13:51:15 -07002107 (features->device_type & WACOM_DEVICETYPE_PEN))
2108 return wacom_intuos_irq(wacom);
2109 else if (len == WACOM_PKGLEN_BBTOUCH)
Chris Bagwelle1d38e42010-09-12 00:09:27 -07002110 return wacom_bpt_touch(wacom);
Chris Bagwell73149ab2011-10-26 22:34:21 -07002111 else if (len == WACOM_PKGLEN_BBTOUCH3)
2112 return wacom_bpt3_touch(wacom);
2113 else if (len == WACOM_PKGLEN_BBFUN || len == WACOM_PKGLEN_BBPEN)
Chris Bagwell2aaacb12010-09-12 00:11:35 -07002114 return wacom_bpt_pen(wacom);
Chris Bagwelle1d38e42010-09-12 00:09:27 -07002115
2116 return 0;
2117}
2118
Benjamin Tissoires8c97a762015-02-26 11:28:50 -05002119static void wacom_bamboo_pad_pen_event(struct wacom_wac *wacom,
2120 unsigned char *data)
2121{
2122 unsigned char prefix;
2123
2124 /*
2125 * We need to reroute the event from the debug interface to the
2126 * pen interface.
2127 * We need to add the report ID to the actual pen report, so we
2128 * temporary overwrite the first byte to prevent having to kzalloc/kfree
2129 * and memcpy the report.
2130 */
2131 prefix = data[0];
2132 data[0] = WACOM_REPORT_BPAD_PEN;
2133
2134 /*
2135 * actually reroute the event.
2136 * No need to check if wacom->shared->pen is valid, hid_input_report()
2137 * will check for us.
2138 */
2139 hid_input_report(wacom->shared->pen, HID_INPUT_REPORT, data,
2140 WACOM_PKGLEN_PENABLED, 1);
2141
2142 data[0] = prefix;
2143}
2144
2145static int wacom_bamboo_pad_touch_event(struct wacom_wac *wacom,
2146 unsigned char *data)
2147{
Jason Gerecke2a6cdbd2015-06-15 18:01:45 -07002148 struct input_dev *input = wacom->touch_input;
Benjamin Tissoires8c97a762015-02-26 11:28:50 -05002149 unsigned char *finger_data, prefix;
2150 unsigned id;
2151 int x, y;
2152 bool valid;
2153
2154 prefix = data[0];
2155
2156 for (id = 0; id < wacom->features.touch_max; id++) {
2157 valid = !!(prefix & BIT(id)) &&
2158 !wacom->shared->stylus_in_proximity;
2159
2160 input_mt_slot(input, id);
2161 input_mt_report_slot_state(input, MT_TOOL_FINGER, valid);
2162
2163 if (!valid)
2164 continue;
2165
2166 finger_data = data + 1 + id * 3;
2167 x = finger_data[0] | ((finger_data[1] & 0x0f) << 8);
2168 y = (finger_data[2] << 4) | (finger_data[1] >> 4);
2169
2170 input_report_abs(input, ABS_MT_POSITION_X, x);
2171 input_report_abs(input, ABS_MT_POSITION_Y, y);
2172 }
2173
2174 input_mt_sync_frame(input);
2175
2176 input_report_key(input, BTN_LEFT, prefix & 0x40);
2177 input_report_key(input, BTN_RIGHT, prefix & 0x80);
2178
2179 /* keep touch state for pen event */
2180 wacom->shared->touch_down = !!prefix &&
2181 !wacom->shared->stylus_in_proximity;
2182
2183 return 1;
2184}
2185
2186static int wacom_bamboo_pad_irq(struct wacom_wac *wacom, size_t len)
2187{
2188 unsigned char *data = wacom->data;
2189
2190 if (!((len == WACOM_PKGLEN_BPAD_TOUCH) ||
2191 (len == WACOM_PKGLEN_BPAD_TOUCH_USB)) ||
2192 (data[0] != WACOM_REPORT_BPAD_TOUCH))
2193 return 0;
2194
2195 if (data[1] & 0x01)
2196 wacom_bamboo_pad_pen_event(wacom, &data[1]);
2197
2198 if (data[1] & 0x02)
2199 return wacom_bamboo_pad_touch_event(wacom, &data[9]);
2200
2201 return 0;
2202}
2203
Chris Bagwelld3825d52012-03-25 23:26:11 -07002204static int wacom_wireless_irq(struct wacom_wac *wacom, size_t len)
2205{
Chris Bagwell16bf2882012-03-25 23:26:20 -07002206 unsigned char *data = wacom->data;
2207 int connected;
2208
Ping Chengb5fd2a32013-11-25 18:44:55 -08002209 if (len != WACOM_PKGLEN_WIRELESS || data[0] != WACOM_REPORT_WL)
Chris Bagwelld3825d52012-03-25 23:26:11 -07002210 return 0;
2211
Chris Bagwell16bf2882012-03-25 23:26:20 -07002212 connected = data[1] & 0x01;
2213 if (connected) {
Jason Gereckeb0882cb2015-03-06 11:47:43 -08002214 int pid, battery, charging;
Chris Bagwell16bf2882012-03-25 23:26:20 -07002215
Ping Chengeda01da2015-09-23 13:51:15 -07002216 if ((wacom->shared->type == INTUOSHT ||
2217 wacom->shared->type == INTUOSHT2) &&
Ping Cheng44b96832014-11-06 17:30:51 -08002218 wacom->shared->touch_input &&
2219 wacom->shared->touch_max) {
Ping Cheng961794a2013-12-05 12:54:53 -08002220 input_report_switch(wacom->shared->touch_input,
2221 SW_MUTE_DEVICE, data[5] & 0x40);
2222 input_sync(wacom->shared->touch_input);
2223 }
2224
Chris Bagwell16bf2882012-03-25 23:26:20 -07002225 pid = get_unaligned_be16(&data[6]);
Benjamin Tissoiresac8d1012014-07-25 17:29:48 -07002226 battery = (data[5] & 0x3f) * 100 / 31;
Jason Gereckeb0882cb2015-03-06 11:47:43 -08002227 charging = !!(data[5] & 0x80);
Chris Bagwell16bf2882012-03-25 23:26:20 -07002228 if (wacom->pid != pid) {
2229 wacom->pid = pid;
2230 wacom_schedule_work(wacom);
2231 }
Benjamin Tissoiresac8d1012014-07-25 17:29:48 -07002232
Jason Gerecke953f2c52015-03-06 11:47:39 -08002233 if (wacom->shared->type)
Jason Gerecke71fa6412015-03-11 10:25:41 -07002234 wacom_notify_battery(wacom, battery, charging, 1, 0);
Jason Gerecke953f2c52015-03-06 11:47:39 -08002235
Chris Bagwell16bf2882012-03-25 23:26:20 -07002236 } else if (wacom->pid != 0) {
2237 /* disconnected while previously connected */
2238 wacom->pid = 0;
2239 wacom_schedule_work(wacom);
Jason Gerecke71fa6412015-03-11 10:25:41 -07002240 wacom_notify_battery(wacom, 0, 0, 0, 0);
Chris Bagwell16bf2882012-03-25 23:26:20 -07002241 }
2242
Chris Bagwelld3825d52012-03-25 23:26:11 -07002243 return 0;
2244}
2245
Jason Gerecke4ca4ec72015-03-06 11:47:38 -08002246static int wacom_status_irq(struct wacom_wac *wacom_wac, size_t len)
2247{
Jason Gerecke8f93b0b2015-03-06 11:47:41 -08002248 struct wacom *wacom = container_of(wacom_wac, struct wacom, wacom_wac);
Jason Gerecke4ca4ec72015-03-06 11:47:38 -08002249 struct wacom_features *features = &wacom_wac->features;
2250 unsigned char *data = wacom_wac->data;
2251
2252 if (data[0] != WACOM_REPORT_USB)
2253 return 0;
2254
Ping Chengeda01da2015-09-23 13:51:15 -07002255 if ((features->type == INTUOSHT ||
2256 features->type == INTUOSHT2) &&
Jason Gerecke4ca4ec72015-03-06 11:47:38 -08002257 wacom_wac->shared->touch_input &&
2258 features->touch_max) {
2259 input_report_switch(wacom_wac->shared->touch_input,
2260 SW_MUTE_DEVICE, data[8] & 0x40);
2261 input_sync(wacom_wac->shared->touch_input);
2262 }
Jason Gerecke8f93b0b2015-03-06 11:47:41 -08002263
2264 if (data[9] & 0x02) { /* wireless module is attached */
2265 int battery = (data[8] & 0x3f) * 100 / 31;
Jason Gereckeb0882cb2015-03-06 11:47:43 -08002266 bool charging = !!(data[8] & 0x80);
Jason Gerecke8f93b0b2015-03-06 11:47:41 -08002267
2268 wacom_notify_battery(wacom_wac, battery, charging,
Jason Gerecke71fa6412015-03-11 10:25:41 -07002269 battery || charging, 1);
Jason Gerecke8f93b0b2015-03-06 11:47:41 -08002270
Linus Torvalds8de29a32015-04-14 08:25:26 -08002271 if (!wacom->battery &&
Jason Gerecke8f93b0b2015-03-06 11:47:41 -08002272 !(features->quirks & WACOM_QUIRK_BATTERY)) {
2273 features->quirks |= WACOM_QUIRK_BATTERY;
2274 INIT_WORK(&wacom->work, wacom_battery_work);
2275 wacom_schedule_work(wacom_wac);
2276 }
2277 }
2278 else if ((features->quirks & WACOM_QUIRK_BATTERY) &&
Linus Torvalds8de29a32015-04-14 08:25:26 -08002279 wacom->battery) {
Jason Gerecke8f93b0b2015-03-06 11:47:41 -08002280 features->quirks &= ~WACOM_QUIRK_BATTERY;
2281 INIT_WORK(&wacom->work, wacom_battery_work);
2282 wacom_schedule_work(wacom_wac);
Jason Gerecke71fa6412015-03-11 10:25:41 -07002283 wacom_notify_battery(wacom_wac, 0, 0, 0, 0);
Jason Gerecke8f93b0b2015-03-06 11:47:41 -08002284 }
Jason Gerecke4ca4ec72015-03-06 11:47:38 -08002285 return 0;
2286}
2287
Dmitry Torokhov95dd3b32010-03-19 22:18:15 -07002288void wacom_wac_irq(struct wacom_wac *wacom_wac, size_t len)
Ping Cheng3bea7332006-07-13 18:01:36 -07002289{
Dmitry Torokhov95dd3b32010-03-19 22:18:15 -07002290 bool sync;
2291
Jason Childse33da8a2010-02-17 22:38:31 -08002292 switch (wacom_wac->features.type) {
Dmitry Torokhov73a97f42010-03-19 22:18:15 -07002293 case PENPARTNER:
Dmitry Torokhov95dd3b32010-03-19 22:18:15 -07002294 sync = wacom_penpartner_irq(wacom_wac);
2295 break;
Ping Cheng545f4e92008-11-24 11:44:27 -05002296
Dmitry Torokhov73a97f42010-03-19 22:18:15 -07002297 case PL:
Dmitry Torokhov95dd3b32010-03-19 22:18:15 -07002298 sync = wacom_pl_irq(wacom_wac);
2299 break;
Ping Cheng545f4e92008-11-24 11:44:27 -05002300
Dmitry Torokhov73a97f42010-03-19 22:18:15 -07002301 case WACOM_G4:
2302 case GRAPHIRE:
Benjamin Tissoires387142b2014-08-06 13:52:56 -07002303 case GRAPHIRE_BT:
Dmitry Torokhov73a97f42010-03-19 22:18:15 -07002304 case WACOM_MO:
Dmitry Torokhov95dd3b32010-03-19 22:18:15 -07002305 sync = wacom_graphire_irq(wacom_wac);
2306 break;
Ping Cheng545f4e92008-11-24 11:44:27 -05002307
Dmitry Torokhov73a97f42010-03-19 22:18:15 -07002308 case PTU:
Dmitry Torokhov95dd3b32010-03-19 22:18:15 -07002309 sync = wacom_ptu_irq(wacom_wac);
2310 break;
Ping Cheng545f4e92008-11-24 11:44:27 -05002311
Ping Chengc8f2edc2010-06-28 01:10:51 -07002312 case DTU:
2313 sync = wacom_dtu_irq(wacom_wac);
2314 break;
2315
Ping Cheng497ab1f2014-01-20 20:18:04 -08002316 case DTUS:
Ping Chengfff00bf2014-12-04 18:23:04 -08002317 case DTUSX:
Ping Cheng497ab1f2014-01-20 20:18:04 -08002318 sync = wacom_dtus_irq(wacom_wac);
2319 break;
2320
Dmitry Torokhov73a97f42010-03-19 22:18:15 -07002321 case INTUOS:
2322 case INTUOS3S:
2323 case INTUOS3:
2324 case INTUOS3L:
2325 case INTUOS4S:
2326 case INTUOS4:
2327 case INTUOS4L:
2328 case CINTIQ:
2329 case WACOM_BEE:
Ping Cheng56218562013-05-05 19:56:18 -07002330 case WACOM_13HD:
Ping Cheng3a4b4aa2010-06-03 22:10:21 -07002331 case WACOM_21UX2:
Ping Chengd838c642012-07-24 23:54:11 -07002332 case WACOM_22HD:
Jason Gerecke803296b2011-12-12 00:11:45 -08002333 case WACOM_24HD:
Ping Cheng500d4162015-01-27 13:30:03 -08002334 case WACOM_27QHD:
Ping Chenga112e9f2013-02-13 20:20:01 -08002335 case DTK:
Jason Gerecke36d3c512013-09-20 09:47:35 -07002336 case CINTIQ_HYBRID:
Jason Gereckef7acb552015-10-13 10:03:49 -07002337 case CINTIQ_COMPANION_2:
Dmitry Torokhov95dd3b32010-03-19 22:18:15 -07002338 sync = wacom_intuos_irq(wacom_wac);
2339 break;
Ping Cheng545f4e92008-11-24 11:44:27 -05002340
Benjamin Tissoires81af7e62014-08-06 13:55:56 -07002341 case INTUOS4WL:
2342 sync = wacom_intuos_bt_irq(wacom_wac, len);
2343 break;
2344
Jason Gereckeb1e42792012-10-21 00:38:04 -07002345 case WACOM_24HDT:
Ping Cheng500d4162015-01-27 13:30:03 -08002346 case WACOM_27QHDT:
Jason Gereckeb1e42792012-10-21 00:38:04 -07002347 sync = wacom_24hdt_irq(wacom_wac);
2348 break;
2349
Jason Gereckeae584ca2012-04-03 15:50:40 -07002350 case INTUOS5S:
2351 case INTUOS5:
2352 case INTUOS5L:
Ping Cheng9a35c412013-09-20 09:51:56 -07002353 case INTUOSPS:
2354 case INTUOSPM:
2355 case INTUOSPL:
Jason Gereckeae584ca2012-04-03 15:50:40 -07002356 if (len == WACOM_PKGLEN_BBTOUCH3)
2357 sync = wacom_bpt3_touch(wacom_wac);
Jason Gerecke2d13a432015-03-06 11:47:42 -08002358 else if (wacom_wac->data[0] == WACOM_REPORT_USB)
2359 sync = wacom_status_irq(wacom_wac, len);
Jason Gereckeae584ca2012-04-03 15:50:40 -07002360 else
2361 sync = wacom_intuos_irq(wacom_wac);
2362 break;
2363
Dmitry Torokhov73a97f42010-03-19 22:18:15 -07002364 case TABLETPC:
Ping Chengac173832012-06-12 00:15:06 -07002365 case TABLETPCE:
Dmitry Torokhov73a97f42010-03-19 22:18:15 -07002366 case TABLETPC2FG:
Ping Cheng19635182012-04-29 21:09:18 -07002367 case MTSCREEN:
Ping Cheng6afdc282012-11-03 12:16:15 -07002368 case MTTPC:
Jason Gerecked51ddb22014-05-14 17:14:29 -07002369 case MTTPC_B:
Dmitry Torokhov95dd3b32010-03-19 22:18:15 -07002370 sync = wacom_tpc_irq(wacom_wac, len);
2371 break;
Ping Cheng545f4e92008-11-24 11:44:27 -05002372
Henrik Rydbergcb734c02010-09-05 12:53:16 -07002373 case BAMBOO_PT:
Ping Cheng3b164a02015-09-23 09:59:10 -07002374 case BAMBOO_PEN:
2375 case BAMBOO_TOUCH:
Ping Chengb5fd2a32013-11-25 18:44:55 -08002376 case INTUOSHT:
Ping Chengeda01da2015-09-23 13:51:15 -07002377 case INTUOSHT2:
Jason Gerecke4ca4ec72015-03-06 11:47:38 -08002378 if (wacom_wac->data[0] == WACOM_REPORT_USB)
2379 sync = wacom_status_irq(wacom_wac, len);
2380 else
2381 sync = wacom_bpt_irq(wacom_wac, len);
Henrik Rydbergcb734c02010-09-05 12:53:16 -07002382 break;
2383
Benjamin Tissoires8c97a762015-02-26 11:28:50 -05002384 case BAMBOO_PAD:
2385 sync = wacom_bamboo_pad_irq(wacom_wac, len);
Ping Cheng3bea7332006-07-13 18:01:36 -07002386 break;
2387
Chris Bagwelld3825d52012-03-25 23:26:11 -07002388 case WIRELESS:
2389 sync = wacom_wireless_irq(wacom_wac, len);
2390 break;
2391
Aaron Skomra72b236d2015-08-20 16:05:17 -07002392 case REMOTE:
2393 if (wacom_wac->data[0] == WACOM_REPORT_DEVICE_LIST)
2394 sync = wacom_remote_status_irq(wacom_wac, len);
2395 else
2396 sync = wacom_remote_irq(wacom_wac, len);
2397 break;
2398
Dmitry Torokhov73a97f42010-03-19 22:18:15 -07002399 default:
Dmitry Torokhov95dd3b32010-03-19 22:18:15 -07002400 sync = false;
2401 break;
Ping Cheng3bea7332006-07-13 18:01:36 -07002402 }
Dmitry Torokhov95dd3b32010-03-19 22:18:15 -07002403
Benjamin Tissoiresd2d13f12014-07-24 12:48:28 -07002404 if (sync) {
Jason Gerecke2a6cdbd2015-06-15 18:01:45 -07002405 if (wacom_wac->pen_input)
2406 input_sync(wacom_wac->pen_input);
2407 if (wacom_wac->touch_input)
2408 input_sync(wacom_wac->touch_input);
Benjamin Tissoiresd2d13f12014-07-24 12:48:28 -07002409 if (wacom_wac->pad_input)
2410 input_sync(wacom_wac->pad_input);
2411 }
Ping Cheng3bea7332006-07-13 18:01:36 -07002412}
2413
Ping Chengeda01da2015-09-23 13:51:15 -07002414static void wacom_setup_basic_pro_pen(struct wacom_wac *wacom_wac)
Ping Cheng3bea7332006-07-13 18:01:36 -07002415{
Jason Gerecke2a6cdbd2015-06-15 18:01:45 -07002416 struct input_dev *input_dev = wacom_wac->pen_input;
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -07002417
2418 input_set_capability(input_dev, EV_MSC, MSC_SERIAL);
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -07002419
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -07002420 __set_bit(BTN_TOOL_PEN, input_dev->keybit);
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -07002421 __set_bit(BTN_STYLUS, input_dev->keybit);
2422 __set_bit(BTN_STYLUS2, input_dev->keybit);
2423
2424 input_set_abs_params(input_dev, ABS_DISTANCE,
2425 0, wacom_wac->features.distance_max, 0, 0);
Ping Chengeda01da2015-09-23 13:51:15 -07002426}
2427
2428static void wacom_setup_cintiq(struct wacom_wac *wacom_wac)
2429{
2430 struct input_dev *input_dev = wacom_wac->pen_input;
2431
2432 wacom_setup_basic_pro_pen(wacom_wac);
2433
2434 __set_bit(BTN_TOOL_RUBBER, input_dev->keybit);
2435 __set_bit(BTN_TOOL_BRUSH, input_dev->keybit);
2436 __set_bit(BTN_TOOL_PENCIL, input_dev->keybit);
2437 __set_bit(BTN_TOOL_AIRBRUSH, input_dev->keybit);
2438
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -07002439 input_set_abs_params(input_dev, ABS_WHEEL, 0, 1023, 0, 0);
Jason Gereckeec5fc1c2014-11-18 16:50:08 -08002440 input_set_abs_params(input_dev, ABS_TILT_X, -64, 63, 0, 0);
Jason Gerecke26fe4122014-11-18 16:50:09 -08002441 input_abs_set_res(input_dev, ABS_TILT_X, 57);
Jason Gereckeec5fc1c2014-11-18 16:50:08 -08002442 input_set_abs_params(input_dev, ABS_TILT_Y, -64, 63, 0, 0);
Jason Gerecke26fe4122014-11-18 16:50:09 -08002443 input_abs_set_res(input_dev, ABS_TILT_Y, 57);
Ping Cheng6521d0b2010-10-24 21:53:40 -07002444}
2445
2446static void wacom_setup_intuos(struct wacom_wac *wacom_wac)
2447{
Jason Gerecke2a6cdbd2015-06-15 18:01:45 -07002448 struct input_dev *input_dev = wacom_wac->pen_input;
Ping Cheng6521d0b2010-10-24 21:53:40 -07002449
2450 input_set_capability(input_dev, EV_REL, REL_WHEEL);
2451
2452 wacom_setup_cintiq(wacom_wac);
2453
2454 __set_bit(BTN_LEFT, input_dev->keybit);
2455 __set_bit(BTN_RIGHT, input_dev->keybit);
2456 __set_bit(BTN_MIDDLE, input_dev->keybit);
2457 __set_bit(BTN_SIDE, input_dev->keybit);
2458 __set_bit(BTN_EXTRA, input_dev->keybit);
2459 __set_bit(BTN_TOOL_MOUSE, input_dev->keybit);
2460 __set_bit(BTN_TOOL_LENS, input_dev->keybit);
2461
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -07002462 input_set_abs_params(input_dev, ABS_RZ, -900, 899, 0, 0);
Jason Gerecke26fe4122014-11-18 16:50:09 -08002463 input_abs_set_res(input_dev, ABS_RZ, 287);
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -07002464 input_set_abs_params(input_dev, ABS_THROTTLE, -1023, 1023, 0, 0);
2465}
2466
Ping Cheng42f4f272015-04-15 16:53:54 -07002467void wacom_setup_device_quirks(struct wacom *wacom)
Henrik Rydbergbc73dd32010-09-05 12:26:16 -07002468{
Ping Cheng42f4f272015-04-15 16:53:54 -07002469 struct wacom_features *features = &wacom->wacom_wac.features;
Henrik Rydbergbc73dd32010-09-05 12:26:16 -07002470
Jason Gerecke862cf552015-06-15 18:01:43 -07002471 /* The pen and pad share the same interface on most devices */
2472 if (features->type == GRAPHIRE_BT || features->type == WACOM_G4 ||
Ping Cheng3b164a02015-09-23 09:59:10 -07002473 features->type == DTUS ||
2474 (features->type >= INTUOS3S && features->type <= WACOM_MO)) {
Jason Gerecke862cf552015-06-15 18:01:43 -07002475 if (features->device_type & WACOM_DEVICETYPE_PEN)
2476 features->device_type |= WACOM_DEVICETYPE_PAD;
2477 }
Henrik Rydbergbc73dd32010-09-05 12:26:16 -07002478
2479 /* touch device found but size is not defined. use default */
Jason Gereckeaa86b182015-06-15 18:01:42 -07002480 if (features->device_type & WACOM_DEVICETYPE_TOUCH && !features->x_max) {
Henrik Rydbergbc73dd32010-09-05 12:26:16 -07002481 features->x_max = 1023;
2482 features->y_max = 1023;
2483 }
2484
Ping Cheng42f4f272015-04-15 16:53:54 -07002485 /*
2486 * Intuos5/Pro and Bamboo 3rd gen have no useful data about its
2487 * touch interface in its HID descriptor. If this is the touch
2488 * interface (PacketSize of WACOM_PKGLEN_BBTOUCH3), override the
2489 * tablet values.
2490 */
Ping Cheng3b164a02015-09-23 09:59:10 -07002491 if ((features->type >= INTUOS5S && features->type <= INTUOSPL) ||
2492 (features->type >= INTUOSHT && features->type <= BAMBOO_PT)) {
Ping Cheng42f4f272015-04-15 16:53:54 -07002493 if (features->pktlen == WACOM_PKGLEN_BBTOUCH3) {
Jason Gerecke862cf552015-06-15 18:01:43 -07002494 if (features->touch_max)
2495 features->device_type |= WACOM_DEVICETYPE_TOUCH;
Ping Cheng3b164a02015-09-23 09:59:10 -07002496 if (features->type >= INTUOSHT || features->type <= BAMBOO_PT)
Jason Gerecke862cf552015-06-15 18:01:43 -07002497 features->device_type |= WACOM_DEVICETYPE_PAD;
Ping Cheng42f4f272015-04-15 16:53:54 -07002498
2499 features->x_max = 4096;
2500 features->y_max = 4096;
Ping Cheng42f4f272015-04-15 16:53:54 -07002501 }
Jason Gerecke96339202015-07-01 13:01:00 -07002502 else if (features->pktlen == WACOM_PKGLEN_BBTOUCH) {
2503 features->device_type |= WACOM_DEVICETYPE_PAD;
2504 }
Ping Cheng42f4f272015-04-15 16:53:54 -07002505 }
2506
2507 /*
Jason Gerecke042628a2015-04-30 17:51:54 -07002508 * Raw Wacom-mode pen and touch events both come from interface
2509 * 0, whose HID descriptor has an application usage of 0xFF0D
2510 * (i.e., WACOM_VENDORDEFINED_PEN). We route pen packets back
2511 * out through the HID_GENERIC device created for interface 1,
Benjamin Tissoires70caee02015-07-09 14:11:51 -04002512 * so rewrite this one to be of type WACOM_DEVICETYPE_TOUCH.
Ping Cheng42f4f272015-04-15 16:53:54 -07002513 */
2514 if (features->type == BAMBOO_PAD)
Benjamin Tissoires70caee02015-07-09 14:11:51 -04002515 features->device_type = WACOM_DEVICETYPE_TOUCH;
Ping Cheng42f4f272015-04-15 16:53:54 -07002516
Aaron Skomra72b236d2015-08-20 16:05:17 -07002517 if (features->type == REMOTE)
2518 features->device_type = WACOM_DEVICETYPE_PAD;
Ping Cheng42f4f272015-04-15 16:53:54 -07002519
2520 if (wacom->hdev->bus == BUS_BLUETOOTH)
2521 features->quirks |= WACOM_QUIRK_BATTERY;
2522
Chris Bagwell73149ab2011-10-26 22:34:21 -07002523 /* quirk for bamboo touch with 2 low res touches */
Henrik Rydbergcb734c02010-09-05 12:53:16 -07002524 if (features->type == BAMBOO_PT &&
Chris Bagwell73149ab2011-10-26 22:34:21 -07002525 features->pktlen == WACOM_PKGLEN_BBTOUCH) {
Henrik Rydbergf4ccbef2010-09-05 12:57:13 -07002526 features->x_max <<= 5;
2527 features->y_max <<= 5;
2528 features->x_fuzz <<= 5;
2529 features->y_fuzz <<= 5;
Henrik Rydbergf4ccbef2010-09-05 12:57:13 -07002530 features->quirks |= WACOM_QUIRK_BBTOUCH_LOWRES;
Henrik Rydbergcb734c02010-09-05 12:53:16 -07002531 }
Chris Bagwelld3825d52012-03-25 23:26:11 -07002532
2533 if (features->type == WIRELESS) {
Jason Gereckeccad85c2015-08-03 10:17:04 -07002534 if (features->device_type == WACOM_DEVICETYPE_WL_MONITOR) {
Benjamin Tissoiresac8d1012014-07-25 17:29:48 -07002535 features->quirks |= WACOM_QUIRK_BATTERY;
2536 }
Chris Bagwelld3825d52012-03-25 23:26:11 -07002537 }
Henrik Rydbergbc73dd32010-09-05 12:26:16 -07002538}
2539
Jason Gerecke2636a3f2015-06-15 18:01:44 -07002540int wacom_setup_pen_input_capabilities(struct input_dev *input_dev,
Ping Cheng19635182012-04-29 21:09:18 -07002541 struct wacom_wac *wacom_wac)
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -07002542{
2543 struct wacom_features *features = &wacom_wac->features;
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -07002544
2545 input_dev->evbit[0] |= BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS);
2546
Jason Gerecke2636a3f2015-06-15 18:01:44 -07002547 if (!(features->device_type & WACOM_DEVICETYPE_PEN))
2548 return -ENODEV;
2549
Benjamin Tissoires7704ac92014-09-23 12:08:08 -04002550 if (features->type == HID_GENERIC)
2551 /* setup has already been done */
2552 return 0;
2553
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -07002554 __set_bit(BTN_TOUCH, input_dev->keybit);
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -07002555 __set_bit(ABS_MISC, input_dev->absbit);
2556
Jason Gerecke2636a3f2015-06-15 18:01:44 -07002557 input_set_abs_params(input_dev, ABS_X, features->x_min,
2558 features->x_max, features->x_fuzz, 0);
2559 input_set_abs_params(input_dev, ABS_Y, features->y_min,
2560 features->y_max, features->y_fuzz, 0);
2561 input_set_abs_params(input_dev, ABS_PRESSURE, 0,
2562 features->pressure_max, features->pressure_fuzz, 0);
2563
2564 /* penabled devices have fixed resolution for each model */
2565 input_abs_set_res(input_dev, ABS_X, features->x_resolution);
2566 input_abs_set_res(input_dev, ABS_Y, features->y_resolution);
2567
Ping Cheng8c0e0a42013-01-04 23:53:52 -08002568
Ping Cheng497ab1f2014-01-20 20:18:04 -08002569 switch (features->type) {
Ping Chenga2f71c62015-01-27 13:29:36 -08002570 case GRAPHIRE_BT:
2571 __clear_bit(ABS_MISC, input_dev->absbit);
2572
Dmitry Torokhov73a97f42010-03-19 22:18:15 -07002573 case WACOM_MO:
Dmitry Torokhov73a97f42010-03-19 22:18:15 -07002574 case WACOM_G4:
Ping Chenga2f71c62015-01-27 13:29:36 -08002575 input_set_abs_params(input_dev, ABS_DISTANCE, 0,
2576 features->distance_max,
2577 0, 0);
Dmitry Torokhov73a97f42010-03-19 22:18:15 -07002578 /* fall through */
2579
2580 case GRAPHIRE:
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -07002581 input_set_capability(input_dev, EV_REL, REL_WHEEL);
2582
2583 __set_bit(BTN_LEFT, input_dev->keybit);
2584 __set_bit(BTN_RIGHT, input_dev->keybit);
2585 __set_bit(BTN_MIDDLE, input_dev->keybit);
2586
2587 __set_bit(BTN_TOOL_RUBBER, input_dev->keybit);
2588 __set_bit(BTN_TOOL_PEN, input_dev->keybit);
2589 __set_bit(BTN_TOOL_MOUSE, input_dev->keybit);
2590 __set_bit(BTN_STYLUS, input_dev->keybit);
2591 __set_bit(BTN_STYLUS2, input_dev->keybit);
Jason Gerecke35120692011-09-08 09:38:14 -07002592
2593 __set_bit(INPUT_PROP_POINTER, input_dev->propbit);
Dmitry Torokhov73a97f42010-03-19 22:18:15 -07002594 break;
2595
Ping Cheng500d4162015-01-27 13:30:03 -08002596 case WACOM_27QHD:
Jason Gerecke803296b2011-12-12 00:11:45 -08002597 case WACOM_24HD:
Ping Chenga112e9f2013-02-13 20:20:01 -08002598 case DTK:
Ping Chengd838c642012-07-24 23:54:11 -07002599 case WACOM_22HD:
Ping Cheng3a4b4aa2010-06-03 22:10:21 -07002600 case WACOM_21UX2:
Dmitry Torokhov73a97f42010-03-19 22:18:15 -07002601 case WACOM_BEE:
Ping Cheng6521d0b2010-10-24 21:53:40 -07002602 case CINTIQ:
Ping Cheng56218562013-05-05 19:56:18 -07002603 case WACOM_13HD:
Ping Chenga2f71c62015-01-27 13:29:36 -08002604 case CINTIQ_HYBRID:
Jason Gereckef7acb552015-10-13 10:03:49 -07002605 case CINTIQ_COMPANION_2:
Ping Cheng56218562013-05-05 19:56:18 -07002606 input_set_abs_params(input_dev, ABS_Z, -900, 899, 0, 0);
Jason Gerecke26fe4122014-11-18 16:50:09 -08002607 input_abs_set_res(input_dev, ABS_Z, 287);
Ping Cheng56218562013-05-05 19:56:18 -07002608 __set_bit(INPUT_PROP_DIRECT, input_dev->propbit);
2609 wacom_setup_cintiq(wacom_wac);
2610 break;
2611
Dmitry Torokhov73a97f42010-03-19 22:18:15 -07002612 case INTUOS3:
2613 case INTUOS3L:
Dmitry Torokhov73a97f42010-03-19 22:18:15 -07002614 case INTUOS3S:
Ping Chenga2f71c62015-01-27 13:29:36 -08002615 case INTUOS4:
2616 case INTUOS4WL:
2617 case INTUOS4L:
2618 case INTUOS4S:
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -07002619 input_set_abs_params(input_dev, ABS_Z, -900, 899, 0, 0);
Jason Gerecke26fe4122014-11-18 16:50:09 -08002620 input_abs_set_res(input_dev, ABS_Z, 287);
Dmitry Torokhov73a97f42010-03-19 22:18:15 -07002621 /* fall through */
2622
2623 case INTUOS:
Jason Gerecke35120692011-09-08 09:38:14 -07002624 __set_bit(INPUT_PROP_POINTER, input_dev->propbit);
2625
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -07002626 wacom_setup_intuos(wacom_wac);
Dmitry Torokhov73a97f42010-03-19 22:18:15 -07002627 break;
2628
Jason Gerecke9fee6192012-04-03 15:47:22 -07002629 case INTUOS5:
2630 case INTUOS5L:
Ping Cheng9a35c412013-09-20 09:51:56 -07002631 case INTUOSPM:
2632 case INTUOSPL:
Jason Gereckeae584ca2012-04-03 15:50:40 -07002633 case INTUOS5S:
Ping Cheng9a35c412013-09-20 09:51:56 -07002634 case INTUOSPS:
Jason Gereckeae584ca2012-04-03 15:50:40 -07002635 __set_bit(INPUT_PROP_POINTER, input_dev->propbit);
2636
Jason Gerecke2636a3f2015-06-15 18:01:44 -07002637 input_set_abs_params(input_dev, ABS_DISTANCE, 0,
2638 features->distance_max,
2639 0, 0);
Jason Gereckeae584ca2012-04-03 15:50:40 -07002640
Jason Gerecke2636a3f2015-06-15 18:01:44 -07002641 input_set_abs_params(input_dev, ABS_Z, -900, 899, 0, 0);
2642 input_abs_set_res(input_dev, ABS_Z, 287);
Jason Gereckeae584ca2012-04-03 15:50:40 -07002643
Jason Gerecke2636a3f2015-06-15 18:01:44 -07002644 wacom_setup_intuos(wacom_wac);
Jason Gereckeae584ca2012-04-03 15:50:40 -07002645 break;
2646
Jason Gereckeb1e42792012-10-21 00:38:04 -07002647 case WACOM_24HDT:
Ping Cheng500d4162015-01-27 13:30:03 -08002648 case WACOM_27QHDT:
Ping Cheng19635182012-04-29 21:09:18 -07002649 case MTSCREEN:
Ping Cheng6afdc282012-11-03 12:16:15 -07002650 case MTTPC:
Jason Gerecked51ddb22014-05-14 17:14:29 -07002651 case MTTPC_B:
Ping Cheng6795a522012-06-28 16:49:00 -07002652 case TABLETPC2FG:
Dmitry Torokhov73a97f42010-03-19 22:18:15 -07002653 case TABLETPC:
Ping Chengac173832012-06-12 00:15:06 -07002654 case TABLETPCE:
Ping Chenga43c7c52011-03-12 20:34:42 -08002655 __clear_bit(ABS_MISC, input_dev->absbit);
Dmitry Torokhov73a97f42010-03-19 22:18:15 -07002656 /* fall through */
2657
Ping Cheng497ab1f2014-01-20 20:18:04 -08002658 case DTUS:
Ping Chengfff00bf2014-12-04 18:23:04 -08002659 case DTUSX:
Dmitry Torokhov73a97f42010-03-19 22:18:15 -07002660 case PL:
Ping Chengc8f2edc2010-06-28 01:10:51 -07002661 case DTU:
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -07002662 __set_bit(BTN_TOOL_PEN, input_dev->keybit);
Jason Gerecke35120692011-09-08 09:38:14 -07002663 __set_bit(BTN_TOOL_RUBBER, input_dev->keybit);
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -07002664 __set_bit(BTN_STYLUS, input_dev->keybit);
2665 __set_bit(BTN_STYLUS2, input_dev->keybit);
Jason Gerecke35120692011-09-08 09:38:14 -07002666
2667 __set_bit(INPUT_PROP_DIRECT, input_dev->propbit);
2668 break;
2669
2670 case PTU:
Dmitry Torokhov73a97f42010-03-19 22:18:15 -07002671 __set_bit(BTN_STYLUS2, input_dev->keybit);
2672 /* fall through */
2673
2674 case PENPARTNER:
Jason Gerecke1fab84a2011-08-26 23:18:22 -07002675 __set_bit(BTN_TOOL_PEN, input_dev->keybit);
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -07002676 __set_bit(BTN_TOOL_RUBBER, input_dev->keybit);
Jason Gerecke1fab84a2011-08-26 23:18:22 -07002677 __set_bit(BTN_STYLUS, input_dev->keybit);
Jason Gerecke35120692011-09-08 09:38:14 -07002678
2679 __set_bit(INPUT_PROP_POINTER, input_dev->propbit);
Dmitry Torokhov73a97f42010-03-19 22:18:15 -07002680 break;
Henrik Rydbergcb734c02010-09-05 12:53:16 -07002681
Ping Chengb5fd2a32013-11-25 18:44:55 -08002682 case INTUOSHT:
Henrik Rydbergcb734c02010-09-05 12:53:16 -07002683 case BAMBOO_PT:
Ping Cheng3b164a02015-09-23 09:59:10 -07002684 case BAMBOO_PEN:
Ping Chengeda01da2015-09-23 13:51:15 -07002685 case INTUOSHT2:
Jason Gerecke2636a3f2015-06-15 18:01:44 -07002686 __set_bit(INPUT_PROP_POINTER, input_dev->propbit);
Ping Chengeda01da2015-09-23 13:51:15 -07002687
2688 if (features->type == INTUOSHT2) {
2689 wacom_setup_basic_pro_pen(wacom_wac);
2690 } else {
2691 __clear_bit(ABS_MISC, input_dev->absbit);
2692 __set_bit(BTN_TOOL_PEN, input_dev->keybit);
2693 __set_bit(BTN_TOOL_RUBBER, input_dev->keybit);
2694 __set_bit(BTN_STYLUS, input_dev->keybit);
2695 __set_bit(BTN_STYLUS2, input_dev->keybit);
2696 input_set_abs_params(input_dev, ABS_DISTANCE, 0,
Jason Gerecke2636a3f2015-06-15 18:01:44 -07002697 features->distance_max,
2698 0, 0);
Ping Chengeda01da2015-09-23 13:51:15 -07002699 }
Henrik Rydbergcb734c02010-09-05 12:53:16 -07002700 break;
Benjamin Tissoires8c97a762015-02-26 11:28:50 -05002701 case BAMBOO_PAD:
2702 __clear_bit(ABS_MISC, input_dev->absbit);
Jason Gerecke2636a3f2015-06-15 18:01:44 -07002703 break;
2704 }
2705 return 0;
2706}
2707
2708int wacom_setup_touch_input_capabilities(struct input_dev *input_dev,
2709 struct wacom_wac *wacom_wac)
2710{
2711 struct wacom_features *features = &wacom_wac->features;
2712
2713 input_dev->evbit[0] |= BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS);
2714
2715 if (!(features->device_type & WACOM_DEVICETYPE_TOUCH))
2716 return -ENODEV;
2717
2718 if (features->type == HID_GENERIC)
2719 /* setup has already been done */
2720 return 0;
2721
2722 __set_bit(BTN_TOUCH, input_dev->keybit);
2723
2724 if (features->touch_max == 1) {
2725 input_set_abs_params(input_dev, ABS_X, 0,
2726 features->x_max, features->x_fuzz, 0);
2727 input_set_abs_params(input_dev, ABS_Y, 0,
2728 features->y_max, features->y_fuzz, 0);
2729 input_abs_set_res(input_dev, ABS_X,
2730 features->x_resolution);
2731 input_abs_set_res(input_dev, ABS_Y,
2732 features->y_resolution);
2733 }
2734 else if (features->touch_max > 1) {
2735 input_set_abs_params(input_dev, ABS_MT_POSITION_X, 0,
2736 features->x_max, features->x_fuzz, 0);
2737 input_set_abs_params(input_dev, ABS_MT_POSITION_Y, 0,
2738 features->y_max, features->y_fuzz, 0);
2739 input_abs_set_res(input_dev, ABS_MT_POSITION_X,
2740 features->x_resolution);
2741 input_abs_set_res(input_dev, ABS_MT_POSITION_Y,
2742 features->y_resolution);
2743 }
2744
2745 switch (features->type) {
2746 case INTUOS5:
2747 case INTUOS5L:
2748 case INTUOSPM:
2749 case INTUOSPL:
2750 case INTUOS5S:
2751 case INTUOSPS:
2752 __set_bit(INPUT_PROP_POINTER, input_dev->propbit);
2753
2754 input_set_abs_params(input_dev, ABS_MT_TOUCH_MAJOR, 0, features->x_max, 0, 0);
2755 input_set_abs_params(input_dev, ABS_MT_TOUCH_MINOR, 0, features->y_max, 0, 0);
2756 input_mt_init_slots(input_dev, features->touch_max, INPUT_MT_POINTER);
2757 break;
2758
2759 case WACOM_24HDT:
2760 input_set_abs_params(input_dev, ABS_MT_TOUCH_MAJOR, 0, features->x_max, 0, 0);
2761 input_set_abs_params(input_dev, ABS_MT_WIDTH_MAJOR, 0, features->x_max, 0, 0);
2762 input_set_abs_params(input_dev, ABS_MT_WIDTH_MINOR, 0, features->y_max, 0, 0);
2763 input_set_abs_params(input_dev, ABS_MT_ORIENTATION, 0, 1, 0, 0);
2764 /* fall through */
2765
2766 case WACOM_27QHDT:
2767 case MTSCREEN:
2768 case MTTPC:
2769 case MTTPC_B:
2770 case TABLETPC2FG:
2771 input_mt_init_slots(input_dev, features->touch_max, INPUT_MT_DIRECT);
2772 /*fall through */
2773
2774 case TABLETPC:
2775 case TABLETPCE:
2776 __set_bit(INPUT_PROP_DIRECT, input_dev->propbit);
2777 break;
2778
2779 case INTUOSHT:
Ping Chengeda01da2015-09-23 13:51:15 -07002780 case INTUOSHT2:
Jason Gerecke2636a3f2015-06-15 18:01:44 -07002781 input_dev->evbit[0] |= BIT_MASK(EV_SW);
2782 __set_bit(SW_MUTE_DEVICE, input_dev->swbit);
2783 /* fall through */
2784
2785 case BAMBOO_PT:
Ping Cheng3b164a02015-09-23 09:59:10 -07002786 case BAMBOO_TOUCH:
Jason Gerecke2636a3f2015-06-15 18:01:44 -07002787 if (features->pktlen == WACOM_PKGLEN_BBTOUCH3) {
2788 input_set_abs_params(input_dev,
2789 ABS_MT_TOUCH_MAJOR,
2790 0, features->x_max, 0, 0);
2791 input_set_abs_params(input_dev,
2792 ABS_MT_TOUCH_MINOR,
2793 0, features->y_max, 0, 0);
2794 }
2795 input_mt_init_slots(input_dev, features->touch_max, INPUT_MT_POINTER);
2796 break;
2797
2798 case BAMBOO_PAD:
Benjamin Tissoires8c97a762015-02-26 11:28:50 -05002799 input_mt_init_slots(input_dev, features->touch_max,
2800 INPUT_MT_POINTER);
2801 __set_bit(BTN_LEFT, input_dev->keybit);
2802 __set_bit(BTN_RIGHT, input_dev->keybit);
2803 break;
Ping Cheng3bea7332006-07-13 18:01:36 -07002804 }
Ping Cheng19635182012-04-29 21:09:18 -07002805 return 0;
Ping Cheng3bea7332006-07-13 18:01:36 -07002806}
2807
Jiri Kosina5397df12015-08-28 20:46:42 +02002808static void wacom_setup_numbered_buttons(struct input_dev *input_dev,
Aaron Skomra70ee06c2015-08-20 16:05:16 -07002809 int button_count)
2810{
2811 int i;
2812
2813 for (i = 0; i < button_count && i < 10; i++)
2814 __set_bit(BTN_0 + i, input_dev->keybit);
2815 for (i = 10; i < button_count && i < 16; i++)
2816 __set_bit(BTN_A + (i-10), input_dev->keybit);
2817 for (i = 16; i < button_count && i < 18; i++)
2818 __set_bit(BTN_BASE + (i-16), input_dev->keybit);
2819}
2820
Benjamin Tissoiresd2d13f12014-07-24 12:48:28 -07002821int wacom_setup_pad_input_capabilities(struct input_dev *input_dev,
2822 struct wacom_wac *wacom_wac)
2823{
2824 struct wacom_features *features = &wacom_wac->features;
2825
Jason Gerecke862cf552015-06-15 18:01:43 -07002826 if (!(features->device_type & WACOM_DEVICETYPE_PAD))
2827 return -ENODEV;
2828
Benjamin Tissoiresd2d13f12014-07-24 12:48:28 -07002829 input_dev->evbit[0] |= BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS);
2830
2831 /* kept for making legacy xf86-input-wacom working with the wheels */
2832 __set_bit(ABS_MISC, input_dev->absbit);
2833
2834 /* kept for making legacy xf86-input-wacom accepting the pad */
2835 input_set_abs_params(input_dev, ABS_X, 0, 1, 0, 0);
2836 input_set_abs_params(input_dev, ABS_Y, 0, 1, 0, 0);
2837
Benjamin Tissoires12969e32014-09-11 13:14:04 -04002838 /* kept for making udev and libwacom accepting the pad */
2839 __set_bit(BTN_STYLUS, input_dev->keybit);
2840
Aaron Skomra70ee06c2015-08-20 16:05:16 -07002841 wacom_setup_numbered_buttons(input_dev, features->numbered_buttons);
2842
Benjamin Tissoiresd2d13f12014-07-24 12:48:28 -07002843 switch (features->type) {
Aaron Skomra70ee06c2015-08-20 16:05:16 -07002844
2845 case CINTIQ_HYBRID:
Jason Gereckef7acb552015-10-13 10:03:49 -07002846 case CINTIQ_COMPANION_2:
Aaron Skomra70ee06c2015-08-20 16:05:16 -07002847 case DTK:
2848 case DTUS:
Benjamin Tissoires387142b2014-08-06 13:52:56 -07002849 case GRAPHIRE_BT:
Benjamin Tissoires387142b2014-08-06 13:52:56 -07002850 break;
2851
Benjamin Tissoires38138102014-07-24 12:51:03 -07002852 case WACOM_MO:
2853 __set_bit(BTN_BACK, input_dev->keybit);
2854 __set_bit(BTN_LEFT, input_dev->keybit);
2855 __set_bit(BTN_FORWARD, input_dev->keybit);
2856 __set_bit(BTN_RIGHT, input_dev->keybit);
2857 input_set_abs_params(input_dev, ABS_WHEEL, 0, 71, 0, 0);
2858 break;
2859
2860 case WACOM_G4:
2861 __set_bit(BTN_BACK, input_dev->keybit);
Benjamin Tissoires38138102014-07-24 12:51:03 -07002862 __set_bit(BTN_FORWARD, input_dev->keybit);
Benjamin Tissoires38138102014-07-24 12:51:03 -07002863 input_set_capability(input_dev, EV_REL, REL_WHEEL);
2864 break;
2865
Benjamin Tissoires10059cdc2014-07-24 12:49:08 -07002866 case WACOM_24HD:
Benjamin Tissoires10059cdc2014-07-24 12:49:08 -07002867 __set_bit(KEY_PROG1, input_dev->keybit);
2868 __set_bit(KEY_PROG2, input_dev->keybit);
2869 __set_bit(KEY_PROG3, input_dev->keybit);
2870
2871 input_set_abs_params(input_dev, ABS_WHEEL, 0, 71, 0, 0);
2872 input_set_abs_params(input_dev, ABS_THROTTLE, 0, 71, 0, 0);
2873 break;
2874
Ping Cheng500d4162015-01-27 13:30:03 -08002875 case WACOM_27QHD:
2876 __set_bit(KEY_PROG1, input_dev->keybit);
2877 __set_bit(KEY_PROG2, input_dev->keybit);
2878 __set_bit(KEY_PROG3, input_dev->keybit);
2879 input_set_abs_params(input_dev, ABS_X, -2048, 2048, 0, 0);
2880 input_abs_set_res(input_dev, ABS_X, 1024); /* points/g */
2881 input_set_abs_params(input_dev, ABS_Y, -2048, 2048, 0, 0);
2882 input_abs_set_res(input_dev, ABS_Y, 1024);
2883 input_set_abs_params(input_dev, ABS_Z, -2048, 2048, 0, 0);
2884 input_abs_set_res(input_dev, ABS_Z, 1024);
2885 __set_bit(INPUT_PROP_ACCELEROMETER, input_dev->propbit);
2886 break;
2887
Benjamin Tissoires10059cdc2014-07-24 12:49:08 -07002888 case WACOM_22HD:
2889 __set_bit(KEY_PROG1, input_dev->keybit);
2890 __set_bit(KEY_PROG2, input_dev->keybit);
2891 __set_bit(KEY_PROG3, input_dev->keybit);
2892 /* fall through */
2893
2894 case WACOM_21UX2:
Benjamin Tissoires10059cdc2014-07-24 12:49:08 -07002895 case WACOM_BEE:
Benjamin Tissoires10059cdc2014-07-24 12:49:08 -07002896 case CINTIQ:
Benjamin Tissoires10059cdc2014-07-24 12:49:08 -07002897 input_set_abs_params(input_dev, ABS_RX, 0, 4096, 0, 0);
2898 input_set_abs_params(input_dev, ABS_RY, 0, 4096, 0, 0);
2899 break;
2900
2901 case WACOM_13HD:
Benjamin Tissoires10059cdc2014-07-24 12:49:08 -07002902 input_set_abs_params(input_dev, ABS_WHEEL, 0, 71, 0, 0);
2903 break;
2904
2905 case INTUOS3:
2906 case INTUOS3L:
Benjamin Tissoires10059cdc2014-07-24 12:49:08 -07002907 input_set_abs_params(input_dev, ABS_RY, 0, 4096, 0, 0);
2908 /* fall through */
2909
2910 case INTUOS3S:
Benjamin Tissoires10059cdc2014-07-24 12:49:08 -07002911 input_set_abs_params(input_dev, ABS_RX, 0, 4096, 0, 0);
2912 break;
2913
2914 case INTUOS5:
2915 case INTUOS5L:
2916 case INTUOSPM:
2917 case INTUOSPL:
Benjamin Tissoires10059cdc2014-07-24 12:49:08 -07002918 case INTUOS5S:
2919 case INTUOSPS:
Benjamin Tissoires10059cdc2014-07-24 12:49:08 -07002920 input_set_abs_params(input_dev, ABS_WHEEL, 0, 71, 0, 0);
2921 break;
2922
Benjamin Tissoires81af7e62014-08-06 13:55:56 -07002923 case INTUOS4WL:
2924 /*
2925 * For Bluetooth devices, the udev rule does not work correctly
2926 * for pads unless we add a stylus capability, which forces
2927 * ID_INPUT_TABLET to be set.
2928 */
2929 __set_bit(BTN_STYLUS, input_dev->keybit);
2930 /* fall through */
2931
Benjamin Tissoires10059cdc2014-07-24 12:49:08 -07002932 case INTUOS4:
2933 case INTUOS4L:
Benjamin Tissoires10059cdc2014-07-24 12:49:08 -07002934 case INTUOS4S:
Benjamin Tissoires10059cdc2014-07-24 12:49:08 -07002935 input_set_abs_params(input_dev, ABS_WHEEL, 0, 71, 0, 0);
2936 break;
2937
Benjamin Tissoires31168712014-07-24 12:50:10 -07002938 case INTUOSHT:
2939 case BAMBOO_PT:
Ping Cheng3b164a02015-09-23 09:59:10 -07002940 case BAMBOO_TOUCH:
Ping Chengeda01da2015-09-23 13:51:15 -07002941 case INTUOSHT2:
Benjamin Tissoires31168712014-07-24 12:50:10 -07002942 __clear_bit(ABS_MISC, input_dev->absbit);
2943
2944 __set_bit(BTN_LEFT, input_dev->keybit);
2945 __set_bit(BTN_FORWARD, input_dev->keybit);
2946 __set_bit(BTN_BACK, input_dev->keybit);
2947 __set_bit(BTN_RIGHT, input_dev->keybit);
2948
2949 break;
2950
Aaron Skomra72b236d2015-08-20 16:05:17 -07002951 case REMOTE:
2952 input_set_capability(input_dev, EV_MSC, MSC_SERIAL);
2953 input_set_abs_params(input_dev, ABS_WHEEL, 0, 71, 0, 0);
2954 break;
2955
Benjamin Tissoiresd2d13f12014-07-24 12:48:28 -07002956 default:
2957 /* no pad supported */
Ping Chengb3c8e932014-11-18 13:27:48 -08002958 return -ENODEV;
Benjamin Tissoiresd2d13f12014-07-24 12:48:28 -07002959 }
2960 return 0;
2961}
2962
Dmitry Torokhove87a3442010-02-18 01:51:47 -08002963static const struct wacom_features wacom_features_0x00 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07002964 { "Wacom Penpartner", 5040, 3780, 255, 0,
2965 PENPARTNER, WACOM_PENPRTN_RES, WACOM_PENPRTN_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08002966static const struct wacom_features wacom_features_0x10 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07002967 { "Wacom Graphire", 10206, 7422, 511, 63,
2968 GRAPHIRE, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
Benjamin Tissoires387142b2014-08-06 13:52:56 -07002969static const struct wacom_features wacom_features_0x81 =
2970 { "Wacom Graphire BT", 16704, 12064, 511, 32,
Aaron Skomra70ee06c2015-08-20 16:05:16 -07002971 GRAPHIRE_BT, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES, 2 };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08002972static const struct wacom_features wacom_features_0x11 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07002973 { "Wacom Graphire2 4x5", 10206, 7422, 511, 63,
2974 GRAPHIRE, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08002975static const struct wacom_features wacom_features_0x12 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07002976 { "Wacom Graphire2 5x7", 13918, 10206, 511, 63,
2977 GRAPHIRE, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08002978static const struct wacom_features wacom_features_0x13 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07002979 { "Wacom Graphire3", 10208, 7424, 511, 63,
2980 GRAPHIRE, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08002981static const struct wacom_features wacom_features_0x14 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07002982 { "Wacom Graphire3 6x8", 16704, 12064, 511, 63,
2983 GRAPHIRE, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08002984static const struct wacom_features wacom_features_0x15 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07002985 { "Wacom Graphire4 4x5", 10208, 7424, 511, 63,
2986 WACOM_G4, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08002987static const struct wacom_features wacom_features_0x16 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07002988 { "Wacom Graphire4 6x8", 16704, 12064, 511, 63,
2989 WACOM_G4, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08002990static const struct wacom_features wacom_features_0x17 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07002991 { "Wacom BambooFun 4x5", 14760, 9225, 511, 63,
2992 WACOM_MO, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08002993static const struct wacom_features wacom_features_0x18 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07002994 { "Wacom BambooFun 6x8", 21648, 13530, 511, 63,
2995 WACOM_MO, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08002996static const struct wacom_features wacom_features_0x19 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07002997 { "Wacom Bamboo1 Medium", 16704, 12064, 511, 63,
2998 GRAPHIRE, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08002999static const struct wacom_features wacom_features_0x60 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003000 { "Wacom Volito", 5104, 3712, 511, 63,
3001 GRAPHIRE, WACOM_VOLITO_RES, WACOM_VOLITO_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08003002static const struct wacom_features wacom_features_0x61 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003003 { "Wacom PenStation2", 3250, 2320, 255, 63,
3004 GRAPHIRE, WACOM_VOLITO_RES, WACOM_VOLITO_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08003005static const struct wacom_features wacom_features_0x62 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003006 { "Wacom Volito2 4x5", 5104, 3712, 511, 63,
3007 GRAPHIRE, WACOM_VOLITO_RES, WACOM_VOLITO_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08003008static const struct wacom_features wacom_features_0x63 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003009 { "Wacom Volito2 2x3", 3248, 2320, 511, 63,
3010 GRAPHIRE, WACOM_VOLITO_RES, WACOM_VOLITO_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08003011static const struct wacom_features wacom_features_0x64 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003012 { "Wacom PenPartner2", 3250, 2320, 511, 63,
3013 GRAPHIRE, WACOM_VOLITO_RES, WACOM_VOLITO_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08003014static const struct wacom_features wacom_features_0x65 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003015 { "Wacom Bamboo", 14760, 9225, 511, 63,
3016 WACOM_MO, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08003017static const struct wacom_features wacom_features_0x69 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003018 { "Wacom Bamboo1", 5104, 3712, 511, 63,
3019 GRAPHIRE, WACOM_PENPRTN_RES, WACOM_PENPRTN_RES };
Ping Cheng11d0cf82011-06-27 12:57:58 -07003020static const struct wacom_features wacom_features_0x6A =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003021 { "Wacom Bamboo1 4x6", 14760, 9225, 1023, 63,
3022 GRAPHIRE, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Ping Cheng11d0cf82011-06-27 12:57:58 -07003023static const struct wacom_features wacom_features_0x6B =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003024 { "Wacom Bamboo1 5x8", 21648, 13530, 1023, 63,
3025 GRAPHIRE, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08003026static const struct wacom_features wacom_features_0x20 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003027 { "Wacom Intuos 4x5", 12700, 10600, 1023, 31,
3028 INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08003029static const struct wacom_features wacom_features_0x21 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003030 { "Wacom Intuos 6x8", 20320, 16240, 1023, 31,
3031 INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08003032static const struct wacom_features wacom_features_0x22 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003033 { "Wacom Intuos 9x12", 30480, 24060, 1023, 31,
3034 INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08003035static const struct wacom_features wacom_features_0x23 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003036 { "Wacom Intuos 12x12", 30480, 31680, 1023, 31,
3037 INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08003038static const struct wacom_features wacom_features_0x24 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003039 { "Wacom Intuos 12x18", 45720, 31680, 1023, 31,
3040 INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08003041static const struct wacom_features wacom_features_0x30 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003042 { "Wacom PL400", 5408, 4056, 255, 0,
3043 PL, WACOM_PL_RES, WACOM_PL_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08003044static const struct wacom_features wacom_features_0x31 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003045 { "Wacom PL500", 6144, 4608, 255, 0,
3046 PL, WACOM_PL_RES, WACOM_PL_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08003047static const struct wacom_features wacom_features_0x32 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003048 { "Wacom PL600", 6126, 4604, 255, 0,
3049 PL, WACOM_PL_RES, WACOM_PL_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08003050static const struct wacom_features wacom_features_0x33 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003051 { "Wacom PL600SX", 6260, 5016, 255, 0,
3052 PL, WACOM_PL_RES, WACOM_PL_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08003053static const struct wacom_features wacom_features_0x34 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003054 { "Wacom PL550", 6144, 4608, 511, 0,
3055 PL, WACOM_PL_RES, WACOM_PL_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08003056static const struct wacom_features wacom_features_0x35 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003057 { "Wacom PL800", 7220, 5780, 511, 0,
3058 PL, WACOM_PL_RES, WACOM_PL_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08003059static const struct wacom_features wacom_features_0x37 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003060 { "Wacom PL700", 6758, 5406, 511, 0,
3061 PL, WACOM_PL_RES, WACOM_PL_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08003062static const struct wacom_features wacom_features_0x38 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003063 { "Wacom PL510", 6282, 4762, 511, 0,
3064 PL, WACOM_PL_RES, WACOM_PL_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08003065static const struct wacom_features wacom_features_0x39 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003066 { "Wacom DTU710", 34080, 27660, 511, 0,
3067 PL, WACOM_PL_RES, WACOM_PL_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08003068static const struct wacom_features wacom_features_0xC4 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003069 { "Wacom DTF521", 6282, 4762, 511, 0,
3070 PL, WACOM_PL_RES, WACOM_PL_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08003071static const struct wacom_features wacom_features_0xC0 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003072 { "Wacom DTF720", 6858, 5506, 511, 0,
3073 PL, WACOM_PL_RES, WACOM_PL_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08003074static const struct wacom_features wacom_features_0xC2 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003075 { "Wacom DTF720a", 6858, 5506, 511, 0,
3076 PL, WACOM_PL_RES, WACOM_PL_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08003077static const struct wacom_features wacom_features_0x03 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003078 { "Wacom Cintiq Partner", 20480, 15360, 511, 0,
3079 PTU, WACOM_PL_RES, WACOM_PL_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08003080static const struct wacom_features wacom_features_0x41 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003081 { "Wacom Intuos2 4x5", 12700, 10600, 1023, 31,
3082 INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08003083static const struct wacom_features wacom_features_0x42 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003084 { "Wacom Intuos2 6x8", 20320, 16240, 1023, 31,
3085 INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08003086static const struct wacom_features wacom_features_0x43 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003087 { "Wacom Intuos2 9x12", 30480, 24060, 1023, 31,
3088 INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08003089static const struct wacom_features wacom_features_0x44 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003090 { "Wacom Intuos2 12x12", 30480, 31680, 1023, 31,
3091 INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08003092static const struct wacom_features wacom_features_0x45 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003093 { "Wacom Intuos2 12x18", 45720, 31680, 1023, 31,
3094 INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08003095static const struct wacom_features wacom_features_0xB0 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003096 { "Wacom Intuos3 4x5", 25400, 20320, 1023, 63,
Aaron Skomra70ee06c2015-08-20 16:05:16 -07003097 INTUOS3S, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 4 };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08003098static const struct wacom_features wacom_features_0xB1 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003099 { "Wacom Intuos3 6x8", 40640, 30480, 1023, 63,
Aaron Skomra70ee06c2015-08-20 16:05:16 -07003100 INTUOS3, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 8 };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08003101static const struct wacom_features wacom_features_0xB2 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003102 { "Wacom Intuos3 9x12", 60960, 45720, 1023, 63,
Aaron Skomra70ee06c2015-08-20 16:05:16 -07003103 INTUOS3, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 8 };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08003104static const struct wacom_features wacom_features_0xB3 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003105 { "Wacom Intuos3 12x12", 60960, 60960, 1023, 63,
Aaron Skomra70ee06c2015-08-20 16:05:16 -07003106 INTUOS3L, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 8 };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08003107static const struct wacom_features wacom_features_0xB4 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003108 { "Wacom Intuos3 12x19", 97536, 60960, 1023, 63,
Aaron Skomra70ee06c2015-08-20 16:05:16 -07003109 INTUOS3L, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 8 };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08003110static const struct wacom_features wacom_features_0xB5 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003111 { "Wacom Intuos3 6x11", 54204, 31750, 1023, 63,
Aaron Skomra70ee06c2015-08-20 16:05:16 -07003112 INTUOS3, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 8 };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08003113static const struct wacom_features wacom_features_0xB7 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003114 { "Wacom Intuos3 4x6", 31496, 19685, 1023, 63,
Aaron Skomra70ee06c2015-08-20 16:05:16 -07003115 INTUOS3S, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 4 };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08003116static const struct wacom_features wacom_features_0xB8 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003117 { "Wacom Intuos4 4x6", 31496, 19685, 2047, 63,
Aaron Skomra70ee06c2015-08-20 16:05:16 -07003118 INTUOS4S, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 7 };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08003119static const struct wacom_features wacom_features_0xB9 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003120 { "Wacom Intuos4 6x9", 44704, 27940, 2047, 63,
Aaron Skomra70ee06c2015-08-20 16:05:16 -07003121 INTUOS4, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9 };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08003122static const struct wacom_features wacom_features_0xBA =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003123 { "Wacom Intuos4 8x13", 65024, 40640, 2047, 63,
Aaron Skomra70ee06c2015-08-20 16:05:16 -07003124 INTUOS4L, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9 };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08003125static const struct wacom_features wacom_features_0xBB =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003126 { "Wacom Intuos4 12x19", 97536, 60960, 2047, 63,
Aaron Skomra70ee06c2015-08-20 16:05:16 -07003127 INTUOS4L, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9 };
Ping Cheng3a4b4aa2010-06-03 22:10:21 -07003128static const struct wacom_features wacom_features_0xBC =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003129 { "Wacom Intuos4 WL", 40640, 25400, 2047, 63,
Aaron Skomra70ee06c2015-08-20 16:05:16 -07003130 INTUOS4, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9 };
Benjamin Tissoires81af7e62014-08-06 13:55:56 -07003131static const struct wacom_features wacom_features_0xBD =
3132 { "Wacom Intuos4 WL", 40640, 25400, 2047, 63,
Aaron Skomra70ee06c2015-08-20 16:05:16 -07003133 INTUOS4WL, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9 };
Jason Gerecke9fee6192012-04-03 15:47:22 -07003134static const struct wacom_features wacom_features_0x26 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003135 { "Wacom Intuos5 touch S", 31496, 19685, 2047, 63,
Aaron Skomra70ee06c2015-08-20 16:05:16 -07003136 INTUOS5S, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 7, .touch_max = 16 };
Jason Gerecke9fee6192012-04-03 15:47:22 -07003137static const struct wacom_features wacom_features_0x27 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003138 { "Wacom Intuos5 touch M", 44704, 27940, 2047, 63,
Aaron Skomra70ee06c2015-08-20 16:05:16 -07003139 INTUOS5, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9, .touch_max = 16 };
Jason Gerecke9fee6192012-04-03 15:47:22 -07003140static const struct wacom_features wacom_features_0x28 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003141 { "Wacom Intuos5 touch L", 65024, 40640, 2047, 63,
Aaron Skomra70ee06c2015-08-20 16:05:16 -07003142 INTUOS5L, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9, .touch_max = 16 };
Jason Gerecke9fee6192012-04-03 15:47:22 -07003143static const struct wacom_features wacom_features_0x29 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003144 { "Wacom Intuos5 S", 31496, 19685, 2047, 63,
Aaron Skomra70ee06c2015-08-20 16:05:16 -07003145 INTUOS5S, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 7 };
Jason Gerecke9fee6192012-04-03 15:47:22 -07003146static const struct wacom_features wacom_features_0x2A =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003147 { "Wacom Intuos5 M", 44704, 27940, 2047, 63,
Aaron Skomra70ee06c2015-08-20 16:05:16 -07003148 INTUOS5, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9 };
Ping Cheng9a35c412013-09-20 09:51:56 -07003149static const struct wacom_features wacom_features_0x314 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003150 { "Wacom Intuos Pro S", 31496, 19685, 2047, 63,
Aaron Skomra70ee06c2015-08-20 16:05:16 -07003151 INTUOSPS, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 7, .touch_max = 16,
Benjamin Tissoires29b47392014-07-24 12:52:23 -07003152 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
Ping Cheng9a35c412013-09-20 09:51:56 -07003153static const struct wacom_features wacom_features_0x315 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003154 { "Wacom Intuos Pro M", 44704, 27940, 2047, 63,
Aaron Skomra70ee06c2015-08-20 16:05:16 -07003155 INTUOSPM, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9, .touch_max = 16,
Benjamin Tissoires29b47392014-07-24 12:52:23 -07003156 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
Ping Cheng9a35c412013-09-20 09:51:56 -07003157static const struct wacom_features wacom_features_0x317 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003158 { "Wacom Intuos Pro L", 65024, 40640, 2047, 63,
Aaron Skomra70ee06c2015-08-20 16:05:16 -07003159 INTUOSPL, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9, .touch_max = 16,
Benjamin Tissoires29b47392014-07-24 12:52:23 -07003160 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
Jason Gerecke803296b2011-12-12 00:11:45 -08003161static const struct wacom_features wacom_features_0xF4 =
Ping Chengecd618d2014-12-04 18:25:07 -08003162 { "Wacom Cintiq 24HD", 104080, 65200, 2047, 63,
Aaron Skomra70ee06c2015-08-20 16:05:16 -07003163 WACOM_24HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 16,
Ping Chengfa770342014-12-01 13:44:28 -08003164 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET };
Jason Gerecke6f4d0382012-08-21 22:11:59 -07003165static const struct wacom_features wacom_features_0xF8 =
Ping Chengecd618d2014-12-04 18:25:07 -08003166 { "Wacom Cintiq 24HD touch", 104080, 65200, 2047, 63, /* Pen */
Aaron Skomra70ee06c2015-08-20 16:05:16 -07003167 WACOM_24HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 16,
Ping Chengfa770342014-12-01 13:44:28 -08003168 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
Ping Cheng3bd1f7e2013-05-23 10:22:33 -07003169 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0xf6 };
Jason Gereckeb1e42792012-10-21 00:38:04 -07003170static const struct wacom_features wacom_features_0xF6 =
3171 { "Wacom Cintiq 24HD touch", .type = WACOM_24HDT, /* Touch */
Benjamin Tissoires29b47392014-07-24 12:52:23 -07003172 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0xf8, .touch_max = 10,
3173 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
Ping Cheng500d4162015-01-27 13:30:03 -08003174static const struct wacom_features wacom_features_0x32A =
Ping Chenga7e66452015-02-04 16:01:54 -08003175 { "Wacom Cintiq 27QHD", 119740, 67520, 2047, 63,
Aaron Skomra70ee06c2015-08-20 16:05:16 -07003176 WACOM_27QHD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 0,
Ping Chenga7e66452015-02-04 16:01:54 -08003177 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET };
Ping Cheng500d4162015-01-27 13:30:03 -08003178static const struct wacom_features wacom_features_0x32B =
3179 { "Wacom Cintiq 27QHD touch", 119740, 67520, 2047, 63,
Aaron Skomra70ee06c2015-08-20 16:05:16 -07003180 WACOM_27QHD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 0,
Ping Cheng500d4162015-01-27 13:30:03 -08003181 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
3182 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x32C };
3183static const struct wacom_features wacom_features_0x32C =
3184 { "Wacom Cintiq 27QHD touch", .type = WACOM_27QHDT,
3185 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x32B, .touch_max = 10 };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08003186static const struct wacom_features wacom_features_0x3F =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003187 { "Wacom Cintiq 21UX", 87200, 65600, 1023, 63,
Aaron Skomra70ee06c2015-08-20 16:05:16 -07003188 CINTIQ, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 8 };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08003189static const struct wacom_features wacom_features_0xC5 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003190 { "Wacom Cintiq 20WSX", 86680, 54180, 1023, 63,
Aaron Skomra70ee06c2015-08-20 16:05:16 -07003191 WACOM_BEE, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 10 };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08003192static const struct wacom_features wacom_features_0xC6 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003193 { "Wacom Cintiq 12WX", 53020, 33440, 1023, 63,
Aaron Skomra70ee06c2015-08-20 16:05:16 -07003194 WACOM_BEE, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 10 };
Ping Cheng56218562013-05-05 19:56:18 -07003195static const struct wacom_features wacom_features_0x304 =
Ping Chengecd618d2014-12-04 18:25:07 -08003196 { "Wacom Cintiq 13HD", 59152, 33448, 1023, 63,
Aaron Skomra70ee06c2015-08-20 16:05:16 -07003197 WACOM_13HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9,
Ping Chengfa770342014-12-01 13:44:28 -08003198 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET };
Ping Chengb4bf2122015-03-25 17:08:13 -07003199static const struct wacom_features wacom_features_0x333 =
3200 { "Wacom Cintiq 13HD touch", 59152, 33448, 2047, 63,
Aaron Skomra70ee06c2015-08-20 16:05:16 -07003201 WACOM_13HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9,
Ping Chengb4bf2122015-03-25 17:08:13 -07003202 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
3203 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x335 };
3204static const struct wacom_features wacom_features_0x335 =
3205 { "Wacom Cintiq 13HD touch", .type = WACOM_24HDT, /* Touch */
3206 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x333, .touch_max = 10,
3207 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08003208static const struct wacom_features wacom_features_0xC7 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003209 { "Wacom DTU1931", 37832, 30305, 511, 0,
3210 PL, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Ping Chengc8f2edc2010-06-28 01:10:51 -07003211static const struct wacom_features wacom_features_0xCE =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003212 { "Wacom DTU2231", 47864, 27011, 511, 0,
3213 DTU, WACOM_INTUOS_RES, WACOM_INTUOS_RES,
Benjamin Tissoires29b47392014-07-24 12:52:23 -07003214 .check_for_hid_type = true, .hid_type = HID_TYPE_USBMOUSE };
Ping Chengc8f2edc2010-06-28 01:10:51 -07003215static const struct wacom_features wacom_features_0xF0 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003216 { "Wacom DTU1631", 34623, 19553, 511, 0,
3217 DTU, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Ping Cheng497ab1f2014-01-20 20:18:04 -08003218static const struct wacom_features wacom_features_0xFB =
Ping Chengecd618d2014-12-04 18:25:07 -08003219 { "Wacom DTU1031", 21896, 13760, 511, 0,
Aaron Skomra70ee06c2015-08-20 16:05:16 -07003220 DTUS, WACOM_INTUOS_RES, WACOM_INTUOS_RES, 4,
Ping Chengfa770342014-12-01 13:44:28 -08003221 WACOM_DTU_OFFSET, WACOM_DTU_OFFSET };
Ping Chengfff00bf2014-12-04 18:23:04 -08003222static const struct wacom_features wacom_features_0x32F =
3223 { "Wacom DTU1031X", 22472, 12728, 511, 0,
Aaron Skomra70ee06c2015-08-20 16:05:16 -07003224 DTUSX, WACOM_INTUOS_RES, WACOM_INTUOS_RES, 0,
Ping Chengfff00bf2014-12-04 18:23:04 -08003225 WACOM_DTU_OFFSET, WACOM_DTU_OFFSET };
Aaron Skomra007760c2015-04-16 15:01:14 -07003226static const struct wacom_features wacom_features_0x336 =
3227 { "Wacom DTU1141", 23472, 13203, 1023, 0,
Aaron Skomra70ee06c2015-08-20 16:05:16 -07003228 DTUS, WACOM_INTUOS_RES, WACOM_INTUOS_RES, 4 };
Ping Cheng56218562013-05-05 19:56:18 -07003229static const struct wacom_features wacom_features_0x57 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003230 { "Wacom DTK2241", 95640, 54060, 2047, 63,
Aaron Skomra70ee06c2015-08-20 16:05:16 -07003231 DTK, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 6,
Ping Chengfa770342014-12-01 13:44:28 -08003232 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET };
Ping Chenga112e9f2013-02-13 20:20:01 -08003233static const struct wacom_features wacom_features_0x59 = /* Pen */
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003234 { "Wacom DTH2242", 95640, 54060, 2047, 63,
Aaron Skomra70ee06c2015-08-20 16:05:16 -07003235 DTK, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 6,
Ping Chengfa770342014-12-01 13:44:28 -08003236 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
Ping Chenga112e9f2013-02-13 20:20:01 -08003237 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x5D };
3238static const struct wacom_features wacom_features_0x5D = /* Touch */
3239 { "Wacom DTH2242", .type = WACOM_24HDT,
Benjamin Tissoires29b47392014-07-24 12:52:23 -07003240 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x59, .touch_max = 10,
3241 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
Ping Cheng3a4b4aa2010-06-03 22:10:21 -07003242static const struct wacom_features wacom_features_0xCC =
Ping Chengecd618d2014-12-04 18:25:07 -08003243 { "Wacom Cintiq 21UX2", 86800, 65200, 2047, 63,
Aaron Skomra70ee06c2015-08-20 16:05:16 -07003244 WACOM_21UX2, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 18,
Ping Chengfa770342014-12-01 13:44:28 -08003245 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET };
Ping Chengd838c642012-07-24 23:54:11 -07003246static const struct wacom_features wacom_features_0xFA =
Ping Chengecd618d2014-12-04 18:25:07 -08003247 { "Wacom Cintiq 22HD", 95440, 53860, 2047, 63,
Aaron Skomra70ee06c2015-08-20 16:05:16 -07003248 WACOM_22HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 18,
Ping Chengfa770342014-12-01 13:44:28 -08003249 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET };
Ping Cheng56218562013-05-05 19:56:18 -07003250static const struct wacom_features wacom_features_0x5B =
Ping Chengecd618d2014-12-04 18:25:07 -08003251 { "Wacom Cintiq 22HDT", 95440, 53860, 2047, 63,
Aaron Skomra70ee06c2015-08-20 16:05:16 -07003252 WACOM_22HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 18,
Ping Chengfa770342014-12-01 13:44:28 -08003253 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
Ping Cheng3bd1f7e2013-05-23 10:22:33 -07003254 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x5e };
Ping Cheng56218562013-05-05 19:56:18 -07003255static const struct wacom_features wacom_features_0x5E =
3256 { "Wacom Cintiq 22HDT", .type = WACOM_24HDT,
Benjamin Tissoires29b47392014-07-24 12:52:23 -07003257 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x5b, .touch_max = 10,
3258 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08003259static const struct wacom_features wacom_features_0x90 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003260 { "Wacom ISDv4 90", 26202, 16325, 255, 0,
3261 TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08003262static const struct wacom_features wacom_features_0x93 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003263 { "Wacom ISDv4 93", 26202, 16325, 255, 0,
3264 TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Ping Cheng11d0cf82011-06-27 12:57:58 -07003265static const struct wacom_features wacom_features_0x97 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003266 { "Wacom ISDv4 97", 26202, 16325, 511, 0,
3267 TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08003268static const struct wacom_features wacom_features_0x9A =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003269 { "Wacom ISDv4 9A", 26202, 16325, 255, 0,
3270 TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08003271static const struct wacom_features wacom_features_0x9F =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003272 { "Wacom ISDv4 9F", 26202, 16325, 255, 0,
3273 TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08003274static const struct wacom_features wacom_features_0xE2 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003275 { "Wacom ISDv4 E2", 26202, 16325, 255, 0,
3276 TABLETPC2FG, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08003277static const struct wacom_features wacom_features_0xE3 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003278 { "Wacom ISDv4 E3", 26202, 16325, 255, 0,
3279 TABLETPC2FG, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
Ping Cheng19635182012-04-29 21:09:18 -07003280static const struct wacom_features wacom_features_0xE5 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003281 { "Wacom ISDv4 E5", 26202, 16325, 255, 0,
3282 MTSCREEN, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Manoj Iyer26fcd2a2011-03-31 22:39:43 -07003283static const struct wacom_features wacom_features_0xE6 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003284 { "Wacom ISDv4 E6", 27760, 15694, 255, 0,
3285 TABLETPC2FG, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
Chris Bagwell0d0e3062011-12-11 23:50:59 -08003286static const struct wacom_features wacom_features_0xEC =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003287 { "Wacom ISDv4 EC", 25710, 14500, 255, 0,
3288 TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Ping Chengac173832012-06-12 00:15:06 -07003289static const struct wacom_features wacom_features_0xED =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003290 { "Wacom ISDv4 ED", 26202, 16325, 255, 0,
3291 TABLETPCE, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Ping Chengac173832012-06-12 00:15:06 -07003292static const struct wacom_features wacom_features_0xEF =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003293 { "Wacom ISDv4 EF", 26202, 16325, 255, 0,
3294 TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Ping Cheng6afdc282012-11-03 12:16:15 -07003295static const struct wacom_features wacom_features_0x100 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003296 { "Wacom ISDv4 100", 26202, 16325, 255, 0,
3297 MTTPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Ping Cheng6afdc282012-11-03 12:16:15 -07003298static const struct wacom_features wacom_features_0x101 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003299 { "Wacom ISDv4 101", 26202, 16325, 255, 0,
3300 MTTPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Stephan Frank58694832013-03-07 14:08:50 -08003301static const struct wacom_features wacom_features_0x10D =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003302 { "Wacom ISDv4 10D", 26202, 16325, 255, 0,
3303 MTTPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Jason Gerecke2d3163f2013-10-22 15:35:30 -07003304static const struct wacom_features wacom_features_0x10E =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003305 { "Wacom ISDv4 10E", 27760, 15694, 255, 0,
3306 MTTPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Jason Gerecke9b4f60e2013-10-15 23:46:34 -07003307static const struct wacom_features wacom_features_0x10F =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003308 { "Wacom ISDv4 10F", 27760, 15694, 255, 0,
3309 MTTPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Jason Gerecke61616ed2014-05-14 11:42:22 -07003310static const struct wacom_features wacom_features_0x116 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003311 { "Wacom ISDv4 116", 26202, 16325, 255, 0,
3312 TABLETPCE, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Jason Gereckeaeaf50d2014-07-28 10:53:16 -07003313static const struct wacom_features wacom_features_0x12C =
3314 { "Wacom ISDv4 12C", 27848, 15752, 2047, 0,
3315 TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Ping Chengedbe2652012-11-21 13:12:50 -08003316static const struct wacom_features wacom_features_0x4001 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003317 { "Wacom ISDv4 4001", 26202, 16325, 255, 0,
3318 MTTPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Jason Gerecked51ddb22014-05-14 17:14:29 -07003319static const struct wacom_features wacom_features_0x4004 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003320 { "Wacom ISDv4 4004", 11060, 6220, 255, 0,
3321 MTTPC_B, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Jason Gerecked51ddb22014-05-14 17:14:29 -07003322static const struct wacom_features wacom_features_0x5000 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003323 { "Wacom ISDv4 5000", 27848, 15752, 1023, 0,
3324 MTTPC_B, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Jason Gerecked51ddb22014-05-14 17:14:29 -07003325static const struct wacom_features wacom_features_0x5002 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003326 { "Wacom ISDv4 5002", 29576, 16724, 1023, 0,
3327 MTTPC_B, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08003328static const struct wacom_features wacom_features_0x47 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003329 { "Wacom Intuos2 6x8", 20320, 16240, 1023, 31,
3330 INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Chris Bagwelld3825d52012-03-25 23:26:11 -07003331static const struct wacom_features wacom_features_0x84 =
Ping Cheng3b164a02015-09-23 09:59:10 -07003332 { "Wacom Wireless Receiver", .type = WIRELESS, .touch_max = 16 };
Ping Cheng7b824bb2011-03-26 21:16:04 -07003333static const struct wacom_features wacom_features_0xD0 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003334 { "Wacom Bamboo 2FG", 14720, 9200, 1023, 31,
Ping Cheng3b164a02015-09-23 09:59:10 -07003335 BAMBOO_TOUCH, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
Ping Cheng7b824bb2011-03-26 21:16:04 -07003336static const struct wacom_features wacom_features_0xD1 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003337 { "Wacom Bamboo 2FG 4x5", 14720, 9200, 1023, 31,
3338 BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
Ping Cheng7b824bb2011-03-26 21:16:04 -07003339static const struct wacom_features wacom_features_0xD2 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003340 { "Wacom Bamboo Craft", 14720, 9200, 1023, 31,
3341 BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
Ping Cheng7b824bb2011-03-26 21:16:04 -07003342static const struct wacom_features wacom_features_0xD3 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003343 { "Wacom Bamboo 2FG 6x8", 21648, 13700, 1023, 31,
3344 BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
Kevin Granade57a78722010-12-10 23:04:02 -08003345static const struct wacom_features wacom_features_0xD4 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003346 { "Wacom Bamboo Pen", 14720, 9200, 1023, 31,
Ping Cheng3b164a02015-09-23 09:59:10 -07003347 BAMBOO_PEN, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Gerard Braad18adad12011-08-16 00:17:56 -07003348static const struct wacom_features wacom_features_0xD5 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003349 { "Wacom Bamboo Pen 6x8", 21648, 13700, 1023, 31,
Ping Cheng3b164a02015-09-23 09:59:10 -07003350 BAMBOO_PEN, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Ping Cheng7b824bb2011-03-26 21:16:04 -07003351static const struct wacom_features wacom_features_0xD6 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003352 { "Wacom BambooPT 2FG 4x5", 14720, 9200, 1023, 31,
3353 BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
Ping Cheng7b824bb2011-03-26 21:16:04 -07003354static const struct wacom_features wacom_features_0xD7 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003355 { "Wacom BambooPT 2FG Small", 14720, 9200, 1023, 31,
3356 BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
Ping Cheng7b824bb2011-03-26 21:16:04 -07003357static const struct wacom_features wacom_features_0xD8 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003358 { "Wacom Bamboo Comic 2FG", 21648, 13700, 1023, 31,
3359 BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
Ping Cheng7b824bb2011-03-26 21:16:04 -07003360static const struct wacom_features wacom_features_0xDA =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003361 { "Wacom Bamboo 2FG 4x5 SE", 14720, 9200, 1023, 31,
3362 BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
Ping Chengf41a64e2013-08-21 09:14:49 -07003363static const struct wacom_features wacom_features_0xDB =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003364 { "Wacom Bamboo 2FG 6x8 SE", 21648, 13700, 1023, 31,
3365 BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
Chris Bagwell73149ab2011-10-26 22:34:21 -07003366static const struct wacom_features wacom_features_0xDD =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003367 { "Wacom Bamboo Connect", 14720, 9200, 1023, 31,
3368 BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Chris Bagwell73149ab2011-10-26 22:34:21 -07003369static const struct wacom_features wacom_features_0xDE =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003370 { "Wacom Bamboo 16FG 4x5", 14720, 9200, 1023, 31,
3371 BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 16 };
Chris Bagwell73149ab2011-10-26 22:34:21 -07003372static const struct wacom_features wacom_features_0xDF =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003373 { "Wacom Bamboo 16FG 6x8", 21648, 13700, 1023, 31,
3374 BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 16 };
Ping Chengf41a64e2013-08-21 09:14:49 -07003375static const struct wacom_features wacom_features_0x300 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003376 { "Wacom Bamboo One S", 14720, 9225, 1023, 31,
Ping Cheng3b164a02015-09-23 09:59:10 -07003377 BAMBOO_PEN, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Ping Chengf41a64e2013-08-21 09:14:49 -07003378static const struct wacom_features wacom_features_0x301 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003379 { "Wacom Bamboo One M", 21648, 13530, 1023, 31,
3380 BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Ping Chengb5fd2a32013-11-25 18:44:55 -08003381static const struct wacom_features wacom_features_0x302 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003382 { "Wacom Intuos PT S", 15200, 9500, 1023, 31,
3383 INTUOSHT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 16,
Benjamin Tissoires29b47392014-07-24 12:52:23 -07003384 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
Ping Chengb5fd2a32013-11-25 18:44:55 -08003385static const struct wacom_features wacom_features_0x303 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003386 { "Wacom Intuos PT M", 21600, 13500, 1023, 31,
3387 INTUOSHT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 16,
Benjamin Tissoires29b47392014-07-24 12:52:23 -07003388 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
Ping Chengb5fd2a32013-11-25 18:44:55 -08003389static const struct wacom_features wacom_features_0x30E =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003390 { "Wacom Intuos S", 15200, 9500, 1023, 31,
3391 INTUOSHT, WACOM_INTUOS_RES, WACOM_INTUOS_RES,
Benjamin Tissoires29b47392014-07-24 12:52:23 -07003392 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
Ajay Ramaswamy7b4b3062010-12-23 01:19:39 -08003393static const struct wacom_features wacom_features_0x6004 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07003394 { "ISD-V4", 12800, 8000, 255, 0,
3395 TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Benjamin Tissoiresa3e6f652014-07-24 13:05:49 -07003396static const struct wacom_features wacom_features_0x307 =
Ping Chengecd618d2014-12-04 18:25:07 -08003397 { "Wacom ISDv5 307", 59152, 33448, 2047, 63,
Aaron Skomra70ee06c2015-08-20 16:05:16 -07003398 CINTIQ_HYBRID, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9,
Ping Chengfa770342014-12-01 13:44:28 -08003399 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
Jason Gerecke36d3c512013-09-20 09:47:35 -07003400 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x309 };
Benjamin Tissoiresa3e6f652014-07-24 13:05:49 -07003401static const struct wacom_features wacom_features_0x309 =
Jason Gerecke36d3c512013-09-20 09:47:35 -07003402 { "Wacom ISDv5 309", .type = WACOM_24HDT, /* Touch */
Benjamin Tissoires29b47392014-07-24 12:52:23 -07003403 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x0307, .touch_max = 10,
3404 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
Benjamin Tissoires89f2ab52014-09-03 15:43:25 -04003405static const struct wacom_features wacom_features_0x30A =
Ping Chengecd618d2014-12-04 18:25:07 -08003406 { "Wacom ISDv5 30A", 59152, 33448, 2047, 63,
Aaron Skomra70ee06c2015-08-20 16:05:16 -07003407 CINTIQ_HYBRID, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9,
Ping Chengfa770342014-12-01 13:44:28 -08003408 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
Benjamin Tissoires89f2ab52014-09-03 15:43:25 -04003409 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x30C };
3410static const struct wacom_features wacom_features_0x30C =
3411 { "Wacom ISDv5 30C", .type = WACOM_24HDT, /* Touch */
3412 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x30A, .touch_max = 10,
3413 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
Benjamin Tissoires8c97a762015-02-26 11:28:50 -05003414static const struct wacom_features wacom_features_0x318 =
3415 { "Wacom USB Bamboo PAD", 4095, 4095, /* Touch */
3416 .type = BAMBOO_PAD, 35, 48, .touch_max = 4 };
3417static const struct wacom_features wacom_features_0x319 =
3418 { "Wacom Wireless Bamboo PAD", 4095, 4095, /* Touch */
3419 .type = BAMBOO_PAD, 35, 48, .touch_max = 4 };
Jason Gereckef7acb552015-10-13 10:03:49 -07003420static const struct wacom_features wacom_features_0x325 =
3421 { "Wacom ISDv5 325", 59552, 33848, 2047, 63,
3422 CINTIQ_COMPANION_2, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 11,
3423 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
3424 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x326 };
3425static const struct wacom_features wacom_features_0x326 = /* Touch */
3426 { "Wacom ISDv5 326", .type = HID_GENERIC, .oVid = USB_VENDOR_ID_WACOM,
3427 .oPid = 0x325 };
Ping Chengfefb3912014-11-11 12:52:08 -08003428static const struct wacom_features wacom_features_0x323 =
3429 { "Wacom Intuos P M", 21600, 13500, 1023, 31,
3430 INTUOSHT, WACOM_INTUOS_RES, WACOM_INTUOS_RES,
3431 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
Aaron Skomra72b236d2015-08-20 16:05:17 -07003432static const struct wacom_features wacom_features_0x331 =
Ping Cheng3b164a02015-09-23 09:59:10 -07003433 { "Wacom Express Key Remote", .type = REMOTE,
3434 .numbered_buttons = 18, .check_for_hid_type = true,
Aaron Skomra72b236d2015-08-20 16:05:17 -07003435 .hid_type = HID_TYPE_USBNONE };
Ping Chengeda01da2015-09-23 13:51:15 -07003436static const struct wacom_features wacom_features_0x33B =
3437 { "Wacom Intuos S 2", 15200, 9500, 2047, 63,
3438 INTUOSHT2, WACOM_INTUOS_RES, WACOM_INTUOS_RES,
3439 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
3440static const struct wacom_features wacom_features_0x33C =
3441 { "Wacom Intuos PT S 2", 15200, 9500, 2047, 63,
3442 INTUOSHT2, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 16,
3443 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
3444static const struct wacom_features wacom_features_0x33D =
3445 { "Wacom Intuos P M 2", 21600, 13500, 2047, 63,
3446 INTUOSHT2, WACOM_INTUOS_RES, WACOM_INTUOS_RES,
3447 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
3448static const struct wacom_features wacom_features_0x33E =
3449 { "Wacom Intuos PT M 2", 21600, 13500, 2047, 63,
3450 INTUOSHT2, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 16,
3451 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
Bastian Blankb036f6f2010-02-10 23:06:23 -08003452
Benjamin Tissoires7704ac92014-09-23 12:08:08 -04003453static const struct wacom_features wacom_features_HID_ANY_ID =
3454 { "Wacom HID", .type = HID_GENERIC };
3455
Benjamin Tissoires29b47392014-07-24 12:52:23 -07003456#define USB_DEVICE_WACOM(prod) \
3457 HID_DEVICE(BUS_USB, HID_GROUP_WACOM, USB_VENDOR_ID_WACOM, prod),\
3458 .driver_data = (kernel_ulong_t)&wacom_features_##prod
Bastian Blankb036f6f2010-02-10 23:06:23 -08003459
Benjamin Tissoires387142b2014-08-06 13:52:56 -07003460#define BT_DEVICE_WACOM(prod) \
3461 HID_DEVICE(BUS_BLUETOOTH, HID_GROUP_WACOM, USB_VENDOR_ID_WACOM, prod),\
3462 .driver_data = (kernel_ulong_t)&wacom_features_##prod
Aristeu Rozanski1483f552011-06-22 01:17:17 -07003463
Mika Westerbergeef23a82015-02-23 15:52:43 +02003464#define I2C_DEVICE_WACOM(prod) \
3465 HID_DEVICE(BUS_I2C, HID_GROUP_WACOM, USB_VENDOR_ID_WACOM, prod),\
3466 .driver_data = (kernel_ulong_t)&wacom_features_##prod
3467
Ajay Ramaswamy7b4b3062010-12-23 01:19:39 -08003468#define USB_DEVICE_LENOVO(prod) \
Benjamin Tissoires29b47392014-07-24 12:52:23 -07003469 HID_USB_DEVICE(USB_VENDOR_ID_LENOVO, prod), \
3470 .driver_data = (kernel_ulong_t)&wacom_features_##prod
Ajay Ramaswamy7b4b3062010-12-23 01:19:39 -08003471
Benjamin Tissoires29b47392014-07-24 12:52:23 -07003472const struct hid_device_id wacom_ids[] = {
Bastian Blankb036f6f2010-02-10 23:06:23 -08003473 { USB_DEVICE_WACOM(0x00) },
Benjamin Tissoiresa3e6f652014-07-24 13:05:49 -07003474 { USB_DEVICE_WACOM(0x03) },
Bastian Blankb036f6f2010-02-10 23:06:23 -08003475 { USB_DEVICE_WACOM(0x10) },
3476 { USB_DEVICE_WACOM(0x11) },
3477 { USB_DEVICE_WACOM(0x12) },
3478 { USB_DEVICE_WACOM(0x13) },
3479 { USB_DEVICE_WACOM(0x14) },
3480 { USB_DEVICE_WACOM(0x15) },
3481 { USB_DEVICE_WACOM(0x16) },
3482 { USB_DEVICE_WACOM(0x17) },
3483 { USB_DEVICE_WACOM(0x18) },
3484 { USB_DEVICE_WACOM(0x19) },
Bastian Blankb036f6f2010-02-10 23:06:23 -08003485 { USB_DEVICE_WACOM(0x20) },
3486 { USB_DEVICE_WACOM(0x21) },
3487 { USB_DEVICE_WACOM(0x22) },
3488 { USB_DEVICE_WACOM(0x23) },
3489 { USB_DEVICE_WACOM(0x24) },
Benjamin Tissoiresa3e6f652014-07-24 13:05:49 -07003490 { USB_DEVICE_WACOM(0x26) },
3491 { USB_DEVICE_WACOM(0x27) },
3492 { USB_DEVICE_WACOM(0x28) },
3493 { USB_DEVICE_WACOM(0x29) },
3494 { USB_DEVICE_WACOM(0x2A) },
Bastian Blankb036f6f2010-02-10 23:06:23 -08003495 { USB_DEVICE_WACOM(0x30) },
3496 { USB_DEVICE_WACOM(0x31) },
3497 { USB_DEVICE_WACOM(0x32) },
3498 { USB_DEVICE_WACOM(0x33) },
3499 { USB_DEVICE_WACOM(0x34) },
3500 { USB_DEVICE_WACOM(0x35) },
3501 { USB_DEVICE_WACOM(0x37) },
3502 { USB_DEVICE_WACOM(0x38) },
3503 { USB_DEVICE_WACOM(0x39) },
Benjamin Tissoiresa3e6f652014-07-24 13:05:49 -07003504 { USB_DEVICE_WACOM(0x3F) },
Bastian Blankb036f6f2010-02-10 23:06:23 -08003505 { USB_DEVICE_WACOM(0x41) },
3506 { USB_DEVICE_WACOM(0x42) },
3507 { USB_DEVICE_WACOM(0x43) },
3508 { USB_DEVICE_WACOM(0x44) },
3509 { USB_DEVICE_WACOM(0x45) },
Benjamin Tissoiresa3e6f652014-07-24 13:05:49 -07003510 { USB_DEVICE_WACOM(0x47) },
Ping Cheng56218562013-05-05 19:56:18 -07003511 { USB_DEVICE_WACOM(0x57) },
Ping Chenga112e9f2013-02-13 20:20:01 -08003512 { USB_DEVICE_WACOM(0x59) },
Ping Cheng56218562013-05-05 19:56:18 -07003513 { USB_DEVICE_WACOM(0x5B) },
Benjamin Tissoiresa3e6f652014-07-24 13:05:49 -07003514 { USB_DEVICE_WACOM(0x5D) },
Benjamin Tissoires29b47392014-07-24 12:52:23 -07003515 { USB_DEVICE_WACOM(0x5E) },
Benjamin Tissoiresa3e6f652014-07-24 13:05:49 -07003516 { USB_DEVICE_WACOM(0x60) },
3517 { USB_DEVICE_WACOM(0x61) },
3518 { USB_DEVICE_WACOM(0x62) },
3519 { USB_DEVICE_WACOM(0x63) },
3520 { USB_DEVICE_WACOM(0x64) },
3521 { USB_DEVICE_WACOM(0x65) },
3522 { USB_DEVICE_WACOM(0x69) },
3523 { USB_DEVICE_WACOM(0x6A) },
3524 { USB_DEVICE_WACOM(0x6B) },
Benjamin Tissoires387142b2014-08-06 13:52:56 -07003525 { BT_DEVICE_WACOM(0x81) },
Benjamin Tissoiresa3e6f652014-07-24 13:05:49 -07003526 { USB_DEVICE_WACOM(0x84) },
3527 { USB_DEVICE_WACOM(0x90) },
3528 { USB_DEVICE_WACOM(0x93) },
3529 { USB_DEVICE_WACOM(0x97) },
3530 { USB_DEVICE_WACOM(0x9A) },
3531 { USB_DEVICE_WACOM(0x9F) },
Bastian Blankb036f6f2010-02-10 23:06:23 -08003532 { USB_DEVICE_WACOM(0xB0) },
3533 { USB_DEVICE_WACOM(0xB1) },
3534 { USB_DEVICE_WACOM(0xB2) },
3535 { USB_DEVICE_WACOM(0xB3) },
3536 { USB_DEVICE_WACOM(0xB4) },
3537 { USB_DEVICE_WACOM(0xB5) },
3538 { USB_DEVICE_WACOM(0xB7) },
3539 { USB_DEVICE_WACOM(0xB8) },
3540 { USB_DEVICE_WACOM(0xB9) },
3541 { USB_DEVICE_WACOM(0xBA) },
3542 { USB_DEVICE_WACOM(0xBB) },
Ping Cheng3a4b4aa2010-06-03 22:10:21 -07003543 { USB_DEVICE_WACOM(0xBC) },
Benjamin Tissoires81af7e62014-08-06 13:55:56 -07003544 { BT_DEVICE_WACOM(0xBD) },
Benjamin Tissoiresa3e6f652014-07-24 13:05:49 -07003545 { USB_DEVICE_WACOM(0xC0) },
3546 { USB_DEVICE_WACOM(0xC2) },
3547 { USB_DEVICE_WACOM(0xC4) },
Bastian Blankb036f6f2010-02-10 23:06:23 -08003548 { USB_DEVICE_WACOM(0xC5) },
3549 { USB_DEVICE_WACOM(0xC6) },
3550 { USB_DEVICE_WACOM(0xC7) },
Benjamin Tissoiresa3e6f652014-07-24 13:05:49 -07003551 { USB_DEVICE_WACOM(0xCC) },
Benjamin Tissoires29b47392014-07-24 12:52:23 -07003552 { USB_DEVICE_WACOM(0xCE) },
Henrik Rydbergcb734c02010-09-05 12:53:16 -07003553 { USB_DEVICE_WACOM(0xD0) },
Chris Bagwell2aaacb12010-09-12 00:11:35 -07003554 { USB_DEVICE_WACOM(0xD1) },
3555 { USB_DEVICE_WACOM(0xD2) },
3556 { USB_DEVICE_WACOM(0xD3) },
Kevin Granade57a78722010-12-10 23:04:02 -08003557 { USB_DEVICE_WACOM(0xD4) },
Gerard Braad18adad12011-08-16 00:17:56 -07003558 { USB_DEVICE_WACOM(0xD5) },
Ping Chengd38acb42011-01-24 09:32:50 -08003559 { USB_DEVICE_WACOM(0xD6) },
3560 { USB_DEVICE_WACOM(0xD7) },
David Foleya318e6b2010-11-30 23:45:46 -08003561 { USB_DEVICE_WACOM(0xD8) },
3562 { USB_DEVICE_WACOM(0xDA) },
David Foley47d09232010-12-07 21:05:59 -08003563 { USB_DEVICE_WACOM(0xDB) },
Chris Bagwell73149ab2011-10-26 22:34:21 -07003564 { USB_DEVICE_WACOM(0xDD) },
3565 { USB_DEVICE_WACOM(0xDE) },
3566 { USB_DEVICE_WACOM(0xDF) },
Bastian Blankb036f6f2010-02-10 23:06:23 -08003567 { USB_DEVICE_WACOM(0xE2) },
3568 { USB_DEVICE_WACOM(0xE3) },
Ping Cheng19635182012-04-29 21:09:18 -07003569 { USB_DEVICE_WACOM(0xE5) },
Manoj Iyer26fcd2a2011-03-31 22:39:43 -07003570 { USB_DEVICE_WACOM(0xE6) },
Chris Bagwell0d0e3062011-12-11 23:50:59 -08003571 { USB_DEVICE_WACOM(0xEC) },
Ping Chengac173832012-06-12 00:15:06 -07003572 { USB_DEVICE_WACOM(0xED) },
3573 { USB_DEVICE_WACOM(0xEF) },
Benjamin Tissoiresa3e6f652014-07-24 13:05:49 -07003574 { USB_DEVICE_WACOM(0xF0) },
3575 { USB_DEVICE_WACOM(0xF4) },
3576 { USB_DEVICE_WACOM(0xF6) },
3577 { USB_DEVICE_WACOM(0xF8) },
3578 { USB_DEVICE_WACOM(0xFA) },
3579 { USB_DEVICE_WACOM(0xFB) },
Ping Cheng6afdc282012-11-03 12:16:15 -07003580 { USB_DEVICE_WACOM(0x100) },
3581 { USB_DEVICE_WACOM(0x101) },
Stephan Frank58694832013-03-07 14:08:50 -08003582 { USB_DEVICE_WACOM(0x10D) },
Jason Gerecke2d3163f2013-10-22 15:35:30 -07003583 { USB_DEVICE_WACOM(0x10E) },
Jason Gerecke9b4f60e2013-10-15 23:46:34 -07003584 { USB_DEVICE_WACOM(0x10F) },
Jason Gerecke61616ed2014-05-14 11:42:22 -07003585 { USB_DEVICE_WACOM(0x116) },
Jason Gereckeaeaf50d2014-07-28 10:53:16 -07003586 { USB_DEVICE_WACOM(0x12C) },
Ping Chengf41a64e2013-08-21 09:14:49 -07003587 { USB_DEVICE_WACOM(0x300) },
3588 { USB_DEVICE_WACOM(0x301) },
Benjamin Tissoires29b47392014-07-24 12:52:23 -07003589 { USB_DEVICE_WACOM(0x302) },
3590 { USB_DEVICE_WACOM(0x303) },
Ping Cheng56218562013-05-05 19:56:18 -07003591 { USB_DEVICE_WACOM(0x304) },
Benjamin Tissoiresa3e6f652014-07-24 13:05:49 -07003592 { USB_DEVICE_WACOM(0x307) },
3593 { USB_DEVICE_WACOM(0x309) },
Benjamin Tissoires89f2ab52014-09-03 15:43:25 -04003594 { USB_DEVICE_WACOM(0x30A) },
3595 { USB_DEVICE_WACOM(0x30C) },
Benjamin Tissoiresa3e6f652014-07-24 13:05:49 -07003596 { USB_DEVICE_WACOM(0x30E) },
Benjamin Tissoires29b47392014-07-24 12:52:23 -07003597 { USB_DEVICE_WACOM(0x314) },
3598 { USB_DEVICE_WACOM(0x315) },
3599 { USB_DEVICE_WACOM(0x317) },
Benjamin Tissoires8c97a762015-02-26 11:28:50 -05003600 { USB_DEVICE_WACOM(0x318) },
3601 { USB_DEVICE_WACOM(0x319) },
Ping Chengfefb3912014-11-11 12:52:08 -08003602 { USB_DEVICE_WACOM(0x323) },
Jason Gereckef7acb552015-10-13 10:03:49 -07003603 { USB_DEVICE_WACOM(0x325) },
3604 { USB_DEVICE_WACOM(0x326) },
Ping Cheng500d4162015-01-27 13:30:03 -08003605 { USB_DEVICE_WACOM(0x32A) },
3606 { USB_DEVICE_WACOM(0x32B) },
3607 { USB_DEVICE_WACOM(0x32C) },
Ping Chengfff00bf2014-12-04 18:23:04 -08003608 { USB_DEVICE_WACOM(0x32F) },
Aaron Skomra72b236d2015-08-20 16:05:17 -07003609 { USB_DEVICE_WACOM(0x331) },
Ping Chengb4bf2122015-03-25 17:08:13 -07003610 { USB_DEVICE_WACOM(0x333) },
3611 { USB_DEVICE_WACOM(0x335) },
Aaron Skomra007760c2015-04-16 15:01:14 -07003612 { USB_DEVICE_WACOM(0x336) },
Ping Chengeda01da2015-09-23 13:51:15 -07003613 { USB_DEVICE_WACOM(0x33B) },
3614 { USB_DEVICE_WACOM(0x33C) },
3615 { USB_DEVICE_WACOM(0x33D) },
3616 { USB_DEVICE_WACOM(0x33E) },
Ping Chengedbe2652012-11-21 13:12:50 -08003617 { USB_DEVICE_WACOM(0x4001) },
Jason Gerecked51ddb22014-05-14 17:14:29 -07003618 { USB_DEVICE_WACOM(0x4004) },
3619 { USB_DEVICE_WACOM(0x5000) },
3620 { USB_DEVICE_WACOM(0x5002) },
Benjamin Tissoires00d6f222014-12-01 11:52:39 -05003621 { USB_DEVICE_LENOVO(0x6004) },
Benjamin Tissoires7704ac92014-09-23 12:08:08 -04003622
3623 { USB_DEVICE_WACOM(HID_ANY_ID) },
Mika Westerbergeef23a82015-02-23 15:52:43 +02003624 { I2C_DEVICE_WACOM(HID_ANY_ID) },
Ping Cheng3bea7332006-07-13 18:01:36 -07003625 { }
3626};
Benjamin Tissoires29b47392014-07-24 12:52:23 -07003627MODULE_DEVICE_TABLE(hid, wacom_ids);