summaryrefslogtreecommitdiffstats
path: root/sound/soc/intel/avs/path.c
diff options
context:
space:
mode:
authorCezary Rojewski <cezary.rojewski@intel.com>2022-03-31 15:52:45 +0200
committerMark Brown <broonie@kernel.org>2022-04-19 12:04:03 +0100
commit435e25730fe7b3a4e4a8e66028e39597b2524f0c (patch)
treebd4b35ae2f29f9acc9dfa5756693a1f02d232b46 /sound/soc/intel/avs/path.c
parent84a99908fc7b988067e927834575df42707ec024 (diff)
downloadlinux-stable-435e25730fe7b3a4e4a8e66028e39597b2524f0c.tar.gz
linux-stable-435e25730fe7b3a4e4a8e66028e39597b2524f0c.tar.bz2
linux-stable-435e25730fe7b3a4e4a8e66028e39597b2524f0c.zip
ASoC: Intel: avs: Prepare modules before bindings them
When binding modules to pins other than pin0, sometimes additional preparations need to be made, depending on the module type. Add function that prepares modules when necessary before binding them. Signed-off-by: Amadeusz Sławiński <amadeuszx.slawinski@linux.intel.com> Signed-off-by: Cezary Rojewski <cezary.rojewski@intel.com> Link: https://lore.kernel.org/r/20220331135246.993089-14-cezary.rojewski@intel.com Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'sound/soc/intel/avs/path.c')
-rw-r--r--sound/soc/intel/avs/path.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/sound/soc/intel/avs/path.c b/sound/soc/intel/avs/path.c
index 13006c24ebf8..916a4f25636e 100644
--- a/sound/soc/intel/avs/path.c
+++ b/sound/soc/intel/avs/path.c
@@ -463,6 +463,37 @@ struct avs_path *avs_path_create(struct avs_dev *adev, u32 dma_id,
return path;
}
+static int avs_path_bind_prepare(struct avs_dev *adev,
+ struct avs_path_binding *binding)
+{
+ const struct avs_audio_format *src_fmt, *sink_fmt;
+ struct avs_tplg_module *tsource = binding->source->template;
+ struct avs_path_module *source = binding->source;
+ int ret;
+
+ /*
+ * only copier modules about to be bound
+ * to output pin other than 0 need preparation
+ */
+ if (!binding->source_pin)
+ return 0;
+ if (!guid_equal(&tsource->cfg_ext->type, &AVS_COPIER_MOD_UUID))
+ return 0;
+
+ src_fmt = tsource->in_fmt;
+ sink_fmt = binding->sink->template->in_fmt;
+
+ ret = avs_ipc_copier_set_sink_format(adev, source->module_id,
+ source->instance_id, binding->source_pin,
+ src_fmt, sink_fmt);
+ if (ret) {
+ dev_err(adev->dev, "config copier failed: %d\n", ret);
+ return AVS_IPC_RET(ret);
+ }
+
+ return 0;
+}
+
int avs_path_bind(struct avs_path *path)
{
struct avs_path_pipeline *ppl;
@@ -478,6 +509,10 @@ int avs_path_bind(struct avs_path *path)
source = binding->source;
sink = binding->sink;
+ ret = avs_path_bind_prepare(adev, binding);
+ if (ret < 0)
+ return ret;
+
ret = avs_ipc_bind(adev, source->module_id,
source->instance_id, sink->module_id,
sink->instance_id, binding->sink_pin,