From alsa-devel-owner@alsa.jcu.cz  Thu Feb  4 07:09:50 1999
Received: from mgate2.uni-hannover.de (root@mgate2.uni-hannover.de [130.75.2.5])
	by marvin.jcu.cz (8.9.1a/8.9.1) with ESMTP id HAA20072
	for <alsa-devel@alsa.jcu.cz>; Thu, 4 Feb 1999 07:09:37 +0100
Received: from helios.tnt.uni-hannover.de by mgate2.uni-hannover.de 
          with LocalSMTP (PP) with ESMTP; Thu, 4 Feb 1999 07:09:33 +0100
Received: from sokrates.tnt.uni-hannover.de (pahl@sokrates.tnt.uni-hannover.de [130.75.31.157]) 
          by helios.tnt.uni-hannover.de (8.8.8/8.8.8) with ESMTP id HAA05620;
          Thu, 4 Feb 1999 07:09:33 +0100 (MET)
Received: (from pahl@localhost) by sokrates.tnt.uni-hannover.de (8.8.8/8.8.8) 
          id HAA28130; Thu, 4 Feb 1999 07:09:32 +0100
Date: Thu, 4 Feb 1999 07:09:32 +0100
Message-Id: <199902040609.HAA28130@sokrates.tnt.uni-hannover.de>
From: Martin Pahl <pahl@tnt.uni-hannover.de>
To: Jaroslav Kysela <perex@jcu.cz>
Cc: alsa-devel@alsa.jcu.cz
Subject: Re: Question to dma-buf allocation
In-Reply-To: <Pine.LNX.3.96.990203103729.1554F-100000@entry.jcu.cz>
References: <199902030707.IAA19690@sokrates.tnt.uni-hannover.de> <Pine.LNX.3.96.990203103729.1554F-100000@entry.jcu.cz>
Mime-Version: 1.0 (generated by tm-edit 7.106)
Content-Type: text/plain; charset=US-ASCII
Reply-To: alsa-devel@alsa.jcu.cz
Sender: alsa-devel-owner@alsa.jcu.cz
Precedence: list

>>>>> "Jaroslav" == Jaroslav Kysela <perex@jcu.cz> writes:

    Jaroslav> On Wed, 3 Feb 1999, Martin Pahl wrote:
    >> Ok, my ZA2-driver still does not work. I've a working driver outside
    >> ALSA and the only difference I see, is the allocation of DMA-buffer. 
    >> 
    >> In my old driver I used
    >> 
    >> za2_dma_buf = (unsigned long) kmalloc(131048, GFP_DMA);
    >> 
    >> to allocate the DMA-buffer.
    >> 
    >> Now I use the ALSA-code:
    >> 
    >> if (snd_dma2[dev] >= 0) {
    >> if ((err = snd_register_dma_channel(card,
    >> "ZA2 - DMA2",
    >> snd_dma2[dev],
    >> SND_DMA_TYPE_ISA,
    >> snd_dma2_size[dev],
    >> possible_dmas,
    >> &acard->dma2ptr)) < 0) 
    >> 
    >> and
    >> 
    >> if ((err=snd_pcm1_dma_alloc(pcm1, SND_PCM1_PLAYBACK,
    codec-> dma_out16ptr, "ZA2 (playback)"))<0)
    >> 
    >> to actually allocate a DMA-buffer. snd_pcm1_dma_alloc uses
    >> snd_malloc_pages, which uses __get_free_pages to allocate
    >> memory-pages. Is there any difference between those
    >> calls? __get_free_pages seems to return virtual pages because the
    >> buffer-adress is converted with virt_to_bus in snd_dma_program. 

    Jaroslav> The function __get_free_pages is internaly used by kmalloc, too. The 
    Jaroslav> result from these two functions are similar (except that __get_free_pages
    Jaroslav> doesn't use any space for memory allocation header, thus you can use whole
    Jaroslav> 128kB size).

    >> Another problem could be the DMA-buffer-blocksize. How often must an
    >> interrupt be generated from the sound card. 

    Jaroslav> Yep, I had quick look to your sources and I don't wonder that things in
    Jaroslav> your code doesn't work properly.

Maybe a quick look is to short :-)

    Jaroslav> The code in prepare() functions must use 'count' variable which determines
    Jaroslav> fragment length (interrupt rate). The variable means count of samples
    Jaroslav> among interrupts.

In my code I used pchn->block_size to calculate the interrupt-rate. Of
course it's better to use count, although they both have the same
value. As far as I can see, count is NOT the number of samples, but
the number of bytes between two interrupts. But anyway, changing
pchn->block_size to count does not change anything in the result: DMA
and interrupts are working, but nothing comes out of the speaker. It
looks like the data is transfered to a wrong position. Probably it's a
really silly mistake I made somewhere.

Martin Pahl

-- 
Martin Pahl                                email: pahl@tnt.uni-hannover.de  

Institut fuer Theoretische Nachrichtentechnik und Informationsverarbeitung
Universitaet Hannover                 http://www.tnt.uni-hannover.de/~pahl

