[openfirmware] r1257 - cpu/x86/pc/olpc/via dev/hdaudio
svn at openfirmware.info
svn at openfirmware.info
Wed Jul 29 03:08:57 CEST 2009
Author: wmb
Date: 2009-07-29 03:08:57 +0200 (Wed, 29 Jul 2009)
New Revision: 1257
Modified:
cpu/x86/pc/olpc/via/addrs.fth
dev/hdaudio/core.fth
Log:
Via - Fixed test /audio
Modified: cpu/x86/pc/olpc/via/addrs.fth
===================================================================
--- cpu/x86/pc/olpc/via/addrs.fth 2009-07-28 04:19:31 UTC (rev 1256)
+++ cpu/x86/pc/olpc/via/addrs.fth 2009-07-29 01:08:57 UTC (rev 1257)
@@ -36,7 +36,7 @@
h# 18.0000 constant heap-size
-h# 20.0000 constant /dma-extra \ In case the firmware region isn't enough
+h# 40.0000 constant /dma-extra \ In case the firmware region isn't enough
/fw-ram /dma-extra + constant dma-size \ We let the DMA area overlap the FW area
fw-pa /dma-extra - constant dma-base
Modified: dev/hdaudio/core.fth
===================================================================
--- dev/hdaudio/core.fth 2009-07-28 04:19:31 UTC (rev 1256)
+++ dev/hdaudio/core.fth 2009-07-29 01:08:57 UTC (rev 1257)
@@ -78,12 +78,11 @@
\ \\ Stream Descriptors
\ Default: 48kHz 16bit stereo
-1 value scale-factor
-0 value sample-base
-0 value sample-mul
-0 value sample-div
-1 value sample-format
-2 value #channels
+0 instance value sample-base
+0 instance value sample-mul
+0 instance value sample-div
+1 instance value sample-format
+2 instance value #channels
: stream-format ( -- u )
sample-base d# 14 lshift ( acc )
@@ -221,9 +220,17 @@
;
defer playback-alarm
+0 value alarmed?
-: install-playback-alarm ( -- ) ['] playback-alarm d# 20 alarm ;
-: uninstall-playback-alarm ( -- ) ['] playback-alarm d# 0 alarm ;
+: install-playback-alarm ( -- )
+ true to alarmed? ['] playback-alarm d# 20 alarm
+;
+: uninstall-playback-alarm ( -- )
+ alarmed? if
+ ['] playback-alarm d# 0 alarm
+ false to alarmed?
+ then
+;
\ \ Device open and close
@@ -232,11 +239,9 @@
: init-codec ( -- ) detect-codec open-codec ;
: close-controller ( -- ) reset unmap-regs ;
-: open ( -- flag ) init-controller init-codec true ;
-: close ( -- ) uninstall-playback-alarm close-codec close-controller ;
+d# 48.000 instance value sample-rate
+1 instance value scale-factor
-d# 48.000 value sample-rate
-
: low-rate? ( Hz ) dup d# 48.000 < swap d# 44.100 <> and ;
: set-sample-rate ( Hz -- )
@@ -255,6 +260,20 @@
then
;
+0 value open-count
+: open ( -- flag )
+ open-count 0= if init-controller then
+ init-codec
+ open-count 1+ to open-count
+ true
+;
+: close ( -- )
+ open-count 1 = if
+ uninstall-playback-alarm close-codec close-controller
+ then
+ open-count 1- 0 max to open-count
+;
+
\ \ Streams
\ \\ Sound buffer
@@ -400,7 +419,7 @@
: steps/dB ( -- #steps ) step-size 4 * ;
: dB>steps ( dB -- #steps ) -4 * step-size / ;
-: step# ( dB -- step ) dB>steps 0dB-step + ;
+: dB>step# ( dB -- step ) dB>steps 0dB-step + ;
\ \\ Playback
@@ -409,16 +428,17 @@
: open-out ( -- )
4 to sd#
48kHz
- upsampling? if scale-factor upsample then ( adr len )
;
: audio-out ( adr len -- actual )
+ dup >r
+ upsampling? if scale-factor upsample then ( adr len )
install-sound-buffer ( )
setup-bdl
setup-stream
enable-codec-playback
start-stream
- /sound-buffer ( actual )
+ r> ( actual )
;
: release-sound-buffer ( -- )
@@ -449,7 +469,7 @@
: wait-sound ( -- ) ; \ sound stops with asynchronous alarm handler
-: set-volume ( dB -- ) dac to node step# output-gain ;
+: set-volume ( dB -- ) dac to node dB>step# output-gain ;
\ \\ Recording
More information about the openfirmware
mailing list