module_adapter: add get_total_process_data_process support

Get_total_process_data_process is used to get the processed data of
a module when stream is started. It is used to calculate pipeline
latency with the algorithm of subtracting processed data count between
source pipeline module and sink pipeline module. This patch will
calculate consumed & produced data count based on input & output buffer
setting and return produced data count for source module and consumed
data for sink module.

Currently only copier supports this function, now add it to
module_adapter framework to support other modules.

Signed-off-by: Rander Wang <rander.wang@intel.com>
This commit is contained in:
Rander Wang 2023-04-14 11:17:54 +08:00 committed by Liam Girdwood
parent b3d1583f3c
commit 98a3f67b10
2 changed files with 41 additions and 1 deletions

View File

@ -616,6 +616,8 @@ static void module_adapter_process_output(struct comp_dev *dev)
}
i++;
}
mod->total_data_produced += mod->output_buffers[0].size;
}
static uint32_t
@ -751,9 +753,15 @@ static int module_adapter_simple_copy(struct comp_dev *dev)
src_c = attr_container_of(mod->input_buffers[i].data,
struct comp_buffer __sparse_cache,
stream, __sparse_cache);
comp_update_buffer_consume(src_c, mod->input_buffers[i].consumed);
}
/* compute data consumed based on pin 0 since it is processed with base config
* which is set for pin 0
*/
mod->total_data_consumed += mod->input_buffers[0].consumed;
/* release all source buffers */
i = 0;
list_for_item(blist, &dev->bsource_list) {
@ -776,6 +784,8 @@ static int module_adapter_simple_copy(struct comp_dev *dev)
comp_update_buffer_produce(sink_c, mod->output_buffers[i].size);
}
mod->total_data_produced += mod->output_buffers[0].size;
/* release all sink buffers */
i = 0;
list_for_item(blist, &dev->bsink_list) {
@ -856,7 +866,6 @@ int module_adapter_copy(struct comp_dev *dev)
ca_copy_from_source_to_module(&src_c->stream, mod->input_buffers[i].data,
md->mpd.in_buff_size, bytes_to_process);
buffer_release(src_c);
i++;
}
@ -886,8 +895,12 @@ int module_adapter_copy(struct comp_dev *dev)
bzero((__sparse_force void *)mod->input_buffers[i].data, size);
mod->input_buffers[i].size = 0;
mod->input_buffers[i].consumed = 0;
i++;
}
mod->total_data_consumed += mod->input_buffers[0].consumed;
module_adapter_process_output(dev);
return 0;
@ -1125,6 +1138,9 @@ int module_adapter_reset(struct comp_dev *dev)
mod->num_input_buffers = 0;
mod->num_output_buffers = 0;
mod->total_data_consumed = 0;
mod->total_data_produced = 0;
list_for_item(blist, &mod->sink_buffer_list) {
struct comp_buffer *buffer = container_of(blist, struct comp_buffer,
sink_list);
@ -1329,6 +1345,17 @@ int module_adapter_unbind(struct comp_dev *dev, void *data)
return 0;
}
uint64_t module_adapter_get_total_data_processed(struct comp_dev *dev,
uint32_t stream_no, bool input)
{
struct processing_module *mod = comp_get_drvdata(dev);
if (input)
return mod->total_data_produced;
else
return mod->total_data_consumed;
}
#else
int module_adapter_get_attribute(struct comp_dev *dev, uint32_t type, void *value)
{
@ -1355,4 +1382,10 @@ int module_adapter_unbind(struct comp_dev *dev, void *data)
{
return 0;
}
uint64_t module_adapter_get_total_data_processed(struct comp_dev *dev,
uint32_t stream_no, bool input)
{
return 0;
}
#endif

View File

@ -59,6 +59,7 @@ static const struct comp_driver comp_##adapter##_module = { \
.get_attribute = module_adapter_get_attribute,\
.bind = module_adapter_bind,\
.unbind = module_adapter_unbind,\
.get_total_data_processed = module_adapter_get_total_data_processed,\
}, \
}; \
\
@ -209,6 +210,10 @@ struct processing_module {
/* table containing the list of connected sources */
struct module_source_info *source_info;
/* total processed data after stream started */
uint64_t total_data_consumed;
uint64_t total_data_produced;
};
/*****************************************************************************/
@ -248,6 +253,8 @@ int module_get_large_config(struct comp_dev *dev, uint32_t param_id, bool first_
int module_adapter_get_attribute(struct comp_dev *dev, uint32_t type, void *value);
int module_adapter_bind(struct comp_dev *dev, void *data);
int module_adapter_unbind(struct comp_dev *dev, void *data);
uint64_t module_adapter_get_total_data_processed(struct comp_dev *dev,
uint32_t stream_no, bool input);
static inline void module_update_buffer_position(struct input_stream_buffer *input_buffers,
struct output_stream_buffer *output_buffers,