LF-3774-3 ASoC: SOF: Fix sof_ipc_msg_data for compress streams
authorDaniel Baluta <daniel.baluta@nxp.com>
Wed, 12 May 2021 17:17:31 +0000 (20:17 +0300)
committerDaniel Baluta <daniel.baluta@nxp.com>
Thu, 13 May 2021 06:33:53 +0000 (09:33 +0300)
sof_ipc_msg_data relies on sof_pcm_stream to retrieve the Host position
offset. This doesn't work for compress audio.

For compressed audio we need to retrieve position offset from
sof_compr_stream.

Signed-off-by: Daniel Baluta <daniel.baluta@nxp.com>
sound/soc/sof/compress.c
sound/soc/sof/ipc-stream.c
sound/soc/sof/sof-priv.h

index 4d3890e..a7de209 100644 (file)
 #include "sof-audio.h"
 #include "sof-priv.h"
 
-struct sof_compr_stream {
-       unsigned int copied_total;
-       unsigned int sample_rate;
-};
-
 static void sof_set_transferred_bytes(struct sof_compr_stream *sstream,
                                      u64 host_pos, u64 buffer_size)
 {
@@ -185,6 +180,7 @@ int sof_compr_set_params(struct snd_soc_component *component,
                return ret;
        }
 
+       sstream->posn_offset = sdev->stream_box.offset + ipc_params_reply.posn_offset;
        sstream->sample_rate = params->codec.sample_rate;
        spcm->prepared[cstream->direction] = true;
 
index 497c082..6e5e983 100644 (file)
@@ -34,11 +34,21 @@ void sof_ipc_msg_data(struct snd_sof_dev *sdev,
                sof_mailbox_read(sdev, sdev->dsp_box.offset, p, sz);
        } else {
                struct snd_pcm_substream *substream = sps->substream;
-               struct sof_pcm_stream *stream = substream->runtime->private_data;
-
+               struct snd_compr_stream *cstream = sps->cstream;
+               struct sof_pcm_stream *pstream;
+               struct sof_compr_stream *sstream;
+               size_t posn_offset;
+
+               if (substream) {
+                       pstream = substream->runtime->private_data;
+                       posn_offset = pstream->posn_offset;
+               } else {
+                       sstream = cstream->runtime->private_data;
+                       posn_offset = sstream->posn_offset;
+               }
                /* The stream might already be closed */
-               if (stream)
-                       sof_mailbox_read(sdev, stream->posn_offset, p, sz);
+               if (pstream || sstream)
+                       sof_mailbox_read(sdev, posn_offset, p, sz);
        }
 }
 EXPORT_SYMBOL(sof_ipc_msg_data);
index 9d2e6f1..86a7ab3 100644 (file)
@@ -81,6 +81,12 @@ enum sof_system_suspend_state {
        SOF_SUSPEND_S3,
 };
 
+struct sof_compr_stream {
+       unsigned int copied_total;
+       unsigned int sample_rate;
+       size_t posn_offset;
+};
+
 struct snd_sof_dev;
 struct snd_sof_ipc_msg;
 struct snd_sof_ipc;