Skip to content

Commit

Permalink
smart-amp: [WiP] extend to be usable as a loadable module
Browse files Browse the repository at this point in the history
Add a manifest and a "main()" entry point to IPC4 smart-amp-test to
adapt it for dynamic loading. Note, that at the moment we need a
trick to force .bss from being optimised out. This has to be solved
in a better way.

Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
  • Loading branch information
lyakh committed Sep 8, 2023
1 parent 6397aed commit 4433c3a
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions src/samples/audio/smart_amp_test_ipc4.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ struct smart_amp_data {
uint32_t out_channels;
};

static int keep_bss;

static int smart_amp_init(struct processing_module *mod)
{
struct smart_amp_data *sad;
Expand All @@ -49,7 +51,11 @@ static int smart_amp_init(struct processing_module *mod)
int ret;
const struct ipc4_base_module_extended_cfg *base_cfg = mod_data->cfg.init_data;

comp_dbg(dev, "smart_amp_init()");
if (!base_cfg) {
comp_err(dev, "smart_amp_init(): no rzalloc %d", ++keep_bss);
return -EINVAL;
}

sad = rzalloc(SOF_MEM_ZONE_RUNTIME, 0, SOF_MEM_CAPS_RAM, sizeof(*sad));
if (!sad)
return -ENOMEM;
Expand All @@ -65,7 +71,9 @@ static int smart_amp_init(struct processing_module *mod)

if (base_cfg->base_cfg_ext.nb_input_pins != SMART_AMP_NUM_IN_PINS ||
base_cfg->base_cfg_ext.nb_output_pins != SMART_AMP_NUM_OUT_PINS) {
comp_err(dev, "smart_amp_init(): Invalid pin configuration");
comp_err(dev, "smart_amp_init(): Invalid pin configuration: %d %d %d",
base_cfg->base_cfg_ext.nb_input_pins,
base_cfg->base_cfg_ext.nb_output_pins, ++keep_bss);
ret = -EINVAL;
goto sad_fail;
}
Expand Down Expand Up @@ -118,7 +126,7 @@ static int smart_amp_set_config(struct processing_module *mod, uint32_t config_i
struct comp_dev *dev = mod->dev;
struct smart_amp_data *sad = module_get_private_data(mod);

comp_dbg(dev, "smart_amp_set_config()");
comp_dbg(dev, "smart_amp_set_config(): %u", config_id);

switch (config_id) {
case SMART_AMP_SET_MODEL:
Expand Down Expand Up @@ -182,7 +190,9 @@ static int smart_amp_params(struct processing_module *mod)

comp_dbg(dev, "smart_amp_params()");
smart_amp_set_params(mod);

ret = comp_verify_params(dev, BUFF_PARAMS_CHANNELS, params);
comp_dbg(dev, "smart_amp_params(): %d", ret);
if (ret < 0) {
comp_err(dev, "smart_amp_params(): pcm params verification failed.");
return -EINVAL;
Expand Down Expand Up @@ -366,6 +376,7 @@ static int smart_amp_prepare(struct processing_module *mod,
source_buffer = container_of(blist, struct comp_buffer,
sink_list);
buffer_c = buffer_acquire(source_buffer);
comp_dbg(dev, "smart_amp_prepare() init source %p", source_buffer);
audio_stream_init_alignment_constants(1, 1, &buffer_c->stream);
if (IPC4_SINK_QUEUE_ID(buffer_c->id) == SOF_SMART_AMP_FEEDBACK_QUEUE_ID) {
audio_stream_set_channels(&buffer_c->stream, sad->config.feedback_channels);
Expand All @@ -377,6 +388,7 @@ static int smart_amp_prepare(struct processing_module *mod,

sink_buffer = list_first_item(&dev->bsink_list, struct comp_buffer, source_list);
buffer_c = buffer_acquire(sink_buffer);
comp_dbg(dev, "smart_amp_prepare() init sink %p", sink_buffer);
sad->out_channels = audio_stream_get_channels(&buffer_c->stream);
audio_stream_init_alignment_constants(1, 1, &buffer_c->stream);
sad->process = get_smart_amp_process(dev, buffer_c);
Expand Down

0 comments on commit 4433c3a

Please sign in to comment.