Commit 1dea80d4 authored by Kuninori Morimoto's avatar Kuninori Morimoto Committed by Mark Brown

ASoC: soc-dai: add snd_soc_dai_delay()

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: default avatarKuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/87o91mhn3i.wl-kuninori.morimoto.gx@renesas.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent 5c0769af
...@@ -160,6 +160,8 @@ int snd_soc_dai_trigger(struct snd_soc_dai *dai, ...@@ -160,6 +160,8 @@ int snd_soc_dai_trigger(struct snd_soc_dai *dai,
struct snd_pcm_substream *substream, int cmd); struct snd_pcm_substream *substream, int cmd);
int snd_soc_dai_bespoke_trigger(struct snd_soc_dai *dai, int snd_soc_dai_bespoke_trigger(struct snd_soc_dai *dai,
struct snd_pcm_substream *substream, int cmd); 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 { struct snd_soc_dai_ops {
/* /*
......
...@@ -342,3 +342,14 @@ int snd_soc_dai_bespoke_trigger(struct snd_soc_dai *dai, ...@@ -342,3 +342,14 @@ int snd_soc_dai_bespoke_trigger(struct snd_soc_dai *dai,
return ret; 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;
}
...@@ -1169,14 +1169,11 @@ static snd_pcm_uframes_t soc_pcm_pointer(struct snd_pcm_substream *substream) ...@@ -1169,14 +1169,11 @@ static snd_pcm_uframes_t soc_pcm_pointer(struct snd_pcm_substream *substream)
/* base delay if assigned in pointer callback */ /* base delay if assigned in pointer callback */
delay = runtime->delay; delay = runtime->delay;
if (cpu_dai->driver->ops->delay) delay += snd_soc_dai_delay(cpu_dai, substream);
delay += cpu_dai->driver->ops->delay(substream, cpu_dai);
for_each_rtd_codec_dai(rtd, i, codec_dai) { for_each_rtd_codec_dai(rtd, i, codec_dai) {
if (codec_dai->driver->ops->delay) codec_delay = max(codec_delay,
codec_delay = max(codec_delay, snd_soc_dai_delay(codec_dai, substream));
codec_dai->driver->ops->delay(substream,
codec_dai));
} }
delay += codec_delay; delay += codec_delay;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment