diff options
| -rw-r--r-- | CHANGES | 7 | ||||
| -rw-r--r-- | bcm5974-dkms-mkdeb/debian/changelog | 3 | ||||
| -rw-r--r-- | bcm5974.c | 240 | ||||
| -rw-r--r-- | dkms.conf | 2 | ||||
| -rw-r--r-- | etc/modprobe.d/bcm5974 | 15 |
5 files changed, 48 insertions, 219 deletions
| @@ -1,3 +1,10 @@ | |||
| 1 | bcm5974 (0.62) unstable; urgency=low | ||
| 2 | |||
| 3 | * Compatibility mode reverted | ||
| 4 | * BTN_TOUCH event added for mousedev | ||
| 5 | |||
| 6 | -- Henrik Rydberg <rydberg@euromail.se> Tue, 02 Sep 2008 20:46:51 +0200 | ||
| 7 | |||
| 1 | bcm5974 (0.61) unstable; urgency=low | 8 | bcm5974 (0.61) unstable; urgency=low |
| 2 | 9 | ||
| 3 | * Smoother motion in mouse interface | 10 | * Smoother motion in mouse interface |
diff --git a/bcm5974-dkms-mkdeb/debian/changelog b/bcm5974-dkms-mkdeb/debian/changelog index 1ab2521..ccb4bc3 100644 --- a/bcm5974-dkms-mkdeb/debian/changelog +++ b/bcm5974-dkms-mkdeb/debian/changelog | |||
| @@ -1,5 +1,6 @@ | |||
| 1 | MODULE_NAME-dkms (MODULE_VERSION) unstable; urgency=low | 1 | MODULE_NAME-dkms (MODULE_VERSION) unstable; urgency=low |
| 2 | 2 | ||
| 3 | * Smoother motion in mouse interface | 3 | * Compatibility mode reverted |
| 4 | * BTN_TOUCH event added for mousedev | ||
| 4 | 5 | ||
| 5 | -- Henrik Rydberg <rydberg@euromail.se> DATE_STAMP | 6 | -- Henrik Rydberg <rydberg@euromail.se> DATE_STAMP |
| @@ -84,33 +84,10 @@ 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 | |||
| 90 | static int debug = 1; | 87 | static int debug = 1; |
| 91 | module_param(debug, int, 0644); | 88 | module_param(debug, int, 0644); |
| 92 | MODULE_PARM_DESC(debug, "Activate debugging output"); | 89 | MODULE_PARM_DESC(debug, "Activate debugging output"); |
| 93 | 90 | ||
| 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 | |||
| 114 | /* button data structure */ | 91 | /* button data structure */ |
| 115 | struct bt_data { | 92 | struct bt_data { |
| 116 | u8 unknown1; /* constant */ | 93 | u8 unknown1; /* constant */ |
| @@ -169,15 +146,6 @@ struct bcm5974_config { | |||
| 169 | struct bcm5974_param y; /* vertical limits */ | 146 | struct bcm5974_param y; /* vertical limits */ |
| 170 | }; | 147 | }; |
| 171 | 148 | ||
| 172 | /* mouse driver state */ | ||
| 173 | struct bcm5974_mouse_state { | ||
| 174 | int fingers; /* number of fingers on trackpad */ | ||
| 175 | int rel_x; /* horizontal relative counter */ | ||
| 176 | int rel_y; /* vertical relative counter */ | ||
| 177 | int wheel_x; /* horizontal wheel counter */ | ||
| 178 | int wheel_y; /* vertical wheel counter */ | ||
| 179 | }; | ||
| 180 | |||
| 181 | /* logical device structure */ | 149 | /* logical device structure */ |
| 182 | struct bcm5974 { | 150 | struct bcm5974 { |
| 183 | char phys[64]; | 151 | char phys[64]; |
| @@ -191,7 +159,6 @@ struct bcm5974 { | |||
| 191 | struct bt_data *bt_data; /* button transferred data */ | 159 | struct bt_data *bt_data; /* button transferred data */ |
| 192 | struct urb *tp_urb; /* trackpad usb request block */ | 160 | struct urb *tp_urb; /* trackpad usb request block */ |
| 193 | struct tp_data *tp_data; /* trackpad transferred data */ | 161 | struct tp_data *tp_data; /* trackpad transferred data */ |
| 194 | struct bcm5974_mouse_state ms; /* mouse state */ | ||
| 195 | }; | 162 | }; |
| 196 | 163 | ||
| 197 | /* logical dimensions */ | 164 | /* logical dimensions */ |
| @@ -270,204 +237,73 @@ static inline int int2bound(const struct bcm5974_param *p, int x) | |||
| 270 | static void setup_events_to_report(struct input_dev *input_dev, | 237 | static void setup_events_to_report(struct input_dev *input_dev, |
| 271 | const struct bcm5974_config *cfg) | 238 | const struct bcm5974_config *cfg) |
| 272 | { | 239 | { |
| 273 | __set_bit(EV_KEY, input_dev->evbit); | 240 | __set_bit(EV_ABS, input_dev->evbit); |
| 274 | __set_bit(BTN_LEFT, input_dev->keybit); | ||
| 275 | 241 | ||
| 276 | switch (driver_mode) { | 242 | input_set_abs_params(input_dev, ABS_PRESSURE, |
| 277 | case MODE_MOUSE: | 243 | 0, cfg->p.dim, cfg->p.fuzz, 0); |
| 278 | __set_bit(EV_REL, input_dev->evbit); | 244 | input_set_abs_params(input_dev, ABS_TOOL_WIDTH, |
| 279 | __set_bit(REL_X, input_dev->relbit); | 245 | 0, cfg->w.dim, cfg->w.fuzz, 0); |
| 280 | __set_bit(REL_Y, input_dev->relbit); | 246 | input_set_abs_params(input_dev, ABS_X, |
| 281 | __set_bit(REL_HWHEEL, input_dev->relbit); | 247 | 0, cfg->x.dim, cfg->x.fuzz, 0); |
| 282 | __set_bit(REL_WHEEL, input_dev->relbit); | 248 | input_set_abs_params(input_dev, ABS_Y, |
| 283 | __set_bit(BTN_MIDDLE, input_dev->keybit); | 249 | 0, cfg->y.dim, cfg->y.fuzz, 0); |
| 284 | __set_bit(BTN_RIGHT, input_dev->keybit); | ||
| 285 | break; | ||
| 286 | case MODE_TOUCHPAD: | ||
| 287 | __set_bit(EV_ABS, input_dev->evbit); | ||
| 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 | |||
| 292 | input_set_abs_params(input_dev, ABS_PRESSURE, | ||
| 293 | 0, cfg->p.dim, cfg->p.fuzz, 0); | ||
| 294 | input_set_abs_params(input_dev, ABS_TOOL_WIDTH, | ||
| 295 | 0, cfg->w.dim, cfg->w.fuzz, 0); | ||
| 296 | input_set_abs_params(input_dev, ABS_X, | ||
| 297 | 0, cfg->x.dim, cfg->x.fuzz, 0); | ||
| 298 | input_set_abs_params(input_dev, ABS_Y, | ||
| 299 | 0, cfg->y.dim, cfg->y.fuzz, 0); | ||
| 300 | break; | ||
| 301 | } | ||
| 302 | } | ||
| 303 | 250 | ||
| 304 | /* update logical mouse button state */ | 251 | __set_bit(EV_KEY, input_dev->evbit); |
| 305 | static void update_bt_mouse_state(struct input_dev *dev, | 252 | __set_bit(BTN_TOUCH, input_dev->keybit); |
| 306 | const struct bcm5974_mouse_state *ms, | 253 | __set_bit(BTN_TOOL_FINGER, input_dev->keybit); |
| 307 | const struct bt_data *bt) | 254 | __set_bit(BTN_TOOL_DOUBLETAP, input_dev->keybit); |
| 308 | { | 255 | __set_bit(BTN_TOOL_TRIPLETAP, input_dev->keybit); |
| 309 | const int n = ms->fingers; | 256 | __set_bit(BTN_LEFT, input_dev->keybit); |
| 310 | |||
| 311 | bool left, middle, right; | ||
| 312 | switch (mouse_button_mode) { | ||
| 313 | case 1: | ||
| 314 | left = n <= 1 && bt->button; | ||
| 315 | middle = n == 2 && bt->button; | ||
| 316 | right = n >= 3 && bt->button; | ||
| 317 | break; | ||
| 318 | case 2: | ||
| 319 | left = n <= 1 && bt->button; | ||
| 320 | middle = n >= 3 && bt->button; | ||
| 321 | right = n == 2 && bt->button; | ||
| 322 | break; | ||
| 323 | default: | ||
| 324 | left = bt->button; | ||
| 325 | middle = false; | ||
| 326 | right = false; | ||
| 327 | break; | ||
| 328 | }; | ||
| 329 | input_report_key(dev, BTN_LEFT, left); | ||
| 330 | input_report_key(dev, BTN_MIDDLE, middle); | ||
| 331 | input_report_key(dev, BTN_RIGHT, right); | ||
| 332 | } | ||
| 333 | |||
| 334 | /* update logical touchpad button state */ | ||
| 335 | static void update_bt_touchpad_state(struct input_dev *dev, | ||
| 336 | const struct bt_data *bt) | ||
| 337 | { | ||
| 338 | input_report_key(dev, BTN_LEFT, bt->button); | ||
| 339 | } | 257 | } |
| 340 | 258 | ||
| 341 | /* report button data as logical mouse/touchpad button state */ | 259 | /* report button data as logical button state */ |
| 342 | static int report_bt_state(struct bcm5974 *dev, int size) | 260 | static int report_bt_state(struct bcm5974 *dev, int size) |
| 343 | { | 261 | { |
| 344 | if (size != sizeof(struct bt_data)) | 262 | if (size != sizeof(struct bt_data)) |
| 345 | return -EIO; | 263 | return -EIO; |
| 346 | 264 | ||
| 347 | switch (driver_mode) { | 265 | input_report_key(dev->input, BTN_LEFT, dev->bt_data->button); |
| 348 | case MODE_MOUSE: | ||
| 349 | update_bt_mouse_state(dev->input, &dev->ms, dev->bt_data); | ||
| 350 | break; | ||
| 351 | case MODE_TOUCHPAD: | ||
| 352 | update_bt_touchpad_state(dev->input, dev->bt_data); | ||
| 353 | break; | ||
| 354 | } | ||
| 355 | |||
| 356 | input_sync(dev->input); | 266 | input_sync(dev->input); |
| 357 | 267 | ||
| 358 | return 0; | 268 | return 0; |
| 359 | } | 269 | } |
| 360 | 270 | ||
| 361 | /* update logical mouse motion state */ | 271 | /* report trackpad data as logical trackpad state */ |
| 362 | static void update_tp_mouse_state(struct input_dev *dev, | 272 | static int report_tp_state(struct bcm5974 *dev, int size) |
| 363 | struct bcm5974_mouse_state *ms, | ||
| 364 | const struct bcm5974_config *c, | ||
| 365 | const struct tp_finger *f, | ||
| 366 | int p, int n) | ||
| 367 | { | 273 | { |
| 368 | int dx = 0, dy = 0, sx = 0, sy = 0, swx = 0, swy = 0; | 274 | const struct bcm5974_config *c = &dev->cfg; |
| 369 | 275 | const struct tp_finger *f = dev->tp_data->finger; | |
| 370 | if (f) { | 276 | struct input_dev *input = dev->input; |
| 371 | dx = raw2int(f->rel_x); | 277 | const int fingers = (size - 26) / 28; |
| 372 | dy = raw2int(f->rel_y); | 278 | int p = 0, w, x, y, n = 0; |
| 373 | |||
| 374 | dprintk(9, | ||
| 375 | "bcm5974: p: %+05d dx: %+05d dy: %+05d n: %d\n", | ||
| 376 | p, dx, dy, n); | ||
| 377 | } | ||
| 378 | |||
| 379 | if (n >= 3) { | ||
| 380 | /* swipe */ | ||
| 381 | ms->rel_x = 0; | ||
| 382 | ms->rel_y = 0; | ||
| 383 | ms->wheel_x += int2scale(&c->x, dx); | ||
| 384 | ms->wheel_y = 0; | ||
| 385 | swx = ms->wheel_x / mouse_hwheel_damping; | ||
| 386 | ms->wheel_x -= swx * mouse_hwheel_damping; | ||
| 387 | } else if (n == 2) { | ||
| 388 | /* scroll */ | ||
| 389 | ms->rel_x = 0; | ||
| 390 | ms->rel_y = 0; | ||
| 391 | ms->wheel_x = 0; | ||
| 392 | ms->wheel_y += int2scale(&c->y, dy); | ||
| 393 | swy = ms->wheel_y / mouse_wheel_damping; | ||
| 394 | ms->wheel_y -= swy * mouse_wheel_damping; | ||
| 395 | } else { | ||
| 396 | /* pointer */ | ||
| 397 | ms->rel_x += int2scale(&c->x, dx); | ||
| 398 | ms->rel_y += int2scale(&c->y, -dy); | ||
| 399 | ms->wheel_x = 0; | ||
| 400 | ms->wheel_y = 0; | ||
| 401 | sx = ms->rel_x / mouse_motion_damping; | ||
| 402 | sy = ms->rel_y / mouse_motion_damping; | ||
| 403 | ms->rel_x -= sx * mouse_motion_damping; | ||
| 404 | ms->rel_y -= sy * mouse_motion_damping; | ||
| 405 | } | ||
| 406 | |||
| 407 | ms->fingers = n; | ||
| 408 | |||
| 409 | input_report_rel(dev, REL_X, sx); | ||
| 410 | input_report_rel(dev, REL_Y, sy); | ||
| 411 | input_report_rel(dev, REL_HWHEEL, swx); | ||
| 412 | input_report_rel(dev, REL_WHEEL, swy); | ||
| 413 | } | ||
| 414 | 279 | ||
| 415 | /* update logical touchpad state */ | 280 | if (size < 26 || (size - 26) % 28 != 0) |
| 416 | static void update_tp_touchpad_state(struct input_dev *dev, | 281 | return -EIO; |
| 417 | const struct bcm5974_config *c, | ||
| 418 | const struct tp_finger *f, | ||
| 419 | int p, int n) | ||
| 420 | { | ||
| 421 | int w, x, y; | ||
| 422 | 282 | ||
| 423 | if (f) { | 283 | if (fingers) { |
| 284 | p = raw2int(f->force_major); | ||
| 424 | w = raw2int(f->size_major); | 285 | w = raw2int(f->size_major); |
| 425 | x = raw2int(f->abs_x); | 286 | x = raw2int(f->abs_x); |
| 426 | y = raw2int(f->abs_y); | 287 | y = raw2int(f->abs_y); |
| 288 | n = p > 0 ? fingers : 0; | ||
| 427 | 289 | ||
| 428 | dprintk(9, | 290 | dprintk(9, |
| 429 | "bcm5974: p: %+05d w: %+05d x: %+05d y: %+05d n: %d\n", | 291 | "bcm5974: p: %+05d w: %+05d x: %+05d y: %+05d n: %d\n", |
| 430 | p, w, x, y, n); | 292 | p, w, x, y, n); |
| 431 | 293 | ||
| 432 | input_report_abs(dev, ABS_TOOL_WIDTH, int2bound(&c->w, w)); | 294 | input_report_abs(input, ABS_TOOL_WIDTH, int2bound(&c->w, w)); |
| 433 | input_report_abs(dev, ABS_X, int2bound(&c->x, x - c->x.devmin)); | 295 | input_report_abs(input, ABS_X, int2bound(&c->x, x - c->x.devmin)); |
| 434 | input_report_abs(dev, ABS_Y, int2bound(&c->y, c->y.devmax - y)); | 296 | input_report_abs(input, ABS_Y, int2bound(&c->y, c->y.devmax - y)); |
| 435 | } | 297 | } |
| 436 | 298 | ||
| 437 | input_report_abs(dev, ABS_PRESSURE, int2bound(&c->p, p)); | 299 | input_report_abs(input, ABS_PRESSURE, int2bound(&c->p, p)); |
| 438 | |||
| 439 | input_report_key(dev, BTN_TOOL_FINGER, n == 1); | ||
| 440 | input_report_key(dev, BTN_TOOL_DOUBLETAP, n == 2); | ||
| 441 | input_report_key(dev, BTN_TOOL_TRIPLETAP, n > 2); | ||
| 442 | } | ||
| 443 | |||
| 444 | /* report trackpad data as logical mouse/touchpad state */ | ||
| 445 | static int report_tp_state(struct bcm5974 *dev, int size) | ||
| 446 | { | ||
| 447 | const struct bcm5974_config *c = &dev->cfg; | ||
| 448 | const int fingers = (size - 26) / 28; | ||
| 449 | const struct tp_finger *f = 0; | ||
| 450 | int p = 0, n = 0; | ||
| 451 | |||
| 452 | if (size < 26 || (size - 26) % 28 != 0) | ||
| 453 | return -EIO; | ||
| 454 | |||
| 455 | if (fingers) { | ||
| 456 | f = dev->tp_data->finger; | ||
| 457 | p = raw2int(f->force_major); | ||
| 458 | n = p > 0 ? fingers : 0; | ||
| 459 | } | ||
| 460 | 300 | ||
| 461 | switch (driver_mode) { | 301 | input_report_key(input, BTN_TOUCH, p > 0); |
| 462 | case MODE_MOUSE: | 302 | input_report_key(input, BTN_TOOL_FINGER, n == 1); |
| 463 | update_tp_mouse_state(dev->input, &dev->ms, c, f, p, n); | 303 | input_report_key(input, BTN_TOOL_DOUBLETAP, n == 2); |
| 464 | break; | 304 | input_report_key(input, BTN_TOOL_TRIPLETAP, n > 2); |
| 465 | case MODE_TOUCHPAD: | ||
| 466 | update_tp_touchpad_state(dev->input, c, f, p, n); | ||
| 467 | break; | ||
| 468 | } | ||
| 469 | 305 | ||
| 470 | input_sync(dev->input); | 306 | input_sync(input); |
| 471 | 307 | ||
| 472 | return 0; | 308 | return 0; |
| 473 | } | 309 | } |
| @@ -1,5 +1,5 @@ | |||
| 1 | PACKAGE_NAME="bcm5974" | 1 | PACKAGE_NAME="bcm5974" |
| 2 | PACKAGE_VERSION="0.61" | 2 | PACKAGE_VERSION="0.62" |
| 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 8a0e017..81cd5ce 100644 --- a/etc/modprobe.d/bcm5974 +++ b/etc/modprobe.d/bcm5974 | |||
| @@ -8,18 +8,3 @@ | |||
| 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 | ||
