Skip to contentSkip to conversation

Toshiba keyboard workaroun

DISCUSSION Pete Zaitcev 2 participants 3 messages Feb 18, 2003 1 message not in the archive Char and misc drivers

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw
Quoted 15 lines
drivers/char/keyboard.c +9 -0
@@ -1020,6 +1041,23 @@
 	struct tty_struct *tty;
 	int shift_final;
 
+        /*
+         * Fix for Toshiba Satellites. Toshiba's like to repeat 
+	 * "key down" event for A in combinations like shift-A.
+	 * Thanx to Andrei Pitis <[email protected]>.
+         */
+        static int prev_scancode = 0;
+        static int stop_jiffies = 0;
+
+        /* new scancode, trigger delay */

drivers/char/keyboard.c line 1062

Quoted 10 lines
drivers/char/keyboard.c +8 -0
+        if (keycode != prev_scancode) 	       stop_jiffies = jiffies;
+        else if (jiffies - stop_jiffies >= 10) stop_jiffies = 0;
+        else {
+	    printk( "Keyboard glitch detected, ignoring keypress\n" );
+            return;
+	}
+        prev_scancode = keycode;
+
 	if (down != 2)
 		add_keyboard_randomness((keycode << 1) ^ down);

This is incredibly broken, on many layers.

First, formatting does not respect the original code. Pavel, please, I do not care what crap you write in softsuspend, but this is a generic piece of code. Be kind to those who come next.

Second, no HZ or other way to specify a wall clock interval. What if I run with HZ=4000? How do you protect against a jiffies wraparound?

Third, I do not see how this is supposed to work at all. What if I hit two letters like in a word "Fool"? The up event is filtered already by this time, so, won't this code eat the second 'o'?

-- Pete

#2 lore raw

Hi!

Quoted 28 lines
Quoted 15 lines
drivers/char/keyboard.c +9 -0
@@ -1020,6 +1041,23 @@
 	struct tty_struct *tty;
 	int shift_final;
 
+        /*
+         * Fix for Toshiba Satellites. Toshiba's like to repeat 
+	 * "key down" event for A in combinations like shift-A.
+	 * Thanx to Andrei Pitis <[email protected]>.
+         */
+        static int prev_scancode = 0;
+        static int stop_jiffies = 0;
+
+        /* new scancode, trigger delay */

drivers/char/keyboard.c line 1062

Quoted 10 lines
drivers/char/keyboard.c +8 -0
+        if (keycode != prev_scancode) 	       stop_jiffies = jiffies;
+        else if (jiffies - stop_jiffies >= 10) stop_jiffies = 0;
+        else {
+	    printk( "Keyboard glitch detected, ignoring keypress\n" );
+            return;
+	}
+        prev_scancode = keycode;
+
 	if (down != 2)
 		add_keyboard_randomness((keycode << 1) ^ down);

This is incredibly broken, on many layers.

Quoted 3 lines

First, formatting does not respect the original code. Pavel, please, I do not care what crap you write in softsuspend, but this is a generic piece of code. Be kind to those who come next.

Its not originally mine, I should have reformated it. Sorry.

Quoted 8 lines

Second, no HZ or other way to specify a wall clock interval. What if I run with HZ=4000? How do you protect against a jiffies wraparound?

Third, I do not see how this is supposed to work at all. What if I hit two letters like in a word "Fool"? The up event is filtered already by this time, so, won't this code eat the second 'o'?

The up event is not filtered, AFAICS. Parameter down carries that.

Pavel

Signature · 2 lines
Casualities in World Trade Center: ~3k dead inside the building,
cryptography in U.S.A. and free speech in Czech Republic.
#3 lore raw
In reply to Pete Zaitcev

Hi!

Quoted 2 lines

First, formatting does not respect the original code. Pavel, please, I do not care what crap you write in softsuspend, but this is a

Do you like this better?

Pavel
PS: Oh, and, what crap in swsusp are you talking about?

drivers/char/keyboard.c +20 -0
@@ -1020,6 +1041,26 @@
 	struct tty_struct *tty;
 	int shift_final;
 
+        /*
+         * Fix for Toshiba Satellites. Toshiba's like to repeat 
+	 * "key down" event for A in combinations like shift-A.
+	 * Thanx to Andrei Pitis <[email protected]>.
+         */
+        static int prev_scancode = 0;
+        static int stop_jiffies = 0;
+
+        /* new scancode, trigger delay */
+        if (keycode != prev_scancode)
+		stop_jiffies = jiffies;
+        else 
+		if (time_after(jiffies, stop_jiffies + HZ/10))
+			prev_scancode = -1;
+        else {
+		printk( "Keyboard glitch detected, ignoring keypress\n" );
+		return;
+	}
+        prev_scancode = keycode;
+
 	if (down != 2)
 		add_keyboard_randomness((keycode << 1) ^ down);
 
Signature · 2 lines
Casualities in World Trade Center: ~3k dead inside the building,
cryptography in U.S.A. and free speech in Czech Republic.