From ab57893f1969e4cf5d68434edf91e3589b19c300 Mon Sep 17 00:00:00 2001 From: Andy Ross Date: Fri, 22 Dec 2023 17:17:00 -0800 Subject: [PATCH] various components: Remove default/stub init_alignment_constants usage Traditionally audio_stream has failed to initialize its computed alignment fields, forcing components to do this themselves even when they don't actually have special alignment requirements. Remove all the code that was merely setting default values, leaving only a handful of spots with specialr equirements (e.g. eq/area need to treat pairs of samples, a few others have HiFi-optimized variants which need SIMD alignment). Signed-off-by: Andy Ross --- src/audio/aria/aria.c | 4 +--- src/audio/asrc/asrc.c | 3 --- src/audio/crossover/crossover.c | 5 +---- src/audio/dcblock/dcblock.c | 13 ------------- src/audio/drc/drc.c | 9 --------- src/audio/kpb.c | 4 ---- src/audio/mfcc/mfcc.c | 12 ------------ src/audio/mixer/mixer.c | 11 +---------- src/audio/multiband_drc/multiband_drc.c | 10 ---------- src/audio/mux/mux.c | 8 -------- src/audio/volume/volume.c | 12 +----------- 11 files changed, 4 insertions(+), 87 deletions(-) diff --git a/src/audio/aria/aria.c b/src/audio/aria/aria.c index d338ae22743e..cd9046e61dea 100644 --- a/src/audio/aria/aria.c +++ b/src/audio/aria/aria.c @@ -162,9 +162,7 @@ static void aria_set_stream_params(struct comp_buffer *buffer, const struct ipc4_audio_format *audio_fmt = &mod->priv.cfg.base_cfg.audio_fmt; ipc4_update_buffer_format(buffer, audio_fmt); -#ifdef ARIA_GENERIC - audio_stream_init_alignment_constants(1, 1, &buffer->stream); -#else +#ifndef ARIA_GENERIC audio_stream_init_alignment_constants(8, 1, &buffer->stream); #endif } diff --git a/src/audio/asrc/asrc.c b/src/audio/asrc/asrc.c index 5e7eb0f3300a..3bd8679639fc 100644 --- a/src/audio/asrc/asrc.c +++ b/src/audio/asrc/asrc.c @@ -755,9 +755,6 @@ static int asrc_prepare(struct processing_module *mod, sinkb = list_first_item(&dev->bsink_list, struct comp_buffer, source_list); - audio_stream_init_alignment_constants(1, 1, &sourceb->stream); - audio_stream_init_alignment_constants(1, 1, &sinkb->stream); - /* get source data format and period bytes */ cd->source_format = audio_stream_get_frm_fmt(&sourceb->stream); source_period_bytes = audio_stream_period_bytes(&sourceb->stream, diff --git a/src/audio/crossover/crossover.c b/src/audio/crossover/crossover.c index 4e89a9d05042..1f82b7625cc7 100644 --- a/src/audio/crossover/crossover.c +++ b/src/audio/crossover/crossover.c @@ -733,14 +733,11 @@ static int crossover_prepare(struct processing_module *mod, /* Get source data format */ cd->source_format = audio_stream_get_frm_fmt(&source->stream); channels = audio_stream_get_channels(&source->stream); - audio_stream_init_alignment_constants(1, 1, &source->stream); /* Validate frame format and buffer size of sinks */ list_for_item(sink_list, &dev->bsink_list) { sink = container_of(sink_list, struct comp_buffer, source_list); - if (cd->source_format == audio_stream_get_frm_fmt(&sink->stream)) { - audio_stream_init_alignment_constants(1, 1, &sink->stream); - } else { + if (cd->source_format != audio_stream_get_frm_fmt(&sink->stream)) { comp_err(dev, "crossover_prepare(): Source fmt %d and sink fmt %d are different.", cd->source_format, audio_stream_get_frm_fmt(&sink->stream)); ret = -EINVAL; diff --git a/src/audio/dcblock/dcblock.c b/src/audio/dcblock/dcblock.c index 8e52820341ba..dfde5591815d 100644 --- a/src/audio/dcblock/dcblock.c +++ b/src/audio/dcblock/dcblock.c @@ -206,17 +206,6 @@ static int dcblock_process(struct processing_module *mod, return 0; } -/* init and calculate the aligned setting for available frames and free frames retrieve*/ -static inline void dcblock_set_frame_alignment(struct audio_stream *source, - struct audio_stream *sink) -{ - const uint32_t byte_align = 1; - const uint32_t frame_align_req = 1; - - audio_stream_init_alignment_constants(byte_align, frame_align_req, source); - audio_stream_init_alignment_constants(byte_align, frame_align_req, sink); -} - #if CONFIG_IPC_MAJOR_4 static void dcblock_params(struct processing_module *mod) { @@ -266,8 +255,6 @@ static int dcblock_prepare(struct processing_module *mod, /* get sink data format and period bytes */ cd->sink_format = audio_stream_get_frm_fmt(&sinkb->stream); - dcblock_set_frame_alignment(&sourceb->stream, &sinkb->stream); - dcblock_init_state(cd); cd->dcblock_func = dcblock_find_func(cd->source_format); if (!cd->dcblock_func) { diff --git a/src/audio/drc/drc.c b/src/audio/drc/drc.c index c69b3a742ea6..3c3bae268bd5 100644 --- a/src/audio/drc/drc.c +++ b/src/audio/drc/drc.c @@ -227,14 +227,6 @@ static int drc_get_config(struct processing_module *mod, return comp_data_blob_get_cmd(cd->model_handler, cdata, fragment_size); } -static void drc_set_alignment(struct audio_stream *source, - struct audio_stream *sink) -{ - /* Currently no optimizations those would use wider loads and stores */ - audio_stream_init_alignment_constants(1, 1, source); - audio_stream_init_alignment_constants(1, 1, sink); -} - static int drc_process(struct processing_module *mod, struct input_stream_buffer *input_buffers, int num_input_buffers, @@ -308,7 +300,6 @@ static int drc_prepare(struct processing_module *mod, /* DRC component will only ever have 1 source and 1 sink buffer */ sourceb = list_first_item(&dev->bsource_list, struct comp_buffer, sink_list); sinkb = list_first_item(&dev->bsink_list, struct comp_buffer, source_list); - drc_set_alignment(&sourceb->stream, &sinkb->stream); /* get source data format */ cd->source_format = audio_stream_get_frm_fmt(&sourceb->stream); diff --git a/src/audio/kpb.c b/src/audio/kpb.c index 6e4ce13bdca0..c195c5ba0d7c 100644 --- a/src/audio/kpb.c +++ b/src/audio/kpb.c @@ -893,16 +893,12 @@ static int kpb_prepare(struct comp_dev *dev) */ if (kpb->ipc4_cfg.base_cfg.ibs != kpb->ipc4_cfg.base_cfg.obs) { struct list_item *sink_list; - const uint32_t byte_align = 1; - const uint32_t frame_align_req = 1; uint32_t sink_id; list_for_item(sink_list, &dev->bsink_list) { struct comp_buffer *sink = container_of(sink_list, struct comp_buffer, source_list); - audio_stream_init_alignment_constants(byte_align, frame_align_req, - &sink->stream); sink_id = buf_get_id(sink); if (sink_id == 0) diff --git a/src/audio/mfcc/mfcc.c b/src/audio/mfcc/mfcc.c index 109c3636a4a1..9b88f1bc238a 100644 --- a/src/audio/mfcc/mfcc.c +++ b/src/audio/mfcc/mfcc.c @@ -177,15 +177,6 @@ static int mfcc_process(struct processing_module *mod, return 0; } -static void mfcc_set_alignment(struct audio_stream *source, struct audio_stream *sink) -{ - const uint32_t byte_align = 1; - const uint32_t frame_align_req = 1; - - audio_stream_init_alignment_constants(byte_align, frame_align_req, source); - audio_stream_init_alignment_constants(byte_align, frame_align_req, sink); -} - static int mfcc_prepare(struct processing_module *mod, struct sof_source **sources, int num_of_sources, struct sof_sink **sinks, int num_of_sinks) @@ -208,9 +199,6 @@ static int mfcc_prepare(struct processing_module *mod, /* get source data format */ source_format = audio_stream_get_frm_fmt(&sourceb->stream); - /* set align requirements */ - mfcc_set_alignment(&sourceb->stream, &sinkb->stream); - /* get sink data format and period bytes */ sink_format = audio_stream_get_frm_fmt(&sinkb->stream); sink_period_bytes = audio_stream_period_bytes(&sinkb->stream, dev->frames); diff --git a/src/audio/mixer/mixer.c b/src/audio/mixer/mixer.c index fce964f4da1b..a13e6652bf1e 100644 --- a/src/audio/mixer/mixer.c +++ b/src/audio/mixer/mixer.c @@ -204,17 +204,8 @@ static inline void mixer_set_frame_alignment(struct audio_stream *source) /*There is no limit for frame number, so set it as 1*/ const uint32_t frame_align_req = 1; -#else - - /* Since the generic version process signal sample by sample, so there is no - * limit for it, then set the byte_align and frame_align_req to be 1. - */ - const uint32_t byte_align = 1; - const uint32_t frame_align_req = 1; - -#endif - audio_stream_init_alignment_constants(byte_align, frame_align_req, source); +#endif } static int mixer_prepare(struct processing_module *mod, diff --git a/src/audio/multiband_drc/multiband_drc.c b/src/audio/multiband_drc/multiband_drc.c index fe1c11f3cdab..8bb203a6bacf 100644 --- a/src/audio/multiband_drc/multiband_drc.c +++ b/src/audio/multiband_drc/multiband_drc.c @@ -411,14 +411,6 @@ static int multiband_drc_get_config(struct processing_module *mod, return comp_data_blob_get_cmd(cd->model_handler, cdata, fragment_size); } -static void multiband_drc_set_alignment(struct audio_stream *source, - struct audio_stream *sink) -{ - /* Currently no optimizations those would use wider loads and stores */ - audio_stream_init_alignment_constants(1, 1, source); - audio_stream_init_alignment_constants(1, 1, sink); -} - static int multiband_drc_process(struct processing_module *mod, struct input_stream_buffer *input_buffers, int num_input_buffers, struct output_stream_buffer *output_buffers, @@ -509,8 +501,6 @@ static int multiband_drc_prepare(struct processing_module *mod, sourceb = list_first_item(&dev->bsource_list, struct comp_buffer, sink_list); sinkb = list_first_item(&dev->bsink_list, struct comp_buffer, source_list); - multiband_drc_set_alignment(&sourceb->stream, &sinkb->stream); - /* get source data format */ cd->source_format = audio_stream_get_frm_fmt(&sourceb->stream); channels = audio_stream_get_channels(&sourceb->stream); diff --git a/src/audio/mux/mux.c b/src/audio/mux/mux.c index de16ee754c98..ef308753c8ce 100644 --- a/src/audio/mux/mux.c +++ b/src/audio/mux/mux.c @@ -276,8 +276,6 @@ static void set_mux_params(struct processing_module *mod) struct comp_buffer *sink, *source; struct list_item *source_list; int j; - const uint32_t byte_align = 1; - const uint32_t frame_align_req = 1; params->direction = dev->direction; params->channels = cd->md.base_cfg.audio_fmt.channels_count; @@ -297,8 +295,6 @@ static void set_mux_params(struct processing_module *mod) /* update sink format */ if (!list_is_empty(&dev->bsink_list)) { sink = list_first_item(&dev->bsink_list, struct comp_buffer, source_list); - audio_stream_init_alignment_constants(byte_align, frame_align_req, - &sink->stream); if (!sink->hw_params_configured) { ipc4_update_buffer_format(sink, &cd->md.output_format); @@ -313,8 +309,6 @@ static void set_mux_params(struct processing_module *mod) list_for_item(source_list, &dev->bsource_list) { source = container_of(source_list, struct comp_buffer, sink_list); - audio_stream_init_alignment_constants(byte_align, frame_align_req, - &source->stream); j = buf_get_id(source); cd->config.streams[j].pipeline_id = source->pipeline_id; if (j == BASE_CFG_QUEUED_ID) @@ -607,7 +601,6 @@ static int mux_prepare(struct processing_module *mod, list_for_item(blist, &dev->bsource_list) { source = container_of(blist, struct comp_buffer, sink_list); state = source->source->state; - audio_stream_init_alignment_constants(1, 1, &source->stream); /* only prepare downstream if we have no active sources */ if (state == COMP_STATE_PAUSED || state == COMP_STATE_ACTIVE) @@ -617,7 +610,6 @@ static int mux_prepare(struct processing_module *mod, /* set sink align to 1 byte, 1 frame */ list_for_item(blist, &dev->bsink_list) { sink = container_of(blist, struct comp_buffer, source_list); - audio_stream_init_alignment_constants(1, 1, &sink->stream); } /* prepare downstream */ diff --git a/src/audio/volume/volume.c b/src/audio/volume/volume.c index 002ceff9d852..694d778db6b0 100644 --- a/src/audio/volume/volume.c +++ b/src/audio/volume/volume.c @@ -623,7 +623,6 @@ static void volume_set_alignment(struct audio_stream *source, struct audio_stream *sink) { #if XCHAL_HAVE_HIFI3 || XCHAL_HAVE_HIFI4 - /* Both source and sink buffer in HiFi 3 or HiFi4 processing version, * xtensa intrinsics ask for 8-byte aligned. 5.1 format SSE audio * requires 16-byte aligned. @@ -633,18 +632,9 @@ static void volume_set_alignment(struct audio_stream *source, /*There is no limit for frame number, so both source and sink set it to be 1*/ const uint32_t frame_align_req = 1; -#else - - /* Since the generic version process signal sample by sample, so there is no - * limit for it, then set the byte_align and frame_align_req to be 1. - */ - const uint32_t byte_align = 1; - const uint32_t frame_align_req = 1; - -#endif - audio_stream_init_alignment_constants(byte_align, frame_align_req, source); audio_stream_init_alignment_constants(byte_align, frame_align_req, sink); +#endif } /**