[PATCH 04/10] ASoC: SOF: Introduce optional callback to configure stream data offset
Ranjani Sridharan
ranjani.sridharan at linux.intel.com
Thu Mar 10 05:27:14 CET 2022
From: Peter Ujfalusi <peter.ujfalusi at linux.intel.com>
Each running audio stream's data have distinct start offset within the
stream mailbox area from/to where the host can read/write.
Instead of using the struct sof_ipc_pcm_params_reply to configure this
offset, add an optional callback which is IPC agnostic.
Signed-off-by: Peter Ujfalusi <peter.ujfalusi at linux.intel.com>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart at linux.intel.com>
Reviewed-by: Rander Wang <rander.wang at intel.com>
Reviewed-by: Daniel Baluta <daniel.baluta at nxp.com>
Signed-off-by: Ranjani Sridharan <ranjani.sridharan at linux.intel.com>
---
sound/soc/sof/ops.h | 13 +++++++++++++
sound/soc/sof/pcm.c | 8 ++++++++
sound/soc/sof/sof-priv.h | 5 +++++
3 files changed, 26 insertions(+)
diff --git a/sound/soc/sof/ops.h b/sound/soc/sof/ops.h
index 98fa91f5927d..f21d4a7ac261 100644
--- a/sound/soc/sof/ops.h
+++ b/sound/soc/sof/ops.h
@@ -476,6 +476,19 @@ snd_sof_ipc_pcm_params(struct snd_sof_dev *sdev,
return sof_ops(sdev)->ipc_pcm_params(sdev, substream, reply);
}
+/* host side configuration of the stream's data offset in stream mailbox area */
+static inline int
+snd_sof_set_stream_data_offset(struct snd_sof_dev *sdev,
+ struct snd_pcm_substream *substream,
+ size_t posn_offset)
+{
+ if (sof_ops(sdev) && sof_ops(sdev)->set_stream_data_offset)
+ return sof_ops(sdev)->set_stream_data_offset(sdev, substream,
+ posn_offset);
+
+ return 0;
+}
+
/* host stream pointer */
static inline snd_pcm_uframes_t
snd_sof_pcm_platform_pointer(struct snd_sof_dev *sdev,
diff --git a/sound/soc/sof/pcm.c b/sound/soc/sof/pcm.c
index 93989a77873a..af8c367cd55c 100644
--- a/sound/soc/sof/pcm.c
+++ b/sound/soc/sof/pcm.c
@@ -276,6 +276,14 @@ static int sof_pcm_hw_params(struct snd_soc_component *component,
return ret;
}
+ ret = snd_sof_set_stream_data_offset(sdev, substream,
+ ipc_params_reply.posn_offset);
+ if (ret < 0) {
+ dev_err(component->dev, "%s: invalid stream data offset for PCM %d\n",
+ __func__, spcm->pcm.pcm_id);
+ return ret;
+ }
+
spcm->prepared[substream->stream] = true;
/* save pcm hw_params */
diff --git a/sound/soc/sof/sof-priv.h b/sound/soc/sof/sof-priv.h
index 3c50defcfb25..3a2804c82bae 100644
--- a/sound/soc/sof/sof-priv.h
+++ b/sound/soc/sof/sof-priv.h
@@ -226,6 +226,11 @@ struct snd_sof_dsp_ops {
struct snd_pcm_substream *substream,
const struct sof_ipc_pcm_params_reply *reply); /* mandatory */
+ /* host side configuration of the stream's data offset in stream mailbox area */
+ int (*set_stream_data_offset)(struct snd_sof_dev *sdev,
+ struct snd_pcm_substream *substream,
+ size_t posn_offset); /* optional */
+
/* pre/post firmware run */
int (*pre_fw_run)(struct snd_sof_dev *sof_dev); /* optional */
int (*post_fw_run)(struct snd_sof_dev *sof_dev); /* optional */
--
2.25.1
More information about the Alsa-devel
mailing list