1 From: Jiri Kosina <jkosina@suse.cz>
2 Subject: Elo USB touchscreen driver
3 Patch-mainline: will be submitted for 2.6.28
4 References: FATE#304972
6 This is a driver for Elo USB touchscreen devices.
8 Signed-off-by: Vojtech Pavlik <vojtech@suse.cz>
9 Acked-by: Jiri Kosina <jkosina@suse.cz>
12 drivers/hid/usbhid/hid-quirks.c | 4
13 drivers/input/touchscreen/Kconfig | 12 +
14 drivers/input/touchscreen/Makefile | 1
15 drivers/input/touchscreen/elousb.c | 305 +++++++++++++++++++++++++++++++++++++
16 4 files changed, 322 insertions(+)
18 --- a/drivers/hid/usbhid/hid-quirks.c
19 +++ b/drivers/hid/usbhid/hid-quirks.c
21 #define USB_DEVICE_ID_DMI_ENC 0x5fab
23 #define USB_VENDOR_ID_ELO 0x04E7
24 +#define USB_DEVICE_ID_ELO_4000U 0x0009
25 #define USB_DEVICE_ID_ELO_TS2700 0x0020
26 +#define USB_DEVICE_ID_ELO_4500U 0x0030
28 #define USB_VENDOR_ID_ESSENTIAL_REALITY 0x0d7f
29 #define USB_DEVICE_ID_ESSENTIAL_REALITY_P5 0x0100
30 @@ -485,6 +487,8 @@ static const struct hid_blacklist {
31 { USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_ULTRAMOUSE, HID_QUIRK_IGNORE },
32 { USB_VENDOR_ID_DELORME, USB_DEVICE_ID_DELORME_EARTHMATE, HID_QUIRK_IGNORE },
33 { USB_VENDOR_ID_DELORME, USB_DEVICE_ID_DELORME_EM_LT20, HID_QUIRK_IGNORE },
34 + { USB_VENDOR_ID_ELO, USB_DEVICE_ID_ELO_4000U, HID_QUIRK_IGNORE },
35 + { USB_VENDOR_ID_ELO, USB_DEVICE_ID_ELO_4500U, HID_QUIRK_IGNORE },
36 { USB_VENDOR_ID_ESSENTIAL_REALITY, USB_DEVICE_ID_ESSENTIAL_REALITY_P5, HID_QUIRK_IGNORE },
37 { USB_VENDOR_ID_GENERAL_TOUCH, 0x0001, HID_QUIRK_IGNORE },
38 { USB_VENDOR_ID_GENERAL_TOUCH, 0x0002, HID_QUIRK_IGNORE },
40 +++ b/drivers/input/touchscreen/elousb.c
43 + * Copyright (c) 1999-2001 Vojtech Pavlik
45 + * Elo USB touchscreen support
49 + * This program is free software; you can redistribute it and/or modify
50 + * it under the terms of the GNU General Public License as published by
51 + * the Free Software Foundation; either version 2 of the License.
53 + * This program is distributed in the hope that it will be useful,
54 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
55 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
56 + * GNU General Public License for more details.
58 + * You should have received a copy of the GNU General Public License
59 + * along with this program; if not, write to the Free Software
60 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
62 + * Should you need to contact me, the author, you can do so either by
63 + * e-mail - mail your message to <vojtech@suse.cz>, or by paper mail:
64 + * Vojtech Pavlik, Simunkova 1594, Prague 8, 182 00 Czech Republic
67 +#include <linux/kernel.h>
68 +#include <linux/slab.h>
69 +#include <linux/module.h>
70 +#include <linux/init.h>
71 +#include <linux/usb.h>
72 +#include <linux/usb/input.h>
73 +#include <linux/hid.h>
74 +#include <linux/input.h>
77 + * Version Information
79 +#define DRIVER_VERSION "v1.1"
80 +#define DRIVER_AUTHOR "Vojtech Pavlik <vojtech@suse.cz>"
81 +#define DRIVER_DESC "Elo USB touchscreen driver"
82 +#define DRIVER_LICENSE "GPL"
84 +MODULE_AUTHOR(DRIVER_AUTHOR);
85 +MODULE_DESCRIPTION(DRIVER_DESC);
86 +MODULE_LICENSE(DRIVER_LICENSE);
91 + struct usb_device *usbdev;
92 + struct input_dev *dev;
95 + unsigned char *data;
96 + dma_addr_t data_dma;
99 +static void elousb_irq(struct urb *urb)
101 + struct elousb *elo = urb->context;
102 + unsigned char *data = elo->data;
103 + struct input_dev *dev = elo->dev;
106 + switch (urb->status) {
107 + case 0: /* success */
109 + case -ECONNRESET: /* unlink */
113 + /* -EPIPE: should clear the halt */
114 + default: /* error */
118 + if (data[0] != 'T') /* Mandatory ELO packet marker */
122 + input_report_abs(dev, ABS_X, ((u32)data[3] << 8) | data[2]);
123 + input_report_abs(dev, ABS_Y, ((u32)data[5] << 8) | data[4]);
125 + input_report_abs(dev, ABS_PRESSURE,
126 + (data[1] & 0x80) ? (((u32)data[7] << 8) | data[6]): 0);
128 + if (data[1] & 0x03) {
129 + input_report_key(dev, BTN_TOUCH, 1);
133 + if (data[1] & 0x04)
134 + input_report_key(dev, BTN_TOUCH, 0);
139 + status = usb_submit_urb (urb, GFP_ATOMIC);
141 + err ("can't resubmit intr, %s-%s/input0, status %d",
142 + elo->usbdev->bus->bus_name,
143 + elo->usbdev->devpath, status);
146 +static int elousb_open(struct input_dev *dev)
148 + struct elousb *elo = input_get_drvdata(dev);
150 + elo->irq->dev = elo->usbdev;
151 + if (usb_submit_urb(elo->irq, GFP_KERNEL))
157 +static void elousb_close(struct input_dev *dev)
159 + struct elousb *elo = input_get_drvdata(dev);
161 + usb_kill_urb(elo->irq);
164 +static int elousb_probe(struct usb_interface *intf, const struct usb_device_id *id)
166 + struct usb_device *dev = interface_to_usbdev(intf);
167 + struct usb_host_interface *interface;
168 + struct usb_endpoint_descriptor *endpoint;
169 + struct hid_descriptor *hdesc;
170 + struct elousb *elo;
171 + struct input_dev *input_dev;
173 + unsigned int rsize = 0;
174 + int error = -ENOMEM;
177 + interface = intf->cur_altsetting;
179 + if (interface->desc.bNumEndpoints != 1)
182 + endpoint = &interface->endpoint[0].desc;
183 + if (!(endpoint->bEndpointAddress & USB_DIR_IN))
185 + if ((endpoint->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) != USB_ENDPOINT_XFER_INT)
188 + if (usb_get_extra_descriptor(interface, HID_DT_HID, &hdesc) &&
189 + (!interface->desc.bNumEndpoints ||
190 + usb_get_extra_descriptor(&interface->endpoint[0], HID_DT_HID, &hdesc))) {
191 + err("HID class descriptor not present");
195 + for (i = 0; i < hdesc->bNumDescriptors; i++)
196 + if (hdesc->desc[i].bDescriptorType == HID_DT_REPORT)
197 + rsize = le16_to_cpu(hdesc->desc[i].wDescriptorLength);
199 + if (!rsize || rsize > HID_MAX_DESCRIPTOR_SIZE) {
200 + err("weird size of report descriptor (%u)", rsize);
205 + pipe = usb_rcvintpipe(dev, endpoint->bEndpointAddress);
207 + elo = kzalloc(sizeof(struct elousb), GFP_KERNEL);
208 + input_dev = input_allocate_device();
209 + if (!elo || !input_dev)
212 + elo->data = usb_buffer_alloc(dev, 8, GFP_ATOMIC, &elo->data_dma);
216 + elo->irq = usb_alloc_urb(0, GFP_KERNEL);
220 + if (!(rdesc = kmalloc(rsize, GFP_KERNEL)))
224 + elo->dev = input_dev;
226 + if ((error = usb_control_msg(dev, usb_sndctrlpipe(dev, 0),
227 + HID_REQ_SET_IDLE, USB_TYPE_CLASS | USB_RECIP_INTERFACE, 0,
228 + interface->desc.bInterfaceNumber,
229 + NULL, 0, USB_CTRL_SET_TIMEOUT)) < 0) {
230 + err("setting HID idle timeout failed, error %d", error);
235 + if ((error = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0),
236 + USB_REQ_GET_DESCRIPTOR, USB_RECIP_INTERFACE | USB_DIR_IN,
237 + HID_DT_REPORT << 8, interface->desc.bInterfaceNumber,
238 + rdesc, rsize, USB_CTRL_GET_TIMEOUT)) < rsize) {
239 + err("reading HID report descriptor failed, error %d", error);
244 + if (dev->manufacturer)
245 + strlcpy(elo->name, dev->manufacturer, sizeof(elo->name));
247 + if (dev->product) {
248 + if (dev->manufacturer)
249 + strlcat(elo->name, " ", sizeof(elo->name));
250 + strlcat(elo->name, dev->product, sizeof(elo->name));
253 + if (!strlen(elo->name))
254 + snprintf(elo->name, sizeof(elo->name),
255 + "Elo touchscreen %04x:%04x",
256 + le16_to_cpu(dev->descriptor.idVendor),
257 + le16_to_cpu(dev->descriptor.idProduct));
259 + usb_make_path(dev, elo->phys, sizeof(elo->phys));
260 + strlcat(elo->phys, "/input0", sizeof(elo->phys));
262 + input_dev->name = elo->name;
263 + input_dev->phys = elo->phys;
264 + usb_to_input_id(dev, &input_dev->id);
265 + input_dev->dev.parent = &intf->dev;
267 + input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS);
268 + set_bit(BTN_TOUCH, input_dev->keybit);
269 + input_dev->absbit[0] = BIT(ABS_X) | BIT(ABS_Y);
270 + set_bit(ABS_PRESSURE, input_dev->absbit);
272 + input_set_abs_params(input_dev, ABS_X, 0, 4000, 0, 0);
273 + input_set_abs_params(input_dev, ABS_Y, 0, 3840, 0, 0);
274 + input_set_abs_params(input_dev, ABS_PRESSURE, 0, 256, 0, 0);
276 + input_set_drvdata(input_dev, elo);
278 + input_dev->open = elousb_open;
279 + input_dev->close = elousb_close;
281 + usb_fill_int_urb(elo->irq, dev, pipe, elo->data, 8,
282 + elousb_irq, elo, endpoint->bInterval);
283 + elo->irq->transfer_dma = elo->data_dma;
284 + elo->irq->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
286 + input_register_device(elo->dev);
288 + usb_set_intfdata(intf, elo);
294 + usb_free_urb(elo->irq);
296 + usb_buffer_free(dev, 8, elo->data, elo->data_dma);
298 + input_free_device(input_dev);
303 +static void elousb_disconnect(struct usb_interface *intf)
305 + struct elousb *elo = usb_get_intfdata (intf);
307 + usb_set_intfdata(intf, NULL);
309 + usb_kill_urb(elo->irq);
310 + input_unregister_device(elo->dev);
311 + usb_free_urb(elo->irq);
312 + usb_buffer_free(interface_to_usbdev(intf), 8, elo->data, elo->data_dma);
317 +static struct usb_device_id elousb_id_table [] = {
318 + { USB_DEVICE(0x04e7, 0x0009) }, /* CarrolTouch 4000U */
319 + { USB_DEVICE(0x04e7, 0x0030) }, /* CarrolTouch 4500U */
320 + { } /* Terminating entry */
323 +MODULE_DEVICE_TABLE (usb, elousb_id_table);
325 +static struct usb_driver elousb_driver = {
327 + .probe = elousb_probe,
328 + .disconnect = elousb_disconnect,
329 + .id_table = elousb_id_table,
332 +static int __init elousb_init(void)
334 + int retval = usb_register(&elousb_driver);
336 + info(DRIVER_VERSION ":" DRIVER_DESC);
340 +static void __exit elousb_exit(void)
342 + usb_deregister(&elousb_driver);
345 +module_init(elousb_init);
346 +module_exit(elousb_exit);
347 --- a/drivers/input/touchscreen/Kconfig
348 +++ b/drivers/input/touchscreen/Kconfig
349 @@ -91,6 +91,18 @@ config TOUCHSCREEN_ELO
350 To compile this driver as a module, choose M here: the
351 module will be called elo.
353 +config TOUCHSCREEN_ELOUSB
354 + tristate "Elo USB touchscreens"
357 + Say Y here if you have an Elo USB touchscreen connected to
362 + To compile this driver as a module, choose M here: the
363 + module will be called elousb.
365 config TOUCHSCREEN_MTOUCH
366 tristate "MicroTouch serial touchscreens"
368 --- a/drivers/input/touchscreen/Makefile
369 +++ b/drivers/input/touchscreen/Makefile
370 @@ -12,6 +12,7 @@ obj-$(CONFIG_TOUCHSCREEN_BITSY) += h360
371 obj-$(CONFIG_TOUCHSCREEN_CORGI) += corgi_ts.o
372 obj-$(CONFIG_TOUCHSCREEN_GUNZE) += gunze.o
373 obj-$(CONFIG_TOUCHSCREEN_ELO) += elo.o
374 +obj-$(CONFIG_TOUCHSCREEN_ELOUSB) += elousb.o
375 obj-$(CONFIG_TOUCHSCREEN_FUJITSU) += fujitsu_ts.o
376 obj-$(CONFIG_TOUCHSCREEN_INEXIO) += inexio.o
377 obj-$(CONFIG_TOUCHSCREEN_MIGOR) += migor_ts.o