blob: c40dcb7036b3343da2bdcc5aa44f3f4db1a15221 [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) {
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700251 input_report_abs(input, ABS_PRESSURE, data[6] | ((data[7] & 0x01) << 8));
252 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]);
891 } else { /* with capacity */
892 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:
964 return wacom_tpc_single_touch(wacom, len);
965
Ping Cheng19635182012-04-29 21:09:18 -0700966 case WACOM_REPORT_TPCMT:
967 return wacom_mt_touch(wacom);
968
Ping Cheng31175a82012-01-31 00:07:33 -0800969 case WACOM_REPORT_PENABLED:
970 return wacom_tpc_pen(wacom);
971 }
972 }
Ping Cheng545f4e92008-11-24 11:44:27 -0500973
Ping Cheng8aa9a9a2011-03-12 20:34:11 -0800974 return 0;
Ping Cheng545f4e92008-11-24 11:44:27 -0500975}
976
Chris Bagwelle1d38e42010-09-12 00:09:27 -0700977static int wacom_bpt_touch(struct wacom_wac *wacom)
Henrik Rydbergcb734c02010-09-05 12:53:16 -0700978{
Henrik Rydbergf4ccbef2010-09-05 12:57:13 -0700979 struct wacom_features *features = &wacom->features;
Henrik Rydbergcb734c02010-09-05 12:53:16 -0700980 struct input_dev *input = wacom->input;
981 unsigned char *data = wacom->data;
Henrik Rydbergcb734c02010-09-05 12:53:16 -0700982 int i;
983
Chris Bagwell5a6c8652011-11-07 19:52:42 -0800984 if (data[0] != 0x02)
985 return 0;
986
Henrik Rydbergcb734c02010-09-05 12:53:16 -0700987 for (i = 0; i < 2; i++) {
Chris Bagwell8f906862011-09-09 13:38:10 -0700988 int offset = (data[1] & 0x80) ? (8 * i) : (9 * i);
989 bool touch = data[offset + 3] & 0x80;
Henrik Rydbergc5f4dec2010-12-15 13:50:34 +0100990
Chris Bagwell33d5f712010-09-12 00:12:28 -0700991 /*
992 * Touch events need to be disabled while stylus is
993 * in proximity because user's hand is resting on touchpad
994 * and sending unwanted events. User expects tablet buttons
995 * to continue working though.
996 */
Chris Bagwell8f906862011-09-09 13:38:10 -0700997 touch = touch && !wacom->shared->stylus_in_proximity;
998
999 input_mt_slot(input, i);
1000 input_mt_report_slot_state(input, MT_TOOL_FINGER, touch);
Henrik Rydbergc5f4dec2010-12-15 13:50:34 +01001001 if (touch) {
Chris Bagwell8f906862011-09-09 13:38:10 -07001002 int x = get_unaligned_be16(&data[offset + 3]) & 0x7ff;
1003 int y = get_unaligned_be16(&data[offset + 5]) & 0x7ff;
Henrik Rydbergf4ccbef2010-09-05 12:57:13 -07001004 if (features->quirks & WACOM_QUIRK_BBTOUCH_LOWRES) {
1005 x <<= 5;
1006 y <<= 5;
1007 }
Henrik Rydbergcb734c02010-09-05 12:53:16 -07001008 input_report_abs(input, ABS_MT_POSITION_X, x);
1009 input_report_abs(input, ABS_MT_POSITION_Y, y);
Henrik Rydbergcb734c02010-09-05 12:53:16 -07001010 }
Henrik Rydbergcb734c02010-09-05 12:53:16 -07001011 }
1012
Henrik Rydbergc5f4dec2010-12-15 13:50:34 +01001013 input_mt_report_pointer_emulation(input, true);
Henrik Rydbergcb734c02010-09-05 12:53:16 -07001014
1015 input_report_key(input, BTN_LEFT, (data[1] & 0x08) != 0);
1016 input_report_key(input, BTN_FORWARD, (data[1] & 0x04) != 0);
1017 input_report_key(input, BTN_BACK, (data[1] & 0x02) != 0);
1018 input_report_key(input, BTN_RIGHT, (data[1] & 0x01) != 0);
1019
1020 input_sync(input);
1021
1022 return 0;
1023}
1024
Chris Bagwell73149ab2011-10-26 22:34:21 -07001025static void wacom_bpt3_touch_msg(struct wacom_wac *wacom, unsigned char *data)
1026{
1027 struct input_dev *input = wacom->input;
1028 int slot_id = data[0] - 2; /* data[0] is between 2 and 17 */
1029 bool touch = data[1] & 0x80;
1030
1031 touch = touch && !wacom->shared->stylus_in_proximity;
1032
1033 input_mt_slot(input, slot_id);
1034 input_mt_report_slot_state(input, MT_TOOL_FINGER, touch);
1035
1036 if (touch) {
1037 int x = (data[2] << 4) | (data[4] >> 4);
1038 int y = (data[3] << 4) | (data[4] & 0x0f);
1039 int w = data[6];
1040
1041 input_report_abs(input, ABS_MT_POSITION_X, x);
1042 input_report_abs(input, ABS_MT_POSITION_Y, y);
1043 input_report_abs(input, ABS_MT_TOUCH_MAJOR, w);
1044 }
1045}
1046
1047static void wacom_bpt3_button_msg(struct wacom_wac *wacom, unsigned char *data)
1048{
1049 struct input_dev *input = wacom->input;
1050
1051 input_report_key(input, BTN_LEFT, (data[1] & 0x08) != 0);
1052 input_report_key(input, BTN_FORWARD, (data[1] & 0x04) != 0);
1053 input_report_key(input, BTN_BACK, (data[1] & 0x02) != 0);
1054 input_report_key(input, BTN_RIGHT, (data[1] & 0x01) != 0);
1055}
1056
1057static int wacom_bpt3_touch(struct wacom_wac *wacom)
1058{
1059 struct input_dev *input = wacom->input;
1060 unsigned char *data = wacom->data;
Jason Gerecke19d57d32012-03-06 10:19:19 -08001061 int count = data[1] & 0x07;
Chris Bagwell73149ab2011-10-26 22:34:21 -07001062 int i;
1063
Chris Bagwell5a6c8652011-11-07 19:52:42 -08001064 if (data[0] != 0x02)
1065 return 0;
1066
Chris Bagwell73149ab2011-10-26 22:34:21 -07001067 /* data has up to 7 fixed sized 8-byte messages starting at data[2] */
1068 for (i = 0; i < count; i++) {
1069 int offset = (8 * i) + 2;
1070 int msg_id = data[offset];
1071
1072 if (msg_id >= 2 && msg_id <= 17)
1073 wacom_bpt3_touch_msg(wacom, data + offset);
1074 else if (msg_id == 128)
1075 wacom_bpt3_button_msg(wacom, data + offset);
1076
1077 }
1078
1079 input_mt_report_pointer_emulation(input, true);
1080
1081 input_sync(input);
1082
1083 return 0;
1084}
1085
Chris Bagwell2aaacb12010-09-12 00:11:35 -07001086static int wacom_bpt_pen(struct wacom_wac *wacom)
1087{
1088 struct input_dev *input = wacom->input;
1089 unsigned char *data = wacom->data;
1090 int prox = 0, x = 0, y = 0, p = 0, d = 0, pen = 0, btn1 = 0, btn2 = 0;
1091
Chris Bagwell5a6c8652011-11-07 19:52:42 -08001092 if (data[0] != 0x02)
1093 return 0;
1094
Chris Bagwellc5981412011-10-26 22:28:34 -07001095 prox = (data[1] & 0x20) == 0x20;
Chris Bagwell2aaacb12010-09-12 00:11:35 -07001096
1097 /*
1098 * All reports shared between PEN and RUBBER tool must be
1099 * forced to a known starting value (zero) when transitioning to
1100 * out-of-prox.
1101 *
1102 * If not reset then, to userspace, it will look like lost events
1103 * if new tool comes in-prox with same values as previous tool sent.
1104 *
1105 * Hardware does report zero in most out-of-prox cases but not all.
1106 */
1107 if (prox) {
1108 if (!wacom->shared->stylus_in_proximity) {
1109 if (data[1] & 0x08) {
1110 wacom->tool[0] = BTN_TOOL_RUBBER;
1111 wacom->id[0] = ERASER_DEVICE_ID;
1112 } else {
1113 wacom->tool[0] = BTN_TOOL_PEN;
1114 wacom->id[0] = STYLUS_DEVICE_ID;
1115 }
1116 wacom->shared->stylus_in_proximity = true;
1117 }
1118 x = le16_to_cpup((__le16 *)&data[2]);
1119 y = le16_to_cpup((__le16 *)&data[4]);
1120 p = le16_to_cpup((__le16 *)&data[6]);
Chris Bagwellc18c2ce2011-10-10 08:52:13 -07001121 /*
1122 * Convert distance from out prox to distance from tablet.
1123 * distance will be greater than distance_max once
1124 * touching and applying pressure; do not report negative
1125 * distance.
1126 */
1127 if (data[8] <= wacom->features.distance_max)
1128 d = wacom->features.distance_max - data[8];
1129
Chris Bagwell2aaacb12010-09-12 00:11:35 -07001130 pen = data[1] & 0x01;
1131 btn1 = data[1] & 0x02;
1132 btn2 = data[1] & 0x04;
1133 }
1134
1135 input_report_key(input, BTN_TOUCH, pen);
1136 input_report_key(input, BTN_STYLUS, btn1);
1137 input_report_key(input, BTN_STYLUS2, btn2);
1138
1139 input_report_abs(input, ABS_X, x);
1140 input_report_abs(input, ABS_Y, y);
1141 input_report_abs(input, ABS_PRESSURE, p);
1142 input_report_abs(input, ABS_DISTANCE, d);
1143
1144 if (!prox) {
1145 wacom->id[0] = 0;
1146 wacom->shared->stylus_in_proximity = false;
1147 }
1148
1149 input_report_key(input, wacom->tool[0], prox); /* PEN or RUBBER */
1150 input_report_abs(input, ABS_MISC, wacom->id[0]); /* TOOL ID */
1151
1152 return 1;
1153}
1154
Chris Bagwelle1d38e42010-09-12 00:09:27 -07001155static int wacom_bpt_irq(struct wacom_wac *wacom, size_t len)
1156{
1157 if (len == WACOM_PKGLEN_BBTOUCH)
1158 return wacom_bpt_touch(wacom);
Chris Bagwell73149ab2011-10-26 22:34:21 -07001159 else if (len == WACOM_PKGLEN_BBTOUCH3)
1160 return wacom_bpt3_touch(wacom);
1161 else if (len == WACOM_PKGLEN_BBFUN || len == WACOM_PKGLEN_BBPEN)
Chris Bagwell2aaacb12010-09-12 00:11:35 -07001162 return wacom_bpt_pen(wacom);
Chris Bagwelle1d38e42010-09-12 00:09:27 -07001163
1164 return 0;
1165}
1166
Chris Bagwelld3825d52012-03-25 23:26:11 -07001167static int wacom_wireless_irq(struct wacom_wac *wacom, size_t len)
1168{
Chris Bagwell16bf2882012-03-25 23:26:20 -07001169 unsigned char *data = wacom->data;
1170 int connected;
1171
1172 if (len != WACOM_PKGLEN_WIRELESS || data[0] != 0x80)
Chris Bagwelld3825d52012-03-25 23:26:11 -07001173 return 0;
1174
Chris Bagwell16bf2882012-03-25 23:26:20 -07001175 connected = data[1] & 0x01;
1176 if (connected) {
Chris Bagwella1d552c2012-03-25 23:26:30 -07001177 int pid, battery;
Chris Bagwell16bf2882012-03-25 23:26:20 -07001178
1179 pid = get_unaligned_be16(&data[6]);
Chris Bagwella1d552c2012-03-25 23:26:30 -07001180 battery = data[5] & 0x3f;
Chris Bagwell16bf2882012-03-25 23:26:20 -07001181 if (wacom->pid != pid) {
1182 wacom->pid = pid;
1183 wacom_schedule_work(wacom);
1184 }
Chris Bagwella1d552c2012-03-25 23:26:30 -07001185 wacom->battery_capacity = battery;
Chris Bagwell16bf2882012-03-25 23:26:20 -07001186 } else if (wacom->pid != 0) {
1187 /* disconnected while previously connected */
1188 wacom->pid = 0;
1189 wacom_schedule_work(wacom);
Chris Bagwella1d552c2012-03-25 23:26:30 -07001190 wacom->battery_capacity = 0;
Chris Bagwell16bf2882012-03-25 23:26:20 -07001191 }
1192
Chris Bagwelld3825d52012-03-25 23:26:11 -07001193 return 0;
1194}
1195
Dmitry Torokhov95dd3b32010-03-19 22:18:15 -07001196void wacom_wac_irq(struct wacom_wac *wacom_wac, size_t len)
Ping Cheng3bea7332006-07-13 18:01:36 -07001197{
Dmitry Torokhov95dd3b32010-03-19 22:18:15 -07001198 bool sync;
1199
Jason Childse33da8a2010-02-17 22:38:31 -08001200 switch (wacom_wac->features.type) {
Dmitry Torokhov73a97f42010-03-19 22:18:15 -07001201 case PENPARTNER:
Dmitry Torokhov95dd3b32010-03-19 22:18:15 -07001202 sync = wacom_penpartner_irq(wacom_wac);
1203 break;
Ping Cheng545f4e92008-11-24 11:44:27 -05001204
Dmitry Torokhov73a97f42010-03-19 22:18:15 -07001205 case PL:
Dmitry Torokhov95dd3b32010-03-19 22:18:15 -07001206 sync = wacom_pl_irq(wacom_wac);
1207 break;
Ping Cheng545f4e92008-11-24 11:44:27 -05001208
Dmitry Torokhov73a97f42010-03-19 22:18:15 -07001209 case WACOM_G4:
1210 case GRAPHIRE:
1211 case WACOM_MO:
Dmitry Torokhov95dd3b32010-03-19 22:18:15 -07001212 sync = wacom_graphire_irq(wacom_wac);
1213 break;
Ping Cheng545f4e92008-11-24 11:44:27 -05001214
Dmitry Torokhov73a97f42010-03-19 22:18:15 -07001215 case PTU:
Dmitry Torokhov95dd3b32010-03-19 22:18:15 -07001216 sync = wacom_ptu_irq(wacom_wac);
1217 break;
Ping Cheng545f4e92008-11-24 11:44:27 -05001218
Ping Chengc8f2edc2010-06-28 01:10:51 -07001219 case DTU:
1220 sync = wacom_dtu_irq(wacom_wac);
1221 break;
1222
Dmitry Torokhov73a97f42010-03-19 22:18:15 -07001223 case INTUOS:
1224 case INTUOS3S:
1225 case INTUOS3:
1226 case INTUOS3L:
1227 case INTUOS4S:
1228 case INTUOS4:
1229 case INTUOS4L:
1230 case CINTIQ:
1231 case WACOM_BEE:
Ping Cheng3a4b4aa2010-06-03 22:10:21 -07001232 case WACOM_21UX2:
Jason Gerecke803296b2011-12-12 00:11:45 -08001233 case WACOM_24HD:
Dmitry Torokhov95dd3b32010-03-19 22:18:15 -07001234 sync = wacom_intuos_irq(wacom_wac);
1235 break;
Ping Cheng545f4e92008-11-24 11:44:27 -05001236
Jason Gereckeae584ca2012-04-03 15:50:40 -07001237 case INTUOS5S:
1238 case INTUOS5:
1239 case INTUOS5L:
1240 if (len == WACOM_PKGLEN_BBTOUCH3)
1241 sync = wacom_bpt3_touch(wacom_wac);
1242 else
1243 sync = wacom_intuos_irq(wacom_wac);
1244 break;
1245
Dmitry Torokhov73a97f42010-03-19 22:18:15 -07001246 case TABLETPC:
1247 case TABLETPC2FG:
Ping Cheng19635182012-04-29 21:09:18 -07001248 case MTSCREEN:
Dmitry Torokhov95dd3b32010-03-19 22:18:15 -07001249 sync = wacom_tpc_irq(wacom_wac, len);
1250 break;
Ping Cheng545f4e92008-11-24 11:44:27 -05001251
Henrik Rydbergcb734c02010-09-05 12:53:16 -07001252 case BAMBOO_PT:
1253 sync = wacom_bpt_irq(wacom_wac, len);
1254 break;
1255
Chris Bagwelld3825d52012-03-25 23:26:11 -07001256 case WIRELESS:
1257 sync = wacom_wireless_irq(wacom_wac, len);
1258 break;
1259
Dmitry Torokhov73a97f42010-03-19 22:18:15 -07001260 default:
Dmitry Torokhov95dd3b32010-03-19 22:18:15 -07001261 sync = false;
1262 break;
Ping Cheng3bea7332006-07-13 18:01:36 -07001263 }
Dmitry Torokhov95dd3b32010-03-19 22:18:15 -07001264
1265 if (sync)
1266 input_sync(wacom_wac->input);
Ping Cheng3bea7332006-07-13 18:01:36 -07001267}
1268
Ping Cheng6521d0b2010-10-24 21:53:40 -07001269static void wacom_setup_cintiq(struct wacom_wac *wacom_wac)
Ping Cheng3bea7332006-07-13 18:01:36 -07001270{
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -07001271 struct input_dev *input_dev = wacom_wac->input;
1272
1273 input_set_capability(input_dev, EV_MSC, MSC_SERIAL);
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -07001274
1275 __set_bit(BTN_TOOL_RUBBER, input_dev->keybit);
1276 __set_bit(BTN_TOOL_PEN, input_dev->keybit);
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -07001277 __set_bit(BTN_TOOL_BRUSH, input_dev->keybit);
1278 __set_bit(BTN_TOOL_PENCIL, input_dev->keybit);
1279 __set_bit(BTN_TOOL_AIRBRUSH, input_dev->keybit);
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -07001280 __set_bit(BTN_STYLUS, input_dev->keybit);
1281 __set_bit(BTN_STYLUS2, input_dev->keybit);
1282
1283 input_set_abs_params(input_dev, ABS_DISTANCE,
1284 0, wacom_wac->features.distance_max, 0, 0);
1285 input_set_abs_params(input_dev, ABS_WHEEL, 0, 1023, 0, 0);
1286 input_set_abs_params(input_dev, ABS_TILT_X, 0, 127, 0, 0);
1287 input_set_abs_params(input_dev, ABS_TILT_Y, 0, 127, 0, 0);
Ping Cheng6521d0b2010-10-24 21:53:40 -07001288}
1289
1290static void wacom_setup_intuos(struct wacom_wac *wacom_wac)
1291{
1292 struct input_dev *input_dev = wacom_wac->input;
1293
1294 input_set_capability(input_dev, EV_REL, REL_WHEEL);
1295
1296 wacom_setup_cintiq(wacom_wac);
1297
1298 __set_bit(BTN_LEFT, input_dev->keybit);
1299 __set_bit(BTN_RIGHT, input_dev->keybit);
1300 __set_bit(BTN_MIDDLE, input_dev->keybit);
1301 __set_bit(BTN_SIDE, input_dev->keybit);
1302 __set_bit(BTN_EXTRA, input_dev->keybit);
1303 __set_bit(BTN_TOOL_MOUSE, input_dev->keybit);
1304 __set_bit(BTN_TOOL_LENS, input_dev->keybit);
1305
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -07001306 input_set_abs_params(input_dev, ABS_RZ, -900, 899, 0, 0);
1307 input_set_abs_params(input_dev, ABS_THROTTLE, -1023, 1023, 0, 0);
1308}
1309
Henrik Rydbergbc73dd32010-09-05 12:26:16 -07001310void wacom_setup_device_quirks(struct wacom_features *features)
1311{
1312
1313 /* touch device found but size is not defined. use default */
Ping Cheng84eb5aa2011-03-12 20:35:18 -08001314 if (features->device_type == BTN_TOOL_FINGER && !features->x_max) {
Henrik Rydbergbc73dd32010-09-05 12:26:16 -07001315 features->x_max = 1023;
1316 features->y_max = 1023;
1317 }
1318
1319 /* these device have multiple inputs */
Ping Chengea2e6022012-06-12 00:14:12 -07001320 if (features->type >= WIRELESS ||
1321 (features->type >= INTUOS5S && features->type <= INTUOS5L))
Henrik Rydbergbc73dd32010-09-05 12:26:16 -07001322 features->quirks |= WACOM_QUIRK_MULTI_INPUT;
Henrik Rydbergcb734c02010-09-05 12:53:16 -07001323
Chris Bagwell73149ab2011-10-26 22:34:21 -07001324 /* quirk for bamboo touch with 2 low res touches */
Henrik Rydbergcb734c02010-09-05 12:53:16 -07001325 if (features->type == BAMBOO_PT &&
Chris Bagwell73149ab2011-10-26 22:34:21 -07001326 features->pktlen == WACOM_PKGLEN_BBTOUCH) {
Henrik Rydbergf4ccbef2010-09-05 12:57:13 -07001327 features->x_max <<= 5;
1328 features->y_max <<= 5;
1329 features->x_fuzz <<= 5;
1330 features->y_fuzz <<= 5;
Henrik Rydbergf4ccbef2010-09-05 12:57:13 -07001331 features->quirks |= WACOM_QUIRK_BBTOUCH_LOWRES;
Henrik Rydbergcb734c02010-09-05 12:53:16 -07001332 }
Chris Bagwelld3825d52012-03-25 23:26:11 -07001333
1334 if (features->type == WIRELESS) {
1335
1336 /* monitor never has input and pen/touch have delayed create */
1337 features->quirks |= WACOM_QUIRK_NO_INPUT;
1338
1339 /* must be monitor interface if no device_type set */
1340 if (!features->device_type)
1341 features->quirks |= WACOM_QUIRK_MONITOR;
1342 }
Henrik Rydbergbc73dd32010-09-05 12:26:16 -07001343}
1344
Ping Cheng409550f2011-01-25 18:03:13 -08001345static unsigned int wacom_calculate_touch_res(unsigned int logical_max,
1346 unsigned int physical_max)
1347{
1348 /* Touch physical dimensions are in 100th of mm */
1349 return (logical_max * 100) / physical_max;
1350}
1351
Ping Cheng19635182012-04-29 21:09:18 -07001352int wacom_setup_input_capabilities(struct input_dev *input_dev,
1353 struct wacom_wac *wacom_wac)
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -07001354{
1355 struct wacom_features *features = &wacom_wac->features;
1356 int i;
1357
1358 input_dev->evbit[0] |= BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS);
1359
1360 __set_bit(BTN_TOUCH, input_dev->keybit);
1361
Henrik Rydbergfed87e62010-09-05 12:25:11 -07001362 input_set_abs_params(input_dev, ABS_X, 0, features->x_max,
1363 features->x_fuzz, 0);
1364 input_set_abs_params(input_dev, ABS_Y, 0, features->y_max,
1365 features->y_fuzz, 0);
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -07001366
Ping Chenge35fb8c2011-03-26 21:16:05 -07001367 if (features->device_type == BTN_TOOL_PEN) {
Ping Chengcfb7d552011-08-26 23:10:02 -07001368 input_set_abs_params(input_dev, ABS_PRESSURE, 0, features->pressure_max,
1369 features->pressure_fuzz, 0);
1370
Ping Chenge35fb8c2011-03-26 21:16:05 -07001371 /* penabled devices have fixed resolution for each model */
1372 input_abs_set_res(input_dev, ABS_X, features->x_resolution);
1373 input_abs_set_res(input_dev, ABS_Y, features->y_resolution);
1374 } else {
1375 input_abs_set_res(input_dev, ABS_X,
1376 wacom_calculate_touch_res(features->x_max,
1377 features->x_phy));
1378 input_abs_set_res(input_dev, ABS_Y,
1379 wacom_calculate_touch_res(features->y_max,
1380 features->y_phy));
1381 }
1382
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -07001383 __set_bit(ABS_MISC, input_dev->absbit);
1384
Jason Childse33da8a2010-02-17 22:38:31 -08001385 switch (wacom_wac->features.type) {
Dmitry Torokhov73a97f42010-03-19 22:18:15 -07001386 case WACOM_MO:
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -07001387 input_set_abs_params(input_dev, ABS_WHEEL, 0, 71, 0, 0);
1388 /* fall through */
Ping Chengec67bbe2009-12-15 00:35:24 -08001389
Dmitry Torokhov73a97f42010-03-19 22:18:15 -07001390 case WACOM_G4:
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -07001391 input_set_capability(input_dev, EV_MSC, MSC_SERIAL);
1392
Ping Cheng0bd10ef2011-07-06 18:05:42 -07001393 __set_bit(BTN_BACK, input_dev->keybit);
1394 __set_bit(BTN_FORWARD, input_dev->keybit);
Dmitry Torokhov73a97f42010-03-19 22:18:15 -07001395 /* fall through */
1396
1397 case GRAPHIRE:
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -07001398 input_set_capability(input_dev, EV_REL, REL_WHEEL);
1399
1400 __set_bit(BTN_LEFT, input_dev->keybit);
1401 __set_bit(BTN_RIGHT, input_dev->keybit);
1402 __set_bit(BTN_MIDDLE, input_dev->keybit);
1403
1404 __set_bit(BTN_TOOL_RUBBER, input_dev->keybit);
1405 __set_bit(BTN_TOOL_PEN, input_dev->keybit);
1406 __set_bit(BTN_TOOL_MOUSE, input_dev->keybit);
1407 __set_bit(BTN_STYLUS, input_dev->keybit);
1408 __set_bit(BTN_STYLUS2, input_dev->keybit);
Jason Gerecke35120692011-09-08 09:38:14 -07001409
1410 __set_bit(INPUT_PROP_POINTER, input_dev->propbit);
Dmitry Torokhov73a97f42010-03-19 22:18:15 -07001411 break;
1412
Jason Gerecke803296b2011-12-12 00:11:45 -08001413 case WACOM_24HD:
1414 __set_bit(BTN_A, input_dev->keybit);
1415 __set_bit(BTN_B, input_dev->keybit);
1416 __set_bit(BTN_C, input_dev->keybit);
1417 __set_bit(BTN_X, input_dev->keybit);
1418 __set_bit(BTN_Y, input_dev->keybit);
1419 __set_bit(BTN_Z, input_dev->keybit);
1420
1421 for (i = 0; i < 10; i++)
1422 __set_bit(BTN_0 + i, input_dev->keybit);
1423
1424 __set_bit(KEY_PROG1, input_dev->keybit);
1425 __set_bit(KEY_PROG2, input_dev->keybit);
1426 __set_bit(KEY_PROG3, input_dev->keybit);
1427
1428 input_set_abs_params(input_dev, ABS_Z, -900, 899, 0, 0);
1429 input_set_abs_params(input_dev, ABS_THROTTLE, 0, 71, 0, 0);
1430 wacom_setup_cintiq(wacom_wac);
1431 break;
1432
Ping Cheng3a4b4aa2010-06-03 22:10:21 -07001433 case WACOM_21UX2:
1434 __set_bit(BTN_A, input_dev->keybit);
1435 __set_bit(BTN_B, input_dev->keybit);
1436 __set_bit(BTN_C, input_dev->keybit);
1437 __set_bit(BTN_X, input_dev->keybit);
1438 __set_bit(BTN_Y, input_dev->keybit);
1439 __set_bit(BTN_Z, input_dev->keybit);
1440 __set_bit(BTN_BASE, input_dev->keybit);
1441 __set_bit(BTN_BASE2, input_dev->keybit);
1442 /* fall through */
1443
Dmitry Torokhov73a97f42010-03-19 22:18:15 -07001444 case WACOM_BEE:
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -07001445 __set_bit(BTN_8, input_dev->keybit);
1446 __set_bit(BTN_9, input_dev->keybit);
1447 /* fall through */
Dmitry Torokhov73a97f42010-03-19 22:18:15 -07001448
Ping Cheng6521d0b2010-10-24 21:53:40 -07001449 case CINTIQ:
1450 for (i = 0; i < 8; i++)
1451 __set_bit(BTN_0 + i, input_dev->keybit);
Ping Cheng6521d0b2010-10-24 21:53:40 -07001452
Jason Gerecked6069da2011-10-04 22:50:45 -07001453 input_set_abs_params(input_dev, ABS_RX, 0, 4096, 0, 0);
1454 input_set_abs_params(input_dev, ABS_RY, 0, 4096, 0, 0);
Ping Cheng6521d0b2010-10-24 21:53:40 -07001455 input_set_abs_params(input_dev, ABS_Z, -900, 899, 0, 0);
Jason Gerecke35120692011-09-08 09:38:14 -07001456
1457 __set_bit(INPUT_PROP_DIRECT, input_dev->propbit);
1458
Ping Cheng6521d0b2010-10-24 21:53:40 -07001459 wacom_setup_cintiq(wacom_wac);
1460 break;
1461
Dmitry Torokhov73a97f42010-03-19 22:18:15 -07001462 case INTUOS3:
1463 case INTUOS3L:
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -07001464 __set_bit(BTN_4, input_dev->keybit);
1465 __set_bit(BTN_5, input_dev->keybit);
1466 __set_bit(BTN_6, input_dev->keybit);
1467 __set_bit(BTN_7, input_dev->keybit);
1468
1469 input_set_abs_params(input_dev, ABS_RY, 0, 4096, 0, 0);
Dmitry Torokhov73a97f42010-03-19 22:18:15 -07001470 /* fall through */
1471
1472 case INTUOS3S:
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -07001473 __set_bit(BTN_0, input_dev->keybit);
1474 __set_bit(BTN_1, input_dev->keybit);
1475 __set_bit(BTN_2, input_dev->keybit);
1476 __set_bit(BTN_3, input_dev->keybit);
1477
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -07001478 input_set_abs_params(input_dev, ABS_RX, 0, 4096, 0, 0);
1479 input_set_abs_params(input_dev, ABS_Z, -900, 899, 0, 0);
Dmitry Torokhov73a97f42010-03-19 22:18:15 -07001480 /* fall through */
1481
1482 case INTUOS:
Jason Gerecke35120692011-09-08 09:38:14 -07001483 __set_bit(INPUT_PROP_POINTER, input_dev->propbit);
1484
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -07001485 wacom_setup_intuos(wacom_wac);
Dmitry Torokhov73a97f42010-03-19 22:18:15 -07001486 break;
1487
Jason Gerecke9fee6192012-04-03 15:47:22 -07001488 case INTUOS5:
1489 case INTUOS5L:
Jason Gereckeae584ca2012-04-03 15:50:40 -07001490 if (features->device_type == BTN_TOOL_PEN) {
1491 __set_bit(BTN_7, input_dev->keybit);
1492 __set_bit(BTN_8, input_dev->keybit);
1493 }
1494 /* fall through */
1495
1496 case INTUOS5S:
1497 __set_bit(INPUT_PROP_POINTER, input_dev->propbit);
1498
1499 if (features->device_type == BTN_TOOL_PEN) {
1500 for (i = 0; i < 7; i++)
1501 __set_bit(BTN_0 + i, input_dev->keybit);
1502
1503 input_set_abs_params(input_dev, ABS_DISTANCE, 0,
1504 features->distance_max,
1505 0, 0);
1506
1507 input_set_abs_params(input_dev, ABS_Z, -900, 899, 0, 0);
1508
1509 wacom_setup_intuos(wacom_wac);
1510 } else if (features->device_type == BTN_TOOL_FINGER) {
1511 __clear_bit(ABS_MISC, input_dev->absbit);
1512
1513 __set_bit(BTN_TOOL_FINGER, input_dev->keybit);
1514 __set_bit(BTN_TOOL_DOUBLETAP, input_dev->keybit);
1515 __set_bit(BTN_TOOL_TRIPLETAP, input_dev->keybit);
1516 __set_bit(BTN_TOOL_QUADTAP, input_dev->keybit);
1517
Ping Chengf393ee22012-04-29 21:09:17 -07001518 input_mt_init_slots(input_dev, features->touch_max);
Jason Gereckeae584ca2012-04-03 15:50:40 -07001519
1520 input_set_abs_params(input_dev, ABS_MT_TOUCH_MAJOR,
1521 0, 255, 0, 0);
1522
1523 input_set_abs_params(input_dev, ABS_MT_POSITION_X,
1524 0, features->x_max,
1525 features->x_fuzz, 0);
1526 input_set_abs_params(input_dev, ABS_MT_POSITION_Y,
1527 0, features->y_max,
1528 features->y_fuzz, 0);
1529 }
1530 break;
1531
Dmitry Torokhov73a97f42010-03-19 22:18:15 -07001532 case INTUOS4:
1533 case INTUOS4L:
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -07001534 __set_bit(BTN_7, input_dev->keybit);
1535 __set_bit(BTN_8, input_dev->keybit);
Dmitry Torokhov73a97f42010-03-19 22:18:15 -07001536 /* fall through */
1537
1538 case INTUOS4S:
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -07001539 for (i = 0; i < 7; i++)
1540 __set_bit(BTN_0 + i, input_dev->keybit);
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -07001541
1542 input_set_abs_params(input_dev, ABS_Z, -900, 899, 0, 0);
1543 wacom_setup_intuos(wacom_wac);
Jason Gerecke35120692011-09-08 09:38:14 -07001544
1545 __set_bit(INPUT_PROP_POINTER, input_dev->propbit);
Dmitry Torokhov73a97f42010-03-19 22:18:15 -07001546 break;
1547
1548 case TABLETPC2FG:
Ping Cheng19635182012-04-29 21:09:18 -07001549 case MTSCREEN:
Ping Cheng8b4a0c12012-01-31 00:07:33 -08001550 if (features->device_type == BTN_TOOL_FINGER) {
Ping Cheng84eb5aa2011-03-12 20:35:18 -08001551
Ping Cheng19635182012-04-29 21:09:18 -07001552 wacom_wac->slots = kmalloc(features->touch_max *
1553 sizeof(int),
1554 GFP_KERNEL);
1555 if (!wacom_wac->slots)
1556 return -ENOMEM;
1557
1558 for (i = 0; i < features->touch_max; i++)
1559 wacom_wac->slots[i] = -1;
1560
Ping Chengf393ee22012-04-29 21:09:17 -07001561 input_mt_init_slots(input_dev, features->touch_max);
Ping Cheng84eb5aa2011-03-12 20:35:18 -08001562 input_set_abs_params(input_dev, ABS_MT_TOOL_TYPE,
1563 0, MT_TOOL_MAX, 0, 0);
1564 input_set_abs_params(input_dev, ABS_MT_POSITION_X,
1565 0, features->x_max, 0, 0);
1566 input_set_abs_params(input_dev, ABS_MT_POSITION_Y,
1567 0, features->y_max, 0, 0);
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -07001568 }
Dmitry Torokhov73a97f42010-03-19 22:18:15 -07001569 /* fall through */
1570
1571 case TABLETPC:
Ping Chenga43c7c52011-03-12 20:34:42 -08001572 __clear_bit(ABS_MISC, input_dev->absbit);
1573
Jason Gerecke35120692011-09-08 09:38:14 -07001574 __set_bit(INPUT_PROP_DIRECT, input_dev->propbit);
1575
Ping Chenge35fb8c2011-03-26 21:16:05 -07001576 if (features->device_type != BTN_TOOL_PEN)
Dmitry Torokhov73a97f42010-03-19 22:18:15 -07001577 break; /* no need to process stylus stuff */
Ping Chenge35fb8c2011-03-26 21:16:05 -07001578
Dmitry Torokhov73a97f42010-03-19 22:18:15 -07001579 /* fall through */
1580
1581 case PL:
Ping Chengc8f2edc2010-06-28 01:10:51 -07001582 case DTU:
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -07001583 __set_bit(BTN_TOOL_PEN, input_dev->keybit);
Jason Gerecke35120692011-09-08 09:38:14 -07001584 __set_bit(BTN_TOOL_RUBBER, input_dev->keybit);
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -07001585 __set_bit(BTN_STYLUS, input_dev->keybit);
1586 __set_bit(BTN_STYLUS2, input_dev->keybit);
Jason Gerecke35120692011-09-08 09:38:14 -07001587
1588 __set_bit(INPUT_PROP_DIRECT, input_dev->propbit);
1589 break;
1590
1591 case PTU:
Dmitry Torokhov73a97f42010-03-19 22:18:15 -07001592 __set_bit(BTN_STYLUS2, input_dev->keybit);
1593 /* fall through */
1594
1595 case PENPARTNER:
Jason Gerecke1fab84a2011-08-26 23:18:22 -07001596 __set_bit(BTN_TOOL_PEN, input_dev->keybit);
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -07001597 __set_bit(BTN_TOOL_RUBBER, input_dev->keybit);
Jason Gerecke1fab84a2011-08-26 23:18:22 -07001598 __set_bit(BTN_STYLUS, input_dev->keybit);
Jason Gerecke35120692011-09-08 09:38:14 -07001599
1600 __set_bit(INPUT_PROP_POINTER, input_dev->propbit);
Dmitry Torokhov73a97f42010-03-19 22:18:15 -07001601 break;
Henrik Rydbergcb734c02010-09-05 12:53:16 -07001602
1603 case BAMBOO_PT:
1604 __clear_bit(ABS_MISC, input_dev->absbit);
1605
Jason Gerecke35120692011-09-08 09:38:14 -07001606 __set_bit(INPUT_PROP_POINTER, input_dev->propbit);
1607
Ping Cheng8b4a0c12012-01-31 00:07:33 -08001608 if (features->device_type == BTN_TOOL_FINGER) {
Henrik Rydbergcb734c02010-09-05 12:53:16 -07001609 __set_bit(BTN_LEFT, input_dev->keybit);
1610 __set_bit(BTN_FORWARD, input_dev->keybit);
1611 __set_bit(BTN_BACK, input_dev->keybit);
1612 __set_bit(BTN_RIGHT, input_dev->keybit);
1613
1614 __set_bit(BTN_TOOL_FINGER, input_dev->keybit);
1615 __set_bit(BTN_TOOL_DOUBLETAP, input_dev->keybit);
Ping Chengf393ee22012-04-29 21:09:17 -07001616 input_mt_init_slots(input_dev, features->touch_max);
Henrik Rydbergcb734c02010-09-05 12:53:16 -07001617
Chris Bagwell73149ab2011-10-26 22:34:21 -07001618 if (features->pktlen == WACOM_PKGLEN_BBTOUCH3) {
1619 __set_bit(BTN_TOOL_TRIPLETAP,
1620 input_dev->keybit);
1621 __set_bit(BTN_TOOL_QUADTAP,
1622 input_dev->keybit);
1623
Chris Bagwell73149ab2011-10-26 22:34:21 -07001624 input_set_abs_params(input_dev,
1625 ABS_MT_TOUCH_MAJOR,
1626 0, 255, 0, 0);
Chris Bagwell73149ab2011-10-26 22:34:21 -07001627 }
1628
Henrik Rydbergcb734c02010-09-05 12:53:16 -07001629 input_set_abs_params(input_dev, ABS_MT_POSITION_X,
1630 0, features->x_max,
1631 features->x_fuzz, 0);
1632 input_set_abs_params(input_dev, ABS_MT_POSITION_Y,
1633 0, features->y_max,
1634 features->y_fuzz, 0);
Chris Bagwell2aaacb12010-09-12 00:11:35 -07001635 } else if (features->device_type == BTN_TOOL_PEN) {
1636 __set_bit(BTN_TOOL_RUBBER, input_dev->keybit);
1637 __set_bit(BTN_TOOL_PEN, input_dev->keybit);
1638 __set_bit(BTN_STYLUS, input_dev->keybit);
1639 __set_bit(BTN_STYLUS2, input_dev->keybit);
Chris Bagwellc18c2ce2011-10-10 08:52:13 -07001640 input_set_abs_params(input_dev, ABS_DISTANCE, 0,
1641 features->distance_max,
1642 0, 0);
Henrik Rydbergcb734c02010-09-05 12:53:16 -07001643 }
1644 break;
Ping Cheng3bea7332006-07-13 18:01:36 -07001645 }
Ping Cheng19635182012-04-29 21:09:18 -07001646 return 0;
Ping Cheng3bea7332006-07-13 18:01:36 -07001647}
1648
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001649static const struct wacom_features wacom_features_0x00 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001650 { "Wacom Penpartner", WACOM_PKGLEN_PENPRTN, 5040, 3780, 255,
1651 0, PENPARTNER, WACOM_PENPRTN_RES, WACOM_PENPRTN_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001652static const struct wacom_features wacom_features_0x10 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001653 { "Wacom Graphire", WACOM_PKGLEN_GRAPHIRE, 10206, 7422, 511,
1654 63, GRAPHIRE, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001655static const struct wacom_features wacom_features_0x11 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001656 { "Wacom Graphire2 4x5", 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_0x12 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001659 { "Wacom Graphire2 5x7", WACOM_PKGLEN_GRAPHIRE, 13918, 10206, 511,
1660 63, GRAPHIRE, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001661static const struct wacom_features wacom_features_0x13 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001662 { "Wacom Graphire3", WACOM_PKGLEN_GRAPHIRE, 10208, 7424, 511,
1663 63, GRAPHIRE, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001664static const struct wacom_features wacom_features_0x14 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001665 { "Wacom Graphire3 6x8", WACOM_PKGLEN_GRAPHIRE, 16704, 12064, 511,
1666 63, GRAPHIRE, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001667static const struct wacom_features wacom_features_0x15 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001668 { "Wacom Graphire4 4x5", WACOM_PKGLEN_GRAPHIRE, 10208, 7424, 511,
1669 63, WACOM_G4, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001670static const struct wacom_features wacom_features_0x16 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001671 { "Wacom Graphire4 6x8", WACOM_PKGLEN_GRAPHIRE, 16704, 12064, 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_0x17 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001674 { "Wacom BambooFun 4x5", WACOM_PKGLEN_BBFUN, 14760, 9225, 511,
1675 63, WACOM_MO, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001676static const struct wacom_features wacom_features_0x18 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001677 { "Wacom BambooFun 6x8", WACOM_PKGLEN_BBFUN, 21648, 13530, 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_0x19 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001680 { "Wacom Bamboo1 Medium", WACOM_PKGLEN_GRAPHIRE, 16704, 12064, 511,
1681 63, GRAPHIRE, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001682static const struct wacom_features wacom_features_0x60 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001683 { "Wacom Volito", WACOM_PKGLEN_GRAPHIRE, 5104, 3712, 511,
1684 63, GRAPHIRE, WACOM_VOLITO_RES, WACOM_VOLITO_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001685static const struct wacom_features wacom_features_0x61 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001686 { "Wacom PenStation2", WACOM_PKGLEN_GRAPHIRE, 3250, 2320, 255,
1687 63, GRAPHIRE, WACOM_VOLITO_RES, WACOM_VOLITO_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001688static const struct wacom_features wacom_features_0x62 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001689 { "Wacom Volito2 4x5", WACOM_PKGLEN_GRAPHIRE, 5104, 3712, 511,
1690 63, GRAPHIRE, WACOM_VOLITO_RES, WACOM_VOLITO_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001691static const struct wacom_features wacom_features_0x63 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001692 { "Wacom Volito2 2x3", WACOM_PKGLEN_GRAPHIRE, 3248, 2320, 511,
1693 63, GRAPHIRE, WACOM_VOLITO_RES, WACOM_VOLITO_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001694static const struct wacom_features wacom_features_0x64 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001695 { "Wacom PenPartner2", WACOM_PKGLEN_GRAPHIRE, 3250, 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_0x65 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001698 { "Wacom Bamboo", WACOM_PKGLEN_BBFUN, 14760, 9225, 511,
1699 63, WACOM_MO, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001700static const struct wacom_features wacom_features_0x69 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001701 { "Wacom Bamboo1", WACOM_PKGLEN_GRAPHIRE, 5104, 3712, 511,
1702 63, GRAPHIRE, WACOM_PENPRTN_RES, WACOM_PENPRTN_RES };
Ping Cheng11d0cf82011-06-27 12:57:58 -07001703static const struct wacom_features wacom_features_0x6A =
1704 { "Wacom Bamboo1 4x6", WACOM_PKGLEN_GRAPHIRE, 14760, 9225, 1023,
1705 63, GRAPHIRE, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
1706static const struct wacom_features wacom_features_0x6B =
1707 { "Wacom Bamboo1 5x8", WACOM_PKGLEN_GRAPHIRE, 21648, 13530, 1023,
1708 63, GRAPHIRE, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001709static const struct wacom_features wacom_features_0x20 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001710 { "Wacom Intuos 4x5", WACOM_PKGLEN_INTUOS, 12700, 10600, 1023,
1711 31, INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001712static const struct wacom_features wacom_features_0x21 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001713 { "Wacom Intuos 6x8", WACOM_PKGLEN_INTUOS, 20320, 16240, 1023,
1714 31, INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001715static const struct wacom_features wacom_features_0x22 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001716 { "Wacom Intuos 9x12", WACOM_PKGLEN_INTUOS, 30480, 24060, 1023,
1717 31, INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001718static const struct wacom_features wacom_features_0x23 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001719 { "Wacom Intuos 12x12", WACOM_PKGLEN_INTUOS, 30480, 31680, 1023,
1720 31, INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001721static const struct wacom_features wacom_features_0x24 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001722 { "Wacom Intuos 12x18", WACOM_PKGLEN_INTUOS, 45720, 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_0x30 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001725 { "Wacom PL400", WACOM_PKGLEN_GRAPHIRE, 5408, 4056, 255,
1726 0, PL, WACOM_PL_RES, WACOM_PL_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001727static const struct wacom_features wacom_features_0x31 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001728 { "Wacom PL500", WACOM_PKGLEN_GRAPHIRE, 6144, 4608, 255,
1729 0, PL, WACOM_PL_RES, WACOM_PL_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001730static const struct wacom_features wacom_features_0x32 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001731 { "Wacom PL600", WACOM_PKGLEN_GRAPHIRE, 6126, 4604, 255,
1732 0, PL, WACOM_PL_RES, WACOM_PL_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001733static const struct wacom_features wacom_features_0x33 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001734 { "Wacom PL600SX", WACOM_PKGLEN_GRAPHIRE, 6260, 5016, 255,
1735 0, PL, WACOM_PL_RES, WACOM_PL_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001736static const struct wacom_features wacom_features_0x34 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001737 { "Wacom PL550", WACOM_PKGLEN_GRAPHIRE, 6144, 4608, 511,
1738 0, PL, WACOM_PL_RES, WACOM_PL_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001739static const struct wacom_features wacom_features_0x35 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001740 { "Wacom PL800", WACOM_PKGLEN_GRAPHIRE, 7220, 5780, 511,
1741 0, PL, WACOM_PL_RES, WACOM_PL_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001742static const struct wacom_features wacom_features_0x37 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001743 { "Wacom PL700", WACOM_PKGLEN_GRAPHIRE, 6758, 5406, 511,
1744 0, PL, WACOM_PL_RES, WACOM_PL_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001745static const struct wacom_features wacom_features_0x38 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001746 { "Wacom PL510", WACOM_PKGLEN_GRAPHIRE, 6282, 4762, 511,
1747 0, PL, WACOM_PL_RES, WACOM_PL_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001748static const struct wacom_features wacom_features_0x39 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001749 { "Wacom DTU710", WACOM_PKGLEN_GRAPHIRE, 34080, 27660, 511,
1750 0, PL, WACOM_PL_RES, WACOM_PL_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001751static const struct wacom_features wacom_features_0xC4 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001752 { "Wacom DTF521", WACOM_PKGLEN_GRAPHIRE, 6282, 4762, 511,
1753 0, PL, WACOM_PL_RES, WACOM_PL_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001754static const struct wacom_features wacom_features_0xC0 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001755 { "Wacom DTF720", WACOM_PKGLEN_GRAPHIRE, 6858, 5506, 511,
1756 0, PL, WACOM_PL_RES, WACOM_PL_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001757static const struct wacom_features wacom_features_0xC2 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001758 { "Wacom DTF720a", 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_0x03 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001761 { "Wacom Cintiq Partner", WACOM_PKGLEN_GRAPHIRE, 20480, 15360, 511,
1762 0, PTU, WACOM_PL_RES, WACOM_PL_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001763static const struct wacom_features wacom_features_0x41 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001764 { "Wacom Intuos2 4x5", WACOM_PKGLEN_INTUOS, 12700, 10600, 1023,
1765 31, INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001766static const struct wacom_features wacom_features_0x42 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001767 { "Wacom Intuos2 6x8", WACOM_PKGLEN_INTUOS, 20320, 16240, 1023,
1768 31, INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001769static const struct wacom_features wacom_features_0x43 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001770 { "Wacom Intuos2 9x12", WACOM_PKGLEN_INTUOS, 30480, 24060, 1023,
1771 31, INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001772static const struct wacom_features wacom_features_0x44 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001773 { "Wacom Intuos2 12x12", WACOM_PKGLEN_INTUOS, 30480, 31680, 1023,
1774 31, INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001775static const struct wacom_features wacom_features_0x45 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001776 { "Wacom Intuos2 12x18", WACOM_PKGLEN_INTUOS, 45720, 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_0xB0 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001779 { "Wacom Intuos3 4x5", WACOM_PKGLEN_INTUOS, 25400, 20320, 1023,
1780 63, INTUOS3S, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001781static const struct wacom_features wacom_features_0xB1 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001782 { "Wacom Intuos3 6x8", WACOM_PKGLEN_INTUOS, 40640, 30480, 1023,
1783 63, INTUOS3, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001784static const struct wacom_features wacom_features_0xB2 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001785 { "Wacom Intuos3 9x12", WACOM_PKGLEN_INTUOS, 60960, 45720, 1023,
1786 63, INTUOS3, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001787static const struct wacom_features wacom_features_0xB3 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001788 { "Wacom Intuos3 12x12", WACOM_PKGLEN_INTUOS, 60960, 60960, 1023,
1789 63, INTUOS3L, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001790static const struct wacom_features wacom_features_0xB4 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001791 { "Wacom Intuos3 12x19", WACOM_PKGLEN_INTUOS, 97536, 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_0xB5 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001794 { "Wacom Intuos3 6x11", WACOM_PKGLEN_INTUOS, 54204, 31750, 1023,
1795 63, INTUOS3, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001796static const struct wacom_features wacom_features_0xB7 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001797 { "Wacom Intuos3 4x6", WACOM_PKGLEN_INTUOS, 31496, 19685, 1023,
1798 63, INTUOS3S, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001799static const struct wacom_features wacom_features_0xB8 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001800 { "Wacom Intuos4 4x6", WACOM_PKGLEN_INTUOS, 31496, 19685, 2047,
1801 63, INTUOS4S, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001802static const struct wacom_features wacom_features_0xB9 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001803 { "Wacom Intuos4 6x9", WACOM_PKGLEN_INTUOS, 44704, 27940, 2047,
1804 63, INTUOS4, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001805static const struct wacom_features wacom_features_0xBA =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001806 { "Wacom Intuos4 8x13", WACOM_PKGLEN_INTUOS, 65024, 40640, 2047,
1807 63, INTUOS4L, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001808static const struct wacom_features wacom_features_0xBB =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001809 { "Wacom Intuos4 12x19", WACOM_PKGLEN_INTUOS, 97536, 60960, 2047,
1810 63, INTUOS4L, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
Ping Cheng3a4b4aa2010-06-03 22:10:21 -07001811static const struct wacom_features wacom_features_0xBC =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001812 { "Wacom Intuos4 WL", WACOM_PKGLEN_INTUOS, 40840, 25400, 2047,
1813 63, INTUOS4, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
Jason Gerecke9fee6192012-04-03 15:47:22 -07001814static const struct wacom_features wacom_features_0x26 =
1815 { "Wacom Intuos5 touch S", WACOM_PKGLEN_INTUOS, 31496, 19685, 2047,
Ping Chengf393ee22012-04-29 21:09:17 -07001816 63, INTUOS5S, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES,
1817 .touch_max = 16 };
Jason Gerecke9fee6192012-04-03 15:47:22 -07001818static const struct wacom_features wacom_features_0x27 =
1819 { "Wacom Intuos5 touch M", WACOM_PKGLEN_INTUOS, 44704, 27940, 2047,
Ping Chengf393ee22012-04-29 21:09:17 -07001820 63, INTUOS5, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES,
1821 .touch_max = 16 };
Jason Gerecke9fee6192012-04-03 15:47:22 -07001822static const struct wacom_features wacom_features_0x28 =
1823 { "Wacom Intuos5 touch L", WACOM_PKGLEN_INTUOS, 65024, 40640, 2047,
Ping Chengf393ee22012-04-29 21:09:17 -07001824 63, INTUOS5L, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES,
1825 .touch_max = 16 };
Jason Gerecke9fee6192012-04-03 15:47:22 -07001826static const struct wacom_features wacom_features_0x29 =
1827 { "Wacom Intuos5 S", WACOM_PKGLEN_INTUOS, 31496, 19685, 2047,
1828 63, INTUOS5S, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
1829static const struct wacom_features wacom_features_0x2A =
1830 { "Wacom Intuos5 M", WACOM_PKGLEN_INTUOS, 44704, 27940, 2047,
1831 63, INTUOS5, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
Jason Gerecke803296b2011-12-12 00:11:45 -08001832static const struct wacom_features wacom_features_0xF4 =
1833 { "Wacom Cintiq 24HD", WACOM_PKGLEN_INTUOS, 104480, 65600, 2047,
1834 63, WACOM_24HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001835static const struct wacom_features wacom_features_0x3F =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001836 { "Wacom Cintiq 21UX", WACOM_PKGLEN_INTUOS, 87200, 65600, 1023,
1837 63, CINTIQ, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001838static const struct wacom_features wacom_features_0xC5 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001839 { "Wacom Cintiq 20WSX", WACOM_PKGLEN_INTUOS, 86680, 54180, 1023,
1840 63, WACOM_BEE, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001841static const struct wacom_features wacom_features_0xC6 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001842 { "Wacom Cintiq 12WX", WACOM_PKGLEN_INTUOS, 53020, 33440, 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_0xC7 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001845 { "Wacom DTU1931", WACOM_PKGLEN_GRAPHIRE, 37832, 30305, 511,
1846 0, PL, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Ping Chengc8f2edc2010-06-28 01:10:51 -07001847static const struct wacom_features wacom_features_0xCE =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001848 { "Wacom DTU2231", WACOM_PKGLEN_GRAPHIRE, 47864, 27011, 511,
1849 0, DTU, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Ping Chengc8f2edc2010-06-28 01:10:51 -07001850static const struct wacom_features wacom_features_0xF0 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001851 { "Wacom DTU1631", WACOM_PKGLEN_GRAPHIRE, 34623, 19553, 511,
1852 0, DTU, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Ping Cheng3a4b4aa2010-06-03 22:10:21 -07001853static const struct wacom_features wacom_features_0xCC =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001854 { "Wacom Cintiq 21UX2", WACOM_PKGLEN_INTUOS, 87200, 65600, 2047,
1855 63, WACOM_21UX2, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001856static const struct wacom_features wacom_features_0x90 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001857 { "Wacom ISDv4 90", WACOM_PKGLEN_GRAPHIRE, 26202, 16325, 255,
1858 0, TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001859static const struct wacom_features wacom_features_0x93 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001860 { "Wacom ISDv4 93", WACOM_PKGLEN_GRAPHIRE, 26202, 16325, 255,
1861 0, TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Ping Cheng11d0cf82011-06-27 12:57:58 -07001862static const struct wacom_features wacom_features_0x97 =
1863 { "Wacom ISDv4 97", WACOM_PKGLEN_GRAPHIRE, 26202, 16325, 511,
1864 0, TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001865static const struct wacom_features wacom_features_0x9A =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001866 { "Wacom ISDv4 9A", WACOM_PKGLEN_GRAPHIRE, 26202, 16325, 255,
1867 0, TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001868static const struct wacom_features wacom_features_0x9F =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001869 { "Wacom ISDv4 9F", 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_0xE2 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001872 { "Wacom ISDv4 E2", WACOM_PKGLEN_TPC2FG, 26202, 16325, 255,
Ping Chengf393ee22012-04-29 21:09:17 -07001873 0, TABLETPC2FG, WACOM_INTUOS_RES, WACOM_INTUOS_RES,
1874 .touch_max = 2 };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001875static const struct wacom_features wacom_features_0xE3 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001876 { "Wacom ISDv4 E3", WACOM_PKGLEN_TPC2FG, 26202, 16325, 255,
Ping Chengf393ee22012-04-29 21:09:17 -07001877 0, TABLETPC2FG, WACOM_INTUOS_RES, WACOM_INTUOS_RES,
1878 .touch_max = 2 };
Ping Cheng19635182012-04-29 21:09:18 -07001879static const struct wacom_features wacom_features_0xE5 =
1880 { "Wacom ISDv4 E5", WACOM_PKGLEN_MTOUCH, 26202, 16325, 255,
1881 0, MTSCREEN, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Manoj Iyer26fcd2a2011-03-31 22:39:43 -07001882static const struct wacom_features wacom_features_0xE6 =
1883 { "Wacom ISDv4 E6", WACOM_PKGLEN_TPC2FG, 27760, 15694, 255,
Ping Chengf393ee22012-04-29 21:09:17 -07001884 0, TABLETPC2FG, WACOM_INTUOS_RES, WACOM_INTUOS_RES,
1885 .touch_max = 2 };
Chris Bagwell0d0e3062011-12-11 23:50:59 -08001886static const struct wacom_features wacom_features_0xEC =
1887 { "Wacom ISDv4 EC", WACOM_PKGLEN_GRAPHIRE, 25710, 14500, 255,
1888 0, TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001889static const struct wacom_features wacom_features_0x47 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001890 { "Wacom Intuos2 6x8", WACOM_PKGLEN_INTUOS, 20320, 16240, 1023,
1891 31, INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Chris Bagwelld3825d52012-03-25 23:26:11 -07001892static const struct wacom_features wacom_features_0x84 =
1893 { "Wacom Wireless Receiver", WACOM_PKGLEN_WIRELESS, 0, 0, 0,
Ping Chengf393ee22012-04-29 21:09:17 -07001894 0, WIRELESS, 0, 0, .touch_max = 16 };
Ping Cheng7b824bb2011-03-26 21:16:04 -07001895static const struct wacom_features wacom_features_0xD0 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001896 { "Wacom Bamboo 2FG", WACOM_PKGLEN_BBFUN, 14720, 9200, 1023,
Ping Chengf393ee22012-04-29 21:09:17 -07001897 31, BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES,
1898 .touch_max = 2 };
Ping Cheng7b824bb2011-03-26 21:16:04 -07001899static const struct wacom_features wacom_features_0xD1 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001900 { "Wacom Bamboo 2FG 4x5", WACOM_PKGLEN_BBFUN, 14720, 9200, 1023,
Ping Chengf393ee22012-04-29 21:09:17 -07001901 31, BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES,
1902 .touch_max = 2 };
Ping Cheng7b824bb2011-03-26 21:16:04 -07001903static const struct wacom_features wacom_features_0xD2 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001904 { "Wacom Bamboo Craft", WACOM_PKGLEN_BBFUN, 14720, 9200, 1023,
Chris Bagwellc18c2ce2011-10-10 08:52:13 -07001905 31, BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Ping Cheng7b824bb2011-03-26 21:16:04 -07001906static const struct wacom_features wacom_features_0xD3 =
Chris Bagwellae927562011-10-10 08:52:32 -07001907 { "Wacom Bamboo 2FG 6x8", WACOM_PKGLEN_BBFUN, 21648, 13700, 1023,
Ping Chengf393ee22012-04-29 21:09:17 -07001908 31, BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES,
1909 .touch_max = 2 };
Kevin Granade57a78722010-12-10 23:04:02 -08001910static const struct wacom_features wacom_features_0xD4 =
Ping Chenga001a8f2011-06-27 12:57:58 -07001911 { "Wacom Bamboo Pen", WACOM_PKGLEN_BBFUN, 14720, 9200, 1023,
Chris Bagwellc18c2ce2011-10-10 08:52:13 -07001912 31, BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Gerard Braad18adad12011-08-16 00:17:56 -07001913static const struct wacom_features wacom_features_0xD5 =
Chris Bagwellae927562011-10-10 08:52:32 -07001914 { "Wacom Bamboo Pen 6x8", WACOM_PKGLEN_BBFUN, 21648, 13700, 1023,
Chris Bagwellc18c2ce2011-10-10 08:52:13 -07001915 31, BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Ping Cheng7b824bb2011-03-26 21:16:04 -07001916static const struct wacom_features wacom_features_0xD6 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001917 { "Wacom BambooPT 2FG 4x5", WACOM_PKGLEN_BBFUN, 14720, 9200, 1023,
Ping Chengf393ee22012-04-29 21:09:17 -07001918 31, BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES,
1919 .touch_max = 2 };
Ping Cheng7b824bb2011-03-26 21:16:04 -07001920static const struct wacom_features wacom_features_0xD7 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001921 { "Wacom BambooPT 2FG Small", WACOM_PKGLEN_BBFUN, 14720, 9200, 1023,
Ping Chengf393ee22012-04-29 21:09:17 -07001922 31, BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES,
1923 .touch_max = 2 };
Ping Cheng7b824bb2011-03-26 21:16:04 -07001924static const struct wacom_features wacom_features_0xD8 =
Chris Bagwellae927562011-10-10 08:52:32 -07001925 { "Wacom Bamboo Comic 2FG", WACOM_PKGLEN_BBFUN, 21648, 13700, 1023,
Ping Chengf393ee22012-04-29 21:09:17 -07001926 31, BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES,
1927 .touch_max = 2 };
Ping Cheng7b824bb2011-03-26 21:16:04 -07001928static const struct wacom_features wacom_features_0xDA =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001929 { "Wacom Bamboo 2FG 4x5 SE", WACOM_PKGLEN_BBFUN, 14720, 9200, 1023,
Ping Chengf393ee22012-04-29 21:09:17 -07001930 31, BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES,
1931 .touch_max = 2 };
David Foley47d09232010-12-07 21:05:59 -08001932static struct wacom_features wacom_features_0xDB =
Chris Bagwellae927562011-10-10 08:52:32 -07001933 { "Wacom Bamboo 2FG 6x8 SE", WACOM_PKGLEN_BBFUN, 21648, 13700, 1023,
Ping Chengf393ee22012-04-29 21:09:17 -07001934 31, BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES,
1935 .touch_max = 2 };
Chris Bagwell73149ab2011-10-26 22:34:21 -07001936static const struct wacom_features wacom_features_0xDD =
1937 { "Wacom Bamboo Connect", WACOM_PKGLEN_BBPEN, 14720, 9200, 1023,
1938 31, BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
1939static const struct wacom_features wacom_features_0xDE =
1940 { "Wacom Bamboo 16FG 4x5", WACOM_PKGLEN_BBPEN, 14720, 9200, 1023,
Ping Chengf393ee22012-04-29 21:09:17 -07001941 31, BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES,
1942 .touch_max = 16 };
Chris Bagwell73149ab2011-10-26 22:34:21 -07001943static const struct wacom_features wacom_features_0xDF =
1944 { "Wacom Bamboo 16FG 6x8", WACOM_PKGLEN_BBPEN, 21648, 13700, 1023,
Ping Chengf393ee22012-04-29 21:09:17 -07001945 31, BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES,
1946 .touch_max = 16 };
Ajay Ramaswamy7b4b3062010-12-23 01:19:39 -08001947static const struct wacom_features wacom_features_0x6004 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001948 { "ISD-V4", WACOM_PKGLEN_GRAPHIRE, 12800, 8000, 255,
1949 0, TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Bastian Blankb036f6f2010-02-10 23:06:23 -08001950
1951#define USB_DEVICE_WACOM(prod) \
1952 USB_DEVICE(USB_VENDOR_ID_WACOM, prod), \
1953 .driver_info = (kernel_ulong_t)&wacom_features_##prod
1954
Aristeu Rozanski1483f552011-06-22 01:17:17 -07001955#define USB_DEVICE_DETAILED(prod, class, sub, proto) \
1956 USB_DEVICE_AND_INTERFACE_INFO(USB_VENDOR_ID_WACOM, prod, class, \
1957 sub, proto), \
1958 .driver_info = (kernel_ulong_t)&wacom_features_##prod
1959
Ajay Ramaswamy7b4b3062010-12-23 01:19:39 -08001960#define USB_DEVICE_LENOVO(prod) \
1961 USB_DEVICE(USB_VENDOR_ID_LENOVO, prod), \
1962 .driver_info = (kernel_ulong_t)&wacom_features_##prod
1963
Bastian Blankb036f6f2010-02-10 23:06:23 -08001964const struct usb_device_id wacom_ids[] = {
1965 { USB_DEVICE_WACOM(0x00) },
1966 { USB_DEVICE_WACOM(0x10) },
1967 { USB_DEVICE_WACOM(0x11) },
1968 { USB_DEVICE_WACOM(0x12) },
1969 { USB_DEVICE_WACOM(0x13) },
1970 { USB_DEVICE_WACOM(0x14) },
1971 { USB_DEVICE_WACOM(0x15) },
1972 { USB_DEVICE_WACOM(0x16) },
1973 { USB_DEVICE_WACOM(0x17) },
1974 { USB_DEVICE_WACOM(0x18) },
1975 { USB_DEVICE_WACOM(0x19) },
1976 { USB_DEVICE_WACOM(0x60) },
1977 { USB_DEVICE_WACOM(0x61) },
1978 { USB_DEVICE_WACOM(0x62) },
1979 { USB_DEVICE_WACOM(0x63) },
1980 { USB_DEVICE_WACOM(0x64) },
1981 { USB_DEVICE_WACOM(0x65) },
1982 { USB_DEVICE_WACOM(0x69) },
Ping Cheng11d0cf82011-06-27 12:57:58 -07001983 { USB_DEVICE_WACOM(0x6A) },
1984 { USB_DEVICE_WACOM(0x6B) },
Bastian Blankb036f6f2010-02-10 23:06:23 -08001985 { USB_DEVICE_WACOM(0x20) },
1986 { USB_DEVICE_WACOM(0x21) },
1987 { USB_DEVICE_WACOM(0x22) },
1988 { USB_DEVICE_WACOM(0x23) },
1989 { USB_DEVICE_WACOM(0x24) },
1990 { USB_DEVICE_WACOM(0x30) },
1991 { USB_DEVICE_WACOM(0x31) },
1992 { USB_DEVICE_WACOM(0x32) },
1993 { USB_DEVICE_WACOM(0x33) },
1994 { USB_DEVICE_WACOM(0x34) },
1995 { USB_DEVICE_WACOM(0x35) },
1996 { USB_DEVICE_WACOM(0x37) },
1997 { USB_DEVICE_WACOM(0x38) },
1998 { USB_DEVICE_WACOM(0x39) },
1999 { USB_DEVICE_WACOM(0xC4) },
2000 { USB_DEVICE_WACOM(0xC0) },
2001 { USB_DEVICE_WACOM(0xC2) },
2002 { USB_DEVICE_WACOM(0x03) },
2003 { USB_DEVICE_WACOM(0x41) },
2004 { USB_DEVICE_WACOM(0x42) },
2005 { USB_DEVICE_WACOM(0x43) },
2006 { USB_DEVICE_WACOM(0x44) },
2007 { USB_DEVICE_WACOM(0x45) },
2008 { USB_DEVICE_WACOM(0xB0) },
2009 { USB_DEVICE_WACOM(0xB1) },
2010 { USB_DEVICE_WACOM(0xB2) },
2011 { USB_DEVICE_WACOM(0xB3) },
2012 { USB_DEVICE_WACOM(0xB4) },
2013 { USB_DEVICE_WACOM(0xB5) },
2014 { USB_DEVICE_WACOM(0xB7) },
2015 { USB_DEVICE_WACOM(0xB8) },
2016 { USB_DEVICE_WACOM(0xB9) },
2017 { USB_DEVICE_WACOM(0xBA) },
2018 { USB_DEVICE_WACOM(0xBB) },
Ping Cheng3a4b4aa2010-06-03 22:10:21 -07002019 { USB_DEVICE_WACOM(0xBC) },
Jason Gerecke9fee6192012-04-03 15:47:22 -07002020 { USB_DEVICE_WACOM(0x26) },
2021 { USB_DEVICE_WACOM(0x27) },
2022 { USB_DEVICE_WACOM(0x28) },
2023 { USB_DEVICE_WACOM(0x29) },
2024 { USB_DEVICE_WACOM(0x2A) },
Bastian Blankb036f6f2010-02-10 23:06:23 -08002025 { USB_DEVICE_WACOM(0x3F) },
2026 { USB_DEVICE_WACOM(0xC5) },
2027 { USB_DEVICE_WACOM(0xC6) },
2028 { USB_DEVICE_WACOM(0xC7) },
Aristeu Rozanski1483f552011-06-22 01:17:17 -07002029 /*
2030 * DTU-2231 has two interfaces on the same configuration,
2031 * only one is used.
2032 */
2033 { USB_DEVICE_DETAILED(0xCE, USB_CLASS_HID,
2034 USB_INTERFACE_SUBCLASS_BOOT,
2035 USB_INTERFACE_PROTOCOL_MOUSE) },
Chris Bagwelld3825d52012-03-25 23:26:11 -07002036 { USB_DEVICE_WACOM(0x84) },
Henrik Rydbergcb734c02010-09-05 12:53:16 -07002037 { USB_DEVICE_WACOM(0xD0) },
Chris Bagwell2aaacb12010-09-12 00:11:35 -07002038 { USB_DEVICE_WACOM(0xD1) },
2039 { USB_DEVICE_WACOM(0xD2) },
2040 { USB_DEVICE_WACOM(0xD3) },
Kevin Granade57a78722010-12-10 23:04:02 -08002041 { USB_DEVICE_WACOM(0xD4) },
Gerard Braad18adad12011-08-16 00:17:56 -07002042 { USB_DEVICE_WACOM(0xD5) },
Ping Chengd38acb42011-01-24 09:32:50 -08002043 { USB_DEVICE_WACOM(0xD6) },
2044 { USB_DEVICE_WACOM(0xD7) },
David Foleya318e6b2010-11-30 23:45:46 -08002045 { USB_DEVICE_WACOM(0xD8) },
2046 { USB_DEVICE_WACOM(0xDA) },
David Foley47d09232010-12-07 21:05:59 -08002047 { USB_DEVICE_WACOM(0xDB) },
Chris Bagwell73149ab2011-10-26 22:34:21 -07002048 { USB_DEVICE_WACOM(0xDD) },
2049 { USB_DEVICE_WACOM(0xDE) },
2050 { USB_DEVICE_WACOM(0xDF) },
Ping Chengc8f2edc2010-06-28 01:10:51 -07002051 { USB_DEVICE_WACOM(0xF0) },
Ping Cheng3a4b4aa2010-06-03 22:10:21 -07002052 { USB_DEVICE_WACOM(0xCC) },
Bastian Blankb036f6f2010-02-10 23:06:23 -08002053 { USB_DEVICE_WACOM(0x90) },
2054 { USB_DEVICE_WACOM(0x93) },
Ping Cheng11d0cf82011-06-27 12:57:58 -07002055 { USB_DEVICE_WACOM(0x97) },
Bastian Blankb036f6f2010-02-10 23:06:23 -08002056 { USB_DEVICE_WACOM(0x9A) },
2057 { USB_DEVICE_WACOM(0x9F) },
2058 { USB_DEVICE_WACOM(0xE2) },
2059 { USB_DEVICE_WACOM(0xE3) },
Ping Cheng19635182012-04-29 21:09:18 -07002060 { USB_DEVICE_WACOM(0xE5) },
Manoj Iyer26fcd2a2011-03-31 22:39:43 -07002061 { USB_DEVICE_WACOM(0xE6) },
Chris Bagwell0d0e3062011-12-11 23:50:59 -08002062 { USB_DEVICE_WACOM(0xEC) },
Bastian Blankb036f6f2010-02-10 23:06:23 -08002063 { USB_DEVICE_WACOM(0x47) },
Jason Gerecke803296b2011-12-12 00:11:45 -08002064 { USB_DEVICE_WACOM(0xF4) },
Ajay Ramaswamy7b4b3062010-12-23 01:19:39 -08002065 { USB_DEVICE_LENOVO(0x6004) },
Ping Cheng3bea7332006-07-13 18:01:36 -07002066 { }
2067};
Ping Cheng3bea7332006-07-13 18:01:36 -07002068MODULE_DEVICE_TABLE(usb, wacom_ids);