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) {
631 * Try activating protocol, but check if support is enabled first, since
632 * we try detecting Synaptics even when protocol is disabled.
634 if (synaptics_supported() &&
635 (!set_properties || synaptics_init(psmouse) == 0)) {
636 return PSMOUSE_SYNAPTICS;
640 * Some Synaptics touchpads can emulate extended protocols (like IMPS/2).
641 * Unfortunately Logitech/Genius probes confuse some firmware versions so
642 * we'll have to skip them.
644 max_proto = PSMOUSE_IMEX;
647 * Make sure that touchpad is in relative mode, gestures (taps) are enabled
649 synaptics_reset(psmouse);
655 if (max_proto > PSMOUSE_IMEX) {
656 ps2_command(&psmouse->ps2dev, NULL, PSMOUSE_CMD_RESET_DIS);
657 if (alps_detect(psmouse, set_properties) == 0) {
658 if (!set_properties || alps_init(psmouse) == 0)
661 * Init failed, try basic relative protocols
663 max_proto = PSMOUSE_IMEX;
668 * Try OLPC HGPK touchpad.
670 if (max_proto > PSMOUSE_IMEX &&
671 hgpk_detect(psmouse, set_properties) == 0) {
672 if (!set_properties || hgpk_init(psmouse) == 0)
675 * Init failed, try basic relative protocols
677 max_proto = PSMOUSE_IMEX;
681 * Try Elantech touchpad.
683 if (max_proto > PSMOUSE_IMEX &&
684 elantech_detect(psmouse, set_properties) == 0) {
685 if (!set_properties || elantech_init(psmouse) == 0)
686 return PSMOUSE_ELANTECH;
688 * Init failed, try basic relative protocols
690 max_proto = PSMOUSE_IMEX;
694 if (max_proto > PSMOUSE_IMEX) {
695 if (genius_detect(psmouse, set_properties) == 0)
696 return PSMOUSE_GENPS;
698 if (ps2pp_init(psmouse, set_properties) == 0)
699 return PSMOUSE_PS2PP;
701 if (trackpoint_detect(psmouse, set_properties) == 0)
702 return PSMOUSE_TRACKPOINT;
704 if (touchkit_ps2_detect(psmouse, set_properties) == 0)
705 return PSMOUSE_TOUCHKIT_PS2;
709 * Try Finger Sensing Pad. We do it here because its probe upsets
710 * Trackpoint devices (causing TP_READ_ID command to time out).
712 if (max_proto > PSMOUSE_IMEX) {
713 if (fsp_detect(psmouse, set_properties) == 0) {
714 if (!set_properties || fsp_init(psmouse) == 0)
717 * Init failed, try basic relative protocols
719 max_proto = PSMOUSE_IMEX;
724 * Reset to defaults in case the device got confused by extended
725 * protocol probes. Note that we follow up with full reset because
726 * some mice put themselves to sleep when they see PSMOUSE_RESET_DIS.
728 ps2_command(&psmouse->ps2dev, NULL, PSMOUSE_CMD_RESET_DIS);
729 psmouse_reset(psmouse);
731 if (max_proto >= PSMOUSE_IMEX && im_explorer_detect(psmouse, set_properties) == 0)
734 if (max_proto >= PSMOUSE_IMPS && intellimouse_detect(psmouse, set_properties) == 0)
738 * Okay, all failed, we have a standard mouse here. The number of the buttons
739 * is still a question, though. We assume 3.
741 ps2bare_detect(psmouse, set_properties);
743 if (synaptics_hardware) {
745 * We detected Synaptics hardware but it did not respond to IMPS/2 probes.
746 * We need to reset the touchpad because if there is a track point on the
747 * pass through port it could get disabled while probing for protocol
750 psmouse_reset(psmouse);
756 static const struct psmouse_protocol psmouse_protocols[] = {
762 .detect = ps2bare_detect,
764 #ifdef CONFIG_MOUSE_PS2_LOGIPS2PP
766 .type = PSMOUSE_PS2PP,
769 .detect = ps2pp_init,
773 .type = PSMOUSE_THINKPS,
776 .detect = thinking_detect,
779 .type = PSMOUSE_GENPS,
782 .detect = genius_detect,
785 .type = PSMOUSE_IMPS,
789 .detect = intellimouse_detect,
792 .type = PSMOUSE_IMEX,
796 .detect = im_explorer_detect,
798 #ifdef CONFIG_MOUSE_PS2_SYNAPTICS
800 .type = PSMOUSE_SYNAPTICS,
802 .alias = "synaptics",
803 .detect = synaptics_detect,
804 .init = synaptics_init,
807 #ifdef CONFIG_MOUSE_PS2_ALPS
809 .type = PSMOUSE_ALPS,
812 .detect = alps_detect,
816 #ifdef CONFIG_MOUSE_PS2_LIFEBOOK
818 .type = PSMOUSE_LIFEBOOK,
821 .init = lifebook_init,
824 #ifdef CONFIG_MOUSE_PS2_TRACKPOINT
826 .type = PSMOUSE_TRACKPOINT,
828 .alias = "trackpoint",
829 .detect = trackpoint_detect,
832 #ifdef CONFIG_MOUSE_PS2_TOUCHKIT
834 .type = PSMOUSE_TOUCHKIT_PS2,
835 .name = "touchkitPS/2",
837 .detect = touchkit_ps2_detect,
840 #ifdef CONFIG_MOUSE_PS2_OLPC
842 .type = PSMOUSE_HGPK,
845 .detect = hgpk_detect,
848 #ifdef CONFIG_MOUSE_PS2_ELANTECH
850 .type = PSMOUSE_ELANTECH,
853 .detect = elantech_detect,
854 .init = elantech_init,
857 #ifdef CONFIG_MOUSE_PS2_SENTELIC
862 .detect = fsp_detect,
867 .type = PSMOUSE_CORTRON,
868 .name = "CortronPS/2",
870 .detect = cortron_detect,
873 .type = PSMOUSE_AUTO,
880 static const struct psmouse_protocol *psmouse_protocol_by_type(enum psmouse_type type)
884 for (i = 0; i < ARRAY_SIZE(psmouse_protocols); i++)
885 if (psmouse_protocols[i].type == type)
886 return &psmouse_protocols[i];
889 return &psmouse_protocols[0];
892 static const struct psmouse_protocol *psmouse_protocol_by_name(const char *name, size_t len)
894 const struct psmouse_protocol *p;
897 for (i = 0; i < ARRAY_SIZE(psmouse_protocols); i++) {
898 p = &psmouse_protocols[i];
900 if ((strlen(p->name) == len && !strncmp(p->name, name, len)) ||
901 (strlen(p->alias) == len && !strncmp(p->alias, name, len)))
902 return &psmouse_protocols[i];
910 * psmouse_probe() probes for a PS/2 mouse.
913 static int psmouse_probe(struct psmouse *psmouse)
915 struct ps2dev *ps2dev = &psmouse->ps2dev;
916 unsigned char param[2];
919 * First, we check if it's a mouse. It should send 0x00 or 0x03
920 * in case of an IntelliMouse in 4-byte mode or 0x04 for IM Explorer.
921 * Sunrex K8561 IR Keyboard/Mouse reports 0xff on second and subsequent
922 * ID queries, probably due to a firmware bug.
926 if (ps2_command(ps2dev, param, PSMOUSE_CMD_GETID))
929 if (param[0] != 0x00 && param[0] != 0x03 &&
930 param[0] != 0x04 && param[0] != 0xff)
934 * Then we reset and disable the mouse so that it doesn't generate events.
937 if (ps2_command(ps2dev, NULL, PSMOUSE_CMD_RESET_DIS))
938 printk(KERN_WARNING "psmouse.c: Failed to reset mouse on %s\n", ps2dev->serio->phys);
944 * Here we set the mouse resolution.
947 void psmouse_set_resolution(struct psmouse *psmouse, unsigned int resolution)
949 static const unsigned char params[] = { 0, 1, 2, 2, 3 };
952 if (resolution == 0 || resolution > 200)
955 p = params[resolution / 50];
956 ps2_command(&psmouse->ps2dev, &p, PSMOUSE_CMD_SETRES);
957 psmouse->resolution = 25 << p;
961 * Here we set the mouse report rate.
964 static void psmouse_set_rate(struct psmouse *psmouse, unsigned int rate)
966 static const unsigned char rates[] = { 200, 100, 80, 60, 40, 20, 10, 0 };
970 while (rates[i] > rate) i++;
972 ps2_command(&psmouse->ps2dev, &r, PSMOUSE_CMD_SETRATE);
977 * psmouse_initialize() initializes the mouse to a sane state.
980 static void psmouse_initialize(struct psmouse *psmouse)
983 * We set the mouse report rate, resolution and scaling.
986 if (psmouse_max_proto != PSMOUSE_PS2) {
987 psmouse->set_rate(psmouse, psmouse->rate);
988 psmouse->set_resolution(psmouse, psmouse->resolution);
989 ps2_command(&psmouse->ps2dev, NULL, PSMOUSE_CMD_SETSCALE11);
994 * psmouse_activate() enables the mouse so that we get motion reports from it.
997 static void psmouse_activate(struct psmouse *psmouse)
999 if (ps2_command(&psmouse->ps2dev, NULL, PSMOUSE_CMD_ENABLE))
1000 printk(KERN_WARNING "psmouse.c: Failed to enable mouse on %s\n",
1001 psmouse->ps2dev.serio->phys);
1003 psmouse_set_state(psmouse, PSMOUSE_ACTIVATED);
1008 * psmouse_deactivate() puts the mouse into poll mode so that we don't get motion
1009 * reports from it unless we explicitly request it.
1012 static void psmouse_deactivate(struct psmouse *psmouse)
1014 if (ps2_command(&psmouse->ps2dev, NULL, PSMOUSE_CMD_DISABLE))
1015 printk(KERN_WARNING "psmouse.c: Failed to deactivate mouse on %s\n",
1016 psmouse->ps2dev.serio->phys);
1018 psmouse_set_state(psmouse, PSMOUSE_CMD_MODE);
1022 * psmouse_poll() - default poll hanlder. Everyone except for ALPS uses it.
1025 static int psmouse_poll(struct psmouse *psmouse)
1027 return ps2_command(&psmouse->ps2dev, psmouse->packet,
1028 PSMOUSE_CMD_POLL | (psmouse->pktsize << 8));
1033 * psmouse_resync() attempts to re-validate current protocol.
1036 static void psmouse_resync(struct work_struct *work)
1038 struct psmouse *parent = NULL, *psmouse =
1039 container_of(work, struct psmouse, resync_work.work);
1040 struct serio *serio = psmouse->ps2dev.serio;
1041 psmouse_ret_t rc = PSMOUSE_GOOD_DATA;
1042 bool failed = false, enabled = false;
1045 mutex_lock(&psmouse_mutex);
1047 if (psmouse->state != PSMOUSE_RESYNCING)
1050 if (serio->parent && serio->id.type == SERIO_PS_PSTHRU) {
1051 parent = serio_get_drvdata(serio->parent);
1052 psmouse_deactivate(parent);
1056 * Some mice don't ACK commands sent while they are in the middle of
1057 * transmitting motion packet. To avoid delay we use ps2_sendbyte()
1058 * instead of ps2_command() which would wait for 200ms for an ACK
1059 * that may never come.
1060 * As an additional quirk ALPS touchpads may not only forget to ACK
1061 * disable command but will stop reporting taps, so if we see that
1062 * mouse at least once ACKs disable we will do full reconnect if ACK
1065 psmouse->num_resyncs++;
1067 if (ps2_sendbyte(&psmouse->ps2dev, PSMOUSE_CMD_DISABLE, 20)) {
1068 if (psmouse->num_resyncs < 3 || psmouse->acks_disable_command)
1071 psmouse->acks_disable_command = true;
1074 * Poll the mouse. If it was reset the packet will be shorter than
1075 * psmouse->pktsize and ps2_command will fail. We do not expect and
1076 * do not handle scenario when mouse "upgrades" its protocol while
1077 * disconnected since it would require additional delay. If we ever
1078 * see a mouse that does it we'll adjust the code.
1081 if (psmouse->poll(psmouse))
1084 psmouse_set_state(psmouse, PSMOUSE_CMD_MODE);
1085 for (i = 0; i < psmouse->pktsize; i++) {
1087 rc = psmouse->protocol_handler(psmouse);
1088 if (rc != PSMOUSE_GOOD_DATA)
1091 if (rc != PSMOUSE_FULL_PACKET)
1093 psmouse_set_state(psmouse, PSMOUSE_RESYNCING);
1097 * Now try to enable mouse. We try to do that even if poll failed and also
1098 * repeat our attempts 5 times, otherwise we may be left out with disabled
1101 for (i = 0; i < 5; i++) {
1102 if (!ps2_command(&psmouse->ps2dev, NULL, PSMOUSE_CMD_ENABLE)) {
1110 printk(KERN_WARNING "psmouse.c: failed to re-enable mouse on %s\n",
1111 psmouse->ps2dev.serio->phys);
1116 psmouse_set_state(psmouse, PSMOUSE_IGNORE);
1117 printk(KERN_INFO "psmouse.c: resync failed, issuing reconnect request\n");
1118 serio_reconnect(serio);
1120 psmouse_set_state(psmouse, PSMOUSE_ACTIVATED);
1123 psmouse_activate(parent);
1125 mutex_unlock(&psmouse_mutex);
1129 * psmouse_cleanup() resets the mouse into power-on state.
1132 static void psmouse_cleanup(struct serio *serio)
1134 struct psmouse *psmouse = serio_get_drvdata(serio);
1135 struct psmouse *parent = NULL;
1137 mutex_lock(&psmouse_mutex);
1139 if (serio->parent && serio->id.type == SERIO_PS_PSTHRU) {
1140 parent = serio_get_drvdata(serio->parent);
1141 psmouse_deactivate(parent);
1144 psmouse_deactivate(psmouse);
1146 if (psmouse->cleanup)
1147 psmouse->cleanup(psmouse);
1150 * Reset the mouse to defaults (bare PS/2 protocol).
1152 ps2_command(&psmouse->ps2dev, NULL, PSMOUSE_CMD_RESET_DIS);
1155 * Some boxes, such as HP nx7400, get terribly confused if mouse
1156 * is not fully enabled before suspending/shutting down.
1158 ps2_command(&psmouse->ps2dev, NULL, PSMOUSE_CMD_ENABLE);
1161 if (parent->pt_deactivate)
1162 parent->pt_deactivate(parent);
1164 psmouse_activate(parent);
1167 mutex_unlock(&psmouse_mutex);
1171 * psmouse_disconnect() closes and frees.
1174 static void psmouse_disconnect(struct serio *serio)
1176 struct psmouse *psmouse, *parent = NULL;
1178 psmouse = serio_get_drvdata(serio);
1180 sysfs_remove_group(&serio->dev.kobj, &psmouse_attribute_group);
1182 mutex_lock(&psmouse_mutex);
1184 psmouse_set_state(psmouse, PSMOUSE_CMD_MODE);
1186 /* make sure we don't have a resync in progress */
1187 mutex_unlock(&psmouse_mutex);
1188 flush_workqueue(kpsmoused_wq);
1189 mutex_lock(&psmouse_mutex);
1191 if (serio->parent && serio->id.type == SERIO_PS_PSTHRU) {
1192 parent = serio_get_drvdata(serio->parent);
1193 psmouse_deactivate(parent);
1196 if (psmouse->disconnect)
1197 psmouse->disconnect(psmouse);
1199 if (parent && parent->pt_deactivate)
1200 parent->pt_deactivate(parent);
1202 psmouse_set_state(psmouse, PSMOUSE_IGNORE);
1205 serio_set_drvdata(serio, NULL);
1206 input_unregister_device(psmouse->dev);
1210 psmouse_activate(parent);
1212 mutex_unlock(&psmouse_mutex);
1215 static int psmouse_switch_protocol(struct psmouse *psmouse,
1216 const struct psmouse_protocol *proto)
1218 struct input_dev *input_dev = psmouse->dev;
1220 input_dev->dev.parent = &psmouse->ps2dev.serio->dev;
1222 input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_REL);
1223 input_dev->keybit[BIT_WORD(BTN_MOUSE)] =
1224 BIT_MASK(BTN_LEFT) | BIT_MASK(BTN_RIGHT);
1225 input_dev->relbit[0] = BIT_MASK(REL_X) | BIT_MASK(REL_Y);
1227 psmouse->set_rate = psmouse_set_rate;
1228 psmouse->set_resolution = psmouse_set_resolution;
1229 psmouse->poll = psmouse_poll;
1230 psmouse->protocol_handler = psmouse_process_byte;
1231 psmouse->pktsize = 3;
1233 if (proto && (proto->detect || proto->init)) {
1234 if (proto->detect && proto->detect(psmouse, 1) < 0)
1237 if (proto->init && proto->init(psmouse) < 0)
1240 psmouse->type = proto->type;
1242 psmouse->type = psmouse_extensions(psmouse,
1243 psmouse_max_proto, true);
1246 * If mouse's packet size is 3 there is no point in polling the
1247 * device in hopes to detect protocol reset - we won't get less
1248 * than 3 bytes response anyhow.
1250 if (psmouse->pktsize == 3)
1251 psmouse->resync_time = 0;
1254 * Some smart KVMs fake response to POLL command returning just
1255 * 3 bytes and messing up our resync logic, so if initial poll
1256 * fails we won't try polling the device anymore. Hopefully
1257 * such KVM will maintain initially selected protocol.
1259 if (psmouse->resync_time && psmouse->poll(psmouse))
1260 psmouse->resync_time = 0;
1262 snprintf(psmouse->devname, sizeof(psmouse->devname), "%s %s %s",
1263 psmouse_protocol_by_type(psmouse->type)->name, psmouse->vendor, psmouse->name);
1265 input_dev->name = psmouse->devname;
1266 input_dev->phys = psmouse->phys;
1267 input_dev->id.bustype = BUS_I8042;
1268 input_dev->id.vendor = 0x0002;
1269 input_dev->id.product = psmouse->type;
1270 input_dev->id.version = psmouse->model;
1276 * psmouse_connect() is a callback from the serio module when
1277 * an unhandled serio port is found.
1279 static int psmouse_connect(struct serio *serio, struct serio_driver *drv)
1281 struct psmouse *psmouse, *parent = NULL;
1282 struct input_dev *input_dev;
1283 int retval = 0, error = -ENOMEM;
1285 mutex_lock(&psmouse_mutex);
1288 * If this is a pass-through port deactivate parent so the device
1289 * connected to this port can be successfully identified
1291 if (serio->parent && serio->id.type == SERIO_PS_PSTHRU) {
1292 parent = serio_get_drvdata(serio->parent);
1293 psmouse_deactivate(parent);
1296 psmouse = kzalloc(sizeof(struct psmouse), GFP_KERNEL);
1297 input_dev = input_allocate_device();
1298 if (!psmouse || !input_dev)
1301 ps2_init(&psmouse->ps2dev, serio);
1302 INIT_DELAYED_WORK(&psmouse->resync_work, psmouse_resync);
1303 psmouse->dev = input_dev;
1304 snprintf(psmouse->phys, sizeof(psmouse->phys), "%s/input0", serio->phys);
1306 psmouse_set_state(psmouse, PSMOUSE_INITIALIZING);
1308 serio_set_drvdata(serio, psmouse);
1310 error = serio_open(serio, drv);
1312 goto err_clear_drvdata;
1314 if (psmouse_probe(psmouse) < 0) {
1316 goto err_close_serio;
1319 psmouse->rate = psmouse_rate;
1320 psmouse->resolution = psmouse_resolution;
1321 psmouse->resetafter = psmouse_resetafter;
1322 psmouse->resync_time = parent ? 0 : psmouse_resync_time;
1323 psmouse->smartscroll = psmouse_smartscroll;
1325 psmouse_switch_protocol(psmouse, NULL);
1327 psmouse_set_state(psmouse, PSMOUSE_CMD_MODE);
1328 psmouse_initialize(psmouse);
1330 error = input_register_device(psmouse->dev);
1332 goto err_protocol_disconnect;
1334 if (parent && parent->pt_activate)
1335 parent->pt_activate(parent);
1337 error = sysfs_create_group(&serio->dev.kobj, &psmouse_attribute_group);
1339 goto err_pt_deactivate;
1341 psmouse_activate(psmouse);
1344 /* If this is a pass-through port the parent needs to be re-activated */
1346 psmouse_activate(parent);
1348 mutex_unlock(&psmouse_mutex);
1352 if (parent && parent->pt_deactivate)
1353 parent->pt_deactivate(parent);
1354 input_unregister_device(psmouse->dev);
1355 input_dev = NULL; /* so we don't try to free it below */
1356 err_protocol_disconnect:
1357 if (psmouse->disconnect)
1358 psmouse->disconnect(psmouse);
1359 psmouse_set_state(psmouse, PSMOUSE_IGNORE);
1363 serio_set_drvdata(serio, NULL);
1365 input_free_device(input_dev);
1373 static int psmouse_reconnect(struct serio *serio)
1375 struct psmouse *psmouse = serio_get_drvdata(serio);
1376 struct psmouse *parent = NULL;
1377 struct serio_driver *drv = serio->drv;
1380 if (!drv || !psmouse) {
1381 printk(KERN_DEBUG "psmouse: reconnect request, but serio is disconnected, ignoring...\n");
1385 mutex_lock(&psmouse_mutex);
1387 if (serio->parent && serio->id.type == SERIO_PS_PSTHRU) {
1388 parent = serio_get_drvdata(serio->parent);
1389 psmouse_deactivate(parent);
1392 psmouse_set_state(psmouse, PSMOUSE_INITIALIZING);
1394 if (psmouse->reconnect) {
1395 if (psmouse->reconnect(psmouse))
1397 } else if (psmouse_probe(psmouse) < 0 ||
1398 psmouse->type != psmouse_extensions(psmouse,
1399 psmouse_max_proto, false)) {
1403 /* ok, the device type (and capabilities) match the old one,
1404 * we can continue using it, complete intialization
1406 psmouse_set_state(psmouse, PSMOUSE_CMD_MODE);
1408 psmouse_initialize(psmouse);
1410 if (parent && parent->pt_activate)
1411 parent->pt_activate(parent);
1413 psmouse_activate(psmouse);
1417 /* If this is a pass-through port the parent waits to be activated */
1419 psmouse_activate(parent);
1421 mutex_unlock(&psmouse_mutex);
1425 static struct serio_device_id psmouse_serio_ids[] = {
1433 .type = SERIO_PS_PSTHRU,
1441 MODULE_DEVICE_TABLE(serio, psmouse_serio_ids);
1443 static struct serio_driver psmouse_drv = {
1447 .description = DRIVER_DESC,
1448 .id_table = psmouse_serio_ids,
1449 .interrupt = psmouse_interrupt,
1450 .connect = psmouse_connect,
1451 .reconnect = psmouse_reconnect,
1452 .disconnect = psmouse_disconnect,
1453 .cleanup = psmouse_cleanup,
1456 ssize_t psmouse_attr_show_helper(struct device *dev, struct device_attribute *devattr,
1459 struct serio *serio = to_serio_port(dev);
1460 struct psmouse_attribute *attr = to_psmouse_attr(devattr);
1461 struct psmouse *psmouse;
1463 psmouse = serio_get_drvdata(serio);
1465 return attr->show(psmouse, attr->data, buf);
1468 ssize_t psmouse_attr_set_helper(struct device *dev, struct device_attribute *devattr,
1469 const char *buf, size_t count)
1471 struct serio *serio = to_serio_port(dev);
1472 struct psmouse_attribute *attr = to_psmouse_attr(devattr);
1473 struct psmouse *psmouse, *parent = NULL;
1476 retval = mutex_lock_interruptible(&psmouse_mutex);
1480 psmouse = serio_get_drvdata(serio);
1482 if (attr->protect) {
1483 if (psmouse->state == PSMOUSE_IGNORE) {
1488 if (serio->parent && serio->id.type == SERIO_PS_PSTHRU) {
1489 parent = serio_get_drvdata(serio->parent);
1490 psmouse_deactivate(parent);
1493 psmouse_deactivate(psmouse);
1496 retval = attr->set(psmouse, attr->data, buf, count);
1498 if (attr->protect) {
1499 if (retval != -ENODEV)
1500 psmouse_activate(psmouse);
1503 psmouse_activate(parent);
1507 mutex_unlock(&psmouse_mutex);
1512 static ssize_t psmouse_show_int_attr(struct psmouse *psmouse, void *offset, char *buf)
1514 unsigned int *field = (unsigned int *)((char *)psmouse + (size_t)offset);
1516 return sprintf(buf, "%u\n", *field);
1519 static ssize_t psmouse_set_int_attr(struct psmouse *psmouse, void *offset, const char *buf, size_t count)
1521 unsigned int *field = (unsigned int *)((char *)psmouse + (size_t)offset);
1522 unsigned long value;
1524 if (strict_strtoul(buf, 10, &value))
1527 if ((unsigned int)value != value)
1535 static ssize_t psmouse_attr_show_protocol(struct psmouse *psmouse, void *data, char *buf)
1537 return sprintf(buf, "%s\n", psmouse_protocol_by_type(psmouse->type)->name);
1540 static ssize_t psmouse_attr_set_protocol(struct psmouse *psmouse, void *data, const char *buf, size_t count)
1542 struct serio *serio = psmouse->ps2dev.serio;
1543 struct psmouse *parent = NULL;
1544 struct input_dev *old_dev, *new_dev;
1545 const struct psmouse_protocol *proto, *old_proto;
1549 proto = psmouse_protocol_by_name(buf, count);
1553 if (psmouse->type == proto->type)
1556 new_dev = input_allocate_device();
1560 while (serio->child) {
1563 "psmouse: failed to destroy child port, "
1564 "protocol change aborted.\n");
1565 input_free_device(new_dev);
1569 mutex_unlock(&psmouse_mutex);
1570 serio_unregister_child_port(serio);
1571 mutex_lock(&psmouse_mutex);
1573 if (serio->drv != &psmouse_drv) {
1574 input_free_device(new_dev);
1578 if (psmouse->type == proto->type) {
1579 input_free_device(new_dev);
1580 return count; /* switched by other thread */
1584 if (serio->parent && serio->id.type == SERIO_PS_PSTHRU) {
1585 parent = serio_get_drvdata(serio->parent);
1586 if (parent->pt_deactivate)
1587 parent->pt_deactivate(parent);
1590 old_dev = psmouse->dev;
1591 old_proto = psmouse_protocol_by_type(psmouse->type);
1593 if (psmouse->disconnect)
1594 psmouse->disconnect(psmouse);
1596 psmouse_set_state(psmouse, PSMOUSE_IGNORE);
1598 psmouse->dev = new_dev;
1599 psmouse_set_state(psmouse, PSMOUSE_INITIALIZING);
1601 if (psmouse_switch_protocol(psmouse, proto) < 0) {
1602 psmouse_reset(psmouse);
1603 /* default to PSMOUSE_PS2 */
1604 psmouse_switch_protocol(psmouse, &psmouse_protocols[0]);
1607 psmouse_initialize(psmouse);
1608 psmouse_set_state(psmouse, PSMOUSE_CMD_MODE);
1610 error = input_register_device(psmouse->dev);
1612 if (psmouse->disconnect)
1613 psmouse->disconnect(psmouse);
1615 psmouse_set_state(psmouse, PSMOUSE_IGNORE);
1616 input_free_device(new_dev);
1617 psmouse->dev = old_dev;
1618 psmouse_set_state(psmouse, PSMOUSE_INITIALIZING);
1619 psmouse_switch_protocol(psmouse, old_proto);
1620 psmouse_initialize(psmouse);
1621 psmouse_set_state(psmouse, PSMOUSE_CMD_MODE);
1626 input_unregister_device(old_dev);
1628 if (parent && parent->pt_activate)
1629 parent->pt_activate(parent);
1634 static ssize_t psmouse_attr_set_rate(struct psmouse *psmouse, void *data, const char *buf, size_t count)
1636 unsigned long value;
1638 if (strict_strtoul(buf, 10, &value))
1641 psmouse->set_rate(psmouse, value);
1645 static ssize_t psmouse_attr_set_resolution(struct psmouse *psmouse, void *data, const char *buf, size_t count)
1647 unsigned long value;
1649 if (strict_strtoul(buf, 10, &value))
1652 psmouse->set_resolution(psmouse, value);
1657 static int psmouse_set_maxproto(const char *val, struct kernel_param *kp)
1659 const struct psmouse_protocol *proto;
1664 proto = psmouse_protocol_by_name(val, strlen(val));
1666 if (!proto || !proto->maxproto)
1669 *((unsigned int *)kp->arg) = proto->type;
1674 static int psmouse_get_maxproto(char *buffer, struct kernel_param *kp)
1676 int type = *((unsigned int *)kp->arg);
1678 return sprintf(buffer, "%s", psmouse_protocol_by_type(type)->name);
1681 static int __init psmouse_init(void)
1685 lifebook_module_init();
1686 synaptics_module_init();
1688 kpsmoused_wq = create_singlethread_workqueue("kpsmoused");
1689 if (!kpsmoused_wq) {
1690 printk(KERN_ERR "psmouse: failed to create kpsmoused workqueue\n");
1694 err = serio_register_driver(&psmouse_drv);
1696 destroy_workqueue(kpsmoused_wq);
1701 static void __exit psmouse_exit(void)
1703 serio_unregister_driver(&psmouse_drv);
1704 destroy_workqueue(kpsmoused_wq);
1707 module_init(psmouse_init);
1708 module_exit(psmouse_exit);