[openfirmware] r835 - cpu/x86/pc/olpc dev/geode/display dev/olpc/cafecamera

svn at openfirmware.info svn at openfirmware.info
Wed Jun 11 11:03:04 CEST 2008


Author: wmb
Date: 2008-06-11 11:03:04 +0200 (Wed, 11 Jun 2008)
New Revision: 835

Added:
   cpu/x86/pc/olpc/expand16.fth
Modified:
   dev/geode/display/loadpkg.fth
   dev/olpc/cafecamera/cafecamera.fth
Log:
OLPC camera selftest - display the camera image expanded to fill the
screen.  In the movie mode, mirror image the display and automatically
adjust the brighness according to the ambient conditions.  Thanks to
Cortland Setlow for the idea and the code.


Added: cpu/x86/pc/olpc/expand16.fth
===================================================================
--- cpu/x86/pc/olpc/expand16.fth	                        (rev 0)
+++ cpu/x86/pc/olpc/expand16.fth	2008-06-11 09:03:04 UTC (rev 835)
@@ -0,0 +1,50 @@
+purpose: Display a 16bpp image expanded by 2x
+\ See license at end of file
+
+\ This code has the OLPC display dimensions hardcoded
+
+code expand-image  ( src dst --- )
+   0 [sp] edi xchg
+   4 [sp] esi xchg
+   d# 450 # edx mov
+   begin
+      d# 80 # esi add   \ Skip left edge of camera image
+      d# 600 # cx mov   \ Number of doubled scan lines
+      begin
+         op: ax lods                \ Get a pixel
+         op: ax d# 2400 [edi] mov   \ Write to next line
+         op: ax stos                \ Write to this line + increment
+         op: ax d# 2400 [edi] mov   \ Write to next line
+         op: ax stos                \ Write to this line + increment
+      loopa
+      d# 2400 # edi add             \ Skip the next output line - already written
+      edx dec
+   0= until
+   edi pop
+   esi pop
+c;
+: expand-to-screen  ( src -- )  frame-buffer-adr expand-image  ;
+
+\ LICENSE_BEGIN
+\ Copyright (c) 2008 FirmWorks
+\ 
+\ Permission is hereby granted, free of charge, to any person obtaining
+\ a copy of this software and associated documentation files (the
+\ "Software"), to deal in the Software without restriction, including
+\ without limitation the rights to use, copy, modify, merge, publish,
+\ distribute, sublicense, and/or sell copies of the Software, and to
+\ permit persons to whom the Software is furnished to do so, subject to
+\ the following conditions:
+\ 
+\ The above copyright notice and this permission notice shall be
+\ included in all copies or substantial portions of the Software.
+\ 
+\ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+\ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+\ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+\ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+\ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+\ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+\ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+\
+\ LICENSE_END

Modified: dev/geode/display/loadpkg.fth
===================================================================
--- dev/geode/display/loadpkg.fth	2008-06-06 21:23:28 UTC (rev 834)
+++ dev/geode/display/loadpkg.fth	2008-06-11 09:03:04 UTC (rev 835)
@@ -7,6 +7,8 @@
 fload ${BP}/dev/geode/display/gxfb.fth           \ Controller code
 fload ${BP}/dev/geode/display/gp.fth             \ Graphics processor support
 fload ${BP}/dev/video/common/rectangle16.fth     \ Rectangular graphics
+fload ${BP}/cpu/x86/pc/olpc/expand16.fth         \ Expand image by 2x
+fload ${BP}/dev/geode/display/gxvga.fth          \ Legacy VGA support
 
 \ LICENSE_BEGIN
 \ Copyright (c) 2006 FirmWorks

Modified: dev/olpc/cafecamera/cafecamera.fth
===================================================================
--- dev/olpc/cafecamera/cafecamera.fth	2008-06-06 21:23:28 UTC (rev 834)
+++ dev/olpc/cafecamera/cafecamera.fth	2008-06-11 09:03:04 UTC (rev 835)
@@ -300,6 +300,16 @@
    c0 3d ov!				\ Gamma enable, UV saturation auto adjust
 ;
 
+: read-agc  ( -- n )
+   3 ov@  h# c0 and  2 lshift  0 ov@ or
+;
+
+: read-aec  ( -- n )
+   7 ov@  h# 3f and  d# 10 lshift
+   h# 10 ov@  2 lshift  or
+   4 ov@  3 and  or
+;
+
 : set-hw  ( vstop vstart hstop hstart -- )
    dup  3 >> 17 ov!			\ Horiz start high bits
    over 3 >> 18 ov!			\ Horiz stop high bits
@@ -488,8 +498,18 @@
 0 constant test-x
 0 constant test-y
 
+\ Thanks to Cortland Setlow (AKA Blaketh) for the autobrightness code
+\ and the full-screen + mirrored display.
+
+: autobright  ( -- )
+   read-agc 3 + 3 rshift  h# f min  " bright!" " $call-screen" evaluate
+;
+: full-brightness  ( -- )  h# f " bright!" " $call-screen" evaluate  ;
+
 : display-frame  ( adr -- )
-   test-x test-y VGA_WIDTH VGA_HEIGHT " draw-rectangle" " $call-screen" evaluate
+\   test-x test-y VGA_WIDTH VGA_HEIGHT " draw-rectangle" " $call-screen" evaluate
+   " expand-to-screen" " $call-screen" evaluate
+   autobright
 ;
 
 : timeout-read  ( adr len timeout -- actual )
@@ -500,7 +520,7 @@
 ;
 
 : shoot-movie  ( -- error? )
-   /dma-buf #dma-bufs * dup alloc-mem swap	( adr len )
+   /dma-buf #dma-bufs * dup dma-alloc swap	( adr len )
    get-msecs movie-time + -rot			( timeout adr len )
    begin
       2dup read ?dup 0>  if			( timeout adr len actual )
@@ -510,26 +530,29 @@
       then					( timeout adr len )
       get-msecs 3 pick u>
    until					( timeout adr len )
-   free-mem drop false				( error? )
+   dma-free drop false				( error? )
 ;
 
 : shoot-still  ( -- error? )
-   /dma-buf dup alloc-mem tuck			( adr len adr )
+   /dma-buf dup dma-alloc tuck			( adr len adr )
    /dma-buf d# 1,000 timeout-read 0>  if	( adr len )
       over display-frame
       false
    else
       true
    then						( adr len error? )
-   -rot free-mem				( error? )
+   -rot dma-free				( error? )
 ;
 
+: mirrored  ( -- )  h# 1e ov@  h# 20 or  h# 1e ov!  ;
+: unmirrored  ( -- )  h# 1e ov@  h# 20 invert and  h# 1e ov!  ;
+
 : selftest  ( -- error? )
    open 0=  if  true exit  then
-   shoot-still  ?dup  if  close exit  then	( error? )
+   unmirrored  shoot-still  ?dup  if  close exit  then	( error? )
    d# 1,000 ms
-   shoot-movie					( error? )
-   close					( error? )
+   mirrored   shoot-movie  full-brightness		( error? )
+   close						( error? )
 ;
 
 : dump-regs  ( run# -- )




More information about the openfirmware mailing list