Commit ce1b5551 authored by Jeeja KP's avatar Jeeja KP Committed by Mark Brown

ASoC: Intel: Skylake: use module_pin info for unbind

in_pin and out_pin list for a module has the information about
the module that are bound together. So we can directly look at
pin information of module for binding and unbind.

As a result the preinitialized dapm_path_last we had is removed
and code and memory optimzed.
Signed-off-by: default avatarJeeja KP <jeeja.kp@intel.com>
Signed-off-by: default avatarVinod Koul <vinod.koul@intel.com>
Signed-off-by: default avatarMark Brown <broonie@kernel.org>
parent 83b50246
...@@ -938,7 +938,6 @@ int skl_platform_register(struct device *dev) ...@@ -938,7 +938,6 @@ int skl_platform_register(struct device *dev)
struct skl *skl = ebus_to_skl(ebus); struct skl *skl = ebus_to_skl(ebus);
INIT_LIST_HEAD(&skl->ppl_list); INIT_LIST_HEAD(&skl->ppl_list);
INIT_LIST_HEAD(&skl->dapm_path_list);
ret = snd_soc_register_platform(dev, &skl_platform_drv); ret = snd_soc_register_platform(dev, &skl_platform_drv);
if (ret) { if (ret) {
......
...@@ -411,7 +411,6 @@ static int skl_tplg_pga_dapm_pre_pmu_event(struct snd_soc_dapm_widget *w, ...@@ -411,7 +411,6 @@ static int skl_tplg_pga_dapm_pre_pmu_event(struct snd_soc_dapm_widget *w,
struct skl *skl) struct skl *skl)
{ {
struct snd_soc_dapm_path *p; struct snd_soc_dapm_path *p;
struct skl_dapm_path_list *path_list;
struct snd_soc_dapm_widget *source, *sink; struct snd_soc_dapm_widget *source, *sink;
struct skl_module_cfg *src_mconfig, *sink_mconfig; struct skl_module_cfg *src_mconfig, *sink_mconfig;
struct skl_sst *ctx = skl->skl_sst; struct skl_sst *ctx = skl->skl_sst;
...@@ -455,16 +454,6 @@ static int skl_tplg_pga_dapm_pre_pmu_event(struct snd_soc_dapm_widget *w, ...@@ -455,16 +454,6 @@ static int skl_tplg_pga_dapm_pre_pmu_event(struct snd_soc_dapm_widget *w,
if (ret) if (ret)
return ret; return ret;
} }
path_list = kzalloc(
sizeof(struct skl_dapm_path_list),
GFP_KERNEL);
if (path_list == NULL)
return -ENOMEM;
/* Add connected path to one global list */
path_list->dapm_path = p;
list_add_tail(&path_list->node, &skl->dapm_path_list);
break; break;
} }
} }
...@@ -552,54 +541,37 @@ static int skl_tplg_mixer_dapm_post_pmu_event(struct snd_soc_dapm_widget *w, ...@@ -552,54 +541,37 @@ static int skl_tplg_mixer_dapm_post_pmu_event(struct snd_soc_dapm_widget *w,
static int skl_tplg_mixer_dapm_pre_pmd_event(struct snd_soc_dapm_widget *w, static int skl_tplg_mixer_dapm_pre_pmd_event(struct snd_soc_dapm_widget *w,
struct skl *skl) struct skl *skl)
{ {
struct snd_soc_dapm_widget *source, *sink;
struct skl_module_cfg *src_mconfig, *sink_mconfig; struct skl_module_cfg *src_mconfig, *sink_mconfig;
int ret = 0, path_found = 0; int ret = 0, i;
struct skl_dapm_path_list *path_list, *tmp_list;
struct skl_sst *ctx = skl->skl_sst; struct skl_sst *ctx = skl->skl_sst;
sink = w; sink_mconfig = w->priv;
sink_mconfig = sink->priv;
/* Stop the pipe */ /* Stop the pipe */
ret = skl_stop_pipe(ctx, sink_mconfig->pipe); ret = skl_stop_pipe(ctx, sink_mconfig->pipe);
if (ret) if (ret)
return ret; return ret;
/* for (i = 0; i < sink_mconfig->max_in_queue; i++) {
* This list, dapm_path_list handling here does not need any locks if (sink_mconfig->m_in_pin[i].pin_state == SKL_PIN_BIND_DONE) {
* as we are under dapm lock while handling widget events. src_mconfig = sink_mconfig->m_in_pin[i].tgt_mcfg;
* List can be manipulated safely only under dapm widgets handler if (!src_mconfig)
* routines continue;
*/ /*
list_for_each_entry_safe(path_list, tmp_list, * If path_found == 1, that means pmd for source
&skl->dapm_path_list, node) { * pipe has not occurred, source is connected to
if (path_list->dapm_path->sink == sink) { * some other sink. so its responsibility of sink
dev_dbg(ctx->dev, "Path found = %s\n", * to unbind itself from source.
path_list->dapm_path->name); */
source = path_list->dapm_path->source; ret = skl_stop_pipe(ctx, src_mconfig->pipe);
src_mconfig = source->priv; if (ret < 0)
path_found = 1; return ret;
list_del(&path_list->node); ret = skl_unbind_modules(ctx,
kfree(path_list); src_mconfig, sink_mconfig);
break;
} }
} }
/*
* If path_found == 1, that means pmd for source pipe has
* not occurred, source is connected to some other sink.
* so its responsibility of sink to unbind itself from source.
*/
if (path_found) {
ret = skl_stop_pipe(ctx, src_mconfig->pipe);
if (ret < 0)
return ret;
ret = skl_unbind_modules(ctx, src_mconfig, sink_mconfig);
}
return ret; return ret;
} }
...@@ -653,14 +625,11 @@ static int skl_tplg_mixer_dapm_post_pmd_event(struct snd_soc_dapm_widget *w, ...@@ -653,14 +625,11 @@ static int skl_tplg_mixer_dapm_post_pmd_event(struct snd_soc_dapm_widget *w,
static int skl_tplg_pga_dapm_post_pmd_event(struct snd_soc_dapm_widget *w, static int skl_tplg_pga_dapm_post_pmd_event(struct snd_soc_dapm_widget *w,
struct skl *skl) struct skl *skl)
{ {
struct snd_soc_dapm_widget *source, *sink;
struct skl_module_cfg *src_mconfig, *sink_mconfig; struct skl_module_cfg *src_mconfig, *sink_mconfig;
int ret = 0, path_found = 0; int ret = 0, i;
struct skl_dapm_path_list *path_list, *tmp_path_list;
struct skl_sst *ctx = skl->skl_sst; struct skl_sst *ctx = skl->skl_sst;
source = w; src_mconfig = w->priv;
src_mconfig = source->priv;
skl_tplg_free_pipe_mcps(skl, src_mconfig); skl_tplg_free_pipe_mcps(skl, src_mconfig);
/* Stop the pipe since this is a mixin module */ /* Stop the pipe since this is a mixin module */
...@@ -668,32 +637,23 @@ static int skl_tplg_pga_dapm_post_pmd_event(struct snd_soc_dapm_widget *w, ...@@ -668,32 +637,23 @@ static int skl_tplg_pga_dapm_post_pmd_event(struct snd_soc_dapm_widget *w,
if (ret) if (ret)
return ret; return ret;
list_for_each_entry_safe(path_list, tmp_path_list, &skl->dapm_path_list, node) { for (i = 0; i < src_mconfig->max_out_queue; i++) {
if (path_list->dapm_path->source == source) { if (src_mconfig->m_out_pin[i].pin_state == SKL_PIN_BIND_DONE) {
dev_dbg(ctx->dev, "Path found = %s\n", sink_mconfig = src_mconfig->m_out_pin[i].tgt_mcfg;
path_list->dapm_path->name); if (!sink_mconfig)
sink = path_list->dapm_path->sink; continue;
sink_mconfig = sink->priv; /*
path_found = 1; * This is a connecter and if path is found that means
* unbind between source and sink has not happened yet
list_del(&path_list->node); */
kfree(path_list); ret = skl_stop_pipe(ctx, sink_mconfig->pipe);
break; if (ret < 0)
return ret;
ret = skl_unbind_modules(ctx, src_mconfig,
sink_mconfig);
} }
} }
/*
* This is a connector and if path is found that means
* unbind between source and sink has not happened yet
*/
if (path_found) {
ret = skl_stop_pipe(ctx, src_mconfig->pipe);
if (ret < 0)
return ret;
ret = skl_unbind_modules(ctx, src_mconfig, sink_mconfig);
}
return ret; return ret;
} }
......
...@@ -280,11 +280,6 @@ struct skl_pipeline { ...@@ -280,11 +280,6 @@ struct skl_pipeline {
struct list_head node; struct list_head node;
}; };
struct skl_dapm_path_list {
struct snd_soc_dapm_path *dapm_path;
struct list_head node;
};
static inline struct skl *get_skl_ctx(struct device *dev) static inline struct skl *get_skl_ctx(struct device *dev)
{ {
struct hdac_ext_bus *ebus = dev_get_drvdata(dev); struct hdac_ext_bus *ebus = dev_get_drvdata(dev);
......
...@@ -67,7 +67,6 @@ struct skl { ...@@ -67,7 +67,6 @@ struct skl {
struct skl_dsp_resource resource; struct skl_dsp_resource resource;
struct list_head ppl_list; struct list_head ppl_list;
struct list_head dapm_path_list;
}; };
#define skl_to_ebus(s) (&(s)->ebus) #define skl_to_ebus(s) (&(s)->ebus)
......
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