From dc33c8e1ff4a0d0b5be0d0643b4dce22f1f95b31 Mon Sep 17 00:00:00 2001 From: Daniel Baluta Date: Mon, 18 Jan 2021 15:46:31 +0200 Subject: [PATCH] LF-3665-2 ASoC: SOF: Refactor ipc_msg_data to prepare for compress API 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 --- sound/soc/sof/imx/imx8.c | 3 ++- sound/soc/sof/imx/imx8m.c | 3 ++- sound/soc/sof/intel/hda-ipc.c | 6 ++++-- sound/soc/sof/intel/hda.h | 2 +- sound/soc/sof/intel/intel-ipc.c | 6 ++++-- sound/soc/sof/ipc.c | 4 ++-- sound/soc/sof/ops.h | 4 ++-- sound/soc/sof/sof-priv.h | 6 ++++-- 8 files changed, 21 insertions(+), 13 deletions(-) diff --git a/sound/soc/sof/imx/imx8.c b/sound/soc/sof/imx/imx8.c index 69bd569ac1f4..f22752de8569 100644 --- a/sound/soc/sof/imx/imx8.c +++ b/sound/soc/sof/imx/imx8.c @@ -22,6 +22,7 @@ #include #include #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); diff --git a/sound/soc/sof/imx/imx8m.c b/sound/soc/sof/imx/imx8m.c index f72493e646ce..437b4b707212 100644 --- a/sound/soc/sof/imx/imx8m.c +++ b/sound/soc/sof/imx/imx8m.c @@ -21,6 +21,7 @@ #include #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); diff --git a/sound/soc/sof/intel/hda-ipc.c b/sound/soc/sof/intel/hda-ipc.c index c91aa951df22..9e7347fab91b 100644 --- a/sound/soc/sof/intel/hda-ipc.c +++ b/sound/soc/sof/intel/hda-ipc.c @@ -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; diff --git a/sound/soc/sof/intel/hda.h b/sound/soc/sof/intel/hda.h index 1bc4dabdd394..b1bd657a506f 100644 --- a/sound/soc/sof/intel/hda.h +++ b/sound/soc/sof/intel/hda.h @@ -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, diff --git a/sound/soc/sof/intel/intel-ipc.c b/sound/soc/sof/intel/intel-ipc.c index 310f9168c124..4bd940b54bd7 100644 --- a/sound/soc/sof/intel/intel-ipc.c +++ b/sound/soc/sof/intel/intel-ipc.c @@ -18,6 +18,7 @@ #include #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 */ diff --git a/sound/soc/sof/ipc.c b/sound/soc/sof/ipc.c index fd2b96ae4943..8da0a1067c14 100644 --- a/sound/soc/sof/ipc.c +++ b/sound/soc/sof/ipc.c @@ -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); diff --git a/sound/soc/sof/ops.h b/sound/soc/sof/ops.h index b21632f5511a..2ce501a948cb 100644 --- a/sound/soc/sof/ops.h +++ b/sound/soc/sof/ops.h @@ -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 */ diff --git a/sound/soc/sof/sof-priv.h b/sound/soc/sof/sof-priv.h index 0aed2a7ab858..29069265ad48 100644 --- a/sound/soc/sof/sof-priv.h +++ b/sound/soc/sof/sof-priv.h @@ -19,6 +19,8 @@ #include #include +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, -- 2.17.1