Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Liam Girdwood and committed by
Mark Brown
ebd259d3 102ebe26

+22
+3
include/sound/soc-topology.h
··· 118 118 int (*widget_load)(struct snd_soc_component *, 119 119 struct snd_soc_dapm_widget *, 120 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 124 int (*widget_unload)(struct snd_soc_component *, 122 125 struct snd_soc_dobj *); 123 126
+19
sound/soc/soc-topology.c
··· 344 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 */ 349 + static 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 358 /* pass DAI configurations to component driver for extra initialization */ 348 359 static int soc_tplg_dai_load(struct soc_tplg *tplg, 349 360 struct snd_soc_dai_driver *dai_drv) ··· 1590 1579 widget->dobj.ops = tplg->ops; 1591 1580 widget->dobj.index = tplg->index; 1592 1581 list_add(&widget->dobj.list, &tplg->comp->dobj_list); 1582 + 1583 + ret = soc_tplg_widget_ready(tplg, widget, w); 1584 + if (ret < 0) 1585 + goto ready_err; 1586 + 1593 1587 return 0; 1594 1588 1589 + ready_err: 1590 + snd_soc_tplg_widget_remove(widget); 1591 + snd_soc_dapm_free_widget(widget); 1595 1592 hdr_err: 1596 1593 kfree(template.sname); 1597 1594 err: