blob: 4453864956b6499d3b0252c0d767bdfc9cd07229 [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
Dmitry Torokhov95dd3b32010-03-19 22:18:15 -070028static int wacom_penpartner_irq(struct wacom_wac *wacom)
Ping Cheng3bea7332006-07-13 18:01:36 -070029{
30 unsigned char *data = wacom->data;
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -070031 struct input_dev *input = wacom->input;
Ping Cheng3bea7332006-07-13 18:01:36 -070032
33 switch (data[0]) {
Dmitry Torokhov73a97f42010-03-19 22:18:15 -070034 case 1:
35 if (data[5] & 0x80) {
36 wacom->tool[0] = (data[5] & 0x20) ? BTN_TOOL_RUBBER : BTN_TOOL_PEN;
37 wacom->id[0] = (data[5] & 0x20) ? ERASER_DEVICE_ID : STYLUS_DEVICE_ID;
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -070038 input_report_key(input, wacom->tool[0], 1);
39 input_report_abs(input, ABS_MISC, wacom->id[0]); /* report tool id */
Dmitry Torokhov252f7762010-03-19 22:33:38 -070040 input_report_abs(input, ABS_X, get_unaligned_le16(&data[1]));
41 input_report_abs(input, ABS_Y, get_unaligned_le16(&data[3]));
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -070042 input_report_abs(input, ABS_PRESSURE, (signed char)data[6] + 127);
43 input_report_key(input, BTN_TOUCH, ((signed char)data[6] > -127));
44 input_report_key(input, BTN_STYLUS, (data[5] & 0x40));
Dmitry Torokhov73a97f42010-03-19 22:18:15 -070045 } else {
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -070046 input_report_key(input, wacom->tool[0], 0);
47 input_report_abs(input, ABS_MISC, 0); /* report tool id */
48 input_report_abs(input, ABS_PRESSURE, -1);
49 input_report_key(input, BTN_TOUCH, 0);
Dmitry Torokhov73a97f42010-03-19 22:18:15 -070050 }
51 break;
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -070052
Dmitry Torokhov73a97f42010-03-19 22:18:15 -070053 case 2:
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -070054 input_report_key(input, BTN_TOOL_PEN, 1);
55 input_report_abs(input, ABS_MISC, STYLUS_DEVICE_ID); /* report tool id */
Dmitry Torokhov252f7762010-03-19 22:33:38 -070056 input_report_abs(input, ABS_X, get_unaligned_le16(&data[1]));
57 input_report_abs(input, ABS_Y, get_unaligned_le16(&data[3]));
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -070058 input_report_abs(input, ABS_PRESSURE, (signed char)data[6] + 127);
59 input_report_key(input, BTN_TOUCH, ((signed char)data[6] > -80) && !(data[5] & 0x20));
60 input_report_key(input, BTN_STYLUS, (data[5] & 0x40));
Dmitry Torokhov73a97f42010-03-19 22:18:15 -070061 break;
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -070062
Dmitry Torokhov73a97f42010-03-19 22:18:15 -070063 default:
Dmitry Torokhoveb71d1b2012-05-02 00:13:38 -070064 dev_dbg(input->dev.parent,
65 "%s: received unknown report #%d\n", __func__, data[0]);
Dmitry Torokhov73a97f42010-03-19 22:18:15 -070066 return 0;
Ping Cheng3bea7332006-07-13 18:01:36 -070067 }
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -070068
Ping Cheng3bea7332006-07-13 18:01:36 -070069 return 1;
70}
71
Dmitry Torokhov95dd3b32010-03-19 22:18:15 -070072static int wacom_pl_irq(struct wacom_wac *wacom)
Ping Cheng3bea7332006-07-13 18:01:36 -070073{
Jason Childse33da8a2010-02-17 22:38:31 -080074 struct wacom_features *features = &wacom->features;
Ping Cheng3bea7332006-07-13 18:01:36 -070075 unsigned char *data = wacom->data;
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -070076 struct input_dev *input = wacom->input;
Ping Chenge34b9d22008-05-05 11:36:41 -040077 int prox, pressure;
Ping Cheng3bea7332006-07-13 18:01:36 -070078
Ping Chengcad74702009-12-15 00:35:25 -080079 if (data[0] != WACOM_REPORT_PENABLED) {
Dmitry Torokhoveb71d1b2012-05-02 00:13:38 -070080 dev_dbg(input->dev.parent,
81 "%s: received unknown report #%d\n", __func__, data[0]);
Ping Cheng3bea7332006-07-13 18:01:36 -070082 return 0;
83 }
84
85 prox = data[1] & 0x40;
86
Ping Cheng3bea7332006-07-13 18:01:36 -070087 if (prox) {
Ping Chengec67bbe2009-12-15 00:35:24 -080088 wacom->id[0] = ERASER_DEVICE_ID;
Ping Cheng3bea7332006-07-13 18:01:36 -070089 pressure = (signed char)((data[7] << 1) | ((data[4] >> 2) & 1));
Jason Childse33da8a2010-02-17 22:38:31 -080090 if (features->pressure_max > 255)
Ping Cheng3bea7332006-07-13 18:01:36 -070091 pressure = (pressure << 1) | ((data[4] >> 6) & 1);
Jason Childse33da8a2010-02-17 22:38:31 -080092 pressure += (features->pressure_max + 1) / 2;
Ping Cheng3bea7332006-07-13 18:01:36 -070093
94 /*
95 * if going from out of proximity into proximity select between the eraser
96 * and the pen based on the state of the stylus2 button, choose eraser if
97 * pressed else choose pen. if not a proximity change from out to in, send
98 * an out of proximity for previous tool then a in for new tool.
99 */
100 if (!wacom->tool[0]) {
101 /* Eraser bit set for DTF */
102 if (data[1] & 0x10)
103 wacom->tool[1] = BTN_TOOL_RUBBER;
104 else
105 /* Going into proximity select tool */
106 wacom->tool[1] = (data[4] & 0x20) ? BTN_TOOL_RUBBER : BTN_TOOL_PEN;
107 } else {
108 /* was entered with stylus2 pressed */
109 if (wacom->tool[1] == BTN_TOOL_RUBBER && !(data[4] & 0x20)) {
110 /* report out proximity for previous tool */
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700111 input_report_key(input, wacom->tool[1], 0);
112 input_sync(input);
Ping Cheng3bea7332006-07-13 18:01:36 -0700113 wacom->tool[1] = BTN_TOOL_PEN;
114 return 0;
115 }
116 }
117 if (wacom->tool[1] != BTN_TOOL_RUBBER) {
118 /* Unknown tool selected default to pen tool */
119 wacom->tool[1] = BTN_TOOL_PEN;
Ping Chenge34b9d22008-05-05 11:36:41 -0400120 wacom->id[0] = STYLUS_DEVICE_ID;
Ping Cheng3bea7332006-07-13 18:01:36 -0700121 }
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700122 input_report_key(input, wacom->tool[1], prox); /* report in proximity for tool */
123 input_report_abs(input, ABS_MISC, wacom->id[0]); /* report tool id */
124 input_report_abs(input, ABS_X, data[3] | (data[2] << 7) | ((data[1] & 0x03) << 14));
125 input_report_abs(input, ABS_Y, data[6] | (data[5] << 7) | ((data[4] & 0x03) << 14));
126 input_report_abs(input, ABS_PRESSURE, pressure);
Ping Cheng3bea7332006-07-13 18:01:36 -0700127
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700128 input_report_key(input, BTN_TOUCH, data[4] & 0x08);
129 input_report_key(input, BTN_STYLUS, data[4] & 0x10);
Ping Cheng3bea7332006-07-13 18:01:36 -0700130 /* Only allow the stylus2 button to be reported for the pen tool. */
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700131 input_report_key(input, BTN_STYLUS2, (wacom->tool[1] == BTN_TOOL_PEN) && (data[4] & 0x20));
Ping Cheng3bea7332006-07-13 18:01:36 -0700132 } else {
133 /* report proximity-out of a (valid) tool */
134 if (wacom->tool[1] != BTN_TOOL_RUBBER) {
135 /* Unknown tool selected default to pen tool */
136 wacom->tool[1] = BTN_TOOL_PEN;
137 }
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700138 input_report_key(input, wacom->tool[1], prox);
Ping Cheng3bea7332006-07-13 18:01:36 -0700139 }
140
141 wacom->tool[0] = prox; /* Save proximity state */
142 return 1;
143}
144
Dmitry Torokhov95dd3b32010-03-19 22:18:15 -0700145static int wacom_ptu_irq(struct wacom_wac *wacom)
Ping Cheng3bea7332006-07-13 18:01:36 -0700146{
147 unsigned char *data = wacom->data;
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700148 struct input_dev *input = wacom->input;
Ping Cheng3bea7332006-07-13 18:01:36 -0700149
Ping Chengcad74702009-12-15 00:35:25 -0800150 if (data[0] != WACOM_REPORT_PENABLED) {
Dmitry Torokhoveb71d1b2012-05-02 00:13:38 -0700151 dev_dbg(input->dev.parent,
152 "%s: received unknown report #%d\n", __func__, data[0]);
Ping Cheng3bea7332006-07-13 18:01:36 -0700153 return 0;
154 }
155
Ping Cheng3bea7332006-07-13 18:01:36 -0700156 if (data[1] & 0x04) {
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700157 input_report_key(input, BTN_TOOL_RUBBER, data[1] & 0x20);
158 input_report_key(input, BTN_TOUCH, data[1] & 0x08);
Ping Chenge34b9d22008-05-05 11:36:41 -0400159 wacom->id[0] = ERASER_DEVICE_ID;
Ping Cheng3bea7332006-07-13 18:01:36 -0700160 } else {
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700161 input_report_key(input, BTN_TOOL_PEN, data[1] & 0x20);
162 input_report_key(input, BTN_TOUCH, data[1] & 0x01);
Ping Chenge34b9d22008-05-05 11:36:41 -0400163 wacom->id[0] = STYLUS_DEVICE_ID;
Ping Cheng3bea7332006-07-13 18:01:36 -0700164 }
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700165 input_report_abs(input, ABS_MISC, wacom->id[0]); /* report tool id */
Dmitry Torokhov252f7762010-03-19 22:33:38 -0700166 input_report_abs(input, ABS_X, le16_to_cpup((__le16 *)&data[2]));
167 input_report_abs(input, ABS_Y, le16_to_cpup((__le16 *)&data[4]));
168 input_report_abs(input, ABS_PRESSURE, le16_to_cpup((__le16 *)&data[6]));
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700169 input_report_key(input, BTN_STYLUS, data[1] & 0x02);
170 input_report_key(input, BTN_STYLUS2, data[1] & 0x10);
Ping Cheng3bea7332006-07-13 18:01:36 -0700171 return 1;
172}
173
Ping Chengc8f2edc2010-06-28 01:10:51 -0700174static int wacom_dtu_irq(struct wacom_wac *wacom)
175{
176 struct wacom_features *features = &wacom->features;
177 char *data = wacom->data;
178 struct input_dev *input = wacom->input;
179 int prox = data[1] & 0x20, pressure;
180
Dmitry Torokhoveb71d1b2012-05-02 00:13:38 -0700181 dev_dbg(input->dev.parent,
182 "%s: received report #%d", __func__, data[0]);
Ping Chengc8f2edc2010-06-28 01:10:51 -0700183
184 if (prox) {
185 /* Going into proximity select tool */
186 wacom->tool[0] = (data[1] & 0x0c) ? BTN_TOOL_RUBBER : BTN_TOOL_PEN;
187 if (wacom->tool[0] == BTN_TOOL_PEN)
188 wacom->id[0] = STYLUS_DEVICE_ID;
189 else
190 wacom->id[0] = ERASER_DEVICE_ID;
191 }
192 input_report_key(input, BTN_STYLUS, data[1] & 0x02);
193 input_report_key(input, BTN_STYLUS2, data[1] & 0x10);
194 input_report_abs(input, ABS_X, le16_to_cpup((__le16 *)&data[2]));
195 input_report_abs(input, ABS_Y, le16_to_cpup((__le16 *)&data[4]));
196 pressure = ((data[7] & 0x01) << 8) | data[6];
197 if (pressure < 0)
198 pressure = features->pressure_max + pressure + 1;
199 input_report_abs(input, ABS_PRESSURE, pressure);
200 input_report_key(input, BTN_TOUCH, data[1] & 0x05);
201 if (!prox) /* out-prox */
202 wacom->id[0] = 0;
203 input_report_key(input, wacom->tool[0], prox);
204 input_report_abs(input, ABS_MISC, wacom->id[0]);
205 return 1;
206}
207
Dmitry Torokhov95dd3b32010-03-19 22:18:15 -0700208static int wacom_graphire_irq(struct wacom_wac *wacom)
Ping Cheng3bea7332006-07-13 18:01:36 -0700209{
Jason Childse33da8a2010-02-17 22:38:31 -0800210 struct wacom_features *features = &wacom->features;
Ping Cheng3bea7332006-07-13 18:01:36 -0700211 unsigned char *data = wacom->data;
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700212 struct input_dev *input = wacom->input;
Dmitry Torokhov252f7762010-03-19 22:33:38 -0700213 int prox;
Ping Cheng3b57ca02010-03-04 21:50:59 -0800214 int rw = 0;
215 int retval = 0;
Ping Cheng3bea7332006-07-13 18:01:36 -0700216
Ping Chengcad74702009-12-15 00:35:25 -0800217 if (data[0] != WACOM_REPORT_PENABLED) {
Dmitry Torokhoveb71d1b2012-05-02 00:13:38 -0700218 dev_dbg(input->dev.parent,
219 "%s: received unknown report #%d\n", __func__, data[0]);
Ping Cheng3b57ca02010-03-04 21:50:59 -0800220 goto exit;
Ping Cheng3bea7332006-07-13 18:01:36 -0700221 }
222
Ping Cheng3b57ca02010-03-04 21:50:59 -0800223 prox = data[1] & 0x80;
224 if (prox || wacom->id[0]) {
225 if (prox) {
226 switch ((data[1] >> 5) & 3) {
Ping Cheng3bea7332006-07-13 18:01:36 -0700227
228 case 0: /* Pen */
229 wacom->tool[0] = BTN_TOOL_PEN;
Ping Chenge34b9d22008-05-05 11:36:41 -0400230 wacom->id[0] = STYLUS_DEVICE_ID;
Ping Cheng3bea7332006-07-13 18:01:36 -0700231 break;
232
233 case 1: /* Rubber */
234 wacom->tool[0] = BTN_TOOL_RUBBER;
Ping Chenge34b9d22008-05-05 11:36:41 -0400235 wacom->id[0] = ERASER_DEVICE_ID;
Ping Cheng3bea7332006-07-13 18:01:36 -0700236 break;
237
238 case 2: /* Mouse with wheel */
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700239 input_report_key(input, BTN_MIDDLE, data[1] & 0x04);
Ping Cheng3bea7332006-07-13 18:01:36 -0700240 /* fall through */
241
242 case 3: /* Mouse without wheel */
243 wacom->tool[0] = BTN_TOOL_MOUSE;
Ping Chenge34b9d22008-05-05 11:36:41 -0400244 wacom->id[0] = CURSOR_DEVICE_ID;
Ping Cheng3bea7332006-07-13 18:01:36 -0700245 break;
Ping Cheng3b57ca02010-03-04 21:50:59 -0800246 }
Ping Cheng3bea7332006-07-13 18:01:36 -0700247 }
Dmitry Torokhov252f7762010-03-19 22:33:38 -0700248 input_report_abs(input, ABS_X, le16_to_cpup((__le16 *)&data[2]));
249 input_report_abs(input, ABS_Y, le16_to_cpup((__le16 *)&data[4]));
Ping Cheng3bea7332006-07-13 18:01:36 -0700250 if (wacom->tool[0] != BTN_TOOL_MOUSE) {
Chris Bagwell6dc46352012-06-12 00:25:48 -0700251 input_report_abs(input, ABS_PRESSURE, data[6] | ((data[7] & 0x03) << 8));
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700252 input_report_key(input, BTN_TOUCH, data[1] & 0x01);
253 input_report_key(input, BTN_STYLUS, data[1] & 0x02);
254 input_report_key(input, BTN_STYLUS2, data[1] & 0x04);
Dmitry Torokhovafb567e2010-04-13 23:08:58 -0700255 } else {
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700256 input_report_key(input, BTN_LEFT, data[1] & 0x01);
257 input_report_key(input, BTN_RIGHT, data[1] & 0x02);
Ping Cheng3b57ca02010-03-04 21:50:59 -0800258 if (features->type == WACOM_G4 ||
259 features->type == WACOM_MO) {
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700260 input_report_abs(input, ABS_DISTANCE, data[6] & 0x3f);
Mike Autyd9f66c12010-08-28 20:35:17 -0700261 rw = (data[7] & 0x04) - (data[7] & 0x03);
Ping Cheng3b57ca02010-03-04 21:50:59 -0800262 } else {
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700263 input_report_abs(input, ABS_DISTANCE, data[7] & 0x3f);
Mike Autyd9f66c12010-08-28 20:35:17 -0700264 rw = -(signed char)data[6];
Ping Cheng3b57ca02010-03-04 21:50:59 -0800265 }
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700266 input_report_rel(input, REL_WHEEL, rw);
Dmitry Torokhovafb567e2010-04-13 23:08:58 -0700267 }
Ping Cheng3b57ca02010-03-04 21:50:59 -0800268
269 if (!prox)
270 wacom->id[0] = 0;
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700271 input_report_abs(input, ABS_MISC, wacom->id[0]); /* report tool id */
272 input_report_key(input, wacom->tool[0], prox);
Ping Cheng998c4542011-07-06 18:05:41 -0700273 input_event(input, EV_MSC, MSC_SERIAL, 1);
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700274 input_sync(input); /* sync last event */
Ping Cheng80d4e8e2007-02-23 12:22:48 -0800275 }
Ping Cheng3bea7332006-07-13 18:01:36 -0700276
277 /* send pad data */
Jason Childse33da8a2010-02-17 22:38:31 -0800278 switch (features->type) {
Dmitry Torokhov73a97f42010-03-19 22:18:15 -0700279 case WACOM_G4:
Ping Cheng3b57ca02010-03-04 21:50:59 -0800280 prox = data[7] & 0xf8;
281 if (prox || wacom->id[1]) {
Ping Chenge34b9d22008-05-05 11:36:41 -0400282 wacom->id[1] = PAD_DEVICE_ID;
Ping Cheng0bd10ef2011-07-06 18:05:42 -0700283 input_report_key(input, BTN_BACK, (data[7] & 0x40));
284 input_report_key(input, BTN_FORWARD, (data[7] & 0x80));
Ping Cheng3bea7332006-07-13 18:01:36 -0700285 rw = ((data[7] & 0x18) >> 3) - ((data[7] & 0x20) >> 3);
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700286 input_report_rel(input, REL_WHEEL, rw);
Ping Cheng3b57ca02010-03-04 21:50:59 -0800287 if (!prox)
288 wacom->id[1] = 0;
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700289 input_report_abs(input, ABS_MISC, wacom->id[1]);
290 input_event(input, EV_MSC, MSC_SERIAL, 0xf0);
Ping Chengab687b12010-04-05 23:07:41 -0700291 retval = 1;
Ping Cheng3bea7332006-07-13 18:01:36 -0700292 }
Ping Cheng7ecfbfd2007-06-14 23:32:48 -0400293 break;
Dmitry Torokhov73a97f42010-03-19 22:18:15 -0700294
295 case WACOM_MO:
Ping Cheng3b57ca02010-03-04 21:50:59 -0800296 prox = (data[7] & 0xf8) || data[8];
297 if (prox || wacom->id[1]) {
Ping Chenge34b9d22008-05-05 11:36:41 -0400298 wacom->id[1] = PAD_DEVICE_ID;
Ping Cheng0bd10ef2011-07-06 18:05:42 -0700299 input_report_key(input, BTN_BACK, (data[7] & 0x08));
300 input_report_key(input, BTN_LEFT, (data[7] & 0x20));
301 input_report_key(input, BTN_FORWARD, (data[7] & 0x10));
302 input_report_key(input, BTN_RIGHT, (data[7] & 0x40));
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700303 input_report_abs(input, ABS_WHEEL, (data[8] & 0x7f));
Ping Cheng3b57ca02010-03-04 21:50:59 -0800304 if (!prox)
305 wacom->id[1] = 0;
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700306 input_report_abs(input, ABS_MISC, wacom->id[1]);
307 input_event(input, EV_MSC, MSC_SERIAL, 0xf0);
Ping Cheng84460012011-07-06 18:05:43 -0700308 retval = 1;
Ping Cheng7ecfbfd2007-06-14 23:32:48 -0400309 }
310 break;
Ping Cheng3bea7332006-07-13 18:01:36 -0700311 }
Ping Cheng3b57ca02010-03-04 21:50:59 -0800312exit:
313 return retval;
Ping Cheng3bea7332006-07-13 18:01:36 -0700314}
315
Dmitry Torokhov95dd3b32010-03-19 22:18:15 -0700316static int wacom_intuos_inout(struct wacom_wac *wacom)
Ping Cheng3bea7332006-07-13 18:01:36 -0700317{
Jason Childse33da8a2010-02-17 22:38:31 -0800318 struct wacom_features *features = &wacom->features;
Ping Cheng3bea7332006-07-13 18:01:36 -0700319 unsigned char *data = wacom->data;
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700320 struct input_dev *input = wacom->input;
Ping Cheng6f660f12009-05-08 18:30:33 -0700321 int idx = 0;
Ping Cheng3bea7332006-07-13 18:01:36 -0700322
323 /* tool number */
Jason Childse33da8a2010-02-17 22:38:31 -0800324 if (features->type == INTUOS)
Ping Cheng6f660f12009-05-08 18:30:33 -0700325 idx = data[1] & 0x01;
Ping Cheng3bea7332006-07-13 18:01:36 -0700326
327 /* Enter report */
328 if ((data[1] & 0xfc) == 0xc0) {
Jason Gereckeae584ca2012-04-03 15:50:40 -0700329 if (features->type >= INTUOS5S && features->type <= INTUOS5L)
330 wacom->shared->stylus_in_proximity = true;
331
Ping Cheng3bea7332006-07-13 18:01:36 -0700332 /* serial number of the tool */
333 wacom->serial[idx] = ((data[3] & 0x0f) << 28) +
334 (data[4] << 20) + (data[5] << 12) +
335 (data[6] << 4) + (data[7] >> 4);
336
Ping Cheng493630b2010-06-22 11:21:34 -0700337 wacom->id[idx] = (data[2] << 4) | (data[3] >> 4) |
338 ((data[7] & 0x0f) << 20) | ((data[8] & 0xf0) << 12);
Dmitry Torokhov73a97f42010-03-19 22:18:15 -0700339
Ping Cheng493630b2010-06-22 11:21:34 -0700340 switch (wacom->id[idx] & 0xfffff) {
Dmitry Torokhov73a97f42010-03-19 22:18:15 -0700341 case 0x812: /* Inking pen */
342 case 0x801: /* Intuos3 Inking pen */
Ping Cheng493630b2010-06-22 11:21:34 -0700343 case 0x20802: /* Intuos4 Inking Pen */
Dmitry Torokhov73a97f42010-03-19 22:18:15 -0700344 case 0x012:
345 wacom->tool[idx] = BTN_TOOL_PENCIL;
346 break;
347
348 case 0x822: /* Pen */
349 case 0x842:
350 case 0x852:
351 case 0x823: /* Intuos3 Grip Pen */
352 case 0x813: /* Intuos3 Classic Pen */
353 case 0x885: /* Intuos3 Marker Pen */
Ping Cheng3a4b4aa2010-06-03 22:10:21 -0700354 case 0x802: /* Intuos4 General Pen */
Dmitry Torokhov73a97f42010-03-19 22:18:15 -0700355 case 0x804: /* Intuos4 Marker Pen */
356 case 0x40802: /* Intuos4 Classic Pen */
357 case 0x022:
358 wacom->tool[idx] = BTN_TOOL_PEN;
359 break;
360
361 case 0x832: /* Stroke pen */
362 case 0x032:
363 wacom->tool[idx] = BTN_TOOL_BRUSH;
364 break;
365
366 case 0x007: /* Mouse 4D and 2D */
367 case 0x09c:
368 case 0x094:
369 case 0x017: /* Intuos3 2D Mouse */
370 case 0x806: /* Intuos4 Mouse */
371 wacom->tool[idx] = BTN_TOOL_MOUSE;
372 break;
373
374 case 0x096: /* Lens cursor */
375 case 0x097: /* Intuos3 Lens cursor */
376 case 0x006: /* Intuos4 Lens cursor */
377 wacom->tool[idx] = BTN_TOOL_LENS;
378 break;
379
380 case 0x82a: /* Eraser */
381 case 0x85a:
382 case 0x91a:
383 case 0xd1a:
384 case 0x0fa:
385 case 0x82b: /* Intuos3 Grip Pen Eraser */
386 case 0x81b: /* Intuos3 Classic Pen Eraser */
387 case 0x91b: /* Intuos3 Airbrush Eraser */
388 case 0x80c: /* Intuos4 Marker Pen Eraser */
Ping Cheng3a4b4aa2010-06-03 22:10:21 -0700389 case 0x80a: /* Intuos4 General Pen Eraser */
Dmitry Torokhov73a97f42010-03-19 22:18:15 -0700390 case 0x4080a: /* Intuos4 Classic Pen Eraser */
391 case 0x90a: /* Intuos4 Airbrush Eraser */
392 wacom->tool[idx] = BTN_TOOL_RUBBER;
393 break;
394
395 case 0xd12:
396 case 0x912:
397 case 0x112:
398 case 0x913: /* Intuos3 Airbrush */
399 case 0x902: /* Intuos4 Airbrush */
400 wacom->tool[idx] = BTN_TOOL_AIRBRUSH;
401 break;
402
403 default: /* Unknown tool */
404 wacom->tool[idx] = BTN_TOOL_PEN;
405 break;
Ping Cheng3bea7332006-07-13 18:01:36 -0700406 }
Ping Cheng3bea7332006-07-13 18:01:36 -0700407 return 1;
408 }
409
Ping Cheng3a4b4aa2010-06-03 22:10:21 -0700410 /* older I4 styli don't work with new Cintiqs */
411 if (!((wacom->id[idx] >> 20) & 0x01) &&
412 (features->type == WACOM_21UX2))
413 return 1;
414
Ping Cheng3bea7332006-07-13 18:01:36 -0700415 /* Exit report */
416 if ((data[1] & 0xfe) == 0x80) {
Jason Gereckeae584ca2012-04-03 15:50:40 -0700417 if (features->type >= INTUOS5S && features->type <= INTUOS5L)
418 wacom->shared->stylus_in_proximity = false;
419
Ping Cheng6f660f12009-05-08 18:30:33 -0700420 /*
421 * Reset all states otherwise we lose the initial states
422 * when in-prox next time
423 */
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700424 input_report_abs(input, ABS_X, 0);
425 input_report_abs(input, ABS_Y, 0);
426 input_report_abs(input, ABS_DISTANCE, 0);
427 input_report_abs(input, ABS_TILT_X, 0);
428 input_report_abs(input, ABS_TILT_Y, 0);
Ping Cheng80d4e8e2007-02-23 12:22:48 -0800429 if (wacom->tool[idx] >= BTN_TOOL_MOUSE) {
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700430 input_report_key(input, BTN_LEFT, 0);
431 input_report_key(input, BTN_MIDDLE, 0);
432 input_report_key(input, BTN_RIGHT, 0);
433 input_report_key(input, BTN_SIDE, 0);
434 input_report_key(input, BTN_EXTRA, 0);
435 input_report_abs(input, ABS_THROTTLE, 0);
436 input_report_abs(input, ABS_RZ, 0);
Ping Cheng7ecfbfd2007-06-14 23:32:48 -0400437 } else {
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700438 input_report_abs(input, ABS_PRESSURE, 0);
439 input_report_key(input, BTN_STYLUS, 0);
440 input_report_key(input, BTN_STYLUS2, 0);
441 input_report_key(input, BTN_TOUCH, 0);
442 input_report_abs(input, ABS_WHEEL, 0);
Jason Childse33da8a2010-02-17 22:38:31 -0800443 if (features->type >= INTUOS3S)
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700444 input_report_abs(input, ABS_Z, 0);
Ping Cheng8d32e3a2006-09-26 13:34:47 -0700445 }
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700446 input_report_key(input, wacom->tool[idx], 0);
447 input_report_abs(input, ABS_MISC, 0); /* reset tool id */
448 input_event(input, EV_MSC, MSC_SERIAL, wacom->serial[idx]);
Ping Cheng6f660f12009-05-08 18:30:33 -0700449 wacom->id[idx] = 0;
Ping Cheng80d4e8e2007-02-23 12:22:48 -0800450 return 2;
Ping Cheng3bea7332006-07-13 18:01:36 -0700451 }
452 return 0;
453}
454
Dmitry Torokhov95dd3b32010-03-19 22:18:15 -0700455static void wacom_intuos_general(struct wacom_wac *wacom)
Ping Cheng3bea7332006-07-13 18:01:36 -0700456{
Jason Childse33da8a2010-02-17 22:38:31 -0800457 struct wacom_features *features = &wacom->features;
Ping Cheng3bea7332006-07-13 18:01:36 -0700458 unsigned char *data = wacom->data;
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700459 struct input_dev *input = wacom->input;
Ping Cheng3bea7332006-07-13 18:01:36 -0700460 unsigned int t;
461
462 /* general pen packet */
463 if ((data[1] & 0xb8) == 0xa0) {
464 t = (data[6] << 2) | ((data[7] >> 6) & 3);
Aristeu Rozanskica047fe2010-10-10 14:12:33 -0700465 if ((features->type >= INTUOS4S && features->type <= INTUOS4L) ||
Jason Gerecke9fee6192012-04-03 15:47:22 -0700466 (features->type >= INTUOS5S && features->type <= INTUOS5L) ||
Jason Gerecke803296b2011-12-12 00:11:45 -0800467 features->type == WACOM_21UX2 || features->type == WACOM_24HD) {
Ping Cheng6f660f12009-05-08 18:30:33 -0700468 t = (t << 1) | (data[1] & 1);
Aristeu Rozanskica047fe2010-10-10 14:12:33 -0700469 }
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700470 input_report_abs(input, ABS_PRESSURE, t);
471 input_report_abs(input, ABS_TILT_X,
Ping Cheng3bea7332006-07-13 18:01:36 -0700472 ((data[7] << 1) & 0x7e) | (data[8] >> 7));
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700473 input_report_abs(input, ABS_TILT_Y, data[8] & 0x7f);
474 input_report_key(input, BTN_STYLUS, data[1] & 2);
475 input_report_key(input, BTN_STYLUS2, data[1] & 4);
476 input_report_key(input, BTN_TOUCH, t > 10);
Ping Cheng3bea7332006-07-13 18:01:36 -0700477 }
478
479 /* airbrush second packet */
480 if ((data[1] & 0xbc) == 0xb4) {
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700481 input_report_abs(input, ABS_WHEEL,
Ping Cheng3bea7332006-07-13 18:01:36 -0700482 (data[6] << 2) | ((data[7] >> 6) & 3));
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700483 input_report_abs(input, ABS_TILT_X,
Ping Cheng3bea7332006-07-13 18:01:36 -0700484 ((data[7] << 1) & 0x7e) | (data[8] >> 7));
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700485 input_report_abs(input, ABS_TILT_Y, data[8] & 0x7f);
Ping Cheng3bea7332006-07-13 18:01:36 -0700486 }
Ping Cheng3bea7332006-07-13 18:01:36 -0700487}
488
Dmitry Torokhov95dd3b32010-03-19 22:18:15 -0700489static int wacom_intuos_irq(struct wacom_wac *wacom)
Ping Cheng3bea7332006-07-13 18:01:36 -0700490{
Jason Childse33da8a2010-02-17 22:38:31 -0800491 struct wacom_features *features = &wacom->features;
Ping Cheng3bea7332006-07-13 18:01:36 -0700492 unsigned char *data = wacom->data;
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700493 struct input_dev *input = wacom->input;
Ping Cheng3bea7332006-07-13 18:01:36 -0700494 unsigned int t;
Ping Cheng6f660f12009-05-08 18:30:33 -0700495 int idx = 0, result;
Ping Cheng3bea7332006-07-13 18:01:36 -0700496
Dmitry Torokhoveb71d1b2012-05-02 00:13:38 -0700497 if (data[0] != WACOM_REPORT_PENABLED &&
498 data[0] != WACOM_REPORT_INTUOSREAD &&
499 data[0] != WACOM_REPORT_INTUOSWRITE &&
500 data[0] != WACOM_REPORT_INTUOSPAD &&
501 data[0] != WACOM_REPORT_INTUOS5PAD) {
502 dev_dbg(input->dev.parent,
503 "%s: received unknown report #%d\n", __func__, data[0]);
Ping Cheng3bea7332006-07-13 18:01:36 -0700504 return 0;
505 }
506
Ping Cheng3bea7332006-07-13 18:01:36 -0700507 /* tool number */
Jason Childse33da8a2010-02-17 22:38:31 -0800508 if (features->type == INTUOS)
Ping Cheng6f660f12009-05-08 18:30:33 -0700509 idx = data[1] & 0x01;
Ping Cheng3bea7332006-07-13 18:01:36 -0700510
511 /* pad packets. Works as a second tool and is always in prox */
Jason Gereckef860e582012-04-03 15:48:35 -0700512 if (data[0] == WACOM_REPORT_INTUOSPAD || data[0] == WACOM_REPORT_INTUOS5PAD) {
Jason Childse33da8a2010-02-17 22:38:31 -0800513 if (features->type >= INTUOS4S && features->type <= INTUOS4L) {
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700514 input_report_key(input, BTN_0, (data[2] & 0x01));
515 input_report_key(input, BTN_1, (data[3] & 0x01));
516 input_report_key(input, BTN_2, (data[3] & 0x02));
517 input_report_key(input, BTN_3, (data[3] & 0x04));
518 input_report_key(input, BTN_4, (data[3] & 0x08));
519 input_report_key(input, BTN_5, (data[3] & 0x10));
520 input_report_key(input, BTN_6, (data[3] & 0x20));
Ping Cheng6f660f12009-05-08 18:30:33 -0700521 if (data[1] & 0x80) {
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700522 input_report_abs(input, ABS_WHEEL, (data[1] & 0x7f));
Ping Chenga8629522009-06-02 16:59:58 -0700523 } else {
524 /* Out of proximity, clear wheel value. */
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700525 input_report_abs(input, ABS_WHEEL, 0);
Ping Cheng6f660f12009-05-08 18:30:33 -0700526 }
Jason Childse33da8a2010-02-17 22:38:31 -0800527 if (features->type != INTUOS4S) {
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700528 input_report_key(input, BTN_7, (data[3] & 0x40));
529 input_report_key(input, BTN_8, (data[3] & 0x80));
Ping Cheng6f660f12009-05-08 18:30:33 -0700530 }
531 if (data[1] | (data[2] & 0x01) | data[3]) {
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700532 input_report_key(input, wacom->tool[1], 1);
533 input_report_abs(input, ABS_MISC, PAD_DEVICE_ID);
Ping Cheng6f660f12009-05-08 18:30:33 -0700534 } else {
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700535 input_report_key(input, wacom->tool[1], 0);
536 input_report_abs(input, ABS_MISC, 0);
Ping Cheng6f660f12009-05-08 18:30:33 -0700537 }
Jason Gerecke803296b2011-12-12 00:11:45 -0800538 } else if (features->type == WACOM_24HD) {
539 input_report_key(input, BTN_0, (data[6] & 0x01));
540 input_report_key(input, BTN_1, (data[6] & 0x02));
541 input_report_key(input, BTN_2, (data[6] & 0x04));
542 input_report_key(input, BTN_3, (data[6] & 0x08));
543 input_report_key(input, BTN_4, (data[6] & 0x10));
544 input_report_key(input, BTN_5, (data[6] & 0x20));
545 input_report_key(input, BTN_6, (data[6] & 0x40));
546 input_report_key(input, BTN_7, (data[6] & 0x80));
547 input_report_key(input, BTN_8, (data[8] & 0x01));
548 input_report_key(input, BTN_9, (data[8] & 0x02));
549 input_report_key(input, BTN_A, (data[8] & 0x04));
550 input_report_key(input, BTN_B, (data[8] & 0x08));
551 input_report_key(input, BTN_C, (data[8] & 0x10));
552 input_report_key(input, BTN_X, (data[8] & 0x20));
553 input_report_key(input, BTN_Y, (data[8] & 0x40));
554 input_report_key(input, BTN_Z, (data[8] & 0x80));
555
556 /*
557 * Three "buttons" are available on the 24HD which are
558 * physically implemented as a touchstrip. Each button
559 * is approximately 3 bits wide with a 2 bit spacing.
560 * The raw touchstrip bits are stored at:
561 * ((data[3] & 0x1f) << 8) | data[4])
562 */
563 input_report_key(input, KEY_PROG1, data[4] & 0x07);
564 input_report_key(input, KEY_PROG2, data[4] & 0xE0);
565 input_report_key(input, KEY_PROG3, data[3] & 0x1C);
566
567 if (data[1] & 0x80) {
568 input_report_abs(input, ABS_WHEEL, (data[1] & 0x7f));
569 } else {
570 /* Out of proximity, clear wheel value. */
571 input_report_abs(input, ABS_WHEEL, 0);
572 }
573
574 if (data[2] & 0x80) {
575 input_report_abs(input, ABS_THROTTLE, (data[2] & 0x7f));
576 } else {
577 /* Out of proximity, clear second wheel value. */
578 input_report_abs(input, ABS_THROTTLE, 0);
579 }
580
581 if (data[1] | data[2] | (data[3] & 0x1f) | data[4] | data[6] | data[8]) {
582 input_report_key(input, wacom->tool[1], 1);
583 input_report_abs(input, ABS_MISC, PAD_DEVICE_ID);
584 } else {
585 input_report_key(input, wacom->tool[1], 0);
586 input_report_abs(input, ABS_MISC, 0);
587 }
Jason Gereckef860e582012-04-03 15:48:35 -0700588 } else if (features->type >= INTUOS5S && features->type <= INTUOS5L) {
589 int i;
590
591 /* Touch ring mode switch has no capacitive sensor */
592 input_report_key(input, BTN_0, (data[3] & 0x01));
593
594 /*
595 * ExpressKeys on Intuos5 have a capacitive sensor in
596 * addition to the mechanical switch. Switch data is
597 * stored in data[4], capacitive data in data[5].
598 */
599 for (i = 0; i < 8; i++)
600 input_report_key(input, BTN_1 + i, data[4] & (1 << i));
601
602 if (data[2] & 0x80) {
603 input_report_abs(input, ABS_WHEEL, (data[2] & 0x7f));
604 } else {
605 /* Out of proximity, clear wheel value. */
606 input_report_abs(input, ABS_WHEEL, 0);
607 }
608
609 if (data[2] | (data[3] & 0x01) | data[4]) {
610 input_report_key(input, wacom->tool[1], 1);
611 input_report_abs(input, ABS_MISC, PAD_DEVICE_ID);
612 } else {
613 input_report_key(input, wacom->tool[1], 0);
614 input_report_abs(input, ABS_MISC, 0);
615 }
Ping Cheng6f660f12009-05-08 18:30:33 -0700616 } else {
Ping Cheng3a4b4aa2010-06-03 22:10:21 -0700617 if (features->type == WACOM_21UX2) {
618 input_report_key(input, BTN_0, (data[5] & 0x01));
619 input_report_key(input, BTN_1, (data[6] & 0x01));
620 input_report_key(input, BTN_2, (data[6] & 0x02));
621 input_report_key(input, BTN_3, (data[6] & 0x04));
622 input_report_key(input, BTN_4, (data[6] & 0x08));
623 input_report_key(input, BTN_5, (data[6] & 0x10));
624 input_report_key(input, BTN_6, (data[6] & 0x20));
625 input_report_key(input, BTN_7, (data[6] & 0x40));
626 input_report_key(input, BTN_8, (data[6] & 0x80));
627 input_report_key(input, BTN_9, (data[7] & 0x01));
628 input_report_key(input, BTN_A, (data[8] & 0x01));
629 input_report_key(input, BTN_B, (data[8] & 0x02));
630 input_report_key(input, BTN_C, (data[8] & 0x04));
631 input_report_key(input, BTN_X, (data[8] & 0x08));
632 input_report_key(input, BTN_Y, (data[8] & 0x10));
633 input_report_key(input, BTN_Z, (data[8] & 0x20));
634 input_report_key(input, BTN_BASE, (data[8] & 0x40));
635 input_report_key(input, BTN_BASE2, (data[8] & 0x80));
636 } else {
637 input_report_key(input, BTN_0, (data[5] & 0x01));
638 input_report_key(input, BTN_1, (data[5] & 0x02));
639 input_report_key(input, BTN_2, (data[5] & 0x04));
640 input_report_key(input, BTN_3, (data[5] & 0x08));
641 input_report_key(input, BTN_4, (data[6] & 0x01));
642 input_report_key(input, BTN_5, (data[6] & 0x02));
643 input_report_key(input, BTN_6, (data[6] & 0x04));
644 input_report_key(input, BTN_7, (data[6] & 0x08));
645 input_report_key(input, BTN_8, (data[5] & 0x10));
646 input_report_key(input, BTN_9, (data[6] & 0x10));
647 }
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700648 input_report_abs(input, ABS_RX, ((data[1] & 0x1f) << 8) | data[2]);
649 input_report_abs(input, ABS_RY, ((data[3] & 0x1f) << 8) | data[4]);
Ping Cheng3bea7332006-07-13 18:01:36 -0700650
Ping Cheng493630b2010-06-22 11:21:34 -0700651 if ((data[5] & 0x1f) | data[6] | (data[1] & 0x1f) |
Ping Cheng3a4b4aa2010-06-03 22:10:21 -0700652 data[2] | (data[3] & 0x1f) | data[4] | data[8] |
653 (data[7] & 0x01)) {
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700654 input_report_key(input, wacom->tool[1], 1);
655 input_report_abs(input, ABS_MISC, PAD_DEVICE_ID);
Ping Cheng6f660f12009-05-08 18:30:33 -0700656 } else {
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700657 input_report_key(input, wacom->tool[1], 0);
658 input_report_abs(input, ABS_MISC, 0);
Ping Cheng6f660f12009-05-08 18:30:33 -0700659 }
660 }
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700661 input_event(input, EV_MSC, MSC_SERIAL, 0xffffffff);
Ping Cheng3bea7332006-07-13 18:01:36 -0700662 return 1;
663 }
664
665 /* process in/out prox events */
Dmitry Torokhov95dd3b32010-03-19 22:18:15 -0700666 result = wacom_intuos_inout(wacom);
Ping Cheng3bea7332006-07-13 18:01:36 -0700667 if (result)
Dmitry Torokhov73a97f42010-03-19 22:18:15 -0700668 return result - 1;
Ping Cheng3bea7332006-07-13 18:01:36 -0700669
Ping Cheng6f660f12009-05-08 18:30:33 -0700670 /* don't proceed if we don't know the ID */
671 if (!wacom->id[idx])
672 return 0;
673
674 /* Only large Intuos support Lense Cursor */
Jason Childse33da8a2010-02-17 22:38:31 -0800675 if (wacom->tool[idx] == BTN_TOOL_LENS &&
676 (features->type == INTUOS3 ||
677 features->type == INTUOS3S ||
678 features->type == INTUOS4 ||
Jason Gerecke9fee6192012-04-03 15:47:22 -0700679 features->type == INTUOS4S ||
680 features->type == INTUOS5 ||
681 features->type == INTUOS5S)) {
Jason Childse33da8a2010-02-17 22:38:31 -0800682
Ping Cheng80d4e8e2007-02-23 12:22:48 -0800683 return 0;
Jason Childse33da8a2010-02-17 22:38:31 -0800684 }
Ping Cheng80d4e8e2007-02-23 12:22:48 -0800685
Ping Cheng3bea7332006-07-13 18:01:36 -0700686 /* Cintiq doesn't send data when RDY bit isn't set */
Jason Childse33da8a2010-02-17 22:38:31 -0800687 if (features->type == CINTIQ && !(data[1] & 0x40))
Ping Cheng3bea7332006-07-13 18:01:36 -0700688 return 0;
689
Jason Childse33da8a2010-02-17 22:38:31 -0800690 if (features->type >= INTUOS3S) {
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700691 input_report_abs(input, ABS_X, (data[2] << 9) | (data[3] << 1) | ((data[9] >> 1) & 1));
692 input_report_abs(input, ABS_Y, (data[4] << 9) | (data[5] << 1) | (data[9] & 1));
693 input_report_abs(input, ABS_DISTANCE, ((data[9] >> 2) & 0x3f));
Ping Cheng3bea7332006-07-13 18:01:36 -0700694 } else {
Dmitry Torokhov252f7762010-03-19 22:33:38 -0700695 input_report_abs(input, ABS_X, be16_to_cpup((__be16 *)&data[2]));
696 input_report_abs(input, ABS_Y, be16_to_cpup((__be16 *)&data[4]));
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700697 input_report_abs(input, ABS_DISTANCE, ((data[9] >> 3) & 0x1f));
Ping Cheng3bea7332006-07-13 18:01:36 -0700698 }
699
700 /* process general packets */
Dmitry Torokhov95dd3b32010-03-19 22:18:15 -0700701 wacom_intuos_general(wacom);
Ping Cheng3bea7332006-07-13 18:01:36 -0700702
Ping Cheng6f660f12009-05-08 18:30:33 -0700703 /* 4D mouse, 2D mouse, marker pen rotation, tilt mouse, or Lens cursor packets */
704 if ((data[1] & 0xbc) == 0xa8 || (data[1] & 0xbe) == 0xb0 || (data[1] & 0xbc) == 0xac) {
Ping Cheng3bea7332006-07-13 18:01:36 -0700705
706 if (data[1] & 0x02) {
707 /* Rotation packet */
Jason Childse33da8a2010-02-17 22:38:31 -0800708 if (features->type >= INTUOS3S) {
Ping Cheng0e1763f2008-03-13 16:46:46 -0400709 /* I3 marker pen rotation */
Ping Cheng3bea7332006-07-13 18:01:36 -0700710 t = (data[6] << 3) | ((data[7] >> 5) & 7);
711 t = (data[7] & 0x20) ? ((t > 900) ? ((t-1) / 2 - 1350) :
712 ((t-1) / 2 + 450)) : (450 - t / 2) ;
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700713 input_report_abs(input, ABS_Z, t);
Ping Cheng3bea7332006-07-13 18:01:36 -0700714 } else {
715 /* 4D mouse rotation packet */
716 t = (data[6] << 3) | ((data[7] >> 5) & 7);
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700717 input_report_abs(input, ABS_RZ, (data[7] & 0x20) ?
Ping Cheng3bea7332006-07-13 18:01:36 -0700718 ((t - 1) / 2) : -t / 2);
719 }
720
Jason Childse33da8a2010-02-17 22:38:31 -0800721 } else if (!(data[1] & 0x10) && features->type < INTUOS3S) {
Ping Cheng3bea7332006-07-13 18:01:36 -0700722 /* 4D mouse packet */
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700723 input_report_key(input, BTN_LEFT, data[8] & 0x01);
724 input_report_key(input, BTN_MIDDLE, data[8] & 0x02);
725 input_report_key(input, BTN_RIGHT, data[8] & 0x04);
Ping Cheng3bea7332006-07-13 18:01:36 -0700726
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700727 input_report_key(input, BTN_SIDE, data[8] & 0x20);
728 input_report_key(input, BTN_EXTRA, data[8] & 0x10);
Ping Cheng3bea7332006-07-13 18:01:36 -0700729 t = (data[6] << 2) | ((data[7] >> 6) & 3);
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700730 input_report_abs(input, ABS_THROTTLE, (data[8] & 0x08) ? -t : t);
Ping Cheng3bea7332006-07-13 18:01:36 -0700731
732 } else if (wacom->tool[idx] == BTN_TOOL_MOUSE) {
Ping Cheng6f660f12009-05-08 18:30:33 -0700733 /* I4 mouse */
Jason Gerecke9fee6192012-04-03 15:47:22 -0700734 if ((features->type >= INTUOS4S && features->type <= INTUOS4L) ||
735 (features->type >= INTUOS5S && features->type <= INTUOS5L)) {
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700736 input_report_key(input, BTN_LEFT, data[6] & 0x01);
737 input_report_key(input, BTN_MIDDLE, data[6] & 0x02);
738 input_report_key(input, BTN_RIGHT, data[6] & 0x04);
739 input_report_rel(input, REL_WHEEL, ((data[7] & 0x80) >> 7)
Ping Cheng6f660f12009-05-08 18:30:33 -0700740 - ((data[7] & 0x40) >> 6));
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700741 input_report_key(input, BTN_SIDE, data[6] & 0x08);
742 input_report_key(input, BTN_EXTRA, data[6] & 0x10);
Ping Cheng6f660f12009-05-08 18:30:33 -0700743
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700744 input_report_abs(input, ABS_TILT_X,
Ping Cheng6f660f12009-05-08 18:30:33 -0700745 ((data[7] << 1) & 0x7e) | (data[8] >> 7));
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700746 input_report_abs(input, ABS_TILT_Y, data[8] & 0x7f);
Ping Cheng6f660f12009-05-08 18:30:33 -0700747 } else {
748 /* 2D mouse packet */
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700749 input_report_key(input, BTN_LEFT, data[8] & 0x04);
750 input_report_key(input, BTN_MIDDLE, data[8] & 0x08);
751 input_report_key(input, BTN_RIGHT, data[8] & 0x10);
752 input_report_rel(input, REL_WHEEL, (data[8] & 0x01)
Ping Cheng3bea7332006-07-13 18:01:36 -0700753 - ((data[8] & 0x02) >> 1));
754
Ping Cheng6f660f12009-05-08 18:30:33 -0700755 /* I3 2D mouse side buttons */
Jason Childse33da8a2010-02-17 22:38:31 -0800756 if (features->type >= INTUOS3S && features->type <= INTUOS3L) {
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700757 input_report_key(input, BTN_SIDE, data[8] & 0x40);
758 input_report_key(input, BTN_EXTRA, data[8] & 0x20);
Ping Cheng6f660f12009-05-08 18:30:33 -0700759 }
Ping Cheng3bea7332006-07-13 18:01:36 -0700760 }
Jason Childse33da8a2010-02-17 22:38:31 -0800761 } else if ((features->type < INTUOS3S || features->type == INTUOS3L ||
Jason Gerecke9fee6192012-04-03 15:47:22 -0700762 features->type == INTUOS4L || features->type == INTUOS5L) &&
Ping Cheng6f660f12009-05-08 18:30:33 -0700763 wacom->tool[idx] == BTN_TOOL_LENS) {
Ping Cheng3bea7332006-07-13 18:01:36 -0700764 /* Lens cursor packets */
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700765 input_report_key(input, BTN_LEFT, data[8] & 0x01);
766 input_report_key(input, BTN_MIDDLE, data[8] & 0x02);
767 input_report_key(input, BTN_RIGHT, data[8] & 0x04);
768 input_report_key(input, BTN_SIDE, data[8] & 0x10);
769 input_report_key(input, BTN_EXTRA, data[8] & 0x08);
Ping Cheng3bea7332006-07-13 18:01:36 -0700770 }
771 }
772
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700773 input_report_abs(input, ABS_MISC, wacom->id[idx]); /* report tool id */
774 input_report_key(input, wacom->tool[idx], 1);
775 input_event(input, EV_MSC, MSC_SERIAL, wacom->serial[idx]);
Ping Cheng3bea7332006-07-13 18:01:36 -0700776 return 1;
777}
778
Ping Cheng19635182012-04-29 21:09:18 -0700779static int find_slot_from_contactid(struct wacom_wac *wacom, int contactid)
780{
781 int touch_max = wacom->features.touch_max;
782 int i;
783
784 if (!wacom->slots)
785 return -1;
786
787 for (i = 0; i < touch_max; ++i) {
788 if (wacom->slots[i] == contactid)
789 return i;
790 }
791 for (i = 0; i < touch_max; ++i) {
792 if (wacom->slots[i] == -1)
793 return i;
794 }
795 return -1;
796}
797
798static int wacom_mt_touch(struct wacom_wac *wacom)
799{
800 struct input_dev *input = wacom->input;
801 char *data = wacom->data;
802 int i;
803 int current_num_contacts = data[2];
804 int contacts_to_send = 0;
805
806 /*
807 * First packet resets the counter since only the first
808 * packet in series will have non-zero current_num_contacts.
809 */
810 if (current_num_contacts)
811 wacom->num_contacts_left = current_num_contacts;
812
813 /* There are at most 5 contacts per packet */
814 contacts_to_send = min(5, wacom->num_contacts_left);
815
816 for (i = 0; i < contacts_to_send; i++) {
817 int offset = (WACOM_BYTES_PER_MT_PACKET * i) + 3;
818 bool touch = data[offset] & 0x1;
819 int id = le16_to_cpup((__le16 *)&data[offset + 1]);
820 int slot = find_slot_from_contactid(wacom, id);
821
822 if (slot < 0)
823 continue;
824
825 input_mt_slot(input, slot);
826 input_mt_report_slot_state(input, MT_TOOL_FINGER, touch);
827 if (touch) {
828 int x = le16_to_cpup((__le16 *)&data[offset + 7]);
829 int y = le16_to_cpup((__le16 *)&data[offset + 9]);
830 input_report_abs(input, ABS_MT_POSITION_X, x);
831 input_report_abs(input, ABS_MT_POSITION_Y, y);
832 }
833 wacom->slots[slot] = touch ? id : -1;
834 }
835
836 input_mt_report_pointer_emulation(input, true);
837
838 wacom->num_contacts_left -= contacts_to_send;
839 if (wacom->num_contacts_left < 0)
840 wacom->num_contacts_left = 0;
841
842 return 1;
843}
844
Ping Cheng84eb5aa2011-03-12 20:35:18 -0800845static int wacom_tpc_mt_touch(struct wacom_wac *wacom)
846{
847 struct input_dev *input = wacom->input;
848 unsigned char *data = wacom->data;
849 int contact_with_no_pen_down_count = 0;
850 int i;
851
852 for (i = 0; i < 2; i++) {
853 int p = data[1] & (1 << i);
854 bool touch = p && !wacom->shared->stylus_in_proximity;
855
856 input_mt_slot(input, i);
857 input_mt_report_slot_state(input, MT_TOOL_FINGER, touch);
858 if (touch) {
859 int x = le16_to_cpup((__le16 *)&data[i * 2 + 2]) & 0x7fff;
860 int y = le16_to_cpup((__le16 *)&data[i * 2 + 6]) & 0x7fff;
861
862 input_report_abs(input, ABS_MT_POSITION_X, x);
863 input_report_abs(input, ABS_MT_POSITION_Y, y);
864 contact_with_no_pen_down_count++;
865 }
866 }
867
868 /* keep touch state for pen event */
869 wacom->shared->touch_down = (contact_with_no_pen_down_count > 0);
870
871 input_mt_report_pointer_emulation(input, true);
872
873 return 1;
874}
875
Ping Chenga43c7c52011-03-12 20:34:42 -0800876static int wacom_tpc_single_touch(struct wacom_wac *wacom, size_t len)
Ping Chengec67bbe2009-12-15 00:35:24 -0800877{
878 char *data = wacom->data;
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700879 struct input_dev *input = wacom->input;
Ping Chenga43c7c52011-03-12 20:34:42 -0800880 bool prox;
881 int x = 0, y = 0;
Ping Chengec67bbe2009-12-15 00:35:24 -0800882
Ping Cheng19635182012-04-29 21:09:18 -0700883 if (wacom->features.touch_max > 1 || len > WACOM_PKGLEN_TPC2FG)
884 return 0;
885
Ping Chenga43c7c52011-03-12 20:34:42 -0800886 if (!wacom->shared->stylus_in_proximity) {
887 if (len == WACOM_PKGLEN_TPC1FG) {
888 prox = data[0] & 0x01;
889 x = get_unaligned_le16(&data[1]);
890 y = get_unaligned_le16(&data[3]);
Ping Chengac173832012-06-12 00:15:06 -0700891 } else {
Ping Chenga43c7c52011-03-12 20:34:42 -0800892 prox = data[1] & 0x01;
893 x = le16_to_cpup((__le16 *)&data[2]);
894 y = le16_to_cpup((__le16 *)&data[4]);
Ping Chengec67bbe2009-12-15 00:35:24 -0800895 }
Ping Chenga43c7c52011-03-12 20:34:42 -0800896 } else
897 /* force touch out when pen is in prox */
898 prox = 0;
899
900 if (prox) {
901 input_report_abs(input, ABS_X, x);
902 input_report_abs(input, ABS_Y, y);
Ping Chengec67bbe2009-12-15 00:35:24 -0800903 }
Ping Chenga43c7c52011-03-12 20:34:42 -0800904 input_report_key(input, BTN_TOUCH, prox);
905
906 /* keep touch state for pen events */
907 wacom->shared->touch_down = prox;
908
909 return 1;
Ping Chengec67bbe2009-12-15 00:35:24 -0800910}
911
Ping Cheng8aa9a9a2011-03-12 20:34:11 -0800912static int wacom_tpc_pen(struct wacom_wac *wacom)
Ping Cheng545f4e92008-11-24 11:44:27 -0500913{
Jason Childse33da8a2010-02-17 22:38:31 -0800914 struct wacom_features *features = &wacom->features;
Ping Cheng545f4e92008-11-24 11:44:27 -0500915 char *data = wacom->data;
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700916 struct input_dev *input = wacom->input;
Ping Chenga43c7c52011-03-12 20:34:42 -0800917 int pressure;
918 bool prox = data[1] & 0x20;
Ping Cheng8aa9a9a2011-03-12 20:34:11 -0800919
Ping Chenga43c7c52011-03-12 20:34:42 -0800920 if (!wacom->shared->stylus_in_proximity) /* first in prox */
Ping Cheng8aa9a9a2011-03-12 20:34:11 -0800921 /* Going into proximity select tool */
922 wacom->tool[0] = (data[1] & 0x0c) ? BTN_TOOL_RUBBER : BTN_TOOL_PEN;
Ping Cheng8aa9a9a2011-03-12 20:34:11 -0800923
Ping Chenga43c7c52011-03-12 20:34:42 -0800924 /* keep pen state for touch events */
925 wacom->shared->stylus_in_proximity = prox;
Ping Cheng8aa9a9a2011-03-12 20:34:11 -0800926
Ping Chenga43c7c52011-03-12 20:34:42 -0800927 /* send pen events only when touch is up or forced out */
928 if (!wacom->shared->touch_down) {
929 input_report_key(input, BTN_STYLUS, data[1] & 0x02);
930 input_report_key(input, BTN_STYLUS2, data[1] & 0x10);
931 input_report_abs(input, ABS_X, le16_to_cpup((__le16 *)&data[2]));
932 input_report_abs(input, ABS_Y, le16_to_cpup((__le16 *)&data[4]));
933 pressure = ((data[7] & 0x01) << 8) | data[6];
934 if (pressure < 0)
935 pressure = features->pressure_max + pressure + 1;
936 input_report_abs(input, ABS_PRESSURE, pressure);
937 input_report_key(input, BTN_TOUCH, data[1] & 0x05);
938 input_report_key(input, wacom->tool[0], prox);
939 return 1;
940 }
941
942 return 0;
Ping Cheng8aa9a9a2011-03-12 20:34:11 -0800943}
944
945static int wacom_tpc_irq(struct wacom_wac *wacom, size_t len)
946{
947 char *data = wacom->data;
Ping Cheng545f4e92008-11-24 11:44:27 -0500948
Dmitry Torokhoveb71d1b2012-05-02 00:13:38 -0700949 dev_dbg(wacom->input->dev.parent,
950 "%s: received report #%d\n", __func__, data[0]);
Ping Cheng545f4e92008-11-24 11:44:27 -0500951
Ping Cheng31175a82012-01-31 00:07:33 -0800952 switch (len) {
953 case WACOM_PKGLEN_TPC1FG:
Ping Cheng19635182012-04-29 21:09:18 -0700954 return wacom_tpc_single_touch(wacom, len);
Ping Cheng31175a82012-01-31 00:07:33 -0800955
956 case WACOM_PKGLEN_TPC2FG:
Ping Cheng19635182012-04-29 21:09:18 -0700957 return wacom_tpc_mt_touch(wacom);
Ping Cheng31175a82012-01-31 00:07:33 -0800958
959 default:
960 switch (data[0]) {
961 case WACOM_REPORT_TPC1FG:
962 case WACOM_REPORT_TPCHID:
963 case WACOM_REPORT_TPCST:
Ping Chengac173832012-06-12 00:15:06 -0700964 case WACOM_REPORT_TPC1FGE:
Ping Cheng31175a82012-01-31 00:07:33 -0800965 return wacom_tpc_single_touch(wacom, len);
966
Ping Cheng19635182012-04-29 21:09:18 -0700967 case WACOM_REPORT_TPCMT:
968 return wacom_mt_touch(wacom);
969
Ping Cheng31175a82012-01-31 00:07:33 -0800970 case WACOM_REPORT_PENABLED:
971 return wacom_tpc_pen(wacom);
972 }
973 }
Ping Cheng545f4e92008-11-24 11:44:27 -0500974
Ping Cheng8aa9a9a2011-03-12 20:34:11 -0800975 return 0;
Ping Cheng545f4e92008-11-24 11:44:27 -0500976}
977
Chris Bagwelle1d38e42010-09-12 00:09:27 -0700978static int wacom_bpt_touch(struct wacom_wac *wacom)
Henrik Rydbergcb734c02010-09-05 12:53:16 -0700979{
Henrik Rydbergf4ccbef2010-09-05 12:57:13 -0700980 struct wacom_features *features = &wacom->features;
Henrik Rydbergcb734c02010-09-05 12:53:16 -0700981 struct input_dev *input = wacom->input;
982 unsigned char *data = wacom->data;
Henrik Rydbergcb734c02010-09-05 12:53:16 -0700983 int i;
984
Chris Bagwell5a6c8652011-11-07 19:52:42 -0800985 if (data[0] != 0x02)
986 return 0;
987
Henrik Rydbergcb734c02010-09-05 12:53:16 -0700988 for (i = 0; i < 2; i++) {
Chris Bagwell8f906862011-09-09 13:38:10 -0700989 int offset = (data[1] & 0x80) ? (8 * i) : (9 * i);
990 bool touch = data[offset + 3] & 0x80;
Henrik Rydbergc5f4dec2010-12-15 13:50:34 +0100991
Chris Bagwell33d5f712010-09-12 00:12:28 -0700992 /*
993 * Touch events need to be disabled while stylus is
994 * in proximity because user's hand is resting on touchpad
995 * and sending unwanted events. User expects tablet buttons
996 * to continue working though.
997 */
Chris Bagwell8f906862011-09-09 13:38:10 -0700998 touch = touch && !wacom->shared->stylus_in_proximity;
999
1000 input_mt_slot(input, i);
1001 input_mt_report_slot_state(input, MT_TOOL_FINGER, touch);
Henrik Rydbergc5f4dec2010-12-15 13:50:34 +01001002 if (touch) {
Chris Bagwell8f906862011-09-09 13:38:10 -07001003 int x = get_unaligned_be16(&data[offset + 3]) & 0x7ff;
1004 int y = get_unaligned_be16(&data[offset + 5]) & 0x7ff;
Henrik Rydbergf4ccbef2010-09-05 12:57:13 -07001005 if (features->quirks & WACOM_QUIRK_BBTOUCH_LOWRES) {
1006 x <<= 5;
1007 y <<= 5;
1008 }
Henrik Rydbergcb734c02010-09-05 12:53:16 -07001009 input_report_abs(input, ABS_MT_POSITION_X, x);
1010 input_report_abs(input, ABS_MT_POSITION_Y, y);
Henrik Rydbergcb734c02010-09-05 12:53:16 -07001011 }
Henrik Rydbergcb734c02010-09-05 12:53:16 -07001012 }
1013
Henrik Rydbergc5f4dec2010-12-15 13:50:34 +01001014 input_mt_report_pointer_emulation(input, true);
Henrik Rydbergcb734c02010-09-05 12:53:16 -07001015
1016 input_report_key(input, BTN_LEFT, (data[1] & 0x08) != 0);
1017 input_report_key(input, BTN_FORWARD, (data[1] & 0x04) != 0);
1018 input_report_key(input, BTN_BACK, (data[1] & 0x02) != 0);
1019 input_report_key(input, BTN_RIGHT, (data[1] & 0x01) != 0);
1020
1021 input_sync(input);
1022
1023 return 0;
1024}
1025
Chris Bagwell73149ab2011-10-26 22:34:21 -07001026static void wacom_bpt3_touch_msg(struct wacom_wac *wacom, unsigned char *data)
1027{
1028 struct input_dev *input = wacom->input;
1029 int slot_id = data[0] - 2; /* data[0] is between 2 and 17 */
1030 bool touch = data[1] & 0x80;
1031
1032 touch = touch && !wacom->shared->stylus_in_proximity;
1033
1034 input_mt_slot(input, slot_id);
1035 input_mt_report_slot_state(input, MT_TOOL_FINGER, touch);
1036
1037 if (touch) {
1038 int x = (data[2] << 4) | (data[4] >> 4);
1039 int y = (data[3] << 4) | (data[4] & 0x0f);
1040 int w = data[6];
1041
1042 input_report_abs(input, ABS_MT_POSITION_X, x);
1043 input_report_abs(input, ABS_MT_POSITION_Y, y);
1044 input_report_abs(input, ABS_MT_TOUCH_MAJOR, w);
1045 }
1046}
1047
1048static void wacom_bpt3_button_msg(struct wacom_wac *wacom, unsigned char *data)
1049{
1050 struct input_dev *input = wacom->input;
1051
1052 input_report_key(input, BTN_LEFT, (data[1] & 0x08) != 0);
1053 input_report_key(input, BTN_FORWARD, (data[1] & 0x04) != 0);
1054 input_report_key(input, BTN_BACK, (data[1] & 0x02) != 0);
1055 input_report_key(input, BTN_RIGHT, (data[1] & 0x01) != 0);
1056}
1057
1058static int wacom_bpt3_touch(struct wacom_wac *wacom)
1059{
1060 struct input_dev *input = wacom->input;
1061 unsigned char *data = wacom->data;
Jason Gerecke19d57d32012-03-06 10:19:19 -08001062 int count = data[1] & 0x07;
Chris Bagwell73149ab2011-10-26 22:34:21 -07001063 int i;
1064
Chris Bagwell5a6c8652011-11-07 19:52:42 -08001065 if (data[0] != 0x02)
1066 return 0;
1067
Chris Bagwell73149ab2011-10-26 22:34:21 -07001068 /* data has up to 7 fixed sized 8-byte messages starting at data[2] */
1069 for (i = 0; i < count; i++) {
1070 int offset = (8 * i) + 2;
1071 int msg_id = data[offset];
1072
1073 if (msg_id >= 2 && msg_id <= 17)
1074 wacom_bpt3_touch_msg(wacom, data + offset);
1075 else if (msg_id == 128)
1076 wacom_bpt3_button_msg(wacom, data + offset);
1077
1078 }
1079
1080 input_mt_report_pointer_emulation(input, true);
1081
1082 input_sync(input);
1083
1084 return 0;
1085}
1086
Chris Bagwell2aaacb12010-09-12 00:11:35 -07001087static int wacom_bpt_pen(struct wacom_wac *wacom)
1088{
1089 struct input_dev *input = wacom->input;
1090 unsigned char *data = wacom->data;
1091 int prox = 0, x = 0, y = 0, p = 0, d = 0, pen = 0, btn1 = 0, btn2 = 0;
1092
Chris Bagwell5a6c8652011-11-07 19:52:42 -08001093 if (data[0] != 0x02)
1094 return 0;
1095
Chris Bagwellc5981412011-10-26 22:28:34 -07001096 prox = (data[1] & 0x20) == 0x20;
Chris Bagwell2aaacb12010-09-12 00:11:35 -07001097
1098 /*
1099 * All reports shared between PEN and RUBBER tool must be
1100 * forced to a known starting value (zero) when transitioning to
1101 * out-of-prox.
1102 *
1103 * If not reset then, to userspace, it will look like lost events
1104 * if new tool comes in-prox with same values as previous tool sent.
1105 *
1106 * Hardware does report zero in most out-of-prox cases but not all.
1107 */
1108 if (prox) {
1109 if (!wacom->shared->stylus_in_proximity) {
1110 if (data[1] & 0x08) {
1111 wacom->tool[0] = BTN_TOOL_RUBBER;
1112 wacom->id[0] = ERASER_DEVICE_ID;
1113 } else {
1114 wacom->tool[0] = BTN_TOOL_PEN;
1115 wacom->id[0] = STYLUS_DEVICE_ID;
1116 }
1117 wacom->shared->stylus_in_proximity = true;
1118 }
1119 x = le16_to_cpup((__le16 *)&data[2]);
1120 y = le16_to_cpup((__le16 *)&data[4]);
1121 p = le16_to_cpup((__le16 *)&data[6]);
Chris Bagwellc18c2ce2011-10-10 08:52:13 -07001122 /*
1123 * Convert distance from out prox to distance from tablet.
1124 * distance will be greater than distance_max once
1125 * touching and applying pressure; do not report negative
1126 * distance.
1127 */
1128 if (data[8] <= wacom->features.distance_max)
1129 d = wacom->features.distance_max - data[8];
1130
Chris Bagwell2aaacb12010-09-12 00:11:35 -07001131 pen = data[1] & 0x01;
1132 btn1 = data[1] & 0x02;
1133 btn2 = data[1] & 0x04;
1134 }
1135
1136 input_report_key(input, BTN_TOUCH, pen);
1137 input_report_key(input, BTN_STYLUS, btn1);
1138 input_report_key(input, BTN_STYLUS2, btn2);
1139
1140 input_report_abs(input, ABS_X, x);
1141 input_report_abs(input, ABS_Y, y);
1142 input_report_abs(input, ABS_PRESSURE, p);
1143 input_report_abs(input, ABS_DISTANCE, d);
1144
1145 if (!prox) {
1146 wacom->id[0] = 0;
1147 wacom->shared->stylus_in_proximity = false;
1148 }
1149
1150 input_report_key(input, wacom->tool[0], prox); /* PEN or RUBBER */
1151 input_report_abs(input, ABS_MISC, wacom->id[0]); /* TOOL ID */
1152
1153 return 1;
1154}
1155
Chris Bagwelle1d38e42010-09-12 00:09:27 -07001156static int wacom_bpt_irq(struct wacom_wac *wacom, size_t len)
1157{
1158 if (len == WACOM_PKGLEN_BBTOUCH)
1159 return wacom_bpt_touch(wacom);
Chris Bagwell73149ab2011-10-26 22:34:21 -07001160 else if (len == WACOM_PKGLEN_BBTOUCH3)
1161 return wacom_bpt3_touch(wacom);
1162 else if (len == WACOM_PKGLEN_BBFUN || len == WACOM_PKGLEN_BBPEN)
Chris Bagwell2aaacb12010-09-12 00:11:35 -07001163 return wacom_bpt_pen(wacom);
Chris Bagwelle1d38e42010-09-12 00:09:27 -07001164
1165 return 0;
1166}
1167
Chris Bagwelld3825d52012-03-25 23:26:11 -07001168static int wacom_wireless_irq(struct wacom_wac *wacom, size_t len)
1169{
Chris Bagwell16bf2882012-03-25 23:26:20 -07001170 unsigned char *data = wacom->data;
1171 int connected;
1172
1173 if (len != WACOM_PKGLEN_WIRELESS || data[0] != 0x80)
Chris Bagwelld3825d52012-03-25 23:26:11 -07001174 return 0;
1175
Chris Bagwell16bf2882012-03-25 23:26:20 -07001176 connected = data[1] & 0x01;
1177 if (connected) {
Chris Bagwella1d552c2012-03-25 23:26:30 -07001178 int pid, battery;
Chris Bagwell16bf2882012-03-25 23:26:20 -07001179
1180 pid = get_unaligned_be16(&data[6]);
Chris Bagwella1d552c2012-03-25 23:26:30 -07001181 battery = data[5] & 0x3f;
Chris Bagwell16bf2882012-03-25 23:26:20 -07001182 if (wacom->pid != pid) {
1183 wacom->pid = pid;
1184 wacom_schedule_work(wacom);
1185 }
Chris Bagwella1d552c2012-03-25 23:26:30 -07001186 wacom->battery_capacity = battery;
Chris Bagwell16bf2882012-03-25 23:26:20 -07001187 } else if (wacom->pid != 0) {
1188 /* disconnected while previously connected */
1189 wacom->pid = 0;
1190 wacom_schedule_work(wacom);
Chris Bagwella1d552c2012-03-25 23:26:30 -07001191 wacom->battery_capacity = 0;
Chris Bagwell16bf2882012-03-25 23:26:20 -07001192 }
1193
Chris Bagwelld3825d52012-03-25 23:26:11 -07001194 return 0;
1195}
1196
Dmitry Torokhov95dd3b32010-03-19 22:18:15 -07001197void wacom_wac_irq(struct wacom_wac *wacom_wac, size_t len)
Ping Cheng3bea7332006-07-13 18:01:36 -07001198{
Dmitry Torokhov95dd3b32010-03-19 22:18:15 -07001199 bool sync;
1200
Jason Childse33da8a2010-02-17 22:38:31 -08001201 switch (wacom_wac->features.type) {
Dmitry Torokhov73a97f42010-03-19 22:18:15 -07001202 case PENPARTNER:
Dmitry Torokhov95dd3b32010-03-19 22:18:15 -07001203 sync = wacom_penpartner_irq(wacom_wac);
1204 break;
Ping Cheng545f4e92008-11-24 11:44:27 -05001205
Dmitry Torokhov73a97f42010-03-19 22:18:15 -07001206 case PL:
Dmitry Torokhov95dd3b32010-03-19 22:18:15 -07001207 sync = wacom_pl_irq(wacom_wac);
1208 break;
Ping Cheng545f4e92008-11-24 11:44:27 -05001209
Dmitry Torokhov73a97f42010-03-19 22:18:15 -07001210 case WACOM_G4:
1211 case GRAPHIRE:
1212 case WACOM_MO:
Dmitry Torokhov95dd3b32010-03-19 22:18:15 -07001213 sync = wacom_graphire_irq(wacom_wac);
1214 break;
Ping Cheng545f4e92008-11-24 11:44:27 -05001215
Dmitry Torokhov73a97f42010-03-19 22:18:15 -07001216 case PTU:
Dmitry Torokhov95dd3b32010-03-19 22:18:15 -07001217 sync = wacom_ptu_irq(wacom_wac);
1218 break;
Ping Cheng545f4e92008-11-24 11:44:27 -05001219
Ping Chengc8f2edc2010-06-28 01:10:51 -07001220 case DTU:
1221 sync = wacom_dtu_irq(wacom_wac);
1222 break;
1223
Dmitry Torokhov73a97f42010-03-19 22:18:15 -07001224 case INTUOS:
1225 case INTUOS3S:
1226 case INTUOS3:
1227 case INTUOS3L:
1228 case INTUOS4S:
1229 case INTUOS4:
1230 case INTUOS4L:
1231 case CINTIQ:
1232 case WACOM_BEE:
Ping Cheng3a4b4aa2010-06-03 22:10:21 -07001233 case WACOM_21UX2:
Jason Gerecke803296b2011-12-12 00:11:45 -08001234 case WACOM_24HD:
Dmitry Torokhov95dd3b32010-03-19 22:18:15 -07001235 sync = wacom_intuos_irq(wacom_wac);
1236 break;
Ping Cheng545f4e92008-11-24 11:44:27 -05001237
Jason Gereckeae584ca2012-04-03 15:50:40 -07001238 case INTUOS5S:
1239 case INTUOS5:
1240 case INTUOS5L:
1241 if (len == WACOM_PKGLEN_BBTOUCH3)
1242 sync = wacom_bpt3_touch(wacom_wac);
1243 else
1244 sync = wacom_intuos_irq(wacom_wac);
1245 break;
1246
Dmitry Torokhov73a97f42010-03-19 22:18:15 -07001247 case TABLETPC:
Ping Chengac173832012-06-12 00:15:06 -07001248 case TABLETPCE:
Dmitry Torokhov73a97f42010-03-19 22:18:15 -07001249 case TABLETPC2FG:
Ping Cheng19635182012-04-29 21:09:18 -07001250 case MTSCREEN:
Dmitry Torokhov95dd3b32010-03-19 22:18:15 -07001251 sync = wacom_tpc_irq(wacom_wac, len);
1252 break;
Ping Cheng545f4e92008-11-24 11:44:27 -05001253
Henrik Rydbergcb734c02010-09-05 12:53:16 -07001254 case BAMBOO_PT:
1255 sync = wacom_bpt_irq(wacom_wac, len);
1256 break;
1257
Chris Bagwelld3825d52012-03-25 23:26:11 -07001258 case WIRELESS:
1259 sync = wacom_wireless_irq(wacom_wac, len);
1260 break;
1261
Dmitry Torokhov73a97f42010-03-19 22:18:15 -07001262 default:
Dmitry Torokhov95dd3b32010-03-19 22:18:15 -07001263 sync = false;
1264 break;
Ping Cheng3bea7332006-07-13 18:01:36 -07001265 }
Dmitry Torokhov95dd3b32010-03-19 22:18:15 -07001266
1267 if (sync)
1268 input_sync(wacom_wac->input);
Ping Cheng3bea7332006-07-13 18:01:36 -07001269}
1270
Ping Cheng6521d0b2010-10-24 21:53:40 -07001271static void wacom_setup_cintiq(struct wacom_wac *wacom_wac)
Ping Cheng3bea7332006-07-13 18:01:36 -07001272{
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -07001273 struct input_dev *input_dev = wacom_wac->input;
1274
1275 input_set_capability(input_dev, EV_MSC, MSC_SERIAL);
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -07001276
1277 __set_bit(BTN_TOOL_RUBBER, input_dev->keybit);
1278 __set_bit(BTN_TOOL_PEN, input_dev->keybit);
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -07001279 __set_bit(BTN_TOOL_BRUSH, input_dev->keybit);
1280 __set_bit(BTN_TOOL_PENCIL, input_dev->keybit);
1281 __set_bit(BTN_TOOL_AIRBRUSH, input_dev->keybit);
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -07001282 __set_bit(BTN_STYLUS, input_dev->keybit);
1283 __set_bit(BTN_STYLUS2, input_dev->keybit);
1284
1285 input_set_abs_params(input_dev, ABS_DISTANCE,
1286 0, wacom_wac->features.distance_max, 0, 0);
1287 input_set_abs_params(input_dev, ABS_WHEEL, 0, 1023, 0, 0);
1288 input_set_abs_params(input_dev, ABS_TILT_X, 0, 127, 0, 0);
1289 input_set_abs_params(input_dev, ABS_TILT_Y, 0, 127, 0, 0);
Ping Cheng6521d0b2010-10-24 21:53:40 -07001290}
1291
1292static void wacom_setup_intuos(struct wacom_wac *wacom_wac)
1293{
1294 struct input_dev *input_dev = wacom_wac->input;
1295
1296 input_set_capability(input_dev, EV_REL, REL_WHEEL);
1297
1298 wacom_setup_cintiq(wacom_wac);
1299
1300 __set_bit(BTN_LEFT, input_dev->keybit);
1301 __set_bit(BTN_RIGHT, input_dev->keybit);
1302 __set_bit(BTN_MIDDLE, input_dev->keybit);
1303 __set_bit(BTN_SIDE, input_dev->keybit);
1304 __set_bit(BTN_EXTRA, input_dev->keybit);
1305 __set_bit(BTN_TOOL_MOUSE, input_dev->keybit);
1306 __set_bit(BTN_TOOL_LENS, input_dev->keybit);
1307
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -07001308 input_set_abs_params(input_dev, ABS_RZ, -900, 899, 0, 0);
1309 input_set_abs_params(input_dev, ABS_THROTTLE, -1023, 1023, 0, 0);
1310}
1311
Henrik Rydbergbc73dd32010-09-05 12:26:16 -07001312void wacom_setup_device_quirks(struct wacom_features *features)
1313{
1314
1315 /* touch device found but size is not defined. use default */
Ping Cheng84eb5aa2011-03-12 20:35:18 -08001316 if (features->device_type == BTN_TOOL_FINGER && !features->x_max) {
Henrik Rydbergbc73dd32010-09-05 12:26:16 -07001317 features->x_max = 1023;
1318 features->y_max = 1023;
1319 }
1320
1321 /* these device have multiple inputs */
Ping Chengea2e6022012-06-12 00:14:12 -07001322 if (features->type >= WIRELESS ||
1323 (features->type >= INTUOS5S && features->type <= INTUOS5L))
Henrik Rydbergbc73dd32010-09-05 12:26:16 -07001324 features->quirks |= WACOM_QUIRK_MULTI_INPUT;
Henrik Rydbergcb734c02010-09-05 12:53:16 -07001325
Chris Bagwell73149ab2011-10-26 22:34:21 -07001326 /* quirk for bamboo touch with 2 low res touches */
Henrik Rydbergcb734c02010-09-05 12:53:16 -07001327 if (features->type == BAMBOO_PT &&
Chris Bagwell73149ab2011-10-26 22:34:21 -07001328 features->pktlen == WACOM_PKGLEN_BBTOUCH) {
Henrik Rydbergf4ccbef2010-09-05 12:57:13 -07001329 features->x_max <<= 5;
1330 features->y_max <<= 5;
1331 features->x_fuzz <<= 5;
1332 features->y_fuzz <<= 5;
Henrik Rydbergf4ccbef2010-09-05 12:57:13 -07001333 features->quirks |= WACOM_QUIRK_BBTOUCH_LOWRES;
Henrik Rydbergcb734c02010-09-05 12:53:16 -07001334 }
Chris Bagwelld3825d52012-03-25 23:26:11 -07001335
1336 if (features->type == WIRELESS) {
1337
1338 /* monitor never has input and pen/touch have delayed create */
1339 features->quirks |= WACOM_QUIRK_NO_INPUT;
1340
1341 /* must be monitor interface if no device_type set */
1342 if (!features->device_type)
1343 features->quirks |= WACOM_QUIRK_MONITOR;
1344 }
Henrik Rydbergbc73dd32010-09-05 12:26:16 -07001345}
1346
Ping Cheng409550f2011-01-25 18:03:13 -08001347static unsigned int wacom_calculate_touch_res(unsigned int logical_max,
1348 unsigned int physical_max)
1349{
1350 /* Touch physical dimensions are in 100th of mm */
1351 return (logical_max * 100) / physical_max;
1352}
1353
Ping Cheng19635182012-04-29 21:09:18 -07001354int wacom_setup_input_capabilities(struct input_dev *input_dev,
1355 struct wacom_wac *wacom_wac)
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -07001356{
1357 struct wacom_features *features = &wacom_wac->features;
1358 int i;
1359
1360 input_dev->evbit[0] |= BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS);
1361
1362 __set_bit(BTN_TOUCH, input_dev->keybit);
1363
Henrik Rydbergfed87e62010-09-05 12:25:11 -07001364 input_set_abs_params(input_dev, ABS_X, 0, features->x_max,
1365 features->x_fuzz, 0);
1366 input_set_abs_params(input_dev, ABS_Y, 0, features->y_max,
1367 features->y_fuzz, 0);
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -07001368
Ping Chenge35fb8c2011-03-26 21:16:05 -07001369 if (features->device_type == BTN_TOOL_PEN) {
Ping Chengcfb7d552011-08-26 23:10:02 -07001370 input_set_abs_params(input_dev, ABS_PRESSURE, 0, features->pressure_max,
1371 features->pressure_fuzz, 0);
1372
Ping Chenge35fb8c2011-03-26 21:16:05 -07001373 /* penabled devices have fixed resolution for each model */
1374 input_abs_set_res(input_dev, ABS_X, features->x_resolution);
1375 input_abs_set_res(input_dev, ABS_Y, features->y_resolution);
1376 } else {
1377 input_abs_set_res(input_dev, ABS_X,
1378 wacom_calculate_touch_res(features->x_max,
1379 features->x_phy));
1380 input_abs_set_res(input_dev, ABS_Y,
1381 wacom_calculate_touch_res(features->y_max,
1382 features->y_phy));
1383 }
1384
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -07001385 __set_bit(ABS_MISC, input_dev->absbit);
1386
Jason Childse33da8a2010-02-17 22:38:31 -08001387 switch (wacom_wac->features.type) {
Dmitry Torokhov73a97f42010-03-19 22:18:15 -07001388 case WACOM_MO:
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -07001389 input_set_abs_params(input_dev, ABS_WHEEL, 0, 71, 0, 0);
1390 /* fall through */
Ping Chengec67bbe2009-12-15 00:35:24 -08001391
Dmitry Torokhov73a97f42010-03-19 22:18:15 -07001392 case WACOM_G4:
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -07001393 input_set_capability(input_dev, EV_MSC, MSC_SERIAL);
1394
Ping Cheng0bd10ef2011-07-06 18:05:42 -07001395 __set_bit(BTN_BACK, input_dev->keybit);
1396 __set_bit(BTN_FORWARD, input_dev->keybit);
Dmitry Torokhov73a97f42010-03-19 22:18:15 -07001397 /* fall through */
1398
1399 case GRAPHIRE:
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -07001400 input_set_capability(input_dev, EV_REL, REL_WHEEL);
1401
1402 __set_bit(BTN_LEFT, input_dev->keybit);
1403 __set_bit(BTN_RIGHT, input_dev->keybit);
1404 __set_bit(BTN_MIDDLE, input_dev->keybit);
1405
1406 __set_bit(BTN_TOOL_RUBBER, input_dev->keybit);
1407 __set_bit(BTN_TOOL_PEN, input_dev->keybit);
1408 __set_bit(BTN_TOOL_MOUSE, input_dev->keybit);
1409 __set_bit(BTN_STYLUS, input_dev->keybit);
1410 __set_bit(BTN_STYLUS2, input_dev->keybit);
Jason Gerecke35120692011-09-08 09:38:14 -07001411
1412 __set_bit(INPUT_PROP_POINTER, input_dev->propbit);
Dmitry Torokhov73a97f42010-03-19 22:18:15 -07001413 break;
1414
Jason Gerecke803296b2011-12-12 00:11:45 -08001415 case WACOM_24HD:
1416 __set_bit(BTN_A, input_dev->keybit);
1417 __set_bit(BTN_B, input_dev->keybit);
1418 __set_bit(BTN_C, input_dev->keybit);
1419 __set_bit(BTN_X, input_dev->keybit);
1420 __set_bit(BTN_Y, input_dev->keybit);
1421 __set_bit(BTN_Z, input_dev->keybit);
1422
1423 for (i = 0; i < 10; i++)
1424 __set_bit(BTN_0 + i, input_dev->keybit);
1425
1426 __set_bit(KEY_PROG1, input_dev->keybit);
1427 __set_bit(KEY_PROG2, input_dev->keybit);
1428 __set_bit(KEY_PROG3, input_dev->keybit);
1429
1430 input_set_abs_params(input_dev, ABS_Z, -900, 899, 0, 0);
1431 input_set_abs_params(input_dev, ABS_THROTTLE, 0, 71, 0, 0);
1432 wacom_setup_cintiq(wacom_wac);
1433 break;
1434
Ping Cheng3a4b4aa2010-06-03 22:10:21 -07001435 case WACOM_21UX2:
1436 __set_bit(BTN_A, input_dev->keybit);
1437 __set_bit(BTN_B, input_dev->keybit);
1438 __set_bit(BTN_C, input_dev->keybit);
1439 __set_bit(BTN_X, input_dev->keybit);
1440 __set_bit(BTN_Y, input_dev->keybit);
1441 __set_bit(BTN_Z, input_dev->keybit);
1442 __set_bit(BTN_BASE, input_dev->keybit);
1443 __set_bit(BTN_BASE2, input_dev->keybit);
1444 /* fall through */
1445
Dmitry Torokhov73a97f42010-03-19 22:18:15 -07001446 case WACOM_BEE:
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -07001447 __set_bit(BTN_8, input_dev->keybit);
1448 __set_bit(BTN_9, input_dev->keybit);
1449 /* fall through */
Dmitry Torokhov73a97f42010-03-19 22:18:15 -07001450
Ping Cheng6521d0b2010-10-24 21:53:40 -07001451 case CINTIQ:
1452 for (i = 0; i < 8; i++)
1453 __set_bit(BTN_0 + i, input_dev->keybit);
Ping Cheng6521d0b2010-10-24 21:53:40 -07001454
Jason Gerecked6069da2011-10-04 22:50:45 -07001455 input_set_abs_params(input_dev, ABS_RX, 0, 4096, 0, 0);
1456 input_set_abs_params(input_dev, ABS_RY, 0, 4096, 0, 0);
Ping Cheng6521d0b2010-10-24 21:53:40 -07001457 input_set_abs_params(input_dev, ABS_Z, -900, 899, 0, 0);
Jason Gerecke35120692011-09-08 09:38:14 -07001458
1459 __set_bit(INPUT_PROP_DIRECT, input_dev->propbit);
1460
Ping Cheng6521d0b2010-10-24 21:53:40 -07001461 wacom_setup_cintiq(wacom_wac);
1462 break;
1463
Dmitry Torokhov73a97f42010-03-19 22:18:15 -07001464 case INTUOS3:
1465 case INTUOS3L:
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -07001466 __set_bit(BTN_4, input_dev->keybit);
1467 __set_bit(BTN_5, input_dev->keybit);
1468 __set_bit(BTN_6, input_dev->keybit);
1469 __set_bit(BTN_7, input_dev->keybit);
1470
1471 input_set_abs_params(input_dev, ABS_RY, 0, 4096, 0, 0);
Dmitry Torokhov73a97f42010-03-19 22:18:15 -07001472 /* fall through */
1473
1474 case INTUOS3S:
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -07001475 __set_bit(BTN_0, input_dev->keybit);
1476 __set_bit(BTN_1, input_dev->keybit);
1477 __set_bit(BTN_2, input_dev->keybit);
1478 __set_bit(BTN_3, input_dev->keybit);
1479
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -07001480 input_set_abs_params(input_dev, ABS_RX, 0, 4096, 0, 0);
1481 input_set_abs_params(input_dev, ABS_Z, -900, 899, 0, 0);
Dmitry Torokhov73a97f42010-03-19 22:18:15 -07001482 /* fall through */
1483
1484 case INTUOS:
Jason Gerecke35120692011-09-08 09:38:14 -07001485 __set_bit(INPUT_PROP_POINTER, input_dev->propbit);
1486
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -07001487 wacom_setup_intuos(wacom_wac);
Dmitry Torokhov73a97f42010-03-19 22:18:15 -07001488 break;
1489
Jason Gerecke9fee6192012-04-03 15:47:22 -07001490 case INTUOS5:
1491 case INTUOS5L:
Jason Gereckeae584ca2012-04-03 15:50:40 -07001492 if (features->device_type == BTN_TOOL_PEN) {
1493 __set_bit(BTN_7, input_dev->keybit);
1494 __set_bit(BTN_8, input_dev->keybit);
1495 }
1496 /* fall through */
1497
1498 case INTUOS5S:
1499 __set_bit(INPUT_PROP_POINTER, input_dev->propbit);
1500
1501 if (features->device_type == BTN_TOOL_PEN) {
1502 for (i = 0; i < 7; i++)
1503 __set_bit(BTN_0 + i, input_dev->keybit);
1504
1505 input_set_abs_params(input_dev, ABS_DISTANCE, 0,
1506 features->distance_max,
1507 0, 0);
1508
1509 input_set_abs_params(input_dev, ABS_Z, -900, 899, 0, 0);
1510
1511 wacom_setup_intuos(wacom_wac);
1512 } else if (features->device_type == BTN_TOOL_FINGER) {
1513 __clear_bit(ABS_MISC, input_dev->absbit);
1514
1515 __set_bit(BTN_TOOL_FINGER, input_dev->keybit);
1516 __set_bit(BTN_TOOL_DOUBLETAP, input_dev->keybit);
1517 __set_bit(BTN_TOOL_TRIPLETAP, input_dev->keybit);
1518 __set_bit(BTN_TOOL_QUADTAP, input_dev->keybit);
1519
Ping Chengf393ee22012-04-29 21:09:17 -07001520 input_mt_init_slots(input_dev, features->touch_max);
Jason Gereckeae584ca2012-04-03 15:50:40 -07001521
1522 input_set_abs_params(input_dev, ABS_MT_TOUCH_MAJOR,
1523 0, 255, 0, 0);
1524
1525 input_set_abs_params(input_dev, ABS_MT_POSITION_X,
1526 0, features->x_max,
1527 features->x_fuzz, 0);
1528 input_set_abs_params(input_dev, ABS_MT_POSITION_Y,
1529 0, features->y_max,
1530 features->y_fuzz, 0);
1531 }
1532 break;
1533
Dmitry Torokhov73a97f42010-03-19 22:18:15 -07001534 case INTUOS4:
1535 case INTUOS4L:
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -07001536 __set_bit(BTN_7, input_dev->keybit);
1537 __set_bit(BTN_8, input_dev->keybit);
Dmitry Torokhov73a97f42010-03-19 22:18:15 -07001538 /* fall through */
1539
1540 case INTUOS4S:
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -07001541 for (i = 0; i < 7; i++)
1542 __set_bit(BTN_0 + i, input_dev->keybit);
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -07001543
1544 input_set_abs_params(input_dev, ABS_Z, -900, 899, 0, 0);
1545 wacom_setup_intuos(wacom_wac);
Jason Gerecke35120692011-09-08 09:38:14 -07001546
1547 __set_bit(INPUT_PROP_POINTER, input_dev->propbit);
Dmitry Torokhov73a97f42010-03-19 22:18:15 -07001548 break;
1549
1550 case TABLETPC2FG:
Ping Cheng19635182012-04-29 21:09:18 -07001551 case MTSCREEN:
Ping Cheng8b4a0c1f2012-01-31 00:07:33 -08001552 if (features->device_type == BTN_TOOL_FINGER) {
Ping Cheng84eb5aa2011-03-12 20:35:18 -08001553
Ping Cheng19635182012-04-29 21:09:18 -07001554 wacom_wac->slots = kmalloc(features->touch_max *
1555 sizeof(int),
1556 GFP_KERNEL);
1557 if (!wacom_wac->slots)
1558 return -ENOMEM;
1559
1560 for (i = 0; i < features->touch_max; i++)
1561 wacom_wac->slots[i] = -1;
1562
Ping Chengf393ee22012-04-29 21:09:17 -07001563 input_mt_init_slots(input_dev, features->touch_max);
Ping Cheng84eb5aa2011-03-12 20:35:18 -08001564 input_set_abs_params(input_dev, ABS_MT_TOOL_TYPE,
1565 0, MT_TOOL_MAX, 0, 0);
1566 input_set_abs_params(input_dev, ABS_MT_POSITION_X,
1567 0, features->x_max, 0, 0);
1568 input_set_abs_params(input_dev, ABS_MT_POSITION_Y,
1569 0, features->y_max, 0, 0);
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -07001570 }
Dmitry Torokhov73a97f42010-03-19 22:18:15 -07001571 /* fall through */
1572
1573 case TABLETPC:
Ping Chengac173832012-06-12 00:15:06 -07001574 case TABLETPCE:
Ping Chenga43c7c52011-03-12 20:34:42 -08001575 __clear_bit(ABS_MISC, input_dev->absbit);
1576
Jason Gerecke35120692011-09-08 09:38:14 -07001577 __set_bit(INPUT_PROP_DIRECT, input_dev->propbit);
1578
Ping Chenge35fb8c2011-03-26 21:16:05 -07001579 if (features->device_type != BTN_TOOL_PEN)
Dmitry Torokhov73a97f42010-03-19 22:18:15 -07001580 break; /* no need to process stylus stuff */
Ping Chenge35fb8c2011-03-26 21:16:05 -07001581
Dmitry Torokhov73a97f42010-03-19 22:18:15 -07001582 /* fall through */
1583
1584 case PL:
Ping Chengc8f2edc2010-06-28 01:10:51 -07001585 case DTU:
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -07001586 __set_bit(BTN_TOOL_PEN, input_dev->keybit);
Jason Gerecke35120692011-09-08 09:38:14 -07001587 __set_bit(BTN_TOOL_RUBBER, input_dev->keybit);
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -07001588 __set_bit(BTN_STYLUS, input_dev->keybit);
1589 __set_bit(BTN_STYLUS2, input_dev->keybit);
Jason Gerecke35120692011-09-08 09:38:14 -07001590
1591 __set_bit(INPUT_PROP_DIRECT, input_dev->propbit);
1592 break;
1593
1594 case PTU:
Dmitry Torokhov73a97f42010-03-19 22:18:15 -07001595 __set_bit(BTN_STYLUS2, input_dev->keybit);
1596 /* fall through */
1597
1598 case PENPARTNER:
Jason Gerecke1fab84a2011-08-26 23:18:22 -07001599 __set_bit(BTN_TOOL_PEN, input_dev->keybit);
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -07001600 __set_bit(BTN_TOOL_RUBBER, input_dev->keybit);
Jason Gerecke1fab84a2011-08-26 23:18:22 -07001601 __set_bit(BTN_STYLUS, input_dev->keybit);
Jason Gerecke35120692011-09-08 09:38:14 -07001602
1603 __set_bit(INPUT_PROP_POINTER, input_dev->propbit);
Dmitry Torokhov73a97f42010-03-19 22:18:15 -07001604 break;
Henrik Rydbergcb734c02010-09-05 12:53:16 -07001605
1606 case BAMBOO_PT:
1607 __clear_bit(ABS_MISC, input_dev->absbit);
1608
Jason Gerecke35120692011-09-08 09:38:14 -07001609 __set_bit(INPUT_PROP_POINTER, input_dev->propbit);
1610
Ping Cheng8b4a0c1f2012-01-31 00:07:33 -08001611 if (features->device_type == BTN_TOOL_FINGER) {
Henrik Rydbergcb734c02010-09-05 12:53:16 -07001612 __set_bit(BTN_LEFT, input_dev->keybit);
1613 __set_bit(BTN_FORWARD, input_dev->keybit);
1614 __set_bit(BTN_BACK, input_dev->keybit);
1615 __set_bit(BTN_RIGHT, input_dev->keybit);
1616
1617 __set_bit(BTN_TOOL_FINGER, input_dev->keybit);
1618 __set_bit(BTN_TOOL_DOUBLETAP, input_dev->keybit);
Ping Chengf393ee22012-04-29 21:09:17 -07001619 input_mt_init_slots(input_dev, features->touch_max);
Henrik Rydbergcb734c02010-09-05 12:53:16 -07001620
Chris Bagwell73149ab2011-10-26 22:34:21 -07001621 if (features->pktlen == WACOM_PKGLEN_BBTOUCH3) {
1622 __set_bit(BTN_TOOL_TRIPLETAP,
1623 input_dev->keybit);
1624 __set_bit(BTN_TOOL_QUADTAP,
1625 input_dev->keybit);
1626
Chris Bagwell73149ab2011-10-26 22:34:21 -07001627 input_set_abs_params(input_dev,
1628 ABS_MT_TOUCH_MAJOR,
1629 0, 255, 0, 0);
Chris Bagwell73149ab2011-10-26 22:34:21 -07001630 }
1631
Henrik Rydbergcb734c02010-09-05 12:53:16 -07001632 input_set_abs_params(input_dev, ABS_MT_POSITION_X,
1633 0, features->x_max,
1634 features->x_fuzz, 0);
1635 input_set_abs_params(input_dev, ABS_MT_POSITION_Y,
1636 0, features->y_max,
1637 features->y_fuzz, 0);
Chris Bagwell2aaacb12010-09-12 00:11:35 -07001638 } else if (features->device_type == BTN_TOOL_PEN) {
1639 __set_bit(BTN_TOOL_RUBBER, input_dev->keybit);
1640 __set_bit(BTN_TOOL_PEN, input_dev->keybit);
1641 __set_bit(BTN_STYLUS, input_dev->keybit);
1642 __set_bit(BTN_STYLUS2, input_dev->keybit);
Chris Bagwellc18c2ce2011-10-10 08:52:13 -07001643 input_set_abs_params(input_dev, ABS_DISTANCE, 0,
1644 features->distance_max,
1645 0, 0);
Henrik Rydbergcb734c02010-09-05 12:53:16 -07001646 }
1647 break;
Ping Cheng3bea7332006-07-13 18:01:36 -07001648 }
Ping Cheng19635182012-04-29 21:09:18 -07001649 return 0;
Ping Cheng3bea7332006-07-13 18:01:36 -07001650}
1651
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001652static const struct wacom_features wacom_features_0x00 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001653 { "Wacom Penpartner", WACOM_PKGLEN_PENPRTN, 5040, 3780, 255,
1654 0, PENPARTNER, WACOM_PENPRTN_RES, WACOM_PENPRTN_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001655static const struct wacom_features wacom_features_0x10 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001656 { "Wacom Graphire", WACOM_PKGLEN_GRAPHIRE, 10206, 7422, 511,
1657 63, GRAPHIRE, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001658static const struct wacom_features wacom_features_0x11 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001659 { "Wacom Graphire2 4x5", WACOM_PKGLEN_GRAPHIRE, 10206, 7422, 511,
1660 63, GRAPHIRE, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001661static const struct wacom_features wacom_features_0x12 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001662 { "Wacom Graphire2 5x7", WACOM_PKGLEN_GRAPHIRE, 13918, 10206, 511,
1663 63, GRAPHIRE, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001664static const struct wacom_features wacom_features_0x13 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001665 { "Wacom Graphire3", WACOM_PKGLEN_GRAPHIRE, 10208, 7424, 511,
1666 63, GRAPHIRE, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001667static const struct wacom_features wacom_features_0x14 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001668 { "Wacom Graphire3 6x8", WACOM_PKGLEN_GRAPHIRE, 16704, 12064, 511,
1669 63, GRAPHIRE, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001670static const struct wacom_features wacom_features_0x15 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001671 { "Wacom Graphire4 4x5", WACOM_PKGLEN_GRAPHIRE, 10208, 7424, 511,
1672 63, WACOM_G4, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001673static const struct wacom_features wacom_features_0x16 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001674 { "Wacom Graphire4 6x8", WACOM_PKGLEN_GRAPHIRE, 16704, 12064, 511,
1675 63, WACOM_G4, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001676static const struct wacom_features wacom_features_0x17 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001677 { "Wacom BambooFun 4x5", WACOM_PKGLEN_BBFUN, 14760, 9225, 511,
1678 63, WACOM_MO, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001679static const struct wacom_features wacom_features_0x18 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001680 { "Wacom BambooFun 6x8", WACOM_PKGLEN_BBFUN, 21648, 13530, 511,
1681 63, WACOM_MO, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001682static const struct wacom_features wacom_features_0x19 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001683 { "Wacom Bamboo1 Medium", WACOM_PKGLEN_GRAPHIRE, 16704, 12064, 511,
1684 63, GRAPHIRE, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001685static const struct wacom_features wacom_features_0x60 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001686 { "Wacom Volito", WACOM_PKGLEN_GRAPHIRE, 5104, 3712, 511,
1687 63, GRAPHIRE, WACOM_VOLITO_RES, WACOM_VOLITO_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001688static const struct wacom_features wacom_features_0x61 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001689 { "Wacom PenStation2", WACOM_PKGLEN_GRAPHIRE, 3250, 2320, 255,
1690 63, GRAPHIRE, WACOM_VOLITO_RES, WACOM_VOLITO_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001691static const struct wacom_features wacom_features_0x62 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001692 { "Wacom Volito2 4x5", WACOM_PKGLEN_GRAPHIRE, 5104, 3712, 511,
1693 63, GRAPHIRE, WACOM_VOLITO_RES, WACOM_VOLITO_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001694static const struct wacom_features wacom_features_0x63 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001695 { "Wacom Volito2 2x3", WACOM_PKGLEN_GRAPHIRE, 3248, 2320, 511,
1696 63, GRAPHIRE, WACOM_VOLITO_RES, WACOM_VOLITO_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001697static const struct wacom_features wacom_features_0x64 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001698 { "Wacom PenPartner2", WACOM_PKGLEN_GRAPHIRE, 3250, 2320, 511,
1699 63, GRAPHIRE, WACOM_VOLITO_RES, WACOM_VOLITO_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001700static const struct wacom_features wacom_features_0x65 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001701 { "Wacom Bamboo", WACOM_PKGLEN_BBFUN, 14760, 9225, 511,
1702 63, WACOM_MO, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001703static const struct wacom_features wacom_features_0x69 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001704 { "Wacom Bamboo1", WACOM_PKGLEN_GRAPHIRE, 5104, 3712, 511,
1705 63, GRAPHIRE, WACOM_PENPRTN_RES, WACOM_PENPRTN_RES };
Ping Cheng11d0cf82011-06-27 12:57:58 -07001706static const struct wacom_features wacom_features_0x6A =
1707 { "Wacom Bamboo1 4x6", WACOM_PKGLEN_GRAPHIRE, 14760, 9225, 1023,
1708 63, GRAPHIRE, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
1709static const struct wacom_features wacom_features_0x6B =
1710 { "Wacom Bamboo1 5x8", WACOM_PKGLEN_GRAPHIRE, 21648, 13530, 1023,
1711 63, GRAPHIRE, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001712static const struct wacom_features wacom_features_0x20 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001713 { "Wacom Intuos 4x5", WACOM_PKGLEN_INTUOS, 12700, 10600, 1023,
1714 31, INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001715static const struct wacom_features wacom_features_0x21 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001716 { "Wacom Intuos 6x8", WACOM_PKGLEN_INTUOS, 20320, 16240, 1023,
1717 31, INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001718static const struct wacom_features wacom_features_0x22 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001719 { "Wacom Intuos 9x12", WACOM_PKGLEN_INTUOS, 30480, 24060, 1023,
1720 31, INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001721static const struct wacom_features wacom_features_0x23 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001722 { "Wacom Intuos 12x12", WACOM_PKGLEN_INTUOS, 30480, 31680, 1023,
1723 31, INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001724static const struct wacom_features wacom_features_0x24 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001725 { "Wacom Intuos 12x18", WACOM_PKGLEN_INTUOS, 45720, 31680, 1023,
1726 31, INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001727static const struct wacom_features wacom_features_0x30 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001728 { "Wacom PL400", WACOM_PKGLEN_GRAPHIRE, 5408, 4056, 255,
1729 0, PL, WACOM_PL_RES, WACOM_PL_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001730static const struct wacom_features wacom_features_0x31 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001731 { "Wacom PL500", WACOM_PKGLEN_GRAPHIRE, 6144, 4608, 255,
1732 0, PL, WACOM_PL_RES, WACOM_PL_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001733static const struct wacom_features wacom_features_0x32 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001734 { "Wacom PL600", WACOM_PKGLEN_GRAPHIRE, 6126, 4604, 255,
1735 0, PL, WACOM_PL_RES, WACOM_PL_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001736static const struct wacom_features wacom_features_0x33 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001737 { "Wacom PL600SX", WACOM_PKGLEN_GRAPHIRE, 6260, 5016, 255,
1738 0, PL, WACOM_PL_RES, WACOM_PL_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001739static const struct wacom_features wacom_features_0x34 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001740 { "Wacom PL550", WACOM_PKGLEN_GRAPHIRE, 6144, 4608, 511,
1741 0, PL, WACOM_PL_RES, WACOM_PL_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001742static const struct wacom_features wacom_features_0x35 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001743 { "Wacom PL800", WACOM_PKGLEN_GRAPHIRE, 7220, 5780, 511,
1744 0, PL, WACOM_PL_RES, WACOM_PL_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001745static const struct wacom_features wacom_features_0x37 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001746 { "Wacom PL700", WACOM_PKGLEN_GRAPHIRE, 6758, 5406, 511,
1747 0, PL, WACOM_PL_RES, WACOM_PL_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001748static const struct wacom_features wacom_features_0x38 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001749 { "Wacom PL510", WACOM_PKGLEN_GRAPHIRE, 6282, 4762, 511,
1750 0, PL, WACOM_PL_RES, WACOM_PL_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001751static const struct wacom_features wacom_features_0x39 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001752 { "Wacom DTU710", WACOM_PKGLEN_GRAPHIRE, 34080, 27660, 511,
1753 0, PL, WACOM_PL_RES, WACOM_PL_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001754static const struct wacom_features wacom_features_0xC4 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001755 { "Wacom DTF521", WACOM_PKGLEN_GRAPHIRE, 6282, 4762, 511,
1756 0, PL, WACOM_PL_RES, WACOM_PL_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001757static const struct wacom_features wacom_features_0xC0 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001758 { "Wacom DTF720", WACOM_PKGLEN_GRAPHIRE, 6858, 5506, 511,
1759 0, PL, WACOM_PL_RES, WACOM_PL_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001760static const struct wacom_features wacom_features_0xC2 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001761 { "Wacom DTF720a", WACOM_PKGLEN_GRAPHIRE, 6858, 5506, 511,
1762 0, PL, WACOM_PL_RES, WACOM_PL_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001763static const struct wacom_features wacom_features_0x03 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001764 { "Wacom Cintiq Partner", WACOM_PKGLEN_GRAPHIRE, 20480, 15360, 511,
1765 0, PTU, WACOM_PL_RES, WACOM_PL_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001766static const struct wacom_features wacom_features_0x41 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001767 { "Wacom Intuos2 4x5", WACOM_PKGLEN_INTUOS, 12700, 10600, 1023,
1768 31, INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001769static const struct wacom_features wacom_features_0x42 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001770 { "Wacom Intuos2 6x8", WACOM_PKGLEN_INTUOS, 20320, 16240, 1023,
1771 31, INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001772static const struct wacom_features wacom_features_0x43 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001773 { "Wacom Intuos2 9x12", WACOM_PKGLEN_INTUOS, 30480, 24060, 1023,
1774 31, INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001775static const struct wacom_features wacom_features_0x44 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001776 { "Wacom Intuos2 12x12", WACOM_PKGLEN_INTUOS, 30480, 31680, 1023,
1777 31, INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001778static const struct wacom_features wacom_features_0x45 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001779 { "Wacom Intuos2 12x18", WACOM_PKGLEN_INTUOS, 45720, 31680, 1023,
1780 31, INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001781static const struct wacom_features wacom_features_0xB0 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001782 { "Wacom Intuos3 4x5", WACOM_PKGLEN_INTUOS, 25400, 20320, 1023,
1783 63, INTUOS3S, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001784static const struct wacom_features wacom_features_0xB1 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001785 { "Wacom Intuos3 6x8", WACOM_PKGLEN_INTUOS, 40640, 30480, 1023,
1786 63, INTUOS3, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001787static const struct wacom_features wacom_features_0xB2 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001788 { "Wacom Intuos3 9x12", WACOM_PKGLEN_INTUOS, 60960, 45720, 1023,
1789 63, INTUOS3, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001790static const struct wacom_features wacom_features_0xB3 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001791 { "Wacom Intuos3 12x12", WACOM_PKGLEN_INTUOS, 60960, 60960, 1023,
1792 63, INTUOS3L, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001793static const struct wacom_features wacom_features_0xB4 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001794 { "Wacom Intuos3 12x19", WACOM_PKGLEN_INTUOS, 97536, 60960, 1023,
1795 63, INTUOS3L, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001796static const struct wacom_features wacom_features_0xB5 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001797 { "Wacom Intuos3 6x11", WACOM_PKGLEN_INTUOS, 54204, 31750, 1023,
1798 63, INTUOS3, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001799static const struct wacom_features wacom_features_0xB7 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001800 { "Wacom Intuos3 4x6", WACOM_PKGLEN_INTUOS, 31496, 19685, 1023,
1801 63, INTUOS3S, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001802static const struct wacom_features wacom_features_0xB8 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001803 { "Wacom Intuos4 4x6", WACOM_PKGLEN_INTUOS, 31496, 19685, 2047,
1804 63, INTUOS4S, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001805static const struct wacom_features wacom_features_0xB9 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001806 { "Wacom Intuos4 6x9", WACOM_PKGLEN_INTUOS, 44704, 27940, 2047,
1807 63, INTUOS4, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001808static const struct wacom_features wacom_features_0xBA =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001809 { "Wacom Intuos4 8x13", WACOM_PKGLEN_INTUOS, 65024, 40640, 2047,
1810 63, INTUOS4L, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001811static const struct wacom_features wacom_features_0xBB =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001812 { "Wacom Intuos4 12x19", WACOM_PKGLEN_INTUOS, 97536, 60960, 2047,
1813 63, INTUOS4L, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
Ping Cheng3a4b4aa2010-06-03 22:10:21 -07001814static const struct wacom_features wacom_features_0xBC =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001815 { "Wacom Intuos4 WL", WACOM_PKGLEN_INTUOS, 40840, 25400, 2047,
1816 63, INTUOS4, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
Jason Gerecke9fee6192012-04-03 15:47:22 -07001817static const struct wacom_features wacom_features_0x26 =
1818 { "Wacom Intuos5 touch S", WACOM_PKGLEN_INTUOS, 31496, 19685, 2047,
Ping Chengf393ee22012-04-29 21:09:17 -07001819 63, INTUOS5S, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES,
1820 .touch_max = 16 };
Jason Gerecke9fee6192012-04-03 15:47:22 -07001821static const struct wacom_features wacom_features_0x27 =
1822 { "Wacom Intuos5 touch M", WACOM_PKGLEN_INTUOS, 44704, 27940, 2047,
Ping Chengf393ee22012-04-29 21:09:17 -07001823 63, INTUOS5, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES,
1824 .touch_max = 16 };
Jason Gerecke9fee6192012-04-03 15:47:22 -07001825static const struct wacom_features wacom_features_0x28 =
1826 { "Wacom Intuos5 touch L", WACOM_PKGLEN_INTUOS, 65024, 40640, 2047,
Ping Chengf393ee22012-04-29 21:09:17 -07001827 63, INTUOS5L, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES,
1828 .touch_max = 16 };
Jason Gerecke9fee6192012-04-03 15:47:22 -07001829static const struct wacom_features wacom_features_0x29 =
1830 { "Wacom Intuos5 S", WACOM_PKGLEN_INTUOS, 31496, 19685, 2047,
1831 63, INTUOS5S, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
1832static const struct wacom_features wacom_features_0x2A =
1833 { "Wacom Intuos5 M", WACOM_PKGLEN_INTUOS, 44704, 27940, 2047,
1834 63, INTUOS5, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
Jason Gerecke803296b2011-12-12 00:11:45 -08001835static const struct wacom_features wacom_features_0xF4 =
1836 { "Wacom Cintiq 24HD", WACOM_PKGLEN_INTUOS, 104480, 65600, 2047,
1837 63, WACOM_24HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001838static const struct wacom_features wacom_features_0x3F =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001839 { "Wacom Cintiq 21UX", WACOM_PKGLEN_INTUOS, 87200, 65600, 1023,
1840 63, CINTIQ, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001841static const struct wacom_features wacom_features_0xC5 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001842 { "Wacom Cintiq 20WSX", WACOM_PKGLEN_INTUOS, 86680, 54180, 1023,
1843 63, WACOM_BEE, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001844static const struct wacom_features wacom_features_0xC6 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001845 { "Wacom Cintiq 12WX", WACOM_PKGLEN_INTUOS, 53020, 33440, 1023,
1846 63, WACOM_BEE, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001847static const struct wacom_features wacom_features_0xC7 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001848 { "Wacom DTU1931", WACOM_PKGLEN_GRAPHIRE, 37832, 30305, 511,
1849 0, PL, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Ping Chengc8f2edc2010-06-28 01:10:51 -07001850static const struct wacom_features wacom_features_0xCE =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001851 { "Wacom DTU2231", WACOM_PKGLEN_GRAPHIRE, 47864, 27011, 511,
1852 0, DTU, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Ping Chengc8f2edc2010-06-28 01:10:51 -07001853static const struct wacom_features wacom_features_0xF0 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001854 { "Wacom DTU1631", WACOM_PKGLEN_GRAPHIRE, 34623, 19553, 511,
1855 0, DTU, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Ping Cheng3a4b4aa2010-06-03 22:10:21 -07001856static const struct wacom_features wacom_features_0xCC =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001857 { "Wacom Cintiq 21UX2", WACOM_PKGLEN_INTUOS, 87200, 65600, 2047,
1858 63, WACOM_21UX2, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001859static const struct wacom_features wacom_features_0x90 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001860 { "Wacom ISDv4 90", WACOM_PKGLEN_GRAPHIRE, 26202, 16325, 255,
1861 0, TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001862static const struct wacom_features wacom_features_0x93 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001863 { "Wacom ISDv4 93", WACOM_PKGLEN_GRAPHIRE, 26202, 16325, 255,
1864 0, TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Ping Cheng11d0cf82011-06-27 12:57:58 -07001865static const struct wacom_features wacom_features_0x97 =
1866 { "Wacom ISDv4 97", WACOM_PKGLEN_GRAPHIRE, 26202, 16325, 511,
1867 0, TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001868static const struct wacom_features wacom_features_0x9A =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001869 { "Wacom ISDv4 9A", WACOM_PKGLEN_GRAPHIRE, 26202, 16325, 255,
1870 0, TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001871static const struct wacom_features wacom_features_0x9F =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001872 { "Wacom ISDv4 9F", WACOM_PKGLEN_GRAPHIRE, 26202, 16325, 255,
1873 0, TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001874static const struct wacom_features wacom_features_0xE2 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001875 { "Wacom ISDv4 E2", WACOM_PKGLEN_TPC2FG, 26202, 16325, 255,
Ping Chengf393ee22012-04-29 21:09:17 -07001876 0, TABLETPC2FG, WACOM_INTUOS_RES, WACOM_INTUOS_RES,
1877 .touch_max = 2 };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001878static const struct wacom_features wacom_features_0xE3 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001879 { "Wacom ISDv4 E3", WACOM_PKGLEN_TPC2FG, 26202, 16325, 255,
Ping Chengf393ee22012-04-29 21:09:17 -07001880 0, TABLETPC2FG, WACOM_INTUOS_RES, WACOM_INTUOS_RES,
1881 .touch_max = 2 };
Ping Cheng19635182012-04-29 21:09:18 -07001882static const struct wacom_features wacom_features_0xE5 =
1883 { "Wacom ISDv4 E5", WACOM_PKGLEN_MTOUCH, 26202, 16325, 255,
1884 0, MTSCREEN, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Manoj Iyer26fcd2a2011-03-31 22:39:43 -07001885static const struct wacom_features wacom_features_0xE6 =
1886 { "Wacom ISDv4 E6", WACOM_PKGLEN_TPC2FG, 27760, 15694, 255,
Ping Chengf393ee22012-04-29 21:09:17 -07001887 0, TABLETPC2FG, WACOM_INTUOS_RES, WACOM_INTUOS_RES,
1888 .touch_max = 2 };
Chris Bagwell0d0e3062011-12-11 23:50:59 -08001889static const struct wacom_features wacom_features_0xEC =
1890 { "Wacom ISDv4 EC", WACOM_PKGLEN_GRAPHIRE, 25710, 14500, 255,
1891 0, TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Ping Chengac173832012-06-12 00:15:06 -07001892static const struct wacom_features wacom_features_0xED =
1893 { "Wacom ISDv4 ED", WACOM_PKGLEN_GRAPHIRE, 26202, 16325, 255,
1894 0, TABLETPCE, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
1895static const struct wacom_features wacom_features_0xEF =
1896 { "Wacom ISDv4 EF", WACOM_PKGLEN_GRAPHIRE, 26202, 16325, 255,
1897 0, TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001898static const struct wacom_features wacom_features_0x47 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001899 { "Wacom Intuos2 6x8", WACOM_PKGLEN_INTUOS, 20320, 16240, 1023,
1900 31, INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Chris Bagwelld3825d52012-03-25 23:26:11 -07001901static const struct wacom_features wacom_features_0x84 =
1902 { "Wacom Wireless Receiver", WACOM_PKGLEN_WIRELESS, 0, 0, 0,
Ping Chengf393ee22012-04-29 21:09:17 -07001903 0, WIRELESS, 0, 0, .touch_max = 16 };
Ping Cheng7b824bb2011-03-26 21:16:04 -07001904static const struct wacom_features wacom_features_0xD0 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001905 { "Wacom Bamboo 2FG", WACOM_PKGLEN_BBFUN, 14720, 9200, 1023,
Ping Chengf393ee22012-04-29 21:09:17 -07001906 31, BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES,
1907 .touch_max = 2 };
Ping Cheng7b824bb2011-03-26 21:16:04 -07001908static const struct wacom_features wacom_features_0xD1 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001909 { "Wacom Bamboo 2FG 4x5", WACOM_PKGLEN_BBFUN, 14720, 9200, 1023,
Ping Chengf393ee22012-04-29 21:09:17 -07001910 31, BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES,
1911 .touch_max = 2 };
Ping Cheng7b824bb2011-03-26 21:16:04 -07001912static const struct wacom_features wacom_features_0xD2 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001913 { "Wacom Bamboo Craft", WACOM_PKGLEN_BBFUN, 14720, 9200, 1023,
Chris Bagwellc18c2ce2011-10-10 08:52:13 -07001914 31, BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Ping Cheng7b824bb2011-03-26 21:16:04 -07001915static const struct wacom_features wacom_features_0xD3 =
Chris Bagwellae927562011-10-10 08:52:32 -07001916 { "Wacom Bamboo 2FG 6x8", WACOM_PKGLEN_BBFUN, 21648, 13700, 1023,
Ping Chengf393ee22012-04-29 21:09:17 -07001917 31, BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES,
1918 .touch_max = 2 };
Kevin Granade57a78722010-12-10 23:04:02 -08001919static const struct wacom_features wacom_features_0xD4 =
Ping Chenga001a8f2011-06-27 12:57:58 -07001920 { "Wacom Bamboo Pen", WACOM_PKGLEN_BBFUN, 14720, 9200, 1023,
Chris Bagwellc18c2ce2011-10-10 08:52:13 -07001921 31, BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Gerard Braad18adad12011-08-16 00:17:56 -07001922static const struct wacom_features wacom_features_0xD5 =
Chris Bagwellae927562011-10-10 08:52:32 -07001923 { "Wacom Bamboo Pen 6x8", WACOM_PKGLEN_BBFUN, 21648, 13700, 1023,
Chris Bagwellc18c2ce2011-10-10 08:52:13 -07001924 31, BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Ping Cheng7b824bb2011-03-26 21:16:04 -07001925static const struct wacom_features wacom_features_0xD6 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001926 { "Wacom BambooPT 2FG 4x5", WACOM_PKGLEN_BBFUN, 14720, 9200, 1023,
Ping Chengf393ee22012-04-29 21:09:17 -07001927 31, BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES,
1928 .touch_max = 2 };
Ping Cheng7b824bb2011-03-26 21:16:04 -07001929static const struct wacom_features wacom_features_0xD7 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001930 { "Wacom BambooPT 2FG Small", WACOM_PKGLEN_BBFUN, 14720, 9200, 1023,
Ping Chengf393ee22012-04-29 21:09:17 -07001931 31, BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES,
1932 .touch_max = 2 };
Ping Cheng7b824bb2011-03-26 21:16:04 -07001933static const struct wacom_features wacom_features_0xD8 =
Chris Bagwellae927562011-10-10 08:52:32 -07001934 { "Wacom Bamboo Comic 2FG", WACOM_PKGLEN_BBFUN, 21648, 13700, 1023,
Ping Chengf393ee22012-04-29 21:09:17 -07001935 31, BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES,
1936 .touch_max = 2 };
Ping Cheng7b824bb2011-03-26 21:16:04 -07001937static const struct wacom_features wacom_features_0xDA =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001938 { "Wacom Bamboo 2FG 4x5 SE", WACOM_PKGLEN_BBFUN, 14720, 9200, 1023,
Ping Chengf393ee22012-04-29 21:09:17 -07001939 31, BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES,
1940 .touch_max = 2 };
David Foley47d09232010-12-07 21:05:59 -08001941static struct wacom_features wacom_features_0xDB =
Chris Bagwellae927562011-10-10 08:52:32 -07001942 { "Wacom Bamboo 2FG 6x8 SE", WACOM_PKGLEN_BBFUN, 21648, 13700, 1023,
Ping Chengf393ee22012-04-29 21:09:17 -07001943 31, BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES,
1944 .touch_max = 2 };
Chris Bagwell73149ab2011-10-26 22:34:21 -07001945static const struct wacom_features wacom_features_0xDD =
1946 { "Wacom Bamboo Connect", WACOM_PKGLEN_BBPEN, 14720, 9200, 1023,
1947 31, BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
1948static const struct wacom_features wacom_features_0xDE =
1949 { "Wacom Bamboo 16FG 4x5", WACOM_PKGLEN_BBPEN, 14720, 9200, 1023,
Ping Chengf393ee22012-04-29 21:09:17 -07001950 31, BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES,
1951 .touch_max = 16 };
Chris Bagwell73149ab2011-10-26 22:34:21 -07001952static const struct wacom_features wacom_features_0xDF =
1953 { "Wacom Bamboo 16FG 6x8", WACOM_PKGLEN_BBPEN, 21648, 13700, 1023,
Ping Chengf393ee22012-04-29 21:09:17 -07001954 31, BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES,
1955 .touch_max = 16 };
Ajay Ramaswamy7b4b3062010-12-23 01:19:39 -08001956static const struct wacom_features wacom_features_0x6004 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001957 { "ISD-V4", WACOM_PKGLEN_GRAPHIRE, 12800, 8000, 255,
1958 0, TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Bastian Blankb036f6f2010-02-10 23:06:23 -08001959
1960#define USB_DEVICE_WACOM(prod) \
1961 USB_DEVICE(USB_VENDOR_ID_WACOM, prod), \
1962 .driver_info = (kernel_ulong_t)&wacom_features_##prod
1963
Aristeu Rozanski1483f552011-06-22 01:17:17 -07001964#define USB_DEVICE_DETAILED(prod, class, sub, proto) \
1965 USB_DEVICE_AND_INTERFACE_INFO(USB_VENDOR_ID_WACOM, prod, class, \
1966 sub, proto), \
1967 .driver_info = (kernel_ulong_t)&wacom_features_##prod
1968
Ajay Ramaswamy7b4b3062010-12-23 01:19:39 -08001969#define USB_DEVICE_LENOVO(prod) \
1970 USB_DEVICE(USB_VENDOR_ID_LENOVO, prod), \
1971 .driver_info = (kernel_ulong_t)&wacom_features_##prod
1972
Bastian Blankb036f6f2010-02-10 23:06:23 -08001973const struct usb_device_id wacom_ids[] = {
1974 { USB_DEVICE_WACOM(0x00) },
1975 { USB_DEVICE_WACOM(0x10) },
1976 { USB_DEVICE_WACOM(0x11) },
1977 { USB_DEVICE_WACOM(0x12) },
1978 { USB_DEVICE_WACOM(0x13) },
1979 { USB_DEVICE_WACOM(0x14) },
1980 { USB_DEVICE_WACOM(0x15) },
1981 { USB_DEVICE_WACOM(0x16) },
1982 { USB_DEVICE_WACOM(0x17) },
1983 { USB_DEVICE_WACOM(0x18) },
1984 { USB_DEVICE_WACOM(0x19) },
1985 { USB_DEVICE_WACOM(0x60) },
1986 { USB_DEVICE_WACOM(0x61) },
1987 { USB_DEVICE_WACOM(0x62) },
1988 { USB_DEVICE_WACOM(0x63) },
1989 { USB_DEVICE_WACOM(0x64) },
1990 { USB_DEVICE_WACOM(0x65) },
1991 { USB_DEVICE_WACOM(0x69) },
Ping Cheng11d0cf82011-06-27 12:57:58 -07001992 { USB_DEVICE_WACOM(0x6A) },
1993 { USB_DEVICE_WACOM(0x6B) },
Bastian Blankb036f6f2010-02-10 23:06:23 -08001994 { USB_DEVICE_WACOM(0x20) },
1995 { USB_DEVICE_WACOM(0x21) },
1996 { USB_DEVICE_WACOM(0x22) },
1997 { USB_DEVICE_WACOM(0x23) },
1998 { USB_DEVICE_WACOM(0x24) },
1999 { USB_DEVICE_WACOM(0x30) },
2000 { USB_DEVICE_WACOM(0x31) },
2001 { USB_DEVICE_WACOM(0x32) },
2002 { USB_DEVICE_WACOM(0x33) },
2003 { USB_DEVICE_WACOM(0x34) },
2004 { USB_DEVICE_WACOM(0x35) },
2005 { USB_DEVICE_WACOM(0x37) },
2006 { USB_DEVICE_WACOM(0x38) },
2007 { USB_DEVICE_WACOM(0x39) },
2008 { USB_DEVICE_WACOM(0xC4) },
2009 { USB_DEVICE_WACOM(0xC0) },
2010 { USB_DEVICE_WACOM(0xC2) },
2011 { USB_DEVICE_WACOM(0x03) },
2012 { USB_DEVICE_WACOM(0x41) },
2013 { USB_DEVICE_WACOM(0x42) },
2014 { USB_DEVICE_WACOM(0x43) },
2015 { USB_DEVICE_WACOM(0x44) },
2016 { USB_DEVICE_WACOM(0x45) },
2017 { USB_DEVICE_WACOM(0xB0) },
2018 { USB_DEVICE_WACOM(0xB1) },
2019 { USB_DEVICE_WACOM(0xB2) },
2020 { USB_DEVICE_WACOM(0xB3) },
2021 { USB_DEVICE_WACOM(0xB4) },
2022 { USB_DEVICE_WACOM(0xB5) },
2023 { USB_DEVICE_WACOM(0xB7) },
2024 { USB_DEVICE_WACOM(0xB8) },
2025 { USB_DEVICE_WACOM(0xB9) },
2026 { USB_DEVICE_WACOM(0xBA) },
2027 { USB_DEVICE_WACOM(0xBB) },
Ping Cheng3a4b4aa2010-06-03 22:10:21 -07002028 { USB_DEVICE_WACOM(0xBC) },
Jason Gerecke9fee6192012-04-03 15:47:22 -07002029 { USB_DEVICE_WACOM(0x26) },
2030 { USB_DEVICE_WACOM(0x27) },
2031 { USB_DEVICE_WACOM(0x28) },
2032 { USB_DEVICE_WACOM(0x29) },
2033 { USB_DEVICE_WACOM(0x2A) },
Bastian Blankb036f6f2010-02-10 23:06:23 -08002034 { USB_DEVICE_WACOM(0x3F) },
2035 { USB_DEVICE_WACOM(0xC5) },
2036 { USB_DEVICE_WACOM(0xC6) },
2037 { USB_DEVICE_WACOM(0xC7) },
Aristeu Rozanski1483f552011-06-22 01:17:17 -07002038 /*
2039 * DTU-2231 has two interfaces on the same configuration,
2040 * only one is used.
2041 */
2042 { USB_DEVICE_DETAILED(0xCE, USB_CLASS_HID,
2043 USB_INTERFACE_SUBCLASS_BOOT,
2044 USB_INTERFACE_PROTOCOL_MOUSE) },
Chris Bagwelld3825d52012-03-25 23:26:11 -07002045 { USB_DEVICE_WACOM(0x84) },
Henrik Rydbergcb734c02010-09-05 12:53:16 -07002046 { USB_DEVICE_WACOM(0xD0) },
Chris Bagwell2aaacb12010-09-12 00:11:35 -07002047 { USB_DEVICE_WACOM(0xD1) },
2048 { USB_DEVICE_WACOM(0xD2) },
2049 { USB_DEVICE_WACOM(0xD3) },
Kevin Granade57a78722010-12-10 23:04:02 -08002050 { USB_DEVICE_WACOM(0xD4) },
Gerard Braad18adad12011-08-16 00:17:56 -07002051 { USB_DEVICE_WACOM(0xD5) },
Ping Chengd38acb42011-01-24 09:32:50 -08002052 { USB_DEVICE_WACOM(0xD6) },
2053 { USB_DEVICE_WACOM(0xD7) },
David Foleya318e6b2010-11-30 23:45:46 -08002054 { USB_DEVICE_WACOM(0xD8) },
2055 { USB_DEVICE_WACOM(0xDA) },
David Foley47d09232010-12-07 21:05:59 -08002056 { USB_DEVICE_WACOM(0xDB) },
Chris Bagwell73149ab2011-10-26 22:34:21 -07002057 { USB_DEVICE_WACOM(0xDD) },
2058 { USB_DEVICE_WACOM(0xDE) },
2059 { USB_DEVICE_WACOM(0xDF) },
Ping Chengc8f2edc2010-06-28 01:10:51 -07002060 { USB_DEVICE_WACOM(0xF0) },
Ping Cheng3a4b4aa2010-06-03 22:10:21 -07002061 { USB_DEVICE_WACOM(0xCC) },
Bastian Blankb036f6f2010-02-10 23:06:23 -08002062 { USB_DEVICE_WACOM(0x90) },
2063 { USB_DEVICE_WACOM(0x93) },
Ping Cheng11d0cf82011-06-27 12:57:58 -07002064 { USB_DEVICE_WACOM(0x97) },
Bastian Blankb036f6f2010-02-10 23:06:23 -08002065 { USB_DEVICE_WACOM(0x9A) },
2066 { USB_DEVICE_WACOM(0x9F) },
2067 { USB_DEVICE_WACOM(0xE2) },
2068 { USB_DEVICE_WACOM(0xE3) },
Ping Cheng19635182012-04-29 21:09:18 -07002069 { USB_DEVICE_WACOM(0xE5) },
Manoj Iyer26fcd2a2011-03-31 22:39:43 -07002070 { USB_DEVICE_WACOM(0xE6) },
Chris Bagwell0d0e3062011-12-11 23:50:59 -08002071 { USB_DEVICE_WACOM(0xEC) },
Ping Chengac173832012-06-12 00:15:06 -07002072 { USB_DEVICE_WACOM(0xED) },
2073 { USB_DEVICE_WACOM(0xEF) },
Bastian Blankb036f6f2010-02-10 23:06:23 -08002074 { USB_DEVICE_WACOM(0x47) },
Jason Gerecke803296b2011-12-12 00:11:45 -08002075 { USB_DEVICE_WACOM(0xF4) },
Ajay Ramaswamy7b4b3062010-12-23 01:19:39 -08002076 { USB_DEVICE_LENOVO(0x6004) },
Ping Cheng3bea7332006-07-13 18:01:36 -07002077 { }
2078};
Ping Cheng3bea7332006-07-13 18:01:36 -07002079MODULE_DEVICE_TABLE(usb, wacom_ids);