Author: wmb Date: Fri Nov 5 04:54:21 2010 New Revision: 2011 URL: http://tracker.coreboot.org/trac/openfirmware/changeset/2011
Log: OLPC XO-1.75 - Camera test now uses display video port instead of CPU copying into frame buffer.
Modified: cpu/arm/olpc/1.75/devices.fth cpu/arm/olpc/1.75/fw.bth cpu/arm/olpc/1.75/lcd.fth dev/olpc/mmp2camera/ccic.fth
Modified: cpu/arm/olpc/1.75/devices.fth ============================================================================== --- cpu/arm/olpc/1.75/devices.fth Fri Nov 5 02:44:07 2010 (r2010) +++ cpu/arm/olpc/1.75/devices.fth Fri Nov 5 04:54:21 2010 (r2011) @@ -27,7 +27,6 @@ fload ${BP}/forth/lib/sysuart.fth \ Set console I/O vectors to UART
0 value keyboard-ih -0 value screen-ih
fload ${BP}/ofw/core/muxdev.fth \ I/O collection/distribution device
@@ -86,6 +85,7 @@
\needs md5init fload ${BP}/ofw/ppp/md5.fth \ MD5 hash
+ [ifdef] notyet fload ${BP}/dev/olpc/confirm.fth \ Selftest interaction modalities fload ${BP}/cpu/x86/pc/olpc/mfgdata.fth \ Manufacturing data @@ -94,6 +94,7 @@
fload ${BP}/dev/olpc/kb3700/battery.fth \ Battery status reports [else] +: confirm-selftest? ( -- flag ) false ; \ XXX implement me : find-tag ( adr len -- false | value$ true ) 2drop false ; [then]
Modified: cpu/arm/olpc/1.75/fw.bth ============================================================================== --- cpu/arm/olpc/1.75/fw.bth Fri Nov 5 02:44:07 2010 (r2010) +++ cpu/arm/olpc/1.75/fw.bth Fri Nov 5 04:54:21 2010 (r2011) @@ -11,8 +11,6 @@ \ ' $report-name is include-hook \ ' noop is include-hook
-: confirm-selftest? ( -- flag ) true ; \ XXX implement me - fload ${BP}/cpu/arm/olpc/1.75/devices.fth
[ifndef] virtual-mode
Modified: cpu/arm/olpc/1.75/lcd.fth ============================================================================== --- cpu/arm/olpc/1.75/lcd.fth Fri Nov 5 02:44:07 2010 (r2010) +++ cpu/arm/olpc/1.75/lcd.fth Fri Nov 5 04:54:21 2010 (r2011) @@ -28,3 +28,74 @@ clkdiv h# 1a8 lcd! \ Clock divider h# 08021100 h# 190 lcd! \ DMA CTRL 0 - enable DMA, 24 bpp mode ; + +: normal-hsv ( -- ) + \ The brightness range is from ffff (-255) to 00ff (255) - 8 bits sign-extended + \ 0 is the median value + h# 0000.4000 h# 1ac lcd! \ Brightness.contrast 0 is normal brightness, 4000 is 1.0 contrast + h# 2000.4000 h# 1b0 lcd! \ Multiplier(1).Saturation(1) + h# 0000.4000 h# 1b4 lcd! \ HueSine(0).HueCosine(1) +; +: clear-unused-regs ( -- ) + 0 h# 0c4 lcd! \ Frame 0 U + 0 h# 0c8 lcd! \ Frame 0 V + 0 h# 0cc lcd! \ Frame 0 Command + 0 h# 0d0 lcd! \ Frame 1 Y + 0 h# 0d4 lcd! \ Frame 1 U + 0 h# 0d8 lcd! \ Frame 1 V + 0 h# 0dc lcd! \ Frame 1 Command + 0 h# 0e4 lcd! \ U and V pitch + 0 h# 130 lcd! \ Color key Y + 0 h# 134 lcd! \ Color key U + 0 h# 138 lcd! \ Color key V +; + +: centered ( w h -- ) + hdisp third - 2/ ( w h x ) \ X centering offset + vdisp third - 2/ ( w h x y ) \ Y centering offset + wljoin h# 0e8 lcd! ( w h ) + + wljoin dup h# 0ec lcd! ( h.w ) \ Source size + h# 0f0 lcd! ( ) \ Zoomed size +; +: zoomed ( w h -- ) + 0 h# 0e8 lcd! ( w h ) \ No offset when zooming + wljoin h# 0ec lcd! ( ) \ Source size + hdisp vdisp wljoin h# 0f0 lcd! ( ) \ Zoom to fill screen +; + +defer placement ' zoomed is placement + +: set-video-alpha ( 0..ff -- ) + 8 lshift ( xx00 ) + h# 194 lcd@ ( xx00 regval ) + h# ff00 invert and ( xx00 regval' ) + or ( regval' ) + h# 194 lcd! ( ) +; + +\ 0:RBG565 1:RGB1555 2:RGB888packed 3:RGB888unpacked 4:RGBA888 +\ 5:YUV422packed 6:YUV422planar 7:YUV420planar 8:SmartPanelCmd +\ 9:Palette4bpp A:Palette8bpp B:RGB888A +: set-video-mode ( mode -- ) + d# 20 lshift ( x00000 ) + h# 190 lcd@ ( x00000 regval ) + h# f00000 invert and ( x00000 regval' ) + or ( regval' ) + h# 190 lcd! ( ) +; +: video-on ( -- ) h# 190 lcd@ 1 or h# 190 lcd! ; +: video-off ( -- ) h# 190 lcd@ 1 invert and h# 190 lcd! ; +: set-video-dma-adr ( adr -- ) h# 0c0 lcd! ; + +\ Assumes RGB565 +: start-video ( adr w h -- ) + clear-unused-regs normal-hsv ( adr w h ) + over 2* h# 0e0 lcd! ( adr w h ) \ Pitch - width * 2 bytes/pixel + placement ( adr ) + set-video-dma-adr ( ) \ Video buffer + 0 set-video-mode ( ) \ RGB565 + d# 255 set-video-alpha ( ) \ Opaque video + video-on +; +: stop-video ( -- ) video-off ;
Modified: dev/olpc/mmp2camera/ccic.fth ============================================================================== --- dev/olpc/mmp2camera/ccic.fth Fri Nov 5 02:44:07 2010 (r2010) +++ dev/olpc/mmp2camera/ccic.fth Fri Nov 5 04:54:21 2010 (r2011) @@ -18,7 +18,7 @@ then ; : free-dma-bufs ( -- ) - dma-bufs dma-bufs-phys /dma-buf #dma-bufs * " free-capture-buffer" $call-parent + dma-bufs dma-bufs-phys /dma-buf #dma-bufs * free-capture-buffer 0 to dma-bufs 0 to dma-bufs-phys ;
@@ -105,21 +105,20 @@
0 value buf-act : /string ( adr len n -- adr' len' ) tuck - -rot + swap ; -: buf-done? ( -- false | buf-adr true ) +: buf-done? ( -- false | buf# true ) h# 30 cl@ dup 1 next-buf lshift and if ( value ) h# 30 cl! ( ) - next-buf 'dma-buf ( buf-adr ) - true ( buf-adr true ) + next-buf true ( buf# true ) else ( value ) drop false ( false ) then ;
-: snap ( timeout -- true | adr false ) +: snap ( timeout -- true | buf# false ) 0 do - buf-done? if ( buf-adr ) - false unloop exit ( -- buf-adr false ) + buf-done? if ( buf# ) + false unloop exit ( -- buf# false ) then 1 ms loop @@ -129,11 +128,12 @@ external
: read ( adr len -- actual ) - buf-done? if ( adr len buf-adr ) - -rot /dma-buf min ( buf-adr adr actual ) + buf-done? if ( adr len buf# ) + 'dma-buf -rot ( buf-adr adr len ) + /dma-buf min ( buf-adr adr actual ) dup >r move r> ( actual ) else - 2drop 0 + 2drop -2 then ;
@@ -145,7 +145,15 @@ true ;
+: start-display ( -- ) + 0 'dma-buf-phys VGA_WIDTH VGA_HEIGHT " start-video" $call-screen +; +: stop-display ( -- ) + " stop-video" $call-screen +; + : close ( -- ) + stop-display ctlr-stop interrupts-off power-off @@ -210,8 +218,9 @@ 2drop ( ) ;
-: display-frame ( adr -- ) - fb-pa copy16>24 +: display-frame ( buf# -- ) + 'dma-buf-phys " set-video-dma-adr" $call-screen +\ 'dma-buf fb-pa copy16>24 \ autobright ;
@@ -223,7 +232,7 @@ ;
: shoot-still ( -- error? ) - d# 1000 snap if true exit then ( adr ) + d# 1000 snap if true exit then ( buf# ) display-frame false ; @@ -243,6 +252,7 @@ : selftest ( -- error? ) open 0= if true exit then d# 300 ms + start-display unmirrored shoot-still ?dup if close exit then ( error? ) d# 1,000 ms mirrored shoot-movie full-brightness ( error? )