diff --git a/src/audio/host.c b/src/audio/host.c index 8f0495723569..7bf46d6cb34f 100644 --- a/src/audio/host.c +++ b/src/audio/host.c @@ -76,6 +76,7 @@ struct host_data { uint32_t host_period_bytes; uint16_t stream_tag; uint16_t no_stream_position; /**< 1 means don't send stream position */ + uint8_t cont_update_posn; /**< 1 means continuous update stream position */ /* host component attributes */ enum comp_copy_type copy_type; /**< Current host copy type */ @@ -307,6 +308,8 @@ static void host_update_position(struct comp_dev *dev, uint32_t bytes) struct comp_buffer *source; struct comp_buffer *sink; int ret; + bool update_mailbox = false; + bool send_ipc = false; if (dev->direction == SOF_IPC_STREAM_PLAYBACK) @@ -345,6 +348,8 @@ static void host_update_position(struct comp_dev *dev, uint32_t bytes) #else hd->local_pos = 0; #endif + if (hd->cont_update_posn) + update_mailbox = true; /* Don't send stream position if no_stream_position == 1 */ if (!hd->no_stream_position) { @@ -361,12 +366,18 @@ static void host_update_position(struct comp_dev *dev, uint32_t bytes) /* send timestamped position to host * (updates position first, by calling ops.position()) */ - pipeline_get_timestamp(dev->pipeline, dev, &hd->posn); - mailbox_stream_write(dev->pipeline->posn_offset, - &hd->posn, sizeof(hd->posn)); - ipc_msg_send(hd->msg, &hd->posn, false); + update_mailbox = true; + send_ipc = true; } } + + if (update_mailbox) { + pipeline_get_timestamp(dev->pipeline, dev, &hd->posn); + mailbox_stream_write(dev->pipeline->posn_offset, + &hd->posn, sizeof(hd->posn)); + if (send_ipc) + ipc_msg_send(hd->msg, &hd->posn, false); + } } /* The host memory is not guaranteed to be continuous and also not guaranteed @@ -761,6 +772,7 @@ static int host_params(struct comp_dev *dev, hd->stream_tag = params->stream_tag; hd->no_stream_position = params->no_stream_position; hd->host_period_bytes = params->host_period_bytes; + hd->cont_update_posn = params->cont_update_posn; /* retrieve DMA buffer address alignment */ err = dma_get_attribute(hd->dma, DMA_ATTR_BUFFER_ADDRESS_ALIGNMENT, diff --git a/src/include/ipc/stream.h b/src/include/ipc/stream.h index 1bf75832d5dc..e4723972a9f1 100644 --- a/src/include/ipc/stream.h +++ b/src/include/ipc/stream.h @@ -94,8 +94,9 @@ struct sof_ipc_stream_params { uint32_t host_period_bytes; uint16_t no_stream_position; /**< 1 means don't send stream position */ + uint8_t cont_update_posn; /**< 1 means continuous update stream position */ - uint16_t reserved[3]; + uint8_t reserved[5]; uint16_t chmap[SOF_IPC_MAX_CHANNELS]; /**< channel map - SOF_CHMAP_ */ } __attribute__((packed, aligned(4))); diff --git a/src/include/kernel/abi.h b/src/include/kernel/abi.h index 43580b178e11..cc061fb0aa28 100644 --- a/src/include/kernel/abi.h +++ b/src/include/kernel/abi.h @@ -29,8 +29,8 @@ /** \brief SOF ABI version major, minor and patch numbers */ #define SOF_ABI_MAJOR 3 -#define SOF_ABI_MINOR 20 -#define SOF_ABI_PATCH 1 +#define SOF_ABI_MINOR 21 +#define SOF_ABI_PATCH 0 /** \brief SOF ABI version number. Format within 32bit word is MMmmmppp */ #define SOF_ABI_MAJOR_SHIFT 24 diff --git a/src/ipc/ipc3/handler.c b/src/ipc/ipc3/handler.c index 36c9266f0885..e81dd1188929 100644 --- a/src/ipc/ipc3/handler.c +++ b/src/ipc/ipc3/handler.c @@ -193,6 +193,7 @@ static int ipc_stream_pcm_params(uint32_t stream) struct sof_ipc_pcm_params pcm_params; struct sof_ipc_pcm_params_reply reply; struct ipc_comp_dev *pcm_dev; + struct sof_ipc_stream_posn posn; int err, reset_err; /* copy message with ABI safe method */ @@ -299,6 +300,11 @@ static int ipc_stream_pcm_params(uint32_t stream) reply.rhdr.error = 0; reply.comp_id = pcm_params.comp_id; reply.posn_offset = pcm_dev->cd->pipeline->posn_offset; + + /* reset position value before send ipc */ + memset(&posn, 0, sizeof(posn)); + mailbox_stream_write(reply.posn_offset, &posn, sizeof(posn)); + mailbox_hostbox_write(0, &reply, sizeof(reply)); return 1;