ASoC: soc-dai: add snd_soc_dai_delay()
authorKuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Mon, 22 Jul 2019 01:34:09 +0000 (10:34 +0900)
committerMark Brown <broonie@kernel.org>
Tue, 23 Jul 2019 17:14:20 +0000 (18:14 +0100)
Current ALSA SoC is directly using dai->driver->ops->xxx,
thus, it has deep nested bracket, and it makes code unreadable.
This patch adds new snd_soc_dai_delay() and use it.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/87o91mhn3i.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
include/sound/soc-dai.h
sound/soc/soc-dai.c
sound/soc/soc-pcm.c

index 6a5566d459adb24df0ffb0fcbde5f62fe7ab5372..7cfed3034511c45654d172d439c9c5a20d5e78cd 100644 (file)
@@ -160,6 +160,8 @@ int snd_soc_dai_trigger(struct snd_soc_dai *dai,
                        struct snd_pcm_substream *substream, int cmd);
 int snd_soc_dai_bespoke_trigger(struct snd_soc_dai *dai,
                        struct snd_pcm_substream *substream, int cmd);
+snd_pcm_sframes_t snd_soc_dai_delay(struct snd_soc_dai *dai,
+                                   struct snd_pcm_substream *substream);
 
 struct snd_soc_dai_ops {
        /*
index 6f466cfcbeefe751f25fe57752a2ec96047b645a..5b5b979cd1f35f536da14267a45abca1e7883512 100644 (file)
@@ -342,3 +342,14 @@ int snd_soc_dai_bespoke_trigger(struct snd_soc_dai *dai,
 
        return ret;
 }
+
+snd_pcm_sframes_t snd_soc_dai_delay(struct snd_soc_dai *dai,
+                                   struct snd_pcm_substream *substream)
+{
+       int delay = 0;
+
+       if (dai->driver->ops->delay)
+               delay = dai->driver->ops->delay(substream, dai);
+
+       return delay;
+}
index a10627f1ceff5e5f7e263352e085f6c6ed573ba1..f3137723301c8281da59c966e9e27bd441c01949 100644 (file)
@@ -1169,14 +1169,11 @@ static snd_pcm_uframes_t soc_pcm_pointer(struct snd_pcm_substream *substream)
        /* base delay if assigned in pointer callback */
        delay = runtime->delay;
 
-       if (cpu_dai->driver->ops->delay)
-               delay += cpu_dai->driver->ops->delay(substream, cpu_dai);
+       delay += snd_soc_dai_delay(cpu_dai, substream);
 
        for_each_rtd_codec_dai(rtd, i, codec_dai) {
-               if (codec_dai->driver->ops->delay)
-                       codec_delay = max(codec_delay,
-                                       codec_dai->driver->ops->delay(substream,
-                                                                   codec_dai));
+               codec_delay = max(codec_delay,
+                                 snd_soc_dai_delay(codec_dai, substream));
        }
        delay += codec_delay;