linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Re: Toshiba keyboard workaroun
       [not found] <mailman.1045603384.24857.linux-kernel2news@redhat.com>
@ 2003-02-18 22:13 ` Pete Zaitcev
  2003-02-18 22:21   ` Pavel Machek
  2003-02-18 22:24   ` Pavel Machek
  0 siblings, 2 replies; 7+ messages in thread
From: Pete Zaitcev @ 2003-02-18 22:13 UTC (permalink / raw)
  To: Pavel Machek; +Cc: linux-kernel

> --- clean/drivers/char/keyboard.c	2003-02-15 18:51:18.000000000 +0100
> +++ linux/drivers/char/keyboard.c	2003-02-15 19:19:45.000000000 +0100
> @@ -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 <pink@roedu.net>.
> +         */
> +        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);

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

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Toshiba keyboard workaroun
  2003-02-18 22:13 ` Toshiba keyboard workaroun Pete Zaitcev
@ 2003-02-18 22:21   ` Pavel Machek
  2003-02-18 22:24   ` Pavel Machek
  1 sibling, 0 replies; 7+ messages in thread
From: Pavel Machek @ 2003-02-18 22:21 UTC (permalink / raw)
  To: Pete Zaitcev; +Cc: Pavel Machek, linux-kernel

Hi!

> > --- clean/drivers/char/keyboard.c	2003-02-15 18:51:18.000000000 +0100
> > +++ linux/drivers/char/keyboard.c	2003-02-15 19:19:45.000000000 +0100
> > @@ -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 <pink@roedu.net>.
> > +         */
> > +        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);
> 
> 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.

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

> 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

-- 
Casualities in World Trade Center: ~3k dead inside the building,
cryptography in U.S.A. and free speech in Czech Republic.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Toshiba keyboard workaroun
  2003-02-18 22:13 ` Toshiba keyboard workaroun Pete Zaitcev
  2003-02-18 22:21   ` Pavel Machek
@ 2003-02-18 22:24   ` Pavel Machek
  1 sibling, 0 replies; 7+ messages in thread
From: Pavel Machek @ 2003-02-18 22:24 UTC (permalink / raw)
  To: Pete Zaitcev; +Cc: linux-kernel

Hi!

> 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?

--- clean/drivers/char/keyboard.c	2003-02-15 18:51:18.000000000 +0100
+++ linux/drivers/char/keyboard.c	2003-02-18 23:20:33.000000000 +0100
@@ -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 <pink@roedu.net>.
+         */
+        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);
 

-- 
Casualities in World Trade Center: ~3k dead inside the building,
cryptography in U.S.A. and free speech in Czech Republic.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Toshiba keyboard workaroun
  2003-02-18 21:19 Pavel Machek
  2003-02-23  8:19 ` Vojtech Pavlik
@ 2003-02-23 11:50 ` Christoph Hellwig
  1 sibling, 0 replies; 7+ messages in thread
From: Christoph Hellwig @ 2003-02-23 11:50 UTC (permalink / raw)
  To: Pavel Machek; +Cc: alan, kernel list

On Tue, Feb 18, 2003 at 10:19:40PM +0100, Pavel Machek wrote:
> +        /*
> +         * Fix for Toshiba Satellites. Toshiba's like to repeat 
> +	 * "key down" event for A in combinations like shift-A.
> +	 * Thanx to Andrei Pitis <pink@roedu.net>.
> +         */
> +        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;
> +

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


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Toshiba keyboard workaroun
  2003-02-23  8:19 ` Vojtech Pavlik
@ 2003-02-23 11:29   ` Pavel Machek
  0 siblings, 0 replies; 7+ messages in thread
From: Pavel Machek @ 2003-02-23 11:29 UTC (permalink / raw)
  To: Vojtech Pavlik; +Cc: Pavel Machek, alan, kernel list

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? ;-).
> 
> 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

> 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.



> > --- clean/drivers/char/keyboard.c	2003-02-15 18:51:18.000000000 +0100
> > +++ linux/drivers/char/keyboard.c	2003-02-15 19:19:45.000000000 +0100
> > @@ -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 <pink@roedu.net>.
> > +         */
> > +        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);
> 

-- 
Horseback riding is like software...
...vgf orggre jura vgf serr.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Toshiba keyboard workaroun
  2003-02-18 21:19 Pavel Machek
@ 2003-02-23  8:19 ` Vojtech Pavlik
  2003-02-23 11:29   ` Pavel Machek
  2003-02-23 11:50 ` Christoph Hellwig
  1 sibling, 1 reply; 7+ messages in thread
From: Vojtech Pavlik @ 2003-02-23  8:19 UTC (permalink / raw)
  To: Pavel Machek; +Cc: alan, kernel list

On Tue, Feb 18, 2003 at 10:19:40PM +0100, Pavel Machek wrote:

> 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.

> --- clean/drivers/char/keyboard.c	2003-02-15 18:51:18.000000000 +0100
> +++ linux/drivers/char/keyboard.c	2003-02-15 19:19:45.000000000 +0100
> @@ -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 <pink@roedu.net>.
> +         */
> +        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);

-- 
Vojtech Pavlik
SuSE Labs

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Toshiba keyboard workaroun
@ 2003-02-18 21:19 Pavel Machek
  2003-02-23  8:19 ` Vojtech Pavlik
  2003-02-23 11:50 ` Christoph Hellwig
  0 siblings, 2 replies; 7+ messages in thread
From: Pavel Machek @ 2003-02-18 21:19 UTC (permalink / raw)
  To: alan, kernel list

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? ;-).

--- clean/drivers/char/keyboard.c	2003-02-15 18:51:18.000000000 +0100
+++ linux/drivers/char/keyboard.c	2003-02-15 19:19:45.000000000 +0100
@@ -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 <pink@roedu.net>.
+         */
+        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);
 

-- 
When do you have a heart between your knees?
[Johanka's followup: and *two* hearts?]

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2003-02-23 11:40 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <mailman.1045603384.24857.linux-kernel2news@redhat.com>
2003-02-18 22:13 ` Toshiba keyboard workaroun Pete Zaitcev
2003-02-18 22:21   ` Pavel Machek
2003-02-18 22:24   ` Pavel Machek
2003-02-18 21:19 Pavel Machek
2003-02-23  8:19 ` Vojtech Pavlik
2003-02-23 11:29   ` Pavel Machek
2003-02-23 11:50 ` Christoph Hellwig

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).