[openfirmware] [commit] r2373 - cpu/arm/olpc/1.75 dev/olpc/touchpad ofw/gui

repository service svn at openfirmware.info
Sat Jul 16 13:37:10 CEST 2011


Author: wmb
Date: Sat Jul 16 13:37:09 2011
New Revision: 2373
URL: http://tracker.coreboot.org/trac/openfirmware/changeset/2373

Log:
Implemented hardware mouse cursor for XO-1.75 display driver and modified menu cursor tracking and synaptics touchpad diag to use it if present.

Modified:
   cpu/arm/olpc/1.75/fw.bth
   cpu/arm/olpc/1.75/lcd.fth
   dev/olpc/touchpad/syntpad.fth
   ofw/gui/mouse.fth

Modified: cpu/arm/olpc/1.75/fw.bth
==============================================================================
--- cpu/arm/olpc/1.75/fw.bth	Fri Jul 15 15:18:51 2011	(r2372)
+++ cpu/arm/olpc/1.75/fw.bth	Sat Jul 16 13:37:09 2011	(r2373)
@@ -111,9 +111,6 @@
 ;
 ' (.firmware) to .firmware
 
-patch merge-rect-565 merge-rect merge-cursor  \ Hack since we do all our user-level graphics in 565
-patch merge-rect-565 merge-rect merge-cursor  \ Hack since we do all our user-level graphics in 565
-
 \ Uninstall the diag menu from the general user interface vector
 \ so exiting from emacs doesn't invoke the diag menu.
 ' quit to user-interface

Modified: cpu/arm/olpc/1.75/lcd.fth
==============================================================================
--- cpu/arm/olpc/1.75/lcd.fth	Fri Jul 15 15:18:51 2011	(r2372)
+++ cpu/arm/olpc/1.75/lcd.fth	Sat Jul 16 13:37:09 2011	(r2373)
@@ -100,3 +100,109 @@
    video-on
 ;
 : stop-video  ( -- )  video-off  ;
+
+: bg!  ( r g b -- )  h# 124 lcd!  ;
+: lcd-set  ( mask offset -- )  tuck lcd@ or swap lcd!  ;
+: lcd-clr  ( mask offset -- )  tuck lcd@ swap invert and swap lcd!  ;
+
+: cursor-on  ( -- )  h# 100.0000 h# 190 lcd-set  ;
+: cursor-off  ( -- )  h# 100.0000 h# 190 lcd-clr  ;
+
+: cursor-xy@  ( -- x y )  h# 10c lcd@ lwsplit  ;
+: cursor-xy!  ( x y -- )  cursor-off  wljoin h# 10c lcd!  cursor-on  ;
+
+: cursor-wh@  ( -- w h )  h# 110 lcd@ lwsplit  ;
+: cursor-wh!  ( w h -- )  wljoin h# 110 lcd!  ;
+
+: rgb<>bgr  ( rgb -- bgr )  lbsplit drop  swap rot  0 bljoin  ;
+: cursor-fgbg!  ( fg-rgb bg-rgb -- )  rgb<>bgr h# 12c lcd!  rgb<>bgr h# 128 lcd!  ;
+: cursor-fgbg@  ( -- fg-rgb bg-rgb )  h# 128 lcd@ rgb<>bgr  h# 12c lcd@ rgb<>bgr  ;
+
+: cursor-1bpp-mode  ( -- )  h# 200.0000 h# 190 lcd-set  ;
+: cursor-2bpp-mode  ( -- )  h# 200.0000 h# 190 lcd-clr  ;
+: cursor-opaque  ( -- )  cursor-1bpp-mode  h# 400.0000 h# 190 lcd-set  ;
+: cursor-transparent  ( -- )  cursor-1bpp-mode  h# 400.0000 h# 190 lcd-clr  ;
+
+: sram-write-mode  ( -- )  h# 198 lcd@ h# c000 invert and  h# 8000 or  h# 198 lcd!  ;
+: sram-read-mode  ( -- )  h# 198 lcd@ h# c000 invert and  h# 198 lcd!  ;
+: cursor-sram@  ( offset -- value )  h# 0c bwjoin h# 198 lcd!  h# 158 lcd@  ;
+: cursor-sram!  ( value offset -- )  swap h# 19c lcd!  h# 8c bwjoin h# 198 lcd!  ;
+: sram-read  ( adr len start path -- )
+   bwjoin  -rot  bounds ?do                 ( index )
+      dup h# 198 lcd!  h# 158 lcd@  i l!    ( index )
+      1+                                    ( index' )
+   /l +loop                                 ( index )
+   drop                                     ( )
+;
+: sram-write  ( adr len start path -- )
+   h# 80 or                                ( adr len start mode )
+   bwjoin  -rot  bounds ?do                ( index )
+      i l@ h# 19c lcd!  dup h# 198 lcd!    ( index )
+      1+                                   ( index' )
+   /l +loop                                ( index )
+   drop                                    ( )
+;
+: cursor-sram-read   ( adr len start -- )  h# c sram-read   ;
+: cursor-sram-write  ( adr len start -- )  h# c sram-write  ;
+
+0 value cursor-w
+0 value cursor-h
+
+: enable-cursor-writes  ( -- )
+   h# 8000 h# 1a4 lcd-set   \ allow writes to cursor SRAM
+;
+
+0 value #cursor-bits
+0 value cursor-bits
+0 value cursor-index
+: flush-cursor-bits  ( -- )
+   cursor-bits cursor-index cursor-sram!
+   0 to #cursor-bits
+   0 to cursor-bits
+   cursor-index 1+ to cursor-index
+;
+: +2bits  ( 0..3 -- )
+   #cursor-bits lshift cursor-bits or to cursor-bits
+   #cursor-bits 2+ to #cursor-bits
+   #cursor-bits d# 32 =  if
+      flush-cursor-bits
+   then
+;
+: init-cursor-bits  ( -- )
+   0 to #cursor-bits
+   0 to cursor-bits
+   0 to cursor-index
+;
+0 value cursor-pitch
+: set-cursor-line  ( fg-l bg-l -- )
+   cursor-w  0  do                 ( fg-l bg-l )
+      over  h# 8000.0000 and  if   ( fg-l bg-l )
+	 1     \ Color 1           ( fg-l bg-l value )
+      else                         ( fg-l bg-l )
+         dup h# 8000.0000 and  if  ( fg-l bg-l )
+            2  \ Color 2           ( fg-l bg-l value )
+	 else                      ( fg-l bg-l )
+	    0  \ Transparent       ( fg-l bg-l value )
+	 then                      ( fg-l bg-l value )
+      then                         ( fg-l bg-l value )
+      +2bits                       ( fg-l bg-l )
+      swap 2* swap 2*              ( fg-l' bg-l' )
+   loop                            ( fg-l bg-l )
+   2drop                           ( )
+;
+: set-cursor-image  ( 'fg 'bg w h fg-color bg-color -- )
+   init-cursor-bits                ( 'fg 'bg w h fg-color bg-color )
+   enable-cursor-writes            ( 'fg 'bg w h fg-color bg-color )
+   cursor-off                      ( 'fg 'bg w h fg-color bg-color )
+   cursor-2bpp-mode                ( 'fg 'bg w h fg-color bg-color )
+   cursor-fgbg!                    ( 'fg 'bg w h )
+   to cursor-h  to cursor-w        ( 'fg 'bg )
+   cursor-w cursor-h cursor-wh!    ( 'fg 'bg )
+   cursor-h  0  do                 ( 'fg 'bg )
+      over l@  over l@             ( 'fg 'bg fg-l bg-l )
+      set-cursor-line              ( 'fg 'bg )
+      swap la1+  swap la1+         ( 'fg' 'bg' )
+   loop                            ( 'fg 'bg )
+   2drop                           ( )
+   flush-cursor-bits               ( )
+;

Modified: dev/olpc/touchpad/syntpad.fth
==============================================================================
--- dev/olpc/touchpad/syntpad.fth	Fri Jul 15 15:18:51 2011	(r2372)
+++ dev/olpc/touchpad/syntpad.fth	Sat Jul 16 13:37:09 2011	(r2373)
@@ -49,6 +49,22 @@
 
 patch start remote-mode open
 
+0 value hw-cursor?
+defer move-hw-cursor  ( x y -- )
+' 2drop to move-hw-cursor
+0 0 2value saved-cursor-fgbg
+
+: setup-hw-cursor  ( -- )
+   " cursor-xy!" screen-ih ihandle>phandle  find-method  if
+      to move-hw-cursor
+      " cursor-fgbg@" $call-screen  to saved-cursor-fgbg
+      arrow-cursor h# ff00ff h# 00ff00  " set-cursor-image" $call-screen
+      true to hw-cursor?
+   else
+      false to hw-cursor?
+   then
+;
+
 \ The following code receives and decodes touchpad packets
 
 : show-packets  ( adr len -- )
@@ -140,10 +156,12 @@
    screen-w 2/ mouse-x !  screen-h 2/ mouse-y !
    screen-ih package( bytes/line )package  to /line
    load-base ptr !
+   setup-hw-cursor
 ;
 
 : dot  ( x y -- )
    swap screen-w 3 - min  swap y-offset + screen-h 3 - min  ( x' y' )
+   2dup move-hw-cursor                      ( )
    pixcolor @  -rot   3 3                   ( color x y w h )
    fill-rectangle-noff                      ( )
 ;
@@ -237,6 +255,10 @@
       if  track  then
    exit-test?  until
 
+   hw-cursor?  if
+      " cursor-off" $call-screen
+      saved-cursor-fgbg " cursor-fgbg!" $call-screen
+   then
    close
    cursor-on
    page

Modified: ofw/gui/mouse.fth
==============================================================================
--- ofw/gui/mouse.fth	Fri Jul 15 15:18:51 2011	(r2372)
+++ ofw/gui/mouse.fth	Sat Jul 16 13:37:09 2011	(r2373)
@@ -7,17 +7,6 @@
 
 0 value xpos  0 value ypos
 
-\ move-mouse-cursor ( x y - )
-\ remove-mouse-cursor ( - )
-\ poll-mouse  ( -- x y buttons )
-\ get-event  ( #msecs -- false | x y buttons true )
-\    0 means wait forever, buttons are ...RML
-\ trackmouse ( - ) invokes 
-\    defer handle-movement  ( x-abs y-abs buttons -- done? )
-\ e.g.
-\ ' move-cursor is handle-movement
-\ mouse position is kept in values x and y
-
 0 [if]
 d# 16 constant cursor-w
 d# 16 constant cursor-h
@@ -38,7 +27,7 @@
 \  04000000 ,  06000000 ,  02000000 ,  00000000 ,
    06000000 ,  06000000 ,  00000000 ,  00000000 ,
 [else]
-d# 17 constant cursor-w
+d# 18 constant cursor-w
 d# 31 constant cursor-h
 
 create white-bits
@@ -70,9 +59,9 @@
    00000000110000011000000000000000 ,
    00000000110000001100000000000000 ,
    00000000011000001100000000000000 ,
-   00000000011000000110000000000000 ,
-   00000000001100011000000000000000 ,
-   00000000000111110000000000000000 ,
+   00000000011000001100000000000000 ,
+   00000000001100001100000000000000 ,
+   00000000000111111000000000000000 ,
    00000000000111110000000000000000 ,
 
 create black-bits
@@ -104,21 +93,33 @@
    00000000001111110000000000000000 ,
    00000000000111110000000000000000 ,
    00000000000111110000000000000000 ,
-   00000000000011100000000000000000 ,
+   00000000000011110000000000000000 ,
    00000000000000000000000000000000 ,
    00000000000000000000000000000000 ,
 hex
 [then]
 
+: arrow-cursor  ( -- 'fg 'bg w h )
+   black-bits white-bits
+   cursor-w  cursor-h
+;
 
+0 value hardware-cursor?
 
 0 value /rect
 0 value old-rect
 0 value new-rect
 : alloc-mouse-cursor  ( -- )
-   cursor-w cursor-h *  ['] pix* screen-execute  to /rect
-   cursor-w cursor-h *  alloc-pixels to old-rect
-   cursor-w cursor-h *  alloc-pixels to new-rect
+   " cursor-xy!" screen-ih ihandle>phandle  find-method  if   ( xt )
+      drop
+      true to hardware-cursor?
+      arrow-cursor 0 h# ffffff " set-cursor-image" $call-screen
+   else
+      false to hardware-cursor?
+      cursor-w cursor-h *  ['] pix* screen-execute  to /rect
+      cursor-w cursor-h *  alloc-pixels to old-rect
+      cursor-w cursor-h *  alloc-pixels to new-rect
+   then
 ;
 
 : merge-cursor  ( -- )
@@ -131,11 +132,16 @@
 ;
 
 : remove-mouse-cursor  ( -- )
+   hardware-cursor?  if  " cursor-off" $call-screen  exit  then
    mouse-ih 0=  if  exit  then
    xpos ypos  old-rect  put-cursor
 ;
 : draw-mouse-cursor  ( -- )
    mouse-ih 0=  if  exit  then
+   hardware-cursor?  if
+      xpos ypos " cursor-xy!" $call-screen
+      exit
+   then
    xpos ypos 2dup old-rect -rot         ( x y adr x y )
    cursor-w cursor-h  read-rectangle    ( x y )
    old-rect  new-rect /rect move        ( x y )
@@ -178,6 +184,10 @@
    close-mouse?  if
       mouse-ih close-dev
       0 to mouse-ih
+      hardware-cursor?  if
+	 false to hardware-cursor?
+	 " cursor-off" $call-screen
+      then
    then
 ;
 : ?open-mouse  ( -- )



More information about the openfirmware mailing list