4 * Copyright (c) 1999-2002 Vojtech Pavlik
5 * Copyright (c) 2003-2004 Dmitry Torokhov
9 * This program is free software; you can redistribute it and/or modify it
10 * under the terms of the GNU General Public License version 2 as published by
11 * the Free Software Foundation.
14 #include <linux/delay.h>
15 #include <linux/module.h>
16 #include <linux/slab.h>
17 #include <linux/interrupt.h>
18 #include <linux/input.h>
19 #include <linux/serio.h>
20 #include <linux/init.h>
21 #include <linux/libps2.h>
22 #include <linux/mutex.h>
25 #include "synaptics.h"
26 #include "logips2pp.h"
30 #include "trackpoint.h"
31 #include "touchkit_ps2.h"
35 #define DRIVER_DESC "PS/2 mouse driver"
37 MODULE_AUTHOR("Vojtech Pavlik <vojtech@suse.cz>");
38 MODULE_DESCRIPTION(DRIVER_DESC);
39 MODULE_LICENSE("GPL");
41 static unsigned int psmouse_max_proto = PSMOUSE_AUTO;
42 static int psmouse_set_maxproto(const char *val, struct kernel_param *kp);
43 static int psmouse_get_maxproto(char *buffer, struct kernel_param *kp);
44 #define param_check_proto_abbrev(name, p) __param_check(name, p, unsigned int)
45 #define param_set_proto_abbrev psmouse_set_maxproto
46 #define param_get_proto_abbrev psmouse_get_maxproto
47 module_param_named(proto, psmouse_max_proto, proto_abbrev, 0644);
48 MODULE_PARM_DESC(proto, "Highest protocol extension to probe (bare, imps, exps, any). Useful for KVM switches.");
50 static unsigned int psmouse_resolution = 200;
51 module_param_named(resolution, psmouse_resolution, uint, 0644);
52 MODULE_PARM_DESC(resolution, "Resolution, in dpi.");
54 static unsigned int psmouse_rate = 100;
55 module_param_named(rate, psmouse_rate, uint, 0644);
56 MODULE_PARM_DESC(rate, "Report rate, in reports per second.");
58 static unsigned int psmouse_smartscroll = 1;
59 module_param_named(smartscroll, psmouse_smartscroll, bool, 0644);
60 MODULE_PARM_DESC(smartscroll, "Logitech Smartscroll autorepeat, 1 = enabled (default), 0 = disabled.");
62 static unsigned int psmouse_resetafter = 5;
63 module_param_named(resetafter, psmouse_resetafter, uint, 0644);
64 MODULE_PARM_DESC(resetafter, "Reset device after so many bad packets (0 = never).");
66 static unsigned int psmouse_resync_time;
67 module_param_named(resync_time, psmouse_resync_time, uint, 0644);
68 MODULE_PARM_DESC(resync_time, "How long can mouse stay idle before forcing resync (in seconds, 0 = never).");
70 PSMOUSE_DEFINE_ATTR(protocol, S_IWUSR | S_IRUGO,
72 psmouse_attr_show_protocol, psmouse_attr_set_protocol);
73 PSMOUSE_DEFINE_ATTR(rate, S_IWUSR | S_IRUGO,
74 (void *) offsetof(struct psmouse, rate),
75 psmouse_show_int_attr, psmouse_attr_set_rate);
76 PSMOUSE_DEFINE_ATTR(resolution, S_IWUSR | S_IRUGO,
77 (void *) offsetof(struct psmouse, resolution),
78 psmouse_show_int_attr, psmouse_attr_set_resolution);
79 PSMOUSE_DEFINE_ATTR(resetafter, S_IWUSR | S_IRUGO,
80 (void *) offsetof(struct psmouse, resetafter),
81 psmouse_show_int_attr, psmouse_set_int_attr);
82 PSMOUSE_DEFINE_ATTR(resync_time, S_IWUSR | S_IRUGO,
83 (void *) offsetof(struct psmouse, resync_time),
84 psmouse_show_int_attr, psmouse_set_int_attr);
86 static struct attribute *psmouse_attributes[] = {
87 &psmouse_attr_protocol.dattr.attr,
88 &psmouse_attr_rate.dattr.attr,
89 &psmouse_attr_resolution.dattr.attr,
90 &psmouse_attr_resetafter.dattr.attr,
91 &psmouse_attr_resync_time.dattr.attr,
95 static struct attribute_group psmouse_attribute_group = {
96 .attrs = psmouse_attributes,
100 * psmouse_mutex protects all operations changing state of mouse
101 * (connecting, disconnecting, changing rate or resolution via
102 * sysfs). We could use a per-device semaphore but since there
103 * rarely more than one PS/2 mouse connected and since semaphore
104 * is taken in "slow" paths it is not worth it.
106 static DEFINE_MUTEX(psmouse_mutex);
108 static struct workqueue_struct *kpsmoused_wq;
110 struct psmouse_protocol {
111 enum psmouse_type type;
115 int (*detect)(struct psmouse *, bool);
116 int (*init)(struct psmouse *);
120 * psmouse_process_byte() analyzes the PS/2 data stream and reports
121 * relevant events to the input module once full packet has arrived.
124 static psmouse_ret_t psmouse_process_byte(struct psmouse *psmouse)
126 struct input_dev *dev = psmouse->dev;
127 unsigned char *packet = psmouse->packet;
129 if (psmouse->pktcnt < psmouse->pktsize)
130 return PSMOUSE_GOOD_DATA;
133 * Full packet accumulated, process it
137 * Scroll wheel on IntelliMice, scroll buttons on NetMice
140 if (psmouse->type == PSMOUSE_IMPS || psmouse->type == PSMOUSE_GENPS)
141 input_report_rel(dev, REL_WHEEL, -(signed char) packet[3]);
144 * Scroll wheel and buttons on IntelliMouse Explorer
147 if (psmouse->type == PSMOUSE_IMEX) {
148 switch (packet[3] & 0xC0) {
149 case 0x80: /* vertical scroll on IntelliMouse Explorer 4.0 */
150 input_report_rel(dev, REL_WHEEL, (int) (packet[3] & 32) - (int) (packet[3] & 31));
152 case 0x40: /* horizontal scroll on IntelliMouse Explorer 4.0 */
153 input_report_rel(dev, REL_HWHEEL, (int) (packet[3] & 32) - (int) (packet[3] & 31));
157 input_report_rel(dev, REL_WHEEL, (int) (packet[3] & 8) - (int) (packet[3] & 7));
158 input_report_key(dev, BTN_SIDE, (packet[3] >> 4) & 1);
159 input_report_key(dev, BTN_EXTRA, (packet[3] >> 5) & 1);
165 * Extra buttons on Genius NewNet 3D
168 if (psmouse->type == PSMOUSE_GENPS) {
169 input_report_key(dev, BTN_SIDE, (packet[0] >> 6) & 1);
170 input_report_key(dev, BTN_EXTRA, (packet[0] >> 7) & 1);
174 * Extra button on ThinkingMouse
176 if (psmouse->type == PSMOUSE_THINKPS) {
177 input_report_key(dev, BTN_EXTRA, (packet[0] >> 3) & 1);
178 /* Without this bit of weirdness moving up gives wildly high Y changes. */
179 packet[1] |= (packet[0] & 0x40) << 1;
183 * Cortron PS2 Trackball reports SIDE button on the 4th bit of the first
186 if (psmouse->type == PSMOUSE_CORTRON) {
187 input_report_key(dev, BTN_SIDE, (packet[0] >> 3) & 1);
195 input_report_key(dev, BTN_LEFT, packet[0] & 1);
196 input_report_key(dev, BTN_MIDDLE, (packet[0] >> 2) & 1);
197 input_report_key(dev, BTN_RIGHT, (packet[0] >> 1) & 1);
199 input_report_rel(dev, REL_X, packet[1] ? (int) packet[1] - (int) ((packet[0] << 4) & 0x100) : 0);
200 input_report_rel(dev, REL_Y, packet[2] ? (int) ((packet[0] << 3) & 0x100) - (int) packet[2] : 0);
204 return PSMOUSE_FULL_PACKET;
207 void psmouse_queue_work(struct psmouse *psmouse, struct delayed_work *work,
210 queue_delayed_work(kpsmoused_wq, work, delay);
214 * __psmouse_set_state() sets new psmouse state and resets all flags.
217 static inline void __psmouse_set_state(struct psmouse *psmouse, enum psmouse_state new_state)
219 psmouse->state = new_state;
220 psmouse->pktcnt = psmouse->out_of_sync_cnt = 0;
221 psmouse->ps2dev.flags = 0;
222 psmouse->last = jiffies;
227 * psmouse_set_state() sets new psmouse state and resets all flags and
228 * counters while holding serio lock so fighting with interrupt handler
232 void psmouse_set_state(struct psmouse *psmouse, enum psmouse_state new_state)
234 serio_pause_rx(psmouse->ps2dev.serio);
235 __psmouse_set_state(psmouse, new_state);
236 serio_continue_rx(psmouse->ps2dev.serio);
240 * psmouse_handle_byte() processes one byte of the input data stream
241 * by calling corresponding protocol handler.
244 static int psmouse_handle_byte(struct psmouse *psmouse)
246 psmouse_ret_t rc = psmouse->protocol_handler(psmouse);
249 case PSMOUSE_BAD_DATA:
250 if (psmouse->state == PSMOUSE_ACTIVATED) {
251 printk(KERN_WARNING "psmouse.c: %s at %s lost sync at byte %d\n",
252 psmouse->name, psmouse->phys, psmouse->pktcnt);
253 if (++psmouse->out_of_sync_cnt == psmouse->resetafter) {
254 __psmouse_set_state(psmouse, PSMOUSE_IGNORE);
255 printk(KERN_NOTICE "psmouse.c: issuing reconnect request\n");
256 serio_reconnect(psmouse->ps2dev.serio);
263 case PSMOUSE_FULL_PACKET:
265 if (psmouse->out_of_sync_cnt) {
266 psmouse->out_of_sync_cnt = 0;
267 printk(KERN_NOTICE "psmouse.c: %s at %s - driver resynched.\n",
268 psmouse->name, psmouse->phys);
272 case PSMOUSE_GOOD_DATA:
279 * psmouse_interrupt() handles incoming characters, either passing them
280 * for normal processing or gathering them as command response.
283 static irqreturn_t psmouse_interrupt(struct serio *serio,
284 unsigned char data, unsigned int flags)
286 struct psmouse *psmouse = serio_get_drvdata(serio);
288 if (psmouse->state == PSMOUSE_IGNORE)
291 if (flags & (SERIO_PARITY|SERIO_TIMEOUT)) {
292 if (psmouse->state == PSMOUSE_ACTIVATED)
293 printk(KERN_WARNING "psmouse.c: bad data from KBC -%s%s\n",
294 flags & SERIO_TIMEOUT ? " timeout" : "",
295 flags & SERIO_PARITY ? " bad parity" : "");
296 ps2_cmd_aborted(&psmouse->ps2dev);
300 if (unlikely(psmouse->ps2dev.flags & PS2_FLAG_ACK))
301 if (ps2_handle_ack(&psmouse->ps2dev, data))
304 if (unlikely(psmouse->ps2dev.flags & PS2_FLAG_CMD))
305 if (ps2_handle_response(&psmouse->ps2dev, data))
308 if (psmouse->state <= PSMOUSE_RESYNCING)
311 if (psmouse->state == PSMOUSE_ACTIVATED &&
312 psmouse->pktcnt && time_after(jiffies, psmouse->last + HZ/2)) {
313 printk(KERN_INFO "psmouse.c: %s at %s lost synchronization, throwing %d bytes away.\n",
314 psmouse->name, psmouse->phys, psmouse->pktcnt);
315 psmouse->badbyte = psmouse->packet[0];
316 __psmouse_set_state(psmouse, PSMOUSE_RESYNCING);
317 psmouse_queue_work(psmouse, &psmouse->resync_work, 0);
321 psmouse->packet[psmouse->pktcnt++] = data;
323 * Check if this is a new device announcement (0xAA 0x00)
325 if (unlikely(psmouse->packet[0] == PSMOUSE_RET_BAT && psmouse->pktcnt <= 2)) {
326 if (psmouse->pktcnt == 1) {
327 psmouse->last = jiffies;
331 if (psmouse->packet[1] == PSMOUSE_RET_ID ||
332 (psmouse->type == PSMOUSE_HGPK &&
333 psmouse->packet[1] == PSMOUSE_RET_BAT)) {
334 __psmouse_set_state(psmouse, PSMOUSE_IGNORE);
335 serio_reconnect(serio);
339 * Not a new device, try processing first byte normally
342 if (psmouse_handle_byte(psmouse))
345 psmouse->packet[psmouse->pktcnt++] = data;
349 * See if we need to force resync because mouse was idle for too long
351 if (psmouse->state == PSMOUSE_ACTIVATED &&
352 psmouse->pktcnt == 1 && psmouse->resync_time &&
353 time_after(jiffies, psmouse->last + psmouse->resync_time * HZ)) {
354 psmouse->badbyte = psmouse->packet[0];
355 __psmouse_set_state(psmouse, PSMOUSE_RESYNCING);
356 psmouse_queue_work(psmouse, &psmouse->resync_work, 0);
360 psmouse->last = jiffies;
361 psmouse_handle_byte(psmouse);
369 * psmouse_sliced_command() sends an extended PS/2 command to the mouse
370 * using sliced syntax, understood by advanced devices, such as Logitech
371 * or Synaptics touchpads. The command is encoded as:
372 * 0xE6 0xE8 rr 0xE8 ss 0xE8 tt 0xE8 uu where (rr*64)+(ss*16)+(tt*4)+uu
375 int psmouse_sliced_command(struct psmouse *psmouse, unsigned char command)
379 if (ps2_command(&psmouse->ps2dev, NULL, PSMOUSE_CMD_SETSCALE11))
382 for (i = 6; i >= 0; i -= 2) {
383 unsigned char d = (command >> i) & 3;
384 if (ps2_command(&psmouse->ps2dev, &d, PSMOUSE_CMD_SETRES))
393 * psmouse_reset() resets the mouse into power-on state.
395 int psmouse_reset(struct psmouse *psmouse)
397 unsigned char param[2];
399 if (ps2_command(&psmouse->ps2dev, param, PSMOUSE_CMD_RESET_BAT))
402 if (param[0] != PSMOUSE_RET_BAT && param[1] != PSMOUSE_RET_ID)
410 * Genius NetMouse magic init.
412 static int genius_detect(struct psmouse *psmouse, bool set_properties)
414 struct ps2dev *ps2dev = &psmouse->ps2dev;
415 unsigned char param[4];
418 ps2_command(ps2dev, param, PSMOUSE_CMD_SETRES);
419 ps2_command(ps2dev, NULL, PSMOUSE_CMD_SETSCALE11);
420 ps2_command(ps2dev, NULL, PSMOUSE_CMD_SETSCALE11);
421 ps2_command(ps2dev, NULL, PSMOUSE_CMD_SETSCALE11);
422 ps2_command(ps2dev, param, PSMOUSE_CMD_GETINFO);
424 if (param[0] != 0x00 || param[1] != 0x33 || param[2] != 0x55)
427 if (set_properties) {
428 __set_bit(BTN_MIDDLE, psmouse->dev->keybit);
429 __set_bit(BTN_EXTRA, psmouse->dev->keybit);
430 __set_bit(BTN_SIDE, psmouse->dev->keybit);
431 __set_bit(REL_WHEEL, psmouse->dev->relbit);
433 psmouse->vendor = "Genius";
434 psmouse->name = "Mouse";
435 psmouse->pktsize = 4;
442 * IntelliMouse magic init.
444 static int intellimouse_detect(struct psmouse *psmouse, bool set_properties)
446 struct ps2dev *ps2dev = &psmouse->ps2dev;
447 unsigned char param[2];
450 ps2_command(ps2dev, param, PSMOUSE_CMD_SETRATE);
452 ps2_command(ps2dev, param, PSMOUSE_CMD_SETRATE);
454 ps2_command(ps2dev, param, PSMOUSE_CMD_SETRATE);
455 ps2_command(ps2dev, param, PSMOUSE_CMD_GETID);
460 if (set_properties) {
461 __set_bit(BTN_MIDDLE, psmouse->dev->keybit);
462 __set_bit(REL_WHEEL, psmouse->dev->relbit);
464 if (!psmouse->vendor)
465 psmouse->vendor = "Generic";
467 psmouse->name = "Wheel Mouse";
468 psmouse->pktsize = 4;
475 * Try IntelliMouse/Explorer magic init.
477 static int im_explorer_detect(struct psmouse *psmouse, bool set_properties)
479 struct ps2dev *ps2dev = &psmouse->ps2dev;
480 unsigned char param[2];
482 intellimouse_detect(psmouse, 0);
485 ps2_command(ps2dev, param, PSMOUSE_CMD_SETRATE);
487 ps2_command(ps2dev, param, PSMOUSE_CMD_SETRATE);
489 ps2_command(ps2dev, param, PSMOUSE_CMD_SETRATE);
490 ps2_command(ps2dev, param, PSMOUSE_CMD_GETID);
495 /* Magic to enable horizontal scrolling on IntelliMouse 4.0 */
497 ps2_command(ps2dev, param, PSMOUSE_CMD_SETRATE);
499 ps2_command(ps2dev, param, PSMOUSE_CMD_SETRATE);
501 ps2_command(ps2dev, param, PSMOUSE_CMD_SETRATE);
503 if (set_properties) {
504 __set_bit(BTN_MIDDLE, psmouse->dev->keybit);
505 __set_bit(REL_WHEEL, psmouse->dev->relbit);
506 __set_bit(REL_HWHEEL, psmouse->dev->relbit);
507 __set_bit(BTN_SIDE, psmouse->dev->keybit);
508 __set_bit(BTN_EXTRA, psmouse->dev->keybit);
510 if (!psmouse->vendor)
511 psmouse->vendor = "Generic";
513 psmouse->name = "Explorer Mouse";
514 psmouse->pktsize = 4;
521 * Kensington ThinkingMouse / ExpertMouse magic init.
523 static int thinking_detect(struct psmouse *psmouse, bool set_properties)
525 struct ps2dev *ps2dev = &psmouse->ps2dev;
526 unsigned char param[2];
527 static const unsigned char seq[] = { 20, 60, 40, 20, 20, 60, 40, 20, 20 };
531 ps2_command(ps2dev, param, PSMOUSE_CMD_SETRATE);
533 ps2_command(ps2dev, param, PSMOUSE_CMD_SETRES);
534 for (i = 0; i < ARRAY_SIZE(seq); i++) {
536 ps2_command(ps2dev, param, PSMOUSE_CMD_SETRATE);
538 ps2_command(ps2dev, param, PSMOUSE_CMD_GETID);
543 if (set_properties) {
544 __set_bit(BTN_MIDDLE, psmouse->dev->keybit);
545 __set_bit(BTN_EXTRA, psmouse->dev->keybit);
547 psmouse->vendor = "Kensington";
548 psmouse->name = "ThinkingMouse";
555 * Bare PS/2 protocol "detection". Always succeeds.
557 static int ps2bare_detect(struct psmouse *psmouse, bool set_properties)
559 if (set_properties) {
560 if (!psmouse->vendor)
561 psmouse->vendor = "Generic";
563 psmouse->name = "Mouse";
566 * We have no way of figuring true number of buttons so let's
567 * assume that the device has 3.
569 __set_bit(BTN_MIDDLE, psmouse->dev->keybit);
576 * Cortron PS/2 protocol detection. There's no special way to detect it, so it
577 * must be forced by sysfs protocol writing.
579 static int cortron_detect(struct psmouse *psmouse, bool set_properties)
581 if (set_properties) {
582 psmouse->vendor = "Cortron";
583 psmouse->name = "PS/2 Trackball";
585 __set_bit(BTN_MIDDLE, psmouse->dev->keybit);
586 __set_bit(BTN_SIDE, psmouse->dev->keybit);
593 * psmouse_extensions() probes for any extensions to the basic PS/2 protocol
594 * the mouse may have.
597 static int psmouse_extensions(struct psmouse *psmouse,
598 unsigned int max_proto, bool set_properties)
600 bool synaptics_hardware = false;
603 * We always check for lifebook because it does not disturb mouse
604 * (it only checks DMI information).
606 if (lifebook_detect(psmouse, set_properties) == 0) {
607 if (max_proto > PSMOUSE_IMEX) {
608 if (!set_properties || lifebook_init(psmouse) == 0)
609 return PSMOUSE_LIFEBOOK;
614 * Try Kensington ThinkingMouse (we try first, because synaptics probe
615 * upsets the thinkingmouse).
618 if (max_proto > PSMOUSE_IMEX && thinking_detect(psmouse, set_properties) == 0)
619 return PSMOUSE_THINKPS;
622 * Try Synaptics TouchPad. Note that probing is done even if Synaptics protocol
623 * support is disabled in config - we need to know if it is synaptics so we
624 * can reset it properly after probing for intellimouse.
626 if (max_proto > PSMOUSE_PS2 && synaptics_detect(psmouse, set_properties) == 0) {
627 synaptics_hardware = true;
629 if (max_proto > PSMOUSE_IMEX) {
630 if (!set_properties || synaptics_init(psmouse) == 0)
631 return PSMOUSE_SYNAPTICS;
633 * Some Synaptics touchpads can emulate extended protocols (like IMPS/2).
634 * Unfortunately Logitech/Genius probes confuse some firmware versions so
635 * we'll have to skip them.
637 max_proto = PSMOUSE_IMEX;
640 * Make sure that touchpad is in relative mode, gestures (taps) are enabled
642 synaptics_reset(psmouse);
648 if (max_proto > PSMOUSE_IMEX) {
649 ps2_command(&psmouse->ps2dev, NULL, PSMOUSE_CMD_RESET_DIS);
650 if (alps_detect(psmouse, set_properties) == 0) {
651 if (!set_properties || alps_init(psmouse) == 0)
654 * Init failed, try basic relative protocols
656 max_proto = PSMOUSE_IMEX;
661 * Try OLPC HGPK touchpad.
663 if (max_proto > PSMOUSE_IMEX &&
664 hgpk_detect(psmouse, set_properties) == 0) {
665 if (!set_properties || hgpk_init(psmouse) == 0)
668 * Init failed, try basic relative protocols
670 max_proto = PSMOUSE_IMEX;
674 * Try Elantech touchpad.
676 if (max_proto > PSMOUSE_IMEX &&
677 elantech_detect(psmouse, set_properties) == 0) {
678 if (!set_properties || elantech_init(psmouse) == 0)
679 return PSMOUSE_ELANTECH;
681 * Init failed, try basic relative protocols
683 max_proto = PSMOUSE_IMEX;
687 * Try Finger Sensing Pad
689 if (max_proto > PSMOUSE_IMEX) {
690 if (fsp_detect(psmouse, set_properties) == 0) {
691 if (!set_properties || fsp_init(psmouse) == 0)
694 * Init failed, try basic relative protocols
696 max_proto = PSMOUSE_IMEX;
700 if (max_proto > PSMOUSE_IMEX) {
701 if (genius_detect(psmouse, set_properties) == 0)
702 return PSMOUSE_GENPS;
704 if (ps2pp_init(psmouse, set_properties) == 0)
705 return PSMOUSE_PS2PP;
707 if (trackpoint_detect(psmouse, set_properties) == 0)
708 return PSMOUSE_TRACKPOINT;
710 if (touchkit_ps2_detect(psmouse, set_properties) == 0)
711 return PSMOUSE_TOUCHKIT_PS2;
715 * Reset to defaults in case the device got confused by extended
716 * protocol probes. Note that we follow up with full reset because
717 * some mice put themselves to sleep when they see PSMOUSE_RESET_DIS.
719 ps2_command(&psmouse->ps2dev, NULL, PSMOUSE_CMD_RESET_DIS);
720 psmouse_reset(psmouse);
722 if (max_proto >= PSMOUSE_IMEX && im_explorer_detect(psmouse, set_properties) == 0)
725 if (max_proto >= PSMOUSE_IMPS && intellimouse_detect(psmouse, set_properties) == 0)
729 * Okay, all failed, we have a standard mouse here. The number of the buttons
730 * is still a question, though. We assume 3.
732 ps2bare_detect(psmouse, set_properties);
734 if (synaptics_hardware) {
736 * We detected Synaptics hardware but it did not respond to IMPS/2 probes.
737 * We need to reset the touchpad because if there is a track point on the
738 * pass through port it could get disabled while probing for protocol
741 psmouse_reset(psmouse);
747 static const struct psmouse_protocol psmouse_protocols[] = {
753 .detect = ps2bare_detect,
755 #ifdef CONFIG_MOUSE_PS2_LOGIPS2PP
757 .type = PSMOUSE_PS2PP,
760 .detect = ps2pp_init,
764 .type = PSMOUSE_THINKPS,
767 .detect = thinking_detect,
770 .type = PSMOUSE_GENPS,
773 .detect = genius_detect,
776 .type = PSMOUSE_IMPS,
780 .detect = intellimouse_detect,
783 .type = PSMOUSE_IMEX,
787 .detect = im_explorer_detect,
789 #ifdef CONFIG_MOUSE_PS2_SYNAPTICS
791 .type = PSMOUSE_SYNAPTICS,
793 .alias = "synaptics",
794 .detect = synaptics_detect,
795 .init = synaptics_init,
798 #ifdef CONFIG_MOUSE_PS2_ALPS
800 .type = PSMOUSE_ALPS,
803 .detect = alps_detect,
807 #ifdef CONFIG_MOUSE_PS2_LIFEBOOK
809 .type = PSMOUSE_LIFEBOOK,
812 .init = lifebook_init,
815 #ifdef CONFIG_MOUSE_PS2_TRACKPOINT
817 .type = PSMOUSE_TRACKPOINT,
819 .alias = "trackpoint",
820 .detect = trackpoint_detect,
823 #ifdef CONFIG_MOUSE_PS2_TOUCHKIT
825 .type = PSMOUSE_TOUCHKIT_PS2,
826 .name = "touchkitPS/2",
828 .detect = touchkit_ps2_detect,
831 #ifdef CONFIG_MOUSE_PS2_OLPC
833 .type = PSMOUSE_HGPK,
836 .detect = hgpk_detect,
839 #ifdef CONFIG_MOUSE_PS2_ELANTECH
841 .type = PSMOUSE_ELANTECH,
844 .detect = elantech_detect,
845 .init = elantech_init,
848 #ifdef CONFIG_MOUSE_PS2_SENTELIC
853 .detect = fsp_detect,
858 .type = PSMOUSE_CORTRON,
859 .name = "CortronPS/2",
861 .detect = cortron_detect,
864 .type = PSMOUSE_AUTO,
871 static const struct psmouse_protocol *psmouse_protocol_by_type(enum psmouse_type type)
875 for (i = 0; i < ARRAY_SIZE(psmouse_protocols); i++)
876 if (psmouse_protocols[i].type == type)
877 return &psmouse_protocols[i];
880 return &psmouse_protocols[0];
883 static const struct psmouse_protocol *psmouse_protocol_by_name(const char *name, size_t len)
885 const struct psmouse_protocol *p;
888 for (i = 0; i < ARRAY_SIZE(psmouse_protocols); i++) {
889 p = &psmouse_protocols[i];
891 if ((strlen(p->name) == len && !strncmp(p->name, name, len)) ||
892 (strlen(p->alias) == len && !strncmp(p->alias, name, len)))
893 return &psmouse_protocols[i];
901 * psmouse_probe() probes for a PS/2 mouse.
904 static int psmouse_probe(struct psmouse *psmouse)
906 struct ps2dev *ps2dev = &psmouse->ps2dev;
907 unsigned char param[2];
910 * First, we check if it's a mouse. It should send 0x00 or 0x03
911 * in case of an IntelliMouse in 4-byte mode or 0x04 for IM Explorer.
912 * Sunrex K8561 IR Keyboard/Mouse reports 0xff on second and subsequent
913 * ID queries, probably due to a firmware bug.
917 if (ps2_command(ps2dev, param, PSMOUSE_CMD_GETID))
920 if (param[0] != 0x00 && param[0] != 0x03 &&
921 param[0] != 0x04 && param[0] != 0xff)
925 * Then we reset and disable the mouse so that it doesn't generate events.
928 if (ps2_command(ps2dev, NULL, PSMOUSE_CMD_RESET_DIS))
929 printk(KERN_WARNING "psmouse.c: Failed to reset mouse on %s\n", ps2dev->serio->phys);
935 * Here we set the mouse resolution.
938 void psmouse_set_resolution(struct psmouse *psmouse, unsigned int resolution)
940 static const unsigned char params[] = { 0, 1, 2, 2, 3 };
943 if (resolution == 0 || resolution > 200)
946 p = params[resolution / 50];
947 ps2_command(&psmouse->ps2dev, &p, PSMOUSE_CMD_SETRES);
948 psmouse->resolution = 25 << p;
952 * Here we set the mouse report rate.
955 static void psmouse_set_rate(struct psmouse *psmouse, unsigned int rate)
957 static const unsigned char rates[] = { 200, 100, 80, 60, 40, 20, 10, 0 };
961 while (rates[i] > rate) i++;
963 ps2_command(&psmouse->ps2dev, &r, PSMOUSE_CMD_SETRATE);
968 * psmouse_initialize() initializes the mouse to a sane state.
971 static void psmouse_initialize(struct psmouse *psmouse)
974 * We set the mouse report rate, resolution and scaling.
977 if (psmouse_max_proto != PSMOUSE_PS2) {
978 psmouse->set_rate(psmouse, psmouse->rate);
979 psmouse->set_resolution(psmouse, psmouse->resolution);
980 ps2_command(&psmouse->ps2dev, NULL, PSMOUSE_CMD_SETSCALE11);
985 * psmouse_activate() enables the mouse so that we get motion reports from it.
988 static void psmouse_activate(struct psmouse *psmouse)
990 if (ps2_command(&psmouse->ps2dev, NULL, PSMOUSE_CMD_ENABLE))
991 printk(KERN_WARNING "psmouse.c: Failed to enable mouse on %s\n",
992 psmouse->ps2dev.serio->phys);
994 psmouse_set_state(psmouse, PSMOUSE_ACTIVATED);
999 * psmouse_deactivate() puts the mouse into poll mode so that we don't get motion
1000 * reports from it unless we explicitly request it.
1003 static void psmouse_deactivate(struct psmouse *psmouse)
1005 if (ps2_command(&psmouse->ps2dev, NULL, PSMOUSE_CMD_DISABLE))
1006 printk(KERN_WARNING "psmouse.c: Failed to deactivate mouse on %s\n",
1007 psmouse->ps2dev.serio->phys);
1009 psmouse_set_state(psmouse, PSMOUSE_CMD_MODE);
1013 * psmouse_poll() - default poll hanlder. Everyone except for ALPS uses it.
1016 static int psmouse_poll(struct psmouse *psmouse)
1018 return ps2_command(&psmouse->ps2dev, psmouse->packet,
1019 PSMOUSE_CMD_POLL | (psmouse->pktsize << 8));
1024 * psmouse_resync() attempts to re-validate current protocol.
1027 static void psmouse_resync(struct work_struct *work)
1029 struct psmouse *parent = NULL, *psmouse =
1030 container_of(work, struct psmouse, resync_work.work);
1031 struct serio *serio = psmouse->ps2dev.serio;
1032 psmouse_ret_t rc = PSMOUSE_GOOD_DATA;
1033 bool failed = false, enabled = false;
1036 mutex_lock(&psmouse_mutex);
1038 if (psmouse->state != PSMOUSE_RESYNCING)
1041 if (serio->parent && serio->id.type == SERIO_PS_PSTHRU) {
1042 parent = serio_get_drvdata(serio->parent);
1043 psmouse_deactivate(parent);
1047 * Some mice don't ACK commands sent while they are in the middle of
1048 * transmitting motion packet. To avoid delay we use ps2_sendbyte()
1049 * instead of ps2_command() which would wait for 200ms for an ACK
1050 * that may never come.
1051 * As an additional quirk ALPS touchpads may not only forget to ACK
1052 * disable command but will stop reporting taps, so if we see that
1053 * mouse at least once ACKs disable we will do full reconnect if ACK
1056 psmouse->num_resyncs++;
1058 if (ps2_sendbyte(&psmouse->ps2dev, PSMOUSE_CMD_DISABLE, 20)) {
1059 if (psmouse->num_resyncs < 3 || psmouse->acks_disable_command)
1062 psmouse->acks_disable_command = true;
1065 * Poll the mouse. If it was reset the packet will be shorter than
1066 * psmouse->pktsize and ps2_command will fail. We do not expect and
1067 * do not handle scenario when mouse "upgrades" its protocol while
1068 * disconnected since it would require additional delay. If we ever
1069 * see a mouse that does it we'll adjust the code.
1072 if (psmouse->poll(psmouse))
1075 psmouse_set_state(psmouse, PSMOUSE_CMD_MODE);
1076 for (i = 0; i < psmouse->pktsize; i++) {
1078 rc = psmouse->protocol_handler(psmouse);
1079 if (rc != PSMOUSE_GOOD_DATA)
1082 if (rc != PSMOUSE_FULL_PACKET)
1084 psmouse_set_state(psmouse, PSMOUSE_RESYNCING);
1088 * Now try to enable mouse. We try to do that even if poll failed and also
1089 * repeat our attempts 5 times, otherwise we may be left out with disabled
1092 for (i = 0; i < 5; i++) {
1093 if (!ps2_command(&psmouse->ps2dev, NULL, PSMOUSE_CMD_ENABLE)) {
1101 printk(KERN_WARNING "psmouse.c: failed to re-enable mouse on %s\n",
1102 psmouse->ps2dev.serio->phys);
1107 psmouse_set_state(psmouse, PSMOUSE_IGNORE);
1108 printk(KERN_INFO "psmouse.c: resync failed, issuing reconnect request\n");
1109 serio_reconnect(serio);
1111 psmouse_set_state(psmouse, PSMOUSE_ACTIVATED);
1114 psmouse_activate(parent);
1116 mutex_unlock(&psmouse_mutex);
1120 * psmouse_cleanup() resets the mouse into power-on state.
1123 static void psmouse_cleanup(struct serio *serio)
1125 struct psmouse *psmouse = serio_get_drvdata(serio);
1126 struct psmouse *parent = NULL;
1128 mutex_lock(&psmouse_mutex);
1130 if (serio->parent && serio->id.type == SERIO_PS_PSTHRU) {
1131 parent = serio_get_drvdata(serio->parent);
1132 psmouse_deactivate(parent);
1135 psmouse_deactivate(psmouse);
1137 if (psmouse->cleanup)
1138 psmouse->cleanup(psmouse);
1141 * Reset the mouse to defaults (bare PS/2 protocol).
1143 ps2_command(&psmouse->ps2dev, NULL, PSMOUSE_CMD_RESET_DIS);
1146 * Some boxes, such as HP nx7400, get terribly confused if mouse
1147 * is not fully enabled before suspending/shutting down.
1149 ps2_command(&psmouse->ps2dev, NULL, PSMOUSE_CMD_ENABLE);
1152 if (parent->pt_deactivate)
1153 parent->pt_deactivate(parent);
1155 psmouse_activate(parent);
1158 mutex_unlock(&psmouse_mutex);
1162 * psmouse_disconnect() closes and frees.
1165 static void psmouse_disconnect(struct serio *serio)
1167 struct psmouse *psmouse, *parent = NULL;
1169 psmouse = serio_get_drvdata(serio);
1171 sysfs_remove_group(&serio->dev.kobj, &psmouse_attribute_group);
1173 mutex_lock(&psmouse_mutex);
1175 psmouse_set_state(psmouse, PSMOUSE_CMD_MODE);
1177 /* make sure we don't have a resync in progress */
1178 mutex_unlock(&psmouse_mutex);
1179 flush_workqueue(kpsmoused_wq);
1180 mutex_lock(&psmouse_mutex);
1182 if (serio->parent && serio->id.type == SERIO_PS_PSTHRU) {
1183 parent = serio_get_drvdata(serio->parent);
1184 psmouse_deactivate(parent);
1187 if (psmouse->disconnect)
1188 psmouse->disconnect(psmouse);
1190 if (parent && parent->pt_deactivate)
1191 parent->pt_deactivate(parent);
1193 psmouse_set_state(psmouse, PSMOUSE_IGNORE);
1196 serio_set_drvdata(serio, NULL);
1197 input_unregister_device(psmouse->dev);
1201 psmouse_activate(parent);
1203 mutex_unlock(&psmouse_mutex);
1206 static int psmouse_switch_protocol(struct psmouse *psmouse,
1207 const struct psmouse_protocol *proto)
1209 struct input_dev *input_dev = psmouse->dev;
1211 input_dev->dev.parent = &psmouse->ps2dev.serio->dev;
1213 input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_REL);
1214 input_dev->keybit[BIT_WORD(BTN_MOUSE)] =
1215 BIT_MASK(BTN_LEFT) | BIT_MASK(BTN_RIGHT);
1216 input_dev->relbit[0] = BIT_MASK(REL_X) | BIT_MASK(REL_Y);
1218 psmouse->set_rate = psmouse_set_rate;
1219 psmouse->set_resolution = psmouse_set_resolution;
1220 psmouse->poll = psmouse_poll;
1221 psmouse->protocol_handler = psmouse_process_byte;
1222 psmouse->pktsize = 3;
1224 if (proto && (proto->detect || proto->init)) {
1225 if (proto->detect && proto->detect(psmouse, 1) < 0)
1228 if (proto->init && proto->init(psmouse) < 0)
1231 psmouse->type = proto->type;
1233 psmouse->type = psmouse_extensions(psmouse,
1234 psmouse_max_proto, true);
1237 * If mouse's packet size is 3 there is no point in polling the
1238 * device in hopes to detect protocol reset - we won't get less
1239 * than 3 bytes response anyhow.
1241 if (psmouse->pktsize == 3)
1242 psmouse->resync_time = 0;
1245 * Some smart KVMs fake response to POLL command returning just
1246 * 3 bytes and messing up our resync logic, so if initial poll
1247 * fails we won't try polling the device anymore. Hopefully
1248 * such KVM will maintain initially selected protocol.
1250 if (psmouse->resync_time && psmouse->poll(psmouse))
1251 psmouse->resync_time = 0;
1253 snprintf(psmouse->devname, sizeof(psmouse->devname), "%s %s %s",
1254 psmouse_protocol_by_type(psmouse->type)->name, psmouse->vendor, psmouse->name);
1256 input_dev->name = psmouse->devname;
1257 input_dev->phys = psmouse->phys;
1258 input_dev->id.bustype = BUS_I8042;
1259 input_dev->id.vendor = 0x0002;
1260 input_dev->id.product = psmouse->type;
1261 input_dev->id.version = psmouse->model;
1267 * psmouse_connect() is a callback from the serio module when
1268 * an unhandled serio port is found.
1270 static int psmouse_connect(struct serio *serio, struct serio_driver *drv)
1272 struct psmouse *psmouse, *parent = NULL;
1273 struct input_dev *input_dev;
1274 int retval = 0, error = -ENOMEM;
1276 mutex_lock(&psmouse_mutex);
1279 * If this is a pass-through port deactivate parent so the device
1280 * connected to this port can be successfully identified
1282 if (serio->parent && serio->id.type == SERIO_PS_PSTHRU) {
1283 parent = serio_get_drvdata(serio->parent);
1284 psmouse_deactivate(parent);
1287 psmouse = kzalloc(sizeof(struct psmouse), GFP_KERNEL);
1288 input_dev = input_allocate_device();
1289 if (!psmouse || !input_dev)
1292 ps2_init(&psmouse->ps2dev, serio);
1293 INIT_DELAYED_WORK(&psmouse->resync_work, psmouse_resync);
1294 psmouse->dev = input_dev;
1295 snprintf(psmouse->phys, sizeof(psmouse->phys), "%s/input0", serio->phys);
1297 psmouse_set_state(psmouse, PSMOUSE_INITIALIZING);
1299 serio_set_drvdata(serio, psmouse);
1301 error = serio_open(serio, drv);
1303 goto err_clear_drvdata;
1305 if (psmouse_probe(psmouse) < 0) {
1307 goto err_close_serio;
1310 psmouse->rate = psmouse_rate;
1311 psmouse->resolution = psmouse_resolution;
1312 psmouse->resetafter = psmouse_resetafter;
1313 psmouse->resync_time = parent ? 0 : psmouse_resync_time;
1314 psmouse->smartscroll = psmouse_smartscroll;
1316 psmouse_switch_protocol(psmouse, NULL);
1318 psmouse_set_state(psmouse, PSMOUSE_CMD_MODE);
1319 psmouse_initialize(psmouse);
1321 error = input_register_device(psmouse->dev);
1323 goto err_protocol_disconnect;
1325 if (parent && parent->pt_activate)
1326 parent->pt_activate(parent);
1328 error = sysfs_create_group(&serio->dev.kobj, &psmouse_attribute_group);
1330 goto err_pt_deactivate;
1332 psmouse_activate(psmouse);
1335 /* If this is a pass-through port the parent needs to be re-activated */
1337 psmouse_activate(parent);
1339 mutex_unlock(&psmouse_mutex);
1343 if (parent && parent->pt_deactivate)
1344 parent->pt_deactivate(parent);
1345 input_unregister_device(psmouse->dev);
1346 input_dev = NULL; /* so we don't try to free it below */
1347 err_protocol_disconnect:
1348 if (psmouse->disconnect)
1349 psmouse->disconnect(psmouse);
1350 psmouse_set_state(psmouse, PSMOUSE_IGNORE);
1354 serio_set_drvdata(serio, NULL);
1356 input_free_device(input_dev);
1364 static int psmouse_reconnect(struct serio *serio)
1366 struct psmouse *psmouse = serio_get_drvdata(serio);
1367 struct psmouse *parent = NULL;
1368 struct serio_driver *drv = serio->drv;
1371 if (!drv || !psmouse) {
1372 printk(KERN_DEBUG "psmouse: reconnect request, but serio is disconnected, ignoring...\n");
1376 mutex_lock(&psmouse_mutex);
1378 if (serio->parent && serio->id.type == SERIO_PS_PSTHRU) {
1379 parent = serio_get_drvdata(serio->parent);
1380 psmouse_deactivate(parent);
1383 psmouse_set_state(psmouse, PSMOUSE_INITIALIZING);
1385 if (psmouse->reconnect) {
1386 if (psmouse->reconnect(psmouse))
1388 } else if (psmouse_probe(psmouse) < 0 ||
1389 psmouse->type != psmouse_extensions(psmouse,
1390 psmouse_max_proto, false)) {
1394 /* ok, the device type (and capabilities) match the old one,
1395 * we can continue using it, complete intialization
1397 psmouse_set_state(psmouse, PSMOUSE_CMD_MODE);
1399 psmouse_initialize(psmouse);
1401 if (parent && parent->pt_activate)
1402 parent->pt_activate(parent);
1404 psmouse_activate(psmouse);
1408 /* If this is a pass-through port the parent waits to be activated */
1410 psmouse_activate(parent);
1412 mutex_unlock(&psmouse_mutex);
1416 static struct serio_device_id psmouse_serio_ids[] = {
1424 .type = SERIO_PS_PSTHRU,
1432 MODULE_DEVICE_TABLE(serio, psmouse_serio_ids);
1434 static struct serio_driver psmouse_drv = {
1438 .description = DRIVER_DESC,
1439 .id_table = psmouse_serio_ids,
1440 .interrupt = psmouse_interrupt,
1441 .connect = psmouse_connect,
1442 .reconnect = psmouse_reconnect,
1443 .disconnect = psmouse_disconnect,
1444 .cleanup = psmouse_cleanup,
1447 ssize_t psmouse_attr_show_helper(struct device *dev, struct device_attribute *devattr,
1450 struct serio *serio = to_serio_port(dev);
1451 struct psmouse_attribute *attr = to_psmouse_attr(devattr);
1452 struct psmouse *psmouse;
1455 retval = serio_pin_driver(serio);
1459 if (serio->drv != &psmouse_drv) {
1464 psmouse = serio_get_drvdata(serio);
1466 retval = attr->show(psmouse, attr->data, buf);
1469 serio_unpin_driver(serio);
1473 ssize_t psmouse_attr_set_helper(struct device *dev, struct device_attribute *devattr,
1474 const char *buf, size_t count)
1476 struct serio *serio = to_serio_port(dev);
1477 struct psmouse_attribute *attr = to_psmouse_attr(devattr);
1478 struct psmouse *psmouse, *parent = NULL;
1481 retval = serio_pin_driver(serio);
1485 if (serio->drv != &psmouse_drv) {
1490 retval = mutex_lock_interruptible(&psmouse_mutex);
1494 psmouse = serio_get_drvdata(serio);
1496 if (attr->protect) {
1497 if (psmouse->state == PSMOUSE_IGNORE) {
1502 if (serio->parent && serio->id.type == SERIO_PS_PSTHRU) {
1503 parent = serio_get_drvdata(serio->parent);
1504 psmouse_deactivate(parent);
1507 psmouse_deactivate(psmouse);
1510 retval = attr->set(psmouse, attr->data, buf, count);
1512 if (attr->protect) {
1513 if (retval != -ENODEV)
1514 psmouse_activate(psmouse);
1517 psmouse_activate(parent);
1521 mutex_unlock(&psmouse_mutex);
1523 serio_unpin_driver(serio);
1527 static ssize_t psmouse_show_int_attr(struct psmouse *psmouse, void *offset, char *buf)
1529 unsigned int *field = (unsigned int *)((char *)psmouse + (size_t)offset);
1531 return sprintf(buf, "%u\n", *field);
1534 static ssize_t psmouse_set_int_attr(struct psmouse *psmouse, void *offset, const char *buf, size_t count)
1536 unsigned int *field = (unsigned int *)((char *)psmouse + (size_t)offset);
1537 unsigned long value;
1539 if (strict_strtoul(buf, 10, &value))
1542 if ((unsigned int)value != value)
1550 static ssize_t psmouse_attr_show_protocol(struct psmouse *psmouse, void *data, char *buf)
1552 return sprintf(buf, "%s\n", psmouse_protocol_by_type(psmouse->type)->name);
1555 static ssize_t psmouse_attr_set_protocol(struct psmouse *psmouse, void *data, const char *buf, size_t count)
1557 struct serio *serio = psmouse->ps2dev.serio;
1558 struct psmouse *parent = NULL;
1559 struct input_dev *old_dev, *new_dev;
1560 const struct psmouse_protocol *proto, *old_proto;
1564 proto = psmouse_protocol_by_name(buf, count);
1568 if (psmouse->type == proto->type)
1571 new_dev = input_allocate_device();
1575 while (serio->child) {
1578 "psmouse: failed to destroy child port, "
1579 "protocol change aborted.\n");
1580 input_free_device(new_dev);
1584 mutex_unlock(&psmouse_mutex);
1585 serio_unpin_driver(serio);
1586 serio_unregister_child_port(serio);
1587 serio_pin_driver_uninterruptible(serio);
1588 mutex_lock(&psmouse_mutex);
1590 if (serio->drv != &psmouse_drv) {
1591 input_free_device(new_dev);
1595 if (psmouse->type == proto->type) {
1596 input_free_device(new_dev);
1597 return count; /* switched by other thread */
1601 if (serio->parent && serio->id.type == SERIO_PS_PSTHRU) {
1602 parent = serio_get_drvdata(serio->parent);
1603 if (parent->pt_deactivate)
1604 parent->pt_deactivate(parent);
1607 old_dev = psmouse->dev;
1608 old_proto = psmouse_protocol_by_type(psmouse->type);
1610 if (psmouse->disconnect)
1611 psmouse->disconnect(psmouse);
1613 psmouse_set_state(psmouse, PSMOUSE_IGNORE);
1615 psmouse->dev = new_dev;
1616 psmouse_set_state(psmouse, PSMOUSE_INITIALIZING);
1618 if (psmouse_switch_protocol(psmouse, proto) < 0) {
1619 psmouse_reset(psmouse);
1620 /* default to PSMOUSE_PS2 */
1621 psmouse_switch_protocol(psmouse, &psmouse_protocols[0]);
1624 psmouse_initialize(psmouse);
1625 psmouse_set_state(psmouse, PSMOUSE_CMD_MODE);
1627 error = input_register_device(psmouse->dev);
1629 if (psmouse->disconnect)
1630 psmouse->disconnect(psmouse);
1632 psmouse_set_state(psmouse, PSMOUSE_IGNORE);
1633 input_free_device(new_dev);
1634 psmouse->dev = old_dev;
1635 psmouse_set_state(psmouse, PSMOUSE_INITIALIZING);
1636 psmouse_switch_protocol(psmouse, old_proto);
1637 psmouse_initialize(psmouse);
1638 psmouse_set_state(psmouse, PSMOUSE_CMD_MODE);
1643 input_unregister_device(old_dev);
1645 if (parent && parent->pt_activate)
1646 parent->pt_activate(parent);
1651 static ssize_t psmouse_attr_set_rate(struct psmouse *psmouse, void *data, const char *buf, size_t count)
1653 unsigned long value;
1655 if (strict_strtoul(buf, 10, &value))
1658 psmouse->set_rate(psmouse, value);
1662 static ssize_t psmouse_attr_set_resolution(struct psmouse *psmouse, void *data, const char *buf, size_t count)
1664 unsigned long value;
1666 if (strict_strtoul(buf, 10, &value))
1669 psmouse->set_resolution(psmouse, value);
1674 static int psmouse_set_maxproto(const char *val, struct kernel_param *kp)
1676 const struct psmouse_protocol *proto;
1681 proto = psmouse_protocol_by_name(val, strlen(val));
1683 if (!proto || !proto->maxproto)
1686 *((unsigned int *)kp->arg) = proto->type;
1691 static int psmouse_get_maxproto(char *buffer, struct kernel_param *kp)
1693 int type = *((unsigned int *)kp->arg);
1695 return sprintf(buffer, "%s", psmouse_protocol_by_type(type)->name);
1698 static int __init psmouse_init(void)
1702 lifebook_module_init();
1703 synaptics_module_init();
1705 kpsmoused_wq = create_singlethread_workqueue("kpsmoused");
1706 if (!kpsmoused_wq) {
1707 printk(KERN_ERR "psmouse: failed to create kpsmoused workqueue\n");
1711 err = serio_register_driver(&psmouse_drv);
1713 destroy_workqueue(kpsmoused_wq);
1718 static void __exit psmouse_exit(void)
1720 serio_unregister_driver(&psmouse_drv);
1721 destroy_workqueue(kpsmoused_wq);
1724 module_init(psmouse_init);
1725 module_exit(psmouse_exit);