mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andries Brouwer <aebr@win.tue.nl>
To: Petr Vandrovec <vandrove@vc.cvut.cz>
Cc: vojtech@suse.cz, Zwane Mwaikambo <zwane@linuxpower.ca>,
	linux-kernel@vger.kernel.org
Subject: Re: Another keyboard woes with 2.6.0...
Date: Tue, 14 Oct 2003 23:27:06 +0200	[thread overview]
Message-ID: <20031014212706.GA5898@win.tue.nl> (raw)
In-Reply-To: <20031014181606.GD21740@vana.vc.cvut.cz>

On Tue, Oct 14, 2003 at 08:16:06PM +0200, Petr Vandrovec wrote:

> Got it again. This time with detailed logging.

Excellent. This immediately shows another bug in the code.

> Oct 14 19:59:18 ppc kernel: i8042.c: e0 <- i8042 (interrupt, kbd, 1) [30115341]
> Oct 14 19:59:18 ppc kernel: i8042.c: ed -> i8042 (kbd-data) [30115342]
> Oct 14 19:59:18 ppc kernel: i8042.c: fa <- i8042 (interrupt, kbd, 1) [30115346]
> Oct 14 19:59:18 ppc kernel: atkbd.c: Unknown key released (translated set 2, code 0x165, data 0xfa, on isa0060/serio0).

The code (some version of 2.6.0-test6) says

	if (atkbd->translated) do {
		if (atkbd->emul != 1) {
			if (code == ATKBD_RET_ACK)
				break;
			...
		}
		if (code < 0x80) {
			code = atkbd_unxlate_table[code];
			break;
		}
		code = atkbd_unxlate_table[code & 0x7f];
	}

Here an e0 preceded, setting the atkbd->emul flag.
Now the acknowledge for the 0xed command was not recognized as
ATKBD_RET_ACK and untranslated as if it were a keystroke.

Yes, I hope to convince Vojtech that untranslating is evil.

The question is: what to do with a protocol scancode?
My answer from long ago was: view it as a protocol scancode only
when it is expected - after we send a command we expect an ACK.
And indeed, 2.4 still has

	if (reply_expected) {
		if (scancode == KBD_REPLY_ACK) {
			acknowledge = 1;
			reply_expected = 0;
	...

That is, the right way, or at least the way that worked since 1.1.54,
is to test only for KBD_REPLY_ACK when we just sent something.

The wrong solution follows below (not compiled or tested):

--- atkbd.c~    Mon Sep 29 09:12:26 2003
+++ atkbd.c     Tue Oct 14 23:15:57 2003
@@ -183,11 +183,19 @@
                atkbd->resend = 0;
 #endif
 
+       switch (code) {
+               case ATKBD_RET_ACK:
+                       atkbd->ack = 1;
+                       goto out;
+               case ATKBD_RET_NAK:
+                       atkbd->ack = -1;
+                       goto out;
+       }
+
        if (atkbd->translated) do {
 
                if (atkbd->emul != 1) {
-                       if (code == ATKBD_RET_EMUL0 || code == ATKBD_RET_EMUL1 ||
-                           code == ATKBD_RET_ACK || code == ATKBD_RET_NAK)
+                       if (code == ATKBD_RET_EMUL0 || code == ATKBD_RET_EMUL1)
                                break;
                        if (code == ATKBD_RET_BAT) {
                                if (!atkbd->bat_xl)
@@ -211,15 +219,6 @@
 
        } while (0);
 
-       switch (code) {
-               case ATKBD_RET_ACK:
-                       atkbd->ack = 1;
-                       goto out;
-               case ATKBD_RET_NAK:
-                       atkbd->ack = -1;
-                       goto out;
-       }
-
        if (atkbd->cmdcnt) {
                atkbd->cmdbuf[--atkbd->cmdcnt] = code;
                goto out;

(This is right for the great majority of people that does not
have fa,fe occur as non-protocol scancodes. In rare cases
some more surgery is needed. Left to Vojtech.)

Andries


[patch against some source similar to 2.6.0-test6]


  reply	other threads:[~2003-10-14 21:27 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-09-12 16:50 Petr Vandrovec
2003-09-12 17:45 ` Zwane Mwaikambo
2003-09-16 21:23   ` Andries Brouwer
2003-09-16 22:45     ` Jamie Lokier
2003-09-16 22:49     ` Zwane Mwaikambo
2003-09-16 23:12       ` Zwane Mwaikambo
2003-09-16 23:18         ` Zwane Mwaikambo
2003-09-17  0:01         ` Andries Brouwer
2003-10-06 22:08     ` Petr Vandrovec
2003-10-14 18:16       ` Petr Vandrovec
2003-10-14 21:27         ` Andries Brouwer [this message]
2003-09-13 19:06 ` Pekka Pietikainen
2003-09-12 18:33 Petr Vandrovec
2003-09-13 18:52 ` Andries Brouwer
2003-09-13 21:40   ` Petr Vandrovec
2003-09-14 10:13     ` Andries Brouwer
2003-09-14 10:34       ` Andries Brouwer
2003-09-14 19:52         ` Petr Vandrovec
2003-09-14 22:10           ` Andries Brouwer
2003-09-19 11:38     ` Vojtech Pavlik

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20031014212706.GA5898@win.tue.nl \
    --to=aebr@win.tue.nl \
    --cc=linux-kernel@vger.kernel.org \
    --cc=vandrove@vc.cvut.cz \
    --cc=vojtech@suse.cz \
    --cc=zwane@linuxpower.ca \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome