module: cadence: don't return on non-fatal error

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>
This commit is contained in:
Laurentiu Mihalcea 2024-04-15 12:44:19 +03:00 committed by Kai Vehmanen
parent d534df477f
commit c592f78e25
1 changed files with 13 additions and 1 deletions

View File

@ -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); 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", comp_err(dev, "cadence_codec_init_process() error %x: failed to initialize codec",
ret); ret);
return 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, API_CALL(cd, XA_API_CMD_INIT, XA_CMD_TYPE_INIT_DONE_QUERY,