diff mbox series

[RFC,v2,3/4] ASoC: Intel: avs: Run detecting paths during prepare

Message ID 20241112114006.2812697-4-amadeuszx.slawinski@linux.intel.com (mailing list archive)
State RFC
Headers show
Series Add support for detection | expand

Commit Message

Amadeusz Sławiński Nov. 12, 2024, 11:40 a.m. UTC
Setup and run detecting paths during snd_pcm_prepare() call, so they can
wait for event to start drain pipelines.

Signed-off-by: Amadeusz Sławiński <amadeuszx.slawinski@linux.intel.com>
---
 sound/soc/intel/avs/path.c     | 5 ++++-
 sound/soc/intel/avs/pcm.c      | 8 +++++++-
 sound/soc/intel/avs/topology.h | 1 +
 3 files changed, 12 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/sound/soc/intel/avs/path.c b/sound/soc/intel/avs/path.c
index fa9ca3faec871..5e7b9151178fa 100644
--- a/sound/soc/intel/avs/path.c
+++ b/sound/soc/intel/avs/path.c
@@ -1095,7 +1095,10 @@  int avs_path_run(struct avs_path *path, int trigger)
 		}
 	}
 
-	path->state = AVS_PATH_STATE_RUNNING;
+	if (trigger == AVS_TPLG_TRIGGER_AUTO)
+		path->state = AVS_PATH_STATE_RUNNING;
+	else if (trigger == AVS_TPLG_TRIGGER_DETECT)
+		path->state = AVS_PATH_STATE_DETECTING;
 
 	return 0;
 }
diff --git a/sound/soc/intel/avs/pcm.c b/sound/soc/intel/avs/pcm.c
index 83eb01cf17e9c..0b618b1d04689 100644
--- a/sound/soc/intel/avs/pcm.c
+++ b/sound/soc/intel/avs/pcm.c
@@ -185,8 +185,14 @@  static int avs_dai_prepare(struct snd_pcm_substream *substream, struct snd_soc_d
 	}
 
 	ret = avs_path_pause(data->path);
-	if (ret < 0)
+	if (ret < 0) {
 		dev_err(dai->dev, "pause path failed: %d\n", ret);
+		return ret;
+	}
+
+	ret = avs_path_run(data->path, AVS_TPLG_TRIGGER_DETECT);
+	if (ret < 0)
+		dev_err(dai->dev, "run path failed: %d\n", ret);
 	return ret;
 }
 
diff --git a/sound/soc/intel/avs/topology.h b/sound/soc/intel/avs/topology.h
index 7892e3797f63c..9d3b73c9b2add 100644
--- a/sound/soc/intel/avs/topology.h
+++ b/sound/soc/intel/avs/topology.h
@@ -112,6 +112,7 @@  struct avs_tplg_modcfg_ext {
 /* Specifies path behaviour during PCM ->trigger(START) command. */
 enum avs_tplg_trigger {
 	AVS_TPLG_TRIGGER_AUTO = 0,
+	AVS_TPLG_TRIGGER_DETECT = 1,
 };
 
 struct avs_tplg_pplcfg {