From 726cfc75ef5e73bff043f1f4668681661a83be50 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 | 2 -- src/audio/volume/volume.c | 12 +----------- 11 files changed, 4 insertions(+), 81 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 c89785fcb790..8ce6c711dfc9 100644 --- a/src/audio/asrc/asrc.c +++ b/src/audio/asrc/asrc.c @@ -550,9 +550,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 4bb0be6f239f..69135368671a 100644 --- a/src/audio/crossover/crossover.c +++ b/src/audio/crossover/crossover.c @@ -546,14 +546,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 a7ef67309c6a..8cca278d285d 100644 --- a/src/audio/dcblock/dcblock.c +++ b/src/audio/dcblock/dcblock.c @@ -183,17 +183,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); -} - /** * \brief Prepares DC Blocking Filter component for processing. * \param[in,out] dev DC Blocking Filter base component device. @@ -221,8 +210,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 9eff93d79019..7080fdea55f1 100644 --- a/src/audio/drc/drc.c +++ b/src/audio/drc/drc.c @@ -260,14 +260,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, @@ -344,7 +336,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 43f75519850e..6d0507a033d1 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 1fe9c381c142..38be94676c29 100644 --- a/src/audio/mixer/mixer.c +++ b/src/audio/mixer/mixer.c @@ -205,17 +205,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 5454df29318a..bfb650d28f74 100644 --- a/src/audio/multiband_drc/multiband_drc.c +++ b/src/audio/multiband_drc/multiband_drc.c @@ -310,14 +310,6 @@ static int multiband_drc_get_config(struct processing_module *mod, return multiband_drc_get_ipc_config(mod, 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, @@ -371,8 +363,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 b57588655941..06b080b2d77a 100644 --- a/src/audio/mux/mux.c +++ b/src/audio/mux/mux.c @@ -414,7 +414,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) @@ -424,7 +423,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 } /**