blob: 6533f44be5bd6636f22457f9ca32eaa7f404505c [file] [log] [blame]
Ping Cheng3bea7332006-07-13 18:01:36 -07001/*
Dmitry Torokhov4104d132007-05-07 16:16:29 -04002 * drivers/input/tablet/wacom_wac.c
Ping Cheng3bea7332006-07-13 18:01:36 -07003 *
Ping Chengee545002009-12-15 00:35:24 -08004 * USB Wacom tablet support - Wacom specific code
Ping Cheng3bea7332006-07-13 18:01:36 -07005 *
6 */
7
8/*
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 */
Dmitry Torokhov51269fe2010-03-19 22:18:15 -070014
Ping Cheng3bea7332006-07-13 18:01:36 -070015#include "wacom_wac.h"
Dmitry Torokhov51269fe2010-03-19 22:18:15 -070016#include "wacom.h"
Henrik Rydberg47c78e82010-11-27 09:16:48 +010017#include <linux/input/mt.h>
Aristeu Rozanski1483f552011-06-22 01:17:17 -070018#include <linux/hid.h>
Ping Cheng3bea7332006-07-13 18:01:36 -070019
Ping Chenge35fb8c2011-03-26 21:16:05 -070020/* resolution for penabled devices */
21#define WACOM_PL_RES 20
22#define WACOM_PENPRTN_RES 40
23#define WACOM_VOLITO_RES 50
24#define WACOM_GRAPHIRE_RES 80
25#define WACOM_INTUOS_RES 100
26#define WACOM_INTUOS3_RES 200
27
Dmitry Torokhov95dd3b32010-03-19 22:18:15 -070028static int wacom_penpartner_irq(struct wacom_wac *wacom)
Ping Cheng3bea7332006-07-13 18:01:36 -070029{
30 unsigned char *data = wacom->data;
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -070031 struct input_dev *input = wacom->input;
Ping Cheng3bea7332006-07-13 18:01:36 -070032
33 switch (data[0]) {
Dmitry Torokhov73a97f42010-03-19 22:18:15 -070034 case 1:
35 if (data[5] & 0x80) {
36 wacom->tool[0] = (data[5] & 0x20) ? BTN_TOOL_RUBBER : BTN_TOOL_PEN;
37 wacom->id[0] = (data[5] & 0x20) ? ERASER_DEVICE_ID : STYLUS_DEVICE_ID;
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -070038 input_report_key(input, wacom->tool[0], 1);
39 input_report_abs(input, ABS_MISC, wacom->id[0]); /* report tool id */
Dmitry Torokhov252f7762010-03-19 22:33:38 -070040 input_report_abs(input, ABS_X, get_unaligned_le16(&data[1]));
41 input_report_abs(input, ABS_Y, get_unaligned_le16(&data[3]));
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -070042 input_report_abs(input, ABS_PRESSURE, (signed char)data[6] + 127);
43 input_report_key(input, BTN_TOUCH, ((signed char)data[6] > -127));
44 input_report_key(input, BTN_STYLUS, (data[5] & 0x40));
Dmitry Torokhov73a97f42010-03-19 22:18:15 -070045 } else {
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -070046 input_report_key(input, wacom->tool[0], 0);
47 input_report_abs(input, ABS_MISC, 0); /* report tool id */
48 input_report_abs(input, ABS_PRESSURE, -1);
49 input_report_key(input, BTN_TOUCH, 0);
Dmitry Torokhov73a97f42010-03-19 22:18:15 -070050 }
51 break;
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -070052
Dmitry Torokhov73a97f42010-03-19 22:18:15 -070053 case 2:
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -070054 input_report_key(input, BTN_TOOL_PEN, 1);
55 input_report_abs(input, ABS_MISC, STYLUS_DEVICE_ID); /* report tool id */
Dmitry Torokhov252f7762010-03-19 22:33:38 -070056 input_report_abs(input, ABS_X, get_unaligned_le16(&data[1]));
57 input_report_abs(input, ABS_Y, get_unaligned_le16(&data[3]));
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -070058 input_report_abs(input, ABS_PRESSURE, (signed char)data[6] + 127);
59 input_report_key(input, BTN_TOUCH, ((signed char)data[6] > -80) && !(data[5] & 0x20));
60 input_report_key(input, BTN_STYLUS, (data[5] & 0x40));
Dmitry Torokhov73a97f42010-03-19 22:18:15 -070061 break;
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -070062
Dmitry Torokhov73a97f42010-03-19 22:18:15 -070063 default:
Dmitry Torokhoveb71d1b2012-05-02 00:13:38 -070064 dev_dbg(input->dev.parent,
65 "%s: received unknown report #%d\n", __func__, data[0]);
Dmitry Torokhov73a97f42010-03-19 22:18:15 -070066 return 0;
Ping Cheng3bea7332006-07-13 18:01:36 -070067 }
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -070068
Ping Cheng3bea7332006-07-13 18:01:36 -070069 return 1;
70}
71
Dmitry Torokhov95dd3b32010-03-19 22:18:15 -070072static int wacom_pl_irq(struct wacom_wac *wacom)
Ping Cheng3bea7332006-07-13 18:01:36 -070073{
Jason Childse33da8a2010-02-17 22:38:31 -080074 struct wacom_features *features = &wacom->features;
Ping Cheng3bea7332006-07-13 18:01:36 -070075 unsigned char *data = wacom->data;
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -070076 struct input_dev *input = wacom->input;
Ping Chenge34b9d22008-05-05 11:36:41 -040077 int prox, pressure;
Ping Cheng3bea7332006-07-13 18:01:36 -070078
Ping Chengcad74702009-12-15 00:35:25 -080079 if (data[0] != WACOM_REPORT_PENABLED) {
Dmitry Torokhoveb71d1b2012-05-02 00:13:38 -070080 dev_dbg(input->dev.parent,
81 "%s: received unknown report #%d\n", __func__, data[0]);
Ping Cheng3bea7332006-07-13 18:01:36 -070082 return 0;
83 }
84
85 prox = data[1] & 0x40;
86
Ping Cheng3bea7332006-07-13 18:01:36 -070087 if (prox) {
Ping Chengec67bbe2009-12-15 00:35:24 -080088 wacom->id[0] = ERASER_DEVICE_ID;
Ping Cheng3bea7332006-07-13 18:01:36 -070089 pressure = (signed char)((data[7] << 1) | ((data[4] >> 2) & 1));
Jason Childse33da8a2010-02-17 22:38:31 -080090 if (features->pressure_max > 255)
Ping Cheng3bea7332006-07-13 18:01:36 -070091 pressure = (pressure << 1) | ((data[4] >> 6) & 1);
Jason Childse33da8a2010-02-17 22:38:31 -080092 pressure += (features->pressure_max + 1) / 2;
Ping Cheng3bea7332006-07-13 18:01:36 -070093
94 /*
95 * if going from out of proximity into proximity select between the eraser
96 * and the pen based on the state of the stylus2 button, choose eraser if
97 * pressed else choose pen. if not a proximity change from out to in, send
98 * an out of proximity for previous tool then a in for new tool.
99 */
100 if (!wacom->tool[0]) {
101 /* Eraser bit set for DTF */
102 if (data[1] & 0x10)
103 wacom->tool[1] = BTN_TOOL_RUBBER;
104 else
105 /* Going into proximity select tool */
106 wacom->tool[1] = (data[4] & 0x20) ? BTN_TOOL_RUBBER : BTN_TOOL_PEN;
107 } else {
108 /* was entered with stylus2 pressed */
109 if (wacom->tool[1] == BTN_TOOL_RUBBER && !(data[4] & 0x20)) {
110 /* report out proximity for previous tool */
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700111 input_report_key(input, wacom->tool[1], 0);
112 input_sync(input);
Ping Cheng3bea7332006-07-13 18:01:36 -0700113 wacom->tool[1] = BTN_TOOL_PEN;
114 return 0;
115 }
116 }
117 if (wacom->tool[1] != BTN_TOOL_RUBBER) {
118 /* Unknown tool selected default to pen tool */
119 wacom->tool[1] = BTN_TOOL_PEN;
Ping Chenge34b9d22008-05-05 11:36:41 -0400120 wacom->id[0] = STYLUS_DEVICE_ID;
Ping Cheng3bea7332006-07-13 18:01:36 -0700121 }
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700122 input_report_key(input, wacom->tool[1], prox); /* report in proximity for tool */
123 input_report_abs(input, ABS_MISC, wacom->id[0]); /* report tool id */
124 input_report_abs(input, ABS_X, data[3] | (data[2] << 7) | ((data[1] & 0x03) << 14));
125 input_report_abs(input, ABS_Y, data[6] | (data[5] << 7) | ((data[4] & 0x03) << 14));
126 input_report_abs(input, ABS_PRESSURE, pressure);
Ping Cheng3bea7332006-07-13 18:01:36 -0700127
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700128 input_report_key(input, BTN_TOUCH, data[4] & 0x08);
129 input_report_key(input, BTN_STYLUS, data[4] & 0x10);
Ping Cheng3bea7332006-07-13 18:01:36 -0700130 /* Only allow the stylus2 button to be reported for the pen tool. */
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700131 input_report_key(input, BTN_STYLUS2, (wacom->tool[1] == BTN_TOOL_PEN) && (data[4] & 0x20));
Ping Cheng3bea7332006-07-13 18:01:36 -0700132 } else {
133 /* report proximity-out of a (valid) tool */
134 if (wacom->tool[1] != BTN_TOOL_RUBBER) {
135 /* Unknown tool selected default to pen tool */
136 wacom->tool[1] = BTN_TOOL_PEN;
137 }
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700138 input_report_key(input, wacom->tool[1], prox);
Ping Cheng3bea7332006-07-13 18:01:36 -0700139 }
140
141 wacom->tool[0] = prox; /* Save proximity state */
142 return 1;
143}
144
Dmitry Torokhov95dd3b32010-03-19 22:18:15 -0700145static int wacom_ptu_irq(struct wacom_wac *wacom)
Ping Cheng3bea7332006-07-13 18:01:36 -0700146{
147 unsigned char *data = wacom->data;
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700148 struct input_dev *input = wacom->input;
Ping Cheng3bea7332006-07-13 18:01:36 -0700149
Ping Chengcad74702009-12-15 00:35:25 -0800150 if (data[0] != WACOM_REPORT_PENABLED) {
Dmitry Torokhoveb71d1b2012-05-02 00:13:38 -0700151 dev_dbg(input->dev.parent,
152 "%s: received unknown report #%d\n", __func__, data[0]);
Ping Cheng3bea7332006-07-13 18:01:36 -0700153 return 0;
154 }
155
Ping Cheng3bea7332006-07-13 18:01:36 -0700156 if (data[1] & 0x04) {
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700157 input_report_key(input, BTN_TOOL_RUBBER, data[1] & 0x20);
158 input_report_key(input, BTN_TOUCH, data[1] & 0x08);
Ping Chenge34b9d22008-05-05 11:36:41 -0400159 wacom->id[0] = ERASER_DEVICE_ID;
Ping Cheng3bea7332006-07-13 18:01:36 -0700160 } else {
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700161 input_report_key(input, BTN_TOOL_PEN, data[1] & 0x20);
162 input_report_key(input, BTN_TOUCH, data[1] & 0x01);
Ping Chenge34b9d22008-05-05 11:36:41 -0400163 wacom->id[0] = STYLUS_DEVICE_ID;
Ping Cheng3bea7332006-07-13 18:01:36 -0700164 }
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700165 input_report_abs(input, ABS_MISC, wacom->id[0]); /* report tool id */
Dmitry Torokhov252f7762010-03-19 22:33:38 -0700166 input_report_abs(input, ABS_X, le16_to_cpup((__le16 *)&data[2]));
167 input_report_abs(input, ABS_Y, le16_to_cpup((__le16 *)&data[4]));
168 input_report_abs(input, ABS_PRESSURE, le16_to_cpup((__le16 *)&data[6]));
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700169 input_report_key(input, BTN_STYLUS, data[1] & 0x02);
170 input_report_key(input, BTN_STYLUS2, data[1] & 0x10);
Ping Cheng3bea7332006-07-13 18:01:36 -0700171 return 1;
172}
173
Ping Chengc8f2edc2010-06-28 01:10:51 -0700174static int wacom_dtu_irq(struct wacom_wac *wacom)
175{
176 struct wacom_features *features = &wacom->features;
177 char *data = wacom->data;
178 struct input_dev *input = wacom->input;
179 int prox = data[1] & 0x20, pressure;
180
Dmitry Torokhoveb71d1b2012-05-02 00:13:38 -0700181 dev_dbg(input->dev.parent,
182 "%s: received report #%d", __func__, data[0]);
Ping Chengc8f2edc2010-06-28 01:10:51 -0700183
184 if (prox) {
185 /* Going into proximity select tool */
186 wacom->tool[0] = (data[1] & 0x0c) ? BTN_TOOL_RUBBER : BTN_TOOL_PEN;
187 if (wacom->tool[0] == BTN_TOOL_PEN)
188 wacom->id[0] = STYLUS_DEVICE_ID;
189 else
190 wacom->id[0] = ERASER_DEVICE_ID;
191 }
192 input_report_key(input, BTN_STYLUS, data[1] & 0x02);
193 input_report_key(input, BTN_STYLUS2, data[1] & 0x10);
194 input_report_abs(input, ABS_X, le16_to_cpup((__le16 *)&data[2]));
195 input_report_abs(input, ABS_Y, le16_to_cpup((__le16 *)&data[4]));
196 pressure = ((data[7] & 0x01) << 8) | data[6];
197 if (pressure < 0)
198 pressure = features->pressure_max + pressure + 1;
199 input_report_abs(input, ABS_PRESSURE, pressure);
200 input_report_key(input, BTN_TOUCH, data[1] & 0x05);
201 if (!prox) /* out-prox */
202 wacom->id[0] = 0;
203 input_report_key(input, wacom->tool[0], prox);
204 input_report_abs(input, ABS_MISC, wacom->id[0]);
205 return 1;
206}
207
Dmitry Torokhov95dd3b32010-03-19 22:18:15 -0700208static int wacom_graphire_irq(struct wacom_wac *wacom)
Ping Cheng3bea7332006-07-13 18:01:36 -0700209{
Jason Childse33da8a2010-02-17 22:38:31 -0800210 struct wacom_features *features = &wacom->features;
Ping Cheng3bea7332006-07-13 18:01:36 -0700211 unsigned char *data = wacom->data;
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700212 struct input_dev *input = wacom->input;
Dmitry Torokhov252f7762010-03-19 22:33:38 -0700213 int prox;
Ping Cheng3b57ca02010-03-04 21:50:59 -0800214 int rw = 0;
215 int retval = 0;
Ping Cheng3bea7332006-07-13 18:01:36 -0700216
Ping Chengcad74702009-12-15 00:35:25 -0800217 if (data[0] != WACOM_REPORT_PENABLED) {
Dmitry Torokhoveb71d1b2012-05-02 00:13:38 -0700218 dev_dbg(input->dev.parent,
219 "%s: received unknown report #%d\n", __func__, data[0]);
Ping Cheng3b57ca02010-03-04 21:50:59 -0800220 goto exit;
Ping Cheng3bea7332006-07-13 18:01:36 -0700221 }
222
Ping Cheng3b57ca02010-03-04 21:50:59 -0800223 prox = data[1] & 0x80;
224 if (prox || wacom->id[0]) {
225 if (prox) {
226 switch ((data[1] >> 5) & 3) {
Ping Cheng3bea7332006-07-13 18:01:36 -0700227
228 case 0: /* Pen */
229 wacom->tool[0] = BTN_TOOL_PEN;
Ping Chenge34b9d22008-05-05 11:36:41 -0400230 wacom->id[0] = STYLUS_DEVICE_ID;
Ping Cheng3bea7332006-07-13 18:01:36 -0700231 break;
232
233 case 1: /* Rubber */
234 wacom->tool[0] = BTN_TOOL_RUBBER;
Ping Chenge34b9d22008-05-05 11:36:41 -0400235 wacom->id[0] = ERASER_DEVICE_ID;
Ping Cheng3bea7332006-07-13 18:01:36 -0700236 break;
237
238 case 2: /* Mouse with wheel */
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700239 input_report_key(input, BTN_MIDDLE, data[1] & 0x04);
Ping Cheng3bea7332006-07-13 18:01:36 -0700240 /* fall through */
241
242 case 3: /* Mouse without wheel */
243 wacom->tool[0] = BTN_TOOL_MOUSE;
Ping Chenge34b9d22008-05-05 11:36:41 -0400244 wacom->id[0] = CURSOR_DEVICE_ID;
Ping Cheng3bea7332006-07-13 18:01:36 -0700245 break;
Ping Cheng3b57ca02010-03-04 21:50:59 -0800246 }
Ping Cheng3bea7332006-07-13 18:01:36 -0700247 }
Dmitry Torokhov252f7762010-03-19 22:33:38 -0700248 input_report_abs(input, ABS_X, le16_to_cpup((__le16 *)&data[2]));
249 input_report_abs(input, ABS_Y, le16_to_cpup((__le16 *)&data[4]));
Ping Cheng3bea7332006-07-13 18:01:36 -0700250 if (wacom->tool[0] != BTN_TOOL_MOUSE) {
Chris Bagwell6dc46352012-06-12 00:25:48 -0700251 input_report_abs(input, ABS_PRESSURE, data[6] | ((data[7] & 0x03) << 8));
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700252 input_report_key(input, BTN_TOUCH, data[1] & 0x01);
253 input_report_key(input, BTN_STYLUS, data[1] & 0x02);
254 input_report_key(input, BTN_STYLUS2, data[1] & 0x04);
Dmitry Torokhovafb567e2010-04-13 23:08:58 -0700255 } else {
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700256 input_report_key(input, BTN_LEFT, data[1] & 0x01);
257 input_report_key(input, BTN_RIGHT, data[1] & 0x02);
Ping Cheng3b57ca02010-03-04 21:50:59 -0800258 if (features->type == WACOM_G4 ||
259 features->type == WACOM_MO) {
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700260 input_report_abs(input, ABS_DISTANCE, data[6] & 0x3f);
Mike Autyd9f66c12010-08-28 20:35:17 -0700261 rw = (data[7] & 0x04) - (data[7] & 0x03);
Ping Cheng3b57ca02010-03-04 21:50:59 -0800262 } else {
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700263 input_report_abs(input, ABS_DISTANCE, data[7] & 0x3f);
Mike Autyd9f66c12010-08-28 20:35:17 -0700264 rw = -(signed char)data[6];
Ping Cheng3b57ca02010-03-04 21:50:59 -0800265 }
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700266 input_report_rel(input, REL_WHEEL, rw);
Dmitry Torokhovafb567e2010-04-13 23:08:58 -0700267 }
Ping Cheng3b57ca02010-03-04 21:50:59 -0800268
269 if (!prox)
270 wacom->id[0] = 0;
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700271 input_report_abs(input, ABS_MISC, wacom->id[0]); /* report tool id */
272 input_report_key(input, wacom->tool[0], prox);
Ping Cheng998c4542011-07-06 18:05:41 -0700273 input_event(input, EV_MSC, MSC_SERIAL, 1);
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700274 input_sync(input); /* sync last event */
Ping Cheng80d4e8e2007-02-23 12:22:48 -0800275 }
Ping Cheng3bea7332006-07-13 18:01:36 -0700276
277 /* send pad data */
Jason Childse33da8a2010-02-17 22:38:31 -0800278 switch (features->type) {
Dmitry Torokhov73a97f42010-03-19 22:18:15 -0700279 case WACOM_G4:
Ping Cheng3b57ca02010-03-04 21:50:59 -0800280 prox = data[7] & 0xf8;
281 if (prox || wacom->id[1]) {
Ping Chenge34b9d22008-05-05 11:36:41 -0400282 wacom->id[1] = PAD_DEVICE_ID;
Ping Cheng0bd10ef2011-07-06 18:05:42 -0700283 input_report_key(input, BTN_BACK, (data[7] & 0x40));
284 input_report_key(input, BTN_FORWARD, (data[7] & 0x80));
Ping Cheng3bea7332006-07-13 18:01:36 -0700285 rw = ((data[7] & 0x18) >> 3) - ((data[7] & 0x20) >> 3);
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700286 input_report_rel(input, REL_WHEEL, rw);
Ping Cheng3b57ca02010-03-04 21:50:59 -0800287 if (!prox)
288 wacom->id[1] = 0;
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700289 input_report_abs(input, ABS_MISC, wacom->id[1]);
290 input_event(input, EV_MSC, MSC_SERIAL, 0xf0);
Ping Chengab687b12010-04-05 23:07:41 -0700291 retval = 1;
Ping Cheng3bea7332006-07-13 18:01:36 -0700292 }
Ping Cheng7ecfbfd2007-06-14 23:32:48 -0400293 break;
Dmitry Torokhov73a97f42010-03-19 22:18:15 -0700294
295 case WACOM_MO:
Ping Cheng3b57ca02010-03-04 21:50:59 -0800296 prox = (data[7] & 0xf8) || data[8];
297 if (prox || wacom->id[1]) {
Ping Chenge34b9d22008-05-05 11:36:41 -0400298 wacom->id[1] = PAD_DEVICE_ID;
Ping Cheng0bd10ef2011-07-06 18:05:42 -0700299 input_report_key(input, BTN_BACK, (data[7] & 0x08));
300 input_report_key(input, BTN_LEFT, (data[7] & 0x20));
301 input_report_key(input, BTN_FORWARD, (data[7] & 0x10));
302 input_report_key(input, BTN_RIGHT, (data[7] & 0x40));
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700303 input_report_abs(input, ABS_WHEEL, (data[8] & 0x7f));
Ping Cheng3b57ca02010-03-04 21:50:59 -0800304 if (!prox)
305 wacom->id[1] = 0;
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700306 input_report_abs(input, ABS_MISC, wacom->id[1]);
307 input_event(input, EV_MSC, MSC_SERIAL, 0xf0);
Ping Cheng84460012011-07-06 18:05:43 -0700308 retval = 1;
Ping Cheng7ecfbfd2007-06-14 23:32:48 -0400309 }
310 break;
Ping Cheng3bea7332006-07-13 18:01:36 -0700311 }
Ping Cheng3b57ca02010-03-04 21:50:59 -0800312exit:
313 return retval;
Ping Cheng3bea7332006-07-13 18:01:36 -0700314}
315
Dmitry Torokhov95dd3b32010-03-19 22:18:15 -0700316static int wacom_intuos_inout(struct wacom_wac *wacom)
Ping Cheng3bea7332006-07-13 18:01:36 -0700317{
Jason Childse33da8a2010-02-17 22:38:31 -0800318 struct wacom_features *features = &wacom->features;
Ping Cheng3bea7332006-07-13 18:01:36 -0700319 unsigned char *data = wacom->data;
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700320 struct input_dev *input = wacom->input;
Ping Cheng6f660f12009-05-08 18:30:33 -0700321 int idx = 0;
Ping Cheng3bea7332006-07-13 18:01:36 -0700322
323 /* tool number */
Jason Childse33da8a2010-02-17 22:38:31 -0800324 if (features->type == INTUOS)
Ping Cheng6f660f12009-05-08 18:30:33 -0700325 idx = data[1] & 0x01;
Ping Cheng3bea7332006-07-13 18:01:36 -0700326
327 /* Enter report */
328 if ((data[1] & 0xfc) == 0xc0) {
Jason Gereckeae584ca2012-04-03 15:50:40 -0700329 if (features->type >= INTUOS5S && features->type <= INTUOS5L)
330 wacom->shared->stylus_in_proximity = true;
331
Ping Cheng3bea7332006-07-13 18:01:36 -0700332 /* serial number of the tool */
333 wacom->serial[idx] = ((data[3] & 0x0f) << 28) +
334 (data[4] << 20) + (data[5] << 12) +
335 (data[6] << 4) + (data[7] >> 4);
336
Ping Cheng493630b2010-06-22 11:21:34 -0700337 wacom->id[idx] = (data[2] << 4) | (data[3] >> 4) |
338 ((data[7] & 0x0f) << 20) | ((data[8] & 0xf0) << 12);
Dmitry Torokhov73a97f42010-03-19 22:18:15 -0700339
Ping Cheng493630b2010-06-22 11:21:34 -0700340 switch (wacom->id[idx] & 0xfffff) {
Dmitry Torokhov73a97f42010-03-19 22:18:15 -0700341 case 0x812: /* Inking pen */
342 case 0x801: /* Intuos3 Inking pen */
Ping Cheng493630b2010-06-22 11:21:34 -0700343 case 0x20802: /* Intuos4 Inking Pen */
Dmitry Torokhov73a97f42010-03-19 22:18:15 -0700344 case 0x012:
345 wacom->tool[idx] = BTN_TOOL_PENCIL;
346 break;
347
348 case 0x822: /* Pen */
349 case 0x842:
350 case 0x852:
351 case 0x823: /* Intuos3 Grip Pen */
352 case 0x813: /* Intuos3 Classic Pen */
353 case 0x885: /* Intuos3 Marker Pen */
Ping Cheng3a4b4aa2010-06-03 22:10:21 -0700354 case 0x802: /* Intuos4 General Pen */
Dmitry Torokhov73a97f42010-03-19 22:18:15 -0700355 case 0x804: /* Intuos4 Marker Pen */
356 case 0x40802: /* Intuos4 Classic Pen */
357 case 0x022:
358 wacom->tool[idx] = BTN_TOOL_PEN;
359 break;
360
361 case 0x832: /* Stroke pen */
362 case 0x032:
363 wacom->tool[idx] = BTN_TOOL_BRUSH;
364 break;
365
366 case 0x007: /* Mouse 4D and 2D */
367 case 0x09c:
368 case 0x094:
369 case 0x017: /* Intuos3 2D Mouse */
370 case 0x806: /* Intuos4 Mouse */
371 wacom->tool[idx] = BTN_TOOL_MOUSE;
372 break;
373
374 case 0x096: /* Lens cursor */
375 case 0x097: /* Intuos3 Lens cursor */
376 case 0x006: /* Intuos4 Lens cursor */
377 wacom->tool[idx] = BTN_TOOL_LENS;
378 break;
379
380 case 0x82a: /* Eraser */
381 case 0x85a:
382 case 0x91a:
383 case 0xd1a:
384 case 0x0fa:
385 case 0x82b: /* Intuos3 Grip Pen Eraser */
386 case 0x81b: /* Intuos3 Classic Pen Eraser */
387 case 0x91b: /* Intuos3 Airbrush Eraser */
388 case 0x80c: /* Intuos4 Marker Pen Eraser */
Ping Cheng3a4b4aa2010-06-03 22:10:21 -0700389 case 0x80a: /* Intuos4 General Pen Eraser */
Dmitry Torokhov73a97f42010-03-19 22:18:15 -0700390 case 0x4080a: /* Intuos4 Classic Pen Eraser */
391 case 0x90a: /* Intuos4 Airbrush Eraser */
392 wacom->tool[idx] = BTN_TOOL_RUBBER;
393 break;
394
395 case 0xd12:
396 case 0x912:
397 case 0x112:
398 case 0x913: /* Intuos3 Airbrush */
399 case 0x902: /* Intuos4 Airbrush */
400 wacom->tool[idx] = BTN_TOOL_AIRBRUSH;
401 break;
402
403 default: /* Unknown tool */
404 wacom->tool[idx] = BTN_TOOL_PEN;
405 break;
Ping Cheng3bea7332006-07-13 18:01:36 -0700406 }
Ping Cheng3bea7332006-07-13 18:01:36 -0700407 return 1;
408 }
409
Ping Cheng3a4b4aa2010-06-03 22:10:21 -0700410 /* older I4 styli don't work with new Cintiqs */
411 if (!((wacom->id[idx] >> 20) & 0x01) &&
412 (features->type == WACOM_21UX2))
413 return 1;
414
Ping Cheng3bea7332006-07-13 18:01:36 -0700415 /* Exit report */
416 if ((data[1] & 0xfe) == 0x80) {
Jason Gereckeae584ca2012-04-03 15:50:40 -0700417 if (features->type >= INTUOS5S && features->type <= INTUOS5L)
418 wacom->shared->stylus_in_proximity = false;
419
Ping Cheng6f660f12009-05-08 18:30:33 -0700420 /*
421 * Reset all states otherwise we lose the initial states
422 * when in-prox next time
423 */
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700424 input_report_abs(input, ABS_X, 0);
425 input_report_abs(input, ABS_Y, 0);
426 input_report_abs(input, ABS_DISTANCE, 0);
427 input_report_abs(input, ABS_TILT_X, 0);
428 input_report_abs(input, ABS_TILT_Y, 0);
Ping Cheng80d4e8e2007-02-23 12:22:48 -0800429 if (wacom->tool[idx] >= BTN_TOOL_MOUSE) {
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700430 input_report_key(input, BTN_LEFT, 0);
431 input_report_key(input, BTN_MIDDLE, 0);
432 input_report_key(input, BTN_RIGHT, 0);
433 input_report_key(input, BTN_SIDE, 0);
434 input_report_key(input, BTN_EXTRA, 0);
435 input_report_abs(input, ABS_THROTTLE, 0);
436 input_report_abs(input, ABS_RZ, 0);
Ping Cheng7ecfbfd2007-06-14 23:32:48 -0400437 } else {
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700438 input_report_abs(input, ABS_PRESSURE, 0);
439 input_report_key(input, BTN_STYLUS, 0);
440 input_report_key(input, BTN_STYLUS2, 0);
441 input_report_key(input, BTN_TOUCH, 0);
442 input_report_abs(input, ABS_WHEEL, 0);
Jason Childse33da8a2010-02-17 22:38:31 -0800443 if (features->type >= INTUOS3S)
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700444 input_report_abs(input, ABS_Z, 0);
Ping Cheng8d32e3a2006-09-26 13:34:47 -0700445 }
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700446 input_report_key(input, wacom->tool[idx], 0);
447 input_report_abs(input, ABS_MISC, 0); /* reset tool id */
448 input_event(input, EV_MSC, MSC_SERIAL, wacom->serial[idx]);
Ping Cheng6f660f12009-05-08 18:30:33 -0700449 wacom->id[idx] = 0;
Ping Cheng80d4e8e2007-02-23 12:22:48 -0800450 return 2;
Ping Cheng3bea7332006-07-13 18:01:36 -0700451 }
452 return 0;
453}
454
Dmitry Torokhov95dd3b32010-03-19 22:18:15 -0700455static void wacom_intuos_general(struct wacom_wac *wacom)
Ping Cheng3bea7332006-07-13 18:01:36 -0700456{
Jason Childse33da8a2010-02-17 22:38:31 -0800457 struct wacom_features *features = &wacom->features;
Ping Cheng3bea7332006-07-13 18:01:36 -0700458 unsigned char *data = wacom->data;
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700459 struct input_dev *input = wacom->input;
Ping Cheng3bea7332006-07-13 18:01:36 -0700460 unsigned int t;
461
462 /* general pen packet */
463 if ((data[1] & 0xb8) == 0xa0) {
464 t = (data[6] << 2) | ((data[7] >> 6) & 3);
Aristeu Rozanskica047fe2010-10-10 14:12:33 -0700465 if ((features->type >= INTUOS4S && features->type <= INTUOS4L) ||
Jason Gerecke9fee6192012-04-03 15:47:22 -0700466 (features->type >= INTUOS5S && features->type <= INTUOS5L) ||
Jason Gerecke803296b2011-12-12 00:11:45 -0800467 features->type == WACOM_21UX2 || features->type == WACOM_24HD) {
Ping Cheng6f660f12009-05-08 18:30:33 -0700468 t = (t << 1) | (data[1] & 1);
Aristeu Rozanskica047fe2010-10-10 14:12:33 -0700469 }
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700470 input_report_abs(input, ABS_PRESSURE, t);
471 input_report_abs(input, ABS_TILT_X,
Ping Cheng3bea7332006-07-13 18:01:36 -0700472 ((data[7] << 1) & 0x7e) | (data[8] >> 7));
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700473 input_report_abs(input, ABS_TILT_Y, data[8] & 0x7f);
474 input_report_key(input, BTN_STYLUS, data[1] & 2);
475 input_report_key(input, BTN_STYLUS2, data[1] & 4);
476 input_report_key(input, BTN_TOUCH, t > 10);
Ping Cheng3bea7332006-07-13 18:01:36 -0700477 }
478
479 /* airbrush second packet */
480 if ((data[1] & 0xbc) == 0xb4) {
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700481 input_report_abs(input, ABS_WHEEL,
Ping Cheng3bea7332006-07-13 18:01:36 -0700482 (data[6] << 2) | ((data[7] >> 6) & 3));
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700483 input_report_abs(input, ABS_TILT_X,
Ping Cheng3bea7332006-07-13 18:01:36 -0700484 ((data[7] << 1) & 0x7e) | (data[8] >> 7));
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700485 input_report_abs(input, ABS_TILT_Y, data[8] & 0x7f);
Ping Cheng3bea7332006-07-13 18:01:36 -0700486 }
Ping Cheng3bea7332006-07-13 18:01:36 -0700487}
488
Dmitry Torokhov95dd3b32010-03-19 22:18:15 -0700489static int wacom_intuos_irq(struct wacom_wac *wacom)
Ping Cheng3bea7332006-07-13 18:01:36 -0700490{
Jason Childse33da8a2010-02-17 22:38:31 -0800491 struct wacom_features *features = &wacom->features;
Ping Cheng3bea7332006-07-13 18:01:36 -0700492 unsigned char *data = wacom->data;
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700493 struct input_dev *input = wacom->input;
Ping Cheng3bea7332006-07-13 18:01:36 -0700494 unsigned int t;
Ping Cheng6f660f12009-05-08 18:30:33 -0700495 int idx = 0, result;
Ping Cheng3bea7332006-07-13 18:01:36 -0700496
Dmitry Torokhoveb71d1b2012-05-02 00:13:38 -0700497 if (data[0] != WACOM_REPORT_PENABLED &&
498 data[0] != WACOM_REPORT_INTUOSREAD &&
499 data[0] != WACOM_REPORT_INTUOSWRITE &&
500 data[0] != WACOM_REPORT_INTUOSPAD &&
501 data[0] != WACOM_REPORT_INTUOS5PAD) {
502 dev_dbg(input->dev.parent,
503 "%s: received unknown report #%d\n", __func__, data[0]);
Ping Cheng3bea7332006-07-13 18:01:36 -0700504 return 0;
505 }
506
Ping Cheng3bea7332006-07-13 18:01:36 -0700507 /* tool number */
Jason Childse33da8a2010-02-17 22:38:31 -0800508 if (features->type == INTUOS)
Ping Cheng6f660f12009-05-08 18:30:33 -0700509 idx = data[1] & 0x01;
Ping Cheng3bea7332006-07-13 18:01:36 -0700510
511 /* pad packets. Works as a second tool and is always in prox */
Jason Gereckef860e582012-04-03 15:48:35 -0700512 if (data[0] == WACOM_REPORT_INTUOSPAD || data[0] == WACOM_REPORT_INTUOS5PAD) {
Jason Childse33da8a2010-02-17 22:38:31 -0800513 if (features->type >= INTUOS4S && features->type <= INTUOS4L) {
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700514 input_report_key(input, BTN_0, (data[2] & 0x01));
515 input_report_key(input, BTN_1, (data[3] & 0x01));
516 input_report_key(input, BTN_2, (data[3] & 0x02));
517 input_report_key(input, BTN_3, (data[3] & 0x04));
518 input_report_key(input, BTN_4, (data[3] & 0x08));
519 input_report_key(input, BTN_5, (data[3] & 0x10));
520 input_report_key(input, BTN_6, (data[3] & 0x20));
Ping Cheng6f660f12009-05-08 18:30:33 -0700521 if (data[1] & 0x80) {
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700522 input_report_abs(input, ABS_WHEEL, (data[1] & 0x7f));
Ping Chenga8629522009-06-02 16:59:58 -0700523 } else {
524 /* Out of proximity, clear wheel value. */
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700525 input_report_abs(input, ABS_WHEEL, 0);
Ping Cheng6f660f12009-05-08 18:30:33 -0700526 }
Jason Childse33da8a2010-02-17 22:38:31 -0800527 if (features->type != INTUOS4S) {
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700528 input_report_key(input, BTN_7, (data[3] & 0x40));
529 input_report_key(input, BTN_8, (data[3] & 0x80));
Ping Cheng6f660f12009-05-08 18:30:33 -0700530 }
531 if (data[1] | (data[2] & 0x01) | data[3]) {
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700532 input_report_key(input, wacom->tool[1], 1);
533 input_report_abs(input, ABS_MISC, PAD_DEVICE_ID);
Ping Cheng6f660f12009-05-08 18:30:33 -0700534 } else {
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700535 input_report_key(input, wacom->tool[1], 0);
536 input_report_abs(input, ABS_MISC, 0);
Ping Cheng6f660f12009-05-08 18:30:33 -0700537 }
Jason Gerecke803296b2011-12-12 00:11:45 -0800538 } else if (features->type == WACOM_24HD) {
539 input_report_key(input, BTN_0, (data[6] & 0x01));
540 input_report_key(input, BTN_1, (data[6] & 0x02));
541 input_report_key(input, BTN_2, (data[6] & 0x04));
542 input_report_key(input, BTN_3, (data[6] & 0x08));
543 input_report_key(input, BTN_4, (data[6] & 0x10));
544 input_report_key(input, BTN_5, (data[6] & 0x20));
545 input_report_key(input, BTN_6, (data[6] & 0x40));
546 input_report_key(input, BTN_7, (data[6] & 0x80));
547 input_report_key(input, BTN_8, (data[8] & 0x01));
548 input_report_key(input, BTN_9, (data[8] & 0x02));
549 input_report_key(input, BTN_A, (data[8] & 0x04));
550 input_report_key(input, BTN_B, (data[8] & 0x08));
551 input_report_key(input, BTN_C, (data[8] & 0x10));
552 input_report_key(input, BTN_X, (data[8] & 0x20));
553 input_report_key(input, BTN_Y, (data[8] & 0x40));
554 input_report_key(input, BTN_Z, (data[8] & 0x80));
555
556 /*
557 * Three "buttons" are available on the 24HD which are
558 * physically implemented as a touchstrip. Each button
559 * is approximately 3 bits wide with a 2 bit spacing.
560 * The raw touchstrip bits are stored at:
561 * ((data[3] & 0x1f) << 8) | data[4])
562 */
563 input_report_key(input, KEY_PROG1, data[4] & 0x07);
564 input_report_key(input, KEY_PROG2, data[4] & 0xE0);
565 input_report_key(input, KEY_PROG3, data[3] & 0x1C);
566
567 if (data[1] & 0x80) {
568 input_report_abs(input, ABS_WHEEL, (data[1] & 0x7f));
569 } else {
570 /* Out of proximity, clear wheel value. */
571 input_report_abs(input, ABS_WHEEL, 0);
572 }
573
574 if (data[2] & 0x80) {
575 input_report_abs(input, ABS_THROTTLE, (data[2] & 0x7f));
576 } else {
577 /* Out of proximity, clear second wheel value. */
578 input_report_abs(input, ABS_THROTTLE, 0);
579 }
580
581 if (data[1] | data[2] | (data[3] & 0x1f) | data[4] | data[6] | data[8]) {
582 input_report_key(input, wacom->tool[1], 1);
583 input_report_abs(input, ABS_MISC, PAD_DEVICE_ID);
584 } else {
585 input_report_key(input, wacom->tool[1], 0);
586 input_report_abs(input, ABS_MISC, 0);
587 }
Jason Gereckef860e582012-04-03 15:48:35 -0700588 } else if (features->type >= INTUOS5S && features->type <= INTUOS5L) {
589 int i;
590
591 /* Touch ring mode switch has no capacitive sensor */
592 input_report_key(input, BTN_0, (data[3] & 0x01));
593
594 /*
595 * ExpressKeys on Intuos5 have a capacitive sensor in
596 * addition to the mechanical switch. Switch data is
597 * stored in data[4], capacitive data in data[5].
598 */
599 for (i = 0; i < 8; i++)
600 input_report_key(input, BTN_1 + i, data[4] & (1 << i));
601
602 if (data[2] & 0x80) {
603 input_report_abs(input, ABS_WHEEL, (data[2] & 0x7f));
604 } else {
605 /* Out of proximity, clear wheel value. */
606 input_report_abs(input, ABS_WHEEL, 0);
607 }
608
609 if (data[2] | (data[3] & 0x01) | data[4]) {
610 input_report_key(input, wacom->tool[1], 1);
611 input_report_abs(input, ABS_MISC, PAD_DEVICE_ID);
612 } else {
613 input_report_key(input, wacom->tool[1], 0);
614 input_report_abs(input, ABS_MISC, 0);
615 }
Ping Cheng6f660f12009-05-08 18:30:33 -0700616 } else {
Ping Cheng3a4b4aa2010-06-03 22:10:21 -0700617 if (features->type == WACOM_21UX2) {
618 input_report_key(input, BTN_0, (data[5] & 0x01));
619 input_report_key(input, BTN_1, (data[6] & 0x01));
620 input_report_key(input, BTN_2, (data[6] & 0x02));
621 input_report_key(input, BTN_3, (data[6] & 0x04));
622 input_report_key(input, BTN_4, (data[6] & 0x08));
623 input_report_key(input, BTN_5, (data[6] & 0x10));
624 input_report_key(input, BTN_6, (data[6] & 0x20));
625 input_report_key(input, BTN_7, (data[6] & 0x40));
626 input_report_key(input, BTN_8, (data[6] & 0x80));
627 input_report_key(input, BTN_9, (data[7] & 0x01));
628 input_report_key(input, BTN_A, (data[8] & 0x01));
629 input_report_key(input, BTN_B, (data[8] & 0x02));
630 input_report_key(input, BTN_C, (data[8] & 0x04));
631 input_report_key(input, BTN_X, (data[8] & 0x08));
632 input_report_key(input, BTN_Y, (data[8] & 0x10));
633 input_report_key(input, BTN_Z, (data[8] & 0x20));
634 input_report_key(input, BTN_BASE, (data[8] & 0x40));
635 input_report_key(input, BTN_BASE2, (data[8] & 0x80));
636 } else {
637 input_report_key(input, BTN_0, (data[5] & 0x01));
638 input_report_key(input, BTN_1, (data[5] & 0x02));
639 input_report_key(input, BTN_2, (data[5] & 0x04));
640 input_report_key(input, BTN_3, (data[5] & 0x08));
641 input_report_key(input, BTN_4, (data[6] & 0x01));
642 input_report_key(input, BTN_5, (data[6] & 0x02));
643 input_report_key(input, BTN_6, (data[6] & 0x04));
644 input_report_key(input, BTN_7, (data[6] & 0x08));
645 input_report_key(input, BTN_8, (data[5] & 0x10));
646 input_report_key(input, BTN_9, (data[6] & 0x10));
647 }
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700648 input_report_abs(input, ABS_RX, ((data[1] & 0x1f) << 8) | data[2]);
649 input_report_abs(input, ABS_RY, ((data[3] & 0x1f) << 8) | data[4]);
Ping Cheng3bea7332006-07-13 18:01:36 -0700650
Ping Cheng493630b2010-06-22 11:21:34 -0700651 if ((data[5] & 0x1f) | data[6] | (data[1] & 0x1f) |
Ping Cheng3a4b4aa2010-06-03 22:10:21 -0700652 data[2] | (data[3] & 0x1f) | data[4] | data[8] |
653 (data[7] & 0x01)) {
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700654 input_report_key(input, wacom->tool[1], 1);
655 input_report_abs(input, ABS_MISC, PAD_DEVICE_ID);
Ping Cheng6f660f12009-05-08 18:30:33 -0700656 } else {
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700657 input_report_key(input, wacom->tool[1], 0);
658 input_report_abs(input, ABS_MISC, 0);
Ping Cheng6f660f12009-05-08 18:30:33 -0700659 }
660 }
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700661 input_event(input, EV_MSC, MSC_SERIAL, 0xffffffff);
Ping Cheng3bea7332006-07-13 18:01:36 -0700662 return 1;
663 }
664
665 /* process in/out prox events */
Dmitry Torokhov95dd3b32010-03-19 22:18:15 -0700666 result = wacom_intuos_inout(wacom);
Ping Cheng3bea7332006-07-13 18:01:36 -0700667 if (result)
Dmitry Torokhov73a97f42010-03-19 22:18:15 -0700668 return result - 1;
Ping Cheng3bea7332006-07-13 18:01:36 -0700669
Ping Cheng6f660f12009-05-08 18:30:33 -0700670 /* don't proceed if we don't know the ID */
671 if (!wacom->id[idx])
672 return 0;
673
674 /* Only large Intuos support Lense Cursor */
Jason Childse33da8a2010-02-17 22:38:31 -0800675 if (wacom->tool[idx] == BTN_TOOL_LENS &&
676 (features->type == INTUOS3 ||
677 features->type == INTUOS3S ||
678 features->type == INTUOS4 ||
Jason Gerecke9fee6192012-04-03 15:47:22 -0700679 features->type == INTUOS4S ||
680 features->type == INTUOS5 ||
681 features->type == INTUOS5S)) {
Jason Childse33da8a2010-02-17 22:38:31 -0800682
Ping Cheng80d4e8e2007-02-23 12:22:48 -0800683 return 0;
Jason Childse33da8a2010-02-17 22:38:31 -0800684 }
Ping Cheng80d4e8e2007-02-23 12:22:48 -0800685
Ping Cheng3bea7332006-07-13 18:01:36 -0700686 /* Cintiq doesn't send data when RDY bit isn't set */
Jason Childse33da8a2010-02-17 22:38:31 -0800687 if (features->type == CINTIQ && !(data[1] & 0x40))
Ping Cheng3bea7332006-07-13 18:01:36 -0700688 return 0;
689
Jason Childse33da8a2010-02-17 22:38:31 -0800690 if (features->type >= INTUOS3S) {
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700691 input_report_abs(input, ABS_X, (data[2] << 9) | (data[3] << 1) | ((data[9] >> 1) & 1));
692 input_report_abs(input, ABS_Y, (data[4] << 9) | (data[5] << 1) | (data[9] & 1));
693 input_report_abs(input, ABS_DISTANCE, ((data[9] >> 2) & 0x3f));
Ping Cheng3bea7332006-07-13 18:01:36 -0700694 } else {
Dmitry Torokhov252f7762010-03-19 22:33:38 -0700695 input_report_abs(input, ABS_X, be16_to_cpup((__be16 *)&data[2]));
696 input_report_abs(input, ABS_Y, be16_to_cpup((__be16 *)&data[4]));
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700697 input_report_abs(input, ABS_DISTANCE, ((data[9] >> 3) & 0x1f));
Ping Cheng3bea7332006-07-13 18:01:36 -0700698 }
699
700 /* process general packets */
Dmitry Torokhov95dd3b32010-03-19 22:18:15 -0700701 wacom_intuos_general(wacom);
Ping Cheng3bea7332006-07-13 18:01:36 -0700702
Ping Cheng6f660f12009-05-08 18:30:33 -0700703 /* 4D mouse, 2D mouse, marker pen rotation, tilt mouse, or Lens cursor packets */
704 if ((data[1] & 0xbc) == 0xa8 || (data[1] & 0xbe) == 0xb0 || (data[1] & 0xbc) == 0xac) {
Ping Cheng3bea7332006-07-13 18:01:36 -0700705
706 if (data[1] & 0x02) {
707 /* Rotation packet */
Jason Childse33da8a2010-02-17 22:38:31 -0800708 if (features->type >= INTUOS3S) {
Ping Cheng0e1763f2008-03-13 16:46:46 -0400709 /* I3 marker pen rotation */
Ping Cheng3bea7332006-07-13 18:01:36 -0700710 t = (data[6] << 3) | ((data[7] >> 5) & 7);
711 t = (data[7] & 0x20) ? ((t > 900) ? ((t-1) / 2 - 1350) :
712 ((t-1) / 2 + 450)) : (450 - t / 2) ;
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700713 input_report_abs(input, ABS_Z, t);
Ping Cheng3bea7332006-07-13 18:01:36 -0700714 } else {
715 /* 4D mouse rotation packet */
716 t = (data[6] << 3) | ((data[7] >> 5) & 7);
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700717 input_report_abs(input, ABS_RZ, (data[7] & 0x20) ?
Ping Cheng3bea7332006-07-13 18:01:36 -0700718 ((t - 1) / 2) : -t / 2);
719 }
720
Jason Childse33da8a2010-02-17 22:38:31 -0800721 } else if (!(data[1] & 0x10) && features->type < INTUOS3S) {
Ping Cheng3bea7332006-07-13 18:01:36 -0700722 /* 4D mouse packet */
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700723 input_report_key(input, BTN_LEFT, data[8] & 0x01);
724 input_report_key(input, BTN_MIDDLE, data[8] & 0x02);
725 input_report_key(input, BTN_RIGHT, data[8] & 0x04);
Ping Cheng3bea7332006-07-13 18:01:36 -0700726
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700727 input_report_key(input, BTN_SIDE, data[8] & 0x20);
728 input_report_key(input, BTN_EXTRA, data[8] & 0x10);
Ping Cheng3bea7332006-07-13 18:01:36 -0700729 t = (data[6] << 2) | ((data[7] >> 6) & 3);
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700730 input_report_abs(input, ABS_THROTTLE, (data[8] & 0x08) ? -t : t);
Ping Cheng3bea7332006-07-13 18:01:36 -0700731
732 } else if (wacom->tool[idx] == BTN_TOOL_MOUSE) {
Ping Cheng6f660f12009-05-08 18:30:33 -0700733 /* I4 mouse */
Jason Gerecke9fee6192012-04-03 15:47:22 -0700734 if ((features->type >= INTUOS4S && features->type <= INTUOS4L) ||
735 (features->type >= INTUOS5S && features->type <= INTUOS5L)) {
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700736 input_report_key(input, BTN_LEFT, data[6] & 0x01);
737 input_report_key(input, BTN_MIDDLE, data[6] & 0x02);
738 input_report_key(input, BTN_RIGHT, data[6] & 0x04);
739 input_report_rel(input, REL_WHEEL, ((data[7] & 0x80) >> 7)
Ping Cheng6f660f12009-05-08 18:30:33 -0700740 - ((data[7] & 0x40) >> 6));
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700741 input_report_key(input, BTN_SIDE, data[6] & 0x08);
742 input_report_key(input, BTN_EXTRA, data[6] & 0x10);
Ping Cheng6f660f12009-05-08 18:30:33 -0700743
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700744 input_report_abs(input, ABS_TILT_X,
Ping Cheng6f660f12009-05-08 18:30:33 -0700745 ((data[7] << 1) & 0x7e) | (data[8] >> 7));
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700746 input_report_abs(input, ABS_TILT_Y, data[8] & 0x7f);
Ping Cheng6f660f12009-05-08 18:30:33 -0700747 } else {
748 /* 2D mouse packet */
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700749 input_report_key(input, BTN_LEFT, data[8] & 0x04);
750 input_report_key(input, BTN_MIDDLE, data[8] & 0x08);
751 input_report_key(input, BTN_RIGHT, data[8] & 0x10);
752 input_report_rel(input, REL_WHEEL, (data[8] & 0x01)
Ping Cheng3bea7332006-07-13 18:01:36 -0700753 - ((data[8] & 0x02) >> 1));
754
Ping Cheng6f660f12009-05-08 18:30:33 -0700755 /* I3 2D mouse side buttons */
Jason Childse33da8a2010-02-17 22:38:31 -0800756 if (features->type >= INTUOS3S && features->type <= INTUOS3L) {
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700757 input_report_key(input, BTN_SIDE, data[8] & 0x40);
758 input_report_key(input, BTN_EXTRA, data[8] & 0x20);
Ping Cheng6f660f12009-05-08 18:30:33 -0700759 }
Ping Cheng3bea7332006-07-13 18:01:36 -0700760 }
Jason Childse33da8a2010-02-17 22:38:31 -0800761 } else if ((features->type < INTUOS3S || features->type == INTUOS3L ||
Jason Gerecke9fee6192012-04-03 15:47:22 -0700762 features->type == INTUOS4L || features->type == INTUOS5L) &&
Ping Cheng6f660f12009-05-08 18:30:33 -0700763 wacom->tool[idx] == BTN_TOOL_LENS) {
Ping Cheng3bea7332006-07-13 18:01:36 -0700764 /* Lens cursor packets */
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700765 input_report_key(input, BTN_LEFT, data[8] & 0x01);
766 input_report_key(input, BTN_MIDDLE, data[8] & 0x02);
767 input_report_key(input, BTN_RIGHT, data[8] & 0x04);
768 input_report_key(input, BTN_SIDE, data[8] & 0x10);
769 input_report_key(input, BTN_EXTRA, data[8] & 0x08);
Ping Cheng3bea7332006-07-13 18:01:36 -0700770 }
771 }
772
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700773 input_report_abs(input, ABS_MISC, wacom->id[idx]); /* report tool id */
774 input_report_key(input, wacom->tool[idx], 1);
775 input_event(input, EV_MSC, MSC_SERIAL, wacom->serial[idx]);
Ping Cheng3bea7332006-07-13 18:01:36 -0700776 return 1;
777}
778
Ping Cheng19635182012-04-29 21:09:18 -0700779static int find_slot_from_contactid(struct wacom_wac *wacom, int contactid)
780{
781 int touch_max = wacom->features.touch_max;
782 int i;
783
784 if (!wacom->slots)
785 return -1;
786
787 for (i = 0; i < touch_max; ++i) {
788 if (wacom->slots[i] == contactid)
789 return i;
790 }
791 for (i = 0; i < touch_max; ++i) {
792 if (wacom->slots[i] == -1)
793 return i;
794 }
795 return -1;
796}
797
798static int wacom_mt_touch(struct wacom_wac *wacom)
799{
800 struct input_dev *input = wacom->input;
801 char *data = wacom->data;
802 int i;
803 int current_num_contacts = data[2];
804 int contacts_to_send = 0;
805
806 /*
807 * First packet resets the counter since only the first
808 * packet in series will have non-zero current_num_contacts.
809 */
810 if (current_num_contacts)
811 wacom->num_contacts_left = current_num_contacts;
812
813 /* There are at most 5 contacts per packet */
814 contacts_to_send = min(5, wacom->num_contacts_left);
815
816 for (i = 0; i < contacts_to_send; i++) {
817 int offset = (WACOM_BYTES_PER_MT_PACKET * i) + 3;
818 bool touch = data[offset] & 0x1;
819 int id = le16_to_cpup((__le16 *)&data[offset + 1]);
820 int slot = find_slot_from_contactid(wacom, id);
821
822 if (slot < 0)
823 continue;
824
825 input_mt_slot(input, slot);
826 input_mt_report_slot_state(input, MT_TOOL_FINGER, touch);
827 if (touch) {
828 int x = le16_to_cpup((__le16 *)&data[offset + 7]);
829 int y = le16_to_cpup((__le16 *)&data[offset + 9]);
830 input_report_abs(input, ABS_MT_POSITION_X, x);
831 input_report_abs(input, ABS_MT_POSITION_Y, y);
832 }
833 wacom->slots[slot] = touch ? id : -1;
834 }
835
836 input_mt_report_pointer_emulation(input, true);
837
838 wacom->num_contacts_left -= contacts_to_send;
839 if (wacom->num_contacts_left < 0)
840 wacom->num_contacts_left = 0;
841
842 return 1;
843}
844
Ping Cheng84eb5aa2011-03-12 20:35:18 -0800845static int wacom_tpc_mt_touch(struct wacom_wac *wacom)
846{
847 struct input_dev *input = wacom->input;
848 unsigned char *data = wacom->data;
849 int contact_with_no_pen_down_count = 0;
850 int i;
851
852 for (i = 0; i < 2; i++) {
853 int p = data[1] & (1 << i);
854 bool touch = p && !wacom->shared->stylus_in_proximity;
855
856 input_mt_slot(input, i);
857 input_mt_report_slot_state(input, MT_TOOL_FINGER, touch);
858 if (touch) {
859 int x = le16_to_cpup((__le16 *)&data[i * 2 + 2]) & 0x7fff;
860 int y = le16_to_cpup((__le16 *)&data[i * 2 + 6]) & 0x7fff;
861
862 input_report_abs(input, ABS_MT_POSITION_X, x);
863 input_report_abs(input, ABS_MT_POSITION_Y, y);
864 contact_with_no_pen_down_count++;
865 }
866 }
867
868 /* keep touch state for pen event */
869 wacom->shared->touch_down = (contact_with_no_pen_down_count > 0);
870
871 input_mt_report_pointer_emulation(input, true);
872
873 return 1;
874}
875
Ping Chenga43c7c52011-03-12 20:34:42 -0800876static int wacom_tpc_single_touch(struct wacom_wac *wacom, size_t len)
Ping Chengec67bbe2009-12-15 00:35:24 -0800877{
878 char *data = wacom->data;
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700879 struct input_dev *input = wacom->input;
Ping Chenga43c7c52011-03-12 20:34:42 -0800880 bool prox;
881 int x = 0, y = 0;
Ping Chengec67bbe2009-12-15 00:35:24 -0800882
Ping Cheng19635182012-04-29 21:09:18 -0700883 if (wacom->features.touch_max > 1 || len > WACOM_PKGLEN_TPC2FG)
884 return 0;
885
Ping Chenga43c7c52011-03-12 20:34:42 -0800886 if (!wacom->shared->stylus_in_proximity) {
887 if (len == WACOM_PKGLEN_TPC1FG) {
888 prox = data[0] & 0x01;
889 x = get_unaligned_le16(&data[1]);
890 y = get_unaligned_le16(&data[3]);
Ping Chengac173832012-06-12 00:15:06 -0700891 } else {
Ping Chenga43c7c52011-03-12 20:34:42 -0800892 prox = data[1] & 0x01;
893 x = le16_to_cpup((__le16 *)&data[2]);
894 y = le16_to_cpup((__le16 *)&data[4]);
Ping Chengec67bbe2009-12-15 00:35:24 -0800895 }
Ping Chenga43c7c52011-03-12 20:34:42 -0800896 } else
897 /* force touch out when pen is in prox */
898 prox = 0;
899
900 if (prox) {
901 input_report_abs(input, ABS_X, x);
902 input_report_abs(input, ABS_Y, y);
Ping Chengec67bbe2009-12-15 00:35:24 -0800903 }
Ping Chenga43c7c52011-03-12 20:34:42 -0800904 input_report_key(input, BTN_TOUCH, prox);
905
906 /* keep touch state for pen events */
907 wacom->shared->touch_down = prox;
908
909 return 1;
Ping Chengec67bbe2009-12-15 00:35:24 -0800910}
911
Ping Cheng8aa9a9a2011-03-12 20:34:11 -0800912static int wacom_tpc_pen(struct wacom_wac *wacom)
Ping Cheng545f4e92008-11-24 11:44:27 -0500913{
Jason Childse33da8a2010-02-17 22:38:31 -0800914 struct wacom_features *features = &wacom->features;
Ping Cheng545f4e92008-11-24 11:44:27 -0500915 char *data = wacom->data;
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700916 struct input_dev *input = wacom->input;
Ping Chenga43c7c52011-03-12 20:34:42 -0800917 int pressure;
918 bool prox = data[1] & 0x20;
Ping Cheng8aa9a9a2011-03-12 20:34:11 -0800919
Ping Chenga43c7c52011-03-12 20:34:42 -0800920 if (!wacom->shared->stylus_in_proximity) /* first in prox */
Ping Cheng8aa9a9a2011-03-12 20:34:11 -0800921 /* Going into proximity select tool */
922 wacom->tool[0] = (data[1] & 0x0c) ? BTN_TOOL_RUBBER : BTN_TOOL_PEN;
Ping Cheng8aa9a9a2011-03-12 20:34:11 -0800923
Ping Chenga43c7c52011-03-12 20:34:42 -0800924 /* keep pen state for touch events */
925 wacom->shared->stylus_in_proximity = prox;
Ping Cheng8aa9a9a2011-03-12 20:34:11 -0800926
Ping Chenga43c7c52011-03-12 20:34:42 -0800927 /* send pen events only when touch is up or forced out */
928 if (!wacom->shared->touch_down) {
929 input_report_key(input, BTN_STYLUS, data[1] & 0x02);
930 input_report_key(input, BTN_STYLUS2, data[1] & 0x10);
931 input_report_abs(input, ABS_X, le16_to_cpup((__le16 *)&data[2]));
932 input_report_abs(input, ABS_Y, le16_to_cpup((__le16 *)&data[4]));
933 pressure = ((data[7] & 0x01) << 8) | data[6];
934 if (pressure < 0)
935 pressure = features->pressure_max + pressure + 1;
936 input_report_abs(input, ABS_PRESSURE, pressure);
937 input_report_key(input, BTN_TOUCH, data[1] & 0x05);
938 input_report_key(input, wacom->tool[0], prox);
939 return 1;
940 }
941
942 return 0;
Ping Cheng8aa9a9a2011-03-12 20:34:11 -0800943}
944
945static int wacom_tpc_irq(struct wacom_wac *wacom, size_t len)
946{
947 char *data = wacom->data;
Ping Cheng545f4e92008-11-24 11:44:27 -0500948
Dmitry Torokhoveb71d1b2012-05-02 00:13:38 -0700949 dev_dbg(wacom->input->dev.parent,
950 "%s: received report #%d\n", __func__, data[0]);
Ping Cheng545f4e92008-11-24 11:44:27 -0500951
Ping Cheng31175a82012-01-31 00:07:33 -0800952 switch (len) {
953 case WACOM_PKGLEN_TPC1FG:
Ping Cheng19635182012-04-29 21:09:18 -0700954 return wacom_tpc_single_touch(wacom, len);
Ping Cheng31175a82012-01-31 00:07:33 -0800955
956 case WACOM_PKGLEN_TPC2FG:
Ping Cheng19635182012-04-29 21:09:18 -0700957 return wacom_tpc_mt_touch(wacom);
Ping Cheng31175a82012-01-31 00:07:33 -0800958
959 default:
960 switch (data[0]) {
961 case WACOM_REPORT_TPC1FG:
962 case WACOM_REPORT_TPCHID:
963 case WACOM_REPORT_TPCST:
Ping Chengac173832012-06-12 00:15:06 -0700964 case WACOM_REPORT_TPC1FGE:
Ping Cheng31175a82012-01-31 00:07:33 -0800965 return wacom_tpc_single_touch(wacom, len);
966
Ping Cheng19635182012-04-29 21:09:18 -0700967 case WACOM_REPORT_TPCMT:
968 return wacom_mt_touch(wacom);
969
Ping Cheng31175a82012-01-31 00:07:33 -0800970 case WACOM_REPORT_PENABLED:
971 return wacom_tpc_pen(wacom);
972 }
973 }
Ping Cheng545f4e92008-11-24 11:44:27 -0500974
Ping Cheng8aa9a9a2011-03-12 20:34:11 -0800975 return 0;
Ping Cheng545f4e92008-11-24 11:44:27 -0500976}
977
Chris Bagwelle1d38e42010-09-12 00:09:27 -0700978static int wacom_bpt_touch(struct wacom_wac *wacom)
Henrik Rydbergcb734c02010-09-05 12:53:16 -0700979{
Henrik Rydbergf4ccbef2010-09-05 12:57:13 -0700980 struct wacom_features *features = &wacom->features;
Henrik Rydbergcb734c02010-09-05 12:53:16 -0700981 struct input_dev *input = wacom->input;
982 unsigned char *data = wacom->data;
Henrik Rydbergcb734c02010-09-05 12:53:16 -0700983 int i;
984
Chris Bagwell5a6c8652011-11-07 19:52:42 -0800985 if (data[0] != 0x02)
986 return 0;
987
Henrik Rydbergcb734c02010-09-05 12:53:16 -0700988 for (i = 0; i < 2; i++) {
Chris Bagwell8f906862011-09-09 13:38:10 -0700989 int offset = (data[1] & 0x80) ? (8 * i) : (9 * i);
990 bool touch = data[offset + 3] & 0x80;
Henrik Rydbergc5f4dec2010-12-15 13:50:34 +0100991
Chris Bagwell33d5f712010-09-12 00:12:28 -0700992 /*
993 * Touch events need to be disabled while stylus is
994 * in proximity because user's hand is resting on touchpad
995 * and sending unwanted events. User expects tablet buttons
996 * to continue working though.
997 */
Chris Bagwell8f906862011-09-09 13:38:10 -0700998 touch = touch && !wacom->shared->stylus_in_proximity;
999
1000 input_mt_slot(input, i);
1001 input_mt_report_slot_state(input, MT_TOOL_FINGER, touch);
Henrik Rydbergc5f4dec2010-12-15 13:50:34 +01001002 if (touch) {
Chris Bagwell8f906862011-09-09 13:38:10 -07001003 int x = get_unaligned_be16(&data[offset + 3]) & 0x7ff;
1004 int y = get_unaligned_be16(&data[offset + 5]) & 0x7ff;
Henrik Rydbergf4ccbef2010-09-05 12:57:13 -07001005 if (features->quirks & WACOM_QUIRK_BBTOUCH_LOWRES) {
1006 x <<= 5;
1007 y <<= 5;
1008 }
Henrik Rydbergcb734c02010-09-05 12:53:16 -07001009 input_report_abs(input, ABS_MT_POSITION_X, x);
1010 input_report_abs(input, ABS_MT_POSITION_Y, y);
Henrik Rydbergcb734c02010-09-05 12:53:16 -07001011 }
Henrik Rydbergcb734c02010-09-05 12:53:16 -07001012 }
1013
Henrik Rydbergc5f4dec2010-12-15 13:50:34 +01001014 input_mt_report_pointer_emulation(input, true);
Henrik Rydbergcb734c02010-09-05 12:53:16 -07001015
1016 input_report_key(input, BTN_LEFT, (data[1] & 0x08) != 0);
1017 input_report_key(input, BTN_FORWARD, (data[1] & 0x04) != 0);
1018 input_report_key(input, BTN_BACK, (data[1] & 0x02) != 0);
1019 input_report_key(input, BTN_RIGHT, (data[1] & 0x01) != 0);
1020
1021 input_sync(input);
1022
1023 return 0;
1024}
1025
Chris Bagwell73149ab2011-10-26 22:34:21 -07001026static void wacom_bpt3_touch_msg(struct wacom_wac *wacom, unsigned char *data)
1027{
1028 struct input_dev *input = wacom->input;
1029 int slot_id = data[0] - 2; /* data[0] is between 2 and 17 */
1030 bool touch = data[1] & 0x80;
1031
1032 touch = touch && !wacom->shared->stylus_in_proximity;
1033
1034 input_mt_slot(input, slot_id);
1035 input_mt_report_slot_state(input, MT_TOOL_FINGER, touch);
1036
1037 if (touch) {
1038 int x = (data[2] << 4) | (data[4] >> 4);
1039 int y = (data[3] << 4) | (data[4] & 0x0f);
1040 int w = data[6];
1041
1042 input_report_abs(input, ABS_MT_POSITION_X, x);
1043 input_report_abs(input, ABS_MT_POSITION_Y, y);
1044 input_report_abs(input, ABS_MT_TOUCH_MAJOR, w);
1045 }
1046}
1047
1048static void wacom_bpt3_button_msg(struct wacom_wac *wacom, unsigned char *data)
1049{
1050 struct input_dev *input = wacom->input;
1051
1052 input_report_key(input, BTN_LEFT, (data[1] & 0x08) != 0);
1053 input_report_key(input, BTN_FORWARD, (data[1] & 0x04) != 0);
1054 input_report_key(input, BTN_BACK, (data[1] & 0x02) != 0);
1055 input_report_key(input, BTN_RIGHT, (data[1] & 0x01) != 0);
1056}
1057
1058static int wacom_bpt3_touch(struct wacom_wac *wacom)
1059{
1060 struct input_dev *input = wacom->input;
1061 unsigned char *data = wacom->data;
Jason Gerecke19d57d32012-03-06 10:19:19 -08001062 int count = data[1] & 0x07;
Chris Bagwell73149ab2011-10-26 22:34:21 -07001063 int i;
1064
Chris Bagwell5a6c8652011-11-07 19:52:42 -08001065 if (data[0] != 0x02)
1066 return 0;
1067
Chris Bagwell73149ab2011-10-26 22:34:21 -07001068 /* data has up to 7 fixed sized 8-byte messages starting at data[2] */
1069 for (i = 0; i < count; i++) {
1070 int offset = (8 * i) + 2;
1071 int msg_id = data[offset];
1072
1073 if (msg_id >= 2 && msg_id <= 17)
1074 wacom_bpt3_touch_msg(wacom, data + offset);
1075 else if (msg_id == 128)
1076 wacom_bpt3_button_msg(wacom, data + offset);
1077
1078 }
1079
1080 input_mt_report_pointer_emulation(input, true);
1081
1082 input_sync(input);
1083
1084 return 0;
1085}
1086
Chris Bagwell2aaacb12010-09-12 00:11:35 -07001087static int wacom_bpt_pen(struct wacom_wac *wacom)
1088{
1089 struct input_dev *input = wacom->input;
1090 unsigned char *data = wacom->data;
1091 int prox = 0, x = 0, y = 0, p = 0, d = 0, pen = 0, btn1 = 0, btn2 = 0;
1092
Chris Bagwell5a6c8652011-11-07 19:52:42 -08001093 if (data[0] != 0x02)
1094 return 0;
1095
Chris Bagwellc5981412011-10-26 22:28:34 -07001096 prox = (data[1] & 0x20) == 0x20;
Chris Bagwell2aaacb12010-09-12 00:11:35 -07001097
1098 /*
1099 * All reports shared between PEN and RUBBER tool must be
1100 * forced to a known starting value (zero) when transitioning to
1101 * out-of-prox.
1102 *
1103 * If not reset then, to userspace, it will look like lost events
1104 * if new tool comes in-prox with same values as previous tool sent.
1105 *
1106 * Hardware does report zero in most out-of-prox cases but not all.
1107 */
1108 if (prox) {
1109 if (!wacom->shared->stylus_in_proximity) {
1110 if (data[1] & 0x08) {
1111 wacom->tool[0] = BTN_TOOL_RUBBER;
1112 wacom->id[0] = ERASER_DEVICE_ID;
1113 } else {
1114 wacom->tool[0] = BTN_TOOL_PEN;
1115 wacom->id[0] = STYLUS_DEVICE_ID;
1116 }
1117 wacom->shared->stylus_in_proximity = true;
1118 }
1119 x = le16_to_cpup((__le16 *)&data[2]);
1120 y = le16_to_cpup((__le16 *)&data[4]);
1121 p = le16_to_cpup((__le16 *)&data[6]);
Chris Bagwellc18c2ce2011-10-10 08:52:13 -07001122 /*
1123 * Convert distance from out prox to distance from tablet.
1124 * distance will be greater than distance_max once
1125 * touching and applying pressure; do not report negative
1126 * distance.
1127 */
1128 if (data[8] <= wacom->features.distance_max)
1129 d = wacom->features.distance_max - data[8];
1130
Chris Bagwell2aaacb12010-09-12 00:11:35 -07001131 pen = data[1] & 0x01;
1132 btn1 = data[1] & 0x02;
1133 btn2 = data[1] & 0x04;
1134 }
1135
1136 input_report_key(input, BTN_TOUCH, pen);
1137 input_report_key(input, BTN_STYLUS, btn1);
1138 input_report_key(input, BTN_STYLUS2, btn2);
1139
1140 input_report_abs(input, ABS_X, x);
1141 input_report_abs(input, ABS_Y, y);
1142 input_report_abs(input, ABS_PRESSURE, p);
1143 input_report_abs(input, ABS_DISTANCE, d);
1144
1145 if (!prox) {
1146 wacom->id[0] = 0;
1147 wacom->shared->stylus_in_proximity = false;
1148 }
1149
1150 input_report_key(input, wacom->tool[0], prox); /* PEN or RUBBER */
1151 input_report_abs(input, ABS_MISC, wacom->id[0]); /* TOOL ID */
1152
1153 return 1;
1154}
1155
Chris Bagwelle1d38e42010-09-12 00:09:27 -07001156static int wacom_bpt_irq(struct wacom_wac *wacom, size_t len)
1157{
1158 if (len == WACOM_PKGLEN_BBTOUCH)
1159 return wacom_bpt_touch(wacom);
Chris Bagwell73149ab2011-10-26 22:34:21 -07001160 else if (len == WACOM_PKGLEN_BBTOUCH3)
1161 return wacom_bpt3_touch(wacom);
1162 else if (len == WACOM_PKGLEN_BBFUN || len == WACOM_PKGLEN_BBPEN)
Chris Bagwell2aaacb12010-09-12 00:11:35 -07001163 return wacom_bpt_pen(wacom);
Chris Bagwelle1d38e42010-09-12 00:09:27 -07001164
1165 return 0;
1166}
1167
Chris Bagwelld3825d52012-03-25 23:26:11 -07001168static int wacom_wireless_irq(struct wacom_wac *wacom, size_t len)
1169{
Chris Bagwell16bf2882012-03-25 23:26:20 -07001170 unsigned char *data = wacom->data;
1171 int connected;
1172
1173 if (len != WACOM_PKGLEN_WIRELESS || data[0] != 0x80)
Chris Bagwelld3825d52012-03-25 23:26:11 -07001174 return 0;
1175
Chris Bagwell16bf2882012-03-25 23:26:20 -07001176 connected = data[1] & 0x01;
1177 if (connected) {
Chris Bagwella1d552c2012-03-25 23:26:30 -07001178 int pid, battery;
Chris Bagwell16bf2882012-03-25 23:26:20 -07001179
1180 pid = get_unaligned_be16(&data[6]);
Chris Bagwella1d552c2012-03-25 23:26:30 -07001181 battery = data[5] & 0x3f;
Chris Bagwell16bf2882012-03-25 23:26:20 -07001182 if (wacom->pid != pid) {
1183 wacom->pid = pid;
1184 wacom_schedule_work(wacom);
1185 }
Chris Bagwella1d552c2012-03-25 23:26:30 -07001186 wacom->battery_capacity = battery;
Chris Bagwell16bf2882012-03-25 23:26:20 -07001187 } else if (wacom->pid != 0) {
1188 /* disconnected while previously connected */
1189 wacom->pid = 0;
1190 wacom_schedule_work(wacom);
Chris Bagwella1d552c2012-03-25 23:26:30 -07001191 wacom->battery_capacity = 0;
Chris Bagwell16bf2882012-03-25 23:26:20 -07001192 }
1193
Chris Bagwelld3825d52012-03-25 23:26:11 -07001194 return 0;
1195}
1196
Dmitry Torokhov95dd3b32010-03-19 22:18:15 -07001197void wacom_wac_irq(struct wacom_wac *wacom_wac, size_t len)
Ping Cheng3bea7332006-07-13 18:01:36 -07001198{
Dmitry Torokhov95dd3b32010-03-19 22:18:15 -07001199 bool sync;
1200
Jason Childse33da8a2010-02-17 22:38:31 -08001201 switch (wacom_wac->features.type) {
Dmitry Torokhov73a97f42010-03-19 22:18:15 -07001202 case PENPARTNER:
Dmitry Torokhov95dd3b32010-03-19 22:18:15 -07001203 sync = wacom_penpartner_irq(wacom_wac);
1204 break;
Ping Cheng545f4e92008-11-24 11:44:27 -05001205
Dmitry Torokhov73a97f42010-03-19 22:18:15 -07001206 case PL:
Dmitry Torokhov95dd3b32010-03-19 22:18:15 -07001207 sync = wacom_pl_irq(wacom_wac);
1208 break;
Ping Cheng545f4e92008-11-24 11:44:27 -05001209
Dmitry Torokhov73a97f42010-03-19 22:18:15 -07001210 case WACOM_G4:
1211 case GRAPHIRE:
1212 case WACOM_MO:
Dmitry Torokhov95dd3b32010-03-19 22:18:15 -07001213 sync = wacom_graphire_irq(wacom_wac);
1214 break;
Ping Cheng545f4e92008-11-24 11:44:27 -05001215
Dmitry Torokhov73a97f42010-03-19 22:18:15 -07001216 case PTU:
Dmitry Torokhov95dd3b32010-03-19 22:18:15 -07001217 sync = wacom_ptu_irq(wacom_wac);
1218 break;
Ping Cheng545f4e92008-11-24 11:44:27 -05001219
Ping Chengc8f2edc2010-06-28 01:10:51 -07001220 case DTU:
1221 sync = wacom_dtu_irq(wacom_wac);
1222 break;
1223
Dmitry Torokhov73a97f42010-03-19 22:18:15 -07001224 case INTUOS:
1225 case INTUOS3S:
1226 case INTUOS3:
1227 case INTUOS3L:
1228 case INTUOS4S:
1229 case INTUOS4:
1230 case INTUOS4L:
1231 case CINTIQ:
1232 case WACOM_BEE:
Ping Cheng3a4b4aa2010-06-03 22:10:21 -07001233 case WACOM_21UX2:
Jason Gerecke803296b2011-12-12 00:11:45 -08001234 case WACOM_24HD:
Dmitry Torokhov95dd3b32010-03-19 22:18:15 -07001235 sync = wacom_intuos_irq(wacom_wac);
1236 break;
Ping Cheng545f4e92008-11-24 11:44:27 -05001237
Jason Gereckeae584ca2012-04-03 15:50:40 -07001238 case INTUOS5S:
1239 case INTUOS5:
1240 case INTUOS5L:
1241 if (len == WACOM_PKGLEN_BBTOUCH3)
1242 sync = wacom_bpt3_touch(wacom_wac);
1243 else
1244 sync = wacom_intuos_irq(wacom_wac);
1245 break;
1246
Dmitry Torokhov73a97f42010-03-19 22:18:15 -07001247 case TABLETPC:
Ping Chengac173832012-06-12 00:15:06 -07001248 case TABLETPCE:
Dmitry Torokhov73a97f42010-03-19 22:18:15 -07001249 case TABLETPC2FG:
Ping Cheng19635182012-04-29 21:09:18 -07001250 case MTSCREEN:
Dmitry Torokhov95dd3b32010-03-19 22:18:15 -07001251 sync = wacom_tpc_irq(wacom_wac, len);
1252 break;
Ping Cheng545f4e92008-11-24 11:44:27 -05001253
Henrik Rydbergcb734c02010-09-05 12:53:16 -07001254 case BAMBOO_PT:
1255 sync = wacom_bpt_irq(wacom_wac, len);
1256 break;
1257
Chris Bagwelld3825d52012-03-25 23:26:11 -07001258 case WIRELESS:
1259 sync = wacom_wireless_irq(wacom_wac, len);
1260 break;
1261
Dmitry Torokhov73a97f42010-03-19 22:18:15 -07001262 default:
Dmitry Torokhov95dd3b32010-03-19 22:18:15 -07001263 sync = false;
1264 break;
Ping Cheng3bea7332006-07-13 18:01:36 -07001265 }
Dmitry Torokhov95dd3b32010-03-19 22:18:15 -07001266
1267 if (sync)
1268 input_sync(wacom_wac->input);
Ping Cheng3bea7332006-07-13 18:01:36 -07001269}
1270
Ping Cheng6521d0b2010-10-24 21:53:40 -07001271static void wacom_setup_cintiq(struct wacom_wac *wacom_wac)
Ping Cheng3bea7332006-07-13 18:01:36 -07001272{
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -07001273 struct input_dev *input_dev = wacom_wac->input;
1274
1275 input_set_capability(input_dev, EV_MSC, MSC_SERIAL);
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -07001276
1277 __set_bit(BTN_TOOL_RUBBER, input_dev->keybit);
1278 __set_bit(BTN_TOOL_PEN, input_dev->keybit);
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -07001279 __set_bit(BTN_TOOL_BRUSH, input_dev->keybit);
1280 __set_bit(BTN_TOOL_PENCIL, input_dev->keybit);
1281 __set_bit(BTN_TOOL_AIRBRUSH, input_dev->keybit);
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -07001282 __set_bit(BTN_STYLUS, input_dev->keybit);
1283 __set_bit(BTN_STYLUS2, input_dev->keybit);
1284
1285 input_set_abs_params(input_dev, ABS_DISTANCE,
1286 0, wacom_wac->features.distance_max, 0, 0);
1287 input_set_abs_params(input_dev, ABS_WHEEL, 0, 1023, 0, 0);
1288 input_set_abs_params(input_dev, ABS_TILT_X, 0, 127, 0, 0);
1289 input_set_abs_params(input_dev, ABS_TILT_Y, 0, 127, 0, 0);
Ping Cheng6521d0b2010-10-24 21:53:40 -07001290}
1291
1292static void wacom_setup_intuos(struct wacom_wac *wacom_wac)
1293{
1294 struct input_dev *input_dev = wacom_wac->input;
1295
1296 input_set_capability(input_dev, EV_REL, REL_WHEEL);
1297
1298 wacom_setup_cintiq(wacom_wac);
1299
1300 __set_bit(BTN_LEFT, input_dev->keybit);
1301 __set_bit(BTN_RIGHT, input_dev->keybit);
1302 __set_bit(BTN_MIDDLE, input_dev->keybit);
1303 __set_bit(BTN_SIDE, input_dev->keybit);
1304 __set_bit(BTN_EXTRA, input_dev->keybit);
1305 __set_bit(BTN_TOOL_MOUSE, input_dev->keybit);
1306 __set_bit(BTN_TOOL_LENS, input_dev->keybit);
1307
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -07001308 input_set_abs_params(input_dev, ABS_RZ, -900, 899, 0, 0);
1309 input_set_abs_params(input_dev, ABS_THROTTLE, -1023, 1023, 0, 0);
1310}
1311
Henrik Rydbergbc73dd32010-09-05 12:26:16 -07001312void wacom_setup_device_quirks(struct wacom_features *features)
1313{
1314
1315 /* touch device found but size is not defined. use default */
Ping Cheng84eb5aa2011-03-12 20:35:18 -08001316 if (features->device_type == BTN_TOOL_FINGER && !features->x_max) {
Henrik Rydbergbc73dd32010-09-05 12:26:16 -07001317 features->x_max = 1023;
1318 features->y_max = 1023;
1319 }
1320
1321 /* these device have multiple inputs */
Ping Chengea2e6022012-06-12 00:14:12 -07001322 if (features->type >= WIRELESS ||
1323 (features->type >= INTUOS5S && features->type <= INTUOS5L))
Henrik Rydbergbc73dd32010-09-05 12:26:16 -07001324 features->quirks |= WACOM_QUIRK_MULTI_INPUT;
Henrik Rydbergcb734c02010-09-05 12:53:16 -07001325
Chris Bagwell73149ab2011-10-26 22:34:21 -07001326 /* quirk for bamboo touch with 2 low res touches */
Henrik Rydbergcb734c02010-09-05 12:53:16 -07001327 if (features->type == BAMBOO_PT &&
Chris Bagwell73149ab2011-10-26 22:34:21 -07001328 features->pktlen == WACOM_PKGLEN_BBTOUCH) {
Henrik Rydbergf4ccbef2010-09-05 12:57:13 -07001329 features->x_max <<= 5;
1330 features->y_max <<= 5;
1331 features->x_fuzz <<= 5;
1332 features->y_fuzz <<= 5;
Henrik Rydbergf4ccbef2010-09-05 12:57:13 -07001333 features->quirks |= WACOM_QUIRK_BBTOUCH_LOWRES;
Henrik Rydbergcb734c02010-09-05 12:53:16 -07001334 }
Chris Bagwelld3825d52012-03-25 23:26:11 -07001335
1336 if (features->type == WIRELESS) {
1337
1338 /* monitor never has input and pen/touch have delayed create */
1339 features->quirks |= WACOM_QUIRK_NO_INPUT;
1340
1341 /* must be monitor interface if no device_type set */
1342 if (!features->device_type)
1343 features->quirks |= WACOM_QUIRK_MONITOR;
1344 }
Henrik Rydbergbc73dd32010-09-05 12:26:16 -07001345}
1346
Ping Cheng409550f2011-01-25 18:03:13 -08001347static unsigned int wacom_calculate_touch_res(unsigned int logical_max,
1348 unsigned int physical_max)
1349{
1350 /* Touch physical dimensions are in 100th of mm */
1351 return (logical_max * 100) / physical_max;
1352}
1353
Ping Cheng19635182012-04-29 21:09:18 -07001354int wacom_setup_input_capabilities(struct input_dev *input_dev,
1355 struct wacom_wac *wacom_wac)
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -07001356{
1357 struct wacom_features *features = &wacom_wac->features;
1358 int i;
1359
1360 input_dev->evbit[0] |= BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS);
1361
1362 __set_bit(BTN_TOUCH, input_dev->keybit);
1363
Henrik Rydbergfed87e62010-09-05 12:25:11 -07001364 input_set_abs_params(input_dev, ABS_X, 0, features->x_max,
1365 features->x_fuzz, 0);
1366 input_set_abs_params(input_dev, ABS_Y, 0, features->y_max,
1367 features->y_fuzz, 0);
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -07001368
Ping Chenge35fb8c2011-03-26 21:16:05 -07001369 if (features->device_type == BTN_TOOL_PEN) {
Ping Chengcfb7d552011-08-26 23:10:02 -07001370 input_set_abs_params(input_dev, ABS_PRESSURE, 0, features->pressure_max,
1371 features->pressure_fuzz, 0);
1372
Ping Chenge35fb8c2011-03-26 21:16:05 -07001373 /* penabled devices have fixed resolution for each model */
1374 input_abs_set_res(input_dev, ABS_X, features->x_resolution);
1375 input_abs_set_res(input_dev, ABS_Y, features->y_resolution);
1376 } else {
1377 input_abs_set_res(input_dev, ABS_X,
1378 wacom_calculate_touch_res(features->x_max,
1379 features->x_phy));
1380 input_abs_set_res(input_dev, ABS_Y,
1381 wacom_calculate_touch_res(features->y_max,
1382 features->y_phy));
1383 }
1384
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -07001385 __set_bit(ABS_MISC, input_dev->absbit);
1386
Jason Childse33da8a2010-02-17 22:38:31 -08001387 switch (wacom_wac->features.type) {
Dmitry Torokhov73a97f42010-03-19 22:18:15 -07001388 case WACOM_MO:
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -07001389 input_set_abs_params(input_dev, ABS_WHEEL, 0, 71, 0, 0);
1390 /* fall through */
Ping Chengec67bbe2009-12-15 00:35:24 -08001391
Dmitry Torokhov73a97f42010-03-19 22:18:15 -07001392 case WACOM_G4:
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -07001393 input_set_capability(input_dev, EV_MSC, MSC_SERIAL);
1394
Ping Cheng0bd10ef2011-07-06 18:05:42 -07001395 __set_bit(BTN_BACK, input_dev->keybit);
1396 __set_bit(BTN_FORWARD, input_dev->keybit);
Dmitry Torokhov73a97f42010-03-19 22:18:15 -07001397 /* fall through */
1398
1399 case GRAPHIRE:
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -07001400 input_set_capability(input_dev, EV_REL, REL_WHEEL);
1401
1402 __set_bit(BTN_LEFT, input_dev->keybit);
1403 __set_bit(BTN_RIGHT, input_dev->keybit);
1404 __set_bit(BTN_MIDDLE, input_dev->keybit);
1405
1406 __set_bit(BTN_TOOL_RUBBER, input_dev->keybit);
1407 __set_bit(BTN_TOOL_PEN, input_dev->keybit);
1408 __set_bit(BTN_TOOL_MOUSE, input_dev->keybit);
1409 __set_bit(BTN_STYLUS, input_dev->keybit);
1410 __set_bit(BTN_STYLUS2, input_dev->keybit);
Jason Gerecke35120692011-09-08 09:38:14 -07001411
1412 __set_bit(INPUT_PROP_POINTER, input_dev->propbit);
Dmitry Torokhov73a97f42010-03-19 22:18:15 -07001413 break;
1414
Jason Gerecke803296b2011-12-12 00:11:45 -08001415 case WACOM_24HD:
1416 __set_bit(BTN_A, input_dev->keybit);
1417 __set_bit(BTN_B, input_dev->keybit);
1418 __set_bit(BTN_C, input_dev->keybit);
1419 __set_bit(BTN_X, input_dev->keybit);
1420 __set_bit(BTN_Y, input_dev->keybit);
1421 __set_bit(BTN_Z, input_dev->keybit);
1422
1423 for (i = 0; i < 10; i++)
1424 __set_bit(BTN_0 + i, input_dev->keybit);
1425
1426 __set_bit(KEY_PROG1, input_dev->keybit);
1427 __set_bit(KEY_PROG2, input_dev->keybit);
1428 __set_bit(KEY_PROG3, input_dev->keybit);
1429
1430 input_set_abs_params(input_dev, ABS_Z, -900, 899, 0, 0);
1431 input_set_abs_params(input_dev, ABS_THROTTLE, 0, 71, 0, 0);
1432 wacom_setup_cintiq(wacom_wac);
1433 break;
1434
Ping Cheng3a4b4aa2010-06-03 22:10:21 -07001435 case WACOM_21UX2:
1436 __set_bit(BTN_A, input_dev->keybit);
1437 __set_bit(BTN_B, input_dev->keybit);
1438 __set_bit(BTN_C, input_dev->keybit);
1439 __set_bit(BTN_X, input_dev->keybit);
1440 __set_bit(BTN_Y, input_dev->keybit);
1441 __set_bit(BTN_Z, input_dev->keybit);
1442 __set_bit(BTN_BASE, input_dev->keybit);
1443 __set_bit(BTN_BASE2, input_dev->keybit);
1444 /* fall through */
1445
Dmitry Torokhov73a97f42010-03-19 22:18:15 -07001446 case WACOM_BEE:
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -07001447 __set_bit(BTN_8, input_dev->keybit);
1448 __set_bit(BTN_9, input_dev->keybit);
1449 /* fall through */
Dmitry Torokhov73a97f42010-03-19 22:18:15 -07001450
Ping Cheng6521d0b2010-10-24 21:53:40 -07001451 case CINTIQ:
1452 for (i = 0; i < 8; i++)
1453 __set_bit(BTN_0 + i, input_dev->keybit);
Ping Cheng6521d0b2010-10-24 21:53:40 -07001454
Jason Gerecked6069da2011-10-04 22:50:45 -07001455 input_set_abs_params(input_dev, ABS_RX, 0, 4096, 0, 0);
1456 input_set_abs_params(input_dev, ABS_RY, 0, 4096, 0, 0);
Ping Cheng6521d0b2010-10-24 21:53:40 -07001457 input_set_abs_params(input_dev, ABS_Z, -900, 899, 0, 0);
Jason Gerecke35120692011-09-08 09:38:14 -07001458
1459 __set_bit(INPUT_PROP_DIRECT, input_dev->propbit);
1460
Ping Cheng6521d0b2010-10-24 21:53:40 -07001461 wacom_setup_cintiq(wacom_wac);
1462 break;
1463
Dmitry Torokhov73a97f42010-03-19 22:18:15 -07001464 case INTUOS3:
1465 case INTUOS3L:
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -07001466 __set_bit(BTN_4, input_dev->keybit);
1467 __set_bit(BTN_5, input_dev->keybit);
1468 __set_bit(BTN_6, input_dev->keybit);
1469 __set_bit(BTN_7, input_dev->keybit);
1470
1471 input_set_abs_params(input_dev, ABS_RY, 0, 4096, 0, 0);
Dmitry Torokhov73a97f42010-03-19 22:18:15 -07001472 /* fall through */
1473
1474 case INTUOS3S:
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -07001475 __set_bit(BTN_0, input_dev->keybit);
1476 __set_bit(BTN_1, input_dev->keybit);
1477 __set_bit(BTN_2, input_dev->keybit);
1478 __set_bit(BTN_3, input_dev->keybit);
1479
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -07001480 input_set_abs_params(input_dev, ABS_RX, 0, 4096, 0, 0);
1481 input_set_abs_params(input_dev, ABS_Z, -900, 899, 0, 0);
Dmitry Torokhov73a97f42010-03-19 22:18:15 -07001482 /* fall through */
1483
1484 case INTUOS:
Jason Gerecke35120692011-09-08 09:38:14 -07001485 __set_bit(INPUT_PROP_POINTER, input_dev->propbit);
1486
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -07001487 wacom_setup_intuos(wacom_wac);
Dmitry Torokhov73a97f42010-03-19 22:18:15 -07001488 break;
1489
Jason Gerecke9fee6192012-04-03 15:47:22 -07001490 case INTUOS5:
1491 case INTUOS5L:
Jason Gereckeae584ca2012-04-03 15:50:40 -07001492 if (features->device_type == BTN_TOOL_PEN) {
1493 __set_bit(BTN_7, input_dev->keybit);
1494 __set_bit(BTN_8, input_dev->keybit);
1495 }
1496 /* fall through */
1497
1498 case INTUOS5S:
1499 __set_bit(INPUT_PROP_POINTER, input_dev->propbit);
1500
1501 if (features->device_type == BTN_TOOL_PEN) {
1502 for (i = 0; i < 7; i++)
1503 __set_bit(BTN_0 + i, input_dev->keybit);
1504
1505 input_set_abs_params(input_dev, ABS_DISTANCE, 0,
1506 features->distance_max,
1507 0, 0);
1508
1509 input_set_abs_params(input_dev, ABS_Z, -900, 899, 0, 0);
1510
1511 wacom_setup_intuos(wacom_wac);
1512 } else if (features->device_type == BTN_TOOL_FINGER) {
1513 __clear_bit(ABS_MISC, input_dev->absbit);
1514
1515 __set_bit(BTN_TOOL_FINGER, input_dev->keybit);
1516 __set_bit(BTN_TOOL_DOUBLETAP, input_dev->keybit);
1517 __set_bit(BTN_TOOL_TRIPLETAP, input_dev->keybit);
1518 __set_bit(BTN_TOOL_QUADTAP, input_dev->keybit);
1519
Ping Chengf393ee22012-04-29 21:09:17 -07001520 input_mt_init_slots(input_dev, features->touch_max);
Jason Gereckeae584ca2012-04-03 15:50:40 -07001521
1522 input_set_abs_params(input_dev, ABS_MT_TOUCH_MAJOR,
1523 0, 255, 0, 0);
1524
1525 input_set_abs_params(input_dev, ABS_MT_POSITION_X,
1526 0, features->x_max,
1527 features->x_fuzz, 0);
1528 input_set_abs_params(input_dev, ABS_MT_POSITION_Y,
1529 0, features->y_max,
1530 features->y_fuzz, 0);
1531 }
1532 break;
1533
Dmitry Torokhov73a97f42010-03-19 22:18:15 -07001534 case INTUOS4:
1535 case INTUOS4L:
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -07001536 __set_bit(BTN_7, input_dev->keybit);
1537 __set_bit(BTN_8, input_dev->keybit);
Dmitry Torokhov73a97f42010-03-19 22:18:15 -07001538 /* fall through */
1539
1540 case INTUOS4S:
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -07001541 for (i = 0; i < 7; i++)
1542 __set_bit(BTN_0 + i, input_dev->keybit);
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -07001543
1544 input_set_abs_params(input_dev, ABS_Z, -900, 899, 0, 0);
1545 wacom_setup_intuos(wacom_wac);
Jason Gerecke35120692011-09-08 09:38:14 -07001546
1547 __set_bit(INPUT_PROP_POINTER, input_dev->propbit);
Dmitry Torokhov73a97f42010-03-19 22:18:15 -07001548 break;
1549
Ping Cheng19635182012-04-29 21:09:18 -07001550 case MTSCREEN:
Ping Cheng8b4a0c1f2012-01-31 00:07:33 -08001551 if (features->device_type == BTN_TOOL_FINGER) {
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;
Ping Cheng6795a522012-06-28 16:49:00 -07001560 }
1561 /* fall through */
Ping Cheng19635182012-04-29 21:09:18 -07001562
Ping Cheng6795a522012-06-28 16:49:00 -07001563 case TABLETPC2FG:
1564 if (features->device_type == BTN_TOOL_FINGER) {
Ping Chengf393ee22012-04-29 21:09:17 -07001565 input_mt_init_slots(input_dev, features->touch_max);
Ping Cheng84eb5aa2011-03-12 20:35:18 -08001566 input_set_abs_params(input_dev, ABS_MT_TOOL_TYPE,
1567 0, MT_TOOL_MAX, 0, 0);
1568 input_set_abs_params(input_dev, ABS_MT_POSITION_X,
1569 0, features->x_max, 0, 0);
1570 input_set_abs_params(input_dev, ABS_MT_POSITION_Y,
1571 0, features->y_max, 0, 0);
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -07001572 }
Dmitry Torokhov73a97f42010-03-19 22:18:15 -07001573 /* fall through */
1574
1575 case TABLETPC:
Ping Chengac173832012-06-12 00:15:06 -07001576 case TABLETPCE:
Ping Chenga43c7c52011-03-12 20:34:42 -08001577 __clear_bit(ABS_MISC, input_dev->absbit);
1578
Jason Gerecke35120692011-09-08 09:38:14 -07001579 __set_bit(INPUT_PROP_DIRECT, input_dev->propbit);
1580
Ping Chenge35fb8c2011-03-26 21:16:05 -07001581 if (features->device_type != BTN_TOOL_PEN)
Dmitry Torokhov73a97f42010-03-19 22:18:15 -07001582 break; /* no need to process stylus stuff */
Ping Chenge35fb8c2011-03-26 21:16:05 -07001583
Dmitry Torokhov73a97f42010-03-19 22:18:15 -07001584 /* fall through */
1585
1586 case PL:
Ping Chengc8f2edc2010-06-28 01:10:51 -07001587 case DTU:
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -07001588 __set_bit(BTN_TOOL_PEN, input_dev->keybit);
Jason Gerecke35120692011-09-08 09:38:14 -07001589 __set_bit(BTN_TOOL_RUBBER, input_dev->keybit);
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -07001590 __set_bit(BTN_STYLUS, input_dev->keybit);
1591 __set_bit(BTN_STYLUS2, input_dev->keybit);
Jason Gerecke35120692011-09-08 09:38:14 -07001592
1593 __set_bit(INPUT_PROP_DIRECT, input_dev->propbit);
1594 break;
1595
1596 case PTU:
Dmitry Torokhov73a97f42010-03-19 22:18:15 -07001597 __set_bit(BTN_STYLUS2, input_dev->keybit);
1598 /* fall through */
1599
1600 case PENPARTNER:
Jason Gerecke1fab84a2011-08-26 23:18:22 -07001601 __set_bit(BTN_TOOL_PEN, input_dev->keybit);
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -07001602 __set_bit(BTN_TOOL_RUBBER, input_dev->keybit);
Jason Gerecke1fab84a2011-08-26 23:18:22 -07001603 __set_bit(BTN_STYLUS, input_dev->keybit);
Jason Gerecke35120692011-09-08 09:38:14 -07001604
1605 __set_bit(INPUT_PROP_POINTER, input_dev->propbit);
Dmitry Torokhov73a97f42010-03-19 22:18:15 -07001606 break;
Henrik Rydbergcb734c02010-09-05 12:53:16 -07001607
1608 case BAMBOO_PT:
1609 __clear_bit(ABS_MISC, input_dev->absbit);
1610
Jason Gerecke35120692011-09-08 09:38:14 -07001611 __set_bit(INPUT_PROP_POINTER, input_dev->propbit);
1612
Ping Cheng8b4a0c1f2012-01-31 00:07:33 -08001613 if (features->device_type == BTN_TOOL_FINGER) {
Henrik Rydbergcb734c02010-09-05 12:53:16 -07001614 __set_bit(BTN_LEFT, input_dev->keybit);
1615 __set_bit(BTN_FORWARD, input_dev->keybit);
1616 __set_bit(BTN_BACK, input_dev->keybit);
1617 __set_bit(BTN_RIGHT, input_dev->keybit);
1618
1619 __set_bit(BTN_TOOL_FINGER, input_dev->keybit);
1620 __set_bit(BTN_TOOL_DOUBLETAP, input_dev->keybit);
Ping Chengf393ee22012-04-29 21:09:17 -07001621 input_mt_init_slots(input_dev, features->touch_max);
Henrik Rydbergcb734c02010-09-05 12:53:16 -07001622
Chris Bagwell73149ab2011-10-26 22:34:21 -07001623 if (features->pktlen == WACOM_PKGLEN_BBTOUCH3) {
1624 __set_bit(BTN_TOOL_TRIPLETAP,
1625 input_dev->keybit);
1626 __set_bit(BTN_TOOL_QUADTAP,
1627 input_dev->keybit);
1628
Chris Bagwell73149ab2011-10-26 22:34:21 -07001629 input_set_abs_params(input_dev,
1630 ABS_MT_TOUCH_MAJOR,
1631 0, 255, 0, 0);
Chris Bagwell73149ab2011-10-26 22:34:21 -07001632 }
1633
Henrik Rydbergcb734c02010-09-05 12:53:16 -07001634 input_set_abs_params(input_dev, ABS_MT_POSITION_X,
1635 0, features->x_max,
1636 features->x_fuzz, 0);
1637 input_set_abs_params(input_dev, ABS_MT_POSITION_Y,
1638 0, features->y_max,
1639 features->y_fuzz, 0);
Chris Bagwell2aaacb12010-09-12 00:11:35 -07001640 } else if (features->device_type == BTN_TOOL_PEN) {
1641 __set_bit(BTN_TOOL_RUBBER, input_dev->keybit);
1642 __set_bit(BTN_TOOL_PEN, input_dev->keybit);
1643 __set_bit(BTN_STYLUS, input_dev->keybit);
1644 __set_bit(BTN_STYLUS2, input_dev->keybit);
Chris Bagwellc18c2ce2011-10-10 08:52:13 -07001645 input_set_abs_params(input_dev, ABS_DISTANCE, 0,
1646 features->distance_max,
1647 0, 0);
Henrik Rydbergcb734c02010-09-05 12:53:16 -07001648 }
1649 break;
Ping Cheng3bea7332006-07-13 18:01:36 -07001650 }
Ping Cheng19635182012-04-29 21:09:18 -07001651 return 0;
Ping Cheng3bea7332006-07-13 18:01:36 -07001652}
1653
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001654static const struct wacom_features wacom_features_0x00 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001655 { "Wacom Penpartner", WACOM_PKGLEN_PENPRTN, 5040, 3780, 255,
1656 0, PENPARTNER, WACOM_PENPRTN_RES, WACOM_PENPRTN_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001657static const struct wacom_features wacom_features_0x10 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001658 { "Wacom Graphire", WACOM_PKGLEN_GRAPHIRE, 10206, 7422, 511,
1659 63, GRAPHIRE, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001660static const struct wacom_features wacom_features_0x11 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001661 { "Wacom Graphire2 4x5", WACOM_PKGLEN_GRAPHIRE, 10206, 7422, 511,
1662 63, GRAPHIRE, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001663static const struct wacom_features wacom_features_0x12 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001664 { "Wacom Graphire2 5x7", WACOM_PKGLEN_GRAPHIRE, 13918, 10206, 511,
1665 63, GRAPHIRE, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001666static const struct wacom_features wacom_features_0x13 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001667 { "Wacom Graphire3", WACOM_PKGLEN_GRAPHIRE, 10208, 7424, 511,
1668 63, GRAPHIRE, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001669static const struct wacom_features wacom_features_0x14 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001670 { "Wacom Graphire3 6x8", WACOM_PKGLEN_GRAPHIRE, 16704, 12064, 511,
1671 63, GRAPHIRE, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001672static const struct wacom_features wacom_features_0x15 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001673 { "Wacom Graphire4 4x5", WACOM_PKGLEN_GRAPHIRE, 10208, 7424, 511,
1674 63, WACOM_G4, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001675static const struct wacom_features wacom_features_0x16 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001676 { "Wacom Graphire4 6x8", WACOM_PKGLEN_GRAPHIRE, 16704, 12064, 511,
1677 63, WACOM_G4, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001678static const struct wacom_features wacom_features_0x17 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001679 { "Wacom BambooFun 4x5", WACOM_PKGLEN_BBFUN, 14760, 9225, 511,
1680 63, WACOM_MO, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001681static const struct wacom_features wacom_features_0x18 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001682 { "Wacom BambooFun 6x8", WACOM_PKGLEN_BBFUN, 21648, 13530, 511,
1683 63, WACOM_MO, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001684static const struct wacom_features wacom_features_0x19 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001685 { "Wacom Bamboo1 Medium", WACOM_PKGLEN_GRAPHIRE, 16704, 12064, 511,
1686 63, GRAPHIRE, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001687static const struct wacom_features wacom_features_0x60 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001688 { "Wacom Volito", WACOM_PKGLEN_GRAPHIRE, 5104, 3712, 511,
1689 63, GRAPHIRE, WACOM_VOLITO_RES, WACOM_VOLITO_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001690static const struct wacom_features wacom_features_0x61 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001691 { "Wacom PenStation2", WACOM_PKGLEN_GRAPHIRE, 3250, 2320, 255,
1692 63, GRAPHIRE, WACOM_VOLITO_RES, WACOM_VOLITO_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001693static const struct wacom_features wacom_features_0x62 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001694 { "Wacom Volito2 4x5", WACOM_PKGLEN_GRAPHIRE, 5104, 3712, 511,
1695 63, GRAPHIRE, WACOM_VOLITO_RES, WACOM_VOLITO_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001696static const struct wacom_features wacom_features_0x63 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001697 { "Wacom Volito2 2x3", WACOM_PKGLEN_GRAPHIRE, 3248, 2320, 511,
1698 63, GRAPHIRE, WACOM_VOLITO_RES, WACOM_VOLITO_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001699static const struct wacom_features wacom_features_0x64 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001700 { "Wacom PenPartner2", WACOM_PKGLEN_GRAPHIRE, 3250, 2320, 511,
1701 63, GRAPHIRE, WACOM_VOLITO_RES, WACOM_VOLITO_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001702static const struct wacom_features wacom_features_0x65 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001703 { "Wacom Bamboo", WACOM_PKGLEN_BBFUN, 14760, 9225, 511,
1704 63, WACOM_MO, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001705static const struct wacom_features wacom_features_0x69 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001706 { "Wacom Bamboo1", WACOM_PKGLEN_GRAPHIRE, 5104, 3712, 511,
1707 63, GRAPHIRE, WACOM_PENPRTN_RES, WACOM_PENPRTN_RES };
Ping Cheng11d0cf82011-06-27 12:57:58 -07001708static const struct wacom_features wacom_features_0x6A =
1709 { "Wacom Bamboo1 4x6", WACOM_PKGLEN_GRAPHIRE, 14760, 9225, 1023,
1710 63, GRAPHIRE, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
1711static const struct wacom_features wacom_features_0x6B =
1712 { "Wacom Bamboo1 5x8", WACOM_PKGLEN_GRAPHIRE, 21648, 13530, 1023,
1713 63, GRAPHIRE, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001714static const struct wacom_features wacom_features_0x20 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001715 { "Wacom Intuos 4x5", WACOM_PKGLEN_INTUOS, 12700, 10600, 1023,
1716 31, INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001717static const struct wacom_features wacom_features_0x21 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001718 { "Wacom Intuos 6x8", WACOM_PKGLEN_INTUOS, 20320, 16240, 1023,
1719 31, INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001720static const struct wacom_features wacom_features_0x22 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001721 { "Wacom Intuos 9x12", WACOM_PKGLEN_INTUOS, 30480, 24060, 1023,
1722 31, INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001723static const struct wacom_features wacom_features_0x23 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001724 { "Wacom Intuos 12x12", WACOM_PKGLEN_INTUOS, 30480, 31680, 1023,
1725 31, INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001726static const struct wacom_features wacom_features_0x24 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001727 { "Wacom Intuos 12x18", WACOM_PKGLEN_INTUOS, 45720, 31680, 1023,
1728 31, INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001729static const struct wacom_features wacom_features_0x30 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001730 { "Wacom PL400", WACOM_PKGLEN_GRAPHIRE, 5408, 4056, 255,
1731 0, PL, WACOM_PL_RES, WACOM_PL_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001732static const struct wacom_features wacom_features_0x31 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001733 { "Wacom PL500", WACOM_PKGLEN_GRAPHIRE, 6144, 4608, 255,
1734 0, PL, WACOM_PL_RES, WACOM_PL_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001735static const struct wacom_features wacom_features_0x32 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001736 { "Wacom PL600", WACOM_PKGLEN_GRAPHIRE, 6126, 4604, 255,
1737 0, PL, WACOM_PL_RES, WACOM_PL_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001738static const struct wacom_features wacom_features_0x33 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001739 { "Wacom PL600SX", WACOM_PKGLEN_GRAPHIRE, 6260, 5016, 255,
1740 0, PL, WACOM_PL_RES, WACOM_PL_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001741static const struct wacom_features wacom_features_0x34 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001742 { "Wacom PL550", WACOM_PKGLEN_GRAPHIRE, 6144, 4608, 511,
1743 0, PL, WACOM_PL_RES, WACOM_PL_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001744static const struct wacom_features wacom_features_0x35 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001745 { "Wacom PL800", WACOM_PKGLEN_GRAPHIRE, 7220, 5780, 511,
1746 0, PL, WACOM_PL_RES, WACOM_PL_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001747static const struct wacom_features wacom_features_0x37 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001748 { "Wacom PL700", WACOM_PKGLEN_GRAPHIRE, 6758, 5406, 511,
1749 0, PL, WACOM_PL_RES, WACOM_PL_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001750static const struct wacom_features wacom_features_0x38 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001751 { "Wacom PL510", WACOM_PKGLEN_GRAPHIRE, 6282, 4762, 511,
1752 0, PL, WACOM_PL_RES, WACOM_PL_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001753static const struct wacom_features wacom_features_0x39 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001754 { "Wacom DTU710", WACOM_PKGLEN_GRAPHIRE, 34080, 27660, 511,
1755 0, PL, WACOM_PL_RES, WACOM_PL_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001756static const struct wacom_features wacom_features_0xC4 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001757 { "Wacom DTF521", WACOM_PKGLEN_GRAPHIRE, 6282, 4762, 511,
1758 0, PL, WACOM_PL_RES, WACOM_PL_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001759static const struct wacom_features wacom_features_0xC0 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001760 { "Wacom DTF720", WACOM_PKGLEN_GRAPHIRE, 6858, 5506, 511,
1761 0, PL, WACOM_PL_RES, WACOM_PL_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001762static const struct wacom_features wacom_features_0xC2 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001763 { "Wacom DTF720a", WACOM_PKGLEN_GRAPHIRE, 6858, 5506, 511,
1764 0, PL, WACOM_PL_RES, WACOM_PL_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001765static const struct wacom_features wacom_features_0x03 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001766 { "Wacom Cintiq Partner", WACOM_PKGLEN_GRAPHIRE, 20480, 15360, 511,
1767 0, PTU, WACOM_PL_RES, WACOM_PL_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001768static const struct wacom_features wacom_features_0x41 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001769 { "Wacom Intuos2 4x5", WACOM_PKGLEN_INTUOS, 12700, 10600, 1023,
1770 31, INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001771static const struct wacom_features wacom_features_0x42 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001772 { "Wacom Intuos2 6x8", WACOM_PKGLEN_INTUOS, 20320, 16240, 1023,
1773 31, INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001774static const struct wacom_features wacom_features_0x43 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001775 { "Wacom Intuos2 9x12", WACOM_PKGLEN_INTUOS, 30480, 24060, 1023,
1776 31, INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001777static const struct wacom_features wacom_features_0x44 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001778 { "Wacom Intuos2 12x12", WACOM_PKGLEN_INTUOS, 30480, 31680, 1023,
1779 31, INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001780static const struct wacom_features wacom_features_0x45 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001781 { "Wacom Intuos2 12x18", WACOM_PKGLEN_INTUOS, 45720, 31680, 1023,
1782 31, INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001783static const struct wacom_features wacom_features_0xB0 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001784 { "Wacom Intuos3 4x5", WACOM_PKGLEN_INTUOS, 25400, 20320, 1023,
1785 63, INTUOS3S, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001786static const struct wacom_features wacom_features_0xB1 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001787 { "Wacom Intuos3 6x8", WACOM_PKGLEN_INTUOS, 40640, 30480, 1023,
1788 63, INTUOS3, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001789static const struct wacom_features wacom_features_0xB2 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001790 { "Wacom Intuos3 9x12", WACOM_PKGLEN_INTUOS, 60960, 45720, 1023,
1791 63, INTUOS3, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001792static const struct wacom_features wacom_features_0xB3 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001793 { "Wacom Intuos3 12x12", WACOM_PKGLEN_INTUOS, 60960, 60960, 1023,
1794 63, INTUOS3L, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001795static const struct wacom_features wacom_features_0xB4 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001796 { "Wacom Intuos3 12x19", WACOM_PKGLEN_INTUOS, 97536, 60960, 1023,
1797 63, INTUOS3L, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001798static const struct wacom_features wacom_features_0xB5 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001799 { "Wacom Intuos3 6x11", WACOM_PKGLEN_INTUOS, 54204, 31750, 1023,
1800 63, INTUOS3, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001801static const struct wacom_features wacom_features_0xB7 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001802 { "Wacom Intuos3 4x6", WACOM_PKGLEN_INTUOS, 31496, 19685, 1023,
1803 63, INTUOS3S, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001804static const struct wacom_features wacom_features_0xB8 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001805 { "Wacom Intuos4 4x6", WACOM_PKGLEN_INTUOS, 31496, 19685, 2047,
1806 63, INTUOS4S, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001807static const struct wacom_features wacom_features_0xB9 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001808 { "Wacom Intuos4 6x9", WACOM_PKGLEN_INTUOS, 44704, 27940, 2047,
1809 63, INTUOS4, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001810static const struct wacom_features wacom_features_0xBA =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001811 { "Wacom Intuos4 8x13", WACOM_PKGLEN_INTUOS, 65024, 40640, 2047,
1812 63, INTUOS4L, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001813static const struct wacom_features wacom_features_0xBB =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001814 { "Wacom Intuos4 12x19", WACOM_PKGLEN_INTUOS, 97536, 60960, 2047,
1815 63, INTUOS4L, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
Ping Cheng3a4b4aa2010-06-03 22:10:21 -07001816static const struct wacom_features wacom_features_0xBC =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001817 { "Wacom Intuos4 WL", WACOM_PKGLEN_INTUOS, 40840, 25400, 2047,
1818 63, INTUOS4, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
Jason Gerecke9fee6192012-04-03 15:47:22 -07001819static const struct wacom_features wacom_features_0x26 =
1820 { "Wacom Intuos5 touch S", WACOM_PKGLEN_INTUOS, 31496, 19685, 2047,
Ping Chengf393ee22012-04-29 21:09:17 -07001821 63, INTUOS5S, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES,
1822 .touch_max = 16 };
Jason Gerecke9fee6192012-04-03 15:47:22 -07001823static const struct wacom_features wacom_features_0x27 =
1824 { "Wacom Intuos5 touch M", WACOM_PKGLEN_INTUOS, 44704, 27940, 2047,
Ping Chengf393ee22012-04-29 21:09:17 -07001825 63, INTUOS5, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES,
1826 .touch_max = 16 };
Jason Gerecke9fee6192012-04-03 15:47:22 -07001827static const struct wacom_features wacom_features_0x28 =
1828 { "Wacom Intuos5 touch L", WACOM_PKGLEN_INTUOS, 65024, 40640, 2047,
Ping Chengf393ee22012-04-29 21:09:17 -07001829 63, INTUOS5L, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES,
1830 .touch_max = 16 };
Jason Gerecke9fee6192012-04-03 15:47:22 -07001831static const struct wacom_features wacom_features_0x29 =
1832 { "Wacom Intuos5 S", WACOM_PKGLEN_INTUOS, 31496, 19685, 2047,
1833 63, INTUOS5S, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
1834static const struct wacom_features wacom_features_0x2A =
1835 { "Wacom Intuos5 M", WACOM_PKGLEN_INTUOS, 44704, 27940, 2047,
1836 63, INTUOS5, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
Jason Gerecke803296b2011-12-12 00:11:45 -08001837static const struct wacom_features wacom_features_0xF4 =
1838 { "Wacom Cintiq 24HD", WACOM_PKGLEN_INTUOS, 104480, 65600, 2047,
1839 63, WACOM_24HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001840static const struct wacom_features wacom_features_0x3F =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001841 { "Wacom Cintiq 21UX", WACOM_PKGLEN_INTUOS, 87200, 65600, 1023,
1842 63, CINTIQ, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001843static const struct wacom_features wacom_features_0xC5 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001844 { "Wacom Cintiq 20WSX", WACOM_PKGLEN_INTUOS, 86680, 54180, 1023,
1845 63, WACOM_BEE, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001846static const struct wacom_features wacom_features_0xC6 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001847 { "Wacom Cintiq 12WX", WACOM_PKGLEN_INTUOS, 53020, 33440, 1023,
1848 63, WACOM_BEE, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001849static const struct wacom_features wacom_features_0xC7 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001850 { "Wacom DTU1931", WACOM_PKGLEN_GRAPHIRE, 37832, 30305, 511,
1851 0, PL, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Ping Chengc8f2edc2010-06-28 01:10:51 -07001852static const struct wacom_features wacom_features_0xCE =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001853 { "Wacom DTU2231", WACOM_PKGLEN_GRAPHIRE, 47864, 27011, 511,
1854 0, DTU, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Ping Chengc8f2edc2010-06-28 01:10:51 -07001855static const struct wacom_features wacom_features_0xF0 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001856 { "Wacom DTU1631", WACOM_PKGLEN_GRAPHIRE, 34623, 19553, 511,
1857 0, DTU, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Ping Cheng3a4b4aa2010-06-03 22:10:21 -07001858static const struct wacom_features wacom_features_0xCC =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001859 { "Wacom Cintiq 21UX2", WACOM_PKGLEN_INTUOS, 87200, 65600, 2047,
1860 63, WACOM_21UX2, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001861static const struct wacom_features wacom_features_0x90 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001862 { "Wacom ISDv4 90", WACOM_PKGLEN_GRAPHIRE, 26202, 16325, 255,
1863 0, TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001864static const struct wacom_features wacom_features_0x93 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001865 { "Wacom ISDv4 93", WACOM_PKGLEN_GRAPHIRE, 26202, 16325, 255,
1866 0, TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Ping Cheng11d0cf82011-06-27 12:57:58 -07001867static const struct wacom_features wacom_features_0x97 =
1868 { "Wacom ISDv4 97", WACOM_PKGLEN_GRAPHIRE, 26202, 16325, 511,
1869 0, TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001870static const struct wacom_features wacom_features_0x9A =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001871 { "Wacom ISDv4 9A", WACOM_PKGLEN_GRAPHIRE, 26202, 16325, 255,
1872 0, TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001873static const struct wacom_features wacom_features_0x9F =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001874 { "Wacom ISDv4 9F", WACOM_PKGLEN_GRAPHIRE, 26202, 16325, 255,
1875 0, TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001876static const struct wacom_features wacom_features_0xE2 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001877 { "Wacom ISDv4 E2", WACOM_PKGLEN_TPC2FG, 26202, 16325, 255,
Ping Chengf393ee22012-04-29 21:09:17 -07001878 0, TABLETPC2FG, WACOM_INTUOS_RES, WACOM_INTUOS_RES,
1879 .touch_max = 2 };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001880static const struct wacom_features wacom_features_0xE3 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001881 { "Wacom ISDv4 E3", WACOM_PKGLEN_TPC2FG, 26202, 16325, 255,
Ping Chengf393ee22012-04-29 21:09:17 -07001882 0, TABLETPC2FG, WACOM_INTUOS_RES, WACOM_INTUOS_RES,
1883 .touch_max = 2 };
Ping Cheng19635182012-04-29 21:09:18 -07001884static const struct wacom_features wacom_features_0xE5 =
1885 { "Wacom ISDv4 E5", WACOM_PKGLEN_MTOUCH, 26202, 16325, 255,
1886 0, MTSCREEN, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Manoj Iyer26fcd2a2011-03-31 22:39:43 -07001887static const struct wacom_features wacom_features_0xE6 =
1888 { "Wacom ISDv4 E6", WACOM_PKGLEN_TPC2FG, 27760, 15694, 255,
Ping Chengf393ee22012-04-29 21:09:17 -07001889 0, TABLETPC2FG, WACOM_INTUOS_RES, WACOM_INTUOS_RES,
1890 .touch_max = 2 };
Chris Bagwell0d0e3062011-12-11 23:50:59 -08001891static const struct wacom_features wacom_features_0xEC =
1892 { "Wacom ISDv4 EC", WACOM_PKGLEN_GRAPHIRE, 25710, 14500, 255,
1893 0, TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Ping Chengac173832012-06-12 00:15:06 -07001894static const struct wacom_features wacom_features_0xED =
1895 { "Wacom ISDv4 ED", WACOM_PKGLEN_GRAPHIRE, 26202, 16325, 255,
1896 0, TABLETPCE, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
1897static const struct wacom_features wacom_features_0xEF =
1898 { "Wacom ISDv4 EF", WACOM_PKGLEN_GRAPHIRE, 26202, 16325, 255,
1899 0, TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001900static const struct wacom_features wacom_features_0x47 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001901 { "Wacom Intuos2 6x8", WACOM_PKGLEN_INTUOS, 20320, 16240, 1023,
1902 31, INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Chris Bagwelld3825d52012-03-25 23:26:11 -07001903static const struct wacom_features wacom_features_0x84 =
1904 { "Wacom Wireless Receiver", WACOM_PKGLEN_WIRELESS, 0, 0, 0,
Ping Chengf393ee22012-04-29 21:09:17 -07001905 0, WIRELESS, 0, 0, .touch_max = 16 };
Ping Cheng7b824bb2011-03-26 21:16:04 -07001906static const struct wacom_features wacom_features_0xD0 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001907 { "Wacom Bamboo 2FG", WACOM_PKGLEN_BBFUN, 14720, 9200, 1023,
Ping Chengf393ee22012-04-29 21:09:17 -07001908 31, BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES,
1909 .touch_max = 2 };
Ping Cheng7b824bb2011-03-26 21:16:04 -07001910static const struct wacom_features wacom_features_0xD1 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001911 { "Wacom Bamboo 2FG 4x5", WACOM_PKGLEN_BBFUN, 14720, 9200, 1023,
Ping Chengf393ee22012-04-29 21:09:17 -07001912 31, BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES,
1913 .touch_max = 2 };
Ping Cheng7b824bb2011-03-26 21:16:04 -07001914static const struct wacom_features wacom_features_0xD2 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001915 { "Wacom Bamboo Craft", WACOM_PKGLEN_BBFUN, 14720, 9200, 1023,
Chris Bagwellc18c2ce2011-10-10 08:52:13 -07001916 31, BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Ping Cheng7b824bb2011-03-26 21:16:04 -07001917static const struct wacom_features wacom_features_0xD3 =
Chris Bagwellae927562011-10-10 08:52:32 -07001918 { "Wacom Bamboo 2FG 6x8", WACOM_PKGLEN_BBFUN, 21648, 13700, 1023,
Ping Chengf393ee22012-04-29 21:09:17 -07001919 31, BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES,
1920 .touch_max = 2 };
Kevin Granade57a78722010-12-10 23:04:02 -08001921static const struct wacom_features wacom_features_0xD4 =
Ping Chenga001a8f2011-06-27 12:57:58 -07001922 { "Wacom Bamboo Pen", WACOM_PKGLEN_BBFUN, 14720, 9200, 1023,
Chris Bagwellc18c2ce2011-10-10 08:52:13 -07001923 31, BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Gerard Braad18adad12011-08-16 00:17:56 -07001924static const struct wacom_features wacom_features_0xD5 =
Chris Bagwellae927562011-10-10 08:52:32 -07001925 { "Wacom Bamboo Pen 6x8", WACOM_PKGLEN_BBFUN, 21648, 13700, 1023,
Chris Bagwellc18c2ce2011-10-10 08:52:13 -07001926 31, BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Ping Cheng7b824bb2011-03-26 21:16:04 -07001927static const struct wacom_features wacom_features_0xD6 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001928 { "Wacom BambooPT 2FG 4x5", WACOM_PKGLEN_BBFUN, 14720, 9200, 1023,
Ping Chengf393ee22012-04-29 21:09:17 -07001929 31, BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES,
1930 .touch_max = 2 };
Ping Cheng7b824bb2011-03-26 21:16:04 -07001931static const struct wacom_features wacom_features_0xD7 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001932 { "Wacom BambooPT 2FG Small", WACOM_PKGLEN_BBFUN, 14720, 9200, 1023,
Ping Chengf393ee22012-04-29 21:09:17 -07001933 31, BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES,
1934 .touch_max = 2 };
Ping Cheng7b824bb2011-03-26 21:16:04 -07001935static const struct wacom_features wacom_features_0xD8 =
Chris Bagwellae927562011-10-10 08:52:32 -07001936 { "Wacom Bamboo Comic 2FG", WACOM_PKGLEN_BBFUN, 21648, 13700, 1023,
Ping Chengf393ee22012-04-29 21:09:17 -07001937 31, BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES,
1938 .touch_max = 2 };
Ping Cheng7b824bb2011-03-26 21:16:04 -07001939static const struct wacom_features wacom_features_0xDA =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001940 { "Wacom Bamboo 2FG 4x5 SE", WACOM_PKGLEN_BBFUN, 14720, 9200, 1023,
Ping Chengf393ee22012-04-29 21:09:17 -07001941 31, BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES,
1942 .touch_max = 2 };
David Foley47d09232010-12-07 21:05:59 -08001943static struct wacom_features wacom_features_0xDB =
Chris Bagwellae927562011-10-10 08:52:32 -07001944 { "Wacom Bamboo 2FG 6x8 SE", WACOM_PKGLEN_BBFUN, 21648, 13700, 1023,
Ping Chengf393ee22012-04-29 21:09:17 -07001945 31, BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES,
1946 .touch_max = 2 };
Chris Bagwell73149ab2011-10-26 22:34:21 -07001947static const struct wacom_features wacom_features_0xDD =
1948 { "Wacom Bamboo Connect", WACOM_PKGLEN_BBPEN, 14720, 9200, 1023,
1949 31, BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
1950static const struct wacom_features wacom_features_0xDE =
1951 { "Wacom Bamboo 16FG 4x5", WACOM_PKGLEN_BBPEN, 14720, 9200, 1023,
Ping Chengf393ee22012-04-29 21:09:17 -07001952 31, BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES,
1953 .touch_max = 16 };
Chris Bagwell73149ab2011-10-26 22:34:21 -07001954static const struct wacom_features wacom_features_0xDF =
1955 { "Wacom Bamboo 16FG 6x8", WACOM_PKGLEN_BBPEN, 21648, 13700, 1023,
Ping Chengf393ee22012-04-29 21:09:17 -07001956 31, BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES,
1957 .touch_max = 16 };
Ajay Ramaswamy7b4b3062010-12-23 01:19:39 -08001958static const struct wacom_features wacom_features_0x6004 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001959 { "ISD-V4", WACOM_PKGLEN_GRAPHIRE, 12800, 8000, 255,
1960 0, TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Bastian Blankb036f6f2010-02-10 23:06:23 -08001961
1962#define USB_DEVICE_WACOM(prod) \
1963 USB_DEVICE(USB_VENDOR_ID_WACOM, prod), \
1964 .driver_info = (kernel_ulong_t)&wacom_features_##prod
1965
Aristeu Rozanski1483f552011-06-22 01:17:17 -07001966#define USB_DEVICE_DETAILED(prod, class, sub, proto) \
1967 USB_DEVICE_AND_INTERFACE_INFO(USB_VENDOR_ID_WACOM, prod, class, \
1968 sub, proto), \
1969 .driver_info = (kernel_ulong_t)&wacom_features_##prod
1970
Ajay Ramaswamy7b4b3062010-12-23 01:19:39 -08001971#define USB_DEVICE_LENOVO(prod) \
1972 USB_DEVICE(USB_VENDOR_ID_LENOVO, prod), \
1973 .driver_info = (kernel_ulong_t)&wacom_features_##prod
1974
Bastian Blankb036f6f2010-02-10 23:06:23 -08001975const struct usb_device_id wacom_ids[] = {
1976 { USB_DEVICE_WACOM(0x00) },
1977 { USB_DEVICE_WACOM(0x10) },
1978 { USB_DEVICE_WACOM(0x11) },
1979 { USB_DEVICE_WACOM(0x12) },
1980 { USB_DEVICE_WACOM(0x13) },
1981 { USB_DEVICE_WACOM(0x14) },
1982 { USB_DEVICE_WACOM(0x15) },
1983 { USB_DEVICE_WACOM(0x16) },
1984 { USB_DEVICE_WACOM(0x17) },
1985 { USB_DEVICE_WACOM(0x18) },
1986 { USB_DEVICE_WACOM(0x19) },
1987 { USB_DEVICE_WACOM(0x60) },
1988 { USB_DEVICE_WACOM(0x61) },
1989 { USB_DEVICE_WACOM(0x62) },
1990 { USB_DEVICE_WACOM(0x63) },
1991 { USB_DEVICE_WACOM(0x64) },
1992 { USB_DEVICE_WACOM(0x65) },
1993 { USB_DEVICE_WACOM(0x69) },
Ping Cheng11d0cf82011-06-27 12:57:58 -07001994 { USB_DEVICE_WACOM(0x6A) },
1995 { USB_DEVICE_WACOM(0x6B) },
Bastian Blankb036f6f2010-02-10 23:06:23 -08001996 { USB_DEVICE_WACOM(0x20) },
1997 { USB_DEVICE_WACOM(0x21) },
1998 { USB_DEVICE_WACOM(0x22) },
1999 { USB_DEVICE_WACOM(0x23) },
2000 { USB_DEVICE_WACOM(0x24) },
2001 { USB_DEVICE_WACOM(0x30) },
2002 { USB_DEVICE_WACOM(0x31) },
2003 { USB_DEVICE_WACOM(0x32) },
2004 { USB_DEVICE_WACOM(0x33) },
2005 { USB_DEVICE_WACOM(0x34) },
2006 { USB_DEVICE_WACOM(0x35) },
2007 { USB_DEVICE_WACOM(0x37) },
2008 { USB_DEVICE_WACOM(0x38) },
2009 { USB_DEVICE_WACOM(0x39) },
2010 { USB_DEVICE_WACOM(0xC4) },
2011 { USB_DEVICE_WACOM(0xC0) },
2012 { USB_DEVICE_WACOM(0xC2) },
2013 { USB_DEVICE_WACOM(0x03) },
2014 { USB_DEVICE_WACOM(0x41) },
2015 { USB_DEVICE_WACOM(0x42) },
2016 { USB_DEVICE_WACOM(0x43) },
2017 { USB_DEVICE_WACOM(0x44) },
2018 { USB_DEVICE_WACOM(0x45) },
2019 { USB_DEVICE_WACOM(0xB0) },
2020 { USB_DEVICE_WACOM(0xB1) },
2021 { USB_DEVICE_WACOM(0xB2) },
2022 { USB_DEVICE_WACOM(0xB3) },
2023 { USB_DEVICE_WACOM(0xB4) },
2024 { USB_DEVICE_WACOM(0xB5) },
2025 { USB_DEVICE_WACOM(0xB7) },
2026 { USB_DEVICE_WACOM(0xB8) },
2027 { USB_DEVICE_WACOM(0xB9) },
2028 { USB_DEVICE_WACOM(0xBA) },
2029 { USB_DEVICE_WACOM(0xBB) },
Ping Cheng3a4b4aa2010-06-03 22:10:21 -07002030 { USB_DEVICE_WACOM(0xBC) },
Jason Gerecke9fee6192012-04-03 15:47:22 -07002031 { USB_DEVICE_WACOM(0x26) },
2032 { USB_DEVICE_WACOM(0x27) },
2033 { USB_DEVICE_WACOM(0x28) },
2034 { USB_DEVICE_WACOM(0x29) },
2035 { USB_DEVICE_WACOM(0x2A) },
Bastian Blankb036f6f2010-02-10 23:06:23 -08002036 { USB_DEVICE_WACOM(0x3F) },
2037 { USB_DEVICE_WACOM(0xC5) },
2038 { USB_DEVICE_WACOM(0xC6) },
2039 { USB_DEVICE_WACOM(0xC7) },
Aristeu Rozanski1483f552011-06-22 01:17:17 -07002040 /*
2041 * DTU-2231 has two interfaces on the same configuration,
2042 * only one is used.
2043 */
2044 { USB_DEVICE_DETAILED(0xCE, USB_CLASS_HID,
2045 USB_INTERFACE_SUBCLASS_BOOT,
2046 USB_INTERFACE_PROTOCOL_MOUSE) },
Chris Bagwelld3825d52012-03-25 23:26:11 -07002047 { USB_DEVICE_WACOM(0x84) },
Henrik Rydbergcb734c02010-09-05 12:53:16 -07002048 { USB_DEVICE_WACOM(0xD0) },
Chris Bagwell2aaacb12010-09-12 00:11:35 -07002049 { USB_DEVICE_WACOM(0xD1) },
2050 { USB_DEVICE_WACOM(0xD2) },
2051 { USB_DEVICE_WACOM(0xD3) },
Kevin Granade57a78722010-12-10 23:04:02 -08002052 { USB_DEVICE_WACOM(0xD4) },
Gerard Braad18adad12011-08-16 00:17:56 -07002053 { USB_DEVICE_WACOM(0xD5) },
Ping Chengd38acb42011-01-24 09:32:50 -08002054 { USB_DEVICE_WACOM(0xD6) },
2055 { USB_DEVICE_WACOM(0xD7) },
David Foleya318e6b2010-11-30 23:45:46 -08002056 { USB_DEVICE_WACOM(0xD8) },
2057 { USB_DEVICE_WACOM(0xDA) },
David Foley47d09232010-12-07 21:05:59 -08002058 { USB_DEVICE_WACOM(0xDB) },
Chris Bagwell73149ab2011-10-26 22:34:21 -07002059 { USB_DEVICE_WACOM(0xDD) },
2060 { USB_DEVICE_WACOM(0xDE) },
2061 { USB_DEVICE_WACOM(0xDF) },
Ping Chengc8f2edc2010-06-28 01:10:51 -07002062 { USB_DEVICE_WACOM(0xF0) },
Ping Cheng3a4b4aa2010-06-03 22:10:21 -07002063 { USB_DEVICE_WACOM(0xCC) },
Bastian Blankb036f6f2010-02-10 23:06:23 -08002064 { USB_DEVICE_WACOM(0x90) },
2065 { USB_DEVICE_WACOM(0x93) },
Ping Cheng11d0cf82011-06-27 12:57:58 -07002066 { USB_DEVICE_WACOM(0x97) },
Bastian Blankb036f6f2010-02-10 23:06:23 -08002067 { USB_DEVICE_WACOM(0x9A) },
2068 { USB_DEVICE_WACOM(0x9F) },
2069 { USB_DEVICE_WACOM(0xE2) },
2070 { USB_DEVICE_WACOM(0xE3) },
Ping Cheng19635182012-04-29 21:09:18 -07002071 { USB_DEVICE_WACOM(0xE5) },
Manoj Iyer26fcd2a2011-03-31 22:39:43 -07002072 { USB_DEVICE_WACOM(0xE6) },
Chris Bagwell0d0e3062011-12-11 23:50:59 -08002073 { USB_DEVICE_WACOM(0xEC) },
Ping Chengac173832012-06-12 00:15:06 -07002074 { USB_DEVICE_WACOM(0xED) },
2075 { USB_DEVICE_WACOM(0xEF) },
Bastian Blankb036f6f2010-02-10 23:06:23 -08002076 { USB_DEVICE_WACOM(0x47) },
Jason Gerecke803296b2011-12-12 00:11:45 -08002077 { USB_DEVICE_WACOM(0xF4) },
Ajay Ramaswamy7b4b3062010-12-23 01:19:39 -08002078 { USB_DEVICE_LENOVO(0x6004) },
Ping Cheng3bea7332006-07-13 18:01:36 -07002079 { }
2080};
Ping Cheng3bea7332006-07-13 18:01:36 -07002081MODULE_DEVICE_TABLE(usb, wacom_ids);