aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/input/tablet/wacom_sys.c
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/wacom_sys.c
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/wacom_sys.c')
-rw-r--r--drivers/input/tablet/wacom_sys.c174
1 files changed, 11 insertions, 163 deletions
diff --git a/drivers/input/tablet/wacom_sys.c b/drivers/input/tablet/wacom_sys.c
index ed339e5eca86..58bb763b60dd 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);