From 5ca2499d5f4854f4a93a95464fe753545fb4c55a Mon Sep 17 00:00:00 2001 From: Adrian Warecki Date: Tue, 27 Oct 2026 16:19:41 +0100 Subject: [PATCH 1/2] test: cmocka: remove input_buffers and output_buffers usage Stop using the input_buffers and output_buffers members of struct processing_module in the cmocka tests. The dcblock, eq_fir and eq_iir tests keep the number of filled frames and produced bytes in their own test data structure. Remove the stream buffer descriptors, which were not more used by the converted modules. Signed-off-by: Adrian Warecki --- .../src/audio/dcblock/dcblock_process.c | 43 +++++-------------- test/cmocka/src/audio/eq_fir/eq_fir_process.c | 37 +++++----------- test/cmocka/src/audio/eq_iir/eq_iir_process.c | 34 +++++---------- test/cmocka/src/audio/module_adapter.h | 2 - test/cmocka/src/audio/module_adapter_test.c | 25 ++--------- test/cmocka/src/audio/mux/demux_copy.c | 3 -- test/cmocka/src/audio/mux/mux_copy.c | 3 -- test/cmocka/src/audio/volume/volume_process.c | 3 -- 8 files changed, 36 insertions(+), 114 deletions(-) diff --git a/test/cmocka/src/audio/dcblock/dcblock_process.c b/test/cmocka/src/audio/dcblock/dcblock_process.c index 96f971ba8379..53868fe17287 100644 --- a/test/cmocka/src/audio/dcblock/dcblock_process.c +++ b/test/cmocka/src/audio/dcblock/dcblock_process.c @@ -86,6 +86,8 @@ struct test_data { struct test_parameters *params; struct processing_module *mod; bool continue_loop; + size_t input_frames; + size_t output_bytes; }; static int setup_group(void **state) @@ -194,10 +196,6 @@ static void cleanup_test_data(struct test_data *td) if (td->dev) { mod = comp_mod(td->dev); if (mod) { - test_free(mod->input_buffers); - mod->input_buffers = NULL; - test_free(mod->output_buffers); - mod->output_buffers = NULL; test_free(mod->stream_params); mod->stream_params = NULL; } @@ -281,18 +279,6 @@ static int setup(void **state) prepare_sink(td, mod); prepare_source(td, mod); - mod->input_buffers = test_malloc(sizeof(struct input_stream_buffer)); - if (!mod->input_buffers) { - ret = -ENOMEM; - goto error; - } - mod->input_buffers[0].data = &td->source->stream; - mod->output_buffers = test_malloc(sizeof(struct output_stream_buffer)); - if (!mod->output_buffers) { - ret = -ENOMEM; - goto error; - } - mod->output_buffers[0].data = &td->sink->stream; mod->stream_params = test_malloc(sizeof(struct sof_ipc_stream_params)); if (!mod->stream_params) { ret = -ENOMEM; @@ -330,7 +316,6 @@ static int teardown(void **state) #if CONFIG_FORMAT_S16LE static void fill_source_s16(struct test_data *td, int frames_max) { - struct processing_module *mod = comp_mod(td->dev); struct comp_dev *dev = td->dev; struct comp_buffer *sb; struct audio_stream *ss; @@ -360,12 +345,11 @@ static void fill_source_s16(struct test_data *td, int frames_max) comp_update_buffer_produce(sb, bytes_total); } - mod->input_buffers[0].size = samples_processed / audio_stream_get_channels(ss); + td->input_frames = samples_processed / audio_stream_get_channels(ss); } static void verify_sink_s16(struct test_data *td) { - struct processing_module *mod = comp_mod(td->dev); struct comp_dev *dev = td->dev; struct comp_buffer *sb; struct audio_stream *ss; @@ -380,7 +364,7 @@ static void verify_sink_s16(struct test_data *td) sb = comp_dev_get_first_data_consumer(dev); ss = &sb->stream; - samples = mod->output_buffers[0].size >> 1; + samples = td->output_bytes >> 1; for (i = 0; i < samples; i++) { x = audio_stream_read_frag_s16(ss, i); out = *x; @@ -399,7 +383,6 @@ static void verify_sink_s16(struct test_data *td) #if CONFIG_FORMAT_S24LE static void fill_source_s24(struct test_data *td, int frames_max) { - struct processing_module *mod = comp_mod(td->dev); struct comp_dev *dev = td->dev; struct comp_buffer *sb; struct audio_stream *ss; @@ -429,12 +412,11 @@ static void fill_source_s24(struct test_data *td, int frames_max) comp_update_buffer_produce(sb, bytes_total); } - mod->input_buffers[0].size = samples_processed / audio_stream_get_channels(ss); + td->input_frames = samples_processed / audio_stream_get_channels(ss); } static void verify_sink_s24(struct test_data *td) { - struct processing_module *mod = comp_mod(td->dev); struct comp_dev *dev = td->dev; struct comp_buffer *sb; struct audio_stream *ss; @@ -449,7 +431,7 @@ static void verify_sink_s24(struct test_data *td) sb = comp_dev_get_first_data_consumer(dev); ss = &sb->stream; - samples = mod->output_buffers[0].size >> 2; + samples = td->output_bytes >> 2; for (i = 0; i < samples; i++) { x = audio_stream_read_frag_s32(ss, i); out = (*x << 8) >> 8; /* Make sure there's no 24 bit overflow */ @@ -468,7 +450,6 @@ static void verify_sink_s24(struct test_data *td) #if CONFIG_FORMAT_S32LE static void fill_source_s32(struct test_data *td, int frames_max) { - struct processing_module *mod = comp_mod(td->dev); struct comp_dev *dev = td->dev; struct comp_buffer *sb; struct audio_stream *ss; @@ -498,12 +479,11 @@ static void fill_source_s32(struct test_data *td, int frames_max) comp_update_buffer_produce(sb, bytes_total); } - mod->input_buffers[0].size = samples_processed / audio_stream_get_channels(ss); + td->input_frames = samples_processed / audio_stream_get_channels(ss); } static void verify_sink_s32(struct test_data *td) { - struct processing_module *mod = comp_mod(td->dev); struct comp_dev *dev = td->dev; struct comp_buffer *sb; struct audio_stream *ss; @@ -518,7 +498,7 @@ static void verify_sink_s32(struct test_data *td) sb = comp_dev_get_first_data_consumer(dev); ss = &sb->stream; - samples = mod->output_buffers[0].size >> 2; + samples = td->output_bytes >> 2; for (i = 0; i < samples; i++) { x = audio_stream_read_frag_s32(ss, i); out = *x; @@ -581,12 +561,11 @@ static void test_audio_dcblock(void **state) * updates the buffer read/write positions internally, so record * the sink fill level to know how many bytes were produced. */ - td->dev->frames = mod->input_buffers[0].size; + td->dev->frames = td->input_frames; avail_before = audio_stream_get_avail_bytes(&sink->stream); ret = module_process_sink_src(mod, sources, 1, sinks, 1); assert_int_equal(ret, 0); - mod->output_buffers[0].size = - audio_stream_get_avail_bytes(&sink->stream) - avail_before; + td->output_bytes = audio_stream_get_avail_bytes(&sink->stream) - avail_before; switch (audio_stream_get_frm_fmt(&sink->stream)) { case SOF_IPC_FRAME_S16_LE: @@ -603,7 +582,7 @@ static void test_audio_dcblock(void **state) break; } - comp_update_buffer_consume(sink, mod->output_buffers[0].size); + comp_update_buffer_consume(sink, td->output_bytes); } } diff --git a/test/cmocka/src/audio/eq_fir/eq_fir_process.c b/test/cmocka/src/audio/eq_fir/eq_fir_process.c index 0158b09dc29d..cd3183e2ca19 100644 --- a/test/cmocka/src/audio/eq_fir/eq_fir_process.c +++ b/test/cmocka/src/audio/eq_fir/eq_fir_process.c @@ -64,6 +64,8 @@ struct test_data { struct test_parameters *params; struct processing_module *mod; bool continue_loop; + size_t input_frames; + size_t output_bytes; }; static int setup_group(void **state) @@ -214,11 +216,6 @@ static int setup(void **state) prepare_sink(td, mod); prepare_source(td, mod); - /* allocate intermediate buffers */ - mod->input_buffers = test_malloc(sizeof(struct input_stream_buffer)); - mod->input_buffers[0].data = &td->source->stream; - mod->output_buffers = test_malloc(sizeof(struct output_stream_buffer)); - mod->output_buffers[0].data = &td->sink->stream; mod->stream_params = test_malloc(sizeof(struct sof_ipc_stream_params)); mod->stream_params->channels = params->channels; mod->period_bytes = get_frame_bytes(params->source_format, params->channels) * 48000 / 1000; @@ -240,8 +237,6 @@ static int teardown(void **state) struct test_data *td = *state; struct processing_module *mod = comp_mod(td->dev); - test_free(mod->input_buffers); - test_free(mod->output_buffers); test_free(mod->stream_params); mod->stream_params = NULL; test_free(td->params); @@ -255,7 +250,6 @@ static int teardown(void **state) #if CONFIG_FORMAT_S16LE static void fill_source_s16(struct test_data *td, size_t frames_max) { - struct processing_module *mod = comp_mod(td->dev); struct comp_dev *dev = td->dev; struct comp_buffer *sb; struct audio_stream *ss; @@ -285,12 +279,11 @@ static void fill_source_s16(struct test_data *td, size_t frames_max) comp_update_buffer_produce(sb, bytes_total); } - mod->input_buffers[0].size = samples_processed / audio_stream_get_channels(ss); + td->input_frames = samples_processed / audio_stream_get_channels(ss); } static void verify_sink_s16(struct test_data *td) { - struct processing_module *mod = comp_mod(td->dev); struct comp_dev *dev = td->dev; struct comp_buffer *sb; struct audio_stream *ss; @@ -303,7 +296,7 @@ static void verify_sink_s16(struct test_data *td) sb = comp_dev_get_first_data_consumer(dev); ss = &sb->stream; - samples = mod->output_buffers[0].size >> 1; + samples = td->output_bytes >> 1; for (i = 0; i < samples; i++) { x = audio_stream_read_frag_s16(ss, i); out = *x; @@ -321,7 +314,6 @@ static void verify_sink_s16(struct test_data *td) #if CONFIG_FORMAT_S24LE static void fill_source_s24(struct test_data *td, size_t frames_max) { - struct processing_module *mod = comp_mod(td->dev); struct comp_dev *dev = td->dev; struct comp_buffer *sb; struct audio_stream *ss; @@ -351,12 +343,11 @@ static void fill_source_s24(struct test_data *td, size_t frames_max) comp_update_buffer_produce(sb, bytes_total); } - mod->input_buffers[0].size = samples_processed / audio_stream_get_channels(ss); + td->input_frames = samples_processed / audio_stream_get_channels(ss); } static void verify_sink_s24(struct test_data *td) { - struct processing_module *mod = comp_mod(td->dev); struct comp_dev *dev = td->dev; struct comp_buffer *sb; struct audio_stream *ss; @@ -369,7 +360,7 @@ static void verify_sink_s24(struct test_data *td) sb = comp_dev_get_first_data_consumer(dev); ss = &sb->stream; - samples = mod->output_buffers[0].size >> 2; + samples = td->output_bytes >> 2; for (i = 0; i < samples; i++) { x = audio_stream_read_frag_s32(ss, i); out = (*x << 8) >> 8; /* Make sure there's no 24 bit overflow */ @@ -387,7 +378,6 @@ static void verify_sink_s24(struct test_data *td) #if CONFIG_FORMAT_S32LE static void fill_source_s32(struct test_data *td, size_t frames_max) { - struct processing_module *mod = comp_mod(td->dev); struct comp_dev *dev = td->dev; struct comp_buffer *sb; struct audio_stream *ss; @@ -417,12 +407,11 @@ static void fill_source_s32(struct test_data *td, size_t frames_max) comp_update_buffer_produce(sb, bytes_total); } - mod->input_buffers[0].size = samples_processed / audio_stream_get_channels(ss); + td->input_frames = samples_processed / audio_stream_get_channels(ss); } static void verify_sink_s32(struct test_data *td) { - struct processing_module *mod = comp_mod(td->dev); struct comp_dev *dev = td->dev; struct comp_buffer *sb; struct audio_stream *ss; @@ -435,7 +424,7 @@ static void verify_sink_s32(struct test_data *td) sb = comp_dev_get_first_data_consumer(dev); ss = &sb->stream; - samples = mod->output_buffers[0].size >> 2; + samples = td->output_bytes >> 2; for (i = 0; i < samples; i++) { x = audio_stream_read_frag_s32(ss, i); out = *x; @@ -491,7 +480,6 @@ static void test_eq_fir_rounds_down_odd_frame_count(void **state) fill_source_for_test(td, 3); source_avail_before = audio_stream_get_avail_bytes(&td->source->stream); sink_avail_before = audio_stream_get_avail_bytes(&td->sink->stream); - mod->output_buffers[0].size = 0; ret = module_process_sink_src(mod, sources, 1, sinks, 1); assert_int_equal(ret, 0); @@ -662,15 +650,12 @@ static void test_audio_eq_fir(void **state) break; } - mod->output_buffers[0].size = 0; - - td->dev->frames = mod->input_buffers[0].size; + td->dev->frames = td->input_frames; avail_before = audio_stream_get_avail_bytes(&sink->stream); ret = module_process_sink_src(mod, sources, 1, sinks, 1); assert_int_equal(ret, 0); - mod->output_buffers[0].size = audio_stream_get_avail_bytes(&sink->stream) - - avail_before; + td->output_bytes = audio_stream_get_avail_bytes(&sink->stream) - avail_before; switch (audio_stream_get_frm_fmt(&sink->stream)) { case SOF_IPC_FRAME_S16_LE: @@ -687,7 +672,7 @@ static void test_audio_eq_fir(void **state) break; } - comp_update_buffer_consume(sink, mod->output_buffers[0].size); + comp_update_buffer_consume(sink, td->output_bytes); } } diff --git a/test/cmocka/src/audio/eq_iir/eq_iir_process.c b/test/cmocka/src/audio/eq_iir/eq_iir_process.c index 50f6aefe484d..6c527c84404d 100644 --- a/test/cmocka/src/audio/eq_iir/eq_iir_process.c +++ b/test/cmocka/src/audio/eq_iir/eq_iir_process.c @@ -62,6 +62,8 @@ struct test_data { struct test_parameters *params; struct processing_module *mod; bool continue_loop; + size_t input_frames; + size_t output_bytes; }; static int setup_group(void **state) @@ -195,11 +197,6 @@ static int setup(void **state) prepare_sink(td, mod); prepare_source(td, mod); - /* allocate intermediate buffers */ - mod->input_buffers = test_malloc(sizeof(struct input_stream_buffer)); - mod->input_buffers[0].data = &td->source->stream; - mod->output_buffers = test_malloc(sizeof(struct output_stream_buffer)); - mod->output_buffers[0].data = &td->sink->stream; mod->stream_params = test_malloc(sizeof(struct sof_ipc_stream_params)); mod->stream_params->channels = params->channels; mod->period_bytes = get_frame_bytes(params->source_format, params->channels) * 48000 / 1000; @@ -221,8 +218,6 @@ static int teardown(void **state) struct test_data *td = *state; struct processing_module *mod = comp_mod(td->dev); - test_free(mod->input_buffers); - test_free(mod->output_buffers); test_free(mod->stream_params); mod->stream_params = NULL; test_free(td->params); @@ -236,7 +231,6 @@ static int teardown(void **state) #if CONFIG_FORMAT_S16LE static void fill_source_s16(struct test_data *td, int frames_max) { - struct processing_module *mod = comp_mod(td->dev); struct comp_dev *dev = td->dev; struct comp_buffer *sb; struct audio_stream *ss; @@ -266,12 +260,11 @@ static void fill_source_s16(struct test_data *td, int frames_max) comp_update_buffer_produce(sb, bytes_total); } - mod->input_buffers[0].size = samples_processed / audio_stream_get_channels(ss); + td->input_frames = samples_processed / audio_stream_get_channels(ss); } static void verify_sink_s16(struct test_data *td) { - struct processing_module *mod = comp_mod(td->dev); struct comp_dev *dev = td->dev; struct comp_buffer *sb; struct audio_stream *ss; @@ -284,7 +277,7 @@ static void verify_sink_s16(struct test_data *td) sb = comp_dev_get_first_data_consumer(dev); ss = &sb->stream; - samples = mod->output_buffers[0].size >> 1; + samples = td->output_bytes >> 1; for (i = 0; i < samples; i++) { x = audio_stream_read_frag_s16(ss, i); out = *x; @@ -299,7 +292,6 @@ static void verify_sink_s16(struct test_data *td) #if CONFIG_FORMAT_S24LE static void fill_source_s24(struct test_data *td, int frames_max) { - struct processing_module *mod = comp_mod(td->dev); struct comp_dev *dev = td->dev; struct comp_buffer *sb; struct audio_stream *ss; @@ -329,12 +321,11 @@ static void fill_source_s24(struct test_data *td, int frames_max) comp_update_buffer_produce(sb, bytes_total); } - mod->input_buffers[0].size = samples_processed / audio_stream_get_channels(ss); + td->input_frames = samples_processed / audio_stream_get_channels(ss); } static void verify_sink_s24(struct test_data *td) { - struct processing_module *mod = comp_mod(td->dev); struct comp_dev *dev = td->dev; struct comp_buffer *sb; struct audio_stream *ss; @@ -347,7 +338,7 @@ static void verify_sink_s24(struct test_data *td) sb = comp_dev_get_first_data_consumer(dev); ss = &sb->stream; - samples = mod->output_buffers[0].size >> 2; + samples = td->output_bytes >> 2; for (i = 0; i < samples; i++) { x = audio_stream_read_frag_s32(ss, i); out = (*x << 8) >> 8; /* Make sure there's no 24 bit overflow */ @@ -362,7 +353,6 @@ static void verify_sink_s24(struct test_data *td) #if CONFIG_FORMAT_S32LE static void fill_source_s32(struct test_data *td, int frames_max) { - struct processing_module *mod = comp_mod(td->dev); struct comp_dev *dev = td->dev; struct comp_buffer *sb; struct audio_stream *ss; @@ -392,12 +382,11 @@ static void fill_source_s32(struct test_data *td, int frames_max) comp_update_buffer_produce(sb, bytes_total); } - mod->input_buffers[0].size = samples_processed / audio_stream_get_channels(ss); + td->input_frames = samples_processed / audio_stream_get_channels(ss); } static void verify_sink_s32(struct test_data *td) { - struct processing_module *mod = comp_mod(td->dev); struct comp_dev *dev = td->dev; struct comp_buffer *sb; struct audio_stream *ss; @@ -410,7 +399,7 @@ static void verify_sink_s32(struct test_data *td) sb = comp_dev_get_first_data_consumer(dev); ss = &sb->stream; - samples = mod->output_buffers[0].size >> 2; + samples = td->output_bytes >> 2; for (i = 0; i < samples; i++) { x = audio_stream_read_frag_s32(ss, i); out = *x; @@ -469,14 +458,11 @@ static void test_audio_eq_iir(void **state) break; } - mod->input_buffers[0].consumed = 0; - mod->output_buffers[0].size = 0; sink_avail_before = audio_stream_get_avail_bytes(&sink->stream); ret = module_process_sink_src(mod, sources, 1, sinks, 1); assert_int_equal(ret, 0); - mod->output_buffers[0].size = audio_stream_get_avail_bytes(&sink->stream) - - sink_avail_before; + td->output_bytes = audio_stream_get_avail_bytes(&sink->stream) - sink_avail_before; switch (audio_stream_get_frm_fmt(&sink->stream)) { case SOF_IPC_FRAME_S16_LE: @@ -493,7 +479,7 @@ static void test_audio_eq_iir(void **state) break; } - comp_update_buffer_consume(sink, mod->output_buffers[0].size); + comp_update_buffer_consume(sink, td->output_bytes); } } diff --git a/test/cmocka/src/audio/module_adapter.h b/test/cmocka/src/audio/module_adapter.h index 1f913fa5cbcd..deb8c49ba8e7 100644 --- a/test/cmocka/src/audio/module_adapter.h +++ b/test/cmocka/src/audio/module_adapter.h @@ -17,8 +17,6 @@ struct processing_module_test_data { struct processing_module *mod; struct comp_buffer **sinks; struct comp_buffer **sources; - struct input_stream_buffer **input_buffers; - struct output_stream_buffer **output_buffers; uint32_t num_sources; uint32_t num_sinks; struct processing_module_test_parameters parameters; diff --git a/test/cmocka/src/audio/module_adapter_test.c b/test/cmocka/src/audio/module_adapter_test.c index 81ec6cadc1b7..798c3545f97f 100644 --- a/test/cmocka/src/audio/module_adapter_test.c +++ b/test/cmocka/src/audio/module_adapter_test.c @@ -33,11 +33,6 @@ int module_adapter_test_setup(struct processing_module_test_data *test_data) test_data->sinks = test_calloc(test_data->num_sinks, sizeof(struct comp_buffer *)); test_data->sources = test_calloc(test_data->num_sources, sizeof(struct comp_buffer *)); - test_data->input_buffers = test_calloc(test_data->num_sources, - sizeof(struct input_stream_buffer *)); - test_data->output_buffers = test_calloc(test_data->num_sinks, - sizeof(struct output_stream_buffer *)); - list_init(&dev->bsource_list); list_init(&dev->bsink_list); @@ -45,22 +40,16 @@ int module_adapter_test_setup(struct processing_module_test_data *test_data) size = parameters->frames * get_frame_bytes(parameters->sink_format, parameters->channels) * parameters->buffer_size_ms; - for (i = 0; i < test_data->num_sinks; i++) { + for (i = 0; i < test_data->num_sinks; i++) test_data->sinks[i] = create_test_sink(dev, 0, parameters->sink_format, parameters->channels, size); - test_data->output_buffers[i] = test_malloc(sizeof(struct output_stream_buffer)); - test_data->output_buffers[i]->data = &test_data->sinks[i]->stream; - } /* allocate source buffers */ size = parameters->frames * get_frame_bytes(parameters->source_format, parameters->channels) * parameters->buffer_size_ms; - for (i = 0; i < test_data->num_sources; i++) { + for (i = 0; i < test_data->num_sources; i++) test_data->sources[i] = create_test_source(dev, 0, parameters->source_format, parameters->channels, size); - test_data->input_buffers[i] = test_malloc(sizeof(struct input_stream_buffer)); - test_data->input_buffers[i]->data = &test_data->sources[i]->stream; - } test_data->verify = parameters->verify; @@ -71,18 +60,12 @@ void module_adapter_test_free(struct processing_module_test_data *test_data) { int i; - for (i = 0; i < test_data->num_sinks; i++) { + for (i = 0; i < test_data->num_sinks; i++) free_test_sink(test_data->sinks[i]); - test_free(test_data->output_buffers[i]); - } - for (i = 0; i < test_data->num_sources; i++) { + for (i = 0; i < test_data->num_sources; i++) free_test_source(test_data->sources[i]); - test_free(test_data->input_buffers[i]); - } - test_free(test_data->input_buffers); - test_free(test_data->output_buffers); test_free(test_data->sinks); test_free(test_data->sources); test_free(test_data->mod->dev); diff --git a/test/cmocka/src/audio/mux/demux_copy.c b/test/cmocka/src/audio/mux/demux_copy.c index 542fdf8732f5..270f9f61dd04 100644 --- a/test/cmocka/src/audio/mux/demux_copy.c +++ b/test/cmocka/src/audio/mux/demux_copy.c @@ -188,9 +188,6 @@ static int teardown_test_case(void **state) struct test_data *td = *((struct test_data **)state); int i; - rfree(td->mod->input_buffers); - rfree(td->mod->output_buffers); - free_test_source(td->source); for (i = 0; i < MUX_MAX_STREAMS; ++i) diff --git a/test/cmocka/src/audio/mux/mux_copy.c b/test/cmocka/src/audio/mux/mux_copy.c index 99a442d84d88..df9d00252d15 100644 --- a/test/cmocka/src/audio/mux/mux_copy.c +++ b/test/cmocka/src/audio/mux/mux_copy.c @@ -211,9 +211,6 @@ static int teardown_test_case(void **state) struct test_data *td = *((struct test_data **)state); int i; - rfree(td->mod->input_buffers); - rfree(td->mod->output_buffers); - for (i = 0; i < MUX_MAX_STREAMS; ++i) free_test_source(td->sources[i]); diff --git a/test/cmocka/src/audio/volume/volume_process.c b/test/cmocka/src/audio/volume/volume_process.c index b6c1fec45e45..267277692d2d 100644 --- a/test/cmocka/src/audio/volume/volume_process.c +++ b/test/cmocka/src/audio/volume/volume_process.c @@ -291,9 +291,6 @@ static void test_audio_vol(void **state) break; } - vol_state->input_buffers[0]->consumed = 0; - vol_state->output_buffers[0]->size = 0; - source_buf.buf_start = audio_stream_get_addr(&vol_state->sources[0]->stream); source_buf.buf_end = audio_stream_get_end_addr(&vol_state->sources[0]->stream); source_buf.ptr = audio_stream_get_rptr(&vol_state->sources[0]->stream); From 559426af7f18e377b1590adb63544df3356ddee9 Mon Sep 17 00:00:00 2001 From: Adrian Warecki Date: Tue, 27 Oct 2026 17:10:11 +0100 Subject: [PATCH 2/2] audio: module_adapter: remove process_audio_stream callback Remove the legacy audio_stream processing path in module_adapter. Drop the process_audio_stream callback from struct module_interface together with struct input_stream_buffer and struct output_stream_buffer. Remove the processing type selection proc_type. The sink/source process() callback is now the only supported one. Delete the fields of struct processing_module that served only the removed path. The cache maintenance flags are not needed with the sink/source API because source_get_data() and sink_commit_buffer() operate on the requested range only, and cache operations are performed solely for buffers shared between cores. The IPC4 bind and unbind handlers keep refreshing the sources and sinks arrays used by prepare. Bump SOF_MODULE_API_CURRENT_VERSION to 5.0.3 since the layout of the structures changed. Modules built against the previous version are rejected by the loaders. All modules were converted to process() earlier, so the removed code was no longer reachable. Signed-off-by: Adrian Warecki --- src/audio/asrc/asrc.c | 2 - src/audio/mixin_mixout/mixin_mixout.c | 4 - src/audio/module_adapter/README.md | 2 +- src/audio/module_adapter/module/README.md | 2 +- src/audio/module_adapter/module/generic.c | 59 +-- src/audio/module_adapter/module/modules.c | 1 - src/audio/module_adapter/module_adapter.c | 376 +----------------- .../module_adapter/module_adapter_ipc3.c | 14 - .../module_adapter/module_adapter_ipc4.c | 20 +- src/include/module/module/api_ver.h | 2 +- src/include/module/module/base.h | 37 +- src/include/module/module/interface.h | 49 +-- .../sof/audio/module_adapter/module/generic.h | 38 -- 13 files changed, 15 insertions(+), 591 deletions(-) diff --git a/src/audio/asrc/asrc.c b/src/audio/asrc/asrc.c index 95f119f8716e..a62e968d3360 100644 --- a/src/audio/asrc/asrc.c +++ b/src/audio/asrc/asrc.c @@ -221,8 +221,6 @@ static int asrc_init(struct processing_module *mod) */ cd->track_drift = asrc_get_asynchronous_mode(ipc_asrc); cd->skew = 0; - mod->skip_src_buffer_invalidate = true; - mod->skip_sink_buffer_writeback = true; return 0; } diff --git a/src/audio/mixin_mixout/mixin_mixout.c b/src/audio/mixin_mixout/mixin_mixout.c index bd957e617f10..8209d992b1f7 100644 --- a/src/audio/mixin_mixout/mixin_mixout.c +++ b/src/audio/mixin_mixout/mixin_mixout.c @@ -150,8 +150,6 @@ static int mixin_init(struct processing_module *mod) md->sink_config[i].gain = IPC4_MIXIN_UNITY_GAIN; } - mod->skip_src_buffer_invalidate = true; - mod->max_sinks = MIXIN_MAX_SINKS; return 0; } @@ -169,8 +167,6 @@ static int mixout_init(struct processing_module *mod) mod->priv.private = mo_data; - mod->skip_sink_buffer_writeback = true; - mod->max_sources = MIXOUT_MAX_SOURCES; return 0; } diff --git a/src/audio/module_adapter/README.md b/src/audio/module_adapter/README.md index 416ee73628b8..9a58bbf956fc 100644 --- a/src/audio/module_adapter/README.md +++ b/src/audio/module_adapter/README.md @@ -81,7 +81,7 @@ To unify components operating directly in interrupt boundaries (DMA Low Latency For LL modules, processing is fully synchronous within the pipeline tick: 1. `comp_copy()` invokes `module_adapter_copy()`. -2. Data is fetched directly into `module_process_legacy()` or `module_process_sink_src()`. +2. Data is fetched directly into `module_process_sink_src()`. 3. `ops->process()` consumes upstream arrays and produces downstream arrays. ### Data Processing (DP) Execution diff --git a/src/audio/module_adapter/module/README.md b/src/audio/module_adapter/module/README.md index 2cb64db5ce01..8076ac9885c2 100644 --- a/src/audio/module_adapter/module/README.md +++ b/src/audio/module_adapter/module/README.md @@ -16,7 +16,7 @@ It implements the full `struct module_interface` contract: * **Memory Management**: It intercepts memory allocation mappings using `mod_balloc_align` and tracks memory requests in a module-specific resource pool (`module_resource`). When the module goes out of scope, the framework garbage-collects any leaked allocations automatically via `mod_free_all()`. * **Configuration Handling**: Manages large blob configuration messages across multiple IPC fragments (`module_set_configuration`). It allocates memory for `runtime_params` until the blob is fully assembled, then triggers the underlying algorithm with the completed struct. -* **State Machine Enforcement**: It wraps `process_audio_stream` calls to verify the module is in either `MODULE_IDLE` or `MODULE_PROCESSING` states before execution. +* **State Machine Enforcement**: It wraps `process` calls to verify the module is in either `MODULE_IDLE` or `MODULE_PROCESSING` states before execution. ## 2. Modules (IADK Shim) Adapter (`modules.c`) diff --git a/src/audio/module_adapter/module/generic.c b/src/audio/module_adapter/module/generic.c index c53102c0f906..058577dd844e 100644 --- a/src/audio/module_adapter/module/generic.c +++ b/src/audio/module_adapter/module/generic.c @@ -115,9 +115,8 @@ int module_init(struct processing_module *mod) return -EIO; } - /* check interface, there must be one and only one of processing procedure */ - if (!interface->init || - (!!interface->process + !!interface->process_audio_stream < 1)) { + /* check interface, there must be a processing procedure */ + if (!interface->init || !interface->process) { comp_err(dev, "comp is missing mandatory interfaces"); return -EIO; } @@ -675,48 +674,6 @@ int module_prepare(struct processing_module *mod, return 0; } -int module_process_legacy(struct processing_module *mod, - struct input_stream_buffer *input_buffers, int num_input_buffers, - struct output_stream_buffer *output_buffers, - int num_output_buffers) -{ - struct comp_dev *dev = mod->dev; - const struct module_interface *const ops = dev->drv->adapter_ops; - int ret; - - comp_dbg(dev, "entry"); - -#if CONFIG_IPC_MAJOR_3 - struct module_data *md = &mod->priv; - - if (md->state != MODULE_IDLE) { - comp_err(dev, "wrong state %d", md->state); - return -EPERM; - } - - /* set state to processing */ - md->state = MODULE_PROCESSING; -#endif - if (IS_PROCESSING_MODE_AUDIO_STREAM(mod)) - ret = ops->process_audio_stream(mod, input_buffers, num_input_buffers, - output_buffers, num_output_buffers); - else - ret = -EOPNOTSUPP; - - if (ret && ret != -ENOSPC && ret != -ENODATA) { - comp_err(dev, "error %d", ret); - return ret; - } - - comp_dbg(dev, "done"); - -#if CONFIG_IPC_MAJOR_3 - /* reset state to idle */ - md->state = MODULE_IDLE; -#endif - return 0; -} - int module_process_sink_src(struct processing_module *mod, struct sof_source **sources, int num_of_sources, struct sof_sink **sinks, int num_of_sinks) @@ -1050,18 +1007,6 @@ int module_unbind(struct processing_module *mod, const struct bind_info *unbind_ return ret; } -void module_update_buffer_position(struct input_stream_buffer *input_buffers, - struct output_stream_buffer *output_buffers, - uint32_t frames) -{ - struct audio_stream *source = input_buffers->data; - struct audio_stream *sink = output_buffers->data; - - input_buffers->consumed += audio_stream_frame_bytes(source) * frames; - output_buffers->size += audio_stream_frame_bytes(sink) * frames; -} -EXPORT_SYMBOL(module_update_buffer_position); - uint32_t module_get_deadline(struct processing_module *mod) { uint32_t deadline; diff --git a/src/audio/module_adapter/module/modules.c b/src/audio/module_adapter/module/modules.c index 589a25e33887..be400a922e3c 100644 --- a/src/audio/module_adapter/module/modules.c +++ b/src/audio/module_adapter/module/modules.c @@ -63,7 +63,6 @@ static int modules_init(struct processing_module *mod) md->mpd.in_buff_size = src_cfg->ibs; md->mpd.out_buff_size = src_cfg->obs; - mod->proc_type = MODULE_PROCESS_TYPE_SOURCE_SINK; return iadk_wrapper_init(module_get_private_data(mod)); } diff --git a/src/audio/module_adapter/module_adapter.c b/src/audio/module_adapter/module_adapter.c index 2735f6763e97..343c57b464b6 100644 --- a/src/audio/module_adapter/module_adapter.c +++ b/src/audio/module_adapter/module_adapter.c @@ -341,19 +341,10 @@ struct comp_dev *module_adapter_new_ext(const struct comp_driver *drv, mod->max_sources = 1; mod->max_sinks = 1; - /* The order of preference */ - if (interface->process) - mod->proc_type = MODULE_PROCESS_TYPE_SOURCE_SINK; - else if (interface->process_audio_stream) - mod->proc_type = MODULE_PROCESS_TYPE_STREAM; - else - goto err; - /* Init processing module */ ret = module_init(mod); if (ret) { - comp_err(dev, "%d: module initialization failed", - ret); + comp_err(dev, "%d: module initialization failed", ret); goto err; } @@ -456,8 +447,6 @@ int module_adapter_prepare(struct comp_dev *dev) int ret; struct processing_module *mod = comp_mod(dev); struct comp_buffer *sink; - struct list_item *blist; - int memory_flags; comp_dbg(dev, "start"); #if CONFIG_IPC_MAJOR_4 @@ -473,16 +462,7 @@ int module_adapter_prepare(struct comp_dev *dev) } #endif /* Prepare module */ - if (IS_PROCESSING_MODE_SINK_SOURCE(mod)) - ret = module_adapter_sink_src_prepare(dev); - - else if (IS_PROCESSING_MODE_AUDIO_STREAM(mod) && - mod->dev->ipc_config.proc_domain == COMP_PROCESSING_DOMAIN_LL) - ret = module_prepare(mod, NULL, 0, NULL, 0); - - else - ret = -EINVAL; - + ret = module_adapter_sink_src_prepare(dev); if (ret) { if (ret != PPL_STATUS_PATH_STOP) comp_err(dev, "error %d: module prepare failed", ret); @@ -540,10 +520,6 @@ int module_adapter_prepare(struct comp_dev *dev) * Hence check for NULL. */ sink = comp_dev_get_first_data_consumer(dev); - if (!sink && !IS_PROCESSING_MODE_SINK_SOURCE(mod)) { - comp_err(dev, "no sink present on period size calculation"); - return -EINVAL; - } /* A sinkless module still needs at least one source. */ if (!sink && !comp_dev_get_first_data_producer(dev)) { @@ -554,87 +530,7 @@ int module_adapter_prepare(struct comp_dev *dev) mod->period_bytes = sink ? audio_stream_period_bytes(&sink->stream, dev->frames) : 0; comp_dbg(dev, "got period_bytes = %u", mod->period_bytes); - /* no more to do for sink/source mode */ - if (IS_PROCESSING_MODE_SINK_SOURCE(mod)) - return 0; - - /* compute number of input buffers */ - mod->num_of_sources = 0; - list_for_item(blist, &dev->bsource_list) - mod->num_of_sources++; - - /* compute number of output buffers */ - mod->num_of_sinks = 0; - list_for_item(blist, &dev->bsink_list) - mod->num_of_sinks++; - - if (!mod->num_of_sources && !mod->num_of_sinks) { - comp_err(dev, "no source and sink buffers connected!"); - return -EINVAL; - } - if (mod->num_of_sources > CONFIG_MODULE_MAX_CONNECTIONS || - mod->num_of_sinks > CONFIG_MODULE_MAX_CONNECTIONS) { - comp_err(dev, "too many connected sinks %d or sources %d!", - mod->num_of_sinks, mod->num_of_sources); - return -EINVAL; - } - - if (mod->num_of_sources > mod->max_sources || - mod->num_of_sinks > mod->max_sinks) { - comp_err(dev, "connected sources %d (max %d) or sinks %d (max %d) exceed module capacity", - mod->num_of_sources, mod->max_sources, - mod->num_of_sinks, mod->max_sinks); - return -EINVAL; - } - - /* check processing mode */ - if (IS_PROCESSING_MODE_AUDIO_STREAM(mod) && mod->max_sources > 1 && mod->max_sinks > 1) { - comp_err(dev, "Invalid use of simple_copy"); - return -EINVAL; - } - - module_adapter_check_data(mod, dev, sink); - - memory_flags = user_get_buffer_memory_region(dev->drv); - /* allocate memory for input buffers */ - if (mod->max_sources) { - mod->input_buffers = - sof_heap_alloc(sof_sys_user_heap_get(), memory_flags, - sizeof(*mod->input_buffers) * mod->max_sources, 0); - if (!mod->input_buffers) { - comp_err(dev, "failed to allocate input buffers"); - return -ENOMEM; - } - memset(mod->input_buffers, 0, sizeof(*mod->input_buffers) * mod->max_sources); - } else { - mod->input_buffers = NULL; - } - - /* allocate memory for output buffers */ - if (mod->max_sinks) { - mod->output_buffers = - sof_heap_alloc(sof_sys_user_heap_get(), memory_flags, - sizeof(*mod->output_buffers) * mod->max_sinks, 0); - if (!mod->output_buffers) { - comp_err(dev, "failed to allocate output buffers"); - ret = -ENOMEM; - goto in_out_free; - } - memset(mod->output_buffers, 0, sizeof(*mod->output_buffers) * mod->max_sinks); - } else { - mod->output_buffers = NULL; - } - - comp_dbg(dev, "done"); - return 0; - -in_out_free: - sof_heap_free(sof_sys_user_heap_get(), mod->output_buffers); - mod->output_buffers = NULL; - sof_heap_free(sof_sys_user_heap_get(), mod->input_buffers); - mod->input_buffers = NULL; - return ret; } int module_adapter_params(struct comp_dev *dev, struct sof_ipc_stream_params *params) @@ -676,251 +572,6 @@ int module_adapter_params(struct comp_dev *dev, struct sof_ipc_stream_params *pa return 0; } -static uint32_t module_single_sink_setup(struct comp_dev *dev, - struct comp_buffer **source, - struct comp_buffer **sinks) -{ - struct processing_module *mod = comp_mod(dev); - struct list_item *blist; - uint32_t num_input_buffers; - uint32_t frames; - int i = 0; - - list_for_item(blist, &dev->bsource_list) { - frames = audio_stream_avail_frames_aligned(&source[i]->stream, - &sinks[0]->stream); - - if (!mod->skip_src_buffer_invalidate) { - uint32_t source_frame_bytes; - - source_frame_bytes = audio_stream_frame_bytes(&source[i]->stream); - buffer_stream_invalidate(source[i], frames * source_frame_bytes); - } - - /* - * note that the size is in number of frames not the number of - * bytes - */ - mod->input_buffers[i].size = frames; - mod->input_buffers[i].consumed = 0; - - mod->input_buffers[i].data = &source[i]->stream; - i++; - } - - num_input_buffers = i; - - mod->output_buffers[0].size = 0; - mod->output_buffers[0].data = &sinks[0]->stream; - - return num_input_buffers; -} - -static uint32_t module_single_source_setup(struct comp_dev *dev, - struct comp_buffer **source, - struct comp_buffer **sinks) -{ - struct processing_module *mod = comp_mod(dev); - struct list_item *blist; - uint32_t min_frames = UINT32_MAX; - uint32_t num_output_buffers; - uint32_t source_frame_bytes; - int i = 0; - - source_frame_bytes = audio_stream_frame_bytes(&source[0]->stream); - if (list_is_empty(&dev->bsink_list)) { - min_frames = audio_stream_get_avail_frames(&source[0]->stream); - } else { - uint32_t frames; - - list_for_item(blist, &dev->bsink_list) { - frames = audio_stream_avail_frames_aligned(&source[0]->stream, - &sinks[i]->stream); - - min_frames = MIN(min_frames, frames); - - mod->output_buffers[i].size = 0; - mod->output_buffers[i].data = &sinks[i]->stream; - i++; - } - } - - num_output_buffers = i; - - if (!mod->skip_src_buffer_invalidate) - buffer_stream_invalidate(source[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; - mod->input_buffers[0].data = &source[0]->stream; - - return num_output_buffers; -} - -static int module_adapter_audio_stream_copy_1to1(struct comp_dev *dev) -{ - struct processing_module *mod = comp_mod(dev); - uint32_t num_output_buffers = 0; - uint32_t frames; - int ret; - - frames = audio_stream_avail_frames_aligned(&mod->source_comp_buffer->stream, - &mod->sink_comp_buffer->stream); - mod->input_buffers[0].size = frames; - mod->input_buffers[0].consumed = 0; - mod->input_buffers[0].data = &mod->source_comp_buffer->stream; - mod->output_buffers[0].size = 0; - mod->output_buffers[0].data = &mod->sink_comp_buffer->stream; - - if (!mod->skip_src_buffer_invalidate) { /* TODO: add mod->is_multi_core && optimization */ - /* moved bytes to its own variable to fix checkpatch */ - uint32_t bytes = - frames * audio_stream_frame_bytes(&mod->source_comp_buffer->stream); - buffer_stream_invalidate(mod->source_comp_buffer, - bytes); - } - - /* Note: Source buffer state is not checked to enable mixout to generate zero - * PCM codes when source is not active. - */ - if (comp_buffer_get_sink_state(mod->sink_comp_buffer) == dev->state) - num_output_buffers = 1; - - ret = module_process_legacy(mod, mod->input_buffers, 1, - mod->output_buffers, num_output_buffers); - - /* consume from the input buffer */ - mod->total_data_consumed += mod->input_buffers[0].consumed; - if (mod->input_buffers[0].consumed) - audio_stream_consume(&mod->source_comp_buffer->stream, - mod->input_buffers[0].consumed); - - /* produce data into the output buffer */ - mod->total_data_produced += mod->output_buffers[0].size; - if (!mod->skip_sink_buffer_writeback) /* TODO: add mod->is_multi_core && optimization */ - buffer_stream_writeback(mod->sink_comp_buffer, mod->output_buffers[0].size); - - if (mod->output_buffers[0].size) - comp_update_buffer_produce(mod->sink_comp_buffer, mod->output_buffers[0].size); - - return ret; -} - -static int module_adapter_audio_stream_type_copy(struct comp_dev *dev) -{ - struct comp_buffer *sources[PLATFORM_MAX_STREAMS]; - struct comp_buffer *sinks[PLATFORM_MAX_STREAMS]; - struct comp_buffer *sink; - struct comp_buffer *source; - struct processing_module *mod = comp_mod(dev); - uint32_t num_input_buffers, num_output_buffers; - int ret, i; - - /* handle special case of HOST/DAI type components */ - if (dev->ipc_config.type == SOF_COMP_HOST || dev->ipc_config.type == SOF_COMP_DAI) - return module_process_endpoint(mod, NULL, 0, NULL, 0); - - if (mod->stream_copy_single_to_single) - return module_adapter_audio_stream_copy_1to1(dev); - - /* acquire all sink and source buffers */ - i = 0; - comp_dev_for_each_consumer(dev, sink) - sinks[i++] = sink; - num_output_buffers = i; - if (num_output_buffers > mod->max_sinks) { - comp_err(dev, "Invalid number of sinks %d\n", num_output_buffers); - return -EINVAL; - } - - i = 0; - comp_dev_for_each_producer(dev, source) - sources[i++] = source; - num_input_buffers = i; - if (num_input_buffers > mod->max_sources) { - comp_err(dev, "Invalid number of sources %d\n", num_input_buffers); - return -EINVAL; - } - - /* setup active input/output buffers for processing */ - if (num_output_buffers == 1) { - module_single_sink_setup(dev, sources, sinks); - if (comp_buffer_get_sink_state(sinks[0]) != dev->state) - num_output_buffers = 0; - } else if (num_input_buffers == 1) { - module_single_source_setup(dev, sources, sinks); - if (comp_buffer_get_source_state(sources[0]) != dev->state) { - num_input_buffers = 0; - } - } else { - ret = -EINVAL; - goto out; - } - - ret = module_process_legacy(mod, mod->input_buffers, num_input_buffers, - mod->output_buffers, num_output_buffers); - if (ret) { - if (ret != -ENOSPC && ret != -ENODATA) { - comp_err(dev, "failed with error: %d", ret); - goto out; - } - - ret = 0; - } - - /* consume from all active input buffers */ - for (i = 0; i < num_input_buffers; i++) { - struct comp_buffer *src = - container_of(mod->input_buffers[i].data, struct comp_buffer, stream); - - if (mod->input_buffers[i].consumed) - audio_stream_consume(&src->stream, 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 */ - for (i = 0; i < num_input_buffers; i++) { - mod->input_buffers[i].size = 0; - mod->input_buffers[i].consumed = 0; - } - - /* produce data into all active output buffers */ - for (i = 0; i < num_output_buffers; i++) { - struct comp_buffer *sink = - container_of(mod->output_buffers[i].data, struct comp_buffer, stream); - - if (!mod->skip_sink_buffer_writeback) - buffer_stream_writeback(sink, mod->output_buffers[i].size); - if (mod->output_buffers[i].size) - comp_update_buffer_produce(sink, mod->output_buffers[i].size); - } - - mod->total_data_produced += mod->output_buffers[0].size; - - /* release all sink buffers */ - for (i = 0; i < num_output_buffers; i++) { - mod->output_buffers[i].size = 0; - } - - return 0; -out: - for (i = 0; i < num_output_buffers; i++) { - mod->output_buffers[i].size = 0; - } - - for (i = 0; i < num_input_buffers; i++) { - mod->input_buffers[i].size = 0; - mod->input_buffers[i].consumed = 0; - } - - return ret; -} - #if CONFIG_PIPELINE_2_0 static int module_adapter_copy_ring_buffers(struct comp_dev *dev) { @@ -1021,19 +672,10 @@ int module_adapter_copy(struct comp_dev *dev) struct processing_module *mod = comp_mod(dev); - if (IS_PROCESSING_MODE_AUDIO_STREAM(mod)) - return module_adapter_audio_stream_type_copy(dev); - - if (IS_PROCESSING_MODE_SINK_SOURCE(mod)) { - if (mod->dev->ipc_config.proc_domain == COMP_PROCESSING_DOMAIN_DP) - return module_adapter_copy_ring_buffers(dev); - else - return module_adapter_sink_source_copy(dev); - - } + if (mod->dev->ipc_config.proc_domain == COMP_PROCESSING_DOMAIN_DP) + return module_adapter_copy_ring_buffers(dev); - comp_err(dev, "unknown processing_data_type"); - return -EINVAL; + return module_adapter_sink_source_copy(dev); } int module_adapter_trigger(struct comp_dev *dev, int cmd) @@ -1089,14 +731,6 @@ int module_adapter_reset(struct comp_dev *dev) return ret; } - if (IS_PROCESSING_MODE_AUDIO_STREAM(mod)) { - sof_heap_free(sof_sys_user_heap_get(), mod->output_buffers); - sof_heap_free(sof_sys_user_heap_get(), mod->input_buffers); - - mod->num_of_sources = 0; - mod->num_of_sinks = 0; - } - mod->total_data_consumed = 0; mod->total_data_produced = 0; diff --git a/src/audio/module_adapter/module_adapter_ipc3.c b/src/audio/module_adapter/module_adapter_ipc3.c index 594acfb53f4e..ab3a5db627c2 100644 --- a/src/audio/module_adapter/module_adapter_ipc3.c +++ b/src/audio/module_adapter/module_adapter_ipc3.c @@ -112,20 +112,6 @@ void module_adapter_reset_data(struct module_config *dst) { } -void module_adapter_check_data(struct processing_module *mod, struct comp_dev *dev, - struct comp_buffer *sink) -{ - /* Check if audio stream client has only one source and one sink buffer to use a - * simplified copy function. - */ - if (IS_PROCESSING_MODE_AUDIO_STREAM(mod) && mod->num_of_sources == 1 && - mod->num_of_sinks == 1) { - mod->source_comp_buffer = comp_dev_get_first_data_producer(dev); - mod->sink_comp_buffer = sink; - mod->stream_copy_single_to_single = true; - } -} - void module_adapter_set_params(struct processing_module *mod, struct sof_ipc_stream_params *params) { } diff --git a/src/audio/module_adapter/module_adapter_ipc4.c b/src/audio/module_adapter/module_adapter_ipc4.c index d2844dcc1bf3..96bd4f009586 100644 --- a/src/audio/module_adapter/module_adapter_ipc4.c +++ b/src/audio/module_adapter/module_adapter_ipc4.c @@ -227,11 +227,6 @@ void module_adapter_reset_data(struct module_config *dst) dst->init_data = NULL; } -void module_adapter_check_data(struct processing_module *mod, struct comp_dev *dev, - struct comp_buffer *sink) -{ -} - void module_adapter_set_params(struct processing_module *mod, struct sof_ipc_stream_params *params) { ipc4_base_module_cfg_to_stream_params(&mod->priv.cfg.base_cfg, params); @@ -403,7 +398,7 @@ int module_adapter_set_attribute(struct comp_dev *dev, uint32_t type, void *valu return 0; } -static bool module_adapter_multi_sink_source_prepare(struct comp_dev *dev) +static void module_adapter_update_sinks_sources(struct comp_dev *dev) { struct processing_module *mod = comp_mod(dev); struct comp_buffer *sink_buffer; @@ -426,15 +421,6 @@ static bool module_adapter_multi_sink_source_prepare(struct comp_dev *dev) mod->num_of_sources = i; comp_dbg(dev, "num_sources=%d num_sinks=%d", mod->num_of_sinks, mod->num_of_sources); - - if (mod->num_of_sinks != 1 || mod->num_of_sources != 1) - return true; - - /* re-assign the source/sink modules */ - mod->sink_comp_buffer = comp_dev_get_first_data_consumer(dev); - mod->source_comp_buffer = comp_dev_get_first_data_producer(dev); - - return false; } static int module_update_source_buffer_params(struct processing_module *mod, @@ -482,7 +468,7 @@ int module_adapter_bind(struct comp_dev *dev, const struct bind_info *bind_data) if (ret < 0) return ret; - mod->stream_copy_single_to_single = !module_adapter_multi_sink_source_prepare(dev); + module_adapter_update_sinks_sources(dev); return 0; } @@ -496,7 +482,7 @@ int module_adapter_unbind(struct comp_dev *dev, const struct bind_info *unbind_d if (ret < 0) return ret; - mod->stream_copy_single_to_single = !module_adapter_multi_sink_source_prepare(dev); + module_adapter_update_sinks_sources(dev); return 0; } diff --git a/src/include/module/module/api_ver.h b/src/include/module/module/api_ver.h index 99ddae1aa2d4..db8ed14ec234 100644 --- a/src/include/module/module/api_ver.h +++ b/src/include/module/module/api_ver.h @@ -21,7 +21,7 @@ #define SOF_MODULE_API_MAJOR_VERSION 5 #define SOF_MODULE_API_MIDDLE_VERSION 0 -#define SOF_MODULE_API_MINOR_VERSION 2 +#define SOF_MODULE_API_MINOR_VERSION 3 #define SOF_MODULE_API_CURRENT_VERSION MODULE_API_VERSION_ENCODE(SOF_MODULE_API_MAJOR_VERSION, \ SOF_MODULE_API_MIDDLE_VERSION, SOF_MODULE_API_MINOR_VERSION) diff --git a/src/include/module/module/base.h b/src/include/module/module/base.h index 1e48bb2e506b..c311625428e4 100644 --- a/src/include/module/module/base.h +++ b/src/include/module/module/base.h @@ -86,11 +86,6 @@ struct module_data { #endif /* SOF_MODULE_PRIVATE */ }; -enum module_processing_type { - MODULE_PROCESS_TYPE_SOURCE_SINK, - MODULE_PROCESS_TYPE_STREAM, -}; - struct userspace_context; struct k_mem_domain; @@ -117,7 +112,7 @@ struct processing_module { */ struct comp_dev *dev; - /* number of sinks / sources and (when in use) input_buffers / input_buffers */ + /* number of sinks / sources */ uint32_t num_of_sources; uint32_t num_of_sinks; @@ -125,16 +120,6 @@ struct processing_module { struct sof_sink *sinks[CONFIG_MODULE_MAX_CONNECTIONS]; struct sof_source *sources[CONFIG_MODULE_MAX_CONNECTIONS]; - /* this is used in case of audio_stream mode - * number of buffers described by fields: - * input_buffers - num_of_sources - * output_buffers - num_of_sinks - */ - struct input_stream_buffer *input_buffers; - struct output_stream_buffer *output_buffers; - struct comp_buffer *source_comp_buffer; /**< single source component buffer */ - struct comp_buffer *sink_comp_buffer; /**< single sink compoonent buffer */ - /* module-specific flags for comp_verify_params() */ uint32_t verify_params_flags; @@ -172,25 +157,6 @@ struct processing_module { bool no_pause; #endif - /* - * 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; - - /* - * True for module with one source component buffer and one sink component buffer - * to enable reduction of module processing overhead. False if component uses - * multiple buffers. - */ - bool stream_copy_single_to_single; - /* total processed data after stream started */ uint64_t total_data_consumed; uint64_t total_data_produced; @@ -199,7 +165,6 @@ struct processing_module { uint32_t max_sources; uint32_t max_sinks; - enum module_processing_type proc_type; #if CONFIG_USERSPACE struct userspace_context *user_ctx; struct k_mem_domain *mdom; diff --git a/src/include/module/module/interface.h b/src/include/module/module/interface.h index b62b61e84dd0..41809c5dee6a 100644 --- a/src/include/module/module/interface.h +++ b/src/include/module/module/interface.h @@ -46,28 +46,6 @@ enum module_processing_mode { MODULE_PROCESSING_BYPASS, }; -/** - * \struct input_stream_buffer - * \brief Input stream buffer - */ -struct input_stream_buffer { - void *data; /* data stream buffer */ - uint32_t size; /* size of data in the buffer */ - uint32_t consumed; /* number of bytes consumed by the module */ - - /* Indicates end of stream condition has occurred on the input stream */ - bool end_of_stream; -}; - -/** - * \struct output_stream_buffer - * \brief Output stream buffer - */ -struct output_stream_buffer { - void *data; /* data stream buffer */ - uint32_t size; /* size of data in the buffer */ -}; - struct processing_module; struct sof_source; struct sof_sink; @@ -139,16 +117,8 @@ struct module_interface { * samples provided by the module_adapter and produce/output the processed * ones back to module_adapter. * - * there are 2 versions of the procedure, the difference is the format of - * input/output data + * the module MUST implement it * - * the module MUST implement one and ONLY one of them - * - * process_audio_stream is depreciated and will be removed - * once pipeline learns to use module API directly (without module adapter) - * modules that need such processing should use proper wrappers - * - * process * - sources are handlers to source API struct source*[] * - sinks are handlers to sink API struct sink*[] * @@ -158,23 +128,6 @@ struct module_interface { struct sof_source **sources, int num_of_sources, struct sof_sink **sinks, int num_of_sinks); - /** - * process_audio_stream (depreciated) - * - sources are input_stream_buffer[] - * - sources[].data is a pointer to audio_stream structure - * - sinks are output_stream_buffer[] - * - sinks[].data is a pointer to audio_stream structure - * - * It can be used by modules that support 1:1, 1:N, N:1 sources:sinks configuration. - * - * Usually shouldn't be __cold - */ - int (*process_audio_stream)(struct processing_module *mod, - struct input_stream_buffer *input_buffers, - int num_input_buffers, - struct output_stream_buffer *output_buffers, - int num_output_buffers); - /** * (optional) Set module configuration parameter * diff --git a/src/include/sof/audio/module_adapter/module/generic.h b/src/include/sof/audio/module_adapter/module/generic.h index 49437640effd..e0b9b2def6e8 100644 --- a/src/include/sof/audio/module_adapter/module/generic.h +++ b/src/include/sof/audio/module_adapter/module/generic.h @@ -24,13 +24,6 @@ #include -/* - * helpers to determine processing type - * Needed till all the modules use PROCESSING_MODE_SINK_SOURCE - */ -#define IS_PROCESSING_MODE_AUDIO_STREAM(mod) ((mod)->proc_type == MODULE_PROCESS_TYPE_STREAM) -#define IS_PROCESSING_MODE_SINK_SOURCE(mod) ((mod)->proc_type == MODULE_PROCESS_TYPE_SOURCE_SINK) - #if CONFIG_IPC_MAJOR_4 #define IPC_MOD_CMD(v) #elif CONFIG_IPC_MAJOR_3 @@ -461,10 +454,6 @@ bool module_is_ready_to_process(struct processing_module *mod, int module_process_sink_src(struct processing_module *mod, struct sof_source **sources, int num_of_sources, struct sof_sink **sinks, int num_of_sinks); -int module_process_legacy(struct processing_module *mod, - struct input_stream_buffer *input_buffers, int num_input_buffers, - struct output_stream_buffer *output_buffers, - int num_output_buffers); int module_reset(struct processing_module *mod); int module_free(struct processing_module *mod); int module_set_configuration(struct processing_module *mod, @@ -538,16 +527,6 @@ uint64_t module_adapter_get_total_data_processed(struct comp_dev *dev, return 0; } -static inline int module_process_endpoint(struct processing_module *mod, - struct input_stream_buffer *input_buffers, - int num_input_buffers, - struct output_stream_buffer *output_buffers, - int num_output_buffers) -{ - return module_process_legacy(mod, input_buffers, num_input_buffers, - output_buffers, num_output_buffers); -} - #else int module_set_large_config(struct comp_dev *dev, uint32_t param_id, bool first_block, bool last_block, uint32_t data_offset, const char *data); @@ -560,18 +539,6 @@ int module_adapter_unbind(struct comp_dev *dev, const struct bind_info *unbind_d uint64_t module_adapter_get_total_data_processed(struct comp_dev *dev, uint32_t stream_no, bool input); -static inline int module_process_endpoint(struct processing_module *mod, - struct input_stream_buffer *input_buffers, - int num_input_buffers, - struct output_stream_buffer *output_buffers, - int num_output_buffers) -{ - const struct module_interface *const ops = mod->dev->drv->adapter_ops; - - return ops->process_audio_stream(mod, input_buffers, num_input_buffers, - output_buffers, num_output_buffers); -} - #endif int module_adapter_get_hw_params(struct comp_dev *dev, struct sof_ipc_stream_params *params, @@ -586,9 +553,6 @@ int module_adapter_ts_get_op(struct comp_dev *dev, struct dai_ts_data *tsd); int module_adapter_ts_get_op(struct comp_dev *dev, struct timestamp_data *tsd); #endif -void module_update_buffer_position(struct input_stream_buffer *input_buffers, - struct output_stream_buffer *output_buffers, - uint32_t frames); struct module_ext_init_data; #if CONFIG_IPC_MAJOR_4 int module_ext_init_decode(const struct comp_driver *drv, struct module_ext_init_data *ext_data, @@ -606,8 +570,6 @@ int module_adapter_init_data(struct comp_dev *dev, const struct comp_ipc_config *config, const void *spec); void module_adapter_reset_data(struct module_config *dst); -void module_adapter_check_data(struct processing_module *mod, struct comp_dev *dev, - struct comp_buffer *sink); void module_adapter_set_params(struct processing_module *mod, struct sof_ipc_stream_params *params); int module_adapter_set_state(struct processing_module *mod, struct comp_dev *dev, int cmd);