All of lore.kernel.org
 help / color / mirror / Atom feed
From: Lars-Peter Clausen <lars@metafoo.de>
To: Raymond Yau <superquad.vortex2@gmail.com>,
	"Alexander E. Patrakov" <patrakov@gmail.com>
Cc: Takashi Iwai <tiwai@suse.de>,
	ALSA Development Mailing List <alsa-devel@alsa-project.org>,
	Clemens Ladisch <clemens@ladisch.de>,
	David Henningsson <david.henningsson@canonical.com>,
	Takashi Sakamoto <o-takashi@sakamocchi.jp>
Subject: Re: Master Plan on rewinding
Date: Mon, 22 Sep 2014 15:20:25 +0200	[thread overview]
Message-ID: <54202219.9070102@metafoo.de> (raw)
In-Reply-To: <CAN8cciYhJxJz1ZCctYzPsDj7J2OzNFFm11O29u3YP+aMN+xsyQ@mail.gmail.com>

On 09/21/2014 04:02 AM, Raymond Yau wrote:
[...]
> https://git.kernel.org/cgit/linux/kernel/git/tiwai/sound.git/commit/sound/soc/soc-generic-dmaengine-pcm.c?id=478028e088d6a94666d8a776be2cd2291faf3bbd
>
> a) Set the SNDRV_PCM_INFO_BATCH if the granularity is per period or worse.
> b) Fallback to the (race condition prone) period counting if the driver
> does not support any residue reporting.
>
> Seem soc already have this granularity
>
> How can the granularity worse more than one period ?

The granularity is the granularity that the DMA driver is able to report. In 
some cases the DMA driver is only able to tell whether a transfer has 
finished or not, but is not able tell any intermediate position. In case of 
a cyclic transfer the transfer never stops, so the DMA driver will only ever 
tell us that it hasn't finished the transfer yet. But the DMA driver will 
still generate a interrupt after every finished period. So we use this as a 
fallback mechanism and simply increase the pointer position after each 
interrupt by one period size. So userspace will never see a granularity that 
is worse than one descriptor. This is just something kernel internal.

On a side node, this period counting scheme is prone to race conditions and 
we strongly discourage new drivers from using it. Its mainly for supporting 
old DMA drivers which do not implement progress reporting (yet).

>
> https://git.kernel.org/cgit/linux/kernel/git/tiwai/sound.git/tree/include/linux/dmaengine.h
>
> enum dma_residue_granularity {
> DMA_RESIDUE_GRANULARITY_DESCRIPTOR = 0,
> DMA_RESIDUE_GRANULARITY_SEGMENT = 1,
> DMA_RESIDUE_GRANULARITY_BURST = 2,
> };
>
> There are three type of granularity

Only SEGMENT and BURST granularity are relevant for audio userspace.

For ALSA we'd probably see different kind of categories of granularity 
though. E.g. one field which is the unit of the granularity

PERIOD: The granularity is a multiple of the period size
FRAME: The granularity is a multiple of the frame size
BYTE: The granularity is a fixed number of bytes
MS: The granularity is a fixed amount of time

and then a second field that has a integer number of the granularity in that 
unit.


And then there is of course the issue that for some chips you can trade 
granularity for e.g. power efficiency or similar (e.g. by changing the 
transfer burst size). And this needs to be modeled somehow as well.

>
> Does this mean the those sound card can report
> DMA_RESIDUE_GRANULARITY_BURST and driver use readl in pcm pointer callback ?
>
> A few PCI sound cards use SG buffer including hda
>
> It seem that pulseaudio expect the driver support
> DMA_RESIDUE_GRANULARITY_BURST for rewind/ timer scheduling

Yes. This is why we set the BATCH flag if the granularity is not 
DMA_RESIDUE_GRANULARITY_BURST so for example pulse audio can disable timer 
scheduling.

- Lars

  reply	other threads:[~2014-09-22 13:20 UTC|newest]

Thread overview: 52+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-07 15:16 Master Plan on rewinding Alexander E. Patrakov
2014-09-07 18:38 ` Tanu Kaskinen
2014-09-07 19:05   ` Alexander E. Patrakov
2014-09-07 20:51 ` Clemens Ladisch
2014-09-08  3:06   ` Raymond Yau
2014-09-08  7:31   ` Alexander E. Patrakov
2014-09-09  8:43     ` Clemens Ladisch
2014-09-09  8:55       ` Alexander E. Patrakov
2014-09-09  9:08         ` David Henningsson
2014-09-09  9:31           ` Alexander E. Patrakov
2014-09-21  2:02             ` Raymond Yau
2014-09-22 13:20               ` Lars-Peter Clausen [this message]
2014-09-22 13:36                 ` Alexander E. Patrakov
2014-09-22 13:44                   ` Lars-Peter Clausen
2014-09-23  8:29                   ` Raymond Yau
2014-09-23 10:22                     ` Alexander E. Patrakov
2014-09-09 13:45         ` Clemens Ladisch
2014-09-09 15:55           ` Alexander E. Patrakov
2014-09-09 16:09             ` Takashi Iwai
2014-09-07 23:12 ` David Henningsson
2014-09-09 19:56   ` Pierre-Louis Bossart
2014-09-10  5:38     ` Alexander E. Patrakov
2014-09-08  7:34 ` Lars-Peter Clausen
2014-09-08  7:59 ` David Henningsson
2014-09-08  8:46   ` Alexander E. Patrakov
2014-09-08  9:26     ` David Henningsson
2014-09-08 10:21       ` Alexander E. Patrakov
2014-09-09  8:43         ` Clemens Ladisch
2014-09-11  3:49 ` Raymond Yau
2014-09-11  4:19   ` A. C. Censi
2014-09-13  9:15     ` Raymond Yau
2014-09-11  5:28   ` Alexander E. Patrakov
2014-09-11  6:21     ` Raymond Yau
2014-09-13  8:57     ` Raymond Yau
2014-09-13 10:43       ` Alexander E. Patrakov
2014-09-13 11:33         ` Raymond Yau
2014-09-13 11:36           ` Alexander E. Patrakov
2014-09-13 18:35 ` Alexander E. Patrakov
2014-09-14 11:37   ` Raymond Yau
2014-09-14 12:07     ` Alexander E. Patrakov
2014-09-15  2:43       ` Raymond Yau
2014-09-15  9:19       ` Takashi Iwai
2014-09-15  9:58         ` Alexander E. Patrakov
2014-09-15 10:08           ` Takashi Iwai
2014-09-15 17:01             ` Pierre-Louis Bossart
2014-09-15 17:14               ` Alexander E. Patrakov
2014-09-15 18:08                 ` Takashi Iwai
2014-09-18  1:15                   ` Raymond Yau
2014-09-21  9:22                     ` Alexander E. Patrakov
2014-09-21  9:53                     ` Clemens Ladisch
2014-09-21 10:56                       ` Alexander E. Patrakov
2014-09-22  3:27                       ` 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=54202219.9070102@metafoo.de \
    --to=lars@metafoo.de \
    --cc=alsa-devel@alsa-project.org \
    --cc=clemens@ladisch.de \
    --cc=david.henningsson@canonical.com \
    --cc=o-takashi@sakamocchi.jp \
    --cc=patrakov@gmail.com \
    --cc=superquad.vortex2@gmail.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.