All of lore.kernel.org
 help / color / mirror / Atom feed
From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
To: Mark Brown <broonie@kernel.org>
Cc: Linux-ALSA <alsa-devel@alsa-project.org>, Lars-Peter <lars@metafoo.de>
Subject: [PATCH 06/13] ASoC: snd_soc_component_driver has snd_compr_ops
Date: Fri, 1 Sep 2017 05:33:31 +0000	[thread overview]
Message-ID: <87shg7m1kt.wl%kuninori.morimoto.gx@renesas.com> (raw)
In-Reply-To: <871snrngcu.wl%kuninori.morimoto.gx@renesas.com>


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

snd_soc_platform_driver has snd_compr_ops,
and it will be replaced into snd_soc_component_driver in the future.
To prepare it, component driver has it.

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

diff --git a/include/sound/soc.h b/include/sound/soc.h
index 2acb566..ae0a27f 100644
--- a/include/sound/soc.h
+++ b/include/sound/soc.h
@@ -827,6 +827,7 @@ struct snd_soc_component_driver {
 			      enum snd_soc_bias_level level);
 
 	const struct snd_pcm_ops *ops;
+	const struct snd_compr_ops *compr_ops;
 
 	/* probe ordering - for components with runtime dependencies */
 	int probe_order;
diff --git a/sound/soc/soc-compress.c b/sound/soc/soc-compress.c
index 2cb8d3b..d9b1e64 100644
--- a/sound/soc/soc-compress.c
+++ b/sound/soc/soc-compress.c
@@ -30,8 +30,10 @@ static int soc_compr_open(struct snd_compr_stream *cstream)
 {
 	struct snd_soc_pcm_runtime *rtd = cstream->private_data;
 	struct snd_soc_platform *platform = rtd->platform;
+	struct snd_soc_component *component;
+	struct snd_soc_rtdcom_list *rtdcom;
 	struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
-	int ret = 0;
+	int ret = 0, __ret;
 
 	mutex_lock_nested(&rtd->pcm_mutex, rtd->pcm_subclass);
 
@@ -44,7 +46,7 @@ static int soc_compr_open(struct snd_compr_stream *cstream)
 		}
 	}
 
-	if (platform->driver->compr_ops && platform->driver->compr_ops->open) {
+	if (platform && platform->driver->compr_ops && platform->driver->compr_ops->open) {
 		ret = platform->driver->compr_ops->open(cstream);
 		if (ret < 0) {
 			pr_err("compress asoc: can't open platform %s\n",
@@ -53,6 +55,27 @@ static int soc_compr_open(struct snd_compr_stream *cstream)
 		}
 	}
 
+	for_each_rtdcom(rtd, rtdcom) {
+		component = rtdcom->component;
+
+		/* ignore duplication for now */
+		if (platform && (component == &platform->component))
+			continue;
+
+		if (!component->driver->compr_ops ||
+		    !component->driver->compr_ops->open)
+			continue;
+
+		__ret = component->driver->compr_ops->open(cstream);
+		if (__ret < 0) {
+			pr_err("compress asoc: can't open platform %s\n",
+			       component->name);
+			ret = __ret;
+		}
+	}
+	if (ret < 0)
+		goto machine_err;
+
 	if (rtd->dai_link->compr_ops && rtd->dai_link->compr_ops->startup) {
 		ret = rtd->dai_link->compr_ops->startup(cstream);
 		if (ret < 0) {
@@ -68,7 +91,21 @@ static int soc_compr_open(struct snd_compr_stream *cstream)
 	return 0;
 
 machine_err:
-	if (platform->driver->compr_ops && platform->driver->compr_ops->free)
+	for_each_rtdcom(rtd, rtdcom) {
+		component = rtdcom->component;
+
+		/* ignore duplication for now */
+		if (platform && (component == &platform->component))
+			continue;
+
+		if (!component->driver->compr_ops ||
+		    !component->driver->compr_ops->free)
+			continue;
+
+		component->driver->compr_ops->free(cstream);
+	}
+
+	if (platform && platform->driver->compr_ops && platform->driver->compr_ops->free)
 		platform->driver->compr_ops->free(cstream);
 plat_err:
 	if (cpu_dai->driver->cops && cpu_dai->driver->cops->shutdown)
@@ -84,11 +121,13 @@ static int soc_compr_open_fe(struct snd_compr_stream *cstream)
 	struct snd_pcm_substream *fe_substream =
 		 fe->pcm->streams[cstream->direction].substream;
 	struct snd_soc_platform *platform = fe->platform;
+	struct snd_soc_component *component;
+	struct snd_soc_rtdcom_list *rtdcom;
 	struct snd_soc_dai *cpu_dai = fe->cpu_dai;
 	struct snd_soc_dpcm *dpcm;
 	struct snd_soc_dapm_widget_list *list;
 	int stream;
-	int ret = 0;
+	int ret = 0, __ret;
 
 	if (cstream->direction == SND_COMPRESS_PLAYBACK)
 		stream = SNDRV_PCM_STREAM_PLAYBACK;
@@ -107,7 +146,7 @@ static int soc_compr_open_fe(struct snd_compr_stream *cstream)
 	}
 
 
-	if (platform->driver->compr_ops && platform->driver->compr_ops->open) {
+	if (platform && platform->driver->compr_ops && platform->driver->compr_ops->open) {
 		ret = platform->driver->compr_ops->open(cstream);
 		if (ret < 0) {
 			pr_err("compress asoc: can't open platform %s\n",
@@ -116,6 +155,27 @@ static int soc_compr_open_fe(struct snd_compr_stream *cstream)
 		}
 	}
 
+	for_each_rtdcom(fe, rtdcom) {
+		component = rtdcom->component;
+
+		/* ignore duplication for now */
+		if (platform && (component == &platform->component))
+			continue;
+
+		if (!component->driver->compr_ops ||
+		    !component->driver->compr_ops->open)
+			continue;
+
+		__ret = component->driver->compr_ops->open(cstream);
+		if (__ret < 0) {
+			pr_err("compress asoc: can't open platform %s\n",
+			       component->name);
+			ret = __ret;
+		}
+	}
+	if (ret < 0)
+		goto machine_err;
+
 	if (fe->dai_link->compr_ops && fe->dai_link->compr_ops->startup) {
 		ret = fe->dai_link->compr_ops->startup(cstream);
 		if (ret < 0) {
@@ -167,7 +227,21 @@ static int soc_compr_open_fe(struct snd_compr_stream *cstream)
 	if (fe->dai_link->compr_ops && fe->dai_link->compr_ops->shutdown)
 		fe->dai_link->compr_ops->shutdown(cstream);
 machine_err:
-	if (platform->driver->compr_ops && platform->driver->compr_ops->free)
+	for_each_rtdcom(fe, rtdcom) {
+		component = rtdcom->component;
+
+		/* ignore duplication for now */
+		if (platform && (component == &platform->component))
+			continue;
+
+		if (!component->driver->compr_ops ||
+		    !component->driver->compr_ops->free)
+			continue;
+
+		component->driver->compr_ops->free(cstream);
+	}
+
+	if (platform && platform->driver->compr_ops && platform->driver->compr_ops->free)
 		platform->driver->compr_ops->free(cstream);
 plat_err:
 	if (cpu_dai->driver->cops && cpu_dai->driver->cops->shutdown)
@@ -210,6 +284,8 @@ static int soc_compr_free(struct snd_compr_stream *cstream)
 {
 	struct snd_soc_pcm_runtime *rtd = cstream->private_data;
 	struct snd_soc_platform *platform = rtd->platform;
+	struct snd_soc_component *component;
+	struct snd_soc_rtdcom_list *rtdcom;
 	struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
 	struct snd_soc_dai *codec_dai = rtd->codec_dai;
 	int stream;
@@ -235,7 +311,21 @@ static int soc_compr_free(struct snd_compr_stream *cstream)
 	if (rtd->dai_link->compr_ops && rtd->dai_link->compr_ops->shutdown)
 		rtd->dai_link->compr_ops->shutdown(cstream);
 
-	if (platform->driver->compr_ops && platform->driver->compr_ops->free)
+	for_each_rtdcom(rtd, rtdcom) {
+		component = rtdcom->component;
+
+		/* ignore duplication for now */
+		if (platform && (component == &platform->component))
+			continue;
+
+		if (!component->driver->compr_ops ||
+		    !component->driver->compr_ops->free)
+			continue;
+
+		component->driver->compr_ops->free(cstream);
+	}
+
+	if (platform && platform->driver->compr_ops && platform->driver->compr_ops->free)
 		platform->driver->compr_ops->free(cstream);
 
 	if (cpu_dai->driver->cops && cpu_dai->driver->cops->shutdown)
@@ -267,6 +357,8 @@ static int soc_compr_free_fe(struct snd_compr_stream *cstream)
 {
 	struct snd_soc_pcm_runtime *fe = cstream->private_data;
 	struct snd_soc_platform *platform = fe->platform;
+	struct snd_soc_component *component;
+	struct snd_soc_rtdcom_list *rtdcom;
 	struct snd_soc_dai *cpu_dai = fe->cpu_dai;
 	struct snd_soc_dpcm *dpcm;
 	int stream, ret;
@@ -304,9 +396,23 @@ static int soc_compr_free_fe(struct snd_compr_stream *cstream)
 	if (fe->dai_link->compr_ops && fe->dai_link->compr_ops->shutdown)
 		fe->dai_link->compr_ops->shutdown(cstream);
 
-	if (platform->driver->compr_ops && platform->driver->compr_ops->free)
+	if (platform && platform->driver->compr_ops && platform->driver->compr_ops->free)
 		platform->driver->compr_ops->free(cstream);
 
+	for_each_rtdcom(fe, rtdcom) {
+		component = rtdcom->component;
+
+		/* ignore duplication for now */
+		if (platform && (component == &platform->component))
+			continue;
+
+		if (!component->driver->compr_ops ||
+		    !component->driver->compr_ops->free)
+			continue;
+
+		component->driver->compr_ops->free(cstream);
+	}
+
 	if (cpu_dai->driver->cops && cpu_dai->driver->cops->shutdown)
 		cpu_dai->driver->cops->shutdown(cstream, cpu_dai);
 
@@ -319,18 +425,38 @@ static int soc_compr_trigger(struct snd_compr_stream *cstream, int cmd)
 
 	struct snd_soc_pcm_runtime *rtd = cstream->private_data;
 	struct snd_soc_platform *platform = rtd->platform;
+	struct snd_soc_component *component;
+	struct snd_soc_rtdcom_list *rtdcom;
 	struct snd_soc_dai *codec_dai = rtd->codec_dai;
 	struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
-	int ret = 0;
+	int ret = 0, __ret;
 
 	mutex_lock_nested(&rtd->pcm_mutex, rtd->pcm_subclass);
 
-	if (platform->driver->compr_ops && platform->driver->compr_ops->trigger) {
+	if (platform && platform->driver->compr_ops && platform->driver->compr_ops->trigger) {
 		ret = platform->driver->compr_ops->trigger(cstream, cmd);
 		if (ret < 0)
 			goto out;
 	}
 
+	for_each_rtdcom(rtd, rtdcom) {
+		component = rtdcom->component;
+
+		/* ignore duplication for now */
+		if (platform && (component == &platform->component))
+			continue;
+
+		if (!component->driver->compr_ops ||
+		    !component->driver->compr_ops->trigger)
+			continue;
+
+		__ret = component->driver->compr_ops->trigger(cstream, cmd);
+		if (__ret < 0)
+			ret = __ret;
+	}
+	if (ret < 0)
+		goto out;
+
 	if (cpu_dai->driver->cops && cpu_dai->driver->cops->trigger)
 		cpu_dai->driver->cops->trigger(cstream, cmd, cpu_dai);
 
@@ -353,16 +479,36 @@ static int soc_compr_trigger_fe(struct snd_compr_stream *cstream, int cmd)
 {
 	struct snd_soc_pcm_runtime *fe = cstream->private_data;
 	struct snd_soc_platform *platform = fe->platform;
+	struct snd_soc_component *component;
+	struct snd_soc_rtdcom_list *rtdcom;
 	struct snd_soc_dai *cpu_dai = fe->cpu_dai;
-	int ret = 0, stream;
+	int ret = 0, __ret, stream;
 
 	if (cmd == SND_COMPR_TRIGGER_PARTIAL_DRAIN ||
 		cmd == SND_COMPR_TRIGGER_DRAIN) {
 
-		if (platform->driver->compr_ops &&
+		if (platform &&
+		    platform->driver->compr_ops &&
 		    platform->driver->compr_ops->trigger)
 			return platform->driver->compr_ops->trigger(cstream,
 								    cmd);
+
+		for_each_rtdcom(fe, rtdcom) {
+			component = rtdcom->component;
+
+			/* ignore duplication for now */
+			if (platform && (component == &platform->component))
+				continue;
+
+			if (!component->driver->compr_ops ||
+			    !component->driver->compr_ops->trigger)
+				continue;
+
+			__ret = component->driver->compr_ops->trigger(cstream, cmd);
+			if (__ret < 0)
+				ret = __ret;
+		}
+		return ret;
 	}
 
 	if (cstream->direction == SND_COMPRESS_PLAYBACK)
@@ -379,12 +525,30 @@ static int soc_compr_trigger_fe(struct snd_compr_stream *cstream, int cmd)
 			goto out;
 	}
 
-	if (platform->driver->compr_ops && platform->driver->compr_ops->trigger) {
+	if (platform && platform->driver->compr_ops && platform->driver->compr_ops->trigger) {
 		ret = platform->driver->compr_ops->trigger(cstream, cmd);
 		if (ret < 0)
 			goto out;
 	}
 
+	for_each_rtdcom(fe, rtdcom) {
+		component = rtdcom->component;
+
+		/* ignore duplication for now */
+		if (platform && (component == &platform->component))
+			continue;
+
+		if (!component->driver->compr_ops ||
+		    !component->driver->compr_ops->trigger)
+			continue;
+
+		__ret = component->driver->compr_ops->trigger(cstream, cmd);
+		if (__ret < 0)
+			ret = __ret;
+	}
+	if (ret < 0)
+		goto out;
+
 	fe->dpcm[stream].runtime_update = SND_SOC_DPCM_UPDATE_FE;
 
 	ret = dpcm_be_dai_trigger(fe, stream, cmd);
@@ -415,8 +579,10 @@ static int soc_compr_set_params(struct snd_compr_stream *cstream,
 {
 	struct snd_soc_pcm_runtime *rtd = cstream->private_data;
 	struct snd_soc_platform *platform = rtd->platform;
+	struct snd_soc_component *component;
+	struct snd_soc_rtdcom_list *rtdcom;
 	struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
-	int ret = 0;
+	int ret = 0, __ret;
 
 	mutex_lock_nested(&rtd->pcm_mutex, rtd->pcm_subclass);
 
@@ -432,12 +598,30 @@ static int soc_compr_set_params(struct snd_compr_stream *cstream,
 			goto err;
 	}
 
-	if (platform->driver->compr_ops && platform->driver->compr_ops->set_params) {
+	if (platform && platform->driver->compr_ops && platform->driver->compr_ops->set_params) {
 		ret = platform->driver->compr_ops->set_params(cstream, params);
 		if (ret < 0)
 			goto err;
 	}
 
+	for_each_rtdcom(rtd, rtdcom) {
+		component = rtdcom->component;
+
+		/* ignore duplication for now */
+		if (platform && (component == &platform->component))
+			continue;
+
+		if (!component->driver->compr_ops ||
+		    !component->driver->compr_ops->set_params)
+			continue;
+
+		__ret = component->driver->compr_ops->set_params(cstream, params);
+		if (__ret < 0)
+			ret = __ret;
+	}
+	if (ret < 0)
+		goto err;
+
 	if (rtd->dai_link->compr_ops && rtd->dai_link->compr_ops->set_params) {
 		ret = rtd->dai_link->compr_ops->set_params(cstream);
 		if (ret < 0)
@@ -471,8 +655,10 @@ static int soc_compr_set_params_fe(struct snd_compr_stream *cstream,
 	struct snd_pcm_substream *fe_substream =
 		 fe->pcm->streams[cstream->direction].substream;
 	struct snd_soc_platform *platform = fe->platform;
+	struct snd_soc_component *component;
+	struct snd_soc_rtdcom_list *rtdcom;
 	struct snd_soc_dai *cpu_dai = fe->cpu_dai;
-	int ret = 0, stream;
+	int ret = 0, __ret, stream;
 
 	if (cstream->direction == SND_COMPRESS_PLAYBACK)
 		stream = SNDRV_PCM_STREAM_PLAYBACK;
@@ -487,12 +673,30 @@ static int soc_compr_set_params_fe(struct snd_compr_stream *cstream,
 			goto out;
 	}
 
-	if (platform->driver->compr_ops && platform->driver->compr_ops->set_params) {
+	if (platform && platform->driver->compr_ops && platform->driver->compr_ops->set_params) {
 		ret = platform->driver->compr_ops->set_params(cstream, params);
 		if (ret < 0)
 			goto out;
 	}
 
+	for_each_rtdcom(fe, rtdcom) {
+		component = rtdcom->component;
+
+		/* ignore duplication for now */
+		if (platform && (component == &platform->component))
+			continue;
+
+		if (!component->driver->compr_ops ||
+		    !component->driver->compr_ops->set_params)
+			continue;
+
+		__ret = component->driver->compr_ops->set_params(cstream, params);
+		if (__ret < 0)
+			ret = __ret;
+	}
+	if (ret < 0)
+		goto out;
+
 	if (fe->dai_link->compr_ops && fe->dai_link->compr_ops->set_params) {
 		ret = fe->dai_link->compr_ops->set_params(cstream);
 		if (ret < 0)
@@ -531,8 +735,10 @@ static int soc_compr_get_params(struct snd_compr_stream *cstream,
 {
 	struct snd_soc_pcm_runtime *rtd = cstream->private_data;
 	struct snd_soc_platform *platform = rtd->platform;
+	struct snd_soc_component *component;
+	struct snd_soc_rtdcom_list *rtdcom;
 	struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
-	int ret = 0;
+	int ret = 0, __ret;
 
 	mutex_lock_nested(&rtd->pcm_mutex, rtd->pcm_subclass);
 
@@ -542,8 +748,27 @@ static int soc_compr_get_params(struct snd_compr_stream *cstream,
 			goto err;
 	}
 
-	if (platform->driver->compr_ops && platform->driver->compr_ops->get_params)
+	if (platform && platform->driver->compr_ops && platform->driver->compr_ops->get_params) {
 		ret = platform->driver->compr_ops->get_params(cstream, params);
+		if (ret < 0)
+			goto err;
+	}
+
+	for_each_rtdcom(rtd, rtdcom) {
+		component = rtdcom->component;
+
+		/* ignore duplication for now */
+		if (platform && (component == &platform->component))
+			continue;
+
+		if (!component->driver->compr_ops ||
+		    !component->driver->compr_ops->get_params)
+			continue;
+
+		__ret = component->driver->compr_ops->get_params(cstream, params);
+		if (__ret < 0)
+			ret = __ret;
+	}
 
 err:
 	mutex_unlock(&rtd->pcm_mutex);
@@ -555,13 +780,35 @@ static int soc_compr_get_caps(struct snd_compr_stream *cstream,
 {
 	struct snd_soc_pcm_runtime *rtd = cstream->private_data;
 	struct snd_soc_platform *platform = rtd->platform;
-	int ret = 0;
+	struct snd_soc_component *component;
+	struct snd_soc_rtdcom_list *rtdcom;
+	int ret = 0, __ret;
 
 	mutex_lock_nested(&rtd->pcm_mutex, rtd->pcm_subclass);
 
-	if (platform->driver->compr_ops && platform->driver->compr_ops->get_caps)
+	if (platform && platform->driver->compr_ops && platform->driver->compr_ops->get_caps) {
 		ret = platform->driver->compr_ops->get_caps(cstream, caps);
+		if (ret < 0)
+			goto err;
+	}
+
+	for_each_rtdcom(rtd, rtdcom) {
+		component = rtdcom->component;
+
+		/* ignore duplication for now */
+		if (platform && (component == &platform->component))
+			continue;
 
+		if (!component->driver->compr_ops ||
+		    !component->driver->compr_ops->get_caps)
+			continue;
+
+		__ret = component->driver->compr_ops->get_caps(cstream, caps);
+		if (__ret < 0)
+			ret = __ret;
+	}
+
+err:
 	mutex_unlock(&rtd->pcm_mutex);
 	return ret;
 }
@@ -571,13 +818,35 @@ static int soc_compr_get_codec_caps(struct snd_compr_stream *cstream,
 {
 	struct snd_soc_pcm_runtime *rtd = cstream->private_data;
 	struct snd_soc_platform *platform = rtd->platform;
-	int ret = 0;
+	struct snd_soc_component *component;
+	struct snd_soc_rtdcom_list *rtdcom;
+	int ret = 0, __ret;
 
 	mutex_lock_nested(&rtd->pcm_mutex, rtd->pcm_subclass);
 
-	if (platform->driver->compr_ops && platform->driver->compr_ops->get_codec_caps)
+	if (platform && platform->driver->compr_ops && platform->driver->compr_ops->get_codec_caps) {
 		ret = platform->driver->compr_ops->get_codec_caps(cstream, codec);
+		if (ret < 0)
+			goto err;
+	}
+
+	for_each_rtdcom(rtd, rtdcom) {
+		component = rtdcom->component;
+
+		/* ignore duplication for now */
+		if (platform && (component == &platform->component))
+			continue;
 
+		if (!component->driver->compr_ops ||
+		    !component->driver->compr_ops->get_codec_caps)
+			continue;
+
+		__ret = component->driver->compr_ops->get_codec_caps(cstream, codec);
+		if (__ret < 0)
+			ret = __ret;
+	}
+
+err:
 	mutex_unlock(&rtd->pcm_mutex);
 	return ret;
 }
@@ -586,8 +855,10 @@ static int soc_compr_ack(struct snd_compr_stream *cstream, size_t bytes)
 {
 	struct snd_soc_pcm_runtime *rtd = cstream->private_data;
 	struct snd_soc_platform *platform = rtd->platform;
+	struct snd_soc_component *component;
+	struct snd_soc_rtdcom_list *rtdcom;
 	struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
-	int ret = 0;
+	int ret = 0, __ret;
 
 	mutex_lock_nested(&rtd->pcm_mutex, rtd->pcm_subclass);
 
@@ -597,8 +868,27 @@ static int soc_compr_ack(struct snd_compr_stream *cstream, size_t bytes)
 			goto err;
 	}
 
-	if (platform->driver->compr_ops && platform->driver->compr_ops->ack)
+	if (platform && platform->driver->compr_ops && platform->driver->compr_ops->ack) {
 		ret = platform->driver->compr_ops->ack(cstream, bytes);
+		if (ret < 0)
+			goto err;
+	}
+
+	for_each_rtdcom(rtd, rtdcom) {
+		component = rtdcom->component;
+
+		/* ignore duplication for now */
+		if (platform && (component == &platform->component))
+			continue;
+
+		if (!component->driver->compr_ops ||
+		    !component->driver->compr_ops->ack)
+			continue;
+
+		__ret = component->driver->compr_ops->ack(cstream, bytes);
+		if (__ret < 0)
+			ret = __ret;
+	}
 
 err:
 	mutex_unlock(&rtd->pcm_mutex);
@@ -610,7 +900,9 @@ static int soc_compr_pointer(struct snd_compr_stream *cstream,
 {
 	struct snd_soc_pcm_runtime *rtd = cstream->private_data;
 	struct snd_soc_platform *platform = rtd->platform;
-	int ret = 0;
+	struct snd_soc_component *component;
+	struct snd_soc_rtdcom_list *rtdcom;
+	int ret = 0, __ret;
 	struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
 
 	mutex_lock_nested(&rtd->pcm_mutex, rtd->pcm_subclass);
@@ -618,9 +910,29 @@ static int soc_compr_pointer(struct snd_compr_stream *cstream,
 	if (cpu_dai->driver->cops && cpu_dai->driver->cops->pointer)
 		cpu_dai->driver->cops->pointer(cstream, tstamp, cpu_dai);
 
-	if (platform->driver->compr_ops && platform->driver->compr_ops->pointer)
+	if (platform && platform->driver->compr_ops && platform->driver->compr_ops->pointer) {
 		ret = platform->driver->compr_ops->pointer(cstream, tstamp);
+		if (ret < 0)
+			goto err;
+	}
+
+	for_each_rtdcom(rtd, rtdcom) {
+		component = rtdcom->component;
+
+		/* ignore duplication for now */
+		if (platform && (component == &platform->component))
+			continue;
+
+		if (!component->driver->compr_ops ||
+		    !component->driver->compr_ops->pointer)
+			continue;
 
+		__ret = component->driver->compr_ops->pointer(cstream, tstamp);
+		if (__ret < 0)
+			ret = __ret;
+	}
+
+err:
 	mutex_unlock(&rtd->pcm_mutex);
 	return ret;
 }
@@ -630,13 +942,34 @@ static int soc_compr_copy(struct snd_compr_stream *cstream,
 {
 	struct snd_soc_pcm_runtime *rtd = cstream->private_data;
 	struct snd_soc_platform *platform = rtd->platform;
-	int ret = 0;
+	struct snd_soc_component *component;
+	struct snd_soc_rtdcom_list *rtdcom;
+	int ret = 0, __ret;
 
 	mutex_lock_nested(&rtd->pcm_mutex, rtd->pcm_subclass);
 
-	if (platform->driver->compr_ops && platform->driver->compr_ops->copy)
+	if (platform && platform->driver->compr_ops && platform->driver->compr_ops->copy) {
 		ret = platform->driver->compr_ops->copy(cstream, buf, count);
+		if (ret < 0)
+			goto err;
+	}
+
+	for_each_rtdcom(rtd, rtdcom) {
+		component = rtdcom->component;
+
+		/* ignore duplication for now */
+		if (platform && (component == &platform->component))
+			continue;
+
+		if (!component->driver->compr_ops ||
+		    !component->driver->compr_ops->copy)
+			continue;
 
+		__ret = component->driver->compr_ops->copy(cstream, buf, count);
+		if (__ret < 0)
+			ret = __ret;
+	}
+err:
 	mutex_unlock(&rtd->pcm_mutex);
 	return ret;
 }
@@ -646,8 +979,10 @@ static int soc_compr_set_metadata(struct snd_compr_stream *cstream,
 {
 	struct snd_soc_pcm_runtime *rtd = cstream->private_data;
 	struct snd_soc_platform *platform = rtd->platform;
+	struct snd_soc_component *component;
+	struct snd_soc_rtdcom_list *rtdcom;
 	struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
-	int ret = 0;
+	int ret = 0, __ret;
 
 	if (cpu_dai->driver->cops && cpu_dai->driver->cops->set_metadata) {
 		ret = cpu_dai->driver->cops->set_metadata(cstream, metadata, cpu_dai);
@@ -655,8 +990,27 @@ static int soc_compr_set_metadata(struct snd_compr_stream *cstream,
 			return ret;
 	}
 
-	if (platform->driver->compr_ops && platform->driver->compr_ops->set_metadata)
+	if (platform && platform->driver->compr_ops && platform->driver->compr_ops->set_metadata) {
 		ret = platform->driver->compr_ops->set_metadata(cstream, metadata);
+		if (ret < 0)
+			return ret;
+	}
+
+	for_each_rtdcom(rtd, rtdcom) {
+		component = rtdcom->component;
+
+		/* ignore duplication for now */
+		if (platform && (component == &platform->component))
+			continue;
+
+		if (!component->driver->compr_ops ||
+		    !component->driver->compr_ops->set_metadata)
+			continue;
+
+		__ret = component->driver->compr_ops->set_metadata(cstream, metadata);
+		if (__ret < 0)
+			ret = __ret;
+	}
 
 	return ret;
 }
@@ -666,8 +1020,10 @@ static int soc_compr_get_metadata(struct snd_compr_stream *cstream,
 {
 	struct snd_soc_pcm_runtime *rtd = cstream->private_data;
 	struct snd_soc_platform *platform = rtd->platform;
+	struct snd_soc_component *component;
+	struct snd_soc_rtdcom_list *rtdcom;
 	struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
-	int ret = 0;
+	int ret = 0, __ret;
 
 	if (cpu_dai->driver->cops && cpu_dai->driver->cops->get_metadata) {
 		ret = cpu_dai->driver->cops->get_metadata(cstream, metadata, cpu_dai);
@@ -675,8 +1031,27 @@ static int soc_compr_get_metadata(struct snd_compr_stream *cstream,
 			return ret;
 	}
 
-	if (platform->driver->compr_ops && platform->driver->compr_ops->get_metadata)
+	if (platform && platform->driver->compr_ops && platform->driver->compr_ops->get_metadata) {
 		ret = platform->driver->compr_ops->get_metadata(cstream, metadata);
+		if (ret < 0)
+			return ret;
+	}
+
+	for_each_rtdcom(rtd, rtdcom) {
+		component = rtdcom->component;
+
+		/* ignore duplication for now */
+		if (platform && (component == &platform->component))
+			continue;
+
+		if (!component->driver->compr_ops ||
+		    !component->driver->compr_ops->get_metadata)
+			continue;
+
+		__ret = component->driver->compr_ops->get_metadata(cstream, metadata);
+		if (__ret < 0)
+			ret = __ret;
+	}
 
 	return ret;
 }
@@ -723,6 +1098,8 @@ int snd_soc_new_compress(struct snd_soc_pcm_runtime *rtd, int num)
 {
 	struct snd_soc_codec *codec = rtd->codec;
 	struct snd_soc_platform *platform = rtd->platform;
+	struct snd_soc_component *component;
+	struct snd_soc_rtdcom_list *rtdcom;
 	struct snd_soc_dai *codec_dai = rtd->codec_dai;
 	struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
 	struct snd_compr *compr;
@@ -798,9 +1175,25 @@ int snd_soc_new_compress(struct snd_soc_pcm_runtime *rtd, int num)
 		memcpy(compr->ops, &soc_compr_ops, sizeof(soc_compr_ops));
 	}
 
+
 	/* Add copy callback for not memory mapped DSPs */
-	if (platform->driver->compr_ops && platform->driver->compr_ops->copy)
+	if (platform && platform->driver->compr_ops && platform->driver->compr_ops->copy)
+		compr->ops->copy = soc_compr_copy;
+
+	for_each_rtdcom(rtd, rtdcom) {
+		component = rtdcom->component;
+
+		/* ignore duplication for now */
+		if (platform && (component == &platform->component))
+			continue;
+
+		if (!component->driver->compr_ops ||
+		    !component->driver->compr_ops->copy)
+			continue;
+
 		compr->ops->copy = soc_compr_copy;
+	}
+
 
 	mutex_init(&compr->lock);
 	ret = snd_compress_new(rtd->card->snd_card, num, direction,
-- 
1.9.1

  parent reply	other threads:[~2017-09-01  5:33 UTC|newest]

Thread overview: 105+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-01  5:25 Prepare to covert Codec/Platform into Component Kuninori Morimoto
2017-09-01  5:28 ` [PATCH 00/13] ASoC add new necessary features for Conversion Kuninori Morimoto
2017-09-01  5:31   ` [PATCH 01/13] ASoC: add Component level pcm_new/pcm_free v2 Kuninori Morimoto
2017-09-27 17:13     ` Applied "ASoC: add Component level pcm_new/pcm_free v2" to the asoc tree Mark Brown
2017-09-01  5:31   ` [PATCH 02/13] ASoC: add Component level set_bias_level Kuninori Morimoto
2017-09-27 17:13     ` Applied "ASoC: add Component level set_bias_level" to the asoc tree Mark Brown
2017-09-01  5:32   ` [PATCH 03/13] ASoC: soc-core: add component lookup functions Kuninori Morimoto
2017-09-01  5:32   ` [PATCH 04/13] ASoC: soc-core: add snd_soc_add_component() Kuninori Morimoto
2017-10-10  9:19     ` Applied "ASoC: soc-core: add snd_soc_add_component()" to the asoc tree Mark Brown
2017-09-01  5:33   ` [PATCH 05/13] ASoC: snd_soc_component_driver has snd_pcm_ops Kuninori Morimoto
2017-09-01  5:33   ` Kuninori Morimoto [this message]
2017-10-23  9:43     ` Applied "ASoC: snd_soc_component_driver has snd_compr_ops" to the asoc tree Mark Brown
2017-09-01  5:33   ` [PATCH 07/13] ASoC: snd_soc_component_driver has pmdown_time Kuninori Morimoto
2017-10-23  9:43     ` Applied "ASoC: snd_soc_component_driver has pmdown_time" to the asoc tree Mark Brown
2017-09-01  5:34   ` [PATCH 08/13] ASoC: snd_soc_component_driver has endianness Kuninori Morimoto
2017-10-23  9:43     ` Applied "ASoC: snd_soc_component_driver has endianness" to the asoc tree Mark Brown
2017-09-01  5:34   ` [PATCH 09/13] ASoC: snd_soc_component_driver has non_legacy_dai_naming Kuninori Morimoto
2017-10-23  9:43     ` Applied "ASoC: snd_soc_component_driver has non_legacy_dai_naming" to the asoc tree Mark Brown
2017-09-01  5:34   ` [PATCH 10/13] ASoC: add snd_soc_component_read32 Kuninori Morimoto
2017-09-01  5:35   ` [PATCH 11/13] ASoC: add snd_soc_component_xxx_bias_level() Kuninori Morimoto
2017-09-01  5:35   ` [PATCH 12/13] ASoC: add snd_soc_component_cache_sync() Kuninori Morimoto
2017-11-08 21:32     ` Applied "ASoC: add snd_soc_component_cache_sync()" to the asoc tree Mark Brown
2017-09-01  5:36   ` [PATCH 13/13] ASoC: add snd_soc_dapm_kcontrol_component() Kuninori Morimoto
2017-11-08 21:32     ` Applied "ASoC: add snd_soc_dapm_kcontrol_component()" to the asoc tree Mark Brown
2017-09-01  5:42 ` [PATCH 0/6] ASoC don't use codec hw_write/read Kuninori Morimoto
2017-09-01  5:40   ` [PATCH -/-] ASoC: remove codec hw_write/control_data Kuninori Morimoto
2018-05-09  9:45     ` Applied "ASoC: remove codec hw_write/control_data" to the asoc tree Mark Brown
2017-09-01  5:44   ` [PATCH 1/6] ASoC: don't use codec hw_write on uda1380 Kuninori Morimoto
2017-11-27 18:52     ` Applied "ASoC: don't use codec hw_write on uda1380" to the asoc tree Mark Brown
2017-09-01  5:45   ` [PATCH 2/6] ASoC: don't use codec hw_write on tlv320dac33 Kuninori Morimoto
2017-11-27 18:52     ` Applied "ASoC: don't use codec hw_write on tlv320dac33" to the asoc tree Mark Brown
2017-09-01  5:45   ` [PATCH 3/6] ASoC: don't use codec hw_write on cx20442/omap-ams-delta Kuninori Morimoto
2017-11-27 18:52     ` Applied "ASoC: don't use codec hw_write on cx20442/omap-ams-delta" to the asoc tree Mark Brown
2017-09-01  5:45   ` [PATCH 4/6] ASoC: don't use codec hw_write on twl6040 Kuninori Morimoto
2017-11-27 18:52     ` Applied "ASoC: don't use codec hw_write on twl6040" to the asoc tree Mark Brown
2017-09-01  5:46   ` [PATCH 5/6] ASoC: don't use codec hw_write on max98926 Kuninori Morimoto
2017-11-27 18:52     ` Applied "ASoC: don't use codec hw_write on max98926" to the asoc tree Mark Brown
2017-09-01  5:46   ` [PATCH 6/6] ASoC: don't use codec hw_write on max98927 Kuninori Morimoto
2017-11-27 18:52     ` Applied "ASoC: don't use codec hw_write on max98927" to the asoc tree Mark Brown
2017-09-01  6:05 ` [PATCH 00/19] ASoC: cleanup Codec reg_cache Kuninori Morimoto
2017-09-01  6:06   ` [PATCH 01/19] ASoC: use internal reg_cache on uda1380 Kuninori Morimoto
2017-11-27 18:51     ` Applied "ASoC: use internal reg_cache on uda1380" to the asoc tree Mark Brown
2017-09-01  6:06   ` [PATCH 02/19] ASoC: use internal reg_cache on tlv320dac33 Kuninori Morimoto
2017-11-27 18:51     ` Applied "ASoC: use internal reg_cache on tlv320dac33" to the asoc tree Mark Brown
2017-09-01  6:06   ` [PATCH 03/19] ASoC: cx20442: don't use reg_cache Kuninori Morimoto
2017-11-27 18:51     ` Applied "ASoC: cx20442: don't use reg_cache" to the asoc tree Mark Brown
2017-09-01  6:07   ` [PATCH 04/19] ASoC: don't use snd_soc_write/read on twl6040 Kuninori Morimoto
2017-11-27 18:51     ` Applied "ASoC: don't use snd_soc_write/read on twl6040" to the asoc tree Mark Brown
2017-09-01  6:07   ` [PATCH 05/19] ASoC: don't use snd_soc_write/read on twl4030 Kuninori Morimoto
2017-11-27 18:51     ` Applied "ASoC: don't use snd_soc_write/read on twl4030" to the asoc tree Mark Brown
2017-09-01  6:07   ` [PATCH 06/19] ASoC: use snd_soc_component_init_regmap() on wm8998 Kuninori Morimoto
2017-12-04 18:50     ` Applied "ASoC: use snd_soc_component_init_regmap() on wm8998" to the asoc tree Mark Brown
2017-09-01  6:08   ` [PATCH 07/19] ASoC: use snd_soc_component_init_regmap() on wm8997 Kuninori Morimoto
2017-12-04 18:50     ` Applied "ASoC: use snd_soc_component_init_regmap() on wm8997" to the asoc tree Mark Brown
2017-09-01  6:08   ` [PATCH 08/19] ASoC: use snd_soc_component_init_regmap() on wm8994 Kuninori Morimoto
2017-12-04 18:50     ` Applied "ASoC: use snd_soc_component_init_regmap() on wm8994" to the asoc tree Mark Brown
2017-09-01  6:08   ` [PATCH 09/19] ASoC: use snd_soc_component_init_regmap() on wm8400 Kuninori Morimoto
2017-12-04 18:49     ` Applied "ASoC: use snd_soc_component_init_regmap() on wm8400" to the asoc tree Mark Brown
2017-09-01  6:09   ` [PATCH 10/19] ASoC: use snd_soc_component_init_regmap() on wm8350 Kuninori Morimoto
2017-12-04 18:49     ` Applied "ASoC: use snd_soc_component_init_regmap() on wm8350" to the asoc tree Mark Brown
2017-09-01  6:09   ` [PATCH 11/19] ASoC: use snd_soc_component_init_regmap() on wm5110 Kuninori Morimoto
2017-12-04 18:49     ` Applied "ASoC: use snd_soc_component_init_regmap() on wm5110" to the asoc tree Mark Brown
2017-09-01  6:09   ` [PATCH 12/19] ASoC: use snd_soc_component_init_regmap() on wm5102 Kuninori Morimoto
2017-12-04 18:49     ` Applied "ASoC: use snd_soc_component_init_regmap() on wm5102" to the asoc tree Mark Brown
2017-09-01  6:10   ` [PATCH 13/19] ASoC: use snd_soc_component_init_regmap() on si476x Kuninori Morimoto
2017-12-04 18:49     ` Applied "ASoC: use snd_soc_component_init_regmap() on si476x" to the asoc tree Mark Brown
2017-09-01  6:10   ` [PATCH 14/19] ASoC: use snd_soc_component_init_regmap() on mc13783 Kuninori Morimoto
2017-12-04 18:49     ` Applied "ASoC: use snd_soc_component_init_regmap() on mc13783" to the asoc tree Mark Brown
2017-09-01  6:11   ` [PATCH 15/19] ASoC: use snd_soc_component_init_regmap() on cq93vc Kuninori Morimoto
2017-12-04 18:49     ` Applied "ASoC: use snd_soc_component_init_regmap() on cq93vc" to the asoc tree Mark Brown
2017-09-01  6:11   ` [PATCH 16/19] ASoC: use snd_soc_component_init_regmap() on cs47l24 Kuninori Morimoto
2017-12-04 18:49     ` Applied "ASoC: use snd_soc_component_init_regmap() on cs47l24" to the asoc tree Mark Brown
2017-09-01  6:11   ` [PATCH 17/19] ASoC: use snd_soc_component_init_regmap() on 88pm860x Kuninori Morimoto
2017-12-04 18:49     ` Applied "ASoC: use snd_soc_component_init_regmap() on 88pm860x" to the asoc tree Mark Brown
2017-09-01  6:12   ` [PATCH 18/19] ASoC: use snd_soc_component_init_regmap() on msm8916 Kuninori Morimoto
2017-12-04 18:49     ` Applied "ASoC: use snd_soc_component_init_regmap() on msm8916" to the asoc tree Mark Brown
2017-09-01  6:12   ` [PATCH 19/19] ASoC: use snd_soc_component_init_regmap() on atmel-classd Kuninori Morimoto
2017-12-04 18:49     ` Applied "ASoC: use snd_soc_component_init_regmap() on atmel-classd" to the asoc tree Mark Brown
2017-09-01  6:13   ` [PATCH --/--] ASoC: remove codec reg_cache Kuninori Morimoto
2017-09-01  6:14   ` [PATCH --/--] ASoC: remove .get_regmap Kuninori Morimoto
2017-09-01  6:23 ` [SAMPLE 0/4] ASoC: don't use rtd->codec Kuninori Morimoto
2017-09-01  6:24   ` [SAMPLE 1/4] ASoC: don't use rtd->codec on soc_dev_attr_is_visible() Kuninori Morimoto
2017-12-05 12:47     ` Applied "ASoC: don't use rtd->codec on soc_dev_attr_is_visible()" to the asoc tree Mark Brown
2017-09-01  6:25   ` [SAMPLE 2/4] ASoC: don't use rtd->codec on snd_soc_new_compress() Kuninori Morimoto
2017-09-01  6:25   ` [SAMPLE 3/4] ASoC: don't use rtd->codec on fsl-asoc-card Kuninori Morimoto
2017-12-05 12:47     ` Applied "ASoC: don't use rtd->codec on fsl-asoc-card" to the asoc tree Mark Brown
2017-09-01  6:25   ` [SAMPLE 4/4] ASoC: don't use rtd->codec on intel/skylake Kuninori Morimoto
2017-12-05 12:46     ` Applied "ASoC: don't use rtd->codec on intel/skylake" to the asoc tree Mark Brown
2017-09-01  6:27 ` [SAMPLE 0/6] ASoC: replace platform to component Kuninori Morimoto
2017-09-01  6:28   ` [SAMPLE 1/6] ASoC: replace platform to component on soc-utils Kuninori Morimoto
2017-09-01  6:29   ` [SAMPLE 2/6] ASoC: replace platform to component on soc-generic-dmaengine-pcm Kuninori Morimoto
2017-09-01  6:29   ` [SAMPLE 3/6] ASoC: replace platform to component on intel/atom Kuninori Morimoto
2017-09-01  6:29   ` [SAMPLE 4/6] ASoC: replace platform to component on renesas/siu Kuninori Morimoto
2018-02-12 12:30     ` Applied "ASoC: sh: siu: replace platform to component" to the asoc tree Mark Brown
2017-09-01  6:30   ` [SAMPLE 5/6] ASoC: replace platform to component on atmel-xxx Kuninori Morimoto
2017-09-01  6:30   ` [SAMPLE 6/6] ASoC: replace platform to component on amd/acp Kuninori Morimoto
2017-09-01  6:31   ` [SAMPLE -/-] ASoC: remove platform related things Kuninori Morimoto
2017-09-01  6:34 ` [SAMPLE 0/6] ASoC: convert codec to compoent Kuninori Morimoto
2017-09-01  6:35   ` [SAMPLE 1/6] ASoC: convert codec to compoent on hdac_hdmi/nau8825/rt286/rt298/da7219 Kuninori Morimoto
2017-09-01  6:35   ` [PATCH 2/6] ASoC: convert codec to compoent on arizona/cs47l24/wm5102/wm5110/wm8997/wm8998/wm_adsp Kuninori Morimoto
2017-09-01  6:36   ` [SAMPLE 3/6] ASoC: convert codec to compoent on mc13783 Kuninori Morimoto
2017-09-01  6:36   ` [SAMPLE 4/6] ASoC: convert codec to compoent on sgtl5000 Kuninori Morimoto
2017-09-01  6:36   ` [SAMPLE 5/6] ASoC: convert codec to compoent on stac9766 Kuninori Morimoto
2017-09-01  6:37   ` [SAMPLE 6/6] ASoC: convert codec to compoent on sn95031 Kuninori Morimoto
2017-09-01  6:37   ` [SAMPLE -/0] ASoC: remove Codec related code Kuninori Morimoto

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87shg7m1kt.wl%kuninori.morimoto.gx@renesas.com \
    --to=kuninori.morimoto.gx@renesas.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@kernel.org \
    --cc=lars@metafoo.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.