[PATCH 07/12] ASoC: soc-component: add snd_soc_component_compr_get_codec_caps()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Kuninori Morimoto <kuninori.morimoto.gx@xxxxxxxxxxx>

component related function should be implemented at
soc-component.c.
This patch adds snd_soc_component_compr_get_codec_caps().

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@xxxxxxxxxxx>
---
 include/sound/soc-component.h |  2 ++
 sound/soc/soc-component.c     | 21 +++++++++++++++++++++
 sound/soc/soc-compress.c      | 13 ++-----------
 3 files changed, 25 insertions(+), 11 deletions(-)

diff --git a/include/sound/soc-component.h b/include/sound/soc-component.h
index 7fd45462963e..d91e0eb1546d 100644
--- a/include/sound/soc-component.h
+++ b/include/sound/soc-component.h
@@ -455,6 +455,8 @@ int snd_soc_component_compr_get_params(struct snd_compr_stream *cstream,
 				       struct snd_codec *params);
 int snd_soc_component_compr_get_caps(struct snd_compr_stream *cstream,
 				     struct snd_compr_caps *caps);
+int snd_soc_component_compr_get_codec_caps(struct snd_compr_stream *cstream,
+					   struct snd_compr_codec_caps *codec);
 
 int snd_soc_pcm_component_pointer(struct snd_pcm_substream *substream);
 int snd_soc_pcm_component_ioctl(struct snd_pcm_substream *substream,
diff --git a/sound/soc/soc-component.c b/sound/soc/soc-component.c
index 6f560238e2f9..2f1628100208 100644
--- a/sound/soc/soc-component.c
+++ b/sound/soc/soc-component.c
@@ -545,6 +545,27 @@ int snd_soc_component_compr_get_caps(struct snd_compr_stream *cstream,
 }
 EXPORT_SYMBOL_GPL(snd_soc_component_compr_get_caps);
 
+int snd_soc_component_compr_get_codec_caps(struct snd_compr_stream *cstream,
+					   struct snd_compr_codec_caps *codec)
+{
+	struct snd_soc_pcm_runtime *rtd = cstream->private_data;
+	struct snd_soc_component *component;
+	int i, ret;
+
+	for_each_rtd_components(rtd, i, component) {
+		if (component->driver->compress_ops &&
+		    component->driver->compress_ops->get_codec_caps) {
+			ret = component->driver->compress_ops->get_codec_caps(
+				component, cstream, codec);
+			if (ret < 0)
+				return soc_component_ret(component, ret);
+		}
+	}
+
+	return 0;
+}
+EXPORT_SYMBOL_GPL(snd_soc_component_compr_get_codec_caps);
+
 static unsigned int soc_component_read_no_lock(
 	struct snd_soc_component *component,
 	unsigned int reg)
diff --git a/sound/soc/soc-compress.c b/sound/soc/soc-compress.c
index c62aa1a52c28..9d6010fd5160 100644
--- a/sound/soc/soc-compress.c
+++ b/sound/soc/soc-compress.c
@@ -427,20 +427,11 @@ static int soc_compr_get_codec_caps(struct snd_compr_stream *cstream,
 				    struct snd_compr_codec_caps *codec)
 {
 	struct snd_soc_pcm_runtime *rtd = cstream->private_data;
-	struct snd_soc_component *component;
-	int i, ret = 0;
+	int ret;
 
 	mutex_lock_nested(&rtd->card->pcm_mutex, rtd->card->pcm_subclass);
 
-	for_each_rtd_components(rtd, i, component) {
-		if (!component->driver->compress_ops ||
-		    !component->driver->compress_ops->get_codec_caps)
-			continue;
-
-		ret = component->driver->compress_ops->get_codec_caps(
-			component, cstream, codec);
-		break;
-	}
+	ret = snd_soc_component_compr_get_codec_caps(cstream, codec);
 
 	mutex_unlock(&rtd->card->pcm_mutex);
 	return ret;
-- 
2.25.1




[Index of Archives]     [ALSA User]     [Linux Audio Users]     [Pulse Audio]     [Kernel Archive]     [Asterisk PBX]     [Photo Sharing]     [Linux Sound]     [Video 4 Linux]     [Gimp]     [Yosemite News]

  Powered by Linux