Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
e45e82f
codec_adapter: rename codec_interface to module_interface
ranj063 Jan 7, 2022
455c6ee
codec_adapter: dts: check for !cd->ca_source instead of == NULL
ranj063 Jan 7, 2022
dfdf025
codec_adapter: rename struct comp_data to struct processing_module
ranj063 Jan 7, 2022
13b38bb
codec_adapter: rename codec_data to module_data
ranj063 Jan 7, 2022
a07760d
codec_adapter: rename codec_state to module_state
ranj063 Jan 7, 2022
be9ea17
codec_adapter: rename codec_config to module_config
ranj063 Jan 7, 2022
9e3f1e6
codec_adapter: fix typo in comment
ranj063 Jan 7, 2022
4b8bc9c
codec_adapter: rename codec_memory to module_memory
ranj063 Jan 7, 2022
ad599ef
codec_adapter: rename codec_processing_data to module_processing_data
ranj063 Jan 7, 2022
a63a27b
codec_adapter: rename codec_cfg_type to module_cfg_type
ranj063 Jan 7, 2022
a8e8ac3
codec_adapter: rename struct codec_param to module_param
ranj063 Jan 7, 2022
de6b82c
codec_adapter: rename codec_init() to module_init()
ranj063 Jan 8, 2022
6e0e25b
codec_adapter: Rename codec_free() to module_free()
ranj063 Jan 8, 2022
7aa6b3f
codec_adapter: rename codec_reset() to module_reset()
ranj063 Jan 8, 2022
733f7b3
codec_adapter: rename codec_prepare() to module_prepare()
ranj063 Jan 8, 2022
1598bd3
codec_adapter: rename codec_apply_runtime_config()
ranj063 Jan 8, 2022
400da53
codec_adapter: rename codec_process() to module_process()
ranj063 Jan 8, 2022
e4af5fa
codec_adapter: rename codec_load_config()
ranj063 Jan 8, 2022
a0031bf
codec_adapter: rename codec_allocate/free_memory()
ranj063 Jan 8, 2022
a931c9f
codec_adapter: rename codec_free_all_memory()
ranj063 Jan 8, 2022
400d0bb
codec_adapter: rename codec_id in struct ca_config
ranj063 Jan 8, 2022
4be75d3
codec_adapter: rename comp_get_codec()
ranj063 Jan 8, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
96 changes: 48 additions & 48 deletions src/audio/codec_adapter/codec/cadence.c
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ static struct cadence_api cadence_api_table[] = {
int cadence_codec_init(struct comp_dev *dev)
{
int ret;
struct codec_data *codec = comp_get_codec(dev);
struct module_data *codec = comp_get_module_data(dev);
struct cadence_codec_data *cd = NULL;
uint32_t obj_size;
uint32_t no_of_api = ARRAY_SIZE(cadence_api_table);
Expand All @@ -104,14 +104,14 @@ int cadence_codec_init(struct comp_dev *dev)

comp_dbg(dev, "cadence_codec_init() start");

cd = codec_allocate_memory(dev, sizeof(struct cadence_codec_data), 0);
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;
}

codec->private = cd;
codec->cpd.init_done = 0;
codec->mpd.init_done = 0;
cd->self = NULL;
cd->mem_tabs = NULL;
cd->api = NULL;
Expand All @@ -137,22 +137,22 @@ int cadence_codec_init(struct comp_dev *dev)
if (ret != LIB_NO_ERROR) {
comp_err(dev, "cadence_codec_init() error %x: failed to get lib name",
ret);
codec_free_memory(dev, cd);
module_free_memory(dev, cd);
goto out;
}
/* Get codec object size */
API_CALL(cd, XA_API_CMD_GET_API_SIZE, 0, &obj_size, ret);
if (ret != LIB_NO_ERROR) {
comp_err(dev, "cadence_codec_init() error %x: failed to get lib object size",
ret);
codec_free_memory(dev, cd);
module_free_memory(dev, cd);
goto out;
}
/* Allocate space for codec object */
cd->self = codec_allocate_memory(dev, obj_size, 0);
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");
codec_free_memory(dev, cd);
module_free_memory(dev, cd);
goto out;
} else {
comp_dbg(dev, "cadence_codec_init(): allocated %d bytes for lib object",
Expand All @@ -172,19 +172,19 @@ int cadence_codec_init(struct comp_dev *dev)
return ret;
}

static int apply_config(struct comp_dev *dev, enum codec_cfg_type type)
static int apply_config(struct comp_dev *dev, enum module_cfg_type type)
{
int ret = 0;
int size;
struct codec_config *cfg;
struct module_config *cfg;
void *data;
struct codec_param *param;
struct codec_data *codec = comp_get_codec(dev);
struct module_param *param;
struct module_data *codec = comp_get_module_data(dev);
struct cadence_codec_data *cd = codec->private;

comp_dbg(dev, "apply_config() start");

cfg = (type == CODEC_CFG_SETUP) ? &codec->s_cfg :
cfg = (type == MODULE_CFG_SETUP) ? &codec->s_cfg :
&codec->r_cfg;
data = cfg->data;
size = cfg->size;
Expand Down Expand Up @@ -228,7 +228,7 @@ static int init_memory_tables(struct comp_dev *dev)
{
int ret, no_mem_tables, i, mem_type, mem_size, mem_alignment;
void *ptr, *scratch, *persistent;
struct codec_data *codec = comp_get_codec(dev);
struct module_data *codec = comp_get_module_data(dev);
struct cadence_codec_data *cd = codec->private;

scratch = NULL;
Expand Down Expand Up @@ -277,7 +277,7 @@ static int init_memory_tables(struct comp_dev *dev)
goto err;
}
/* Allocate memory for this type, taking alignment into account */
ptr = codec_allocate_memory(dev, mem_size, mem_alignment);
ptr = module_allocate_memory(dev, mem_size, mem_alignment);
if (!ptr) {
comp_err(dev, "init_memory_tables() error %x: failed to allocate memory for %d",
ret, mem_type);
Expand All @@ -300,12 +300,12 @@ static int init_memory_tables(struct comp_dev *dev)
persistent = ptr;
break;
case XA_MEMTYPE_INPUT:
codec->cpd.in_buff = ptr;
codec->cpd.in_buff_size = mem_size;
codec->mpd.in_buff = ptr;
codec->mpd.in_buff_size = mem_size;
break;
case XA_MEMTYPE_OUTPUT:
codec->cpd.out_buff = ptr;
codec->cpd.out_buff_size = mem_size;
codec->mpd.out_buff = ptr;
codec->mpd.out_buff_size = mem_size;
break;
default:
comp_err(dev, "init_memory_tables() error %x: unrecognized memory type!",
Expand All @@ -321,19 +321,19 @@ static int init_memory_tables(struct comp_dev *dev)
return 0;
err:
if (scratch)
codec_free_memory(dev, scratch);
module_free_memory(dev, scratch);
if (persistent)
codec_free_memory(dev, persistent);
if (codec->cpd.in_buff)
codec_free_memory(dev, codec->cpd.in_buff);
if (codec->cpd.out_buff)
codec_free_memory(dev, codec->cpd.out_buff);
module_free_memory(dev, persistent);
if (codec->mpd.in_buff)
module_free_memory(dev, codec->mpd.in_buff);
if (codec->mpd.out_buff)
module_free_memory(dev, codec->mpd.out_buff);
return ret;
}

static int cadence_codec_get_samples(struct comp_dev *dev)
{
struct codec_data *codec = comp_get_codec(dev);
struct module_data *codec = comp_get_module_data(dev);
uint32_t api_id = CODEC_GET_API_ID(codec->id);

comp_dbg(dev, "cadence_codec_get_samples() start");
Expand All @@ -356,10 +356,10 @@ static int cadence_codec_get_samples(struct comp_dev *dev)
static int cadence_codec_init_process(struct comp_dev *dev)
{
int ret;
struct codec_data *codec = comp_get_codec(dev);
struct module_data *codec = comp_get_module_data(dev);
struct cadence_codec_data *cd = codec->private;

API_CALL(cd, XA_API_CMD_SET_INPUT_BYTES, 0, &codec->cpd.avail, ret);
API_CALL(cd, XA_API_CMD_SET_INPUT_BYTES, 0, &codec->mpd.avail, ret);
if (ret != LIB_NO_ERROR) {
comp_err(dev, "cadence_codec_init_process() error %x: failed to set size of input data",
ret);
Expand All @@ -374,14 +374,14 @@ static int cadence_codec_init_process(struct comp_dev *dev)
}

API_CALL(cd, XA_API_CMD_INIT, XA_CMD_TYPE_INIT_DONE_QUERY,
&codec->cpd.init_done, ret);
&codec->mpd.init_done, ret);
if (ret != LIB_NO_ERROR) {
comp_err(dev, "cadence_codec_init_process() error %x: failed to get lib init status",
ret);
return ret;
}

API_CALL(cd, XA_API_CMD_GET_CURIDX_INPUT_BUF, 0, &codec->cpd.consumed, ret);
API_CALL(cd, XA_API_CMD_GET_CURIDX_INPUT_BUF, 0, &codec->mpd.consumed, ret);
if (ret != LIB_NO_ERROR) {
comp_err(dev, "cadence_codec_init_process() error %x: could not get consumed bytes",
ret);
Expand All @@ -393,7 +393,7 @@ static int cadence_codec_init_process(struct comp_dev *dev)
int cadence_codec_prepare(struct comp_dev *dev)
{
int ret = 0, mem_tabs_size;
struct codec_data *codec = comp_get_codec(dev);
struct module_data *codec = comp_get_module_data(dev);
struct cadence_codec_data *cd = codec->private;

comp_dbg(dev, "cadence_codec_prepare() start");
Expand All @@ -407,7 +407,7 @@ int cadence_codec_prepare(struct comp_dev *dev)
comp_warn(dev, "cadence_codec_prepare(): no new setup configuration available, using the old one");
codec->s_cfg.avail = true;
}
ret = apply_config(dev, CODEC_CFG_SETUP);
ret = apply_config(dev, MODULE_CFG_SETUP);
if (ret) {
comp_err(dev, "cadence_codec_prepare() error %x: failed to applay setup config",
ret);
Expand All @@ -420,7 +420,7 @@ int cadence_codec_prepare(struct comp_dev *dev)

/* Runtime config */
if (codec->r_cfg.avail) {
ret = apply_config(dev, CODEC_CFG_RUNTIME);
ret = apply_config(dev, MODULE_CFG_RUNTIME);
if (ret) {
comp_err(dev, "cadence_codec_prepare() error %x: failed to applay runtime config",
ret);
Expand All @@ -436,7 +436,7 @@ int cadence_codec_prepare(struct comp_dev *dev)
goto err;
}

cd->mem_tabs = codec_allocate_memory(dev, mem_tabs_size, 4);
cd->mem_tabs = module_allocate_memory(dev, mem_tabs_size, 4);
if (!cd->mem_tabs) {
comp_err(dev, "cadence_codec_prepare() error: failed to allocate space for memtabs");
ret = -ENOMEM;
Expand Down Expand Up @@ -472,7 +472,7 @@ int cadence_codec_prepare(struct comp_dev *dev)
* in codec_adapter_copy().
*/
API_CALL(cd, XA_API_CMD_INIT, XA_CMD_TYPE_INIT_DONE_QUERY,
&codec->cpd.init_done, ret);
&codec->mpd.init_done, ret);
if (ret != LIB_NO_ERROR) {
comp_err(dev, "cadence_codec_init_process() error %x: failed to get lib init status",
ret);
Expand All @@ -482,24 +482,24 @@ int cadence_codec_prepare(struct comp_dev *dev)
comp_dbg(dev, "cadence_codec_prepare() done");
return 0;
free:
codec_free_memory(dev, cd->mem_tabs);
module_free_memory(dev, cd->mem_tabs);
err:
return ret;
}

int cadence_codec_process(struct comp_dev *dev)
{
struct comp_data *comp_data = comp_get_drvdata(dev);
struct comp_buffer *local_buff = comp_data->local_buff;
struct codec_data *codec = comp_get_codec(dev);
struct processing_module *mod = comp_get_drvdata(dev);
struct comp_buffer *local_buff = mod->local_buff;
struct module_data *codec = comp_get_module_data(dev);
struct cadence_codec_data *cd = codec->private;
int ret;

/* do not proceed with processing if not enough free left in the local buffer */
if (codec->cpd.init_done) {
if (codec->mpd.init_done) {
int output_bytes = cadence_codec_get_samples(dev) *
comp_data->stream_params.sample_container_bytes *
comp_data->stream_params.channels;
mod->stream_params.sample_container_bytes *
mod->stream_params.channels;

if (local_buff->stream.free < output_bytes)
return -ENOSPC;
Expand All @@ -509,7 +509,7 @@ int cadence_codec_process(struct comp_dev *dev)

comp_dbg(dev, "cadence_codec_process() start");

API_CALL(cd, XA_API_CMD_SET_INPUT_BYTES, 0, &codec->cpd.avail, ret);
API_CALL(cd, XA_API_CMD_SET_INPUT_BYTES, 0, &codec->mpd.avail, ret);
if (ret != LIB_NO_ERROR) {
comp_err(dev, "cadence_codec_process() error %x: failed to set size of input data",
ret);
Expand All @@ -523,14 +523,14 @@ int cadence_codec_process(struct comp_dev *dev)
goto err;
}

API_CALL(cd, XA_API_CMD_GET_OUTPUT_BYTES, 0, &codec->cpd.produced, ret);
API_CALL(cd, XA_API_CMD_GET_OUTPUT_BYTES, 0, &codec->mpd.produced, ret);
if (ret != LIB_NO_ERROR) {
comp_err(dev, "cadence_codec_process() error %x: could not get produced bytes",
ret);
goto err;
}

API_CALL(cd, XA_API_CMD_GET_CURIDX_INPUT_BUF, 0, &codec->cpd.consumed, ret);
API_CALL(cd, XA_API_CMD_GET_CURIDX_INPUT_BUF, 0, &codec->mpd.consumed, ret);
if (ret != LIB_NO_ERROR) {
comp_err(dev, "cadence_codec_process() error %x: could not get consumed bytes",
ret);
Expand All @@ -546,7 +546,7 @@ int cadence_codec_process(struct comp_dev *dev)

int cadence_codec_apply_config(struct comp_dev *dev)
{
return apply_config(dev, CODEC_CFG_RUNTIME);
return apply_config(dev, MODULE_CFG_RUNTIME);
}

int cadence_codec_reset(struct comp_dev *dev)
Expand All @@ -557,7 +557,7 @@ int cadence_codec_reset(struct comp_dev *dev)
* runtime parameters therefore we need to free all the resources
* and start over.
*/
codec_free_all_memory(dev);
module_free_all_memory(dev);
ret = cadence_codec_init(dev);
if (ret) {
comp_err(dev, "cadence_codec_reset() error %x: could not re-initialize codec after reset",
Expand All @@ -575,11 +575,11 @@ int cadence_codec_reset(struct comp_dev *dev)

int cadence_codec_free(struct comp_dev *dev)
{
codec_free_all_memory(dev);
module_free_all_memory(dev);
return 0;
}

static struct codec_interface cadence_interface = {
static struct module_interface cadence_interface = {
.init = cadence_codec_init,
.prepare = cadence_codec_prepare,
.process = cadence_codec_process,
Expand Down
Loading