From 33fa026524847c0bc15aecea8340baf6492e7b07 Mon Sep 17 00:00:00 2001 From: Ranjani Sridharan Date: Thu, 22 Dec 2022 06:37:44 -0800 Subject: [PATCH] module_adapter: Add flags to skip source/sink buffer invalidate/writeback Some modules like the mixin/mixout do the invalidate/writebacks for the source/sink buffers themselves. So, add flags in struct processing_module to skip doing the same again in the module adapter code. Signed-off-by: Ranjani Sridharan --- src/audio/mixin_mixout/mixin_mixout.c | 2 ++ src/audio/module_adapter/module_adapter.c | 10 +++++++--- .../sof/audio/module_adapter/module/generic.h | 12 ++++++++++++ 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/src/audio/mixin_mixout/mixin_mixout.c b/src/audio/mixin_mixout/mixin_mixout.c index f7351192b..ff3578bd3 100644 --- a/src/audio/mixin_mixout/mixin_mixout.c +++ b/src/audio/mixin_mixout/mixin_mixout.c @@ -121,6 +121,7 @@ static int mixin_init(struct processing_module *mod) dev->ipc_config.frame_fmt = frame_fmt; mod->simple_copy = true; + mod->skip_src_buffer_invalidate = true; return 0; } @@ -149,6 +150,7 @@ static int mixout_init(struct processing_module *mod) dev->ipc_config.frame_fmt = frame_fmt; mod->simple_copy = true; + mod->skip_sink_buffer_writeback = true; return 0; } diff --git a/src/audio/module_adapter/module_adapter.c b/src/audio/module_adapter/module_adapter.c index f00466fd7..0cdeb8ef0 100644 --- a/src/audio/module_adapter/module_adapter.c +++ b/src/audio/module_adapter/module_adapter.c @@ -569,7 +569,8 @@ static void module_adapter_process_output(struct comp_dev *dev) sink = container_of(blist, struct comp_buffer, source_list); sink_c = buffer_acquire(sink); - buffer_stream_writeback(sink_c, mod->output_buffers[i].size); + if (!mod->skip_sink_buffer_writeback) + buffer_stream_writeback(sink_c, mod->output_buffers[i].size); comp_update_buffer_produce(sink_c, mod->output_buffers[i].size); buffer_release(sink_c); @@ -650,7 +651,8 @@ module_single_sink_setup(struct comp_dev *dev, comp_get_copy_limits_frame_aligned(source_c[i], sinks_c[0], &c); - buffer_stream_invalidate(source_c[i], c.frames * c.source_frame_bytes); + if (!mod->skip_src_buffer_invalidate) + buffer_stream_invalidate(source_c[i], c.frames * c.source_frame_bytes); /* * note that the size is in number of frames not the number of @@ -701,7 +703,9 @@ module_single_source_setup(struct comp_dev *dev, i++; } - buffer_stream_invalidate(source_c[0], min_frames * source_frame_bytes); + if (!mod->skip_src_buffer_invalidate) + buffer_stream_invalidate(source_c[0], min_frames * source_frame_bytes); + /* note that the size is in number of frames not the number of bytes */ mod->input_buffers[0].size = min_frames; mod->input_buffers[0].consumed = 0; diff --git a/src/include/sof/audio/module_adapter/module/generic.h b/src/include/sof/audio/module_adapter/module/generic.h index 32168b017..a12e7f857 100644 --- a/src/include/sof/audio/module_adapter/module/generic.h +++ b/src/include/sof/audio/module_adapter/module/generic.h @@ -195,6 +195,18 @@ struct processing_module { /* flag to indicate module does not pause */ bool no_pause; + /* + * flag to indicate that the sink buffer writeback should be skipped. It will be handled + * in the module's process callback + */ + bool skip_sink_buffer_writeback; + + /* + * flag to indicate that the source buffer invalidate should be skipped. It will be handled + * in the module's process callback + */ + bool skip_src_buffer_invalidate; + /* table containing the list of connected sources */ struct module_source_info *source_info; };