diff options
| -rw-r--r-- | CHANGES | 7 | ||||
| -rw-r--r-- | bcm5974-dkms-mkdeb/debian/changelog | 4 | ||||
| -rw-r--r-- | bcm5974.c | 234 | ||||
| -rw-r--r-- | dkms.conf | 2 | ||||
| -rw-r--r-- | etc/modprobe.d/bcm5974 | 15 |
5 files changed, 220 insertions, 42 deletions
| @@ -1,3 +1,10 @@ | |||
| 1 | bcm5974 (0.60) unstable; urgency=low | ||
| 2 | |||
| 3 | * New default mouse driver mode | ||
| 4 | * Mouse configuration parameters | ||
| 5 | |||
| 6 | -- Henrik Rydberg <rydberg@euromail.se> Mon, 01 Sep 2008 18:38:21 +0200 | ||
| 7 | |||
| 1 | bcm5974 (0.59) unstable; urgency=low | 8 | bcm5974 (0.59) unstable; urgency=low |
| 2 | 9 | ||
| 3 | * Cleanup patch from Dmitry Torokhov | 10 | * Cleanup patch from Dmitry Torokhov |
diff --git a/bcm5974-dkms-mkdeb/debian/changelog b/bcm5974-dkms-mkdeb/debian/changelog index 9c8bd7b..aff6ab4 100644 --- a/bcm5974-dkms-mkdeb/debian/changelog +++ b/bcm5974-dkms-mkdeb/debian/changelog | |||
| @@ -1,6 +1,6 @@ | |||
| 1 | MODULE_NAME-dkms (MODULE_VERSION) unstable; urgency=low | 1 | MODULE_NAME-dkms (MODULE_VERSION) unstable; urgency=low |
| 2 | 2 | ||
| 3 | * Cleanup patch from Dmitry Torokhov | 3 | * New default mouse driver mode |
| 4 | * Auto-suspend patch from Dmitry Torokhov | 4 | * Mouse configuration parameters |
| 5 | 5 | ||
| 6 | -- Henrik Rydberg <rydberg@euromail.se> DATE_STAMP | 6 | -- Henrik Rydberg <rydberg@euromail.se> DATE_STAMP |
| @@ -63,7 +63,7 @@ | |||
| 63 | } | 63 | } |
| 64 | 64 | ||
| 65 | /* table of devices that work with this driver */ | 65 | /* table of devices that work with this driver */ |
| 66 | static const struct usb_device_id bcm5974_table [] = { | 66 | static const struct usb_device_id bcm5974_table[] = { |
| 67 | /* MacbookAir1.1 */ | 67 | /* MacbookAir1.1 */ |
| 68 | BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING_ANSI), | 68 | BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING_ANSI), |
| 69 | BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING_ISO), | 69 | BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING_ISO), |
| @@ -84,10 +84,33 @@ MODULE_LICENSE("GPL"); | |||
| 84 | #define dprintk(level, format, a...)\ | 84 | #define dprintk(level, format, a...)\ |
| 85 | { if (debug >= level) printk(KERN_DEBUG format, ##a); } | 85 | { if (debug >= level) printk(KERN_DEBUG format, ##a); } |
| 86 | 86 | ||
| 87 | #define MODE_MOUSE 1 | ||
| 88 | #define MODE_TOUCHPAD 2 | ||
| 89 | |||
| 87 | static int debug = 1; | 90 | static int debug = 1; |
| 88 | module_param(debug, int, 0644); | 91 | module_param(debug, int, 0644); |
| 89 | MODULE_PARM_DESC(debug, "Activate debugging output"); | 92 | MODULE_PARM_DESC(debug, "Activate debugging output"); |
| 90 | 93 | ||
| 94 | static int driver_mode = MODE_MOUSE; | ||
| 95 | module_param(driver_mode, int, 0644); | ||
| 96 | MODULE_PARM_DESC(driver_mode, "Driver mode (1 - mouse; 2 - touchpad)"); | ||
| 97 | |||
| 98 | static int mouse_motion_damping = 8; | ||
| 99 | module_param(mouse_motion_damping, int, 0644); | ||
| 100 | MODULE_PARM_DESC(mouse_motion_damping, "Mouse motion damping"); | ||
| 101 | |||
| 102 | static int mouse_wheel_damping = 256; | ||
| 103 | module_param(mouse_wheel_damping, int, 0644); | ||
| 104 | MODULE_PARM_DESC(mouse_wheel_damping, "Vertical mouse wheel damping"); | ||
| 105 | |||
| 106 | static int mouse_hwheel_damping = 256; | ||
| 107 | module_param(mouse_hwheel_damping, int, 0644); | ||
| 108 | MODULE_PARM_DESC(mouse_hwheel_damping, "Horizontal mouse wheel damping"); | ||
| 109 | |||
| 110 | static int mouse_button_mode = 2; | ||
| 111 | module_param(mouse_button_mode, int, 0644); | ||
| 112 | MODULE_PARM_DESC(mouse_button_mode, "Mouse button mode (1 - unix; 2 - macos)"); | ||
| 113 | |||
| 91 | /* button data structure */ | 114 | /* button data structure */ |
| 92 | struct bt_data { | 115 | struct bt_data { |
| 93 | u8 unknown1; /* constant */ | 116 | u8 unknown1; /* constant */ |
| @@ -146,6 +169,13 @@ struct bcm5974_config { | |||
| 146 | struct bcm5974_param y; /* vertical limits */ | 169 | struct bcm5974_param y; /* vertical limits */ |
| 147 | }; | 170 | }; |
| 148 | 171 | ||
| 172 | /* mouse driver state */ | ||
| 173 | struct bcm5974_mouse_state { | ||
| 174 | int fingers; /* number of fingers on trackpad */ | ||
| 175 | int wheel; /* vertical wheel counter */ | ||
| 176 | int hwheel; /* horizontal wheel counter */ | ||
| 177 | }; | ||
| 178 | |||
| 149 | /* logical device structure */ | 179 | /* logical device structure */ |
| 150 | struct bcm5974 { | 180 | struct bcm5974 { |
| 151 | char phys[64]; | 181 | char phys[64]; |
| @@ -159,6 +189,7 @@ struct bcm5974 { | |||
| 159 | struct bt_data *bt_data; /* button transferred data */ | 189 | struct bt_data *bt_data; /* button transferred data */ |
| 160 | struct urb *tp_urb; /* trackpad usb request block */ | 190 | struct urb *tp_urb; /* trackpad usb request block */ |
| 161 | struct tp_data *tp_data; /* trackpad transferred data */ | 191 | struct tp_data *tp_data; /* trackpad transferred data */ |
| 192 | struct bcm5974_mouse_state ms; /* mouse state */ | ||
| 162 | }; | 193 | }; |
| 163 | 194 | ||
| 164 | /* logical dimensions */ | 195 | /* logical dimensions */ |
| @@ -229,79 +260,204 @@ static inline int int2bound(const struct bcm5974_param *p, int x) | |||
| 229 | { | 260 | { |
| 230 | int s = int2scale(p, x); | 261 | int s = int2scale(p, x); |
| 231 | 262 | ||
| 232 | // return clamp_val(s, 0, p->dim - 1); | 263 | // return clamp_val(s, 0, p->dim - 1); |
| 233 | return s < 0 ? 0 : s >= p->dim ? p->dim - 1 : s; | 264 | return s < 0 ? 0 : s >= p->dim ? p->dim - 1 : s; |
| 234 | } | 265 | } |
| 235 | 266 | ||
| 236 | /* setup which logical events to report */ | 267 | /* setup which logical events to report */ |
| 237 | static void setup_events_to_report(struct input_dev *input_dev, | 268 | static void setup_events_to_report(struct input_dev *input_dev, |
| 238 | const struct bcm5974_config *cfg) | 269 | const struct bcm5974_config *cfg) |
| 239 | { | 270 | { |
| 240 | __set_bit(EV_ABS, input_dev->evbit); | ||
| 241 | |||
| 242 | input_set_abs_params(input_dev, ABS_PRESSURE, | ||
| 243 | 0, cfg->p.dim, cfg->p.fuzz, 0); | ||
| 244 | input_set_abs_params(input_dev, ABS_TOOL_WIDTH, | ||
| 245 | 0, cfg->w.dim, cfg->w.fuzz, 0); | ||
| 246 | input_set_abs_params(input_dev, ABS_X, | ||
| 247 | 0, cfg->x.dim, cfg->x.fuzz, 0); | ||
| 248 | input_set_abs_params(input_dev, ABS_Y, | ||
| 249 | 0, cfg->y.dim, cfg->y.fuzz, 0); | ||
| 250 | |||
| 251 | __set_bit(EV_KEY, input_dev->evbit); | 271 | __set_bit(EV_KEY, input_dev->evbit); |
| 252 | __set_bit(BTN_TOOL_FINGER, input_dev->keybit); | ||
| 253 | __set_bit(BTN_TOOL_DOUBLETAP, input_dev->keybit); | ||
| 254 | __set_bit(BTN_TOOL_TRIPLETAP, input_dev->keybit); | ||
| 255 | __set_bit(BTN_LEFT, input_dev->keybit); | 272 | __set_bit(BTN_LEFT, input_dev->keybit); |
| 273 | |||
| 274 | switch (driver_mode) { | ||
| 275 | case MODE_MOUSE: | ||
| 276 | __set_bit(EV_REL, input_dev->evbit); | ||
| 277 | __set_bit(REL_X, input_dev->relbit); | ||
| 278 | __set_bit(REL_Y, input_dev->relbit); | ||
| 279 | __set_bit(REL_WHEEL, input_dev->relbit); | ||
| 280 | __set_bit(REL_HWHEEL, input_dev->relbit); | ||
| 281 | __set_bit(BTN_MIDDLE, input_dev->keybit); | ||
| 282 | __set_bit(BTN_RIGHT, input_dev->keybit); | ||
| 283 | break; | ||
| 284 | case MODE_TOUCHPAD: | ||
| 285 | __set_bit(EV_ABS, input_dev->evbit); | ||
| 286 | __set_bit(BTN_TOOL_FINGER, input_dev->keybit); | ||
| 287 | __set_bit(BTN_TOOL_DOUBLETAP, input_dev->keybit); | ||
| 288 | __set_bit(BTN_TOOL_TRIPLETAP, input_dev->keybit); | ||
| 289 | |||
| 290 | input_set_abs_params(input_dev, ABS_PRESSURE, | ||
| 291 | 0, cfg->p.dim, cfg->p.fuzz, 0); | ||
| 292 | input_set_abs_params(input_dev, ABS_TOOL_WIDTH, | ||
| 293 | 0, cfg->w.dim, cfg->w.fuzz, 0); | ||
| 294 | input_set_abs_params(input_dev, ABS_X, | ||
| 295 | 0, cfg->x.dim, cfg->x.fuzz, 0); | ||
| 296 | input_set_abs_params(input_dev, ABS_Y, | ||
| 297 | 0, cfg->y.dim, cfg->y.fuzz, 0); | ||
| 298 | break; | ||
| 299 | } | ||
| 256 | } | 300 | } |
| 257 | 301 | ||
| 258 | /* report button data as logical button state */ | 302 | /* update logical mouse button state */ |
| 303 | static void update_bt_mouse_state(struct input_dev *dev, | ||
| 304 | const struct bcm5974_mouse_state *ms, | ||
| 305 | const struct bt_data *bt) | ||
| 306 | { | ||
| 307 | const int n = ms->fingers; | ||
| 308 | |||
| 309 | bool left, middle, right; | ||
| 310 | switch (mouse_button_mode) { | ||
| 311 | case 1: | ||
| 312 | left = n <= 1 && bt->button; | ||
| 313 | middle = n == 2 && bt->button; | ||
| 314 | right = n >= 3 && bt->button; | ||
| 315 | break; | ||
| 316 | case 2: | ||
| 317 | left = n <= 1 && bt->button; | ||
| 318 | middle = n >= 3 && bt->button; | ||
| 319 | right = n == 2 && bt->button; | ||
| 320 | break; | ||
| 321 | default: | ||
| 322 | left = bt->button; | ||
| 323 | middle = false; | ||
| 324 | right = false; | ||
| 325 | break; | ||
| 326 | }; | ||
| 327 | input_report_key(dev, BTN_LEFT, left); | ||
| 328 | input_report_key(dev, BTN_MIDDLE, middle); | ||
| 329 | input_report_key(dev, BTN_RIGHT, right); | ||
| 330 | } | ||
| 331 | |||
| 332 | /* update logical touchpad button state */ | ||
| 333 | static void update_bt_touchpad_state(struct input_dev *dev, | ||
| 334 | const struct bt_data *bt) | ||
| 335 | { | ||
| 336 | input_report_key(dev, BTN_LEFT, bt->button); | ||
| 337 | } | ||
| 338 | |||
| 339 | /* report button data as logical mouse/touchpad button state */ | ||
| 259 | static int report_bt_state(struct bcm5974 *dev, int size) | 340 | static int report_bt_state(struct bcm5974 *dev, int size) |
| 260 | { | 341 | { |
| 261 | if (size != sizeof(struct bt_data)) | 342 | if (size != sizeof(struct bt_data)) |
| 262 | return -EIO; | 343 | return -EIO; |
| 263 | 344 | ||
| 264 | input_report_key(dev->input, BTN_LEFT, dev->bt_data->button); | 345 | switch (driver_mode) { |
| 346 | case MODE_MOUSE: | ||
| 347 | update_bt_mouse_state(dev->input, &dev->ms, dev->bt_data); | ||
| 348 | break; | ||
| 349 | case MODE_TOUCHPAD: | ||
| 350 | update_bt_touchpad_state(dev->input, dev->bt_data); | ||
| 351 | break; | ||
| 352 | } | ||
| 353 | |||
| 265 | input_sync(dev->input); | 354 | input_sync(dev->input); |
| 266 | 355 | ||
| 267 | return 0; | 356 | return 0; |
| 268 | } | 357 | } |
| 269 | 358 | ||
| 270 | /* report trackpad data as logical trackpad state */ | 359 | /* update logical mouse motion state */ |
| 271 | static int report_tp_state(struct bcm5974 *dev, int size) | 360 | static void update_tp_mouse_state(struct input_dev *dev, |
| 361 | struct bcm5974_mouse_state *ms, | ||
| 362 | const struct bcm5974_config *c, | ||
| 363 | const struct tp_finger *f, | ||
| 364 | int p, int n) | ||
| 272 | { | 365 | { |
| 273 | const struct bcm5974_config *c = &dev->cfg; | 366 | int dx = 0, dy = 0, sx = 0, sy = 0, sw = 0, shw = 0; |
| 274 | const struct tp_finger *f = dev->tp_data->finger; | ||
| 275 | struct input_dev *input = dev->input; | ||
| 276 | const int fingers = (size - 26) / 28; | ||
| 277 | int p = 0, w, x, y, n = 0; | ||
| 278 | 367 | ||
| 279 | if (size < 26 || (size - 26) % 28 != 0) | 368 | if (f) { |
| 280 | return -EIO; | 369 | dx = raw2int(f->rel_x); |
| 370 | dy = raw2int(f->rel_y); | ||
| 281 | 371 | ||
| 282 | if (fingers) { | 372 | dprintk(9, |
| 283 | p = raw2int(f->force_major); | 373 | "bcm5974: p: %+05d dx: %+05d dy: %+05d n: %d\n", |
| 374 | p, dx, dy, n); | ||
| 375 | } | ||
| 376 | |||
| 377 | if (n >= 3) { | ||
| 378 | /* swipe */ | ||
| 379 | ms->wheel = 0; | ||
| 380 | ms->hwheel += int2scale(&c->x, dx); | ||
| 381 | shw = ms->hwheel / mouse_hwheel_damping; | ||
| 382 | ms->hwheel -= shw * mouse_hwheel_damping; | ||
| 383 | } else if (n == 2) { | ||
| 384 | /* scroll */ | ||
| 385 | ms->wheel += int2scale(&c->y, dy); | ||
| 386 | ms->hwheel = 0; | ||
| 387 | sw = ms->wheel / mouse_wheel_damping; | ||
| 388 | ms->wheel -= sw * mouse_wheel_damping; | ||
| 389 | } else { | ||
| 390 | /* pointer */ | ||
| 391 | ms->wheel = 0; | ||
| 392 | ms->hwheel = 0; | ||
| 393 | sx = int2scale(&c->x, dx) / mouse_motion_damping; | ||
| 394 | sy = int2scale(&c->y, -dy) / mouse_motion_damping; | ||
| 395 | } | ||
| 396 | |||
| 397 | ms->fingers = n; | ||
| 398 | |||
| 399 | input_report_rel(dev, REL_X, sx); | ||
| 400 | input_report_rel(dev, REL_Y, sy); | ||
| 401 | input_report_rel(dev, REL_WHEEL, sw); | ||
| 402 | input_report_rel(dev, REL_HWHEEL, shw); | ||
| 403 | } | ||
| 404 | |||
| 405 | /* update logical touchpad state */ | ||
| 406 | static void update_tp_touchpad_state(struct input_dev *dev, | ||
| 407 | const struct bcm5974_config *c, | ||
| 408 | const struct tp_finger *f, | ||
| 409 | int p, int n) | ||
| 410 | { | ||
| 411 | int w, x, y; | ||
| 412 | |||
| 413 | if (f) { | ||
| 284 | w = raw2int(f->size_major); | 414 | w = raw2int(f->size_major); |
| 285 | x = raw2int(f->abs_x); | 415 | x = raw2int(f->abs_x); |
| 286 | y = raw2int(f->abs_y); | 416 | y = raw2int(f->abs_y); |
| 287 | n = p > 0 ? fingers : 0; | ||
| 288 | 417 | ||
| 289 | dprintk(9, | 418 | dprintk(9, |
| 290 | "bcm5974: p: %+05d w: %+05d x: %+05d y: %+05d n: %d\n", | 419 | "bcm5974: p: %+05d w: %+05d x: %+05d y: %+05d n: %d\n", |
| 291 | p, w, x, y, n); | 420 | p, w, x, y, n); |
| 292 | 421 | ||
| 293 | input_report_abs(input, ABS_TOOL_WIDTH, int2bound(&c->w, w)); | 422 | input_report_abs(dev, ABS_TOOL_WIDTH, int2bound(&c->w, w)); |
| 294 | input_report_abs(input, ABS_X, int2bound(&c->x, x - c->x.devmin)); | 423 | input_report_abs(dev, ABS_X, int2bound(&c->x, x - c->x.devmin)); |
| 295 | input_report_abs(input, ABS_Y, int2bound(&c->y, c->y.devmax - y)); | 424 | input_report_abs(dev, ABS_Y, int2bound(&c->y, c->y.devmax - y)); |
| 296 | } | 425 | } |
| 297 | 426 | ||
| 298 | input_report_abs(input, ABS_PRESSURE, int2bound(&c->p, p)); | 427 | input_report_abs(dev, ABS_PRESSURE, int2bound(&c->p, p)); |
| 428 | |||
| 429 | input_report_key(dev, BTN_TOOL_FINGER, n == 1); | ||
| 430 | input_report_key(dev, BTN_TOOL_DOUBLETAP, n == 2); | ||
| 431 | input_report_key(dev, BTN_TOOL_TRIPLETAP, n > 2); | ||
| 432 | } | ||
| 433 | |||
| 434 | /* report trackpad data as logical mouse/touchpad state */ | ||
| 435 | static int report_tp_state(struct bcm5974 *dev, int size) | ||
| 436 | { | ||
| 437 | const struct bcm5974_config *c = &dev->cfg; | ||
| 438 | const int fingers = (size - 26) / 28; | ||
| 439 | const struct tp_finger *f = 0; | ||
| 440 | int p = 0, n = 0; | ||
| 441 | |||
| 442 | if (size < 26 || (size - 26) % 28 != 0) | ||
| 443 | return -EIO; | ||
| 444 | |||
| 445 | if (fingers) { | ||
| 446 | f = dev->tp_data->finger; | ||
| 447 | p = raw2int(f->force_major); | ||
| 448 | n = p > 0 ? fingers : 0; | ||
| 449 | } | ||
| 299 | 450 | ||
| 300 | input_report_key(input, BTN_TOOL_FINGER, n == 1); | 451 | switch (driver_mode) { |
| 301 | input_report_key(input, BTN_TOOL_DOUBLETAP, n == 2); | 452 | case MODE_MOUSE: |
| 302 | input_report_key(input, BTN_TOOL_TRIPLETAP, n > 2); | 453 | update_tp_mouse_state(dev->input, &dev->ms, c, f, p, n); |
| 454 | break; | ||
| 455 | case MODE_TOUCHPAD: | ||
| 456 | update_tp_touchpad_state(dev->input, c, f, p, n); | ||
| 457 | break; | ||
| 458 | } | ||
| 303 | 459 | ||
| 304 | input_sync(input); | 460 | input_sync(dev->input); |
| 305 | 461 | ||
| 306 | return 0; | 462 | return 0; |
| 307 | } | 463 | } |
| @@ -1,5 +1,5 @@ | |||
| 1 | PACKAGE_NAME="bcm5974" | 1 | PACKAGE_NAME="bcm5974" |
| 2 | PACKAGE_VERSION="0.59" | 2 | PACKAGE_VERSION="0.60" |
| 3 | MAKE[0]="make -C ${kernel_source_dir} | 3 | MAKE[0]="make -C ${kernel_source_dir} |
| 4 | SUBDIRS=${dkms_tree}/${PACKAGE_NAME}/${PACKAGE_VERSION}/build modules" | 4 | SUBDIRS=${dkms_tree}/${PACKAGE_NAME}/${PACKAGE_VERSION}/build modules" |
| 5 | BUILT_MODULE_NAME[0]="bcm5974" | 5 | BUILT_MODULE_NAME[0]="bcm5974" |
diff --git a/etc/modprobe.d/bcm5974 b/etc/modprobe.d/bcm5974 index 81cd5ce..8a0e017 100644 --- a/etc/modprobe.d/bcm5974 +++ b/etc/modprobe.d/bcm5974 | |||
| @@ -8,3 +8,18 @@ | |||
| 8 | 8 | ||
| 9 | ## Debug level - uncomment this to get raw packets in /var/log/debug | 9 | ## Debug level - uncomment this to get raw packets in /var/log/debug |
| 10 | #options bcm5974 debug=99 | 10 | #options bcm5974 debug=99 |
| 11 | |||
| 12 | ## Driver mode: 1 - mouse; 2 - touchpad | ||
| 13 | options bcm5974 driver_mode=2 | ||
| 14 | |||
| 15 | ## Mouse motion damping | ||
| 16 | #options bcm5974 mouse_motion_damping=8 | ||
| 17 | |||
| 18 | ## Vertical mouse wheel damping | ||
| 19 | #options bcm5974 mouse_wheel_damping=256 | ||
| 20 | |||
| 21 | ## Horizontal mouse wheel damping | ||
| 22 | #options bcm5974 mouse_hwheel_damping=256 | ||
| 23 | |||
| 24 | ## Mouse button mode: 0 - standard; 1 - unix three-button; 2 - mac three-button | ||
| 25 | #options bcm5974 mouse_button_mode=2 | ||
