[PATCH] drivers/char/pc_keyb.c

From: Brent Verner (brent@linux1.org)
Date: Mon Mar 27 2000 - 03:31:54 EST


hi,
        The following patch reenables the (ps2) mouse after it has
been unplugged and plugged back in, or when using a KVM switch
between machines.

note: the scancode==170 that I'm using might not work for all
cases, but has been tested with 2 logitech and 1 MS mouse.

FWIW, the keyboard (MS Natural) sends the same scancode when it
is reconnected.

cheers.
        b

======= patch follows =======
--- pc_keyb.c Mon Mar 27 03:16:39 2000
+++ pc_keyb.c.brent Mon Mar 27 03:20:13 2000
@@ -56,6 +56,7 @@
 
 static void kbd_write_command_w(int data);
 static void kbd_write_output_w(int data);
+static void aux_write_ack(int val);
 
 spinlock_t kbd_controller_lock = SPIN_LOCK_UNLOCKED;
 static unsigned char handle_kbd_event(void);
@@ -73,6 +74,9 @@
 
 static int __init psaux_init(void);
 
+#define AUX_RECONNECT 170
+/* #define CHECK_RECONNECT_SCANCODE 1 */
+
 static struct aux_queue *queue; /* Mouse data buffer. */
 static int aux_count = 0;
 /* used when we send commands to the mouse that expect an ACK. */
@@ -393,6 +397,19 @@
                 }
                 mouse_reply_expected = 0;
         }
+ else if(scancode == AUX_RECONNECT){
+ queue->head = queue->tail = 0; /* Flush input queue */
+ /*
+ * need this stuff? seems to work fine w/o it for me
+ aux_write_ack(AUX_SET_SAMPLE);
+ aux_write_ack(100);
+ aux_write_ack(AUX_SET_RES);
+ aux_write_ack(3);
+ aux_write_ack(AUX_SET_SCALE21);
+ */
+ aux_write_ack(AUX_ENABLE_DEV); /* ping the mouse :) */
+ return;
+ }
 
         add_mouse_randomness(scancode);
         if (aux_count) {
@@ -426,6 +443,9 @@
                 unsigned char scancode;
 
                 scancode = kbd_read_input();
+# ifdef CHECK_RECONNECT_SCANCODE
+ printk(KERN_INFO "-=db=-: kbd_read_input() : scancode == %d\n",scancode);
+# endif
                 if (status & KBD_STAT_MOUSE_OBF) {
                         handle_mouse_event(scancode);
                 } else {

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Fri Mar 31 2000 - 21:00:19 EST