diff mbox series

[17/17] ASoC: soc-dai: add snd_soc_dai_stream_activity()

Message ID 87h7wn813q.wl-kuninori.morimoto.gx@renesas.com
State New
Headers show
Series [01/17] ASoC: soc-dai: add snd_soc_dai_activity() | expand

Commit Message

Kuninori Morimoto May 11, 2020, 5:58 a.m. UTC
From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

We can use DAI activity by snd_soc_dai_activity(),
and  Component activity by snd_soc_component_activity().
But, is directly using dai->stream_activity.
This patch adds snd_soc_dai_stream_activity(), and is able to
apply after snd_soc_dai_activity() / snd_soc_component_activity() patches.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 include/sound/soc-dai.h   |  1 +
 sound/soc/codecs/cs4271.c |  4 ++--
 sound/soc/dwc/dwc-i2s.c   |  2 +-
 sound/soc/soc-core.c      |  7 ++++---
 sound/soc/soc-dai.c       |  2 +-
 sound/soc/soc-dapm.c      |  8 ++++----
 sound/soc/soc-pcm.c       | 19 ++++++++++---------
 7 files changed, 23 insertions(+), 20 deletions(-)
diff mbox series

Patch

diff --git a/include/sound/soc-dai.h b/include/sound/soc-dai.h
index 502aaeb561a0..e7cb6c90d217 100644
--- a/include/sound/soc-dai.h
+++ b/include/sound/soc-dai.h
@@ -138,6 +138,7 @@  int snd_soc_dai_set_tristate(struct snd_soc_dai *dai, int tristate);
 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);
+#define snd_soc_dai_stream_activity(dai, stream) (dai)->stream_active[stream]
 
 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/codecs/cs4271.c b/sound/soc/codecs/cs4271.c
index 62f412d6f9f2..2ef92a11db5f 100644
--- a/sound/soc/codecs/cs4271.c
+++ b/sound/soc/codecs/cs4271.c
@@ -356,9 +356,9 @@  static int cs4271_hw_params(struct snd_pcm_substream *substream,
 		 */
 
 		if ((substream->stream == SNDRV_PCM_STREAM_PLAYBACK &&
-		     !dai->stream_active[SNDRV_PCM_STREAM_CAPTURE]) ||
+		     !snd_soc_dai_stream_activity(dai, SNDRV_PCM_STREAM_CAPTURE)) ||
 		    (substream->stream == SNDRV_PCM_STREAM_CAPTURE &&
-		     !dai->stream_active[SNDRV_PCM_STREAM_PLAYBACK])) {
+		     !snd_soc_dai_stream_activity(dai, SNDRV_PCM_STREAM_PLAYBACK])) {
 			ret = regmap_update_bits(cs4271->regmap, CS4271_MODE2,
 						 CS4271_MODE2_PDN,
 						 CS4271_MODE2_PDN);
diff --git a/sound/soc/dwc/dwc-i2s.c b/sound/soc/dwc/dwc-i2s.c
index 515f88456dbd..c2a58246a7c4 100644
--- a/sound/soc/dwc/dwc-i2s.c
+++ b/sound/soc/dwc/dwc-i2s.c
@@ -429,7 +429,7 @@  static int dw_i2s_resume(struct snd_soc_component *component)
 
 	for_each_component_dais(component, dai) {
 		for_each_pcm_streams(stream)
-			if (dai->stream_active[stream])
+			if (snd_soc_dai_stream_activity(dai, stream))
 				dw_i2s_config(dev, stream);
 	}
 
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index 2cd88b9e8151..9661019949fb 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -372,7 +372,8 @@  void snd_soc_close_delayed_work(struct snd_soc_pcm_runtime *rtd)
 	dev_dbg(rtd->dev,
 		"ASoC: pop wq checking: %s status: %s waiting: %s\n",
 		codec_dai->driver->playback.stream_name,
-		codec_dai->stream_active[playback] ? "active" : "inactive",
+		snd_soc_dai_stream_activity(codec_dai, playback) ?
+		"active" : "inactive",
 		rtd->pop_wait ? "yes" : "no");
 
 	/* are we waiting on this codec DAI stream */
@@ -546,7 +547,7 @@  int snd_soc_suspend(struct device *dev)
 			continue;
 
 		for_each_rtd_codec_dais(rtd, i, dai) {
-			if (dai->stream_active[playback])
+			if (snd_soc_dai_stream_activity(dai, playback))
 				snd_soc_dai_digital_mute(dai, 1, playback);
 		}
 	}
@@ -688,7 +689,7 @@  static void soc_resume_deferred(struct work_struct *work)
 			continue;
 
 		for_each_rtd_codec_dais(rtd, i, dai) {
-			if (dai->stream_active[playback])
+			if (snd_soc_dai_stream_activity(dai, playback))
 				snd_soc_dai_digital_mute(dai, 0, playback);
 		}
 	}
diff --git a/sound/soc/soc-dai.c b/sound/soc/soc-dai.c
index aa0826136f57..f09b6d3a66af 100644
--- a/sound/soc/soc-dai.c
+++ b/sound/soc/soc-dai.c
@@ -311,7 +311,7 @@  int snd_soc_dai_activity(struct snd_soc_dai *dai)
 
 	active = 0;
 	for_each_pcm_streams(stream)
-		active += dai->stream_active[stream];
+		active += snd_soc_dai_stream_activity(dai, stream);
 
 	return active;
 }
diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c
index 94134878b320..5ecf57356bd8 100644
--- a/sound/soc/soc-dapm.c
+++ b/sound/soc/soc-dapm.c
@@ -3835,7 +3835,7 @@  snd_soc_dai_link_event_pre_pmu(struct snd_soc_dapm_widget *w,
 				"ASoC: startup() failed: %d\n", ret);
 			goto out;
 		}
-		source->stream_active[substream->stream]++;
+		snd_soc_dai_stream_activity(source, substream->stream)++;
 	}
 
 	substream->stream = SNDRV_PCM_STREAM_PLAYBACK;
@@ -3848,7 +3848,7 @@  snd_soc_dai_link_event_pre_pmu(struct snd_soc_dapm_widget *w,
 				"ASoC: startup() failed: %d\n", ret);
 			goto out;
 		}
-		sink->stream_active[substream->stream]++;
+		snd_soc_dai_stream_activity(sink, substream->stream)++;
 	}
 
 	substream->hw_opened = 1;
@@ -3978,14 +3978,14 @@  static int snd_soc_dai_link_event(struct snd_soc_dapm_widget *w,
 		substream->stream = SNDRV_PCM_STREAM_CAPTURE;
 		snd_soc_dapm_widget_for_each_source_path(w, path) {
 			source = path->source->priv;
-			source->stream_active[substream->stream]--;
+			snd_soc_dai_stream_activity(source, substream->stream)--;
 			snd_soc_dai_shutdown(source, substream);
 		}
 
 		substream->stream = SNDRV_PCM_STREAM_PLAYBACK;
 		snd_soc_dapm_widget_for_each_sink_path(w, path) {
 			sink = path->sink->priv;
-			sink->stream_active[substream->stream]--;
+			snd_soc_dai_stream_activity(sink, substream->stream)--;
 			snd_soc_dai_shutdown(sink, substream);
 		}
 		break;
diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c
index 0eae9ab2a2ea..61223aec5e85 100644
--- a/sound/soc/soc-pcm.c
+++ b/sound/soc/soc-pcm.c
@@ -265,7 +265,7 @@  static void snd_soc_runtime_action(struct snd_soc_pcm_runtime *rtd,
 	lockdep_assert_held(&rtd->card->pcm_mutex);
 
 	for_each_rtd_dais(rtd, i, dai) {
-		dai->stream_active[stream] += action;
+		snd_soc_dai_stream_activity(dai, stream) += action;
 		snd_soc_component_activity(dai->component) += action;
 	}
 }
@@ -1157,15 +1157,13 @@  static int soc_pcm_hw_free(struct snd_pcm_substream *substream)
 
 	/* clear the corresponding DAIs parameters when going to be inactive */
 	for_each_rtd_dais(rtd, i, dai) {
-		int active = dai->stream_active[substream->stream];
-
 		if (snd_soc_dai_activity(dai) == 1) {
 			dai->rate = 0;
 			dai->channels = 0;
 			dai->sample_bits = 0;
 		}
 
-		if (active == 1)
+		if (snd_soc_dai_stream_activity(dai, substream->stream) == 1)
 			snd_soc_dai_digital_mute(dai, 1, substream->stream);
 	}
 
@@ -2716,6 +2714,8 @@  static int dpcm_run_update_startup(struct snd_soc_pcm_runtime *fe, int stream)
 static int soc_dpcm_fe_runtime_update(struct snd_soc_pcm_runtime *fe, int new)
 {
 	struct snd_soc_dapm_widget_list *list;
+	struct snd_soc_dai *cpu_dai = asoc_rtd_to_cpu(fe, 0);
+	struct snd_soc_dai *codec_dai = asoc_rtd_to_codec(fe, 0);
 	int stream;
 	int count, paths;
 	int ret;
@@ -2730,7 +2730,7 @@  static int soc_dpcm_fe_runtime_update(struct snd_soc_pcm_runtime *fe, int new)
 		return 0;
 
 	/* only check active links */
-	if (!snd_soc_dai_activity(asoc_rtd_to_cpu(fe, 0)))
+	if (!snd_soc_dai_activity(cpu_dai))
 		return 0;
 
 	/* DAPM sync will call this to update DSP paths */
@@ -2740,13 +2740,14 @@  static int soc_dpcm_fe_runtime_update(struct snd_soc_pcm_runtime *fe, int new)
 	for_each_pcm_streams(stream) {
 
 		/* skip if FE doesn't have playback/capture capability */
-		if (!snd_soc_dai_stream_valid(asoc_rtd_to_cpu(fe, 0),   stream) ||
-		    !snd_soc_dai_stream_valid(asoc_rtd_to_codec(fe, 0), stream))
+		if (!snd_soc_dai_stream_valid(cpu_dai,   stream) ||
+		    !snd_soc_dai_stream_valid(codec_dai, stream))
 			continue;
 
 		/* skip if FE isn't currently playing/capturing */
-		if (!asoc_rtd_to_cpu(fe, 0)->stream_active[stream] ||
-		    !asoc_rtd_to_codec(fe, 0)->stream_active[stream])
+		/* skip if FE isn't currently playing/capturing */
+		if (!snd_soc_dai_stream_activity(cpu_dai,   stream) ||
+		    !snd_soc_dai_stream_activity(codec_dai, stream))
 			continue;
 
 		paths = dpcm_path_get(fe, stream, &list);