All of lore.kernel.org
 help / color / mirror / Atom feed
From: Takashi Sakamoto <o-takashi@sakamocchi.jp>
To: "Alexander E. Patrakov" <patrakov@gmail.com>,
	Raymond Yau <superquad.vortex2@gmail.com>,
	Clemens Ladisch <clemens@ladisch.de>
Cc: ALSA Development Mailing List <alsa-devel@alsa-project.org>,
	Lars-Peter Clausen <lars@metafoo.de>,
	Takashi Iwai <tiwai@suse.de>,
	Tanu Kaskinen <tanu.kaskinen@linux.intel.com>,
	Arun Raghavan <arun@accosted.net>,
	David Henningsson <david.henningsson@canonical.com>
Subject: Re: PulseAudio and SNDRV_PCM_INFO_BATCH
Date: Tue, 23 Jun 2015 07:52:10 +0900	[thread overview]
Message-ID: <5588919A.5090500@sakamocchi.jp> (raw)
In-Reply-To: <5587FB52.9070401@gmail.com>

On jUN 22 2015 21:10, Alexander E. Patrakov wrote:
> 22.06.2015 16:54, Raymond Yau wrote:
>>>>> Are all soc audio driver use cyclic dma ?
>>>>
>>>> I'm not sure I understand the question. All audio drivers use some
>>>> kind of cyclic DMA.
>>>
>>> The ALSA API requires the driver to provide a cyclic sample buffer (or
>>> something that behaves like one).
>>>
>>> However, not all hardware works this way.  USB and FireWire require the
>>> driver to continually queue new packets, whose size and timing are
>>> determined by the bus clock and are not directly related to the ALSA
>>> ring buffer.  These drivers use double buffering; the actual DMA happens
>>> from those packets, not from the ring buffer.
>>>
>>
>> If those queued packets/urb cannot be rewind, snd_pcm_rewindable should
>> return zero for those driver

No need at all for ALSA firewire drivers, because PCM frames which is
not transferred are still rewindable.

Current ALSA firewire stack implementation, 16 packets are queued in one
callback from software interrupt context. In IEEE 1394 bus, 8,000
packets are transmitted per second. Therefore, one callback processes
PCM frames around 2 msec.
(Actually, in IEC 61883-6, two ways to transfer PCM frames in
these packets, thus one callback cannot processes PCM frames 'just' 2 msec.)

Let's consider about actual time, for example, in my system:
 * Software interrupt interval takes 1.986-2.015msec
 * The processing of one callback takes 0.024-0.026msec

(Intel DH77DF, Core i3-2120T, 4GB RAM, VT6315 as 1394 OHCI controller)

During processing one callback, pcm frames are copied to packet buffer.
The 'hw_ptr' is updated every time the number of copied pcm
frames is across period boundary. Therefore, the 'hw_ptr' suddenly jumps
by one period. This is a reason to use 'SNDRV_PCM_INFO_BLOCK_TRANSFER'.

While, snd-firewire-lib has internal representation to count the number
of transferred PCM frames. The 'struct snd_pcm_ops.pointer()' returns
the counter in the representation. This counter is updated during the
callback processing, while it's not updated between the callback.
Therefore, the counter changes during 0.024-0.026msec and calm
during 1.986-2.015msec. In short, the counter doesn't move continuously.
Roughly, this may be observed as the returned value of 'struct
snd_pcm_ops.pointer()' changes every 1.986-2.015msec. This
is a reason to use 'SNDRV_PCM_INFO_BATCH'.

(I think we use these two flags as the same way as Lars explained:
http://mailman.alsa-project.org/pipermail/alsa-devel/2015-June/093750.html)

(In my understanding, 'SNDRV_PCM_INFO_BATCH' means that 'struct
snd_pcm_ops.pointer()' returns correct value in PCM period/buffer but
the value doesn't change constantly against actual time frame.
Therefore, several periods must be included in the buffer.)

Well, here, I describe two aspects; one is for period size and
across-boundary, another is for rewindability.

* period size and across-boundary:
All of ALSA firewire drivers has a restriction that the minimum size of
period is equivalent to 5 msec. Our intension is that at least one
callback from software interrupt context occurs during processing PCM
frames equivalent to the size of period.
('5' msec is for safe. '3' msec may be OK, I think.)

* rewindability
During the 0.024-0.026msec, snd_pcm_rewindable() returns the value based
on currect pointer position in the internal representation in
snd-firewire-lib, while the value is immediately changed and the
retrieved value becomes old. During the 1.986-2.015msec,
snd_pcm_rewindable returns the fastened value because no PCM frames are
processed for transmission.


By the way, abour the packetization and PCM frame processing, I've
written a report:
https://github.com/takaswie/alsa-firewire-report

If you want to post your questions about ALSA firewire stack, please
read this report and consider about your issues before posting it,
Raymond. Of cource, I'm welcome to receive any questions or indications
about the content of my report.


Regards

Takashi Sakamoto

  parent reply	other threads:[~2015-06-22 22:52 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-12 12:29 PulseAudio and SNDRV_PCM_INFO_BATCH Arun Raghavan
2015-06-12 12:32 ` Arun Raghavan
2015-06-12 13:43   ` Alexander E. Patrakov
2015-06-12 13:57     ` Alexander E. Patrakov
2015-06-17  3:04     ` Raymond Yau
2015-06-17  3:38       ` Alexander E. Patrakov
2015-06-15  3:42   ` Raymond Yau
2015-06-15  8:03 ` Lars-Peter Clausen
2015-06-15 11:39   ` Raymond Yau
2015-06-15 12:01     ` Lars-Peter Clausen
2015-06-15 13:34       ` Raymond Yau
2015-06-15 14:16         ` Lars-Peter Clausen
2015-06-16  2:33           ` Raymond Yau
2015-06-17  8:27             ` Lars-Peter Clausen
2015-06-17  9:19               ` Takashi Iwai
2015-06-17 15:09                 ` David Henningsson
2015-06-17 16:48                   ` Alexander E. Patrakov
2015-06-18  3:15                     ` Raymond Yau
2015-06-19 11:19                       ` Alexander E. Patrakov
2015-06-19  1:17                   ` Raymond Yau
2015-06-19 11:32                   ` Takashi Iwai
2015-06-20  3:24                     ` Raymond Yau
2015-06-20  6:17                     ` Raymond Yau
2015-06-22  2:35           ` Raymond Yau
2015-06-22  6:43             ` Lars-Peter Clausen
2015-06-22  7:49               ` Raymond Yau
2015-06-22  9:41               ` Clemens Ladisch
2015-06-22 11:54                 ` Raymond Yau
2015-06-22 12:10                   ` Alexander E. Patrakov
2015-06-22 12:34                     ` Raymond Yau
2015-06-22 12:49                       ` Alexander E. Patrakov
2015-06-22 15:50                         ` Raymond Yau
2015-06-22 16:28                           ` Alexander E. Patrakov
2015-06-24  5:51                             ` Raymond Yau
2015-06-22 22:52                     ` Takashi Sakamoto [this message]
2015-06-27 15:28   ` Alexander E. Patrakov
2015-06-27 17:15     ` Clemens Ladisch
2015-06-27 17:58       ` Alexander E. Patrakov
2015-06-28  2:09         ` Raymond Yau

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=5588919A.5090500@sakamocchi.jp \
    --to=o-takashi@sakamocchi.jp \
    --cc=alsa-devel@alsa-project.org \
    --cc=arun@accosted.net \
    --cc=clemens@ladisch.de \
    --cc=david.henningsson@canonical.com \
    --cc=lars@metafoo.de \
    --cc=patrakov@gmail.com \
    --cc=superquad.vortex2@gmail.com \
    --cc=tanu.kaskinen@linux.intel.com \
    --cc=tiwai@suse.de \
    /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.