Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 20 Jun 1995 23:02:21 +0300 (EET DST)
From:      Jukka Ukkonen <jau@aphrodite.funet.fi>
To:        hackers@freebsd.org
Subject:   patched pcvt keyboard recognition....
Message-ID:  <199506202002.XAA27390@aphrodite.funet.fi>

next in thread | raw e-mail | index | archive | help

	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
  			{



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199506202002.XAA27390>