ASoC: Allow mulitple usage count of codec and cpu dai
PATCH 1/1 ASoC: Allow mulitple usage count of codec and cpu dai
If we are to have a snd_soc_dai i.e, cpu_dai and codec_dai, shared among two or more dai_links we need to log the number of active users of the dai. For that, we change semantics of the snd_soc_dai.active flag from indicator to reference counter.
--- include/sound/soc.h | 2 +- sound/soc/soc-core.c | 31 ++++++++++++++++++------------- 2 files changed, 19 insertions(+), 14 deletions(-)
include/sound/soc.h +1 -1
@@ -375,7 +375,7 @@ struct snd_soc_pcm_stream {unsigned int rate_max;/* max rate */ unsigned int channels_min;/* min channels */ unsigned int channels_max;/* max channels */ - unsigned int active:1; /* stream is in use */ +unsigned int active;/* num of active users of the stream */ };/* SoC audio ops */
sound/soc/soc-core.c +18 -13
@@ -454,11 +454,15 @@ static int soc_pcm_open(struct snd_pcm_substream *substream)pr_debug ("asoc: min rate %d max rate %d\n" , runtime->hw.rate_min, runtime->hw.rate_max); -if (substream->stream ==SNDRV_PCM_STREAM_PLAYBACK ) - cpu_dai->playback.active = codec_dai->playback.active =1 ; -else - cpu_dai->capture.active = codec_dai->capture.active =1 ; - cpu_dai->active = codec_dai->active =1 ; +if (substream->stream ==SNDRV_PCM_STREAM_PLAYBACK ) { + cpu_dai->playback.active++; + codec_dai->playback.active++; + }else { + cpu_dai->capture.active++; + codec_dai->capture.active++; + } + cpu_dai->active++; + codec_dai->active++; card->codec->active++;mutex_unlock (&pcm_mutex);return 0 ;
@@ -534,15 +538,16 @@ static int soc_codec_close(struct snd_pcm_substream *substream)mutex_lock (&pcm_mutex); -if (substream->stream ==SNDRV_PCM_STREAM_PLAYBACK ) - cpu_dai->playback.active = codec_dai->playback.active =0 ; -else - cpu_dai->capture.active = codec_dai->capture.active =0 ; - -if (codec_dai->playback.active ==0 && - codec_dai->capture.active ==0 ) { - cpu_dai->active = codec_dai->active =0 ; +if (substream->stream ==SNDRV_PCM_STREAM_PLAYBACK ) { + cpu_dai->playback.active--; + codec_dai->playback.active--; + }else { + cpu_dai->capture.active--; + codec_dai->capture.active--; } + + cpu_dai->active--; + codec_dai->active--; codec->active--;/* Muting the DAC suppresses artifacts caused during digital
Signature · 1 line
1.6.2.5
Quoted 6 lines · Jassi Brar
If we are to have a
snd_soc_daii.e,cpu_daiandcodec_dai, shared among two or moredai_linkswe need to log the number of active users of the dai. For that, we change semantics of the snd_soc_dai.active flag from indicator to reference counter.Signed-off-by Jassi Brar <[email protected]>
Signature · 3 lines
Freelance Developer, SlimLogic Ltd ASoC and Voltage Regulator Maintainer. http://www.slimlogic.co.uk
Mark Brown
AppliedQuoted 6 lines · Jassi Brar
If we are to have a
snd_soc_daii.e,cpu_daiandcodec_dai, shared among two or moredai_linkswe need to log the number of active users of the dai. For that, we change semantics of the snd_soc_dai.active flag from indicator to reference counter.Signed-off-by Jassi Brar <[email protected]>
Applied, thanks.