blob: ea4068b4490bd5c9c10cbc3e3263a86994ac67fa [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
Jason Gerecke4e904952012-10-03 17:19:11 -070028/* Scale factor relating reported contact size to logical contact area.
29 * 2^14/pi is a good approximation on Intuos5 and 3rd-gen Bamboo
30 */
31#define WACOM_CONTACT_AREA_SCALE 2607
32
Dmitry Torokhov95dd3b32010-03-19 22:18:15 -070033static int wacom_penpartner_irq(struct wacom_wac *wacom)
Ping Cheng3bea7332006-07-13 18:01:36 -070034{
35 unsigned char *data = wacom->data;
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -070036 struct input_dev *input = wacom->input;
Ping Cheng3bea7332006-07-13 18:01:36 -070037
38 switch (data[0]) {
Dmitry Torokhov73a97f42010-03-19 22:18:15 -070039 case 1:
40 if (data[5] & 0x80) {
41 wacom->tool[0] = (data[5] & 0x20) ? BTN_TOOL_RUBBER : BTN_TOOL_PEN;
42 wacom->id[0] = (data[5] & 0x20) ? ERASER_DEVICE_ID : STYLUS_DEVICE_ID;
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -070043 input_report_key(input, wacom->tool[0], 1);
44 input_report_abs(input, ABS_MISC, wacom->id[0]); /* report tool id */
Dmitry Torokhov252f7762010-03-19 22:33:38 -070045 input_report_abs(input, ABS_X, get_unaligned_le16(&data[1]));
46 input_report_abs(input, ABS_Y, get_unaligned_le16(&data[3]));
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -070047 input_report_abs(input, ABS_PRESSURE, (signed char)data[6] + 127);
48 input_report_key(input, BTN_TOUCH, ((signed char)data[6] > -127));
49 input_report_key(input, BTN_STYLUS, (data[5] & 0x40));
Dmitry Torokhov73a97f42010-03-19 22:18:15 -070050 } else {
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -070051 input_report_key(input, wacom->tool[0], 0);
52 input_report_abs(input, ABS_MISC, 0); /* report tool id */
53 input_report_abs(input, ABS_PRESSURE, -1);
54 input_report_key(input, BTN_TOUCH, 0);
Dmitry Torokhov73a97f42010-03-19 22:18:15 -070055 }
56 break;
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -070057
Dmitry Torokhov73a97f42010-03-19 22:18:15 -070058 case 2:
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -070059 input_report_key(input, BTN_TOOL_PEN, 1);
60 input_report_abs(input, ABS_MISC, STYLUS_DEVICE_ID); /* report tool id */
Dmitry Torokhov252f7762010-03-19 22:33:38 -070061 input_report_abs(input, ABS_X, get_unaligned_le16(&data[1]));
62 input_report_abs(input, ABS_Y, get_unaligned_le16(&data[3]));
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -070063 input_report_abs(input, ABS_PRESSURE, (signed char)data[6] + 127);
64 input_report_key(input, BTN_TOUCH, ((signed char)data[6] > -80) && !(data[5] & 0x20));
65 input_report_key(input, BTN_STYLUS, (data[5] & 0x40));
Dmitry Torokhov73a97f42010-03-19 22:18:15 -070066 break;
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -070067
Dmitry Torokhov73a97f42010-03-19 22:18:15 -070068 default:
Dmitry Torokhoveb71d1b2012-05-02 00:13:38 -070069 dev_dbg(input->dev.parent,
70 "%s: received unknown report #%d\n", __func__, data[0]);
Dmitry Torokhov73a97f42010-03-19 22:18:15 -070071 return 0;
Ping Cheng3bea7332006-07-13 18:01:36 -070072 }
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -070073
Ping Cheng3bea7332006-07-13 18:01:36 -070074 return 1;
75}
76
Dmitry Torokhov95dd3b32010-03-19 22:18:15 -070077static int wacom_pl_irq(struct wacom_wac *wacom)
Ping Cheng3bea7332006-07-13 18:01:36 -070078{
Jason Childse33da8a2010-02-17 22:38:31 -080079 struct wacom_features *features = &wacom->features;
Ping Cheng3bea7332006-07-13 18:01:36 -070080 unsigned char *data = wacom->data;
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -070081 struct input_dev *input = wacom->input;
Ping Chenge34b9d22008-05-05 11:36:41 -040082 int prox, pressure;
Ping Cheng3bea7332006-07-13 18:01:36 -070083
Ping Chengcad74702009-12-15 00:35:25 -080084 if (data[0] != WACOM_REPORT_PENABLED) {
Dmitry Torokhoveb71d1b2012-05-02 00:13:38 -070085 dev_dbg(input->dev.parent,
86 "%s: received unknown report #%d\n", __func__, data[0]);
Ping Cheng3bea7332006-07-13 18:01:36 -070087 return 0;
88 }
89
90 prox = data[1] & 0x40;
91
Ping Cheng3bea7332006-07-13 18:01:36 -070092 if (prox) {
Ping Chengec67bbe2009-12-15 00:35:24 -080093 wacom->id[0] = ERASER_DEVICE_ID;
Ping Cheng3bea7332006-07-13 18:01:36 -070094 pressure = (signed char)((data[7] << 1) | ((data[4] >> 2) & 1));
Jason Childse33da8a2010-02-17 22:38:31 -080095 if (features->pressure_max > 255)
Ping Cheng3bea7332006-07-13 18:01:36 -070096 pressure = (pressure << 1) | ((data[4] >> 6) & 1);
Jason Childse33da8a2010-02-17 22:38:31 -080097 pressure += (features->pressure_max + 1) / 2;
Ping Cheng3bea7332006-07-13 18:01:36 -070098
99 /*
100 * if going from out of proximity into proximity select between the eraser
101 * and the pen based on the state of the stylus2 button, choose eraser if
102 * pressed else choose pen. if not a proximity change from out to in, send
103 * an out of proximity for previous tool then a in for new tool.
104 */
105 if (!wacom->tool[0]) {
106 /* Eraser bit set for DTF */
107 if (data[1] & 0x10)
108 wacom->tool[1] = BTN_TOOL_RUBBER;
109 else
110 /* Going into proximity select tool */
111 wacom->tool[1] = (data[4] & 0x20) ? BTN_TOOL_RUBBER : BTN_TOOL_PEN;
112 } else {
113 /* was entered with stylus2 pressed */
114 if (wacom->tool[1] == BTN_TOOL_RUBBER && !(data[4] & 0x20)) {
115 /* report out proximity for previous tool */
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700116 input_report_key(input, wacom->tool[1], 0);
117 input_sync(input);
Ping Cheng3bea7332006-07-13 18:01:36 -0700118 wacom->tool[1] = BTN_TOOL_PEN;
119 return 0;
120 }
121 }
122 if (wacom->tool[1] != BTN_TOOL_RUBBER) {
123 /* Unknown tool selected default to pen tool */
124 wacom->tool[1] = BTN_TOOL_PEN;
Ping Chenge34b9d22008-05-05 11:36:41 -0400125 wacom->id[0] = STYLUS_DEVICE_ID;
Ping Cheng3bea7332006-07-13 18:01:36 -0700126 }
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700127 input_report_key(input, wacom->tool[1], prox); /* report in proximity for tool */
128 input_report_abs(input, ABS_MISC, wacom->id[0]); /* report tool id */
129 input_report_abs(input, ABS_X, data[3] | (data[2] << 7) | ((data[1] & 0x03) << 14));
130 input_report_abs(input, ABS_Y, data[6] | (data[5] << 7) | ((data[4] & 0x03) << 14));
131 input_report_abs(input, ABS_PRESSURE, pressure);
Ping Cheng3bea7332006-07-13 18:01:36 -0700132
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700133 input_report_key(input, BTN_TOUCH, data[4] & 0x08);
134 input_report_key(input, BTN_STYLUS, data[4] & 0x10);
Ping Cheng3bea7332006-07-13 18:01:36 -0700135 /* Only allow the stylus2 button to be reported for the pen tool. */
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700136 input_report_key(input, BTN_STYLUS2, (wacom->tool[1] == BTN_TOOL_PEN) && (data[4] & 0x20));
Ping Cheng3bea7332006-07-13 18:01:36 -0700137 } else {
138 /* report proximity-out of a (valid) tool */
139 if (wacom->tool[1] != BTN_TOOL_RUBBER) {
140 /* Unknown tool selected default to pen tool */
141 wacom->tool[1] = BTN_TOOL_PEN;
142 }
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700143 input_report_key(input, wacom->tool[1], prox);
Ping Cheng3bea7332006-07-13 18:01:36 -0700144 }
145
146 wacom->tool[0] = prox; /* Save proximity state */
147 return 1;
148}
149
Dmitry Torokhov95dd3b32010-03-19 22:18:15 -0700150static int wacom_ptu_irq(struct wacom_wac *wacom)
Ping Cheng3bea7332006-07-13 18:01:36 -0700151{
152 unsigned char *data = wacom->data;
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700153 struct input_dev *input = wacom->input;
Ping Cheng3bea7332006-07-13 18:01:36 -0700154
Ping Chengcad74702009-12-15 00:35:25 -0800155 if (data[0] != WACOM_REPORT_PENABLED) {
Dmitry Torokhoveb71d1b2012-05-02 00:13:38 -0700156 dev_dbg(input->dev.parent,
157 "%s: received unknown report #%d\n", __func__, data[0]);
Ping Cheng3bea7332006-07-13 18:01:36 -0700158 return 0;
159 }
160
Ping Cheng3bea7332006-07-13 18:01:36 -0700161 if (data[1] & 0x04) {
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700162 input_report_key(input, BTN_TOOL_RUBBER, data[1] & 0x20);
163 input_report_key(input, BTN_TOUCH, data[1] & 0x08);
Ping Chenge34b9d22008-05-05 11:36:41 -0400164 wacom->id[0] = ERASER_DEVICE_ID;
Ping Cheng3bea7332006-07-13 18:01:36 -0700165 } else {
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700166 input_report_key(input, BTN_TOOL_PEN, data[1] & 0x20);
167 input_report_key(input, BTN_TOUCH, data[1] & 0x01);
Ping Chenge34b9d22008-05-05 11:36:41 -0400168 wacom->id[0] = STYLUS_DEVICE_ID;
Ping Cheng3bea7332006-07-13 18:01:36 -0700169 }
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700170 input_report_abs(input, ABS_MISC, wacom->id[0]); /* report tool id */
Dmitry Torokhov252f7762010-03-19 22:33:38 -0700171 input_report_abs(input, ABS_X, le16_to_cpup((__le16 *)&data[2]));
172 input_report_abs(input, ABS_Y, le16_to_cpup((__le16 *)&data[4]));
173 input_report_abs(input, ABS_PRESSURE, le16_to_cpup((__le16 *)&data[6]));
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700174 input_report_key(input, BTN_STYLUS, data[1] & 0x02);
175 input_report_key(input, BTN_STYLUS2, data[1] & 0x10);
Ping Cheng3bea7332006-07-13 18:01:36 -0700176 return 1;
177}
178
Ping Chengc8f2edc2010-06-28 01:10:51 -0700179static int wacom_dtu_irq(struct wacom_wac *wacom)
180{
181 struct wacom_features *features = &wacom->features;
182 char *data = wacom->data;
183 struct input_dev *input = wacom->input;
184 int prox = data[1] & 0x20, pressure;
185
Dmitry Torokhoveb71d1b2012-05-02 00:13:38 -0700186 dev_dbg(input->dev.parent,
187 "%s: received report #%d", __func__, data[0]);
Ping Chengc8f2edc2010-06-28 01:10:51 -0700188
189 if (prox) {
190 /* Going into proximity select tool */
191 wacom->tool[0] = (data[1] & 0x0c) ? BTN_TOOL_RUBBER : BTN_TOOL_PEN;
192 if (wacom->tool[0] == BTN_TOOL_PEN)
193 wacom->id[0] = STYLUS_DEVICE_ID;
194 else
195 wacom->id[0] = ERASER_DEVICE_ID;
196 }
197 input_report_key(input, BTN_STYLUS, data[1] & 0x02);
198 input_report_key(input, BTN_STYLUS2, data[1] & 0x10);
199 input_report_abs(input, ABS_X, le16_to_cpup((__le16 *)&data[2]));
200 input_report_abs(input, ABS_Y, le16_to_cpup((__le16 *)&data[4]));
201 pressure = ((data[7] & 0x01) << 8) | data[6];
202 if (pressure < 0)
203 pressure = features->pressure_max + pressure + 1;
204 input_report_abs(input, ABS_PRESSURE, pressure);
205 input_report_key(input, BTN_TOUCH, data[1] & 0x05);
206 if (!prox) /* out-prox */
207 wacom->id[0] = 0;
208 input_report_key(input, wacom->tool[0], prox);
209 input_report_abs(input, ABS_MISC, wacom->id[0]);
210 return 1;
211}
212
Dmitry Torokhov95dd3b32010-03-19 22:18:15 -0700213static int wacom_graphire_irq(struct wacom_wac *wacom)
Ping Cheng3bea7332006-07-13 18:01:36 -0700214{
Jason Childse33da8a2010-02-17 22:38:31 -0800215 struct wacom_features *features = &wacom->features;
Ping Cheng3bea7332006-07-13 18:01:36 -0700216 unsigned char *data = wacom->data;
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700217 struct input_dev *input = wacom->input;
Dmitry Torokhov252f7762010-03-19 22:33:38 -0700218 int prox;
Ping Cheng3b57ca02010-03-04 21:50:59 -0800219 int rw = 0;
220 int retval = 0;
Ping Cheng3bea7332006-07-13 18:01:36 -0700221
Ping Chengcad74702009-12-15 00:35:25 -0800222 if (data[0] != WACOM_REPORT_PENABLED) {
Dmitry Torokhoveb71d1b2012-05-02 00:13:38 -0700223 dev_dbg(input->dev.parent,
224 "%s: received unknown report #%d\n", __func__, data[0]);
Ping Cheng3b57ca02010-03-04 21:50:59 -0800225 goto exit;
Ping Cheng3bea7332006-07-13 18:01:36 -0700226 }
227
Ping Cheng3b57ca02010-03-04 21:50:59 -0800228 prox = data[1] & 0x80;
229 if (prox || wacom->id[0]) {
230 if (prox) {
231 switch ((data[1] >> 5) & 3) {
Ping Cheng3bea7332006-07-13 18:01:36 -0700232
233 case 0: /* Pen */
234 wacom->tool[0] = BTN_TOOL_PEN;
Ping Chenge34b9d22008-05-05 11:36:41 -0400235 wacom->id[0] = STYLUS_DEVICE_ID;
Ping Cheng3bea7332006-07-13 18:01:36 -0700236 break;
237
238 case 1: /* Rubber */
239 wacom->tool[0] = BTN_TOOL_RUBBER;
Ping Chenge34b9d22008-05-05 11:36:41 -0400240 wacom->id[0] = ERASER_DEVICE_ID;
Ping Cheng3bea7332006-07-13 18:01:36 -0700241 break;
242
243 case 2: /* Mouse with wheel */
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700244 input_report_key(input, BTN_MIDDLE, data[1] & 0x04);
Ping Cheng3bea7332006-07-13 18:01:36 -0700245 /* fall through */
246
247 case 3: /* Mouse without wheel */
248 wacom->tool[0] = BTN_TOOL_MOUSE;
Ping Chenge34b9d22008-05-05 11:36:41 -0400249 wacom->id[0] = CURSOR_DEVICE_ID;
Ping Cheng3bea7332006-07-13 18:01:36 -0700250 break;
Ping Cheng3b57ca02010-03-04 21:50:59 -0800251 }
Ping Cheng3bea7332006-07-13 18:01:36 -0700252 }
Dmitry Torokhov252f7762010-03-19 22:33:38 -0700253 input_report_abs(input, ABS_X, le16_to_cpup((__le16 *)&data[2]));
254 input_report_abs(input, ABS_Y, le16_to_cpup((__le16 *)&data[4]));
Ping Cheng3bea7332006-07-13 18:01:36 -0700255 if (wacom->tool[0] != BTN_TOOL_MOUSE) {
Chris Bagwell6dc46352012-06-12 00:25:48 -0700256 input_report_abs(input, ABS_PRESSURE, data[6] | ((data[7] & 0x03) << 8));
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700257 input_report_key(input, BTN_TOUCH, data[1] & 0x01);
258 input_report_key(input, BTN_STYLUS, data[1] & 0x02);
259 input_report_key(input, BTN_STYLUS2, data[1] & 0x04);
Dmitry Torokhovafb567e2010-04-13 23:08:58 -0700260 } else {
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700261 input_report_key(input, BTN_LEFT, data[1] & 0x01);
262 input_report_key(input, BTN_RIGHT, data[1] & 0x02);
Ping Cheng3b57ca02010-03-04 21:50:59 -0800263 if (features->type == WACOM_G4 ||
264 features->type == WACOM_MO) {
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700265 input_report_abs(input, ABS_DISTANCE, data[6] & 0x3f);
Mike Autyd9f66c12010-08-28 20:35:17 -0700266 rw = (data[7] & 0x04) - (data[7] & 0x03);
Ping Cheng3b57ca02010-03-04 21:50:59 -0800267 } else {
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700268 input_report_abs(input, ABS_DISTANCE, data[7] & 0x3f);
Mike Autyd9f66c12010-08-28 20:35:17 -0700269 rw = -(signed char)data[6];
Ping Cheng3b57ca02010-03-04 21:50:59 -0800270 }
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700271 input_report_rel(input, REL_WHEEL, rw);
Dmitry Torokhovafb567e2010-04-13 23:08:58 -0700272 }
Ping Cheng3b57ca02010-03-04 21:50:59 -0800273
274 if (!prox)
275 wacom->id[0] = 0;
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700276 input_report_abs(input, ABS_MISC, wacom->id[0]); /* report tool id */
277 input_report_key(input, wacom->tool[0], prox);
Ping Cheng998c4542011-07-06 18:05:41 -0700278 input_event(input, EV_MSC, MSC_SERIAL, 1);
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700279 input_sync(input); /* sync last event */
Ping Cheng80d4e8e2007-02-23 12:22:48 -0800280 }
Ping Cheng3bea7332006-07-13 18:01:36 -0700281
282 /* send pad data */
Jason Childse33da8a2010-02-17 22:38:31 -0800283 switch (features->type) {
Dmitry Torokhov73a97f42010-03-19 22:18:15 -0700284 case WACOM_G4:
Ping Cheng3b57ca02010-03-04 21:50:59 -0800285 prox = data[7] & 0xf8;
286 if (prox || wacom->id[1]) {
Ping Chenge34b9d22008-05-05 11:36:41 -0400287 wacom->id[1] = PAD_DEVICE_ID;
Ping Cheng0bd10ef2011-07-06 18:05:42 -0700288 input_report_key(input, BTN_BACK, (data[7] & 0x40));
289 input_report_key(input, BTN_FORWARD, (data[7] & 0x80));
Ping Cheng3bea7332006-07-13 18:01:36 -0700290 rw = ((data[7] & 0x18) >> 3) - ((data[7] & 0x20) >> 3);
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700291 input_report_rel(input, REL_WHEEL, rw);
Ping Cheng3b57ca02010-03-04 21:50:59 -0800292 if (!prox)
293 wacom->id[1] = 0;
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700294 input_report_abs(input, ABS_MISC, wacom->id[1]);
295 input_event(input, EV_MSC, MSC_SERIAL, 0xf0);
Ping Chengab687b12010-04-05 23:07:41 -0700296 retval = 1;
Ping Cheng3bea7332006-07-13 18:01:36 -0700297 }
Ping Cheng7ecfbfd2007-06-14 23:32:48 -0400298 break;
Dmitry Torokhov73a97f42010-03-19 22:18:15 -0700299
300 case WACOM_MO:
Ping Cheng3b57ca02010-03-04 21:50:59 -0800301 prox = (data[7] & 0xf8) || data[8];
302 if (prox || wacom->id[1]) {
Ping Chenge34b9d22008-05-05 11:36:41 -0400303 wacom->id[1] = PAD_DEVICE_ID;
Ping Cheng0bd10ef2011-07-06 18:05:42 -0700304 input_report_key(input, BTN_BACK, (data[7] & 0x08));
305 input_report_key(input, BTN_LEFT, (data[7] & 0x20));
306 input_report_key(input, BTN_FORWARD, (data[7] & 0x10));
307 input_report_key(input, BTN_RIGHT, (data[7] & 0x40));
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700308 input_report_abs(input, ABS_WHEEL, (data[8] & 0x7f));
Ping Cheng3b57ca02010-03-04 21:50:59 -0800309 if (!prox)
310 wacom->id[1] = 0;
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700311 input_report_abs(input, ABS_MISC, wacom->id[1]);
312 input_event(input, EV_MSC, MSC_SERIAL, 0xf0);
Ping Cheng84460012011-07-06 18:05:43 -0700313 retval = 1;
Ping Cheng7ecfbfd2007-06-14 23:32:48 -0400314 }
315 break;
Ping Cheng3bea7332006-07-13 18:01:36 -0700316 }
Ping Cheng3b57ca02010-03-04 21:50:59 -0800317exit:
318 return retval;
Ping Cheng3bea7332006-07-13 18:01:36 -0700319}
320
Dmitry Torokhov95dd3b32010-03-19 22:18:15 -0700321static int wacom_intuos_inout(struct wacom_wac *wacom)
Ping Cheng3bea7332006-07-13 18:01:36 -0700322{
Jason Childse33da8a2010-02-17 22:38:31 -0800323 struct wacom_features *features = &wacom->features;
Ping Cheng3bea7332006-07-13 18:01:36 -0700324 unsigned char *data = wacom->data;
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700325 struct input_dev *input = wacom->input;
Ping Cheng6f660f12009-05-08 18:30:33 -0700326 int idx = 0;
Ping Cheng3bea7332006-07-13 18:01:36 -0700327
328 /* tool number */
Jason Childse33da8a2010-02-17 22:38:31 -0800329 if (features->type == INTUOS)
Ping Cheng6f660f12009-05-08 18:30:33 -0700330 idx = data[1] & 0x01;
Ping Cheng3bea7332006-07-13 18:01:36 -0700331
332 /* Enter report */
333 if ((data[1] & 0xfc) == 0xc0) {
Jason Gereckeae584ca2012-04-03 15:50:40 -0700334 if (features->type >= INTUOS5S && features->type <= INTUOS5L)
335 wacom->shared->stylus_in_proximity = true;
336
Ping Cheng3bea7332006-07-13 18:01:36 -0700337 /* serial number of the tool */
338 wacom->serial[idx] = ((data[3] & 0x0f) << 28) +
339 (data[4] << 20) + (data[5] << 12) +
340 (data[6] << 4) + (data[7] >> 4);
341
Ping Cheng493630b2010-06-22 11:21:34 -0700342 wacom->id[idx] = (data[2] << 4) | (data[3] >> 4) |
343 ((data[7] & 0x0f) << 20) | ((data[8] & 0xf0) << 12);
Dmitry Torokhov73a97f42010-03-19 22:18:15 -0700344
Ping Cheng493630b2010-06-22 11:21:34 -0700345 switch (wacom->id[idx] & 0xfffff) {
Dmitry Torokhov73a97f42010-03-19 22:18:15 -0700346 case 0x812: /* Inking pen */
347 case 0x801: /* Intuos3 Inking pen */
Ping Cheng493630b2010-06-22 11:21:34 -0700348 case 0x20802: /* Intuos4 Inking Pen */
Dmitry Torokhov73a97f42010-03-19 22:18:15 -0700349 case 0x012:
350 wacom->tool[idx] = BTN_TOOL_PENCIL;
351 break;
352
353 case 0x822: /* Pen */
354 case 0x842:
355 case 0x852:
356 case 0x823: /* Intuos3 Grip Pen */
357 case 0x813: /* Intuos3 Classic Pen */
358 case 0x885: /* Intuos3 Marker Pen */
Ping Cheng3a4b4aa2010-06-03 22:10:21 -0700359 case 0x802: /* Intuos4 General Pen */
Dmitry Torokhov73a97f42010-03-19 22:18:15 -0700360 case 0x804: /* Intuos4 Marker Pen */
361 case 0x40802: /* Intuos4 Classic Pen */
362 case 0x022:
363 wacom->tool[idx] = BTN_TOOL_PEN;
364 break;
365
366 case 0x832: /* Stroke pen */
367 case 0x032:
368 wacom->tool[idx] = BTN_TOOL_BRUSH;
369 break;
370
371 case 0x007: /* Mouse 4D and 2D */
372 case 0x09c:
373 case 0x094:
374 case 0x017: /* Intuos3 2D Mouse */
375 case 0x806: /* Intuos4 Mouse */
376 wacom->tool[idx] = BTN_TOOL_MOUSE;
377 break;
378
379 case 0x096: /* Lens cursor */
380 case 0x097: /* Intuos3 Lens cursor */
381 case 0x006: /* Intuos4 Lens cursor */
382 wacom->tool[idx] = BTN_TOOL_LENS;
383 break;
384
385 case 0x82a: /* Eraser */
386 case 0x85a:
387 case 0x91a:
388 case 0xd1a:
389 case 0x0fa:
390 case 0x82b: /* Intuos3 Grip Pen Eraser */
391 case 0x81b: /* Intuos3 Classic Pen Eraser */
392 case 0x91b: /* Intuos3 Airbrush Eraser */
393 case 0x80c: /* Intuos4 Marker Pen Eraser */
Ping Cheng3a4b4aa2010-06-03 22:10:21 -0700394 case 0x80a: /* Intuos4 General Pen Eraser */
Dmitry Torokhov73a97f42010-03-19 22:18:15 -0700395 case 0x4080a: /* Intuos4 Classic Pen Eraser */
396 case 0x90a: /* Intuos4 Airbrush Eraser */
397 wacom->tool[idx] = BTN_TOOL_RUBBER;
398 break;
399
400 case 0xd12:
401 case 0x912:
402 case 0x112:
403 case 0x913: /* Intuos3 Airbrush */
404 case 0x902: /* Intuos4 Airbrush */
405 wacom->tool[idx] = BTN_TOOL_AIRBRUSH;
406 break;
407
408 default: /* Unknown tool */
409 wacom->tool[idx] = BTN_TOOL_PEN;
410 break;
Ping Cheng3bea7332006-07-13 18:01:36 -0700411 }
Ping Cheng3bea7332006-07-13 18:01:36 -0700412 return 1;
413 }
414
Ping Cheng3a4b4aa2010-06-03 22:10:21 -0700415 /* older I4 styli don't work with new Cintiqs */
416 if (!((wacom->id[idx] >> 20) & 0x01) &&
417 (features->type == WACOM_21UX2))
418 return 1;
419
Ping Cheng3bea7332006-07-13 18:01:36 -0700420 /* Exit report */
421 if ((data[1] & 0xfe) == 0x80) {
Jason Gereckeae584ca2012-04-03 15:50:40 -0700422 if (features->type >= INTUOS5S && features->type <= INTUOS5L)
423 wacom->shared->stylus_in_proximity = false;
424
Ping Cheng6f660f12009-05-08 18:30:33 -0700425 /*
426 * Reset all states otherwise we lose the initial states
427 * when in-prox next time
428 */
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700429 input_report_abs(input, ABS_X, 0);
430 input_report_abs(input, ABS_Y, 0);
431 input_report_abs(input, ABS_DISTANCE, 0);
432 input_report_abs(input, ABS_TILT_X, 0);
433 input_report_abs(input, ABS_TILT_Y, 0);
Ping Cheng80d4e8e2007-02-23 12:22:48 -0800434 if (wacom->tool[idx] >= BTN_TOOL_MOUSE) {
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700435 input_report_key(input, BTN_LEFT, 0);
436 input_report_key(input, BTN_MIDDLE, 0);
437 input_report_key(input, BTN_RIGHT, 0);
438 input_report_key(input, BTN_SIDE, 0);
439 input_report_key(input, BTN_EXTRA, 0);
440 input_report_abs(input, ABS_THROTTLE, 0);
441 input_report_abs(input, ABS_RZ, 0);
Ping Cheng7ecfbfd2007-06-14 23:32:48 -0400442 } else {
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700443 input_report_abs(input, ABS_PRESSURE, 0);
444 input_report_key(input, BTN_STYLUS, 0);
445 input_report_key(input, BTN_STYLUS2, 0);
446 input_report_key(input, BTN_TOUCH, 0);
447 input_report_abs(input, ABS_WHEEL, 0);
Jason Childse33da8a2010-02-17 22:38:31 -0800448 if (features->type >= INTUOS3S)
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700449 input_report_abs(input, ABS_Z, 0);
Ping Cheng8d32e3a2006-09-26 13:34:47 -0700450 }
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700451 input_report_key(input, wacom->tool[idx], 0);
452 input_report_abs(input, ABS_MISC, 0); /* reset tool id */
453 input_event(input, EV_MSC, MSC_SERIAL, wacom->serial[idx]);
Ping Cheng6f660f12009-05-08 18:30:33 -0700454 wacom->id[idx] = 0;
Ping Cheng80d4e8e2007-02-23 12:22:48 -0800455 return 2;
Ping Cheng3bea7332006-07-13 18:01:36 -0700456 }
457 return 0;
458}
459
Dmitry Torokhov95dd3b32010-03-19 22:18:15 -0700460static void wacom_intuos_general(struct wacom_wac *wacom)
Ping Cheng3bea7332006-07-13 18:01:36 -0700461{
Jason Childse33da8a2010-02-17 22:38:31 -0800462 struct wacom_features *features = &wacom->features;
Ping Cheng3bea7332006-07-13 18:01:36 -0700463 unsigned char *data = wacom->data;
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700464 struct input_dev *input = wacom->input;
Ping Cheng3bea7332006-07-13 18:01:36 -0700465 unsigned int t;
466
467 /* general pen packet */
468 if ((data[1] & 0xb8) == 0xa0) {
469 t = (data[6] << 2) | ((data[7] >> 6) & 3);
Aristeu Rozanskica047fe2010-10-10 14:12:33 -0700470 if ((features->type >= INTUOS4S && features->type <= INTUOS4L) ||
Jason Gerecke9fee6192012-04-03 15:47:22 -0700471 (features->type >= INTUOS5S && features->type <= INTUOS5L) ||
Ping Chengd838c642012-07-24 23:54:11 -0700472 (features->type >= WACOM_21UX2 && features->type <= WACOM_24HD)) {
Ping Cheng6f660f12009-05-08 18:30:33 -0700473 t = (t << 1) | (data[1] & 1);
Aristeu Rozanskica047fe2010-10-10 14:12:33 -0700474 }
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700475 input_report_abs(input, ABS_PRESSURE, t);
476 input_report_abs(input, ABS_TILT_X,
Ping Cheng3bea7332006-07-13 18:01:36 -0700477 ((data[7] << 1) & 0x7e) | (data[8] >> 7));
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700478 input_report_abs(input, ABS_TILT_Y, data[8] & 0x7f);
479 input_report_key(input, BTN_STYLUS, data[1] & 2);
480 input_report_key(input, BTN_STYLUS2, data[1] & 4);
481 input_report_key(input, BTN_TOUCH, t > 10);
Ping Cheng3bea7332006-07-13 18:01:36 -0700482 }
483
484 /* airbrush second packet */
485 if ((data[1] & 0xbc) == 0xb4) {
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700486 input_report_abs(input, ABS_WHEEL,
Ping Cheng3bea7332006-07-13 18:01:36 -0700487 (data[6] << 2) | ((data[7] >> 6) & 3));
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700488 input_report_abs(input, ABS_TILT_X,
Ping Cheng3bea7332006-07-13 18:01:36 -0700489 ((data[7] << 1) & 0x7e) | (data[8] >> 7));
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700490 input_report_abs(input, ABS_TILT_Y, data[8] & 0x7f);
Ping Cheng3bea7332006-07-13 18:01:36 -0700491 }
Ping Cheng3bea7332006-07-13 18:01:36 -0700492}
493
Dmitry Torokhov95dd3b32010-03-19 22:18:15 -0700494static int wacom_intuos_irq(struct wacom_wac *wacom)
Ping Cheng3bea7332006-07-13 18:01:36 -0700495{
Jason Childse33da8a2010-02-17 22:38:31 -0800496 struct wacom_features *features = &wacom->features;
Ping Cheng3bea7332006-07-13 18:01:36 -0700497 unsigned char *data = wacom->data;
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700498 struct input_dev *input = wacom->input;
Ping Cheng3bea7332006-07-13 18:01:36 -0700499 unsigned int t;
Ping Cheng6f660f12009-05-08 18:30:33 -0700500 int idx = 0, result;
Ping Cheng3bea7332006-07-13 18:01:36 -0700501
Dmitry Torokhoveb71d1b2012-05-02 00:13:38 -0700502 if (data[0] != WACOM_REPORT_PENABLED &&
503 data[0] != WACOM_REPORT_INTUOSREAD &&
504 data[0] != WACOM_REPORT_INTUOSWRITE &&
505 data[0] != WACOM_REPORT_INTUOSPAD &&
506 data[0] != WACOM_REPORT_INTUOS5PAD) {
507 dev_dbg(input->dev.parent,
508 "%s: received unknown report #%d\n", __func__, data[0]);
Ping Cheng3bea7332006-07-13 18:01:36 -0700509 return 0;
510 }
511
Ping Cheng3bea7332006-07-13 18:01:36 -0700512 /* tool number */
Jason Childse33da8a2010-02-17 22:38:31 -0800513 if (features->type == INTUOS)
Ping Cheng6f660f12009-05-08 18:30:33 -0700514 idx = data[1] & 0x01;
Ping Cheng3bea7332006-07-13 18:01:36 -0700515
516 /* pad packets. Works as a second tool and is always in prox */
Jason Gereckef860e582012-04-03 15:48:35 -0700517 if (data[0] == WACOM_REPORT_INTUOSPAD || data[0] == WACOM_REPORT_INTUOS5PAD) {
Jason Childse33da8a2010-02-17 22:38:31 -0800518 if (features->type >= INTUOS4S && features->type <= INTUOS4L) {
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700519 input_report_key(input, BTN_0, (data[2] & 0x01));
520 input_report_key(input, BTN_1, (data[3] & 0x01));
521 input_report_key(input, BTN_2, (data[3] & 0x02));
522 input_report_key(input, BTN_3, (data[3] & 0x04));
523 input_report_key(input, BTN_4, (data[3] & 0x08));
524 input_report_key(input, BTN_5, (data[3] & 0x10));
525 input_report_key(input, BTN_6, (data[3] & 0x20));
Ping Cheng6f660f12009-05-08 18:30:33 -0700526 if (data[1] & 0x80) {
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700527 input_report_abs(input, ABS_WHEEL, (data[1] & 0x7f));
Ping Chenga8629522009-06-02 16:59:58 -0700528 } else {
529 /* Out of proximity, clear wheel value. */
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700530 input_report_abs(input, ABS_WHEEL, 0);
Ping Cheng6f660f12009-05-08 18:30:33 -0700531 }
Jason Childse33da8a2010-02-17 22:38:31 -0800532 if (features->type != INTUOS4S) {
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700533 input_report_key(input, BTN_7, (data[3] & 0x40));
534 input_report_key(input, BTN_8, (data[3] & 0x80));
Ping Cheng6f660f12009-05-08 18:30:33 -0700535 }
536 if (data[1] | (data[2] & 0x01) | data[3]) {
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700537 input_report_key(input, wacom->tool[1], 1);
538 input_report_abs(input, ABS_MISC, PAD_DEVICE_ID);
Ping Cheng6f660f12009-05-08 18:30:33 -0700539 } else {
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700540 input_report_key(input, wacom->tool[1], 0);
541 input_report_abs(input, ABS_MISC, 0);
Ping Cheng6f660f12009-05-08 18:30:33 -0700542 }
Jason Gerecke803296b2011-12-12 00:11:45 -0800543 } else if (features->type == WACOM_24HD) {
544 input_report_key(input, BTN_0, (data[6] & 0x01));
545 input_report_key(input, BTN_1, (data[6] & 0x02));
546 input_report_key(input, BTN_2, (data[6] & 0x04));
547 input_report_key(input, BTN_3, (data[6] & 0x08));
548 input_report_key(input, BTN_4, (data[6] & 0x10));
549 input_report_key(input, BTN_5, (data[6] & 0x20));
550 input_report_key(input, BTN_6, (data[6] & 0x40));
551 input_report_key(input, BTN_7, (data[6] & 0x80));
552 input_report_key(input, BTN_8, (data[8] & 0x01));
553 input_report_key(input, BTN_9, (data[8] & 0x02));
554 input_report_key(input, BTN_A, (data[8] & 0x04));
555 input_report_key(input, BTN_B, (data[8] & 0x08));
556 input_report_key(input, BTN_C, (data[8] & 0x10));
557 input_report_key(input, BTN_X, (data[8] & 0x20));
558 input_report_key(input, BTN_Y, (data[8] & 0x40));
559 input_report_key(input, BTN_Z, (data[8] & 0x80));
560
561 /*
562 * Three "buttons" are available on the 24HD which are
563 * physically implemented as a touchstrip. Each button
564 * is approximately 3 bits wide with a 2 bit spacing.
565 * The raw touchstrip bits are stored at:
566 * ((data[3] & 0x1f) << 8) | data[4])
567 */
568 input_report_key(input, KEY_PROG1, data[4] & 0x07);
569 input_report_key(input, KEY_PROG2, data[4] & 0xE0);
570 input_report_key(input, KEY_PROG3, data[3] & 0x1C);
571
572 if (data[1] & 0x80) {
573 input_report_abs(input, ABS_WHEEL, (data[1] & 0x7f));
574 } else {
575 /* Out of proximity, clear wheel value. */
576 input_report_abs(input, ABS_WHEEL, 0);
577 }
578
579 if (data[2] & 0x80) {
580 input_report_abs(input, ABS_THROTTLE, (data[2] & 0x7f));
581 } else {
582 /* Out of proximity, clear second wheel value. */
583 input_report_abs(input, ABS_THROTTLE, 0);
584 }
585
586 if (data[1] | data[2] | (data[3] & 0x1f) | data[4] | data[6] | data[8]) {
587 input_report_key(input, wacom->tool[1], 1);
588 input_report_abs(input, ABS_MISC, PAD_DEVICE_ID);
589 } else {
590 input_report_key(input, wacom->tool[1], 0);
591 input_report_abs(input, ABS_MISC, 0);
592 }
Jason Gereckef860e582012-04-03 15:48:35 -0700593 } else if (features->type >= INTUOS5S && features->type <= INTUOS5L) {
594 int i;
595
596 /* Touch ring mode switch has no capacitive sensor */
597 input_report_key(input, BTN_0, (data[3] & 0x01));
598
599 /*
600 * ExpressKeys on Intuos5 have a capacitive sensor in
601 * addition to the mechanical switch. Switch data is
602 * stored in data[4], capacitive data in data[5].
603 */
604 for (i = 0; i < 8; i++)
605 input_report_key(input, BTN_1 + i, data[4] & (1 << i));
606
607 if (data[2] & 0x80) {
608 input_report_abs(input, ABS_WHEEL, (data[2] & 0x7f));
609 } else {
610 /* Out of proximity, clear wheel value. */
611 input_report_abs(input, ABS_WHEEL, 0);
612 }
613
614 if (data[2] | (data[3] & 0x01) | data[4]) {
615 input_report_key(input, wacom->tool[1], 1);
616 input_report_abs(input, ABS_MISC, PAD_DEVICE_ID);
617 } else {
618 input_report_key(input, wacom->tool[1], 0);
619 input_report_abs(input, ABS_MISC, 0);
620 }
Ping Cheng6f660f12009-05-08 18:30:33 -0700621 } else {
Ping Chengd838c642012-07-24 23:54:11 -0700622 if (features->type == WACOM_21UX2 || features->type == WACOM_22HD) {
Ping Cheng3a4b4aa2010-06-03 22:10:21 -0700623 input_report_key(input, BTN_0, (data[5] & 0x01));
624 input_report_key(input, BTN_1, (data[6] & 0x01));
625 input_report_key(input, BTN_2, (data[6] & 0x02));
626 input_report_key(input, BTN_3, (data[6] & 0x04));
627 input_report_key(input, BTN_4, (data[6] & 0x08));
628 input_report_key(input, BTN_5, (data[6] & 0x10));
629 input_report_key(input, BTN_6, (data[6] & 0x20));
630 input_report_key(input, BTN_7, (data[6] & 0x40));
631 input_report_key(input, BTN_8, (data[6] & 0x80));
632 input_report_key(input, BTN_9, (data[7] & 0x01));
633 input_report_key(input, BTN_A, (data[8] & 0x01));
634 input_report_key(input, BTN_B, (data[8] & 0x02));
635 input_report_key(input, BTN_C, (data[8] & 0x04));
636 input_report_key(input, BTN_X, (data[8] & 0x08));
637 input_report_key(input, BTN_Y, (data[8] & 0x10));
638 input_report_key(input, BTN_Z, (data[8] & 0x20));
639 input_report_key(input, BTN_BASE, (data[8] & 0x40));
640 input_report_key(input, BTN_BASE2, (data[8] & 0x80));
Ping Chengd838c642012-07-24 23:54:11 -0700641
642 if (features->type == WACOM_22HD) {
643 input_report_key(input, KEY_PROG1, data[9] & 0x01);
644 input_report_key(input, KEY_PROG2, data[9] & 0x02);
645 input_report_key(input, KEY_PROG3, data[9] & 0x04);
646 }
Ping Cheng3a4b4aa2010-06-03 22:10:21 -0700647 } else {
648 input_report_key(input, BTN_0, (data[5] & 0x01));
649 input_report_key(input, BTN_1, (data[5] & 0x02));
650 input_report_key(input, BTN_2, (data[5] & 0x04));
651 input_report_key(input, BTN_3, (data[5] & 0x08));
652 input_report_key(input, BTN_4, (data[6] & 0x01));
653 input_report_key(input, BTN_5, (data[6] & 0x02));
654 input_report_key(input, BTN_6, (data[6] & 0x04));
655 input_report_key(input, BTN_7, (data[6] & 0x08));
656 input_report_key(input, BTN_8, (data[5] & 0x10));
657 input_report_key(input, BTN_9, (data[6] & 0x10));
658 }
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700659 input_report_abs(input, ABS_RX, ((data[1] & 0x1f) << 8) | data[2]);
660 input_report_abs(input, ABS_RY, ((data[3] & 0x1f) << 8) | data[4]);
Ping Cheng3bea7332006-07-13 18:01:36 -0700661
Ping Cheng493630b2010-06-22 11:21:34 -0700662 if ((data[5] & 0x1f) | data[6] | (data[1] & 0x1f) |
Ping Cheng3a4b4aa2010-06-03 22:10:21 -0700663 data[2] | (data[3] & 0x1f) | data[4] | data[8] |
664 (data[7] & 0x01)) {
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700665 input_report_key(input, wacom->tool[1], 1);
666 input_report_abs(input, ABS_MISC, PAD_DEVICE_ID);
Ping Cheng6f660f12009-05-08 18:30:33 -0700667 } else {
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700668 input_report_key(input, wacom->tool[1], 0);
669 input_report_abs(input, ABS_MISC, 0);
Ping Cheng6f660f12009-05-08 18:30:33 -0700670 }
671 }
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700672 input_event(input, EV_MSC, MSC_SERIAL, 0xffffffff);
Ping Cheng3bea7332006-07-13 18:01:36 -0700673 return 1;
674 }
675
676 /* process in/out prox events */
Dmitry Torokhov95dd3b32010-03-19 22:18:15 -0700677 result = wacom_intuos_inout(wacom);
Ping Cheng3bea7332006-07-13 18:01:36 -0700678 if (result)
Dmitry Torokhov73a97f42010-03-19 22:18:15 -0700679 return result - 1;
Ping Cheng3bea7332006-07-13 18:01:36 -0700680
Ping Cheng6f660f12009-05-08 18:30:33 -0700681 /* don't proceed if we don't know the ID */
682 if (!wacom->id[idx])
683 return 0;
684
685 /* Only large Intuos support Lense Cursor */
Jason Childse33da8a2010-02-17 22:38:31 -0800686 if (wacom->tool[idx] == BTN_TOOL_LENS &&
687 (features->type == INTUOS3 ||
688 features->type == INTUOS3S ||
689 features->type == INTUOS4 ||
Jason Gerecke9fee6192012-04-03 15:47:22 -0700690 features->type == INTUOS4S ||
691 features->type == INTUOS5 ||
692 features->type == INTUOS5S)) {
Jason Childse33da8a2010-02-17 22:38:31 -0800693
Ping Cheng80d4e8e2007-02-23 12:22:48 -0800694 return 0;
Jason Childse33da8a2010-02-17 22:38:31 -0800695 }
Ping Cheng80d4e8e2007-02-23 12:22:48 -0800696
Ping Cheng3bea7332006-07-13 18:01:36 -0700697 /* Cintiq doesn't send data when RDY bit isn't set */
Jason Childse33da8a2010-02-17 22:38:31 -0800698 if (features->type == CINTIQ && !(data[1] & 0x40))
Ping Cheng3bea7332006-07-13 18:01:36 -0700699 return 0;
700
Jason Childse33da8a2010-02-17 22:38:31 -0800701 if (features->type >= INTUOS3S) {
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700702 input_report_abs(input, ABS_X, (data[2] << 9) | (data[3] << 1) | ((data[9] >> 1) & 1));
703 input_report_abs(input, ABS_Y, (data[4] << 9) | (data[5] << 1) | (data[9] & 1));
704 input_report_abs(input, ABS_DISTANCE, ((data[9] >> 2) & 0x3f));
Ping Cheng3bea7332006-07-13 18:01:36 -0700705 } else {
Dmitry Torokhov252f7762010-03-19 22:33:38 -0700706 input_report_abs(input, ABS_X, be16_to_cpup((__be16 *)&data[2]));
707 input_report_abs(input, ABS_Y, be16_to_cpup((__be16 *)&data[4]));
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700708 input_report_abs(input, ABS_DISTANCE, ((data[9] >> 3) & 0x1f));
Ping Cheng3bea7332006-07-13 18:01:36 -0700709 }
710
711 /* process general packets */
Dmitry Torokhov95dd3b32010-03-19 22:18:15 -0700712 wacom_intuos_general(wacom);
Ping Cheng3bea7332006-07-13 18:01:36 -0700713
Ping Cheng6f660f12009-05-08 18:30:33 -0700714 /* 4D mouse, 2D mouse, marker pen rotation, tilt mouse, or Lens cursor packets */
715 if ((data[1] & 0xbc) == 0xa8 || (data[1] & 0xbe) == 0xb0 || (data[1] & 0xbc) == 0xac) {
Ping Cheng3bea7332006-07-13 18:01:36 -0700716
717 if (data[1] & 0x02) {
718 /* Rotation packet */
Jason Childse33da8a2010-02-17 22:38:31 -0800719 if (features->type >= INTUOS3S) {
Ping Cheng0e1763f2008-03-13 16:46:46 -0400720 /* I3 marker pen rotation */
Ping Cheng3bea7332006-07-13 18:01:36 -0700721 t = (data[6] << 3) | ((data[7] >> 5) & 7);
722 t = (data[7] & 0x20) ? ((t > 900) ? ((t-1) / 2 - 1350) :
723 ((t-1) / 2 + 450)) : (450 - t / 2) ;
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700724 input_report_abs(input, ABS_Z, t);
Ping Cheng3bea7332006-07-13 18:01:36 -0700725 } else {
726 /* 4D mouse rotation packet */
727 t = (data[6] << 3) | ((data[7] >> 5) & 7);
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700728 input_report_abs(input, ABS_RZ, (data[7] & 0x20) ?
Ping Cheng3bea7332006-07-13 18:01:36 -0700729 ((t - 1) / 2) : -t / 2);
730 }
731
Jason Childse33da8a2010-02-17 22:38:31 -0800732 } else if (!(data[1] & 0x10) && features->type < INTUOS3S) {
Ping Cheng3bea7332006-07-13 18:01:36 -0700733 /* 4D mouse packet */
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700734 input_report_key(input, BTN_LEFT, data[8] & 0x01);
735 input_report_key(input, BTN_MIDDLE, data[8] & 0x02);
736 input_report_key(input, BTN_RIGHT, data[8] & 0x04);
Ping Cheng3bea7332006-07-13 18:01:36 -0700737
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700738 input_report_key(input, BTN_SIDE, data[8] & 0x20);
739 input_report_key(input, BTN_EXTRA, data[8] & 0x10);
Ping Cheng3bea7332006-07-13 18:01:36 -0700740 t = (data[6] << 2) | ((data[7] >> 6) & 3);
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700741 input_report_abs(input, ABS_THROTTLE, (data[8] & 0x08) ? -t : t);
Ping Cheng3bea7332006-07-13 18:01:36 -0700742
743 } else if (wacom->tool[idx] == BTN_TOOL_MOUSE) {
Ping Cheng6f660f12009-05-08 18:30:33 -0700744 /* I4 mouse */
Jason Gerecke9fee6192012-04-03 15:47:22 -0700745 if ((features->type >= INTUOS4S && features->type <= INTUOS4L) ||
746 (features->type >= INTUOS5S && features->type <= INTUOS5L)) {
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700747 input_report_key(input, BTN_LEFT, data[6] & 0x01);
748 input_report_key(input, BTN_MIDDLE, data[6] & 0x02);
749 input_report_key(input, BTN_RIGHT, data[6] & 0x04);
750 input_report_rel(input, REL_WHEEL, ((data[7] & 0x80) >> 7)
Ping Cheng6f660f12009-05-08 18:30:33 -0700751 - ((data[7] & 0x40) >> 6));
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700752 input_report_key(input, BTN_SIDE, data[6] & 0x08);
753 input_report_key(input, BTN_EXTRA, data[6] & 0x10);
Ping Cheng6f660f12009-05-08 18:30:33 -0700754
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700755 input_report_abs(input, ABS_TILT_X,
Ping Cheng6f660f12009-05-08 18:30:33 -0700756 ((data[7] << 1) & 0x7e) | (data[8] >> 7));
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700757 input_report_abs(input, ABS_TILT_Y, data[8] & 0x7f);
Ping Cheng6f660f12009-05-08 18:30:33 -0700758 } else {
759 /* 2D mouse packet */
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700760 input_report_key(input, BTN_LEFT, data[8] & 0x04);
761 input_report_key(input, BTN_MIDDLE, data[8] & 0x08);
762 input_report_key(input, BTN_RIGHT, data[8] & 0x10);
763 input_report_rel(input, REL_WHEEL, (data[8] & 0x01)
Ping Cheng3bea7332006-07-13 18:01:36 -0700764 - ((data[8] & 0x02) >> 1));
765
Ping Cheng6f660f12009-05-08 18:30:33 -0700766 /* I3 2D mouse side buttons */
Jason Childse33da8a2010-02-17 22:38:31 -0800767 if (features->type >= INTUOS3S && features->type <= INTUOS3L) {
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700768 input_report_key(input, BTN_SIDE, data[8] & 0x40);
769 input_report_key(input, BTN_EXTRA, data[8] & 0x20);
Ping Cheng6f660f12009-05-08 18:30:33 -0700770 }
Ping Cheng3bea7332006-07-13 18:01:36 -0700771 }
Jason Childse33da8a2010-02-17 22:38:31 -0800772 } else if ((features->type < INTUOS3S || features->type == INTUOS3L ||
Jason Gerecke9fee6192012-04-03 15:47:22 -0700773 features->type == INTUOS4L || features->type == INTUOS5L) &&
Ping Cheng6f660f12009-05-08 18:30:33 -0700774 wacom->tool[idx] == BTN_TOOL_LENS) {
Ping Cheng3bea7332006-07-13 18:01:36 -0700775 /* Lens cursor packets */
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700776 input_report_key(input, BTN_LEFT, data[8] & 0x01);
777 input_report_key(input, BTN_MIDDLE, data[8] & 0x02);
778 input_report_key(input, BTN_RIGHT, data[8] & 0x04);
779 input_report_key(input, BTN_SIDE, data[8] & 0x10);
780 input_report_key(input, BTN_EXTRA, data[8] & 0x08);
Ping Cheng3bea7332006-07-13 18:01:36 -0700781 }
782 }
783
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700784 input_report_abs(input, ABS_MISC, wacom->id[idx]); /* report tool id */
785 input_report_key(input, wacom->tool[idx], 1);
786 input_event(input, EV_MSC, MSC_SERIAL, wacom->serial[idx]);
Ping Cheng3bea7332006-07-13 18:01:36 -0700787 return 1;
788}
789
Ping Cheng19635182012-04-29 21:09:18 -0700790static int find_slot_from_contactid(struct wacom_wac *wacom, int contactid)
791{
792 int touch_max = wacom->features.touch_max;
793 int i;
794
795 if (!wacom->slots)
796 return -1;
797
798 for (i = 0; i < touch_max; ++i) {
799 if (wacom->slots[i] == contactid)
800 return i;
801 }
802 for (i = 0; i < touch_max; ++i) {
803 if (wacom->slots[i] == -1)
804 return i;
805 }
806 return -1;
807}
808
809static int wacom_mt_touch(struct wacom_wac *wacom)
810{
811 struct input_dev *input = wacom->input;
812 char *data = wacom->data;
813 int i;
814 int current_num_contacts = data[2];
815 int contacts_to_send = 0;
816
817 /*
818 * First packet resets the counter since only the first
819 * packet in series will have non-zero current_num_contacts.
820 */
821 if (current_num_contacts)
822 wacom->num_contacts_left = current_num_contacts;
823
824 /* There are at most 5 contacts per packet */
825 contacts_to_send = min(5, wacom->num_contacts_left);
826
827 for (i = 0; i < contacts_to_send; i++) {
828 int offset = (WACOM_BYTES_PER_MT_PACKET * i) + 3;
829 bool touch = data[offset] & 0x1;
830 int id = le16_to_cpup((__le16 *)&data[offset + 1]);
831 int slot = find_slot_from_contactid(wacom, id);
832
833 if (slot < 0)
834 continue;
835
836 input_mt_slot(input, slot);
837 input_mt_report_slot_state(input, MT_TOOL_FINGER, touch);
838 if (touch) {
839 int x = le16_to_cpup((__le16 *)&data[offset + 7]);
840 int y = le16_to_cpup((__le16 *)&data[offset + 9]);
841 input_report_abs(input, ABS_MT_POSITION_X, x);
842 input_report_abs(input, ABS_MT_POSITION_Y, y);
843 }
844 wacom->slots[slot] = touch ? id : -1;
845 }
846
847 input_mt_report_pointer_emulation(input, true);
848
849 wacom->num_contacts_left -= contacts_to_send;
850 if (wacom->num_contacts_left < 0)
851 wacom->num_contacts_left = 0;
852
853 return 1;
854}
855
Ping Cheng84eb5aa2011-03-12 20:35:18 -0800856static int wacom_tpc_mt_touch(struct wacom_wac *wacom)
857{
858 struct input_dev *input = wacom->input;
859 unsigned char *data = wacom->data;
860 int contact_with_no_pen_down_count = 0;
861 int i;
862
863 for (i = 0; i < 2; i++) {
864 int p = data[1] & (1 << i);
865 bool touch = p && !wacom->shared->stylus_in_proximity;
866
867 input_mt_slot(input, i);
868 input_mt_report_slot_state(input, MT_TOOL_FINGER, touch);
869 if (touch) {
870 int x = le16_to_cpup((__le16 *)&data[i * 2 + 2]) & 0x7fff;
871 int y = le16_to_cpup((__le16 *)&data[i * 2 + 6]) & 0x7fff;
872
873 input_report_abs(input, ABS_MT_POSITION_X, x);
874 input_report_abs(input, ABS_MT_POSITION_Y, y);
875 contact_with_no_pen_down_count++;
876 }
877 }
878
879 /* keep touch state for pen event */
880 wacom->shared->touch_down = (contact_with_no_pen_down_count > 0);
881
882 input_mt_report_pointer_emulation(input, true);
883
884 return 1;
885}
886
Ping Chenga43c7c52011-03-12 20:34:42 -0800887static int wacom_tpc_single_touch(struct wacom_wac *wacom, size_t len)
Ping Chengec67bbe2009-12-15 00:35:24 -0800888{
889 char *data = wacom->data;
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700890 struct input_dev *input = wacom->input;
Ping Chenga43c7c52011-03-12 20:34:42 -0800891 bool prox;
892 int x = 0, y = 0;
Ping Chengec67bbe2009-12-15 00:35:24 -0800893
Ping Cheng19635182012-04-29 21:09:18 -0700894 if (wacom->features.touch_max > 1 || len > WACOM_PKGLEN_TPC2FG)
895 return 0;
896
Ping Chenga43c7c52011-03-12 20:34:42 -0800897 if (!wacom->shared->stylus_in_proximity) {
898 if (len == WACOM_PKGLEN_TPC1FG) {
899 prox = data[0] & 0x01;
900 x = get_unaligned_le16(&data[1]);
901 y = get_unaligned_le16(&data[3]);
Ping Chengac173832012-06-12 00:15:06 -0700902 } else {
Ping Chenga43c7c52011-03-12 20:34:42 -0800903 prox = data[1] & 0x01;
904 x = le16_to_cpup((__le16 *)&data[2]);
905 y = le16_to_cpup((__le16 *)&data[4]);
Ping Chengec67bbe2009-12-15 00:35:24 -0800906 }
Ping Chenga43c7c52011-03-12 20:34:42 -0800907 } else
908 /* force touch out when pen is in prox */
909 prox = 0;
910
911 if (prox) {
912 input_report_abs(input, ABS_X, x);
913 input_report_abs(input, ABS_Y, y);
Ping Chengec67bbe2009-12-15 00:35:24 -0800914 }
Ping Chenga43c7c52011-03-12 20:34:42 -0800915 input_report_key(input, BTN_TOUCH, prox);
916
917 /* keep touch state for pen events */
918 wacom->shared->touch_down = prox;
919
920 return 1;
Ping Chengec67bbe2009-12-15 00:35:24 -0800921}
922
Ping Cheng8aa9a9a2011-03-12 20:34:11 -0800923static int wacom_tpc_pen(struct wacom_wac *wacom)
Ping Cheng545f4e92008-11-24 11:44:27 -0500924{
Jason Childse33da8a2010-02-17 22:38:31 -0800925 struct wacom_features *features = &wacom->features;
Ping Cheng545f4e92008-11-24 11:44:27 -0500926 char *data = wacom->data;
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700927 struct input_dev *input = wacom->input;
Ping Chenga43c7c52011-03-12 20:34:42 -0800928 int pressure;
929 bool prox = data[1] & 0x20;
Ping Cheng8aa9a9a2011-03-12 20:34:11 -0800930
Ping Chenga43c7c52011-03-12 20:34:42 -0800931 if (!wacom->shared->stylus_in_proximity) /* first in prox */
Ping Cheng8aa9a9a2011-03-12 20:34:11 -0800932 /* Going into proximity select tool */
933 wacom->tool[0] = (data[1] & 0x0c) ? BTN_TOOL_RUBBER : BTN_TOOL_PEN;
Ping Cheng8aa9a9a2011-03-12 20:34:11 -0800934
Ping Chenga43c7c52011-03-12 20:34:42 -0800935 /* keep pen state for touch events */
936 wacom->shared->stylus_in_proximity = prox;
Ping Cheng8aa9a9a2011-03-12 20:34:11 -0800937
Ping Chenga43c7c52011-03-12 20:34:42 -0800938 /* send pen events only when touch is up or forced out */
939 if (!wacom->shared->touch_down) {
940 input_report_key(input, BTN_STYLUS, data[1] & 0x02);
941 input_report_key(input, BTN_STYLUS2, data[1] & 0x10);
942 input_report_abs(input, ABS_X, le16_to_cpup((__le16 *)&data[2]));
943 input_report_abs(input, ABS_Y, le16_to_cpup((__le16 *)&data[4]));
944 pressure = ((data[7] & 0x01) << 8) | data[6];
945 if (pressure < 0)
946 pressure = features->pressure_max + pressure + 1;
947 input_report_abs(input, ABS_PRESSURE, pressure);
948 input_report_key(input, BTN_TOUCH, data[1] & 0x05);
949 input_report_key(input, wacom->tool[0], prox);
950 return 1;
951 }
952
953 return 0;
Ping Cheng8aa9a9a2011-03-12 20:34:11 -0800954}
955
956static int wacom_tpc_irq(struct wacom_wac *wacom, size_t len)
957{
958 char *data = wacom->data;
Ping Cheng545f4e92008-11-24 11:44:27 -0500959
Dmitry Torokhoveb71d1b2012-05-02 00:13:38 -0700960 dev_dbg(wacom->input->dev.parent,
961 "%s: received report #%d\n", __func__, data[0]);
Ping Cheng545f4e92008-11-24 11:44:27 -0500962
Ping Cheng31175a82012-01-31 00:07:33 -0800963 switch (len) {
964 case WACOM_PKGLEN_TPC1FG:
Ping Cheng19635182012-04-29 21:09:18 -0700965 return wacom_tpc_single_touch(wacom, len);
Ping Cheng31175a82012-01-31 00:07:33 -0800966
967 case WACOM_PKGLEN_TPC2FG:
Ping Cheng19635182012-04-29 21:09:18 -0700968 return wacom_tpc_mt_touch(wacom);
Ping Cheng31175a82012-01-31 00:07:33 -0800969
970 default:
971 switch (data[0]) {
972 case WACOM_REPORT_TPC1FG:
973 case WACOM_REPORT_TPCHID:
974 case WACOM_REPORT_TPCST:
Ping Chengac173832012-06-12 00:15:06 -0700975 case WACOM_REPORT_TPC1FGE:
Ping Cheng31175a82012-01-31 00:07:33 -0800976 return wacom_tpc_single_touch(wacom, len);
977
Ping Cheng19635182012-04-29 21:09:18 -0700978 case WACOM_REPORT_TPCMT:
979 return wacom_mt_touch(wacom);
980
Ping Cheng31175a82012-01-31 00:07:33 -0800981 case WACOM_REPORT_PENABLED:
982 return wacom_tpc_pen(wacom);
983 }
984 }
Ping Cheng545f4e92008-11-24 11:44:27 -0500985
Ping Cheng8aa9a9a2011-03-12 20:34:11 -0800986 return 0;
Ping Cheng545f4e92008-11-24 11:44:27 -0500987}
988
Chris Bagwelle1d38e42010-09-12 00:09:27 -0700989static int wacom_bpt_touch(struct wacom_wac *wacom)
Henrik Rydbergcb734c02010-09-05 12:53:16 -0700990{
Henrik Rydbergf4ccbef2010-09-05 12:57:13 -0700991 struct wacom_features *features = &wacom->features;
Henrik Rydbergcb734c02010-09-05 12:53:16 -0700992 struct input_dev *input = wacom->input;
993 unsigned char *data = wacom->data;
Henrik Rydbergcb734c02010-09-05 12:53:16 -0700994 int i;
995
Chris Bagwell5a6c8652011-11-07 19:52:42 -0800996 if (data[0] != 0x02)
997 return 0;
998
Henrik Rydbergcb734c02010-09-05 12:53:16 -0700999 for (i = 0; i < 2; i++) {
Chris Bagwell8f906862011-09-09 13:38:10 -07001000 int offset = (data[1] & 0x80) ? (8 * i) : (9 * i);
1001 bool touch = data[offset + 3] & 0x80;
Henrik Rydbergc5f4dec2010-12-15 13:50:34 +01001002
Chris Bagwell33d5f712010-09-12 00:12:28 -07001003 /*
1004 * Touch events need to be disabled while stylus is
1005 * in proximity because user's hand is resting on touchpad
1006 * and sending unwanted events. User expects tablet buttons
1007 * to continue working though.
1008 */
Chris Bagwell8f906862011-09-09 13:38:10 -07001009 touch = touch && !wacom->shared->stylus_in_proximity;
1010
1011 input_mt_slot(input, i);
1012 input_mt_report_slot_state(input, MT_TOOL_FINGER, touch);
Henrik Rydbergc5f4dec2010-12-15 13:50:34 +01001013 if (touch) {
Chris Bagwell8f906862011-09-09 13:38:10 -07001014 int x = get_unaligned_be16(&data[offset + 3]) & 0x7ff;
1015 int y = get_unaligned_be16(&data[offset + 5]) & 0x7ff;
Henrik Rydbergf4ccbef2010-09-05 12:57:13 -07001016 if (features->quirks & WACOM_QUIRK_BBTOUCH_LOWRES) {
1017 x <<= 5;
1018 y <<= 5;
1019 }
Henrik Rydbergcb734c02010-09-05 12:53:16 -07001020 input_report_abs(input, ABS_MT_POSITION_X, x);
1021 input_report_abs(input, ABS_MT_POSITION_Y, y);
Henrik Rydbergcb734c02010-09-05 12:53:16 -07001022 }
Henrik Rydbergcb734c02010-09-05 12:53:16 -07001023 }
1024
Henrik Rydbergc5f4dec2010-12-15 13:50:34 +01001025 input_mt_report_pointer_emulation(input, true);
Henrik Rydbergcb734c02010-09-05 12:53:16 -07001026
1027 input_report_key(input, BTN_LEFT, (data[1] & 0x08) != 0);
1028 input_report_key(input, BTN_FORWARD, (data[1] & 0x04) != 0);
1029 input_report_key(input, BTN_BACK, (data[1] & 0x02) != 0);
1030 input_report_key(input, BTN_RIGHT, (data[1] & 0x01) != 0);
1031
1032 input_sync(input);
1033
1034 return 0;
1035}
1036
Chris Bagwell73149ab2011-10-26 22:34:21 -07001037static void wacom_bpt3_touch_msg(struct wacom_wac *wacom, unsigned char *data)
1038{
1039 struct input_dev *input = wacom->input;
1040 int slot_id = data[0] - 2; /* data[0] is between 2 and 17 */
1041 bool touch = data[1] & 0x80;
1042
1043 touch = touch && !wacom->shared->stylus_in_proximity;
1044
1045 input_mt_slot(input, slot_id);
1046 input_mt_report_slot_state(input, MT_TOOL_FINGER, touch);
1047
1048 if (touch) {
1049 int x = (data[2] << 4) | (data[4] >> 4);
1050 int y = (data[3] << 4) | (data[4] & 0x0f);
Jason Gerecke4e904952012-10-03 17:19:11 -07001051 int a = data[5];
1052
1053 // "a" is a scaled-down area which we assume is roughly
1054 // circular and which can be described as: a=(pi*r^2)/C.
1055 int x_res = input_abs_get_res(input, ABS_X);
1056 int y_res = input_abs_get_res(input, ABS_Y);
1057 int width = 2 * int_sqrt(a * WACOM_CONTACT_AREA_SCALE);
1058 int height = width * y_res / x_res;
Chris Bagwell73149ab2011-10-26 22:34:21 -07001059
1060 input_report_abs(input, ABS_MT_POSITION_X, x);
1061 input_report_abs(input, ABS_MT_POSITION_Y, y);
Jason Gerecke4e904952012-10-03 17:19:11 -07001062 input_report_abs(input, ABS_MT_TOUCH_MAJOR, width);
1063 input_report_abs(input, ABS_MT_TOUCH_MINOR, height);
Chris Bagwell73149ab2011-10-26 22:34:21 -07001064 }
1065}
1066
1067static void wacom_bpt3_button_msg(struct wacom_wac *wacom, unsigned char *data)
1068{
1069 struct input_dev *input = wacom->input;
1070
1071 input_report_key(input, BTN_LEFT, (data[1] & 0x08) != 0);
1072 input_report_key(input, BTN_FORWARD, (data[1] & 0x04) != 0);
1073 input_report_key(input, BTN_BACK, (data[1] & 0x02) != 0);
1074 input_report_key(input, BTN_RIGHT, (data[1] & 0x01) != 0);
1075}
1076
1077static int wacom_bpt3_touch(struct wacom_wac *wacom)
1078{
1079 struct input_dev *input = wacom->input;
1080 unsigned char *data = wacom->data;
Jason Gerecke19d57d32012-03-06 10:19:19 -08001081 int count = data[1] & 0x07;
Chris Bagwell73149ab2011-10-26 22:34:21 -07001082 int i;
1083
Chris Bagwell5a6c8652011-11-07 19:52:42 -08001084 if (data[0] != 0x02)
1085 return 0;
1086
Chris Bagwell73149ab2011-10-26 22:34:21 -07001087 /* data has up to 7 fixed sized 8-byte messages starting at data[2] */
1088 for (i = 0; i < count; i++) {
1089 int offset = (8 * i) + 2;
1090 int msg_id = data[offset];
1091
1092 if (msg_id >= 2 && msg_id <= 17)
1093 wacom_bpt3_touch_msg(wacom, data + offset);
1094 else if (msg_id == 128)
1095 wacom_bpt3_button_msg(wacom, data + offset);
1096
1097 }
1098
1099 input_mt_report_pointer_emulation(input, true);
1100
1101 input_sync(input);
1102
1103 return 0;
1104}
1105
Chris Bagwell2aaacb12010-09-12 00:11:35 -07001106static int wacom_bpt_pen(struct wacom_wac *wacom)
1107{
1108 struct input_dev *input = wacom->input;
1109 unsigned char *data = wacom->data;
1110 int prox = 0, x = 0, y = 0, p = 0, d = 0, pen = 0, btn1 = 0, btn2 = 0;
1111
Chris Bagwell5a6c8652011-11-07 19:52:42 -08001112 if (data[0] != 0x02)
1113 return 0;
1114
Chris Bagwellc5981412011-10-26 22:28:34 -07001115 prox = (data[1] & 0x20) == 0x20;
Chris Bagwell2aaacb12010-09-12 00:11:35 -07001116
1117 /*
1118 * All reports shared between PEN and RUBBER tool must be
1119 * forced to a known starting value (zero) when transitioning to
1120 * out-of-prox.
1121 *
1122 * If not reset then, to userspace, it will look like lost events
1123 * if new tool comes in-prox with same values as previous tool sent.
1124 *
1125 * Hardware does report zero in most out-of-prox cases but not all.
1126 */
1127 if (prox) {
1128 if (!wacom->shared->stylus_in_proximity) {
1129 if (data[1] & 0x08) {
1130 wacom->tool[0] = BTN_TOOL_RUBBER;
1131 wacom->id[0] = ERASER_DEVICE_ID;
1132 } else {
1133 wacom->tool[0] = BTN_TOOL_PEN;
1134 wacom->id[0] = STYLUS_DEVICE_ID;
1135 }
1136 wacom->shared->stylus_in_proximity = true;
1137 }
1138 x = le16_to_cpup((__le16 *)&data[2]);
1139 y = le16_to_cpup((__le16 *)&data[4]);
1140 p = le16_to_cpup((__le16 *)&data[6]);
Chris Bagwellc18c2ce2011-10-10 08:52:13 -07001141 /*
1142 * Convert distance from out prox to distance from tablet.
1143 * distance will be greater than distance_max once
1144 * touching and applying pressure; do not report negative
1145 * distance.
1146 */
1147 if (data[8] <= wacom->features.distance_max)
1148 d = wacom->features.distance_max - data[8];
1149
Chris Bagwell2aaacb12010-09-12 00:11:35 -07001150 pen = data[1] & 0x01;
1151 btn1 = data[1] & 0x02;
1152 btn2 = data[1] & 0x04;
1153 }
1154
1155 input_report_key(input, BTN_TOUCH, pen);
1156 input_report_key(input, BTN_STYLUS, btn1);
1157 input_report_key(input, BTN_STYLUS2, btn2);
1158
1159 input_report_abs(input, ABS_X, x);
1160 input_report_abs(input, ABS_Y, y);
1161 input_report_abs(input, ABS_PRESSURE, p);
1162 input_report_abs(input, ABS_DISTANCE, d);
1163
1164 if (!prox) {
1165 wacom->id[0] = 0;
1166 wacom->shared->stylus_in_proximity = false;
1167 }
1168
1169 input_report_key(input, wacom->tool[0], prox); /* PEN or RUBBER */
1170 input_report_abs(input, ABS_MISC, wacom->id[0]); /* TOOL ID */
1171
1172 return 1;
1173}
1174
Chris Bagwelle1d38e42010-09-12 00:09:27 -07001175static int wacom_bpt_irq(struct wacom_wac *wacom, size_t len)
1176{
1177 if (len == WACOM_PKGLEN_BBTOUCH)
1178 return wacom_bpt_touch(wacom);
Chris Bagwell73149ab2011-10-26 22:34:21 -07001179 else if (len == WACOM_PKGLEN_BBTOUCH3)
1180 return wacom_bpt3_touch(wacom);
1181 else if (len == WACOM_PKGLEN_BBFUN || len == WACOM_PKGLEN_BBPEN)
Chris Bagwell2aaacb12010-09-12 00:11:35 -07001182 return wacom_bpt_pen(wacom);
Chris Bagwelle1d38e42010-09-12 00:09:27 -07001183
1184 return 0;
1185}
1186
Chris Bagwelld3825d52012-03-25 23:26:11 -07001187static int wacom_wireless_irq(struct wacom_wac *wacom, size_t len)
1188{
Chris Bagwell16bf2882012-03-25 23:26:20 -07001189 unsigned char *data = wacom->data;
1190 int connected;
1191
1192 if (len != WACOM_PKGLEN_WIRELESS || data[0] != 0x80)
Chris Bagwelld3825d52012-03-25 23:26:11 -07001193 return 0;
1194
Chris Bagwell16bf2882012-03-25 23:26:20 -07001195 connected = data[1] & 0x01;
1196 if (connected) {
Chris Bagwella1d552c2012-03-25 23:26:30 -07001197 int pid, battery;
Chris Bagwell16bf2882012-03-25 23:26:20 -07001198
1199 pid = get_unaligned_be16(&data[6]);
Chris Bagwella1d552c2012-03-25 23:26:30 -07001200 battery = data[5] & 0x3f;
Chris Bagwell16bf2882012-03-25 23:26:20 -07001201 if (wacom->pid != pid) {
1202 wacom->pid = pid;
1203 wacom_schedule_work(wacom);
1204 }
Chris Bagwella1d552c2012-03-25 23:26:30 -07001205 wacom->battery_capacity = battery;
Chris Bagwell16bf2882012-03-25 23:26:20 -07001206 } else if (wacom->pid != 0) {
1207 /* disconnected while previously connected */
1208 wacom->pid = 0;
1209 wacom_schedule_work(wacom);
Chris Bagwella1d552c2012-03-25 23:26:30 -07001210 wacom->battery_capacity = 0;
Chris Bagwell16bf2882012-03-25 23:26:20 -07001211 }
1212
Chris Bagwelld3825d52012-03-25 23:26:11 -07001213 return 0;
1214}
1215
Dmitry Torokhov95dd3b32010-03-19 22:18:15 -07001216void wacom_wac_irq(struct wacom_wac *wacom_wac, size_t len)
Ping Cheng3bea7332006-07-13 18:01:36 -07001217{
Dmitry Torokhov95dd3b32010-03-19 22:18:15 -07001218 bool sync;
1219
Jason Childse33da8a2010-02-17 22:38:31 -08001220 switch (wacom_wac->features.type) {
Dmitry Torokhov73a97f42010-03-19 22:18:15 -07001221 case PENPARTNER:
Dmitry Torokhov95dd3b32010-03-19 22:18:15 -07001222 sync = wacom_penpartner_irq(wacom_wac);
1223 break;
Ping Cheng545f4e92008-11-24 11:44:27 -05001224
Dmitry Torokhov73a97f42010-03-19 22:18:15 -07001225 case PL:
Dmitry Torokhov95dd3b32010-03-19 22:18:15 -07001226 sync = wacom_pl_irq(wacom_wac);
1227 break;
Ping Cheng545f4e92008-11-24 11:44:27 -05001228
Dmitry Torokhov73a97f42010-03-19 22:18:15 -07001229 case WACOM_G4:
1230 case GRAPHIRE:
1231 case WACOM_MO:
Dmitry Torokhov95dd3b32010-03-19 22:18:15 -07001232 sync = wacom_graphire_irq(wacom_wac);
1233 break;
Ping Cheng545f4e92008-11-24 11:44:27 -05001234
Dmitry Torokhov73a97f42010-03-19 22:18:15 -07001235 case PTU:
Dmitry Torokhov95dd3b32010-03-19 22:18:15 -07001236 sync = wacom_ptu_irq(wacom_wac);
1237 break;
Ping Cheng545f4e92008-11-24 11:44:27 -05001238
Ping Chengc8f2edc2010-06-28 01:10:51 -07001239 case DTU:
1240 sync = wacom_dtu_irq(wacom_wac);
1241 break;
1242
Dmitry Torokhov73a97f42010-03-19 22:18:15 -07001243 case INTUOS:
1244 case INTUOS3S:
1245 case INTUOS3:
1246 case INTUOS3L:
1247 case INTUOS4S:
1248 case INTUOS4:
1249 case INTUOS4L:
1250 case CINTIQ:
1251 case WACOM_BEE:
Ping Cheng3a4b4aa2010-06-03 22:10:21 -07001252 case WACOM_21UX2:
Ping Chengd838c642012-07-24 23:54:11 -07001253 case WACOM_22HD:
Jason Gerecke803296b2011-12-12 00:11:45 -08001254 case WACOM_24HD:
Dmitry Torokhov95dd3b32010-03-19 22:18:15 -07001255 sync = wacom_intuos_irq(wacom_wac);
1256 break;
Ping Cheng545f4e92008-11-24 11:44:27 -05001257
Jason Gereckeae584ca2012-04-03 15:50:40 -07001258 case INTUOS5S:
1259 case INTUOS5:
1260 case INTUOS5L:
1261 if (len == WACOM_PKGLEN_BBTOUCH3)
1262 sync = wacom_bpt3_touch(wacom_wac);
1263 else
1264 sync = wacom_intuos_irq(wacom_wac);
1265 break;
1266
Dmitry Torokhov73a97f42010-03-19 22:18:15 -07001267 case TABLETPC:
Ping Chengac173832012-06-12 00:15:06 -07001268 case TABLETPCE:
Dmitry Torokhov73a97f42010-03-19 22:18:15 -07001269 case TABLETPC2FG:
Ping Cheng19635182012-04-29 21:09:18 -07001270 case MTSCREEN:
Dmitry Torokhov95dd3b32010-03-19 22:18:15 -07001271 sync = wacom_tpc_irq(wacom_wac, len);
1272 break;
Ping Cheng545f4e92008-11-24 11:44:27 -05001273
Henrik Rydbergcb734c02010-09-05 12:53:16 -07001274 case BAMBOO_PT:
1275 sync = wacom_bpt_irq(wacom_wac, len);
1276 break;
1277
Chris Bagwelld3825d52012-03-25 23:26:11 -07001278 case WIRELESS:
1279 sync = wacom_wireless_irq(wacom_wac, len);
1280 break;
1281
Dmitry Torokhov73a97f42010-03-19 22:18:15 -07001282 default:
Dmitry Torokhov95dd3b32010-03-19 22:18:15 -07001283 sync = false;
1284 break;
Ping Cheng3bea7332006-07-13 18:01:36 -07001285 }
Dmitry Torokhov95dd3b32010-03-19 22:18:15 -07001286
1287 if (sync)
1288 input_sync(wacom_wac->input);
Ping Cheng3bea7332006-07-13 18:01:36 -07001289}
1290
Ping Cheng6521d0b2010-10-24 21:53:40 -07001291static void wacom_setup_cintiq(struct wacom_wac *wacom_wac)
Ping Cheng3bea7332006-07-13 18:01:36 -07001292{
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -07001293 struct input_dev *input_dev = wacom_wac->input;
1294
1295 input_set_capability(input_dev, EV_MSC, MSC_SERIAL);
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -07001296
1297 __set_bit(BTN_TOOL_RUBBER, input_dev->keybit);
1298 __set_bit(BTN_TOOL_PEN, input_dev->keybit);
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -07001299 __set_bit(BTN_TOOL_BRUSH, input_dev->keybit);
1300 __set_bit(BTN_TOOL_PENCIL, input_dev->keybit);
1301 __set_bit(BTN_TOOL_AIRBRUSH, input_dev->keybit);
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -07001302 __set_bit(BTN_STYLUS, input_dev->keybit);
1303 __set_bit(BTN_STYLUS2, input_dev->keybit);
1304
1305 input_set_abs_params(input_dev, ABS_DISTANCE,
1306 0, wacom_wac->features.distance_max, 0, 0);
1307 input_set_abs_params(input_dev, ABS_WHEEL, 0, 1023, 0, 0);
1308 input_set_abs_params(input_dev, ABS_TILT_X, 0, 127, 0, 0);
1309 input_set_abs_params(input_dev, ABS_TILT_Y, 0, 127, 0, 0);
Ping Cheng6521d0b2010-10-24 21:53:40 -07001310}
1311
1312static void wacom_setup_intuos(struct wacom_wac *wacom_wac)
1313{
1314 struct input_dev *input_dev = wacom_wac->input;
1315
1316 input_set_capability(input_dev, EV_REL, REL_WHEEL);
1317
1318 wacom_setup_cintiq(wacom_wac);
1319
1320 __set_bit(BTN_LEFT, input_dev->keybit);
1321 __set_bit(BTN_RIGHT, input_dev->keybit);
1322 __set_bit(BTN_MIDDLE, input_dev->keybit);
1323 __set_bit(BTN_SIDE, input_dev->keybit);
1324 __set_bit(BTN_EXTRA, input_dev->keybit);
1325 __set_bit(BTN_TOOL_MOUSE, input_dev->keybit);
1326 __set_bit(BTN_TOOL_LENS, input_dev->keybit);
1327
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -07001328 input_set_abs_params(input_dev, ABS_RZ, -900, 899, 0, 0);
1329 input_set_abs_params(input_dev, ABS_THROTTLE, -1023, 1023, 0, 0);
1330}
1331
Henrik Rydbergbc73dd32010-09-05 12:26:16 -07001332void wacom_setup_device_quirks(struct wacom_features *features)
1333{
1334
1335 /* touch device found but size is not defined. use default */
Ping Cheng84eb5aa2011-03-12 20:35:18 -08001336 if (features->device_type == BTN_TOOL_FINGER && !features->x_max) {
Henrik Rydbergbc73dd32010-09-05 12:26:16 -07001337 features->x_max = 1023;
1338 features->y_max = 1023;
1339 }
1340
1341 /* these device have multiple inputs */
Ping Chengea2e6022012-06-12 00:14:12 -07001342 if (features->type >= WIRELESS ||
1343 (features->type >= INTUOS5S && features->type <= INTUOS5L))
Henrik Rydbergbc73dd32010-09-05 12:26:16 -07001344 features->quirks |= WACOM_QUIRK_MULTI_INPUT;
Henrik Rydbergcb734c02010-09-05 12:53:16 -07001345
Chris Bagwell73149ab2011-10-26 22:34:21 -07001346 /* quirk for bamboo touch with 2 low res touches */
Henrik Rydbergcb734c02010-09-05 12:53:16 -07001347 if (features->type == BAMBOO_PT &&
Chris Bagwell73149ab2011-10-26 22:34:21 -07001348 features->pktlen == WACOM_PKGLEN_BBTOUCH) {
Henrik Rydbergf4ccbef2010-09-05 12:57:13 -07001349 features->x_max <<= 5;
1350 features->y_max <<= 5;
1351 features->x_fuzz <<= 5;
1352 features->y_fuzz <<= 5;
Henrik Rydbergf4ccbef2010-09-05 12:57:13 -07001353 features->quirks |= WACOM_QUIRK_BBTOUCH_LOWRES;
Henrik Rydbergcb734c02010-09-05 12:53:16 -07001354 }
Chris Bagwelld3825d52012-03-25 23:26:11 -07001355
1356 if (features->type == WIRELESS) {
1357
1358 /* monitor never has input and pen/touch have delayed create */
1359 features->quirks |= WACOM_QUIRK_NO_INPUT;
1360
1361 /* must be monitor interface if no device_type set */
1362 if (!features->device_type)
1363 features->quirks |= WACOM_QUIRK_MONITOR;
1364 }
Henrik Rydbergbc73dd32010-09-05 12:26:16 -07001365}
1366
Ping Cheng409550f2011-01-25 18:03:13 -08001367static unsigned int wacom_calculate_touch_res(unsigned int logical_max,
1368 unsigned int physical_max)
1369{
1370 /* Touch physical dimensions are in 100th of mm */
1371 return (logical_max * 100) / physical_max;
1372}
1373
Ping Cheng19635182012-04-29 21:09:18 -07001374int wacom_setup_input_capabilities(struct input_dev *input_dev,
1375 struct wacom_wac *wacom_wac)
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -07001376{
1377 struct wacom_features *features = &wacom_wac->features;
1378 int i;
1379
1380 input_dev->evbit[0] |= BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS);
1381
1382 __set_bit(BTN_TOUCH, input_dev->keybit);
1383
Henrik Rydbergfed87e62010-09-05 12:25:11 -07001384 input_set_abs_params(input_dev, ABS_X, 0, features->x_max,
1385 features->x_fuzz, 0);
1386 input_set_abs_params(input_dev, ABS_Y, 0, features->y_max,
1387 features->y_fuzz, 0);
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -07001388
Ping Chenge35fb8c2011-03-26 21:16:05 -07001389 if (features->device_type == BTN_TOOL_PEN) {
Ping Chengcfb7d552011-08-26 23:10:02 -07001390 input_set_abs_params(input_dev, ABS_PRESSURE, 0, features->pressure_max,
1391 features->pressure_fuzz, 0);
1392
Ping Chenge35fb8c2011-03-26 21:16:05 -07001393 /* penabled devices have fixed resolution for each model */
1394 input_abs_set_res(input_dev, ABS_X, features->x_resolution);
1395 input_abs_set_res(input_dev, ABS_Y, features->y_resolution);
1396 } else {
1397 input_abs_set_res(input_dev, ABS_X,
1398 wacom_calculate_touch_res(features->x_max,
1399 features->x_phy));
1400 input_abs_set_res(input_dev, ABS_Y,
1401 wacom_calculate_touch_res(features->y_max,
1402 features->y_phy));
1403 }
1404
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -07001405 __set_bit(ABS_MISC, input_dev->absbit);
1406
Jason Childse33da8a2010-02-17 22:38:31 -08001407 switch (wacom_wac->features.type) {
Dmitry Torokhov73a97f42010-03-19 22:18:15 -07001408 case WACOM_MO:
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -07001409 input_set_abs_params(input_dev, ABS_WHEEL, 0, 71, 0, 0);
1410 /* fall through */
Ping Chengec67bbe2009-12-15 00:35:24 -08001411
Dmitry Torokhov73a97f42010-03-19 22:18:15 -07001412 case WACOM_G4:
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -07001413 input_set_capability(input_dev, EV_MSC, MSC_SERIAL);
1414
Ping Cheng0bd10ef2011-07-06 18:05:42 -07001415 __set_bit(BTN_BACK, input_dev->keybit);
1416 __set_bit(BTN_FORWARD, input_dev->keybit);
Dmitry Torokhov73a97f42010-03-19 22:18:15 -07001417 /* fall through */
1418
1419 case GRAPHIRE:
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -07001420 input_set_capability(input_dev, EV_REL, REL_WHEEL);
1421
1422 __set_bit(BTN_LEFT, input_dev->keybit);
1423 __set_bit(BTN_RIGHT, input_dev->keybit);
1424 __set_bit(BTN_MIDDLE, input_dev->keybit);
1425
1426 __set_bit(BTN_TOOL_RUBBER, input_dev->keybit);
1427 __set_bit(BTN_TOOL_PEN, input_dev->keybit);
1428 __set_bit(BTN_TOOL_MOUSE, input_dev->keybit);
1429 __set_bit(BTN_STYLUS, input_dev->keybit);
1430 __set_bit(BTN_STYLUS2, input_dev->keybit);
Jason Gerecke35120692011-09-08 09:38:14 -07001431
1432 __set_bit(INPUT_PROP_POINTER, input_dev->propbit);
Dmitry Torokhov73a97f42010-03-19 22:18:15 -07001433 break;
1434
Jason Gerecke803296b2011-12-12 00:11:45 -08001435 case WACOM_24HD:
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
1443 for (i = 0; i < 10; i++)
1444 __set_bit(BTN_0 + i, input_dev->keybit);
1445
1446 __set_bit(KEY_PROG1, input_dev->keybit);
1447 __set_bit(KEY_PROG2, input_dev->keybit);
1448 __set_bit(KEY_PROG3, input_dev->keybit);
1449
1450 input_set_abs_params(input_dev, ABS_Z, -900, 899, 0, 0);
1451 input_set_abs_params(input_dev, ABS_THROTTLE, 0, 71, 0, 0);
1452 wacom_setup_cintiq(wacom_wac);
1453 break;
1454
Ping Chengd838c642012-07-24 23:54:11 -07001455 case WACOM_22HD:
1456 __set_bit(KEY_PROG1, input_dev->keybit);
1457 __set_bit(KEY_PROG2, input_dev->keybit);
1458 __set_bit(KEY_PROG3, input_dev->keybit);
1459 /* fall through */
1460
Ping Cheng3a4b4aa2010-06-03 22:10:21 -07001461 case WACOM_21UX2:
1462 __set_bit(BTN_A, input_dev->keybit);
1463 __set_bit(BTN_B, input_dev->keybit);
1464 __set_bit(BTN_C, input_dev->keybit);
1465 __set_bit(BTN_X, input_dev->keybit);
1466 __set_bit(BTN_Y, input_dev->keybit);
1467 __set_bit(BTN_Z, input_dev->keybit);
1468 __set_bit(BTN_BASE, input_dev->keybit);
1469 __set_bit(BTN_BASE2, input_dev->keybit);
1470 /* fall through */
1471
Dmitry Torokhov73a97f42010-03-19 22:18:15 -07001472 case WACOM_BEE:
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -07001473 __set_bit(BTN_8, input_dev->keybit);
1474 __set_bit(BTN_9, input_dev->keybit);
1475 /* fall through */
Dmitry Torokhov73a97f42010-03-19 22:18:15 -07001476
Ping Cheng6521d0b2010-10-24 21:53:40 -07001477 case CINTIQ:
1478 for (i = 0; i < 8; i++)
1479 __set_bit(BTN_0 + i, input_dev->keybit);
Ping Cheng6521d0b2010-10-24 21:53:40 -07001480
Jason Gerecked6069da2011-10-04 22:50:45 -07001481 input_set_abs_params(input_dev, ABS_RX, 0, 4096, 0, 0);
1482 input_set_abs_params(input_dev, ABS_RY, 0, 4096, 0, 0);
Ping Cheng6521d0b2010-10-24 21:53:40 -07001483 input_set_abs_params(input_dev, ABS_Z, -900, 899, 0, 0);
Jason Gerecke35120692011-09-08 09:38:14 -07001484
1485 __set_bit(INPUT_PROP_DIRECT, input_dev->propbit);
1486
Ping Cheng6521d0b2010-10-24 21:53:40 -07001487 wacom_setup_cintiq(wacom_wac);
1488 break;
1489
Dmitry Torokhov73a97f42010-03-19 22:18:15 -07001490 case INTUOS3:
1491 case INTUOS3L:
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -07001492 __set_bit(BTN_4, input_dev->keybit);
1493 __set_bit(BTN_5, input_dev->keybit);
1494 __set_bit(BTN_6, input_dev->keybit);
1495 __set_bit(BTN_7, input_dev->keybit);
1496
1497 input_set_abs_params(input_dev, ABS_RY, 0, 4096, 0, 0);
Dmitry Torokhov73a97f42010-03-19 22:18:15 -07001498 /* fall through */
1499
1500 case INTUOS3S:
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -07001501 __set_bit(BTN_0, input_dev->keybit);
1502 __set_bit(BTN_1, input_dev->keybit);
1503 __set_bit(BTN_2, input_dev->keybit);
1504 __set_bit(BTN_3, input_dev->keybit);
1505
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -07001506 input_set_abs_params(input_dev, ABS_RX, 0, 4096, 0, 0);
1507 input_set_abs_params(input_dev, ABS_Z, -900, 899, 0, 0);
Dmitry Torokhov73a97f42010-03-19 22:18:15 -07001508 /* fall through */
1509
1510 case INTUOS:
Jason Gerecke35120692011-09-08 09:38:14 -07001511 __set_bit(INPUT_PROP_POINTER, input_dev->propbit);
1512
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -07001513 wacom_setup_intuos(wacom_wac);
Dmitry Torokhov73a97f42010-03-19 22:18:15 -07001514 break;
1515
Jason Gerecke9fee6192012-04-03 15:47:22 -07001516 case INTUOS5:
1517 case INTUOS5L:
Jason Gereckeae584ca2012-04-03 15:50:40 -07001518 if (features->device_type == BTN_TOOL_PEN) {
1519 __set_bit(BTN_7, input_dev->keybit);
1520 __set_bit(BTN_8, input_dev->keybit);
1521 }
1522 /* fall through */
1523
1524 case INTUOS5S:
1525 __set_bit(INPUT_PROP_POINTER, input_dev->propbit);
1526
1527 if (features->device_type == BTN_TOOL_PEN) {
1528 for (i = 0; i < 7; i++)
1529 __set_bit(BTN_0 + i, input_dev->keybit);
1530
1531 input_set_abs_params(input_dev, ABS_DISTANCE, 0,
1532 features->distance_max,
1533 0, 0);
1534
1535 input_set_abs_params(input_dev, ABS_Z, -900, 899, 0, 0);
1536
1537 wacom_setup_intuos(wacom_wac);
1538 } else if (features->device_type == BTN_TOOL_FINGER) {
1539 __clear_bit(ABS_MISC, input_dev->absbit);
1540
1541 __set_bit(BTN_TOOL_FINGER, input_dev->keybit);
1542 __set_bit(BTN_TOOL_DOUBLETAP, input_dev->keybit);
1543 __set_bit(BTN_TOOL_TRIPLETAP, input_dev->keybit);
1544 __set_bit(BTN_TOOL_QUADTAP, input_dev->keybit);
1545
Henrik Rydbergb4adbbe2012-08-11 22:07:55 +02001546 input_mt_init_slots(input_dev, features->touch_max, 0);
Jason Gereckeae584ca2012-04-03 15:50:40 -07001547
1548 input_set_abs_params(input_dev, ABS_MT_TOUCH_MAJOR,
Jason Gerecke4e904952012-10-03 17:19:11 -07001549 0, features->x_max, 0, 0);
1550 input_set_abs_params(input_dev, ABS_MT_TOUCH_MINOR,
1551 0, features->y_max, 0, 0);
Jason Gereckeae584ca2012-04-03 15:50:40 -07001552
1553 input_set_abs_params(input_dev, ABS_MT_POSITION_X,
1554 0, features->x_max,
1555 features->x_fuzz, 0);
1556 input_set_abs_params(input_dev, ABS_MT_POSITION_Y,
1557 0, features->y_max,
1558 features->y_fuzz, 0);
1559 }
1560 break;
1561
Dmitry Torokhov73a97f42010-03-19 22:18:15 -07001562 case INTUOS4:
1563 case INTUOS4L:
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -07001564 __set_bit(BTN_7, input_dev->keybit);
1565 __set_bit(BTN_8, input_dev->keybit);
Dmitry Torokhov73a97f42010-03-19 22:18:15 -07001566 /* fall through */
1567
1568 case INTUOS4S:
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -07001569 for (i = 0; i < 7; i++)
1570 __set_bit(BTN_0 + i, input_dev->keybit);
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -07001571
1572 input_set_abs_params(input_dev, ABS_Z, -900, 899, 0, 0);
1573 wacom_setup_intuos(wacom_wac);
Jason Gerecke35120692011-09-08 09:38:14 -07001574
1575 __set_bit(INPUT_PROP_POINTER, input_dev->propbit);
Dmitry Torokhov73a97f42010-03-19 22:18:15 -07001576 break;
1577
Ping Cheng19635182012-04-29 21:09:18 -07001578 case MTSCREEN:
Ping Cheng8b4a0c12012-01-31 00:07:33 -08001579 if (features->device_type == BTN_TOOL_FINGER) {
Ping Cheng19635182012-04-29 21:09:18 -07001580 wacom_wac->slots = kmalloc(features->touch_max *
1581 sizeof(int),
1582 GFP_KERNEL);
1583 if (!wacom_wac->slots)
1584 return -ENOMEM;
1585
1586 for (i = 0; i < features->touch_max; i++)
1587 wacom_wac->slots[i] = -1;
Ping Cheng6795a522012-06-28 16:49:00 -07001588 }
1589 /* fall through */
Ping Cheng19635182012-04-29 21:09:18 -07001590
Ping Cheng6795a522012-06-28 16:49:00 -07001591 case TABLETPC2FG:
1592 if (features->device_type == BTN_TOOL_FINGER) {
Henrik Rydbergb4adbbe2012-08-11 22:07:55 +02001593 input_mt_init_slots(input_dev, features->touch_max, 0);
Ping Cheng84eb5aa2011-03-12 20:35:18 -08001594 input_set_abs_params(input_dev, ABS_MT_TOOL_TYPE,
1595 0, MT_TOOL_MAX, 0, 0);
1596 input_set_abs_params(input_dev, ABS_MT_POSITION_X,
1597 0, features->x_max, 0, 0);
1598 input_set_abs_params(input_dev, ABS_MT_POSITION_Y,
1599 0, features->y_max, 0, 0);
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -07001600 }
Dmitry Torokhov73a97f42010-03-19 22:18:15 -07001601 /* fall through */
1602
1603 case TABLETPC:
Ping Chengac173832012-06-12 00:15:06 -07001604 case TABLETPCE:
Ping Chenga43c7c52011-03-12 20:34:42 -08001605 __clear_bit(ABS_MISC, input_dev->absbit);
1606
Jason Gerecke35120692011-09-08 09:38:14 -07001607 __set_bit(INPUT_PROP_DIRECT, input_dev->propbit);
1608
Ping Chenge35fb8c2011-03-26 21:16:05 -07001609 if (features->device_type != BTN_TOOL_PEN)
Dmitry Torokhov73a97f42010-03-19 22:18:15 -07001610 break; /* no need to process stylus stuff */
Ping Chenge35fb8c2011-03-26 21:16:05 -07001611
Dmitry Torokhov73a97f42010-03-19 22:18:15 -07001612 /* fall through */
1613
1614 case PL:
Ping Chengc8f2edc2010-06-28 01:10:51 -07001615 case DTU:
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -07001616 __set_bit(BTN_TOOL_PEN, input_dev->keybit);
Jason Gerecke35120692011-09-08 09:38:14 -07001617 __set_bit(BTN_TOOL_RUBBER, input_dev->keybit);
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -07001618 __set_bit(BTN_STYLUS, input_dev->keybit);
1619 __set_bit(BTN_STYLUS2, input_dev->keybit);
Jason Gerecke35120692011-09-08 09:38:14 -07001620
1621 __set_bit(INPUT_PROP_DIRECT, input_dev->propbit);
1622 break;
1623
1624 case PTU:
Dmitry Torokhov73a97f42010-03-19 22:18:15 -07001625 __set_bit(BTN_STYLUS2, input_dev->keybit);
1626 /* fall through */
1627
1628 case PENPARTNER:
Jason Gerecke1fab84a2011-08-26 23:18:22 -07001629 __set_bit(BTN_TOOL_PEN, input_dev->keybit);
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -07001630 __set_bit(BTN_TOOL_RUBBER, input_dev->keybit);
Jason Gerecke1fab84a2011-08-26 23:18:22 -07001631 __set_bit(BTN_STYLUS, input_dev->keybit);
Jason Gerecke35120692011-09-08 09:38:14 -07001632
1633 __set_bit(INPUT_PROP_POINTER, input_dev->propbit);
Dmitry Torokhov73a97f42010-03-19 22:18:15 -07001634 break;
Henrik Rydbergcb734c02010-09-05 12:53:16 -07001635
1636 case BAMBOO_PT:
1637 __clear_bit(ABS_MISC, input_dev->absbit);
1638
Jason Gerecke35120692011-09-08 09:38:14 -07001639 __set_bit(INPUT_PROP_POINTER, input_dev->propbit);
1640
Ping Cheng8b4a0c12012-01-31 00:07:33 -08001641 if (features->device_type == BTN_TOOL_FINGER) {
Henrik Rydbergcb734c02010-09-05 12:53:16 -07001642 __set_bit(BTN_LEFT, input_dev->keybit);
1643 __set_bit(BTN_FORWARD, input_dev->keybit);
1644 __set_bit(BTN_BACK, input_dev->keybit);
1645 __set_bit(BTN_RIGHT, input_dev->keybit);
1646
1647 __set_bit(BTN_TOOL_FINGER, input_dev->keybit);
1648 __set_bit(BTN_TOOL_DOUBLETAP, input_dev->keybit);
Henrik Rydbergb4adbbe2012-08-11 22:07:55 +02001649 input_mt_init_slots(input_dev, features->touch_max, 0);
Henrik Rydbergcb734c02010-09-05 12:53:16 -07001650
Chris Bagwell73149ab2011-10-26 22:34:21 -07001651 if (features->pktlen == WACOM_PKGLEN_BBTOUCH3) {
1652 __set_bit(BTN_TOOL_TRIPLETAP,
1653 input_dev->keybit);
1654 __set_bit(BTN_TOOL_QUADTAP,
1655 input_dev->keybit);
1656
Chris Bagwell73149ab2011-10-26 22:34:21 -07001657 input_set_abs_params(input_dev,
1658 ABS_MT_TOUCH_MAJOR,
Jason Gerecke4e904952012-10-03 17:19:11 -07001659 0, features->x_max, 0, 0);
1660 input_set_abs_params(input_dev,
1661 ABS_MT_TOUCH_MINOR,
1662 0, features->y_max, 0, 0);
Chris Bagwell73149ab2011-10-26 22:34:21 -07001663 }
1664
Henrik Rydbergcb734c02010-09-05 12:53:16 -07001665 input_set_abs_params(input_dev, ABS_MT_POSITION_X,
1666 0, features->x_max,
1667 features->x_fuzz, 0);
1668 input_set_abs_params(input_dev, ABS_MT_POSITION_Y,
1669 0, features->y_max,
1670 features->y_fuzz, 0);
Chris Bagwell2aaacb12010-09-12 00:11:35 -07001671 } else if (features->device_type == BTN_TOOL_PEN) {
1672 __set_bit(BTN_TOOL_RUBBER, input_dev->keybit);
1673 __set_bit(BTN_TOOL_PEN, input_dev->keybit);
1674 __set_bit(BTN_STYLUS, input_dev->keybit);
1675 __set_bit(BTN_STYLUS2, input_dev->keybit);
Chris Bagwellc18c2ce2011-10-10 08:52:13 -07001676 input_set_abs_params(input_dev, ABS_DISTANCE, 0,
1677 features->distance_max,
1678 0, 0);
Henrik Rydbergcb734c02010-09-05 12:53:16 -07001679 }
1680 break;
Ping Cheng3bea7332006-07-13 18:01:36 -07001681 }
Ping Cheng19635182012-04-29 21:09:18 -07001682 return 0;
Ping Cheng3bea7332006-07-13 18:01:36 -07001683}
1684
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001685static const struct wacom_features wacom_features_0x00 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001686 { "Wacom Penpartner", WACOM_PKGLEN_PENPRTN, 5040, 3780, 255,
1687 0, PENPARTNER, WACOM_PENPRTN_RES, WACOM_PENPRTN_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001688static const struct wacom_features wacom_features_0x10 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001689 { "Wacom Graphire", WACOM_PKGLEN_GRAPHIRE, 10206, 7422, 511,
1690 63, GRAPHIRE, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001691static const struct wacom_features wacom_features_0x11 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001692 { "Wacom Graphire2 4x5", WACOM_PKGLEN_GRAPHIRE, 10206, 7422, 511,
1693 63, GRAPHIRE, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001694static const struct wacom_features wacom_features_0x12 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001695 { "Wacom Graphire2 5x7", WACOM_PKGLEN_GRAPHIRE, 13918, 10206, 511,
1696 63, GRAPHIRE, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001697static const struct wacom_features wacom_features_0x13 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001698 { "Wacom Graphire3", WACOM_PKGLEN_GRAPHIRE, 10208, 7424, 511,
1699 63, GRAPHIRE, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001700static const struct wacom_features wacom_features_0x14 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001701 { "Wacom Graphire3 6x8", WACOM_PKGLEN_GRAPHIRE, 16704, 12064, 511,
1702 63, GRAPHIRE, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001703static const struct wacom_features wacom_features_0x15 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001704 { "Wacom Graphire4 4x5", WACOM_PKGLEN_GRAPHIRE, 10208, 7424, 511,
1705 63, WACOM_G4, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001706static const struct wacom_features wacom_features_0x16 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001707 { "Wacom Graphire4 6x8", WACOM_PKGLEN_GRAPHIRE, 16704, 12064, 511,
1708 63, WACOM_G4, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001709static const struct wacom_features wacom_features_0x17 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001710 { "Wacom BambooFun 4x5", WACOM_PKGLEN_BBFUN, 14760, 9225, 511,
1711 63, WACOM_MO, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001712static const struct wacom_features wacom_features_0x18 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001713 { "Wacom BambooFun 6x8", WACOM_PKGLEN_BBFUN, 21648, 13530, 511,
1714 63, WACOM_MO, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001715static const struct wacom_features wacom_features_0x19 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001716 { "Wacom Bamboo1 Medium", WACOM_PKGLEN_GRAPHIRE, 16704, 12064, 511,
1717 63, GRAPHIRE, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001718static const struct wacom_features wacom_features_0x60 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001719 { "Wacom Volito", WACOM_PKGLEN_GRAPHIRE, 5104, 3712, 511,
1720 63, GRAPHIRE, WACOM_VOLITO_RES, WACOM_VOLITO_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001721static const struct wacom_features wacom_features_0x61 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001722 { "Wacom PenStation2", WACOM_PKGLEN_GRAPHIRE, 3250, 2320, 255,
1723 63, GRAPHIRE, WACOM_VOLITO_RES, WACOM_VOLITO_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001724static const struct wacom_features wacom_features_0x62 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001725 { "Wacom Volito2 4x5", WACOM_PKGLEN_GRAPHIRE, 5104, 3712, 511,
1726 63, GRAPHIRE, WACOM_VOLITO_RES, WACOM_VOLITO_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001727static const struct wacom_features wacom_features_0x63 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001728 { "Wacom Volito2 2x3", WACOM_PKGLEN_GRAPHIRE, 3248, 2320, 511,
1729 63, GRAPHIRE, WACOM_VOLITO_RES, WACOM_VOLITO_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001730static const struct wacom_features wacom_features_0x64 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001731 { "Wacom PenPartner2", WACOM_PKGLEN_GRAPHIRE, 3250, 2320, 511,
1732 63, GRAPHIRE, WACOM_VOLITO_RES, WACOM_VOLITO_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001733static const struct wacom_features wacom_features_0x65 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001734 { "Wacom Bamboo", WACOM_PKGLEN_BBFUN, 14760, 9225, 511,
1735 63, WACOM_MO, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001736static const struct wacom_features wacom_features_0x69 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001737 { "Wacom Bamboo1", WACOM_PKGLEN_GRAPHIRE, 5104, 3712, 511,
1738 63, GRAPHIRE, WACOM_PENPRTN_RES, WACOM_PENPRTN_RES };
Ping Cheng11d0cf82011-06-27 12:57:58 -07001739static const struct wacom_features wacom_features_0x6A =
1740 { "Wacom Bamboo1 4x6", WACOM_PKGLEN_GRAPHIRE, 14760, 9225, 1023,
1741 63, GRAPHIRE, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
1742static const struct wacom_features wacom_features_0x6B =
1743 { "Wacom Bamboo1 5x8", WACOM_PKGLEN_GRAPHIRE, 21648, 13530, 1023,
1744 63, GRAPHIRE, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001745static const struct wacom_features wacom_features_0x20 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001746 { "Wacom Intuos 4x5", WACOM_PKGLEN_INTUOS, 12700, 10600, 1023,
1747 31, INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001748static const struct wacom_features wacom_features_0x21 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001749 { "Wacom Intuos 6x8", WACOM_PKGLEN_INTUOS, 20320, 16240, 1023,
1750 31, INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001751static const struct wacom_features wacom_features_0x22 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001752 { "Wacom Intuos 9x12", WACOM_PKGLEN_INTUOS, 30480, 24060, 1023,
1753 31, INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001754static const struct wacom_features wacom_features_0x23 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001755 { "Wacom Intuos 12x12", WACOM_PKGLEN_INTUOS, 30480, 31680, 1023,
1756 31, INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001757static const struct wacom_features wacom_features_0x24 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001758 { "Wacom Intuos 12x18", WACOM_PKGLEN_INTUOS, 45720, 31680, 1023,
1759 31, INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001760static const struct wacom_features wacom_features_0x30 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001761 { "Wacom PL400", WACOM_PKGLEN_GRAPHIRE, 5408, 4056, 255,
1762 0, PL, WACOM_PL_RES, WACOM_PL_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001763static const struct wacom_features wacom_features_0x31 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001764 { "Wacom PL500", WACOM_PKGLEN_GRAPHIRE, 6144, 4608, 255,
1765 0, PL, WACOM_PL_RES, WACOM_PL_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001766static const struct wacom_features wacom_features_0x32 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001767 { "Wacom PL600", WACOM_PKGLEN_GRAPHIRE, 6126, 4604, 255,
1768 0, PL, WACOM_PL_RES, WACOM_PL_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001769static const struct wacom_features wacom_features_0x33 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001770 { "Wacom PL600SX", WACOM_PKGLEN_GRAPHIRE, 6260, 5016, 255,
1771 0, PL, WACOM_PL_RES, WACOM_PL_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001772static const struct wacom_features wacom_features_0x34 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001773 { "Wacom PL550", WACOM_PKGLEN_GRAPHIRE, 6144, 4608, 511,
1774 0, PL, WACOM_PL_RES, WACOM_PL_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001775static const struct wacom_features wacom_features_0x35 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001776 { "Wacom PL800", WACOM_PKGLEN_GRAPHIRE, 7220, 5780, 511,
1777 0, PL, WACOM_PL_RES, WACOM_PL_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001778static const struct wacom_features wacom_features_0x37 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001779 { "Wacom PL700", WACOM_PKGLEN_GRAPHIRE, 6758, 5406, 511,
1780 0, PL, WACOM_PL_RES, WACOM_PL_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001781static const struct wacom_features wacom_features_0x38 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001782 { "Wacom PL510", WACOM_PKGLEN_GRAPHIRE, 6282, 4762, 511,
1783 0, PL, WACOM_PL_RES, WACOM_PL_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001784static const struct wacom_features wacom_features_0x39 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001785 { "Wacom DTU710", WACOM_PKGLEN_GRAPHIRE, 34080, 27660, 511,
1786 0, PL, WACOM_PL_RES, WACOM_PL_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001787static const struct wacom_features wacom_features_0xC4 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001788 { "Wacom DTF521", WACOM_PKGLEN_GRAPHIRE, 6282, 4762, 511,
1789 0, PL, WACOM_PL_RES, WACOM_PL_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001790static const struct wacom_features wacom_features_0xC0 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001791 { "Wacom DTF720", WACOM_PKGLEN_GRAPHIRE, 6858, 5506, 511,
1792 0, PL, WACOM_PL_RES, WACOM_PL_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001793static const struct wacom_features wacom_features_0xC2 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001794 { "Wacom DTF720a", WACOM_PKGLEN_GRAPHIRE, 6858, 5506, 511,
1795 0, PL, WACOM_PL_RES, WACOM_PL_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001796static const struct wacom_features wacom_features_0x03 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001797 { "Wacom Cintiq Partner", WACOM_PKGLEN_GRAPHIRE, 20480, 15360, 511,
1798 0, PTU, WACOM_PL_RES, WACOM_PL_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001799static const struct wacom_features wacom_features_0x41 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001800 { "Wacom Intuos2 4x5", WACOM_PKGLEN_INTUOS, 12700, 10600, 1023,
1801 31, INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001802static const struct wacom_features wacom_features_0x42 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001803 { "Wacom Intuos2 6x8", WACOM_PKGLEN_INTUOS, 20320, 16240, 1023,
1804 31, INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001805static const struct wacom_features wacom_features_0x43 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001806 { "Wacom Intuos2 9x12", WACOM_PKGLEN_INTUOS, 30480, 24060, 1023,
1807 31, INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001808static const struct wacom_features wacom_features_0x44 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001809 { "Wacom Intuos2 12x12", WACOM_PKGLEN_INTUOS, 30480, 31680, 1023,
1810 31, INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001811static const struct wacom_features wacom_features_0x45 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001812 { "Wacom Intuos2 12x18", WACOM_PKGLEN_INTUOS, 45720, 31680, 1023,
1813 31, INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001814static const struct wacom_features wacom_features_0xB0 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001815 { "Wacom Intuos3 4x5", WACOM_PKGLEN_INTUOS, 25400, 20320, 1023,
1816 63, INTUOS3S, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001817static const struct wacom_features wacom_features_0xB1 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001818 { "Wacom Intuos3 6x8", WACOM_PKGLEN_INTUOS, 40640, 30480, 1023,
1819 63, INTUOS3, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001820static const struct wacom_features wacom_features_0xB2 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001821 { "Wacom Intuos3 9x12", WACOM_PKGLEN_INTUOS, 60960, 45720, 1023,
1822 63, INTUOS3, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001823static const struct wacom_features wacom_features_0xB3 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001824 { "Wacom Intuos3 12x12", WACOM_PKGLEN_INTUOS, 60960, 60960, 1023,
1825 63, INTUOS3L, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001826static const struct wacom_features wacom_features_0xB4 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001827 { "Wacom Intuos3 12x19", WACOM_PKGLEN_INTUOS, 97536, 60960, 1023,
1828 63, INTUOS3L, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001829static const struct wacom_features wacom_features_0xB5 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001830 { "Wacom Intuos3 6x11", WACOM_PKGLEN_INTUOS, 54204, 31750, 1023,
1831 63, INTUOS3, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001832static const struct wacom_features wacom_features_0xB7 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001833 { "Wacom Intuos3 4x6", WACOM_PKGLEN_INTUOS, 31496, 19685, 1023,
1834 63, INTUOS3S, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001835static const struct wacom_features wacom_features_0xB8 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001836 { "Wacom Intuos4 4x6", WACOM_PKGLEN_INTUOS, 31496, 19685, 2047,
1837 63, INTUOS4S, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001838static const struct wacom_features wacom_features_0xB9 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001839 { "Wacom Intuos4 6x9", WACOM_PKGLEN_INTUOS, 44704, 27940, 2047,
1840 63, INTUOS4, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001841static const struct wacom_features wacom_features_0xBA =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001842 { "Wacom Intuos4 8x13", WACOM_PKGLEN_INTUOS, 65024, 40640, 2047,
1843 63, INTUOS4L, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001844static const struct wacom_features wacom_features_0xBB =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001845 { "Wacom Intuos4 12x19", WACOM_PKGLEN_INTUOS, 97536, 60960, 2047,
1846 63, INTUOS4L, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
Ping Cheng3a4b4aa2010-06-03 22:10:21 -07001847static const struct wacom_features wacom_features_0xBC =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001848 { "Wacom Intuos4 WL", WACOM_PKGLEN_INTUOS, 40840, 25400, 2047,
1849 63, INTUOS4, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
Jason Gerecke9fee6192012-04-03 15:47:22 -07001850static const struct wacom_features wacom_features_0x26 =
1851 { "Wacom Intuos5 touch S", WACOM_PKGLEN_INTUOS, 31496, 19685, 2047,
Ping Chengf393ee22012-04-29 21:09:17 -07001852 63, INTUOS5S, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES,
1853 .touch_max = 16 };
Jason Gerecke9fee6192012-04-03 15:47:22 -07001854static const struct wacom_features wacom_features_0x27 =
1855 { "Wacom Intuos5 touch M", WACOM_PKGLEN_INTUOS, 44704, 27940, 2047,
Ping Chengf393ee22012-04-29 21:09:17 -07001856 63, INTUOS5, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES,
1857 .touch_max = 16 };
Jason Gerecke9fee6192012-04-03 15:47:22 -07001858static const struct wacom_features wacom_features_0x28 =
1859 { "Wacom Intuos5 touch L", WACOM_PKGLEN_INTUOS, 65024, 40640, 2047,
Ping Chengf393ee22012-04-29 21:09:17 -07001860 63, INTUOS5L, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES,
1861 .touch_max = 16 };
Jason Gerecke9fee6192012-04-03 15:47:22 -07001862static const struct wacom_features wacom_features_0x29 =
1863 { "Wacom Intuos5 S", WACOM_PKGLEN_INTUOS, 31496, 19685, 2047,
1864 63, INTUOS5S, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
1865static const struct wacom_features wacom_features_0x2A =
1866 { "Wacom Intuos5 M", WACOM_PKGLEN_INTUOS, 44704, 27940, 2047,
1867 63, INTUOS5, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
Jason Gerecke803296b2011-12-12 00:11:45 -08001868static const struct wacom_features wacom_features_0xF4 =
Jason Gerecke77626eb2012-08-21 22:11:59 -07001869 { "Wacom Cintiq 24HD", WACOM_PKGLEN_INTUOS, 104480, 65600, 2047,
1870 63, WACOM_24HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
1871static const struct wacom_features wacom_features_0xF8 =
1872 { "Wacom Cintiq 24HD touch", WACOM_PKGLEN_INTUOS, 104480, 65600, 2047,
Jason Gerecke803296b2011-12-12 00:11:45 -08001873 63, WACOM_24HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001874static const struct wacom_features wacom_features_0x3F =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001875 { "Wacom Cintiq 21UX", WACOM_PKGLEN_INTUOS, 87200, 65600, 1023,
1876 63, CINTIQ, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001877static const struct wacom_features wacom_features_0xC5 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001878 { "Wacom Cintiq 20WSX", WACOM_PKGLEN_INTUOS, 86680, 54180, 1023,
1879 63, WACOM_BEE, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001880static const struct wacom_features wacom_features_0xC6 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001881 { "Wacom Cintiq 12WX", WACOM_PKGLEN_INTUOS, 53020, 33440, 1023,
1882 63, WACOM_BEE, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001883static const struct wacom_features wacom_features_0xC7 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001884 { "Wacom DTU1931", WACOM_PKGLEN_GRAPHIRE, 37832, 30305, 511,
1885 0, PL, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Ping Chengc8f2edc2010-06-28 01:10:51 -07001886static const struct wacom_features wacom_features_0xCE =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001887 { "Wacom DTU2231", WACOM_PKGLEN_GRAPHIRE, 47864, 27011, 511,
1888 0, DTU, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Ping Chengc8f2edc2010-06-28 01:10:51 -07001889static const struct wacom_features wacom_features_0xF0 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001890 { "Wacom DTU1631", WACOM_PKGLEN_GRAPHIRE, 34623, 19553, 511,
1891 0, DTU, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Ping Cheng3a4b4aa2010-06-03 22:10:21 -07001892static const struct wacom_features wacom_features_0xCC =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001893 { "Wacom Cintiq 21UX2", WACOM_PKGLEN_INTUOS, 87200, 65600, 2047,
1894 63, WACOM_21UX2, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
Ping Chengd838c642012-07-24 23:54:11 -07001895static const struct wacom_features wacom_features_0xFA =
1896 { "Wacom Cintiq 22HD", WACOM_PKGLEN_INTUOS, 95840, 54260, 2047,
1897 63, WACOM_22HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001898static const struct wacom_features wacom_features_0x90 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001899 { "Wacom ISDv4 90", WACOM_PKGLEN_GRAPHIRE, 26202, 16325, 255,
1900 0, TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001901static const struct wacom_features wacom_features_0x93 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001902 { "Wacom ISDv4 93", WACOM_PKGLEN_GRAPHIRE, 26202, 16325, 255,
1903 0, TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Ping Cheng11d0cf82011-06-27 12:57:58 -07001904static const struct wacom_features wacom_features_0x97 =
1905 { "Wacom ISDv4 97", WACOM_PKGLEN_GRAPHIRE, 26202, 16325, 511,
1906 0, TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001907static const struct wacom_features wacom_features_0x9A =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001908 { "Wacom ISDv4 9A", WACOM_PKGLEN_GRAPHIRE, 26202, 16325, 255,
1909 0, TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001910static const struct wacom_features wacom_features_0x9F =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001911 { "Wacom ISDv4 9F", WACOM_PKGLEN_GRAPHIRE, 26202, 16325, 255,
1912 0, TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001913static const struct wacom_features wacom_features_0xE2 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001914 { "Wacom ISDv4 E2", WACOM_PKGLEN_TPC2FG, 26202, 16325, 255,
Ping Chengf393ee22012-04-29 21:09:17 -07001915 0, TABLETPC2FG, WACOM_INTUOS_RES, WACOM_INTUOS_RES,
1916 .touch_max = 2 };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001917static const struct wacom_features wacom_features_0xE3 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001918 { "Wacom ISDv4 E3", WACOM_PKGLEN_TPC2FG, 26202, 16325, 255,
Ping Chengf393ee22012-04-29 21:09:17 -07001919 0, TABLETPC2FG, WACOM_INTUOS_RES, WACOM_INTUOS_RES,
1920 .touch_max = 2 };
Ping Cheng19635182012-04-29 21:09:18 -07001921static const struct wacom_features wacom_features_0xE5 =
1922 { "Wacom ISDv4 E5", WACOM_PKGLEN_MTOUCH, 26202, 16325, 255,
1923 0, MTSCREEN, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Manoj Iyer26fcd2a2011-03-31 22:39:43 -07001924static const struct wacom_features wacom_features_0xE6 =
1925 { "Wacom ISDv4 E6", WACOM_PKGLEN_TPC2FG, 27760, 15694, 255,
Ping Chengf393ee22012-04-29 21:09:17 -07001926 0, TABLETPC2FG, WACOM_INTUOS_RES, WACOM_INTUOS_RES,
1927 .touch_max = 2 };
Chris Bagwell0d0e3062011-12-11 23:50:59 -08001928static const struct wacom_features wacom_features_0xEC =
1929 { "Wacom ISDv4 EC", WACOM_PKGLEN_GRAPHIRE, 25710, 14500, 255,
1930 0, TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Ping Chengac173832012-06-12 00:15:06 -07001931static const struct wacom_features wacom_features_0xED =
1932 { "Wacom ISDv4 ED", WACOM_PKGLEN_GRAPHIRE, 26202, 16325, 255,
1933 0, TABLETPCE, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
1934static const struct wacom_features wacom_features_0xEF =
1935 { "Wacom ISDv4 EF", WACOM_PKGLEN_GRAPHIRE, 26202, 16325, 255,
1936 0, TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Dmitry Torokhove87a3442010-02-18 01:51:47 -08001937static const struct wacom_features wacom_features_0x47 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001938 { "Wacom Intuos2 6x8", WACOM_PKGLEN_INTUOS, 20320, 16240, 1023,
1939 31, INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Chris Bagwelld3825d52012-03-25 23:26:11 -07001940static const struct wacom_features wacom_features_0x84 =
1941 { "Wacom Wireless Receiver", WACOM_PKGLEN_WIRELESS, 0, 0, 0,
Ping Chengf393ee22012-04-29 21:09:17 -07001942 0, WIRELESS, 0, 0, .touch_max = 16 };
Ping Cheng7b824bb2011-03-26 21:16:04 -07001943static const struct wacom_features wacom_features_0xD0 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001944 { "Wacom Bamboo 2FG", WACOM_PKGLEN_BBFUN, 14720, 9200, 1023,
Ping Chengf393ee22012-04-29 21:09:17 -07001945 31, BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES,
1946 .touch_max = 2 };
Ping Cheng7b824bb2011-03-26 21:16:04 -07001947static const struct wacom_features wacom_features_0xD1 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001948 { "Wacom Bamboo 2FG 4x5", WACOM_PKGLEN_BBFUN, 14720, 9200, 1023,
Ping Chengf393ee22012-04-29 21:09:17 -07001949 31, BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES,
1950 .touch_max = 2 };
Ping Cheng7b824bb2011-03-26 21:16:04 -07001951static const struct wacom_features wacom_features_0xD2 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001952 { "Wacom Bamboo Craft", WACOM_PKGLEN_BBFUN, 14720, 9200, 1023,
Chris Bagwellc18c2ce2011-10-10 08:52:13 -07001953 31, BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Ping Cheng7b824bb2011-03-26 21:16:04 -07001954static const struct wacom_features wacom_features_0xD3 =
Chris Bagwellae927562011-10-10 08:52:32 -07001955 { "Wacom Bamboo 2FG 6x8", WACOM_PKGLEN_BBFUN, 21648, 13700, 1023,
Ping Chengf393ee22012-04-29 21:09:17 -07001956 31, BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES,
1957 .touch_max = 2 };
Kevin Granade57a78722010-12-10 23:04:02 -08001958static const struct wacom_features wacom_features_0xD4 =
Ping Chenga001a8f2011-06-27 12:57:58 -07001959 { "Wacom Bamboo Pen", WACOM_PKGLEN_BBFUN, 14720, 9200, 1023,
Chris Bagwellc18c2ce2011-10-10 08:52:13 -07001960 31, BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Gerard Braad18adad12011-08-16 00:17:56 -07001961static const struct wacom_features wacom_features_0xD5 =
Chris Bagwellae927562011-10-10 08:52:32 -07001962 { "Wacom Bamboo Pen 6x8", WACOM_PKGLEN_BBFUN, 21648, 13700, 1023,
Chris Bagwellc18c2ce2011-10-10 08:52:13 -07001963 31, BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Ping Cheng7b824bb2011-03-26 21:16:04 -07001964static const struct wacom_features wacom_features_0xD6 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001965 { "Wacom BambooPT 2FG 4x5", WACOM_PKGLEN_BBFUN, 14720, 9200, 1023,
Ping Chengf393ee22012-04-29 21:09:17 -07001966 31, BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES,
1967 .touch_max = 2 };
Ping Cheng7b824bb2011-03-26 21:16:04 -07001968static const struct wacom_features wacom_features_0xD7 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001969 { "Wacom BambooPT 2FG Small", WACOM_PKGLEN_BBFUN, 14720, 9200, 1023,
Ping Chengf393ee22012-04-29 21:09:17 -07001970 31, BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES,
1971 .touch_max = 2 };
Ping Cheng7b824bb2011-03-26 21:16:04 -07001972static const struct wacom_features wacom_features_0xD8 =
Chris Bagwellae927562011-10-10 08:52:32 -07001973 { "Wacom Bamboo Comic 2FG", WACOM_PKGLEN_BBFUN, 21648, 13700, 1023,
Ping Chengf393ee22012-04-29 21:09:17 -07001974 31, BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES,
1975 .touch_max = 2 };
Ping Cheng7b824bb2011-03-26 21:16:04 -07001976static const struct wacom_features wacom_features_0xDA =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001977 { "Wacom Bamboo 2FG 4x5 SE", WACOM_PKGLEN_BBFUN, 14720, 9200, 1023,
Ping Chengf393ee22012-04-29 21:09:17 -07001978 31, BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES,
1979 .touch_max = 2 };
David Foley47d09232010-12-07 21:05:59 -08001980static struct wacom_features wacom_features_0xDB =
Chris Bagwellae927562011-10-10 08:52:32 -07001981 { "Wacom Bamboo 2FG 6x8 SE", WACOM_PKGLEN_BBFUN, 21648, 13700, 1023,
Ping Chengf393ee22012-04-29 21:09:17 -07001982 31, BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES,
1983 .touch_max = 2 };
Chris Bagwell73149ab2011-10-26 22:34:21 -07001984static const struct wacom_features wacom_features_0xDD =
1985 { "Wacom Bamboo Connect", WACOM_PKGLEN_BBPEN, 14720, 9200, 1023,
1986 31, BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
1987static const struct wacom_features wacom_features_0xDE =
1988 { "Wacom Bamboo 16FG 4x5", WACOM_PKGLEN_BBPEN, 14720, 9200, 1023,
Ping Chengf393ee22012-04-29 21:09:17 -07001989 31, BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES,
1990 .touch_max = 16 };
Chris Bagwell73149ab2011-10-26 22:34:21 -07001991static const struct wacom_features wacom_features_0xDF =
1992 { "Wacom Bamboo 16FG 6x8", WACOM_PKGLEN_BBPEN, 21648, 13700, 1023,
Ping Chengf393ee22012-04-29 21:09:17 -07001993 31, BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES,
1994 .touch_max = 16 };
Ajay Ramaswamy7b4b3062010-12-23 01:19:39 -08001995static const struct wacom_features wacom_features_0x6004 =
Ping Chenge35fb8c2011-03-26 21:16:05 -07001996 { "ISD-V4", WACOM_PKGLEN_GRAPHIRE, 12800, 8000, 255,
1997 0, TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
Bastian Blankb036f6f2010-02-10 23:06:23 -08001998
1999#define USB_DEVICE_WACOM(prod) \
2000 USB_DEVICE(USB_VENDOR_ID_WACOM, prod), \
2001 .driver_info = (kernel_ulong_t)&wacom_features_##prod
2002
Aristeu Rozanski1483f552011-06-22 01:17:17 -07002003#define USB_DEVICE_DETAILED(prod, class, sub, proto) \
2004 USB_DEVICE_AND_INTERFACE_INFO(USB_VENDOR_ID_WACOM, prod, class, \
2005 sub, proto), \
2006 .driver_info = (kernel_ulong_t)&wacom_features_##prod
2007
Ajay Ramaswamy7b4b3062010-12-23 01:19:39 -08002008#define USB_DEVICE_LENOVO(prod) \
2009 USB_DEVICE(USB_VENDOR_ID_LENOVO, prod), \
2010 .driver_info = (kernel_ulong_t)&wacom_features_##prod
2011
Bastian Blankb036f6f2010-02-10 23:06:23 -08002012const struct usb_device_id wacom_ids[] = {
2013 { USB_DEVICE_WACOM(0x00) },
2014 { USB_DEVICE_WACOM(0x10) },
2015 { USB_DEVICE_WACOM(0x11) },
2016 { USB_DEVICE_WACOM(0x12) },
2017 { USB_DEVICE_WACOM(0x13) },
2018 { USB_DEVICE_WACOM(0x14) },
2019 { USB_DEVICE_WACOM(0x15) },
2020 { USB_DEVICE_WACOM(0x16) },
2021 { USB_DEVICE_WACOM(0x17) },
2022 { USB_DEVICE_WACOM(0x18) },
2023 { USB_DEVICE_WACOM(0x19) },
2024 { USB_DEVICE_WACOM(0x60) },
2025 { USB_DEVICE_WACOM(0x61) },
2026 { USB_DEVICE_WACOM(0x62) },
2027 { USB_DEVICE_WACOM(0x63) },
2028 { USB_DEVICE_WACOM(0x64) },
2029 { USB_DEVICE_WACOM(0x65) },
2030 { USB_DEVICE_WACOM(0x69) },
Ping Cheng11d0cf82011-06-27 12:57:58 -07002031 { USB_DEVICE_WACOM(0x6A) },
2032 { USB_DEVICE_WACOM(0x6B) },
Bastian Blankb036f6f2010-02-10 23:06:23 -08002033 { USB_DEVICE_WACOM(0x20) },
2034 { USB_DEVICE_WACOM(0x21) },
2035 { USB_DEVICE_WACOM(0x22) },
2036 { USB_DEVICE_WACOM(0x23) },
2037 { USB_DEVICE_WACOM(0x24) },
2038 { USB_DEVICE_WACOM(0x30) },
2039 { USB_DEVICE_WACOM(0x31) },
2040 { USB_DEVICE_WACOM(0x32) },
2041 { USB_DEVICE_WACOM(0x33) },
2042 { USB_DEVICE_WACOM(0x34) },
2043 { USB_DEVICE_WACOM(0x35) },
2044 { USB_DEVICE_WACOM(0x37) },
2045 { USB_DEVICE_WACOM(0x38) },
2046 { USB_DEVICE_WACOM(0x39) },
2047 { USB_DEVICE_WACOM(0xC4) },
2048 { USB_DEVICE_WACOM(0xC0) },
2049 { USB_DEVICE_WACOM(0xC2) },
2050 { USB_DEVICE_WACOM(0x03) },
2051 { USB_DEVICE_WACOM(0x41) },
2052 { USB_DEVICE_WACOM(0x42) },
2053 { USB_DEVICE_WACOM(0x43) },
2054 { USB_DEVICE_WACOM(0x44) },
2055 { USB_DEVICE_WACOM(0x45) },
2056 { USB_DEVICE_WACOM(0xB0) },
2057 { USB_DEVICE_WACOM(0xB1) },
2058 { USB_DEVICE_WACOM(0xB2) },
2059 { USB_DEVICE_WACOM(0xB3) },
2060 { USB_DEVICE_WACOM(0xB4) },
2061 { USB_DEVICE_WACOM(0xB5) },
2062 { USB_DEVICE_WACOM(0xB7) },
2063 { USB_DEVICE_WACOM(0xB8) },
2064 { USB_DEVICE_WACOM(0xB9) },
2065 { USB_DEVICE_WACOM(0xBA) },
2066 { USB_DEVICE_WACOM(0xBB) },
Ping Cheng3a4b4aa2010-06-03 22:10:21 -07002067 { USB_DEVICE_WACOM(0xBC) },
Jason Gerecke9fee6192012-04-03 15:47:22 -07002068 { USB_DEVICE_WACOM(0x26) },
2069 { USB_DEVICE_WACOM(0x27) },
2070 { USB_DEVICE_WACOM(0x28) },
2071 { USB_DEVICE_WACOM(0x29) },
2072 { USB_DEVICE_WACOM(0x2A) },
Bastian Blankb036f6f2010-02-10 23:06:23 -08002073 { USB_DEVICE_WACOM(0x3F) },
2074 { USB_DEVICE_WACOM(0xC5) },
2075 { USB_DEVICE_WACOM(0xC6) },
2076 { USB_DEVICE_WACOM(0xC7) },
Aristeu Rozanski1483f552011-06-22 01:17:17 -07002077 /*
2078 * DTU-2231 has two interfaces on the same configuration,
2079 * only one is used.
2080 */
2081 { USB_DEVICE_DETAILED(0xCE, USB_CLASS_HID,
2082 USB_INTERFACE_SUBCLASS_BOOT,
2083 USB_INTERFACE_PROTOCOL_MOUSE) },
Chris Bagwelld3825d52012-03-25 23:26:11 -07002084 { USB_DEVICE_WACOM(0x84) },
Henrik Rydbergcb734c02010-09-05 12:53:16 -07002085 { USB_DEVICE_WACOM(0xD0) },
Chris Bagwell2aaacb12010-09-12 00:11:35 -07002086 { USB_DEVICE_WACOM(0xD1) },
2087 { USB_DEVICE_WACOM(0xD2) },
2088 { USB_DEVICE_WACOM(0xD3) },
Kevin Granade57a78722010-12-10 23:04:02 -08002089 { USB_DEVICE_WACOM(0xD4) },
Gerard Braad18adad12011-08-16 00:17:56 -07002090 { USB_DEVICE_WACOM(0xD5) },
Ping Chengd38acb42011-01-24 09:32:50 -08002091 { USB_DEVICE_WACOM(0xD6) },
2092 { USB_DEVICE_WACOM(0xD7) },
David Foleya318e6b2010-11-30 23:45:46 -08002093 { USB_DEVICE_WACOM(0xD8) },
2094 { USB_DEVICE_WACOM(0xDA) },
David Foley47d09232010-12-07 21:05:59 -08002095 { USB_DEVICE_WACOM(0xDB) },
Chris Bagwell73149ab2011-10-26 22:34:21 -07002096 { USB_DEVICE_WACOM(0xDD) },
2097 { USB_DEVICE_WACOM(0xDE) },
2098 { USB_DEVICE_WACOM(0xDF) },
Ping Chengc8f2edc2010-06-28 01:10:51 -07002099 { USB_DEVICE_WACOM(0xF0) },
Ping Cheng3a4b4aa2010-06-03 22:10:21 -07002100 { USB_DEVICE_WACOM(0xCC) },
Bastian Blankb036f6f2010-02-10 23:06:23 -08002101 { USB_DEVICE_WACOM(0x90) },
2102 { USB_DEVICE_WACOM(0x93) },
Ping Cheng11d0cf82011-06-27 12:57:58 -07002103 { USB_DEVICE_WACOM(0x97) },
Bastian Blankb036f6f2010-02-10 23:06:23 -08002104 { USB_DEVICE_WACOM(0x9A) },
2105 { USB_DEVICE_WACOM(0x9F) },
2106 { USB_DEVICE_WACOM(0xE2) },
2107 { USB_DEVICE_WACOM(0xE3) },
Ping Cheng19635182012-04-29 21:09:18 -07002108 { USB_DEVICE_WACOM(0xE5) },
Manoj Iyer26fcd2a2011-03-31 22:39:43 -07002109 { USB_DEVICE_WACOM(0xE6) },
Chris Bagwell0d0e3062011-12-11 23:50:59 -08002110 { USB_DEVICE_WACOM(0xEC) },
Ping Chengac173832012-06-12 00:15:06 -07002111 { USB_DEVICE_WACOM(0xED) },
2112 { USB_DEVICE_WACOM(0xEF) },
Bastian Blankb036f6f2010-02-10 23:06:23 -08002113 { USB_DEVICE_WACOM(0x47) },
Jason Gerecke803296b2011-12-12 00:11:45 -08002114 { USB_DEVICE_WACOM(0xF4) },
Jason Gerecke77626eb2012-08-21 22:11:59 -07002115 { USB_DEVICE_WACOM(0xF8) },
Ping Chengd838c642012-07-24 23:54:11 -07002116 { USB_DEVICE_WACOM(0xFA) },
Ajay Ramaswamy7b4b3062010-12-23 01:19:39 -08002117 { USB_DEVICE_LENOVO(0x6004) },
Ping Cheng3bea7332006-07-13 18:01:36 -07002118 { }
2119};
Ping Cheng3bea7332006-07-13 18:01:36 -07002120MODULE_DEVICE_TABLE(usb, wacom_ids);