aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/usb/input/Makefile3
-rw-r--r--drivers/usb/input/itmtouch.c271
-rw-r--r--drivers/usb/input/mtouchusb.c332
-rw-r--r--drivers/usb/input/touchkitusb.c392
4 files changed, 0 insertions, 998 deletions
diff --git a/drivers/usb/input/Makefile b/drivers/usb/input/Makefile
index a9d206c945e9..f8c35b66c466 100644
--- a/drivers/usb/input/Makefile
+++ b/drivers/usb/input/Makefile
@@ -38,9 +38,6 @@ obj-$(CONFIG_USB_KBD) += usbkbd.o
38obj-$(CONFIG_USB_KBTAB) += kbtab.o 38obj-$(CONFIG_USB_KBTAB) += kbtab.o
39obj-$(CONFIG_USB_KEYSPAN_REMOTE) += keyspan_remote.o 39obj-$(CONFIG_USB_KEYSPAN_REMOTE) += keyspan_remote.o
40obj-$(CONFIG_USB_MOUSE) += usbmouse.o 40obj-$(CONFIG_USB_MOUSE) += usbmouse.o
41obj-$(CONFIG_USB_MTOUCH) += mtouchusb.o
42obj-$(CONFIG_USB_ITMTOUCH) += itmtouch.o
43obj-$(CONFIG_USB_EGALAX) += touchkitusb.o
44obj-$(CONFIG_USB_TOUCHSCREEN) += usbtouchscreen.o 41obj-$(CONFIG_USB_TOUCHSCREEN) += usbtouchscreen.o
45obj-$(CONFIG_USB_POWERMATE) += powermate.o 42obj-$(CONFIG_USB_POWERMATE) += powermate.o
46obj-$(CONFIG_USB_WACOM) += wacom.o 43obj-$(CONFIG_USB_WACOM) += wacom.o
diff --git a/drivers/usb/input/itmtouch.c b/drivers/usb/input/itmtouch.c
deleted file mode 100644
index aac968aab860..000000000000
--- a/drivers/usb/input/itmtouch.c
+++ /dev/null
@@ -1,271 +0,0 @@
1/******************************************************************************
2 * itmtouch.c -- Driver for ITM touchscreen panel
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation; either version 2 of the
7 * License, or (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17 *
18 * Based upon original work by Chris Collins <xfire-itmtouch@xware.cx>.
19 *
20 * Kudos to ITM for providing me with the datasheet for the panel,
21 * even though it was a day later than I had finished writing this
22 * driver.
23 *
24 * It has meant that I've been able to correct my interpretation of the
25 * protocol packets however.
26 *
27 * CC -- 2003/9/29
28 *
29 * History
30 * 1.0 & 1.1 2003 (CC) vojtech@suse.cz
31 * Original version for 2.4.x kernels
32 *
33 * 1.2 02/03/2005 (HCE) hc@mivu.no
34 * Complete rewrite to support Linux 2.6.10, thanks to mtouchusb.c for hints.
35 * Unfortunately no calibration support at this time.
36 *
37 * 1.2.1 09/03/2005 (HCE) hc@mivu.no
38 * Code cleanup and adjusting syntax to start matching kernel standards
39 *
40 * 1.2.2 10/05/2006 (MJA) massad@gmail.com
41 * Flag for detecting if the screen was being touch was incorrectly
42 * inverted, so no touch events were being detected.
43 *
44 *****************************************************************************/
45
46#include <linux/kernel.h>
47#include <linux/slab.h>
48#include <linux/module.h>
49#include <linux/init.h>
50#include <linux/usb/input.h>
51
52/* only an 8 byte buffer necessary for a single packet */
53#define ITM_BUFSIZE 8
54#define PATH_SIZE 64
55
56#define USB_VENDOR_ID_ITMINC 0x0403
57#define USB_PRODUCT_ID_TOUCHPANEL 0xf9e9
58
59#define DRIVER_AUTHOR "Hans-Christian Egtvedt <hc@mivu.no>"
60#define DRIVER_VERSION "v1.2.2"
61#define DRIVER_DESC "USB ITM Inc Touch Panel Driver"
62#define DRIVER_LICENSE "GPL"
63
64MODULE_AUTHOR( DRIVER_AUTHOR );
65MODULE_DESCRIPTION( DRIVER_DESC );
66MODULE_LICENSE( DRIVER_LICENSE );
67
68struct itmtouch_dev {
69 struct usb_device *usbdev; /* usb device */
70 struct input_dev *inputdev; /* input device */
71 struct urb *readurb; /* urb */
72 char rbuf[ITM_BUFSIZE]; /* data */
73 int users;
74 char name[128];
75 char phys[64];
76};
77
78static struct usb_device_id itmtouch_ids [] = {
79 { USB_DEVICE(USB_VENDOR_ID_ITMINC, USB_PRODUCT_ID_TOUCHPANEL) },
80 { }
81};
82
83static void itmtouch_irq(struct urb *urb)
84{
85 struct itmtouch_dev *itmtouch = urb->context;
86 unsigned char *data = urb->transfer_buffer;
87 struct input_dev *dev = itmtouch->inputdev;
88 int retval;
89
90 switch (urb->status) {
91 case 0:
92 /* success */
93 break;
94 case -ETIME:
95 /* this urb is timing out */
96 dbg("%s - urb timed out - was the device unplugged?",
97 __FUNCTION__);
98 return;
99 case -ECONNRESET:
100 case -ENOENT:
101 case -ESHUTDOWN:
102 /* this urb is terminated, clean up */
103 dbg("%s - urb shutting down with status: %d",
104 __FUNCTION__, urb->status);
105 return;
106 default:
107 dbg("%s - nonzero urb status received: %d",
108 __FUNCTION__, urb->status);
109 goto exit;
110 }
111
112 /* if pressure has been released, then don't report X/Y */
113 if (!(data[7] & 0x20)) {
114 input_report_abs(dev, ABS_X, (data[0] & 0x1F) << 7 | (data[3] & 0x7F));
115 input_report_abs(dev, ABS_Y, (data[1] & 0x1F) << 7 | (data[4] & 0x7F));
116 }
117
118 input_report_abs(dev, ABS_PRESSURE, (data[2] & 1) << 7 | (data[5] & 0x7F));
119 input_report_key(dev, BTN_TOUCH, ~data[7] & 0x20);
120 input_sync(dev);
121
122exit:
123 retval = usb_submit_urb (urb, GFP_ATOMIC);
124 if (retval)
125 printk(KERN_ERR "%s - usb_submit_urb failed with result: %d",
126 __FUNCTION__, retval);
127}
128
129static int itmtouch_open(struct input_dev *input)
130{
131 struct itmtouch_dev *itmtouch = input->private;
132
133 itmtouch->readurb->dev = itmtouch->usbdev;
134
135 if (usb_submit_urb(itmtouch->readurb, GFP_KERNEL))
136 return -EIO;
137
138 return 0;
139}
140
141static void itmtouch_close(struct input_dev *input)
142{
143 struct itmtouch_dev *itmtouch = input->private;
144
145 usb_kill_urb(itmtouch->readurb);
146}
147
148static int itmtouch_probe(struct usb_interface *intf, const struct usb_device_id *id)
149{
150 struct itmtouch_dev *itmtouch;
151 struct input_dev *input_dev;
152 struct usb_host_interface *interface;
153 struct usb_endpoint_descriptor *endpoint;
154 struct usb_device *udev = interface_to_usbdev(intf);
155 unsigned int pipe;
156 unsigned int maxp;
157
158 interface = intf->cur_altsetting;
159 endpoint = &interface->endpoint[0].desc;
160
161 itmtouch = kzalloc(sizeof(struct itmtouch_dev), GFP_KERNEL);
162 input_dev = input_allocate_device();
163 if (!itmtouch || !input_dev) {
164 err("%s - Out of memory.", __FUNCTION__);
165 goto fail;
166 }
167
168 itmtouch->usbdev = udev;
169 itmtouch->inputdev = input_dev;
170
171 if (udev->manufacturer)
172 strlcpy(itmtouch->name, udev->manufacturer, sizeof(itmtouch->name));
173
174 if (udev->product) {
175 if (udev->manufacturer)
176 strlcat(itmtouch->name, " ", sizeof(itmtouch->name));
177 strlcat(itmtouch->name, udev->product, sizeof(itmtouch->name));
178 }
179
180 if (!strlen(itmtouch->name))
181 sprintf(itmtouch->name, "USB ITM touchscreen");
182
183 usb_make_path(udev, itmtouch->phys, sizeof(itmtouch->phys));
184 strlcpy(itmtouch->phys, "/input0", sizeof(itmtouch->phys));
185
186 input_dev->name = itmtouch->name;
187 input_dev->phys = itmtouch->phys;
188 usb_to_input_id(udev, &input_dev->id);
189 input_dev->cdev.dev = &intf->dev;
190 input_dev->private = itmtouch;
191
192 input_dev->open = itmtouch_open;
193 input_dev->close = itmtouch_close;
194
195 input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS);
196 input_dev->absbit[0] = BIT(ABS_X) | BIT(ABS_Y) | BIT(ABS_PRESSURE);
197 input_dev->keybit[LONG(BTN_TOUCH)] = BIT(BTN_TOUCH);
198
199 /* device limits */
200 /* as specified by the ITM datasheet, X and Y are 12bit,
201 * Z (pressure) is 8 bit. However, the fields are defined up
202 * to 14 bits for future possible expansion.
203 */
204 input_set_abs_params(input_dev, ABS_X, 0, 0x0FFF, 2, 0);
205 input_set_abs_params(input_dev, ABS_Y, 0, 0x0FFF, 2, 0);
206 input_set_abs_params(input_dev, ABS_PRESSURE, 0, 0xFF, 2, 0);
207
208 /* initialise the URB so we can read from the transport stream */
209 pipe = usb_rcvintpipe(itmtouch->usbdev, endpoint->bEndpointAddress);
210 maxp = usb_maxpacket(udev, pipe, usb_pipeout(pipe));
211
212 if (maxp > ITM_BUFSIZE)
213 maxp = ITM_BUFSIZE;
214
215 itmtouch->readurb = usb_alloc_urb(0, GFP_KERNEL);
216 if (!itmtouch->readurb) {
217 dbg("%s - usb_alloc_urb failed: itmtouch->readurb", __FUNCTION__);
218 goto fail;
219 }
220
221 usb_fill_int_urb(itmtouch->readurb, itmtouch->usbdev, pipe, itmtouch->rbuf,
222 maxp, itmtouch_irq, itmtouch, endpoint->bInterval);
223
224 input_register_device(itmtouch->inputdev);
225
226 usb_set_intfdata(intf, itmtouch);
227
228 return 0;
229
230 fail: input_free_device(input_dev);
231 kfree(itmtouch);
232 return -ENOMEM;
233}
234
235static void itmtouch_disconnect(struct usb_interface *intf)
236{
237 struct itmtouch_dev *itmtouch = usb_get_intfdata(intf);
238
239 usb_set_intfdata(intf, NULL);
240
241 if (itmtouch) {
242 input_unregister_device(itmtouch->inputdev);
243 usb_kill_urb(itmtouch->readurb);
244 usb_free_urb(itmtouch->readurb);
245 kfree(itmtouch);
246 }
247}
248
249MODULE_DEVICE_TABLE(usb, itmtouch_ids);
250
251static struct usb_driver itmtouch_driver = {
252 .name = "itmtouch",
253 .probe = itmtouch_probe,
254 .disconnect = itmtouch_disconnect,
255 .id_table = itmtouch_ids,
256};
257
258static int __init itmtouch_init(void)
259{
260 info(DRIVER_DESC " " DRIVER_VERSION);
261 info(DRIVER_AUTHOR);
262 return usb_register(&itmtouch_driver);
263}
264
265static void __exit itmtouch_exit(void)
266{
267 usb_deregister(&itmtouch_driver);
268}
269
270module_init(itmtouch_init);
271module_exit(itmtouch_exit);
diff --git a/drivers/usb/input/mtouchusb.c b/drivers/usb/input/mtouchusb.c
deleted file mode 100644
index 92c4e07da4c8..000000000000
--- a/drivers/usb/input/mtouchusb.c
+++ /dev/null
@@ -1,332 +0,0 @@
1/******************************************************************************
2 * mtouchusb.c -- Driver for Microtouch (Now 3M) USB Touchscreens
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation; either version 2 of the
7 * License, or (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17 *
18 * Based upon original work by Radoslaw Garbacz (usb-support@ite.pl)
19 * (http://freshmeat.net/projects/3mtouchscreendriver)
20 *
21 * History
22 *
23 * 0.3 & 0.4 2002 (TEJ) tejohnson@yahoo.com
24 * Updated to 2.4.18, then 2.4.19
25 * Old version still relied on stealing a minor
26 *
27 * 0.5 02/26/2004 (TEJ) tejohnson@yahoo.com
28 * Complete rewrite using Linux Input in 2.6.3
29 * Unfortunately no calibration support at this time
30 *
31 * 1.4 04/25/2004 (TEJ) tejohnson@yahoo.com
32 * Changed reset from standard USB dev reset to vendor reset
33 * Changed data sent to host from compensated to raw coordinates
34 * Eliminated vendor/product module params
35 * Performed multiple successful tests with an EXII-5010UC
36 *
37 * 1.5 02/27/2005 ddstreet@ieee.org
38 * Added module parameter to select raw or hw-calibrated coordinate reporting
39 *
40 *****************************************************************************/
41
42#include <linux/kernel.h>
43#include <linux/slab.h>
44#include <linux/module.h>
45#include <linux/init.h>
46#include <linux/usb/input.h>
47
48#define MTOUCHUSB_MIN_XC 0x0
49#define MTOUCHUSB_MAX_RAW_XC 0x4000
50#define MTOUCHUSB_MAX_CALIB_XC 0xffff
51#define MTOUCHUSB_XC_FUZZ 0x0
52#define MTOUCHUSB_XC_FLAT 0x0
53#define MTOUCHUSB_MIN_YC 0x0
54#define MTOUCHUSB_MAX_RAW_YC 0x4000
55#define MTOUCHUSB_MAX_CALIB_YC 0xffff
56#define MTOUCHUSB_YC_FUZZ 0x0
57#define MTOUCHUSB_YC_FLAT 0x0
58
59#define MTOUCHUSB_ASYNC_REPORT 1
60#define MTOUCHUSB_RESET 7
61#define MTOUCHUSB_REPORT_DATA_SIZE 11
62#define MTOUCHUSB_REQ_CTRLLR_ID 10
63
64#define MTOUCHUSB_GET_RAW_XC(data) (data[8]<<8 | data[7])
65#define MTOUCHUSB_GET_CALIB_XC(data) (data[4]<<8 | data[3])
66#define MTOUCHUSB_GET_RAW_YC(data) (data[10]<<8 | data[9])
67#define MTOUCHUSB_GET_CALIB_YC(data) (data[6]<<8 | data[5])
68#define MTOUCHUSB_GET_XC(data) (raw_coordinates ? \
69 MTOUCHUSB_GET_RAW_XC(data) : \
70 MTOUCHUSB_GET_CALIB_XC(data))
71#define MTOUCHUSB_GET_YC(data) (raw_coordinates ? \
72 MTOUCHUSB_GET_RAW_YC(data) : \
73 MTOUCHUSB_GET_CALIB_YC(data))
74#define MTOUCHUSB_GET_TOUCHED(data) ((data[2] & 0x40) ? 1:0)
75
76#define DRIVER_VERSION "v1.5"
77#define DRIVER_AUTHOR "Todd E. Johnson, tejohnson@yahoo.com"
78#define DRIVER_DESC "3M USB Touchscreen Driver"
79#define DRIVER_LICENSE "GPL"
80
81static int raw_coordinates = 1;
82
83module_param(raw_coordinates, bool, S_IRUGO | S_IWUSR);
84MODULE_PARM_DESC(raw_coordinates, "report raw coordinate values (y, default) or hardware-calibrated coordinate values (n)");
85
86struct mtouch_usb {
87 unsigned char *data;
88 dma_addr_t data_dma;
89 struct urb *irq;
90 struct usb_device *udev;
91 struct input_dev *input;
92 char name[128];
93 char phys[64];
94};
95
96static struct usb_device_id mtouchusb_devices[] = {
97 { USB_DEVICE(0x0596, 0x0001) },
98 { }
99};
100
101static void mtouchusb_irq(struct urb *urb)
102{
103 struct mtouch_usb *mtouch = urb->context;
104 int retval;
105
106 switch (urb->status) {
107 case 0:
108 /* success */
109 break;
110 case -ETIME:
111 /* this urb is timing out */
112 dbg("%s - urb timed out - was the device unplugged?",
113 __FUNCTION__);
114 return;
115 case -ECONNRESET:
116 case -ENOENT:
117 case -ESHUTDOWN:
118 /* this urb is terminated, clean up */
119 dbg("%s - urb shutting down with status: %d",
120 __FUNCTION__, urb->status);
121 return;
122 default:
123 dbg("%s - nonzero urb status received: %d",
124 __FUNCTION__, urb->status);
125 goto exit;
126 }
127
128 input_report_key(mtouch->input, BTN_TOUCH,
129 MTOUCHUSB_GET_TOUCHED(mtouch->data));
130 input_report_abs(mtouch->input, ABS_X, MTOUCHUSB_GET_XC(mtouch->data));
131 input_report_abs(mtouch->input, ABS_Y,
132 (raw_coordinates ? MTOUCHUSB_MAX_RAW_YC : MTOUCHUSB_MAX_CALIB_YC)
133 - MTOUCHUSB_GET_YC(mtouch->data));
134 input_sync(mtouch->input);
135
136exit:
137 retval = usb_submit_urb(urb, GFP_ATOMIC);
138 if (retval)
139 err("%s - usb_submit_urb failed with result: %d",
140 __FUNCTION__, retval);
141}
142
143static int mtouchusb_open(struct input_dev *input)
144{
145 struct mtouch_usb *mtouch = input->private;
146
147 mtouch->irq->dev = mtouch->udev;
148
149 if (usb_submit_urb(mtouch->irq, GFP_ATOMIC))
150 return -EIO;
151
152 return 0;
153}
154
155static void mtouchusb_close(struct input_dev *input)
156{
157 struct mtouch_usb *mtouch = input->private;
158
159 usb_kill_urb(mtouch->irq);
160}
161
162static int mtouchusb_alloc_buffers(struct usb_device *udev, struct mtouch_usb *mtouch)
163{
164 dbg("%s - called", __FUNCTION__);
165
166 mtouch->data = usb_buffer_alloc(udev, MTOUCHUSB_REPORT_DATA_SIZE,
167 GFP_ATOMIC, &mtouch->data_dma);
168
169 if (!mtouch->data)
170 return -1;
171
172 return 0;
173}
174
175static void mtouchusb_free_buffers(struct usb_device *udev, struct mtouch_usb *mtouch)
176{
177 dbg("%s - called", __FUNCTION__);
178
179 if (mtouch->data)
180 usb_buffer_free(udev, MTOUCHUSB_REPORT_DATA_SIZE,
181 mtouch->data, mtouch->data_dma);
182}
183
184static int mtouchusb_probe(struct usb_interface *intf, const struct usb_device_id *id)
185{
186 struct mtouch_usb *mtouch;
187 struct input_dev *input_dev;
188 struct usb_host_interface *interface;
189 struct usb_endpoint_descriptor *endpoint;
190 struct usb_device *udev = interface_to_usbdev(intf);
191 int nRet;
192
193 dbg("%s - called", __FUNCTION__);
194
195 dbg("%s - setting interface", __FUNCTION__);
196 interface = intf->cur_altsetting;
197
198 dbg("%s - setting endpoint", __FUNCTION__);
199 endpoint = &interface->endpoint[0].desc;
200
201 mtouch = kzalloc(sizeof(struct mtouch_usb), GFP_KERNEL);
202 input_dev = input_allocate_device();
203 if (!mtouch || !input_dev) {
204 err("%s - Out of memory.", __FUNCTION__);
205 goto fail1;
206 }
207
208 dbg("%s - allocating buffers", __FUNCTION__);
209 if (mtouchusb_alloc_buffers(udev, mtouch))
210 goto fail2;
211
212 mtouch->udev = udev;
213 mtouch->input = input_dev;
214
215 if (udev->manufacturer)
216 strlcpy(mtouch->name, udev->manufacturer, sizeof(mtouch->name));
217
218 if (udev->product) {
219 if (udev->manufacturer)
220 strlcat(mtouch->name, " ", sizeof(mtouch->name));
221 strlcat(mtouch->name, udev->product, sizeof(mtouch->name));
222 }
223
224 if (!strlen(mtouch->name))
225 snprintf(mtouch->name, sizeof(mtouch->name),
226 "USB Touchscreen %04x:%04x",
227 le16_to_cpu(udev->descriptor.idVendor),
228 le16_to_cpu(udev->descriptor.idProduct));
229
230 usb_make_path(udev, mtouch->phys, sizeof(mtouch->phys));
231 strlcpy(mtouch->phys, "/input0", sizeof(mtouch->phys));
232
233 input_dev->name = mtouch->name;
234 input_dev->phys = mtouch->phys;
235 usb_to_input_id(udev, &input_dev->id);
236 input_dev->cdev.dev = &intf->dev;
237 input_dev->private = mtouch;
238
239 input_dev->open = mtouchusb_open;
240 input_dev->close = mtouchusb_close;
241
242 input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS);
243 input_dev->keybit[LONG(BTN_TOUCH)] = BIT(BTN_TOUCH);
244 input_set_abs_params(input_dev, ABS_X, MTOUCHUSB_MIN_XC,
245 raw_coordinates ? MTOUCHUSB_MAX_RAW_XC : MTOUCHUSB_MAX_CALIB_XC,
246 MTOUCHUSB_XC_FUZZ, MTOUCHUSB_XC_FLAT);
247 input_set_abs_params(input_dev, ABS_Y, MTOUCHUSB_MIN_YC,
248 raw_coordinates ? MTOUCHUSB_MAX_RAW_YC : MTOUCHUSB_MAX_CALIB_YC,
249 MTOUCHUSB_YC_FUZZ, MTOUCHUSB_YC_FLAT);
250
251 nRet = usb_control_msg(mtouch->udev, usb_rcvctrlpipe(udev, 0),
252 MTOUCHUSB_RESET,
253 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
254 1, 0, NULL, 0, USB_CTRL_SET_TIMEOUT);
255 dbg("%s - usb_control_msg - MTOUCHUSB_RESET - bytes|err: %d",
256 __FUNCTION__, nRet);
257
258 dbg("%s - usb_alloc_urb: mtouch->irq", __FUNCTION__);
259 mtouch->irq = usb_alloc_urb(0, GFP_KERNEL);
260 if (!mtouch->irq) {
261 dbg("%s - usb_alloc_urb failed: mtouch->irq", __FUNCTION__);
262 goto fail2;
263 }
264
265 dbg("%s - usb_fill_int_urb", __FUNCTION__);
266 usb_fill_int_urb(mtouch->irq, mtouch->udev,
267 usb_rcvintpipe(mtouch->udev, 0x81),
268 mtouch->data, MTOUCHUSB_REPORT_DATA_SIZE,
269 mtouchusb_irq, mtouch, endpoint->bInterval);
270
271 dbg("%s - input_register_device", __FUNCTION__);
272 input_register_device(mtouch->input);
273
274 nRet = usb_control_msg(mtouch->udev, usb_rcvctrlpipe(udev, 0),
275 MTOUCHUSB_ASYNC_REPORT,
276 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
277 1, 1, NULL, 0, USB_CTRL_SET_TIMEOUT);
278 dbg("%s - usb_control_msg - MTOUCHUSB_ASYNC_REPORT - bytes|err: %d",
279 __FUNCTION__, nRet);
280
281 usb_set_intfdata(intf, mtouch);
282 return 0;
283
284fail2: mtouchusb_free_buffers(udev, mtouch);
285fail1: input_free_device(input_dev);
286 kfree(mtouch);
287 return -ENOMEM;
288}
289
290static void mtouchusb_disconnect(struct usb_interface *intf)
291{
292 struct mtouch_usb *mtouch = usb_get_intfdata(intf);
293
294 dbg("%s - called", __FUNCTION__);
295 usb_set_intfdata(intf, NULL);
296 if (mtouch) {
297 dbg("%s - mtouch is initialized, cleaning up", __FUNCTION__);
298 usb_kill_urb(mtouch->irq);
299 input_unregister_device(mtouch->input);
300 usb_free_urb(mtouch->irq);
301 mtouchusb_free_buffers(interface_to_usbdev(intf), mtouch);
302 kfree(mtouch);
303 }
304}
305
306MODULE_DEVICE_TABLE(usb, mtouchusb_devices);
307
308static struct usb_driver mtouchusb_driver = {
309 .name = "mtouchusb",
310 .probe = mtouchusb_probe,
311 .disconnect = mtouchusb_disconnect,
312 .id_table = mtouchusb_devices,
313};
314
315static int __init mtouchusb_init(void)
316{
317 dbg("%s - called", __FUNCTION__);
318 return usb_register(&mtouchusb_driver);
319}
320
321static void __exit mtouchusb_cleanup(void)
322{
323 dbg("%s - called", __FUNCTION__);
324 usb_deregister(&mtouchusb_driver);
325}
326
327module_init(mtouchusb_init);
328module_exit(mtouchusb_cleanup);
329
330MODULE_AUTHOR(DRIVER_AUTHOR);
331MODULE_DESCRIPTION(DRIVER_DESC);
332MODULE_LICENSE("GPL");
diff --git a/drivers/usb/input/touchkitusb.c b/drivers/usb/input/touchkitusb.c
deleted file mode 100644
index 2a314b065922..000000000000
--- a/drivers/usb/input/touchkitusb.c
+++ /dev/null
@@ -1,392 +0,0 @@
1/******************************************************************************
2 * touchkitusb.c -- Driver for eGalax TouchKit USB Touchscreens
3 *
4 * Copyright (C) 2004-2005 by Daniel Ritz <daniel.ritz@gmx.ch>
5 * Copyright (C) by Todd E. Johnson (mtouchusb.c)
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License as
9 * published by the Free Software Foundation; either version 2 of the
10 * License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 *
21 * Based upon mtouchusb.c
22 *
23 *****************************************************************************/
24
25//#define DEBUG
26
27#include <linux/kernel.h>
28#include <linux/slab.h>
29#include <linux/module.h>
30#include <linux/init.h>
31#include <linux/usb/input.h>
32
33#define TOUCHKIT_MIN_XC 0x0
34#define TOUCHKIT_MAX_XC 0x07ff
35#define TOUCHKIT_XC_FUZZ 0x0
36#define TOUCHKIT_XC_FLAT 0x0
37#define TOUCHKIT_MIN_YC 0x0
38#define TOUCHKIT_MAX_YC 0x07ff
39#define TOUCHKIT_YC_FUZZ 0x0
40#define TOUCHKIT_YC_FLAT 0x0
41#define TOUCHKIT_REPORT_DATA_SIZE 16
42
43#define TOUCHKIT_DOWN 0x01
44
45#define TOUCHKIT_PKT_TYPE_MASK 0xFE
46#define TOUCHKIT_PKT_TYPE_REPT 0x80
47#define TOUCHKIT_PKT_TYPE_DIAG 0x0A
48
49#define DRIVER_VERSION "v0.1"
50#define DRIVER_AUTHOR "Daniel Ritz <daniel.ritz@gmx.ch>"
51#define DRIVER_DESC "eGalax TouchKit USB HID Touchscreen Driver"
52
53static int swap_xy;
54module_param(swap_xy, bool, 0644);
55MODULE_PARM_DESC(swap_xy, "If set X and Y axes are swapped.");
56
57struct touchkit_usb {
58 unsigned char *data;
59 dma_addr_t data_dma;
60 char buffer[TOUCHKIT_REPORT_DATA_SIZE];
61 int buf_len;
62 struct urb *irq;
63 struct usb_device *udev;
64 struct input_dev *input;
65 char name[128];
66 char phys[64];
67};
68
69static struct usb_device_id touchkit_devices[] = {
70 {USB_DEVICE(0x3823, 0x0001)},
71 {USB_DEVICE(0x0123, 0x0001)},
72 {USB_DEVICE(0x0eef, 0x0001)},
73 {USB_DEVICE(0x0eef, 0x0002)},
74 {}
75};
76
77/* helpers to read the data */
78static inline int touchkit_get_touched(char *data)
79{
80 return (data[0] & TOUCHKIT_DOWN) ? 1 : 0;
81}
82
83static inline int touchkit_get_x(char *data)
84{
85 return ((data[3] & 0x0F) << 7) | (data[4] & 0x7F);
86}
87
88static inline int touchkit_get_y(char *data)
89{
90 return ((data[1] & 0x0F) << 7) | (data[2] & 0x7F);
91}
92
93
94/* processes one input packet. */
95static void touchkit_process_pkt(struct touchkit_usb *touchkit, char *pkt)
96{
97 int x, y;
98
99 /* only process report packets */
100 if ((pkt[0] & TOUCHKIT_PKT_TYPE_MASK) != TOUCHKIT_PKT_TYPE_REPT)
101 return;
102
103 if (swap_xy) {
104 y = touchkit_get_x(pkt);
105 x = touchkit_get_y(pkt);
106 } else {
107 x = touchkit_get_x(pkt);
108 y = touchkit_get_y(pkt);
109 }
110
111 input_report_key(touchkit->input, BTN_TOUCH, touchkit_get_touched(pkt));
112 input_report_abs(touchkit->input, ABS_X, x);
113 input_report_abs(touchkit->input, ABS_Y, y);
114 input_sync(touchkit->input);
115}
116
117
118static int touchkit_get_pkt_len(char *buf)
119{
120 switch (buf[0] & TOUCHKIT_PKT_TYPE_MASK) {
121 case TOUCHKIT_PKT_TYPE_REPT:
122 return 5;
123
124 case TOUCHKIT_PKT_TYPE_DIAG:
125 return buf[1] + 2;
126 }
127
128 return 0;
129}
130
131static void touchkit_process(struct touchkit_usb *touchkit, int len)
132{
133 char *buffer;
134 int pkt_len, buf_len, pos;
135
136 /* if the buffer contains data, append */
137 if (unlikely(touchkit->buf_len)) {
138 int tmp;
139
140 /* if only 1 byte in buffer, add another one to get length */
141 if (touchkit->buf_len == 1)
142 touchkit->buffer[1] = touchkit->data[0];
143
144 pkt_len = touchkit_get_pkt_len(touchkit->buffer);
145
146 /* unknown packet: drop everything */
147 if (!pkt_len)
148 return;
149
150 /* append, process */
151 tmp = pkt_len - touchkit->buf_len;
152 memcpy(touchkit->buffer + touchkit->buf_len, touchkit->data, tmp);
153 touchkit_process_pkt(touchkit, touchkit->buffer);
154
155 buffer = touchkit->data + tmp;
156 buf_len = len - tmp;
157 } else {
158 buffer = touchkit->data;
159 buf_len = len;
160 }
161
162 /* only one byte left in buffer */
163 if (unlikely(buf_len == 1)) {
164 touchkit->buffer[0] = buffer[0];
165 touchkit->buf_len = 1;
166 return;
167 }
168
169 /* loop over the buffer */
170 pos = 0;
171 while (pos < buf_len) {
172 /* get packet len */
173 pkt_len = touchkit_get_pkt_len(buffer + pos);
174
175 /* unknown packet: drop everything */
176 if (unlikely(!pkt_len))
177 return;
178
179 /* full packet: process */
180 if (likely(pkt_len <= buf_len)) {
181 touchkit_process_pkt(touchkit, buffer + pos);
182 } else {
183 /* incomplete packet: save in buffer */
184 memcpy(touchkit->buffer, buffer + pos, buf_len - pos);
185 touchkit->buf_len = buf_len - pos;
186 }
187 pos += pkt_len;
188 }
189}
190
191
192static void touchkit_irq(struct urb *urb)
193{
194 struct touchkit_usb *touchkit = urb->context;
195 int retval;
196
197 switch (urb->status) {
198 case 0:
199 /* success */
200 break;
201 case -ETIME:
202 /* this urb is timing out */
203 dbg("%s - urb timed out - was the device unplugged?",
204 __FUNCTION__);
205 return;
206 case -ECONNRESET:
207 case -ENOENT:
208 case -ESHUTDOWN:
209 /* this urb is terminated, clean up */
210 dbg("%s - urb shutting down with status: %d",
211 __FUNCTION__, urb->status);
212 return;
213 default:
214 dbg("%s - nonzero urb status received: %d",
215 __FUNCTION__, urb->status);
216 goto exit;
217 }
218
219 touchkit_process(touchkit, urb->actual_length);
220
221exit:
222 retval = usb_submit_urb(urb, GFP_ATOMIC);
223 if (retval)
224 err("%s - usb_submit_urb failed with result: %d",
225 __FUNCTION__, retval);
226}
227
228static int touchkit_open(struct input_dev *input)
229{
230 struct touchkit_usb *touchkit = input->private;
231
232 touchkit->irq->dev = touchkit->udev;
233
234 if (usb_submit_urb(touchkit->irq, GFP_ATOMIC))
235 return -EIO;
236
237 return 0;
238}
239
240static void touchkit_close(struct input_dev *input)
241{
242 struct touchkit_usb *touchkit = input->private;
243
244 usb_kill_urb(touchkit->irq);
245}
246
247static int touchkit_alloc_buffers(struct usb_device *udev,
248 struct touchkit_usb *touchkit)
249{
250 touchkit->data = usb_buffer_alloc(udev, TOUCHKIT_REPORT_DATA_SIZE,
251 GFP_ATOMIC, &touchkit->data_dma);
252
253 if (!touchkit->data)
254 return -1;
255
256 return 0;
257}
258
259static void touchkit_free_buffers(struct usb_device *udev,
260 struct touchkit_usb *touchkit)
261{
262 if (touchkit->data)
263 usb_buffer_free(udev, TOUCHKIT_REPORT_DATA_SIZE,
264 touchkit->data, touchkit->data_dma);
265}
266
267static int touchkit_probe(struct usb_interface *intf,
268 const struct usb_device_id *id)
269{
270 struct touchkit_usb *touchkit;
271 struct input_dev *input_dev;
272 struct usb_host_interface *interface;
273 struct usb_endpoint_descriptor *endpoint;
274 struct usb_device *udev = interface_to_usbdev(intf);
275
276 interface = intf->cur_altsetting;
277 endpoint = &interface->endpoint[0].desc;
278
279 touchkit = kzalloc(sizeof(struct touchkit_usb), GFP_KERNEL);
280 input_dev = input_allocate_device();
281 if (!touchkit || !input_dev)
282 goto out_free;
283
284 if (touchkit_alloc_buffers(udev, touchkit))
285 goto out_free;
286
287 touchkit->irq = usb_alloc_urb(0, GFP_KERNEL);
288 if (!touchkit->irq) {
289 dbg("%s - usb_alloc_urb failed: touchkit->irq", __FUNCTION__);
290 goto out_free_buffers;
291 }
292
293 touchkit->udev = udev;
294 touchkit->input = input_dev;
295
296 if (udev->manufacturer)
297 strlcpy(touchkit->name, udev->manufacturer, sizeof(touchkit->name));
298
299 if (udev->product) {
300 if (udev->manufacturer)
301 strlcat(touchkit->name, " ", sizeof(touchkit->name));
302 strlcat(touchkit->name, udev->product, sizeof(touchkit->name));
303 }
304
305 if (!strlen(touchkit->name))
306 snprintf(touchkit->name, sizeof(touchkit->name),
307 "USB Touchscreen %04x:%04x",
308 le16_to_cpu(udev->descriptor.idVendor),
309 le16_to_cpu(udev->descriptor.idProduct));
310
311 usb_make_path(udev, touchkit->phys, sizeof(touchkit->phys));
312 strlcpy(touchkit->phys, "/input0", sizeof(touchkit->phys));
313
314 input_dev->name = touchkit->name;
315 input_dev->phys = touchkit->phys;
316 usb_to_input_id(udev, &input_dev->id);
317 input_dev->cdev.dev = &intf->dev;
318 input_dev->private = touchkit;
319 input_dev->open = touchkit_open;
320 input_dev->close = touchkit_close;
321
322 input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS);
323 input_dev->keybit[LONG(BTN_TOUCH)] = BIT(BTN_TOUCH);
324 input_set_abs_params(input_dev, ABS_X, TOUCHKIT_MIN_XC, TOUCHKIT_MAX_XC,
325 TOUCHKIT_XC_FUZZ, TOUCHKIT_XC_FLAT);
326 input_set_abs_params(input_dev, ABS_Y, TOUCHKIT_MIN_YC, TOUCHKIT_MAX_YC,
327 TOUCHKIT_YC_FUZZ, TOUCHKIT_YC_FLAT);
328
329 usb_fill_int_urb(touchkit->irq, touchkit->udev,
330 usb_rcvintpipe(touchkit->udev, 0x81),
331 touchkit->data, TOUCHKIT_REPORT_DATA_SIZE,
332 touchkit_irq, touchkit, endpoint->bInterval);
333
334 touchkit->irq->transfer_dma = touchkit->data_dma;
335 touchkit->irq->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
336
337 input_register_device(touchkit->input);
338
339 usb_set_intfdata(intf, touchkit);
340 return 0;
341
342out_free_buffers:
343 touchkit_free_buffers(udev, touchkit);
344out_free:
345 input_free_device(input_dev);
346 kfree(touchkit);
347 return -ENOMEM;
348}
349
350static void touchkit_disconnect(struct usb_interface *intf)
351{
352 struct touchkit_usb *touchkit = usb_get_intfdata(intf);
353
354 dbg("%s - called", __FUNCTION__);
355
356 if (!touchkit)
357 return;
358
359 dbg("%s - touchkit is initialized, cleaning up", __FUNCTION__);
360 usb_set_intfdata(intf, NULL);
361 usb_kill_urb(touchkit->irq);
362 input_unregister_device(touchkit->input);
363 usb_free_urb(touchkit->irq);
364 touchkit_free_buffers(interface_to_usbdev(intf), touchkit);
365 kfree(touchkit);
366}
367
368MODULE_DEVICE_TABLE(usb, touchkit_devices);
369
370static struct usb_driver touchkit_driver = {
371 .name = "touchkitusb",
372 .probe = touchkit_probe,
373 .disconnect = touchkit_disconnect,
374 .id_table = touchkit_devices,
375};
376
377static int __init touchkit_init(void)
378{
379 return usb_register(&touchkit_driver);
380}
381
382static void __exit touchkit_cleanup(void)
383{
384 usb_deregister(&touchkit_driver);
385}
386
387module_init(touchkit_init);
388module_exit(touchkit_cleanup);
389
390MODULE_AUTHOR(DRIVER_AUTHOR);
391MODULE_DESCRIPTION(DRIVER_DESC);
392MODULE_LICENSE("GPL");