Author: wmb
Date: Thu Dec 8 13:43:46 2011
New Revision: 2755
URL: http://tracker.coreboot.org/trac/openfirmware/changeset/2755
Log:
Absolutely-addressed text display routines for use by on-screen keyboard.
Modified:
ofw/gui/graphics.fth
Modified: ofw/gui/graphics.fth
==============================================================================
--- ofw/gui/graphics.fth Thu Dec 8 13:43:42 2011 (r2754)
+++ ofw/gui/graphics.fth Thu Dec 8 13:43:46 2011 (r2755)
@@ -114,6 +114,28 @@
)package
;
+: xy>screenadr ( x y -- screenadr )
+ bytes/line * swap pix* + frame-buffer-adr +
+;
+0 value char-fg 0 value char-bg
+: character-at-xy ( char x y -- )
+ screen-ih package(
+ 2>r ( char r: x y )
+ >font fontbytes char-width char-height ( 'font fontbytes w h r: x y )
+ 2r> xy>screenadr ( 'font fontbytes w h 'screen )
+ bytes/line char-fg char-bg ( font fontbytes w h 'screen bytes/line fg bg )
+ fb-paint ( )
+ )package
+;
+: type-at-xy ( adr len x y -- )
+ 2swap bounds ?do ( x y )
+ 2dup i c@ -rot character-at-xy ( x y )
+ screen-ih package( char-width )package ( x y char-width )
+ rot + swap ( x' y )
+ loop ( x y )
+ 2drop ( )
+;
+
: getchar ( -- byte ) key ;
\ use getchar or keyboard package read ( a n - actual ) to get input
Author: wmb
Date: Thu Dec 8 13:43:42 2011
New Revision: 2754
URL: http://tracker.coreboot.org/trac/openfirmware/changeset/2754
Log:
GUI mouse driver - support absolutely-addressed pointers like touchscreens.
Modified:
ofw/gui/mouse.fth
Modified: ofw/gui/mouse.fth
==============================================================================
--- ofw/gui/mouse.fth Thu Dec 8 13:43:38 2011 (r2753)
+++ ofw/gui/mouse.fth Thu Dec 8 13:43:42 2011 (r2754)
@@ -3,6 +3,8 @@
headerless
+false value mouse-absolute? \ True if coordinates are absolute
+
\ Current mouse cursor position
0 value xpos 0 value ypos
@@ -134,10 +136,12 @@
: remove-mouse-cursor ( -- )
hardware-cursor? if " cursor-off" $call-screen exit then
mouse-ih 0= if exit then
+ mouse-absolute? if exit then
xpos ypos old-rect put-cursor
;
: draw-mouse-cursor ( -- )
mouse-ih 0= if exit then
+ mouse-absolute? if exit then
hardware-cursor? if
xpos ypos " cursor-xy!" $call-screen
exit
@@ -152,6 +156,7 @@
: clamp ( n min max - m ) rot min max ;
: update-position ( x y -- )
+ mouse-absolute? if to ypos to xpos exit then
2dup or 0= if 2drop exit then \ Avoid flicker if there is no movement
\ Minimize the time the cursor is down by doing computation in advance
@@ -184,6 +189,7 @@
close-mouse? if
mouse-ih close-dev
0 to mouse-ih
+ false to mouse-absolute?
hardware-cursor? if
false to hardware-cursor?
" cursor-off" $call-screen
@@ -196,7 +202,13 @@
mouse-ih 0= if
" /mouse" open-dev to mouse-ih
then
- mouse-ih if alloc-mouse-cursor then
+ mouse-ih if
+ " absolute?" mouse-ih ['] $call-method catch if ( x x x )
+ 3drop false
+ then ( absolute? )
+ to mouse-absolute?
+ mouse-absolute? 0= if alloc-mouse-cursor then
+ then
then
;
: mouse-event? ( -- false | x y buttons true )
Author: wmb
Date: Thu Dec 8 13:43:12 2011
New Revision: 2747
URL: http://tracker.coreboot.org/trac/openfirmware/changeset/2747
Log:
EXC7200 touchscreen driver - mouse compatibility.
Modified:
cpu/arm/olpc/exc7200-touchscreen.fth
Modified: cpu/arm/olpc/exc7200-touchscreen.fth
==============================================================================
--- cpu/arm/olpc/exc7200-touchscreen.fth Thu Dec 8 13:43:07 2011 (r2746)
+++ cpu/arm/olpc/exc7200-touchscreen.fth Thu Dec 8 13:43:12 2011 (r2747)
@@ -4,13 +4,37 @@
0 0 " 4,8" " /twsi" begin-package
my-space encode-int my-address encode-int encode+ " reg" property
" touchscreen" name
+
+0 value screen-w
+0 value screen-h
+
: open ( -- okay? )
my-unit " set-address" $call-parent true
\ Read once to prime the interrupt
d# 10 " get" $call-parent 4drop 4drop 2drop
+ " dimensions" $call-screen to screen-h to screen-w
;
: close ( -- ) ;
-: get-touch? ( -- false | x y z down? contact# true )
+
+h# 7fff constant touchscreen-max-x
+h# 7fff constant touchscreen-max-y
+
+: invert-x ( x -- x' ) touchscreen-max-x swap - ;
+: invert-y ( y -- y' ) touchscreen-max-y swap - ;
+
+: scale-x ( x -- x' )
+ invert-x
+ screen-w touchscreen-max-x */
+;
+: scale-y ( y -- y' )
+ invert-y
+ screen-h touchscreen-max-y */
+;
+
+\ Try to receive a mouse report packet. If one arrives within
+\ 20 milliseconds, return true and the decoded information.
+\ Otherwise return false.
+: pad? ( -- false | x y z down? contact# true )
d# 99 gpio-pin@ if false exit then
d# 10 " get" $call-parent ( 4 flags xlo xhi ylo yhi zlo zhi 0 0 )
2drop bwjoin >r bwjoin >r bwjoin >r ( 4 flags r: z y x )
@@ -21,12 +45,26 @@
r> r> r> 4drop false exit ( -- false )
then ( flags r: z y x )
- r> r> r> 3 roll ( x y z flags )
+ r> scale-x ( flags x' r: z y )
+ r> scale-y ( flags x y' r: z )
+
+ r> 3 roll ( x y z flags )
dup 1 and 0<> ( x y z flags down? )
swap 2 rshift h# 1f and ( x y z down? contact# )
true ( x y z down? contact# true )
;
-
+true value absolute?
+: stream-poll? ( -- false | x y buttons true )
+ pad? if ( x y z down? contact# )
+ 0= if ( x y z down? )
+ nip 1 and true ( x y buttons true )
+ else ( x y z down? )
+ 4drop false ( false )
+ then ( false | x y buttons true )
+ else ( )
+ false ( false )
+ then ( false | x y buttons true )
+;
h# f800 constant red
h# 07e0 constant green
@@ -40,10 +78,8 @@
variable pixcolor
h# 4 value y-offset
-0 value screen-w
-0 value screen-h
-0 value /line
-2 value /pixel
+\ 0 value /line
+\ 2 value /pixel
variable ptr
@@ -66,30 +102,6 @@
show-packets
;
-h# 7fff constant touchscreen-max-x
-h# 7fff constant touchscreen-max-y
-
-: invert-x ( x y -- x' y ) touchscreen-max-x rot - swap ;
-: invert-y ( x y -- x y' ) touchscreen-max-y swap - ;
-
-: scale-xy ( x y -- x' y' )
- invert-x invert-y
- swap screen-w touchscreen-max-x */
- swap screen-h touchscreen-max-y */
-;
-
-\ Try to receive a mouse report packet. If one arrives within
-\ 20 milliseconds, return true and the decoded information.
-\ Otherwise return false.
-: pad? ( -- false | x y z down? contact# true )
- get-touch? if ( x dy buttons )
- 2>r >r scale-xy r> 2r> ( x' y' z down? contact# )
- true
- else
- false
- then
-;
-
\ Display raw data from the device, stopping when a key is typed.
: show-pad ( -- )
begin
@@ -133,9 +145,10 @@
then ( x y )
;
+: targets? ( -- flag ) true ; \ Used to be "final-test?"
+
: track-init ( -- )
- " dimensions" $call-screen to screen-h to screen-w
- screen-ih package( bytes/line )package to /line
+\ screen-ih package( bytes/line )package to /line
load-base ptr !
;
@@ -147,13 +160,13 @@
: background ( -- )
black 0 0 screen-w screen-h fill-rectangle-noff
- final-test? if
+ targets? if
false to left-hit?
false to right-hit?
draw-left-target
draw-right-target
else
- 0 d# 27 at-xy ." Touchscreen test. Type a key to exit" cr
+ 0 d# 27 at-xy ." Touchscreen test. Hit both targets to exit" cr
then
;
@@ -185,7 +198,7 @@
\ dup 5 and 5 = if background load-base ptr ! then
- final-test? if ( x y )
+ targets? if ( x y )
?hit-target ( x y )
then ( x y )
@@ -208,7 +221,7 @@
false value selftest-failed? \ Success/failure flag for final test mode
: exit-test? ( -- flag )
- final-test? if ( )
+ targets? if ( )
\ If the targets have been hit, we exit with successa
left-hit? right-hit? and if ( )
false to selftest-failed? ( )
@@ -236,6 +249,8 @@
then
;
+: flush-touchpad ( -- ) begin pad? while 2drop 3drop repeat ;
+
: selftest ( -- error? )
open 0= if
." Touchscreen open failed" true exit
@@ -248,7 +263,7 @@
\ Being able to open the touchpad is good enough in SMT mode
smt-test? if close false exit then
- final-test? 0= if
+ targets? 0= if
." Touchscreen test will start in 4 seconds" cr
d# 4000 ms
then
@@ -259,7 +274,7 @@
begin key? while key drop repeat
\ Consume already-queued trackpad events to prevent premature exit
- begin pad? while 2drop 3drop repeat
+ flush-touchpad
background
begin
@@ -267,10 +282,12 @@
if track then
exit-test? until
+ flush-touchpad
+
close
cursor-on
page
- final-test? if selftest-failed? else false then
+ targets? if selftest-failed? else false then
;
Author: wmb
Date: Thu Dec 8 13:43:07 2011
New Revision: 2746
URL: http://tracker.coreboot.org/trac/openfirmware/changeset/2746
Log:
USB EHCI driver - support low and full speed devices connected to EHCI controller, as some EHCI controllers can handle them without needing a companion controller.
Modified:
cpu/arm/olpc/3.0/usb.fth
dev/usb2/hcd/ehci/probe.fth
Modified: cpu/arm/olpc/3.0/usb.fth
==============================================================================
--- cpu/arm/olpc/3.0/usb.fth Thu Dec 8 13:43:02 2011 (r2745)
+++ cpu/arm/olpc/3.0/usb.fth Thu Dec 8 13:43:07 2011 (r2746)
@@ -16,6 +16,11 @@
: otg-set-host-mode 3 h# a8 ehci-reg! ; \ Force host mode
' otg-set-host-mode to set-host-mode
+ \ The Marvell EHCI can handle low and full speed devices directly,
+ \ without needing a UHCI or OHCI companion controller
+ ' make-port-node to handle-ls-device
+ ' make-port-node to handle-fs-device
+
: sleep ( -- ) true to first-open? ;
: wake ( -- ) ;
end-package
@@ -33,11 +38,17 @@
fload ${BP}/dev/usb2/hcd/ehci/loadpkg.fth
\ false to delay? \ No need for a polling delay on this platform
+ \ The Marvell EHCI can handle low and full speed devices directly,
+ \ without needing a UHCI or OHCI companion controller
+ ' make-port-node to handle-ls-device
+ ' make-port-node to handle-fs-device
+
: sleep ( -- ) true to first-open? ;
: wake ( -- ) ;
end-package
-\ Turn on USB power after a delay, to ensure that USB devices are reset correctly on boot
+\ usb-power-on is unnecessary on initial boot, as CForth turns on the
+\ USB power during its GPIO setup.
: usb-power-on ( -- )
d# 126 gpio-clr \ OTG 5V on
d# 127 gpio-clr \ ULPI 5V on
@@ -56,7 +67,7 @@
;
stand-init: Init USB Phy
-\ usb-power-on \ The EC now controls the USB power
+\ usb-power-on \ The USB power is turned on early, when CForth sets up GPIOs
init-usb
;
@@ -118,17 +129,24 @@
alias p2 probe-usb
0 value usb-keyboard-ih
+0 value otg-keyboard-ih
: attach-usb-keyboard ( -- )
" usb-keyboard" expand-alias if ( devspec$ )
drop " /usb" comp 0= if ( )
" usb-keyboard" open-dev to usb-keyboard-ih
usb-keyboard-ih add-input
- exit
then
else ( devspec$ )
2drop
then
+
+ " otg/keyboard" expand-alias if ( devspec$ )
+ open-dev to otg-keyboard-ih
+ otg-keyboard-ih add-input
+ else
+ 2drop
+ then
;
: detach-usb-keyboard ( -- )
Modified: dev/usb2/hcd/ehci/probe.fth
==============================================================================
--- dev/usb2/hcd/ehci/probe.fth Thu Dec 8 13:43:02 2011 (r2745)
+++ dev/usb2/hcd/ehci/probe.fth Thu Dec 8 13:43:07 2011 (r2746)
@@ -4,13 +4,15 @@
hex
headers
+0 value port-speed
+
: make-root-hub-node ( port -- )
\ Some devices (e.g. Lexar USB-to-SD) fail unless you get the cfg desc from device 0 first
0 set-target \ First address it as device 0 ( port )
- speed-high 0 di-speed! \ Use high speed for getting the device descriptor
+ port-speed 0 di-speed! \ Use high speed for getting the device descriptor
dev-desc-buf h# 40 get-cfg-desc drop ( port )
- speed-high ( port speed )
+ port-speed ( port speed )
\ hub-port and hub-dev route USB 1.1 transactions through USB 2.0 hubs
over get-hub20-port get-hub20-dev ( port speed hub-port hub-dev )
@@ -21,22 +23,31 @@
0 instance value probe-error? \ Back channel to selftest
+: make-port-node ( port -- )
+ ['] make-root-hub-node catch if
+ drop ." Failed to make root hub node for port " dup .d cr
+ true to probe-error?
+ then
+;
+defer handle-ls-device ' disown-port to handle-ls-device
+defer handle-fs-device ' disown-port to handle-fs-device
+
: probe-root-hub-port ( port -- )
false to probe-error? ( port )
dup disable-old-nodes ( port )
dup portsc@ 1 and 0= if drop exit then ( port ) \ No device detected
dup portsc@ h# c00 and h# 400 = if \ A low speed device detected
- dup disown-port \ Disown the port
+ speed-low to port-speed
+ dup handle-ls-device \ Process low-speed device
else \ Don't know what it is
dup reset-port \ Reset to find out
dup portsc@ 4 and 0= if \ A full speed device detected
- dup disown-port \ Disown the port
+ speed-full to port-speed
+ dup handle-fs-device \ Process full-speed device
else \ A high speed device detected
- dup ['] make-root-hub-node catch if \ Process high speed device
- drop ." Failed to make root hub node for port " dup .d cr
- true to probe-error?
- then
+ speed-high to port-speed
+ dup make-port-node \ Process high-speed device
then
then ( port# )
dup portsc@ swap portsc! ( ) \ Clear connection change bit