aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorPing Cheng <pingc@wacom.com>2008-11-24 11:44:27 -0500
committerDmitry Torokhov <dmitry.torokhov@gmail.com>2008-11-26 10:14:18 -0500
commit545f4e99dee7284ed57c79384c5c1d5ac58dcd59 (patch)
tree96505bbc39ca58b2e7b9617d49ccba866938455d /drivers
parent8442c87d2f6c73cdc9a391e4dd9390523d242bda (diff)
Input: wacom - add support for new USB Tablet PCs
Signed-off-by: Ping Cheng <pingc@wacom.com> Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/input/tablet/wacom.h13
-rw-r--r--drivers/input/tablet/wacom_sys.c228
-rw-r--r--drivers/input/tablet/wacom_wac.c160
-rw-r--r--drivers/input/tablet/wacom_wac.h4
4 files changed, 356 insertions, 49 deletions
diff --git a/drivers/input/tablet/wacom.h b/drivers/input/tablet/wacom.h
index ca62ec639f8f..677680e9f54f 100644
--- a/drivers/input/tablet/wacom.h
+++ b/drivers/input/tablet/wacom.h
@@ -66,6 +66,7 @@
66 * - Support Intuos3 4x6 66 * - Support Intuos3 4x6
67 * v1.47 (pc) - Added support for Bamboo 67 * v1.47 (pc) - Added support for Bamboo
68 * v1.48 (pc) - Added support for Bamboo1, BambooFun, and Cintiq 12WX 68 * v1.48 (pc) - Added support for Bamboo1, BambooFun, and Cintiq 12WX
69 * v1.49 (pc) - Added support for USB Tablet PC (0x90, 0x93, and 0x9A)
69 */ 70 */
70 71
71/* 72/*
@@ -86,7 +87,7 @@
86/* 87/*
87 * Version Information 88 * Version Information
88 */ 89 */
89#define DRIVER_VERSION "v1.48" 90#define DRIVER_VERSION "v1.49"
90#define DRIVER_AUTHOR "Vojtech Pavlik <vojtech@ucw.cz>" 91#define DRIVER_AUTHOR "Vojtech Pavlik <vojtech@ucw.cz>"
91#define DRIVER_DESC "USB Wacom Graphire and Wacom Intuos tablet driver" 92#define DRIVER_DESC "USB Wacom Graphire and Wacom Intuos tablet driver"
92#define DRIVER_LICENSE "GPL" 93#define DRIVER_LICENSE "GPL"
@@ -103,15 +104,15 @@ struct wacom {
103 struct usb_device *usbdev; 104 struct usb_device *usbdev;
104 struct usb_interface *intf; 105 struct usb_interface *intf;
105 struct urb *irq; 106 struct urb *irq;
106 struct wacom_wac * wacom_wac; 107 struct wacom_wac *wacom_wac;
107 struct mutex lock; 108 struct mutex lock;
108 unsigned int open:1; 109 unsigned int open:1;
109 char phys[32]; 110 char phys[32];
110}; 111};
111 112
112struct wacom_combo { 113struct wacom_combo {
113 struct wacom * wacom; 114 struct wacom *wacom;
114 struct urb * urb; 115 struct urb *urb;
115}; 116};
116 117
117extern int wacom_wac_irq(struct wacom_wac * wacom_wac, void * wcombo); 118extern int wacom_wac_irq(struct wacom_wac * wacom_wac, void * wcombo);
@@ -132,7 +133,7 @@ extern void input_dev_mo(struct input_dev *input_dev, struct wacom_wac *wacom_wa
132extern void input_dev_bee(struct input_dev *input_dev, struct wacom_wac *wacom_wac); 133extern void input_dev_bee(struct input_dev *input_dev, struct wacom_wac *wacom_wac);
133extern __u16 wacom_le16_to_cpu(unsigned char *data); 134extern __u16 wacom_le16_to_cpu(unsigned char *data);
134extern __u16 wacom_be16_to_cpu(unsigned char *data); 135extern __u16 wacom_be16_to_cpu(unsigned char *data);
135extern struct wacom_features * get_wacom_feature(const struct usb_device_id *id); 136extern struct wacom_features *get_wacom_feature(const struct usb_device_id *id);
136extern const struct usb_device_id * get_device_table(void); 137extern const struct usb_device_id *get_device_table(void);
137 138
138#endif 139#endif
diff --git a/drivers/input/tablet/wacom_sys.c b/drivers/input/tablet/wacom_sys.c
index 5fbc463baf5a..7fe73586e024 100644
--- a/drivers/input/tablet/wacom_sys.c
+++ b/drivers/input/tablet/wacom_sys.c
@@ -14,8 +14,41 @@
14#include "wacom.h" 14#include "wacom.h"
15#include "wacom_wac.h" 15#include "wacom_wac.h"
16 16
17/* defines to get HID report descriptor */
18#define HID_DEVICET_HID (USB_TYPE_CLASS | 0x01)
19#define HID_DEVICET_REPORT (USB_TYPE_CLASS | 0x02)
20#define HID_USAGE_UNDEFINED 0x00
21#define HID_USAGE_PAGE 0x05
22#define HID_USAGE_PAGE_DIGITIZER 0x0d
23#define HID_USAGE_PAGE_DESKTOP 0x01
24#define HID_USAGE 0x09
25#define HID_USAGE_X 0x30
26#define HID_USAGE_Y 0x31
27#define HID_USAGE_X_TILT 0x3d
28#define HID_USAGE_Y_TILT 0x3e
29#define HID_USAGE_FINGER 0x22
30#define HID_USAGE_STYLUS 0x20
31#define HID_COLLECTION 0xc0
32
33enum {
34 WCM_UNDEFINED = 0,
35 WCM_DESKTOP,
36 WCM_DIGITIZER,
37};
38
39struct hid_descriptor {
40 struct usb_descriptor_header header;
41 __le16 bcdHID;
42 u8 bCountryCode;
43 u8 bNumDescriptors;
44 u8 bDescriptorType;
45 __le16 wDescriptorLength;
46} __attribute__ ((packed));
47
48/* defines to get/set USB message */
17#define USB_REQ_GET_REPORT 0x01 49#define USB_REQ_GET_REPORT 0x01
18#define USB_REQ_SET_REPORT 0x09 50#define USB_REQ_SET_REPORT 0x09
51#define WAC_HID_FEATURE_REPORT 0x03
19 52
20static int usb_get_report(struct usb_interface *intf, unsigned char type, 53static int usb_get_report(struct usb_interface *intf, unsigned char type,
21 unsigned char id, void *buf, int size) 54 unsigned char id, void *buf, int size)
@@ -80,25 +113,21 @@ static void wacom_sys_irq(struct urb *urb)
80void wacom_report_key(void *wcombo, unsigned int key_type, int key_data) 113void wacom_report_key(void *wcombo, unsigned int key_type, int key_data)
81{ 114{
82 input_report_key(get_input_dev((struct wacom_combo *)wcombo), key_type, key_data); 115 input_report_key(get_input_dev((struct wacom_combo *)wcombo), key_type, key_data);
83 return;
84} 116}
85 117
86void wacom_report_abs(void *wcombo, unsigned int abs_type, int abs_data) 118void wacom_report_abs(void *wcombo, unsigned int abs_type, int abs_data)
87{ 119{
88 input_report_abs(get_input_dev((struct wacom_combo *)wcombo), abs_type, abs_data); 120 input_report_abs(get_input_dev((struct wacom_combo *)wcombo), abs_type, abs_data);
89 return;
90} 121}
91 122
92void wacom_report_rel(void *wcombo, unsigned int rel_type, int rel_data) 123void wacom_report_rel(void *wcombo, unsigned int rel_type, int rel_data)
93{ 124{
94 input_report_rel(get_input_dev((struct wacom_combo *)wcombo), rel_type, rel_data); 125 input_report_rel(get_input_dev((struct wacom_combo *)wcombo), rel_type, rel_data);
95 return;
96} 126}
97 127
98void wacom_input_event(void *wcombo, unsigned int type, unsigned int code, int value) 128void wacom_input_event(void *wcombo, unsigned int type, unsigned int code, int value)
99{ 129{
100 input_event(get_input_dev((struct wacom_combo *)wcombo), type, code, value); 130 input_event(get_input_dev((struct wacom_combo *)wcombo), type, code, value);
101 return;
102} 131}
103 132
104__u16 wacom_be16_to_cpu(unsigned char *data) 133__u16 wacom_be16_to_cpu(unsigned char *data)
@@ -118,7 +147,6 @@ __u16 wacom_le16_to_cpu(unsigned char *data)
118void wacom_input_sync(void *wcombo) 147void wacom_input_sync(void *wcombo)
119{ 148{
120 input_sync(get_input_dev((struct wacom_combo *)wcombo)); 149 input_sync(get_input_dev((struct wacom_combo *)wcombo));
121 return;
122} 150}
123 151
124static int wacom_open(struct input_dev *dev) 152static int wacom_open(struct input_dev *dev)
@@ -160,7 +188,7 @@ static void wacom_close(struct input_dev *dev)
160 188
161void input_dev_mo(struct input_dev *input_dev, struct wacom_wac *wacom_wac) 189void input_dev_mo(struct input_dev *input_dev, struct wacom_wac *wacom_wac)
162{ 190{
163 input_dev->keybit[BIT_WORD(BTN_LEFT)] |= BIT_MASK(BTN_1) | 191 input_dev->keybit[BIT_WORD(BTN_MISC)] |= BIT_MASK(BTN_1) |
164 BIT_MASK(BTN_5); 192 BIT_MASK(BTN_5);
165 input_set_abs_params(input_dev, ABS_WHEEL, 0, 71, 0, 0); 193 input_set_abs_params(input_dev, ABS_WHEEL, 0, 71, 0, 0);
166} 194}
@@ -170,7 +198,7 @@ void input_dev_g4(struct input_dev *input_dev, struct wacom_wac *wacom_wac)
170 input_dev->evbit[0] |= BIT_MASK(EV_MSC); 198 input_dev->evbit[0] |= BIT_MASK(EV_MSC);
171 input_dev->mscbit[0] |= BIT_MASK(MSC_SERIAL); 199 input_dev->mscbit[0] |= BIT_MASK(MSC_SERIAL);
172 input_dev->keybit[BIT_WORD(BTN_DIGI)] |= BIT_MASK(BTN_TOOL_FINGER); 200 input_dev->keybit[BIT_WORD(BTN_DIGI)] |= BIT_MASK(BTN_TOOL_FINGER);
173 input_dev->keybit[BIT_WORD(BTN_LEFT)] |= BIT_MASK(BTN_0) | 201 input_dev->keybit[BIT_WORD(BTN_MISC)] |= BIT_MASK(BTN_0) |
174 BIT_MASK(BTN_4); 202 BIT_MASK(BTN_4);
175} 203}
176 204
@@ -178,7 +206,7 @@ void input_dev_g(struct input_dev *input_dev, struct wacom_wac *wacom_wac)
178{ 206{
179 input_dev->evbit[0] |= BIT_MASK(EV_REL); 207 input_dev->evbit[0] |= BIT_MASK(EV_REL);
180 input_dev->relbit[0] |= BIT_MASK(REL_WHEEL); 208 input_dev->relbit[0] |= BIT_MASK(REL_WHEEL);
181 input_dev->keybit[BIT_WORD(BTN_LEFT)] |= BIT_MASK(BTN_LEFT) | 209 input_dev->keybit[BIT_WORD(BTN_MOUSE)] |= BIT_MASK(BTN_LEFT) |
182 BIT_MASK(BTN_RIGHT) | BIT_MASK(BTN_MIDDLE); 210 BIT_MASK(BTN_RIGHT) | BIT_MASK(BTN_MIDDLE);
183 input_dev->keybit[BIT_WORD(BTN_DIGI)] |= BIT_MASK(BTN_TOOL_RUBBER) | 211 input_dev->keybit[BIT_WORD(BTN_DIGI)] |= BIT_MASK(BTN_TOOL_RUBBER) |
184 BIT_MASK(BTN_TOOL_MOUSE) | BIT_MASK(BTN_STYLUS2); 212 BIT_MASK(BTN_TOOL_MOUSE) | BIT_MASK(BTN_STYLUS2);
@@ -188,7 +216,7 @@ void input_dev_g(struct input_dev *input_dev, struct wacom_wac *wacom_wac)
188void input_dev_i3s(struct input_dev *input_dev, struct wacom_wac *wacom_wac) 216void input_dev_i3s(struct input_dev *input_dev, struct wacom_wac *wacom_wac)
189{ 217{
190 input_dev->keybit[BIT_WORD(BTN_DIGI)] |= BIT_MASK(BTN_TOOL_FINGER); 218 input_dev->keybit[BIT_WORD(BTN_DIGI)] |= BIT_MASK(BTN_TOOL_FINGER);
191 input_dev->keybit[BIT_WORD(BTN_LEFT)] |= BIT_MASK(BTN_0) | 219 input_dev->keybit[BIT_WORD(BTN_MISC)] |= BIT_MASK(BTN_0) |
192 BIT_MASK(BTN_1) | BIT_MASK(BTN_2) | BIT_MASK(BTN_3); 220 BIT_MASK(BTN_1) | BIT_MASK(BTN_2) | BIT_MASK(BTN_3);
193 input_set_abs_params(input_dev, ABS_RX, 0, 4096, 0, 0); 221 input_set_abs_params(input_dev, ABS_RX, 0, 4096, 0, 0);
194 input_set_abs_params(input_dev, ABS_Z, -900, 899, 0, 0); 222 input_set_abs_params(input_dev, ABS_Z, -900, 899, 0, 0);
@@ -196,14 +224,14 @@ void input_dev_i3s(struct input_dev *input_dev, struct wacom_wac *wacom_wac)
196 224
197void input_dev_i3(struct input_dev *input_dev, struct wacom_wac *wacom_wac) 225void input_dev_i3(struct input_dev *input_dev, struct wacom_wac *wacom_wac)
198{ 226{
199 input_dev->keybit[BIT_WORD(BTN_LEFT)] |= BIT_MASK(BTN_4) | 227 input_dev->keybit[BIT_WORD(BTN_MISC)] |= BIT_MASK(BTN_4) |
200 BIT_MASK(BTN_5) | BIT_MASK(BTN_6) | BIT_MASK(BTN_7); 228 BIT_MASK(BTN_5) | BIT_MASK(BTN_6) | BIT_MASK(BTN_7);
201 input_set_abs_params(input_dev, ABS_RY, 0, 4096, 0, 0); 229 input_set_abs_params(input_dev, ABS_RY, 0, 4096, 0, 0);
202} 230}
203 231
204void input_dev_bee(struct input_dev *input_dev, struct wacom_wac *wacom_wac) 232void input_dev_bee(struct input_dev *input_dev, struct wacom_wac *wacom_wac)
205{ 233{
206 input_dev->keybit[BIT_WORD(BTN_LEFT)] |= BIT_MASK(BTN_8) | BIT_MASK(BTN_9); 234 input_dev->keybit[BIT_WORD(BTN_MISC)] |= BIT_MASK(BTN_8) | BIT_MASK(BTN_9);
207} 235}
208 236
209void input_dev_i(struct input_dev *input_dev, struct wacom_wac *wacom_wac) 237void input_dev_i(struct input_dev *input_dev, struct wacom_wac *wacom_wac)
@@ -211,7 +239,7 @@ void input_dev_i(struct input_dev *input_dev, struct wacom_wac *wacom_wac)
211 input_dev->evbit[0] |= BIT_MASK(EV_MSC) | BIT_MASK(EV_REL); 239 input_dev->evbit[0] |= BIT_MASK(EV_MSC) | BIT_MASK(EV_REL);
212 input_dev->mscbit[0] |= BIT_MASK(MSC_SERIAL); 240 input_dev->mscbit[0] |= BIT_MASK(MSC_SERIAL);
213 input_dev->relbit[0] |= BIT_MASK(REL_WHEEL); 241 input_dev->relbit[0] |= BIT_MASK(REL_WHEEL);
214 input_dev->keybit[BIT_WORD(BTN_LEFT)] |= BIT_MASK(BTN_LEFT) | 242 input_dev->keybit[BIT_WORD(BTN_MOUSE)] |= BIT_MASK(BTN_LEFT) |
215 BIT_MASK(BTN_RIGHT) | BIT_MASK(BTN_MIDDLE) | 243 BIT_MASK(BTN_RIGHT) | BIT_MASK(BTN_MIDDLE) |
216 BIT_MASK(BTN_SIDE) | BIT_MASK(BTN_EXTRA); 244 BIT_MASK(BTN_SIDE) | BIT_MASK(BTN_EXTRA);
217 input_dev->keybit[BIT_WORD(BTN_DIGI)] |= BIT_MASK(BTN_TOOL_RUBBER) | 245 input_dev->keybit[BIT_WORD(BTN_DIGI)] |= BIT_MASK(BTN_TOOL_RUBBER) |
@@ -228,8 +256,7 @@ void input_dev_i(struct input_dev *input_dev, struct wacom_wac *wacom_wac)
228 256
229void input_dev_pl(struct input_dev *input_dev, struct wacom_wac *wacom_wac) 257void input_dev_pl(struct input_dev *input_dev, struct wacom_wac *wacom_wac)
230{ 258{
231 input_dev->keybit[BIT_WORD(BTN_DIGI)] |= BIT_MASK(BTN_STYLUS2) | 259 input_dev->keybit[BIT_WORD(BTN_DIGI)] |= BIT_MASK(BTN_STYLUS2);
232 BIT_MASK(BTN_TOOL_RUBBER);
233} 260}
234 261
235void input_dev_pt(struct input_dev *input_dev, struct wacom_wac *wacom_wac) 262void input_dev_pt(struct input_dev *input_dev, struct wacom_wac *wacom_wac)
@@ -237,15 +264,129 @@ void input_dev_pt(struct input_dev *input_dev, struct wacom_wac *wacom_wac)
237 input_dev->keybit[BIT_WORD(BTN_DIGI)] |= BIT_MASK(BTN_TOOL_RUBBER); 264 input_dev->keybit[BIT_WORD(BTN_DIGI)] |= BIT_MASK(BTN_TOOL_RUBBER);
238} 265}
239 266
267static int wacom_parse_hid(struct usb_interface *intf, struct hid_descriptor *hid_desc,
268 struct wacom_wac *wacom_wac)
269{
270 struct usb_device *dev = interface_to_usbdev(intf);
271 struct wacom_features *features = wacom_wac->features;
272 char limit = 0, result = 0;
273 int i = 0, usage = WCM_UNDEFINED, finger = 0, pen = 0;
274 unsigned char *report;
275
276 report = kzalloc(hid_desc->wDescriptorLength, GFP_KERNEL);
277 if (!report)
278 return -ENOMEM;
279
280 /* retrive report descriptors */
281 do {
282 result = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0),
283 USB_REQ_GET_DESCRIPTOR,
284 USB_RECIP_INTERFACE | USB_DIR_IN,
285 HID_DEVICET_REPORT << 8,
286 intf->altsetting[0].desc.bInterfaceNumber, /* interface */
287 report,
288 hid_desc->wDescriptorLength,
289 5000); /* 5 secs */
290 } while (result < 0 && limit++ < 5);
291
292 if (result < 0)
293 goto out;
294
295 for (i = 0; i < hid_desc->wDescriptorLength; i++) {
296
297 switch (report[i]) {
298 case HID_USAGE_PAGE:
299 switch (report[i + 1]) {
300 case HID_USAGE_PAGE_DIGITIZER:
301 usage = WCM_DIGITIZER;
302 i++;
303 break;
304
305 case HID_USAGE_PAGE_DESKTOP:
306 usage = WCM_DESKTOP;
307 i++;
308 break;
309 }
310 break;
311
312 case HID_USAGE:
313 switch (report[i + 1]) {
314 case HID_USAGE_X:
315 if (usage == WCM_DESKTOP) {
316 if (finger) {
317 features->touch_x_max =
318 features->touch_y_max =
319 wacom_le16_to_cpu(&report[i + 3]);
320 features->x_max =
321 wacom_le16_to_cpu(&report[i + 6]);
322 i += 7;
323 } else if (pen) {
324 features->x_max =
325 wacom_le16_to_cpu(&report[i + 3]);
326 i += 4;
327 }
328 } else if (usage == WCM_DIGITIZER) {
329 /* max pressure isn't reported
330 features->pressure_max = (unsigned short)
331 (report[i+4] << 8 | report[i + 3]);
332 */
333 features->pressure_max = 255;
334 i += 4;
335 }
336 break;
337
338 case HID_USAGE_Y:
339 if (usage == WCM_DESKTOP)
340 features->y_max =
341 wacom_le16_to_cpu(&report[i + 3]);
342 i += 4;
343 break;
344
345 case HID_USAGE_FINGER:
346 finger = 1;
347 i++;
348 break;
349
350 case HID_USAGE_STYLUS:
351 pen = 1;
352 i++;
353 break;
354
355 case HID_USAGE_UNDEFINED:
356 if (usage == WCM_DESKTOP && finger) /* capacity */
357 features->pressure_max =
358 wacom_le16_to_cpu(&report[i + 3]);
359 i += 4;
360 break;
361 }
362 break;
363
364 case HID_COLLECTION:
365 /* reset UsagePage ans Finger */
366 finger = usage = 0;
367 break;
368 }
369 }
370
371 result = 0;
372
373 out:
374 kfree(report);
375 return result;
376}
377
240static int wacom_probe(struct usb_interface *intf, const struct usb_device_id *id) 378static int wacom_probe(struct usb_interface *intf, const struct usb_device_id *id)
241{ 379{
242 struct usb_device *dev = interface_to_usbdev(intf); 380 struct usb_device *dev = interface_to_usbdev(intf);
381 struct usb_host_interface *interface = intf->cur_altsetting;
243 struct usb_endpoint_descriptor *endpoint; 382 struct usb_endpoint_descriptor *endpoint;
244 struct wacom *wacom; 383 struct wacom *wacom;
245 struct wacom_wac *wacom_wac; 384 struct wacom_wac *wacom_wac;
385 struct wacom_features *features;
246 struct input_dev *input_dev; 386 struct input_dev *input_dev;
247 int error = -ENOMEM; 387 int error = -ENOMEM;
248 char rep_data[2], limit = 0; 388 char rep_data[2], limit = 0;
389 struct hid_descriptor *hid_desc;
249 390
250 wacom = kzalloc(sizeof(struct wacom), GFP_KERNEL); 391 wacom = kzalloc(sizeof(struct wacom), GFP_KERNEL);
251 wacom_wac = kzalloc(sizeof(struct wacom_wac), GFP_KERNEL); 392 wacom_wac = kzalloc(sizeof(struct wacom_wac), GFP_KERNEL);
@@ -268,8 +409,8 @@ static int wacom_probe(struct usb_interface *intf, const struct usb_device_id *i
268 usb_make_path(dev, wacom->phys, sizeof(wacom->phys)); 409 usb_make_path(dev, wacom->phys, sizeof(wacom->phys));
269 strlcat(wacom->phys, "/input0", sizeof(wacom->phys)); 410 strlcat(wacom->phys, "/input0", sizeof(wacom->phys));
270 411
271 wacom_wac->features = get_wacom_feature(id); 412 wacom_wac->features = features = get_wacom_feature(id);
272 BUG_ON(wacom_wac->features->pktlen > 10); 413 BUG_ON(features->pktlen > 10);
273 414
274 input_dev->name = wacom_wac->features->name; 415 input_dev->name = wacom_wac->features->name;
275 wacom->wacom_wac = wacom_wac; 416 wacom->wacom_wac = wacom_wac;
@@ -282,18 +423,37 @@ static int wacom_probe(struct usb_interface *intf, const struct usb_device_id *i
282 input_dev->open = wacom_open; 423 input_dev->open = wacom_open;
283 input_dev->close = wacom_close; 424 input_dev->close = wacom_close;
284 425
426 endpoint = &intf->cur_altsetting->endpoint[0].desc;
427
428 /* TabletPC need to retrieve the physical and logical maximum from report descriptor */
429 if (wacom_wac->features->type == TABLETPC) {
430 if (usb_get_extra_descriptor(interface, HID_DEVICET_HID, &hid_desc)) {
431 if (usb_get_extra_descriptor(&interface->endpoint[0],
432 HID_DEVICET_REPORT, &hid_desc)) {
433 printk("wacom: can not retrive extra class descriptor\n");
434 goto fail2;
435 }
436 }
437 error = wacom_parse_hid(intf, hid_desc, wacom_wac);
438 if (error)
439 goto fail2;
440 }
441
285 input_dev->evbit[0] |= BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS); 442 input_dev->evbit[0] |= BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS);
286 input_dev->keybit[BIT_WORD(BTN_DIGI)] |= BIT_MASK(BTN_TOOL_PEN) | 443 input_dev->keybit[BIT_WORD(BTN_DIGI)] |= BIT_MASK(BTN_TOOL_PEN) |
287 BIT_MASK(BTN_TOUCH) | BIT_MASK(BTN_STYLUS); 444 BIT_MASK(BTN_TOUCH) | BIT_MASK(BTN_STYLUS);
288 input_set_abs_params(input_dev, ABS_X, 0, wacom_wac->features->x_max, 4, 0); 445 input_set_abs_params(input_dev, ABS_X, 0, features->x_max, 4, 0);
289 input_set_abs_params(input_dev, ABS_Y, 0, wacom_wac->features->y_max, 4, 0); 446 input_set_abs_params(input_dev, ABS_Y, 0, features->y_max, 4, 0);
290 input_set_abs_params(input_dev, ABS_PRESSURE, 0, wacom_wac->features->pressure_max, 0, 0); 447 input_set_abs_params(input_dev, ABS_PRESSURE, 0, features->pressure_max, 0, 0);
448 if (features->type == TABLETPC) {
449 input_dev->keybit[BIT_WORD(BTN_DIGI)] |= BIT_MASK(BTN_TOOL_DOUBLETAP);
450 input_set_abs_params(input_dev, ABS_RX, 0, features->touch_x_max, 4, 0);
451 input_set_abs_params(input_dev, ABS_RY, 0, features->touch_y_max, 4, 0);
452 }
291 input_dev->absbit[BIT_WORD(ABS_MISC)] |= BIT_MASK(ABS_MISC); 453 input_dev->absbit[BIT_WORD(ABS_MISC)] |= BIT_MASK(ABS_MISC);
292 454
293 wacom_init_input_dev(input_dev, wacom_wac); 455 wacom_init_input_dev(input_dev, wacom_wac);
294 456
295 endpoint = &intf->cur_altsetting->endpoint[0].desc;
296
297 usb_fill_int_urb(wacom->irq, dev, 457 usb_fill_int_urb(wacom->irq, dev,
298 usb_rcvintpipe(dev, endpoint->bEndpointAddress), 458 usb_rcvintpipe(dev, endpoint->bEndpointAddress),
299 wacom_wac->data, wacom_wac->features->pktlen, 459 wacom_wac->data, wacom_wac->features->pktlen,
@@ -305,13 +465,22 @@ static int wacom_probe(struct usb_interface *intf, const struct usb_device_id *i
305 if (error) 465 if (error)
306 goto fail3; 466 goto fail3;
307 467
308 /* Ask the tablet to report tablet data. Repeat until it succeeds */ 468 /*
309 do { 469 * Ask the tablet to report tablet data if it is not a Tablet PC.
310 rep_data[0] = 2; 470 * Repeat until it succeeds
311 rep_data[1] = 2; 471 */
312 usb_set_report(intf, 3, 2, rep_data, 2); 472 if (wacom_wac->features->type != TABLETPC) {
313 usb_get_report(intf, 3, 2, rep_data, 2); 473 do {
314 } while (rep_data[1] != 2 && limit++ < 5); 474 rep_data[0] = 2;
475 rep_data[1] = 2;
476 error = usb_set_report(intf, WAC_HID_FEATURE_REPORT,
477 2, rep_data, 2);
478 if (error >= 0)
479 error = usb_get_report(intf,
480 WAC_HID_FEATURE_REPORT, 2,
481 rep_data, 2);
482 } while ((error < 0 || rep_data[1] != 2) && limit++ < 5);
483 }
315 484
316 usb_set_intfdata(intf, wacom); 485 usb_set_intfdata(intf, wacom);
317 return 0; 486 return 0;
@@ -333,7 +502,8 @@ static void wacom_disconnect(struct usb_interface *intf)
333 usb_kill_urb(wacom->irq); 502 usb_kill_urb(wacom->irq);
334 input_unregister_device(wacom->dev); 503 input_unregister_device(wacom->dev);
335 usb_free_urb(wacom->irq); 504 usb_free_urb(wacom->irq);
336 usb_buffer_free(interface_to_usbdev(intf), 10, wacom->wacom_wac->data, wacom->data_dma); 505 usb_buffer_free(interface_to_usbdev(intf), 10,
506 wacom->wacom_wac->data, wacom->data_dma);
337 kfree(wacom->wacom_wac); 507 kfree(wacom->wacom_wac);
338 kfree(wacom); 508 kfree(wacom);
339} 509}
diff --git a/drivers/input/tablet/wacom_wac.c b/drivers/input/tablet/wacom_wac.c
index bf3d9a8b2c1b..8dc8d1e59bea 100644
--- a/drivers/input/tablet/wacom_wac.c
+++ b/drivers/input/tablet/wacom_wac.c
@@ -535,31 +535,147 @@ static int wacom_intuos_irq(struct wacom_wac *wacom, void *wcombo)
535 return 1; 535 return 1;
536} 536}
537 537
538int wacom_tpc_irq(struct wacom_wac *wacom, void *wcombo)
539{
540 char *data = wacom->data;
541 int prox = 0, pressure;
542 static int stylusInProx, touchInProx = 1, touchOut;
543 struct urb *urb = ((struct wacom_combo *)wcombo)->urb;
544
545 dbg("wacom_tpc_irq: received report #%d", data[0]);
546
547 if (urb->actual_length == 5 || data[0] == 6) { /* Touch data */
548 if (urb->actual_length == 5) { /* with touch */
549 prox = data[0] & 0x03;
550 } else { /* with capacity */
551 prox = data[1] & 0x03;
552 }
553
554 if (!stylusInProx) { /* stylus not in prox */
555 if (prox) {
556 if (touchInProx) {
557 wacom->tool[1] = BTN_TOOL_DOUBLETAP;
558 wacom->id[0] = TOUCH_DEVICE_ID;
559 if (urb->actual_length != 5) {
560 wacom_report_abs(wcombo, ABS_X, wacom_le16_to_cpu(&data[2]));
561 wacom_report_abs(wcombo, ABS_Y, wacom_le16_to_cpu(&data[4]));
562 wacom_report_abs(wcombo, ABS_PRESSURE, wacom_le16_to_cpu(&data[6]));
563 wacom_report_key(wcombo, BTN_TOUCH, wacom_le16_to_cpu(&data[6]));
564 } else {
565 wacom_report_abs(wcombo, ABS_X, wacom_le16_to_cpu(&data[1]));
566 wacom_report_abs(wcombo, ABS_Y, wacom_le16_to_cpu(&data[3]));
567 wacom_report_key(wcombo, BTN_TOUCH, 1);
568 }
569 wacom_report_abs(wcombo, ABS_MISC, wacom->id[0]);
570 wacom_report_key(wcombo, wacom->tool[1], prox & 0x01);
571 touchOut = 1;
572 return 1;
573 }
574 } else {
575 wacom_report_abs(wcombo, ABS_MISC, wacom->id[0]);
576 wacom_report_key(wcombo, wacom->tool[1], prox & 0x01);
577 wacom_report_key(wcombo, BTN_TOUCH, 0);
578 touchOut = 0;
579 touchInProx = 1;
580 return 1;
581 }
582 } else if (touchOut || !prox) { /* force touch out-prox */
583 wacom_report_abs(wcombo, ABS_MISC, TOUCH_DEVICE_ID);
584 wacom_report_key(wcombo, BTN_TOUCH, 0);
585 touchOut = 0;
586 touchInProx = 1;
587 return 1;
588 }
589 } else if (data[0] == 2) { /* Penabled */
590 prox = data[1] & 0x20;
591
592 touchInProx = 0;
593
594 wacom->id[0] = ERASER_DEVICE_ID;
595
596 /*
597 * if going from out of proximity into proximity select between the eraser
598 * and the pen based on the state of the stylus2 button, choose eraser if
599 * pressed else choose pen. if not a proximity change from out to in, send
600 * an out of proximity for previous tool then a in for new tool.
601 */
602 if (prox) { /* in prox */
603 if (!wacom->tool[0]) {
604 /* Going into proximity select tool */
605 wacom->tool[1] = (data[1] & 0x08) ? BTN_TOOL_RUBBER : BTN_TOOL_PEN;
606 if (wacom->tool[1] == BTN_TOOL_PEN)
607 wacom->id[0] = STYLUS_DEVICE_ID;
608 } else if (wacom->tool[1] == BTN_TOOL_RUBBER && !(data[1] & 0x08)) {
609 /*
610 * was entered with stylus2 pressed
611 * report out proximity for previous tool
612 */
613 wacom_report_abs(wcombo, ABS_MISC, wacom->id[0]);
614 wacom_report_key(wcombo, wacom->tool[1], 0);
615 wacom_input_sync(wcombo);
616
617 /* set new tool */
618 wacom->tool[1] = BTN_TOOL_PEN;
619 wacom->id[0] = STYLUS_DEVICE_ID;
620 return 0;
621 }
622 if (wacom->tool[1] != BTN_TOOL_RUBBER) {
623 /* Unknown tool selected default to pen tool */
624 wacom->tool[1] = BTN_TOOL_PEN;
625 wacom->id[0] = STYLUS_DEVICE_ID;
626 }
627 wacom_report_key(wcombo, BTN_STYLUS, data[1] & 0x02);
628 wacom_report_key(wcombo, BTN_STYLUS2, data[1] & 0x10);
629 wacom_report_abs(wcombo, ABS_X, wacom_le16_to_cpu(&data[2]));
630 wacom_report_abs(wcombo, ABS_Y, wacom_le16_to_cpu(&data[4]));
631 pressure = ((data[7] & 0x01) << 8) | data[6];
632 if (pressure < 0)
633 pressure = wacom->features->pressure_max + pressure + 1;
634 wacom_report_abs(wcombo, ABS_PRESSURE, pressure);
635 wacom_report_key(wcombo, BTN_TOUCH, pressure);
636 } else {
637 wacom_report_abs(wcombo, ABS_PRESSURE, 0);
638 wacom_report_key(wcombo, BTN_STYLUS, 0);
639 wacom_report_key(wcombo, BTN_STYLUS2, 0);
640 wacom_report_key(wcombo, BTN_TOUCH, 0);
641 }
642 wacom_report_key(wcombo, wacom->tool[1], prox);
643 wacom_report_abs(wcombo, ABS_MISC, wacom->id[0]);
644 stylusInProx = prox;
645 wacom->tool[0] = prox;
646 return 1;
647 }
648 return 0;
649}
650
538int wacom_wac_irq(struct wacom_wac *wacom_wac, void *wcombo) 651int wacom_wac_irq(struct wacom_wac *wacom_wac, void *wcombo)
539{ 652{
540 switch (wacom_wac->features->type) { 653 switch (wacom_wac->features->type) {
541 case PENPARTNER: 654 case PENPARTNER:
542 return (wacom_penpartner_irq(wacom_wac, wcombo)); 655 return wacom_penpartner_irq(wacom_wac, wcombo);
543 break; 656
544 case PL: 657 case PL:
545 return (wacom_pl_irq(wacom_wac, wcombo)); 658 return wacom_pl_irq(wacom_wac, wcombo);
546 break; 659
547 case WACOM_G4: 660 case WACOM_G4:
548 case GRAPHIRE: 661 case GRAPHIRE:
549 case WACOM_MO: 662 case WACOM_MO:
550 return (wacom_graphire_irq(wacom_wac, wcombo)); 663 return wacom_graphire_irq(wacom_wac, wcombo);
551 break; 664
552 case PTU: 665 case PTU:
553 return (wacom_ptu_irq(wacom_wac, wcombo)); 666 return wacom_ptu_irq(wacom_wac, wcombo);
554 break; 667
555 case INTUOS: 668 case INTUOS:
556 case INTUOS3S: 669 case INTUOS3S:
557 case INTUOS3: 670 case INTUOS3:
558 case INTUOS3L: 671 case INTUOS3L:
559 case CINTIQ: 672 case CINTIQ:
560 case WACOM_BEE: 673 case WACOM_BEE:
561 return (wacom_intuos_irq(wacom_wac, wcombo)); 674 return wacom_intuos_irq(wacom_wac, wcombo);
562 break; 675
676 case TABLETPC:
677 return wacom_tpc_irq(wacom_wac, wcombo);
678
563 default: 679 default:
564 return 0; 680 return 0;
565 } 681 }
@@ -586,13 +702,15 @@ void wacom_init_input_dev(struct input_dev *input_dev, struct wacom_wac *wacom_w
586 /* fall through */ 702 /* fall through */
587 case INTUOS3S: 703 case INTUOS3S:
588 input_dev_i3s(input_dev, wacom_wac); 704 input_dev_i3s(input_dev, wacom_wac);
705 /* fall through */
589 case INTUOS: 706 case INTUOS:
590 input_dev_i(input_dev, wacom_wac); 707 input_dev_i(input_dev, wacom_wac);
591 break; 708 break;
592 case PL: 709 case PL:
593 case PTU: 710 case PTU:
711 case TABLETPC:
594 input_dev_pl(input_dev, wacom_wac); 712 input_dev_pl(input_dev, wacom_wac);
595 break; 713 /* fall through */
596 case PENPARTNER: 714 case PENPARTNER:
597 input_dev_pt(input_dev, wacom_wac); 715 input_dev_pt(input_dev, wacom_wac);
598 break; 716 break;
@@ -611,6 +729,7 @@ static struct wacom_features wacom_features[] = {
611 { "Wacom Graphire4 6x8", 8, 16704, 12064, 511, 63, WACOM_G4 }, 729 { "Wacom Graphire4 6x8", 8, 16704, 12064, 511, 63, WACOM_G4 },
612 { "Wacom BambooFun 4x5", 9, 14760, 9225, 511, 63, WACOM_MO }, 730 { "Wacom BambooFun 4x5", 9, 14760, 9225, 511, 63, WACOM_MO },
613 { "Wacom BambooFun 6x8", 9, 21648, 13530, 511, 63, WACOM_MO }, 731 { "Wacom BambooFun 6x8", 9, 21648, 13530, 511, 63, WACOM_MO },
732 { "Wacom Bamboo1 Medium",8, 16704, 12064, 511, 63, GRAPHIRE },
614 { "Wacom Volito", 8, 5104, 3712, 511, 63, GRAPHIRE }, 733 { "Wacom Volito", 8, 5104, 3712, 511, 63, GRAPHIRE },
615 { "Wacom PenStation2", 8, 3250, 2320, 255, 63, GRAPHIRE }, 734 { "Wacom PenStation2", 8, 3250, 2320, 255, 63, GRAPHIRE },
616 { "Wacom Volito2 4x5", 8, 5104, 3712, 511, 63, GRAPHIRE }, 735 { "Wacom Volito2 4x5", 8, 5104, 3712, 511, 63, GRAPHIRE },
@@ -650,6 +769,10 @@ static struct wacom_features wacom_features[] = {
650 { "Wacom Cintiq 21UX", 10, 87200, 65600, 1023, 63, CINTIQ }, 769 { "Wacom Cintiq 21UX", 10, 87200, 65600, 1023, 63, CINTIQ },
651 { "Wacom Cintiq 20WSX", 10, 86680, 54180, 1023, 63, WACOM_BEE }, 770 { "Wacom Cintiq 20WSX", 10, 86680, 54180, 1023, 63, WACOM_BEE },
652 { "Wacom Cintiq 12WX", 10, 53020, 33440, 1023, 63, WACOM_BEE }, 771 { "Wacom Cintiq 12WX", 10, 53020, 33440, 1023, 63, WACOM_BEE },
772 { "Wacom DTU1931", 8, 37832, 30305, 511, 0, PL },
773 { "Wacom ISDv4 90", 8, 26202, 16325, 255, 0, TABLETPC },
774 { "Wacom ISDv4 93", 8, 26202, 16325, 255, 0, TABLETPC },
775 { "Wacom ISDv4 9A", 8, 26202, 16325, 255, 0, TABLETPC },
653 { "Wacom Intuos2 6x8", 10, 20320, 16240, 1023, 31, INTUOS }, 776 { "Wacom Intuos2 6x8", 10, 20320, 16240, 1023, 31, INTUOS },
654 { } 777 { }
655}; 778};
@@ -665,6 +788,7 @@ static struct usb_device_id wacom_ids[] = {
665 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x16) }, 788 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x16) },
666 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x17) }, 789 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x17) },
667 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x18) }, 790 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x18) },
791 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x19) },
668 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x60) }, 792 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x60) },
669 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x61) }, 793 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x61) },
670 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x62) }, 794 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x62) },
@@ -704,18 +828,26 @@ static struct usb_device_id wacom_ids[] = {
704 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x3F) }, 828 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x3F) },
705 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xC5) }, 829 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xC5) },
706 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xC6) }, 830 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xC6) },
831 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xC7) },
832 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x90) },
833 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x93) },
834 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x9A) },
707 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x47) }, 835 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x47) },
708 { } 836 { }
709}; 837};
710 838
711const struct usb_device_id * get_device_table(void) { 839const struct usb_device_id *get_device_table(void)
712 const struct usb_device_id * id_table = wacom_ids; 840{
841 const struct usb_device_id *id_table = wacom_ids;
842
713 return id_table; 843 return id_table;
714} 844}
715 845
716struct wacom_features * get_wacom_feature(const struct usb_device_id * id) { 846struct wacom_features * get_wacom_feature(const struct usb_device_id *id)
847{
717 int index = id - wacom_ids; 848 int index = id - wacom_ids;
718 struct wacom_features *wf = &wacom_features[index]; 849 struct wacom_features *wf = &wacom_features[index];
850
719 return wf; 851 return wf;
720} 852}
721 853
diff --git a/drivers/input/tablet/wacom_wac.h b/drivers/input/tablet/wacom_wac.h
index 3342bc05847d..f9c8b69673b7 100644
--- a/drivers/input/tablet/wacom_wac.h
+++ b/drivers/input/tablet/wacom_wac.h
@@ -10,6 +10,7 @@
10#define WACOM_WAC_H 10#define WACOM_WAC_H
11 11
12#define STYLUS_DEVICE_ID 0x02 12#define STYLUS_DEVICE_ID 0x02
13#define TOUCH_DEVICE_ID 0x03
13#define CURSOR_DEVICE_ID 0x06 14#define CURSOR_DEVICE_ID 0x06
14#define ERASER_DEVICE_ID 0x0A 15#define ERASER_DEVICE_ID 0x0A
15#define PAD_DEVICE_ID 0x0F 16#define PAD_DEVICE_ID 0x0F
@@ -27,6 +28,7 @@ enum {
27 CINTIQ, 28 CINTIQ,
28 WACOM_BEE, 29 WACOM_BEE,
29 WACOM_MO, 30 WACOM_MO,
31 TABLETPC,
30 MAX_TYPE 32 MAX_TYPE
31}; 33};
32 34
@@ -38,6 +40,8 @@ struct wacom_features {
38 int pressure_max; 40 int pressure_max;
39 int distance_max; 41 int distance_max;
40 int type; 42 int type;
43 int touch_x_max;
44 int touch_y_max;
41}; 45};
42 46
43struct wacom_wac { 47struct wacom_wac {