summaryrefslogtreecommitdiff
path: root/sound/soc/sof/sof-audio.h
diff options
context:
space:
mode:
authorRanjani Sridharan <ranjani.sridharan@linux.intel.com>2022-04-26 20:17:43 +0300
committerMark Brown <broonie@kernel.org>2022-04-29 15:06:05 +0300
commit66344c6d92113e605d8212e79b1219406893ee05 (patch)
tree03c5ce96ce660e5a9f43f266b63285c722b12d1b /sound/soc/sof/sof-audio.h
parent463a809ba8efa127484d16ff588e3bcdb63fe41e (diff)
downloadlinux-66344c6d92113e605d8212e79b1219406893ee05.tar.xz
ASoC: SOF: Add a prepare op to IPC topology widget ops
In order to set up a pipeline with IPC4, the total memory usage for the pipeline needs to be calculated based on the list of connected widgets. Add a new ipc_prepare() op to struct sof_ipc_tplg_widget_ops that will be used to calculate the memory usage for each widget in the pipelines associated with a PCM and prepare the widget for getting set up in the DSP. The prepare step will be used to allocate memory for the IPC payload, assign instance ID and update the config data for the widget based on the runtime PCM params. Once prepared, the setup step is used to send the IPC to create the widget in the DSP. Add an ipc_unprepare() op to unprepare the widget i.e free the memory allocated during prepare, free the instance ID etc. This should be invoked after the widget is freed. A new flag "prepared" is added to struct snd_sof_widget to track the prepared status of widgets. Also, IPC4 requires the platform_params and the runtime PCM params in order to prepare a widget for set up. So modify the signature of sof_pcm_setup_connected_widgets() and sof_widget_list_setup() to accept these as arguments. Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com> Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com> Reviewed-by: Péter Ujfalusi <peter.ujfalusi@linux.intel.com> Reviewed-by: Bard Liao <yung-chuan.liao@linux.intel.com> Link: https://lore.kernel.org/r/20220426171743.171061-12-ranjani.sridharan@linux.intel.com Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'sound/soc/sof/sof-audio.h')
-rw-r--r--sound/soc/sof/sof-audio.h21
1 files changed, 19 insertions, 2 deletions
diff --git a/sound/soc/sof/sof-audio.h b/sound/soc/sof/sof-audio.h
index 4dbee02424fe..27cc5fb642e5 100644
--- a/sound/soc/sof/sof-audio.h
+++ b/sound/soc/sof/sof-audio.h
@@ -36,8 +36,10 @@
#define SOF_DAI_CLK_INTEL_SSP_BCLK 1
enum sof_widget_op {
- SOF_WIDGET_FREE,
+ SOF_WIDGET_PREPARE,
SOF_WIDGET_SETUP,
+ SOF_WIDGET_FREE,
+ SOF_WIDGET_UNPREPARE,
};
/*
@@ -129,6 +131,8 @@ struct sof_ipc_tplg_control_ops {
* @token_list: List of token ID's that should be parsed for the widget
* @token_list_size: number of elements in token_list
* @bind_event: Function pointer for binding events to the widget
+ * @ipc_prepare: Optional op for preparing a widget for set up
+ * @ipc_unprepare: Optional op for unpreparing a widget
*/
struct sof_ipc_tplg_widget_ops {
int (*ipc_setup)(struct snd_sof_widget *swidget);
@@ -137,6 +141,11 @@ struct sof_ipc_tplg_widget_ops {
int token_list_size;
int (*bind_event)(struct snd_soc_component *scomp, struct snd_sof_widget *swidget,
u16 event_type);
+ int (*ipc_prepare)(struct snd_sof_widget *swidget,
+ struct snd_pcm_hw_params *fe_params,
+ struct snd_sof_platform_stream_params *platform_params,
+ struct snd_pcm_hw_params *source_params, int dir);
+ void (*ipc_unprepare)(struct snd_sof_widget *swidget);
};
/**
@@ -332,6 +341,11 @@ struct snd_sof_widget {
* widgets. It is unused for all other widget types.
*/
int complete;
+ /*
+ * the prepared flag is used to indicate that a widget has been prepared for getting set
+ * up in the DSP.
+ */
+ bool prepared;
int use_count; /* use_count will be protected by the PCM mutex held by the core */
int core;
int id; /* id is the DAPM widget type */
@@ -491,7 +505,10 @@ int sof_route_setup(struct snd_sof_dev *sdev, struct snd_soc_dapm_widget *wsourc
struct snd_soc_dapm_widget *wsink);
/* PCM */
-int sof_widget_list_setup(struct snd_sof_dev *sdev, struct snd_sof_pcm *spcm, int dir);
+int sof_widget_list_setup(struct snd_sof_dev *sdev, struct snd_sof_pcm *spcm,
+ struct snd_pcm_hw_params *fe_params,
+ struct snd_sof_platform_stream_params *platform_params,
+ int dir);
int sof_widget_list_free(struct snd_sof_dev *sdev, struct snd_sof_pcm *spcm, int dir);
int sof_pcm_dsp_pcm_free(struct snd_pcm_substream *substream, struct snd_sof_dev *sdev,
struct snd_sof_pcm *spcm);