alsa-devel.alsa-project.org archive mirror
 help / color / mirror / Atom feed
From: Vinod Koul <vinod.koul@linux.intel.com>
To: alsa-devel@alsa-project.org
Cc: tiwai@suse.de, Vinod Koul <vinod.koul@linux.intel.com>,
	broonie@opensource.wolfsonmicro.com, lrg@ti.com
Subject: [PATCH 2/3] ASoC: add device_buffer in asoc
Date: Fri, 31 Aug 2012 06:44:43 +0530	[thread overview]
Message-ID: <1346375684-4145-3-git-send-email-vinod.koul@linux.intel.com> (raw)
In-Reply-To: <1346375684-4145-1-git-send-email-vinod.koul@linux.intel.com>

This adds a new callback "buffer" in dai_ops and platform. The runtime->delay
is reported to sound core as sum of delay and buffer value. The buffer value is
also reported independently to pcm core for error checks

Signed-off-by: Vinod Koul <vinod.koul@linux.intel.com>
---
 include/sound/soc-dai.h |    6 ++++++
 include/sound/soc.h     |    6 ++++++
 sound/soc/soc-pcm.c     |   13 ++++++++++++-
 3 files changed, 24 insertions(+), 1 deletion(-)

diff --git a/include/sound/soc-dai.h b/include/sound/soc-dai.h
index 628db7b..b0c84df 100644
--- a/include/sound/soc-dai.h
+++ b/include/sound/soc-dai.h
@@ -182,6 +182,12 @@ struct snd_soc_dai_ops {
 	 */
 	snd_pcm_sframes_t (*delay)(struct snd_pcm_substream *,
 		struct snd_soc_dai *);
+	/*
+	 * For hardware based buffer reporting
+	 * Optional.
+	 */
+	snd_pcm_sframes_t (*buffer)(struct snd_pcm_substream *,
+		struct snd_soc_dai *);
 };
 
 /*
diff --git a/include/sound/soc.h b/include/sound/soc.h
index 313b766..f50bdf9 100644
--- a/include/sound/soc.h
+++ b/include/sound/soc.h
@@ -795,6 +795,12 @@ struct snd_soc_platform_driver {
 	 */
 	snd_pcm_sframes_t (*delay)(struct snd_pcm_substream *,
 		struct snd_soc_dai *);
+	/*
+	 * For hardware based buffer reporting
+	 * Optional.
+	 */
+	snd_pcm_sframes_t (*buffer)(struct snd_pcm_substream *,
+		struct snd_soc_dai *);
 
 	/* platform stream pcm ops */
 	struct snd_pcm_ops *ops;
diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c
index ef22d0b..605337f 100644
--- a/sound/soc/soc-pcm.c
+++ b/sound/soc/soc-pcm.c
@@ -674,6 +674,7 @@ static snd_pcm_uframes_t soc_pcm_pointer(struct snd_pcm_substream *substream)
 	struct snd_pcm_runtime *runtime = substream->runtime;
 	snd_pcm_uframes_t offset = 0;
 	snd_pcm_sframes_t delay = 0;
+	snd_pcm_sframes_t buffer = 0;
 
 	if (platform->driver->ops && platform->driver->ops->pointer)
 		offset = platform->driver->ops->pointer(substream);
@@ -687,7 +688,17 @@ static snd_pcm_uframes_t soc_pcm_pointer(struct snd_pcm_substream *substream)
 	if (platform->driver->delay)
 		delay += platform->driver->delay(substream, codec_dai);
 
-	runtime->delay = delay;
+	if (cpu_dai->driver->ops->buffer)
+		buffer += cpu_dai->driver->ops->buffer(substream, cpu_dai);
+
+	if (codec_dai->driver->ops->buffer)
+		buffer += codec_dai->driver->ops->buffer(substream, codec_dai);
+
+	if (platform->driver->buffer)
+		buffer += platform->driver->buffer(substream, codec_dai);
+
+	runtime->delay = delay + buffer;
+	runtime->device_buffer = buffer;
 
 	return offset;
 }
-- 
1.7.9.5

  parent reply	other threads:[~2012-08-31  1:09 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-08-31  1:14 [PATCH v3 0/3] introduce device_buffer Vinod Koul
2012-08-31  1:14 ` [PATCH 1/3] ALSA: pcm - " Vinod Koul
2012-08-31  2:06   ` Raymond Yau
2012-08-31 15:05     ` Vinod Koul
2012-08-31 10:48   ` Jaroslav Kysela
2012-08-31 15:02     ` Vinod Koul
2012-08-31  1:14 ` Vinod Koul [this message]
2012-08-31  1:14 ` [PATCH 3/3] ASoC: mid-x86 - implement buffer query in sst_platform driver Vinod Koul
2012-08-31 10:41 ` [PATCH v3 0/3] introduce device_buffer Jaroslav Kysela
2012-08-31 14:53   ` Vinod Koul
2012-09-04 14:24     ` Takashi Iwai
  -- strict thread matches above, loose matches on Subject: below --
2012-08-30 19:12 [PATCH " Vinod Koul
2012-08-30 19:12 ` [PATCH 2/3] ASoC: add device_buffer in asoc Vinod Koul

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=1346375684-4145-3-git-send-email-vinod.koul@linux.intel.com \
    --to=vinod.koul@linux.intel.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@opensource.wolfsonmicro.com \
    --cc=lrg@ti.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 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).