aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLiam Girdwood <liam.r.girdwood@linux.intel.com>2017-06-09 10:43:23 -0400
committerMark Brown <broonie@kernel.org>2017-06-09 13:46:08 -0400
commitebd259d33a900b28ef774c4c26e8ce6e2baea7e5 (patch)
treea178243366c8e0ad58a8b9a158249238639dcd62
parent102ebe266c317da59471e2cde0dce603de031482 (diff)
ASoC: topology: Allow bespoke configuration post widget creation
Current topology only allows for widget configuration before the widget is registered. This patch also allows further configuration and usage after registration is complete. Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com> Signed-off-by: Mark Brown <broonie@kernel.org>
-rw-r--r--include/sound/soc-topology.h3
-rw-r--r--sound/soc/soc-topology.c19
2 files changed, 22 insertions, 0 deletions
diff --git a/include/sound/soc-topology.h b/include/sound/soc-topology.h
index b8da221615e0..f552c3f56368 100644
--- a/include/sound/soc-topology.h
+++ b/include/sound/soc-topology.h
@@ -118,6 +118,9 @@ struct snd_soc_tplg_ops {
118 int (*widget_load)(struct snd_soc_component *, 118 int (*widget_load)(struct snd_soc_component *,
119 struct snd_soc_dapm_widget *, 119 struct snd_soc_dapm_widget *,
120 struct snd_soc_tplg_dapm_widget *); 120 struct snd_soc_tplg_dapm_widget *);
121 int (*widget_ready)(struct snd_soc_component *,
122 struct snd_soc_dapm_widget *,
123 struct snd_soc_tplg_dapm_widget *);
121 int (*widget_unload)(struct snd_soc_component *, 124 int (*widget_unload)(struct snd_soc_component *,
122 struct snd_soc_dobj *); 125 struct snd_soc_dobj *);
123 126
diff --git a/sound/soc/soc-topology.c b/sound/soc/soc-topology.c
index f4ec236a418e..12e189701924 100644
--- a/sound/soc/soc-topology.c
+++ b/sound/soc/soc-topology.c
@@ -344,6 +344,17 @@ static int soc_tplg_widget_load(struct soc_tplg *tplg,
344 return 0; 344 return 0;
345} 345}
346 346
347/* optionally pass new dynamic widget to component driver. This is mainly for
348 * external widgets where we can assign private data/ops */
349static int soc_tplg_widget_ready(struct soc_tplg *tplg,
350 struct snd_soc_dapm_widget *w, struct snd_soc_tplg_dapm_widget *tplg_w)
351{
352 if (tplg->comp && tplg->ops && tplg->ops->widget_ready)
353 return tplg->ops->widget_ready(tplg->comp, w, tplg_w);
354
355 return 0;
356}
357
347/* pass DAI configurations to component driver for extra initialization */ 358/* pass DAI configurations to component driver for extra initialization */
348static int soc_tplg_dai_load(struct soc_tplg *tplg, 359static int soc_tplg_dai_load(struct soc_tplg *tplg,
349 struct snd_soc_dai_driver *dai_drv) 360 struct snd_soc_dai_driver *dai_drv)
@@ -1579,8 +1590,16 @@ widget:
1579 widget->dobj.ops = tplg->ops; 1590 widget->dobj.ops = tplg->ops;
1580 widget->dobj.index = tplg->index; 1591 widget->dobj.index = tplg->index;
1581 list_add(&widget->dobj.list, &tplg->comp->dobj_list); 1592 list_add(&widget->dobj.list, &tplg->comp->dobj_list);
1593
1594 ret = soc_tplg_widget_ready(tplg, widget, w);
1595 if (ret < 0)
1596 goto ready_err;
1597
1582 return 0; 1598 return 0;
1583 1599
1600ready_err:
1601 snd_soc_tplg_widget_remove(widget);
1602 snd_soc_dapm_free_widget(widget);
1584hdr_err: 1603hdr_err:
1585 kfree(template.sname); 1604 kfree(template.sname);
1586err: 1605err: