Message ID | 874ksn9fqf.wl-kuninori.morimoto.gx@renesas.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | ASoC: cleanup DAI/Component activity | expand |
On Mon, 2020-05-11 at 14:56 +0900, Kuninori Morimoto wrote: > From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> > > Current snd_soc_runtime_action() is counting > dai->stream_active for Playback/Capture, > dai->active for DAI > > static void snd_soc_runtime_action(...) > { > ... > for_each_rtd_dais(rtd, i, dai) { > dai->stream_active[stream] += action; > dai->active += action; > ... > } > } > > But, these are very verbose, because we can calculate > DAI activity from stream_activity. > > This patch adds snd_soc_dai_activity() which calculate > DAI activity from DAI stream_activity. > > Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> > --- > include/sound/soc-dai.h | 2 +- > sound/soc/soc-dai.c | 12 ++++++++++++ > 2 files changed, 13 insertions(+), 1 deletion(-) > > diff --git a/include/sound/soc-dai.h b/include/sound/soc-dai.h > index 2a0a5af1c1ae..887575d59e31 100644 > --- a/include/sound/soc-dai.h > +++ b/include/sound/soc-dai.h > @@ -137,7 +137,7 @@ int snd_soc_dai_set_tristate(struct snd_soc_dai > *dai, int tristate); > /* Digital Audio Interface mute */ > int snd_soc_dai_digital_mute(struct snd_soc_dai *dai, int mute, > int direction); > - > +int snd_soc_dai_activity(struct snd_soc_dai *dai); > > int snd_soc_dai_get_channel_map(struct snd_soc_dai *dai, > unsigned int *tx_num, unsigned int *tx_slot, > diff --git a/sound/soc/soc-dai.c b/sound/soc/soc-dai.c > index 8e5fe012aa1d..aa0826136f57 100644 > --- a/sound/soc/soc-dai.c > +++ b/sound/soc/soc-dai.c > @@ -305,6 +305,18 @@ int snd_soc_dai_digital_mute(struct snd_soc_dai > *dai, int mute, > } > EXPORT_SYMBOL_GPL(snd_soc_dai_digital_mute); > > +int snd_soc_dai_activity(struct snd_soc_dai *dai) I think snd_soc_dai_active() is a better name than activity. Thanks, Ranjani
On Mon, 2020-05-11 at 14:56 +0900, Kuninori Morimoto wrote: > From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> > > Current snd_soc_runtime_action() is counting > dai->stream_active for Playback/Capture, > dai->active for DAI > > static void snd_soc_runtime_action(...) > { > ... > for_each_rtd_dais(rtd, i, dai) { > dai->stream_active[stream] += action; > dai->active += action; > ... > } > } > > But, these are very verbose, because we can calculate > DAI activity from stream_activity. > > This patch adds snd_soc_dai_activity() which calculate > DAI activity from DAI stream_activity. > > Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> > --- > include/sound/soc-dai.h | 2 +- > sound/soc/soc-dai.c | 12 ++++++++++++ > 2 files changed, 13 insertions(+), 1 deletion(-) > > diff --git a/include/sound/soc-dai.h b/include/sound/soc-dai.h > index 2a0a5af1c1ae..887575d59e31 100644 > --- a/include/sound/soc-dai.h > +++ b/include/sound/soc-dai.h > @@ -137,7 +137,7 @@ int snd_soc_dai_set_tristate(struct snd_soc_dai > *dai, int tristate); > /* Digital Audio Interface mute */ > int snd_soc_dai_digital_mute(struct snd_soc_dai *dai, int mute, > int direction); > - > +int snd_soc_dai_activity(struct snd_soc_dai *dai); > > int snd_soc_dai_get_channel_map(struct snd_soc_dai *dai, > unsigned int *tx_num, unsigned int *tx_slot, > diff --git a/sound/soc/soc-dai.c b/sound/soc/soc-dai.c > index 8e5fe012aa1d..aa0826136f57 100644 > --- a/sound/soc/soc-dai.c > +++ b/sound/soc/soc-dai.c > @@ -305,6 +305,18 @@ int snd_soc_dai_digital_mute(struct snd_soc_dai > *dai, int mute, > } > EXPORT_SYMBOL_GPL(snd_soc_dai_digital_mute); > > +int snd_soc_dai_activity(struct snd_soc_dai *dai) > +{ > + int stream, active; > + > + active = 0; > + for_each_pcm_streams(stream) > + active += dai->stream_active[stream]; Morimoto-san, snd_soc_dai has both stream_active and active. In this function, you're checking stream_active. Do you think, snd_soc_dai_stream_usage_count() makes for a better name? Thanks, Ranjani > + > + return active; > +} > +EXPORT_SYMBOL_GPL(snd_soc_dai_activity); > + > int snd_soc_dai_hw_params(struct snd_soc_dai *dai, > struct snd_pcm_substream *substream, > struct snd_pcm_hw_params *params)
diff --git a/include/sound/soc-dai.h b/include/sound/soc-dai.h index 2a0a5af1c1ae..887575d59e31 100644 --- a/include/sound/soc-dai.h +++ b/include/sound/soc-dai.h @@ -137,7 +137,7 @@ int snd_soc_dai_set_tristate(struct snd_soc_dai *dai, int tristate); /* Digital Audio Interface mute */ int snd_soc_dai_digital_mute(struct snd_soc_dai *dai, int mute, int direction); - +int snd_soc_dai_activity(struct snd_soc_dai *dai); int snd_soc_dai_get_channel_map(struct snd_soc_dai *dai, unsigned int *tx_num, unsigned int *tx_slot, diff --git a/sound/soc/soc-dai.c b/sound/soc/soc-dai.c index 8e5fe012aa1d..aa0826136f57 100644 --- a/sound/soc/soc-dai.c +++ b/sound/soc/soc-dai.c @@ -305,6 +305,18 @@ int snd_soc_dai_digital_mute(struct snd_soc_dai *dai, int mute, } EXPORT_SYMBOL_GPL(snd_soc_dai_digital_mute); +int snd_soc_dai_activity(struct snd_soc_dai *dai) +{ + int stream, active; + + active = 0; + for_each_pcm_streams(stream) + active += dai->stream_active[stream]; + + return active; +} +EXPORT_SYMBOL_GPL(snd_soc_dai_activity); + int snd_soc_dai_hw_params(struct snd_soc_dai *dai, struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params)