Skip to content

Commit d4e91ad

Browse files
xdarklightbroonie
authored andcommitted
ASoC: soc-dai: add snd_soc_dai_prepare() and use it internally
Add a new snd_soc_dai_prepare() which can be used (in an upcoming patch) by soc-dapm.c. Use this new function internally in snd_soc_pcm_dai_prepare() to avoid duplicating code. Suggested-by: Jerome Brunet <[email protected]> Reviewed-by: Charles Keepax <[email protected]> Reviewed-by: Jerome Brunet <[email protected]> Signed-off-by: Martin Blumenstingl <[email protected]> Acked-by: Kuninori Morimoto <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent 6b07723 commit d4e91ad

File tree

2 files changed

+22
-8
lines changed

2 files changed

+22
-8
lines changed

include/sound/soc-dai.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,9 @@ int snd_soc_dai_set_channel_map(struct snd_soc_dai *dai,
193193

194194
int snd_soc_dai_set_tristate(struct snd_soc_dai *dai, int tristate);
195195

196+
int snd_soc_dai_prepare(struct snd_soc_dai *dai,
197+
struct snd_pcm_substream *substream);
198+
196199
/* Digital Audio Interface mute */
197200
int snd_soc_dai_digital_mute(struct snd_soc_dai *dai, int mute,
198201
int direction);

sound/soc/soc-dai.c

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -360,6 +360,22 @@ int snd_soc_dai_set_tristate(struct snd_soc_dai *dai, int tristate)
360360
}
361361
EXPORT_SYMBOL_GPL(snd_soc_dai_set_tristate);
362362

363+
int snd_soc_dai_prepare(struct snd_soc_dai *dai,
364+
struct snd_pcm_substream *substream)
365+
{
366+
int ret = 0;
367+
368+
if (!snd_soc_dai_stream_valid(dai, substream->stream))
369+
return 0;
370+
371+
if (dai->driver->ops &&
372+
dai->driver->ops->prepare)
373+
ret = dai->driver->ops->prepare(substream, dai);
374+
375+
return soc_dai_ret(dai, ret);
376+
}
377+
EXPORT_SYMBOL_GPL(snd_soc_dai_prepare);
378+
363379
/**
364380
* snd_soc_dai_digital_mute - configure DAI system or master clock.
365381
* @dai: DAI
@@ -577,14 +593,9 @@ int snd_soc_pcm_dai_prepare(struct snd_pcm_substream *substream)
577593
int i, ret;
578594

579595
for_each_rtd_dais(rtd, i, dai) {
580-
if (!snd_soc_dai_stream_valid(dai, substream->stream))
581-
continue;
582-
if (dai->driver->ops &&
583-
dai->driver->ops->prepare) {
584-
ret = dai->driver->ops->prepare(substream, dai);
585-
if (ret < 0)
586-
return soc_dai_ret(dai, ret);
587-
}
596+
ret = snd_soc_dai_prepare(dai, substream);
597+
if (ret < 0)
598+
return ret;
588599
}
589600

590601
return 0;

0 commit comments

Comments
 (0)