[alsa-devel] [PATCH v3 5/8] ASoC: soc-pcm: call snd_soc_dai_startup()/shutdown() once

Pierre-Louis Bossart pierre-louis.bossart at linux.intel.com
Fri Mar 27 19:38:18 CET 2020


>>   static inline void *snd_soc_dai_get_dma_data(const struct 
>> snd_soc_dai *dai,
>> diff --git a/sound/soc/soc-dai.c b/sound/soc/soc-dai.c
>> index 51031e33..73a8293 100644
>> --- a/sound/soc/soc-dai.c
>> +++ b/sound/soc/soc-dai.c
>> @@ -295,17 +295,24 @@ int snd_soc_dai_startup(struct snd_soc_dai *dai,
>>   {
>>       int ret = 0;
>> -    if (dai->driver->ops->startup)
>> +    if (!dai->started &&
>> +        dai->driver->ops->startup)
>>           ret = dai->driver->ops->startup(substream, dai);
>> +    if (ret == 0)
>> +        dai->started = 1;
>> +
>>       return ret;
>>   }
> 
> Hi,
> 
> the above change breaks simultaneous playback and capture on single DAI 
> in more complicated use cases. With above change when one runs playback 
> first, startup callback is skipped when running capture while playback 
> is still running.

Should the 'started' bitfield should be an array for capture and 
playback cases respectively? e.g.

diff --git a/include/sound/soc-dai.h b/include/sound/soc-dai.h
index 78bac995db15..d4825b82c7a3 100644
--- a/include/sound/soc-dai.h
+++ b/include/sound/soc-dai.h
@@ -351,7 +351,7 @@ struct snd_soc_dai {

         /* bit field */
         unsigned int probed:1;
-       unsigned int started:1;
+       unsigned int started[SNDRV_PCM_STREAM_LAST + 1];
  };

  static inline struct snd_soc_pcm_stream *
diff --git a/sound/soc/soc-dai.c b/sound/soc/soc-dai.c
index 19142f6e533c..8f3cad8db89a 100644
--- a/sound/soc/soc-dai.c
+++ b/sound/soc/soc-dai.c
@@ -295,12 +295,12 @@ int snd_soc_dai_startup(struct snd_soc_dai *dai,
  {
         int ret = 0;

-       if (!dai->started &&
+       if (!dai->started[substream->stream] &&
             dai->driver->ops->startup)
                 ret = dai->driver->ops->startup(substream, dai);

         if (ret == 0)
-               dai->started = 1;
+               dai->started[substream->stream] = 1;

         return ret;
  }
@@ -308,11 +308,11 @@ int snd_soc_dai_startup(struct snd_soc_dai *dai,
  void snd_soc_dai_shutdown(struct snd_soc_dai *dai,
                          struct snd_pcm_substream *substream)
  {
-       if (dai->started &&
+       if (dai->started[substream->stream] &&
             dai->driver->ops->shutdown)
                 dai->driver->ops->shutdown(substream, dai);

-       dai->started = 0;
+       dai->started[substream->stream] = 0;
  }

  int snd_soc_dai_prepare(struct snd_soc_dai *dai,


More information about the Alsa-devel mailing list