aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/input/tablet
diff options
context:
space:
mode:
authorDmitry Torokhov <dmitry.torokhov@gmail.com>2010-03-20 01:18:15 -0400
committerDmitry Torokhov <dmitry.torokhov@gmail.com>2010-04-14 02:24:23 -0400
commit8da23fc113e8bdaf813545ec935a6c60254ac439 (patch)
tree4423781a8a27b44082de74b987e3c3ee2c12a215 /drivers/input/tablet
parent73a97f4f6e53545b71f5c14ae2cb70a4b8d3cf63 (diff)
Input: wacom - get rid of input event wrappers
Input event interface is pretty stable so let's get rig of wrappers for input_event() and fiends and call them directly. This will simplify and speed up code a bit. Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
Diffstat (limited to 'drivers/input/tablet')
-rw-r--r--drivers/input/tablet/wacom.h28
-rw-r--r--drivers/input/tablet/wacom_sys.c174
-rw-r--r--drivers/input/tablet/wacom_wac.c549
-rw-r--r--drivers/input/tablet/wacom_wac.h1
4 files changed, 347 insertions, 405 deletions
diff --git a/drivers/input/tablet/wacom.h b/drivers/input/tablet/wacom.h
index fdb1d16b947..103a8cc2944 100644
--- a/drivers/input/tablet/wacom.h
+++ b/drivers/input/tablet/wacom.h
@@ -106,7 +106,6 @@ MODULE_LICENSE(DRIVER_LICENSE);
106 106
107struct wacom { 107struct wacom {
108 dma_addr_t data_dma; 108 dma_addr_t data_dma;
109 struct input_dev *dev;
110 struct usb_device *usbdev; 109 struct usb_device *usbdev;
111 struct usb_interface *intf; 110 struct usb_interface *intf;
112 struct urb *irq; 111 struct urb *irq;
@@ -123,27 +122,10 @@ struct wacom_combo {
123 122
124extern const struct usb_device_id wacom_ids[]; 123extern const struct usb_device_id wacom_ids[];
125 124
126extern int wacom_wac_irq(struct wacom_wac * wacom_wac, void * wcombo); 125int wacom_wac_irq(struct wacom_wac * wacom_wac, void * wcombo);
127extern void wacom_report_abs(void *wcombo, unsigned int abs_type, int abs_data); 126void wacom_setup_input_capabilities(struct input_dev *input_dev,
128extern void wacom_report_rel(void *wcombo, unsigned int rel_type, int rel_data); 127 struct wacom_wac *wacom_wac);
129extern void wacom_report_key(void *wcombo, unsigned int key_type, int key_data); 128__u16 wacom_le16_to_cpu(unsigned char *data);
130extern void wacom_input_event(void *wcombo, unsigned int type, unsigned int code, int value); 129__u16 wacom_be16_to_cpu(unsigned char *data);
131extern void wacom_input_sync(void *wcombo);
132extern void wacom_init_input_dev(struct input_dev *input_dev, struct wacom_wac *wacom_wac);
133extern void input_dev_g4(struct input_dev *input_dev, struct wacom_wac *wacom_wac);
134extern void input_dev_g(struct input_dev *input_dev, struct wacom_wac *wacom_wac);
135extern void input_dev_i3s(struct input_dev *input_dev, struct wacom_wac *wacom_wac);
136extern void input_dev_i3(struct input_dev *input_dev, struct wacom_wac *wacom_wac);
137extern void input_dev_i(struct input_dev *input_dev, struct wacom_wac *wacom_wac);
138extern void input_dev_i4s(struct input_dev *input_dev, struct wacom_wac *wacom_wac);
139extern void input_dev_i4(struct input_dev *input_dev, struct wacom_wac *wacom_wac);
140extern void input_dev_pl(struct input_dev *input_dev, struct wacom_wac *wacom_wac);
141extern void input_dev_pt(struct input_dev *input_dev, struct wacom_wac *wacom_wac);
142extern void input_dev_tpc(struct input_dev *input_dev, struct wacom_wac *wacom_wac);
143extern void input_dev_tpc2fg(struct input_dev *input_dev, struct wacom_wac *wacom_wac);
144extern void input_dev_mo(struct input_dev *input_dev, struct wacom_wac *wacom_wac);
145extern void input_dev_bee(struct input_dev *input_dev, struct wacom_wac *wacom_wac);
146extern __u16 wacom_le16_to_cpu(unsigned char *data);
147extern __u16 wacom_be16_to_cpu(unsigned char *data);
148 130
149#endif 131#endif
diff --git a/drivers/input/tablet/wacom_sys.c b/drivers/input/tablet/wacom_sys.c
index ed339e5eca8..58bb763b60d 100644
--- a/drivers/input/tablet/wacom_sys.c
+++ b/drivers/input/tablet/wacom_sys.c
@@ -72,7 +72,7 @@ static int usb_set_report(struct usb_interface *intf, unsigned char type,
72 72
73static struct input_dev * get_input_dev(struct wacom_combo *wcombo) 73static struct input_dev * get_input_dev(struct wacom_combo *wcombo)
74{ 74{
75 return wcombo->wacom->dev; 75 return wcombo->wacom->wacom_wac.input;
76} 76}
77 77
78static void wacom_sys_irq(struct urb *urb) 78static void wacom_sys_irq(struct urb *urb)
@@ -110,26 +110,6 @@ static void wacom_sys_irq(struct urb *urb)
110 __func__, retval); 110 __func__, retval);
111} 111}
112 112
113void wacom_report_key(void *wcombo, unsigned int key_type, int key_data)
114{
115 input_report_key(get_input_dev((struct wacom_combo *)wcombo), key_type, key_data);
116}
117
118void wacom_report_abs(void *wcombo, unsigned int abs_type, int abs_data)
119{
120 input_report_abs(get_input_dev((struct wacom_combo *)wcombo), abs_type, abs_data);
121}
122
123void wacom_report_rel(void *wcombo, unsigned int rel_type, int rel_data)
124{
125 input_report_rel(get_input_dev((struct wacom_combo *)wcombo), rel_type, rel_data);
126}
127
128void wacom_input_event(void *wcombo, unsigned int type, unsigned int code, int value)
129{
130 input_event(get_input_dev((struct wacom_combo *)wcombo), type, code, value);
131}
132
133__u16 wacom_be16_to_cpu(unsigned char *data) 113__u16 wacom_be16_to_cpu(unsigned char *data)
134{ 114{
135 __u16 value; 115 __u16 value;
@@ -144,11 +124,6 @@ __u16 wacom_le16_to_cpu(unsigned char *data)
144 return value; 124 return value;
145} 125}
146 126
147void wacom_input_sync(void *wcombo)
148{
149 input_sync(get_input_dev((struct wacom_combo *)wcombo));
150}
151
152static int wacom_open(struct input_dev *dev) 127static int wacom_open(struct input_dev *dev)
153{ 128{
154 struct wacom *wacom = input_get_drvdata(dev); 129 struct wacom *wacom = input_get_drvdata(dev);
@@ -186,123 +161,6 @@ static void wacom_close(struct input_dev *dev)
186 mutex_unlock(&wacom->lock); 161 mutex_unlock(&wacom->lock);
187} 162}
188 163
189void input_dev_mo(struct input_dev *input_dev, struct wacom_wac *wacom_wac)
190{
191 input_dev->keybit[BIT_WORD(BTN_MISC)] |= BIT_MASK(BTN_1) |
192 BIT_MASK(BTN_5);
193 input_set_abs_params(input_dev, ABS_WHEEL, 0, 71, 0, 0);
194}
195
196void input_dev_g4(struct input_dev *input_dev, struct wacom_wac *wacom_wac)
197{
198 input_dev->evbit[0] |= BIT_MASK(EV_MSC);
199 input_dev->mscbit[0] |= BIT_MASK(MSC_SERIAL);
200 input_dev->keybit[BIT_WORD(BTN_DIGI)] |= BIT_MASK(BTN_TOOL_FINGER);
201 input_dev->keybit[BIT_WORD(BTN_MISC)] |= BIT_MASK(BTN_0) |
202 BIT_MASK(BTN_4);
203}
204
205void input_dev_g(struct input_dev *input_dev, struct wacom_wac *wacom_wac)
206{
207 input_dev->evbit[0] |= BIT_MASK(EV_REL);
208 input_dev->relbit[0] |= BIT_MASK(REL_WHEEL);
209 input_dev->keybit[BIT_WORD(BTN_MOUSE)] |= BIT_MASK(BTN_LEFT) |
210 BIT_MASK(BTN_RIGHT) | BIT_MASK(BTN_MIDDLE);
211 input_dev->keybit[BIT_WORD(BTN_DIGI)] |= BIT_MASK(BTN_TOOL_RUBBER) |
212 BIT_MASK(BTN_TOOL_PEN) | BIT_MASK(BTN_STYLUS) |
213 BIT_MASK(BTN_TOOL_MOUSE) | BIT_MASK(BTN_STYLUS2);
214 input_set_abs_params(input_dev, ABS_DISTANCE,
215 0, wacom_wac->features.distance_max, 0, 0);
216}
217
218void input_dev_i3s(struct input_dev *input_dev, struct wacom_wac *wacom_wac)
219{
220 input_dev->keybit[BIT_WORD(BTN_DIGI)] |= BIT_MASK(BTN_TOOL_FINGER);
221 input_dev->keybit[BIT_WORD(BTN_MISC)] |= BIT_MASK(BTN_0) |
222 BIT_MASK(BTN_1) | BIT_MASK(BTN_2) | BIT_MASK(BTN_3);
223 input_set_abs_params(input_dev, ABS_RX, 0, 4096, 0, 0);
224 input_set_abs_params(input_dev, ABS_Z, -900, 899, 0, 0);
225}
226
227void input_dev_i3(struct input_dev *input_dev, struct wacom_wac *wacom_wac)
228{
229 input_dev->keybit[BIT_WORD(BTN_MISC)] |= BIT_MASK(BTN_4) |
230 BIT_MASK(BTN_5) | BIT_MASK(BTN_6) | BIT_MASK(BTN_7);
231 input_set_abs_params(input_dev, ABS_RY, 0, 4096, 0, 0);
232}
233
234void input_dev_i4s(struct input_dev *input_dev, struct wacom_wac *wacom_wac)
235{
236 input_dev->keybit[BIT_WORD(BTN_DIGI)] |= BIT_MASK(BTN_TOOL_FINGER);
237 input_dev->keybit[BIT_WORD(BTN_MISC)] |= BIT_MASK(BTN_0) | BIT_MASK(BTN_1) | BIT_MASK(BTN_2) | BIT_MASK(BTN_3);
238 input_dev->keybit[BIT_WORD(BTN_MISC)] |= BIT_MASK(BTN_4) | BIT_MASK(BTN_5) | BIT_MASK(BTN_6);
239 input_set_abs_params(input_dev, ABS_Z, -900, 899, 0, 0);
240}
241
242void input_dev_i4(struct input_dev *input_dev, struct wacom_wac *wacom_wac)
243{
244 input_dev->keybit[BIT_WORD(BTN_MISC)] |= BIT_MASK(BTN_7) | BIT_MASK(BTN_8);
245}
246
247void input_dev_bee(struct input_dev *input_dev, struct wacom_wac *wacom_wac)
248{
249 input_dev->keybit[BIT_WORD(BTN_MISC)] |= BIT_MASK(BTN_8) | BIT_MASK(BTN_9);
250}
251
252void input_dev_i(struct input_dev *input_dev, struct wacom_wac *wacom_wac)
253{
254 input_dev->evbit[0] |= BIT_MASK(EV_MSC) | BIT_MASK(EV_REL);
255 input_dev->mscbit[0] |= BIT_MASK(MSC_SERIAL);
256 input_dev->relbit[0] |= BIT_MASK(REL_WHEEL);
257 input_dev->keybit[BIT_WORD(BTN_MOUSE)] |= BIT_MASK(BTN_LEFT) |
258 BIT_MASK(BTN_RIGHT) | BIT_MASK(BTN_MIDDLE) |
259 BIT_MASK(BTN_SIDE) | BIT_MASK(BTN_EXTRA);
260 input_dev->keybit[BIT_WORD(BTN_DIGI)] |= BIT_MASK(BTN_TOOL_RUBBER) |
261 BIT_MASK(BTN_TOOL_PEN) | BIT_MASK(BTN_STYLUS) |
262 BIT_MASK(BTN_TOOL_MOUSE) | BIT_MASK(BTN_TOOL_BRUSH) |
263 BIT_MASK(BTN_TOOL_PENCIL) | BIT_MASK(BTN_TOOL_AIRBRUSH) |
264 BIT_MASK(BTN_TOOL_LENS) | BIT_MASK(BTN_STYLUS2);
265 input_set_abs_params(input_dev, ABS_DISTANCE,
266 0, wacom_wac->features.distance_max, 0, 0);
267 input_set_abs_params(input_dev, ABS_WHEEL, 0, 1023, 0, 0);
268 input_set_abs_params(input_dev, ABS_TILT_X, 0, 127, 0, 0);
269 input_set_abs_params(input_dev, ABS_TILT_Y, 0, 127, 0, 0);
270 input_set_abs_params(input_dev, ABS_RZ, -900, 899, 0, 0);
271 input_set_abs_params(input_dev, ABS_THROTTLE, -1023, 1023, 0, 0);
272}
273
274void input_dev_pl(struct input_dev *input_dev, struct wacom_wac *wacom_wac)
275{
276 input_dev->keybit[BIT_WORD(BTN_DIGI)] |= BIT_MASK(BTN_TOOL_PEN) |
277 BIT_MASK(BTN_STYLUS) | BIT_MASK(BTN_STYLUS2);
278}
279
280void input_dev_pt(struct input_dev *input_dev, struct wacom_wac *wacom_wac)
281{
282 input_dev->keybit[BIT_WORD(BTN_DIGI)] |= BIT_MASK(BTN_TOOL_RUBBER);
283}
284
285void input_dev_tpc(struct input_dev *input_dev, struct wacom_wac *wacom_wac)
286{
287 struct wacom_features *features = &wacom_wac->features;
288
289 if (features->device_type == BTN_TOOL_DOUBLETAP ||
290 features->device_type == BTN_TOOL_TRIPLETAP) {
291 input_set_abs_params(input_dev, ABS_RX, 0, features->x_phy, 0, 0);
292 input_set_abs_params(input_dev, ABS_RY, 0, features->y_phy, 0, 0);
293 __set_bit(BTN_TOOL_DOUBLETAP, input_dev->keybit);
294 }
295}
296
297void input_dev_tpc2fg(struct input_dev *input_dev, struct wacom_wac *wacom_wac)
298{
299 if (wacom_wac->features.device_type == BTN_TOOL_TRIPLETAP) {
300 input_dev->keybit[BIT_WORD(BTN_DIGI)] |= BIT_MASK(BTN_TOOL_TRIPLETAP);
301 input_dev->evbit[0] |= BIT_MASK(EV_MSC);
302 input_dev->mscbit[0] |= BIT_MASK(MSC_SERIAL);
303 }
304}
305
306static int wacom_parse_hid(struct usb_interface *intf, struct hid_descriptor *hid_desc, 164static int wacom_parse_hid(struct usb_interface *intf, struct hid_descriptor *hid_desc,
307 struct wacom_features *features) 165 struct wacom_features *features)
308{ 166{
@@ -645,20 +503,12 @@ static int wacom_probe(struct usb_interface *intf, const struct usb_device_id *i
645 } 503 }
646 504
647 wacom->usbdev = dev; 505 wacom->usbdev = dev;
648 wacom->dev = input_dev;
649 wacom->intf = intf; 506 wacom->intf = intf;
650 mutex_init(&wacom->lock); 507 mutex_init(&wacom->lock);
651 usb_make_path(dev, wacom->phys, sizeof(wacom->phys)); 508 usb_make_path(dev, wacom->phys, sizeof(wacom->phys));
652 strlcat(wacom->phys, "/input0", sizeof(wacom->phys)); 509 strlcat(wacom->phys, "/input0", sizeof(wacom->phys));
653 510
654 usb_to_input_id(dev, &input_dev->id); 511 wacom_wac->input = input_dev;
655
656 input_dev->dev.parent = &intf->dev;
657
658 input_set_drvdata(input_dev, wacom);
659
660 input_dev->open = wacom_open;
661 input_dev->close = wacom_close;
662 512
663 endpoint = &intf->cur_altsetting->endpoint[0].desc; 513 endpoint = &intf->cur_altsetting->endpoint[0].desc;
664 514
@@ -682,16 +532,14 @@ static int wacom_probe(struct usb_interface *intf, const struct usb_device_id *i
682 } 532 }
683 533
684 input_dev->name = wacom_wac->name; 534 input_dev->name = wacom_wac->name;
535 input_dev->name = wacom_wac->name;
536 input_dev->dev.parent = &intf->dev;
537 input_dev->open = wacom_open;
538 input_dev->close = wacom_close;
539 usb_to_input_id(dev, &input_dev->id);
540 input_set_drvdata(input_dev, wacom);
685 541
686 input_dev->evbit[0] |= BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS); 542 wacom_setup_input_capabilities(input_dev, wacom_wac);
687 input_dev->keybit[BIT_WORD(BTN_DIGI)] |= BIT_MASK(BTN_TOUCH);
688
689 input_set_abs_params(input_dev, ABS_X, 0, features->x_max, 4, 0);
690 input_set_abs_params(input_dev, ABS_Y, 0, features->y_max, 4, 0);
691 input_set_abs_params(input_dev, ABS_PRESSURE, 0, features->pressure_max, 0, 0);
692 input_dev->absbit[BIT_WORD(ABS_MISC)] |= BIT_MASK(ABS_MISC);
693
694 wacom_init_input_dev(input_dev, wacom_wac);
695 543
696 usb_fill_int_urb(wacom->irq, dev, 544 usb_fill_int_urb(wacom->irq, dev,
697 usb_rcvintpipe(dev, endpoint->bEndpointAddress), 545 usb_rcvintpipe(dev, endpoint->bEndpointAddress),
@@ -700,7 +548,7 @@ static int wacom_probe(struct usb_interface *intf, const struct usb_device_id *i
700 wacom->irq->transfer_dma = wacom->data_dma; 548 wacom->irq->transfer_dma = wacom->data_dma;
701 wacom->irq->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; 549 wacom->irq->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
702 550
703 error = input_register_device(wacom->dev); 551 error = input_register_device(input_dev);
704 if (error) 552 if (error)
705 goto fail4; 553 goto fail4;
706 554
@@ -725,7 +573,7 @@ static void wacom_disconnect(struct usb_interface *intf)
725 usb_set_intfdata(intf, NULL); 573 usb_set_intfdata(intf, NULL);
726 574
727 usb_kill_urb(wacom->irq); 575 usb_kill_urb(wacom->irq);
728 input_unregister_device(wacom->dev); 576 input_unregister_device(wacom->wacom_wac.input);
729 usb_free_urb(wacom->irq); 577 usb_free_urb(wacom->irq);
730 usb_buffer_free(interface_to_usbdev(intf), WACOM_PKGLEN_MAX, 578 usb_buffer_free(interface_to_usbdev(intf), WACOM_PKGLEN_MAX,
731 wacom->wacom_wac.data, wacom->data_dma); 579 wacom->wacom_wac.data, wacom->data_dma);
diff --git a/drivers/input/tablet/wacom_wac.c b/drivers/input/tablet/wacom_wac.c
index 4da32d0159f..9cf4854a981 100644
--- a/drivers/input/tablet/wacom_wac.c
+++ b/drivers/input/tablet/wacom_wac.c
@@ -18,39 +18,43 @@
18static int wacom_penpartner_irq(struct wacom_wac *wacom, void *wcombo) 18static int wacom_penpartner_irq(struct wacom_wac *wacom, void *wcombo)
19{ 19{
20 unsigned char *data = wacom->data; 20 unsigned char *data = wacom->data;
21 struct input_dev *input = wacom->input;
21 22
22 switch (data[0]) { 23 switch (data[0]) {
23 case 1: 24 case 1:
24 if (data[5] & 0x80) { 25 if (data[5] & 0x80) {
25 wacom->tool[0] = (data[5] & 0x20) ? BTN_TOOL_RUBBER : BTN_TOOL_PEN; 26 wacom->tool[0] = (data[5] & 0x20) ? BTN_TOOL_RUBBER : BTN_TOOL_PEN;
26 wacom->id[0] = (data[5] & 0x20) ? ERASER_DEVICE_ID : STYLUS_DEVICE_ID; 27 wacom->id[0] = (data[5] & 0x20) ? ERASER_DEVICE_ID : STYLUS_DEVICE_ID;
27 wacom_report_key(wcombo, wacom->tool[0], 1); 28 input_report_key(input, wacom->tool[0], 1);
28 wacom_report_abs(wcombo, ABS_MISC, wacom->id[0]); /* report tool id */ 29 input_report_abs(input, ABS_MISC, wacom->id[0]); /* report tool id */
29 wacom_report_abs(wcombo, ABS_X, wacom_le16_to_cpu(&data[1])); 30 input_report_abs(input, ABS_X, wacom_le16_to_cpu(&data[1]));
30 wacom_report_abs(wcombo, ABS_Y, wacom_le16_to_cpu(&data[3])); 31 input_report_abs(input, ABS_Y, wacom_le16_to_cpu(&data[3]));
31 wacom_report_abs(wcombo, ABS_PRESSURE, (signed char)data[6] + 127); 32 input_report_abs(input, ABS_PRESSURE, (signed char)data[6] + 127);
32 wacom_report_key(wcombo, BTN_TOUCH, ((signed char)data[6] > -127)); 33 input_report_key(input, BTN_TOUCH, ((signed char)data[6] > -127));
33 wacom_report_key(wcombo, BTN_STYLUS, (data[5] & 0x40)); 34 input_report_key(input, BTN_STYLUS, (data[5] & 0x40));
34 } else { 35 } else {
35 wacom_report_key(wcombo, wacom->tool[0], 0); 36 input_report_key(input, wacom->tool[0], 0);
36 wacom_report_abs(wcombo, ABS_MISC, 0); /* report tool id */ 37 input_report_abs(input, ABS_MISC, 0); /* report tool id */
37 wacom_report_abs(wcombo, ABS_PRESSURE, -1); 38 input_report_abs(input, ABS_PRESSURE, -1);
38 wacom_report_key(wcombo, BTN_TOUCH, 0); 39 input_report_key(input, BTN_TOUCH, 0);
39 } 40 }
40 break; 41 break;
42
41 case 2: 43 case 2:
42 wacom_report_key(wcombo, BTN_TOOL_PEN, 1); 44 input_report_key(input, BTN_TOOL_PEN, 1);
43 wacom_report_abs(wcombo, ABS_MISC, STYLUS_DEVICE_ID); /* report tool id */ 45 input_report_abs(input, ABS_MISC, STYLUS_DEVICE_ID); /* report tool id */
44 wacom_report_abs(wcombo, ABS_X, wacom_le16_to_cpu(&data[1])); 46 input_report_abs(input, ABS_X, wacom_le16_to_cpu(&data[1]));
45 wacom_report_abs(wcombo, ABS_Y, wacom_le16_to_cpu(&data[3])); 47 input_report_abs(input, ABS_Y, wacom_le16_to_cpu(&data[3]));
46 wacom_report_abs(wcombo, ABS_PRESSURE, (signed char)data[6] + 127); 48 input_report_abs(input, ABS_PRESSURE, (signed char)data[6] + 127);
47 wacom_report_key(wcombo, BTN_TOUCH, ((signed char)data[6] > -80) && !(data[5] & 0x20)); 49 input_report_key(input, BTN_TOUCH, ((signed char)data[6] > -80) && !(data[5] & 0x20));
48 wacom_report_key(wcombo, BTN_STYLUS, (data[5] & 0x40)); 50 input_report_key(input, BTN_STYLUS, (data[5] & 0x40));
49 break; 51 break;
52
50 default: 53 default:
51 printk(KERN_INFO "wacom_penpartner_irq: received unknown report #%d\n", data[0]); 54 printk(KERN_INFO "wacom_penpartner_irq: received unknown report #%d\n", data[0]);
52 return 0; 55 return 0;
53 } 56 }
57
54 return 1; 58 return 1;
55} 59}
56 60
@@ -58,6 +62,7 @@ static int wacom_pl_irq(struct wacom_wac *wacom, void *wcombo)
58{ 62{
59 struct wacom_features *features = &wacom->features; 63 struct wacom_features *features = &wacom->features;
60 unsigned char *data = wacom->data; 64 unsigned char *data = wacom->data;
65 struct input_dev *input = wacom->input;
61 int prox, pressure; 66 int prox, pressure;
62 67
63 if (data[0] != WACOM_REPORT_PENABLED) { 68 if (data[0] != WACOM_REPORT_PENABLED) {
@@ -91,8 +96,8 @@ static int wacom_pl_irq(struct wacom_wac *wacom, void *wcombo)
91 /* was entered with stylus2 pressed */ 96 /* was entered with stylus2 pressed */
92 if (wacom->tool[1] == BTN_TOOL_RUBBER && !(data[4] & 0x20)) { 97 if (wacom->tool[1] == BTN_TOOL_RUBBER && !(data[4] & 0x20)) {
93 /* report out proximity for previous tool */ 98 /* report out proximity for previous tool */
94 wacom_report_key(wcombo, wacom->tool[1], 0); 99 input_report_key(input, wacom->tool[1], 0);
95 wacom_input_sync(wcombo); 100 input_sync(input);
96 wacom->tool[1] = BTN_TOOL_PEN; 101 wacom->tool[1] = BTN_TOOL_PEN;
97 return 0; 102 return 0;
98 } 103 }
@@ -102,23 +107,23 @@ static int wacom_pl_irq(struct wacom_wac *wacom, void *wcombo)
102 wacom->tool[1] = BTN_TOOL_PEN; 107 wacom->tool[1] = BTN_TOOL_PEN;
103 wacom->id[0] = STYLUS_DEVICE_ID; 108 wacom->id[0] = STYLUS_DEVICE_ID;
104 } 109 }
105 wacom_report_key(wcombo, wacom->tool[1], prox); /* report in proximity for tool */ 110 input_report_key(input, wacom->tool[1], prox); /* report in proximity for tool */
106 wacom_report_abs(wcombo, ABS_MISC, wacom->id[0]); /* report tool id */ 111 input_report_abs(input, ABS_MISC, wacom->id[0]); /* report tool id */
107 wacom_report_abs(wcombo, ABS_X, data[3] | (data[2] << 7) | ((data[1] & 0x03) << 14)); 112 input_report_abs(input, ABS_X, data[3] | (data[2] << 7) | ((data[1] & 0x03) << 14));
108 wacom_report_abs(wcombo, ABS_Y, data[6] | (data[5] << 7) | ((data[4] & 0x03) << 14)); 113 input_report_abs(input, ABS_Y, data[6] | (data[5] << 7) | ((data[4] & 0x03) << 14));
109 wacom_report_abs(wcombo, ABS_PRESSURE, pressure); 114 input_report_abs(input, ABS_PRESSURE, pressure);
110 115
111 wacom_report_key(wcombo, BTN_TOUCH, data[4] & 0x08); 116 input_report_key(input, BTN_TOUCH, data[4] & 0x08);
112 wacom_report_key(wcombo, BTN_STYLUS, data[4] & 0x10); 117 input_report_key(input, BTN_STYLUS, data[4] & 0x10);
113 /* Only allow the stylus2 button to be reported for the pen tool. */ 118 /* Only allow the stylus2 button to be reported for the pen tool. */
114 wacom_report_key(wcombo, BTN_STYLUS2, (wacom->tool[1] == BTN_TOOL_PEN) && (data[4] & 0x20)); 119 input_report_key(input, BTN_STYLUS2, (wacom->tool[1] == BTN_TOOL_PEN) && (data[4] & 0x20));
115 } else { 120 } else {
116 /* report proximity-out of a (valid) tool */ 121 /* report proximity-out of a (valid) tool */
117 if (wacom->tool[1] != BTN_TOOL_RUBBER) { 122 if (wacom->tool[1] != BTN_TOOL_RUBBER) {
118 /* Unknown tool selected default to pen tool */ 123 /* Unknown tool selected default to pen tool */
119 wacom->tool[1] = BTN_TOOL_PEN; 124 wacom->tool[1] = BTN_TOOL_PEN;
120 } 125 }
121 wacom_report_key(wcombo, wacom->tool[1], prox); 126 input_report_key(input, wacom->tool[1], prox);
122 } 127 }
123 128
124 wacom->tool[0] = prox; /* Save proximity state */ 129 wacom->tool[0] = prox; /* Save proximity state */
@@ -128,6 +133,7 @@ static int wacom_pl_irq(struct wacom_wac *wacom, void *wcombo)
128static int wacom_ptu_irq(struct wacom_wac *wacom, void *wcombo) 133static int wacom_ptu_irq(struct wacom_wac *wacom, void *wcombo)
129{ 134{
130 unsigned char *data = wacom->data; 135 unsigned char *data = wacom->data;
136 struct input_dev *input = wacom->input;
131 137
132 if (data[0] != WACOM_REPORT_PENABLED) { 138 if (data[0] != WACOM_REPORT_PENABLED) {
133 printk(KERN_INFO "wacom_ptu_irq: received unknown report #%d\n", data[0]); 139 printk(KERN_INFO "wacom_ptu_irq: received unknown report #%d\n", data[0]);
@@ -135,20 +141,20 @@ static int wacom_ptu_irq(struct wacom_wac *wacom, void *wcombo)
135 } 141 }
136 142
137 if (data[1] & 0x04) { 143 if (data[1] & 0x04) {
138 wacom_report_key(wcombo, BTN_TOOL_RUBBER, data[1] & 0x20); 144 input_report_key(input, BTN_TOOL_RUBBER, data[1] & 0x20);
139 wacom_report_key(wcombo, BTN_TOUCH, data[1] & 0x08); 145 input_report_key(input, BTN_TOUCH, data[1] & 0x08);
140 wacom->id[0] = ERASER_DEVICE_ID; 146 wacom->id[0] = ERASER_DEVICE_ID;
141 } else { 147 } else {
142 wacom_report_key(wcombo, BTN_TOOL_PEN, data[1] & 0x20); 148 input_report_key(input, BTN_TOOL_PEN, data[1] & 0x20);
143 wacom_report_key(wcombo, BTN_TOUCH, data[1] & 0x01); 149 input_report_key(input, BTN_TOUCH, data[1] & 0x01);
144 wacom->id[0] = STYLUS_DEVICE_ID; 150 wacom->id[0] = STYLUS_DEVICE_ID;
145 } 151 }
146 wacom_report_abs(wcombo, ABS_MISC, wacom->id[0]); /* report tool id */ 152 input_report_abs(input, ABS_MISC, wacom->id[0]); /* report tool id */
147 wacom_report_abs(wcombo, ABS_X, wacom_le16_to_cpu(&data[2])); 153 input_report_abs(input, ABS_X, wacom_le16_to_cpu(&data[2]));
148 wacom_report_abs(wcombo, ABS_Y, wacom_le16_to_cpu(&data[4])); 154 input_report_abs(input, ABS_Y, wacom_le16_to_cpu(&data[4]));
149 wacom_report_abs(wcombo, ABS_PRESSURE, wacom_le16_to_cpu(&data[6])); 155 input_report_abs(input, ABS_PRESSURE, wacom_le16_to_cpu(&data[6]));
150 wacom_report_key(wcombo, BTN_STYLUS, data[1] & 0x02); 156 input_report_key(input, BTN_STYLUS, data[1] & 0x02);
151 wacom_report_key(wcombo, BTN_STYLUS2, data[1] & 0x10); 157 input_report_key(input, BTN_STYLUS2, data[1] & 0x10);
152 return 1; 158 return 1;
153} 159}
154 160
@@ -156,6 +162,7 @@ static int wacom_graphire_irq(struct wacom_wac *wacom, void *wcombo)
156{ 162{
157 struct wacom_features *features = &wacom->features; 163 struct wacom_features *features = &wacom->features;
158 unsigned char *data = wacom->data; 164 unsigned char *data = wacom->data;
165 struct input_dev *input = wacom->input;
159 int x, y, prox; 166 int x, y, prox;
160 int rw = 0; 167 int rw = 0;
161 int retval = 0; 168 int retval = 0;
@@ -181,7 +188,7 @@ static int wacom_graphire_irq(struct wacom_wac *wacom, void *wcombo)
181 break; 188 break;
182 189
183 case 2: /* Mouse with wheel */ 190 case 2: /* Mouse with wheel */
184 wacom_report_key(wcombo, BTN_MIDDLE, data[1] & 0x04); 191 input_report_key(input, BTN_MIDDLE, data[1] & 0x04);
185 /* fall through */ 192 /* fall through */
186 193
187 case 3: /* Mouse without wheel */ 194 case 3: /* Mouse without wheel */
@@ -192,32 +199,32 @@ static int wacom_graphire_irq(struct wacom_wac *wacom, void *wcombo)
192 } 199 }
193 x = wacom_le16_to_cpu(&data[2]); 200 x = wacom_le16_to_cpu(&data[2]);
194 y = wacom_le16_to_cpu(&data[4]); 201 y = wacom_le16_to_cpu(&data[4]);
195 wacom_report_abs(wcombo, ABS_X, x); 202 input_report_abs(input, ABS_X, x);
196 wacom_report_abs(wcombo, ABS_Y, y); 203 input_report_abs(input, ABS_Y, y);
197 if (wacom->tool[0] != BTN_TOOL_MOUSE) { 204 if (wacom->tool[0] != BTN_TOOL_MOUSE) {
198 wacom_report_abs(wcombo, ABS_PRESSURE, data[6] | ((data[7] & 0x01) << 8)); 205 input_report_abs(input, ABS_PRESSURE, data[6] | ((data[7] & 0x01) << 8));
199 wacom_report_key(wcombo, BTN_TOUCH, data[1] & 0x01); 206 input_report_key(input, BTN_TOUCH, data[1] & 0x01);
200 wacom_report_key(wcombo, BTN_STYLUS, data[1] & 0x02); 207 input_report_key(input, BTN_STYLUS, data[1] & 0x02);
201 wacom_report_key(wcombo, BTN_STYLUS2, data[1] & 0x04); 208 input_report_key(input, BTN_STYLUS2, data[1] & 0x04);
202 } else { 209 } else {
203 wacom_report_key(wcombo, BTN_LEFT, data[1] & 0x01); 210 input_report_key(input, BTN_LEFT, data[1] & 0x01);
204 wacom_report_key(wcombo, BTN_RIGHT, data[1] & 0x02); 211 input_report_key(input, BTN_RIGHT, data[1] & 0x02);
205 if (features->type == WACOM_G4 || 212 if (features->type == WACOM_G4 ||
206 features->type == WACOM_MO) { 213 features->type == WACOM_MO) {
207 wacom_report_abs(wcombo, ABS_DISTANCE, data[6] & 0x3f); 214 input_report_abs(input, ABS_DISTANCE, data[6] & 0x3f);
208 rw = (signed)(data[7] & 0x04) - (data[7] & 0x03); 215 rw = (signed)(data[7] & 0x04) - (data[7] & 0x03);
209 } else { 216 } else {
210 wacom_report_abs(wcombo, ABS_DISTANCE, data[7] & 0x3f); 217 input_report_abs(input, ABS_DISTANCE, data[7] & 0x3f);
211 rw = -(signed)data[6]; 218 rw = -(signed)data[6];
212 } 219 }
213 wacom_report_rel(wcombo, REL_WHEEL, rw); 220 input_report_rel(input, REL_WHEEL, rw);
214 } 221 }
215 222
216 if (!prox) 223 if (!prox)
217 wacom->id[0] = 0; 224 wacom->id[0] = 0;
218 wacom_report_abs(wcombo, ABS_MISC, wacom->id[0]); /* report tool id */ 225 input_report_abs(input, ABS_MISC, wacom->id[0]); /* report tool id */
219 wacom_report_key(wcombo, wacom->tool[0], prox); 226 input_report_key(input, wacom->tool[0], prox);
220 wacom_input_sync(wcombo); /* sync last event */ 227 input_sync(input); /* sync last event */
221 } 228 }
222 229
223 /* send pad data */ 230 /* send pad data */
@@ -226,16 +233,16 @@ static int wacom_graphire_irq(struct wacom_wac *wacom, void *wcombo)
226 prox = data[7] & 0xf8; 233 prox = data[7] & 0xf8;
227 if (prox || wacom->id[1]) { 234 if (prox || wacom->id[1]) {
228 wacom->id[1] = PAD_DEVICE_ID; 235 wacom->id[1] = PAD_DEVICE_ID;
229 wacom_report_key(wcombo, BTN_0, (data[7] & 0x40)); 236 input_report_key(input, BTN_0, (data[7] & 0x40));
230 wacom_report_key(wcombo, BTN_4, (data[7] & 0x80)); 237 input_report_key(input, BTN_4, (data[7] & 0x80));
231 rw = ((data[7] & 0x18) >> 3) - ((data[7] & 0x20) >> 3); 238 rw = ((data[7] & 0x18) >> 3) - ((data[7] & 0x20) >> 3);
232 wacom_report_rel(wcombo, REL_WHEEL, rw); 239 input_report_rel(input, REL_WHEEL, rw);
233 wacom_report_key(wcombo, BTN_TOOL_FINGER, 0xf0); 240 input_report_key(input, BTN_TOOL_FINGER, 0xf0);
234 wacom_report_abs(wcombo, ABS_MISC, wacom->id[1]); 241 input_report_abs(input, ABS_MISC, wacom->id[1]);
235 if (!prox) 242 if (!prox)
236 wacom->id[1] = 0; 243 wacom->id[1] = 0;
237 wacom_report_abs(wcombo, ABS_MISC, wacom->id[1]); 244 input_report_abs(input, ABS_MISC, wacom->id[1]);
238 wacom_input_event(wcombo, EV_MSC, MSC_SERIAL, 0xf0); 245 input_event(input, EV_MSC, MSC_SERIAL, 0xf0);
239 } 246 }
240 retval = 1; 247 retval = 1;
241 break; 248 break;
@@ -244,16 +251,16 @@ static int wacom_graphire_irq(struct wacom_wac *wacom, void *wcombo)
244 prox = (data[7] & 0xf8) || data[8]; 251 prox = (data[7] & 0xf8) || data[8];
245 if (prox || wacom->id[1]) { 252 if (prox || wacom->id[1]) {
246 wacom->id[1] = PAD_DEVICE_ID; 253 wacom->id[1] = PAD_DEVICE_ID;
247 wacom_report_key(wcombo, BTN_0, (data[7] & 0x08)); 254 input_report_key(input, BTN_0, (data[7] & 0x08));
248 wacom_report_key(wcombo, BTN_1, (data[7] & 0x20)); 255 input_report_key(input, BTN_1, (data[7] & 0x20));
249 wacom_report_key(wcombo, BTN_4, (data[7] & 0x10)); 256 input_report_key(input, BTN_4, (data[7] & 0x10));
250 wacom_report_key(wcombo, BTN_5, (data[7] & 0x40)); 257 input_report_key(input, BTN_5, (data[7] & 0x40));
251 wacom_report_abs(wcombo, ABS_WHEEL, (data[8] & 0x7f)); 258 input_report_abs(input, ABS_WHEEL, (data[8] & 0x7f));
252 wacom_report_key(wcombo, BTN_TOOL_FINGER, 0xf0); 259 input_report_key(input, BTN_TOOL_FINGER, 0xf0);
253 if (!prox) 260 if (!prox)
254 wacom->id[1] = 0; 261 wacom->id[1] = 0;
255 wacom_report_abs(wcombo, ABS_MISC, wacom->id[1]); 262 input_report_abs(input, ABS_MISC, wacom->id[1]);
256 wacom_input_event(wcombo, EV_MSC, MSC_SERIAL, 0xf0); 263 input_event(input, EV_MSC, MSC_SERIAL, 0xf0);
257 } 264 }
258 retval = 1; 265 retval = 1;
259 break; 266 break;
@@ -266,6 +273,7 @@ static int wacom_intuos_inout(struct wacom_wac *wacom, void *wcombo)
266{ 273{
267 struct wacom_features *features = &wacom->features; 274 struct wacom_features *features = &wacom->features;
268 unsigned char *data = wacom->data; 275 unsigned char *data = wacom->data;
276 struct input_dev *input = wacom->input;
269 int idx = 0; 277 int idx = 0;
270 278
271 /* tool number */ 279 /* tool number */
@@ -357,31 +365,31 @@ static int wacom_intuos_inout(struct wacom_wac *wacom, void *wcombo)
357 * Reset all states otherwise we lose the initial states 365 * Reset all states otherwise we lose the initial states
358 * when in-prox next time 366 * when in-prox next time
359 */ 367 */
360 wacom_report_abs(wcombo, ABS_X, 0); 368 input_report_abs(input, ABS_X, 0);
361 wacom_report_abs(wcombo, ABS_Y, 0); 369 input_report_abs(input, ABS_Y, 0);
362 wacom_report_abs(wcombo, ABS_DISTANCE, 0); 370 input_report_abs(input, ABS_DISTANCE, 0);
363 wacom_report_abs(wcombo, ABS_TILT_X, 0); 371 input_report_abs(input, ABS_TILT_X, 0);
364 wacom_report_abs(wcombo, ABS_TILT_Y, 0); 372 input_report_abs(input, ABS_TILT_Y, 0);
365 if (wacom->tool[idx] >= BTN_TOOL_MOUSE) { 373 if (wacom->tool[idx] >= BTN_TOOL_MOUSE) {
366 wacom_report_key(wcombo, BTN_LEFT, 0); 374 input_report_key(input, BTN_LEFT, 0);
367 wacom_report_key(wcombo, BTN_MIDDLE, 0); 375 input_report_key(input, BTN_MIDDLE, 0);
368 wacom_report_key(wcombo, BTN_RIGHT, 0); 376 input_report_key(input, BTN_RIGHT, 0);
369 wacom_report_key(wcombo, BTN_SIDE, 0); 377 input_report_key(input, BTN_SIDE, 0);
370 wacom_report_key(wcombo, BTN_EXTRA, 0); 378 input_report_key(input, BTN_EXTRA, 0);
371 wacom_report_abs(wcombo, ABS_THROTTLE, 0); 379 input_report_abs(input, ABS_THROTTLE, 0);
372 wacom_report_abs(wcombo, ABS_RZ, 0); 380 input_report_abs(input, ABS_RZ, 0);
373 } else { 381 } else {
374 wacom_report_abs(wcombo, ABS_PRESSURE, 0); 382 input_report_abs(input, ABS_PRESSURE, 0);
375 wacom_report_key(wcombo, BTN_STYLUS, 0); 383 input_report_key(input, BTN_STYLUS, 0);
376 wacom_report_key(wcombo, BTN_STYLUS2, 0); 384 input_report_key(input, BTN_STYLUS2, 0);
377 wacom_report_key(wcombo, BTN_TOUCH, 0); 385 input_report_key(input, BTN_TOUCH, 0);
378 wacom_report_abs(wcombo, ABS_WHEEL, 0); 386 input_report_abs(input, ABS_WHEEL, 0);
379 if (features->type >= INTUOS3S) 387 if (features->type >= INTUOS3S)
380 wacom_report_abs(wcombo, ABS_Z, 0); 388 input_report_abs(input, ABS_Z, 0);
381 } 389 }
382 wacom_report_key(wcombo, wacom->tool[idx], 0); 390 input_report_key(input, wacom->tool[idx], 0);
383 wacom_report_abs(wcombo, ABS_MISC, 0); /* reset tool id */ 391 input_report_abs(input, ABS_MISC, 0); /* reset tool id */
384 wacom_input_event(wcombo, EV_MSC, MSC_SERIAL, wacom->serial[idx]); 392 input_event(input, EV_MSC, MSC_SERIAL, wacom->serial[idx]);
385 wacom->id[idx] = 0; 393 wacom->id[idx] = 0;
386 return 2; 394 return 2;
387 } 395 }
@@ -392,6 +400,7 @@ static void wacom_intuos_general(struct wacom_wac *wacom, void *wcombo)
392{ 400{
393 struct wacom_features *features = &wacom->features; 401 struct wacom_features *features = &wacom->features;
394 unsigned char *data = wacom->data; 402 unsigned char *data = wacom->data;
403 struct input_dev *input = wacom->input;
395 unsigned int t; 404 unsigned int t;
396 405
397 /* general pen packet */ 406 /* general pen packet */
@@ -399,22 +408,22 @@ static void wacom_intuos_general(struct wacom_wac *wacom, void *wcombo)
399 t = (data[6] << 2) | ((data[7] >> 6) & 3); 408 t = (data[6] << 2) | ((data[7] >> 6) & 3);
400 if (features->type >= INTUOS4S && features->type <= INTUOS4L) 409 if (features->type >= INTUOS4S && features->type <= INTUOS4L)
401 t = (t << 1) | (data[1] & 1); 410 t = (t << 1) | (data[1] & 1);
402 wacom_report_abs(wcombo, ABS_PRESSURE, t); 411 input_report_abs(input, ABS_PRESSURE, t);
403 wacom_report_abs(wcombo, ABS_TILT_X, 412 input_report_abs(input, ABS_TILT_X,
404 ((data[7] << 1) & 0x7e) | (data[8] >> 7)); 413 ((data[7] << 1) & 0x7e) | (data[8] >> 7));
405 wacom_report_abs(wcombo, ABS_TILT_Y, data[8] & 0x7f); 414 input_report_abs(input, ABS_TILT_Y, data[8] & 0x7f);
406 wacom_report_key(wcombo, BTN_STYLUS, data[1] & 2); 415 input_report_key(input, BTN_STYLUS, data[1] & 2);
407 wacom_report_key(wcombo, BTN_STYLUS2, data[1] & 4); 416 input_report_key(input, BTN_STYLUS2, data[1] & 4);
408 wacom_report_key(wcombo, BTN_TOUCH, t > 10); 417 input_report_key(input, BTN_TOUCH, t > 10);
409 } 418 }
410 419
411 /* airbrush second packet */ 420 /* airbrush second packet */
412 if ((data[1] & 0xbc) == 0xb4) { 421 if ((data[1] & 0xbc) == 0xb4) {
413 wacom_report_abs(wcombo, ABS_WHEEL, 422 input_report_abs(input, ABS_WHEEL,
414 (data[6] << 2) | ((data[7] >> 6) & 3)); 423 (data[6] << 2) | ((data[7] >> 6) & 3));
415 wacom_report_abs(wcombo, ABS_TILT_X, 424 input_report_abs(input, ABS_TILT_X,
416 ((data[7] << 1) & 0x7e) | (data[8] >> 7)); 425 ((data[7] << 1) & 0x7e) | (data[8] >> 7));
417 wacom_report_abs(wcombo, ABS_TILT_Y, data[8] & 0x7f); 426 input_report_abs(input, ABS_TILT_Y, data[8] & 0x7f);
418 } 427 }
419} 428}
420 429
@@ -422,6 +431,7 @@ static int wacom_intuos_irq(struct wacom_wac *wacom, void *wcombo)
422{ 431{
423 struct wacom_features *features = &wacom->features; 432 struct wacom_features *features = &wacom->features;
424 unsigned char *data = wacom->data; 433 unsigned char *data = wacom->data;
434 struct input_dev *input = wacom->input;
425 unsigned int t; 435 unsigned int t;
426 int idx = 0, result; 436 int idx = 0, result;
427 437
@@ -442,54 +452,54 @@ static int wacom_intuos_irq(struct wacom_wac *wacom, void *wcombo)
442 wacom->tool[1] = BTN_TOOL_FINGER; 452 wacom->tool[1] = BTN_TOOL_FINGER;
443 453
444 if (features->type >= INTUOS4S && features->type <= INTUOS4L) { 454 if (features->type >= INTUOS4S && features->type <= INTUOS4L) {
445 wacom_report_key(wcombo, BTN_0, (data[2] & 0x01)); 455 input_report_key(input, BTN_0, (data[2] & 0x01));
446 wacom_report_key(wcombo, BTN_1, (data[3] & 0x01)); 456 input_report_key(input, BTN_1, (data[3] & 0x01));
447 wacom_report_key(wcombo, BTN_2, (data[3] & 0x02)); 457 input_report_key(input, BTN_2, (data[3] & 0x02));
448 wacom_report_key(wcombo, BTN_3, (data[3] & 0x04)); 458 input_report_key(input, BTN_3, (data[3] & 0x04));
449 wacom_report_key(wcombo, BTN_4, (data[3] & 0x08)); 459 input_report_key(input, BTN_4, (data[3] & 0x08));
450 wacom_report_key(wcombo, BTN_5, (data[3] & 0x10)); 460 input_report_key(input, BTN_5, (data[3] & 0x10));
451 wacom_report_key(wcombo, BTN_6, (data[3] & 0x20)); 461 input_report_key(input, BTN_6, (data[3] & 0x20));
452 if (data[1] & 0x80) { 462 if (data[1] & 0x80) {
453 wacom_report_abs(wcombo, ABS_WHEEL, (data[1] & 0x7f)); 463 input_report_abs(input, ABS_WHEEL, (data[1] & 0x7f));
454 } else { 464 } else {
455 /* Out of proximity, clear wheel value. */ 465 /* Out of proximity, clear wheel value. */
456 wacom_report_abs(wcombo, ABS_WHEEL, 0); 466 input_report_abs(input, ABS_WHEEL, 0);
457 } 467 }
458 if (features->type != INTUOS4S) { 468 if (features->type != INTUOS4S) {
459 wacom_report_key(wcombo, BTN_7, (data[3] & 0x40)); 469 input_report_key(input, BTN_7, (data[3] & 0x40));
460 wacom_report_key(wcombo, BTN_8, (data[3] & 0x80)); 470 input_report_key(input, BTN_8, (data[3] & 0x80));
461 } 471 }
462 if (data[1] | (data[2] & 0x01) | data[3]) { 472 if (data[1] | (data[2] & 0x01) | data[3]) {
463 wacom_report_key(wcombo, wacom->tool[1], 1); 473 input_report_key(input, wacom->tool[1], 1);
464 wacom_report_abs(wcombo, ABS_MISC, PAD_DEVICE_ID); 474 input_report_abs(input, ABS_MISC, PAD_DEVICE_ID);
465 } else { 475 } else {
466 wacom_report_key(wcombo, wacom->tool[1], 0); 476 input_report_key(input, wacom->tool[1], 0);
467 wacom_report_abs(wcombo, ABS_MISC, 0); 477 input_report_abs(input, ABS_MISC, 0);
468 } 478 }
469 } else { 479 } else {
470 wacom_report_key(wcombo, BTN_0, (data[5] & 0x01)); 480 input_report_key(input, BTN_0, (data[5] & 0x01));
471 wacom_report_key(wcombo, BTN_1, (data[5] & 0x02)); 481 input_report_key(input, BTN_1, (data[5] & 0x02));
472 wacom_report_key(wcombo, BTN_2, (data[5] & 0x04)); 482 input_report_key(input, BTN_2, (data[5] & 0x04));
473 wacom_report_key(wcombo, BTN_3, (data[5] & 0x08)); 483 input_report_key(input, BTN_3, (data[5] & 0x08));
474 wacom_report_key(wcombo, BTN_4, (data[6] & 0x01)); 484 input_report_key(input, BTN_4, (data[6] & 0x01));
475 wacom_report_key(wcombo, BTN_5, (data[6] & 0x02)); 485 input_report_key(input, BTN_5, (data[6] & 0x02));
476 wacom_report_key(wcombo, BTN_6, (data[6] & 0x04)); 486 input_report_key(input, BTN_6, (data[6] & 0x04));
477 wacom_report_key(wcombo, BTN_7, (data[6] & 0x08)); 487 input_report_key(input, BTN_7, (data[6] & 0x08));
478 wacom_report_key(wcombo, BTN_8, (data[5] & 0x10)); 488 input_report_key(input, BTN_8, (data[5] & 0x10));
479 wacom_report_key(wcombo, BTN_9, (data[6] & 0x10)); 489 input_report_key(input, BTN_9, (data[6] & 0x10));
480 wacom_report_abs(wcombo, ABS_RX, ((data[1] & 0x1f) << 8) | data[2]); 490 input_report_abs(input, ABS_RX, ((data[1] & 0x1f) << 8) | data[2]);
481 wacom_report_abs(wcombo, ABS_RY, ((data[3] & 0x1f) << 8) | data[4]); 491 input_report_abs(input, ABS_RY, ((data[3] & 0x1f) << 8) | data[4]);
482 492
483 if ((data[5] & 0x1f) | (data[6] & 0x1f) | (data[1] & 0x1f) | 493 if ((data[5] & 0x1f) | (data[6] & 0x1f) | (data[1] & 0x1f) |
484 data[2] | (data[3] & 0x1f) | data[4]) { 494 data[2] | (data[3] & 0x1f) | data[4]) {
485 wacom_report_key(wcombo, wacom->tool[1], 1); 495 input_report_key(input, wacom->tool[1], 1);
486 wacom_report_abs(wcombo, ABS_MISC, PAD_DEVICE_ID); 496 input_report_abs(input, ABS_MISC, PAD_DEVICE_ID);
487 } else { 497 } else {
488 wacom_report_key(wcombo, wacom->tool[1], 0); 498 input_report_key(input, wacom->tool[1], 0);
489 wacom_report_abs(wcombo, ABS_MISC, 0); 499 input_report_abs(input, ABS_MISC, 0);
490 } 500 }
491 } 501 }
492 wacom_input_event(wcombo, EV_MSC, MSC_SERIAL, 0xffffffff); 502 input_event(input, EV_MSC, MSC_SERIAL, 0xffffffff);
493 return 1; 503 return 1;
494 } 504 }
495 505
@@ -517,13 +527,13 @@ static int wacom_intuos_irq(struct wacom_wac *wacom, void *wcombo)
517 return 0; 527 return 0;
518 528
519 if (features->type >= INTUOS3S) { 529 if (features->type >= INTUOS3S) {
520 wacom_report_abs(wcombo, ABS_X, (data[2] << 9) | (data[3] << 1) | ((data[9] >> 1) & 1)); 530 input_report_abs(input, ABS_X, (data[2] << 9) | (data[3] << 1) | ((data[9] >> 1) & 1));
521 wacom_report_abs(wcombo, ABS_Y, (data[4] << 9) | (data[5] << 1) | (data[9] & 1)); 531 input_report_abs(input, ABS_Y, (data[4] << 9) | (data[5] << 1) | (data[9] & 1));
522 wacom_report_abs(wcombo, ABS_DISTANCE, ((data[9] >> 2) & 0x3f)); 532 input_report_abs(input, ABS_DISTANCE, ((data[9] >> 2) & 0x3f));
523 } else { 533 } else {
524 wacom_report_abs(wcombo, ABS_X, wacom_be16_to_cpu(&data[2])); 534 input_report_abs(input, ABS_X, wacom_be16_to_cpu(&data[2]));
525 wacom_report_abs(wcombo, ABS_Y, wacom_be16_to_cpu(&data[4])); 535 input_report_abs(input, ABS_Y, wacom_be16_to_cpu(&data[4]));
526 wacom_report_abs(wcombo, ABS_DISTANCE, ((data[9] >> 3) & 0x1f)); 536 input_report_abs(input, ABS_DISTANCE, ((data[9] >> 3) & 0x1f));
527 } 537 }
528 538
529 /* process general packets */ 539 /* process general packets */
@@ -539,102 +549,106 @@ static int wacom_intuos_irq(struct wacom_wac *wacom, void *wcombo)
539 t = (data[6] << 3) | ((data[7] >> 5) & 7); 549 t = (data[6] << 3) | ((data[7] >> 5) & 7);
540 t = (data[7] & 0x20) ? ((t > 900) ? ((t-1) / 2 - 1350) : 550 t = (data[7] & 0x20) ? ((t > 900) ? ((t-1) / 2 - 1350) :
541 ((t-1) / 2 + 450)) : (450 - t / 2) ; 551 ((t-1) / 2 + 450)) : (450 - t / 2) ;
542 wacom_report_abs(wcombo, ABS_Z, t); 552 input_report_abs(input, ABS_Z, t);
543 } else { 553 } else {
544 /* 4D mouse rotation packet */ 554 /* 4D mouse rotation packet */
545 t = (data[6] << 3) | ((data[7] >> 5) & 7); 555 t = (data[6] << 3) | ((data[7] >> 5) & 7);
546 wacom_report_abs(wcombo, ABS_RZ, (data[7] & 0x20) ? 556 input_report_abs(input, ABS_RZ, (data[7] & 0x20) ?
547 ((t - 1) / 2) : -t / 2); 557 ((t - 1) / 2) : -t / 2);
548 } 558 }
549 559
550 } else if (!(data[1] & 0x10) && features->type < INTUOS3S) { 560 } else if (!(data[1] & 0x10) && features->type < INTUOS3S) {
551 /* 4D mouse packet */ 561 /* 4D mouse packet */
552 wacom_report_key(wcombo, BTN_LEFT, data[8] & 0x01); 562 input_report_key(input, BTN_LEFT, data[8] & 0x01);
553 wacom_report_key(wcombo, BTN_MIDDLE, data[8] & 0x02); 563 input_report_key(input, BTN_MIDDLE, data[8] & 0x02);
554 wacom_report_key(wcombo, BTN_RIGHT, data[8] & 0x04); 564 input_report_key(input, BTN_RIGHT, data[8] & 0x04);
555 565
556 wacom_report_key(wcombo, BTN_SIDE, data[8] & 0x20); 566 input_report_key(input, BTN_SIDE, data[8] & 0x20);
557 wacom_report_key(wcombo, BTN_EXTRA, data[8] & 0x10); 567 input_report_key(input, BTN_EXTRA, data[8] & 0x10);
558 t = (data[6] << 2) | ((data[7] >> 6) & 3); 568 t = (data[6] << 2) | ((data[7] >> 6) & 3);
559 wacom_report_abs(wcombo, ABS_THROTTLE, (data[8] & 0x08) ? -t : t); 569 input_report_abs(input, ABS_THROTTLE, (data[8] & 0x08) ? -t : t);
560 570
561 } else if (wacom->tool[idx] == BTN_TOOL_MOUSE) { 571 } else if (wacom->tool[idx] == BTN_TOOL_MOUSE) {
562 /* I4 mouse */ 572 /* I4 mouse */
563 if (features->type >= INTUOS4S && features->type <= INTUOS4L) { 573 if (features->type >= INTUOS4S && features->type <= INTUOS4L) {
564 wacom_report_key(wcombo, BTN_LEFT, data[6] & 0x01); 574 input_report_key(input, BTN_LEFT, data[6] & 0x01);
565 wacom_report_key(wcombo, BTN_MIDDLE, data[6] & 0x02); 575 input_report_key(input, BTN_MIDDLE, data[6] & 0x02);
566 wacom_report_key(wcombo, BTN_RIGHT, data[6] & 0x04); 576 input_report_key(input, BTN_RIGHT, data[6] & 0x04);
567 wacom_report_rel(wcombo, REL_WHEEL, ((data[7] & 0x80) >> 7) 577 input_report_rel(input, REL_WHEEL, ((data[7] & 0x80) >> 7)
568 - ((data[7] & 0x40) >> 6)); 578 - ((data[7] & 0x40) >> 6));
569 wacom_report_key(wcombo, BTN_SIDE, data[6] & 0x08); 579 input_report_key(input, BTN_SIDE, data[6] & 0x08);
570 wacom_report_key(wcombo, BTN_EXTRA, data[6] & 0x10); 580 input_report_key(input, BTN_EXTRA, data[6] & 0x10);
571 581
572 wacom_report_abs(wcombo, ABS_TILT_X, 582 input_report_abs(input, ABS_TILT_X,
573 ((data[7] << 1) & 0x7e) | (data[8] >> 7)); 583 ((data[7] << 1) & 0x7e) | (data[8] >> 7));
574 wacom_report_abs(wcombo, ABS_TILT_Y, data[8] & 0x7f); 584 input_report_abs(input, ABS_TILT_Y, data[8] & 0x7f);
575 } else { 585 } else {
576 /* 2D mouse packet */ 586 /* 2D mouse packet */
577 wacom_report_key(wcombo, BTN_LEFT, data[8] & 0x04); 587 input_report_key(input, BTN_LEFT, data[8] & 0x04);
578 wacom_report_key(wcombo, BTN_MIDDLE, data[8] & 0x08); 588 input_report_key(input, BTN_MIDDLE, data[8] & 0x08);
579 wacom_report_key(wcombo, BTN_RIGHT, data[8] & 0x10); 589 input_report_key(input, BTN_RIGHT, data[8] & 0x10);
580 wacom_report_rel(wcombo, REL_WHEEL, (data[8] & 0x01) 590 input_report_rel(input, REL_WHEEL, (data[8] & 0x01)
581 - ((data[8] & 0x02) >> 1)); 591 - ((data[8] & 0x02) >> 1));
582 592
583 /* I3 2D mouse side buttons */ 593 /* I3 2D mouse side buttons */
584 if (features->type >= INTUOS3S && features->type <= INTUOS3L) { 594 if (features->type >= INTUOS3S && features->type <= INTUOS3L) {
585 wacom_report_key(wcombo, BTN_SIDE, data[8] & 0x40); 595 input_report_key(input, BTN_SIDE, data[8] & 0x40);
586 wacom_report_key(wcombo, BTN_EXTRA, data[8] & 0x20); 596 input_report_key(input, BTN_EXTRA, data[8] & 0x20);
587 } 597 }
588 } 598 }
589 } else if ((features->type < INTUOS3S || features->type == INTUOS3L || 599 } else if ((features->type < INTUOS3S || features->type == INTUOS3L ||
590 features->type == INTUOS4L) && 600 features->type == INTUOS4L) &&
591 wacom->tool[idx] == BTN_TOOL_LENS) { 601 wacom->tool[idx] == BTN_TOOL_LENS) {
592 /* Lens cursor packets */ 602 /* Lens cursor packets */
593 wacom_report_key(wcombo, BTN_LEFT, data[8] & 0x01); 603 input_report_key(input, BTN_LEFT, data[8] & 0x01);
594 wacom_report_key(wcombo, BTN_MIDDLE, data[8] & 0x02); 604 input_report_key(input, BTN_MIDDLE, data[8] & 0x02);
595 wacom_report_key(wcombo, BTN_RIGHT, data[8] & 0x04); 605 input_report_key(input, BTN_RIGHT, data[8] & 0x04);
596 wacom_report_key(wcombo, BTN_SIDE, data[8] & 0x10); 606 input_report_key(input, BTN_SIDE, data[8] & 0x10);
597 wacom_report_key(wcombo, BTN_EXTRA, data[8] & 0x08); 607 input_report_key(input, BTN_EXTRA, data[8] & 0x08);
598 } 608 }
599 } 609 }
600 610
601 wacom_report_abs(wcombo, ABS_MISC, wacom->id[idx]); /* report tool id */ 611 input_report_abs(input, ABS_MISC, wacom->id[idx]); /* report tool id */
602 wacom_report_key(wcombo, wacom->tool[idx], 1); 612 input_report_key(input, wacom->tool[idx], 1);
603 wacom_input_event(wcombo, EV_MSC, MSC_SERIAL, wacom->serial[idx]); 613 input_event(input, EV_MSC, MSC_SERIAL, wacom->serial[idx]);
604 return 1; 614 return 1;
605} 615}
606 616
607 617
608static void wacom_tpc_finger_in(struct wacom_wac *wacom, void *wcombo, char *data, int idx) 618static void wacom_tpc_finger_in(struct wacom_wac *wacom, void *wcombo, char *data, int idx)
609{ 619{
610 wacom_report_abs(wcombo, ABS_X, 620 struct input_dev *input = wacom->input;
621
622 input_report_abs(input, ABS_X,
611 data[2 + idx * 2] | ((data[3 + idx * 2] & 0x7f) << 8)); 623 data[2 + idx * 2] | ((data[3 + idx * 2] & 0x7f) << 8));
612 wacom_report_abs(wcombo, ABS_Y, 624 input_report_abs(input, ABS_Y,
613 data[6 + idx * 2] | ((data[7 + idx * 2] & 0x7f) << 8)); 625 data[6 + idx * 2] | ((data[7 + idx * 2] & 0x7f) << 8));
614 wacom_report_abs(wcombo, ABS_MISC, wacom->id[0]); 626 input_report_abs(input, ABS_MISC, wacom->id[0]);
615 wacom_report_key(wcombo, wacom->tool[idx], 1); 627 input_report_key(input, wacom->tool[idx], 1);
616 if (idx) 628 if (idx)
617 wacom_input_event(wcombo, EV_MSC, MSC_SERIAL, 0xf0); 629 input_event(input, EV_MSC, MSC_SERIAL, 0xf0);
618 else 630 else
619 wacom_report_key(wcombo, BTN_TOUCH, 1); 631 input_report_key(input, BTN_TOUCH, 1);
620} 632}
621 633
622static void wacom_tpc_touch_out(struct wacom_wac *wacom, void *wcombo, int idx) 634static void wacom_tpc_touch_out(struct wacom_wac *wacom, void *wcombo, int idx)
623{ 635{
624 wacom_report_abs(wcombo, ABS_X, 0); 636 struct input_dev *input = wacom->input;
625 wacom_report_abs(wcombo, ABS_Y, 0); 637
626 wacom_report_abs(wcombo, ABS_MISC, 0); 638 input_report_abs(input, ABS_X, 0);
627 wacom_report_key(wcombo, wacom->tool[idx], 0); 639 input_report_abs(input, ABS_Y, 0);
640 input_report_abs(input, ABS_MISC, 0);
641 input_report_key(input, wacom->tool[idx], 0);
628 if (idx) 642 if (idx)
629 wacom_input_event(wcombo, EV_MSC, MSC_SERIAL, 0xf0); 643 input_event(input, EV_MSC, MSC_SERIAL, 0xf0);
630 else 644 else
631 wacom_report_key(wcombo, BTN_TOUCH, 0); 645 input_report_key(input, BTN_TOUCH, 0);
632 return;
633} 646}
634 647
635static void wacom_tpc_touch_in(struct wacom_wac *wacom, void *wcombo) 648static void wacom_tpc_touch_in(struct wacom_wac *wacom, void *wcombo)
636{ 649{
637 char *data = wacom->data; 650 char *data = wacom->data;
651 struct input_dev *input = wacom->input;
638 struct urb *urb = ((struct wacom_combo *)wcombo)->urb; 652 struct urb *urb = ((struct wacom_combo *)wcombo)->urb;
639 static int firstFinger = 0; 653 static int firstFinger = 0;
640 static int secondFinger = 0; 654 static int secondFinger = 0;
@@ -648,12 +662,12 @@ static void wacom_tpc_touch_in(struct wacom_wac *wacom, void *wcombo)
648 switch (data[0]) { 662 switch (data[0]) {
649 663
650 case WACOM_REPORT_TPC1FG: 664 case WACOM_REPORT_TPC1FG:
651 wacom_report_abs(wcombo, ABS_X, wacom_le16_to_cpu(&data[2])); 665 input_report_abs(input, ABS_X, wacom_le16_to_cpu(&data[2]));
652 wacom_report_abs(wcombo, ABS_Y, wacom_le16_to_cpu(&data[4])); 666 input_report_abs(input, ABS_Y, wacom_le16_to_cpu(&data[4]));
653 wacom_report_abs(wcombo, ABS_PRESSURE, wacom_le16_to_cpu(&data[6])); 667 input_report_abs(input, ABS_PRESSURE, wacom_le16_to_cpu(&data[6]));
654 wacom_report_key(wcombo, BTN_TOUCH, wacom_le16_to_cpu(&data[6])); 668 input_report_key(input, BTN_TOUCH, wacom_le16_to_cpu(&data[6]));
655 wacom_report_abs(wcombo, ABS_MISC, wacom->id[0]); 669 input_report_abs(input, ABS_MISC, wacom->id[0]);
656 wacom_report_key(wcombo, wacom->tool[0], 1); 670 input_report_key(input, wacom->tool[0], 1);
657 break; 671 break;
658 672
659 case WACOM_REPORT_TPC2FG: 673 case WACOM_REPORT_TPC2FG:
@@ -670,14 +684,14 @@ static void wacom_tpc_touch_in(struct wacom_wac *wacom, void *wcombo)
670 if (data[1] & 0x02) { 684 if (data[1] & 0x02) {
671 /* sync first finger data */ 685 /* sync first finger data */
672 if (firstFinger) 686 if (firstFinger)
673 wacom_input_sync(wcombo); 687 input_sync(input);
674 688
675 wacom_tpc_finger_in(wacom, wcombo, data, 1); 689 wacom_tpc_finger_in(wacom, wcombo, data, 1);
676 secondFinger = 1; 690 secondFinger = 1;
677 } else if (secondFinger) { 691 } else if (secondFinger) {
678 /* sync first finger data */ 692 /* sync first finger data */
679 if (firstFinger) 693 if (firstFinger)
680 wacom_input_sync(wcombo); 694 input_sync(input);
681 695
682 wacom_tpc_touch_out(wacom, wcombo, 1); 696 wacom_tpc_touch_out(wacom, wcombo, 1);
683 secondFinger = 0; 697 secondFinger = 0;
@@ -687,11 +701,11 @@ static void wacom_tpc_touch_in(struct wacom_wac *wacom, void *wcombo)
687 break; 701 break;
688 } 702 }
689 } else { 703 } else {
690 wacom_report_abs(wcombo, ABS_X, wacom_le16_to_cpu(&data[1])); 704 input_report_abs(input, ABS_X, wacom_le16_to_cpu(&data[1]));
691 wacom_report_abs(wcombo, ABS_Y, wacom_le16_to_cpu(&data[3])); 705 input_report_abs(input, ABS_Y, wacom_le16_to_cpu(&data[3]));
692 wacom_report_key(wcombo, BTN_TOUCH, 1); 706 input_report_key(input, BTN_TOUCH, 1);
693 wacom_report_abs(wcombo, ABS_MISC, wacom->id[0]); 707 input_report_abs(input, ABS_MISC, wacom->id[0]);
694 wacom_report_key(wcombo, wacom->tool[0], 1); 708 input_report_key(input, wacom->tool[0], 1);
695 } 709 }
696} 710}
697 711
@@ -699,6 +713,7 @@ static int wacom_tpc_irq(struct wacom_wac *wacom, void *wcombo)
699{ 713{
700 struct wacom_features *features = &wacom->features; 714 struct wacom_features *features = &wacom->features;
701 char *data = wacom->data; 715 char *data = wacom->data;
716 struct input_dev *input = wacom->input;
702 int prox = 0, pressure, idx = -1; 717 int prox = 0, pressure, idx = -1;
703 struct urb *urb = ((struct wacom_combo *)wcombo)->urb; 718 struct urb *urb = ((struct wacom_combo *)wcombo)->urb;
704 719
@@ -729,7 +744,7 @@ static int wacom_tpc_irq(struct wacom_wac *wacom, void *wcombo)
729 wacom_tpc_touch_out(wacom, wcombo, idx); 744 wacom_tpc_touch_out(wacom, wcombo, idx);
730 /* sync first finger event */ 745 /* sync first finger event */
731 if (wacom->id[1] & 0x02) 746 if (wacom->id[1] & 0x02)
732 wacom_input_sync(wcombo); 747 input_sync(input);
733 } 748 }
734 idx = (wacom->id[1] & 0x02) - 1; 749 idx = (wacom->id[1] & 0x02) - 1;
735 if (idx == 1) 750 if (idx == 1)
@@ -757,21 +772,21 @@ static int wacom_tpc_irq(struct wacom_wac *wacom, void *wcombo)
757 772
758 wacom->shared->stylus_in_proximity = true; 773 wacom->shared->stylus_in_proximity = true;
759 } 774 }
760 wacom_report_key(wcombo, BTN_STYLUS, data[1] & 0x02); 775 input_report_key(input, BTN_STYLUS, data[1] & 0x02);
761 wacom_report_key(wcombo, BTN_STYLUS2, data[1] & 0x10); 776 input_report_key(input, BTN_STYLUS2, data[1] & 0x10);
762 wacom_report_abs(wcombo, ABS_X, wacom_le16_to_cpu(&data[2])); 777 input_report_abs(input, ABS_X, wacom_le16_to_cpu(&data[2]));
763 wacom_report_abs(wcombo, ABS_Y, wacom_le16_to_cpu(&data[4])); 778 input_report_abs(input, ABS_Y, wacom_le16_to_cpu(&data[4]));
764 pressure = ((data[7] & 0x01) << 8) | data[6]; 779 pressure = ((data[7] & 0x01) << 8) | data[6];
765 if (pressure < 0) 780 if (pressure < 0)
766 pressure = features->pressure_max + pressure + 1; 781 pressure = features->pressure_max + pressure + 1;
767 wacom_report_abs(wcombo, ABS_PRESSURE, pressure); 782 input_report_abs(input, ABS_PRESSURE, pressure);
768 wacom_report_key(wcombo, BTN_TOUCH, data[1] & 0x05); 783 input_report_key(input, BTN_TOUCH, data[1] & 0x05);
769 if (!prox) { /* out-prox */ 784 if (!prox) { /* out-prox */
770 wacom->id[0] = 0; 785 wacom->id[0] = 0;
771 wacom->shared->stylus_in_proximity = false; 786 wacom->shared->stylus_in_proximity = false;
772 } 787 }
773 wacom_report_key(wcombo, wacom->tool[0], prox); 788 input_report_key(input, wacom->tool[0], prox);
774 wacom_report_abs(wcombo, ABS_MISC, wacom->id[0]); 789 input_report_abs(input, ABS_MISC, wacom->id[0]);
775 return 1; 790 return 1;
776 } 791 }
777 return 0; 792 return 0;
@@ -815,64 +830,160 @@ int wacom_wac_irq(struct wacom_wac *wacom_wac, void *wcombo)
815 return 0; 830 return 0;
816} 831}
817 832
818void wacom_init_input_dev(struct input_dev *input_dev, struct wacom_wac *wacom_wac) 833static void wacom_setup_intuos(struct wacom_wac *wacom_wac)
834{
835 struct input_dev *input_dev = wacom_wac->input;
836
837 input_set_capability(input_dev, EV_MSC, MSC_SERIAL);
838 input_set_capability(input_dev, EV_REL, REL_WHEEL);
839
840 __set_bit(BTN_LEFT, input_dev->keybit);
841 __set_bit(BTN_RIGHT, input_dev->keybit);
842 __set_bit(BTN_MIDDLE, input_dev->keybit);
843 __set_bit(BTN_SIDE, input_dev->keybit);
844 __set_bit(BTN_EXTRA, input_dev->keybit);
845
846 __set_bit(BTN_TOOL_RUBBER, input_dev->keybit);
847 __set_bit(BTN_TOOL_PEN, input_dev->keybit);
848 __set_bit(BTN_TOOL_MOUSE, input_dev->keybit);
849 __set_bit(BTN_TOOL_BRUSH, input_dev->keybit);
850 __set_bit(BTN_TOOL_PENCIL, input_dev->keybit);
851 __set_bit(BTN_TOOL_AIRBRUSH, input_dev->keybit);
852 __set_bit(BTN_TOOL_LENS, input_dev->keybit);
853 __set_bit(BTN_STYLUS, input_dev->keybit);
854 __set_bit(BTN_STYLUS2, input_dev->keybit);
855
856 input_set_abs_params(input_dev, ABS_DISTANCE,
857 0, wacom_wac->features.distance_max, 0, 0);
858 input_set_abs_params(input_dev, ABS_WHEEL, 0, 1023, 0, 0);
859 input_set_abs_params(input_dev, ABS_TILT_X, 0, 127, 0, 0);
860 input_set_abs_params(input_dev, ABS_TILT_Y, 0, 127, 0, 0);
861 input_set_abs_params(input_dev, ABS_RZ, -900, 899, 0, 0);
862 input_set_abs_params(input_dev, ABS_THROTTLE, -1023, 1023, 0, 0);
863}
864
865void wacom_setup_input_capabilities(struct input_dev *input_dev,
866 struct wacom_wac *wacom_wac)
819{ 867{
868 struct wacom_features *features = &wacom_wac->features;
869 int i;
870
871 input_dev->evbit[0] |= BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS);
872
873 __set_bit(BTN_TOUCH, input_dev->keybit);
874
875 input_set_abs_params(input_dev, ABS_X, 0, features->x_max, 4, 0);
876 input_set_abs_params(input_dev, ABS_Y, 0, features->y_max, 4, 0);
877 input_set_abs_params(input_dev, ABS_PRESSURE, 0, features->pressure_max, 0, 0);
878
879 __set_bit(ABS_MISC, input_dev->absbit);
880
820 switch (wacom_wac->features.type) { 881 switch (wacom_wac->features.type) {
821 case WACOM_MO: 882 case WACOM_MO:
822 input_dev_mo(input_dev, wacom_wac); 883 __set_bit(BTN_1, input_dev->keybit);
884 __set_bit(BTN_5, input_dev->keybit);
885
886 input_set_abs_params(input_dev, ABS_WHEEL, 0, 71, 0, 0);
887 /* fall through */
823 888
824 case WACOM_G4: 889 case WACOM_G4:
825 input_dev_g4(input_dev, wacom_wac); 890 input_set_capability(input_dev, EV_MSC, MSC_SERIAL);
891
892 __set_bit(BTN_TOOL_FINGER, input_dev->keybit);
893 __set_bit(BTN_0, input_dev->keybit);
894 __set_bit(BTN_4, input_dev->keybit);
826 /* fall through */ 895 /* fall through */
827 896
828 case GRAPHIRE: 897 case GRAPHIRE:
829 input_dev_g(input_dev, wacom_wac); 898 input_set_capability(input_dev, EV_REL, REL_WHEEL);
899
900 __set_bit(BTN_LEFT, input_dev->keybit);
901 __set_bit(BTN_RIGHT, input_dev->keybit);
902 __set_bit(BTN_MIDDLE, input_dev->keybit);
903
904 __set_bit(BTN_TOOL_RUBBER, input_dev->keybit);
905 __set_bit(BTN_TOOL_PEN, input_dev->keybit);
906 __set_bit(BTN_TOOL_MOUSE, input_dev->keybit);
907 __set_bit(BTN_STYLUS, input_dev->keybit);
908 __set_bit(BTN_STYLUS2, input_dev->keybit);
830 break; 909 break;
831 910
832 case WACOM_BEE: 911 case WACOM_BEE:
833 input_dev_bee(input_dev, wacom_wac); 912 __set_bit(BTN_8, input_dev->keybit);
913 __set_bit(BTN_9, input_dev->keybit);
914 /* fall through */
834 915
835 case INTUOS3: 916 case INTUOS3:
836 case INTUOS3L: 917 case INTUOS3L:
837 case CINTIQ: 918 case CINTIQ:
838 input_dev_i3(input_dev, wacom_wac); 919 __set_bit(BTN_4, input_dev->keybit);
920 __set_bit(BTN_5, input_dev->keybit);
921 __set_bit(BTN_6, input_dev->keybit);
922 __set_bit(BTN_7, input_dev->keybit);
923
924 input_set_abs_params(input_dev, ABS_RY, 0, 4096, 0, 0);
839 /* fall through */ 925 /* fall through */
840 926
841 case INTUOS3S: 927 case INTUOS3S:
842 input_dev_i3s(input_dev, wacom_wac); 928 __set_bit(BTN_0, input_dev->keybit);
929 __set_bit(BTN_1, input_dev->keybit);
930 __set_bit(BTN_2, input_dev->keybit);
931 __set_bit(BTN_3, input_dev->keybit);
932
933 __set_bit(BTN_TOOL_FINGER, input_dev->keybit);
934
935 input_set_abs_params(input_dev, ABS_RX, 0, 4096, 0, 0);
936 input_set_abs_params(input_dev, ABS_Z, -900, 899, 0, 0);
843 /* fall through */ 937 /* fall through */
844 938
845 case INTUOS: 939 case INTUOS:
846 input_dev_i(input_dev, wacom_wac); 940 wacom_setup_intuos(wacom_wac);
847 break; 941 break;
848 942
849 case INTUOS4: 943 case INTUOS4:
850 case INTUOS4L: 944 case INTUOS4L:
851 input_dev_i4(input_dev, wacom_wac); 945 __set_bit(BTN_7, input_dev->keybit);
946 __set_bit(BTN_8, input_dev->keybit);
852 /* fall through */ 947 /* fall through */
853 948
854 case INTUOS4S: 949 case INTUOS4S:
855 input_dev_i4s(input_dev, wacom_wac); 950 for (i = 0; i < 7; i++)
856 input_dev_i(input_dev, wacom_wac); 951 __set_bit(BTN_0 + i, input_dev->keybit);
952 __set_bit(BTN_TOOL_FINGER, input_dev->keybit);
953
954 input_set_abs_params(input_dev, ABS_Z, -900, 899, 0, 0);
955 wacom_setup_intuos(wacom_wac);
857 break; 956 break;
858 957
859 case TABLETPC2FG: 958 case TABLETPC2FG:
860 input_dev_tpc2fg(input_dev, wacom_wac); 959 if (features->device_type == BTN_TOOL_TRIPLETAP) {
960 __set_bit(BTN_TOOL_TRIPLETAP, input_dev->keybit);
961 input_set_capability(input_dev, EV_MSC, MSC_SERIAL);
962 }
861 /* fall through */ 963 /* fall through */
862 964
863 case TABLETPC: 965 case TABLETPC:
864 input_dev_tpc(input_dev, wacom_wac); 966 if (features->device_type == BTN_TOOL_DOUBLETAP ||
865 if (wacom_wac->features.device_type != BTN_TOOL_PEN) 967 features->device_type == BTN_TOOL_TRIPLETAP) {
968 input_set_abs_params(input_dev, ABS_RX, 0, features->x_phy, 0, 0);
969 input_set_abs_params(input_dev, ABS_RY, 0, features->y_phy, 0, 0);
970 __set_bit(BTN_TOOL_DOUBLETAP, input_dev->keybit);
971 }
972
973 if (features->device_type != BTN_TOOL_PEN)
866 break; /* no need to process stylus stuff */ 974 break; /* no need to process stylus stuff */
975
867 /* fall through */ 976 /* fall through */
868 977
869 case PL: 978 case PL:
870 case PTU: 979 case PTU:
871 input_dev_pl(input_dev, wacom_wac); 980 __set_bit(BTN_TOOL_PEN, input_dev->keybit);
981 __set_bit(BTN_STYLUS, input_dev->keybit);
982 __set_bit(BTN_STYLUS2, input_dev->keybit);
872 /* fall through */ 983 /* fall through */
873 984
874 case PENPARTNER: 985 case PENPARTNER:
875 input_dev_pt(input_dev, wacom_wac); 986 __set_bit(BTN_TOOL_RUBBER, input_dev->keybit);
876 break; 987 break;
877 } 988 }
878} 989}
diff --git a/drivers/input/tablet/wacom_wac.h b/drivers/input/tablet/wacom_wac.h
index f190a2bf148..69098a2aa69 100644
--- a/drivers/input/tablet/wacom_wac.h
+++ b/drivers/input/tablet/wacom_wac.h
@@ -85,6 +85,7 @@ struct wacom_wac {
85 __u32 serial[2]; 85 __u32 serial[2];
86 struct wacom_features features; 86 struct wacom_features features;
87 struct wacom_shared *shared; 87 struct wacom_shared *shared;
88 struct input_dev *input;
88}; 89};
89 90
90#endif 91#endif