diff options
author | Lars-Peter Clausen <lars@metafoo.de> | 2014-06-16 18:13:06 +0200 |
---|---|---|
committer | Mark Brown <broonie@linaro.org> | 2014-06-21 21:34:15 +0100 |
commit | ce0fc93ae56e2ba50ff8c220d69e4e860e889320 (patch) | |
tree | b444788c95c34b08a18f80f00a411f359aa8ce23 /sound/soc/soc-core.c | |
parent | 68f831c2724ab72c0088471b2ed1dc99e81948ef (diff) | |
download | blackbird-op-linux-ce0fc93ae56e2ba50ff8c220d69e4e860e889320.tar.gz blackbird-op-linux-ce0fc93ae56e2ba50ff8c220d69e4e860e889320.zip |
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>
Diffstat (limited to 'sound/soc/soc-core.c')
-rw-r--r-- | sound/soc/soc-core.c | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 10e13c43bc54..f519a9f7571c 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -3997,6 +3997,8 @@ err: 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 @@ static int snd_soc_component_initialize(struct snd_soc_component *component, 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 snd_soc_add_platform(struct device *dev, struct snd_soc_platform *platform, { 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 @@ int snd_soc_add_platform(struct device *dev, struct snd_soc_platform *platform, 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 @@ int snd_soc_register_codec(struct device *dev, 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 @@ int snd_soc_register_codec(struct device *dev, 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) |