* [PATCH] ASoC: Allow mulitple usage count of codec and cpu dai
@ 2010-02-26 0:12 Jassi Brar
2010-02-26 9:17 ` Liam Girdwood
2010-02-26 11:20 ` Mark Brown
0 siblings, 2 replies; 3+ messages in thread
From: Jassi Brar @ 2010-02-26 0:12 UTC (permalink / raw)
To: alsa-devel; +Cc: broonie, Jassi Brar, lrg
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.
Signed-off-by: Jassi Brar <jassi.brar@samsung.com>
---
include/sound/soc.h | 2 +-
sound/soc/soc-core.c | 31 ++++++++++++++++++-------------
2 files changed, 19 insertions(+), 14 deletions(-)
diff --git a/include/sound/soc.h b/include/sound/soc.h
index 27a2ad9..f792c18 100644
--- a/include/sound/soc.h
+++ b/include/sound/soc.h
@@ -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 */
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index 2b66719..0211369 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -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
--
1.6.2.5
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] ASoC: Allow mulitple usage count of codec and cpu dai
2010-02-26 0:12 [PATCH] ASoC: Allow mulitple usage count of codec and cpu dai Jassi Brar
@ 2010-02-26 9:17 ` Liam Girdwood
2010-02-26 11:20 ` Mark Brown
1 sibling, 0 replies; 3+ messages in thread
From: Liam Girdwood @ 2010-02-26 9:17 UTC (permalink / raw)
To: Jassi Brar; +Cc: alsa-devel, broonie
On Fri, 2010-02-26 at 09:12 +0900, Jassi Brar wrote:
> 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.
>
> Signed-off-by: Jassi Brar <jassi.brar@samsung.com>
Acked-by: Liam Girdwood <lrg@slimlogic.co.uk>
--
Freelance Developer, SlimLogic Ltd
ASoC and Voltage Regulator Maintainer.
http://www.slimlogic.co.uk
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] ASoC: Allow mulitple usage count of codec and cpu dai
2010-02-26 0:12 [PATCH] ASoC: Allow mulitple usage count of codec and cpu dai Jassi Brar
2010-02-26 9:17 ` Liam Girdwood
@ 2010-02-26 11:20 ` Mark Brown
1 sibling, 0 replies; 3+ messages in thread
From: Mark Brown @ 2010-02-26 11:20 UTC (permalink / raw)
To: Jassi Brar; +Cc: alsa-devel, lrg
On Fri, Feb 26, 2010 at 09:12:32AM +0900, Jassi Brar wrote:
> 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.
>
> Signed-off-by: Jassi Brar <jassi.brar@samsung.com>
Applied, thanks.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2010-02-26 11:20 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-02-26 0:12 [PATCH] ASoC: Allow mulitple usage count of codec and cpu dai Jassi Brar
2010-02-26 9:17 ` Liam Girdwood
2010-02-26 11:20 ` Mark Brown
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).