From 46a9d87f1f75dd72076018691b76de020e8176f6 Mon Sep 17 00:00:00 2001 From: Marcin Szkudlinski Date: Wed, 20 Sep 2023 12:57:58 +0200 Subject: [PATCH] sink/src: change IBS/OBS in API to more meaningful names there's a big confusion in naming: meaning IBS/OBS from module point of view is opposite to meaning of OBS/IBS from buffer or queue point of view This PR changes - IBS to min_available - OBS to min_free_space names like this are less likely to cause confusions Signed-off-by: Marcin Szkudlinski --- src/audio/dp_queue.c | 15 ++++++++------- src/audio/sink_api_helper.c | 8 ++++---- src/audio/source_api_helper.c | 8 ++++---- src/include/sof/audio/dp_queue.h | 12 +++++------- .../sof/audio/module_adapter/module/generic.h | 4 ++-- src/include/sof/audio/sink_api.h | 4 ++-- src/include/sof/audio/sink_api_implementation.h | 4 +++- src/include/sof/audio/source_api.h | 4 ++-- .../sof/audio/source_api_implementation.h | 6 +++++- src/ipc/ipc4/helper.c | 16 ++++++++++------ 10 files changed, 45 insertions(+), 36 deletions(-) diff --git a/src/audio/dp_queue.c b/src/audio/dp_queue.c index 62ca3e85f894..07fa67fc0169 100644 --- a/src/audio/dp_queue.c +++ b/src/audio/dp_queue.c @@ -245,7 +245,7 @@ static const struct sink_ops dp_queue_sink_ops = { .audio_set_ipc_params = dp_queue_set_ipc_params_sink, }; -struct dp_queue *dp_queue_create(size_t ibs, size_t obs, uint32_t flags) +struct dp_queue *dp_queue_create(size_t min_available, size_t min_free_space, uint32_t flags) { struct dp_queue *dp_queue; @@ -269,11 +269,11 @@ struct dp_queue *dp_queue_create(size_t ibs, size_t obs, uint32_t flags) &dp_queue->audio_stream_params); /* set obs/ibs in sink/source interfaces */ - sink_set_obs(&dp_queue->_sink_api, obs); - source_set_ibs(&dp_queue->_source_api, ibs); + sink_set_min_free_space(&dp_queue->_sink_api, min_free_space); + source_set_min_available(&dp_queue->_source_api, min_available); - uint32_t max_ibs_obs = MAX(ibs, obs); - uint32_t min_ibs_obs = MIN(ibs, obs); + uint32_t max_ibs_obs = MAX(min_available, min_free_space); + uint32_t min_ibs_obs = MIN(min_available, min_free_space); /* calculate required buffer size */ if (max_ibs_obs % min_ibs_obs == 0) @@ -288,8 +288,9 @@ struct dp_queue *dp_queue_create(size_t ibs, size_t obs, uint32_t flags) if (!dp_queue->_data_buffer) goto err; - tr_info(&dp_queue_tr, "DpQueue created, shared: %u ibs: %u obs %u, size %u", - dp_queue_is_shared(dp_queue), ibs, obs, dp_queue->data_buffer_size); + tr_info(&dp_queue_tr, "DpQueue created, shared: %u min_available: %u min_free_space %u, size %u", + dp_queue_is_shared(dp_queue), min_available, min_free_space, + dp_queue->data_buffer_size); /* return a pointer to allocated structure */ return dp_queue; diff --git a/src/audio/sink_api_helper.c b/src/audio/sink_api_helper.c index 519912e49967..46ffbfd6b860 100644 --- a/src/audio/sink_api_helper.c +++ b/src/audio/sink_api_helper.c @@ -176,12 +176,12 @@ int sink_set_alignment_constants(struct sof_sink *sink, return 0; } -void sink_set_obs(struct sof_sink *sink, size_t obs) +void sink_set_min_free_space(struct sof_sink *sink, size_t min_free_space) { - sink->obs = obs; + sink->min_free_space = min_free_space; } -size_t sink_get_obs(struct sof_sink *sink) +size_t sink_get_min_free_space(struct sof_sink *sink) { - return sink->obs; + return sink->min_free_space; } diff --git a/src/audio/source_api_helper.c b/src/audio/source_api_helper.c index f71cf5bdc7e1..91eb026812a9 100644 --- a/src/audio/source_api_helper.c +++ b/src/audio/source_api_helper.c @@ -166,12 +166,12 @@ int source_set_alignment_constants(struct sof_source *source, return 0; } -void source_set_ibs(struct sof_source *source, size_t ibs) +void source_set_min_available(struct sof_source *source, size_t min_available) { - source->ibs = ibs; + source->min_available = min_available; } -size_t source_get_ibs(struct sof_source *source) +size_t source_get_min_available(struct sof_source *source) { - return source->ibs; + return source->min_available; } diff --git a/src/include/sof/audio/dp_queue.h b/src/include/sof/audio/dp_queue.h index 64409abed6cd..ed56ed3ceb0d 100644 --- a/src/include/sof/audio/dp_queue.h +++ b/src/include/sof/audio/dp_queue.h @@ -98,18 +98,16 @@ struct dp_queue { }; /** - * @param ibs input buffer size - * the size of data to be produced in 1 cycle - * the data producer declares here how much data it will produce in single cycle * - * @param obs output buffer size - * the size of data to be consumed in 1 cycle - * the data receiver declares here how much data it will consume in single cycle + * @param min_available minimum data available in queue required by the module using + * dp_queue's source api + * @param min_free_space minimum buffer space in queue required by the module using + * dp_queue's sink api * * @param flags a combinatin of DP_QUEUE_MODE_* flags determining working mode * */ -struct dp_queue *dp_queue_create(size_t ibs, size_t obs, uint32_t flags); +struct dp_queue *dp_queue_create(size_t min_available, size_t min_free_space, uint32_t flags); /** * @brief free dp queue memory diff --git a/src/include/sof/audio/module_adapter/module/generic.h b/src/include/sof/audio/module_adapter/module/generic.h index 2c9fd2d88afa..ce7a3d347806 100644 --- a/src/include/sof/audio/module_adapter/module/generic.h +++ b/src/include/sof/audio/module_adapter/module/generic.h @@ -267,8 +267,8 @@ bool module_is_ready_to_process(struct processing_module *mod, /* default action - the module is ready if there's enough data for processing and enough * space to store result. IBS/OBS as declared in init_instance */ - return (source_get_data_available(sources[0]) >= source_get_ibs(sources[0]) && - sink_get_free_size(sinks[0]) >= sink_get_obs(sinks[0])); + return (source_get_data_available(sources[0]) >= source_get_min_available(sources[0]) && + sink_get_free_size(sinks[0]) >= sink_get_min_free_space(sinks[0])); } int module_process_sink_src(struct processing_module *mod, diff --git a/src/include/sof/audio/sink_api.h b/src/include/sof/audio/sink_api.h index 83aeae514317..bb279166c167 100644 --- a/src/include/sof/audio/sink_api.h +++ b/src/include/sof/audio/sink_api.h @@ -129,8 +129,8 @@ int sink_set_rate(struct sof_sink *sink, unsigned int rate); int sink_set_channels(struct sof_sink *sink, unsigned int channels); int sink_set_overrun(struct sof_sink *sink, bool overrun_permitted); int sink_set_buffer_fmt(struct sof_sink *sink, uint32_t buffer_fmt); -void sink_set_obs(struct sof_sink *sink, size_t obs); -size_t sink_get_obs(struct sof_sink *sink); +void sink_set_min_free_space(struct sof_sink *sink, size_t min_free_space); +size_t sink_get_min_free_space(struct sof_sink *sink); /** * initial set of audio parameters, provided in sof_ipc_stream_params diff --git a/src/include/sof/audio/sink_api_implementation.h b/src/include/sof/audio/sink_api_implementation.h index 71c694d8a774..23cec8dbb30e 100644 --- a/src/include/sof/audio/sink_api_implementation.h +++ b/src/include/sof/audio/sink_api_implementation.h @@ -72,7 +72,9 @@ struct sof_sink { const struct sink_ops *ops; /** operations interface */ size_t requested_write_frag_size; /** keeps number of bytes requested by get_buffer() */ size_t num_of_bytes_processed; /** processed bytes counter */ - size_t obs; /** output buffer size as declared in module bind IPC */ + size_t min_free_space; /** minimum buffer space required by the module using sink + * it is module's OBS as declared in module bind IPC + */ struct sof_audio_stream_params *audio_stream_params; /** pointer to audio params */ }; diff --git a/src/include/sof/audio/source_api.h b/src/include/sof/audio/source_api.h index e4bd132a8ada..70b3ce38c909 100644 --- a/src/include/sof/audio/source_api.h +++ b/src/include/sof/audio/source_api.h @@ -140,8 +140,8 @@ int source_set_rate(struct sof_source *source, unsigned int rate); int source_set_channels(struct sof_source *source, unsigned int channels); int source_set_underrun(struct sof_source *source, bool underrun_permitted); int source_set_buffer_fmt(struct sof_source *source, uint32_t buffer_fmt); -void source_set_ibs(struct sof_source *source, size_t ibs); -size_t source_get_ibs(struct sof_source *source); +void source_set_min_available(struct sof_source *source, size_t min_available); +size_t source_get_min_available(struct sof_source *source); /** * initial set of audio parameters, provided in sof_ipc_stream_params diff --git a/src/include/sof/audio/source_api_implementation.h b/src/include/sof/audio/source_api_implementation.h index 5f2a9ffb4803..606141c92dfb 100644 --- a/src/include/sof/audio/source_api_implementation.h +++ b/src/include/sof/audio/source_api_implementation.h @@ -72,7 +72,11 @@ struct sof_source { const struct source_ops *ops; size_t requested_read_frag_size; /** keeps size of data obtained by get_data() */ size_t num_of_bytes_processed; /** processed bytes counter */ - size_t ibs; /** input buffer size as declared in module bind IPC */ + size_t min_available; /** minimum data available required by the module using + * source + * it is module's IBS as declared in module bind IPC + */ + struct sof_audio_stream_params *audio_stream_params; }; diff --git a/src/ipc/ipc4/helper.c b/src/ipc/ipc4/helper.c index d213a8f43fd5..73e9c6d1a787 100644 --- a/src/ipc/ipc4/helper.c +++ b/src/ipc/ipc4/helper.c @@ -376,13 +376,17 @@ int ipc_comp_connect(struct ipc *ipc, ipc_pipe_comp_connect *_connect) } /* - * set ibs and obs in sink/src api of created buffer - * IBS of a buffer is OBS of source component - * OBS of a buffer is IBS of destination component + * set min_free_space and min_available in sink/src api of created buffer. + * buffer is connected like: + * source_module -> (sink_ifc) BUFFER (source_ifc) -> sink_module + * + * source_module needs to set its OBS (out buffer size) + * as min_free_space in buffer's sink ifc + * sink_module needs to set its IBS (input buffer size) + * as min_available in buffer's source ifc */ - - source_set_ibs(audio_stream_get_source(&buffer->stream), source_src_cfg.obs); - sink_set_obs(audio_stream_get_sink(&buffer->stream), sink_src_cfg.ibs); + sink_set_min_free_space(audio_stream_get_sink(&buffer->stream), source_src_cfg.obs); + source_set_min_available(audio_stream_get_source(&buffer->stream), sink_src_cfg.ibs); /* * Connect and bind the buffer to both source and sink components with the interrupts