From alsa-devel-owner@alsa.jcu.cz  Wed Feb  3 10:50:53 1999
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 KAA31766;
	Wed, 3 Feb 1999 10:47:17 +0100
Date: Wed, 3 Feb 1999 10:47:17 +0100 (CET)
From: Jaroslav Kysela <perex@jcu.cz>
To: Martin Pahl <pahl@tnt.uni-hannover.de>
cc: alsa-devel@alsa.jcu.cz
Subject: Re: Question to dma-buf allocation
In-Reply-To: <199902030707.IAA19690@sokrates.tnt.uni-hannover.de>
Message-ID: <Pine.LNX.3.96.990203103729.1554F-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 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. 

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

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

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

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

							Jaroslav

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


