[OpenBIOS] r322 - dev/olpc/cafecamera

svn at openbios.org svn at openbios.org
Wed Apr 25 09:26:54 CEST 2007


Author: wmb
Date: 2007-04-25 09:26:54 +0200 (Wed, 25 Apr 2007)
New Revision: 322

Modified:
   dev/olpc/cafecamera/cafecamera.fth
Log:
OLPC CaFe camera driver - added workaround for trac ticket #1360, and some diagnostics
to help catch the problem.


Modified: dev/olpc/cafecamera/cafecamera.fth
===================================================================
--- dev/olpc/cafecamera/cafecamera.fth	2007-04-25 07:18:07 UTC (rev 321)
+++ dev/olpc/cafecamera/cafecamera.fth	2007-04-25 07:26:54 UTC (rev 322)
@@ -27,10 +27,6 @@
 
 : cl!  ( l adr -- )  chip + rl!  ;
 : cl@  ( adr -- l )  chip + rl@  ;
-: cw!  ( w adr -- )  chip + rw!  ;
-: cw@  ( adr -- w )  chip + rw@  ;
-: cb!  ( b adr -- )  chip + rb!  ;
-: cb@  ( adr -- b )  chip + rb@  ;
 
 : map-regs ( -- )
    0 0  h# 0200.0010 my-space +  /regs " map-in" $call-parent to chip
@@ -73,12 +69,22 @@
    bc cl@ drop
 ;
 
+: ovc  ( val adr -- )
+   2dup ov@      ( val reg# val actual )
+   tuck <>  if   ( val reg# actual )
+      ." Bad camera I2C value at " swap 2 u.r  ( val actual )
+      ."  expected " swap 2 u.r  ."  got " 2 u.r  cr    ( )
+   else          ( val reg# actual )
+      3drop      ( )
+   then          ( )
+;
+
 \ ============================= camera operations =============================
 
 false value ov7670-detected?
 
 : ((camera-init)  ( -- )
-   80 12 ov!			\ reset
+   80 12 ov!			\ reset (reads back different)
    01 11 ov!			\ 30 fps
    04 3a ov!			\ UYVY or VYUY
    00 12 ov!			\ VGA
@@ -89,7 +95,7 @@
    b6 32 ov!			\ HREF pieces
    0a 19 ov!			\ Vert start high bits
    7a 1a ov!			\ Vert stop high bits
-   0a 0a ov!			\ GAIN, VSTART, VSTOP pieces
+   0a 03 ov!			\ GAIN, VSTART, VSTOP pieces
 
    \ Mystery scaling numbers
    00 0c ov!			\ Control 3
@@ -153,7 +159,7 @@
    00 3f ov!			\ Edge enhancement factor
    05 75 ov!  e1 76 ov!  00 4c ov!  01 77 ov!
    c3 3d ov!			\ Control 13
-   09 4b ov!  60 c9 ov!
+   09 4b ov!  60 c9 ov!         \ Reads back differently
    38 41 ov!			\ Control 16
    40 56 ov!
 
@@ -176,8 +182,99 @@
    03 79 ov!  40 c8 ov!
    05 79 ov!  30 c8 ov!
    26 79 ov!
+
+   \ OVT says that rewrite this works around a bug in 565 mode.
+   \ The symptom of the bug is red and green speckles in the image.
+   01 11 ov!			\ 30 fps def 80
 ;
 
+: config-check  ( -- )
+   01 11 ovc			\ 30 fps
+   04 3a ovc			\ UYVY or VYUY
+   ( 00 12 ovc )		\ VGA
+
+   \ Hardware window
+   13 17 ovc			\ Horiz start high bits
+   01 18 ovc			\ Horiz stop high bits
+   b6 32 ovc			\ HREF pieces
+   ( 0a 19 ovc )		\ Vert start high bits
+   7a 1a ovc			\ Vert stop high bits
+   0a 03 ovc			\ GAIN, VSTART, VSTOP pieces
+
+   \ Mystery scaling numbers
+   00 0c ovc			\ Control 3
+   00 3e ovc			\ Control 14
+   3a 70 ovc  35 71 ovc  11 72 ovc  f0 73 ovc
+   02 a2 ovc
+   00 15 ovc			\ Control 10
+
+   \ Gamma curve values
+   20 7a ovc  10 7b ovc  1e 7c ovc  35 7d ovc
+   5a 7e ovc  69 7f ovc  76 80 ovc  80 81 ovc
+   88 82 ovc  8f 83 ovc  96 84 ovc  a3 85 ovc
+   af 86 ovc  c4 87 ovc  d7 88 ovc  e8 89 ovc
+
+   \ AGC and AEC parameters
+   ( e0 13 ovc )		\ Control 8
+   ( 00 00 ovc )		\ Gain lower 8 bits
+   40 0d ovc			\ Control 4 magic reserved bit
+   ( 18 14 ovc )		\ Control 9: 4x gain + magic reserved bit
+   05 a5 ovc			\ 50hz banding step limit
+   07 ab ovc			\ 60hz banding step limit
+   ( 95 24 ovc )		\ AGC upper limit
+   33 25 ovc			\ AGC lower limit
+   e3 24 ovc			\ AGC/AEC fast mode op region
+   78 9f ovc			\ Hist AEC/AGC control 1
+   68 a0 ovc			\ Hist AEC/AGC control 2
+   03 a1 ovc			\ Magic
+   d8 a6 ovc			\ Hist AEC/AGC control 3
+   d8 a7 ovc			\ Hist AEC/AGC control 4
+   f0 a8 ovc			\ Hist AEC/AGC control 5
+   90 a9 ovc			\ Hist AEC/AGC control 6
+   94 aa ovc			\ Hist AEC/AGC control 7
+   ( e5 13 ovc	)		\ Control 8
+
+   \ Mostly magic
+   61 0e ovc  4b 0f ovc  02 16 ovc  07 1e ovc
+   02 21 ovc  91 22 ovc  07 29 ovc  0b 33 ovc
+   0b 35 ovc  1d 37 ovc  71 38 ovc  2a 39 ovc
+   78 3c ovc  40 4d ovc  20 4e ovc  00 69 ovc 
+   4a 6b ovc  10 74 ovc  4f 8d ovc  00 8e ovc
+   00 8f ovc  00 90 ovc  00 91 ovc  00 96 ovc
+   ( 00 9a ovc )  84 b0 ovc  0c b1 ovc  0e b2 ovc
+   82 b3 ovc  0a b8 ovc
+
+   \ More magic, some of which tweaks white balance
+   0a 43 ovc  f0 44 ovc  34 45 ovc  58 46 ovc
+   28 47 ovc  3a 48 ovc  88 59 ovc  88 5a ovc
+   44 5b ovc  67 5c ovc  49 5d ovc  0e 5e ovc
+   0a 6c ovc  55 6d ovc  11 6e ovc
+   9f 6f ovc			\ 9e for advance AWB
+   ( 40 6a ovc )
+   ( 40 01 ovc )		\ Blue gain
+   ( 60 02 ovc )		\ Red gain
+   e7 13 ovc			\ Control 8
+
+   \ Matrix coefficients
+   b3 4f ovc  b3 50 ovc  00 51 ovc  3d 52 ovc
+   a7 53 ovc  e4 54 ovc  9e 58 ovc
+
+   \ 08 41 ovc			\ AWB gain enable
+   ( 00 3f ovc )		\ Edge enhancement factor
+   05 75 ovc  e1 76 ovc  ( 00 4c ovc )  01 77 ovc
+   c0 3d ovc			\ Control 13
+   09 4b ovc  ( 60 c9 ovc )
+   38 41 ovc			\ Control 16
+   40 56 ovc
+
+   11 34 ovc
+   12 3b ovc			\ Control 11
+   88 a4 ovc  00 96 ovc  30 97 ovc  20 98 ovc
+   30 99 ovc  84 9a ovc  29 9b ovc  03 9c ovc
+   5c 9d ovc  3f 9e ovc  04 78 ovc
+
+;
+
 : camera-init  ( -- )
    false to ov7670-detected?
    ((camera-init)
@@ -424,6 +521,32 @@
    close					( error? )
 ;
 
+: dump-regs  ( run# -- )
+   0 d# 16 " at-xy" eval
+   ." Pass " .d
+   key upc  h# 47 =  if ." Good" else  ." Bad" then cr  \ 47 is G
+
+   ."        0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f" cr
+   ."       -----------------------------------------------" cr
+   h# ca 0  do
+      i 2 u.r ." :  "
+      i h# 10 bounds  do
+         i h# ca <  if  i ov@ 3 u.r   then
+      loop
+      cr
+   h# 10 +loop
+;
+
+: xselftest  ( -- error? )
+   open 0=  if  true exit  then
+   h# 10 0 do
+      shoot-still  drop  d# 500 ms  camera-config  config-check
+      i dump-regs
+   loop
+   0 close					( error? )
+;
+
+
 \ LICENSE_BEGIN
 \ Copyright (c) 2006 FirmWorks
 \ 




More information about the OpenBIOS mailing list