diff --git a/src/audio/buffers/comp_buffer.c b/src/audio/buffers/comp_buffer.c index 16cbc2bcb686..be26ef5479b6 100644 --- a/src/audio/buffers/comp_buffer.c +++ b/src/audio/buffers/comp_buffer.c @@ -429,7 +429,7 @@ int buffer_set_params(struct comp_buffer *buffer, return -EINVAL; } - if (buffer->hw_params_configured && !force_update) + if (audio_buffer_hw_params_configured(&buffer->audio_buffer) && !force_update) return 0; ret = audio_stream_set_params(&buffer->stream, params); @@ -442,7 +442,7 @@ int buffer_set_params(struct comp_buffer *buffer, for (i = 0; i < SOF_IPC_MAX_CHANNELS; i++) buffer->chmap[i] = params->chmap[i]; - buffer->hw_params_configured = true; + audio_buffer_set_hw_params_configured(&buffer->audio_buffer); return 0; } diff --git a/src/audio/buffers/ring_buffer.c b/src/audio/buffers/ring_buffer.c index 25543c2e4992..45849b0b0669 100644 --- a/src/audio/buffers/ring_buffer.c +++ b/src/audio/buffers/ring_buffer.c @@ -224,7 +224,8 @@ static int ring_buffer_set_ipc_params(struct ring_buffer *ring_buffer, bool force_update) { CORE_CHECK_STRUCT(&ring_buffer->audio_buffer); - if (ring_buffer->_hw_params_configured && !force_update) + + if (audio_buffer_hw_params_configured(&ring_buffer->audio_buffer) && !force_update) return 0; struct sof_audio_stream_params *audio_stream_params = @@ -235,7 +236,7 @@ static int ring_buffer_set_ipc_params(struct ring_buffer *ring_buffer, audio_stream_params->channels = params->channels; audio_stream_params->buffer_fmt = params->buffer_fmt; - ring_buffer->_hw_params_configured = true; + audio_buffer_set_hw_params_configured(&ring_buffer->audio_buffer); return 0; } diff --git a/src/audio/copier/copier.c b/src/audio/copier/copier.c index a82e54990311..31f62eb9d115 100644 --- a/src/audio/copier/copier.c +++ b/src/audio/copier/copier.c @@ -431,7 +431,8 @@ static int do_conversion_copy(struct comp_dev *dev, int i; /* buffer params might be not yet configured by component on another pipeline */ - if (!src->hw_params_configured || !sink->hw_params_configured) + if (!audio_buffer_hw_params_configured(&src->audio_buffer) || + !audio_buffer_hw_params_configured(&sink->audio_buffer)) return 0; comp_get_copy_limits(src, sink, processed_data); diff --git a/src/audio/copier/copier_generic.c b/src/audio/copier/copier_generic.c index 48107d238cae..0fe271d76c12 100644 --- a/src/audio/copier/copier_generic.c +++ b/src/audio/copier/copier_generic.c @@ -194,7 +194,7 @@ int create_endpoint_buffer(struct comp_dev *dev, for (i = 0; i < SOF_IPC_MAX_CHANNELS; i++) buffer->chmap[i] = (chan_map >> i * 4) & 0xf; - buffer->hw_params_configured = true; + audio_buffer_set_hw_params_configured(&buffer->audio_buffer); if (create_multi_endpoint_buffer) cd->multi_endpoint_buffer = buffer; diff --git a/src/audio/dai-zephyr.c b/src/audio/dai-zephyr.c index 32b44776a278..783207c45b64 100644 --- a/src/audio/dai-zephyr.c +++ b/src/audio/dai-zephyr.c @@ -302,7 +302,7 @@ dai_dma_cb(struct dai_data *dd, struct comp_dev *dev, uint32_t bytes, } if (sink_dev && sink_dev->state == COMP_STATE_ACTIVE && - sink->hw_params_configured) { + audio_buffer_hw_params_configured(&sink->audio_buffer)) { ret = stream_copy_from_no_consume(dd->local_buffer, sink, converter[j], bytes, dd->chmap); } @@ -353,7 +353,7 @@ dai_dma_cb(struct dai_data *dd, struct comp_dev *dev, uint32_t bytes, } if (sink_dev && sink_dev->state == COMP_STATE_ACTIVE && - sink->hw_params_configured) + audio_buffer_hw_params_configured(&sink->audio_buffer)) ret = stream_copy_from_no_consume(dd->dma_buffer, sink, converter[j], bytes, dd->chmap); @@ -1650,7 +1650,7 @@ int dai_common_copy(struct dai_data *dd, struct comp_dev *dev, pcm_converter_fun sink_dev = sink->sink; if (sink_dev && sink_dev->state == COMP_STATE_ACTIVE && - sink->hw_params_configured) { + audio_buffer_hw_params_configured(&sink->audio_buffer)) { sink_frames = audio_stream_get_free_frames(&sink->stream); frames = MIN(frames, sink_frames); @@ -1680,7 +1680,7 @@ int dai_common_copy(struct dai_data *dd, struct comp_dev *dev, pcm_converter_fun sink_dev = sink->sink; if (sink_dev && sink_dev->state == COMP_STATE_ACTIVE && - sink->hw_params_configured) { + audio_buffer_hw_params_configured(&sink->audio_buffer)) { sink_frames = audio_stream_get_free_frames(&sink->stream); frames = MIN(frames, sink_frames); diff --git a/src/audio/mux/mux_ipc4.c b/src/audio/mux/mux_ipc4.c index 6d183d6973f6..dd6315b3bcd0 100644 --- a/src/audio/mux/mux_ipc4.c +++ b/src/audio/mux/mux_ipc4.c @@ -95,7 +95,7 @@ static void set_mux_params(struct processing_module *mod) if (!list_is_empty(&dev->bsink_list)) { sink = comp_dev_get_first_data_consumer(dev); - if (!sink->hw_params_configured) { + if (!audio_buffer_hw_params_configured(&sink->audio_buffer)) { ipc4_update_buffer_format(sink, &cd->md.output_format); params->frame_fmt = audio_stream_get_frm_fmt(&sink->stream); } diff --git a/src/audio/selector/selector.c b/src/audio/selector/selector.c index 3ade8c14e477..fc36d5a9a830 100644 --- a/src/audio/selector/selector.c +++ b/src/audio/selector/selector.c @@ -669,7 +669,7 @@ static void set_selector_params(struct processing_module *mod, */ src_buf = comp_dev_get_first_data_producer(dev); - if (!src_buf->hw_params_configured) + if (!audio_buffer_hw_params_configured(&src_buf->audio_buffer)) ipc4_update_buffer_format(src_buf, &mod->priv.cfg.base_cfg.audio_fmt); } diff --git a/src/include/module/audio/audio_stream.h b/src/include/module/audio/audio_stream.h index 5e30c2aab4a9..301d74861a74 100644 --- a/src/include/module/audio/audio_stream.h +++ b/src/include/module/audio/audio_stream.h @@ -50,6 +50,8 @@ struct sof_audio_stream_params { bool underrun_permitted; /**< indicates whether underrun is permitted */ uint32_t buffer_fmt; /**< enum sof_ipc_buffer_format */ + + bool hw_params_configured; /**< indicates whether hw params were set */ }; #endif /* __MODULE_AUDIO_AUDIO_STREAM_H__ */ diff --git a/src/include/sof/audio/audio_buffer.h b/src/include/sof/audio/audio_buffer.h index 38d690107157..4254d98d3c02 100644 --- a/src/include/sof/audio/audio_buffer.h +++ b/src/include/sof/audio/audio_buffer.h @@ -173,6 +173,21 @@ static inline bool audio_buffer_is_shared(struct sof_audio_buffer *buffer) return buffer->is_shared; } +static inline bool audio_buffer_hw_params_configured(struct sof_audio_buffer *buffer) +{ + return buffer->audio_stream_params->hw_params_configured; +} + +static inline void audio_buffer_set_hw_params_configured(struct sof_audio_buffer *buffer) +{ + buffer->audio_stream_params->hw_params_configured = true; +} + +static inline void audio_buffer_reset_params(struct sof_audio_buffer *buffer) +{ + buffer->audio_stream_params->hw_params_configured = false; +} + /** * @brief return a handler to stream params structure */ diff --git a/src/include/sof/audio/buffer.h b/src/include/sof/audio/buffer.h index 4bb996c51a78..1e290d71cb4e 100644 --- a/src/include/sof/audio/buffer.h +++ b/src/include/sof/audio/buffer.h @@ -145,7 +145,6 @@ struct comp_buffer { /* runtime stream params */ uint16_t chmap[SOF_IPC_MAX_CHANNELS]; /**< channel map - SOF_CHMAP_ */ - bool hw_params_configured; /**< indicates whether hw params were set */ bool walking; /**< indicates if the buffer is being walked */ }; @@ -285,7 +284,7 @@ static inline void buffer_init_stream(struct comp_buffer *buffer, size_t size) static inline void buffer_reset_params(struct comp_buffer *buffer, void *data) { - buffer->hw_params_configured = false; + audio_buffer_reset_params(&buffer->audio_buffer); } #endif /* __SOF_AUDIO_BUFFER_H__ */ diff --git a/src/include/sof/audio/ring_buffer.h b/src/include/sof/audio/ring_buffer.h index cd1f7cc968b0..222b102f2ae9 100644 --- a/src/include/sof/audio/ring_buffer.h +++ b/src/include/sof/audio/ring_buffer.h @@ -110,8 +110,6 @@ struct ring_buffer { uint8_t __sparse_cache *_data_buffer; size_t _write_offset; /* private: to be modified by data producer using API */ size_t _read_offset; /* private: to be modified by data consumer using API */ - - bool _hw_params_configured; }; /** diff --git a/src/ipc/ipc4/helper.c b/src/ipc/ipc4/helper.c index 114f1cfea937..619be15a8030 100644 --- a/src/ipc/ipc4/helper.c +++ b/src/ipc/ipc4/helper.c @@ -1196,7 +1196,7 @@ void ipc4_update_buffer_format(struct comp_buffer *buf_c, for (i = 0; i < SOF_IPC_MAX_CHANNELS; i++) buf_c->chmap[i] = (fmt->ch_map >> i * 4) & 0xf; - buf_c->hw_params_configured = true; + audio_buffer_set_hw_params_configured(&buf_c->audio_buffer); } void ipc4_update_source_format(struct sof_source *source,