]> git.baikalelectronics.ru Git - kernel.git/commitdiff
ASoC: SOF: topology: make sof_route_load() IPC agnostic
authorRanjani Sridharan <ranjani.sridharan@linux.intel.com>
Tue, 8 Mar 2022 16:43:38 +0000 (08:43 -0800)
committerMark Brown <broonie@kernel.org>
Wed, 9 Mar 2022 13:30:03 +0000 (13:30 +0000)
The IPC structure can be set up using the fields in struct snd_sof_route
when the pipeline connections are established.

Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Reviewed-by: Bard Liao <yung-chuan.liao@linux.intel.com>
Reviewed-by: Péter Ujfalusi <peter.ujfalusi@linux.intel.com>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Link: https://lore.kernel.org/r/20220308164344.577647-13-ranjani.sridharan@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/sof/sof-audio.c
sound/soc/sof/topology.c

index b49d8e3480774ab940c328a83c819a42ed0be94f..8fccfbb339a340cde45a6942dafffbe9916d9ca9 100644 (file)
@@ -259,28 +259,25 @@ EXPORT_SYMBOL(sof_widget_setup);
 
 static int sof_route_setup_ipc(struct snd_sof_dev *sdev, struct snd_sof_route *sroute)
 {
-       struct sof_ipc_pipe_comp_connect *connect;
+       struct sof_ipc_pipe_comp_connect connect;
        struct sof_ipc_reply reply;
        int ret;
 
-       /* skip if there's no private data */
-       if (!sroute->private)
-               return 0;
-
        /* nothing to do if route is already set up */
        if (sroute->setup)
                return 0;
 
-       connect = sroute->private;
+       connect.hdr.size = sizeof(connect);
+       connect.hdr.cmd = SOF_IPC_GLB_TPLG_MSG | SOF_IPC_TPLG_COMP_CONNECT;
+       connect.source_id = sroute->src_widget->comp_id;
+       connect.sink_id = sroute->sink_widget->comp_id;
 
        dev_dbg(sdev->dev, "setting up route %s -> %s\n",
                sroute->src_widget->widget->name,
                sroute->sink_widget->widget->name);
 
        /* send ipc */
-       ret = sof_ipc_tx_message(sdev->ipc,
-                                connect->hdr.cmd,
-                                connect, sizeof(*connect),
+       ret = sof_ipc_tx_message(sdev->ipc, connect.hdr.cmd, &connect, sizeof(connect),
                                 &reply, sizeof(reply));
        if (ret < 0) {
                dev_err(sdev->dev, "%s: route setup failed %d\n", __func__, ret);
index 111ff0f77be4d38baf66eea8cae7a69cc66f8c69..42260d0b97403ba4ce58dde53c5fae8ce98684b4 100644 (file)
@@ -3322,7 +3322,6 @@ static int sof_route_load(struct snd_soc_component *scomp, int index,
                          struct snd_soc_dapm_route *route)
 {
        struct snd_sof_dev *sdev = snd_soc_component_get_drvdata(scomp);
-       struct sof_ipc_pipe_comp_connect *connect;
        struct snd_sof_widget *source_swidget, *sink_swidget;
        struct snd_soc_dobj *dobj = &route->dobj;
        struct snd_sof_route *sroute;
@@ -3334,16 +3333,6 @@ static int sof_route_load(struct snd_soc_component *scomp, int index,
                return -ENOMEM;
 
        sroute->scomp = scomp;
-
-       connect = kzalloc(sizeof(*connect), GFP_KERNEL);
-       if (!connect) {
-               kfree(sroute);
-               return -ENOMEM;
-       }
-
-       connect->hdr.size = sizeof(*connect);
-       connect->hdr.cmd = SOF_IPC_GLB_TPLG_MSG | SOF_IPC_TPLG_COMP_CONNECT;
-
        dev_dbg(scomp->dev, "sink %s control %s source %s\n",
                route->sink, route->control ? route->control : "none",
                route->source);
@@ -3367,8 +3356,6 @@ static int sof_route_load(struct snd_soc_component *scomp, int index,
            source_swidget->id == snd_soc_dapm_output)
                goto err;
 
-       connect->source_id = source_swidget->comp_id;
-
        /* sink component */
        sink_swidget = snd_sof_find_swidget(scomp, (char *)route->sink);
        if (!sink_swidget) {
@@ -3386,8 +3373,6 @@ static int sof_route_load(struct snd_soc_component *scomp, int index,
            sink_swidget->id == snd_soc_dapm_output)
                goto err;
 
-       connect->sink_id = sink_swidget->comp_id;
-
        /*
         * For virtual routes, both sink and source are not
         * buffer. Since only buffer linked to component is supported by
@@ -3402,7 +3387,6 @@ static int sof_route_load(struct snd_soc_component *scomp, int index,
        } else {
                sroute->route = route;
                dobj->private = sroute;
-               sroute->private = connect;
                sroute->src_widget = source_swidget;
                sroute->sink_widget = sink_swidget;
 
@@ -3413,7 +3397,6 @@ static int sof_route_load(struct snd_soc_component *scomp, int index,
        }
 
 err:
-       kfree(connect);
        kfree(sroute);
        return ret;
 }