Revert "codec_adapter: cadence: Do not free codec data during reset"

This reverts commit a60df96c7d.
This commit is contained in:
Liam Girdwood 2022-01-21 12:01:42 +00:00
parent a60df96c7d
commit 82fcef457d
1 changed files with 12 additions and 19 deletions

View File

@ -106,7 +106,7 @@ static int cadence_codec_init(struct comp_dev *dev)
comp_dbg(dev, "cadence_codec_init() start");
cd = rballoc(0, SOF_MEM_CAPS_RAM, sizeof(struct cadence_codec_data));
cd = module_allocate_memory(dev, sizeof(struct cadence_codec_data), 0);
if (!cd) {
comp_err(dev, "cadence_codec_init(): failed to allocate memory for cadence codec data");
return -ENOMEM;
@ -176,7 +176,7 @@ static int cadence_codec_init(struct comp_dev *dev)
goto free;
}
/* Allocate space for codec object */
cd->self = rballoc(0, SOF_MEM_CAPS_RAM, obj_size);
cd->self = module_allocate_memory(dev, obj_size, 0);
if (!cd->self) {
comp_err(dev, "cadence_codec_init(): failed to allocate space for lib object");
ret = -ENOMEM;
@ -188,16 +188,14 @@ static int cadence_codec_init(struct comp_dev *dev)
/* Set all params to their default values */
API_CALL(cd, XA_API_CMD_INIT, XA_CMD_TYPE_INIT_API_PRE_CONFIG_PARAMS,
NULL, ret);
if (ret != LIB_NO_ERROR) {
rfree(cd->self);
if (ret != LIB_NO_ERROR)
goto free;
}
comp_dbg(dev, "cadence_codec_init() done");
return 0;
free:
rfree(cd);
module_free_memory(dev, cd);
return ret;
}
@ -549,21 +547,18 @@ static int cadence_codec_process(struct comp_dev *dev)
static int cadence_codec_reset(struct comp_dev *dev)
{
struct module_data *codec = comp_get_module_data(dev);
struct cadence_codec_data *cd = codec->private;
int ret;
/*
* Current CADENCE API doesn't support reset of codec's runtime parameters.
* So, free all memory associated with runtime params. These will be reallocated during
* prepare.
/* Current CADENCE API doesn't support reset of codec's
* runtime parameters therefore we need to free all the resources
* and start over.
*/
module_free_all_memory(dev);
/* reset to default params */
API_CALL(cd, XA_API_CMD_INIT, XA_CMD_TYPE_INIT_API_PRE_CONFIG_PARAMS, NULL, ret);
if (ret != LIB_NO_ERROR)
return ret;
ret = cadence_codec_init(dev);
if (ret) {
comp_err(dev, "cadence_codec_reset() error %x: could not re-initialize codec after reset",
ret);
}
ret = cadence_codec_prepare(dev);
if (ret) {
@ -581,8 +576,6 @@ static int cadence_codec_free(struct comp_dev *dev)
rfree(cd->setup_cfg.data);
module_free_all_memory(dev);
rfree(cd->self);
rfree(cd);
return 0;
}