All of lore.kernel.org
 help / color / mirror / Atom feed
From: Takashi Iwai <tiwai@suse.de>
To: Winfried Ritsch <ritsch@iem.at>
Cc: alsa-devel@lists.sourceforge.net
Subject: Re: Scatter-Gather buffer allocation before running on HDSP-MADI ?
Date: Tue, 07 Oct 2003 18:43:10 +0200	[thread overview]
Message-ID: <s5h65j1knhd.wl@alsa2.suse.de> (raw)
In-Reply-To: <16258.59662.729091.684464@seneca.iemnet>

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

  reply	other threads:[~2003-10-07 16:43 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-10-04 16:15 Scatter-Gather buffer allocation before running on HDSP-MADI ? Winfried Ritsch
2003-10-05 19:01 ` Jaroslav Kysela
2003-10-06 13:50   ` Takashi Iwai
2003-10-06 17:19     ` ritsch
2003-10-06 17:38       ` Takashi Iwai
2003-10-07 16:25         ` Winfried Ritsch
2003-10-07 16:43           ` Takashi Iwai [this message]
     [not found]             ` <1065776616.3f8675e8b202e@iem.at>
2003-10-10 11:39               ` Takashi Iwai
2003-10-10 11:57                 ` Jaroslav Kysela
2003-10-10 12:06                   ` Takashi Iwai
2003-10-10 12:15                     ` Jaroslav Kysela
2003-10-10 15:23                     ` Winfried Ritsch

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=s5h65j1knhd.wl@alsa2.suse.de \
    --to=tiwai@suse.de \
    --cc=alsa-devel@lists.sourceforge.net \
    --cc=ritsch@iem.at \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.