Commit adfebb51 authored by Bard liao's avatar Bard liao Committed by Mark Brown

ASoC: topology: unload physical dai link in remove

soc_tplg_link_config() will find the physical dai link and call
soc_tplg_dai_link_load() to load the BE dai link. Currently remove_link()
is only used to remove the FE dai link which is created by the topology.
The BE dai link cannot however be unloaded in snd_soc_tplg_component
_remove(), which is problematic if anything needs to be released or
reinitialized.

This patch aligns the definitions of dynamic types with the existing
UAPI and adds a new remove_backend_link() routine to unload the the BE
dai link when snd_soc_tplg_component_remove() is invoked.
Signed-off-by: default avatarBard liao <yung-chuan.liao@linux.intel.com>
Signed-off-by: default avatarPierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: default avatarMark Brown <broonie@kernel.org>
parent 78a24e10
...@@ -45,6 +45,7 @@ enum snd_soc_dobj_type { ...@@ -45,6 +45,7 @@ enum snd_soc_dobj_type {
SND_SOC_DOBJ_DAI_LINK, SND_SOC_DOBJ_DAI_LINK,
SND_SOC_DOBJ_PCM, SND_SOC_DOBJ_PCM,
SND_SOC_DOBJ_CODEC_LINK, SND_SOC_DOBJ_CODEC_LINK,
SND_SOC_DOBJ_BACKEND_LINK,
}; };
/* dynamic control object */ /* dynamic control object */
......
...@@ -557,6 +557,25 @@ static void remove_link(struct snd_soc_component *comp, ...@@ -557,6 +557,25 @@ static void remove_link(struct snd_soc_component *comp,
kfree(link); kfree(link);
} }
/* unload dai link */
static void remove_backend_link(struct snd_soc_component *comp,
struct snd_soc_dobj *dobj, int pass)
{
if (pass != SOC_TPLG_PASS_LINK)
return;
if (dobj->ops && dobj->ops->link_unload)
dobj->ops->link_unload(comp, dobj);
/*
* We don't free the link here as what remove_link() do since BE
* links are not allocated by topology.
* We however need to reset the dobj type to its initial values
*/
dobj->type = SND_SOC_DOBJ_NONE;
list_del(&dobj->list);
}
/* bind a kcontrol to it's IO handlers */ /* bind a kcontrol to it's IO handlers */
static int soc_tplg_kcontrol_bind_io(struct snd_soc_tplg_ctl_hdr *hdr, static int soc_tplg_kcontrol_bind_io(struct snd_soc_tplg_ctl_hdr *hdr,
struct snd_kcontrol_new *k, struct snd_kcontrol_new *k,
...@@ -2163,6 +2182,12 @@ static int soc_tplg_link_config(struct soc_tplg *tplg, ...@@ -2163,6 +2182,12 @@ static int soc_tplg_link_config(struct soc_tplg *tplg,
return ret; return ret;
} }
/* for unloading it in snd_soc_tplg_component_remove */
link->dobj.index = tplg->index;
link->dobj.ops = tplg->ops;
link->dobj.type = SND_SOC_DOBJ_BACKEND_LINK;
list_add(&link->dobj.list, &tplg->comp->dobj_list);
return 0; return 0;
} }
...@@ -2649,6 +2674,13 @@ int snd_soc_tplg_component_remove(struct snd_soc_component *comp, u32 index) ...@@ -2649,6 +2674,13 @@ int snd_soc_tplg_component_remove(struct snd_soc_component *comp, u32 index)
case SND_SOC_DOBJ_DAI_LINK: case SND_SOC_DOBJ_DAI_LINK:
remove_link(comp, dobj, pass); remove_link(comp, dobj, pass);
break; break;
case SND_SOC_DOBJ_BACKEND_LINK:
/*
* call link_unload ops if extra
* deinitialization is needed.
*/
remove_backend_link(comp, dobj, pass);
break;
default: default:
dev_err(comp->dev, "ASoC: invalid component type %d for removal\n", dev_err(comp->dev, "ASoC: invalid component type %d for removal\n",
dobj->type); dobj->type);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment