From alsa-devel-owner@alsa.jcu.cz  Sat Oct 24 20:43:18 1998
Received: from entry.jcu.cz (IDENT:perex@entry.jcu.cz [160.217.1.111])
	by marvin.jcu.cz (8.9.1a/8.9.1) with SMTP id UAA19930;
	Sat, 24 Oct 1998 20:41:27 +0200
Date: Sat, 24 Oct 1998 20:41:27 +0200 (CEST)
From: Jaroslav Kysela <perex@jcu.cz>
To: Martin Udden <nanook@linux.nu>
cc: "alsa-devel@jcu.cz" <alsa-devel@jcu.cz>
Subject: Re: EWS64 hacking
In-Reply-To: <36300A2E.452DD8DD@linux.nu>
Message-ID: <Pine.LNX.3.96.981024201300.15112E-100000@entry.jcu.cz>
MIME-Version: 1.0
Content-Type: TEXT/PLAIN; charset=US-ASCII
Reply-To: alsa-devel@alsa.jcu.cz
Sender: alsa-devel-owner@alsa.jcu.cz
Precedence: list

On Fri, 23 Oct 1998, Martin Udden wrote:

> Hi, I'm hacking around with my EWS64 (SAM9407 based) and succeed
> yesterday to make it play a WAV file =). 
> 
> Now, to make something of a alsa-driver (of the more primitive kind) I
> really need some examples of how to communicate with DMA-less cards The
> Right Way. Is there any of the currently supported cards that are
> DMA-less ? I mean, that don't use DMA-channels at all ?

No, but ALSA supports GF1 chip (wavetable chip on GUS soundcards) and this
chip have probably very similar interface as SAM9407 have.

>   The SAM9407 has its sample-buffer in onboard memory. Is the
> wave-playing procedure different from other cards ?

It is different, more code is needed to handle playback, but as I say
before - GF1 uses same algorithm. GF1 supports transfer between system
memory and soundcard memory with DMA, but other transfers (such as
programmed i/o) can be used, too. You can control under ALSA driver
all sample transfers (except mmaped access for OSS/Lite emulation module).

GF1 playback algorithm (look to struct snd_stru_pcm1_hardware for more
details):

1) middle level PCM code sends sample data to lowlevel code which
   should convert and/or write data to hardware (soundcard memory)
2) middle level PCM code sends start signal to lowlevel code
3) middle level PCM code sends stop signal to lowlevel code

Middle level PCM code uses ring buffer which is separated to fragments.
This isn't very big program for wavetable chips. You can simply allocate
same buffer size in onboard memory and transfer samples to same positions
as in buffer in system memory. One wavetable voice is programmed for loop
of whole ring buffer in soundcard memory (this is complicated a little
bit with fragment handling - interrupts).

>   Also the EWS features up to 32 hardware mixed channels, is this easy
> to implement in ALSA? I can already do this "in theory" with a good
> interrupt handler, but can ALSA do it? Are there any examples among the
> supported cards ?

Same algorithm is used for GF1 playback.

>   The driver should do wave-playing of eight channels + mixer
> (Volume/panning for all).

There should be a little problem with PCM devices limit. This limit is
currently 4 PCM devices per soundcard (we can increase this limit with
rearranging device minor numbers). GF1 PCM driver uses only one PCM
device with ability playing streams with 1-32 voices (channels).

							Jaroslav

-----
Jaroslav Kysela <perex@jcu.cz>
Academic Computer Centre, University of South Bohemia
Branisovska 31, C. Budejovice, CZ-370 05 Czech Republic


