ASoC: Add DAPM support at the component level
This patch adds full DAPM support at the component level. Previously there was
only full DAPM support for CODECs and partial DAPM support (e.g. no Mixers nor
MUXs) for platforms. Having DAPM support at the component level will allow all
types of components to use DAPM and also help in consolidating the DAPM support
between CODECs and platforms.
Since the DAPM context is directly embedded into the snd_soc_codec and
snd_soc_platform struct and the 'dapm' field is directly referenced in a lot of
drivers moving the field just right now is not possible without causing code
churn. The approach this patch takes is to add two new fields to the component
struct. One field which is the pointer to the actual DAPM context used by the
component and one DAPM context that will be used as the default if no other
context was specified. For CODECs and platforms the pointer is initialized to
point to the CODEC or platform DAPM context. All generic code when referencing
a component's DAPM struct will go via the pointer. This will make it possible to
eventually seamlessly move the DAPM context from snd_soc_codec and
snd_soc_platform struct over once all direct references have been eliminated.
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Mark Brown <broonie@linaro.org>
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index 10e13c4..f519a9f 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -3997,6 +3997,8 @@
static int snd_soc_component_initialize(struct snd_soc_component *component,
const struct snd_soc_component_driver *driver, struct device *dev)
{
+ struct snd_soc_dapm_context *dapm;
+
component->name = fmt_single_name(dev, &component->id);
if (!component->name) {
dev_err(dev, "ASoC: Failed to allocate name\n");
@@ -4006,6 +4008,14 @@
component->dev = dev;
component->driver = driver;
+ if (!component->dapm_ptr)
+ component->dapm_ptr = &component->dapm;
+
+ dapm = component->dapm_ptr;
+ dapm->dev = dev;
+ dapm->component = component;
+ dapm->bias_level = SND_SOC_BIAS_OFF;
+
INIT_LIST_HEAD(&component->dai_list);
mutex_init(&component->io_mutex);
@@ -4131,6 +4141,8 @@
{
int ret;
+ platform->component.dapm_ptr = &platform->dapm;
+
ret = snd_soc_component_initialize(&platform->component,
&platform_drv->component_driver, dev);
if (ret)
@@ -4138,9 +4150,7 @@
platform->dev = dev;
platform->driver = platform_drv;
- platform->dapm.dev = dev;
platform->dapm.platform = platform;
- platform->dapm.component = &platform->component;
platform->dapm.stream_event = platform_drv->stream_event;
if (platform_drv->write)
platform->component.write = snd_soc_platform_drv_write;
@@ -4314,6 +4324,8 @@
if (codec == NULL)
return -ENOMEM;
+ codec->component.dapm_ptr = &codec->dapm;
+
ret = snd_soc_component_initialize(&codec->component,
&codec_drv->component_driver, dev);
if (ret)
@@ -4324,10 +4336,7 @@
if (codec_drv->read)
codec->component.read = snd_soc_codec_drv_read;
codec->component.ignore_pmdown_time = codec_drv->ignore_pmdown_time;
- codec->dapm.bias_level = SND_SOC_BIAS_OFF;
- codec->dapm.dev = dev;
codec->dapm.codec = codec;
- codec->dapm.component = &codec->component;
codec->dapm.seq_notifier = codec_drv->seq_notifier;
codec->dapm.stream_event = codec_drv->stream_event;
if (codec_drv->set_bias_level)