Skip to content

Commit b56be80

Browse files
morimotobroonie
authored andcommitted
ASoC: soc-pcm: call snd_soc_dai_startup()/shutdown() once
Current soc_pcm_open() calls snd_soc_dai_startup() under loop. Thus, it needs to care about started/not-yet-started codec DAI. But, if soc-dai.c is handling it, soc-pcm.c don't need to care about it. This patch adds started flag to soc-dai.h, and simplify soc-pcm.c. This is one of prepare for cleanup soc-pcm-open() Signed-off-by: Kuninori Morimoto <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent e82ebff commit b56be80

File tree

3 files changed

+15
-8
lines changed

3 files changed

+15
-8
lines changed

include/sound/soc-dai.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,6 @@ struct snd_soc_dai {
324324
/* DAI runtime info */
325325
unsigned int capture_active; /* stream usage count */
326326
unsigned int playback_active; /* stream usage count */
327-
unsigned int probed:1;
328327

329328
unsigned int active;
330329

@@ -348,6 +347,10 @@ struct snd_soc_dai {
348347
unsigned int rx_mask;
349348

350349
struct list_head list;
350+
351+
/* bit field */
352+
unsigned int probed:1;
353+
unsigned int started:1;
351354
};
352355

353356
static inline void *snd_soc_dai_get_dma_data(const struct snd_soc_dai *dai,

sound/soc/soc-dai.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -295,17 +295,24 @@ int snd_soc_dai_startup(struct snd_soc_dai *dai,
295295
{
296296
int ret = 0;
297297

298-
if (dai->driver->ops->startup)
298+
if (!dai->started &&
299+
dai->driver->ops->startup)
299300
ret = dai->driver->ops->startup(substream, dai);
300301

302+
if (ret == 0)
303+
dai->started = 1;
304+
301305
return ret;
302306
}
303307

304308
void snd_soc_dai_shutdown(struct snd_soc_dai *dai,
305309
struct snd_pcm_substream *substream)
306310
{
307-
if (dai->driver->ops->shutdown)
311+
if (dai->started &&
312+
dai->driver->ops->shutdown)
308313
dai->driver->ops->shutdown(substream, dai);
314+
315+
dai->started = 0;
309316
}
310317

311318
int snd_soc_dai_prepare(struct snd_soc_dai *dai,

sound/soc/soc-pcm.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -568,7 +568,7 @@ static int soc_pcm_open(struct snd_pcm_substream *substream)
568568
if (ret < 0) {
569569
pr_err("ASoC: %s startup failed: %d\n",
570570
rtd->dai_link->name, ret);
571-
goto machine_err;
571+
goto codec_dai_err;
572572
}
573573

574574
/* Dynamic PCM DAI links compat checks use dynamic capabilities */
@@ -637,11 +637,8 @@ static int soc_pcm_open(struct snd_pcm_substream *substream)
637637
config_err:
638638
soc_rtd_shutdown(rtd, substream);
639639

640-
machine_err:
641-
i = rtd->num_codecs;
642-
643640
codec_dai_err:
644-
for_each_rtd_codec_dai_rollback(rtd, i, codec_dai)
641+
for_each_rtd_codec_dai(rtd, i, codec_dai)
645642
snd_soc_dai_shutdown(codec_dai, substream);
646643

647644
component_err:

0 commit comments

Comments
 (0)