aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/input/touchkitusb.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/usb/input/touchkitusb.c')
-rw-r--r--drivers/usb/input/touchkitusb.c118
1 files changed, 57 insertions, 61 deletions
diff --git a/drivers/usb/input/touchkitusb.c b/drivers/usb/input/touchkitusb.c
index 4276c24a5080..0043e6ebcd1f 100644
--- a/drivers/usb/input/touchkitusb.c
+++ b/drivers/usb/input/touchkitusb.c
@@ -68,14 +68,16 @@ struct touchkit_usb {
68 dma_addr_t data_dma; 68 dma_addr_t data_dma;
69 struct urb *irq; 69 struct urb *irq;
70 struct usb_device *udev; 70 struct usb_device *udev;
71 struct input_dev input; 71 struct input_dev *input;
72 char name[128]; 72 char name[128];
73 char phys[64]; 73 char phys[64];
74}; 74};
75 75
76static struct usb_device_id touchkit_devices[] = { 76static struct usb_device_id touchkit_devices[] = {
77 {USB_DEVICE(0x3823, 0x0001)}, 77 {USB_DEVICE(0x3823, 0x0001)},
78 {USB_DEVICE(0x0123, 0x0001)},
78 {USB_DEVICE(0x0eef, 0x0001)}, 79 {USB_DEVICE(0x0eef, 0x0001)},
80 {USB_DEVICE(0x0eef, 0x0002)},
79 {} 81 {}
80}; 82};
81 83
@@ -115,12 +117,12 @@ static void touchkit_irq(struct urb *urb, struct pt_regs *regs)
115 y = TOUCHKIT_GET_Y(touchkit->data); 117 y = TOUCHKIT_GET_Y(touchkit->data);
116 } 118 }
117 119
118 input_regs(&touchkit->input, regs); 120 input_regs(touchkit->input, regs);
119 input_report_key(&touchkit->input, BTN_TOUCH, 121 input_report_key(touchkit->input, BTN_TOUCH,
120 TOUCHKIT_GET_TOUCHED(touchkit->data)); 122 TOUCHKIT_GET_TOUCHED(touchkit->data));
121 input_report_abs(&touchkit->input, ABS_X, x); 123 input_report_abs(touchkit->input, ABS_X, x);
122 input_report_abs(&touchkit->input, ABS_Y, y); 124 input_report_abs(touchkit->input, ABS_Y, y);
123 input_sync(&touchkit->input); 125 input_sync(touchkit->input);
124 126
125exit: 127exit:
126 retval = usb_submit_urb(urb, GFP_ATOMIC); 128 retval = usb_submit_urb(urb, GFP_ATOMIC);
@@ -171,87 +173,81 @@ static void touchkit_free_buffers(struct usb_device *udev,
171static int touchkit_probe(struct usb_interface *intf, 173static int touchkit_probe(struct usb_interface *intf,
172 const struct usb_device_id *id) 174 const struct usb_device_id *id)
173{ 175{
174 int ret;
175 struct touchkit_usb *touchkit; 176 struct touchkit_usb *touchkit;
177 struct input_dev *input_dev;
176 struct usb_host_interface *interface; 178 struct usb_host_interface *interface;
177 struct usb_endpoint_descriptor *endpoint; 179 struct usb_endpoint_descriptor *endpoint;
178 struct usb_device *udev = interface_to_usbdev(intf); 180 struct usb_device *udev = interface_to_usbdev(intf);
179 char path[64];
180 181
181 interface = intf->cur_altsetting; 182 interface = intf->cur_altsetting;
182 endpoint = &interface->endpoint[0].desc; 183 endpoint = &interface->endpoint[0].desc;
183 184
184 touchkit = kmalloc(sizeof(struct touchkit_usb), GFP_KERNEL); 185 touchkit = kzalloc(sizeof(struct touchkit_usb), GFP_KERNEL);
185 if (!touchkit) 186 input_dev = input_allocate_device();
186 return -ENOMEM; 187 if (!touchkit || !input_dev)
187
188 memset(touchkit, 0, sizeof(struct touchkit_usb));
189 touchkit->udev = udev;
190
191 if (touchkit_alloc_buffers(udev, touchkit)) {
192 ret = -ENOMEM;
193 goto out_free; 188 goto out_free;
194 }
195
196 touchkit->input.private = touchkit;
197 touchkit->input.open = touchkit_open;
198 touchkit->input.close = touchkit_close;
199
200 usb_make_path(udev, path, 64);
201 sprintf(touchkit->phys, "%s/input0", path);
202
203 touchkit->input.name = touchkit->name;
204 touchkit->input.phys = touchkit->phys;
205 usb_to_input_id(udev, &touchkit->input.id);
206 touchkit->input.dev = &intf->dev;
207
208 touchkit->input.evbit[0] = BIT(EV_KEY) | BIT(EV_ABS);
209 touchkit->input.absbit[0] = BIT(ABS_X) | BIT(ABS_Y);
210 touchkit->input.keybit[LONG(BTN_TOUCH)] = BIT(BTN_TOUCH);
211
212 /* Used to Scale Compensated Data */
213 touchkit->input.absmin[ABS_X] = TOUCHKIT_MIN_XC;
214 touchkit->input.absmax[ABS_X] = TOUCHKIT_MAX_XC;
215 touchkit->input.absfuzz[ABS_X] = TOUCHKIT_XC_FUZZ;
216 touchkit->input.absflat[ABS_X] = TOUCHKIT_XC_FLAT;
217 touchkit->input.absmin[ABS_Y] = TOUCHKIT_MIN_YC;
218 touchkit->input.absmax[ABS_Y] = TOUCHKIT_MAX_YC;
219 touchkit->input.absfuzz[ABS_Y] = TOUCHKIT_YC_FUZZ;
220 touchkit->input.absflat[ABS_Y] = TOUCHKIT_YC_FLAT;
221
222 if (udev->manufacturer)
223 strcat(touchkit->name, udev->manufacturer);
224 if (udev->product)
225 sprintf(touchkit->name, "%s %s", touchkit->name, udev->product);
226 189
227 if (!strlen(touchkit->name)) 190 if (touchkit_alloc_buffers(udev, touchkit))
228 sprintf(touchkit->name, "USB Touchscreen %04x:%04x", 191 goto out_free;
229 touchkit->input.id.vendor, touchkit->input.id.product);
230 192
231 touchkit->irq = usb_alloc_urb(0, GFP_KERNEL); 193 touchkit->irq = usb_alloc_urb(0, GFP_KERNEL);
232 if (!touchkit->irq) { 194 if (!touchkit->irq) {
233 dbg("%s - usb_alloc_urb failed: touchkit->irq", __FUNCTION__); 195 dbg("%s - usb_alloc_urb failed: touchkit->irq", __FUNCTION__);
234 ret = -ENOMEM;
235 goto out_free_buffers; 196 goto out_free_buffers;
236 } 197 }
237 198
199 touchkit->udev = udev;
200 touchkit->input = input_dev;
201
202 if (udev->manufacturer)
203 strlcpy(touchkit->name, udev->manufacturer, sizeof(touchkit->name));
204
205 if (udev->product) {
206 if (udev->manufacturer)
207 strlcat(touchkit->name, " ", sizeof(touchkit->name));
208 strlcat(touchkit->name, udev->product, sizeof(touchkit->name));
209 }
210
211 if (!strlen(touchkit->name))
212 snprintf(touchkit->name, sizeof(touchkit->name),
213 "USB Touchscreen %04x:%04x",
214 le16_to_cpu(udev->descriptor.idVendor),
215 le16_to_cpu(udev->descriptor.idProduct));
216
217 usb_make_path(udev, touchkit->phys, sizeof(touchkit->phys));
218 strlcpy(touchkit->phys, "/input0", sizeof(touchkit->phys));
219
220 input_dev->name = touchkit->name;
221 input_dev->phys = touchkit->phys;
222 usb_to_input_id(udev, &input_dev->id);
223 input_dev->cdev.dev = &intf->dev;
224 input_dev->private = touchkit;
225 input_dev->open = touchkit_open;
226 input_dev->close = touchkit_close;
227
228 input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS);
229 input_dev->keybit[LONG(BTN_TOUCH)] = BIT(BTN_TOUCH);
230 input_set_abs_params(input_dev, ABS_X, TOUCHKIT_MIN_XC, TOUCHKIT_MAX_XC,
231 TOUCHKIT_XC_FUZZ, TOUCHKIT_XC_FLAT);
232 input_set_abs_params(input_dev, ABS_Y, TOUCHKIT_MIN_YC, TOUCHKIT_MAX_YC,
233 TOUCHKIT_YC_FUZZ, TOUCHKIT_YC_FLAT);
234
238 usb_fill_int_urb(touchkit->irq, touchkit->udev, 235 usb_fill_int_urb(touchkit->irq, touchkit->udev,
239 usb_rcvintpipe(touchkit->udev, 0x81), 236 usb_rcvintpipe(touchkit->udev, 0x81),
240 touchkit->data, TOUCHKIT_REPORT_DATA_SIZE, 237 touchkit->data, TOUCHKIT_REPORT_DATA_SIZE,
241 touchkit_irq, touchkit, endpoint->bInterval); 238 touchkit_irq, touchkit, endpoint->bInterval);
242 239
243 input_register_device(&touchkit->input); 240 input_register_device(touchkit->input);
244 241
245 printk(KERN_INFO "input: %s on %s\n", touchkit->name, path);
246 usb_set_intfdata(intf, touchkit); 242 usb_set_intfdata(intf, touchkit);
247
248 return 0; 243 return 0;
249 244
250out_free_buffers: 245out_free_buffers:
251 touchkit_free_buffers(udev, touchkit); 246 touchkit_free_buffers(udev, touchkit);
252out_free: 247out_free:
248 input_free_device(input_dev);
253 kfree(touchkit); 249 kfree(touchkit);
254 return ret; 250 return -ENOMEM;
255} 251}
256 252
257static void touchkit_disconnect(struct usb_interface *intf) 253static void touchkit_disconnect(struct usb_interface *intf)
@@ -265,8 +261,8 @@ static void touchkit_disconnect(struct usb_interface *intf)
265 261
266 dbg("%s - touchkit is initialized, cleaning up", __FUNCTION__); 262 dbg("%s - touchkit is initialized, cleaning up", __FUNCTION__);
267 usb_set_intfdata(intf, NULL); 263 usb_set_intfdata(intf, NULL);
268 input_unregister_device(&touchkit->input);
269 usb_kill_urb(touchkit->irq); 264 usb_kill_urb(touchkit->irq);
265 input_unregister_device(touchkit->input);
270 usb_free_urb(touchkit->irq); 266 usb_free_urb(touchkit->irq);
271 touchkit_free_buffers(interface_to_usbdev(intf), touchkit); 267 touchkit_free_buffers(interface_to_usbdev(intf), touchkit);
272 kfree(touchkit); 268 kfree(touchkit);