All of lore.kernel.org
 help / color / mirror / Atom feed
From: Peter Ujfalusi <peter.ujfalusi@nokia.com>
To: broonie@opensource.wolfsonmicro.com, tony@atomide.com
Cc: alsa-devel@alsa-project.org, linux-omap@vger.kernel.org,
	ext-eero.nurkkala@nokia.com, lrg@slimlogic.co.uk
Subject: [PATCHv2 5/5] ASoC: OMAP3: Report delay caused by the internal FIFO
Date: Wed,  3 Mar 2010 15:08:09 +0200	[thread overview]
Message-ID: <1267621689-30337-7-git-send-email-peter.ujfalusi@nokia.com> (raw)
In-Reply-To: <1267621689-30337-1-git-send-email-peter.ujfalusi@nokia.com>

Use the new delay calback function to report the delay through
ALSA for application caused by the internal FIFO.

Signed-off-by: Peter Ujfalusi <peter.ujfalusi@nokia.com>
---
 sound/soc/omap/omap-mcbsp.c |   26 ++++++++++++++++++++++++++
 1 files changed, 26 insertions(+), 0 deletions(-)

diff --git a/sound/soc/omap/omap-mcbsp.c b/sound/soc/omap/omap-mcbsp.c
index e814a95..2952fb0 100644
--- a/sound/soc/omap/omap-mcbsp.c
+++ b/sound/soc/omap/omap-mcbsp.c
@@ -256,6 +256,31 @@ static int omap_mcbsp_dai_trigger(struct snd_pcm_substream *substream, int cmd,
 	return err;
 }
 
+static snd_pcm_sframes_t omap_mcbsp_dai_delay(
+			struct snd_pcm_substream *substream,
+			struct snd_soc_dai *dai)
+{
+	struct snd_soc_pcm_runtime *rtd = substream->private_data;
+	struct snd_soc_dai *cpu_dai = rtd->dai->cpu_dai;
+	struct omap_mcbsp_data *mcbsp_data = to_mcbsp(cpu_dai->private_data);
+	u16 fifo_use;
+	snd_pcm_sframes_t delay;
+
+	if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
+		fifo_use = omap_mcbsp_get_tx_delay(mcbsp_data->bus_id);
+	else
+		fifo_use = omap_mcbsp_get_rx_delay(mcbsp_data->bus_id);
+
+	/*
+	 * Divide the used locations with the channel count to get the
+	 * FIFO usage in samples (don't care about partial samples in the
+	 * buffer).
+	 */
+	delay = fifo_use / substream->runtime->channels;
+
+	return delay;
+}
+
 static int omap_mcbsp_dai_hw_params(struct snd_pcm_substream *substream,
 				    struct snd_pcm_hw_params *params,
 				    struct snd_soc_dai *dai)
@@ -607,6 +632,7 @@ static struct snd_soc_dai_ops omap_mcbsp_dai_ops = {
 	.startup	= omap_mcbsp_dai_startup,
 	.shutdown	= omap_mcbsp_dai_shutdown,
 	.trigger	= omap_mcbsp_dai_trigger,
+	.delay		= omap_mcbsp_dai_delay,
 	.hw_params	= omap_mcbsp_dai_hw_params,
 	.set_fmt	= omap_mcbsp_dai_set_dai_fmt,
 	.set_clkdiv	= omap_mcbsp_dai_set_clkdiv,
-- 
1.7.0

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

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-03-03 13:08 [PATCHv2 0/5] FIFO caused playback delay (latency) handling in soc/omap Peter Ujfalusi
2010-03-03 13:08 ` [PATCHv2 1/5] ASoC: core: fix tailing whitespace in soc_pcm_apply_symmetry Peter Ujfalusi
2010-03-03 13:27   ` [alsa-devel] " Liam Girdwood
2010-03-03 13:08 ` [PATCH] OMAP3: PM: Enable wake-up from McBSP2, 3 and 4 modules Peter Ujfalusi
2010-03-03 14:08   ` Peter Ujfalusi
2010-03-03 14:46   ` Jarkko Nikula
2010-03-03 13:08 ` [PATCHv2 2/5] ASoC: core: soc level wrapper for pcm_pointer callback Peter Ujfalusi
2010-03-03 13:27   ` [alsa-devel] " Liam Girdwood
2010-03-03 13:08 ` [PATCHv2 3/5] ASoC: core: Add delay operation to snd_soc_dai_ops Peter Ujfalusi
2010-03-03 13:28   ` Liam Girdwood
2010-03-03 13:08 ` [PATCHv2 4/5] OMAP3: McBSP: Add interface for FIFO caused delay query Peter Ujfalusi
2010-03-03 14:38   ` Jarkko Nikula
2010-03-03 13:08 ` Peter Ujfalusi [this message]
2010-03-03 13:28   ` [PATCHv2 5/5] ASoC: OMAP3: Report delay caused by the internal FIFO Liam Girdwood
2010-03-03 14:30     ` Jarkko Nikula
2010-03-03 13:38 ` [PATCHv2 0/5] FIFO caused playback delay (latency) handling in soc/omap Mark Brown
2010-03-11 22:26   ` Tony Lindgren
2010-03-11 22:43     ` Mark Brown
2010-03-12  6:18       ` Peter Ujfalusi
2010-03-12  8:30         ` Jarkko Nikula
2010-03-12 11:12           ` 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=1267621689-30337-7-git-send-email-peter.ujfalusi@nokia.com \
    --to=peter.ujfalusi@nokia.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@opensource.wolfsonmicro.com \
    --cc=ext-eero.nurkkala@nokia.com \
    --cc=linux-omap@vger.kernel.org \
    --cc=lrg@slimlogic.co.uk \
    --cc=tony@atomide.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.