[openfirmware] r979 - dev

svn at openfirmware.info svn at openfirmware.info
Sun Oct 5 11:37:32 CEST 2008


Author: wmb
Date: 2008-10-05 11:37:32 +0200 (Sun, 05 Oct 2008)
New Revision: 979

Modified:
   dev/ps2mouse.fth
Log:
OLPC trac 8451 - further improvements in mouse/trackpad robustness.
Sometimes the driver would fail to open if either the first identify
command returned "RESEND" or the EC had mouse events queued up.  And
the driver failed to turn off streaming mode on close, thus causing
events to queue up if you touched the touchpad between "test /mouse" runs.

Modified: dev/ps2mouse.fth
===================================================================
--- dev/ps2mouse.fth	2008-10-04 00:11:03 UTC (rev 978)
+++ dev/ps2mouse.fth	2008-10-05 09:37:32 UTC (rev 979)
@@ -25,9 +25,35 @@
 \    apex?  0=  if  " get-data" $call-parent  ?ack  then
 \ ;
 
+: timed-read  ( #ms -- true | data false )
+   0  do
+      get-data?  if  unloop false exit  then
+      1 ms
+   loop
+   true
+;
+
+: put-get-data  ( cmd -- data )  " put-get-data" $call-parent  ;
 : send-cmd  ( cmd -- )  " put-data" $call-parent  ;
-: cmd  ( cmd -- )  " put-get-data" $call-parent ?ack  ;
 
+: cmd?  ( cmd -- error? )
+   dup put-get-data                   ( cmd response )
+   begin                              ( cmd response )
+      case                            ( cmd response )
+         h# fa of  drop false exit   endof   \ ACK
+         h# fe of  dup put-get-data  endof   \ RESEND - try again
+         ( cmd response )
+            d# 10 timed-read  if      ( cmd response )
+              2drop true exit
+            then                      ( cmd response new-response )
+            swap                      ( cmd new-response response )
+      endcase                         ( cmd new-response )
+   again
+;
+: cmd  ( cmd -- )  cmd? drop  ;
+
+\ : cmd  ( cmd -- )  " put-get-data" $call-parent ?ack  ;
+
 \ This serves the same purpose as "cmd", but it handles a bug in the
 \ Apex concentrator in which said device neglects to acknowledge certain
 \ commands.
@@ -100,13 +126,6 @@
 \ PS2 mouse packets have no framing information, so we must depend on
 \ timing information for framing
 : clear-queue  ( -- )  begin  get-data?  while  drop  repeat  ;
-: timed-read  ( #ms -- true | data false )
-   0  do
-      get-data?  if  unloop false exit  then
-      1 ms
-   loop
-   true
-;
 : no-event  ( -- 0 0 0 )  clear-queue  0 0 0  ;
 
 headers
@@ -148,9 +167,7 @@
 
 : identify  ( -- true | char false )
 \   h# f2  ['] read1  catch  dup  if  nip  then
-   h# f2  send-cmd
-
-   apex-timeout timed-read  if  true exit  else  drop  then
+   h# f2  cmd?  if  true exit  then
    apex-timeout timed-read
 ;
 
@@ -198,7 +215,7 @@
    remote-mode
    true
 ;
-: close  ( -- )  ;
+: close  ( -- )  stream-off  ;
 
 headerless
 \ Filter out large negative motions; they're probably spurious




More information about the openfirmware mailing list