aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/input/mouse/psmouse-base.c
diff options
context:
space:
mode:
authorDmitry Torokhov <dmitry.torokhov@gmail.com>2009-09-14 00:16:56 -0400
committerDmitry Torokhov <dmitry.torokhov@gmail.com>2009-09-14 00:16:56 -0400
commitfc8e1ead9314cf0e0f1922e661428b93d3a50d88 (patch)
treef3cb97c4769b74f6627a59769f1ed5c92a13c58a /drivers/input/mouse/psmouse-base.c
parent2bcaa6a4238094c5695d5b1943078388d82d3004 (diff)
parent9de48cc300fb10f7d9faa978670becf5e352462a (diff)
Merge branch 'next' into for-linus
Diffstat (limited to 'drivers/input/mouse/psmouse-base.c')
-rw-r--r--drivers/input/mouse/psmouse-base.c113
1 files changed, 71 insertions, 42 deletions
diff --git a/drivers/input/mouse/psmouse-base.c b/drivers/input/mouse/psmouse-base.c
index b407b355dceb..690aed905436 100644
--- a/drivers/input/mouse/psmouse-base.c
+++ b/drivers/input/mouse/psmouse-base.c
@@ -30,6 +30,7 @@
30#include "trackpoint.h" 30#include "trackpoint.h"
31#include "touchkit_ps2.h" 31#include "touchkit_ps2.h"
32#include "elantech.h" 32#include "elantech.h"
33#include "sentelic.h"
33 34
34#define DRIVER_DESC "PS/2 mouse driver" 35#define DRIVER_DESC "PS/2 mouse driver"
35 36
@@ -108,10 +109,10 @@ static struct workqueue_struct *kpsmoused_wq;
108 109
109struct psmouse_protocol { 110struct psmouse_protocol {
110 enum psmouse_type type; 111 enum psmouse_type type;
112 bool maxproto;
111 const char *name; 113 const char *name;
112 const char *alias; 114 const char *alias;
113 int maxproto; 115 int (*detect)(struct psmouse *, bool);
114 int (*detect)(struct psmouse *, int);
115 int (*init)(struct psmouse *); 116 int (*init)(struct psmouse *);
116}; 117};
117 118
@@ -216,7 +217,7 @@ void psmouse_queue_work(struct psmouse *psmouse, struct delayed_work *work,
216static inline void __psmouse_set_state(struct psmouse *psmouse, enum psmouse_state new_state) 217static inline void __psmouse_set_state(struct psmouse *psmouse, enum psmouse_state new_state)
217{ 218{
218 psmouse->state = new_state; 219 psmouse->state = new_state;
219 psmouse->pktcnt = psmouse->out_of_sync = 0; 220 psmouse->pktcnt = psmouse->out_of_sync_cnt = 0;
220 psmouse->ps2dev.flags = 0; 221 psmouse->ps2dev.flags = 0;
221 psmouse->last = jiffies; 222 psmouse->last = jiffies;
222} 223}
@@ -249,7 +250,7 @@ static int psmouse_handle_byte(struct psmouse *psmouse)
249 if (psmouse->state == PSMOUSE_ACTIVATED) { 250 if (psmouse->state == PSMOUSE_ACTIVATED) {
250 printk(KERN_WARNING "psmouse.c: %s at %s lost sync at byte %d\n", 251 printk(KERN_WARNING "psmouse.c: %s at %s lost sync at byte %d\n",
251 psmouse->name, psmouse->phys, psmouse->pktcnt); 252 psmouse->name, psmouse->phys, psmouse->pktcnt);
252 if (++psmouse->out_of_sync == psmouse->resetafter) { 253 if (++psmouse->out_of_sync_cnt == psmouse->resetafter) {
253 __psmouse_set_state(psmouse, PSMOUSE_IGNORE); 254 __psmouse_set_state(psmouse, PSMOUSE_IGNORE);
254 printk(KERN_NOTICE "psmouse.c: issuing reconnect request\n"); 255 printk(KERN_NOTICE "psmouse.c: issuing reconnect request\n");
255 serio_reconnect(psmouse->ps2dev.serio); 256 serio_reconnect(psmouse->ps2dev.serio);
@@ -261,8 +262,8 @@ static int psmouse_handle_byte(struct psmouse *psmouse)
261 262
262 case PSMOUSE_FULL_PACKET: 263 case PSMOUSE_FULL_PACKET:
263 psmouse->pktcnt = 0; 264 psmouse->pktcnt = 0;
264 if (psmouse->out_of_sync) { 265 if (psmouse->out_of_sync_cnt) {
265 psmouse->out_of_sync = 0; 266 psmouse->out_of_sync_cnt = 0;
266 printk(KERN_NOTICE "psmouse.c: %s at %s - driver resynched.\n", 267 printk(KERN_NOTICE "psmouse.c: %s at %s - driver resynched.\n",
267 psmouse->name, psmouse->phys); 268 psmouse->name, psmouse->phys);
268 } 269 }
@@ -408,7 +409,7 @@ int psmouse_reset(struct psmouse *psmouse)
408/* 409/*
409 * Genius NetMouse magic init. 410 * Genius NetMouse magic init.
410 */ 411 */
411static int genius_detect(struct psmouse *psmouse, int set_properties) 412static int genius_detect(struct psmouse *psmouse, bool set_properties)
412{ 413{
413 struct ps2dev *ps2dev = &psmouse->ps2dev; 414 struct ps2dev *ps2dev = &psmouse->ps2dev;
414 unsigned char param[4]; 415 unsigned char param[4];
@@ -424,9 +425,9 @@ static int genius_detect(struct psmouse *psmouse, int set_properties)
424 return -1; 425 return -1;
425 426
426 if (set_properties) { 427 if (set_properties) {
427 set_bit(BTN_EXTRA, psmouse->dev->keybit); 428 __set_bit(BTN_EXTRA, psmouse->dev->keybit);
428 set_bit(BTN_SIDE, psmouse->dev->keybit); 429 __set_bit(BTN_SIDE, psmouse->dev->keybit);
429 set_bit(REL_WHEEL, psmouse->dev->relbit); 430 __set_bit(REL_WHEEL, psmouse->dev->relbit);
430 431
431 psmouse->vendor = "Genius"; 432 psmouse->vendor = "Genius";
432 psmouse->name = "Mouse"; 433 psmouse->name = "Mouse";
@@ -439,7 +440,7 @@ static int genius_detect(struct psmouse *psmouse, int set_properties)
439/* 440/*
440 * IntelliMouse magic init. 441 * IntelliMouse magic init.
441 */ 442 */
442static int intellimouse_detect(struct psmouse *psmouse, int set_properties) 443static int intellimouse_detect(struct psmouse *psmouse, bool set_properties)
443{ 444{
444 struct ps2dev *ps2dev = &psmouse->ps2dev; 445 struct ps2dev *ps2dev = &psmouse->ps2dev;
445 unsigned char param[2]; 446 unsigned char param[2];
@@ -456,8 +457,8 @@ static int intellimouse_detect(struct psmouse *psmouse, int set_properties)
456 return -1; 457 return -1;
457 458
458 if (set_properties) { 459 if (set_properties) {
459 set_bit(BTN_MIDDLE, psmouse->dev->keybit); 460 __set_bit(BTN_MIDDLE, psmouse->dev->keybit);
460 set_bit(REL_WHEEL, psmouse->dev->relbit); 461 __set_bit(REL_WHEEL, psmouse->dev->relbit);
461 462
462 if (!psmouse->vendor) psmouse->vendor = "Generic"; 463 if (!psmouse->vendor) psmouse->vendor = "Generic";
463 if (!psmouse->name) psmouse->name = "Wheel Mouse"; 464 if (!psmouse->name) psmouse->name = "Wheel Mouse";
@@ -470,7 +471,7 @@ static int intellimouse_detect(struct psmouse *psmouse, int set_properties)
470/* 471/*
471 * Try IntelliMouse/Explorer magic init. 472 * Try IntelliMouse/Explorer magic init.
472 */ 473 */
473static int im_explorer_detect(struct psmouse *psmouse, int set_properties) 474static int im_explorer_detect(struct psmouse *psmouse, bool set_properties)
474{ 475{
475 struct ps2dev *ps2dev = &psmouse->ps2dev; 476 struct ps2dev *ps2dev = &psmouse->ps2dev;
476 unsigned char param[2]; 477 unsigned char param[2];
@@ -497,11 +498,11 @@ static int im_explorer_detect(struct psmouse *psmouse, int set_properties)
497 ps2_command(ps2dev, param, PSMOUSE_CMD_SETRATE); 498 ps2_command(ps2dev, param, PSMOUSE_CMD_SETRATE);
498 499
499 if (set_properties) { 500 if (set_properties) {
500 set_bit(BTN_MIDDLE, psmouse->dev->keybit); 501 __set_bit(BTN_MIDDLE, psmouse->dev->keybit);
501 set_bit(REL_WHEEL, psmouse->dev->relbit); 502 __set_bit(REL_WHEEL, psmouse->dev->relbit);
502 set_bit(REL_HWHEEL, psmouse->dev->relbit); 503 __set_bit(REL_HWHEEL, psmouse->dev->relbit);
503 set_bit(BTN_SIDE, psmouse->dev->keybit); 504 __set_bit(BTN_SIDE, psmouse->dev->keybit);
504 set_bit(BTN_EXTRA, psmouse->dev->keybit); 505 __set_bit(BTN_EXTRA, psmouse->dev->keybit);
505 506
506 if (!psmouse->vendor) psmouse->vendor = "Generic"; 507 if (!psmouse->vendor) psmouse->vendor = "Generic";
507 if (!psmouse->name) psmouse->name = "Explorer Mouse"; 508 if (!psmouse->name) psmouse->name = "Explorer Mouse";
@@ -514,7 +515,7 @@ static int im_explorer_detect(struct psmouse *psmouse, int set_properties)
514/* 515/*
515 * Kensington ThinkingMouse / ExpertMouse magic init. 516 * Kensington ThinkingMouse / ExpertMouse magic init.
516 */ 517 */
517static int thinking_detect(struct psmouse *psmouse, int set_properties) 518static int thinking_detect(struct psmouse *psmouse, bool set_properties)
518{ 519{
519 struct ps2dev *ps2dev = &psmouse->ps2dev; 520 struct ps2dev *ps2dev = &psmouse->ps2dev;
520 unsigned char param[2]; 521 unsigned char param[2];
@@ -535,7 +536,7 @@ static int thinking_detect(struct psmouse *psmouse, int set_properties)
535 return -1; 536 return -1;
536 537
537 if (set_properties) { 538 if (set_properties) {
538 set_bit(BTN_EXTRA, psmouse->dev->keybit); 539 __set_bit(BTN_EXTRA, psmouse->dev->keybit);
539 540
540 psmouse->vendor = "Kensington"; 541 psmouse->vendor = "Kensington";
541 psmouse->name = "ThinkingMouse"; 542 psmouse->name = "ThinkingMouse";
@@ -547,7 +548,7 @@ static int thinking_detect(struct psmouse *psmouse, int set_properties)
547/* 548/*
548 * Bare PS/2 protocol "detection". Always succeeds. 549 * Bare PS/2 protocol "detection". Always succeeds.
549 */ 550 */
550static int ps2bare_detect(struct psmouse *psmouse, int set_properties) 551static int ps2bare_detect(struct psmouse *psmouse, bool set_properties)
551{ 552{
552 if (set_properties) { 553 if (set_properties) {
553 if (!psmouse->vendor) psmouse->vendor = "Generic"; 554 if (!psmouse->vendor) psmouse->vendor = "Generic";
@@ -561,12 +562,12 @@ static int ps2bare_detect(struct psmouse *psmouse, int set_properties)
561 * Cortron PS/2 protocol detection. There's no special way to detect it, so it 562 * Cortron PS/2 protocol detection. There's no special way to detect it, so it
562 * must be forced by sysfs protocol writing. 563 * must be forced by sysfs protocol writing.
563 */ 564 */
564static int cortron_detect(struct psmouse *psmouse, int set_properties) 565static int cortron_detect(struct psmouse *psmouse, bool set_properties)
565{ 566{
566 if (set_properties) { 567 if (set_properties) {
567 psmouse->vendor = "Cortron"; 568 psmouse->vendor = "Cortron";
568 psmouse->name = "PS/2 Trackball"; 569 psmouse->name = "PS/2 Trackball";
569 set_bit(BTN_SIDE, psmouse->dev->keybit); 570 __set_bit(BTN_SIDE, psmouse->dev->keybit);
570 } 571 }
571 572
572 return 0; 573 return 0;
@@ -578,9 +579,9 @@ static int cortron_detect(struct psmouse *psmouse, int set_properties)
578 */ 579 */
579 580
580static int psmouse_extensions(struct psmouse *psmouse, 581static int psmouse_extensions(struct psmouse *psmouse,
581 unsigned int max_proto, int set_properties) 582 unsigned int max_proto, bool set_properties)
582{ 583{
583 int synaptics_hardware = 0; 584 bool synaptics_hardware = true;
584 585
585/* 586/*
586 * We always check for lifebook because it does not disturb mouse 587 * We always check for lifebook because it does not disturb mouse
@@ -607,7 +608,7 @@ static int psmouse_extensions(struct psmouse *psmouse,
607 * can reset it properly after probing for intellimouse. 608 * can reset it properly after probing for intellimouse.
608 */ 609 */
609 if (max_proto > PSMOUSE_PS2 && synaptics_detect(psmouse, set_properties) == 0) { 610 if (max_proto > PSMOUSE_PS2 && synaptics_detect(psmouse, set_properties) == 0) {
610 synaptics_hardware = 1; 611 synaptics_hardware = true;
611 612
612 if (max_proto > PSMOUSE_IMEX) { 613 if (max_proto > PSMOUSE_IMEX) {
613 if (!set_properties || synaptics_init(psmouse) == 0) 614 if (!set_properties || synaptics_init(psmouse) == 0)
@@ -666,6 +667,20 @@ static int psmouse_extensions(struct psmouse *psmouse,
666 max_proto = PSMOUSE_IMEX; 667 max_proto = PSMOUSE_IMEX;
667 } 668 }
668 669
670/*
671 * Try Finger Sensing Pad
672 */
673 if (max_proto > PSMOUSE_IMEX) {
674 if (fsp_detect(psmouse, set_properties) == 0) {
675 if (!set_properties || fsp_init(psmouse) == 0)
676 return PSMOUSE_FSP;
677/*
678 * Init failed, try basic relative protocols
679 */
680 max_proto = PSMOUSE_IMEX;
681 }
682 }
683
669 if (max_proto > PSMOUSE_IMEX) { 684 if (max_proto > PSMOUSE_IMEX) {
670 if (genius_detect(psmouse, set_properties) == 0) 685 if (genius_detect(psmouse, set_properties) == 0)
671 return PSMOUSE_GENPS; 686 return PSMOUSE_GENPS;
@@ -718,7 +733,7 @@ static const struct psmouse_protocol psmouse_protocols[] = {
718 .type = PSMOUSE_PS2, 733 .type = PSMOUSE_PS2,
719 .name = "PS/2", 734 .name = "PS/2",
720 .alias = "bare", 735 .alias = "bare",
721 .maxproto = 1, 736 .maxproto = true,
722 .detect = ps2bare_detect, 737 .detect = ps2bare_detect,
723 }, 738 },
724#ifdef CONFIG_MOUSE_PS2_LOGIPS2PP 739#ifdef CONFIG_MOUSE_PS2_LOGIPS2PP
@@ -745,14 +760,14 @@ static const struct psmouse_protocol psmouse_protocols[] = {
745 .type = PSMOUSE_IMPS, 760 .type = PSMOUSE_IMPS,
746 .name = "ImPS/2", 761 .name = "ImPS/2",
747 .alias = "imps", 762 .alias = "imps",
748 .maxproto = 1, 763 .maxproto = true,
749 .detect = intellimouse_detect, 764 .detect = intellimouse_detect,
750 }, 765 },
751 { 766 {
752 .type = PSMOUSE_IMEX, 767 .type = PSMOUSE_IMEX,
753 .name = "ImExPS/2", 768 .name = "ImExPS/2",
754 .alias = "exps", 769 .alias = "exps",
755 .maxproto = 1, 770 .maxproto = true,
756 .detect = im_explorer_detect, 771 .detect = im_explorer_detect,
757 }, 772 },
758#ifdef CONFIG_MOUSE_PS2_SYNAPTICS 773#ifdef CONFIG_MOUSE_PS2_SYNAPTICS
@@ -813,7 +828,16 @@ static const struct psmouse_protocol psmouse_protocols[] = {
813 .detect = elantech_detect, 828 .detect = elantech_detect,
814 .init = elantech_init, 829 .init = elantech_init,
815 }, 830 },
816 #endif 831#endif
832#ifdef CONFIG_MOUSE_PS2_SENTELIC
833 {
834 .type = PSMOUSE_FSP,
835 .name = "FSPPS/2",
836 .alias = "fsp",
837 .detect = fsp_detect,
838 .init = fsp_init,
839 },
840#endif
817 { 841 {
818 .type = PSMOUSE_CORTRON, 842 .type = PSMOUSE_CORTRON,
819 .name = "CortronPS/2", 843 .name = "CortronPS/2",
@@ -824,7 +848,7 @@ static const struct psmouse_protocol psmouse_protocols[] = {
824 .type = PSMOUSE_AUTO, 848 .type = PSMOUSE_AUTO,
825 .name = "auto", 849 .name = "auto",
826 .alias = "any", 850 .alias = "any",
827 .maxproto = 1, 851 .maxproto = true,
828 }, 852 },
829}; 853};
830 854
@@ -990,7 +1014,7 @@ static void psmouse_resync(struct work_struct *work)
990 container_of(work, struct psmouse, resync_work.work); 1014 container_of(work, struct psmouse, resync_work.work);
991 struct serio *serio = psmouse->ps2dev.serio; 1015 struct serio *serio = psmouse->ps2dev.serio;
992 psmouse_ret_t rc = PSMOUSE_GOOD_DATA; 1016 psmouse_ret_t rc = PSMOUSE_GOOD_DATA;
993 int failed = 0, enabled = 0; 1017 bool failed = false, enabled = false;
994 int i; 1018 int i;
995 1019
996 mutex_lock(&psmouse_mutex); 1020 mutex_lock(&psmouse_mutex);
@@ -1017,9 +1041,9 @@ static void psmouse_resync(struct work_struct *work)
1017 1041
1018 if (ps2_sendbyte(&psmouse->ps2dev, PSMOUSE_CMD_DISABLE, 20)) { 1042 if (ps2_sendbyte(&psmouse->ps2dev, PSMOUSE_CMD_DISABLE, 20)) {
1019 if (psmouse->num_resyncs < 3 || psmouse->acks_disable_command) 1043 if (psmouse->num_resyncs < 3 || psmouse->acks_disable_command)
1020 failed = 1; 1044 failed = true;
1021 } else 1045 } else
1022 psmouse->acks_disable_command = 1; 1046 psmouse->acks_disable_command = true;
1023 1047
1024/* 1048/*
1025 * Poll the mouse. If it was reset the packet will be shorter than 1049 * Poll the mouse. If it was reset the packet will be shorter than
@@ -1030,7 +1054,7 @@ static void psmouse_resync(struct work_struct *work)
1030 */ 1054 */
1031 if (!failed) { 1055 if (!failed) {
1032 if (psmouse->poll(psmouse)) 1056 if (psmouse->poll(psmouse))
1033 failed = 1; 1057 failed = true;
1034 else { 1058 else {
1035 psmouse_set_state(psmouse, PSMOUSE_CMD_MODE); 1059 psmouse_set_state(psmouse, PSMOUSE_CMD_MODE);
1036 for (i = 0; i < psmouse->pktsize; i++) { 1060 for (i = 0; i < psmouse->pktsize; i++) {
@@ -1040,7 +1064,7 @@ static void psmouse_resync(struct work_struct *work)
1040 break; 1064 break;
1041 } 1065 }
1042 if (rc != PSMOUSE_FULL_PACKET) 1066 if (rc != PSMOUSE_FULL_PACKET)
1043 failed = 1; 1067 failed = true;
1044 psmouse_set_state(psmouse, PSMOUSE_RESYNCING); 1068 psmouse_set_state(psmouse, PSMOUSE_RESYNCING);
1045 } 1069 }
1046 } 1070 }
@@ -1051,7 +1075,7 @@ static void psmouse_resync(struct work_struct *work)
1051 */ 1075 */
1052 for (i = 0; i < 5; i++) { 1076 for (i = 0; i < 5; i++) {
1053 if (!ps2_command(&psmouse->ps2dev, NULL, PSMOUSE_CMD_ENABLE)) { 1077 if (!ps2_command(&psmouse->ps2dev, NULL, PSMOUSE_CMD_ENABLE)) {
1054 enabled = 1; 1078 enabled = true;
1055 break; 1079 break;
1056 } 1080 }
1057 msleep(200); 1081 msleep(200);
@@ -1060,7 +1084,7 @@ static void psmouse_resync(struct work_struct *work)
1060 if (!enabled) { 1084 if (!enabled) {
1061 printk(KERN_WARNING "psmouse.c: failed to re-enable mouse on %s\n", 1085 printk(KERN_WARNING "psmouse.c: failed to re-enable mouse on %s\n",
1062 psmouse->ps2dev.serio->phys); 1086 psmouse->ps2dev.serio->phys);
1063 failed = 1; 1087 failed = true;
1064 } 1088 }
1065 1089
1066 if (failed) { 1090 if (failed) {
@@ -1187,7 +1211,8 @@ static int psmouse_switch_protocol(struct psmouse *psmouse, const struct psmouse
1187 psmouse->type = proto->type; 1211 psmouse->type = proto->type;
1188 } 1212 }
1189 else 1213 else
1190 psmouse->type = psmouse_extensions(psmouse, psmouse_max_proto, 1); 1214 psmouse->type = psmouse_extensions(psmouse,
1215 psmouse_max_proto, true);
1191 1216
1192 /* 1217 /*
1193 * If mouse's packet size is 3 there is no point in polling the 1218 * If mouse's packet size is 3 there is no point in polling the
@@ -1342,8 +1367,10 @@ static int psmouse_reconnect(struct serio *serio)
1342 if (psmouse->reconnect(psmouse)) 1367 if (psmouse->reconnect(psmouse))
1343 goto out; 1368 goto out;
1344 } else if (psmouse_probe(psmouse) < 0 || 1369 } else if (psmouse_probe(psmouse) < 0 ||
1345 psmouse->type != psmouse_extensions(psmouse, psmouse_max_proto, 0)) 1370 psmouse->type != psmouse_extensions(psmouse,
1371 psmouse_max_proto, false)) {
1346 goto out; 1372 goto out;
1373 }
1347 1374
1348 /* ok, the device type (and capabilities) match the old one, 1375 /* ok, the device type (and capabilities) match the old one,
1349 * we can continue using it, complete intialization 1376 * we can continue using it, complete intialization
@@ -1528,7 +1555,9 @@ static ssize_t psmouse_attr_set_protocol(struct psmouse *psmouse, void *data, co
1528 1555
1529 while (serio->child) { 1556 while (serio->child) {
1530 if (++retry > 3) { 1557 if (++retry > 3) {
1531 printk(KERN_WARNING "psmouse: failed to destroy child port, protocol change aborted.\n"); 1558 printk(KERN_WARNING
1559 "psmouse: failed to destroy child port, "
1560 "protocol change aborted.\n");
1532 input_free_device(new_dev); 1561 input_free_device(new_dev);
1533 return -EIO; 1562 return -EIO;
1534 } 1563 }