At Mon, 06 Oct 2003 19:19:08 +0200 (CEST), [EMAIL PROTECTED] wrote: > > Thanx that cleared a lot. > > I thought so, > > since I want to allocate once and then leave it, (because I dont want an exlusiv > use of capture and playback ...) > > Please three more questions: > > 1) I found also the function: > > snd_malloc_sgbuf_pages(hdspm->pci, wanted, dmab) > > Can I allocate memory with these before initializing a substream and > write it to hardware and then set all the buffer data in the > substream: > > runtime->dma_area = hdspm->p_dmab.area; > runtime->dma_addr = hdspm->p_dmab.addr; > runtime->dma_private = hdspm->p_dmab.private_data; > runtime->dma_bytes = hdspm->p_dmab.bytes; > > Do I miss something ?
the above is doable, but the preallocation mechanism is exactly what you want here. i'd recommend to simply pre-allocate the buffers and use snd_pcm_lib_malloc_pages() and snd_pcm_lib_free_pages() in hw_params and hw_free callbacks. > > 2) If SG_BUF makes continous virtual buffer > > why there is a > > .pages=snd_pcm_sgbuf_ops_page ^^^^^^ .page (without 's') > > function needed ? > what is the purpose of this ? this is mandatory to handle nopage callback in the mmap. check pcm_native.c. > 3) Just for my understanding: > > SG allocates scattered physical memory and maps it to > continous virtual: > > when I allocate via > > snd_malloc_sgbuf_pages(hdspm->pci, wanted, dmab) > > I test the memory so get a syslog: > > hdspm.c:2788: Preallocated 8192 kBytes > hdspm.c:2831: dmab(d27b7a84): area=e2db1000, addr=0, bytes = 0 (wanted 4194304), > private=ce4a25c0 > > hdspm.c:2834: area Start: e2db1000 End:e31b0ffc diff=4194300 > hdspm.c:2839: phys Start: b65b000 End:f6acffc diff=-67444732 > hdspm.c:2845: bus_to_virt Start: cb65b000 End:cf6acffc diff=-67444732 > > (src of this see at the end) > > > Which tells me > - virt is ok 4194304 > - phys is scattered so also any diff number is ok. > - but bus_to_virt of physical adress should make a continous, but it doesnt - Why ? you cannot calculate the virtual address from the physical address uniquely. a physical page can be mapped to different multiple virtual pages. (the ALSA's sg-buffer handler uses the vmap() for the virtual areas, btw.) Takashi ------------------------------------------------------- This sf.net email is sponsored by:ThinkGeek Welcome to geek heaven. http://thinkgeek.com/sf _______________________________________________ Alsa-devel mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/alsa-devel