Skip to content

Commit c44f608

Browse files
committed
audio: cadence: add optional API error reporting
Extend cadence_codec_process_data() with an optional output parameter for returning Cadence API error codes while preserving existing return behavior: non-fatal API errors still return 0 and fatal errors are returned. Suppress non-fatal warning prints in this path and add lightweight overwrite tracing for repeated API error updates. Update cadence IPC3 and IPC4 call sites to pass NULL for now. Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
1 parent a32d983 commit c44f608

File tree

4 files changed

+29
-7
lines changed

4 files changed

+29
-7
lines changed

src/audio/module_adapter/module/cadence.c

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -471,14 +471,30 @@ int cadence_codec_resolve_api_with_id(struct processing_module *mod, uint32_t co
471471
return 0;
472472
}
473473

474-
int cadence_codec_process_data(struct processing_module *mod)
474+
static void cadence_store_api_error_code(struct comp_dev *dev, int *api_error_code,
475+
int ret, const char *cmd_name)
476+
{
477+
if (!api_error_code)
478+
return;
479+
480+
if (*api_error_code && *api_error_code != ret)
481+
comp_dbg(dev, "overwriting api error code at %s: old %#x new %#x",
482+
cmd_name, *api_error_code, ret);
483+
484+
*api_error_code = ret;
485+
}
486+
487+
int cadence_codec_process_data(struct processing_module *mod, int *api_error_code)
475488
{
476489
struct cadence_codec_data *cd = module_get_private_data(mod);
477490
struct module_data *codec = &mod->priv;
478491
struct comp_dev *dev = mod->dev;
479492
uint32_t done = 0;
480493
int ret;
481494

495+
if (api_error_code)
496+
*api_error_code = 0;
497+
482498
if (codec->mpd.eos_reached) {
483499
codec->mpd.produced = 0;
484500
codec->mpd.consumed = 0;
@@ -490,11 +506,13 @@ int cadence_codec_process_data(struct processing_module *mod)
490506
/* Signal that the stream is expected to end anytime soon */
491507
API_CALL(cd, XA_API_CMD_INPUT_OVER, 0, NULL, ret);
492508
if (ret != LIB_NO_ERROR) {
509+
if (api_error_code)
510+
*api_error_code = ret;
511+
493512
if (LIB_IS_FATAL_ERROR(ret)) {
494513
comp_err(dev, "input_over failed with error: %x", ret);
495514
return ret;
496515
}
497-
comp_warn(dev, "input_over failed with nonfatal error: %x", ret);
498516
}
499517
}
500518

@@ -506,20 +524,24 @@ int cadence_codec_process_data(struct processing_module *mod)
506524

507525
API_CALL(cd, XA_API_CMD_EXECUTE, XA_CMD_TYPE_DO_EXECUTE, NULL, ret);
508526
if (ret != LIB_NO_ERROR) {
527+
cadence_store_api_error_code(dev, api_error_code, ret,
528+
"XA_API_CMD_EXECUTE_DO_EXECUTE");
529+
509530
if (LIB_IS_FATAL_ERROR(ret)) {
510531
comp_err(dev, "processing failed with error: %x", ret);
511532
return ret;
512533
}
513-
comp_warn(dev, "processing failed with nonfatal error: %x", ret);
514534
}
515535

516536
API_CALL(cd, XA_API_CMD_EXECUTE, XA_CMD_TYPE_DONE_QUERY, &done, ret);
517537
if (ret != LIB_NO_ERROR) {
538+
cadence_store_api_error_code(dev, api_error_code, ret,
539+
"XA_API_CMD_EXECUTE_DONE_QUERY");
540+
518541
if (LIB_IS_FATAL_ERROR(ret)) {
519542
comp_err(dev, "done query failed with error: %x", ret);
520543
return ret;
521544
}
522-
comp_warn(dev, "done query failed with nonfatal error: %x", ret);
523545
}
524546

525547
API_CALL(cd, XA_API_CMD_GET_OUTPUT_BYTES, 0, &codec->mpd.produced, ret);

src/audio/module_adapter/module/cadence_ipc3.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ cadence_codec_process(struct processing_module *mod,
264264

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

267-
ret = cadence_codec_process_data(mod);
267+
ret = cadence_codec_process_data(mod, NULL);
268268
if (ret)
269269
return ret;
270270

src/audio/module_adapter/module/cadence_ipc4.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -465,7 +465,7 @@ static int cadence_codec_process(struct processing_module *mod, struct sof_sourc
465465

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

468-
ret = cadence_codec_process_data(mod);
468+
ret = cadence_codec_process_data(mod, NULL);
469469
if (ret) {
470470
source_release_data(sources[0], 0);
471471
return ret;

src/include/sof/audio/module_adapter/module/cadence.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ int cadence_codec_set_configuration(struct processing_module *mod, uint32_t conf
9696
int cadence_codec_resolve_api_with_id(struct processing_module *mod, uint32_t codec_id,
9797
uint32_t direction);
9898
int cadence_codec_apply_params(struct processing_module *mod, int size, void *data);
99-
int cadence_codec_process_data(struct processing_module *mod);
99+
int cadence_codec_process_data(struct processing_module *mod, int *api_error_code);
100100
int cadence_codec_apply_config(struct processing_module *mod);
101101
void cadence_codec_free_memory_tables(struct processing_module *mod);
102102
int cadence_codec_init_memory_tables(struct processing_module *mod);

0 commit comments

Comments
 (0)