LF-3665-2 ASoC: SOF: Refactor ipc_msg_data to prepare for compress API
authorDaniel Baluta <daniel.baluta@nxp.com>
Mon, 18 Jan 2021 13:46:31 +0000 (15:46 +0200)
committerDaniel Baluta <daniel.baluta@nxp.com>
Wed, 28 Apr 2021 12:27:52 +0000 (15:27 +0300)
Make second parameter of ipc_msg_data generic
in order to be able to support compressed streams.

This patch doesn't hold any functional change.

snd_sof_pcm_stream holds the information for a PCM stream like:
* page_table buffer for sharing data with the DSP
* snd_pcm_substream
* workqueue for handling period elapsed notifications.

Most of these fields are also useful for compress implementation. So,
snd_sof_pcm_stream will be extended to be used for compress
implementation.

First step, is to make ipc_msg_data parameters more generic:

       void (*ipc_msg_data)(struct snd_sof_dev *sdev,
-                            struct snd_pcm_substream *substream,
+                            struct snd_sof_pcm_stream *sps,
                             void *p, size_t sz); /* mandatory */

With this case we can use ipc_msg_data, to retrieve information from DSP
for both PCM/Compress API.

Note:
     - snd_sof_pcm_stream, will be updated with a new member of type
       snd_compr_stream to account for Compress streams.

Signed-off-by: Daniel Baluta <daniel.baluta@nxp.com>
sound/soc/sof/imx/imx8.c
sound/soc/sof/imx/imx8m.c
sound/soc/sof/intel/hda-ipc.c
sound/soc/sof/intel/hda.h
sound/soc/sof/intel/intel-ipc.c
sound/soc/sof/ipc.c
sound/soc/sof/ops.h
sound/soc/sof/sof-priv.h

index 69bd569..f22752d 100644 (file)
@@ -22,6 +22,7 @@
 #include <linux/firmware/imx/svc/misc.h>
 #include <dt-bindings/firmware/imx/rsrc.h>
 #include "../ops.h"
+#include "../sof-audio.h"
 #include "imx-common.h"
 
 /* DSP memories */
@@ -455,7 +456,7 @@ static int imx8_get_bar_index(struct snd_sof_dev *sdev, u32 type)
 }
 
 static void imx8_ipc_msg_data(struct snd_sof_dev *sdev,
-                             struct snd_pcm_substream *substream,
+                             struct snd_sof_pcm_stream *sps,
                              void *p, size_t sz)
 {
        sof_mailbox_read(sdev, sdev->dsp_box.offset, p, sz);
index f72493e..437b4b7 100644 (file)
@@ -21,6 +21,7 @@
 #include <linux/firmware/imx/dsp.h>
 
 #include "../ops.h"
+#include "../sof-audio.h"
 #include "imx-common.h"
 
 #define MBOX_OFFSET    0x800000
@@ -382,7 +383,7 @@ static int imx8m_get_bar_index(struct snd_sof_dev *sdev, u32 type)
 }
 
 static void imx8m_ipc_msg_data(struct snd_sof_dev *sdev,
-                              struct snd_pcm_substream *substream,
+                              struct snd_sof_pcm_stream *sps,
                               void *p, size_t sz)
 {
        sof_mailbox_read(sdev, sdev->dsp_box.offset, p, sz);
index c91aa95..9e7347f 100644 (file)
@@ -16,6 +16,7 @@
  */
 
 #include "../ops.h"
+#include "../sof-audio.h"
 #include "hda.h"
 
 static void hda_dsp_ipc_host_done(struct snd_sof_dev *sdev)
@@ -254,12 +255,13 @@ int hda_dsp_ipc_get_window_offset(struct snd_sof_dev *sdev, u32 id)
 }
 
 void hda_ipc_msg_data(struct snd_sof_dev *sdev,
-                     struct snd_pcm_substream *substream,
+                     struct snd_sof_pcm_stream *sps,
                      void *p, size_t sz)
 {
-       if (!substream || !sdev->stream_box.size) {
+       if (!sps || !sdev->stream_box.size) {
                sof_mailbox_read(sdev, sdev->dsp_box.offset, p, sz);
        } else {
+               struct snd_pcm_substream *substream = sps->substream;
                struct hdac_stream *hstream = substream->runtime->private_data;
                struct sof_intel_hda_stream *hda_stream;
 
index 1bc4dab..b1bd657 100644 (file)
@@ -566,7 +566,7 @@ int hda_dsp_stream_spib_config(struct snd_sof_dev *sdev,
                               int enable, u32 size);
 
 void hda_ipc_msg_data(struct snd_sof_dev *sdev,
-                     struct snd_pcm_substream *substream,
+                     struct snd_sof_pcm_stream *sps,
                      void *p, size_t sz);
 int hda_ipc_pcm_params(struct snd_sof_dev *sdev,
                       struct snd_pcm_substream *substream,
index 310f916..4bd940b 100644 (file)
@@ -18,6 +18,7 @@
 #include <sound/sof/stream.h>
 
 #include "../ops.h"
+#include "../sof-audio.h"
 #include "../sof-priv.h"
 
 struct intel_stream {
@@ -26,12 +27,13 @@ struct intel_stream {
 
 /* Mailbox-based Intel IPC implementation */
 void intel_ipc_msg_data(struct snd_sof_dev *sdev,
-                       struct snd_pcm_substream *substream,
+                       struct snd_sof_pcm_stream *sps,
                        void *p, size_t sz)
 {
-       if (!substream || !sdev->stream_box.size) {
+       if (!sps || !sdev->stream_box.size) {
                sof_mailbox_read(sdev, sdev->dsp_box.offset, p, sz);
        } else {
+               struct snd_pcm_substream *substream = sps->substream;
                struct intel_stream *stream = substream->runtime->private_data;
 
                /* The stream might already be closed */
index fd2b96a..8da0a10 100644 (file)
@@ -453,7 +453,7 @@ static void ipc_period_elapsed(struct snd_sof_dev *sdev, u32 msg_id)
        }
 
        stream = &spcm->stream[direction];
-       snd_sof_ipc_msg_data(sdev, stream->substream, &posn, sizeof(posn));
+       snd_sof_ipc_msg_data(sdev, stream, &posn, sizeof(posn));
 
        dev_vdbg(sdev->dev, "posn : host 0x%llx dai 0x%llx wall 0x%llx\n",
                 posn.host_posn, posn.dai_posn, posn.wallclock);
@@ -482,7 +482,7 @@ static void ipc_xrun(struct snd_sof_dev *sdev, u32 msg_id)
        }
 
        stream = &spcm->stream[direction];
-       snd_sof_ipc_msg_data(sdev, stream->substream, &posn, sizeof(posn));
+       snd_sof_ipc_msg_data(sdev, stream, &posn, sizeof(posn));
 
        dev_dbg(sdev->dev,  "posn XRUN: host %llx comp %d size %d\n",
                posn.host_posn, posn.xrun_comp_id, posn.xrun_size);
index b21632f..2ce501a 100644 (file)
@@ -367,10 +367,10 @@ snd_sof_pcm_platform_trigger(struct snd_sof_dev *sdev,
 
 /* host DSP message data */
 static inline void snd_sof_ipc_msg_data(struct snd_sof_dev *sdev,
-                                       struct snd_pcm_substream *substream,
+                                       struct snd_sof_pcm_stream *sps,
                                        void *p, size_t sz)
 {
-       sof_ops(sdev)->ipc_msg_data(sdev, substream, p, sz);
+       sof_ops(sdev)->ipc_msg_data(sdev, sps, p, sz);
 }
 
 /* host configure DSP HW parameters */
index 0aed2a7..2906926 100644 (file)
@@ -19,6 +19,8 @@
 #include <sound/sof/trace.h>
 #include <uapi/sound/sof/fw.h>
 
+struct snd_sof_pcm_stream;
+
 /* debug flags */
 #define SOF_DBG_ENABLE_TRACE   BIT(0)
 #define SOF_DBG_REGS           BIT(1)
@@ -196,7 +198,7 @@ struct snd_sof_dsp_ops {
 
        /* host read DSP stream data */
        void (*ipc_msg_data)(struct snd_sof_dev *sdev,
-                            struct snd_pcm_substream *substream,
+                            struct snd_sof_pcm_stream *sps,
                             void *p, size_t sz); /* mandatory */
 
        /* host configure DSP HW parameters */
@@ -565,7 +567,7 @@ void sof_block_read(struct snd_sof_dev *sdev, u32 bar, u32 offset, void *dest,
 int sof_fw_ready(struct snd_sof_dev *sdev, u32 msg_id);
 
 void intel_ipc_msg_data(struct snd_sof_dev *sdev,
-                       struct snd_pcm_substream *substream,
+                       struct snd_sof_pcm_stream *sps,
                        void *p, size_t sz);
 int intel_ipc_pcm_params(struct snd_sof_dev *sdev,
                         struct snd_pcm_substream *substream,