aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/input/wacom.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/usb/input/wacom.c')
-rw-r--r--drivers/usb/input/wacom.c142
1 files changed, 66 insertions, 76 deletions
diff --git a/drivers/usb/input/wacom.c b/drivers/usb/input/wacom.c
index 3b266af3048a..ea0f75773ae1 100644
--- a/drivers/usb/input/wacom.c
+++ b/drivers/usb/input/wacom.c
@@ -111,7 +111,7 @@ struct wacom_features {
111struct wacom { 111struct wacom {
112 signed char *data; 112 signed char *data;
113 dma_addr_t data_dma; 113 dma_addr_t data_dma;
114 struct input_dev dev; 114 struct input_dev *dev;
115 struct usb_device *usbdev; 115 struct usb_device *usbdev;
116 struct urb *irq; 116 struct urb *irq;
117 struct wacom_features *features; 117 struct wacom_features *features;
@@ -135,7 +135,7 @@ static void wacom_pl_irq(struct urb *urb, struct pt_regs *regs)
135{ 135{
136 struct wacom *wacom = urb->context; 136 struct wacom *wacom = urb->context;
137 unsigned char *data = wacom->data; 137 unsigned char *data = wacom->data;
138 struct input_dev *dev = &wacom->dev; 138 struct input_dev *dev = wacom->dev;
139 int prox, pressure; 139 int prox, pressure;
140 int retval; 140 int retval;
141 141
@@ -225,7 +225,7 @@ static void wacom_ptu_irq(struct urb *urb, struct pt_regs *regs)
225{ 225{
226 struct wacom *wacom = urb->context; 226 struct wacom *wacom = urb->context;
227 unsigned char *data = wacom->data; 227 unsigned char *data = wacom->data;
228 struct input_dev *dev = &wacom->dev; 228 struct input_dev *dev = wacom->dev;
229 int retval; 229 int retval;
230 230
231 switch (urb->status) { 231 switch (urb->status) {
@@ -275,7 +275,7 @@ static void wacom_penpartner_irq(struct urb *urb, struct pt_regs *regs)
275{ 275{
276 struct wacom *wacom = urb->context; 276 struct wacom *wacom = urb->context;
277 unsigned char *data = wacom->data; 277 unsigned char *data = wacom->data;
278 struct input_dev *dev = &wacom->dev; 278 struct input_dev *dev = wacom->dev;
279 int retval; 279 int retval;
280 280
281 switch (urb->status) { 281 switch (urb->status) {
@@ -318,7 +318,7 @@ static void wacom_graphire_irq(struct urb *urb, struct pt_regs *regs)
318{ 318{
319 struct wacom *wacom = urb->context; 319 struct wacom *wacom = urb->context;
320 unsigned char *data = wacom->data; 320 unsigned char *data = wacom->data;
321 struct input_dev *dev = &wacom->dev; 321 struct input_dev *dev = wacom->dev;
322 int x, y; 322 int x, y;
323 int retval; 323 int retval;
324 324
@@ -397,7 +397,7 @@ static int wacom_intuos_inout(struct urb *urb)
397{ 397{
398 struct wacom *wacom = urb->context; 398 struct wacom *wacom = urb->context;
399 unsigned char *data = wacom->data; 399 unsigned char *data = wacom->data;
400 struct input_dev *dev = &wacom->dev; 400 struct input_dev *dev = wacom->dev;
401 int idx; 401 int idx;
402 402
403 /* tool number */ 403 /* tool number */
@@ -479,7 +479,7 @@ static void wacom_intuos_general(struct urb *urb)
479{ 479{
480 struct wacom *wacom = urb->context; 480 struct wacom *wacom = urb->context;
481 unsigned char *data = wacom->data; 481 unsigned char *data = wacom->data;
482 struct input_dev *dev = &wacom->dev; 482 struct input_dev *dev = wacom->dev;
483 unsigned int t; 483 unsigned int t;
484 484
485 /* general pen packet */ 485 /* general pen packet */
@@ -509,7 +509,7 @@ static void wacom_intuos_irq(struct urb *urb, struct pt_regs *regs)
509{ 509{
510 struct wacom *wacom = urb->context; 510 struct wacom *wacom = urb->context;
511 unsigned char *data = wacom->data; 511 unsigned char *data = wacom->data;
512 struct input_dev *dev = &wacom->dev; 512 struct input_dev *dev = wacom->dev;
513 unsigned int t; 513 unsigned int t;
514 int idx; 514 int idx;
515 int retval; 515 int retval;
@@ -738,95 +738,83 @@ static int wacom_probe(struct usb_interface *intf, const struct usb_device_id *i
738{ 738{
739 struct usb_device *dev = interface_to_usbdev(intf); 739 struct usb_device *dev = interface_to_usbdev(intf);
740 struct usb_endpoint_descriptor *endpoint; 740 struct usb_endpoint_descriptor *endpoint;
741 char rep_data[2] = {0x02, 0x02};
742 struct wacom *wacom; 741 struct wacom *wacom;
743 char path[64]; 742 struct input_dev *input_dev;
743 char rep_data[2] = {0x02, 0x02};
744 744
745 if (!(wacom = kmalloc(sizeof(struct wacom), GFP_KERNEL))) 745 wacom = kzalloc(sizeof(struct wacom), GFP_KERNEL);
746 return -ENOMEM; 746 input_dev = input_allocate_device();
747 memset(wacom, 0, sizeof(struct wacom)); 747 if (!wacom || !input_dev)
748 goto fail1;
748 749
749 wacom->data = usb_buffer_alloc(dev, 10, GFP_KERNEL, &wacom->data_dma); 750 wacom->data = usb_buffer_alloc(dev, 10, GFP_KERNEL, &wacom->data_dma);
750 if (!wacom->data) { 751 if (!wacom->data)
751 kfree(wacom); 752 goto fail1;
752 return -ENOMEM;
753 }
754 753
755 wacom->irq = usb_alloc_urb(0, GFP_KERNEL); 754 wacom->irq = usb_alloc_urb(0, GFP_KERNEL);
756 if (!wacom->irq) { 755 if (!wacom->irq)
757 usb_buffer_free(dev, 10, wacom->data, wacom->data_dma); 756 goto fail2;
758 kfree(wacom); 757
759 return -ENOMEM; 758 wacom->usbdev = dev;
760 } 759 wacom->dev = input_dev;
760 usb_make_path(dev, wacom->phys, sizeof(wacom->phys));
761 strlcat(wacom->phys, "/input0", sizeof(wacom->phys));
761 762
762 wacom->features = wacom_features + (id - wacom_ids); 763 wacom->features = wacom_features + (id - wacom_ids);
764 if (wacom->features->pktlen > 10)
765 BUG();
766
767 input_dev->name = wacom->features->name;
768 usb_to_input_id(dev, &input_dev->id);
763 769
764 wacom->dev.evbit[0] |= BIT(EV_KEY) | BIT(EV_ABS); 770 input_dev->cdev.dev = &intf->dev;
765 wacom->dev.absbit[0] |= BIT(ABS_X) | BIT(ABS_Y) | BIT(ABS_PRESSURE); 771 input_dev->private = wacom;
766 wacom->dev.keybit[LONG(BTN_DIGI)] |= BIT(BTN_TOOL_PEN) | BIT(BTN_TOUCH) | BIT(BTN_STYLUS); 772 input_dev->open = wacom_open;
773 input_dev->close = wacom_close;
774
775 input_dev->evbit[0] |= BIT(EV_KEY) | BIT(EV_ABS);
776 input_dev->keybit[LONG(BTN_DIGI)] |= BIT(BTN_TOOL_PEN) | BIT(BTN_TOUCH) | BIT(BTN_STYLUS);
777 input_set_abs_params(input_dev, ABS_X, 0, wacom->features->y_max, 4, 0);
778 input_set_abs_params(input_dev, ABS_Y, 0, wacom->features->y_max, 4, 0);
779 input_set_abs_params(input_dev, ABS_PRESSURE, 0, wacom->features->pressure_max, 0, 0);
767 780
768 switch (wacom->features->type) { 781 switch (wacom->features->type) {
769 case GRAPHIRE: 782 case GRAPHIRE:
770 wacom->dev.evbit[0] |= BIT(EV_REL); 783 input_dev->evbit[0] |= BIT(EV_REL);
771 wacom->dev.relbit[0] |= BIT(REL_WHEEL); 784 input_dev->relbit[0] |= BIT(REL_WHEEL);
772 wacom->dev.absbit[0] |= BIT(ABS_DISTANCE); 785 input_dev->keybit[LONG(BTN_LEFT)] |= BIT(BTN_LEFT) | BIT(BTN_RIGHT) | BIT(BTN_MIDDLE);
773 wacom->dev.keybit[LONG(BTN_LEFT)] |= BIT(BTN_LEFT) | BIT(BTN_RIGHT) | BIT(BTN_MIDDLE); 786 input_dev->keybit[LONG(BTN_DIGI)] |= BIT(BTN_TOOL_RUBBER) | BIT(BTN_TOOL_MOUSE) | BIT(BTN_STYLUS2);
774 wacom->dev.keybit[LONG(BTN_DIGI)] |= BIT(BTN_TOOL_RUBBER) | BIT(BTN_TOOL_MOUSE) | BIT(BTN_STYLUS2); 787 input_set_abs_params(input_dev, ABS_DISTANCE, 0, wacom->features->distance_max, 0, 0);
775 break; 788 break;
776 789
777 case INTUOS3: 790 case INTUOS3:
778 case CINTIQ: 791 case CINTIQ:
779 wacom->dev.keybit[LONG(BTN_DIGI)] |= BIT(BTN_TOOL_FINGER); 792 input_dev->keybit[LONG(BTN_DIGI)] |= BIT(BTN_TOOL_FINGER);
780 wacom->dev.keybit[LONG(BTN_LEFT)] |= BIT(BTN_0) | BIT(BTN_1) | BIT(BTN_2) | BIT(BTN_3) | BIT(BTN_4) | BIT(BTN_5) | BIT(BTN_6) | BIT(BTN_7); 793 input_dev->keybit[LONG(BTN_LEFT)] |= BIT(BTN_0) | BIT(BTN_1) | BIT(BTN_2) | BIT(BTN_3) | BIT(BTN_4) | BIT(BTN_5) | BIT(BTN_6) | BIT(BTN_7);
781 wacom->dev.absbit[0] |= BIT(ABS_RX) | BIT(ABS_RY); 794 input_set_abs_params(input_dev, ABS_RX, 0, 4097, 0, 0);
795 input_set_abs_params(input_dev, ABS_RY, 0, 4097, 0, 0);
782 /* fall through */ 796 /* fall through */
783 797
784 case INTUOS: 798 case INTUOS:
785 wacom->dev.evbit[0] |= BIT(EV_MSC) | BIT(EV_REL); 799 input_dev->evbit[0] |= BIT(EV_MSC) | BIT(EV_REL);
786 wacom->dev.mscbit[0] |= BIT(MSC_SERIAL); 800 input_dev->mscbit[0] |= BIT(MSC_SERIAL);
787 wacom->dev.relbit[0] |= BIT(REL_WHEEL); 801 input_dev->relbit[0] |= BIT(REL_WHEEL);
788 wacom->dev.keybit[LONG(BTN_LEFT)] |= BIT(BTN_LEFT) | BIT(BTN_RIGHT) | BIT(BTN_MIDDLE) | BIT(BTN_SIDE) | BIT(BTN_EXTRA); 802 input_dev->keybit[LONG(BTN_LEFT)] |= BIT(BTN_LEFT) | BIT(BTN_RIGHT) | BIT(BTN_MIDDLE) | BIT(BTN_SIDE) | BIT(BTN_EXTRA);
789 wacom->dev.keybit[LONG(BTN_DIGI)] |= BIT(BTN_TOOL_RUBBER) | BIT(BTN_TOOL_MOUSE) | BIT(BTN_TOOL_BRUSH) 803 input_dev->keybit[LONG(BTN_DIGI)] |= BIT(BTN_TOOL_RUBBER) | BIT(BTN_TOOL_MOUSE) | BIT(BTN_TOOL_BRUSH)
790 | BIT(BTN_TOOL_PENCIL) | BIT(BTN_TOOL_AIRBRUSH) | BIT(BTN_TOOL_LENS) | BIT(BTN_STYLUS2); 804 | BIT(BTN_TOOL_PENCIL) | BIT(BTN_TOOL_AIRBRUSH) | BIT(BTN_TOOL_LENS) | BIT(BTN_STYLUS2);
791 wacom->dev.absbit[0] |= BIT(ABS_DISTANCE) | BIT(ABS_WHEEL) | BIT(ABS_TILT_X) | BIT(ABS_TILT_Y) | BIT(ABS_RZ) | BIT(ABS_THROTTLE); 805 input_set_abs_params(input_dev, ABS_DISTANCE, 0, wacom->features->distance_max, 0, 0);
806 input_set_abs_params(input_dev, ABS_WHEEL, 0, 1023, 0, 0);
807 input_set_abs_params(input_dev, ABS_TILT_X, 0, 127, 0, 0);
808 input_set_abs_params(input_dev, ABS_TILT_Y, 0, 127, 0, 0);
809 input_set_abs_params(input_dev, ABS_RZ, -900, 899, 0, 0);
810 input_set_abs_params(input_dev, ABS_THROTTLE, -1023, 1023, 0, 0);
792 break; 811 break;
793 812
794 case PL: 813 case PL:
795 wacom->dev.keybit[LONG(BTN_DIGI)] |= BIT(BTN_STYLUS2) | BIT(BTN_TOOL_RUBBER); 814 input_dev->keybit[LONG(BTN_DIGI)] |= BIT(BTN_STYLUS2) | BIT(BTN_TOOL_RUBBER);
796 break; 815 break;
797 } 816 }
798 817
799 wacom->dev.absmax[ABS_X] = wacom->features->x_max;
800 wacom->dev.absmax[ABS_Y] = wacom->features->y_max;
801 wacom->dev.absmax[ABS_PRESSURE] = wacom->features->pressure_max;
802 wacom->dev.absmax[ABS_DISTANCE] = wacom->features->distance_max;
803 wacom->dev.absmax[ABS_TILT_X] = 127;
804 wacom->dev.absmax[ABS_TILT_Y] = 127;
805 wacom->dev.absmax[ABS_WHEEL] = 1023;
806
807 wacom->dev.absmax[ABS_RX] = 4097;
808 wacom->dev.absmax[ABS_RY] = 4097;
809 wacom->dev.absmin[ABS_RZ] = -900;
810 wacom->dev.absmax[ABS_RZ] = 899;
811 wacom->dev.absmin[ABS_THROTTLE] = -1023;
812 wacom->dev.absmax[ABS_THROTTLE] = 1023;
813
814 wacom->dev.absfuzz[ABS_X] = 4;
815 wacom->dev.absfuzz[ABS_Y] = 4;
816
817 wacom->dev.private = wacom;
818 wacom->dev.open = wacom_open;
819 wacom->dev.close = wacom_close;
820
821 usb_make_path(dev, path, 64);
822 sprintf(wacom->phys, "%s/input0", path);
823
824 wacom->dev.name = wacom->features->name;
825 wacom->dev.phys = wacom->phys;
826 usb_to_input_id(dev, &wacom->dev.id);
827 wacom->dev.dev = &intf->dev;
828 wacom->usbdev = dev;
829
830 endpoint = &intf->cur_altsetting->endpoint[0].desc; 818 endpoint = &intf->cur_altsetting->endpoint[0].desc;
831 819
832 if (wacom->features->pktlen > 10) 820 if (wacom->features->pktlen > 10)
@@ -839,18 +827,20 @@ static int wacom_probe(struct usb_interface *intf, const struct usb_device_id *i
839 wacom->irq->transfer_dma = wacom->data_dma; 827 wacom->irq->transfer_dma = wacom->data_dma;
840 wacom->irq->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; 828 wacom->irq->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
841 829
842 input_register_device(&wacom->dev); 830 input_register_device(wacom->dev);
843 831
844 /* ask the tablet to report tablet data */ 832 /* ask the tablet to report tablet data */
845 usb_set_report(intf, 3, 2, rep_data, 2); 833 usb_set_report(intf, 3, 2, rep_data, 2);
846 /* repeat once (not sure why the first call often fails) */ 834 /* repeat once (not sure why the first call often fails) */
847 usb_set_report(intf, 3, 2, rep_data, 2); 835 usb_set_report(intf, 3, 2, rep_data, 2);
848 836
849 printk(KERN_INFO "input: %s on %s\n", wacom->features->name, path);
850
851 usb_set_intfdata(intf, wacom); 837 usb_set_intfdata(intf, wacom);
852
853 return 0; 838 return 0;
839
840fail2: usb_buffer_free(dev, 10, wacom->data, wacom->data_dma);
841fail1: input_free_device(input_dev);
842 kfree(wacom);
843 return -ENOMEM;
854} 844}
855 845
856static void wacom_disconnect(struct usb_interface *intf) 846static void wacom_disconnect(struct usb_interface *intf)
@@ -860,7 +850,7 @@ static void wacom_disconnect(struct usb_interface *intf)
860 usb_set_intfdata(intf, NULL); 850 usb_set_intfdata(intf, NULL);
861 if (wacom) { 851 if (wacom) {
862 usb_kill_urb(wacom->irq); 852 usb_kill_urb(wacom->irq);
863 input_unregister_device(&wacom->dev); 853 input_unregister_device(wacom->dev);
864 usb_free_urb(wacom->irq); 854 usb_free_urb(wacom->irq);
865 usb_buffer_free(interface_to_usbdev(intf), 10, wacom->data, wacom->data_dma); 855 usb_buffer_free(interface_to_usbdev(intf), 10, wacom->data, wacom->data_dma);
866 kfree(wacom); 856 kfree(wacom);