From owner-freebsd-hackers Tue Jun 20 13:49:57 1995 Return-Path: hackers-owner Received: (from majordom@localhost) by freefall.cdrom.com (8.6.10/8.6.6) id NAA15359 for hackers-outgoing; Tue, 20 Jun 1995 13:49:57 -0700 Received: from aphrodite.funet.fi (root@aphrodite.funet.fi [193.166.1.10]) by freefall.cdrom.com (8.6.10/8.6.6) with ESMTP id NAA15338 for ; Tue, 20 Jun 1995 13:49:44 -0700 Received: (from ukkonen@localhost) by aphrodite.funet.fi (8.6.11/8.6.11+CSC-2.0) id XAA27390 for hackers@freebsd.org; Tue, 20 Jun 1995 23:02:22 +0300 From: Jukka Ukkonen Message-Id: <199506202002.XAA27390@aphrodite.funet.fi> Subject: patched pcvt keyboard recognition.... To: hackers@freebsd.org Date: Tue, 20 Jun 1995 23:02:21 +0300 (EET DST) Latin-Date: Marti XX Iunie a.d. MCMXCV Organization: Centre for Scientific Computing (CSC) Phone: +358-0-4573208 (work) X-Mailer: ELM [version 2.4 PL23] MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Content-Length: 3925 Sender: hackers-owner@freebsd.org Precedence: bulk Hi all! I have no idea whether the attached patch is relevant to versions of FreeBSD later than 2.0.5-alpha, but just in case there is need for it... I noticed that the doreset() function in pcvt was too hasty in expecting SELFOK answers from certain keyboards. At least Alps Membrane seems to first respond with an ACK as expected but then it takes a short moment for itself. During that time the only response to any attempts to fetch the status value is -1. If one didn't allow for a few negative replies being received before the SELFOK, one would get the SELFOK only when expecting the answer to KBD ID query and right after that there would be a request to re-issue the KBD ID query. My patch may not be the best possible solution, but it hits the point quite nicely. With this patch attached e.g. Alps Membrane will be correctly recognized as an MF-II keyboard. Cheers, // jau ------ / Jukka A. Ukkonen, FUNET / Centre for Scientific Computing /__ M.Sc. (sw-eng & cs) Tel: (Home) +358-0-578628 / Internet: ukkonen@csc.fi (Work) +358-0-4573208 / Internet: jau@funet.fi (Mobile) +358-400-606671 v X.400: c=fi, admd=fumail, no prmd, org=csc, pn=jukka.ukkonen ------------------------------ CLIP CLIP ------------------------------ *** pcvt_kbd.c.orig Tue May 30 11:03:59 1995 --- pcvt_kbd.c Sun Jun 18 11:34:35 1995 *************** *** 359,364 **** --- 359,365 ---- int again = 0; int once = 0; int response, opri; + unsigned int wait_retries, seen_negative_response; /* Enable interrupts and keyboard, etc. */ if (kbc_8042cmd(CONTR_WRITE) != 0) *************** *** 401,406 **** --- 402,408 ---- printf("pcvt: doreset() - timeout for keyboard reset command\n"); /* Wait for the first response to reset and handle retries */ + while ((response = kbd_response()) != KEYB_R_ACK) { if (response < 0) *************** *** 432,442 **** /* Wait for the second response to reset */ while ((response = kbd_response()) != KEYB_R_SELFOK) { if (response < 0) { ! printf("pcvt: doreset() - response != OK and resonse < 0\n"); /* * If KEYB_R_SELFOK never arrives, the loop will * finish here unless the keyboard babbles or --- 434,455 ---- /* Wait for the second response to reset */ + wait_retries = seen_negative_response = 0; + while ((response = kbd_response()) != KEYB_R_SELFOK) { + /* + * Let's be a little more tolerant here... + * Receiving a -1 could indicate that the keyboard + * is not ready to answer just yet. + * Such cases have been noticed with e.g. Alps Membrane. + */ if (response < 0) + seen_negative_response = 1; + + if (seen_negative_response && (wait_retries >= 10)) { ! printf("pcvt: doreset() - response != OK and response < 0\n"); /* * If KEYB_R_SELFOK never arrives, the loop will * finish here unless the keyboard babbles or *************** *** 444,455 **** --- 457,471 ---- */ break; } + + wait_retries++; } splx (opri); #if PCVT_KEYBDID + query_kbd_id: opri = spltty (); if(kbd_cmd(KEYB_C_ID) != 0) *************** *** 462,468 **** r_entry: ! if((response = kbd_response()) == KEYB_R_MF2ID1) { if((response = kbd_response()) == KEYB_R_MF2ID2) { --- 478,484 ---- r_entry: ! if ((response = kbd_response()) == KEYB_R_MF2ID1) { if((response = kbd_response()) == KEYB_R_MF2ID2) { *************** *** 471,476 **** --- 487,501 ---- else if(response == KEYB_R_MF2ID2HP) { keyboard_type = KB_MFII; + } + else if (response == KEYB_R_RESEND) { + /* + * Let's give other priority levels + * a chance instead of blocking at + * tty level. + */ + splx (opri); + goto query_kbd_id; } else {