alsa-devel.alsa-project.org archive mirror
 help / color / mirror / Atom feed
From: Peter Ujfalusi <peter.ujfalusi@nokia.com>
To: alsa-devel@alsa-project.org
Cc: tiwai@suse.de, broonie@opensource.wolfsonmicro.com, lrg@slimlogic.co.uk
Subject: [RFC 2/4] ASoC: core: Add delay operation to snd_soc_dai_ops
Date: Tue,  2 Mar 2010 15:39:49 +0200	[thread overview]
Message-ID: <1267537191-25254-3-git-send-email-peter.ujfalusi@nokia.com> (raw)
In-Reply-To: <1267537191-25254-1-git-send-email-peter.ujfalusi@nokia.com>

The delay calback can be used by the core to query the delay
on the dais caused by FIFO.
In case if both CPU and CODEC dai has FIFO the delay reported
by each will be added to form the full delay on the chain.
If none of the dai has FIFO, than the delay will be kept as
zero.

Signed-off-by: Peter Ujfalusi <peter.ujfalusi@nokia.com>
---
 include/sound/soc-dai.h |    6 ++++++
 sound/soc/soc-core.c    |   15 +++++++++++++++
 2 files changed, 21 insertions(+), 0 deletions(-)

diff --git a/include/sound/soc-dai.h b/include/sound/soc-dai.h
index 061f16d..be9cd47 100644
--- a/include/sound/soc-dai.h
+++ b/include/sound/soc-dai.h
@@ -182,6 +182,12 @@ struct snd_soc_dai_ops {
 		struct snd_soc_dai *);
 	int (*trigger)(struct snd_pcm_substream *, int,
 		struct snd_soc_dai *);
+	/*
+	 * For hardware based FIFO caused delay reporting.
+	 * Optional.
+	 */
+	snd_pcm_sframes_t (*delay)(struct snd_pcm_substream *,
+		struct snd_soc_dai *);
 };
 
 /*
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index 6e35741..feaf03b 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -806,11 +806,26 @@ static snd_pcm_uframes_t soc_pcm_pointer(struct snd_pcm_substream *substream)
 	struct snd_soc_device *socdev = rtd->socdev;
 	struct snd_soc_card *card = socdev->card;
 	struct snd_soc_platform *platform = card->platform;
+	struct snd_soc_dai_link *machine = rtd->dai;
+	struct snd_soc_dai *cpu_dai = machine->cpu_dai;
+	struct snd_soc_dai *codec_dai = machine->codec_dai;
+	struct snd_pcm_runtime *runtime = substream->runtime;
 	snd_pcm_uframes_t offset = 0;
+	snd_pcm_sframes_t delay = 0;
 
 	if (platform->pcm_ops->pointer)
 		offset = platform->pcm_ops->pointer(substream);
 
+	/* Query the delay only for playback stream */
+	if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
+		if (cpu_dai->ops->delay)
+			delay += cpu_dai->ops->delay(substream, cpu_dai);
+
+		if (codec_dai->ops->delay)
+			delay += codec_dai->ops->delay(substream, codec_dai);
+
+		runtime->delay = delay;
+	}
 	return offset;
 }
 
-- 
1.7.0

  parent reply	other threads:[~2010-03-02 13:40 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-03-02 13:39 [RFC 0/4] FIFO caused playback delay (latency) handling in soc Peter Ujfalusi
2010-03-02 13:39 ` [RFC 1/4] ASoC: core: soc level wrapper for pcm_pointer callback Peter Ujfalusi
2010-03-02 13:39 ` Peter Ujfalusi [this message]
2010-03-02 13:45   ` [RFC 2/4] ASoC: core: Add delay operation to snd_soc_dai_ops Mark Brown
2010-03-02 13:49     ` Peter Ujfalusi
2010-03-02 13:54       ` Mark Brown
2010-03-02 13:39 ` [RFC 3/4] OMAP3: McBSP: Add interface for transmit FIFO state query Peter Ujfalusi
2010-03-02 13:45   ` Mark Brown
2010-03-02 13:52   ` Eero Nurkkala
2010-03-02 13:58     ` Liam Girdwood
2010-03-02 14:02     ` Peter Ujfalusi
2010-03-02 14:06     ` Jarkko Nikula
2010-03-03  6:07       ` Eero Nurkkala
2010-03-03  7:03         ` Jarkko Nikula
2010-03-03 10:02           ` Peter Ujfalusi
2010-03-03 10:07             ` Peter Ujfalusi
2010-03-03 14:18             ` Jarkko Nikula
2010-03-03 15:01               ` Peter Ujfalusi
2010-03-04  7:30                 ` Peter Ujfalusi
2010-03-03 19:00             ` ext-Eero.Nurkkala
2010-03-03 19:07               ` ext-Eero.Nurkkala
2010-03-04  7:53                 ` Peter Ujfalusi
2010-03-04  8:09               ` Peter Ujfalusi
2010-03-04  8:46                 ` Eero Nurkkala
2010-03-02 13:39 ` [RFC 4/4] ASoC: OMAP3: Report delay on playback caused by the internal FIFO Peter Ujfalusi
2010-03-02 13:47   ` Mark Brown
2010-03-02 13:52     ` Peter Ujfalusi
2010-03-02 14:06       ` Mark Brown
2010-03-02 13:53 ` [RFC 0/4] FIFO caused playback delay (latency) handling in soc Mark Brown
2010-03-02 23:29 ` Raymond Yau
2010-03-03 10:03   ` Mark Brown

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=1267537191-25254-3-git-send-email-peter.ujfalusi@nokia.com \
    --to=peter.ujfalusi@nokia.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@opensource.wolfsonmicro.com \
    --cc=lrg@slimlogic.co.uk \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).