Stelian Pop | f7214ff | 2005-09-08 10:19:48 +0200 | [diff] [blame] | 1 | /* |
Nicolas Boichat | 9effa97 | 2006-04-19 23:36:40 +0200 | [diff] [blame] | 2 | * Apple USB Touchpad (for post-February 2005 PowerBooks and MacBooks) driver |
Stelian Pop | f7214ff | 2005-09-08 10:19:48 +0200 | [diff] [blame] | 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) |
Michael Hanselmann | e1e02c9 | 2005-12-21 00:50:23 -0500 | [diff] [blame] | 9 | * Copyright (C) 2005 Michael Hanselmann (linux-kernel@hansmi.ch) |
Nicolas Boichat | 9effa97 | 2006-04-19 23:36:40 +0200 | [diff] [blame] | 10 | * Copyright (C) 2006 Nicolas Boichat (nicolas@boichat.ch) |
Stelian Pop | f7214ff | 2005-09-08 10:19:48 +0200 | [diff] [blame] | 11 | * |
| 12 | * Thanks to Alex Harper <basilisk@foobox.net> for his inputs. |
| 13 | * |
| 14 | * This program is free software; you can redistribute it and/or modify |
| 15 | * it under the terms of the GNU General Public License as published by |
| 16 | * the Free Software Foundation; either version 2 of the License, or |
| 17 | * (at your option) any later version. |
| 18 | * |
| 19 | * This program is distributed in the hope that it will be useful, |
| 20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 22 | * GNU General Public License for more details. |
| 23 | * |
| 24 | * You should have received a copy of the GNU General Public License |
| 25 | * along with this program; if not, write to the Free Software |
| 26 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
| 27 | * |
| 28 | */ |
| 29 | |
Stelian Pop | f7214ff | 2005-09-08 10:19:48 +0200 | [diff] [blame] | 30 | #include <linux/kernel.h> |
| 31 | #include <linux/errno.h> |
| 32 | #include <linux/init.h> |
| 33 | #include <linux/slab.h> |
| 34 | #include <linux/module.h> |
David Brownell | ae0dadc | 2006-06-13 10:04:34 -0700 | [diff] [blame] | 35 | #include <linux/usb/input.h> |
Stelian Pop | f7214ff | 2005-09-08 10:19:48 +0200 | [diff] [blame] | 36 | |
| 37 | /* Apple has powerbooks which have the keyboard with different Product IDs */ |
| 38 | #define APPLE_VENDOR_ID 0x05AC |
| 39 | |
Michael Hanselmann | e1e02c9 | 2005-12-21 00:50:23 -0500 | [diff] [blame] | 40 | /* These names come from Info.plist in AppleUSBTrackpad.kext */ |
Julien BLACHE | e5d9832 | 2006-11-17 01:06:25 -0500 | [diff] [blame] | 41 | #define FOUNTAIN_ANSI_PRODUCT_ID 0x020E |
| 42 | #define FOUNTAIN_ISO_PRODUCT_ID 0x020F |
| 43 | |
| 44 | #define FOUNTAIN_TP_ONLY_PRODUCT_ID 0x030A |
| 45 | |
| 46 | #define GEYSER1_TP_ONLY_PRODUCT_ID 0x030B |
| 47 | |
| 48 | #define GEYSER_ANSI_PRODUCT_ID 0x0214 |
| 49 | #define GEYSER_ISO_PRODUCT_ID 0x0215 |
| 50 | #define GEYSER_JIS_PRODUCT_ID 0x0216 |
Michael Hanselmann | e1e02c9 | 2005-12-21 00:50:23 -0500 | [diff] [blame] | 51 | |
Nicolas Boichat | 9effa97 | 2006-04-19 23:36:40 +0200 | [diff] [blame] | 52 | /* MacBook devices */ |
Julien BLACHE | e5d9832 | 2006-11-17 01:06:25 -0500 | [diff] [blame] | 53 | #define GEYSER3_ANSI_PRODUCT_ID 0x0217 |
| 54 | #define GEYSER3_ISO_PRODUCT_ID 0x0218 |
| 55 | #define GEYSER3_JIS_PRODUCT_ID 0x0219 |
Nicolas Boichat | 9effa97 | 2006-04-19 23:36:40 +0200 | [diff] [blame] | 56 | |
Julien BLACHE | 009ad0e | 2006-11-17 01:06:13 -0500 | [diff] [blame] | 57 | /* |
| 58 | * Geyser IV: same as Geyser III according to Info.plist in AppleUSBTrackpad.kext |
| 59 | * -> same IOClass (AppleUSBGrIIITrackpad), same acceleration tables |
| 60 | */ |
| 61 | #define GEYSER4_ANSI_PRODUCT_ID 0x021A |
| 62 | #define GEYSER4_ISO_PRODUCT_ID 0x021B |
| 63 | #define GEYSER4_JIS_PRODUCT_ID 0x021C |
| 64 | |
Stelian Pop | f7214ff | 2005-09-08 10:19:48 +0200 | [diff] [blame] | 65 | #define ATP_DEVICE(prod) \ |
Dmitry Torokhov | c5b7c7c | 2005-09-15 02:01:47 -0500 | [diff] [blame] | 66 | .match_flags = USB_DEVICE_ID_MATCH_DEVICE | \ |
Stelian Pop | f7214ff | 2005-09-08 10:19:48 +0200 | [diff] [blame] | 67 | USB_DEVICE_ID_MATCH_INT_CLASS | \ |
| 68 | USB_DEVICE_ID_MATCH_INT_PROTOCOL, \ |
| 69 | .idVendor = APPLE_VENDOR_ID, \ |
| 70 | .idProduct = (prod), \ |
| 71 | .bInterfaceClass = 0x03, \ |
| 72 | .bInterfaceProtocol = 0x02 |
| 73 | |
| 74 | /* table of devices that work with this driver */ |
| 75 | static struct usb_device_id atp_table [] = { |
Julien BLACHE | e5d9832 | 2006-11-17 01:06:25 -0500 | [diff] [blame] | 76 | { ATP_DEVICE(FOUNTAIN_ANSI_PRODUCT_ID) }, |
| 77 | { ATP_DEVICE(FOUNTAIN_ISO_PRODUCT_ID) }, |
| 78 | { ATP_DEVICE(FOUNTAIN_TP_ONLY_PRODUCT_ID) }, |
| 79 | { ATP_DEVICE(GEYSER1_TP_ONLY_PRODUCT_ID) }, |
Michael Hanselmann | e1e02c9 | 2005-12-21 00:50:23 -0500 | [diff] [blame] | 80 | |
| 81 | /* PowerBooks Oct 2005 */ |
| 82 | { ATP_DEVICE(GEYSER_ANSI_PRODUCT_ID) }, |
| 83 | { ATP_DEVICE(GEYSER_ISO_PRODUCT_ID) }, |
| 84 | { ATP_DEVICE(GEYSER_JIS_PRODUCT_ID) }, |
| 85 | |
Julien BLACHE | 009ad0e | 2006-11-17 01:06:13 -0500 | [diff] [blame] | 86 | /* Core Duo MacBook & MacBook Pro */ |
Nicolas Boichat | 9effa97 | 2006-04-19 23:36:40 +0200 | [diff] [blame] | 87 | { ATP_DEVICE(GEYSER3_ANSI_PRODUCT_ID) }, |
| 88 | { ATP_DEVICE(GEYSER3_ISO_PRODUCT_ID) }, |
| 89 | { ATP_DEVICE(GEYSER3_JIS_PRODUCT_ID) }, |
| 90 | |
Julien BLACHE | 009ad0e | 2006-11-17 01:06:13 -0500 | [diff] [blame] | 91 | /* Core2 Duo MacBook & MacBook Pro */ |
| 92 | { ATP_DEVICE(GEYSER4_ANSI_PRODUCT_ID) }, |
| 93 | { ATP_DEVICE(GEYSER4_ISO_PRODUCT_ID) }, |
| 94 | { ATP_DEVICE(GEYSER4_JIS_PRODUCT_ID) }, |
| 95 | |
Michael Hanselmann | e1e02c9 | 2005-12-21 00:50:23 -0500 | [diff] [blame] | 96 | /* Terminating entry */ |
| 97 | { } |
Stelian Pop | f7214ff | 2005-09-08 10:19:48 +0200 | [diff] [blame] | 98 | }; |
| 99 | MODULE_DEVICE_TABLE (usb, atp_table); |
| 100 | |
Stelian Pop | f7214ff | 2005-09-08 10:19:48 +0200 | [diff] [blame] | 101 | /* |
| 102 | * number of sensors. Note that only 16 instead of 26 X (horizontal) |
| 103 | * sensors exist on 12" and 15" PowerBooks. All models have 16 Y |
| 104 | * (vertical) sensors. |
| 105 | */ |
| 106 | #define ATP_XSENSORS 26 |
| 107 | #define ATP_YSENSORS 16 |
| 108 | |
| 109 | /* amount of fuzz this touchpad generates */ |
| 110 | #define ATP_FUZZ 16 |
| 111 | |
| 112 | /* maximum pressure this driver will report */ |
| 113 | #define ATP_PRESSURE 300 |
| 114 | /* |
| 115 | * multiplication factor for the X and Y coordinates. |
| 116 | * We try to keep the touchpad aspect ratio while still doing only simple |
| 117 | * arithmetics. |
| 118 | * The factors below give coordinates like: |
Dmitry Torokhov | c5b7c7c | 2005-09-15 02:01:47 -0500 | [diff] [blame] | 119 | * 0 <= x < 960 on 12" and 15" Powerbooks |
| 120 | * 0 <= x < 1600 on 17" Powerbooks |
| 121 | * 0 <= y < 646 |
Stelian Pop | f7214ff | 2005-09-08 10:19:48 +0200 | [diff] [blame] | 122 | */ |
| 123 | #define ATP_XFACT 64 |
| 124 | #define ATP_YFACT 43 |
| 125 | |
| 126 | /* |
| 127 | * Threshold for the touchpad sensors. Any change less than ATP_THRESHOLD is |
| 128 | * ignored. |
| 129 | */ |
| 130 | #define ATP_THRESHOLD 5 |
| 131 | |
Julien BLACHE | 009ad0e | 2006-11-17 01:06:13 -0500 | [diff] [blame] | 132 | /* MacBook Pro (Geyser 3 & 4) initialization constants */ |
Nicolas Boichat | 9effa97 | 2006-04-19 23:36:40 +0200 | [diff] [blame] | 133 | #define ATP_GEYSER3_MODE_READ_REQUEST_ID 1 |
| 134 | #define ATP_GEYSER3_MODE_WRITE_REQUEST_ID 9 |
| 135 | #define ATP_GEYSER3_MODE_REQUEST_VALUE 0x300 |
| 136 | #define ATP_GEYSER3_MODE_REQUEST_INDEX 0 |
| 137 | #define ATP_GEYSER3_MODE_VENDOR_VALUE 0x04 |
| 138 | |
Stelian Pop | f7214ff | 2005-09-08 10:19:48 +0200 | [diff] [blame] | 139 | /* Structure to hold all of our device specific stuff */ |
| 140 | struct atp { |
Dmitry Torokhov | c5b7c7c | 2005-09-15 02:01:47 -0500 | [diff] [blame] | 141 | char phys[64]; |
Stelian Pop | f7214ff | 2005-09-08 10:19:48 +0200 | [diff] [blame] | 142 | struct usb_device * udev; /* usb device */ |
| 143 | struct urb * urb; /* usb request block */ |
| 144 | signed char * data; /* transferred data */ |
| 145 | int open; /* non-zero if opened */ |
Dmitry Torokhov | c5b7c7c | 2005-09-15 02:01:47 -0500 | [diff] [blame] | 146 | struct input_dev *input; /* input dev */ |
Stelian Pop | f7214ff | 2005-09-08 10:19:48 +0200 | [diff] [blame] | 147 | int valid; /* are the sensors valid ? */ |
| 148 | int x_old; /* last reported x/y, */ |
| 149 | int y_old; /* used for smoothing */ |
| 150 | /* current value of the sensors */ |
| 151 | signed char xy_cur[ATP_XSENSORS + ATP_YSENSORS]; |
| 152 | /* last value of the sensors */ |
| 153 | signed char xy_old[ATP_XSENSORS + ATP_YSENSORS]; |
| 154 | /* accumulated sensors */ |
| 155 | int xy_acc[ATP_XSENSORS + ATP_YSENSORS]; |
Michael Hanselmann | e1e02c9 | 2005-12-21 00:50:23 -0500 | [diff] [blame] | 156 | int overflowwarn; /* overflow warning printed? */ |
| 157 | int datalen; /* size of an USB urb transfer */ |
Stelian Pop | f7214ff | 2005-09-08 10:19:48 +0200 | [diff] [blame] | 158 | }; |
| 159 | |
| 160 | #define dbg_dump(msg, tab) \ |
| 161 | if (debug > 1) { \ |
| 162 | int i; \ |
| 163 | printk("appletouch: %s %lld", msg, (long long)jiffies); \ |
| 164 | for (i = 0; i < ATP_XSENSORS + ATP_YSENSORS; i++) \ |
Dmitry Torokhov | c5b7c7c | 2005-09-15 02:01:47 -0500 | [diff] [blame] | 165 | printk(" %02x", tab[i]); \ |
| 166 | printk("\n"); \ |
Stelian Pop | f7214ff | 2005-09-08 10:19:48 +0200 | [diff] [blame] | 167 | } |
| 168 | |
Dmitry Torokhov | c5b7c7c | 2005-09-15 02:01:47 -0500 | [diff] [blame] | 169 | #define dprintk(format, a...) \ |
Stelian Pop | f7214ff | 2005-09-08 10:19:48 +0200 | [diff] [blame] | 170 | do { \ |
| 171 | if (debug) printk(format, ##a); \ |
| 172 | } while (0) |
| 173 | |
Michael Hanselmann | e1e02c9 | 2005-12-21 00:50:23 -0500 | [diff] [blame] | 174 | MODULE_AUTHOR("Johannes Berg, Stelian Pop, Frank Arnold, Michael Hanselmann"); |
Stelian Pop | f7214ff | 2005-09-08 10:19:48 +0200 | [diff] [blame] | 175 | MODULE_DESCRIPTION("Apple PowerBooks USB touchpad driver"); |
| 176 | MODULE_LICENSE("GPL"); |
| 177 | |
Jason Parekh | 00081d3 | 2006-11-17 01:05:58 -0500 | [diff] [blame] | 178 | /* |
| 179 | * Make the threshold a module parameter |
| 180 | */ |
| 181 | static int threshold = ATP_THRESHOLD; |
| 182 | module_param(threshold, int, 0644); |
| 183 | MODULE_PARM_DESC(threshold, "Discards any change in data from a sensor (trackpad has hundreds of these sensors) less than this value"); |
| 184 | |
Stelian Pop | f7214ff | 2005-09-08 10:19:48 +0200 | [diff] [blame] | 185 | static int debug = 1; |
| 186 | module_param(debug, int, 0644); |
| 187 | MODULE_PARM_DESC(debug, "Activate debugging output"); |
| 188 | |
Michael Hanselmann | e1e02c9 | 2005-12-21 00:50:23 -0500 | [diff] [blame] | 189 | /* Checks if the device a Geyser 2 (ANSI, ISO, JIS) */ |
| 190 | static inline int atp_is_geyser_2(struct atp *dev) |
| 191 | { |
Nicolas Boichat | 9effa97 | 2006-04-19 23:36:40 +0200 | [diff] [blame] | 192 | u16 productId = le16_to_cpu(dev->udev->descriptor.idProduct); |
Michael Hanselmann | e1e02c9 | 2005-12-21 00:50:23 -0500 | [diff] [blame] | 193 | |
| 194 | return (productId == GEYSER_ANSI_PRODUCT_ID) || |
| 195 | (productId == GEYSER_ISO_PRODUCT_ID) || |
| 196 | (productId == GEYSER_JIS_PRODUCT_ID); |
| 197 | } |
| 198 | |
Nicolas Boichat | 9effa97 | 2006-04-19 23:36:40 +0200 | [diff] [blame] | 199 | static inline int atp_is_geyser_3(struct atp *dev) |
| 200 | { |
| 201 | u16 productId = le16_to_cpu(dev->udev->descriptor.idProduct); |
| 202 | |
| 203 | return (productId == GEYSER3_ANSI_PRODUCT_ID) || |
| 204 | (productId == GEYSER3_ISO_PRODUCT_ID) || |
Julien BLACHE | 009ad0e | 2006-11-17 01:06:13 -0500 | [diff] [blame] | 205 | (productId == GEYSER3_JIS_PRODUCT_ID) || |
| 206 | (productId == GEYSER4_ANSI_PRODUCT_ID) || |
| 207 | (productId == GEYSER4_ISO_PRODUCT_ID) || |
| 208 | (productId == GEYSER4_JIS_PRODUCT_ID); |
Nicolas Boichat | 9effa97 | 2006-04-19 23:36:40 +0200 | [diff] [blame] | 209 | } |
| 210 | |
Stelian Pop | f7214ff | 2005-09-08 10:19:48 +0200 | [diff] [blame] | 211 | static int atp_calculate_abs(int *xy_sensors, int nb_sensors, int fact, |
| 212 | int *z, int *fingers) |
| 213 | { |
| 214 | int i; |
| 215 | /* values to calculate mean */ |
| 216 | int pcum = 0, psum = 0; |
Jason Parekh | 00081d3 | 2006-11-17 01:05:58 -0500 | [diff] [blame] | 217 | int is_increasing = 0; |
Stelian Pop | f7214ff | 2005-09-08 10:19:48 +0200 | [diff] [blame] | 218 | |
| 219 | *fingers = 0; |
| 220 | |
| 221 | for (i = 0; i < nb_sensors; i++) { |
Jason Parekh | 00081d3 | 2006-11-17 01:05:58 -0500 | [diff] [blame] | 222 | if (xy_sensors[i] < threshold) { |
| 223 | if (is_increasing) |
| 224 | is_increasing = 0; |
| 225 | |
Stelian Pop | f7214ff | 2005-09-08 10:19:48 +0200 | [diff] [blame] | 226 | continue; |
Jason Parekh | 00081d3 | 2006-11-17 01:05:58 -0500 | [diff] [blame] | 227 | } |
| 228 | |
| 229 | /* |
| 230 | * Makes the finger detection more versatile. For example, |
| 231 | * two fingers with no gap will be detected. Also, my |
| 232 | * tests show it less likely to have intermittent loss |
| 233 | * of multiple finger readings while moving around (scrolling). |
| 234 | * |
| 235 | * Changes the multiple finger detection to counting humps on |
| 236 | * sensors (transitions from nonincreasing to increasing) |
| 237 | * instead of counting transitions from low sensors (no |
| 238 | * finger reading) to high sensors (finger above |
| 239 | * sensor) |
| 240 | * |
| 241 | * - Jason Parekh <jasonparekh@gmail.com> |
| 242 | */ |
| 243 | if (i < 1 || (!is_increasing && xy_sensors[i - 1] < xy_sensors[i])) { |
Stelian Pop | f7214ff | 2005-09-08 10:19:48 +0200 | [diff] [blame] | 244 | (*fingers)++; |
Jason Parekh | 00081d3 | 2006-11-17 01:05:58 -0500 | [diff] [blame] | 245 | is_increasing = 1; |
| 246 | } else if (i > 0 && xy_sensors[i - 1] >= xy_sensors[i]) { |
| 247 | is_increasing = 0; |
| 248 | } |
| 249 | |
| 250 | /* |
| 251 | * Subtracts threshold so a high sensor that just passes the threshold |
| 252 | * won't skew the calculated absolute coordinate. Fixes an issue |
| 253 | * where slowly moving the mouse would occassionaly jump a number of |
| 254 | * pixels (let me restate--slowly moving the mouse makes this issue |
| 255 | * most apparent). |
| 256 | */ |
| 257 | pcum += (xy_sensors[i] - threshold) * i; |
| 258 | psum += (xy_sensors[i] - threshold); |
Stelian Pop | f7214ff | 2005-09-08 10:19:48 +0200 | [diff] [blame] | 259 | } |
| 260 | |
| 261 | if (psum > 0) { |
| 262 | *z = psum; |
| 263 | return pcum * fact / psum; |
| 264 | } |
| 265 | |
| 266 | return 0; |
| 267 | } |
| 268 | |
| 269 | static inline void atp_report_fingers(struct input_dev *input, int fingers) |
| 270 | { |
| 271 | input_report_key(input, BTN_TOOL_FINGER, fingers == 1); |
| 272 | input_report_key(input, BTN_TOOL_DOUBLETAP, fingers == 2); |
| 273 | input_report_key(input, BTN_TOOL_TRIPLETAP, fingers > 2); |
| 274 | } |
| 275 | |
David Howells | 7d12e78 | 2006-10-05 14:55:46 +0100 | [diff] [blame] | 276 | static void atp_complete(struct urb* urb) |
Stelian Pop | f7214ff | 2005-09-08 10:19:48 +0200 | [diff] [blame] | 277 | { |
| 278 | int x, y, x_z, y_z, x_f, y_f; |
Michael Hanselmann | e1e02c9 | 2005-12-21 00:50:23 -0500 | [diff] [blame] | 279 | int retval, i, j; |
Stelian Pop | f7214ff | 2005-09-08 10:19:48 +0200 | [diff] [blame] | 280 | struct atp *dev = urb->context; |
| 281 | |
| 282 | switch (urb->status) { |
| 283 | case 0: |
| 284 | /* success */ |
| 285 | break; |
Michael Hanselmann | e1e02c9 | 2005-12-21 00:50:23 -0500 | [diff] [blame] | 286 | case -EOVERFLOW: |
| 287 | if(!dev->overflowwarn) { |
| 288 | printk("appletouch: OVERFLOW with data " |
| 289 | "length %d, actual length is %d\n", |
| 290 | dev->datalen, dev->urb->actual_length); |
| 291 | dev->overflowwarn = 1; |
| 292 | } |
Stelian Pop | f7214ff | 2005-09-08 10:19:48 +0200 | [diff] [blame] | 293 | case -ECONNRESET: |
| 294 | case -ENOENT: |
| 295 | case -ESHUTDOWN: |
| 296 | /* This urb is terminated, clean up */ |
| 297 | dbg("%s - urb shutting down with status: %d", |
| 298 | __FUNCTION__, urb->status); |
| 299 | return; |
| 300 | default: |
| 301 | dbg("%s - nonzero urb status received: %d", |
| 302 | __FUNCTION__, urb->status); |
| 303 | goto exit; |
| 304 | } |
| 305 | |
| 306 | /* drop incomplete datasets */ |
Michael Hanselmann | e1e02c9 | 2005-12-21 00:50:23 -0500 | [diff] [blame] | 307 | if (dev->urb->actual_length != dev->datalen) { |
Nicolas Boichat | 9effa97 | 2006-04-19 23:36:40 +0200 | [diff] [blame] | 308 | dprintk("appletouch: incomplete data package" |
| 309 | " (first byte: %d, length: %d).\n", |
| 310 | dev->data[0], dev->urb->actual_length); |
Stelian Pop | f7214ff | 2005-09-08 10:19:48 +0200 | [diff] [blame] | 311 | goto exit; |
| 312 | } |
| 313 | |
| 314 | /* reorder the sensors values */ |
Nicolas Boichat | 9effa97 | 2006-04-19 23:36:40 +0200 | [diff] [blame] | 315 | if (atp_is_geyser_3(dev)) { |
| 316 | memset(dev->xy_cur, 0, sizeof(dev->xy_cur)); |
| 317 | |
| 318 | /* |
| 319 | * The values are laid out like this: |
| 320 | * -, Y1, Y2, -, Y3, Y4, -, ..., -, X1, X2, -, X3, X4, ... |
| 321 | * '-' is an unused value. |
| 322 | */ |
| 323 | |
| 324 | /* read X values */ |
| 325 | for (i = 0, j = 19; i < 20; i += 2, j += 3) { |
| 326 | dev->xy_cur[i] = dev->data[j + 1]; |
| 327 | dev->xy_cur[i + 1] = dev->data[j + 2]; |
| 328 | } |
| 329 | /* read Y values */ |
| 330 | for (i = 0, j = 1; i < 9; i += 2, j += 3) { |
| 331 | dev->xy_cur[ATP_XSENSORS + i] = dev->data[j + 1]; |
| 332 | dev->xy_cur[ATP_XSENSORS + i + 1] = dev->data[j + 2]; |
| 333 | } |
| 334 | } else if (atp_is_geyser_2(dev)) { |
Michael Hanselmann | e1e02c9 | 2005-12-21 00:50:23 -0500 | [diff] [blame] | 335 | memset(dev->xy_cur, 0, sizeof(dev->xy_cur)); |
Stelian Pop | f7214ff | 2005-09-08 10:19:48 +0200 | [diff] [blame] | 336 | |
Michael Hanselmann | e1e02c9 | 2005-12-21 00:50:23 -0500 | [diff] [blame] | 337 | /* |
| 338 | * The values are laid out like this: |
| 339 | * Y1, Y2, -, Y3, Y4, -, ..., X1, X2, -, X3, X4, -, ... |
| 340 | * '-' is an unused value. |
| 341 | */ |
| 342 | |
| 343 | /* read X values */ |
| 344 | for (i = 0, j = 19; i < 20; i += 2, j += 3) { |
| 345 | dev->xy_cur[i] = dev->data[j]; |
| 346 | dev->xy_cur[i + 1] = dev->data[j + 1]; |
| 347 | } |
| 348 | |
| 349 | /* read Y values */ |
| 350 | for (i = 0, j = 1; i < 9; i += 2, j += 3) { |
| 351 | dev->xy_cur[ATP_XSENSORS + i] = dev->data[j]; |
| 352 | dev->xy_cur[ATP_XSENSORS + i + 1] = dev->data[j + 1]; |
| 353 | } |
| 354 | } else { |
| 355 | for (i = 0; i < 8; i++) { |
| 356 | /* X values */ |
| 357 | dev->xy_cur[i ] = dev->data[5 * i + 2]; |
| 358 | dev->xy_cur[i + 8] = dev->data[5 * i + 4]; |
| 359 | dev->xy_cur[i + 16] = dev->data[5 * i + 42]; |
| 360 | if (i < 2) |
| 361 | dev->xy_cur[i + 24] = dev->data[5 * i + 44]; |
| 362 | |
| 363 | /* Y values */ |
| 364 | dev->xy_cur[i + 26] = dev->data[5 * i + 1]; |
| 365 | dev->xy_cur[i + 34] = dev->data[5 * i + 3]; |
| 366 | } |
Stelian Pop | f7214ff | 2005-09-08 10:19:48 +0200 | [diff] [blame] | 367 | } |
| 368 | |
| 369 | dbg_dump("sample", dev->xy_cur); |
| 370 | |
| 371 | if (!dev->valid) { |
| 372 | /* first sample */ |
| 373 | dev->valid = 1; |
| 374 | dev->x_old = dev->y_old = -1; |
| 375 | memcpy(dev->xy_old, dev->xy_cur, sizeof(dev->xy_old)); |
| 376 | |
Nicolas Boichat | 9effa97 | 2006-04-19 23:36:40 +0200 | [diff] [blame] | 377 | if (atp_is_geyser_3(dev)) /* No 17" Macbooks (yet) */ |
| 378 | goto exit; |
| 379 | |
Michael Hanselmann | e1e02c9 | 2005-12-21 00:50:23 -0500 | [diff] [blame] | 380 | /* 17" Powerbooks have extra X sensors */ |
| 381 | for (i = (atp_is_geyser_2(dev)?15:16); i < ATP_XSENSORS; i++) { |
| 382 | if (!dev->xy_cur[i]) continue; |
| 383 | |
| 384 | printk("appletouch: 17\" model detected.\n"); |
| 385 | if(atp_is_geyser_2(dev)) |
| 386 | input_set_abs_params(dev->input, ABS_X, 0, |
| 387 | (20 - 1) * |
| 388 | ATP_XFACT - 1, |
| 389 | ATP_FUZZ, 0); |
| 390 | else |
Dmitry Torokhov | c5b7c7c | 2005-09-15 02:01:47 -0500 | [diff] [blame] | 391 | input_set_abs_params(dev->input, ABS_X, 0, |
| 392 | (ATP_XSENSORS - 1) * |
Stelian Pop | f7214ff | 2005-09-08 10:19:48 +0200 | [diff] [blame] | 393 | ATP_XFACT - 1, |
| 394 | ATP_FUZZ, 0); |
Michael Hanselmann | e1e02c9 | 2005-12-21 00:50:23 -0500 | [diff] [blame] | 395 | |
| 396 | break; |
| 397 | } |
Stelian Pop | f7214ff | 2005-09-08 10:19:48 +0200 | [diff] [blame] | 398 | |
| 399 | goto exit; |
| 400 | } |
| 401 | |
| 402 | for (i = 0; i < ATP_XSENSORS + ATP_YSENSORS; i++) { |
| 403 | /* accumulate the change */ |
| 404 | signed char change = dev->xy_old[i] - dev->xy_cur[i]; |
| 405 | dev->xy_acc[i] -= change; |
| 406 | |
| 407 | /* prevent down drifting */ |
| 408 | if (dev->xy_acc[i] < 0) |
| 409 | dev->xy_acc[i] = 0; |
| 410 | } |
| 411 | |
| 412 | memcpy(dev->xy_old, dev->xy_cur, sizeof(dev->xy_old)); |
| 413 | |
| 414 | dbg_dump("accumulator", dev->xy_acc); |
| 415 | |
| 416 | x = atp_calculate_abs(dev->xy_acc, ATP_XSENSORS, |
| 417 | ATP_XFACT, &x_z, &x_f); |
| 418 | y = atp_calculate_abs(dev->xy_acc + ATP_XSENSORS, ATP_YSENSORS, |
| 419 | ATP_YFACT, &y_z, &y_f); |
| 420 | |
| 421 | if (x && y) { |
| 422 | if (dev->x_old != -1) { |
| 423 | x = (dev->x_old * 3 + x) >> 2; |
| 424 | y = (dev->y_old * 3 + y) >> 2; |
| 425 | dev->x_old = x; |
| 426 | dev->y_old = y; |
| 427 | |
| 428 | if (debug > 1) |
| 429 | printk("appletouch: X: %3d Y: %3d " |
| 430 | "Xz: %3d Yz: %3d\n", |
| 431 | x, y, x_z, y_z); |
| 432 | |
Dmitry Torokhov | c5b7c7c | 2005-09-15 02:01:47 -0500 | [diff] [blame] | 433 | input_report_key(dev->input, BTN_TOUCH, 1); |
| 434 | input_report_abs(dev->input, ABS_X, x); |
| 435 | input_report_abs(dev->input, ABS_Y, y); |
| 436 | input_report_abs(dev->input, ABS_PRESSURE, |
Stelian Pop | f7214ff | 2005-09-08 10:19:48 +0200 | [diff] [blame] | 437 | min(ATP_PRESSURE, x_z + y_z)); |
Dmitry Torokhov | c5b7c7c | 2005-09-15 02:01:47 -0500 | [diff] [blame] | 438 | atp_report_fingers(dev->input, max(x_f, y_f)); |
Stelian Pop | f7214ff | 2005-09-08 10:19:48 +0200 | [diff] [blame] | 439 | } |
| 440 | dev->x_old = x; |
| 441 | dev->y_old = y; |
| 442 | } |
| 443 | else if (!x && !y) { |
| 444 | |
| 445 | dev->x_old = dev->y_old = -1; |
Dmitry Torokhov | c5b7c7c | 2005-09-15 02:01:47 -0500 | [diff] [blame] | 446 | input_report_key(dev->input, BTN_TOUCH, 0); |
| 447 | input_report_abs(dev->input, ABS_PRESSURE, 0); |
| 448 | atp_report_fingers(dev->input, 0); |
Stelian Pop | f7214ff | 2005-09-08 10:19:48 +0200 | [diff] [blame] | 449 | |
| 450 | /* reset the accumulator on release */ |
| 451 | memset(dev->xy_acc, 0, sizeof(dev->xy_acc)); |
| 452 | } |
| 453 | |
Michael Hanselmann | e1e02c9 | 2005-12-21 00:50:23 -0500 | [diff] [blame] | 454 | input_report_key(dev->input, BTN_LEFT, |
| 455 | !!dev->data[dev->datalen - 1]); |
Stelian Pop | f7214ff | 2005-09-08 10:19:48 +0200 | [diff] [blame] | 456 | |
Dmitry Torokhov | c5b7c7c | 2005-09-15 02:01:47 -0500 | [diff] [blame] | 457 | input_sync(dev->input); |
Stelian Pop | f7214ff | 2005-09-08 10:19:48 +0200 | [diff] [blame] | 458 | |
| 459 | exit: |
| 460 | retval = usb_submit_urb(dev->urb, GFP_ATOMIC); |
| 461 | if (retval) { |
| 462 | err("%s - usb_submit_urb failed with result %d", |
| 463 | __FUNCTION__, retval); |
| 464 | } |
| 465 | } |
| 466 | |
| 467 | static int atp_open(struct input_dev *input) |
| 468 | { |
| 469 | struct atp *dev = input->private; |
| 470 | |
| 471 | if (usb_submit_urb(dev->urb, GFP_ATOMIC)) |
| 472 | return -EIO; |
| 473 | |
| 474 | dev->open = 1; |
| 475 | return 0; |
| 476 | } |
| 477 | |
| 478 | static void atp_close(struct input_dev *input) |
| 479 | { |
| 480 | struct atp *dev = input->private; |
| 481 | |
| 482 | usb_kill_urb(dev->urb); |
| 483 | dev->open = 0; |
| 484 | } |
| 485 | |
| 486 | static int atp_probe(struct usb_interface *iface, const struct usb_device_id *id) |
| 487 | { |
Dmitry Torokhov | c5b7c7c | 2005-09-15 02:01:47 -0500 | [diff] [blame] | 488 | struct atp *dev; |
| 489 | struct input_dev *input_dev; |
| 490 | struct usb_device *udev = interface_to_usbdev(iface); |
Stelian Pop | f7214ff | 2005-09-08 10:19:48 +0200 | [diff] [blame] | 491 | struct usb_host_interface *iface_desc; |
| 492 | struct usb_endpoint_descriptor *endpoint; |
| 493 | int int_in_endpointAddr = 0; |
| 494 | int i, retval = -ENOMEM; |
| 495 | |
Stelian Pop | f7214ff | 2005-09-08 10:19:48 +0200 | [diff] [blame] | 496 | |
| 497 | /* set up the endpoint information */ |
| 498 | /* use only the first interrupt-in endpoint */ |
| 499 | iface_desc = iface->cur_altsetting; |
| 500 | for (i = 0; i < iface_desc->desc.bNumEndpoints; i++) { |
| 501 | endpoint = &iface_desc->endpoint[i].desc; |
Luiz Fernando N. Capitulino | 97b107c | 2006-09-27 11:58:53 -0700 | [diff] [blame] | 502 | if (!int_in_endpointAddr && usb_endpoint_is_int_in(endpoint)) { |
Stelian Pop | f7214ff | 2005-09-08 10:19:48 +0200 | [diff] [blame] | 503 | /* we found an interrupt in endpoint */ |
| 504 | int_in_endpointAddr = endpoint->bEndpointAddress; |
| 505 | break; |
| 506 | } |
| 507 | } |
| 508 | if (!int_in_endpointAddr) { |
Stelian Pop | f7214ff | 2005-09-08 10:19:48 +0200 | [diff] [blame] | 509 | err("Could not find int-in endpoint"); |
Dmitry Torokhov | c5b7c7c | 2005-09-15 02:01:47 -0500 | [diff] [blame] | 510 | return -EIO; |
Stelian Pop | f7214ff | 2005-09-08 10:19:48 +0200 | [diff] [blame] | 511 | } |
| 512 | |
Dmitry Torokhov | c5b7c7c | 2005-09-15 02:01:47 -0500 | [diff] [blame] | 513 | /* allocate memory for our device state and initialize it */ |
| 514 | dev = kzalloc(sizeof(struct atp), GFP_KERNEL); |
| 515 | input_dev = input_allocate_device(); |
| 516 | if (!dev || !input_dev) { |
| 517 | err("Out of memory"); |
| 518 | goto err_free_devs; |
| 519 | } |
| 520 | |
| 521 | dev->udev = udev; |
| 522 | dev->input = input_dev; |
Michael Hanselmann | e1e02c9 | 2005-12-21 00:50:23 -0500 | [diff] [blame] | 523 | dev->overflowwarn = 0; |
Nicolas Boichat | 9effa97 | 2006-04-19 23:36:40 +0200 | [diff] [blame] | 524 | if (atp_is_geyser_3(dev)) |
| 525 | dev->datalen = 64; |
| 526 | else if (atp_is_geyser_2(dev)) |
| 527 | dev->datalen = 64; |
| 528 | else |
| 529 | dev->datalen = 81; |
| 530 | |
| 531 | if (atp_is_geyser_3(dev)) { |
| 532 | /* |
| 533 | * By default Geyser 3 device sends standard USB HID mouse |
| 534 | * packets (Report ID 2). This code changes device mode, so it |
| 535 | * sends raw sensor reports (Report ID 5). |
| 536 | */ |
| 537 | char data[8]; |
| 538 | int size; |
| 539 | |
| 540 | size = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), |
| 541 | ATP_GEYSER3_MODE_READ_REQUEST_ID, |
| 542 | USB_DIR_IN | USB_TYPE_CLASS | USB_RECIP_INTERFACE, |
| 543 | ATP_GEYSER3_MODE_REQUEST_VALUE, |
| 544 | ATP_GEYSER3_MODE_REQUEST_INDEX, &data, 8, 5000); |
| 545 | |
| 546 | if (size != 8) { |
| 547 | err("Could not do mode read request from device" |
| 548 | " (Geyser 3 mode)"); |
| 549 | goto err_free_devs; |
| 550 | } |
| 551 | |
| 552 | /* Apply the mode switch */ |
| 553 | data[0] = ATP_GEYSER3_MODE_VENDOR_VALUE; |
| 554 | |
| 555 | size = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), |
| 556 | ATP_GEYSER3_MODE_WRITE_REQUEST_ID, |
| 557 | USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_INTERFACE, |
| 558 | ATP_GEYSER3_MODE_REQUEST_VALUE, |
| 559 | ATP_GEYSER3_MODE_REQUEST_INDEX, &data, 8, 5000); |
| 560 | |
| 561 | if (size != 8) { |
| 562 | err("Could not do mode write request to device" |
| 563 | " (Geyser 3 mode)"); |
| 564 | goto err_free_devs; |
| 565 | } |
| 566 | printk("appletouch Geyser 3 inited.\n"); |
| 567 | } |
Stelian Pop | f7214ff | 2005-09-08 10:19:48 +0200 | [diff] [blame] | 568 | |
| 569 | dev->urb = usb_alloc_urb(0, GFP_KERNEL); |
| 570 | if (!dev->urb) { |
| 571 | retval = -ENOMEM; |
Dmitry Torokhov | c5b7c7c | 2005-09-15 02:01:47 -0500 | [diff] [blame] | 572 | goto err_free_devs; |
Stelian Pop | f7214ff | 2005-09-08 10:19:48 +0200 | [diff] [blame] | 573 | } |
Dmitry Torokhov | c5b7c7c | 2005-09-15 02:01:47 -0500 | [diff] [blame] | 574 | |
Michael Hanselmann | e1e02c9 | 2005-12-21 00:50:23 -0500 | [diff] [blame] | 575 | dev->data = usb_buffer_alloc(dev->udev, dev->datalen, GFP_KERNEL, |
Stelian Pop | f7214ff | 2005-09-08 10:19:48 +0200 | [diff] [blame] | 576 | &dev->urb->transfer_dma); |
| 577 | if (!dev->data) { |
| 578 | retval = -ENOMEM; |
Dmitry Torokhov | c5b7c7c | 2005-09-15 02:01:47 -0500 | [diff] [blame] | 579 | goto err_free_urb; |
Stelian Pop | f7214ff | 2005-09-08 10:19:48 +0200 | [diff] [blame] | 580 | } |
Dmitry Torokhov | c5b7c7c | 2005-09-15 02:01:47 -0500 | [diff] [blame] | 581 | |
| 582 | usb_fill_int_urb(dev->urb, udev, |
| 583 | usb_rcvintpipe(udev, int_in_endpointAddr), |
Michael Hanselmann | e1e02c9 | 2005-12-21 00:50:23 -0500 | [diff] [blame] | 584 | dev->data, dev->datalen, atp_complete, dev, 1); |
Stelian Pop | f7214ff | 2005-09-08 10:19:48 +0200 | [diff] [blame] | 585 | |
Dmitry Torokhov | c5b7c7c | 2005-09-15 02:01:47 -0500 | [diff] [blame] | 586 | usb_make_path(udev, dev->phys, sizeof(dev->phys)); |
| 587 | strlcat(dev->phys, "/input0", sizeof(dev->phys)); |
Stelian Pop | f7214ff | 2005-09-08 10:19:48 +0200 | [diff] [blame] | 588 | |
Dmitry Torokhov | c5b7c7c | 2005-09-15 02:01:47 -0500 | [diff] [blame] | 589 | input_dev->name = "appletouch"; |
| 590 | input_dev->phys = dev->phys; |
| 591 | usb_to_input_id(dev->udev, &input_dev->id); |
| 592 | input_dev->cdev.dev = &iface->dev; |
Stelian Pop | f7214ff | 2005-09-08 10:19:48 +0200 | [diff] [blame] | 593 | |
Dmitry Torokhov | c5b7c7c | 2005-09-15 02:01:47 -0500 | [diff] [blame] | 594 | input_dev->private = dev; |
| 595 | input_dev->open = atp_open; |
| 596 | input_dev->close = atp_close; |
| 597 | |
| 598 | set_bit(EV_ABS, input_dev->evbit); |
Stelian Pop | f7214ff | 2005-09-08 10:19:48 +0200 | [diff] [blame] | 599 | |
Nicolas Boichat | 9effa97 | 2006-04-19 23:36:40 +0200 | [diff] [blame] | 600 | if (atp_is_geyser_3(dev)) { |
| 601 | /* |
| 602 | * MacBook have 20 X sensors, 10 Y sensors |
| 603 | */ |
| 604 | input_set_abs_params(input_dev, ABS_X, 0, |
| 605 | ((20 - 1) * ATP_XFACT) - 1, ATP_FUZZ, 0); |
| 606 | input_set_abs_params(input_dev, ABS_Y, 0, |
| 607 | ((10 - 1) * ATP_YFACT) - 1, ATP_FUZZ, 0); |
| 608 | } else if (atp_is_geyser_2(dev)) { |
Michael Hanselmann | e1e02c9 | 2005-12-21 00:50:23 -0500 | [diff] [blame] | 609 | /* |
| 610 | * Oct 2005 15" PowerBooks have 15 X sensors, 17" are detected |
| 611 | * later. |
| 612 | */ |
| 613 | input_set_abs_params(input_dev, ABS_X, 0, |
| 614 | ((15 - 1) * ATP_XFACT) - 1, ATP_FUZZ, 0); |
| 615 | input_set_abs_params(input_dev, ABS_Y, 0, |
| 616 | ((9 - 1) * ATP_YFACT) - 1, ATP_FUZZ, 0); |
| 617 | } else { |
| 618 | /* |
| 619 | * 12" and 15" Powerbooks only have 16 x sensors, |
| 620 | * 17" models are detected later. |
| 621 | */ |
| 622 | input_set_abs_params(input_dev, ABS_X, 0, |
| 623 | (16 - 1) * ATP_XFACT - 1, ATP_FUZZ, 0); |
| 624 | input_set_abs_params(input_dev, ABS_Y, 0, |
| 625 | (ATP_YSENSORS - 1) * ATP_YFACT - 1, ATP_FUZZ, 0); |
| 626 | } |
Dmitry Torokhov | c5b7c7c | 2005-09-15 02:01:47 -0500 | [diff] [blame] | 627 | input_set_abs_params(input_dev, ABS_PRESSURE, 0, ATP_PRESSURE, 0, 0); |
Stelian Pop | f7214ff | 2005-09-08 10:19:48 +0200 | [diff] [blame] | 628 | |
Dmitry Torokhov | c5b7c7c | 2005-09-15 02:01:47 -0500 | [diff] [blame] | 629 | set_bit(EV_KEY, input_dev->evbit); |
| 630 | set_bit(BTN_TOUCH, input_dev->keybit); |
| 631 | set_bit(BTN_TOOL_FINGER, input_dev->keybit); |
| 632 | set_bit(BTN_TOOL_DOUBLETAP, input_dev->keybit); |
| 633 | set_bit(BTN_TOOL_TRIPLETAP, input_dev->keybit); |
| 634 | set_bit(BTN_LEFT, input_dev->keybit); |
Stelian Pop | f7214ff | 2005-09-08 10:19:48 +0200 | [diff] [blame] | 635 | |
Dmitry Torokhov | c5b7c7c | 2005-09-15 02:01:47 -0500 | [diff] [blame] | 636 | input_register_device(dev->input); |
Stelian Pop | f7214ff | 2005-09-08 10:19:48 +0200 | [diff] [blame] | 637 | |
Dmitry Torokhov | c5b7c7c | 2005-09-15 02:01:47 -0500 | [diff] [blame] | 638 | /* save our data pointer in this interface device */ |
| 639 | usb_set_intfdata(iface, dev); |
Stelian Pop | f7214ff | 2005-09-08 10:19:48 +0200 | [diff] [blame] | 640 | |
| 641 | return 0; |
| 642 | |
Dmitry Torokhov | c5b7c7c | 2005-09-15 02:01:47 -0500 | [diff] [blame] | 643 | err_free_urb: |
Stelian Pop | f7214ff | 2005-09-08 10:19:48 +0200 | [diff] [blame] | 644 | usb_free_urb(dev->urb); |
Dmitry Torokhov | c5b7c7c | 2005-09-15 02:01:47 -0500 | [diff] [blame] | 645 | err_free_devs: |
Stelian Pop | f7214ff | 2005-09-08 10:19:48 +0200 | [diff] [blame] | 646 | usb_set_intfdata(iface, NULL); |
Stelian Pop | f7214ff | 2005-09-08 10:19:48 +0200 | [diff] [blame] | 647 | kfree(dev); |
Dmitry Torokhov | c5b7c7c | 2005-09-15 02:01:47 -0500 | [diff] [blame] | 648 | input_free_device(input_dev); |
Stelian Pop | f7214ff | 2005-09-08 10:19:48 +0200 | [diff] [blame] | 649 | return retval; |
| 650 | } |
| 651 | |
| 652 | static void atp_disconnect(struct usb_interface *iface) |
| 653 | { |
| 654 | struct atp *dev = usb_get_intfdata(iface); |
| 655 | |
| 656 | usb_set_intfdata(iface, NULL); |
| 657 | if (dev) { |
| 658 | usb_kill_urb(dev->urb); |
Dmitry Torokhov | c5b7c7c | 2005-09-15 02:01:47 -0500 | [diff] [blame] | 659 | input_unregister_device(dev->input); |
Michael Hanselmann | e1e02c9 | 2005-12-21 00:50:23 -0500 | [diff] [blame] | 660 | usb_buffer_free(dev->udev, dev->datalen, |
Stelian Pop | f7214ff | 2005-09-08 10:19:48 +0200 | [diff] [blame] | 661 | dev->data, dev->urb->transfer_dma); |
Johannes Berg | 7af569a | 2006-07-19 15:39:46 +0200 | [diff] [blame] | 662 | usb_free_urb(dev->urb); |
Stelian Pop | f7214ff | 2005-09-08 10:19:48 +0200 | [diff] [blame] | 663 | kfree(dev); |
| 664 | } |
| 665 | printk(KERN_INFO "input: appletouch disconnected\n"); |
| 666 | } |
| 667 | |
| 668 | static int atp_suspend(struct usb_interface *iface, pm_message_t message) |
| 669 | { |
| 670 | struct atp *dev = usb_get_intfdata(iface); |
| 671 | usb_kill_urb(dev->urb); |
| 672 | dev->valid = 0; |
| 673 | return 0; |
| 674 | } |
| 675 | |
| 676 | static int atp_resume(struct usb_interface *iface) |
| 677 | { |
| 678 | struct atp *dev = usb_get_intfdata(iface); |
| 679 | if (dev->open && usb_submit_urb(dev->urb, GFP_ATOMIC)) |
| 680 | return -EIO; |
| 681 | |
| 682 | return 0; |
| 683 | } |
| 684 | |
| 685 | static struct usb_driver atp_driver = { |
Stelian Pop | f7214ff | 2005-09-08 10:19:48 +0200 | [diff] [blame] | 686 | .name = "appletouch", |
| 687 | .probe = atp_probe, |
| 688 | .disconnect = atp_disconnect, |
| 689 | .suspend = atp_suspend, |
| 690 | .resume = atp_resume, |
| 691 | .id_table = atp_table, |
| 692 | }; |
| 693 | |
| 694 | static int __init atp_init(void) |
| 695 | { |
| 696 | return usb_register(&atp_driver); |
| 697 | } |
| 698 | |
| 699 | static void __exit atp_exit(void) |
| 700 | { |
| 701 | usb_deregister(&atp_driver); |
| 702 | } |
| 703 | |
| 704 | module_init(atp_init); |
| 705 | module_exit(atp_exit); |