codec_adapter: fix for CADENCE codec reset

Codecs which apply to CADENCE API don't have any means
of reset, therefore we need to rework the reset procedure
so cadence codecs can remove all memory allocated by itself
and re-initialize again.

Signed-off-by: Marcin Rajwa <marcin.rajwa@linux.intel.com>
This commit is contained in:
Marcin Rajwa 2020-11-24 21:14:54 +01:00 committed by Liam Girdwood
parent 299ae71771
commit eaa9a55d0b
2 changed files with 19 additions and 7 deletions

View File

@ -254,12 +254,15 @@ err:
int cadence_codec_prepare(struct comp_dev *dev)
{
int ret, mem_tabs_size, lib_init_status;
int ret = 0, mem_tabs_size, lib_init_status;
struct codec_data *codec = comp_get_codec(dev);
struct cadence_codec_data *cd = codec->private;
comp_dbg(dev, "cadence_codec_prepare() start");
if (codec->state == CODEC_PREPARED)
goto done;
API_CALL(cd, XA_API_CMD_INIT, XA_CMD_TYPE_INIT_API_PRE_CONFIG_PARAMS,
NULL, ret);
if (ret != LIB_NO_ERROR) {
@ -345,6 +348,7 @@ int cadence_codec_prepare(struct comp_dev *dev)
free:
codec_free_memory(dev, cd->mem_tabs);
err:
done:
return ret;
}
@ -391,8 +395,19 @@ int cadence_codec_apply_config(struct comp_dev *dev)
int cadence_codec_reset(struct comp_dev *dev)
{
/* Nothing to do */
return 0;
int ret;
/* Current CADENCE API doesn't support reset of codec's
* runtime parameters therefore we need to free all the resources
* and start over.
*/
codec_free_all_memory(dev);
ret = cadence_codec_init(dev);
if (ret) {
comp_err(dev, "cadence_codec_reset() error %x: could not reinitialize codec after reset",
ret);
}
return ret;
}
int cadence_codec_free(struct comp_dev *dev)

View File

@ -217,9 +217,6 @@ int codec_prepare(struct comp_dev *dev)
comp_dbg(dev, "codec_prepare() start");
/* After reset the codec should remain prepared, hence there
* is no need to re-prepare it again.
*/
if (cd->codec.state == CODEC_PREPARED)
return 0;
if (cd->codec.state < CODEC_INITIALIZED)
@ -328,7 +325,7 @@ int codec_reset(struct comp_dev *dev)
/* Codec reset itself to the initial condition after prepare()
* so let's change its state to reflect that.
*/
codec->state = CODEC_PREPARED;
codec->state = CODEC_INITIALIZED;
return 0;
}