codec_adapter: move runtime params to codec_data

The runtime_params keeps configuration of codec therefore
codec_data structure is a better place to store it.

Signed-off-by: Marcin Rajwa <marcin.rajwa@linux.intel.com>
This commit is contained in:
Marcin Rajwa 2020-11-23 17:21:04 +01:00 committed by Liam Girdwood
parent e79893ee02
commit 9c660ec6a6
3 changed files with 16 additions and 15 deletions

View File

@ -369,8 +369,8 @@ int codec_free(struct comp_dev *dev)
codec->r_cfg.size = 0;
rfree(codec->r_cfg.data);
rfree(codec->s_cfg.data);
if (cd->runtime_params)
rfree(cd->runtime_params);
if (codec->runtime_params)
rfree(codec->runtime_params);
codec->state = CODEC_DISABLED;

View File

@ -358,6 +358,7 @@ static int codec_adapter_set_params(struct comp_dev *dev, struct sof_ipc_ctrl_da
static uint32_t size;
uint32_t offset;
struct comp_data *cd = comp_get_drvdata(dev);
struct codec_data *codec = &cd->codec;
comp_dbg(dev, "codec_adapter_set_params(): start: num_of_elem %d, elem remain %d msg_index %u",
cdata->num_elems, cdata->elems_remaining, cdata->msg_index);
@ -366,7 +367,7 @@ static int codec_adapter_set_params(struct comp_dev *dev, struct sof_ipc_ctrl_da
if (cdata->msg_index == 0) {
size = cdata->num_elems + cdata->elems_remaining;
/* Check that there is no work-in-progress on previous request */
if (cd->runtime_params) {
if (codec->runtime_params) {
comp_err(dev, "codec_adapter_set_params() error: busy with previous request");
ret = -EBUSY;
goto end;
@ -388,22 +389,22 @@ static int codec_adapter_set_params(struct comp_dev *dev, struct sof_ipc_ctrl_da
}
/* Allocate buffer for new params */
cd->runtime_params = rballoc(0, SOF_MEM_CAPS_RAM, size);
if (!cd->runtime_params) {
codec->runtime_params = rballoc(0, SOF_MEM_CAPS_RAM, size);
if (!codec->runtime_params) {
comp_err(dev, "codec_adapter_set_params(): space allocation for new params failed");
ret = -ENOMEM;
goto end;
}
memset(cd->runtime_params, 0, size);
} else if (!cd->runtime_params) {
memset(codec->runtime_params, 0, size);
} else if (!codec->runtime_params) {
comp_err(dev, "codec_adapter_set_params() error: no memory available for runtime params in consecutive load");
ret = -EIO;
goto end;
}
offset = size - (cdata->num_elems + cdata->elems_remaining);
dst = (char *)cd->runtime_params + offset;
dst = (char *)codec->runtime_params + offset;
src = (char *)cdata->data->data;
ret = memcpy_s(dst, size - offset, src, cdata->num_elems);
@ -415,7 +416,7 @@ static int codec_adapter_set_params(struct comp_dev *dev, struct sof_ipc_ctrl_da
if (!cdata->elems_remaining) {
switch (type) {
case CODEC_CFG_SETUP:
ret = load_setup_config(dev, cd->runtime_params, size);
ret = load_setup_config(dev, codec->runtime_params, size);
if (ret) {
comp_err(dev, "codec_adapter_set_params(): error %d: load of setup config failed.",
ret);
@ -425,7 +426,7 @@ static int codec_adapter_set_params(struct comp_dev *dev, struct sof_ipc_ctrl_da
break;
case CODEC_CFG_RUNTIME:
ret = codec_load_config(dev, cd->runtime_params, size,
ret = codec_load_config(dev, codec->runtime_params, size,
CODEC_CFG_RUNTIME);
if (ret) {
comp_err(dev, "codec_adapter_set_params() error %d: load of runtime config failed.",
@ -459,9 +460,9 @@ static int codec_adapter_set_params(struct comp_dev *dev, struct sof_ipc_ctrl_da
goto end;
done:
if (cd->runtime_params)
rfree(cd->runtime_params);
cd->runtime_params = NULL;
if (codec->runtime_params)
rfree(codec->runtime_params);
codec->runtime_params = NULL;
return ret;
end:
return ret;

View File

@ -167,10 +167,11 @@ struct codec_processing_data {
struct codec_data {
uint32_t id;
enum codec_state state;
void *private; /**< self object, memory tables etc here */
void *runtime_params;
struct codec_config s_cfg; /**< setup config */
struct codec_config r_cfg; /**< runtime config */
struct codec_interface *ops; /**< codec specific operations */
void *private; /**< self object, memory tables etc here */
struct codec_memory memory; /**< memory allocated by codec */
struct codec_processing_data cpd; /**< shared data comp <-> codec */
};
@ -182,7 +183,6 @@ struct comp_data {
struct codec_data codec; /**< codec private data */
struct comp_buffer *ca_sink;
struct comp_buffer *ca_source;
void *runtime_params;
struct sof_ipc_stream_params stream_params;
uint32_t period_bytes; /** pipeline period bytes */
};