From 4a64352304e24b88f212d718db9d0a3911b51116 Mon Sep 17 00:00:00 2001 From: jcs Date: Sat, 6 Jan 2018 18:51:20 +0000 Subject: [PATCH] pckbd: don't change translation mode if controller is in table 2 This was changed a decade ago to forcibly try table 3 first in order to make some now-long-gone hardware work. Newer Lenovo machines seem to have trouble being asked to change modes which manifests as a long boot delay as it waits for each request to timeout, or by causing the keyboard to generate junk when typing. Assume table 2 by default and just leave it alone if it's already there. This is how Linux has operated for quite a while and seems to help on these Lenovo machines. Tested by a few with these machines and has been in snaps for a bit. --- sys/dev/pckbc/pckbd.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/sys/dev/pckbc/pckbd.c b/sys/dev/pckbc/pckbd.c index 4b9bdfedde4..100f28c06f5 100644 --- a/sys/dev/pckbc/pckbd.c +++ b/sys/dev/pckbc/pckbd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pckbd.c,v 1.43 2016/04/14 07:06:03 mlarkin Exp $ */ +/* $OpenBSD: pckbd.c,v 1.44 2018/01/06 18:51:20 jcs Exp $ */ /* $NetBSD: pckbd.c,v 1.24 2000/06/05 22:20:57 sommerfeld Exp $ */ /*- @@ -214,8 +214,7 @@ int pckbd_set_xtscancode(pckbc_tag_t kbctag, pckbc_slot_t kbcslot, struct pckbd_internal *id) { - /* default to have the 8042 translate the keyboard with table 3. */ - int table = 3; + int table; if (pckbc_xt_translation(kbctag)) { #ifdef DEBUG @@ -234,12 +233,21 @@ pckbd_set_xtscancode(pckbc_tag_t kbctag, pckbc_slot_t kbcslot, if (id != NULL) id->t_translating = 0; } else { - if (id != NULL) + if (id != NULL) { id->t_translating = 1; + if (id->t_table == 0) { + /* + * Don't bother explicitly setting into set 2, + * it's the default. + */ + id->t_table = 2; + return (0); + } + } } /* keep falling back until we hit a table that looks usable. */ - for (; table >= 1; table--) { + for (table = 3; table >= 1; table--) { u_char cmd[2]; #ifdef DEBUG printf("pckbd: trying table %d\n", table); -- 2.20.1