From mboxrd@z Thu Jan 1 00:00:00 1970 From: Takashi Iwai Subject: Re: Scatter-Gather buffer allocation before running on HDSP-MADI ? Date: Tue, 07 Oct 2003 18:43:10 +0200 Sender: alsa-devel-admin@lists.sourceforge.net Message-ID: References: <16254.61960.840856.972245@seneca.iemnet> <1065460748.3f81a40c61063@iem.at> <16258.59662.729091.684464@seneca.iemnet> Mime-Version: 1.0 (generated by SEMI 1.14.5 - "Awara-Onsen") Content-Type: text/plain; charset=US-ASCII Return-path: In-Reply-To: <16258.59662.729091.684464@seneca.iemnet> Errors-To: alsa-devel-admin@lists.sourceforge.net List-Help: List-Post: List-Subscribe: , List-Unsubscribe: , List-Archive: To: Winfried Ritsch Cc: alsa-devel@lists.sourceforge.net List-Id: alsa-devel@alsa-project.org At Tue, 7 Oct 2003 18:25:50 +0200, Winfried Ritsch wrote: > > > Thanx that cleared a lot. > > So I managed now to put it in hw_params and it works in some way. > needed an additional > > There is one point I found: > > - when I preallocate with for playback and capture > 2*4194304 = 8388608 Bytes: > > snd_pcm_lib_preallocate_sg_pages_for_all(hdspm->pci, pcm,8388608,8388608)) this will allocate 838608 bytes for _each_ stream. so, you'll eventually allocate double. > and then in hw_params for one substream do a: > > snd_pcm_lib_malloc_pages(substream, 4194304); > > I got a sgbuf with size=8388608 not 4194304. So it takes all the > memory at first. > > Then I tried to preallcate 4194304 and it nearly works (see below). > > ... since in it prealloctes the mem for 2 substreams (seen in pcm_memory.c). > > at least I have to allocate one page more = 4194304+4096, to get no > Segmentation fault, but that could be the hardware too, since hdsp > also needs one page more ? the SG-buffer allocation size is aligned (round up) to PAGE_SIZE. (note that PAGE_SIZE is not always 4K byte on other architectures.) > What should be the right way ? > > a) Allocating the sum of both ? > > b) Acllocate with the value of one substream ? > > c) should I call snd_pcm_lib_preallocate_sg_pages_for_all twice ? > (also free pages twice) it's b). call the function with the size allocated for each stream. but please note that the preallocation doesn't assure that the given buffer size is allocated. also, snd_pcm_lib_malloc_pages() should be called with the configured buffer size (if the hardware supports different size of buffer -- i suppose it does). it would be like: snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params)); in hw_params callback. Takashi ------------------------------------------------------- This sf.net email is sponsored by:ThinkGeek Welcome to geek heaven. http://thinkgeek.com/sf