Author: wmb Date: Fri Mar 5 05:55:13 2010 New Revision: 1761 URL: http://tracker.coreboot.org/trac/openfirmware/changeset/1761
Log: OLPC trac 10053 - XO-1.5 - Flaky audio selftest. Use hardware synchronization between the output and input audio streams to make the test insensitive to CPU speed variations that can be caused by thermal throttling or interrupt vagaries.
Modified: dev/hdaudio/core.fth dev/hdaudio/noiseburst.fth dev/hdaudio/test.fth
Modified: dev/hdaudio/core.fth ============================================================================== --- dev/hdaudio/core.fth Mon Mar 1 06:25:09 2010 (r1760) +++ dev/hdaudio/core.fth Fri Mar 5 05:55:13 2010 (r1761) @@ -56,6 +56,7 @@ : wakeen h# 0c au + ; \ Wake enable : statests h# 0e au + ; \ Wake status : counter h# 30 au + ; \ Wall Clock Counter +: ssync h# 38 au + ; \ Stream synchronization : corblbase h# 40 au + ; : corbubase h# 44 au + ; : corbwp h# 48 au + ; \ CORB write pointer (last valid command) @@ -674,8 +675,10 @@
: out-in ( out-adr out-len in-adr in-len -- ) upsampling? if 2swap scale-factor upsample 2swap then ( out-adr,len in-adr,len ) + 1 out-sd lshift 1 in-sd lshift or ssync rl! \ Block the streams while setting up start-audio-in ( out-adr out-len ) start-audio-out ( ) + 0 ssync rl! ( ) \ Unblock the streams to start them simultaneously begin recording? if ?end-recording then playing? if ?end-playing then
Modified: dev/hdaudio/noiseburst.fth ============================================================================== --- dev/hdaudio/noiseburst.fth Mon Mar 1 06:25:09 2010 (r1760) +++ dev/hdaudio/noiseburst.fth Fri Mar 5 05:55:13 2010 (r1761) @@ -339,15 +339,15 @@ 1 max d# 10 swap */ debug? if dup .d cr then ; -\ Reasonable threshold is d# 25 + : fixture-ratio-left ( -- error? ) - left-range d# 240 d# 140 sm-covar-abs-sum nip ( sum1 ) + left-range d# 160 d# 60 sm-covar-abs-sum nip ( sum1 ) left-range d# 400 d# 300 sm-covar-abs-sum nip ( sum1 sum2 ) >ratio d# 25 < ; : fixture-ratio-right ( -- error? ) - right-range d# 240 d# 140 sm-covar-abs-sum nip ( sum1 ) + right-range d# 160 d# 60 sm-covar-abs-sum nip ( sum1 ) right-range d# 400 d# 300 sm-covar-abs-sum nip ( sum1 sum2 ) >ratio d# 25 < @@ -356,14 +356,14 @@ \ This compares the total energy within the impulse response band to the \ total energy in a similar-length band : case-ratio-left ( -- error? ) - left-range d# 200 d# 140 sm-covar-abs-sum nip ( sum1.high ) - left-range d# 540 d# 400 sm-covar-abs-sum nip ( sum1.high sum2.high ) + left-range d# 120 d# 60 sm-covar-abs-sum nip ( sum1.high ) + left-range d# 460 d# 400 sm-covar-abs-sum nip ( sum1.high sum2.high ) >ratio d# 25 < ; : case-ratio-right ( -- error? ) - right-range d# 330 d# 140 sm-covar-abs-sum nip ( sum1.high ) - right-range d# 590 d# 400 sm-covar-abs-sum nip ( sum1.high sum2.high ) + right-range d# 250 d# 60 sm-covar-abs-sum nip ( sum1.high ) + right-range d# 590 d# 400 sm-covar-abs-sum nip ( sum1.high sum2.high ) >ratio d# 14 < ; @@ -371,13 +371,13 @@ \ This compares the total energy within the impulse response band to the \ total energy in a similar-length band : loopback-ratio-left ( -- error? ) - left-stereo-range d# 148 d# 128 ss-covar-abs-sum nip ( sum1.high ) + left-stereo-range d# 68 d# 48 ss-covar-abs-sum nip ( sum1.high ) left-stereo-range d# 220 d# 200 ss-covar-abs-sum nip ( sum1.high sum2.high ) >ratio d# 70 < ; : loopback-ratio-right ( -- error? ) - right-stereo-range d# 148 d# 128 ss-covar-abs-sum nip ( sum1.high ) + right-stereo-range d# 68 d# 48 ss-covar-abs-sum nip ( sum1.high ) right-stereo-range d# 220 d# 200 ss-covar-abs-sum nip ( sum1.high sum2.high ) >ratio d# 70 < @@ -385,14 +385,25 @@
d# 1024 /w* buffer: impulse-response
-: calc-sm-impulse ( offset -- ) \ offset is 0 for left or 2 for right +: calc-sm-impulse ( offset -- adr ) \ offset is 0 for left or 2 for right pb + rb #samples ( adr1 adr2 #samples ) - d# 1024 0 do + d# 1200 0 do 3dup swap i wa+ swap stereo-mono-covar ( adr1 adr2 #samples d.covar ) d# 50000000 m/mod nip ( adr1 adr2 #samples n.covar ) impulse-response i wa+ w! ( adr1 adr2 #samples ) loop ( adr1 adr2 len ) 3drop ( ) + impulse-response ( adr ) +; +: calc-stereo-impulse ( offset -- adr ) \ offset is 0 for left or 2 for right + dup pb + swap rb + #samples ( adr1 adr2 #samples ) + d# 1200 0 do + 3dup swap i wa+ swap stereo-covar ( adr1 adr2 #samples d.covar ) + d# 50000000 m/mod nip ( adr1 adr2 #samples n.covar ) + impulse-response i wa+ w! ( adr1 adr2 #samples ) + loop ( adr1 adr2 len ) + 3drop ( ) + impulse-response ( adr ) ; : .samples ( adr end start -- ) do
Modified: dev/hdaudio/test.fth ============================================================================== --- dev/hdaudio/test.fth Mon Mar 1 06:25:09 2010 (r1760) +++ dev/hdaudio/test.fth Fri Mar 5 05:55:13 2010 (r1761) @@ -99,6 +99,11 @@ out-in ( ) " analyze-signal" $call-analyzer ( okay? ) ; +false value plot? \ Set to true to plot the impulse response, for debugging +: plot-impulse ( adr -- ) + " 0 set-fg h# ffff set-bg single-drawing clear-drawing wave" evaluate + key ascii d = if debug-me then +; : input-common-settings ( -- ) open-in 48kHz 16bit with-adc d# 73 input-gain ; @@ -114,6 +119,10 @@ ." Testing internal speakers and microphone" cr " setup-case" test-common false to force-speakers? false to force-internal-mic? + plot? if + 0 " calc-sm-impulse" $call-analyzer plot-impulse + 2 " calc-sm-impulse" $call-analyzer plot-impulse + then ; : test-with-fixture ( -- error? ) true to force-speakers? true to force-internal-mic? @@ -122,12 +131,20 @@ ." Testing internal speakers and microphone with fixture" cr " setup-fixture" test-common false to force-speakers? false to force-internal-mic? + plot? if + 0 " calc-sm-impulse" $call-analyzer plot-impulse + 2 " calc-sm-impulse" $call-analyzer plot-impulse + then ; : test-with-loopback ( -- error? ) input-common-settings stereo output-common-settings d# -33 set-volume \ -23 prevents obvious visible clipping ." Testing headphone and microphone jacks with loopback cable" cr " setup-loopback" test-common + plot? if + 0 " calc-stereo-impulse" $call-analyzer plot-impulse + 2 " calc-stereo-impulse" $call-analyzer plot-impulse + then ;
0 value saved-volume
openfirmware@openfirmware.info