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

copier: Add bind function to configure source/sink buffers params #9276

Merged
merged 3 commits into from
Jul 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 28 additions & 18 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 @@ -662,8 +659,6 @@ static int copier_set_sink_fmt(struct comp_dev *dev, const void *data,
const struct ipc4_copier_config_set_sink_format *sink_fmt = data;
struct processing_module *mod = comp_mod(dev);
struct copier_data *cd = module_get_private_data(mod);
struct list_item *sink_list;
struct comp_buffer *sink;

if (max_data_size < sizeof(*sink_fmt)) {
comp_err(dev, "error: max_data_size %d should be bigger than %d", max_data_size,
Expand Down Expand Up @@ -693,19 +688,6 @@ static int copier_set_sink_fmt(struct comp_dev *dev, const void *data,
&sink_fmt->sink_fmt, ipc4_gtw_none,
ipc4_bidirection);

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

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

sink_id = IPC4_SINK_QUEUE_ID(buf_get_id(sink));
if (sink_id == sink_fmt->sink_id) {
ipc4_update_buffer_format(sink, &sink_fmt->sink_fmt);
break;
}
}

return 0;
}

Expand Down Expand Up @@ -990,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 @@ -1023,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
15 changes: 1 addition & 14 deletions src/audio/copier/copier_generic.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +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 comp_buffer *sink;
struct list_item *sink_list;

memset(params, 0, sizeof(*params));
Expand Down Expand Up @@ -90,19 +90,6 @@ void copier_update_params(struct copier_data *cd, struct comp_dev *dev,
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
*/
if (!list_is_empty(&dev->bsource_list)) {
struct ipc4_audio_format *in_fmt;

source = list_first_item(&dev->bsource_list, struct comp_buffer, sink_list);

in_fmt = &cd->config.base.audio_fmt;
ipc4_update_buffer_format(source, in_fmt);
}

/* update params for the DMA buffer */
switch (dev->ipc_config.type) {
case SOF_COMP_HOST:
Expand Down