Skip to content

Commit 9f358b9

Browse files
committed
copier: Add bind function to configure source/sink buffers params
Setting the source/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 configurations to the new copier_bind bind function. Delete the sink buffers configurations 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 6c9df30 commit 9f358b9

File tree

2 files changed

+44
-30
lines changed

2 files changed

+44
-30
lines changed

src/audio/copier/copier.c

+44-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 *
@@ -990,6 +987,49 @@ static int copier_get_hw_params(struct comp_dev *dev, struct sof_ipc_stream_para
990987
return dai_common_get_hw_params(dd, dev, params, dir);
991988
}
992989

990+
static int copier_bind(struct processing_module *mod, void *data)
991+
{
992+
const struct ipc4_module_bind_unbind *const bu = (struct ipc4_module_bind_unbind *)data;
993+
struct copier_data *cd = module_get_private_data(mod);
994+
struct comp_dev *dev = mod->dev;
995+
struct comp_buffer *buffer;
996+
uint32_t src_id, sink_id;
997+
struct list_item *list;
998+
999+
src_id = IPC4_COMP_ID(bu->primary.r.module_id, bu->primary.r.instance_id);
1000+
sink_id = IPC4_COMP_ID(bu->extension.r.dst_module_id, bu->extension.r.dst_instance_id);
1001+
1002+
if (dev->ipc_config.id == src_id) {
1003+
/* update sink format */
1004+
list_for_item(list, &dev->bsink_list) {
1005+
buffer = container_of(list, struct comp_buffer, source_list);
1006+
uint32_t id = IPC4_SINK_QUEUE_ID(buf_get_id(buffer));
1007+
1008+
if (bu->extension.r.src_queue == id) {
1009+
ipc4_update_buffer_format(buffer, &cd->out_fmt[id]);
1010+
break;
1011+
}
1012+
}
1013+
} else if (dev->ipc_config.id == sink_id) {
1014+
/*
1015+
* force update the source buffer format to cover cases where the source module
1016+
* fails to set the sink buffer params
1017+
*/
1018+
if (!list_is_empty(&dev->bsource_list)) {
1019+
const struct ipc4_audio_format *const in_fmt = &cd->config.base.audio_fmt;
1020+
1021+
buffer = list_first_item(&dev->bsource_list, struct comp_buffer, sink_list);
1022+
1023+
ipc4_update_buffer_format(buffer, in_fmt);
1024+
}
1025+
} else {
1026+
comp_err(dev, "Invalid bind request %x -> %x", src_id, sink_id);
1027+
return -EINVAL;
1028+
}
1029+
1030+
return 0;
1031+
}
1032+
9931033
static int copier_unbind(struct processing_module *mod, void *data)
9941034
{
9951035
struct copier_data *cd = module_get_private_data(mod);
@@ -1023,6 +1063,7 @@ static const struct module_interface copier_interface = {
10231063
.free = copier_free,
10241064
.set_configuration = copier_set_configuration,
10251065
.get_configuration = copier_get_configuration,
1066+
.bind = copier_bind,
10261067
.unbind = copier_unbind,
10271068
.endpoint_ops = &copier_endpoint_ops,
10281069
};

src/audio/copier/copier_generic.c

-27
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,6 @@ 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;
66-
6764
memset(params, 0, sizeof(*params));
6865
params->direction = cd->direction;
6966
params->channels = cd->config.base.audio_fmt.channels_count;
@@ -79,30 +76,6 @@ void copier_update_params(struct copier_data *cd, struct comp_dev *dev,
7976
/* disable ipc3 stream position */
8077
params->no_stream_position = 1;
8178

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-
93-
/*
94-
* force update the source buffer format to cover cases where the source module
95-
* fails to set the sink buffer params
96-
*/
97-
if (!list_is_empty(&dev->bsource_list)) {
98-
struct ipc4_audio_format *in_fmt;
99-
100-
source = list_first_item(&dev->bsource_list, struct comp_buffer, sink_list);
101-
102-
in_fmt = &cd->config.base.audio_fmt;
103-
ipc4_update_buffer_format(source, in_fmt);
104-
}
105-
10679
/* update params for the DMA buffer */
10780
switch (dev->ipc_config.type) {
10881
case SOF_COMP_HOST:

0 commit comments

Comments
 (0)