ASoC: SOF: ipc4-pcm: Define pcm_setup/free ops
authorRanjani Sridharan <ranjani.sridharan@linux.intel.com>
Fri, 27 Jan 2023 12:00:21 +0000 (14:00 +0200)
committerMark Brown <broonie@kernel.org>
Fri, 27 Jan 2023 12:14:04 +0000 (12:14 +0000)
Define the pcm_setup/pcm_free ops for IPC4. Define a new struct
snd_sof_pcm_stream_trigger_info and add a new field trigger_info of this
type to struct snd_sof_pcm_stream. This will be used to save the list of
pipelines that need to be triggered.

Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Reviewed-by: Libin Yang <libin.yang@intel.com>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: Péter Ujfalusi <peter.ujfalusi@linux.intel.com>
Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
Link: https://lore.kernel.org/r/20230127120031.10709-9-peter.ujfalusi@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/sof/ipc4-pcm.c
sound/soc/sof/sof-audio.h

index 23de58d7d06b384a3cbf3039ec2cdd3773f4b95a..05515e8e6f57a2872173232362688de31c72c661 100644 (file)
@@ -215,8 +215,44 @@ static int sof_ipc4_pcm_dai_link_fixup(struct snd_soc_pcm_runtime *rtd,
        return 0;
 }
 
+static void sof_ipc4_pcm_free(struct snd_sof_dev *sdev, struct snd_sof_pcm *spcm)
+{
+       struct snd_sof_pcm_stream_pipeline_list *pipeline_list;
+       int stream;
+
+       for_each_pcm_streams(stream) {
+               pipeline_list = &spcm->stream[stream].pipeline_list;
+               kfree(pipeline_list->pipe_widgets);
+               pipeline_list->pipe_widgets = NULL;
+       }
+}
+
+static int sof_ipc4_pcm_setup(struct snd_sof_dev *sdev, struct snd_sof_pcm *spcm)
+{
+       struct snd_sof_pcm_stream_pipeline_list *pipeline_list;
+       struct sof_ipc4_fw_data *ipc4_data = sdev->private;
+       int stream;
+
+       for_each_pcm_streams(stream) {
+               pipeline_list = &spcm->stream[stream].pipeline_list;
+
+               /* allocate memory for max number of pipeline IDs */
+               pipeline_list->pipe_widgets = kcalloc(ipc4_data->max_num_pipelines,
+                                                     sizeof(struct snd_sof_widget *),
+                                                     GFP_KERNEL);
+               if (!pipeline_list->pipe_widgets) {
+                       sof_ipc4_pcm_free(sdev, spcm);
+                       return -ENOMEM;
+               }
+       }
+
+       return 0;
+}
+
 const struct sof_ipc_pcm_ops ipc4_pcm_ops = {
        .trigger = sof_ipc4_pcm_trigger,
        .hw_free = sof_ipc4_pcm_hw_free,
        .dai_link_fixup = sof_ipc4_pcm_dai_link_fixup,
+       .pcm_setup = sof_ipc4_pcm_setup,
+       .pcm_free = sof_ipc4_pcm_free,
 };
index bcde2ebaf022bd9ee34fc0be7eb1c9bff1ad1a1c..bb5c61dd9b1e056d09ce778193d70f083ef5eea6 100644 (file)
@@ -285,6 +285,16 @@ struct sof_token_info {
        int count;
 };
 
+/**
+ * struct snd_sof_pcm_stream_pipeline_list - List of pipelines associated with a PCM stream
+ * @count: number of pipeline widgets in the @pipe_widgets array
+ * @pipe_widgets: array of pipeline widgets
+ */
+struct snd_sof_pcm_stream_pipeline_list {
+       u32 count;
+       struct snd_sof_widget **pipe_widgets;
+};
+
 /* PCM stream, mapped to FW component  */
 struct snd_sof_pcm_stream {
        u32 comp_id;
@@ -300,6 +310,7 @@ struct snd_sof_pcm_stream {
         * active or not while suspending the stream
         */
        bool suspend_ignored;
+       struct snd_sof_pcm_stream_pipeline_list pipeline_list;
 };
 
 /* ALSA SOF PCM device */