aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/input/tablet/wacom_sys.c
diff options
context:
space:
mode:
authorDmitry Torokhov <dmitry.torokhov@gmail.com>2010-03-01 02:55:20 -0500
committerDmitry Torokhov <dmitry.torokhov@gmail.com>2010-03-01 02:55:20 -0500
commit35858adbfca13678af99fb31618ef4428d6dedb0 (patch)
tree3336feaa61324486945816cb52c347733e7c0821 /drivers/input/tablet/wacom_sys.c
parent197d4db752e67160d79fed09968c2140376a80a3 (diff)
parent4b70858ba8d4537daf782defebe5f2ff80ccef2b (diff)
Merge branch 'next' into for-linus
Diffstat (limited to 'drivers/input/tablet/wacom_sys.c')
-rw-r--r--drivers/input/tablet/wacom_sys.c70
1 files changed, 50 insertions, 20 deletions
diff --git a/drivers/input/tablet/wacom_sys.c b/drivers/input/tablet/wacom_sys.c
index 072f33b3b2b0..a1770e6feeec 100644
--- a/drivers/input/tablet/wacom_sys.c
+++ b/drivers/input/tablet/wacom_sys.c
@@ -211,7 +211,8 @@ void input_dev_g(struct input_dev *input_dev, struct wacom_wac *wacom_wac)
211 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) |
212 BIT_MASK(BTN_TOOL_PEN) | BIT_MASK(BTN_STYLUS) | 212 BIT_MASK(BTN_TOOL_PEN) | BIT_MASK(BTN_STYLUS) |
213 BIT_MASK(BTN_TOOL_MOUSE) | BIT_MASK(BTN_STYLUS2); 213 BIT_MASK(BTN_TOOL_MOUSE) | BIT_MASK(BTN_STYLUS2);
214 input_set_abs_params(input_dev, ABS_DISTANCE, 0, wacom_wac->features->distance_max, 0, 0); 214 input_set_abs_params(input_dev, ABS_DISTANCE,
215 0, wacom_wac->features.distance_max, 0, 0);
215} 216}
216 217
217void input_dev_i3s(struct input_dev *input_dev, struct wacom_wac *wacom_wac) 218void input_dev_i3s(struct input_dev *input_dev, struct wacom_wac *wacom_wac)
@@ -261,7 +262,8 @@ void input_dev_i(struct input_dev *input_dev, struct wacom_wac *wacom_wac)
261 BIT_MASK(BTN_TOOL_MOUSE) | BIT_MASK(BTN_TOOL_BRUSH) | 262 BIT_MASK(BTN_TOOL_MOUSE) | BIT_MASK(BTN_TOOL_BRUSH) |
262 BIT_MASK(BTN_TOOL_PENCIL) | BIT_MASK(BTN_TOOL_AIRBRUSH) | 263 BIT_MASK(BTN_TOOL_PENCIL) | BIT_MASK(BTN_TOOL_AIRBRUSH) |
263 BIT_MASK(BTN_TOOL_LENS) | BIT_MASK(BTN_STYLUS2); 264 BIT_MASK(BTN_TOOL_LENS) | BIT_MASK(BTN_STYLUS2);
264 input_set_abs_params(input_dev, ABS_DISTANCE, 0, wacom_wac->features->distance_max, 0, 0); 265 input_set_abs_params(input_dev, ABS_DISTANCE,
266 0, wacom_wac->features.distance_max, 0, 0);
265 input_set_abs_params(input_dev, ABS_WHEEL, 0, 1023, 0, 0); 267 input_set_abs_params(input_dev, ABS_WHEEL, 0, 1023, 0, 0);
266 input_set_abs_params(input_dev, ABS_TILT_X, 0, 127, 0, 0); 268 input_set_abs_params(input_dev, ABS_TILT_X, 0, 127, 0, 0);
267 input_set_abs_params(input_dev, ABS_TILT_Y, 0, 127, 0, 0); 269 input_set_abs_params(input_dev, ABS_TILT_Y, 0, 127, 0, 0);
@@ -282,17 +284,19 @@ void input_dev_pt(struct input_dev *input_dev, struct wacom_wac *wacom_wac)
282 284
283void input_dev_tpc(struct input_dev *input_dev, struct wacom_wac *wacom_wac) 285void input_dev_tpc(struct input_dev *input_dev, struct wacom_wac *wacom_wac)
284{ 286{
285 if (wacom_wac->features->device_type == BTN_TOOL_DOUBLETAP || 287 struct wacom_features *features = &wacom_wac->features;
286 wacom_wac->features->device_type == BTN_TOOL_TRIPLETAP) { 288
287 input_set_abs_params(input_dev, ABS_RX, 0, wacom_wac->features->x_phy, 0, 0); 289 if (features->device_type == BTN_TOOL_DOUBLETAP ||
288 input_set_abs_params(input_dev, ABS_RY, 0, wacom_wac->features->y_phy, 0, 0); 290 features->device_type == BTN_TOOL_TRIPLETAP) {
289 input_dev->keybit[BIT_WORD(BTN_DIGI)] |= BIT_MASK(BTN_TOOL_DOUBLETAP); 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);
290 } 294 }
291} 295}
292 296
293void input_dev_tpc2fg(struct input_dev *input_dev, struct wacom_wac *wacom_wac) 297void input_dev_tpc2fg(struct input_dev *input_dev, struct wacom_wac *wacom_wac)
294{ 298{
295 if (wacom_wac->features->device_type == BTN_TOOL_TRIPLETAP) { 299 if (wacom_wac->features.device_type == BTN_TOOL_TRIPLETAP) {
296 input_dev->keybit[BIT_WORD(BTN_DIGI)] |= BIT_MASK(BTN_TOOL_TRIPLETAP); 300 input_dev->keybit[BIT_WORD(BTN_DIGI)] |= BIT_MASK(BTN_TOOL_TRIPLETAP);
297 input_dev->evbit[0] |= BIT_MASK(EV_MSC); 301 input_dev->evbit[0] |= BIT_MASK(EV_MSC);
298 input_dev->mscbit[0] |= BIT_MASK(MSC_SERIAL); 302 input_dev->mscbit[0] |= BIT_MASK(MSC_SERIAL);
@@ -532,21 +536,38 @@ static int wacom_probe(struct usb_interface *intf, const struct usb_device_id *i
532 struct wacom_wac *wacom_wac; 536 struct wacom_wac *wacom_wac;
533 struct wacom_features *features; 537 struct wacom_features *features;
534 struct input_dev *input_dev; 538 struct input_dev *input_dev;
535 int error = -ENOMEM; 539 int error;
540
541 if (!id->driver_info)
542 return -EINVAL;
536 543
537 wacom = kzalloc(sizeof(struct wacom), GFP_KERNEL); 544 wacom = kzalloc(sizeof(struct wacom), GFP_KERNEL);
538 wacom_wac = kzalloc(sizeof(struct wacom_wac), GFP_KERNEL); 545 wacom_wac = kzalloc(sizeof(struct wacom_wac), GFP_KERNEL);
539 input_dev = input_allocate_device(); 546 input_dev = input_allocate_device();
540 if (!wacom || !input_dev || !wacom_wac) 547 if (!wacom || !input_dev || !wacom_wac) {
548 error = -ENOMEM;
541 goto fail1; 549 goto fail1;
550 }
542 551
543 wacom_wac->data = usb_buffer_alloc(dev, WACOM_PKGLEN_MAX, GFP_KERNEL, &wacom->data_dma); 552 wacom_wac->features = *((struct wacom_features *)id->driver_info);
544 if (!wacom_wac->data) 553 features = &wacom_wac->features;
554 if (features->pktlen > WACOM_PKGLEN_MAX) {
555 error = -EINVAL;
545 goto fail1; 556 goto fail1;
557 }
558
559 wacom_wac->data = usb_buffer_alloc(dev, WACOM_PKGLEN_MAX,
560 GFP_KERNEL, &wacom->data_dma);
561 if (!wacom_wac->data) {
562 error = -ENOMEM;
563 goto fail1;
564 }
546 565
547 wacom->irq = usb_alloc_urb(0, GFP_KERNEL); 566 wacom->irq = usb_alloc_urb(0, GFP_KERNEL);
548 if (!wacom->irq) 567 if (!wacom->irq) {
568 error = -ENOMEM;
549 goto fail2; 569 goto fail2;
570 }
550 571
551 wacom->usbdev = dev; 572 wacom->usbdev = dev;
552 wacom->dev = input_dev; 573 wacom->dev = input_dev;
@@ -555,11 +576,6 @@ static int wacom_probe(struct usb_interface *intf, const struct usb_device_id *i
555 usb_make_path(dev, wacom->phys, sizeof(wacom->phys)); 576 usb_make_path(dev, wacom->phys, sizeof(wacom->phys));
556 strlcat(wacom->phys, "/input0", sizeof(wacom->phys)); 577 strlcat(wacom->phys, "/input0", sizeof(wacom->phys));
557 578
558 wacom_wac->features = features = get_wacom_feature(id);
559 BUG_ON(features->pktlen > WACOM_PKGLEN_MAX);
560
561 input_dev->name = wacom_wac->features->name;
562 wacom->wacom_wac = wacom_wac;
563 usb_to_input_id(dev, &input_dev->id); 579 usb_to_input_id(dev, &input_dev->id);
564 580
565 input_dev->dev.parent = &intf->dev; 581 input_dev->dev.parent = &intf->dev;
@@ -576,6 +592,19 @@ static int wacom_probe(struct usb_interface *intf, const struct usb_device_id *i
576 if (error) 592 if (error)
577 goto fail2; 593 goto fail2;
578 594
595 strlcpy(wacom_wac->name, features->name, sizeof(wacom_wac->name));
596
597 if (features->type == TABLETPC || features->type == TABLETPC2FG) {
598 /* Append the device type to the name */
599 strlcat(wacom_wac->name,
600 features->device_type == BTN_TOOL_PEN ?
601 " Pen" : " Finger",
602 sizeof(wacom_wac->name));
603 }
604
605 input_dev->name = wacom_wac->name;
606 wacom->wacom_wac = wacom_wac;
607
579 input_dev->evbit[0] |= BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS); 608 input_dev->evbit[0] |= BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS);
580 input_dev->keybit[BIT_WORD(BTN_DIGI)] |= BIT_MASK(BTN_TOUCH); 609 input_dev->keybit[BIT_WORD(BTN_DIGI)] |= BIT_MASK(BTN_TOUCH);
581 610
@@ -640,7 +669,7 @@ static int wacom_suspend(struct usb_interface *intf, pm_message_t message)
640static int wacom_resume(struct usb_interface *intf) 669static int wacom_resume(struct usb_interface *intf)
641{ 670{
642 struct wacom *wacom = usb_get_intfdata(intf); 671 struct wacom *wacom = usb_get_intfdata(intf);
643 struct wacom_features *features = wacom->wacom_wac->features; 672 struct wacom_features *features = &wacom->wacom_wac->features;
644 int rv; 673 int rv;
645 674
646 mutex_lock(&wacom->lock); 675 mutex_lock(&wacom->lock);
@@ -663,6 +692,7 @@ static int wacom_reset_resume(struct usb_interface *intf)
663 692
664static struct usb_driver wacom_driver = { 693static struct usb_driver wacom_driver = {
665 .name = "wacom", 694 .name = "wacom",
695 .id_table = wacom_ids,
666 .probe = wacom_probe, 696 .probe = wacom_probe,
667 .disconnect = wacom_disconnect, 697 .disconnect = wacom_disconnect,
668 .suspend = wacom_suspend, 698 .suspend = wacom_suspend,
@@ -674,7 +704,7 @@ static struct usb_driver wacom_driver = {
674static int __init wacom_init(void) 704static int __init wacom_init(void)
675{ 705{
676 int result; 706 int result;
677 wacom_driver.id_table = get_device_table(); 707
678 result = usb_register(&wacom_driver); 708 result = usb_register(&wacom_driver);
679 if (result == 0) 709 if (result == 0)
680 printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":" 710 printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":"