Skip to contentSkip to conversation

Toshiba keyboard workaroun

PATCH Pavel Machek 4 participants 4 messages Feb 18, 2003 – Feb 23, 2003 Char and misc drivers

lore
Share & tools
lore
#0 lore raw

Hi!

You said that you'll submit toshiba keyboard fix for 2.4 to marcelo... Here goes 2.5 version, will you submit it to Linus? ;-).

drivers/char/keyboard.c +17 -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 */
+        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);
 
Signature · 2 lines
When do you have a heart between your knees?
[Johanka's followup: and *two* hearts?]
#1 lore raw
Quoted 2 lines · Pavel Machek

You said that you'll submit toshiba keyboard fix for 2.4 to marcelo... Here goes 2.5 version, will you submit it to Linus? ;-).

This belongs into drivers/input/keyboard/atkbd.c, not here!

Subsequent keypresses are already ignored - autorepeat is done in software, however if you get a very quick press-release-press of the same key that means the keyboard controller didn't do proper debouncing and you probably can ignore the later release and press. But you must ignore the release as well. Further - comparing to 10 jiffies isn't a good idea - jiffies speed is different on different archs.

Quoted 25 lines
drivers/char/keyboard.c +17 -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 */
+        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);
Signature · 2 lines
Vojtech Pavlik
SuSE Labs
#2 lore raw

Hi!

Quoted 7 lines
Quoted 2 lines

You said that you'll submit toshiba keyboard fix for 2.4 to marcelo... Here goes 2.5 version, will you submit it to Linus? ;-).

This belongs into drivers/input/keyboard/atkbd.c, not here!

Subsequent keypresses are already ignored - autorepeat is done in software, however if you get a very quick press-release-press of the

No, it did not do releases.

Guess I should really try 2.5. without that patch, because vojtech's patches might have had fixed that as a side effect. Alan, please don't push this patch to Linus until this is fixed. [2.4 version is still neccessary, through].
Pavel

Quoted 33 lines

same key that means the keyboard controller didn't do proper debouncing and you probably can ignore the later release and press. But you must ignore the release as well. Further - comparing to 10 jiffies isn't a good idea - jiffies speed is different on different archs.

Quoted 25 lines
drivers/char/keyboard.c +17 -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 */
+        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);
Signature · 2 lines
Horseback riding is like software...
...vgf orggre jura vgf serr.
#3 lore raw
In reply to Pavel Machek
Quoted 7 lines · Pavel Machek
drivers/char/keyboard.c +7 -0
+        /*
+         * 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;

drivers/char/keyboard.c line 1060

Quoted 10 lines
drivers/char/keyboard.c +10 -0
+
+        /* new scancode, trigger delay */
+        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;
+

That codingstyle is not acceptable. Please reformat to match Documentation/CodingStyle. Also there are macros for jiffie overflow handling you might want to use, see include/linux/jiffies.h