blob: ac7447c7b82e35ff81209c31dd417fb8a53de112 [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>
Aristeu Rozanski1483f552011-06-22 01:17:17 -070018#include <linux/hid.h>
Ping Cheng3bea7332006-07-13 18:01:36 -070019
Ping Chenge35fb8c2011-03-26 21:16:05 -070020/* resolution for penabled devices */
21#define WACOM_PL_RES 20
22#define WACOM_PENPRTN_RES 40
23#define WACOM_VOLITO_RES 50
24#define WACOM_GRAPHIRE_RES 80
25#define WACOM_INTUOS_RES 100
26#define WACOM_INTUOS3_RES 200
27
Ping Chengfa770342014-12-01 13:44:28 -080028/* Newer Cintiq and DTU have an offset between tablet and screen areas */
29#define WACOM_DTU_OFFSET 200
30#define WACOM_CINTIQ_OFFSET 400
31
Benjamin Tissoires387142b2014-08-06 13:52:56 -070032/*
33 * Scale factor relating reported contact size to logical contact area.
Jason Gerecke4e904952012-10-03 17:19:11 -070034 * 2^14/pi is a good approximation on Intuos5 and 3rd-gen Bamboo
35 */
36#define WACOM_CONTACT_AREA_SCALE 2607
37
Benjamin Tissoires387142b2014-08-06 13:52:56 -070038/*
39 * Percent of battery capacity for Graphire.
40 * 8th value means AC online and show 100% capacity.
41 */
42static unsigned short batcap_gr[8] = { 1, 15, 25, 35, 50, 70, 100, 100 };
43
Benjamin Tissoires81af7e62014-08-06 13:55:56 -070044/*
45 * Percent of battery capacity for Intuos4 WL, AC has a separate bit.
46 */
47static unsigned short batcap_i4[8] = { 1, 15, 30, 45, 60, 70, 85, 100 };
48
Dmitry Torokhov95dd3b32010-03-19 22:18:15 -070049static int wacom_penpartner_irq(struct wacom_wac *wacom)
Ping Cheng3bea7332006-07-13 18:01:36 -070050{
51 unsigned char *data = wacom->data;
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -070052 struct input_dev *input = wacom->input;
Ping Cheng3bea7332006-07-13 18:01:36 -070053
54 switch (data[0]) {
Dmitry Torokhov73a97f42010-03-19 22:18:15 -070055 case 1:
56 if (data[5] & 0x80) {
57 wacom->tool[0] = (data[5] & 0x20) ? BTN_TOOL_RUBBER : BTN_TOOL_PEN;
58 wacom->id[0] = (data[5] & 0x20) ? ERASER_DEVICE_ID : STYLUS_DEVICE_ID;
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -070059 input_report_key(input, wacom->tool[0], 1);
60 input_report_abs(input, ABS_MISC, wacom->id[0]); /* report tool id */
Dmitry Torokhov252f7762010-03-19 22:33:38 -070061 input_report_abs(input, ABS_X, get_unaligned_le16(&data[1]));
62 input_report_abs(input, ABS_Y, get_unaligned_le16(&data[3]));
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -070063 input_report_abs(input, ABS_PRESSURE, (signed char)data[6] + 127);
64 input_report_key(input, BTN_TOUCH, ((signed char)data[6] > -127));
65 input_report_key(input, BTN_STYLUS, (data[5] & 0x40));
Dmitry Torokhov73a97f42010-03-19 22:18:15 -070066 } else {
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -070067 input_report_key(input, wacom->tool[0], 0);
68 input_report_abs(input, ABS_MISC, 0); /* report tool id */
69 input_report_abs(input, ABS_PRESSURE, -1);
70 input_report_key(input, BTN_TOUCH, 0);
Dmitry Torokhov73a97f42010-03-19 22:18:15 -070071 }
72 break;
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -070073
Dmitry Torokhov73a97f42010-03-19 22:18:15 -070074 case 2:
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -070075 input_report_key(input, BTN_TOOL_PEN, 1);
76 input_report_abs(input, ABS_MISC, STYLUS_DEVICE_ID); /* report tool id */
Dmitry Torokhov252f7762010-03-19 22:33:38 -070077 input_report_abs(input, ABS_X, get_unaligned_le16(&data[1]));
78 input_report_abs(input, ABS_Y, get_unaligned_le16(&data[3]));
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -070079 input_report_abs(input, ABS_PRESSURE, (signed char)data[6] + 127);
80 input_report_key(input, BTN_TOUCH, ((signed char)data[6] > -80) && !(data[5] & 0x20));
81 input_report_key(input, BTN_STYLUS, (data[5] & 0x40));
Dmitry Torokhov73a97f42010-03-19 22:18:15 -070082 break;
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -070083
Dmitry Torokhov73a97f42010-03-19 22:18:15 -070084 default:
Dmitry Torokhoveb71d1b2012-05-02 00:13:38 -070085 dev_dbg(input->dev.parent,
86 "%s: received unknown report #%d\n", __func__, data[0]);
Dmitry Torokhov73a97f42010-03-19 22:18:15 -070087 return 0;
Ping Cheng3bea7332006-07-13 18:01:36 -070088 }
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -070089
Ping Cheng3bea7332006-07-13 18:01:36 -070090 return 1;
91}
92
Dmitry Torokhov95dd3b32010-03-19 22:18:15 -070093static int wacom_pl_irq(struct wacom_wac *wacom)
Ping Cheng3bea7332006-07-13 18:01:36 -070094{
Jason Childse33da8a2010-02-17 22:38:31 -080095 struct wacom_features *features = &wacom->features;
Ping Cheng3bea7332006-07-13 18:01:36 -070096 unsigned char *data = wacom->data;
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -070097 struct input_dev *input = wacom->input;
Ping Chenge34b9d22008-05-05 11:36:41 -040098 int prox, pressure;
Ping Cheng3bea7332006-07-13 18:01:36 -070099
Ping Chengcad74702009-12-15 00:35:25 -0800100 if (data[0] != WACOM_REPORT_PENABLED) {
Dmitry Torokhoveb71d1b2012-05-02 00:13:38 -0700101 dev_dbg(input->dev.parent,
102 "%s: received unknown report #%d\n", __func__, data[0]);
Ping Cheng3bea7332006-07-13 18:01:36 -0700103 return 0;
104 }
105
106 prox = data[1] & 0x40;
107
Ping Cheng3bea7332006-07-13 18:01:36 -0700108 if (prox) {
Ping Chengec67bbe2009-12-15 00:35:24 -0800109 wacom->id[0] = ERASER_DEVICE_ID;
Ping Cheng3bea7332006-07-13 18:01:36 -0700110 pressure = (signed char)((data[7] << 1) | ((data[4] >> 2) & 1));
Jason Childse33da8a2010-02-17 22:38:31 -0800111 if (features->pressure_max > 255)
Ping Cheng3bea7332006-07-13 18:01:36 -0700112 pressure = (pressure << 1) | ((data[4] >> 6) & 1);
Jason Childse33da8a2010-02-17 22:38:31 -0800113 pressure += (features->pressure_max + 1) / 2;
Ping Cheng3bea7332006-07-13 18:01:36 -0700114
115 /*
116 * if going from out of proximity into proximity select between the eraser
117 * and the pen based on the state of the stylus2 button, choose eraser if
118 * pressed else choose pen. if not a proximity change from out to in, send
119 * an out of proximity for previous tool then a in for new tool.
120 */
121 if (!wacom->tool[0]) {
122 /* Eraser bit set for DTF */
123 if (data[1] & 0x10)
124 wacom->tool[1] = BTN_TOOL_RUBBER;
125 else
126 /* Going into proximity select tool */
127 wacom->tool[1] = (data[4] & 0x20) ? BTN_TOOL_RUBBER : BTN_TOOL_PEN;
128 } else {
129 /* was entered with stylus2 pressed */
130 if (wacom->tool[1] == BTN_TOOL_RUBBER && !(data[4] & 0x20)) {
131 /* report out proximity for previous tool */
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700132 input_report_key(input, wacom->tool[1], 0);
133 input_sync(input);
Ping Cheng3bea7332006-07-13 18:01:36 -0700134 wacom->tool[1] = BTN_TOOL_PEN;
135 return 0;
136 }
137 }
138 if (wacom->tool[1] != BTN_TOOL_RUBBER) {
139 /* Unknown tool selected default to pen tool */
140 wacom->tool[1] = BTN_TOOL_PEN;
Ping Chenge34b9d22008-05-05 11:36:41 -0400141 wacom->id[0] = STYLUS_DEVICE_ID;
Ping Cheng3bea7332006-07-13 18:01:36 -0700142 }
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700143 input_report_key(input, wacom->tool[1], prox); /* report in proximity for tool */
144 input_report_abs(input, ABS_MISC, wacom->id[0]); /* report tool id */
145 input_report_abs(input, ABS_X, data[3] | (data[2] << 7) | ((data[1] & 0x03) << 14));
146 input_report_abs(input, ABS_Y, data[6] | (data[5] << 7) | ((data[4] & 0x03) << 14));
147 input_report_abs(input, ABS_PRESSURE, pressure);
Ping Cheng3bea7332006-07-13 18:01:36 -0700148
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700149 input_report_key(input, BTN_TOUCH, data[4] & 0x08);
150 input_report_key(input, BTN_STYLUS, data[4] & 0x10);
Ping Cheng3bea7332006-07-13 18:01:36 -0700151 /* Only allow the stylus2 button to be reported for the pen tool. */
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700152 input_report_key(input, BTN_STYLUS2, (wacom->tool[1] == BTN_TOOL_PEN) && (data[4] & 0x20));
Ping Cheng3bea7332006-07-13 18:01:36 -0700153 } else {
154 /* report proximity-out of a (valid) tool */
155 if (wacom->tool[1] != BTN_TOOL_RUBBER) {
156 /* Unknown tool selected default to pen tool */
157 wacom->tool[1] = BTN_TOOL_PEN;
158 }
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700159 input_report_key(input, wacom->tool[1], prox);
Ping Cheng3bea7332006-07-13 18:01:36 -0700160 }
161
162 wacom->tool[0] = prox; /* Save proximity state */
163 return 1;
164}
165
Dmitry Torokhov95dd3b32010-03-19 22:18:15 -0700166static int wacom_ptu_irq(struct wacom_wac *wacom)
Ping Cheng3bea7332006-07-13 18:01:36 -0700167{
168 unsigned char *data = wacom->data;
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700169 struct input_dev *input = wacom->input;
Ping Cheng3bea7332006-07-13 18:01:36 -0700170
Ping Chengcad74702009-12-15 00:35:25 -0800171 if (data[0] != WACOM_REPORT_PENABLED) {
Dmitry Torokhoveb71d1b2012-05-02 00:13:38 -0700172 dev_dbg(input->dev.parent,
173 "%s: received unknown report #%d\n", __func__, data[0]);
Ping Cheng3bea7332006-07-13 18:01:36 -0700174 return 0;
175 }
176
Ping Cheng3bea7332006-07-13 18:01:36 -0700177 if (data[1] & 0x04) {
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700178 input_report_key(input, BTN_TOOL_RUBBER, data[1] & 0x20);
179 input_report_key(input, BTN_TOUCH, data[1] & 0x08);
Ping Chenge34b9d22008-05-05 11:36:41 -0400180 wacom->id[0] = ERASER_DEVICE_ID;
Ping Cheng3bea7332006-07-13 18:01:36 -0700181 } else {
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700182 input_report_key(input, BTN_TOOL_PEN, data[1] & 0x20);
183 input_report_key(input, BTN_TOUCH, data[1] & 0x01);
Ping Chenge34b9d22008-05-05 11:36:41 -0400184 wacom->id[0] = STYLUS_DEVICE_ID;
Ping Cheng3bea7332006-07-13 18:01:36 -0700185 }
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700186 input_report_abs(input, ABS_MISC, wacom->id[0]); /* report tool id */
Dmitry Torokhov252f7762010-03-19 22:33:38 -0700187 input_report_abs(input, ABS_X, le16_to_cpup((__le16 *)&data[2]));
188 input_report_abs(input, ABS_Y, le16_to_cpup((__le16 *)&data[4]));
189 input_report_abs(input, ABS_PRESSURE, le16_to_cpup((__le16 *)&data[6]));
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700190 input_report_key(input, BTN_STYLUS, data[1] & 0x02);
191 input_report_key(input, BTN_STYLUS2, data[1] & 0x10);
Ping Cheng3bea7332006-07-13 18:01:36 -0700192 return 1;
193}
194
Ping Chengc8f2edc2010-06-28 01:10:51 -0700195static int wacom_dtu_irq(struct wacom_wac *wacom)
196{
Jason Gerecke74b63412014-04-19 13:50:22 -0700197 unsigned char *data = wacom->data;
Ping Chengc8f2edc2010-06-28 01:10:51 -0700198 struct input_dev *input = wacom->input;
Jason Gerecke74b63412014-04-19 13:50:22 -0700199 int prox = data[1] & 0x20;
Ping Chengc8f2edc2010-06-28 01:10:51 -0700200
Dmitry Torokhoveb71d1b2012-05-02 00:13:38 -0700201 dev_dbg(input->dev.parent,
202 "%s: received report #%d", __func__, data[0]);
Ping Chengc8f2edc2010-06-28 01:10:51 -0700203
204 if (prox) {
205 /* Going into proximity select tool */
206 wacom->tool[0] = (data[1] & 0x0c) ? BTN_TOOL_RUBBER : BTN_TOOL_PEN;
207 if (wacom->tool[0] == BTN_TOOL_PEN)
208 wacom->id[0] = STYLUS_DEVICE_ID;
209 else
210 wacom->id[0] = ERASER_DEVICE_ID;
211 }
212 input_report_key(input, BTN_STYLUS, data[1] & 0x02);
213 input_report_key(input, BTN_STYLUS2, data[1] & 0x10);
214 input_report_abs(input, ABS_X, le16_to_cpup((__le16 *)&data[2]));
215 input_report_abs(input, ABS_Y, le16_to_cpup((__le16 *)&data[4]));
Jason Gerecke74b63412014-04-19 13:50:22 -0700216 input_report_abs(input, ABS_PRESSURE, ((data[7] & 0x01) << 8) | data[6]);
Ping Chengc8f2edc2010-06-28 01:10:51 -0700217 input_report_key(input, BTN_TOUCH, data[1] & 0x05);
218 if (!prox) /* out-prox */
219 wacom->id[0] = 0;
220 input_report_key(input, wacom->tool[0], prox);
221 input_report_abs(input, ABS_MISC, wacom->id[0]);
222 return 1;
223}
224
Ping Cheng497ab1f2014-01-20 20:18:04 -0800225static int wacom_dtus_irq(struct wacom_wac *wacom)
226{
227 char *data = wacom->data;
228 struct input_dev *input = wacom->input;
229 unsigned short prox, pressure = 0;
230
231 if (data[0] != WACOM_REPORT_DTUS && data[0] != WACOM_REPORT_DTUSPAD) {
232 dev_dbg(input->dev.parent,
233 "%s: received unknown report #%d", __func__, data[0]);
234 return 0;
235 } else if (data[0] == WACOM_REPORT_DTUSPAD) {
Benjamin Tissoires422b0312014-07-24 12:50:39 -0700236 input = wacom->pad_input;
Ping Cheng497ab1f2014-01-20 20:18:04 -0800237 input_report_key(input, BTN_0, (data[1] & 0x01));
238 input_report_key(input, BTN_1, (data[1] & 0x02));
239 input_report_key(input, BTN_2, (data[1] & 0x04));
240 input_report_key(input, BTN_3, (data[1] & 0x08));
241 input_report_abs(input, ABS_MISC,
242 data[1] & 0x0f ? PAD_DEVICE_ID : 0);
Ping Cheng497ab1f2014-01-20 20:18:04 -0800243 return 1;
244 } else {
245 prox = data[1] & 0x80;
246 if (prox) {
247 switch ((data[1] >> 3) & 3) {
248 case 1: /* Rubber */
249 wacom->tool[0] = BTN_TOOL_RUBBER;
250 wacom->id[0] = ERASER_DEVICE_ID;
251 break;
252
253 case 2: /* Pen */
254 wacom->tool[0] = BTN_TOOL_PEN;
255 wacom->id[0] = STYLUS_DEVICE_ID;
256 break;
257 }
258 }
259
260 input_report_key(input, BTN_STYLUS, data[1] & 0x20);
261 input_report_key(input, BTN_STYLUS2, data[1] & 0x40);
262 input_report_abs(input, ABS_X, get_unaligned_be16(&data[3]));
263 input_report_abs(input, ABS_Y, get_unaligned_be16(&data[5]));
264 pressure = ((data[1] & 0x03) << 8) | (data[2] & 0xff);
265 input_report_abs(input, ABS_PRESSURE, pressure);
266 input_report_key(input, BTN_TOUCH, pressure > 10);
267
268 if (!prox) /* out-prox */
269 wacom->id[0] = 0;
270 input_report_key(input, wacom->tool[0], prox);
271 input_report_abs(input, ABS_MISC, wacom->id[0]);
Ping Cheng497ab1f2014-01-20 20:18:04 -0800272 return 1;
273 }
274}
275
Dmitry Torokhov95dd3b32010-03-19 22:18:15 -0700276static int wacom_graphire_irq(struct wacom_wac *wacom)
Ping Cheng3bea7332006-07-13 18:01:36 -0700277{
Jason Childse33da8a2010-02-17 22:38:31 -0800278 struct wacom_features *features = &wacom->features;
Ping Cheng3bea7332006-07-13 18:01:36 -0700279 unsigned char *data = wacom->data;
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700280 struct input_dev *input = wacom->input;
Benjamin Tissoires38138102014-07-24 12:51:03 -0700281 struct input_dev *pad_input = wacom->pad_input;
Benjamin Tissoires387142b2014-08-06 13:52:56 -0700282 int battery_capacity, ps_connected;
Dmitry Torokhov252f7762010-03-19 22:33:38 -0700283 int prox;
Ping Cheng3b57ca02010-03-04 21:50:59 -0800284 int rw = 0;
285 int retval = 0;
Ping Cheng3bea7332006-07-13 18:01:36 -0700286
Benjamin Tissoires387142b2014-08-06 13:52:56 -0700287 if (features->type == GRAPHIRE_BT) {
288 if (data[0] != WACOM_REPORT_PENABLED_BT) {
289 dev_dbg(input->dev.parent,
290 "%s: received unknown report #%d\n", __func__,
291 data[0]);
292 goto exit;
293 }
294 } else if (data[0] != WACOM_REPORT_PENABLED) {
Dmitry Torokhoveb71d1b2012-05-02 00:13:38 -0700295 dev_dbg(input->dev.parent,
296 "%s: received unknown report #%d\n", __func__, data[0]);
Ping Cheng3b57ca02010-03-04 21:50:59 -0800297 goto exit;
Ping Cheng3bea7332006-07-13 18:01:36 -0700298 }
299
Ping Cheng3b57ca02010-03-04 21:50:59 -0800300 prox = data[1] & 0x80;
301 if (prox || wacom->id[0]) {
302 if (prox) {
303 switch ((data[1] >> 5) & 3) {
Ping Cheng3bea7332006-07-13 18:01:36 -0700304
305 case 0: /* Pen */
306 wacom->tool[0] = BTN_TOOL_PEN;
Ping Chenge34b9d22008-05-05 11:36:41 -0400307 wacom->id[0] = STYLUS_DEVICE_ID;
Ping Cheng3bea7332006-07-13 18:01:36 -0700308 break;
309
310 case 1: /* Rubber */
311 wacom->tool[0] = BTN_TOOL_RUBBER;
Ping Chenge34b9d22008-05-05 11:36:41 -0400312 wacom->id[0] = ERASER_DEVICE_ID;
Ping Cheng3bea7332006-07-13 18:01:36 -0700313 break;
314
315 case 2: /* Mouse with wheel */
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700316 input_report_key(input, BTN_MIDDLE, data[1] & 0x04);
Ping Cheng3bea7332006-07-13 18:01:36 -0700317 /* fall through */
318
319 case 3: /* Mouse without wheel */
320 wacom->tool[0] = BTN_TOOL_MOUSE;
Ping Chenge34b9d22008-05-05 11:36:41 -0400321 wacom->id[0] = CURSOR_DEVICE_ID;
Ping Cheng3bea7332006-07-13 18:01:36 -0700322 break;
Ping Cheng3b57ca02010-03-04 21:50:59 -0800323 }
Ping Cheng3bea7332006-07-13 18:01:36 -0700324 }
Dmitry Torokhov252f7762010-03-19 22:33:38 -0700325 input_report_abs(input, ABS_X, le16_to_cpup((__le16 *)&data[2]));
326 input_report_abs(input, ABS_Y, le16_to_cpup((__le16 *)&data[4]));
Ping Cheng3bea7332006-07-13 18:01:36 -0700327 if (wacom->tool[0] != BTN_TOOL_MOUSE) {
Benjamin Tissoires387142b2014-08-06 13:52:56 -0700328 if (features->type == GRAPHIRE_BT)
329 input_report_abs(input, ABS_PRESSURE, data[6] |
330 (((__u16) (data[1] & 0x08)) << 5));
331 else
332 input_report_abs(input, ABS_PRESSURE, data[6] |
333 ((data[7] & 0x03) << 8));
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700334 input_report_key(input, BTN_TOUCH, data[1] & 0x01);
335 input_report_key(input, BTN_STYLUS, data[1] & 0x02);
336 input_report_key(input, BTN_STYLUS2, data[1] & 0x04);
Dmitry Torokhovafb567e2010-04-13 23:08:58 -0700337 } else {
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700338 input_report_key(input, BTN_LEFT, data[1] & 0x01);
339 input_report_key(input, BTN_RIGHT, data[1] & 0x02);
Ping Cheng3b57ca02010-03-04 21:50:59 -0800340 if (features->type == WACOM_G4 ||
341 features->type == WACOM_MO) {
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700342 input_report_abs(input, ABS_DISTANCE, data[6] & 0x3f);
Mike Autyd9f66c12010-08-28 20:35:17 -0700343 rw = (data[7] & 0x04) - (data[7] & 0x03);
Benjamin Tissoires387142b2014-08-06 13:52:56 -0700344 } else if (features->type == GRAPHIRE_BT) {
345 /* Compute distance between mouse and tablet */
346 rw = 44 - (data[6] >> 2);
347 rw = clamp_val(rw, 0, 31);
348 input_report_abs(input, ABS_DISTANCE, rw);
349 if (((data[1] >> 5) & 3) == 2) {
350 /* Mouse with wheel */
351 input_report_key(input, BTN_MIDDLE,
352 data[1] & 0x04);
353 rw = (data[6] & 0x01) ? -1 :
354 (data[6] & 0x02) ? 1 : 0;
355 } else {
356 rw = 0;
357 }
Ping Cheng3b57ca02010-03-04 21:50:59 -0800358 } else {
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700359 input_report_abs(input, ABS_DISTANCE, data[7] & 0x3f);
Mike Autyd9f66c12010-08-28 20:35:17 -0700360 rw = -(signed char)data[6];
Ping Cheng3b57ca02010-03-04 21:50:59 -0800361 }
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700362 input_report_rel(input, REL_WHEEL, rw);
Dmitry Torokhovafb567e2010-04-13 23:08:58 -0700363 }
Ping Cheng3b57ca02010-03-04 21:50:59 -0800364
365 if (!prox)
366 wacom->id[0] = 0;
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700367 input_report_abs(input, ABS_MISC, wacom->id[0]); /* report tool id */
368 input_report_key(input, wacom->tool[0], prox);
369 input_sync(input); /* sync last event */
Ping Cheng80d4e8e2007-02-23 12:22:48 -0800370 }
Ping Cheng3bea7332006-07-13 18:01:36 -0700371
372 /* send pad data */
Jason Childse33da8a2010-02-17 22:38:31 -0800373 switch (features->type) {
Dmitry Torokhov73a97f42010-03-19 22:18:15 -0700374 case WACOM_G4:
Ping Cheng3b57ca02010-03-04 21:50:59 -0800375 prox = data[7] & 0xf8;
376 if (prox || wacom->id[1]) {
Ping Chenge34b9d22008-05-05 11:36:41 -0400377 wacom->id[1] = PAD_DEVICE_ID;
Benjamin Tissoires38138102014-07-24 12:51:03 -0700378 input_report_key(pad_input, BTN_BACK, (data[7] & 0x40));
379 input_report_key(pad_input, BTN_FORWARD, (data[7] & 0x80));
Ping Cheng3bea7332006-07-13 18:01:36 -0700380 rw = ((data[7] & 0x18) >> 3) - ((data[7] & 0x20) >> 3);
Benjamin Tissoires38138102014-07-24 12:51:03 -0700381 input_report_rel(pad_input, REL_WHEEL, rw);
Ping Cheng3b57ca02010-03-04 21:50:59 -0800382 if (!prox)
383 wacom->id[1] = 0;
Benjamin Tissoires38138102014-07-24 12:51:03 -0700384 input_report_abs(pad_input, ABS_MISC, wacom->id[1]);
Ping Chengab687b12010-04-05 23:07:41 -0700385 retval = 1;
Ping Cheng3bea7332006-07-13 18:01:36 -0700386 }
Ping Cheng7ecfbfd2007-06-14 23:32:48 -0400387 break;
Dmitry Torokhov73a97f42010-03-19 22:18:15 -0700388
389 case WACOM_MO:
Ping Cheng3b57ca02010-03-04 21:50:59 -0800390 prox = (data[7] & 0xf8) || data[8];
391 if (prox || wacom->id[1]) {
Ping Chenge34b9d22008-05-05 11:36:41 -0400392 wacom->id[1] = PAD_DEVICE_ID;
Benjamin Tissoires38138102014-07-24 12:51:03 -0700393 input_report_key(pad_input, BTN_BACK, (data[7] & 0x08));
394 input_report_key(pad_input, BTN_LEFT, (data[7] & 0x20));
395 input_report_key(pad_input, BTN_FORWARD, (data[7] & 0x10));
396 input_report_key(pad_input, BTN_RIGHT, (data[7] & 0x40));
397 input_report_abs(pad_input, ABS_WHEEL, (data[8] & 0x7f));
Ping Cheng3b57ca02010-03-04 21:50:59 -0800398 if (!prox)
399 wacom->id[1] = 0;
Benjamin Tissoires38138102014-07-24 12:51:03 -0700400 input_report_abs(pad_input, ABS_MISC, wacom->id[1]);
Ping Cheng84460012011-07-06 18:05:43 -0700401 retval = 1;
Ping Cheng7ecfbfd2007-06-14 23:32:48 -0400402 }
403 break;
Benjamin Tissoires387142b2014-08-06 13:52:56 -0700404 case GRAPHIRE_BT:
405 prox = data[7] & 0x03;
406 if (prox || wacom->id[1]) {
407 wacom->id[1] = PAD_DEVICE_ID;
408 input_report_key(pad_input, BTN_0, (data[7] & 0x02));
409 input_report_key(pad_input, BTN_1, (data[7] & 0x01));
410 if (!prox)
411 wacom->id[1] = 0;
412 input_report_abs(pad_input, ABS_MISC, wacom->id[1]);
413 retval = 1;
414 }
415 break;
416 }
417
418 /* Store current battery capacity and power supply state */
419 if (features->type == GRAPHIRE_BT) {
420 rw = (data[7] >> 2 & 0x07);
421 battery_capacity = batcap_gr[rw];
422 ps_connected = rw == 7;
423 if ((wacom->battery_capacity != battery_capacity) ||
424 (wacom->ps_connected != ps_connected)) {
425 wacom->battery_capacity = battery_capacity;
426 wacom->ps_connected = ps_connected;
427 wacom_notify_battery(wacom);
428 }
Ping Cheng3bea7332006-07-13 18:01:36 -0700429 }
Ping Cheng3b57ca02010-03-04 21:50:59 -0800430exit:
431 return retval;
Ping Cheng3bea7332006-07-13 18:01:36 -0700432}
433
Dmitry Torokhov95dd3b32010-03-19 22:18:15 -0700434static int wacom_intuos_inout(struct wacom_wac *wacom)
Ping Cheng3bea7332006-07-13 18:01:36 -0700435{
Jason Childse33da8a2010-02-17 22:38:31 -0800436 struct wacom_features *features = &wacom->features;
Ping Cheng3bea7332006-07-13 18:01:36 -0700437 unsigned char *data = wacom->data;
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700438 struct input_dev *input = wacom->input;
Ping Cheng6f660f12009-05-08 18:30:33 -0700439 int idx = 0;
Ping Cheng3bea7332006-07-13 18:01:36 -0700440
441 /* tool number */
Jason Childse33da8a2010-02-17 22:38:31 -0800442 if (features->type == INTUOS)
Ping Cheng6f660f12009-05-08 18:30:33 -0700443 idx = data[1] & 0x01;
Ping Cheng3bea7332006-07-13 18:01:36 -0700444
445 /* Enter report */
446 if ((data[1] & 0xfc) == 0xc0) {
Ping Cheng713481622014-01-16 16:28:47 -0800447 if (features->quirks & WACOM_QUIRK_MULTI_INPUT)
Jason Gereckeae584ca2012-04-03 15:50:40 -0700448 wacom->shared->stylus_in_proximity = true;
449
Ping Cheng3bea7332006-07-13 18:01:36 -0700450 /* serial number of the tool */
451 wacom->serial[idx] = ((data[3] & 0x0f) << 28) +
452 (data[4] << 20) + (data[5] << 12) +
453 (data[6] << 4) + (data[7] >> 4);
454
Ping Cheng493630b2010-06-22 11:21:34 -0700455 wacom->id[idx] = (data[2] << 4) | (data[3] >> 4) |
456 ((data[7] & 0x0f) << 20) | ((data[8] & 0xf0) << 12);
Dmitry Torokhov73a97f42010-03-19 22:18:15 -0700457
Ping Chengf0aacea2013-05-05 19:59:05 -0700458 switch (wacom->id[idx]) {
Dmitry Torokhov73a97f42010-03-19 22:18:15 -0700459 case 0x812: /* Inking pen */
460 case 0x801: /* Intuos3 Inking pen */
Ping Chengf0aacea2013-05-05 19:59:05 -0700461 case 0x120802: /* Intuos4/5 Inking Pen */
Dmitry Torokhov73a97f42010-03-19 22:18:15 -0700462 case 0x012:
463 wacom->tool[idx] = BTN_TOOL_PENCIL;
464 break;
465
466 case 0x822: /* Pen */
467 case 0x842:
468 case 0x852:
469 case 0x823: /* Intuos3 Grip Pen */
470 case 0x813: /* Intuos3 Classic Pen */
471 case 0x885: /* Intuos3 Marker Pen */
Ping Chengf0aacea2013-05-05 19:59:05 -0700472 case 0x802: /* Intuos4/5 13HD/24HD General Pen */
473 case 0x804: /* Intuos4/5 13HD/24HD Marker Pen */
Dmitry Torokhov73a97f42010-03-19 22:18:15 -0700474 case 0x022:
Ping Chengf0aacea2013-05-05 19:59:05 -0700475 case 0x100804: /* Intuos4/5 13HD/24HD Art Pen */
476 case 0x140802: /* Intuos4/5 13HD/24HD Classic Pen */
477 case 0x160802: /* Cintiq 13HD Pro Pen */
Ping Chengc73a1af2013-05-14 23:34:53 -0700478 case 0x180802: /* DTH2242 Pen */
Ping Cheng7d753b02013-06-18 23:14:25 -0700479 case 0x100802: /* Intuos4/5 13HD/24HD General Pen */
Dmitry Torokhov73a97f42010-03-19 22:18:15 -0700480 wacom->tool[idx] = BTN_TOOL_PEN;
481 break;
482
483 case 0x832: /* Stroke pen */
484 case 0x032:
485 wacom->tool[idx] = BTN_TOOL_BRUSH;
486 break;
487
488 case 0x007: /* Mouse 4D and 2D */
489 case 0x09c:
490 case 0x094:
491 case 0x017: /* Intuos3 2D Mouse */
492 case 0x806: /* Intuos4 Mouse */
493 wacom->tool[idx] = BTN_TOOL_MOUSE;
494 break;
495
496 case 0x096: /* Lens cursor */
497 case 0x097: /* Intuos3 Lens cursor */
498 case 0x006: /* Intuos4 Lens cursor */
499 wacom->tool[idx] = BTN_TOOL_LENS;
500 break;
501
502 case 0x82a: /* Eraser */
503 case 0x85a:
504 case 0x91a:
505 case 0xd1a:
506 case 0x0fa:
507 case 0x82b: /* Intuos3 Grip Pen Eraser */
508 case 0x81b: /* Intuos3 Classic Pen Eraser */
509 case 0x91b: /* Intuos3 Airbrush Eraser */
Ping Chengf0aacea2013-05-05 19:59:05 -0700510 case 0x80c: /* Intuos4/5 13HD/24HD Marker Pen Eraser */
511 case 0x80a: /* Intuos4/5 13HD/24HD General Pen Eraser */
512 case 0x90a: /* Intuos4/5 13HD/24HD Airbrush Eraser */
513 case 0x14080a: /* Intuos4/5 13HD/24HD Classic Pen Eraser */
514 case 0x10090a: /* Intuos4/5 13HD/24HD Airbrush Eraser */
515 case 0x10080c: /* Intuos4/5 13HD/24HD Art Pen Eraser */
516 case 0x16080a: /* Cintiq 13HD Pro Pen Eraser */
Ping Chengc73a1af2013-05-14 23:34:53 -0700517 case 0x18080a: /* DTH2242 Eraser */
Ping Cheng7d753b02013-06-18 23:14:25 -0700518 case 0x10080a: /* Intuos4/5 13HD/24HD General Pen Eraser */
Dmitry Torokhov73a97f42010-03-19 22:18:15 -0700519 wacom->tool[idx] = BTN_TOOL_RUBBER;
520 break;
521
522 case 0xd12:
523 case 0x912:
524 case 0x112:
525 case 0x913: /* Intuos3 Airbrush */
Ping Chengf0aacea2013-05-05 19:59:05 -0700526 case 0x902: /* Intuos4/5 13HD/24HD Airbrush */
527 case 0x100902: /* Intuos4/5 13HD/24HD Airbrush */
Dmitry Torokhov73a97f42010-03-19 22:18:15 -0700528 wacom->tool[idx] = BTN_TOOL_AIRBRUSH;
529 break;
530
531 default: /* Unknown tool */
532 wacom->tool[idx] = BTN_TOOL_PEN;
533 break;
Ping Cheng3bea7332006-07-13 18:01:36 -0700534 }
Ping Cheng3bea7332006-07-13 18:01:36 -0700535 return 1;
536 }
537
Ping Cheng3a4b4aa2010-06-03 22:10:21 -0700538 /* older I4 styli don't work with new Cintiqs */
539 if (!((wacom->id[idx] >> 20) & 0x01) &&
540 (features->type == WACOM_21UX2))
541 return 1;
542
Jason Gerecke4eb18302013-09-20 09:48:46 -0700543 /* Range Report */
544 if ((data[1] & 0xfe) == 0x20) {
545 input_report_key(input, BTN_TOUCH, 0);
546 input_report_abs(input, ABS_PRESSURE, 0);
547 input_report_abs(input, ABS_DISTANCE, wacom->features.distance_max);
Ping Cheng805a8762014-05-29 00:08:20 -0700548 if (features->quirks & WACOM_QUIRK_MULTI_INPUT)
549 wacom->shared->stylus_in_proximity = true;
Jason Gerecke4eb18302013-09-20 09:48:46 -0700550 }
551
Ping Cheng3bea7332006-07-13 18:01:36 -0700552 /* Exit report */
553 if ((data[1] & 0xfe) == 0x80) {
Ping Cheng713481622014-01-16 16:28:47 -0800554 if (features->quirks & WACOM_QUIRK_MULTI_INPUT)
Jason Gereckeae584ca2012-04-03 15:50:40 -0700555 wacom->shared->stylus_in_proximity = false;
556
Ping Cheng6f660f12009-05-08 18:30:33 -0700557 /*
558 * Reset all states otherwise we lose the initial states
559 * when in-prox next time
560 */
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700561 input_report_abs(input, ABS_X, 0);
562 input_report_abs(input, ABS_Y, 0);
563 input_report_abs(input, ABS_DISTANCE, 0);
564 input_report_abs(input, ABS_TILT_X, 0);
565 input_report_abs(input, ABS_TILT_Y, 0);
Ping Cheng80d4e8e2007-02-23 12:22:48 -0800566 if (wacom->tool[idx] >= BTN_TOOL_MOUSE) {
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700567 input_report_key(input, BTN_LEFT, 0);
568 input_report_key(input, BTN_MIDDLE, 0);
569 input_report_key(input, BTN_RIGHT, 0);
570 input_report_key(input, BTN_SIDE, 0);
571 input_report_key(input, BTN_EXTRA, 0);
572 input_report_abs(input, ABS_THROTTLE, 0);
573 input_report_abs(input, ABS_RZ, 0);
Ping Cheng7ecfbfd2007-06-14 23:32:48 -0400574 } else {
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700575 input_report_abs(input, ABS_PRESSURE, 0);
576 input_report_key(input, BTN_STYLUS, 0);
577 input_report_key(input, BTN_STYLUS2, 0);
578 input_report_key(input, BTN_TOUCH, 0);
579 input_report_abs(input, ABS_WHEEL, 0);
Jason Childse33da8a2010-02-17 22:38:31 -0800580 if (features->type >= INTUOS3S)
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700581 input_report_abs(input, ABS_Z, 0);
Ping Cheng8d32e3a2006-09-26 13:34:47 -0700582 }
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700583 input_report_key(input, wacom->tool[idx], 0);
584 input_report_abs(input, ABS_MISC, 0); /* reset tool id */
585 input_event(input, EV_MSC, MSC_SERIAL, wacom->serial[idx]);
Ping Cheng6f660f12009-05-08 18:30:33 -0700586 wacom->id[idx] = 0;
Ping Cheng80d4e8e2007-02-23 12:22:48 -0800587 return 2;
Ping Cheng3bea7332006-07-13 18:01:36 -0700588 }
589 return 0;
590}
591
Dmitry Torokhov95dd3b32010-03-19 22:18:15 -0700592static void wacom_intuos_general(struct wacom_wac *wacom)
Ping Cheng3bea7332006-07-13 18:01:36 -0700593{
Jason Childse33da8a2010-02-17 22:38:31 -0800594 struct wacom_features *features = &wacom->features;
Ping Cheng3bea7332006-07-13 18:01:36 -0700595 unsigned char *data = wacom->data;
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700596 struct input_dev *input = wacom->input;
Ping Cheng3bea7332006-07-13 18:01:36 -0700597 unsigned int t;
598
599 /* general pen packet */
600 if ((data[1] & 0xb8) == 0xa0) {
601 t = (data[6] << 2) | ((data[7] >> 6) & 3);
Jason Gerecke36d3c512013-09-20 09:47:35 -0700602 if (features->type >= INTUOS4S && features->type <= CINTIQ_HYBRID) {
Ping Cheng6f660f12009-05-08 18:30:33 -0700603 t = (t << 1) | (data[1] & 1);
Aristeu Rozanskica047fe2010-10-10 14:12:33 -0700604 }
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700605 input_report_abs(input, ABS_PRESSURE, t);
606 input_report_abs(input, ABS_TILT_X,
Jason Gereckeec5fc1c2014-11-18 16:50:08 -0800607 (((data[7] << 1) & 0x7e) | (data[8] >> 7)) - 64);
608 input_report_abs(input, ABS_TILT_Y, (data[8] & 0x7f) - 64);
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700609 input_report_key(input, BTN_STYLUS, data[1] & 2);
610 input_report_key(input, BTN_STYLUS2, data[1] & 4);
611 input_report_key(input, BTN_TOUCH, t > 10);
Ping Cheng3bea7332006-07-13 18:01:36 -0700612 }
613
614 /* airbrush second packet */
615 if ((data[1] & 0xbc) == 0xb4) {
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700616 input_report_abs(input, ABS_WHEEL,
Ping Cheng3bea7332006-07-13 18:01:36 -0700617 (data[6] << 2) | ((data[7] >> 6) & 3));
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700618 input_report_abs(input, ABS_TILT_X,
Jason Gereckeec5fc1c2014-11-18 16:50:08 -0800619 (((data[7] << 1) & 0x7e) | (data[8] >> 7)) - 64);
620 input_report_abs(input, ABS_TILT_Y, (data[8] & 0x7f) - 64);
Ping Cheng3bea7332006-07-13 18:01:36 -0700621 }
Ping Cheng3bea7332006-07-13 18:01:36 -0700622}
623
Dmitry Torokhov95dd3b32010-03-19 22:18:15 -0700624static int wacom_intuos_irq(struct wacom_wac *wacom)
Ping Cheng3bea7332006-07-13 18:01:36 -0700625{
Jason Childse33da8a2010-02-17 22:38:31 -0800626 struct wacom_features *features = &wacom->features;
Ping Cheng3bea7332006-07-13 18:01:36 -0700627 unsigned char *data = wacom->data;
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700628 struct input_dev *input = wacom->input;
Ping Cheng3bea7332006-07-13 18:01:36 -0700629 unsigned int t;
Ping Cheng6f660f12009-05-08 18:30:33 -0700630 int idx = 0, result;
Ping Cheng3bea7332006-07-13 18:01:36 -0700631
Dmitry Torokhoveb71d1b2012-05-02 00:13:38 -0700632 if (data[0] != WACOM_REPORT_PENABLED &&
633 data[0] != WACOM_REPORT_INTUOSREAD &&
634 data[0] != WACOM_REPORT_INTUOSWRITE &&
635 data[0] != WACOM_REPORT_INTUOSPAD &&
636 data[0] != WACOM_REPORT_INTUOS5PAD) {
637 dev_dbg(input->dev.parent,
638 "%s: received unknown report #%d\n", __func__, data[0]);
Ping Cheng3bea7332006-07-13 18:01:36 -0700639 return 0;
640 }
641
Ping Cheng3bea7332006-07-13 18:01:36 -0700642 /* tool number */
Jason Childse33da8a2010-02-17 22:38:31 -0800643 if (features->type == INTUOS)
Ping Cheng6f660f12009-05-08 18:30:33 -0700644 idx = data[1] & 0x01;
Ping Cheng3bea7332006-07-13 18:01:36 -0700645
646 /* pad packets. Works as a second tool and is always in prox */
Jason Gereckef860e582012-04-03 15:48:35 -0700647 if (data[0] == WACOM_REPORT_INTUOSPAD || data[0] == WACOM_REPORT_INTUOS5PAD) {
Benjamin Tissoires10059cdc2014-07-24 12:49:08 -0700648 input = wacom->pad_input;
Jason Childse33da8a2010-02-17 22:38:31 -0800649 if (features->type >= INTUOS4S && features->type <= INTUOS4L) {
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700650 input_report_key(input, BTN_0, (data[2] & 0x01));
651 input_report_key(input, BTN_1, (data[3] & 0x01));
652 input_report_key(input, BTN_2, (data[3] & 0x02));
653 input_report_key(input, BTN_3, (data[3] & 0x04));
654 input_report_key(input, BTN_4, (data[3] & 0x08));
655 input_report_key(input, BTN_5, (data[3] & 0x10));
656 input_report_key(input, BTN_6, (data[3] & 0x20));
Ping Cheng6f660f12009-05-08 18:30:33 -0700657 if (data[1] & 0x80) {
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700658 input_report_abs(input, ABS_WHEEL, (data[1] & 0x7f));
Ping Chenga8629522009-06-02 16:59:58 -0700659 } else {
660 /* Out of proximity, clear wheel value. */
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700661 input_report_abs(input, ABS_WHEEL, 0);
Ping Cheng6f660f12009-05-08 18:30:33 -0700662 }
Jason Childse33da8a2010-02-17 22:38:31 -0800663 if (features->type != INTUOS4S) {
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700664 input_report_key(input, BTN_7, (data[3] & 0x40));
665 input_report_key(input, BTN_8, (data[3] & 0x80));
Ping Cheng6f660f12009-05-08 18:30:33 -0700666 }
667 if (data[1] | (data[2] & 0x01) | data[3]) {
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700668 input_report_abs(input, ABS_MISC, PAD_DEVICE_ID);
Ping Cheng6f660f12009-05-08 18:30:33 -0700669 } else {
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700670 input_report_abs(input, ABS_MISC, 0);
Ping Cheng6f660f12009-05-08 18:30:33 -0700671 }
Ping Chenga112e9f2013-02-13 20:20:01 -0800672 } else if (features->type == DTK) {
673 input_report_key(input, BTN_0, (data[6] & 0x01));
674 input_report_key(input, BTN_1, (data[6] & 0x02));
675 input_report_key(input, BTN_2, (data[6] & 0x04));
676 input_report_key(input, BTN_3, (data[6] & 0x08));
677 input_report_key(input, BTN_4, (data[6] & 0x10));
678 input_report_key(input, BTN_5, (data[6] & 0x20));
Ping Chengc73a1af2013-05-14 23:34:53 -0700679 if (data[6] & 0x3f) {
680 input_report_abs(input, ABS_MISC, PAD_DEVICE_ID);
681 } else {
682 input_report_abs(input, ABS_MISC, 0);
683 }
Ping Cheng56218562013-05-05 19:56:18 -0700684 } else if (features->type == WACOM_13HD) {
685 input_report_key(input, BTN_0, (data[3] & 0x01));
686 input_report_key(input, BTN_1, (data[4] & 0x01));
687 input_report_key(input, BTN_2, (data[4] & 0x02));
688 input_report_key(input, BTN_3, (data[4] & 0x04));
689 input_report_key(input, BTN_4, (data[4] & 0x08));
690 input_report_key(input, BTN_5, (data[4] & 0x10));
691 input_report_key(input, BTN_6, (data[4] & 0x20));
692 input_report_key(input, BTN_7, (data[4] & 0x40));
693 input_report_key(input, BTN_8, (data[4] & 0x80));
Ping Chengc73a1af2013-05-14 23:34:53 -0700694 if ((data[3] & 0x01) | data[4]) {
695 input_report_abs(input, ABS_MISC, PAD_DEVICE_ID);
696 } else {
697 input_report_abs(input, ABS_MISC, 0);
698 }
Jason Gerecke803296b2011-12-12 00:11:45 -0800699 } else if (features->type == WACOM_24HD) {
700 input_report_key(input, BTN_0, (data[6] & 0x01));
701 input_report_key(input, BTN_1, (data[6] & 0x02));
702 input_report_key(input, BTN_2, (data[6] & 0x04));
703 input_report_key(input, BTN_3, (data[6] & 0x08));
704 input_report_key(input, BTN_4, (data[6] & 0x10));
705 input_report_key(input, BTN_5, (data[6] & 0x20));
706 input_report_key(input, BTN_6, (data[6] & 0x40));
707 input_report_key(input, BTN_7, (data[6] & 0x80));
708 input_report_key(input, BTN_8, (data[8] & 0x01));
709 input_report_key(input, BTN_9, (data[8] & 0x02));
710 input_report_key(input, BTN_A, (data[8] & 0x04));
711 input_report_key(input, BTN_B, (data[8] & 0x08));
712 input_report_key(input, BTN_C, (data[8] & 0x10));
713 input_report_key(input, BTN_X, (data[8] & 0x20));
714 input_report_key(input, BTN_Y, (data[8] & 0x40));
715 input_report_key(input, BTN_Z, (data[8] & 0x80));
716
717 /*
718 * Three "buttons" are available on the 24HD which are
719 * physically implemented as a touchstrip. Each button
720 * is approximately 3 bits wide with a 2 bit spacing.
721 * The raw touchstrip bits are stored at:
722 * ((data[3] & 0x1f) << 8) | data[4])
723 */
724 input_report_key(input, KEY_PROG1, data[4] & 0x07);
725 input_report_key(input, KEY_PROG2, data[4] & 0xE0);
726 input_report_key(input, KEY_PROG3, data[3] & 0x1C);
727
728 if (data[1] & 0x80) {
729 input_report_abs(input, ABS_WHEEL, (data[1] & 0x7f));
730 } else {
731 /* Out of proximity, clear wheel value. */
732 input_report_abs(input, ABS_WHEEL, 0);
733 }
734
735 if (data[2] & 0x80) {
736 input_report_abs(input, ABS_THROTTLE, (data[2] & 0x7f));
737 } else {
738 /* Out of proximity, clear second wheel value. */
739 input_report_abs(input, ABS_THROTTLE, 0);
740 }
741
742 if (data[1] | data[2] | (data[3] & 0x1f) | data[4] | data[6] | data[8]) {
Jason Gerecke803296b2011-12-12 00:11:45 -0800743 input_report_abs(input, ABS_MISC, PAD_DEVICE_ID);
744 } else {
Jason Gerecke803296b2011-12-12 00:11:45 -0800745 input_report_abs(input, ABS_MISC, 0);
746 }
Jason Gerecke36d3c512013-09-20 09:47:35 -0700747 } else if (features->type == CINTIQ_HYBRID) {
748 /*
749 * Do not send hardware buttons under Android. They
750 * are already sent to the system through GPIO (and
751 * have different meaning).
752 */
753 input_report_key(input, BTN_1, (data[4] & 0x01));
754 input_report_key(input, BTN_2, (data[4] & 0x02));
755 input_report_key(input, BTN_3, (data[4] & 0x04));
756 input_report_key(input, BTN_4, (data[4] & 0x08));
757
758 input_report_key(input, BTN_5, (data[4] & 0x10)); /* Right */
759 input_report_key(input, BTN_6, (data[4] & 0x20)); /* Up */
760 input_report_key(input, BTN_7, (data[4] & 0x40)); /* Left */
761 input_report_key(input, BTN_8, (data[4] & 0x80)); /* Down */
762 input_report_key(input, BTN_0, (data[3] & 0x01)); /* Center */
Ping Cheng9a35c412013-09-20 09:51:56 -0700763 } else if (features->type >= INTUOS5S && features->type <= INTUOSPL) {
Jason Gereckef860e582012-04-03 15:48:35 -0700764 int i;
765
766 /* Touch ring mode switch has no capacitive sensor */
767 input_report_key(input, BTN_0, (data[3] & 0x01));
768
769 /*
Ping Cheng9a35c412013-09-20 09:51:56 -0700770 * ExpressKeys on Intuos5/Intuos Pro have a capacitive sensor in
Jason Gereckef860e582012-04-03 15:48:35 -0700771 * addition to the mechanical switch. Switch data is
772 * stored in data[4], capacitive data in data[5].
773 */
774 for (i = 0; i < 8; i++)
775 input_report_key(input, BTN_1 + i, data[4] & (1 << i));
776
777 if (data[2] & 0x80) {
778 input_report_abs(input, ABS_WHEEL, (data[2] & 0x7f));
779 } else {
780 /* Out of proximity, clear wheel value. */
781 input_report_abs(input, ABS_WHEEL, 0);
782 }
783
Jason Gerecke5e056ef2012-09-24 09:21:31 -0700784 if (data[2] | (data[3] & 0x01) | data[4] | data[5]) {
Jason Gereckef860e582012-04-03 15:48:35 -0700785 input_report_abs(input, ABS_MISC, PAD_DEVICE_ID);
786 } else {
Jason Gereckef860e582012-04-03 15:48:35 -0700787 input_report_abs(input, ABS_MISC, 0);
788 }
Ping Cheng6f660f12009-05-08 18:30:33 -0700789 } else {
Ping Chengd838c642012-07-24 23:54:11 -0700790 if (features->type == WACOM_21UX2 || features->type == WACOM_22HD) {
Ping Cheng3a4b4aa2010-06-03 22:10:21 -0700791 input_report_key(input, BTN_0, (data[5] & 0x01));
792 input_report_key(input, BTN_1, (data[6] & 0x01));
793 input_report_key(input, BTN_2, (data[6] & 0x02));
794 input_report_key(input, BTN_3, (data[6] & 0x04));
795 input_report_key(input, BTN_4, (data[6] & 0x08));
796 input_report_key(input, BTN_5, (data[6] & 0x10));
797 input_report_key(input, BTN_6, (data[6] & 0x20));
798 input_report_key(input, BTN_7, (data[6] & 0x40));
799 input_report_key(input, BTN_8, (data[6] & 0x80));
800 input_report_key(input, BTN_9, (data[7] & 0x01));
801 input_report_key(input, BTN_A, (data[8] & 0x01));
802 input_report_key(input, BTN_B, (data[8] & 0x02));
803 input_report_key(input, BTN_C, (data[8] & 0x04));
804 input_report_key(input, BTN_X, (data[8] & 0x08));
805 input_report_key(input, BTN_Y, (data[8] & 0x10));
806 input_report_key(input, BTN_Z, (data[8] & 0x20));
807 input_report_key(input, BTN_BASE, (data[8] & 0x40));
808 input_report_key(input, BTN_BASE2, (data[8] & 0x80));
Ping Chengd838c642012-07-24 23:54:11 -0700809
810 if (features->type == WACOM_22HD) {
811 input_report_key(input, KEY_PROG1, data[9] & 0x01);
812 input_report_key(input, KEY_PROG2, data[9] & 0x02);
813 input_report_key(input, KEY_PROG3, data[9] & 0x04);
814 }
Ping Cheng3a4b4aa2010-06-03 22:10:21 -0700815 } else {
816 input_report_key(input, BTN_0, (data[5] & 0x01));
817 input_report_key(input, BTN_1, (data[5] & 0x02));
818 input_report_key(input, BTN_2, (data[5] & 0x04));
819 input_report_key(input, BTN_3, (data[5] & 0x08));
820 input_report_key(input, BTN_4, (data[6] & 0x01));
821 input_report_key(input, BTN_5, (data[6] & 0x02));
822 input_report_key(input, BTN_6, (data[6] & 0x04));
823 input_report_key(input, BTN_7, (data[6] & 0x08));
824 input_report_key(input, BTN_8, (data[5] & 0x10));
825 input_report_key(input, BTN_9, (data[6] & 0x10));
826 }
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700827 input_report_abs(input, ABS_RX, ((data[1] & 0x1f) << 8) | data[2]);
828 input_report_abs(input, ABS_RY, ((data[3] & 0x1f) << 8) | data[4]);
Ping Cheng3bea7332006-07-13 18:01:36 -0700829
Ping Cheng493630b2010-06-22 11:21:34 -0700830 if ((data[5] & 0x1f) | data[6] | (data[1] & 0x1f) |
Ping Cheng3a4b4aa2010-06-03 22:10:21 -0700831 data[2] | (data[3] & 0x1f) | data[4] | data[8] |
832 (data[7] & 0x01)) {
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700833 input_report_abs(input, ABS_MISC, PAD_DEVICE_ID);
Ping Cheng6f660f12009-05-08 18:30:33 -0700834 } else {
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700835 input_report_abs(input, ABS_MISC, 0);
Ping Cheng6f660f12009-05-08 18:30:33 -0700836 }
837 }
Ping Cheng3bea7332006-07-13 18:01:36 -0700838 return 1;
839 }
840
841 /* process in/out prox events */
Dmitry Torokhov95dd3b32010-03-19 22:18:15 -0700842 result = wacom_intuos_inout(wacom);
Ping Cheng3bea7332006-07-13 18:01:36 -0700843 if (result)
Dmitry Torokhov73a97f42010-03-19 22:18:15 -0700844 return result - 1;
Ping Cheng3bea7332006-07-13 18:01:36 -0700845
Ping Cheng6f660f12009-05-08 18:30:33 -0700846 /* don't proceed if we don't know the ID */
847 if (!wacom->id[idx])
848 return 0;
849
850 /* Only large Intuos support Lense Cursor */
Jason Childse33da8a2010-02-17 22:38:31 -0800851 if (wacom->tool[idx] == BTN_TOOL_LENS &&
852 (features->type == INTUOS3 ||
853 features->type == INTUOS3S ||
854 features->type == INTUOS4 ||
Jason Gerecke9fee6192012-04-03 15:47:22 -0700855 features->type == INTUOS4S ||
856 features->type == INTUOS5 ||
Ping Cheng9a35c412013-09-20 09:51:56 -0700857 features->type == INTUOS5S ||
858 features->type == INTUOSPM ||
859 features->type == INTUOSPS)) {
Jason Childse33da8a2010-02-17 22:38:31 -0800860
Ping Cheng80d4e8e2007-02-23 12:22:48 -0800861 return 0;
Jason Childse33da8a2010-02-17 22:38:31 -0800862 }
Ping Cheng80d4e8e2007-02-23 12:22:48 -0800863
Ping Cheng3bea7332006-07-13 18:01:36 -0700864 /* Cintiq doesn't send data when RDY bit isn't set */
Jason Childse33da8a2010-02-17 22:38:31 -0800865 if (features->type == CINTIQ && !(data[1] & 0x40))
Ping Cheng3bea7332006-07-13 18:01:36 -0700866 return 0;
867
Jason Childse33da8a2010-02-17 22:38:31 -0800868 if (features->type >= INTUOS3S) {
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700869 input_report_abs(input, ABS_X, (data[2] << 9) | (data[3] << 1) | ((data[9] >> 1) & 1));
870 input_report_abs(input, ABS_Y, (data[4] << 9) | (data[5] << 1) | (data[9] & 1));
871 input_report_abs(input, ABS_DISTANCE, ((data[9] >> 2) & 0x3f));
Ping Cheng3bea7332006-07-13 18:01:36 -0700872 } else {
Dmitry Torokhov252f7762010-03-19 22:33:38 -0700873 input_report_abs(input, ABS_X, be16_to_cpup((__be16 *)&data[2]));
874 input_report_abs(input, ABS_Y, be16_to_cpup((__be16 *)&data[4]));
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700875 input_report_abs(input, ABS_DISTANCE, ((data[9] >> 3) & 0x1f));
Ping Cheng3bea7332006-07-13 18:01:36 -0700876 }
877
878 /* process general packets */
Dmitry Torokhov95dd3b32010-03-19 22:18:15 -0700879 wacom_intuos_general(wacom);
Ping Cheng3bea7332006-07-13 18:01:36 -0700880
Ping Cheng6f660f12009-05-08 18:30:33 -0700881 /* 4D mouse, 2D mouse, marker pen rotation, tilt mouse, or Lens cursor packets */
882 if ((data[1] & 0xbc) == 0xa8 || (data[1] & 0xbe) == 0xb0 || (data[1] & 0xbc) == 0xac) {
Ping Cheng3bea7332006-07-13 18:01:36 -0700883
884 if (data[1] & 0x02) {
885 /* Rotation packet */
Jason Childse33da8a2010-02-17 22:38:31 -0800886 if (features->type >= INTUOS3S) {
Ping Cheng0e1763f2008-03-13 16:46:46 -0400887 /* I3 marker pen rotation */
Ping Cheng3bea7332006-07-13 18:01:36 -0700888 t = (data[6] << 3) | ((data[7] >> 5) & 7);
889 t = (data[7] & 0x20) ? ((t > 900) ? ((t-1) / 2 - 1350) :
890 ((t-1) / 2 + 450)) : (450 - t / 2) ;
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700891 input_report_abs(input, ABS_Z, t);
Ping Cheng3bea7332006-07-13 18:01:36 -0700892 } else {
893 /* 4D mouse rotation packet */
894 t = (data[6] << 3) | ((data[7] >> 5) & 7);
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700895 input_report_abs(input, ABS_RZ, (data[7] & 0x20) ?
Ping Cheng3bea7332006-07-13 18:01:36 -0700896 ((t - 1) / 2) : -t / 2);
897 }
898
Jason Childse33da8a2010-02-17 22:38:31 -0800899 } else if (!(data[1] & 0x10) && features->type < INTUOS3S) {
Ping Cheng3bea7332006-07-13 18:01:36 -0700900 /* 4D mouse packet */
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700901 input_report_key(input, BTN_LEFT, data[8] & 0x01);
902 input_report_key(input, BTN_MIDDLE, data[8] & 0x02);
903 input_report_key(input, BTN_RIGHT, data[8] & 0x04);
Ping Cheng3bea7332006-07-13 18:01:36 -0700904
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700905 input_report_key(input, BTN_SIDE, data[8] & 0x20);
906 input_report_key(input, BTN_EXTRA, data[8] & 0x10);
Ping Cheng3bea7332006-07-13 18:01:36 -0700907 t = (data[6] << 2) | ((data[7] >> 6) & 3);
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700908 input_report_abs(input, ABS_THROTTLE, (data[8] & 0x08) ? -t : t);
Ping Cheng3bea7332006-07-13 18:01:36 -0700909
910 } else if (wacom->tool[idx] == BTN_TOOL_MOUSE) {
Ping Cheng6f660f12009-05-08 18:30:33 -0700911 /* I4 mouse */
Ping Cheng9a35c412013-09-20 09:51:56 -0700912 if (features->type >= INTUOS4S && features->type <= INTUOSPL) {
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700913 input_report_key(input, BTN_LEFT, data[6] & 0x01);
914 input_report_key(input, BTN_MIDDLE, data[6] & 0x02);
915 input_report_key(input, BTN_RIGHT, data[6] & 0x04);
916 input_report_rel(input, REL_WHEEL, ((data[7] & 0x80) >> 7)
Ping Cheng6f660f12009-05-08 18:30:33 -0700917 - ((data[7] & 0x40) >> 6));
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700918 input_report_key(input, BTN_SIDE, data[6] & 0x08);
919 input_report_key(input, BTN_EXTRA, data[6] & 0x10);
Ping Cheng6f660f12009-05-08 18:30:33 -0700920
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700921 input_report_abs(input, ABS_TILT_X,
Jason Gereckeec5fc1c2014-11-18 16:50:08 -0800922 (((data[7] << 1) & 0x7e) | (data[8] >> 7)) - 64);
923 input_report_abs(input, ABS_TILT_Y, (data[8] & 0x7f) - 64);
Ping Cheng6f660f12009-05-08 18:30:33 -0700924 } else {
925 /* 2D mouse packet */
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700926 input_report_key(input, BTN_LEFT, data[8] & 0x04);
927 input_report_key(input, BTN_MIDDLE, data[8] & 0x08);
928 input_report_key(input, BTN_RIGHT, data[8] & 0x10);
929 input_report_rel(input, REL_WHEEL, (data[8] & 0x01)
Ping Cheng3bea7332006-07-13 18:01:36 -0700930 - ((data[8] & 0x02) >> 1));
931
Ping Cheng6f660f12009-05-08 18:30:33 -0700932 /* I3 2D mouse side buttons */
Jason Childse33da8a2010-02-17 22:38:31 -0800933 if (features->type >= INTUOS3S && features->type <= INTUOS3L) {
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700934 input_report_key(input, BTN_SIDE, data[8] & 0x40);
935 input_report_key(input, BTN_EXTRA, data[8] & 0x20);
Ping Cheng6f660f12009-05-08 18:30:33 -0700936 }
Ping Cheng3bea7332006-07-13 18:01:36 -0700937 }
Jason Childse33da8a2010-02-17 22:38:31 -0800938 } else if ((features->type < INTUOS3S || features->type == INTUOS3L ||
Ping Cheng9a35c412013-09-20 09:51:56 -0700939 features->type == INTUOS4L || features->type == INTUOS5L ||
940 features->type == INTUOSPL) &&
Ping Cheng6f660f12009-05-08 18:30:33 -0700941 wacom->tool[idx] == BTN_TOOL_LENS) {
Ping Cheng3bea7332006-07-13 18:01:36 -0700942 /* Lens cursor packets */
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700943 input_report_key(input, BTN_LEFT, data[8] & 0x01);
944 input_report_key(input, BTN_MIDDLE, data[8] & 0x02);
945 input_report_key(input, BTN_RIGHT, data[8] & 0x04);
946 input_report_key(input, BTN_SIDE, data[8] & 0x10);
947 input_report_key(input, BTN_EXTRA, data[8] & 0x08);
Ping Cheng3bea7332006-07-13 18:01:36 -0700948 }
949 }
950
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700951 input_report_abs(input, ABS_MISC, wacom->id[idx]); /* report tool id */
952 input_report_key(input, wacom->tool[idx], 1);
953 input_event(input, EV_MSC, MSC_SERIAL, wacom->serial[idx]);
Ping Cheng3bea7332006-07-13 18:01:36 -0700954 return 1;
955}
956
Jason Gereckeb1e42792012-10-21 00:38:04 -0700957static int int_dist(int x1, int y1, int x2, int y2)
958{
959 int x = x2 - x1;
960 int y = y2 - y1;
961
962 return int_sqrt(x*x + y*y);
963}
964
Benjamin Tissoires81af7e62014-08-06 13:55:56 -0700965static void wacom_intuos_bt_process_data(struct wacom_wac *wacom,
966 unsigned char *data)
967{
968 memcpy(wacom->data, data, 10);
969 wacom_intuos_irq(wacom);
970
971 input_sync(wacom->input);
972 if (wacom->pad_input)
973 input_sync(wacom->pad_input);
974}
975
976static int wacom_intuos_bt_irq(struct wacom_wac *wacom, size_t len)
977{
978 unsigned char data[WACOM_PKGLEN_MAX];
979 int i = 1;
980 unsigned power_raw, battery_capacity, bat_charging, ps_connected;
981
982 memcpy(data, wacom->data, len);
983
984 switch (data[0]) {
985 case 0x04:
986 wacom_intuos_bt_process_data(wacom, data + i);
987 i += 10;
988 /* fall through */
989 case 0x03:
990 wacom_intuos_bt_process_data(wacom, data + i);
991 i += 10;
992 wacom_intuos_bt_process_data(wacom, data + i);
993 i += 10;
994 power_raw = data[i];
995 bat_charging = (power_raw & 0x08) ? 1 : 0;
996 ps_connected = (power_raw & 0x10) ? 1 : 0;
997 battery_capacity = batcap_i4[power_raw & 0x07];
998 if ((wacom->battery_capacity != battery_capacity) ||
999 (wacom->bat_charging != bat_charging) ||
1000 (wacom->ps_connected != ps_connected)) {
1001 wacom->battery_capacity = battery_capacity;
1002 wacom->bat_charging = bat_charging;
1003 wacom->ps_connected = ps_connected;
1004 wacom_notify_battery(wacom);
1005 }
1006
1007 break;
1008 default:
1009 dev_dbg(wacom->input->dev.parent,
1010 "Unknown report: %d,%d size:%zu\n",
1011 data[0], data[1], len);
1012 return 0;
1013 }
1014 return 0;
1015}
1016
Jason Gereckeb1e42792012-10-21 00:38:04 -07001017static int wacom_24hdt_irq(struct wacom_wac *wacom)
1018{
1019 struct input_dev *input = wacom->input;
Jason Gerecke74b63412014-04-19 13:50:22 -07001020 unsigned char *data = wacom->data;
Jason Gereckeb1e42792012-10-21 00:38:04 -07001021 int i;
1022 int current_num_contacts = data[61];
1023 int contacts_to_send = 0;
1024
1025 /*
1026 * First packet resets the counter since only the first
1027 * packet in series will have non-zero current_num_contacts.
1028 */
1029 if (current_num_contacts)
1030 wacom->num_contacts_left = current_num_contacts;
1031
1032 /* There are at most 4 contacts per packet */
1033 contacts_to_send = min(4, wacom->num_contacts_left);
1034
1035 for (i = 0; i < contacts_to_send; i++) {
1036 int offset = (WACOM_BYTES_PER_24HDT_PACKET * i) + 1;
1037 bool touch = data[offset] & 0x1 && !wacom->shared->stylus_in_proximity;
Ping Cheng02295e62013-01-04 23:56:00 -08001038 int slot = input_mt_get_slot_by_key(input, data[offset + 1]);
Jason Gereckeb1e42792012-10-21 00:38:04 -07001039
1040 if (slot < 0)
1041 continue;
1042 input_mt_slot(input, slot);
1043 input_mt_report_slot_state(input, MT_TOOL_FINGER, touch);
1044
1045 if (touch) {
Jason Gereckeedc8e20a2014-05-14 16:53:30 -07001046 int t_x = get_unaligned_le16(&data[offset + 2]);
1047 int c_x = get_unaligned_le16(&data[offset + 4]);
1048 int t_y = get_unaligned_le16(&data[offset + 6]);
1049 int c_y = get_unaligned_le16(&data[offset + 8]);
1050 int w = get_unaligned_le16(&data[offset + 10]);
1051 int h = get_unaligned_le16(&data[offset + 12]);
Jason Gereckeb1e42792012-10-21 00:38:04 -07001052
1053 input_report_abs(input, ABS_MT_POSITION_X, t_x);
1054 input_report_abs(input, ABS_MT_POSITION_Y, t_y);
1055 input_report_abs(input, ABS_MT_TOUCH_MAJOR, min(w,h));
1056 input_report_abs(input, ABS_MT_WIDTH_MAJOR, min(w, h) + int_dist(t_x, t_y, c_x, c_y));
1057 input_report_abs(input, ABS_MT_WIDTH_MINOR, min(w, h));
1058 input_report_abs(input, ABS_MT_ORIENTATION, w > h);
1059 }
Jason Gereckeb1e42792012-10-21 00:38:04 -07001060 }
Jason Gereckeb1e42792012-10-21 00:38:04 -07001061 input_mt_report_pointer_emulation(input, true);
1062
1063 wacom->num_contacts_left -= contacts_to_send;
1064 if (wacom->num_contacts_left <= 0)
1065 wacom->num_contacts_left = 0;
1066
1067 return 1;
1068}
1069
Ping Cheng19635182012-04-29 21:09:18 -07001070static int wacom_mt_touch(struct wacom_wac *wacom)
1071{
1072 struct input_dev *input = wacom->input;
Jason Gerecke74b63412014-04-19 13:50:22 -07001073 unsigned char *data = wacom->data;
Ping Cheng19635182012-04-29 21:09:18 -07001074 int i;
1075 int current_num_contacts = data[2];
1076 int contacts_to_send = 0;
Ping Cheng6afdc282012-11-03 12:16:15 -07001077 int x_offset = 0;
1078
1079 /* MTTPC does not support Height and Width */
Jason Gerecked51ddb22014-05-14 17:14:29 -07001080 if (wacom->features.type == MTTPC || wacom->features.type == MTTPC_B)
Ping Cheng6afdc282012-11-03 12:16:15 -07001081 x_offset = -4;
Ping Cheng19635182012-04-29 21:09:18 -07001082
1083 /*
1084 * First packet resets the counter since only the first
1085 * packet in series will have non-zero current_num_contacts.
1086 */
1087 if (current_num_contacts)
1088 wacom->num_contacts_left = current_num_contacts;
1089
1090 /* There are at most 5 contacts per packet */
1091 contacts_to_send = min(5, wacom->num_contacts_left);
1092
1093 for (i = 0; i < contacts_to_send; i++) {
Ping Cheng6afdc282012-11-03 12:16:15 -07001094 int offset = (WACOM_BYTES_PER_MT_PACKET + x_offset) * i + 3;
Ping Cheng19635182012-04-29 21:09:18 -07001095 bool touch = data[offset] & 0x1;
Jason Gereckeedc8e20a2014-05-14 16:53:30 -07001096 int id = get_unaligned_le16(&data[offset + 1]);
Ping Cheng02295e62013-01-04 23:56:00 -08001097 int slot = input_mt_get_slot_by_key(input, id);
Ping Cheng19635182012-04-29 21:09:18 -07001098
1099 if (slot < 0)
1100 continue;
1101
1102 input_mt_slot(input, slot);
1103 input_mt_report_slot_state(input, MT_TOOL_FINGER, touch);
1104 if (touch) {
Jason Gereckeedc8e20a2014-05-14 16:53:30 -07001105 int x = get_unaligned_le16(&data[offset + x_offset + 7]);
1106 int y = get_unaligned_le16(&data[offset + x_offset + 9]);
Ping Cheng19635182012-04-29 21:09:18 -07001107 input_report_abs(input, ABS_MT_POSITION_X, x);
1108 input_report_abs(input, ABS_MT_POSITION_Y, y);
1109 }
Ping Cheng19635182012-04-29 21:09:18 -07001110 }
Ping Cheng19635182012-04-29 21:09:18 -07001111 input_mt_report_pointer_emulation(input, true);
1112
1113 wacom->num_contacts_left -= contacts_to_send;
1114 if (wacom->num_contacts_left < 0)
1115 wacom->num_contacts_left = 0;
1116
1117 return 1;
1118}
1119
Ping Cheng84eb5aa2011-03-12 20:35:18 -08001120static int wacom_tpc_mt_touch(struct wacom_wac *wacom)
1121{
1122 struct input_dev *input = wacom->input;
1123 unsigned char *data = wacom->data;
1124 int contact_with_no_pen_down_count = 0;
1125 int i;
1126
1127 for (i = 0; i < 2; i++) {
1128 int p = data[1] & (1 << i);
1129 bool touch = p && !wacom->shared->stylus_in_proximity;
1130
1131 input_mt_slot(input, i);
1132 input_mt_report_slot_state(input, MT_TOOL_FINGER, touch);
1133 if (touch) {
1134 int x = le16_to_cpup((__le16 *)&data[i * 2 + 2]) & 0x7fff;
1135 int y = le16_to_cpup((__le16 *)&data[i * 2 + 6]) & 0x7fff;
1136
1137 input_report_abs(input, ABS_MT_POSITION_X, x);
1138 input_report_abs(input, ABS_MT_POSITION_Y, y);
1139 contact_with_no_pen_down_count++;
1140 }
1141 }
Ping Cheng02295e62013-01-04 23:56:00 -08001142 input_mt_report_pointer_emulation(input, true);
Ping Cheng84eb5aa2011-03-12 20:35:18 -08001143
1144 /* keep touch state for pen event */
1145 wacom->shared->touch_down = (contact_with_no_pen_down_count > 0);
1146
Ping Cheng84eb5aa2011-03-12 20:35:18 -08001147 return 1;
1148}
1149
Ping Chenga43c7c52011-03-12 20:34:42 -08001150static int wacom_tpc_single_touch(struct wacom_wac *wacom, size_t len)
Ping Chengec67bbe2009-12-15 00:35:24 -08001151{
Jason Gerecke74b63412014-04-19 13:50:22 -07001152 unsigned char *data = wacom->data;
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -07001153 struct input_dev *input = wacom->input;
Ping Chenga43c7c52011-03-12 20:34:42 -08001154 bool prox;
1155 int x = 0, y = 0;
Ping Chengec67bbe2009-12-15 00:35:24 -08001156
Ping Cheng19635182012-04-29 21:09:18 -07001157 if (wacom->features.touch_max > 1 || len > WACOM_PKGLEN_TPC2FG)
1158 return 0;
1159
Ping Chenga43c7c52011-03-12 20:34:42 -08001160 if (!wacom->shared->stylus_in_proximity) {
1161 if (len == WACOM_PKGLEN_TPC1FG) {
1162 prox = data[0] & 0x01;
1163 x = get_unaligned_le16(&data[1]);
1164 y = get_unaligned_le16(&data[3]);
Jason Gerecke61616ed2014-05-14 11:42:22 -07001165 } else if (len == WACOM_PKGLEN_TPC1FG_B) {
1166 prox = data[2] & 0x01;
1167 x = get_unaligned_le16(&data[3]);
1168 y = get_unaligned_le16(&data[5]);
Ping Chengac173832012-06-12 00:15:06 -07001169 } else {
Ping Chenga43c7c52011-03-12 20:34:42 -08001170 prox = data[1] & 0x01;
1171 x = le16_to_cpup((__le16 *)&data[2]);
1172 y = le16_to_cpup((__le16 *)&data[4]);
Ping Chengec67bbe2009-12-15 00:35:24 -08001173 }
Ping Chenga43c7c52011-03-12 20:34:42 -08001174 } else
1175 /* force touch out when pen is in prox */
1176 prox = 0;
1177
1178 if (prox) {
1179 input_report_abs(input, ABS_X, x);
1180 input_report_abs(input, ABS_Y, y);
Ping Chengec67bbe2009-12-15 00:35:24 -08001181 }
Ping Chenga43c7c52011-03-12 20:34:42 -08001182 input_report_key(input, BTN_TOUCH, prox);
1183
1184 /* keep touch state for pen events */
1185 wacom->shared->touch_down = prox;
1186
1187 return 1;
Ping Chengec67bbe2009-12-15 00:35:24 -08001188}
1189
Ping Cheng8aa9a9a2011-03-12 20:34:11 -08001190static int wacom_tpc_pen(struct wacom_wac *wacom)
Ping Cheng545f4e92008-11-24 11:44:27 -05001191{
Jason Gerecke74b63412014-04-19 13:50:22 -07001192 unsigned char *data = wacom->data;
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -07001193 struct input_dev *input = wacom->input;
Ping Chenga43c7c52011-03-12 20:34:42 -08001194 bool prox = data[1] & 0x20;
Ping Cheng8aa9a9a2011-03-12 20:34:11 -08001195
Ping Chenga43c7c52011-03-12 20:34:42 -08001196 if (!wacom->shared->stylus_in_proximity) /* first in prox */
Ping Cheng8aa9a9a2011-03-12 20:34:11 -08001197 /* Going into proximity select tool */
1198 wacom->tool[0] = (data[1] & 0x0c) ? BTN_TOOL_RUBBER : BTN_TOOL_PEN;
Ping Cheng8aa9a9a2011-03-12 20:34:11 -08001199
Ping Chenga43c7c52011-03-12 20:34:42 -08001200 /* keep pen state for touch events */
1201 wacom->shared->stylus_in_proximity = prox;
Ping Cheng8aa9a9a2011-03-12 20:34:11 -08001202
Ping Chenga43c7c52011-03-12 20:34:42 -08001203 /* send pen events only when touch is up or forced out */
1204 if (!wacom->shared->touch_down) {
1205 input_report_key(input, BTN_STYLUS, data[1] & 0x02);
1206 input_report_key(input, BTN_STYLUS2, data[1] & 0x10);
1207 input_report_abs(input, ABS_X, le16_to_cpup((__le16 *)&data[2]));
1208 input_report_abs(input, ABS_Y, le16_to_cpup((__le16 *)&data[4]));
Jason Gerecke0b335ca2014-07-24 13:15:31 -07001209 input_report_abs(input, ABS_PRESSURE, ((data[7] & 0x07) << 8) | data[6]);
Ping Chenga43c7c52011-03-12 20:34:42 -08001210 input_report_key(input, BTN_TOUCH, data[1] & 0x05);
1211 input_report_key(input, wacom->tool[0], prox);
1212 return 1;
1213 }
1214
1215 return 0;
Ping Cheng8aa9a9a2011-03-12 20:34:11 -08001216}
1217
1218static int wacom_tpc_irq(struct wacom_wac *wacom, size_t len)
1219{
Jason Gerecke74b63412014-04-19 13:50:22 -07001220 unsigned char *data = wacom->data;
Ping Cheng545f4e92008-11-24 11:44:27 -05001221
Dmitry Torokhoveb71d1b2012-05-02 00:13:38 -07001222 dev_dbg(wacom->input->dev.parent,
1223 "%s: received report #%d\n", __func__, data[0]);
Ping Cheng545f4e92008-11-24 11:44:27 -05001224
Ping Cheng31175a82012-01-31 00:07:33 -08001225 switch (len) {
1226 case WACOM_PKGLEN_TPC1FG:
Ping Cheng19635182012-04-29 21:09:18 -07001227 return wacom_tpc_single_touch(wacom, len);
Ping Cheng31175a82012-01-31 00:07:33 -08001228
1229 case WACOM_PKGLEN_TPC2FG:
Ping Cheng19635182012-04-29 21:09:18 -07001230 return wacom_tpc_mt_touch(wacom);
Ping Cheng31175a82012-01-31 00:07:33 -08001231
Jason Gerecked51ddb22014-05-14 17:14:29 -07001232 case WACOM_PKGLEN_PENABLED:
1233 return wacom_tpc_pen(wacom);
1234
Ping Cheng31175a82012-01-31 00:07:33 -08001235 default:
1236 switch (data[0]) {
1237 case WACOM_REPORT_TPC1FG:
1238 case WACOM_REPORT_TPCHID:
1239 case WACOM_REPORT_TPCST:
Ping Chengac173832012-06-12 00:15:06 -07001240 case WACOM_REPORT_TPC1FGE:
Ping Cheng31175a82012-01-31 00:07:33 -08001241 return wacom_tpc_single_touch(wacom, len);
1242
Ping Cheng19635182012-04-29 21:09:18 -07001243 case WACOM_REPORT_TPCMT:
Jason Gerecked51ddb22014-05-14 17:14:29 -07001244 case WACOM_REPORT_TPCMT2:
Ping Cheng19635182012-04-29 21:09:18 -07001245 return wacom_mt_touch(wacom);
1246
Ping Cheng31175a82012-01-31 00:07:33 -08001247 case WACOM_REPORT_PENABLED:
1248 return wacom_tpc_pen(wacom);
1249 }
1250 }
Ping Cheng545f4e92008-11-24 11:44:27 -05001251
Ping Cheng8aa9a9a2011-03-12 20:34:11 -08001252 return 0;
Ping Cheng545f4e92008-11-24 11:44:27 -05001253}
1254
Benjamin Tissoires7704ac92014-09-23 12:08:08 -04001255static void wacom_map_usage(struct wacom *wacom, struct hid_usage *usage,
1256 struct hid_field *field, __u8 type, __u16 code, int fuzz)
1257{
1258 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
1259 struct input_dev *input = wacom_wac->input;
1260 int fmin = field->logical_minimum;
1261 int fmax = field->logical_maximum;
1262
1263 usage->type = type;
1264 usage->code = code;
1265
1266 set_bit(type, input->evbit);
1267
1268 switch (type) {
1269 case EV_ABS:
1270 input_set_abs_params(input, code, fmin, fmax, fuzz, 0);
1271 input_abs_set_res(input, code,
1272 hidinput_calc_abs_res(field, code));
1273 break;
1274 case EV_KEY:
1275 input_set_capability(input, EV_KEY, code);
1276 break;
1277 case EV_MSC:
1278 input_set_capability(input, EV_MSC, code);
1279 break;
1280 }
1281}
1282
1283static void wacom_wac_pen_usage_mapping(struct hid_device *hdev,
1284 struct hid_field *field, struct hid_usage *usage)
1285{
1286 struct wacom *wacom = hid_get_drvdata(hdev);
1287
1288 switch (usage->hid) {
1289 case HID_GD_X:
1290 wacom_map_usage(wacom, usage, field, EV_ABS, ABS_X, 4);
1291 break;
1292 case HID_GD_Y:
1293 wacom_map_usage(wacom, usage, field, EV_ABS, ABS_Y, 4);
1294 break;
1295 case HID_DG_TIPPRESSURE:
1296 wacom_map_usage(wacom, usage, field, EV_ABS, ABS_PRESSURE, 0);
1297 break;
1298 case HID_DG_INRANGE:
1299 wacom_map_usage(wacom, usage, field, EV_KEY, BTN_TOOL_PEN, 0);
1300 break;
1301 case HID_DG_INVERT:
1302 wacom_map_usage(wacom, usage, field, EV_KEY,
1303 BTN_TOOL_RUBBER, 0);
1304 break;
1305 case HID_DG_ERASER:
1306 case HID_DG_TIPSWITCH:
1307 wacom_map_usage(wacom, usage, field, EV_KEY, BTN_TOUCH, 0);
1308 break;
1309 case HID_DG_BARRELSWITCH:
1310 wacom_map_usage(wacom, usage, field, EV_KEY, BTN_STYLUS, 0);
1311 break;
1312 case HID_DG_BARRELSWITCH2:
1313 wacom_map_usage(wacom, usage, field, EV_KEY, BTN_STYLUS2, 0);
1314 break;
1315 case HID_DG_TOOLSERIALNUMBER:
1316 wacom_map_usage(wacom, usage, field, EV_MSC, MSC_SERIAL, 0);
1317 break;
1318 }
1319}
1320
1321static int wacom_wac_pen_event(struct hid_device *hdev, struct hid_field *field,
1322 struct hid_usage *usage, __s32 value)
1323{
1324 struct wacom *wacom = hid_get_drvdata(hdev);
1325 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
1326 struct input_dev *input = wacom_wac->input;
1327
1328 /* checking which Tool / tip switch to send */
1329 switch (usage->hid) {
1330 case HID_DG_INRANGE:
1331 wacom_wac->hid_data.inrange_state = value;
1332 return 0;
1333 case HID_DG_INVERT:
1334 wacom_wac->hid_data.invert_state = value;
1335 return 0;
1336 case HID_DG_ERASER:
1337 case HID_DG_TIPSWITCH:
1338 wacom_wac->hid_data.tipswitch |= value;
1339 return 0;
1340 }
1341
1342 /* send pen events only when touch is up or forced out */
1343 if (!usage->type || wacom_wac->shared->touch_down)
1344 return 0;
1345
1346 input_event(input, usage->type, usage->code, value);
1347
1348 return 0;
1349}
1350
1351static void wacom_wac_pen_report(struct hid_device *hdev,
1352 struct hid_report *report)
1353{
1354 struct wacom *wacom = hid_get_drvdata(hdev);
1355 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
1356 struct input_dev *input = wacom_wac->input;
1357 bool prox = wacom_wac->hid_data.inrange_state;
1358
1359 if (!wacom_wac->shared->stylus_in_proximity) /* first in prox */
1360 /* Going into proximity select tool */
1361 wacom_wac->tool[0] = wacom_wac->hid_data.invert_state ?
1362 BTN_TOOL_RUBBER : BTN_TOOL_PEN;
1363
1364 /* keep pen state for touch events */
1365 wacom_wac->shared->stylus_in_proximity = prox;
1366
1367 /* send pen events only when touch is up or forced out */
1368 if (!wacom_wac->shared->touch_down) {
1369 input_report_key(input, BTN_TOUCH,
1370 wacom_wac->hid_data.tipswitch);
1371 input_report_key(input, wacom_wac->tool[0], prox);
1372
1373 wacom_wac->hid_data.tipswitch = false;
1374
1375 input_sync(input);
1376 }
1377}
1378
Benjamin Tissoires5ae6e892014-09-23 12:08:09 -04001379static void wacom_wac_finger_usage_mapping(struct hid_device *hdev,
1380 struct hid_field *field, struct hid_usage *usage)
1381{
1382 struct wacom *wacom = hid_get_drvdata(hdev);
1383 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
Jason Gerecke601a22f2014-12-10 16:26:04 -08001384 struct wacom_features *features = &wacom_wac->features;
Benjamin Tissoires5ae6e892014-09-23 12:08:09 -04001385 unsigned touch_max = wacom_wac->features.touch_max;
1386
1387 switch (usage->hid) {
1388 case HID_GD_X:
Jason Gerecke601a22f2014-12-10 16:26:04 -08001389 features->last_slot_field = usage->hid;
Benjamin Tissoires5ae6e892014-09-23 12:08:09 -04001390 if (touch_max == 1)
1391 wacom_map_usage(wacom, usage, field, EV_ABS, ABS_X, 4);
1392 else
1393 wacom_map_usage(wacom, usage, field, EV_ABS,
1394 ABS_MT_POSITION_X, 4);
1395 break;
1396 case HID_GD_Y:
Jason Gerecke601a22f2014-12-10 16:26:04 -08001397 features->last_slot_field = usage->hid;
Benjamin Tissoires5ae6e892014-09-23 12:08:09 -04001398 if (touch_max == 1)
1399 wacom_map_usage(wacom, usage, field, EV_ABS, ABS_Y, 4);
1400 else
1401 wacom_map_usage(wacom, usage, field, EV_ABS,
1402 ABS_MT_POSITION_Y, 4);
1403 break;
1404 case HID_DG_CONTACTID:
Jason Gerecke601a22f2014-12-10 16:26:04 -08001405 features->last_slot_field = usage->hid;
Benjamin Tissoires5ae6e892014-09-23 12:08:09 -04001406 break;
1407 case HID_DG_INRANGE:
Jason Gerecke601a22f2014-12-10 16:26:04 -08001408 features->last_slot_field = usage->hid;
Benjamin Tissoires5ae6e892014-09-23 12:08:09 -04001409 break;
1410 case HID_DG_INVERT:
Jason Gerecke601a22f2014-12-10 16:26:04 -08001411 features->last_slot_field = usage->hid;
Benjamin Tissoires5ae6e892014-09-23 12:08:09 -04001412 break;
1413 case HID_DG_TIPSWITCH:
Jason Gerecke601a22f2014-12-10 16:26:04 -08001414 features->last_slot_field = usage->hid;
Benjamin Tissoires5ae6e892014-09-23 12:08:09 -04001415 wacom_map_usage(wacom, usage, field, EV_KEY, BTN_TOUCH, 0);
1416 break;
1417 }
1418}
1419
Jason Gerecke601a22f2014-12-10 16:26:04 -08001420static void wacom_wac_finger_slot(struct wacom_wac *wacom_wac,
1421 struct input_dev *input)
1422{
1423 struct hid_data *hid_data = &wacom_wac->hid_data;
1424 bool mt = wacom_wac->features.touch_max > 1;
1425 bool prox = hid_data->tipswitch &&
1426 !wacom_wac->shared->stylus_in_proximity;
1427
1428 if (mt) {
1429 int slot;
1430
1431 slot = input_mt_get_slot_by_key(input, hid_data->id);
1432 input_mt_slot(input, slot);
1433 input_mt_report_slot_state(input, MT_TOOL_FINGER, prox);
1434 }
1435 else {
1436 input_report_key(input, BTN_TOUCH, prox);
1437 }
1438
1439 if (prox) {
1440 input_report_abs(input, mt ? ABS_MT_POSITION_X : ABS_X,
1441 hid_data->x);
1442 input_report_abs(input, mt ? ABS_MT_POSITION_Y : ABS_Y,
1443 hid_data->y);
1444 }
1445}
1446
Benjamin Tissoires5ae6e892014-09-23 12:08:09 -04001447static int wacom_wac_finger_event(struct hid_device *hdev,
1448 struct hid_field *field, struct hid_usage *usage, __s32 value)
1449{
1450 struct wacom *wacom = hid_get_drvdata(hdev);
1451 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
1452
1453 switch (usage->hid) {
1454 case HID_GD_X:
1455 wacom_wac->hid_data.x = value;
1456 break;
1457 case HID_GD_Y:
1458 wacom_wac->hid_data.y = value;
1459 break;
1460 case HID_DG_CONTACTID:
1461 wacom_wac->hid_data.id = value;
1462 break;
1463 case HID_DG_TIPSWITCH:
1464 wacom_wac->hid_data.tipswitch = value;
1465 break;
1466 }
1467
1468
Jason Gerecke601a22f2014-12-10 16:26:04 -08001469 if (usage->usage_index + 1 == field->report_count) {
1470 if (usage->hid == wacom_wac->features.last_slot_field)
1471 wacom_wac_finger_slot(wacom_wac, wacom_wac->input);
1472 }
1473
Benjamin Tissoires5ae6e892014-09-23 12:08:09 -04001474 return 0;
1475}
1476
Jason Gerecke601a22f2014-12-10 16:26:04 -08001477static int wacom_wac_finger_count_touches(struct hid_device *hdev)
Benjamin Tissoires5ae6e892014-09-23 12:08:09 -04001478{
Jason Gerecke601a22f2014-12-10 16:26:04 -08001479 struct wacom *wacom = hid_get_drvdata(hdev);
1480 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
1481 struct input_dev *input = wacom_wac->input;
1482 unsigned touch_max = wacom_wac->features.touch_max;
1483 int count = 0;
1484 int i;
Benjamin Tissoires5ae6e892014-09-23 12:08:09 -04001485
Jason Gerecke601a22f2014-12-10 16:26:04 -08001486 if (touch_max == 1)
1487 return wacom_wac->hid_data.tipswitch &&
1488 !wacom_wac->shared->stylus_in_proximity;
Benjamin Tissoires5ae6e892014-09-23 12:08:09 -04001489
Jason Gerecke601a22f2014-12-10 16:26:04 -08001490 for (i = 0; i < input->mt->num_slots; i++) {
1491 struct input_mt_slot *ps = &input->mt->slots[i];
1492 int id = input_mt_get_value(ps, ABS_MT_TRACKING_ID);
1493 if (id >= 0)
1494 count++;
Benjamin Tissoires5ae6e892014-09-23 12:08:09 -04001495 }
Benjamin Tissoires5ae6e892014-09-23 12:08:09 -04001496
Jason Gerecke601a22f2014-12-10 16:26:04 -08001497 return count;
Benjamin Tissoires5ae6e892014-09-23 12:08:09 -04001498}
1499
1500static void wacom_wac_finger_report(struct hid_device *hdev,
1501 struct hid_report *report)
1502{
1503 struct wacom *wacom = hid_get_drvdata(hdev);
1504 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
1505 struct input_dev *input = wacom_wac->input;
Benjamin Tissoires5ae6e892014-09-23 12:08:09 -04001506 unsigned touch_max = wacom_wac->features.touch_max;
1507
1508 if (touch_max > 1)
Jason Gerecke601a22f2014-12-10 16:26:04 -08001509 input_mt_sync_frame(input);
1510
Benjamin Tissoires5ae6e892014-09-23 12:08:09 -04001511 input_sync(input);
1512
1513 /* keep touch state for pen event */
Jason Gerecke601a22f2014-12-10 16:26:04 -08001514 wacom_wac->shared->touch_down = wacom_wac_finger_count_touches(hdev);
Benjamin Tissoires5ae6e892014-09-23 12:08:09 -04001515}
1516
Benjamin Tissoires7704ac92014-09-23 12:08:08 -04001517#define WACOM_PEN_FIELD(f) (((f)->logical == HID_DG_STYLUS) || \
Jason Gereckec376e712014-11-24 15:32:12 -08001518 ((f)->physical == HID_DG_STYLUS) || \
1519 ((f)->application == HID_DG_PEN))
Benjamin Tissoires7704ac92014-09-23 12:08:08 -04001520#define WACOM_FINGER_FIELD(f) (((f)->logical == HID_DG_FINGER) || \
Jason Gereckec376e712014-11-24 15:32:12 -08001521 ((f)->physical == HID_DG_FINGER) || \
1522 ((f)->application == HID_DG_TOUCHSCREEN))
Benjamin Tissoires7704ac92014-09-23 12:08:08 -04001523
1524void wacom_wac_usage_mapping(struct hid_device *hdev,
1525 struct hid_field *field, struct hid_usage *usage)
1526{
1527 struct wacom *wacom = hid_get_drvdata(hdev);
1528 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
1529 struct input_dev *input = wacom_wac->input;
1530
1531 /* currently, only direct devices have proper hid report descriptors */
1532 __set_bit(INPUT_PROP_DIRECT, input->propbit);
1533
1534 if (WACOM_PEN_FIELD(field))
1535 return wacom_wac_pen_usage_mapping(hdev, field, usage);
Benjamin Tissoires5ae6e892014-09-23 12:08:09 -04001536
1537 if (WACOM_FINGER_FIELD(field))
1538 return wacom_wac_finger_usage_mapping(hdev, field, usage);
Benjamin Tissoires7704ac92014-09-23 12:08:08 -04001539}
1540
1541int wacom_wac_event(struct hid_device *hdev, struct hid_field *field,
1542 struct hid_usage *usage, __s32 value)
1543{
1544 struct wacom *wacom = hid_get_drvdata(hdev);
1545
1546 if (wacom->wacom_wac.features.type != HID_GENERIC)
1547 return 0;
1548
1549 if (WACOM_PEN_FIELD(field))
1550 return wacom_wac_pen_event(hdev, field, usage, value);
1551
Benjamin Tissoires5ae6e892014-09-23 12:08:09 -04001552 if (WACOM_FINGER_FIELD(field))
1553 return wacom_wac_finger_event(hdev, field, usage, value);
1554
Benjamin Tissoires7704ac92014-09-23 12:08:08 -04001555 return 0;
1556}
1557
1558void wacom_wac_report(struct hid_device *hdev, struct hid_report *report)
1559{
1560 struct wacom *wacom = hid_get_drvdata(hdev);
1561 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
1562 struct hid_field *field = report->field[0];
1563
1564 if (wacom_wac->features.type != HID_GENERIC)
1565 return;
1566
1567 if (WACOM_PEN_FIELD(field))
1568 return wacom_wac_pen_report(hdev, report);
Benjamin Tissoires5ae6e892014-09-23 12:08:09 -04001569
1570 if (WACOM_FINGER_FIELD(field))
1571 return wacom_wac_finger_report(hdev, report);
Benjamin Tissoires7704ac92014-09-23 12:08:08 -04001572}
1573
Chris Bagwelle1d38e42010-09-12 00:09:27 -07001574static int wacom_bpt_touch(struct wacom_wac *wacom)
Henrik Rydbergcb734c02010-09-05 12:53:16 -07001575{
Henrik Rydbergf4ccbef2010-09-05 12:57:13 -07001576 struct wacom_features *features = &wacom->features;
Henrik Rydbergcb734c02010-09-05 12:53:16 -07001577 struct input_dev *input = wacom->input;
Benjamin Tissoires31168712014-07-24 12:50:10 -07001578 struct input_dev *pad_input = wacom->pad_input;
Henrik Rydbergcb734c02010-09-05 12:53:16 -07001579 unsigned char *data = wacom->data;
Henrik Rydbergcb734c02010-09-05 12:53:16 -07001580 int i;
1581
Chris Bagwell5a6c8652011-11-07 19:52:42 -08001582 if (data[0] != 0x02)
1583 return 0;
1584
Henrik Rydbergcb734c02010-09-05 12:53:16 -07001585 for (i = 0; i < 2; i++) {
Chris Bagwell8f906862011-09-09 13:38:10 -07001586 int offset = (data[1] & 0x80) ? (8 * i) : (9 * i);
1587 bool touch = data[offset + 3] & 0x80;
Henrik Rydbergc5f4dec2010-12-15 13:50:34 +01001588
Chris Bagwell33d5f712010-09-12 00:12:28 -07001589 /*
1590 * Touch events need to be disabled while stylus is
1591 * in proximity because user's hand is resting on touchpad
1592 * and sending unwanted events. User expects tablet buttons
1593 * to continue working though.
1594 */
Chris Bagwell8f906862011-09-09 13:38:10 -07001595 touch = touch && !wacom->shared->stylus_in_proximity;
1596
1597 input_mt_slot(input, i);
1598 input_mt_report_slot_state(input, MT_TOOL_FINGER, touch);
Henrik Rydbergc5f4dec2010-12-15 13:50:34 +01001599 if (touch) {
Chris Bagwell8f906862011-09-09 13:38:10 -07001600 int x = get_unaligned_be16(&data[offset + 3]) & 0x7ff;
1601 int y = get_unaligned_be16(&data[offset + 5]) & 0x7ff;
Henrik Rydbergf4ccbef2010-09-05 12:57:13 -07001602 if (features->quirks & WACOM_QUIRK_BBTOUCH_LOWRES) {
1603 x <<= 5;
1604 y <<= 5;
1605 }
Henrik Rydbergcb734c02010-09-05 12:53:16 -07001606 input_report_abs(input, ABS_MT_POSITION_X, x);
1607 input_report_abs(input, ABS_MT_POSITION_Y, y);
Henrik Rydbergcb734c02010-09-05 12:53:16 -07001608 }
Henrik Rydbergcb734c02010-09-05 12:53:16 -07001609 }
1610
Henrik Rydbergc5f4dec2010-12-15 13:50:34 +01001611 input_mt_report_pointer_emulation(input, true);
Henrik Rydbergcb734c02010-09-05 12:53:16 -07001612
Benjamin Tissoires31168712014-07-24 12:50:10 -07001613 input_report_key(pad_input, BTN_LEFT, (data[1] & 0x08) != 0);
1614 input_report_key(pad_input, BTN_FORWARD, (data[1] & 0x04) != 0);
1615 input_report_key(pad_input, BTN_BACK, (data[1] & 0x02) != 0);
1616 input_report_key(pad_input, BTN_RIGHT, (data[1] & 0x01) != 0);
Henrik Rydbergcb734c02010-09-05 12:53:16 -07001617
Benjamin Tissoires31168712014-07-24 12:50:10 -07001618 return 1;
Henrik Rydbergcb734c02010-09-05 12:53:16 -07001619}
1620
Chris Bagwell73149ab2011-10-26 22:34:21 -07001621static void wacom_bpt3_touch_msg(struct wacom_wac *wacom, unsigned char *data)
1622{
Ping Cheng9a35c412013-09-20 09:51:56 -07001623 struct wacom_features *features = &wacom->features;
Chris Bagwell73149ab2011-10-26 22:34:21 -07001624 struct input_dev *input = wacom->input;
Chris Bagwell73149ab2011-10-26 22:34:21 -07001625 bool touch = data[1] & 0x80;
Ping Cheng02295e62013-01-04 23:56:00 -08001626 int slot = input_mt_get_slot_by_key(input, data[0]);
1627
1628 if (slot < 0)
1629 return;
Chris Bagwell73149ab2011-10-26 22:34:21 -07001630
1631 touch = touch && !wacom->shared->stylus_in_proximity;
1632
Ping Cheng02295e62013-01-04 23:56:00 -08001633 input_mt_slot(input, slot);
Chris Bagwell73149ab2011-10-26 22:34:21 -07001634 input_mt_report_slot_state(input, MT_TOOL_FINGER, touch);
1635
1636 if (touch) {
1637 int x = (data[2] << 4) | (data[4] >> 4);
1638 int y = (data[3] << 4) | (data[4] & 0x0f);
Ping Cheng9a35c412013-09-20 09:51:56 -07001639 int width, height;
Jason Gerecke4e904952012-10-03 17:19:11 -07001640
Ping Cheng9a35c412013-09-20 09:51:56 -07001641 if (features->type >= INTUOSPS && features->type <= INTUOSPL) {
Jason Gerecke0b279da2013-11-25 18:43:16 -08001642 width = data[5] * 100;
1643 height = data[6] * 100;
Ping Cheng9a35c412013-09-20 09:51:56 -07001644 } else {
1645 /*
1646 * "a" is a scaled-down area which we assume is
1647 * roughly circular and which can be described as:
1648 * a=(pi*r^2)/C.
1649 */
1650 int a = data[5];
Ping Chengd7da3a32014-06-13 13:37:33 -07001651 int x_res = input_abs_get_res(input, ABS_MT_POSITION_X);
1652 int y_res = input_abs_get_res(input, ABS_MT_POSITION_Y);
1653 width = 2 * int_sqrt(a * WACOM_CONTACT_AREA_SCALE);
Ping Cheng9a35c412013-09-20 09:51:56 -07001654 height = width * y_res / x_res;
1655 }
Chris Bagwell73149ab2011-10-26 22:34:21 -07001656
1657 input_report_abs(input, ABS_MT_POSITION_X, x);
1658 input_report_abs(input, ABS_MT_POSITION_Y, y);
Jason Gerecke4e904952012-10-03 17:19:11 -07001659 input_report_abs(input, ABS_MT_TOUCH_MAJOR, width);
1660 input_report_abs(input, ABS_MT_TOUCH_MINOR, height);
Chris Bagwell73149ab2011-10-26 22:34:21 -07001661 }
1662}
1663
1664static void wacom_bpt3_button_msg(struct wacom_wac *wacom, unsigned char *data)
1665{
Benjamin Tissoires31168712014-07-24 12:50:10 -07001666 struct input_dev *input = wacom->pad_input;
Ping Chengb5fd2a32013-11-25 18:44:55 -08001667 struct wacom_features *features = &wacom->features;
Chris Bagwell73149ab2011-10-26 22:34:21 -07001668
Ping Chengb5fd2a32013-11-25 18:44:55 -08001669 if (features->type == INTUOSHT) {
1670 input_report_key(input, BTN_LEFT, (data[1] & 0x02) != 0);
1671 input_report_key(input, BTN_BACK, (data[1] & 0x08) != 0);
1672 } else {
1673 input_report_key(input, BTN_BACK, (data[1] & 0x02) != 0);
1674 input_report_key(input, BTN_LEFT, (data[1] & 0x08) != 0);
1675 }
Chris Bagwell73149ab2011-10-26 22:34:21 -07001676 input_report_key(input, BTN_FORWARD, (data[1] & 0x04) != 0);
Chris Bagwell73149ab2011-10-26 22:34:21 -07001677 input_report_key(input, BTN_RIGHT, (data[1] & 0x01) != 0);
1678}
1679
1680static int wacom_bpt3_touch(struct wacom_wac *wacom)
1681{
1682 struct input_dev *input = wacom->input;
1683 unsigned char *data = wacom->data;
Jason Gerecke19d57d32012-03-06 10:19:19 -08001684 int count = data[1] & 0x07;
Chris Bagwell73149ab2011-10-26 22:34:21 -07001685 int i;
1686
Chris Bagwell5a6c8652011-11-07 19:52:42 -08001687 if (data[0] != 0x02)
1688 return 0;
1689
Chris Bagwell73149ab2011-10-26 22:34:21 -07001690 /* data has up to 7 fixed sized 8-byte messages starting at data[2] */
1691 for (i = 0; i < count; i++) {
1692 int offset = (8 * i) + 2;
1693 int msg_id = data[offset];
1694
1695 if (msg_id >= 2 && msg_id <= 17)
1696 wacom_bpt3_touch_msg(wacom, data + offset);
1697 else if (msg_id == 128)
1698 wacom_bpt3_button_msg(wacom, data + offset);
1699
1700 }
Chris Bagwell73149ab2011-10-26 22:34:21 -07001701 input_mt_report_pointer_emulation(input, true);
1702
Benjamin Tissoires31168712014-07-24 12:50:10 -07001703 return 1;
Chris Bagwell73149ab2011-10-26 22:34:21 -07001704}
1705
Chris Bagwell2aaacb12010-09-12 00:11:35 -07001706static int wacom_bpt_pen(struct wacom_wac *wacom)
1707{
Ping Cheng961794a2013-12-05 12:54:53 -08001708 struct wacom_features *features = &wacom->features;
Chris Bagwell2aaacb12010-09-12 00:11:35 -07001709 struct input_dev *input = wacom->input;
1710 unsigned char *data = wacom->data;
1711 int prox = 0, x = 0, y = 0, p = 0, d = 0, pen = 0, btn1 = 0, btn2 = 0;
1712
Ping Cheng961794a2013-12-05 12:54:53 -08001713 if (data[0] != WACOM_REPORT_PENABLED && data[0] != WACOM_REPORT_USB)
Chris Bagwell5a6c8652011-11-07 19:52:42 -08001714 return 0;
1715
Ping Cheng961794a2013-12-05 12:54:53 -08001716 if (data[0] == WACOM_REPORT_USB) {
Ping Cheng44b96832014-11-06 17:30:51 -08001717 if (features->type == INTUOSHT &&
1718 wacom->shared->touch_input &&
1719 features->touch_max) {
Ping Cheng961794a2013-12-05 12:54:53 -08001720 input_report_switch(wacom->shared->touch_input,
1721 SW_MUTE_DEVICE, data[8] & 0x40);
1722 input_sync(wacom->shared->touch_input);
1723 }
1724 return 0;
1725 }
1726
Chris Bagwellc5981412011-10-26 22:28:34 -07001727 prox = (data[1] & 0x20) == 0x20;
Chris Bagwell2aaacb12010-09-12 00:11:35 -07001728
1729 /*
1730 * All reports shared between PEN and RUBBER tool must be
1731 * forced to a known starting value (zero) when transitioning to
1732 * out-of-prox.
1733 *
1734 * If not reset then, to userspace, it will look like lost events
1735 * if new tool comes in-prox with same values as previous tool sent.
1736 *
1737 * Hardware does report zero in most out-of-prox cases but not all.
1738 */
1739 if (prox) {
1740 if (!wacom->shared->stylus_in_proximity) {
1741 if (data[1] & 0x08) {
1742 wacom->tool[0] = BTN_TOOL_RUBBER;
1743 wacom->id[0] = ERASER_DEVICE_ID;
1744 } else {
1745 wacom->tool[0] = BTN_TOOL_PEN;
1746 wacom->id[0] = STYLUS_DEVICE_ID;
1747 }
1748 wacom->shared->stylus_in_proximity = true;
1749 }
1750 x = le16_to_cpup((__le16 *)&data[2]);
1751 y = le16_to_cpup((__le16 *)&data[4]);
1752 p = le16_to_cpup((__le16 *)&data[6]);
Chris Bagwellc18c2ce2011-10-10 08:52:13 -07001753 /*
1754 * Convert distance from out prox to distance from tablet.
1755 * distance will be greater than distance_max once
1756 * touching and applying pressure; do not report negative
1757 * distance.
1758 */
Ping Cheng961794a2013-12-05 12:54:53 -08001759 if (data[8] <= features->distance_max)
1760 d = features->distance_max - data[8];
Chris Bagwellc18c2ce2011-10-10 08:52:13 -07001761
Chris Bagwell2aaacb12010-09-12 00:11:35 -07001762 pen = data[1] & 0x01;
1763 btn1 = data[1] & 0x02;
1764 btn2 = data[1] & 0x04;
1765 }
1766
1767 input_report_key(input, BTN_TOUCH, pen);
1768 input_report_key(input, BTN_STYLUS, btn1);
1769 input_report_key(input, BTN_STYLUS2, btn2);
1770
1771 input_report_abs(input, ABS_X, x);
1772 input_report_abs(input, ABS_Y, y);
1773 input_report_abs(input, ABS_PRESSURE, p);
1774 input_report_abs(input, ABS_DISTANCE, d);
1775
1776 if (!prox) {
1777 wacom->id[0] = 0;
1778 wacom->shared->stylus_in_proximity = false;
1779 }
1780
1781 input_report_key(input, wacom->tool[0], prox); /* PEN or RUBBER */
1782 input_report_abs(input, ABS_MISC, wacom->id[0]); /* TOOL ID */
1783
1784 return 1;
1785}
1786
Chris Bagwelle1d38e42010-09-12 00:09:27 -07001787static int wacom_bpt_irq(struct wacom_wac *wacom, size_t len)
1788{
1789 if (len == WACOM_PKGLEN_BBTOUCH)
1790 return wacom_bpt_touch(wacom);
Chris Bagwell73149ab2011-10-26 22:34:21 -07001791 else if (len == WACOM_PKGLEN_BBTOUCH3)
1792 return wacom_bpt3_touch(wacom);
1793 else if (len == WACOM_PKGLEN_BBFUN || len == WACOM_PKGLEN_BBPEN)
Chris Bagwell2aaacb12010-09-12 00:11:35 -07001794 return wacom_bpt_pen(wacom);
Chris Bagwelle1d38e42010-09-12 00:09:27 -07001795
1796 return 0;
1797}
1798
Chris Bagwelld3825d52012-03-25 23:26:11 -07001799static int wacom_wireless_irq(struct wacom_wac *wacom, size_t len)
1800{
Chris Bagwell16bf2882012-03-25 23:26:20 -07001801 unsigned char *data = wacom->data;
1802 int connected;
1803
Ping Chengb5fd2a32013-11-25 18:44:55 -08001804 if (len != WACOM_PKGLEN_WIRELESS || data[0] != WACOM_REPORT_WL)
Chris Bagwelld3825d52012-03-25 23:26:11 -07001805 return 0;
1806
Chris Bagwell16bf2882012-03-25 23:26:20 -07001807 connected = data[1] & 0x01;
1808 if (connected) {
Benjamin Tissoiresac8d1012014-07-25 17:29:48 -07001809 int pid, battery, ps_connected;
Chris Bagwell16bf2882012-03-25 23:26:20 -07001810
Ping Cheng961794a2013-12-05 12:54:53 -08001811 if ((wacom->shared->type == INTUOSHT) &&
Ping Cheng44b96832014-11-06 17:30:51 -08001812 wacom->shared->touch_input &&
1813 wacom->shared->touch_max) {
Ping Cheng961794a2013-12-05 12:54:53 -08001814 input_report_switch(wacom->shared->touch_input,
1815 SW_MUTE_DEVICE, data[5] & 0x40);
1816 input_sync(wacom->shared->touch_input);
1817 }
1818
Chris Bagwell16bf2882012-03-25 23:26:20 -07001819 pid = get_unaligned_be16(&data[6]);
Benjamin Tissoiresac8d1012014-07-25 17:29:48 -07001820 battery = (data[5] & 0x3f) * 100 / 31;
1821 ps_connected = !!(data[5] & 0x80);
Chris Bagwell16bf2882012-03-25 23:26:20 -07001822 if (wacom->pid != pid) {
1823 wacom->pid = pid;
1824 wacom_schedule_work(wacom);
1825 }
Benjamin Tissoiresac8d1012014-07-25 17:29:48 -07001826
1827 if (wacom->shared->type &&
1828 (battery != wacom->battery_capacity ||
1829 ps_connected != wacom->ps_connected)) {
1830 wacom->battery_capacity = battery;
1831 wacom->ps_connected = ps_connected;
1832 wacom->bat_charging = ps_connected &&
1833 wacom->battery_capacity < 100;
1834 wacom_notify_battery(wacom);
1835 }
Chris Bagwell16bf2882012-03-25 23:26:20 -07001836 } else if (wacom->pid != 0) {
1837 /* disconnected while previously connected */
1838 wacom->pid = 0;
1839 wacom_schedule_work(wacom);
Chris Bagwella1d552c2012-03-25 23:26:30 -07001840 wacom->battery_capacity = 0;
Benjamin Tissoiresac8d1012014-07-25 17:29:48 -07001841 wacom->bat_charging = 0;
1842 wacom->ps_connected = 0;
Chris Bagwell16bf2882012-03-25 23:26:20 -07001843 }
1844
Chris Bagwelld3825d52012-03-25 23:26:11 -07001845 return 0;
1846}
1847
Dmitry Torokhov95dd3b32010-03-19 22:18:15 -07001848void wacom_wac_irq(struct wacom_wac *wacom_wac, size_t len)
Ping Cheng3bea7332006-07-13 18:01:36 -07001849{
Dmitry Torokhov95dd3b32010-03-19 22:18:15 -07001850 bool sync;
1851
Jason Childse33da8a2010-02-17 22:38:31 -08001852 switch (wacom_wac->features.type) {
Dmitry Torokhov73a97f42010-03-19 22:18:15 -07001853 case PENPARTNER:
Dmitry Torokhov95dd3b32010-03-19 22:18:15 -07001854 sync = wacom_penpartner_irq(wacom_wac);
1855 break;
Ping Cheng545f4e92008-11-24 11:44:27 -05001856
Dmitry Torokhov73a97f42010-03-19 22:18:15 -07001857 case PL:
Dmitry Torokhov95dd3b32010-03-19 22:18:15 -07001858 sync = wacom_pl_irq(wacom_wac);
1859 break;
Ping Cheng545f4e92008-11-24 11:44:27 -05001860
Dmitry Torokhov73a97f42010-03-19 22:18:15 -07001861 case WACOM_G4:
1862 case GRAPHIRE:
Benjamin Tissoires387142b2014-08-06 13:52:56 -07001863 case GRAPHIRE_BT:
Dmitry Torokhov73a97f42010-03-19 22:18:15 -07001864 case WACOM_MO:
Dmitry Torokhov95dd3b32010-03-19 22:18:15 -07001865 sync = wacom_graphire_irq(wacom_wac);
1866 break;
Ping Cheng545f4e92008-11-24 11:44:27 -05001867
Dmitry Torokhov73a97f42010-03-19 22:18:15 -07001868 case PTU:
Dmitry Torokhov95dd3b32010-03-19 22:18:15 -07001869 sync = wacom_ptu_irq(wacom_wac);
1870 break;
Ping Cheng545f4e92008-11-24 11:44:27 -05001871
Ping Chengc8f2edc2010-06-28 01:10:51 -07001872 case DTU:
1873 sync = wacom_dtu_irq(wacom_wac);
1874 break;
1875
Ping Cheng497ab1f2014-01-20 20:18:04 -08001876 case DTUS:
Ping Chengfff00bf2014-12-04 18:23:04 -08001877 case DTUSX:
Ping Cheng497ab1f2014-01-20 20:18:04 -08001878 sync = wacom_dtus_irq(wacom_wac);
1879 break;
1880
Dmitry Torokhov73a97f42010-03-19 22:18:15 -07001881 case INTUOS:
1882 case INTUOS3S:
1883 case INTUOS3:
1884 case INTUOS3L:
1885 case INTUOS4S:
1886 case INTUOS4:
1887 case INTUOS4L:
1888 case CINTIQ:
1889 case WACOM_BEE:
Ping Cheng56218562013-05-05 19:56:18 -07001890 case WACOM_13HD:
Ping Cheng3a4b4aa2010-06-03 22:10:21 -07001891 case WACOM_21UX2:
Ping Chengd838c642012-07-24 23:54:11 -07001892 case WACOM_22HD:
Jason Gerecke803296b2011-12-12 00:11:45 -08001893 case WACOM_24HD:
Ping Chenga112e9f2013-02-13 20:20:01 -08001894 case DTK:
Jason Gerecke36d3c512013-09-20 09:47:35 -07001895 case CINTIQ_HYBRID:
Dmitry Torokhov95dd3b32010-03-19 22:18:15 -07001896 sync = wacom_intuos_irq(wacom_wac);
1897 break;
Ping Cheng545f4e92008-11-24 11:44:27 -05001898
Benjamin Tissoires81af7e62014-08-06 13:55:56 -07001899 case INTUOS4WL:
1900 sync = wacom_intuos_bt_irq(wacom_wac, len);
1901 break;
1902
Jason Gereckeb1e42792012-10-21 00:38:04 -07001903 case WACOM_24HDT:
1904 sync = wacom_24hdt_irq(wacom_wac);
1905 break;
1906
Jason Gereckeae584ca2012-04-03 15:50:40 -07001907 case INTUOS5S:
1908 case INTUOS5:
1909 case INTUOS5L:
Ping Cheng9a35c412013-09-20 09:51:56 -07001910 case INTUOSPS:
1911 case INTUOSPM:
1912 case INTUOSPL:
Jason Gereckeae584ca2012-04-03 15:50:40 -07001913 if (len == WACOM_PKGLEN_BBTOUCH3)
1914 sync = wacom_bpt3_touch(wacom_wac);
1915 else
1916 sync = wacom_intuos_irq(wacom_wac);
1917 break;
1918
Dmitry Torokhov73a97f42010-03-19 22:18:15 -07001919 case TABLETPC:
Ping Chengac173832012-06-12 00:15:06 -07001920 case TABLETPCE:
Dmitry Torokhov73a97f42010-03-19 22:18:15 -07001921 case TABLETPC2FG:
Ping Cheng19635182012-04-29 21:09:18 -07001922 case MTSCREEN:
Ping Cheng6afdc282012-11-03 12:16:15 -07001923 case MTTPC:
Jason Gerecked51ddb22014-05-14 17:14:29 -07001924 case MTTPC_B:
Dmitry Torokhov95dd3b32010-03-19 22:18:15 -07001925 sync = wacom_tpc_irq(wacom_wac, len);
1926 break;
Ping Cheng545f4e92008-11-24 11:44:27 -05001927
Henrik Rydbergcb734c02010-09-05 12:53:16 -07001928 case BAMBOO_PT:
Ping Chengb5fd2a32013-11-25 18:44:55 -08001929 case INTUOSHT:
Henrik Rydbergcb734c02010-09-05 12:53:16 -07001930 sync = wacom_bpt_irq(wacom_wac, len);
1931 break;
1932
Chris Bagwelld3825d52012-03-25 23:26:11 -07001933 case WIRELESS:
1934 sync = wacom_wireless_irq(wacom_wac, len);
1935 break;
1936
Dmitry Torokhov73a97f42010-03-19 22:18:15 -07001937 default:
Dmitry Torokhov95dd3b32010-03-19 22:18:15 -07001938 sync = false;
1939 break;
Ping Cheng3bea7332006-07-13 18:01:36 -07001940 }
Dmitry Torokhov95dd3b32010-03-19 22:18:15 -07001941
Benjamin Tissoiresd2d13f12014-07-24 12:48:28 -07001942 if (sync) {
Dmitry Torokhov95dd3b32010-03-19 22:18:15 -07001943 input_sync(wacom_wac->input);
Benjamin Tissoiresd2d13f12014-07-24 12:48:28 -07001944 if (wacom_wac->pad_input)
1945 input_sync(wacom_wac->pad_input);
1946 }
Ping Cheng3bea7332006-07-13 18:01:36 -07001947}
1948
Ping Cheng6521d0b2010-10-24 21:53:40 -07001949static void wacom_setup_cintiq(struct wacom_wac *wacom_wac)
Ping Cheng3bea7332006-07-13 18:01:36 -07001950{
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -07001951 struct input_dev *input_dev = wacom_wac->input;
1952
1953 input_set_capability(input_dev, EV_MSC, MSC_SERIAL);
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -07001954
1955 __set_bit(BTN_TOOL_RUBBER, input_dev->keybit);
1956 __set_bit(BTN_TOOL_PEN, input_dev->keybit);
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -07001957 __set_bit(BTN_TOOL_BRUSH, input_dev->keybit);
1958 __set_bit(BTN_TOOL_PENCIL, input_dev->keybit);
1959 __set_bit(BTN_TOOL_AIRBRUSH, input_dev->keybit);
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -07001960 __set_bit(BTN_STYLUS, input_dev->keybit);
1961 __set_bit(BTN_STYLUS2, input_dev->keybit);
1962
1963 input_set_abs_params(input_dev, ABS_DISTANCE,
1964 0, wacom_wac->features.distance_max, 0, 0);
1965 input_set_abs_params(input_dev, ABS_WHEEL, 0, 1023, 0, 0);
Jason Gereckeec5fc1c2014-11-18 16:50:08 -08001966 input_set_abs_params(input_dev, ABS_TILT_X, -64, 63, 0, 0);
Jason Gerecke26fe4122014-11-18 16:50:09 -08001967 input_abs_set_res(input_dev, ABS_TILT_X, 57);
Jason Gereckeec5fc1c2014-11-18 16:50:08 -08001968 input_set_abs_params(input_dev, ABS_TILT_Y, -64, 63, 0, 0);
Jason Gerecke26fe4122014-11-18 16:50:09 -08001969 input_abs_set_res(input_dev, ABS_TILT_Y, 57);
Ping Cheng6521d0b2010-10-24 21:53:40 -07001970}
1971
1972static void wacom_setup_intuos(struct wacom_wac *wacom_wac)
1973{
1974 struct input_dev *input_dev = wacom_wac->input;
1975
1976 input_set_capability(input_dev, EV_REL, REL_WHEEL);
1977
1978 wacom_setup_cintiq(wacom_wac);
1979
1980 __set_bit(BTN_LEFT, input_dev->keybit);
1981 __set_bit(BTN_RIGHT, input_dev->keybit);
1982 __set_bit(BTN_MIDDLE, input_dev->keybit);
1983 __set_bit(BTN_SIDE, input_dev->keybit);
1984 __set_bit(BTN_EXTRA, input_dev->keybit);
1985 __set_bit(BTN_TOOL_MOUSE, input_dev->keybit);
1986 __set_bit(BTN_TOOL_LENS, input_dev->keybit);
1987
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -07001988 input_set_abs_params(input_dev, ABS_RZ, -900, 899, 0, 0);
Jason Gerecke26fe4122014-11-18 16:50:09 -08001989 input_abs_set_res(input_dev, ABS_RZ, 287);
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -07001990 input_set_abs_params(input_dev, ABS_THROTTLE, -1023, 1023, 0, 0);
1991}
1992
Henrik Rydbergbc73dd32010-09-05 12:26:16 -07001993void wacom_setup_device_quirks(struct wacom_features *features)
1994{
1995
1996 /* touch device found but size is not defined. use default */
Ping Cheng84eb5aa2011-03-12 20:35:18 -08001997 if (features->device_type == BTN_TOOL_FINGER && !features->x_max) {
Henrik Rydbergbc73dd32010-09-05 12:26:16 -07001998 features->x_max = 1023;
1999 features->y_max = 1023;
2000 }
2001
2002 /* these device have multiple inputs */
Ping Chengea2e6022012-06-12 00:14:12 -07002003 if (features->type >= WIRELESS ||
Ping Chengb5fd2a32013-11-25 18:44:55 -08002004 (features->type >= INTUOS5S && features->type <= INTUOSHT) ||
Jason Gereckeaea2bf62012-10-21 00:38:03 -07002005 (features->oVid && features->oPid))
Henrik Rydbergbc73dd32010-09-05 12:26:16 -07002006 features->quirks |= WACOM_QUIRK_MULTI_INPUT;
Henrik Rydbergcb734c02010-09-05 12:53:16 -07002007
Chris Bagwell73149ab2011-10-26 22:34:21 -07002008 /* quirk for bamboo touch with 2 low res touches */
Henrik Rydbergcb734c02010-09-05 12:53:16 -07002009 if (features->type == BAMBOO_PT &&
Chris Bagwell73149ab2011-10-26 22:34:21 -07002010 features->pktlen == WACOM_PKGLEN_BBTOUCH) {
Henrik Rydbergf4ccbef2010-09-05 12:57:13 -07002011 features->x_max <<= 5;
2012 features->y_max <<= 5;
2013 features->x_fuzz <<= 5;
2014 features->y_fuzz <<= 5;
Henrik Rydbergf4ccbef2010-09-05 12:57:13 -07002015 features->quirks |= WACOM_QUIRK_BBTOUCH_LOWRES;
Henrik Rydbergcb734c02010-09-05 12:53:16 -07002016 }
Chris Bagwelld3825d52012-03-25 23:26:11 -07002017
2018 if (features->type == WIRELESS) {
2019
2020 /* monitor never has input and pen/touch have delayed create */
2021 features->quirks |= WACOM_QUIRK_NO_INPUT;
2022
2023 /* must be monitor interface if no device_type set */
Benjamin Tissoiresac8d1012014-07-25 17:29:48 -07002024 if (!features->device_type) {
Chris Bagwelld3825d52012-03-25 23:26:11 -07002025 features->quirks |= WACOM_QUIRK_MONITOR;
Benjamin Tissoiresac8d1012014-07-25 17:29:48 -07002026 features->quirks |= WACOM_QUIRK_BATTERY;
2027 }
Chris Bagwelld3825d52012-03-25 23:26:11 -07002028 }
Henrik Rydbergbc73dd32010-09-05 12:26:16 -07002029}
2030
Ping Cheng8c0e0a42013-01-04 23:53:52 -08002031static void wacom_abs_set_axis(struct input_dev *input_dev,
2032 struct wacom_wac *wacom_wac)
2033{
2034 struct wacom_features *features = &wacom_wac->features;
2035
2036 if (features->device_type == BTN_TOOL_PEN) {
Ping Chengac414da2014-05-29 00:08:41 -07002037 input_set_abs_params(input_dev, ABS_X, features->x_min,
2038 features->x_max, features->x_fuzz, 0);
2039 input_set_abs_params(input_dev, ABS_Y, features->y_min,
2040 features->y_max, features->y_fuzz, 0);
Ping Cheng8c0e0a42013-01-04 23:53:52 -08002041 input_set_abs_params(input_dev, ABS_PRESSURE, 0,
2042 features->pressure_max, features->pressure_fuzz, 0);
2043
2044 /* penabled devices have fixed resolution for each model */
2045 input_abs_set_res(input_dev, ABS_X, features->x_resolution);
2046 input_abs_set_res(input_dev, ABS_Y, features->y_resolution);
2047 } else {
Ping Chengd7da3a32014-06-13 13:37:33 -07002048 if (features->touch_max == 1) {
Ping Cheng8c0e0a42013-01-04 23:53:52 -08002049 input_set_abs_params(input_dev, ABS_X, 0,
2050 features->x_max, features->x_fuzz, 0);
2051 input_set_abs_params(input_dev, ABS_Y, 0,
2052 features->y_max, features->y_fuzz, 0);
2053 input_abs_set_res(input_dev, ABS_X,
Ping Cheng401d7d12013-07-28 00:38:54 -07002054 features->x_resolution);
Ping Cheng8c0e0a42013-01-04 23:53:52 -08002055 input_abs_set_res(input_dev, ABS_Y,
Ping Cheng401d7d12013-07-28 00:38:54 -07002056 features->y_resolution);
Ping Cheng8c0e0a42013-01-04 23:53:52 -08002057 }
2058
2059 if (features->touch_max > 1) {
2060 input_set_abs_params(input_dev, ABS_MT_POSITION_X, 0,
2061 features->x_max, features->x_fuzz, 0);
2062 input_set_abs_params(input_dev, ABS_MT_POSITION_Y, 0,
2063 features->y_max, features->y_fuzz, 0);
2064 input_abs_set_res(input_dev, ABS_MT_POSITION_X,
Ping Cheng401d7d12013-07-28 00:38:54 -07002065 features->x_resolution);
Ping Cheng8c0e0a42013-01-04 23:53:52 -08002066 input_abs_set_res(input_dev, ABS_MT_POSITION_Y,
Ping Cheng401d7d12013-07-28 00:38:54 -07002067 features->y_resolution);
Ping Cheng8c0e0a42013-01-04 23:53:52 -08002068 }
2069 }
2070}
2071
Ping Cheng30ebc1a2014-11-18 13:29:16 -08002072int wacom_setup_pentouch_input_capabilities(struct input_dev *input_dev,
Ping Cheng19635182012-04-29 21:09:18 -07002073 struct wacom_wac *wacom_wac)
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -07002074{
2075 struct wacom_features *features = &wacom_wac->features;
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -07002076
2077 input_dev->evbit[0] |= BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS);
2078
Benjamin Tissoires7704ac92014-09-23 12:08:08 -04002079 if (features->type == HID_GENERIC)
2080 /* setup has already been done */
2081 return 0;
2082
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -07002083 __set_bit(BTN_TOUCH, input_dev->keybit);
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -07002084 __set_bit(ABS_MISC, input_dev->absbit);
2085
Ping Cheng8c0e0a42013-01-04 23:53:52 -08002086 wacom_abs_set_axis(input_dev, wacom_wac);
2087
Ping Cheng497ab1f2014-01-20 20:18:04 -08002088 switch (features->type) {
Dmitry Torokhov73a97f42010-03-19 22:18:15 -07002089 case WACOM_MO:
Dmitry Torokhov73a97f42010-03-19 22:18:15 -07002090 case WACOM_G4:
Dmitry Torokhov73a97f42010-03-19 22:18:15 -07002091 /* fall through */
2092
2093 case GRAPHIRE:
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -07002094 input_set_capability(input_dev, EV_REL, REL_WHEEL);
2095
2096 __set_bit(BTN_LEFT, input_dev->keybit);
2097 __set_bit(BTN_RIGHT, input_dev->keybit);
2098 __set_bit(BTN_MIDDLE, input_dev->keybit);
2099
2100 __set_bit(BTN_TOOL_RUBBER, input_dev->keybit);
2101 __set_bit(BTN_TOOL_PEN, input_dev->keybit);
2102 __set_bit(BTN_TOOL_MOUSE, input_dev->keybit);
2103 __set_bit(BTN_STYLUS, input_dev->keybit);
2104 __set_bit(BTN_STYLUS2, input_dev->keybit);
Jason Gerecke35120692011-09-08 09:38:14 -07002105
2106 __set_bit(INPUT_PROP_POINTER, input_dev->propbit);
Dmitry Torokhov73a97f42010-03-19 22:18:15 -07002107 break;
2108
Benjamin Tissoires387142b2014-08-06 13:52:56 -07002109 case GRAPHIRE_BT:
2110 __clear_bit(ABS_MISC, input_dev->absbit);
2111 input_set_abs_params(input_dev, ABS_DISTANCE, 0,
2112 features->distance_max,
2113 0, 0);
2114
2115 input_set_capability(input_dev, EV_REL, REL_WHEEL);
2116
2117 __set_bit(BTN_LEFT, input_dev->keybit);
2118 __set_bit(BTN_RIGHT, input_dev->keybit);
2119 __set_bit(BTN_MIDDLE, input_dev->keybit);
2120
2121 __set_bit(BTN_TOOL_RUBBER, input_dev->keybit);
2122 __set_bit(BTN_TOOL_PEN, input_dev->keybit);
2123 __set_bit(BTN_TOOL_MOUSE, input_dev->keybit);
2124 __set_bit(BTN_STYLUS, input_dev->keybit);
2125 __set_bit(BTN_STYLUS2, input_dev->keybit);
2126
2127 __set_bit(INPUT_PROP_POINTER, input_dev->propbit);
2128 break;
2129
Jason Gerecke803296b2011-12-12 00:11:45 -08002130 case WACOM_24HD:
Ping Chengc73a1af2013-05-14 23:34:53 -07002131 input_set_abs_params(input_dev, ABS_Z, -900, 899, 0, 0);
Jason Gerecke26fe4122014-11-18 16:50:09 -08002132 input_abs_set_res(input_dev, ABS_Z, 287);
Ping Chengc73a1af2013-05-14 23:34:53 -07002133 input_set_abs_params(input_dev, ABS_THROTTLE, 0, 71, 0, 0);
Ping Chenga112e9f2013-02-13 20:20:01 -08002134 /* fall through */
2135
2136 case DTK:
Jason Gerecke88fd4492012-10-24 23:53:02 -07002137 __set_bit(INPUT_PROP_DIRECT, input_dev->propbit);
2138
Jason Gerecke803296b2011-12-12 00:11:45 -08002139 wacom_setup_cintiq(wacom_wac);
2140 break;
2141
Ping Chengd838c642012-07-24 23:54:11 -07002142 case WACOM_22HD:
Ping Cheng3a4b4aa2010-06-03 22:10:21 -07002143 case WACOM_21UX2:
Dmitry Torokhov73a97f42010-03-19 22:18:15 -07002144 case WACOM_BEE:
Ping Cheng6521d0b2010-10-24 21:53:40 -07002145 case CINTIQ:
Ping Cheng6521d0b2010-10-24 21:53:40 -07002146 input_set_abs_params(input_dev, ABS_Z, -900, 899, 0, 0);
Jason Gerecke26fe4122014-11-18 16:50:09 -08002147 input_abs_set_res(input_dev, ABS_Z, 287);
Jason Gerecke35120692011-09-08 09:38:14 -07002148
2149 __set_bit(INPUT_PROP_DIRECT, input_dev->propbit);
2150
Ping Cheng6521d0b2010-10-24 21:53:40 -07002151 wacom_setup_cintiq(wacom_wac);
2152 break;
2153
Ping Cheng56218562013-05-05 19:56:18 -07002154 case WACOM_13HD:
Ping Cheng56218562013-05-05 19:56:18 -07002155 input_set_abs_params(input_dev, ABS_Z, -900, 899, 0, 0);
Jason Gerecke26fe4122014-11-18 16:50:09 -08002156 input_abs_set_res(input_dev, ABS_Z, 287);
Ping Cheng56218562013-05-05 19:56:18 -07002157 __set_bit(INPUT_PROP_DIRECT, input_dev->propbit);
2158 wacom_setup_cintiq(wacom_wac);
2159 break;
2160
Dmitry Torokhov73a97f42010-03-19 22:18:15 -07002161 case INTUOS3:
2162 case INTUOS3L:
Dmitry Torokhov73a97f42010-03-19 22:18:15 -07002163 case INTUOS3S:
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -07002164 input_set_abs_params(input_dev, ABS_Z, -900, 899, 0, 0);
Jason Gerecke26fe4122014-11-18 16:50:09 -08002165 input_abs_set_res(input_dev, ABS_Z, 287);
Dmitry Torokhov73a97f42010-03-19 22:18:15 -07002166 /* fall through */
2167
2168 case INTUOS:
Jason Gerecke35120692011-09-08 09:38:14 -07002169 __set_bit(INPUT_PROP_POINTER, input_dev->propbit);
2170
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -07002171 wacom_setup_intuos(wacom_wac);
Dmitry Torokhov73a97f42010-03-19 22:18:15 -07002172 break;
2173
Jason Gerecke9fee6192012-04-03 15:47:22 -07002174 case INTUOS5:
2175 case INTUOS5L:
Ping Cheng9a35c412013-09-20 09:51:56 -07002176 case INTUOSPM:
2177 case INTUOSPL:
Jason Gereckeae584ca2012-04-03 15:50:40 -07002178 case INTUOS5S:
Ping Cheng9a35c412013-09-20 09:51:56 -07002179 case INTUOSPS:
Jason Gereckeae584ca2012-04-03 15:50:40 -07002180 __set_bit(INPUT_PROP_POINTER, input_dev->propbit);
2181
2182 if (features->device_type == BTN_TOOL_PEN) {
Jason Gereckeae584ca2012-04-03 15:50:40 -07002183 input_set_abs_params(input_dev, ABS_DISTANCE, 0,
2184 features->distance_max,
2185 0, 0);
2186
2187 input_set_abs_params(input_dev, ABS_Z, -900, 899, 0, 0);
Jason Gerecke26fe4122014-11-18 16:50:09 -08002188 input_abs_set_res(input_dev, ABS_Z, 287);
Jason Gereckeae584ca2012-04-03 15:50:40 -07002189
2190 wacom_setup_intuos(wacom_wac);
2191 } else if (features->device_type == BTN_TOOL_FINGER) {
2192 __clear_bit(ABS_MISC, input_dev->absbit);
2193
Jason Gereckeae584ca2012-04-03 15:50:40 -07002194 input_set_abs_params(input_dev, ABS_MT_TOUCH_MAJOR,
Jason Gerecke4e904952012-10-03 17:19:11 -07002195 0, features->x_max, 0, 0);
2196 input_set_abs_params(input_dev, ABS_MT_TOUCH_MINOR,
2197 0, features->y_max, 0, 0);
Ping Cheng02295e62013-01-04 23:56:00 -08002198 input_mt_init_slots(input_dev, features->touch_max, INPUT_MT_POINTER);
Jason Gereckeae584ca2012-04-03 15:50:40 -07002199 }
2200 break;
2201
Dmitry Torokhov73a97f42010-03-19 22:18:15 -07002202 case INTUOS4:
Benjamin Tissoires81af7e62014-08-06 13:55:56 -07002203 case INTUOS4WL:
Dmitry Torokhov73a97f42010-03-19 22:18:15 -07002204 case INTUOS4L:
Dmitry Torokhov73a97f42010-03-19 22:18:15 -07002205 case INTUOS4S:
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -07002206 input_set_abs_params(input_dev, ABS_Z, -900, 899, 0, 0);
Jason Gerecke26fe4122014-11-18 16:50:09 -08002207 input_abs_set_res(input_dev, ABS_Z, 287);
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -07002208 wacom_setup_intuos(wacom_wac);
Jason Gerecke35120692011-09-08 09:38:14 -07002209
2210 __set_bit(INPUT_PROP_POINTER, input_dev->propbit);
Dmitry Torokhov73a97f42010-03-19 22:18:15 -07002211 break;
2212
Jason Gereckeb1e42792012-10-21 00:38:04 -07002213 case WACOM_24HDT:
2214 if (features->device_type == BTN_TOOL_FINGER) {
2215 input_set_abs_params(input_dev, ABS_MT_TOUCH_MAJOR, 0, features->x_max, 0, 0);
2216 input_set_abs_params(input_dev, ABS_MT_WIDTH_MAJOR, 0, features->x_max, 0, 0);
2217 input_set_abs_params(input_dev, ABS_MT_WIDTH_MINOR, 0, features->y_max, 0, 0);
2218 input_set_abs_params(input_dev, ABS_MT_ORIENTATION, 0, 1, 0, 0);
2219 }
2220 /* fall through */
2221
Ping Cheng19635182012-04-29 21:09:18 -07002222 case MTSCREEN:
Ping Cheng6afdc282012-11-03 12:16:15 -07002223 case MTTPC:
Jason Gerecked51ddb22014-05-14 17:14:29 -07002224 case MTTPC_B:
Ping Cheng6795a522012-06-28 16:49:00 -07002225 case TABLETPC2FG:
Ping Chengd7da3a32014-06-13 13:37:33 -07002226 if (features->device_type == BTN_TOOL_FINGER && features->touch_max > 1)
2227 input_mt_init_slots(input_dev, features->touch_max, INPUT_MT_DIRECT);
Dmitry Torokhov73a97f42010-03-19 22:18:15 -07002228 /* fall through */
2229
2230 case TABLETPC:
Ping Chengac173832012-06-12 00:15:06 -07002231 case TABLETPCE:
Ping Chenga43c7c52011-03-12 20:34:42 -08002232 __clear_bit(ABS_MISC, input_dev->absbit);
2233
Jason Gerecke35120692011-09-08 09:38:14 -07002234 __set_bit(INPUT_PROP_DIRECT, input_dev->propbit);
2235
Ping Chenge35fb8c2011-03-26 21:16:05 -07002236 if (features->device_type != BTN_TOOL_PEN)
Dmitry Torokhov73a97f42010-03-19 22:18:15 -07002237 break; /* no need to process stylus stuff */
Ping Chenge35fb8c2011-03-26 21:16:05 -07002238
Dmitry Torokhov73a97f42010-03-19 22:18:15 -07002239 /* fall through */
2240
Ping Cheng497ab1f2014-01-20 20:18:04 -08002241 case DTUS:
Ping Chengfff00bf2014-12-04 18:23:04 -08002242 case DTUSX:
Dmitry Torokhov73a97f42010-03-19 22:18:15 -07002243 case PL:
Ping Chengc8f2edc2010-06-28 01:10:51 -07002244 case DTU:
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -07002245 __set_bit(BTN_TOOL_PEN, input_dev->keybit);
Jason Gerecke35120692011-09-08 09:38:14 -07002246 __set_bit(BTN_TOOL_RUBBER, input_dev->keybit);
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -07002247 __set_bit(BTN_STYLUS, input_dev->keybit);
2248 __set_bit(BTN_STYLUS2, input_dev->keybit);
Jason Gerecke35120692011-09-08 09:38:14 -07002249
2250 __set_bit(INPUT_PROP_DIRECT, input_dev->propbit);
2251 break;
2252
2253 case PTU:
Dmitry Torokhov73a97f42010-03-19 22:18:15 -07002254 __set_bit(BTN_STYLUS2, input_dev->keybit);
2255 /* fall through */
2256
2257 case PENPARTNER:
Jason Gerecke1fab84a2011-08-26 23:18:22 -07002258 __set_bit(BTN_TOOL_PEN, input_dev->keybit);
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -07002259 __set_bit(BTN_TOOL_RUBBER, input_dev->keybit);
Jason Gerecke1fab84a2011-08-26 23:18:22 -07002260 __set_bit(BTN_STYLUS, input_dev->keybit);
Jason Gerecke35120692011-09-08 09:38:14 -07002261
2262 __set_bit(INPUT_PROP_POINTER, input_dev->propbit);
Dmitry Torokhov73a97f42010-03-19 22:18:15 -07002263 break;
Henrik Rydbergcb734c02010-09-05 12:53:16 -07002264
Ping Chengb5fd2a32013-11-25 18:44:55 -08002265 case INTUOSHT:
Ping Cheng961794a2013-12-05 12:54:53 -08002266 if (features->touch_max &&
2267 features->device_type == BTN_TOOL_FINGER) {
2268 input_dev->evbit[0] |= BIT_MASK(EV_SW);
2269 __set_bit(SW_MUTE_DEVICE, input_dev->swbit);
2270 }
2271 /* fall through */
2272
Henrik Rydbergcb734c02010-09-05 12:53:16 -07002273 case BAMBOO_PT:
2274 __clear_bit(ABS_MISC, input_dev->absbit);
2275
Ping Cheng8b4a0c12012-01-31 00:07:33 -08002276 if (features->device_type == BTN_TOOL_FINGER) {
Ping Cheng02295e62013-01-04 23:56:00 -08002277
Ping Chengb5fd2a32013-11-25 18:44:55 -08002278 if (features->touch_max) {
Ping Chengb5fd2a32013-11-25 18:44:55 -08002279 if (features->pktlen == WACOM_PKGLEN_BBTOUCH3) {
2280 input_set_abs_params(input_dev,
Chris Bagwell73149ab2011-10-26 22:34:21 -07002281 ABS_MT_TOUCH_MAJOR,
Jason Gerecke4e904952012-10-03 17:19:11 -07002282 0, features->x_max, 0, 0);
Ping Chengb5fd2a32013-11-25 18:44:55 -08002283 input_set_abs_params(input_dev,
Jason Gerecke4e904952012-10-03 17:19:11 -07002284 ABS_MT_TOUCH_MINOR,
2285 0, features->y_max, 0, 0);
Ping Chengb5fd2a32013-11-25 18:44:55 -08002286 }
Ping Chengd7da3a32014-06-13 13:37:33 -07002287 input_mt_init_slots(input_dev, features->touch_max, INPUT_MT_POINTER);
Ping Cheng02295e62013-01-04 23:56:00 -08002288 } else {
Ping Chengb5fd2a32013-11-25 18:44:55 -08002289 /* buttons/keys only interface */
2290 __clear_bit(ABS_X, input_dev->absbit);
2291 __clear_bit(ABS_Y, input_dev->absbit);
2292 __clear_bit(BTN_TOUCH, input_dev->keybit);
Ping Cheng30ebc1a2014-11-18 13:29:16 -08002293
2294 /* PAD is setup by wacom_setup_pad_input_capabilities later */
2295 return 1;
Chris Bagwell73149ab2011-10-26 22:34:21 -07002296 }
Chris Bagwell2aaacb12010-09-12 00:11:35 -07002297 } else if (features->device_type == BTN_TOOL_PEN) {
Ping Chengb5fd2a32013-11-25 18:44:55 -08002298 __set_bit(INPUT_PROP_POINTER, input_dev->propbit);
Chris Bagwell2aaacb12010-09-12 00:11:35 -07002299 __set_bit(BTN_TOOL_RUBBER, input_dev->keybit);
2300 __set_bit(BTN_TOOL_PEN, input_dev->keybit);
2301 __set_bit(BTN_STYLUS, input_dev->keybit);
2302 __set_bit(BTN_STYLUS2, input_dev->keybit);
Chris Bagwellc18c2ce2011-10-10 08:52:13 -07002303 input_set_abs_params(input_dev, ABS_DISTANCE, 0,
2304 features->distance_max,
2305 0, 0);
Henrik Rydbergcb734c02010-09-05 12:53:16 -07002306 }
2307 break;
Jason Gerecke36d3c512013-09-20 09:47:35 -07002308
2309 case CINTIQ_HYBRID:
Jason Gerecke36d3c512013-09-20 09:47:35 -07002310 input_set_abs_params(input_dev, ABS_Z, -900, 899, 0, 0);
Jason Gerecke26fe4122014-11-18 16:50:09 -08002311 input_abs_set_res(input_dev, ABS_Z, 287);
Jason Gerecke36d3c512013-09-20 09:47:35 -07002312 __set_bit(INPUT_PROP_DIRECT, input_dev->propbit);
2313
2314 wacom_setup_cintiq(wacom_wac);
2315 break;
Ping Cheng3bea7332006-07-13 18:01:36 -07002316 }
Ping Cheng19635182012-04-29 21:09:18 -07002317 return 0;
Ping Cheng3bea7332006-07-13 18:01:36 -07002318}
2319
Benjamin Tissoiresd2d13f12014-07-24 12:48:28 -07002320int wacom_setup_pad_input_capabilities(struct input_dev *input_dev,
2321 struct wacom_wac *wacom_wac)
2322{
2323 struct wacom_features *features = &wacom_wac->features;
Benjamin Tissoires10059cdc2014-07-24 12:49:08 -07002324 int i;
Benjamin Tissoiresd2d13f12014-07-24 12:48:28 -07002325
2326 input_dev->evbit[0] |= BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS);
2327
2328 /* kept for making legacy xf86-input-wacom working with the wheels */
2329 __set_bit(ABS_MISC, input_dev->absbit);
2330
2331 /* kept for making legacy xf86-input-wacom accepting the pad */
2332 input_set_abs_params(input_dev, ABS_X, 0, 1, 0, 0);
2333 input_set_abs_params(input_dev, ABS_Y, 0, 1, 0, 0);
2334
Benjamin Tissoires12969e32014-09-11 13:14:04 -04002335 /* kept for making udev and libwacom accepting the pad */
2336 __set_bit(BTN_STYLUS, input_dev->keybit);
2337
Benjamin Tissoiresd2d13f12014-07-24 12:48:28 -07002338 switch (features->type) {
Benjamin Tissoires387142b2014-08-06 13:52:56 -07002339 case GRAPHIRE_BT:
2340 __set_bit(BTN_0, input_dev->keybit);
2341 __set_bit(BTN_1, input_dev->keybit);
2342 break;
2343
Benjamin Tissoires38138102014-07-24 12:51:03 -07002344 case WACOM_MO:
2345 __set_bit(BTN_BACK, input_dev->keybit);
2346 __set_bit(BTN_LEFT, input_dev->keybit);
2347 __set_bit(BTN_FORWARD, input_dev->keybit);
2348 __set_bit(BTN_RIGHT, input_dev->keybit);
2349 input_set_abs_params(input_dev, ABS_WHEEL, 0, 71, 0, 0);
2350 break;
2351
2352 case WACOM_G4:
2353 __set_bit(BTN_BACK, input_dev->keybit);
Benjamin Tissoires38138102014-07-24 12:51:03 -07002354 __set_bit(BTN_FORWARD, input_dev->keybit);
Benjamin Tissoires38138102014-07-24 12:51:03 -07002355 input_set_capability(input_dev, EV_REL, REL_WHEEL);
2356 break;
2357
Benjamin Tissoires10059cdc2014-07-24 12:49:08 -07002358 case WACOM_24HD:
2359 __set_bit(BTN_A, input_dev->keybit);
2360 __set_bit(BTN_B, input_dev->keybit);
2361 __set_bit(BTN_C, input_dev->keybit);
2362 __set_bit(BTN_X, input_dev->keybit);
2363 __set_bit(BTN_Y, input_dev->keybit);
2364 __set_bit(BTN_Z, input_dev->keybit);
2365
2366 for (i = 0; i < 10; i++)
2367 __set_bit(BTN_0 + i, input_dev->keybit);
2368
2369 __set_bit(KEY_PROG1, input_dev->keybit);
2370 __set_bit(KEY_PROG2, input_dev->keybit);
2371 __set_bit(KEY_PROG3, input_dev->keybit);
2372
2373 input_set_abs_params(input_dev, ABS_WHEEL, 0, 71, 0, 0);
2374 input_set_abs_params(input_dev, ABS_THROTTLE, 0, 71, 0, 0);
2375 break;
2376
2377 case DTK:
2378 for (i = 0; i < 6; i++)
2379 __set_bit(BTN_0 + i, input_dev->keybit);
2380
2381 break;
2382
2383 case WACOM_22HD:
2384 __set_bit(KEY_PROG1, input_dev->keybit);
2385 __set_bit(KEY_PROG2, input_dev->keybit);
2386 __set_bit(KEY_PROG3, input_dev->keybit);
2387 /* fall through */
2388
2389 case WACOM_21UX2:
2390 __set_bit(BTN_A, input_dev->keybit);
2391 __set_bit(BTN_B, input_dev->keybit);
2392 __set_bit(BTN_C, input_dev->keybit);
2393 __set_bit(BTN_X, input_dev->keybit);
2394 __set_bit(BTN_Y, input_dev->keybit);
2395 __set_bit(BTN_Z, input_dev->keybit);
2396 __set_bit(BTN_BASE, input_dev->keybit);
2397 __set_bit(BTN_BASE2, input_dev->keybit);
2398 /* fall through */
2399
2400 case WACOM_BEE:
2401 __set_bit(BTN_8, input_dev->keybit);
2402 __set_bit(BTN_9, input_dev->keybit);
2403 /* fall through */
2404
2405 case CINTIQ:
2406 for (i = 0; i < 8; i++)
2407 __set_bit(BTN_0 + i, input_dev->keybit);
2408
2409 input_set_abs_params(input_dev, ABS_RX, 0, 4096, 0, 0);
2410 input_set_abs_params(input_dev, ABS_RY, 0, 4096, 0, 0);
2411 break;
2412
2413 case WACOM_13HD:
2414 for (i = 0; i < 9; i++)
2415 __set_bit(BTN_0 + i, input_dev->keybit);
2416
2417 input_set_abs_params(input_dev, ABS_WHEEL, 0, 71, 0, 0);
2418 break;
2419
2420 case INTUOS3:
2421 case INTUOS3L:
2422 __set_bit(BTN_4, input_dev->keybit);
2423 __set_bit(BTN_5, input_dev->keybit);
2424 __set_bit(BTN_6, input_dev->keybit);
2425 __set_bit(BTN_7, input_dev->keybit);
2426
2427 input_set_abs_params(input_dev, ABS_RY, 0, 4096, 0, 0);
2428 /* fall through */
2429
2430 case INTUOS3S:
2431 __set_bit(BTN_0, input_dev->keybit);
2432 __set_bit(BTN_1, input_dev->keybit);
2433 __set_bit(BTN_2, input_dev->keybit);
2434 __set_bit(BTN_3, input_dev->keybit);
2435
2436 input_set_abs_params(input_dev, ABS_RX, 0, 4096, 0, 0);
2437 break;
2438
2439 case INTUOS5:
2440 case INTUOS5L:
2441 case INTUOSPM:
2442 case INTUOSPL:
2443 __set_bit(BTN_7, input_dev->keybit);
2444 __set_bit(BTN_8, input_dev->keybit);
2445 /* fall through */
2446
2447 case INTUOS5S:
2448 case INTUOSPS:
2449 /* touch interface does not have the pad device */
2450 if (features->device_type != BTN_TOOL_PEN)
Ping Chengb3c8e932014-11-18 13:27:48 -08002451 return -ENODEV;
Benjamin Tissoires10059cdc2014-07-24 12:49:08 -07002452
2453 for (i = 0; i < 7; i++)
2454 __set_bit(BTN_0 + i, input_dev->keybit);
2455
2456 input_set_abs_params(input_dev, ABS_WHEEL, 0, 71, 0, 0);
2457 break;
2458
Benjamin Tissoires81af7e62014-08-06 13:55:56 -07002459 case INTUOS4WL:
2460 /*
2461 * For Bluetooth devices, the udev rule does not work correctly
2462 * for pads unless we add a stylus capability, which forces
2463 * ID_INPUT_TABLET to be set.
2464 */
2465 __set_bit(BTN_STYLUS, input_dev->keybit);
2466 /* fall through */
2467
Benjamin Tissoires10059cdc2014-07-24 12:49:08 -07002468 case INTUOS4:
2469 case INTUOS4L:
2470 __set_bit(BTN_7, input_dev->keybit);
2471 __set_bit(BTN_8, input_dev->keybit);
2472 /* fall through */
2473
2474 case INTUOS4S:
2475 for (i = 0; i < 7; i++)
2476 __set_bit(BTN_0 + i, input_dev->keybit);
2477
2478 input_set_abs_params(input_dev, ABS_WHEEL, 0, 71, 0, 0);
2479 break;
2480
2481 case CINTIQ_HYBRID:
2482 for (i = 0; i < 9; i++)
2483 __set_bit(BTN_0 + i, input_dev->keybit);
2484
2485 break;
2486
Benjamin Tissoires422b0312014-07-24 12:50:39 -07002487 case DTUS:
2488 for (i = 0; i < 4; i++)
2489 __set_bit(BTN_0 + i, input_dev->keybit);
2490 break;
2491
Benjamin Tissoires31168712014-07-24 12:50:10 -07002492 case INTUOSHT:
2493 case BAMBOO_PT:
2494 /* pad device is on the touch interface */
Ping Cheng30ebc1a2014-11-18 13:29:16 -08002495 if ((features->device_type != BTN_TOOL_FINGER) ||
2496 /* Bamboo Pen only tablet does not have pad */
2497 ((features->type == BAMBOO_PT) && !features->touch_max))
Ping Chengb3c8e932014-11-18 13:27:48 -08002498 return -ENODEV;
Benjamin Tissoires31168712014-07-24 12:50:10 -07002499
2500 __clear_bit(ABS_MISC, input_dev->absbit);
2501
2502 __set_bit(BTN_LEFT, input_dev->keybit);
2503 __set_bit(BTN_FORWARD, input_dev->keybit);
2504 __set_bit(BTN_BACK, input_dev->keybit);
2505 __set_bit(BTN_RIGHT, input_dev->keybit);
2506
2507 break;
2508
Benjamin Tissoiresd2d13f12014-07-24 12:48:28 -07002509 default:
2510 /* no pad supported */
Ping Chengb3c8e932014-11-18 13:27:48 -08002511 return -ENODEV;
Benjamin Tissoiresd2d13f12014-07-24 12:48:28 -07002512 }
2513 return 0;
2514}
2515
Dmitry Torokhove87a3442010-02-18 01:51:47 -08002516static const struct wacom_features wacom_features_0x00 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07002517 { "Wacom Penpartner", 5040, 3780, 255, 0,
2518 PENPARTNER, WACOM_PENPRTN_RES, WACOM_PENPRTN_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08002519static const struct wacom_features wacom_features_0x10 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07002520 { "Wacom Graphire", 10206, 7422, 511, 63,
2521 GRAPHIRE, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
Benjamin Tissoires387142b2014-08-06 13:52:56 -07002522static const struct wacom_features wacom_features_0x81 =
2523 { "Wacom Graphire BT", 16704, 12064, 511, 32,
2524 GRAPHIRE_BT, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08002525static const struct wacom_features wacom_features_0x11 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07002526 { "Wacom Graphire2 4x5", 10206, 7422, 511, 63,
2527 GRAPHIRE, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08002528static const struct wacom_features wacom_features_0x12 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07002529 { "Wacom Graphire2 5x7", 13918, 10206, 511, 63,
2530 GRAPHIRE, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08002531static const struct wacom_features wacom_features_0x13 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07002532 { "Wacom Graphire3", 10208, 7424, 511, 63,
2533 GRAPHIRE, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08002534static const struct wacom_features wacom_features_0x14 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07002535 { "Wacom Graphire3 6x8", 16704, 12064, 511, 63,
2536 GRAPHIRE, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08002537static const struct wacom_features wacom_features_0x15 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07002538 { "Wacom Graphire4 4x5", 10208, 7424, 511, 63,
2539 WACOM_G4, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08002540static const struct wacom_features wacom_features_0x16 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07002541 { "Wacom Graphire4 6x8", 16704, 12064, 511, 63,
2542 WACOM_G4, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08002543static const struct wacom_features wacom_features_0x17 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07002544 { "Wacom BambooFun 4x5", 14760, 9225, 511, 63,
2545 WACOM_MO, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08002546static const struct wacom_features wacom_features_0x18 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07002547 { "Wacom BambooFun 6x8", 21648, 13530, 511, 63,
2548 WACOM_MO, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08002549static const struct wacom_features wacom_features_0x19 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07002550 { "Wacom Bamboo1 Medium", 16704, 12064, 511, 63,
2551 GRAPHIRE, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08002552static const struct wacom_features wacom_features_0x60 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07002553 { "Wacom Volito", 5104, 3712, 511, 63,
2554 GRAPHIRE, WACOM_VOLITO_RES, WACOM_VOLITO_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08002555static const struct wacom_features wacom_features_0x61 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07002556 { "Wacom PenStation2", 3250, 2320, 255, 63,
2557 GRAPHIRE, WACOM_VOLITO_RES, WACOM_VOLITO_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08002558static const struct wacom_features wacom_features_0x62 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07002559 { "Wacom Volito2 4x5", 5104, 3712, 511, 63,
2560 GRAPHIRE, WACOM_VOLITO_RES, WACOM_VOLITO_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08002561static const struct wacom_features wacom_features_0x63 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07002562 { "Wacom Volito2 2x3", 3248, 2320, 511, 63,
2563 GRAPHIRE, WACOM_VOLITO_RES, WACOM_VOLITO_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08002564static const struct wacom_features wacom_features_0x64 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07002565 { "Wacom PenPartner2", 3250, 2320, 511, 63,
2566 GRAPHIRE, WACOM_VOLITO_RES, WACOM_VOLITO_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08002567static const struct wacom_features wacom_features_0x65 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07002568 { "Wacom Bamboo", 14760, 9225, 511, 63,
2569 WACOM_MO, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08002570static const struct wacom_features wacom_features_0x69 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07002571 { "Wacom Bamboo1", 5104, 3712, 511, 63,
2572 GRAPHIRE, WACOM_PENPRTN_RES, WACOM_PENPRTN_RES };
Ping Cheng11d0cf82011-06-27 12:57:58 -07002573static const struct wacom_features wacom_features_0x6A =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07002574 { "Wacom Bamboo1 4x6", 14760, 9225, 1023, 63,
2575 GRAPHIRE, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Ping Cheng11d0cf82011-06-27 12:57:58 -07002576static const struct wacom_features wacom_features_0x6B =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07002577 { "Wacom Bamboo1 5x8", 21648, 13530, 1023, 63,
2578 GRAPHIRE, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08002579static const struct wacom_features wacom_features_0x20 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07002580 { "Wacom Intuos 4x5", 12700, 10600, 1023, 31,
2581 INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08002582static const struct wacom_features wacom_features_0x21 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07002583 { "Wacom Intuos 6x8", 20320, 16240, 1023, 31,
2584 INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08002585static const struct wacom_features wacom_features_0x22 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07002586 { "Wacom Intuos 9x12", 30480, 24060, 1023, 31,
2587 INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08002588static const struct wacom_features wacom_features_0x23 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07002589 { "Wacom Intuos 12x12", 30480, 31680, 1023, 31,
2590 INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08002591static const struct wacom_features wacom_features_0x24 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07002592 { "Wacom Intuos 12x18", 45720, 31680, 1023, 31,
2593 INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08002594static const struct wacom_features wacom_features_0x30 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07002595 { "Wacom PL400", 5408, 4056, 255, 0,
2596 PL, WACOM_PL_RES, WACOM_PL_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08002597static const struct wacom_features wacom_features_0x31 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07002598 { "Wacom PL500", 6144, 4608, 255, 0,
2599 PL, WACOM_PL_RES, WACOM_PL_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08002600static const struct wacom_features wacom_features_0x32 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07002601 { "Wacom PL600", 6126, 4604, 255, 0,
2602 PL, WACOM_PL_RES, WACOM_PL_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08002603static const struct wacom_features wacom_features_0x33 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07002604 { "Wacom PL600SX", 6260, 5016, 255, 0,
2605 PL, WACOM_PL_RES, WACOM_PL_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08002606static const struct wacom_features wacom_features_0x34 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07002607 { "Wacom PL550", 6144, 4608, 511, 0,
2608 PL, WACOM_PL_RES, WACOM_PL_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08002609static const struct wacom_features wacom_features_0x35 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07002610 { "Wacom PL800", 7220, 5780, 511, 0,
2611 PL, WACOM_PL_RES, WACOM_PL_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08002612static const struct wacom_features wacom_features_0x37 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07002613 { "Wacom PL700", 6758, 5406, 511, 0,
2614 PL, WACOM_PL_RES, WACOM_PL_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08002615static const struct wacom_features wacom_features_0x38 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07002616 { "Wacom PL510", 6282, 4762, 511, 0,
2617 PL, WACOM_PL_RES, WACOM_PL_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08002618static const struct wacom_features wacom_features_0x39 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07002619 { "Wacom DTU710", 34080, 27660, 511, 0,
2620 PL, WACOM_PL_RES, WACOM_PL_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08002621static const struct wacom_features wacom_features_0xC4 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07002622 { "Wacom DTF521", 6282, 4762, 511, 0,
2623 PL, WACOM_PL_RES, WACOM_PL_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08002624static const struct wacom_features wacom_features_0xC0 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07002625 { "Wacom DTF720", 6858, 5506, 511, 0,
2626 PL, WACOM_PL_RES, WACOM_PL_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08002627static const struct wacom_features wacom_features_0xC2 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07002628 { "Wacom DTF720a", 6858, 5506, 511, 0,
2629 PL, WACOM_PL_RES, WACOM_PL_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08002630static const struct wacom_features wacom_features_0x03 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07002631 { "Wacom Cintiq Partner", 20480, 15360, 511, 0,
2632 PTU, WACOM_PL_RES, WACOM_PL_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08002633static const struct wacom_features wacom_features_0x41 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07002634 { "Wacom Intuos2 4x5", 12700, 10600, 1023, 31,
2635 INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08002636static const struct wacom_features wacom_features_0x42 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07002637 { "Wacom Intuos2 6x8", 20320, 16240, 1023, 31,
2638 INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08002639static const struct wacom_features wacom_features_0x43 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07002640 { "Wacom Intuos2 9x12", 30480, 24060, 1023, 31,
2641 INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08002642static const struct wacom_features wacom_features_0x44 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07002643 { "Wacom Intuos2 12x12", 30480, 31680, 1023, 31,
2644 INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08002645static const struct wacom_features wacom_features_0x45 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07002646 { "Wacom Intuos2 12x18", 45720, 31680, 1023, 31,
2647 INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08002648static const struct wacom_features wacom_features_0xB0 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07002649 { "Wacom Intuos3 4x5", 25400, 20320, 1023, 63,
2650 INTUOS3S, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08002651static const struct wacom_features wacom_features_0xB1 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07002652 { "Wacom Intuos3 6x8", 40640, 30480, 1023, 63,
2653 INTUOS3, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08002654static const struct wacom_features wacom_features_0xB2 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07002655 { "Wacom Intuos3 9x12", 60960, 45720, 1023, 63,
2656 INTUOS3, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08002657static const struct wacom_features wacom_features_0xB3 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07002658 { "Wacom Intuos3 12x12", 60960, 60960, 1023, 63,
2659 INTUOS3L, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08002660static const struct wacom_features wacom_features_0xB4 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07002661 { "Wacom Intuos3 12x19", 97536, 60960, 1023, 63,
2662 INTUOS3L, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08002663static const struct wacom_features wacom_features_0xB5 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07002664 { "Wacom Intuos3 6x11", 54204, 31750, 1023, 63,
2665 INTUOS3, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08002666static const struct wacom_features wacom_features_0xB7 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07002667 { "Wacom Intuos3 4x6", 31496, 19685, 1023, 63,
2668 INTUOS3S, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08002669static const struct wacom_features wacom_features_0xB8 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07002670 { "Wacom Intuos4 4x6", 31496, 19685, 2047, 63,
2671 INTUOS4S, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08002672static const struct wacom_features wacom_features_0xB9 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07002673 { "Wacom Intuos4 6x9", 44704, 27940, 2047, 63,
2674 INTUOS4, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08002675static const struct wacom_features wacom_features_0xBA =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07002676 { "Wacom Intuos4 8x13", 65024, 40640, 2047, 63,
2677 INTUOS4L, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08002678static const struct wacom_features wacom_features_0xBB =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07002679 { "Wacom Intuos4 12x19", 97536, 60960, 2047, 63,
2680 INTUOS4L, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
Ping Cheng3a4b4aa2010-06-03 22:10:21 -07002681static const struct wacom_features wacom_features_0xBC =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07002682 { "Wacom Intuos4 WL", 40640, 25400, 2047, 63,
2683 INTUOS4, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
Benjamin Tissoires81af7e62014-08-06 13:55:56 -07002684static const struct wacom_features wacom_features_0xBD =
2685 { "Wacom Intuos4 WL", 40640, 25400, 2047, 63,
2686 INTUOS4WL, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
Jason Gerecke9fee6192012-04-03 15:47:22 -07002687static const struct wacom_features wacom_features_0x26 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07002688 { "Wacom Intuos5 touch S", 31496, 19685, 2047, 63,
2689 INTUOS5S, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, .touch_max = 16 };
Jason Gerecke9fee6192012-04-03 15:47:22 -07002690static const struct wacom_features wacom_features_0x27 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07002691 { "Wacom Intuos5 touch M", 44704, 27940, 2047, 63,
2692 INTUOS5, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, .touch_max = 16 };
Jason Gerecke9fee6192012-04-03 15:47:22 -07002693static const struct wacom_features wacom_features_0x28 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07002694 { "Wacom Intuos5 touch L", 65024, 40640, 2047, 63,
2695 INTUOS5L, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, .touch_max = 16 };
Jason Gerecke9fee6192012-04-03 15:47:22 -07002696static const struct wacom_features wacom_features_0x29 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07002697 { "Wacom Intuos5 S", 31496, 19685, 2047, 63,
2698 INTUOS5S, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
Jason Gerecke9fee6192012-04-03 15:47:22 -07002699static const struct wacom_features wacom_features_0x2A =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07002700 { "Wacom Intuos5 M", 44704, 27940, 2047, 63,
2701 INTUOS5, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
Ping Cheng9a35c412013-09-20 09:51:56 -07002702static const struct wacom_features wacom_features_0x314 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07002703 { "Wacom Intuos Pro S", 31496, 19685, 2047, 63,
2704 INTUOSPS, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, .touch_max = 16,
Benjamin Tissoires29b47392014-07-24 12:52:23 -07002705 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
Ping Cheng9a35c412013-09-20 09:51:56 -07002706static const struct wacom_features wacom_features_0x315 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07002707 { "Wacom Intuos Pro M", 44704, 27940, 2047, 63,
2708 INTUOSPM, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, .touch_max = 16,
Benjamin Tissoires29b47392014-07-24 12:52:23 -07002709 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
Ping Cheng9a35c412013-09-20 09:51:56 -07002710static const struct wacom_features wacom_features_0x317 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07002711 { "Wacom Intuos Pro L", 65024, 40640, 2047, 63,
2712 INTUOSPL, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, .touch_max = 16,
Benjamin Tissoires29b47392014-07-24 12:52:23 -07002713 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
Jason Gerecke803296b2011-12-12 00:11:45 -08002714static const struct wacom_features wacom_features_0xF4 =
Ping Chengecd618d2014-12-04 18:25:07 -08002715 { "Wacom Cintiq 24HD", 104080, 65200, 2047, 63,
Ping Chengfa770342014-12-01 13:44:28 -08002716 WACOM_24HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES,
2717 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET };
Jason Gerecke6f4d0382012-08-21 22:11:59 -07002718static const struct wacom_features wacom_features_0xF8 =
Ping Chengecd618d2014-12-04 18:25:07 -08002719 { "Wacom Cintiq 24HD touch", 104080, 65200, 2047, 63, /* Pen */
Ping Chengfa770342014-12-01 13:44:28 -08002720 WACOM_24HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES,
2721 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
Ping Cheng3bd1f7e2013-05-23 10:22:33 -07002722 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0xf6 };
Jason Gereckeb1e42792012-10-21 00:38:04 -07002723static const struct wacom_features wacom_features_0xF6 =
2724 { "Wacom Cintiq 24HD touch", .type = WACOM_24HDT, /* Touch */
Benjamin Tissoires29b47392014-07-24 12:52:23 -07002725 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0xf8, .touch_max = 10,
2726 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08002727static const struct wacom_features wacom_features_0x3F =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07002728 { "Wacom Cintiq 21UX", 87200, 65600, 1023, 63,
2729 CINTIQ, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08002730static const struct wacom_features wacom_features_0xC5 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07002731 { "Wacom Cintiq 20WSX", 86680, 54180, 1023, 63,
2732 WACOM_BEE, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08002733static const struct wacom_features wacom_features_0xC6 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07002734 { "Wacom Cintiq 12WX", 53020, 33440, 1023, 63,
2735 WACOM_BEE, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
Ping Cheng56218562013-05-05 19:56:18 -07002736static const struct wacom_features wacom_features_0x304 =
Ping Chengecd618d2014-12-04 18:25:07 -08002737 { "Wacom Cintiq 13HD", 59152, 33448, 1023, 63,
Ping Chengfa770342014-12-01 13:44:28 -08002738 WACOM_13HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES,
2739 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08002740static const struct wacom_features wacom_features_0xC7 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07002741 { "Wacom DTU1931", 37832, 30305, 511, 0,
2742 PL, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Ping Chengc8f2edc2010-06-28 01:10:51 -07002743static const struct wacom_features wacom_features_0xCE =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07002744 { "Wacom DTU2231", 47864, 27011, 511, 0,
2745 DTU, WACOM_INTUOS_RES, WACOM_INTUOS_RES,
Benjamin Tissoires29b47392014-07-24 12:52:23 -07002746 .check_for_hid_type = true, .hid_type = HID_TYPE_USBMOUSE };
Ping Chengc8f2edc2010-06-28 01:10:51 -07002747static const struct wacom_features wacom_features_0xF0 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07002748 { "Wacom DTU1631", 34623, 19553, 511, 0,
2749 DTU, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Ping Cheng497ab1f2014-01-20 20:18:04 -08002750static const struct wacom_features wacom_features_0xFB =
Ping Chengecd618d2014-12-04 18:25:07 -08002751 { "Wacom DTU1031", 21896, 13760, 511, 0,
Ping Chengfa770342014-12-01 13:44:28 -08002752 DTUS, WACOM_INTUOS_RES, WACOM_INTUOS_RES,
2753 WACOM_DTU_OFFSET, WACOM_DTU_OFFSET };
Ping Chengfff00bf2014-12-04 18:23:04 -08002754static const struct wacom_features wacom_features_0x32F =
2755 { "Wacom DTU1031X", 22472, 12728, 511, 0,
2756 DTUSX, WACOM_INTUOS_RES, WACOM_INTUOS_RES,
2757 WACOM_DTU_OFFSET, WACOM_DTU_OFFSET };
Ping Cheng56218562013-05-05 19:56:18 -07002758static const struct wacom_features wacom_features_0x57 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07002759 { "Wacom DTK2241", 95640, 54060, 2047, 63,
Ping Chengfa770342014-12-01 13:44:28 -08002760 DTK, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES,
2761 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET };
Ping Chenga112e9f2013-02-13 20:20:01 -08002762static const struct wacom_features wacom_features_0x59 = /* Pen */
Benjamin Tissoires80befa92014-07-24 13:05:19 -07002763 { "Wacom DTH2242", 95640, 54060, 2047, 63,
Ping Chengfa770342014-12-01 13:44:28 -08002764 DTK, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES,
2765 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
Ping Chenga112e9f2013-02-13 20:20:01 -08002766 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x5D };
2767static const struct wacom_features wacom_features_0x5D = /* Touch */
2768 { "Wacom DTH2242", .type = WACOM_24HDT,
Benjamin Tissoires29b47392014-07-24 12:52:23 -07002769 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x59, .touch_max = 10,
2770 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
Ping Cheng3a4b4aa2010-06-03 22:10:21 -07002771static const struct wacom_features wacom_features_0xCC =
Ping Chengecd618d2014-12-04 18:25:07 -08002772 { "Wacom Cintiq 21UX2", 86800, 65200, 2047, 63,
Ping Chengfa770342014-12-01 13:44:28 -08002773 WACOM_21UX2, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES,
2774 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET };
Ping Chengd838c642012-07-24 23:54:11 -07002775static const struct wacom_features wacom_features_0xFA =
Ping Chengecd618d2014-12-04 18:25:07 -08002776 { "Wacom Cintiq 22HD", 95440, 53860, 2047, 63,
Ping Chengfa770342014-12-01 13:44:28 -08002777 WACOM_22HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES,
2778 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET };
Ping Cheng56218562013-05-05 19:56:18 -07002779static const struct wacom_features wacom_features_0x5B =
Ping Chengecd618d2014-12-04 18:25:07 -08002780 { "Wacom Cintiq 22HDT", 95440, 53860, 2047, 63,
Ping Chengfa770342014-12-01 13:44:28 -08002781 WACOM_22HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES,
2782 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
Ping Cheng3bd1f7e2013-05-23 10:22:33 -07002783 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x5e };
Ping Cheng56218562013-05-05 19:56:18 -07002784static const struct wacom_features wacom_features_0x5E =
2785 { "Wacom Cintiq 22HDT", .type = WACOM_24HDT,
Benjamin Tissoires29b47392014-07-24 12:52:23 -07002786 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x5b, .touch_max = 10,
2787 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08002788static const struct wacom_features wacom_features_0x90 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07002789 { "Wacom ISDv4 90", 26202, 16325, 255, 0,
2790 TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08002791static const struct wacom_features wacom_features_0x93 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07002792 { "Wacom ISDv4 93", 26202, 16325, 255, 0,
2793 TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Ping Cheng11d0cf82011-06-27 12:57:58 -07002794static const struct wacom_features wacom_features_0x97 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07002795 { "Wacom ISDv4 97", 26202, 16325, 511, 0,
2796 TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08002797static const struct wacom_features wacom_features_0x9A =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07002798 { "Wacom ISDv4 9A", 26202, 16325, 255, 0,
2799 TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08002800static const struct wacom_features wacom_features_0x9F =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07002801 { "Wacom ISDv4 9F", 26202, 16325, 255, 0,
2802 TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08002803static const struct wacom_features wacom_features_0xE2 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07002804 { "Wacom ISDv4 E2", 26202, 16325, 255, 0,
2805 TABLETPC2FG, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08002806static const struct wacom_features wacom_features_0xE3 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07002807 { "Wacom ISDv4 E3", 26202, 16325, 255, 0,
2808 TABLETPC2FG, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
Ping Cheng19635182012-04-29 21:09:18 -07002809static const struct wacom_features wacom_features_0xE5 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07002810 { "Wacom ISDv4 E5", 26202, 16325, 255, 0,
2811 MTSCREEN, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Manoj Iyer26fcd2a2011-03-31 22:39:43 -07002812static const struct wacom_features wacom_features_0xE6 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07002813 { "Wacom ISDv4 E6", 27760, 15694, 255, 0,
2814 TABLETPC2FG, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
Chris Bagwell0d0e3062011-12-11 23:50:59 -08002815static const struct wacom_features wacom_features_0xEC =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07002816 { "Wacom ISDv4 EC", 25710, 14500, 255, 0,
2817 TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Ping Chengac173832012-06-12 00:15:06 -07002818static const struct wacom_features wacom_features_0xED =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07002819 { "Wacom ISDv4 ED", 26202, 16325, 255, 0,
2820 TABLETPCE, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Ping Chengac173832012-06-12 00:15:06 -07002821static const struct wacom_features wacom_features_0xEF =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07002822 { "Wacom ISDv4 EF", 26202, 16325, 255, 0,
2823 TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Ping Cheng6afdc282012-11-03 12:16:15 -07002824static const struct wacom_features wacom_features_0x100 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07002825 { "Wacom ISDv4 100", 26202, 16325, 255, 0,
2826 MTTPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Ping Cheng6afdc282012-11-03 12:16:15 -07002827static const struct wacom_features wacom_features_0x101 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07002828 { "Wacom ISDv4 101", 26202, 16325, 255, 0,
2829 MTTPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Stephan Frank58694832013-03-07 14:08:50 -08002830static const struct wacom_features wacom_features_0x10D =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07002831 { "Wacom ISDv4 10D", 26202, 16325, 255, 0,
2832 MTTPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Jason Gerecke2d3163f2013-10-22 15:35:30 -07002833static const struct wacom_features wacom_features_0x10E =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07002834 { "Wacom ISDv4 10E", 27760, 15694, 255, 0,
2835 MTTPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Jason Gerecke9b4f60e2013-10-15 23:46:34 -07002836static const struct wacom_features wacom_features_0x10F =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07002837 { "Wacom ISDv4 10F", 27760, 15694, 255, 0,
2838 MTTPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Jason Gerecke61616ed2014-05-14 11:42:22 -07002839static const struct wacom_features wacom_features_0x116 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07002840 { "Wacom ISDv4 116", 26202, 16325, 255, 0,
2841 TABLETPCE, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Jason Gereckeaeaf50d2014-07-28 10:53:16 -07002842static const struct wacom_features wacom_features_0x12C =
2843 { "Wacom ISDv4 12C", 27848, 15752, 2047, 0,
2844 TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Ping Chengedbe2652012-11-21 13:12:50 -08002845static const struct wacom_features wacom_features_0x4001 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07002846 { "Wacom ISDv4 4001", 26202, 16325, 255, 0,
2847 MTTPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Jason Gerecked51ddb22014-05-14 17:14:29 -07002848static const struct wacom_features wacom_features_0x4004 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07002849 { "Wacom ISDv4 4004", 11060, 6220, 255, 0,
2850 MTTPC_B, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Jason Gerecked51ddb22014-05-14 17:14:29 -07002851static const struct wacom_features wacom_features_0x5000 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07002852 { "Wacom ISDv4 5000", 27848, 15752, 1023, 0,
2853 MTTPC_B, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Jason Gerecked51ddb22014-05-14 17:14:29 -07002854static const struct wacom_features wacom_features_0x5002 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07002855 { "Wacom ISDv4 5002", 29576, 16724, 1023, 0,
2856 MTTPC_B, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08002857static const struct wacom_features wacom_features_0x47 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07002858 { "Wacom Intuos2 6x8", 20320, 16240, 1023, 31,
2859 INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Chris Bagwelld3825d52012-03-25 23:26:11 -07002860static const struct wacom_features wacom_features_0x84 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07002861 { "Wacom Wireless Receiver", 0, 0, 0, 0,
2862 WIRELESS, 0, 0, .touch_max = 16 };
Ping Cheng7b824bb2011-03-26 21:16:04 -07002863static const struct wacom_features wacom_features_0xD0 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07002864 { "Wacom Bamboo 2FG", 14720, 9200, 1023, 31,
2865 BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
Ping Cheng7b824bb2011-03-26 21:16:04 -07002866static const struct wacom_features wacom_features_0xD1 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07002867 { "Wacom Bamboo 2FG 4x5", 14720, 9200, 1023, 31,
2868 BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
Ping Cheng7b824bb2011-03-26 21:16:04 -07002869static const struct wacom_features wacom_features_0xD2 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07002870 { "Wacom Bamboo Craft", 14720, 9200, 1023, 31,
2871 BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
Ping Cheng7b824bb2011-03-26 21:16:04 -07002872static const struct wacom_features wacom_features_0xD3 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07002873 { "Wacom Bamboo 2FG 6x8", 21648, 13700, 1023, 31,
2874 BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
Kevin Granade57a78722010-12-10 23:04:02 -08002875static const struct wacom_features wacom_features_0xD4 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07002876 { "Wacom Bamboo Pen", 14720, 9200, 1023, 31,
2877 BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Gerard Braad18adad12011-08-16 00:17:56 -07002878static const struct wacom_features wacom_features_0xD5 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07002879 { "Wacom Bamboo Pen 6x8", 21648, 13700, 1023, 31,
2880 BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Ping Cheng7b824bb2011-03-26 21:16:04 -07002881static const struct wacom_features wacom_features_0xD6 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07002882 { "Wacom BambooPT 2FG 4x5", 14720, 9200, 1023, 31,
2883 BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
Ping Cheng7b824bb2011-03-26 21:16:04 -07002884static const struct wacom_features wacom_features_0xD7 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07002885 { "Wacom BambooPT 2FG Small", 14720, 9200, 1023, 31,
2886 BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
Ping Cheng7b824bb2011-03-26 21:16:04 -07002887static const struct wacom_features wacom_features_0xD8 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07002888 { "Wacom Bamboo Comic 2FG", 21648, 13700, 1023, 31,
2889 BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
Ping Cheng7b824bb2011-03-26 21:16:04 -07002890static const struct wacom_features wacom_features_0xDA =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07002891 { "Wacom Bamboo 2FG 4x5 SE", 14720, 9200, 1023, 31,
2892 BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
Ping Chengf41a64e2013-08-21 09:14:49 -07002893static const struct wacom_features wacom_features_0xDB =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07002894 { "Wacom Bamboo 2FG 6x8 SE", 21648, 13700, 1023, 31,
2895 BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
Chris Bagwell73149ab2011-10-26 22:34:21 -07002896static const struct wacom_features wacom_features_0xDD =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07002897 { "Wacom Bamboo Connect", 14720, 9200, 1023, 31,
2898 BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Chris Bagwell73149ab2011-10-26 22:34:21 -07002899static const struct wacom_features wacom_features_0xDE =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07002900 { "Wacom Bamboo 16FG 4x5", 14720, 9200, 1023, 31,
2901 BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 16 };
Chris Bagwell73149ab2011-10-26 22:34:21 -07002902static const struct wacom_features wacom_features_0xDF =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07002903 { "Wacom Bamboo 16FG 6x8", 21648, 13700, 1023, 31,
2904 BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 16 };
Ping Chengf41a64e2013-08-21 09:14:49 -07002905static const struct wacom_features wacom_features_0x300 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07002906 { "Wacom Bamboo One S", 14720, 9225, 1023, 31,
2907 BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Ping Chengf41a64e2013-08-21 09:14:49 -07002908static const struct wacom_features wacom_features_0x301 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07002909 { "Wacom Bamboo One M", 21648, 13530, 1023, 31,
2910 BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Ping Chengb5fd2a32013-11-25 18:44:55 -08002911static const struct wacom_features wacom_features_0x302 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07002912 { "Wacom Intuos PT S", 15200, 9500, 1023, 31,
2913 INTUOSHT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 16,
Benjamin Tissoires29b47392014-07-24 12:52:23 -07002914 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
Ping Chengb5fd2a32013-11-25 18:44:55 -08002915static const struct wacom_features wacom_features_0x303 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07002916 { "Wacom Intuos PT M", 21600, 13500, 1023, 31,
2917 INTUOSHT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 16,
Benjamin Tissoires29b47392014-07-24 12:52:23 -07002918 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
Ping Chengb5fd2a32013-11-25 18:44:55 -08002919static const struct wacom_features wacom_features_0x30E =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07002920 { "Wacom Intuos S", 15200, 9500, 1023, 31,
2921 INTUOSHT, WACOM_INTUOS_RES, WACOM_INTUOS_RES,
Benjamin Tissoires29b47392014-07-24 12:52:23 -07002922 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
Ajay Ramaswamy7b4b3062010-12-23 01:19:39 -08002923static const struct wacom_features wacom_features_0x6004 =
Benjamin Tissoires80befa92014-07-24 13:05:19 -07002924 { "ISD-V4", 12800, 8000, 255, 0,
2925 TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Benjamin Tissoiresa3e6f652014-07-24 13:05:49 -07002926static const struct wacom_features wacom_features_0x307 =
Ping Chengecd618d2014-12-04 18:25:07 -08002927 { "Wacom ISDv5 307", 59152, 33448, 2047, 63,
Ping Chengfa770342014-12-01 13:44:28 -08002928 CINTIQ_HYBRID, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES,
2929 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
Jason Gerecke36d3c512013-09-20 09:47:35 -07002930 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x309 };
Benjamin Tissoiresa3e6f652014-07-24 13:05:49 -07002931static const struct wacom_features wacom_features_0x309 =
Jason Gerecke36d3c512013-09-20 09:47:35 -07002932 { "Wacom ISDv5 309", .type = WACOM_24HDT, /* Touch */
Benjamin Tissoires29b47392014-07-24 12:52:23 -07002933 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x0307, .touch_max = 10,
2934 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
Benjamin Tissoires89f2ab52014-09-03 15:43:25 -04002935static const struct wacom_features wacom_features_0x30A =
Ping Chengecd618d2014-12-04 18:25:07 -08002936 { "Wacom ISDv5 30A", 59152, 33448, 2047, 63,
Ping Chengfa770342014-12-01 13:44:28 -08002937 CINTIQ_HYBRID, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES,
2938 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
Benjamin Tissoires89f2ab52014-09-03 15:43:25 -04002939 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x30C };
2940static const struct wacom_features wacom_features_0x30C =
2941 { "Wacom ISDv5 30C", .type = WACOM_24HDT, /* Touch */
2942 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x30A, .touch_max = 10,
2943 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
Ping Chengfefb3912014-11-11 12:52:08 -08002944static const struct wacom_features wacom_features_0x323 =
2945 { "Wacom Intuos P M", 21600, 13500, 1023, 31,
2946 INTUOSHT, WACOM_INTUOS_RES, WACOM_INTUOS_RES,
2947 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
Bastian Blankb036f6f2010-02-10 23:06:23 -08002948
Benjamin Tissoires7704ac92014-09-23 12:08:08 -04002949static const struct wacom_features wacom_features_HID_ANY_ID =
2950 { "Wacom HID", .type = HID_GENERIC };
2951
Benjamin Tissoires29b47392014-07-24 12:52:23 -07002952#define USB_DEVICE_WACOM(prod) \
2953 HID_DEVICE(BUS_USB, HID_GROUP_WACOM, USB_VENDOR_ID_WACOM, prod),\
2954 .driver_data = (kernel_ulong_t)&wacom_features_##prod
Bastian Blankb036f6f2010-02-10 23:06:23 -08002955
Benjamin Tissoires387142b2014-08-06 13:52:56 -07002956#define BT_DEVICE_WACOM(prod) \
2957 HID_DEVICE(BUS_BLUETOOTH, HID_GROUP_WACOM, USB_VENDOR_ID_WACOM, prod),\
2958 .driver_data = (kernel_ulong_t)&wacom_features_##prod
Aristeu Rozanski1483f552011-06-22 01:17:17 -07002959
Ajay Ramaswamy7b4b3062010-12-23 01:19:39 -08002960#define USB_DEVICE_LENOVO(prod) \
Benjamin Tissoires29b47392014-07-24 12:52:23 -07002961 HID_USB_DEVICE(USB_VENDOR_ID_LENOVO, prod), \
2962 .driver_data = (kernel_ulong_t)&wacom_features_##prod
Ajay Ramaswamy7b4b3062010-12-23 01:19:39 -08002963
Benjamin Tissoires29b47392014-07-24 12:52:23 -07002964const struct hid_device_id wacom_ids[] = {
Bastian Blankb036f6f2010-02-10 23:06:23 -08002965 { USB_DEVICE_WACOM(0x00) },
Benjamin Tissoiresa3e6f652014-07-24 13:05:49 -07002966 { USB_DEVICE_WACOM(0x03) },
Bastian Blankb036f6f2010-02-10 23:06:23 -08002967 { USB_DEVICE_WACOM(0x10) },
2968 { USB_DEVICE_WACOM(0x11) },
2969 { USB_DEVICE_WACOM(0x12) },
2970 { USB_DEVICE_WACOM(0x13) },
2971 { USB_DEVICE_WACOM(0x14) },
2972 { USB_DEVICE_WACOM(0x15) },
2973 { USB_DEVICE_WACOM(0x16) },
2974 { USB_DEVICE_WACOM(0x17) },
2975 { USB_DEVICE_WACOM(0x18) },
2976 { USB_DEVICE_WACOM(0x19) },
Bastian Blankb036f6f2010-02-10 23:06:23 -08002977 { USB_DEVICE_WACOM(0x20) },
2978 { USB_DEVICE_WACOM(0x21) },
2979 { USB_DEVICE_WACOM(0x22) },
2980 { USB_DEVICE_WACOM(0x23) },
2981 { USB_DEVICE_WACOM(0x24) },
Benjamin Tissoiresa3e6f652014-07-24 13:05:49 -07002982 { USB_DEVICE_WACOM(0x26) },
2983 { USB_DEVICE_WACOM(0x27) },
2984 { USB_DEVICE_WACOM(0x28) },
2985 { USB_DEVICE_WACOM(0x29) },
2986 { USB_DEVICE_WACOM(0x2A) },
Bastian Blankb036f6f2010-02-10 23:06:23 -08002987 { USB_DEVICE_WACOM(0x30) },
2988 { USB_DEVICE_WACOM(0x31) },
2989 { USB_DEVICE_WACOM(0x32) },
2990 { USB_DEVICE_WACOM(0x33) },
2991 { USB_DEVICE_WACOM(0x34) },
2992 { USB_DEVICE_WACOM(0x35) },
2993 { USB_DEVICE_WACOM(0x37) },
2994 { USB_DEVICE_WACOM(0x38) },
2995 { USB_DEVICE_WACOM(0x39) },
Benjamin Tissoiresa3e6f652014-07-24 13:05:49 -07002996 { USB_DEVICE_WACOM(0x3F) },
Bastian Blankb036f6f2010-02-10 23:06:23 -08002997 { USB_DEVICE_WACOM(0x41) },
2998 { USB_DEVICE_WACOM(0x42) },
2999 { USB_DEVICE_WACOM(0x43) },
3000 { USB_DEVICE_WACOM(0x44) },
3001 { USB_DEVICE_WACOM(0x45) },
Benjamin Tissoiresa3e6f652014-07-24 13:05:49 -07003002 { USB_DEVICE_WACOM(0x47) },
Ping Cheng56218562013-05-05 19:56:18 -07003003 { USB_DEVICE_WACOM(0x57) },
Ping Chenga112e9f2013-02-13 20:20:01 -08003004 { USB_DEVICE_WACOM(0x59) },
Ping Cheng56218562013-05-05 19:56:18 -07003005 { USB_DEVICE_WACOM(0x5B) },
Benjamin Tissoiresa3e6f652014-07-24 13:05:49 -07003006 { USB_DEVICE_WACOM(0x5D) },
Benjamin Tissoires29b47392014-07-24 12:52:23 -07003007 { USB_DEVICE_WACOM(0x5E) },
Benjamin Tissoiresa3e6f652014-07-24 13:05:49 -07003008 { USB_DEVICE_WACOM(0x60) },
3009 { USB_DEVICE_WACOM(0x61) },
3010 { USB_DEVICE_WACOM(0x62) },
3011 { USB_DEVICE_WACOM(0x63) },
3012 { USB_DEVICE_WACOM(0x64) },
3013 { USB_DEVICE_WACOM(0x65) },
3014 { USB_DEVICE_WACOM(0x69) },
3015 { USB_DEVICE_WACOM(0x6A) },
3016 { USB_DEVICE_WACOM(0x6B) },
Benjamin Tissoires387142b2014-08-06 13:52:56 -07003017 { BT_DEVICE_WACOM(0x81) },
Benjamin Tissoiresa3e6f652014-07-24 13:05:49 -07003018 { USB_DEVICE_WACOM(0x84) },
3019 { USB_DEVICE_WACOM(0x90) },
3020 { USB_DEVICE_WACOM(0x93) },
3021 { USB_DEVICE_WACOM(0x97) },
3022 { USB_DEVICE_WACOM(0x9A) },
3023 { USB_DEVICE_WACOM(0x9F) },
Bastian Blankb036f6f2010-02-10 23:06:23 -08003024 { USB_DEVICE_WACOM(0xB0) },
3025 { USB_DEVICE_WACOM(0xB1) },
3026 { USB_DEVICE_WACOM(0xB2) },
3027 { USB_DEVICE_WACOM(0xB3) },
3028 { USB_DEVICE_WACOM(0xB4) },
3029 { USB_DEVICE_WACOM(0xB5) },
3030 { USB_DEVICE_WACOM(0xB7) },
3031 { USB_DEVICE_WACOM(0xB8) },
3032 { USB_DEVICE_WACOM(0xB9) },
3033 { USB_DEVICE_WACOM(0xBA) },
3034 { USB_DEVICE_WACOM(0xBB) },
Ping Cheng3a4b4aa2010-06-03 22:10:21 -07003035 { USB_DEVICE_WACOM(0xBC) },
Benjamin Tissoires81af7e62014-08-06 13:55:56 -07003036 { BT_DEVICE_WACOM(0xBD) },
Benjamin Tissoiresa3e6f652014-07-24 13:05:49 -07003037 { USB_DEVICE_WACOM(0xC0) },
3038 { USB_DEVICE_WACOM(0xC2) },
3039 { USB_DEVICE_WACOM(0xC4) },
Bastian Blankb036f6f2010-02-10 23:06:23 -08003040 { USB_DEVICE_WACOM(0xC5) },
3041 { USB_DEVICE_WACOM(0xC6) },
3042 { USB_DEVICE_WACOM(0xC7) },
Benjamin Tissoiresa3e6f652014-07-24 13:05:49 -07003043 { USB_DEVICE_WACOM(0xCC) },
Benjamin Tissoires29b47392014-07-24 12:52:23 -07003044 { USB_DEVICE_WACOM(0xCE) },
Henrik Rydbergcb734c02010-09-05 12:53:16 -07003045 { USB_DEVICE_WACOM(0xD0) },
Chris Bagwell2aaacb12010-09-12 00:11:35 -07003046 { USB_DEVICE_WACOM(0xD1) },
3047 { USB_DEVICE_WACOM(0xD2) },
3048 { USB_DEVICE_WACOM(0xD3) },
Kevin Granade57a78722010-12-10 23:04:02 -08003049 { USB_DEVICE_WACOM(0xD4) },
Gerard Braad18adad12011-08-16 00:17:56 -07003050 { USB_DEVICE_WACOM(0xD5) },
Ping Chengd38acb42011-01-24 09:32:50 -08003051 { USB_DEVICE_WACOM(0xD6) },
3052 { USB_DEVICE_WACOM(0xD7) },
David Foleya318e6b2010-11-30 23:45:46 -08003053 { USB_DEVICE_WACOM(0xD8) },
3054 { USB_DEVICE_WACOM(0xDA) },
David Foley47d09232010-12-07 21:05:59 -08003055 { USB_DEVICE_WACOM(0xDB) },
Chris Bagwell73149ab2011-10-26 22:34:21 -07003056 { USB_DEVICE_WACOM(0xDD) },
3057 { USB_DEVICE_WACOM(0xDE) },
3058 { USB_DEVICE_WACOM(0xDF) },
Bastian Blankb036f6f2010-02-10 23:06:23 -08003059 { USB_DEVICE_WACOM(0xE2) },
3060 { USB_DEVICE_WACOM(0xE3) },
Ping Cheng19635182012-04-29 21:09:18 -07003061 { USB_DEVICE_WACOM(0xE5) },
Manoj Iyer26fcd2a2011-03-31 22:39:43 -07003062 { USB_DEVICE_WACOM(0xE6) },
Chris Bagwell0d0e3062011-12-11 23:50:59 -08003063 { USB_DEVICE_WACOM(0xEC) },
Ping Chengac173832012-06-12 00:15:06 -07003064 { USB_DEVICE_WACOM(0xED) },
3065 { USB_DEVICE_WACOM(0xEF) },
Benjamin Tissoiresa3e6f652014-07-24 13:05:49 -07003066 { USB_DEVICE_WACOM(0xF0) },
3067 { USB_DEVICE_WACOM(0xF4) },
3068 { USB_DEVICE_WACOM(0xF6) },
3069 { USB_DEVICE_WACOM(0xF8) },
3070 { USB_DEVICE_WACOM(0xFA) },
3071 { USB_DEVICE_WACOM(0xFB) },
Ping Cheng6afdc282012-11-03 12:16:15 -07003072 { USB_DEVICE_WACOM(0x100) },
3073 { USB_DEVICE_WACOM(0x101) },
Stephan Frank58694832013-03-07 14:08:50 -08003074 { USB_DEVICE_WACOM(0x10D) },
Jason Gerecke2d3163f2013-10-22 15:35:30 -07003075 { USB_DEVICE_WACOM(0x10E) },
Jason Gerecke9b4f60e2013-10-15 23:46:34 -07003076 { USB_DEVICE_WACOM(0x10F) },
Jason Gerecke61616ed2014-05-14 11:42:22 -07003077 { USB_DEVICE_WACOM(0x116) },
Jason Gereckeaeaf50d2014-07-28 10:53:16 -07003078 { USB_DEVICE_WACOM(0x12C) },
Ping Chengf41a64e2013-08-21 09:14:49 -07003079 { USB_DEVICE_WACOM(0x300) },
3080 { USB_DEVICE_WACOM(0x301) },
Benjamin Tissoires29b47392014-07-24 12:52:23 -07003081 { USB_DEVICE_WACOM(0x302) },
3082 { USB_DEVICE_WACOM(0x303) },
Ping Cheng56218562013-05-05 19:56:18 -07003083 { USB_DEVICE_WACOM(0x304) },
Benjamin Tissoiresa3e6f652014-07-24 13:05:49 -07003084 { USB_DEVICE_WACOM(0x307) },
3085 { USB_DEVICE_WACOM(0x309) },
Benjamin Tissoires89f2ab52014-09-03 15:43:25 -04003086 { USB_DEVICE_WACOM(0x30A) },
3087 { USB_DEVICE_WACOM(0x30C) },
Benjamin Tissoiresa3e6f652014-07-24 13:05:49 -07003088 { USB_DEVICE_WACOM(0x30E) },
Benjamin Tissoires29b47392014-07-24 12:52:23 -07003089 { USB_DEVICE_WACOM(0x314) },
3090 { USB_DEVICE_WACOM(0x315) },
3091 { USB_DEVICE_WACOM(0x317) },
Ping Chengfefb3912014-11-11 12:52:08 -08003092 { USB_DEVICE_WACOM(0x323) },
Ping Chengfff00bf2014-12-04 18:23:04 -08003093 { USB_DEVICE_WACOM(0x32F) },
Ping Chengedbe2652012-11-21 13:12:50 -08003094 { USB_DEVICE_WACOM(0x4001) },
Jason Gerecked51ddb22014-05-14 17:14:29 -07003095 { USB_DEVICE_WACOM(0x4004) },
3096 { USB_DEVICE_WACOM(0x5000) },
3097 { USB_DEVICE_WACOM(0x5002) },
Benjamin Tissoires00d6f222014-12-01 11:52:39 -05003098 { USB_DEVICE_LENOVO(0x6004) },
Benjamin Tissoires7704ac92014-09-23 12:08:08 -04003099
3100 { USB_DEVICE_WACOM(HID_ANY_ID) },
Ping Cheng3bea7332006-07-13 18:01:36 -07003101 { }
3102};
Benjamin Tissoires29b47392014-07-24 12:52:23 -07003103MODULE_DEVICE_TABLE(hid, wacom_ids);