All of lore.kernel.org
 help / color / mirror / Atom feed
From: Takashi Iwai <tiwai@suse.de>
To: Martijn Sipkema <msipkema@sipkema-digital.com>
Cc: alsa-devel@lists.sourceforge.net
Subject: Re: Fw: writing audiowerk driver (philips saa7146a), some questions
Date: Fri, 31 May 2002 15:15:14 +0200	[thread overview]
Message-ID: <s5helfsh319.wl@alsa2.suse.de> (raw)
In-Reply-To: <003201c208a3$d8e06030$0400a8c0@martijn>

At Fri, 31 May 2002 14:05:20 +0100,
Martijn Sipkema wrote:
> 
> > >  - should i use the normal double buffered aproach or does having
> > >  more than 2 buffers have advantages?
> >
> > most of pci drivers use a linear contigous buffer for pcm (per
> > stream).
> > the scatter-gather buffer is not supported yet on alsa (as a mid/high
> > level layer -- it would be possible if you write all on the low-level
> > layer).
> > the buffer is accessed directly via mmap as long as it's supported.
> >
> >
> > >  - what is normally called the latency of an audio interface for output?
> > >  is this the total size of the buffers or (in the case of double
> buffered
> > > io)
> > >  only one buffer? i'm thinking it is the total buffer size and this
> would
> > >  make using more than 2 buffers have a better latency/interrupt response
> > >  time ratio, right?
> >
> > but if you have double buffer, isn't it difficult to handle mmap?
> > also i don't think double-buffer (that i'm not sure whether you mean
> > here "period" in the sense of alsa, or really double-buffering as in
> > graphics) leads to better latency.  of course my guess may be wrong.
> 
> i did not mean two buffers actually, perhaps the alsa term is period? with
> double buffering i meant having the saa7146 interrupt at half buffer.
 
then it's called "two periods per buffer" in alsa.

> the saa7146 uses a single contiguous buffer, optionally using an mmu (so
> then the buffer is not actually contiguous in physical memory).
 
ok, it's similar to trident or emu10k1, which uses also its own TLB.
for pcm, both of them use contigous memory buffer, though.

> thus, having more than two periods is advantageous?
 
let the choice left to application.
more periods would be more stable even for interrupts delay, but of
course would have longer latency.


> > >  - should setting the buffer size and number be done on modules loading
> > >  or should it be possible to change it after that? the saa7146 doesn't
> need
> > >  contiguous memory since it has a mmu.
> >
> > the buffer size and numbers are specified by each application.
> > at set-up stage, an application and driver commnucate with each other
> > to find the preferable condition.  the driver answers the hardware
> > restriction to the application which inquires the condition.
> > then the hardware is "prepared" actually, by calling prepare
> > callback.
> >
> > in most cases, the hardawre restriction (condition) can be described
> > in snd_pcm_hardware_t struct, which is passed to the runtime instance
> > at open callback.  the struct contains most of important conditions,
> > such as supported formats, rates, channels, max buffers, etc.
> > also, you can define more complicated conditions, if necessary.
> >
> 
> so if the application can set the buffer at set-up stage, it is best to
> allocate
> buffer memory at that time?
 
yes.  however, usually a chunk of memory is pre-allocated at the boot
time (i.e. when the module is loaded), to avoid possible memory
fragmentation.   you can find snd_pci_preallocate_buffer() is called
where the pcm is created via snd_pcm_new().


> > >  - does alsa allow varipitch? i think the new rme cards are supposed to
> > >  have this feature and the audiowerk8 has it, i.e. it can change its
> > > sampling
> > >  rate from about 37700 to 58200 hz while running in 1hz increments.
> > >  this allows for sync to video/tape/midi or whatever. or it allows for
> the
> > >  sample rate to be adjusted when receiving audio using rtp.
> >
> > basically no (at least not tested).  but i think it's not too
> > difficult to support it.  we can assign a control per pcm.
> > you'll need to change runtime->rate dynamically according to the
> > current rate, so that the tick interrupt handler calculates the time
> > properly.
> 
> again, i am not (yet) familiar with alsa, so i am not sure what
> runtime->rate is
> or what you mean with the tick interrupt handler (where can i find
> documentation
> on this?), but i think 'pitch' is meant as a deviation from the nominal
> sample rate
> and setting a large deviation can be thought of as a bad dac/adc?
 
there is a runtime instance for a pcm stream, and this holds the
informaton such as the current rate, channels, formats, etc.
there is no pitch parameter implemented in alsa, but this can be added
easily into the runtime instance, if inevitablly necessary.

alsa pcm engine invokes a timer interrupt to update the "tick", and
this tick is determined using the rate of the runtime instance.
if you change the rate value dynamically during playback, then the
tick interrupt will be wrongly scheduled, and leads to wrong detection
of under/overrun.


> > >  - the audiowerk8 uses three dma channels: one for input and two for
> output.
> > >  should i just wake a process that is blocking on a read() from the
> input
> > > dma
> > >  interrupt or should i wait until all three dma channels are ready and
> then
> > >  unblock all read()/write() processes? should unblocking the processes
> be
> > >  done
> > >  from bottom half?
> >
> > it's a job of alsa's high-level layer.
> > the lowlevel routines don't have to handle sleep()/wakeup().
> > just call snd_pcm_period_elapsed() in the interrupts routine when the
> > certain amount of samples have been processed.
> 
> is there any documentation on this?

not (yet)...  i once posted a very brief summary to alsa devel ML.
please check out the archive.


Takashi


_______________________________________________________________

Don't miss the 2002 Sprint PCS Application Developer's Conference
August 25-28 in Las Vegas -- http://devcon.sprintpcs.com/adp/index.cfm

  reply	other threads:[~2002-05-31 13:15 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-05-31 10:38 Fw: writing audiowerk driver (philips saa7146a), some questions Martijn Sipkema
2002-05-31 11:03 ` tomasz motylewski
2002-05-31 12:22   ` Martijn Sipkema
2002-05-31 11:26 ` Takashi Iwai
2002-05-31 13:05   ` Martijn Sipkema
2002-05-31 13:15     ` Takashi Iwai [this message]
2002-05-31 14:36       ` Martijn Sipkema
     [not found]         ` <s5h7klkh1ba.wl@alsa2.suse.de>
2002-05-31 18:11           ` Martijn Sipkema
2002-06-03 11:26 ` Bob Ham
2002-06-03 12:49   ` Fw: writing audiowerk driver (philips saa7146a),some questions Martijn Sipkema

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=s5helfsh319.wl@alsa2.suse.de \
    --to=tiwai@suse.de \
    --cc=alsa-devel@lists.sourceforge.net \
    --cc=msipkema@sipkema-digital.com \
    /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.