41 #include <linux/kernel.h>
43 #include <linux/slab.h>
44 #include <linux/module.h>
47 #include <linux/input.h>
50 #define USB_VENDOR_ID_SYNAPTICS 0x06cb
51 #define USB_DEVICE_ID_SYNAPTICS_TP 0x0001
52 #define USB_DEVICE_ID_SYNAPTICS_INT_TP 0x0002
53 #define USB_DEVICE_ID_SYNAPTICS_CPAD 0x0003
54 #define USB_DEVICE_ID_SYNAPTICS_TS 0x0006
55 #define USB_DEVICE_ID_SYNAPTICS_STICK 0x0007
56 #define USB_DEVICE_ID_SYNAPTICS_WP 0x0008
57 #define USB_DEVICE_ID_SYNAPTICS_COMP_TP 0x0009
58 #define USB_DEVICE_ID_SYNAPTICS_WTP 0x0010
59 #define USB_DEVICE_ID_SYNAPTICS_DPAD 0x0013
61 #define SYNUSB_TOUCHPAD (1 << 0)
62 #define SYNUSB_STICK (1 << 1)
63 #define SYNUSB_TOUCHSCREEN (1 << 2)
64 #define SYNUSB_AUXDISPLAY (1 << 3)
65 #define SYNUSB_COMBO (1 << 4)
66 #define SYNUSB_IO_ALWAYS (1 << 5)
68 #define USB_DEVICE_SYNAPTICS(prod, kind) \
69 USB_DEVICE(USB_VENDOR_ID_SYNAPTICS, \
70 USB_DEVICE_ID_SYNAPTICS_##prod), \
71 .driver_info = (kind),
73 #define SYNUSB_RECV_SIZE 8
75 #define XMIN_NOMINAL 1472
76 #define XMAX_NOMINAL 5472
77 #define YMIN_NOMINAL 1408
78 #define YMAX_NOMINAL 4448
97 struct input_dev *input_dev = synusb->
input;
99 input_report_key(input_dev,
BTN_LEFT, synusb->
data[1] & 0x04);
100 input_report_key(input_dev,
BTN_RIGHT, synusb->
data[1] & 0x01);
106 struct input_dev *input_dev = synusb->
input;
108 unsigned int pressure;
110 pressure = synusb->
data[6];
115 input_report_rel(input_dev,
REL_X, x);
116 input_report_rel(input_dev,
REL_Y, -y);
121 synusb_report_buttons(synusb);
123 input_sync(input_dev);
126 static void synusb_report_touchpad(
struct synusb *synusb)
128 struct input_dev *input_dev = synusb->
input;
129 unsigned int num_fingers, tool_width;
131 unsigned int pressure,
w;
133 pressure = synusb->
data[6];
136 w = synusb->
data[0] & 0x0f;
165 input_report_key(input_dev,
BTN_TOUCH, 1);
167 input_report_key(input_dev,
BTN_TOUCH, 0);
169 if (num_fingers > 0) {
170 input_report_abs(input_dev,
ABS_X, x);
171 input_report_abs(input_dev,
ABS_Y,
182 synusb_report_buttons(synusb);
186 input_sync(input_dev);
189 static void synusb_irq(
struct urb *
urb)
191 struct synusb *synusb = urb->context;
195 switch (urb->status) {
197 usb_mark_last_busy(synusb->
udev);
212 synusb_report_stick(synusb);
214 synusb_report_touchpad(synusb);
218 if (error && error != -
EPERM)
220 "%s - usb_submit_urb failed with result: %d",
225 synusb_get_in_endpoint(
struct usb_host_interface *iface)
231 for (i = 0; i < iface->desc.bNumEndpoints; ++
i) {
232 endpoint = &iface->endpoint[
i].desc;
234 if (usb_endpoint_is_int_in(endpoint)) {
243 static int synusb_open(
struct input_dev *
dev)
245 struct synusb *synusb = input_get_drvdata(dev);
248 retval = usb_autopm_get_interface(synusb->
intf);
251 "%s - usb_autopm_get_interface failed, error: %d\n",
259 "%s - usb_submit_urb failed, error: %d\n",
265 synusb->
intf->needs_remote_wakeup = 1;
268 usb_autopm_put_interface(synusb->
intf);
272 static void synusb_close(
struct input_dev *dev)
274 struct synusb *synusb = input_get_drvdata(dev);
277 autopm_error = usb_autopm_get_interface(synusb->
intf);
280 synusb->
intf->needs_remote_wakeup = 0;
283 usb_autopm_put_interface(synusb->
intf);
289 struct usb_device *
udev = interface_to_usbdev(intf);
291 struct synusb *synusb;
292 struct input_dev *input_dev;
293 unsigned int intf_num = intf->cur_altsetting->desc.bInterfaceNumber;
294 unsigned int altsetting =
min(intf->num_altsetting, 1
U);
300 "Can not set alternate setting to %i, error: %i",
305 ep = synusb_get_in_endpoint(intf->cur_altsetting);
309 synusb = kzalloc(
sizeof(*synusb),
GFP_KERNEL);
310 input_dev = input_allocate_device();
311 if (!synusb || !input_dev) {
318 synusb->
input = input_dev;
320 synusb->
flags =
id->driver_info;
326 synusb->
flags |= intf_num == 1 ?
337 &synusb->
urb->transfer_dma);
343 usb_fill_int_urb(synusb->
urb, udev,
348 synusb->
urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
350 if (udev->manufacturer)
352 sizeof(synusb->
name));
355 if (udev->manufacturer)
362 "USB Synaptics Device %04x:%04x",
369 usb_make_path(udev, synusb->
phys,
sizeof(synusb->
phys));
372 input_dev->name = synusb->
name;
373 input_dev->phys = synusb->
phys;
374 usb_to_input_id(udev, &input_dev->id);
375 input_dev->dev.parent = &synusb->
intf->dev;
378 input_dev->open = synusb_open;
379 input_dev->close = synusb_close;
382 input_set_drvdata(input_dev, synusb);
391 input_set_abs_params(input_dev,
ABS_PRESSURE, 0, 127, 0, 0);
393 input_set_abs_params(input_dev,
ABS_X,
395 input_set_abs_params(input_dev,
ABS_Y,
397 input_set_abs_params(input_dev,
ABS_PRESSURE, 0, 255, 0, 0);
409 usb_set_intfdata(intf, synusb);
412 error = synusb_open(input_dev);
417 error = input_register_device(input_dev);
420 "Failed to register input device, error %d\n",
429 synusb_close(synusb->
input);
432 synusb->
urb->transfer_dma);
436 input_free_device(input_dev);
438 usb_set_intfdata(intf,
NULL);
445 struct synusb *synusb = usb_get_intfdata(intf);
446 struct usb_device *udev = interface_to_usbdev(intf);
449 synusb_close(synusb->
input);
451 input_unregister_device(synusb->
input);
454 synusb->
urb->transfer_dma);
458 usb_set_intfdata(intf,
NULL);
463 struct synusb *synusb = usb_get_intfdata(intf);
464 struct input_dev *input_dev = synusb->
input;
475 struct synusb *synusb = usb_get_intfdata(intf);
476 struct input_dev *input_dev = synusb->
input;
493 struct synusb *synusb = usb_get_intfdata(intf);
494 struct input_dev *input_dev = synusb->
input;
504 struct synusb *synusb = usb_get_intfdata(intf);
505 struct input_dev *input_dev = synusb->
input;
520 return synusb_resume(intf);
538 static struct usb_driver synusb_driver = {
539 .name =
"synaptics_usb",
540 .probe = synusb_probe,
541 .disconnect = synusb_disconnect,
542 .id_table = synusb_idtable,
543 .suspend = synusb_suspend,
544 .resume = synusb_resume,
545 .pre_reset = synusb_pre_reset,
546 .post_reset = synusb_post_reset,
547 .reset_resume = synusb_reset_resume,
548 .supports_autosuspend = 1,