Skip to content

Commit edfe8d0

Browse files
ujfalusiplbossart
authored andcommitted
ASoC: SOF: Introduce optional callback to configure stream data offset
Each running audio stream's data have distinct start offset within the stream mailbox area from/to where the host can read/write. Instead of using the struct sof_ipc_pcm_params_reply to configure this offset, add an optional callback which is IPC agnostic. Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
1 parent 4aee5ec commit edfe8d0

3 files changed

Lines changed: 26 additions & 0 deletions

File tree

sound/soc/sof/ops.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -476,6 +476,19 @@ snd_sof_ipc_pcm_params(struct snd_sof_dev *sdev,
476476
return sof_ops(sdev)->ipc_pcm_params(sdev, substream, reply);
477477
}
478478

479+
/* host side configuration of the stream's data offset in stream mailbox area */
480+
static inline int
481+
snd_sof_set_stream_data_offset(struct snd_sof_dev *sdev,
482+
struct snd_pcm_substream *substream,
483+
size_t posn_offset)
484+
{
485+
if (sof_ops(sdev) && sof_ops(sdev)->set_stream_data_offset)
486+
return sof_ops(sdev)->set_stream_data_offset(sdev, substream,
487+
posn_offset);
488+
489+
return 0;
490+
}
491+
479492
/* host stream pointer */
480493
static inline snd_pcm_uframes_t
481494
snd_sof_pcm_platform_pointer(struct snd_sof_dev *sdev,

sound/soc/sof/pcm.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,14 @@ static int sof_pcm_hw_params(struct snd_soc_component *component,
276276
return ret;
277277
}
278278

279+
ret = snd_sof_set_stream_data_offset(sdev, substream,
280+
ipc_params_reply.posn_offset);
281+
if (ret < 0) {
282+
dev_err(component->dev, "%s: invalid stream data offset for PCM %d\n",
283+
__func__, spcm->pcm.pcm_id);
284+
return ret;
285+
}
286+
279287
spcm->prepared[substream->stream] = true;
280288

281289
/* save pcm hw_params */

sound/soc/sof/sof-priv.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,11 @@ struct snd_sof_dsp_ops {
224224
struct snd_pcm_substream *substream,
225225
const struct sof_ipc_pcm_params_reply *reply); /* mandatory */
226226

227+
/* host side configuration of the stream's data offset in stream mailbox area */
228+
int (*set_stream_data_offset)(struct snd_sof_dev *sdev,
229+
struct snd_pcm_substream *substream,
230+
size_t posn_offset); /* optional */
231+
227232
/* pre/post firmware run */
228233
int (*pre_fw_run)(struct snd_sof_dev *sof_dev); /* optional */
229234
int (*post_fw_run)(struct snd_sof_dev *sof_dev); /* optional */

0 commit comments

Comments
 (0)