From: Dmitry Torokhov <dtor_core@ameritech.net>
To: Vojtech Pavlik <vojtech@suse.cz>
Cc: LKML <linux-kernel@vger.kernel.org>
Subject: [PATCH 3/8] New set of input patches
Date: Thu, 8 Jul 2004 01:56:30 -0500 [thread overview]
Message-ID: <200407080156.32341.dtor_core@ameritech.net> (raw)
In-Reply-To: <200407080156.05021.dtor_core@ameritech.net>
===================================================================
ChangeSet@1.1822, 2004-07-08 00:23:44-05:00, dtor_core@ameritech.net
Input: workaround for i8042 active multiplexing controllers losing
track of where data is coming from. Also sprinkled some
"likely"s in i8042 interrupt handler.
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
i8042.c | 60 ++++++++++++++++++++++++++++++++++++++++++------------------
1 files changed, 42 insertions(+), 18 deletions(-)
===================================================================
diff -Nru a/drivers/input/serio/i8042.c b/drivers/input/serio/i8042.c
--- a/drivers/input/serio/i8042.c 2004-07-08 01:35:04 -05:00
+++ b/drivers/input/serio/i8042.c 2004-07-08 01:35:04 -05:00
@@ -362,6 +362,7 @@
unsigned long flags;
unsigned char str, data = 0;
unsigned int dfl;
+ unsigned int aux_idx;
int ret;
mod_timer(&i8042_timer, jiffies + I8042_POLL_PERIOD);
@@ -378,44 +379,67 @@
goto out;
}
- dfl = ((str & I8042_STR_PARITY) ? SERIO_PARITY : 0) |
- ((str & I8042_STR_TIMEOUT) ? SERIO_TIMEOUT : 0);
-
- if (i8042_mux_values[0].exists && (str & I8042_STR_AUXDATA)) {
+ if (i8042_mux_present && (str & I8042_STR_AUXDATA)) {
+ static unsigned long last_transmit;
+ static unsigned char last_str;
+ dfl = 0;
if (str & I8042_STR_MUXERR) {
+ dbg("MUX error, status is %02x, data is %02x", str, data);
switch (data) {
+ default:
+/*
+ * When MUXERR condition is signalled the data register can only contain
+ * 0xfd, 0xfe or 0xff if implementation follows the spec. Unfortunately
+ * it is not always the case. Some KBC just get confused which port the
+ * data came from and signal error leaving the data intact. They _do not_
+ * revert to legacy mode (actually I've never seen KBC reverting to legacy
+ * mode yet, when we see one we'll add proper handling).
+ * Anyway, we will assume that the data came from the same serio last byte
+ * was transmitted (if transmission happened not too long ago).
+ */
+ if (time_before(jiffies, last_transmit + HZ/10)) {
+ str = last_str;
+ break;
+ }
+ /* fall through - report timeout */
case 0xfd:
- case 0xfe: dfl = SERIO_TIMEOUT; break;
- case 0xff: dfl = SERIO_PARITY; break;
+ case 0xfe: dfl = SERIO_TIMEOUT; data = 0xfe; break;
+ case 0xff: dfl = SERIO_PARITY; data = 0xfe; break;
}
- data = 0xfe;
- } else dfl = 0;
+ }
+
+ aux_idx = (str >> 6) & 3;
dbg("%02x <- i8042 (interrupt, aux%d, %d%s%s)",
- data, (str >> 6), irq,
+ data, aux_idx, irq,
dfl & SERIO_PARITY ? ", bad parity" : "",
dfl & SERIO_TIMEOUT ? ", timeout" : "");
- serio_interrupt(i8042_mux_port[(str >> 6) & 3], data, dfl, regs);
+ if (likely(i8042_mux_values[aux_idx].exists))
+ serio_interrupt(i8042_mux_port[aux_idx], data, dfl, regs);
+ last_str = str;
+ last_transmit = jiffies;
goto irq_ret;
}
+ dfl = ((str & I8042_STR_PARITY) ? SERIO_PARITY : 0) |
+ ((str & I8042_STR_TIMEOUT) ? SERIO_TIMEOUT : 0);
+
dbg("%02x <- i8042 (interrupt, %s, %d%s%s)",
data, (str & I8042_STR_AUXDATA) ? "aux" : "kbd", irq,
dfl & SERIO_PARITY ? ", bad parity" : "",
dfl & SERIO_TIMEOUT ? ", timeout" : "");
- if (i8042_aux_values.exists && (str & I8042_STR_AUXDATA)) {
- serio_interrupt(i8042_aux_port, data, dfl, regs);
- goto irq_ret;
- }
-
- if (!i8042_kbd_values.exists)
- goto irq_ret;
- serio_interrupt(i8042_kbd_port, data, dfl, regs);
+ if (str & I8042_STR_AUXDATA) {
+ if (likely(i8042_aux_values.exists))
+ serio_interrupt(i8042_aux_port, data, dfl, regs);
+ } else {
+ if (likely(i8042_kbd_values.exists))
+ serio_interrupt(i8042_kbd_port, data, dfl, regs);
+ }
irq_ret:
ret = 1;
next prev parent reply other threads:[~2004-07-08 7:02 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-07-08 6:55 [PATCH 0/8] New set of input patches Dmitry Torokhov
2004-07-08 6:55 ` [PATCH 1/8] " Dmitry Torokhov
2004-07-08 6:56 ` [PATCH 2/8] " Dmitry Torokhov
2004-07-08 6:56 ` Dmitry Torokhov [this message]
2004-07-08 6:57 ` [PATCH 4/8] " Dmitry Torokhov
2004-07-08 6:57 ` [PATCH 5/8] " Dmitry Torokhov
2004-07-08 6:58 ` [PATCH 6/8] " Dmitry Torokhov
2004-07-08 6:58 ` [PATCH 7/8] " Dmitry Torokhov
2004-07-08 6:59 ` [PATCH 8/8] " Dmitry Torokhov
2004-07-12 3:17 ` synaptics driver Ari Pollak
2004-07-12 3:41 ` Dmitry Torokhov
2004-07-08 20:32 ` [PATCH 0/8] New set of input patches Pavel Machek
2004-07-09 3:48 ` Dmitry Torokhov
2004-07-09 5:06 ` Pavel Machek
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=200407080156.32341.dtor_core@ameritech.net \
--to=dtor_core@ameritech.net \
--cc=linux-kernel@vger.kernel.org \
--cc=vojtech@suse.cz \
/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