From: Takashi Iwai <tiwai@suse.de>
To: Jaroslav Kysela <perex@suse.cz>
Cc: Winfried Ritsch <ritsch@iem.at>, alsa-devel@lists.sourceforge.net
Subject: Re: Scatter-Gather buffer allocation before running on HDSP-MADI ?
Date: Mon, 06 Oct 2003 15:50:50 +0200 [thread overview]
Message-ID: <s5had8eo4p1.wl@alsa2.suse.de> (raw)
In-Reply-To: <Pine.LNX.4.53.0310052055350.13267@pnote.perex-int.cz>
At Sun, 5 Oct 2003 21:01:58 +0200 (CEST),
Jaroslav wrote:
>
> On Sat, 4 Oct 2003, Winfried Ritsch wrote:
>
> >
> > Hello !
> >
> > (A question from an newbie-developer to make it perfect ;-)
> >
> > I am writing an ALSA-lowleveldriver for the RME HDSP-MADI card.
> > (which have 64Audion in and out and an 128in64(= 8192Fader) Mixer
> > see http://www.rme-audio.de/hdsp/hdspmadi.htm ) Coding is quite
> > complete but I have trouble with the memory management.
> >
> > The Card uses ScatterGather Buffer, each channel 64kB and this
> > has to be asigned (to be safe) before activation, so I want
> > to allocate SGbuffer (64+64)*64*1024=8388608 in 4k-blocks.
> >
> > I do a
> >
> > snd_pcm_lib_preallocate_pci_pages_for_all(hdspm->pci, pcm,8388608l,8388608l)
> >
> > after making the pcm_device.
> >
> > Here the questions:
> >
> > 1) How can I get the sgbuf pointer ?
> >
> > ... since in the streams runtime is not set and therefore (besides the
> > Documentation says is (snd_pcm_sgbuf_t*)substream->dma_private which I
> > couldnt find)
> >
> > sgbuf = (snd_pcm_sgbuf_t*)substream->runtime->dma_private;
> >
> > is not assigned.
> >
> > but when I activate the card (for MIDI for example) there must be
> > memory asigned und I think doing it in hw_params is to late.
>
> Note that ALSA has SG routines only for PCM streams and it's lifetime is
> limited only for stream lifetime.
well, this is no longer true. the sg-buffer allocation is handled
generally in snd-page-alloc module (although only PCM handlers use it
in practice :)
and we have preallocation for sg PCM buffers now, too.
> If hardware needs to allocate a big
> buffer at the initialization phase, you have to do it yourself.
the SG buffers should be pre-allocated via
snd_pcm_lib_preallocate_sg_pages() and _for_all() functions
instead of snd_pcm_lib_preallocate_pci_pages() and co.
in addition, in hw_params() callback, you'll need to map the sg-pages
like below:
struct snd_sg_buf *sgbuf = snd_pcm_substream_sgbuf(substream);
...
for_all_pages { /* rewrite as you like */
/* get the physical address by snd_pcm_sgbuf_get_addr(). */
/* set this address on the hardware's address table */
do_my_mapping(snd_pcm_sgbuf_get_addr(sgbuf, offset));
}
check via82xx.c as an example (or emu10k1 driver as a more complex
case).
you can find a brief information in my tutorial ("Non-Contiguous
Buffers" section in "Buffer and Memory Management").
Takashi
-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
next prev parent reply other threads:[~2003-10-06 13:50 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 [this message]
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
[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=s5had8eo4p1.wl@alsa2.suse.de \
--to=tiwai@suse.de \
--cc=alsa-devel@lists.sourceforge.net \
--cc=perex@suse.cz \
--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.