]> git.karo-electronics.de Git - linux-beck.git/commitdiff
ASoC: Intel: Skylake: use module_pin info for unbind
authorJeeja KP <jeeja.kp@intel.com>
Tue, 27 Oct 2015 00:22:51 +0000 (09:22 +0900)
committerMark Brown <broonie@kernel.org>
Mon, 16 Nov 2015 10:08:09 +0000 (10:08 +0000)
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: Jeeja KP <jeeja.kp@intel.com>
Signed-off-by: Vinod Koul <vinod.koul@intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/intel/skylake/skl-pcm.c
sound/soc/intel/skylake/skl-topology.c
sound/soc/intel/skylake/skl-topology.h
sound/soc/intel/skylake/skl.h

index 1242beac4e46834fba83b7baede2e4ca83494baa..1a9cd00c0b0a1cd855c66d0ee57f2abfd620164d 100644 (file)
@@ -938,7 +938,6 @@ int skl_platform_register(struct device *dev)
        struct skl *skl = ebus_to_skl(ebus);
 
        INIT_LIST_HEAD(&skl->ppl_list);
-       INIT_LIST_HEAD(&skl->dapm_path_list);
 
        ret = snd_soc_register_platform(dev, &skl_platform_drv);
        if (ret) {
index e8258d4807ffbff6c6161404e7e5dfb04c8846d5..abbf8e7eb3e77b170380d89dd0998b95639d949c 100644 (file)
@@ -411,7 +411,6 @@ static int skl_tplg_pga_dapm_pre_pmu_event(struct snd_soc_dapm_widget *w,
                                                        struct skl *skl)
 {
        struct snd_soc_dapm_path *p;
-       struct skl_dapm_path_list *path_list;
        struct snd_soc_dapm_widget *source, *sink;
        struct skl_module_cfg *src_mconfig, *sink_mconfig;
        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,
                                if (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;
                }
        }
@@ -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,
                                                        struct skl *skl)
 {
-       struct snd_soc_dapm_widget *source, *sink;
        struct skl_module_cfg *src_mconfig, *sink_mconfig;
-       int ret = 0, path_found = 0;
-       struct skl_dapm_path_list *path_list, *tmp_list;
+       int ret = 0, i;
        struct skl_sst *ctx = skl->skl_sst;
 
-       sink = w;
-       sink_mconfig = sink->priv;
+       sink_mconfig = w->priv;
 
        /* Stop the pipe */
        ret = skl_stop_pipe(ctx, sink_mconfig->pipe);
        if (ret)
                return ret;
 
-       /*
-        * This list, dapm_path_list handling here does not need any locks
-        * as we are under dapm lock while handling widget events.
-        * List can be manipulated safely only under dapm widgets handler
-        * routines
-        */
-       list_for_each_entry_safe(path_list, tmp_list,
-                               &skl->dapm_path_list, node) {
-               if (path_list->dapm_path->sink == sink) {
-                       dev_dbg(ctx->dev, "Path found = %s\n",
-                                       path_list->dapm_path->name);
-                       source = path_list->dapm_path->source;
-                       src_mconfig = source->priv;
-                       path_found = 1;
+       for (i = 0; i < sink_mconfig->max_in_queue; i++) {
+               if (sink_mconfig->m_in_pin[i].pin_state == SKL_PIN_BIND_DONE) {
+                       src_mconfig = sink_mconfig->m_in_pin[i].tgt_mcfg;
+                       if (!src_mconfig)
+                               continue;
+                       /*
+                        * 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.
+                        */
+                       ret = skl_stop_pipe(ctx, src_mconfig->pipe);
+                       if (ret < 0)
+                               return ret;
 
-                       list_del(&path_list->node);
-                       kfree(path_list);
-                       break;
+                       ret = skl_unbind_modules(ctx,
+                                               src_mconfig, sink_mconfig);
                }
        }
 
-       /*
-        * 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;
 }
 
@@ -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,
                                                                struct skl *skl)
 {
-       struct snd_soc_dapm_widget *source, *sink;
        struct skl_module_cfg *src_mconfig, *sink_mconfig;
-       int ret = 0, path_found = 0;
-       struct skl_dapm_path_list *path_list, *tmp_path_list;
+       int ret = 0, i;
        struct skl_sst *ctx = skl->skl_sst;
 
-       source = w;
-       src_mconfig = source->priv;
+       src_mconfig = w->priv;
 
        skl_tplg_free_pipe_mcps(skl, src_mconfig);
        /* 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,
        if (ret)
                return ret;
 
-       list_for_each_entry_safe(path_list, tmp_path_list, &skl->dapm_path_list, node) {
-               if (path_list->dapm_path->source == source) {
-                       dev_dbg(ctx->dev, "Path found = %s\n",
-                                       path_list->dapm_path->name);
-                       sink = path_list->dapm_path->sink;
-                       sink_mconfig = sink->priv;
-                       path_found = 1;
-
-                       list_del(&path_list->node);
-                       kfree(path_list);
-                       break;
+       for (i = 0; i < src_mconfig->max_out_queue; i++) {
+               if (src_mconfig->m_out_pin[i].pin_state == SKL_PIN_BIND_DONE) {
+                       sink_mconfig = src_mconfig->m_out_pin[i].tgt_mcfg;
+                       if (!sink_mconfig)
+                               continue;
+                       /*
+                        * This is a connecter and if path is found that means
+                        * unbind between source and sink has not happened yet
+                        */
+                       ret = skl_stop_pipe(ctx, sink_mconfig->pipe);
+                       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;
 }
 
index cd8768308f29e92a80406f8fab54843f313658d6..1b35cb6c397a132bd9d47949a93d9cd8fc1e8f85 100644 (file)
@@ -280,11 +280,6 @@ struct skl_pipeline {
        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)
 {
        struct hdac_ext_bus *ebus = dev_get_drvdata(dev);
index dd2e79ae45a8e6294c2766ef5eff7f4fac37befe..f803ebb106059e50c4b84d1ad82e5c817e48b92f 100644 (file)
@@ -67,7 +67,6 @@ struct skl {
 
        struct skl_dsp_resource resource;
        struct list_head ppl_list;
-       struct list_head dapm_path_list;
 };
 
 #define skl_to_ebus(s) (&(s)->ebus)