[alsa-devel] [PATCH 1/2][RFC] ASoC: snd_soc_codec include snd_soc_component
Kuninori Morimoto
kuninori.morimoto.gx at renesas.com
Mon Sep 2 08:03:24 CEST 2013
This is rough version patch for merging codec <-> component.
The main topic is that snd_soc_register_dais() will be called
via component.
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx at renesas.com>
---
include/sound/soc.h | 33 +++++++++++++++++++--------------
sound/soc/soc-core.c | 44 +++++++++++++++++++++++++++++++++-----------
2 files changed, 52 insertions(+), 25 deletions(-)
diff --git a/include/sound/soc.h b/include/sound/soc.h
index 8e2ad52..e312b97 100644
--- a/include/sound/soc.h
+++ b/include/sound/soc.h
@@ -670,6 +670,21 @@ struct snd_soc_cache_ops {
int (*sync)(struct snd_soc_codec *codec);
};
+/* component interface */
+struct snd_soc_component_driver {
+ const char *name;
+};
+
+struct snd_soc_component {
+ const char *name;
+ int id;
+ int num_dai;
+ struct device *dev;
+ struct list_head list;
+
+ const struct snd_soc_component_driver *driver;
+};
+
/* SoC Audio Codec device */
struct snd_soc_codec {
const char *name;
@@ -717,6 +732,9 @@ struct snd_soc_codec {
struct mutex cache_rw_mutex;
int val_bytes;
+ /* component */
+ struct snd_soc_component component;
+
/* dapm */
struct snd_soc_dapm_context dapm;
unsigned int ignore_pmdown_time:1; /* pmdown_time is ignored at stop */
@@ -736,6 +754,7 @@ struct snd_soc_codec_driver {
int (*remove)(struct snd_soc_codec *);
int (*suspend)(struct snd_soc_codec *);
int (*resume)(struct snd_soc_codec *);
+ struct snd_soc_component_driver *component_driver;
/* Default control and setup, added after probe() is run */
const struct snd_kcontrol_new *controls;
@@ -853,20 +872,6 @@ struct snd_soc_platform {
#endif
};
-struct snd_soc_component_driver {
- const char *name;
-};
-
-struct snd_soc_component {
- const char *name;
- int id;
- int num_dai;
- struct device *dev;
- struct list_head list;
-
- const struct snd_soc_component_driver *driver;
-};
-
struct snd_soc_dai_link {
/* config - must be set by machine driver */
const char *name; /* Codec name */
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index 7d13c4f..1b76ef0 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -4154,6 +4154,11 @@ static void fixup_codec_formats(struct snd_soc_pcm_stream *stream)
stream->formats |= codec_format_map[i];
}
+static int __snd_soc_register_component(struct device *dev,
+ struct snd_soc_component *cmpnt,
+ const struct snd_soc_component_driver *cmpnt_drv,
+ struct snd_soc_dai_driver *dai_drv,
+ int num_dai);
/**
* snd_soc_register_codec - Register a codec with the ASoC core
*
@@ -4240,10 +4245,12 @@ int snd_soc_register_codec(struct device *dev,
list_add(&codec->list, &codec_list);
mutex_unlock(&client_mutex);
- /* register any DAIs */
- ret = snd_soc_register_dais(dev, dai_drv, num_dai);
+ /* register component */
+ ret = __snd_soc_register_component(dev, &codec->component,
+ codec_drv->component_driver,
+ dai_drv, num_dai);
if (ret < 0) {
- dev_err(codec->dev, "ASoC: Failed to regster DAIs: %d\n", ret);
+ dev_err(codec->dev, "ASoC: Failed to regster component: %d\n", ret);
goto fail_codec_name;
}
@@ -4293,24 +4300,23 @@ found:
}
EXPORT_SYMBOL_GPL(snd_soc_unregister_codec);
-
/**
* snd_soc_register_component - Register a component with the ASoC core
*
*/
-int snd_soc_register_component(struct device *dev,
- const struct snd_soc_component_driver *cmpnt_drv,
- struct snd_soc_dai_driver *dai_drv,
- int num_dai)
+static int
+__snd_soc_register_component(struct device *dev,
+ struct snd_soc_component *cmpnt,
+ const struct snd_soc_component_driver *cmpnt_drv,
+ struct snd_soc_dai_driver *dai_drv,
+ int num_dai)
{
- struct snd_soc_component *cmpnt;
int ret;
dev_dbg(dev, "component register %s\n", dev_name(dev));
- cmpnt = devm_kzalloc(dev, sizeof(*cmpnt), GFP_KERNEL);
if (!cmpnt) {
- dev_err(dev, "ASoC: Failed to allocate memory\n");
+ dev_err(dev, "ASoC: Failed to connecting component\n");
return -ENOMEM;
}
@@ -4351,6 +4357,22 @@ error_component_name:
return ret;
}
+
+int snd_soc_register_component(struct device *dev,
+ const struct snd_soc_component_driver *cmpnt_drv,
+ struct snd_soc_dai_driver *dai_drv,
+ int num_dai)
+{
+ struct snd_soc_component *cmpnt;
+
+ cmpnt = devm_kzalloc(dev, sizeof(*cmpnt), GFP_KERNEL);
+ if (!cmpnt) {
+ dev_err(dev, "ASoC: Failed to allocate memory\n");
+ return -ENOMEM;
+ }
+
+ return __snd_soc_register_component(dev, cmpnt, cmpnt_drv, dai_drv, num_dai);
+}
EXPORT_SYMBOL_GPL(snd_soc_register_component);
/**
--
1.7.9.5
More information about the Alsa-devel
mailing list