Skip to content

Commit

Permalink
module: cadence: don't return on non-fatal error
Browse files Browse the repository at this point in the history
Assuming the following pipeline:

   HOST ---> MA (CADENCE [MP3 DECODER]) ---> DAI

for native Zephyr SOF, data is first copied from the host
component to MA and then from Linux to the host component.
This means that the first chunk of data will be 0s (since
the host DMA buffer is zero'd via host_prepare()) instead
of useful data. Because of this, the `XA_CMD_TYPE_INIT_PROCESS`
command will return a non-fatal error (i.e:
`XA_MP3DEC_EXECUTE_NONFATAL_NEXT_SYNC_NOT_FOUND`). This
is not the case for non-native SOF since data is first copied
from Linux to host and then from host to MA so the aforementioned
command will get actual data instead of 0s.

Instead of having to alter the flow of data for native Zephyr
SOF (i.e: change the order in which data is copied), which
could impact other components and bits of the firmware, the
fix is to not return if the command returns a non-fatal error.
This way, the first chunk (i.e: the 0s) will be consumed and
the processing can start with the next chunk.

Signed-off-by: Laurentiu Mihalcea <laurentiu.mihalcea@nxp.com>
  • Loading branch information
LaurentiuM1234 authored and kv2019i committed Apr 15, 2024
1 parent d534df4 commit c592f78
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/audio/module_adapter/module/cadence.c
Original file line number Diff line number Diff line change
Expand Up @@ -608,10 +608,22 @@ static int cadence_codec_init_process(struct processing_module *mod)
}

API_CALL(cd, XA_API_CMD_INIT, XA_CMD_TYPE_INIT_PROCESS, NULL, ret);
if (ret != LIB_NO_ERROR) {
if (LIB_IS_FATAL_ERROR(ret)) {
comp_err(dev, "cadence_codec_init_process() error %x: failed to initialize codec",
ret);
return ret;
} else if (ret != LIB_NO_ERROR) {
/* for SOF with native Zephyr, the first chunk of data will be
* 0s since data is first transferred from host to the next
* component and **then** from Linux to host. Because of this, the
* above API call will return `...NONFATAL_NEXT_SYNC_NOT_FOUND`
* since the API seems to expect useful data in the first chunk.
* To avoid this, print a warning if the above call returns
* a non-fatal error and let the init process continue. Next
* chunk will contain the useful data.
*/
comp_warn(dev, "cadence_codec_init_process() returned non-fatal error: 0x%x",
ret);
}

API_CALL(cd, XA_API_CMD_INIT, XA_CMD_TYPE_INIT_DONE_QUERY,
Expand Down

0 comments on commit c592f78

Please sign in to comment.