ASoC: Add delay information for Samsung IISv2 DAIs
authorMark Brown <broonie@opensource.wolfsonmicro.com>
Thu, 4 Mar 2010 14:54:40 +0000 (14:54 +0000)
committerMark Brown <broonie@opensource.wolfsonmicro.com>
Thu, 4 Mar 2010 14:57:09 +0000 (14:57 +0000)
Report the current FIFO depth when delay is queried. The FIFO is only
16 frames deep so the latency will be at most a couple of miliseconds
(and we tend to end up reporting zero most of the time) but it may
help some applications.

Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Acked-by: Liam Girdwood <lrg@slimlogic.co.uk>
sound/soc/s3c24xx/s3c-i2s-v2.c

index e994d8374fe62dc313aca6077e8bed20c5fb186f..aa84f4cb4d8acce0e7777ae2f217f3750c51ee43 100644 (file)
@@ -550,6 +550,21 @@ static int s3c2412_i2s_set_clkdiv(struct snd_soc_dai *cpu_dai,
        return 0;
 }
 
+static snd_pcm_sframes_t s3c2412_i2s_delay(struct snd_pcm_substream *substream,
+                                          struct snd_soc_dai *dai)
+{
+       struct s3c_i2sv2_info *i2s = to_info(dai);
+       u32 reg = readl(i2s->regs + S3C2412_IISFIC);
+       snd_pcm_sframes_t delay;
+
+       if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
+               delay = S3C2412_IISFIC_TXCOUNT(reg);
+       else
+               delay = S3C2412_IISFIC_RXCOUNT(reg);
+
+       return delay;
+}
+
 /* default table of all avaialable root fs divisors */
 static unsigned int iis_fs_tab[] = { 256, 512, 384, 768 };
 
@@ -736,6 +751,10 @@ int s3c_i2sv2_register_dai(struct snd_soc_dai *dai)
        ops->set_fmt = s3c2412_i2s_set_fmt;
        ops->set_clkdiv = s3c2412_i2s_set_clkdiv;
 
+       /* Allow overriding by (for example) IISv4 */
+       if (!ops->delay)
+               ops->delay = s3c2412_i2s_delay,
+
        dai->suspend = s3c2412_i2s_suspend;
        dai->resume = s3c2412_i2s_resume;