Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sink / source API #7622

Merged
merged 10 commits into from
Jun 19, 2023
2 changes: 1 addition & 1 deletion src/audio/buffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ struct comp_buffer *buffer_alloc(uint32_t size, uint32_t caps, uint32_t flags, u

/* From here no more uncached access to the buffer object, except its list headers */
buffer_c = buffer_acquire(buffer);
buffer_c->stream.addr = stream_addr;
audio_stream_set_addr(&buffer_c->stream, stream_addr);
buffer_init(buffer_c, size, caps);

audio_stream_set_underrun(&buffer_c->stream, !!(flags & SOF_BUF_UNDERRUN_PERMITTED));
Expand Down
4 changes: 1 addition & 3 deletions src/audio/eq_fir/eq_fir.c
Original file line number Diff line number Diff line change
Expand Up @@ -456,8 +456,6 @@ static int eq_fir_init(struct processing_module *mod)
for (i = 0; i < PLATFORM_MAX_CHANNELS; i++)
fir_reset(&cd->fir[i]);

mod->simple_copy = true;

return 0;

err_init:
Expand Down Expand Up @@ -641,7 +639,7 @@ static struct module_interface eq_fir_interface = {
.free = eq_fir_free,
.set_configuration = eq_fir_set_config,
.get_configuration = eq_fir_get_config,
.process = eq_fir_process,
.process_audio_stream = eq_fir_process,
.prepare = eq_fir_prepare,
.reset = eq_fir_reset,
};
Expand Down
8 changes: 1 addition & 7 deletions src/audio/eq_iir/eq_iir.c
Original file line number Diff line number Diff line change
Expand Up @@ -670,12 +670,6 @@ static int eq_iir_init(struct processing_module *mod)
for (i = 0; i < PLATFORM_MAX_CHANNELS; i++)
iir_reset_df1(&cd->iir[i]);

/*
* set the simple_copy flag as the eq_iir component always produces period_bytes
* every period and has only 1 input/output buffer
*/
mod->simple_copy = true;

return 0;
err:
rfree(cd);
Expand Down Expand Up @@ -967,7 +961,7 @@ static int eq_iir_reset(struct processing_module *mod)
static struct module_interface eq_iir_interface = {
.init = eq_iir_init,
.prepare = eq_iir_prepare,
.process = eq_iir_process,
.process_audio_stream = eq_iir_process,
.set_configuration = eq_iir_set_config,
.get_configuration = eq_iir_get_config,
.reset = eq_iir_reset,
Expand Down
3 changes: 1 addition & 2 deletions src/audio/mfcc/mfcc.c
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@ static int mfcc_init(struct processing_module *mod)
goto err_init;
}

mod->simple_copy = true;
return 0;

err_init:
Expand Down Expand Up @@ -272,7 +271,7 @@ static struct module_interface mfcc_interface = {
.free = mfcc_free,
.set_configuration = mfcc_set_config,
.get_configuration = mfcc_get_config,
.process = mfcc_process,
.process_audio_stream = mfcc_process,
.prepare = mfcc_prepare,
.reset = mfcc_reset,
};
Expand Down
3 changes: 1 addition & 2 deletions src/audio/mixer/mixer.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ static int mixer_init(struct processing_module *mod)

mod_data->private = md;
mod->verify_params_flags = BUFF_PARAMS_CHANNELS;
mod->simple_copy = true;
mod->no_pause = true;
return 0;
}
Expand Down Expand Up @@ -266,7 +265,7 @@ static int mixer_prepare(struct processing_module *mod)
static struct module_interface mixer_interface = {
.init = mixer_init,
.prepare = mixer_prepare,
.process = mixer_process,
.process_audio_stream = mixer_process,
.reset = mixer_reset,
.free = mixer_free,
};
Expand Down
6 changes: 2 additions & 4 deletions src/audio/mixin_mixout/mixin_mixout.c
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,6 @@ static int mixin_init(struct processing_module *mod)
mod->priv.cfg.base_cfg.audio_fmt.s_type);

dev->ipc_config.frame_fmt = frame_fmt;
mod->simple_copy = true;
mod->skip_src_buffer_invalidate = true;

return 0;
Expand Down Expand Up @@ -150,7 +149,6 @@ static int mixout_init(struct processing_module *mod)
mod->priv.cfg.base_cfg.audio_fmt.s_type);

dev->ipc_config.frame_fmt = frame_fmt;
mod->simple_copy = true;
mod->skip_sink_buffer_writeback = true;

return 0;
Expand Down Expand Up @@ -928,7 +926,7 @@ static int mixin_set_config(struct processing_module *mod, uint32_t config_id,
static struct module_interface mixin_interface = {
.init = mixin_init,
.prepare = mixin_prepare,
.process = mixin_process,
.process_audio_stream = mixin_process,
.set_configuration = mixin_set_config,
.reset = mixin_reset,
.free = mixin_free
Expand All @@ -940,7 +938,7 @@ SOF_MODULE_INIT(mixin, sys_comp_module_mixin_interface_init);
static struct module_interface mixout_interface = {
.init = mixout_init,
.prepare = mixout_prepare,
.process = mixout_process,
.process_audio_stream = mixout_process,
.reset = mixout_reset,
.free = mixout_free
};
Expand Down
2 changes: 1 addition & 1 deletion src/audio/module_adapter/module/cadence.c
Original file line number Diff line number Diff line change
Expand Up @@ -749,7 +749,7 @@ cadence_codec_set_configuration(struct processing_module *mod, uint32_t config_i
static struct module_interface cadence_interface = {
.init = cadence_codec_init,
.prepare = cadence_codec_prepare,
.process = cadence_codec_process,
.process_raw_data = cadence_codec_process,
.set_configuration = cadence_codec_set_configuration,
.reset = cadence_codec_reset,
.free = cadence_codec_free
Expand Down
2 changes: 1 addition & 1 deletion src/audio/module_adapter/module/dts.c
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,7 @@ dts_codec_set_configuration(struct processing_module *mod, uint32_t config_id,
static struct module_interface dts_interface = {
.init = dts_codec_init,
.prepare = dts_codec_prepare,
.process = dts_codec_process,
.process_raw_data = dts_codec_process,
.set_configuration = dts_codec_set_configuration,
.reset = dts_codec_reset,
.free = dts_codec_free
Expand Down
66 changes: 57 additions & 9 deletions src/audio/module_adapter/module/generic.c
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,11 @@ int module_init(struct processing_module *mod, struct module_interface *interfac
return -EIO;
}

if (!interface->init || !interface->prepare || !interface->process ||
!interface->reset || !interface->free) {
/*check interface, there must be one and only one of processing procedure */
if (!interface->init || !interface->prepare ||
!interface->reset || !interface->free ||
(!!interface->process + !!interface->process_audio_stream +
!!interface->process_raw_data != 1)) {
comp_err(dev, "module_init(): comp %d is missing mandatory interfaces",
dev_comp_id(dev));
return -EIO;
Expand Down Expand Up @@ -225,16 +228,17 @@ int module_prepare(struct processing_module *mod)
return ret;
}

int module_process(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_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;
int ret;

struct module_data *md = &mod->priv;

comp_dbg(dev, "module_process() start");
comp_dbg(dev, "module_process_legacy() start");

if (md->state != MODULE_IDLE) {
comp_err(dev, "module_process(): wrong state of comp_id %x, state %d",
Expand All @@ -245,15 +249,59 @@ int module_process(struct processing_module *mod, struct input_stream_buffer *in
/* set state to processing */
md->state = MODULE_PROCESSING;

ret = md->ops->process(mod, input_buffers, num_input_buffers, output_buffers,
num_output_buffers);
if (md->ops->process_audio_stream)
ret = md->ops->process_audio_stream(mod, input_buffers, num_input_buffers,
output_buffers, num_output_buffers);
else if (md->ops->process_raw_data)
ret = md->ops->process_raw_data(mod, input_buffers, num_input_buffers,
output_buffers, num_output_buffers);
else
ret = -EOPNOTSUPP;

if (ret && ret != -ENOSPC && ret != -ENODATA) {
comp_err(dev, "module_process() error %d: for comp %d",
ret, dev_comp_id(dev));
return ret;
}

comp_dbg(dev, "module_process_legacy() done");

/* reset state to idle */
md->state = MODULE_IDLE;
return 0;
}

int module_process_sink_src(struct processing_module *mod,
struct sof_source __sparse_cache **sources, int num_of_sources,
struct sof_sink __sparse_cache **sinks, int num_of_sinks)

{
struct comp_dev *dev = mod->dev;
int ret;

struct module_data *md = &mod->priv;

comp_dbg(dev, "module_process sink src() start");

if (md->state != MODULE_IDLE) {
comp_err(dev, "module_process(): wrong state of comp_id %x, state %d",
dev_comp_id(dev), md->state);
return -EPERM;
}

/* set state to processing */
md->state = MODULE_PROCESSING;

assert(md->ops->process);
ret = md->ops->process(mod, sources, num_of_sources, sinks, num_of_sinks);

if (ret && ret != -ENOSPC && ret != -ENODATA) {
comp_err(dev, "module_process() error %d: for comp %d",
ret, dev_comp_id(dev));
return ret;
}

comp_dbg(dev, "module_process() done");
comp_dbg(dev, "module_process sink src() done");

/* reset state to idle */
md->state = MODULE_IDLE;
Expand Down
2 changes: 1 addition & 1 deletion src/audio/module_adapter/module/iadk_modules.c
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ static int iadk_modules_reset(struct processing_module *mod)
static struct module_interface iadk_interface = {
.init = iadk_modules_init,
.prepare = iadk_modules_prepare,
.process = iadk_modules_process,
.process_raw_data = iadk_modules_process,
.set_processing_mode = iadk_modules_set_processing_mode,
.get_processing_mode = iadk_modules_get_processing_mode,
.set_configuration = iadk_modules_set_configuration,
Expand Down
2 changes: 1 addition & 1 deletion src/audio/module_adapter/module/passthrough.c
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ static int passthrough_codec_free(struct processing_module *mod)
static struct module_interface passthrough_interface = {
.init = passthrough_codec_init,
.prepare = passthrough_codec_prepare,
.process = passthrough_codec_process,
.process_raw_data = passthrough_codec_process,
.reset = passthrough_codec_reset,
.free = passthrough_codec_free
};
Expand Down
10 changes: 2 additions & 8 deletions src/audio/module_adapter/module/volume/volume.c
Original file line number Diff line number Diff line change
Expand Up @@ -1340,12 +1340,6 @@ static int volume_prepare(struct processing_module *mod)
md->mpd.in_buff_size = sink_period_bytes;
md->mpd.out_buff_size = sink_period_bytes;

/*
* also set the simple_copy flag as the volume component always produces period_bytes
* every period and has only 1 input/output buffer
*/
mod->simple_copy = true;

return 0;

err:
Expand Down Expand Up @@ -1611,7 +1605,7 @@ SOF_MODULE_INIT(volume, sys_comp_volume_init);
static struct module_interface volume_interface = {
.init = volume_init,
.prepare = volume_prepare,
.process = volume_process,
.process_audio_stream = volume_process,
.set_configuration = volume_set_config,
.get_configuration = volume_get_config,
.reset = volume_reset,
Expand All @@ -1625,7 +1619,7 @@ SOF_MODULE_INIT(volume, sys_comp_module_volume_interface_init);
static struct module_interface gain_interface = {
.init = volume_init,
.prepare = volume_prepare,
.process = volume_process,
.process_audio_stream = volume_process,
.set_configuration = volume_set_config,
.get_configuration = volume_get_config,
.reset = volume_reset,
Expand Down
2 changes: 1 addition & 1 deletion src/audio/module_adapter/module/waves.c
Original file line number Diff line number Diff line change
Expand Up @@ -887,7 +887,7 @@ waves_codec_set_configuration(struct processing_module *mod, uint32_t config_id,
static struct module_interface waves_interface = {
.init = waves_codec_init,
.prepare = waves_codec_prepare,
.process = waves_codec_process,
.process_raw_data = waves_codec_process,
.set_configuration = waves_codec_set_configuration,
.reset = waves_codec_reset,
.free = waves_codec_free
Expand Down
Loading