Skip to content

Commit

Permalink
copier: store gateway config in copier_data
Browse files Browse the repository at this point in the history
Calculate actual size of copier module gateway config. Copy
and store it in copier_data. It needs to be available even
after copier is created e.g. during SET_PIPELINE_STATE IPC
when dai_config_dma_channel() is called second time and
DMA config is used to assing dma_channel_id value.

Signed-off-by: Ievgen Ganakov <ievgen.ganakov@intel.com>
  • Loading branch information
iganakov committed Oct 31, 2023
1 parent 8b5aaf7 commit 01f03d2
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 2 deletions.
34 changes: 33 additions & 1 deletion src/audio/copier/copier.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ static int copier_init(struct processing_module *mod)
struct module_data *md = &mod->priv;
struct ipc4_copier_module_cfg *copier = (struct ipc4_copier_module_cfg *)md->cfg.init_data;
struct comp_ipc_config *config = &dev->ipc_config;
void *gtw_cfg;
size_t gtw_cfg_size;
int i, ret = 0;

cd = rzalloc(SOF_MEM_ZONE_RUNTIME, 0, SOF_MEM_CAPS_RAM, sizeof(*cd));
Expand All @@ -78,7 +80,33 @@ static int copier_init(struct processing_module *mod)
*/
if (memcpy_s(&cd->config, sizeof(cd->config), copier, sizeof(*copier)) < 0) {
ret = -EINVAL;
goto error;
goto error_cd;
}

/* Allocate memory and store gateway_cfg in runtime. Gateway cfg has to
* be kept even after copier is created e.g. during SET_PIPELINE_STATE
* IPC when dai_config_dma_channel() is called second time and DMA
* config is used to assign dma_channel_id value.
*/
if (copier->gtw_cfg.config_length) {
gtw_cfg_size = copier->gtw_cfg.config_length << 2;
gtw_cfg = rzalloc(SOF_MEM_ZONE_RUNTIME, 0, SOF_MEM_CAPS_RAM,
gtw_cfg_size);
if (!gtw_cfg) {
ret = -ENOMEM;
goto error_cd;
}

ret = memcpy_s(gtw_cfg, gtw_cfg_size, &copier->gtw_cfg.config_data,
gtw_cfg_size);
if (ret < 0) {
comp_err(dev, "Unable to copy gateway config from copier blob");
goto error;
}

cd->gtw_cfg = gtw_cfg;
} else {
cd->gtw_cfg = NULL;
}

for (i = 0; i < IPC4_COPIER_MODULE_OUTPUT_PINS_COUNT; i++)
Expand Down Expand Up @@ -146,6 +174,8 @@ static int copier_init(struct processing_module *mod)
dev->state = COMP_STATE_READY;
return 0;
error:
rfree(gtw_cfg);
error_cd:
rfree(cd);
return ret;
}
Expand All @@ -170,6 +200,8 @@ static int copier_free(struct processing_module *mod)
break;
}

if (cd)
rfree(cd->gtw_cfg);
rfree(cd);

return 0;
Expand Down
3 changes: 2 additions & 1 deletion src/include/ipc4/copier.h
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ struct ipc4_copier_module_cfg {
/* audio format for output pin 0 */
struct ipc4_audio_format out_fmt;
uint32_t copier_feature_mask;
struct ipc4_copier_gateway_cfg gtw_cfg;
struct ipc4_copier_gateway_cfg gtw_cfg;
} __attribute__((packed, aligned(4)));

enum ipc4_copier_module_config_params {
Expand Down Expand Up @@ -242,6 +242,7 @@ struct copier_data {
* from the IPC data.
*/
struct ipc4_copier_module_cfg config;
void *gtw_cfg;
struct comp_dev *endpoint[IPC4_COPIER_MODULE_OUTPUT_PINS_COUNT];
struct comp_buffer *endpoint_buffer[IPC4_COPIER_MODULE_OUTPUT_PINS_COUNT];
uint32_t endpoint_num;
Expand Down

0 comments on commit 01f03d2

Please sign in to comment.