Skip to content

Commit be41a4b

Browse files
committed
audio: host-zephyr: add HOST_DMA_IPC_POSITION_UPDATES Kconfig
Add a built option HOST_DMA_IPC_POSITION_UPDATES to control whether functionality to send IPC stream position updates is enabled or not. Most platforms provide more efficient means for host to monitor DMA state, so this code is in most cases unncessary. The current IPC sending code (from audio context) also assume kernel context, so making this functionality user-space compatible will require extra work. Enable DMA IPC position updates by default for IPC3 as the feature can be controlled by host with sof_ipc_stream_params.no_stream_position IPC interface. Disable the feature by default for IPC4, as there is no host IPC interface to control this and copier_update_params() unconditionally disables IPC updates for IPC4 now, so this code is never used. Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
1 parent e3246b8 commit be41a4b

3 files changed

Lines changed: 21 additions & 1 deletion

File tree

src/audio/Kconfig

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,14 @@ config HOST_DMA_STREAM_SYNCHRONIZATION
4242
for each group, different than the default one determined by the system tick frequency.
4343
This feature will allow host lower power consumption in scenarios with deep buffering.
4444

45+
config HOST_DMA_IPC_POSITION_UPDATES
46+
bool "Support for stream position updates via IPC messages"
47+
default y if IPC_MAJOR_3
48+
help
49+
Support firmware functionality to report stream position updates
50+
by sending an IPC message whenever one period of audio is transferred.
51+
Most platforms provide more efficient ways to query the DMA status.
52+
4553
config COMP_CHAIN_DMA
4654
bool "Chain DMA component"
4755
depends on IPC_MAJOR_4

src/audio/copier/host_copier.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,9 @@ struct host_data {
106106

107107
/* stream info */
108108
struct sof_ipc_stream_posn posn; /* TODO: update this */
109+
#if CONFIG_HOST_DMA_IPC_POSITION_UPDATES
109110
struct ipc_msg *msg; /**< host notification */
111+
#endif
110112
#if CONFIG_XRUN_NOTIFICATIONS_ENABLE
111113
bool xrun_notification_sent;
112114
#endif

src/audio/host-zephyr.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,9 @@ void host_common_update(struct host_data *hd, struct comp_dev *dev, uint32_t byt
246246
struct comp_buffer *sink;
247247
int ret;
248248
bool update_mailbox = false;
249+
#if CONFIG_HOST_DMA_IPC_POSITION_UPDATES
249250
bool send_ipc = false;
251+
#endif
250252

251253
if (dev->direction == SOF_IPC_STREAM_PLAYBACK) {
252254
source = hd->dma_buffer;
@@ -285,6 +287,7 @@ void host_common_update(struct host_data *hd, struct comp_dev *dev, uint32_t byt
285287
if (hd->cont_update_posn)
286288
update_mailbox = true;
287289

290+
#if CONFIG_HOST_DMA_IPC_POSITION_UPDATES
288291
/* Don't send stream position if no_stream_position == 1 */
289292
if (!hd->no_stream_position) {
290293
hd->report_pos += bytes;
@@ -304,13 +307,16 @@ void host_common_update(struct host_data *hd, struct comp_dev *dev, uint32_t byt
304307
send_ipc = true;
305308
}
306309
}
310+
#endif
307311

308312
if (update_mailbox) {
309313
pipeline_get_timestamp(dev->pipeline, dev, &hd->posn);
310314
mailbox_stream_write(dev->pipeline->posn_offset,
311315
&hd->posn, sizeof(hd->posn));
316+
#if CONFIG_HOST_DMA_IPC_POSITION_UPDATES
312317
if (send_ipc)
313318
ipc_msg_send(hd->msg, &hd->posn, false);
319+
#endif
314320
}
315321
}
316322

@@ -720,14 +726,16 @@ __cold int host_common_new(struct host_data *hd, struct comp_dev *dev,
720726
dma_sg_init(&hd->local.elem_array);
721727

722728
ipc_build_stream_posn(&hd->posn, SOF_IPC_STREAM_POSITION, config_id);
729+
hd->chan_index = -EINVAL;
723730

731+
#if CONFIG_HOST_DMA_IPC_POSITION_UPDATES
724732
hd->msg = ipc_msg_init(hd->posn.rhdr.hdr.cmd, sizeof(hd->posn));
725733
if (!hd->msg) {
726734
comp_err(dev, "ipc_msg_init failed");
727735
sof_dma_put(hd->dma);
728736
return -ENOMEM;
729737
}
730-
hd->chan_index = -EINVAL;
738+
#endif
731739
hd->copy_type = COMP_COPY_NORMAL;
732740

733741
#ifdef CONFIG_SOF_USERSPACE_LL
@@ -808,7 +816,9 @@ __cold void host_common_free(struct host_data *hd)
808816

809817
sof_dma_put(hd->dma);
810818

819+
#if CONFIG_HOST_DMA_IPC_POSITION_UPDATES
811820
ipc_msg_free(hd->msg);
821+
#endif
812822
dma_sg_free(hd->alloc_ctx.heap, &hd->config.elem_array);
813823
}
814824

0 commit comments

Comments
 (0)