copier: store gateway config in copier_data

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 assign dma_channel_id value.

Signed-off-by: Ievgen Ganakov <ievgen.ganakov@intel.com>
This commit is contained in:
Ievgen Ganakov 2023-09-08 12:17:20 +02:00 committed by Kai Vehmanen
parent 79f914e8ab
commit 8b08e79e36
2 changed files with 33 additions and 2 deletions

View File

@ -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 = NULL;
size_t gtw_cfg_size;
int i, ret = 0;
cd = rzalloc(SOF_MEM_ZONE_RUNTIME, 0, SOF_MEM_CAPS_RAM, sizeof(*cd));
@ -78,7 +80,31 @@ 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 = rmalloc(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) {
comp_err(dev, "Unable to copy gateway config from copier blob");
goto error;
}
cd->gtw_cfg = gtw_cfg;
}
for (i = 0; i < IPC4_COPIER_MODULE_OUTPUT_PINS_COUNT; i++)
@ -148,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;
}
@ -172,6 +200,8 @@ static int copier_free(struct processing_module *mod)
break;
}
if (cd)
rfree(cd->gtw_cfg);
rfree(cd);
return 0;

View File

@ -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 {
@ -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;