mirror of https://github.com/thesofproject/sof.git
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:
parent
e79893ee02
commit
9c660ec6a6
|
@ -369,8 +369,8 @@ int codec_free(struct comp_dev *dev)
|
||||||
codec->r_cfg.size = 0;
|
codec->r_cfg.size = 0;
|
||||||
rfree(codec->r_cfg.data);
|
rfree(codec->r_cfg.data);
|
||||||
rfree(codec->s_cfg.data);
|
rfree(codec->s_cfg.data);
|
||||||
if (cd->runtime_params)
|
if (codec->runtime_params)
|
||||||
rfree(cd->runtime_params);
|
rfree(codec->runtime_params);
|
||||||
|
|
||||||
codec->state = CODEC_DISABLED;
|
codec->state = CODEC_DISABLED;
|
||||||
|
|
||||||
|
|
|
@ -358,6 +358,7 @@ static int codec_adapter_set_params(struct comp_dev *dev, struct sof_ipc_ctrl_da
|
||||||
static uint32_t size;
|
static uint32_t size;
|
||||||
uint32_t offset;
|
uint32_t offset;
|
||||||
struct comp_data *cd = comp_get_drvdata(dev);
|
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",
|
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);
|
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) {
|
if (cdata->msg_index == 0) {
|
||||||
size = cdata->num_elems + cdata->elems_remaining;
|
size = cdata->num_elems + cdata->elems_remaining;
|
||||||
/* Check that there is no work-in-progress on previous request */
|
/* 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");
|
comp_err(dev, "codec_adapter_set_params() error: busy with previous request");
|
||||||
ret = -EBUSY;
|
ret = -EBUSY;
|
||||||
goto end;
|
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 */
|
/* Allocate buffer for new params */
|
||||||
cd->runtime_params = rballoc(0, SOF_MEM_CAPS_RAM, size);
|
codec->runtime_params = rballoc(0, SOF_MEM_CAPS_RAM, size);
|
||||||
if (!cd->runtime_params) {
|
if (!codec->runtime_params) {
|
||||||
comp_err(dev, "codec_adapter_set_params(): space allocation for new params failed");
|
comp_err(dev, "codec_adapter_set_params(): space allocation for new params failed");
|
||||||
ret = -ENOMEM;
|
ret = -ENOMEM;
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
|
||||||
memset(cd->runtime_params, 0, size);
|
memset(codec->runtime_params, 0, size);
|
||||||
} else if (!cd->runtime_params) {
|
} else if (!codec->runtime_params) {
|
||||||
comp_err(dev, "codec_adapter_set_params() error: no memory available for runtime params in consecutive load");
|
comp_err(dev, "codec_adapter_set_params() error: no memory available for runtime params in consecutive load");
|
||||||
ret = -EIO;
|
ret = -EIO;
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
|
||||||
offset = size - (cdata->num_elems + cdata->elems_remaining);
|
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;
|
src = (char *)cdata->data->data;
|
||||||
|
|
||||||
ret = memcpy_s(dst, size - offset, src, cdata->num_elems);
|
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) {
|
if (!cdata->elems_remaining) {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case CODEC_CFG_SETUP:
|
case CODEC_CFG_SETUP:
|
||||||
ret = load_setup_config(dev, cd->runtime_params, size);
|
ret = load_setup_config(dev, codec->runtime_params, size);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
comp_err(dev, "codec_adapter_set_params(): error %d: load of setup config failed.",
|
comp_err(dev, "codec_adapter_set_params(): error %d: load of setup config failed.",
|
||||||
ret);
|
ret);
|
||||||
|
@ -425,7 +426,7 @@ static int codec_adapter_set_params(struct comp_dev *dev, struct sof_ipc_ctrl_da
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case CODEC_CFG_RUNTIME:
|
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);
|
CODEC_CFG_RUNTIME);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
comp_err(dev, "codec_adapter_set_params() error %d: load of runtime config failed.",
|
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;
|
goto end;
|
||||||
|
|
||||||
done:
|
done:
|
||||||
if (cd->runtime_params)
|
if (codec->runtime_params)
|
||||||
rfree(cd->runtime_params);
|
rfree(codec->runtime_params);
|
||||||
cd->runtime_params = NULL;
|
codec->runtime_params = NULL;
|
||||||
return ret;
|
return ret;
|
||||||
end:
|
end:
|
||||||
return ret;
|
return ret;
|
||||||
|
|
|
@ -167,10 +167,11 @@ struct codec_processing_data {
|
||||||
struct codec_data {
|
struct codec_data {
|
||||||
uint32_t id;
|
uint32_t id;
|
||||||
enum codec_state state;
|
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 s_cfg; /**< setup config */
|
||||||
struct codec_config r_cfg; /**< runtime config */
|
struct codec_config r_cfg; /**< runtime config */
|
||||||
struct codec_interface *ops; /**< codec specific operations */
|
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_memory memory; /**< memory allocated by codec */
|
||||||
struct codec_processing_data cpd; /**< shared data comp <-> 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 codec_data codec; /**< codec private data */
|
||||||
struct comp_buffer *ca_sink;
|
struct comp_buffer *ca_sink;
|
||||||
struct comp_buffer *ca_source;
|
struct comp_buffer *ca_source;
|
||||||
void *runtime_params;
|
|
||||||
struct sof_ipc_stream_params stream_params;
|
struct sof_ipc_stream_params stream_params;
|
||||||
uint32_t period_bytes; /** pipeline period bytes */
|
uint32_t period_bytes; /** pipeline period bytes */
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue