Skip to content

Commit

Permalink
copier: Add bind function to configure sink buffers params
Browse files Browse the repository at this point in the history
Setting the sink buffers parameters in the copier_update_params function is
not sufficient. If a sink buffer is attached during copier operation, the
module will not set buffers parameters. Move the buffer parameter
configuration to the new copier_bind bind function. Delete the sink buffers
configuration from the copier_module_copy function. There is no need to
configure sink buffers parameters on each copy. We are assured that they
were configured at the time of bind.

Fixes: thesofproject#9123

Signed-off-by: Adrian Warecki <[email protected]>
  • Loading branch information
softwarecki committed Jul 5, 2024
1 parent 8bf6cf4 commit fef0d9d
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 16 deletions.
31 changes: 28 additions & 3 deletions src/audio/copier/copier.c
Original file line number Diff line number Diff line change
Expand Up @@ -518,9 +518,6 @@ static int copier_module_copy(struct processing_module *mod,
if (sink_queue_id >= IPC4_COPIER_MODULE_OUTPUT_PINS_COUNT)
return -EINVAL;

/* update corresponding sink format in case it isn't updated */
ipc4_update_buffer_format(sink_c, &cd->out_fmt[sink_queue_id]);

comp_get_copy_limits(src_c, sink_c, &processed_data);

samples = processed_data.frames *
Expand Down Expand Up @@ -975,6 +972,33 @@ static int copier_get_hw_params(struct comp_dev *dev, struct sof_ipc_stream_para
return dai_common_get_hw_params(dd, dev, params, dir);
}

static int copier_bind(struct processing_module *mod, void *data)
{
const struct ipc4_module_bind_unbind *const bu = (struct ipc4_module_bind_unbind *)data;
const uint32_t src_id = IPC4_COMP_ID(bu->primary.r.module_id, bu->primary.r.instance_id);
const uint32_t src_queue_id = bu->extension.r.src_queue;
struct copier_data *cd = module_get_private_data(mod);
struct comp_dev *dev = mod->dev;
struct list_item *list;

if (dev->ipc_config.id != src_id)
return 0; /* Another component is a data producer */

/* update sink format */
list_for_item(list, &dev->bsink_list) {
struct comp_buffer *buffer = container_of(list, struct comp_buffer, source_list);
uint32_t id = IPC4_SRC_QUEUE_ID(buf_get_id(buffer));

if (src_queue_id == id) {
ipc4_update_buffer_format(buffer, &cd->out_fmt[id]);
return 0;
}
}

comp_err(dev, "No sink buffer found for src_queue = %u", src_queue_id);
return -ENODEV;
}

static int copier_unbind(struct processing_module *mod, void *data)
{
struct copier_data *cd = module_get_private_data(mod);
Expand Down Expand Up @@ -1008,6 +1032,7 @@ static const struct module_interface copier_interface = {
.free = copier_free,
.set_configuration = copier_set_configuration,
.get_configuration = copier_get_configuration,
.bind = copier_bind,
.unbind = copier_unbind,
.endpoint_ops = &copier_endpoint_ops,
};
Expand Down
14 changes: 1 addition & 13 deletions src/audio/copier/copier_generic.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,7 @@ int apply_attenuation(struct comp_dev *dev, struct copier_data *cd,
void copier_update_params(struct copier_data *cd, struct comp_dev *dev,
struct sof_ipc_stream_params *params)
{
struct comp_buffer *sink, *source;
struct list_item *sink_list;
struct comp_buffer *source;

memset(params, 0, sizeof(*params));
params->direction = cd->direction;
Expand All @@ -79,17 +78,6 @@ void copier_update_params(struct copier_data *cd, struct comp_dev *dev,
/* disable ipc3 stream position */
params->no_stream_position = 1;

/* update each sink format */
list_for_item(sink_list, &dev->bsink_list) {
int j;

sink = container_of(sink_list, struct comp_buffer, source_list);

j = IPC4_SINK_QUEUE_ID(buf_get_id(sink));

ipc4_update_buffer_format(sink, &cd->out_fmt[j]);
}

/*
* force update the source buffer format to cover cases where the source module
* fails to set the sink buffer params
Expand Down

0 comments on commit fef0d9d

Please sign in to comment.