All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 00/17] ASoC: cleanup DAI/Component activity
@ 2020-05-11  5:55 Kuninori Morimoto
  2020-05-11  5:56 ` [PATCH 01/17] ASoC: soc-dai: add snd_soc_dai_activity() Kuninori Morimoto
                   ` (16 more replies)
  0 siblings, 17 replies; 28+ messages in thread
From: Kuninori Morimoto @ 2020-05-11  5:55 UTC (permalink / raw)
  To: Mark Brown; +Cc: Linux-ALSA


Hi Mark

This patch-set cleanups DAI/Component activity operation.
I believe these works correctly, but maybe need some tests
or deep review.
[17/17] patch can be apply after [03/17] patch.

Kuninori Morimoto (17):
   1 ASoC: soc-dai: add snd_soc_dai_activity()
   2 ASoC: use snd_soc_dai/component_activity()
   3 ASoC: soc-dai: add snd_soc_component_activity()
   4 ASoC: atomel: use snd_soc_dai/component_activity()
   5 ASoC: bcm: use snd_soc_dai/component_activity()
   6 ASoC: cirrus: use snd_soc_dai/component_activity()
   7 ASoC: codecs: use snd_soc_dai/component_activity()
   8 ASoC: fsl: use snd_soc_dai/component_activity()
   9 ASoC: intel: use snd_soc_dai/component_activity()
  10 ASoC: jz4740: use snd_soc_dai/component_activity()
  11 ASoC: mediatek: use snd_soc_dai/component_activity()
  12 ASoC: meson: use snd_soc_dai/component_activity()
  13 ASoC: pxa: use snd_soc_dai/component_activity()
  14 ASoC: ti: use snd_soc_dai/component_activity()
  15 ASoC: uniphier: use snd_soc_dai/component_activity()
  16 ASoC: cleanup dai / component active code
  17 ASoC: soc-dai: add snd_soc_dai_stream_activity()

 include/sound/soc-component.h                |  7 +---
 include/sound/soc-dai.h                      |  5 ++-
 sound/soc/atmel/atmel_ssc_dai.c              |  4 +--
 sound/soc/bcm/bcm2835-i2s.c                  |  6 ++--
 sound/soc/bcm/cygnus-ssp.c                   |  4 +--
 sound/soc/cirrus/ep93xx-i2s.c                |  4 +--
 sound/soc/codecs/adav80x.c                   |  4 +--
 sound/soc/codecs/arizona.c                   |  2 +-
 sound/soc/codecs/cs4271.c                    |  4 +--
 sound/soc/codecs/madera.c                    |  2 +-
 sound/soc/codecs/max98090.c                  |  6 ++--
 sound/soc/codecs/tlv320aic23.c               |  2 +-
 sound/soc/codecs/tlv320dac33.c               |  2 +-
 sound/soc/codecs/uda1380.c                   |  2 +-
 sound/soc/codecs/wl1273.c                    |  2 +-
 sound/soc/codecs/wm8711.c                    |  2 +-
 sound/soc/codecs/wm8753.c                    |  4 +--
 sound/soc/dwc/dwc-i2s.c                      |  2 +-
 sound/soc/fsl/fsl_esai.c                     |  2 +-
 sound/soc/fsl/fsl_spdif.c                    |  4 +--
 sound/soc/intel/atom/sst-mfld-platform-pcm.c | 14 ++++----
 sound/soc/jz4740/jz4740-i2s.c                |  8 ++---
 sound/soc/mediatek/mt8173/mt8173-afe-pcm.c   |  8 ++---
 sound/soc/meson/axg-tdm-interface.c          |  2 +-
 sound/soc/pxa/pxa-ssp.c                      |  8 ++---
 sound/soc/pxa/pxa2xx-i2s.c                   |  2 +-
 sound/soc/soc-compress.c                     |  4 +--
 sound/soc/soc-core.c                         | 11 ++++---
 sound/soc/soc-dai.c                          | 12 +++++++
 sound/soc/soc-dapm.c                         |  8 ++---
 sound/soc/soc-pcm.c                          | 34 ++++++++++----------
 sound/soc/ti/davinci-mcasp.c                 |  2 +-
 sound/soc/ti/omap-dmic.c                     |  4 +--
 sound/soc/ti/omap-mcbsp.c                    |  4 +--
 sound/soc/ti/omap-mcpdm.c                    |  8 ++---
 sound/soc/uniphier/aio-cpu.c                 |  4 +--
 36 files changed, 105 insertions(+), 98 deletions(-)

-- 
2.17.1


^ permalink raw reply	[flat|nested] 28+ messages in thread

* [PATCH 01/17] ASoC: soc-dai: add snd_soc_dai_activity()
  2020-05-11  5:55 [PATCH 00/17] ASoC: cleanup DAI/Component activity Kuninori Morimoto
@ 2020-05-11  5:56 ` Kuninori Morimoto
  2020-05-11 22:37   ` Ranjani Sridharan
  2020-05-11 22:42   ` Ranjani Sridharan
  2020-05-11  5:56 ` [PATCH 02/17] ASoC: use snd_soc_dai/component_activity() Kuninori Morimoto
                   ` (15 subsequent siblings)
  16 siblings, 2 replies; 28+ messages in thread
From: Kuninori Morimoto @ 2020-05-11  5:56 UTC (permalink / raw)
  To: Mark Brown; +Cc: Linux-ALSA


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];
+
+	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)
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [PATCH 02/17] ASoC: use snd_soc_dai/component_activity()
  2020-05-11  5:55 [PATCH 00/17] ASoC: cleanup DAI/Component activity Kuninori Morimoto
  2020-05-11  5:56 ` [PATCH 01/17] ASoC: soc-dai: add snd_soc_dai_activity() Kuninori Morimoto
@ 2020-05-11  5:56 ` Kuninori Morimoto
  2020-05-11 22:44   ` Ranjani Sridharan
  2020-05-11  5:56 ` [PATCH 03/17] ASoC: soc-dai: add snd_soc_component_activity() Kuninori Morimoto
                   ` (14 subsequent siblings)
  16 siblings, 1 reply; 28+ messages in thread
From: Kuninori Morimoto @ 2020-05-11  5:56 UTC (permalink / raw)
  To: Mark Brown; +Cc: Linux-ALSA


From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 sound/soc/soc-compress.c |  4 ++--
 sound/soc/soc-core.c     |  4 ++--
 sound/soc/soc-dapm.c     |  8 ++++----
 sound/soc/soc-pcm.c      | 14 +++++++-------
 4 files changed, 15 insertions(+), 15 deletions(-)

diff --git a/sound/soc/soc-compress.c b/sound/soc/soc-compress.c
index def3ae78b4a7..92d70e75a5a4 100644
--- a/sound/soc/soc-compress.c
+++ b/sound/soc/soc-compress.c
@@ -231,10 +231,10 @@ static int soc_compr_free(struct snd_compr_stream *cstream)
 
 	snd_soc_dai_digital_mute(codec_dai, 1, cstream->direction);
 
-	if (!cpu_dai->active)
+	if (!snd_soc_dai_activity(cpu_dai))
 		cpu_dai->rate = 0;
 
-	if (!codec_dai->active)
+	if (!snd_soc_dai_activity(codec_dai))
 		codec_dai->rate = 0;
 
 	if (rtd->dai_link->compr_ops && rtd->dai_link->compr_ops->shutdown)
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index 95d8189e45ab..2cd88b9e8151 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -718,7 +718,7 @@ int snd_soc_resume(struct device *dev)
 
 	/* activate pins from sleep state */
 	for_each_card_components(card, component)
-		if (component->active)
+		if (snd_soc_component_activity(component))
 			pinctrl_pm_select_default_state(component->dev);
 
 	dev_dbg(dev, "ASoC: Scheduling resume work\n");
@@ -1943,7 +1943,7 @@ static int snd_soc_bind_card(struct snd_soc_card *card)
 
 	/* deactivate pins to sleep state */
 	for_each_card_components(card, component)
-		if (!component->active)
+		if (!snd_soc_component_activity(component))
 			pinctrl_pm_select_sleep_state(component->dev);
 
 probe_end:
diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c
index 80658d13a855..94134878b320 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->active++;
+		source->stream_active[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->active++;
+		sink->stream_active[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->active--;
+			source->stream_active[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->active--;
+			sink->stream_active[substream->stream]--;
 			snd_soc_dai_shutdown(sink, substream);
 		}
 		break;
diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c
index 440c7e87829a..e923e3746fec 100644
--- a/sound/soc/soc-pcm.c
+++ b/sound/soc/soc-pcm.c
@@ -772,7 +772,7 @@ static int soc_pcm_close(struct snd_pcm_substream *substream)
 	}
 
 	for_each_rtd_components(rtd, i, component)
-		if (!component->active)
+		if (!snd_soc_component_activity(component))
 			pinctrl_pm_select_sleep_state(component->dev);
 
 	return 0;
@@ -866,7 +866,7 @@ static int soc_pcm_open(struct snd_pcm_substream *substream)
 
 	/* Symmetry only applies if we've already got an active stream. */
 	for_each_rtd_dais(rtd, i, dai) {
-		if (dai->active) {
+		if (snd_soc_dai_activity(dai)) {
 			ret = soc_pcm_apply_symmetry(substream, dai);
 			if (ret != 0)
 				goto config_err;
@@ -904,7 +904,7 @@ static int soc_pcm_open(struct snd_pcm_substream *substream)
 	}
 
 	for_each_rtd_components(rtd, i, component)
-		if (!component->active)
+		if (!snd_soc_component_activity(component))
 			pinctrl_pm_select_sleep_state(component->dev);
 
 	return ret;
@@ -1160,7 +1160,7 @@ static int soc_pcm_hw_free(struct snd_pcm_substream *substream)
 	for_each_rtd_dais(rtd, i, dai) {
 		int active = dai->stream_active[substream->stream];
 
-		if (dai->active == 1) {
+		if (snd_soc_dai_activity(dai) == 1) {
 			dai->rate = 0;
 			dai->channels = 0;
 			dai->sample_bits = 0;
@@ -1929,7 +1929,7 @@ static int dpcm_apply_symmetry(struct snd_pcm_substream *fe_substream,
 
 	for_each_rtd_cpu_dais (fe, i, fe_cpu_dai) {
 		/* Symmetry only applies if we've got an active stream. */
-		if (fe_cpu_dai->active) {
+		if (snd_soc_dai_activity(fe_cpu_dai)) {
 			err = soc_pcm_apply_symmetry(fe_substream, fe_cpu_dai);
 			if (err < 0)
 				return err;
@@ -1958,7 +1958,7 @@ static int dpcm_apply_symmetry(struct snd_pcm_substream *fe_substream,
 
 		/* Symmetry only applies if we've got an active stream. */
 		for_each_rtd_dais(rtd, i, dai) {
-			if (dai->active) {
+			if (snd_soc_dai_activity(dai)) {
 				err = soc_pcm_apply_symmetry(fe_substream, dai);
 				if (err < 0)
 					return err;
@@ -2731,7 +2731,7 @@ static int soc_dpcm_fe_runtime_update(struct snd_soc_pcm_runtime *fe, int new)
 		return 0;
 
 	/* only check active links */
-	if (!asoc_rtd_to_cpu(fe, 0)->active)
+	if (!snd_soc_dai_activity(asoc_rtd_to_cpu(fe, 0)))
 		return 0;
 
 	/* DAPM sync will call this to update DSP paths */
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [PATCH 03/17] ASoC: soc-dai: add snd_soc_component_activity()
  2020-05-11  5:55 [PATCH 00/17] ASoC: cleanup DAI/Component activity Kuninori Morimoto
  2020-05-11  5:56 ` [PATCH 01/17] ASoC: soc-dai: add snd_soc_dai_activity() Kuninori Morimoto
  2020-05-11  5:56 ` [PATCH 02/17] ASoC: use snd_soc_dai/component_activity() Kuninori Morimoto
@ 2020-05-11  5:56 ` Kuninori Morimoto
  2020-05-11 19:07   ` Pierre-Louis Bossart
  2020-05-11 22:47   ` Ranjani Sridharan
  2020-05-11  5:56 ` [PATCH 04/17] ASoC: atomel: use snd_soc_dai/component_activity() Kuninori Morimoto
                   ` (13 subsequent siblings)
  16 siblings, 2 replies; 28+ messages in thread
From: Kuninori Morimoto @ 2020-05-11  5:56 UTC (permalink / raw)
  To: Mark Brown; +Cc: Linux-ALSA


From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 include/sound/soc-component.h | 1 +
 sound/soc/soc-pcm.c           | 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/include/sound/soc-component.h b/include/sound/soc-component.h
index 864983b09846..29b0c2c1d2db 100644
--- a/include/sound/soc-component.h
+++ b/include/sound/soc-component.h
@@ -358,6 +358,7 @@ int snd_soc_component_stream_event(struct snd_soc_component *component,
 				   int event);
 int snd_soc_component_set_bias_level(struct snd_soc_component *component,
 				     enum snd_soc_bias_level level);
+#define snd_soc_component_activity(component)	((component)->active)
 
 #ifdef CONFIG_REGMAP
 void snd_soc_component_init_regmap(struct snd_soc_component *component,
diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c
index e923e3746fec..420595356111 100644
--- a/sound/soc/soc-pcm.c
+++ b/sound/soc/soc-pcm.c
@@ -267,7 +267,7 @@ static void snd_soc_runtime_action(struct snd_soc_pcm_runtime *rtd,
 	for_each_rtd_dais(rtd, i, dai) {
 		dai->stream_active[stream] += action;
 		dai->active += action;
-		dai->component->active += action;
+		snd_soc_component_activity(dai->component) += action;
 	}
 }
 
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [PATCH 04/17] ASoC: atomel: use snd_soc_dai/component_activity()
  2020-05-11  5:55 [PATCH 00/17] ASoC: cleanup DAI/Component activity Kuninori Morimoto
                   ` (2 preceding siblings ...)
  2020-05-11  5:56 ` [PATCH 03/17] ASoC: soc-dai: add snd_soc_component_activity() Kuninori Morimoto
@ 2020-05-11  5:56 ` Kuninori Morimoto
  2020-05-11  5:56 ` [PATCH 05/17] ASoC: bcm: " Kuninori Morimoto
                   ` (12 subsequent siblings)
  16 siblings, 0 replies; 28+ messages in thread
From: Kuninori Morimoto @ 2020-05-11  5:56 UTC (permalink / raw)
  To: Mark Brown; +Cc: Linux-ALSA


From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 sound/soc/atmel/atmel_ssc_dai.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/sound/soc/atmel/atmel_ssc_dai.c b/sound/soc/atmel/atmel_ssc_dai.c
index 1073f468f21f..eecf1a71f1e2 100644
--- a/sound/soc/atmel/atmel_ssc_dai.c
+++ b/sound/soc/atmel/atmel_ssc_dai.c
@@ -765,7 +765,7 @@ static int atmel_ssc_suspend(struct snd_soc_component *component)
 	struct atmel_ssc_info *ssc_p;
 	struct platform_device *pdev = to_platform_device(component->dev);
 
-	if (!component->active)
+	if (!snd_soc_component_activity(component))
 		return 0;
 
 	ssc_p = &ssc_info[pdev->id];
@@ -793,7 +793,7 @@ static int atmel_ssc_resume(struct snd_soc_component *component)
 	struct platform_device *pdev = to_platform_device(component->dev);
 	u32 cr;
 
-	if (!component->active)
+	if (!snd_soc_component_activity(component))
 		return 0;
 
 	ssc_p = &ssc_info[pdev->id];
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [PATCH 05/17] ASoC: bcm: use snd_soc_dai/component_activity()
  2020-05-11  5:55 [PATCH 00/17] ASoC: cleanup DAI/Component activity Kuninori Morimoto
                   ` (3 preceding siblings ...)
  2020-05-11  5:56 ` [PATCH 04/17] ASoC: atomel: use snd_soc_dai/component_activity() Kuninori Morimoto
@ 2020-05-11  5:56 ` Kuninori Morimoto
  2020-05-11  5:57 ` [PATCH 06/17] ASoC: cirrus: " Kuninori Morimoto
                   ` (11 subsequent siblings)
  16 siblings, 0 replies; 28+ messages in thread
From: Kuninori Morimoto @ 2020-05-11  5:56 UTC (permalink / raw)
  To: Mark Brown; +Cc: Linux-ALSA


From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 sound/soc/bcm/bcm2835-i2s.c | 6 +++---
 sound/soc/bcm/cygnus-ssp.c  | 4 ++--
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/sound/soc/bcm/bcm2835-i2s.c b/sound/soc/bcm/bcm2835-i2s.c
index e6a12e271b07..b30d77ba1671 100644
--- a/sound/soc/bcm/bcm2835-i2s.c
+++ b/sound/soc/bcm/bcm2835-i2s.c
@@ -653,7 +653,7 @@ static void bcm2835_i2s_stop(struct bcm2835_i2s_dev *dev,
 			BCM2835_I2S_CS_A_REG, mask, 0);
 
 	/* Stop also the clock when not SND_SOC_DAIFMT_CONT */
-	if (!dai->active && !(dev->fmt & SND_SOC_DAIFMT_CONT))
+	if (!snd_soc_dai_activity(dai) && !(dev->fmt & SND_SOC_DAIFMT_CONT))
 		bcm2835_i2s_stop_clock(dev);
 }
 
@@ -695,7 +695,7 @@ static int bcm2835_i2s_startup(struct snd_pcm_substream *substream,
 {
 	struct bcm2835_i2s_dev *dev = snd_soc_dai_get_drvdata(dai);
 
-	if (dai->active)
+	if (snd_soc_dai_activity(dai))
 		return 0;
 
 	/* Should this still be running stop it */
@@ -723,7 +723,7 @@ static void bcm2835_i2s_shutdown(struct snd_pcm_substream *substream,
 	bcm2835_i2s_stop(dev, substream, dai);
 
 	/* If both streams are stopped, disable module and clock */
-	if (dai->active)
+	if (snd_soc_dai_activity(dai))
 		return;
 
 	/* Disable the module */
diff --git a/sound/soc/bcm/cygnus-ssp.c b/sound/soc/bcm/cygnus-ssp.c
index 257f5048061e..2251b9f46803 100644
--- a/sound/soc/bcm/cygnus-ssp.c
+++ b/sound/soc/bcm/cygnus-ssp.c
@@ -1056,7 +1056,7 @@ static int __cygnus_ssp_suspend(struct snd_soc_dai *cpu_dai)
 {
 	struct cygnus_aio_port *aio = cygnus_dai_get_portinfo(cpu_dai);
 
-	if (!cpu_dai->active)
+	if (!snd_soc_dai_activity(cpu_dai))
 		return 0;
 
 	if (!aio->is_slave) {
@@ -1097,7 +1097,7 @@ static int __cygnus_ssp_resume(struct snd_soc_dai *cpu_dai)
 	struct cygnus_aio_port *aio = cygnus_dai_get_portinfo(cpu_dai);
 	int error;
 
-	if (!cpu_dai->active)
+	if (!snd_soc_dai_activity(cpu_dai))
 		return 0;
 
 	if (!aio->is_slave) {
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [PATCH 06/17] ASoC: cirrus: use snd_soc_dai/component_activity()
  2020-05-11  5:55 [PATCH 00/17] ASoC: cleanup DAI/Component activity Kuninori Morimoto
                   ` (4 preceding siblings ...)
  2020-05-11  5:56 ` [PATCH 05/17] ASoC: bcm: " Kuninori Morimoto
@ 2020-05-11  5:57 ` Kuninori Morimoto
  2020-05-11  5:57 ` [PATCH 07/17] ASoC: codecs: " Kuninori Morimoto
                   ` (10 subsequent siblings)
  16 siblings, 0 replies; 28+ messages in thread
From: Kuninori Morimoto @ 2020-05-11  5:57 UTC (permalink / raw)
  To: Mark Brown; +Cc: Linux-ALSA


From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 sound/soc/cirrus/ep93xx-i2s.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/sound/soc/cirrus/ep93xx-i2s.c b/sound/soc/cirrus/ep93xx-i2s.c
index 723f4cf19467..e5d13b73adbb 100644
--- a/sound/soc/cirrus/ep93xx-i2s.c
+++ b/sound/soc/cirrus/ep93xx-i2s.c
@@ -368,7 +368,7 @@ static int ep93xx_i2s_suspend(struct snd_soc_component *component)
 {
 	struct ep93xx_i2s_info *info = snd_soc_component_get_drvdata(component);
 
-	if (!component->active)
+	if (!snd_soc_component_activity(component))
 		return 0;
 
 	ep93xx_i2s_disable(info, SNDRV_PCM_STREAM_PLAYBACK);
@@ -381,7 +381,7 @@ static int ep93xx_i2s_resume(struct snd_soc_component *component)
 {
 	struct ep93xx_i2s_info *info = snd_soc_component_get_drvdata(component);
 
-	if (!component->active)
+	if (!snd_soc_component_activity(component))
 		return 0;
 
 	ep93xx_i2s_enable(info, SNDRV_PCM_STREAM_PLAYBACK);
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [PATCH 07/17] ASoC: codecs: use snd_soc_dai/component_activity()
  2020-05-11  5:55 [PATCH 00/17] ASoC: cleanup DAI/Component activity Kuninori Morimoto
                   ` (5 preceding siblings ...)
  2020-05-11  5:57 ` [PATCH 06/17] ASoC: cirrus: " Kuninori Morimoto
@ 2020-05-11  5:57 ` Kuninori Morimoto
  2020-05-11  5:57 ` [PATCH 08/17] ASoC: fsl: " Kuninori Morimoto
                   ` (9 subsequent siblings)
  16 siblings, 0 replies; 28+ messages in thread
From: Kuninori Morimoto @ 2020-05-11  5:57 UTC (permalink / raw)
  To: Mark Brown; +Cc: Linux-ALSA


From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 sound/soc/codecs/adav80x.c     | 4 ++--
 sound/soc/codecs/arizona.c     | 2 +-
 sound/soc/codecs/madera.c      | 2 +-
 sound/soc/codecs/max98090.c    | 6 +++---
 sound/soc/codecs/tlv320aic23.c | 2 +-
 sound/soc/codecs/tlv320dac33.c | 2 +-
 sound/soc/codecs/uda1380.c     | 2 +-
 sound/soc/codecs/wl1273.c      | 2 +-
 sound/soc/codecs/wm8711.c      | 2 +-
 sound/soc/codecs/wm8753.c      | 4 ++--
 10 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/sound/soc/codecs/adav80x.c b/sound/soc/codecs/adav80x.c
index 7cea398ec392..5b5badd47912 100644
--- a/sound/soc/codecs/adav80x.c
+++ b/sound/soc/codecs/adav80x.c
@@ -725,7 +725,7 @@ static int adav80x_dai_startup(struct snd_pcm_substream *substream,
 	struct snd_soc_component *component = dai->component;
 	struct adav80x *adav80x = snd_soc_component_get_drvdata(component);
 
-	if (!snd_soc_component_is_active(component) || !adav80x->rate)
+	if (!snd_soc_component_activity(component) || !adav80x->rate)
 		return 0;
 
 	return snd_pcm_hw_constraint_single(substream->runtime,
@@ -738,7 +738,7 @@ static void adav80x_dai_shutdown(struct snd_pcm_substream *substream,
 	struct snd_soc_component *component = dai->component;
 	struct adav80x *adav80x = snd_soc_component_get_drvdata(component);
 
-	if (!snd_soc_component_is_active(component))
+	if (!snd_soc_component_activity(component))
 		adav80x->rate = 0;
 }
 
diff --git a/sound/soc/codecs/arizona.c b/sound/soc/codecs/arizona.c
index 70341b30f567..ae2afd649e5c 100644
--- a/sound/soc/codecs/arizona.c
+++ b/sound/soc/codecs/arizona.c
@@ -1926,7 +1926,7 @@ static int arizona_dai_set_sysclk(struct snd_soc_dai *dai,
 	if (clk_id == dai_priv->clk)
 		return 0;
 
-	if (dai->active) {
+	if (snd_soc_dai_activity(dai)) {
 		dev_err(component->dev, "Can't change clock on active DAI %d\n",
 			dai->id);
 		return -EBUSY;
diff --git a/sound/soc/codecs/madera.c b/sound/soc/codecs/madera.c
index a448d2a2918a..bf615d93a9f3 100644
--- a/sound/soc/codecs/madera.c
+++ b/sound/soc/codecs/madera.c
@@ -3279,7 +3279,7 @@ static int madera_dai_set_sysclk(struct snd_soc_dai *dai,
 	if (is_sync == madera_is_syncclk(dai_priv->clk))
 		return 0;
 
-	if (dai->active) {
+	if (snd_soc_dai_activity(dai)) {
 		dev_err(component->dev, "Can't change clock on active DAI %d\n",
 			dai->id);
 		return -EBUSY;
diff --git a/sound/soc/codecs/max98090.c b/sound/soc/codecs/max98090.c
index 032adc14562d..44ec0ab42ac1 100644
--- a/sound/soc/codecs/max98090.c
+++ b/sound/soc/codecs/max98090.c
@@ -2039,7 +2039,7 @@ static int max98090_dai_trigger(struct snd_pcm_substream *substream, int cmd,
 	case SNDRV_PCM_TRIGGER_START:
 	case SNDRV_PCM_TRIGGER_RESUME:
 	case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
-		if (!max98090->master && dai->active == 1)
+		if (!max98090->master && snd_soc_dai_activity(dai) == 1)
 			queue_delayed_work(system_power_efficient_wq,
 					   &max98090->pll_det_enable_work,
 					   msecs_to_jiffies(10));
@@ -2047,7 +2047,7 @@ static int max98090_dai_trigger(struct snd_pcm_substream *substream, int cmd,
 	case SNDRV_PCM_TRIGGER_STOP:
 	case SNDRV_PCM_TRIGGER_SUSPEND:
 	case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
-		if (!max98090->master && dai->active == 1)
+		if (!max98090->master && snd_soc_dai_activity(dai) == 1)
 			schedule_work(&max98090->pll_det_disable_work);
 		break;
 	default:
@@ -2109,7 +2109,7 @@ static void max98090_pll_work(struct max98090_priv *max98090)
 	unsigned int pll;
 	int i;
 
-	if (!snd_soc_component_is_active(component))
+	if (!snd_soc_component_activity(component))
 		return;
 
 	dev_info_ratelimited(component->dev, "PLL unlocked\n");
diff --git a/sound/soc/codecs/tlv320aic23.c b/sound/soc/codecs/tlv320aic23.c
index f8e2f4b74db3..86c8a4f6b98c 100644
--- a/sound/soc/codecs/tlv320aic23.c
+++ b/sound/soc/codecs/tlv320aic23.c
@@ -394,7 +394,7 @@ static void tlv320aic23_shutdown(struct snd_pcm_substream *substream,
 	struct aic23 *aic23 = snd_soc_component_get_drvdata(component);
 
 	/* deactivate */
-	if (!snd_soc_component_is_active(component)) {
+	if (!snd_soc_component_activity(component)) {
 		udelay(50);
 		snd_soc_component_write(component, TLV320AIC23_ACTIVE, 0x0);
 	}
diff --git a/sound/soc/codecs/tlv320dac33.c b/sound/soc/codecs/tlv320dac33.c
index 808654b10deb..f30e0b38ac1d 100644
--- a/sound/soc/codecs/tlv320dac33.c
+++ b/sound/soc/codecs/tlv320dac33.c
@@ -449,7 +449,7 @@ static int dac33_set_fifo_mode(struct snd_kcontrol *kcontrol,
 	if (dac33->fifo_mode == ucontrol->value.enumerated.item[0])
 		return 0;
 	/* Do not allow changes while stream is running*/
-	if (snd_soc_component_is_active(component))
+	if (snd_soc_component_activity(component))
 		return -EPERM;
 
 	if (ucontrol->value.enumerated.item[0] >= DAC33_FIFO_LAST_MODE)
diff --git a/sound/soc/codecs/uda1380.c b/sound/soc/codecs/uda1380.c
index 26b2ee428aee..01c8fd1489bd 100644
--- a/sound/soc/codecs/uda1380.c
+++ b/sound/soc/codecs/uda1380.c
@@ -110,7 +110,7 @@ static int uda1380_write(struct snd_soc_component *component, unsigned int reg,
 	/* the interpolator & decimator regs must only be written when the
 	 * codec DAI is active.
 	 */
-	if (!snd_soc_component_is_active(component) && (reg >= UDA1380_MVOL))
+	if (!snd_soc_component_activity(component) && (reg >= UDA1380_MVOL))
 		return 0;
 	pr_debug("uda1380: hw write %x val %x\n", reg, value);
 	if (i2c_master_send(uda1380->i2c, data, 3) == 3) {
diff --git a/sound/soc/codecs/wl1273.c b/sound/soc/codecs/wl1273.c
index b30bfcd6a125..2c8a8762384b 100644
--- a/sound/soc/codecs/wl1273.c
+++ b/sound/soc/codecs/wl1273.c
@@ -183,7 +183,7 @@ static int snd_wl1273_set_audio_route(struct snd_kcontrol *kcontrol,
 		return 0;
 
 	/* Do not allow changes while stream is running */
-	if (snd_soc_component_is_active(component))
+	if (snd_soc_component_activity(component))
 		return -EPERM;
 
 	if (ucontrol->value.enumerated.item[0] >=  ARRAY_SIZE(wl1273_audio_route))
diff --git a/sound/soc/codecs/wm8711.c b/sound/soc/codecs/wm8711.c
index 8036b18fdeb9..d0dec2f7ceef 100644
--- a/sound/soc/codecs/wm8711.c
+++ b/sound/soc/codecs/wm8711.c
@@ -198,7 +198,7 @@ static void wm8711_shutdown(struct snd_pcm_substream *substream,
 	struct snd_soc_component *component = dai->component;
 
 	/* deactivate */
-	if (!snd_soc_component_is_active(component)) {
+	if (!snd_soc_component_activity(component)) {
 		udelay(50);
 		snd_soc_component_write(component, WM8711_ACTIVE, 0x0);
 	}
diff --git a/sound/soc/codecs/wm8753.c b/sound/soc/codecs/wm8753.c
index 95a12718f3af..dde13b76a79e 100644
--- a/sound/soc/codecs/wm8753.c
+++ b/sound/soc/codecs/wm8753.c
@@ -241,7 +241,7 @@ static int wm8753_set_dai(struct snd_kcontrol *kcontrol,
 	if (wm8753->dai_func == ucontrol->value.enumerated.item[0])
 		return 0;
 
-	if (snd_soc_component_is_active(component))
+	if (snd_soc_component_activity(component))
 		return -EBUSY;
 
 	ioctl = snd_soc_component_read32(component, WM8753_IOCTL);
@@ -1304,7 +1304,7 @@ static int wm8753_mute(struct snd_soc_dai *dai, int mute)
 	/* the digital mute covers the HiFi and Voice DAC's on the WM8753.
 	 * make sure we check if they are not both active when we mute */
 	if (mute && wm8753->dai_func == 1) {
-		if (!snd_soc_component_is_active(component))
+		if (!snd_soc_component_activity(component))
 			snd_soc_component_write(component, WM8753_DAC, mute_reg | 0x8);
 	} else {
 		if (mute)
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [PATCH 08/17] ASoC: fsl: use snd_soc_dai/component_activity()
  2020-05-11  5:55 [PATCH 00/17] ASoC: cleanup DAI/Component activity Kuninori Morimoto
                   ` (6 preceding siblings ...)
  2020-05-11  5:57 ` [PATCH 07/17] ASoC: codecs: " Kuninori Morimoto
@ 2020-05-11  5:57 ` Kuninori Morimoto
  2020-05-11  5:57 ` [PATCH 09/17] ASoC: intel: " Kuninori Morimoto
                   ` (8 subsequent siblings)
  16 siblings, 0 replies; 28+ messages in thread
From: Kuninori Morimoto @ 2020-05-11  5:57 UTC (permalink / raw)
  To: Mark Brown; +Cc: Linux-ALSA


From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 sound/soc/fsl/fsl_esai.c  | 2 +-
 sound/soc/fsl/fsl_spdif.c | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/sound/soc/fsl/fsl_esai.c b/sound/soc/fsl/fsl_esai.c
index 84290be778f0..18115ae82991 100644
--- a/sound/soc/fsl/fsl_esai.c
+++ b/sound/soc/fsl/fsl_esai.c
@@ -488,7 +488,7 @@ static int fsl_esai_startup(struct snd_pcm_substream *substream,
 {
 	struct fsl_esai *esai_priv = snd_soc_dai_get_drvdata(dai);
 
-	if (!dai->active) {
+	if (!snd_soc_dai_activity(dai)) {
 		/* Set synchronous mode */
 		regmap_update_bits(esai_priv->regmap, REG_ESAI_SAICR,
 				   ESAI_SAICR_SYNC, esai_priv->synchronous ?
diff --git a/sound/soc/fsl/fsl_spdif.c b/sound/soc/fsl/fsl_spdif.c
index c711d2d93280..e4bce271a916 100644
--- a/sound/soc/fsl/fsl_spdif.c
+++ b/sound/soc/fsl/fsl_spdif.c
@@ -466,7 +466,7 @@ static int fsl_spdif_startup(struct snd_pcm_substream *substream,
 	int ret;
 
 	/* Reset module and interrupts only for first initialization */
-	if (!cpu_dai->active) {
+	if (!snd_soc_dai_activity(cpu_dai)) {
 		ret = clk_prepare_enable(spdif_priv->coreclk);
 		if (ret) {
 			dev_err(&pdev->dev, "failed to enable core clock\n");
@@ -554,7 +554,7 @@ static void fsl_spdif_shutdown(struct snd_pcm_substream *substream,
 	regmap_update_bits(regmap, REG_SPDIF_SCR, mask, scr);
 
 	/* Power down SPDIF module only if tx&rx are both inactive */
-	if (!cpu_dai->active) {
+	if (!snd_soc_dai_activity(cpu_dai)) {
 		spdif_intr_status_clear(spdif_priv);
 		regmap_update_bits(regmap, REG_SPDIF_SCR,
 				SCR_LOW_POWER, SCR_LOW_POWER);
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [PATCH 09/17] ASoC: intel: use snd_soc_dai/component_activity()
  2020-05-11  5:55 [PATCH 00/17] ASoC: cleanup DAI/Component activity Kuninori Morimoto
                   ` (7 preceding siblings ...)
  2020-05-11  5:57 ` [PATCH 08/17] ASoC: fsl: " Kuninori Morimoto
@ 2020-05-11  5:57 ` Kuninori Morimoto
  2020-05-11  5:57 ` [PATCH 10/17] ASoC: jz4740: " Kuninori Morimoto
                   ` (7 subsequent siblings)
  16 siblings, 0 replies; 28+ messages in thread
From: Kuninori Morimoto @ 2020-05-11  5:57 UTC (permalink / raw)
  To: Mark Brown; +Cc: Linux-ALSA


From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 sound/soc/intel/atom/sst-mfld-platform-pcm.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/sound/soc/intel/atom/sst-mfld-platform-pcm.c b/sound/soc/intel/atom/sst-mfld-platform-pcm.c
index 2e9222ed9daa..6ad096392d2d 100644
--- a/sound/soc/intel/atom/sst-mfld-platform-pcm.c
+++ b/sound/soc/intel/atom/sst-mfld-platform-pcm.c
@@ -392,7 +392,7 @@ static int sst_enable_ssp(struct snd_pcm_substream *substream,
 {
 	int ret = 0;
 
-	if (!dai->active) {
+	if (!snd_soc_dai_activity(dai)) {
 		ret = sst_handle_vb_timer(dai, true);
 		sst_fill_ssp_defaults(dai);
 	}
@@ -405,7 +405,7 @@ static int sst_be_hw_params(struct snd_pcm_substream *substream,
 {
 	int ret = 0;
 
-	if (dai->active == 1)
+	if (snd_soc_dai_activity(dai) == 1)
 		ret = send_ssp_cmd(dai, dai->name, 1);
 	return ret;
 }
@@ -414,7 +414,7 @@ static int sst_set_format(struct snd_soc_dai *dai, unsigned int fmt)
 {
 	int ret = 0;
 
-	if (!dai->active)
+	if (!snd_soc_dai_activity(dai))
 		return 0;
 
 	ret = sst_fill_ssp_config(dai, fmt);
@@ -429,7 +429,7 @@ static int sst_platform_set_ssp_slot(struct snd_soc_dai *dai,
 			int slots, int slot_width) {
 	int ret = 0;
 
-	if (!dai->active)
+	if (!snd_soc_dai_activity(dai))
 		return ret;
 
 	ret = sst_fill_ssp_slot(dai, tx_mask, rx_mask, slots, slot_width);
@@ -442,7 +442,7 @@ static int sst_platform_set_ssp_slot(struct snd_soc_dai *dai,
 static void sst_disable_ssp(struct snd_pcm_substream *substream,
 			struct snd_soc_dai *dai)
 {
-	if (!dai->active) {
+	if (!snd_soc_dai_activity(dai)) {
 		send_ssp_cmd(dai, dai->name, 0);
 		sst_handle_vb_timer(dai, false);
 	}
@@ -743,7 +743,7 @@ static int sst_soc_prepare(struct device *dev)
 	for_each_card_rtds(drv->soc_card, rtd) {
 		struct snd_soc_dai *dai = asoc_rtd_to_cpu(rtd, 0);
 
-		if (dai->active) {
+		if (snd_soc_dai_activity(dai)) {
 			send_ssp_cmd(dai, dai->name, 0);
 			sst_handle_vb_timer(dai, false);
 		}
@@ -764,7 +764,7 @@ static void sst_soc_complete(struct device *dev)
 	for_each_card_rtds(drv->soc_card, rtd) {
 		struct snd_soc_dai *dai = asoc_rtd_to_cpu(rtd, 0);
 
-		if (dai->active) {
+		if (snd_soc_dai_activity(dai)) {
 			sst_handle_vb_timer(dai, true);
 			send_ssp_cmd(dai, dai->name, 1);
 		}
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [PATCH 10/17] ASoC: jz4740: use snd_soc_dai/component_activity()
  2020-05-11  5:55 [PATCH 00/17] ASoC: cleanup DAI/Component activity Kuninori Morimoto
                   ` (8 preceding siblings ...)
  2020-05-11  5:57 ` [PATCH 09/17] ASoC: intel: " Kuninori Morimoto
@ 2020-05-11  5:57 ` Kuninori Morimoto
  2020-05-11  5:57 ` [PATCH 11/17] ASoC: mediatek: " Kuninori Morimoto
                   ` (6 subsequent siblings)
  16 siblings, 0 replies; 28+ messages in thread
From: Kuninori Morimoto @ 2020-05-11  5:57 UTC (permalink / raw)
  To: Mark Brown; +Cc: Linux-ALSA


From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 sound/soc/jz4740/jz4740-i2s.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/sound/soc/jz4740/jz4740-i2s.c b/sound/soc/jz4740/jz4740-i2s.c
index 6f6f8dad0356..872257bec630 100644
--- a/sound/soc/jz4740/jz4740-i2s.c
+++ b/sound/soc/jz4740/jz4740-i2s.c
@@ -129,7 +129,7 @@ static int jz4740_i2s_startup(struct snd_pcm_substream *substream,
 	uint32_t conf, ctrl;
 	int ret;
 
-	if (dai->active)
+	if (snd_soc_dai_activity(dai))
 		return 0;
 
 	ctrl = jz4740_i2s_read(i2s, JZ_REG_AIC_CTRL);
@@ -153,7 +153,7 @@ static void jz4740_i2s_shutdown(struct snd_pcm_substream *substream,
 	struct jz4740_i2s *i2s = snd_soc_dai_get_drvdata(dai);
 	uint32_t conf;
 
-	if (dai->active)
+	if (snd_soc_dai_activity(dai))
 		return;
 
 	conf = jz4740_i2s_read(i2s, JZ_REG_AIC_CONF);
@@ -332,7 +332,7 @@ static int jz4740_i2s_suspend(struct snd_soc_component *component)
 	struct jz4740_i2s *i2s = snd_soc_component_get_drvdata(component);
 	uint32_t conf;
 
-	if (component->active) {
+	if (snd_soc_component_activity(component)) {
 		conf = jz4740_i2s_read(i2s, JZ_REG_AIC_CONF);
 		conf &= ~JZ_AIC_CONF_ENABLE;
 		jz4740_i2s_write(i2s, JZ_REG_AIC_CONF, conf);
@@ -355,7 +355,7 @@ static int jz4740_i2s_resume(struct snd_soc_component *component)
 	if (ret)
 		return ret;
 
-	if (component->active) {
+	if (snd_soc_component_activity(component)) {
 		ret = clk_prepare_enable(i2s->clk_i2s);
 		if (ret) {
 			clk_disable_unprepare(i2s->clk_aic);
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [PATCH 11/17] ASoC: mediatek: use snd_soc_dai/component_activity()
  2020-05-11  5:55 [PATCH 00/17] ASoC: cleanup DAI/Component activity Kuninori Morimoto
                   ` (9 preceding siblings ...)
  2020-05-11  5:57 ` [PATCH 10/17] ASoC: jz4740: " Kuninori Morimoto
@ 2020-05-11  5:57 ` Kuninori Morimoto
  2020-05-11  5:57 ` [PATCH 12/17] ASoC: meson: " Kuninori Morimoto
                   ` (5 subsequent siblings)
  16 siblings, 0 replies; 28+ messages in thread
From: Kuninori Morimoto @ 2020-05-11  5:57 UTC (permalink / raw)
  To: Mark Brown; +Cc: Linux-ALSA


From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 sound/soc/mediatek/mt8173/mt8173-afe-pcm.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/sound/soc/mediatek/mt8173/mt8173-afe-pcm.c b/sound/soc/mediatek/mt8173/mt8173-afe-pcm.c
index 6262e2c69107..4fa263cad985 100644
--- a/sound/soc/mediatek/mt8173/mt8173-afe-pcm.c
+++ b/sound/soc/mediatek/mt8173/mt8173-afe-pcm.c
@@ -297,7 +297,7 @@ static int mt8173_afe_i2s_startup(struct snd_pcm_substream *substream,
 {
 	struct mtk_base_afe *afe = snd_soc_dai_get_drvdata(dai);
 
-	if (dai->active)
+	if (snd_soc_dai_activity(dai))
 		return 0;
 
 	regmap_update_bits(afe->regmap, AUDIO_TOP_CON0,
@@ -310,7 +310,7 @@ static void mt8173_afe_i2s_shutdown(struct snd_pcm_substream *substream,
 {
 	struct mtk_base_afe *afe = snd_soc_dai_get_drvdata(dai);
 
-	if (dai->active)
+	if (snd_soc_dai_activity(dai))
 		return;
 
 	mt8173_afe_set_i2s_enable(afe, false);
@@ -347,7 +347,7 @@ static int mt8173_afe_hdmi_startup(struct snd_pcm_substream *substream,
 	struct mtk_base_afe *afe = snd_soc_dai_get_drvdata(dai);
 	struct mt8173_afe_private *afe_priv = afe->platform_priv;
 
-	if (dai->active)
+	if (snd_soc_dai_activity(dai))
 		return 0;
 
 	mt8173_afe_dais_enable_clks(afe, afe_priv->clocks[MT8173_CLK_I2S3_M],
@@ -361,7 +361,7 @@ static void mt8173_afe_hdmi_shutdown(struct snd_pcm_substream *substream,
 	struct mtk_base_afe *afe = snd_soc_dai_get_drvdata(dai);
 	struct mt8173_afe_private *afe_priv = afe->platform_priv;
 
-	if (dai->active)
+	if (snd_soc_dai_activity(dai))
 		return;
 
 	mt8173_afe_dais_disable_clks(afe, afe_priv->clocks[MT8173_CLK_I2S3_M],
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [PATCH 12/17] ASoC: meson: use snd_soc_dai/component_activity()
  2020-05-11  5:55 [PATCH 00/17] ASoC: cleanup DAI/Component activity Kuninori Morimoto
                   ` (10 preceding siblings ...)
  2020-05-11  5:57 ` [PATCH 11/17] ASoC: mediatek: " Kuninori Morimoto
@ 2020-05-11  5:57 ` Kuninori Morimoto
  2020-05-11  5:57 ` [PATCH 13/17] ASoC: pxa: " Kuninori Morimoto
                   ` (4 subsequent siblings)
  16 siblings, 0 replies; 28+ messages in thread
From: Kuninori Morimoto @ 2020-05-11  5:57 UTC (permalink / raw)
  To: Mark Brown; +Cc: Linux-ALSA


From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 sound/soc/meson/axg-tdm-interface.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sound/soc/meson/axg-tdm-interface.c b/sound/soc/meson/axg-tdm-interface.c
index d51f3344be7c..3dea935826de 100644
--- a/sound/soc/meson/axg-tdm-interface.c
+++ b/sound/soc/meson/axg-tdm-interface.c
@@ -149,7 +149,7 @@ static int axg_tdm_iface_startup(struct snd_pcm_substream *substream,
 	}
 
 	/* Apply component wide rate symmetry */
-	if (dai->component->active) {
+	if (snd_soc_component_activity(dai->component)) {
 		ret = snd_pcm_hw_constraint_single(substream->runtime,
 						   SNDRV_PCM_HW_PARAM_RATE,
 						   iface->rate);
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [PATCH 13/17] ASoC: pxa: use snd_soc_dai/component_activity()
  2020-05-11  5:55 [PATCH 00/17] ASoC: cleanup DAI/Component activity Kuninori Morimoto
                   ` (11 preceding siblings ...)
  2020-05-11  5:57 ` [PATCH 12/17] ASoC: meson: " Kuninori Morimoto
@ 2020-05-11  5:57 ` Kuninori Morimoto
  2020-05-11  5:57 ` [PATCH 14/17] ASoC: ti: " Kuninori Morimoto
                   ` (3 subsequent siblings)
  16 siblings, 0 replies; 28+ messages in thread
From: Kuninori Morimoto @ 2020-05-11  5:57 UTC (permalink / raw)
  To: Mark Brown; +Cc: Linux-ALSA


From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 sound/soc/pxa/pxa-ssp.c    | 8 ++++----
 sound/soc/pxa/pxa2xx-i2s.c | 2 +-
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/sound/soc/pxa/pxa-ssp.c b/sound/soc/pxa/pxa-ssp.c
index e615acaa0199..75aa390d4649 100644
--- a/sound/soc/pxa/pxa-ssp.c
+++ b/sound/soc/pxa/pxa-ssp.c
@@ -94,7 +94,7 @@ static int pxa_ssp_startup(struct snd_pcm_substream *substream,
 	struct snd_dmaengine_dai_dma_data *dma;
 	int ret = 0;
 
-	if (!cpu_dai->active) {
+	if (!snd_soc_dai_activity(cpu_dai)) {
 		clk_prepare_enable(ssp->clk);
 		pxa_ssp_disable(ssp);
 	}
@@ -119,7 +119,7 @@ static void pxa_ssp_shutdown(struct snd_pcm_substream *substream,
 	struct ssp_priv *priv = snd_soc_dai_get_drvdata(cpu_dai);
 	struct ssp_device *ssp = priv->ssp;
 
-	if (!cpu_dai->active) {
+	if (!snd_soc_dai_activity(cpu_dai)) {
 		pxa_ssp_disable(ssp);
 		clk_disable_unprepare(ssp->clk);
 	}
@@ -138,7 +138,7 @@ static int pxa_ssp_suspend(struct snd_soc_component *component)
 	struct ssp_priv *priv = snd_soc_component_get_drvdata(component);
 	struct ssp_device *ssp = priv->ssp;
 
-	if (!component->active)
+	if (!snd_soc_component_activity(component))
 		clk_prepare_enable(ssp->clk);
 
 	priv->cr0 = __raw_readl(ssp->mmio_base + SSCR0);
@@ -165,7 +165,7 @@ static int pxa_ssp_resume(struct snd_soc_component *component)
 	__raw_writel(priv->to,  ssp->mmio_base + SSTO);
 	__raw_writel(priv->psp, ssp->mmio_base + SSPSP);
 
-	if (component->active)
+	if (snd_soc_component_activity(component))
 		pxa_ssp_enable(ssp);
 	else
 		clk_disable_unprepare(ssp->clk);
diff --git a/sound/soc/pxa/pxa2xx-i2s.c b/sound/soc/pxa/pxa2xx-i2s.c
index 9a32bf72127a..ec0a2ee5bd78 100644
--- a/sound/soc/pxa/pxa2xx-i2s.c
+++ b/sound/soc/pxa/pxa2xx-i2s.c
@@ -101,7 +101,7 @@ static int pxa2xx_i2s_startup(struct snd_pcm_substream *substream,
 	if (IS_ERR(clk_i2s))
 		return PTR_ERR(clk_i2s);
 
-	if (!cpu_dai->active)
+	if (!snd_soc_dai_activity(cpu_dai))
 		SACR0 = 0;
 
 	return 0;
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [PATCH 14/17] ASoC: ti: use snd_soc_dai/component_activity()
  2020-05-11  5:55 [PATCH 00/17] ASoC: cleanup DAI/Component activity Kuninori Morimoto
                   ` (12 preceding siblings ...)
  2020-05-11  5:57 ` [PATCH 13/17] ASoC: pxa: " Kuninori Morimoto
@ 2020-05-11  5:57 ` Kuninori Morimoto
  2020-05-11  5:57 ` [PATCH 15/17] ASoC: uniphier: " Kuninori Morimoto
                   ` (2 subsequent siblings)
  16 siblings, 0 replies; 28+ messages in thread
From: Kuninori Morimoto @ 2020-05-11  5:57 UTC (permalink / raw)
  To: Mark Brown; +Cc: Linux-ALSA


From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 sound/soc/ti/davinci-mcasp.c | 2 +-
 sound/soc/ti/omap-dmic.c     | 4 ++--
 sound/soc/ti/omap-mcbsp.c    | 4 ++--
 sound/soc/ti/omap-mcpdm.c    | 8 ++++----
 4 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/sound/soc/ti/davinci-mcasp.c b/sound/soc/ti/davinci-mcasp.c
index 734ffe925c4d..14e75b6c2644 100644
--- a/sound/soc/ti/davinci-mcasp.c
+++ b/sound/soc/ti/davinci-mcasp.c
@@ -1577,7 +1577,7 @@ static void davinci_mcasp_shutdown(struct snd_pcm_substream *substream,
 	if (mcasp->op_mode == DAVINCI_MCASP_DIT_MODE)
 		return;
 
-	if (!cpu_dai->active) {
+	if (!snd_soc_dai_activity(cpu_dai)) {
 		mcasp->channels = 0;
 		mcasp->max_format_width = 0;
 	}
diff --git a/sound/soc/ti/omap-dmic.c b/sound/soc/ti/omap-dmic.c
index 913579c43e9d..42b61bbfd060 100644
--- a/sound/soc/ti/omap-dmic.c
+++ b/sound/soc/ti/omap-dmic.c
@@ -95,7 +95,7 @@ static int omap_dmic_dai_startup(struct snd_pcm_substream *substream,
 
 	mutex_lock(&dmic->mutex);
 
-	if (!dai->active)
+	if (!snd_soc_dai_activity(dai))
 		dmic->active = 1;
 	else
 		ret = -EBUSY;
@@ -114,7 +114,7 @@ static void omap_dmic_dai_shutdown(struct snd_pcm_substream *substream,
 
 	cpu_latency_qos_remove_request(&dmic->pm_qos_req);
 
-	if (!dai->active)
+	if (!snd_soc_dai_activity(dai))
 		dmic->active = 0;
 
 	mutex_unlock(&dmic->mutex);
diff --git a/sound/soc/ti/omap-mcbsp.c b/sound/soc/ti/omap-mcbsp.c
index 0348963f4df7..685f7add6379 100644
--- a/sound/soc/ti/omap-mcbsp.c
+++ b/sound/soc/ti/omap-mcbsp.c
@@ -788,7 +788,7 @@ static int omap_mcbsp_dai_startup(struct snd_pcm_substream *substream,
 	struct omap_mcbsp *mcbsp = snd_soc_dai_get_drvdata(cpu_dai);
 	int err = 0;
 
-	if (!cpu_dai->active)
+	if (!snd_soc_dai_activity(cpu_dai))
 		err = omap_mcbsp_request(mcbsp);
 
 	/*
@@ -843,7 +843,7 @@ static void omap_mcbsp_dai_shutdown(struct snd_pcm_substream *substream,
 
 	mcbsp->latency[stream1] = 0;
 
-	if (!cpu_dai->active) {
+	if (!snd_soc_dai_activity(cpu_dai)) {
 		omap_mcbsp_free(mcbsp);
 		mcbsp->configured = 0;
 	}
diff --git a/sound/soc/ti/omap-mcpdm.c b/sound/soc/ti/omap-mcpdm.c
index f2dbadea33bb..ef5786f9a840 100644
--- a/sound/soc/ti/omap-mcpdm.c
+++ b/sound/soc/ti/omap-mcpdm.c
@@ -253,7 +253,7 @@ static int omap_mcpdm_dai_startup(struct snd_pcm_substream *substream,
 
 	mutex_lock(&mcpdm->mutex);
 
-	if (!dai->active)
+	if (!snd_soc_dai_activity(dai))
 		omap_mcpdm_open_streams(mcpdm);
 
 	mutex_unlock(&mcpdm->mutex);
@@ -271,7 +271,7 @@ static void omap_mcpdm_dai_shutdown(struct snd_pcm_substream *substream,
 
 	mutex_lock(&mcpdm->mutex);
 
-	if (!dai->active) {
+	if (!snd_soc_dai_activity(dai)) {
 		if (omap_mcpdm_active(mcpdm)) {
 			omap_mcpdm_stop(mcpdm);
 			omap_mcpdm_close_streams(mcpdm);
@@ -462,7 +462,7 @@ static int omap_mcpdm_suspend(struct snd_soc_component *component)
 {
 	struct omap_mcpdm *mcpdm = snd_soc_component_get_drvdata(component);
 
-	if (component->active) {
+	if (snd_soc_component_activity(component)) {
 		omap_mcpdm_stop(mcpdm);
 		omap_mcpdm_close_streams(mcpdm);
 	}
@@ -484,7 +484,7 @@ static int omap_mcpdm_resume(struct snd_soc_component *component)
 		while (mcpdm->pm_active_count--)
 			pm_runtime_get_sync(mcpdm->dev);
 
-		if (component->active) {
+		if (snd_soc_component_activity(component)) {
 			omap_mcpdm_open_streams(mcpdm);
 			omap_mcpdm_start(mcpdm);
 		}
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [PATCH 15/17] ASoC: uniphier: use snd_soc_dai/component_activity()
  2020-05-11  5:55 [PATCH 00/17] ASoC: cleanup DAI/Component activity Kuninori Morimoto
                   ` (13 preceding siblings ...)
  2020-05-11  5:57 ` [PATCH 14/17] ASoC: ti: " Kuninori Morimoto
@ 2020-05-11  5:57 ` Kuninori Morimoto
  2020-05-11  5:57 ` [PATCH 16/17] ASoC: cleanup dai / component active code Kuninori Morimoto
  2020-05-11  5:58 ` [PATCH 17/17] ASoC: soc-dai: add snd_soc_dai_stream_activity() Kuninori Morimoto
  16 siblings, 0 replies; 28+ messages in thread
From: Kuninori Morimoto @ 2020-05-11  5:57 UTC (permalink / raw)
  To: Mark Brown; +Cc: Linux-ALSA


From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 sound/soc/uniphier/aio-cpu.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/sound/soc/uniphier/aio-cpu.c b/sound/soc/uniphier/aio-cpu.c
index fdaa6522720f..f717daf3f820 100644
--- a/sound/soc/uniphier/aio-cpu.c
+++ b/sound/soc/uniphier/aio-cpu.c
@@ -424,7 +424,7 @@ static void uniphier_aio_dai_suspend(struct snd_soc_dai *dai)
 {
 	struct uniphier_aio *aio = uniphier_priv(dai);
 
-	if (!dai->active)
+	if (!snd_soc_dai_activity(dai))
 		return;
 
 	aio->chip->num_wup_aios--;
@@ -448,7 +448,7 @@ static int uniphier_aio_dai_resume(struct snd_soc_dai *dai)
 	struct uniphier_aio *aio = uniphier_priv(dai);
 	int ret, i;
 
-	if (!dai->active)
+	if (!snd_soc_dai_activity(dai))
 		return 0;
 
 	if (!aio->chip->active)
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [PATCH 16/17] ASoC: cleanup dai / component active code
  2020-05-11  5:55 [PATCH 00/17] ASoC: cleanup DAI/Component activity Kuninori Morimoto
                   ` (14 preceding siblings ...)
  2020-05-11  5:57 ` [PATCH 15/17] ASoC: uniphier: " Kuninori Morimoto
@ 2020-05-11  5:57 ` Kuninori Morimoto
  2020-05-11  5:58 ` [PATCH 17/17] ASoC: soc-dai: add snd_soc_dai_stream_activity() Kuninori Morimoto
  16 siblings, 0 replies; 28+ messages in thread
From: Kuninori Morimoto @ 2020-05-11  5:57 UTC (permalink / raw)
  To: Mark Brown; +Cc: Linux-ALSA


From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

No one is using dai->active, snd_soc_component_is_active().
Let's remove these.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 include/sound/soc-component.h | 6 ------
 include/sound/soc-dai.h       | 2 --
 sound/soc/soc-pcm.c           | 1 -
 3 files changed, 9 deletions(-)

diff --git a/include/sound/soc-component.h b/include/sound/soc-component.h
index 29b0c2c1d2db..cbb7255c8e27 100644
--- a/include/sound/soc-component.h
+++ b/include/sound/soc-component.h
@@ -390,12 +390,6 @@ static inline void *snd_soc_component_get_drvdata(struct snd_soc_component *c)
 	return dev_get_drvdata(c->dev);
 }
 
-static inline bool snd_soc_component_is_active(
-	struct snd_soc_component *component)
-{
-	return component->active != 0;
-}
-
 /* component pin */
 int snd_soc_component_enable_pin(struct snd_soc_component *component,
 				 const char *pin);
diff --git a/include/sound/soc-dai.h b/include/sound/soc-dai.h
index 887575d59e31..502aaeb561a0 100644
--- a/include/sound/soc-dai.h
+++ b/include/sound/soc-dai.h
@@ -351,8 +351,6 @@ struct snd_soc_dai {
 	/* DAI runtime info */
 	unsigned int stream_active[SNDRV_PCM_STREAM_LAST + 1]; /* usage count */
 
-	unsigned int active;
-
 	struct snd_soc_dapm_widget *playback_widget;
 	struct snd_soc_dapm_widget *capture_widget;
 
diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c
index 420595356111..0eae9ab2a2ea 100644
--- a/sound/soc/soc-pcm.c
+++ b/sound/soc/soc-pcm.c
@@ -266,7 +266,6 @@ static void snd_soc_runtime_action(struct snd_soc_pcm_runtime *rtd,
 
 	for_each_rtd_dais(rtd, i, dai) {
 		dai->stream_active[stream] += action;
-		dai->active += action;
 		snd_soc_component_activity(dai->component) += action;
 	}
 }
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [PATCH 17/17] ASoC: soc-dai: add snd_soc_dai_stream_activity()
  2020-05-11  5:55 [PATCH 00/17] ASoC: cleanup DAI/Component activity Kuninori Morimoto
                   ` (15 preceding siblings ...)
  2020-05-11  5:57 ` [PATCH 16/17] ASoC: cleanup dai / component active code Kuninori Morimoto
@ 2020-05-11  5:58 ` Kuninori Morimoto
  2020-05-11  8:12   ` kbuild test robot
  2020-05-11  8:12   ` kbuild test robot
  16 siblings, 2 replies; 28+ messages in thread
From: Kuninori Morimoto @ 2020-05-11  5:58 UTC (permalink / raw)
  To: Mark Brown; +Cc: Linux-ALSA


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 --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);
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 28+ messages in thread

* Re: [PATCH 17/17] ASoC: soc-dai: add snd_soc_dai_stream_activity()
  2020-05-11  5:58 ` [PATCH 17/17] ASoC: soc-dai: add snd_soc_dai_stream_activity() Kuninori Morimoto
@ 2020-05-11  8:12   ` kbuild test robot
  2020-05-11  8:12   ` kbuild test robot
  1 sibling, 0 replies; 28+ messages in thread
From: kbuild test robot @ 2020-05-11  8:12 UTC (permalink / raw)
  To: kbuild-all

[-- Attachment #1: Type: text/plain, Size: 3259 bytes --]

Hi Kuninori,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on asoc/for-next]
[also build test ERROR on next-20200508]
[cannot apply to sound/for-next spi/for-next v5.7-rc5]
[if your patch is applied to the wrong git tree, please drop us a note to help
improve the system. BTW, we also suggest to use '--base' option to specify the
base tree in git format-patch, please see https://stackoverflow.com/a/37406982]

url:    https://github.com/0day-ci/linux/commits/Kuninori-Morimoto/ASoC-cleanup-DAI-Component-activity/20200511-144543
base:   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next
config: i386-randconfig-a006-20200511 (attached as .config)
compiler: gcc-7 (Ubuntu 7.5.0-6ubuntu2) 7.5.0
reproduce:
        # save the attached .config to linux build tree
        make ARCH=i386 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kbuild test robot <lkp@intel.com>

All error/warnings (new ones prefixed by >>):

   In file included from include/sound/soc.h:1380:0,
                    from sound/soc/codecs/cs4271.c:22:
   sound/soc/codecs/cs4271.c: In function 'cs4271_hw_params':
>> include/sound/soc-dai.h:141:77: error: expected ')' before ']' token
    #define snd_soc_dai_stream_activity(dai, stream) (dai)->stream_active[stream]
                                                                                ^
>> sound/soc/codecs/cs4271.c:361:9: note: in expansion of macro 'snd_soc_dai_stream_activity'
           !snd_soc_dai_stream_activity(dai, SNDRV_PCM_STREAM_PLAYBACK])) {
            ^~~~~~~~~~~~~~~~~~~~~~~~~~~
>> include/sound/soc-dai.h:141:77: error: expected ')' before ']' token
    #define snd_soc_dai_stream_activity(dai, stream) (dai)->stream_active[stream]
                                                                                ^
>> sound/soc/codecs/cs4271.c:361:9: note: in expansion of macro 'snd_soc_dai_stream_activity'
           !snd_soc_dai_stream_activity(dai, SNDRV_PCM_STREAM_PLAYBACK])) {
            ^~~~~~~~~~~~~~~~~~~~~~~~~~~
>> include/sound/soc-dai.h:141:77: error: expected statement before ']' token
    #define snd_soc_dai_stream_activity(dai, stream) (dai)->stream_active[stream]
                                                                                ^
>> sound/soc/codecs/cs4271.c:361:9: note: in expansion of macro 'snd_soc_dai_stream_activity'
           !snd_soc_dai_stream_activity(dai, SNDRV_PCM_STREAM_PLAYBACK])) {
            ^~~~~~~~~~~~~~~~~~~~~~~~~~~
>> sound/soc/codecs/cs4271.c:361:69: error: expected statement before ')' token
           !snd_soc_dai_stream_activity(dai, SNDRV_PCM_STREAM_PLAYBACK])) {
                                                                        ^

vim +141 include/sound/soc-dai.h

   136	
   137	/* Digital Audio Interface mute */
   138	int snd_soc_dai_digital_mute(struct snd_soc_dai *dai, int mute,
   139				     int direction);
   140	int snd_soc_dai_activity(struct snd_soc_dai *dai);
 > 141	#define snd_soc_dai_stream_activity(dai, stream) (dai)->stream_active[stream]
   142	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 38533 bytes --]

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH 17/17] ASoC: soc-dai: add snd_soc_dai_stream_activity()
  2020-05-11  5:58 ` [PATCH 17/17] ASoC: soc-dai: add snd_soc_dai_stream_activity() Kuninori Morimoto
  2020-05-11  8:12   ` kbuild test robot
@ 2020-05-11  8:12   ` kbuild test robot
  1 sibling, 0 replies; 28+ messages in thread
From: kbuild test robot @ 2020-05-11  8:12 UTC (permalink / raw)
  To: kbuild-all

[-- Attachment #1: Type: text/plain, Size: 5378 bytes --]

Hi Kuninori,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on asoc/for-next]
[also build test ERROR on next-20200508]
[cannot apply to sound/for-next spi/for-next v5.7-rc5]
[if your patch is applied to the wrong git tree, please drop us a note to help
improve the system. BTW, we also suggest to use '--base' option to specify the
base tree in git format-patch, please see https://stackoverflow.com/a/37406982]

url:    https://github.com/0day-ci/linux/commits/Kuninori-Morimoto/ASoC-cleanup-DAI-Component-activity/20200511-144543
base:   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next
config: powerpc64-randconfig-r034-20200511 (attached as .config)
compiler: powerpc-linux-gcc (GCC) 9.3.0
reproduce:
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day GCC_VERSION=9.3.0 make.cross ARCH=powerpc64 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kbuild test robot <lkp@intel.com>

All error/warnings (new ones prefixed by >>):

   sound/soc/codecs/cs4271.c: In function 'cs4271_hw_params':
>> sound/soc/codecs/cs4271.c:721: error: unterminated argument list invoking macro "if"
     721 | MODULE_LICENSE("GPL");
         | 
>> sound/soc/codecs/cs4271.c:721: error: expected '(' at end of input
     721 | MODULE_LICENSE("GPL");
         | 
         |(
>> sound/soc/codecs/cs4271.c:358:3: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
     358 |   if ((substream->stream == SNDRV_PCM_STREAM_PLAYBACK &&
         |   ^~
   sound/soc/codecs/cs4271.c:721: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
     721 | MODULE_LICENSE("GPL");
         | 
>> sound/soc/codecs/cs4271.c:358:3: error: expected declaration or statement at end of input
     358 |   if ((substream->stream == SNDRV_PCM_STREAM_PLAYBACK &&
         |   ^~
>> sound/soc/codecs/cs4271.c:358:3: error: expected declaration or statement at end of input
   sound/soc/codecs/cs4271.c:346:22: warning: unused variable 'val' [-Wunused-variable]
     346 |  unsigned int ratio, val;
         |                      ^~~
   sound/soc/codecs/cs4271.c:346:15: warning: unused variable 'ratio' [-Wunused-variable]
     346 |  unsigned int ratio, val;
         |               ^~~~~
   sound/soc/codecs/cs4271.c:345:9: warning: unused variable 'ret' [-Wunused-variable]
     345 |  int i, ret;
         |         ^~~
   sound/soc/codecs/cs4271.c:345:6: warning: unused variable 'i' [-Wunused-variable]
     345 |  int i, ret;
         |      ^
>> sound/soc/codecs/cs4271.c:358:3: warning: no return statement in function returning non-void [-Wreturn-type]
     358 |   if ((substream->stream == SNDRV_PCM_STREAM_PLAYBACK &&
         |   ^~
   At top level:
   sound/soc/codecs/cs4271.c:339:12: warning: 'cs4271_hw_params' defined but not used [-Wunused-function]
     339 | static int cs4271_hw_params(struct snd_pcm_substream *substream,
         |            ^~~~~~~~~~~~~~~~
   sound/soc/codecs/cs4271.c:307:30: warning: 'cs4271_clk_tab' defined but not used [-Wunused-variable]
     307 | static struct cs4271_clk_cfg cs4271_clk_tab[] = {
         |                              ^~~~~~~~~~~~~~
   sound/soc/codecs/cs4271.c:290:12: warning: 'cs4271_put_deemph' defined but not used [-Wunused-function]
     290 | static int cs4271_put_deemph(struct snd_kcontrol *kcontrol,
         |            ^~~~~~~~~~~~~~~~~
   sound/soc/codecs/cs4271.c:280:12: warning: 'cs4271_get_deemph' defined but not used [-Wunused-function]
     280 | static int cs4271_get_deemph(struct snd_kcontrol *kcontrol,
         |            ^~~~~~~~~~~~~~~~~
   sound/soc/codecs/cs4271.c:207:12: warning: 'cs4271_set_dai_fmt' defined but not used [-Wunused-function]
     207 | static int cs4271_set_dai_fmt(struct snd_soc_dai *codec_dai,
         |            ^~~~~~~~~~~~~~~~~~
   sound/soc/codecs/cs4271.c:197:12: warning: 'cs4271_set_dai_sysclk' defined but not used [-Wunused-function]
     197 | static int cs4271_set_dai_sysclk(struct snd_soc_dai *codec_dai,
         |            ^~~~~~~~~~~~~~~~~~~~~
   sound/soc/codecs/cs4271.c:147:13: warning: 'cs4271_volatile_reg' defined but not used [-Wunused-function]
     147 | static bool cs4271_volatile_reg(struct device *dev, unsigned int reg)
         |             ^~~~~~~~~~~~~~~~~~~

vim +/if +721 sound/soc/codecs/cs4271.c

67b22517d8e48a9 Alexander Sverdlin 2011-01-19  718  
67b22517d8e48a9 Alexander Sverdlin 2011-01-19  719  MODULE_AUTHOR("Alexander Sverdlin <subaparts@yandex.ru>");
67b22517d8e48a9 Alexander Sverdlin 2011-01-19  720  MODULE_DESCRIPTION("Cirrus Logic CS4271 ALSA SoC Codec Driver");
67b22517d8e48a9 Alexander Sverdlin 2011-01-19 @721  MODULE_LICENSE("GPL");

:::::: The code at line 721 was first introduced by commit
:::::: 67b22517d8e48a97e1d2ab10d095c538bbb2374c ASoC: CS4271 codec support

:::::: TO: Alexander Sverdlin <subaparts@yandex.ru>
:::::: CC: Mark Brown <broonie@opensource.wolfsonmicro.com>

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 30138 bytes --]

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH 03/17] ASoC: soc-dai: add snd_soc_component_activity()
  2020-05-11  5:56 ` [PATCH 03/17] ASoC: soc-dai: add snd_soc_component_activity() Kuninori Morimoto
@ 2020-05-11 19:07   ` Pierre-Louis Bossart
  2020-05-11 22:47   ` Ranjani Sridharan
  1 sibling, 0 replies; 28+ messages in thread
From: Pierre-Louis Bossart @ 2020-05-11 19:07 UTC (permalink / raw)
  To: Kuninori Morimoto, Mark Brown; +Cc: Linux-ALSA



On 5/11/20 12:56 AM, Kuninori Morimoto wrote:
> 
> From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
> 
> Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
> ---
>   include/sound/soc-component.h | 1 +
>   sound/soc/soc-pcm.c           | 2 +-
>   2 files changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/include/sound/soc-component.h b/include/sound/soc-component.h
> index 864983b09846..29b0c2c1d2db 100644
> --- a/include/sound/soc-component.h
> +++ b/include/sound/soc-component.h
> @@ -358,6 +358,7 @@ int snd_soc_component_stream_event(struct snd_soc_component *component,
>   				   int event);
>   int snd_soc_component_set_bias_level(struct snd_soc_component *component,
>   				     enum snd_soc_bias_level level);
> +#define snd_soc_component_activity(component)	((component)->active)

this patch would need to be added as patch2, before 
snd_soc_component_activity() is used to avoid breaking bisection

>   
>   #ifdef CONFIG_REGMAP
>   void snd_soc_component_init_regmap(struct snd_soc_component *component,
> diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c
> index e923e3746fec..420595356111 100644
> --- a/sound/soc/soc-pcm.c
> +++ b/sound/soc/soc-pcm.c
> @@ -267,7 +267,7 @@ static void snd_soc_runtime_action(struct snd_soc_pcm_runtime *rtd,
>   	for_each_rtd_dais(rtd, i, dai) {
>   		dai->stream_active[stream] += action;
>   		dai->active += action;
> -		dai->component->active += action;
> +		snd_soc_component_activity(dai->component) += action;
>   	}
>   }
>   
> 

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH 01/17] ASoC: soc-dai: add snd_soc_dai_activity()
  2020-05-11  5:56 ` [PATCH 01/17] ASoC: soc-dai: add snd_soc_dai_activity() Kuninori Morimoto
@ 2020-05-11 22:37   ` Ranjani Sridharan
  2020-05-11 22:42   ` Ranjani Sridharan
  1 sibling, 0 replies; 28+ messages in thread
From: Ranjani Sridharan @ 2020-05-11 22:37 UTC (permalink / raw)
  To: Kuninori Morimoto, Mark Brown; +Cc: Linux-ALSA

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


^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH 01/17] ASoC: soc-dai: add snd_soc_dai_activity()
  2020-05-11  5:56 ` [PATCH 01/17] ASoC: soc-dai: add snd_soc_dai_activity() Kuninori Morimoto
  2020-05-11 22:37   ` Ranjani Sridharan
@ 2020-05-11 22:42   ` Ranjani Sridharan
  1 sibling, 0 replies; 28+ messages in thread
From: Ranjani Sridharan @ 2020-05-11 22:42 UTC (permalink / raw)
  To: Kuninori Morimoto, Mark Brown; +Cc: Linux-ALSA

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)


^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH 02/17] ASoC: use snd_soc_dai/component_activity()
  2020-05-11  5:56 ` [PATCH 02/17] ASoC: use snd_soc_dai/component_activity() Kuninori Morimoto
@ 2020-05-11 22:44   ` Ranjani Sridharan
  2020-05-11 23:53     ` Kuninori Morimoto
  0 siblings, 1 reply; 28+ messages in thread
From: Ranjani Sridharan @ 2020-05-11 22:44 UTC (permalink / raw)
  To: Kuninori Morimoto, Mark Brown; +Cc: Linux-ALSA

On Mon, 2020-05-11 at 14:56 +0900, Kuninori Morimoto wrote:
> From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
> 
> Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
> ---
>  sound/soc/soc-compress.c |  4 ++--
>  sound/soc/soc-core.c     |  4 ++--
>  sound/soc/soc-dapm.c     |  8 ++++----
>  sound/soc/soc-pcm.c      | 14 +++++++-------
>  4 files changed, 15 insertions(+), 15 deletions(-)
> 
> diff --git a/sound/soc/soc-compress.c b/sound/soc/soc-compress.c
> index def3ae78b4a7..92d70e75a5a4 100644
> --- a/sound/soc/soc-compress.c
> +++ b/sound/soc/soc-compress.c
> @@ -231,10 +231,10 @@ static int soc_compr_free(struct
> snd_compr_stream *cstream)
>  
>  	snd_soc_dai_digital_mute(codec_dai, 1, cstream->direction);
>  
> -	if (!cpu_dai->active)
> +	if (!snd_soc_dai_activity(cpu_dai))
I have a feeling this is probably incorrect. snd_soc_dai_activity()
checks for stream_active count which is different from snd_soc_dai's
active member, isnt it?

Thanks,
Ranjani


^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH 03/17] ASoC: soc-dai: add snd_soc_component_activity()
  2020-05-11  5:56 ` [PATCH 03/17] ASoC: soc-dai: add snd_soc_component_activity() Kuninori Morimoto
  2020-05-11 19:07   ` Pierre-Louis Bossart
@ 2020-05-11 22:47   ` Ranjani Sridharan
  1 sibling, 0 replies; 28+ messages in thread
From: Ranjani Sridharan @ 2020-05-11 22:47 UTC (permalink / raw)
  To: Kuninori Morimoto, Mark Brown; +Cc: Linux-ALSA

On Mon, 2020-05-11 at 14:56 +0900, Kuninori Morimoto wrote:
> From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
> 
> Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
> ---
>  include/sound/soc-component.h | 1 +
>  sound/soc/soc-pcm.c           | 2 +-
>  2 files changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/include/sound/soc-component.h b/include/sound/soc-
> component.h
> index 864983b09846..29b0c2c1d2db 100644
> --- a/include/sound/soc-component.h
> +++ b/include/sound/soc-component.h
> @@ -358,6 +358,7 @@ int snd_soc_component_stream_event(struct
> snd_soc_component *component,
>  				   int event);
>  int snd_soc_component_set_bias_level(struct snd_soc_component
> *component,
>  				     enum snd_soc_bias_level level);
> +#define snd_soc_component_activity(component)	((component)-
> >active)
>  
>  #ifdef CONFIG_REGMAP
>  void snd_soc_component_init_regmap(struct snd_soc_component
> *component,
> diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c
> index e923e3746fec..420595356111 100644
> --- a/sound/soc/soc-pcm.c
> +++ b/sound/soc/soc-pcm.c
> @@ -267,7 +267,7 @@ static void snd_soc_runtime_action(struct
> snd_soc_pcm_runtime *rtd,
>  	for_each_rtd_dais(rtd, i, dai) {
>  		dai->stream_active[stream] += action;
>  		dai->active += action;
> -		dai->component->active += action;
> +		snd_soc_component_activity(dai->component) += action;

This is not very easy to comprehend. Maybe we could introduce another
macro for updating the usage count for the component and use that
instead? something like, snd_soc_component_update_usage_count(dai-
>component, action)?
Thanks,
Ranjani


^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH 02/17] ASoC: use snd_soc_dai/component_activity()
  2020-05-11 22:44   ` Ranjani Sridharan
@ 2020-05-11 23:53     ` Kuninori Morimoto
  2020-05-12  0:55       ` Ranjani Sridharan
  0 siblings, 1 reply; 28+ messages in thread
From: Kuninori Morimoto @ 2020-05-11 23:53 UTC (permalink / raw)
  To: Ranjani Sridharan; +Cc: Linux-ALSA, Mark Brown


Hi Ranjani

Thank you for reviewing

> > -	if (!cpu_dai->active)
> > +	if (!snd_soc_dai_activity(cpu_dai))
> I have a feeling this is probably incorrect. snd_soc_dai_activity()
> checks for stream_active count which is different from snd_soc_dai's
> active member, isnt it?

OK, let me check.
The original code is like this

	static void snd_soc_runtime_action(struct snd_soc_pcm_runtime *rtd,
					   int stream, int action)
	{
		...
		for_each_rtd_dais(rtd, i, dai) {
			dai->stream_active[stream] += action;
			dai->active += action;
			...
		}
	}

	void snd_soc_runtime_activate(...)
	{
		snd_soc_runtime_action(rtd, stream, 1);
	}

	void snd_soc_runtime_deactivate(...)
	{
		snd_soc_runtime_action(rtd, stream, -1);
	}


Basically, ASoC calls
snd_soc_runtime_activate()   for activate count up, and,
snd_soc_runtime_deactivate() for activate count down.

I think snd_soc_dai_activity() is correct, *so far*.

Exceptions are
soc-dapm.c :: snd_soc_dai_link_event_pre_pmu()
soc-dapm.c :: snd_soc_dai_link_event()

	snd_soc_dai_link_event_pre_pmu(...)
	{
		...
		snd_soc_dapm_widget_for_each_source_path(w, path) {
			...
			source->active++;
		}
		...
		snd_soc_dapm_widget_for_each_sink_path(w, path) {
			...
			sink->active++;
		}
		...
	}

	snd_soc_dai_link_event(...)
	{
		...
		snd_soc_dapm_widget_for_each_source_path(w, path) {
			...
			source->active--;
			...
		}

		snd_soc_dapm_widget_for_each_sink_path(w, path) {
			...
			sink->active--;
			...
		}
		...
	}
	
Only these directly access to dai->active, *without* thinking stream_active.
I think it should use snd_soc_runtime_activate() / snd_soc_runtime_deactivate().
My patch cares it... Oops !!
I thought my patch cares it, but not enough (= [02/17]).

Can you agree below ?
	1) use runtime_activate()/deactivate() at above functions.
	2) apply my original patches on top of 1)
	   then, update git-log to explain above

Thank you for your help !!

Best regards
---
Kuninori Morimoto

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH 02/17] ASoC: use snd_soc_dai/component_activity()
  2020-05-11 23:53     ` Kuninori Morimoto
@ 2020-05-12  0:55       ` Ranjani Sridharan
  2020-05-12  4:06         ` Kuninori Morimoto
  0 siblings, 1 reply; 28+ messages in thread
From: Ranjani Sridharan @ 2020-05-12  0:55 UTC (permalink / raw)
  To: Kuninori Morimoto; +Cc: Linux-ALSA, Mark Brown

On Tue, 2020-05-12 at 08:53 +0900, Kuninori Morimoto wrote:
> Hi Ranjani
> 
> Thank you for reviewing
> 
> > > -	if (!cpu_dai->active)
> > > +	if (!snd_soc_dai_activity(cpu_dai))
> > 
> > I have a feeling this is probably incorrect. snd_soc_dai_activity()
> > checks for stream_active count which is different from
> > snd_soc_dai's
> > active member, isnt it?
> 
> OK, let me check.
> The original code is like this
> 
> 	static void snd_soc_runtime_action(struct snd_soc_pcm_runtime
> *rtd,
> 					   int stream, int action)
> 	{
> 		...
> 		for_each_rtd_dais(rtd, i, dai) {
> 			dai->stream_active[stream] += action;
> 			dai->active += action;
> 			...
> 		}
> 	}
> 
> 	void snd_soc_runtime_activate(...)
> 	{
> 		snd_soc_runtime_action(rtd, stream, 1);
> 	}
> 
> 	void snd_soc_runtime_deactivate(...)
> 	{
> 		snd_soc_runtime_action(rtd, stream, -1);
> 	}
> 
> 
> Basically, ASoC calls
> snd_soc_runtime_activate()   for activate count up, and,
> snd_soc_runtime_deactivate() for activate count down.
> 
> I think snd_soc_dai_activity() is correct, *so far*.
> 
> Exceptions are
> soc-dapm.c :: snd_soc_dai_link_event_pre_pmu()
> soc-dapm.c :: snd_soc_dai_link_event()
> 
> 	snd_soc_dai_link_event_pre_pmu(...)
> 	{
> 		...
> 		snd_soc_dapm_widget_for_each_source_path(w, path) {
> 			...
> 			source->active++;
> 		}
> 		...
> 		snd_soc_dapm_widget_for_each_sink_path(w, path) {
> 			...
> 			sink->active++;
> 		}
> 		...
> 	}
> 
> 	snd_soc_dai_link_event(...)
> 	{
> 		...
> 		snd_soc_dapm_widget_for_each_source_path(w, path) {
> 			...
> 			source->active--;
> 			...
> 		}
> 
> 		snd_soc_dapm_widget_for_each_sink_path(w, path) {
> 			...
> 			sink->active--;
> 			...
> 		}
> 		...
> 	}
> 	
> Only these directly access to dai->active, *without* thinking
> stream_active.
> I think it should use snd_soc_runtime_activate() /
> snd_soc_runtime_deactivate().
> My patch cares it... Oops !!
> I thought my patch cares it, but not enough (= [02/17]).
> 
> Can you agree below ?
> 	1) use runtime_activate()/deactivate() at above functions.
I am wondering what the original intention for having separate
stream_active and active members for snd_soc_dai was. With your
proposal there wouldnt be a need for "active" anymore, isnt it?

Thanks,
Ranjani


^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH 02/17] ASoC: use snd_soc_dai/component_activity()
  2020-05-12  0:55       ` Ranjani Sridharan
@ 2020-05-12  4:06         ` Kuninori Morimoto
  0 siblings, 0 replies; 28+ messages in thread
From: Kuninori Morimoto @ 2020-05-12  4:06 UTC (permalink / raw)
  To: Ranjani Sridharan; +Cc: Linux-ALSA, Mark Brown


Hi Ranjani

Thank you for feedback

> > I think snd_soc_dai_activity() is correct, *so far*.
> > 
> > Exceptions are
> > soc-dapm.c :: snd_soc_dai_link_event_pre_pmu()
> > soc-dapm.c :: snd_soc_dai_link_event()
(snip)
> > Can you agree below ?
> > 	1) use runtime_activate()/deactivate() at above functions.
> I am wondering what the original intention for having separate
> stream_active and active members for snd_soc_dai was.

I'm not sure...

> With your proposal there wouldnt be a need for "active" anymore, isnt it?

Yeah, thus, my patch will remove it.

Thank you for your help !!

Best regards
---
Kuninori Morimoto

^ permalink raw reply	[flat|nested] 28+ messages in thread

end of thread, other threads:[~2020-05-12  4:07 UTC | newest]

Thread overview: 28+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-11  5:55 [PATCH 00/17] ASoC: cleanup DAI/Component activity Kuninori Morimoto
2020-05-11  5:56 ` [PATCH 01/17] ASoC: soc-dai: add snd_soc_dai_activity() Kuninori Morimoto
2020-05-11 22:37   ` Ranjani Sridharan
2020-05-11 22:42   ` Ranjani Sridharan
2020-05-11  5:56 ` [PATCH 02/17] ASoC: use snd_soc_dai/component_activity() Kuninori Morimoto
2020-05-11 22:44   ` Ranjani Sridharan
2020-05-11 23:53     ` Kuninori Morimoto
2020-05-12  0:55       ` Ranjani Sridharan
2020-05-12  4:06         ` Kuninori Morimoto
2020-05-11  5:56 ` [PATCH 03/17] ASoC: soc-dai: add snd_soc_component_activity() Kuninori Morimoto
2020-05-11 19:07   ` Pierre-Louis Bossart
2020-05-11 22:47   ` Ranjani Sridharan
2020-05-11  5:56 ` [PATCH 04/17] ASoC: atomel: use snd_soc_dai/component_activity() Kuninori Morimoto
2020-05-11  5:56 ` [PATCH 05/17] ASoC: bcm: " Kuninori Morimoto
2020-05-11  5:57 ` [PATCH 06/17] ASoC: cirrus: " Kuninori Morimoto
2020-05-11  5:57 ` [PATCH 07/17] ASoC: codecs: " Kuninori Morimoto
2020-05-11  5:57 ` [PATCH 08/17] ASoC: fsl: " Kuninori Morimoto
2020-05-11  5:57 ` [PATCH 09/17] ASoC: intel: " Kuninori Morimoto
2020-05-11  5:57 ` [PATCH 10/17] ASoC: jz4740: " Kuninori Morimoto
2020-05-11  5:57 ` [PATCH 11/17] ASoC: mediatek: " Kuninori Morimoto
2020-05-11  5:57 ` [PATCH 12/17] ASoC: meson: " Kuninori Morimoto
2020-05-11  5:57 ` [PATCH 13/17] ASoC: pxa: " Kuninori Morimoto
2020-05-11  5:57 ` [PATCH 14/17] ASoC: ti: " Kuninori Morimoto
2020-05-11  5:57 ` [PATCH 15/17] ASoC: uniphier: " Kuninori Morimoto
2020-05-11  5:57 ` [PATCH 16/17] ASoC: cleanup dai / component active code Kuninori Morimoto
2020-05-11  5:58 ` [PATCH 17/17] ASoC: soc-dai: add snd_soc_dai_stream_activity() Kuninori Morimoto
2020-05-11  8:12   ` kbuild test robot
2020-05-11  8:12   ` kbuild test robot

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.