Skip to content

Commit

Permalink
various components: Remove default/stub init_alignment_constants usage
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
andyross committed Dec 23, 2023
1 parent 2f1224f commit ab57893
Show file tree
Hide file tree
Showing 11 changed files with 4 additions and 87 deletions.
4 changes: 1 addition & 3 deletions src/audio/aria/aria.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
3 changes: 0 additions & 3 deletions src/audio/asrc/asrc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
5 changes: 1 addition & 4 deletions src/audio/crossover/crossover.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
13 changes: 0 additions & 13 deletions src/audio/dcblock/dcblock.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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) {
Expand Down
9 changes: 0 additions & 9 deletions src/audio/drc/drc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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);
Expand Down
4 changes: 0 additions & 4 deletions src/audio/kpb.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
12 changes: 0 additions & 12 deletions src/audio/mfcc/mfcc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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);
Expand Down
11 changes: 1 addition & 10 deletions src/audio/mixer/mixer.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
10 changes: 0 additions & 10 deletions src/audio/multiband_drc/multiband_drc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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);
Expand Down
8 changes: 0 additions & 8 deletions src/audio/mux/mux.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
Expand All @@ -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)
Expand Down Expand Up @@ -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)
Expand All @@ -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 */
Expand Down
12 changes: 1 addition & 11 deletions src/audio/volume/volume.c
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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
}

/**
Expand Down

0 comments on commit ab57893

Please sign in to comment.