Skip to content

Commit fef0d9d

Browse files
committed
copier: Add bind function to configure sink buffers params
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 <adrian.warecki@intel.com>
1 parent 8bf6cf4 commit fef0d9d

File tree

2 files changed

+29
-16
lines changed

2 files changed

+29
-16
lines changed

src/audio/copier/copier.c

+28-3
Original file line numberDiff line numberDiff line change
@@ -518,9 +518,6 @@ static int copier_module_copy(struct processing_module *mod,
518518
if (sink_queue_id >= IPC4_COPIER_MODULE_OUTPUT_PINS_COUNT)
519519
return -EINVAL;
520520

521-
/* update corresponding sink format in case it isn't updated */
522-
ipc4_update_buffer_format(sink_c, &cd->out_fmt[sink_queue_id]);
523-
524521
comp_get_copy_limits(src_c, sink_c, &processed_data);
525522

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

975+
static int copier_bind(struct processing_module *mod, void *data)
976+
{
977+
const struct ipc4_module_bind_unbind *const bu = (struct ipc4_module_bind_unbind *)data;
978+
const uint32_t src_id = IPC4_COMP_ID(bu->primary.r.module_id, bu->primary.r.instance_id);
979+
const uint32_t src_queue_id = bu->extension.r.src_queue;
980+
struct copier_data *cd = module_get_private_data(mod);
981+
struct comp_dev *dev = mod->dev;
982+
struct list_item *list;
983+
984+
if (dev->ipc_config.id != src_id)
985+
return 0; /* Another component is a data producer */
986+
987+
/* update sink format */
988+
list_for_item(list, &dev->bsink_list) {
989+
struct comp_buffer *buffer = container_of(list, struct comp_buffer, source_list);
990+
uint32_t id = IPC4_SRC_QUEUE_ID(buf_get_id(buffer));
991+
992+
if (src_queue_id == id) {
993+
ipc4_update_buffer_format(buffer, &cd->out_fmt[id]);
994+
return 0;
995+
}
996+
}
997+
998+
comp_err(dev, "No sink buffer found for src_queue = %u", src_queue_id);
999+
return -ENODEV;
1000+
}
1001+
9781002
static int copier_unbind(struct processing_module *mod, void *data)
9791003
{
9801004
struct copier_data *cd = module_get_private_data(mod);
@@ -1008,6 +1032,7 @@ static const struct module_interface copier_interface = {
10081032
.free = copier_free,
10091033
.set_configuration = copier_set_configuration,
10101034
.get_configuration = copier_get_configuration,
1035+
.bind = copier_bind,
10111036
.unbind = copier_unbind,
10121037
.endpoint_ops = &copier_endpoint_ops,
10131038
};

src/audio/copier/copier_generic.c

+1-13
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,7 @@ int apply_attenuation(struct comp_dev *dev, struct copier_data *cd,
6161
void copier_update_params(struct copier_data *cd, struct comp_dev *dev,
6262
struct sof_ipc_stream_params *params)
6363
{
64-
struct comp_buffer *sink, *source;
65-
struct list_item *sink_list;
64+
struct comp_buffer *source;
6665

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

82-
/* update each sink format */
83-
list_for_item(sink_list, &dev->bsink_list) {
84-
int j;
85-
86-
sink = container_of(sink_list, struct comp_buffer, source_list);
87-
88-
j = IPC4_SINK_QUEUE_ID(buf_get_id(sink));
89-
90-
ipc4_update_buffer_format(sink, &cd->out_fmt[j]);
91-
}
92-
9381
/*
9482
* force update the source buffer format to cover cases where the source module
9583
* fails to set the sink buffer params

0 commit comments

Comments
 (0)