LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Daniel Baluta <daniel.baluta@oss.nxp.com>
To: broonie@kernel.org
Cc: pierre-louis.bossart@linux.intel.com, lgirdwood@gmail.com,
	ranjani.sridharan@linux.intel.com, kai.vehmanen@linux.intel.com,
	alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org,
	daniel.baluta@nxp.com,
	Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
Subject: [PATCH v2 06/12] ASoC: SOF: Add new fields to snd_sof_route
Date: Fri, 17 Sep 2021 17:36:53 +0300	[thread overview]
Message-ID: <20210917143659.401102-7-daniel.baluta@oss.nxp.com> (raw)
In-Reply-To: <20210917143659.401102-1-daniel.baluta@oss.nxp.com>

From: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>

Add two new fields to save the source widget and sink widget
pointers in struct snd_sof_route to make it easier to look up
routes by source/sink widget. Also, add a flag to indicate
if the route has been set up in the DSP. These will be used
when the dynamic pipeline feature is implemented and routes
will have to be set up at run time.

Also, add a new sof_tear_down_pipelines() callback, that will
used to reset the set up status for all routes during suspend.

Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Reviewed-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Signed-off-by: Daniel Baluta <daniel.baluta@nxp.com>
---
 sound/soc/sof/pm.c        |  2 ++
 sound/soc/sof/sof-audio.c | 15 +++++++++++++++
 sound/soc/sof/sof-audio.h |  4 ++++
 sound/soc/sof/topology.c  |  3 +++
 4 files changed, 24 insertions(+)

diff --git a/sound/soc/sof/pm.c b/sound/soc/sof/pm.c
index c83fb6255961..ce922227c4c6 100644
--- a/sound/soc/sof/pm.c
+++ b/sound/soc/sof/pm.c
@@ -208,6 +208,8 @@ static int sof_suspend(struct device *dev, bool runtime_suspend)
 	if (target_state == SOF_DSP_PM_D0)
 		goto suspend;
 
+	sof_tear_down_pipelines(dev);
+
 	/* release trace */
 	snd_sof_release_trace(sdev);
 
diff --git a/sound/soc/sof/sof-audio.c b/sound/soc/sof/sof-audio.c
index a4b9bb99bced..b52a453ae9d7 100644
--- a/sound/soc/sof/sof-audio.c
+++ b/sound/soc/sof/sof-audio.c
@@ -276,6 +276,7 @@ int sof_restore_pipelines(struct device *dev)
 
 			return ret;
 		}
+		sroute->setup = true;
 	}
 
 	/* restore dai links */
@@ -317,6 +318,20 @@ int sof_restore_pipelines(struct device *dev)
 	return ret;
 }
 
+/* This function doesn't free widgets. It only resets the set up status for all routes */
+void sof_tear_down_pipelines(struct device *dev)
+{
+	struct snd_sof_dev *sdev = dev_get_drvdata(dev);
+	struct snd_sof_route *sroute;
+
+	/*
+	 * No need to protect sroute->setup as this function is called only during the suspend
+	 * callback and all streams should be suspended by then
+	 */
+	list_for_each_entry(sroute, &sdev->route_list, list)
+		sroute->setup = false;
+}
+
 /*
  * Generic object lookup APIs.
  */
diff --git a/sound/soc/sof/sof-audio.h b/sound/soc/sof/sof-audio.h
index 4a1c38c5618d..fe997a80a847 100644
--- a/sound/soc/sof/sof-audio.h
+++ b/sound/soc/sof/sof-audio.h
@@ -118,6 +118,9 @@ struct snd_sof_route {
 
 	struct snd_soc_dapm_route *route;
 	struct list_head list;	/* list in sdev route list */
+	struct snd_sof_widget *src_widget;
+	struct snd_sof_widget *sink_widget;
+	bool setup;
 
 	void *private;
 };
@@ -240,6 +243,7 @@ int sof_pcm_dai_link_fixup(struct snd_soc_pcm_runtime *rtd, struct snd_pcm_hw_pa
 
 /* PM */
 int sof_restore_pipelines(struct device *dev);
+void sof_tear_down_pipelines(struct device *dev);
 int sof_set_hw_params_upon_resume(struct device *dev);
 bool snd_sof_stream_suspend_ignored(struct snd_sof_dev *sdev);
 bool snd_sof_dsp_only_d0i3_compatible_stream_active(struct snd_sof_dev *sdev);
diff --git a/sound/soc/sof/topology.c b/sound/soc/sof/topology.c
index 60d1db6a9193..58f966ab2e81 100644
--- a/sound/soc/sof/topology.c
+++ b/sound/soc/sof/topology.c
@@ -3501,6 +3501,9 @@ static int sof_route_load(struct snd_soc_component *scomp, int index,
 		sroute->route = route;
 		dobj->private = sroute;
 		sroute->private = connect;
+		sroute->src_widget = source_swidget;
+		sroute->sink_widget = sink_swidget;
+		sroute->setup = true;
 
 		/* add route to route list */
 		list_add(&sroute->list, &sdev->route_list);
-- 
2.27.0


  parent reply	other threads:[~2021-09-17 14:37 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-17 14:36 [PATCH v2 00/12] Add support for on demand pipeline setup/destroy Daniel Baluta
2021-09-17 14:36 ` [PATCH v2 01/12] ASoC: topology: change the complete op in snd_soc_tplg_ops to return int Daniel Baluta
2021-09-17 14:36 ` [PATCH v2 02/12] ASoC: SOF: control: Add access field in struct snd_sof_control Daniel Baluta
2021-09-17 14:36 ` [PATCH v2 03/12] ASoC: SOF: topology: Add new token for dynamic pipeline Daniel Baluta
2021-09-17 14:36 ` [PATCH v2 04/12] ASoC: SOF: sof-audio: add helpers for widgets, kcontrols and dai config set up Daniel Baluta
2021-09-17 14:36 ` [PATCH v2 05/12] AsoC: dapm: export a couple of functions Daniel Baluta
2021-09-17 14:36 ` Daniel Baluta [this message]
2021-09-17 14:36 ` [PATCH v2 07/12] ASoC: SOF: restore kcontrols for widget during set up Daniel Baluta
2021-09-17 14:36 ` [PATCH v2 08/12] ASoC: SOF: Don't set up widgets during topology parsing Daniel Baluta
2021-09-17 14:36 ` [PATCH v2 09/12] ASoC: SOF: Introduce widget use_count Daniel Baluta
2021-09-17 14:36 ` [PATCH v2 10/12] ASoC: SOF: Intel: hda: make sure DAI widget is set up before IPC Daniel Baluta
     [not found]   ` <203bf6cd-6407-f01d-52c3-e399d06cb3f6@linux.intel.com>
2021-09-23 12:58     ` Pierre-Louis Bossart
2021-09-23 13:00       ` Péter Ujfalusi
2021-09-24  7:42         ` Daniel Baluta
2021-09-27  9:09           ` Péter Ujfalusi
2021-09-17 14:36 ` [PATCH v2 11/12] ASoC: SOF: Add support for dynamic pipelines Daniel Baluta
2021-09-17 14:36 ` [PATCH v2 12/12] ASoC: SOF: topology: Add kernel parameter for topology verification Daniel Baluta

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210917143659.401102-7-daniel.baluta@oss.nxp.com \
    --to=daniel.baluta@oss.nxp.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@kernel.org \
    --cc=daniel.baluta@nxp.com \
    --cc=guennadi.liakhovetski@linux.intel.com \
    --cc=kai.vehmanen@linux.intel.com \
    --cc=lgirdwood@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pierre-louis.bossart@linux.intel.com \
    --cc=ranjani.sridharan@linux.intel.com \
    --subject='Re: [PATCH v2 06/12] ASoC: SOF: Add new fields to snd_sof_route' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).