diff options
| author | Henrik Rydberg <rydberg@euromail.se> | 2008-10-24 23:53:30 +0200 |
|---|---|---|
| committer | Henrik Rydberg <rydberg@euromail.se> | 2008-10-24 23:53:30 +0200 |
| commit | eb8e529c4657c2e57e491ed8f38215708eed7fb5 (patch) | |
| tree | 37616977fc299521f97c43819b9d7e417ed79e74 /usr/src/dkms_source_tree | |
| parent | 8c13725ebac26ba2ed72dc33fc23671dc8bfb766 (diff) | |
Reorganize into a usable debian dkms package
Signed-off-by: Henrik Rydberg <rydberg@euromail.se>
Diffstat (limited to 'usr/src/dkms_source_tree')
| -rw-r--r-- | usr/src/dkms_source_tree/Makefile | 5 | ||||
| -rw-r--r-- | usr/src/dkms_source_tree/bcm5974.c | 778 | ||||
| -rw-r--r-- | usr/src/dkms_source_tree/dkms.conf | 11 | ||||
| -rwxr-xr-x | usr/src/dkms_source_tree/scripts/bcm5974-diagnostics | 232 | ||||
| -rwxr-xr-x | usr/src/dkms_source_tree/scripts/bcm5974-post-install | 63 | ||||
| -rwxr-xr-x | usr/src/dkms_source_tree/scripts/bcm5974-post-remove | 29 | ||||
| -rwxr-xr-x | usr/src/dkms_source_tree/scripts/bcm5974-pre-install | 42 |
7 files changed, 1160 insertions, 0 deletions
diff --git a/usr/src/dkms_source_tree/Makefile b/usr/src/dkms_source_tree/Makefile new file mode 100644 index 0000000..6a04556 --- /dev/null +++ b/usr/src/dkms_source_tree/Makefile | |||
| @@ -0,0 +1,5 @@ | |||
| 1 | # | ||
| 2 | # Makefile for input/mouse drivers | ||
| 3 | # | ||
| 4 | |||
| 5 | obj-m := bcm5974.o | ||
diff --git a/usr/src/dkms_source_tree/bcm5974.c b/usr/src/dkms_source_tree/bcm5974.c new file mode 100644 index 0000000..e858f0b --- /dev/null +++ b/usr/src/dkms_source_tree/bcm5974.c | |||
| @@ -0,0 +1,778 @@ | |||
| 1 | /* | ||
| 2 | * Apple USB BCM5974 (Macbook Air and Penryn Macbook Pro) multitouch driver | ||
| 3 | * | ||
| 4 | * Copyright (C) 2008 Henrik Rydberg (rydberg@euromail.se) | ||
| 5 | * | ||
| 6 | * The USB initialization and package decoding was made by | ||
| 7 | * Scott Shawcroft as part of the touchd user-space driver project: | ||
| 8 | * Copyright (C) 2008 Scott Shawcroft (scott.shawcroft@gmail.com) | ||
| 9 | * | ||
| 10 | * The BCM5974 driver is based on the appletouch driver: | ||
| 11 | * Copyright (C) 2001-2004 Greg Kroah-Hartman (greg@kroah.com) | ||
| 12 | * Copyright (C) 2005 Johannes Berg (johannes@sipsolutions.net) | ||
| 13 | * Copyright (C) 2005 Stelian Pop (stelian@popies.net) | ||
| 14 | * Copyright (C) 2005 Frank Arnold (frank@scirocco-5v-turbo.de) | ||
| 15 | * Copyright (C) 2005 Peter Osterlund (petero2@telia.com) | ||
| 16 | * Copyright (C) 2005 Michael Hanselmann (linux-kernel@hansmi.ch) | ||
| 17 | * Copyright (C) 2006 Nicolas Boichat (nicolas@boichat.ch) | ||
| 18 | * | ||
| 19 | * This program is free software; you can redistribute it and/or modify | ||
| 20 | * it under the terms of the GNU General Public License as published by | ||
| 21 | * the Free Software Foundation; either version 2 of the License, or | ||
| 22 | * (at your option) any later version. | ||
| 23 | * | ||
| 24 | * This program is distributed in the hope that it will be useful, | ||
| 25 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 26 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 27 | * GNU General Public License for more details. | ||
| 28 | * | ||
| 29 | * You should have received a copy of the GNU General Public License | ||
| 30 | * along with this program; if not, write to the Free Software | ||
| 31 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
| 32 | * | ||
| 33 | */ | ||
| 34 | |||
| 35 | #include <linux/kernel.h> | ||
| 36 | #include <linux/errno.h> | ||
| 37 | #include <linux/init.h> | ||
| 38 | #include <linux/slab.h> | ||
| 39 | #include <linux/module.h> | ||
| 40 | #include <linux/usb/input.h> | ||
| 41 | #include <linux/hid.h> | ||
| 42 | #include <linux/mutex.h> | ||
| 43 | |||
| 44 | #define USB_VENDOR_ID_APPLE 0x05ac | ||
| 45 | #define BTN_TOOL_PRESS 0x148 | ||
| 46 | #define BTN_TOOL_QUADTAP 0x14f | ||
| 47 | |||
| 48 | /* MacbookAir, aka wellspring */ | ||
| 49 | #define USB_DEVICE_ID_APPLE_WELLSPRING_ANSI 0x0223 | ||
| 50 | #define USB_DEVICE_ID_APPLE_WELLSPRING_ISO 0x0224 | ||
| 51 | #define USB_DEVICE_ID_APPLE_WELLSPRING_JIS 0x0225 | ||
| 52 | /* MacbookProPenryn, aka wellspring2 */ | ||
| 53 | #define USB_DEVICE_ID_APPLE_WELLSPRING2_ANSI 0x0230 | ||
| 54 | #define USB_DEVICE_ID_APPLE_WELLSPRING2_ISO 0x0231 | ||
| 55 | #define USB_DEVICE_ID_APPLE_WELLSPRING2_JIS 0x0232 | ||
| 56 | /* Macbook5,1 (unibody), aka wellspring3 */ | ||
| 57 | #define USB_DEVICE_ID_APPLE_WELLSPRING3_ANSI 0x0236 | ||
| 58 | #define USB_DEVICE_ID_APPLE_WELLSPRING3_ISO 0x0237 | ||
| 59 | #define USB_DEVICE_ID_APPLE_WELLSPRING3_JIS 0x0238 | ||
| 60 | |||
| 61 | #define BCM5974_DEVICE(prod) { \ | ||
| 62 | .match_flags = (USB_DEVICE_ID_MATCH_DEVICE | \ | ||
| 63 | USB_DEVICE_ID_MATCH_INT_CLASS | \ | ||
| 64 | USB_DEVICE_ID_MATCH_INT_PROTOCOL), \ | ||
| 65 | .idVendor = USB_VENDOR_ID_APPLE, \ | ||
| 66 | .idProduct = (prod), \ | ||
| 67 | .bInterfaceClass = USB_INTERFACE_CLASS_HID, \ | ||
| 68 | .bInterfaceProtocol = USB_INTERFACE_PROTOCOL_MOUSE \ | ||
| 69 | } | ||
| 70 | |||
| 71 | /* table of devices that work with this driver */ | ||
| 72 | static const struct usb_device_id bcm5974_table[] = { | ||
| 73 | /* MacbookAir1.1 */ | ||
| 74 | BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING_ANSI), | ||
| 75 | BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING_ISO), | ||
| 76 | BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING_JIS), | ||
| 77 | /* MacbookProPenryn */ | ||
| 78 | BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING2_ANSI), | ||
| 79 | BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING2_ISO), | ||
| 80 | BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING2_JIS), | ||
| 81 | /* Macbook5,1 */ | ||
| 82 | BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING3_ANSI), | ||
| 83 | BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING3_ISO), | ||
| 84 | BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING3_JIS), | ||
| 85 | /* Terminating entry */ | ||
| 86 | {} | ||
| 87 | }; | ||
| 88 | MODULE_DEVICE_TABLE(usb, bcm5974_table); | ||
| 89 | |||
| 90 | MODULE_AUTHOR("Henrik Rydberg"); | ||
| 91 | MODULE_DESCRIPTION("Apple USB BCM5974 multitouch driver"); | ||
| 92 | MODULE_LICENSE("GPL"); | ||
| 93 | |||
| 94 | #define dprintk(level, format, a...)\ | ||
| 95 | { if (debug >= level) printk(KERN_DEBUG format, ##a); } | ||
| 96 | |||
| 97 | static int debug = 1; | ||
| 98 | module_param(debug, int, 0644); | ||
| 99 | MODULE_PARM_DESC(debug, "Activate debugging output"); | ||
| 100 | |||
| 101 | /* button data structure */ | ||
| 102 | struct bt_data { | ||
| 103 | u8 unknown1; /* constant */ | ||
| 104 | u8 button; /* left button */ | ||
| 105 | u8 rel_x; /* relative x coordinate */ | ||
| 106 | u8 rel_y; /* relative y coordinate */ | ||
| 107 | }; | ||
| 108 | |||
| 109 | /* trackpad header types */ | ||
| 110 | enum tp_type { | ||
| 111 | TYPE1, /* plain trackpad */ | ||
| 112 | TYPE2 /* button integrated in trackpad */ | ||
| 113 | }; | ||
| 114 | |||
| 115 | /* trackpad finger data offsets */ | ||
| 116 | #define FINGER_TYPE1 26 | ||
| 117 | #define FINGER_TYPE2 30 | ||
| 118 | |||
| 119 | /* trackpad button data offsets */ | ||
| 120 | #define BUTTON_TYPE2 15 | ||
| 121 | |||
| 122 | /* integrated button capability by configuration */ | ||
| 123 | #define HAS_INTEGRATED_BUTTON(c) (c->tp_type == TYPE2) | ||
| 124 | |||
| 125 | /* trackpad finger structure */ | ||
| 126 | struct tp_finger { | ||
| 127 | __le16 origin; /* zero when switching track finger */ | ||
| 128 | __le16 abs_x; /* absolute x coodinate */ | ||
| 129 | __le16 abs_y; /* absolute y coodinate */ | ||
| 130 | __le16 rel_x; /* relative x coodinate */ | ||
| 131 | __le16 rel_y; /* relative y coodinate */ | ||
| 132 | __le16 size_major; /* finger size, major axis? */ | ||
| 133 | __le16 size_minor; /* finger size, minor axis? */ | ||
| 134 | __le16 orientation; /* 16384 when point, else 15 bit angle */ | ||
| 135 | __le16 force_major; /* trackpad force, major axis? */ | ||
| 136 | __le16 force_minor; /* trackpad force, minor axis? */ | ||
| 137 | __le16 unused[3]; /* zeros */ | ||
| 138 | __le16 multi; /* one finger: varies, more fingers: constant */ | ||
| 139 | }; | ||
| 140 | |||
| 141 | /* trackpad finger data size, empirically at least ten fingers */ | ||
| 142 | #define SIZEOF_FINGER sizeof(struct tp_finger) | ||
| 143 | #define SIZEOF_ALL_FINGERS (16 * SIZEOF_FINGER) | ||
| 144 | |||
| 145 | /* device-specific parameters */ | ||
| 146 | struct bcm5974_param { | ||
| 147 | int dim; /* logical dimension */ | ||
| 148 | int fuzz; /* logical noise value */ | ||
| 149 | int devmin; /* device minimum reading */ | ||
| 150 | int devmax; /* device maximum reading */ | ||
| 151 | }; | ||
| 152 | |||
| 153 | /* device-specific configuration */ | ||
| 154 | struct bcm5974_config { | ||
| 155 | int ansi, iso, jis; /* the product id of this device */ | ||
| 156 | int bt_ep; /* the endpoint of the button interface */ | ||
| 157 | int bt_datalen; /* data length of the button interface */ | ||
| 158 | int tp_ep; /* the endpoint of the trackpad interface */ | ||
| 159 | enum tp_type tp_type; /* type of trackpad interface */ | ||
| 160 | int tp_offset; /* offset to trackpad finger data */ | ||
| 161 | int tp_datalen; /* data length of the trackpad interface */ | ||
| 162 | struct bcm5974_param p; /* finger pressure limits */ | ||
| 163 | struct bcm5974_param w; /* finger width limits */ | ||
| 164 | struct bcm5974_param x; /* horizontal limits */ | ||
| 165 | struct bcm5974_param y; /* vertical limits */ | ||
| 166 | }; | ||
| 167 | |||
| 168 | /* logical device structure */ | ||
| 169 | struct bcm5974 { | ||
| 170 | char phys[64]; | ||
| 171 | struct usb_device *udev; /* usb device */ | ||
| 172 | struct usb_interface *intf; /* our interface */ | ||
| 173 | struct input_dev *input; /* input dev */ | ||
| 174 | struct bcm5974_config cfg; /* device configuration */ | ||
| 175 | struct mutex pm_mutex; /* serialize access to open/suspend */ | ||
| 176 | int opened; /* 1: opened, 0: closed */ | ||
| 177 | struct urb *bt_urb; /* button usb request block */ | ||
| 178 | struct bt_data *bt_data; /* button transferred data */ | ||
| 179 | struct urb *tp_urb; /* trackpad usb request block */ | ||
| 180 | u8 *tp_data; /* trackpad transferred data */ | ||
| 181 | int fingers; /* number of fingers on trackpad */ | ||
| 182 | }; | ||
| 183 | |||
| 184 | /* logical dimensions */ | ||
| 185 | #define DIM_PRESSURE 256 /* maximum finger pressure */ | ||
| 186 | #define DIM_WIDTH 16 /* maximum finger width */ | ||
| 187 | #define DIM_X 1280 /* maximum trackpad x value */ | ||
| 188 | #define DIM_Y 800 /* maximum trackpad y value */ | ||
| 189 | |||
| 190 | /* logical signal quality */ | ||
| 191 | #define SN_PRESSURE 45 /* pressure signal-to-noise ratio */ | ||
| 192 | #define SN_WIDTH 100 /* width signal-to-noise ratio */ | ||
| 193 | #define SN_COORD 250 /* coordinate signal-to-noise ratio */ | ||
| 194 | |||
| 195 | /* pressure thresholds */ | ||
| 196 | #define PRESSURE_LOW (2 * DIM_PRESSURE / SN_PRESSURE) | ||
| 197 | #define PRESSURE_HIGH (3 * PRESSURE_LOW) | ||
| 198 | |||
| 199 | /* device constants */ | ||
| 200 | static const struct bcm5974_config bcm5974_config_table[] = { | ||
| 201 | { | ||
| 202 | USB_DEVICE_ID_APPLE_WELLSPRING_ANSI, | ||
| 203 | USB_DEVICE_ID_APPLE_WELLSPRING_ISO, | ||
| 204 | USB_DEVICE_ID_APPLE_WELLSPRING_JIS, | ||
| 205 | 0x84, sizeof(struct bt_data), | ||
| 206 | 0x81, TYPE1, FINGER_TYPE1, FINGER_TYPE1 + SIZEOF_ALL_FINGERS, | ||
| 207 | { DIM_PRESSURE, DIM_PRESSURE / SN_PRESSURE, 0, 256 }, | ||
| 208 | { DIM_WIDTH, DIM_WIDTH / SN_WIDTH, 0, 2048 }, | ||
| 209 | { DIM_X, DIM_X / SN_COORD, -4824, 5342 }, | ||
| 210 | { DIM_Y, DIM_Y / SN_COORD, -172, 5820 } | ||
| 211 | }, | ||
| 212 | { | ||
| 213 | USB_DEVICE_ID_APPLE_WELLSPRING2_ANSI, | ||
| 214 | USB_DEVICE_ID_APPLE_WELLSPRING2_ISO, | ||
| 215 | USB_DEVICE_ID_APPLE_WELLSPRING2_JIS, | ||
| 216 | 0x84, sizeof(struct bt_data), | ||
| 217 | 0x81, TYPE1, FINGER_TYPE1, FINGER_TYPE1 + SIZEOF_ALL_FINGERS, | ||
| 218 | { DIM_PRESSURE, DIM_PRESSURE / SN_PRESSURE, 0, 256 }, | ||
| 219 | { DIM_WIDTH, DIM_WIDTH / SN_WIDTH, 0, 2048 }, | ||
| 220 | { DIM_X, DIM_X / SN_COORD, -4824, 4824 }, | ||
| 221 | { DIM_Y, DIM_Y / SN_COORD, -172, 4290 } | ||
| 222 | }, | ||
| 223 | { | ||
| 224 | USB_DEVICE_ID_APPLE_WELLSPRING3_ANSI, | ||
| 225 | USB_DEVICE_ID_APPLE_WELLSPRING3_ISO, | ||
| 226 | USB_DEVICE_ID_APPLE_WELLSPRING3_JIS, | ||
| 227 | 0x84, sizeof(struct bt_data), | ||
| 228 | 0x81, TYPE2, FINGER_TYPE2, FINGER_TYPE2 + SIZEOF_ALL_FINGERS, | ||
| 229 | { DIM_PRESSURE, DIM_PRESSURE / SN_PRESSURE, 0, 300 }, | ||
| 230 | { DIM_WIDTH, DIM_WIDTH / SN_WIDTH, 0, 2048 }, | ||
| 231 | { DIM_X, DIM_X / SN_COORD, -4460, 5166 }, | ||
| 232 | { DIM_Y, DIM_Y / SN_COORD, -75, 6700 } | ||
| 233 | }, | ||
| 234 | {} | ||
| 235 | }; | ||
| 236 | |||
| 237 | /* return the device-specific configuration by device */ | ||
| 238 | static const struct bcm5974_config *bcm5974_get_config(struct usb_device *udev) | ||
| 239 | { | ||
| 240 | u16 id = le16_to_cpu(udev->descriptor.idProduct); | ||
| 241 | const struct bcm5974_config *cfg; | ||
| 242 | |||
| 243 | for (cfg = bcm5974_config_table; cfg->ansi; ++cfg) | ||
| 244 | if (cfg->ansi == id || cfg->iso == id || cfg->jis == id) | ||
| 245 | return cfg; | ||
| 246 | |||
| 247 | return bcm5974_config_table; | ||
| 248 | } | ||
| 249 | |||
| 250 | /* convert 16-bit little endian to signed integer */ | ||
| 251 | static inline int raw2int(__le16 x) | ||
| 252 | { | ||
| 253 | return (signed short)le16_to_cpu(x); | ||
| 254 | } | ||
| 255 | |||
| 256 | /* scale device data to logical dimensions (asserts devmin < devmax) */ | ||
| 257 | static inline int int2scale(const struct bcm5974_param *p, int x) | ||
| 258 | { | ||
| 259 | return x * p->dim / (p->devmax - p->devmin); | ||
| 260 | } | ||
| 261 | |||
| 262 | /* all logical value ranges are [0,dim). */ | ||
| 263 | static inline int int2bound(const struct bcm5974_param *p, int x) | ||
| 264 | { | ||
| 265 | int s = int2scale(p, x); | ||
| 266 | |||
| 267 | //return clamp_val(s, 0, p->dim - 1); | ||
| 268 | return s < 0 ? 0 : s >= p->dim ? p->dim - 1 : s; | ||
| 269 | } | ||
| 270 | |||
| 271 | /* setup which logical events to report */ | ||
| 272 | static void setup_events_to_report(struct input_dev *input_dev, | ||
| 273 | const struct bcm5974_config *cfg) | ||
| 274 | { | ||
| 275 | __set_bit(EV_ABS, input_dev->evbit); | ||
| 276 | |||
| 277 | input_set_abs_params(input_dev, ABS_PRESSURE, | ||
| 278 | 0, cfg->p.dim, cfg->p.fuzz, 0); | ||
| 279 | input_set_abs_params(input_dev, ABS_TOOL_WIDTH, | ||
| 280 | 0, cfg->w.dim, cfg->w.fuzz, 0); | ||
| 281 | input_set_abs_params(input_dev, ABS_X, | ||
| 282 | 0, cfg->x.dim, cfg->x.fuzz, 0); | ||
| 283 | input_set_abs_params(input_dev, ABS_Y, | ||
| 284 | 0, cfg->y.dim, cfg->y.fuzz, 0); | ||
| 285 | |||
| 286 | __set_bit(EV_KEY, input_dev->evbit); | ||
| 287 | __set_bit(BTN_TOUCH, input_dev->keybit); | ||
| 288 | __set_bit(BTN_TOOL_FINGER, input_dev->keybit); | ||
| 289 | __set_bit(BTN_TOOL_DOUBLETAP, input_dev->keybit); | ||
| 290 | __set_bit(BTN_TOOL_TRIPLETAP, input_dev->keybit); | ||
| 291 | __set_bit(BTN_TOOL_QUADTAP, input_dev->keybit); | ||
| 292 | if (HAS_INTEGRATED_BUTTON(cfg)) | ||
| 293 | __set_bit(BTN_TOOL_PRESS, input_dev->keybit); | ||
| 294 | __set_bit(BTN_LEFT, input_dev->keybit); | ||
| 295 | } | ||
| 296 | |||
| 297 | /* report button data as logical button state */ | ||
| 298 | static int report_bt_state(struct bcm5974 *dev, int size) | ||
| 299 | { | ||
| 300 | if (size != sizeof(struct bt_data)) | ||
| 301 | return -EIO; | ||
| 302 | |||
| 303 | dprintk(7, | ||
| 304 | "bcm5974: button data: %x %x %x %x\n", | ||
| 305 | dev->bt_data->unknown1, dev->bt_data->button, | ||
| 306 | dev->bt_data->rel_x, dev->bt_data->rel_y); | ||
| 307 | |||
| 308 | input_report_key(dev->input, BTN_LEFT, dev->bt_data->button); | ||
| 309 | input_sync(dev->input); | ||
| 310 | |||
| 311 | return 0; | ||
| 312 | } | ||
| 313 | |||
| 314 | /* report trackpad data as logical trackpad state */ | ||
| 315 | static int report_tp_state(struct bcm5974 *dev, int size) | ||
| 316 | { | ||
| 317 | const struct bcm5974_config *c = &dev->cfg; | ||
| 318 | const struct tp_finger *f; | ||
| 319 | struct input_dev *input = dev->input; | ||
| 320 | int raw_p, raw_w, raw_x, raw_y, raw_n; | ||
| 321 | int ptest = 0, origin = 0, ibt = 0, nmin = 0, nmax = 0; | ||
| 322 | int abs_p = 0, abs_w = 0, abs_x = 0, abs_y = 0; | ||
| 323 | |||
| 324 | if (size < c->tp_offset || (size - c->tp_offset) % SIZEOF_FINGER != 0) | ||
| 325 | return -EIO; | ||
| 326 | |||
| 327 | f = (const struct tp_finger *)(dev->tp_data + c->tp_offset); | ||
| 328 | raw_n = (size - c->tp_offset) / SIZEOF_FINGER; | ||
| 329 | |||
| 330 | /* always track the first finger; when detached, start over */ | ||
| 331 | if (raw_n) { | ||
| 332 | raw_p = raw2int(f->force_major); | ||
| 333 | raw_w = raw2int(f->size_major); | ||
| 334 | raw_x = raw2int(f->abs_x); | ||
| 335 | raw_y = raw2int(f->abs_y); | ||
| 336 | |||
| 337 | dprintk(9, | ||
| 338 | "bcm5974: raw: p: %+05d w: %+05d x: %+05d y: %+05d " | ||
| 339 | "n: %d\n", raw_p, raw_w, raw_x, raw_y, raw_n); | ||
| 340 | |||
| 341 | ptest = int2bound(&c->p, raw_p); | ||
| 342 | origin = raw2int(f->origin); | ||
| 343 | |||
| 344 | /* set the integrated button if applicable */ | ||
| 345 | if (c->tp_type == TYPE2) | ||
| 346 | ibt = raw2int(dev->tp_data[BUTTON_TYPE2]); | ||
| 347 | } | ||
| 348 | |||
| 349 | /* while tracking finger still valid, count all fingers */ | ||
| 350 | if (ptest > PRESSURE_LOW && origin) { | ||
| 351 | abs_p = ptest; | ||
| 352 | abs_w = int2bound(&c->w, raw_w); | ||
| 353 | abs_x = int2bound(&c->x, raw_x - c->x.devmin); | ||
| 354 | abs_y = int2bound(&c->y, c->y.devmax - raw_y); | ||
| 355 | while (raw_n--) { | ||
| 356 | ptest = int2bound(&c->p, raw2int(f->force_major)); | ||
| 357 | if (ptest > PRESSURE_LOW) | ||
| 358 | nmax++; | ||
| 359 | if (ptest > PRESSURE_HIGH) | ||
| 360 | nmin++; | ||
| 361 | f++; | ||
| 362 | } | ||
| 363 | } | ||
| 364 | |||
| 365 | if (dev->fingers < nmin) | ||
| 366 | dev->fingers = nmin; | ||
| 367 | if (dev->fingers > nmax) | ||
| 368 | dev->fingers = nmax; | ||
| 369 | |||
| 370 | input_report_key(input, BTN_TOUCH, dev->fingers > 0); | ||
| 371 | input_report_key(input, BTN_TOOL_FINGER, dev->fingers == 1); | ||
| 372 | input_report_key(input, BTN_TOOL_DOUBLETAP, dev->fingers == 2); | ||
| 373 | input_report_key(input, BTN_TOOL_TRIPLETAP, dev->fingers == 3); | ||
| 374 | input_report_key(input, BTN_TOOL_QUADTAP, dev->fingers > 3); | ||
| 375 | |||
| 376 | input_report_abs(input, ABS_PRESSURE, abs_p); | ||
| 377 | input_report_abs(input, ABS_TOOL_WIDTH, abs_w); | ||
| 378 | |||
| 379 | if (abs_p) { | ||
| 380 | input_report_abs(input, ABS_X, abs_x); | ||
| 381 | input_report_abs(input, ABS_Y, abs_y); | ||
| 382 | |||
| 383 | dprintk(8, | ||
| 384 | "bcm5974: abs: p: %+05d w: %+05d x: %+05d y: %+05d " | ||
| 385 | "nmin: %d nmax: %d n: %d ibt: %d\n", abs_p, abs_w, | ||
| 386 | abs_x, abs_y, nmin, nmax, dev->fingers, ibt); | ||
| 387 | |||
| 388 | } | ||
| 389 | |||
| 390 | if (HAS_INTEGRATED_BUTTON(c)) { | ||
| 391 | input_report_key(input, BTN_TOOL_PRESS, ibt); | ||
| 392 | input_report_key(input, BTN_LEFT, ibt); | ||
| 393 | } | ||
| 394 | |||
| 395 | input_sync(input); | ||
| 396 | |||
| 397 | return 0; | ||
| 398 | } | ||
| 399 | |||
| 400 | /* Wellspring initialization constants */ | ||
| 401 | #define BCM5974_WELLSPRING_MODE_READ_REQUEST_ID 1 | ||
| 402 | #define BCM5974_WELLSPRING_MODE_WRITE_REQUEST_ID 9 | ||
| 403 | #define BCM5974_WELLSPRING_MODE_REQUEST_VALUE 0x300 | ||
| 404 | #define BCM5974_WELLSPRING_MODE_REQUEST_INDEX 0 | ||
| 405 | #define BCM5974_WELLSPRING_MODE_VENDOR_VALUE 0x01 | ||
| 406 | #define BCM5974_WELLSPRING_MODE_NORMAL_VALUE 0x08 | ||
| 407 | |||
| 408 | static int bcm5974_wellspring_mode(struct bcm5974 *dev, bool on) | ||
| 409 | { | ||
| 410 | char *data = kmalloc(8, GFP_KERNEL); | ||
| 411 | int retval = 0, size; | ||
| 412 | |||
| 413 | if (!data) { | ||
| 414 | err("bcm5974: out of memory"); | ||
| 415 | retval = -ENOMEM; | ||
| 416 | goto out; | ||
| 417 | } | ||
| 418 | |||
| 419 | /* read configuration */ | ||
| 420 | size = usb_control_msg(dev->udev, usb_rcvctrlpipe(dev->udev, 0), | ||
| 421 | BCM5974_WELLSPRING_MODE_READ_REQUEST_ID, | ||
| 422 | USB_DIR_IN | USB_TYPE_CLASS | USB_RECIP_INTERFACE, | ||
| 423 | BCM5974_WELLSPRING_MODE_REQUEST_VALUE, | ||
| 424 | BCM5974_WELLSPRING_MODE_REQUEST_INDEX, data, 8, 5000); | ||
| 425 | |||
| 426 | if (size != 8) { | ||
| 427 | err("bcm5974: could not read from device"); | ||
| 428 | retval = -EIO; | ||
| 429 | goto out; | ||
| 430 | } | ||
| 431 | |||
| 432 | /* apply the mode switch */ | ||
| 433 | data[0] = on ? | ||
| 434 | BCM5974_WELLSPRING_MODE_VENDOR_VALUE : | ||
| 435 | BCM5974_WELLSPRING_MODE_NORMAL_VALUE; | ||
| 436 | |||
| 437 | /* write configuration */ | ||
| 438 | size = usb_control_msg(dev->udev, usb_sndctrlpipe(dev->udev, 0), | ||
| 439 | BCM5974_WELLSPRING_MODE_WRITE_REQUEST_ID, | ||
| 440 | USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_INTERFACE, | ||
| 441 | BCM5974_WELLSPRING_MODE_REQUEST_VALUE, | ||
| 442 | BCM5974_WELLSPRING_MODE_REQUEST_INDEX, data, 8, 5000); | ||
| 443 | |||
| 444 | if (size != 8) { | ||
| 445 | err("bcm5974: could not write to device"); | ||
| 446 | retval = -EIO; | ||
| 447 | goto out; | ||
| 448 | } | ||
| 449 | |||
| 450 | dprintk(2, "bcm5974: switched to %s mode.\n", | ||
| 451 | on ? "wellspring" : "normal"); | ||
| 452 | |||
| 453 | out: | ||
| 454 | kfree(data); | ||
| 455 | return retval; | ||
| 456 | } | ||
| 457 | |||
| 458 | static void bcm5974_irq_button(struct urb *urb) | ||
| 459 | { | ||
| 460 | struct bcm5974 *dev = urb->context; | ||
| 461 | int error; | ||
| 462 | |||
| 463 | switch (urb->status) { | ||
| 464 | case 0: | ||
| 465 | break; | ||
| 466 | case -EOVERFLOW: | ||
| 467 | case -ECONNRESET: | ||
| 468 | case -ENOENT: | ||
| 469 | case -ESHUTDOWN: | ||
| 470 | dbg("bcm5974: button urb shutting down: %d", urb->status); | ||
| 471 | return; | ||
| 472 | default: | ||
| 473 | dbg("bcm5974: button urb status: %d", urb->status); | ||
| 474 | goto exit; | ||
| 475 | } | ||
| 476 | |||
| 477 | if (report_bt_state(dev, dev->bt_urb->actual_length)) | ||
| 478 | dprintk(1, "bcm5974: bad button package, length: %d\n", | ||
| 479 | dev->bt_urb->actual_length); | ||
| 480 | |||
| 481 | exit: | ||
| 482 | error = usb_submit_urb(dev->bt_urb, GFP_ATOMIC); | ||
| 483 | if (error) | ||
| 484 | err("bcm5974: button urb failed: %d", error); | ||
| 485 | } | ||
| 486 | |||
| 487 | static void bcm5974_irq_trackpad(struct urb *urb) | ||
| 488 | { | ||
| 489 | struct bcm5974 *dev = urb->context; | ||
| 490 | int error; | ||
| 491 | |||
| 492 | switch (urb->status) { | ||
| 493 | case 0: | ||
| 494 | break; | ||
| 495 | case -EOVERFLOW: | ||
| 496 | case -ECONNRESET: | ||
| 497 | case -ENOENT: | ||
| 498 | case -ESHUTDOWN: | ||
| 499 | dbg("bcm5974: trackpad urb shutting down: %d", urb->status); | ||
| 500 | return; | ||
| 501 | default: | ||
| 502 | dbg("bcm5974: trackpad urb status: %d", urb->status); | ||
| 503 | goto exit; | ||
| 504 | } | ||
| 505 | |||
| 506 | /* control response ignored */ | ||
| 507 | if (dev->tp_urb->actual_length == 2) | ||
| 508 | goto exit; | ||
| 509 | |||
| 510 | if (report_tp_state(dev, dev->tp_urb->actual_length)) | ||
| 511 | dprintk(1, "bcm5974: bad trackpad package, length: %d\n", | ||
| 512 | dev->tp_urb->actual_length); | ||
| 513 | |||
| 514 | exit: | ||
| 515 | error = usb_submit_urb(dev->tp_urb, GFP_ATOMIC); | ||
| 516 | if (error) | ||
| 517 | err("bcm5974: trackpad urb failed: %d", error); | ||
| 518 | } | ||
| 519 | |||
| 520 | /* | ||
| 521 | * The Wellspring trackpad, like many recent Apple trackpads, share | ||
| 522 | * the usb device with the keyboard. Since keyboards are usually | ||
| 523 | * handled by the HID system, the device ends up being handled by two | ||
| 524 | * modules. Setting up the device therefore becomes slightly | ||
| 525 | * complicated. To enable multitouch features, a mode switch is | ||
| 526 | * required, which is usually applied via the control interface of the | ||
| 527 | * device. It can be argued where this switch should take place. In | ||
| 528 | * some drivers, like appletouch, the switch is made during | ||
| 529 | * probe. However, the hid module may also alter the state of the | ||
| 530 | * device, resulting in trackpad malfunction under certain | ||
| 531 | * circumstances. To get around this problem, there is at least one | ||
| 532 | * example that utilizes the USB_QUIRK_RESET_RESUME quirk in order to | ||
| 533 | * recieve a reset_resume request rather than the normal resume. | ||
| 534 | * Since the implementation of reset_resume is equal to mode switch | ||
| 535 | * plus start_traffic, it seems easier to always do the switch when | ||
| 536 | * starting traffic on the device. | ||
| 537 | */ | ||
| 538 | static int bcm5974_start_traffic(struct bcm5974 *dev) | ||
| 539 | { | ||
| 540 | if (bcm5974_wellspring_mode(dev, true)) { | ||
| 541 | dprintk(1, "bcm5974: mode switch failed\n"); | ||
| 542 | goto error; | ||
| 543 | } | ||
| 544 | |||
| 545 | if (usb_submit_urb(dev->bt_urb, GFP_KERNEL)) | ||
| 546 | goto error; | ||
| 547 | |||
| 548 | if (usb_submit_urb(dev->tp_urb, GFP_KERNEL)) | ||
| 549 | goto err_kill_bt; | ||
| 550 | |||
| 551 | return 0; | ||
| 552 | |||
| 553 | err_kill_bt: | ||
| 554 | usb_kill_urb(dev->bt_urb); | ||
| 555 | error: | ||
| 556 | return -EIO; | ||
| 557 | } | ||
| 558 | |||
| 559 | static void bcm5974_pause_traffic(struct bcm5974 *dev) | ||
| 560 | { | ||
| 561 | usb_kill_urb(dev->tp_urb); | ||
| 562 | usb_kill_urb(dev->bt_urb); | ||
| 563 | bcm5974_wellspring_mode(dev, false); | ||
| 564 | } | ||
| 565 | |||
| 566 | /* | ||
| 567 | * The code below implements open/close and manual suspend/resume. | ||
| 568 | * All functions may be called in random order. | ||
| 569 | * | ||
| 570 | * Opening a suspended device fails with EACCES - permission denied. | ||
| 571 | * | ||
| 572 | * Failing a resume leaves the device resumed but closed. | ||
| 573 | */ | ||
| 574 | static int bcm5974_open(struct input_dev *input) | ||
| 575 | { | ||
| 576 | struct bcm5974 *dev = input_get_drvdata(input); | ||
| 577 | int error; | ||
| 578 | |||
| 579 | error = usb_autopm_get_interface(dev->intf); | ||
| 580 | if (error) | ||
| 581 | return error; | ||
| 582 | |||
| 583 | mutex_lock(&dev->pm_mutex); | ||
| 584 | |||
| 585 | error = bcm5974_start_traffic(dev); | ||
| 586 | if (!error) | ||
| 587 | dev->opened = 1; | ||
| 588 | |||
| 589 | mutex_unlock(&dev->pm_mutex); | ||
| 590 | |||
| 591 | if (error) | ||
| 592 | usb_autopm_put_interface(dev->intf); | ||
| 593 | |||
| 594 | return error; | ||
| 595 | } | ||
| 596 | |||
| 597 | static void bcm5974_close(struct input_dev *input) | ||
| 598 | { | ||
| 599 | struct bcm5974 *dev = input_get_drvdata(input); | ||
| 600 | |||
| 601 | mutex_lock(&dev->pm_mutex); | ||
| 602 | |||
| 603 | bcm5974_pause_traffic(dev); | ||
| 604 | dev->opened = 0; | ||
| 605 | |||
| 606 | mutex_unlock(&dev->pm_mutex); | ||
| 607 | |||
| 608 | usb_autopm_put_interface(dev->intf); | ||
| 609 | } | ||
| 610 | |||
| 611 | static int bcm5974_suspend(struct usb_interface *iface, pm_message_t message) | ||
| 612 | { | ||
| 613 | struct bcm5974 *dev = usb_get_intfdata(iface); | ||
| 614 | |||
| 615 | mutex_lock(&dev->pm_mutex); | ||
| 616 | |||
| 617 | if (dev->opened) | ||
| 618 | bcm5974_pause_traffic(dev); | ||
| 619 | |||
| 620 | mutex_unlock(&dev->pm_mutex); | ||
| 621 | |||
| 622 | return 0; | ||
| 623 | } | ||
| 624 | |||
| 625 | static int bcm5974_resume(struct usb_interface *iface) | ||
| 626 | { | ||
| 627 | struct bcm5974 *dev = usb_get_intfdata(iface); | ||
| 628 | int error = 0; | ||
| 629 | |||
| 630 | mutex_lock(&dev->pm_mutex); | ||
| 631 | |||
| 632 | if (dev->opened) | ||
| 633 | error = bcm5974_start_traffic(dev); | ||
| 634 | |||
| 635 | mutex_unlock(&dev->pm_mutex); | ||
| 636 | |||
| 637 | return error; | ||
| 638 | } | ||
| 639 | |||
| 640 | static int bcm5974_probe(struct usb_interface *iface, | ||
| 641 | const struct usb_device_id *id) | ||
| 642 | { | ||
| 643 | struct usb_device *udev = interface_to_usbdev(iface); | ||
| 644 | const struct bcm5974_config *cfg; | ||
| 645 | struct bcm5974 *dev; | ||
| 646 | struct input_dev *input_dev; | ||
| 647 | int error = -ENOMEM; | ||
| 648 | |||
| 649 | /* find the product index */ | ||
| 650 | cfg = bcm5974_get_config(udev); | ||
| 651 | |||
| 652 | /* allocate memory for our device state and initialize it */ | ||
| 653 | dev = kzalloc(sizeof(struct bcm5974), GFP_KERNEL); | ||
| 654 | input_dev = input_allocate_device(); | ||
| 655 | if (!dev || !input_dev) { | ||
| 656 | err("bcm5974: out of memory"); | ||
| 657 | goto err_free_devs; | ||
| 658 | } | ||
| 659 | |||
| 660 | dev->udev = udev; | ||
| 661 | dev->intf = iface; | ||
| 662 | dev->input = input_dev; | ||
| 663 | dev->cfg = *cfg; | ||
| 664 | mutex_init(&dev->pm_mutex); | ||
| 665 | |||
| 666 | /* setup urbs */ | ||
| 667 | dev->bt_urb = usb_alloc_urb(0, GFP_KERNEL); | ||
| 668 | if (!dev->bt_urb) | ||
| 669 | goto err_free_devs; | ||
| 670 | |||
| 671 | dev->tp_urb = usb_alloc_urb(0, GFP_KERNEL); | ||
| 672 | if (!dev->tp_urb) | ||
| 673 | goto err_free_bt_urb; | ||
| 674 | |||
| 675 | dev->bt_data = usb_buffer_alloc(dev->udev, | ||
| 676 | dev->cfg.bt_datalen, GFP_KERNEL, | ||
| 677 | &dev->bt_urb->transfer_dma); | ||
| 678 | if (!dev->bt_data) | ||
| 679 | goto err_free_urb; | ||
| 680 | |||
| 681 | dev->tp_data = usb_buffer_alloc(dev->udev, | ||
| 682 | dev->cfg.tp_datalen, GFP_KERNEL, | ||
| 683 | &dev->tp_urb->transfer_dma); | ||
| 684 | if (!dev->tp_data) | ||
| 685 | goto err_free_bt_buffer; | ||
| 686 | |||
| 687 | usb_fill_int_urb(dev->bt_urb, udev, | ||
| 688 | usb_rcvintpipe(udev, cfg->bt_ep), | ||
| 689 | dev->bt_data, dev->cfg.bt_datalen, | ||
| 690 | bcm5974_irq_button, dev, 1); | ||
| 691 | |||
| 692 | usb_fill_int_urb(dev->tp_urb, udev, | ||
| 693 | usb_rcvintpipe(udev, cfg->tp_ep), | ||
| 694 | dev->tp_data, dev->cfg.tp_datalen, | ||
| 695 | bcm5974_irq_trackpad, dev, 1); | ||
| 696 | |||
| 697 | /* create bcm5974 device */ | ||
| 698 | usb_make_path(udev, dev->phys, sizeof(dev->phys)); | ||
| 699 | strlcat(dev->phys, "/input0", sizeof(dev->phys)); | ||
| 700 | |||
| 701 | input_dev->name = "bcm5974"; | ||
| 702 | input_dev->phys = dev->phys; | ||
| 703 | usb_to_input_id(dev->udev, &input_dev->id); | ||
| 704 | input_dev->dev.parent = &iface->dev; | ||
| 705 | |||
| 706 | input_set_drvdata(input_dev, dev); | ||
| 707 | |||
| 708 | input_dev->open = bcm5974_open; | ||
| 709 | input_dev->close = bcm5974_close; | ||
| 710 | |||
| 711 | setup_events_to_report(input_dev, cfg); | ||
| 712 | |||
| 713 | error = input_register_device(dev->input); | ||
| 714 | if (error) | ||
| 715 | goto err_free_buffer; | ||
| 716 | |||
| 717 | /* save our data pointer in this interface device */ | ||
| 718 | usb_set_intfdata(iface, dev); | ||
| 719 | |||
| 720 | return 0; | ||
| 721 | |||
| 722 | err_free_buffer: | ||
| 723 | usb_buffer_free(dev->udev, dev->cfg.tp_datalen, | ||
| 724 | dev->tp_data, dev->tp_urb->transfer_dma); | ||
| 725 | err_free_bt_buffer: | ||
| 726 | usb_buffer_free(dev->udev, dev->cfg.bt_datalen, | ||
| 727 | dev->bt_data, dev->bt_urb->transfer_dma); | ||
| 728 | err_free_urb: | ||
| 729 | usb_free_urb(dev->tp_urb); | ||
| 730 | err_free_bt_urb: | ||
| 731 | usb_free_urb(dev->bt_urb); | ||
| 732 | err_free_devs: | ||
| 733 | usb_set_intfdata(iface, NULL); | ||
| 734 | input_free_device(input_dev); | ||
| 735 | kfree(dev); | ||
| 736 | return error; | ||
| 737 | } | ||
| 738 | |||
| 739 | static void bcm5974_disconnect(struct usb_interface *iface) | ||
| 740 | { | ||
| 741 | struct bcm5974 *dev = usb_get_intfdata(iface); | ||
| 742 | |||
| 743 | usb_set_intfdata(iface, NULL); | ||
| 744 | |||
| 745 | input_unregister_device(dev->input); | ||
| 746 | usb_buffer_free(dev->udev, dev->cfg.tp_datalen, | ||
| 747 | dev->tp_data, dev->tp_urb->transfer_dma); | ||
| 748 | usb_buffer_free(dev->udev, dev->cfg.bt_datalen, | ||
| 749 | dev->bt_data, dev->bt_urb->transfer_dma); | ||
| 750 | usb_free_urb(dev->tp_urb); | ||
| 751 | usb_free_urb(dev->bt_urb); | ||
| 752 | kfree(dev); | ||
| 753 | } | ||
| 754 | |||
| 755 | static struct usb_driver bcm5974_driver = { | ||
| 756 | .name = "bcm5974", | ||
| 757 | .probe = bcm5974_probe, | ||
| 758 | .disconnect = bcm5974_disconnect, | ||
| 759 | .suspend = bcm5974_suspend, | ||
| 760 | .resume = bcm5974_resume, | ||
| 761 | .reset_resume = bcm5974_resume, | ||
| 762 | .id_table = bcm5974_table, | ||
| 763 | .supports_autosuspend = 1, | ||
| 764 | }; | ||
| 765 | |||
| 766 | static int __init bcm5974_init(void) | ||
| 767 | { | ||
| 768 | return usb_register(&bcm5974_driver); | ||
| 769 | } | ||
| 770 | |||
| 771 | static void __exit bcm5974_exit(void) | ||
| 772 | { | ||
| 773 | usb_deregister(&bcm5974_driver); | ||
| 774 | } | ||
| 775 | |||
| 776 | module_init(bcm5974_init); | ||
| 777 | module_exit(bcm5974_exit); | ||
| 778 | |||
diff --git a/usr/src/dkms_source_tree/dkms.conf b/usr/src/dkms_source_tree/dkms.conf new file mode 100644 index 0000000..df7925c --- /dev/null +++ b/usr/src/dkms_source_tree/dkms.conf | |||
| @@ -0,0 +1,11 @@ | |||
| 1 | NAME=bcm5974 | ||
| 2 | VERSION=0.99 | ||
| 3 | PACKAGE_NAME="$NAME" | ||
| 4 | PACKAGE_VERSION="$VERSION" | ||
| 5 | MAKE[0]="make -C ${kernel_source_dir} | ||
| 6 | SUBDIRS=${dkms_tree}/${PACKAGE_NAME}/${PACKAGE_VERSION}/build modules" | ||
| 7 | BUILT_MODULE_NAME[0]="bcm5974" | ||
| 8 | DEST_MODULE_LOCATION[0]="/kernel/drivers/input/mouse" | ||
| 9 | PRE_INSTALL="scripts/bcm5974-pre-install" | ||
| 10 | POST_INSTALL="scripts/bcm5974-post-install" | ||
| 11 | POST_REMOVE="scripts/bcm5974-post-remove" | ||
diff --git a/usr/src/dkms_source_tree/scripts/bcm5974-diagnostics b/usr/src/dkms_source_tree/scripts/bcm5974-diagnostics new file mode 100755 index 0000000..acd0bf4 --- /dev/null +++ b/usr/src/dkms_source_tree/scripts/bcm5974-diagnostics | |||
| @@ -0,0 +1,232 @@ | |||
| 1 | #!/bin/bash | ||
| 2 | # | ||
| 3 | # bcm5943-diagnostics - troubleshooting the BCM5974 setup | ||
| 4 | # | ||
| 5 | # Copyright (C) 2008 Henrik Rydberg (rydberg@euromail.se) | ||
| 6 | # | ||
| 7 | # This program is free software; you can redistribute it and/or modify | ||
| 8 | # it under the terms of the GNU General Public License as published by | ||
| 9 | # the Free Software Foundation; either version 2 of the License, or | ||
| 10 | # (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., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
| 20 | # | ||
| 21 | |||
| 22 | DRIVER=bcm5974 | ||
| 23 | |||
| 24 | echo ----------------------------------------------------------------------- | ||
| 25 | |||
| 26 | # What kernel version am I running? | ||
| 27 | KERNEL=`uname -r` | ||
| 28 | echo \* Kernel version: $KERNEL | ||
| 29 | |||
| 30 | # What synaptics version is installed (debian)? | ||
| 31 | if [ -x /usr/bin/dpkg-query ]; then | ||
| 32 | SYNAPTICS=`/usr/bin/dpkg-query -W -f='${Version}\n' xserver-xorg-input-synaptics` | ||
| 33 | echo \* Synaptics version: $SYNAPTICS | ||
| 34 | else | ||
| 35 | echo \* Synaptics version: UNKNOWN - dpkg not found | ||
| 36 | fi | ||
| 37 | |||
| 38 | # What USB devices of interest can we find? | ||
| 39 | if [ -x /usr/sbin/lsusb ]; then | ||
| 40 | LSUSB=`lsusb|grep 05ac:02` | ||
| 41 | echo \* USB device: $LSUSB | ||
| 42 | else | ||
| 43 | echo \* USB device: UNKNOWN - lsusb not found | ||
| 44 | fi | ||
| 45 | |||
| 46 | # Do we have the module intalled? | ||
| 47 | MODLIB=/lib/modules/$KERNEL/kernel/drivers/input/mouse/$DRIVER.ko | ||
| 48 | MODLIB2=/lib/modules/$KERNEL/updates/dkms/$DRIVER.ko | ||
| 49 | if [ -f $MODLIB ]; then | ||
| 50 | echo \* $MODLIB: exists | ||
| 51 | elif [ -f $MODLIB2 ]; then | ||
| 52 | echo \* $MODLIB2: exists | ||
| 53 | else | ||
| 54 | echo \* $DRIVER does NOT exist | ||
| 55 | echo dkms: install package | ||
| 56 | echo manual: copy the file $DRIVER.ko to $MODLIB | ||
| 57 | exit 1 | ||
| 58 | fi | ||
| 59 | |||
| 60 | # Do we have the module configured? | ||
| 61 | MODULES=/etc/modules | ||
| 62 | if [ -f $MODULES ]; then | ||
| 63 | if (grep -q $DRIVER $MODULES); then | ||
| 64 | echo \* $MODULES: has $DRIVER config, please remove | ||
| 65 | exit 1 | ||
| 66 | else | ||
| 67 | echo \* $MODULES: $DRIVER no longer explicitly listed, good | ||
| 68 | fi | ||
| 69 | fi | ||
| 70 | |||
| 71 | # Do we have old quirks? | ||
| 72 | MODPROBE=/etc/modprobe.d/options | ||
| 73 | if [ -f $MODPROBE ]; then | ||
| 74 | MODPROBEOPTS=`grep quirks= $MODPROBE|grep -v ^#|grep 0x05ac:0x02` | ||
| 75 | if [ "$MODPROBEOPTS" != "" ]; then | ||
| 76 | echo \* $MODPROBE: has obsolete quirks - please remove | ||
| 77 | exit 1 | ||
| 78 | else | ||
| 79 | echo \* $MODPROBE: no obsolete quirks, good | ||
| 80 | fi | ||
| 81 | else | ||
| 82 | echo \* $MODPROBE: file not found | ||
| 83 | fi | ||
| 84 | |||
| 85 | # Do we have the right quirks? | ||
| 86 | DRIVMOD=/etc/modprobe.d/$DRIVER | ||
| 87 | if [ -f $DRIVMOD ]; then | ||
| 88 | DRIVMODOPTS=`grep quirks= $DRIVMOD|grep -v ^#|grep 0x05ac:0x02` | ||
| 89 | if [ "$DRIVMODOPTS" != "" ]; then | ||
| 90 | echo \* $DRIVMOD: has quirks, good | ||
| 91 | else | ||
| 92 | echo \* $DRIVMOD: does NOT have quirks | ||
| 93 | echo Uncomment the right quirk line in $DRIVMOD | ||
| 94 | exit 1 | ||
| 95 | fi | ||
| 96 | else | ||
| 97 | echo \* $DRIVMOD: file not found | ||
| 98 | echo Copy the etc/modprobe.d/bcm5974 file to /etc/modprobe.d/ | ||
| 99 | exit 1 | ||
| 100 | fi | ||
| 101 | |||
| 102 | # Did the depmod bite? | ||
| 103 | USBMAP=/lib/modules/$KERNEL/modules.usbmap | ||
| 104 | if [ -f $USBMAP ]; then | ||
| 105 | typeset -i nusb=`grep $DRIVER $USBMAP|grep 0x05ac|grep 0x02|wc -l` | ||
| 106 | if [ $nusb -gt 0 ]; then | ||
| 107 | echo \* $USBMAP: maps to $DRIVER, good | ||
| 108 | else | ||
| 109 | echo \* $USBMAP: does NOT map to $DRIVER | ||
| 110 | echo Run depmod -a as root | ||
| 111 | exit 1 | ||
| 112 | fi | ||
| 113 | fi | ||
| 114 | |||
| 115 | # Was the $DRIVER module loaded? | ||
| 116 | DMESG=`lsmod|grep $DRIVER` | ||
| 117 | if [ "$DMESG" != "" ]; then | ||
| 118 | echo \* $DRIVER: module is loaded | ||
| 119 | else | ||
| 120 | echo \* $DRIVER: module is NOT loaded | ||
| 121 | echo Add this line to /etc/modules: | ||
| 122 | echo "$DRIVER" | ||
| 123 | exit 1 | ||
| 124 | fi | ||
| 125 | |||
| 126 | # Was the $DRIVER module registered? | ||
| 127 | DEVPATH=/proc/bus/input/devices | ||
| 128 | if [ -f $DEVPATH ]; then | ||
| 129 | DEVICES=`grep $DRIVER /proc/bus/input/devices` | ||
| 130 | if [ "$DEVICES" != "" ]; then | ||
| 131 | echo \* $DEVPATH: module is registered | ||
| 132 | else | ||
| 133 | echo \* $DEVPATH: module is NOT registered | ||
| 134 | echo "Please double-check the quirks settings in $DRIVMOD" | ||
| 135 | exit 1 | ||
| 136 | fi | ||
| 137 | else | ||
| 138 | echo \* $DEVPATH: does not exist, ignore | ||
| 139 | fi | ||
| 140 | |||
| 141 | # Do we have synaptics working properly? | ||
| 142 | typeset -i SYNLINES=`synclient -l|wc -l` | ||
| 143 | if [ $SYNLINES -gt 10 ]; then | ||
| 144 | echo \* synaptics: configuration readable | ||
| 145 | else | ||
| 146 | echo \* synaptics: configuration NOT readable | ||
| 147 | exit 1 | ||
| 148 | fi | ||
| 149 | |||
| 150 | # Do we have a working synaptics configuration? | ||
| 151 | DIFF=/tmp/synclient-output.diff.$$ | ||
| 152 | TMP=/tmp/synclient-output.txt.$$ | ||
| 153 | synclient -l | grep -v Parameter | sort > $TMP | ||
| 154 | diff -u - $TMP > $DIFF <<EOF | ||
| 155 | AccelFactor = 0.1 | ||
| 156 | BottomEdge = 800 | ||
| 157 | CircScrollDelta = 0.1 | ||
| 158 | CircScrollTrigger = 0 | ||
| 159 | CircularPad = 0 | ||
| 160 | CircularScrolling = 0 | ||
| 161 | ClickTime = 100 | ||
| 162 | CoastingSpeed = 0 | ||
| 163 | CornerCoasting = 0 | ||
| 164 | EdgeMotionMaxSpeed = 80 | ||
| 165 | EdgeMotionMaxZ = 160 | ||
| 166 | EdgeMotionMinSpeed = 1 | ||
| 167 | EdgeMotionMinZ = 30 | ||
| 168 | EdgeMotionUseAlways = 0 | ||
| 169 | EmulateMidButtonTime = 75 | ||
| 170 | EmulateTwoFingerMinZ = 257 | ||
| 171 | FastTaps = 0 | ||
| 172 | FingerHigh = 80 | ||
| 173 | FingerLow = 16 | ||
| 174 | FingerPress = 256 | ||
| 175 | GrabEventDevice = 1 | ||
| 176 | GuestMouseOff = 0 | ||
| 177 | HorizEdgeScroll = 0 | ||
| 178 | HorizScrollDelta = 0 | ||
| 179 | HorizTwoFingerScroll = 1 | ||
| 180 | LBCornerButton = 0 | ||
| 181 | LeftEdge = 0 | ||
| 182 | LeftRightScrolling = 1 | ||
| 183 | LeftRightScrollRepeat = 1 | ||
| 184 | LockedDrags = 0 | ||
| 185 | LockedDragTimeout = 5000 | ||
| 186 | LTCornerButton = 0 | ||
| 187 | MaxDoubleTapTime = 200 | ||
| 188 | MaxSpeed = 1.2 | ||
| 189 | MaxTapMove = 100 | ||
| 190 | MaxTapTime = 223 | ||
| 191 | MinSpeed = 0.8 | ||
| 192 | MultiFingerButton = 2 | ||
| 193 | PalmDetect = 0 | ||
| 194 | PalmMinWidth = 10 | ||
| 195 | PalmMinZ = 200 | ||
| 196 | PressureMotionMaxFactor = 1 | ||
| 197 | PressureMotionMaxZ = 160 | ||
| 198 | PressureMotionMinFactor = 1 | ||
| 199 | PressureMotionMinZ = 10 | ||
| 200 | RBCornerButton = 0 | ||
| 201 | RightEdge = 1280 | ||
| 202 | RTCornerButton = 0 | ||
| 203 | ScrollButtonRepeat = 100 | ||
| 204 | SingleTapTimeout = 180 | ||
| 205 | TapButton1 = 0 | ||
| 206 | TapButton2 = 0 | ||
| 207 | TapButton3 = 0 | ||
| 208 | TopEdge = 0 | ||
| 209 | TouchpadOff = 0 | ||
| 210 | TrackstickSpeed = 40 | ||
| 211 | UpDownScrolling = 1 | ||
| 212 | UpDownScrollRepeat = 1 | ||
| 213 | VertEdgeScroll = 0 | ||
| 214 | VertScrollDelta = 40 | ||
| 215 | VertTwoFingerScroll = 1 | ||
| 216 | EOF | ||
| 217 | rm -f $TMP | ||
| 218 | |||
| 219 | echo ======================================================================= | ||
| 220 | echo The bcm5974 seems properly configured | ||
| 221 | |||
| 222 | typeset -i NDIFF=`cat $DIFF|wc -l` | ||
| 223 | if [ $NDIFF -gt 0 ]; then | ||
| 224 | echo | ||
| 225 | echo Your synaptics settings differ from the bcm5974 default: | ||
| 226 | echo ----------------------------------------------------------------------- | ||
| 227 | tail -n +4 $DIFF | ||
| 228 | echo ----------------------------------------------------------------------- | ||
| 229 | echo If in doubt, please check your /etc/X11/xorg.conf settings | ||
| 230 | fi | ||
| 231 | |||
| 232 | rm -f $DIFF | ||
diff --git a/usr/src/dkms_source_tree/scripts/bcm5974-post-install b/usr/src/dkms_source_tree/scripts/bcm5974-post-install new file mode 100755 index 0000000..de5094c --- /dev/null +++ b/usr/src/dkms_source_tree/scripts/bcm5974-post-install | |||
| @@ -0,0 +1,63 @@ | |||
| 1 | #!/bin/bash | ||
| 2 | # | ||
| 3 | # bcm5943-post-install - post-installing the BCM5974 | ||
| 4 | # | ||
| 5 | # Copyright (C) 2008 Henrik Rydberg (rydberg@euromail.se) | ||
| 6 | # | ||
| 7 | # This program is free software; you can redistribute it and/or modify | ||
| 8 | # it under the terms of the GNU General Public License as published by | ||
| 9 | # the Free Software Foundation; either version 2 of the License, or | ||
| 10 | # (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., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
| 20 | # | ||
| 21 | |||
| 22 | DRIVER=bcm5974 | ||
| 23 | ETCPATH=/etc/modprobe.d/$DRIVER | ||
| 24 | |||
| 25 | echo ----------------------------------------------------------------------- | ||
| 26 | |||
| 27 | DIR=`dirname $0` | ||
| 28 | LSUSB=/usr/sbin/lsusb | ||
| 29 | |||
| 30 | PAT_HEAD="options usbhid quirks=" | ||
| 31 | |||
| 32 | DEV[0]="0223" | ||
| 33 | DEV[1]="0224" | ||
| 34 | DEV[2]="0225" | ||
| 35 | DEV[3]="0230" | ||
| 36 | DEV[4]="0231" | ||
| 37 | DEV[5]="0232" | ||
| 38 | DEV[6]="0236" | ||
| 39 | DEV[7]="0237" | ||
| 40 | DEV[8]="0238" | ||
| 41 | |||
| 42 | if [ -x $LSUSB ]; then | ||
| 43 | typeset -i i=0 | ||
| 44 | while [ $i -lt 9 ]; do | ||
| 45 | PAT=05ac:${DEV[$i]} | ||
| 46 | MATCH=${PAT_HEAD}0x05ac:0x${DEV[$i]} | ||
| 47 | if [ "`$LSUSB|grep $PAT`" != "" ]; then | ||
| 48 | SED="s/#$MATCH/$MATCH/" | ||
| 49 | fi | ||
| 50 | i=$i+1 | ||
| 51 | done | ||
| 52 | else | ||
| 53 | echo \* USB device: UNKNOWN - lsusb not found | ||
| 54 | exit 1 | ||
| 55 | fi | ||
| 56 | |||
| 57 | if [ "$SED" != "" ]; then | ||
| 58 | cat $DIR/..$ETCPATH | sed "$SED" > $ETCPATH | ||
| 59 | exit 0 | ||
| 60 | else | ||
| 61 | echo No suitable device found | ||
| 62 | exit 1 | ||
| 63 | fi | ||
diff --git a/usr/src/dkms_source_tree/scripts/bcm5974-post-remove b/usr/src/dkms_source_tree/scripts/bcm5974-post-remove new file mode 100755 index 0000000..21977de --- /dev/null +++ b/usr/src/dkms_source_tree/scripts/bcm5974-post-remove | |||
| @@ -0,0 +1,29 @@ | |||
| 1 | #!/bin/bash | ||
| 2 | # | ||
| 3 | # bcm5943-post-remove - post-removing the BCM5974 | ||
| 4 | # | ||
| 5 | # Copyright (C) 2008 Henrik Rydberg (rydberg@euromail.se) | ||
| 6 | # | ||
| 7 | # This program is free software; you can redistribute it and/or modify | ||
| 8 | # it under the terms of the GNU General Public License as published by | ||
| 9 | # the Free Software Foundation; either version 2 of the License, or | ||
| 10 | # (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., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
| 20 | # | ||
| 21 | |||
| 22 | DRIVER=bcm5974 | ||
| 23 | ETCPATH=/etc/modprobe.d/$DRIVER | ||
| 24 | |||
| 25 | echo ----------------------------------------------------------------------- | ||
| 26 | |||
| 27 | rm -f $ETCPATH | ||
| 28 | |||
| 29 | exit 0 | ||
diff --git a/usr/src/dkms_source_tree/scripts/bcm5974-pre-install b/usr/src/dkms_source_tree/scripts/bcm5974-pre-install new file mode 100755 index 0000000..1e2b864 --- /dev/null +++ b/usr/src/dkms_source_tree/scripts/bcm5974-pre-install | |||
| @@ -0,0 +1,42 @@ | |||
| 1 | #!/bin/bash | ||
| 2 | # | ||
| 3 | # bcm5943-pre-install - check system before installing the bcm5974 | ||
| 4 | # | ||
| 5 | # Copyright (C) 2008 Henrik Rydberg (rydberg@euromail.se) | ||
| 6 | # | ||
| 7 | # This program is free software; you can redistribute it and/or modify | ||
| 8 | # it under the terms of the GNU General Public License as published by | ||
| 9 | # the Free Software Foundation; either version 2 of the License, or | ||
| 10 | # (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., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
| 20 | # | ||
| 21 | |||
| 22 | DRIVER=bcm5974 | ||
| 23 | LSUSB=/usr/sbin/lsusb | ||
| 24 | |||
| 25 | PAT[0]="05ac:022" | ||
| 26 | PAT[1]="05ac:023" | ||
| 27 | |||
| 28 | if [ -x $LSUSB ]; then | ||
| 29 | if [ "`$LSUSB|grep ${PAT[0]}`" != "" ]; then | ||
| 30 | exit 0 | ||
| 31 | elif [ "`$LSUSB|grep ${PAT[1]}`" != "" ]; then | ||
| 32 | exit 0 | ||
| 33 | else | ||
| 34 | echo bcm5974: no suitable device found | ||
| 35 | exit -1 | ||
| 36 | fi | ||
| 37 | else | ||
| 38 | echo bcm5974: cannot determine device type | ||
| 39 | exit -1 | ||
| 40 | fi | ||
| 41 | |||
| 42 | exit 0 | ||
