[openfirmware] [commit] r2630 - cpu/arm/olpc/1.75

repository service svn at openfirmware.info
Sat Oct 22 05:40:03 CEST 2011


Author: wmb
Date: Sat Oct 22 05:40:03 2011
New Revision: 2630
URL: http://tracker.coreboot.org/trac/openfirmware/changeset/2630

Log:
OLPC XO-1.75 - added watch-dc-biased and watch-dc-unbiased commands for checking sensor input mode.

Modified:
   cpu/arm/olpc/1.75/alc5631.fth
   cpu/arm/olpc/1.75/sound.fth

Modified: cpu/arm/olpc/1.75/alc5631.fth
==============================================================================
--- cpu/arm/olpc/1.75/alc5631.fth	Sat Oct 22 05:39:56 2011	(r2629)
+++ cpu/arm/olpc/1.75/alc5631.fth	Sat Oct 22 05:40:03 2011	(r2630)
@@ -30,7 +30,7 @@
    \ The speaker gain ratio must be <= the ratio of SPKVDD to AVDD.
    \ In our system, SPKVDD is 5V and AVDD is 3.3V, so we need a gain ratio <= 1.51 .
    \ The value 3 gives a ratio of 1.44, and value 4 gives a ratio of 1.56 .  We use 3.
-   h# 3e00 h# 40 codec!  \ Speaker Amp Ratio GAIN is 1.44x, no HPFs
+   h# 3e00 h# 40 codec!  \ Speaker Amp Ratio GAIN is 1.44x, HPF on ADC and DAC
 
    h# 0000 h# 42 codec!  \ Use MCLK, not PLL
 \  b# 1110.1100.1001.0000 h# 52 codec!  \ Protection on
@@ -42,10 +42,10 @@
 : mic-bias-off  ( -- )  h# 000c h# 3b codec-clr  ;
 : mic-bias-on   ( -- )  h# 000c h# 3b codec-set  ;
 
-: mic1-high-bias  ( -- )  h# 80 h# 22 codec-clr  mic-bias-on  ;  \ 0.90*AVDD, e.g. 3V with AVDD=3.3V
-: mic1-low-bias   ( -- )  h# 80 h# 22 codec-set  mic-bias-on  ;  \ 0.75*AVDD, e.g. 2.5V with AVDD=3.3V
-: mic2-high-bias  ( -- )  h# 08 h# 22 codec-clr  mic-bias-on  ;  \ 0.90*AVDD, e.g. 3V with AVDD=3.3V
-: mic2-low-bias   ( -- )  h# 08 h# 22 codec-set  mic-bias-on  ;  \ 0.75*AVDD, e.g. 2.5V with AVDD=3.3V
+: mic1-high-bias  ( -- )  h# 80 h# 22 codec-clr  ;  \ 0.90*AVDD, e.g. 3V with AVDD=3.3V
+: mic1-low-bias   ( -- )  h# 80 h# 22 codec-set  ;  \ 0.75*AVDD, e.g. 2.5V with AVDD=3.3V
+: mic2-high-bias  ( -- )  h# 08 h# 22 codec-clr  ;  \ 0.90*AVDD, e.g. 3V with AVDD=3.3V
+: mic2-low-bias   ( -- )  h# 08 h# 22 codec-set  ;  \ 0.75*AVDD, e.g. 2.5V with AVDD=3.3V
 
 : depop!  ( value -- )  h# 54 codec!  ;
 : pwr3a!  ( value -- )  h# 3a codec!  ;
@@ -201,8 +201,9 @@
 : adc-mono-right       ( -- )  h# 8000 adc-source  ;  \ R->L+R
 : adc-stereo-reversed  ( -- )  h# c000 adc-source  ;  \ L->R, R->L (channels swapped)
 
+true value mic-bias?
 : open-in-specific  ( -- )
-   h# 000c h# 3b codec-set  \ Power on MIC1/2 bias
+   mic-bias?  if  mic-bias-on  else  mic-bias-off  then  \ Power on MIC1/2 bias
    adc-stereo
    h# 0c00 h# 3b codec-set  \ Power on RECMIXLR
    h# 0030 h# 3b codec-set  \ Power on MIC1/2 boost gain

Modified: cpu/arm/olpc/1.75/sound.fth
==============================================================================
--- cpu/arm/olpc/1.75/sound.fth	Sat Oct 22 05:39:56 2011	(r2629)
+++ cpu/arm/olpc/1.75/sound.fth	Sat Oct 22 05:40:03 2011	(r2630)
@@ -400,6 +400,51 @@
 : read  ( adr len -- actual )  open-in audio-in  close-in  ;
 
 0 value mono?
+: stereo  false to mono?  ;
+: mono  true to mono?  ;
+
+: average-channel  ( adr -- n )
+   0 swap  /audio-buf  bounds  do   ( accum )
+      i <w@ +                       ( accum' )
+   /l +loop                         ( accum )
+   /audio-buf /l /  /               ( average )
+;
+: average-in  ( -- )
+   my-in-desc 2 la+ l@           ( adr )
+   (cr  push-decimal             ( adr )
+   dup average-channel           ( adr average )
+   6 .r space                    ( adr )
+   wa1+ average-channel          ( average )
+   6 .r                          ( )
+   pop-base                      ( )
+   my-in-desc 3 la+ l@ to my-in-desc
+;
+: audio-watch  ( -- )
+   setup-sspa-rx               ( )
+   make-in-ring                ( )
+   start-in-ring               ( )
+   master-rx                   ( )
+   begin                       ( )
+      wait-in                  ( )
+      average-in               ( )
+   key? until                  ( )
+   disable-sspa-rx             ( )
+   stop-in-ring                ( )
+   reset-rx                    ( )
+;
+: watch-dc  ( bias? -- )
+   to mic-bias?
+   d# 143 gpio-set   \ DC input mode
+   h# 0400 h# 40 codec-clr
+   open-in
+   stereo  0 set-adc-gain  0 set-mic-gain
+   \ High bias gets us closer to the top of the digital range - but bias can
+   \ be turned off completely with "false to mic-bias?"
+   mic1-high-bias mic2-high-bias
+   audio-watch
+   close-in
+;
+
 0 value in-adr0
 0 value in-len0
 : collapse-in  ( -- )
@@ -504,9 +549,6 @@
    set-adc-gain
 ;
 
-: stereo  false to mono?  ;
-: mono  true to mono?  ;
-
 : init-codec  ( -- )
    codec-on
    set-default-gains
@@ -570,6 +612,15 @@
 
 end-package
 
+: (watch-dc)  ( bias? -- )
+   " /audio" open-dev >r          ( bias? r: ihandle )
+   " watch-dc" r@ $call-method    ( r: ihandle )
+   r> close-dev                   ( )
+;
+: watch-dc-biased  ( -- )  true  (watch-dc)  ;
+: watch-dc-unbiased  ( -- )  false  (watch-dc)  ;
+
+
 \ LICENSE_BEGIN
 \ Copyright (c) 2011 FirmWorks
 \ 



More information about the openfirmware mailing list