[alsa-devel] [RFC 0/x v2] ASoC: replace platform to component
Hi Mark, Lars-Peter
These are v2 of platform replace patch-set. Big difference is that from version, rtd can have component list. As you know, current rtd has platform, codec, and this patch replace rtd->platform into component list. We can replace codec in same style in the future.
This patch-set adds new snd_soc_rtdcom_lookup(). So, current struct snd_soc_platform *platform = rtd->platform; will be replaced into struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, DRIVER_NAME);
1 rtd doesn't detect same component multiple times, I guess. Thus, lookup by driver name should be OK.
Current framework is listing component to card (it was originally codec) by component_dev_list. And it is used in soc-pcm.c
list_for_each_entry(component, &rtd->card->component_dev_list, card_list) { ... }
But it is not correct I think. card can have multiple runtimes, and runtime can have multiple components. Thus, I think we can do below case ?
Card -+-> runtime1 -> component1 + component2 +-> runtime2 -> component1 + component2 +-> runtime3 -> component1 + component3
Current list_for_each_entry() will call component1/2/3, but runtime1 needs component1/2 only, for example.
It is connecting all components to card by component_dev_list. OTOH, all runtimes are listed to card by rtd_list. This patch lists component to runtime.
I think we can replace component_dev_list into
for_each_rtdcom(rtd, rtdcom) { component = rtdcom->component; ... }
1) - 5) : prepare to replace 6) - 8) : sample of platform -> component replace 9) : remove platform
Kuninori Morimoto (9): 1) ASoC: soc-core: add component remove/unregister_exp/lookup functions 2) ASoC: soc-devres: use expanded unregister on devm register component 3) ASoC: soc-core: add snd_soc_rtdcom_xxx() 4) ASoC: snd_soc_component_driver has snd_pcm_ops 5) ASoC: snd_soc_component_driver has snd_compr_ops 6) ASoC: replace platform to component on rsnd 7) ASoC: replace platform to component on soc-utils 8) ASoC: replace platform to component on soc-generic-dmaengine-pcm 9) ASoC: remove platform related things
Best regards --- Kuninori Morimoto
ALSA SoC platform/codec will be replaced to component soon. This means 1 device might have multiple components. But current unregister component function only checks "dev" to find it. This means, unexpected component might be unregistered by current function. But, it is no problem if driver registered only 1 component.
To avoid this issue, this patch adds new component unregister_exp/lookup/remove functions. "lookup" function finds component by "dev" and "driver name", and "remove" function removes it. "unregister_exp" will use these functions.
Here, the reason why it uses "driver name" is that "component name" was created by fmt_single_name() and difficult to use it from driver. Driver of course knows its "driver name", thus, using it is more easy.
Current normal unregister function is replaced to "unregister_exp" with driver_name = NULL macro.
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com --- include/sound/soc.h | 7 ++++++- sound/soc/soc-core.c | 54 +++++++++++++++++++++++++++++++++++++++------------- 2 files changed, 47 insertions(+), 14 deletions(-)
diff --git a/include/sound/soc.h b/include/sound/soc.h index 9c94b97..8b2b30f 100644 --- a/include/sound/soc.h +++ b/include/sound/soc.h @@ -474,7 +474,12 @@ int snd_soc_register_component(struct device *dev, int devm_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); -void snd_soc_unregister_component(struct device *dev); +#define snd_soc_unregister_component(dev) snd_soc_unregister_component_exp(dev, NULL) +void snd_soc_unregister_component_exp(struct device *dev, + const char *driver_name); +void snd_soc_remove_component(struct snd_soc_component *component); +struct snd_soc_component *snd_soc_lookup_component(struct device *dev, + const char *driver_name); int snd_soc_cache_init(struct snd_soc_codec *codec); int snd_soc_cache_exit(struct snd_soc_codec *codec);
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index cfa9cf1..4d66c47 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -3294,26 +3294,54 @@ int snd_soc_register_component(struct device *dev, * * @dev: The device to unregister */ -void snd_soc_unregister_component(struct device *dev) +void snd_soc_unregister_component_exp(struct device *dev, + const char *driver_name) { - struct snd_soc_component *cmpnt; + struct snd_soc_component *component; + + component = snd_soc_lookup_component(dev, driver_name); + if (!component || !component->registered_as_component) + return;
+ snd_soc_remove_component(component); +} +EXPORT_SYMBOL_GPL(snd_soc_unregister_component_exp); + +void snd_soc_remove_component(struct snd_soc_component *component) +{ mutex_lock(&client_mutex); - list_for_each_entry(cmpnt, &component_list, list) { - if (dev == cmpnt->dev && cmpnt->registered_as_component) - goto found; - } + snd_soc_tplg_component_remove(component, SND_SOC_TPLG_INDEX_ALL); + snd_soc_component_del_unlocked(component); mutex_unlock(&client_mutex); - return;
-found: - snd_soc_tplg_component_remove(cmpnt, SND_SOC_TPLG_INDEX_ALL); - snd_soc_component_del_unlocked(cmpnt); + snd_soc_component_cleanup(component); + kfree(component); +} +EXPORT_SYMBOL_GPL(snd_soc_remove_component); + +struct snd_soc_component *snd_soc_lookup_component(struct device *dev, + const char *driver_name) +{ + struct snd_soc_component *component; + struct snd_soc_component *ret; + + ret = NULL; + mutex_lock(&client_mutex); + list_for_each_entry(component, &component_list, list) { + if (dev != component->dev) + continue; + + if (driver_name && (driver_name != component->driver->name)) + continue; + + ret = component; + break; + } mutex_unlock(&client_mutex); - snd_soc_component_cleanup(cmpnt); - kfree(cmpnt); + + return ret; } -EXPORT_SYMBOL_GPL(snd_soc_unregister_component); +EXPORT_SYMBOL_GPL(snd_soc_lookup_component);
static int snd_soc_platform_drv_probe(struct snd_soc_component *component) {
Now, we have snd_soc_unregister_component_exp() which can check registered device and driver. Let's use it on devm_component_release()
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com --- sound/soc/soc-devres.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/sound/soc/soc-devres.c b/sound/soc/soc-devres.c index a57921e..9194696 100644 --- a/sound/soc/soc-devres.c +++ b/sound/soc/soc-devres.c @@ -16,7 +16,7 @@
static void devm_component_release(struct device *dev, void *res) { - snd_soc_unregister_component(*(struct device **)res); + snd_soc_unregister_component_exp(dev, *(const char **)res); }
/** @@ -33,7 +33,7 @@ int devm_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 device **ptr; + const char **ptr; int ret;
ptr = devres_alloc(devm_component_release, sizeof(*ptr), GFP_KERNEL); @@ -42,7 +42,7 @@ int devm_snd_soc_register_component(struct device *dev,
ret = snd_soc_register_component(dev, cmpnt_drv, dai_drv, num_dai); if (ret == 0) { - *ptr = dev; + *ptr = cmpnt_drv->name; devres_add(dev, ptr); } else { devres_free(ptr);
Current snd_soc_pcm_runtime has platform / codec pointers, and we could use these specific pointer. But these will be replaced to more generic "component" soon, and will need more generic method to get each connected component pointer from rtd.
This patch adds new snd_soc_rtdcom_xxx() to connect/disconnect component to rtd. It means same as previous "platform" / "codec" pointer style, but more generic. We can find necessary component pointer from rtd by using component driver name on snd_soc_rtdcom_lookup().
Here, the reason why it uses "driver name" is that "component name" was created by fmt_single_name() and difficult to use it from driver. Driver of course knows its "driver name", thus, using it is more easy.
This patch connect "platform" component to rtd as 1st step. "codec" component will be connected in the future.
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com --- include/sound/soc.h | 13 +++++++++++++ sound/soc/soc-core.c | 42 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+)
diff --git a/include/sound/soc.h b/include/sound/soc.h index 8b2b30f..ed613a7 100644 --- a/include/sound/soc.h +++ b/include/sound/soc.h @@ -891,6 +891,18 @@ struct snd_soc_component { #endif };
+struct snd_soc_rtdcom_list { + struct snd_soc_component *component; + struct list_head list; /* rtd::component_list */ +}; +struct snd_soc_component* +snd_soc_rtdcom_lookup(struct snd_soc_pcm_runtime *rtd, + const char *driver_name); +#define for_each_rtdcom(rtd, rtdcom) \ + list_for_each_entry(rtdcom, &(rtd)->component_list, list) +#define for_each_rtdcom_safe(rtd, rtdcom1, rtdcom2) \ + list_for_each_entry_safe(rtdcom1, rtdcom2, &(rtd)->component_list, list) + /* SoC Audio Codec device */ struct snd_soc_codec { struct device *dev; @@ -1250,6 +1262,7 @@ struct snd_soc_pcm_runtime {
unsigned int num; /* 0-based and monotonic increasing */ struct list_head list; /* rtd list of the soc card */ + struct list_head component_list; /* list of connected components */
/* bit field */ unsigned int dev_registered:1; diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 4d66c47..287dec3 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -536,6 +536,46 @@ static inline void snd_soc_debugfs_exit(void)
#endif
+static int snd_soc_rtdcom_add(struct snd_soc_pcm_runtime *rtd, + struct snd_soc_component *component) +{ + struct snd_soc_rtdcom_list *new_rtdcom; + + new_rtdcom = kmalloc(sizeof(*new_rtdcom), GFP_KERNEL); + if (!new_rtdcom) + return -ENOMEM; + + new_rtdcom->component = component; + INIT_LIST_HEAD(&new_rtdcom->list); + + list_add(&new_rtdcom->list, &rtd->component_list); + + return 0; +} + +static void snd_soc_rtdcom_del_all(struct snd_soc_pcm_runtime *rtd) +{ + struct snd_soc_rtdcom_list *rtdcom1, *rtdcom2; + + for_each_rtdcom_safe(rtd, rtdcom1, rtdcom2) + kfree(rtdcom1); + + INIT_LIST_HEAD(&rtd->component_list); +} + +struct snd_soc_component* snd_soc_rtdcom_lookup(struct snd_soc_pcm_runtime *rtd, + const char *driver_name) +{ + struct snd_soc_rtdcom_list *rtdcom; + + for_each_rtdcom(rtd, rtdcom) { + if (rtdcom->component->driver->name == driver_name) + return rtdcom->component; + } + + return NULL; +} + struct snd_pcm_substream *snd_soc_get_dai_substream(struct snd_soc_card *card, const char *dai_link, int stream) { @@ -560,6 +600,7 @@ static struct snd_soc_pcm_runtime *soc_new_pcm_runtime( if (!rtd) return NULL;
+ INIT_LIST_HEAD(&rtd->component_list); rtd->card = card; rtd->dai_link = dai_link; rtd->codec_dais = kzalloc(sizeof(struct snd_soc_dai *) * @@ -577,6 +618,7 @@ static void soc_free_pcm_runtime(struct snd_soc_pcm_runtime *rtd) { if (rtd && rtd->codec_dais) kfree(rtd->codec_dais); + snd_soc_rtdcom_del_all(rtd); kfree(rtd); }
snd_soc_platform_driver has snd_pcm_ops, and it will be replaced into snd_soc_component_driver in the future. To prepare it, component driver has it.
After this patch, rtd->platfrom is no longer mandatory
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com --- include/sound/soc.h | 4 +- sound/soc/soc-core.c | 43 ++++++- sound/soc/soc-pcm.c | 314 ++++++++++++++++++++++++++++++++++++++++++++++++--- 3 files changed, 337 insertions(+), 24 deletions(-)
diff --git a/include/sound/soc.h b/include/sound/soc.h index ed613a7..f26897c 100644 --- a/include/sound/soc.h +++ b/include/sound/soc.h @@ -814,6 +814,8 @@ struct snd_soc_component_driver { int subseq); int (*stream_event)(struct snd_soc_component *, int event);
+ const struct snd_pcm_ops *ops; + /* probe ordering - for components with runtime dependencies */ int probe_order; int remove_order; @@ -1247,7 +1249,7 @@ struct snd_soc_pcm_runtime { struct snd_pcm *pcm; struct snd_compr *compr; struct snd_soc_codec *codec; - struct snd_soc_platform *platform; + struct snd_soc_platform *platform; /* will be removed */ struct snd_soc_dai *codec_dai; struct snd_soc_dai *cpu_dai;
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 287dec3..cdde8f7 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -1079,6 +1079,7 @@ static int soc_bind_dai_link(struct snd_soc_card *card, struct snd_soc_dai_link_component cpu_dai_component; struct snd_soc_dai **codec_dais; struct snd_soc_platform *platform; + struct snd_soc_component *component; struct device_node *platform_of_node; const char *platform_name; int i; @@ -1128,6 +1129,22 @@ static int soc_bind_dai_link(struct snd_soc_card *card, platform_name = "snd-soc-dummy";
/* find one from the set of registered platforms */ + list_for_each_entry(component, &component_list, list) { + platform_of_node = component->dev->of_node; + if (!platform_of_node && component->dev->parent->of_node) + platform_of_node = component->dev->parent->of_node; + + if (dai_link->platform_of_node) { + if (platform_of_node != dai_link->platform_of_node) + continue; + } else { + if (strcmp(component->name, platform_name)) + continue; + } + + snd_soc_rtdcom_add(rtd, component); + } + list_for_each_entry(platform, &platform_list, list) { platform_of_node = platform->dev->of_node; if (!platform_of_node && platform->dev->parent->of_node) @@ -1143,11 +1160,6 @@ static int soc_bind_dai_link(struct snd_soc_card *card,
rtd->platform = platform; } - if (!rtd->platform) { - dev_err(card->dev, "ASoC: platform %s not registered\n", - dai_link->platform_name); - goto _err_defer; - }
soc_add_pcm_runtime(card, rtd); return 0; @@ -1215,12 +1227,20 @@ static void soc_remove_link_components(struct snd_soc_card *card, struct snd_soc_dai *cpu_dai = rtd->cpu_dai; struct snd_soc_platform *platform = rtd->platform; struct snd_soc_component *component; + struct snd_soc_rtdcom_list *rtdcom; int i;
/* remove the platform */ if (platform && platform->component.driver->remove_order == order) soc_remove_component(&platform->component);
+ /* remove the component */ + for_each_rtdcom(rtd, rtdcom) { + component = rtdcom->component; + if (component->driver->remove_order == order) + soc_remove_component(component); + } + /* remove the CODEC-side CODEC */ for (i = 0; i < rtd->num_codecs; i++) { component = rtd->codec_dais[i]->component; @@ -1586,6 +1606,7 @@ static int soc_probe_link_components(struct snd_soc_card *card, { struct snd_soc_platform *platform = rtd->platform; struct snd_soc_component *component; + struct snd_soc_rtdcom_list *rtdcom; int i, ret;
/* probe the CPU-side component, if it is a CODEC */ @@ -1607,12 +1628,22 @@ static int soc_probe_link_components(struct snd_soc_card *card, }
/* probe the platform */ - if (platform->component.driver->probe_order == order) { + if (platform && platform->component.driver->probe_order == order) { ret = soc_probe_component(card, &platform->component); if (ret < 0) return ret; }
+ /* probe the component */ + for_each_rtdcom(rtd, rtdcom) { + component = rtdcom->component; + if (component->driver->probe_order == order) { + ret = soc_probe_component(card, component); + if (ret < 0) + return ret; + } + } + return 0; }
diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c index efc5831..b08ef16 100644 --- a/sound/soc/soc-pcm.c +++ b/sound/soc/soc-pcm.c @@ -450,10 +450,12 @@ static int soc_pcm_open(struct snd_pcm_substream *substream) struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_pcm_runtime *runtime = substream->runtime; struct snd_soc_platform *platform = rtd->platform; + struct snd_soc_component *component; + struct snd_soc_rtdcom_list *rtdcom; struct snd_soc_dai *cpu_dai = rtd->cpu_dai; struct snd_soc_dai *codec_dai; const char *codec_dai_name = "multicodec"; - int i, ret = 0; + int i, ret = 0, __ret;
pinctrl_pm_select_default_state(cpu_dai->dev); for (i = 0; i < rtd->num_codecs; i++) @@ -461,7 +463,11 @@ static int soc_pcm_open(struct snd_pcm_substream *substream) pm_runtime_get_sync(cpu_dai->dev); for (i = 0; i < rtd->num_codecs; i++) pm_runtime_get_sync(rtd->codec_dais[i]->dev); - pm_runtime_get_sync(platform->dev); + for_each_rtdcom(rtd, rtdcom) { + component = rtdcom->component; + + pm_runtime_get_sync(component->dev); + }
mutex_lock_nested(&rtd->pcm_mutex, rtd->pcm_subclass);
@@ -475,7 +481,7 @@ static int soc_pcm_open(struct snd_pcm_substream *substream) } }
- if (platform->driver->ops && platform->driver->ops->open) { + if (platform && platform->driver->ops && platform->driver->ops->open) { ret = platform->driver->ops->open(substream); if (ret < 0) { dev_err(platform->dev, "ASoC: can't open platform" @@ -484,6 +490,25 @@ static int soc_pcm_open(struct snd_pcm_substream *substream) } }
+ ret = 0; + for_each_rtdcom(rtd, rtdcom) { + component = rtdcom->component; + + if (!component->driver->ops || + !component->driver->ops->open) + continue; + + __ret = component->driver->ops->open(substream); + if (__ret < 0) { + dev_err(component->dev, + "ASoC: can't open platform %s: %d\n", + component->name, ret); + ret = __ret; + } + } + if (ret < 0) + goto component_err; + for (i = 0; i < rtd->num_codecs; i++) { codec_dai = rtd->codec_dais[i]; if (codec_dai->driver->ops && codec_dai->driver->ops->startup) { @@ -590,7 +615,16 @@ static int soc_pcm_open(struct snd_pcm_substream *substream) codec_dai->driver->ops->shutdown(substream, codec_dai); }
- if (platform->driver->ops && platform->driver->ops->close) +component_err: + for_each_rtdcom(rtd, rtdcom) { + component = rtdcom->component; + + if (component->driver->ops && + component->driver->ops->close) + component->driver->ops->close(substream); + } + + if (platform && platform->driver->ops && platform->driver->ops->close) platform->driver->ops->close(substream);
platform_err: @@ -599,8 +633,13 @@ static int soc_pcm_open(struct snd_pcm_substream *substream) out: mutex_unlock(&rtd->pcm_mutex);
- pm_runtime_mark_last_busy(platform->dev); - pm_runtime_put_autosuspend(platform->dev); + for_each_rtdcom(rtd, rtdcom) { + component = rtdcom->component; + + pm_runtime_mark_last_busy(component->dev); + pm_runtime_put_autosuspend(component->dev); + } + for (i = 0; i < rtd->num_codecs; i++) { pm_runtime_mark_last_busy(rtd->codec_dais[i]->dev); pm_runtime_put_autosuspend(rtd->codec_dais[i]->dev); @@ -655,6 +694,8 @@ static int soc_pcm_close(struct snd_pcm_substream *substream) { struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_soc_platform *platform = rtd->platform; + struct snd_soc_component *component; + struct snd_soc_rtdcom_list *rtdcom; struct snd_soc_dai *cpu_dai = rtd->cpu_dai; struct snd_soc_dai *codec_dai; int i; @@ -687,9 +728,17 @@ static int soc_pcm_close(struct snd_pcm_substream *substream) if (rtd->dai_link->ops && rtd->dai_link->ops->shutdown) rtd->dai_link->ops->shutdown(substream);
- if (platform->driver->ops && platform->driver->ops->close) + if (platform && platform->driver->ops && platform->driver->ops->close) platform->driver->ops->close(substream);
+ for_each_rtdcom(rtd, rtdcom) { + component = rtdcom->component; + + if (component->driver->ops && + component->driver->ops->close) + component->driver->ops->close(substream); + } + if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { if (snd_soc_runtime_ignore_pmdown_time(rtd)) { /* powered down playback stream now */ @@ -711,8 +760,12 @@ static int soc_pcm_close(struct snd_pcm_substream *substream)
mutex_unlock(&rtd->pcm_mutex);
- pm_runtime_mark_last_busy(platform->dev); - pm_runtime_put_autosuspend(platform->dev); + for_each_rtdcom(rtd, rtdcom) { + component = rtdcom->component; + + pm_runtime_mark_last_busy(component->dev); + pm_runtime_put_autosuspend(component->dev); + }
for (i = 0; i < rtd->num_codecs; i++) { pm_runtime_mark_last_busy(rtd->codec_dais[i]->dev); @@ -741,6 +794,8 @@ static int soc_pcm_prepare(struct snd_pcm_substream *substream) { struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_soc_platform *platform = rtd->platform; + struct snd_soc_component *component; + struct snd_soc_rtdcom_list *rtdcom; struct snd_soc_dai *cpu_dai = rtd->cpu_dai; struct snd_soc_dai *codec_dai; int i, ret = 0; @@ -756,7 +811,7 @@ static int soc_pcm_prepare(struct snd_pcm_substream *substream) } }
- if (platform->driver->ops && platform->driver->ops->prepare) { + if (platform && platform->driver->ops && platform->driver->ops->prepare) { ret = platform->driver->ops->prepare(substream); if (ret < 0) { dev_err(platform->dev, "ASoC: platform prepare error:" @@ -765,6 +820,21 @@ static int soc_pcm_prepare(struct snd_pcm_substream *substream) } }
+ for_each_rtdcom(rtd, rtdcom) { + component = rtdcom->component; + + if (!component->driver->ops || + !component->driver->ops->prepare) + continue; + + ret = component->driver->ops->prepare(substream); + if (ret < 0) { + dev_err(component->dev, "ASoC: platform prepare error:" + " %d\n", ret); + goto out; + } + } + for (i = 0; i < rtd->num_codecs; i++) { codec_dai = rtd->codec_dais[i]; if (codec_dai->driver->ops && codec_dai->driver->ops->prepare) { @@ -847,8 +917,10 @@ static int soc_pcm_hw_params(struct snd_pcm_substream *substream, { struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_soc_platform *platform = rtd->platform; + struct snd_soc_component *component; + struct snd_soc_rtdcom_list *rtdcom; struct snd_soc_dai *cpu_dai = rtd->cpu_dai; - int i, ret = 0; + int i, ret = 0, __ret;
mutex_lock_nested(&rtd->pcm_mutex, rtd->pcm_subclass);
@@ -911,7 +983,7 @@ static int soc_pcm_hw_params(struct snd_pcm_substream *substream, if (ret < 0) goto interface_err;
- if (platform->driver->ops && platform->driver->ops->hw_params) { + if (platform && platform->driver->ops && platform->driver->ops->hw_params) { ret = platform->driver->ops->hw_params(substream, params); if (ret < 0) { dev_err(platform->dev, "ASoC: %s hw params failed: %d\n", @@ -920,6 +992,25 @@ static int soc_pcm_hw_params(struct snd_pcm_substream *substream, } }
+ ret = 0; + for_each_rtdcom(rtd, rtdcom) { + component = rtdcom->component; + + if (!component->driver->ops || + !component->driver->ops->hw_params) + continue; + + __ret = component->driver->ops->hw_params(substream, params); + if (__ret < 0) { + dev_err(component->dev, + "ASoC: %s hw params failed: %d\n", + component->name, ret); + ret = __ret; + } + } + if (ret < 0) + goto component_err; + /* store the parameters for each DAIs */ cpu_dai->rate = params_rate(params); cpu_dai->channels = params_channels(params); @@ -930,6 +1021,18 @@ static int soc_pcm_hw_params(struct snd_pcm_substream *substream, mutex_unlock(&rtd->pcm_mutex); return ret;
+component_err: + for_each_rtdcom(rtd, rtdcom) { + component = rtdcom->component; + + if (component->driver->ops && + component->driver->ops->hw_free) + component->driver->ops->hw_free(substream); + } + + if (platform && platform->driver->ops && platform->driver->ops->hw_free) + platform->driver->ops->hw_free(substream); + platform_err: if (cpu_dai->driver->ops && cpu_dai->driver->ops->hw_free) cpu_dai->driver->ops->hw_free(substream, cpu_dai); @@ -959,6 +1062,8 @@ static int soc_pcm_hw_free(struct snd_pcm_substream *substream) { struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_soc_platform *platform = rtd->platform; + struct snd_soc_component *component; + struct snd_soc_rtdcom_list *rtdcom; struct snd_soc_dai *cpu_dai = rtd->cpu_dai; struct snd_soc_dai *codec_dai; bool playback = substream->stream == SNDRV_PCM_STREAM_PLAYBACK; @@ -995,9 +1100,18 @@ static int soc_pcm_hw_free(struct snd_pcm_substream *substream) rtd->dai_link->ops->hw_free(substream);
/* free any DMA resources */ - if (platform->driver->ops && platform->driver->ops->hw_free) + if (platform && platform->driver->ops && platform->driver->ops->hw_free) platform->driver->ops->hw_free(substream);
+ /* free any component resources */ + for_each_rtdcom(rtd, rtdcom) { + component = rtdcom->component; + + if (component->driver->ops && + component->driver->ops->hw_free) + component->driver->ops->hw_free(substream); + } + /* now free hw params for the DAIs */ for (i = 0; i < rtd->num_codecs; i++) { codec_dai = rtd->codec_dais[i]; @@ -1016,6 +1130,8 @@ static int soc_pcm_trigger(struct snd_pcm_substream *substream, int cmd) { struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_soc_platform *platform = rtd->platform; + struct snd_soc_component *component; + struct snd_soc_rtdcom_list *rtdcom; struct snd_soc_dai *cpu_dai = rtd->cpu_dai; struct snd_soc_dai *codec_dai; int i, ret; @@ -1030,12 +1146,23 @@ static int soc_pcm_trigger(struct snd_pcm_substream *substream, int cmd) } }
- if (platform->driver->ops && platform->driver->ops->trigger) { + if (platform && platform->driver->ops && platform->driver->ops->trigger) { ret = platform->driver->ops->trigger(substream, cmd); if (ret < 0) return ret; }
+ for_each_rtdcom(rtd, rtdcom) { + component = rtdcom->component; + + if (component->driver->ops && + component->driver->ops->trigger) { + ret = component->driver->ops->trigger(substream, cmd); + if (ret < 0) + return ret; + } + } + if (cpu_dai->driver->ops && cpu_dai->driver->ops->trigger) { ret = cpu_dai->driver->ops->trigger(substream, cmd, cpu_dai); if (ret < 0) @@ -1086,6 +1213,8 @@ static snd_pcm_uframes_t soc_pcm_pointer(struct snd_pcm_substream *substream) { struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_soc_platform *platform = rtd->platform; + struct snd_soc_component *component; + struct snd_soc_rtdcom_list *rtdcom; struct snd_soc_dai *cpu_dai = rtd->cpu_dai; struct snd_soc_dai *codec_dai; struct snd_pcm_runtime *runtime = substream->runtime; @@ -1094,9 +1223,19 @@ static snd_pcm_uframes_t soc_pcm_pointer(struct snd_pcm_substream *substream) snd_pcm_sframes_t codec_delay = 0; int i;
- if (platform->driver->ops && platform->driver->ops->pointer) + if (platform && platform->driver->ops && platform->driver->ops->pointer) offset = platform->driver->ops->pointer(substream);
+ for_each_rtdcom(rtd, rtdcom) { + component = rtdcom->component; + + if (component->driver->ops && + component->driver->ops->pointer) { + offset = component->driver->ops->pointer(substream); + break; + } + } + if (cpu_dai->driver->ops && cpu_dai->driver->ops->delay) delay += cpu_dai->driver->ops->delay(substream, cpu_dai);
@@ -2281,9 +2420,20 @@ static int soc_pcm_ioctl(struct snd_pcm_substream *substream, { struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_soc_platform *platform = rtd->platform; + struct snd_soc_component *component; + struct snd_soc_rtdcom_list *rtdcom;
- if (platform->driver->ops && platform->driver->ops->ioctl) + if (platform && platform->driver->ops && platform->driver->ops->ioctl) return platform->driver->ops->ioctl(substream, cmd, arg); + + for_each_rtdcom(rtd, rtdcom) { + component = rtdcom->component; + + if (component->driver->ops && + component->driver->ops->ioctl) + return component->driver->ops->ioctl(substream, cmd, arg); + } + return snd_pcm_lib_ioctl(substream, cmd, arg); }
@@ -2640,6 +2790,116 @@ static void soc_pcm_free(struct snd_pcm *pcm) } }
+static int soc_rtdcom_ack(struct snd_pcm_substream *substream) +{ + struct snd_soc_pcm_runtime *rtd = substream->private_data; + struct snd_soc_rtdcom_list *rtdcom; + struct snd_soc_component *component; + + for_each_rtdcom(rtd, rtdcom) { + component = rtdcom->component; + + if (!component->driver->ops || + !component->driver->ops->ack) + continue; + + /* FIXME. it returns 1st ask now */ + return component->driver->ops->ack(substream); + } + + return -EINVAL; +} + +static int soc_rtdcom_copy(struct snd_pcm_substream *substream, int channel, + snd_pcm_uframes_t pos, + void __user *buf, snd_pcm_uframes_t count) +{ + struct snd_soc_pcm_runtime *rtd = substream->private_data; + struct snd_soc_rtdcom_list *rtdcom; + struct snd_soc_component *component; + + for_each_rtdcom(rtd, rtdcom) { + component = rtdcom->component; + + if (!component->driver->ops || + !component->driver->ops->copy) + continue; + + /* FIXME. it returns 1st copy now */ + return component->driver->ops->copy(substream, channel, + pos, buf, count); + } + + return -EINVAL; +} + +static int soc_rtdcom_silence(struct snd_pcm_substream *substream, int channel, + snd_pcm_uframes_t pos, snd_pcm_uframes_t count) +{ + struct snd_soc_pcm_runtime *rtd = substream->private_data; + struct snd_soc_rtdcom_list *rtdcom; + struct snd_soc_component *component; + + for_each_rtdcom(rtd, rtdcom) { + component = rtdcom->component; + + if (!component->driver->ops || + !component->driver->ops->silence) + continue; + + /* FIXME. it returns 1st silence now */ + return component->driver->ops->silence(substream, channel, + pos, count); + } + + return -EINVAL; +} + +static struct page* soc_rtdcom_page(struct snd_pcm_substream *substream, + unsigned long offset) +{ + struct snd_soc_pcm_runtime *rtd = substream->private_data; + struct snd_soc_rtdcom_list *rtdcom; + struct snd_soc_component *component; + struct page *page; + + for_each_rtdcom(rtd, rtdcom) { + component = rtdcom->component; + + if (!component->driver->ops || + !component->driver->ops->page) + continue; + + /* FIXME. it returns 1st page now */ + page = component->driver->ops->page(substream, offset); + if (page) + return page; + } + + return NULL; +} + +static int soc_rtdcom_mmap(struct snd_pcm_substream *substream, + struct vm_area_struct *vma) +{ + struct snd_soc_pcm_runtime *rtd = substream->private_data; + struct snd_soc_rtdcom_list *rtdcom; + struct snd_soc_component *component; + + for_each_rtdcom(rtd, rtdcom) { + component = rtdcom->component; + + if (!component->driver->ops || + !component->driver->ops->mmap) + continue; + + /* FIXME. it returns 1st mmap now */ + return component->driver->ops->mmap(substream, vma); + } + + return -EINVAL; +} + /* create a new pcm */ int soc_new_pcm(struct snd_soc_pcm_runtime *rtd, int num) { @@ -2647,6 +2907,7 @@ int soc_new_pcm(struct snd_soc_pcm_runtime *rtd, int num) struct snd_soc_dai *codec_dai; struct snd_soc_dai *cpu_dai = rtd->cpu_dai; struct snd_soc_component *component; + struct snd_soc_rtdcom_list *rtdcom; struct snd_pcm *pcm; char new_name[64]; int ret = 0, playback = 0, capture = 0; @@ -2741,7 +3002,26 @@ int soc_new_pcm(struct snd_soc_pcm_runtime *rtd, int num) rtd->ops.ioctl = soc_pcm_ioctl; }
- if (platform->driver->ops) { + for_each_rtdcom(rtd, rtdcom) { + const struct snd_pcm_ops *ops = rtdcom->component->driver->ops; + + if (!ops) + continue; + + if (ops->ack) + rtd->ops.ack = soc_rtdcom_ack; + if (ops->copy) + rtd->ops.copy = soc_rtdcom_copy; + if (ops->silence) + rtd->ops.silence = soc_rtdcom_silence; + if (ops->page) + rtd->ops.page = soc_rtdcom_page; + if (ops->mmap) + rtd->ops.mmap = soc_rtdcom_mmap; + } + + /* overwrite */ + if (platform && platform->driver->ops) { rtd->ops.ack = platform->driver->ops->ack; rtd->ops.copy = platform->driver->ops->copy; rtd->ops.silence = platform->driver->ops->silence;
snd_soc_platform_driver has snd_compr_ops, and it will be replaced into snd_soc_component_driver in the future. To prepare it, component driver has it.
After this patch, rtd->platform is no longer mandatory
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com --- include/sound/soc.h | 1 + sound/soc/soc-compress.c | 366 ++++++++++++++++++++++++++++++++++++++++++----- 2 files changed, 329 insertions(+), 38 deletions(-)
diff --git a/include/sound/soc.h b/include/sound/soc.h index f26897c..d953912 100644 --- a/include/sound/soc.h +++ b/include/sound/soc.h @@ -815,6 +815,7 @@ struct snd_soc_component_driver { int (*stream_event)(struct snd_soc_component *, int event);
const struct snd_pcm_ops *ops; + const struct snd_compr_ops *compr_ops;
/* probe ordering - for components with runtime dependencies */ int probe_order; diff --git a/sound/soc/soc-compress.c b/sound/soc/soc-compress.c index bfd71b8..a75dc5f 100644 --- a/sound/soc/soc-compress.c +++ b/sound/soc/soc-compress.c @@ -30,8 +30,10 @@ static int soc_compr_open(struct snd_compr_stream *cstream) { struct snd_soc_pcm_runtime *rtd = cstream->private_data; struct snd_soc_platform *platform = rtd->platform; + struct snd_soc_component *component; + struct snd_soc_rtdcom_list *rtdcom; struct snd_soc_dai *cpu_dai = rtd->cpu_dai; - int ret = 0; + int ret = 0, __ret;
mutex_lock_nested(&rtd->pcm_mutex, rtd->pcm_subclass);
@@ -44,7 +46,7 @@ static int soc_compr_open(struct snd_compr_stream *cstream) } }
- if (platform->driver->compr_ops && platform->driver->compr_ops->open) { + if (platform && platform->driver->compr_ops && platform->driver->compr_ops->open) { ret = platform->driver->compr_ops->open(cstream); if (ret < 0) { pr_err("compress asoc: can't open platform %s\n", @@ -53,6 +55,23 @@ static int soc_compr_open(struct snd_compr_stream *cstream) } }
+ for_each_rtdcom(rtd, rtdcom) { + component = rtdcom->component; + + if (!component->driver->compr_ops || + !component->driver->compr_ops->open) + continue; + + __ret = component->driver->compr_ops->open(cstream); + if (__ret < 0) { + pr_err("compress asoc: can't open platform %s\n", + component->name); + ret = __ret; + } + } + if (ret < 0) + goto machine_err; + if (rtd->dai_link->compr_ops && rtd->dai_link->compr_ops->startup) { ret = rtd->dai_link->compr_ops->startup(cstream); if (ret < 0) { @@ -68,7 +87,15 @@ static int soc_compr_open(struct snd_compr_stream *cstream) return 0;
machine_err: - if (platform->driver->compr_ops && platform->driver->compr_ops->free) + for_each_rtdcom(rtd, rtdcom) { + component = rtdcom->component; + + if (component->driver->compr_ops && + component->driver->compr_ops->free) + component->driver->compr_ops->free(cstream); + } + + if (platform && platform->driver->compr_ops && platform->driver->compr_ops->free) platform->driver->compr_ops->free(cstream); plat_err: if (cpu_dai->driver->cops && cpu_dai->driver->cops->shutdown) @@ -83,11 +110,13 @@ static int soc_compr_open_fe(struct snd_compr_stream *cstream) struct snd_soc_pcm_runtime *fe = cstream->private_data; struct snd_pcm_substream *fe_substream = fe->pcm->streams[0].substream; struct snd_soc_platform *platform = fe->platform; + struct snd_soc_component *component; + struct snd_soc_rtdcom_list *rtdcom; struct snd_soc_dai *cpu_dai = fe->cpu_dai; struct snd_soc_dpcm *dpcm; struct snd_soc_dapm_widget_list *list; int stream; - int ret = 0; + int ret = 0, __ret;
if (cstream->direction == SND_COMPRESS_PLAYBACK) stream = SNDRV_PCM_STREAM_PLAYBACK; @@ -106,7 +135,7 @@ static int soc_compr_open_fe(struct snd_compr_stream *cstream) }
- if (platform->driver->compr_ops && platform->driver->compr_ops->open) { + if (platform && platform->driver->compr_ops && platform->driver->compr_ops->open) { ret = platform->driver->compr_ops->open(cstream); if (ret < 0) { pr_err("compress asoc: can't open platform %s\n", @@ -115,6 +144,23 @@ static int soc_compr_open_fe(struct snd_compr_stream *cstream) } }
+ for_each_rtdcom(fe, rtdcom) { + component = rtdcom->component; + + if (!component->driver->compr_ops || + !component->driver->compr_ops->open) + continue; + + __ret = component->driver->compr_ops->open(cstream); + if (__ret < 0) { + pr_err("compress asoc: can't open platform %s\n", + component->name); + ret = __ret; + } + } + if (ret < 0) + goto machine_err; + if (fe->dai_link->compr_ops && fe->dai_link->compr_ops->startup) { ret = fe->dai_link->compr_ops->startup(cstream); if (ret < 0) { @@ -166,7 +212,15 @@ static int soc_compr_open_fe(struct snd_compr_stream *cstream) if (fe->dai_link->compr_ops && fe->dai_link->compr_ops->shutdown) fe->dai_link->compr_ops->shutdown(cstream); machine_err: - if (platform->driver->compr_ops && platform->driver->compr_ops->free) + for_each_rtdcom(fe, rtdcom) { + component = rtdcom->component; + + if (component->driver->compr_ops && + component->driver->compr_ops->free) + component->driver->compr_ops->free(cstream); + } + + if (playback && platform->driver->compr_ops && platform->driver->compr_ops->free) platform->driver->compr_ops->free(cstream); plat_err: if (cpu_dai->driver->cops && cpu_dai->driver->cops->shutdown) @@ -209,6 +263,8 @@ static int soc_compr_free(struct snd_compr_stream *cstream) { struct snd_soc_pcm_runtime *rtd = cstream->private_data; struct snd_soc_platform *platform = rtd->platform; + struct snd_soc_component *component; + struct snd_soc_rtdcom_list *rtdcom; struct snd_soc_dai *cpu_dai = rtd->cpu_dai; struct snd_soc_dai *codec_dai = rtd->codec_dai; int stream; @@ -234,7 +290,15 @@ static int soc_compr_free(struct snd_compr_stream *cstream) if (rtd->dai_link->compr_ops && rtd->dai_link->compr_ops->shutdown) rtd->dai_link->compr_ops->shutdown(cstream);
- if (platform->driver->compr_ops && platform->driver->compr_ops->free) + for_each_rtdcom(rtd, rtdcom) { + component = rtdcom->component; + + if (component->driver->compr_ops && + component->driver->compr_ops->free) + component->driver->compr_ops->free(cstream); + } + + if (platform && platform->driver->compr_ops && platform->driver->compr_ops->free) platform->driver->compr_ops->free(cstream);
if (cpu_dai->driver->cops && cpu_dai->driver->cops->shutdown) @@ -266,6 +330,8 @@ static int soc_compr_free_fe(struct snd_compr_stream *cstream) { struct snd_soc_pcm_runtime *fe = cstream->private_data; struct snd_soc_platform *platform = fe->platform; + struct snd_soc_component *component; + struct snd_soc_rtdcom_list *rtdcom; struct snd_soc_dai *cpu_dai = fe->cpu_dai; struct snd_soc_dpcm *dpcm; int stream, ret; @@ -303,7 +369,15 @@ static int soc_compr_free_fe(struct snd_compr_stream *cstream) if (fe->dai_link->compr_ops && fe->dai_link->compr_ops->shutdown) fe->dai_link->compr_ops->shutdown(cstream);
- if (platform->driver->compr_ops && platform->driver->compr_ops->free) + for_each_rtdcom(fe, rtdcom) { + component = rtdcom->component; + + if (component->driver->compr_ops && + component->driver->compr_ops->free) + component->driver->compr_ops->free(cstream); + } + + if (platform && platform->driver->compr_ops && platform->driver->compr_ops->free) platform->driver->compr_ops->free(cstream);
if (cpu_dai->driver->cops && cpu_dai->driver->cops->shutdown) @@ -318,13 +392,29 @@ static int soc_compr_trigger(struct snd_compr_stream *cstream, int cmd)
struct snd_soc_pcm_runtime *rtd = cstream->private_data; struct snd_soc_platform *platform = rtd->platform; + struct snd_soc_component *component; + struct snd_soc_rtdcom_list *rtdcom; struct snd_soc_dai *codec_dai = rtd->codec_dai; struct snd_soc_dai *cpu_dai = rtd->cpu_dai; - int ret = 0; + int ret = 0, __ret;;
mutex_lock_nested(&rtd->pcm_mutex, rtd->pcm_subclass);
- if (platform->driver->compr_ops && platform->driver->compr_ops->trigger) { + for_each_rtdcom(rtd, rtdcom) { + component = rtdcom->component; + + if (!component->driver->compr_ops || + !component->driver->compr_ops->trigger) + continue; + + __ret = component->driver->compr_ops->trigger(cstream, cmd); + if (__ret < 0) + ret = __ret; + } + if (ret < 0) + goto out; + + if (platform && platform->driver->compr_ops && platform->driver->compr_ops->trigger) { ret = platform->driver->compr_ops->trigger(cstream, cmd); if (ret < 0) goto out; @@ -352,16 +442,32 @@ static int soc_compr_trigger_fe(struct snd_compr_stream *cstream, int cmd) { struct snd_soc_pcm_runtime *fe = cstream->private_data; struct snd_soc_platform *platform = fe->platform; + struct snd_soc_component *component; + struct snd_soc_rtdcom_list *rtdcom; struct snd_soc_dai *cpu_dai = fe->cpu_dai; - int ret = 0, stream; + int ret = 0, __ret, stream;
if (cmd == SND_COMPR_TRIGGER_PARTIAL_DRAIN || cmd == SND_COMPR_TRIGGER_DRAIN) {
- if (platform->driver->compr_ops && + if (platform && + platform->driver->compr_ops && platform->driver->compr_ops->trigger) return platform->driver->compr_ops->trigger(cstream, cmd); + + for_each_rtdcom(fe, rtdcom) { + component = rtdcom->component; + + if (!component->driver->compr_ops || + !component->driver->compr_ops->trigger) + continue; + + __ret = component->driver->compr_ops->trigger(cstream, cmd); + if (__ret < 0) + ret = __ret; + } + return ret; }
if (cstream->direction == SND_COMPRESS_PLAYBACK) @@ -378,7 +484,21 @@ static int soc_compr_trigger_fe(struct snd_compr_stream *cstream, int cmd) goto out; }
- if (platform->driver->compr_ops && platform->driver->compr_ops->trigger) { + for_each_rtdcom(fe, rtdcom) { + component = rtdcom->component; + + if (!component->driver->compr_ops || + !component->driver->compr_ops->trigger) + continue; + + __ret = component->driver->compr_ops->trigger(cstream, cmd); + if (__ret < 0) + ret = __ret; + } + if (ret < 0) + goto out; + + if (platform && platform->driver->compr_ops && platform->driver->compr_ops->trigger) { ret = platform->driver->compr_ops->trigger(cstream, cmd); if (ret < 0) goto out; @@ -414,8 +534,10 @@ static int soc_compr_set_params(struct snd_compr_stream *cstream, { struct snd_soc_pcm_runtime *rtd = cstream->private_data; struct snd_soc_platform *platform = rtd->platform; + struct snd_soc_component *component; + struct snd_soc_rtdcom_list *rtdcom; struct snd_soc_dai *cpu_dai = rtd->cpu_dai; - int ret = 0; + int ret = 0, __ret;
mutex_lock_nested(&rtd->pcm_mutex, rtd->pcm_subclass);
@@ -431,7 +553,21 @@ static int soc_compr_set_params(struct snd_compr_stream *cstream, goto err; }
- if (platform->driver->compr_ops && platform->driver->compr_ops->set_params) { + for_each_rtdcom(rtd, rtdcom) { + component = rtdcom->component; + + if (!component->driver->compr_ops || + !component->driver->compr_ops->set_params) + continue; + + __ret = component->driver->compr_ops->set_params(cstream, params); + if (__ret < 0) + ret = __ret; + } + if (ret < 0) + goto err; + + if (platform && platform->driver->compr_ops && platform->driver->compr_ops->set_params) { ret = platform->driver->compr_ops->set_params(cstream, params); if (ret < 0) goto err; @@ -469,8 +605,10 @@ static int soc_compr_set_params_fe(struct snd_compr_stream *cstream, struct snd_soc_pcm_runtime *fe = cstream->private_data; struct snd_pcm_substream *fe_substream = fe->pcm->streams[0].substream; struct snd_soc_platform *platform = fe->platform; + struct snd_soc_component *component; + struct snd_soc_rtdcom_list *rtdcom; struct snd_soc_dai *cpu_dai = fe->cpu_dai; - int ret = 0, stream; + int ret = 0, __ret, stream;
if (cstream->direction == SND_COMPRESS_PLAYBACK) stream = SNDRV_PCM_STREAM_PLAYBACK; @@ -485,7 +623,21 @@ static int soc_compr_set_params_fe(struct snd_compr_stream *cstream, goto out; }
- if (platform->driver->compr_ops && platform->driver->compr_ops->set_params) { + for_each_rtdcom(fe, rtdcom) { + component = rtdcom->component; + + if (!component->driver->compr_ops || + !component->driver->compr_ops->set_params) + continue; + + __ret = component->driver->compr_ops->set_params(cstream, params); + if (__ret < 0) + ret = __ret; + } + if (ret < 0) + goto out; + + if (platform && platform->driver->compr_ops && platform->driver->compr_ops->set_params) { ret = platform->driver->compr_ops->set_params(cstream, params); if (ret < 0) goto out; @@ -529,8 +681,10 @@ static int soc_compr_get_params(struct snd_compr_stream *cstream, { struct snd_soc_pcm_runtime *rtd = cstream->private_data; struct snd_soc_platform *platform = rtd->platform; + struct snd_soc_component *component; + struct snd_soc_rtdcom_list *rtdcom; struct snd_soc_dai *cpu_dai = rtd->cpu_dai; - int ret = 0; + int ret = 0, __ret;
mutex_lock_nested(&rtd->pcm_mutex, rtd->pcm_subclass);
@@ -540,7 +694,21 @@ static int soc_compr_get_params(struct snd_compr_stream *cstream, goto err; }
- if (platform->driver->compr_ops && platform->driver->compr_ops->get_params) + for_each_rtdcom(rtd, rtdcom) { + component = rtdcom->component; + + if (!component->driver->compr_ops || + !component->driver->compr_ops->get_params) + continue; + + __ret = component->driver->compr_ops->get_params(cstream, params); + if (__ret < 0) + ret = __ret; + } + if (ret < 0) + goto err; + + if (platform && platform->driver->compr_ops && platform->driver->compr_ops->get_params) ret = platform->driver->compr_ops->get_params(cstream, params);
err: @@ -553,13 +721,29 @@ static int soc_compr_get_caps(struct snd_compr_stream *cstream, { struct snd_soc_pcm_runtime *rtd = cstream->private_data; struct snd_soc_platform *platform = rtd->platform; - int ret = 0; + struct snd_soc_component *component; + struct snd_soc_rtdcom_list *rtdcom; + int ret = 0, __ret;
mutex_lock_nested(&rtd->pcm_mutex, rtd->pcm_subclass);
- if (platform->driver->compr_ops && platform->driver->compr_ops->get_caps) - ret = platform->driver->compr_ops->get_caps(cstream, caps); + for_each_rtdcom(rtd, rtdcom) { + component = rtdcom->component;
+ if (!component->driver->compr_ops || + !component->driver->compr_ops->get_caps) + continue; + + __ret = component->driver->compr_ops->get_caps(cstream, caps); + if (__ret < 0) + ret = __ret; + } + if (ret < 0) + goto err; + + if (platform && platform->driver->compr_ops && platform->driver->compr_ops->get_caps) + ret = platform->driver->compr_ops->get_caps(cstream, caps); +err: mutex_unlock(&rtd->pcm_mutex); return ret; } @@ -569,13 +753,29 @@ static int soc_compr_get_codec_caps(struct snd_compr_stream *cstream, { struct snd_soc_pcm_runtime *rtd = cstream->private_data; struct snd_soc_platform *platform = rtd->platform; - int ret = 0; + struct snd_soc_component *component; + struct snd_soc_rtdcom_list *rtdcom; + int ret = 0, __ret;
mutex_lock_nested(&rtd->pcm_mutex, rtd->pcm_subclass);
- if (platform->driver->compr_ops && platform->driver->compr_ops->get_codec_caps) - ret = platform->driver->compr_ops->get_codec_caps(cstream, codec); + for_each_rtdcom(rtd, rtdcom) { + component = rtdcom->component; + + if (!component->driver->compr_ops || + !component->driver->compr_ops->get_codec_caps) + continue;
+ __ret = component->driver->compr_ops->get_codec_caps(cstream, codec); + if (__ret < 0) + ret = __ret; + } + if (ret < 0) + goto err; + + if (platform && platform->driver->compr_ops && platform->driver->compr_ops->get_codec_caps) + ret = platform->driver->compr_ops->get_codec_caps(cstream, codec); +err: mutex_unlock(&rtd->pcm_mutex); return ret; } @@ -584,8 +784,10 @@ static int soc_compr_ack(struct snd_compr_stream *cstream, size_t bytes) { struct snd_soc_pcm_runtime *rtd = cstream->private_data; struct snd_soc_platform *platform = rtd->platform; + struct snd_soc_component *component; + struct snd_soc_rtdcom_list *rtdcom; struct snd_soc_dai *cpu_dai = rtd->cpu_dai; - int ret = 0; + int ret = 0, __ret;
mutex_lock_nested(&rtd->pcm_mutex, rtd->pcm_subclass);
@@ -595,7 +797,21 @@ static int soc_compr_ack(struct snd_compr_stream *cstream, size_t bytes) goto err; }
- if (platform->driver->compr_ops && platform->driver->compr_ops->ack) + for_each_rtdcom(rtd, rtdcom) { + component = rtdcom->component; + + if (!component->driver->compr_ops || + !component->driver->compr_ops->ack) + continue; + + __ret = component->driver->compr_ops->ack(cstream, bytes); + if (__ret < 0) + ret = __ret; + } + if (ret < 0) + goto err; + + if (platform && platform->driver->compr_ops && platform->driver->compr_ops->ack) ret = platform->driver->compr_ops->ack(cstream, bytes);
err: @@ -608,7 +824,9 @@ static int soc_compr_pointer(struct snd_compr_stream *cstream, { struct snd_soc_pcm_runtime *rtd = cstream->private_data; struct snd_soc_platform *platform = rtd->platform; - int ret = 0; + struct snd_soc_component *component; + struct snd_soc_rtdcom_list *rtdcom; + int ret = 0, __ret; struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
mutex_lock_nested(&rtd->pcm_mutex, rtd->pcm_subclass); @@ -616,9 +834,23 @@ static int soc_compr_pointer(struct snd_compr_stream *cstream, if (cpu_dai->driver->cops && cpu_dai->driver->cops->pointer) cpu_dai->driver->cops->pointer(cstream, tstamp, cpu_dai);
- if (platform->driver->compr_ops && platform->driver->compr_ops->pointer) - ret = platform->driver->compr_ops->pointer(cstream, tstamp); + for_each_rtdcom(rtd, rtdcom) { + component = rtdcom->component;
+ if (!component->driver->compr_ops || + !component->driver->compr_ops->pointer) + continue; + + __ret = component->driver->compr_ops->pointer(cstream, tstamp); + if (__ret < 0) + ret = __ret; + } + if (ret < 0) + goto err; + + if (platform && platform->driver->compr_ops && platform->driver->compr_ops->pointer) + ret = platform->driver->compr_ops->pointer(cstream, tstamp); +err: mutex_unlock(&rtd->pcm_mutex); return ret; } @@ -628,13 +860,29 @@ static int soc_compr_copy(struct snd_compr_stream *cstream, { struct snd_soc_pcm_runtime *rtd = cstream->private_data; struct snd_soc_platform *platform = rtd->platform; - int ret = 0; + struct snd_soc_component *component; + struct snd_soc_rtdcom_list *rtdcom; + int ret = 0, __ret;
mutex_lock_nested(&rtd->pcm_mutex, rtd->pcm_subclass);
- if (platform->driver->compr_ops && platform->driver->compr_ops->copy) - ret = platform->driver->compr_ops->copy(cstream, buf, count); + for_each_rtdcom(rtd, rtdcom) { + component = rtdcom->component;
+ if (!component->driver->compr_ops || + !component->driver->compr_ops->copy) + continue; + + __ret = component->driver->compr_ops->copy(cstream, buf, count); + if (__ret < 0) + ret = __ret; + } + if (ret < 0) + goto err; + + if (platform && platform->driver->compr_ops && platform->driver->compr_ops->copy) + ret = platform->driver->compr_ops->copy(cstream, buf, count); +err: mutex_unlock(&rtd->pcm_mutex); return ret; } @@ -644,8 +892,10 @@ static int soc_compr_set_metadata(struct snd_compr_stream *cstream, { struct snd_soc_pcm_runtime *rtd = cstream->private_data; struct snd_soc_platform *platform = rtd->platform; + struct snd_soc_component *component; + struct snd_soc_rtdcom_list *rtdcom; struct snd_soc_dai *cpu_dai = rtd->cpu_dai; - int ret = 0; + int ret = 0, __ret;
if (cpu_dai->driver->cops && cpu_dai->driver->cops->set_metadata) { ret = cpu_dai->driver->cops->set_metadata(cstream, metadata, cpu_dai); @@ -653,7 +903,21 @@ static int soc_compr_set_metadata(struct snd_compr_stream *cstream, return ret; }
- if (platform->driver->compr_ops && platform->driver->compr_ops->set_metadata) + for_each_rtdcom(rtd, rtdcom) { + component = rtdcom->component; + + if (!component->driver->compr_ops || + !component->driver->compr_ops->set_metadata) + continue; + + __ret = component->driver->compr_ops->set_metadata(cstream, metadata); + if (__ret < 0) + ret = __ret; + } + if (ret < 0) + return ret; + + if (platform && platform->driver->compr_ops && platform->driver->compr_ops->set_metadata) ret = platform->driver->compr_ops->set_metadata(cstream, metadata);
return ret; @@ -664,8 +928,10 @@ static int soc_compr_get_metadata(struct snd_compr_stream *cstream, { struct snd_soc_pcm_runtime *rtd = cstream->private_data; struct snd_soc_platform *platform = rtd->platform; + struct snd_soc_component *component; + struct snd_soc_rtdcom_list *rtdcom; struct snd_soc_dai *cpu_dai = rtd->cpu_dai; - int ret = 0; + int ret = 0, __ret;
if (cpu_dai->driver->cops && cpu_dai->driver->cops->get_metadata) { ret = cpu_dai->driver->cops->get_metadata(cstream, metadata, cpu_dai); @@ -673,7 +939,21 @@ static int soc_compr_get_metadata(struct snd_compr_stream *cstream, return ret; }
- if (platform->driver->compr_ops && platform->driver->compr_ops->get_metadata) + for_each_rtdcom(rtd, rtdcom) { + component = rtdcom->component; + + if (!component->driver->compr_ops || + !component->driver->compr_ops->get_metadata) + continue; + + __ret = component->driver->compr_ops->get_metadata(cstream, metadata); + if (__ret < 0) + ret = __ret; + } + if (ret < 0) + return ret; + + if (platform && platform->driver->compr_ops && platform->driver->compr_ops->get_metadata) ret = platform->driver->compr_ops->get_metadata(cstream, metadata);
return ret; @@ -721,6 +1001,8 @@ int snd_soc_new_compress(struct snd_soc_pcm_runtime *rtd, int num) { struct snd_soc_codec *codec = rtd->codec; struct snd_soc_platform *platform = rtd->platform; + struct snd_soc_component *component; + struct snd_soc_rtdcom_list *rtdcom; struct snd_soc_dai *codec_dai = rtd->codec_dai; struct snd_soc_dai *cpu_dai = rtd->cpu_dai; struct snd_compr *compr; @@ -799,7 +1081,15 @@ int snd_soc_new_compress(struct snd_soc_pcm_runtime *rtd, int num) memcpy(compr->ops, &soc_compr_ops, sizeof(soc_compr_ops));
/* Add copy callback for not memory mapped DSPs */ - if (platform->driver->compr_ops && platform->driver->compr_ops->copy) + for_each_rtdcom(rtd, rtdcom) { + component = rtdcom->component; + + if (component->driver->compr_ops && + component->driver->compr_ops->copy) + compr->ops->copy = soc_compr_copy; + } + + if (platform && platform->driver->compr_ops && platform->driver->compr_ops->copy) compr->ops->copy = soc_compr_copy;
mutex_init(&compr->lock);
Now platform can be replaced to component, let's do it.
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com --- sound/soc/sh/rcar/core.c | 20 +++----------------- 1 file changed, 3 insertions(+), 17 deletions(-)
diff --git a/sound/soc/sh/rcar/core.c b/sound/soc/sh/rcar/core.c index 409bac3..8dcf1a8 100644 --- a/sound/soc/sh/rcar/core.c +++ b/sound/soc/sh/rcar/core.c @@ -1339,12 +1339,9 @@ static int rsnd_pcm_new(struct snd_soc_pcm_runtime *rtd) PREALLOC_BUFFER, PREALLOC_BUFFER_MAX); }
-static struct snd_soc_platform_driver rsnd_soc_platform = { +static const struct snd_soc_component_driver rsnd_soc_component = { .ops = &rsnd_pcm_ops, .pcm_new = rsnd_pcm_new, -}; - -static const struct snd_soc_component_driver rsnd_soc_component = { .name = "rsnd", };
@@ -1455,17 +1452,11 @@ static int rsnd_probe(struct platform_device *pdev) /* * asoc register */ - ret = snd_soc_register_platform(dev, &rsnd_soc_platform); - if (ret < 0) { - dev_err(dev, "cannot snd soc register\n"); - return ret; - } - - ret = snd_soc_register_component(dev, &rsnd_soc_component, + ret = devm_snd_soc_register_component(dev, &rsnd_soc_component, priv->daidrv, rsnd_rdai_nr(priv)); if (ret < 0) { dev_err(dev, "cannot snd dai register\n"); - goto exit_snd_soc; + goto exit_snd_probe; }
pm_runtime_enable(dev); @@ -1473,8 +1464,6 @@ static int rsnd_probe(struct platform_device *pdev) dev_info(dev, "probed\n"); return ret;
-exit_snd_soc: - snd_soc_unregister_platform(dev); exit_snd_probe: for_each_rsnd_dai(rdai, priv, i) { rsnd_dai_call(remove, &rdai->playback, priv); @@ -1510,9 +1499,6 @@ static int rsnd_remove(struct platform_device *pdev) for (i = 0; i < ARRAY_SIZE(remove_func); i++) remove_func[i](priv);
- snd_soc_unregister_component(&pdev->dev); - snd_soc_unregister_platform(&pdev->dev); - return ret; }
Now platform can be replaced to component, let's do it.
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com --- sound/soc/soc-utils.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/sound/soc/soc-utils.c b/sound/soc/soc-utils.c index 644d9a9..b7bf63d 100644 --- a/sound/soc/soc-utils.c +++ b/sound/soc/soc-utils.c @@ -284,7 +284,7 @@ static int dummy_dma_open(struct snd_pcm_substream *substream) .ioctl = snd_pcm_lib_ioctl, };
-static struct snd_soc_platform_driver dummy_platform = { +static struct snd_soc_component_driver dummy_component = { .ops = &dummy_dma_ops, };
@@ -342,7 +342,8 @@ static int snd_soc_dummy_probe(struct platform_device *pdev) if (ret < 0) return ret;
- ret = snd_soc_register_platform(&pdev->dev, &dummy_platform); + ret = devm_snd_soc_register_component(&pdev->dev, &dummy_component, + NULL, 0); if (ret < 0) { snd_soc_unregister_codec(&pdev->dev); return ret; @@ -353,7 +354,6 @@ static int snd_soc_dummy_probe(struct platform_device *pdev)
static int snd_soc_dummy_remove(struct platform_device *pdev) { - snd_soc_unregister_platform(&pdev->dev); snd_soc_unregister_codec(&pdev->dev);
return 0;
Now platform can be replaced to component, let's do it.
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com --- include/sound/dmaengine_pcm.h | 2 ++ sound/soc/soc-generic-dmaengine-pcm.c | 54 +++++++++++++++++++++-------------- 2 files changed, 34 insertions(+), 22 deletions(-)
diff --git a/include/sound/dmaengine_pcm.h b/include/sound/dmaengine_pcm.h index 67be244..c2ac20f 100644 --- a/include/sound/dmaengine_pcm.h +++ b/include/sound/dmaengine_pcm.h @@ -19,6 +19,8 @@ #include <sound/soc.h> #include <linux/dmaengine.h>
+#define SND_DMAENGINE_NAME "snd_dmaengine_pcm" + /** * snd_pcm_substream_to_dma_direction - Get dma_transfer_direction for a PCM * substream diff --git a/sound/soc/soc-generic-dmaengine-pcm.c b/sound/soc/soc-generic-dmaengine-pcm.c index d537864..dcd1c7a 100644 --- a/sound/soc/soc-generic-dmaengine-pcm.c +++ b/sound/soc/soc-generic-dmaengine-pcm.c @@ -33,13 +33,13 @@ struct dmaengine_pcm { struct dma_chan *chan[SNDRV_PCM_STREAM_LAST + 1]; const struct snd_dmaengine_pcm_config *config; - struct snd_soc_platform platform; + struct snd_soc_component component; unsigned int flags; };
-static struct dmaengine_pcm *soc_platform_to_pcm(struct snd_soc_platform *p) +static struct dmaengine_pcm *soc_component_to_pcm(struct snd_soc_component *p) { - return container_of(p, struct dmaengine_pcm, platform); + return container_of(p, struct dmaengine_pcm, component); }
static struct device *dmaengine_dma_dev(struct dmaengine_pcm *pcm, @@ -88,7 +88,9 @@ static int dmaengine_pcm_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params) { struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct dmaengine_pcm *pcm = soc_platform_to_pcm(rtd->platform); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, + SND_DMAENGINE_NAME); + struct dmaengine_pcm *pcm = soc_component_to_pcm(component); struct dma_chan *chan = snd_dmaengine_pcm_get_chan(substream); int (*prepare_slave_config)(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, @@ -119,7 +121,9 @@ static int dmaengine_pcm_hw_params(struct snd_pcm_substream *substream, static int dmaengine_pcm_set_runtime_hwparams(struct snd_pcm_substream *substream) { struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct dmaengine_pcm *pcm = soc_platform_to_pcm(rtd->platform); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, + SND_DMAENGINE_NAME); + struct dmaengine_pcm *pcm = soc_component_to_pcm(component); struct device *dma_dev = dmaengine_dma_dev(pcm, substream); struct dma_chan *chan = pcm->chan[substream->stream]; struct snd_dmaengine_dai_dma_data *dma_data; @@ -206,7 +210,9 @@ static int dmaengine_pcm_set_runtime_hwparams(struct snd_pcm_substream *substrea static int dmaengine_pcm_open(struct snd_pcm_substream *substream) { struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct dmaengine_pcm *pcm = soc_platform_to_pcm(rtd->platform); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, + SND_DMAENGINE_NAME); + struct dmaengine_pcm *pcm = soc_component_to_pcm(component); struct dma_chan *chan = pcm->chan[substream->stream]; int ret;
@@ -221,7 +227,9 @@ static struct dma_chan *dmaengine_pcm_compat_request_channel( struct snd_soc_pcm_runtime *rtd, struct snd_pcm_substream *substream) { - struct dmaengine_pcm *pcm = soc_platform_to_pcm(rtd->platform); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, + SND_DMAENGINE_NAME); + struct dmaengine_pcm *pcm = soc_component_to_pcm(component); struct snd_dmaengine_dai_dma_data *dma_data; dma_filter_fn fn = NULL;
@@ -260,9 +268,11 @@ static bool dmaengine_pcm_can_report_residue(struct device *dev,
static int dmaengine_pcm_new(struct snd_soc_pcm_runtime *rtd) { - struct dmaengine_pcm *pcm = soc_platform_to_pcm(rtd->platform); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, + SND_DMAENGINE_NAME); + struct dmaengine_pcm *pcm = soc_component_to_pcm(component); const struct snd_dmaengine_pcm_config *config = pcm->config; - struct device *dev = rtd->platform->dev; + struct device *dev = component->dev; struct snd_dmaengine_dai_dma_data *dma_data; struct snd_pcm_substream *substream; size_t prealloc_buffer_size; @@ -296,7 +306,7 @@ static int dmaengine_pcm_new(struct snd_soc_pcm_runtime *rtd) }
if (!pcm->chan[i]) { - dev_err(rtd->platform->dev, + dev_err(component->dev, "Missing dma channel for stream: %d\n", i); return -EINVAL; } @@ -320,7 +330,9 @@ static snd_pcm_uframes_t dmaengine_pcm_pointer( struct snd_pcm_substream *substream) { struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct dmaengine_pcm *pcm = soc_platform_to_pcm(rtd->platform); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, + SND_DMAENGINE_NAME); + struct dmaengine_pcm *pcm = soc_component_to_pcm(component);
if (pcm->flags & SND_DMAENGINE_PCM_FLAG_NO_RESIDUE) return snd_dmaengine_pcm_pointer_no_residue(substream); @@ -338,10 +350,9 @@ static snd_pcm_uframes_t dmaengine_pcm_pointer( .pointer = dmaengine_pcm_pointer, };
-static const struct snd_soc_platform_driver dmaengine_pcm_platform = { - .component_driver = { - .probe_order = SND_SOC_COMP_ORDER_LATE, - }, +static const struct snd_soc_component_driver dmaengine_pcm_component = { + .name = SND_DMAENGINE_NAME, + .probe_order = SND_SOC_COMP_ORDER_LATE, .ops = &dmaengine_pcm_ops, .pcm_new = dmaengine_pcm_new, }; @@ -438,8 +449,8 @@ int snd_dmaengine_pcm_register(struct device *dev, if (ret) goto err_free_dma;
- ret = snd_soc_add_platform(dev, &pcm->platform, - &dmaengine_pcm_platform); + ret = devm_snd_soc_register_component(dev, &dmaengine_pcm_component, + NULL, 0); if (ret) goto err_free_dma;
@@ -461,16 +472,15 @@ int snd_dmaengine_pcm_register(struct device *dev, */ void snd_dmaengine_pcm_unregister(struct device *dev) { - struct snd_soc_platform *platform; + struct snd_soc_component *component; struct dmaengine_pcm *pcm;
- platform = snd_soc_lookup_platform(dev); - if (!platform) + component = snd_soc_lookup_component(dev, SND_DMAENGINE_NAME); + if (!component) return;
- pcm = soc_platform_to_pcm(platform); + pcm = soc_component_to_pcm(component);
- snd_soc_remove_platform(platform); dmaengine_pcm_release_chan(pcm); kfree(pcm); }
Now, all platform are replaced to component. This patch removes all platform code.
platform_list_read_file() is replaced to component_list_read_file()
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com --- include/sound/soc.h | 101 --------------------- sound/soc/soc-compress.c | 123 -------------------------- sound/soc/soc-core.c | 224 ++--------------------------------------------- sound/soc/soc-devres.c | 35 -------- sound/soc/soc-io.c | 21 ----- sound/soc/soc-pcm.c | 80 +---------------- 6 files changed, 12 insertions(+), 572 deletions(-)
diff --git a/include/sound/soc.h b/include/sound/soc.h index d953912..bf0e90d 100644 --- a/include/sound/soc.h +++ b/include/sound/soc.h @@ -401,9 +401,7 @@ enum snd_soc_bias_level { struct snd_soc_pcm_runtime; struct snd_soc_dai; struct snd_soc_dai_driver; -struct snd_soc_platform; struct snd_soc_dai_link; -struct snd_soc_platform_driver; struct snd_soc_codec; struct snd_soc_codec_driver; struct snd_soc_component; @@ -455,15 +453,6 @@ static inline int snd_soc_resume(struct device *dev) } #endif int snd_soc_poweroff(struct device *dev); -int snd_soc_register_platform(struct device *dev, - const struct snd_soc_platform_driver *platform_drv); -int devm_snd_soc_register_platform(struct device *dev, - const struct snd_soc_platform_driver *platform_drv); -void snd_soc_unregister_platform(struct device *dev); -int snd_soc_add_platform(struct device *dev, struct snd_soc_platform *platform, - const struct snd_soc_platform_driver *platform_drv); -void snd_soc_remove_platform(struct snd_soc_platform *platform); -struct snd_soc_platform *snd_soc_lookup_platform(struct device *dev); int snd_soc_register_codec(struct device *dev, const struct snd_soc_codec_driver *codec_drv, struct snd_soc_dai_driver *dai_drv, int num_dai); @@ -482,11 +471,6 @@ struct snd_soc_component *snd_soc_lookup_component(struct device *dev, const char *driver_name); int snd_soc_cache_init(struct snd_soc_codec *codec); int snd_soc_cache_exit(struct snd_soc_codec *codec); - -int snd_soc_platform_read(struct snd_soc_platform *platform, - unsigned int reg); -int snd_soc_platform_write(struct snd_soc_platform *platform, - unsigned int reg, unsigned int val); int soc_new_pcm(struct snd_soc_pcm_runtime *rtd, int num); #ifdef CONFIG_SND_SOC_COMPRESS int snd_soc_new_compress(struct snd_soc_pcm_runtime *rtd, int num); @@ -617,8 +601,6 @@ int snd_soc_add_component_controls(struct snd_soc_component *component, const struct snd_kcontrol_new *controls, unsigned int num_controls); int snd_soc_add_codec_controls(struct snd_soc_codec *codec, const struct snd_kcontrol_new *controls, unsigned int num_controls); -int snd_soc_add_platform_controls(struct snd_soc_platform *platform, - const struct snd_kcontrol_new *controls, unsigned int num_controls); int snd_soc_add_card_controls(struct snd_soc_card *soc_card, const struct snd_kcontrol_new *controls, int num_controls); int snd_soc_add_dai_controls(struct snd_soc_dai *dai, @@ -800,7 +782,6 @@ struct snd_soc_component_driver { int (*suspend)(struct snd_soc_component *); int (*resume)(struct snd_soc_component *);
- /* pcm creation and destruction */ int (*pcm_new)(struct snd_soc_pcm_runtime *); void (*pcm_free)(struct snd_pcm *);
@@ -882,8 +863,6 @@ struct snd_soc_component { void (*remove)(struct snd_soc_component *); int (*suspend)(struct snd_soc_component *); int (*resume)(struct snd_soc_component *); - int (*pcm_new)(struct snd_soc_pcm_runtime *); - void (*pcm_free)(struct snd_pcm *);
/* machine specific init */ int (*init)(struct snd_soc_component *component); @@ -969,39 +948,12 @@ struct snd_soc_codec_driver { bool ignore_pmdown_time; /* Doesn't benefit from pmdown delay */ };
-/* SoC platform interface */ -struct snd_soc_platform_driver { - - int (*probe)(struct snd_soc_platform *); - int (*remove)(struct snd_soc_platform *); - struct snd_soc_component_driver component_driver; - - /* pcm creation and destruction */ - int (*pcm_new)(struct snd_soc_pcm_runtime *); - void (*pcm_free)(struct snd_pcm *); - - /* platform stream pcm ops */ - const struct snd_pcm_ops *ops; - - /* platform stream compress ops */ - const struct snd_compr_ops *compr_ops; -}; - struct snd_soc_dai_link_component { const char *name; struct device_node *of_node; const char *dai_name; };
-struct snd_soc_platform { - struct device *dev; - const struct snd_soc_platform_driver *driver; - - struct list_head list; - - struct snd_soc_component component; -}; - struct snd_soc_dai_link { /* config - must be set by machine driver */ const char *name; /* Codec name */ @@ -1250,7 +1202,6 @@ struct snd_soc_pcm_runtime { struct snd_pcm *pcm; struct snd_compr *compr; struct snd_soc_codec *codec; - struct snd_soc_platform *platform; /* will be removed */ struct snd_soc_dai *codec_dai; struct snd_soc_dai *cpu_dai;
@@ -1333,19 +1284,6 @@ static inline struct snd_soc_codec *snd_soc_component_to_codec( }
/** - * snd_soc_component_to_platform() - Casts a component to the platform it is embedded in - * @component: The component to cast to a platform - * - * This function must only be used on components that are known to be platforms. - * Otherwise the behavior is undefined. - */ -static inline struct snd_soc_platform *snd_soc_component_to_platform( - struct snd_soc_component *component) -{ - return container_of(component, struct snd_soc_platform, component); -} - -/** * snd_soc_dapm_to_component() - Casts a DAPM context to the component it is * embedded in * @dapm: The DAPM context to cast to the component @@ -1374,20 +1312,6 @@ static inline struct snd_soc_codec *snd_soc_dapm_to_codec( }
/** - * snd_soc_dapm_to_platform() - Casts a DAPM context to the platform it is - * embedded in - * @dapm: The DAPM context to cast to the platform. - * - * This function must only be used on DAPM contexts that are known to be part of - * a platform (e.g. in a platform driver). Otherwise the behavior is undefined. - */ -static inline struct snd_soc_platform *snd_soc_dapm_to_platform( - struct snd_soc_dapm_context *dapm) -{ - return snd_soc_component_to_platform(snd_soc_dapm_to_component(dapm)); -} - -/** * snd_soc_component_get_dapm() - Returns the DAPM context associated with a * component * @component: The component for which to get the DAPM context @@ -1566,17 +1490,6 @@ static inline void *snd_soc_codec_get_drvdata(struct snd_soc_codec *codec) return snd_soc_component_get_drvdata(&codec->component); }
-static inline void snd_soc_platform_set_drvdata(struct snd_soc_platform *platform, - void *data) -{ - snd_soc_component_set_drvdata(&platform->component, data); -} - -static inline void *snd_soc_platform_get_drvdata(struct snd_soc_platform *platform) -{ - return snd_soc_component_get_drvdata(&platform->component); -} - static inline void snd_soc_initialize_card_lists(struct snd_soc_card *card) { INIT_LIST_HEAD(&card->widgets); @@ -1663,20 +1576,6 @@ static inline struct snd_soc_codec *snd_soc_kcontrol_codec( return snd_soc_component_to_codec(snd_soc_kcontrol_component(kcontrol)); }
-/** - * snd_soc_kcontrol_platform() - Returns the platform that registered the control - * @kcontrol: The control for which to get the platform - * - * Note: This function will only work correctly if the control has been - * registered with snd_soc_add_platform_controls() or via table based setup of - * a snd_soc_platform_driver. Otherwise the behavior is undefined. - */ -static inline struct snd_soc_platform *snd_soc_kcontrol_platform( - struct snd_kcontrol *kcontrol) -{ - return snd_soc_component_to_platform(snd_soc_kcontrol_component(kcontrol)); -} - int snd_soc_util_init(void); void snd_soc_util_exit(void);
diff --git a/sound/soc/soc-compress.c b/sound/soc/soc-compress.c index a75dc5f..58a72e6 100644 --- a/sound/soc/soc-compress.c +++ b/sound/soc/soc-compress.c @@ -29,7 +29,6 @@ static int soc_compr_open(struct snd_compr_stream *cstream) { struct snd_soc_pcm_runtime *rtd = cstream->private_data; - struct snd_soc_platform *platform = rtd->platform; struct snd_soc_component *component; struct snd_soc_rtdcom_list *rtdcom; struct snd_soc_dai *cpu_dai = rtd->cpu_dai; @@ -46,15 +45,6 @@ static int soc_compr_open(struct snd_compr_stream *cstream) } }
- if (platform && platform->driver->compr_ops && platform->driver->compr_ops->open) { - ret = platform->driver->compr_ops->open(cstream); - if (ret < 0) { - pr_err("compress asoc: can't open platform %s\n", - platform->component.name); - goto plat_err; - } - } - for_each_rtdcom(rtd, rtdcom) { component = rtdcom->component;
@@ -95,9 +85,6 @@ static int soc_compr_open(struct snd_compr_stream *cstream) component->driver->compr_ops->free(cstream); }
- if (platform && platform->driver->compr_ops && platform->driver->compr_ops->free) - platform->driver->compr_ops->free(cstream); -plat_err: if (cpu_dai->driver->cops && cpu_dai->driver->cops->shutdown) cpu_dai->driver->cops->shutdown(cstream, cpu_dai); out: @@ -109,7 +96,6 @@ static int soc_compr_open_fe(struct snd_compr_stream *cstream) { struct snd_soc_pcm_runtime *fe = cstream->private_data; struct snd_pcm_substream *fe_substream = fe->pcm->streams[0].substream; - struct snd_soc_platform *platform = fe->platform; struct snd_soc_component *component; struct snd_soc_rtdcom_list *rtdcom; struct snd_soc_dai *cpu_dai = fe->cpu_dai; @@ -134,16 +120,6 @@ static int soc_compr_open_fe(struct snd_compr_stream *cstream) } }
- - if (platform && platform->driver->compr_ops && platform->driver->compr_ops->open) { - ret = platform->driver->compr_ops->open(cstream); - if (ret < 0) { - pr_err("compress asoc: can't open platform %s\n", - platform->component.name); - goto plat_err; - } - } - for_each_rtdcom(fe, rtdcom) { component = rtdcom->component;
@@ -220,9 +196,6 @@ static int soc_compr_open_fe(struct snd_compr_stream *cstream) component->driver->compr_ops->free(cstream); }
- if (playback && platform->driver->compr_ops && platform->driver->compr_ops->free) - platform->driver->compr_ops->free(cstream); -plat_err: if (cpu_dai->driver->cops && cpu_dai->driver->cops->shutdown) cpu_dai->driver->cops->shutdown(cstream, cpu_dai); out: @@ -262,7 +235,6 @@ static void close_delayed_work(struct work_struct *work) static int soc_compr_free(struct snd_compr_stream *cstream) { struct snd_soc_pcm_runtime *rtd = cstream->private_data; - struct snd_soc_platform *platform = rtd->platform; struct snd_soc_component *component; struct snd_soc_rtdcom_list *rtdcom; struct snd_soc_dai *cpu_dai = rtd->cpu_dai; @@ -298,9 +270,6 @@ static int soc_compr_free(struct snd_compr_stream *cstream) component->driver->compr_ops->free(cstream); }
- if (platform && platform->driver->compr_ops && platform->driver->compr_ops->free) - platform->driver->compr_ops->free(cstream); - if (cpu_dai->driver->cops && cpu_dai->driver->cops->shutdown) cpu_dai->driver->cops->shutdown(cstream, cpu_dai);
@@ -329,7 +298,6 @@ static int soc_compr_free(struct snd_compr_stream *cstream) static int soc_compr_free_fe(struct snd_compr_stream *cstream) { struct snd_soc_pcm_runtime *fe = cstream->private_data; - struct snd_soc_platform *platform = fe->platform; struct snd_soc_component *component; struct snd_soc_rtdcom_list *rtdcom; struct snd_soc_dai *cpu_dai = fe->cpu_dai; @@ -377,9 +345,6 @@ static int soc_compr_free_fe(struct snd_compr_stream *cstream) component->driver->compr_ops->free(cstream); }
- if (platform && platform->driver->compr_ops && platform->driver->compr_ops->free) - platform->driver->compr_ops->free(cstream); - if (cpu_dai->driver->cops && cpu_dai->driver->cops->shutdown) cpu_dai->driver->cops->shutdown(cstream, cpu_dai);
@@ -391,7 +356,6 @@ static int soc_compr_trigger(struct snd_compr_stream *cstream, int cmd) {
struct snd_soc_pcm_runtime *rtd = cstream->private_data; - struct snd_soc_platform *platform = rtd->platform; struct snd_soc_component *component; struct snd_soc_rtdcom_list *rtdcom; struct snd_soc_dai *codec_dai = rtd->codec_dai; @@ -414,12 +378,6 @@ static int soc_compr_trigger(struct snd_compr_stream *cstream, int cmd) if (ret < 0) goto out;
- if (platform && platform->driver->compr_ops && platform->driver->compr_ops->trigger) { - ret = platform->driver->compr_ops->trigger(cstream, cmd); - if (ret < 0) - goto out; - } - if (cpu_dai->driver->cops && cpu_dai->driver->cops->trigger) cpu_dai->driver->cops->trigger(cstream, cmd, cpu_dai);
@@ -441,7 +399,6 @@ static int soc_compr_trigger(struct snd_compr_stream *cstream, int cmd) static int soc_compr_trigger_fe(struct snd_compr_stream *cstream, int cmd) { struct snd_soc_pcm_runtime *fe = cstream->private_data; - struct snd_soc_platform *platform = fe->platform; struct snd_soc_component *component; struct snd_soc_rtdcom_list *rtdcom; struct snd_soc_dai *cpu_dai = fe->cpu_dai; @@ -450,12 +407,6 @@ static int soc_compr_trigger_fe(struct snd_compr_stream *cstream, int cmd) if (cmd == SND_COMPR_TRIGGER_PARTIAL_DRAIN || cmd == SND_COMPR_TRIGGER_DRAIN) {
- if (platform && - platform->driver->compr_ops && - platform->driver->compr_ops->trigger) - return platform->driver->compr_ops->trigger(cstream, - cmd); - for_each_rtdcom(fe, rtdcom) { component = rtdcom->component;
@@ -498,12 +449,6 @@ static int soc_compr_trigger_fe(struct snd_compr_stream *cstream, int cmd) if (ret < 0) goto out;
- if (platform && platform->driver->compr_ops && platform->driver->compr_ops->trigger) { - ret = platform->driver->compr_ops->trigger(cstream, cmd); - if (ret < 0) - goto out; - } - fe->dpcm[stream].runtime_update = SND_SOC_DPCM_UPDATE_FE;
ret = dpcm_be_dai_trigger(fe, stream, cmd); @@ -533,7 +478,6 @@ static int soc_compr_set_params(struct snd_compr_stream *cstream, struct snd_compr_params *params) { struct snd_soc_pcm_runtime *rtd = cstream->private_data; - struct snd_soc_platform *platform = rtd->platform; struct snd_soc_component *component; struct snd_soc_rtdcom_list *rtdcom; struct snd_soc_dai *cpu_dai = rtd->cpu_dai; @@ -567,12 +511,6 @@ static int soc_compr_set_params(struct snd_compr_stream *cstream, if (ret < 0) goto err;
- if (platform && platform->driver->compr_ops && platform->driver->compr_ops->set_params) { - ret = platform->driver->compr_ops->set_params(cstream, params); - if (ret < 0) - goto err; - } - if (rtd->dai_link->compr_ops && rtd->dai_link->compr_ops->set_params) { ret = rtd->dai_link->compr_ops->set_params(cstream); if (ret < 0) @@ -604,7 +542,6 @@ static int soc_compr_set_params_fe(struct snd_compr_stream *cstream, { struct snd_soc_pcm_runtime *fe = cstream->private_data; struct snd_pcm_substream *fe_substream = fe->pcm->streams[0].substream; - struct snd_soc_platform *platform = fe->platform; struct snd_soc_component *component; struct snd_soc_rtdcom_list *rtdcom; struct snd_soc_dai *cpu_dai = fe->cpu_dai; @@ -637,12 +574,6 @@ static int soc_compr_set_params_fe(struct snd_compr_stream *cstream, if (ret < 0) goto out;
- if (platform && platform->driver->compr_ops && platform->driver->compr_ops->set_params) { - ret = platform->driver->compr_ops->set_params(cstream, params); - if (ret < 0) - goto out; - } - if (fe->dai_link->compr_ops && fe->dai_link->compr_ops->set_params) { ret = fe->dai_link->compr_ops->set_params(cstream); if (ret < 0) @@ -680,7 +611,6 @@ static int soc_compr_get_params(struct snd_compr_stream *cstream, struct snd_codec *params) { struct snd_soc_pcm_runtime *rtd = cstream->private_data; - struct snd_soc_platform *platform = rtd->platform; struct snd_soc_component *component; struct snd_soc_rtdcom_list *rtdcom; struct snd_soc_dai *cpu_dai = rtd->cpu_dai; @@ -705,12 +635,6 @@ static int soc_compr_get_params(struct snd_compr_stream *cstream, if (__ret < 0) ret = __ret; } - if (ret < 0) - goto err; - - if (platform && platform->driver->compr_ops && platform->driver->compr_ops->get_params) - ret = platform->driver->compr_ops->get_params(cstream, params); - err: mutex_unlock(&rtd->pcm_mutex); return ret; @@ -720,7 +644,6 @@ static int soc_compr_get_caps(struct snd_compr_stream *cstream, struct snd_compr_caps *caps) { struct snd_soc_pcm_runtime *rtd = cstream->private_data; - struct snd_soc_platform *platform = rtd->platform; struct snd_soc_component *component; struct snd_soc_rtdcom_list *rtdcom; int ret = 0, __ret; @@ -738,12 +661,7 @@ static int soc_compr_get_caps(struct snd_compr_stream *cstream, if (__ret < 0) ret = __ret; } - if (ret < 0) - goto err;
- if (platform && platform->driver->compr_ops && platform->driver->compr_ops->get_caps) - ret = platform->driver->compr_ops->get_caps(cstream, caps); -err: mutex_unlock(&rtd->pcm_mutex); return ret; } @@ -752,7 +670,6 @@ 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_platform *platform = rtd->platform; struct snd_soc_component *component; struct snd_soc_rtdcom_list *rtdcom; int ret = 0, __ret; @@ -770,12 +687,7 @@ static int soc_compr_get_codec_caps(struct snd_compr_stream *cstream, if (__ret < 0) ret = __ret; } - if (ret < 0) - goto err;
- if (platform && platform->driver->compr_ops && platform->driver->compr_ops->get_codec_caps) - ret = platform->driver->compr_ops->get_codec_caps(cstream, codec); -err: mutex_unlock(&rtd->pcm_mutex); return ret; } @@ -783,7 +695,6 @@ static int soc_compr_get_codec_caps(struct snd_compr_stream *cstream, static int soc_compr_ack(struct snd_compr_stream *cstream, size_t bytes) { struct snd_soc_pcm_runtime *rtd = cstream->private_data; - struct snd_soc_platform *platform = rtd->platform; struct snd_soc_component *component; struct snd_soc_rtdcom_list *rtdcom; struct snd_soc_dai *cpu_dai = rtd->cpu_dai; @@ -808,12 +719,6 @@ static int soc_compr_ack(struct snd_compr_stream *cstream, size_t bytes) if (__ret < 0) ret = __ret; } - if (ret < 0) - goto err; - - if (platform && platform->driver->compr_ops && platform->driver->compr_ops->ack) - ret = platform->driver->compr_ops->ack(cstream, bytes); - err: mutex_unlock(&rtd->pcm_mutex); return ret; @@ -823,7 +728,6 @@ static int soc_compr_pointer(struct snd_compr_stream *cstream, struct snd_compr_tstamp *tstamp) { struct snd_soc_pcm_runtime *rtd = cstream->private_data; - struct snd_soc_platform *platform = rtd->platform; struct snd_soc_component *component; struct snd_soc_rtdcom_list *rtdcom; int ret = 0, __ret; @@ -845,12 +749,7 @@ static int soc_compr_pointer(struct snd_compr_stream *cstream, if (__ret < 0) ret = __ret; } - if (ret < 0) - goto err;
- if (platform && platform->driver->compr_ops && platform->driver->compr_ops->pointer) - ret = platform->driver->compr_ops->pointer(cstream, tstamp); -err: mutex_unlock(&rtd->pcm_mutex); return ret; } @@ -859,7 +758,6 @@ static int soc_compr_copy(struct snd_compr_stream *cstream, char __user *buf, size_t count) { struct snd_soc_pcm_runtime *rtd = cstream->private_data; - struct snd_soc_platform *platform = rtd->platform; struct snd_soc_component *component; struct snd_soc_rtdcom_list *rtdcom; int ret = 0, __ret; @@ -877,12 +775,7 @@ static int soc_compr_copy(struct snd_compr_stream *cstream, if (__ret < 0) ret = __ret; } - if (ret < 0) - goto err;
- if (platform && platform->driver->compr_ops && platform->driver->compr_ops->copy) - ret = platform->driver->compr_ops->copy(cstream, buf, count); -err: mutex_unlock(&rtd->pcm_mutex); return ret; } @@ -891,7 +784,6 @@ static int soc_compr_set_metadata(struct snd_compr_stream *cstream, struct snd_compr_metadata *metadata) { struct snd_soc_pcm_runtime *rtd = cstream->private_data; - struct snd_soc_platform *platform = rtd->platform; struct snd_soc_component *component; struct snd_soc_rtdcom_list *rtdcom; struct snd_soc_dai *cpu_dai = rtd->cpu_dai; @@ -914,11 +806,6 @@ static int soc_compr_set_metadata(struct snd_compr_stream *cstream, if (__ret < 0) ret = __ret; } - if (ret < 0) - return ret; - - if (platform && platform->driver->compr_ops && platform->driver->compr_ops->set_metadata) - ret = platform->driver->compr_ops->set_metadata(cstream, metadata);
return ret; } @@ -927,7 +814,6 @@ static int soc_compr_get_metadata(struct snd_compr_stream *cstream, struct snd_compr_metadata *metadata) { struct snd_soc_pcm_runtime *rtd = cstream->private_data; - struct snd_soc_platform *platform = rtd->platform; struct snd_soc_component *component; struct snd_soc_rtdcom_list *rtdcom; struct snd_soc_dai *cpu_dai = rtd->cpu_dai; @@ -950,11 +836,6 @@ static int soc_compr_get_metadata(struct snd_compr_stream *cstream, if (__ret < 0) ret = __ret; } - if (ret < 0) - return ret; - - if (platform && platform->driver->compr_ops && platform->driver->compr_ops->get_metadata) - ret = platform->driver->compr_ops->get_metadata(cstream, metadata);
return ret; } @@ -1000,7 +881,6 @@ static int soc_compr_get_metadata(struct snd_compr_stream *cstream, int snd_soc_new_compress(struct snd_soc_pcm_runtime *rtd, int num) { struct snd_soc_codec *codec = rtd->codec; - struct snd_soc_platform *platform = rtd->platform; struct snd_soc_component *component; struct snd_soc_rtdcom_list *rtdcom; struct snd_soc_dai *codec_dai = rtd->codec_dai; @@ -1089,9 +969,6 @@ int snd_soc_new_compress(struct snd_soc_pcm_runtime *rtd, int num) compr->ops->copy = soc_compr_copy; }
- if (platform && platform->driver->compr_ops && platform->driver->compr_ops->copy) - compr->ops->copy = soc_compr_copy; - mutex_init(&compr->lock);
snprintf(new_name, sizeof(new_name), "%s %s-%d", diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index cdde8f7..8e1c447 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -56,7 +56,6 @@ #endif
static DEFINE_MUTEX(client_mutex); -static LIST_HEAD(platform_list); static LIST_HEAD(codec_list); static LIST_HEAD(component_list);
@@ -412,22 +411,22 @@ static ssize_t dai_list_read_file(struct file *file, char __user *user_buf, .llseek = default_llseek,/* read accesses f_pos */ };
-static ssize_t platform_list_read_file(struct file *file, +static ssize_t component_list_read_file(struct file *file, char __user *user_buf, size_t count, loff_t *ppos) { char *buf = kmalloc(PAGE_SIZE, GFP_KERNEL); ssize_t len, ret = 0; - struct snd_soc_platform *platform; + struct snd_soc_component *component;
if (!buf) return -ENOMEM;
mutex_lock(&client_mutex);
- list_for_each_entry(platform, &platform_list, list) { + list_for_each_entry(component, &component_list, list) { len = snprintf(buf + ret, PAGE_SIZE - ret, "%s\n", - platform->component.name); + component->name); if (len >= 0) ret += len; if (ret > PAGE_SIZE) { @@ -445,8 +444,8 @@ static ssize_t platform_list_read_file(struct file *file, return ret; }
-static const struct file_operations platform_list_fops = { - .read = platform_list_read_file, +static const struct file_operations component_list_fops = { + .read = component_list_read_file, .llseek = default_llseek,/* read accesses f_pos */ };
@@ -494,8 +493,8 @@ static void snd_soc_debugfs_init(void) &dai_list_fops)) pr_warn("ASoC: Failed to create DAI list debugfs file\n");
- if (!debugfs_create_file("platforms", 0444, snd_soc_debugfs_root, NULL, - &platform_list_fops)) + if (!debugfs_create_file("components", 0444, snd_soc_debugfs_root, NULL, + &component_list_fops)) pr_warn("ASoC: Failed to create platform list debugfs file\n"); }
@@ -1078,7 +1077,6 @@ static int soc_bind_dai_link(struct snd_soc_card *card, struct snd_soc_dai_link_component *codecs = dai_link->codecs; struct snd_soc_dai_link_component cpu_dai_component; struct snd_soc_dai **codec_dais; - struct snd_soc_platform *platform; struct snd_soc_component *component; struct device_node *platform_of_node; const char *platform_name; @@ -1145,22 +1143,6 @@ static int soc_bind_dai_link(struct snd_soc_card *card, snd_soc_rtdcom_add(rtd, component); }
- list_for_each_entry(platform, &platform_list, list) { - platform_of_node = platform->dev->of_node; - if (!platform_of_node && platform->dev->parent->of_node) - platform_of_node = platform->dev->parent->of_node; - - if (dai_link->platform_of_node) { - if (platform_of_node != dai_link->platform_of_node) - continue; - } else { - if (strcmp(platform->component.name, platform_name)) - continue; - } - - rtd->platform = platform; - } - soc_add_pcm_runtime(card, rtd); return 0;
@@ -1225,15 +1207,10 @@ static void soc_remove_link_components(struct snd_soc_card *card, struct snd_soc_pcm_runtime *rtd, int order) { struct snd_soc_dai *cpu_dai = rtd->cpu_dai; - struct snd_soc_platform *platform = rtd->platform; struct snd_soc_component *component; struct snd_soc_rtdcom_list *rtdcom; int i;
- /* remove the platform */ - if (platform && platform->component.driver->remove_order == order) - soc_remove_component(&platform->component); - /* remove the component */ for_each_rtdcom(rtd, rtdcom) { component = rtdcom->component; @@ -1604,7 +1581,6 @@ static int soc_probe_link_components(struct snd_soc_card *card, struct snd_soc_pcm_runtime *rtd, int order) { - struct snd_soc_platform *platform = rtd->platform; struct snd_soc_component *component; struct snd_soc_rtdcom_list *rtdcom; int i, ret; @@ -1627,13 +1603,6 @@ static int soc_probe_link_components(struct snd_soc_card *card, } }
- /* probe the platform */ - if (platform && platform->component.driver->probe_order == order) { - ret = soc_probe_component(card, &platform->component); - if (ret < 0) - return ret; - } - /* probe the component */ for_each_rtdcom(rtd, rtdcom) { component = rtdcom->component; @@ -2558,24 +2527,6 @@ int snd_soc_add_codec_controls(struct snd_soc_codec *codec, EXPORT_SYMBOL_GPL(snd_soc_add_codec_controls);
/** - * snd_soc_add_platform_controls - add an array of controls to a platform. - * Convenience function to add a list of controls. - * - * @platform: platform to add controls to - * @controls: array of controls to add - * @num_controls: number of elements in the array - * - * Return 0 for success, else error. - */ -int snd_soc_add_platform_controls(struct snd_soc_platform *platform, - const struct snd_kcontrol_new *controls, unsigned int num_controls) -{ - return snd_soc_add_component_controls(&platform->component, controls, - num_controls); -} -EXPORT_SYMBOL_GPL(snd_soc_add_platform_controls); - -/** * snd_soc_add_card_controls - add an array of controls to a SoC card. * Convenience function to add a list of controls. * @@ -3213,8 +3164,6 @@ static int snd_soc_component_initialize(struct snd_soc_component *component, component->remove = component->driver->remove; component->suspend = component->driver->suspend; component->resume = component->driver->resume; - component->pcm_new = component->driver->pcm_new; - component->pcm_free = component->driver->pcm_free;
dapm = &component->dapm; dapm->dev = dev; @@ -3416,163 +3365,6 @@ struct snd_soc_component *snd_soc_lookup_component(struct device *dev, } EXPORT_SYMBOL_GPL(snd_soc_lookup_component);
-static int snd_soc_platform_drv_probe(struct snd_soc_component *component) -{ - struct snd_soc_platform *platform = snd_soc_component_to_platform(component); - - return platform->driver->probe(platform); -} - -static void snd_soc_platform_drv_remove(struct snd_soc_component *component) -{ - struct snd_soc_platform *platform = snd_soc_component_to_platform(component); - - platform->driver->remove(platform); -} - -static int snd_soc_platform_drv_pcm_new(struct snd_soc_pcm_runtime *rtd) -{ - struct snd_soc_platform *platform = rtd->platform; - - if (platform->driver->pcm_new) - return platform->driver->pcm_new(rtd); - else - return 0; -} - -static void snd_soc_platform_drv_pcm_free(struct snd_pcm *pcm) -{ - struct snd_soc_pcm_runtime *rtd = pcm->private_data; - struct snd_soc_platform *platform = rtd->platform; - - if (platform->driver->pcm_free) - platform->driver->pcm_free(pcm); -} - -/** - * snd_soc_add_platform - Add a platform to the ASoC core - * @dev: The parent device for the platform - * @platform: The platform to add - * @platform_drv: The driver for the platform - */ -int snd_soc_add_platform(struct device *dev, struct snd_soc_platform *platform, - const struct snd_soc_platform_driver *platform_drv) -{ - int ret; - - ret = snd_soc_component_initialize(&platform->component, - &platform_drv->component_driver, dev); - if (ret) - return ret; - - platform->dev = dev; - platform->driver = platform_drv; - - if (platform_drv->probe) - platform->component.probe = snd_soc_platform_drv_probe; - if (platform_drv->remove) - platform->component.remove = snd_soc_platform_drv_remove; - if (platform_drv->pcm_new) - platform->component.pcm_new = snd_soc_platform_drv_pcm_new; - if (platform_drv->pcm_free) - platform->component.pcm_free = snd_soc_platform_drv_pcm_free; - -#ifdef CONFIG_DEBUG_FS - platform->component.debugfs_prefix = "platform"; -#endif - - mutex_lock(&client_mutex); - snd_soc_component_add_unlocked(&platform->component); - list_add(&platform->list, &platform_list); - mutex_unlock(&client_mutex); - - dev_dbg(dev, "ASoC: Registered platform '%s'\n", - platform->component.name); - - return 0; -} -EXPORT_SYMBOL_GPL(snd_soc_add_platform); - -/** - * snd_soc_register_platform - Register a platform with the ASoC core - * - * @dev: The device for the platform - * @platform_drv: The driver for the platform - */ -int snd_soc_register_platform(struct device *dev, - const struct snd_soc_platform_driver *platform_drv) -{ - struct snd_soc_platform *platform; - int ret; - - dev_dbg(dev, "ASoC: platform register %s\n", dev_name(dev)); - - platform = kzalloc(sizeof(struct snd_soc_platform), GFP_KERNEL); - if (platform == NULL) - return -ENOMEM; - - ret = snd_soc_add_platform(dev, platform, platform_drv); - if (ret) - kfree(platform); - - return ret; -} -EXPORT_SYMBOL_GPL(snd_soc_register_platform); - -/** - * snd_soc_remove_platform - Remove a platform from the ASoC core - * @platform: the platform to remove - */ -void snd_soc_remove_platform(struct snd_soc_platform *platform) -{ - - mutex_lock(&client_mutex); - list_del(&platform->list); - snd_soc_component_del_unlocked(&platform->component); - mutex_unlock(&client_mutex); - - dev_dbg(platform->dev, "ASoC: Unregistered platform '%s'\n", - platform->component.name); - - snd_soc_component_cleanup(&platform->component); -} -EXPORT_SYMBOL_GPL(snd_soc_remove_platform); - -struct snd_soc_platform *snd_soc_lookup_platform(struct device *dev) -{ - struct snd_soc_platform *platform; - - mutex_lock(&client_mutex); - list_for_each_entry(platform, &platform_list, list) { - if (dev == platform->dev) { - mutex_unlock(&client_mutex); - return platform; - } - } - mutex_unlock(&client_mutex); - - return NULL; -} -EXPORT_SYMBOL_GPL(snd_soc_lookup_platform); - -/** - * snd_soc_unregister_platform - Unregister a platform from the ASoC core - * - * @dev: platform to unregister - */ -void snd_soc_unregister_platform(struct device *dev) -{ - struct snd_soc_platform *platform; - - platform = snd_soc_lookup_platform(dev); - if (!platform) - return; - - snd_soc_remove_platform(platform); - kfree(platform); -} -EXPORT_SYMBOL_GPL(snd_soc_unregister_platform); - static u64 codec_format_map[] = { SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S16_BE, SNDRV_PCM_FMTBIT_U16_LE | SNDRV_PCM_FMTBIT_U16_BE, diff --git a/sound/soc/soc-devres.c b/sound/soc/soc-devres.c index 9194696..b05041c 100644 --- a/sound/soc/soc-devres.c +++ b/sound/soc/soc-devres.c @@ -52,41 +52,6 @@ int devm_snd_soc_register_component(struct device *dev, } EXPORT_SYMBOL_GPL(devm_snd_soc_register_component);
-static void devm_platform_release(struct device *dev, void *res) -{ - snd_soc_unregister_platform(*(struct device **)res); -} - -/** - * devm_snd_soc_register_platform - resource managed platform registration - * @dev: Device used to manage platform - * @platform_drv: platform to register - * - * Register a platform driver with automatic unregistration when the device is - * unregistered. - */ -int devm_snd_soc_register_platform(struct device *dev, - const struct snd_soc_platform_driver *platform_drv) -{ - struct device **ptr; - int ret; - - ptr = devres_alloc(devm_platform_release, sizeof(*ptr), GFP_KERNEL); - if (!ptr) - return -ENOMEM; - - ret = snd_soc_register_platform(dev, platform_drv); - if (ret == 0) { - *ptr = dev; - devres_add(dev, ptr); - } else { - devres_free(ptr); - } - - return ret; -} -EXPORT_SYMBOL_GPL(devm_snd_soc_register_platform); - static void devm_card_release(struct device *dev, void *res) { snd_soc_unregister_card(*(struct snd_soc_card **)res); diff --git a/sound/soc/soc-io.c b/sound/soc/soc-io.c index 9b39390..c909330 100644 --- a/sound/soc/soc-io.c +++ b/sound/soc/soc-io.c @@ -250,24 +250,3 @@ int snd_soc_test_bits(struct snd_soc_codec *codec, unsigned int reg, return snd_soc_component_test_bits(&codec->component, reg, mask, value); } EXPORT_SYMBOL_GPL(snd_soc_test_bits); - -int snd_soc_platform_read(struct snd_soc_platform *platform, - unsigned int reg) -{ - unsigned int val; - int ret; - - ret = snd_soc_component_read(&platform->component, reg, &val); - if (ret < 0) - return -1; - - return val; -} -EXPORT_SYMBOL_GPL(snd_soc_platform_read); - -int snd_soc_platform_write(struct snd_soc_platform *platform, - unsigned int reg, unsigned int val) -{ - return snd_soc_component_write(&platform->component, reg, val); -} -EXPORT_SYMBOL_GPL(snd_soc_platform_write); diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c index b08ef16..bf07d8b 100644 --- a/sound/soc/soc-pcm.c +++ b/sound/soc/soc-pcm.c @@ -449,7 +449,6 @@ static int soc_pcm_open(struct snd_pcm_substream *substream) { struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_pcm_runtime *runtime = substream->runtime; - struct snd_soc_platform *platform = rtd->platform; struct snd_soc_component *component; struct snd_soc_rtdcom_list *rtdcom; struct snd_soc_dai *cpu_dai = rtd->cpu_dai; @@ -481,15 +480,6 @@ static int soc_pcm_open(struct snd_pcm_substream *substream) } }
- if (platform && platform->driver->ops && platform->driver->ops->open) { - ret = platform->driver->ops->open(substream); - if (ret < 0) { - dev_err(platform->dev, "ASoC: can't open platform" - " %s: %d\n", platform->component.name, ret); - goto platform_err; - } - } - ret = 0; for_each_rtdcom(rtd, rtdcom) { component = rtdcom->component; @@ -624,10 +614,6 @@ static int soc_pcm_open(struct snd_pcm_substream *substream) component->driver->ops->close(substream); }
- if (platform && platform->driver->ops && platform->driver->ops->close) - platform->driver->ops->close(substream); - -platform_err: if (cpu_dai->driver->ops->shutdown) cpu_dai->driver->ops->shutdown(substream, cpu_dai); out: @@ -693,7 +679,6 @@ static void close_delayed_work(struct work_struct *work) static int soc_pcm_close(struct snd_pcm_substream *substream) { struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct snd_soc_platform *platform = rtd->platform; struct snd_soc_component *component; struct snd_soc_rtdcom_list *rtdcom; struct snd_soc_dai *cpu_dai = rtd->cpu_dai; @@ -728,9 +713,6 @@ static int soc_pcm_close(struct snd_pcm_substream *substream) if (rtd->dai_link->ops && rtd->dai_link->ops->shutdown) rtd->dai_link->ops->shutdown(substream);
- if (platform && platform->driver->ops && platform->driver->ops->close) - platform->driver->ops->close(substream); - for_each_rtdcom(rtd, rtdcom) { component = rtdcom->component;
@@ -793,7 +775,6 @@ static int soc_pcm_close(struct snd_pcm_substream *substream) static int soc_pcm_prepare(struct snd_pcm_substream *substream) { struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct snd_soc_platform *platform = rtd->platform; struct snd_soc_component *component; struct snd_soc_rtdcom_list *rtdcom; struct snd_soc_dai *cpu_dai = rtd->cpu_dai; @@ -811,15 +792,6 @@ static int soc_pcm_prepare(struct snd_pcm_substream *substream) } }
- if (platform && platform->driver->ops && platform->driver->ops->prepare) { - ret = platform->driver->ops->prepare(substream); - if (ret < 0) { - dev_err(platform->dev, "ASoC: platform prepare error:" - " %d\n", ret); - goto out; - } - } - for_each_rtdcom(rtd, rtdcom) { component = rtdcom->component;
@@ -916,7 +888,6 @@ static int soc_pcm_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params) { struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct snd_soc_platform *platform = rtd->platform; struct snd_soc_component *component; struct snd_soc_rtdcom_list *rtdcom; struct snd_soc_dai *cpu_dai = rtd->cpu_dai; @@ -983,15 +954,6 @@ static int soc_pcm_hw_params(struct snd_pcm_substream *substream, if (ret < 0) goto interface_err;
- if (platform && platform->driver->ops && platform->driver->ops->hw_params) { - ret = platform->driver->ops->hw_params(substream, params); - if (ret < 0) { - dev_err(platform->dev, "ASoC: %s hw params failed: %d\n", - platform->component.name, ret); - goto platform_err; - } - } - ret = 0; for_each_rtdcom(rtd, rtdcom) { component = rtdcom->component; @@ -1030,10 +992,6 @@ static int soc_pcm_hw_params(struct snd_pcm_substream *substream, component->driver->ops->hw_free(substream); }
- if (platform && platform->driver->ops && platform->driver->ops->hw_free) - platform->driver->ops->hw_free(substream); - -platform_err: if (cpu_dai->driver->ops && cpu_dai->driver->ops->hw_free) cpu_dai->driver->ops->hw_free(substream, cpu_dai);
@@ -1061,7 +1019,6 @@ static int soc_pcm_hw_params(struct snd_pcm_substream *substream, static int soc_pcm_hw_free(struct snd_pcm_substream *substream) { struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct snd_soc_platform *platform = rtd->platform; struct snd_soc_component *component; struct snd_soc_rtdcom_list *rtdcom; struct snd_soc_dai *cpu_dai = rtd->cpu_dai; @@ -1099,10 +1056,6 @@ static int soc_pcm_hw_free(struct snd_pcm_substream *substream) if (rtd->dai_link->ops && rtd->dai_link->ops->hw_free) rtd->dai_link->ops->hw_free(substream);
- /* free any DMA resources */ - if (platform && platform->driver->ops && platform->driver->ops->hw_free) - platform->driver->ops->hw_free(substream); - /* free any component resources */ for_each_rtdcom(rtd, rtdcom) { component = rtdcom->component; @@ -1129,7 +1082,6 @@ static int soc_pcm_hw_free(struct snd_pcm_substream *substream) static int soc_pcm_trigger(struct snd_pcm_substream *substream, int cmd) { struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct snd_soc_platform *platform = rtd->platform; struct snd_soc_component *component; struct snd_soc_rtdcom_list *rtdcom; struct snd_soc_dai *cpu_dai = rtd->cpu_dai; @@ -1146,12 +1098,6 @@ static int soc_pcm_trigger(struct snd_pcm_substream *substream, int cmd) } }
- if (platform && platform->driver->ops && platform->driver->ops->trigger) { - ret = platform->driver->ops->trigger(substream, cmd); - if (ret < 0) - return ret; - } - for_each_rtdcom(rtd, rtdcom) { component = rtdcom->component;
@@ -1212,7 +1158,6 @@ static int soc_pcm_bespoke_trigger(struct snd_pcm_substream *substream, static snd_pcm_uframes_t soc_pcm_pointer(struct snd_pcm_substream *substream) { struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct snd_soc_platform *platform = rtd->platform; struct snd_soc_component *component; struct snd_soc_rtdcom_list *rtdcom; struct snd_soc_dai *cpu_dai = rtd->cpu_dai; @@ -1223,9 +1168,6 @@ static snd_pcm_uframes_t soc_pcm_pointer(struct snd_pcm_substream *substream) snd_pcm_sframes_t codec_delay = 0; int i;
- if (platform && platform->driver->ops && platform->driver->ops->pointer) - offset = platform->driver->ops->pointer(substream); - for_each_rtdcom(rtd, rtdcom) { component = rtdcom->component;
@@ -2419,13 +2361,9 @@ static int soc_pcm_ioctl(struct snd_pcm_substream *substream, unsigned int cmd, void *arg) { struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct snd_soc_platform *platform = rtd->platform; struct snd_soc_component *component; struct snd_soc_rtdcom_list *rtdcom;
- if (platform && platform->driver->ops && platform->driver->ops->ioctl) - return platform->driver->ops->ioctl(substream, cmd, arg); - for_each_rtdcom(rtd, rtdcom) { component = rtdcom->component;
@@ -2785,8 +2723,8 @@ static void soc_pcm_free(struct snd_pcm *pcm)
list_for_each_entry(component, &rtd->card->component_dev_list, card_list) { - if (component->pcm_free) - component->pcm_free(pcm); + if (component->driver->pcm_free) + component->driver->pcm_free(pcm); } }
@@ -2903,7 +2841,6 @@ static int soc_rtdcom_mmap(struct snd_pcm_substream *substream, /* create a new pcm */ int soc_new_pcm(struct snd_soc_pcm_runtime *rtd, int num) { - struct snd_soc_platform *platform = rtd->platform; struct snd_soc_dai *codec_dai; struct snd_soc_dai *cpu_dai = rtd->cpu_dai; struct snd_soc_component *component; @@ -3020,15 +2957,6 @@ int soc_new_pcm(struct snd_soc_pcm_runtime *rtd, int num) rtd->ops.mmap = soc_rtdcom_mmap; }
- /* overwrite */ - if (platform && platform->driver->ops) { - rtd->ops.ack = platform->driver->ops->ack; - rtd->ops.copy = platform->driver->ops->copy; - rtd->ops.silence = platform->driver->ops->silence; - rtd->ops.page = platform->driver->ops->page; - rtd->ops.mmap = platform->driver->ops->mmap; - } - if (playback) snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &rtd->ops);
@@ -3036,8 +2964,8 @@ int soc_new_pcm(struct snd_soc_pcm_runtime *rtd, int num) snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &rtd->ops);
list_for_each_entry(component, &rtd->card->component_dev_list, card_list) { - if (component->pcm_new) { - ret = component->pcm_new(rtd); + if (component->driver->pcm_new) { + ret = component->driver->pcm_new(rtd); if (ret < 0) { dev_err(component->dev, "ASoC: pcm constructor failed: %d\n",
participants (1)
-
Kuninori Morimoto