home .. forth .. colorforth mail list archive ..

[colorforth] PCI soundcard (was How is colorForth different from other Forths?)



On Fri, 16 Jan 2004, Nick Maroudas wrote:

 While other Forths have adapted to ... evolutionary drive towards
complexity ... Colour Forth has stuck to its original ... simplicity ...
to remove ... veils ... between software and hardware.  Jeff has commented
on the surprising ease of programming ...

  ... for my ... music project ... by patiently studying CF's North Bridge
block, and by following Chuck's advice to get good hardware manuals, I
seem to see a way ... through the jungle of complexity.
>
> Nick


     Sure enough, once I had honest info thanks to Linux & Open Source,
CF gives direct access to the AC97 codec that does all the real work of
DAC, ADC, MPEG and mixing. Here it is, FIG style:-

( PCI soundcard.  North block 2e finds an ES1371 controller at io a800.
Linux and Open Source PCI manual say it controls an AC97 at ES port 14h.
Loading North also gives you the words for 4byte PCI io.  Then load yours)

forth North  **myblock load

: acport  a814 a! ;
: ac@  acport 4@ ;     ( -d)
: ac!  acport 4! ;     ( d-)

( Shift the address byte b of the AC97 register and add it to the data.
  Write it as a doubleword to ES#14, which has a serial link to AC#b)

: shift  1000 * ;      ( b-b****)
: acwr   shift + acwr ;     ( wb-)

( allow ample time for ES read-ready? signal WIP "Wait In Patience"?)

: wip  4000 for next ;

( to read acreg#b first send a mute datum 800000 to esreg#14)

: acrd 800000 swap acwr wip ac@ ;    ( b-d)

( to read AC97 master and pcm volume registers)

: mv@   2 acrd ;    ( -w)
: pv@  18 acrd ;

( to set them)

: mv!   2 acwr ;    ( w-)
: pv!  18 acwr ;

( to reset all ac regs to their default values, write anything to ac#0)

: reset  0 acrd  0 acwr ;    ( -w0-)

( example  -8*xxyyyy where 8 means validread, xx acreg#, yyyy data)

 mv@  ( -80028000  8000 means muted  ie no actual output)
 pv@  ( -80188x0x  would have been vol xx but muted by that initial8)

 0000 mv!  mv@   ( -80020000  max vol analog output)
 0f0f pv!  pv@   ( -80180f0f  mid vol pcm input)

 reset

 mv@  ( -80028000 as before)

-------------

This is work in progress, but I hope it shows how CF can help in
"dispelling the user illusion".  In contrast, Creative's software
encourages the illusion of still programming its ES1371 soundcard thru a
1bit ISA port at 220.  Linux's software admits the PCI reality and communicates
directly with the AC97 - but aims to create the illusion of still
programming it via an ES1371 soundcard!

Details on request, or on the wiki. Help welcome.

Nick



---------------------------------------------------------------------
To unsubscribe, e-mail: colorforth-unsubscribe@xxxxxxxxxxxxxxxxxx
For additional commands, e-mail: colorforth-help@xxxxxxxxxxxxxxxxxx
Main web page - http://www.colorforth.com