usbtouchscreen.c (c67dda14389205f0a223c5089307495290939b3b) usbtouchscreen.c (38771bb440e8c01d07627abc39ac28acbf450cbe)
1/******************************************************************************
2 * usbtouchscreen.c
3 * Driver for USB Touchscreens, supporting those devices:
4 * - eGalax Touchkit
5 * includes eTurboTouch CT-410/510/700
6 * - 3M/Microtouch EX II series
7 * - ITM
8 * - PanJit TouchSet

--- 121 unchanged lines hidden (view full) ---

130 DEVTYPE_DMC_TSC10,
131 DEVTYPE_IRTOUCH,
132 DEVTYPE_IDEALTEK,
133 DEVTYPE_GENERAL_TOUCH,
134 DEVTYPE_GOTOP,
135 DEVTYPE_JASTEC,
136 DEVTYPE_E2I,
137 DEVTYPE_ZYTRONIC,
1/******************************************************************************
2 * usbtouchscreen.c
3 * Driver for USB Touchscreens, supporting those devices:
4 * - eGalax Touchkit
5 * includes eTurboTouch CT-410/510/700
6 * - 3M/Microtouch EX II series
7 * - ITM
8 * - PanJit TouchSet

--- 121 unchanged lines hidden (view full) ---

130 DEVTYPE_DMC_TSC10,
131 DEVTYPE_IRTOUCH,
132 DEVTYPE_IDEALTEK,
133 DEVTYPE_GENERAL_TOUCH,
134 DEVTYPE_GOTOP,
135 DEVTYPE_JASTEC,
136 DEVTYPE_E2I,
137 DEVTYPE_ZYTRONIC,
138 DEVTYPE_TC5UH,
138 DEVTYPE_TC45USB,
139 DEVTYPE_NEXIO,
140};
141
142#define USB_DEVICE_HID_CLASS(vend, prod) \
143 .match_flags = USB_DEVICE_ID_MATCH_INT_CLASS \
144 | USB_DEVICE_ID_MATCH_INT_PROTOCOL \
145 | USB_DEVICE_ID_MATCH_DEVICE, \
146 .idVendor = (vend), \

--- 70 unchanged lines hidden (view full) ---

217#ifdef CONFIG_TOUCHSCREEN_USB_E2I
218 {USB_DEVICE(0x1ac7, 0x0001), .driver_info = DEVTYPE_E2I},
219#endif
220
221#ifdef CONFIG_TOUCHSCREEN_USB_ZYTRONIC
222 {USB_DEVICE(0x14c8, 0x0003), .driver_info = DEVTYPE_ZYTRONIC},
223#endif
224
139 DEVTYPE_NEXIO,
140};
141
142#define USB_DEVICE_HID_CLASS(vend, prod) \
143 .match_flags = USB_DEVICE_ID_MATCH_INT_CLASS \
144 | USB_DEVICE_ID_MATCH_INT_PROTOCOL \
145 | USB_DEVICE_ID_MATCH_DEVICE, \
146 .idVendor = (vend), \

--- 70 unchanged lines hidden (view full) ---

217#ifdef CONFIG_TOUCHSCREEN_USB_E2I
218 {USB_DEVICE(0x1ac7, 0x0001), .driver_info = DEVTYPE_E2I},
219#endif
220
221#ifdef CONFIG_TOUCHSCREEN_USB_ZYTRONIC
222 {USB_DEVICE(0x14c8, 0x0003), .driver_info = DEVTYPE_ZYTRONIC},
223#endif
224
225#ifdef CONFIG_TOUCHSCREEN_USB_ETT_TC5UH
226 {USB_DEVICE(0x0664, 0x0309), .driver_info = DEVTYPE_TC5UH},
225#ifdef CONFIG_TOUCHSCREEN_USB_ETT_TC45USB
226 /* TC5UH */
227 {USB_DEVICE(0x0664, 0x0309), .driver_info = DEVTYPE_TC45USB},
228 /* TC4UM */
229 {USB_DEVICE(0x0664, 0x0306), .driver_info = DEVTYPE_TC45USB},
227#endif
228
229#ifdef CONFIG_TOUCHSCREEN_USB_NEXIO
230 /* data interface only */
231 {USB_DEVICE_AND_INTERFACE_INFO(0x10f0, 0x2002, 0x0a, 0x00, 0x00),
232 .driver_info = DEVTYPE_NEXIO},
233 {USB_DEVICE_AND_INTERFACE_INFO(0x1870, 0x0001, 0x0a, 0x00, 0x00),
234 .driver_info = DEVTYPE_NEXIO},

--- 334 unchanged lines hidden (view full) ---

569 dev->y = (pkt[5] << 8) | pkt[4];
570 dev->touch = (pkt[1] & 0x03) ? 1 : 0;
571
572 return 1;
573}
574#endif
575
576/*****************************************************************************
230#endif
231
232#ifdef CONFIG_TOUCHSCREEN_USB_NEXIO
233 /* data interface only */
234 {USB_DEVICE_AND_INTERFACE_INFO(0x10f0, 0x2002, 0x0a, 0x00, 0x00),
235 .driver_info = DEVTYPE_NEXIO},
236 {USB_DEVICE_AND_INTERFACE_INFO(0x1870, 0x0001, 0x0a, 0x00, 0x00),
237 .driver_info = DEVTYPE_NEXIO},

--- 334 unchanged lines hidden (view full) ---

572 dev->y = (pkt[5] << 8) | pkt[4];
573 dev->touch = (pkt[1] & 0x03) ? 1 : 0;
574
575 return 1;
576}
577#endif
578
579/*****************************************************************************
577 * ET&T TC5UH part
580 * ET&T TC5UH/TC4UM part
578 */
581 */
579#ifdef CONFIG_TOUCHSCREEN_USB_ETT_TC5UH
580static int tc5uh_read_data(struct usbtouch_usb *dev, unsigned char *pkt)
582#ifdef CONFIG_TOUCHSCREEN_USB_ETT_TC45USB
583static int tc45usb_read_data(struct usbtouch_usb *dev, unsigned char *pkt)
581{
582 dev->x = ((pkt[2] & 0x0F) << 8) | pkt[1];
583 dev->y = ((pkt[4] & 0x0F) << 8) | pkt[3];
584 dev->touch = pkt[0] & 0x01;
585
586 return 1;
587}
588#endif

--- 255 unchanged lines hidden (view full) ---

844 usb_kill_urb(priv->ack);
845 usb_free_urb(priv->ack);
846 kfree(priv->ack_buf);
847 kfree(priv);
848}
849
850static int nexio_read_data(struct usbtouch_usb *usbtouch, unsigned char *pkt)
851{
584{
585 dev->x = ((pkt[2] & 0x0F) << 8) | pkt[1];
586 dev->y = ((pkt[4] & 0x0F) << 8) | pkt[3];
587 dev->touch = pkt[0] & 0x01;
588
589 return 1;
590}
591#endif

--- 255 unchanged lines hidden (view full) ---

847 usb_kill_urb(priv->ack);
848 usb_free_urb(priv->ack);
849 kfree(priv->ack_buf);
850 kfree(priv);
851}
852
853static int nexio_read_data(struct usbtouch_usb *usbtouch, unsigned char *pkt)
854{
852 int x, y, begin_x, begin_y, end_x, end_y, w, h, ret;
853 struct nexio_touch_packet *packet = (void *) pkt;
854 struct nexio_priv *priv = usbtouch->priv;
855 struct nexio_touch_packet *packet = (void *) pkt;
856 struct nexio_priv *priv = usbtouch->priv;
857 unsigned int data_len = be16_to_cpu(packet->data_len);
858 unsigned int x_len = be16_to_cpu(packet->x_len);
859 unsigned int y_len = be16_to_cpu(packet->y_len);
860 int x, y, begin_x, begin_y, end_x, end_y, w, h, ret;
855
856 /* got touch data? */
857 if ((pkt[0] & 0xe0) != 0xe0)
858 return 0;
859
861
862 /* got touch data? */
863 if ((pkt[0] & 0xe0) != 0xe0)
864 return 0;
865
860 if (be16_to_cpu(packet->data_len) > 0xff)
861 packet->data_len = cpu_to_be16(be16_to_cpu(packet->data_len) - 0x100);
862 if (be16_to_cpu(packet->x_len) > 0xff)
863 packet->x_len = cpu_to_be16(be16_to_cpu(packet->x_len) - 0x80);
866 if (data_len > 0xff)
867 data_len -= 0x100;
868 if (x_len > 0xff)
869 x_len -= 0x80;
864
865 /* send ACK */
866 ret = usb_submit_urb(priv->ack, GFP_ATOMIC);
867
868 if (!usbtouch->type->max_xc) {
870
871 /* send ACK */
872 ret = usb_submit_urb(priv->ack, GFP_ATOMIC);
873
874 if (!usbtouch->type->max_xc) {
869 usbtouch->type->max_xc = 2 * be16_to_cpu(packet->x_len);
870 input_set_abs_params(usbtouch->input, ABS_X, 0,
871 2 * be16_to_cpu(packet->x_len), 0, 0);
872 usbtouch->type->max_yc = 2 * be16_to_cpu(packet->y_len);
873 input_set_abs_params(usbtouch->input, ABS_Y, 0,
874 2 * be16_to_cpu(packet->y_len), 0, 0);
875 usbtouch->type->max_xc = 2 * x_len;
876 input_set_abs_params(usbtouch->input, ABS_X,
877 0, usbtouch->type->max_xc, 0, 0);
878 usbtouch->type->max_yc = 2 * y_len;
879 input_set_abs_params(usbtouch->input, ABS_Y,
880 0, usbtouch->type->max_yc, 0, 0);
875 }
876 /*
877 * The device reports state of IR sensors on X and Y axes.
878 * Each byte represents "darkness" percentage (0-100) of one element.
879 * 17" touchscreen reports only 64 x 52 bytes so the resolution is low.
880 * This also means that there's a limited multi-touch capability but
881 * it's disabled (and untested) here as there's no X driver for that.
882 */
883 begin_x = end_x = begin_y = end_y = -1;
881 }
882 /*
883 * The device reports state of IR sensors on X and Y axes.
884 * Each byte represents "darkness" percentage (0-100) of one element.
885 * 17" touchscreen reports only 64 x 52 bytes so the resolution is low.
886 * This also means that there's a limited multi-touch capability but
887 * it's disabled (and untested) here as there's no X driver for that.
888 */
889 begin_x = end_x = begin_y = end_y = -1;
884 for (x = 0; x < be16_to_cpu(packet->x_len); x++) {
890 for (x = 0; x < x_len; x++) {
885 if (begin_x == -1 && packet->data[x] > NEXIO_THRESHOLD) {
886 begin_x = x;
887 continue;
888 }
889 if (end_x == -1 && begin_x != -1 && packet->data[x] < NEXIO_THRESHOLD) {
890 end_x = x - 1;
891 if (begin_x == -1 && packet->data[x] > NEXIO_THRESHOLD) {
892 begin_x = x;
893 continue;
894 }
895 if (end_x == -1 && begin_x != -1 && packet->data[x] < NEXIO_THRESHOLD) {
896 end_x = x - 1;
891 for (y = be16_to_cpu(packet->x_len);
892 y < be16_to_cpu(packet->data_len); y++) {
897 for (y = x_len; y < data_len; y++) {
893 if (begin_y == -1 && packet->data[y] > NEXIO_THRESHOLD) {
898 if (begin_y == -1 && packet->data[y] > NEXIO_THRESHOLD) {
894 begin_y = y - be16_to_cpu(packet->x_len);
899 begin_y = y - x_len;
895 continue;
896 }
897 if (end_y == -1 &&
898 begin_y != -1 && packet->data[y] < NEXIO_THRESHOLD) {
900 continue;
901 }
902 if (end_y == -1 &&
903 begin_y != -1 && packet->data[y] < NEXIO_THRESHOLD) {
899 end_y = y - 1 - be16_to_cpu(packet->x_len);
904 end_y = y - 1 - x_len;
900 w = end_x - begin_x;
901 h = end_y - begin_y;
902#if 0
903 /* multi-touch */
904 input_report_abs(usbtouch->input,
905 ABS_MT_TOUCH_MAJOR, max(w,h));
906 input_report_abs(usbtouch->input,
907 ABS_MT_TOUCH_MINOR, min(x,h));

--- 191 unchanged lines hidden (view full) ---

1099 .min_yc = 0x0,
1100 .max_yc = 0x03ff,
1101 .rept_size = 5,
1102 .read_data = zytronic_read_data,
1103 .irq_always = true,
1104 },
1105#endif
1106
905 w = end_x - begin_x;
906 h = end_y - begin_y;
907#if 0
908 /* multi-touch */
909 input_report_abs(usbtouch->input,
910 ABS_MT_TOUCH_MAJOR, max(w,h));
911 input_report_abs(usbtouch->input,
912 ABS_MT_TOUCH_MINOR, min(x,h));

--- 191 unchanged lines hidden (view full) ---

1104 .min_yc = 0x0,
1105 .max_yc = 0x03ff,
1106 .rept_size = 5,
1107 .read_data = zytronic_read_data,
1108 .irq_always = true,
1109 },
1110#endif
1111
1107#ifdef CONFIG_TOUCHSCREEN_USB_ETT_TC5UH
1108 [DEVTYPE_TC5UH] = {
1112#ifdef CONFIG_TOUCHSCREEN_USB_ETT_TC45USB
1113 [DEVTYPE_TC45USB] = {
1109 .min_xc = 0x0,
1110 .max_xc = 0x0fff,
1111 .min_yc = 0x0,
1112 .max_yc = 0x0fff,
1113 .rept_size = 5,
1114 .min_xc = 0x0,
1115 .max_xc = 0x0fff,
1116 .min_yc = 0x0,
1117 .max_yc = 0x0fff,
1118 .rept_size = 5,
1114 .read_data = tc5uh_read_data,
1119 .read_data = tc45usb_read_data,
1115 },
1116#endif
1117
1118#ifdef CONFIG_TOUCHSCREEN_USB_NEXIO
1119 [DEVTYPE_NEXIO] = {
1120 .rept_size = 1024,
1121 .irq_always = true,
1122 .read_data = nexio_read_data,

--- 384 unchanged lines hidden ---
1120 },
1121#endif
1122
1123#ifdef CONFIG_TOUCHSCREEN_USB_NEXIO
1124 [DEVTYPE_NEXIO] = {
1125 .rept_size = 1024,
1126 .irq_always = true,
1127 .read_data = nexio_read_data,

--- 384 unchanged lines hidden ---