[alsa-devel] [PATCH 10/25] ASoC: soc-component: add snd_soc_component_ioctrl()
Kuninori Morimoto
kuninori.morimoto.gx at renesas.com
Wed Jul 24 03:52:05 CEST 2019
From: Kuninori Morimoto <kuninori.morimoto.gx at renesas.com>
Current ALSA SoC is directly using component->driver->ops->xxx,
thus, it is deep nested, and makes code difficult to read,
and is not good for encapsulation.
This patch adds new snd_soc_component_ioctrl() and use it.
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx at renesas.com>
---
include/sound/soc-component.h | 3 +++
sound/soc/soc-component.c | 11 +++++++++++
sound/soc/soc-pcm.c | 10 +++++-----
3 files changed, 19 insertions(+), 5 deletions(-)
diff --git a/include/sound/soc-component.h b/include/sound/soc-component.h
index c923d04..8230519 100644
--- a/include/sound/soc-component.h
+++ b/include/sound/soc-component.h
@@ -339,5 +339,8 @@ int snd_soc_component_trigger(struct snd_soc_component *component,
int cmd);
int snd_soc_component_pointer(struct snd_soc_component *component,
struct snd_pcm_substream *substream);
+int snd_soc_component_ioctl(struct snd_soc_component *component,
+ struct snd_pcm_substream *substream,
+ unsigned int cmd, void *arg);
#endif /* __SOC_COMPONENT_H */
diff --git a/sound/soc/soc-component.c b/sound/soc/soc-component.c
index 7cb936a..dbc8295 100644
--- a/sound/soc/soc-component.c
+++ b/sound/soc/soc-component.c
@@ -357,3 +357,14 @@ int snd_soc_component_pointer(struct snd_soc_component *component,
return 0;
}
+
+int snd_soc_component_ioctl(struct snd_soc_component *component,
+ struct snd_pcm_substream *substream,
+ unsigned int cmd, void *arg)
+{
+ if (component->driver->ops &&
+ component->driver->ops->ioctl)
+ return component->driver->ops->ioctl(substream, cmd, arg);
+
+ return -ENOTSUPP;
+}
diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c
index 7ab68de..064d16c 100644
--- a/sound/soc/soc-pcm.c
+++ b/sound/soc/soc-pcm.c
@@ -1116,6 +1116,7 @@ static snd_pcm_uframes_t soc_pcm_pointer(struct snd_pcm_substream *substream)
component = rtdcom->component;
offset = snd_soc_component_pointer(component, substream);
+
/* FIXME: use 1st pointer */
if (offset > 0)
break;
@@ -2455,16 +2456,15 @@ static int soc_pcm_ioctl(struct snd_pcm_substream *substream,
struct snd_soc_pcm_runtime *rtd = substream->private_data;
struct snd_soc_component *component;
struct snd_soc_rtdcom_list *rtdcom;
+ int ret;
for_each_rtdcom(rtd, rtdcom) {
component = rtdcom->component;
- if (!component->driver->ops ||
- !component->driver->ops->ioctl)
- continue;
-
+ ret = snd_soc_component_ioctl(component, substream, cmd, arg);
/* FIXME: use 1st ioctl */
- return component->driver->ops->ioctl(substream, cmd, arg);
+ if (ret != -ENOTSUPP)
+ return ret;
}
return snd_pcm_lib_ioctl(substream, cmd, arg);
--
2.7.4
More information about the Alsa-devel
mailing list