In 2007 I changed this code to use table 3 by default, falling back 
on table 2 (the previous default) or 1.  This was done just to make 
the keyboard on the OQO model 01 work, and these devices are long 
gone.

10 years later, some newer Lenovo machines seem to have trouble 
trying this mode which can occasionally leave the keyboard in a 
state where it generates bogus keys when typing.  It also causes a 
long delay when booting because the table changes have to timeout:

    pckbd: trying table 3
    pckbc_cmd: lost 0xee
    pckbc_cmd: timeout
    pckbd: table set of 3 failed
    pckbd: trying table 2
    pckbc_cmd: lost 0xee
    pckbc_cmd: timeout
    pckbd: table set of 2 failed
    pckbd: trying table 1
    pckbc_cmd: lost 0xee
    pckbc_cmd: timeout
    pckbd: table set of 1 failed
    pckbd: settling on table 1

This patch reverts back to using table 2 by default and if it says 
it was already in table 2, leaves it alone rather than forcibly 
changing to that mode again, which is how Linux behaves.


Index: sys/dev/pckbc/pckbd.c
===================================================================
RCS file: /cvs/src/sys/dev/pckbc/pckbd.c,v
retrieving revision 1.43
diff -u -p -u -p -r1.43 pckbd.c
--- sys/dev/pckbc/pckbd.c       14 Apr 2016 07:06:03 -0000      1.43
+++ sys/dev/pckbc/pckbd.c       2 Jan 2018 15:21:05 -0000
@@ -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,
                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);

Reply via email to