diff options
author | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2008-10-15 23:29:12 -0400 |
---|---|---|
committer | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2008-10-15 23:29:12 -0400 |
commit | 4c0e799a9a6dc64426ddb6c03aea1a154357658f (patch) | |
tree | 2d9aa9493d80fceb178a63bf15bb3d9edfc5fbae /drivers/input/mouse | |
parent | 3fa8749e584b55f1180411ab1b51117190bac1e5 (diff) | |
parent | b8d055a878ee0f997ded40649701089d2486f850 (diff) |
Merge branch 'next' into for-linus
Diffstat (limited to 'drivers/input/mouse')
-rw-r--r-- | drivers/input/mouse/Kconfig | 10 | ||||
-rw-r--r-- | drivers/input/mouse/Makefile | 1 | ||||
-rw-r--r-- | drivers/input/mouse/alps.c | 1 | ||||
-rw-r--r-- | drivers/input/mouse/appletouch.c | 299 | ||||
-rw-r--r-- | drivers/input/mouse/hgpk.c | 477 | ||||
-rw-r--r-- | drivers/input/mouse/hgpk.h | 49 | ||||
-rw-r--r-- | drivers/input/mouse/logips2pp.c | 4 | ||||
-rw-r--r-- | drivers/input/mouse/psmouse-base.c | 81 | ||||
-rw-r--r-- | drivers/input/mouse/psmouse.h | 14 | ||||
-rw-r--r-- | drivers/input/mouse/trackpoint.c | 8 |
10 files changed, 827 insertions, 117 deletions
diff --git a/drivers/input/mouse/Kconfig b/drivers/input/mouse/Kconfig index f996546fc443..f488b6852baf 100644 --- a/drivers/input/mouse/Kconfig +++ b/drivers/input/mouse/Kconfig | |||
@@ -96,6 +96,16 @@ config MOUSE_PS2_TOUCHKIT | |||
96 | 96 | ||
97 | If unsure, say N. | 97 | If unsure, say N. |
98 | 98 | ||
99 | config MOUSE_PS2_OLPC | ||
100 | bool "OLPC PS/2 mouse protocol extension" | ||
101 | depends on MOUSE_PS2 && OLPC | ||
102 | help | ||
103 | Say Y here if you have an OLPC XO-1 laptop (with built-in | ||
104 | PS/2 touchpad/tablet device). The manufacturer calls the | ||
105 | touchpad an HGPK. | ||
106 | |||
107 | If unsure, say N. | ||
108 | |||
99 | config MOUSE_SERIAL | 109 | config MOUSE_SERIAL |
100 | tristate "Serial mouse" | 110 | tristate "Serial mouse" |
101 | select SERIO | 111 | select SERIO |
diff --git a/drivers/input/mouse/Makefile b/drivers/input/mouse/Makefile index d4d202516090..8e6e69097801 100644 --- a/drivers/input/mouse/Makefile +++ b/drivers/input/mouse/Makefile | |||
@@ -21,6 +21,7 @@ obj-$(CONFIG_MOUSE_GPIO) += gpio_mouse.o | |||
21 | psmouse-objs := psmouse-base.o synaptics.o | 21 | psmouse-objs := psmouse-base.o synaptics.o |
22 | 22 | ||
23 | psmouse-$(CONFIG_MOUSE_PS2_ALPS) += alps.o | 23 | psmouse-$(CONFIG_MOUSE_PS2_ALPS) += alps.o |
24 | psmouse-$(CONFIG_MOUSE_PS2_OLPC) += hgpk.o | ||
24 | psmouse-$(CONFIG_MOUSE_PS2_LOGIPS2PP) += logips2pp.o | 25 | psmouse-$(CONFIG_MOUSE_PS2_LOGIPS2PP) += logips2pp.o |
25 | psmouse-$(CONFIG_MOUSE_PS2_LIFEBOOK) += lifebook.o | 26 | psmouse-$(CONFIG_MOUSE_PS2_LIFEBOOK) += lifebook.o |
26 | psmouse-$(CONFIG_MOUSE_PS2_TRACKPOINT) += trackpoint.o | 27 | psmouse-$(CONFIG_MOUSE_PS2_TRACKPOINT) += trackpoint.o |
diff --git a/drivers/input/mouse/alps.c b/drivers/input/mouse/alps.c index 385e32bcf6a6..cbedf957cc58 100644 --- a/drivers/input/mouse/alps.c +++ b/drivers/input/mouse/alps.c | |||
@@ -54,6 +54,7 @@ static const struct alps_model_info alps_model_data[] = { | |||
54 | { { 0x20, 0x02, 0x0e }, 0xf8, 0xf8, ALPS_PASS | ALPS_DUALPOINT }, /* XXX */ | 54 | { { 0x20, 0x02, 0x0e }, 0xf8, 0xf8, ALPS_PASS | ALPS_DUALPOINT }, /* XXX */ |
55 | { { 0x22, 0x02, 0x0a }, 0xf8, 0xf8, ALPS_PASS | ALPS_DUALPOINT }, | 55 | { { 0x22, 0x02, 0x0a }, 0xf8, 0xf8, ALPS_PASS | ALPS_DUALPOINT }, |
56 | { { 0x22, 0x02, 0x14 }, 0xff, 0xff, ALPS_PASS | ALPS_DUALPOINT }, /* Dell Latitude D600 */ | 56 | { { 0x22, 0x02, 0x14 }, 0xff, 0xff, ALPS_PASS | ALPS_DUALPOINT }, /* Dell Latitude D600 */ |
57 | { { 0x62, 0x02, 0x14 }, 0xcf, 0xcf, ALPS_PASS | ALPS_DUALPOINT }, /* Dell Latitude E6500 */ | ||
57 | { { 0x73, 0x02, 0x50 }, 0xcf, 0xcf, ALPS_FW_BK_1 } /* Dell Vostro 1400 */ | 58 | { { 0x73, 0x02, 0x50 }, 0xcf, 0xcf, ALPS_FW_BK_1 } /* Dell Vostro 1400 */ |
58 | }; | 59 | }; |
59 | 60 | ||
diff --git a/drivers/input/mouse/appletouch.c b/drivers/input/mouse/appletouch.c index 1f41ae94f26b..079816e6b23b 100644 --- a/drivers/input/mouse/appletouch.c +++ b/drivers/input/mouse/appletouch.c | |||
@@ -136,12 +136,28 @@ MODULE_DEVICE_TABLE(usb, atp_table); | |||
136 | #define ATP_GEYSER_MODE_REQUEST_INDEX 0 | 136 | #define ATP_GEYSER_MODE_REQUEST_INDEX 0 |
137 | #define ATP_GEYSER_MODE_VENDOR_VALUE 0x04 | 137 | #define ATP_GEYSER_MODE_VENDOR_VALUE 0x04 |
138 | 138 | ||
139 | /** | ||
140 | * enum atp_status_bits - status bit meanings | ||
141 | * | ||
142 | * These constants represent the meaning of the status bits. | ||
143 | * (only Geyser 3/4) | ||
144 | * | ||
145 | * @ATP_STATUS_BUTTON: The button was pressed | ||
146 | * @ATP_STATUS_BASE_UPDATE: Update of the base values (untouched pad) | ||
147 | * @ATP_STATUS_FROM_RESET: Reset previously performed | ||
148 | */ | ||
149 | enum atp_status_bits { | ||
150 | ATP_STATUS_BUTTON = BIT(0), | ||
151 | ATP_STATUS_BASE_UPDATE = BIT(2), | ||
152 | ATP_STATUS_FROM_RESET = BIT(4), | ||
153 | }; | ||
154 | |||
139 | /* Structure to hold all of our device specific stuff */ | 155 | /* Structure to hold all of our device specific stuff */ |
140 | struct atp { | 156 | struct atp { |
141 | char phys[64]; | 157 | char phys[64]; |
142 | struct usb_device *udev; /* usb device */ | 158 | struct usb_device *udev; /* usb device */ |
143 | struct urb *urb; /* usb request block */ | 159 | struct urb *urb; /* usb request block */ |
144 | signed char *data; /* transferred data */ | 160 | u8 *data; /* transferred data */ |
145 | struct input_dev *input; /* input dev */ | 161 | struct input_dev *input; /* input dev */ |
146 | enum atp_touchpad_type type; /* type of touchpad */ | 162 | enum atp_touchpad_type type; /* type of touchpad */ |
147 | bool open; | 163 | bool open; |
@@ -251,8 +267,6 @@ static void atp_reinit(struct work_struct *work) | |||
251 | int retval; | 267 | int retval; |
252 | 268 | ||
253 | dprintk("appletouch: putting appletouch to sleep (reinit)\n"); | 269 | dprintk("appletouch: putting appletouch to sleep (reinit)\n"); |
254 | dev->idlecount = 0; | ||
255 | |||
256 | atp_geyser_init(udev); | 270 | atp_geyser_init(udev); |
257 | 271 | ||
258 | retval = usb_submit_urb(dev->urb, GFP_ATOMIC); | 272 | retval = usb_submit_urb(dev->urb, GFP_ATOMIC); |
@@ -327,11 +341,14 @@ static inline void atp_report_fingers(struct input_dev *input, int fingers) | |||
327 | input_report_key(input, BTN_TOOL_TRIPLETAP, fingers > 2); | 341 | input_report_key(input, BTN_TOOL_TRIPLETAP, fingers > 2); |
328 | } | 342 | } |
329 | 343 | ||
330 | static void atp_complete(struct urb *urb) | 344 | /* Check URB status and for correct length of data package */ |
345 | |||
346 | #define ATP_URB_STATUS_SUCCESS 0 | ||
347 | #define ATP_URB_STATUS_ERROR 1 | ||
348 | #define ATP_URB_STATUS_ERROR_FATAL 2 | ||
349 | |||
350 | static int atp_status_check(struct urb *urb) | ||
331 | { | 351 | { |
332 | int x, y, x_z, y_z, x_f, y_f; | ||
333 | int retval, i, j; | ||
334 | int key; | ||
335 | struct atp *dev = urb->context; | 352 | struct atp *dev = urb->context; |
336 | 353 | ||
337 | switch (urb->status) { | 354 | switch (urb->status) { |
@@ -351,11 +368,12 @@ static void atp_complete(struct urb *urb) | |||
351 | /* This urb is terminated, clean up */ | 368 | /* This urb is terminated, clean up */ |
352 | dbg("atp_complete: urb shutting down with status: %d", | 369 | dbg("atp_complete: urb shutting down with status: %d", |
353 | urb->status); | 370 | urb->status); |
354 | return; | 371 | return ATP_URB_STATUS_ERROR_FATAL; |
372 | |||
355 | default: | 373 | default: |
356 | dbg("atp_complete: nonzero urb status received: %d", | 374 | dbg("atp_complete: nonzero urb status received: %d", |
357 | urb->status); | 375 | urb->status); |
358 | goto exit; | 376 | return ATP_URB_STATUS_ERROR; |
359 | } | 377 | } |
360 | 378 | ||
361 | /* drop incomplete datasets */ | 379 | /* drop incomplete datasets */ |
@@ -363,30 +381,33 @@ static void atp_complete(struct urb *urb) | |||
363 | dprintk("appletouch: incomplete data package" | 381 | dprintk("appletouch: incomplete data package" |
364 | " (first byte: %d, length: %d).\n", | 382 | " (first byte: %d, length: %d).\n", |
365 | dev->data[0], dev->urb->actual_length); | 383 | dev->data[0], dev->urb->actual_length); |
366 | goto exit; | 384 | return ATP_URB_STATUS_ERROR; |
367 | } | 385 | } |
368 | 386 | ||
369 | /* reorder the sensors values */ | 387 | return ATP_URB_STATUS_SUCCESS; |
370 | if (dev->type == ATP_GEYSER3 || dev->type == ATP_GEYSER4) { | 388 | } |
371 | memset(dev->xy_cur, 0, sizeof(dev->xy_cur)); | ||
372 | 389 | ||
373 | /* | 390 | /* |
374 | * The values are laid out like this: | 391 | * USB interrupt callback functions |
375 | * -, Y1, Y2, -, Y3, Y4, -, ..., -, X1, X2, -, X3, X4, ... | 392 | */ |
376 | * '-' is an unused value. | ||
377 | */ | ||
378 | 393 | ||
379 | /* read X values */ | 394 | /* Interrupt function for older touchpads: FOUNTAIN/GEYSER1/GEYSER2 */ |
380 | for (i = 0, j = 19; i < 20; i += 2, j += 3) { | 395 | |
381 | dev->xy_cur[i] = dev->data[j + 1]; | 396 | static void atp_complete_geyser_1_2(struct urb *urb) |
382 | dev->xy_cur[i + 1] = dev->data[j + 2]; | 397 | { |
383 | } | 398 | int x, y, x_z, y_z, x_f, y_f; |
384 | /* read Y values */ | 399 | int retval, i, j; |
385 | for (i = 0, j = 1; i < 9; i += 2, j += 3) { | 400 | int key; |
386 | dev->xy_cur[ATP_XSENSORS + i] = dev->data[j + 1]; | 401 | struct atp *dev = urb->context; |
387 | dev->xy_cur[ATP_XSENSORS + i + 1] = dev->data[j + 2]; | 402 | int status = atp_status_check(urb); |
388 | } | 403 | |
389 | } else if (dev->type == ATP_GEYSER2) { | 404 | if (status == ATP_URB_STATUS_ERROR_FATAL) |
405 | return; | ||
406 | else if (status == ATP_URB_STATUS_ERROR) | ||
407 | goto exit; | ||
408 | |||
409 | /* reorder the sensors values */ | ||
410 | if (dev->type == ATP_GEYSER2) { | ||
390 | memset(dev->xy_cur, 0, sizeof(dev->xy_cur)); | 411 | memset(dev->xy_cur, 0, sizeof(dev->xy_cur)); |
391 | 412 | ||
392 | /* | 413 | /* |
@@ -427,34 +448,40 @@ static void atp_complete(struct urb *urb) | |||
427 | /* first sample */ | 448 | /* first sample */ |
428 | dev->valid = true; | 449 | dev->valid = true; |
429 | dev->x_old = dev->y_old = -1; | 450 | dev->x_old = dev->y_old = -1; |
451 | |||
452 | /* Store first sample */ | ||
430 | memcpy(dev->xy_old, dev->xy_cur, sizeof(dev->xy_old)); | 453 | memcpy(dev->xy_old, dev->xy_cur, sizeof(dev->xy_old)); |
431 | 454 | ||
432 | if (dev->size_detect_done || | 455 | /* Perform size detection, if not done already */ |
433 | dev->type == ATP_GEYSER3) /* No 17" Macbooks (yet) */ | 456 | if (!dev->size_detect_done) { |
434 | goto exit; | 457 | |
458 | /* 17" Powerbooks have extra X sensors */ | ||
459 | for (i = (dev->type == ATP_GEYSER2 ? 15 : 16); | ||
460 | i < ATP_XSENSORS; i++) { | ||
461 | if (!dev->xy_cur[i]) | ||
462 | continue; | ||
463 | |||
464 | printk(KERN_INFO | ||
465 | "appletouch: 17\" model detected.\n"); | ||
466 | |||
467 | if (dev->type == ATP_GEYSER2) | ||
468 | input_set_abs_params(dev->input, ABS_X, | ||
469 | 0, | ||
470 | (20 - 1) * | ||
471 | ATP_XFACT - 1, | ||
472 | ATP_FUZZ, 0); | ||
473 | else | ||
474 | input_set_abs_params(dev->input, ABS_X, | ||
475 | 0, | ||
476 | (26 - 1) * | ||
477 | ATP_XFACT - 1, | ||
478 | ATP_FUZZ, 0); | ||
479 | break; | ||
480 | } | ||
435 | 481 | ||
436 | /* 17" Powerbooks have extra X sensors */ | 482 | dev->size_detect_done = 1; |
437 | for (i = (dev->type == ATP_GEYSER2 ? 15 : 16); | 483 | goto exit; |
438 | i < ATP_XSENSORS; i++) { | ||
439 | if (!dev->xy_cur[i]) | ||
440 | continue; | ||
441 | |||
442 | printk(KERN_INFO "appletouch: 17\" model detected.\n"); | ||
443 | if (dev->type == ATP_GEYSER2) | ||
444 | input_set_abs_params(dev->input, ABS_X, 0, | ||
445 | (20 - 1) * | ||
446 | ATP_XFACT - 1, | ||
447 | ATP_FUZZ, 0); | ||
448 | else | ||
449 | input_set_abs_params(dev->input, ABS_X, 0, | ||
450 | (ATP_XSENSORS - 1) * | ||
451 | ATP_XFACT - 1, | ||
452 | ATP_FUZZ, 0); | ||
453 | break; | ||
454 | } | 484 | } |
455 | |||
456 | dev->size_detect_done = 1; | ||
457 | goto exit; | ||
458 | } | 485 | } |
459 | 486 | ||
460 | for (i = 0; i < ATP_XSENSORS + ATP_YSENSORS; i++) { | 487 | for (i = 0; i < ATP_XSENSORS + ATP_YSENSORS; i++) { |
@@ -475,7 +502,118 @@ static void atp_complete(struct urb *urb) | |||
475 | ATP_XFACT, &x_z, &x_f); | 502 | ATP_XFACT, &x_z, &x_f); |
476 | y = atp_calculate_abs(dev->xy_acc + ATP_XSENSORS, ATP_YSENSORS, | 503 | y = atp_calculate_abs(dev->xy_acc + ATP_XSENSORS, ATP_YSENSORS, |
477 | ATP_YFACT, &y_z, &y_f); | 504 | ATP_YFACT, &y_z, &y_f); |
478 | key = dev->data[dev->datalen - 1] & 1; | 505 | key = dev->data[dev->datalen - 1] & ATP_STATUS_BUTTON; |
506 | |||
507 | if (x && y) { | ||
508 | if (dev->x_old != -1) { | ||
509 | x = (dev->x_old * 3 + x) >> 2; | ||
510 | y = (dev->y_old * 3 + y) >> 2; | ||
511 | dev->x_old = x; | ||
512 | dev->y_old = y; | ||
513 | |||
514 | if (debug > 1) | ||
515 | printk(KERN_DEBUG "appletouch: " | ||
516 | "X: %3d Y: %3d Xz: %3d Yz: %3d\n", | ||
517 | x, y, x_z, y_z); | ||
518 | |||
519 | input_report_key(dev->input, BTN_TOUCH, 1); | ||
520 | input_report_abs(dev->input, ABS_X, x); | ||
521 | input_report_abs(dev->input, ABS_Y, y); | ||
522 | input_report_abs(dev->input, ABS_PRESSURE, | ||
523 | min(ATP_PRESSURE, x_z + y_z)); | ||
524 | atp_report_fingers(dev->input, max(x_f, y_f)); | ||
525 | } | ||
526 | dev->x_old = x; | ||
527 | dev->y_old = y; | ||
528 | |||
529 | } else if (!x && !y) { | ||
530 | |||
531 | dev->x_old = dev->y_old = -1; | ||
532 | input_report_key(dev->input, BTN_TOUCH, 0); | ||
533 | input_report_abs(dev->input, ABS_PRESSURE, 0); | ||
534 | atp_report_fingers(dev->input, 0); | ||
535 | |||
536 | /* reset the accumulator on release */ | ||
537 | memset(dev->xy_acc, 0, sizeof(dev->xy_acc)); | ||
538 | } | ||
539 | |||
540 | input_report_key(dev->input, BTN_LEFT, key); | ||
541 | input_sync(dev->input); | ||
542 | |||
543 | exit: | ||
544 | retval = usb_submit_urb(dev->urb, GFP_ATOMIC); | ||
545 | if (retval) | ||
546 | err("atp_complete: usb_submit_urb failed with result %d", | ||
547 | retval); | ||
548 | } | ||
549 | |||
550 | /* Interrupt function for older touchpads: GEYSER3/GEYSER4 */ | ||
551 | |||
552 | static void atp_complete_geyser_3_4(struct urb *urb) | ||
553 | { | ||
554 | int x, y, x_z, y_z, x_f, y_f; | ||
555 | int retval, i, j; | ||
556 | int key; | ||
557 | struct atp *dev = urb->context; | ||
558 | int status = atp_status_check(urb); | ||
559 | |||
560 | if (status == ATP_URB_STATUS_ERROR_FATAL) | ||
561 | return; | ||
562 | else if (status == ATP_URB_STATUS_ERROR) | ||
563 | goto exit; | ||
564 | |||
565 | /* Reorder the sensors values: | ||
566 | * | ||
567 | * The values are laid out like this: | ||
568 | * -, Y1, Y2, -, Y3, Y4, -, ..., -, X1, X2, -, X3, X4, ... | ||
569 | * '-' is an unused value. | ||
570 | */ | ||
571 | |||
572 | /* read X values */ | ||
573 | for (i = 0, j = 19; i < 20; i += 2, j += 3) { | ||
574 | dev->xy_cur[i] = dev->data[j + 1]; | ||
575 | dev->xy_cur[i + 1] = dev->data[j + 2]; | ||
576 | } | ||
577 | /* read Y values */ | ||
578 | for (i = 0, j = 1; i < 9; i += 2, j += 3) { | ||
579 | dev->xy_cur[ATP_XSENSORS + i] = dev->data[j + 1]; | ||
580 | dev->xy_cur[ATP_XSENSORS + i + 1] = dev->data[j + 2]; | ||
581 | } | ||
582 | |||
583 | dbg_dump("sample", dev->xy_cur); | ||
584 | |||
585 | /* Just update the base values (i.e. touchpad in untouched state) */ | ||
586 | if (dev->data[dev->datalen - 1] & ATP_STATUS_BASE_UPDATE) { | ||
587 | |||
588 | dprintk(KERN_DEBUG "appletouch: updated base values\n"); | ||
589 | |||
590 | memcpy(dev->xy_old, dev->xy_cur, sizeof(dev->xy_old)); | ||
591 | goto exit; | ||
592 | } | ||
593 | |||
594 | for (i = 0; i < ATP_XSENSORS + ATP_YSENSORS; i++) { | ||
595 | /* calculate the change */ | ||
596 | dev->xy_acc[i] = dev->xy_cur[i] - dev->xy_old[i]; | ||
597 | |||
598 | /* this is a round-robin value, so couple with that */ | ||
599 | if (dev->xy_acc[i] > 127) | ||
600 | dev->xy_acc[i] -= 256; | ||
601 | |||
602 | if (dev->xy_acc[i] < -127) | ||
603 | dev->xy_acc[i] += 256; | ||
604 | |||
605 | /* prevent down drifting */ | ||
606 | if (dev->xy_acc[i] < 0) | ||
607 | dev->xy_acc[i] = 0; | ||
608 | } | ||
609 | |||
610 | dbg_dump("accumulator", dev->xy_acc); | ||
611 | |||
612 | x = atp_calculate_abs(dev->xy_acc, ATP_XSENSORS, | ||
613 | ATP_XFACT, &x_z, &x_f); | ||
614 | y = atp_calculate_abs(dev->xy_acc + ATP_XSENSORS, ATP_YSENSORS, | ||
615 | ATP_YFACT, &y_z, &y_f); | ||
616 | key = dev->data[dev->datalen - 1] & ATP_STATUS_BUTTON; | ||
479 | 617 | ||
480 | if (x && y) { | 618 | if (x && y) { |
481 | if (dev->x_old != -1) { | 619 | if (dev->x_old != -1) { |
@@ -514,28 +652,27 @@ static void atp_complete(struct urb *urb) | |||
514 | input_sync(dev->input); | 652 | input_sync(dev->input); |
515 | 653 | ||
516 | /* | 654 | /* |
517 | * Many Geysers will continue to send packets continually after | 655 | * Geysers 3/4 will continue to send packets continually after |
518 | * the first touch unless reinitialised. Do so if it's been | 656 | * the first touch unless reinitialised. Do so if it's been |
519 | * idle for a while in order to avoid waking the kernel up | 657 | * idle for a while in order to avoid waking the kernel up |
520 | * several hundred times a second. Re-initialization does not | 658 | * several hundred times a second. |
521 | * work on Fountain touchpads. | ||
522 | */ | 659 | */ |
523 | if (dev->type != ATP_FOUNTAIN) { | 660 | |
524 | /* | 661 | /* |
525 | * Button must not be pressed when entering suspend, | 662 | * Button must not be pressed when entering suspend, |
526 | * otherwise we will never release the button. | 663 | * otherwise we will never release the button. |
527 | */ | 664 | */ |
528 | if (!x && !y && !key) { | 665 | if (!x && !y && !key) { |
529 | dev->idlecount++; | 666 | dev->idlecount++; |
530 | if (dev->idlecount == 10) { | 667 | if (dev->idlecount == 10) { |
531 | dev->valid = false; | 668 | dev->x_old = dev->y_old = -1; |
532 | schedule_work(&dev->work); | ||
533 | /* Don't resubmit urb here, wait for reinit */ | ||
534 | return; | ||
535 | } | ||
536 | } else | ||
537 | dev->idlecount = 0; | 669 | dev->idlecount = 0; |
538 | } | 670 | schedule_work(&dev->work); |
671 | /* Don't resubmit urb here, wait for reinit */ | ||
672 | return; | ||
673 | } | ||
674 | } else | ||
675 | dev->idlecount = 0; | ||
539 | 676 | ||
540 | exit: | 677 | exit: |
541 | retval = usb_submit_urb(dev->urb, GFP_ATOMIC); | 678 | retval = usb_submit_urb(dev->urb, GFP_ATOMIC); |
@@ -632,9 +769,19 @@ static int atp_probe(struct usb_interface *iface, | |||
632 | if (!dev->data) | 769 | if (!dev->data) |
633 | goto err_free_urb; | 770 | goto err_free_urb; |
634 | 771 | ||
635 | usb_fill_int_urb(dev->urb, udev, | 772 | /* Select the USB complete (callback) function */ |
636 | usb_rcvintpipe(udev, int_in_endpointAddr), | 773 | if (dev->type == ATP_FOUNTAIN || |
637 | dev->data, dev->datalen, atp_complete, dev, 1); | 774 | dev->type == ATP_GEYSER1 || |
775 | dev->type == ATP_GEYSER2) | ||
776 | usb_fill_int_urb(dev->urb, udev, | ||
777 | usb_rcvintpipe(udev, int_in_endpointAddr), | ||
778 | dev->data, dev->datalen, | ||
779 | atp_complete_geyser_1_2, dev, 1); | ||
780 | else | ||
781 | usb_fill_int_urb(dev->urb, udev, | ||
782 | usb_rcvintpipe(udev, int_in_endpointAddr), | ||
783 | dev->data, dev->datalen, | ||
784 | atp_complete_geyser_3_4, dev, 1); | ||
638 | 785 | ||
639 | error = atp_handle_geyser(dev); | 786 | error = atp_handle_geyser(dev); |
640 | if (error) | 787 | if (error) |
@@ -751,8 +898,6 @@ static int atp_suspend(struct usb_interface *iface, pm_message_t message) | |||
751 | struct atp *dev = usb_get_intfdata(iface); | 898 | struct atp *dev = usb_get_intfdata(iface); |
752 | 899 | ||
753 | usb_kill_urb(dev->urb); | 900 | usb_kill_urb(dev->urb); |
754 | dev->valid = false; | ||
755 | |||
756 | return 0; | 901 | return 0; |
757 | } | 902 | } |
758 | 903 | ||
diff --git a/drivers/input/mouse/hgpk.c b/drivers/input/mouse/hgpk.c new file mode 100644 index 000000000000..e82d34201e97 --- /dev/null +++ b/drivers/input/mouse/hgpk.c | |||
@@ -0,0 +1,477 @@ | |||
1 | /* | ||
2 | * OLPC HGPK (XO-1) touchpad PS/2 mouse driver | ||
3 | * | ||
4 | * Copyright (c) 2006-2008 One Laptop Per Child | ||
5 | * Authors: | ||
6 | * Zephaniah E. Hull | ||
7 | * Andres Salomon <dilinger@debian.org> | ||
8 | * | ||
9 | * This driver is partly based on the ALPS driver, which is: | ||
10 | * | ||
11 | * Copyright (c) 2003 Neil Brown <neilb@cse.unsw.edu.au> | ||
12 | * Copyright (c) 2003-2005 Peter Osterlund <petero2@telia.com> | ||
13 | * Copyright (c) 2004 Dmitry Torokhov <dtor@mail.ru> | ||
14 | * Copyright (c) 2005 Vojtech Pavlik <vojtech@suse.cz> | ||
15 | * | ||
16 | * This program is free software; you can redistribute it and/or modify | ||
17 | * it under the terms of the GNU General Public License version 2 as | ||
18 | * published by the Free Software Foundation. | ||
19 | */ | ||
20 | |||
21 | /* | ||
22 | * The spec from ALPS is available from | ||
23 | * <http://wiki.laptop.org/go/Touch_Pad/Tablet>. It refers to this | ||
24 | * device as HGPK (Hybrid GS, PT, and Keymatrix). | ||
25 | * | ||
26 | * The earliest versions of the device had simultaneous reporting; that | ||
27 | * was removed. After that, the device used the Advanced Mode GS/PT streaming | ||
28 | * stuff. That turned out to be too buggy to support, so we've finally | ||
29 | * switched to Mouse Mode (which utilizes only the center 1/3 of the touchpad). | ||
30 | */ | ||
31 | |||
32 | #define DEBUG | ||
33 | #include <linux/input.h> | ||
34 | #include <linux/serio.h> | ||
35 | #include <linux/libps2.h> | ||
36 | #include <linux/delay.h> | ||
37 | #include <asm/olpc.h> | ||
38 | |||
39 | #include "psmouse.h" | ||
40 | #include "hgpk.h" | ||
41 | |||
42 | static int tpdebug; | ||
43 | module_param(tpdebug, int, 0644); | ||
44 | MODULE_PARM_DESC(tpdebug, "enable debugging, dumping packets to KERN_DEBUG."); | ||
45 | |||
46 | static int recalib_delta = 100; | ||
47 | module_param(recalib_delta, int, 0644); | ||
48 | MODULE_PARM_DESC(recalib_delta, | ||
49 | "packets containing a delta this large will cause a recalibration."); | ||
50 | |||
51 | /* | ||
52 | * When the touchpad gets ultra-sensitive, one can keep their finger 1/2" | ||
53 | * above the pad and still have it send packets. This causes a jump cursor | ||
54 | * when one places their finger on the pad. We can probably detect the | ||
55 | * jump as we see a large deltas (>= 100px). In mouse mode, I've been | ||
56 | * unable to even come close to 100px deltas during normal usage, so I think | ||
57 | * this threshold is safe. If a large delta occurs, trigger a recalibration. | ||
58 | */ | ||
59 | static void hgpk_jumpy_hack(struct psmouse *psmouse, int x, int y) | ||
60 | { | ||
61 | struct hgpk_data *priv = psmouse->private; | ||
62 | |||
63 | if (abs(x) > recalib_delta || abs(y) > recalib_delta) { | ||
64 | hgpk_err(psmouse, ">%dpx jump detected (%d,%d)\n", | ||
65 | recalib_delta, x, y); | ||
66 | /* My car gets forty rods to the hogshead and that's the | ||
67 | * way I likes it! */ | ||
68 | psmouse_queue_work(psmouse, &priv->recalib_wq, | ||
69 | msecs_to_jiffies(1000)); | ||
70 | } | ||
71 | } | ||
72 | |||
73 | /* | ||
74 | * We have no idea why this particular hardware bug occurs. The touchpad | ||
75 | * will randomly start spewing packets without anything touching the | ||
76 | * pad. This wouldn't necessarily be bad, but it's indicative of a | ||
77 | * severely miscalibrated pad; attempting to use the touchpad while it's | ||
78 | * spewing means the cursor will jump all over the place, and act "drunk". | ||
79 | * | ||
80 | * The packets that are spewed tend to all have deltas between -2 and 2, and | ||
81 | * the cursor will move around without really going very far. It will | ||
82 | * tend to end up in the same location; if we tally up the changes over | ||
83 | * 100 packets, we end up w/ a final delta of close to 0. This happens | ||
84 | * pretty regularly when the touchpad is spewing, and is pretty hard to | ||
85 | * manually trigger (at least for *my* fingers). So, it makes a perfect | ||
86 | * scheme for detecting spews. | ||
87 | */ | ||
88 | static void hgpk_spewing_hack(struct psmouse *psmouse, | ||
89 | int l, int r, int x, int y) | ||
90 | { | ||
91 | struct hgpk_data *priv = psmouse->private; | ||
92 | |||
93 | /* ignore button press packets; many in a row could trigger | ||
94 | * a false-positive! */ | ||
95 | if (l || r) | ||
96 | return; | ||
97 | |||
98 | priv->x_tally += x; | ||
99 | priv->y_tally += y; | ||
100 | |||
101 | if (++priv->count > 100) { | ||
102 | if (abs(priv->x_tally) < 3 && abs(priv->y_tally) < 3) { | ||
103 | hgpk_dbg(psmouse, "packet spew detected (%d,%d)\n", | ||
104 | priv->x_tally, priv->y_tally); | ||
105 | psmouse_queue_work(psmouse, &priv->recalib_wq, | ||
106 | msecs_to_jiffies(1000)); | ||
107 | } | ||
108 | /* reset every 100 packets */ | ||
109 | priv->count = 0; | ||
110 | priv->x_tally = 0; | ||
111 | priv->y_tally = 0; | ||
112 | } | ||
113 | } | ||
114 | |||
115 | /* | ||
116 | * HGPK Mouse Mode format (standard mouse format, sans middle button) | ||
117 | * | ||
118 | * byte 0: y-over x-over y-neg x-neg 1 0 swr swl | ||
119 | * byte 1: x7 x6 x5 x4 x3 x2 x1 x0 | ||
120 | * byte 2: y7 y6 y5 y4 y3 y2 y1 y0 | ||
121 | * | ||
122 | * swr/swl are the left/right buttons. | ||
123 | * x-neg/y-neg are the x and y delta negative bits | ||
124 | * x-over/y-over are the x and y overflow bits | ||
125 | */ | ||
126 | static int hgpk_validate_byte(unsigned char *packet) | ||
127 | { | ||
128 | return (packet[0] & 0x0C) == 0x08; | ||
129 | } | ||
130 | |||
131 | static void hgpk_process_packet(struct psmouse *psmouse) | ||
132 | { | ||
133 | struct input_dev *dev = psmouse->dev; | ||
134 | unsigned char *packet = psmouse->packet; | ||
135 | int x, y, left, right; | ||
136 | |||
137 | left = packet[0] & 1; | ||
138 | right = (packet[0] >> 1) & 1; | ||
139 | |||
140 | x = packet[1] - ((packet[0] << 4) & 0x100); | ||
141 | y = ((packet[0] << 3) & 0x100) - packet[2]; | ||
142 | |||
143 | hgpk_jumpy_hack(psmouse, x, y); | ||
144 | hgpk_spewing_hack(psmouse, left, right, x, y); | ||
145 | |||
146 | if (tpdebug) | ||
147 | hgpk_dbg(psmouse, "l=%d r=%d x=%d y=%d\n", left, right, x, y); | ||
148 | |||
149 | input_report_key(dev, BTN_LEFT, left); | ||
150 | input_report_key(dev, BTN_RIGHT, right); | ||
151 | |||
152 | input_report_rel(dev, REL_X, x); | ||
153 | input_report_rel(dev, REL_Y, y); | ||
154 | |||
155 | input_sync(dev); | ||
156 | } | ||
157 | |||
158 | static psmouse_ret_t hgpk_process_byte(struct psmouse *psmouse) | ||
159 | { | ||
160 | struct hgpk_data *priv = psmouse->private; | ||
161 | |||
162 | if (hgpk_validate_byte(psmouse->packet)) { | ||
163 | hgpk_dbg(psmouse, "%s: (%d) %02x %02x %02x\n", | ||
164 | __func__, psmouse->pktcnt, psmouse->packet[0], | ||
165 | psmouse->packet[1], psmouse->packet[2]); | ||
166 | return PSMOUSE_BAD_DATA; | ||
167 | } | ||
168 | |||
169 | if (psmouse->pktcnt >= psmouse->pktsize) { | ||
170 | hgpk_process_packet(psmouse); | ||
171 | return PSMOUSE_FULL_PACKET; | ||
172 | } | ||
173 | |||
174 | if (priv->recalib_window) { | ||
175 | if (time_before(jiffies, priv->recalib_window)) { | ||
176 | /* | ||
177 | * ugh, got a packet inside our recalibration | ||
178 | * window, schedule another recalibration. | ||
179 | */ | ||
180 | hgpk_dbg(psmouse, | ||
181 | "packet inside calibration window, " | ||
182 | "queueing another recalibration\n"); | ||
183 | psmouse_queue_work(psmouse, &priv->recalib_wq, | ||
184 | msecs_to_jiffies(1000)); | ||
185 | } | ||
186 | priv->recalib_window = 0; | ||
187 | } | ||
188 | |||
189 | return PSMOUSE_GOOD_DATA; | ||
190 | } | ||
191 | |||
192 | static int hgpk_force_recalibrate(struct psmouse *psmouse) | ||
193 | { | ||
194 | struct ps2dev *ps2dev = &psmouse->ps2dev; | ||
195 | struct hgpk_data *priv = psmouse->private; | ||
196 | |||
197 | /* C-series touchpads added the recalibrate command */ | ||
198 | if (psmouse->model < HGPK_MODEL_C) | ||
199 | return 0; | ||
200 | |||
201 | /* we don't want to race with the irq handler, nor with resyncs */ | ||
202 | psmouse_set_state(psmouse, PSMOUSE_INITIALIZING); | ||
203 | |||
204 | /* start by resetting the device */ | ||
205 | psmouse_reset(psmouse); | ||
206 | |||
207 | /* send the recalibrate request */ | ||
208 | if (ps2_command(ps2dev, NULL, 0xf5) || | ||
209 | ps2_command(ps2dev, NULL, 0xf5) || | ||
210 | ps2_command(ps2dev, NULL, 0xe6) || | ||
211 | ps2_command(ps2dev, NULL, 0xf5)) { | ||
212 | return -1; | ||
213 | } | ||
214 | |||
215 | /* according to ALPS, 150mS is required for recalibration */ | ||
216 | msleep(150); | ||
217 | |||
218 | /* XXX: If a finger is down during this delay, recalibration will | ||
219 | * detect capacitance incorrectly. This is a hardware bug, and | ||
220 | * we don't have a good way to deal with it. The 2s window stuff | ||
221 | * (below) is our best option for now. | ||
222 | */ | ||
223 | |||
224 | if (ps2_command(ps2dev, NULL, PSMOUSE_CMD_ENABLE)) | ||
225 | return -1; | ||
226 | |||
227 | psmouse_set_state(psmouse, PSMOUSE_ACTIVATED); | ||
228 | |||
229 | /* After we recalibrate, we shouldn't get any packets for 2s. If | ||
230 | * we do, it's likely that someone's finger was on the touchpad. | ||
231 | * If someone's finger *was* on the touchpad, it's probably | ||
232 | * miscalibrated. So, we should schedule another recalibration | ||
233 | */ | ||
234 | priv->recalib_window = jiffies + msecs_to_jiffies(2000); | ||
235 | |||
236 | return 0; | ||
237 | } | ||
238 | |||
239 | /* | ||
240 | * This kills power to the touchpad; according to ALPS, current consumption | ||
241 | * goes down to 50uA after running this. To turn power back on, we drive | ||
242 | * MS-DAT low. | ||
243 | */ | ||
244 | static int hgpk_toggle_power(struct psmouse *psmouse, int enable) | ||
245 | { | ||
246 | struct ps2dev *ps2dev = &psmouse->ps2dev; | ||
247 | int timeo; | ||
248 | |||
249 | /* Added on D-series touchpads */ | ||
250 | if (psmouse->model < HGPK_MODEL_D) | ||
251 | return 0; | ||
252 | |||
253 | if (enable) { | ||
254 | psmouse_set_state(psmouse, PSMOUSE_INITIALIZING); | ||
255 | |||
256 | /* | ||
257 | * Sending a byte will drive MS-DAT low; this will wake up | ||
258 | * the controller. Once we get an ACK back from it, it | ||
259 | * means we can continue with the touchpad re-init. ALPS | ||
260 | * tells us that 1s should be long enough, so set that as | ||
261 | * the upper bound. | ||
262 | */ | ||
263 | for (timeo = 20; timeo > 0; timeo--) { | ||
264 | if (!ps2_sendbyte(&psmouse->ps2dev, | ||
265 | PSMOUSE_CMD_DISABLE, 20)) | ||
266 | break; | ||
267 | msleep(50); | ||
268 | } | ||
269 | |||
270 | psmouse_reset(psmouse); | ||
271 | |||
272 | /* should be all set, enable the touchpad */ | ||
273 | ps2_command(&psmouse->ps2dev, NULL, PSMOUSE_CMD_ENABLE); | ||
274 | psmouse_set_state(psmouse, PSMOUSE_ACTIVATED); | ||
275 | |||
276 | } else { | ||
277 | hgpk_dbg(psmouse, "Powering off touchpad.\n"); | ||
278 | psmouse_set_state(psmouse, PSMOUSE_IGNORE); | ||
279 | |||
280 | if (ps2_command(ps2dev, NULL, 0xec) || | ||
281 | ps2_command(ps2dev, NULL, 0xec) || | ||
282 | ps2_command(ps2dev, NULL, 0xea)) { | ||
283 | return -1; | ||
284 | } | ||
285 | |||
286 | /* probably won't see an ACK, the touchpad will be off */ | ||
287 | ps2_sendbyte(&psmouse->ps2dev, 0xec, 20); | ||
288 | } | ||
289 | |||
290 | return 0; | ||
291 | } | ||
292 | |||
293 | static int hgpk_poll(struct psmouse *psmouse) | ||
294 | { | ||
295 | /* We can't poll, so always return failure. */ | ||
296 | return -1; | ||
297 | } | ||
298 | |||
299 | static int hgpk_reconnect(struct psmouse *psmouse) | ||
300 | { | ||
301 | /* During suspend/resume the ps2 rails remain powered. We don't want | ||
302 | * to do a reset because it's flush data out of buffers; however, | ||
303 | * earlier prototypes (B1) had some brokenness that required a reset. */ | ||
304 | if (olpc_board_at_least(olpc_board(0xb2))) | ||
305 | if (psmouse->ps2dev.serio->dev.power.power_state.event != | ||
306 | PM_EVENT_ON) | ||
307 | return 0; | ||
308 | |||
309 | psmouse_reset(psmouse); | ||
310 | |||
311 | return 0; | ||
312 | } | ||
313 | |||
314 | static ssize_t hgpk_show_powered(struct psmouse *psmouse, void *data, char *buf) | ||
315 | { | ||
316 | struct hgpk_data *priv = psmouse->private; | ||
317 | |||
318 | return sprintf(buf, "%d\n", priv->powered); | ||
319 | } | ||
320 | |||
321 | static ssize_t hgpk_set_powered(struct psmouse *psmouse, void *data, | ||
322 | const char *buf, size_t count) | ||
323 | { | ||
324 | struct hgpk_data *priv = psmouse->private; | ||
325 | unsigned long value; | ||
326 | int err; | ||
327 | |||
328 | err = strict_strtoul(buf, 10, &value); | ||
329 | if (err || value > 1) | ||
330 | return -EINVAL; | ||
331 | |||
332 | if (value != priv->powered) { | ||
333 | /* | ||
334 | * hgpk_toggle_power will deal w/ state so | ||
335 | * we're not racing w/ irq | ||
336 | */ | ||
337 | err = hgpk_toggle_power(psmouse, value); | ||
338 | if (!err) | ||
339 | priv->powered = value; | ||
340 | } | ||
341 | |||
342 | return err ? err : count; | ||
343 | } | ||
344 | |||
345 | __PSMOUSE_DEFINE_ATTR(powered, S_IWUSR | S_IRUGO, NULL, | ||
346 | hgpk_show_powered, hgpk_set_powered, 0); | ||
347 | |||
348 | static void hgpk_disconnect(struct psmouse *psmouse) | ||
349 | { | ||
350 | struct hgpk_data *priv = psmouse->private; | ||
351 | |||
352 | device_remove_file(&psmouse->ps2dev.serio->dev, | ||
353 | &psmouse_attr_powered.dattr); | ||
354 | psmouse_reset(psmouse); | ||
355 | kfree(priv); | ||
356 | } | ||
357 | |||
358 | static void hgpk_recalib_work(struct work_struct *work) | ||
359 | { | ||
360 | struct delayed_work *w = container_of(work, struct delayed_work, work); | ||
361 | struct hgpk_data *priv = container_of(w, struct hgpk_data, recalib_wq); | ||
362 | struct psmouse *psmouse = priv->psmouse; | ||
363 | |||
364 | hgpk_dbg(psmouse, "recalibrating touchpad..\n"); | ||
365 | |||
366 | if (hgpk_force_recalibrate(psmouse)) | ||
367 | hgpk_err(psmouse, "recalibration failed!\n"); | ||
368 | } | ||
369 | |||
370 | static int hgpk_register(struct psmouse *psmouse) | ||
371 | { | ||
372 | struct input_dev *dev = psmouse->dev; | ||
373 | int err; | ||
374 | |||
375 | /* unset the things that psmouse-base sets which we don't have */ | ||
376 | __clear_bit(BTN_MIDDLE, dev->keybit); | ||
377 | |||
378 | /* set the things we do have */ | ||
379 | __set_bit(EV_KEY, dev->evbit); | ||
380 | __set_bit(EV_REL, dev->evbit); | ||
381 | |||
382 | __set_bit(REL_X, dev->relbit); | ||
383 | __set_bit(REL_Y, dev->relbit); | ||
384 | |||
385 | __set_bit(BTN_LEFT, dev->keybit); | ||
386 | __set_bit(BTN_RIGHT, dev->keybit); | ||
387 | |||
388 | /* register handlers */ | ||
389 | psmouse->protocol_handler = hgpk_process_byte; | ||
390 | psmouse->poll = hgpk_poll; | ||
391 | psmouse->disconnect = hgpk_disconnect; | ||
392 | psmouse->reconnect = hgpk_reconnect; | ||
393 | psmouse->pktsize = 3; | ||
394 | |||
395 | /* Disable the idle resync. */ | ||
396 | psmouse->resync_time = 0; | ||
397 | /* Reset after a lot of bad bytes. */ | ||
398 | psmouse->resetafter = 1024; | ||
399 | |||
400 | err = device_create_file(&psmouse->ps2dev.serio->dev, | ||
401 | &psmouse_attr_powered.dattr); | ||
402 | if (err) | ||
403 | hgpk_err(psmouse, "Failed to create sysfs attribute\n"); | ||
404 | |||
405 | return err; | ||
406 | } | ||
407 | |||
408 | int hgpk_init(struct psmouse *psmouse) | ||
409 | { | ||
410 | struct hgpk_data *priv; | ||
411 | int err = -ENOMEM; | ||
412 | |||
413 | priv = kzalloc(sizeof(struct hgpk_data), GFP_KERNEL); | ||
414 | if (!priv) | ||
415 | goto alloc_fail; | ||
416 | |||
417 | psmouse->private = priv; | ||
418 | priv->psmouse = psmouse; | ||
419 | priv->powered = 1; | ||
420 | INIT_DELAYED_WORK(&priv->recalib_wq, hgpk_recalib_work); | ||
421 | |||
422 | err = psmouse_reset(psmouse); | ||
423 | if (err) | ||
424 | goto init_fail; | ||
425 | |||
426 | err = hgpk_register(psmouse); | ||
427 | if (err) | ||
428 | goto init_fail; | ||
429 | |||
430 | return 0; | ||
431 | |||
432 | init_fail: | ||
433 | kfree(priv); | ||
434 | alloc_fail: | ||
435 | return err; | ||
436 | } | ||
437 | |||
438 | static enum hgpk_model_t hgpk_get_model(struct psmouse *psmouse) | ||
439 | { | ||
440 | struct ps2dev *ps2dev = &psmouse->ps2dev; | ||
441 | unsigned char param[3]; | ||
442 | |||
443 | /* E7, E7, E7, E9 gets us a 3 byte identifier */ | ||
444 | if (ps2_command(ps2dev, NULL, PSMOUSE_CMD_SETSCALE21) || | ||
445 | ps2_command(ps2dev, NULL, PSMOUSE_CMD_SETSCALE21) || | ||
446 | ps2_command(ps2dev, NULL, PSMOUSE_CMD_SETSCALE21) || | ||
447 | ps2_command(ps2dev, param, PSMOUSE_CMD_GETINFO)) { | ||
448 | return -EIO; | ||
449 | } | ||
450 | |||
451 | hgpk_dbg(psmouse, "ID: %02x %02x %02x", param[0], param[1], param[2]); | ||
452 | |||
453 | /* HGPK signature: 0x67, 0x00, 0x<model> */ | ||
454 | if (param[0] != 0x67 || param[1] != 0x00) | ||
455 | return -ENODEV; | ||
456 | |||
457 | hgpk_info(psmouse, "OLPC touchpad revision 0x%x\n", param[2]); | ||
458 | |||
459 | return param[2]; | ||
460 | } | ||
461 | |||
462 | int hgpk_detect(struct psmouse *psmouse, int set_properties) | ||
463 | { | ||
464 | int version; | ||
465 | |||
466 | version = hgpk_get_model(psmouse); | ||
467 | if (version < 0) | ||
468 | return version; | ||
469 | |||
470 | if (set_properties) { | ||
471 | psmouse->vendor = "ALPS"; | ||
472 | psmouse->name = "HGPK"; | ||
473 | psmouse->model = version; | ||
474 | } | ||
475 | |||
476 | return 0; | ||
477 | } | ||
diff --git a/drivers/input/mouse/hgpk.h b/drivers/input/mouse/hgpk.h new file mode 100644 index 000000000000..a4b2a96f5f54 --- /dev/null +++ b/drivers/input/mouse/hgpk.h | |||
@@ -0,0 +1,49 @@ | |||
1 | /* | ||
2 | * OLPC HGPK (XO-1) touchpad PS/2 mouse driver | ||
3 | */ | ||
4 | |||
5 | #ifndef _HGPK_H | ||
6 | #define _HGPK_H | ||
7 | |||
8 | enum hgpk_model_t { | ||
9 | HGPK_MODEL_PREA = 0x0a, /* pre-B1s */ | ||
10 | HGPK_MODEL_A = 0x14, /* found on B1s, PT disabled in hardware */ | ||
11 | HGPK_MODEL_B = 0x28, /* B2s, has capacitance issues */ | ||
12 | HGPK_MODEL_C = 0x3c, | ||
13 | HGPK_MODEL_D = 0x50, /* C1, mass production */ | ||
14 | }; | ||
15 | |||
16 | struct hgpk_data { | ||
17 | struct psmouse *psmouse; | ||
18 | int powered; | ||
19 | int count, x_tally, y_tally; /* hardware workaround stuff */ | ||
20 | unsigned long recalib_window; | ||
21 | struct delayed_work recalib_wq; | ||
22 | }; | ||
23 | |||
24 | #define hgpk_dbg(psmouse, format, arg...) \ | ||
25 | dev_dbg(&(psmouse)->ps2dev.serio->dev, format, ## arg) | ||
26 | #define hgpk_err(psmouse, format, arg...) \ | ||
27 | dev_err(&(psmouse)->ps2dev.serio->dev, format, ## arg) | ||
28 | #define hgpk_info(psmouse, format, arg...) \ | ||
29 | dev_info(&(psmouse)->ps2dev.serio->dev, format, ## arg) | ||
30 | #define hgpk_warn(psmouse, format, arg...) \ | ||
31 | dev_warn(&(psmouse)->ps2dev.serio->dev, format, ## arg) | ||
32 | #define hgpk_notice(psmouse, format, arg...) \ | ||
33 | dev_notice(&(psmouse)->ps2dev.serio->dev, format, ## arg) | ||
34 | |||
35 | #ifdef CONFIG_MOUSE_PS2_OLPC | ||
36 | int hgpk_detect(struct psmouse *psmouse, int set_properties); | ||
37 | int hgpk_init(struct psmouse *psmouse); | ||
38 | #else | ||
39 | static inline int hgpk_detect(struct psmouse *psmouse, int set_properties) | ||
40 | { | ||
41 | return -ENODEV; | ||
42 | } | ||
43 | static inline int hgpk_init(struct psmouse *psmouse) | ||
44 | { | ||
45 | return -ENODEV; | ||
46 | } | ||
47 | #endif | ||
48 | |||
49 | #endif | ||
diff --git a/drivers/input/mouse/logips2pp.c b/drivers/input/mouse/logips2pp.c index 0c5660d28caa..390f1dbb98a4 100644 --- a/drivers/input/mouse/logips2pp.c +++ b/drivers/input/mouse/logips2pp.c | |||
@@ -157,10 +157,8 @@ static ssize_t ps2pp_attr_show_smartscroll(struct psmouse *psmouse, void *data, | |||
157 | static ssize_t ps2pp_attr_set_smartscroll(struct psmouse *psmouse, void *data, const char *buf, size_t count) | 157 | static ssize_t ps2pp_attr_set_smartscroll(struct psmouse *psmouse, void *data, const char *buf, size_t count) |
158 | { | 158 | { |
159 | unsigned long value; | 159 | unsigned long value; |
160 | char *rest; | ||
161 | 160 | ||
162 | value = simple_strtoul(buf, &rest, 10); | 161 | if (strict_strtoul(buf, 10, &value) || value > 1) |
163 | if (*rest || value > 1) | ||
164 | return -EINVAL; | 162 | return -EINVAL; |
165 | 163 | ||
166 | ps2pp_set_smartscroll(psmouse, value); | 164 | ps2pp_set_smartscroll(psmouse, value); |
diff --git a/drivers/input/mouse/psmouse-base.c b/drivers/input/mouse/psmouse-base.c index f5a6be1d3c46..126e977e199e 100644 --- a/drivers/input/mouse/psmouse-base.c +++ b/drivers/input/mouse/psmouse-base.c | |||
@@ -25,6 +25,7 @@ | |||
25 | #include "synaptics.h" | 25 | #include "synaptics.h" |
26 | #include "logips2pp.h" | 26 | #include "logips2pp.h" |
27 | #include "alps.h" | 27 | #include "alps.h" |
28 | #include "hgpk.h" | ||
28 | #include "lifebook.h" | 29 | #include "lifebook.h" |
29 | #include "trackpoint.h" | 30 | #include "trackpoint.h" |
30 | #include "touchkit_ps2.h" | 31 | #include "touchkit_ps2.h" |
@@ -201,6 +202,12 @@ static psmouse_ret_t psmouse_process_byte(struct psmouse *psmouse) | |||
201 | return PSMOUSE_FULL_PACKET; | 202 | return PSMOUSE_FULL_PACKET; |
202 | } | 203 | } |
203 | 204 | ||
205 | void psmouse_queue_work(struct psmouse *psmouse, struct delayed_work *work, | ||
206 | unsigned long delay) | ||
207 | { | ||
208 | queue_delayed_work(kpsmoused_wq, work, delay); | ||
209 | } | ||
210 | |||
204 | /* | 211 | /* |
205 | * __psmouse_set_state() sets new psmouse state and resets all flags. | 212 | * __psmouse_set_state() sets new psmouse state and resets all flags. |
206 | */ | 213 | */ |
@@ -220,7 +227,7 @@ static inline void __psmouse_set_state(struct psmouse *psmouse, enum psmouse_sta | |||
220 | * is not a concern. | 227 | * is not a concern. |
221 | */ | 228 | */ |
222 | 229 | ||
223 | static void psmouse_set_state(struct psmouse *psmouse, enum psmouse_state new_state) | 230 | void psmouse_set_state(struct psmouse *psmouse, enum psmouse_state new_state) |
224 | { | 231 | { |
225 | serio_pause_rx(psmouse->ps2dev.serio); | 232 | serio_pause_rx(psmouse->ps2dev.serio); |
226 | __psmouse_set_state(psmouse, new_state); | 233 | __psmouse_set_state(psmouse, new_state); |
@@ -305,7 +312,7 @@ static irqreturn_t psmouse_interrupt(struct serio *serio, | |||
305 | psmouse->name, psmouse->phys, psmouse->pktcnt); | 312 | psmouse->name, psmouse->phys, psmouse->pktcnt); |
306 | psmouse->badbyte = psmouse->packet[0]; | 313 | psmouse->badbyte = psmouse->packet[0]; |
307 | __psmouse_set_state(psmouse, PSMOUSE_RESYNCING); | 314 | __psmouse_set_state(psmouse, PSMOUSE_RESYNCING); |
308 | queue_work(kpsmoused_wq, &psmouse->resync_work); | 315 | psmouse_queue_work(psmouse, &psmouse->resync_work, 0); |
309 | goto out; | 316 | goto out; |
310 | } | 317 | } |
311 | 318 | ||
@@ -342,7 +349,7 @@ static irqreturn_t psmouse_interrupt(struct serio *serio, | |||
342 | time_after(jiffies, psmouse->last + psmouse->resync_time * HZ)) { | 349 | time_after(jiffies, psmouse->last + psmouse->resync_time * HZ)) { |
343 | psmouse->badbyte = psmouse->packet[0]; | 350 | psmouse->badbyte = psmouse->packet[0]; |
344 | __psmouse_set_state(psmouse, PSMOUSE_RESYNCING); | 351 | __psmouse_set_state(psmouse, PSMOUSE_RESYNCING); |
345 | queue_work(kpsmoused_wq, &psmouse->resync_work); | 352 | psmouse_queue_work(psmouse, &psmouse->resync_work, 0); |
346 | goto out; | 353 | goto out; |
347 | } | 354 | } |
348 | 355 | ||
@@ -630,8 +637,20 @@ static int psmouse_extensions(struct psmouse *psmouse, | |||
630 | } | 637 | } |
631 | } | 638 | } |
632 | 639 | ||
633 | if (max_proto > PSMOUSE_IMEX) { | 640 | /* |
641 | * Try OLPC HGPK touchpad. | ||
642 | */ | ||
643 | if (max_proto > PSMOUSE_IMEX && | ||
644 | hgpk_detect(psmouse, set_properties) == 0) { | ||
645 | if (!set_properties || hgpk_init(psmouse) == 0) | ||
646 | return PSMOUSE_HGPK; | ||
647 | /* | ||
648 | * Init failed, try basic relative protocols | ||
649 | */ | ||
650 | max_proto = PSMOUSE_IMEX; | ||
651 | } | ||
634 | 652 | ||
653 | if (max_proto > PSMOUSE_IMEX) { | ||
635 | if (genius_detect(psmouse, set_properties) == 0) | 654 | if (genius_detect(psmouse, set_properties) == 0) |
636 | return PSMOUSE_GENPS; | 655 | return PSMOUSE_GENPS; |
637 | 656 | ||
@@ -762,6 +781,14 @@ static const struct psmouse_protocol psmouse_protocols[] = { | |||
762 | .detect = touchkit_ps2_detect, | 781 | .detect = touchkit_ps2_detect, |
763 | }, | 782 | }, |
764 | #endif | 783 | #endif |
784 | #ifdef CONFIG_MOUSE_PS2_OLPC | ||
785 | { | ||
786 | .type = PSMOUSE_HGPK, | ||
787 | .name = "OLPC HGPK", | ||
788 | .alias = "hgpk", | ||
789 | .detect = hgpk_detect, | ||
790 | }, | ||
791 | #endif | ||
765 | { | 792 | { |
766 | .type = PSMOUSE_CORTRON, | 793 | .type = PSMOUSE_CORTRON, |
767 | .name = "CortronPS/2", | 794 | .name = "CortronPS/2", |
@@ -935,7 +962,7 @@ static int psmouse_poll(struct psmouse *psmouse) | |||
935 | static void psmouse_resync(struct work_struct *work) | 962 | static void psmouse_resync(struct work_struct *work) |
936 | { | 963 | { |
937 | struct psmouse *parent = NULL, *psmouse = | 964 | struct psmouse *parent = NULL, *psmouse = |
938 | container_of(work, struct psmouse, resync_work); | 965 | container_of(work, struct psmouse, resync_work.work); |
939 | struct serio *serio = psmouse->ps2dev.serio; | 966 | struct serio *serio = psmouse->ps2dev.serio; |
940 | psmouse_ret_t rc = PSMOUSE_GOOD_DATA; | 967 | psmouse_ret_t rc = PSMOUSE_GOOD_DATA; |
941 | int failed = 0, enabled = 0; | 968 | int failed = 0, enabled = 0; |
@@ -1194,7 +1221,7 @@ static int psmouse_connect(struct serio *serio, struct serio_driver *drv) | |||
1194 | goto err_free; | 1221 | goto err_free; |
1195 | 1222 | ||
1196 | ps2_init(&psmouse->ps2dev, serio); | 1223 | ps2_init(&psmouse->ps2dev, serio); |
1197 | INIT_WORK(&psmouse->resync_work, psmouse_resync); | 1224 | INIT_DELAYED_WORK(&psmouse->resync_work, psmouse_resync); |
1198 | psmouse->dev = input_dev; | 1225 | psmouse->dev = input_dev; |
1199 | snprintf(psmouse->phys, sizeof(psmouse->phys), "%s/input0", serio->phys); | 1226 | snprintf(psmouse->phys, sizeof(psmouse->phys), "%s/input0", serio->phys); |
1200 | 1227 | ||
@@ -1395,25 +1422,29 @@ ssize_t psmouse_attr_set_helper(struct device *dev, struct device_attribute *dev | |||
1395 | 1422 | ||
1396 | psmouse = serio_get_drvdata(serio); | 1423 | psmouse = serio_get_drvdata(serio); |
1397 | 1424 | ||
1398 | if (psmouse->state == PSMOUSE_IGNORE) { | 1425 | if (attr->protect) { |
1399 | retval = -ENODEV; | 1426 | if (psmouse->state == PSMOUSE_IGNORE) { |
1400 | goto out_unlock; | 1427 | retval = -ENODEV; |
1401 | } | 1428 | goto out_unlock; |
1429 | } | ||
1402 | 1430 | ||
1403 | if (serio->parent && serio->id.type == SERIO_PS_PSTHRU) { | 1431 | if (serio->parent && serio->id.type == SERIO_PS_PSTHRU) { |
1404 | parent = serio_get_drvdata(serio->parent); | 1432 | parent = serio_get_drvdata(serio->parent); |
1405 | psmouse_deactivate(parent); | 1433 | psmouse_deactivate(parent); |
1406 | } | 1434 | } |
1407 | 1435 | ||
1408 | psmouse_deactivate(psmouse); | 1436 | psmouse_deactivate(psmouse); |
1437 | } | ||
1409 | 1438 | ||
1410 | retval = attr->set(psmouse, attr->data, buf, count); | 1439 | retval = attr->set(psmouse, attr->data, buf, count); |
1411 | 1440 | ||
1412 | if (retval != -ENODEV) | 1441 | if (attr->protect) { |
1413 | psmouse_activate(psmouse); | 1442 | if (retval != -ENODEV) |
1443 | psmouse_activate(psmouse); | ||
1414 | 1444 | ||
1415 | if (parent) | 1445 | if (parent) |
1416 | psmouse_activate(parent); | 1446 | psmouse_activate(parent); |
1447 | } | ||
1417 | 1448 | ||
1418 | out_unlock: | 1449 | out_unlock: |
1419 | mutex_unlock(&psmouse_mutex); | 1450 | mutex_unlock(&psmouse_mutex); |
@@ -1433,10 +1464,8 @@ static ssize_t psmouse_set_int_attr(struct psmouse *psmouse, void *offset, const | |||
1433 | { | 1464 | { |
1434 | unsigned int *field = (unsigned int *)((char *)psmouse + (size_t)offset); | 1465 | unsigned int *field = (unsigned int *)((char *)psmouse + (size_t)offset); |
1435 | unsigned long value; | 1466 | unsigned long value; |
1436 | char *rest; | ||
1437 | 1467 | ||
1438 | value = simple_strtoul(buf, &rest, 10); | 1468 | if (strict_strtoul(buf, 10, &value)) |
1439 | if (*rest) | ||
1440 | return -EINVAL; | 1469 | return -EINVAL; |
1441 | 1470 | ||
1442 | if ((unsigned int)value != value) | 1471 | if ((unsigned int)value != value) |
@@ -1549,10 +1578,8 @@ static ssize_t psmouse_attr_set_protocol(struct psmouse *psmouse, void *data, co | |||
1549 | static ssize_t psmouse_attr_set_rate(struct psmouse *psmouse, void *data, const char *buf, size_t count) | 1578 | static ssize_t psmouse_attr_set_rate(struct psmouse *psmouse, void *data, const char *buf, size_t count) |
1550 | { | 1579 | { |
1551 | unsigned long value; | 1580 | unsigned long value; |
1552 | char *rest; | ||
1553 | 1581 | ||
1554 | value = simple_strtoul(buf, &rest, 10); | 1582 | if (strict_strtoul(buf, 10, &value)) |
1555 | if (*rest) | ||
1556 | return -EINVAL; | 1583 | return -EINVAL; |
1557 | 1584 | ||
1558 | psmouse->set_rate(psmouse, value); | 1585 | psmouse->set_rate(psmouse, value); |
@@ -1562,10 +1589,8 @@ static ssize_t psmouse_attr_set_rate(struct psmouse *psmouse, void *data, const | |||
1562 | static ssize_t psmouse_attr_set_resolution(struct psmouse *psmouse, void *data, const char *buf, size_t count) | 1589 | static ssize_t psmouse_attr_set_resolution(struct psmouse *psmouse, void *data, const char *buf, size_t count) |
1563 | { | 1590 | { |
1564 | unsigned long value; | 1591 | unsigned long value; |
1565 | char *rest; | ||
1566 | 1592 | ||
1567 | value = simple_strtoul(buf, &rest, 10); | 1593 | if (strict_strtoul(buf, 10, &value)) |
1568 | if (*rest) | ||
1569 | return -EINVAL; | 1594 | return -EINVAL; |
1570 | 1595 | ||
1571 | psmouse->set_resolution(psmouse, value); | 1596 | psmouse->set_resolution(psmouse, value); |
diff --git a/drivers/input/mouse/psmouse.h b/drivers/input/mouse/psmouse.h index 1317bdd8cc7c..8b608a1cdd12 100644 --- a/drivers/input/mouse/psmouse.h +++ b/drivers/input/mouse/psmouse.h | |||
@@ -39,7 +39,7 @@ struct psmouse { | |||
39 | void *private; | 39 | void *private; |
40 | struct input_dev *dev; | 40 | struct input_dev *dev; |
41 | struct ps2dev ps2dev; | 41 | struct ps2dev ps2dev; |
42 | struct work_struct resync_work; | 42 | struct delayed_work resync_work; |
43 | char *vendor; | 43 | char *vendor; |
44 | char *name; | 44 | char *name; |
45 | unsigned char packet[8]; | 45 | unsigned char packet[8]; |
@@ -89,20 +89,24 @@ enum psmouse_type { | |||
89 | PSMOUSE_TRACKPOINT, | 89 | PSMOUSE_TRACKPOINT, |
90 | PSMOUSE_TOUCHKIT_PS2, | 90 | PSMOUSE_TOUCHKIT_PS2, |
91 | PSMOUSE_CORTRON, | 91 | PSMOUSE_CORTRON, |
92 | PSMOUSE_HGPK, | ||
92 | PSMOUSE_AUTO /* This one should always be last */ | 93 | PSMOUSE_AUTO /* This one should always be last */ |
93 | }; | 94 | }; |
94 | 95 | ||
96 | void psmouse_queue_work(struct psmouse *psmouse, struct delayed_work *work, | ||
97 | unsigned long delay); | ||
95 | int psmouse_sliced_command(struct psmouse *psmouse, unsigned char command); | 98 | int psmouse_sliced_command(struct psmouse *psmouse, unsigned char command); |
96 | int psmouse_reset(struct psmouse *psmouse); | 99 | int psmouse_reset(struct psmouse *psmouse); |
100 | void psmouse_set_state(struct psmouse *psmouse, enum psmouse_state new_state); | ||
97 | void psmouse_set_resolution(struct psmouse *psmouse, unsigned int resolution); | 101 | void psmouse_set_resolution(struct psmouse *psmouse, unsigned int resolution); |
98 | 102 | ||
99 | |||
100 | struct psmouse_attribute { | 103 | struct psmouse_attribute { |
101 | struct device_attribute dattr; | 104 | struct device_attribute dattr; |
102 | void *data; | 105 | void *data; |
103 | ssize_t (*show)(struct psmouse *psmouse, void *data, char *buf); | 106 | ssize_t (*show)(struct psmouse *psmouse, void *data, char *buf); |
104 | ssize_t (*set)(struct psmouse *psmouse, void *data, | 107 | ssize_t (*set)(struct psmouse *psmouse, void *data, |
105 | const char *buf, size_t count); | 108 | const char *buf, size_t count); |
109 | int protect; | ||
106 | }; | 110 | }; |
107 | #define to_psmouse_attr(a) container_of((a), struct psmouse_attribute, dattr) | 111 | #define to_psmouse_attr(a) container_of((a), struct psmouse_attribute, dattr) |
108 | 112 | ||
@@ -111,7 +115,7 @@ ssize_t psmouse_attr_show_helper(struct device *dev, struct device_attribute *at | |||
111 | ssize_t psmouse_attr_set_helper(struct device *dev, struct device_attribute *attr, | 115 | ssize_t psmouse_attr_set_helper(struct device *dev, struct device_attribute *attr, |
112 | const char *buf, size_t count); | 116 | const char *buf, size_t count); |
113 | 117 | ||
114 | #define PSMOUSE_DEFINE_ATTR(_name, _mode, _data, _show, _set) \ | 118 | #define __PSMOUSE_DEFINE_ATTR(_name, _mode, _data, _show, _set, _protect) \ |
115 | static ssize_t _show(struct psmouse *, void *data, char *); \ | 119 | static ssize_t _show(struct psmouse *, void *data, char *); \ |
116 | static ssize_t _set(struct psmouse *, void *data, const char *, size_t); \ | 120 | static ssize_t _set(struct psmouse *, void *data, const char *, size_t); \ |
117 | static struct psmouse_attribute psmouse_attr_##_name = { \ | 121 | static struct psmouse_attribute psmouse_attr_##_name = { \ |
@@ -126,6 +130,10 @@ static struct psmouse_attribute psmouse_attr_##_name = { \ | |||
126 | .data = _data, \ | 130 | .data = _data, \ |
127 | .show = _show, \ | 131 | .show = _show, \ |
128 | .set = _set, \ | 132 | .set = _set, \ |
133 | .protect = _protect, \ | ||
129 | } | 134 | } |
130 | 135 | ||
136 | #define PSMOUSE_DEFINE_ATTR(_name, _mode, _data, _show, _set) \ | ||
137 | __PSMOUSE_DEFINE_ATTR(_name, _mode, _data, _show, _set, 1) | ||
138 | |||
131 | #endif /* _PSMOUSE_H */ | 139 | #endif /* _PSMOUSE_H */ |
diff --git a/drivers/input/mouse/trackpoint.c b/drivers/input/mouse/trackpoint.c index 26b845fc186a..e68c814c4361 100644 --- a/drivers/input/mouse/trackpoint.c +++ b/drivers/input/mouse/trackpoint.c | |||
@@ -89,10 +89,8 @@ static ssize_t trackpoint_set_int_attr(struct psmouse *psmouse, void *data, | |||
89 | struct trackpoint_attr_data *attr = data; | 89 | struct trackpoint_attr_data *attr = data; |
90 | unsigned char *field = (unsigned char *)((char *)tp + attr->field_offset); | 90 | unsigned char *field = (unsigned char *)((char *)tp + attr->field_offset); |
91 | unsigned long value; | 91 | unsigned long value; |
92 | char *rest; | ||
93 | 92 | ||
94 | value = simple_strtoul(buf, &rest, 10); | 93 | if (strict_strtoul(buf, 10, &value) || value > 255) |
95 | if (*rest || value > 255) | ||
96 | return -EINVAL; | 94 | return -EINVAL; |
97 | 95 | ||
98 | *field = value; | 96 | *field = value; |
@@ -117,10 +115,8 @@ static ssize_t trackpoint_set_bit_attr(struct psmouse *psmouse, void *data, | |||
117 | struct trackpoint_attr_data *attr = data; | 115 | struct trackpoint_attr_data *attr = data; |
118 | unsigned char *field = (unsigned char *)((char *)tp + attr->field_offset); | 116 | unsigned char *field = (unsigned char *)((char *)tp + attr->field_offset); |
119 | unsigned long value; | 117 | unsigned long value; |
120 | char *rest; | ||
121 | 118 | ||
122 | value = simple_strtoul(buf, &rest, 10); | 119 | if (strict_strtoul(buf, 10, &value) || value > 1) |
123 | if (*rest || value > 1) | ||
124 | return -EINVAL; | 120 | return -EINVAL; |
125 | 121 | ||
126 | if (attr->inverted) | 122 | if (attr->inverted) |