diff options
| author | Jeff Garzik <jgarzik@pobox.com> | 2005-09-14 08:19:08 -0400 |
|---|---|---|
| committer | Jeff Garzik <jgarzik@pobox.com> | 2005-09-14 08:19:08 -0400 |
| commit | 905ec87e93bc9e01b15c60035cd6a50c636cbaef (patch) | |
| tree | 46fd7618d6511611ffc19eb0dd4d7bc6b90a41c2 /drivers/usb/input | |
| parent | 1d6ae775d7a948c9575658eb41184fd2e506c0df (diff) | |
| parent | 2f4ba45a75d6383b4a1201169a808ffea416ffa0 (diff) | |
Merge /spare/repo/linux-2.6/
Diffstat (limited to 'drivers/usb/input')
| -rw-r--r-- | drivers/usb/input/Kconfig | 34 | ||||
| -rw-r--r-- | drivers/usb/input/Makefile | 2 | ||||
| -rw-r--r-- | drivers/usb/input/appletouch.c | 469 | ||||
| -rw-r--r-- | drivers/usb/input/hid-core.c | 81 | ||||
| -rw-r--r-- | drivers/usb/input/hid-debug.h | 34 | ||||
| -rw-r--r-- | drivers/usb/input/hid-input.c | 66 | ||||
| -rw-r--r-- | drivers/usb/input/hid.h | 9 | ||||
| -rw-r--r-- | drivers/usb/input/hiddev.c | 1 | ||||
| -rw-r--r-- | drivers/usb/input/keyspan_remote.c | 5 | ||||
| -rw-r--r-- | drivers/usb/input/map_to_7segment.h | 189 | ||||
| -rw-r--r-- | drivers/usb/input/yealink.c | 1013 | ||||
| -rw-r--r-- | drivers/usb/input/yealink.h | 220 |
12 files changed, 2084 insertions, 39 deletions
diff --git a/drivers/usb/input/Kconfig b/drivers/usb/input/Kconfig index 298e4a25e3d3..1e53934907c0 100644 --- a/drivers/usb/input/Kconfig +++ b/drivers/usb/input/Kconfig | |||
| @@ -230,6 +230,20 @@ config USB_EGALAX | |||
| 230 | To compile this driver as a module, choose M here: the | 230 | To compile this driver as a module, choose M here: the |
| 231 | module will be called touchkitusb. | 231 | module will be called touchkitusb. |
| 232 | 232 | ||
| 233 | config USB_YEALINK | ||
| 234 | tristate "Yealink usb-p1k voip phone" | ||
| 235 | depends on USB && INPUT && EXPERIMENTAL | ||
| 236 | ---help--- | ||
| 237 | Say Y here if you want to enable keyboard and LCD functions of the | ||
| 238 | Yealink usb-p1k usb phones. The audio part is enabled by the generic | ||
| 239 | usb sound driver, so you might want to enable that as well. | ||
| 240 | |||
| 241 | For information about how to use these additional functions, see | ||
| 242 | <file:Documentation/input/yealink.txt>. | ||
| 243 | |||
| 244 | To compile this driver as a module, choose M here: the module will be | ||
| 245 | called yealink. | ||
| 246 | |||
| 233 | config USB_XPAD | 247 | config USB_XPAD |
| 234 | tristate "X-Box gamepad support" | 248 | tristate "X-Box gamepad support" |
| 235 | depends on USB && INPUT | 249 | depends on USB && INPUT |
| @@ -272,3 +286,23 @@ config USB_KEYSPAN_REMOTE | |||
| 272 | 286 | ||
| 273 | To compile this driver as a module, choose M here: the module will | 287 | To compile this driver as a module, choose M here: the module will |
| 274 | be called keyspan_remote. | 288 | be called keyspan_remote. |
| 289 | |||
| 290 | config USB_APPLETOUCH | ||
| 291 | tristate "Apple USB Touchpad support" | ||
| 292 | depends on USB && INPUT | ||
| 293 | ---help--- | ||
| 294 | Say Y here if you want to use an Apple USB Touchpad. | ||
| 295 | |||
| 296 | These are the touchpads that can be found on post-February 2005 | ||
| 297 | Apple Powerbooks (prior models have a Synaptics touchpad connected | ||
| 298 | to the ADB bus). | ||
| 299 | |||
| 300 | This driver provides a basic mouse driver but can be interfaced | ||
| 301 | with the synaptics X11 driver to provide acceleration and | ||
| 302 | scrolling in X11. | ||
| 303 | |||
| 304 | For further information, see | ||
| 305 | <file:Documentation/input/appletouch.txt>. | ||
| 306 | |||
| 307 | To compile this driver as a module, choose M here: the | ||
| 308 | module will be called appletouch. | ||
diff --git a/drivers/usb/input/Makefile b/drivers/usb/input/Makefile index f1547be632d4..5e03b93f29f6 100644 --- a/drivers/usb/input/Makefile +++ b/drivers/usb/input/Makefile | |||
| @@ -39,4 +39,6 @@ obj-$(CONFIG_USB_EGALAX) += touchkitusb.o | |||
| 39 | obj-$(CONFIG_USB_POWERMATE) += powermate.o | 39 | obj-$(CONFIG_USB_POWERMATE) += powermate.o |
| 40 | obj-$(CONFIG_USB_WACOM) += wacom.o | 40 | obj-$(CONFIG_USB_WACOM) += wacom.o |
| 41 | obj-$(CONFIG_USB_ACECAD) += acecad.o | 41 | obj-$(CONFIG_USB_ACECAD) += acecad.o |
| 42 | obj-$(CONFIG_USB_YEALINK) += yealink.o | ||
| 42 | obj-$(CONFIG_USB_XPAD) += xpad.o | 43 | obj-$(CONFIG_USB_XPAD) += xpad.o |
| 44 | obj-$(CONFIG_USB_APPLETOUCH) += appletouch.o | ||
diff --git a/drivers/usb/input/appletouch.c b/drivers/usb/input/appletouch.c new file mode 100644 index 000000000000..e03c1c567a14 --- /dev/null +++ b/drivers/usb/input/appletouch.c | |||
| @@ -0,0 +1,469 @@ | |||
| 1 | /* | ||
| 2 | * Apple USB Touchpad (for post-February 2005 PowerBooks) driver | ||
| 3 | * | ||
| 4 | * Copyright (C) 2001-2004 Greg Kroah-Hartman (greg@kroah.com) | ||
| 5 | * Copyright (C) 2005 Johannes Berg (johannes@sipsolutions.net) | ||
| 6 | * Copyright (C) 2005 Stelian Pop (stelian@popies.net) | ||
| 7 | * Copyright (C) 2005 Frank Arnold (frank@scirocco-5v-turbo.de) | ||
| 8 | * Copyright (C) 2005 Peter Osterlund (petero2@telia.com) | ||
| 9 | * | ||
| 10 | * Thanks to Alex Harper <basilisk@foobox.net> for his inputs. | ||
| 11 | * | ||
| 12 | * This program is free software; you can redistribute it and/or modify | ||
| 13 | * it under the terms of the GNU General Public License as published by | ||
| 14 | * the Free Software Foundation; either version 2 of the License, or | ||
| 15 | * (at your option) any later version. | ||
| 16 | * | ||
| 17 | * This program is distributed in the hope that it will be useful, | ||
| 18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 20 | * GNU General Public License for more details. | ||
| 21 | * | ||
| 22 | * You should have received a copy of the GNU General Public License | ||
| 23 | * along with this program; if not, write to the Free Software | ||
| 24 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
| 25 | * | ||
| 26 | */ | ||
| 27 | |||
| 28 | #include <linux/config.h> | ||
| 29 | #include <linux/kernel.h> | ||
| 30 | #include <linux/errno.h> | ||
| 31 | #include <linux/init.h> | ||
| 32 | #include <linux/slab.h> | ||
| 33 | #include <linux/module.h> | ||
| 34 | #include <linux/usb.h> | ||
| 35 | #include <linux/input.h> | ||
| 36 | #include <linux/usb_input.h> | ||
| 37 | |||
| 38 | /* Apple has powerbooks which have the keyboard with different Product IDs */ | ||
| 39 | #define APPLE_VENDOR_ID 0x05AC | ||
| 40 | |||
| 41 | #define ATP_DEVICE(prod) \ | ||
| 42 | .match_flags = USB_DEVICE_ID_MATCH_DEVICE | \ | ||
| 43 | USB_DEVICE_ID_MATCH_INT_CLASS | \ | ||
| 44 | USB_DEVICE_ID_MATCH_INT_PROTOCOL, \ | ||
| 45 | .idVendor = APPLE_VENDOR_ID, \ | ||
| 46 | .idProduct = (prod), \ | ||
| 47 | .bInterfaceClass = 0x03, \ | ||
| 48 | .bInterfaceProtocol = 0x02 | ||
| 49 | |||
| 50 | /* table of devices that work with this driver */ | ||
| 51 | static struct usb_device_id atp_table [] = { | ||
| 52 | { ATP_DEVICE(0x020E) }, | ||
| 53 | { ATP_DEVICE(0x020F) }, | ||
| 54 | { ATP_DEVICE(0x030A) }, | ||
| 55 | { ATP_DEVICE(0x030B) }, | ||
| 56 | { } /* Terminating entry */ | ||
| 57 | }; | ||
| 58 | MODULE_DEVICE_TABLE (usb, atp_table); | ||
| 59 | |||
| 60 | /* size of a USB urb transfer */ | ||
| 61 | #define ATP_DATASIZE 81 | ||
| 62 | |||
| 63 | /* | ||
| 64 | * number of sensors. Note that only 16 instead of 26 X (horizontal) | ||
| 65 | * sensors exist on 12" and 15" PowerBooks. All models have 16 Y | ||
| 66 | * (vertical) sensors. | ||
| 67 | */ | ||
| 68 | #define ATP_XSENSORS 26 | ||
| 69 | #define ATP_YSENSORS 16 | ||
| 70 | |||
| 71 | /* amount of fuzz this touchpad generates */ | ||
| 72 | #define ATP_FUZZ 16 | ||
| 73 | |||
| 74 | /* maximum pressure this driver will report */ | ||
| 75 | #define ATP_PRESSURE 300 | ||
| 76 | /* | ||
| 77 | * multiplication factor for the X and Y coordinates. | ||
| 78 | * We try to keep the touchpad aspect ratio while still doing only simple | ||
| 79 | * arithmetics. | ||
| 80 | * The factors below give coordinates like: | ||
| 81 | * 0 <= x < 960 on 12" and 15" Powerbooks | ||
| 82 | * 0 <= x < 1600 on 17" Powerbooks | ||
| 83 | * 0 <= y < 646 | ||
| 84 | */ | ||
| 85 | #define ATP_XFACT 64 | ||
| 86 | #define ATP_YFACT 43 | ||
| 87 | |||
| 88 | /* | ||
| 89 | * Threshold for the touchpad sensors. Any change less than ATP_THRESHOLD is | ||
| 90 | * ignored. | ||
| 91 | */ | ||
| 92 | #define ATP_THRESHOLD 5 | ||
| 93 | |||
| 94 | /* Structure to hold all of our device specific stuff */ | ||
| 95 | struct atp { | ||
| 96 | struct usb_device * udev; /* usb device */ | ||
| 97 | struct urb * urb; /* usb request block */ | ||
| 98 | signed char * data; /* transferred data */ | ||
| 99 | int open; /* non-zero if opened */ | ||
| 100 | struct input_dev input; /* input dev */ | ||
| 101 | int valid; /* are the sensors valid ? */ | ||
| 102 | int x_old; /* last reported x/y, */ | ||
| 103 | int y_old; /* used for smoothing */ | ||
| 104 | /* current value of the sensors */ | ||
| 105 | signed char xy_cur[ATP_XSENSORS + ATP_YSENSORS]; | ||
| 106 | /* last value of the sensors */ | ||
| 107 | signed char xy_old[ATP_XSENSORS + ATP_YSENSORS]; | ||
| 108 | /* accumulated sensors */ | ||
| 109 | int xy_acc[ATP_XSENSORS + ATP_YSENSORS]; | ||
| 110 | }; | ||
| 111 | |||
| 112 | #define dbg_dump(msg, tab) \ | ||
| 113 | if (debug > 1) { \ | ||
| 114 | int i; \ | ||
| 115 | printk("appletouch: %s %lld", msg, (long long)jiffies); \ | ||
| 116 | for (i = 0; i < ATP_XSENSORS + ATP_YSENSORS; i++) \ | ||
| 117 | printk(" %02x", tab[i]); \ | ||
| 118 | printk("\n"); \ | ||
| 119 | } | ||
| 120 | |||
| 121 | #define dprintk(format, a...) \ | ||
| 122 | do { \ | ||
| 123 | if (debug) printk(format, ##a); \ | ||
| 124 | } while (0) | ||
| 125 | |||
| 126 | MODULE_AUTHOR("Johannes Berg, Stelian Pop, Frank Arnold"); | ||
| 127 | MODULE_DESCRIPTION("Apple PowerBooks USB touchpad driver"); | ||
| 128 | MODULE_LICENSE("GPL"); | ||
| 129 | |||
| 130 | static int debug = 1; | ||
| 131 | module_param(debug, int, 0644); | ||
| 132 | MODULE_PARM_DESC(debug, "Activate debugging output"); | ||
| 133 | |||
| 134 | static int atp_calculate_abs(int *xy_sensors, int nb_sensors, int fact, | ||
| 135 | int *z, int *fingers) | ||
| 136 | { | ||
| 137 | int i; | ||
| 138 | /* values to calculate mean */ | ||
| 139 | int pcum = 0, psum = 0; | ||
| 140 | |||
| 141 | *fingers = 0; | ||
| 142 | |||
| 143 | for (i = 0; i < nb_sensors; i++) { | ||
| 144 | if (xy_sensors[i] < ATP_THRESHOLD) | ||
| 145 | continue; | ||
| 146 | if ((i - 1 < 0) || (xy_sensors[i - 1] < ATP_THRESHOLD)) | ||
| 147 | (*fingers)++; | ||
| 148 | pcum += xy_sensors[i] * i; | ||
| 149 | psum += xy_sensors[i]; | ||
| 150 | } | ||
| 151 | |||
| 152 | if (psum > 0) { | ||
| 153 | *z = psum; | ||
| 154 | return pcum * fact / psum; | ||
| 155 | } | ||
| 156 | |||
| 157 | return 0; | ||
| 158 | } | ||
| 159 | |||
| 160 | static inline void atp_report_fingers(struct input_dev *input, int fingers) | ||
| 161 | { | ||
| 162 | input_report_key(input, BTN_TOOL_FINGER, fingers == 1); | ||
| 163 | input_report_key(input, BTN_TOOL_DOUBLETAP, fingers == 2); | ||
| 164 | input_report_key(input, BTN_TOOL_TRIPLETAP, fingers > 2); | ||
| 165 | } | ||
| 166 | |||
| 167 | static void atp_complete(struct urb* urb, struct pt_regs* regs) | ||
| 168 | { | ||
| 169 | int x, y, x_z, y_z, x_f, y_f; | ||
| 170 | int retval, i; | ||
| 171 | struct atp *dev = urb->context; | ||
| 172 | |||
| 173 | switch (urb->status) { | ||
| 174 | case 0: | ||
| 175 | /* success */ | ||
| 176 | break; | ||
| 177 | case -ECONNRESET: | ||
| 178 | case -ENOENT: | ||
| 179 | case -ESHUTDOWN: | ||
| 180 | /* This urb is terminated, clean up */ | ||
| 181 | dbg("%s - urb shutting down with status: %d", | ||
| 182 | __FUNCTION__, urb->status); | ||
| 183 | return; | ||
| 184 | default: | ||
| 185 | dbg("%s - nonzero urb status received: %d", | ||
| 186 | __FUNCTION__, urb->status); | ||
| 187 | goto exit; | ||
| 188 | } | ||
| 189 | |||
| 190 | /* drop incomplete datasets */ | ||
| 191 | if (dev->urb->actual_length != ATP_DATASIZE) { | ||
| 192 | dprintk("appletouch: incomplete data package.\n"); | ||
| 193 | goto exit; | ||
| 194 | } | ||
| 195 | |||
| 196 | /* reorder the sensors values */ | ||
| 197 | for (i = 0; i < 8; i++) { | ||
| 198 | /* X values */ | ||
| 199 | dev->xy_cur[i ] = dev->data[5 * i + 2]; | ||
| 200 | dev->xy_cur[i + 8] = dev->data[5 * i + 4]; | ||
| 201 | dev->xy_cur[i + 16] = dev->data[5 * i + 42]; | ||
| 202 | if (i < 2) | ||
| 203 | dev->xy_cur[i + 24] = dev->data[5 * i + 44]; | ||
| 204 | |||
| 205 | /* Y values */ | ||
| 206 | dev->xy_cur[i + 26] = dev->data[5 * i + 1]; | ||
| 207 | dev->xy_cur[i + 34] = dev->data[5 * i + 3]; | ||
| 208 | } | ||
| 209 | |||
| 210 | dbg_dump("sample", dev->xy_cur); | ||
| 211 | |||
| 212 | if (!dev->valid) { | ||
| 213 | /* first sample */ | ||
| 214 | dev->valid = 1; | ||
| 215 | dev->x_old = dev->y_old = -1; | ||
| 216 | memcpy(dev->xy_old, dev->xy_cur, sizeof(dev->xy_old)); | ||
| 217 | |||
| 218 | /* 17" Powerbooks have 10 extra X sensors */ | ||
| 219 | for (i = 16; i < ATP_XSENSORS; i++) | ||
| 220 | if (dev->xy_cur[i]) { | ||
| 221 | printk("appletouch: 17\" model detected.\n"); | ||
| 222 | input_set_abs_params(&dev->input, ABS_X, 0, | ||
| 223 | (ATP_XSENSORS - 1) * | ||
| 224 | ATP_XFACT - 1, | ||
| 225 | ATP_FUZZ, 0); | ||
| 226 | break; | ||
| 227 | } | ||
| 228 | |||
| 229 | goto exit; | ||
| 230 | } | ||
| 231 | |||
| 232 | for (i = 0; i < ATP_XSENSORS + ATP_YSENSORS; i++) { | ||
| 233 | /* accumulate the change */ | ||
| 234 | signed char change = dev->xy_old[i] - dev->xy_cur[i]; | ||
| 235 | dev->xy_acc[i] -= change; | ||
| 236 | |||
| 237 | /* prevent down drifting */ | ||
| 238 | if (dev->xy_acc[i] < 0) | ||
| 239 | dev->xy_acc[i] = 0; | ||
| 240 | } | ||
| 241 | |||
| 242 | memcpy(dev->xy_old, dev->xy_cur, sizeof(dev->xy_old)); | ||
| 243 | |||
| 244 | dbg_dump("accumulator", dev->xy_acc); | ||
| 245 | |||
| 246 | x = atp_calculate_abs(dev->xy_acc, ATP_XSENSORS, | ||
| 247 | ATP_XFACT, &x_z, &x_f); | ||
| 248 | y = atp_calculate_abs(dev->xy_acc + ATP_XSENSORS, ATP_YSENSORS, | ||
| 249 | ATP_YFACT, &y_z, &y_f); | ||
| 250 | |||
| 251 | if (x && y) { | ||
| 252 | if (dev->x_old != -1) { | ||
| 253 | x = (dev->x_old * 3 + x) >> 2; | ||
| 254 | y = (dev->y_old * 3 + y) >> 2; | ||
| 255 | dev->x_old = x; | ||
| 256 | dev->y_old = y; | ||
| 257 | |||
| 258 | if (debug > 1) | ||
| 259 | printk("appletouch: X: %3d Y: %3d " | ||
| 260 | "Xz: %3d Yz: %3d\n", | ||
| 261 | x, y, x_z, y_z); | ||
| 262 | |||
| 263 | input_report_key(&dev->input, BTN_TOUCH, 1); | ||
| 264 | input_report_abs(&dev->input, ABS_X, x); | ||
| 265 | input_report_abs(&dev->input, ABS_Y, y); | ||
| 266 | input_report_abs(&dev->input, ABS_PRESSURE, | ||
| 267 | min(ATP_PRESSURE, x_z + y_z)); | ||
| 268 | atp_report_fingers(&dev->input, max(x_f, y_f)); | ||
| 269 | } | ||
| 270 | dev->x_old = x; | ||
| 271 | dev->y_old = y; | ||
| 272 | } | ||
| 273 | else if (!x && !y) { | ||
| 274 | |||
| 275 | dev->x_old = dev->y_old = -1; | ||
| 276 | input_report_key(&dev->input, BTN_TOUCH, 0); | ||
| 277 | input_report_abs(&dev->input, ABS_PRESSURE, 0); | ||
| 278 | atp_report_fingers(&dev->input, 0); | ||
| 279 | |||
| 280 | /* reset the accumulator on release */ | ||
| 281 | memset(dev->xy_acc, 0, sizeof(dev->xy_acc)); | ||
| 282 | } | ||
| 283 | |||
| 284 | input_report_key(&dev->input, BTN_LEFT, !!dev->data[80]); | ||
| 285 | |||
| 286 | input_sync(&dev->input); | ||
| 287 | |||
| 288 | exit: | ||
| 289 | retval = usb_submit_urb(dev->urb, GFP_ATOMIC); | ||
| 290 | if (retval) { | ||
| 291 | err("%s - usb_submit_urb failed with result %d", | ||
| 292 | __FUNCTION__, retval); | ||
| 293 | } | ||
| 294 | } | ||
| 295 | |||
| 296 | static int atp_open(struct input_dev *input) | ||
| 297 | { | ||
| 298 | struct atp *dev = input->private; | ||
| 299 | |||
| 300 | if (usb_submit_urb(dev->urb, GFP_ATOMIC)) | ||
| 301 | return -EIO; | ||
| 302 | |||
| 303 | dev->open = 1; | ||
| 304 | return 0; | ||
| 305 | } | ||
| 306 | |||
| 307 | static void atp_close(struct input_dev *input) | ||
| 308 | { | ||
| 309 | struct atp *dev = input->private; | ||
| 310 | |||
| 311 | usb_kill_urb(dev->urb); | ||
| 312 | dev->open = 0; | ||
| 313 | } | ||
| 314 | |||
| 315 | static int atp_probe(struct usb_interface *iface, const struct usb_device_id *id) | ||
| 316 | { | ||
| 317 | struct atp *dev = NULL; | ||
| 318 | struct usb_host_interface *iface_desc; | ||
| 319 | struct usb_endpoint_descriptor *endpoint; | ||
| 320 | int int_in_endpointAddr = 0; | ||
| 321 | int i, retval = -ENOMEM; | ||
| 322 | |||
| 323 | /* allocate memory for our device state and initialize it */ | ||
| 324 | dev = kmalloc(sizeof(struct atp), GFP_KERNEL); | ||
| 325 | if (dev == NULL) { | ||
| 326 | err("Out of memory"); | ||
| 327 | goto err_kmalloc; | ||
| 328 | } | ||
| 329 | memset(dev, 0, sizeof(struct atp)); | ||
| 330 | |||
| 331 | dev->udev = interface_to_usbdev(iface); | ||
| 332 | |||
| 333 | /* set up the endpoint information */ | ||
| 334 | /* use only the first interrupt-in endpoint */ | ||
| 335 | iface_desc = iface->cur_altsetting; | ||
| 336 | for (i = 0; i < iface_desc->desc.bNumEndpoints; i++) { | ||
| 337 | endpoint = &iface_desc->endpoint[i].desc; | ||
| 338 | if (!int_in_endpointAddr && | ||
| 339 | (endpoint->bEndpointAddress & USB_DIR_IN) && | ||
| 340 | ((endpoint->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) | ||
| 341 | == USB_ENDPOINT_XFER_INT)) { | ||
| 342 | /* we found an interrupt in endpoint */ | ||
| 343 | int_in_endpointAddr = endpoint->bEndpointAddress; | ||
| 344 | break; | ||
| 345 | } | ||
| 346 | } | ||
| 347 | if (!int_in_endpointAddr) { | ||
| 348 | retval = -EIO; | ||
| 349 | err("Could not find int-in endpoint"); | ||
| 350 | goto err_endpoint; | ||
| 351 | } | ||
| 352 | |||
| 353 | /* save our data pointer in this interface device */ | ||
| 354 | usb_set_intfdata(iface, dev); | ||
| 355 | |||
| 356 | dev->urb = usb_alloc_urb(0, GFP_KERNEL); | ||
| 357 | if (!dev->urb) { | ||
| 358 | retval = -ENOMEM; | ||
| 359 | goto err_usballoc; | ||
| 360 | } | ||
| 361 | dev->data = usb_buffer_alloc(dev->udev, ATP_DATASIZE, GFP_KERNEL, | ||
| 362 | &dev->urb->transfer_dma); | ||
| 363 | if (!dev->data) { | ||
| 364 | retval = -ENOMEM; | ||
| 365 | goto err_usbbufalloc; | ||
| 366 | } | ||
| 367 | usb_fill_int_urb(dev->urb, dev->udev, | ||
| 368 | usb_rcvintpipe(dev->udev, int_in_endpointAddr), | ||
| 369 | dev->data, ATP_DATASIZE, atp_complete, dev, 1); | ||
| 370 | |||
| 371 | init_input_dev(&dev->input); | ||
| 372 | dev->input.name = "appletouch"; | ||
| 373 | dev->input.dev = &iface->dev; | ||
| 374 | dev->input.private = dev; | ||
| 375 | dev->input.open = atp_open; | ||
| 376 | dev->input.close = atp_close; | ||
| 377 | |||
| 378 | usb_to_input_id(dev->udev, &dev->input.id); | ||
| 379 | |||
| 380 | set_bit(EV_ABS, dev->input.evbit); | ||
| 381 | |||
| 382 | /* | ||
| 383 | * 12" and 15" Powerbooks only have 16 x sensors, | ||
| 384 | * 17" models are detected later. | ||
| 385 | */ | ||
| 386 | input_set_abs_params(&dev->input, ABS_X, 0, | ||
| 387 | (16 - 1) * ATP_XFACT - 1, ATP_FUZZ, 0); | ||
| 388 | input_set_abs_params(&dev->input, ABS_Y, 0, | ||
| 389 | (ATP_YSENSORS - 1) * ATP_YFACT - 1, ATP_FUZZ, 0); | ||
| 390 | input_set_abs_params(&dev->input, ABS_PRESSURE, 0, ATP_PRESSURE, 0, 0); | ||
| 391 | |||
| 392 | set_bit(EV_KEY, dev->input.evbit); | ||
| 393 | set_bit(BTN_TOUCH, dev->input.keybit); | ||
| 394 | set_bit(BTN_TOOL_FINGER, dev->input.keybit); | ||
| 395 | set_bit(BTN_TOOL_DOUBLETAP, dev->input.keybit); | ||
| 396 | set_bit(BTN_TOOL_TRIPLETAP, dev->input.keybit); | ||
| 397 | set_bit(BTN_LEFT, dev->input.keybit); | ||
| 398 | |||
| 399 | input_register_device(&dev->input); | ||
| 400 | |||
| 401 | printk(KERN_INFO "input: appletouch connected\n"); | ||
| 402 | |||
| 403 | return 0; | ||
| 404 | |||
| 405 | err_usbbufalloc: | ||
| 406 | usb_free_urb(dev->urb); | ||
| 407 | err_usballoc: | ||
| 408 | usb_set_intfdata(iface, NULL); | ||
| 409 | err_endpoint: | ||
| 410 | kfree(dev); | ||
| 411 | err_kmalloc: | ||
| 412 | return retval; | ||
| 413 | } | ||
| 414 | |||
| 415 | static void atp_disconnect(struct usb_interface *iface) | ||
| 416 | { | ||
| 417 | struct atp *dev = usb_get_intfdata(iface); | ||
| 418 | |||
| 419 | usb_set_intfdata(iface, NULL); | ||
| 420 | if (dev) { | ||
| 421 | usb_kill_urb(dev->urb); | ||
| 422 | input_unregister_device(&dev->input); | ||
| 423 | usb_free_urb(dev->urb); | ||
| 424 | usb_buffer_free(dev->udev, ATP_DATASIZE, | ||
| 425 | dev->data, dev->urb->transfer_dma); | ||
| 426 | kfree(dev); | ||
| 427 | } | ||
| 428 | printk(KERN_INFO "input: appletouch disconnected\n"); | ||
| 429 | } | ||
| 430 | |||
| 431 | static int atp_suspend(struct usb_interface *iface, pm_message_t message) | ||
| 432 | { | ||
| 433 | struct atp *dev = usb_get_intfdata(iface); | ||
| 434 | usb_kill_urb(dev->urb); | ||
| 435 | dev->valid = 0; | ||
| 436 | return 0; | ||
| 437 | } | ||
| 438 | |||
| 439 | static int atp_resume(struct usb_interface *iface) | ||
| 440 | { | ||
| 441 | struct atp *dev = usb_get_intfdata(iface); | ||
| 442 | if (dev->open && usb_submit_urb(dev->urb, GFP_ATOMIC)) | ||
| 443 | return -EIO; | ||
| 444 | |||
| 445 | return 0; | ||
| 446 | } | ||
| 447 | |||
| 448 | static struct usb_driver atp_driver = { | ||
| 449 | .owner = THIS_MODULE, | ||
| 450 | .name = "appletouch", | ||
| 451 | .probe = atp_probe, | ||
| 452 | .disconnect = atp_disconnect, | ||
| 453 | .suspend = atp_suspend, | ||
| 454 | .resume = atp_resume, | ||
| 455 | .id_table = atp_table, | ||
| 456 | }; | ||
| 457 | |||
| 458 | static int __init atp_init(void) | ||
| 459 | { | ||
| 460 | return usb_register(&atp_driver); | ||
| 461 | } | ||
| 462 | |||
| 463 | static void __exit atp_exit(void) | ||
| 464 | { | ||
| 465 | usb_deregister(&atp_driver); | ||
| 466 | } | ||
| 467 | |||
| 468 | module_init(atp_init); | ||
| 469 | module_exit(atp_exit); | ||
diff --git a/drivers/usb/input/hid-core.c b/drivers/usb/input/hid-core.c index b2cb2b35892e..a99865c689c5 100644 --- a/drivers/usb/input/hid-core.c +++ b/drivers/usb/input/hid-core.c | |||
| @@ -2,7 +2,8 @@ | |||
| 2 | * USB HID support for Linux | 2 | * USB HID support for Linux |
| 3 | * | 3 | * |
| 4 | * Copyright (c) 1999 Andreas Gal | 4 | * Copyright (c) 1999 Andreas Gal |
| 5 | * Copyright (c) 2000-2001 Vojtech Pavlik <vojtech@suse.cz> | 5 | * Copyright (c) 2000-2005 Vojtech Pavlik <vojtech@suse.cz> |
| 6 | * Copyright (c) 2005 Michael Haboustak <mike-@cinci.rr.com> for Concept2, Inc | ||
| 6 | */ | 7 | */ |
| 7 | 8 | ||
| 8 | /* | 9 | /* |
| @@ -38,7 +39,7 @@ | |||
| 38 | * Version Information | 39 | * Version Information |
| 39 | */ | 40 | */ |
| 40 | 41 | ||
| 41 | #define DRIVER_VERSION "v2.01" | 42 | #define DRIVER_VERSION "v2.6" |
| 42 | #define DRIVER_AUTHOR "Andreas Gal, Vojtech Pavlik" | 43 | #define DRIVER_AUTHOR "Andreas Gal, Vojtech Pavlik" |
| 43 | #define DRIVER_DESC "USB HID core driver" | 44 | #define DRIVER_DESC "USB HID core driver" |
| 44 | #define DRIVER_LICENSE "GPL" | 45 | #define DRIVER_LICENSE "GPL" |
| @@ -1058,8 +1059,8 @@ static int hid_submit_ctrl(struct hid_device *hid) | |||
| 1058 | if (maxpacket > 0) { | 1059 | if (maxpacket > 0) { |
| 1059 | padlen = (len + maxpacket - 1) / maxpacket; | 1060 | padlen = (len + maxpacket - 1) / maxpacket; |
| 1060 | padlen *= maxpacket; | 1061 | padlen *= maxpacket; |
| 1061 | if (padlen > HID_BUFFER_SIZE) | 1062 | if (padlen > hid->bufsize) |
| 1062 | padlen = HID_BUFFER_SIZE; | 1063 | padlen = hid->bufsize; |
| 1063 | } else | 1064 | } else |
| 1064 | padlen = 0; | 1065 | padlen = 0; |
| 1065 | hid->urbctrl->transfer_buffer_length = padlen; | 1066 | hid->urbctrl->transfer_buffer_length = padlen; |
| @@ -1096,6 +1097,7 @@ static void hid_irq_out(struct urb *urb, struct pt_regs *regs) | |||
| 1096 | 1097 | ||
| 1097 | switch (urb->status) { | 1098 | switch (urb->status) { |
| 1098 | case 0: /* success */ | 1099 | case 0: /* success */ |
| 1100 | break; | ||
| 1099 | case -ESHUTDOWN: /* unplug */ | 1101 | case -ESHUTDOWN: /* unplug */ |
| 1100 | case -EILSEQ: /* unplug timeout on uhci */ | 1102 | case -EILSEQ: /* unplug timeout on uhci */ |
| 1101 | unplug = 1; | 1103 | unplug = 1; |
| @@ -1143,6 +1145,7 @@ static void hid_ctrl(struct urb *urb, struct pt_regs *regs) | |||
| 1143 | case 0: /* success */ | 1145 | case 0: /* success */ |
| 1144 | if (hid->ctrl[hid->ctrltail].dir == USB_DIR_IN) | 1146 | if (hid->ctrl[hid->ctrltail].dir == USB_DIR_IN) |
| 1145 | hid_input_report(hid->ctrl[hid->ctrltail].report->type, urb, 0, regs); | 1147 | hid_input_report(hid->ctrl[hid->ctrltail].report->type, urb, 0, regs); |
| 1148 | break; | ||
| 1146 | case -ESHUTDOWN: /* unplug */ | 1149 | case -ESHUTDOWN: /* unplug */ |
| 1147 | case -EILSEQ: /* unplug timectrl on uhci */ | 1150 | case -EILSEQ: /* unplug timectrl on uhci */ |
| 1148 | unplug = 1; | 1151 | unplug = 1; |
| @@ -1284,13 +1287,8 @@ void hid_init_reports(struct hid_device *hid) | |||
| 1284 | struct hid_report *report; | 1287 | struct hid_report *report; |
| 1285 | int err, ret; | 1288 | int err, ret; |
| 1286 | 1289 | ||
| 1287 | list_for_each_entry(report, &hid->report_enum[HID_INPUT_REPORT].report_list, list) { | 1290 | list_for_each_entry(report, &hid->report_enum[HID_INPUT_REPORT].report_list, list) |
| 1288 | int size = ((report->size - 1) >> 3) + 1 + hid->report_enum[HID_INPUT_REPORT].numbered; | ||
| 1289 | if (size > HID_BUFFER_SIZE) size = HID_BUFFER_SIZE; | ||
| 1290 | if (size > hid->urbin->transfer_buffer_length) | ||
| 1291 | hid->urbin->transfer_buffer_length = size; | ||
| 1292 | hid_submit_report(hid, report, USB_DIR_IN); | 1291 | hid_submit_report(hid, report, USB_DIR_IN); |
| 1293 | } | ||
| 1294 | 1292 | ||
| 1295 | list_for_each_entry(report, &hid->report_enum[HID_FEATURE_REPORT].report_list, list) | 1293 | list_for_each_entry(report, &hid->report_enum[HID_FEATURE_REPORT].report_list, list) |
| 1296 | hid_submit_report(hid, report, USB_DIR_IN); | 1294 | hid_submit_report(hid, report, USB_DIR_IN); |
| @@ -1372,12 +1370,14 @@ void hid_init_reports(struct hid_device *hid) | |||
| 1372 | #define USB_VENDOR_ID_A4TECH 0x09da | 1370 | #define USB_VENDOR_ID_A4TECH 0x09da |
| 1373 | #define USB_DEVICE_ID_A4TECH_WCP32PU 0x0006 | 1371 | #define USB_DEVICE_ID_A4TECH_WCP32PU 0x0006 |
| 1374 | 1372 | ||
| 1375 | #define USB_VENDOR_ID_AASHIMA 0x06D6 | 1373 | #define USB_VENDOR_ID_AASHIMA 0x06d6 |
| 1376 | #define USB_DEVICE_ID_AASHIMA_GAMEPAD 0x0025 | 1374 | #define USB_DEVICE_ID_AASHIMA_GAMEPAD 0x0025 |
| 1375 | #define USB_DEVICE_ID_AASHIMA_PREDATOR 0x0026 | ||
| 1377 | 1376 | ||
| 1378 | #define USB_VENDOR_ID_CYPRESS 0x04b4 | 1377 | #define USB_VENDOR_ID_CYPRESS 0x04b4 |
| 1379 | #define USB_DEVICE_ID_CYPRESS_MOUSE 0x0001 | 1378 | #define USB_DEVICE_ID_CYPRESS_MOUSE 0x0001 |
| 1380 | #define USB_DEVICE_ID_CYPRESS_HIDCOM 0x5500 | 1379 | #define USB_DEVICE_ID_CYPRESS_HIDCOM 0x5500 |
| 1380 | #define USB_DEVICE_ID_CYPRESS_ULTRAMOUSE 0x7417 | ||
| 1381 | 1381 | ||
| 1382 | #define USB_VENDOR_ID_BERKSHIRE 0x0c98 | 1382 | #define USB_VENDOR_ID_BERKSHIRE 0x0c98 |
| 1383 | #define USB_DEVICE_ID_BERKSHIRE_PCWD 0x1140 | 1383 | #define USB_DEVICE_ID_BERKSHIRE_PCWD 0x1140 |
| @@ -1432,7 +1432,7 @@ void hid_init_reports(struct hid_device *hid) | |||
| 1432 | #define USB_DEVICE_ID_VERNIER_CYCLOPS 0x0004 | 1432 | #define USB_DEVICE_ID_VERNIER_CYCLOPS 0x0004 |
| 1433 | 1433 | ||
| 1434 | #define USB_VENDOR_ID_LD 0x0f11 | 1434 | #define USB_VENDOR_ID_LD 0x0f11 |
| 1435 | #define USB_DEVICE_ID_CASSY 0x1000 | 1435 | #define USB_DEVICE_ID_CASSY 0x1000 |
| 1436 | #define USB_DEVICE_ID_POCKETCASSY 0x1010 | 1436 | #define USB_DEVICE_ID_POCKETCASSY 0x1010 |
| 1437 | #define USB_DEVICE_ID_MOBILECASSY 0x1020 | 1437 | #define USB_DEVICE_ID_MOBILECASSY 0x1020 |
| 1438 | #define USB_DEVICE_ID_JWM 0x1080 | 1438 | #define USB_DEVICE_ID_JWM 0x1080 |
| @@ -1444,6 +1444,8 @@ void hid_init_reports(struct hid_device *hid) | |||
| 1444 | #define USB_DEVICE_ID_NETWORKANALYSER 0x2020 | 1444 | #define USB_DEVICE_ID_NETWORKANALYSER 0x2020 |
| 1445 | #define USB_DEVICE_ID_POWERCONTROL 0x2030 | 1445 | #define USB_DEVICE_ID_POWERCONTROL 0x2030 |
| 1446 | 1446 | ||
| 1447 | #define USB_VENDOR_ID_APPLE 0x05ac | ||
| 1448 | #define USB_DEVICE_ID_APPLE_POWERMOUSE 0x0304 | ||
| 1447 | 1449 | ||
| 1448 | /* | 1450 | /* |
| 1449 | * Alphabetically sorted blacklist by quirk type. | 1451 | * Alphabetically sorted blacklist by quirk type. |
| @@ -1468,6 +1470,7 @@ static struct hid_blacklist { | |||
| 1468 | { USB_VENDOR_ID_CODEMERCS, USB_DEVICE_ID_CODEMERCS_IOW48, HID_QUIRK_IGNORE }, | 1470 | { USB_VENDOR_ID_CODEMERCS, USB_DEVICE_ID_CODEMERCS_IOW48, HID_QUIRK_IGNORE }, |
| 1469 | { USB_VENDOR_ID_CODEMERCS, USB_DEVICE_ID_CODEMERCS_IOW28, HID_QUIRK_IGNORE }, | 1471 | { USB_VENDOR_ID_CODEMERCS, USB_DEVICE_ID_CODEMERCS_IOW28, HID_QUIRK_IGNORE }, |
| 1470 | { USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_HIDCOM, HID_QUIRK_IGNORE }, | 1472 | { USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_HIDCOM, HID_QUIRK_IGNORE }, |
| 1473 | { USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_ULTRAMOUSE, HID_QUIRK_IGNORE }, | ||
| 1471 | { USB_VENDOR_ID_DELORME, USB_DEVICE_ID_DELORME_EARTHMATE, HID_QUIRK_IGNORE }, | 1474 | { USB_VENDOR_ID_DELORME, USB_DEVICE_ID_DELORME_EARTHMATE, HID_QUIRK_IGNORE }, |
| 1472 | { USB_VENDOR_ID_DELORME, USB_DEVICE_ID_DELORME_EM_LT20, HID_QUIRK_IGNORE }, | 1475 | { USB_VENDOR_ID_DELORME, USB_DEVICE_ID_DELORME_EM_LT20, HID_QUIRK_IGNORE }, |
| 1473 | { USB_VENDOR_ID_ESSENTIAL_REALITY, USB_DEVICE_ID_ESSENTIAL_REALITY_P5, HID_QUIRK_IGNORE }, | 1476 | { USB_VENDOR_ID_ESSENTIAL_REALITY, USB_DEVICE_ID_ESSENTIAL_REALITY_P5, HID_QUIRK_IGNORE }, |
| @@ -1548,10 +1551,12 @@ static struct hid_blacklist { | |||
| 1548 | { USB_VENDOR_ID_CHICONY, USB_DEVICE_ID_CHICONY_USBHUB_KB, HID_QUIRK_NOGET}, | 1551 | { USB_VENDOR_ID_CHICONY, USB_DEVICE_ID_CHICONY_USBHUB_KB, HID_QUIRK_NOGET}, |
| 1549 | { USB_VENDOR_ID_TANGTOP, USB_DEVICE_ID_TANGTOP_USBPS2, HID_QUIRK_NOGET }, | 1552 | { USB_VENDOR_ID_TANGTOP, USB_DEVICE_ID_TANGTOP_USBPS2, HID_QUIRK_NOGET }, |
| 1550 | 1553 | ||
| 1554 | { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_POWERMOUSE, HID_QUIRK_2WHEEL_POWERMOUSE }, | ||
| 1551 | { USB_VENDOR_ID_A4TECH, USB_DEVICE_ID_A4TECH_WCP32PU, HID_QUIRK_2WHEEL_MOUSE_HACK_7 }, | 1555 | { USB_VENDOR_ID_A4TECH, USB_DEVICE_ID_A4TECH_WCP32PU, HID_QUIRK_2WHEEL_MOUSE_HACK_7 }, |
| 1552 | { USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_MOUSE, HID_QUIRK_2WHEEL_MOUSE_HACK_5 }, | 1556 | { USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_MOUSE, HID_QUIRK_2WHEEL_MOUSE_HACK_5 }, |
| 1553 | 1557 | ||
| 1554 | { USB_VENDOR_ID_AASHIMA, USB_DEVICE_ID_AASHIMA_GAMEPAD, HID_QUIRK_BADPAD }, | 1558 | { USB_VENDOR_ID_AASHIMA, USB_DEVICE_ID_AASHIMA_GAMEPAD, HID_QUIRK_BADPAD }, |
| 1559 | { USB_VENDOR_ID_AASHIMA, USB_DEVICE_ID_AASHIMA_PREDATOR, HID_QUIRK_BADPAD }, | ||
| 1555 | { USB_VENDOR_ID_ALPS, USB_DEVICE_ID_IBM_GAMEPAD, HID_QUIRK_BADPAD }, | 1560 | { USB_VENDOR_ID_ALPS, USB_DEVICE_ID_IBM_GAMEPAD, HID_QUIRK_BADPAD }, |
| 1556 | { USB_VENDOR_ID_CHIC, USB_DEVICE_ID_CHIC_GAMEPAD, HID_QUIRK_BADPAD }, | 1561 | { USB_VENDOR_ID_CHIC, USB_DEVICE_ID_CHIC_GAMEPAD, HID_QUIRK_BADPAD }, |
| 1557 | { USB_VENDOR_ID_HAPP, USB_DEVICE_ID_UGCI_DRIVING, HID_QUIRK_BADPAD | HID_QUIRK_MULTI_INPUT }, | 1562 | { USB_VENDOR_ID_HAPP, USB_DEVICE_ID_UGCI_DRIVING, HID_QUIRK_BADPAD | HID_QUIRK_MULTI_INPUT }, |
| @@ -1564,15 +1569,32 @@ static struct hid_blacklist { | |||
| 1564 | { 0, 0 } | 1569 | { 0, 0 } |
| 1565 | }; | 1570 | }; |
| 1566 | 1571 | ||
| 1572 | /* | ||
| 1573 | * Traverse the supplied list of reports and find the longest | ||
| 1574 | */ | ||
| 1575 | static void hid_find_max_report(struct hid_device *hid, unsigned int type, int *max) | ||
| 1576 | { | ||
| 1577 | struct hid_report *report; | ||
| 1578 | int size; | ||
| 1579 | |||
| 1580 | list_for_each_entry(report, &hid->report_enum[type].report_list, list) { | ||
| 1581 | size = ((report->size - 1) >> 3) + 1; | ||
| 1582 | if (type == HID_INPUT_REPORT && hid->report_enum[type].numbered) | ||
| 1583 | size++; | ||
| 1584 | if (*max < size) | ||
| 1585 | *max = size; | ||
| 1586 | } | ||
| 1587 | } | ||
| 1588 | |||
| 1567 | static int hid_alloc_buffers(struct usb_device *dev, struct hid_device *hid) | 1589 | static int hid_alloc_buffers(struct usb_device *dev, struct hid_device *hid) |
| 1568 | { | 1590 | { |
| 1569 | if (!(hid->inbuf = usb_buffer_alloc(dev, HID_BUFFER_SIZE, SLAB_ATOMIC, &hid->inbuf_dma))) | 1591 | if (!(hid->inbuf = usb_buffer_alloc(dev, hid->bufsize, SLAB_ATOMIC, &hid->inbuf_dma))) |
| 1570 | return -1; | 1592 | return -1; |
| 1571 | if (!(hid->outbuf = usb_buffer_alloc(dev, HID_BUFFER_SIZE, SLAB_ATOMIC, &hid->outbuf_dma))) | 1593 | if (!(hid->outbuf = usb_buffer_alloc(dev, hid->bufsize, SLAB_ATOMIC, &hid->outbuf_dma))) |
| 1572 | return -1; | 1594 | return -1; |
| 1573 | if (!(hid->cr = usb_buffer_alloc(dev, sizeof(*(hid->cr)), SLAB_ATOMIC, &hid->cr_dma))) | 1595 | if (!(hid->cr = usb_buffer_alloc(dev, sizeof(*(hid->cr)), SLAB_ATOMIC, &hid->cr_dma))) |
| 1574 | return -1; | 1596 | return -1; |
| 1575 | if (!(hid->ctrlbuf = usb_buffer_alloc(dev, HID_BUFFER_SIZE, SLAB_ATOMIC, &hid->ctrlbuf_dma))) | 1597 | if (!(hid->ctrlbuf = usb_buffer_alloc(dev, hid->bufsize, SLAB_ATOMIC, &hid->ctrlbuf_dma))) |
| 1576 | return -1; | 1598 | return -1; |
| 1577 | 1599 | ||
| 1578 | return 0; | 1600 | return 0; |
| @@ -1581,13 +1603,13 @@ static int hid_alloc_buffers(struct usb_device *dev, struct hid_device *hid) | |||
| 1581 | static void hid_free_buffers(struct usb_device *dev, struct hid_device *hid) | 1603 | static void hid_free_buffers(struct usb_device *dev, struct hid_device *hid) |
| 1582 | { | 1604 | { |
| 1583 | if (hid->inbuf) | 1605 | if (hid->inbuf) |
| 1584 | usb_buffer_free(dev, HID_BUFFER_SIZE, hid->inbuf, hid->inbuf_dma); | 1606 | usb_buffer_free(dev, hid->bufsize, hid->inbuf, hid->inbuf_dma); |
| 1585 | if (hid->outbuf) | 1607 | if (hid->outbuf) |
| 1586 | usb_buffer_free(dev, HID_BUFFER_SIZE, hid->outbuf, hid->outbuf_dma); | 1608 | usb_buffer_free(dev, hid->bufsize, hid->outbuf, hid->outbuf_dma); |
| 1587 | if (hid->cr) | 1609 | if (hid->cr) |
| 1588 | usb_buffer_free(dev, sizeof(*(hid->cr)), hid->cr, hid->cr_dma); | 1610 | usb_buffer_free(dev, sizeof(*(hid->cr)), hid->cr, hid->cr_dma); |
| 1589 | if (hid->ctrlbuf) | 1611 | if (hid->ctrlbuf) |
| 1590 | usb_buffer_free(dev, HID_BUFFER_SIZE, hid->ctrlbuf, hid->ctrlbuf_dma); | 1612 | usb_buffer_free(dev, hid->bufsize, hid->ctrlbuf, hid->ctrlbuf_dma); |
| 1591 | } | 1613 | } |
| 1592 | 1614 | ||
| 1593 | static struct hid_device *usb_hid_configure(struct usb_interface *intf) | 1615 | static struct hid_device *usb_hid_configure(struct usb_interface *intf) |
| @@ -1598,7 +1620,7 @@ static struct hid_device *usb_hid_configure(struct usb_interface *intf) | |||
| 1598 | struct hid_device *hid; | 1620 | struct hid_device *hid; |
| 1599 | unsigned quirks = 0, rsize = 0; | 1621 | unsigned quirks = 0, rsize = 0; |
| 1600 | char *buf, *rdesc; | 1622 | char *buf, *rdesc; |
| 1601 | int n; | 1623 | int n, insize = 0; |
| 1602 | 1624 | ||
| 1603 | for (n = 0; hid_blacklist[n].idVendor; n++) | 1625 | for (n = 0; hid_blacklist[n].idVendor; n++) |
| 1604 | if ((hid_blacklist[n].idVendor == le16_to_cpu(dev->descriptor.idVendor)) && | 1626 | if ((hid_blacklist[n].idVendor == le16_to_cpu(dev->descriptor.idVendor)) && |
| @@ -1652,6 +1674,19 @@ static struct hid_device *usb_hid_configure(struct usb_interface *intf) | |||
| 1652 | kfree(rdesc); | 1674 | kfree(rdesc); |
| 1653 | hid->quirks = quirks; | 1675 | hid->quirks = quirks; |
| 1654 | 1676 | ||
| 1677 | hid->bufsize = HID_MIN_BUFFER_SIZE; | ||
| 1678 | hid_find_max_report(hid, HID_INPUT_REPORT, &hid->bufsize); | ||
| 1679 | hid_find_max_report(hid, HID_OUTPUT_REPORT, &hid->bufsize); | ||
| 1680 | hid_find_max_report(hid, HID_FEATURE_REPORT, &hid->bufsize); | ||
| 1681 | |||
| 1682 | if (hid->bufsize > HID_MAX_BUFFER_SIZE) | ||
| 1683 | hid->bufsize = HID_MAX_BUFFER_SIZE; | ||
| 1684 | |||
| 1685 | hid_find_max_report(hid, HID_INPUT_REPORT, &insize); | ||
| 1686 | |||
| 1687 | if (insize > HID_MAX_BUFFER_SIZE) | ||
| 1688 | insize = HID_MAX_BUFFER_SIZE; | ||
| 1689 | |||
| 1655 | if (hid_alloc_buffers(dev, hid)) { | 1690 | if (hid_alloc_buffers(dev, hid)) { |
| 1656 | hid_free_buffers(dev, hid); | 1691 | hid_free_buffers(dev, hid); |
| 1657 | goto fail; | 1692 | goto fail; |
| @@ -1682,10 +1717,10 @@ static struct hid_device *usb_hid_configure(struct usb_interface *intf) | |||
| 1682 | if (!(hid->urbin = usb_alloc_urb(0, GFP_KERNEL))) | 1717 | if (!(hid->urbin = usb_alloc_urb(0, GFP_KERNEL))) |
| 1683 | goto fail; | 1718 | goto fail; |
| 1684 | pipe = usb_rcvintpipe(dev, endpoint->bEndpointAddress); | 1719 | pipe = usb_rcvintpipe(dev, endpoint->bEndpointAddress); |
| 1685 | usb_fill_int_urb(hid->urbin, dev, pipe, hid->inbuf, 0, | 1720 | usb_fill_int_urb(hid->urbin, dev, pipe, hid->inbuf, insize, |
| 1686 | hid_irq_in, hid, interval); | 1721 | hid_irq_in, hid, interval); |
| 1687 | hid->urbin->transfer_dma = hid->inbuf_dma; | 1722 | hid->urbin->transfer_dma = hid->inbuf_dma; |
| 1688 | hid->urbin->transfer_flags |=(URB_NO_TRANSFER_DMA_MAP | URB_ASYNC_UNLINK); | 1723 | hid->urbin->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; |
| 1689 | } else { | 1724 | } else { |
| 1690 | if (hid->urbout) | 1725 | if (hid->urbout) |
| 1691 | continue; | 1726 | continue; |
| @@ -1695,7 +1730,7 @@ static struct hid_device *usb_hid_configure(struct usb_interface *intf) | |||
| 1695 | usb_fill_int_urb(hid->urbout, dev, pipe, hid->outbuf, 0, | 1730 | usb_fill_int_urb(hid->urbout, dev, pipe, hid->outbuf, 0, |
| 1696 | hid_irq_out, hid, interval); | 1731 | hid_irq_out, hid, interval); |
| 1697 | hid->urbout->transfer_dma = hid->outbuf_dma; | 1732 | hid->urbout->transfer_dma = hid->outbuf_dma; |
| 1698 | hid->urbout->transfer_flags |= (URB_NO_TRANSFER_DMA_MAP | URB_ASYNC_UNLINK); | 1733 | hid->urbout->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; |
| 1699 | } | 1734 | } |
| 1700 | } | 1735 | } |
| 1701 | 1736 | ||
| @@ -1747,7 +1782,7 @@ static struct hid_device *usb_hid_configure(struct usb_interface *intf) | |||
| 1747 | hid->ctrlbuf, 1, hid_ctrl, hid); | 1782 | hid->ctrlbuf, 1, hid_ctrl, hid); |
| 1748 | hid->urbctrl->setup_dma = hid->cr_dma; | 1783 | hid->urbctrl->setup_dma = hid->cr_dma; |
| 1749 | hid->urbctrl->transfer_dma = hid->ctrlbuf_dma; | 1784 | hid->urbctrl->transfer_dma = hid->ctrlbuf_dma; |
| 1750 | hid->urbctrl->transfer_flags |= (URB_NO_TRANSFER_DMA_MAP | URB_NO_SETUP_DMA_MAP | URB_ASYNC_UNLINK); | 1785 | hid->urbctrl->transfer_flags |= (URB_NO_TRANSFER_DMA_MAP | URB_NO_SETUP_DMA_MAP); |
| 1751 | 1786 | ||
| 1752 | return hid; | 1787 | return hid; |
| 1753 | 1788 | ||
diff --git a/drivers/usb/input/hid-debug.h b/drivers/usb/input/hid-debug.h index 52437e5e2e78..ceebab99eff2 100644 --- a/drivers/usb/input/hid-debug.h +++ b/drivers/usb/input/hid-debug.h | |||
| @@ -85,6 +85,23 @@ static const struct hid_usage_entry hid_usage_table[] = { | |||
| 85 | {0, 0x91, "D-PadDown"}, | 85 | {0, 0x91, "D-PadDown"}, |
| 86 | {0, 0x92, "D-PadRight"}, | 86 | {0, 0x92, "D-PadRight"}, |
| 87 | {0, 0x93, "D-PadLeft"}, | 87 | {0, 0x93, "D-PadLeft"}, |
| 88 | { 2, 0, "Simulation" }, | ||
| 89 | {0, 0xb0, "Aileron"}, | ||
| 90 | {0, 0xb1, "AileronTrim"}, | ||
| 91 | {0, 0xb2, "Anti-Torque"}, | ||
| 92 | {0, 0xb3, "Autopilot"}, | ||
| 93 | {0, 0xb4, "Chaff"}, | ||
| 94 | {0, 0xb5, "Collective"}, | ||
| 95 | {0, 0xb6, "DiveBrake"}, | ||
| 96 | {0, 0xb7, "ElectronicCountermeasures"}, | ||
| 97 | {0, 0xb8, "Elevator"}, | ||
| 98 | {0, 0xb9, "ElevatorTrim"}, | ||
| 99 | {0, 0xba, "Rudder"}, | ||
| 100 | {0, 0xbb, "Throttle"}, | ||
| 101 | {0, 0xbc, "FlightCommunications"}, | ||
| 102 | {0, 0xbd, "FlareRelease"}, | ||
| 103 | {0, 0xbe, "LandingGear"}, | ||
| 104 | {0, 0xbf, "ToeBrake"}, | ||
| 88 | { 7, 0, "Keyboard" }, | 105 | { 7, 0, "Keyboard" }, |
| 89 | { 8, 0, "LED" }, | 106 | { 8, 0, "LED" }, |
| 90 | {0, 0x01, "NumLock"}, | 107 | {0, 0x01, "NumLock"}, |
| @@ -92,6 +109,7 @@ static const struct hid_usage_entry hid_usage_table[] = { | |||
| 92 | {0, 0x03, "ScrollLock"}, | 109 | {0, 0x03, "ScrollLock"}, |
| 93 | {0, 0x04, "Compose"}, | 110 | {0, 0x04, "Compose"}, |
| 94 | {0, 0x05, "Kana"}, | 111 | {0, 0x05, "Kana"}, |
| 112 | {0, 0x4b, "GenericIndicator"}, | ||
| 95 | { 9, 0, "Button" }, | 113 | { 9, 0, "Button" }, |
| 96 | { 10, 0, "Ordinal" }, | 114 | { 10, 0, "Ordinal" }, |
| 97 | { 12, 0, "Consumer" }, | 115 | { 12, 0, "Consumer" }, |
| @@ -574,7 +592,8 @@ static char *keys[KEY_MAX + 1] = { | |||
| 574 | [KEY_EXIT] = "Exit", [KEY_MOVE] = "Move", | 592 | [KEY_EXIT] = "Exit", [KEY_MOVE] = "Move", |
| 575 | [KEY_EDIT] = "Edit", [KEY_SCROLLUP] = "ScrollUp", | 593 | [KEY_EDIT] = "Edit", [KEY_SCROLLUP] = "ScrollUp", |
| 576 | [KEY_SCROLLDOWN] = "ScrollDown", [KEY_KPLEFTPAREN] = "KPLeftParenthesis", | 594 | [KEY_SCROLLDOWN] = "ScrollDown", [KEY_KPLEFTPAREN] = "KPLeftParenthesis", |
| 577 | [KEY_KPRIGHTPAREN] = "KPRightParenthesis", [KEY_F13] = "F13", | 595 | [KEY_KPRIGHTPAREN] = "KPRightParenthesis", [KEY_NEW] = "New", |
| 596 | [KEY_REDO] = "Redo", [KEY_F13] = "F13", | ||
| 578 | [KEY_F14] = "F14", [KEY_F15] = "F15", | 597 | [KEY_F14] = "F14", [KEY_F15] = "F15", |
| 579 | [KEY_F16] = "F16", [KEY_F17] = "F17", | 598 | [KEY_F16] = "F16", [KEY_F17] = "F17", |
| 580 | [KEY_F18] = "F18", [KEY_F19] = "F19", | 599 | [KEY_F18] = "F18", [KEY_F19] = "F19", |
| @@ -584,15 +603,15 @@ static char *keys[KEY_MAX + 1] = { | |||
| 584 | [KEY_PAUSECD] = "PauseCD", [KEY_PROG3] = "Prog3", | 603 | [KEY_PAUSECD] = "PauseCD", [KEY_PROG3] = "Prog3", |
| 585 | [KEY_PROG4] = "Prog4", [KEY_SUSPEND] = "Suspend", | 604 | [KEY_PROG4] = "Prog4", [KEY_SUSPEND] = "Suspend", |
| 586 | [KEY_CLOSE] = "Close", [KEY_PLAY] = "Play", | 605 | [KEY_CLOSE] = "Close", [KEY_PLAY] = "Play", |
| 587 | [KEY_FASTFORWARD] = "Fast Forward", [KEY_BASSBOOST] = "Bass Boost", | 606 | [KEY_FASTFORWARD] = "FastForward", [KEY_BASSBOOST] = "BassBoost", |
| 588 | [KEY_PRINT] = "Print", [KEY_HP] = "HP", | 607 | [KEY_PRINT] = "Print", [KEY_HP] = "HP", |
| 589 | [KEY_CAMERA] = "Camera", [KEY_SOUND] = "Sound", | 608 | [KEY_CAMERA] = "Camera", [KEY_SOUND] = "Sound", |
| 590 | [KEY_QUESTION] = "Question", [KEY_EMAIL] = "Email", | 609 | [KEY_QUESTION] = "Question", [KEY_EMAIL] = "Email", |
| 591 | [KEY_CHAT] = "Chat", [KEY_SEARCH] = "Search", | 610 | [KEY_CHAT] = "Chat", [KEY_SEARCH] = "Search", |
| 592 | [KEY_CONNECT] = "Connect", [KEY_FINANCE] = "Finance", | 611 | [KEY_CONNECT] = "Connect", [KEY_FINANCE] = "Finance", |
| 593 | [KEY_SPORT] = "Sport", [KEY_SHOP] = "Shop", | 612 | [KEY_SPORT] = "Sport", [KEY_SHOP] = "Shop", |
| 594 | [KEY_ALTERASE] = "Alternate Erase", [KEY_CANCEL] = "Cancel", | 613 | [KEY_ALTERASE] = "AlternateErase", [KEY_CANCEL] = "Cancel", |
| 595 | [KEY_BRIGHTNESSDOWN] = "Brightness down", [KEY_BRIGHTNESSUP] = "Brightness up", | 614 | [KEY_BRIGHTNESSDOWN] = "BrightnessDown", [KEY_BRIGHTNESSUP] = "BrightnessUp", |
| 596 | [KEY_MEDIA] = "Media", [KEY_UNKNOWN] = "Unknown", | 615 | [KEY_MEDIA] = "Media", [KEY_UNKNOWN] = "Unknown", |
| 597 | [BTN_0] = "Btn0", [BTN_1] = "Btn1", | 616 | [BTN_0] = "Btn0", [BTN_1] = "Btn1", |
| 598 | [BTN_2] = "Btn2", [BTN_3] = "Btn3", | 617 | [BTN_2] = "Btn2", [BTN_3] = "Btn3", |
| @@ -622,8 +641,8 @@ static char *keys[KEY_MAX + 1] = { | |||
| 622 | [BTN_TOOL_AIRBRUSH] = "ToolAirbrush", [BTN_TOOL_FINGER] = "ToolFinger", | 641 | [BTN_TOOL_AIRBRUSH] = "ToolAirbrush", [BTN_TOOL_FINGER] = "ToolFinger", |
| 623 | [BTN_TOOL_MOUSE] = "ToolMouse", [BTN_TOOL_LENS] = "ToolLens", | 642 | [BTN_TOOL_MOUSE] = "ToolMouse", [BTN_TOOL_LENS] = "ToolLens", |
| 624 | [BTN_TOUCH] = "Touch", [BTN_STYLUS] = "Stylus", | 643 | [BTN_TOUCH] = "Touch", [BTN_STYLUS] = "Stylus", |
| 625 | [BTN_STYLUS2] = "Stylus2", [BTN_TOOL_DOUBLETAP] = "Tool Doubletap", | 644 | [BTN_STYLUS2] = "Stylus2", [BTN_TOOL_DOUBLETAP] = "ToolDoubleTap", |
| 626 | [BTN_TOOL_TRIPLETAP] = "Tool Tripletap", [BTN_GEAR_DOWN] = "WheelBtn", | 645 | [BTN_TOOL_TRIPLETAP] = "ToolTripleTap", [BTN_GEAR_DOWN] = "WheelBtn", |
| 627 | [BTN_GEAR_UP] = "Gear up", [KEY_OK] = "Ok", | 646 | [BTN_GEAR_UP] = "Gear up", [KEY_OK] = "Ok", |
| 628 | [KEY_SELECT] = "Select", [KEY_GOTO] = "Goto", | 647 | [KEY_SELECT] = "Select", [KEY_GOTO] = "Goto", |
| 629 | [KEY_CLEAR] = "Clear", [KEY_POWER2] = "Power2", | 648 | [KEY_CLEAR] = "Clear", [KEY_POWER2] = "Power2", |
| @@ -659,6 +678,9 @@ static char *keys[KEY_MAX + 1] = { | |||
| 659 | [KEY_TWEN] = "TWEN", [KEY_DEL_EOL] = "DeleteEOL", | 678 | [KEY_TWEN] = "TWEN", [KEY_DEL_EOL] = "DeleteEOL", |
| 660 | [KEY_DEL_EOS] = "DeleteEOS", [KEY_INS_LINE] = "InsertLine", | 679 | [KEY_DEL_EOS] = "DeleteEOS", [KEY_INS_LINE] = "InsertLine", |
| 661 | [KEY_DEL_LINE] = "DeleteLine", | 680 | [KEY_DEL_LINE] = "DeleteLine", |
| 681 | [KEY_SEND] = "Send", [KEY_REPLY] = "Reply", | ||
| 682 | [KEY_FORWARDMAIL] = "ForwardMail", [KEY_SAVE] = "Save", | ||
| 683 | [KEY_DOCUMENTS] = "Documents", | ||
| 662 | }; | 684 | }; |
| 663 | 685 | ||
| 664 | static char *relatives[REL_MAX + 1] = { | 686 | static char *relatives[REL_MAX + 1] = { |
diff --git a/drivers/usb/input/hid-input.c b/drivers/usb/input/hid-input.c index 63a4db721f7e..0b6452248a39 100644 --- a/drivers/usb/input/hid-input.c +++ b/drivers/usb/input/hid-input.c | |||
| @@ -78,8 +78,8 @@ static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_fiel | |||
| 78 | { | 78 | { |
| 79 | struct input_dev *input = &hidinput->input; | 79 | struct input_dev *input = &hidinput->input; |
| 80 | struct hid_device *device = hidinput->input.private; | 80 | struct hid_device *device = hidinput->input.private; |
| 81 | int max, code; | 81 | int max = 0, code; |
| 82 | unsigned long *bit; | 82 | unsigned long *bit = NULL; |
| 83 | 83 | ||
| 84 | field->hidinput = hidinput; | 84 | field->hidinput = hidinput; |
| 85 | 85 | ||
| @@ -131,6 +131,15 @@ static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_fiel | |||
| 131 | map_key(code); | 131 | map_key(code); |
| 132 | break; | 132 | break; |
| 133 | 133 | ||
| 134 | |||
| 135 | case HID_UP_SIMULATION: | ||
| 136 | |||
| 137 | switch (usage->hid & 0xffff) { | ||
| 138 | case 0xba: map_abs(ABS_RUDDER); break; | ||
| 139 | case 0xbb: map_abs(ABS_THROTTLE); break; | ||
| 140 | } | ||
| 141 | break; | ||
| 142 | |||
| 134 | case HID_UP_GENDESK: | 143 | case HID_UP_GENDESK: |
| 135 | 144 | ||
| 136 | if ((usage->hid & 0xf0) == 0x80) { /* SystemControl */ | 145 | if ((usage->hid & 0xf0) == 0x80) { /* SystemControl */ |
| @@ -238,8 +247,12 @@ static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_fiel | |||
| 238 | case 0x000: goto ignore; | 247 | case 0x000: goto ignore; |
| 239 | case 0x034: map_key_clear(KEY_SLEEP); break; | 248 | case 0x034: map_key_clear(KEY_SLEEP); break; |
| 240 | case 0x036: map_key_clear(BTN_MISC); break; | 249 | case 0x036: map_key_clear(BTN_MISC); break; |
| 250 | case 0x045: map_key_clear(KEY_RADIO); break; | ||
| 241 | case 0x08a: map_key_clear(KEY_WWW); break; | 251 | case 0x08a: map_key_clear(KEY_WWW); break; |
| 252 | case 0x08d: map_key_clear(KEY_PROGRAM); break; | ||
| 242 | case 0x095: map_key_clear(KEY_HELP); break; | 253 | case 0x095: map_key_clear(KEY_HELP); break; |
| 254 | case 0x09c: map_key_clear(KEY_CHANNELUP); break; | ||
| 255 | case 0x09d: map_key_clear(KEY_CHANNELDOWN); break; | ||
| 243 | case 0x0b0: map_key_clear(KEY_PLAY); break; | 256 | case 0x0b0: map_key_clear(KEY_PLAY); break; |
| 244 | case 0x0b1: map_key_clear(KEY_PAUSE); break; | 257 | case 0x0b1: map_key_clear(KEY_PAUSE); break; |
| 245 | case 0x0b2: map_key_clear(KEY_RECORD); break; | 258 | case 0x0b2: map_key_clear(KEY_RECORD); break; |
| @@ -259,6 +272,11 @@ static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_fiel | |||
| 259 | case 0x18a: map_key_clear(KEY_MAIL); break; | 272 | case 0x18a: map_key_clear(KEY_MAIL); break; |
| 260 | case 0x192: map_key_clear(KEY_CALC); break; | 273 | case 0x192: map_key_clear(KEY_CALC); break; |
| 261 | case 0x194: map_key_clear(KEY_FILE); break; | 274 | case 0x194: map_key_clear(KEY_FILE); break; |
| 275 | case 0x1a7: map_key_clear(KEY_DOCUMENTS); break; | ||
| 276 | case 0x201: map_key_clear(KEY_NEW); break; | ||
| 277 | case 0x207: map_key_clear(KEY_SAVE); break; | ||
| 278 | case 0x208: map_key_clear(KEY_PRINT); break; | ||
| 279 | case 0x209: map_key_clear(KEY_PROPS); break; | ||
| 262 | case 0x21a: map_key_clear(KEY_UNDO); break; | 280 | case 0x21a: map_key_clear(KEY_UNDO); break; |
| 263 | case 0x21b: map_key_clear(KEY_COPY); break; | 281 | case 0x21b: map_key_clear(KEY_COPY); break; |
| 264 | case 0x21c: map_key_clear(KEY_CUT); break; | 282 | case 0x21c: map_key_clear(KEY_CUT); break; |
| @@ -271,7 +289,11 @@ static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_fiel | |||
| 271 | case 0x227: map_key_clear(KEY_REFRESH); break; | 289 | case 0x227: map_key_clear(KEY_REFRESH); break; |
| 272 | case 0x22a: map_key_clear(KEY_BOOKMARKS); break; | 290 | case 0x22a: map_key_clear(KEY_BOOKMARKS); break; |
| 273 | case 0x238: map_rel(REL_HWHEEL); break; | 291 | case 0x238: map_rel(REL_HWHEEL); break; |
| 274 | default: goto unknown; | 292 | case 0x279: map_key_clear(KEY_REDO); break; |
| 293 | case 0x289: map_key_clear(KEY_REPLY); break; | ||
| 294 | case 0x28b: map_key_clear(KEY_FORWARDMAIL); break; | ||
| 295 | case 0x28c: map_key_clear(KEY_SEND); break; | ||
| 296 | default: goto ignore; | ||
| 275 | } | 297 | } |
| 276 | break; | 298 | break; |
| 277 | 299 | ||
| @@ -296,9 +318,42 @@ static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_fiel | |||
| 296 | break; | 318 | break; |
| 297 | 319 | ||
| 298 | case HID_UP_MSVENDOR: | 320 | case HID_UP_MSVENDOR: |
| 299 | |||
| 300 | goto ignore; | 321 | goto ignore; |
| 301 | 322 | ||
| 323 | case HID_UP_CUSTOM: /* Reported on Logitech and Powerbook USB keyboards */ | ||
| 324 | |||
| 325 | set_bit(EV_REP, input->evbit); | ||
| 326 | switch(usage->hid & HID_USAGE) { | ||
| 327 | case 0x003: map_key_clear(KEY_FN); break; | ||
| 328 | default: goto ignore; | ||
| 329 | } | ||
| 330 | break; | ||
| 331 | |||
| 332 | case HID_UP_LOGIVENDOR: /* Reported on Logitech Ultra X Media Remote */ | ||
| 333 | |||
| 334 | set_bit(EV_REP, input->evbit); | ||
| 335 | switch(usage->hid & HID_USAGE) { | ||
| 336 | case 0x004: map_key_clear(KEY_AGAIN); break; | ||
| 337 | case 0x00d: map_key_clear(KEY_HOME); break; | ||
| 338 | case 0x024: map_key_clear(KEY_SHUFFLE); break; | ||
| 339 | case 0x025: map_key_clear(KEY_TV); break; | ||
| 340 | case 0x026: map_key_clear(KEY_MENU); break; | ||
| 341 | case 0x031: map_key_clear(KEY_AUDIO); break; | ||
| 342 | case 0x032: map_key_clear(KEY_SUBTITLE); break; | ||
| 343 | case 0x033: map_key_clear(KEY_LAST); break; | ||
| 344 | case 0x047: map_key_clear(KEY_MP3); break; | ||
| 345 | case 0x048: map_key_clear(KEY_DVD); break; | ||
| 346 | case 0x049: map_key_clear(KEY_MEDIA); break; | ||
| 347 | case 0x04a: map_key_clear(KEY_VIDEO); break; | ||
| 348 | case 0x04b: map_key_clear(KEY_ANGLE); break; | ||
| 349 | case 0x04c: map_key_clear(KEY_LANGUAGE); break; | ||
| 350 | case 0x04d: map_key_clear(KEY_SUBTITLE); break; | ||
| 351 | case 0x051: map_key_clear(KEY_RED); break; | ||
| 352 | case 0x052: map_key_clear(KEY_CLOSE); break; | ||
| 353 | default: goto ignore; | ||
| 354 | } | ||
| 355 | break; | ||
| 356 | |||
| 302 | case HID_UP_PID: | 357 | case HID_UP_PID: |
| 303 | 358 | ||
| 304 | set_bit(EV_FF, input->evbit); | 359 | set_bit(EV_FF, input->evbit); |
| @@ -349,6 +404,9 @@ static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_fiel | |||
| 349 | if (usage->code > max) | 404 | if (usage->code > max) |
| 350 | goto ignore; | 405 | goto ignore; |
| 351 | 406 | ||
| 407 | if (((device->quirks & (HID_QUIRK_2WHEEL_POWERMOUSE)) && (usage->hid == 0x00010032))) | ||
| 408 | map_rel(REL_HWHEEL); | ||
| 409 | |||
| 352 | if ((device->quirks & (HID_QUIRK_2WHEEL_MOUSE_HACK_7 | HID_QUIRK_2WHEEL_MOUSE_HACK_5)) && | 410 | if ((device->quirks & (HID_QUIRK_2WHEEL_MOUSE_HACK_7 | HID_QUIRK_2WHEEL_MOUSE_HACK_5)) && |
| 353 | (usage->type == EV_REL) && (usage->code == REL_WHEEL)) | 411 | (usage->type == EV_REL) && (usage->code == REL_WHEEL)) |
| 354 | set_bit(REL_HWHEEL, bit); | 412 | set_bit(REL_HWHEEL, bit); |
diff --git a/drivers/usb/input/hid.h b/drivers/usb/input/hid.h index c1b6b69bc4a4..ec2412c42f1e 100644 --- a/drivers/usb/input/hid.h +++ b/drivers/usb/input/hid.h | |||
| @@ -173,6 +173,7 @@ struct hid_item { | |||
| 173 | 173 | ||
| 174 | #define HID_UP_UNDEFINED 0x00000000 | 174 | #define HID_UP_UNDEFINED 0x00000000 |
| 175 | #define HID_UP_GENDESK 0x00010000 | 175 | #define HID_UP_GENDESK 0x00010000 |
| 176 | #define HID_UP_SIMULATION 0x00020000 | ||
| 176 | #define HID_UP_KEYBOARD 0x00070000 | 177 | #define HID_UP_KEYBOARD 0x00070000 |
| 177 | #define HID_UP_LED 0x00080000 | 178 | #define HID_UP_LED 0x00080000 |
| 178 | #define HID_UP_BUTTON 0x00090000 | 179 | #define HID_UP_BUTTON 0x00090000 |
| @@ -182,6 +183,8 @@ struct hid_item { | |||
| 182 | #define HID_UP_PID 0x000f0000 | 183 | #define HID_UP_PID 0x000f0000 |
| 183 | #define HID_UP_HPVENDOR 0xff7f0000 | 184 | #define HID_UP_HPVENDOR 0xff7f0000 |
| 184 | #define HID_UP_MSVENDOR 0xff000000 | 185 | #define HID_UP_MSVENDOR 0xff000000 |
| 186 | #define HID_UP_CUSTOM 0x00ff0000 | ||
| 187 | #define HID_UP_LOGIVENDOR 0xffbc0000 | ||
| 185 | 188 | ||
| 186 | #define HID_USAGE 0x0000ffff | 189 | #define HID_USAGE 0x0000ffff |
| 187 | 190 | ||
| @@ -242,6 +245,7 @@ struct hid_item { | |||
| 242 | #define HID_QUIRK_2WHEEL_MOUSE_HACK_7 0x080 | 245 | #define HID_QUIRK_2WHEEL_MOUSE_HACK_7 0x080 |
| 243 | #define HID_QUIRK_2WHEEL_MOUSE_HACK_5 0x100 | 246 | #define HID_QUIRK_2WHEEL_MOUSE_HACK_5 0x100 |
| 244 | #define HID_QUIRK_2WHEEL_MOUSE_HACK_ON 0x200 | 247 | #define HID_QUIRK_2WHEEL_MOUSE_HACK_ON 0x200 |
| 248 | #define HID_QUIRK_2WHEEL_POWERMOUSE 0x400 | ||
| 245 | 249 | ||
| 246 | /* | 250 | /* |
| 247 | * This is the global environment of the parser. This information is | 251 | * This is the global environment of the parser. This information is |
| @@ -348,7 +352,8 @@ struct hid_report_enum { | |||
| 348 | 352 | ||
| 349 | #define HID_REPORT_TYPES 3 | 353 | #define HID_REPORT_TYPES 3 |
| 350 | 354 | ||
| 351 | #define HID_BUFFER_SIZE 64 /* use 64 for compatibility with all possible packetlen */ | 355 | #define HID_MIN_BUFFER_SIZE 64 /* make sure there is at least a packet size of space */ |
| 356 | #define HID_MAX_BUFFER_SIZE 4096 /* 4kb */ | ||
| 352 | #define HID_CONTROL_FIFO_SIZE 256 /* to init devices with >100 reports */ | 357 | #define HID_CONTROL_FIFO_SIZE 256 /* to init devices with >100 reports */ |
| 353 | #define HID_OUTPUT_FIFO_SIZE 64 | 358 | #define HID_OUTPUT_FIFO_SIZE 64 |
| 354 | 359 | ||
| @@ -386,6 +391,8 @@ struct hid_device { /* device report descriptor */ | |||
| 386 | 391 | ||
| 387 | unsigned long iofl; /* I/O flags (CTRL_RUNNING, OUT_RUNNING) */ | 392 | unsigned long iofl; /* I/O flags (CTRL_RUNNING, OUT_RUNNING) */ |
| 388 | 393 | ||
| 394 | unsigned int bufsize; /* URB buffer size */ | ||
| 395 | |||
| 389 | struct urb *urbin; /* Input URB */ | 396 | struct urb *urbin; /* Input URB */ |
| 390 | char *inbuf; /* Input buffer */ | 397 | char *inbuf; /* Input buffer */ |
| 391 | dma_addr_t inbuf_dma; /* Input buffer dma */ | 398 | dma_addr_t inbuf_dma; /* Input buffer dma */ |
diff --git a/drivers/usb/input/hiddev.c b/drivers/usb/input/hiddev.c index 4c13331b5f41..d32427818af7 100644 --- a/drivers/usb/input/hiddev.c +++ b/drivers/usb/input/hiddev.c | |||
| @@ -507,6 +507,7 @@ static int hiddev_ioctl(struct inode *inode, struct file *file, unsigned int cmd | |||
| 507 | return -EINVAL; | 507 | return -EINVAL; |
| 508 | 508 | ||
| 509 | hid_submit_report(hid, report, USB_DIR_OUT); | 509 | hid_submit_report(hid, report, USB_DIR_OUT); |
| 510 | hid_wait_io(hid); | ||
| 510 | 511 | ||
| 511 | return 0; | 512 | return 0; |
| 512 | 513 | ||
diff --git a/drivers/usb/input/keyspan_remote.c b/drivers/usb/input/keyspan_remote.c index 67dc93685203..99de1b33c07d 100644 --- a/drivers/usb/input/keyspan_remote.c +++ b/drivers/usb/input/keyspan_remote.c | |||
| @@ -431,11 +431,6 @@ static int keyspan_probe(struct usb_interface *interface, const struct usb_devic | |||
| 431 | struct usb_endpoint_descriptor *endpoint; | 431 | struct usb_endpoint_descriptor *endpoint; |
| 432 | struct usb_device *udev = usb_get_dev(interface_to_usbdev(interface)); | 432 | struct usb_device *udev = usb_get_dev(interface_to_usbdev(interface)); |
| 433 | 433 | ||
| 434 | /* See if the offered device matches what we can accept */ | ||
| 435 | if ((udev->descriptor.idVendor != USB_KEYSPAN_VENDOR_ID) || | ||
| 436 | (udev->descriptor.idProduct != USB_KEYSPAN_PRODUCT_UIA11) ) | ||
| 437 | return -ENODEV; | ||
| 438 | |||
| 439 | /* allocate memory for our device state and initialize it */ | 434 | /* allocate memory for our device state and initialize it */ |
| 440 | remote = kmalloc(sizeof(*remote), GFP_KERNEL); | 435 | remote = kmalloc(sizeof(*remote), GFP_KERNEL); |
| 441 | if (remote == NULL) { | 436 | if (remote == NULL) { |
diff --git a/drivers/usb/input/map_to_7segment.h b/drivers/usb/input/map_to_7segment.h new file mode 100644 index 000000000000..52ff27f15127 --- /dev/null +++ b/drivers/usb/input/map_to_7segment.h | |||
| @@ -0,0 +1,189 @@ | |||
| 1 | /* | ||
| 2 | * drivers/usb/input/map_to_7segment.h | ||
| 3 | * | ||
| 4 | * Copyright (c) 2005 Henk Vergonet <Henk.Vergonet@gmail.com> | ||
| 5 | * | ||
| 6 | * This program is free software; you can redistribute it and/or | ||
| 7 | * modify it under the terms of the GNU General Public License as | ||
| 8 | * published by the Free Software Foundation; either version 2 of | ||
| 9 | * the License, or (at your option) any later version. | ||
| 10 | * | ||
| 11 | * This program is distributed in the hope that it will be useful, | ||
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 14 | * GNU General Public License for more details. | ||
| 15 | * | ||
| 16 | * You should have received a copy of the GNU General Public License | ||
| 17 | * along with this program; if not, write to the Free Software | ||
| 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
| 19 | */ | ||
| 20 | |||
| 21 | #ifndef MAP_TO_7SEGMENT_H | ||
| 22 | #define MAP_TO_7SEGMENT_H | ||
| 23 | |||
| 24 | /* This file provides translation primitives and tables for the conversion | ||
| 25 | * of (ASCII) characters to a 7-segments notation. | ||
| 26 | * | ||
| 27 | * The 7 segment's wikipedia notation below is used as standard. | ||
| 28 | * See: http://en.wikipedia.org/wiki/Seven_segment_display | ||
| 29 | * | ||
| 30 | * Notation: +-a-+ | ||
| 31 | * f b | ||
| 32 | * +-g-+ | ||
| 33 | * e c | ||
| 34 | * +-d-+ | ||
| 35 | * | ||
| 36 | * Usage: | ||
| 37 | * | ||
| 38 | * Register a map variable, and fill it with a character set: | ||
| 39 | * static SEG7_DEFAULT_MAP(map_seg7); | ||
| 40 | * | ||
| 41 | * | ||
| 42 | * Then use for conversion: | ||
| 43 | * seg7 = map_to_seg7(&map_seg7, some_char); | ||
| 44 | * ... | ||
| 45 | * | ||
| 46 | * In device drivers it is recommended, if required, to make the char map | ||
| 47 | * accessible via the sysfs interface using the following scheme: | ||
| 48 | * | ||
| 49 | * static ssize_t show_map(struct device *dev, char *buf) { | ||
| 50 | * memcpy(buf, &map_seg7, sizeof(map_seg7)); | ||
| 51 | * return sizeof(map_seg7); | ||
| 52 | * } | ||
| 53 | * static ssize_t store_map(struct device *dev, const char *buf, size_t cnt) { | ||
| 54 | * if(cnt != sizeof(map_seg7)) | ||
| 55 | * return -EINVAL; | ||
| 56 | * memcpy(&map_seg7, buf, cnt); | ||
| 57 | * return cnt; | ||
| 58 | * } | ||
| 59 | * static DEVICE_ATTR(map_seg7, PERMS_RW, show_map, store_map); | ||
| 60 | * | ||
| 61 | * History: | ||
| 62 | * 2005-05-31 RFC linux-kernel@vger.kernel.org | ||
| 63 | */ | ||
| 64 | #include <linux/errno.h> | ||
| 65 | |||
| 66 | |||
| 67 | #define BIT_SEG7_A 0 | ||
| 68 | #define BIT_SEG7_B 1 | ||
| 69 | #define BIT_SEG7_C 2 | ||
| 70 | #define BIT_SEG7_D 3 | ||
| 71 | #define BIT_SEG7_E 4 | ||
| 72 | #define BIT_SEG7_F 5 | ||
| 73 | #define BIT_SEG7_G 6 | ||
| 74 | #define BIT_SEG7_RESERVED 7 | ||
| 75 | |||
| 76 | struct seg7_conversion_map { | ||
| 77 | unsigned char table[128]; | ||
| 78 | }; | ||
| 79 | |||
| 80 | static inline int map_to_seg7(struct seg7_conversion_map *map, int c) | ||
| 81 | { | ||
| 82 | return c & 0x7f ? map->table[c] : -EINVAL; | ||
| 83 | } | ||
| 84 | |||
| 85 | #define SEG7_CONVERSION_MAP(_name, _map) \ | ||
| 86 | struct seg7_conversion_map _name = { .table = { _map } } | ||
| 87 | |||
| 88 | /* | ||
| 89 | * It is recommended to use a facility that allows user space to redefine | ||
| 90 | * custom character sets for LCD devices. Please use a sysfs interface | ||
| 91 | * as described above. | ||
| 92 | */ | ||
| 93 | #define MAP_TO_SEG7_SYSFS_FILE "map_seg7" | ||
| 94 | |||
| 95 | /******************************************************************************* | ||
| 96 | * ASCII conversion table | ||
| 97 | ******************************************************************************/ | ||
| 98 | |||
| 99 | #define _SEG7(l,a,b,c,d,e,f,g) \ | ||
| 100 | ( a<<BIT_SEG7_A | b<<BIT_SEG7_B | c<<BIT_SEG7_C | d<<BIT_SEG7_D | \ | ||
| 101 | e<<BIT_SEG7_E | f<<BIT_SEG7_F | g<<BIT_SEG7_G ) | ||
| 102 | |||
| 103 | #define _MAP_0_32_ASCII_SEG7_NON_PRINTABLE \ | ||
| 104 | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, | ||
| 105 | |||
| 106 | #define _MAP_33_47_ASCII_SEG7_SYMBOL \ | ||
| 107 | _SEG7('!',0,0,0,0,1,1,0), _SEG7('"',0,1,0,0,0,1,0), _SEG7('#',0,1,1,0,1,1,0),\ | ||
| 108 | _SEG7('$',1,0,1,1,0,1,1), _SEG7('%',0,0,1,0,0,1,0), _SEG7('&',1,0,1,1,1,1,1),\ | ||
| 109 | _SEG7('\'',0,0,0,0,0,1,0),_SEG7('(',1,0,0,1,1,1,0), _SEG7(')',1,1,1,1,0,0,0),\ | ||
| 110 | _SEG7('*',0,1,1,0,1,1,1), _SEG7('+',0,1,1,0,0,0,1), _SEG7(',',0,0,0,0,1,0,0),\ | ||
| 111 | _SEG7('-',0,0,0,0,0,0,1), _SEG7('.',0,0,0,0,1,0,0), _SEG7('/',0,1,0,0,1,0,1), | ||
| 112 | |||
| 113 | #define _MAP_48_57_ASCII_SEG7_NUMERIC \ | ||
| 114 | _SEG7('0',1,1,1,1,1,1,0), _SEG7('1',0,1,1,0,0,0,0), _SEG7('2',1,1,0,1,1,0,1),\ | ||
| 115 | _SEG7('3',1,1,1,1,0,0,1), _SEG7('4',0,1,1,0,0,1,1), _SEG7('5',1,0,1,1,0,1,1),\ | ||
| 116 | _SEG7('6',1,0,1,1,1,1,1), _SEG7('7',1,1,1,0,0,0,0), _SEG7('8',1,1,1,1,1,1,1),\ | ||
| 117 | _SEG7('9',1,1,1,1,0,1,1), | ||
| 118 | |||
| 119 | #define _MAP_58_64_ASCII_SEG7_SYMBOL \ | ||
| 120 | _SEG7(':',0,0,0,1,0,0,1), _SEG7(';',0,0,0,1,0,0,1), _SEG7('<',1,0,0,0,0,1,1),\ | ||
| 121 | _SEG7('=',0,0,0,1,0,0,1), _SEG7('>',1,1,0,0,0,0,1), _SEG7('?',1,1,1,0,0,1,0),\ | ||
| 122 | _SEG7('@',1,1,0,1,1,1,1), | ||
| 123 | |||
| 124 | #define _MAP_65_90_ASCII_SEG7_ALPHA_UPPR \ | ||
| 125 | _SEG7('A',1,1,1,0,1,1,1), _SEG7('B',1,1,1,1,1,1,1), _SEG7('C',1,0,0,1,1,1,0),\ | ||
| 126 | _SEG7('D',1,1,1,1,1,1,0), _SEG7('E',1,0,0,1,1,1,1), _SEG7('F',1,0,0,0,1,1,1),\ | ||
| 127 | _SEG7('G',1,1,1,1,0,1,1), _SEG7('H',0,1,1,0,1,1,1), _SEG7('I',0,1,1,0,0,0,0),\ | ||
| 128 | _SEG7('J',0,1,1,1,0,0,0), _SEG7('K',0,1,1,0,1,1,1), _SEG7('L',0,0,0,1,1,1,0),\ | ||
| 129 | _SEG7('M',1,1,1,0,1,1,0), _SEG7('N',1,1,1,0,1,1,0), _SEG7('O',1,1,1,1,1,1,0),\ | ||
| 130 | _SEG7('P',1,1,0,0,1,1,1), _SEG7('Q',1,1,1,1,1,1,0), _SEG7('R',1,1,1,0,1,1,1),\ | ||
| 131 | _SEG7('S',1,0,1,1,0,1,1), _SEG7('T',0,0,0,1,1,1,1), _SEG7('U',0,1,1,1,1,1,0),\ | ||
| 132 | _SEG7('V',0,1,1,1,1,1,0), _SEG7('W',0,1,1,1,1,1,1), _SEG7('X',0,1,1,0,1,1,1),\ | ||
| 133 | _SEG7('Y',0,1,1,0,0,1,1), _SEG7('Z',1,1,0,1,1,0,1), | ||
| 134 | |||
| 135 | #define _MAP_91_96_ASCII_SEG7_SYMBOL \ | ||
| 136 | _SEG7('[',1,0,0,1,1,1,0), _SEG7('\\',0,0,1,0,0,1,1),_SEG7(']',1,1,1,1,0,0,0),\ | ||
| 137 | _SEG7('^',1,1,0,0,0,1,0), _SEG7('_',0,0,0,1,0,0,0), _SEG7('`',0,1,0,0,0,0,0), | ||
| 138 | |||
| 139 | #define _MAP_97_122_ASCII_SEG7_ALPHA_LOWER \ | ||
| 140 | _SEG7('A',1,1,1,0,1,1,1), _SEG7('b',0,0,1,1,1,1,1), _SEG7('c',0,0,0,1,1,0,1),\ | ||
| 141 | _SEG7('d',0,1,1,1,1,0,1), _SEG7('E',1,0,0,1,1,1,1), _SEG7('F',1,0,0,0,1,1,1),\ | ||
| 142 | _SEG7('G',1,1,1,1,0,1,1), _SEG7('h',0,0,1,0,1,1,1), _SEG7('i',0,0,1,0,0,0,0),\ | ||
| 143 | _SEG7('j',0,0,1,1,0,0,0), _SEG7('k',0,0,1,0,1,1,1), _SEG7('L',0,0,0,1,1,1,0),\ | ||
| 144 | _SEG7('M',1,1,1,0,1,1,0), _SEG7('n',0,0,1,0,1,0,1), _SEG7('o',0,0,1,1,1,0,1),\ | ||
| 145 | _SEG7('P',1,1,0,0,1,1,1), _SEG7('q',1,1,1,0,0,1,1), _SEG7('r',0,0,0,0,1,0,1),\ | ||
| 146 | _SEG7('S',1,0,1,1,0,1,1), _SEG7('T',0,0,0,1,1,1,1), _SEG7('u',0,0,1,1,1,0,0),\ | ||
| 147 | _SEG7('v',0,0,1,1,1,0,0), _SEG7('W',0,1,1,1,1,1,1), _SEG7('X',0,1,1,0,1,1,1),\ | ||
| 148 | _SEG7('y',0,1,1,1,0,1,1), _SEG7('Z',1,1,0,1,1,0,1), | ||
| 149 | |||
| 150 | #define _MAP_123_126_ASCII_SEG7_SYMBOL \ | ||
| 151 | _SEG7('{',1,0,0,1,1,1,0), _SEG7('|',0,0,0,0,1,1,0), _SEG7('}',1,1,1,1,0,0,0),\ | ||
| 152 | _SEG7('~',1,0,0,0,0,0,0), | ||
| 153 | |||
| 154 | /* Maps */ | ||
| 155 | |||
| 156 | /* This set tries to map as close as possible to the visible characteristics | ||
| 157 | * of the ASCII symbol, lowercase and uppercase letters may differ in | ||
| 158 | * presentation on the display. | ||
| 159 | */ | ||
| 160 | #define MAP_ASCII7SEG_ALPHANUM \ | ||
| 161 | _MAP_0_32_ASCII_SEG7_NON_PRINTABLE \ | ||
| 162 | _MAP_33_47_ASCII_SEG7_SYMBOL \ | ||
| 163 | _MAP_48_57_ASCII_SEG7_NUMERIC \ | ||
| 164 | _MAP_58_64_ASCII_SEG7_SYMBOL \ | ||
| 165 | _MAP_65_90_ASCII_SEG7_ALPHA_UPPR \ | ||
| 166 | _MAP_91_96_ASCII_SEG7_SYMBOL \ | ||
| 167 | _MAP_97_122_ASCII_SEG7_ALPHA_LOWER \ | ||
| 168 | _MAP_123_126_ASCII_SEG7_SYMBOL | ||
| 169 | |||
| 170 | /* This set tries to map as close as possible to the symbolic characteristics | ||
| 171 | * of the ASCII character for maximum discrimination. | ||
| 172 | * For now this means all alpha chars are in lower case representations. | ||
| 173 | * (This for example facilitates the use of hex numbers with uppercase input.) | ||
| 174 | */ | ||
| 175 | #define MAP_ASCII7SEG_ALPHANUM_LC \ | ||
| 176 | _MAP_0_32_ASCII_SEG7_NON_PRINTABLE \ | ||
| 177 | _MAP_33_47_ASCII_SEG7_SYMBOL \ | ||
| 178 | _MAP_48_57_ASCII_SEG7_NUMERIC \ | ||
| 179 | _MAP_58_64_ASCII_SEG7_SYMBOL \ | ||
| 180 | _MAP_97_122_ASCII_SEG7_ALPHA_LOWER \ | ||
| 181 | _MAP_91_96_ASCII_SEG7_SYMBOL \ | ||
| 182 | _MAP_97_122_ASCII_SEG7_ALPHA_LOWER \ | ||
| 183 | _MAP_123_126_ASCII_SEG7_SYMBOL | ||
| 184 | |||
| 185 | #define SEG7_DEFAULT_MAP(_name) \ | ||
| 186 | SEG7_CONVERSION_MAP(_name,MAP_ASCII7SEG_ALPHANUM) | ||
| 187 | |||
| 188 | #endif /* MAP_TO_7SEGMENT_H */ | ||
| 189 | |||
diff --git a/drivers/usb/input/yealink.c b/drivers/usb/input/yealink.c new file mode 100644 index 000000000000..58a176ef96a5 --- /dev/null +++ b/drivers/usb/input/yealink.c | |||
| @@ -0,0 +1,1013 @@ | |||
| 1 | /* | ||
| 2 | * drivers/usb/input/yealink.c | ||
| 3 | * | ||
| 4 | * Copyright (c) 2005 Henk Vergonet <Henk.Vergonet@gmail.com> | ||
| 5 | * | ||
| 6 | * This program is free software; you can redistribute it and/or | ||
| 7 | * modify it under the terms of the GNU General Public License as | ||
| 8 | * published by the Free Software Foundation; either version 2 of | ||
| 9 | * the License, or (at your option) any later version. | ||
| 10 | * | ||
| 11 | * This program is distributed in the hope that it will be useful, | ||
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 14 | * GNU General Public License for more details. | ||
| 15 | * | ||
| 16 | * You should have received a copy of the GNU General Public License | ||
| 17 | * along with this program; if not, write to the Free Software | ||
| 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
| 19 | */ | ||
| 20 | /* | ||
| 21 | * Description: | ||
| 22 | * Driver for the USB-P1K voip usb phone. | ||
| 23 | * This device is produced by Yealink Network Technology Co Ltd | ||
| 24 | * but may be branded under several names: | ||
| 25 | * - Yealink usb-p1k | ||
| 26 | * - Tiptel 115 | ||
| 27 | * - ... | ||
| 28 | * | ||
| 29 | * This driver is based on: | ||
| 30 | * - the usbb2k-api http://savannah.nongnu.org/projects/usbb2k-api/ | ||
| 31 | * - information from http://memeteau.free.fr/usbb2k | ||
| 32 | * - the xpad-driver drivers/usb/input/xpad.c | ||
| 33 | * | ||
| 34 | * Thanks to: | ||
| 35 | * - Olivier Vandorpe, for providing the usbb2k-api. | ||
| 36 | * - Martin Diehl, for spotting my memory allocation bug. | ||
| 37 | * | ||
| 38 | * History: | ||
| 39 | * 20050527 henk First version, functional keyboard. Keyboard events | ||
| 40 | * will pop-up on the ../input/eventX bus. | ||
| 41 | * 20050531 henk Added led, LCD, dialtone and sysfs interface. | ||
| 42 | * 20050610 henk Cleanups, make it ready for public consumption. | ||
| 43 | * 20050630 henk Cleanups, fixes in response to comments. | ||
| 44 | * 20050701 henk sysfs write serialisation, fix potential unload races | ||
| 45 | * 20050801 henk Added ringtone, restructure USB | ||
| 46 | * 20050816 henk Merge 2.6.13-rc6 | ||
| 47 | */ | ||
| 48 | |||
| 49 | #include <linux/config.h> | ||
| 50 | #include <linux/kernel.h> | ||
| 51 | #include <linux/input.h> | ||
| 52 | #include <linux/init.h> | ||
| 53 | #include <linux/slab.h> | ||
| 54 | #include <linux/module.h> | ||
| 55 | #include <linux/rwsem.h> | ||
| 56 | #include <linux/usb.h> | ||
| 57 | |||
| 58 | #include "map_to_7segment.h" | ||
| 59 | #include "yealink.h" | ||
| 60 | |||
| 61 | #define DRIVER_VERSION "yld-20050816" | ||
| 62 | #define DRIVER_AUTHOR "Henk Vergonet" | ||
| 63 | #define DRIVER_DESC "Yealink phone driver" | ||
| 64 | |||
| 65 | #define YEALINK_POLLING_FREQUENCY 10 /* in [Hz] */ | ||
| 66 | |||
| 67 | struct yld_status { | ||
| 68 | u8 lcd[24]; | ||
| 69 | u8 led; | ||
| 70 | u8 dialtone; | ||
| 71 | u8 ringtone; | ||
| 72 | u8 keynum; | ||
| 73 | } __attribute__ ((packed)); | ||
| 74 | |||
| 75 | /* | ||
| 76 | * Register the LCD segment and icon map | ||
| 77 | */ | ||
| 78 | #define _LOC(k,l) { .a = (k), .m = (l) } | ||
| 79 | #define _SEG(t, a, am, b, bm, c, cm, d, dm, e, em, f, fm, g, gm) \ | ||
| 80 | { .type = (t), \ | ||
| 81 | .u = { .s = { _LOC(a, am), _LOC(b, bm), _LOC(c, cm), \ | ||
| 82 | _LOC(d, dm), _LOC(e, em), _LOC(g, gm), \ | ||
| 83 | _LOC(f, fm) } } } | ||
| 84 | #define _PIC(t, h, hm, n) \ | ||
| 85 | { .type = (t), \ | ||
| 86 | .u = { .p = { .name = (n), .a = (h), .m = (hm) } } } | ||
| 87 | |||
| 88 | static const struct lcd_segment_map { | ||
| 89 | char type; | ||
| 90 | union { | ||
| 91 | struct pictogram_map { | ||
| 92 | u8 a,m; | ||
| 93 | char name[10]; | ||
| 94 | } p; | ||
| 95 | struct segment_map { | ||
| 96 | u8 a,m; | ||
| 97 | } s[7]; | ||
| 98 | } u; | ||
| 99 | } lcdMap[] = { | ||
| 100 | #include "yealink.h" | ||
| 101 | }; | ||
| 102 | |||
| 103 | struct yealink_dev { | ||
| 104 | struct input_dev idev; /* input device */ | ||
| 105 | struct usb_device *udev; /* usb device */ | ||
| 106 | |||
| 107 | /* irq input channel */ | ||
| 108 | struct yld_ctl_packet *irq_data; | ||
| 109 | dma_addr_t irq_dma; | ||
| 110 | struct urb *urb_irq; | ||
| 111 | |||
| 112 | /* control output channel */ | ||
| 113 | struct yld_ctl_packet *ctl_data; | ||
| 114 | dma_addr_t ctl_dma; | ||
| 115 | struct usb_ctrlrequest *ctl_req; | ||
| 116 | dma_addr_t ctl_req_dma; | ||
| 117 | struct urb *urb_ctl; | ||
| 118 | |||
| 119 | char phys[64]; /* physical device path */ | ||
| 120 | |||
| 121 | u8 lcdMap[ARRAY_SIZE(lcdMap)]; /* state of LCD, LED ... */ | ||
| 122 | int key_code; /* last reported key */ | ||
| 123 | |||
| 124 | int stat_ix; | ||
| 125 | union { | ||
| 126 | struct yld_status s; | ||
| 127 | u8 b[sizeof(struct yld_status)]; | ||
| 128 | } master, copy; | ||
| 129 | }; | ||
| 130 | |||
| 131 | |||
| 132 | /******************************************************************************* | ||
| 133 | * Yealink lcd interface | ||
| 134 | ******************************************************************************/ | ||
| 135 | |||
| 136 | /* | ||
| 137 | * Register a default 7 segment character set | ||
| 138 | */ | ||
| 139 | static SEG7_DEFAULT_MAP(map_seg7); | ||
| 140 | |||
| 141 | /* Display a char, | ||
| 142 | * char '\9' and '\n' are placeholders and do not overwrite the original text. | ||
| 143 | * A space will always hide an icon. | ||
| 144 | */ | ||
| 145 | static int setChar(struct yealink_dev *yld, int el, int chr) | ||
| 146 | { | ||
| 147 | int i, a, m, val; | ||
| 148 | |||
| 149 | if (el >= ARRAY_SIZE(lcdMap)) | ||
| 150 | return -EINVAL; | ||
| 151 | |||
| 152 | if (chr == '\t' || chr == '\n') | ||
| 153 | return 0; | ||
| 154 | |||
| 155 | yld->lcdMap[el] = chr; | ||
| 156 | |||
| 157 | if (lcdMap[el].type == '.') { | ||
| 158 | a = lcdMap[el].u.p.a; | ||
| 159 | m = lcdMap[el].u.p.m; | ||
| 160 | if (chr != ' ') | ||
| 161 | yld->master.b[a] |= m; | ||
| 162 | else | ||
| 163 | yld->master.b[a] &= ~m; | ||
| 164 | return 0; | ||
| 165 | } | ||
| 166 | |||
| 167 | val = map_to_seg7(&map_seg7, chr); | ||
| 168 | for (i = 0; i < ARRAY_SIZE(lcdMap[0].u.s); i++) { | ||
| 169 | m = lcdMap[el].u.s[i].m; | ||
| 170 | |||
| 171 | if (m == 0) | ||
| 172 | continue; | ||
| 173 | |||
| 174 | a = lcdMap[el].u.s[i].a; | ||
| 175 | if (val & 1) | ||
| 176 | yld->master.b[a] |= m; | ||
| 177 | else | ||
| 178 | yld->master.b[a] &= ~m; | ||
| 179 | val = val >> 1; | ||
| 180 | } | ||
| 181 | return 0; | ||
| 182 | }; | ||
| 183 | |||
| 184 | /******************************************************************************* | ||
| 185 | * Yealink key interface | ||
| 186 | ******************************************************************************/ | ||
| 187 | |||
| 188 | /* Map device buttons to internal key events. | ||
| 189 | * | ||
| 190 | * USB-P1K button layout: | ||
| 191 | * | ||
| 192 | * up | ||
| 193 | * IN OUT | ||
| 194 | * down | ||
| 195 | * | ||
| 196 | * pickup C hangup | ||
| 197 | * 1 2 3 | ||
| 198 | * 4 5 6 | ||
| 199 | * 7 8 9 | ||
| 200 | * * 0 # | ||
| 201 | * | ||
| 202 | * The "up" and "down" keys, are symbolised by arrows on the button. | ||
| 203 | * The "pickup" and "hangup" keys are symbolised by a green and red phone | ||
| 204 | * on the button. | ||
| 205 | */ | ||
| 206 | static int map_p1k_to_key(int scancode) | ||
| 207 | { | ||
| 208 | switch(scancode) { /* phone key: */ | ||
| 209 | case 0x23: return KEY_LEFT; /* IN */ | ||
| 210 | case 0x33: return KEY_UP; /* up */ | ||
| 211 | case 0x04: return KEY_RIGHT; /* OUT */ | ||
| 212 | case 0x24: return KEY_DOWN; /* down */ | ||
| 213 | case 0x03: return KEY_ENTER; /* pickup */ | ||
| 214 | case 0x14: return KEY_BACKSPACE; /* C */ | ||
| 215 | case 0x13: return KEY_ESC; /* hangup */ | ||
| 216 | case 0x00: return KEY_1; /* 1 */ | ||
| 217 | case 0x01: return KEY_2; /* 2 */ | ||
| 218 | case 0x02: return KEY_3; /* 3 */ | ||
| 219 | case 0x10: return KEY_4; /* 4 */ | ||
| 220 | case 0x11: return KEY_5; /* 5 */ | ||
| 221 | case 0x12: return KEY_6; /* 6 */ | ||
| 222 | case 0x20: return KEY_7; /* 7 */ | ||
| 223 | case 0x21: return KEY_8; /* 8 */ | ||
| 224 | case 0x22: return KEY_9; /* 9 */ | ||
| 225 | case 0x30: return KEY_KPASTERISK; /* * */ | ||
| 226 | case 0x31: return KEY_0; /* 0 */ | ||
| 227 | case 0x32: return KEY_LEFTSHIFT | | ||
| 228 | KEY_3 << 8; /* # */ | ||
| 229 | } | ||
| 230 | return -EINVAL; | ||
| 231 | } | ||
| 232 | |||
| 233 | /* Completes a request by converting the data into events for the | ||
| 234 | * input subsystem. | ||
| 235 | * | ||
| 236 | * The key parameter can be cascaded: key2 << 8 | key1 | ||
| 237 | */ | ||
| 238 | static void report_key(struct yealink_dev *yld, int key, struct pt_regs *regs) | ||
| 239 | { | ||
| 240 | struct input_dev *idev = &yld->idev; | ||
| 241 | |||
| 242 | input_regs(idev, regs); | ||
| 243 | if (yld->key_code >= 0) { | ||
| 244 | /* old key up */ | ||
| 245 | input_report_key(idev, yld->key_code & 0xff, 0); | ||
| 246 | if (yld->key_code >> 8) | ||
| 247 | input_report_key(idev, yld->key_code >> 8, 0); | ||
| 248 | } | ||
| 249 | |||
| 250 | yld->key_code = key; | ||
| 251 | if (key >= 0) { | ||
| 252 | /* new valid key */ | ||
| 253 | input_report_key(idev, key & 0xff, 1); | ||
| 254 | if (key >> 8) | ||
| 255 | input_report_key(idev, key >> 8, 1); | ||
| 256 | } | ||
| 257 | input_sync(idev); | ||
| 258 | } | ||
| 259 | |||
| 260 | /******************************************************************************* | ||
| 261 | * Yealink usb communication interface | ||
| 262 | ******************************************************************************/ | ||
| 263 | |||
| 264 | static int yealink_cmd(struct yealink_dev *yld, struct yld_ctl_packet *p) | ||
| 265 | { | ||
| 266 | u8 *buf = (u8 *)p; | ||
| 267 | int i; | ||
| 268 | u8 sum = 0; | ||
| 269 | |||
| 270 | for(i=0; i<USB_PKT_LEN-1; i++) | ||
| 271 | sum -= buf[i]; | ||
| 272 | p->sum = sum; | ||
| 273 | return usb_control_msg(yld->udev, | ||
| 274 | usb_sndctrlpipe(yld->udev, 0), | ||
| 275 | USB_REQ_SET_CONFIGURATION, | ||
| 276 | USB_TYPE_CLASS | USB_RECIP_INTERFACE | USB_DIR_OUT, | ||
| 277 | 0x200, 3, | ||
| 278 | p, sizeof(*p), | ||
| 279 | USB_CTRL_SET_TIMEOUT); | ||
| 280 | } | ||
| 281 | |||
| 282 | static u8 default_ringtone[] = { | ||
| 283 | 0xEF, /* volume [0-255] */ | ||
| 284 | 0xFB, 0x1E, 0x00, 0x0C, /* 1250 [hz], 12/100 [s] */ | ||
| 285 | 0xFC, 0x18, 0x00, 0x0C, /* 1000 [hz], 12/100 [s] */ | ||
| 286 | 0xFB, 0x1E, 0x00, 0x0C, | ||
| 287 | 0xFC, 0x18, 0x00, 0x0C, | ||
| 288 | 0xFB, 0x1E, 0x00, 0x0C, | ||
| 289 | 0xFC, 0x18, 0x00, 0x0C, | ||
| 290 | 0xFB, 0x1E, 0x00, 0x0C, | ||
| 291 | 0xFC, 0x18, 0x00, 0x0C, | ||
| 292 | 0xFF, 0xFF, 0x01, 0x90, /* silent, 400/100 [s] */ | ||
| 293 | 0x00, 0x00 /* end of sequence */ | ||
| 294 | }; | ||
| 295 | |||
| 296 | static int yealink_set_ringtone(struct yealink_dev *yld, u8 *buf, size_t size) | ||
| 297 | { | ||
| 298 | struct yld_ctl_packet *p = yld->ctl_data; | ||
| 299 | int ix, len; | ||
| 300 | |||
| 301 | if (size <= 0) | ||
| 302 | return -EINVAL; | ||
| 303 | |||
| 304 | /* Set the ringtone volume */ | ||
| 305 | memset(yld->ctl_data, 0, sizeof(*(yld->ctl_data))); | ||
| 306 | yld->ctl_data->cmd = CMD_RING_VOLUME; | ||
| 307 | yld->ctl_data->size = 1; | ||
| 308 | yld->ctl_data->data[0] = buf[0]; | ||
| 309 | yealink_cmd(yld, p); | ||
| 310 | |||
| 311 | buf++; | ||
| 312 | size--; | ||
| 313 | |||
| 314 | p->cmd = CMD_RING_NOTE; | ||
| 315 | ix = 0; | ||
| 316 | while (size != ix) { | ||
| 317 | len = size - ix; | ||
| 318 | if (len > sizeof(p->data)) | ||
| 319 | len = sizeof(p->data); | ||
| 320 | p->size = len; | ||
| 321 | p->offset = cpu_to_be16(ix); | ||
| 322 | memcpy(p->data, &buf[ix], len); | ||
| 323 | yealink_cmd(yld, p); | ||
| 324 | ix += len; | ||
| 325 | } | ||
| 326 | return 0; | ||
| 327 | } | ||
| 328 | |||
| 329 | /* keep stat_master & stat_copy in sync. | ||
| 330 | */ | ||
| 331 | static int yealink_do_idle_tasks(struct yealink_dev *yld) | ||
| 332 | { | ||
| 333 | u8 val; | ||
| 334 | int i, ix, len; | ||
| 335 | |||
| 336 | ix = yld->stat_ix; | ||
| 337 | |||
| 338 | memset(yld->ctl_data, 0, sizeof(*(yld->ctl_data))); | ||
| 339 | yld->ctl_data->cmd = CMD_KEYPRESS; | ||
| 340 | yld->ctl_data->size = 1; | ||
| 341 | yld->ctl_data->sum = 0xff - CMD_KEYPRESS; | ||
| 342 | |||
| 343 | /* If state update pointer wraps do a KEYPRESS first. */ | ||
| 344 | if (ix >= sizeof(yld->master)) { | ||
| 345 | yld->stat_ix = 0; | ||
| 346 | return 0; | ||
| 347 | } | ||
| 348 | |||
| 349 | /* find update candidates: copy != master */ | ||
| 350 | do { | ||
| 351 | val = yld->master.b[ix]; | ||
| 352 | if (val != yld->copy.b[ix]) | ||
| 353 | goto send_update; | ||
| 354 | } while (++ix < sizeof(yld->master)); | ||
| 355 | |||
| 356 | /* nothing todo, wait a bit and poll for a KEYPRESS */ | ||
| 357 | yld->stat_ix = 0; | ||
| 358 | /* TODO how can we wait abit. ?? | ||
| 359 | * msleep_interruptible(1000 / YEALINK_POLLING_FREQUENCY); | ||
| 360 | */ | ||
| 361 | return 0; | ||
| 362 | |||
| 363 | send_update: | ||
| 364 | |||
| 365 | /* Setup an appropriate update request */ | ||
| 366 | yld->copy.b[ix] = val; | ||
| 367 | yld->ctl_data->data[0] = val; | ||
| 368 | |||
| 369 | switch(ix) { | ||
| 370 | case offsetof(struct yld_status, led): | ||
| 371 | yld->ctl_data->cmd = CMD_LED; | ||
| 372 | yld->ctl_data->sum = -1 - CMD_LED - val; | ||
| 373 | break; | ||
| 374 | case offsetof(struct yld_status, dialtone): | ||
| 375 | yld->ctl_data->cmd = CMD_DIALTONE; | ||
| 376 | yld->ctl_data->sum = -1 - CMD_DIALTONE - val; | ||
| 377 | break; | ||
| 378 | case offsetof(struct yld_status, ringtone): | ||
| 379 | yld->ctl_data->cmd = CMD_RINGTONE; | ||
| 380 | yld->ctl_data->sum = -1 - CMD_RINGTONE - val; | ||
| 381 | break; | ||
| 382 | case offsetof(struct yld_status, keynum): | ||
| 383 | val--; | ||
| 384 | val &= 0x1f; | ||
| 385 | yld->ctl_data->cmd = CMD_SCANCODE; | ||
| 386 | yld->ctl_data->offset = cpu_to_be16(val); | ||
| 387 | yld->ctl_data->data[0] = 0; | ||
| 388 | yld->ctl_data->sum = -1 - CMD_SCANCODE - val; | ||
| 389 | break; | ||
| 390 | default: | ||
| 391 | len = sizeof(yld->master.s.lcd) - ix; | ||
| 392 | if (len > sizeof(yld->ctl_data->data)) | ||
| 393 | len = sizeof(yld->ctl_data->data); | ||
| 394 | |||
| 395 | /* Combine up to <len> consecutive LCD bytes in a singe request | ||
| 396 | */ | ||
| 397 | yld->ctl_data->cmd = CMD_LCD; | ||
| 398 | yld->ctl_data->offset = cpu_to_be16(ix); | ||
| 399 | yld->ctl_data->size = len; | ||
| 400 | yld->ctl_data->sum = -CMD_LCD - ix - val - len; | ||
| 401 | for(i=1; i<len; i++) { | ||
| 402 | ix++; | ||
| 403 | val = yld->master.b[ix]; | ||
| 404 | yld->copy.b[ix] = val; | ||
| 405 | yld->ctl_data->data[i] = val; | ||
| 406 | yld->ctl_data->sum -= val; | ||
| 407 | } | ||
| 408 | } | ||
| 409 | yld->stat_ix = ix + 1; | ||
| 410 | return 1; | ||
| 411 | } | ||
| 412 | |||
| 413 | /* Decide on how to handle responses | ||
| 414 | * | ||
| 415 | * The state transition diagram is somethhing like: | ||
| 416 | * | ||
| 417 | * syncState<--+ | ||
| 418 | * | | | ||
| 419 | * | idle | ||
| 420 | * \|/ | | ||
| 421 | * init --ok--> waitForKey --ok--> getKey | ||
| 422 | * ^ ^ | | ||
| 423 | * | +-------ok-------+ | ||
| 424 | * error,start | ||
| 425 | * | ||
| 426 | */ | ||
| 427 | static void urb_irq_callback(struct urb *urb, struct pt_regs *regs) | ||
| 428 | { | ||
| 429 | struct yealink_dev *yld = urb->context; | ||
| 430 | int ret; | ||
| 431 | |||
| 432 | if (urb->status) | ||
| 433 | err("%s - urb status %d", __FUNCTION__, urb->status); | ||
| 434 | |||
| 435 | switch (yld->irq_data->cmd) { | ||
| 436 | case CMD_KEYPRESS: | ||
| 437 | |||
| 438 | yld->master.s.keynum = yld->irq_data->data[0]; | ||
| 439 | break; | ||
| 440 | |||
| 441 | case CMD_SCANCODE: | ||
| 442 | dbg("get scancode %x", yld->irq_data->data[0]); | ||
| 443 | |||
| 444 | report_key(yld, map_p1k_to_key(yld->irq_data->data[0]), regs); | ||
| 445 | break; | ||
| 446 | |||
| 447 | default: | ||
| 448 | err("unexpected response %x", yld->irq_data->cmd); | ||
| 449 | } | ||
| 450 | |||
| 451 | yealink_do_idle_tasks(yld); | ||
| 452 | |||
| 453 | ret = usb_submit_urb(yld->urb_ctl, GFP_ATOMIC); | ||
| 454 | if (ret) | ||
| 455 | err("%s - usb_submit_urb failed %d", __FUNCTION__, ret); | ||
| 456 | } | ||
| 457 | |||
| 458 | static void urb_ctl_callback(struct urb *urb, struct pt_regs *regs) | ||
| 459 | { | ||
| 460 | struct yealink_dev *yld = urb->context; | ||
| 461 | int ret; | ||
| 462 | |||
| 463 | if (urb->status) | ||
| 464 | err("%s - urb status %d", __FUNCTION__, urb->status); | ||
| 465 | |||
| 466 | switch (yld->ctl_data->cmd) { | ||
| 467 | case CMD_KEYPRESS: | ||
| 468 | case CMD_SCANCODE: | ||
| 469 | /* ask for a response */ | ||
| 470 | ret = usb_submit_urb(yld->urb_irq, GFP_ATOMIC); | ||
| 471 | break; | ||
| 472 | default: | ||
| 473 | /* send new command */ | ||
| 474 | yealink_do_idle_tasks(yld); | ||
| 475 | ret = usb_submit_urb(yld->urb_ctl, GFP_ATOMIC); | ||
| 476 | } | ||
| 477 | |||
| 478 | if (ret) | ||
| 479 | err("%s - usb_submit_urb failed %d", __FUNCTION__, ret); | ||
| 480 | } | ||
| 481 | |||
| 482 | /******************************************************************************* | ||
| 483 | * input event interface | ||
| 484 | ******************************************************************************/ | ||
| 485 | |||
| 486 | /* TODO should we issue a ringtone on a SND_BELL event? | ||
| 487 | static int input_ev(struct input_dev *dev, unsigned int type, | ||
| 488 | unsigned int code, int value) | ||
| 489 | { | ||
| 490 | |||
| 491 | if (type != EV_SND) | ||
| 492 | return -EINVAL; | ||
| 493 | |||
| 494 | switch (code) { | ||
| 495 | case SND_BELL: | ||
| 496 | case SND_TONE: | ||
| 497 | break; | ||
| 498 | default: | ||
| 499 | return -EINVAL; | ||
| 500 | } | ||
| 501 | |||
| 502 | return 0; | ||
| 503 | } | ||
| 504 | */ | ||
| 505 | |||
| 506 | static int input_open(struct input_dev *dev) | ||
| 507 | { | ||
| 508 | struct yealink_dev *yld = dev->private; | ||
| 509 | int i, ret; | ||
| 510 | |||
| 511 | dbg("%s", __FUNCTION__); | ||
| 512 | |||
| 513 | /* force updates to device */ | ||
| 514 | for (i = 0; i<sizeof(yld->master); i++) | ||
| 515 | yld->copy.b[i] = ~yld->master.b[i]; | ||
| 516 | yld->key_code = -1; /* no keys pressed */ | ||
| 517 | |||
| 518 | yealink_set_ringtone(yld, default_ringtone, sizeof(default_ringtone)); | ||
| 519 | |||
| 520 | /* issue INIT */ | ||
| 521 | memset(yld->ctl_data, 0, sizeof(*(yld->ctl_data))); | ||
| 522 | yld->ctl_data->cmd = CMD_INIT; | ||
| 523 | yld->ctl_data->size = 10; | ||
| 524 | yld->ctl_data->sum = 0x100-CMD_INIT-10; | ||
| 525 | if ((ret = usb_submit_urb(yld->urb_ctl, GFP_KERNEL)) != 0) { | ||
| 526 | dbg("%s - usb_submit_urb failed with result %d", | ||
| 527 | __FUNCTION__, ret); | ||
| 528 | return ret; | ||
| 529 | } | ||
| 530 | return 0; | ||
| 531 | } | ||
| 532 | |||
| 533 | static void input_close(struct input_dev *dev) | ||
| 534 | { | ||
| 535 | struct yealink_dev *yld = dev->private; | ||
| 536 | |||
| 537 | usb_kill_urb(yld->urb_ctl); | ||
| 538 | usb_kill_urb(yld->urb_irq); | ||
| 539 | } | ||
| 540 | |||
| 541 | /******************************************************************************* | ||
| 542 | * sysfs interface | ||
| 543 | ******************************************************************************/ | ||
| 544 | |||
| 545 | static DECLARE_RWSEM(sysfs_rwsema); | ||
| 546 | |||
| 547 | /* Interface to the 7-segments translation table aka. char set. | ||
| 548 | */ | ||
| 549 | static ssize_t show_map(struct device *dev, struct device_attribute *attr, | ||
| 550 | char *buf) | ||
| 551 | { | ||
| 552 | memcpy(buf, &map_seg7, sizeof(map_seg7)); | ||
| 553 | return sizeof(map_seg7); | ||
| 554 | } | ||
| 555 | |||
| 556 | static ssize_t store_map(struct device *dev, struct device_attribute *attr, | ||
| 557 | const char *buf, size_t cnt) | ||
| 558 | { | ||
| 559 | if (cnt != sizeof(map_seg7)) | ||
| 560 | return -EINVAL; | ||
| 561 | memcpy(&map_seg7, buf, sizeof(map_seg7)); | ||
| 562 | return sizeof(map_seg7); | ||
| 563 | } | ||
| 564 | |||
| 565 | /* Interface to the LCD. | ||
| 566 | */ | ||
| 567 | |||
| 568 | /* Reading /sys/../lineX will return the format string with its settings: | ||
| 569 | * | ||
| 570 | * Example: | ||
| 571 | * cat ./line3 | ||
| 572 | * 888888888888 | ||
| 573 | * Linux Rocks! | ||
| 574 | */ | ||
| 575 | static ssize_t show_line(struct device *dev, char *buf, int a, int b) | ||
| 576 | { | ||
| 577 | struct yealink_dev *yld; | ||
| 578 | int i; | ||
| 579 | |||
| 580 | down_read(&sysfs_rwsema); | ||
| 581 | yld = dev_get_drvdata(dev); | ||
| 582 | if (yld == NULL) { | ||
| 583 | up_read(&sysfs_rwsema); | ||
| 584 | return -ENODEV; | ||
| 585 | } | ||
| 586 | |||
| 587 | for (i = a; i < b; i++) | ||
| 588 | *buf++ = lcdMap[i].type; | ||
| 589 | *buf++ = '\n'; | ||
| 590 | for (i = a; i < b; i++) | ||
| 591 | *buf++ = yld->lcdMap[i]; | ||
| 592 | *buf++ = '\n'; | ||
| 593 | *buf = 0; | ||
| 594 | |||
| 595 | up_read(&sysfs_rwsema); | ||
| 596 | return 3 + ((b - a) << 1); | ||
| 597 | } | ||
| 598 | |||
| 599 | static ssize_t show_line1(struct device *dev, struct device_attribute *attr, | ||
| 600 | char *buf) | ||
| 601 | { | ||
| 602 | return show_line(dev, buf, LCD_LINE1_OFFSET, LCD_LINE2_OFFSET); | ||
| 603 | } | ||
| 604 | |||
| 605 | static ssize_t show_line2(struct device *dev, struct device_attribute *attr, | ||
| 606 | char *buf) | ||
| 607 | { | ||
| 608 | return show_line(dev, buf, LCD_LINE2_OFFSET, LCD_LINE3_OFFSET); | ||
| 609 | } | ||
| 610 | |||
| 611 | static ssize_t show_line3(struct device *dev, struct device_attribute *attr, | ||
| 612 | char *buf) | ||
| 613 | { | ||
| 614 | return show_line(dev, buf, LCD_LINE3_OFFSET, LCD_LINE4_OFFSET); | ||
| 615 | } | ||
| 616 | |||
| 617 | /* Writing to /sys/../lineX will set the coresponding LCD line. | ||
| 618 | * - Excess characters are ignored. | ||
| 619 | * - If less characters are written than allowed, the remaining digits are | ||
| 620 | * unchanged. | ||
| 621 | * - The '\n' or '\t' char is a placeholder, it does not overwrite the | ||
| 622 | * original content. | ||
| 623 | */ | ||
| 624 | static ssize_t store_line(struct device *dev, const char *buf, size_t count, | ||
| 625 | int el, size_t len) | ||
| 626 | { | ||
| 627 | struct yealink_dev *yld; | ||
| 628 | int i; | ||
| 629 | |||
| 630 | down_write(&sysfs_rwsema); | ||
| 631 | yld = dev_get_drvdata(dev); | ||
| 632 | if (yld == NULL) { | ||
| 633 | up_write(&sysfs_rwsema); | ||
| 634 | return -ENODEV; | ||
| 635 | } | ||
| 636 | |||
| 637 | if (len > count) | ||
| 638 | len = count; | ||
| 639 | for (i = 0; i < len; i++) | ||
| 640 | setChar(yld, el++, buf[i]); | ||
| 641 | |||
| 642 | up_write(&sysfs_rwsema); | ||
| 643 | return count; | ||
| 644 | } | ||
| 645 | |||
| 646 | static ssize_t store_line1(struct device *dev, struct device_attribute *attr, | ||
| 647 | const char *buf, size_t count) | ||
| 648 | { | ||
| 649 | return store_line(dev, buf, count, LCD_LINE1_OFFSET, LCD_LINE1_SIZE); | ||
| 650 | } | ||
| 651 | |||
| 652 | static ssize_t store_line2(struct device *dev, struct device_attribute *attr, | ||
| 653 | const char *buf, size_t count) | ||
| 654 | { | ||
| 655 | return store_line(dev, buf, count, LCD_LINE2_OFFSET, LCD_LINE2_SIZE); | ||
| 656 | } | ||
| 657 | |||
| 658 | static ssize_t store_line3(struct device *dev, struct device_attribute *attr, | ||
| 659 | const char *buf, size_t count) | ||
| 660 | { | ||
| 661 | return store_line(dev, buf, count, LCD_LINE3_OFFSET, LCD_LINE3_SIZE); | ||
| 662 | } | ||
| 663 | |||
| 664 | /* Interface to visible and audible "icons", these include: | ||
| 665 | * pictures on the LCD, the LED, and the dialtone signal. | ||
| 666 | */ | ||
| 667 | |||
| 668 | /* Get a list of "switchable elements" with their current state. */ | ||
| 669 | static ssize_t get_icons(struct device *dev, struct device_attribute *attr, | ||
| 670 | char *buf) | ||
| 671 | { | ||
| 672 | struct yealink_dev *yld; | ||
| 673 | int i, ret = 1; | ||
| 674 | |||
| 675 | down_read(&sysfs_rwsema); | ||
| 676 | yld = dev_get_drvdata(dev); | ||
| 677 | if (yld == NULL) { | ||
| 678 | up_read(&sysfs_rwsema); | ||
| 679 | return -ENODEV; | ||
| 680 | } | ||
| 681 | |||
| 682 | for (i = 0; i < ARRAY_SIZE(lcdMap); i++) { | ||
| 683 | if (lcdMap[i].type != '.') | ||
| 684 | continue; | ||
| 685 | ret += sprintf(&buf[ret], "%s %s\n", | ||
| 686 | yld->lcdMap[i] == ' ' ? " " : "on", | ||
| 687 | lcdMap[i].u.p.name); | ||
| 688 | } | ||
| 689 | up_read(&sysfs_rwsema); | ||
| 690 | return ret; | ||
| 691 | } | ||
| 692 | |||
| 693 | /* Change the visibility of a particular element. */ | ||
| 694 | static ssize_t set_icon(struct device *dev, const char *buf, size_t count, | ||
| 695 | int chr) | ||
| 696 | { | ||
| 697 | struct yealink_dev *yld; | ||
| 698 | int i; | ||
| 699 | |||
| 700 | down_write(&sysfs_rwsema); | ||
| 701 | yld = dev_get_drvdata(dev); | ||
| 702 | if (yld == NULL) { | ||
| 703 | up_write(&sysfs_rwsema); | ||
| 704 | return -ENODEV; | ||
| 705 | } | ||
| 706 | |||
| 707 | for (i = 0; i < ARRAY_SIZE(lcdMap); i++) { | ||
| 708 | if (lcdMap[i].type != '.') | ||
| 709 | continue; | ||
| 710 | if (strncmp(buf, lcdMap[i].u.p.name, count) == 0) { | ||
| 711 | setChar(yld, i, chr); | ||
| 712 | break; | ||
| 713 | } | ||
| 714 | } | ||
| 715 | |||
| 716 | up_write(&sysfs_rwsema); | ||
| 717 | return count; | ||
| 718 | } | ||
| 719 | |||
| 720 | static ssize_t show_icon(struct device *dev, struct device_attribute *attr, | ||
| 721 | const char *buf, size_t count) | ||
| 722 | { | ||
| 723 | return set_icon(dev, buf, count, buf[0]); | ||
| 724 | } | ||
| 725 | |||
| 726 | static ssize_t hide_icon(struct device *dev, struct device_attribute *attr, | ||
| 727 | const char *buf, size_t count) | ||
| 728 | { | ||
| 729 | return set_icon(dev, buf, count, ' '); | ||
| 730 | } | ||
| 731 | |||
| 732 | /* Upload a ringtone to the device. | ||
| 733 | */ | ||
| 734 | |||
| 735 | /* Stores raw ringtone data in the phone */ | ||
| 736 | static ssize_t store_ringtone(struct device *dev, | ||
| 737 | struct device_attribute *attr, | ||
| 738 | const char *buf, size_t count) | ||
| 739 | { | ||
| 740 | struct yealink_dev *yld; | ||
| 741 | |||
| 742 | down_write(&sysfs_rwsema); | ||
| 743 | yld = dev_get_drvdata(dev); | ||
| 744 | if (yld == NULL) { | ||
| 745 | up_write(&sysfs_rwsema); | ||
| 746 | return -ENODEV; | ||
| 747 | } | ||
| 748 | |||
| 749 | /* TODO locking with async usb control interface??? */ | ||
| 750 | yealink_set_ringtone(yld, (char *)buf, count); | ||
| 751 | up_write(&sysfs_rwsema); | ||
| 752 | return count; | ||
| 753 | } | ||
| 754 | |||
| 755 | #define _M444 S_IRUGO | ||
| 756 | #define _M664 S_IRUGO|S_IWUSR|S_IWGRP | ||
| 757 | #define _M220 S_IWUSR|S_IWGRP | ||
| 758 | |||
| 759 | static DEVICE_ATTR(map_seg7 , _M664, show_map , store_map ); | ||
| 760 | static DEVICE_ATTR(line1 , _M664, show_line1 , store_line1 ); | ||
| 761 | static DEVICE_ATTR(line2 , _M664, show_line2 , store_line2 ); | ||
| 762 | static DEVICE_ATTR(line3 , _M664, show_line3 , store_line3 ); | ||
| 763 | static DEVICE_ATTR(get_icons , _M444, get_icons , NULL ); | ||
| 764 | static DEVICE_ATTR(show_icon , _M220, NULL , show_icon ); | ||
| 765 | static DEVICE_ATTR(hide_icon , _M220, NULL , hide_icon ); | ||
| 766 | static DEVICE_ATTR(ringtone , _M220, NULL , store_ringtone); | ||
| 767 | |||
| 768 | static struct attribute *yld_attributes[] = { | ||
| 769 | &dev_attr_line1.attr, | ||
| 770 | &dev_attr_line2.attr, | ||
| 771 | &dev_attr_line3.attr, | ||
| 772 | &dev_attr_get_icons.attr, | ||
| 773 | &dev_attr_show_icon.attr, | ||
| 774 | &dev_attr_hide_icon.attr, | ||
| 775 | &dev_attr_map_seg7.attr, | ||
| 776 | &dev_attr_ringtone.attr, | ||
| 777 | NULL | ||
| 778 | }; | ||
| 779 | |||
| 780 | static struct attribute_group yld_attr_group = { | ||
| 781 | .attrs = yld_attributes | ||
| 782 | }; | ||
| 783 | |||
| 784 | /******************************************************************************* | ||
| 785 | * Linux interface and usb initialisation | ||
| 786 | ******************************************************************************/ | ||
| 787 | |||
| 788 | static const struct yld_device { | ||
| 789 | u16 idVendor; | ||
| 790 | u16 idProduct; | ||
| 791 | char *name; | ||
| 792 | } yld_device[] = { | ||
| 793 | { 0x6993, 0xb001, "Yealink usb-p1k" }, | ||
| 794 | }; | ||
| 795 | |||
| 796 | static struct usb_device_id usb_table [] = { | ||
| 797 | { USB_INTERFACE_INFO(USB_CLASS_HID, 0, 0) }, | ||
| 798 | { } | ||
| 799 | }; | ||
| 800 | |||
| 801 | static int usb_cleanup(struct yealink_dev *yld, int err) | ||
| 802 | { | ||
| 803 | if (yld == NULL) | ||
| 804 | return err; | ||
| 805 | |||
| 806 | if (yld->urb_irq) { | ||
| 807 | usb_kill_urb(yld->urb_irq); | ||
| 808 | usb_free_urb(yld->urb_irq); | ||
| 809 | } | ||
| 810 | if (yld->urb_ctl) | ||
| 811 | usb_free_urb(yld->urb_ctl); | ||
| 812 | if (yld->idev.dev) | ||
| 813 | input_unregister_device(&yld->idev); | ||
| 814 | if (yld->ctl_req) | ||
| 815 | usb_buffer_free(yld->udev, sizeof(*(yld->ctl_req)), | ||
| 816 | yld->ctl_req, yld->ctl_req_dma); | ||
| 817 | if (yld->ctl_data) | ||
| 818 | usb_buffer_free(yld->udev, USB_PKT_LEN, | ||
| 819 | yld->ctl_data, yld->ctl_dma); | ||
| 820 | if (yld->irq_data) | ||
| 821 | usb_buffer_free(yld->udev, USB_PKT_LEN, | ||
| 822 | yld->irq_data, yld->irq_dma); | ||
| 823 | kfree(yld); | ||
| 824 | return err; | ||
| 825 | } | ||
| 826 | |||
| 827 | static void usb_disconnect(struct usb_interface *intf) | ||
| 828 | { | ||
| 829 | struct yealink_dev *yld; | ||
| 830 | |||
| 831 | down_write(&sysfs_rwsema); | ||
| 832 | yld = usb_get_intfdata(intf); | ||
| 833 | sysfs_remove_group(&intf->dev.kobj, &yld_attr_group); | ||
| 834 | usb_set_intfdata(intf, NULL); | ||
| 835 | up_write(&sysfs_rwsema); | ||
| 836 | |||
| 837 | usb_cleanup(yld, 0); | ||
| 838 | } | ||
| 839 | |||
| 840 | static int usb_match(struct usb_device *udev) | ||
| 841 | { | ||
| 842 | int i; | ||
| 843 | u16 idVendor = le16_to_cpu(udev->descriptor.idVendor); | ||
| 844 | u16 idProduct = le16_to_cpu(udev->descriptor.idProduct); | ||
| 845 | |||
| 846 | for (i = 0; i < ARRAY_SIZE(yld_device); i++) { | ||
| 847 | if ((idVendor == yld_device[i].idVendor) && | ||
| 848 | (idProduct == yld_device[i].idProduct)) | ||
| 849 | return i; | ||
| 850 | } | ||
| 851 | return -ENODEV; | ||
| 852 | } | ||
| 853 | |||
| 854 | static int usb_probe(struct usb_interface *intf, const struct usb_device_id *id) | ||
| 855 | { | ||
| 856 | struct usb_device *udev = interface_to_usbdev (intf); | ||
| 857 | struct usb_host_interface *interface; | ||
| 858 | struct usb_endpoint_descriptor *endpoint; | ||
| 859 | struct yealink_dev *yld; | ||
| 860 | char path[64]; | ||
| 861 | int ret, pipe, i; | ||
| 862 | |||
| 863 | i = usb_match(udev); | ||
| 864 | if (i < 0) | ||
| 865 | return -ENODEV; | ||
| 866 | |||
| 867 | interface = intf->cur_altsetting; | ||
| 868 | endpoint = &interface->endpoint[0].desc; | ||
| 869 | if (!(endpoint->bEndpointAddress & 0x80)) | ||
| 870 | return -EIO; | ||
| 871 | if ((endpoint->bmAttributes & 3) != 3) | ||
| 872 | return -EIO; | ||
| 873 | |||
| 874 | if ((yld = kmalloc(sizeof(struct yealink_dev), GFP_KERNEL)) == NULL) | ||
| 875 | return -ENOMEM; | ||
| 876 | |||
| 877 | memset(yld, 0, sizeof(*yld)); | ||
| 878 | yld->udev = udev; | ||
| 879 | |||
| 880 | /* allocate usb buffers */ | ||
| 881 | yld->irq_data = usb_buffer_alloc(udev, USB_PKT_LEN, | ||
| 882 | SLAB_ATOMIC, &yld->irq_dma); | ||
| 883 | if (yld->irq_data == NULL) | ||
| 884 | return usb_cleanup(yld, -ENOMEM); | ||
| 885 | |||
| 886 | yld->ctl_data = usb_buffer_alloc(udev, USB_PKT_LEN, | ||
| 887 | SLAB_ATOMIC, &yld->ctl_dma); | ||
| 888 | if (!yld->ctl_data) | ||
| 889 | return usb_cleanup(yld, -ENOMEM); | ||
| 890 | |||
| 891 | yld->ctl_req = usb_buffer_alloc(udev, sizeof(*(yld->ctl_req)), | ||
| 892 | SLAB_ATOMIC, &yld->ctl_req_dma); | ||
| 893 | if (yld->ctl_req == NULL) | ||
| 894 | return usb_cleanup(yld, -ENOMEM); | ||
| 895 | |||
| 896 | /* allocate urb structures */ | ||
| 897 | yld->urb_irq = usb_alloc_urb(0, GFP_KERNEL); | ||
| 898 | if (yld->urb_irq == NULL) | ||
| 899 | return usb_cleanup(yld, -ENOMEM); | ||
| 900 | |||
| 901 | yld->urb_ctl = usb_alloc_urb(0, GFP_KERNEL); | ||
| 902 | if (yld->urb_ctl == NULL) | ||
| 903 | return usb_cleanup(yld, -ENOMEM); | ||
| 904 | |||
| 905 | /* get a handle to the interrupt data pipe */ | ||
| 906 | pipe = usb_rcvintpipe(udev, endpoint->bEndpointAddress); | ||
| 907 | ret = usb_maxpacket(udev, pipe, usb_pipeout(pipe)); | ||
| 908 | if (ret != USB_PKT_LEN) | ||
| 909 | err("invalid payload size %d, expected %d", ret, USB_PKT_LEN); | ||
| 910 | |||
| 911 | /* initialise irq urb */ | ||
| 912 | usb_fill_int_urb(yld->urb_irq, udev, pipe, yld->irq_data, | ||
| 913 | USB_PKT_LEN, | ||
| 914 | urb_irq_callback, | ||
| 915 | yld, endpoint->bInterval); | ||
| 916 | yld->urb_irq->transfer_dma = yld->irq_dma; | ||
| 917 | yld->urb_irq->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; | ||
| 918 | yld->urb_irq->dev = udev; | ||
| 919 | |||
| 920 | /* initialise ctl urb */ | ||
| 921 | yld->ctl_req->bRequestType = USB_TYPE_CLASS | USB_RECIP_INTERFACE | | ||
| 922 | USB_DIR_OUT; | ||
| 923 | yld->ctl_req->bRequest = USB_REQ_SET_CONFIGURATION; | ||
| 924 | yld->ctl_req->wValue = cpu_to_le16(0x200); | ||
| 925 | yld->ctl_req->wIndex = cpu_to_le16(interface->desc.bInterfaceNumber); | ||
| 926 | yld->ctl_req->wLength = cpu_to_le16(USB_PKT_LEN); | ||
| 927 | |||
| 928 | usb_fill_control_urb(yld->urb_ctl, udev, usb_sndctrlpipe(udev, 0), | ||
| 929 | (void *)yld->ctl_req, yld->ctl_data, USB_PKT_LEN, | ||
| 930 | urb_ctl_callback, yld); | ||
| 931 | yld->urb_ctl->setup_dma = yld->ctl_req_dma; | ||
| 932 | yld->urb_ctl->transfer_dma = yld->ctl_dma; | ||
| 933 | yld->urb_ctl->transfer_flags |= URB_NO_SETUP_DMA_MAP | | ||
| 934 | URB_NO_TRANSFER_DMA_MAP; | ||
| 935 | yld->urb_ctl->dev = udev; | ||
| 936 | |||
| 937 | /* find out the physical bus location */ | ||
| 938 | if (usb_make_path(udev, path, sizeof(path)) > 0) | ||
| 939 | snprintf(yld->phys, sizeof(yld->phys)-1, "%s/input0", path); | ||
| 940 | |||
| 941 | /* register settings for the input device */ | ||
| 942 | init_input_dev(&yld->idev); | ||
| 943 | yld->idev.private = yld; | ||
| 944 | yld->idev.id.bustype = BUS_USB; | ||
| 945 | yld->idev.id.vendor = le16_to_cpu(udev->descriptor.idVendor); | ||
| 946 | yld->idev.id.product = le16_to_cpu(udev->descriptor.idProduct); | ||
| 947 | yld->idev.id.version = le16_to_cpu(udev->descriptor.bcdDevice); | ||
| 948 | yld->idev.dev = &intf->dev; | ||
| 949 | yld->idev.name = yld_device[i].name; | ||
| 950 | yld->idev.phys = yld->phys; | ||
| 951 | /* yld->idev.event = input_ev; TODO */ | ||
| 952 | yld->idev.open = input_open; | ||
| 953 | yld->idev.close = input_close; | ||
| 954 | |||
| 955 | /* register available key events */ | ||
| 956 | yld->idev.evbit[0] = BIT(EV_KEY); | ||
| 957 | for (i = 0; i < 256; i++) { | ||
| 958 | int k = map_p1k_to_key(i); | ||
| 959 | if (k >= 0) { | ||
| 960 | set_bit(k & 0xff, yld->idev.keybit); | ||
| 961 | if (k >> 8) | ||
| 962 | set_bit(k >> 8, yld->idev.keybit); | ||
| 963 | } | ||
| 964 | } | ||
| 965 | |||
| 966 | printk(KERN_INFO "input: %s on %s\n", yld->idev.name, path); | ||
| 967 | |||
| 968 | input_register_device(&yld->idev); | ||
| 969 | |||
| 970 | usb_set_intfdata(intf, yld); | ||
| 971 | |||
| 972 | /* clear visible elements */ | ||
| 973 | for (i=0; i<ARRAY_SIZE(lcdMap); i++) | ||
| 974 | setChar(yld, i, ' '); | ||
| 975 | |||
| 976 | /* display driver version on LCD line 3 */ | ||
| 977 | store_line3(&intf->dev, NULL, | ||
| 978 | DRIVER_VERSION, sizeof(DRIVER_VERSION)); | ||
| 979 | |||
| 980 | /* Register sysfs hooks (don't care about failure) */ | ||
| 981 | sysfs_create_group(&intf->dev.kobj, &yld_attr_group); | ||
| 982 | return 0; | ||
| 983 | } | ||
| 984 | |||
| 985 | static struct usb_driver yealink_driver = { | ||
| 986 | .owner = THIS_MODULE, | ||
| 987 | .name = "yealink", | ||
| 988 | .probe = usb_probe, | ||
| 989 | .disconnect = usb_disconnect, | ||
| 990 | .id_table = usb_table, | ||
| 991 | }; | ||
| 992 | |||
| 993 | static int __init yealink_dev_init(void) | ||
| 994 | { | ||
| 995 | int ret = usb_register(&yealink_driver); | ||
| 996 | if (ret == 0) | ||
| 997 | info(DRIVER_DESC ":" DRIVER_VERSION); | ||
| 998 | return ret; | ||
| 999 | } | ||
| 1000 | |||
| 1001 | static void __exit yealink_dev_exit(void) | ||
| 1002 | { | ||
| 1003 | usb_deregister(&yealink_driver); | ||
| 1004 | } | ||
| 1005 | |||
| 1006 | module_init(yealink_dev_init); | ||
| 1007 | module_exit(yealink_dev_exit); | ||
| 1008 | |||
| 1009 | MODULE_DEVICE_TABLE (usb, usb_table); | ||
| 1010 | |||
| 1011 | MODULE_AUTHOR(DRIVER_AUTHOR); | ||
| 1012 | MODULE_DESCRIPTION(DRIVER_DESC); | ||
| 1013 | MODULE_LICENSE("GPL"); | ||
diff --git a/drivers/usb/input/yealink.h b/drivers/usb/input/yealink.h new file mode 100644 index 000000000000..48af0be9cbdf --- /dev/null +++ b/drivers/usb/input/yealink.h | |||
| @@ -0,0 +1,220 @@ | |||
| 1 | /* | ||
| 2 | * drivers/usb/input/yealink.h | ||
| 3 | * | ||
| 4 | * Copyright (c) 2005 Henk Vergonet <Henk.Vergonet@gmail.com> | ||
| 5 | * | ||
| 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 | ||
| 10 | * the License, or (at your option) any later version. | ||
| 11 | * | ||
| 12 | * This program is distributed in the hope that it will be useful, | ||
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 15 | * GNU 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
| 20 | */ | ||
| 21 | #ifndef INPUT_YEALINK_H | ||
| 22 | #define INPUT_YEALINK_H | ||
| 23 | |||
| 24 | /* Using the control channel on interface 3 various aspects of the phone | ||
| 25 | * can be controlled like LCD, LED, dialtone and the ringtone. | ||
| 26 | */ | ||
| 27 | |||
| 28 | struct yld_ctl_packet { | ||
| 29 | u8 cmd; /* command code, see below */ | ||
| 30 | u8 size; /* 1-11, size of used data bytes. */ | ||
| 31 | u16 offset; /* internal packet offset */ | ||
| 32 | u8 data[11]; | ||
| 33 | s8 sum; /* negative sum of 15 preceding bytes */ | ||
| 34 | } __attribute__ ((packed)); | ||
| 35 | |||
| 36 | #define USB_PKT_LEN sizeof(struct yld_ctl_packet) | ||
| 37 | |||
| 38 | /* The following yld_ctl_packet's are available: */ | ||
| 39 | |||
| 40 | /* Init registers | ||
| 41 | * | ||
| 42 | * cmd 0x8e | ||
| 43 | * size 10 | ||
| 44 | * offset 0 | ||
| 45 | * data 0,0,0,0.... | ||
| 46 | */ | ||
| 47 | #define CMD_INIT 0x8e | ||
| 48 | |||
| 49 | /* Request key scan | ||
| 50 | * | ||
| 51 | * cmd 0x80 | ||
| 52 | * size 1 | ||
| 53 | * offset 0 | ||
| 54 | * data[0] on return returns the key number, if it changes there's a new | ||
| 55 | * key pressed. | ||
| 56 | */ | ||
| 57 | #define CMD_KEYPRESS 0x80 | ||
| 58 | |||
| 59 | /* Request scancode | ||
| 60 | * | ||
| 61 | * cmd 0x81 | ||
| 62 | * size 1 | ||
| 63 | * offset key number [0-1f] | ||
| 64 | * data[0] on return returns the scancode | ||
| 65 | */ | ||
| 66 | #define CMD_SCANCODE 0x81 | ||
| 67 | |||
| 68 | /* Set LCD | ||
| 69 | * | ||
| 70 | * cmd 0x04 | ||
| 71 | * size 1-11 | ||
| 72 | * offset 0-23 | ||
| 73 | * data segment bits | ||
| 74 | */ | ||
| 75 | #define CMD_LCD 0x04 | ||
| 76 | |||
| 77 | /* Set led | ||
| 78 | * | ||
| 79 | * cmd 0x05 | ||
| 80 | * size 1 | ||
| 81 | * offset 0 | ||
| 82 | * data[0] 0 OFF / 1 ON | ||
| 83 | */ | ||
| 84 | #define CMD_LED 0x05 | ||
| 85 | |||
| 86 | /* Set ringtone volume | ||
| 87 | * | ||
| 88 | * cmd 0x11 | ||
| 89 | * size 1 | ||
| 90 | * offset 0 | ||
| 91 | * data[0] 0-0xff volume | ||
| 92 | */ | ||
| 93 | #define CMD_RING_VOLUME 0x11 | ||
| 94 | |||
| 95 | /* Set ringtone notes | ||
| 96 | * | ||
| 97 | * cmd 0x02 | ||
| 98 | * size 1-11 | ||
| 99 | * offset 0-> | ||
| 100 | * data binary representation LE16(-freq), LE16(duration) .... | ||
| 101 | */ | ||
| 102 | #define CMD_RING_NOTE 0x02 | ||
| 103 | |||
| 104 | /* Sound ringtone via the speaker on the back | ||
| 105 | * | ||
| 106 | * cmd 0x03 | ||
| 107 | * size 1 | ||
| 108 | * offset 0 | ||
| 109 | * data[0] 0 OFF / 0x24 ON | ||
| 110 | */ | ||
| 111 | #define CMD_RINGTONE 0x03 | ||
| 112 | |||
| 113 | /* Sound dial tone via the ear speaker | ||
| 114 | * | ||
| 115 | * cmd 0x09 | ||
| 116 | * size 1 | ||
| 117 | * offset 0 | ||
| 118 | * data[0] 0 OFF / 1 ON | ||
| 119 | */ | ||
| 120 | #define CMD_DIALTONE 0x09 | ||
| 121 | |||
| 122 | #endif /* INPUT_YEALINK_H */ | ||
| 123 | |||
| 124 | |||
| 125 | #if defined(_SEG) && defined(_PIC) | ||
| 126 | /* This table maps the LCD segments onto individual bit positions in the | ||
| 127 | * yld_status struct. | ||
| 128 | */ | ||
| 129 | |||
| 130 | /* LCD, each segment must be driven seperately. | ||
| 131 | * | ||
| 132 | * Layout: | ||
| 133 | * | ||
| 134 | * |[] [][] [][] [][] in |[][] | ||
| 135 | * |[] M [][] D [][] : [][] out |[][] | ||
| 136 | * store | ||
| 137 | * | ||
| 138 | * NEW REP SU MO TU WE TH FR SA | ||
| 139 | * | ||
| 140 | * [] [] [] [] [] [] [] [] [] [] [] [] | ||
| 141 | * [] [] [] [] [] [] [] [] [] [] [] [] | ||
| 142 | */ | ||
| 143 | |||
| 144 | /* Line 1 | ||
| 145 | * Format : 18.e8.M8.88...188 | ||
| 146 | * Icon names : M D : IN OUT STORE | ||
| 147 | */ | ||
| 148 | #define LCD_LINE1_OFFSET 0 | ||
| 149 | #define LCD_LINE1_SIZE 17 | ||
| 150 | |||
| 151 | /* Note: first g then f => ! ! */ | ||
| 152 | /* _SEG( type a b c d e g f ) */ | ||
| 153 | _SEG('1', 0,0 , 22,2 , 22,2 , 0,0 , 0,0 , 0,0 , 0,0 ), | ||
| 154 | _SEG('8', 20,1 , 20,2 , 20,4 , 20,8 , 21,4 , 21,2 , 21,1 ), | ||
| 155 | _PIC('.', 22,1 , "M" ), | ||
| 156 | _SEG('e', 18,1 , 18,2 , 18,4 , 18,1 , 19,2 , 18,1 , 19,1 ), | ||
| 157 | _SEG('8', 16,1 , 16,2 , 16,4 , 16,8 , 17,4 , 17,2 , 17,1 ), | ||
| 158 | _PIC('.', 15,8 , "D" ), | ||
| 159 | _SEG('M', 14,1 , 14,2 , 14,4 , 14,1 , 15,4 , 15,2 , 15,1 ), | ||
| 160 | _SEG('8', 12,1 , 12,2 , 12,4 , 12,8 , 13,4 , 13,2 , 13,1 ), | ||
| 161 | _PIC('.', 11,8 , ":" ), | ||
| 162 | _SEG('8', 10,1 , 10,2 , 10,4 , 10,8 , 11,4 , 11,2 , 11,1 ), | ||
| 163 | _SEG('8', 8,1 , 8,2 , 8,4 , 8,8 , 9,4 , 9,2 , 9,1 ), | ||
| 164 | _PIC('.', 7,1 , "IN" ), | ||
| 165 | _PIC('.', 7,2 , "OUT" ), | ||
| 166 | _PIC('.', 7,4 , "STORE" ), | ||
| 167 | _SEG('1', 0,0 , 5,1 , 5,1 , 0,0 , 0,0 , 0,0 , 0,0 ), | ||
| 168 | _SEG('8', 4,1 , 4,2 , 4,4 , 4,8 , 5,8 , 5,4 , 5,2 ), | ||
| 169 | _SEG('8', 2,1 , 2,2 , 2,4 , 2,8 , 3,4 , 3,2 , 3,1 ), | ||
| 170 | |||
| 171 | /* Line 2 | ||
| 172 | * Format : ......... | ||
| 173 | * Pict. name : NEW REP SU MO TU WE TH FR SA | ||
| 174 | */ | ||
| 175 | #define LCD_LINE2_OFFSET LCD_LINE1_OFFSET + LCD_LINE1_SIZE | ||
| 176 | #define LCD_LINE2_SIZE 9 | ||
| 177 | |||
| 178 | _PIC('.', 23,2 , "NEW" ), | ||
| 179 | _PIC('.', 23,4 , "REP" ), | ||
| 180 | _PIC('.', 1,8 , "SU" ), | ||
| 181 | _PIC('.', 1,4 , "MO" ), | ||
| 182 | _PIC('.', 1,2 , "TU" ), | ||
| 183 | _PIC('.', 1,1 , "WE" ), | ||
| 184 | _PIC('.', 0,1 , "TH" ), | ||
| 185 | _PIC('.', 0,2 , "FR" ), | ||
| 186 | _PIC('.', 0,4 , "SA" ), | ||
| 187 | |||
| 188 | /* Line 3 | ||
| 189 | * Format : 888888888888 | ||
| 190 | */ | ||
| 191 | #define LCD_LINE3_OFFSET LCD_LINE2_OFFSET + LCD_LINE2_SIZE | ||
| 192 | #define LCD_LINE3_SIZE 12 | ||
| 193 | |||
| 194 | _SEG('8', 22,16, 22,32, 22,64, 22,128, 23,128, 23,64, 23,32 ), | ||
| 195 | _SEG('8', 20,16, 20,32, 20,64, 20,128, 21,128, 21,64, 21,32 ), | ||
| 196 | _SEG('8', 18,16, 18,32, 18,64, 18,128, 19,128, 19,64, 19,32 ), | ||
| 197 | _SEG('8', 16,16, 16,32, 16,64, 16,128, 17,128, 17,64, 17,32 ), | ||
| 198 | _SEG('8', 14,16, 14,32, 14,64, 14,128, 15,128, 15,64, 15,32 ), | ||
| 199 | _SEG('8', 12,16, 12,32, 12,64, 12,128, 13,128, 13,64, 13,32 ), | ||
| 200 | _SEG('8', 10,16, 10,32, 10,64, 10,128, 11,128, 11,64, 11,32 ), | ||
| 201 | _SEG('8', 8,16, 8,32, 8,64, 8,128, 9,128, 9,64, 9,32 ), | ||
| 202 | _SEG('8', 6,16, 6,32, 6,64, 6,128, 7,128, 7,64, 7,32 ), | ||
| 203 | _SEG('8', 4,16, 4,32, 4,64, 4,128, 5,128, 5,64, 5,32 ), | ||
| 204 | _SEG('8', 2,16, 2,32, 2,64, 2,128, 3,128, 3,64, 3,32 ), | ||
| 205 | _SEG('8', 0,16, 0,32, 0,64, 0,128, 1,128, 1,64, 1,32 ), | ||
| 206 | |||
| 207 | /* Line 4 | ||
| 208 | * | ||
| 209 | * The LED, DIALTONE and RINGTONE are implemented as icons and use the same | ||
| 210 | * sysfs interface. | ||
| 211 | */ | ||
| 212 | #define LCD_LINE4_OFFSET LCD_LINE3_OFFSET + LCD_LINE3_SIZE | ||
| 213 | |||
| 214 | _PIC('.', offsetof(struct yld_status, led) , 0x01, "LED" ), | ||
| 215 | _PIC('.', offsetof(struct yld_status, dialtone) , 0x01, "DIALTONE" ), | ||
| 216 | _PIC('.', offsetof(struct yld_status, ringtone) , 0x24, "RINGTONE" ), | ||
| 217 | |||
| 218 | #undef _SEG | ||
| 219 | #undef _PIC | ||
| 220 | #endif /* _SEG && _PIC */ | ||
