aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLars-Peter Clausen <lars@metafoo.de>2014-08-19 09:51:21 -0400
committerMark Brown <broonie@linaro.org>2014-08-19 11:59:45 -0400
commit61aca5646b736a794d40de29a197144db3f0c5ba (patch)
tree725bcb8158a795876225fd005c7298a0f99e179c
parent93c3ce76ccced3a8718149e8734ccaa931e9a1f1 (diff)
ASoC: Add component level probe/remove support
Now that we have a unified probe and remove path make sure to call them for all components. soc_{probe,remove}_component are responsible for setting up the DAPM context for the component, initialize the component prefix, manage the debugfs entries as well as do the registration of table based controls and DAPM elements. They also call the component drivers probe and remove callbacks. This patch makes these things available for generic snd_soc_component drivers rather than only having them for snd_soc_codec and snd_soc_platform drivers. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Mark Brown <broonie@linaro.org>
-rw-r--r--include/sound/soc.h11
-rw-r--r--sound/soc/soc-core.c42
2 files changed, 35 insertions, 18 deletions
diff --git a/include/sound/soc.h b/include/sound/soc.h
index 22543acfae4b..4a223a895f00 100644
--- a/include/sound/soc.h
+++ b/include/sound/soc.h
@@ -690,6 +690,17 @@ struct snd_soc_compr_ops {
690struct snd_soc_component_driver { 690struct snd_soc_component_driver {
691 const char *name; 691 const char *name;
692 692
693 /* Default control and setup, added after probe() is run */
694 const struct snd_kcontrol_new *controls;
695 unsigned int num_controls;
696 const struct snd_soc_dapm_widget *dapm_widgets;
697 unsigned int num_dapm_widgets;
698 const struct snd_soc_dapm_route *dapm_routes;
699 unsigned int num_dapm_routes;
700
701 int (*probe)(struct snd_soc_component *);
702 void (*remove)(struct snd_soc_component *);
703
693 /* DT */ 704 /* DT */
694 int (*of_xlate_dai_name)(struct snd_soc_component *component, 705 int (*of_xlate_dai_name)(struct snd_soc_component *component,
695 struct of_phandle_args *args, 706 struct of_phandle_args *args,
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index 1c705c28389c..08fd85e8c751 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -1058,7 +1058,7 @@ static void soc_remove_link_components(struct snd_soc_card *card, int num,
1058 struct snd_soc_pcm_runtime *rtd = &card->rtd[num]; 1058 struct snd_soc_pcm_runtime *rtd = &card->rtd[num];
1059 struct snd_soc_dai *cpu_dai = rtd->cpu_dai; 1059 struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
1060 struct snd_soc_platform *platform = rtd->platform; 1060 struct snd_soc_platform *platform = rtd->platform;
1061 struct snd_soc_codec *codec; 1061 struct snd_soc_component *component;
1062 int i; 1062 int i;
1063 1063
1064 /* remove the platform */ 1064 /* remove the platform */
@@ -1068,18 +1068,17 @@ static void soc_remove_link_components(struct snd_soc_card *card, int num,
1068 1068
1069 /* remove the CODEC-side CODEC */ 1069 /* remove the CODEC-side CODEC */
1070 for (i = 0; i < rtd->num_codecs; i++) { 1070 for (i = 0; i < rtd->num_codecs; i++) {
1071 codec = rtd->codec_dais[i]->codec; 1071 component = rtd->codec_dais[i]->component;
1072 if (codec && codec->component.probed && 1072 if (component->probed &&
1073 codec->component.driver->remove_order == order) 1073 component->driver->remove_order == order)
1074 soc_remove_component(&codec->component); 1074 soc_remove_component(component);
1075 } 1075 }
1076 1076
1077 /* remove any CPU-side CODEC */ 1077 /* remove any CPU-side CODEC */
1078 if (cpu_dai) { 1078 if (cpu_dai) {
1079 codec = cpu_dai->codec; 1079 if (cpu_dai->component->probed &&
1080 if (codec && codec->component.probed && 1080 cpu_dai->component->driver->remove_order == order)
1081 codec->component.driver->remove_order == order) 1081 soc_remove_component(cpu_dai->component);
1082 soc_remove_component(&codec->component);
1083 } 1082 }
1084} 1083}
1085 1084
@@ -1289,19 +1288,17 @@ static int soc_probe_link_components(struct snd_soc_card *card, int num,
1289 int i, ret; 1288 int i, ret;
1290 1289
1291 /* probe the CPU-side component, if it is a CODEC */ 1290 /* probe the CPU-side component, if it is a CODEC */
1292 if (rtd->cpu_dai->codec) { 1291 component = rtd->cpu_dai->component;
1293 component = &rtd->cpu_dai->codec->component; 1292 if (!component->probed &&
1294 if (!component->probed && 1293 component->driver->probe_order == order) {
1295 component->driver->probe_order == order) { 1294 ret = soc_probe_component(card, component);
1296 ret = soc_probe_component(card, component); 1295 if (ret < 0)
1297 if (ret < 0) 1296 return ret;
1298 return ret;
1299 }
1300 } 1297 }
1301 1298
1302 /* probe the CODEC-side components */ 1299 /* probe the CODEC-side components */
1303 for (i = 0; i < rtd->num_codecs; i++) { 1300 for (i = 0; i < rtd->num_codecs; i++) {
1304 component = &rtd->codec_dais[i]->codec->component; 1301 component = rtd->codec_dais[i]->component;
1305 if (!component->probed && 1302 if (!component->probed &&
1306 component->driver->probe_order == order) { 1303 component->driver->probe_order == order) {
1307 ret = soc_probe_component(card, component); 1304 ret = soc_probe_component(card, component);
@@ -4042,6 +4039,8 @@ static int snd_soc_component_initialize(struct snd_soc_component *component,
4042 4039
4043 component->dev = dev; 4040 component->dev = dev;
4044 component->driver = driver; 4041 component->driver = driver;
4042 component->probe = component->driver->probe;
4043 component->remove = component->driver->remove;
4045 4044
4046 if (!component->dapm_ptr) 4045 if (!component->dapm_ptr)
4047 component->dapm_ptr = &component->dapm; 4046 component->dapm_ptr = &component->dapm;
@@ -4055,6 +4054,13 @@ static int snd_soc_component_initialize(struct snd_soc_component *component,
4055 if (driver->stream_event) 4054 if (driver->stream_event)
4056 dapm->stream_event = snd_soc_component_stream_event; 4055 dapm->stream_event = snd_soc_component_stream_event;
4057 4056
4057 component->controls = driver->controls;
4058 component->num_controls = driver->num_controls;
4059 component->dapm_widgets = driver->dapm_widgets;
4060 component->num_dapm_widgets = driver->num_dapm_widgets;
4061 component->dapm_routes = driver->dapm_routes;
4062 component->num_dapm_routes = driver->num_dapm_routes;
4063
4058 INIT_LIST_HEAD(&component->dai_list); 4064 INIT_LIST_HEAD(&component->dai_list);
4059 mutex_init(&component->io_mutex); 4065 mutex_init(&component->io_mutex);
4060 4066